@devtable/dashboard 14.0.1 → 14.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dashboard.es.js +5 -4
- package/dist/dashboard.umd.js +2 -2
- package/dist/stats.html +1 -1
- package/dist/version.json +2 -2
- package/package.json +1 -1
package/dist/dashboard.es.js
CHANGED
|
@@ -6545,7 +6545,7 @@ class wl {
|
|
|
6545
6545
|
}), this.instanceRegistry.clear(), this.factoryRegistry.clear();
|
|
6546
6546
|
}
|
|
6547
6547
|
}
|
|
6548
|
-
const um = "14.0.
|
|
6548
|
+
const um = "14.0.2", C0 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
6549
6549
|
__proto__: null,
|
|
6550
6550
|
version: um
|
|
6551
6551
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
@@ -38085,9 +38085,10 @@ const xP = [{
|
|
|
38085
38085
|
const s = z(() => a.data.map((d) => ({
|
|
38086
38086
|
label: d.name,
|
|
38087
38087
|
value: d.id,
|
|
38088
|
-
description: d.description
|
|
38089
|
-
|
|
38090
|
-
|
|
38088
|
+
description: d.description,
|
|
38089
|
+
type: d.type
|
|
38090
|
+
})), [a.data]), o = fe((d, u) => {
|
|
38091
|
+
d && (i.selectMetric(d), t.setID(d), t.setType(u.type));
|
|
38091
38092
|
}, [i, t]), {
|
|
38092
38093
|
loading: l,
|
|
38093
38094
|
error: c
|
package/dist/dashboard.umd.js
CHANGED
|
@@ -89,7 +89,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
89
89
|
${Object.entries(t).map(([s,i])=>`const ${s} = '${i}';`).join(`
|
|
90
90
|
`)}
|
|
91
91
|
return ${e};
|
|
92
|
-
`)(r)}catch(s){return console.error(s),console.log(e),e}}function fs(e,t,r,s){const i=dy(t,s);return e.replaceAll(/(\{\{([^{\}]+(?=}))\}\})/g,(...l)=>{const c=l[2];if(!c)return c;const u=i[c];if(u)return u;const d=py(c);return hy(d,i,r)})}function gy(e,t){const r=wl.decode(t);r!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:r}),console.groupEnd())}async function fy({query:e,name:t,payload:r,additionals:s},i){if(!e.sql)return[];const{type:o,key:l,sql:c,pre_process:u,post_process:d}=e,p=Xs(c,r),h=tx({sql:p,pre_process:u}),x=wl.encode(h);gy(h,x);let b=await gt.query(i)({type:o,key:l,query:x,...s},{params:{name:t}});return b=nx(d,b,ma(r)),b}async function xy({type:e,key:t,configString:r,name:s,additionals:i},o){try{return await gt.httpDataSourceQuery(o)({type:e,key:t,query:r,...i},{params:{name:s}})}catch(l){if(pt.isCancel(l))throw l;return console.error(l),l}}async function my({key:e,configString:t,name:r,additionals:s},i){try{return await gt.mericoMetricQuery(i)({type:"merico_metric_system",key:e,query:t,...s},{params:{name:r}})}catch(o){throw o}}async function ba(){try{return(await gt.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function yd(){try{return(await gt.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class vd{constructor(t){N(this,"rootRef");this.rootRef=te.observable({current:t})}async deleteItem(t){te.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?te.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(v.isObject(r))te.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else te.runInAction(()=>{v.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,s){return te.reaction(()=>this.getValueFromRoot(t),(i,o)=>{r(i,o)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class by{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new Cl)}getChannel(t){const r=this.channels.get(t);if(r)return r;const s=new Cl;return this.channels.set(t,s),s}}class yy{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 r=this.instances.get(t.id);if(r)return r;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new by,instanceData:new vd(t.viz.conf)};return this.instances.set(t.id,s),s}}function _d(e,t,r,s){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new vd({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const vy=e=>{const{panel:t,measure:r,vizManager:s,data:i,variables:o}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={..._d(c,i,s,o),viewport:{width:r.w,height:r.h}},d=l.viewRender;return n.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},_y=e=>{const{vizManager:t,panel:r,data:s,variables:i}=e,o=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),c={..._d(l,s,t,i)},u=o.configRender;return n.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},jd=(e,t)=>{const r=kt.bezier(e),s=kt.bezier(t);return function(i){return i<50?r(i*2/100).hex():s((i-50)*2/100).hex()}},xs=e=>{const t=kt.bezier(e);return function(r){return t(r/100).hex()}},jy={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:jd(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},wy={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:jd(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Cy={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:xs(["#fff7f1","darkred"]),name:"red",category:"sequential"},Sy={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:xs(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ty={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:xs(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},ky={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:xs(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Dy{constructor(t){N(this,"symbol");this.symbol=Symbol(t)}}function Jt(e){return new Dy(e)}class ya{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const t=new ya;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const r=this.factoryRegistry.get(t.symbol);if(r){const s=r(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=v.get(t,"dispose");v.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const wd="14.0.1",zy=Object.freeze(Object.defineProperty({__proto__:null,version:wd},Symbol.toStringTag,{value:"Module"}));class Iy{constructor(t){N(this,"staticColors",new Map);N(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(r,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class My{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class Ey{constructor(){N(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,s){var l;if(t.from===t.to)return r;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),o=v.orderBy(i,"version","asc");if(((l=v.last(o))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((c,u)=>u.handler(c,s),r)}}class ke extends Ey{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(s,i)=>({version:t,...r(s,i)}))}async migrate({configData:t,panelModel:r}){const s=await t.getItem(null),i=v.get(s,"version",0),o=this.run({from:i,to:this.VERSION},s,{panelModel:r});await t.setItem(null,o)}async needMigration({configData:t}){const r=await t.getItem(null);return v.get(r,"version",0)<this.VERSION}}const R=(e,t)=>{const[r,{setFalse:s}]=Y.useBoolean(!0),[i,o]=f.useState();f.useEffect(()=>(e.getItem(t).then(c=>{o(c),s()}),e.watchItem(t,c=>{o(c)})));const l=f.useCallback(async c=>{await e.setItem(t,c),o(c)},[e,t]);return{loading:r,value:i,set:l}},st={top:16,right:16,bottom:16,left:16},Et=e=>Math.max(0,e-st.left-st.right),Pt=e=>Math.max(0,e-st.top-st.bottom),kr=(e,t)=>({width:Et(e),height:Pt(t)}),at=({width:e,height:t,children:r})=>n.jsx(a.Box,{pt:st.top,pr:st.right,pb:st.bottom,pl:st.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:r}),va={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function Py({context:e}){const{value:t}=R(e.instanceData,"config"),r=e.data,{width:s,height:i}=e.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=v.defaults({},t,va),h=f.useMemo(()=>qr(r,o),[r,o]),{x,y:b,z:m}=f.useMemo(()=>({x:O(o),y:O(l),z:O(c)}),[o,l,c]),{min:j,max:D}=f.useMemo(()=>{const z=v.minBy(h,M=>M[m.columnKey]),I=v.maxBy(h,M=>M[m.columnKey]);return{min:v.get(z,m.columnKey),max:v.get(I,m.columnKey)}},[h,m]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:j,max:D,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:p,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(z=>[z[x.columnKey],z[b.columnKey],z[m.columnKey]])}]};return t?n.jsx(at,{width:s,height:i,children:n.jsx(Qe,{echarts:Fe,option:T,style:kr(s,i),notMerge:!0,theme:"merico-light"})}):null}const W=k.observer(f.forwardRef(({label:e,required:t,description:r,value:s,onChange:i,queryID:o,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=Le(),h=f.useMemo(()=>p.dataFieldOptionGroups(s,l,o),[s,l,o]);if(h.length===0){const x=p.explainDataKey(s);return n.jsxs(a.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[n.jsx(a.HoverCard.Target,{children:n.jsx(a.Box,{children:n.jsx(a.TextInput,{label:e,required:t,defaultValue:x.columnKey,readOnly:!0,disabled:!0})})}),n.jsx(a.HoverCard.Dropdown,{children:n.jsxs(a.Group,{justify:"flex-start",gap:0,children:[n.jsx(a.Text,{size:"xs",c:x.queryName?"black":"red",ff:"monospace",children:x.queryName??x.queryID}),n.jsx(a.Text,{size:"xs",c:"black",ff:"monospace",children:"."}),n.jsx(a.Text,{size:"xs",c:"red",ff:"monospace",children:x.columnKey})]})})]})}return n.jsx(a.Select,{ref:d,label:e,description:r,data:h,value:s,onChange:Se(i),required:t,sx:c,maxDropdownHeight:500,...u})}));function Ay({context:e}){const{value:t,set:r}=R(e.instanceData,"config"),s=v.defaults({},t,va),{control:i,handleSubmit:o,reset:l}=y.useForm({defaultValues:s});return f.useEffect(()=>{l(s)},[t]),t?n.jsx(a.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:o(r),children:[n.jsx(a.Text,{size:"sm",children:"X Axis"}),n.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(y.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>n.jsx(W,{label:"Data Field",required:!0,...c})}),n.jsx(y.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>n.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(a.Text,{mt:"lg",size:"sm",children:"Y Axis"}),n.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(y.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>n.jsx(W,{label:"Data Field",required:!0,...c})}),n.jsx(y.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>n.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(a.Text,{mt:"lg",size:"sm",children:"Z Axis"}),n.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(y.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>n.jsx(W,{label:"Data Field",required:!0,...c})}),n.jsx(y.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>n.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(a.Group,{justify:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:n.jsxs(a.Button,{color:"blue",type:"submit",children:[n.jsx(C.IconDeviceFloppy,{size:20}),n.jsx(a.Text,{ml:"md",size:"sm",children:"Save"})]})})]})}):null}const Ly=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function Oy(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${r}.${u}`,{x_axis_data_key:i,y_axis_data_key:o,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:s(i),y_axis_data_key:s(o),z_axis_data_key:s(l)}}catch(r){throw console.error("[Migration failed]",r),r}}class Vy extends ke{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,s)=>{const{config:i}=r;return{...r,version:2,config:Oy(i,s)}})}}const By={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Vy,name:"bar-3d",viewRender:Py,configRender:Ay,createConfig(){return{version:2,config:v.cloneDeep(va)}},translation:Ly},qy=({disabled:e,value:t,onChange:r})=>{const s=i=>{i&&r(i)};return n.jsxs(a.Box,{sx:{position:"relative"},children:[e&&n.jsx(a.Overlay,{backgroundOpacity:.6,color:"#fff",zIndex:5,blur:2}),n.jsx(ht,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function ot({enabled:e,func_content:t}){return(r,s)=>{if(!e)return r;try{return new Function(`return ${t}`)()(r,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),r}}}function Xe(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
92
|
+
`)(r)}catch(s){return console.error(s),console.log(e),e}}function fs(e,t,r,s){const i=dy(t,s);return e.replaceAll(/(\{\{([^{\}]+(?=}))\}\})/g,(...l)=>{const c=l[2];if(!c)return c;const u=i[c];if(u)return u;const d=py(c);return hy(d,i,r)})}function gy(e,t){const r=wl.decode(t);r!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:r}),console.groupEnd())}async function fy({query:e,name:t,payload:r,additionals:s},i){if(!e.sql)return[];const{type:o,key:l,sql:c,pre_process:u,post_process:d}=e,p=Xs(c,r),h=tx({sql:p,pre_process:u}),x=wl.encode(h);gy(h,x);let b=await gt.query(i)({type:o,key:l,query:x,...s},{params:{name:t}});return b=nx(d,b,ma(r)),b}async function xy({type:e,key:t,configString:r,name:s,additionals:i},o){try{return await gt.httpDataSourceQuery(o)({type:e,key:t,query:r,...i},{params:{name:s}})}catch(l){if(pt.isCancel(l))throw l;return console.error(l),l}}async function my({key:e,configString:t,name:r,additionals:s},i){try{return await gt.mericoMetricQuery(i)({type:"merico_metric_system",key:e,query:t,...s},{params:{name:r}})}catch(o){throw o}}async function ba(){try{return(await gt.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function yd(){try{return(await gt.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class vd{constructor(t){N(this,"rootRef");this.rootRef=te.observable({current:t})}async deleteItem(t){te.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const r=this.getValueFromRoot(t);return Promise.resolve(r)}getValueFromRoot(t){return t===null?te.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,r){if(t===null)if(v.isObject(r))te.runInAction(()=>{this.rootRef.current=r});else throw new Error("Cannot set root value to non-object");else te.runInAction(()=>{v.set(this.rootRef.current,[t],r)});return Promise.resolve(this.getItem(t))}watchItem(t,r,s){return te.reaction(()=>this.getValueFromRoot(t),(i,o)=>{r(i,o)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class by{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new Cl)}getChannel(t){const r=this.channels.get(t);if(r)return r;const s=new Cl;return this.channels.set(t,s),s}}class yy{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 r=this.instances.get(t.id);if(r)return r;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new by,instanceData:new vd(t.viz.conf)};return this.instances.set(t.id,s),s}}function _d(e,t,r,s){return{vizManager:r,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new vd({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const vy=e=>{const{panel:t,measure:r,vizManager:s,data:i,variables:o}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={..._d(c,i,s,o),viewport:{width:r.w,height:r.h}},d=l.viewRender;return n.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},_y=e=>{const{vizManager:t,panel:r,data:s,variables:i}=e,o=t.resolveComponent(r.viz.type),l=t.getOrCreateInstance(r),c={..._d(l,s,t,i)},u=o.configRender;return n.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},jd=(e,t)=>{const r=kt.bezier(e),s=kt.bezier(t);return function(i){return i<50?r(i*2/100).hex():s((i-50)*2/100).hex()}},xs=e=>{const t=kt.bezier(e);return function(r){return t(r/100).hex()}},jy={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:jd(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},wy={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:jd(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Cy={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:xs(["#fff7f1","darkred"]),name:"red",category:"sequential"},Sy={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:xs(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ty={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:xs(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},ky={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:xs(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Dy{constructor(t){N(this,"symbol");this.symbol=Symbol(t)}}function Jt(e){return new Dy(e)}class ya{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const t=new ya;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const r=this.factoryRegistry.get(t.symbol);if(r){const s=r(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,r),this}provideValue(t,r){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>r),this}dispose(){this.instanceRegistry.forEach(t=>{const r=v.get(t,"dispose");v.isFunction(r)&&r.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const wd="14.0.2",zy=Object.freeze(Object.defineProperty({__proto__:null,version:wd},Symbol.toStringTag,{value:"Module"}));class Iy{constructor(t){N(this,"staticColors",new Map);N(this,"interpolations",new Map);t.installedPlugins.forEach(r=>{r.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const r=this.encodeColor(t);t.type==="single"?(this.staticColors.has(r)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(r,t)):t.type==="interpolation"&&(this.interpolations.has(r)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(r,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class My{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:t=>{const r=this.vizComponents.get(t);if(r)return r;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const r of t.manifest.viz){if(this.vizComponents.has(r.name))throw new Error(`Viz Component (${r.name}) has been installed before`);this.vizComponents.set(r.name,r)}}get installedPlugins(){return Array.from(this.plugins.values())}}class Ey{constructor(){N(this,"migrations",[])}version(t,r){return this.migrations.push({version:t,handler:r}),this}run(t,r,s){var l;if(t.from===t.to)return r;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),o=v.orderBy(i,"version","asc");if(((l=v.last(o))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((c,u)=>u.handler(c,s),r)}}class ke extends Ey{constructor(){super(),this.configVersions()}version(t,r){return super.version(t,(s,i)=>({version:t,...r(s,i)}))}async migrate({configData:t,panelModel:r}){const s=await t.getItem(null),i=v.get(s,"version",0),o=this.run({from:i,to:this.VERSION},s,{panelModel:r});await t.setItem(null,o)}async needMigration({configData:t}){const r=await t.getItem(null);return v.get(r,"version",0)<this.VERSION}}const R=(e,t)=>{const[r,{setFalse:s}]=Y.useBoolean(!0),[i,o]=f.useState();f.useEffect(()=>(e.getItem(t).then(c=>{o(c),s()}),e.watchItem(t,c=>{o(c)})));const l=f.useCallback(async c=>{await e.setItem(t,c),o(c)},[e,t]);return{loading:r,value:i,set:l}},st={top:16,right:16,bottom:16,left:16},Et=e=>Math.max(0,e-st.left-st.right),Pt=e=>Math.max(0,e-st.top-st.bottom),kr=(e,t)=>({width:Et(e),height:Pt(t)}),at=({width:e,height:t,children:r})=>n.jsx(a.Box,{pt:st.top,pr:st.right,pb:st.bottom,pl:st.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:r}),va={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function Py({context:e}){const{value:t}=R(e.instanceData,"config"),r=e.data,{width:s,height:i}=e.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=v.defaults({},t,va),h=f.useMemo(()=>qr(r,o),[r,o]),{x,y:b,z:m}=f.useMemo(()=>({x:O(o),y:O(l),z:O(c)}),[o,l,c]),{min:j,max:D}=f.useMemo(()=>{const z=v.minBy(h,M=>M[m.columnKey]),I=v.maxBy(h,M=>M[m.columnKey]);return{min:v.get(z,m.columnKey),max:v.get(I,m.columnKey)}},[h,m]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:j,max:D,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:p,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(z=>[z[x.columnKey],z[b.columnKey],z[m.columnKey]])}]};return t?n.jsx(at,{width:s,height:i,children:n.jsx(Qe,{echarts:Fe,option:T,style:kr(s,i),notMerge:!0,theme:"merico-light"})}):null}const W=k.observer(f.forwardRef(({label:e,required:t,description:r,value:s,onChange:i,queryID:o,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=Le(),h=f.useMemo(()=>p.dataFieldOptionGroups(s,l,o),[s,l,o]);if(h.length===0){const x=p.explainDataKey(s);return n.jsxs(a.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[n.jsx(a.HoverCard.Target,{children:n.jsx(a.Box,{children:n.jsx(a.TextInput,{label:e,required:t,defaultValue:x.columnKey,readOnly:!0,disabled:!0})})}),n.jsx(a.HoverCard.Dropdown,{children:n.jsxs(a.Group,{justify:"flex-start",gap:0,children:[n.jsx(a.Text,{size:"xs",c:x.queryName?"black":"red",ff:"monospace",children:x.queryName??x.queryID}),n.jsx(a.Text,{size:"xs",c:"black",ff:"monospace",children:"."}),n.jsx(a.Text,{size:"xs",c:"red",ff:"monospace",children:x.columnKey})]})})]})}return n.jsx(a.Select,{ref:d,label:e,description:r,data:h,value:s,onChange:Se(i),required:t,sx:c,maxDropdownHeight:500,...u})}));function Ay({context:e}){const{value:t,set:r}=R(e.instanceData,"config"),s=v.defaults({},t,va),{control:i,handleSubmit:o,reset:l}=y.useForm({defaultValues:s});return f.useEffect(()=>{l(s)},[t]),t?n.jsx(a.Stack,{gap:"xs",children:n.jsxs("form",{onSubmit:o(r),children:[n.jsx(a.Text,{size:"sm",children:"X Axis"}),n.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(y.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>n.jsx(W,{label:"Data Field",required:!0,...c})}),n.jsx(y.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>n.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(a.Text,{mt:"lg",size:"sm",children:"Y Axis"}),n.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(y.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>n.jsx(W,{label:"Data Field",required:!0,...c})}),n.jsx(y.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>n.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(a.Text,{mt:"lg",size:"sm",children:"Z Axis"}),n.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[n.jsx(y.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>n.jsx(W,{label:"Data Field",required:!0,...c})}),n.jsx(y.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>n.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),n.jsx(a.Group,{justify:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:n.jsxs(a.Button,{color:"blue",type:"submit",children:[n.jsx(C.IconDeviceFloppy,{size:20}),n.jsx(a.Text,{ml:"md",size:"sm",children:"Save"})]})})]})}):null}const Ly=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function Oy(e,{panelModel:t}){try{const r=t.queryIDs[0];if(!r)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${r}.${u}`,{x_axis_data_key:i,y_axis_data_key:o,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:s(i),y_axis_data_key:s(o),z_axis_data_key:s(l)}}catch(r){throw console.error("[Migration failed]",r),r}}class Vy extends ke{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,r=>({version:1,config:r})),this.version(2,(r,s)=>{const{config:i}=r;return{...r,version:2,config:Oy(i,s)}})}}const By={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Vy,name:"bar-3d",viewRender:Py,configRender:Ay,createConfig(){return{version:2,config:v.cloneDeep(va)}},translation:Ly},qy=({disabled:e,value:t,onChange:r})=>{const s=i=>{i&&r(i)};return n.jsxs(a.Box,{sx:{position:"relative"},children:[e&&n.jsx(a.Overlay,{backgroundOpacity:.6,color:"#fff",zIndex:5,blur:2}),n.jsx(ht,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function ot({enabled:e,func_content:t}){return(r,s)=>{if(!e)return r;try{return new Function(`return ${t}`)()(r,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),r}}}function Xe(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
93
93
|
`)}}const At=f.forwardRef(({value:e,onChange:t,triggerButtonText:r},s)=>{const{t:i}=_.useTranslation(),[o,{setTrue:l,setFalse:c}]=Y.useBoolean(),[u,d]=f.useState(e);f.useEffect(()=>{d(e)},[e]);const p=D=>{d({...u,enabled:D})},h=()=>{c();const{enabled:D,func_content:T}=u,z={enabled:D,func_content:T};d(z),t(z)},x=()=>{c(),d(e)},b=D=>{d(T=>({...T,func_content:D}))},m=()=>{b(Xe().func_content)},j=r??i("chart.axis.customize_label");return n.jsxs(n.Fragment,{children:[n.jsx(a.Button,{variant:"filled",color:"grape",leftSection:n.jsx(C.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:j}),n.jsx(a.Modal,{size:800,title:j,opened:o,onClose:c,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:o&&n.jsxs(a.Stack,{children:[n.jsx(a.Checkbox,{mt:10,label:i("common.enabled"),checked:u.enabled,onChange:D=>p(D.currentTarget.checked)}),n.jsx(qy,{value:u.func_content,onChange:b,disabled:!u.enabled}),n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Button,{onClick:m,color:"red",leftSection:n.jsx(C.IconRecycle,{size:20}),children:i("common.actions.reset_to_default")}),n.jsxs(a.Group,{justify:"flex-end",children:[n.jsx(a.Button,{onClick:x,variant:"subtle",children:i("common.actions.cancel")}),n.jsx(a.Button,{color:"green",leftSection:n.jsx(C.IconDeviceFloppy,{size:16}),onClick:h,children:i("common.actions.save")})]})]})]})})]})}),Tn={x_axis_scroll:!1,y_axis_scroll:!1,x_axis_slider:!1,y_axis_slider:!1};function Cd(){return v.cloneDeep(Tn)}const Ny=[{lang:"en",resources:{boxplot:{viz_name:"Boxplot Chart",box:"Box",outlier:"Outlier",scatter:"Scatter",click_series:{label:"Click box, scatter or outlier"}}}},{lang:"zh",resources:{boxplot:{viz_name:"箱线图",box:"箱体",outlier:"异常点",scatter:"散点",click_series:{label:"点击箱体、散点或异常点"}}}}],Sd={id:"builtin:echarts:click-echart:series",displayName:"viz.boxplot.click_series.label",nameRender:Gy,configRender:$y,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 $y(e){return n.jsx(n.Fragment,{})}function Gy(e){const{t}=_.useTranslation();return n.jsx(a.Text,{size:"sm",children:t("viz.boxplot.click_series.label")})}const ms=f.forwardRef(({sectionTitle:e,value:t,onChange:r},s)=>{const{t:i,i18n:o}=_.useTranslation(),l=u=>d=>{const p=v.cloneDeep(t);v.set(p,u,d),r(p)},c=f.useMemo(()=>[{label:i("chart.axis.overflow.truncate"),value:"truncate"},{label:i("chart.axis.overflow.break_line"),value:"break"},{label:i("chart.axis.overflow.break_word"),value:"breakAll"}],[o.language]);return n.jsxs(a.Stack,{gap:0,children:[e&&n.jsx(a.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",styles:{label:{color:"dimmed"}}}),n.jsxs(a.Group,{grow:!0,wrap:"nowrap",children:[n.jsx(a.NumberInput,{label:i("chart.axis.overflow.max_width"),hideControls:!0,value:t.width,onChange:l("width")}),n.jsx(a.Select,{label:i("chart.axis.overflow.label"),data:c,value:t.overflow,onChange:l("overflow")}),n.jsx(a.TextInput,{label:i("chart.axis.overflow.ellipsis"),value:t.ellipsis,disabled:!0})]})]})}),Lt=f.forwardRef(({value:e,onChange:t},r)=>{const{t:s}=_.useTranslation(),i=l=>{t({...e,on_axis:l})},o=l=>{t({...e,in_tooltip:l})};return n.jsxs(a.Stack,{ref:r,gap:0,children:[n.jsx(ms,{sectionTitle:s("chart.axis.overflow.section_title.on_axis"),value:e.on_axis,onChange:i}),n.jsx(ms,{sectionTitle:s("chart.axis.overflow.section_title.in_tooltip"),value:e.in_tooltip,onChange:o})]})});function lt(){return{on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}}}function wt({overflow:e,width:t}){const r={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],s=e==="truncate"?"nowrap":"initial",i={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
|
|
94
94
|
max-width: ${t}px;
|
|
95
95
|
word-break: ${r};
|
|
@@ -515,4 +515,4 @@ WHERE
|
|
|
515
515
|
`),post:["function process_result(data, utils, state) {"," // process data and return the result"," return data","}"].join(`
|
|
516
516
|
`)},TM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation();if(!e.typedAsSQL)return null;const r=e.config;return n.jsxs(a.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%",height:"28px",lineHeight:"28px"}},keepMounted:!1,children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"Edit",children:n.jsx(a.Group,{gap:14,justify:"space-between",children:t("query.edit_sql")})}),n.jsx(a.Tabs.Tab,{value:"Preview",children:t("query.preview_sql")}),n.jsx(a.Tabs.Tab,{value:"pre_process",children:t("query.process_request")}),n.jsx(a.Tabs.Tab,{value:"post_process",children:t("query.process_result")}),n.jsx(Ko,{}),e.datasource&&n.jsx(Sg,{dataSource:e.datasource})]}),n.jsx(a.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:n.jsx(wM,{queryModel:e})}),n.jsx(a.Tabs.Panel,{value:"Preview",p:0,pl:4,children:n.jsx(SM,{value:r.sql})}),n.jsx(a.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:n.jsx(Sn,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:Mg.pre})}),n.jsx(a.Tabs.Panel,{value:"post_process",p:"sm",children:n.jsx(Sn,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:Mg.post})})]})}),kM={pre:["function transform(queries, state, utils) {"," // use queries & dashboar state to build new data"," const data = []"," return data","}"].join(`
|
|
517
517
|
`),post:""},DM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),r=re();if(!e.isTransform)return null;const s=e.config;return n.jsxs(a.Stack,{py:20,px:20,sx:{height:"100%"},children:[n.jsx(a.Text,{size:"sm",children:t("query.transform.guide.pick_queries")}),n.jsx(a.MultiSelect,{data:r.queries.optionsWithoutTransform,value:[...s.dep_query_ids],onChange:s.setDependantQueryIDs,maxDropdownHeight:800}),n.jsx(a.Text,{size:"sm",children:t("query.transform.guide.write_function")}),n.jsx(a.Box,{sx:{flexGrow:1},children:n.jsx(Sn,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:kM.pre})})]})}),Er={height:"calc(100% - 44px)",padding:0},zM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),r=re(),s=f.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),[i,o]=f.useState(s);f.useEffect(()=>{o(u=>u!=="Configurations"&&s==="Configurations"?"Configurations":u)},[s]);const c=r.findQueryUsage(e.id).length===0;return n.jsxs(a.Tabs,{value:i,onChange:o,defaultValue:s,orientation:"horizontal",keepMounted:!1,sx:{height:"100vh"},children:[n.jsxs(a.Tabs.List,{grow:!0,children:[n.jsx(a.Tabs.Tab,{value:"Configurations",children:t("query.configurations")}),e.typedAsSQL&&n.jsx(a.Tabs.Tab,{value:"SQL",children:t("query.request")}),e.typedAsHTTP&&n.jsx(a.Tabs.Tab,{value:"HTTP",children:t("query.request")}),e.isTransform&&n.jsx(a.Tabs.Tab,{value:"Transform",children:t("query.transform.label")}),n.jsx(a.Tabs.Tab,{value:"Data",disabled:!e.canPreviewData,children:n.jsx(a.Tooltip,{label:e.guideToPreviewData,disabled:e.canPreviewData,withinPortal:!0,children:n.jsx(a.Text,{size:"sm",children:t("data.preview_data")})})}),n.jsx(a.Tabs.Tab,{value:"Usage",disabled:c,children:n.jsx(a.Tooltip,{label:t("query.usage.unused_description"),disabled:!c,withinPortal:!0,children:n.jsx(a.Text,{size:"sm",children:t("query.usage.label")})})})]}),n.jsx(a.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:n.jsx(xM,{queryModel:e})}),e.typedAsSQL&&n.jsx(a.Tabs.Panel,{value:"SQL",sx:Er,children:n.jsx(a.Stack,{sx:{height:"100%"},children:n.jsx(TM,{queryModel:e})})}),e.typedAsHTTP&&n.jsx(a.Tabs.Panel,{value:"HTTP",sx:Er,children:n.jsx(a.Stack,{sx:{height:"100%"},children:n.jsx(vM,{queryModel:e})})}),e.isTransform&&n.jsx(a.Tabs.Panel,{value:"Transform",sx:Er,children:n.jsx(a.Stack,{sx:{height:"100%"},children:n.jsx(DM,{queryModel:e})})}),n.jsx(a.Tabs.Panel,{value:"Data",sx:{...Er,overflow:"hidden"},children:n.jsx(Wo,{id:e.id,moreActions:null,refreshOnMount:!0})}),n.jsx(a.Tabs.Panel,{value:"Usage",py:"sm",px:"md",sx:{...Er,overflow:"hidden"},children:n.jsx(Ig,{queryModel:e})})]})}),IM=({width:e,height:t})=>n.jsxs("svg",{width:e,height:t,viewBox:"0 0 36 36",fill:"none",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.5 10.5C7.10217 10.5 6.72064 10.658 6.43934 10.9393C6.15804 11.2206 6 11.6022 6 12V28.5C6 28.8978 6.15804 29.2794 6.43934 29.5607C6.72064 29.842 7.10218 30 7.5 30H24C24.3978 30 24.7794 29.842 25.0607 29.5607C25.342 29.2794 25.5 28.8978 25.5 28.5V19.5C25.5 18.6716 26.1716 18 27 18C27.8284 18 28.5 18.6716 28.5 19.5V28.5C28.5 29.6935 28.0259 30.8381 27.182 31.682C26.3381 32.5259 25.1935 33 24 33H7.5C6.30653 33 5.16193 32.5259 4.31802 31.682C3.47411 30.8381 3 29.6935 3 28.5V12C3 10.8065 3.47411 9.66193 4.31802 8.81802C5.16193 7.97411 6.30653 7.5 7.5 7.5H16.5C17.3284 7.5 18 8.17157 18 9C18 9.82843 17.3284 10.5 16.5 10.5H7.5Z",fill:"#3D3E45"}),n.jsx("path",{d:"M32.8862 3.92582C32.8135 3.75021 32.7061 3.5856 32.5638 3.44253C32.5617 3.4404 32.5596 3.43828 32.5575 3.43616C32.2863 3.16658 31.9126 3 31.5 3H22.5C21.6716 3 21 3.67157 21 4.5C21 5.32843 21.6716 6 22.5 6H27.8787L13.9393 19.9393C13.3536 20.5251 13.3536 21.4749 13.9393 22.0607C14.5251 22.6464 15.4749 22.6464 16.0607 22.0607L30 8.12132V13.5C30 14.3284 30.6716 15 31.5 15C32.3284 15 33 14.3284 33 13.5V4.5C33 4.29662 32.9595 4.10268 32.8862 3.92582Z",fill:"#3D3E45"})]}),Eg=({width:e,height:t,color:r="#FFFFFF"})=>n.jsxs("svg",{viewBox:"0 0 36 36",fill:"none",width:e,height:t,children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24.6931 20.547C26.1129 19.5516 26.113 17.4483 24.6931 16.4529L16.9351 11.0141C15.2783 9.85255 13 11.0377 13 13.0611L13 23.9389C13 25.9623 15.2783 27.1474 16.9351 25.9859L24.6931 20.547ZM16 14.0223L22.387 18.5L16 22.9777L16 14.0223Z",fill:r}),n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M18 1.5C8.8873 1.5 1.5 8.8873 1.5 18C1.5 27.1127 8.8873 34.5 18 34.5C27.1127 34.5 34.5 27.1127 34.5 18C34.5 8.8873 27.1127 1.5 18 1.5ZM4.5 18C4.5 10.5442 10.5442 4.5 18 4.5C25.4558 4.5 31.5 10.5442 31.5 18C31.5 25.4558 25.4558 31.5 18 31.5C10.5442 31.5 4.5 25.4558 4.5 18Z",fill:r})]}),Pg=({width:e,height:t,color:r="#EB1212"})=>n.jsxs("svg",{viewBox:"0 0 16 16",fill:"none",width:e,height:t,children:[n.jsx("path",{d:"M6.66665 6.66699C7.03484 6.66699 7.33331 6.96547 7.33331 7.33366V11.3337C7.33331 11.7018 7.03484 12.0003 6.66665 12.0003C6.29846 12.0003 5.99998 11.7018 5.99998 11.3337V7.33366C5.99998 6.96547 6.29846 6.66699 6.66665 6.66699Z",fill:r}),n.jsx("path",{d:"M9.99998 11.3337V7.33366C9.99998 6.96547 9.7015 6.66699 9.33331 6.66699C8.96512 6.66699 8.66665 6.96547 8.66665 7.33366V11.3337C8.66665 11.7018 8.96512 12.0003 9.33331 12.0003C9.7015 12.0003 9.99998 11.7018 9.99998 11.3337Z",fill:r}),n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M4.66665 3.33366V2.66699C4.66665 2.13656 4.87736 1.62785 5.25243 1.25278C5.62751 0.877706 6.13621 0.666992 6.66665 0.666992H9.33331C9.86375 0.666992 10.3725 0.877706 10.7475 1.25278C11.1226 1.62785 11.3333 2.13656 11.3333 2.66699V3.33366H14C14.3682 3.33366 14.6666 3.63214 14.6666 4.00033C14.6666 4.36852 14.3682 4.66699 14 4.66699H13.3333V13.3337C13.3333 13.8641 13.1226 14.3728 12.7475 14.7479C12.3725 15.1229 11.8637 15.3337 11.3333 15.3337H4.66665C4.13621 15.3337 3.62751 15.1229 3.25243 14.7479C2.87736 14.3728 2.66665 13.8641 2.66665 13.3337V4.66699H1.99998C1.63179 4.66699 1.33331 4.36852 1.33331 4.00033C1.33331 3.63214 1.63179 3.33366 1.99998 3.33366H4.66665ZM6.19524 2.19559C6.32027 2.07056 6.48984 2.00033 6.66665 2.00033H9.33331C9.51012 2.00033 9.67969 2.07056 9.80472 2.19559C9.92974 2.32061 9.99998 2.49018 9.99998 2.66699V3.33366H5.99998V2.66699C5.99998 2.49018 6.07022 2.32061 6.19524 2.19559ZM3.99998 4.66699V13.3337C3.99998 13.5105 4.07022 13.68 4.19524 13.8051C4.32027 13.9301 4.48984 14.0003 4.66665 14.0003H11.3333C11.5101 14.0003 11.6797 13.9301 11.8047 13.8051C11.9297 13.68 12 13.5105 12 13.3337V4.66699H3.99998Z",fill:r})]}),MM=({width:e,height:t})=>n.jsxs("svg",{viewBox:"0 0 18 18",fill:"none",width:e,height:t,children:[n.jsx("path",{d:"M7.5 3.75C7.5 2.92157 8.17157 2.25 9 2.25C9.82843 2.25 10.5 2.92157 10.5 3.75C10.5 4.57843 9.82843 5.25 9 5.25C8.17157 5.25 7.5 4.57843 7.5 3.75Z",fill:"#3D3E45"}),n.jsx("path",{d:"M7.5 9C7.5 8.17157 8.17157 7.5 9 7.5C9.82843 7.5 10.5 8.17157 10.5 9C10.5 9.82843 9.82843 10.5 9 10.5C8.17157 10.5 7.5 9.82843 7.5 9Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9 12.75C8.17157 12.75 7.5 13.4216 7.5 14.25C7.5 15.0784 8.17157 15.75 9 15.75C9.82843 15.75 10.5 15.0784 10.5 14.25C10.5 13.4216 9.82843 12.75 9 12.75Z",fill:"#3D3E45"})]}),EM=k.observer(({queryModel:e})=>{const{t}=_.useTranslation(),r=se(),s=re(),o=s.findQueryUsage(e.id).length>0,l=dt.useModals(),c=()=>{l.openConfirmModal({title:`${t("query.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{s.queries.removeQuery(e.id),r.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return o?n.jsx(a.Tooltip,{label:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"bottom-end",children:n.jsx(a.Button,{leftSection:n.jsx(Pg,{width:14,height:14,color:"gray"}),variant:"subtle",color:"gray",onClick:u=>{u.stopPropagation()},children:"删除查询"})}):n.jsx(a.Menu.Item,{leftSection:n.jsx(Pg,{width:14,height:14}),color:"red",onClick:c,children:"删除查询"})}),PM=k.observer(({queryModel:e})=>n.jsxs(a.Menu,{shadow:"md",width:120,trigger:"hover",children:[n.jsx(a.Menu.Target,{children:n.jsx(a.ActionIcon,{variant:"subtle","aria-label":"Settings",children:n.jsx(MM,{width:18,height:18})})}),n.jsx(a.Menu.Dropdown,{children:n.jsx(EM,{queryModel:e})})]})),AM={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},"th, td":{wordBreak:"break-word"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function LM({data:e}){const t=f.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const s=Re.createColumnHelper();return Object.keys(e[0]).map(i=>s.accessor(i,{cell:o=>o.getValue()}))},[e]),r=Re.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:Re.getCoreRowModel()});return e.length===0?n.jsx(a.Box,{sx:{height:"5em"}}):n.jsx(Ie,{children:n.jsxs(a.Table,{sx:AM,stickyHeader:!0,stickyHeaderOffset:0,children:[n.jsx(a.Table.Thead,{style:{backgroundColor:"#F9F9FA"},children:r.getHeaderGroups().map(s=>n.jsx(a.Table.Tr,{children:s.headers.map(i=>n.jsxs(a.Table.Th,{style:{width:i.getSize()},children:[i.isPlaceholder?null:Re.flexRender(i.column.columnDef.header,i.getContext()),n.jsx(a.ActionIcon,{variant:"subtle",onMouseDown:i.getResizeHandler(),onTouchStart:i.getResizeHandler(),className:`resizer ${i.column.getIsResizing()?"isResizing":""}`,children:n.jsx(C.IconArrowBarToRight,{})})]},i.id))},s.id))}),n.jsx(a.Table.Tbody,{children:r.getRowModel().rows.map(s=>n.jsx(a.Table.Tr,{children:s.getVisibleCells().map(i=>n.jsx(a.Table.Td,{children:n.jsx(Ie,{children:typeof i.getValue()=="object"?n.jsx("pre",{children:JSON.stringify(i.getValue(),null,2)}):Re.flexRender(i.column.columnDef.cell,i.getContext())})},i.id))},s.id))})]})})}const OM=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],VM={root:{width:"150px"},section:{"&[data-position=left]":{width:"70px",textAlign:"center"}},input:{paddingLeft:"70px",paddingRight:0}},BM=({data:e,page:t,setPage:r,limit:s,setLimit:i})=>{const{t:o}=_.useTranslation(),l=e.length,c=Math.ceil(l/s),u=p=>{p&&(r(1),i(Number(p)))};if(l===0)return null;const d=c===1&&l<=10;return n.jsxs(a.Group,{pt:10,px:10,justify:"space-between",children:[n.jsxs(a.Group,{justify:"flex-start",children:[!d&&n.jsx(a.Select,{leftSection:n.jsx(a.Text,{ta:"center",c:"dimmed",size:"xs",children:o("common.pagination.page_size")}),size:"xs",styles:VM,data:OM,value:String(s),onChange:u}),c>1&&n.jsx(a.Pagination,{size:"sm",value:t,onChange:r,total:c,withEdges:c>7,styles:{control:{height:"30px"}},color:"red"})]}),n.jsx(a.Group,{justify:"flex-end",children:n.jsx(a.Text,{c:"dimmed",my:0,size:"14px",children:o("common.pagination.total_rows",{total:l})})})]})},qM=xd(({data:e,loading:t})=>{const[r,s]=f.useState(1),[i,o]=f.useState(20),l=f.useMemo(()=>{const c=(r-1)*i,u=c+i;return e.slice(c,u)},[e,r,i]);return n.jsx(Ie,{children:n.jsxs(a.Stack,{gap:10,styles:{root:{height:"100%",overflow:"hidden"}},children:[n.jsx(BM,{data:e,page:r,setPage:s,limit:i,setLimit:o}),n.jsxs(a.Box,{sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[n.jsx(a.LoadingOverlay,{visible:t,overlayProps:{blur:2}}),n.jsx(LM,{data:l})]})]})})}),NM=k.observer(({queryModel:e})=>{const{state:t,error:r,metricQueryPayloadError:s,stateMessage:i}=e;return t==="loading"?null:r?n.jsx(a.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:r}):s?n.jsx(a.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:s}):i?n.jsx(a.Text,{size:"sm",mt:10,c:"gray",ta:"center",children:i}):null}),$M=k.observer(({queryModel:e})=>{_.useTranslation();const{data:t,state:r}=e,s=r==="loading",i=f.useCallback(()=>{e.fetchData(!0)},[e.fetchData]),o=()=>{gh(e.name,e.data)};f.useEffect(()=>{i()},[i]);const l=!Array.isArray(t)||t.length===0;return n.jsxs(a.Stack,{gap:0,sx:{minHeight:"250px",maxHeight:"calc(50vh - 48px)",flexGrow:1,flexShrink:0,background:"#F9F9FA"},children:[n.jsxs(a.Group,{justify:"space-between",py:7,px:8,children:[n.jsx(a.Text,{size:"sm",fw:500,children:"查询结果"}),n.jsx(a.Button,{size:"xs",variant:"transparent",color:"gray",leftSection:n.jsx(C.IconDownload,{size:16}),disabled:s||l,onClick:o,children:"下载查询结果"})]}),n.jsxs(a.Box,{sx:{position:"relative",flexGrow:1,overflow:"hidden"},children:[n.jsx(NM,{queryModel:e}),n.jsx(qM,{data:t,loading:s})]})]})}),GM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.24335 1.62305C7.50108 1.62305 7.71001 1.83198 7.71001 2.08971L7.71001 11.423C7.71001 11.6808 7.50108 11.8897 7.24335 11.8897C6.98561 11.8897 6.77668 11.6808 6.77668 11.423L6.77668 2.08971C6.77668 1.83198 6.98561 1.62305 7.24335 1.62305Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9.93845 9.4786C9.80779 9.4786 9.70045 9.43893 9.61645 9.3596C9.53712 9.2756 9.49745 9.17293 9.49745 9.0516L9.49745 5.0056C9.49745 4.88427 9.53712 4.78393 9.61645 4.7046C9.70045 4.6206 9.80312 4.5786 9.92445 4.5786L12.1995 4.5786C12.3208 4.5786 12.4211 4.61827 12.5005 4.6976C12.5845 4.77227 12.6265 4.87027 12.6265 4.9916C12.6265 5.09427 12.5845 5.18527 12.5005 5.2646C12.4211 5.34393 12.3208 5.3836 12.1995 5.3836L10.3725 5.3836V6.6156H11.8845C12.0058 6.6156 12.1061 6.65527 12.1855 6.7346C12.2695 6.80927 12.3115 6.90727 12.3115 7.0286C12.3115 7.13127 12.2695 7.22227 12.1855 7.3016C12.1061 7.38093 12.0058 7.4206 11.8845 7.4206H10.3725L10.3725 9.0516C10.3725 9.17293 10.3281 9.2756 10.2395 9.3596C10.1555 9.43893 10.0551 9.4786 9.93845 9.4786Z",fill:"#3D3E45"}),n.jsx("path",{d:"M3.34754 9.4786C3.21687 9.4786 3.10954 9.43893 3.02554 9.3596C2.94154 9.2756 2.89954 9.17293 2.89954 9.0516L2.89954 5.3836H1.80054C1.6792 5.3836 1.57654 5.34627 1.49254 5.2716C1.4132 5.19693 1.37354 5.09893 1.37354 4.9776C1.37354 4.85627 1.4132 4.7606 1.49254 4.6906C1.57654 4.61593 1.6792 4.5786 1.80054 4.5786H4.90854C5.02987 4.5786 5.1302 4.61593 5.20954 4.6906C5.29354 4.76527 5.33554 4.86327 5.33554 4.9846C5.33554 5.10593 5.29354 5.20393 5.20954 5.2786C5.1302 5.3486 5.02987 5.3836 4.90854 5.3836H3.80954L3.80954 9.0516C3.80954 9.17293 3.7652 9.2756 3.67654 9.3596C3.59254 9.43893 3.48287 9.4786 3.34754 9.4786Z",fill:"#3D3E45"})]}),FM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("g",{clipPath:"url(#clip0_245_10828)",children:n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M9.91663 1.16634C9.91663 0.844175 9.65546 0.583008 9.33329 0.583008C9.01113 0.583008 8.74996 0.844175 8.74996 1.16634V1.74967L5.24996 1.74967V1.16634C5.24996 0.844175 4.98879 0.583008 4.66663 0.583008C4.34446 0.583008 4.08329 0.844175 4.08329 1.16634V1.74967H2.91663C1.95013 1.74967 1.16663 2.53318 1.16663 3.49967L1.16663 11.6663C1.16663 12.6328 1.95013 13.4163 2.91663 13.4163L11.0833 13.4163C12.0498 13.4163 12.8333 12.6328 12.8333 11.6663L12.8333 3.49967C12.8333 2.53318 12.0498 1.74967 11.0833 1.74967H9.91663V1.16634ZM11.6666 5.24967V3.49967C11.6666 3.17751 11.4055 2.91634 11.0833 2.91634H9.91663V3.49967C9.91663 3.82184 9.65546 4.08301 9.33329 4.08301C9.01113 4.08301 8.74996 3.82184 8.74996 3.49967V2.91634L5.24996 2.91634V3.49967C5.24996 3.82184 4.98879 4.08301 4.66663 4.08301C4.34446 4.08301 4.08329 3.82184 4.08329 3.49967V2.91634L2.91663 2.91634C2.59446 2.91634 2.33329 3.17751 2.33329 3.49967L2.33329 5.24967L11.6666 5.24967ZM2.33329 6.41634L11.6666 6.41634L11.6666 11.6663C11.6666 11.9885 11.4055 12.2497 11.0833 12.2497L2.91663 12.2497C2.59446 12.2497 2.33329 11.9885 2.33329 11.6663V6.41634Z",fill:"#3D3E45"})}),n.jsx("defs",{children:n.jsx("clipPath",{id:"clip0_245_10828",children:n.jsx("rect",{width:"14",height:"14",fill:"white"})})})]}),QM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M3.11108 2.13932C2.78892 2.13932 2.52775 2.40049 2.52775 2.72266V10.8893C2.52775 11.2115 2.78892 11.4727 3.11108 11.4727H11.2778C11.5999 11.4727 11.8611 11.2115 11.8611 10.8893V2.72266C11.8611 2.40049 11.5999 2.13932 11.2778 2.13932H3.11108ZM1.36108 2.72266C1.36108 1.75616 2.14459 0.972656 3.11108 0.972656H11.2778C12.2442 0.972656 13.0278 1.75616 13.0278 2.72266V10.8893C13.0278 11.8558 12.2442 12.6393 11.2778 12.6393H3.11108C2.14459 12.6393 1.36108 11.8558 1.36108 10.8893V2.72266Z",fill:"#3D3E45"}),n.jsx("path",{d:"M9.84418 8.37166C9.94816 8.37166 10.0348 8.40631 10.1041 8.47563C10.1734 8.54494 10.2081 8.63159 10.2081 8.73556C10.2081 8.8352 10.1734 8.91968 10.1041 8.989C10.0348 9.05398 9.94816 9.08647 9.84418 9.08647H7.63475C7.52211 9.08647 7.4333 9.05182 7.36832 8.9825C7.30334 8.91318 7.27084 8.82437 7.27084 8.71607C7.27084 8.60776 7.30983 8.51245 7.38781 8.43014L8.80445 6.91603C8.96474 6.74274 9.09038 6.56512 9.18135 6.38317C9.27666 6.20121 9.32432 6.04309 9.32432 5.90879C9.32432 5.69218 9.2615 5.51889 9.13587 5.38892C9.01023 5.25462 8.84344 5.18747 8.63549 5.18747C8.55318 5.18747 8.4687 5.20697 8.38206 5.24596C8.29541 5.28495 8.21094 5.3391 8.12862 5.40842C8.05064 5.47773 7.977 5.55788 7.90768 5.64885C7.85569 5.71817 7.80371 5.76149 7.75172 5.77882C7.69973 5.79615 7.65208 5.80481 7.60876 5.80481C7.51345 5.80481 7.42464 5.77016 7.34233 5.70084C7.26435 5.62719 7.22536 5.54271 7.22536 5.44741C7.22536 5.37376 7.24918 5.30228 7.29684 5.23296C7.34882 5.16365 7.41164 5.09216 7.48529 5.01852C7.59359 4.91021 7.7149 4.8149 7.8492 4.73259C7.98349 4.65028 8.12213 4.58746 8.26509 4.54414C8.40805 4.49648 8.54668 4.47266 8.68098 4.47266C8.97124 4.47266 9.22251 4.53114 9.43479 4.64811C9.6514 4.76075 9.81819 4.92321 9.93516 5.13549C10.0521 5.34343 10.1106 5.59037 10.1106 5.8763C10.1106 6.11457 10.0391 6.381 9.89617 6.67559C9.75754 6.96585 9.56909 7.23878 9.33081 7.49438L8.50837 8.37166H9.84418Z",fill:"#3D3E45"}),n.jsx("path",{d:"M5.49994 9.08647C5.37864 9.08647 5.279 9.04965 5.20102 8.976C5.12304 8.89802 5.08405 8.80271 5.08405 8.69007V5.62518L4.70065 5.90879C4.64 5.95644 4.56418 5.98027 4.47321 5.98027C4.36923 5.98027 4.27826 5.94128 4.20028 5.8633C4.1223 5.78532 4.08331 5.69218 4.08331 5.58387C4.08331 5.44524 4.15046 5.3326 4.28475 5.24596L5.22051 4.62212C5.26384 4.59179 5.31149 4.57013 5.36348 4.55713C5.4198 4.54414 5.47178 4.53764 5.51944 4.53764C5.64507 4.53764 5.74471 4.57663 5.81836 4.65461C5.89201 4.72826 5.92883 4.8214 5.92883 4.93404V8.69007C5.92883 8.80271 5.88768 8.89802 5.80536 8.976C5.72738 9.04965 5.62558 9.08647 5.49994 9.08647Z",fill:"#3D3E45"})]}),RM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("path",{d:"M12.0334 5.64833C12.3099 5.64833 12.55 5.67744 12.7537 5.73565C12.9623 5.79386 13.1224 5.87632 13.2339 5.98303C13.3504 6.0849 13.4086 6.20859 13.4086 6.35412C13.4086 6.45113 13.3795 6.5433 13.3213 6.63061C13.263 6.71307 13.1782 6.7543 13.0666 6.7543C12.989 6.7543 12.9235 6.7446 12.8701 6.7252C12.8216 6.70094 12.778 6.67184 12.7392 6.63788C12.7004 6.60393 12.6543 6.5724 12.6009 6.54329C12.5524 6.51419 12.4772 6.49236 12.3754 6.47781C12.2783 6.45841 12.2056 6.44871 12.1571 6.44871C11.9097 6.44871 11.6987 6.50206 11.5241 6.60878C11.3543 6.7155 11.2233 6.86102 11.1311 7.04535C11.039 7.22482 10.9929 7.43341 10.9929 7.67109C10.9929 7.90393 11.039 8.11251 11.1311 8.29684C11.2282 8.47631 11.3591 8.61941 11.5241 8.72613C11.6938 8.83284 11.8879 8.8862 12.1061 8.8862C12.2274 8.8862 12.3317 8.87893 12.419 8.86437C12.5063 8.84982 12.5791 8.82799 12.6373 8.79889C12.7052 8.76008 12.7658 8.71885 12.8192 8.6752C12.8726 8.63154 12.9526 8.60971 13.0593 8.60971C13.1854 8.60971 13.2824 8.65094 13.3504 8.7334C13.4183 8.81102 13.4522 8.90803 13.4522 9.02445C13.4522 9.14572 13.3843 9.25728 13.2485 9.35915C13.1127 9.45616 12.9332 9.5362 12.7101 9.59926C12.4918 9.65747 12.2541 9.68657 11.997 9.68657C11.6138 9.68657 11.2815 9.59926 11.0002 9.42463C10.7188 9.24516 10.5005 9.00262 10.3453 8.69702C10.1949 8.39143 10.1198 8.04945 10.1198 7.67109C10.1198 7.27333 10.1998 6.92408 10.3599 6.62333C10.5248 6.31774 10.7504 6.08005 11.0366 5.91027C11.3276 5.73565 11.6599 5.64833 12.0334 5.64833Z",fill:"#3D3E45"}),n.jsx("path",{d:"M7.74826 5.64833C8.08781 5.64833 8.39099 5.73565 8.65778 5.91027C8.92942 6.08005 9.14285 6.31531 9.29807 6.61606C9.45815 6.9168 9.53819 7.26606 9.53819 7.66382C9.53819 8.06158 9.45815 8.41326 9.29807 8.71885C9.14285 9.0196 8.93184 9.25728 8.66505 9.43191C8.40311 9.60169 8.10722 9.68657 7.77737 9.68657C7.58334 9.68657 7.40143 9.65505 7.23166 9.59199C7.06188 9.52893 6.91151 9.44889 6.78054 9.35187C6.65442 9.25486 6.55498 9.15784 6.48222 9.06083C6.41431 8.95896 6.38035 8.87408 6.38035 8.80617L6.60591 8.71158V9.24273C6.60591 9.36885 6.56468 9.47557 6.48222 9.56288C6.39976 9.64534 6.29547 9.68657 6.16935 9.68657C6.04323 9.68657 5.93894 9.64534 5.85647 9.56288C5.77401 9.48042 5.73278 9.3737 5.73278 9.24273V4.67333C5.73278 4.54722 5.77401 4.44292 5.85647 4.36046C5.93894 4.27315 6.04323 4.22949 6.16935 4.22949C6.29547 4.22949 6.39976 4.27315 6.48222 4.36046C6.56468 4.44292 6.60591 4.54722 6.60591 4.67333V6.52147L6.48222 6.45598C6.48222 6.39292 6.51617 6.31774 6.58408 6.23042C6.652 6.13826 6.74416 6.04852 6.86058 5.96121C6.97699 5.86904 7.11039 5.79386 7.26076 5.73565C7.41599 5.67744 7.57849 5.64833 7.74826 5.64833ZM7.63912 6.44871C7.42569 6.44871 7.23893 6.50206 7.07886 6.60878C6.91879 6.7155 6.79267 6.86102 6.7005 7.04535C6.61319 7.22482 6.56953 7.43098 6.56953 7.66382C6.56953 7.8918 6.61319 8.10038 6.7005 8.28956C6.79267 8.47389 6.91879 8.61941 7.07886 8.72613C7.23893 8.83285 7.42569 8.8862 7.63912 8.8862C7.85255 8.8862 8.03688 8.83285 8.19211 8.72613C8.35218 8.61941 8.47587 8.47389 8.56319 8.28956C8.65535 8.10038 8.70143 7.8918 8.70143 7.66382C8.70143 7.43098 8.65535 7.22482 8.56319 7.04535C8.47587 6.86102 8.35218 6.7155 8.19211 6.60878C8.03688 6.50206 7.85255 6.44871 7.63912 6.44871Z",fill:"#3D3E45"}),n.jsx("path",{d:"M3.02845 5.66289L1.45681 9.35915C1.42286 9.45131 1.3695 9.52408 1.29674 9.57743C1.22883 9.62594 1.15364 9.65019 1.07118 9.65019C0.940211 9.65019 0.843196 9.61381 0.780136 9.54105C0.717077 9.46829 0.685547 9.37855 0.685547 9.27184C0.685547 9.22818 0.692823 9.1821 0.707375 9.13359L2.51913 4.78248C2.55793 4.68546 2.61614 4.61028 2.69375 4.55692C2.77622 4.50356 2.86353 4.48173 2.95569 4.49143C3.04301 4.49143 3.12304 4.51811 3.19581 4.57147C3.27342 4.61998 3.3292 4.69031 3.36316 4.78248L5.15308 9.04628C5.17733 9.10934 5.18946 9.16755 5.18946 9.2209C5.18946 9.35187 5.1458 9.45616 5.05849 9.53378C4.97603 9.61139 4.88386 9.65019 4.782 9.65019C4.69468 9.65019 4.61465 9.62352 4.54189 9.57016C4.47398 9.5168 4.42062 9.44404 4.38181 9.35187L2.81745 5.70654L3.02845 5.66289ZM1.68237 8.47146L2.08256 7.63471H4.04711L4.18536 8.47146H1.68237Z",fill:"#3D3E45"})]}),WM=()=>n.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[n.jsx("g",{clipPath:"url(#clip0_567_6919)",children:n.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M7.00001 1.02051C7.29533 1.02051 7.53473 1.25991 7.53473 1.55523V2.99492L11.3486 5.17429C11.5152 5.2695 11.6181 5.44667 11.6181 5.63856V9.97475L13.0725 10.702C13.3366 10.834 13.4437 11.1552 13.3116 11.4194C13.1795 11.6835 12.8583 11.7906 12.5942 11.6585L11.1002 10.9115L7.26531 13.1028C7.10091 13.1968 6.8991 13.1968 6.73471 13.1028L2.89985 10.9115L1.40581 11.6585C1.14167 11.7906 0.820476 11.6835 0.688405 11.4194C0.556335 11.1552 0.663399 10.834 0.92754 10.702L2.38195 9.97475V5.63856C2.38195 5.44667 2.48477 5.2695 2.65138 5.17429L6.46529 2.99492V1.55523C6.46529 1.25991 6.70469 1.02051 7.00001 1.02051ZM7.00001 3.9211L3.99444 5.63856L7.00001 7.35603L10.0056 5.63856L7.00001 3.9211ZM10.5486 6.55999L7.53473 8.28221V11.7171L10.5486 9.99492V6.55999ZM6.46529 11.7171V8.28221L3.4514 6.55999V9.99492L6.46529 11.7171Z",fill:"#3D3E45"})}),n.jsx("defs",{children:n.jsx("clipPath",{id:"clip0_567_6919",children:n.jsx("rect",{width:"14",height:"14",fill:"white"})})})]}),Xo=({type:e})=>{switch(e){case"boolean":return n.jsx(GM,{});case"date":return n.jsx(FM,{});case"number":return n.jsx(QM,{});case"string":return n.jsx(RM,{});case"dimension":return n.jsx(WM,{});default:return null}},UM={option:{fontFamily:"monospace","&.sub-option":{position:"relative",marginLeft:"22px"},"&.sub-option::before":{content:'""',width:"1px",height:"100%",position:"absolute",left:"-6px",borderLeft:"1px solid #E7E7E9"}},groupLabel:{cursor:"default",fontWeight:"normal","&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",borderBottom:"1px dashed var(--mantine-color-gray-2)"},"&::after":{borderBottom:"1px dashed var(--mantine-color-gray-2)",background:"none"}},group:{"&.dimension-group":{paddingBottom:"4px",".mantine-Combobox-groupLabel":{color:"#000"},".mantine-Combobox-groupLabel::before":{display:"none"},".mantine-Combobox-groupLabel::after":{display:"none"}}}},YM={root:{maxWidth:"unset"},option:{fontFamily:"monospace"},input:{paddingInlineStart:"var(--input-padding-inline-start)",color:"black",fontFamily:"monospace"}},Ag=(e,t,r)=>{const s=[];return t&&s.push("sub-option"),r&&s.push("disabled"),n.jsx(a.Combobox.Option,{value:e.value,className:s.join(" "),disabled:r,children:n.jsxs(a.Stack,{gap:1,children:[n.jsxs(a.Group,{gap:4,children:[n.jsx(Xo,{type:e.dataType}),n.jsx(a.Text,{size:"xs",children:e.label})]}),n.jsx(a.Text,{size:"xs",c:"dimmed",pl:18,children:e.description})]})},e.value)},Lg=k.observer(({mmInfo:e,value:t,onChange:r,usedKeys:s})=>{const i=e.metricDetail,o=e.metrics.loading||i.loading,l=i.error,c=i.filterColOptions,u=a.useCombobox({onDropdownClose:()=>u.resetSelectedOption()}),d=f.useMemo(()=>o?n.jsx(a.Loader,{size:"xs"}):t?n.jsx(a.CloseButton,{size:"xs",onClick:()=>r(null)}):n.jsx(a.Combobox.Chevron,{size:"xs"}),[o,t]),p=n.jsx(a.InputBase,{component:"button",type:"button",variant:"unstyled",size:"xs",pointer:!0,rightSection:d,rightSectionPointerEvents:!o&&t?"all":"none",onClick:()=>u.toggleDropdown(),disabled:o||c.length===0,styles:YM,error:!!l,children:t||n.jsx(a.Input.Placeholder,{children:"选择维度"})});return n.jsxs(a.Combobox,{store:u,onOptionSubmit:h=>{r(h),u.closeDropdown()},styles:UM,children:[n.jsx(a.Combobox.Target,{children:l?n.jsx(a.Tooltip,{label:l,children:p}):p}),n.jsx(a.Combobox.Dropdown,{miw:300,children:n.jsx(a.Combobox.Options,{children:c.map(({group:h,items:x})=>n.jsx(a.Combobox.Group,{label:h,children:x.map(b=>{var m;return"group"in b?n.jsx(a.Combobox.Group,{className:"dimension-group",label:n.jsxs(a.Group,{gap:4,children:[n.jsx(Xo,{type:"dimension"}),n.jsx(a.Text,{size:"sm",children:b.group}),n.jsx(a.Text,{size:"xs",c:"dimmed",children:b.description})]}),children:(m=b.items)==null?void 0:m.map(j=>Ag(j,!0,s.has(j.value)))},b.group):Ag(b,!1,s.has(b.value))})},h))})})]})}),Og={tbody:{td:{fontFamily:"monospace"}}},KM={root:{maxWidth:"unset"},option:{fontFamily:"monospace","&[data-checked=true][data-combobox-disabled]":{opacity:1}},input:{fontFamily:"monospace"},groupLabel:{"&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",backgroundColor:"var(--mantine-color-gray-2)"}}},XM=({option:e,...t})=>{const{t:r}=_.useTranslation(),s=e,i=s.type==="filter";return n.jsxs(a.Stack,{gap:0,py:4,styles:{root:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}}},...t,children:[n.jsx(a.Group,{flex:"1",gap:4,children:n.jsx(a.Text,{size:"xs",children:e.value})}),i&&n.jsxs(a.Group,{justify:"space-between",wrap:"nowrap",children:[n.jsx(a.Text,{size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",style:{flexShrink:1,flexGrow:1},children:s.widget_label}),n.jsx(a.Text,{size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",style:{flexShrink:0,flexGrow:0},children:r(rn[s.widget])})]})]})},Fs=k.observer(({queryModel:e,value:t,onChange:r,usedKeys:s})=>{const{t:i}=_.useTranslation();e.config;const o=f.useMemo(()=>e.getConditionOptionsWithInvalidValue(t).optionGroups.map(u=>{const d=u.items.length;return{group:`${i(u.group)}(${d})`,items:u.items.map(h=>({...h,label:h.value,widget_label:h.label,disabled:s.has(h.value)}))}}),[e.getConditionOptionsWithInvalidValue,i,t,s]),l=f.useCallback((c,u)=>{r(c,u)},[r]);return n.jsx(a.Select,{size:"xs",variant:"unstyled",placeholder:"选择变量",styles:KM,data:o,renderOption:XM,maxDropdownHeight:600,value:t,onChange:l,clearable:!0})}),Ho=k.observer(({variable:e})=>{const t=se();if(!e)return null;const r=v.has(t.queryVariables,e);return n.jsx(a.ThemeIcon,{variant:"white",size:"xs",color:r?"#88CE98":"#F15050",styles:{root:{flexGrow:0,flexShrink:0}},children:n.jsx(C.IconPointFilled,{})})}),HM=k.observer(({queryModel:e})=>{const t=e.config,s=e.datasource.mericoMetricInfo;return f.useEffect(()=>{s.selectMetric(t.id)},[t.id,s]),n.jsxs(a.Stack,{gap:7,children:[n.jsxs(a.Group,{justify:"flex-start",gap:8,children:[n.jsx(a.Text,{size:"sm",children:"看板变量与指标维度关联"}),n.jsx(a.Tooltip,{label:"将看板的筛选器参数与指标的查询维度关联上,使指标可以按照看板的筛选条件和背景变量进行关联展示。",children:n.jsx(a.ActionIcon,{size:"xs",variant:"subtle",color:"gray",children:n.jsx(C.IconInfoCircle,{})})})]}),n.jsxs(a.Table,{withTableBorder:!0,withColumnBorders:!0,layout:"fixed",styles:Og,children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:250}}),n.jsx("col",{}),n.jsx("col",{style:{width:130}}),n.jsx("col",{style:{width:40}})]}),n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:"指标筛选维度"}),n.jsx(a.Table.Td,{children:"看板变量"}),n.jsx(a.Table.Td,{colSpan:2,children:"变量值为真时运行查询"})]})}),n.jsxs(a.Table.Tbody,{children:[t.filters.map(i=>n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{pr:0,children:n.jsx(Lg,{mmInfo:s,value:i.dimension,onChange:i.setDimension,usedKeys:t.usedFilterDimensionKeys})}),n.jsx(a.Table.Td,{colSpan:2,pr:0,children:n.jsxs(a.Group,{justify:"flex-start",grow:!0,gap:0,w:"100%",children:[n.jsx(Ho,{variable:i.variable}),n.jsx(Fs,{queryModel:e,value:i.variable,onChange:i.setVariable,usedKeys:t.usedFilterVariableSet})]})}),n.jsx(a.Table.Td,{children:n.jsx(a.Checkbox,{size:"xs",checked:e.keyInRunBy(i.variable),onChange:o=>e.changeRunByRecord(i.variable,o.currentTarget.checked),color:"red"})})]},i.dimension)),n.jsxs(a.Table.Tr,{className:"add-a-row",children:[n.jsx(a.Table.Td,{pr:0,children:n.jsx(Lg,{mmInfo:s,value:null,onChange:i=>i&&t.addFilter(i,""),usedKeys:t.usedFilterDimensionKeys})}),n.jsx(a.Table.Td,{colSpan:2,pr:0,children:n.jsx(Fs,{queryModel:e,value:null,onChange:i=>i&&t.addFilter("",i),usedKeys:t.usedFilterVariableSet})}),n.jsx(a.Table.Td,{})]})]})]})]})}),ZM=k.observer(({queryModel:e,variable:t})=>{const r=e.keyInRunBy(t),s=i=>{e.changeRunByRecord(t,i.currentTarget.checked)};return n.jsx(a.Checkbox,{size:"xs",checked:r,onChange:s,color:"red"})}),Vg=({queryModel:e,variable:t})=>t?n.jsx(ZM,{queryModel:e,variable:t}):null,JM=k.observer(({queryModel:e})=>{const t=e.config,o=e.datasource.mericoMetricInfo.metricDetail.trendingDateCol;return!t.timeQuery.enabled||!o?null:n.jsxs(a.Table,{withTableBorder:!0,withColumnBorders:!0,layout:"fixed",styles:Og,children:[n.jsxs("colgroup",{children:[n.jsx("col",{style:{width:250}}),n.jsx("col",{}),n.jsx("col",{style:{width:130}}),n.jsx("col",{style:{width:40}})]}),n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{}),n.jsx(a.Table.Td,{children:"看板变量"}),n.jsx(a.Table.Td,{colSpan:2,children:"变量值为真时运行查询"})]})}),n.jsxs(a.Table.Tbody,{children:[n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{pr:0,children:n.jsxs(a.Group,{gap:4,children:[n.jsx(a.Text,{size:"xs",children:"时间维度:"}),n.jsx(a.Text,{size:"xs",c:"dimmed",ff:"monospace",children:o.name})]})}),n.jsx(a.Table.Td,{colSpan:2,pr:0,children:n.jsxs(a.Group,{justify:"flex-start",gap:0,grow:!0,children:[n.jsx(Ho,{variable:t.timeQuery.range_variable}),n.jsx(Fs,{queryModel:e,value:t.timeQuery.range_variable,onChange:t.setRangeVariable,usedKeys:t.usedTimeQueryVariableSet})]})}),n.jsx(a.Table.Td,{children:n.jsx(Vg,{queryModel:e,variable:t.timeQuery.range_variable})})]},"dimension.time"),n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:n.jsx(a.Text,{size:"xs",children:"步长"})}),n.jsx(a.Table.Td,{colSpan:2,pr:0,children:n.jsxs(a.Group,{justify:"flex-start",gap:0,grow:!0,children:[n.jsx(Ho,{variable:t.timeQuery.unit_variable}),n.jsx(Fs,{queryModel:e,value:t.timeQuery.unit_variable,onChange:t.setUnitVariable,usedKeys:t.usedTimeQueryVariableSet})]})}),n.jsx(a.Table.Td,{children:n.jsx(Vg,{queryModel:e,variable:t.timeQuery.unit_variable})})]},"dimension.step")]})]})}),e4=k.observer(({queryModel:e})=>{const t=e.config,o=e.datasource.mericoMetricInfo.metricDetail.trendingDateCol;return n.jsxs(a.Stack,{gap:7,children:[n.jsxs(a.Group,{justify:"flex-start",gap:8,children:[n.jsx(a.Text,{size:"sm",children:"按时间序列展示"}),n.jsx(a.Tooltip,{label:"将看板的时间&步长筛选器与相应的查询维度关联上。",children:n.jsx(a.ActionIcon,{size:"xs",variant:"subtle",color:"gray",children:n.jsx(C.IconInfoCircle,{})})}),o?n.jsx(a.Switch,{size:"xs",color:"red",checked:t.timeQuery.enabled,onChange:l=>t.setTimeQueryEnabled(l.currentTarget.checked)}):n.jsx(a.Tooltip,{label:"由于指标未设定时序维度,所以不具备时间序列展示功能。",children:n.jsx(a.Box,{children:n.jsx(a.Switch,{size:"xs",color:"red",disabled:!o})})})]}),n.jsx(JM,{queryModel:e})]})}),t4={label:{fontWeight:"normal"},input:{fontSize:"12px"},groupLabel:{cursor:"default",fontWeight:"normal","&::before":{content:'""',flex:1,insetInline:0,height:"calc(0.0625rem* var(--mantine-scale))",marginInlineEnd:"var(--mantine-spacing-xs)",borderBottom:"1px dashed var(--mantine-color-gray-2)"},"&::after":{borderBottom:"1px dashed var(--mantine-color-gray-2)",background:"none"}},option:{fontFamily:"monospace"}},n4=e=>{const t=e.option;return n.jsxs(a.Stack,{gap:1,styles:{root:{flexGrow:1}},children:[n.jsxs(a.Group,{gap:4,children:[n.jsx(Xo,{type:t.dataType}),n.jsx(a.Text,{size:"xs",children:t.label})]}),n.jsx(a.Text,{size:"xs",c:"dimmed",pl:18,children:t.description})]})},r4=k.observer(({queryModel:e})=>{const t=e.config,s=e.datasource.mericoMetricInfo,i=s.metricDetail,o=s.metrics.loading||i.loading,l=i.groupByColOptions,c=u=>{const d=i.getGroupByOptions(u),p=[];d.forEach(h=>{h.dimension?h.dimension.fields.forEach(x=>{p.push(`${h.value} -> ${x.field}`)}):p.push(h.value)}),t.setGroupBys(p)};return n.jsx(a.MultiSelect,{size:"sm",label:"分组聚合维度",description:"指标在查询时按照哪些维度进行聚合计算。最多支持两个维度的聚合计算。若选择按时间序列展示,则仅可选择一个聚合维度。",data:l,searchable:!0,styles:t4,renderOption:n4,rightSection:o?n.jsx(a.Loader,{size:"xs"}):null,value:[...t.groupByValues],onChange:c,maxValues:t.timeQuery.enabled?1:2,placeholder:t.timeQuery.enabled?"仅可选一个维度":"最多选两个维度",disabled:o})}),s4=k.observer(({queryModel:e})=>{const t=e.config,r=t.id;return f.useEffect(()=>{if(e.run_by.length===0)return;const s=[],i=t.usedFilterVariableSet,o=t.usedTimeQueryVariableSet;e.run_by.forEach(l=>{(i.has(l)||o.has(l))&&s.push(l)}),e.setRunBy(s)},[t.usedFilterVariableSet,t.usedTimeQueryVariableSet,e.run_by]),n.jsxs(a.Stack,{gap:16,pos:"relative",children:[!r&&n.jsx(a.Overlay,{color:"#fff",backgroundOpacity:.5,blur:3,children:n.jsx(a.Center,{h:"100%",children:n.jsx(a.Text,{size:"sm",c:"black",children:"请先选择指标"})})}),n.jsx(HM,{queryModel:e}),n.jsx(e4,{queryModel:e}),n.jsx(r4,{queryModel:e})]})}),i4=k.observer(({queryModel:e})=>(e.config,n.jsx(a.Stack,{children:n.jsx(Dt.CodeHighlight,{language:"json",sx:{width:"100%",height:"100%",minHeight:"400px",overflowY:"auto"},withCopyButton:!1,code:e.metricQueryPayloadString})}))),a4=["function process_result(resp, utils, state) {"," return resp.data","}"].join(`
|
|
518
|
-
`),o4={root:{minHeight:"350px",maxHeight:"50vh",height:"100%",overflow:"hidden"},list:{"&::before":{borderColor:"transparent"}},panel:{height:"calc(100% - 36px)",overflowY:"auto"}},l4=k.observer(({queryModel:e})=>{const[t,r]=f.useState("编辑查询");return n.jsxs(a.Tabs,{color:"red",defaultValue:"编辑查询",styles:o4,value:t,onChange:r,children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"编辑查询",size:"xs",children:"编辑查询"}),n.jsx(a.Tabs.Tab,{value:"加工结果",size:"xs",children:"加工结果"}),n.jsx(a.Tabs.Tab,{value:"使用情况",size:"xs",children:"使用情况"}),n.jsx(a.Tabs.Tab,{value:"预览查询",size:"xs",leftSection:n.jsx(C.IconEye,{size:14}),ml:"auto",children:"预览查询"})]}),n.jsx(a.Tabs.Panel,{value:"编辑查询",pt:"xs",children:n.jsx(s4,{queryModel:e})}),n.jsx(a.Tabs.Panel,{value:"加工结果",pt:"xs",children:n.jsx(Sn,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:a4})}),n.jsx(a.Tabs.Panel,{value:"使用情况",pt:"xs",children:n.jsx(Ig,{queryModel:e})}),n.jsx(a.Tabs.Panel,{value:"预览查询",pt:"xs",children:n.jsx(i4,{queryModel:e})})]})}),c4=k.observer(()=>{const e=se();return n.jsxs(a.Stack,{styles:{root:{borderRadius:4,backgroundColor:"#F9F9FA",height:"100%",minHeight:"350px",maxHeight:"50vh",overflow:"hidden"}},children:[n.jsx(a.Box,{py:7,px:8,children:n.jsx(a.Text,{fw:"bold",size:"sm",children:"看板变量预览"})}),n.jsx(Dt.CodeHighlight,{language:"json",sx:{width:"100%",height:"100%",minHeight:"400px",overflowY:"auto"},withCopyButton:!1,code:e.queryVariablesString})]})}),u4=k.observer(({queryModel:e})=>{const t=e.metricQueryPayloadError;return t.length>0?n.jsxs(a.HoverCard,{shadow:"md",children:[n.jsx(a.HoverCard.Target,{children:n.jsx(a.Box,{children:n.jsx(a.Button,{size:"xs",leftSection:n.jsx(Eg,{width:14,height:14,color:"rgb(173, 181, 189)"}),variant:"filled",color:"red",disabled:!0,children:"执行查询"})})}),n.jsx(a.HoverCard.Dropdown,{children:n.jsx(a.List,{size:"xs",children:t.map(r=>n.jsx(a.List.Item,{children:r},r))})})]}):n.jsx(a.Button,{size:"xs",leftSection:n.jsx(Eg,{width:14,height:14}),variant:"filled",color:"red",onClick:()=>e.fetchData(!0),children:"执行查询"})}),d4=({option:e,...t})=>{const r=e;return n.jsxs(a.Stack,{gap:0,py:4,styles:{root:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}}},...t,children:[n.jsxs(a.Group,{flex:"1",gap:4,children:[n.jsx(C.IconHash,{size:12}),n.jsx(a.Text,{size:"xs",children:r.label})]}),n.jsx(a.Text,{ml:16,size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",children:r.description})]})},p4=k.observer(({queryModel:e})=>{const t=e.config,s=e.datasource.mericoMetricInfo,i=s.metrics;f.useEffect(()=>{i.load()},[i]),f.useEffect(()=>{!s.metricID&&t.id&&s.selectMetric(t.id)},[t.id]);const o=f.useMemo(()=>i.data.map(d=>({label:d.name,value:d.id,description:d.description})),[i.data]),l=f.useCallback(d=>{d&&(s.selectMetric(d),t.setID(d))},[s,t]),{loading:c,error:u}=i;return n.jsx(Ie,{children:n.jsxs(a.Group,{justify:"flex-end",gap:12,align:"flex-end",children:[u?n.jsx(a.Tooltip,{label:u,children:n.jsx(a.Select,{size:"xs",label:"指标",error:!0,styles:{root:{flexGrow:1}}})}):n.jsx(a.Select,{size:"xs",label:"指标",data:o,renderOption:d4,styles:{root:{flexGrow:1}},maxDropdownHeight:500,value:t.id,onChange:l,rightSection:c?n.jsx(a.Loader,{size:"xs"}):null}),n.jsx(a.Tooltip,{label:"跳转到指标明细页查看详情。",disabled:c,children:n.jsx(a.Anchor,{size:"md",variant:"subtle",mb:2,href:`/admin/metrics/detail/${t.id}`,target:"_blank",underline:"never",children:n.jsx(IM,{width:14,height:14})})})]})})}),h4=k.observer(({queryModel:e})=>{const{t}=_.useTranslation();return n.jsxs(a.Stack,{pt:8,pb:16,px:24,gap:8,styles:{root:{height:"100vh",overflow:"hidden"}},children:[n.jsx(a.Group,{styles:{root:{flexGrow:0,flexShrink:0}},children:n.jsx(a.TextInput,{size:"xs",placeholder:t("query.name_description"),label:t("query.name"),value:e.name,onChange:r=>{e.setName(r.currentTarget.value)},styles:{root:{flexGrow:0,width:"calc(50% - 44px)"}}})}),n.jsxs(a.Group,{justify:"space-between",grow:!0,gap:8,align:"flex-end",styles:{root:{flexGrow:0,flexShrink:0}},children:[n.jsxs(a.Group,{justify:"flex-start",grow:!0,gap:24,align:"flex-end",children:[n.jsx(kg,{queryModel:e,size:"xs"}),n.jsx(p4,{queryModel:e})]}),n.jsxs(a.Group,{justify:"flex-end",children:[n.jsx(u4,{queryModel:e}),n.jsx(PM,{queryModel:e})]})]}),n.jsxs(a.Group,{justify:"space-between",grow:!0,gap:12,align:"flex-start",sx:{flexGrow:0,flexShrink:1,overflowY:"hidden"},children:[n.jsx(l4,{queryModel:e}),n.jsx(c4,{})]}),n.jsx($M,{queryModel:e})]})}),g4=k.observer(({id:e})=>{const r=re().queries.findByID(e);return e===""?null:r?r.isMericoMetricQuery?n.jsx(h4,{queryModel:r}):n.jsx(zM,{queryModel:r}):n.jsx(a.Text,{size:"14px",c:"red",children:"Invalid Query ID"})}),f4=k.observer(({value:e})=>{const r=Te().payloadForSQL,s=f.useMemo(()=>Hs(e,r),[e,r]);return n.jsx(fa,{height:"100%",value:s})}),x4=k.observer(({item:e,remove:t,onKeyChanged:r})=>{const{t:s}=_.useTranslation(),[i,o]=f.useState("SQL"),[l,c]=f.useState(e.key),u=()=>{e.setKey(l),r(l)},d=l!==e.key,p=e.isADuplicatedKey(l),[h,x]=f.useState(e.value),b=()=>{e.setValue(h)};f.useEffect(()=>{c(e.key),x(e.value)},[e]);const m=h!==e.value,j=dt.useModals(),D=()=>{j.openConfirmModal({title:`${s("sql_snippet.delete")}?`,labels:{confirm:s("common.actions.confirm"),cancel:s("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:t,confirmProps:{color:"red"},zIndex:320})};return n.jsxs(a.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},gap:"sm",children:[n.jsxs(a.Group,{sx:{alignItems:"end"},gap:40,children:[n.jsx(a.TextInput,{label:s(p?"sql_snippet.key_occupied":"sql_snippet.key"),value:l,onChange:T=>{c(T.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:n.jsx(a.ActionIcon,{color:"blue",variant:"subtle",onClick:u,disabled:!d||p,children:n.jsx(C.IconDeviceFloppy,{size:16})}),error:p}),n.jsx(a.Button,{leftSection:n.jsx(C.IconTrash,{size:16}),color:"red",variant:"light",onClick:D,children:s("sql_snippet.delete")})]}),n.jsxs(a.Tabs,{value:i,onChange:o,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[n.jsxs(a.Tabs.List,{sx:{position:"relative"},children:[n.jsx(a.Tabs.Tab,{value:"SQL",children:s("sql_snippet.edit_snippet")}),n.jsx(a.Tabs.Tab,{value:"Preview",children:s("sql_snippet.preview_snippet")}),n.jsx(Ko,{}),n.jsx(a.ActionIcon,{color:"blue",variant:"filled",onClick:b,disabled:!m,sx:{position:"absolute",top:0,right:10},children:n.jsx(C.IconDeviceFloppy,{size:18})})]}),n.jsx(a.Tabs.Panel,{value:"SQL",pt:"sm",children:n.jsx(fa,{height:"100%",value:h,onChange:x,defaultLanguage:"sql",theme:"sql-dark"})}),n.jsx(a.Tabs.Panel,{value:"Preview",pt:"sm",children:n.jsx(f4,{value:h})})]})]})}),m4=k.observer(({id:e})=>{const t=se(),r=re(),s=f.useMemo(()=>r.sqlSnippets.findByKey(e),[e]);if(!e)return null;if(!s)return n.jsxs(a.Text,{size:"14px",children:["SQL Snippet by key[",e,"] is not found"]});const i=()=>{t.editor.setPath(["_SQL_SNIPPETS_",""])},o=()=>{r.sqlSnippets.removeByKey(e),i()},l=c=>{t.editor.setPath(["_SQL_SNIPPETS_",c])};return n.jsx(x4,{item:s,remove:o,onKeyChanged:l})}),b4=k.observer(()=>{const{t:e}=_.useTranslation(),[t,r]=f.useState([]),s=dt.useModals(),i=se(),o=x=>{i.editor.setPath(["_SQL_SNIPPETS_",x])},l=()=>{s.openConfirmModal({title:"Delete ununsed SQL snippets?",children:n.jsx(a.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.content.removeUnusedSQLSnippets(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.sqlSnippets.downloadSchema(t)},u=f.useMemo(()=>i.content.sqlSnippets.sortedList.map(x=>x.key),[i.content.sqlSnippets.sortedList]),d=()=>{r(u)},p=()=>{r([])},h=i.content.sqlSnippetsUsage;return n.jsxs(a.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(a.Text,{size:"sm",px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("sql_snippet.manage")})}),n.jsxs(a.Flex,{justify:"space-between",align:"center",px:12,children:[n.jsxs(a.Group,{justify:"flex-start",children:[n.jsxs(a.Button.Group,{children:[n.jsx(a.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),n.jsx(a.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),n.jsx(a.Button,{size:"xs",color:"blue",leftSection:n.jsx(C.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),n.jsx(a.Button,{variant:"subtle",size:"xs",color:"red",leftSection:n.jsx(C.IconTrash,{size:14}),disabled:!i.content.hasUnusedSQLSnippets,onClick:l,children:e("sql_snippet.delete_unused")})]}),n.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(a.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"40px"}}),n.jsx(a.Table.Th,{children:e("common.key")}),n.jsx(a.Table.Th,{style:{width:"100px",textAlign:"center"},children:e("sql_snippet.usage.label")}),n.jsx(a.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(a.Table.Tbody,{children:i.content.sqlSnippets.sortedList.map(x=>{var m;const b=((m=h[x.key])==null?void 0:m.length)??0;return n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:n.jsx(a.Checkbox,{value:x.key,styles:{input:{cursor:"pointer"}}})}),n.jsx(a.Table.Td,{children:x.key}),n.jsx(a.Table.Td,{style:{color:b===0?"#ff0000":"#000",fontWeight:b===0?"bold":"normal",textAlign:"center"},children:b}),n.jsx(a.Table.Td,{children:n.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>o(x.key),children:e("common.actions.open")})})]},x.key)})})]})})})]})}),y4=k.observer(({view:e})=>!e||e.type!==F.Division?null:n.jsx(a.Stack,{})),v4=k.observer(({view:e})=>{const{t,i18n:r}=_.useTranslation(),s=f.useMemo(()=>[{value:"default",label:t("common.tabs.variant.default")},{value:"outline",label:t("common.tabs.variant.outline")},{value:"pills",label:t("common.tabs.variant.pills")}],[r.language]),i=f.useMemo(()=>[{value:"horizontal",label:t("common.tabs.orientation.horizontal")},{value:"vertical",label:t("common.tabs.orientation.vertical")}],[r.language]);if(!e||e.type!==F.Tabs)return null;const o=e.config;return n.jsxs(a.Stack,{children:[n.jsx(a.Divider,{mt:8,mb:0,label:t("view.component.tabs.tabs_settings"),labelPosition:"center"}),n.jsx(a.Select,{label:t("common.tabs.variant.label"),value:o.variant,onChange:o.setVariant,data:s}),n.jsx(a.Select,{label:t("common.tabs.orientation.label"),value:o.orientation,onChange:o.setOrientation,data:i}),n.jsx(a.Switch,{label:t("common.tabs.grow_tabs"),checked:o.grow,onChange:l=>o.setGrow(l.currentTarget.checked)})]})}),_4=({disabled:e,value:t,onChange:r})=>{const s=i=>{i&&r(i)};return n.jsxs(a.Box,{sx:{position:"relative"},children:[e&&n.jsx(a.Overlay,{backgroundOpacity:.6,color:"#fff",zIndex:5,blur:2}),n.jsx(ht,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},j4=({value:e,onChange:t})=>{const{t:r}=_.useTranslation(),[s,{setTrue:i,setFalse:o}]=Y.useBoolean(),[l,c]=f.useState(e??Ps),u=b=>{c({...l,enabled:b})},d=()=>{o();const{enabled:b,func_content:m}=l,j={enabled:b,func_content:m};c(j),t(j)},p=()=>{o(),c(e)},h=b=>{c(m=>({...m,func_content:b}))},x=()=>{h(Ps.func_content)};return n.jsxs(n.Fragment,{children:[n.jsx(a.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:i,sx:{flexGrow:0},children:n.jsx(C.IconSettings,{size:14})}),n.jsx(a.Modal,{size:800,title:r("view.component.modal.custom_title"),opened:s,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&n.jsxs(a.Stack,{children:[n.jsx(a.Checkbox,{mt:10,label:r("common.enabled"),checked:l.enabled,onChange:b=>u(b.currentTarget.checked)}),n.jsx(_4,{value:l.func_content,onChange:h,disabled:!l.enabled}),n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Button,{onClick:x,color:"red",leftSection:n.jsx(C.IconRecycle,{size:20}),children:r("common.actions.revert")}),n.jsxs(a.Group,{justify:"flex-end",children:[n.jsx(a.Button,{onClick:p,variant:"subtle",children:r("common.actions.cancel")}),n.jsx(a.Button,{onClick:d,children:r("common.actions.save")})]})]})]})})]})},w4=k.observer(({view:e})=>{const{t}=_.useTranslation();if(!e||e.type!==F.Modal)return null;const r=e.config,s=r.custom_modal_title.value;return n.jsxs(a.Stack,{children:[n.jsx(a.Divider,{mt:8,label:t("view.component.modal.modal_settings"),labelPosition:"center"}),n.jsxs(a.Flex,{gap:10,children:[n.jsx(a.TextInput,{label:t("view.component.modal.title"),value:s,onChange:v.noop,disabled:!0,sx:{flexGrow:1}}),n.jsx(j4,{value:r.custom_modal_title,onChange:r.custom_modal_title.replace})]}),n.jsxs(a.Group,{grow:!0,children:[n.jsx(a.TextInput,{label:t("view.component.modal.width"),value:r.width,onChange:i=>r.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),n.jsx(a.TextInput,{label:t("view.component.modal.height"),value:r.height,onChange:i=>r.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),C4=k.observer(({view:e})=>n.jsxs(n.Fragment,{children:[n.jsx(y4,{view:e}),n.jsx(w4,{view:e}),n.jsx(v4,{view:e})]})),S4=k.observer(({view:e})=>{const{t,i18n:r}=_.useTranslation(),s=f.useMemo(()=>[{label:t("view.component.div.label"),value:F.Division},{label:t("view.component.modal.label"),value:F.Modal},{label:t("view.component.tabs.label"),value:F.Tabs}],[r.language]);return e?n.jsxs(a.Stack,{sx:{position:"relative"},children:[n.jsx(a.TextInput,{label:t("common.name"),value:e.name,onChange:i=>{e.setName(i.currentTarget.value)}}),n.jsx(a.Select,{label:t("common.type"),comboboxProps:{withinPortal:!0,zIndex:320},value:e.type,onChange:e.setType,data:s}),n.jsx(C4,{view:e})]}):null}),T4=k.observer(({id:e})=>{const{t}=_.useTranslation(),r=dt.useModals(),s=se(),i=re();if(e==="")return null;const o=i.views.findByID(e);if(!o)return n.jsxs(a.Text,{size:"14px",children:["View by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_VIEWS_",""])},c=()=>{r.openConfirmModal({title:`${t("view.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.views.removeByID(e),l()},confirmProps:{color:"red"},zIndex:320})};return n.jsxs(a.Stack,{sx:{maxWidth:"600px",height:"100%"},gap:"sm",children:[n.jsx(a.Group,{justify:"flex-end",pt:10,children:n.jsx(a.Button,{size:"xs",color:"red",leftSection:n.jsx(C.IconTrash,{size:16}),onClick:c,children:t("view.delete")})}),n.jsx(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n.jsx(S4,{view:o})})]})}),k4=k.observer(()=>n.jsx(a.Stack,{sx:{height:"100%"},p:"sm",children:n.jsx(Dg,{})})),D4=k.observer(()=>{const e=se().editor,t=e.path;return F5(t)?n.jsx(k4,{}):Q5(t)?n.jsx(mI,{}):R5(t)?n.jsx(xI,{}):W5(t)?n.jsx(a.Box,{p:"xs",pl:20,children:n.jsx(fI,{id:t[1]})}):U5(t)?n.jsx(b4,{}):Y5(t)?n.jsx(m4,{id:t[1]}):X5(t)?n.jsx(XI,{}):K5(t)?n.jsx(g4,{id:t[1]}):H5(t)?n.jsx(a.Box,{p:"xs",pl:20,children:n.jsx(T4,{id:t[1]})}):No(t)?n.jsx(KI,{viewID:t[1],panelID:t[3]}):n.jsx(a.Box,{children:e.path})}),z4=k.observer(()=>n.jsx(D4,{})),I4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=()=>{const s=new Date().getTime().toString(),i={id:s,key:s,label:s,order:t.content.filters.current.length+1,type:Q.TextInput,config:fo(),visibleInViewsIDs:["Main"],auto_submit:!1};t.content.filters.append(i),t.editor.setPath(["_FILTERS_",s])};return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("filter.add")})}),M4=k.observer(({parentID:e})=>{const{t}=_.useTranslation(),r=re();if(!e)return null;const s=r.views.findByID(e);return!s||s.type===F.Tabs?null:n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>r.addANewPanel(s.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("panel.add")})}),E4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=()=>{const s=new Date().getTime().toString(),i={id:s,name:s,type:J.Postgresql,key:"",config:{_type:J.Postgresql,sql:""}};t.content.queries.append(i),t.editor.setPath(["_QUERIES_",s])};return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("query.add")})}),P4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=()=>{const s=new Date().getTime().toString(),i={key:s,value:""};t.content.sqlSnippets.append(i),t.editor.setPath(["_SQL_SNIPPETS_",s])};return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("sql_snippet.add")})}),A4=k.observer(()=>{const{t:e}=_.useTranslation(),t=re();return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("view.add")})}),L4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_QUERIES_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("query.manage")})}),O4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_SQL_SNIPPETS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("sql_snippet.manage")})}),V4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_FILTERS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("filter.manage")})}),B4=k.observer(({action_type:e,parentID:t})=>e==="_Add_A_Filter_"?n.jsx(I4,{}):e==="_Add_A_SQL_SNIPPET_"?n.jsx(P4,{}):e==="_Add_A_QUERY_"?n.jsx(E4,{}):e==="_Add_A_VIEW_"?n.jsx(A4,{}):e==="_Add_A_PANEL_"?n.jsx(M4,{parentID:t}):e==="_QUERIES_SETTINGS_"?n.jsx(L4,{}):e==="_SQL_SNIPPETS_SETTINGS_"?n.jsx(O4,{}):e==="_FILTERS_SETTINGS_"?n.jsx(V4,{}):null),Bg=k.observer(({option:e})=>{var p;const{t}=_.useTranslation(),r=se().editor,s=r.isOptionActive,i=s(r.path,e),o=r.isOptionOpened,l=r.navigate,c=o(e),[u,d]=f.useState(c);return f.useEffect(()=>{d(c)},[c]),n.jsx(a.NavLink,{active:i,defaultOpened:c,opened:u,onChange:d,label:t(e.label),onClick:()=>l(e),leftSection:e.Icon?n.jsx(e.Icon,{size:18}):null,children:(p=e.children)==null?void 0:p.map(h=>h._type==="ACTION"?n.jsx(B4,{action_type:h._action_type,parentID:h.parentID},`_ADD_${h.value}_`):n.jsx(Bg,{option:h},h.value))},e.label)}),q4=k.observer(()=>{const e=se();return n.jsx(a.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>n.jsx(Bg,{option:t},t.value))})}),N4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsxs(a.AppShell.Navbar,{p:0,sx:{height:"100vh - 60px - 60px",".mantine-NavLink-body":{wordWrap:"break-word"}},children:[n.jsx(a.AppShell.Section,{sx:{borderBottom:"1px solid #eee",padding:"var(--mantine-spacing-xs) var(--mantine-spacing-md)"},children:n.jsx(a.Text,{size:"sm",ta:"center",sx:{userSelect:"none",cursor:"default"},children:e("common.titles.settings")})}),n.jsx(a.AppShell.Section,{grow:!0,sx:{overflow:"auto"},children:n.jsx(q4,{})}),n.jsx(a.AppShell.Section,{children:n.jsx(a.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n.jsx(a.Button,{size:"xs",color:"red",leftSection:n.jsx(C.IconX,{size:18}),onClick:()=>t.editor.close(),children:e("common.actions.close")})})})]})}),$4={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden",minWidth:"calc(var(--app-shell-navbar-width, 0px) + 1200px)"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},G4=k.observer(()=>{const e=se().editor;return n.jsx(a.Modal,{onClose:()=>e.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:e.settings_open,fullScreen:!0,title:null,transitionProps:{duration:0},withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{body:{padding:"0 !important"},content:{overflowY:"hidden !important"}},children:n.jsxs(a.AppShell,{padding:0,navbar:{width:{base:220,xs:220,sm:240,md:260,lg:300,xl:320},breakpoint:"xxs"},styles:$4,children:[n.jsx(N4,{}),n.jsx(a.AppShell.Main,{children:n.jsx(z4,{})})]})})}),F4=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function Q4(e){f.useEffect(()=>{if(ht.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const r=F4(e);ht.loader.config({paths:{vs:r}}),ht.loader.init().then(s=>console.log("monaco instance:",s))},[])}Hl(),bd();const R4={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden","--app-shell-header-offset":"calc(3.75rem * var(--mantine-scale))"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},W4=({context:e,dashboard:t,content:r,update:s,className:i="dashboard",config:o,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h},x)=>{Q4(o.monacoPath),Zs(o);const{data:b=[]}=Y.useRequest(ba),{data:m=[]}=Y.useRequest(yd),j=f.useMemo(()=>ig(t,r,b,m,e,u??{}),[t,r]);f.useImperativeHandle(x,()=>j,[j]),og(j.content,!0),f.useEffect(()=>{j.context.replace(e)},[e]),f.useEffect(()=>{j.datasources.replace(b)},[b]),f.useEffect(()=>{j.globalSQLSnippets.replace(m)},[m]),f.useEffect(()=>{d==null||d(j.content.filters.values)},[d,j.content.filters.values]),f.useEffect(()=>{u&&j.content.filters.patchValues(u)},[u,j.content.filters.patchValues]),f.useEffect(()=>te.reaction(()=>te.toJS(j.json),I=>{l==null||l(I)}),[j]);const D=async()=>{await s(j.json,j.content.json)},T=Y.useCreation(no,[]),z=lg(T);return Y.useWhyDidYouUpdate("@devtable/dashboard editor",{context:e,dashboard:t,content:r,update:s,className:i,config:o,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h}),n.jsx(on.MantineEmotionProvider,{children:n.jsx(ag,{lang:h,children:n.jsx(dt.ModalsProvider,{children:n.jsx(li,{children:n.jsx(ri,{value:{searchButtonProps:o.searchButtonProps},children:n.jsx(ti,{value:j,children:n.jsx(si,{value:j.content,children:n.jsxs($r.Provider,{value:{inEditMode:!0},children:[n.jsx(Tz,{}),n.jsx(tn.Provider,{value:T,children:n.jsxs(Ms,{configure:z,children:[n.jsxs(a.AppShell,{padding:0,navbar:{width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},breakpoint:"xxs"},styles:R4,children:[n.jsx(Iz,{onExit:p,saveDashboardChanges:D,headerSlot:c}),n.jsx(rI,{}),n.jsx(a.AppShell.Main,{children:n.jsx(a.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:j.content.views.visibleViews.map(I=>n.jsx(Rh,{view:I},I.id))})})]}),n.jsx(G4,{})]})})]})})})})})})})})},U4=k.observer(f.forwardRef(W4)),CE="",Zo=g.types.model({id:g.types.string,name:g.types.string,dashboard_id:g.types.string,create_time:g.types.string,update_time:g.types.string,version:g.types.string,filters:Io,queries:Po,sqlSnippets:Lo,views:ko,panels:zo,layouts:Ao,mock_context:so}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,layouts:e.layouts.json,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get contentJSON(){return this.json.content},get payloadForSQL(){const t=g.getParent(e).context.current,r=g.getParent(e).globalSQLSnippets,s={context:{...e.mock_context.current,...t},filters:e.filters.valuesForPayload};return{...s,sql_snippets:Ir(e.sqlSnippets.current,"key","value",s),global_sql_snippets:Ir(r.list,"id","content",s)}},get payloadForViz(){const t=g.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.valuesForPayload}},get dashboardState(){return ma(this.payloadForSQL)},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardState}},get data(){return e.queries.current.map(({id:r,data:s})=>({id:r,data:s})).reduce((r,s)=>(r[s.id]=s.data,r),{})},getDataStuffByID(t){const r=e.queries.findByID(t);return r?{data:r.data,len:r.data.length,state:r.state,error:r.error??r.metricQueryPayloadErrorString}:{data:[],len:0,state:"idle",error:void 0}}})).actions(e=>({}));function qg({id:e,name:t,dashboard_id:r,create_time:s,update_time:i,content:o},l,c,u){if(!o)throw new Error("unexpected null content when creating a content model");const{version:d,filters:p,views:h,panels:x,layouts:b,definition:{queries:m,sqlSnippets:j,mock_context:D={}}}=o;return Zo.create({id:e,name:t,dashboard_id:r,create_time:s,update_time:i,version:d,filters:Mo(p,l,D,c),queries:jh(m),sqlSnippets:Sh(j),mock_context:io(D),views:ph(h,u),panels:{list:x},layouts:{list:b,currentBreakpoint:b[0].id}})}const Ng=g.types.model({id:g.types.identifier,name:g.types.string,group:g.types.string,content:Zo,content_id:g.types.string,datasources:uh,globalSQLSnippets:Co,context:As});function $g({id:e,name:t,group:r,content_id:s},i,o,l,c,u,d){return Ng.create({id:e,name:t,group:r,content_id:s,content:qg(i,c,u,d),datasources:{list:o},globalSQLSnippets:{list:l},context:So(c)})}Hl(),bd();const Y4=({context:e,dashboard:t,content:r,className:s="dashboard",config:i,fullScreenPanelID:o,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h})=>{Zs(i);const{data:x=[]}=Y.useRequest(ba),{data:b=[]}=Y.useRequest(yd),m=f.useMemo(()=>$g(t,r,x,b,e,c??{},d??null),[t,r,d]);og(m.content,!1),f.useEffect(()=>{m.context.replace(e)},[e]),f.useEffect(()=>{m.datasources.replace(x)},[x]),f.useEffect(()=>{m.globalSQLSnippets.replace(b)},[b]),f.useEffect(()=>{console.log("⚪️ calling onFilterValuesChange: ",m.content.filters.values),u==null||u(m.content.filters.values)},[u,m.content.filters.valuesString]),f.useEffect(()=>{c&&m.content.filters.patchValues(c)},[c,m.content.filters.patchValues]),f.useEffect(()=>{p==null||p(m.content.views.firstVisibleTabsViewActiveTab)},[p,m.content.views.firstVisibleTabsViewActiveTabStr]),f.useEffect(()=>{d&&m.content.views.setFirstVisibleTabsViewActiveTab(d)},[d,m.content.views.setFirstVisibleTabsViewActiveTab]);const j=Y.useCreation(no,[]),D=lg(j);return Y.useWhyDidYouUpdate("@devtable/dashboard render",{context:e,dashboard:t,content:r,className:s,config:i,fullScreenPanelID:o,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h}),n.jsx(on.MantineEmotionProvider,{children:n.jsx(ag,{lang:h,children:n.jsx(dt.ModalsProvider,{children:n.jsx(li,{children:n.jsx(ri,{value:{searchButtonProps:i.searchButtonProps},children:n.jsx(ti,{value:m,children:n.jsx(si,{value:m.content,children:n.jsx(oi.Provider,{value:{fullScreenPanelID:o,setFullScreenPanelID:l},children:n.jsx($r.Provider,{value:{inEditMode:!1},children:n.jsx(a.Box,{className:`${s} dashboard-root`,children:n.jsx(tn.Provider,{value:j,children:n.jsx(Ms,{configure:D,children:m.content.views.visibleViews.map(T=>n.jsx(Vs,{view:T},T.id))})})})})})})})})})})})})},K4=k.observer(Y4);A.extend(pf),A.extend(hf),A.extend(gf),A.extend(ff),A.extend(xf),A.extend(mf),A.extend(bf),A.extend(yf),A.extend(vf),A.extend(_f),A.extend(Cf),A.extend(Sf),A.extend(Tf),A.extend(kf),A.extend(Df),A.extend(jf),A.extend(wf),A.extend(zf),A.extend(If),A.extend(Mf),A.extend(Ef),A.extend(Pf),A.extend(Af),A.extend(Lf),A.extend(Of),A.extend(Vf),A.extend(Bf),A.extend(qf),A.extend(Nf),A.extend($f),A.extend(Ff),A.extend(Qf),A.extend(Gf),A.tz.setDefault("UTC"),A.updateLocale("en",{weekStart:1});const X4=()=>Promise.resolve().then(()=>zy).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));w.APIClient=gt,w.CURRENT_SCHEMA_VERSION=nn,w.ContentModel=Go,w.ContentModelContextProvider=si,w.ContentRenderModel=Zo,w.ContextMeta=As,w.DEFAULT_CUSTOM_MODAL_TITLE=Ps,w.DashboardApiClient=El,w.DashboardApiFacadeClient=Pl,w.DashboardEditor=U4,w.DashboardFilterType=Q,w.DashboardMode=Wh,w.DashboardModel=sg,w.DashboardModelContextProvider=ti,w.DashboardRenderModel=Ng,w.DashboardThemeContextProvider=ri,w.DashboardViewEditor=Rh,w.DashboardViewRender=Vs,w.DataSourceMetaModel=wo,w.DataSourceType=J,w.DataSourcesMetaModel=uh,w.DatesProvider=li,w.DefaultApiClient=Ml,w.DescriptionPopover=Oo,w.DraftModel=Th,w.EViewComponentType=F,w.FacadeApiClient=ix,w.FilterCheckboxConfigMeta=oo,w.FilterDateRangeConfigMeta=co,w.FilterMeta=yo,w.FilterMultiSelectConfigMeta=po,w.FilterSelectConfigMeta=ho,w.FilterTextInputConfigMeta=go,w.FilterTreeSelectConfigMeta=mo,w.FilterTreeSingleSelectConfigMeta=bo,w.FiltersModel=Yh,w.FiltersRenderModel=Io,w.FullScreenPanel=Nh,w.FullScreenPanelContext=oi,w.GlobalSQLSnippetMeta=dh,w.GlobalSQLSnippetsMeta=Co,w.LayoutItemMeta=Gp,w.LayoutSetMeta=Fp,w.LayoutStateContext=$r,w.LayoutsRenderModel=Ao,w.MericoMetricQueryMeta=ao,w.MockContextMeta=so,w.MuteQueryModel=_h,w.Panel=qh,w.PanelContextProvider=ii,w.PanelErrorOrStateMessage=Vh,w.PanelMeta=Lp,w.PanelModel=eg,w.PanelRender=Bo,w.PanelRenderModel=Do,w.PanelStyleMeta=Mp,w.PanelTitleMeta=Ep,w.PanelVizMeta=Ap,w.PanelVizSection=Vo,w.PanelsModel=tg,w.PanelsRenderModel=zo,w.QueriesModel=Xh,w.QueriesRenderModel=Po,w.QueryMeta=$p,w.QueryModel=Kh,w.QueryRenderModel=Eo,w.ReadOnlyDashboard=K4,w.SQLSnippetMeta=Qp,w.SQLSnippetRenderModel=Ch,w.SQLSnippetsModel=Hh,w.SQLSnippetsRenderModel=Lo,w.VariableMeta=Pp,w.ViewComponentTypeBackground=Uh,w.ViewComponentTypeColor=k5,w.ViewComponentTypeName=T5,w.ViewDivisionConfig=vo,w.ViewMeta=ch,w.ViewModalConfig=_o,w.ViewRenderModel=To,w.ViewTabsConfig=jo,w.ViewsModel=ng,w.ViewsRenderModel=ko,w.Viz=Oh,w.applyPartialDashboard=rz,w.configureAPIClient=Zs,w.createContentModel=rg,w.createContentRenderModel=qg,w.createContextMeta=So,w.createDashboardModel=ig,w.createDashboardRenderModel=$g,w.createDraft=kh,w.createFilterCheckboxConfig=Rp,w.createFilterDateRangeConfig=Xp,w.createFilterMultiSelectConfig=Zp,w.createFilterSelectConfig=Jp,w.createFilterTextInputConfig=fo,w.createFilterTreeSelectConfig=sh,w.createFilterTreeSingleSelectConfig=ih,w.createMericoMetricQueryMetaConfig=Np,w.createViewDivisionConfig=ah,w.createViewModalConfig=oh,w.createViewTabsConfig=lh,w.facadeApiClient=Al,w.formatSQLSnippet=Ir,w.getInitialDashboardViewsModel=$o,w.getInitialFiltersConfig=Mo,w.getInitialMockContextMeta=io,w.getInitialQueriesRenderModel=jh,w.getInitialSQLSnippetsRenderModel=Sh,w.getInitialViewsRenderModel=ph,w.getNewPanel=xh,w.getStaticDateRangeDefaultValue=Yp,w.getVersion=X4,w.initialDashboardContent=C3,w.useDashboardContext=ni,w.useDashboardThemeContext=ql,w.useEditContentModelContext=re,w.useEditDashboardContext=se,w.useEditPanelContext=Le,w.useFullScreenPanelContext=Wl,w.useIsInEditPanelContext=Rl,w.useIsInRenderPanelContext=Ql,w.usePanelFullScreen=$h,w.useRenderContentModelContext=Te,w.useRenderDashboardContext=Vl,w.useRenderPanelContext=He,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|
|
518
|
+
`),o4={root:{minHeight:"350px",maxHeight:"50vh",height:"100%",overflow:"hidden"},list:{"&::before":{borderColor:"transparent"}},panel:{height:"calc(100% - 36px)",overflowY:"auto"}},l4=k.observer(({queryModel:e})=>{const[t,r]=f.useState("编辑查询");return n.jsxs(a.Tabs,{color:"red",defaultValue:"编辑查询",styles:o4,value:t,onChange:r,children:[n.jsxs(a.Tabs.List,{children:[n.jsx(a.Tabs.Tab,{value:"编辑查询",size:"xs",children:"编辑查询"}),n.jsx(a.Tabs.Tab,{value:"加工结果",size:"xs",children:"加工结果"}),n.jsx(a.Tabs.Tab,{value:"使用情况",size:"xs",children:"使用情况"}),n.jsx(a.Tabs.Tab,{value:"预览查询",size:"xs",leftSection:n.jsx(C.IconEye,{size:14}),ml:"auto",children:"预览查询"})]}),n.jsx(a.Tabs.Panel,{value:"编辑查询",pt:"xs",children:n.jsx(s4,{queryModel:e})}),n.jsx(a.Tabs.Panel,{value:"加工结果",pt:"xs",children:n.jsx(Sn,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:a4})}),n.jsx(a.Tabs.Panel,{value:"使用情况",pt:"xs",children:n.jsx(Ig,{queryModel:e})}),n.jsx(a.Tabs.Panel,{value:"预览查询",pt:"xs",children:n.jsx(i4,{queryModel:e})})]})}),c4=k.observer(()=>{const e=se();return n.jsxs(a.Stack,{styles:{root:{borderRadius:4,backgroundColor:"#F9F9FA",height:"100%",minHeight:"350px",maxHeight:"50vh",overflow:"hidden"}},children:[n.jsx(a.Box,{py:7,px:8,children:n.jsx(a.Text,{fw:"bold",size:"sm",children:"看板变量预览"})}),n.jsx(Dt.CodeHighlight,{language:"json",sx:{width:"100%",height:"100%",minHeight:"400px",overflowY:"auto"},withCopyButton:!1,code:e.queryVariablesString})]})}),u4=k.observer(({queryModel:e})=>{const t=e.metricQueryPayloadError;return t.length>0?n.jsxs(a.HoverCard,{shadow:"md",children:[n.jsx(a.HoverCard.Target,{children:n.jsx(a.Box,{children:n.jsx(a.Button,{size:"xs",leftSection:n.jsx(Eg,{width:14,height:14,color:"rgb(173, 181, 189)"}),variant:"filled",color:"red",disabled:!0,children:"执行查询"})})}),n.jsx(a.HoverCard.Dropdown,{children:n.jsx(a.List,{size:"xs",children:t.map(r=>n.jsx(a.List.Item,{children:r},r))})})]}):n.jsx(a.Button,{size:"xs",leftSection:n.jsx(Eg,{width:14,height:14}),variant:"filled",color:"red",onClick:()=>e.fetchData(!0),children:"执行查询"})}),d4=({option:e,...t})=>{const r=e;return n.jsxs(a.Stack,{gap:0,py:4,styles:{root:{flexGrow:1,'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}}},...t,children:[n.jsxs(a.Group,{flex:"1",gap:4,children:[n.jsx(C.IconHash,{size:12}),n.jsx(a.Text,{size:"xs",children:r.label})]}),n.jsx(a.Text,{ml:16,size:"xs",c:t.checked?"rgba(255,255,255,.8)":"dimmed",children:r.description})]})},p4=k.observer(({queryModel:e})=>{const t=e.config,s=e.datasource.mericoMetricInfo,i=s.metrics;f.useEffect(()=>{i.load()},[i]),f.useEffect(()=>{!s.metricID&&t.id&&s.selectMetric(t.id)},[t.id]);const o=f.useMemo(()=>i.data.map(d=>({label:d.name,value:d.id,description:d.description,type:d.type})),[i.data]),l=f.useCallback((d,p)=>{d&&(s.selectMetric(d),t.setID(d),t.setType(p.type))},[s,t]),{loading:c,error:u}=i;return n.jsx(Ie,{children:n.jsxs(a.Group,{justify:"flex-end",gap:12,align:"flex-end",children:[u?n.jsx(a.Tooltip,{label:u,children:n.jsx(a.Select,{size:"xs",label:"指标",error:!0,styles:{root:{flexGrow:1}}})}):n.jsx(a.Select,{size:"xs",label:"指标",data:o,renderOption:d4,styles:{root:{flexGrow:1}},maxDropdownHeight:500,value:t.id,onChange:l,rightSection:c?n.jsx(a.Loader,{size:"xs"}):null}),n.jsx(a.Tooltip,{label:"跳转到指标明细页查看详情。",disabled:c,children:n.jsx(a.Anchor,{size:"md",variant:"subtle",mb:2,href:`/admin/metrics/detail/${t.id}`,target:"_blank",underline:"never",children:n.jsx(IM,{width:14,height:14})})})]})})}),h4=k.observer(({queryModel:e})=>{const{t}=_.useTranslation();return n.jsxs(a.Stack,{pt:8,pb:16,px:24,gap:8,styles:{root:{height:"100vh",overflow:"hidden"}},children:[n.jsx(a.Group,{styles:{root:{flexGrow:0,flexShrink:0}},children:n.jsx(a.TextInput,{size:"xs",placeholder:t("query.name_description"),label:t("query.name"),value:e.name,onChange:r=>{e.setName(r.currentTarget.value)},styles:{root:{flexGrow:0,width:"calc(50% - 44px)"}}})}),n.jsxs(a.Group,{justify:"space-between",grow:!0,gap:8,align:"flex-end",styles:{root:{flexGrow:0,flexShrink:0}},children:[n.jsxs(a.Group,{justify:"flex-start",grow:!0,gap:24,align:"flex-end",children:[n.jsx(kg,{queryModel:e,size:"xs"}),n.jsx(p4,{queryModel:e})]}),n.jsxs(a.Group,{justify:"flex-end",children:[n.jsx(u4,{queryModel:e}),n.jsx(PM,{queryModel:e})]})]}),n.jsxs(a.Group,{justify:"space-between",grow:!0,gap:12,align:"flex-start",sx:{flexGrow:0,flexShrink:1,overflowY:"hidden"},children:[n.jsx(l4,{queryModel:e}),n.jsx(c4,{})]}),n.jsx($M,{queryModel:e})]})}),g4=k.observer(({id:e})=>{const r=re().queries.findByID(e);return e===""?null:r?r.isMericoMetricQuery?n.jsx(h4,{queryModel:r}):n.jsx(zM,{queryModel:r}):n.jsx(a.Text,{size:"14px",c:"red",children:"Invalid Query ID"})}),f4=k.observer(({value:e})=>{const r=Te().payloadForSQL,s=f.useMemo(()=>Hs(e,r),[e,r]);return n.jsx(fa,{height:"100%",value:s})}),x4=k.observer(({item:e,remove:t,onKeyChanged:r})=>{const{t:s}=_.useTranslation(),[i,o]=f.useState("SQL"),[l,c]=f.useState(e.key),u=()=>{e.setKey(l),r(l)},d=l!==e.key,p=e.isADuplicatedKey(l),[h,x]=f.useState(e.value),b=()=>{e.setValue(h)};f.useEffect(()=>{c(e.key),x(e.value)},[e]);const m=h!==e.value,j=dt.useModals(),D=()=>{j.openConfirmModal({title:`${s("sql_snippet.delete")}?`,labels:{confirm:s("common.actions.confirm"),cancel:s("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:t,confirmProps:{color:"red"},zIndex:320})};return n.jsxs(a.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},gap:"sm",children:[n.jsxs(a.Group,{sx:{alignItems:"end"},gap:40,children:[n.jsx(a.TextInput,{label:s(p?"sql_snippet.key_occupied":"sql_snippet.key"),value:l,onChange:T=>{c(T.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:n.jsx(a.ActionIcon,{color:"blue",variant:"subtle",onClick:u,disabled:!d||p,children:n.jsx(C.IconDeviceFloppy,{size:16})}),error:p}),n.jsx(a.Button,{leftSection:n.jsx(C.IconTrash,{size:16}),color:"red",variant:"light",onClick:D,children:s("sql_snippet.delete")})]}),n.jsxs(a.Tabs,{value:i,onChange:o,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[n.jsxs(a.Tabs.List,{sx:{position:"relative"},children:[n.jsx(a.Tabs.Tab,{value:"SQL",children:s("sql_snippet.edit_snippet")}),n.jsx(a.Tabs.Tab,{value:"Preview",children:s("sql_snippet.preview_snippet")}),n.jsx(Ko,{}),n.jsx(a.ActionIcon,{color:"blue",variant:"filled",onClick:b,disabled:!m,sx:{position:"absolute",top:0,right:10},children:n.jsx(C.IconDeviceFloppy,{size:18})})]}),n.jsx(a.Tabs.Panel,{value:"SQL",pt:"sm",children:n.jsx(fa,{height:"100%",value:h,onChange:x,defaultLanguage:"sql",theme:"sql-dark"})}),n.jsx(a.Tabs.Panel,{value:"Preview",pt:"sm",children:n.jsx(f4,{value:h})})]})]})}),m4=k.observer(({id:e})=>{const t=se(),r=re(),s=f.useMemo(()=>r.sqlSnippets.findByKey(e),[e]);if(!e)return null;if(!s)return n.jsxs(a.Text,{size:"14px",children:["SQL Snippet by key[",e,"] is not found"]});const i=()=>{t.editor.setPath(["_SQL_SNIPPETS_",""])},o=()=>{r.sqlSnippets.removeByKey(e),i()},l=c=>{t.editor.setPath(["_SQL_SNIPPETS_",c])};return n.jsx(x4,{item:s,remove:o,onKeyChanged:l})}),b4=k.observer(()=>{const{t:e}=_.useTranslation(),[t,r]=f.useState([]),s=dt.useModals(),i=se(),o=x=>{i.editor.setPath(["_SQL_SNIPPETS_",x])},l=()=>{s.openConfirmModal({title:"Delete ununsed SQL snippets?",children:n.jsx(a.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.content.removeUnusedSQLSnippets(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.sqlSnippets.downloadSchema(t)},u=f.useMemo(()=>i.content.sqlSnippets.sortedList.map(x=>x.key),[i.content.sqlSnippets.sortedList]),d=()=>{r(u)},p=()=>{r([])},h=i.content.sqlSnippetsUsage;return n.jsxs(a.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[n.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:n.jsx(a.Text,{size:"sm",px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("sql_snippet.manage")})}),n.jsxs(a.Flex,{justify:"space-between",align:"center",px:12,children:[n.jsxs(a.Group,{justify:"flex-start",children:[n.jsxs(a.Button.Group,{children:[n.jsx(a.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),n.jsx(a.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),n.jsx(a.Button,{size:"xs",color:"blue",leftSection:n.jsx(C.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),n.jsx(a.Button,{variant:"subtle",size:"xs",color:"red",leftSection:n.jsx(C.IconTrash,{size:14}),disabled:!i.content.hasUnusedSQLSnippets,onClick:l,children:e("sql_snippet.delete_unused")})]}),n.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:n.jsx(a.Checkbox.Group,{size:"xs",value:t,onChange:r,children:n.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[n.jsx(a.Table.Thead,{children:n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Th,{style:{width:"40px"}}),n.jsx(a.Table.Th,{children:e("common.key")}),n.jsx(a.Table.Th,{style:{width:"100px",textAlign:"center"},children:e("sql_snippet.usage.label")}),n.jsx(a.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),n.jsx(a.Table.Tbody,{children:i.content.sqlSnippets.sortedList.map(x=>{var m;const b=((m=h[x.key])==null?void 0:m.length)??0;return n.jsxs(a.Table.Tr,{children:[n.jsx(a.Table.Td,{children:n.jsx(a.Checkbox,{value:x.key,styles:{input:{cursor:"pointer"}}})}),n.jsx(a.Table.Td,{children:x.key}),n.jsx(a.Table.Td,{style:{color:b===0?"#ff0000":"#000",fontWeight:b===0?"bold":"normal",textAlign:"center"},children:b}),n.jsx(a.Table.Td,{children:n.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>o(x.key),children:e("common.actions.open")})})]},x.key)})})]})})})]})}),y4=k.observer(({view:e})=>!e||e.type!==F.Division?null:n.jsx(a.Stack,{})),v4=k.observer(({view:e})=>{const{t,i18n:r}=_.useTranslation(),s=f.useMemo(()=>[{value:"default",label:t("common.tabs.variant.default")},{value:"outline",label:t("common.tabs.variant.outline")},{value:"pills",label:t("common.tabs.variant.pills")}],[r.language]),i=f.useMemo(()=>[{value:"horizontal",label:t("common.tabs.orientation.horizontal")},{value:"vertical",label:t("common.tabs.orientation.vertical")}],[r.language]);if(!e||e.type!==F.Tabs)return null;const o=e.config;return n.jsxs(a.Stack,{children:[n.jsx(a.Divider,{mt:8,mb:0,label:t("view.component.tabs.tabs_settings"),labelPosition:"center"}),n.jsx(a.Select,{label:t("common.tabs.variant.label"),value:o.variant,onChange:o.setVariant,data:s}),n.jsx(a.Select,{label:t("common.tabs.orientation.label"),value:o.orientation,onChange:o.setOrientation,data:i}),n.jsx(a.Switch,{label:t("common.tabs.grow_tabs"),checked:o.grow,onChange:l=>o.setGrow(l.currentTarget.checked)})]})}),_4=({disabled:e,value:t,onChange:r})=>{const s=i=>{i&&r(i)};return n.jsxs(a.Box,{sx:{position:"relative"},children:[e&&n.jsx(a.Overlay,{backgroundOpacity:.6,color:"#fff",zIndex:5,blur:2}),n.jsx(ht,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},j4=({value:e,onChange:t})=>{const{t:r}=_.useTranslation(),[s,{setTrue:i,setFalse:o}]=Y.useBoolean(),[l,c]=f.useState(e??Ps),u=b=>{c({...l,enabled:b})},d=()=>{o();const{enabled:b,func_content:m}=l,j={enabled:b,func_content:m};c(j),t(j)},p=()=>{o(),c(e)},h=b=>{c(m=>({...m,func_content:b}))},x=()=>{h(Ps.func_content)};return n.jsxs(n.Fragment,{children:[n.jsx(a.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:i,sx:{flexGrow:0},children:n.jsx(C.IconSettings,{size:14})}),n.jsx(a.Modal,{size:800,title:r("view.component.modal.custom_title"),opened:s,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&n.jsxs(a.Stack,{children:[n.jsx(a.Checkbox,{mt:10,label:r("common.enabled"),checked:l.enabled,onChange:b=>u(b.currentTarget.checked)}),n.jsx(_4,{value:l.func_content,onChange:h,disabled:!l.enabled}),n.jsxs(a.Group,{justify:"space-between",children:[n.jsx(a.Button,{onClick:x,color:"red",leftSection:n.jsx(C.IconRecycle,{size:20}),children:r("common.actions.revert")}),n.jsxs(a.Group,{justify:"flex-end",children:[n.jsx(a.Button,{onClick:p,variant:"subtle",children:r("common.actions.cancel")}),n.jsx(a.Button,{onClick:d,children:r("common.actions.save")})]})]})]})})]})},w4=k.observer(({view:e})=>{const{t}=_.useTranslation();if(!e||e.type!==F.Modal)return null;const r=e.config,s=r.custom_modal_title.value;return n.jsxs(a.Stack,{children:[n.jsx(a.Divider,{mt:8,label:t("view.component.modal.modal_settings"),labelPosition:"center"}),n.jsxs(a.Flex,{gap:10,children:[n.jsx(a.TextInput,{label:t("view.component.modal.title"),value:s,onChange:v.noop,disabled:!0,sx:{flexGrow:1}}),n.jsx(j4,{value:r.custom_modal_title,onChange:r.custom_modal_title.replace})]}),n.jsxs(a.Group,{grow:!0,children:[n.jsx(a.TextInput,{label:t("view.component.modal.width"),value:r.width,onChange:i=>r.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),n.jsx(a.TextInput,{label:t("view.component.modal.height"),value:r.height,onChange:i=>r.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),C4=k.observer(({view:e})=>n.jsxs(n.Fragment,{children:[n.jsx(y4,{view:e}),n.jsx(w4,{view:e}),n.jsx(v4,{view:e})]})),S4=k.observer(({view:e})=>{const{t,i18n:r}=_.useTranslation(),s=f.useMemo(()=>[{label:t("view.component.div.label"),value:F.Division},{label:t("view.component.modal.label"),value:F.Modal},{label:t("view.component.tabs.label"),value:F.Tabs}],[r.language]);return e?n.jsxs(a.Stack,{sx:{position:"relative"},children:[n.jsx(a.TextInput,{label:t("common.name"),value:e.name,onChange:i=>{e.setName(i.currentTarget.value)}}),n.jsx(a.Select,{label:t("common.type"),comboboxProps:{withinPortal:!0,zIndex:320},value:e.type,onChange:e.setType,data:s}),n.jsx(C4,{view:e})]}):null}),T4=k.observer(({id:e})=>{const{t}=_.useTranslation(),r=dt.useModals(),s=se(),i=re();if(e==="")return null;const o=i.views.findByID(e);if(!o)return n.jsxs(a.Text,{size:"14px",children:["View by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_VIEWS_",""])},c=()=>{r.openConfirmModal({title:`${t("view.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.views.removeByID(e),l()},confirmProps:{color:"red"},zIndex:320})};return n.jsxs(a.Stack,{sx:{maxWidth:"600px",height:"100%"},gap:"sm",children:[n.jsx(a.Group,{justify:"flex-end",pt:10,children:n.jsx(a.Button,{size:"xs",color:"red",leftSection:n.jsx(C.IconTrash,{size:16}),onClick:c,children:t("view.delete")})}),n.jsx(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:n.jsx(S4,{view:o})})]})}),k4=k.observer(()=>n.jsx(a.Stack,{sx:{height:"100%"},p:"sm",children:n.jsx(Dg,{})})),D4=k.observer(()=>{const e=se().editor,t=e.path;return F5(t)?n.jsx(k4,{}):Q5(t)?n.jsx(mI,{}):R5(t)?n.jsx(xI,{}):W5(t)?n.jsx(a.Box,{p:"xs",pl:20,children:n.jsx(fI,{id:t[1]})}):U5(t)?n.jsx(b4,{}):Y5(t)?n.jsx(m4,{id:t[1]}):X5(t)?n.jsx(XI,{}):K5(t)?n.jsx(g4,{id:t[1]}):H5(t)?n.jsx(a.Box,{p:"xs",pl:20,children:n.jsx(T4,{id:t[1]})}):No(t)?n.jsx(KI,{viewID:t[1],panelID:t[3]}):n.jsx(a.Box,{children:e.path})}),z4=k.observer(()=>n.jsx(D4,{})),I4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=()=>{const s=new Date().getTime().toString(),i={id:s,key:s,label:s,order:t.content.filters.current.length+1,type:Q.TextInput,config:fo(),visibleInViewsIDs:["Main"],auto_submit:!1};t.content.filters.append(i),t.editor.setPath(["_FILTERS_",s])};return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("filter.add")})}),M4=k.observer(({parentID:e})=>{const{t}=_.useTranslation(),r=re();if(!e)return null;const s=r.views.findByID(e);return!s||s.type===F.Tabs?null:n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>r.addANewPanel(s.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("panel.add")})}),E4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=()=>{const s=new Date().getTime().toString(),i={id:s,name:s,type:J.Postgresql,key:"",config:{_type:J.Postgresql,sql:""}};t.content.queries.append(i),t.editor.setPath(["_QUERIES_",s])};return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("query.add")})}),P4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se(),r=()=>{const s=new Date().getTime().toString(),i={key:s,value:""};t.content.sqlSnippets.append(i),t.editor.setPath(["_SQL_SNIPPETS_",s])};return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:r,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("sql_snippet.add")})}),A4=k.observer(()=>{const{t:e}=_.useTranslation(),t=re();return n.jsx(a.Button,{variant:"subtle",leftSection:n.jsx(C.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("view.add")})}),L4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_QUERIES_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("query.manage")})}),O4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_SQL_SNIPPETS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("sql_snippet.manage")})}),V4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsx(a.Button,{variant:"subtle",rightSection:n.jsx(C.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_FILTERS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("filter.manage")})}),B4=k.observer(({action_type:e,parentID:t})=>e==="_Add_A_Filter_"?n.jsx(I4,{}):e==="_Add_A_SQL_SNIPPET_"?n.jsx(P4,{}):e==="_Add_A_QUERY_"?n.jsx(E4,{}):e==="_Add_A_VIEW_"?n.jsx(A4,{}):e==="_Add_A_PANEL_"?n.jsx(M4,{parentID:t}):e==="_QUERIES_SETTINGS_"?n.jsx(L4,{}):e==="_SQL_SNIPPETS_SETTINGS_"?n.jsx(O4,{}):e==="_FILTERS_SETTINGS_"?n.jsx(V4,{}):null),Bg=k.observer(({option:e})=>{var p;const{t}=_.useTranslation(),r=se().editor,s=r.isOptionActive,i=s(r.path,e),o=r.isOptionOpened,l=r.navigate,c=o(e),[u,d]=f.useState(c);return f.useEffect(()=>{d(c)},[c]),n.jsx(a.NavLink,{active:i,defaultOpened:c,opened:u,onChange:d,label:t(e.label),onClick:()=>l(e),leftSection:e.Icon?n.jsx(e.Icon,{size:18}):null,children:(p=e.children)==null?void 0:p.map(h=>h._type==="ACTION"?n.jsx(B4,{action_type:h._action_type,parentID:h.parentID},`_ADD_${h.value}_`):n.jsx(Bg,{option:h},h.value))},e.label)}),q4=k.observer(()=>{const e=se();return n.jsx(a.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>n.jsx(Bg,{option:t},t.value))})}),N4=k.observer(()=>{const{t:e}=_.useTranslation(),t=se();return n.jsxs(a.AppShell.Navbar,{p:0,sx:{height:"100vh - 60px - 60px",".mantine-NavLink-body":{wordWrap:"break-word"}},children:[n.jsx(a.AppShell.Section,{sx:{borderBottom:"1px solid #eee",padding:"var(--mantine-spacing-xs) var(--mantine-spacing-md)"},children:n.jsx(a.Text,{size:"sm",ta:"center",sx:{userSelect:"none",cursor:"default"},children:e("common.titles.settings")})}),n.jsx(a.AppShell.Section,{grow:!0,sx:{overflow:"auto"},children:n.jsx(q4,{})}),n.jsx(a.AppShell.Section,{children:n.jsx(a.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:n.jsx(a.Button,{size:"xs",color:"red",leftSection:n.jsx(C.IconX,{size:18}),onClick:()=>t.editor.close(),children:e("common.actions.close")})})})]})}),$4={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden",minWidth:"calc(var(--app-shell-navbar-width, 0px) + 1200px)"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},G4=k.observer(()=>{const e=se().editor;return n.jsx(a.Modal,{onClose:()=>e.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:e.settings_open,fullScreen:!0,title:null,transitionProps:{duration:0},withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{body:{padding:"0 !important"},content:{overflowY:"hidden !important"}},children:n.jsxs(a.AppShell,{padding:0,navbar:{width:{base:220,xs:220,sm:240,md:260,lg:300,xl:320},breakpoint:"xxs"},styles:$4,children:[n.jsx(N4,{}),n.jsx(a.AppShell.Main,{children:n.jsx(z4,{})})]})})}),F4=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function Q4(e){f.useEffect(()=>{if(ht.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const r=F4(e);ht.loader.config({paths:{vs:r}}),ht.loader.init().then(s=>console.log("monaco instance:",s))},[])}Hl(),bd();const R4={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden","--app-shell-header-offset":"calc(3.75rem * var(--mantine-scale))"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},W4=({context:e,dashboard:t,content:r,update:s,className:i="dashboard",config:o,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h},x)=>{Q4(o.monacoPath),Zs(o);const{data:b=[]}=Y.useRequest(ba),{data:m=[]}=Y.useRequest(yd),j=f.useMemo(()=>ig(t,r,b,m,e,u??{}),[t,r]);f.useImperativeHandle(x,()=>j,[j]),og(j.content,!0),f.useEffect(()=>{j.context.replace(e)},[e]),f.useEffect(()=>{j.datasources.replace(b)},[b]),f.useEffect(()=>{j.globalSQLSnippets.replace(m)},[m]),f.useEffect(()=>{d==null||d(j.content.filters.values)},[d,j.content.filters.values]),f.useEffect(()=>{u&&j.content.filters.patchValues(u)},[u,j.content.filters.patchValues]),f.useEffect(()=>te.reaction(()=>te.toJS(j.json),I=>{l==null||l(I)}),[j]);const D=async()=>{await s(j.json,j.content.json)},T=Y.useCreation(no,[]),z=lg(T);return Y.useWhyDidYouUpdate("@devtable/dashboard editor",{context:e,dashboard:t,content:r,update:s,className:i,config:o,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h}),n.jsx(on.MantineEmotionProvider,{children:n.jsx(ag,{lang:h,children:n.jsx(dt.ModalsProvider,{children:n.jsx(li,{children:n.jsx(ri,{value:{searchButtonProps:o.searchButtonProps},children:n.jsx(ti,{value:j,children:n.jsx(si,{value:j.content,children:n.jsxs($r.Provider,{value:{inEditMode:!0},children:[n.jsx(Tz,{}),n.jsx(tn.Provider,{value:T,children:n.jsxs(Ms,{configure:z,children:[n.jsxs(a.AppShell,{padding:0,navbar:{width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},breakpoint:"xxs"},styles:R4,children:[n.jsx(Iz,{onExit:p,saveDashboardChanges:D,headerSlot:c}),n.jsx(rI,{}),n.jsx(a.AppShell.Main,{children:n.jsx(a.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:j.content.views.visibleViews.map(I=>n.jsx(Rh,{view:I},I.id))})})]}),n.jsx(G4,{})]})})]})})})})})})})})},U4=k.observer(f.forwardRef(W4)),CE="",Zo=g.types.model({id:g.types.string,name:g.types.string,dashboard_id:g.types.string,create_time:g.types.string,update_time:g.types.string,version:g.types.string,filters:Io,queries:Po,sqlSnippets:Lo,views:ko,panels:zo,layouts:Ao,mock_context:so}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,layouts:e.layouts.json,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get contentJSON(){return this.json.content},get payloadForSQL(){const t=g.getParent(e).context.current,r=g.getParent(e).globalSQLSnippets,s={context:{...e.mock_context.current,...t},filters:e.filters.valuesForPayload};return{...s,sql_snippets:Ir(e.sqlSnippets.current,"key","value",s),global_sql_snippets:Ir(r.list,"id","content",s)}},get payloadForViz(){const t=g.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.valuesForPayload}},get dashboardState(){return ma(this.payloadForSQL)},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardState}},get data(){return e.queries.current.map(({id:r,data:s})=>({id:r,data:s})).reduce((r,s)=>(r[s.id]=s.data,r),{})},getDataStuffByID(t){const r=e.queries.findByID(t);return r?{data:r.data,len:r.data.length,state:r.state,error:r.error??r.metricQueryPayloadErrorString}:{data:[],len:0,state:"idle",error:void 0}}})).actions(e=>({}));function qg({id:e,name:t,dashboard_id:r,create_time:s,update_time:i,content:o},l,c,u){if(!o)throw new Error("unexpected null content when creating a content model");const{version:d,filters:p,views:h,panels:x,layouts:b,definition:{queries:m,sqlSnippets:j,mock_context:D={}}}=o;return Zo.create({id:e,name:t,dashboard_id:r,create_time:s,update_time:i,version:d,filters:Mo(p,l,D,c),queries:jh(m),sqlSnippets:Sh(j),mock_context:io(D),views:ph(h,u),panels:{list:x},layouts:{list:b,currentBreakpoint:b[0].id}})}const Ng=g.types.model({id:g.types.identifier,name:g.types.string,group:g.types.string,content:Zo,content_id:g.types.string,datasources:uh,globalSQLSnippets:Co,context:As});function $g({id:e,name:t,group:r,content_id:s},i,o,l,c,u,d){return Ng.create({id:e,name:t,group:r,content_id:s,content:qg(i,c,u,d),datasources:{list:o},globalSQLSnippets:{list:l},context:So(c)})}Hl(),bd();const Y4=({context:e,dashboard:t,content:r,className:s="dashboard",config:i,fullScreenPanelID:o,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h})=>{Zs(i);const{data:x=[]}=Y.useRequest(ba),{data:b=[]}=Y.useRequest(yd),m=f.useMemo(()=>$g(t,r,x,b,e,c??{},d??null),[t,r,d]);og(m.content,!1),f.useEffect(()=>{m.context.replace(e)},[e]),f.useEffect(()=>{m.datasources.replace(x)},[x]),f.useEffect(()=>{m.globalSQLSnippets.replace(b)},[b]),f.useEffect(()=>{console.log("⚪️ calling onFilterValuesChange: ",m.content.filters.values),u==null||u(m.content.filters.values)},[u,m.content.filters.valuesString]),f.useEffect(()=>{c&&m.content.filters.patchValues(c)},[c,m.content.filters.patchValues]),f.useEffect(()=>{p==null||p(m.content.views.firstVisibleTabsViewActiveTab)},[p,m.content.views.firstVisibleTabsViewActiveTabStr]),f.useEffect(()=>{d&&m.content.views.setFirstVisibleTabsViewActiveTab(d)},[d,m.content.views.setFirstVisibleTabsViewActiveTab]);const j=Y.useCreation(no,[]),D=lg(j);return Y.useWhyDidYouUpdate("@devtable/dashboard render",{context:e,dashboard:t,content:r,className:s,config:i,fullScreenPanelID:o,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h}),n.jsx(on.MantineEmotionProvider,{children:n.jsx(ag,{lang:h,children:n.jsx(dt.ModalsProvider,{children:n.jsx(li,{children:n.jsx(ri,{value:{searchButtonProps:i.searchButtonProps},children:n.jsx(ti,{value:m,children:n.jsx(si,{value:m.content,children:n.jsx(oi.Provider,{value:{fullScreenPanelID:o,setFullScreenPanelID:l},children:n.jsx($r.Provider,{value:{inEditMode:!1},children:n.jsx(a.Box,{className:`${s} dashboard-root`,children:n.jsx(tn.Provider,{value:j,children:n.jsx(Ms,{configure:D,children:m.content.views.visibleViews.map(T=>n.jsx(Vs,{view:T},T.id))})})})})})})})})})})})})},K4=k.observer(Y4);A.extend(pf),A.extend(hf),A.extend(gf),A.extend(ff),A.extend(xf),A.extend(mf),A.extend(bf),A.extend(yf),A.extend(vf),A.extend(_f),A.extend(Cf),A.extend(Sf),A.extend(Tf),A.extend(kf),A.extend(Df),A.extend(jf),A.extend(wf),A.extend(zf),A.extend(If),A.extend(Mf),A.extend(Ef),A.extend(Pf),A.extend(Af),A.extend(Lf),A.extend(Of),A.extend(Vf),A.extend(Bf),A.extend(qf),A.extend(Nf),A.extend($f),A.extend(Ff),A.extend(Qf),A.extend(Gf),A.tz.setDefault("UTC"),A.updateLocale("en",{weekStart:1});const X4=()=>Promise.resolve().then(()=>zy).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));w.APIClient=gt,w.CURRENT_SCHEMA_VERSION=nn,w.ContentModel=Go,w.ContentModelContextProvider=si,w.ContentRenderModel=Zo,w.ContextMeta=As,w.DEFAULT_CUSTOM_MODAL_TITLE=Ps,w.DashboardApiClient=El,w.DashboardApiFacadeClient=Pl,w.DashboardEditor=U4,w.DashboardFilterType=Q,w.DashboardMode=Wh,w.DashboardModel=sg,w.DashboardModelContextProvider=ti,w.DashboardRenderModel=Ng,w.DashboardThemeContextProvider=ri,w.DashboardViewEditor=Rh,w.DashboardViewRender=Vs,w.DataSourceMetaModel=wo,w.DataSourceType=J,w.DataSourcesMetaModel=uh,w.DatesProvider=li,w.DefaultApiClient=Ml,w.DescriptionPopover=Oo,w.DraftModel=Th,w.EViewComponentType=F,w.FacadeApiClient=ix,w.FilterCheckboxConfigMeta=oo,w.FilterDateRangeConfigMeta=co,w.FilterMeta=yo,w.FilterMultiSelectConfigMeta=po,w.FilterSelectConfigMeta=ho,w.FilterTextInputConfigMeta=go,w.FilterTreeSelectConfigMeta=mo,w.FilterTreeSingleSelectConfigMeta=bo,w.FiltersModel=Yh,w.FiltersRenderModel=Io,w.FullScreenPanel=Nh,w.FullScreenPanelContext=oi,w.GlobalSQLSnippetMeta=dh,w.GlobalSQLSnippetsMeta=Co,w.LayoutItemMeta=Gp,w.LayoutSetMeta=Fp,w.LayoutStateContext=$r,w.LayoutsRenderModel=Ao,w.MericoMetricQueryMeta=ao,w.MockContextMeta=so,w.MuteQueryModel=_h,w.Panel=qh,w.PanelContextProvider=ii,w.PanelErrorOrStateMessage=Vh,w.PanelMeta=Lp,w.PanelModel=eg,w.PanelRender=Bo,w.PanelRenderModel=Do,w.PanelStyleMeta=Mp,w.PanelTitleMeta=Ep,w.PanelVizMeta=Ap,w.PanelVizSection=Vo,w.PanelsModel=tg,w.PanelsRenderModel=zo,w.QueriesModel=Xh,w.QueriesRenderModel=Po,w.QueryMeta=$p,w.QueryModel=Kh,w.QueryRenderModel=Eo,w.ReadOnlyDashboard=K4,w.SQLSnippetMeta=Qp,w.SQLSnippetRenderModel=Ch,w.SQLSnippetsModel=Hh,w.SQLSnippetsRenderModel=Lo,w.VariableMeta=Pp,w.ViewComponentTypeBackground=Uh,w.ViewComponentTypeColor=k5,w.ViewComponentTypeName=T5,w.ViewDivisionConfig=vo,w.ViewMeta=ch,w.ViewModalConfig=_o,w.ViewRenderModel=To,w.ViewTabsConfig=jo,w.ViewsModel=ng,w.ViewsRenderModel=ko,w.Viz=Oh,w.applyPartialDashboard=rz,w.configureAPIClient=Zs,w.createContentModel=rg,w.createContentRenderModel=qg,w.createContextMeta=So,w.createDashboardModel=ig,w.createDashboardRenderModel=$g,w.createDraft=kh,w.createFilterCheckboxConfig=Rp,w.createFilterDateRangeConfig=Xp,w.createFilterMultiSelectConfig=Zp,w.createFilterSelectConfig=Jp,w.createFilterTextInputConfig=fo,w.createFilterTreeSelectConfig=sh,w.createFilterTreeSingleSelectConfig=ih,w.createMericoMetricQueryMetaConfig=Np,w.createViewDivisionConfig=ah,w.createViewModalConfig=oh,w.createViewTabsConfig=lh,w.facadeApiClient=Al,w.formatSQLSnippet=Ir,w.getInitialDashboardViewsModel=$o,w.getInitialFiltersConfig=Mo,w.getInitialMockContextMeta=io,w.getInitialQueriesRenderModel=jh,w.getInitialSQLSnippetsRenderModel=Sh,w.getInitialViewsRenderModel=ph,w.getNewPanel=xh,w.getStaticDateRangeDefaultValue=Yp,w.getVersion=X4,w.initialDashboardContent=C3,w.useDashboardContext=ni,w.useDashboardThemeContext=ql,w.useEditContentModelContext=re,w.useEditDashboardContext=se,w.useEditPanelContext=Le,w.useFullScreenPanelContext=Wl,w.useIsInEditPanelContext=Rl,w.useIsInRenderPanelContext=Ql,w.usePanelFullScreen=$h,w.useRenderContentModelContext=Te,w.useRenderDashboardContext=Vl,w.useRenderPanelContext=He,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|