@devtable/dashboard 10.34.3 → 10.34.4
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/components/panel/panel-render/full-screen-render/use-panel-full-screen.d.ts +4 -4
- package/dist/components/plugins/plugin-context.d.ts +4 -4
- package/dist/contexts/panel-context.d.ts +8 -8
- package/dist/dashboard-editor/model/panels/panel.d.ts +2 -2
- package/dist/dashboard-editor/model/panels/panels.d.ts +16 -16
- package/dist/dashboard-editor/model/queries/index.d.ts +7 -7
- package/dist/dashboard.es.js +11 -13
- package/dist/dashboard.umd.js +2 -2
- package/dist/model/render-model/dashboard/content/panels/panel.d.ts +2 -2
- package/dist/model/render-model/dashboard/content/panels/panels.d.ts +14 -14
- package/dist/model/render-model/dashboard/content/queries/queries.d.ts +5 -5
- package/dist/model/render-model/dashboard/content/queries/query.d.ts +1 -1
- package/dist/stats.html +1 -1
- package/package.json +1 -1
package/dist/dashboard.umd.js
CHANGED
|
@@ -51,7 +51,7 @@ Check the top-level render call using <`+V+">.")}return E}}function Tu(S,E){{if(
|
|
|
51
51
|
${ju.map(Ru).join("")}
|
|
52
52
|
</tbody>
|
|
53
53
|
</table>
|
|
54
|
-
`;function vr(e,t){const n=Object.keys(t),r=Object.values(t);try{return new Function(...n,`return \`${e}\`;`)(...r)}catch(a){throw n.length===0&&e.includes("$")?new Error("[formatSQL] insufficient payload"):a}}function xr(e,t){try{return vr(e,t)}catch(n){return console.error(n),n.message}}function Qu({sql:e,pre_process:t}){if(!t.trim())return e;try{return new Function(`return ${t}`)()({sql:e},At)}catch(n){return console.error(n),e}}function Uu(e,t){if(!e.trim())return t;try{return new Function(`return ${e}`)()(t,At)}catch(n){return console.error(n),t}}function Ku(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let r=0;r<t.length;r++){const a=t[r];if(a!="authentication"&&e[a])n.push(t[r]+"="+(typeof e[a]=="object"?JSON.stringify(e[a]):e[a]));else{const o=Object.keys(e[a]).sort();for(let l=0;l<o.length;l++){const u=o[l];u!="sign"&&e[a][u]&&n.push(o[l]+"="+(typeof e[a][u]=="object"?JSON.stringify(e[a][u]):e[a][u]))}}}return n.sort().join("&")}function Xu(e,t){let n=Ku(e);return n+="&key="+t,$a.MD5(n).toString().toUpperCase()}const qe={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:Xu({app_id:this.app_id,nonce_str:t,...e},this.app_secret)}},getRequest(e,t){return(n,r,a={})=>{const o=window.localStorage.getItem("token"),l={"X-Requested-With":"XMLHttpRequest","Content-Type":a.string?"application/x-www-form-urlencoded":"application/json",authorization:o?`bearer ${o}`:"",...a.headers},u={baseURL:this.baseURL,method:e,url:n,params:e==="GET"?r:a.params,headers:l,signal:t};return["POST","PUT"].includes(e)&&(u.data=a.string?JSON.stringify(r):r,u.data.authentication=this.getAuthentication(u.data)),xt(u).then(c=>c.data).catch(c=>Promise.reject(c))}},makeQueryENV:null,query(e){return async(t,n={})=>{var r;return t.env||(t.env=((r=this.makeQueryENV)==null?void 0:r.call(this))??{error:"failed to run makeQueryENV"}),this.getRequest("POST",e)("/query",t,n)}}};function es(e){qe.baseURL!==e.apiBaseURL&&(qe.baseURL=e.apiBaseURL),e.app_id&&(qe.app_id=e.app_id),e.app_secret&&(qe.app_secret=e.app_secret),e.makeQueryENV&&(qe.makeQueryENV=e.makeQueryENV)}async function Ju({query:e,name:t,payload:n},r){if(!e.sql)return[];const{type:a,key:o,sql:l,pre_process:u,post_process:c}=e,d=vr(l,n),f=Qu({sql:d,pre_process:u});let h=await qe.query(r)({type:a,key:o,query:f},{params:{name:t}});return h=Uu(c,h),h}async function Zu({type:e,key:t,configString:n,name:r},a){return await qe.query(a)({type:e,key:t,query:n},{params:{name:r}})}async function wr(){try{return(await qe.getRequest("POST")("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}})).data}catch(e){return console.error(e),[]}}async function ts(){try{return(await qe.getRequest("POST")("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}})).data}catch(e){return console.error(e),[]}}class ns{constructor(t){N(this,"rootRef");this.rootRef=te.observable({current:t})}async deleteItem(t){te.runInAction(()=>{x.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?te.toJS(this.rootRef.current):x.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(x.isObject(n))te.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else te.runInAction(()=>{x.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return te.reaction(()=>this.getValueFromRoot(t),(a,o)=>{n(a,o)},{requiresObservable:!0,fireImmediately:x.get(r,"fireImmediately",!1)})}}class Hu{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new La)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new La;return this.channels.set(t,r),r}}class ec{constructor(t){N(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 n=this.instances.get(t.id);if(n)return n;const r={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Hu,instanceData:new ns(t.viz.conf)};return this.instances.set(t.id,r),r}}function rs(e,t,n,r){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new ns({}),colorPalette:{getColor(){return()=>""}},data:t,variables:r}}const tc=e=>{const{panel:t,vizManager:n,data:r,variables:a}=e,o=n.resolveComponent(t.viz.type),l=n.getOrCreateInstance(t),u={...rs(l,r,n,a),viewport:{width:t.layout.w,height:t.layout.h}},c=o.viewRender;return i(c,{context:u,instance:l,...x.omit(e,["panel","vizManager","data"])})},nc=e=>{const{vizManager:t,panel:n,panelInfoEditor:r,data:a,variables:o}=e,l=t.resolveComponent(n.viz.type),u=t.getOrCreateInstance(n),c={...rs(u,a,t,o),panelInfoEditor:r},d=l.configRender;return i(d,{context:c,instance:u,...x.omit(e,["panel","vizManager","data","panelInfoEditor"])})},is=(e,t)=>{const n=ft.bezier(e),r=ft.bezier(t);return function(a){return a<50?n(a*2/100).hex():r((a-50)*2/100).hex()}},In=e=>{const t=ft.bezier(e);return function(n){return t(n/100).hex()}},rc={type:"interpolation",displayName:"Red / Green",getColor:is(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},ic={type:"interpolation",displayName:"Yellow / Blue",getColor:is(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},ac={type:"interpolation",displayName:"Red",getColor:In(["#fff7f1","darkred"]),name:"red",category:"sequential"},sc={type:"interpolation",displayName:"Green",getColor:In(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},oc={type:"interpolation",displayName:"Blue",getColor:In(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},lc={type:"interpolation",displayName:"Orange",getColor:In(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class uc{constructor(t){N(this,"symbol");this.symbol=Symbol(t)}}function gt(e){return new uc(e)}class Cr{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const t=new Cr;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 n=this.factoryRegistry.get(t.symbol);if(n){const r=n(this);return this.instanceRegistry.set(t.symbol,r),r}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=x.get(t,"dispose");x.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const as="10.34.3",cc=Object.freeze(Object.defineProperty({__proto__:null,version:as},Symbol.toStringTag,{value:"Module"}));class dc{constructor(t){N(this,"staticColors",new Map);N(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&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(n,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 pc{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;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 n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class hc{constructor(){N(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,r){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const a=this.migrations.filter(u=>u.version>t.from&&u.version<=t.to),o=x.orderBy(a,"version","asc");if(((l=x.last(o))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((u,c)=>c.handler(u,r),n)}}class ye extends hc{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(r,a)=>({version:t,...n(r,a)}))}async migrate({configData:t,panelModel:n}){const r=await t.getItem(null),a=x.get(r,"version",0),o=this.run({from:a,to:this.VERSION},r,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return x.get(n,"version",0)<this.VERSION}}const R=(e,t)=>{const[n,{setFalse:r}]=K.useBoolean(!0),[a,o]=y.useState();y.useEffect(()=>(e.getItem(t).then(u=>{o(u),r()}),e.watchItem(t,u=>{o(u)})));const l=y.useCallback(async u=>{await e.setItem(t,u),o(u)},[e,t]);return{loading:n,value:a,set:l}},Fe={top:16,right:16,bottom:16,left:16},it=e=>Math.max(0,e-Fe.left-Fe.right),at=e=>Math.max(0,e-Fe.top-Fe.bottom),an=(e,t)=>({width:it(e),height:at(t)}),Ge=({width:e,height:t,children:n})=>i(s.Box,{pt:Fe.top,pr:Fe.right,pb:Fe.bottom,pl:Fe.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n});function O(e){const[t,n]=e.split(".");return{queryID:t,columnKey:n}}function fc(e){return e.includes(".")?O(e):{queryID:"",columnKey:e}}function mt(e,t){var a;const{queryID:n,columnKey:r}=O(t);return n?r?((a=e[n])==null?void 0:a.map(o=>o[r]))??[]:e[n]:[]}function sn(e,t){const{queryID:n}=O(t);return n?e[n]:[]}function gc(e){return Object.values(e)[0]}function Mn(e,t){const{queryID:n,columnKey:r}=O(t);return e[r]}const Sr={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"}};ie.use([q.GridComponent,q.VisualMapComponent,q.LegendComponent,q.TooltipComponent,Be.CanvasRenderer]);function mc({context:e}){const{value:t}=R(e.instanceData,"config"),n=e.data,{width:r,height:a}=e.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:u,xAxis3D:c,yAxis3D:d,zAxis3D:f}=x.defaults({},t,Sr),h=y.useMemo(()=>sn(n,o),[n,o]),{x:g,y:m,z:C}=y.useMemo(()=>({x:O(o),y:O(l),z:O(u)}),[o,l,u]),{min:w,max:_}=y.useMemo(()=>{const M=x.minBy(h,G=>G[C.columnKey]),P=x.maxBy(h,G=>G[C.columnKey]);return{min:x.get(M,C.columnKey),max:x.get(P,C.columnKey)}},[h,C]),D={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:w,max:_,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:c,yAxis3D:d,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(M=>[M[g.columnKey],M[m.columnKey],M[C.columnKey]])}]};return t?i(Ge,{width:r,height:a,children:i(Pe,{echarts:ie,option:D,style:an(r,a),notMerge:!0,theme:"merico-light"})}):null}const ss=y.createContext(null),_r=ss.Provider;function kr(){const e=y.useContext(ss);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const ce=()=>kr(),Tr=()=>kr(),os=y.createContext(null),Dr=os.Provider;function ls(){const e=y.useContext(os);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const le=()=>ls(),we=()=>ls(),yc={inEditMode:!1},An=y.createContext(yc),us=y.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),Ir=us.Provider;function cs(){const e=y.useContext(us);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const Ct=()=>cs(),st=()=>cs(),bc={fullScreenPanelID:"",setFullScreenPanelID:x.noop},Mr=y.createContext(bc);function ds(){const e=y.useContext(Mr);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const W=k.observer(y.forwardRef(({label:e,required:t,value:n,onChange:r,clearable:a=!1,sx:o,...l},u)=>{const{panel:c}=st(),d=y.useMemo(()=>{const f=[...c.dataFieldOptions];return a&&f.unshift({label:"unset",value:"",group:""}),f},[c.dataFieldOptions]);return i(s.Select,{ref:u,label:e,data:d,value:n,onChange:r,required:t,sx:o,maxDropdownHeight:500,...l})}));function vc({context:e}){const{value:t,set:n}=R(e.instanceData,"config"),r=x.defaults({},t,Sr),{control:a,handleSubmit:o,reset:l}=v.useForm({defaultValues:r});return y.useEffect(()=>{l(r)},[t]),t?i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[i(s.Text,{children:"X Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"x_axis_data_key",control:a,render:({field:u})=>i(W,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"xAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Text,{mt:"lg",children:"Y Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"y_axis_data_key",control:a,render:({field:u})=>i(W,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"yAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Text,{mt:"lg",children:"Z Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"z_axis_data_key",control:a,render:({field:u})=>i(W,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"zAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(s.Button,{color:"blue",type:"submit",children:[i(T.DeviceFloppy,{size:20}),i(s.Text,{ml:"md",children:"Save"})]})})]})}):null}function xc(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis_data_key:a,y_axis_data_key:o,z_axis_data_key:l,...u}=e;return{...u,x_axis_data_key:r(a),y_axis_data_key:r(o),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class wc extends ye{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:a}=n;return{...n,version:2,config:xc(a,r)}})}}const Cc={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new wc,name:"bar-3d",viewRender:mc,configRender:vc,createConfig(){return{version:2,config:x.cloneDeep(Sr)}}};class We extends y.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const n=()=>{this.setState({error:null})};return p(s.Box,{children:[i(s.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),i(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}const ze={mantissa:0,output:"number",trimMantissa:!1,average:!1};function Sc({value:e,onChange:t},n){const r=u=>{t({...e,output:u})},a=u=>{const c=u===0?!1:e.trimMantissa;t({...e,mantissa:u,trimMantissa:c})},o=u=>{t({...e,trimMantissa:u.currentTarget.checked})},l=u=>{t({...e,average:u.currentTarget.checked})};return p(s.Stack,{ref:n,children:[p(s.Group,{grow:!0,children:[i(s.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:r,sx:{flexGrow:1}}),i(s.Switch,{label:p(s.Stack,{spacing:0,children:[i(s.Text,{children:"Average"}),i(s.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:l,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(s.Group,{grow:!0,children:[i(s.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:a}),i(s.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(s.Stack,{spacing:0,children:[i(s.Text,{weight:"bold",children:"Preview"}),i(We,{children:p(s.Group,{position:"apart",children:[p(s.Text,{size:12,color:"gray",children:["123456789 ",i(T.ArrowRight,{size:9})," ",Z(123456789).format(e)]}),p(s.Text,{size:12,color:"gray",children:["1234 ",i(T.ArrowRight,{size:9})," ",Z(1234).format(e)]}),p(s.Text,{size:12,color:"gray",children:["0.1234 ",i(T.ArrowRight,{size:9})," ",Z(.1234).format(e)]})]})})]})]})}const Ye=y.forwardRef(Sc),Xe={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
54
|
+
`;function vr(e,t){const n=Object.keys(t),r=Object.values(t);try{return new Function(...n,`return \`${e}\`;`)(...r)}catch(a){throw n.length===0&&e.includes("$")?new Error("[formatSQL] insufficient payload"):a}}function xr(e,t){try{return vr(e,t)}catch(n){return console.error(n),n.message}}function Qu({sql:e,pre_process:t}){if(!t.trim())return e;try{return new Function(`return ${t}`)()({sql:e},At)}catch(n){return console.error(n),e}}function Uu(e,t){if(!e.trim())return t;try{return new Function(`return ${e}`)()(t,At)}catch(n){return console.error(n),t}}function Ku(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let r=0;r<t.length;r++){const a=t[r];if(a!="authentication"&&e[a])n.push(t[r]+"="+(typeof e[a]=="object"?JSON.stringify(e[a]):e[a]));else{const o=Object.keys(e[a]).sort();for(let l=0;l<o.length;l++){const u=o[l];u!="sign"&&e[a][u]&&n.push(o[l]+"="+(typeof e[a][u]=="object"?JSON.stringify(e[a][u]):e[a][u]))}}}return n.sort().join("&")}function Xu(e,t){let n=Ku(e);return n+="&key="+t,$a.MD5(n).toString().toUpperCase()}const qe={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:Xu({app_id:this.app_id,nonce_str:t,...e},this.app_secret)}},getRequest(e,t){return(n,r,a={})=>{const o=window.localStorage.getItem("token"),l={"X-Requested-With":"XMLHttpRequest","Content-Type":a.string?"application/x-www-form-urlencoded":"application/json",authorization:o?`bearer ${o}`:"",...a.headers},u={baseURL:this.baseURL,method:e,url:n,params:e==="GET"?r:a.params,headers:l,signal:t};return["POST","PUT"].includes(e)&&(u.data=a.string?JSON.stringify(r):r,u.data.authentication=this.getAuthentication(u.data)),xt(u).then(c=>c.data).catch(c=>Promise.reject(c))}},makeQueryENV:null,query(e){return async(t,n={})=>{var r;return t.env||(t.env=((r=this.makeQueryENV)==null?void 0:r.call(this))??{error:"failed to run makeQueryENV"}),this.getRequest("POST",e)("/query",t,n)}}};function es(e){qe.baseURL!==e.apiBaseURL&&(qe.baseURL=e.apiBaseURL),e.app_id&&(qe.app_id=e.app_id),e.app_secret&&(qe.app_secret=e.app_secret),e.makeQueryENV&&(qe.makeQueryENV=e.makeQueryENV)}async function Ju({query:e,name:t,payload:n},r){if(!e.sql)return[];const{type:a,key:o,sql:l,pre_process:u,post_process:c}=e,d=vr(l,n),f=Qu({sql:d,pre_process:u});let h=await qe.query(r)({type:a,key:o,query:f},{params:{name:t}});return h=Uu(c,h),h}async function Zu({type:e,key:t,configString:n,name:r},a){return await qe.query(a)({type:e,key:t,query:n},{params:{name:r}})}async function wr(){try{return(await qe.getRequest("POST")("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}})).data}catch(e){return console.error(e),[]}}async function ts(){try{return(await qe.getRequest("POST")("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}})).data}catch(e){return console.error(e),[]}}class ns{constructor(t){N(this,"rootRef");this.rootRef=te.observable({current:t})}async deleteItem(t){te.runInAction(()=>{x.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?te.toJS(this.rootRef.current):x.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(x.isObject(n))te.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else te.runInAction(()=>{x.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return te.reaction(()=>this.getValueFromRoot(t),(a,o)=>{n(a,o)},{requiresObservable:!0,fireImmediately:x.get(r,"fireImmediately",!1)})}}class Hu{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new La)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new La;return this.channels.set(t,r),r}}class ec{constructor(t){N(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 n=this.instances.get(t.id);if(n)return n;const r={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Hu,instanceData:new ns(t.viz.conf)};return this.instances.set(t.id,r),r}}function rs(e,t,n,r){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new ns({}),colorPalette:{getColor(){return()=>""}},data:t,variables:r}}const tc=e=>{const{panel:t,vizManager:n,data:r,variables:a}=e,o=n.resolveComponent(t.viz.type),l=n.getOrCreateInstance(t),u={...rs(l,r,n,a),viewport:{width:t.layout.w,height:t.layout.h}},c=o.viewRender;return i(c,{context:u,instance:l,...x.omit(e,["panel","vizManager","data"])})},nc=e=>{const{vizManager:t,panel:n,panelInfoEditor:r,data:a,variables:o}=e,l=t.resolveComponent(n.viz.type),u=t.getOrCreateInstance(n),c={...rs(u,a,t,o),panelInfoEditor:r},d=l.configRender;return i(d,{context:c,instance:u,...x.omit(e,["panel","vizManager","data","panelInfoEditor"])})},is=(e,t)=>{const n=ft.bezier(e),r=ft.bezier(t);return function(a){return a<50?n(a*2/100).hex():r((a-50)*2/100).hex()}},In=e=>{const t=ft.bezier(e);return function(n){return t(n/100).hex()}},rc={type:"interpolation",displayName:"Red / Green",getColor:is(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},ic={type:"interpolation",displayName:"Yellow / Blue",getColor:is(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},ac={type:"interpolation",displayName:"Red",getColor:In(["#fff7f1","darkred"]),name:"red",category:"sequential"},sc={type:"interpolation",displayName:"Green",getColor:In(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},oc={type:"interpolation",displayName:"Blue",getColor:In(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},lc={type:"interpolation",displayName:"Orange",getColor:In(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class uc{constructor(t){N(this,"symbol");this.symbol=Symbol(t)}}function gt(e){return new uc(e)}class Cr{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const t=new Cr;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 n=this.factoryRegistry.get(t.symbol);if(n){const r=n(this);return this.instanceRegistry.set(t.symbol,r),r}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=x.get(t,"dispose");x.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const as="10.34.4",cc=Object.freeze(Object.defineProperty({__proto__:null,version:as},Symbol.toStringTag,{value:"Module"}));class dc{constructor(t){N(this,"staticColors",new Map);N(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&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(n,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 pc{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;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 n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class hc{constructor(){N(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,r){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const a=this.migrations.filter(u=>u.version>t.from&&u.version<=t.to),o=x.orderBy(a,"version","asc");if(((l=x.last(o))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((u,c)=>c.handler(u,r),n)}}class ye extends hc{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(r,a)=>({version:t,...n(r,a)}))}async migrate({configData:t,panelModel:n}){const r=await t.getItem(null),a=x.get(r,"version",0),o=this.run({from:a,to:this.VERSION},r,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return x.get(n,"version",0)<this.VERSION}}const R=(e,t)=>{const[n,{setFalse:r}]=K.useBoolean(!0),[a,o]=y.useState();y.useEffect(()=>(e.getItem(t).then(u=>{o(u),r()}),e.watchItem(t,u=>{o(u)})));const l=y.useCallback(async u=>{await e.setItem(t,u),o(u)},[e,t]);return{loading:n,value:a,set:l}},Fe={top:16,right:16,bottom:16,left:16},it=e=>Math.max(0,e-Fe.left-Fe.right),at=e=>Math.max(0,e-Fe.top-Fe.bottom),an=(e,t)=>({width:it(e),height:at(t)}),Ge=({width:e,height:t,children:n})=>i(s.Box,{pt:Fe.top,pr:Fe.right,pb:Fe.bottom,pl:Fe.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n});function O(e){const[t,n]=e.split(".");return{queryID:t,columnKey:n}}function fc(e){return e.includes(".")?O(e):{queryID:"",columnKey:e}}function mt(e,t){var a;const{queryID:n,columnKey:r}=O(t);return n?r?((a=e[n])==null?void 0:a.map(o=>o[r]))??[]:e[n]:[]}function sn(e,t){const{queryID:n}=O(t);return n?e[n]:[]}function gc(e){return Object.values(e)[0]}function Mn(e,t){const{queryID:n,columnKey:r}=O(t);return e[r]}const Sr={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"}};ie.use([q.GridComponent,q.VisualMapComponent,q.LegendComponent,q.TooltipComponent,Be.CanvasRenderer]);function mc({context:e}){const{value:t}=R(e.instanceData,"config"),n=e.data,{width:r,height:a}=e.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:u,xAxis3D:c,yAxis3D:d,zAxis3D:f}=x.defaults({},t,Sr),h=y.useMemo(()=>sn(n,o),[n,o]),{x:g,y:m,z:C}=y.useMemo(()=>({x:O(o),y:O(l),z:O(u)}),[o,l,u]),{min:w,max:_}=y.useMemo(()=>{const M=x.minBy(h,G=>G[C.columnKey]),P=x.maxBy(h,G=>G[C.columnKey]);return{min:x.get(M,C.columnKey),max:x.get(P,C.columnKey)}},[h,C]),D={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:w,max:_,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:c,yAxis3D:d,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(M=>[M[g.columnKey],M[m.columnKey],M[C.columnKey]])}]};return t?i(Ge,{width:r,height:a,children:i(Pe,{echarts:ie,option:D,style:an(r,a),notMerge:!0,theme:"merico-light"})}):null}const ss=y.createContext(null),_r=ss.Provider;function kr(){const e=y.useContext(ss);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const ce=()=>kr(),Tr=()=>kr(),os=y.createContext(null),Dr=os.Provider;function ls(){const e=y.useContext(os);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const le=()=>ls(),we=()=>ls(),yc={inEditMode:!1},An=y.createContext(yc),us=y.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),Ir=us.Provider;function cs(){const e=y.useContext(us);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const Ct=()=>cs(),st=()=>cs(),bc={fullScreenPanelID:"",setFullScreenPanelID:x.noop},Mr=y.createContext(bc);function ds(){const e=y.useContext(Mr);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const W=k.observer(y.forwardRef(({label:e,required:t,value:n,onChange:r,clearable:a=!1,sx:o,...l},u)=>{const{panel:c}=st(),d=y.useMemo(()=>{const f=[...c.dataFieldOptions];return a&&f.unshift({label:"unset",value:"",group:""}),f},[c.dataFieldOptions]);return i(s.Select,{ref:u,label:e,data:d,value:n,onChange:r,required:t,sx:o,maxDropdownHeight:500,...l})}));function vc({context:e}){const{value:t,set:n}=R(e.instanceData,"config"),r=x.defaults({},t,Sr),{control:a,handleSubmit:o,reset:l}=v.useForm({defaultValues:r});return y.useEffect(()=>{l(r)},[t]),t?i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[i(s.Text,{children:"X Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"x_axis_data_key",control:a,render:({field:u})=>i(W,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"xAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Text,{mt:"lg",children:"Y Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"y_axis_data_key",control:a,render:({field:u})=>i(W,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"yAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Text,{mt:"lg",children:"Z Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"z_axis_data_key",control:a,render:({field:u})=>i(W,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"zAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(s.Button,{color:"blue",type:"submit",children:[i(T.DeviceFloppy,{size:20}),i(s.Text,{ml:"md",children:"Save"})]})})]})}):null}function xc(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis_data_key:a,y_axis_data_key:o,z_axis_data_key:l,...u}=e;return{...u,x_axis_data_key:r(a),y_axis_data_key:r(o),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class wc extends ye{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:a}=n;return{...n,version:2,config:xc(a,r)}})}}const Cc={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new wc,name:"bar-3d",viewRender:mc,configRender:vc,createConfig(){return{version:2,config:x.cloneDeep(Sr)}}};class We extends y.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const n=()=>{this.setState({error:null})};return p(s.Box,{children:[i(s.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),i(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}const ze={mantissa:0,output:"number",trimMantissa:!1,average:!1};function Sc({value:e,onChange:t},n){const r=u=>{t({...e,output:u})},a=u=>{const c=u===0?!1:e.trimMantissa;t({...e,mantissa:u,trimMantissa:c})},o=u=>{t({...e,trimMantissa:u.currentTarget.checked})},l=u=>{t({...e,average:u.currentTarget.checked})};return p(s.Stack,{ref:n,children:[p(s.Group,{grow:!0,children:[i(s.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:r,sx:{flexGrow:1}}),i(s.Switch,{label:p(s.Stack,{spacing:0,children:[i(s.Text,{children:"Average"}),i(s.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:l,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(s.Group,{grow:!0,children:[i(s.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:a}),i(s.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(s.Stack,{spacing:0,children:[i(s.Text,{weight:"bold",children:"Preview"}),i(We,{children:p(s.Group,{position:"apart",children:[p(s.Text,{size:12,color:"gray",children:["123456789 ",i(T.ArrowRight,{size:9})," ",Z(123456789).format(e)]}),p(s.Text,{size:12,color:"gray",children:["1234 ",i(T.ArrowRight,{size:9})," ",Z(1234).format(e)]}),p(s.Text,{size:12,color:"gray",children:["0.1234 ",i(T.ArrowRight,{size:9})," ",Z(.1234).format(e)]})]})})]})]})}const Ye=y.forwardRef(Sc),Xe={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
55
55
|
`)},ps={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:kc,configRender:_c,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 _c(e){return i(B,{})}function kc(e){return i(s.Text,{children:"Click chart's series"})}const Tc=[{label:"Truncate",value:"truncate"},{label:"Break Line",value:"break"},{label:"Break Word",value:"breakAll"}],zn=y.forwardRef(({sectionTitle:e,value:t,onChange:n},r)=>{const a=o=>l=>{const u=x.cloneDeep(t);x.set(u,o,l),n(u)};return p(s.Stack,{spacing:0,children:[e&&i(s.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),p(s.Group,{grow:!0,noWrap:!0,children:[i(s.NumberInput,{label:"Max Width",hideControls:!0,value:t.width,onChange:a("width")}),i(s.Select,{label:"Overflow",data:Tc,value:t.overflow,onChange:a("overflow")}),i(s.TextInput,{label:"Ellipsis",value:t.ellipsis,disabled:!0})]})]})}),ut=y.forwardRef(({value:e,onChange:t},n)=>{const r=o=>{t({...e,on_axis:o})},a=o=>{t({...e,in_tooltip:o})};return p(s.Stack,{ref:n,spacing:0,children:[i(zn,{sectionTitle:"Overflow on Axis",value:e.on_axis,onChange:r}),i(zn,{sectionTitle:"Overflow in Tooltip",value:e.in_tooltip,onChange:a})]})}),Qe={on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}};function ct({overflow:e,width:t}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],r=e==="truncate"?"nowrap":"initial",a={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
|
|
56
56
|
max-width: ${t}px;
|
|
57
57
|
word-break: ${n};
|
|
@@ -437,7 +437,7 @@ Check the top-level render call using <`+V+">.")}return E}}function Tu(S,E){{if(
|
|
|
437
437
|
<tbody>${g.join("")}</tbody>
|
|
438
438
|
</table>
|
|
439
439
|
`}}}function u1(e,t){const n=Yt(e.heat_block.min,t),r=Yt(e.heat_block.max,t);return{min:n,max:r,calculable:!0,orient:"horizontal",left:"center",top:0,itemWidth:15}}function c1(e,t,n){const r=O(e.x_axis.data_key),a=x.uniq(t[r.queryID].map(c=>c[r.columnKey])),{overflow:o,rotate:l}=e.x_axis.axisLabel,u=ot(o.on_axis);return{id:"main-x-axis",type:"category",data:a,name:e.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:l,...u,formatter:n},splitArea:{show:!0},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:2}}function d1(e,t,n){const r=O(e.x_axis.data_key),a=O(e.y_axis.data_key),{nameAlignment:o,data_key:l,...u}=e.y_axis,c=x.uniq(t[r.queryID].map(g=>g[a.columnKey])),{overflow:d,rotate:f}=e.y_axis.axisLabel,h=ot(d.on_axis);return{...u,type:"category",data:c,axisLabel:{rotate:f,...h,formatter:n},axisLine:{show:!0,color:"blue"},axisTick:{show:!0,alignWithLabel:!0},splitArea:{show:!0},nameTextStyle:{fontWeight:"bold",align:o},nameLocation:"end",nameGap:15,z:2}}const p1={tooltip:{confine:!0}};function h1(e,t,n){if(!e.x_axis.data_key||!e.y_axis.data_key||!e.heat_block.data_key)return{};const r=n.reduce((u,c)=>{const d=bt(c,t);return u[c.name]=et(c,d),u},{}),a=n1(e),o=r1(e),l={xAxis:c1(e,t,a.x_axis),yAxis:d1(e,t,a.y_axis),series:a1(e,t),tooltip:l1(e,t,a,o),grid:i1(e),visualMap:u1(e,r)};return x.defaultsDeep({},l,p1)}ie.use([q.DataZoomComponent,he.HeatmapChart,q.GridComponent,q.LegendComponent,q.TooltipComponent,q.VisualMapComponent,Be.CanvasRenderer]);function f1({conf:e,data:t,width:n,height:r,interactionManager:a,variables:o}){const l=y.useMemo(()=>{const h=O(e.x_axis.data_key),g=O(e.y_axis.data_key);return x.keyBy(t[h.queryID],m=>`${m[h.columnKey]}---${m[g.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),u=Je(a.triggerManager,Ro.id),c=y.useCallback(h=>{const[g,m]=h.value,C=x.get(l,`${g}---${m}`,{error:"rowData is not found"});u.forEach(w=>{a.runInteraction(w.id,{...h,rowData:C})})},[l,u,a]),d=y.useMemo(()=>({click:c}),[c]),f=y.useMemo(()=>h1(e,t,o),[e,t]);return i(Pe,{echarts:ie,option:f,style:{width:n,height:r},onEvents:d,notMerge:!0,theme:"merico-light"})}function g1({context:e,instance:t}){const n=Ze({vizManager:e.vizManager,instance:t}),{value:r}=R(e.instanceData,"config"),{variables:a}=e,o=y.useMemo(()=>x.defaults({},r,Di),[r]),l=e.data,{width:u,height:c}=e.viewport;return!u||!c?null:i(Ge,{width:u,height:c,children:i(f1,{variables:a,width:it(u),height:at(c),data:l,conf:o,interactionManager:n})})}class m1 extends ye{constructor(){super(...arguments);N(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const y1={displayName:"Merico Heatmap",displayGroup:"Merico suite",migrator:new m1,name:"merico-heatmap",viewRender:g1,configRender:HC,createConfig:()=>({version:1,config:Di}),triggers:[Ro]},b1=[{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"})),v1=[rc,ic,oc,sc,ac,lc],Qo=()=>({id:"dashboard",version:as,manifest:{viz:[bi,sx,Iw,Bb,Ix,Iy,J0,Cc,Gh,Hg,Pm,d0,gy,Ag,Uv,Hy,Ib,Pw,MC,y1,WC,nf],color:[...b1,...v1]}}),yn=new pc,Ce={pluginManager:gt("pluginManager"),vizManager:gt("vizManager"),colorManager:gt("colorManager"),instanceScope:{panelModel:gt("panelModel"),vizInstance:gt("vizInstance"),interactionManager:gt("interactionManager"),migrator:gt("migrator"),operationManager:gt("operationManager"),triggerManager:gt("triggerManager")}},Ii=()=>{try{yn.install(Qo())}catch{}const e=new ec(yn),t=new dc(yn);return{pluginManager:yn,vizManager:e,colorManager:t}},ht=y.createContext(Ii());try{yn.install(Qo())}catch{}const Mi=y.createContext(null);function ar(e){const t=y.useContext(Mi),n=K.useCreation(()=>e.configure(t||new Cr),[e.configure]),r=K.usePrevious(n);return r&&r!==n&&r.dispose(),i(Mi.Provider,{value:n,children:e.children})}function Uo(){return y.useContext(Mi)}const x1=({description:e,isDescriptionEmpty:t})=>t?null:i(s.Tooltip,{color:"white",label:i(Rn,{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:i(s.Box,{sx:{height:"16px",alignSelf:"center"},children:i($.IconInfoCircle,{size:16,color:"gray"})})}),w1=k.observer(({label:e,config:{default_value:t,description:n,isDescriptionEmpty:r,...a},value:o,onChange:l})=>p(s.Box,{children:[i(s.Text,{children:" "}),i(s.Checkbox,{label:p(s.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[i(s.Box,{sx:{flexGrow:1},children:e}),i(x1,{description:n,isDescriptionEmpty:r})]}),checked:o||!1,onChange:u=>l(u.currentTarget.checked),...a,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),Ko=k.observer(({label:e,config:t,value:n=[null,null],onChange:r})=>{const{inputFormat:a,...o}=t,l=Array.isArray(n)?n.map(f=>f?Y(f).toDate():null):[null,null],u=f=>{r(f.map(h=>h&&Y(h).format(a)))},c=t.getMinDate(l[0]),d=t.getMaxDate(l[0]);return i(Ou.DatePickerInput,{type:"range",label:e,value:l,onChange:u,icon:i(T.Calendar,{size:16}),sx:{minWidth:"16em"},minDate:c,maxDate:d,valueFormat:a,styles:{input:{borderColor:"#e9ecef"}},...o})}),C1=s.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"},required:{color:"#fa5252",paddingLeft:"3px"},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":{width:"calc(100% - 30px)",overflow:"hidden",'div[data-role="label"]':{overflowWrap:"break-word"}}},".rc-virtual-list-holder-inner":{alignItems:"flex-start"}}})),Xo=({errorMessage:e})=>e?i(s.Text,{color:"red",size:12,children:e}):i(s.Text,{color:"dimmed",size:12,children:"Not found"}),S1=({disabled:e,classNames:t,styles:n,unstyled:r,radius:a,style:o,label:l,value:u,onChange:c,options:d,errorMessage:f,required:h})=>{const{classes:g,cx:m}=C1({radius:a},{name:"MultiSelectWidget",classNames:t,styles:n,unstyled:r}),[C,w]=y.useState(!1),_=L=>{w(L)},D=C&&(u==null?void 0:u.length)>0,[M,P]=y.useState(""),G=y.useMemo(()=>{if(!M)return d;const L=M.toLowerCase(),z=A=>{var F;return((F=A.description)==null?void 0:F.toLowerCase().includes(L))||A.label.toLowerCase().includes(L)};return d.filter(z)},[M,d]);return p(s.Stack,{spacing:3,children:[p(s.Group,{position:"apart",children:[p(s.Text,{className:g.label,children:[l,h&&i("span",{className:g.required,"aria-hidden":"true",children:"*"})]}),D&&i(s.Tooltip,{label:`${u.length} selected`,children:i(s.Badge,{children:u.length})})]}),i(Ka,{disabled:e,allowClear:!0,className:m(g.root,"check-select"),dropdownClassName:m(g.dropdown,""),onDropdownVisibleChange:_,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:o,clearIcon:()=>i(s.CloseButton,{}),value:u,onChange:c,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:i(Xo,{errorMessage:f}),maxTagTextLength:10,maxTagPlaceholder:L=>`${L.length} selected`,searchValue:M,onSearch:P,filterOption:!1,children:G.map(L=>p(Ka.Option,{title:L.label,children:[i(s.Text,{size:"sm","data-role":"label",children:L.label}),L.description&&i(s.Text,{size:"xs",color:"dimmed","data-role":"description",children:L.description})]},L.value))})]})},_1=k.observer(({label:e,config:t,value:n,onChange:r})=>{const a=we(),o=!!t.options_query_id,{state:l,error:u}=a.getDataStuffByID(t.options_query_id),c=l==="loading",d=t.min_width?t.min_width:"200px",f=o?c:!1,h=g=>r(g,!1);return i(S1,{label:e,options:t.options,style:{minWidth:"160px",width:d,maxWidth:f?d:"unset",borderColor:"#e9ecef"},disabled:f,value:n,onChange:h,errorMessage:u,required:t.required})}),k1=y.forwardRef(({label:e,description:t,...n},r)=>i("div",{ref:r,...n,children:i(s.Group,{noWrap:!0,children:p("div",{children:[i(s.Text,{size:"sm","data-role":"label",children:e}),i(s.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),T1=k.observer(({label:e,config:t,value:n,onChange:r})=>{const a=we(),o=!!t.options_query_id,{state:l,error:u}=a.getDataStuffByID(t.options_query_id),c=l==="loading";return i(s.Select,{label:e,data:t.options,disabled:o?c:!1,value:n,onChange:r,error:!!u,placeholder:u,maxDropdownHeight:500,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:k1})});function D1({label:e,config:t,value:n,onChange:r}){return i(s.TextInput,{label:e,value:n||"",onChange:a=>r(a.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}const I1=({rotate:e,onClick:t})=>i("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:i("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),M1=({expanded:e,isLeaf:t,value:n,onClick:r,...a})=>(n==="0-0-value"&&console.log(a),t?i("span",{style:{width:"14px",display:"inline-block"}}):i(I1,{rotate:e?"0":"-90",onClick:r,...a})),A1=({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:[i("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),i("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),i("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),i("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),z1=({onClick:e,...t})=>i(A1,{onClick:e,...t}),E1=s.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"},required:{color:"#fa5252",paddingLeft:"3px"},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"}}}})),$1=({disabled:e,classNames:t,styles:n,unstyled:r,radius:a,style:o,label:l,value:u,onChange:c,treeData:d,errorMessage:f,required:h,treeCheckStrictly:g})=>{const{classes:m,cx:C}=E1({radius:a},{name:"FilterTreeSelectWidget",classNames:t,styles:n,unstyled:r}),[w,_]=y.useState(!1),D=P=>{_(P)},M=w&&(u==null?void 0:u.length)>0;return p(s.Stack,{spacing:3,children:[p(s.Group,{position:"apart",children:[p(s.Text,{className:m.label,children:[l,h&&i("span",{className:m.required,"aria-hidden":"true",children:"*"})]}),M&&i(s.Tooltip,{label:`${u.length} selected`,children:i(s.Badge,{children:u.length})})]}),i(Xa,{disabled:e,allowClear:!0,treeCheckStrictly:g,className:C(m.root,"check-select"),dropdownClassName:C(m.dropdown,""),onDropdownVisibleChange:D,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,treeLine:!0,clearIcon:()=>i(s.CloseButton,{}),switcherIcon:M1,treeIcon:z1,maxTagTextLength:10,value:u,treeData:d,notFoundContent:i(Xo,{errorMessage:f}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:Xa.SHOW_PARENT,onChange:c,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:P=>`${P.length} selected`})]})},L1=k.observer(({label:e,config:t,value:n,onChange:r})=>{const{treeData:a,treeDataLoading:o,errorMessage:l}=t,u=t.min_width?t.min_width:"200px",d=!!t.options_query_id?o:!1;return i($1,{disabled:d,style:{minWidth:"160px",width:u,maxWidth:d?u:"unset",borderColor:"#e9ecef"},value:n,onChange:f=>r(f,!1),treeData:a,errorMessage:l,label:e,required:t.required,treeCheckStrictly:t.treeCheckStrictly})}),O1=k.observer(({filter:{type:e,config:t,key:n,...r},formFieldProps:a})=>{switch(e){case"select":return i(T1,{...r,...a,config:t});case"multi-select":return i(_1,{...r,...a,config:t});case"tree-select":return i(L1,{...r,...a,config:t});case"text-input":return i(D1,{...r,...a,config:t});case"date-range":return i(Ko,{...r,...a,config:t});case"checkbox":return i(w1,{...r,...a,config:t});default:return null}}),P1=k.observer(y.forwardRef(({filter:e,...t},n)=>i("div",{className:"filter-root",ref:n,children:i(We,{children:i(O1,{filter:e,formFieldProps:t})})})));function B1(e){const t=le();y.useEffect(()=>{var n,r;(r=(n=t.filters).updatePreviewValues)==null||r.call(n,e)},[e])}const Jo=k.observer(function({view:t}){const n=we(),{control:r,handleSubmit:a,reset:o}=v.useForm({defaultValues:n.filters.values,reValidateMode:"onBlur"}),l=v.useWatch({control:r});y.useEffect(()=>{o(n.filters.values)},[n.filters.values,o]),B1(l);const u=n.filters.visibleInView(t.id),c=y.useMemo(()=>u.every(g=>g.should_auto_submit),[u]),d=y.useMemo(()=>u.filter(g=>x.get(g,"config.required",!1)),[u]),f=y.useMemo(()=>d.length===0?!1:d.some(g=>!g.requiredAndPass(l[g.key])),[l,d]);if(u.length===0)return null;const h=(g,m)=>(C,w)=>{m(C),(g.should_auto_submit||w)&&n.filters.setValueByKey(g.key,C)};return i("form",{onSubmit:a(n.filters.setValues),children:p(s.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:c?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[i(s.Group,{align:"flex-start",children:u.map(g=>i(v.Controller,{name:g.key,control:r,render:({field:m})=>i(P1,{filter:g,value:m.value,onChange:h(g,m.onChange)})},g.id))}),!c&&i(s.Group,{sx:{alignSelf:"flex-end"},children:i(s.Button,{color:"blue",size:"sm",type:"submit",disabled:f,children:"Search"})})]})})}),V1={viewPanelInFullScreen:x.noop,inFullScreen:!1},sr=y.createContext(V1),Zo=b.types.model("MockContextMeta",{current:b.types.optional(b.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function Ho(e){return{current:e}}const N1=b.types.model("PanelLayoutMeta",{x:b.types.number,y:b.types.maybeNull(b.types.number),w:b.types.number,h:b.types.number,moved:b.types.optional(b.types.boolean,!1),static:b.types.optional(b.types.boolean,!1)}).views(e=>({get json(){const{x:t,y:n,w:r,h:a,moved:o}=e;return{h:a,w:r,x:t,y:n===null?0:n,moved:o,static:e.static}}})).actions(e=>({set(t){const{x:n,y:r,w:a,h:o,moved:l}=t;e.x=n,e.y=r,e.w=a,e.h=o,e.moved=!!l,e.static=!!t.static},setWidth(t){e.w=t},setHeight(t){e.h=t}})),q1=b.types.model("PanelStyleBorderMeta",{enabled:b.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),F1=b.types.model("PanelStyleMeta",{border:q1}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),G1=b.types.model("VariableMeta",{name:b.types.string,size:b.types.string,weight:b.types.string,color:b.types.union(b.types.model({type:b.types.literal("static"),staticColor:b.types.string}),b.types.model({type:b.types.literal("continuous"),valueRange:b.types.array(b.types.number),colorRange:b.types.array(b.types.string)}),b.types.model({type:b.types.literal("piecewise")})),formatter:b.types.model({output:b.types.enumeration("Output",["number","percent"]),average:b.types.optional(b.types.boolean,!1),mantissa:b.types.number,trimMantissa:b.types.optional(b.types.boolean,!1)}),data_field:b.types.string,aggregation:b.types.union(b.types.model({type:b.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:b.types.frozen()}),b.types.model({type:b.types.literal("quantile"),config:b.types.model({p:b.types.number})}),b.types.model({type:b.types.literal("custom"),config:b.types.model({func:b.types.string})}))}).views(e=>({get json(){const{name:t,size:n,weight:r,color:a,formatter:o,data_field:l,aggregation:u}=e;return x.cloneDeep({name:t,size:n,color:a,weight:r,formatter:o,data_field:l,aggregation:u})}})),W1=b.types.model("PanelVizMeta",{type:b.types.string,conf:b.types.frozen()}).views(e=>({get json(){return{conf:e.conf,type:e.type}}})).actions(e=>({setType(t){e.type=t},setConf(t){e.conf=t}})),j1=b.types.model({id:b.types.string,title:b.types.string,description:b.types.string,layout:N1,queryIDs:b.types.array(b.types.string),viz:W1,style:F1,variables:b.types.optional(b.types.array(G1),[])}).views(e=>({get json(){const{id:t,title:n,description:r,queryIDs:a}=e;return{id:t,viz:e.viz.json,style:e.style.json,title:n,layout:e.layout.json,queryIDs:[...a],variables:e.variables.map(o=>o.json),description:r}},get queryIDSet(){return new Set(e.queryIDs)}})).actions(e=>({setID(t){e.id=t},setTitle(t){e.title=t},setDescription(t){e.description=t},addQueryID(t){e.queryIDSet.has(t)||e.queryIDs.push(t)},removeQueryID(t){if(!e.queryIDSet.has(t))return;const n=new Set(e.queryIDSet);n.delete(t),e.queryIDs=b.cast(Array.from(n))},setQueryIDs(t){e.queryIDs=b.cast(t)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)}})),or=e=>x.cloneDeepWith(e,(t,n)=>{if(n!==void 0&&t)return te.toJS(t)});var Se=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e))(Se||{});const R1=b.types.model("QueryMeta",{id:b.types.string,name:b.types.string,type:b.types.enumeration("DataSourceType",[Se.Postgresql,Se.MySQL,Se.HTTP]),key:b.types.string,sql:b.types.string,pre_process:b.types.optional(b.types.string,""),post_process:b.types.optional(b.types.string,""),run_by:b.types.optional(b.types.array(b.types.string),[]),react_to:b.types.optional(b.types.array(b.types.string),[])}).views(e=>({get valid(){return e.id&&e.type&&e.key&&e.name?e.type===Se.HTTP?!!e.pre_process:!!e.sql:!1},get json(){const{id:t,name:n,type:r,key:a,sql:o,run_by:l,react_to:u,pre_process:c,post_process:d}=e;return or({id:t,key:a,sql:o,name:n,type:r,run_by:l,react_to:u,pre_process:c,post_process:d})}})).actions(e=>({setName(t){e.name=t},setKey(t){e.key=t},setType(t){e.type=t},setSQL(t){e.sql=t},setRunBy(t){e.run_by.length=0,e.run_by.push(...t)},setReactTo(t){e.react_to.length=0,e.react_to.push(...t)},setPreProcess(t){e.pre_process=t},setPostProcess(t){e.post_process=t}})),Y1=b.types.model("SQLSnippetMeta",{key:b.types.string,value:b.types.string}).views(e=>({get json(){const{key:t,value:n}=e;return{key:t,value:n}}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.value=t}}));var _e=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TreeSelect="tree-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(_e||{});const el=b.types.model("FilterCheckboxConfigMeta",{_name:b.types.literal("checkbox"),description:b.types.optional(b.types.string,""),default_value:b.types.boolean}).views(e=>({get json(){const{_name:t,description:n,default_value:r}=e;return{_name:t,description:n,default_value:r}},get isDescriptionEmpty(){const{description:t}=e;return t===""||t==="<p></p>"}})).actions(e=>({setDefaultValue(t){e.default_value=t},setDescription(t){e.description=t}})),Q1=()=>el.create({_name:"checkbox",description:"",default_value:!1});function tl(e,t){return e.map(n=>{try{return n?Y.tz(n,"UTC").format(t):null}catch{return console.log(`[date-range] failed parsing ${n}`),null}})}const U1=b.types.model("FilterDateRangeConfigMeta",{_name:b.types.literal("date-range"),required:b.types.boolean,inputFormat:b.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:b.types.optional(b.types.array(b.types.union(b.types.string,b.types.null)),[null,null]),clearable:b.types.boolean,max_days:b.types.optional(b.types.number,0),allowSingleDateInRange:b.types.optional(b.types.boolean,!1)}).views(e=>({get json(){const{_name:t,max_days:n,required:r,clearable:a,inputFormat:o,default_value:l,allowSingleDateInRange:u}=e;return{_name:t,max_days:n,required:r,clearable:a,inputFormat:o,default_value:tl(l,o),allowSingleDateInRange:u}},truthy(t){return Array.isArray(t)&&t.length===2&&t.every(n=>!!n)}})).views(e=>({getMaxDate(t){const{max_days:n}=e;if(!(!n||!t))return Y(t).startOf("day").add(n,"days").toDate()},getMinDate(t){const{max_days:n}=e;if(!(!n||!t))return Y(t).startOf("day").subtract(n,"days").toDate()}})).actions(e=>({setFilterValue(t){try{const n=b.getParent(e);b.getRoot(e).filters.setValueByKey(n.key,t)}catch(n){console.error(n)}}})).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}})),nl=b.types.snapshotProcessor(U1,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>n===null?null:Y.tz(n,"UTC").toISOString())}},postProcessor(e){const{default_value:t,...n}=e;return{...n,default_value:tl(t,n.inputFormat)}}}),K1=()=>nl.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),X1=b.types.model({label:b.types.string,value:b.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),Ai=b.types.model("FilterConfigModel_BaseSelect",{static_options:b.types.optional(b.types.array(X1),[]),options_query_id:b.types.optional(b.types.string,""),default_selection_count:b.types.optional(b.types.number,0),required:b.types.optional(b.types.boolean,!1)}).views(e=>({get usingQuery(){return!!e.options_query_id}})).views(e=>({get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:n,error:r}=b.getRoot(e).content.getDataStuffByID(e.options_query_id);return n==="idle"?t:[]}})).actions(e=>({setRequired(t){e.required=t},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??""}})),rl=b.types.compose("FilterMultiSelectConfigMeta",b.types.model({_name:b.types.literal("multi-select"),min_width:b.types.optional(b.types.string,""),default_value:b.types.optional(b.types.array(b.types.string),[])}),Ai).views(e=>({get json(){const{_name:t,default_value:n,required:r,min_width:a,static_options:o,options_query_id:l,default_selection_count:u}=e;return or({_name:t,required:!!r,min_width:a,default_value:n,static_options:o,options_query_id:l,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},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=b.cast(t)},setMinWidth(t){e.min_width=t},setDefaultSelection(){const t=b.getRoot(e).content.filters,n=b.getParent(e).key;t.setValueByKey(n,e.default_selection)}})).actions(e=>({afterCreate(){b.addDisposer(e,te.reaction(()=>te.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!0,delay:0}))}})),J1=()=>rl.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),il=b.types.compose("FilterConfigModel_Select",b.types.model({_name:b.types.literal("select"),default_value:b.types.string,width:b.types.optional(b.types.string,"")}),Ai).views(e=>({get json(){const{_name:t,default_value:n,required:r,width:a,static_options:o,options_query_id:l,default_selection_count:u}=e;return or({_name:t,width:a,required:r,default_value:n,static_options:o,options_query_id:l,default_selection_count:u})},truthy(t){return!!t},getSelectOption(t){return e.options.find(n=>n.value===t)},get default_selection(){return e.usingQuery?e.default_selection_count>0&&e.options.length>0?e.options[0].value:"":e.default_value}})).actions(e=>({setDefaultValue(t){e.default_value=t},setWidth(t){e.width=t},setDefaultSelection(){const t=b.getRoot(e).content.filters,n=b.getParent(e).key;t.setValueByKey(n,e.default_selection)}})).actions(e=>({afterCreate(){b.addDisposer(e,te.reaction(()=>te.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!0,delay:0}))}})),Z1=()=>il.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),al=b.types.model("FilterTextInputConfigMeta",{_name:b.types.literal("text-input"),required:b.types.boolean,default_value:b.types.string}).views(e=>({get json(){const{_name:t,required:n,default_value:r}=e;return{_name:t,required:n,default_value:r}},truthy(t){return typeof t!="string"?!1:!!t.trim()}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),sl=()=>al.create({_name:"text-input",required:!1,default_value:""});function H1(e){return Pu.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function eS(e){return e.map(t=>{const{label:n,description:r,...a}=t,o={...a,filterBasis:`${n}___${r??""}`,description:r,label:n};return r&&(o.label=y.createElement("div",{},[y.createElement(s.Text,{key:0,title:t.label},t.label),y.createElement(s.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description},t.description)])),o})}const ol=b.types.compose("FilterTreeSelectConfigMeta",b.types.model({_name:b.types.literal("tree-select"),min_width:b.types.optional(b.types.string,""),default_value:b.types.optional(b.types.array(b.types.string),[]),treeCheckStrictly:b.types.optional(b.types.boolean,!1)}),Ai).views(e=>({get json(){const{_name:t,default_value:n,required:r,min_width:a,static_options:o,options_query_id:l,default_selection_count:u,treeCheckStrictly:c}=e;return{_name:t,required:!!r,min_width:a,default_value:n,static_options:o,options_query_id:l,treeCheckStrictly:c,default_selection_count:u}},get treeData(){const{data:t}=b.getRoot(e).content.getDataStuffByID(e.options_query_id),n=eS(t);return H1(n)},get errorMessage(){const{error:t}=b.getRoot(e).content.getDataStuffByID(e.options_query_id);return t},get treeDataLoading(){const{state:t}=b.getRoot(e).content.getDataStuffByID(e.options_query_id);return t==="loading"},get defaultSelection(){const{default_selection_count:t}=e;return t?this.treeData.slice(0,t).map(r=>r.value):[]},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=b.cast(t)},setMinWidth(t){e.min_width=t},setTreeCheckStrictly(t){e.treeCheckStrictly=t},applyDefaultSelection(){const t=b.getParent(e,1).key;b.getRoot(e).content.filters.setValueByKey(t,e.defaultSelection)},afterCreate(){b.addDisposer(e,te.reaction(()=>JSON.stringify(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!0,delay:0}))}})),tS=()=>ol.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),ll=b.types.model("FilterMeta",{id:b.types.identifier,key:b.types.string,label:b.types.string,order:b.types.number,visibleInViewsIDs:b.types.array(b.types.string),auto_submit:b.types.optional(b.types.boolean,!1),type:b.types.enumeration("DashboardFilterType",[_e.Select,_e.MultiSelect,_e.TreeSelect,_e.TextInput,_e.Checkbox,_e.DateRange]),config:b.types.union(il,rl,ol,al,el,nl)}).views(e=>({get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==_e.TreeSelect},get auto_submit_supported(){return[_e.Select,_e.Checkbox,_e.DateRange].includes(e.type)}})).views(e=>({get json(){const{id:t,key:n,label:r,order:a,visibleInViewsIDs:o,auto_submit:l,type:u,config:c}=e;return{id:t,key:n,type:u,label:r,order:a,config:c.json,auto_submit:l,visibleInViewsIDs:te.toJS(o)}},get visibleInViewsIDSet(){return new Set(e.visibleInViewsIDs)},get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return x.get(e.config,"required",!1)?x.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 _e.Select:e.config=Z1();break;case _e.MultiSelect:e.config=J1();break;case _e.TreeSelect:e.config=tS();break;case _e.TextInput:e.config=sl();break;case _e.Checkbox:e.config=Q1();break;case _e.DateRange:e.config=K1();break}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t}}));var j=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(j||{});const ul=b.types.model("ViewDivisionConfig",{_name:b.types.literal(j.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})),nS=()=>ul.create({_name:j.Division}),rS=b.types.model("CustomModalTitleModel",{enabled:b.types.optional(b.types.boolean,!1),func_content:b.types.optional(b.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:n}=e;return{enabled:t,func_content:n}},get value(){const{enabled:t,func_content:n}=e,r=b.getParent(e,2),a=b.getRoot(e);if(!t)return r.name;try{const o={filters:a.content.filters.values,context:a.context.current};return new Function(`return ${n}`)()(o)}catch(o){return console.error(o),r.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:n}){e.enabled=t,e.func_content=n}})),zi={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
440
|
-
`)},cl=b.types.model("ViewModalConfig",{_name:b.types.literal(j.Modal),width:b.types.string,height:b.types.string,custom_modal_title:b.types.optional(rS,zi)}).views(e=>({get json(){const{_name:t,width:n,height:r,custom_modal_title:a}=e;return{_name:t,width:n,height:r,custom_modal_title:a.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),iS=()=>cl.create({_name:j.Modal,width:"90vw",height:"90vh"}),aS=b.types.model("ViewTabsTabModel",{id:b.types.identifier,name:b.types.string,view_id:b.types.string,color:b.types.optional(b.types.string,"")}).views(e=>({get json(){const{id:t,name:n,view_id:r,color:a}=e;return{id:t,name:n,color:a,view_id:r}}})).actions(e=>({setName(t){e.name=t},setViewID(t){e.view_id=t},setColor(t){e.color=t}})),dl=b.types.model("ViewTabsConfig",{_name:b.types.literal(j.Modal),tabs:b.types.optional(b.types.array(aS),[]),variant:b.types.optional(b.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:b.types.optional(b.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:b.types.optional(b.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:n,orientation:r,tabs:a,grow:o}=e;return{grow:o,tabs:a.map(l=>l.json),_name:t,variant:n,orientation:r}}})).actions(e=>({setVariant(t){e.variant=t},setOrientation(t){e.orientation=t},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=b.cast(t)},addTab(){const t=Ie.randomId(),n={id:t,name:t,view_id:""};e.tabs.push(n)},removeTab(t){e.tabs.splice(t,1)}})),sS=()=>dl.create({_name:j.Modal,tabs:[]}),oS=b.types.model({id:b.types.identifier,name:b.types.string,type:b.types.enumeration("EViewComponentType",[j.Division,j.Modal,j.Tabs]),config:b.types.union(ul,cl,dl),panelIDs:b.types.optional(b.types.array(b.types.string),[])}).views(e=>({get json(){const{id:t,name:n,type:r,config:a}=e;return{id:t,name:n,type:r,config:a.json,panelIDs:e.panelIDs}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case j.Division:e.config=nS();break;case j.Modal:e.config=iS();break;case j.Tabs:e.config=sS();break}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},removePanelID(t){const n=e.panelIDs.filter(r=>r!==t);e.panelIDs.length=0,e.panelIDs.push(...n)}})),pl=b.types.model("DataSourceMetaModel",{id:b.types.string,type:b.types.enumeration("DataSourceType",[Se.HTTP,Se.MySQL,Se.Postgresql]),key:b.types.string,config:b.types.frozen()}),lS=b.types.model("DataSourcesMetaModel",{list:b.types.optional(b.types.array(pl),[])}).views(e=>({find({type:t,key:n}){return e.list.find(r=>r.key===n&&r.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),uS=b.types.model({id:b.types.string,content:b.types.string,create_time:b.types.string,update_time:b.types.string,is_preset:b.types.boolean}),hl=b.types.model("GlobalSQLSnippetsMeta",{list:b.types.optional(b.types.array(uS),[])}).views(e=>({find(t){return e.list.find(n=>n.id===t)},get options(){return e.list.map(t=>({value:t.id,label:t.id}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),Ei=b.types.model("ContextMeta",{current:b.types.optional(b.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function fl(e){return Ei.create({current:e})}const cS=b.types.compose("ViewRenderModel",oS,b.types.model({tab:b.types.optional(b.types.string,"")})).views(e=>({get defaultTab(){if(e.type!==j.Tabs)return"";const t=e.config;return t.tabs.length>0?t.tabs[0].id:""},get tabViewID(){var n;return e.type!==j.Tabs?"":((n=e.config.tabs.find(r=>r.id===e.tab))==null?void 0:n.view_id)??""},get contentModel(){return b.getParent(e,3)},get panels(){if(e.type!==j.Tabs)return this.contentModel.panels.panelsByIDs(e.panelIDs).panels;const t=this.tabViewID;return this.contentModel.views.findByID(t).panels},get renderViewIDs(){const t=[e.id];return e.type===j.Tabs&&t.push(this.tabViewID),t}})).actions(e=>({setTab(t){e.tab=t??""},afterCreate(){b.addDisposer(e,te.reaction(()=>e.defaultTab,t=>this.setTab(t),{fireImmediately:!0,delay:0}))}})),gl=b.types.model("ViewsRenderModel",{current:b.types.optional(b.types.array(cS),[]),visibleViewIDs:b.types.array(b.types.string)}).views(e=>({get json(){return e.current.map(t=>or(t.json))},get idMap(){const t=new Map;return e.current.forEach(n=>{t.set(n.id,n)}),t},findByID(t){return e.current.find(n=>n.id===t)},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:n})=>n===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:n})=>t.has(n))}})).actions(e=>({appendToVisibles(t){new Set(e.visibleViewIDs.map(r=>r)).has(t)||e.visibleViewIDs.push(t)},rmVisibleViewID(t){const n=e.visibleViewIDs.findIndex(r=>r===t);n!==-1&&e.visibleViewIDs.splice(n,1)}}));function dS(e){const t=e.length>0?[e[0].id]:[];return{current:e.map(r=>{const{_name:a=r.type}=r.config;return{...r,config:{...r.config,_name:a},panelIDs:r.panelIDs}}),visibleViewIDs:t}}const ml=j1.views(e=>({get contentModel(){return b.getRoot(e).content}})).views(e=>({get queries(){return e.contentModel.queries.findByIDSet(e.queryIDSet)},get data(){return this.queries.reduce((t,n)=>(t[n.id]=n.data,t),{})},get dataLoading(){return this.queries.some(t=>t.state==="loading")},get queryStateMessages(){const t=this.queries.filter(o=>!o.runByConditionsMet);if(t.length===0)return"";const n=new Set,r=new Set;t.forEach(o=>{const l=o.conditionNames;l.context.forEach(u=>n.add(u)),l.filters.forEach(u=>r.add(u))});const a=[];return n.size>0&&(console.log(n),a.push(`context: ${Array.from(n).join(", ")}`)),r.size>0&&a.push(`filter${r.size>1?"s":""}: ${Array.from(r).join(", ")}`),a.length===2&&a.splice(1,0,"and"),a.unshift("Waiting for"),a.join(" ")},get queryErrors(){return this.queries.map(t=>t.error).filter(t=>!!t)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages===""&&!this.dataLoading}})).actions(e=>({refreshData(){e.queries.forEach(t=>t.fetchData())},downloadData(){b.getRoot(e).content.queries.downloadDataByQueryIDs(e.queryIDs)}}));function pS(e){return{id:e,layout:{x:0,y:1/0,w:18,h:300},title:e,description:"<p></p>",queryIDs:[],viz:{type:bi.name,conf:bi.createConfig()},style:{border:{enabled:!0}}}}const yl=b.types.model("PanelsRenderModel",{list:b.types.optional(b.types.array(ml),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(n=>n.id===t)},get idMap(){const t=new Map;return e.list.forEach(n=>{t.set(n.id,n)}),t}})).views(e=>({panelsByIDs(t){const n=[];t.forEach(a=>{const o=e.idMap.get(a);o?n.push(o):console.warn(`Panel is not found, id:${a}`)});const r=n.map(a=>({...a.layout.json,i:a.id}));return{panels:n,layouts:r}}}));function bl(e,t){if(e===void 0)return e;if(t._name==="date-range")try{const[...n]=e;return n.map(r=>r===null?r:Y.tz(r,"UTC").format(t.inputFormat)??r)}catch(n){return console.error(n),e}return e}function hS(e){return e.reduce((t,n)=>(t[n.key]=bl(n.config.default_value,n.config),t),{})}const vl=b.types.model("FiltersRenderModel",{current:b.types.optional(b.types.array(ll),[]),values:b.types.optional(b.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(n=>n.id===t)},get inOrder(){return x.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return x.sortBy(e.current.filter(n=>n.visibleInViewsIDSet.has(t)),"order")},get firstFilterValueKey(){return Object.keys(e.values)[0]??""},get keyLabelMap(){return e.current.reduce((t,n)=>(t[n.key]=n.label,t),{})},getSelectOption(t){const n=this.findByID(t);if(!n||!("getSelectOption"in n.config))return null;const r=e.values[n.key];return n.config.getSelectOption(r)}})).actions(e=>({setValues(t){e.values=t},setValueByKey(t,n){e.values={...e.values,[t]:n}},getValueByKey(t){return e.values[t]}}));function xl(e){return{current:e,values:hS(e)}}const fS=new Bu.AsyncParser({withBOM:!0});async function wl(e){return!Array.isArray(e)||e.length===0?"":await fS.parse(e).promise()}async function gS(e,t){const n=await wl(t),r=new Blob([n],{type:"text/csv"});br.saveAs(r,`${e}.csv`)}function Cl(e){const t=new Vu;e.forEach(({id:n,data:r})=>{t.file(`${n}.csv`,wl(r))}),t.generateAsync({type:"blob"}).then(n=>{br.saveAs(n,"dashboard_data.zip")})}function Sl(e,t){const n=new Blob([t],{type:"application/json"});br.saveAs(n,`${e}.json`)}const mS=R1.views(e=>({get conditionOptions(){if(!b.isAlive(e))return[];const t=b.getRoot(e).content,{context:n}=t.payloadForSQL,r=Object.keys(n).map(o=>({group:"Context",label:o,value:`context.${o}`,description:void 0})),a=t.filters.keyLabelOptions.map(o=>({group:"Filters",label:o.label,value:`filters.${o.value}`,description:o.value}));return[...r,...a]},get unmetRunByConditions(){if(!b.isAlive(e))return[];const{run_by:t}=e;if(t.length===0)return[];const n=b.getRoot(e).content.payloadForSQL;return t.filter(r=>{const a=x.get(n,r);return Array.isArray(a)?a.length===0:typeof a=="number"?Number.isNaN(a):!a})}})).views(e=>({get reQueryKey(){const{react_to:t=[]}=e;if(t.length===0)return"";const n=b.getRoot(e).content.payloadForSQL,r=[...t].reduce((a,o)=>(a[o]=x.get(n,o),a),{});return JSON.stringify(r)},get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=b.getRoot(e).content.filters,n=e.unmetRunByConditions.filter(a=>a.startsWith("context.")).map(a=>a.split("context.")[0]),r=e.unmetRunByConditions.filter(a=>a.startsWith("filters.")).map(a=>x.get({filters:t},a)).filter(a=>!!a);return{context:n,filters:r}},get queries(){return b.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)}}));function yS(e,t){return new Function(`return ${e}`)()(t,At)}function bS(e,t,n){return yS(e,{context:t,filters:n})}function vS(e,t){try{return new Function(`return ${e.config.processing.pre}`)()(t,At)}catch(n){return console.error(n),t}}function xS(e,t){return new Function(`return ${e.config.processing.post}`)()(t,At)}function wS(e,t){return e?new Function(`return ${e}`)()(t,At):t}const CS=b.types.compose("QueryRenderModel",mS,b.types.model({state:b.types.optional(b.types.enumeration(["idle","loading","error"]),"idle"),data:b.types.optional(b.types.frozen([]),[]),error:b.types.frozen()})).views(e=>({get rootModel(){return b.getRoot(e)},get contentModel(){return this.rootModel.content},get formattedSQL(){const t=this.contentModel.payloadForSQL;return xr(e.sql,t)},get typedAsSQL(){return[Se.Postgresql,Se.MySQL].includes(e.type)},get typedAsHTTP(){return[Se.HTTP].includes(e.type)},get datasource(){const{key:t,type:n}=e;return this.rootModel.datasources.find({type:n,key:t})},get httpConfigString(){const{context:t,filters:n}=this.contentModel.payloadForSQL,{name:r,pre_process:a}=e.json,o=bS(a,t,n);return console.groupCollapsed(`Request config for: ${r}`),console.log(o),console.groupEnd(),JSON.stringify(o)}})).views(e=>({get stateMessage(){if(e.state!=="idle")return"";if(!e.runByConditionsMet){const{context:t,filters:n}=e.conditionNames;if(t.length===0&&n.length===0)return"Waiting";const r=[];return t.length>0&&r.push(`context: ${t.join(", ")}`),n.length>0&&r.push(`filter${n.length>1?"s":""}: ${n.join(", ")}`),r.length===2&&r.splice(1,0,"and"),r.unshift("Waiting for"),r.join(" ")}return e.data.length>0?"":"Empty Data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:b.flow(function*(){var t;if(!e.inUse){console.debug(`Skipping query[${e.name}]`);return}if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const n=e.contentModel.payloadForSQL;e.data=yield*b.toGenerator(Ju({payload:n,name:e.name,query:e.json},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(!xt.isCancel(n)){e.data=[];const r=x.get(n,"message","unkown error");e.error=x.get(n,"response.data.detail.message",r),e.state="error"}}}}),runHTTP:b.flow(function*(){var t;if(!e.inUse){console.debug(`Skipping query[${e.name}]`);return}if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{type:n,key:r,post_process:a}=e.json;let o=JSON.parse(e.httpConfigString);o=vS(e.datasource,o);const l=yield*b.toGenerator(Zu({type:n,key:r,configString:JSON.stringify(o),name:e.name},e.controller.signal));let u=xS(e.datasource,l);u=wS(a,u),e.data=u,e.state="idle",e.error=null}catch(n){if(console.error(n),!xt.isCancel(n)){e.data=[];const r=x.get(n,"message","unkown error");e.error=x.get(n,"response.data.detail.message",r),e.state="error"}}}})})).actions(e=>({fetchData:()=>e.typedAsHTTP?e.runHTTP():e.runSQL(),beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){b.addDisposer(e,te.reaction(()=>{var n;return e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(n=e.datasource)==null?void 0:n.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},e.fetchData,{fireImmediately:!0,delay:0}))}})),_l=b.types.model("QueriesRenderModel",{current:b.types.optional(b.types.array(CS),[])}).views(e=>({get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},findByIDSet(t){return e.current.filter(n=>t.has(n.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get contentModel(){return b.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:n}=this.contentModel,r=[];t.visibleViews.forEach(l=>{l.panels.forEach(u=>{r.push(...u.queryIDs)})});const a=x.uniq(t.visibleViews.map(l=>l.renderViewIDs).flat());n.current.forEach(l=>{const u=x.get(l,"config.options_query_id");if(!u)return;a.some(d=>l.visibleInViewsIDSet.has(d))&&r.push(u)});const o=new Set(r);return console.debug("QueryIDs:",o),o},isQueryInUse(t){return this.visibleQueryIDSet.has(t)}})).actions(e=>({downloadAllData(){const t=e.current.map(({name:n,data:r})=>({id:n,data:r}));Cl(t)},downloadDataByQueryIDs(t){const n=new Set(t),r=e.current.filter(a=>n.has(a.id)).map(({name:a,data:o})=>({id:a,data:o}));Cl(r)},downloadDataByQueryID(t){const n=e.findByID(t);if(!n){console.log("[downloadDataByQueryID] query not found");return}const{name:r,data:a}=n;gS(r,a)},refetchDataByQueryID(t){const n=e.findByID(t);if(!n){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return n.fetchData()}}));function SS(e){return{current:e}}const _S=Y1.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!b.getParent(e,2).findByKey(t)}})),kl=b.types.model("SQLSnippetsRenderModel",{current:b.types.optional(b.types.array(_S),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,n)=>(t[n.key]=n.value,t),{})},get firstKey(){if(e.current.length!==0)return e.current[0].key},findByKey(t){return e.current.find(n=>n.key===t)}}));function kS(e){return{current:e}}function lr(e,t,n,r){return e.reduce((a,o)=>{try{a[o[t]]=vr(o[n],r)}catch(l){a[o[t]]=l.message}return a},{})}class TS{constructor(t){N(this,"origin");N(this,"copy");this.origin=t,this.copy=b.clone(t),te.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!x.isEqual(b.getSnapshot(this.origin),b.getSnapshot(this.copy))}commit(){b.applySnapshot(this.origin,b.getSnapshot(this.copy))}update(t){b.applySnapshot(this.copy,t)}}const DS=e=>new TS(e),IS=k.observer(({view:e})=>{const t=ce(),n=le(),r=Re.useModals(),{panel:a,downloadPanelScreenshot:o}=st(),{id:l}=a,{viewPanelInFullScreen:u,inFullScreen:c}=y.useContext(sr),d=()=>{n.duplicatePanelByID(l,e.id)},f=()=>{t.editor.open(["_VIEWS_",e.id,"_PANELS_",l])},h=()=>r.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>n.removePanelByID(l,e.id),confirmProps:{color:"red"},zIndex:320}),g=y.useCallback(()=>{u(l)},[l,u]),m=!c&&e.type!==j.Modal;return i(B,{children:i(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(s.Menu,{withinPortal:!0,children:[i(s.Menu.Target,{children:i(s.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),p(s.Menu.Dropdown,{children:[i(s.Menu.Item,{onClick:a.refreshData,icon:i(T.Refresh,{size:14}),children:"Refresh"}),i(s.Menu.Item,{onClick:a.downloadData,icon:i(T.Download,{size:14}),children:"Download Data"}),i(s.Menu.Item,{onClick:o,icon:i($.IconCamera,{size:14}),children:"Screenshot"}),m&&i(s.Menu.Item,{onClick:g,icon:i(T.ArrowsMaximize,{size:14}),disabled:!0,children:"Full Screen"}),i(s.Divider,{label:"Edit",labelPosition:"center"}),i(s.Menu.Item,{onClick:f,icon:i(T.Settings,{size:14}),children:"Settings"}),i(s.Menu.Item,{onClick:d,icon:i(T.Copy,{size:14}),children:"Duplicate"}),i(s.Menu.Item,{color:"red",onClick:h,icon:i(T.Trash,{size:14}),children:"Delete"})]})]})})})});function MS(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const $i=k.observer(()=>{const[e,t]=y.useState(!1),{panel:n}=Ct();return MS(n.description)?null:p(B,{children:[i(s.Modal,{opened:e,onClose:()=>t(!1),title:n.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:i(Rn,{value:n.description,styles:{root:{border:"none"},content:{padding:0}}})}),i(s.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:i(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>t(r=>!r),sx:{verticalAlign:"baseline",cursor:"pointer"},children:i(T.InfoCircle,{size:20})})})]})}),dM="",AS=k.observer(function(){const{panel:t}=Ct(),{title:n}=t;return n?i(s.Group,{grow:!0,position:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:i(s.Text,{align:"center",lineClamp:1,className:"panel-title-text",children:n})}):null});function zS(e){const t=y.useRef(null);return{ref:t,downloadPanelScreenshot:()=>{const r=t.current;if(!r)return;const a=r.offsetWidth*2,o=r.offsetHeight*2;Ja.toBlob(t.current,{bgcolor:"white",width:a,height:o,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(l=>{window.saveAs(l,`${e.title?e.title:e.viz.type}.png`)})}}}var Tl=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(Tl||{}),ur=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(ur||{});class ES{constructor(t){N(this,"vizInstance");N(this,"operationManager");N(this,"triggerManager");N(this,"vizManager");N(this,"runningMigration");N(this,"panelModel");N(this,"status","notStarted");this.panelModel=t.getRequired(Ce.instanceScope.panelModel),this.vizInstance=t.getRequired(Ce.instanceScope.vizInstance),this.operationManager=t.getRequired(Ce.instanceScope.operationManager),this.triggerManager=t.getRequired(Ce.instanceScope.triggerManager),this.vizManager=t.getRequired(Ce.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(n){return console.warn("check migration failed",n),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(n=>n())),"migrated"}catch(n){return console.warn("migration failed",n),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(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),n={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(n)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData};return t.migrator.needMigration(n)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function Dl(e){const{panel:t}=Ct();return y.useCallback(n=>{const r=n.getRequired(Ce.vizManager),a=r.resolveComponent(e.viz.type);return n.createScoped().provideFactory(Ce.instanceScope.vizInstance,()=>r.getOrCreateInstance(e)).provideFactory(Ce.instanceScope.interactionManager,o=>{const l=o.getRequired(Ce.instanceScope.vizInstance);return new Er(l,a,En)}).provideFactory(Ce.instanceScope.operationManager,o=>o.getRequired(Ce.instanceScope.interactionManager).operationManager).provideFactory(Ce.instanceScope.triggerManager,o=>o.getRequired(Ce.instanceScope.interactionManager).triggerManager).provideValue(Ce.instanceScope.panelModel,t).provideFactory(Ce.instanceScope.migrator,o=>new ES(o))},[e.viz.type,e.viz.conf])}function Il(e){const[t,n]=y.useState(!1),r=Uo().getRequired(Ce.instanceScope.migrator);return K.useAsyncEffect(async()=>{const a=r.status===ur.notStarted;n(r.status===ur.done),r.status===ur.notStarted&&r.runMigration().then(o=>{o===Tl.migrated&&a&&(e==null||e())}).finally(()=>{n(!0)})},[r]),t}function Ml(e,t){const n=Uo().getRequired(Ce.instanceScope.vizInstance);return y.useEffect(()=>(n.instanceData.setItem(null,t.viz.conf),n.instanceData.watchItem(null,r=>{e(r)})),[e,t.viz.type]),n}function $S({setVizConf:e,...t}){const{panel:n}=t,r=Ml(e,n),a=Il(()=>{_n.showNotification({title:`${n.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return K.useAsyncEffect(async()=>{await r.instanceData.setItem(null,n.viz.conf)},[r,n.viz.type]),a?i(nc,{...t}):i(s.Text,{children:"Checking update..."})}function LS(e){const{panel:t,setVizConf:n}=e;Ml(n,t);const{inEditMode:r}=y.useContext(An);return Il(()=>{r&&_n.showNotification({title:`${t.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?i(tc,{...e}):i(s.Text,{children:"Checking update"})}const pM="";function OS(e,t){const{vizManager:n}=y.useContext(ht),{panel:{viz:r,title:a,id:o,description:l,queryIDs:u,variables:c}}=Ct(),d={title:a,id:o,description:l,queryIDs:u,viz:r,layout:t},f=Dl(d);try{return n.resolveComponent(r.type),i(ar,{configure:f,children:i(LS,{setVizConf:r.setConf,panel:d,data:e,variables:c,vizManager:n})})}catch(h){return console.info(x.get(h,"message")),null}}const Al=k.observer(function({data:t}){const{ref:n,width:r,height:a}=Ie.useElementSize(),o=OS(t,{w:r,h:a}),l=r>0&&a>0;return i("div",{className:"viz-root",ref:n,children:i(s.Box,{sx:{width:r,height:a,overflow:"hidden"},children:l&&i(We,{children:o})})})}),zl=k.observer(({panel:e})=>p(s.Stack,{children:[e.queryErrors.map((t,n)=>i(s.Text,{color:"red",size:"sm",align:"center",sx:{fontFamily:"monospace"},children:t},`${n}-${t}`)),i(s.Text,{color:"gray",align:"center",size:"sm",children:e.queryStateMessages})]})),Li=k.observer(({panel:e})=>p(s.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[i(s.LoadingOverlay,{visible:e.dataLoading,exitTransitionDuration:0}),!e.canRenderViz&&i(zl,{panel:e}),e.canRenderViz&&i(Al,{data:e.data})]})),PS={border:"1px solid #e9ecef"},El=k.observer(({panel:e,panelStyle:t,dropdownContent:n})=>{const{ref:r,downloadPanelScreenshot:a}=zS(e),o=!!e.title,l=o?"60px":"28px";return e.title&&`${l}`,i(Ir,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:a},children:p(s.Box,{className:`panel-root ${o?"panel-root--show-title":""}`,ref:r,p:0,sx:{...PS,...t},children:[i(s.Box,{className:"panel-description-popover-wrapper",children:i($i,{})}),n,i(AS,{}),i(Li,{panel:e})]})})}),BS={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function VS(e){return e.style.border.enabled?{}:BS}const $l=k.observer(function({panel:t,view:n}){const r=VS(t);return i(El,{panel:t,panelStyle:r,dropdownContent:i(IS,{view:n})})});function NS(e){return!["richText","button"].includes(e)}const qS=k.observer(({view:e})=>{const{panel:t,downloadPanelScreenshot:n}=Ct(),{id:r}=t,{viewPanelInFullScreen:a,inFullScreen:o}=y.useContext(sr),l=y.useCallback(()=>{a(r)},[r,a]),u=!o&&e.type!==j.Modal;return NS(t.viz.type)?i(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(s.Menu,{withinPortal:!0,children:[i(s.Menu.Target,{children:i(s.Box,{className:"panel-dropdown-target"})}),p(s.Menu.Dropdown,{children:[i(s.Menu.Item,{onClick:t.refreshData,icon:i(T.Refresh,{size:14}),children:"Refresh"}),i(s.Menu.Item,{onClick:t.downloadData,icon:i(T.Download,{size:14}),children:"Download Data"}),i(s.Menu.Item,{onClick:n,icon:i($.IconCamera,{size:14}),children:"Screenshot"}),u&&i(s.Menu.Item,{onClick:l,icon:i(T.ArrowsMaximize,{size:14}),children:"Full Screen"})]})]})}):null});function FS(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const Oi=k.observer(({panel:e,view:t})=>{const n=FS(e);return i(El,{panel:e,panelStyle:n,dropdownContent:i(qS,{view:t})})}),GS={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},Ll=k.observer(function({view:t,panel:n,exitFullScreen:r}){return i(s.Modal,{opened:!0,fullScreen:!0,onClose:r,title:i(s.Button,{color:"blue",size:"xs",onClick:r,leftIcon:i(T.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:GS,children:i(s.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:i(Oi,{view:t,panel:n})})})});function Ol(e,t,n){const{panels:r}=we(),a=e.id==="Main",[o,l]=y.useState(()=>a&&r.findByID(t)?t:null),u=y.useCallback(h=>{l(h),a&&n(h)},[a,n]),c=y.useCallback(()=>{l(null),a&&n("")},[a,n]),d=o?r.findByID(o):null;return{viewPanelInFullScreen:u,exitFullScreen:c,inFullScreen:!!d,fullScreenPanel:d}}const hM="",WS=y.forwardRef(({h:e},t)=>i(s.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:i(T.ArrowsMove,{size:16})})),jS=y.forwardRef(({handleAxis:e,...t},n)=>i(s.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:i(T.ChevronDownRight,{size:16})})),RS=kn.WidthProvider(kn),YS=k.observer(({view:e,className:t="layout"})=>{const n=we(),{panels:r,layouts:a}=n.panels.panelsByIDs(e.panelIDs),o=y.useCallback(u=>{u.forEach(({i:c,...d})=>{const f=n.panels.findByID(c);f&&f.layout.set(d)})},[n]),l=(u,c,d,f)=>{d.h<30&&(d.h=30,f.h=30),d.w<4&&(d.w=4,f.w=4)};return i(RS,{onLayoutChange:o,className:`dashboard-layout ${t}`,rowHeight:1,cols:36,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,layout:a,draggableHandle:".react-grid-customDragHandle",resizeHandle:i(jS,{}),onResize:l,children:r.map((u,c)=>p("div",{"data-grid":{...u.layout},className:"panel-grid-item",children:[i(WS,{h:u.layout.h}),i($l,{view:e,panel:u})]},u.id))})}),QS=kn.WidthProvider(kn),US=k.observer(function({view:t,className:n="layout"}){const{panels:r,layouts:a}=we().panels.panelsByIDs(t.panelIDs);return i(QS,{className:`dashboard-layout ${n}`,cols:36,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,layout:a,children:r.map(o=>i("div",{"data-grid":{...o.layout},className:"panel-grid-item",children:i(Oi,{view:t,panel:o})},o.id))})});function Pi(e){const t=y.useRef(null);return{ref:t,downloadScreenshot:()=>{var l;const r=(l=t.current)==null?void 0:l.querySelector(".react-grid-layout");if(!r)return;const a=r.offsetWidth*2+10,o=r.offsetHeight*2+10;Ja.toBlob(r,{bgcolor:"white",width:a,height:o,style:{transformOrigin:"0 0",transform:"scale(2)"}}).then(u=>{window.saveAs(u,`${e.name}.png`)})}}}const KS=k.observer(({downloadScreenShot:e})=>{const[t,{setTrue:n,setFalse:r}]=K.useBoolean(!1),a=Tr(),o=we(),l=()=>{const u=JSON.stringify(o.json,null,2),c=`${a.name}__${o.name}`;Sl(c,u)};return p(s.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[i(s.Menu.Target,{children:i(s.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:i(s.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:n,onMouseLeave:r,sx:{opacity:t?1:.6,transform:`translateX(${t?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:i($.IconShare3,{size:"1rem"})})})}),p(s.Menu.Dropdown,{children:[i(s.Menu.Item,{icon:i($.IconCamera,{size:14}),onClick:e,children:"Screenshot"}),i(s.Menu.Divider,{}),i(s.Menu.Item,{icon:i($.IconDownload,{size:14}),onClick:o.queries.downloadAllData,children:"Download Data"}),i(s.Menu.Item,{icon:i($.IconCode,{size:14}),onClick:l,children:"Download Schema"})]})]})}),Pl=k.observer(({children:e,view:t,sx:n={}})=>{const{ref:r,downloadScreenshot:a}=Pi(t);return p(B,{children:[i(s.Box,{ref:r,sx:n,children:e}),i(KS,{downloadScreenShot:a})]})}),Bl=k.observer(({downloadScreenshot:e})=>i(s.ActionIcon,{className:"download-screenshot-button",color:"blue",onClick:e,children:i($.IconCamera,{size:14})})),XS=k.observer(({children:e,view:t})=>{const n=we(),r=t.config,a=n.views.visibleViewIDs.includes(t.id),o=()=>n.views.rmVisibleViewID(t.id),{ref:l,downloadScreenshot:u}=Pi(t);return i(s.Modal,{size:r.width,centered:!0,opened:a,onClose:o,withCloseButton:!1,title:p(s.Group,{position:"apart",px:"1rem",h:"48px",children:[i(s.Box,{children:r.custom_modal_title.value}),i(Bl,{downloadScreenshot:u})]}),trapFocus:!0,onDragStart:c=>{c.stopPropagation()},styles:{root:{position:"fixed",zIndex:200,inset:0},overlay:{zIndex:"unset"},inner:{zIndex:"unset",padding:"0 !important"},content:{border:"1px solid #efefef",maxHeight:"unset !important",overflow:"hidden"},body:{maxHeight:r.height,overflow:"auto",position:"relative"},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:i(s.Box,{ref:l,children:e})})}),JS=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},ZS=k.observer(({view:e})=>{const t=we(),n=e.config;return p(s.Tabs,{className:"render-view-tabs",variant:n.variant,orientation:n.orientation,value:e.tab,onTabChange:e.setTab,styles:{root:{height:"100%",overflow:n.orientation==="horizontal"?"hidden":"auto"},panel:{padding:n.orientation==="horizontal"?"8px 0px 8px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[i(s.Tabs.List,{grow:n.grow,children:n.tabs.map(r=>i(s.Tabs.Tab,{value:r.id,sx:JS(r),disabled:!r.view_id,children:r.name??r.id},r.id))}),n.tabs.map(r=>{const a=t.views.findByID(r.view_id);return a?i(s.Tabs.Panel,{value:r.id,children:i(cr,{view:a})},r.id):null})]})}),HS=k.observer(({view:e,children:t})=>{switch(e.type){case j.Modal:return i(XS,{view:e,children:t});case j.Tabs:return i(ZS,{view:e});case j.Division:default:return i(Pl,{view:e,children:t})}}),e_=k.observer(({children:e,view:t})=>i(Pl,{sx:{paddingTop:"10px",paddingBottom:"100px"},view:t,children:e}));function Vl(e){return e.replace(/(vw|vh)/,"%")}const t_=k.observer(({children:e,view:t})=>{const n=t.config,{width:r,height:a}=y.useMemo(()=>({width:Vl(n.width),height:Vl(n.height)}),[n.width,n.height]),{ref:o,downloadScreenshot:l}=Pi(t);return i(s.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:i(s.Modal,{size:n.width,opened:!0,onClose:x.noop,withCloseButton:!1,title:p(s.Group,{position:"apart",px:"1rem",h:"48px",children:[i(s.Box,{children:n.custom_modal_title.value}),i(Bl,{downloadScreenshot:l})]}),trapFocus:!0,onDragStart:u=>{u.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},inner:{position:"relative",top:"50%",left:"50%",right:"unset",bottom:"unset",transform:"translate(-50%, -50%)",padding:"0 !important",width:r,height:a,maxHeight:a},content:{border:"1px solid #efefef",height:"100%"},body:{maxHeight:"calc(100% - 48px)",overflow:"auto"},header:{padding:0},title:{flexGrow:1}},withinPortal:!1,transitionProps:{duration:0},children:i(s.Box,{ref:o,children:e})})})}),n_=({variant:e,orientation:t})=>{const n={root:{height:"100%",overflow:"hidden"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(n.tab.paddingTop="6px",n.tab.paddingBottom="6px"),t==="vertical"&&(n.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},n.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),n},r_=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},i_=k.observer(({view:e})=>{const t=Re.useModals(),n=le(),r=y.useMemo(()=>n.views.options.filter(u=>u.type===j.Division),[e.id,n.views.options]),a=e.config,o=u=>t.openConfirmModal({title:"Delete this tab?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{a.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),l=a.tabs.length===0;return p(s.Tabs,{className:"preview-view-tabs",variant:a.variant,orientation:a.orientation,value:e.tab,onTabChange:e.setTab,styles:n_(a),children:[p(s.Tabs.List,{grow:a.grow,children:[a.tabs.map(u=>i(s.Tabs.Tab,{value:u.id,sx:r_(u),children:u.name??u.id},u.id)),i(s.Tabs.Tab,{onClick:a.addTab,value:"add",className:"add-a-tab",children:i(T.Plus,{size:18,color:"#228be6"})})]}),a.tabs.map((u,c)=>{const d=n.views.findByID(u.view_id);return p(s.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[p(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[i(s.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),p(s.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[i(s.TextInput,{label:"Tab Name",value:u.name,onChange:f=>u.setName(f.currentTarget.value)}),i(s.Select,{label:"View",value:u.view_id,onChange:u.setViewID,data:r}),i(s.ColorInput,{label:"Color",value:u.color,onChange:u.setColor,disabled:a.variant!=="default"}),d&&p(s.Button,{mt:20,variant:"gradient",leftIcon:i($.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>n.views.setIDOfVIE(d.id),children:["Swith to View: ",d.name]}),i(s.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>o(c),disabled:l,leftIcon:i($.IconTrash,{size:14}),children:"Delete This Tab"})]})]}),d&&i(cr,{view:d})]},u.id)})]})}),a_=k.observer(({view:e,children:t})=>{switch(e.type){case j.Modal:return i(t_,{view:e,children:t});case j.Tabs:return i(i_,{view:e});case j.Division:default:return i(e_,{view:e,children:t})}}),Nl=k.observer(function({view:t}){return i(sr.Provider,{value:{viewPanelInFullScreen:x.noop,inFullScreen:!1},children:i(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:i(a_,{view:t,children:p(s.Box,{sx:{position:"relative"},children:[i(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:i(Jo,{view:t})}),i(YS,{view:t})]})})})})}),cr=k.observer(function({view:t}){const{fullScreenPanelID:n,setFullScreenPanelID:r}=ds(),{viewPanelInFullScreen:a,exitFullScreen:o,inFullScreen:l,fullScreenPanel:u}=Ol(t,n,r);return i(sr.Provider,{value:{viewPanelInFullScreen:a,inFullScreen:l},children:p(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===j.Modal?"0 !important":"100%"},children:[l&&i(Ll,{view:t,panel:u,exitFullScreen:o}),i(HS,{view:t,children:p(s.Box,{sx:{position:"relative"},children:[!l&&i(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:i(Jo,{view:t})}),!l&&i(US,{view:t})]})})]})})});var ql=(e=>(e.Use="use",e.Edit="edit",e))(ql||{});const s_={[j.Division]:"Division",[j.Tabs]:"Tabs",[j.Modal]:"Modal"},Fl={[j.Division]:"rgba(255, 0, 0, 0.2)",[j.Modal]:"rgba(0, 0, 0, 0.2)",[j.Tabs]:"rgba(255, 200, 100, 0.4)"},o_={[j.Division]:"#ff4000",[j.Modal]:"#000",[j.Tabs]:"#ffad18"},l_={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:j.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:"9.19.0"};function u_(e,t,n){b.addDisposer(e,b.addMiddleware(e,(r,a)=>{a(r,()=>{b.getType(r.context)===t&&r.type==="action"&&n(r.name,r.context)})}))}const Gl=b.types.compose("FiltersModel",vl,b.types.model("FiltersModel",{previewValues:b.types.optional(b.types.frozen(),{})})).views(e=>({get options(){return e.current.map(t=>({label:t.label??t.id,value:t.id,_type:"filter"}))},get selects(){return e.current.filter(t=>t.type===_e.Select).map(t=>({label:t.label??t.id,value:t.id}))},get keyLabelOptions(){return e.current.map(t=>({label:t.label??t.key,value:t.key}))}})).actions(e=>({replace(t){e.current=b.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(r=>r.id===t);n>=0&&e.current.splice(n,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){u_(e.current,ll,(n,r)=>{if(n==="setType"){const a=bl(r.config.default_value,r.config);e.setValueByKey(r.key,a),e.updatePreviewValues({...e.previewValues,[r.key]:a})}})}return{afterCreate(){t()}}}),Wl=_l.views(e=>({get options(){const t=e.current.map(n=>({value:n.id,label:n.name,_type:"query"}));return x.sortBy(t,n=>n.label.toLowerCase())},get sortedList(){return x.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=b.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},removeQuery(t){const n=e.current.find(r=>r.id===t);n&&(b.detach(n),e.current.remove(n))},removeQueries(t){const n=new Set(t);e.current.forEach(a=>{n.has(a.id)&&b.detach(a)});const r=[...e.current];x.remove(r,a=>n.has(a.id)),e.current=b.cast(r)}})),jl=kl.views(e=>({get sortedList(){return x.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(n=>({label:n.key,value:n.key,_type:"sql_snippet"}));return x.sortBy(t,n=>n.label.toLowerCase())}})).actions(e=>({replace(t){e.current=b.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByKey(t){const n=e.current.findIndex(r=>r.key===t);n>=0&&e.current.splice(n,1)},removeByKeys(t){const n=new Set(t);e.current.forEach(a=>{n.has(a.key)&&b.detach(a)});const r=[...e.current];x.remove(r,a=>n.has(a.key)),e.current=b.cast(r)},replaceByIndex(t,n){e.current.splice(t,1,n)}})),c_=b.types.model({data:b.types.optional(b.types.frozen(),[]),state:b.types.optional(b.types.enumeration(["idle","loading","error"]),"idle"),error:b.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0},get sql(){const t=b.getParent(e,1),{type:n,table_name:r,table_schema:a}=t;if(n===Se.MySQL)return`
|
|
440
|
+
`)},cl=b.types.model("ViewModalConfig",{_name:b.types.literal(j.Modal),width:b.types.string,height:b.types.string,custom_modal_title:b.types.optional(rS,zi)}).views(e=>({get json(){const{_name:t,width:n,height:r,custom_modal_title:a}=e;return{_name:t,width:n,height:r,custom_modal_title:a.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),iS=()=>cl.create({_name:j.Modal,width:"90vw",height:"90vh"}),aS=b.types.model("ViewTabsTabModel",{id:b.types.identifier,name:b.types.string,view_id:b.types.string,color:b.types.optional(b.types.string,"")}).views(e=>({get json(){const{id:t,name:n,view_id:r,color:a}=e;return{id:t,name:n,color:a,view_id:r}}})).actions(e=>({setName(t){e.name=t},setViewID(t){e.view_id=t},setColor(t){e.color=t}})),dl=b.types.model("ViewTabsConfig",{_name:b.types.literal(j.Modal),tabs:b.types.optional(b.types.array(aS),[]),variant:b.types.optional(b.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:b.types.optional(b.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:b.types.optional(b.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:n,orientation:r,tabs:a,grow:o}=e;return{grow:o,tabs:a.map(l=>l.json),_name:t,variant:n,orientation:r}}})).actions(e=>({setVariant(t){e.variant=t},setOrientation(t){e.orientation=t},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=b.cast(t)},addTab(){const t=Ie.randomId(),n={id:t,name:t,view_id:""};e.tabs.push(n)},removeTab(t){e.tabs.splice(t,1)}})),sS=()=>dl.create({_name:j.Modal,tabs:[]}),oS=b.types.model({id:b.types.identifier,name:b.types.string,type:b.types.enumeration("EViewComponentType",[j.Division,j.Modal,j.Tabs]),config:b.types.union(ul,cl,dl),panelIDs:b.types.optional(b.types.array(b.types.string),[])}).views(e=>({get json(){const{id:t,name:n,type:r,config:a}=e;return{id:t,name:n,type:r,config:a.json,panelIDs:e.panelIDs}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case j.Division:e.config=nS();break;case j.Modal:e.config=iS();break;case j.Tabs:e.config=sS();break}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},removePanelID(t){const n=e.panelIDs.filter(r=>r!==t);e.panelIDs.length=0,e.panelIDs.push(...n)}})),pl=b.types.model("DataSourceMetaModel",{id:b.types.string,type:b.types.enumeration("DataSourceType",[Se.HTTP,Se.MySQL,Se.Postgresql]),key:b.types.string,config:b.types.frozen()}),lS=b.types.model("DataSourcesMetaModel",{list:b.types.optional(b.types.array(pl),[])}).views(e=>({find({type:t,key:n}){return e.list.find(r=>r.key===n&&r.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),uS=b.types.model({id:b.types.string,content:b.types.string,create_time:b.types.string,update_time:b.types.string,is_preset:b.types.boolean}),hl=b.types.model("GlobalSQLSnippetsMeta",{list:b.types.optional(b.types.array(uS),[])}).views(e=>({find(t){return e.list.find(n=>n.id===t)},get options(){return e.list.map(t=>({value:t.id,label:t.id}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),Ei=b.types.model("ContextMeta",{current:b.types.optional(b.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function fl(e){return Ei.create({current:e})}const cS=b.types.compose("ViewRenderModel",oS,b.types.model({tab:b.types.optional(b.types.string,"")})).views(e=>({get defaultTab(){if(e.type!==j.Tabs)return"";const t=e.config;return t.tabs.length>0?t.tabs[0].id:""},get tabViewID(){var n;return e.type!==j.Tabs?"":((n=e.config.tabs.find(r=>r.id===e.tab))==null?void 0:n.view_id)??""},get contentModel(){return b.getParent(e,3)},get panels(){if(e.type!==j.Tabs)return this.contentModel.panels.panelsByIDs(e.panelIDs).panels;const t=this.tabViewID;return this.contentModel.views.findByID(t).panels},get renderViewIDs(){const t=[e.id];return e.type===j.Tabs&&t.push(this.tabViewID),t}})).actions(e=>({setTab(t){e.tab=t??""},afterCreate(){b.addDisposer(e,te.reaction(()=>e.defaultTab,t=>this.setTab(t),{fireImmediately:!0,delay:0}))}})),gl=b.types.model("ViewsRenderModel",{current:b.types.optional(b.types.array(cS),[]),visibleViewIDs:b.types.array(b.types.string)}).views(e=>({get json(){return e.current.map(t=>or(t.json))},get idMap(){const t=new Map;return e.current.forEach(n=>{t.set(n.id,n)}),t},findByID(t){return e.current.find(n=>n.id===t)},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:n})=>n===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:n})=>t.has(n))}})).actions(e=>({appendToVisibles(t){new Set(e.visibleViewIDs.map(r=>r)).has(t)||e.visibleViewIDs.push(t)},rmVisibleViewID(t){const n=e.visibleViewIDs.findIndex(r=>r===t);n!==-1&&e.visibleViewIDs.splice(n,1)}}));function dS(e){const t=e.length>0?[e[0].id]:[];return{current:e.map(r=>{const{_name:a=r.type}=r.config;return{...r,config:{...r.config,_name:a},panelIDs:r.panelIDs}}),visibleViewIDs:t}}const ml=j1.views(e=>({get contentModel(){return b.getRoot(e).content}})).views(e=>({get queries(){return e.contentModel.queries.findByIDSet(e.queryIDSet)},get data(){return this.queries.reduce((t,n)=>(t[n.id]=n.data,t),{})},get dataLoading(){return this.queries.some(t=>t.state==="loading")},get queryStateMessages(){const t=this.queries.filter(o=>!o.runByConditionsMet);if(t.length===0)return"";const n=new Set,r=new Set;t.forEach(o=>{const l=o.conditionNames;l.context.forEach(u=>n.add(u)),l.filters.forEach(u=>r.add(u))});const a=[];return n.size>0&&(console.log(n),a.push(`context: ${Array.from(n).join(", ")}`)),r.size>0&&a.push(`filter${r.size>1?"s":""}: ${Array.from(r).join(", ")}`),a.length===2&&a.splice(1,0,"and"),a.unshift("Waiting for"),a.join(" ")},get queryErrors(){return this.queries.map(t=>t.error).filter(t=>!!t)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages===""&&!this.dataLoading}})).actions(e=>({refreshData(){e.queries.forEach(t=>t.fetchData(!0))},downloadData(){b.getRoot(e).content.queries.downloadDataByQueryIDs(e.queryIDs)}}));function pS(e){return{id:e,layout:{x:0,y:1/0,w:18,h:300},title:e,description:"<p></p>",queryIDs:[],viz:{type:bi.name,conf:bi.createConfig()},style:{border:{enabled:!0}}}}const yl=b.types.model("PanelsRenderModel",{list:b.types.optional(b.types.array(ml),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(n=>n.id===t)},get idMap(){const t=new Map;return e.list.forEach(n=>{t.set(n.id,n)}),t}})).views(e=>({panelsByIDs(t){const n=[];t.forEach(a=>{const o=e.idMap.get(a);o?n.push(o):console.warn(`Panel is not found, id:${a}`)});const r=n.map(a=>({...a.layout.json,i:a.id}));return{panels:n,layouts:r}}}));function bl(e,t){if(e===void 0)return e;if(t._name==="date-range")try{const[...n]=e;return n.map(r=>r===null?r:Y.tz(r,"UTC").format(t.inputFormat)??r)}catch(n){return console.error(n),e}return e}function hS(e){return e.reduce((t,n)=>(t[n.key]=bl(n.config.default_value,n.config),t),{})}const vl=b.types.model("FiltersRenderModel",{current:b.types.optional(b.types.array(ll),[]),values:b.types.optional(b.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(n=>n.id===t)},get inOrder(){return x.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return x.sortBy(e.current.filter(n=>n.visibleInViewsIDSet.has(t)),"order")},get firstFilterValueKey(){return Object.keys(e.values)[0]??""},get keyLabelMap(){return e.current.reduce((t,n)=>(t[n.key]=n.label,t),{})},getSelectOption(t){const n=this.findByID(t);if(!n||!("getSelectOption"in n.config))return null;const r=e.values[n.key];return n.config.getSelectOption(r)}})).actions(e=>({setValues(t){e.values=t},setValueByKey(t,n){e.values={...e.values,[t]:n}},getValueByKey(t){return e.values[t]}}));function xl(e){return{current:e,values:hS(e)}}const fS=new Bu.AsyncParser({withBOM:!0});async function wl(e){return!Array.isArray(e)||e.length===0?"":await fS.parse(e).promise()}async function gS(e,t){const n=await wl(t),r=new Blob([n],{type:"text/csv"});br.saveAs(r,`${e}.csv`)}function Cl(e){const t=new Vu;e.forEach(({id:n,data:r})=>{t.file(`${n}.csv`,wl(r))}),t.generateAsync({type:"blob"}).then(n=>{br.saveAs(n,"dashboard_data.zip")})}function Sl(e,t){const n=new Blob([t],{type:"application/json"});br.saveAs(n,`${e}.json`)}const mS=R1.views(e=>({get conditionOptions(){if(!b.isAlive(e))return[];const t=b.getRoot(e).content,{context:n}=t.payloadForSQL,r=Object.keys(n).map(o=>({group:"Context",label:o,value:`context.${o}`,description:void 0})),a=t.filters.keyLabelOptions.map(o=>({group:"Filters",label:o.label,value:`filters.${o.value}`,description:o.value}));return[...r,...a]},get unmetRunByConditions(){if(!b.isAlive(e))return[];const{run_by:t}=e;if(t.length===0)return[];const n=b.getRoot(e).content.payloadForSQL;return t.filter(r=>{const a=x.get(n,r);return Array.isArray(a)?a.length===0:typeof a=="number"?Number.isNaN(a):!a})}})).views(e=>({get reQueryKey(){const{react_to:t=[]}=e;if(t.length===0)return"";const n=b.getRoot(e).content.payloadForSQL,r=[...t].reduce((a,o)=>(a[o]=x.get(n,o),a),{});return JSON.stringify(r)},get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=b.getRoot(e).content.filters,n=e.unmetRunByConditions.filter(a=>a.startsWith("context.")).map(a=>a.split("context.")[0]),r=e.unmetRunByConditions.filter(a=>a.startsWith("filters.")).map(a=>x.get({filters:t},a)).filter(a=>!!a);return{context:n,filters:r}},get queries(){return b.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)}}));function yS(e,t){return new Function(`return ${e}`)()(t,At)}function bS(e,t,n){return yS(e,{context:t,filters:n})}function vS(e,t){try{return new Function(`return ${e.config.processing.pre}`)()(t,At)}catch(n){return console.error(n),t}}function xS(e,t){return new Function(`return ${e.config.processing.post}`)()(t,At)}function wS(e,t){return e?new Function(`return ${e}`)()(t,At):t}const CS=b.types.compose("QueryRenderModel",mS,b.types.model({state:b.types.optional(b.types.enumeration(["idle","loading","error"]),"idle"),data:b.types.optional(b.types.frozen([]),[]),error:b.types.frozen()})).views(e=>({get rootModel(){return b.getRoot(e)},get contentModel(){return this.rootModel.content},get formattedSQL(){const t=this.contentModel.payloadForSQL;return xr(e.sql,t)},get typedAsSQL(){return[Se.Postgresql,Se.MySQL].includes(e.type)},get typedAsHTTP(){return[Se.HTTP].includes(e.type)},get datasource(){const{key:t,type:n}=e;return this.rootModel.datasources.find({type:n,key:t})},get httpConfigString(){const{context:t,filters:n}=this.contentModel.payloadForSQL,{name:r,pre_process:a}=e.json,o=bS(a,t,n);return console.groupCollapsed(`Request config for: ${r}`),console.log(o),console.groupEnd(),JSON.stringify(o)}})).views(e=>({get stateMessage(){if(e.state!=="idle")return"";if(!e.runByConditionsMet){const{context:t,filters:n}=e.conditionNames;if(t.length===0&&n.length===0)return"Waiting";const r=[];return t.length>0&&r.push(`context: ${t.join(", ")}`),n.length>0&&r.push(`filter${n.length>1?"s":""}: ${n.join(", ")}`),r.length===2&&r.splice(1,0,"and"),r.unshift("Waiting for"),r.join(" ")}return e.data.length>0?"":"Empty Data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:b.flow(function*(){var t;if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const n=e.contentModel.payloadForSQL;e.data=yield*b.toGenerator(Ju({payload:n,name:e.name,query:e.json},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(!xt.isCancel(n)){e.data=[];const r=x.get(n,"message","unkown error");e.error=x.get(n,"response.data.detail.message",r),e.state="error"}}}}),runHTTP:b.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{type:n,key:r,post_process:a}=e.json;let o=JSON.parse(e.httpConfigString);o=vS(e.datasource,o);const l=yield*b.toGenerator(Zu({type:n,key:r,configString:JSON.stringify(o),name:e.name},e.controller.signal));let u=xS(e.datasource,l);u=wS(a,u),e.data=u,e.state="idle",e.error=null}catch(n){if(console.error(n),!xt.isCancel(n)){e.data=[];const r=x.get(n,"message","unkown error");e.error=x.get(n,"response.data.detail.message",r),e.state="error"}}}})})).actions(e=>({fetchData:t=>{if(!e.inUse&&!t){console.debug(`Skipping query[${e.name}]`);return}return e.typedAsHTTP?e.runHTTP():e.runSQL()},beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){b.addDisposer(e,te.reaction(()=>{var n;return e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(n=e.datasource)==null?void 0:n.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},()=>e.fetchData(!1),{fireImmediately:!0,delay:0}))}})),_l=b.types.model("QueriesRenderModel",{current:b.types.optional(b.types.array(CS),[])}).views(e=>({get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},findByIDSet(t){return e.current.filter(n=>t.has(n.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get contentModel(){return b.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:n}=this.contentModel,r=[];t.visibleViews.forEach(l=>{l.panels.forEach(u=>{r.push(...u.queryIDs)})});const a=x.uniq(t.visibleViews.map(l=>l.renderViewIDs).flat());n.current.forEach(l=>{const u=x.get(l,"config.options_query_id");if(!u)return;a.some(d=>l.visibleInViewsIDSet.has(d))&&r.push(u)});const o=new Set(r);return console.debug("QueryIDs:",o),o},isQueryInUse(t){return this.visibleQueryIDSet.has(t)}})).actions(e=>({downloadAllData(){const t=e.current.map(({name:n,data:r})=>({id:n,data:r}));Cl(t)},downloadDataByQueryIDs(t){const n=new Set(t),r=e.current.filter(a=>n.has(a.id)).map(({name:a,data:o})=>({id:a,data:o}));Cl(r)},downloadDataByQueryID(t){const n=e.findByID(t);if(!n){console.log("[downloadDataByQueryID] query not found");return}const{name:r,data:a}=n;gS(r,a)},refetchDataByQueryID(t){const n=e.findByID(t);if(!n){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return n.fetchData(!0)}}));function SS(e){return{current:e}}const _S=Y1.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!b.getParent(e,2).findByKey(t)}})),kl=b.types.model("SQLSnippetsRenderModel",{current:b.types.optional(b.types.array(_S),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,n)=>(t[n.key]=n.value,t),{})},get firstKey(){if(e.current.length!==0)return e.current[0].key},findByKey(t){return e.current.find(n=>n.key===t)}}));function kS(e){return{current:e}}function lr(e,t,n,r){return e.reduce((a,o)=>{try{a[o[t]]=vr(o[n],r)}catch(l){a[o[t]]=l.message}return a},{})}class TS{constructor(t){N(this,"origin");N(this,"copy");this.origin=t,this.copy=b.clone(t),te.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!x.isEqual(b.getSnapshot(this.origin),b.getSnapshot(this.copy))}commit(){b.applySnapshot(this.origin,b.getSnapshot(this.copy))}update(t){b.applySnapshot(this.copy,t)}}const DS=e=>new TS(e),IS=k.observer(({view:e})=>{const t=ce(),n=le(),r=Re.useModals(),{panel:a,downloadPanelScreenshot:o}=st(),{id:l}=a,{viewPanelInFullScreen:u,inFullScreen:c}=y.useContext(sr),d=()=>{n.duplicatePanelByID(l,e.id)},f=()=>{t.editor.open(["_VIEWS_",e.id,"_PANELS_",l])},h=()=>r.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>n.removePanelByID(l,e.id),confirmProps:{color:"red"},zIndex:320}),g=y.useCallback(()=>{u(l)},[l,u]),m=!c&&e.type!==j.Modal;return i(B,{children:i(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(s.Menu,{withinPortal:!0,children:[i(s.Menu.Target,{children:i(s.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),p(s.Menu.Dropdown,{children:[i(s.Menu.Item,{onClick:a.refreshData,icon:i(T.Refresh,{size:14}),children:"Refresh"}),i(s.Menu.Item,{onClick:a.downloadData,icon:i(T.Download,{size:14}),children:"Download Data"}),i(s.Menu.Item,{onClick:o,icon:i($.IconCamera,{size:14}),children:"Screenshot"}),m&&i(s.Menu.Item,{onClick:g,icon:i(T.ArrowsMaximize,{size:14}),disabled:!0,children:"Full Screen"}),i(s.Divider,{label:"Edit",labelPosition:"center"}),i(s.Menu.Item,{onClick:f,icon:i(T.Settings,{size:14}),children:"Settings"}),i(s.Menu.Item,{onClick:d,icon:i(T.Copy,{size:14}),children:"Duplicate"}),i(s.Menu.Item,{color:"red",onClick:h,icon:i(T.Trash,{size:14}),children:"Delete"})]})]})})})});function MS(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const $i=k.observer(()=>{const[e,t]=y.useState(!1),{panel:n}=Ct();return MS(n.description)?null:p(B,{children:[i(s.Modal,{opened:e,onClose:()=>t(!1),title:n.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:i(Rn,{value:n.description,styles:{root:{border:"none"},content:{padding:0}}})}),i(s.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:i(s.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>t(r=>!r),sx:{verticalAlign:"baseline",cursor:"pointer"},children:i(T.InfoCircle,{size:20})})})]})}),dM="",AS=k.observer(function(){const{panel:t}=Ct(),{title:n}=t;return n?i(s.Group,{grow:!0,position:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:i(s.Text,{align:"center",lineClamp:1,className:"panel-title-text",children:n})}):null});function zS(e){const t=y.useRef(null);return{ref:t,downloadPanelScreenshot:()=>{const r=t.current;if(!r)return;const a=r.offsetWidth*2,o=r.offsetHeight*2;Ja.toBlob(t.current,{bgcolor:"white",width:a,height:o,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(l=>{window.saveAs(l,`${e.title?e.title:e.viz.type}.png`)})}}}var Tl=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(Tl||{}),ur=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(ur||{});class ES{constructor(t){N(this,"vizInstance");N(this,"operationManager");N(this,"triggerManager");N(this,"vizManager");N(this,"runningMigration");N(this,"panelModel");N(this,"status","notStarted");this.panelModel=t.getRequired(Ce.instanceScope.panelModel),this.vizInstance=t.getRequired(Ce.instanceScope.vizInstance),this.operationManager=t.getRequired(Ce.instanceScope.operationManager),this.triggerManager=t.getRequired(Ce.instanceScope.triggerManager),this.vizManager=t.getRequired(Ce.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(n){return console.warn("check migration failed",n),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(n=>n())),"migrated"}catch(n){return console.warn("migration failed",n),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(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),n={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(n)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData};return t.migrator.needMigration(n)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function Dl(e){const{panel:t}=Ct();return y.useCallback(n=>{const r=n.getRequired(Ce.vizManager),a=r.resolveComponent(e.viz.type);return n.createScoped().provideFactory(Ce.instanceScope.vizInstance,()=>r.getOrCreateInstance(e)).provideFactory(Ce.instanceScope.interactionManager,o=>{const l=o.getRequired(Ce.instanceScope.vizInstance);return new Er(l,a,En)}).provideFactory(Ce.instanceScope.operationManager,o=>o.getRequired(Ce.instanceScope.interactionManager).operationManager).provideFactory(Ce.instanceScope.triggerManager,o=>o.getRequired(Ce.instanceScope.interactionManager).triggerManager).provideValue(Ce.instanceScope.panelModel,t).provideFactory(Ce.instanceScope.migrator,o=>new ES(o))},[e.viz.type,e.viz.conf])}function Il(e){const[t,n]=y.useState(!1),r=Uo().getRequired(Ce.instanceScope.migrator);return K.useAsyncEffect(async()=>{const a=r.status===ur.notStarted;n(r.status===ur.done),r.status===ur.notStarted&&r.runMigration().then(o=>{o===Tl.migrated&&a&&(e==null||e())}).finally(()=>{n(!0)})},[r]),t}function Ml(e,t){const n=Uo().getRequired(Ce.instanceScope.vizInstance);return y.useEffect(()=>(n.instanceData.setItem(null,t.viz.conf),n.instanceData.watchItem(null,r=>{e(r)})),[e,t.viz.type]),n}function $S({setVizConf:e,...t}){const{panel:n}=t,r=Ml(e,n),a=Il(()=>{_n.showNotification({title:`${n.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return K.useAsyncEffect(async()=>{await r.instanceData.setItem(null,n.viz.conf)},[r,n.viz.type]),a?i(nc,{...t}):i(s.Text,{children:"Checking update..."})}function LS(e){const{panel:t,setVizConf:n}=e;Ml(n,t);const{inEditMode:r}=y.useContext(An);return Il(()=>{r&&_n.showNotification({title:`${t.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?i(tc,{...e}):i(s.Text,{children:"Checking update"})}const pM="";function OS(e,t){const{vizManager:n}=y.useContext(ht),{panel:{viz:r,title:a,id:o,description:l,queryIDs:u,variables:c}}=Ct(),d={title:a,id:o,description:l,queryIDs:u,viz:r,layout:t},f=Dl(d);try{return n.resolveComponent(r.type),i(ar,{configure:f,children:i(LS,{setVizConf:r.setConf,panel:d,data:e,variables:c,vizManager:n})})}catch(h){return console.info(x.get(h,"message")),null}}const Al=k.observer(function({data:t}){const{ref:n,width:r,height:a}=Ie.useElementSize(),o=OS(t,{w:r,h:a}),l=r>0&&a>0;return i("div",{className:"viz-root",ref:n,children:i(s.Box,{sx:{width:r,height:a,overflow:"hidden"},children:l&&i(We,{children:o})})})}),zl=k.observer(({panel:e})=>p(s.Stack,{children:[e.queryErrors.map((t,n)=>i(s.Text,{color:"red",size:"sm",align:"center",sx:{fontFamily:"monospace"},children:t},`${n}-${t}`)),i(s.Text,{color:"gray",align:"center",size:"sm",children:e.queryStateMessages})]})),Li=k.observer(({panel:e})=>p(s.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[i(s.LoadingOverlay,{visible:e.dataLoading,exitTransitionDuration:0}),!e.canRenderViz&&i(zl,{panel:e}),e.canRenderViz&&i(Al,{data:e.data})]})),PS={border:"1px solid #e9ecef"},El=k.observer(({panel:e,panelStyle:t,dropdownContent:n})=>{const{ref:r,downloadPanelScreenshot:a}=zS(e),o=!!e.title,l=o?"60px":"28px";return e.title&&`${l}`,i(Ir,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:a},children:p(s.Box,{className:`panel-root ${o?"panel-root--show-title":""}`,ref:r,p:0,sx:{...PS,...t},children:[i(s.Box,{className:"panel-description-popover-wrapper",children:i($i,{})}),n,i(AS,{}),i(Li,{panel:e})]})})}),BS={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function VS(e){return e.style.border.enabled?{}:BS}const $l=k.observer(function({panel:t,view:n}){const r=VS(t);return i(El,{panel:t,panelStyle:r,dropdownContent:i(IS,{view:n})})});function NS(e){return!["richText","button"].includes(e)}const qS=k.observer(({view:e})=>{const{panel:t,downloadPanelScreenshot:n}=Ct(),{id:r}=t,{viewPanelInFullScreen:a,inFullScreen:o}=y.useContext(sr),l=y.useCallback(()=>{a(r)},[r,a]),u=!o&&e.type!==j.Modal;return NS(t.viz.type)?i(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:p(s.Menu,{withinPortal:!0,children:[i(s.Menu.Target,{children:i(s.Box,{className:"panel-dropdown-target"})}),p(s.Menu.Dropdown,{children:[i(s.Menu.Item,{onClick:t.refreshData,icon:i(T.Refresh,{size:14}),children:"Refresh"}),i(s.Menu.Item,{onClick:t.downloadData,icon:i(T.Download,{size:14}),children:"Download Data"}),i(s.Menu.Item,{onClick:n,icon:i($.IconCamera,{size:14}),children:"Screenshot"}),u&&i(s.Menu.Item,{onClick:l,icon:i(T.ArrowsMaximize,{size:14}),children:"Full Screen"})]})]})}):null});function FS(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const Oi=k.observer(({panel:e,view:t})=>{const n=FS(e);return i(El,{panel:e,panelStyle:n,dropdownContent:i(qS,{view:t})})}),GS={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},Ll=k.observer(function({view:t,panel:n,exitFullScreen:r}){return i(s.Modal,{opened:!0,fullScreen:!0,onClose:r,title:i(s.Button,{color:"blue",size:"xs",onClick:r,leftIcon:i(T.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:GS,children:i(s.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:i(Oi,{view:t,panel:n})})})});function Ol(e,t,n){const{panels:r}=we(),a=e.id==="Main",[o,l]=y.useState(()=>a&&r.findByID(t)?t:null),u=y.useCallback(h=>{l(h),a&&n(h)},[a,n]),c=y.useCallback(()=>{l(null),a&&n("")},[a,n]),d=o?r.findByID(o):null;return{viewPanelInFullScreen:u,exitFullScreen:c,inFullScreen:!!d,fullScreenPanel:d}}const hM="",WS=y.forwardRef(({h:e},t)=>i(s.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:i(T.ArrowsMove,{size:16})})),jS=y.forwardRef(({handleAxis:e,...t},n)=>i(s.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:i(T.ChevronDownRight,{size:16})})),RS=kn.WidthProvider(kn),YS=k.observer(({view:e,className:t="layout"})=>{const n=we(),{panels:r,layouts:a}=n.panels.panelsByIDs(e.panelIDs),o=y.useCallback(u=>{u.forEach(({i:c,...d})=>{const f=n.panels.findByID(c);f&&f.layout.set(d)})},[n]),l=(u,c,d,f)=>{d.h<30&&(d.h=30,f.h=30),d.w<4&&(d.w=4,f.w=4)};return i(RS,{onLayoutChange:o,className:`dashboard-layout ${t}`,rowHeight:1,cols:36,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,layout:a,draggableHandle:".react-grid-customDragHandle",resizeHandle:i(jS,{}),onResize:l,children:r.map((u,c)=>p("div",{"data-grid":{...u.layout},className:"panel-grid-item",children:[i(WS,{h:u.layout.h}),i($l,{view:e,panel:u})]},u.id))})}),QS=kn.WidthProvider(kn),US=k.observer(function({view:t,className:n="layout"}){const{panels:r,layouts:a}=we().panels.panelsByIDs(t.panelIDs);return i(QS,{className:`dashboard-layout ${n}`,cols:36,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,layout:a,children:r.map(o=>i("div",{"data-grid":{...o.layout},className:"panel-grid-item",children:i(Oi,{view:t,panel:o})},o.id))})});function Pi(e){const t=y.useRef(null);return{ref:t,downloadScreenshot:()=>{var l;const r=(l=t.current)==null?void 0:l.querySelector(".react-grid-layout");if(!r)return;const a=r.offsetWidth*2+10,o=r.offsetHeight*2+10;Ja.toBlob(r,{bgcolor:"white",width:a,height:o,style:{transformOrigin:"0 0",transform:"scale(2)"}}).then(u=>{window.saveAs(u,`${e.name}.png`)})}}}const KS=k.observer(({downloadScreenShot:e})=>{const[t,{setTrue:n,setFalse:r}]=K.useBoolean(!1),a=Tr(),o=we(),l=()=>{const u=JSON.stringify(o.json,null,2),c=`${a.name}__${o.name}`;Sl(c,u)};return p(s.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[i(s.Menu.Target,{children:i(s.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:i(s.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:n,onMouseLeave:r,sx:{opacity:t?1:.6,transform:`translateX(${t?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:i($.IconShare3,{size:"1rem"})})})}),p(s.Menu.Dropdown,{children:[i(s.Menu.Item,{icon:i($.IconCamera,{size:14}),onClick:e,children:"Screenshot"}),i(s.Menu.Divider,{}),i(s.Menu.Item,{icon:i($.IconDownload,{size:14}),onClick:o.queries.downloadAllData,children:"Download Data"}),i(s.Menu.Item,{icon:i($.IconCode,{size:14}),onClick:l,children:"Download Schema"})]})]})}),Pl=k.observer(({children:e,view:t,sx:n={}})=>{const{ref:r,downloadScreenshot:a}=Pi(t);return p(B,{children:[i(s.Box,{ref:r,sx:n,children:e}),i(KS,{downloadScreenShot:a})]})}),Bl=k.observer(({downloadScreenshot:e})=>i(s.ActionIcon,{className:"download-screenshot-button",color:"blue",onClick:e,children:i($.IconCamera,{size:14})})),XS=k.observer(({children:e,view:t})=>{const n=we(),r=t.config,a=n.views.visibleViewIDs.includes(t.id),o=()=>n.views.rmVisibleViewID(t.id),{ref:l,downloadScreenshot:u}=Pi(t);return i(s.Modal,{size:r.width,centered:!0,opened:a,onClose:o,withCloseButton:!1,title:p(s.Group,{position:"apart",px:"1rem",h:"48px",children:[i(s.Box,{children:r.custom_modal_title.value}),i(Bl,{downloadScreenshot:u})]}),trapFocus:!0,onDragStart:c=>{c.stopPropagation()},styles:{root:{position:"fixed",zIndex:200,inset:0},overlay:{zIndex:"unset"},inner:{zIndex:"unset",padding:"0 !important"},content:{border:"1px solid #efefef",maxHeight:"unset !important",overflow:"hidden"},body:{maxHeight:r.height,overflow:"auto",position:"relative"},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:i(s.Box,{ref:l,children:e})})}),JS=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},ZS=k.observer(({view:e})=>{const t=we(),n=e.config;return p(s.Tabs,{className:"render-view-tabs",variant:n.variant,orientation:n.orientation,value:e.tab,onTabChange:e.setTab,styles:{root:{height:"100%",overflow:n.orientation==="horizontal"?"hidden":"auto"},panel:{padding:n.orientation==="horizontal"?"8px 0px 8px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[i(s.Tabs.List,{grow:n.grow,children:n.tabs.map(r=>i(s.Tabs.Tab,{value:r.id,sx:JS(r),disabled:!r.view_id,children:r.name??r.id},r.id))}),n.tabs.map(r=>{const a=t.views.findByID(r.view_id);return a?i(s.Tabs.Panel,{value:r.id,children:i(cr,{view:a})},r.id):null})]})}),HS=k.observer(({view:e,children:t})=>{switch(e.type){case j.Modal:return i(XS,{view:e,children:t});case j.Tabs:return i(ZS,{view:e});case j.Division:default:return i(Pl,{view:e,children:t})}}),e_=k.observer(({children:e,view:t})=>i(Pl,{sx:{paddingTop:"10px",paddingBottom:"100px"},view:t,children:e}));function Vl(e){return e.replace(/(vw|vh)/,"%")}const t_=k.observer(({children:e,view:t})=>{const n=t.config,{width:r,height:a}=y.useMemo(()=>({width:Vl(n.width),height:Vl(n.height)}),[n.width,n.height]),{ref:o,downloadScreenshot:l}=Pi(t);return i(s.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:i(s.Modal,{size:n.width,opened:!0,onClose:x.noop,withCloseButton:!1,title:p(s.Group,{position:"apart",px:"1rem",h:"48px",children:[i(s.Box,{children:n.custom_modal_title.value}),i(Bl,{downloadScreenshot:l})]}),trapFocus:!0,onDragStart:u=>{u.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},inner:{position:"relative",top:"50%",left:"50%",right:"unset",bottom:"unset",transform:"translate(-50%, -50%)",padding:"0 !important",width:r,height:a,maxHeight:a},content:{border:"1px solid #efefef",height:"100%"},body:{maxHeight:"calc(100% - 48px)",overflow:"auto"},header:{padding:0},title:{flexGrow:1}},withinPortal:!1,transitionProps:{duration:0},children:i(s.Box,{ref:o,children:e})})})}),n_=({variant:e,orientation:t})=>{const n={root:{height:"100%",overflow:"hidden"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(n.tab.paddingTop="6px",n.tab.paddingBottom="6px"),t==="vertical"&&(n.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},n.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),n},r_=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},i_=k.observer(({view:e})=>{const t=Re.useModals(),n=le(),r=y.useMemo(()=>n.views.options.filter(u=>u.type===j.Division),[e.id,n.views.options]),a=e.config,o=u=>t.openConfirmModal({title:"Delete this tab?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{a.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),l=a.tabs.length===0;return p(s.Tabs,{className:"preview-view-tabs",variant:a.variant,orientation:a.orientation,value:e.tab,onTabChange:e.setTab,styles:n_(a),children:[p(s.Tabs.List,{grow:a.grow,children:[a.tabs.map(u=>i(s.Tabs.Tab,{value:u.id,sx:r_(u),children:u.name??u.id},u.id)),i(s.Tabs.Tab,{onClick:a.addTab,value:"add",className:"add-a-tab",children:i(T.Plus,{size:18,color:"#228be6"})})]}),a.tabs.map((u,c)=>{const d=n.views.findByID(u.view_id);return p(s.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[p(s.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[i(s.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),p(s.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[i(s.TextInput,{label:"Tab Name",value:u.name,onChange:f=>u.setName(f.currentTarget.value)}),i(s.Select,{label:"View",value:u.view_id,onChange:u.setViewID,data:r}),i(s.ColorInput,{label:"Color",value:u.color,onChange:u.setColor,disabled:a.variant!=="default"}),d&&p(s.Button,{mt:20,variant:"gradient",leftIcon:i($.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>n.views.setIDOfVIE(d.id),children:["Swith to View: ",d.name]}),i(s.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>o(c),disabled:l,leftIcon:i($.IconTrash,{size:14}),children:"Delete This Tab"})]})]}),d&&i(cr,{view:d})]},u.id)})]})}),a_=k.observer(({view:e,children:t})=>{switch(e.type){case j.Modal:return i(t_,{view:e,children:t});case j.Tabs:return i(i_,{view:e});case j.Division:default:return i(e_,{view:e,children:t})}}),Nl=k.observer(function({view:t}){return i(sr.Provider,{value:{viewPanelInFullScreen:x.noop,inFullScreen:!1},children:i(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:i(a_,{view:t,children:p(s.Box,{sx:{position:"relative"},children:[i(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:i(Jo,{view:t})}),i(YS,{view:t})]})})})})}),cr=k.observer(function({view:t}){const{fullScreenPanelID:n,setFullScreenPanelID:r}=ds(),{viewPanelInFullScreen:a,exitFullScreen:o,inFullScreen:l,fullScreenPanel:u}=Ol(t,n,r);return i(sr.Provider,{value:{viewPanelInFullScreen:a,inFullScreen:l},children:p(s.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===j.Modal?"0 !important":"100%"},children:[l&&i(Ll,{view:t,panel:u,exitFullScreen:o}),i(HS,{view:t,children:p(s.Box,{sx:{position:"relative"},children:[!l&&i(s.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:i(Jo,{view:t})}),!l&&i(US,{view:t})]})})]})})});var ql=(e=>(e.Use="use",e.Edit="edit",e))(ql||{});const s_={[j.Division]:"Division",[j.Tabs]:"Tabs",[j.Modal]:"Modal"},Fl={[j.Division]:"rgba(255, 0, 0, 0.2)",[j.Modal]:"rgba(0, 0, 0, 0.2)",[j.Tabs]:"rgba(255, 200, 100, 0.4)"},o_={[j.Division]:"#ff4000",[j.Modal]:"#000",[j.Tabs]:"#ffad18"},l_={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:j.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:"9.19.0"};function u_(e,t,n){b.addDisposer(e,b.addMiddleware(e,(r,a)=>{a(r,()=>{b.getType(r.context)===t&&r.type==="action"&&n(r.name,r.context)})}))}const Gl=b.types.compose("FiltersModel",vl,b.types.model("FiltersModel",{previewValues:b.types.optional(b.types.frozen(),{})})).views(e=>({get options(){return e.current.map(t=>({label:t.label??t.id,value:t.id,_type:"filter"}))},get selects(){return e.current.filter(t=>t.type===_e.Select).map(t=>({label:t.label??t.id,value:t.id}))},get keyLabelOptions(){return e.current.map(t=>({label:t.label??t.key,value:t.key}))}})).actions(e=>({replace(t){e.current=b.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(r=>r.id===t);n>=0&&e.current.splice(n,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){u_(e.current,ll,(n,r)=>{if(n==="setType"){const a=bl(r.config.default_value,r.config);e.setValueByKey(r.key,a),e.updatePreviewValues({...e.previewValues,[r.key]:a})}})}return{afterCreate(){t()}}}),Wl=_l.views(e=>({get options(){const t=e.current.map(n=>({value:n.id,label:n.name,_type:"query"}));return x.sortBy(t,n=>n.label.toLowerCase())},get sortedList(){return x.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=b.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},removeQuery(t){const n=e.current.find(r=>r.id===t);n&&(b.detach(n),e.current.remove(n))},removeQueries(t){const n=new Set(t);e.current.forEach(a=>{n.has(a.id)&&b.detach(a)});const r=[...e.current];x.remove(r,a=>n.has(a.id)),e.current=b.cast(r)}})),jl=kl.views(e=>({get sortedList(){return x.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(n=>({label:n.key,value:n.key,_type:"sql_snippet"}));return x.sortBy(t,n=>n.label.toLowerCase())}})).actions(e=>({replace(t){e.current=b.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByKey(t){const n=e.current.findIndex(r=>r.key===t);n>=0&&e.current.splice(n,1)},removeByKeys(t){const n=new Set(t);e.current.forEach(a=>{n.has(a.key)&&b.detach(a)});const r=[...e.current];x.remove(r,a=>n.has(a.key)),e.current=b.cast(r)},replaceByIndex(t,n){e.current.splice(t,1,n)}})),c_=b.types.model({data:b.types.optional(b.types.frozen(),[]),state:b.types.optional(b.types.enumeration(["idle","loading","error"]),"idle"),error:b.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0},get sql(){const t=b.getParent(e,1),{type:n,table_name:r,table_schema:a}=t;if(n===Se.MySQL)return`
|
|
441
441
|
SELECT ordinal_position, column_key, column_name, column_type, is_nullable, column_default, column_comment
|
|
442
442
|
FROM information_schema.columns
|
|
443
443
|
WHERE table_name = '${r}' AND table_schema = '${a}'
|
|
@@ -1609,7 +1609,7 @@ export declare const PanelRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
1609
1609
|
runSQL: () => Promise<void>;
|
|
1610
1610
|
runHTTP: () => Promise<void>;
|
|
1611
1611
|
} & {
|
|
1612
|
-
fetchData: () => Promise<void
|
|
1612
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
1613
1613
|
beforeDestroy(): void;
|
|
1614
1614
|
} & {
|
|
1615
1615
|
afterCreate(): void;
|
|
@@ -1677,7 +1677,7 @@ export declare const PanelRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
1677
1677
|
runSQL: () => Promise<void>;
|
|
1678
1678
|
runHTTP: () => Promise<void>;
|
|
1679
1679
|
} & {
|
|
1680
|
-
fetchData: () => Promise<void
|
|
1680
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
1681
1681
|
beforeDestroy(): void;
|
|
1682
1682
|
} & {
|
|
1683
1683
|
afterCreate(): void;
|
|
@@ -1610,7 +1610,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
1610
1610
|
runSQL: () => Promise<void>;
|
|
1611
1611
|
runHTTP: () => Promise<void>;
|
|
1612
1612
|
} & {
|
|
1613
|
-
fetchData: () => Promise<void
|
|
1613
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
1614
1614
|
beforeDestroy(): void;
|
|
1615
1615
|
} & {
|
|
1616
1616
|
afterCreate(): void;
|
|
@@ -1678,7 +1678,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
1678
1678
|
runSQL: () => Promise<void>;
|
|
1679
1679
|
runHTTP: () => Promise<void>;
|
|
1680
1680
|
} & {
|
|
1681
|
-
fetchData: () => Promise<void
|
|
1681
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
1682
1682
|
beforeDestroy(): void;
|
|
1683
1683
|
} & {
|
|
1684
1684
|
afterCreate(): void;
|
|
@@ -3947,7 +3947,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
3947
3947
|
runSQL: () => Promise<void>;
|
|
3948
3948
|
runHTTP: () => Promise<void>;
|
|
3949
3949
|
} & {
|
|
3950
|
-
fetchData: () => Promise<void
|
|
3950
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
3951
3951
|
beforeDestroy(): void;
|
|
3952
3952
|
} & {
|
|
3953
3953
|
afterCreate(): void;
|
|
@@ -4015,7 +4015,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
4015
4015
|
runSQL: () => Promise<void>;
|
|
4016
4016
|
runHTTP: () => Promise<void>;
|
|
4017
4017
|
} & {
|
|
4018
|
-
fetchData: () => Promise<void
|
|
4018
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
4019
4019
|
beforeDestroy(): void;
|
|
4020
4020
|
} & {
|
|
4021
4021
|
afterCreate(): void;
|
|
@@ -5638,7 +5638,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
5638
5638
|
runSQL: () => Promise<void>;
|
|
5639
5639
|
runHTTP: () => Promise<void>;
|
|
5640
5640
|
} & {
|
|
5641
|
-
fetchData: () => Promise<void
|
|
5641
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
5642
5642
|
beforeDestroy(): void;
|
|
5643
5643
|
} & {
|
|
5644
5644
|
afterCreate(): void;
|
|
@@ -5706,7 +5706,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
5706
5706
|
runSQL: () => Promise<void>;
|
|
5707
5707
|
runHTTP: () => Promise<void>;
|
|
5708
5708
|
} & {
|
|
5709
|
-
fetchData: () => Promise<void
|
|
5709
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
5710
5710
|
beforeDestroy(): void;
|
|
5711
5711
|
} & {
|
|
5712
5712
|
afterCreate(): void;
|
|
@@ -7708,7 +7708,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
7708
7708
|
runSQL: () => Promise<void>;
|
|
7709
7709
|
runHTTP: () => Promise<void>;
|
|
7710
7710
|
} & {
|
|
7711
|
-
fetchData: () => Promise<void
|
|
7711
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
7712
7712
|
beforeDestroy(): void;
|
|
7713
7713
|
} & {
|
|
7714
7714
|
afterCreate(): void;
|
|
@@ -7776,7 +7776,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
7776
7776
|
runSQL: () => Promise<void>;
|
|
7777
7777
|
runHTTP: () => Promise<void>;
|
|
7778
7778
|
} & {
|
|
7779
|
-
fetchData: () => Promise<void
|
|
7779
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
7780
7780
|
beforeDestroy(): void;
|
|
7781
7781
|
} & {
|
|
7782
7782
|
afterCreate(): void;
|
|
@@ -9399,7 +9399,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
9399
9399
|
runSQL: () => Promise<void>;
|
|
9400
9400
|
runHTTP: () => Promise<void>;
|
|
9401
9401
|
} & {
|
|
9402
|
-
fetchData: () => Promise<void
|
|
9402
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
9403
9403
|
beforeDestroy(): void;
|
|
9404
9404
|
} & {
|
|
9405
9405
|
afterCreate(): void;
|
|
@@ -9467,7 +9467,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
9467
9467
|
runSQL: () => Promise<void>;
|
|
9468
9468
|
runHTTP: () => Promise<void>;
|
|
9469
9469
|
} & {
|
|
9470
|
-
fetchData: () => Promise<void
|
|
9470
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
9471
9471
|
beforeDestroy(): void;
|
|
9472
9472
|
} & {
|
|
9473
9473
|
afterCreate(): void;
|
|
@@ -11471,7 +11471,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
11471
11471
|
runSQL: () => Promise<void>;
|
|
11472
11472
|
runHTTP: () => Promise<void>;
|
|
11473
11473
|
} & {
|
|
11474
|
-
fetchData: () => Promise<void
|
|
11474
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
11475
11475
|
beforeDestroy(): void;
|
|
11476
11476
|
} & {
|
|
11477
11477
|
afterCreate(): void;
|
|
@@ -11539,7 +11539,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
11539
11539
|
runSQL: () => Promise<void>;
|
|
11540
11540
|
runHTTP: () => Promise<void>;
|
|
11541
11541
|
} & {
|
|
11542
|
-
fetchData: () => Promise<void
|
|
11542
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
11543
11543
|
beforeDestroy(): void;
|
|
11544
11544
|
} & {
|
|
11545
11545
|
afterCreate(): void;
|
|
@@ -13162,7 +13162,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
13162
13162
|
runSQL: () => Promise<void>;
|
|
13163
13163
|
runHTTP: () => Promise<void>;
|
|
13164
13164
|
} & {
|
|
13165
|
-
fetchData: () => Promise<void
|
|
13165
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
13166
13166
|
beforeDestroy(): void;
|
|
13167
13167
|
} & {
|
|
13168
13168
|
afterCreate(): void;
|
|
@@ -13230,7 +13230,7 @@ export declare const PanelsRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
13230
13230
|
runSQL: () => Promise<void>;
|
|
13231
13231
|
runHTTP: () => Promise<void>;
|
|
13232
13232
|
} & {
|
|
13233
|
-
fetchData: () => Promise<void
|
|
13233
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
13234
13234
|
beforeDestroy(): void;
|
|
13235
13235
|
} & {
|
|
13236
13236
|
afterCreate(): void;
|
|
@@ -65,7 +65,7 @@ export declare const QueriesRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
65
65
|
runSQL: () => Promise<void>;
|
|
66
66
|
runHTTP: () => Promise<void>;
|
|
67
67
|
} & {
|
|
68
|
-
fetchData: () => Promise<void
|
|
68
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
69
69
|
beforeDestroy(): void;
|
|
70
70
|
} & {
|
|
71
71
|
afterCreate(): void;
|
|
@@ -135,7 +135,7 @@ export declare const QueriesRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
135
135
|
runSQL: () => Promise<void>;
|
|
136
136
|
runHTTP: () => Promise<void>;
|
|
137
137
|
} & {
|
|
138
|
-
fetchData: () => Promise<void
|
|
138
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
139
139
|
beforeDestroy(): void;
|
|
140
140
|
} & {
|
|
141
141
|
afterCreate(): void;
|
|
@@ -203,7 +203,7 @@ export declare const QueriesRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
203
203
|
runSQL: () => Promise<void>;
|
|
204
204
|
runHTTP: () => Promise<void>;
|
|
205
205
|
} & {
|
|
206
|
-
fetchData: () => Promise<void
|
|
206
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
207
207
|
beforeDestroy(): void;
|
|
208
208
|
} & {
|
|
209
209
|
afterCreate(): void;
|
|
@@ -271,7 +271,7 @@ export declare const QueriesRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
271
271
|
runSQL: () => Promise<void>;
|
|
272
272
|
runHTTP: () => Promise<void>;
|
|
273
273
|
} & {
|
|
274
|
-
fetchData: () => Promise<void
|
|
274
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
275
275
|
beforeDestroy(): void;
|
|
276
276
|
} & {
|
|
277
277
|
afterCreate(): void;
|
|
@@ -339,7 +339,7 @@ export declare const QueriesRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
339
339
|
runSQL: () => Promise<void>;
|
|
340
340
|
runHTTP: () => Promise<void>;
|
|
341
341
|
} & {
|
|
342
|
-
fetchData: () => Promise<void
|
|
342
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
343
343
|
beforeDestroy(): void;
|
|
344
344
|
} & {
|
|
345
345
|
afterCreate(): void;
|
|
@@ -64,7 +64,7 @@ export declare const QueryRenderModel: import("mobx-state-tree").IModelType<{
|
|
|
64
64
|
runSQL: () => Promise<void>;
|
|
65
65
|
runHTTP: () => Promise<void>;
|
|
66
66
|
} & {
|
|
67
|
-
fetchData: () => Promise<void
|
|
67
|
+
fetchData: (force: boolean) => Promise<void> | undefined;
|
|
68
68
|
beforeDestroy(): void;
|
|
69
69
|
} & {
|
|
70
70
|
afterCreate(): void;
|