@devtable/dashboard 13.43.10 → 13.43.12
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 +6 -2
- 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/components/panel/settings/common/color-array-input.d.ts +0 -8
- package/dist/components/panel/settings/common/text-array-input.d.ts +0 -12
package/dist/dashboard.es.js
CHANGED
|
@@ -6512,7 +6512,7 @@ class hl {
|
|
|
6512
6512
|
}), this.instanceRegistry.clear(), this.factoryRegistry.clear();
|
|
6513
6513
|
}
|
|
6514
6514
|
}
|
|
6515
|
-
const Wp = "13.43.
|
|
6515
|
+
const Wp = "13.43.12", Uj = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
6516
6516
|
__proto__: null,
|
|
6517
6517
|
version: Wp
|
|
6518
6518
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
@@ -35138,7 +35138,11 @@ const CR = L(({
|
|
|
35138
35138
|
a(e);
|
|
35139
35139
|
}, [e]);
|
|
35140
35140
|
const s = SR(), o = e !== i;
|
|
35141
|
-
return /* @__PURE__ */ r.jsx(B, { label: n("visualization.component"), value: i, searchable: !0, onChange: a, data: s, rightSection: /* @__PURE__ */ r.jsx(ue, { variant: "filled", color: "green", disabled: !o, onClick: () => t(i),
|
|
35141
|
+
return /* @__PURE__ */ r.jsx(B, { label: n("visualization.component"), value: i, searchable: !0, onChange: a, data: s, rightSection: /* @__PURE__ */ r.jsx(ue, { variant: "filled", color: "green", disabled: !o, onClick: () => t(i), styles: {
|
|
35142
|
+
root: {
|
|
35143
|
+
pointerEvents: "all"
|
|
35144
|
+
}
|
|
35145
|
+
}, children: /* @__PURE__ */ r.jsx(Re, { size: 20 }) }), maxDropdownHeight: 600 });
|
|
35142
35146
|
}), Td = [];
|
|
35143
35147
|
function kR(e, t) {
|
|
35144
35148
|
try {
|
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
|
-
`)(n)}catch(s){return console.error(s),console.log(e),e}}function hs(e,t,n,s){const i=$b(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=Gb(c);return Fb(d,i,n)})}function Rb(e,t){const n=ml.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function Wb({query:e,name:t,payload:n,additionals:s},i){if(!e.sql)return[];const{type:o,key:l,sql:c,pre_process:u,post_process:d}=e,p=Us(c,n),h=kf({sql:p,pre_process:u}),x=ml.encode(h);Rb(h,x);let y=await Bt.query(i)({type:o,key:l,query:x,...s},{params:{name:t}});return y=Df(d,y,ga(n)),y}async function Qb({type:e,key:t,configString:n,name:s,additionals:i},o){try{return await Bt.httpDataSourceQuery(o)({type:e,key:t,query:n,...i},{params:{name:s}})}catch(l){if(Ot.isCancel(l))throw l;return console.error(l),l}}async function fa(){try{return(await Bt.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function dd(){try{return(await Bt.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class pd{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 n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?te.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(v.isObject(n))te.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else te.runInAction(()=>{v.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,s){return te.reaction(()=>this.getValueFromRoot(t),(i,o)=>{n(i,o)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class Ub{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new bl)}getChannel(t){const n=this.channels.get(t);if(n)return n;const s=new bl;return this.channels.set(t,s),s}}class Yb{constructor(t){N(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Ub,instanceData:new pd(t.viz.conf)};return this.instances.set(t.id,s),s}}function hd(e,t,n,s){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new pd({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const Kb=e=>{const{panel:t,measure:n,vizManager:s,data:i,variables:o}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={...hd(c,i,s,o),viewport:{width:n.w,height:n.h}},d=l.viewRender;return r.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},Xb=e=>{const{vizManager:t,panel:n,data:s,variables:i}=e,o=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={...hd(l,s,t,i)},u=o.configRender;return r.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},gd=(e,t)=>{const n=Ct.bezier(e),s=Ct.bezier(t);return function(i){return i<50?n(i*2/100).hex():s((i-50)*2/100).hex()}},gs=e=>{const t=Ct.bezier(e);return function(n){return t(n/100).hex()}},Jb={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:gd(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Zb={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:gd(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Hb={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:gs(["#fff7f1","darkred"]),name:"red",category:"sequential"},ey={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:gs(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},ty={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:gs(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},ny={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:gs(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class ry{constructor(t){N(this,"symbol");this.symbol=Symbol(t)}}function Zt(e){return new ry(e)}class xa{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const t=new xa;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const s=n(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=v.get(t,"dispose");v.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const fd="13.43.10",sy=Object.freeze(Object.defineProperty({__proto__:null,version:fd},Symbol.toStringTag,{value:"Module"}));class iy{constructor(t){N(this,"staticColors",new Map);N(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class ay{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class oy{constructor(){N(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,s){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const 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),n)}}class Te extends oy{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(s,i)=>({version:t,...n(s,i)}))}async migrate({configData:t,panelModel:n}){const s=await t.getItem(null),i=v.get(s,"version",0),o=this.run({from:i,to:this.VERSION},s,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return v.get(n,"version",0)<this.VERSION}}const W=(e,t)=>{const[n,{setFalse:s}]=Y.useBoolean(!0),[i,o]=g.useState();g.useEffect(()=>(e.getItem(t).then(c=>{o(c),s()}),e.watchItem(t,c=>{o(c)})));const l=g.useCallback(async c=>{await e.setItem(t,c),o(c)},[e,t]);return{loading:n,value:i,set:l}},rt={top:16,right:16,bottom:16,left:16},zt=e=>Math.max(0,e-rt.left-rt.right),It=e=>Math.max(0,e-rt.top-rt.bottom),kr=(e,t)=>({width:zt(e),height:It(t)}),st=({width:e,height:t,children:n})=>r.jsx(a.Box,{pt:rt.top,pr:rt.right,pb:rt.bottom,pl:rt.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n}),ma={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 ly({context:e}){const{value:t}=W(e.instanceData,"config"),n=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,ma),h=g.useMemo(()=>Br(n,o),[n,o]),{x,y,z:m}=g.useMemo(()=>({x:O(o),y:O(l),z:O(c)}),[o,l,c]),{min:j,max:k}=g.useMemo(()=>{const D=v.minBy(h,M=>M[m.columnKey]),I=v.maxBy(h,M=>M[m.columnKey]);return{min:v.get(D,m.columnKey),max:v.get(I,m.columnKey)}},[h,m]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:j,max:k,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(D=>[D[x.columnKey],D[y.columnKey],D[m.columnKey]])}]};return t?r.jsx(st,{width:s,height:i,children:r.jsx(Re,{echarts:Fe,option:T,style:kr(s,i),notMerge:!0,theme:"merico-light"})}):null}const Q=z.observer(g.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,queryID:o,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=Pe(),h=g.useMemo(()=>p.dataFieldOptionGroups(s,l,o),[s,l,o]);if(h.length===0){const x=p.explainDataKey(s);return r.jsxs(a.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[r.jsx(a.HoverCard.Target,{children:r.jsx(a.Box,{children:r.jsx(a.TextInput,{label:e,required:t,defaultValue:x.columnKey,readOnly:!0,disabled:!0})})}),r.jsx(a.HoverCard.Dropdown,{children:r.jsxs(a.Group,{justify:"flex-start",gap:0,children:[r.jsx(a.Text,{size:"xs",c:x.queryName?"black":"red",ff:"monospace",children:x.queryName??x.queryID}),r.jsx(a.Text,{size:"xs",c:"black",ff:"monospace",children:"."}),r.jsx(a.Text,{size:"xs",c:"red",ff:"monospace",children:x.columnKey})]})})]})}return r.jsx(a.Select,{ref:d,label:e,description:n,data:h,value:s,onChange:Ce(i),required:t,sx:c,maxDropdownHeight:500,...u})}));function cy({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),s=v.defaults({},t,ma),{control:i,handleSubmit:o,reset:l}=b.useForm({defaultValues:s});return g.useEffect(()=>{l(s)},[t]),t?r.jsx(a.Stack,{gap:"xs",children:r.jsxs("form",{onSubmit:o(n),children:[r.jsx(a.Text,{size:"sm",children:"X Axis"}),r.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>r.jsx(Q,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>r.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(a.Text,{mt:"lg",size:"sm",children:"Y Axis"}),r.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>r.jsx(Q,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>r.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(a.Text,{mt:"lg",size:"sm",children:"Z Axis"}),r.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>r.jsx(Q,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>r.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(a.Group,{justify:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:r.jsxs(a.Button,{color:"blue",type:"submit",children:[r.jsx(C.IconDeviceFloppy,{size:20}),r.jsx(a.Text,{ml:"md",size:"sm",children:"Save"})]})})]})}):null}const uy=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function dy(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${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(n){throw console.error("[Migration failed]",n),n}}class py extends Te{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:dy(i,s)}})}}const hy={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new py,name:"bar-3d",viewRender:ly,configRender:cy,createConfig(){return{version:2,config:v.cloneDeep(ma)}},translation:uy},gy=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(a.Box,{sx:{position:"relative"},children:[e&&r.jsx(a.Overlay,{backgroundOpacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(ut,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function at({enabled:e,func_content:t}){return(n,s)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function Ke(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
92
|
+
`)(n)}catch(s){return console.error(s),console.log(e),e}}function hs(e,t,n,s){const i=$b(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=Gb(c);return Fb(d,i,n)})}function Rb(e,t){const n=ml.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function Wb({query:e,name:t,payload:n,additionals:s},i){if(!e.sql)return[];const{type:o,key:l,sql:c,pre_process:u,post_process:d}=e,p=Us(c,n),h=kf({sql:p,pre_process:u}),x=ml.encode(h);Rb(h,x);let y=await Bt.query(i)({type:o,key:l,query:x,...s},{params:{name:t}});return y=Df(d,y,ga(n)),y}async function Qb({type:e,key:t,configString:n,name:s,additionals:i},o){try{return await Bt.httpDataSourceQuery(o)({type:e,key:t,query:n,...i},{params:{name:s}})}catch(l){if(Ot.isCancel(l))throw l;return console.error(l),l}}async function fa(){try{return(await Bt.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function dd(){try{return(await Bt.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class pd{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 n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?te.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(v.isObject(n))te.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else te.runInAction(()=>{v.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,s){return te.reaction(()=>this.getValueFromRoot(t),(i,o)=>{n(i,o)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class Ub{constructor(){N(this,"channels",new Map);N(this,"globalChannel",new bl)}getChannel(t){const n=this.channels.get(t);if(n)return n;const s=new bl;return this.channels.set(t,s),s}}class Yb{constructor(t){N(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Ub,instanceData:new pd(t.viz.conf)};return this.instances.set(t.id,s),s}}function hd(e,t,n,s){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new pd({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const Kb=e=>{const{panel:t,measure:n,vizManager:s,data:i,variables:o}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={...hd(c,i,s,o),viewport:{width:n.w,height:n.h}},d=l.viewRender;return r.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},Xb=e=>{const{vizManager:t,panel:n,data:s,variables:i}=e,o=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={...hd(l,s,t,i)},u=o.configRender;return r.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},gd=(e,t)=>{const n=Ct.bezier(e),s=Ct.bezier(t);return function(i){return i<50?n(i*2/100).hex():s((i-50)*2/100).hex()}},gs=e=>{const t=Ct.bezier(e);return function(n){return t(n/100).hex()}},Jb={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:gd(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Zb={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:gd(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Hb={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:gs(["#fff7f1","darkred"]),name:"red",category:"sequential"},ey={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:gs(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},ty={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:gs(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},ny={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:gs(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class ry{constructor(t){N(this,"symbol");this.symbol=Symbol(t)}}function Zt(e){return new ry(e)}class xa{constructor(){N(this,"parent");N(this,"factoryRegistry",new Map);N(this,"instanceRegistry",new Map)}createScoped(){const t=new xa;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const s=n(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=v.get(t,"dispose");v.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const fd="13.43.12",sy=Object.freeze(Object.defineProperty({__proto__:null,version:fd},Symbol.toStringTag,{value:"Module"}));class iy{constructor(t){N(this,"staticColors",new Map);N(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class ay{constructor(){N(this,"plugins",new Map);N(this,"vizComponents",new Map);N(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class oy{constructor(){N(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,s){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const 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),n)}}class Te extends oy{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(s,i)=>({version:t,...n(s,i)}))}async migrate({configData:t,panelModel:n}){const s=await t.getItem(null),i=v.get(s,"version",0),o=this.run({from:i,to:this.VERSION},s,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return v.get(n,"version",0)<this.VERSION}}const W=(e,t)=>{const[n,{setFalse:s}]=Y.useBoolean(!0),[i,o]=g.useState();g.useEffect(()=>(e.getItem(t).then(c=>{o(c),s()}),e.watchItem(t,c=>{o(c)})));const l=g.useCallback(async c=>{await e.setItem(t,c),o(c)},[e,t]);return{loading:n,value:i,set:l}},rt={top:16,right:16,bottom:16,left:16},zt=e=>Math.max(0,e-rt.left-rt.right),It=e=>Math.max(0,e-rt.top-rt.bottom),kr=(e,t)=>({width:zt(e),height:It(t)}),st=({width:e,height:t,children:n})=>r.jsx(a.Box,{pt:rt.top,pr:rt.right,pb:rt.bottom,pl:rt.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n}),ma={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 ly({context:e}){const{value:t}=W(e.instanceData,"config"),n=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,ma),h=g.useMemo(()=>Br(n,o),[n,o]),{x,y,z:m}=g.useMemo(()=>({x:O(o),y:O(l),z:O(c)}),[o,l,c]),{min:j,max:k}=g.useMemo(()=>{const D=v.minBy(h,M=>M[m.columnKey]),I=v.maxBy(h,M=>M[m.columnKey]);return{min:v.get(D,m.columnKey),max:v.get(I,m.columnKey)}},[h,m]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:j,max:k,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(D=>[D[x.columnKey],D[y.columnKey],D[m.columnKey]])}]};return t?r.jsx(st,{width:s,height:i,children:r.jsx(Re,{echarts:Fe,option:T,style:kr(s,i),notMerge:!0,theme:"merico-light"})}):null}const Q=z.observer(g.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,queryID:o,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=Pe(),h=g.useMemo(()=>p.dataFieldOptionGroups(s,l,o),[s,l,o]);if(h.length===0){const x=p.explainDataKey(s);return r.jsxs(a.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[r.jsx(a.HoverCard.Target,{children:r.jsx(a.Box,{children:r.jsx(a.TextInput,{label:e,required:t,defaultValue:x.columnKey,readOnly:!0,disabled:!0})})}),r.jsx(a.HoverCard.Dropdown,{children:r.jsxs(a.Group,{justify:"flex-start",gap:0,children:[r.jsx(a.Text,{size:"xs",c:x.queryName?"black":"red",ff:"monospace",children:x.queryName??x.queryID}),r.jsx(a.Text,{size:"xs",c:"black",ff:"monospace",children:"."}),r.jsx(a.Text,{size:"xs",c:"red",ff:"monospace",children:x.columnKey})]})})]})}return r.jsx(a.Select,{ref:d,label:e,description:n,data:h,value:s,onChange:Ce(i),required:t,sx:c,maxDropdownHeight:500,...u})}));function cy({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),s=v.defaults({},t,ma),{control:i,handleSubmit:o,reset:l}=b.useForm({defaultValues:s});return g.useEffect(()=>{l(s)},[t]),t?r.jsx(a.Stack,{gap:"xs",children:r.jsxs("form",{onSubmit:o(n),children:[r.jsx(a.Text,{size:"sm",children:"X Axis"}),r.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>r.jsx(Q,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>r.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(a.Text,{mt:"lg",size:"sm",children:"Y Axis"}),r.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>r.jsx(Q,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>r.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(a.Text,{mt:"lg",size:"sm",children:"Z Axis"}),r.jsxs(a.Group,{justify:"space-between",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>r.jsx(Q,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>r.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(a.Group,{justify:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:r.jsxs(a.Button,{color:"blue",type:"submit",children:[r.jsx(C.IconDeviceFloppy,{size:20}),r.jsx(a.Text,{ml:"md",size:"sm",children:"Save"})]})})]})}):null}const uy=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function dy(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${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(n){throw console.error("[Migration failed]",n),n}}class py extends Te{constructor(){super(...arguments);N(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:dy(i,s)}})}}const hy={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new py,name:"bar-3d",viewRender:ly,configRender:cy,createConfig(){return{version:2,config:v.cloneDeep(ma)}},translation:uy},gy=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(a.Box,{sx:{position:"relative"},children:[e&&r.jsx(a.Overlay,{backgroundOpacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(ut,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function at({enabled:e,func_content:t}){return(n,s)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function Ke(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
93
93
|
`)}}const Mt=g.forwardRef(({value:e,onChange:t,triggerButtonText:n},s)=>{const{t:i}=_.useTranslation(),[o,{setTrue:l,setFalse:c}]=Y.useBoolean(),[u,d]=g.useState(e);g.useEffect(()=>{d(e)},[e]);const p=k=>{d({...u,enabled:k})},h=()=>{c();const{enabled:k,func_content:T}=u,D={enabled:k,func_content:T};d(D),t(D)},x=()=>{c(),d(e)},y=k=>{d(T=>({...T,func_content:k}))},m=()=>{y(Ke().func_content)},j=n??i("chart.axis.customize_label");return r.jsxs(r.Fragment,{children:[r.jsx(a.Button,{variant:"filled",color:"grape",leftSection:r.jsx(C.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:j}),r.jsx(a.Modal,{size:800,title:j,opened:o,onClose:c,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:o&&r.jsxs(a.Stack,{children:[r.jsx(a.Checkbox,{mt:10,label:i("common.enabled"),checked:u.enabled,onChange:k=>p(k.currentTarget.checked)}),r.jsx(gy,{value:u.func_content,onChange:y,disabled:!u.enabled}),r.jsxs(a.Group,{justify:"space-between",children:[r.jsx(a.Button,{onClick:m,color:"red",leftSection:r.jsx(C.IconRecycle,{size:20}),children:i("common.actions.reset_to_default")}),r.jsxs(a.Group,{justify:"flex-end",children:[r.jsx(a.Button,{onClick:x,variant:"subtle",children:i("common.actions.cancel")}),r.jsx(a.Button,{color:"green",leftSection:r.jsx(C.IconDeviceFloppy,{size:16}),onClick:h,children:i("common.actions.save")})]})]})]})})]})}),Cn={x_axis_scroll:!1,y_axis_scroll:!1,x_axis_slider:!1,y_axis_slider:!1};function xd(){return v.cloneDeep(Cn)}const fy=[{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:"点击箱体、散点或异常点"}}}}],md={id:"builtin:echarts:click-echart:series",displayName:"viz.boxplot.click_series.label",nameRender:my,configRender:xy,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 xy(e){return r.jsx(r.Fragment,{})}function my(e){const{t}=_.useTranslation();return r.jsx(a.Text,{size:"sm",children:t("viz.boxplot.click_series.label")})}const fs=g.forwardRef(({sectionTitle:e,value:t,onChange:n},s)=>{const{t:i,i18n:o}=_.useTranslation(),l=u=>d=>{const p=v.cloneDeep(t);v.set(p,u,d),n(p)},c=g.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 r.jsxs(a.Stack,{gap:0,children:[e&&r.jsx(a.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",styles:{label:{color:"dimmed"}}}),r.jsxs(a.Group,{grow:!0,wrap:"nowrap",children:[r.jsx(a.NumberInput,{label:i("chart.axis.overflow.max_width"),hideControls:!0,value:t.width,onChange:l("width")}),r.jsx(a.Select,{label:i("chart.axis.overflow.label"),data:c,value:t.overflow,onChange:l("overflow")}),r.jsx(a.TextInput,{label:i("chart.axis.overflow.ellipsis"),value:t.ellipsis,disabled:!0})]})]})}),Et=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),i=l=>{t({...e,on_axis:l})},o=l=>{t({...e,in_tooltip:l})};return r.jsxs(a.Stack,{ref:n,gap:0,children:[r.jsx(fs,{sectionTitle:s("chart.axis.overflow.section_title.on_axis"),value:e.on_axis,onChange:i}),r.jsx(fs,{sectionTitle:s("chart.axis.overflow.section_title.in_tooltip"),value:e.in_tooltip,onChange:o})]})});function ot(){return{on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}}}function vt({overflow:e,width:t}){const n={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: ${n};
|
|
@@ -495,7 +495,7 @@ Variable: {{ your_var }}`,tabs:{guide:"Guide",vars:"Dashboard state & Panel vari
|
|
|
495
495
|
value: string;
|
|
496
496
|
description?: string; // optional
|
|
497
497
|
}
|
|
498
|
-
`,ng=()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(a.Button,{variant:"subtle",size:"compact-sm",onClick:()=>n(s=>!s),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),r.jsx(a.Collapse,{in:t,children:r.jsx(Ut.CodeHighlight,{language:"typescript",withCopyButton:!1,code:kE})})]})},DE=z.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config,i=()=>{s.addStaticOption({label:"",value:""})},o=s.static_options,l=[...o];return r.jsxs(r.Fragment,{children:[r.jsxs(a.Group,{justify:"space-between",children:[r.jsx(a.Checkbox,{checked:s.required,onChange:c=>s.setRequired(c.currentTarget.checked),label:n("filter.widget.select.required")}),r.jsx(Tn,{filter:t})]}),r.jsx(a.TextInput,{label:n("filter.widget.select.width"),description:n("filter.widget.multi_select.width_description"),value:s.min_width,onChange:c=>s.setMinWidth(c.currentTarget.value),placeholder:"200px"}),r.jsx(a.Divider,{label:n("filter.widget.select.configure_options"),labelPosition:"center"}),r.jsxs(a.Stack,{gap:10,sx:{position:"relative",minHeight:"50px"},children:[s.usingQuery&&r.jsxs(r.Fragment,{children:[r.jsx(a.Overlay,{backgroundOpacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),r.jsx(a.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:r.jsx(a.Text,{c:"white",size:"16px",children:n("filter.widget.common.using_query")})})]}),o.length>0&&r.jsx(a.MultiSelect,{label:n("filter.widget.select.default_selection"),data:l,value:[...s.default_value],onChange:s.setDefaultValue}),o.map((c,u)=>r.jsxs(a.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[r.jsx(a.TextInput,{label:n("common.label"),required:!0,value:s.static_options[u].label,onChange:d=>{s.static_options[u].setLabel(d.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(a.TextInput,{label:n("common.value"),required:!0,value:s.static_options[u].value,onChange:d=>{s.static_options[u].setValue(d.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>s.removeStaticOption(u),sx:{position:"absolute",top:28,right:5},children:r.jsx(C.IconTrash,{size:16})})]},u)),r.jsx(a.Button,{mt:10,size:"xs",color:"blue",leftSection:r.jsx(C.IconPlaylistAdd,{size:20}),onClick:i,sx:{width:"50%"},mx:"auto",children:n("common.actions.add_an_option")})]}),r.jsx(a.Divider,{label:n("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),r.jsx(a.NumberInput,{value:s.default_selection_count,onChange:s.setDefaultSelectionCount,label:n("filter.widget.common.default_selection_count")}),r.jsx(Is,{value:s.options_query_id,onChange:s.setOptionsQueryID}),r.jsx(ng,{})]})}),zE=z.observer(function({filter:t}){const{t:n,i18n:s}=_.useTranslation(),i=t.config,o=()=>{i.addStaticOption({label:"",value:""})},l=i.static_options,c=g.useMemo(()=>[{label:n("filter.widget.select.no_default_selection"),value:""},...l],[s.language,l]);return r.jsxs(r.Fragment,{children:[r.jsxs(a.Group,{justify:"space-between",children:[r.jsx(a.Checkbox,{checked:i.required,onChange:u=>i.setRequired(u.currentTarget.checked),label:n("filter.widget.select.required")}),r.jsx(a.Checkbox,{checked:i.clearable,onChange:u=>i.setClearable(u.currentTarget.checked),label:n("filter.widget.select.clearable")}),r.jsx(Tn,{filter:t})]}),r.jsx(a.TextInput,{label:n("filter.widget.select.width"),value:i.width,onChange:u=>i.setWidth(u.currentTarget.value),placeholder:"200px"}),r.jsx(a.Divider,{label:n("filter.widget.select.configure_options"),labelPosition:"center"}),r.jsxs(a.Stack,{gap:10,sx:{position:"relative",minHeight:"50px"},children:[i.usingQuery&&r.jsxs(r.Fragment,{children:[r.jsx(a.Overlay,{backgroundOpacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),r.jsx(a.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:r.jsx(a.Text,{c:"white",size:"16px",children:n("filter.widget.common.using_query")})})]}),l.length>0&&r.jsx(a.Select,{label:n("filter.widget.select.default_selection"),data:c,value:i.default_value,onChange:i.setDefaultValue}),l.map((u,d)=>r.jsxs(a.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[r.jsx(a.TextInput,{label:n("common.label"),required:!0,value:i.static_options[d].label,onChange:p=>{i.static_options[d].setLabel(p.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(a.TextInput,{label:n("common.value"),required:!0,value:i.static_options[d].value,onChange:p=>{i.static_options[d].setValue(p.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>i.removeStaticOption(d),sx:{position:"absolute",top:28,right:5},children:r.jsx(C.IconTrash,{size:16})})]},d)),r.jsx(a.Button,{size:"xs",color:"blue",leftSection:r.jsx(C.IconPlaylistAdd,{size:20}),onClick:o,sx:{width:"50%"},mx:"auto",children:n("common.actions.add_an_option")})]}),r.jsx(a.Divider,{label:n("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),r.jsx(a.Checkbox,{checked:i.default_selection_count===1,onChange:u=>i.setDefaultSelectionCount(u.currentTarget.checked?1:0),label:n("filter.widget.select.select_first_option_by_default")}),r.jsx(Is,{value:i.options_query_id,onChange:i.setOptionsQueryID}),r.jsx(ng,{})]})}),IE=z.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config;return r.jsxs(r.Fragment,{children:[r.jsxs(a.Group,{children:[r.jsx(a.TextInput,{label:n("filter.widget.text_input.default_value"),value:s.default_value,onChange:i=>{s.setDefaultValue(i.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(a.Box,{mt:22,children:r.jsx(Tn,{filter:t})})]}),r.jsx(a.Checkbox,{checked:s.required,onChange:i=>s.setRequired(i.currentTarget.checked),label:n("filter.widget.text_input.required")})]})}),ME=z.observer(function({filter:t}){const{t:n}=_.useTranslation();return r.jsxs(a.Box,{sx:{maxWidth:"480px"},children:[r.jsx(a.Text,{pt:"0",pb:"md",c:"gray",size:"sm",children:n("common.titles.config")}),r.jsx(Ut.CodeHighlight,{mt:22,language:"json",withCopyButton:!1,code:JSON.stringify(t,null,4)})]})}),EE={[R.Select]:zE,[R.MultiSelect]:DE,[R.TreeSelect]:Vz,[R.TreeSingleSelect]:Fz,[R.TextInput]:IE,[R.Checkbox]:CE,[R.DateRange]:TE},yn={[R.Select]:"filter.widget.names.select",[R.MultiSelect]:"filter.widget.names.multi_select",[R.TreeSelect]:"filter.widget.names.tree_select",[R.TreeSingleSelect]:"filter.widget.names.tree_single_select",[R.TextInput]:"filter.widget.names.text_input",[R.Checkbox]:"filter.widget.names.checkbox",[R.DateRange]:"filter.widget.names.date_range"},AE=z.observer(function({filter:t}){const{t:n,i18n:s}=_.useTranslation(),i=ne(),o=g.useMemo(()=>EE[t.type],[t.type]),l=g.useMemo(()=>[{label:n(yn[R.Select]),value:"select"},{label:n(yn[R.MultiSelect]),value:"multi-select"},{label:n(yn[R.TreeSelect]),value:"tree-select"},{label:n(yn[R.TreeSingleSelect]),value:"tree-single-select"},{label:n(yn[R.TextInput]),value:"text-input"},{label:n(yn[R.Checkbox]),value:"checkbox"},{label:n(yn[R.DateRange]),value:"date-range"}],[s.language]);return r.jsxs(a.Group,{grow:!0,gap:20,align:"top",children:[r.jsxs(a.Box,{sx:{maxWidth:"600px"},children:[r.jsx(a.Text,{pb:"md",c:"gray",size:"sm",children:n("common.titles.edit")}),r.jsxs(a.Stack,{children:[r.jsxs(a.Group,{wrap:"nowrap",children:[r.jsx(a.NumberInput,{label:n("filter.field.order"),required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&r.jsx(a.Checkbox,{label:n("filter.field.auto_submit"),checked:t.auto_submit,onChange:c=>t.setAutoSubmit(c.currentTarget.checked),mt:22})]}),r.jsx(a.MultiSelect,{label:n("filter.field.visible_in"),data:i.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),r.jsx(a.TextInput,{label:n("common.key"),placeholder:n("filter.field.key_placeholder"),required:!0,value:t.key,onChange:c=>{t.setKey(c.currentTarget.value)}}),r.jsx(a.TextInput,{label:n("common.label"),placeholder:n("filter.field.label_placeholder"),required:!0,value:t.label,onChange:c=>{t.setLabel(c.currentTarget.value)}}),r.jsx(a.Select,{label:n("filter.field.widget"),data:l,required:!0,value:t.type,onChange:t.setType,maxDropdownHeight:500}),r.jsx(a.Divider,{mb:0,mt:10,variant:"dashed",labelPosition:"center"}),r.jsx(o,{filter:t})]})]}),r.jsx(ME,{filter:t})]})}),PE=z.observer(({id:e})=>{const{t}=_.useTranslation(),n=ft.useModals(),s=oe(),i=ne();if(e==="")return null;const o=i.filters.findByID(e);if(!o)return r.jsxs(a.Text,{size:"14px",children:["Filter by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_FILTERS_",""])},c=()=>{n.openConfirmModal({title:`${t("filter.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.filters.removeByID(e),l()},confirmProps:{color:"red"},zIndex:320})};return r.jsxs(a.Stack,{sx:{maxWidth:"1100px",height:"100vh"},gap:"sm",pb:30,children:[r.jsx(a.Group,{justify:"flex-end",pt:10,children:r.jsx(a.Button,{size:"xs",color:"red",leftSection:r.jsx(C.IconTrash,{size:16}),onClick:c,children:t("filter.delete")})}),r.jsx(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:r.jsx(AE,{filter:o})})]})}),LE=z.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState([]),s=oe(),i=d=>{s.editor.setPath(["_FILTERS_",d])},o=()=>{s.content.filters.downloadSchema(t)},l=g.useMemo(()=>s.content.filters.sortedList.map(d=>d.id),[s.content.filters.sortedList]),c=()=>{n(l)},u=()=>{n([])};return r.jsxs(a.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[r.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(a.Text,{size:"sm",px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("filter.manage")})}),r.jsx(a.Flex,{justify:"space-between",align:"center",px:12,children:r.jsxs(a.Group,{justify:"flex-start",children:[r.jsxs(a.Button.Group,{children:[r.jsx(a.Button,{variant:"default",size:"xs",onClick:c,children:e("common.actions.select_all")}),r.jsx(a.Button,{variant:"default",size:"xs",onClick:u,children:e("common.actions.clear_selection")})]}),r.jsx(a.Button,{size:"xs",color:"blue",leftSection:r.jsx(C.IconCode,{size:14}),disabled:t.length===0,onClick:o,children:e("common.actions.download_schema")})]})}),r.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:r.jsx(a.Checkbox.Group,{size:"xs",value:t,onChange:n,children:r.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx(a.Table.Thead,{children:r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Th,{style:{width:"40px"}}),r.jsx(a.Table.Th,{style:{width:"300px"},children:e("common.label")}),r.jsx(a.Table.Th,{children:e("common.key")}),r.jsx(a.Table.Th,{style:{width:"100px"},children:e("filter.field.widget")}),r.jsx(a.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),r.jsx(a.Table.Tbody,{children:s.content.filters.sortedList.map(d=>r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Td,{children:r.jsx(a.Checkbox,{value:d.id,styles:{input:{cursor:"pointer"}}})}),r.jsx(a.Table.Td,{children:d.label}),r.jsx(a.Table.Td,{children:d.key}),r.jsx(a.Table.Td,{children:e(yn[d.type])}),r.jsx(a.Table.Td,{children:r.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>i(d.id),children:e("common.actions.open")})})]},d.id))})]})})})]})}),OE=z.observer(()=>{const{t:e}=_.useTranslation(),t=ne(),[n,s]=g.useState(()=>JSON.stringify(t.mock_context.current,null,4)),i=()=>{try{t.mock_context.replace(JSON.parse(n))}catch(l){qt.showNotification({title:"Failed",message:l.message,color:"red"})}},o=g.useMemo(()=>{try{return JSON.stringify(JSON.parse(n))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[n,t.mock_context.current]);return r.jsxs(a.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[r.jsx(a.Group,{justify:"flex-start",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:r.jsx(a.Text,{size:"sm",fw:500,children:e("mock_context.label")})}),r.jsx(a.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:r.jsxs(a.Stack,{gap:10,sx:{maxWidth:"unset !important"},children:[r.jsxs(a.Group,{justify:"flex-start",children:[r.jsx(a.Text,{size:"sm",children:e("mock_context.hint")}),r.jsx(a.Button,{color:"green",size:"compact-sm",leftSection:r.jsx(C.IconDeviceFloppy,{size:16}),onClick:i,disabled:!o,children:e("common.actions.save")})]}),r.jsx(a.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:n,onChange:s,sx:{flexGrow:1}})]})})]})}),VE=z.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Pe();return r.jsx(xn,{label:e("panel.panel_description"),value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}},t.id)}),qE=z.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Pe(),n=Se().layouts.findItemByPanelID(t.id),{style:s}=t;return r.jsx(r.Fragment,{children:r.jsxs(a.Stack,{gap:20,children:[r.jsxs(a.Group,{grow:!0,align:"top",children:[r.jsx(a.NumberInput,{label:e("panel.style.width"),min:1,max:36,step:1,decimalScale:0,rightSection:r.jsx(a.Text,{size:"12px",children:e("panel.style.width_postfix")}),styles:{section:{width:"auto",maxWidth:"100px",paddingRight:"14px",justifyContent:"flex-end"}},value:n.w,onChange:i=>{typeof i!="string"&&n.setWidth(i)}}),r.jsx(a.NumberInput,{label:e("panel.style.height"),rightSection:r.jsx(a.Text,{size:"12px",children:e("panel.style.height_postfix")}),styles:{section:{width:"40px"}},value:n.h,onChange:i=>{typeof i!="string"&&n.setHeight(i)}})]}),r.jsx(a.Checkbox,{ml:6,label:e("panel.style.border"),checked:s.border.enabled,onChange:i=>s.border.setEnabled(i.currentTarget.checked)})]})})}),BE=()=>r.jsxs("span",{className:"mantine-103svbs mantine-InputWrapper-required mantine-Select-required","aria-hidden":"true",children:[" ","*"]}),NE=z.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Pe(),{name:n}=t,[s,i]=De.useInputState(n),o=n!==s,l=g.useCallback(()=>{o&&t.setName(s)},[o,s]);g.useEffect(()=>{i(n)},[n]);const c=!s.trim();return r.jsxs(a.Stack,{gap:4,children:[r.jsxs(a.Group,{align:"center",children:[r.jsxs(a.Text,{size:"14px",fw:500,children:[e("panel.panel_name"),r.jsx(BE,{})]}),r.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:!o||c,onClick:l,children:r.jsx(C.IconDeviceFloppy,{size:18})})]}),r.jsx(a.TextInput,{value:s,onChange:i,required:!0})]})}),$E=z.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Pe();return r.jsx(a.Stack,{gap:6,mb:10,children:r.jsxs(a.Group,{pl:6,justify:"flex-start",gap:20,children:[r.jsx(a.Checkbox,{size:"sm",checked:t.title.show,onChange:n=>t.title.setShow(n.currentTarget.checked),label:e("panel.show_title"),sx:{userSelect:"none"}}),r.jsx(a.Checkbox,{size:"sm",checked:!0,disabled:!0,label:e("panel.use_name_as_title")})]})})});function GE(){const{t:e}=_.useTranslation();return r.jsxs(a.Stack,{sx:{height:"100%"},children:[r.jsx(qE,{}),r.jsx(a.Divider,{label:e("common.info"),labelPosition:"center",variant:"dashed"}),r.jsx(NE,{}),r.jsx($E,{}),r.jsx(VE,{})]})}const FE={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 rg({data:e}){const t=g.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const s=St.createColumnHelper();return Object.keys(e[0]).map(i=>s.accessor(i,{cell:o=>o.getValue()}))},[e]),n=St.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:St.getCoreRowModel()});return e.length===0?r.jsx(a.Box,{sx:{height:"5em"}}):r.jsx(Ne,{children:r.jsxs(a.Table,{sx:FE,children:[r.jsx(a.Table.Thead,{children:n.getHeaderGroups().map(s=>r.jsx(a.Table.Tr,{children:s.headers.map(i=>r.jsxs(a.Table.Th,{style:{width:i.getSize()},children:[i.isPlaceholder?null:St.flexRender(i.column.columnDef.header,i.getContext()),r.jsx(a.ActionIcon,{variant:"subtle",onMouseDown:i.getResizeHandler(),onTouchStart:i.getResizeHandler(),className:`resizer ${i.column.getIsResizing()?"isResizing":""}`,children:r.jsx(C.IconArrowBarToRight,{})})]},i.id))},s.id))}),r.jsx(a.Table.Tbody,{children:n.getRowModel().rows.map(s=>r.jsx(a.Table.Tr,{children:s.getVisibleCells().map(i=>r.jsx(a.Table.Td,{children:r.jsx(Ne,{children:typeof i.getValue()=="object"?r.jsx("pre",{children:JSON.stringify(i.getValue(),null,2)}):St.flexRender(i.column.columnDef.cell,i.getContext())})},i.id))},s.id))})]})})}const RE=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],WE={icon:{width:"80px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"80px"}}},QE=({data:e,page:t,setPage:n,limit:s,setLimit:i})=>{const{t:o}=_.useTranslation(),l=e.length,c=Math.ceil(l/s),u=p=>{p&&(n(1),i(Number(p)))};if(l===0)return null;const d=c===1&&l<=10;return r.jsxs(a.Group,{pt:10,px:10,justify:"space-between",children:[r.jsxs(a.Group,{justify:"flex-start",children:[c>1&&r.jsx(a.Pagination,{size:"sm",value:t,onChange:n,total:c,withEdges:c>7,styles:{control:{height:"30px"}}}),!d&&r.jsx(a.Select,{leftSection:r.jsx(a.Text,{ta:"center",c:"dimmed",size:"14px",children:o("common.pagination.page_size")}),size:"xs",styles:WE,data:RE,value:String(s),onChange:u})]}),r.jsx(a.Group,{justify:"flex-end",children:r.jsx(a.Text,{c:"dimmed",my:0,size:"14px",children:o("common.pagination.total_rows",{total:l})})})]})},UE=Lb(({data:e,loading:t})=>{const[n,s]=g.useState(1),[i,o]=g.useState(20),l=g.useMemo(()=>{const c=(n-1)*i,u=c+i;return e.slice(c,u)},[e,n,i]);return r.jsxs(Ne,{children:[r.jsx(QE,{data:e,page:n,setPage:s,limit:i,setLimit:o}),r.jsxs(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[r.jsx(a.LoadingOverlay,{visible:t,overlayProps:{blur:2}}),r.jsx(rg,{data:l})]})]})}),YE=({queryID:e})=>{const t=Se(),{state:n,error:s}=t.getDataStuffByID(e),i=g.useMemo(()=>t.queries.findByID(e),[t,e]);return n==="loading"?null:s?r.jsx(a.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:s}):i!=null&&i.stateMessage?r.jsx(a.Text,{size:"sm",mt:10,c:"gray",ta:"center",children:i.stateMessage}):null},Go=z.observer(({id:e,moreActions:t,refreshOnMount:n})=>{const{t:s}=_.useTranslation(),i=Se(),{data:o,state:l}=i.getDataStuffByID(e),c=l==="loading",u=g.useCallback(()=>{i.queries.refetchDataByQueryID(e)},[e,i]),d=()=>{i.queries.downloadDataByQueryID(e)};g.useEffect(()=>{n&&u()},[u,n]);const p=!Array.isArray(o)||o.length===0;return r.jsxs(a.Stack,{gap:0,sx:{height:"100%",border:"1px solid #eee"},children:[r.jsxs(a.Group,{justify:"space-between",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[r.jsx(a.Group,{justify:"flex-start",children:r.jsx(a.Text,{size:"sm",fw:500,children:s("data.preview_data")})}),r.jsxs(a.Group,{pr:15,children:[t,r.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:c,onClick:u,children:r.jsx(C.IconRefresh,{size:16})}),r.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:c||p,onClick:d,children:r.jsx(C.IconDownload,{size:16})})]})]}),r.jsxs(a.Box,{pb:20,sx:{position:"relative",flexGrow:1,overflow:"auto"},children:[r.jsx(YE,{queryID:e}),r.jsx(UE,{data:o,loading:c})]})]})}),KE=z.observer(function(){const{t}=_.useTranslation(),n=oe(),s=ne(),{panel:i}=Pe(),[o,l]=g.useState(!1),c=d=>{n.editor.setPath(["_QUERIES_",d])},u=i.queryIDs.length;return r.jsxs(r.Fragment,{children:[r.jsx(a.Drawer,{opened:o,onClose:()=>l(!1),title:t("panel.settings.choose_queries"),padding:"xl",size:500,zIndex:320,children:r.jsx(a.Checkbox.Group,{value:[...i.queryIDs],onChange:i.setQueryIDs,children:r.jsx(a.Stack,{gap:"lg",children:s.queries.options.map(d=>r.jsx(a.Checkbox,{label:d.label,value:d.value},d.value))})})}),r.jsxs(a.Stack,{gap:6,children:[r.jsx(a.Group,{justify:"flex-start",children:r.jsx(a.Button,{variant:"light",size:"sm",leftSection:r.jsx(C.IconLine,{size:16}),onClick:()=>l(!0),children:t(u===0?"panel.settings.need_to_choose_queries":"panel.settings.choose_queries")})}),u===1&&r.jsx(Go,{id:i.queryIDs[0],moreActions:r.jsx(a.Tooltip,{label:t("query.open"),children:r.jsx(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(i.queryIDs[0]),children:r.jsx(C.IconArrowCurveRight,{size:16})})})}),u>1&&r.jsxs(a.Tabs,{defaultValue:i.queryIDs[0],children:[r.jsx(a.Tabs.List,{children:i.queries.map(d=>r.jsx(a.Tabs.Tab,{value:d.id,children:d.name},d.id))}),i.queries.map(d=>r.jsx(a.Tabs.Panel,{value:d.id,children:r.jsx(Go,{id:d.id,moreActions:r.jsx(a.Tooltip,{label:t("query.open"),children:r.jsx(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(d.id),children:r.jsx(C.IconArrowCurveRight,{size:16})})})})},d.id))]})]})]})}),XE=z.observer(()=>{const{panel:e}=Xe();return e.title.show?r.jsx(a.Group,{grow:!0,justify:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:r.jsx(a.Text,{size:"sm",ta:"center",lineClamp:1,className:"panel-title-text",children:e.title.show?e.name:""})}):null}),JE=z.observer(()=>{const{panel:e}=Xe();return r.jsx(Ne,{children:r.jsxs(a.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,p:0,sx:{border:"1px solid",borderColor:e.style.border.enabled?"#e9ecef":"transparent",flexGrow:0,flexShrink:0,width:"600px !important",height:"450px !important"},children:[r.jsx(a.Box,{className:"panel-description-popover-wrapper",children:r.jsx(Eo,{})}),r.jsx(XE,{}),r.jsx(Ao,{panel:e})]})})});function ZE(){const{t:e}=_.useTranslation(),{vizManager:t}=g.useContext(en);return g.useMemo(()=>v.orderBy(Object.entries(v.groupBy(t.availableVizList,"displayGroup")),[i=>i[0]],["asc"]).map(([i,o])=>{const l=o.map(c=>({value:c.name,label:e(c.displayName??it.name)}));return{group:e(i??"ungrouped"),items:v.orderBy(l,[c=>c.label],["asc"])}}),[t])}const HE=z.observer(({value:e,submit:t})=>{const{t:n}=_.useTranslation(),[s,i]=De.useInputState(e);g.useEffect(()=>{i(e)},[e]);const o=ZE(),l=e!==s;return r.jsx(a.Select,{label:n("visualization.component"),value:s,searchable:!0,onChange:i,data:o,rightSection:r.jsx(a.ActionIcon,{variant:"filled",color:"green",disabled:!l,onClick:()=>t(s),children:r.jsx(C.IconDeviceFloppy,{size:20})}),maxDropdownHeight:600})}),sg=[];function eA(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function tA(){const{data:e,panel:{variables:t,viz:n,title:s,name:i,queryIDs:o,description:l,id:c}}=Pe(),{vizManager:u}=g.useContext(en),d={name:i,title:s,description:l,viz:n,queryIDs:o,id:c},p=bh(d);try{return u.resolveComponent(d.viz.type),r.jsx(zs,{configure:p,children:r.jsx(kI,{variables:t,setVizConf:n.setConf,panel:d,vizManager:u,data:e})})}catch(h){return console.info(v.get(h,"message")),null}}const nA=z.observer(()=>{const{data:e,panel:{viz:t}}=Pe(),{vizManager:n}=g.useContext(en),s=g.useCallback(d=>{if(d===t.type)return;const p=eA(n,d);t.setType(d),t.setConf(p||{})},[t.type]),i=d=>{try{t.setConf(JSON.parse(d))}catch(p){console.error(p)}},o=g.useMemo(()=>{var d;return(d=sg.find(p=>p.value===t.type))==null?void 0:d.Panel},[t.type,sg]),l=tA(),c=o?g.createElement(o,{data:e,conf:t.conf,setConf:t.setConf}):null,u=l||c;return r.jsxs(a.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[r.jsx(HE,{submit:s,value:t.type}),r.jsxs(Ne,{children:[r.jsx(a.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:u}),!u&&r.jsx(a.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:i})]})]})}),rA=z.observer(({panel:e,sourceViewID:t})=>{const{t:n}=_.useTranslation(),s=ne(),[i,o]=g.useState(t);g.useEffect(()=>{o(t)},[t]);const[l,{open:c,close:u}]=De.useDisclosure(!1),d=()=>{e.moveToView(t,i),u()};return r.jsxs(r.Fragment,{children:[r.jsx(a.Button,{size:"xs",variant:"subtle",color:"blue",onClick:c,leftSection:r.jsx(C.IconBoxMultiple,{size:14}),children:n("panel.settings.change_view")}),r.jsx(a.Modal,{opened:l,onClose:u,title:n("panel.settings.change_view_title"),zIndex:320,children:r.jsxs(a.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[r.jsx(a.Radio.Group,{value:i,onChange:o,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:r.jsx(a.Stack,{gap:"xs",children:s.views.options.map(p=>r.jsx(a.Radio,{value:p.value,label:p.label},p.value))})}),r.jsxs(a.Group,{wrap:"nowrap",justify:"space-between",sx:{flexGrow:0,flexShrink:0},children:[r.jsx(a.Button,{size:"xs",color:"red",leftSection:r.jsx(C.IconX,{size:14}),onClick:u,children:n("common.actions.cancel")}),r.jsx(a.Button,{size:"xs",color:"blue",leftSection:r.jsx(C.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===t,children:n("common.actions.confirm")})]})]})})]})}),sA=z.observer(({sx:e={}})=>{const{t}=_.useTranslation(),n=Se(),{panel:s}=Xe(),i=n.dashboardState,o=(()=>{const l={...i,...s.variableStrings};return JSON.stringify(l,null,2)})();return r.jsx(a.Stack,{sx:{overflow:"hidden",...e},children:r.jsxs(a.Tabs,{defaultValue:"vars",keepMounted:!1,children:[r.jsxs(a.Tabs.List,{children:[r.jsx(a.Tabs.Tab,{value:"guide",leftSection:r.jsx(C.IconAlertCircle,{size:14}),children:t("panel.variable.guide.tabs.guide")}),r.jsx(a.Tabs.Tab,{value:"vars",leftSection:r.jsx(C.IconVariable,{size:14}),children:t("panel.variable.guide.tabs.vars")})]}),r.jsx(a.Tabs.Panel,{value:"guide",pt:"xs",children:r.jsx(Ut.CodeHighlight,{language:"sql",sx:{width:"100%"},withCopyButton:!1,code:t("panel.variable.guide.text")})}),r.jsx(a.Tabs.Panel,{value:"vars",pt:"xs",children:r.jsx(Ut.CodeHighlight,{language:"json",sx:{width:"100%"},withCopyButton:!1,code:o})})]})})}),Fo={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{},fallback:"0"},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class iA{constructor(t){N(this,"panel");N(this,"selected");this.panel=t,t.variables.length>0&&(this.selected=t.variables[0]),te.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}get variableOptions(){return this.panel.variables.map(t=>({label:t.name,value:t.name,description:t.aggregation.type}))}addNew(){const t=this.panel.variables.filter(n=>n.name.startsWith(Fo.name)).length;this.panel.addVariable(v.cloneDeep({...Fo,name:`${Fo.name}${t||""}`})),this.selected=v.last(this.panel.variables)}select(t){this.selected=t}selectByName(t){if(!t){console.warn("Unexpected null name when calling selectByName");return}const n=this.variables.find(s=>s.name===t);if(!n){console.error(`Variable by name[${t}] not found`);return}this.selected=n}remove(t){this.selected===t&&(this.selected=void 0);const n=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!v.isEmpty(this.panel.variables)){const s=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[s]}}}function aA(){const{panel:e}=Pe();return Y.useCreation(()=>new iA(e),[e])}const oA=g.forwardRef(function({value:t,onChange:n,remove:s},i){const{t:o}=_.useTranslation(),l=(c,u)=>{const d=v.cloneDeep(t);v.set(d,c,u),n(d)};return r.jsxs(a.Stack,{ref:i,children:[r.jsxs(a.Stack,{gap:"xs",px:"sm",py:"md",sx:{border:"1px solid #e9ecef"},children:[r.jsxs(a.Group,{grow:!0,wrap:"nowrap",children:[r.jsx(a.TextInput,{label:o("common.name"),required:!0,value:t.name,onChange:c=>l("name",c.currentTarget.value)}),r.jsx(Q,{label:o("common.data_field"),required:!0,value:t.data_field,onChange:c=>l("data_field",c)})]}),r.jsx(Aa,{label:o("panel.variable.aggregation.label"),pt:0,value:t.aggregation,onChange:c=>l("aggregation",c),withFallback:!0}),t.aggregation.type!=="custom"&&r.jsxs(r.Fragment,{children:[r.jsx(a.Divider,{mt:"xl",mb:0,label:o("numbro.format.label"),labelPosition:"center",variant:"dashed"}),r.jsx(jt,{value:t.formatter,onChange:c=>l("formatter",c)})]})]}),r.jsx(a.Button,{mt:20,leftSection:r.jsx(C.IconTrash,{size:16}),color:"red",variant:"light",onClick:s,children:o("panel.variable.delete")})]})}),lA=z.observer(e=>{const{t}=_.useTranslation(),n=Y.useCreation(()=>ph(e.variable),[e.variable]),s=()=>e.uiModel.remove(e.variable);return r.jsxs(a.Stack,{"data-testid":"variable-editor",align:"stretch",children:[r.jsxs(a.Group,{justify:"space-between",children:[r.jsx(a.Button,{variant:"subtle",size:"xs",disabled:!n.changed,color:"red",onClick:n.reset,leftSection:r.jsx(C.IconRecycle,{size:18}),children:t("common.actions.revert_changes")}),r.jsx(a.Button,{variant:"filled",size:"xs",disabled:!n.changed,color:"green",onClick:n.commit,leftSection:r.jsx(C.IconDeviceFloppy,{size:18}),children:t("common.actions.save_changes")})]}),r.jsx(oA,{value:f.getSnapshot(n.copy),onChange:n.update,remove:s})]})});z.observer(e=>{const{uiModel:t}=e;return r.jsx(a.Stack,{className:"var-list",children:t.variables.map(n=>r.jsx(a.Button,{variant:t.selected===n?"filled":"subtle",color:"gray",onClick:()=>t.select(n),children:n.name},n.name))})});const cA=z.observer(({model:e})=>{const{t}=_.useTranslation();return r.jsx(a.Overlay,{color:"#fff",backgroundOpacity:1,sx:{position:"absolute"},children:r.jsx(a.Button,{variant:"light",size:"xs",leftSection:r.jsx(C.IconPlus,{size:16}),onClick:e.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:t("panel.variable.add")})})}),uA=z.observer(()=>{var n;const{t:e}=_.useTranslation(),t=aA();return t.variableOptions.length===0?r.jsx(cA,{model:t}):r.jsxs(a.Stack,{pb:20,children:[r.jsxs(a.Group,{justify:"flex-start",children:[r.jsx(a.Select,{label:e("panel.variable.labels"),data:t.variableOptions,value:(n=t.selected)==null?void 0:n.name,onChange:t.selectByName,maxDropdownHeight:600,sx:{flexGrow:1}}),r.jsx(a.Button,{variant:"light",size:"xs",leftSection:r.jsx(C.IconPlus,{size:16}),onClick:t.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:e("panel.variable.add")})]}),r.jsx(a.Divider,{variant:"dashed"}),t.selected?r.jsx(lA,{uiModel:t,variable:t.selected}):r.jsx("span",{children:"Select or create a new variable on right side"})]})}),dA={root:{flexGrow:1,width:"100%",minWidth:"1200px",overflow:"hidden"},panel:{width:"100%",minWidth:"1200px",height:"calc(100% - 44px)",padding:10,overflow:"auto"}},Ro=({children:e})=>r.jsxs(a.Group,{wrap:"nowrap",grow:!0,justify:"flex-start",gap:20,sx:{width:"100%",height:"100%",position:"relative"},children:[r.jsx(a.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),r.jsxs(a.Stack,{justify:"flex-start",sx:{alignSelf:"flex-start",width:"600px",flexGrow:0,flexShrink:0},children:[r.jsx(JE,{}),r.jsx(a.Box,{sx:{flexGrow:1},children:r.jsx(sA,{})})]})]});function pA(e){return!["richText","button"].includes(e)}const hA=z.observer(({panel:e})=>{const{t}=_.useTranslation(),n=ft.useModals(),s=oe(),i=ne(),[o,l]=g.useState(s.editor.panelTab),c=e.queries,d=pA(e.viz.type)&&e.dataLoading,p=d||e.queryErrors.length>0||e.queryStateMessages!==""||c.length===0,h=s.editor.path[1];g.useEffect(()=>{l(j=>p&&j==="Visualization"?"Data":j)},[e.id,p]);const x=g.useCallback(j=>{l(j),s.editor.setPanelTab(o)},[]),y=()=>{s.editor.setPath(["_VIEWS_",h])},m=()=>n.openConfirmModal({title:`${t("panel.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.removePanelByID(e.id,h),y()},confirmProps:{color:"red"},zIndex:320});return r.jsxs(ni,{value:{panel:e,data:e.data,loading:d,errors:e.queryErrors,downloadPanelScreenshot:()=>{}},children:[r.jsxs(a.Group,{px:16,justify:"space-between",sx:{borderBottom:"1px solid #eee"},children:[r.jsx(a.Text,{size:"sm",pt:9,pb:8,children:e.name}),r.jsxs(a.Group,{justify:"flex-end",wrap:"nowrap",children:[r.jsx(rA,{panel:e,sourceViewID:h}),r.jsx(a.Button,{size:"xs",variant:"subtle",color:"red",onClick:m,leftSection:r.jsx(C.IconTrash,{size:14}),children:t("panel.delete")})]})]}),r.jsxs(a.Tabs,{value:o,onChange:x,keepMounted:!1,styles:dA,children:[r.jsxs(a.Tabs.List,{children:[r.jsx(a.Tabs.Tab,{value:"Data",leftSection:r.jsx(C.IconDatabase,{size:14}),disabled:d,children:t("data.label")}),r.jsx(a.Tabs.Tab,{value:"Panel",leftSection:r.jsx(C.IconAppWindow,{size:14}),children:t("panel.label")}),r.jsx(a.Tabs.Tab,{value:"Variables",leftSection:r.jsx(C.IconVariable,{size:14}),disabled:p,children:r.jsx(a.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:r.jsx(a.Text,{size:"sm",children:t("panel.variable.labels")})})}),r.jsx(a.Tabs.Tab,{value:"Visualization",leftSection:r.jsx(C.IconChartHistogram,{size:14}),disabled:p,children:r.jsx(a.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:r.jsx(a.Text,{size:"sm",children:t("visualization.label")})})}),r.jsx(a.Tabs.Tab,{value:"Interactions",leftSection:r.jsx(C.IconRoute,{size:14}),children:t("interactions.label")})]}),r.jsxs(a.Tabs.Panel,{value:"Data",children:[r.jsx(a.LoadingOverlay,{visible:d,transitionProps:{exitDuration:0}}),r.jsx(KE,{})]}),r.jsx(a.Tabs.Panel,{value:"Panel",children:r.jsx(Ro,{children:r.jsx(GE,{})})}),r.jsx(a.Tabs.Panel,{value:"Variables",children:r.jsx(Ro,{children:r.jsx(uA,{})})}),r.jsx(a.Tabs.Panel,{value:"Visualization",children:r.jsx(Ne,{children:r.jsx(Ro,{children:r.jsx(nA,{})})})}),r.jsx(a.Tabs.Panel,{value:"Interactions",children:r.jsx(Ne,{children:r.jsx(iv,{})})})]})]})}),gA=z.observer(({viewID:e,panelID:t})=>{const n=ne();if(!n.views.findByID(e))return r.jsxs(a.Text,{size:"14px",children:["View by ID[",e,"] is not found"]});const i=n.panels.findByID(t);return i?r.jsx(hA,{panel:i}):r.jsxs(a.Text,{size:"14px",children:["Panel by ID[",t,"] is not found"]})}),fA=z.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState([]),s=ft.useModals(),i=oe(),o=x=>{i.editor.setPath(["_QUERIES_",x])},l=()=>{s.openConfirmModal({title:"Delete ununsed queries?",children:r.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.removeUnusedQueries(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.queries.downloadSchema(t)},u=g.useMemo(()=>i.content.queries.sortedList.map(x=>x.id),[i.content.queries.sortedList]),d=()=>{n(u)},p=()=>{n([])},h=i.content.queriesUsage;return r.jsxs(a.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[r.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(a.Text,{px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("query.manage")})}),r.jsxs(a.Flex,{justify:"space-between",align:"center",px:12,children:[r.jsxs(a.Group,{justify:"flex-start",children:[r.jsxs(a.Button.Group,{children:[r.jsx(a.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),r.jsx(a.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),r.jsx(a.Button,{size:"xs",color:"blue",leftSection:r.jsx(C.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),r.jsx(a.Button,{variant:"subtle",size:"xs",color:"red",leftSection:r.jsx(C.IconTrash,{size:14}),disabled:!i.content.hasUnusedQueries,onClick:l,children:e("query.delete_unused")})]}),r.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:r.jsx(a.Checkbox.Group,{size:"xs",value:t,onChange:n,children:r.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx(a.Table.Thead,{children:r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Th,{style:{width:"40px"}}),r.jsx(a.Table.Th,{children:e("common.name")}),r.jsx(a.Table.Th,{style:{width:"200px"},children:e("data_source.label")}),r.jsx(a.Table.Th,{style:{width:"100px",textAlign:"right"},children:e("common.type")}),r.jsx(a.Table.Th,{style:{width:"100px",textAlign:"center"},children:e("query.usage.label")}),r.jsx(a.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),r.jsx(a.Table.Tbody,{children:i.content.queries.sortedList.map(x=>{var m;const y=((m=h[x.id])==null?void 0:m.length)??0;return r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Td,{children:r.jsx(a.Checkbox,{value:x.id,styles:{input:{cursor:"pointer"}}})}),r.jsx(a.Table.Td,{children:x.name}),r.jsx(a.Table.Td,{children:x.key}),r.jsx(a.Table.Td,{style:{textAlign:"right"},children:x.type}),r.jsx(a.Table.Td,{style:{color:y===0?"#ff0000":"#000",fontWeight:y===0?"bold":"normal",textAlign:"center"},children:y}),r.jsx(a.Table.Td,{children:r.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>o(x.id),children:e("common.actions.open")})})]},x.id)})})]})})})]})}),xA=e=>{const{t}=_.useTranslation(),{queryModel:n}=e,s=oe(),i=ne(),l=i.findQueryUsage(n.id).length>0,c=ft.useModals(),u=()=>{c.openConfirmModal({title:`${t("query.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.queries.removeQuery(n.id),s.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return l?r.jsx(a.Tooltip,{label:t("query.cant_delete"),withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"top-end",children:r.jsx(a.Box,{sx:{alignSelf:"flex-end"},children:r.jsx(a.Button,{disabled:!0,size:"xs",leftSection:r.jsx(C.IconTrash,{size:16}),children:t("query.delete")})})}):r.jsx(a.Button,{color:"red",size:"xs",onClick:u,leftSection:r.jsx(C.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:t("query.delete")})},mA=z.observer(xA),ig=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:n,count:s,spacing:i=16,pl:o=0})=>r.jsxs(a.Stack,{gap:i,mt:6,pl:o,children:[Array.from(new Array(s-1),(l,c)=>r.jsx(a.Skeleton,{width:e,height:n,radius:"xs"},c)),r.jsx(a.Skeleton,{width:t,height:n,radius:"xs"})]}),Mr=({value:e})=>e===null||e===""?null:r.jsx(a.Tooltip,{label:e,disabled:!e,multiline:!0,zIndex:340,children:r.jsx(a.ActionIcon,{variant:"subtle",children:r.jsx(C.IconInfoCircle,{size:14})})}),bA=({column:e})=>{const{column_key:t,column_key_text:n}=e;return t?r.jsx(a.Tooltip,{label:n,disabled:!n,children:r.jsx(a.Badge,{variant:"light",children:t})}):null},yA=z.observer(({dataSource:e})=>{const{columns:t}=e;return t.loading?r.jsx(ig,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:r.jsxs(a.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{width:50}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:30}}),r.jsx("col",{style:{width:70}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{minWidth:80,width:80}}),r.jsx("col",{style:{minWidth:120,width:120}})]}),r.jsx(a.Table.Thead,{children:r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Th,{children:"#"}),r.jsx(a.Table.Th,{children:"Column Name"}),r.jsx(a.Table.Th,{}),r.jsx(a.Table.Th,{}),r.jsx(a.Table.Th,{children:"Type"}),r.jsx(a.Table.Th,{children:"Nullable"}),r.jsx(a.Table.Th,{children:"Default Value"})]})}),r.jsx(a.Table.Tbody,{children:t.data.map(n=>r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Td,{children:n.ordinal_position}),r.jsx(a.Table.Td,{children:n.column_name}),r.jsx(a.Table.Td,{children:r.jsx(Mr,{value:n.column_comment})}),r.jsx(a.Table.Td,{children:r.jsx(bA,{column:n})}),r.jsx(a.Table.Td,{children:n.column_type}),r.jsx(a.Table.Td,{children:n.is_nullable}),r.jsx(a.Table.Td,{children:r.jsx(Mr,{value:n.column_default})})]},n.column_name))})]})}),vA=z.observer(({dataSource:e})=>{const{indexes:t}=e,n=t.data;return r.jsxs(a.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:250}})]}),r.jsx(a.Table.Thead,{children:r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Th,{children:"Index Length"}),r.jsx(a.Table.Th,{children:"Index Name"}),r.jsx(a.Table.Th,{children:"Index Algorithm"}),r.jsx(a.Table.Th,{children:"Unique"}),r.jsx(a.Table.Th,{children:"Column Name"})]})}),r.jsx(a.Table.Tbody,{children:n.map(s=>r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Td,{children:s.index_length}),r.jsx(a.Table.Td,{children:s.index_name}),r.jsx(a.Table.Td,{children:s.index_algorithm}),r.jsx(a.Table.Td,{children:s.is_unique?"YES":"NO"}),r.jsx(a.Table.Td,{children:s.column_name})]},s.index_name))})]})}),_A=z.observer(({dataSource:e})=>{const{indexes:t}=e,n=t.data;return r.jsxs(a.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}})]}),r.jsx(a.Table.Thead,{children:r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Th,{children:"Index Name"}),r.jsx(a.Table.Th,{children:"Index Algorithm"}),r.jsx(a.Table.Th,{children:"Unique"}),r.jsx(a.Table.Th,{children:"Definition"}),r.jsx(a.Table.Th,{children:"Condition"}),r.jsx(a.Table.Th,{children:"Comment"})]})}),r.jsx(a.Table.Tbody,{children:n.map(s=>r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Td,{children:s.index_name}),r.jsx(a.Table.Td,{children:s.index_algorithm}),r.jsx(a.Table.Td,{children:s.is_unique?"YES":"NO"}),r.jsx(a.Table.Td,{children:r.jsx(Mr,{value:s.index_definition})}),r.jsx(a.Table.Td,{children:r.jsx(Mr,{value:s.condition})}),r.jsx(a.Table.Td,{children:r.jsx(Mr,{value:s.comment})})]},s.index_name))})]})}),jA=z.observer(({dataSource:e})=>{const{indexes:t}=e;return t.loading||t.empty?null:e.type===Ie.MySQL?r.jsx(vA,{dataSource:e}):e.type===Ie.Postgresql?r.jsx(_A,{dataSource:e}):null}),wA=z.observer(({dataSource:e})=>r.jsxs(a.Stack,{gap:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[r.jsx(Ne,{children:r.jsx(yA,{dataSource:e})}),r.jsx(Ne,{children:r.jsx(jA,{dataSource:e})})]}));function CA({table_type:e}){return e==="VIEW"?r.jsx(C.IconEye,{size:14}):e==="BASE TABLE"?r.jsx(C.IconTable,{size:14}):null}const SA=z.observer(({dataSource:e})=>{const{tables:t}=e;return t.loading?r.jsx(ig,{height:"24px",lastWidth:"50%",count:15}):r.jsx(a.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(t.data).map(([n,s])=>r.jsx(a.NavLink,{label:n,title:n,leftSection:r.jsx(C.IconDatabase,{size:14}),defaultOpened:e.table_schema===n,pl:0,childrenOffset:14,children:s.map(i=>r.jsx(a.NavLink,{label:i.table_name,title:i.table_name,leftSection:r.jsx(CA,{table_type:i.table_type}),onClick:()=>{e.setKeywords(n,i.table_name)},active:e.table_name===i.table_name},i.table_name))},n))})}),TA=({visible:e})=>r.jsx(a.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:r.jsx(a.LoadingOverlay,{visible:e})}),kA=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],DA={section:{width:"50px",textAlign:"center"},input:{paddingLeft:"50px"}},zA=z.observer(({dataSource:e})=>{const{t}=_.useTranslation(),{tableData:n}=e;return r.jsxs(a.Group,{pt:10,px:10,justify:"space-between",children:[r.jsxs(a.Group,{justify:"flex-start",children:[n.maxPage>1&&r.jsx(a.Pagination,{size:"sm",value:n.page,onChange:n.setPage,total:n.maxPage,withEdges:n.maxPage>7,styles:{control:{height:"30px"}}}),r.jsx(a.Select,{leftSection:r.jsx(a.Text,{ta:"center",c:"dimmed",size:"14px",children:t("common.pagination.page_size")}),size:"xs",styles:DA,data:kA,value:String(n.limit),onChange:s=>n.setLimit(Number(s)),comboboxProps:{zIndex:340}})]}),r.jsx(a.Group,{justify:"flex-end",children:r.jsx(a.Text,{c:"dimmed",my:0,size:"14px",children:t("common.pagination.total_rows",{total:n.total})})})]})}),IA=z.observer(({dataSource:e})=>{const t=e.tableData;return t.maxPage===0?r.jsx(a.Text,{mt:20,c:"red",size:"md",ta:"center",ff:"monospace",children:"This table is empty"}):t.error?r.jsx(a.Text,{mt:20,c:"red",size:"md",ta:"center",ff:"monospace",children:t.error}):t.page===1&&t.loading?r.jsx(TA,{visible:!0}):r.jsxs(Ne,{children:[r.jsx(zA,{dataSource:e}),r.jsxs(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[r.jsx(a.LoadingOverlay,{visible:t.loading,overlayProps:{blur:2}}),r.jsx(rg,{data:t.data})]})]})}),MA={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},EA=z.observer(({dataSource:e})=>{const{t}=_.useTranslation();return g.useEffect(()=>{e.loadTablesIfEmpty()},[e]),e.tables.error?r.jsx(a.Text,{c:"red",size:"md",ta:"center",ff:"monospace",children:e.tables.error}):r.jsxs(a.Flex,{sx:{height:"100%"},children:[r.jsx(a.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:r.jsx(Ne,{children:r.jsx(SA,{dataSource:e})})}),r.jsxs(a.Tabs,{defaultValue:"structure",styles:MA,children:[r.jsxs(a.Tabs.List,{children:[r.jsx(a.Tabs.Tab,{value:"structure",leftSection:r.jsx(C.IconColumns,{size:14}),children:t("data_source.table_structure_short")}),r.jsx(a.Tabs.Tab,{value:"data",leftSection:r.jsx(C.IconDatabase,{size:14}),children:t("data.label")})]}),r.jsx(a.Tabs.Panel,{value:"structure",children:r.jsx(wA,{dataSource:e})}),r.jsx(a.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:r.jsx(IA,{dataSource:e})})]})]})}),AA={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"20px 20px 10px",borderBottom:"1px solid #efefef",gap:"20px"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},ag=z.observer(({dataSource:e,triggerButtonProps:t={}})=>{const{t:n}=_.useTranslation(),[s,i]=g.useState(!1);return e.type==="http"?null:r.jsxs(r.Fragment,{children:[r.jsx(a.Modal,{opened:s,onClose:()=>i(!1),title:r.jsxs(a.Group,{justify:"space-between",sx:{flexGrow:1},children:[r.jsx(a.Text,{size:"sm",fw:500,children:n("data_source.explorer")}),r.jsxs(a.Group,{gap:7,children:[r.jsx(a.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:e.key}),r.jsx(a.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:e.type})]})]}),zIndex:320,size:"96vw",styles:AA,children:r.jsx(a.Box,{sx:{height:"calc(100vh - 220px)"},children:r.jsx(EA,{dataSource:e})})}),r.jsx(a.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:n("data_source.see_table_structure")})]})}),PA=({option:e,...t})=>{const{label:n,type:s}=e;return s===Ie.Transform?r.jsxs(a.Group,{className:"transform-query-option",justify:"flex-start",...t,sx:{'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}},children:[r.jsx(C.IconVectorTriangle,{size:14,color:"#228be6"}),r.jsx(a.Text,{size:"sm",c:"blue",children:n})]}):r.jsxs(a.Group,{justify:"space-between",...t,children:[r.jsx(a.Text,{size:"sm",children:n}),r.jsx(a.Text,{size:"sm",children:s})]})},LA=z.observer(({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),s=oe(),{data:i=[],loading:o}=Y.useRequest(fa,{refreshDeps:[]},[]),l=g.useMemo(()=>{const p=i.map(h=>({label:h.key,value:h.key,type:h.type}));return p.push({label:n("query.transform.data_source"),value:Ie.Transform,type:Ie.Transform}),p},[i]),c=g.useMemo(()=>l.reduce((p,h)=>(p[h.value]=h.type,p),{}),[l]),u=p=>{p!==null&&t({key:p,type:c[p]})},d=g.useMemo(()=>s.datasources.find(e),[s,e]);return r.jsx(a.Select,{data:l,label:r.jsxs(a.Group,{justify:"space-between",children:[r.jsx(a.Box,{children:n("data_source.label")}),d&&r.jsx(ag,{dataSource:d,triggerButtonProps:{size:"compact-xs",px:10}})]}),renderOption:PA,rightSection:d?r.jsx(a.Text,{size:"xs",c:"dimmed",children:d.type}):void 0,rightSectionWidth:85,maxDropdownHeight:500,styles:{root:{flex:1},label:{display:"block"},section:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:o,value:e.key,onChange:u})}),OA=z.observer(({queryModel:e})=>{const{t}=_.useTranslation(),[n,s]=g.useState(e.name);return g.useEffect(()=>{s(e.name)},[e.name]),r.jsx(a.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:r.jsxs(a.Stack,{gap:10,sx:{width:"100%"},children:[r.jsx(a.Divider,{mb:-10,variant:"dashed",label:t("query.basics"),labelPosition:"center"}),r.jsx(a.TextInput,{placeholder:t("query.name_description"),label:t("query.name"),required:!0,sx:{flex:1},value:n,onChange:i=>{s(i.currentTarget.value)},rightSection:r.jsx(a.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>e.setName(n),disabled:n===e.name,children:r.jsx(C.IconDeviceFloppy,{size:16})}),onBlur:()=>{e.setName(n)}}),r.jsx(LA,{value:{type:e.type,key:e.key},onChange:({type:i,key:o})=>{e.setKey(o),e.setType(i)}}),r.jsx(a.Divider,{mt:10,mb:-10,variant:"dashed",label:t("query.conditions"),labelPosition:"center"}),r.jsx(a.MultiSelect,{label:t("query.run_by_condition.label"),description:t("query.run_by_condition.description"),placeholder:t("query.run_by_condition.unset"),data:e.conditionOptions,value:[...e.run_by],onChange:e.setRunBy,renderOption:rd,maxDropdownHeight:500}),e.typedAsHTTP&&r.jsx(a.MultiSelect,{label:t("query.re_run_condition.label"),placeholder:t("query.re_run_condition.label"),data:e.conditionOptions,value:[...e.react_to],onChange:e.setReactTo,renderOption:rd,maxDropdownHeight:500}),r.jsx(a.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(mA,{queryModel:e})]})})});function VA({content:e}){return r.jsxs(a.HoverCard,{width:"60vw",shadow:"md",zIndex:340,children:[r.jsx(a.HoverCard.Target,{children:r.jsx(a.ActionIcon,{size:16,color:"blue",variant:"subtle",children:r.jsx(C.IconEye,{})})}),r.jsx(a.HoverCard.Dropdown,{children:r.jsx(Ut.CodeHighlight,{language:"sql",withCopyButton:!1,code:e})})]})}const qA=z.observer(()=>{const t=[...oe().globalSQLSnippets.list];return t.length===0?null:r.jsxs(a.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fz:"sm",highlightOnHover:!0,children:[r.jsx(a.Table.Thead,{children:r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Th,{children:"Key"}),r.jsx(a.Table.Th,{children:"Value"})]})}),r.jsx(a.Table.Tbody,{children:t.map(n=>{const{id:s,content:i}=n;return r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Td,{children:s}),r.jsx(a.Table.Td,{width:200,children:r.jsx(VA,{content:i})})]},s)})})]})}),BA=`
|
|
498
|
+
`,ng=()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(a.Button,{variant:"subtle",size:"compact-sm",onClick:()=>n(s=>!s),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),r.jsx(a.Collapse,{in:t,children:r.jsx(Ut.CodeHighlight,{language:"typescript",withCopyButton:!1,code:kE})})]})},DE=z.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config,i=()=>{s.addStaticOption({label:"",value:""})},o=s.static_options,l=[...o];return r.jsxs(r.Fragment,{children:[r.jsxs(a.Group,{justify:"space-between",children:[r.jsx(a.Checkbox,{checked:s.required,onChange:c=>s.setRequired(c.currentTarget.checked),label:n("filter.widget.select.required")}),r.jsx(Tn,{filter:t})]}),r.jsx(a.TextInput,{label:n("filter.widget.select.width"),description:n("filter.widget.multi_select.width_description"),value:s.min_width,onChange:c=>s.setMinWidth(c.currentTarget.value),placeholder:"200px"}),r.jsx(a.Divider,{label:n("filter.widget.select.configure_options"),labelPosition:"center"}),r.jsxs(a.Stack,{gap:10,sx:{position:"relative",minHeight:"50px"},children:[s.usingQuery&&r.jsxs(r.Fragment,{children:[r.jsx(a.Overlay,{backgroundOpacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),r.jsx(a.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:r.jsx(a.Text,{c:"white",size:"16px",children:n("filter.widget.common.using_query")})})]}),o.length>0&&r.jsx(a.MultiSelect,{label:n("filter.widget.select.default_selection"),data:l,value:[...s.default_value],onChange:s.setDefaultValue}),o.map((c,u)=>r.jsxs(a.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[r.jsx(a.TextInput,{label:n("common.label"),required:!0,value:s.static_options[u].label,onChange:d=>{s.static_options[u].setLabel(d.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(a.TextInput,{label:n("common.value"),required:!0,value:s.static_options[u].value,onChange:d=>{s.static_options[u].setValue(d.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>s.removeStaticOption(u),sx:{position:"absolute",top:28,right:5},children:r.jsx(C.IconTrash,{size:16})})]},u)),r.jsx(a.Button,{mt:10,size:"xs",color:"blue",leftSection:r.jsx(C.IconPlaylistAdd,{size:20}),onClick:i,sx:{width:"50%"},mx:"auto",children:n("common.actions.add_an_option")})]}),r.jsx(a.Divider,{label:n("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),r.jsx(a.NumberInput,{value:s.default_selection_count,onChange:s.setDefaultSelectionCount,label:n("filter.widget.common.default_selection_count")}),r.jsx(Is,{value:s.options_query_id,onChange:s.setOptionsQueryID}),r.jsx(ng,{})]})}),zE=z.observer(function({filter:t}){const{t:n,i18n:s}=_.useTranslation(),i=t.config,o=()=>{i.addStaticOption({label:"",value:""})},l=i.static_options,c=g.useMemo(()=>[{label:n("filter.widget.select.no_default_selection"),value:""},...l],[s.language,l]);return r.jsxs(r.Fragment,{children:[r.jsxs(a.Group,{justify:"space-between",children:[r.jsx(a.Checkbox,{checked:i.required,onChange:u=>i.setRequired(u.currentTarget.checked),label:n("filter.widget.select.required")}),r.jsx(a.Checkbox,{checked:i.clearable,onChange:u=>i.setClearable(u.currentTarget.checked),label:n("filter.widget.select.clearable")}),r.jsx(Tn,{filter:t})]}),r.jsx(a.TextInput,{label:n("filter.widget.select.width"),value:i.width,onChange:u=>i.setWidth(u.currentTarget.value),placeholder:"200px"}),r.jsx(a.Divider,{label:n("filter.widget.select.configure_options"),labelPosition:"center"}),r.jsxs(a.Stack,{gap:10,sx:{position:"relative",minHeight:"50px"},children:[i.usingQuery&&r.jsxs(r.Fragment,{children:[r.jsx(a.Overlay,{backgroundOpacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),r.jsx(a.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:r.jsx(a.Text,{c:"white",size:"16px",children:n("filter.widget.common.using_query")})})]}),l.length>0&&r.jsx(a.Select,{label:n("filter.widget.select.default_selection"),data:c,value:i.default_value,onChange:i.setDefaultValue}),l.map((u,d)=>r.jsxs(a.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[r.jsx(a.TextInput,{label:n("common.label"),required:!0,value:i.static_options[d].label,onChange:p=>{i.static_options[d].setLabel(p.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(a.TextInput,{label:n("common.value"),required:!0,value:i.static_options[d].value,onChange:p=>{i.static_options[d].setValue(p.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>i.removeStaticOption(d),sx:{position:"absolute",top:28,right:5},children:r.jsx(C.IconTrash,{size:16})})]},d)),r.jsx(a.Button,{size:"xs",color:"blue",leftSection:r.jsx(C.IconPlaylistAdd,{size:20}),onClick:o,sx:{width:"50%"},mx:"auto",children:n("common.actions.add_an_option")})]}),r.jsx(a.Divider,{label:n("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),r.jsx(a.Checkbox,{checked:i.default_selection_count===1,onChange:u=>i.setDefaultSelectionCount(u.currentTarget.checked?1:0),label:n("filter.widget.select.select_first_option_by_default")}),r.jsx(Is,{value:i.options_query_id,onChange:i.setOptionsQueryID}),r.jsx(ng,{})]})}),IE=z.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config;return r.jsxs(r.Fragment,{children:[r.jsxs(a.Group,{children:[r.jsx(a.TextInput,{label:n("filter.widget.text_input.default_value"),value:s.default_value,onChange:i=>{s.setDefaultValue(i.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(a.Box,{mt:22,children:r.jsx(Tn,{filter:t})})]}),r.jsx(a.Checkbox,{checked:s.required,onChange:i=>s.setRequired(i.currentTarget.checked),label:n("filter.widget.text_input.required")})]})}),ME=z.observer(function({filter:t}){const{t:n}=_.useTranslation();return r.jsxs(a.Box,{sx:{maxWidth:"480px"},children:[r.jsx(a.Text,{pt:"0",pb:"md",c:"gray",size:"sm",children:n("common.titles.config")}),r.jsx(Ut.CodeHighlight,{mt:22,language:"json",withCopyButton:!1,code:JSON.stringify(t,null,4)})]})}),EE={[R.Select]:zE,[R.MultiSelect]:DE,[R.TreeSelect]:Vz,[R.TreeSingleSelect]:Fz,[R.TextInput]:IE,[R.Checkbox]:CE,[R.DateRange]:TE},yn={[R.Select]:"filter.widget.names.select",[R.MultiSelect]:"filter.widget.names.multi_select",[R.TreeSelect]:"filter.widget.names.tree_select",[R.TreeSingleSelect]:"filter.widget.names.tree_single_select",[R.TextInput]:"filter.widget.names.text_input",[R.Checkbox]:"filter.widget.names.checkbox",[R.DateRange]:"filter.widget.names.date_range"},AE=z.observer(function({filter:t}){const{t:n,i18n:s}=_.useTranslation(),i=ne(),o=g.useMemo(()=>EE[t.type],[t.type]),l=g.useMemo(()=>[{label:n(yn[R.Select]),value:"select"},{label:n(yn[R.MultiSelect]),value:"multi-select"},{label:n(yn[R.TreeSelect]),value:"tree-select"},{label:n(yn[R.TreeSingleSelect]),value:"tree-single-select"},{label:n(yn[R.TextInput]),value:"text-input"},{label:n(yn[R.Checkbox]),value:"checkbox"},{label:n(yn[R.DateRange]),value:"date-range"}],[s.language]);return r.jsxs(a.Group,{grow:!0,gap:20,align:"top",children:[r.jsxs(a.Box,{sx:{maxWidth:"600px"},children:[r.jsx(a.Text,{pb:"md",c:"gray",size:"sm",children:n("common.titles.edit")}),r.jsxs(a.Stack,{children:[r.jsxs(a.Group,{wrap:"nowrap",children:[r.jsx(a.NumberInput,{label:n("filter.field.order"),required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&r.jsx(a.Checkbox,{label:n("filter.field.auto_submit"),checked:t.auto_submit,onChange:c=>t.setAutoSubmit(c.currentTarget.checked),mt:22})]}),r.jsx(a.MultiSelect,{label:n("filter.field.visible_in"),data:i.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),r.jsx(a.TextInput,{label:n("common.key"),placeholder:n("filter.field.key_placeholder"),required:!0,value:t.key,onChange:c=>{t.setKey(c.currentTarget.value)}}),r.jsx(a.TextInput,{label:n("common.label"),placeholder:n("filter.field.label_placeholder"),required:!0,value:t.label,onChange:c=>{t.setLabel(c.currentTarget.value)}}),r.jsx(a.Select,{label:n("filter.field.widget"),data:l,required:!0,value:t.type,onChange:t.setType,maxDropdownHeight:500}),r.jsx(a.Divider,{mb:0,mt:10,variant:"dashed",labelPosition:"center"}),r.jsx(o,{filter:t})]})]}),r.jsx(ME,{filter:t})]})}),PE=z.observer(({id:e})=>{const{t}=_.useTranslation(),n=ft.useModals(),s=oe(),i=ne();if(e==="")return null;const o=i.filters.findByID(e);if(!o)return r.jsxs(a.Text,{size:"14px",children:["Filter by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_FILTERS_",""])},c=()=>{n.openConfirmModal({title:`${t("filter.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.filters.removeByID(e),l()},confirmProps:{color:"red"},zIndex:320})};return r.jsxs(a.Stack,{sx:{maxWidth:"1100px",height:"100vh"},gap:"sm",pb:30,children:[r.jsx(a.Group,{justify:"flex-end",pt:10,children:r.jsx(a.Button,{size:"xs",color:"red",leftSection:r.jsx(C.IconTrash,{size:16}),onClick:c,children:t("filter.delete")})}),r.jsx(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:r.jsx(AE,{filter:o})})]})}),LE=z.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState([]),s=oe(),i=d=>{s.editor.setPath(["_FILTERS_",d])},o=()=>{s.content.filters.downloadSchema(t)},l=g.useMemo(()=>s.content.filters.sortedList.map(d=>d.id),[s.content.filters.sortedList]),c=()=>{n(l)},u=()=>{n([])};return r.jsxs(a.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[r.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(a.Text,{size:"sm",px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("filter.manage")})}),r.jsx(a.Flex,{justify:"space-between",align:"center",px:12,children:r.jsxs(a.Group,{justify:"flex-start",children:[r.jsxs(a.Button.Group,{children:[r.jsx(a.Button,{variant:"default",size:"xs",onClick:c,children:e("common.actions.select_all")}),r.jsx(a.Button,{variant:"default",size:"xs",onClick:u,children:e("common.actions.clear_selection")})]}),r.jsx(a.Button,{size:"xs",color:"blue",leftSection:r.jsx(C.IconCode,{size:14}),disabled:t.length===0,onClick:o,children:e("common.actions.download_schema")})]})}),r.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:r.jsx(a.Checkbox.Group,{size:"xs",value:t,onChange:n,children:r.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx(a.Table.Thead,{children:r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Th,{style:{width:"40px"}}),r.jsx(a.Table.Th,{style:{width:"300px"},children:e("common.label")}),r.jsx(a.Table.Th,{children:e("common.key")}),r.jsx(a.Table.Th,{style:{width:"100px"},children:e("filter.field.widget")}),r.jsx(a.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),r.jsx(a.Table.Tbody,{children:s.content.filters.sortedList.map(d=>r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Td,{children:r.jsx(a.Checkbox,{value:d.id,styles:{input:{cursor:"pointer"}}})}),r.jsx(a.Table.Td,{children:d.label}),r.jsx(a.Table.Td,{children:d.key}),r.jsx(a.Table.Td,{children:e(yn[d.type])}),r.jsx(a.Table.Td,{children:r.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>i(d.id),children:e("common.actions.open")})})]},d.id))})]})})})]})}),OE=z.observer(()=>{const{t:e}=_.useTranslation(),t=ne(),[n,s]=g.useState(()=>JSON.stringify(t.mock_context.current,null,4)),i=()=>{try{t.mock_context.replace(JSON.parse(n))}catch(l){qt.showNotification({title:"Failed",message:l.message,color:"red"})}},o=g.useMemo(()=>{try{return JSON.stringify(JSON.parse(n))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[n,t.mock_context.current]);return r.jsxs(a.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[r.jsx(a.Group,{justify:"flex-start",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:r.jsx(a.Text,{size:"sm",fw:500,children:e("mock_context.label")})}),r.jsx(a.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:r.jsxs(a.Stack,{gap:10,sx:{maxWidth:"unset !important"},children:[r.jsxs(a.Group,{justify:"flex-start",children:[r.jsx(a.Text,{size:"sm",children:e("mock_context.hint")}),r.jsx(a.Button,{color:"green",size:"compact-sm",leftSection:r.jsx(C.IconDeviceFloppy,{size:16}),onClick:i,disabled:!o,children:e("common.actions.save")})]}),r.jsx(a.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:n,onChange:s,sx:{flexGrow:1}})]})})]})}),VE=z.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Pe();return r.jsx(xn,{label:e("panel.panel_description"),value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}},t.id)}),qE=z.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Pe(),n=Se().layouts.findItemByPanelID(t.id),{style:s}=t;return r.jsx(r.Fragment,{children:r.jsxs(a.Stack,{gap:20,children:[r.jsxs(a.Group,{grow:!0,align:"top",children:[r.jsx(a.NumberInput,{label:e("panel.style.width"),min:1,max:36,step:1,decimalScale:0,rightSection:r.jsx(a.Text,{size:"12px",children:e("panel.style.width_postfix")}),styles:{section:{width:"auto",maxWidth:"100px",paddingRight:"14px",justifyContent:"flex-end"}},value:n.w,onChange:i=>{typeof i!="string"&&n.setWidth(i)}}),r.jsx(a.NumberInput,{label:e("panel.style.height"),rightSection:r.jsx(a.Text,{size:"12px",children:e("panel.style.height_postfix")}),styles:{section:{width:"40px"}},value:n.h,onChange:i=>{typeof i!="string"&&n.setHeight(i)}})]}),r.jsx(a.Checkbox,{ml:6,label:e("panel.style.border"),checked:s.border.enabled,onChange:i=>s.border.setEnabled(i.currentTarget.checked)})]})})}),BE=()=>r.jsxs("span",{className:"mantine-103svbs mantine-InputWrapper-required mantine-Select-required","aria-hidden":"true",children:[" ","*"]}),NE=z.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Pe(),{name:n}=t,[s,i]=De.useInputState(n),o=n!==s,l=g.useCallback(()=>{o&&t.setName(s)},[o,s]);g.useEffect(()=>{i(n)},[n]);const c=!s.trim();return r.jsxs(a.Stack,{gap:4,children:[r.jsxs(a.Group,{align:"center",children:[r.jsxs(a.Text,{size:"14px",fw:500,children:[e("panel.panel_name"),r.jsx(BE,{})]}),r.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:!o||c,onClick:l,children:r.jsx(C.IconDeviceFloppy,{size:18})})]}),r.jsx(a.TextInput,{value:s,onChange:i,required:!0})]})}),$E=z.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Pe();return r.jsx(a.Stack,{gap:6,mb:10,children:r.jsxs(a.Group,{pl:6,justify:"flex-start",gap:20,children:[r.jsx(a.Checkbox,{size:"sm",checked:t.title.show,onChange:n=>t.title.setShow(n.currentTarget.checked),label:e("panel.show_title"),sx:{userSelect:"none"}}),r.jsx(a.Checkbox,{size:"sm",checked:!0,disabled:!0,label:e("panel.use_name_as_title")})]})})});function GE(){const{t:e}=_.useTranslation();return r.jsxs(a.Stack,{sx:{height:"100%"},children:[r.jsx(qE,{}),r.jsx(a.Divider,{label:e("common.info"),labelPosition:"center",variant:"dashed"}),r.jsx(NE,{}),r.jsx($E,{}),r.jsx(VE,{})]})}const FE={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 rg({data:e}){const t=g.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const s=St.createColumnHelper();return Object.keys(e[0]).map(i=>s.accessor(i,{cell:o=>o.getValue()}))},[e]),n=St.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:St.getCoreRowModel()});return e.length===0?r.jsx(a.Box,{sx:{height:"5em"}}):r.jsx(Ne,{children:r.jsxs(a.Table,{sx:FE,children:[r.jsx(a.Table.Thead,{children:n.getHeaderGroups().map(s=>r.jsx(a.Table.Tr,{children:s.headers.map(i=>r.jsxs(a.Table.Th,{style:{width:i.getSize()},children:[i.isPlaceholder?null:St.flexRender(i.column.columnDef.header,i.getContext()),r.jsx(a.ActionIcon,{variant:"subtle",onMouseDown:i.getResizeHandler(),onTouchStart:i.getResizeHandler(),className:`resizer ${i.column.getIsResizing()?"isResizing":""}`,children:r.jsx(C.IconArrowBarToRight,{})})]},i.id))},s.id))}),r.jsx(a.Table.Tbody,{children:n.getRowModel().rows.map(s=>r.jsx(a.Table.Tr,{children:s.getVisibleCells().map(i=>r.jsx(a.Table.Td,{children:r.jsx(Ne,{children:typeof i.getValue()=="object"?r.jsx("pre",{children:JSON.stringify(i.getValue(),null,2)}):St.flexRender(i.column.columnDef.cell,i.getContext())})},i.id))},s.id))})]})})}const RE=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],WE={icon:{width:"80px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"80px"}}},QE=({data:e,page:t,setPage:n,limit:s,setLimit:i})=>{const{t:o}=_.useTranslation(),l=e.length,c=Math.ceil(l/s),u=p=>{p&&(n(1),i(Number(p)))};if(l===0)return null;const d=c===1&&l<=10;return r.jsxs(a.Group,{pt:10,px:10,justify:"space-between",children:[r.jsxs(a.Group,{justify:"flex-start",children:[c>1&&r.jsx(a.Pagination,{size:"sm",value:t,onChange:n,total:c,withEdges:c>7,styles:{control:{height:"30px"}}}),!d&&r.jsx(a.Select,{leftSection:r.jsx(a.Text,{ta:"center",c:"dimmed",size:"14px",children:o("common.pagination.page_size")}),size:"xs",styles:WE,data:RE,value:String(s),onChange:u})]}),r.jsx(a.Group,{justify:"flex-end",children:r.jsx(a.Text,{c:"dimmed",my:0,size:"14px",children:o("common.pagination.total_rows",{total:l})})})]})},UE=Lb(({data:e,loading:t})=>{const[n,s]=g.useState(1),[i,o]=g.useState(20),l=g.useMemo(()=>{const c=(n-1)*i,u=c+i;return e.slice(c,u)},[e,n,i]);return r.jsxs(Ne,{children:[r.jsx(QE,{data:e,page:n,setPage:s,limit:i,setLimit:o}),r.jsxs(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[r.jsx(a.LoadingOverlay,{visible:t,overlayProps:{blur:2}}),r.jsx(rg,{data:l})]})]})}),YE=({queryID:e})=>{const t=Se(),{state:n,error:s}=t.getDataStuffByID(e),i=g.useMemo(()=>t.queries.findByID(e),[t,e]);return n==="loading"?null:s?r.jsx(a.Text,{mt:10,c:"red",size:"md",ta:"center",ff:"monospace",children:s}):i!=null&&i.stateMessage?r.jsx(a.Text,{size:"sm",mt:10,c:"gray",ta:"center",children:i.stateMessage}):null},Go=z.observer(({id:e,moreActions:t,refreshOnMount:n})=>{const{t:s}=_.useTranslation(),i=Se(),{data:o,state:l}=i.getDataStuffByID(e),c=l==="loading",u=g.useCallback(()=>{i.queries.refetchDataByQueryID(e)},[e,i]),d=()=>{i.queries.downloadDataByQueryID(e)};g.useEffect(()=>{n&&u()},[u,n]);const p=!Array.isArray(o)||o.length===0;return r.jsxs(a.Stack,{gap:0,sx:{height:"100%",border:"1px solid #eee"},children:[r.jsxs(a.Group,{justify:"space-between",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[r.jsx(a.Group,{justify:"flex-start",children:r.jsx(a.Text,{size:"sm",fw:500,children:s("data.preview_data")})}),r.jsxs(a.Group,{pr:15,children:[t,r.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:c,onClick:u,children:r.jsx(C.IconRefresh,{size:16})}),r.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:c||p,onClick:d,children:r.jsx(C.IconDownload,{size:16})})]})]}),r.jsxs(a.Box,{pb:20,sx:{position:"relative",flexGrow:1,overflow:"auto"},children:[r.jsx(YE,{queryID:e}),r.jsx(UE,{data:o,loading:c})]})]})}),KE=z.observer(function(){const{t}=_.useTranslation(),n=oe(),s=ne(),{panel:i}=Pe(),[o,l]=g.useState(!1),c=d=>{n.editor.setPath(["_QUERIES_",d])},u=i.queryIDs.length;return r.jsxs(r.Fragment,{children:[r.jsx(a.Drawer,{opened:o,onClose:()=>l(!1),title:t("panel.settings.choose_queries"),padding:"xl",size:500,zIndex:320,children:r.jsx(a.Checkbox.Group,{value:[...i.queryIDs],onChange:i.setQueryIDs,children:r.jsx(a.Stack,{gap:"lg",children:s.queries.options.map(d=>r.jsx(a.Checkbox,{label:d.label,value:d.value},d.value))})})}),r.jsxs(a.Stack,{gap:6,children:[r.jsx(a.Group,{justify:"flex-start",children:r.jsx(a.Button,{variant:"light",size:"sm",leftSection:r.jsx(C.IconLine,{size:16}),onClick:()=>l(!0),children:t(u===0?"panel.settings.need_to_choose_queries":"panel.settings.choose_queries")})}),u===1&&r.jsx(Go,{id:i.queryIDs[0],moreActions:r.jsx(a.Tooltip,{label:t("query.open"),children:r.jsx(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(i.queryIDs[0]),children:r.jsx(C.IconArrowCurveRight,{size:16})})})}),u>1&&r.jsxs(a.Tabs,{defaultValue:i.queryIDs[0],children:[r.jsx(a.Tabs.List,{children:i.queries.map(d=>r.jsx(a.Tabs.Tab,{value:d.id,children:d.name},d.id))}),i.queries.map(d=>r.jsx(a.Tabs.Panel,{value:d.id,children:r.jsx(Go,{id:d.id,moreActions:r.jsx(a.Tooltip,{label:t("query.open"),children:r.jsx(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(d.id),children:r.jsx(C.IconArrowCurveRight,{size:16})})})})},d.id))]})]})]})}),XE=z.observer(()=>{const{panel:e}=Xe();return e.title.show?r.jsx(a.Group,{grow:!0,justify:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:r.jsx(a.Text,{size:"sm",ta:"center",lineClamp:1,className:"panel-title-text",children:e.title.show?e.name:""})}):null}),JE=z.observer(()=>{const{panel:e}=Xe();return r.jsx(Ne,{children:r.jsxs(a.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,p:0,sx:{border:"1px solid",borderColor:e.style.border.enabled?"#e9ecef":"transparent",flexGrow:0,flexShrink:0,width:"600px !important",height:"450px !important"},children:[r.jsx(a.Box,{className:"panel-description-popover-wrapper",children:r.jsx(Eo,{})}),r.jsx(XE,{}),r.jsx(Ao,{panel:e})]})})});function ZE(){const{t:e}=_.useTranslation(),{vizManager:t}=g.useContext(en);return g.useMemo(()=>v.orderBy(Object.entries(v.groupBy(t.availableVizList,"displayGroup")),[i=>i[0]],["asc"]).map(([i,o])=>{const l=o.map(c=>({value:c.name,label:e(c.displayName??it.name)}));return{group:e(i??"ungrouped"),items:v.orderBy(l,[c=>c.label],["asc"])}}),[t])}const HE=z.observer(({value:e,submit:t})=>{const{t:n}=_.useTranslation(),[s,i]=De.useInputState(e);g.useEffect(()=>{i(e)},[e]);const o=ZE(),l=e!==s;return r.jsx(a.Select,{label:n("visualization.component"),value:s,searchable:!0,onChange:i,data:o,rightSection:r.jsx(a.ActionIcon,{variant:"filled",color:"green",disabled:!l,onClick:()=>t(s),styles:{root:{pointerEvents:"all"}},children:r.jsx(C.IconDeviceFloppy,{size:20})}),maxDropdownHeight:600})}),sg=[];function eA(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function tA(){const{data:e,panel:{variables:t,viz:n,title:s,name:i,queryIDs:o,description:l,id:c}}=Pe(),{vizManager:u}=g.useContext(en),d={name:i,title:s,description:l,viz:n,queryIDs:o,id:c},p=bh(d);try{return u.resolveComponent(d.viz.type),r.jsx(zs,{configure:p,children:r.jsx(kI,{variables:t,setVizConf:n.setConf,panel:d,vizManager:u,data:e})})}catch(h){return console.info(v.get(h,"message")),null}}const nA=z.observer(()=>{const{data:e,panel:{viz:t}}=Pe(),{vizManager:n}=g.useContext(en),s=g.useCallback(d=>{if(d===t.type)return;const p=eA(n,d);t.setType(d),t.setConf(p||{})},[t.type]),i=d=>{try{t.setConf(JSON.parse(d))}catch(p){console.error(p)}},o=g.useMemo(()=>{var d;return(d=sg.find(p=>p.value===t.type))==null?void 0:d.Panel},[t.type,sg]),l=tA(),c=o?g.createElement(o,{data:e,conf:t.conf,setConf:t.setConf}):null,u=l||c;return r.jsxs(a.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[r.jsx(HE,{submit:s,value:t.type}),r.jsxs(Ne,{children:[r.jsx(a.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:u}),!u&&r.jsx(a.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:i})]})]})}),rA=z.observer(({panel:e,sourceViewID:t})=>{const{t:n}=_.useTranslation(),s=ne(),[i,o]=g.useState(t);g.useEffect(()=>{o(t)},[t]);const[l,{open:c,close:u}]=De.useDisclosure(!1),d=()=>{e.moveToView(t,i),u()};return r.jsxs(r.Fragment,{children:[r.jsx(a.Button,{size:"xs",variant:"subtle",color:"blue",onClick:c,leftSection:r.jsx(C.IconBoxMultiple,{size:14}),children:n("panel.settings.change_view")}),r.jsx(a.Modal,{opened:l,onClose:u,title:n("panel.settings.change_view_title"),zIndex:320,children:r.jsxs(a.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[r.jsx(a.Radio.Group,{value:i,onChange:o,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:r.jsx(a.Stack,{gap:"xs",children:s.views.options.map(p=>r.jsx(a.Radio,{value:p.value,label:p.label},p.value))})}),r.jsxs(a.Group,{wrap:"nowrap",justify:"space-between",sx:{flexGrow:0,flexShrink:0},children:[r.jsx(a.Button,{size:"xs",color:"red",leftSection:r.jsx(C.IconX,{size:14}),onClick:u,children:n("common.actions.cancel")}),r.jsx(a.Button,{size:"xs",color:"blue",leftSection:r.jsx(C.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===t,children:n("common.actions.confirm")})]})]})})]})}),sA=z.observer(({sx:e={}})=>{const{t}=_.useTranslation(),n=Se(),{panel:s}=Xe(),i=n.dashboardState,o=(()=>{const l={...i,...s.variableStrings};return JSON.stringify(l,null,2)})();return r.jsx(a.Stack,{sx:{overflow:"hidden",...e},children:r.jsxs(a.Tabs,{defaultValue:"vars",keepMounted:!1,children:[r.jsxs(a.Tabs.List,{children:[r.jsx(a.Tabs.Tab,{value:"guide",leftSection:r.jsx(C.IconAlertCircle,{size:14}),children:t("panel.variable.guide.tabs.guide")}),r.jsx(a.Tabs.Tab,{value:"vars",leftSection:r.jsx(C.IconVariable,{size:14}),children:t("panel.variable.guide.tabs.vars")})]}),r.jsx(a.Tabs.Panel,{value:"guide",pt:"xs",children:r.jsx(Ut.CodeHighlight,{language:"sql",sx:{width:"100%"},withCopyButton:!1,code:t("panel.variable.guide.text")})}),r.jsx(a.Tabs.Panel,{value:"vars",pt:"xs",children:r.jsx(Ut.CodeHighlight,{language:"json",sx:{width:"100%"},withCopyButton:!1,code:o})})]})})}),Fo={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{},fallback:"0"},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class iA{constructor(t){N(this,"panel");N(this,"selected");this.panel=t,t.variables.length>0&&(this.selected=t.variables[0]),te.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}get variableOptions(){return this.panel.variables.map(t=>({label:t.name,value:t.name,description:t.aggregation.type}))}addNew(){const t=this.panel.variables.filter(n=>n.name.startsWith(Fo.name)).length;this.panel.addVariable(v.cloneDeep({...Fo,name:`${Fo.name}${t||""}`})),this.selected=v.last(this.panel.variables)}select(t){this.selected=t}selectByName(t){if(!t){console.warn("Unexpected null name when calling selectByName");return}const n=this.variables.find(s=>s.name===t);if(!n){console.error(`Variable by name[${t}] not found`);return}this.selected=n}remove(t){this.selected===t&&(this.selected=void 0);const n=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!v.isEmpty(this.panel.variables)){const s=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[s]}}}function aA(){const{panel:e}=Pe();return Y.useCreation(()=>new iA(e),[e])}const oA=g.forwardRef(function({value:t,onChange:n,remove:s},i){const{t:o}=_.useTranslation(),l=(c,u)=>{const d=v.cloneDeep(t);v.set(d,c,u),n(d)};return r.jsxs(a.Stack,{ref:i,children:[r.jsxs(a.Stack,{gap:"xs",px:"sm",py:"md",sx:{border:"1px solid #e9ecef"},children:[r.jsxs(a.Group,{grow:!0,wrap:"nowrap",children:[r.jsx(a.TextInput,{label:o("common.name"),required:!0,value:t.name,onChange:c=>l("name",c.currentTarget.value)}),r.jsx(Q,{label:o("common.data_field"),required:!0,value:t.data_field,onChange:c=>l("data_field",c)})]}),r.jsx(Aa,{label:o("panel.variable.aggregation.label"),pt:0,value:t.aggregation,onChange:c=>l("aggregation",c),withFallback:!0}),t.aggregation.type!=="custom"&&r.jsxs(r.Fragment,{children:[r.jsx(a.Divider,{mt:"xl",mb:0,label:o("numbro.format.label"),labelPosition:"center",variant:"dashed"}),r.jsx(jt,{value:t.formatter,onChange:c=>l("formatter",c)})]})]}),r.jsx(a.Button,{mt:20,leftSection:r.jsx(C.IconTrash,{size:16}),color:"red",variant:"light",onClick:s,children:o("panel.variable.delete")})]})}),lA=z.observer(e=>{const{t}=_.useTranslation(),n=Y.useCreation(()=>ph(e.variable),[e.variable]),s=()=>e.uiModel.remove(e.variable);return r.jsxs(a.Stack,{"data-testid":"variable-editor",align:"stretch",children:[r.jsxs(a.Group,{justify:"space-between",children:[r.jsx(a.Button,{variant:"subtle",size:"xs",disabled:!n.changed,color:"red",onClick:n.reset,leftSection:r.jsx(C.IconRecycle,{size:18}),children:t("common.actions.revert_changes")}),r.jsx(a.Button,{variant:"filled",size:"xs",disabled:!n.changed,color:"green",onClick:n.commit,leftSection:r.jsx(C.IconDeviceFloppy,{size:18}),children:t("common.actions.save_changes")})]}),r.jsx(oA,{value:f.getSnapshot(n.copy),onChange:n.update,remove:s})]})});z.observer(e=>{const{uiModel:t}=e;return r.jsx(a.Stack,{className:"var-list",children:t.variables.map(n=>r.jsx(a.Button,{variant:t.selected===n?"filled":"subtle",color:"gray",onClick:()=>t.select(n),children:n.name},n.name))})});const cA=z.observer(({model:e})=>{const{t}=_.useTranslation();return r.jsx(a.Overlay,{color:"#fff",backgroundOpacity:1,sx:{position:"absolute"},children:r.jsx(a.Button,{variant:"light",size:"xs",leftSection:r.jsx(C.IconPlus,{size:16}),onClick:e.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:t("panel.variable.add")})})}),uA=z.observer(()=>{var n;const{t:e}=_.useTranslation(),t=aA();return t.variableOptions.length===0?r.jsx(cA,{model:t}):r.jsxs(a.Stack,{pb:20,children:[r.jsxs(a.Group,{justify:"flex-start",children:[r.jsx(a.Select,{label:e("panel.variable.labels"),data:t.variableOptions,value:(n=t.selected)==null?void 0:n.name,onChange:t.selectByName,maxDropdownHeight:600,sx:{flexGrow:1}}),r.jsx(a.Button,{variant:"light",size:"xs",leftSection:r.jsx(C.IconPlus,{size:16}),onClick:t.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:e("panel.variable.add")})]}),r.jsx(a.Divider,{variant:"dashed"}),t.selected?r.jsx(lA,{uiModel:t,variable:t.selected}):r.jsx("span",{children:"Select or create a new variable on right side"})]})}),dA={root:{flexGrow:1,width:"100%",minWidth:"1200px",overflow:"hidden"},panel:{width:"100%",minWidth:"1200px",height:"calc(100% - 44px)",padding:10,overflow:"auto"}},Ro=({children:e})=>r.jsxs(a.Group,{wrap:"nowrap",grow:!0,justify:"flex-start",gap:20,sx:{width:"100%",height:"100%",position:"relative"},children:[r.jsx(a.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),r.jsxs(a.Stack,{justify:"flex-start",sx:{alignSelf:"flex-start",width:"600px",flexGrow:0,flexShrink:0},children:[r.jsx(JE,{}),r.jsx(a.Box,{sx:{flexGrow:1},children:r.jsx(sA,{})})]})]});function pA(e){return!["richText","button"].includes(e)}const hA=z.observer(({panel:e})=>{const{t}=_.useTranslation(),n=ft.useModals(),s=oe(),i=ne(),[o,l]=g.useState(s.editor.panelTab),c=e.queries,d=pA(e.viz.type)&&e.dataLoading,p=d||e.queryErrors.length>0||e.queryStateMessages!==""||c.length===0,h=s.editor.path[1];g.useEffect(()=>{l(j=>p&&j==="Visualization"?"Data":j)},[e.id,p]);const x=g.useCallback(j=>{l(j),s.editor.setPanelTab(o)},[]),y=()=>{s.editor.setPath(["_VIEWS_",h])},m=()=>n.openConfirmModal({title:`${t("panel.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.removePanelByID(e.id,h),y()},confirmProps:{color:"red"},zIndex:320});return r.jsxs(ni,{value:{panel:e,data:e.data,loading:d,errors:e.queryErrors,downloadPanelScreenshot:()=>{}},children:[r.jsxs(a.Group,{px:16,justify:"space-between",sx:{borderBottom:"1px solid #eee"},children:[r.jsx(a.Text,{size:"sm",pt:9,pb:8,children:e.name}),r.jsxs(a.Group,{justify:"flex-end",wrap:"nowrap",children:[r.jsx(rA,{panel:e,sourceViewID:h}),r.jsx(a.Button,{size:"xs",variant:"subtle",color:"red",onClick:m,leftSection:r.jsx(C.IconTrash,{size:14}),children:t("panel.delete")})]})]}),r.jsxs(a.Tabs,{value:o,onChange:x,keepMounted:!1,styles:dA,children:[r.jsxs(a.Tabs.List,{children:[r.jsx(a.Tabs.Tab,{value:"Data",leftSection:r.jsx(C.IconDatabase,{size:14}),disabled:d,children:t("data.label")}),r.jsx(a.Tabs.Tab,{value:"Panel",leftSection:r.jsx(C.IconAppWindow,{size:14}),children:t("panel.label")}),r.jsx(a.Tabs.Tab,{value:"Variables",leftSection:r.jsx(C.IconVariable,{size:14}),disabled:p,children:r.jsx(a.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:r.jsx(a.Text,{size:"sm",children:t("panel.variable.labels")})})}),r.jsx(a.Tabs.Tab,{value:"Visualization",leftSection:r.jsx(C.IconChartHistogram,{size:14}),disabled:p,children:r.jsx(a.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:r.jsx(a.Text,{size:"sm",children:t("visualization.label")})})}),r.jsx(a.Tabs.Tab,{value:"Interactions",leftSection:r.jsx(C.IconRoute,{size:14}),children:t("interactions.label")})]}),r.jsxs(a.Tabs.Panel,{value:"Data",children:[r.jsx(a.LoadingOverlay,{visible:d,transitionProps:{exitDuration:0}}),r.jsx(KE,{})]}),r.jsx(a.Tabs.Panel,{value:"Panel",children:r.jsx(Ro,{children:r.jsx(GE,{})})}),r.jsx(a.Tabs.Panel,{value:"Variables",children:r.jsx(Ro,{children:r.jsx(uA,{})})}),r.jsx(a.Tabs.Panel,{value:"Visualization",children:r.jsx(Ne,{children:r.jsx(Ro,{children:r.jsx(nA,{})})})}),r.jsx(a.Tabs.Panel,{value:"Interactions",children:r.jsx(Ne,{children:r.jsx(iv,{})})})]})]})}),gA=z.observer(({viewID:e,panelID:t})=>{const n=ne();if(!n.views.findByID(e))return r.jsxs(a.Text,{size:"14px",children:["View by ID[",e,"] is not found"]});const i=n.panels.findByID(t);return i?r.jsx(hA,{panel:i}):r.jsxs(a.Text,{size:"14px",children:["Panel by ID[",t,"] is not found"]})}),fA=z.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState([]),s=ft.useModals(),i=oe(),o=x=>{i.editor.setPath(["_QUERIES_",x])},l=()=>{s.openConfirmModal({title:"Delete ununsed queries?",children:r.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.removeUnusedQueries(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.queries.downloadSchema(t)},u=g.useMemo(()=>i.content.queries.sortedList.map(x=>x.id),[i.content.queries.sortedList]),d=()=>{n(u)},p=()=>{n([])},h=i.content.queriesUsage;return r.jsxs(a.Stack,{sx:{height:"100%"},gap:"sm",pb:"59px",children:[r.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(a.Text,{px:"md",ta:"left",sx:{userSelect:"none",cursor:"default"},children:e("query.manage")})}),r.jsxs(a.Flex,{justify:"space-between",align:"center",px:12,children:[r.jsxs(a.Group,{justify:"flex-start",children:[r.jsxs(a.Button.Group,{children:[r.jsx(a.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),r.jsx(a.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),r.jsx(a.Button,{size:"xs",color:"blue",leftSection:r.jsx(C.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),r.jsx(a.Button,{variant:"subtle",size:"xs",color:"red",leftSection:r.jsx(C.IconTrash,{size:14}),disabled:!i.content.hasUnusedQueries,onClick:l,children:e("query.delete_unused")})]}),r.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:r.jsx(a.Checkbox.Group,{size:"xs",value:t,onChange:n,children:r.jsxs(a.Table,{fz:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx(a.Table.Thead,{children:r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Th,{style:{width:"40px"}}),r.jsx(a.Table.Th,{children:e("common.name")}),r.jsx(a.Table.Th,{style:{width:"200px"},children:e("data_source.label")}),r.jsx(a.Table.Th,{style:{width:"100px",textAlign:"right"},children:e("common.type")}),r.jsx(a.Table.Th,{style:{width:"100px",textAlign:"center"},children:e("query.usage.label")}),r.jsx(a.Table.Th,{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),r.jsx(a.Table.Tbody,{children:i.content.queries.sortedList.map(x=>{var m;const y=((m=h[x.id])==null?void 0:m.length)??0;return r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Td,{children:r.jsx(a.Checkbox,{value:x.id,styles:{input:{cursor:"pointer"}}})}),r.jsx(a.Table.Td,{children:x.name}),r.jsx(a.Table.Td,{children:x.key}),r.jsx(a.Table.Td,{style:{textAlign:"right"},children:x.type}),r.jsx(a.Table.Td,{style:{color:y===0?"#ff0000":"#000",fontWeight:y===0?"bold":"normal",textAlign:"center"},children:y}),r.jsx(a.Table.Td,{children:r.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>o(x.id),children:e("common.actions.open")})})]},x.id)})})]})})})]})}),xA=e=>{const{t}=_.useTranslation(),{queryModel:n}=e,s=oe(),i=ne(),l=i.findQueryUsage(n.id).length>0,c=ft.useModals(),u=()=>{c.openConfirmModal({title:`${t("query.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.queries.removeQuery(n.id),s.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return l?r.jsx(a.Tooltip,{label:t("query.cant_delete"),withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"top-end",children:r.jsx(a.Box,{sx:{alignSelf:"flex-end"},children:r.jsx(a.Button,{disabled:!0,size:"xs",leftSection:r.jsx(C.IconTrash,{size:16}),children:t("query.delete")})})}):r.jsx(a.Button,{color:"red",size:"xs",onClick:u,leftSection:r.jsx(C.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:t("query.delete")})},mA=z.observer(xA),ig=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:n,count:s,spacing:i=16,pl:o=0})=>r.jsxs(a.Stack,{gap:i,mt:6,pl:o,children:[Array.from(new Array(s-1),(l,c)=>r.jsx(a.Skeleton,{width:e,height:n,radius:"xs"},c)),r.jsx(a.Skeleton,{width:t,height:n,radius:"xs"})]}),Mr=({value:e})=>e===null||e===""?null:r.jsx(a.Tooltip,{label:e,disabled:!e,multiline:!0,zIndex:340,children:r.jsx(a.ActionIcon,{variant:"subtle",children:r.jsx(C.IconInfoCircle,{size:14})})}),bA=({column:e})=>{const{column_key:t,column_key_text:n}=e;return t?r.jsx(a.Tooltip,{label:n,disabled:!n,children:r.jsx(a.Badge,{variant:"light",children:t})}):null},yA=z.observer(({dataSource:e})=>{const{columns:t}=e;return t.loading?r.jsx(ig,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:r.jsxs(a.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{width:50}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:30}}),r.jsx("col",{style:{width:70}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{minWidth:80,width:80}}),r.jsx("col",{style:{minWidth:120,width:120}})]}),r.jsx(a.Table.Thead,{children:r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Th,{children:"#"}),r.jsx(a.Table.Th,{children:"Column Name"}),r.jsx(a.Table.Th,{}),r.jsx(a.Table.Th,{}),r.jsx(a.Table.Th,{children:"Type"}),r.jsx(a.Table.Th,{children:"Nullable"}),r.jsx(a.Table.Th,{children:"Default Value"})]})}),r.jsx(a.Table.Tbody,{children:t.data.map(n=>r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Td,{children:n.ordinal_position}),r.jsx(a.Table.Td,{children:n.column_name}),r.jsx(a.Table.Td,{children:r.jsx(Mr,{value:n.column_comment})}),r.jsx(a.Table.Td,{children:r.jsx(bA,{column:n})}),r.jsx(a.Table.Td,{children:n.column_type}),r.jsx(a.Table.Td,{children:n.is_nullable}),r.jsx(a.Table.Td,{children:r.jsx(Mr,{value:n.column_default})})]},n.column_name))})]})}),vA=z.observer(({dataSource:e})=>{const{indexes:t}=e,n=t.data;return r.jsxs(a.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:250}})]}),r.jsx(a.Table.Thead,{children:r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Th,{children:"Index Length"}),r.jsx(a.Table.Th,{children:"Index Name"}),r.jsx(a.Table.Th,{children:"Index Algorithm"}),r.jsx(a.Table.Th,{children:"Unique"}),r.jsx(a.Table.Th,{children:"Column Name"})]})}),r.jsx(a.Table.Tbody,{children:n.map(s=>r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Td,{children:s.index_length}),r.jsx(a.Table.Td,{children:s.index_name}),r.jsx(a.Table.Td,{children:s.index_algorithm}),r.jsx(a.Table.Td,{children:s.is_unique?"YES":"NO"}),r.jsx(a.Table.Td,{children:s.column_name})]},s.index_name))})]})}),_A=z.observer(({dataSource:e})=>{const{indexes:t}=e,n=t.data;return r.jsxs(a.Table,{highlightOnHover:!0,fz:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}})]}),r.jsx(a.Table.Thead,{children:r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Th,{children:"Index Name"}),r.jsx(a.Table.Th,{children:"Index Algorithm"}),r.jsx(a.Table.Th,{children:"Unique"}),r.jsx(a.Table.Th,{children:"Definition"}),r.jsx(a.Table.Th,{children:"Condition"}),r.jsx(a.Table.Th,{children:"Comment"})]})}),r.jsx(a.Table.Tbody,{children:n.map(s=>r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Td,{children:s.index_name}),r.jsx(a.Table.Td,{children:s.index_algorithm}),r.jsx(a.Table.Td,{children:s.is_unique?"YES":"NO"}),r.jsx(a.Table.Td,{children:r.jsx(Mr,{value:s.index_definition})}),r.jsx(a.Table.Td,{children:r.jsx(Mr,{value:s.condition})}),r.jsx(a.Table.Td,{children:r.jsx(Mr,{value:s.comment})})]},s.index_name))})]})}),jA=z.observer(({dataSource:e})=>{const{indexes:t}=e;return t.loading||t.empty?null:e.type===Ie.MySQL?r.jsx(vA,{dataSource:e}):e.type===Ie.Postgresql?r.jsx(_A,{dataSource:e}):null}),wA=z.observer(({dataSource:e})=>r.jsxs(a.Stack,{gap:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[r.jsx(Ne,{children:r.jsx(yA,{dataSource:e})}),r.jsx(Ne,{children:r.jsx(jA,{dataSource:e})})]}));function CA({table_type:e}){return e==="VIEW"?r.jsx(C.IconEye,{size:14}):e==="BASE TABLE"?r.jsx(C.IconTable,{size:14}):null}const SA=z.observer(({dataSource:e})=>{const{tables:t}=e;return t.loading?r.jsx(ig,{height:"24px",lastWidth:"50%",count:15}):r.jsx(a.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(t.data).map(([n,s])=>r.jsx(a.NavLink,{label:n,title:n,leftSection:r.jsx(C.IconDatabase,{size:14}),defaultOpened:e.table_schema===n,pl:0,childrenOffset:14,children:s.map(i=>r.jsx(a.NavLink,{label:i.table_name,title:i.table_name,leftSection:r.jsx(CA,{table_type:i.table_type}),onClick:()=>{e.setKeywords(n,i.table_name)},active:e.table_name===i.table_name},i.table_name))},n))})}),TA=({visible:e})=>r.jsx(a.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:r.jsx(a.LoadingOverlay,{visible:e})}),kA=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],DA={section:{width:"50px",textAlign:"center"},input:{paddingLeft:"50px"}},zA=z.observer(({dataSource:e})=>{const{t}=_.useTranslation(),{tableData:n}=e;return r.jsxs(a.Group,{pt:10,px:10,justify:"space-between",children:[r.jsxs(a.Group,{justify:"flex-start",children:[n.maxPage>1&&r.jsx(a.Pagination,{size:"sm",value:n.page,onChange:n.setPage,total:n.maxPage,withEdges:n.maxPage>7,styles:{control:{height:"30px"}}}),r.jsx(a.Select,{leftSection:r.jsx(a.Text,{ta:"center",c:"dimmed",size:"14px",children:t("common.pagination.page_size")}),size:"xs",styles:DA,data:kA,value:String(n.limit),onChange:s=>n.setLimit(Number(s)),comboboxProps:{zIndex:340}})]}),r.jsx(a.Group,{justify:"flex-end",children:r.jsx(a.Text,{c:"dimmed",my:0,size:"14px",children:t("common.pagination.total_rows",{total:n.total})})})]})}),IA=z.observer(({dataSource:e})=>{const t=e.tableData;return t.maxPage===0?r.jsx(a.Text,{mt:20,c:"red",size:"md",ta:"center",ff:"monospace",children:"This table is empty"}):t.error?r.jsx(a.Text,{mt:20,c:"red",size:"md",ta:"center",ff:"monospace",children:t.error}):t.page===1&&t.loading?r.jsx(TA,{visible:!0}):r.jsxs(Ne,{children:[r.jsx(zA,{dataSource:e}),r.jsxs(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[r.jsx(a.LoadingOverlay,{visible:t.loading,overlayProps:{blur:2}}),r.jsx(rg,{data:t.data})]})]})}),MA={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},EA=z.observer(({dataSource:e})=>{const{t}=_.useTranslation();return g.useEffect(()=>{e.loadTablesIfEmpty()},[e]),e.tables.error?r.jsx(a.Text,{c:"red",size:"md",ta:"center",ff:"monospace",children:e.tables.error}):r.jsxs(a.Flex,{sx:{height:"100%"},children:[r.jsx(a.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:r.jsx(Ne,{children:r.jsx(SA,{dataSource:e})})}),r.jsxs(a.Tabs,{defaultValue:"structure",styles:MA,children:[r.jsxs(a.Tabs.List,{children:[r.jsx(a.Tabs.Tab,{value:"structure",leftSection:r.jsx(C.IconColumns,{size:14}),children:t("data_source.table_structure_short")}),r.jsx(a.Tabs.Tab,{value:"data",leftSection:r.jsx(C.IconDatabase,{size:14}),children:t("data.label")})]}),r.jsx(a.Tabs.Panel,{value:"structure",children:r.jsx(wA,{dataSource:e})}),r.jsx(a.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:r.jsx(IA,{dataSource:e})})]})]})}),AA={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"20px 20px 10px",borderBottom:"1px solid #efefef",gap:"20px"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},ag=z.observer(({dataSource:e,triggerButtonProps:t={}})=>{const{t:n}=_.useTranslation(),[s,i]=g.useState(!1);return e.type==="http"?null:r.jsxs(r.Fragment,{children:[r.jsx(a.Modal,{opened:s,onClose:()=>i(!1),title:r.jsxs(a.Group,{justify:"space-between",sx:{flexGrow:1},children:[r.jsx(a.Text,{size:"sm",fw:500,children:n("data_source.explorer")}),r.jsxs(a.Group,{gap:7,children:[r.jsx(a.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:e.key}),r.jsx(a.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:e.type})]})]}),zIndex:320,size:"96vw",styles:AA,children:r.jsx(a.Box,{sx:{height:"calc(100vh - 220px)"},children:r.jsx(EA,{dataSource:e})})}),r.jsx(a.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:n("data_source.see_table_structure")})]})}),PA=({option:e,...t})=>{const{label:n,type:s}=e;return s===Ie.Transform?r.jsxs(a.Group,{className:"transform-query-option",justify:"flex-start",...t,sx:{'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}},children:[r.jsx(C.IconVectorTriangle,{size:14,color:"#228be6"}),r.jsx(a.Text,{size:"sm",c:"blue",children:n})]}):r.jsxs(a.Group,{justify:"space-between",...t,children:[r.jsx(a.Text,{size:"sm",children:n}),r.jsx(a.Text,{size:"sm",children:s})]})},LA=z.observer(({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),s=oe(),{data:i=[],loading:o}=Y.useRequest(fa,{refreshDeps:[]},[]),l=g.useMemo(()=>{const p=i.map(h=>({label:h.key,value:h.key,type:h.type}));return p.push({label:n("query.transform.data_source"),value:Ie.Transform,type:Ie.Transform}),p},[i]),c=g.useMemo(()=>l.reduce((p,h)=>(p[h.value]=h.type,p),{}),[l]),u=p=>{p!==null&&t({key:p,type:c[p]})},d=g.useMemo(()=>s.datasources.find(e),[s,e]);return r.jsx(a.Select,{data:l,label:r.jsxs(a.Group,{justify:"space-between",children:[r.jsx(a.Box,{children:n("data_source.label")}),d&&r.jsx(ag,{dataSource:d,triggerButtonProps:{size:"compact-xs",px:10}})]}),renderOption:PA,rightSection:d?r.jsx(a.Text,{size:"xs",c:"dimmed",children:d.type}):void 0,rightSectionWidth:85,maxDropdownHeight:500,styles:{root:{flex:1},label:{display:"block"},section:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:o,value:e.key,onChange:u})}),OA=z.observer(({queryModel:e})=>{const{t}=_.useTranslation(),[n,s]=g.useState(e.name);return g.useEffect(()=>{s(e.name)},[e.name]),r.jsx(a.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:r.jsxs(a.Stack,{gap:10,sx:{width:"100%"},children:[r.jsx(a.Divider,{mb:-10,variant:"dashed",label:t("query.basics"),labelPosition:"center"}),r.jsx(a.TextInput,{placeholder:t("query.name_description"),label:t("query.name"),required:!0,sx:{flex:1},value:n,onChange:i=>{s(i.currentTarget.value)},rightSection:r.jsx(a.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>e.setName(n),disabled:n===e.name,children:r.jsx(C.IconDeviceFloppy,{size:16})}),onBlur:()=>{e.setName(n)}}),r.jsx(LA,{value:{type:e.type,key:e.key},onChange:({type:i,key:o})=>{e.setKey(o),e.setType(i)}}),r.jsx(a.Divider,{mt:10,mb:-10,variant:"dashed",label:t("query.conditions"),labelPosition:"center"}),r.jsx(a.MultiSelect,{label:t("query.run_by_condition.label"),description:t("query.run_by_condition.description"),placeholder:t("query.run_by_condition.unset"),data:e.conditionOptions,value:[...e.run_by],onChange:e.setRunBy,renderOption:rd,maxDropdownHeight:500}),e.typedAsHTTP&&r.jsx(a.MultiSelect,{label:t("query.re_run_condition.label"),placeholder:t("query.re_run_condition.label"),data:e.conditionOptions,value:[...e.react_to],onChange:e.setReactTo,renderOption:rd,maxDropdownHeight:500}),r.jsx(a.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(mA,{queryModel:e})]})})});function VA({content:e}){return r.jsxs(a.HoverCard,{width:"60vw",shadow:"md",zIndex:340,children:[r.jsx(a.HoverCard.Target,{children:r.jsx(a.ActionIcon,{size:16,color:"blue",variant:"subtle",children:r.jsx(C.IconEye,{})})}),r.jsx(a.HoverCard.Dropdown,{children:r.jsx(Ut.CodeHighlight,{language:"sql",withCopyButton:!1,code:e})})]})}const qA=z.observer(()=>{const t=[...oe().globalSQLSnippets.list];return t.length===0?null:r.jsxs(a.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fz:"sm",highlightOnHover:!0,children:[r.jsx(a.Table.Thead,{children:r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Th,{children:"Key"}),r.jsx(a.Table.Th,{children:"Value"})]})}),r.jsx(a.Table.Tbody,{children:t.map(n=>{const{id:s,content:i}=n;return r.jsxs(a.Table.Tr,{children:[r.jsx(a.Table.Td,{children:s}),r.jsx(a.Table.Td,{width:200,children:r.jsx(VA,{content:i})})]},s)})})]})}),BA=`
|
|
499
499
|
-- You may reference query variables in SQL or VizConfig.
|
|
500
500
|
SELECT *
|
|
501
501
|
FROM commit
|