@devtable/dashboard 9.2.0 → 9.2.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.
- package/dist/dashboard.es.js +2 -2
- package/dist/dashboard.umd.js +2 -2
- package/package.json +1 -1
package/dist/dashboard.es.js
CHANGED
|
@@ -2128,7 +2128,7 @@ const Ou = (e) => {
|
|
|
2128
2128
|
getColor: xr(["#fff7f1", "darkorange", "#b60000"]),
|
|
2129
2129
|
name: "orange",
|
|
2130
2130
|
category: "sequential"
|
|
2131
|
-
}, Rs = "@devtable/dashboard", Gi = "9.2.
|
|
2131
|
+
}, Rs = "@devtable/dashboard", Gi = "9.2.1", Es = "Apache-2.0", Os = {
|
|
2132
2132
|
access: "public",
|
|
2133
2133
|
registry: "https://registry.npmjs.org/"
|
|
2134
2134
|
}, Vs = [
|
|
@@ -17594,7 +17594,7 @@ function c_(e) {
|
|
|
17594
17594
|
});
|
|
17595
17595
|
}
|
|
17596
17596
|
function xo(e) {
|
|
17597
|
-
return e.includes(",") ? `"${e}"` : e;
|
|
17597
|
+
return typeof e == "string" && e.includes(",") ? `"${e}"` : e;
|
|
17598
17598
|
}
|
|
17599
17599
|
function Bl(e) {
|
|
17600
17600
|
if (!Array.isArray(e) || e.length === 0)
|
package/dist/dashboard.umd.js
CHANGED
|
@@ -24,7 +24,7 @@ Check the render method of \``+_+"`."}return""}}function x1(_){{if(_!==void 0){v
|
|
|
24
24
|
|
|
25
25
|
Check your code at `+M+":"+E+"."}return""}}var io={};function C1(_){{var M=ro();if(!M){var E=typeof _=="string"?_:_.displayName||_.name;E&&(M=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+E+">.")}return M}}function ao(_,M){{if(!_._store||_._store.validated||_.key!=null)return;_._store.validated=!0;var E=C1(M);if(io[E])return;io[E]=!0;var Y="";_&&_._owner&&_._owner!==li.current&&(Y=" It was passed a child from "+oe(_._owner.type)+"."),bt(_),$('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',E,Y),bt(null)}}function so(_,M){{if(typeof _!="object")return;if(si(_))for(var E=0;E<_.length;E++){var Y=_[E];di(Y)&&ao(Y,M)}else if(di(_))_._store&&(_._store.validated=!0);else if(_){var ae=S(_);if(typeof ae=="function"&&ae!==_.entries)for(var ue=ae.call(_),ee;!(ee=ue.next()).done;)di(ee.value)&&ao(ee.value,M)}}}function w1(_){{var M=_.type;if(M==null||typeof M=="string")return;var E;if(typeof M=="function")E=M.propTypes;else if(typeof M=="object"&&(M.$$typeof===d||M.$$typeof===g))E=M.propTypes;else return;if(E){var Y=oe(M);l1(E,_.props,"prop",Y,_)}else if(M.PropTypes!==void 0&&!ui){ui=!0;var ae=oe(M);$("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ae||"Unknown")}typeof M.getDefaultProps=="function"&&!M.getDefaultProps.isReactClassApproved&&$("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function _1(_){{for(var M=Object.keys(_.props),E=0;E<M.length;E++){var Y=M[E];if(Y!=="children"&&Y!=="key"){bt(_),$("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Y),bt(null);break}}_.ref!==null&&(bt(_),$("Invalid attribute `ref` supplied to `React.Fragment`."),bt(null))}}function oo(_,M,E,Y,ae,ue){{var ee=Q(_);if(!ee){var J="";(_===void 0||typeof _=="object"&&_!==null&&Object.keys(_).length===0)&&(J+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Me=x1(ae);Me?J+=Me:J+=ro();var ge;_===null?ge="null":si(_)?ge="array":_!==void 0&&_.$$typeof===t?(ge="<"+(oe(_.type)||"Unknown")+" />",J=" Did you accidentally export a JSX literal instead of a component?"):ge=typeof _,$("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ge,J)}var ye=v1(_,M,E,ae,ue);if(ye==null)return ye;if(ee){var Ee=M.children;if(Ee!==void 0)if(Y)if(si(Ee)){for(var yt=0;yt<Ee.length;yt++)so(Ee[yt],_);Object.freeze&&Object.freeze(Ee)}else $("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 so(Ee,_)}return _===i?_1(ye):w1(ye),ye}}function S1(_,M,E){return oo(_,M,E,!0)}function T1(_,M,E){return oo(_,M,E,!1)}var k1=T1,D1=S1;wt.Fragment=i,wt.jsx=k1,wt.jsxs=D1}()),wt}(function(e){process.env.NODE_ENV==="production"?e.exports=Co():e.exports=wo()})(xo);const B=xt.Fragment,n=xt.jsx,p=xt.jsxs;function $i(e,t){b.useEffect(()=>{const r=i=>{console.log(i);const{viewID:s}=i.detail;if(!s){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(s),t&&e.views.setIDOfVIE(s)};return window.addEventListener("open-view",r),()=>{window.removeEventListener("open-view",r)}},[e,t]),b.useEffect(()=>{const r=i=>{console.log(i);const{dictionary:s,payload:o}=i.detail;if(!o||Object.keys(o).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}Object.entries(s).forEach(([u,l])=>{e.filters.setValueByKey(u,v.get(o,l))})};return window.addEventListener("set-filter-values",r),()=>{window.removeEventListener("set-filter-values",r)}},[e]),b.useEffect(()=>{function r(s){return Array.isArray(s)?[]:typeof s=="object"?{}:typeof s=="boolean"?!1:typeof s=="string"?"":typeof s=="number"?0:s}const i=s=>{console.log(s);const{filter_keys:o}=s.detail;o.forEach(u=>{const l=v.get(e.filters.values,u),d=r(l);console.log(`${u}: ${d}`),e.filters.setValueByKey(u,d)})};return window.addEventListener("clear-filter-values",i),()=>{window.removeEventListener("clear-filter-values",i)}},[e]),b.useEffect(()=>{const r=i=>{console.log(i);const{urlTemplate:s,openInNewTab:o,enableEncoding:u=!1,payload:l}=i.detail;if(!s){console.error(new Error("[Open Link] URL is empty"));return}function d(g){return v.cloneDeepWith(g,m=>{if(u&&typeof m=="string")return encodeURIComponent(m)})}const f=v.template(s||"")(d({...l,filters:e.payloadForSQL.filterValues,context:e.payloadForSQL.context}));window.open(f,o?"_blank":"_self","noopener")};return window.addEventListener("open-link",r),()=>{window.removeEventListener("open-link",r)}},[e])}class _o{constructor(t){O(this,"symbol");this.symbol=Symbol(t)}}function Re(e){return new _o(e)}class mn{constructor(){O(this,"parent");O(this,"factoryRegistry",new Map);O(this,"instanceRegistry",new Map)}createScoped(){const t=new mn;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const r=this.factoryRegistry.get(t.symbol);if(r){const i=r(this);return this.instanceRegistry.set(t.symbol,i),i}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=v.get(t,"dispose");v.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const bn=b.createContext(null);function Gt(e){const t=b.useContext(bn),r=Z.useCreation(()=>e.configure(t||new mn),[e.configure]),i=Z.usePrevious(r);return i&&i!==r&&i.dispose(),n(bn.Provider,{value:r,children:e.children})}function zi(){return b.useContext(bn)}const So={viewPanelInFullScreen:v.noop,inFullScreen:!1},yn=b.createContext(So),Ei=b.createContext(null),vn=Ei.Provider;function me(){const e=b.useContext(Ei);if(!e)throw new Error("Please use ModelContextProvider");return e}const Li=b.createContext(null),xn=Li.Provider;function F(){const e=b.useContext(Li);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const To={layoutFrozen:!1,freezeLayout:v.noop,inEditMode:!1},Ke=b.createContext(To),Pi=b.createContext({panel:null,data:[],loading:!1}),Cn=Pi.Provider;function Ce(){const e=b.useContext(Pi);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const ko={fullScreenPanelID:"",setFullScreenPanelID:v.noop},wn=b.createContext(ko);function Oi(){const e=b.useContext(wn);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}class ke extends b.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const r=()=>{this.setState({error:null})};return p(a.Box,{children:[n(a.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),n(a.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:r,children:"Retry"})]})}return this.props.children}}const _n={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"}},qt=({value:e,styles:t={}})=>{const r=_i.useEditor({extensions:[Si,wi,X.Link,gi,fi,pi,yi.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),Ci,xi,vi,mi.configure({types:["heading","paragraph"]}),hi.configure({placeholder:"This is placeholder"}),bi,ci.Color],content:e,editable:!1});b.useEffect(()=>{r==null||r.commands.setContent(e)},[e,r]);const i=b.useMemo(()=>v.defaultsDeep({},{content:_n},t),[t]);return n(X.RichTextEditor,{editor:r,styles:i,children:n(X.RichTextEditor.Content,{})})},Do=({description:e,isDescriptionEmpty:t})=>t?null:n(a.Tooltip,{color:"white",label:n(qt,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:n(a.Box,{sx:{height:"16px",alignSelf:"center"},children:n(V.IconInfoCircle,{size:16,color:"gray"})})}),Mo=T.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:i,...s},value:o,onChange:u})=>p(a.Box,{children:[n(a.Text,{children:" "}),n(a.Checkbox,{label:p(a.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[n(a.Box,{sx:{flexGrow:1},children:e}),n(Do,{description:r,isDescriptionEmpty:i})]}),checked:o||!1,onChange:l=>u(l.currentTarget.checked),...s,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),Vi=T.observer(({label:e,config:t,value:r=[null,null],onChange:i})=>{const s=Array.isArray(r)?r.map(d=>d?j(d).toDate():null):[null,null],o=d=>{i(d.map(c=>c&&j(c).format(t.inputFormat)))},u=t.getMinDate(s[0]),l=t.getMaxDate(s[0]);return n(uo.DateRangePicker,{label:e,value:s,onChange:o,icon:n(k.Calendar,{size:16}),sx:{minWidth:"16em"},minDate:u,maxDate:l,styles:{input:{borderColor:"#e9ecef"}},...t})}),Io=a.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-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:e.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:e.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}}}})),Ao=({disabled:e,classNames:t,styles:r,unstyled:i,radius:s,style:o,label:u,value:l,onChange:d,options:c})=>{const{classes:f,cx:g}=Io({radius:s},{name:"MultiSelectWidget",classNames:t,styles:r,unstyled:i}),[h,m]=b.useState((l==null?void 0:l.length)>0),w=P=>{m(P)},C=h&&(l==null?void 0:l.length)>0,[S,I]=b.useState(""),$=b.useMemo(()=>{if(!S)return c;const P=S.toLowerCase(),q=L=>L.description.toLowerCase().includes(P)||L.label.toLowerCase().includes(P);return c.filter(q)},[S,c]);return p(a.Stack,{spacing:3,children:[p(a.Group,{position:"apart",children:[n(a.Text,{className:f.label,children:u}),C&&n(a.Tooltip,{label:`${l.length} selected`,children:n(a.Badge,{children:l.length})})]}),n(Ti,{disabled:e,allowClear:!0,className:g(f.root,"check-select"),dropdownClassName:g(f.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:o,clearIcon:()=>n(a.CloseButton,{}),value:l,onChange:d,onSelect:console.log,mode:"multiple",maxTagCount:0,maxTagTextLength:10,maxTagPlaceholder:P=>`${P.length} selected`,searchValue:S,onSearch:I,filterOption:!1,children:$.map(P=>n(Ti.Option,{children:n(a.Group,{noWrap:!0,children:p("div",{children:[n(a.Text,{size:"sm","data-role":"label",children:P.label}),n(a.Text,{size:"xs",color:"dimmed","data-role":"description",children:P.description})]})})},P.value))})]})},$o=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=F(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading",d=t.min_width?t.min_width:"200px",c=o?l:!1;return n(Ao,{label:e,options:t.options,style:{minWidth:"160px",width:d,maxWidth:c?d:"unset",borderColor:"#e9ecef"},disabled:c,value:r,onChange:i})}),zo=b.forwardRef(({label:e,description:t,...r},i)=>n("div",{ref:i,...r,children:n(a.Group,{noWrap:!0,children:p("div",{children:[n(a.Text,{size:"sm","data-role":"label",children:e}),n(a.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),Eo=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=F(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading";return b.useEffect(()=>{var f;const{default_selection_count:d}=t;if(!d)return;const c=((f=t.options[0])==null?void 0:f.value)??"";console.log("Selecting the first option by default. New value: ",c),i(c,!0)},[t.default_selection_count,t.options]),n(a.Select,{label:e,data:t.options,disabled:o?l:!1,value:r,onChange:i,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"}},itemComponent:zo})});function Lo({label:e,config:t,value:r,onChange:i}){return n(a.TextInput,{label:e,value:r||"",onChange:s=>i(s.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}function Po(e){return co.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}const Oo=({rotate:e,onClick:t})=>n("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:n("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),Vo=({expanded:e,isLeaf:t,value:r,onClick:i,...s})=>(r==="0-0-value"&&console.log(s),t?n("span",{style:{width:"14px",display:"inline-block"}}):n(Oo,{rotate:e?"0":"-90",onClick:i,...s})),Bo=({onClick:e})=>p("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[n("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),n("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),n("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),n("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),No=({onClick:e,...t})=>n(Bo,{onClick:e,...t}),Go=a.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),qo=({disabled:e,classNames:t,styles:r,unstyled:i,radius:s,style:o,label:u,value:l,onChange:d,treeData:c})=>{const{classes:f,cx:g}=Go({radius:s},{name:"FilterTreeSelectWidget",classNames:t,styles:r,unstyled:i}),[h,m]=b.useState((l==null?void 0:l.length)>0),w=S=>{m(S)},C=h&&(l==null?void 0:l.length)>0;return p(a.Stack,{spacing:3,children:[p(a.Group,{position:"apart",children:[n(a.Text,{className:f.label,children:u}),C&&n(a.Tooltip,{label:`${l.length} selected`,children:n(a.Badge,{children:l.length})})]}),n(ki,{disabled:e,allowClear:!0,className:g(f.root,"check-select"),dropdownClassName:g(f.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,treeLine:!0,clearIcon:()=>n(a.CloseButton,{}),switcherIcon:Vo,treeIcon:No,maxTagTextLength:10,value:l,treeData:c,treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:ki.SHOW_PARENT,onChange:d,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:S=>`${S.length} selected`})]})};function Fo(e){return e.map(t=>{const{label:r,description:i,...s}=t,o={...s,filterBasis:`${r}___${i??""}`,description:i,label:r};return i&&(o.label=p("div",{children:[n(a.Text,{title:t.label,children:t.label}),n(a.Text,{className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description,children:t.description})]})),o})}const Wo=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=F(),{state:o,dataProxy:u,len:l}=s.getDataStuffByID(t.options_query_id),d=o==="loading",c=b.useMemo(()=>{if(!u)return[];const m=[...u],w=Fo(m);return Po(w)},[u,l]);b.useEffect(()=>{const{default_selection_count:m}=t;if(!m)return;if(c.length===0){console.log("[filter.tree-select] Resetting to empty"),i([],!0);return}const w=c.slice(0,m).map(C=>C.value);console.log(`[filter.tree-select] Selecting first ${m} option(s)`),i(w,!0)},[t.default_selection_count,c]);const f=t.min_width?t.min_width:"200px",h=!!t.options_query_id?d:!1;return n(qo,{disabled:h,style:{minWidth:"160px",width:f,maxWidth:h?f:"unset",borderColor:"#e9ecef"},value:r,onChange:m=>i(m,!1),treeData:c,label:e})}),jo=T.observer(({filter:{type:e,config:t,key:r,...i},formFieldProps:s})=>{switch(e){case"select":return n(Eo,{...i,...s,config:t});case"multi-select":return n($o,{...i,...s,config:t});case"tree-select":return n(Wo,{...i,...s,config:t});case"text-input":return n(Lo,{...i,...s,config:t});case"date-range":return n(Vi,{...i,...s,config:t});case"checkbox":return n(Mo,{...i,...s,config:t});default:return null}}),Bi=T.observer(b.forwardRef(({filter:e,...t},r)=>n("div",{className:"filter-root",ref:r,children:n(ke,{children:n(jo,{filter:e,formFieldProps:t})})}))),Ni=T.observer(function({view:t}){const r=F(),{control:i,handleSubmit:s,reset:o}=x.useForm({defaultValues:r.filters.values,reValidateMode:"onBlur"}),u=x.useWatch({control:i});b.useEffect(()=>{o(r.filters.values)},[r.filters.values,o]),b.useEffect(()=>{r.filters.updatePreviewValues(u)},[u]);const l=r.filters.visibleInView(t.id),d=b.useMemo(()=>l.every(h=>h.should_auto_submit),[l]),c=b.useMemo(()=>l.filter(h=>v.get(h,"config.required",!1)),[l]),f=b.useMemo(()=>c.length===0?!1:c.some(h=>!h.requiredAndPass(u[h.key])),[u,c]);if(l.length===0)return null;const g=(h,m)=>(w,C)=>{m(w),(h.should_auto_submit||C)&&r.filters.setValueByKey(h.key,w)};return n("form",{onSubmit:s(r.filters.setValues),children:p(a.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:d?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n(a.Group,{align:"flex-start",children:l.map(h=>n(x.Controller,{name:h.key,control:i,render:({field:m})=>n(Bi,{filter:h,value:m.value,onChange:g(h,m.onChange)})},h.id))}),!d&&n(a.Group,{sx:{alignSelf:"flex-end"},children:n(a.Button,{color:"blue",size:"sm",type:"submit",disabled:f,children:"Search"})})]})})}),$1="";function Ro(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const Gi=T.observer(()=>{const{freezeLayout:e}=b.useContext(Ke),[t,r]=b.useState(!1),{panel:i}=Ce();return b.useEffect(()=>{e(t)},[t]),Ro(i.description)?null:p(B,{children:[n(a.Modal,{opened:t,onClose:()=>r(!1),title:i.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:n(qt,{value:i.description,styles:{root:{border:"none"},content:{padding:0}}})}),n(a.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(s=>!s),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n(k.InfoCircle,{size:20})})})]})}),Yo=T.observer(({view:e})=>{const t=me(),r=F(),i=Le.useModals(),{panel:s}=Ce(),{id:o,query:u}=s,{inEditMode:l}=b.useContext(Ke),d=()=>u==null?void 0:u.fetchData(),{viewPanelInFullScreen:c,inFullScreen:f}=b.useContext(yn),g=()=>{r.duplicatePanelByID(o,e.id)},h=()=>{t.editor.open(["_VIEWS_",e.id,"_PANELS_",o])},m=()=>i.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>r.removePanelByID(o,e.id),confirmProps:{color:"red"},zIndex:320}),w=b.useCallback(()=>{c(o)},[o,c]),C=!f&&e.type!==K.Modal;return n(B,{children:n(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(a.Menu,{withinPortal:!0,children:[n(a.Menu.Target,{children:n(a.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),p(a.Menu.Dropdown,{children:[n(a.Menu.Item,{onClick:d,icon:n(k.Refresh,{size:14}),children:"Refresh"}),n(a.Menu.Item,{onClick:()=>r.queries.downloadDataByQueryID((u==null?void 0:u.id)??""),icon:n(k.Download,{size:14}),children:"Download Data"}),C&&n(a.Menu.Item,{onClick:w,icon:n(k.ArrowsMaximize,{size:14}),disabled:l,children:"Full Screen"}),l&&p(B,{children:[n(a.Divider,{label:"Edit",labelPosition:"center"}),n(a.Menu.Item,{onClick:h,icon:n(k.Settings,{size:14}),children:"Settings"}),n(a.Menu.Item,{onClick:g,icon:n(k.Copy,{size:14}),children:"Duplicate"}),n(a.Menu.Item,{color:"red",onClick:m,icon:n(k.Trash,{size:14}),children:"Delete"})]})]})]})})})}),z1="",Qo=T.observer(function(){const{panel:t}=Ce(),{title:r}=t;return r?n(a.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:n(a.Text,{align:"center",lineClamp:1,weight:"bold",children:r})}):null}),Ne=(e,t)=>{const[r,i]=b.useState([]);return b.useEffect(()=>e.watchTriggerSnapshotList(s=>i(s.filter(o=>o.schemaRef===t))),[]),r};class lt{constructor(t,r){this.root=t,this.path=r}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,v.omit(r,t))}async getItem(t){const r=await this.root.getItem(this.path);return t===null?r:v.get(r,t)}async setItem(t,r){if(t===null)await this.root.setItem(this.path,r);else{const i=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...i,[t]:r})}return await this.getItem(t)}watchItem(t,r,i){return t===null?this.root.watchItem(this.path,(s,o)=>{r(s,o)},i):this.root.watchItem(this.path,(s,o)=>{const u=v.get(s,t),l=v.get(o,t);u!==l&&r(u,l)},i)}}class Sn{constructor(t,r,i){O(this,"attachmentStorage");this.instance=t,this.attachmentKey=r,this.constructInstance=i,this.attachmentStorage=new lt(t.instanceData,r)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new lt(this.attachmentStorage,t))}async create(t,r){return await this.attachmentStorage.setItem(t,r),this.constructInstance(new lt(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(v.values(t).map(r=>this.constructInstance(new lt(this.attachmentStorage,r.id))))}}class qi{constructor(t){O(this,"rootRef");this.rootRef=se.observable({current:t})}async deleteItem(t){se.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?se.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(v.isObject(r))se.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else se.runInAction(()=>{v.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,i){return se.reaction(()=>this.getValueFromRoot(t),(s,o)=>{r(s,o)},{requiresObservable:!0,fireImmediately:v.get(i,"fireImmediately",!1)})}}class Uo{constructor(){O(this,"channels",new Map);O(this,"globalChannel",new Di)}getChannel(t){const r=this.channels.get(t);if(r)return r;const i=new Di;return this.channels.set(t,i),i}}class Xo{constructor(t){O(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const r=this.instances.get(t.id);if(r)return r;const i={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Uo,instanceData:new qi(t.viz.conf)};return this.instances.set(t.id,i),i}}function Fi(e,t,r,i){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new qi({}),colorPalette:{getColor(){return()=>""}},data:t,variables:i}}const Zo=e=>{const{panel:t,vizManager:r,data:i,variables:s}=e,o=r.resolveComponent(t.viz.type),u=r.getOrCreateInstance(t),l={...Fi(u,i,r,s),viewport:{width:t.layout.w,height:t.layout.h}},d=o.viewRender;return n(d,{context:l,instance:u,...v.omit(e,["panel","vizManager","data"])})},Ko=e=>{const{vizManager:t,panel:r,panelInfoEditor:i,data:s,variables:o}=e,u=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),d={...Fi(l,s,t,o),panelInfoEditor:i},c=u.configRender;return n(c,{context:d,instance:l,...v.omit(e,["panel","vizManager","data","panelInfoEditor"])})},Wi=(e,t)=>{const r=je.bezier(e),i=je.bezier(t);return function(s){return s<50?r(s*2/100).hex():i((s-50)*2/100).hex()}},Ft=e=>{const t=je.bezier(e);return function(r){return t(r/100).hex()}},Jo={type:"interpolation",displayName:"Red / Green",getColor:Wi(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Ho={type:"interpolation",displayName:"Yellow / Blue",getColor:Wi(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},el={type:"interpolation",displayName:"Red",getColor:Ft(["#fff7f1","darkred"]),name:"red",category:"sequential"},tl={type:"interpolation",displayName:"Green",getColor:Ft(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},nl={type:"interpolation",displayName:"Blue",getColor:Ft(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},rl={type:"interpolation",displayName:"Orange",getColor:Ft(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},ji="@devtable/dashboard",Tn="9.2.0",Ri="Apache-2.0",Yi={access:"public",registry:"https://registry.npmjs.org/"},Qi=["dist"],Ui="./dist/dashboard.umd.js",Xi="./dist/dashboard.es.js",Zi="./dist/index.d.ts",Ki={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Ji={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},Hi={"@monaco-editor/react":"4.4.6","@types/chroma-js":"^2.1.4","file-saver":"2.0.5",mathjs:"11.8.0","monaco-editor":"0.36.0","performant-array-to-tree":"1.11.0",popmotion:"^11.0.3","rc-select":"14.1.0","rc-tree-select":"5.5.5",reactflow:"^11.5.3"},ea={"@emotion/babel-plugin":"11.10.6","@faker-js/faker":"7.6.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"1.119.0","@testing-library/cypress":"^9.0.0","@testing-library/jest-dom":"^5.16.4","@testing-library/react":"^13.3.0","@testing-library/react-hooks":"^8.0.1","@testing-library/user-event":"^14.3.0","@tiptap/extension-code-block-lowlight":"2.0.3","@tiptap/extension-color":"2.0.3","@tiptap/extension-highlight":"2.0.3","@tiptap/extension-link":"2.0.3","@tiptap/extension-placeholder":"2.0.3","@tiptap/extension-subscript":"2.0.3","@tiptap/extension-superscript":"2.0.3","@tiptap/extension-table":"2.0.3","@tiptap/extension-table-cell":"2.0.3","@tiptap/extension-table-header":"2.0.3","@tiptap/extension-table-row":"2.0.3","@tiptap/extension-text-align":"2.0.3","@tiptap/extension-text-style":"2.0.3","@tiptap/extension-underline":"2.0.3","@tiptap/pm":"2.0.3","@tiptap/react":"2.0.3","@tiptap/starter-kit":"2.0.3","@types/crypto-js":"v4.1.1","@types/d3-array":"3.0.4","@types/eventemitter2":"^4.1.0","@types/file-saver":"2.0.5","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2",ahooks:"^3.3.11",ajv:"8.12.0",axios:"^0.27.2","crypto-js":"^4.1.1",cypress:"^12.9.0","cypress-wait-until":"^1.7.2",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",jsdom:"^20.0.0","jsdom-testing-mocks":"^1.5.0",lodash:"^4.17.21",lowlight:"^2.8.0",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","rollup-plugin-visualizer":"5.6.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3","vite-plugin-static-copy":"0.13.1"},ta={"@emotion/react":"11.10.6","@faker-js/faker":"7.6.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"1.119.0","@tanstack/react-table":"^8.5.13","@tiptap/extension-code-block-lowlight":"2.0.3","@tiptap/extension-color":"2.0.3","@tiptap/extension-highlight":"2.0.3","@tiptap/extension-link":"2.0.3","@tiptap/extension-placeholder":"2.0.3","@tiptap/extension-subscript":"2.0.3","@tiptap/extension-superscript":"2.0.3","@tiptap/extension-table":"2.0.3","@tiptap/extension-table-cell":"2.0.3","@tiptap/extension-table-header":"2.0.3","@tiptap/extension-table-row":"2.0.3","@tiptap/extension-text-align":"2.0.3","@tiptap/extension-text-style":"2.0.3","@tiptap/extension-underline":"2.0.3","@tiptap/pm":"2.0.3","@tiptap/react":"2.0.3","@tiptap/starter-kit":"2.0.3",ahooks:"^3.3.11",axios:"^0.27.2","chroma-js":"^2.4.2","crypto-js":"^4.1.1","d3-array":"3.2.3","d3-regression":"1.3.10",dayjs:"1.11.7",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",eventemitter2:"^6.4.6",jszip:"3.10.1",lodash:"^4.17.21",lowlight:"^2.8.0",mobx:"^6.6.1","mobx-react-lite":"^3.4.0","mobx-state-tree":"^5.1.5",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","react-router-dom":"^6.3.0","react-virtual":"^2.10.4","tabler-icons-react":"^1.48.0"},il=Object.freeze(Object.defineProperty({__proto__:null,default:{name:ji,version:Tn,license:Ri,publishConfig:Yi,files:Qi,main:Ui,module:Xi,types:Zi,exports:Ki,scripts:Ji,dependencies:Hi,devDependencies:ea,peerDependencies:ta},dependencies:Hi,devDependencies:ea,exports:Ki,files:Qi,license:Ri,main:Ui,module:Xi,name:ji,peerDependencies:ta,publishConfig:Yi,scripts:Ji,types:Zi,version:Tn},Symbol.toStringTag,{value:"Module"}));class al{constructor(t){O(this,"staticColors",new Map);O(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(i=>{this.register(i)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(r,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class sl{constructor(){O(this,"plugins",new Map);O(this,"vizComponents",new Map);O(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class ol{constructor(){O(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,i){var u;if(t.from===t.to)return r;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const s=this.migrations.filter(l=>l.version>t.from&&l.version<=t.to),o=v.orderBy(s,"version","asc");if(((u=v.last(o))==null?void 0:u.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((l,d)=>d.handler(l,i),r)}}class he extends ol{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(i,s)=>({version:t,...r(i,s)}))}async migrate({configData:t,panelModel:r}){const i=await t.getItem(null),s=v.get(i,"version",0),o=this.run({from:s,to:this.VERSION},i,{panelModel:r});await t.setItem(null,o)}async needMigration({configData:t}){const r=await t.getItem(null);return v.get(r,"version",0)<this.VERSION}}const W=(e,t)=>{const[r,{setFalse:i}]=Z.useBoolean(!0),[s,o]=b.useState();b.useEffect(()=>(e.getItem(t).then(l=>{o(l),i()}),e.watchItem(t,l=>{o(l)})));const u=b.useCallback(async l=>{await e.setItem(t,l),o(l)},[e,t]);return{loading:r,value:s,set:u}},kn={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"}};le.use([N.GridComponent,N.VisualMapComponent,N.LegendComponent,N.TooltipComponent,Ie.CanvasRenderer]);function ll({context:e}){const{value:t}=W(e.instanceData,"config"),r=e.data,{width:i,height:s}=e.viewport,{x_axis_data_key:o,y_axis_data_key:u,z_axis_data_key:l,xAxis3D:d,yAxis3D:c,zAxis3D:f}=v.defaults({},t,kn),g=b.useMemo(()=>{const w=v.minBy(r,C=>C[l]);return v.get(w,l)},[r,l]),h=b.useMemo(()=>{const w=v.maxBy(r,C=>C[l]);return v.get(w,l)},[r,l]),m={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:g,max:h,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:d,yAxis3D:c,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:r.map(w=>[w[o],w[u],w[l]])}]};return t?n(Ae,{echarts:le,option:m,style:{width:i,height:s},notMerge:!0,theme:"merico-light"}):null}function ul({label:e,required:t,value:r,onChange:i,data:s,clearable:o=!1,sx:u,...l},d){const c=b.useMemo(()=>{if(!Array.isArray(s)||s.length===0)return[];const g=Object.keys(s[0]).map(h=>({label:h,value:h}));return o?g.concat([{label:"unset",value:""}]):g},[s]);return n(a.Select,{ref:d,label:e,data:c,value:r,onChange:i,required:t,sx:u,...l})}const R=b.forwardRef(ul);function dl({context:e}){const{value:t,set:r}=W(e.instanceData,"config"),i=e.data,s=v.defaults({},t,kn),{control:o,handleSubmit:u,reset:l}=x.useForm({defaultValues:s});return b.useEffect(()=>{l(s)},[t]),t?n(a.Stack,{spacing:"xs",children:p("form",{onSubmit:u(r),children:[n(a.Text,{children:"X Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"x_axis_data_key",control:o,render:({field:d})=>n(R,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"xAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Y Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"y_axis_data_key",control:o,render:({field:d})=>n(R,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"yAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Z Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"z_axis_data_key",control:o,render:({field:d})=>n(R,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"zAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(a.Button,{color:"blue",type:"submit",children:[n(k.DeviceFloppy,{size:20}),n(a.Text,{ml:"md",children:"Save"})]})})]})}):null}class cl extends he{constructor(){super(...arguments);O(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const pl={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new cl,name:"bar-3d",viewRender:ll,configRender:dl,createConfig(){return{version:1,config:v.cloneDeep(kn)}}},Se={mantissa:0,output:"number",trimMantissa:!1,average:!1};function hl({value:e,onChange:t},r){const i=l=>{t({...e,output:l})},s=l=>{const d=l===0?!1:e.trimMantissa;t({...e,mantissa:l,trimMantissa:d})},o=l=>{t({...e,trimMantissa:l.currentTarget.checked})},u=l=>{t({...e,average:l.currentTarget.checked})};return p(a.Stack,{ref:r,children:[p(a.Group,{grow:!0,children:[n(a.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:i,sx:{flexGrow:1}}),n(a.Switch,{label:p(a.Stack,{spacing:0,children:[n(a.Text,{children:"Average"}),n(a.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:u,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(a.Group,{grow:!0,children:[n(a.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:s}),n(a.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(a.Stack,{spacing:0,children:[n(a.Text,{weight:"bold",children:"Preview"}),n(ke,{children:p(a.Group,{position:"apart",children:[p(a.Text,{size:12,color:"gray",children:["123456789 ",n(k.ArrowRight,{size:9})," ",te(123456789).format(e)]}),p(a.Text,{size:12,color:"gray",children:["1234 ",n(k.ArrowRight,{size:9})," ",te(1234).format(e)]}),p(a.Text,{size:12,color:"gray",children:["0.1234 ",n(k.ArrowRight,{size:9})," ",te(.1234).format(e)]})]})})]})]})}const Oe=b.forwardRef(hl),Ge={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
27
|
+
Check the top-level render call using <`+E+">.")}return M}}function ao(_,M){{if(!_._store||_._store.validated||_.key!=null)return;_._store.validated=!0;var E=C1(M);if(io[E])return;io[E]=!0;var Y="";_&&_._owner&&_._owner!==li.current&&(Y=" It was passed a child from "+oe(_._owner.type)+"."),bt(_),$('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',E,Y),bt(null)}}function so(_,M){{if(typeof _!="object")return;if(si(_))for(var E=0;E<_.length;E++){var Y=_[E];di(Y)&&ao(Y,M)}else if(di(_))_._store&&(_._store.validated=!0);else if(_){var ae=S(_);if(typeof ae=="function"&&ae!==_.entries)for(var ue=ae.call(_),ee;!(ee=ue.next()).done;)di(ee.value)&&ao(ee.value,M)}}}function w1(_){{var M=_.type;if(M==null||typeof M=="string")return;var E;if(typeof M=="function")E=M.propTypes;else if(typeof M=="object"&&(M.$$typeof===d||M.$$typeof===g))E=M.propTypes;else return;if(E){var Y=oe(M);l1(E,_.props,"prop",Y,_)}else if(M.PropTypes!==void 0&&!ui){ui=!0;var ae=oe(M);$("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ae||"Unknown")}typeof M.getDefaultProps=="function"&&!M.getDefaultProps.isReactClassApproved&&$("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function _1(_){{for(var M=Object.keys(_.props),E=0;E<M.length;E++){var Y=M[E];if(Y!=="children"&&Y!=="key"){bt(_),$("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",Y),bt(null);break}}_.ref!==null&&(bt(_),$("Invalid attribute `ref` supplied to `React.Fragment`."),bt(null))}}function oo(_,M,E,Y,ae,ue){{var ee=Q(_);if(!ee){var J="";(_===void 0||typeof _=="object"&&_!==null&&Object.keys(_).length===0)&&(J+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Me=x1(ae);Me?J+=Me:J+=ro();var ge;_===null?ge="null":si(_)?ge="array":_!==void 0&&_.$$typeof===t?(ge="<"+(oe(_.type)||"Unknown")+" />",J=" Did you accidentally export a JSX literal instead of a component?"):ge=typeof _,$("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ge,J)}var ye=v1(_,M,E,ae,ue);if(ye==null)return ye;if(ee){var Ee=M.children;if(Ee!==void 0)if(Y)if(si(Ee)){for(var yt=0;yt<Ee.length;yt++)so(Ee[yt],_);Object.freeze&&Object.freeze(Ee)}else $("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 so(Ee,_)}return _===i?_1(ye):w1(ye),ye}}function S1(_,M,E){return oo(_,M,E,!0)}function T1(_,M,E){return oo(_,M,E,!1)}var k1=T1,D1=S1;wt.Fragment=i,wt.jsx=k1,wt.jsxs=D1}()),wt}(function(e){process.env.NODE_ENV==="production"?e.exports=Co():e.exports=wo()})(xo);const B=xt.Fragment,n=xt.jsx,p=xt.jsxs;function $i(e,t){b.useEffect(()=>{const r=i=>{console.log(i);const{viewID:s}=i.detail;if(!s){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(s),t&&e.views.setIDOfVIE(s)};return window.addEventListener("open-view",r),()=>{window.removeEventListener("open-view",r)}},[e,t]),b.useEffect(()=>{const r=i=>{console.log(i);const{dictionary:s,payload:o}=i.detail;if(!o||Object.keys(o).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}Object.entries(s).forEach(([u,l])=>{e.filters.setValueByKey(u,v.get(o,l))})};return window.addEventListener("set-filter-values",r),()=>{window.removeEventListener("set-filter-values",r)}},[e]),b.useEffect(()=>{function r(s){return Array.isArray(s)?[]:typeof s=="object"?{}:typeof s=="boolean"?!1:typeof s=="string"?"":typeof s=="number"?0:s}const i=s=>{console.log(s);const{filter_keys:o}=s.detail;o.forEach(u=>{const l=v.get(e.filters.values,u),d=r(l);console.log(`${u}: ${d}`),e.filters.setValueByKey(u,d)})};return window.addEventListener("clear-filter-values",i),()=>{window.removeEventListener("clear-filter-values",i)}},[e]),b.useEffect(()=>{const r=i=>{console.log(i);const{urlTemplate:s,openInNewTab:o,enableEncoding:u=!1,payload:l}=i.detail;if(!s){console.error(new Error("[Open Link] URL is empty"));return}function d(g){return v.cloneDeepWith(g,m=>{if(u&&typeof m=="string")return encodeURIComponent(m)})}const f=v.template(s||"")(d({...l,filters:e.payloadForSQL.filterValues,context:e.payloadForSQL.context}));window.open(f,o?"_blank":"_self","noopener")};return window.addEventListener("open-link",r),()=>{window.removeEventListener("open-link",r)}},[e])}class _o{constructor(t){O(this,"symbol");this.symbol=Symbol(t)}}function Re(e){return new _o(e)}class mn{constructor(){O(this,"parent");O(this,"factoryRegistry",new Map);O(this,"instanceRegistry",new Map)}createScoped(){const t=new mn;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const r=this.factoryRegistry.get(t.symbol);if(r){const i=r(this);return this.instanceRegistry.set(t.symbol,i),i}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=v.get(t,"dispose");v.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const bn=b.createContext(null);function Gt(e){const t=b.useContext(bn),r=Z.useCreation(()=>e.configure(t||new mn),[e.configure]),i=Z.usePrevious(r);return i&&i!==r&&i.dispose(),n(bn.Provider,{value:r,children:e.children})}function zi(){return b.useContext(bn)}const So={viewPanelInFullScreen:v.noop,inFullScreen:!1},yn=b.createContext(So),Ei=b.createContext(null),vn=Ei.Provider;function me(){const e=b.useContext(Ei);if(!e)throw new Error("Please use ModelContextProvider");return e}const Li=b.createContext(null),xn=Li.Provider;function F(){const e=b.useContext(Li);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const To={layoutFrozen:!1,freezeLayout:v.noop,inEditMode:!1},Ke=b.createContext(To),Pi=b.createContext({panel:null,data:[],loading:!1}),Cn=Pi.Provider;function Ce(){const e=b.useContext(Pi);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const ko={fullScreenPanelID:"",setFullScreenPanelID:v.noop},wn=b.createContext(ko);function Oi(){const e=b.useContext(wn);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}class ke extends b.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const r=()=>{this.setState({error:null})};return p(a.Box,{children:[n(a.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),n(a.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:r,children:"Retry"})]})}return this.props.children}}const _n={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"}},qt=({value:e,styles:t={}})=>{const r=_i.useEditor({extensions:[Si,wi,X.Link,gi,fi,pi,yi.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),Ci,xi,vi,mi.configure({types:["heading","paragraph"]}),hi.configure({placeholder:"This is placeholder"}),bi,ci.Color],content:e,editable:!1});b.useEffect(()=>{r==null||r.commands.setContent(e)},[e,r]);const i=b.useMemo(()=>v.defaultsDeep({},{content:_n},t),[t]);return n(X.RichTextEditor,{editor:r,styles:i,children:n(X.RichTextEditor.Content,{})})},Do=({description:e,isDescriptionEmpty:t})=>t?null:n(a.Tooltip,{color:"white",label:n(qt,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:n(a.Box,{sx:{height:"16px",alignSelf:"center"},children:n(V.IconInfoCircle,{size:16,color:"gray"})})}),Mo=T.observer(({label:e,config:{default_value:t,description:r,isDescriptionEmpty:i,...s},value:o,onChange:u})=>p(a.Box,{children:[n(a.Text,{children:" "}),n(a.Checkbox,{label:p(a.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[n(a.Box,{sx:{flexGrow:1},children:e}),n(Do,{description:r,isDescriptionEmpty:i})]}),checked:o||!1,onChange:l=>u(l.currentTarget.checked),...s,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),Vi=T.observer(({label:e,config:t,value:r=[null,null],onChange:i})=>{const s=Array.isArray(r)?r.map(d=>d?j(d).toDate():null):[null,null],o=d=>{i(d.map(c=>c&&j(c).format(t.inputFormat)))},u=t.getMinDate(s[0]),l=t.getMaxDate(s[0]);return n(uo.DateRangePicker,{label:e,value:s,onChange:o,icon:n(k.Calendar,{size:16}),sx:{minWidth:"16em"},minDate:u,maxDate:l,styles:{input:{borderColor:"#e9ecef"}},...t})}),Io=a.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-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:e.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:e.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}}}})),Ao=({disabled:e,classNames:t,styles:r,unstyled:i,radius:s,style:o,label:u,value:l,onChange:d,options:c})=>{const{classes:f,cx:g}=Io({radius:s},{name:"MultiSelectWidget",classNames:t,styles:r,unstyled:i}),[h,m]=b.useState((l==null?void 0:l.length)>0),w=P=>{m(P)},C=h&&(l==null?void 0:l.length)>0,[S,I]=b.useState(""),$=b.useMemo(()=>{if(!S)return c;const P=S.toLowerCase(),q=L=>L.description.toLowerCase().includes(P)||L.label.toLowerCase().includes(P);return c.filter(q)},[S,c]);return p(a.Stack,{spacing:3,children:[p(a.Group,{position:"apart",children:[n(a.Text,{className:f.label,children:u}),C&&n(a.Tooltip,{label:`${l.length} selected`,children:n(a.Badge,{children:l.length})})]}),n(Ti,{disabled:e,allowClear:!0,className:g(f.root,"check-select"),dropdownClassName:g(f.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:o,clearIcon:()=>n(a.CloseButton,{}),value:l,onChange:d,onSelect:console.log,mode:"multiple",maxTagCount:0,maxTagTextLength:10,maxTagPlaceholder:P=>`${P.length} selected`,searchValue:S,onSearch:I,filterOption:!1,children:$.map(P=>n(Ti.Option,{children:n(a.Group,{noWrap:!0,children:p("div",{children:[n(a.Text,{size:"sm","data-role":"label",children:P.label}),n(a.Text,{size:"xs",color:"dimmed","data-role":"description",children:P.description})]})})},P.value))})]})},$o=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=F(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading",d=t.min_width?t.min_width:"200px",c=o?l:!1;return n(Ao,{label:e,options:t.options,style:{minWidth:"160px",width:d,maxWidth:c?d:"unset",borderColor:"#e9ecef"},disabled:c,value:r,onChange:i})}),zo=b.forwardRef(({label:e,description:t,...r},i)=>n("div",{ref:i,...r,children:n(a.Group,{noWrap:!0,children:p("div",{children:[n(a.Text,{size:"sm","data-role":"label",children:e}),n(a.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),Eo=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=F(),o=!!t.options_query_id,{state:u}=s.getDataStuffByID(t.options_query_id),l=u==="loading";return b.useEffect(()=>{var f;const{default_selection_count:d}=t;if(!d)return;const c=((f=t.options[0])==null?void 0:f.value)??"";console.log("Selecting the first option by default. New value: ",c),i(c,!0)},[t.default_selection_count,t.options]),n(a.Select,{label:e,data:t.options,disabled:o?l:!1,value:r,onChange:i,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"}},itemComponent:zo})});function Lo({label:e,config:t,value:r,onChange:i}){return n(a.TextInput,{label:e,value:r||"",onChange:s=>i(s.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}function Po(e){return co.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}const Oo=({rotate:e,onClick:t})=>n("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:n("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),Vo=({expanded:e,isLeaf:t,value:r,onClick:i,...s})=>(r==="0-0-value"&&console.log(s),t?n("span",{style:{width:"14px",display:"inline-block"}}):n(Oo,{rotate:e?"0":"-90",onClick:i,...s})),Bo=({onClick:e})=>p("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[n("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),n("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),n("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),n("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),No=({onClick:e,...t})=>n(Bo,{onClick:e,...t}),Go=a.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),qo=({disabled:e,classNames:t,styles:r,unstyled:i,radius:s,style:o,label:u,value:l,onChange:d,treeData:c})=>{const{classes:f,cx:g}=Go({radius:s},{name:"FilterTreeSelectWidget",classNames:t,styles:r,unstyled:i}),[h,m]=b.useState((l==null?void 0:l.length)>0),w=S=>{m(S)},C=h&&(l==null?void 0:l.length)>0;return p(a.Stack,{spacing:3,children:[p(a.Group,{position:"apart",children:[n(a.Text,{className:f.label,children:u}),C&&n(a.Tooltip,{label:`${l.length} selected`,children:n(a.Badge,{children:l.length})})]}),n(ki,{disabled:e,allowClear:!0,className:g(f.root,"check-select"),dropdownClassName:g(f.dropdown,""),onDropdownVisibleChange:w,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,treeLine:!0,clearIcon:()=>n(a.CloseButton,{}),switcherIcon:Vo,treeIcon:No,maxTagTextLength:10,value:l,treeData:c,treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:ki.SHOW_PARENT,onChange:d,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:S=>`${S.length} selected`})]})};function Fo(e){return e.map(t=>{const{label:r,description:i,...s}=t,o={...s,filterBasis:`${r}___${i??""}`,description:i,label:r};return i&&(o.label=p("div",{children:[n(a.Text,{title:t.label,children:t.label}),n(a.Text,{className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description,children:t.description})]})),o})}const Wo=T.observer(({label:e,config:t,value:r,onChange:i})=>{const s=F(),{state:o,dataProxy:u,len:l}=s.getDataStuffByID(t.options_query_id),d=o==="loading",c=b.useMemo(()=>{if(!u)return[];const m=[...u],w=Fo(m);return Po(w)},[u,l]);b.useEffect(()=>{const{default_selection_count:m}=t;if(!m)return;if(c.length===0){console.log("[filter.tree-select] Resetting to empty"),i([],!0);return}const w=c.slice(0,m).map(C=>C.value);console.log(`[filter.tree-select] Selecting first ${m} option(s)`),i(w,!0)},[t.default_selection_count,c]);const f=t.min_width?t.min_width:"200px",h=!!t.options_query_id?d:!1;return n(qo,{disabled:h,style:{minWidth:"160px",width:f,maxWidth:h?f:"unset",borderColor:"#e9ecef"},value:r,onChange:m=>i(m,!1),treeData:c,label:e})}),jo=T.observer(({filter:{type:e,config:t,key:r,...i},formFieldProps:s})=>{switch(e){case"select":return n(Eo,{...i,...s,config:t});case"multi-select":return n($o,{...i,...s,config:t});case"tree-select":return n(Wo,{...i,...s,config:t});case"text-input":return n(Lo,{...i,...s,config:t});case"date-range":return n(Vi,{...i,...s,config:t});case"checkbox":return n(Mo,{...i,...s,config:t});default:return null}}),Bi=T.observer(b.forwardRef(({filter:e,...t},r)=>n("div",{className:"filter-root",ref:r,children:n(ke,{children:n(jo,{filter:e,formFieldProps:t})})}))),Ni=T.observer(function({view:t}){const r=F(),{control:i,handleSubmit:s,reset:o}=x.useForm({defaultValues:r.filters.values,reValidateMode:"onBlur"}),u=x.useWatch({control:i});b.useEffect(()=>{o(r.filters.values)},[r.filters.values,o]),b.useEffect(()=>{r.filters.updatePreviewValues(u)},[u]);const l=r.filters.visibleInView(t.id),d=b.useMemo(()=>l.every(h=>h.should_auto_submit),[l]),c=b.useMemo(()=>l.filter(h=>v.get(h,"config.required",!1)),[l]),f=b.useMemo(()=>c.length===0?!1:c.some(h=>!h.requiredAndPass(u[h.key])),[u,c]);if(l.length===0)return null;const g=(h,m)=>(w,C)=>{m(w),(h.should_auto_submit||C)&&r.filters.setValueByKey(h.key,w)};return n("form",{onSubmit:s(r.filters.setValues),children:p(a.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:d?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[n(a.Group,{align:"flex-start",children:l.map(h=>n(x.Controller,{name:h.key,control:i,render:({field:m})=>n(Bi,{filter:h,value:m.value,onChange:g(h,m.onChange)})},h.id))}),!d&&n(a.Group,{sx:{alignSelf:"flex-end"},children:n(a.Button,{color:"blue",size:"sm",type:"submit",disabled:f,children:"Search"})})]})})}),$1="";function Ro(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const Gi=T.observer(()=>{const{freezeLayout:e}=b.useContext(Ke),[t,r]=b.useState(!1),{panel:i}=Ce();return b.useEffect(()=>{e(t)},[t]),Ro(i.description)?null:p(B,{children:[n(a.Modal,{opened:t,onClose:()=>r(!1),title:i.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:n(qt,{value:i.description,styles:{root:{border:"none"},content:{padding:0}}})}),n(a.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:n(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>r(s=>!s),sx:{verticalAlign:"baseline",cursor:"pointer"},children:n(k.InfoCircle,{size:20})})})]})}),Yo=T.observer(({view:e})=>{const t=me(),r=F(),i=Le.useModals(),{panel:s}=Ce(),{id:o,query:u}=s,{inEditMode:l}=b.useContext(Ke),d=()=>u==null?void 0:u.fetchData(),{viewPanelInFullScreen:c,inFullScreen:f}=b.useContext(yn),g=()=>{r.duplicatePanelByID(o,e.id)},h=()=>{t.editor.open(["_VIEWS_",e.id,"_PANELS_",o])},m=()=>i.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>r.removePanelByID(o,e.id),confirmProps:{color:"red"},zIndex:320}),w=b.useCallback(()=>{c(o)},[o,c]),C=!f&&e.type!==K.Modal;return n(B,{children:n(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(a.Menu,{withinPortal:!0,children:[n(a.Menu.Target,{children:n(a.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),p(a.Menu.Dropdown,{children:[n(a.Menu.Item,{onClick:d,icon:n(k.Refresh,{size:14}),children:"Refresh"}),n(a.Menu.Item,{onClick:()=>r.queries.downloadDataByQueryID((u==null?void 0:u.id)??""),icon:n(k.Download,{size:14}),children:"Download Data"}),C&&n(a.Menu.Item,{onClick:w,icon:n(k.ArrowsMaximize,{size:14}),disabled:l,children:"Full Screen"}),l&&p(B,{children:[n(a.Divider,{label:"Edit",labelPosition:"center"}),n(a.Menu.Item,{onClick:h,icon:n(k.Settings,{size:14}),children:"Settings"}),n(a.Menu.Item,{onClick:g,icon:n(k.Copy,{size:14}),children:"Duplicate"}),n(a.Menu.Item,{color:"red",onClick:m,icon:n(k.Trash,{size:14}),children:"Delete"})]})]})]})})})}),z1="",Qo=T.observer(function(){const{panel:t}=Ce(),{title:r}=t;return r?n(a.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:n(a.Text,{align:"center",lineClamp:1,weight:"bold",children:r})}):null}),Ne=(e,t)=>{const[r,i]=b.useState([]);return b.useEffect(()=>e.watchTriggerSnapshotList(s=>i(s.filter(o=>o.schemaRef===t))),[]),r};class lt{constructor(t,r){this.root=t,this.path=r}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,v.omit(r,t))}async getItem(t){const r=await this.root.getItem(this.path);return t===null?r:v.get(r,t)}async setItem(t,r){if(t===null)await this.root.setItem(this.path,r);else{const i=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...i,[t]:r})}return await this.getItem(t)}watchItem(t,r,i){return t===null?this.root.watchItem(this.path,(s,o)=>{r(s,o)},i):this.root.watchItem(this.path,(s,o)=>{const u=v.get(s,t),l=v.get(o,t);u!==l&&r(u,l)},i)}}class Sn{constructor(t,r,i){O(this,"attachmentStorage");this.instance=t,this.attachmentKey=r,this.constructInstance=i,this.attachmentStorage=new lt(t.instanceData,r)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new lt(this.attachmentStorage,t))}async create(t,r){return await this.attachmentStorage.setItem(t,r),this.constructInstance(new lt(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(v.values(t).map(r=>this.constructInstance(new lt(this.attachmentStorage,r.id))))}}class qi{constructor(t){O(this,"rootRef");this.rootRef=se.observable({current:t})}async deleteItem(t){se.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?se.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(v.isObject(r))se.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else se.runInAction(()=>{v.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,i){return se.reaction(()=>this.getValueFromRoot(t),(s,o)=>{r(s,o)},{requiresObservable:!0,fireImmediately:v.get(i,"fireImmediately",!1)})}}class Uo{constructor(){O(this,"channels",new Map);O(this,"globalChannel",new Di)}getChannel(t){const r=this.channels.get(t);if(r)return r;const i=new Di;return this.channels.set(t,i),i}}class Xo{constructor(t){O(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const r=this.instances.get(t.id);if(r)return r;const i={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Uo,instanceData:new qi(t.viz.conf)};return this.instances.set(t.id,i),i}}function Fi(e,t,r,i){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new qi({}),colorPalette:{getColor(){return()=>""}},data:t,variables:i}}const Zo=e=>{const{panel:t,vizManager:r,data:i,variables:s}=e,o=r.resolveComponent(t.viz.type),u=r.getOrCreateInstance(t),l={...Fi(u,i,r,s),viewport:{width:t.layout.w,height:t.layout.h}},d=o.viewRender;return n(d,{context:l,instance:u,...v.omit(e,["panel","vizManager","data"])})},Ko=e=>{const{vizManager:t,panel:r,panelInfoEditor:i,data:s,variables:o}=e,u=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),d={...Fi(l,s,t,o),panelInfoEditor:i},c=u.configRender;return n(c,{context:d,instance:l,...v.omit(e,["panel","vizManager","data","panelInfoEditor"])})},Wi=(e,t)=>{const r=je.bezier(e),i=je.bezier(t);return function(s){return s<50?r(s*2/100).hex():i((s-50)*2/100).hex()}},Ft=e=>{const t=je.bezier(e);return function(r){return t(r/100).hex()}},Jo={type:"interpolation",displayName:"Red / Green",getColor:Wi(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Ho={type:"interpolation",displayName:"Yellow / Blue",getColor:Wi(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},el={type:"interpolation",displayName:"Red",getColor:Ft(["#fff7f1","darkred"]),name:"red",category:"sequential"},tl={type:"interpolation",displayName:"Green",getColor:Ft(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},nl={type:"interpolation",displayName:"Blue",getColor:Ft(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},rl={type:"interpolation",displayName:"Orange",getColor:Ft(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},ji="@devtable/dashboard",Tn="9.2.1",Ri="Apache-2.0",Yi={access:"public",registry:"https://registry.npmjs.org/"},Qi=["dist"],Ui="./dist/dashboard.umd.js",Xi="./dist/dashboard.es.js",Zi="./dist/index.d.ts",Ki={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Ji={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},Hi={"@monaco-editor/react":"4.4.6","@types/chroma-js":"^2.1.4","file-saver":"2.0.5",mathjs:"11.8.0","monaco-editor":"0.36.0","performant-array-to-tree":"1.11.0",popmotion:"^11.0.3","rc-select":"14.1.0","rc-tree-select":"5.5.5",reactflow:"^11.5.3"},ea={"@emotion/babel-plugin":"11.10.6","@faker-js/faker":"7.6.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"1.119.0","@testing-library/cypress":"^9.0.0","@testing-library/jest-dom":"^5.16.4","@testing-library/react":"^13.3.0","@testing-library/react-hooks":"^8.0.1","@testing-library/user-event":"^14.3.0","@tiptap/extension-code-block-lowlight":"2.0.3","@tiptap/extension-color":"2.0.3","@tiptap/extension-highlight":"2.0.3","@tiptap/extension-link":"2.0.3","@tiptap/extension-placeholder":"2.0.3","@tiptap/extension-subscript":"2.0.3","@tiptap/extension-superscript":"2.0.3","@tiptap/extension-table":"2.0.3","@tiptap/extension-table-cell":"2.0.3","@tiptap/extension-table-header":"2.0.3","@tiptap/extension-table-row":"2.0.3","@tiptap/extension-text-align":"2.0.3","@tiptap/extension-text-style":"2.0.3","@tiptap/extension-underline":"2.0.3","@tiptap/pm":"2.0.3","@tiptap/react":"2.0.3","@tiptap/starter-kit":"2.0.3","@types/crypto-js":"v4.1.1","@types/d3-array":"3.0.4","@types/eventemitter2":"^4.1.0","@types/file-saver":"2.0.5","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2",ahooks:"^3.3.11",ajv:"8.12.0",axios:"^0.27.2","crypto-js":"^4.1.1",cypress:"^12.9.0","cypress-wait-until":"^1.7.2",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",jsdom:"^20.0.0","jsdom-testing-mocks":"^1.5.0",lodash:"^4.17.21",lowlight:"^2.8.0",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","rollup-plugin-visualizer":"5.6.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3","vite-plugin-static-copy":"0.13.1"},ta={"@emotion/react":"11.10.6","@faker-js/faker":"7.6.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"1.119.0","@tanstack/react-table":"^8.5.13","@tiptap/extension-code-block-lowlight":"2.0.3","@tiptap/extension-color":"2.0.3","@tiptap/extension-highlight":"2.0.3","@tiptap/extension-link":"2.0.3","@tiptap/extension-placeholder":"2.0.3","@tiptap/extension-subscript":"2.0.3","@tiptap/extension-superscript":"2.0.3","@tiptap/extension-table":"2.0.3","@tiptap/extension-table-cell":"2.0.3","@tiptap/extension-table-header":"2.0.3","@tiptap/extension-table-row":"2.0.3","@tiptap/extension-text-align":"2.0.3","@tiptap/extension-text-style":"2.0.3","@tiptap/extension-underline":"2.0.3","@tiptap/pm":"2.0.3","@tiptap/react":"2.0.3","@tiptap/starter-kit":"2.0.3",ahooks:"^3.3.11",axios:"^0.27.2","chroma-js":"^2.4.2","crypto-js":"^4.1.1","d3-array":"3.2.3","d3-regression":"1.3.10",dayjs:"1.11.7",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9",eventemitter2:"^6.4.6",jszip:"3.10.1",lodash:"^4.17.21",lowlight:"^2.8.0",mobx:"^6.6.1","mobx-react-lite":"^3.4.0","mobx-state-tree":"^5.1.5",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","react-router-dom":"^6.3.0","react-virtual":"^2.10.4","tabler-icons-react":"^1.48.0"},il=Object.freeze(Object.defineProperty({__proto__:null,default:{name:ji,version:Tn,license:Ri,publishConfig:Yi,files:Qi,main:Ui,module:Xi,types:Zi,exports:Ki,scripts:Ji,dependencies:Hi,devDependencies:ea,peerDependencies:ta},dependencies:Hi,devDependencies:ea,exports:Ki,files:Qi,license:Ri,main:Ui,module:Xi,name:ji,peerDependencies:ta,publishConfig:Yi,scripts:Ji,types:Zi,version:Tn},Symbol.toStringTag,{value:"Module"}));class al{constructor(t){O(this,"staticColors",new Map);O(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(i=>{this.register(i)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(r,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class sl{constructor(){O(this,"plugins",new Map);O(this,"vizComponents",new Map);O(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class ol{constructor(){O(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,i){var u;if(t.from===t.to)return r;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const s=this.migrations.filter(l=>l.version>t.from&&l.version<=t.to),o=v.orderBy(s,"version","asc");if(((u=v.last(o))==null?void 0:u.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((l,d)=>d.handler(l,i),r)}}class he extends ol{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(i,s)=>({version:t,...r(i,s)}))}async migrate({configData:t,panelModel:r}){const i=await t.getItem(null),s=v.get(i,"version",0),o=this.run({from:s,to:this.VERSION},i,{panelModel:r});await t.setItem(null,o)}async needMigration({configData:t}){const r=await t.getItem(null);return v.get(r,"version",0)<this.VERSION}}const W=(e,t)=>{const[r,{setFalse:i}]=Z.useBoolean(!0),[s,o]=b.useState();b.useEffect(()=>(e.getItem(t).then(l=>{o(l),i()}),e.watchItem(t,l=>{o(l)})));const u=b.useCallback(async l=>{await e.setItem(t,l),o(l)},[e,t]);return{loading:r,value:s,set:u}},kn={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"}};le.use([N.GridComponent,N.VisualMapComponent,N.LegendComponent,N.TooltipComponent,Ie.CanvasRenderer]);function ll({context:e}){const{value:t}=W(e.instanceData,"config"),r=e.data,{width:i,height:s}=e.viewport,{x_axis_data_key:o,y_axis_data_key:u,z_axis_data_key:l,xAxis3D:d,yAxis3D:c,zAxis3D:f}=v.defaults({},t,kn),g=b.useMemo(()=>{const w=v.minBy(r,C=>C[l]);return v.get(w,l)},[r,l]),h=b.useMemo(()=>{const w=v.maxBy(r,C=>C[l]);return v.get(w,l)},[r,l]),m={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:g,max:h,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:d,yAxis3D:c,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:r.map(w=>[w[o],w[u],w[l]])}]};return t?n(Ae,{echarts:le,option:m,style:{width:i,height:s},notMerge:!0,theme:"merico-light"}):null}function ul({label:e,required:t,value:r,onChange:i,data:s,clearable:o=!1,sx:u,...l},d){const c=b.useMemo(()=>{if(!Array.isArray(s)||s.length===0)return[];const g=Object.keys(s[0]).map(h=>({label:h,value:h}));return o?g.concat([{label:"unset",value:""}]):g},[s]);return n(a.Select,{ref:d,label:e,data:c,value:r,onChange:i,required:t,sx:u,...l})}const R=b.forwardRef(ul);function dl({context:e}){const{value:t,set:r}=W(e.instanceData,"config"),i=e.data,s=v.defaults({},t,kn),{control:o,handleSubmit:u,reset:l}=x.useForm({defaultValues:s});return b.useEffect(()=>{l(s)},[t]),t?n(a.Stack,{spacing:"xs",children:p("form",{onSubmit:u(r),children:[n(a.Text,{children:"X Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"x_axis_data_key",control:o,render:({field:d})=>n(R,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"xAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Y Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"y_axis_data_key",control:o,render:({field:d})=>n(R,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"yAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Text,{mt:"lg",children:"Z Axis"}),p(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n(x.Controller,{name:"z_axis_data_key",control:o,render:({field:d})=>n(R,{label:"Data Field",required:!0,data:i,...d})}),n(x.Controller,{name:"zAxis3D.name",control:o,render:({field:d})=>n(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...d})})]}),n(a.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(a.Button,{color:"blue",type:"submit",children:[n(k.DeviceFloppy,{size:20}),n(a.Text,{ml:"md",children:"Save"})]})})]})}):null}class cl extends he{constructor(){super(...arguments);O(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const pl={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new cl,name:"bar-3d",viewRender:ll,configRender:dl,createConfig(){return{version:1,config:v.cloneDeep(kn)}}},Se={mantissa:0,output:"number",trimMantissa:!1,average:!1};function hl({value:e,onChange:t},r){const i=l=>{t({...e,output:l})},s=l=>{const d=l===0?!1:e.trimMantissa;t({...e,mantissa:l,trimMantissa:d})},o=l=>{t({...e,trimMantissa:l.currentTarget.checked})},u=l=>{t({...e,average:l.currentTarget.checked})};return p(a.Stack,{ref:r,children:[p(a.Group,{grow:!0,children:[n(a.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:i,sx:{flexGrow:1}}),n(a.Switch,{label:p(a.Stack,{spacing:0,children:[n(a.Text,{children:"Average"}),n(a.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:u,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(a.Group,{grow:!0,children:[n(a.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:s}),n(a.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(a.Stack,{spacing:0,children:[n(a.Text,{weight:"bold",children:"Preview"}),n(ke,{children:p(a.Group,{position:"apart",children:[p(a.Text,{size:12,color:"gray",children:["123456789 ",n(k.ArrowRight,{size:9})," ",te(123456789).format(e)]}),p(a.Text,{size:12,color:"gray",children:["1234 ",n(k.ArrowRight,{size:9})," ",te(1234).format(e)]}),p(a.Text,{size:12,color:"gray",children:["0.1234 ",n(k.ArrowRight,{size:9})," ",te(.1234).format(e)]})]})})]})]})}const Oe=b.forwardRef(hl),Ge={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
28
28
|
`)},na={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:gl,configRender:fl,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 fl(e){return n(B,{})}function gl(e){return n(a.Text,{children:"Click chart's series"})}const ml=[{label:"Truncate",value:"truncate"},{label:"Break Line",value:"break"},{label:"Break Word",value:"breakAll"}],Wt=b.forwardRef(({sectionTitle:e,value:t,onChange:r},i)=>{const s=o=>u=>{const l=v.cloneDeep(t);v.set(l,o,u),r(l)};return p(a.Stack,{spacing:0,children:[e&&n(a.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),p(a.Group,{grow:!0,noWrap:!0,children:[n(a.NumberInput,{label:"Max Width",hideControls:!0,value:t.width,onChange:s("width")}),n(a.Select,{label:"Overflow",data:ml,value:t.overflow,onChange:s("overflow")}),n(a.TextInput,{label:"Ellipsis",value:t.ellipsis,disabled:!0})]})]})}),Je=b.forwardRef(({value:e,onChange:t},r)=>{const i=o=>{t({...e,on_axis:o})},s=o=>{t({...e,in_tooltip:o})};return p(a.Stack,{ref:r,spacing:0,children:[n(Wt,{sectionTitle:"Overflow on Axis",value:e.on_axis,onChange:i}),n(Wt,{sectionTitle:"Overflow in Tooltip",value:e.in_tooltip,onChange:s})]})}),Ve={on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}};function He({overflow:e,width:t}){const r={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],i=e==="truncate"?"nowrap":"initial",s={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
|
|
29
29
|
max-width: ${t}px;
|
|
30
30
|
word-break: ${r};
|
|
@@ -363,7 +363,7 @@ Check the top-level render call using <`+E+">.")}return M}}function ao(_,M){{if(
|
|
|
363
363
|
</tr>
|
|
364
364
|
</tbody>
|
|
365
365
|
</table>
|
|
366
|
-
`}},show_in_legend:!0}))}function yb(e,t,r,i){const s=t.data_key,o=t.name,u=r.map(l=>{const d=v.sumBy(i[l],s);return[l,d]});return{type:"line",name:o,xAxisIndex:3,yAxisIndex:3,color:"#b41529",data:u,show_in_legend:!1}}function vb(e,t,r,i){const u={barMinWidth:5,barMaxWidth:20};return[hb(e,r,i),gb(e,r,i,u),...bb(e,r,i,u),yb(e,t,r,i)]}function xb(e,t){const{axisLabel:r}=e.x_axis;return[{data:t,id:"准确估算比例",gridIndex:0,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"平均偏差",gridIndex:1,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!0,lineStyle:{color:"#FFFFFF",width:2}},type:"category"},{data:t,id:"数量占比",gridIndex:2,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"代码当量",gridIndex:3,axisTick:{show:!1},type:"category",axisLabel:{...r,formatter:ya(r.formatter)},axisLine:{show:!1}}]}function Cb(e){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:e.name,nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:3,position:"left",axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}}]}function rr(e){return e==1||e==2?1:rr(e-2)+rr(e-1)}const wb=Array.from(new Array(20),(e,t)=>rr(t+1));function Ga(e){return e<=1?e:wb.findIndex(t=>e<=t)-1}function _b(e,t){const{estimated_value:r,actual_value:i}=e.deviation.data_keys;return t.map(s=>{const o=Ga(s[r]),u=Ga(s[i]),l=o-u;return{...s,level:{estimated:o,actual:u,diff:l}}})}function Sb(e){return e==="rgba(255, 255, 255, 1)"?{borderColor:"rgba(0,0,0,.1)",borderWidth:1}:{}}function Tb(e){return{show:!0,orient:"vertical",top:"middle",right:0,data:e.filter(r=>r.show_in_legend).reverse().map(r=>({name:`${r.name}`,color:r.color,itemStyle:Sb(r.color)})),tooltip:{show:!0,formatter:"档位偏差:{a}"}}}const kb={tooltip:{trigger:"axis"}};function Db(e,t){const{deviation:r,metrics:i}=e,s=i.find(u=>u.data_key===t);if(s)return s;const o=r.data_keys.actual_value;return{id:o,name:r.name,data_key:o}}function Mb(e,t,r){const i=_b(e,r),s=v.uniqBy(r,e.x_axis.data_key).map(c=>c[e.x_axis.data_key]),o=v.groupBy(i,e.x_axis.data_key),u=Db(e,t),l=vb(e,u,s,o),d={xAxis:xb(e,s),yAxis:Cb(u),series:l,grid:pb(),visualMap:[{min:0,max:1,calculable:!0,show:!1,seriesIndex:0,color:["#F0F0F0","#418AAF"]}],legend:Tb(l)};return v.defaultsDeep({},d,kb)}const ir={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,formatter:{...Jt}}},deviation:{name:"",data_keys:{estimated_value:"",actual_value:""}},metrics:[]},Ib={input:{border:"none !important",paddingLeft:0,lineHeight:"1.55 !important"}},Ab=({conf:e,metricKey:t,setMetricKey:r})=>{const{deviation:i,metrics:s}=e,o=b.useMemo(()=>{const u=s.map(l=>({label:l.name,value:l.data_key}));return u.push({label:i.name?i.name:i.data_keys.actual_value,value:i.data_keys.actual_value}),u},[i,s]);return p(a.Group,{spacing:1,children:[n(a.Text,{size:12,color:"dimmed",sx:{cursor:"default",userSelect:"none"},children:"基线指标"}),n(a.NativeSelect,{size:"xs",data:o,value:t,onChange:u=>r(u.currentTarget.value),styles:Ib})]})},$b={"tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function zb(){return p(a.HoverCard,{width:400,shadow:"md",children:[n(a.HoverCard.Target,{children:n(a.Button,{size:"xs",variant:"subtle",compact:!0,leftIcon:n(V.IconInfoCircle,{size:14}),children:"指标说明"})}),n(a.HoverCard.Dropdown,{children:n(a.Table,{fontSize:14,sx:$b,children:p("tbody",{children:[p("tr",{children:[n("th",{children:"估算偏差"}),n("td",{children:"使用斐波那契数列(1,2,3,5,8,13)估算故事点,每个数位为一个档位,计算issue实际故事点与估算故事点的档位偏差,即为估算偏差。如估算故事点为5,实际故事点为8,则估算偏差为-1。"})]}),p("tr",{children:[n("th",{children:"准确估算比例"}),n("td",{children:"偏差在 ± 1 档位内的 issue 均为准确估算,以此计算准确估算的比例。"})]})]})})})]})}function Eb(e){return p(a.Group,{position:"apart",children:[n(zb,{}),n(Ab,{...e})]})}le.use([de.BarChart,de.LineChart,de.HeatmapChart,N.GridComponent,N.LegendComponent,N.TooltipComponent,Ie.CanvasRenderer,N.VisualMapComponent]);function Lb({conf:e,data:t,width:r,height:i,metricKey:s}){const o=b.useMemo(()=>Mb(e,s,t),[e,t,s]);return!r||!i?null:n(Ae,{echarts:le,option:o,style:{width:r,height:i},notMerge:!0,theme:"merico-light"})}function Pb({context:e}){const{value:t}=W(e.instanceData,"config"),r=b.useMemo(()=>v.defaults({},t,ir),[t]),i=e.data,{width:s,height:o}=e.viewport,{x_axis:u,deviation:l}=r,{estimated_value:d,actual_value:c}=l.data_keys,[f,g]=b.useState(c);if(b.useEffect(()=>{g(w=>w||c)},[c]),!u.data_key||!d||!c)return null;const h=Math.max(s,300),m=Math.max(o,370);return p(a.Box,{sx:{overflow:"hidden",height:m,width:h},children:[n(Eb,{conf:r,metricKey:f,setMetricKey:g}),n(Lb,{width:h,height:m-30,data:i,conf:r,metricKey:f})]})}function Ob({data:e,control:t,watch:r}){return r(["x_axis"]),p(a.Stack,{children:[p(a.Group,{grow:!0,noWrap:!0,children:[n(x.Controller,{name:"x_axis.data_key",control:t,render:({field:i})=>n(R,{label:"数据字段",required:!0,data:e,sx:{flex:1},...i})}),n(x.Controller,{name:"x_axis.name",control:t,render:({field:i})=>n(a.TextInput,{label:"X轴名称",sx:{flex:1},...i})})]}),n(a.Divider,{mb:-15,label:"点位文案",labelPosition:"center"}),p(a.Group,{grow:!0,noWrap:!0,children:[n(x.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:i})=>n(a.NumberInput,{label:"旋转",hideControls:!0,min:-90,max:90,rightSection:n(a.Text,{color:"dimmed",children:"度"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...i})}),n(x.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:i})=>n(Ca,{data:e,...i})})]})]})}function Vb({data:e,control:t,watch:r}){return r(["deviation"]),p(a.Stack,{children:[n(a.Group,{grow:!0,noWrap:!0,children:n(x.Controller,{name:"deviation.name",control:t,render:({field:i})=>n(a.TextInput,{label:"指标名称",sx:{flex:1},...i})})}),p(a.Group,{grow:!0,noWrap:!0,children:[n(x.Controller,{name:"deviation.data_keys.estimated_value",control:t,render:({field:i})=>n(R,{label:"估算值字段",required:!0,data:e,sx:{flex:1},...i})}),n(x.Controller,{name:"deviation.data_keys.actual_value",control:t,render:({field:i})=>n(R,{label:"实际值字段",required:!0,data:e,sx:{flex:1},...i})})]})]})}const Bb=({control:e,data:t,index:r,remove:i})=>p(a.Stack,{children:[p(a.Group,{grow:!0,noWrap:!0,children:[n(x.Controller,{name:`metrics.${r}.name`,control:e,render:({field:s})=>n(a.TextInput,{label:"Name",required:!0,sx:{flex:1},...s})}),n(x.Controller,{name:`metrics.${r}.data_key`,control:e,render:({field:s})=>n(R,{label:"Value Field",required:!0,data:t,sx:{flex:1},...s})})]}),n(a.Divider,{mb:-10,mt:10,variant:"dashed"}),n(a.Button,{leftIcon:n(k.Trash,{size:16}),color:"red",variant:"light",onClick:()=>i(r),sx:{top:15,right:5},children:"Delete this Metric"})]}),Nb=({control:e,watch:t,data:r})=>{const{fields:i,append:s,remove:o}=x.useFieldArray({control:e,name:"metrics"}),u=t("metrics"),l=i.map((h,m)=>({...h,...u[m]})),d=()=>s({id:Date.now().toString(),data_key:"",name:""}),c=t("metrics.0.id"),[f,g]=b.useState(()=>c??null);return b.useEffect(()=>{c&&g(h=>h!==null?h:c)},[c]),p(B,{children:[p(a.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[n(k.InfoCircle,{size:14,color:"#888"}),n(a.Text,{size:14,color:"#888",children:"设置可以展示在基线图的指标,例如代码当量"})]}),n(a.Divider,{variant:"dashed",my:10}),p(a.Tabs,{value:f,onTabChange:h=>g(h),styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[p(a.Tabs.List,{children:[l.map((h,m)=>n(a.Tabs.Tab,{value:h.id,children:h.name?h.name:m},h.id)),n(a.Tabs.Tab,{onClick:d,value:"add",children:n(k.Plus,{size:18,color:"#228be6"})})]}),l.map((h,m)=>n(a.Tabs.Panel,{value:h.id,children:n(Bb,{control:e,index:m,remove:o,data:r},h.id)},h.id))]})]})};function Gb({context:e}){const{value:t,set:r}=W(e.instanceData,"config"),i=e.data,s=b.useMemo(()=>v.defaultsDeep({},t,ir),[t]),{control:o,handleSubmit:u,watch:l,getValues:d,reset:c}=x.useForm({defaultValues:s});b.useEffect(()=>{c(s)},[s]),l([]);const f=d(),g=b.useMemo(()=>!v.isEqual(f,s),[f,s]);return n(a.Stack,{spacing:"xs",children:p("form",{onSubmit:u(r),children:[p(a.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n(a.Text,{children:"Merico Estimation Chart Config"}),n(a.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!g,children:n(k.DeviceFloppy,{size:20})})]}),p(a.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"12px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"X Axis",children:"X 轴"}),n(a.Tabs.Tab,{value:"Deviation",children:"偏差"}),n(a.Tabs.Tab,{value:"Additional Metrics",children:"指标"})]}),n(a.Tabs.Panel,{value:"X Axis",children:n(Ob,{control:o,watch:l,data:i})}),n(a.Tabs.Panel,{value:"Deviation",children:n(Vb,{control:o,watch:l,data:i})}),n(a.Tabs.Panel,{value:"Additional Metrics",children:n(Nb,{control:o,watch:l,data:i})})]})]})})}class qb extends he{constructor(){super(...arguments);O(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const Fb={displayName:"Merico Estimation Chart",displayGroup:"Merico suite",migrator:new qb,name:"mericoEstimationChart",viewRender:Pb,configRender:Gb,createConfig:()=>({version:1,config:ir})},Wb=[{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(e=>({name:e.name,value:e.value,type:"single",category:"basic"})),jb=[Jo,Ho,nl,tl,el,rl],qa=()=>({id:"dashboard",version:Tn,manifest:{viz:[Zn,kf,Rg,dh,Qf,gp,cb,pl,eu,ic,zc,km,dp,Od,yf,$p,ah,Hg,Fb,fu],color:[...Wb,...jb]}}),Mt=new sl,be={pluginManager:Re("pluginManager"),vizManager:Re("vizManager"),colorManager:Re("colorManager"),instanceScope:{panelModel:Re("panelModel"),vizInstance:Re("vizInstance"),interactionManager:Re("interactionManager"),migrator:Re("migrator"),operationManager:Re("operationManager"),triggerManager:Re("triggerManager")}},ar=()=>{try{Mt.install(qa())}catch{}const e=new Xo(Mt),t=new al(Mt);return{pluginManager:Mt,vizManager:e,colorManager:t}},qe=b.createContext(ar());try{Mt.install(qa())}catch{}function Rb(e,t){const{value:r,set:i}=W(e.operation.operationData,"config"),[s,o]=b.useState(v.defaults({},r,t)),u=async()=>{await i(s)};return b.useEffect(()=>{o(v.defaults({},r,t))},[r]),{config:s,setConfig:o,commit:u}}function Yb(e){const{config:t,setConfig:r,commit:i}=Rb(e,{urlTemplate:"",openInNewTab:!0});async function s(){await i()}async function o(l){r({...t,openInNewTab:l}),await i()}const u=l=>r({...t,urlTemplate:l.currentTarget.value});return p(a.Stack,{children:[n(a.TextInput,{label:"Url",value:t.urlTemplate,onChange:u,onBlur:s}),n(a.Switch,{label:"Open in new Tab",checked:t.openInNewTab,onChange:l=>o(l.currentTarget.checked)})]})}async function Qb(e,t){const{urlTemplate:r,openInNewTab:i}=await t.operationData.getItem("config");window.dispatchEvent(new CustomEvent("open-link",{detail:{urlTemplate:r,openInNewTab:i,payload:e}}))}class Ub extends he{constructor(){super(...arguments);O(this,"VERSION",1)}configVersions(){this.version(1,r=>r)}}const Xb={displayName:"Open Link",id:"builtin:op:open-link",configRender:Yb,run:Qb,migrator:new Ub,createDefaultConfig:()=>({version:1,config:{urlTemplate:"",openInNewTab:!0}})};function Zb(e){const{value:t,set:r}=W(e.operationData,"config"),i=s=>void r({template:s});return[(t==null?void 0:t.template)||"",i]}function Kb(e){const[t,r]=Zb(e.operation);return n(a.TextInput,{defaultValue:t,onBlur:i=>r(i.currentTarget.value),label:"console.log"})}async function Jb(e,t){const r=await t.operationData.getItem("config"),i=v.template(r.template||"");console.log("run with payload",e),console.log(i(e))}const Hb={displayName:"console.log (debug)",id:"builtin:op:debug",configRender:Kb,run:Jb},ey=T.observer(e=>{const t=F(),{value:r,set:i}=W(e.operation.operationData,"config");console.log({value:r,viewID:r==null?void 0:r.viewID});const s=(r==null?void 0:r.viewID)||"",o=u=>void i({viewID:u});return n(a.Select,{defaultValue:s,value:s,onChange:o,label:"View",data:t.views.options})});async function ty(e,t){const i=(await t.operationData.getItem("config")).viewID;window.dispatchEvent(new CustomEvent("open-view",{detail:{viewID:i}}))}const ny={displayName:"Open View",id:"builtin:op:open_view",configRender:ey,run:ty},ry={dictionary:{}},iy=T.observer(e=>{const t=F(),{value:r=ry,set:i}=W(e.operation.operationData,"config"),{dictionary:s={}}=r,o=(d,c)=>{i({dictionary:{...s,[d]:c}})},u=()=>{o(t.filters.firstFilterValueKey,"")},l=d=>{const c={...s};delete c[d],i({dictionary:c})};return p(a.Stack,{spacing:10,children:[n(a.Text,{children:"Mapping Rules"}),Object.entries(s).map(([d,c])=>p(a.Flex,{justify:"space-between",gap:10,children:[n(a.TextInput,{label:"Payload key",value:c,onChange:f=>{o(d,f.currentTarget.value)},sx:{flexGrow:1}}),n(R,{data:[t.filters.values],value:d,onChange:f=>{o(f,c)},label:"Filter key",sx:{flexGrow:1}}),n(a.ActionIcon,{onClick:()=>l(d),sx:{marginTop:"26px",flexGrow:0},children:n(k.Trash,{size:14,color:"red"})})]},d)),n(a.Button,{size:"xs",onClick:u,sx:{alignSelf:"center",width:"300px"},children:"Add one mapping rule"})]})});async function ay(e,t){const i=(await t.operationData.getItem("config")).dictionary;window.dispatchEvent(new CustomEvent("set-filter-values",{detail:{dictionary:i,payload:e}}))}const sy={displayName:"Set Filter Values",id:"builtin:op:set_filter_values",configRender:iy,run:ay},oy={filter_keys:[]},ly=T.observer(e=>{const t=F(),{value:r=oy,set:i}=W(e.operation.operationData,"config"),{filter_keys:s=[]}=r,o=l=>{i({filter_keys:[...l]})},u=b.useMemo(()=>t.filters.current.map(l=>({label:l.label,value:l.key})),[t.filters.values]);return n(a.Stack,{spacing:10,children:n(a.MultiSelect,{label:"Select Filters to Clear",data:u,value:s,onChange:o})})});async function uy(e,t){const i=(await t.operationData.getItem("config")).filter_keys;window.dispatchEvent(new CustomEvent("clear-filter-values",{detail:{filter_keys:i,payload:e}}))}const tn=[Hb,Xb,ny,sy,{displayName:"Clear Filter Values",id:"builtin:op:clear_filter_values",configRender:ly,run:uy}];class dy{constructor(t,r=tn){O(this,"attachments");this.operations=r;const i=async s=>{const{id:o,schemaRef:u}=await s.getItem(null);return{id:o,schemaRef:u,operationData:new lt(s,"data")}};this.attachments=new Sn(t,"__OPERATIONS",i)}async runOperation(t,r){const i=await this.attachments.getInstance(t);if(!i){console.warn(`Operation '${t}' is not defined`);return}const s=this.tryGetSchema(i.schemaRef);if(!s){console.warn(`Operation schema '${i.schemaRef}' is not defined`);return}await s.run(r,i)}tryGetSchema(t){return this.operations.find(r=>r.id===t)}async needMigration(){const r=(await this.attachments.list()).map(async i=>{const s={configData:i.operationData},o=this.tryGetSchema(i.schemaRef),u=o==null?void 0:o.migrator;return u&&await u.needMigration(s)});return(await Promise.all(r)).some(i=>i)}async runMigration(){const r=(await this.attachments.list()).map(async i=>{const s={configData:i.operationData},o=this.tryGetSchema(i.schemaRef),u=o==null?void 0:o.migrator;u&&await u.needMigration(s)&&await u.migrate(s)});await Promise.all(r)}async createOrGetOperation(t,r){var u;if(!this.getOperationSchemaList().some(l=>l.id===r.id))throw new Error(`Operation schema '${r.id}' is not defined`);const s=await this.attachments.getInstance(t);return!s||s.schemaRef!==r.id?await this.attachments.create(t,{id:t,schemaRef:r.id,data:((u=r.createDefaultConfig)==null?void 0:u.call(r))??{}}):s}getOperationList(){return this.attachments.list()}getOperationSchemaList(){return this.operations}removeOperation(t){return this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}}const Fa="__TRIGGERS";class cy{constructor(t,r){O(this,"attachments");this.instance=t,this.component=r;const i=async s=>{const{id:o,schemaRef:u}=await s.getItem(null);return{id:o,schemaRef:u,triggerData:new lt(s,"data")}};this.attachments=new Sn(t,Fa,i)}watchTriggerSnapshotList(t){return this.instance.instanceData.watchItem(Fa,r=>{const i=v.values(r).map(s=>({id:v.get(s,"id"),schemaRef:v.get(s,"schemaRef"),config:se.toJS(v.get(s,"data.config"))}));t(i)},{fireImmediately:!0})}async createOrGetTrigger(t,r,i={recreate:!1}){var l;if(!this.getTriggerSchemaList().some(d=>d.id===r.id))throw new Error(`Trigger schema '${r.id}' is not defined in component '${this.component.name}'`);const o=await this.attachments.getInstance(t);return!o||i.recreate||o.schemaRef!==r.id?await this.attachments.create(t,{id:t,schemaRef:r.id,data:((l=r==null?void 0:r.createDefaultConfig)==null?void 0:l.call(r))||{}}):o}async getTriggerList(){return await this.attachments.list()}getTriggerSchemaList(){return this.component.triggers||[]}async removeTrigger(t){await this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}async getMigrationTasks(){const r=(await this.getTriggerList()).map(async i=>{const s=this.getTriggerSchemaList().find(l=>l.id===i.schemaRef),o=s==null?void 0:s.migrator,u={configData:i.triggerData};return o&&await o.needMigration(u)?()=>o.migrate(u):null});return Promise.all(r).then(i=>i.filter(s=>s))}async needMigration(){return(await this.getMigrationTasks()).length>0}async runMigration(){const t=await this.getMigrationTasks();await Promise.all(t.map(r=>r()))}}class sr{constructor(t,r,i){O(this,"operationManager");O(this,"triggerManager");O(this,"attachments");this.operationManager=new dy(t,i),this.triggerManager=new cy(t,r);const s=async o=>{const{id:u,triggerRef:l,operationRef:d}=await o.getItem(null);return{id:u,triggerRef:l,operationRef:d}};this.attachments=new Sn(t,"__INTERACTIONS",s)}async addInteraction(t,r){const i=t.id,s=r.id,o=`[${i}]:[${s}]`;await this.attachments.create(o,{id:o,triggerRef:i,operationRef:s})}getInteractionList(){return this.attachments.list()}async removeInteraction(t){const r=await this.attachments.getInstance(t);if(!r)return;const{triggerRef:i,operationRef:s}=r;await this.getTriggerRefCount(i)<=1&&await this.triggerManager.removeTrigger(i),await this.getOperationRefCount(s)<=1&&await this.operationManager.removeOperation(s),await this.attachments.remove(t)}async getOperationRefCount(t){return(await this.getInteractionList()).filter(i=>i.operationRef===t).length}async getTriggerRefCount(t){return(await this.getInteractionList()).filter(i=>i.triggerRef===t).length}async runInteraction(t,r){const s=(await this.getInteractionList()).filter(o=>o.triggerRef===t);await Promise.all(s.map(async o=>{try{return await this.operationManager.runOperation(o.operationRef,r)}catch(u){console.warn(`Failed to run operation '${o.operationRef}'`,u)}}))}}const Fe=({vizManager:e,instance:t})=>Z.useCreation(()=>new sr(t,e.resolveComponent(t.type),tn),[t,e]),Wa=e=>{const{title:t="Variables",variables:r}=e,i=ve.useClipboard(),s=o=>{i.copy(o),Vt.showNotification({color:"green",message:"Copied to clipboard"})};return p(a.Paper,{withBorder:!0,p:"sm",children:[n(a.Text,{size:"xs",color:"dimmed",mb:"sm",children:t}),n(a.Stack,{style:{maxHeight:"500px"},children:r.map(o=>p(a.Text,{size:"sm",children:[p(a.Code,{color:"teal",children:["// ",o.description]}),n("br",{}),p(a.Code,{onClick:()=>s(o.name),style:{cursor:"pointer"},children:[o.name," : ",o.valueType]})]},o.name))})]})};class py{constructor(t,r){O(this,"operationId");O(this,"operation");O(this,"operationSchema");O(this,"variables",[]);this.operationManager=t,this.instance=r,se.makeAutoObservable(this)}get schemaList(){return this.operationManager.getOperationSchemaList()}async configOperation(t,r){const i=await this.operationManager.retrieveTrigger(t),s=this.operationManager.getOperationSchemaList().find(o=>o.id===(i==null?void 0:i.schemaRef));se.runInAction(()=>{this.operationId=t,this.operation=i,this.operationSchema=s,this.variables=r})}async changeSchema(t){this.operationId&&(await this.operationManager.createOrGetOperation(this.operationId,t),await this.configOperation(this.operationId,this.variables))}}function hy(e){return!!e.operationId}const fy=T.observer(({model:e,onClick:t})=>{var i;const r=(i=e.operationSchema)==null?void 0:i.displayName;return n(a.Button,{variant:"outline",onClick:t,children:r})}),gy=T.observer(({model:e})=>{const t={operation:e.operation,instance:e.instance,variables:[]};return b.createElement(e.operationSchema.configRender,t)});function my({model:e}){const t=e.schemaList,r=t.map(s=>({label:s.displayName,value:s.id}));async function i(s){await e.changeSchema(t.find(o=>o.id===s))}return n(a.Select,{label:"Operation",data:r,onChange:i,value:e.operationSchema.id})}const by=T.observer(e=>{const[t,{setTrue:r,setFalse:i}]=Z.useBoolean(!1),{operationManager:s,operationId:o,instance:u,variables:l}=e,d=Z.useCreation(()=>new py(s,u),[s,u]);return Z.useAsyncEffect(async()=>{await d.configOperation(o,l)},[o,d]),hy(d)?p(B,{children:[n(fy,{model:d,onClick:r}),n(a.Modal,{size:600,opened:t,onClose:i,title:"Operation Settings",closeButtonLabel:"close",zIndex:320,children:p(a.Stack,{children:[n(my,{model:d}),n(gy,{model:d}),n(Wa,{title:"Variables",variables:d.variables})]})})]}):null});class yy{constructor(t,r){O(this,"triggerId");O(this,"trigger");O(this,"triggerSchema");O(this,"sampleData");this.triggerManager=t,this.instance=r,se.makeAutoObservable(this)}get schemaList(){return this.triggerManager.getTriggerSchemaList()}async configTrigger(t,r){const i=await this.triggerManager.retrieveTrigger(t),s=this.triggerManager.getTriggerSchemaList().find(o=>o.id===(i==null?void 0:i.schemaRef));se.runInAction(()=>{this.triggerId=t,this.trigger=i,this.triggerSchema=s,this.sampleData=r})}async changeSchema(t){this.triggerId&&(await this.triggerManager.createOrGetTrigger(this.triggerId,t),await this.configTrigger(this.triggerId,this.sampleData))}isReady(){return vy(this)}}function vy(e){return!!e.triggerId&&!!e.triggerSchema}function xy(e,t){return Z.useCreation(()=>new yy(e,t),[e,t])}const Cy=T.observer(({model:e,onClick:t})=>{const r=e.triggerSchema.nameRender,i={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return n(a.Button,{variant:"outline",onClick:t,children:b.createElement(r,i)})}),wy=T.observer(({model:e})=>{const t=e.schemaList,r=t.map(s=>({label:s.displayName,value:s.id}));async function i(s){await e.changeSchema(t.find(o=>o.id===s))}return n(a.Select,{label:"Trigger",data:r,value:e.triggerSchema.id,onChange:i})}),_y=T.observer(({model:e})=>{const t={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return b.createElement(e.triggerSchema.configRender,t)}),Sy=T.observer(e=>{const[t,{setTrue:r,setFalse:i}]=Z.useBoolean(!1),s=e.model;return p(B,{children:[n(a.Modal,{opened:t,onClose:i,title:"Setup Trigger",closeButtonLabel:"close setup",zIndex:320,children:p(a.Stack,{children:[n(wy,{model:s}),n(_y,{model:s}),n(Wa,{title:"Payload",variables:s.triggerSchema.payload})]})}),n(Cy,{onClick:r,model:s})]})});function Ty(e,t){const[r,i]=b.useState([]);return Z.useAsyncEffect(async()=>{const s=await e.getInteractionList();i(s)},[t,e]),r}const ky=T.observer(({item:e,manager:t,instance:r,sampleData:i,variables:s,onRemove:o})=>{const{triggerRef:u,operationRef:l}=e,d=xy(t.triggerManager,r);if(Z.useAsyncEffect(async()=>{await d.configTrigger(u,i)},[d,u,i]),d.isReady()){const c=[...d.triggerSchema.payload,...s];return p(a.Group,{children:[n(Sy,{model:d}),n(by,{instance:r,operationId:l,variables:c,operationManager:t.operationManager}),n(a.ActionIcon,{"aria-label":"delete-interaction",variant:"filled",color:"red",onClick:()=>o(e),children:n(k.Trash,{size:16})})]})}return null}),Dy=e=>{const[t,r]=b.useState(0),{interactionManager:i,instance:s,sampleData:o,variables:u}=e,l=Ty(i,t),d=async()=>{const h=await i.triggerManager.createOrGetTrigger(ve.randomId(),i.triggerManager.getTriggerSchemaList()[0]),m=await i.operationManager.createOrGetOperation(ve.randomId(),i.operationManager.getOperationSchemaList()[0]);await i.addInteraction(h,m),r(w=>w+1)};async function c(h){await i.removeInteraction(h.id),r(m=>m+1)}const{data:f=0,loading:g}=Z.useRequest(async()=>{try{return(await i.triggerManager.getTriggerSchemaList()).length}catch{return 0}});return p(a.Stack,{children:[n(a.LoadingOverlay,{visible:g}),f===0&&n(a.Alert,{icon:n(k.AlertCircle,{size:16}),title:"Unavailable",color:"gray",children:"This visualization does not have available interactions to choose from"}),l.map(h=>n(ky,{onRemove:c,instance:s,sampleData:o,variables:u,item:h,manager:e.interactionManager},h.id)),n(a.Button,{style:{width:"fit-content"},onClick:()=>d(),disabled:f===0,children:"Add interaction"})]})},My=()=>{const{panel:e,data:t}=Ce(),r=e.viz,{vizManager:i}=b.useContext(qe),s=e.json,o=Z.useCreation(()=>i.getOrCreateInstance(s),[i,s]),u=Z.useCreation(()=>new sr(o,i.resolveComponent(r.type),tn),[o,r.type]);return b.useEffect(()=>o.instanceData.watchItem(null,v.throttle(l=>{e.viz.setConf(l)},100,{leading:!1,trailing:!0})),[o]),{instance:o,vizManager:i,interactionManager:u,sampleData:t,variables:[]}},Iy=()=>{const e=My();return n(Dy,{...e})};var ja=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(ja||{}),nn=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(nn||{});class Ay{constructor(t){O(this,"vizInstance");O(this,"operationManager");O(this,"triggerManager");O(this,"vizManager");O(this,"runningMigration");O(this,"panelModel");O(this,"status","notStarted");this.panelModel=t.getRequired(be.instanceScope.panelModel),this.vizInstance=t.getRequired(be.instanceScope.vizInstance),this.operationManager=t.getRequired(be.instanceScope.operationManager),this.triggerManager=t.getRequired(be.instanceScope.triggerManager),this.vizManager=t.getRequired(be.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(r){return console.warn("check migration failed",r),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(r=>r())),"migrated"}catch(r){return console.warn("migration failed",r),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(t=>(this.status="done",t))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),r={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(r)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),r={configData:this.vizInstance.instanceData};return t.migrator.needMigration(r)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function Ra(e){const{panel:t}=Ce();return b.useCallback(r=>{const i=r.getRequired(be.vizManager),s=i.resolveComponent(e.viz.type);return r.createScoped().provideFactory(be.instanceScope.vizInstance,()=>i.getOrCreateInstance(e)).provideFactory(be.instanceScope.interactionManager,o=>{const u=o.getRequired(be.instanceScope.vizInstance);return new sr(u,s,tn)}).provideFactory(be.instanceScope.operationManager,o=>o.getRequired(be.instanceScope.interactionManager).operationManager).provideFactory(be.instanceScope.triggerManager,o=>o.getRequired(be.instanceScope.interactionManager).triggerManager).provideValue(be.instanceScope.panelModel,t).provideFactory(be.instanceScope.migrator,o=>new Ay(o))},[e.viz.type,e.viz.conf])}function Ya(e){const[t,r]=b.useState(!1),i=zi().getRequired(be.instanceScope.migrator);return Z.useAsyncEffect(async()=>{const s=i.status===nn.notStarted;r(i.status===nn.done),i.status===nn.notStarted&&i.runMigration().then(o=>{o===ja.migrated&&s&&(e==null||e())}).finally(()=>{r(!0)})},[i]),t}function Qa(e,t){const r=zi().getRequired(be.instanceScope.vizInstance);return b.useEffect(()=>(r.instanceData.setItem(null,t.viz.conf),r.instanceData.watchItem(null,i=>{e(i)})),[e,t.viz.type]),r}function $y({setVizConf:e,...t}){const{panel:r}=t,i=Qa(e,r),s=Ya(()=>{Vt.showNotification({title:`${r.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return Z.useAsyncEffect(async()=>{await i.instanceData.setItem(null,r.viz.conf)},[i,r.viz.type]),s?n(Ko,{...t}):n(a.Text,{children:"Checking update..."})}function zy(e){const{panel:t,setVizConf:r}=e;Qa(r,t);const{inEditMode:i}=b.useContext(Ke);return Ya(()=>{i&&Vt.showNotification({title:`${t.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?n(Zo,{...e}):n(a.Text,{children:"Checking update"})}const P1="";function Ey(e,t){const{vizManager:r}=b.useContext(qe),{panel:{viz:i,title:s,id:o,description:u,queryID:l,variables:d}}=Ce(),c={title:s,id:o,description:u,queryID:l,viz:i,layout:t},f=Ra(c);try{return r.resolveComponent(i.type),n(Gt,{configure:f,children:n(zy,{setVizConf:i.setConf,panel:c,data:e,variables:d,vizManager:r})})}catch(g){return console.info(v.get(g,"message")),null}}const Ly=["richText","button"],Ua=T.observer(function({height:t,viz:r,data:i,loading:s,error:o,query:u}){const{ref:l,width:d,height:c}=ve.useElementSize(),f=Ey(i,{w:d,h:c});if(Ly.includes(r.type))return n("div",{className:"viz-root",style:{height:t},ref:l,children:n(ke,{children:f})});if(s)return n("div",{className:"viz-root",style:{height:t,position:"relative"},ref:l,children:n(a.LoadingOverlay,{visible:s,exitTransitionDuration:0})});const h=!!o,m=!h&&!!(u!=null&&u.stateMessage),w=!h&&!m;return p("div",{className:"viz-root",style:{height:t},ref:l,children:[h&&n(a.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:o}),m&&n(a.Text,{color:"gray",align:"center",children:u.stateMessage}),w&&n(ke,{children:f})]})});function Py(e){return!["richText","button"].includes(e)}const Oy={border:"1px solid #e9ecef"},Xa={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function Vy(e,t,r){return e.style.border.enabled?Oy:r||t?Xa:{border:"1px dashed transparent"}}const rn=T.observer(function({panel:t,view:r}){const i=F(),{inEditMode:s}=b.useContext(Ke),{data:o,state:u,error:l}=i.getDataStuffByID(t.queryID),d=i.queries.findByID(t.queryID),c=Py(t.viz.type),f=c&&u==="loading",g=t.title?"calc(100% - 25px - 5px)":"100%",h=Vy(t,c,s),m=c||s;return n(Cn,{value:{panel:t,data:o,loading:f},children:p(a.Box,{className:"panel-root",p:5,pt:0,sx:{...h},children:[n(a.Box,{sx:{position:"absolute",left:0,top:0,height:28,zIndex:310},children:n(Gi,{})}),m&&n(Yo,{view:r}),n(Qo,{}),n(Ua,{viz:t.viz,data:o,loading:f,error:l,height:g,query:d})]})})}),O1="",By=b.forwardRef(({h:e},t)=>n(a.ActionIcon,{ref:t,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:5,right:e>38?5:20,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:n(k.ArrowsMove,{size:16})})),Ny=b.forwardRef(({handleAxis:e,...t},r)=>n(a.ActionIcon,{ref:r,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:n(k.ChevronDownRight,{size:16})})),Gy=Ot.WidthProvider(Ot),qy=T.observer(({view:e,className:t="layout"})=>{const r=F(),{panels:i,layouts:s}=r.panels.panelsByIDs(e.panelIDs),o=b.useCallback(l=>{l.forEach(({i:d,...c})=>{const f=r.panels.findByID(d);f&&f.layout.set(c)})},[r]),u=(l,d,c,f)=>{c.h<30&&(c.h=30,f.h=30),c.w<4&&(c.w=4,f.w=4)};return n(Gy,{onLayoutChange:o,className:`dashboard-layout ${t}`,rowHeight:1,cols:36,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,layout:s,draggableHandle:".react-grid-customDragHandle",resizeHandle:n(Ny,{}),onResize:u,children:i.map((l,d)=>p("div",{"data-grid":{...l.layout},className:"panel-grid-item",children:[n(By,{h:l.layout.h}),n(rn,{view:e,panel:l})]},l.id))})}),Fy=Ot.WidthProvider(Ot),Wy=T.observer(function({view:t,className:r="layout"}){const{panels:i,layouts:s}=F().panels.panelsByIDs(t.panelIDs);return n(Fy,{className:`dashboard-layout ${r}`,cols:36,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,layout:s,children:i.map(o=>n("div",{"data-grid":{...o.layout},className:"panel-grid-item",children:n(rn,{view:t,panel:o})},o.id))})});var Za=(e=>(e.Use="use",e.Edit="edit",e))(Za||{}),K=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(K||{});const jy={div:"Division",tabs:"Tabs",modal:"Modal"},Ka={div:"rgba(255, 0, 0, 0.2)",modal:"rgba(0, 0, 0, 0.2)",tabs:"rgba(255, 200, 100, 0.4)"},Ry={div:"#ff4000",modal:"#000",tabs:"#ffad18"},Yy={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:"div",config:{},panelIDs:[]}],panels:[],filters:[],version:"8.57.0"};var or=(e=>(e.Select="select",e.TreeSelect="tree-select",e.MultiSelect="multi-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(or||{});const Qy=T.observer(({children:e})=>n(a.Box,{pt:10,pb:100,children:e})),Uy=T.observer(({children:e,view:t})=>{const r=t.config;return n(a.Modal,{size:r.width,overflow:"inside",opened:!0,onClose:v.noop,withCloseButton:!1,title:r.custom_modal_title.value,trapFocus:!0,onDragStart:i=>{i.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:e})}),Xy=({variant:e,orientation:t})=>{const r={tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(r.tab.paddingTop="6px",r.tab.paddingBottom="6px"),t==="vertical"&&(r.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},r.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),r},Zy=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},Ky=T.observer(({children:e,view:t})=>{const r=Le.useModals(),i=F(),s=b.useMemo(()=>i.views.options.filter(d=>d.type===K.Division),[t.id,i.views.options]),o=t.config,u=d=>r.openConfirmModal({title:"Delete this tab?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.removeTab(d)},confirmProps:{color:"red"},zIndex:320}),l=o.tabs.length===0;return p(a.Box,{className:"preview-view-tabs",children:[p(a.Tabs,{variant:o.variant,orientation:o.orientation,defaultValue:o.tabs.length>0?o.tabs[0].id:"0",styles:Xy(o),children:[p(a.Tabs.List,{grow:o.grow,children:[o.tabs.map(d=>n(a.Tabs.Tab,{value:d.id,sx:Zy(d),children:d.name??d.id},d.id)),n(a.Tabs.Tab,{onClick:o.addTab,value:"add",className:"add-a-tab",children:n(k.Plus,{size:18,color:"#228be6"})})]}),o.tabs.map((d,c)=>{const f=i.views.findByID(d.view_id);return p(a.Tabs.Panel,{value:d.id,sx:{position:"relative"},children:[p(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[n(a.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),p(a.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[n(a.TextInput,{label:"Tab Name",value:d.name,onChange:g=>d.setName(g.currentTarget.value)}),n(a.Select,{label:"View",value:d.view_id,onChange:d.setViewID,data:s}),n(a.ColorInput,{label:"Color",value:d.color,onChange:d.setColor,disabled:o.variant!=="default"}),f&&p(a.Button,{mt:20,variant:"gradient",leftIcon:n(V.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>i.views.setIDOfVIE(f.id),children:["Swith to View: ",f.name]}),n(a.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>u(c),disabled:l,leftIcon:n(V.IconTrash,{size:14}),children:"Delete This Tab"})]})]}),f&&n(an,{view:f})]},d.id)})]}),e]})}),Jy=T.observer(({view:e,children:t})=>{switch(e.type){case K.Modal:return n(Uy,{view:e,children:t});case K.Tabs:return n(Ky,{view:e,children:t});case K.Division:default:return n(Qy,{children:t})}}),Ja=T.observer(function({view:t}){return n(yn.Provider,{value:{viewPanelInFullScreen:v.noop,inFullScreen:!1},children:n(a.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:n(Jy,{view:t,children:p(a.Box,{sx:{position:"relative"},children:[n(a.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n(Ni,{view:t})}),n(qy,{view:t})]})})})})}),Hy={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},ev=T.observer(function({view:t,panel:r,exitFullScreen:i}){return n(a.Modal,{opened:!0,fullScreen:!0,onClose:i,title:n(a.Button,{color:"blue",size:"xs",onClick:i,leftIcon:n(k.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:Hy,children:n(a.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:n(rn,{view:t,panel:r})})})});function tv(e,t,r){const{panels:i}=F(),s=e.id==="Main",[o,u]=b.useState(()=>s&&i.findByID(t)?t:null),l=b.useCallback(g=>{u(g),s&&r(g)},[s,r]),d=b.useCallback(()=>{u(null),s&&r("")},[s,r]),c=o?i.findByID(o):null;return{viewPanelInFullScreen:l,exitFullScreen:d,inFullScreen:!!c,fullScreenPanel:c}}const nv=T.observer(({children:e})=>n(a.Box,{children:e})),rv=T.observer(({children:e,view:t})=>{const r=F(),i=t.config,s=r.views.visibleViewIDs.includes(t.id),o=()=>r.views.rmVisibleViewID(t.id);return n(a.Modal,{size:i.width,centered:!0,overflow:"inside",opened:s,onClose:o,withCloseButton:!1,title:i.custom_modal_title.value,trapFocus:!0,onDragStart:u=>{u.stopPropagation()},styles:{modal:{border:"1px solid #efefef"},body:{maxHeight:i.height,overflow:"auto"}},transitionDuration:0,children:e})}),iv=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},av=T.observer(({children:e,view:t})=>{const r=F(),i=t.config;return p(a.Box,{className:"render-view-tabs",children:[p(a.Tabs,{variant:i.variant,orientation:i.orientation,defaultValue:i.tabs.length>0?i.tabs[0].id:"0",styles:{panel:{padding:i.orientation==="horizontal"?"16px 0px":"0"}},keepMounted:!1,children:[n(a.Tabs.List,{grow:i.grow,children:i.tabs.map(s=>n(a.Tabs.Tab,{value:s.id,sx:iv(s),disabled:!s.view_id,children:s.name??s.id},s.id))}),i.tabs.map(s=>{const o=r.views.findByID(s.view_id);return o?n(a.Tabs.Panel,{value:s.id,children:n(an,{view:o})},s.id):null})]}),e]})}),sv=T.observer(({view:e,children:t})=>{switch(e.type){case K.Modal:return n(rv,{view:e,children:t});case K.Tabs:return n(av,{view:e,children:t});case K.Division:default:return n(nv,{children:t})}}),an=T.observer(function({view:t}){const{fullScreenPanelID:r,setFullScreenPanelID:i}=Oi(),{viewPanelInFullScreen:s,exitFullScreen:o,inFullScreen:u,fullScreenPanel:l}=tv(t,r,i);return n(yn.Provider,{value:{viewPanelInFullScreen:s,inFullScreen:u},children:p(a.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:[u&&n(ev,{view:t,panel:l,exitFullScreen:o}),n(sv,{view:t,children:p(a.Box,{sx:{position:"relative"},children:[!u&&n(a.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n(Ni,{view:t})}),!u&&n(Wy,{view:t})]})})]})})});function ov(e){e=e||{};const t=Object.keys(e).sort(),r=[];for(let i=0;i<t.length;i++){const s=t[i];if(s!="authentication"&&e[s])r.push(t[i]+"="+(typeof e[s]=="object"?JSON.stringify(e[s]):e[s]));else{const o=Object.keys(e[s]).sort();for(let u=0;u<o.length;u++){const l=o[u];l!="sign"&&e[s][l]&&r.push(o[u]+"="+(typeof e[s][l]=="object"?JSON.stringify(e[s][l]):e[s][l]))}}}return r.sort().join("&")}function lv(e,t){let r=ov(e);return r+="&key="+t,Mi.MD5(r).toString().toUpperCase()}const ze={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(e){if(!this.app_id||!this.app_secret)return;const t=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:t,sign:lv({app_id:this.app_id,nonce_str:t,...e},this.app_secret)}},getRequest(e,t){return(r,i,s={})=>{const o=window.localStorage.getItem("token"),u={"X-Requested-With":"XMLHttpRequest","Content-Type":s.string?"application/x-www-form-urlencoded":"application/json",authorization:o?`bearer ${o}`:"",...s.headers},l={baseURL:this.baseURL,method:e,url:r,params:e==="GET"?i:s.params,headers:u,signal:t};return["POST","PUT"].includes(e)&&(l.data=s.string?JSON.stringify(i):i,l.data.authentication=this.getAuthentication(l.data)),Xe(l).then(d=>d.data).catch(d=>Promise.reject(d))}}};function Ha(e){ze.baseURL!==e.apiBaseURL&&(ze.baseURL=e.apiBaseURL),e.app_id&&(ze.app_id=e.app_id),e.app_secret&&(ze.app_secret=e.app_secret)}const es=y.types.model("FilterConfigModel_Checkbox",{_name:y.types.literal("checkbox"),description:y.types.optional(y.types.string,""),default_value:y.types.boolean}).views(e=>({get json(){const{_name:t,description:r,default_value:i}=e;return{_name:t,description:r,default_value:i}},get isDescriptionEmpty(){const{description:t}=e;return t===""||t==="<p></p>"}})).actions(e=>({setDefaultValue(t){e.default_value=t},setDescription(t){e.description=t}})),uv=()=>es.create({_name:"checkbox",description:"",default_value:!1});var ce=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e))(ce||{}),we=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TreeSelect="tree-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(we||{});y.types.model({type:y.types.enumeration("DataSourceType",[ce.Postgresql,ce.MySQL,ce.HTTP]),key:y.types.string,sql:y.types.string});function ts(e,t){return e.map(r=>{try{return r?j.tz(r,"UTC").format(t):null}catch{return console.log(`[date-range] failed parsing ${r}`),null}})}const dv=y.types.model("FilterConfigModel_DateRange",{_name:y.types.literal("date-range"),required:y.types.boolean,inputFormat:y.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:y.types.optional(y.types.array(y.types.union(y.types.string,y.types.null)),[null,null]),clearable:y.types.boolean,max_days:y.types.optional(y.types.number,0),allowSingleDateInRange:y.types.optional(y.types.boolean,!1)}).views(e=>({get json(){const{_name:t,max_days:r,required:i,clearable:s,inputFormat:o,default_value:u,allowSingleDateInRange:l}=e;return{_name:t,max_days:r,required:i,clearable:s,inputFormat:o,default_value:ts(u,o),allowSingleDateInRange:l}},truthy(t){return Array.isArray(t)&&t.length===2&&t.every(r=>!!r)}})).views(e=>({getMaxDate(t){const{max_days:r}=e;if(!(!r||!t))return j(t).startOf("day").add(r,"days").toDate()},getMinDate(t){const{max_days:r}=e;if(!(!r||!t))return j(t).startOf("day").subtract(r,"days").toDate()}})).actions(e=>({setFilterValue(t){try{const r=y.getParent(e);y.getRoot(e).filters.setValueByKey(r.key,t)}catch(r){console.error(r)}}})).actions(e=>({setRequired(t){e.required=t},setClearable(t){e.clearable=t},setInputFormat(t){e.inputFormat=t},setDefaultValue(t){e.default_value.length=0,e.default_value.push(...t),e.setFilterValue(t)},setMaxDays(t){e.max_days=t,t>0&&(e.clearable=!0)},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),ns=y.types.snapshotProcessor(dv,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(r=>r===null?null:j.tz(r,"UTC").toISOString())}},postProcessor(e){const{default_value:t,...r}=e;return{...r,default_value:ts(t,r.inputFormat)}}}),cv=()=>ns.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),pv=y.types.model({label:y.types.string,value:y.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),lr=y.types.model("FilterConfigModel_BaseSelect",{static_options:y.types.optional(y.types.array(pv),[]),options_query_id:y.types.optional(y.types.string,""),default_selection_count:y.types.optional(y.types.number,0)}).views(e=>({get usingQuery(){return!!e.options_query_id}})).views(e=>({get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:r,error:i}=y.getRoot(e).content.getDataStuffByID(e.options_query_id);return r==="idle"?t:[]}})).actions(e=>({addStaticOption(t){e.static_options.push(t)},removeStaticOption(t){e.static_options.splice(t,1)},setDefaultSelectionCount(t){e.default_selection_count=t},setOptionsQueryID(t){e.options_query_id=t??""}})),sn=e=>v.cloneDeepWith(e,(t,r)=>{if(r!==void 0&&t)return se.toJS(t)}),rs=y.types.compose("FilterConfigModel_MultiSelect",y.types.model({_name:y.types.literal("multi-select"),min_width:y.types.optional(y.types.string,""),default_value:y.types.optional(y.types.array(y.types.string),[])}),lr).views(e=>({get json(){const{_name:t,default_value:r,min_width:i,static_options:s,options_query_id:o,default_selection_count:u}=e;return sn({_name:t,min_width:i,default_value:r,static_options:s,options_query_id:o,default_selection_count:u})},get default_selection(){return e.usingQuery?e.options.slice(0,e.default_selection_count).map(t=>t.value):e.default_value}})).actions(e=>({setDefaultValue(t){e.default_value=y.cast(t)},setMinWidth(t){e.min_width=t},setDefaultSelection(){const t=y.getRoot(e).content.filters,r=y.getParent(e).key;t.setValueByKey(r,e.default_selection)}})).actions(e=>({afterCreate(){y.addDisposer(e,se.reaction(()=>se.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!0,delay:0}))}})),hv=()=>rs.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),is=y.types.compose("FilterConfigModel_TreeSelect",y.types.model({_name:y.types.literal("tree-select"),min_width:y.types.optional(y.types.string,""),default_value:y.types.optional(y.types.array(y.types.string),[])}),lr).views(e=>({get json(){const{_name:t,default_value:r,min_width:i,static_options:s,options_query_id:o,default_selection_count:u}=e;return{_name:t,min_width:i,default_value:r,static_options:s,options_query_id:o,default_selection_count:u}}})).actions(e=>({setDefaultValue(t){e.default_value=y.cast(t)},setMinWidth(t){e.min_width=t}})),fv=()=>is.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),as=y.types.compose("FilterConfigModel_Select",y.types.model({_name:y.types.literal("select"),default_value:y.types.string,required:y.types.boolean,width:y.types.optional(y.types.string,"")}),lr).views(e=>({get json(){const{_name:t,default_value:r,required:i,width:s,static_options:o,options_query_id:u,default_selection_count:l}=e;return sn({_name:t,width:s,required:i,default_value:r,static_options:o,options_query_id:u,default_selection_count:l})},truthy(t){return!!t}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t},setWidth(t){e.width=t}})),gv=()=>as.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),ss=y.types.model("FilterConfigModel_TextInput",{_name:y.types.literal("text-input"),required:y.types.boolean,default_value:y.types.string}).views(e=>({get json(){const{_name:t,required:r,default_value:i}=e;return{_name:t,required:r,default_value:i}},truthy(t){return typeof t!="string"?!1:!!t.trim()}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),os=()=>ss.create({_name:"text-input",required:!1,default_value:""}),ur=y.types.model("FilterModel",{id:y.types.identifier,key:y.types.string,label:y.types.string,order:y.types.number,visibleInViewsIDs:y.types.array(y.types.string),auto_submit:y.types.optional(y.types.boolean,!1),type:y.types.enumeration("DashboardFilterType",[we.Select,we.MultiSelect,we.TreeSelect,we.TextInput,we.Checkbox,we.DateRange]),config:y.types.union(as,rs,is,ss,es,ns)}).views(e=>({get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==we.TreeSelect},get auto_submit_supported(){return[we.Select,we.Checkbox,we.DateRange].includes(e.type)}})).views(e=>({get json(){const{id:t,key:r,label:i,order:s,visibleInViewsIDs:o,auto_submit:u,type:l,config:d}=e;return{id:t,key:r,type:l,label:i,order:s,config:d.json,auto_submit:u,visibleInViewsIDs:se.toJS(o)}},get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return v.get(e.config,"required",!1)?v.get(e.config,"truthy",()=>!0)(t):!1}})).actions(e=>({setKey(t){e.key=t},setLabel(t){e.label=t},setOrder(t){e.order=t},setType(t){switch(t){case we.Select:e.config=gv();break;case we.MultiSelect:e.config=hv();break;case we.TreeSelect:e.config=fv();break;case we.TextInput:e.config=os();break;case we.Checkbox:e.config=uv();break;case we.DateRange:e.config=cv();break}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t}}));function ls(e,t){if(e===void 0)return e;if(t._name==="date-range")try{const[...r]=e;return r.map(i=>i===null?i:j.tz(i,"UTC").format(t.inputFormat)??i)}catch(r){return console.error(r),e}return e}function us(e){return e.reduce((t,r)=>(t[r.key]=ls(r.config.default_value,r.config),t),{})}function mv(e,t,r){y.addDisposer(e,y.addMiddleware(e,(i,s)=>{s(i,()=>{y.getType(i.context)===t&&i.type==="action"&&r(i.name,i.context)})}))}const ds=y.types.model("FiltersModel",{current:y.types.optional(y.types.array(ur),[]),values:y.types.optional(y.types.frozen(),{}),previewValues:y.types.optional(y.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(r=>r.id===t)},get inOrder(){return v.sortBy(e.current,"order")},get options(){return e.current.map(t=>({label:t.label??t.id,value:t.id,_type:"filter"}))},get empty(){return e.current.length===0},visibleInView(t){return v.sortBy(e.current.filter(r=>r.visibleInViewsIDs.includes(t)),"order")},get firstFilterValueKey(){return Object.keys(e.values)[0]??""},get keyLabelMap(){return e.current.reduce((t,r)=>(t[r.key]=r.label,t),{})}})).actions(e=>({replace(t){e.current=y.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByID(t){const r=e.current.findIndex(i=>i.id===t);r>=0&&e.current.splice(r,1)},setValues(t){e.values=t},setValueByKey(t,r){e.values={...e.values,[t]:r}},getValueByKey(t){return e.values[t]},refreshValues(){console.log("refreshing values"),e.values=us(e.current)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){mv(e.current,ur,(r,i)=>{if(r==="setType"){const s=ls(i.config.default_value,i.config);e.setValueByKey(i.key,s),e.updatePreviewValues({...e.previewValues,[i.key]:s})}})}return{afterCreate(){t()}}});function cs(e){return{current:e,values:us(e)}}const ps="\uFEFF";function bv(e,t){const r=new Blob([ps+t],{type:"text/csv"});gn.saveAs(r,`${e}.csv`)}function yv(e,t){const r=new Blob([t],{type:"application/json"});gn.saveAs(r,`${e}.json`)}function vv(e){const t=new mo;e.forEach(({id:r,data:i})=>{t.file(`${r}.csv`,fs(i))}),t.generateAsync({type:"blob"}).then(r=>{gn.saveAs(r,"dashboard_data.zip")})}function hs(e){return e.includes(",")?`"${e}"`:e}function fs(e){if(!Array.isArray(e)||e.length===0)return"";const t=[],r=Object.keys(e[0]).map(hs);return t.push(r.join(",")),e.forEach(i=>{const s=Object.values(i).map(hs).join(",");t.push(s)}),ps+t.join(`
|
|
366
|
+
`}},show_in_legend:!0}))}function yb(e,t,r,i){const s=t.data_key,o=t.name,u=r.map(l=>{const d=v.sumBy(i[l],s);return[l,d]});return{type:"line",name:o,xAxisIndex:3,yAxisIndex:3,color:"#b41529",data:u,show_in_legend:!1}}function vb(e,t,r,i){const u={barMinWidth:5,barMaxWidth:20};return[hb(e,r,i),gb(e,r,i,u),...bb(e,r,i,u),yb(e,t,r,i)]}function xb(e,t){const{axisLabel:r}=e.x_axis;return[{data:t,id:"准确估算比例",gridIndex:0,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"平均偏差",gridIndex:1,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!0,lineStyle:{color:"#FFFFFF",width:2}},type:"category"},{data:t,id:"数量占比",gridIndex:2,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"代码当量",gridIndex:3,axisTick:{show:!1},type:"category",axisLabel:{...r,formatter:ya(r.formatter)},axisLine:{show:!1}}]}function Cb(e){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:e.name,nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:3,position:"left",axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}}]}function rr(e){return e==1||e==2?1:rr(e-2)+rr(e-1)}const wb=Array.from(new Array(20),(e,t)=>rr(t+1));function Ga(e){return e<=1?e:wb.findIndex(t=>e<=t)-1}function _b(e,t){const{estimated_value:r,actual_value:i}=e.deviation.data_keys;return t.map(s=>{const o=Ga(s[r]),u=Ga(s[i]),l=o-u;return{...s,level:{estimated:o,actual:u,diff:l}}})}function Sb(e){return e==="rgba(255, 255, 255, 1)"?{borderColor:"rgba(0,0,0,.1)",borderWidth:1}:{}}function Tb(e){return{show:!0,orient:"vertical",top:"middle",right:0,data:e.filter(r=>r.show_in_legend).reverse().map(r=>({name:`${r.name}`,color:r.color,itemStyle:Sb(r.color)})),tooltip:{show:!0,formatter:"档位偏差:{a}"}}}const kb={tooltip:{trigger:"axis"}};function Db(e,t){const{deviation:r,metrics:i}=e,s=i.find(u=>u.data_key===t);if(s)return s;const o=r.data_keys.actual_value;return{id:o,name:r.name,data_key:o}}function Mb(e,t,r){const i=_b(e,r),s=v.uniqBy(r,e.x_axis.data_key).map(c=>c[e.x_axis.data_key]),o=v.groupBy(i,e.x_axis.data_key),u=Db(e,t),l=vb(e,u,s,o),d={xAxis:xb(e,s),yAxis:Cb(u),series:l,grid:pb(),visualMap:[{min:0,max:1,calculable:!0,show:!1,seriesIndex:0,color:["#F0F0F0","#418AAF"]}],legend:Tb(l)};return v.defaultsDeep({},d,kb)}const ir={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,formatter:{...Jt}}},deviation:{name:"",data_keys:{estimated_value:"",actual_value:""}},metrics:[]},Ib={input:{border:"none !important",paddingLeft:0,lineHeight:"1.55 !important"}},Ab=({conf:e,metricKey:t,setMetricKey:r})=>{const{deviation:i,metrics:s}=e,o=b.useMemo(()=>{const u=s.map(l=>({label:l.name,value:l.data_key}));return u.push({label:i.name?i.name:i.data_keys.actual_value,value:i.data_keys.actual_value}),u},[i,s]);return p(a.Group,{spacing:1,children:[n(a.Text,{size:12,color:"dimmed",sx:{cursor:"default",userSelect:"none"},children:"基线指标"}),n(a.NativeSelect,{size:"xs",data:o,value:t,onChange:u=>r(u.currentTarget.value),styles:Ib})]})},$b={"tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function zb(){return p(a.HoverCard,{width:400,shadow:"md",children:[n(a.HoverCard.Target,{children:n(a.Button,{size:"xs",variant:"subtle",compact:!0,leftIcon:n(V.IconInfoCircle,{size:14}),children:"指标说明"})}),n(a.HoverCard.Dropdown,{children:n(a.Table,{fontSize:14,sx:$b,children:p("tbody",{children:[p("tr",{children:[n("th",{children:"估算偏差"}),n("td",{children:"使用斐波那契数列(1,2,3,5,8,13)估算故事点,每个数位为一个档位,计算issue实际故事点与估算故事点的档位偏差,即为估算偏差。如估算故事点为5,实际故事点为8,则估算偏差为-1。"})]}),p("tr",{children:[n("th",{children:"准确估算比例"}),n("td",{children:"偏差在 ± 1 档位内的 issue 均为准确估算,以此计算准确估算的比例。"})]})]})})})]})}function Eb(e){return p(a.Group,{position:"apart",children:[n(zb,{}),n(Ab,{...e})]})}le.use([de.BarChart,de.LineChart,de.HeatmapChart,N.GridComponent,N.LegendComponent,N.TooltipComponent,Ie.CanvasRenderer,N.VisualMapComponent]);function Lb({conf:e,data:t,width:r,height:i,metricKey:s}){const o=b.useMemo(()=>Mb(e,s,t),[e,t,s]);return!r||!i?null:n(Ae,{echarts:le,option:o,style:{width:r,height:i},notMerge:!0,theme:"merico-light"})}function Pb({context:e}){const{value:t}=W(e.instanceData,"config"),r=b.useMemo(()=>v.defaults({},t,ir),[t]),i=e.data,{width:s,height:o}=e.viewport,{x_axis:u,deviation:l}=r,{estimated_value:d,actual_value:c}=l.data_keys,[f,g]=b.useState(c);if(b.useEffect(()=>{g(w=>w||c)},[c]),!u.data_key||!d||!c)return null;const h=Math.max(s,300),m=Math.max(o,370);return p(a.Box,{sx:{overflow:"hidden",height:m,width:h},children:[n(Eb,{conf:r,metricKey:f,setMetricKey:g}),n(Lb,{width:h,height:m-30,data:i,conf:r,metricKey:f})]})}function Ob({data:e,control:t,watch:r}){return r(["x_axis"]),p(a.Stack,{children:[p(a.Group,{grow:!0,noWrap:!0,children:[n(x.Controller,{name:"x_axis.data_key",control:t,render:({field:i})=>n(R,{label:"数据字段",required:!0,data:e,sx:{flex:1},...i})}),n(x.Controller,{name:"x_axis.name",control:t,render:({field:i})=>n(a.TextInput,{label:"X轴名称",sx:{flex:1},...i})})]}),n(a.Divider,{mb:-15,label:"点位文案",labelPosition:"center"}),p(a.Group,{grow:!0,noWrap:!0,children:[n(x.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:i})=>n(a.NumberInput,{label:"旋转",hideControls:!0,min:-90,max:90,rightSection:n(a.Text,{color:"dimmed",children:"度"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...i})}),n(x.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:i})=>n(Ca,{data:e,...i})})]})]})}function Vb({data:e,control:t,watch:r}){return r(["deviation"]),p(a.Stack,{children:[n(a.Group,{grow:!0,noWrap:!0,children:n(x.Controller,{name:"deviation.name",control:t,render:({field:i})=>n(a.TextInput,{label:"指标名称",sx:{flex:1},...i})})}),p(a.Group,{grow:!0,noWrap:!0,children:[n(x.Controller,{name:"deviation.data_keys.estimated_value",control:t,render:({field:i})=>n(R,{label:"估算值字段",required:!0,data:e,sx:{flex:1},...i})}),n(x.Controller,{name:"deviation.data_keys.actual_value",control:t,render:({field:i})=>n(R,{label:"实际值字段",required:!0,data:e,sx:{flex:1},...i})})]})]})}const Bb=({control:e,data:t,index:r,remove:i})=>p(a.Stack,{children:[p(a.Group,{grow:!0,noWrap:!0,children:[n(x.Controller,{name:`metrics.${r}.name`,control:e,render:({field:s})=>n(a.TextInput,{label:"Name",required:!0,sx:{flex:1},...s})}),n(x.Controller,{name:`metrics.${r}.data_key`,control:e,render:({field:s})=>n(R,{label:"Value Field",required:!0,data:t,sx:{flex:1},...s})})]}),n(a.Divider,{mb:-10,mt:10,variant:"dashed"}),n(a.Button,{leftIcon:n(k.Trash,{size:16}),color:"red",variant:"light",onClick:()=>i(r),sx:{top:15,right:5},children:"Delete this Metric"})]}),Nb=({control:e,watch:t,data:r})=>{const{fields:i,append:s,remove:o}=x.useFieldArray({control:e,name:"metrics"}),u=t("metrics"),l=i.map((h,m)=>({...h,...u[m]})),d=()=>s({id:Date.now().toString(),data_key:"",name:""}),c=t("metrics.0.id"),[f,g]=b.useState(()=>c??null);return b.useEffect(()=>{c&&g(h=>h!==null?h:c)},[c]),p(B,{children:[p(a.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[n(k.InfoCircle,{size:14,color:"#888"}),n(a.Text,{size:14,color:"#888",children:"设置可以展示在基线图的指标,例如代码当量"})]}),n(a.Divider,{variant:"dashed",my:10}),p(a.Tabs,{value:f,onTabChange:h=>g(h),styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[p(a.Tabs.List,{children:[l.map((h,m)=>n(a.Tabs.Tab,{value:h.id,children:h.name?h.name:m},h.id)),n(a.Tabs.Tab,{onClick:d,value:"add",children:n(k.Plus,{size:18,color:"#228be6"})})]}),l.map((h,m)=>n(a.Tabs.Panel,{value:h.id,children:n(Bb,{control:e,index:m,remove:o,data:r},h.id)},h.id))]})]})};function Gb({context:e}){const{value:t,set:r}=W(e.instanceData,"config"),i=e.data,s=b.useMemo(()=>v.defaultsDeep({},t,ir),[t]),{control:o,handleSubmit:u,watch:l,getValues:d,reset:c}=x.useForm({defaultValues:s});b.useEffect(()=>{c(s)},[s]),l([]);const f=d(),g=b.useMemo(()=>!v.isEqual(f,s),[f,s]);return n(a.Stack,{spacing:"xs",children:p("form",{onSubmit:u(r),children:[p(a.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[n(a.Text,{children:"Merico Estimation Chart Config"}),n(a.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!g,children:n(k.DeviceFloppy,{size:20})})]}),p(a.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"12px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(a.Tabs.List,{children:[n(a.Tabs.Tab,{value:"X Axis",children:"X 轴"}),n(a.Tabs.Tab,{value:"Deviation",children:"偏差"}),n(a.Tabs.Tab,{value:"Additional Metrics",children:"指标"})]}),n(a.Tabs.Panel,{value:"X Axis",children:n(Ob,{control:o,watch:l,data:i})}),n(a.Tabs.Panel,{value:"Deviation",children:n(Vb,{control:o,watch:l,data:i})}),n(a.Tabs.Panel,{value:"Additional Metrics",children:n(Nb,{control:o,watch:l,data:i})})]})]})})}class qb extends he{constructor(){super(...arguments);O(this,"VERSION",1)}configVersions(){this.version(1,r=>({version:1,config:r}))}}const Fb={displayName:"Merico Estimation Chart",displayGroup:"Merico suite",migrator:new qb,name:"mericoEstimationChart",viewRender:Pb,configRender:Gb,createConfig:()=>({version:1,config:ir})},Wb=[{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(e=>({name:e.name,value:e.value,type:"single",category:"basic"})),jb=[Jo,Ho,nl,tl,el,rl],qa=()=>({id:"dashboard",version:Tn,manifest:{viz:[Zn,kf,Rg,dh,Qf,gp,cb,pl,eu,ic,zc,km,dp,Od,yf,$p,ah,Hg,Fb,fu],color:[...Wb,...jb]}}),Mt=new sl,be={pluginManager:Re("pluginManager"),vizManager:Re("vizManager"),colorManager:Re("colorManager"),instanceScope:{panelModel:Re("panelModel"),vizInstance:Re("vizInstance"),interactionManager:Re("interactionManager"),migrator:Re("migrator"),operationManager:Re("operationManager"),triggerManager:Re("triggerManager")}},ar=()=>{try{Mt.install(qa())}catch{}const e=new Xo(Mt),t=new al(Mt);return{pluginManager:Mt,vizManager:e,colorManager:t}},qe=b.createContext(ar());try{Mt.install(qa())}catch{}function Rb(e,t){const{value:r,set:i}=W(e.operation.operationData,"config"),[s,o]=b.useState(v.defaults({},r,t)),u=async()=>{await i(s)};return b.useEffect(()=>{o(v.defaults({},r,t))},[r]),{config:s,setConfig:o,commit:u}}function Yb(e){const{config:t,setConfig:r,commit:i}=Rb(e,{urlTemplate:"",openInNewTab:!0});async function s(){await i()}async function o(l){r({...t,openInNewTab:l}),await i()}const u=l=>r({...t,urlTemplate:l.currentTarget.value});return p(a.Stack,{children:[n(a.TextInput,{label:"Url",value:t.urlTemplate,onChange:u,onBlur:s}),n(a.Switch,{label:"Open in new Tab",checked:t.openInNewTab,onChange:l=>o(l.currentTarget.checked)})]})}async function Qb(e,t){const{urlTemplate:r,openInNewTab:i}=await t.operationData.getItem("config");window.dispatchEvent(new CustomEvent("open-link",{detail:{urlTemplate:r,openInNewTab:i,payload:e}}))}class Ub extends he{constructor(){super(...arguments);O(this,"VERSION",1)}configVersions(){this.version(1,r=>r)}}const Xb={displayName:"Open Link",id:"builtin:op:open-link",configRender:Yb,run:Qb,migrator:new Ub,createDefaultConfig:()=>({version:1,config:{urlTemplate:"",openInNewTab:!0}})};function Zb(e){const{value:t,set:r}=W(e.operationData,"config"),i=s=>void r({template:s});return[(t==null?void 0:t.template)||"",i]}function Kb(e){const[t,r]=Zb(e.operation);return n(a.TextInput,{defaultValue:t,onBlur:i=>r(i.currentTarget.value),label:"console.log"})}async function Jb(e,t){const r=await t.operationData.getItem("config"),i=v.template(r.template||"");console.log("run with payload",e),console.log(i(e))}const Hb={displayName:"console.log (debug)",id:"builtin:op:debug",configRender:Kb,run:Jb},ey=T.observer(e=>{const t=F(),{value:r,set:i}=W(e.operation.operationData,"config");console.log({value:r,viewID:r==null?void 0:r.viewID});const s=(r==null?void 0:r.viewID)||"",o=u=>void i({viewID:u});return n(a.Select,{defaultValue:s,value:s,onChange:o,label:"View",data:t.views.options})});async function ty(e,t){const i=(await t.operationData.getItem("config")).viewID;window.dispatchEvent(new CustomEvent("open-view",{detail:{viewID:i}}))}const ny={displayName:"Open View",id:"builtin:op:open_view",configRender:ey,run:ty},ry={dictionary:{}},iy=T.observer(e=>{const t=F(),{value:r=ry,set:i}=W(e.operation.operationData,"config"),{dictionary:s={}}=r,o=(d,c)=>{i({dictionary:{...s,[d]:c}})},u=()=>{o(t.filters.firstFilterValueKey,"")},l=d=>{const c={...s};delete c[d],i({dictionary:c})};return p(a.Stack,{spacing:10,children:[n(a.Text,{children:"Mapping Rules"}),Object.entries(s).map(([d,c])=>p(a.Flex,{justify:"space-between",gap:10,children:[n(a.TextInput,{label:"Payload key",value:c,onChange:f=>{o(d,f.currentTarget.value)},sx:{flexGrow:1}}),n(R,{data:[t.filters.values],value:d,onChange:f=>{o(f,c)},label:"Filter key",sx:{flexGrow:1}}),n(a.ActionIcon,{onClick:()=>l(d),sx:{marginTop:"26px",flexGrow:0},children:n(k.Trash,{size:14,color:"red"})})]},d)),n(a.Button,{size:"xs",onClick:u,sx:{alignSelf:"center",width:"300px"},children:"Add one mapping rule"})]})});async function ay(e,t){const i=(await t.operationData.getItem("config")).dictionary;window.dispatchEvent(new CustomEvent("set-filter-values",{detail:{dictionary:i,payload:e}}))}const sy={displayName:"Set Filter Values",id:"builtin:op:set_filter_values",configRender:iy,run:ay},oy={filter_keys:[]},ly=T.observer(e=>{const t=F(),{value:r=oy,set:i}=W(e.operation.operationData,"config"),{filter_keys:s=[]}=r,o=l=>{i({filter_keys:[...l]})},u=b.useMemo(()=>t.filters.current.map(l=>({label:l.label,value:l.key})),[t.filters.values]);return n(a.Stack,{spacing:10,children:n(a.MultiSelect,{label:"Select Filters to Clear",data:u,value:s,onChange:o})})});async function uy(e,t){const i=(await t.operationData.getItem("config")).filter_keys;window.dispatchEvent(new CustomEvent("clear-filter-values",{detail:{filter_keys:i,payload:e}}))}const tn=[Hb,Xb,ny,sy,{displayName:"Clear Filter Values",id:"builtin:op:clear_filter_values",configRender:ly,run:uy}];class dy{constructor(t,r=tn){O(this,"attachments");this.operations=r;const i=async s=>{const{id:o,schemaRef:u}=await s.getItem(null);return{id:o,schemaRef:u,operationData:new lt(s,"data")}};this.attachments=new Sn(t,"__OPERATIONS",i)}async runOperation(t,r){const i=await this.attachments.getInstance(t);if(!i){console.warn(`Operation '${t}' is not defined`);return}const s=this.tryGetSchema(i.schemaRef);if(!s){console.warn(`Operation schema '${i.schemaRef}' is not defined`);return}await s.run(r,i)}tryGetSchema(t){return this.operations.find(r=>r.id===t)}async needMigration(){const r=(await this.attachments.list()).map(async i=>{const s={configData:i.operationData},o=this.tryGetSchema(i.schemaRef),u=o==null?void 0:o.migrator;return u&&await u.needMigration(s)});return(await Promise.all(r)).some(i=>i)}async runMigration(){const r=(await this.attachments.list()).map(async i=>{const s={configData:i.operationData},o=this.tryGetSchema(i.schemaRef),u=o==null?void 0:o.migrator;u&&await u.needMigration(s)&&await u.migrate(s)});await Promise.all(r)}async createOrGetOperation(t,r){var u;if(!this.getOperationSchemaList().some(l=>l.id===r.id))throw new Error(`Operation schema '${r.id}' is not defined`);const s=await this.attachments.getInstance(t);return!s||s.schemaRef!==r.id?await this.attachments.create(t,{id:t,schemaRef:r.id,data:((u=r.createDefaultConfig)==null?void 0:u.call(r))??{}}):s}getOperationList(){return this.attachments.list()}getOperationSchemaList(){return this.operations}removeOperation(t){return this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}}const Fa="__TRIGGERS";class cy{constructor(t,r){O(this,"attachments");this.instance=t,this.component=r;const i=async s=>{const{id:o,schemaRef:u}=await s.getItem(null);return{id:o,schemaRef:u,triggerData:new lt(s,"data")}};this.attachments=new Sn(t,Fa,i)}watchTriggerSnapshotList(t){return this.instance.instanceData.watchItem(Fa,r=>{const i=v.values(r).map(s=>({id:v.get(s,"id"),schemaRef:v.get(s,"schemaRef"),config:se.toJS(v.get(s,"data.config"))}));t(i)},{fireImmediately:!0})}async createOrGetTrigger(t,r,i={recreate:!1}){var l;if(!this.getTriggerSchemaList().some(d=>d.id===r.id))throw new Error(`Trigger schema '${r.id}' is not defined in component '${this.component.name}'`);const o=await this.attachments.getInstance(t);return!o||i.recreate||o.schemaRef!==r.id?await this.attachments.create(t,{id:t,schemaRef:r.id,data:((l=r==null?void 0:r.createDefaultConfig)==null?void 0:l.call(r))||{}}):o}async getTriggerList(){return await this.attachments.list()}getTriggerSchemaList(){return this.component.triggers||[]}async removeTrigger(t){await this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}async getMigrationTasks(){const r=(await this.getTriggerList()).map(async i=>{const s=this.getTriggerSchemaList().find(l=>l.id===i.schemaRef),o=s==null?void 0:s.migrator,u={configData:i.triggerData};return o&&await o.needMigration(u)?()=>o.migrate(u):null});return Promise.all(r).then(i=>i.filter(s=>s))}async needMigration(){return(await this.getMigrationTasks()).length>0}async runMigration(){const t=await this.getMigrationTasks();await Promise.all(t.map(r=>r()))}}class sr{constructor(t,r,i){O(this,"operationManager");O(this,"triggerManager");O(this,"attachments");this.operationManager=new dy(t,i),this.triggerManager=new cy(t,r);const s=async o=>{const{id:u,triggerRef:l,operationRef:d}=await o.getItem(null);return{id:u,triggerRef:l,operationRef:d}};this.attachments=new Sn(t,"__INTERACTIONS",s)}async addInteraction(t,r){const i=t.id,s=r.id,o=`[${i}]:[${s}]`;await this.attachments.create(o,{id:o,triggerRef:i,operationRef:s})}getInteractionList(){return this.attachments.list()}async removeInteraction(t){const r=await this.attachments.getInstance(t);if(!r)return;const{triggerRef:i,operationRef:s}=r;await this.getTriggerRefCount(i)<=1&&await this.triggerManager.removeTrigger(i),await this.getOperationRefCount(s)<=1&&await this.operationManager.removeOperation(s),await this.attachments.remove(t)}async getOperationRefCount(t){return(await this.getInteractionList()).filter(i=>i.operationRef===t).length}async getTriggerRefCount(t){return(await this.getInteractionList()).filter(i=>i.triggerRef===t).length}async runInteraction(t,r){const s=(await this.getInteractionList()).filter(o=>o.triggerRef===t);await Promise.all(s.map(async o=>{try{return await this.operationManager.runOperation(o.operationRef,r)}catch(u){console.warn(`Failed to run operation '${o.operationRef}'`,u)}}))}}const Fe=({vizManager:e,instance:t})=>Z.useCreation(()=>new sr(t,e.resolveComponent(t.type),tn),[t,e]),Wa=e=>{const{title:t="Variables",variables:r}=e,i=ve.useClipboard(),s=o=>{i.copy(o),Vt.showNotification({color:"green",message:"Copied to clipboard"})};return p(a.Paper,{withBorder:!0,p:"sm",children:[n(a.Text,{size:"xs",color:"dimmed",mb:"sm",children:t}),n(a.Stack,{style:{maxHeight:"500px"},children:r.map(o=>p(a.Text,{size:"sm",children:[p(a.Code,{color:"teal",children:["// ",o.description]}),n("br",{}),p(a.Code,{onClick:()=>s(o.name),style:{cursor:"pointer"},children:[o.name," : ",o.valueType]})]},o.name))})]})};class py{constructor(t,r){O(this,"operationId");O(this,"operation");O(this,"operationSchema");O(this,"variables",[]);this.operationManager=t,this.instance=r,se.makeAutoObservable(this)}get schemaList(){return this.operationManager.getOperationSchemaList()}async configOperation(t,r){const i=await this.operationManager.retrieveTrigger(t),s=this.operationManager.getOperationSchemaList().find(o=>o.id===(i==null?void 0:i.schemaRef));se.runInAction(()=>{this.operationId=t,this.operation=i,this.operationSchema=s,this.variables=r})}async changeSchema(t){this.operationId&&(await this.operationManager.createOrGetOperation(this.operationId,t),await this.configOperation(this.operationId,this.variables))}}function hy(e){return!!e.operationId}const fy=T.observer(({model:e,onClick:t})=>{var i;const r=(i=e.operationSchema)==null?void 0:i.displayName;return n(a.Button,{variant:"outline",onClick:t,children:r})}),gy=T.observer(({model:e})=>{const t={operation:e.operation,instance:e.instance,variables:[]};return b.createElement(e.operationSchema.configRender,t)});function my({model:e}){const t=e.schemaList,r=t.map(s=>({label:s.displayName,value:s.id}));async function i(s){await e.changeSchema(t.find(o=>o.id===s))}return n(a.Select,{label:"Operation",data:r,onChange:i,value:e.operationSchema.id})}const by=T.observer(e=>{const[t,{setTrue:r,setFalse:i}]=Z.useBoolean(!1),{operationManager:s,operationId:o,instance:u,variables:l}=e,d=Z.useCreation(()=>new py(s,u),[s,u]);return Z.useAsyncEffect(async()=>{await d.configOperation(o,l)},[o,d]),hy(d)?p(B,{children:[n(fy,{model:d,onClick:r}),n(a.Modal,{size:600,opened:t,onClose:i,title:"Operation Settings",closeButtonLabel:"close",zIndex:320,children:p(a.Stack,{children:[n(my,{model:d}),n(gy,{model:d}),n(Wa,{title:"Variables",variables:d.variables})]})})]}):null});class yy{constructor(t,r){O(this,"triggerId");O(this,"trigger");O(this,"triggerSchema");O(this,"sampleData");this.triggerManager=t,this.instance=r,se.makeAutoObservable(this)}get schemaList(){return this.triggerManager.getTriggerSchemaList()}async configTrigger(t,r){const i=await this.triggerManager.retrieveTrigger(t),s=this.triggerManager.getTriggerSchemaList().find(o=>o.id===(i==null?void 0:i.schemaRef));se.runInAction(()=>{this.triggerId=t,this.trigger=i,this.triggerSchema=s,this.sampleData=r})}async changeSchema(t){this.triggerId&&(await this.triggerManager.createOrGetTrigger(this.triggerId,t),await this.configTrigger(this.triggerId,this.sampleData))}isReady(){return vy(this)}}function vy(e){return!!e.triggerId&&!!e.triggerSchema}function xy(e,t){return Z.useCreation(()=>new yy(e,t),[e,t])}const Cy=T.observer(({model:e,onClick:t})=>{const r=e.triggerSchema.nameRender,i={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return n(a.Button,{variant:"outline",onClick:t,children:b.createElement(r,i)})}),wy=T.observer(({model:e})=>{const t=e.schemaList,r=t.map(s=>({label:s.displayName,value:s.id}));async function i(s){await e.changeSchema(t.find(o=>o.id===s))}return n(a.Select,{label:"Trigger",data:r,value:e.triggerSchema.id,onChange:i})}),_y=T.observer(({model:e})=>{const t={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return b.createElement(e.triggerSchema.configRender,t)}),Sy=T.observer(e=>{const[t,{setTrue:r,setFalse:i}]=Z.useBoolean(!1),s=e.model;return p(B,{children:[n(a.Modal,{opened:t,onClose:i,title:"Setup Trigger",closeButtonLabel:"close setup",zIndex:320,children:p(a.Stack,{children:[n(wy,{model:s}),n(_y,{model:s}),n(Wa,{title:"Payload",variables:s.triggerSchema.payload})]})}),n(Cy,{onClick:r,model:s})]})});function Ty(e,t){const[r,i]=b.useState([]);return Z.useAsyncEffect(async()=>{const s=await e.getInteractionList();i(s)},[t,e]),r}const ky=T.observer(({item:e,manager:t,instance:r,sampleData:i,variables:s,onRemove:o})=>{const{triggerRef:u,operationRef:l}=e,d=xy(t.triggerManager,r);if(Z.useAsyncEffect(async()=>{await d.configTrigger(u,i)},[d,u,i]),d.isReady()){const c=[...d.triggerSchema.payload,...s];return p(a.Group,{children:[n(Sy,{model:d}),n(by,{instance:r,operationId:l,variables:c,operationManager:t.operationManager}),n(a.ActionIcon,{"aria-label":"delete-interaction",variant:"filled",color:"red",onClick:()=>o(e),children:n(k.Trash,{size:16})})]})}return null}),Dy=e=>{const[t,r]=b.useState(0),{interactionManager:i,instance:s,sampleData:o,variables:u}=e,l=Ty(i,t),d=async()=>{const h=await i.triggerManager.createOrGetTrigger(ve.randomId(),i.triggerManager.getTriggerSchemaList()[0]),m=await i.operationManager.createOrGetOperation(ve.randomId(),i.operationManager.getOperationSchemaList()[0]);await i.addInteraction(h,m),r(w=>w+1)};async function c(h){await i.removeInteraction(h.id),r(m=>m+1)}const{data:f=0,loading:g}=Z.useRequest(async()=>{try{return(await i.triggerManager.getTriggerSchemaList()).length}catch{return 0}});return p(a.Stack,{children:[n(a.LoadingOverlay,{visible:g}),f===0&&n(a.Alert,{icon:n(k.AlertCircle,{size:16}),title:"Unavailable",color:"gray",children:"This visualization does not have available interactions to choose from"}),l.map(h=>n(ky,{onRemove:c,instance:s,sampleData:o,variables:u,item:h,manager:e.interactionManager},h.id)),n(a.Button,{style:{width:"fit-content"},onClick:()=>d(),disabled:f===0,children:"Add interaction"})]})},My=()=>{const{panel:e,data:t}=Ce(),r=e.viz,{vizManager:i}=b.useContext(qe),s=e.json,o=Z.useCreation(()=>i.getOrCreateInstance(s),[i,s]),u=Z.useCreation(()=>new sr(o,i.resolveComponent(r.type),tn),[o,r.type]);return b.useEffect(()=>o.instanceData.watchItem(null,v.throttle(l=>{e.viz.setConf(l)},100,{leading:!1,trailing:!0})),[o]),{instance:o,vizManager:i,interactionManager:u,sampleData:t,variables:[]}},Iy=()=>{const e=My();return n(Dy,{...e})};var ja=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(ja||{}),nn=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(nn||{});class Ay{constructor(t){O(this,"vizInstance");O(this,"operationManager");O(this,"triggerManager");O(this,"vizManager");O(this,"runningMigration");O(this,"panelModel");O(this,"status","notStarted");this.panelModel=t.getRequired(be.instanceScope.panelModel),this.vizInstance=t.getRequired(be.instanceScope.vizInstance),this.operationManager=t.getRequired(be.instanceScope.operationManager),this.triggerManager=t.getRequired(be.instanceScope.triggerManager),this.vizManager=t.getRequired(be.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(r){return console.warn("check migration failed",r),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(r=>r())),"migrated"}catch(r){return console.warn("migration failed",r),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(t=>(this.status="done",t))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),r={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(r)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),r={configData:this.vizInstance.instanceData};return t.migrator.needMigration(r)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function Ra(e){const{panel:t}=Ce();return b.useCallback(r=>{const i=r.getRequired(be.vizManager),s=i.resolveComponent(e.viz.type);return r.createScoped().provideFactory(be.instanceScope.vizInstance,()=>i.getOrCreateInstance(e)).provideFactory(be.instanceScope.interactionManager,o=>{const u=o.getRequired(be.instanceScope.vizInstance);return new sr(u,s,tn)}).provideFactory(be.instanceScope.operationManager,o=>o.getRequired(be.instanceScope.interactionManager).operationManager).provideFactory(be.instanceScope.triggerManager,o=>o.getRequired(be.instanceScope.interactionManager).triggerManager).provideValue(be.instanceScope.panelModel,t).provideFactory(be.instanceScope.migrator,o=>new Ay(o))},[e.viz.type,e.viz.conf])}function Ya(e){const[t,r]=b.useState(!1),i=zi().getRequired(be.instanceScope.migrator);return Z.useAsyncEffect(async()=>{const s=i.status===nn.notStarted;r(i.status===nn.done),i.status===nn.notStarted&&i.runMigration().then(o=>{o===ja.migrated&&s&&(e==null||e())}).finally(()=>{r(!0)})},[i]),t}function Qa(e,t){const r=zi().getRequired(be.instanceScope.vizInstance);return b.useEffect(()=>(r.instanceData.setItem(null,t.viz.conf),r.instanceData.watchItem(null,i=>{e(i)})),[e,t.viz.type]),r}function $y({setVizConf:e,...t}){const{panel:r}=t,i=Qa(e,r),s=Ya(()=>{Vt.showNotification({title:`${r.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return Z.useAsyncEffect(async()=>{await i.instanceData.setItem(null,r.viz.conf)},[i,r.viz.type]),s?n(Ko,{...t}):n(a.Text,{children:"Checking update..."})}function zy(e){const{panel:t,setVizConf:r}=e;Qa(r,t);const{inEditMode:i}=b.useContext(Ke);return Ya(()=>{i&&Vt.showNotification({title:`${t.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?n(Zo,{...e}):n(a.Text,{children:"Checking update"})}const P1="";function Ey(e,t){const{vizManager:r}=b.useContext(qe),{panel:{viz:i,title:s,id:o,description:u,queryID:l,variables:d}}=Ce(),c={title:s,id:o,description:u,queryID:l,viz:i,layout:t},f=Ra(c);try{return r.resolveComponent(i.type),n(Gt,{configure:f,children:n(zy,{setVizConf:i.setConf,panel:c,data:e,variables:d,vizManager:r})})}catch(g){return console.info(v.get(g,"message")),null}}const Ly=["richText","button"],Ua=T.observer(function({height:t,viz:r,data:i,loading:s,error:o,query:u}){const{ref:l,width:d,height:c}=ve.useElementSize(),f=Ey(i,{w:d,h:c});if(Ly.includes(r.type))return n("div",{className:"viz-root",style:{height:t},ref:l,children:n(ke,{children:f})});if(s)return n("div",{className:"viz-root",style:{height:t,position:"relative"},ref:l,children:n(a.LoadingOverlay,{visible:s,exitTransitionDuration:0})});const h=!!o,m=!h&&!!(u!=null&&u.stateMessage),w=!h&&!m;return p("div",{className:"viz-root",style:{height:t},ref:l,children:[h&&n(a.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:o}),m&&n(a.Text,{color:"gray",align:"center",children:u.stateMessage}),w&&n(ke,{children:f})]})});function Py(e){return!["richText","button"].includes(e)}const Oy={border:"1px solid #e9ecef"},Xa={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function Vy(e,t,r){return e.style.border.enabled?Oy:r||t?Xa:{border:"1px dashed transparent"}}const rn=T.observer(function({panel:t,view:r}){const i=F(),{inEditMode:s}=b.useContext(Ke),{data:o,state:u,error:l}=i.getDataStuffByID(t.queryID),d=i.queries.findByID(t.queryID),c=Py(t.viz.type),f=c&&u==="loading",g=t.title?"calc(100% - 25px - 5px)":"100%",h=Vy(t,c,s),m=c||s;return n(Cn,{value:{panel:t,data:o,loading:f},children:p(a.Box,{className:"panel-root",p:5,pt:0,sx:{...h},children:[n(a.Box,{sx:{position:"absolute",left:0,top:0,height:28,zIndex:310},children:n(Gi,{})}),m&&n(Yo,{view:r}),n(Qo,{}),n(Ua,{viz:t.viz,data:o,loading:f,error:l,height:g,query:d})]})})}),O1="",By=b.forwardRef(({h:e},t)=>n(a.ActionIcon,{ref:t,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:5,right:e>38?5:20,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:n(k.ArrowsMove,{size:16})})),Ny=b.forwardRef(({handleAxis:e,...t},r)=>n(a.ActionIcon,{ref:r,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:n(k.ChevronDownRight,{size:16})})),Gy=Ot.WidthProvider(Ot),qy=T.observer(({view:e,className:t="layout"})=>{const r=F(),{panels:i,layouts:s}=r.panels.panelsByIDs(e.panelIDs),o=b.useCallback(l=>{l.forEach(({i:d,...c})=>{const f=r.panels.findByID(d);f&&f.layout.set(c)})},[r]),u=(l,d,c,f)=>{c.h<30&&(c.h=30,f.h=30),c.w<4&&(c.w=4,f.w=4)};return n(Gy,{onLayoutChange:o,className:`dashboard-layout ${t}`,rowHeight:1,cols:36,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,layout:s,draggableHandle:".react-grid-customDragHandle",resizeHandle:n(Ny,{}),onResize:u,children:i.map((l,d)=>p("div",{"data-grid":{...l.layout},className:"panel-grid-item",children:[n(By,{h:l.layout.h}),n(rn,{view:e,panel:l})]},l.id))})}),Fy=Ot.WidthProvider(Ot),Wy=T.observer(function({view:t,className:r="layout"}){const{panels:i,layouts:s}=F().panels.panelsByIDs(t.panelIDs);return n(Fy,{className:`dashboard-layout ${r}`,cols:36,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,layout:s,children:i.map(o=>n("div",{"data-grid":{...o.layout},className:"panel-grid-item",children:n(rn,{view:t,panel:o})},o.id))})});var Za=(e=>(e.Use="use",e.Edit="edit",e))(Za||{}),K=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(K||{});const jy={div:"Division",tabs:"Tabs",modal:"Modal"},Ka={div:"rgba(255, 0, 0, 0.2)",modal:"rgba(0, 0, 0, 0.2)",tabs:"rgba(255, 200, 100, 0.4)"},Ry={div:"#ff4000",modal:"#000",tabs:"#ffad18"},Yy={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:"div",config:{},panelIDs:[]}],panels:[],filters:[],version:"8.57.0"};var or=(e=>(e.Select="select",e.TreeSelect="tree-select",e.MultiSelect="multi-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(or||{});const Qy=T.observer(({children:e})=>n(a.Box,{pt:10,pb:100,children:e})),Uy=T.observer(({children:e,view:t})=>{const r=t.config;return n(a.Modal,{size:r.width,overflow:"inside",opened:!0,onClose:v.noop,withCloseButton:!1,title:r.custom_modal_title.value,trapFocus:!0,onDragStart:i=>{i.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:e})}),Xy=({variant:e,orientation:t})=>{const r={tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(r.tab.paddingTop="6px",r.tab.paddingBottom="6px"),t==="vertical"&&(r.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},r.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),r},Zy=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},Ky=T.observer(({children:e,view:t})=>{const r=Le.useModals(),i=F(),s=b.useMemo(()=>i.views.options.filter(d=>d.type===K.Division),[t.id,i.views.options]),o=t.config,u=d=>r.openConfirmModal({title:"Delete this tab?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.removeTab(d)},confirmProps:{color:"red"},zIndex:320}),l=o.tabs.length===0;return p(a.Box,{className:"preview-view-tabs",children:[p(a.Tabs,{variant:o.variant,orientation:o.orientation,defaultValue:o.tabs.length>0?o.tabs[0].id:"0",styles:Xy(o),children:[p(a.Tabs.List,{grow:o.grow,children:[o.tabs.map(d=>n(a.Tabs.Tab,{value:d.id,sx:Zy(d),children:d.name??d.id},d.id)),n(a.Tabs.Tab,{onClick:o.addTab,value:"add",className:"add-a-tab",children:n(k.Plus,{size:18,color:"#228be6"})})]}),o.tabs.map((d,c)=>{const f=i.views.findByID(d.view_id);return p(a.Tabs.Panel,{value:d.id,sx:{position:"relative"},children:[p(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[n(a.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),p(a.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[n(a.TextInput,{label:"Tab Name",value:d.name,onChange:g=>d.setName(g.currentTarget.value)}),n(a.Select,{label:"View",value:d.view_id,onChange:d.setViewID,data:s}),n(a.ColorInput,{label:"Color",value:d.color,onChange:d.setColor,disabled:o.variant!=="default"}),f&&p(a.Button,{mt:20,variant:"gradient",leftIcon:n(V.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>i.views.setIDOfVIE(f.id),children:["Swith to View: ",f.name]}),n(a.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>u(c),disabled:l,leftIcon:n(V.IconTrash,{size:14}),children:"Delete This Tab"})]})]}),f&&n(an,{view:f})]},d.id)})]}),e]})}),Jy=T.observer(({view:e,children:t})=>{switch(e.type){case K.Modal:return n(Uy,{view:e,children:t});case K.Tabs:return n(Ky,{view:e,children:t});case K.Division:default:return n(Qy,{children:t})}}),Ja=T.observer(function({view:t}){return n(yn.Provider,{value:{viewPanelInFullScreen:v.noop,inFullScreen:!1},children:n(a.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:n(Jy,{view:t,children:p(a.Box,{sx:{position:"relative"},children:[n(a.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n(Ni,{view:t})}),n(qy,{view:t})]})})})})}),Hy={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},ev=T.observer(function({view:t,panel:r,exitFullScreen:i}){return n(a.Modal,{opened:!0,fullScreen:!0,onClose:i,title:n(a.Button,{color:"blue",size:"xs",onClick:i,leftIcon:n(k.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:Hy,children:n(a.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:n(rn,{view:t,panel:r})})})});function tv(e,t,r){const{panels:i}=F(),s=e.id==="Main",[o,u]=b.useState(()=>s&&i.findByID(t)?t:null),l=b.useCallback(g=>{u(g),s&&r(g)},[s,r]),d=b.useCallback(()=>{u(null),s&&r("")},[s,r]),c=o?i.findByID(o):null;return{viewPanelInFullScreen:l,exitFullScreen:d,inFullScreen:!!c,fullScreenPanel:c}}const nv=T.observer(({children:e})=>n(a.Box,{children:e})),rv=T.observer(({children:e,view:t})=>{const r=F(),i=t.config,s=r.views.visibleViewIDs.includes(t.id),o=()=>r.views.rmVisibleViewID(t.id);return n(a.Modal,{size:i.width,centered:!0,overflow:"inside",opened:s,onClose:o,withCloseButton:!1,title:i.custom_modal_title.value,trapFocus:!0,onDragStart:u=>{u.stopPropagation()},styles:{modal:{border:"1px solid #efefef"},body:{maxHeight:i.height,overflow:"auto"}},transitionDuration:0,children:e})}),iv=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},av=T.observer(({children:e,view:t})=>{const r=F(),i=t.config;return p(a.Box,{className:"render-view-tabs",children:[p(a.Tabs,{variant:i.variant,orientation:i.orientation,defaultValue:i.tabs.length>0?i.tabs[0].id:"0",styles:{panel:{padding:i.orientation==="horizontal"?"16px 0px":"0"}},keepMounted:!1,children:[n(a.Tabs.List,{grow:i.grow,children:i.tabs.map(s=>n(a.Tabs.Tab,{value:s.id,sx:iv(s),disabled:!s.view_id,children:s.name??s.id},s.id))}),i.tabs.map(s=>{const o=r.views.findByID(s.view_id);return o?n(a.Tabs.Panel,{value:s.id,children:n(an,{view:o})},s.id):null})]}),e]})}),sv=T.observer(({view:e,children:t})=>{switch(e.type){case K.Modal:return n(rv,{view:e,children:t});case K.Tabs:return n(av,{view:e,children:t});case K.Division:default:return n(nv,{children:t})}}),an=T.observer(function({view:t}){const{fullScreenPanelID:r,setFullScreenPanelID:i}=Oi(),{viewPanelInFullScreen:s,exitFullScreen:o,inFullScreen:u,fullScreenPanel:l}=tv(t,r,i);return n(yn.Provider,{value:{viewPanelInFullScreen:s,inFullScreen:u},children:p(a.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:[u&&n(ev,{view:t,panel:l,exitFullScreen:o}),n(sv,{view:t,children:p(a.Box,{sx:{position:"relative"},children:[!u&&n(a.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:n(Ni,{view:t})}),!u&&n(Wy,{view:t})]})})]})})});function ov(e){e=e||{};const t=Object.keys(e).sort(),r=[];for(let i=0;i<t.length;i++){const s=t[i];if(s!="authentication"&&e[s])r.push(t[i]+"="+(typeof e[s]=="object"?JSON.stringify(e[s]):e[s]));else{const o=Object.keys(e[s]).sort();for(let u=0;u<o.length;u++){const l=o[u];l!="sign"&&e[s][l]&&r.push(o[u]+"="+(typeof e[s][l]=="object"?JSON.stringify(e[s][l]):e[s][l]))}}}return r.sort().join("&")}function lv(e,t){let r=ov(e);return r+="&key="+t,Mi.MD5(r).toString().toUpperCase()}const ze={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(e){if(!this.app_id||!this.app_secret)return;const t=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:t,sign:lv({app_id:this.app_id,nonce_str:t,...e},this.app_secret)}},getRequest(e,t){return(r,i,s={})=>{const o=window.localStorage.getItem("token"),u={"X-Requested-With":"XMLHttpRequest","Content-Type":s.string?"application/x-www-form-urlencoded":"application/json",authorization:o?`bearer ${o}`:"",...s.headers},l={baseURL:this.baseURL,method:e,url:r,params:e==="GET"?i:s.params,headers:u,signal:t};return["POST","PUT"].includes(e)&&(l.data=s.string?JSON.stringify(i):i,l.data.authentication=this.getAuthentication(l.data)),Xe(l).then(d=>d.data).catch(d=>Promise.reject(d))}}};function Ha(e){ze.baseURL!==e.apiBaseURL&&(ze.baseURL=e.apiBaseURL),e.app_id&&(ze.app_id=e.app_id),e.app_secret&&(ze.app_secret=e.app_secret)}const es=y.types.model("FilterConfigModel_Checkbox",{_name:y.types.literal("checkbox"),description:y.types.optional(y.types.string,""),default_value:y.types.boolean}).views(e=>({get json(){const{_name:t,description:r,default_value:i}=e;return{_name:t,description:r,default_value:i}},get isDescriptionEmpty(){const{description:t}=e;return t===""||t==="<p></p>"}})).actions(e=>({setDefaultValue(t){e.default_value=t},setDescription(t){e.description=t}})),uv=()=>es.create({_name:"checkbox",description:"",default_value:!1});var ce=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e))(ce||{}),we=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TreeSelect="tree-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(we||{});y.types.model({type:y.types.enumeration("DataSourceType",[ce.Postgresql,ce.MySQL,ce.HTTP]),key:y.types.string,sql:y.types.string});function ts(e,t){return e.map(r=>{try{return r?j.tz(r,"UTC").format(t):null}catch{return console.log(`[date-range] failed parsing ${r}`),null}})}const dv=y.types.model("FilterConfigModel_DateRange",{_name:y.types.literal("date-range"),required:y.types.boolean,inputFormat:y.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:y.types.optional(y.types.array(y.types.union(y.types.string,y.types.null)),[null,null]),clearable:y.types.boolean,max_days:y.types.optional(y.types.number,0),allowSingleDateInRange:y.types.optional(y.types.boolean,!1)}).views(e=>({get json(){const{_name:t,max_days:r,required:i,clearable:s,inputFormat:o,default_value:u,allowSingleDateInRange:l}=e;return{_name:t,max_days:r,required:i,clearable:s,inputFormat:o,default_value:ts(u,o),allowSingleDateInRange:l}},truthy(t){return Array.isArray(t)&&t.length===2&&t.every(r=>!!r)}})).views(e=>({getMaxDate(t){const{max_days:r}=e;if(!(!r||!t))return j(t).startOf("day").add(r,"days").toDate()},getMinDate(t){const{max_days:r}=e;if(!(!r||!t))return j(t).startOf("day").subtract(r,"days").toDate()}})).actions(e=>({setFilterValue(t){try{const r=y.getParent(e);y.getRoot(e).filters.setValueByKey(r.key,t)}catch(r){console.error(r)}}})).actions(e=>({setRequired(t){e.required=t},setClearable(t){e.clearable=t},setInputFormat(t){e.inputFormat=t},setDefaultValue(t){e.default_value.length=0,e.default_value.push(...t),e.setFilterValue(t)},setMaxDays(t){e.max_days=t,t>0&&(e.clearable=!0)},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),ns=y.types.snapshotProcessor(dv,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(r=>r===null?null:j.tz(r,"UTC").toISOString())}},postProcessor(e){const{default_value:t,...r}=e;return{...r,default_value:ts(t,r.inputFormat)}}}),cv=()=>ns.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),pv=y.types.model({label:y.types.string,value:y.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),lr=y.types.model("FilterConfigModel_BaseSelect",{static_options:y.types.optional(y.types.array(pv),[]),options_query_id:y.types.optional(y.types.string,""),default_selection_count:y.types.optional(y.types.number,0)}).views(e=>({get usingQuery(){return!!e.options_query_id}})).views(e=>({get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:r,error:i}=y.getRoot(e).content.getDataStuffByID(e.options_query_id);return r==="idle"?t:[]}})).actions(e=>({addStaticOption(t){e.static_options.push(t)},removeStaticOption(t){e.static_options.splice(t,1)},setDefaultSelectionCount(t){e.default_selection_count=t},setOptionsQueryID(t){e.options_query_id=t??""}})),sn=e=>v.cloneDeepWith(e,(t,r)=>{if(r!==void 0&&t)return se.toJS(t)}),rs=y.types.compose("FilterConfigModel_MultiSelect",y.types.model({_name:y.types.literal("multi-select"),min_width:y.types.optional(y.types.string,""),default_value:y.types.optional(y.types.array(y.types.string),[])}),lr).views(e=>({get json(){const{_name:t,default_value:r,min_width:i,static_options:s,options_query_id:o,default_selection_count:u}=e;return sn({_name:t,min_width:i,default_value:r,static_options:s,options_query_id:o,default_selection_count:u})},get default_selection(){return e.usingQuery?e.options.slice(0,e.default_selection_count).map(t=>t.value):e.default_value}})).actions(e=>({setDefaultValue(t){e.default_value=y.cast(t)},setMinWidth(t){e.min_width=t},setDefaultSelection(){const t=y.getRoot(e).content.filters,r=y.getParent(e).key;t.setValueByKey(r,e.default_selection)}})).actions(e=>({afterCreate(){y.addDisposer(e,se.reaction(()=>se.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!0,delay:0}))}})),hv=()=>rs.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),is=y.types.compose("FilterConfigModel_TreeSelect",y.types.model({_name:y.types.literal("tree-select"),min_width:y.types.optional(y.types.string,""),default_value:y.types.optional(y.types.array(y.types.string),[])}),lr).views(e=>({get json(){const{_name:t,default_value:r,min_width:i,static_options:s,options_query_id:o,default_selection_count:u}=e;return{_name:t,min_width:i,default_value:r,static_options:s,options_query_id:o,default_selection_count:u}}})).actions(e=>({setDefaultValue(t){e.default_value=y.cast(t)},setMinWidth(t){e.min_width=t}})),fv=()=>is.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),as=y.types.compose("FilterConfigModel_Select",y.types.model({_name:y.types.literal("select"),default_value:y.types.string,required:y.types.boolean,width:y.types.optional(y.types.string,"")}),lr).views(e=>({get json(){const{_name:t,default_value:r,required:i,width:s,static_options:o,options_query_id:u,default_selection_count:l}=e;return sn({_name:t,width:s,required:i,default_value:r,static_options:o,options_query_id:u,default_selection_count:l})},truthy(t){return!!t}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t},setWidth(t){e.width=t}})),gv=()=>as.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),ss=y.types.model("FilterConfigModel_TextInput",{_name:y.types.literal("text-input"),required:y.types.boolean,default_value:y.types.string}).views(e=>({get json(){const{_name:t,required:r,default_value:i}=e;return{_name:t,required:r,default_value:i}},truthy(t){return typeof t!="string"?!1:!!t.trim()}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),os=()=>ss.create({_name:"text-input",required:!1,default_value:""}),ur=y.types.model("FilterModel",{id:y.types.identifier,key:y.types.string,label:y.types.string,order:y.types.number,visibleInViewsIDs:y.types.array(y.types.string),auto_submit:y.types.optional(y.types.boolean,!1),type:y.types.enumeration("DashboardFilterType",[we.Select,we.MultiSelect,we.TreeSelect,we.TextInput,we.Checkbox,we.DateRange]),config:y.types.union(as,rs,is,ss,es,ns)}).views(e=>({get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==we.TreeSelect},get auto_submit_supported(){return[we.Select,we.Checkbox,we.DateRange].includes(e.type)}})).views(e=>({get json(){const{id:t,key:r,label:i,order:s,visibleInViewsIDs:o,auto_submit:u,type:l,config:d}=e;return{id:t,key:r,type:l,label:i,order:s,config:d.json,auto_submit:u,visibleInViewsIDs:se.toJS(o)}},get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return v.get(e.config,"required",!1)?v.get(e.config,"truthy",()=>!0)(t):!1}})).actions(e=>({setKey(t){e.key=t},setLabel(t){e.label=t},setOrder(t){e.order=t},setType(t){switch(t){case we.Select:e.config=gv();break;case we.MultiSelect:e.config=hv();break;case we.TreeSelect:e.config=fv();break;case we.TextInput:e.config=os();break;case we.Checkbox:e.config=uv();break;case we.DateRange:e.config=cv();break}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t}}));function ls(e,t){if(e===void 0)return e;if(t._name==="date-range")try{const[...r]=e;return r.map(i=>i===null?i:j.tz(i,"UTC").format(t.inputFormat)??i)}catch(r){return console.error(r),e}return e}function us(e){return e.reduce((t,r)=>(t[r.key]=ls(r.config.default_value,r.config),t),{})}function mv(e,t,r){y.addDisposer(e,y.addMiddleware(e,(i,s)=>{s(i,()=>{y.getType(i.context)===t&&i.type==="action"&&r(i.name,i.context)})}))}const ds=y.types.model("FiltersModel",{current:y.types.optional(y.types.array(ur),[]),values:y.types.optional(y.types.frozen(),{}),previewValues:y.types.optional(y.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(r=>r.id===t)},get inOrder(){return v.sortBy(e.current,"order")},get options(){return e.current.map(t=>({label:t.label??t.id,value:t.id,_type:"filter"}))},get empty(){return e.current.length===0},visibleInView(t){return v.sortBy(e.current.filter(r=>r.visibleInViewsIDs.includes(t)),"order")},get firstFilterValueKey(){return Object.keys(e.values)[0]??""},get keyLabelMap(){return e.current.reduce((t,r)=>(t[r.key]=r.label,t),{})}})).actions(e=>({replace(t){e.current=y.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByID(t){const r=e.current.findIndex(i=>i.id===t);r>=0&&e.current.splice(r,1)},setValues(t){e.values=t},setValueByKey(t,r){e.values={...e.values,[t]:r}},getValueByKey(t){return e.values[t]},refreshValues(){console.log("refreshing values"),e.values=us(e.current)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){mv(e.current,ur,(r,i)=>{if(r==="setType"){const s=ls(i.config.default_value,i.config);e.setValueByKey(i.key,s),e.updatePreviewValues({...e.previewValues,[i.key]:s})}})}return{afterCreate(){t()}}});function cs(e){return{current:e,values:us(e)}}const ps="\uFEFF";function bv(e,t){const r=new Blob([ps+t],{type:"text/csv"});gn.saveAs(r,`${e}.csv`)}function yv(e,t){const r=new Blob([t],{type:"application/json"});gn.saveAs(r,`${e}.json`)}function vv(e){const t=new mo;e.forEach(({id:r,data:i})=>{t.file(`${r}.csv`,fs(i))}),t.generateAsync({type:"blob"}).then(r=>{gn.saveAs(r,"dashboard_data.zip")})}function hs(e){return typeof e=="string"&&e.includes(",")?`"${e}"`:e}function fs(e){if(!Array.isArray(e)||e.length===0)return"";const t=[],r=Object.keys(e[0]).map(hs);return t.push(r.join(",")),e.forEach(i=>{const s=Object.values(i).map(hs).join(",");t.push(s)}),ps+t.join(`
|
|
367
367
|
`)}const ht={CryptoJS:Mi,d3Array:vo,dayjs:j,lodash:v,numbro:te,mathjs:Nt,faker:bo.faker},xv=[{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"}],Cv=e=>`
|
|
368
368
|
<tr>
|
|
369
369
|
<td><code>${e.name}</code></td>
|