@devtable/dashboard 13.2.0 → 13.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dashboard.umd.js
CHANGED
|
@@ -53,7 +53,7 @@ Check the top-level render call using <`+A+">.")}return z}}function hu(w,z){{if(
|
|
|
53
53
|
</table>
|
|
54
54
|
`;function _s(t,e){const n=Object.keys(e),r=Object.values(e);try{return new Function(...n,`return \`${t}\`;`)(...r)}catch(i){throw n.length===0&&t.includes("$")?new Error("[formatSQL] insufficient payload"):i}}function js(t,e){try{return _s(t,e)}catch(n){return console.error(n),n.message}}function dd({sql:t,pre_process:e}){if(!e.trim())return t;try{return new Function(`return ${e}`)()({sql:t},lt)}catch(n){return console.error(n),t}}function hd(t,e,n){if(!t.trim())return e;try{return new Function(`return ${t}`)()(e,lt,n)}catch(r){return console.error(r),e}}function pd(t){t=t||{};const e=Object.keys(t).sort(),n=[];for(let r=0;r<e.length;r++){const i=e[r];if(i!="authentication"&&t[i])n.push(e[r]+"="+(typeof t[i]=="object"?JSON.stringify(t[i]):t[i]));else{const a=Object.keys(t[i]).sort();for(let l=0;l<a.length;l++){const c=a[l];c!="sign"&&t[i][c]&&n.push(a[l]+"="+(typeof t[i][c]=="object"?JSON.stringify(t[i][c]):t[i][c]))}}}return n.sort().join("&")}function md(t,e){let n=pd(t);return n+="&key="+e,rd.MD5(n).toString().toUpperCase()}class ca{constructor(){this.type="default_api_client",this.baseURL="http://localhost:31200",this.app_id="",this.app_secret=""}getAuthentication(e){if(!this.app_id||!this.app_secret)return;const n=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:n,sign:md({app_id:this.app_id,nonce_str:n,...e},this.app_secret)}}getRequest(e,n){return(r,i,a,l)=>{const c=this.buildHeader(a),u=this.buildAxiosConfig(e,r,i,a,c,n);return at(u).then(d=>l?d:d.data).catch(d=>{const h=x.get(d,"response.data.detail.message",d.message);return Promise.reject(new Error(h))})}}get(e){return this.getRequest("GET",e)}post(e){return this.getRequest("POST",e)}put(e){return this.getRequest("PUT",e)}buildAxiosConfig(e,n,r,i,a,l){const c={baseURL:this.baseURL,method:e,url:n,params:e==="GET"?r:i.params,headers:a,signal:l};return["POST","PUT"].includes(e)&&(c.data=i.string?JSON.stringify(r):r,c.data.authentication=this.getAuthentication(c.data)),c}buildHeader(e){const n=window.localStorage.getItem("token");return{"X-Requested-With":"XMLHttpRequest","Content-Type":e.string?"application/x-www-form-urlencoded":"application/json",authorization:n?`bearer ${n}`:"",...e.headers}}}class fd{constructor(e){this.implementation=e}getRequest(e,n){return this.implementation.getRequest(e,n)}get(e){return this.getRequest("GET",e)}post(e){return this.getRequest("POST",e)}put(e){return this.getRequest("PUT",e)}}class ua extends ca{constructor(){super(...arguments);P(this,"makeQueryENV",null)}query(n){return async(r,i={})=>{var a;return r.env||(r.env=((a=this.makeQueryENV)==null?void 0:a.call(this))??{error:"failed to run makeQueryENV"}),this.post(n)("/query",r,i)}}httpDataSourceQuery(n){return async(r,i={})=>{var a;return r.env||(r.env=((a=this.makeQueryENV)==null?void 0:a.call(this))??{error:"failed to run makeQueryENV"}),this.getRequest("POST",n)("/query",r,i,!0)}}structure(n){return async(r,i={})=>this.post(n)("/query/structure",r,i)}}class da{constructor(e){this.implementation=e}query(e){return this.implementation.query(e)}httpDataSourceQuery(e){return this.implementation.httpDataSourceQuery(e)}structure(e){return this.implementation.structure(e)}getRequest(e,n){return this.implementation.getRequest(e,n)}get(e){return this.getRequest("GET",e)}post(e){return this.getRequest("POST",e)}put(e){return this.getRequest("PUT",e)}}const Lt=new ua;function ws(t){Lt.baseURL!==t.apiBaseURL&&(Lt.baseURL=t.apiBaseURL),t.app_id&&(Lt.app_id=t.app_id),t.app_secret&&(Lt.app_secret=t.app_secret),t.makeQueryENV&&(Lt.makeQueryENV=t.makeQueryENV)}const ha=new da(Lt),et=ha,nn=m.forwardRef(function({value:e,onChange:n,...r},i){return s.jsx(o.TextInput,{ref:i,value:e,onChange:n,...r})});function E(t){const[e,n]=t.split(".");return{queryID:e,columnKey:n}}function gd(t){return t.includes(".")?E(t):{queryID:"",columnKey:t}}function tt(t,e){var i;const{queryID:n,columnKey:r}=E(e);return n?r?((i=t[n])==null?void 0:i.map(a=>a[r]))??[]:t[n]:[]}function Sn(t,e){const{queryID:n}=E(e);return n?t[n]:[]}function xd(t){return Object.values(t)[0]}function kn(t,e){const{queryID:n,columnKey:r}=E(e);return t[r]}const pa=["function aggregation({ queryData }, utils) {",' return "Aggregation Result";',"}"].join(`
|
|
55
55
|
`),Bt={type:"none",config:{},fallback:"0"};function yd(t){const e=Array.from(t).sort((r,i)=>r-i),n=Math.floor(e.length/2);return e.length%2===0?(e[n-1]+e[n])/2:e[n]}function bd(t,e){switch(e.type){case"sum":return x.sum(t);case"mean":return x.mean(t);case"median":return yd(t);case"max":return x.max(t);case"min":return x.min(t);case"quantile":return Zt.quantile(t,e.config.p);case"CV":const n=qt.std(...t),r=qt.mean(...t);return r?n/r:Number.NaN;case"std":return qt.std(...t);default:return t}}function Cs(t,e){const n=t.map(Number),r=bd(n,e);return typeof r=="number"?Number.isFinite(r)?r:e.fallback:r??e.fallback}function vd(t,e,n){try{const r=Sn(t,e);return new Function(`return ${n.config.func}`)()({queryData:r},lt)}catch(r){return console.error(r),r.message}}function Tn(t,e,n){try{return n.type==="custom"?vd(t,e,n):Cs(tt(t,e),n)}catch(r){return console.error(r),null}}class _d{constructor({valueRange:e,colorRange:n}){P(this,"mapper");this.mapper=St.interpolate(e,n)}getColor(e){return this.mapper(e)}}const be={mantissa:0,output:"number",trimMantissa:!1,average:!1,absolute:!1};function G(t,{absolute:e,...n}){if(t===null)return String(t);try{let r=jn(t).value();if(r===void 0||Number.isNaN(r))throw new Error(`[formatNumber]Not a number: ${t}`);return e&&(r=Math.abs(r)),jn(r).format(n)}catch(r){return console.debug(r),String(t)}}function jd(t){return t===null?"null":t===void 0?"undefined":Array.isArray(t)?`Array(${t.length})`:t.toString()}function ct({data_field:t,aggregation:e},n){return Tn(n,t,e)}function Oe({formatter:t,aggregation:e},n){if(typeof n!="string"&&typeof n!="number")return jd(n);if(e.type==="custom")return n;try{return G(n,t)}catch(r){return console.error(r),n}}function wd(t,e){if(t.type==="static")return t.staticColor;if(t.type==="continuous")try{if(typeof e!="number")throw new Error(`[getColorByColorConf] Invalid type of aggregated value: ${e}`);return new _d(t).getColor(e)}catch(n){return console.error(n),"black"}return"black"}function Cd(t,e){const{color:n,data_field:r,aggregation:i,size:a,weight:l}=t,c=Tn(e,r,i),u=Oe(t,c);return s.jsx(o.Text,{sx:{fontSize:a,display:"inline"},color:wd(n,c),weight:l,children:u})}function Sd(t,e){const n={};return t.forEach(r=>{const i=r.name;n[i]=Cd(r,e)}),n}function kd(t){return t.split(" ").map((e,n)=>s.jsxs(m.Fragment,{children:[e," "]},n))}function Td(t){const n=t.replaceAll("<br />","<br/>").replaceAll(`
|
|
56
|
-
`,"<br/>").split("<br/>");return n.map((i,a)=>{const l=[kd(i)];return a!==n.length-1&&l.push(s.jsx("br",{},`br-${a}`)),l}).flat().filter(i=>i!==void 0)}function Ss(t){return Td(t)}function sn(t,e,n){const r=Sd(e,n),i=/^\{(.+)\}(.*)$/;return t.split("$").map((a,l)=>{const c=i.exec(a);if(!c)return Ss(a);const u=r[c[1]];if(!u)return Ss(a);const d=c[2]??"";return s.jsxs(m.Fragment,{children:[u,Ss(d)]},`${a}-${l}`)})}function Dd(t,e){const{data_field:n,aggregation:r}=t,i=Tn(e,n,r);return Oe(t,i)}function ma(t,e){const n={};return t.forEach(r=>{n[r.name]=Dd(r,e)}),n}function Dn(t,e,n){const r=ma(e,n),i=/^\{(.+)\}(.*)$/;return t.split("$").map(a=>{const l=i.exec(a);if(!l)return a;const c=r[l[1]];if(!c)return a;const u=l[2]??"";return`${c}${u}`}).join("")}const ks={grid:{axis:"#97999D",scope:"rgba(47,140,192,0.1)",boundary:"#789AB4",reference:"#CFCFD8"},graphics:{compared:{blueDark:"#3E7CAB",blue:"#6398C7",blueLight:"#7CB0DF",blue10:"#6398C71a",redDark:"#AF5F6B",red:"#CD7C88",redLight:"#E794A0",red10:"#CD7C881a"},gradient:{distributed:"linear-gradient(90deg, #1babe6 0%, #2fc8c8 28.63%, #98d44b 48.86%, #ffd057 67.53%, #f5ae53 80.6%, #e76441 91.18%, #b90000 100%)",protrude:"linear-gradient(180deg, #ec73734d 0%, #ec737300 100%)"},level:{lv0:"#6398C7",lv1:"#61B5BF",lv2:"#54D4BB",lv3:"#F5D277",lv4:"#E8BB7F",lv5:"#DB9E84",lv6:"#CB8089"},depth:{dp0:"#FFF7F8",dp1:"#FFE1E1",dp2:"#FDBCBC",dp3:"#F39494",dp4:"#FA4242",dp5:"#E21212"},multiple:{c1:"#66B4DB",c2:"#E46464",c3:"#EEBA00",c4:"#33A678",c5:"#9D88CB",c6:"#939943",c7:"#E49792",c8:"#09A2B8",c9:"#AF5F6B",c10:"#6CA157",c11:"#3E7CAB",c12:"#6398C7",c13:"#E692BA",c14:"#97B566",c15:"#8CACE2",c16:"#CA79AC",c17:"#6DBC80",c18:"#B08F4B",c19:"#39BFA2",c20:"#826BAF"}}};function zd(){_e.registerTheme("merico-light",{color:Object.values(ks.graphics.multiple),visualMap:{color:Object.values(ks.graphics.depth).reverse()},axes:[{type:"all",name:"通用坐标轴",axisLineColor:"#97999D",axisTickColor:"#97999D",axisLabelShow:!0,axisLabelColor:"#818388",splitLineShow:!0,splitLineColor:["#E0E6F1"]}]})}function fa(){zd()}function*Id(t){const e=ks.graphics[t];if(!e)throw new Error("Invalid palette key provided");const n=Object.values(e);let r=0;for(;;)yield n[r%n.length],r++}function ga(){return{filters:{},context:{}}}function Ts(t){const e=ga();if(!t)return ga();const{filters:n=e.filters,context:r=e.context}=t;return{filters:n,context:r}}class je extends m.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}render(){var e;if(this.state.error){const n=()=>{this.setState({error:null})};return s.jsxs(o.Box,{children:[s.jsx(o.Text,{size:"xs",children:(e=this.state.error)==null?void 0:e.message}),s.jsx(o.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}function Md(t,e={handleError:!0}){return n=>s.jsx(je,{...e,children:s.jsx(t,{...n})})}function Ed(t,e){return new Function(`return ${t}`)()(e,lt)}function Ad(t,e,n){return Ed(t,{context:e,filters:n})}function Pd(t,e){try{return new Function(`return ${t.config.processing.pre}`)()(e,lt)}catch(n){return console.error(n),e}}function $d(t,e){return new Function(`return ${t.config.processing.post}`)()(e,lt)}function qd(t,e,n){return t?new Function(`return ${t}`)()(e,lt,n):e}function xa(){Oi.use([yu.CanvasRenderer,He.BarChart,He.BoxplotChart,He.CustomChart,He.FunnelChart,He.HeatmapChart,He.LineChart,He.PieChart,He.RadarChart,He.ScatterChart,He.SunburstChart,xt.CalendarComponent,xt.DataZoomComponent,xt.GridComponent,xt.LegendComponent,xt.TooltipComponent,xt.MarkLineComponent,xt.MarkAreaComponent,xt.VisualMapComponent])}const Ot=t=>x.cloneDeepWith(t,(e,n)=>{if(n!==void 0&&e)return U.toJS(e)}),zn={sqlSnippet:new RegExp("(?<=sql_snippets\\.)([^\\?}.]+)","gm"),context:new RegExp("(?<=context\\.)([^\\?}.]+)","gm"),filter:new RegExp("(?<=filters\\.)([^\\?}.]+)","gm")};function Ld(t,e){const n=Vi.decode(e);n!==t&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:t,after:e,v:n}),console.groupEnd())}async function Bd({query:t,name:e,payload:n,additionals:r},i){if(!t.sql)return[];const{type:a,key:l,sql:c,pre_process:u,post_process:d}=t,h=_s(c,n),p=dd({sql:h,pre_process:u}),g=Vi.encode(p);Ld(p,g);let y=await et.query(i)({type:a,key:l,query:g,...r},{params:{name:e}});return y=hd(d,y,Ts(n)),y}async function Od({type:t,key:e,configString:n,name:r,additionals:i},a){try{return await et.httpDataSourceQuery(a)({type:t,key:e,query:n,...i},{params:{name:r}})}catch(l){if(at.isCancel(l))throw l;return console.error(l),l}}async function Ds(){try{return(await et.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(t){return console.error(t),[]}}async function ya(){try{return(await et.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(t){return console.error(t),[]}}class ba{constructor(e){P(this,"rootRef");this.rootRef=U.observable({current:e})}async deleteItem(e){U.runInAction(()=>{x.unset(this.rootRef.current,[e])})}getItem(e){const n=this.getValueFromRoot(e);return Promise.resolve(n)}getValueFromRoot(e){return e===null?U.toJS(this.rootRef.current):x.get(this.rootRef.current,[e])}setItem(e,n){if(e===null)if(x.isObject(n))U.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else U.runInAction(()=>{x.set(this.rootRef.current,[e],n)});return Promise.resolve(this.getItem(e))}watchItem(e,n,r){return U.reaction(()=>this.getValueFromRoot(e),(i,a)=>{n(i,a)},{requiresObservable:!0,fireImmediately:x.get(r,"fireImmediately",!1)})}}class Vd{constructor(){P(this,"channels",new Map);P(this,"globalChannel",new Ni)}getChannel(e){const n=this.channels.get(e);if(n)return n;const r=new Ni;return this.channels.set(e,r),r}}class Nd{constructor(e){P(this,"instances",new Map);this.pluginManager=e}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(e=>e.manifest.viz)}resolveComponent(e){return this.pluginManager.factory.viz(e)}getOrCreateInstance(e){const n=this.instances.get(e.id);if(n)return n;const r={id:e.id,name:e.viz.type,type:e.viz.type,messageChannels:new Vd,instanceData:new ba(e.viz.conf)};return this.instances.set(e.id,r),r}}function va(t,e,n,r){return{vizManager:n,locale:"zh",msgChannels:t.messageChannels,instanceData:t.instanceData,pluginData:new ba({}),colorPalette:{getColor(){return()=>""}},data:e,variables:r}}const Fd=t=>{const{panel:e,measure:n,vizManager:r,data:i,variables:a}=t,l=r.resolveComponent(e.viz.type),c=r.getOrCreateInstance(e),u={...va(c,i,r,a),viewport:{width:n.w,height:n.h}},d=l.viewRender;return s.jsx(d,{context:u,instance:c,...x.omit(t,["panel","vizManager","data"])})},Gd=t=>{const{vizManager:e,panel:n,data:r,variables:i}=t,a=e.resolveComponent(n.viz.type),l=e.getOrCreateInstance(n),c={...va(l,r,e,i)},u=a.configRender;return s.jsx(u,{context:c,instance:l,...x.omit(t,["panel","vizManager","data"])})},_a=(t,e)=>{const n=ot.bezier(t),r=ot.bezier(e);return function(i){return i<50?n(i*2/100).hex():r((i-50)*2/100).hex()}},In=t=>{const e=ot.bezier(t);return function(n){return e(n/100).hex()}},Wd={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:_a(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Qd={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:_a(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Rd={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:In(["#fff7f1","darkred"]),name:"red",category:"sequential"},Yd={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:In(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ud={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:In(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Kd={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:In(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Jd{constructor(e){P(this,"symbol");this.symbol=Symbol(e)}}function ut(t){return new Jd(t)}class zs{constructor(){P(this,"parent");P(this,"factoryRegistry",new Map);P(this,"instanceRegistry",new Map)}createScoped(){const e=new zs;return e.parent=this,e}getRequired(e){return this.get(e)}get(e){if(this.instanceRegistry.has(e.symbol))return this.instanceRegistry.get(e.symbol);const n=this.factoryRegistry.get(e.symbol);if(n){const r=n(this);return this.instanceRegistry.set(e.symbol,r),r}if(this.parent)return this.parent.get(e)}provideFactory(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,n),this}provideValue(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(e=>{const n=x.get(e,"dispose");x.isFunction(n)&&n.bind(e)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const ja="13.2.0",Xd=Object.freeze(Object.defineProperty({__proto__:null,version:ja},Symbol.toStringTag,{value:"Module"}));class Zd{constructor(e){P(this,"staticColors",new Map);P(this,"interpolations",new Map);e.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(e){const n=this.encodeColor(e);e.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.staticColors.set(n,e)):e.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`,`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.interpolations.set(n,e))}decodeStaticColor(e){return this.staticColors.get(e)}encodeColor(e){return`\${${e.category}}.{${e.name}}`}decodeInterpolation(e){return this.interpolations.get(e)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class Hd{constructor(){P(this,"plugins",new Map);P(this,"vizComponents",new Map);P(this,"factory",{viz:e=>{const n=this.vizComponents.get(e);if(n)return n;throw new Error(`Viz Component (${e}) not found`)}})}install(e){if(this.plugins.has(e.id))throw new Error(`Plugin (${e.id}) has been installed before`);this.plugins.set(e.id,e);for(const n of e.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class eh{constructor(){P(this,"migrations",[])}version(e,n){return this.migrations.push({version:e,handler:n}),this}run(e,n,r){var l;if(e.from===e.to)return n;if(e.from>e.to)throw new Error(`Can not downgrade from version '${e.from}' to (${e.to})`);const i=this.migrations.filter(c=>c.version>e.from&&c.version<=e.to),a=x.orderBy(i,"version","asc");if(((l=x.last(a))==null?void 0:l.version)!==e.to)throw new Error(`Migration to version ${e.to} not found`);return a.reduce((c,u)=>u.handler(c,r),n)}}class oe extends eh{constructor(){super(),this.configVersions()}version(e,n){return super.version(e,(r,i)=>({version:e,...n(r,i)}))}async migrate({configData:e,panelModel:n}){const r=await e.getItem(null),i=x.get(r,"version",0),a=this.run({from:i,to:this.VERSION},r,{panelModel:n});await e.setItem(null,a)}async needMigration({configData:e}){const n=await e.getItem(null);return x.get(n,"version",0)<this.VERSION}}const O=(t,e)=>{const[n,{setFalse:r}]=N.useBoolean(!0),[i,a]=m.useState();m.useEffect(()=>(t.getItem(e).then(c=>{a(c),r()}),t.watchItem(e,c=>{a(c)})));const l=m.useCallback(async c=>{await t.setItem(e,c),a(c)},[t,e]);return{loading:n,value:i,set:l}},ze={top:16,right:16,bottom:16,left:16},Ue=t=>Math.max(0,t-ze.left-ze.right),Ke=t=>Math.max(0,t-ze.top-ze.bottom),rn=(t,e)=>({width:Ue(t),height:Ke(e)}),Ie=({width:t,height:e,children:n})=>s.jsx(o.Box,{pt:ze.top,pr:ze.right,pb:ze.bottom,pl:ze.left,sx:{width:t,height:e,overflow:"hidden",position:"relative"},children:n}),Is={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 th({context:t}){const{value:e}=O(t.instanceData,"config"),n=t.data,{width:r,height:i}=t.viewport,{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:h}=x.defaults({},e,Is),p=m.useMemo(()=>Sn(n,a),[n,a]),{x:g,y,z:v}=m.useMemo(()=>({x:E(a),y:E(l),z:E(c)}),[a,l,c]),{min:C,max:T}=m.useMemo(()=>{const M=x.minBy(p,J=>J[v.columnKey]),$=x.maxBy(p,J=>J[v.columnKey]);return{min:x.get(M,v.columnKey),max:x.get($,v.columnKey)}},[p,v]),D={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:C,max:T,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:h,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:p.map(M=>[M[g.columnKey],M[y.columnKey],M[v.columnKey]])}]};return e?s.jsx(Ie,{width:r,height:i,children:s.jsx(ke,{echarts:_e,option:D,style:rn(r,i),notMerge:!0,theme:"merico-light"})}):null}const wa=m.createContext(null),Ms=wa.Provider;function Es(){const t=m.useContext(wa);if(!t)throw new Error("Please use DashboardModelContextProvider");return t}const X=()=>Es(),Ca=()=>Es(),Sa=m.createContext({searchButtonProps:{}}),As=Sa.Provider;function ka(){return m.useContext(Sa)}const Ta=m.createContext(null),Ps=Ta.Provider;function Da(){const t=m.useContext(Ta);if(!t)throw new Error("Please use ContentModelContextProvider");return t}const W=()=>Da(),de=()=>Da(),nh={inEditMode:!1},Mn=m.createContext(nh),za=m.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),$s=za.Provider;function Ia(){const t=m.useContext(za);if(!t.panel)throw new Error("Please use PanelContextProvider");return t}const dt=()=>Ia(),$e=()=>Ia(),sh={fullScreenPanelID:"",setFullScreenPanelID:x.noop},qs=m.createContext(sh);function Ma(){const t=m.useContext(qs);if(!t)throw new Error("Please use FullScreenPanelContext.Provider");return t}const rh={en:"en",zh:"zh-cn"};function Ls({children:t}){const{i18n:e}=_.useTranslation(),n=m.useMemo(()=>{const r=e.language;return rh[r]??"en"},[e.language]);return s.jsx(Fi.DatesProvider,{settings:{locale:n,firstDayOfWeek:1},children:t})}const B=S.observer(m.forwardRef(({label:t,required:e,description:n,value:r,onChange:i,queryID:a,clearable:l=!1,sx:c,...u},d)=>{const{panel:h}=$e(),p=m.useMemo(()=>h.dataFieldOptions(r,l,a),[r,l,a]);if(p.length===0){const g=h.explainDataKey(r);return s.jsxs(o.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[s.jsx(o.HoverCard.Target,{children:s.jsx(o.Box,{children:s.jsx(o.TextInput,{label:t,required:e,defaultValue:g.columnKey,readOnly:!0,disabled:!0})})}),s.jsx(o.HoverCard.Dropdown,{children:s.jsxs(o.Group,{position:"left",spacing:0,children:[s.jsx(o.Text,{size:"xs",color:g.queryName?"black":"red",sx:{fontFamily:"monospace"},children:g.queryName??g.queryID}),s.jsx(o.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),s.jsx(o.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:g.columnKey})]})})]})}return s.jsx(o.Select,{ref:d,label:t,description:n,data:p,value:r,onChange:i,required:e,sx:c,maxDropdownHeight:500,...u})}));function ih({context:t}){const{value:e,set:n}=O(t.instanceData,"config"),r=x.defaults({},e,Is),{control:i,handleSubmit:a,reset:l}=b.useForm({defaultValues:r});return m.useEffect(()=>{l(r)},[e]),e?s.jsx(o.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:a(n),children:[s.jsx(o.Text,{children:"X Axis"}),s.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>s.jsx(B,{label:"Data Field",required:!0,...c})}),s.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>s.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(o.Text,{mt:"lg",children:"Y Axis"}),s.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>s.jsx(B,{label:"Data Field",required:!0,...c})}),s.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>s.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(o.Text,{mt:"lg",children:"Z Axis"}),s.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>s.jsx(B,{label:"Data Field",required:!0,...c})}),s.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>s.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(o.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:s.jsxs(o.Button,{color:"blue",type:"submit",children:[s.jsx(q.DeviceFloppy,{size:20}),s.jsx(o.Text,{ml:"md",children:"Save"})]})})]})}):null}const ah=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function oh(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:a,z_axis_data_key:l,...c}=t;return{...c,x_axis_data_key:r(i),y_axis_data_key:r(a),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class lh extends oe{constructor(){super(...arguments);P(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:i}=n;return{...n,version:2,config:oh(i,r)}})}}const ch={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new lh,name:"bar-3d",viewRender:th,configRender:ih,createConfig(){return{version:2,config:x.cloneDeep(Is)}},translation:ah},uh=({disabled:t,value:e,onChange:n})=>{const r=i=>{i&&n(i)};return s.jsxs(o.Box,{sx:{position:"relative"},children:[t&&s.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),s.jsx(Pe,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:t}})]})};function Me({enabled:t,func_content:e}){return(n,r)=>{if(!t)return n;try{return new Function(`return ${e}`)()(n,r)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function we(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
56
|
+
`,"<br/>").split("<br/>");return n.map((i,a)=>{const l=[kd(i)];return a!==n.length-1&&l.push(s.jsx("br",{},`br-${a}`)),l}).flat().filter(i=>i!==void 0)}function Ss(t){return Td(t)}function sn(t,e,n){const r=Sd(e,n),i=/^\{(.+)\}(.*)$/;return t.split("$").map((a,l)=>{const c=i.exec(a);if(!c)return Ss(a);const u=r[c[1]];if(!u)return Ss(a);const d=c[2]??"";return s.jsxs(m.Fragment,{children:[u,Ss(d)]},`${a}-${l}`)})}function Dd(t,e){const{data_field:n,aggregation:r}=t,i=Tn(e,n,r);return Oe(t,i)}function ma(t,e){const n={};return t.forEach(r=>{n[r.name]=Dd(r,e)}),n}function Dn(t,e,n){const r=ma(e,n),i=/^\{(.+)\}(.*)$/;return t.split("$").map(a=>{const l=i.exec(a);if(!l)return a;const c=r[l[1]];if(!c)return a;const u=l[2]??"";return`${c}${u}`}).join("")}const ks={grid:{axis:"#97999D",scope:"rgba(47,140,192,0.1)",boundary:"#789AB4",reference:"#CFCFD8"},graphics:{compared:{blueDark:"#3E7CAB",blue:"#6398C7",blueLight:"#7CB0DF",blue10:"#6398C71a",redDark:"#AF5F6B",red:"#CD7C88",redLight:"#E794A0",red10:"#CD7C881a"},gradient:{distributed:"linear-gradient(90deg, #1babe6 0%, #2fc8c8 28.63%, #98d44b 48.86%, #ffd057 67.53%, #f5ae53 80.6%, #e76441 91.18%, #b90000 100%)",protrude:"linear-gradient(180deg, #ec73734d 0%, #ec737300 100%)"},level:{lv0:"#6398C7",lv1:"#61B5BF",lv2:"#54D4BB",lv3:"#F5D277",lv4:"#E8BB7F",lv5:"#DB9E84",lv6:"#CB8089"},depth:{dp0:"#FFF7F8",dp1:"#FFE1E1",dp2:"#FDBCBC",dp3:"#F39494",dp4:"#FA4242",dp5:"#E21212"},multiple:{c1:"#66B4DB",c2:"#E46464",c3:"#EEBA00",c4:"#33A678",c5:"#9D88CB",c6:"#939943",c7:"#E49792",c8:"#09A2B8",c9:"#AF5F6B",c10:"#6CA157",c11:"#3E7CAB",c12:"#6398C7",c13:"#E692BA",c14:"#97B566",c15:"#8CACE2",c16:"#CA79AC",c17:"#6DBC80",c18:"#B08F4B",c19:"#39BFA2",c20:"#826BAF"}}};function zd(){_e.registerTheme("merico-light",{color:Object.values(ks.graphics.multiple),visualMap:{color:Object.values(ks.graphics.depth).reverse()},axes:[{type:"all",name:"通用坐标轴",axisLineColor:"#97999D",axisTickColor:"#97999D",axisLabelShow:!0,axisLabelColor:"#818388",splitLineShow:!0,splitLineColor:["#E0E6F1"]}]})}function fa(){zd()}function*Id(t){const e=ks.graphics[t];if(!e)throw new Error("Invalid palette key provided");const n=Object.values(e);let r=0;for(;;)yield n[r%n.length],r++}function ga(){return{filters:{},context:{}}}function Ts(t){const e=ga();if(!t)return ga();const{filters:n=e.filters,context:r=e.context}=t;return{filters:n,context:r}}class je extends m.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}render(){var e;if(this.state.error){const n=()=>{this.setState({error:null})};return s.jsxs(o.Box,{children:[s.jsx(o.Text,{size:"xs",children:(e=this.state.error)==null?void 0:e.message}),s.jsx(o.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}function Md(t,e={handleError:!0}){return n=>s.jsx(je,{...e,children:s.jsx(t,{...n})})}function Ed(t,e){return new Function(`return ${t}`)()(e,lt)}function Ad(t,e,n){return Ed(t,{context:e,filters:n})}function Pd(t,e){try{return new Function(`return ${t.config.processing.pre}`)()(e,lt)}catch(n){return console.error(n),e}}function $d(t,e){return new Function(`return ${t.config.processing.post}`)()(e,lt)}function qd(t,e,n){return t?new Function(`return ${t}`)()(e,lt,n):e}function xa(){Oi.use([yu.CanvasRenderer,He.BarChart,He.BoxplotChart,He.CustomChart,He.FunnelChart,He.HeatmapChart,He.LineChart,He.PieChart,He.RadarChart,He.ScatterChart,He.SunburstChart,xt.CalendarComponent,xt.DataZoomComponent,xt.GridComponent,xt.LegendComponent,xt.TooltipComponent,xt.MarkLineComponent,xt.MarkAreaComponent,xt.VisualMapComponent])}const Ot=t=>x.cloneDeepWith(t,(e,n)=>{if(n!==void 0&&e)return U.toJS(e)}),zn={sqlSnippet:new RegExp("(?<=sql_snippets\\.)([^\\?}.]+)","gm"),context:new RegExp("(?<=context\\.)([^\\?}.]+)","gm"),filter:new RegExp("(?<=filters\\.)([^\\?}.]+)","gm")};function Ld(t,e){const n=Vi.decode(e);n!==t&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:t,after:e,v:n}),console.groupEnd())}async function Bd({query:t,name:e,payload:n,additionals:r},i){if(!t.sql)return[];const{type:a,key:l,sql:c,pre_process:u,post_process:d}=t,h=_s(c,n),p=dd({sql:h,pre_process:u}),g=Vi.encode(p);Ld(p,g);let y=await et.query(i)({type:a,key:l,query:g,...r},{params:{name:e}});return y=hd(d,y,Ts(n)),y}async function Od({type:t,key:e,configString:n,name:r,additionals:i},a){try{return await et.httpDataSourceQuery(a)({type:t,key:e,query:n,...i},{params:{name:r}})}catch(l){if(at.isCancel(l))throw l;return console.error(l),l}}async function Ds(){try{return(await et.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(t){return console.error(t),[]}}async function ya(){try{return(await et.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(t){return console.error(t),[]}}class ba{constructor(e){P(this,"rootRef");this.rootRef=U.observable({current:e})}async deleteItem(e){U.runInAction(()=>{x.unset(this.rootRef.current,[e])})}getItem(e){const n=this.getValueFromRoot(e);return Promise.resolve(n)}getValueFromRoot(e){return e===null?U.toJS(this.rootRef.current):x.get(this.rootRef.current,[e])}setItem(e,n){if(e===null)if(x.isObject(n))U.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else U.runInAction(()=>{x.set(this.rootRef.current,[e],n)});return Promise.resolve(this.getItem(e))}watchItem(e,n,r){return U.reaction(()=>this.getValueFromRoot(e),(i,a)=>{n(i,a)},{requiresObservable:!0,fireImmediately:x.get(r,"fireImmediately",!1)})}}class Vd{constructor(){P(this,"channels",new Map);P(this,"globalChannel",new Ni)}getChannel(e){const n=this.channels.get(e);if(n)return n;const r=new Ni;return this.channels.set(e,r),r}}class Nd{constructor(e){P(this,"instances",new Map);this.pluginManager=e}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(e=>e.manifest.viz)}resolveComponent(e){return this.pluginManager.factory.viz(e)}getOrCreateInstance(e){const n=this.instances.get(e.id);if(n)return n;const r={id:e.id,name:e.viz.type,type:e.viz.type,messageChannels:new Vd,instanceData:new ba(e.viz.conf)};return this.instances.set(e.id,r),r}}function va(t,e,n,r){return{vizManager:n,locale:"zh",msgChannels:t.messageChannels,instanceData:t.instanceData,pluginData:new ba({}),colorPalette:{getColor(){return()=>""}},data:e,variables:r}}const Fd=t=>{const{panel:e,measure:n,vizManager:r,data:i,variables:a}=t,l=r.resolveComponent(e.viz.type),c=r.getOrCreateInstance(e),u={...va(c,i,r,a),viewport:{width:n.w,height:n.h}},d=l.viewRender;return s.jsx(d,{context:u,instance:c,...x.omit(t,["panel","vizManager","data"])})},Gd=t=>{const{vizManager:e,panel:n,data:r,variables:i}=t,a=e.resolveComponent(n.viz.type),l=e.getOrCreateInstance(n),c={...va(l,r,e,i)},u=a.configRender;return s.jsx(u,{context:c,instance:l,...x.omit(t,["panel","vizManager","data"])})},_a=(t,e)=>{const n=ot.bezier(t),r=ot.bezier(e);return function(i){return i<50?n(i*2/100).hex():r((i-50)*2/100).hex()}},In=t=>{const e=ot.bezier(t);return function(n){return e(n/100).hex()}},Wd={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:_a(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Qd={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:_a(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Rd={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:In(["#fff7f1","darkred"]),name:"red",category:"sequential"},Yd={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:In(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Ud={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:In(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Kd={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:In(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Jd{constructor(e){P(this,"symbol");this.symbol=Symbol(e)}}function ut(t){return new Jd(t)}class zs{constructor(){P(this,"parent");P(this,"factoryRegistry",new Map);P(this,"instanceRegistry",new Map)}createScoped(){const e=new zs;return e.parent=this,e}getRequired(e){return this.get(e)}get(e){if(this.instanceRegistry.has(e.symbol))return this.instanceRegistry.get(e.symbol);const n=this.factoryRegistry.get(e.symbol);if(n){const r=n(this);return this.instanceRegistry.set(e.symbol,r),r}if(this.parent)return this.parent.get(e)}provideFactory(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,n),this}provideValue(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(e=>{const n=x.get(e,"dispose");x.isFunction(n)&&n.bind(e)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const ja="13.2.1",Xd=Object.freeze(Object.defineProperty({__proto__:null,version:ja},Symbol.toStringTag,{value:"Module"}));class Zd{constructor(e){P(this,"staticColors",new Map);P(this,"interpolations",new Map);e.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(e){const n=this.encodeColor(e);e.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.staticColors.set(n,e)):e.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`,`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.interpolations.set(n,e))}decodeStaticColor(e){return this.staticColors.get(e)}encodeColor(e){return`\${${e.category}}.{${e.name}}`}decodeInterpolation(e){return this.interpolations.get(e)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class Hd{constructor(){P(this,"plugins",new Map);P(this,"vizComponents",new Map);P(this,"factory",{viz:e=>{const n=this.vizComponents.get(e);if(n)return n;throw new Error(`Viz Component (${e}) not found`)}})}install(e){if(this.plugins.has(e.id))throw new Error(`Plugin (${e.id}) has been installed before`);this.plugins.set(e.id,e);for(const n of e.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class eh{constructor(){P(this,"migrations",[])}version(e,n){return this.migrations.push({version:e,handler:n}),this}run(e,n,r){var l;if(e.from===e.to)return n;if(e.from>e.to)throw new Error(`Can not downgrade from version '${e.from}' to (${e.to})`);const i=this.migrations.filter(c=>c.version>e.from&&c.version<=e.to),a=x.orderBy(i,"version","asc");if(((l=x.last(a))==null?void 0:l.version)!==e.to)throw new Error(`Migration to version ${e.to} not found`);return a.reduce((c,u)=>u.handler(c,r),n)}}class oe extends eh{constructor(){super(),this.configVersions()}version(e,n){return super.version(e,(r,i)=>({version:e,...n(r,i)}))}async migrate({configData:e,panelModel:n}){const r=await e.getItem(null),i=x.get(r,"version",0),a=this.run({from:i,to:this.VERSION},r,{panelModel:n});await e.setItem(null,a)}async needMigration({configData:e}){const n=await e.getItem(null);return x.get(n,"version",0)<this.VERSION}}const O=(t,e)=>{const[n,{setFalse:r}]=N.useBoolean(!0),[i,a]=m.useState();m.useEffect(()=>(t.getItem(e).then(c=>{a(c),r()}),t.watchItem(e,c=>{a(c)})));const l=m.useCallback(async c=>{await t.setItem(e,c),a(c)},[t,e]);return{loading:n,value:i,set:l}},ze={top:16,right:16,bottom:16,left:16},Ue=t=>Math.max(0,t-ze.left-ze.right),Ke=t=>Math.max(0,t-ze.top-ze.bottom),rn=(t,e)=>({width:Ue(t),height:Ke(e)}),Ie=({width:t,height:e,children:n})=>s.jsx(o.Box,{pt:ze.top,pr:ze.right,pb:ze.bottom,pl:ze.left,sx:{width:t,height:e,overflow:"hidden",position:"relative"},children:n}),Is={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 th({context:t}){const{value:e}=O(t.instanceData,"config"),n=t.data,{width:r,height:i}=t.viewport,{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:h}=x.defaults({},e,Is),p=m.useMemo(()=>Sn(n,a),[n,a]),{x:g,y,z:v}=m.useMemo(()=>({x:E(a),y:E(l),z:E(c)}),[a,l,c]),{min:C,max:T}=m.useMemo(()=>{const M=x.minBy(p,J=>J[v.columnKey]),$=x.maxBy(p,J=>J[v.columnKey]);return{min:x.get(M,v.columnKey),max:x.get($,v.columnKey)}},[p,v]),D={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:C,max:T,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:h,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:p.map(M=>[M[g.columnKey],M[y.columnKey],M[v.columnKey]])}]};return e?s.jsx(Ie,{width:r,height:i,children:s.jsx(ke,{echarts:_e,option:D,style:rn(r,i),notMerge:!0,theme:"merico-light"})}):null}const wa=m.createContext(null),Ms=wa.Provider;function Es(){const t=m.useContext(wa);if(!t)throw new Error("Please use DashboardModelContextProvider");return t}const X=()=>Es(),Ca=()=>Es(),Sa=m.createContext({searchButtonProps:{}}),As=Sa.Provider;function ka(){return m.useContext(Sa)}const Ta=m.createContext(null),Ps=Ta.Provider;function Da(){const t=m.useContext(Ta);if(!t)throw new Error("Please use ContentModelContextProvider");return t}const W=()=>Da(),de=()=>Da(),nh={inEditMode:!1},Mn=m.createContext(nh),za=m.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),$s=za.Provider;function Ia(){const t=m.useContext(za);if(!t.panel)throw new Error("Please use PanelContextProvider");return t}const dt=()=>Ia(),$e=()=>Ia(),sh={fullScreenPanelID:"",setFullScreenPanelID:x.noop},qs=m.createContext(sh);function Ma(){const t=m.useContext(qs);if(!t)throw new Error("Please use FullScreenPanelContext.Provider");return t}const rh={en:"en",zh:"zh-cn"};function Ls({children:t}){const{i18n:e}=_.useTranslation(),n=m.useMemo(()=>{const r=e.language;return rh[r]??"en"},[e.language]);return s.jsx(Fi.DatesProvider,{settings:{locale:n,firstDayOfWeek:1},children:t})}const B=S.observer(m.forwardRef(({label:t,required:e,description:n,value:r,onChange:i,queryID:a,clearable:l=!1,sx:c,...u},d)=>{const{panel:h}=$e(),p=m.useMemo(()=>h.dataFieldOptions(r,l,a),[r,l,a]);if(p.length===0){const g=h.explainDataKey(r);return s.jsxs(o.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[s.jsx(o.HoverCard.Target,{children:s.jsx(o.Box,{children:s.jsx(o.TextInput,{label:t,required:e,defaultValue:g.columnKey,readOnly:!0,disabled:!0})})}),s.jsx(o.HoverCard.Dropdown,{children:s.jsxs(o.Group,{position:"left",spacing:0,children:[s.jsx(o.Text,{size:"xs",color:g.queryName?"black":"red",sx:{fontFamily:"monospace"},children:g.queryName??g.queryID}),s.jsx(o.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),s.jsx(o.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:g.columnKey})]})})]})}return s.jsx(o.Select,{ref:d,label:t,description:n,data:p,value:r,onChange:i,required:e,sx:c,maxDropdownHeight:500,...u})}));function ih({context:t}){const{value:e,set:n}=O(t.instanceData,"config"),r=x.defaults({},e,Is),{control:i,handleSubmit:a,reset:l}=b.useForm({defaultValues:r});return m.useEffect(()=>{l(r)},[e]),e?s.jsx(o.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:a(n),children:[s.jsx(o.Text,{children:"X Axis"}),s.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>s.jsx(B,{label:"Data Field",required:!0,...c})}),s.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>s.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(o.Text,{mt:"lg",children:"Y Axis"}),s.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>s.jsx(B,{label:"Data Field",required:!0,...c})}),s.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>s.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(o.Text,{mt:"lg",children:"Z Axis"}),s.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>s.jsx(B,{label:"Data Field",required:!0,...c})}),s.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>s.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(o.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:s.jsxs(o.Button,{color:"blue",type:"submit",children:[s.jsx(q.DeviceFloppy,{size:20}),s.jsx(o.Text,{ml:"md",children:"Save"})]})})]})}):null}const ah=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function oh(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:a,z_axis_data_key:l,...c}=t;return{...c,x_axis_data_key:r(i),y_axis_data_key:r(a),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class lh extends oe{constructor(){super(...arguments);P(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:i}=n;return{...n,version:2,config:oh(i,r)}})}}const ch={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new lh,name:"bar-3d",viewRender:th,configRender:ih,createConfig(){return{version:2,config:x.cloneDeep(Is)}},translation:ah},uh=({disabled:t,value:e,onChange:n})=>{const r=i=>{i&&n(i)};return s.jsxs(o.Box,{sx:{position:"relative"},children:[t&&s.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),s.jsx(Pe,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:t}})]})};function Me({enabled:t,func_content:e}){return(n,r)=>{if(!t)return n;try{return new Function(`return ${e}`)()(n,r)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function we(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
57
57
|
`)}}const Je=m.forwardRef(({value:t,onChange:e,triggerButtonText:n},r)=>{const{t:i}=_.useTranslation(),[a,{setTrue:l,setFalse:c}]=N.useBoolean(),[u,d]=m.useState(t);m.useEffect(()=>{d(t)},[t]);const h=T=>{d({...u,enabled:T})},p=()=>{c();const{enabled:T,func_content:D}=u,M={enabled:T,func_content:D};d(M),e(M)},g=()=>{c(),d(t)},y=T=>{d(D=>({...D,func_content:T}))},v=()=>{y(we().func_content)},C=n??i("chart.axis.customize_label");return s.jsxs(s.Fragment,{children:[s.jsx(o.Button,{variant:"filled",color:"grape",leftIcon:s.jsx(k.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:C}),s.jsx(o.Modal,{size:800,title:C,opened:a,onClose:c,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&s.jsxs(o.Stack,{children:[s.jsx(o.Checkbox,{mt:10,label:i("common.enabled"),checked:u.enabled,onChange:T=>h(T.currentTarget.checked)}),s.jsx(uh,{value:u.func_content,onChange:y,disabled:!u.enabled}),s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Button,{onClick:v,color:"red",leftIcon:s.jsx(q.Recycle,{size:20}),children:i("common.actions.reset_to_default")}),s.jsxs(o.Group,{position:"right",children:[s.jsx(o.Button,{onClick:g,variant:"subtle",children:i("common.actions.cancel")}),s.jsx(o.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),onClick:p,children:i("common.actions.save")})]})]})]})})]})}),kt={x_axis_scroll:!1,y_axis_scroll:!1,x_axis_slider:!1,y_axis_slider:!1};function Ea(){return x.cloneDeep(kt)}const dh=[{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:"点击箱体、散点或异常点"}}}}],Aa={id:"builtin:echarts:click-echart:series",displayName:"viz.boxplot.click_series.label",nameRender:ph,configRender:hh,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 hh(t){return s.jsx(s.Fragment,{})}function ph(t){const{t:e}=_.useTranslation();return s.jsx(o.Text,{children:e("viz.boxplot.click_series.label")})}const En=m.forwardRef(({sectionTitle:t,value:e,onChange:n},r)=>{const{t:i,i18n:a}=_.useTranslation(),l=u=>d=>{const h=x.cloneDeep(e);x.set(h,u,d),n(h)},c=m.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"}],[a.language]);return s.jsxs(o.Stack,{spacing:0,children:[t&&s.jsx(o.Divider,{mb:-5,mt:5,variant:"dotted",label:t,labelPosition:"right",labelProps:{color:"dimmed"}}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(o.NumberInput,{label:i("chart.axis.overflow.max_width"),hideControls:!0,value:e.width,onChange:l("width")}),s.jsx(o.Select,{label:i("chart.axis.overflow.label"),data:c,value:e.overflow,onChange:l("overflow")}),s.jsx(o.TextInput,{label:i("chart.axis.overflow.ellipsis"),value:e.ellipsis,disabled:!0})]})]})}),Xe=m.forwardRef(({value:t,onChange:e},n)=>{const{t:r}=_.useTranslation(),i=l=>{e({...t,on_axis:l})},a=l=>{e({...t,in_tooltip:l})};return s.jsxs(o.Stack,{ref:n,spacing:0,children:[s.jsx(En,{sectionTitle:r("chart.axis.overflow.section_title.on_axis"),value:t.on_axis,onChange:i}),s.jsx(En,{sectionTitle:r("chart.axis.overflow.section_title.in_tooltip"),value:t.in_tooltip,onChange:a})]})});function Ee(){return{on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}}}function Ve({overflow:t,width:e}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[t],r=t==="truncate"?"nowrap":"initial",i={truncate:"ellipsis",break:"clip",breakAll:"clip"}[t];return`
|
|
58
58
|
max-width: ${e}px;
|
|
59
59
|
word-break: ${n};
|
|
@@ -445,7 +445,7 @@ Check the top-level render call using <`+A+">.")}return z}}function hu(w,z){{if(
|
|
|
445
445
|
`)},Zr=f.types.model("ViewModalConfig",{_name:f.types.literal(L.Modal),width:f.types.string,height:f.types.string,custom_modal_title:f.types.optional(tS,as)}).views(t=>({get json(){const{_name:e,width:n,height:r,custom_modal_title:i}=t;return{_name:e,width:n,height:r,custom_modal_title:i.json}}})).actions(t=>({setWidth(e){t.width=e},setHeight(e){t.height=e}})),Al=()=>Zr.create({_name:L.Modal,width:"90vw",height:"90vh"}),nS=f.types.model("ViewTabsTabModel",{id:f.types.identifier,name:f.types.string,view_id:f.types.string,color:f.types.optional(f.types.string,""),order:f.types.optional(f.types.number,0)}).views(t=>({get json(){const{id:e,name:n,view_id:r,color:i,order:a}=t;return{id:e,name:n,color:i,order:a,view_id:r}}})).actions(t=>({setName(e){t.name=e},setViewID(e){t.view_id=e},setColor(e){t.color=e},setOrder(e){t.order=e}})),Hr=f.types.model("ViewTabsConfig",{_name:f.types.literal(L.Modal),tabs:f.types.optional(f.types.array(nS),[]),variant:f.types.optional(f.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:f.types.optional(f.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:f.types.optional(f.types.boolean,!1)}).views(t=>({get json(){const{_name:e,variant:n,orientation:r,tabs:i,grow:a}=t;return{grow:a,tabs:i.map(l=>l.json),_name:e,variant:n,orientation:r}},get tabsInOrder(){return x.sortBy(t.tabs,"order")}})).actions(t=>({setVariant(e){t.variant=e},setOrientation(e){t.orientation=e},setGrow(e){t.grow=e},setTabs(e){t.tabs.length=0,t.tabs=f.cast(e)},addTab(){const e=ie.randomId(),n={id:e,name:e,view_id:""};t.tabs.push(n)},removeTab(e){t.tabs.splice(e,1)}})),Pl=()=>Hr.create({_name:L.Modal,tabs:[]}),$l=f.types.model({id:f.types.identifier,name:f.types.string,type:f.types.enumeration("EViewComponentType",[L.Division,L.Modal,L.Tabs]),config:f.types.union(Xr,Zr,Hr),panelIDs:f.types.optional(f.types.array(f.types.string),[])}).views(t=>({get json(){const{id:e,name:n,type:r,config:i}=t;return{id:e,name:n,type:r,config:i.json,panelIDs:t.panelIDs.map(a=>a)}}})).actions(t=>({setName(e){t.name=e},setType(e){if(t.type!==e){switch(e){case L.Division:t.config=El();break;case L.Modal:t.config=Al();break;case L.Tabs:t.config=Pl();break}t.type=e}},appendPanelID(e){t.panelIDs.push(e)},appendPanelIDs(e){t.panelIDs.push(...e)},removePanelID(e){const n=t.panelIDs.filter(r=>r!==e);t.panelIDs.length=0,t.panelIDs.push(...n)}})),mt="11.10.0",sS={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:L.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:mt,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},ei=f.types.model("DataSourceMetaModel",{id:f.types.string,type:f.types.enumeration("DataSourceType",[ce.HTTP,ce.MySQL,ce.Postgresql]),key:f.types.string,config:f.types.frozen()}),ql=f.types.model("DataSourcesMetaModel",{list:f.types.optional(f.types.array(ei),[])}).views(t=>({find({type:e,key:n}){return t.list.find(r=>r.key===n&&r.type===e)},get options(){return t.list.map(e=>({value:e.key,label:e.key}))}})).actions(t=>({replace(e){t.list.length=0,t.list.push(...e)}})),Ll=f.types.model({id:f.types.string,content:f.types.string,create_time:f.types.string,update_time:f.types.string,is_preset:f.types.boolean}),ti=f.types.model("GlobalSQLSnippetsMeta",{list:f.types.optional(f.types.array(Ll),[])}).views(t=>({find(e){return t.list.find(n=>n.id===e)},get options(){return t.list.map(e=>({value:e.id,label:e.id}))}})).actions(t=>({replace(e){t.list.length=0,t.list.push(...e)}})),os=f.types.model("ContextMeta",{current:f.types.optional(f.types.frozen(),{})}).views(t=>({get keys(){return Object.keys(t.current)},get entries(){return Object.entries(t.current)}})).actions(t=>({replace(e){t.current=e},get(e){return t.current[e]},set(e,n){t.current[e]=n}}));function ni(t){return os.create({current:t})}const si=f.types.compose("ViewRenderModel",$l,f.types.model({tab:f.types.optional(f.types.string,"")})).views(t=>({get defaultTab(){if(t.type!==L.Tabs)return"";const e=t.config;return e.tabs.length>0?e.tabs[0].id:""},get tabViewID(){var n;return t.type!==L.Tabs?"":((n=t.config.tabs.find(r=>r.id===t.tab))==null?void 0:n.view_id)??""},get contentModel(){return f.getParent(t,3)},get panels(){if(t.type!==L.Tabs)return this.contentModel.panels.panelsByIDs(t.panelIDs);const e=this.tabViewID,n=this.contentModel.views.findByID(e);return(n==null?void 0:n.panels)??[]},get renderViewIDs(){const e=[t.id];return t.type===L.Tabs&&e.push(this.tabViewID),e},async downloadScreenshot(e){const n=e.offsetWidth*2+10,r=e.offsetHeight*2+10,i=new aa,a=new Date().getTime(),l=await ia.toBlob(e,{bgcolor:"white",width:n,height:r,style:{transformOrigin:"0 0",transform:"scale(2)"}});i.file(`${t.name}_${a}.png`,l),i.file(`dashboard_state_${a}.json`,JSON.stringify(this.contentModel.dashboardState,null,4)),i.generateAsync({type:"blob"}).then(c=>{Cn.saveAs(c,`${t.name}_${a}.zip`)}).catch(c=>{console.error(c),yt.notifications.show({color:"red",title:"Failed to download screenshot with dashboard state",message:c.message})})}})).actions(t=>({setTab(e){t.tab=e??""},afterCreate(){f.addDisposer(t,U.reaction(()=>t.defaultTab,e=>this.setTab(e),{fireImmediately:!0,delay:0}))}})),ri=f.types.model("ViewsRenderModel",{current:f.types.optional(f.types.array(si),[]),visibleViewIDs:f.types.array(f.types.string)}).views(t=>({get json(){return t.current.map(e=>Ot(e.json))},get idMap(){const e=new Map;return t.current.forEach(n=>{e.set(n.id,n)}),e},findByID(e){return t.current.find(n=>n.id===e)},get firstVisibleView(){const[e]=t.visibleViewIDs;return t.current.find(({id:n})=>n===e)},get visibleViews(){const e=new Set(t.visibleViewIDs);return t.current.filter(({id:n})=>e.has(n))}})).actions(t=>({appendToVisibles(e){new Set(t.visibleViewIDs.map(r=>r)).has(e)||t.visibleViewIDs.push(e)},rmVisibleViewID(e){const n=t.visibleViewIDs.findIndex(r=>r===e);n!==-1&&t.visibleViewIDs.splice(n,1)}}));function Bl(t){const e=t.length>0?[t[0].id]:[];return{current:t.map(r=>{const{_name:i=r.type}=r.config;return{...r,config:{...r.config,_name:i},panelIDs:r.panelIDs}}),visibleViewIDs:e}}const rS=new ju.AsyncParser({withBOM:!0});async function Ol(t){return!Array.isArray(t)||t.length===0?"":await rS.parse(t).promise()}async function iS(t,e){const n=await Ol(e),r=new Blob([n],{type:"text/csv"});Cn.saveAs(r,`${t}.csv`)}function Vl(t){const e=new aa,n=t.map(async({id:r,data:i})=>{const a=await Ol(i);e.file(`${r}.csv`,a)});Promise.all(n).then(()=>{e.generateAsync({type:"blob"}).then(r=>{Cn.saveAs(r,"dashboard_data.zip")})}).catch(r=>{console.error(r),yt.notifications.show({color:"red",title:"Failed to download data",message:r.message})})}function Ut(t,e){const n=new Blob([e],{type:"application/json"});Cn.saveAs(n,`${t}.json`)}const ii=_l.views(t=>({get contentModel(){return f.getRoot(t).content}})).views(t=>({get queries(){return t.contentModel.queries.findByIDSet(t.queryIDSet)},get firstQuery(){return this.queries.length>0?this.queries[0]:null},get firstQueryData(){return this.firstQuery?this.firstQuery.data:[]},queryByID(e){return this.queries.find(n=>n.id===e)},get data(){return this.queries.reduce((e,n)=>(e[n.id]=n.data,e),{})},get variableStrings(){return ma(t.variables,this.data)},get dataLoading(){return this.queries.some(e=>e.state==="loading")},get queryStateMessages(){const e=this.queries.filter(a=>!a.runByConditionsMet);if(e.length===0)return"";const n=new Set,r=new Set;e.forEach(a=>{const l=a.conditionNames;l.context.forEach(c=>n.add(c)),l.filters.forEach(c=>r.add(c))});const i=[];return n.size>0&&(console.log(n),i.push(`context: ${Array.from(n).join(", ")}`)),r.size>0&&i.push(`filter${r.size>1?"s":""}: ${Array.from(r).join(", ")}`),i.length===2&&i.splice(1,0,"and"),i.unshift("Waiting for"),i.join(" ")},get queryErrors(){return this.queries.map(e=>e.error).filter(e=>!!e)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages===""&&!this.dataLoading}})).actions(t=>({refreshData(){t.queries.forEach(e=>e.fetchData(!0))},downloadData(){t.contentModel.queries.downloadDataByQueryIDs(t.queryIDs)},getSchema(){const e=t.json;return e.viz.conf={...e.viz.conf,__INTERACTIONS:{},__OPERATIONS:{},__TRIGGERS:{}},{panel:e,queries:t.queries.map(n=>n.json),layouts:t.contentModel.layouts.jsonByPanelIDSet(new Set([t.id]))}},downloadSchema(){const{panel:e,queries:n,layouts:r}=this.getSchema(),a=JSON.stringify({panels:[e],definition:{queries:n},layouts:r,version:mt},null,2),l=t.name;Ut(l,a)}}));function Nl(t){return{id:t,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:kr.name,conf:kr.createConfig()},style:{border:{enabled:!0}}}}const ai=f.types.model("PanelsRenderModel",{list:f.types.optional(f.types.array(ii),[])}).views(t=>({get json(){return t.list.map(e=>e.json)},findByID(e){return t.list.find(n=>n.id===e)},get idMap(){const e=new Map;return t.list.forEach(n=>{e.set(n.id,n)}),e}})).views(t=>({panelsByIDs(e){const n=[];return e.forEach(r=>{const i=t.idMap.get(r);i?n.push(i):console.warn(`Panel is not found, id:${r}`)}),n}}));function Fl(t){const e=t.config,n=e.default_value;if(n===void 0)return n;if(e._name==="date-range")try{if(e.default_shortcut){const i=pl(e.default_shortcut);if(i)return i.map(a=>I(a).format(e.inputFormat))}const[...r]=n;return r.map(i=>i===null?i:I.tz(i,"UTC").format(e.inputFormat)??i)}catch(r){return console.error(r),n}return n}function aS(t,e){const n=t.default_value_func;try{return new Function(`return ${n}`)()(t,lt,e)}catch(r){return console.error(r),Fl(t)}}function Gl(t,e){var n;return(n=t.default_value_func)!=null&&n.trim()?aS(t,e):Fl(t)}function Wl(t,e){return t.reduce((n,r)=>(n[r.key]=Gl(r,e),n),{})}const oi=f.types.model("FiltersRenderModel",{current:f.types.optional(f.types.array(Jr),[]),values:f.types.optional(f.types.frozen(),{})}).views(t=>({get json(){return t.current.map(e=>e.json)},get contentModel(){return f.getRoot(t).content},get context(){return this.contentModel.payloadForSQL.context},get initialValuesDep(){return JSON.stringify({filters:t.current.map(({default_value_func:e,config:n})=>({default_value_func:e,config:n})),context:this.contentModel.payloadForSQL.context})},get formattedDefaultValues(){return Wl(this.json,this.contentModel.context)},get firstID(){if(t.current.length!==0)return t.current[0].id},findByID(e){return t.current.find(n=>n.id===e)},findByIDSet(e){return t.current.filter(n=>e.has(n.id))},get inOrder(){return x.sortBy(t.current,"order")},get empty(){return t.current.length===0},visibleInView(e){return x.sortBy(t.current.filter(n=>n.visibleInViewsIDSet.has(e)),"order")},get firstFilterValueKey(){return Object.keys(t.values)[0]??""},get keySet(){return new Set(t.current.map(e=>e.key))},get keyLabelMap(){return t.current.reduce((e,n)=>(e[n.key]=n.label,e),{})},getSelectOption(e){const n=this.findByID(e);if(!n||!("getSelectOption"in n.config))return null;const r=t.values[n.key];return n.config.getSelectOption(r)}})).actions(t=>({setValues(e){t.values=e},patchValues(e){t.values=x.defaults({},e,t.values)},setValueByKey(e,n){t.values={...t.values,[e]:n}},getValueByKey(e){return t.values[e]},getSchema(e,n){return{filters:t.findByIDSet(new Set(e)).map(a=>({...a.json,visibleInViewsIDs:n?a.json.visibleInViewsIDs:[]})),version:mt}},downloadSchema(e){const n=JSON.stringify(this.getSchema(e,!1),null,2);Ut("Filters",n)}}));function li(t,e,n,r){const i=x.defaults({},r,Wl(t,{...n,...e}));return{current:t,values:i}}const Ql=jl.views(t=>({get rootModel(){return f.getRoot(t)},get contentModel(){return this.rootModel.content},get conditionOptions(){if(!f.isAlive(t))return[];const{context:e}=this.contentModel.payloadForSQL,n=Object.keys(e).map(l=>({group:"Context",label:l,value:`context.${l}`,description:void 0})),r=this.contentModel.filters.keyLabelOptions.map(l=>({group:"Filters",label:l.label,value:`filters.${l.value}`,description:l.value})),i=[...n,...r],a=new Set(i.map(l=>l.value));return t.run_by.forEach(l=>{a.has(l)||i.push({group:"Invalid",label:l,value:l})}),i},get unmetRunByConditions(){if(!f.isAlive(t))return[];const{run_by:e}=t;if(e.length===0)return[];const n=this.contentModel.payloadForSQL;return e.filter(r=>{const i=x.get(n,r);return Array.isArray(i)?i.length===0:typeof i=="number"?Number.isNaN(i):!i})}})).views(t=>({get payload(){return t.contentModel.payloadForSQL},get formattedSQL(){return js(t.sql,this.payload)},get httpConfigString(){const{context:e,filters:n}=this.payload,{name:r,pre_process:i}=t.json,a=Ad(i,e,n);return console.groupCollapsed(`Request config for: ${r}`),console.log(a),console.groupEnd(),JSON.stringify(a)},get typedAsSQL(){return[ce.Postgresql,ce.MySQL].includes(t.type)},get typedAsHTTP(){return[ce.HTTP].includes(t.type)},get isTransform(){return t.type===ce.Transform},get reQueryKey(){const{react_to:e=[]}=t;if(e.length===0)return"";const n=t.contentModel.payloadForSQL,r=[...e].reduce((i,a)=>(i[a]=x.get(n,a),i),{});return JSON.stringify(r)},get runByConditionsMet(){return t.unmetRunByConditions.length===0},get conditionNames(){if(t.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:e}=t.contentModel.filters,n=t.unmetRunByConditions.filter(i=>i.startsWith("context.")).map(i=>i.replace("context.","")),r=t.unmetRunByConditions.filter(i=>i.startsWith("filters.")).map(i=>x.get({filters:e},i,i.replace("filters.",""))).filter(i=>!!i);return{context:n,filters:r}},get queries(){return f.getParent(t,2)},get inUse(){return this.queries.isQueryInUse(t.id)},get dependencies(){if(!this.typedAsSQL)return[];const e=x.uniq(t.sql.match(zn.sqlSnippet)),n=x.uniq(t.sql.match(zn.filter)),r=x.uniq(t.sql.match(zn.context)),i=[];return e.forEach(a=>{i.push({type:"sql_snippet",key:a,valid:t.contentModel.sqlSnippets.keySet.has(a)})}),n.forEach(a=>{i.push({type:"filter",key:a,valid:t.contentModel.filters.keySet.has(a)})}),r.forEach(a=>{i.push({type:"context",key:a,valid:t.contentModel.mock_context.keySet.has(a)})}),i}})),ci=f.types.compose("QueryRenderModel",Ql,f.types.model({state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),data:f.types.optional(f.types.frozen([]),[]),error:f.types.frozen()})).views(t=>({get datasource(){const{key:e,type:n}=t;return t.rootModel.datasources.find({type:n,key:e})},get additionalQueryInfo(){return t.contentModel.getAdditionalQueryInfo(t.id)},get depQueryModels(){return t.contentModel.queries.findByIDSet(new Set(t.dep_query_ids))},get depQueryModelStates(){return this.depQueryModels.map(e=>e.state)},get depQueryModelStatesString(){return this.depQueryModelStates.toString()}})).views(t=>({get stateMessage(){if(t.state!=="idle")return"";if(!t.runByConditionsMet){const{context:e,filters:n}=t.conditionNames;if(e.length===0&&n.length===0)return"Waiting";const r=[];return e.length>0&&r.push(`context: ${e.join(", ")}`),n.length>0&&r.push(`filter${n.length>1?"s":""}: ${n.join(", ")}`),r.length===2&&r.splice(1,0,"and"),r.unshift("Waiting for"),r.join(" ")}return t.data.length>0?"":"Empty Data"}})).volatile(()=>({controller:new AbortController})).actions(t=>({runSQL:f.flow(function*(){var e;if(t.valid&&((e=t.controller)==null||e.abort(),!!t.runByConditionsMet)){t.controller=new AbortController,t.state="loading";try{const n=t.payload;t.data=yield*f.toGenerator(Bd({payload:n,name:t.name,query:t.json,additionals:t.additionalQueryInfo},t.controller.signal)),t.state="idle",t.error=null}catch(n){if(!at.isCancel(n)){t.data=[];const r=x.get(n,"message","unkown error");t.error=x.get(n,"response.data.detail.message",r),t.state="error"}}}}),runHTTP:f.flow(function*(){var e;if(!(!t.valid||!t.datasource)&&((e=t.controller)==null||e.abort(),!!t.runByConditionsMet)){t.controller=new AbortController,t.state="loading";try{const{type:n,key:r,post_process:i}=t.json;let a=JSON.parse(t.httpConfigString);a=Pd(t.datasource,a);const l=yield*f.toGenerator(Od({type:n,key:r,configString:JSON.stringify(a),name:t.name,additionals:t.additionalQueryInfo},t.controller.signal)),c=$d(t.datasource,l),u=qd(i,c,t.contentModel.dashboardState);t.data=u,t.state="idle",t.error=null}catch(n){if(console.error(n),!at.isCancel(n)){t.data=[];const r=x.get(n,"message","unkown error");t.error=x.get(n,"response.data.detail.message",r),t.state="error"}}}}),runTransformation(){t.state="loading";try{const n=t.contentModel.queries.findByIDSet(new Set(t.dep_query_ids)).map(l=>({id:l.id,name:l.name,data:x.cloneDeep(l.data)})),r=t.contentModel.dashboardState,i=t.pre_process,a=new Function(`return ${i}`)()(n,r,lt);t.data=a,t.state="idle",t.error=null}catch(e){t.data=[],t.error=e.message,t.state="error"}}})).actions(t=>({fetchData:e=>{if(!t.inUse&&!e){console.debug(`🟡 Skipping query[${t.name}]`);return}return console.debug(`🔵 Running query[${t.name}]`),t.isTransform?t.runTransformation():t.typedAsHTTP?t.runHTTP():t.runSQL()},beforeDestroy(){var e;(e=t.controller)==null||e.abort()}})).actions(t=>({afterCreate(){f.addDisposer(t,U.reaction(()=>{var n;return t.isTransform?[t.inUse,t.id,t.key,t.dep_query_ids.toString(),t.pre_process,t.depQueryModelStatesString].join("--"):t.typedAsHTTP?`${t.inUse}--${t.id}--${t.key}--${t.reQueryKey}--${(n=t.datasource)==null?void 0:n.id}`:[t.inUse,t.id,t.key,t.formattedSQL,t.pre_process,t.post_process].join("--")},()=>t.fetchData(!1),{fireImmediately:!0,delay:0}))}})),ui=f.types.model("QueriesRenderModel",{current:f.types.optional(f.types.array(ci),[])}).views(t=>({get idSet(){return new Set(t.current.map(e=>e.id))},get firstID(){if(t.current.length!==0)return t.current[0].id},findByID(e){return t.current.find(n=>n.id===e)},findByIDSet(e){return t.current.filter(n=>e.has(n.id))},get json(){return t.current.filter(e=>e.id&&e.key).map(e=>e.json)},get contentModel(){return f.getParent(t,1)},get visibleQueryIDSet(){const{views:e,filters:n,queries:r}=this.contentModel,i=[];e.visibleViews.forEach(c=>{c.panels.forEach(u=>{i.push(...u.queryIDs)})});const a=x.uniq(e.visibleViews.map(c=>c.renderViewIDs).flat());n.current.forEach(c=>{const u=x.get(c,"config.options_query_id");if(!u)return;a.some(h=>c.visibleInViewsIDSet.has(h))&&i.push(u)}),r.findByIDSet(new Set(i)).forEach(c=>{!c.isTransform||c.dep_query_ids.length===0||i.push(...c.dep_query_ids)});const l=new Set(i);return console.debug("QueryIDs:",l),l},isQueryInUse(e){return this.visibleQueryIDSet.has(e)}})).actions(t=>({downloadAllData(){const e=t.current.map(({name:n,data:r})=>({id:n,data:r}));Vl(e)},downloadDataByQueryIDs(e){const n=new Set(e),r=t.current.filter(i=>n.has(i.id)).map(({name:i,data:a})=>({id:i,data:a}));Vl(r)},downloadDataByQueryID(e){const n=t.findByID(e);if(!n){console.log("[downloadDataByQueryID] query not found");return}const{name:r,data:i}=n;iS(r,i)},refetchDataByQueryID(e){const n=t.findByID(e);if(!n){console.error(new Error(`[downloadDataByQueryID] query by ID[${e}] not found`));return}return n.fetchData(!0)},getSchema(e){return{definition:{queries:t.findByIDSet(new Set(e)).map(i=>i.json)},version:mt}},downloadSchema(e){const n=JSON.stringify(this.getSchema(e),null,2);Ut("Queries",n)}}));function Rl(t){return{current:t}}function Yl({min:t,max:e}){const n=`${t}px`,r=Number.isFinite(e)?`${e}px`:"∞";return`[${n}, ${r})`}const di=f.types.model("LayoutsRenderModel",{list:f.types.array(Cl),currentBreakpoint:f.types.string}).views(t=>({get json(){return t.list.map(e=>e.json)},jsonByPanelIDSet(e){return t.list.map(n=>n.jsonByPanelIDSet(e))},get root(){return f.getRoot(t)},get contentModel(){return this.root.content},get basisLayoutSet(){return t.list.find(e=>e.id==="basis")},get currentLayoutSet(){return t.list.find(e=>e.id===t.currentBreakpoint)},get currentLayoutRange(){return this.breakpointRanges.find(e=>e.id===t.currentBreakpoint)},get currentRangeText(){const e=this.currentLayoutRange;return Yl(e)},get cols(){const e={};return t.list.forEach(n=>{e[n.id]=36}),e},get breakpoints(){const e={};return t.list.forEach(n=>{e[n.id]=n.breakpoint}),e},get breakpointNameRecord(){const e={};return t.list.forEach(n=>{e[n.name]=n.breakpoint}),e},get breakpointRanges(){const e=t.list.map(n=>({id:n.id,name:n.name,min:n.breakpoint,max:1/0,text:""}));return e.sort((n,r)=>n.min-r.min).forEach((n,r)=>{r!==e.length-1&&(n.max=e[r+1].min)}),e.forEach(n=>{n.text=Yl(n)}),e},get breakpointsInfo(){return t.list.map(e=>({id:e.id,name:e.name,breakpoint:e.breakpoint})).sort((e,n)=>e.breakpoint-n.breakpoint)},get currentBreakpointRange(){return this.breakpointRanges.find(e=>e.id===t.currentBreakpoint)},get currentLayoutPreviewWidth(){const e=this.currentBreakpointRange;if(e)return e.max===1/0?e.min===0?void 0:e.min+1:e.max},items(e){const n=new Set(e);return this.currentLayoutSet.list.filter(i=>n.has(i.panelID))},gridLayouts(e){const n=new Set(e),r={};return t.list.forEach(i=>{r[i.id]=i.list.filter(a=>n.has(a.panelID)).map(a=>a.layoutProperies)}),r},findItemByPanelID(e){return this.currentLayoutSet.findByPanelID(e)}})).actions(t=>({setCurrentBreakpoint(e){console.log("🔴 onBreakpointChange:",e),t.currentBreakpoint=e},afterCreate(){f.addDisposer(t,U.reaction(()=>t.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),Ul=Sl.views(t=>({isADuplicatedKey(e){return!e||e===t.key?!1:!!f.getParent(t,2).findByKey(e)}})),hi=f.types.model("SQLSnippetsRenderModel",{current:f.types.optional(f.types.array(Ul),[])}).views(t=>({get json(){return t.current.map(e=>e.json)},get record(){return t.current.reduce((e,n)=>(e[n.key]=n.value,e),{})},get keySet(){return new Set(t.current.map(e=>e.key))},get firstKey(){if(t.current.length!==0)return t.current[0].key},findByKey(e){return t.current.find(n=>n.key===e)},findByKeySet(e){return t.current.filter(n=>e.has(n.key))}})).actions(t=>({getSchema(e){return{definition:{sqlSnippets:t.findByKeySet(new Set(e)).map(i=>i.json)},version:mt}},downloadSchema(e){const n=JSON.stringify(this.getSchema(e),null,2);Ut("SQL Snippets",n)}}));function Kl(t){return{current:t}}function gn(t,e,n,r){return t.reduce((i,a)=>{try{i[a[e]]=_s(a[n],r)}catch(l){i[a[e]]=l.message}return i},{})}class Jl{constructor(e){P(this,"origin");P(this,"copy");this.origin=e,this.copy=f.clone(e),U.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!x.isEqual(f.getSnapshot(this.origin),f.getSnapshot(this.copy))}commit(){f.applySnapshot(this.origin,f.getSnapshot(this.copy))}reset(){f.applySnapshot(this.copy,f.getSnapshot(this.origin))}update(e){f.applySnapshot(this.copy,e)}}const Xl=t=>new Jl(t),oS=S.observer(({view:t})=>{const{t:e}=_.useTranslation(),n=X(),r=W(),i=Be.useModals(),{panel:a,downloadPanelScreenshot:l}=$e(),{id:c}=a,{viewPanelInFullScreen:u,inFullScreen:d}=m.useContext(is),h=()=>{r.duplicatePanelByID(c,t.id)},p=()=>{n.editor.open(["_VIEWS_",t.id,"_PANELS_",c])},g=()=>i.openConfirmModal({title:`${e("panel.delete")}?`,labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>r.removePanelByID(c,t.id),confirmProps:{color:"red"},zIndex:320}),y=m.useCallback(()=>{u(c)},[c,u]),v=!d&&t.type!==L.Modal;return s.jsx(s.Fragment,{children:s.jsx(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:s.jsxs(o.Menu,{withinPortal:!0,children:[s.jsx(o.Menu.Target,{children:s.jsx(o.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),s.jsxs(o.Menu.Dropdown,{children:[s.jsx(o.Menu.Item,{onClick:a.refreshData,icon:s.jsx(q.Refresh,{size:14}),children:e("common.actions.refresh")}),s.jsx(o.Menu.Item,{onClick:a.downloadData,icon:s.jsx(q.Download,{size:14}),children:e("common.actions.download_data")}),s.jsx(o.Menu.Item,{onClick:a.downloadSchema,icon:s.jsx(k.IconCode,{size:14}),children:e("common.actions.download_schema")}),s.jsx(o.Menu.Item,{onClick:l,icon:s.jsx(k.IconCamera,{size:14}),children:e("common.actions.download_screenshot")}),v&&s.jsx(o.Menu.Item,{onClick:y,icon:s.jsx(q.ArrowsMaximize,{size:14}),disabled:!0,children:e("common.actions.enter_fullscreen")}),s.jsx(o.Divider,{label:e("common.actions.edit"),labelPosition:"center"}),s.jsx(o.Menu.Item,{onClick:p,icon:s.jsx(q.Settings,{size:14}),children:e("common.titles.settings")}),s.jsx(o.Menu.Item,{onClick:h,icon:s.jsx(q.Copy,{size:14}),children:e("common.actions.duplicate")}),s.jsx(o.Menu.Item,{color:"red",onClick:g,icon:s.jsx(q.Trash,{size:14}),children:e("common.actions.delete")})]})]})})})});function lS(t){return t?["<p><br></p>","<p></p>"].includes(t):!0}const pi=S.observer(()=>{const{t}=_.useTranslation(),[e,n]=m.useState(!1),{panel:r}=dt();return lS(r.description)?null:s.jsxs(s.Fragment,{children:[s.jsx(o.Modal,{opened:e,onClose:()=>n(!1),title:r.title.show?r.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:s.jsx(Jn,{value:r.description,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}}})}),s.jsx(o.Tooltip,{label:t("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:s.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:s.jsx(q.InfoCircle,{size:20})})})]})}),eI="",cS=S.observer(function(){const{panel:e}=dt(),{name:n,title:r}=e;return r.show?s.jsx(o.Group,{grow:!0,position:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:s.jsx(o.Text,{align:"center",lineClamp:1,className:"panel-title-text",children:n})}):null});function uS(t){const e=m.useRef(null);return{ref:e,downloadPanelScreenshot:()=>{const r=e.current;if(!r)return;const i=r.offsetWidth*2,a=r.offsetHeight*2;ia.toBlob(e.current,{bgcolor:"white",width:i,height:a,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(l=>{window.saveAs(l,`${t.name?t.name:t.viz.type}.png`)})}}}var Zl=(t=>(t.migrated="migrated",t.nothingToMigrate="nothingToMigrate",t.checkFailed="checkFailed",t.migrationFailed="migrationFailed",t))(Zl||{}),ls=(t=>(t.notStarted="notStarted",t.inProgress="inProgress",t.done="done",t))(ls||{});class dS{constructor(e){P(this,"vizInstance");P(this,"operationManager");P(this,"triggerManager");P(this,"vizManager");P(this,"runningMigration");P(this,"panelModel");P(this,"status","notStarted");this.panelModel=e.getRequired(he.instanceScope.panelModel),this.vizInstance=e.getRequired(he.instanceScope.vizInstance),this.operationManager=e.getRequired(he.instanceScope.operationManager),this.triggerManager=e.getRequired(he.instanceScope.triggerManager),this.vizManager=e.getRequired(he.vizManager)}async createMigrationTask(){const e=[];try{await this.instanceNeedMigration()&&e.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&e.push(()=>this.runInteractionMigration())}catch(n){return console.warn("check migration failed",n),"checkFailed"}if(e.length===0)return"nothingToMigrate";try{return await Promise.all(e.map(n=>n())),"migrated"}catch(n){return console.warn("migration failed",n),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(e=>(this.status="done",e))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const e=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await e.migrator.migrate(n)}async instanceNeedMigration(){const e=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData};return e.migrator.needMigration(n)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function Hl(t){const{panel:e}=dt();return m.useCallback(n=>{const r=n.getRequired(he.vizManager),i=r.resolveComponent(t.viz.type);return n.createScoped().provideFactory(he.instanceScope.vizInstance,()=>r.getOrCreateInstance(t)).provideFactory(he.instanceScope.interactionManager,a=>{const l=a.getRequired(he.instanceScope.vizInstance);return new Vs(l,i,An)}).provideFactory(he.instanceScope.operationManager,a=>a.getRequired(he.instanceScope.interactionManager).operationManager).provideFactory(he.instanceScope.triggerManager,a=>a.getRequired(he.instanceScope.interactionManager).triggerManager).provideValue(he.instanceScope.panelModel,e).provideFactory(he.instanceScope.migrator,a=>new dS(a))},[t.viz.type,t.viz.conf])}function ec(t){const[e,n]=m.useState(!1),r=hl().getRequired(he.instanceScope.migrator);return N.useAsyncEffect(async()=>{const i=r.status===ls.notStarted;n(r.status===ls.done),r.status===ls.notStarted&&r.runMigration().then(a=>{a===Zl.migrated&&i&&(t==null||t())}).finally(()=>{n(!0)})},[r]),e}function tc(t,e){const n=hl().getRequired(he.instanceScope.vizInstance);return m.useEffect(()=>(n.instanceData.setItem(null,e.viz.conf),n.instanceData.watchItem(null,r=>{t(r)})),[t,e.viz.type]),n}function hS({setVizConf:t,...e}){const{panel:n}=e,r=tc(t,n),i=ec(()=>{yt.showNotification({title:`${n.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return N.useAsyncEffect(async()=>{await r.instanceData.setItem(null,n.viz.conf)},[r,n.viz.type]),i?s.jsx(Gd,{...e}):s.jsx(o.Text,{children:"Checking update..."})}function pS(t){const{panel:e,setVizConf:n}=t;tc(n,e);const{inEditMode:r}=m.useContext(Mn);return ec(()=>{r&&yt.showNotification({title:`${e.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?s.jsx(Fd,{...t}):s.jsx(o.Text,{children:"Checking update"})}const tI="";function mS(t,e){const{vizManager:n}=m.useContext(it),{panel:{viz:r,title:i,id:a,name:l,description:c,queryIDs:u,variables:d}}=dt(),h={id:a,name:l,title:i,description:c,queryIDs:u,viz:r},p=Hl(h);try{return n.resolveComponent(r.type),s.jsx(rs,{configure:p,children:s.jsx(pS,{setVizConf:r.setConf,panel:h,measure:e,data:t,variables:d,vizManager:n})})}catch(g){return console.info(x.get(g,"message")),null}}const nc=S.observer(function({data:e}){const{ref:n,width:r,height:i}=ie.useElementSize(),a=mS(e,{w:r,h:i}),l=r>0&&i>0;return s.jsx("div",{className:"viz-root",ref:n,children:s.jsx(o.Box,{sx:{width:r,height:i,overflow:"hidden"},children:l&&s.jsx(je,{children:a})})})}),sc=S.observer(({panel:t})=>s.jsxs(o.Stack,{children:[t.queryErrors.map((e,n)=>s.jsx(o.Text,{color:"red",size:"sm",align:"center",sx:{fontFamily:"monospace"},children:e},`${n}-${e}`)),s.jsx(o.Text,{color:"gray",align:"center",size:"sm",children:t.queryStateMessages})]})),mi=S.observer(({panel:t})=>s.jsxs(o.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[s.jsx(o.LoadingOverlay,{visible:t.dataLoading,exitTransitionDuration:0}),!t.canRenderViz&&s.jsx(sc,{panel:t}),t.canRenderViz&&s.jsx(nc,{data:t.data})]})),fS={border:"1px solid #e9ecef"},rc=S.observer(({panel:t,panelStyle:e,dropdownContent:n})=>{const{ref:r,downloadPanelScreenshot:i}=uS(t);return t.title.show,s.jsx($s,{value:{panel:t,data:t.data,loading:t.dataLoading,errors:t.queryErrors,downloadPanelScreenshot:i},children:s.jsxs(o.Box,{className:`panel-root ${t.title.show?"panel-root--show-title":""}`,ref:r,p:0,sx:{...fS,...e},children:[s.jsx(o.Box,{className:"panel-description-popover-wrapper",children:s.jsx(pi,{})}),n,s.jsx(cS,{}),s.jsx(mi,{panel:t})]})})}),gS={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function xS(t){return t.style.border.enabled?{}:gS}const ic=S.observer(function({panel:e,view:n}){const r=xS(e);return s.jsx(rc,{panel:e,panelStyle:r,dropdownContent:s.jsx(oS,{view:n})})});function yS(t){return!["richText","button"].includes(t)}const bS=S.observer(({view:t})=>{const{t:e}=_.useTranslation(),{panel:n,downloadPanelScreenshot:r}=dt(),{id:i}=n,{viewPanelInFullScreen:a,inFullScreen:l}=m.useContext(is),c=m.useCallback(()=>{a(i)},[i,a]),u=!l&&t.type!==L.Modal;return yS(n.viz.type)?s.jsx(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:s.jsxs(o.Menu,{withinPortal:!0,children:[s.jsx(o.Menu.Target,{children:s.jsx(o.Box,{className:"panel-dropdown-target"})}),s.jsxs(o.Menu.Dropdown,{children:[s.jsx(o.Menu.Item,{onClick:n.refreshData,icon:s.jsx(q.Refresh,{size:14}),children:e("common.actions.refresh")}),s.jsx(o.Menu.Item,{onClick:n.downloadData,icon:s.jsx(q.Download,{size:14}),children:e("common.actions.download_data")}),s.jsx(o.Menu.Item,{onClick:r,icon:s.jsx(k.IconCamera,{size:14}),children:e("common.actions.download_screenshot")}),u&&s.jsx(o.Menu.Item,{onClick:c,icon:s.jsx(q.ArrowsMaximize,{size:14}),children:e("common.actions.enter_fullscreen")})]})]})}):null});function vS(t){return t.style.border.enabled?{}:{border:"1px dashed transparent"}}const fi=S.observer(({panel:t,view:e})=>{const n=vS(t);return s.jsx(rc,{panel:t,panelStyle:n,dropdownContent:s.jsx(bS,{view:e})})}),_S={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},ac=S.observer(function({view:e,panel:n,exitFullScreen:r}){return s.jsx(o.Modal,{opened:!0,fullScreen:!0,onClose:r,title:s.jsx(o.Button,{color:"blue",size:"xs",onClick:r,leftIcon:s.jsx(q.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:_S,children:s.jsx(o.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:s.jsx(fi,{view:e,panel:n})})})});function oc(t,e,n){const{panels:r}=de(),i=t.id==="Main",[a,l]=m.useState(()=>i&&r.findByID(e)?e:null),c=m.useCallback(p=>{l(p),i&&n(p)},[i,n]),u=m.useCallback(()=>{l(null),i&&n("")},[i,n]),d=a?r.findByID(a):null;return{viewPanelInFullScreen:c,exitFullScreen:u,inFullScreen:!!d,fullScreenPanel:d}}const nI="",jS=m.forwardRef(({h:t},e)=>s.jsx(o.ActionIcon,{ref:e,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:5,right:t>38?5:20,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:s.jsx(q.ArrowsMove,{size:16})})),wS=m.forwardRef(({handleAxis:t,...e},n)=>s.jsx(o.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...e,children:s.jsx(q.ChevronDownRight,{size:16})})),CS=wn.WidthProvider(wn.Responsive),SS=S.observer(({view:t,className:e="layout"})=>{const r=W().layouts,i=r.items(t.panelIDs),a=r.gridLayouts(t.panelIDs),l=(d,h,p,g)=>{console.log("🔴 onResize",d),p.h<30&&(p.h=30,g.h=30),p.w<4&&(p.w=4,g.w=4)},c=(d,h,p)=>{console.log("🔴 onResizeStop",{layouts:d,oldItem:h,newItem:p}),r.updateCurrentLayoutItem(p)},u=(d,h,p)=>{console.log("🔴 onDragStop",{layouts:d,oldItem:h,newItem:p}),r.updateCurrentLayoutItem(p)};return s.jsx(CS,{className:`dashboard-layout ${e}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:r.cols,layouts:a,draggableHandle:".react-grid-customDragHandle",resizeHandle:s.jsx(wS,{}),onResize:l,breakpoints:r.breakpoints,onBreakpointChange:r.setCurrentBreakpoint,onResizeStop:c,onDragStop:u,width:r.currentLayoutPreviewWidth,children:i.map(d=>s.jsxs("div",{"data-grid":d.layoutProperies,className:"panel-grid-item",children:[s.jsx(jS,{h:d.h}),s.jsx(ic,{view:t,panel:d.panel})]},d.id))})}),kS=wn.WidthProvider(wn.Responsive),TS=S.observer(({view:t,className:e="layout"})=>{const n=de(),r=n.layouts.items(t.panelIDs),i=n.layouts.gridLayouts(t.panelIDs);return s.jsx(kS,{className:`dashboard-layout ${e}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:n.layouts.cols,layouts:i,breakpoints:n.layouts.breakpoints,onBreakpointChange:n.layouts.setCurrentBreakpoint,children:r.map(a=>s.jsx("div",{"data-grid":a.layoutProperies,className:"panel-grid-item",children:s.jsx(fi,{view:t,panel:a.panel})},a.id))})});function gi(t){const e=m.useRef(null);return{ref:e,downloadScreenshot:()=>{var i;const r=(i=e.current)==null?void 0:i.querySelector(".react-grid-layout");r&&t.downloadScreenshot(r)}}}const DS=S.observer(({downloadScreenshot:t})=>{const{t:e}=_.useTranslation(),[n,{setTrue:r,setFalse:i}]=N.useBoolean(!1),a=Ca(),l=de(),c=()=>{const u=JSON.stringify(l.contentJSON,null,2),d=`${a.name}__${l.name}`;Ut(d,u)};return s.jsxs(o.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[s.jsx(o.Menu.Target,{children:s.jsx(o.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:s.jsx(o.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:r,onMouseLeave:i,sx:{opacity:n?1:.6,transform:`translateX(${n?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:s.jsx(k.IconShare3,{size:"1rem"})})})}),s.jsxs(o.Menu.Dropdown,{children:[s.jsx(o.Menu.Item,{icon:s.jsx(k.IconCamera,{size:14}),onClick:t,children:e("common.actions.download_screenshot")}),s.jsx(o.Menu.Divider,{}),s.jsx(o.Menu.Item,{icon:s.jsx(k.IconDownload,{size:14}),onClick:l.queries.downloadAllData,children:e("common.actions.download_data")}),s.jsx(o.Menu.Item,{icon:s.jsx(k.IconCode,{size:14}),onClick:c,children:e("common.actions.download_schema")})]})]})}),lc=S.observer(({children:t,view:e,sx:n={}})=>{const{ref:r,downloadScreenshot:i}=gi(e);return s.jsxs(s.Fragment,{children:[s.jsx(o.Box,{ref:r,pt:10,pb:10,sx:n,children:t}),s.jsx(DS,{downloadScreenshot:i})]})}),cc=S.observer(({downloadScreenshot:t})=>s.jsx(o.ActionIcon,{className:"download-screenshot-button",color:"blue",onClick:t,children:s.jsx(k.IconCamera,{size:14})})),zS=S.observer(({children:t,view:e})=>{const n=de(),r=e.config,i=n.views.visibleViewIDs.includes(e.id),a=()=>n.views.rmVisibleViewID(e.id),{ref:l,downloadScreenshot:c}=gi(e);return s.jsx(o.Modal,{size:r.width,centered:!0,opened:i,onClose:a,withCloseButton:!1,title:s.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[s.jsx(o.Box,{children:r.custom_modal_title.value}),s.jsx(cc,{downloadScreenshot:c})]}),trapFocus:!0,onDragStart:u=>{u.stopPropagation()},styles:{root:{position:"fixed",zIndex:200,inset:0},overlay:{zIndex:"unset"},inner:{zIndex:"unset",padding:"0 !important"},content:{border:"1px solid #efefef",maxHeight:"unset !important",overflow:"hidden"},body:{maxHeight:r.height,overflow:"auto",position:"relative",paddingBottom:10},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:s.jsx(o.Box,{ref:l,children:t})})}),IS=t=>t.color?{"&[data-active], &[data-active]:hover":{borderColor:t.color?t.color:"..."}}:{},MS=S.observer(({view:t})=>{const e=de(),n=t.config;return s.jsxs(o.Tabs,{className:"render-view-tabs",variant:n.variant,orientation:n.orientation,value:t.tab,onTabChange:t.setTab,styles:{root:{height:"100%",overflow:n.orientation==="horizontal"?"hidden":"auto"},panel:{padding:n.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[s.jsx(o.Tabs.List,{grow:n.grow,children:n.tabsInOrder.map(r=>s.jsx(o.Tabs.Tab,{value:r.id,sx:IS(r),disabled:!r.view_id,children:r.name??r.id},r.id))}),n.tabsInOrder.map(r=>{const i=e.views.findByID(r.view_id);return i?s.jsx(o.Tabs.Panel,{value:r.id,children:s.jsx(cs,{view:i})},r.id):null})]})}),ES=S.observer(({view:t,children:e})=>{switch(t.type){case L.Modal:return s.jsx(zS,{view:t,children:e});case L.Tabs:return s.jsx(MS,{view:t});case L.Division:default:return s.jsx(lc,{view:t,children:e})}}),AS=S.observer(({children:t,view:e})=>{const r=W().layouts,[i,a]=ie.useResizeObserver();return m.useEffect(()=>{r.setCurrentLayoutWrapperWidth(a.width)},[a.width]),s.jsx(o.Box,{sx:{height:"100%"},ref:i,children:s.jsx(o.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:r.currentLayoutPreviewWidth??"100%",transform:`scale(${r.divisionPreviewScale})`,transformOrigin:"0 0"},children:s.jsx(lc,{view:e,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:t})})})});function uc(t){return t.replace(/(vw|vh)/,"%")}const PS=S.observer(({children:t,view:e})=>{const n=e.config,{width:r,height:i}=m.useMemo(()=>({width:uc(n.width),height:uc(n.height)}),[n.width,n.height]),{ref:a,downloadScreenshot:l}=gi(e);return s.jsx(o.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:s.jsx(o.Modal,{size:n.width,opened:!0,onClose:x.noop,withCloseButton:!1,title:s.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[s.jsx(o.Box,{children:n.custom_modal_title.value}),s.jsx(cc,{downloadScreenshot:l})]}),trapFocus:!0,onDragStart:c=>{c.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},inner:{position:"relative",top:"50%",left:"50%",right:"unset",bottom:"unset",transform:"translate(-50%, -50%)",padding:"0 !important",width:r,height:i,maxHeight:i},content:{border:"1px solid #efefef",height:"100%"},body:{maxHeight:"calc(100% - 48px)",overflow:"auto"},header:{padding:0},title:{flexGrow:1}},withinPortal:!1,transitionProps:{duration:0},children:s.jsx(o.Box,{ref:a,children:t})})})}),$S=({variant:t,orientation:e})=>{const n={root:{height:"100%",overflow:"hidden"},tabsList:{backgroundColor:"white"},tab:{},panel:{padding:"16px"}};return t==="pills"&&e==="horizontal"&&(n.tab.paddingTop="6px",n.tab.paddingBottom="6px"),e==="vertical"&&(n.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},n.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),n},qS=t=>t.color?{"&[data-active], &[data-active]:hover":{borderColor:t.color?t.color:"..."}}:{},LS=S.observer(({view:t})=>{const{t:e}=_.useTranslation(),n=Be.useModals(),r=W(),i=m.useMemo(()=>r.views.options.filter(u=>u.type===L.Division),[t.id,r.views.options]),a=t.config,l=u=>n.openConfirmModal({title:`${e("view.component.tabs.tab.delete")}?`,labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{a.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),c=a.tabs.length===0;return s.jsxs(o.Tabs,{className:"preview-view-tabs",variant:a.variant,orientation:a.orientation,value:t.tab,onTabChange:t.setTab,styles:$S(a),children:[s.jsxs(o.Tabs.List,{grow:a.grow,children:[a.tabsInOrder.map(u=>s.jsx(o.Tabs.Tab,{value:u.id,sx:qS(u),children:u.name??u.id},u.id)),s.jsx(o.Tabs.Tab,{onClick:a.addTab,value:"add",className:"add-a-tab",children:s.jsx(q.Plus,{size:18,color:"#228be6"})})]}),a.tabsInOrder.map((u,d)=>{const h=r.views.findByID(u.view_id);return s.jsxs(o.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[s.jsxs(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[s.jsx(o.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),s.jsxs(o.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[s.jsx(o.TextInput,{label:e("view.component.tabs.tab.name"),required:!0,value:u.name,onChange:p=>u.setName(p.currentTarget.value)}),s.jsx(o.Select,{label:"View",value:u.view_id,onChange:u.setViewID,data:i}),s.jsx(o.NumberInput,{label:e("view.component.tabs.tab.order"),required:!0,value:u.order,onChange:p=>u.setOrder(p||0),min:0,max:1e3,step:1}),s.jsx(o.ColorInput,{label:e("view.component.tabs.tab.color"),value:u.color,onChange:u.setColor,disabled:a.variant!=="default"}),h&&s.jsx(o.Button,{mt:20,variant:"gradient",leftIcon:s.jsx(k.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>r.views.setIDOfVIE(h.id),children:e("view.component.tabs.tab.switch_to_view",{name:h.name})}),s.jsx(o.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>l(d),disabled:c,leftIcon:s.jsx(k.IconTrash,{size:14}),children:e("view.component.tabs.tab.delete")})]})]}),h&&s.jsx(cs,{view:h})]},u.id)})]})}),BS=S.observer(({view:t,children:e})=>{switch(t.type){case L.Modal:return s.jsx(PS,{view:t,children:e});case L.Tabs:return s.jsx(LS,{view:t});case L.Division:default:return s.jsx(AS,{view:t,children:e})}}),dc=S.observer(function({view:e}){const r=W().layouts.divisionPreviewScale!==1;return s.jsx(is.Provider,{value:{viewPanelInFullScreen:x.noop,inFullScreen:!1},children:s.jsx(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:r?"transparent":"#efefef"},children:s.jsx(BS,{view:e,children:s.jsxs(o.Box,{sx:{position:"relative"},children:[s.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:s.jsx(gl,{view:e})}),s.jsx(SS,{view:e})]})})})})}),cs=S.observer(function({view:e}){const{fullScreenPanelID:n,setFullScreenPanelID:r}=Ma(),{viewPanelInFullScreen:i,exitFullScreen:a,inFullScreen:l,fullScreenPanel:c}=oc(e,n,r);return s.jsx(is.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:l},children:s.jsxs(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:e.type===L.Modal?"0 !important":"100%"},children:[l&&s.jsx(ac,{view:e,panel:c,exitFullScreen:a}),s.jsx(ES,{view:e,children:s.jsxs(o.Box,{sx:{position:"relative"},children:[!l&&s.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:s.jsx(gl,{view:e})}),!l&&s.jsx(TS,{view:e})]})})]})})});var hc=(t=>(t.Use="use",t.Edit="edit",t))(hc||{});const OS={[L.Division]:"Division",[L.Tabs]:"Tabs",[L.Modal]:"Modal"},pc={[L.Division]:"rgba(255, 0, 0, 0.2)",[L.Modal]:"rgba(0, 0, 0, 0.2)",[L.Tabs]:"rgba(255, 200, 100, 0.4)"},VS={[L.Division]:"#ff4000",[L.Modal]:"#000",[L.Tabs]:"#ffad18"};function NS(t,e,n){f.addDisposer(t,f.addMiddleware(t,(r,i)=>{i(r,()=>{f.getType(r.context)===e&&r.type==="action"&&n(r.name,r.context)})}))}const mc=f.types.compose("FiltersModel",oi,f.types.model("FiltersModel",{previewValues:f.types.optional(f.types.frozen(),{})})).views(t=>({get idSet(){return new Set(t.current.map(e=>e.id))},get keySet(){return new Set(t.current.map(e=>e.key))},get options(){return t.current.map(e=>({label:e.label??e.id,value:e.id,_type:"filter"}))},get selects(){return t.current.filter(e=>e.type===pe.Select).map(e=>({label:e.label??e.id,value:e.id}))},get keyLabelOptions(){return t.current.map(e=>({label:e.label??e.key,value:e.key}))},get sortedList(){return x.sortBy(t.current,e=>e.label.toLowerCase())}})).actions(t=>({replace(e){t.current=f.cast(e)},append(e){t.current.push(e)},appendMultiple(e){if(e.length===0)return;const n=e.filter(r=>!t.idSet.has(r.id));t.current.push(...n)},remove(e){t.current.splice(e,1)},removeByID(e){const n=t.current.findIndex(r=>r.id===e);n>=0&&t.current.splice(n,1)},updatePreviewValues(e){t.previewValues=e}})).actions(t=>{function e(){NS(t.current,Jr,(n,r)=>{if(n==="setType"){const i=Gl(r.config.default_value,r.config);t.setValueByKey(r.key,i),t.updatePreviewValues({...t.previewValues,[r.key]:i})}})}return{afterCreate(){e()}}}),fc=ci.views(t=>({get canPreviewData(){return t.isTransform?t.dep_query_ids.length>0&&!!t.pre_process:!!t.datasource},get guideToPreviewData(){return t.isTransform?"Need to complete settings in Transform tab":"Need to pick a Data Source first"}})),gc=f.types.compose("QueriesModel",ui,f.types.model({current:f.types.optional(f.types.array(fc),[])})).views(t=>({get options(){const e=t.current.map(n=>({value:n.id,label:n.name,_type:"query"}));return x.sortBy(e,n=>n.label.toLowerCase())},get optionsWithoutTransform(){const e=t.current.filter(n=>n.type!==ce.Transform).map(n=>({value:n.id,label:n.name,_type:"query"}));return x.sortBy(e,n=>n.label.toLowerCase())},get sortedList(){return x.sortBy(t.current,e=>e.name.toLowerCase())}})).actions(t=>({replace(e){t.current=f.cast(e)},append(e){t.current.push(e)},appendMultiple(e){if(e.length===0)return;const n=e.filter(r=>!t.idSet.has(r.id));t.current.push(...n)},remove(e){t.current.splice(e,1)},replaceByIndex(e,n){t.current.splice(e,1,n)},removeQuery(e){const n=t.current.find(r=>r.id===e);n&&(f.detach(n),t.current.remove(n))},removeQueries(e){const n=new Set(e);t.current.forEach(i=>{n.has(i.id)&&f.detach(i)});const r=[...t.current];x.remove(r,i=>n.has(i.id)),t.current=f.cast(r)}})),xc=hi.views(t=>({get sortedList(){return x.sortBy(t.current,e=>e.key.toLowerCase())},get options(){const e=t.current.map(n=>({label:n.key,value:n.key,_type:"sql_snippet"}));return x.sortBy(e,n=>n.label.toLowerCase())}})).actions(t=>({replace(e){t.current=f.cast(e)},append(e){t.current.push(e)},appendMultiple(e){if(e.length===0)return;const n=e.filter(r=>!t.keySet.has(r.key));t.current.push(...n)},remove(e){t.current.splice(e,1)},removeByKey(e){const n=t.current.findIndex(r=>r.key===e);n>=0&&t.current.splice(n,1)},removeByKeys(e){const n=new Set(e);t.current.forEach(i=>{n.has(i.key)&&f.detach(i)});const r=[...t.current];x.remove(r,i=>n.has(i.key)),t.current=f.cast(r)},replaceByIndex(e,n){t.current.splice(e,1,n)}})),FS=f.types.model({data:f.types.optional(f.types.frozen(),[]),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).views(t=>({get loading(){return t.state==="loading"},get empty(){return t.data.length===0}})),GS=f.types.model({data:f.types.optional(f.types.frozen(),[]),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).views(t=>({get loading(){return t.state==="loading"},get empty(){return t.data.length===0}})),WS=f.types.model({page:f.types.optional(f.types.number,1),limit:f.types.optional(f.types.number,20),data:f.types.optional(f.types.frozen(),[]),total:f.types.optional(f.types.number,0),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).views(t=>({get keywords(){return f.getParent(t,1)},get keywordString(){const{table_name:e,table_schema:n}=f.getParent(t,1);return`${n}||${e}`}})).views(t=>({get loading(){return t.state==="loading"},get empty(){return t.data.length===0},get maxPage(){return Math.ceil(t.total/t.limit)},get offset(){return(t.page-1)*t.limit},get countSql(){const{table_name:e,table_schema:n}=t.keywords;return`
|
|
446
446
|
SELECT count(*) AS total
|
|
447
447
|
FROM ${n}.${e}
|
|
448
|
-
`}})).actions(t=>({setPage(e){t.page=e},resetPage(){t.page=1},setLimit(e){t.limit=e}})).actions(t=>({afterCreate(){f.addDisposer(t,U.reaction(()=>t.keywordString,t.resetPage,{fireImmediately:!1,delay:0})),f.addDisposer(t,U.reaction(()=>t.limit,t.resetPage,{fireImmediately:!1,delay:0}))}})),QS=f.types.model({data:f.types.optional(f.types.frozen(),{}),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).views(t=>({get loading(){return t.state==="loading"},get empty(){return Object.keys(t.data).length===0}})),RS=f.types.compose("DataSourceModel",ei,f.types.model({tables:f.types.optional(QS,{}),columns:f.types.optional(FS,{}),tableData:f.types.optional(WS,{}),indexes:f.types.optional(GS,{}),table_schema:f.types.optional(f.types.string,""),table_name:f.types.optional(f.types.string,"")})).views(t=>({get sqlDataSourceType(){return t.type},get reloadConditionString(){const{type:e,table_name:n,table_schema:r}=t;return`${e};${n};${r}`}})).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(t=>({setKeywords(e,n){t.table_schema=e,t.table_name=n}})).actions(t=>({initKeywords(){if(t.tables.empty)return;const e=Object.keys(t.tables.data)[0],n=t.tables.data[e][0].table_name;t.setKeywords(e,n)}})).actions(t=>{const e=f.flow(function*(){var n;(n=t.controllers.tables)==null||n.abort(),t.controllers.tables=new AbortController,t.tables.state="loading";try{const r=yield*f.toGenerator(et.structure(t.controllers.tables.signal)({query_type:"TABLES",type:t.sqlDataSourceType,key:t.key,table_schema:"",table_name:""},{params:{query_type:"TABLES"}}));t.tables.data=x.groupBy(r,"table_schema"),t.tables.state="idle",t.tables.error=null,t.initKeywords()}catch(r){if(!at.isCancel(r)){t.tables.data={};const i=x.get(r,"message","unkown error");t.tables.error=x.get(r,"response.data.detail.message",i),t.tables.state="error"}}});return{loadTables:e,loadTablesIfEmpty(){t.tables.empty&&e()},loadColumns:f.flow(function*(){var n;(n=t.controllers.columns)==null||n.abort(),t.controllers.columns=new AbortController,t.columns.state="loading";try{t.columns.data=yield*f.toGenerator(et.structure(t.controllers.columns.signal)({query_type:"COLUMNS",type:t.sqlDataSourceType,key:t.key,table_schema:t.table_schema,table_name:t.table_name},{params:{query_type:"COLUMNS"}})),t.columns.state="idle",t.columns.error=null}catch(r){if(at.isCancel(r))t.columns.state="idle",t.columns.error=null;else{t.columns.data=[];const i=x.get(r,"message","unkown error");t.columns.error=x.get(r,"response.data.detail.message",i),t.columns.state="error"}}}),loadIndexes:f.flow(function*(){var n;(n=t.controllers.indexes)==null||n.abort(),t.controllers.indexes=new AbortController,t.indexes.state="loading";try{t.indexes.data=yield*f.toGenerator(et.structure(t.controllers.indexes.signal)({query_type:"INDEXES",type:t.sqlDataSourceType,key:t.key,table_schema:t.table_schema,table_name:t.table_name},{params:{query_type:"INDEXES"}})),t.indexes.state="idle",t.indexes.error=null}catch(r){if(at.isCancel(r))t.indexes.state="idle",t.indexes.error=null;else{t.indexes.data=[];const i=x.get(r,"message","unkown error");t.indexes.error=x.get(r,"response.data.detail.message",i),t.indexes.state="error"}}}),loadTableData:f.flow(function*(){var r;(r=t.controllers.tableData)==null||r.abort(),t.controllers.tableData=new AbortController;const n=t.tableData;n.state="loading";try{n.data=yield*f.toGenerator(et.structure(t.controllers.tableData.signal)({query_type:"DATA",type:t.sqlDataSourceType,key:t.key,table_schema:t.table_schema,table_name:t.table_name,limit:n.limit,offset:n.offset},{params:{query_type:"DATA"}}));const[{total:i}]=yield*f.toGenerator(et.structure(t.controllers.tableData.signal)({query_type:"COUNT",type:t.sqlDataSourceType,key:t.key,table_schema:t.table_schema,table_name:t.table_name},{params:{query_type:"COUNT"}}));n.total=Number(i),n.state="idle",n.error=null}catch(i){if(at.isCancel(i))n.state="idle",n.error=null;else{n.data=[];const a=x.get(i,"message","unkown error");n.error=x.get(i,"response.data.detail.message",a),n.state="error"}}})}}).actions(t=>({afterCreate(){f.addDisposer(t,U.reaction(()=>t.reloadConditionString,t.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(t=>({afterCreate(){f.addDisposer(t,U.reaction(()=>t.reloadConditionString,t.loadIndexes,{fireImmediately:!1,delay:500})),f.addDisposer(t,U.reaction(()=>`${t.reloadConditionString};limit:${t.tableData.limit};offset:${t.tableData.offset}`,t.loadTableData,{fireImmediately:!1,delay:0}))}})),YS=f.types.model("DataSourcesModel",{list:f.types.optional(f.types.array(RS),[])}).views(t=>({find({type:e,key:n}){return t.list.find(r=>r.key===n&&r.type===e)},get options(){return t.list.map(e=>({value:e.key,label:e.key}))}})).actions(t=>({replace(e){t.list.length=0,t.list.push(...e)}}));function At(t){return{label:t,value:t,_type:"ACTION",_action_type:t,Icon:null,children:null}}function US(t){switch(t._type){case"GROUP":case"ACTION":return null;case"query_variables":return["_QUERY_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",t.value];case"sql_snippet":return["_SQL_SNIPPETS_",t.value];case"query":return["_QUERIES_",t.value];case"view":return["_VIEWS_",t.value];case"panel":return t.parentID?["_VIEWS_",t.parentID,"_PANELS_",t.value]:(console.error("[getPathFromOption] parentID is required"),null)}}const KS=f.types.model("EditorModel",{path:f.types.optional(f.types.frozen(),[]),settings_open:f.types.optional(f.types.boolean,!1)}).views(t=>({get navOptions(){const{content:e}=f.getRoot(t),{filters:n,views:r,sqlSnippets:i,queries:a}=e;return[{label:"query_variable.labels",value:"_QUERY_VARS_",_type:"query_variables",Icon:k.IconVariable},{label:"mock_context.label",value:"_MOCK_CONTEXT_",Icon:k.IconCodeDots,_type:"mock_context"},{label:"filter.labels",value:"_FILTERS_",Icon:k.IconFilter,children:[At("_FILTERS_SETTINGS_"),...n.options,At("_Add_A_Filter_")],_type:"GROUP"},{label:"sql_snippet.labels",value:"_SQL_SNIPPETS_",Icon:k.IconCopy,children:[At("_SQL_SNIPPETS_SETTINGS_"),...i.options,At("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"query.labels",value:"_QUERIES_",Icon:k.IconDatabase,children:[At("_QUERIES_SETTINGS_"),...a.options,At("_Add_A_QUERY_")],_type:"GROUP"},{label:"view.labels",value:"_VIEWS_",Icon:k.IconBoxMultiple,children:[...r.editorOptions,At("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(e,n){return e.length===0?!1:e[e.length-1]===n.value},isOptionOpened(e){const{path:n}=t;return n.length===0||!e.children||e.children.length===0?!1:n.includes(e.value)}})).actions(t=>({setPath(e){t.path=e},setSettingsOpen(e){t.settings_open=e}})).actions(t=>({open(e){t.setPath(e),t.setSettingsOpen(!0)},close(){t.setSettingsOpen(!1)},navigate(e){const n=US(e);n&&t.setPath(n)}})),JS=f.types.compose("LayoutsModel",di,f.types.model({currentLayoutWrapperWidth:f.types.optional(f.types.number,0)})).views(t=>({get divisionPreviewScale(){const e=t.currentLayoutPreviewWidth,n=t.currentLayoutWrapperWidth;return!e||!n||e<=n?1:n/e}})).actions(t=>({addALayoutItem(e){t.list.forEach(n=>{n.addNewLayout(e)})},duplicateLayoutItemsByPanelID(e,n){t.list.forEach(r=>{const i=r.findByPanelID(e);if(!i){console.error(`Can't find a layout item by panelID[${e}] in layoutSet[${r.name}]`);return}r.list.push({...i,id:vt.v4(),panelID:n,y:1/0})})},removeByPanelID(e){t.list.forEach(n=>{n.removeByPanelID(e)})},setCurrentLayoutWrapperWidth(e){t.currentLayoutWrapperWidth=e},addALayoutSet(e,n,r){const i=t.basisLayoutSet,a={id:e,name:n,breakpoint:r,list:i.json.list.map(l=>({...l,id:vt.v4()}))};t.list.push(a)},updateLayoutSetsInfo(e){const n=x.keyBy(t.list,"id");e.forEach(a=>{const l=n[a.id];if(l){l.setName(a.name),l.setBreakpoint(a.breakpoint),delete n[a.id];return}this.addALayoutSet(a.id,a.name,a.breakpoint)});const r=new Set(Object.keys(n)),i=r.size>0;r.forEach(a=>{const l=t.list.findIndex(c=>c.id===a);t.list.splice(l,1)}),i&&t.setCurrentBreakpoint("basis")},updateCurrentLayoutItem(e){t.currentLayoutSet.updateLayoutItem(e)},append(e){t.list.push(e)},appendMultiple(e){e.length!==0&&t.list.push(...e)},remove(e){t.list.splice(e,1)},removeByID(e){const n=t.list.findIndex(r=>r.id===e);n!==-1&&t.list.splice(n,1)},removeByIDs(e){e.forEach(n=>{this.removeByID(n)})}})),yc=ii.views(t=>({get realDataFieldOptions(){return t.queryIDs.length===0?[]:t.queries.map(e=>{const n=e.data;return n.length===0?[]:Object.keys(n[0]).map(i=>({label:i,value:`${e.id}.${i}`,group:e.name,disabled:!1}))}).flat()},get realQueryOptions(){return t.queryIDs.length===0?[]:t.queries.map(e=>({label:e.name,value:e.id,disabled:!1}))},queryOptions(e,n){const r=[...this.realQueryOptions];return e&&!r.find(i=>i.value===e)&&r.unshift({label:e,value:e,disabled:!0}),n&&r.unshift({label:"unset",value:"",disabled:!1}),r},dataFieldOptions(e,n,r){let i=[...this.realDataFieldOptions];if(r&&(i=i.filter(a=>a.group===r)),e&&!i.find(a=>a.value===e)){const a=E(e),l=t.queryByID(a.queryID);i.unshift({label:a.columnKey,value:e,group:l?l.name:a.queryID,disabled:!0})}return n&&i.unshift({label:"unset",value:"",group:"",disabled:!1}),i},explainDataKey(e){const{queryID:n,columnKey:r}=E(e),i=t.queries.find(a=>a.id===n);return i?{queryID:n,queryName:i.name,columnKey:r}:{queryID:n,queryName:null,columnKey:r}}})).actions(t=>({removeSelf(){f.getParent(t,2).removeByID(t.id)}})).actions(t=>({moveToView(e,n){f.getRoot(t).content.views.findByID(e).removePanelID(t.id),f.getRoot(t).content.views.findByID(n).appendPanelID(t.id),f.getRoot(t).editor.setPath(["_VIEWS_",n,"_PANELS_",t.id])}})),bc=f.types.compose("PanelsModel",ai,f.types.model({list:f.types.optional(f.types.array(yc),[])})).views(t=>({get contentModel(){return f.getRoot(t).content},editorOptions(e,n){const r=t.panelsByIDs(n);r.length!==n.length&&console.warn(`Unfulfilled panels for View[${e}]`);const i=r.map(l=>({label:l.name,value:l.id,_type:"panel",parentID:e})),a="_Add_A_PANEL_";return i.push({label:a,value:a,_type:"ACTION",_action_type:a,parentID:e,Icon:null,children:null}),i}})).actions(t=>({replace(e){t.list=f.castToSnapshot(e)},append(e){t.list.push(e)},appendMultiple(e){e.length!==0&&t.list.push(...e)},remove(e){t.list.splice(e,1)},removeByID(e){const n=t.list.findIndex(r=>r.id===e);n!==-1&&t.list.splice(n,1)},removeByIDs(e){e.forEach(n=>{this.removeByID(n)})},duplicateByID(e){const n=t.list.find(i=>i.id===e);if(!n){console.error(new Error(`[duplicate panel] Can't find a panel by id[${e}]`));return}const r=new Date().getTime().toString();return t.list.push({...n.json,id:r,title:{...n.json.title}}),t.contentModel.layouts.duplicateLayoutItemsByPanelID(n.id,r),r},replaceByIndex(e,n){t.list.splice(e,1,n)}})),XS=si.actions(t=>({getSchema(){const e=t.json,n=[],r=[];t.panels.forEach(l=>{const c=l.getSchema();n.push(c.panel),c.queries.length>0&&r.push(...c.queries)});const i=t.contentModel.layouts.jsonByPanelIDSet(new Set(t.panelIDs));return{views:[e],panels:n,definition:{queries:x.uniqBy(r,l=>l.id)},layouts:i,version:mt}},downloadSchema(){if(t.type===L.Tabs){console.error(new Error("Please choose a tab first"));return}const e=JSON.stringify(this.getSchema(),null,2),n=t.name;Ut(n,e)}})),vc=f.types.compose("ViewsModel",ri,f.types.model({current:f.types.optional(f.types.array(XS),[]),idOfVIE:f.types.string})).views(t=>({get isVIETheFirstView(){return t.current.length===0||!t.idOfVIE?!1:t.current[0].id===t.idOfVIE},get VIE(){return t.current.find(({id:e})=>e===t.idOfVIE)},get options(){return t.current.map(e=>({label:e.name,value:e.id,type:e.type}))},get editorOptions(){const e=f.getRoot(t).content.panels;return t.current.map(n=>({label:n.name,value:n.id,_type:"view",children:e.editorOptions(n.id,n.panelIDs)}))}})).actions(t=>({setIDOfVIE(e){t.idOfVIE=e,t.visibleViewIDs.length=0,t.visibleViewIDs.push(e)},replace(e){t.current.replace(e)},addANewView(e,n,r,i){t.current.push({id:e,name:n,type:r,config:i,panelIDs:[]})},append(e){t.current.push(e)},appendMultiple(e){e.length!==0&&t.current.push(...e)},remove(e){t.current.splice(e,1)},removeByID(e){const n=t.current.findIndex(a=>a.id===e);if(n===-1)return;const r=t.current[n];f.getRoot(t).content.panels.removeByIDs(r.panelIDs),t.current.splice(n,1)},replaceByIndex(e,n){t.current.splice(e,1,n)},addARandomNewView(){const e=new Date().getTime().toString();this.addANewView(e,L.Division,L.Division,{_name:L.Division}),this.setIDOfVIE(e)},removeVIE(){t.current.length!==1&&(this.removeByID(t.idOfVIE),this.setIDOfVIE(t.current[0].id))}}));function xi(t){const e=t.length>0?[t[0].id]:[],n=t.length>0?t[0].id:"";return{current:t.map(i=>{const{_name:a=i.type}=i.config;return{...i,config:{...i.config,_name:a},panelIDs:i.panelIDs}}),visibleViewIDs:e,idOfVIE:n}}const ZS=f.types.model({id:f.types.string,name:f.types.string,dashboard_id:f.types.string,create_time:f.types.string,update_time:f.types.string,version:f.types.string,filters:mc,queries:gc,sqlSnippets:xc,views:vc,panels:bc,layouts:JS,mock_context:Vr,origin:f.types.maybe(f.types.frozen())}).views(t=>({get json(){return{id:t.id,name:t.name,create_time:t.create_time,update_time:t.update_time,dashboard_id:t.dashboard_id,content:{views:t.views.json,panels:t.panels.json,filters:t.filters.json,version:t.version,layouts:t.layouts.json,definition:{queries:t.queries.json,sqlSnippets:t.sqlSnippets.json,mock_context:t.mock_context.current}}}},get contentJSON(){return this.json.content},get filtersChanged(){const e="filters.current";return!x.isEqual(f.getSnapshot(x.get(t,e)),x.get(t.origin,e))},get queriesChanged(){const e="queries.current",n=f.getSnapshot(x.get(t,e)).map(r=>x.pick(r,["id","name","key","type","sql","run_by","react_to","pre_process","post_process","dep_query_ids"]));return!x.isEqual(n,x.get(t.origin,e))},get sqlSnippetsChanged(){const e="sqlSnippets.current";return!x.isEqual(f.getSnapshot(x.get(t,e)),x.get(t.origin,e))},get viewsChanged(){const e="views.current";return!x.isEqual(t.views.json,x.get(t.origin,e))},get panelsChanged(){const e="panels.list";return!x.isEqual(f.getSnapshot(x.get(t,e)),x.get(t.origin,e))},get layoutsChanged(){const e="layouts.list";return!x.isEqual(f.getSnapshot(x.get(t,e)),x.get(t.origin,e))},get mockContextChanged(){const e="mock_context.current";return!x.isEqual(x.get(t,e),x.get(t.origin,e))},get context(){const e=f.getParent(t).context.current;return{...t.mock_context.current,...e}},get payloadForSQL(){const e=f.getParent(t).globalSQLSnippets,n={context:this.context,filters:t.filters.values};return{...n,sql_snippets:gn(t.sqlSnippets.current,"key","value",n),global_sql_snippets:gn(e.list,"id","content",n)}},get payloadForViz(){const e=f.getParent(t).context.current;return{context:{...t.mock_context.current,...e},filters:t.filters.values}},get dashboardState(){return Ts(this.payloadForSQL)},getAdditionalQueryInfo(e){return{content_id:t.id,query_id:e,params:this.dashboardState}},get changed(){return this.filtersChanged||this.queriesChanged||this.sqlSnippetsChanged||this.viewsChanged||this.panelsChanged||this.layoutsChanged||this.mockContextChanged},get data(){return t.queries.current.map(({id:n,data:r})=>({id:n,data:r})).reduce((n,r)=>(n[r.id]=r.data,n),{})},getDataStuffByID(e){const n=t.queries.findByID(e);return n?{data:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).views(t=>({get queriesUsage(){const e=t.panels.idMap,n=[];t.views.current.forEach(i=>{i.panelIDs.forEach(a=>{const l=e.get(a);if(!l)return;const c="panel",u=l.name,d=[{id:i.id,label:i.name}];l.queryIDs.forEach(h=>{n.push({id:a,queryID:h,type:c,label:u,views:d})})})});const r=t.views.idMap;return t.filters.current.filter(i=>!!x.get(i,"config.options_query_id")).forEach(i=>{n.push({type:"filter",id:i.id,queryID:x.get(i,"config.options_query_id"),label:i.label,views:i.visibleInViewsIDs.map(a=>{var l;return{id:a,label:((l=r.get(a))==null?void 0:l.name)??a}})})}),x.groupBy(n,"queryID")},get hasUnusedQueries(){return t.queries.current.length>Object.keys(this.queriesUsage).length},findQueryUsage(e){return this.queriesUsage[e]??[]},get sqlSnippetsUsage(){const e=[];return t.queries.current.forEach(n=>{if(!n.typedAsSQL)return;x.uniq(n.sql.match(zn.sqlSnippet)).forEach(i=>{e.push({queryID:n.id,sqlSnippetKey:i,queryName:n.name})})}),x.groupBy(e,"sqlSnippetKey")},get hasUnusedSQLSnippets(){return t.sqlSnippets.current.length>Object.keys(this.sqlSnippetsUsage).length},findSQLSnippetUsage(e){return this.sqlSnippetsUsage[e]??[]}})).actions(t=>({removeUnusedQueries(){const e=new Set(Object.keys(t.queriesUsage)),n=t.queries.current.filter(r=>!e.has(r.id)).map(r=>r.id);t.queries.removeQueries(n)},removeUnusedSQLSnippets(){const e=new Set(Object.keys(t.sqlSnippetsUsage)),n=t.sqlSnippets.current.filter(r=>!e.has(r.key)).map(r=>r.key);t.sqlSnippets.removeByKeys(n)},duplicatePanelByID(e,n){var i;const r=t.panels.duplicateByID(e);r&&((i=t.views.findByID(n))==null||i.appendPanelID(r))},removePanelByID(e,n){var r;t.panels.removeByID(e),t.layouts.removeByPanelID(e),(r=t.views.findByID(n))==null||r.removePanelID(e)},addANewPanel(e){var r;const n=vt.v4();t.panels.append(Nl(n)),(r=t.views.findByID(e))==null||r.appendPanelID(n),t.layouts.addALayoutItem(n)},applyJSONSchema(e){var p;const{views:n,panels:r,filters:i,definition:a={},layouts:l}=e,{queries:c,sqlSnippets:u,mock_context:d}=a,h=new Map;if(Array.isArray(r)){const g=r.map(y=>{const v=vt.v4();return h.set(y.id,v),{...y,id:v}});if(t.panels.appendMultiple(g),!Array.isArray(n)||n.length===0){const y=g.map(v=>v.id);(p=t.views.VIE)==null||p.appendPanelIDs(y)}}if(Array.isArray(n)){const g=n.map(y=>{const v=y.panelIDs.map(C=>h.get(C)??C);return{...y,id:vt.v4(),panelIDs:v}});t.views.appendMultiple(g)}if(Array.isArray(l)){const g=(C,T)=>t.layouts.breakpointNameRecord[C]===T;let y=[];const v=l.filter(C=>g(C.name,C.breakpoint));v.forEach(C=>{C.id==="basis"&&(y=C.list),C.list.forEach(T=>{const D=h.get(T.panelID);T.id=vt.v4(),T.panelID=D})}),t.layouts.list.forEach(C=>{const T=v.find(D=>D.name===C.name&&D.breakpoint===C.breakpoint);if(!T){y.forEach(D=>{C.addLayout(D)});return}T.list.forEach(D=>{C.addLayout(D)})})}Array.isArray(i)&&t.filters.appendMultiple(i),Array.isArray(c)&&t.queries.appendMultiple(c),Array.isArray(u)&&t.sqlSnippets.appendMultiple(u),d&&Object.keys(d).length>0&&t.mock_context.defaults(d)}})).actions(t=>({reset(){f.applySnapshot(t.filters.current,t.origin.filters.current),f.applySnapshot(t.queries.current,t.origin.queries.current),f.applySnapshot(t.sqlSnippets.current,t.origin.sqlSnippets.current),f.applySnapshot(t.views.current,t.origin.views.current),f.applySnapshot(t.panels.list,t.origin.panels.list),f.applySnapshot(t.layouts.list,t.origin.layouts.list),t.mock_context.current=t.origin.mock_context.current},resetFilters(){f.applySnapshot(t.filters.current,t.origin.filters.current)},updateCurrent(e){const{id:n,name:r,content:i}=e;if(!i)throw new Error("unexpected null content when updating a content model");const{version:a,filters:l,views:c,panels:u,definition:{queries:d,sqlSnippets:h,mock_context:p={}}}=i;t.id=n,t.name=r,t.version=a,f.applySnapshot(t.filters.current,l),f.applySnapshot(t.views.current,xi(c).current),f.applySnapshot(t.panels.list,u),f.applySnapshot(t.queries.current,d),f.applySnapshot(t.sqlSnippets.current,h),t.mock_context.current=p}})),yi=f.types.snapshotProcessor(ZS,{preProcessor(t){return{...t,origin:t}},postProcessor(t){delete t.origin;const e=f.castToSnapshot(t.queries.current.map(n=>x.pick(n,["id","key","type","sql"])));return x.defaults({},{queries:{current:e}},t)}});function HS(t,e){e.filters&&f.applySnapshot(t.filters.current,e.filters)}function _c({id:t,name:e,dashboard_id:n,create_time:r,update_time:i,content:a},l,c){if(!a)throw new Error("unexpected null content when creating a content model");const{version:u,filters:d,views:h,panels:p,layouts:g,definition:{queries:y,sqlSnippets:v,mock_context:C={}}}=a;return yi.create({id:t,name:e,dashboard_id:n,create_time:r,update_time:i,version:u,filters:li(d,l,C,c),queries:{current:y},sqlSnippets:{current:v},mock_context:Nr(C),views:xi(h),panels:{list:p},layouts:{list:g,currentBreakpoint:g[0].id}})}const jc=f.types.model({id:f.types.identifier,name:f.types.string,group:f.types.string,content:yi,content_id:f.types.string,datasources:YS,globalSQLSnippets:ti,context:os,editor:KS}).views(t=>({get json(){return{id:t.id,name:t.name,group:t.group,content_id:t.content_id}}})).actions(t=>({updateCurrentContent(e){t.content.updateCurrent(e)},updateCurrent(e,n){const{id:r,name:i,group:a,content_id:l}=e;t.id=r,t.name=i,t.group=a,t.content_id=l,this.updateCurrentContent(n)}}));function wc({id:t,name:e,group:n,content_id:r},i,a,l,c,u){return jc.create({id:t,name:e,group:n,content_id:r,content:_c(i,c,u),datasources:{list:a},globalSQLSnippets:{list:l},context:ni(c),editor:{}})}const ek={translation:{filter:{label:"Filter",labels:"Filters",add:"Add a Filter",manage:"Manage Filters",show_filters:"Show Filters",hide_filters:"Hide Filters",field:{widget:"Widget",visible_in:"Visible in...",key_placeholder:"A unique key to refer",label_placeholder:"Label for this field",auto_submit:"Submit automatically",order:"Placement Order",custom_default_value:{trigger:"Custom",title:"Custom default value",tips:"Tips",tip_1:"Function has the highest priority of getting filter's default value",tip_2:"Leave this editor empty to disable this feature"}},widget:{names:{select:"Select",multi_select:"Multi Select",tree_select:"Tree Select",text_input:"Text Input",checkbox:"Checkbox",date_range:"Date Range"},common:{use_query_data_as_options:"Use query data as options",fetch_options_from_datasource:"Fetch options from datasource",or_fetch_options_from_datasource:"Or fetch options from datasource",selector_option_empty:"Not found",see_data_structure:"Click to see expected data structure",using_query:"Using query",default_selection_count:"Select first N options by default",min_width:"Min width",x_selected:"{{count}} selected"},text_input:{default_value:"Default Value",required:"Required"},select:{width:"Width",required:"Required",clearable:"Clearable",configure_options:"Configure options",default_selection:"Default Selection",no_default_selection:"none",select_first_option_by_default:"Select the first option by default"},multi_select:{width_description:"At least 160px"},tree_select:{strictly:"Parent and children nodes are not associated"},checkbox:{description:"Description",default_checked:"Default checked"},date_range:{required:"Required",allow_single_date:"Allow choosing 1 day",display_format:"Display format",max_days:"Max days",one_day:"1 day",x_days:"{{count}} days",x_max_days:"{{max_days}} days max",default_value:"Default value",default_by_shortcut:"Default by shortcut",defualt_by_shortcut_placeholder:"Priors default value",start_date:"Start date",end_date:"End date",shortcut:{last:{label:"last",d:"yesterday",w:"week",m:"month",m2:"2 months",m3:"3 months",y:"year",full:{d:"yesterday",w:"last week",m:"last month",m2:"last 2 months",m3:"last 3 months",y:"last year"}},recent:{label:"recent",d7:"7 days",d30:"30 days",d60:"60 days",d90:"90 days",d180:"180 days",d365:"365 days",full:{d7:"recent 7 days",d30:"recent 30 days",d60:"recent 60 days",d90:"recent 90 days",d180:"recent 180 days",d365:"recent 365 days"}},this:{label:"this",d:"today",w:"week",m:"month",y:"year",full:{d:"today",w:"this week",m:"this month",y:"this year"}},this_so_far:{label:"this...so far",w:"week",m:"month",y:"year",full:{w:"this week so far",m:"this month so far",y:"this year so far"}}}}}},view:{label:"View",labels:"Views",add:"Add a View",delete:"Delete this View",download_schema:"Download this View",component:{div:{label:"Division"},tabs:{label:"Tabs",tabs_settings:"Tabs Settings",tab:{name:"Tab Name",view:"View",order:"Placement Order",color:"Color",delete:"Delete this tab",switch_to_view:"Swith to View: {{name}}"}},modal:{label:"Modal",modal_settings:"Modal settings",title:"Modal Title",custom_title:"Customize modal title",width:"Width",height:"Height"}}},interactions:{label:"Interactions",add:"Add an interaction",interactions_viewer:"Interactions Viewer",unavailable:"Unavailable",unavailable_reason:"This visualization does not have available interactions to choose from",trigger:{setup:"Setup Trigger",label:"Trigger",payload:"Payload"},operation:{setup:"Operation Settings",label:"Operation",settings:"Settings",variables:"Variables",console_log:{label:"console.log | debug",log_content:"log content"},open_link:{label:"Open Link",url:"URL",open_in_new_tab:"Open in new tab"},open_view:{label:"Open View",view:"View"},set_filter_values:{label:"Set Filter Values",set_filter:"Set filter",with:"with"},clear_filter_values:{label:"Clear Filter Values",select_filter:"Select filters to clear"}}},query_variable:{label:"Query Variable",labels:"Query Variables",add:"Add a Variable",guide:{tabs:{guide:"Guide",variables_in_this_dashboard:"Variables in this dashboard",global_sql_snippets:"Global SQL Snippets"}},open:"See Query Variables"},sql_snippet:{label:"SQL Snippet",labels:"SQL Snippets",add:"Add a SQL Snippet",delete:"Delete this SQL Snippet",delete_unused:"Delete unused SQL Snippets",manage:"Manage SQL Snippets",key:"Key",key_occupied:"This key is occupied by another snippet",edit_snippet:"Edit SQL Snippet",preview_snippet:"Preview SQL Snippet",usage:{label:"Usage"}},global_sql_snippet:{label:"Global SQL Snippet",labels:"Global SQL Snippets",description:"SQL snippets worth sharing between dashboards are managed in System Settings by admins."},common:{titles:{settings:"Settings",edit:"Edit",config:"Config"},pagination:{page_size:"Page Size",total:"Total",total_rows:"Total {{total}} row(s)"},align:{horizontal:{label:"Horizontal Align",left:"left",center:"center",right:"right"},vertical:{label:"Vertical Align",left:"top",center:"center",right:"bottom"}},id:"ID",name:"Name",key:"Key",label:"Label",value:"Value",type:"Type",info:"Info",min:"Min",max:"Max",data_field:"Data Field",name_data_field:"Name Data Field",value_data_field:"Value Data Field",color_data_field:"Color Data Field",enabled:"Enabled",copied:"Copied to clipboard",action:"Action",actions:{open:"Open",close:"Close",save:"Save",save_changes:"Save Changes",revert:"Revert",revert_changes:"Revert Changes",reset_to_default:"Reset to default",select_all:"Select All",clear_selection:"Clear Selection",refresh:"Refresh",download_data:"Download Data",download_schema:"Download Schema",download_screenshot:"Screenshot",enter_fullscreen:"Full Screen",duplicate:"Duplicate",delete:"Delete",cancel:"Cancel",confirm:"Confirm",add_an_option:"Add an Option",edit:"Edit",end_editing:"End editing <1>{{name}}</1>"},tabs:{variant:{label:"Variant",default:"Default",outline:"Outline",pills:"Pills"},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},grow_tabs:"Grow Tabs"},choose_a_tab_first:"Please choose a tab first"},breakpoint:{label_one:"Screen size",label_other:"Screen sizes",add:"Add a screen size",manage:"Manage screen sizes",breakpoint:"Min Width"},context:{label:"Context"},mock_context:{label:"Mock Context",hint:"A valid json string is required"},panel:{label:"Panel",labels:"Panels",add:"Add a Panel",delete:"Delete This Panel",panel_name:"Panel Name",panel_description:"Description",panel_description_click:"Click to see description",show_title:"Show title",use_name_as_title:"Use name as title",settings:{change_view:"Move into Another View",change_view_title:"Move panel into another view",choose_queries:"Choose queries",need_to_choose_queries:"Choose at least 1 query for its data"},style:{label:"Style",width:"Width",width_postfix:"of 36 columns",height:"Height",height_postfix:"px",border:"Border"},variable:{label:"Variable",labels:"Variables",add:"Add a Variable",delete:"Delete this Variable",aggregation:{label:"Aggregation",fallback_value:"Fallback Value",fallback_value_description:"Used when data is empty or the aggregation yields NaN"}}},style:{label:"Style",font_size:{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"Font Weight"},size:{xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"xl"},flex:{justify_content:{label:"Justify Content",left:"Left",center:"Center",right:"Right",space_between:"Space Between",space_around:"Space Around",space_evenly:"Space Evenly"},align_items:{label:"Align Items",start:"Start",center:"Center",end:"End",stretch:"Stretch"}},color:{type:{label:"Color Type",static:"Static",interpolation:"Interpolation",none:"None"},interpolation:{setup:"Setup color interpolation",palette:{label:"Palette",category:{sequential:"Sequential",diverging:"Diverging"},red_green:"Red / Green",yellow_blue:"Yellow / Blue",red:"Red",green:"Green",blue:"Blue",orange:"Orange",mapping:{value_input_label:"Map a value to this color"}}}}},query:{label:"Query",labels:"Queries",add:"Add a Query",delete:"Delete this Query",cant_delete:"Can't delete this query for it's being used, check out Usage tab for details",delete_unused:"Delete unused queries",name:"Name",name_description:"A unique name",manage:"Manage Queries",open:"Open this query",configurations:"Configurations",basics:"Basics",conditions:"Conditions",run_by_condition:{label:"Run query when these are truthy",unset:"Always run this query on load"},re_run_condition:{label:"Re-run query when these changed",unset:"Leave it empty to never re-run this query"},dependency:{label:"Dependency",has_none:"This query has no dependency"},edit_sql:"Edit SQL",preview_sql:"Preview SQL",request:"Request",build_request:"Build Request",process_request:"Process Request",process_result:"Process Result",usage:{label:"Usage",in_views:"In View(s)",unused_description:"This query is not used by any filter or panel"},transform:{label:"Transform",data_source:"Use other queries' data",guide:{pick_queries:"Pick queries for data input",write_function:"Write a function for making new data"}}},data:{label:"Data",preview_data:"Preview Data",empty_data:"Empty Data",requires_data:"Requires data"},data_source:{label:"Data Source",explore:"Explore Data Source",explorer:"Data Source Explorer",table_structure:"Table Structure",table_structure_short:"Structure",see_table_structure:"See Table Structure"},visualization:{label:"Visualization",component:"Visualization",label_short:"Viz"},numbro:{format:{label:"Format",absolute:"Absolute",absolute_description:"Non-negative",abbreviation:"Abbreviation",abbreviation_description:"like 1.23k, 1.23m",mantissa:"Mantissa",trim_mantissa:"Trim mantissa",trim_mantissa_description:"hide trailing zero(s)",preview:{open:"Open Preview",close:"Close Preview",input:"In",output:"Out"}}},import:{label:"Import...",title:"Import content with schema json",json_file:"JSON File",this_dashboard:"This dashboard",this_file:"This file"},function_utils:{trigger_text:"About parameter 'utils'",modal_title:"About FunctionUtils",description:"Parameter <code>utils</code> is <code>FunctionUtils</code>, which contains:",document:"Document"},aggregation:{option:{none:"None",sum:"Sum",mean:"Mean",median:"Median",min:"Min",max:"Max",cov:"Coefficient of Variation",std:"Standard Variation",quantile:{label:"Quantile",label_with_hint:"Quantile(99%, 95%, ...)"},custom:{label:"Custom",label_trigger:"Edit Function",title:"Custom Aggregation"}}},chart:{chart_config:"Chart Config",data_field:"Data Field",groups:{merico_suite:"Merico suite",echarts_based_charts:"ECharts-based charts",others:"Others"},label:{label:"Label",label_full:"Label",label_style:"Label Style",label_format:"Label Format"},label_position:{label:"Label Position",off:"Off",top:"Top",left:"Left",right:"Right",bottom:"Bottom",inside:"Inside",inside_top:"Inside Top",inside_left:"Inside Left",inside_center:"Inside Center",inside_right:"Inside Right",inside_bottom:"Inside Bottom",inside_top_left:"Inside Top Left",inside_top_right:"Inside Top Right",inside_bottom_left:"Inside Bottom Left",inside_bottom_right:"Inside Bottom Right",outside:"Outside"},number_or_dynamic_value:{type:{static:"Static",dynamic:"Dynamic"},dynamic:{setup:"Setup",setup_title:"Setup dynamic value",guide:"Dyanmic by a custom function"}},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},symbol_size:{label:"Symbol Size",static:"Static",dynamic:"Dynamic",setup:{label:"Setup",title:"Setup dynamic size",description:"Dynamic by a custom function"}},series:{label:"Series",name:"Name",y_axis:"Y Axis",data_field:"Data Field",add:"Add a series",delete:"Delete this series",line:{label:"Line",line_settings:"Line Settings",line_style:"Line Style",type:{label:"Line Type",solid:"Solid",dashed:"Dashed",dotted:"Dotted"},line_width:"Line Width",step:{label:"Step",off:"Off",start:"Start",middle:"Middle",end:"End"},smooth_line:"Smooth Line",show_name_on_line:"Display Name on Line",show_symbol_on_line:"Show Symbol on Line"},bar:{label:"Bar",stack:"Stack",stack_hint:"Stack bars by this ID",bar_gap:{label:"Bar Gap",no_gap:"No gap between bars",overlap:"Bars overlapping on each other"},bar_width:{min:"Bar Width(min)",exact:"Bar Width",max:"Bar Width(max)"}},scatter:{label:"Scatter"},group_by:{label:"Split into multiple seires by this field...",label_line:"Split into multiple lines by this field..."}},axis:{tick_label:"Tick Label",customize_label:"Customize Label",overflow:{label:"Overflow",max_width:"Max Width",truncate:"Truncate",break_line:"Break Line",break_word:"Break Word",ellipsis:"Ellipsis",section_title:{on_axis:"Overflow on Axis",in_tooltip:"Overflow in Tooltip"}},section_title:{label_format:"Label Format"},type:{value:"Value",category:"Category",time:"Time",log:"Log",click_to_learn_more:"Click <1>here</1> to learn more about these options"}},name_text:{align:{label:"Name Anchor",left:"Left",center:"Center",right:"Right"}},rotate:"Rotate",degree:"degree",padding:"Padding",content_template:{label:"Content Template",hint:"Average: ${avg}"},x_axis:{label:"X Axis",labels:"X Axes",label_format:"Label Format",add:"Add an X Axis",delete:"Delete this X Axis",x_axis_name:"X Axis Name",x_axis_data_field:"X Axis Data Field",x_axis_type:"X Axis Type",layout:"Layout",position:{label:"Position",top:"Top",bottom:"Bottom"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},y_axis:{label:"Y Axis",labels:"Y Axes",label_format:"Label Format",add:"Add a Y Axis",delete:"Delete this Y Axis",y_axis_name:"Y Axis Name",y_axis_name_anchor:"Name Anchor",y_axis_data_field:"Y Axis Data Field",layout:"Layout",position:{label:"Position",left:"Left",right:"Right"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},stats:{label:"Stats",template:{above_chart:"Template for stats above the chart",under_chart:"Template for stats under the chart"}},legend:{label:"Legend",show_legend:"Show Legend",show_in_legend:"Show in legend",hide_in_legend:"Hide in legend",orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"}},tooltip:{label:"Tooltip",additional_metrics:{description:"Set additional metrics to show in scatter's tooltip",add:"Add a metic",delete:"Delete this Metric"},trigger:{label:"Trigger",scatter_point:"Scatter Point",x_axis:"X Axis"}},style:{label:"Style"},color:{label:"Color",or:"or",set_any_color:"Set any color",pick_a_theme_color:"Pick a theme color",background_color:"Background Color",text_color:"Text Color"},behavior:{label:"Behavior",invisible:"Invisible"},heatmap:{heatblock:{label:"Heat Block",min_value:"Min Value",max_value:"Max Value",show_label:"Show Label"}},reference_line:{label:"Reference Line",labels:"Reference Lines",add:"Add a reference line",name_placeholder:"Average Reference Line",delete:"Remove this Reference Line",orientation:{vertical_hint:"Works only when xAxis values are numbers"}},regression_line:{label:"Regression Line",labels:"Regression Lines",add:"Add a line",delete:"Delete this line",method:{label:"Method",linear:"Linear",exponential:"Exponential",logistic:"Logistic",polynomial:"Polynomial",polynomial_order:"Order"}},reference_area:{label:"Reference Area",labels:"Reference Areas",add:"Add a reference area",delete:"Remove this reference area",type:{label:"Type",rectangle:"Rectangle"},direction:{label:"Direction",horizontal:"Horizontal"},boundary:{upper:"Upper Boundary",lower:"Lower Boundary"},content:{label:"Content",content_text:"Content Text",text_position:"Text Position"},endpoint:{labels:"Endpoints",left_bottom_point:"Left-Bottom Point",right_top_point:"Right-Top Point"}},zooming:{label:"Zooming",scroll:{label:"Scroll to zoom",x_axis:"Enable on X Axis",y_axis:"Enable on Y Axis"},slider:{label:"Slider for zooming",x_axis:"Slider for X Axis",y_axis:"Slider for Y Axis",y_axis_disabled:"Not available for now, will overlap y-axis's label"}}},viz:{viz_config_banner:"Visualization Settings"},validation:{number:{require_a_number:"A number is required"}}}},tk={translation:{filter:{label:"筛选器",labels:"筛选器",add:"新增筛选器",manage:"管理筛选器",show_filters:"展开筛选器",hide_filters:"收起筛选器",field:{widget:"控件",visible_in:"在...视图中可见",key_placeholder:"用于引用此筛选器,需保持唯一",label_placeholder:"用于展示的标签文案",auto_submit:"自动提交",order:"排列次序",custom_default_value:{trigger:"自定义",title:"自定义默认值",tips:"提示",tip_1:"在指定筛选器默认值这事上,自定义函数具备最高优先级",tip_2:"清空下方编辑器来禁用本功能"}},widget:{names:{select:"单选",multi_select:"多选",tree_select:"树形选择器",text_input:"文本框",checkbox:"勾选框",date_range:"日期范围"},common:{use_query_data_as_options:"使用所查数据为选项",fetch_options_from_datasource:"从数据源查选项",or_fetch_options_from_datasource:"或从数据源查选项",selector_option_empty:"无选项可用",see_data_structure:"点击查看期望的数据格式",using_query:"在用查询获取选项",default_selection_count:"默认选中前N项",min_width:"控件最小宽度",x_selected:"已选数:{{count}}"},text_input:{default_value:"默认值",required:"必填"},select:{width:"控件宽度",required:"必选",clearable:"可取消选择",configure_options:"配置选项",default_selection:"默认选项",no_default_selection:"无",select_first_option_by_default:"默认选中第一个选项"},multi_select:{width_description:"至少160px"},tree_select:{strictly:"枝叶节点不相关,各选各的"},checkbox:{description:"描述信息",default_checked:"默认勾选"},date_range:{required:"必选",allow_single_date:"允许选一天作为范围",display_format:"展示格式",max_days:"最大选择天数",one_day:"1天",x_days:"{{count}}天",x_max_days:"最多可选{{max_days}}天",default_value:"默认日期范围(具体)",default_by_shortcut:"默认日期范围(快捷方式)",defualt_by_shortcut_placeholder:"优先于左侧",start_date:"开始日期",end_date:"结束日期",shortcut:{last:{label:"过往整周期",d:"昨天",w:"周",m:"月",m2:"两个月",m3:"三个月",y:"年",full:{d:"昨天",w:"上周",m:"上个月",m2:"上两月",m3:"上三月",y:"去年"}},recent:{label:"最近",d7:"7天",d30:"30天",d60:"60天",d90:"90天",d180:"180天",d365:"365天",full:{d7:"近7天",d30:"近30天",d60:"近60天",d90:"近90天",d180:"近180天",d365:"近365天"}},this:{label:"当前整周期",d:"今天",w:"周",m:"月",y:"年",full:{d:"今天",w:"本周",m:"本月",y:"今年"}},this_so_far:{label:"至今",w:"周",m:"月",y:"年",full:{w:"本周至今",m:"本月至今",y:"本年至今"}}}}}},view:{label:"视图",labels:"视图",add:"新增视图",delete:"删除此视图",download_schema:"下载此视图描述文件",component:{div:{label:"内容"},tabs:{label:"标签页",tabs_settings:"标签页设置",tab:{name:"名称",view:"内容视图",order:"排列次序",color:"颜色",delete:"删除这个标签页",switch_to_view:"打开视图: {{name}}"}},modal:{label:"弹窗",modal_settings:"弹窗设置",title:"弹窗标题",custom_title:"自定义弹窗标题",width:"宽度",height:"高度"}}},interactions:{label:"交互",add:"新增交互",interactions_viewer:"纵览交互",unavailable:"不可用",unavailable_reason:"此可视化组件没有交互功能",trigger:{setup:"设置触发动作",label:"触发动作",payload:"触发时的参数"},operation:{setup:"操作设置",label:"操作",settings:"设置",variables:"变量",console_log:{label:"console.log | 调试用",log_content:"打印内容"},open_link:{label:"打开链接",url:"URL",open_in_new_tab:"在新标签页中打开"},open_view:{label:"唤出视图",view:"视图"},set_filter_values:{label:"设置筛选器值",set_filter:"将筛选器的值",with:"设为"},clear_filter_values:{label:"清除筛选器值",select_filter:"选择筛选器以清除其值"}}},query_variable:{label:"查询变量",labels:"查询变量",add:"新增变量",guide:{tabs:{guide:"使用指南",variables_in_this_dashboard:"本看板中的查询变量",global_sql_snippets:"全局SQL片段"}},open:"查看查询变量"},sql_snippet:{label:"SQL片段",labels:"SQL片段",add:"新增SQL片段",delete:"删除这个SQL片段",delete_unused:"删除未用到的SQL片段",manage:"管理SQL片段",key:"键",key_occupied:"此键已被其他SQL片段占用",edit_snippet:"编辑SQL片段",preview_snippet:"预览SQL片段",usage:{label:"使用情况"}},global_sql_snippet:{label:"全局SQL片段",labels:"全局SQL片段",description:"管理员负责在系统设置中维护全局SQL片段"},common:{titles:{settings:"设置",edit:"编辑",config:"配置"},pagination:{page_size:"页容量",total:"共",total_rows:"共 {{total}} 行"},align:{horizontal:{label:"水平对齐",left:"居左",center:"居中",right:"居右"},vertical:{label:"垂直对齐",left:"居上",center:"居中",right:"居下"}},id:"ID",name:"名称",key:"键",label:"标签",value:"值",type:"类型",info:"信息",min:"最小值",max:"最大值",data_field:"数据字段",name_data_field:"名称字段",value_data_field:"值字段",color_data_field:"颜色字段",enabled:"启用",copied:"已复制到剪切板",action:"操作",actions:{open:"打开",close:"关闭",save:"保存",save_changes:"保存改动",revert:"还原",revert_changes:"还原改动",reset_to_default:"重置为初始值",select_all:"全选",clear_selection:"撤销选择",refresh:"刷新",download_data:"下载数据",download_schema:"下载描述文件",download_screenshot:"下载截图",enter_fullscreen:"全屏",duplicate:"复制",delete:"删除",cancel:"取消",confirm:"确认",add_an_option:"新增选项",edit:"编辑",end_editing:"结束编辑 <1>{{name}}</1>"},tabs:{variant:{label:"风格",default:"默认",outline:"轮廓",pills:"胶囊"},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},grow_tabs:"拉伸标签卡宽度"},choose_a_tab_first:"请先选择一个标签页"},breakpoint:{label_one:"屏幕尺寸",label_other:"屏幕尺寸",add:"新增屏幕尺寸",manage:"管理屏幕尺寸",breakpoint:"最小宽度"},context:{label:"上下文"},mock_context:{label:"模拟上下文",hint:"内容格式为JSON"},panel:{label:"卡片",labels:"卡片",add:"新增卡片",delete:"删除这个卡片",panel_name:"卡片名",panel_description:"卡片描述",panel_description_click:"点击查看卡片描述",show_title:"展示卡片标题",use_name_as_title:"使用卡片名作为标题",settings:{change_view:"移至另一个视图下",change_view_title:"移动此卡片至另一个视图下",choose_queries:"关联查询",need_to_choose_queries:"请关联至少一个查询以使用其数据"},style:{label:"样式",width:"宽",width_postfix:"之 36 栏",height:"高",height_postfix:"px",border:"边框"},variable:{label:"变量",labels:"变量",add:"新增变量",delete:"删除此变量",aggregation:{label:"聚合",fallback_value:"兜底值",fallback_value_description:"当数据为空或聚合结果非数字时,使用此兜底值"}}},style:{label:"样式",font_size:{label:"字号",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"字重"},size:{xs:"特小",sm:"小",md:"中",lg:"大",xl:"特大"},flex:{justify_content:{label:"内容分布",left:"从左起",center:"居中",right:"从右起",space_between:"均匀分布,首尾顶格",space_around:"均匀分布,首尾留空一半",space_evenly:"均匀分布,首尾留空"},align_items:{label:"对齐位置",start:"起点对齐",center:"居中对齐",end:"末端对齐",stretch:"拉伸对齐"}},color:{type:{label:"颜色类型",static:"单色",interpolation:"插值取色",none:"无"},interpolation:{setup:"设置取色方案",palette:{label:"色板",category:{sequential:"单色渐变",diverging:"双色渐变"},red_green:"红 / 绿",yellow_blue:"黄 / 蓝",red:"红",green:"绿",blue:"蓝",orange:"橙",mapping:{value_input_label:"映射一个值到此颜色"}}}}},query:{label:"查询",labels:"查询",add:"新增查询",delete:"删除这个查询",cant_delete:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",delete_unused:"删除未用到的查询",name:"名称",name_description:"唯一名称",manage:"管理查询",open:"打开此查询",configurations:"配置",basics:"基本信息",conditions:"条件",run_by_condition:{label:"以下条件满足时,才运行本查询",unset:"看板加载时便运行本查询"},re_run_condition:{label:"当以下条件改变时,重新运行此查询",unset:"留空则永不重新运行此查询"},dependency:{label:"依赖",has_none:"此查询无依赖"},edit_sql:"编辑SQL",preview_sql:"预览SQL",request:"请求",build_request:"构造请求",process_request:"加工请求",process_result:"加工结果",usage:{label:"使用情况",in_views:"所在视图",unused_description:"此查询未被任何筛选器或卡片用到"},transform:{label:"查询变形",data_source:"基于其他查询的数据,加工出新数据",guide:{pick_queries:"选择一至多个查询作为数据输入",write_function:"编写函数,返回新数据"}}},data:{label:"数据",preview_data:"预览数据",empty_data:"无数据",requires_data:"请先关联查询"},data_source:{label:"数据源",explore:"查看数据源",explorer:"数据源查看器",table_structure:"数据表结构",table_structure_short:"表结构",see_table_structure:"查看数据表结构"},visualization:{label:"可视化",component:"可视化组件",label_short:"可视化"},numbro:{format:{label:"格式",absolute:"绝对值",absolute_description:"非负",abbreviation:"缩写",abbreviation_description:"如1.23k、1.23m",mantissa:"小数",trim_mantissa:"抹零",trim_mantissa_description:"省略末尾的零",preview:{open:"展开预览",close:"收起预览",input:"输入",output:"输出"}}},import:{label:"导入...",title:"自描述文件导入看板内容",json_file:"描述文件(JSON格式)",this_dashboard:"此看板",this_file:"此文件"},function_utils:{trigger_text:"关于utils参数",modal_title:"关于utils参数",description:"参数 <code>utils</code> 是 <code>FunctionUtils</code>,包含以下内容:",document:"文档"},aggregation:{option:{none:"无",sum:"和",mean:"平均值",median:"中位数",min:"最小值",max:"最大值",cov:"变异系数",std:"标准差",quantile:{label:"分位",label_with_hint:"分位(99%, 95%, ...)"},custom:{label:"自定义",label_trigger:"编写函数",title:"自定义聚合方式"}}},chart:{chart_config:"图表设置",data_field:"数据字段",groups:{merico_suite:"思码逸套件",echarts_based_charts:"基于ECharts的图表",others:"其他"},label:{label:"文案",label_full:"标签文案",label_style:"标签文案样式",label_format:"标签文案格式"},label_position:{label:"文案位置",off:"不显示文案",top:"上",left:"左",right:"右",bottom:"下",inside:"内",inside_top:"内-上",inside_left:"内-左",inside_center:"内-中",inside_right:"内-右",inside_bottom:"内-下",inside_top_left:"内-上-左",inside_top_right:"内-上-右",inside_bottom_left:"内-下-左",inside_bottom_right:"内-下-右",outside:"外"},number_or_dynamic_value:{type:{static:"具体值",dynamic:"动态值"},dynamic:{setup:"设置",setup_title:"设置动态值",guide:"由函数确定动态值"}},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},symbol_size:{label:"标记点大小",static:"固定值",dynamic:"动态值",setup:{label:"设置",title:"设置动态值",description:"由函数确定动态值"}},series:{label:"系列",name:"名称",y_axis:"Y轴",data_field:"数据字段",add:"增加一个系列",delete:"删除这个系列",line:{label:"线",line_settings:"线段设置",line_style:"线条样式",type:{label:"类型",solid:"实线",dashed:"方虚线",dotted:"圆点虚线"},line_width:"线宽",step:{label:"阶梯状",off:"不启用",start:"在当前点拐弯",middle:"在当前点与下个点中间拐弯",end:"在下个点拐弯"},smooth_line:"平滑曲线",show_name_on_line:"显示标签文案",show_symbol_on_line:"显示标记点"},bar:{label:"柱",stack:"堆放",stack_hint:"此值相同的柱系列会堆叠在一起",bar_gap:{label:"柱间隔",no_gap:"柱子之间无间隔",overlap:"柱子可互相重叠"},bar_width:{min:"最大柱宽",exact:"柱宽",max:"最大柱宽"}},scatter:{label:"散点"},group_by:{label:"按此字段拆分为多个系列",label_line:"按此字段拆分为多条线"}},axis:{tick_label:"刻度文案",customize_label:"自定义文案",overflow:{label:"溢出",max_width:"最大宽度",truncate:"截断",break_line:"换行",break_word:"断词换行",ellipsis:"省略符",section_title:{on_axis:"轴刻度上文案的溢出",in_tooltip:"提示框中的文案溢出"}},section_title:{label_format:"文案格式"},type:{value:"数值轴",category:"类目轴",time:"时间轴",log:"对数轴",click_to_learn_more:"点击 <1>这里</1> 以进一步了解这些选项"}},name_text:{align:{label:"名称贴靠侧",left:"左",center:"中",right:"右"}},rotate:"旋转",degree:"度",padding:"内间距",content_template:{label:"内容模板",hint:"均值: ${avg}"},x_axis:{label:"X轴",labels:"X轴",label_format:"刻度文案格式",add:"增加一条X轴",delete:"删除这条X轴",x_axis_name:"X轴名称",x_axis_data_field:"X轴数据字段",x_axis_type:"X轴类型",layout:"布局",position:{label:"位置",top:"上",bottom:"下"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},y_axis:{label:"Y轴",labels:"Y轴",label_format:"刻度文案格式",add:"增加一条Y轴",delete:"删除这条Y轴",y_axis_name:"Y轴名称",y_axis_name_anchor:"名称贴靠侧",y_axis_data_field:"Y轴数据字段",layout:"布局",position:{label:"位置",left:"左",right:"右"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},stats:{label:"统计内容",template:{above_chart:"统计内容模板(图表上方)",under_chart:"统计内容模板(图表下方)"}},legend:{label:"图例",show_legend:"显示图例",show_in_legend:"显示在图例中",hide_in_legend:"不显示在图例中",orientation:{label:"布局朝向",horizontal:"横向",vertical:"纵向"}},tooltip:{label:"提示框",additional_metrics:{description:"在此设置更多指标,来展示在散点的提示框",add:"增加一个指标",delete:"删除这个指标"},trigger:{label:"触发者",scatter_point:"散点",x_axis:"X轴"}},style:{label:"样式"},color:{label:"颜色",or:"或",set_any_color:"输入色号",pick_a_theme_color:"选择一个主题色",background_color:"背景色",text_color:"文字颜色"},behavior:{label:"表现",invisible:"隐藏不可见"},heatmap:{heatblock:{label:"热力块",min_value:"最小值",max_value:"最大值",show_label:"展示值文案"}},reference_line:{label:"参考线",labels:"参考线",add:"增加一条参考线",name_placeholder:"均值参考线",delete:"删除这条参考线",orientation:{vertical_hint:"仅当X轴值为数字时可绘制"}},regression_line:{label:"回归线",labels:"回归线",add:"增加一条回归线",delete:"删除这条回归线",method:{label:"方法",linear:"线性回归",exponential:"指数回归",logistic:"指数回归",polynomial:"多项式回归",polynomial_order:"次"}},reference_area:{label:"参考区域",labels:"参考区域",add:"增加一面参考区域",delete:"删除这面参考区域",type:{label:"形状",rectangle:"矩形"},direction:{label:"方向",horizontal:"水平"},boundary:{upper:"上边界",lower:"下边界"},content:{label:"内容",content_text:"内容文字",text_position:"文字位置"},endpoint:{labels:"端点",left_bottom_point:"左下点",right_top_point:"右上点"}},zooming:{label:"缩放",scroll:{label:"滚轮缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用"},slider:{label:"滚动条缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用",y_axis_disabled:"暂不可用,会与Y轴刻度文字重叠"}}},viz:{viz_config_banner:"可视化参数配置"},validation:{number:{require_a_number:"请填写一个数字"}}}},us=nd.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:ek,zh:tk}}).use(sd).use(_.initReactI18next);us.init(),ul.forEach(t=>{var e;(e=t.translation)==null||e.forEach(n=>{us.addResourceBundle(n.lang,"translation",{viz:n.resources},!0,!0)})});function Cc({lang:t,children:e}){return m.useEffect(()=>{us.changeLanguage(t)},[t]),s.jsx(_.I18nextProvider,{i18n:us,children:e})}function Sc(t,e){m.useEffect(()=>{const n=r=>{console.log(r);const{viewID:i}=r.detail;if(!i){console.error(new Error("[Open View] Needs to pick a view first"));return}t.views.appendToVisibles(i),e&&t.views.setIDOfVIE(i)};return window.addEventListener("open-view",n),()=>{window.removeEventListener("open-view",n)}},[t,e]),m.useEffect(()=>{const n=r=>{console.log(r);const{dictionary:i,payload:a}=r.detail;if(!a||Object.keys(a).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}Object.entries(i).forEach(([l,c])=>{t.filters.setValueByKey(l,x.get(a,c))})};return window.addEventListener("set-filter-values",n),()=>{window.removeEventListener("set-filter-values",n)}},[t]),m.useEffect(()=>{function n(i){return Array.isArray(i)?[]:typeof i=="object"?{}:typeof i=="boolean"?!1:typeof i=="string"?"":typeof i=="number"?0:i}const r=i=>{console.log(i);const{filter_keys:a}=i.detail;a.forEach(l=>{const c=x.get(t.filters.values,l),u=n(c);console.log(`${l}: ${u}`),t.filters.setValueByKey(l,u)})};return window.addEventListener("clear-filter-values",r),()=>{window.removeEventListener("clear-filter-values",r)}},[t]),m.useEffect(()=>{const n=r=>{console.log(r);const{urlTemplate:i,openInNewTab:a,enableEncoding:l=!1,payload:c}=r.detail;if(!i){console.error(new Error("[Open Link] URL is empty"));return}function u(p){return x.cloneDeepWith(p,y=>{if(l&&typeof y=="string")return encodeURIComponent(y)})}const h=x.template(i||"")(u({...c,filters:t.payloadForSQL.filters,context:t.payloadForSQL.context}));window.open(h,a?"_blank":"_self","noopener")};return window.addEventListener("open-link",n),()=>{window.removeEventListener("open-link",n)}},[t])}function kc(t){return m.useCallback(e=>e.provideValue(he.pluginManager,t.pluginManager).provideValue(he.vizManager,t.vizManager).provideValue(he.colorManager,t.colorManager),[])}const sI="",nk=S.observer(({saveDashboardChanges:t})=>{const{t:e}=_.useTranslation(),n=Be.useModals(),r=W(),i=()=>{n.openConfirmModal({title:s.jsxs(o.Group,{position:"left",children:[s.jsx(k.IconAlertTriangle,{size:18,color:"red"}),s.jsx(o.Text,{children:"You are reverting changes"})]}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>r.reset(),zIndex:320,withCloseButton:!1})},a=r.changed;return s.jsxs(o.Group,{spacing:0,children:[s.jsx(o.Button,{color:"green",variant:"filled",size:"xs",leftIcon:s.jsx(k.IconDeviceFloppy,{size:18}),onClick:t,disabled:!a,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:e("common.actions.save_changes")}),s.jsxs(o.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!a,children:[s.jsx(o.Menu.Target,{children:s.jsx(o.ActionIcon,{variant:"default",disabled:!a,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:s.jsx(k.IconCaretDown,{size:18})})}),s.jsx(o.Menu.Dropdown,{children:s.jsx(o.Menu.Item,{icon:s.jsx(k.IconRecycle,{size:14,color:"red"}),disabled:!a,onClick:i,children:e("common.actions.revert_changes")})})]})]})}),sk=S.observer(({saveDashboardChanges:t,onExit:e,headerSlot:n=null})=>{_.useTranslation();const r=X(),i=r.content.changed,a=()=>{e({hasChanges:i,dashboardId:r.id})};return s.jsx(o.Header,{height:60,px:"md",py:0,sx:{zIndex:299},children:s.jsxs(o.Group,{position:"apart",sx:{height:60,minWidth:"1000px",position:"relative"},children:[s.jsxs(o.Group,{children:[s.jsx(o.Button,{size:"xs",color:i?"red":"green",leftIcon:s.jsx(k.IconArrowLeft,{size:20}),onClick:a,children:s.jsx(o.Group,{spacing:4,children:s.jsxs(_.Trans,{i18nKey:"common.actions.end_editing",values:{name:r.name},children:["End Editing ",s.jsx(o.Text,{td:"underline",children:r.name})]})})}),s.jsx(nk,{saveDashboardChanges:t})]}),s.jsx(o.Group,{position:"right",sx:{flexGrow:1},children:n})]})})}),Tc={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},rk=S.observer(()=>{var i;const{t}=_.useTranslation(),e=W(),n=((i=e.views.VIE)==null?void 0:i.type)===L.Tabs,r=()=>e.addANewPanel(e.views.idOfVIE);return n?s.jsx(o.Tooltip,{label:t("common.choose_a_tab_first"),children:s.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:s.jsx(k.IconPlaylistAdd,{size:20}),sx:{...Tc,transform:"none !important"},children:t("panel.add")})}):s.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:r,leftIcon:s.jsx(k.IconPlaylistAdd,{size:20}),sx:{...Tc,background:"rgb(231, 245, 255)"},children:t("panel.add")})}),ik=S.observer(({done:t})=>{var te,Q;const{t:e}=_.useTranslation(),r=W().layouts,i=m.useMemo(()=>({list:r.breakpointsInfo}),[r.breakpointsInfo]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d,formState:h}=b.useForm({defaultValues:i}),{fields:p,append:g,remove:y}=b.useFieldArray({control:a,name:"list",rules:{validate:R=>{if(console.log({values:R}),x.uniqBy(R,"breakpoint").length!==R.length)return"Screen sizes should be unique by min width"}}}),v=c("list"),C=p.map((R,ne)=>({...R,...v[ne]})),T=()=>{g({id:vt.v4(),name:"",breakpoint:""})},D=({list:R})=>{const ne=R.filter(Se=>Number.isFinite(Se.breakpoint));r.updateLayoutSetsInfo(ne),t()},M=u(),$=m.useMemo(()=>{const R={list:M.list.filter(ne=>!!ne.name&&Number.isFinite(ne.breakpoint))};return!x.isEqual(R,i)},[M,i]),J=(Q=(te=h.errors.list)==null?void 0:te.root)==null?void 0:Q.message;return s.jsx(s.Fragment,{children:s.jsxs("form",{onSubmit:l(D),children:[s.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,withBorder:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"340px"},children:e("common.name")}),s.jsx("th",{style:{width:"160px"},children:e("breakpoint.breakpoint")}),s.jsx("th",{})]})}),s.jsxs("tbody",{children:[C.map((R,ne)=>s.jsxs("tr",{children:[s.jsx("th",{children:R.id==="basis"?R.name:s.jsx(b.Controller,{name:`list.${ne}.name`,control:a,render:({field:Se})=>s.jsx(o.TextInput,{size:"xs",label:"",required:!0,sx:{flex:1},...Se})})}),s.jsx("td",{children:R.id==="basis"?s.jsxs(o.Text,{ff:"monospace",children:[R.breakpoint,"px"]}):s.jsx(b.Controller,{name:`list.${ne}.breakpoint`,control:a,render:({field:Se})=>s.jsx(o.NumberInput,{size:"xs",label:"",required:!0,max:1e4,hideControls:!0,rightSection:s.jsx(o.Text,{color:"dimmed",children:"px"}),rightSectionProps:{style:{width:"30px"}},sx:{flex:1,fontFamily:"monospace"},styles:{input:{paddingRight:"30px"}},...Se})})}),s.jsx("td",{children:R.id!=="basis"&&s.jsx(o.ActionIcon,{mx:"auto",size:"xs",variant:"subtle",color:"red",onClick:()=>y(ne),children:s.jsx(k.IconTrash,{})})})]},R.id)),s.jsx("tr",{style:{backgroundColor:"transparent"},children:s.jsx("td",{colSpan:3,style:{padding:"0"},children:s.jsx(o.Tooltip,{label:e("breakpoint.add"),children:s.jsx(o.ActionIcon,{variant:"subtle",size:"md",color:"blue",onClick:T,sx:{width:"100%"},children:s.jsx(k.IconPlus,{size:18})})})})})]})]}),s.jsx(o.Text,{mt:6,ta:"right",size:"xs",color:"red",children:J??" "}),s.jsxs(o.Group,{mt:6,position:"apart",children:[s.jsx(o.Button,{color:"orange",size:"xs",onClick:()=>d(),leftIcon:s.jsx(k.IconRecycle,{size:18}),disabled:!$,children:e("common.actions.revert")}),s.jsx(o.Button,{color:"green",size:"xs",type:"submit",leftIcon:s.jsx(k.IconDeviceFloppy,{size:18}),disabled:!$,children:e("common.actions.save_changes")})]})]})})}),ak=S.observer(()=>{const{t}=_.useTranslation(),[e,{open:n,close:r}]=ie.useDisclosure(!1),i=W(),a=i.layouts.currentBreakpoint,l=i.layouts.currentLayoutRange,c=()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},u=()=>{r(),c()};return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{children:[s.jsxs(o.Menu,{withArrow:!0,withinPortal:!0,zIndex:320,trigger:"hover",children:[s.jsx(o.Menu.Target,{children:s.jsx(o.Button,{size:"xs",variant:"subtle",leftIcon:s.jsx(k.IconDevices,{size:16}),sx:{borderRadius:0},children:s.jsxs(o.Group,{spacing:6,children:[s.jsx(o.Text,{size:"xs",fw:"normal",children:l.name}),s.jsx(o.Text,{size:"xs",color:"#777",children:i.layouts.currentRangeText})]})})}),s.jsxs(o.Menu.Dropdown,{children:[i.layouts.breakpointRanges.map(d=>s.jsx(o.Menu.Item,{onClick:()=>i.layouts.setCurrentBreakpoint(d.id),disabled:a===d.id,children:s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Text,{size:"sm",children:d.name}),s.jsx(o.Text,{size:"xs",color:"dimmed",children:d.text})]})},d.id)),s.jsx(o.Menu.Divider,{}),s.jsx(o.Menu.Item,{color:"blue",icon:s.jsx(k.IconSettings,{size:14}),onClick:n,children:s.jsx(o.Text,{size:"sm",children:t("breakpoint.manage")})})]})]}),i.layouts.divisionPreviewScale<1&&s.jsx(o.Text,{size:"xs",color:"dimmed",children:jn(i.layouts.divisionPreviewScale).format({output:"percent",mantissa:0})})]}),s.jsx(o.Modal,{opened:e,onClose:u,title:t("breakpoint.label",{count:2}),withinPortal:!0,zIndex:320,size:600,closeOnClickOutside:!1,children:s.jsx(ik,{done:u})})]})}),Dc={height:"30px",borderRight:"none",borderTop:"none",borderLeft:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},ok=S.observer(()=>{var i;const{t}=_.useTranslation(),e=W(),n=((i=e.views.VIE)==null?void 0:i.type)===L.Tabs,r=()=>{var a;return(a=e.views.VIE)==null?void 0:a.downloadSchema()};return n?s.jsx(o.Tooltip,{label:t("common.choose_a_tab_first"),children:s.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:s.jsx(k.IconCode,{size:16}),sx:{...Dc,transform:"none !important"},children:t("view.download_schema")})}):s.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:r,leftIcon:s.jsx(k.IconCode,{size:16}),sx:{...Dc},children:t("view.download_schema")})}),ds=({headers:t,rows:e})=>s.jsxs(o.Table,{fontSize:"xs",highlightOnHover:!0,sx:{tableLayout:"fixed",fontFamily:"monospace"},children:[s.jsx("thead",{children:t}),s.jsx("tbody",{children:e})]}),lk=({content:t})=>{const{t:e}=_.useTranslation(),n=t.views;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("view.labels")}),s.jsx(ds,{headers:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"160px"},children:e("common.id")}),s.jsx("th",{children:e("common.name")}),s.jsx("th",{children:e("common.type")})]}),rows:n.map(r=>s.jsxs("tr",{children:[s.jsx("td",{children:r.id}),s.jsx("td",{children:r.name}),s.jsx("td",{children:e(`view.component.${r.type}.label`)})]},r.id))})]})},ck=({content:t})=>{const{t:e}=_.useTranslation(),n=t.filters;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("filter.labels")}),s.jsx(ds,{headers:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"160px"},children:e("common.id")}),s.jsx("th",{children:e("common.key")}),s.jsx("th",{children:e("common.label")})]}),rows:n.map(r=>s.jsxs("tr",{children:[s.jsx("td",{children:r.id}),s.jsx("td",{children:r.key}),s.jsx("td",{children:r.label})]},r.id))})]})},uk=({content:t})=>{const{t:e}=_.useTranslation(),n=t.panels;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("panel.labels")}),s.jsx(ds,{headers:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"160px"},children:e("common.id")}),s.jsx("th",{children:e("common.name")}),s.jsx("th",{children:e("visualization.component")})]}),rows:n.map(r=>s.jsxs("tr",{children:[s.jsx("td",{children:r.id}),s.jsx("td",{children:r.name}),s.jsx("td",{children:r.viz.type})]},r.id))})]})},dk=({content:t})=>{var r;const{t:e}=_.useTranslation(),n=(r=t.definition)==null?void 0:r.queries;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("query.labels")}),s.jsx(ds,{headers:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"160px"},children:e("common.id")}),s.jsx("th",{children:e("common.name")}),s.jsx("th",{style:{width:"140px"},children:e("common.type")}),s.jsx("th",{style:{width:"260px"},children:e("data_source.label")})]}),rows:n.map(i=>s.jsxs("tr",{children:[s.jsx("td",{children:i.id}),s.jsx("td",{children:i.name}),s.jsx("td",{children:i.type}),s.jsx("td",{children:i.key})]},i.id))})]})},hk=({content:t})=>{var r;const{t:e}=_.useTranslation(),n=(r=t.definition)==null?void 0:r.sqlSnippets;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("sql_snippet.labels")}),s.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:s.jsx(k.IconPointFilled,{size:10}),children:n.map(i=>s.jsx(o.List.Item,{children:i.key},i.key))})]})},pk=({content:t})=>{var r;const{t:e}=_.useTranslation(),n=Object.keys(((r=t.definition)==null?void 0:r.mock_context)??{});return n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("mock_context.label")}),s.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:s.jsx(k.IconPointFilled,{size:10}),children:n.map(i=>s.jsx(o.List.Item,{children:i},i))})]})},mk=({content:t})=>t?s.jsxs(o.Box,{children:[s.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),s.jsx(o.Text,{ta:"left",c:"dimmed",children:"Preview"}),s.jsxs(o.Stack,{children:[s.jsx(lk,{content:t}),s.jsx(ck,{content:t}),s.jsx(uk,{content:t}),s.jsx(dk,{content:t}),s.jsx(hk,{content:t}),s.jsx(pk,{content:t})]})]}):null;function fk(t){if(t.target===null)throw new Error("FileReader failed with null result");if(typeof t.target.result!="string")throw new Error(`Unparsable file content of type: ${typeof t.target.result}`);let e=JSON.parse(t.target.result);if("content"in e&&(e=e.content),e.version!==mt)throw new Error("Schema version mismatch");return e}const gk=S.observer(({onSuccess:t,stretchModal:e,shrinkModal:n})=>{var D,M;const{t:r}=_.useTranslation(),i=W(),{handleSubmit:a,formState:{errors:l},setValue:c,watch:u,setError:d,clearErrors:h}=b.useForm({defaultValues:{content:null}}),p=({content:$})=>{try{if(!$)throw new Error("please use a valid json file");i.applyJSONSchema($),yt.showNotification({title:"Successful",message:"",color:"green"}),t()}catch(J){console.error(J),yt.showNotification({title:"Failed",message:J.message,color:"red"})}},[g,y]=m.useState(null);m.useEffect(()=>{if(!g)return;const $=new FileReader;$.readAsText(g,"UTF-8"),$.onload=J=>{try{const te=fk(J);c("content",te),h("content")}catch(te){console.error(te),d("content",{type:"custom",message:te.message})}},$.onabort=()=>console.log("🟨 abort"),$.onerror=()=>{$.error&&(console.error($.error),d("content",{type:"custom",message:$.error.message}))}},[g]);const[v]=u(["content"]),C=!v,T=(D=l==null?void 0:l.content)==null?void 0:D.message;return m.useEffect(()=>{!v||T?n():e()},[v,T]),s.jsx(o.Box,{mx:"auto",sx:{position:"relative"},children:s.jsxs("form",{onSubmit:a(p),children:[s.jsx(o.FileInput,{label:r("import.json_file"),required:!0,value:g,onChange:y,error:(M=l==null?void 0:l.content)==null?void 0:M.message,sx:{maxWidth:500}}),T?s.jsx(o.Table,{fontSize:12,mt:10,children:s.jsxs("tbody",{children:[s.jsxs("tr",{children:[s.jsx("th",{children:r("import.this_dashboard")}),s.jsx("td",{children:mt})]}),s.jsxs("tr",{children:[s.jsx("th",{children:r("import.this_file")}),s.jsx("td",{style:{color:"red"},children:v==null?void 0:v.version})]})]})}):s.jsxs(s.Fragment,{children:[s.jsx(mk,{content:v}),s.jsx(o.Group,{position:"right",my:"md",children:s.jsx(o.Button,{type:"submit",color:"green",disabled:C,children:r("common.actions.confirm")})})]})]})})}),zc={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},xk=S.observer(()=>{var d;const{t}=_.useTranslation(),[e,{open:n,close:r}]=ie.useDisclosure(!1),[i,{setTrue:a,setFalse:l}]=N.useBoolean(!1),u=((d=X().content.views.VIE)==null?void 0:d.type)===L.Tabs;return u?s.jsx(o.Tooltip,{label:t("common.choose_a_tab_first"),children:s.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:s.jsx(k.IconFileImport,{size:16}),sx:{...zc,transform:"none !important"},children:t("import.label")})}):s.jsxs(s.Fragment,{children:[s.jsx(o.Button,{variant:"subtle",color:"blue",radius:0,size:"xs",disabled:u||e,onClick:n,leftIcon:s.jsx(k.IconFileImport,{size:16}),sx:{...zc},children:t("import.label")}),s.jsx(o.Modal,{opened:e,onClose:r,title:t("import.title"),trapFocus:!0,onDragStart:h=>{h.stopPropagation()},withinPortal:!0,zIndex:320,size:i?"90vw":500,children:s.jsx(gk,{onSuccess:r,stretchModal:a,shrinkModal:l})})]})}),yk={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},bk=S.observer(()=>s.jsx(o.Box,{sx:yk,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:s.jsxs(o.Group,{position:"apart",align:"center",sx:{height:"30px"},children:[s.jsxs(o.Group,{position:"left",spacing:0,children:[s.jsx(rk,{}),s.jsx(xk,{})]}),s.jsx(ak,{}),s.jsx(o.Group,{position:"right",spacing:0,children:s.jsx(ok,{})})]})})),vk=S.observer(t=>s.jsxs(s.Fragment,{children:[s.jsx(sk,{...t}),s.jsx(bk,{})]})),rI="";function _k(t,e,n){const r=[];return t.filter(i=>"__INTERACTIONS"in i.viz.conf).forEach((i,a)=>{const l=e[i.id];l.data.interactions=x.get(l,"data.interactions",[]);const{__INTERACTIONS:c,__OPERATIONS:u,__TRIGGERS:d}=i.viz.conf;Object.entries(u).forEach(([h,p])=>{const{schemaRef:g,data:y}=p,{config:v}=y;switch(g){case"builtin:op:open-link":let C=v.urlTemplate.substring(0,100);v.urlTemplate.length>=20&&(C+="..."),l.type="interaction",l.data.interactions.push({schemaRef:g,urlTemplate:v.urlTemplate,shortURLTemplate:C});return;case"builtin:op:open_view":r.push({id:`OPERATION--${h}`,source:i.id,target:v.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:g,filters:Object.keys(v.dictionary).map(T=>({key:T,label:n[T]}))});return;case"builtin:op:clear_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:g,filters:v.filter_keys.map(T=>({key:T,label:n[T]}))});return;default:return}})}),r}function jk(t,e){const n=t.filters.keyLabelMap;return{edges:_k(t.panels.list,e,n),edgeNodes:[]}}function Ic(t,e,n){return t*e+t*n}function wk(t,e,n){return t*e+(t-1)*n}const hs=25,bi=40,Mc=25,vi=350,Ck=150,Sk=150,Ec=150,Ac=300,ps=40,Pc=25,kk=300;function Tk(t,e){const n=x.keyBy(e,i=>i.id),r=[];return t.current.forEach((i,a)=>{i.panelIDs.forEach((l,c)=>{const u=Ic(c,ps,Pc)+bi,d=n[l];if(!d){r.push({id:l,_node_type:"panel",parentNode:i.id,data:{label:`!: ${l}`},position:{x:hs,y:u},sourcePosition:ve.Position.Right,targetPosition:ve.Position.Left,style:{width:Ac,height:ps}});return}const h=d.name;r.push({id:d.id,_node_type:"panel",parentNode:i.id,data:{label:h},position:{x:hs,y:u},sourcePosition:ve.Position.Right,targetPosition:ve.Position.Left,style:{width:Ac,height:ps}})})}),r}const Dk={[L.Division]:"Div",[L.Modal]:"Modal",[L.Tabs]:"Tabs"},zk=pc;function Ik(t){return t.current.map((n,r)=>{const i=wk(n.panelIDs.length,ps,Pc)+bi+Mc;let a=[];return n.type===L.Tabs&&(a=n.config.tabsInOrder.map(c=>c.view_id)),{id:n.id,_node_type:"view-root",_view_type:n.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:a,data:{label:`${Dk[n.type]}:${n.name}`},position:{x:0,y:0},sourcePosition:ve.Position.Right,targetPosition:ve.Position.Left,className:"light",style:{backgroundColor:zk[n.type],width:vi,height:i}}})}function Mk(t){const e=x.keyBy(t,n=>n.id);t.forEach(n=>{n._node_type!=="view-root"||n._view_type!==L.Tabs||n._tab_view_ids.forEach(r=>{e[r].parentNode=n.id})})}function Ek(t){const e=Ik(t.views);Mk(e);const n=Tk(t.views,t.panels.list);return[...e,...n]}function Ak({nodeMap:t,nodes:e,edges:n}){e.forEach(r=>{r._node_type!=="view-root"||r._view_type!==L.Tabs||(r.sourcePosition=ve.Position.Bottom,r.style.width=vi+hs*2,r.style.height=Mc+r._tab_view_ids.reduce((i,a)=>{const l=t[a];l.position.y=i,l.position.x=hs;const c=l.style.height;return i+c+20},bi))})}function Pk({nodeMap:t,nodes:e,edges:n}){n.filter(r=>r.label==="Open View").forEach(r=>{const i=t[r.source],a=t[r.target];if(!i||!a||!i.parentNode)return;const l=t[i.parentNode];l._node_type!=="view-root"||a._node_type!=="view-root"||(a._view_level+=1+l._view_level,l._sub_view_ids.push(a.id))}),e.sort((r,i)=>r._node_type==="view-root"&&i._node_type==="view-root"?r._view_level-i._view_level:r._node_type!=="view-root"&&i._node_type!=="view-root"?0:r._node_type==="view-root"?-1:1)}function $k({nodeMap:t,nodes:e,edges:n}){const r={};n.forEach(i=>{if(i.label!=="Open View")return;const a=t[i.source],l=t[i.target];if(a&&l&&a.parentNode){const c=t[a.parentNode],u=c.position.x,d=Number(x.get(l,"style.height",0)),h=Number(c.style.width);l.position.x=u+h+kk,c._view_level===0&&l._sub_view_ids.length===0&&(a.sourcePosition=ve.Position.Left,l.targetPosition=ve.Position.Right,l.position.x*=-1);const g=l.position.x,y=x.get(r,g,0);l.position.y=y,r[g]=y+d+Ec}})}function qk({nodeMap:t,nodes:e,edges:n}){const r=new Set,i=new Set;n.forEach(l=>{r.add(l.source),i.add(l.target)}),e.filter(l=>l._node_type!=="view-root"||l.id==="Main"||l.parentNode?!1:!r.has(l.id)&&!i.has(l.id)).forEach((l,c)=>{l.position.x=Ic(c,vi,Sk),l.position.y=0-Ck-Ec})}function Lk({nodeMap:t,nodes:e,edges:n}){const r={nodeMap:t,nodes:e,edges:n};return qk(r),Pk(r),Ak(r),$k(r),{nodes:e,edges:n}}function Bk(t){const e=Ek(t),n=x.keyBy(e,u=>u.id),{edges:r,edgeNodes:i}=jk(t,n),a=[...e,...i],l=x.keyBy(a,u=>u.id),c={edges:x.uniqBy(r,u=>u.id),nodes:a,nodeMap:l};return Lk(c)}const iI="",_i={"builtin:op:open-link":s.jsx(o.ThemeIcon,{color:"blue",size:20,radius:"xl",children:s.jsx(k.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":s.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:s.jsx(k.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":s.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:s.jsx(k.IconCircleOff,{size:14})})};function Ok(t){const e=[];return t.forEach(n=>{switch(n.schemaRef){case"builtin:op:open-link":e.push({key:n.urlTemplate,icon:_i[n.schemaRef],text:s.jsxs(o.Group,{spacing:4,children:[s.jsx(o.Text,{children:"Open: "}),s.jsx(o.Text,{color:"dimmed",children:n.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":n.filters.forEach(({key:r,label:i})=>{e.push({key:n.schemaRef+r,icon:_i[n.schemaRef],text:s.jsx(o.Group,{spacing:4,children:s.jsxs(o.Text,{children:["Set Filter: ",i]})})})});return;case"builtin:op:clear_filter_values":n.filters.forEach(({key:r,label:i})=>{e.push({key:n.schemaRef+r,icon:_i[n.schemaRef],text:s.jsx(o.Group,{spacing:4,children:s.jsxs(o.Text,{children:["Clear Filter: ",i]})})})});return}}),e}const Vk=m.memo(({data:t,isConnectable:e,sourcePosition:n=ve.Position.Right,targetPosition:r=ve.Position.Left,...i})=>{const a=m.useMemo(()=>Ok(t.interactions),[t.interactions]);return s.jsxs(s.Fragment,{children:[s.jsx(ve.Handle,{type:"target",position:r,isConnectable:e}),s.jsx(o.Box,{sx:{position:"absolute",top:0,right:0},children:s.jsx(q.ChevronsUpRight,{size:12})}),s.jsxs(o.HoverCard,{shadow:"xl",withinPortal:!0,children:[s.jsx(o.HoverCard.Target,{children:s.jsx(o.Text,{children:t.label})}),s.jsx(o.HoverCard.Dropdown,{children:s.jsx(o.List,{spacing:"xs",size:"sm",center:!0,children:a.map(l=>s.jsx(o.List.Item,{icon:l.icon,children:l.text},l.key))})})]}),s.jsx(ve.Handle,{type:"source",position:n,isConnectable:e})]})}),aI="",Nk={interaction:Vk},Fk=S.observer(()=>{const t=de(),{edges:e,nodes:n}=Bk(t);return s.jsxs(ve,{nodes:n,edges:e,onNodesChange:x.noop,onEdgesChange:x.noop,onConnect:x.noop,className:"interactions-viewer",fitView:!0,nodeTypes:Nk,children:[s.jsx(ve.MiniMap,{}),s.jsx(ve.Controls,{}),s.jsx(ve.Background,{})]})}),Gk=S.observer(({opened:t,close:e})=>{const{t:n}=_.useTranslation();return s.jsx(o.Modal,{size:"96vw",opened:t,onClose:e,title:n("interactions.interactions_viewer"),trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{body:{height:"calc(90vh - 54px)"},content:{transform:"none !important"}},zIndex:300,children:s.jsx(Fk,{})})}),Wk={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}};function Qk({onClick:t,name:e,active:n,openSettings:r}){return s.jsxs(o.Box,{sx:{position:"relative"},children:[s.jsx(o.UnstyledButton,{sx:i=>({display:"block",width:"100%",padding:i.spacing.xs,borderRadius:0,position:"relative",color:i.black,"&:hover":{backgroundColor:i.colors.gray[0]},backgroundColor:n?i.colors.gray[2]:"transparent"}),children:s.jsx(o.Group,{sx:{width:"calc(100% - 28px)"},onClick:t,children:s.jsx(o.Text,{size:"sm",children:e})})}),n&&s.jsx(o.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:s.jsx(o.ActionIcon,{onClick:r,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:s.jsx(k.IconAdjustments,{size:16})})})]})}const Rk=S.observer(()=>{const{t}=_.useTranslation(),e=X(),n=W(),r=m.useCallback(a=>()=>n.views.setIDOfVIE(a),[n]),i=a=>{e.editor.open(["_VIEWS_",a])};return s.jsxs(o.Box,{sx:{position:"relative"},children:[n.views.options.map(a=>s.jsx(Qk,{active:n.views.idOfVIE===a.value,name:a.label,onClick:r(a.value),openSettings:()=>i(a.value)},a.value)),s.jsx(o.Divider,{variant:"dashed"}),s.jsx(o.Button,{variant:"subtle",rightIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:n.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:t("view.add")})]})}),Yk=S.observer(()=>{const{t}=_.useTranslation(),e=X(),n=W(),r=()=>{if(!n.queries.firstID){e.editor.open(["_QUERIES_",""]);return}e.editor.open(["_QUERIES_",n.queries.firstID])},i=()=>{if(!n.filters.firstID){e.editor.open(["_FILTERS_",""]);return}e.editor.open(["_FILTERS_",n.filters.firstID])},[a,l]=m.useState(!1),c=()=>l(!0),u=()=>l(!1);return s.jsxs(o.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},zIndex:299,children:[s.jsxs(o.Navbar.Section,{children:[s.jsxs(o.Group,{grow:!0,spacing:0,sx:{...Wk,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[s.jsx(o.Tooltip,{label:t("filter.labels"),withinPortal:!0,children:s.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:i,children:s.jsx(k.IconFilter,{size:18})})}),s.jsx(o.Tooltip,{label:t("query.labels"),withinPortal:!0,children:s.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:r,children:s.jsx(k.IconDatabase,{size:18})})}),s.jsx(o.Tooltip,{label:t("interactions.interactions_viewer"),withinPortal:!0,children:s.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:c,children:s.jsx(k.IconLink,{size:18})})})]}),s.jsx(Gk,{opened:a,close:u})]}),s.jsx(o.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:s.jsx(o.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:t("view.labels")})}),s.jsx(o.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:s.jsx(Rk,{})}),s.jsx(o.Navbar.Section,{children:s.jsx(o.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:s.jsx(o.Button,{size:"xs",leftIcon:s.jsx(k.IconSettings,{size:20}),onClick:()=>e.editor.open([]),children:t("common.titles.settings")})})})]})}),Uk=["function getDefaultValue(filter, utils, context) {",' return "";',"}"].join(`
|
|
448
|
+
`}})).actions(t=>({setPage(e){t.page=e},resetPage(){t.page=1},setLimit(e){t.limit=e}})).actions(t=>({afterCreate(){f.addDisposer(t,U.reaction(()=>t.keywordString,t.resetPage,{fireImmediately:!1,delay:0})),f.addDisposer(t,U.reaction(()=>t.limit,t.resetPage,{fireImmediately:!1,delay:0}))}})),QS=f.types.model({data:f.types.optional(f.types.frozen(),{}),state:f.types.optional(f.types.enumeration(["idle","loading","error"]),"idle"),error:f.types.frozen()}).views(t=>({get loading(){return t.state==="loading"},get empty(){return Object.keys(t.data).length===0}})),RS=f.types.compose("DataSourceModel",ei,f.types.model({tables:f.types.optional(QS,{}),columns:f.types.optional(FS,{}),tableData:f.types.optional(WS,{}),indexes:f.types.optional(GS,{}),table_schema:f.types.optional(f.types.string,""),table_name:f.types.optional(f.types.string,"")})).views(t=>({get sqlDataSourceType(){return t.type},get reloadConditionString(){const{type:e,table_name:n,table_schema:r}=t;return`${e};${n};${r}`}})).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(t=>({setKeywords(e,n){t.table_schema=e,t.table_name=n}})).actions(t=>({initKeywords(){if(t.tables.empty)return;const e=Object.keys(t.tables.data)[0],n=t.tables.data[e][0].table_name;t.setKeywords(e,n)}})).actions(t=>{const e=f.flow(function*(){var n;(n=t.controllers.tables)==null||n.abort(),t.controllers.tables=new AbortController,t.tables.state="loading";try{const r=yield*f.toGenerator(et.structure(t.controllers.tables.signal)({query_type:"TABLES",type:t.sqlDataSourceType,key:t.key,table_schema:"",table_name:""},{params:{query_type:"TABLES"}}));t.tables.data=x.groupBy(r,"table_schema"),t.tables.state="idle",t.tables.error=null,t.initKeywords()}catch(r){if(!at.isCancel(r)){t.tables.data={};const i=x.get(r,"message","unkown error");t.tables.error=x.get(r,"response.data.detail.message",i),t.tables.state="error"}}});return{loadTables:e,loadTablesIfEmpty(){t.tables.empty&&e()},loadColumns:f.flow(function*(){var n;(n=t.controllers.columns)==null||n.abort(),t.controllers.columns=new AbortController,t.columns.state="loading";try{t.columns.data=yield*f.toGenerator(et.structure(t.controllers.columns.signal)({query_type:"COLUMNS",type:t.sqlDataSourceType,key:t.key,table_schema:t.table_schema,table_name:t.table_name},{params:{query_type:"COLUMNS"}})),t.columns.state="idle",t.columns.error=null}catch(r){if(at.isCancel(r))t.columns.state="idle",t.columns.error=null;else{t.columns.data=[];const i=x.get(r,"message","unkown error");t.columns.error=x.get(r,"response.data.detail.message",i),t.columns.state="error"}}}),loadIndexes:f.flow(function*(){var n;(n=t.controllers.indexes)==null||n.abort(),t.controllers.indexes=new AbortController,t.indexes.state="loading";try{t.indexes.data=yield*f.toGenerator(et.structure(t.controllers.indexes.signal)({query_type:"INDEXES",type:t.sqlDataSourceType,key:t.key,table_schema:t.table_schema,table_name:t.table_name},{params:{query_type:"INDEXES"}})),t.indexes.state="idle",t.indexes.error=null}catch(r){if(at.isCancel(r))t.indexes.state="idle",t.indexes.error=null;else{t.indexes.data=[];const i=x.get(r,"message","unkown error");t.indexes.error=x.get(r,"response.data.detail.message",i),t.indexes.state="error"}}}),loadTableData:f.flow(function*(){var r;(r=t.controllers.tableData)==null||r.abort(),t.controllers.tableData=new AbortController;const n=t.tableData;n.state="loading";try{n.data=yield*f.toGenerator(et.structure(t.controllers.tableData.signal)({query_type:"DATA",type:t.sqlDataSourceType,key:t.key,table_schema:t.table_schema,table_name:t.table_name,limit:n.limit,offset:n.offset},{params:{query_type:"DATA"}}));const[{total:i}]=yield*f.toGenerator(et.structure(t.controllers.tableData.signal)({query_type:"COUNT",type:t.sqlDataSourceType,key:t.key,table_schema:t.table_schema,table_name:t.table_name},{params:{query_type:"COUNT"}}));n.total=Number(i),n.state="idle",n.error=null}catch(i){if(at.isCancel(i))n.state="idle",n.error=null;else{n.data=[];const a=x.get(i,"message","unkown error");n.error=x.get(i,"response.data.detail.message",a),n.state="error"}}})}}).actions(t=>({afterCreate(){f.addDisposer(t,U.reaction(()=>t.reloadConditionString,t.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(t=>({afterCreate(){f.addDisposer(t,U.reaction(()=>t.reloadConditionString,t.loadIndexes,{fireImmediately:!1,delay:500})),f.addDisposer(t,U.reaction(()=>`${t.reloadConditionString};limit:${t.tableData.limit};offset:${t.tableData.offset}`,t.loadTableData,{fireImmediately:!1,delay:0}))}})),YS=f.types.model("DataSourcesModel",{list:f.types.optional(f.types.array(RS),[])}).views(t=>({find({type:e,key:n}){return t.list.find(r=>r.key===n&&r.type===e)},get options(){return t.list.map(e=>({value:e.key,label:e.key}))}})).actions(t=>({replace(e){t.list.length=0,t.list.push(...e)}}));function At(t){return{label:t,value:t,_type:"ACTION",_action_type:t,Icon:null,children:null}}function US(t){switch(t._type){case"GROUP":case"ACTION":return null;case"query_variables":return["_QUERY_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",t.value];case"sql_snippet":return["_SQL_SNIPPETS_",t.value];case"query":return["_QUERIES_",t.value];case"view":return["_VIEWS_",t.value];case"panel":return t.parentID?["_VIEWS_",t.parentID,"_PANELS_",t.value]:(console.error("[getPathFromOption] parentID is required"),null)}}const KS=f.types.model("EditorModel",{path:f.types.optional(f.types.frozen(),[]),settings_open:f.types.optional(f.types.boolean,!1)}).views(t=>({get navOptions(){const{content:e}=f.getRoot(t),{filters:n,views:r,sqlSnippets:i,queries:a}=e;return[{label:"query_variable.labels",value:"_QUERY_VARS_",_type:"query_variables",Icon:k.IconVariable},{label:"mock_context.label",value:"_MOCK_CONTEXT_",Icon:k.IconCodeDots,_type:"mock_context"},{label:"filter.labels",value:"_FILTERS_",Icon:k.IconFilter,children:[At("_FILTERS_SETTINGS_"),...n.options,At("_Add_A_Filter_")],_type:"GROUP"},{label:"sql_snippet.labels",value:"_SQL_SNIPPETS_",Icon:k.IconCopy,children:[At("_SQL_SNIPPETS_SETTINGS_"),...i.options,At("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"query.labels",value:"_QUERIES_",Icon:k.IconDatabase,children:[At("_QUERIES_SETTINGS_"),...a.options,At("_Add_A_QUERY_")],_type:"GROUP"},{label:"view.labels",value:"_VIEWS_",Icon:k.IconBoxMultiple,children:[...r.editorOptions,At("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(e,n){return e.length===0?!1:e[e.length-1]===n.value},isOptionOpened(e){const{path:n}=t;return n.length===0||!e.children||e.children.length===0?!1:n.includes(e.value)}})).actions(t=>({setPath(e){t.path=e},setSettingsOpen(e){t.settings_open=e}})).actions(t=>({open(e){t.setPath(e),t.setSettingsOpen(!0)},close(){t.setSettingsOpen(!1)},navigate(e){const n=US(e);n&&t.setPath(n)}})),JS=f.types.compose("LayoutsModel",di,f.types.model({currentLayoutWrapperWidth:f.types.optional(f.types.number,0)})).views(t=>({get divisionPreviewScale(){const e=t.currentLayoutPreviewWidth,n=t.currentLayoutWrapperWidth;return!e||!n||e<=n?1:n/e}})).actions(t=>({addALayoutItem(e){t.list.forEach(n=>{n.addNewLayout(e)})},duplicateLayoutItemsByPanelID(e,n){t.list.forEach(r=>{const i=r.findByPanelID(e);if(!i){console.error(`Can't find a layout item by panelID[${e}] in layoutSet[${r.name}]`);return}r.list.push({...i,id:vt.v4(),panelID:n,y:1/0})})},removeByPanelID(e){t.list.forEach(n=>{n.removeByPanelID(e)})},setCurrentLayoutWrapperWidth(e){t.currentLayoutWrapperWidth=e},addALayoutSet(e,n,r){const i=t.basisLayoutSet,a={id:e,name:n,breakpoint:r,list:i.json.list.map(l=>({...l,id:vt.v4()}))};t.list.push(a)},updateLayoutSetsInfo(e){const n=x.keyBy(t.list,"id");e.forEach(a=>{const l=n[a.id];if(l){l.setName(a.name),l.setBreakpoint(a.breakpoint),delete n[a.id];return}this.addALayoutSet(a.id,a.name,a.breakpoint)});const r=new Set(Object.keys(n)),i=r.size>0;r.forEach(a=>{const l=t.list.findIndex(c=>c.id===a);t.list.splice(l,1)}),i&&t.setCurrentBreakpoint("basis")},updateCurrentLayoutItem(e){t.currentLayoutSet.updateLayoutItem(e)},append(e){t.list.push(e)},appendMultiple(e){e.length!==0&&t.list.push(...e)},remove(e){t.list.splice(e,1)},removeByID(e){const n=t.list.findIndex(r=>r.id===e);n!==-1&&t.list.splice(n,1)},removeByIDs(e){e.forEach(n=>{this.removeByID(n)})}})),yc=ii.views(t=>({get realDataFieldOptions(){return t.queryIDs.length===0?[]:t.queries.map(e=>{const n=e.data;return n.length===0?[]:Object.keys(n[0]).map(i=>({label:i,value:`${e.id}.${i}`,group:e.name,disabled:!1}))}).flat()},get realQueryOptions(){return t.queryIDs.length===0?[]:t.queries.map(e=>({label:e.name,value:e.id,disabled:!1}))},queryOptions(e,n){const r=[...this.realQueryOptions];return e&&!r.find(i=>i.value===e)&&r.unshift({label:e,value:e,disabled:!0}),n&&r.unshift({label:"unset",value:"",disabled:!1}),r},dataFieldOptions(e,n,r){let i=[...this.realDataFieldOptions];if(r&&(i=i.filter(a=>a.group===r)),e&&!i.find(a=>a.value===e)){const a=E(e),l=t.queryByID(a.queryID);i.unshift({label:a.columnKey,value:e,group:l?l.name:a.queryID,disabled:!0})}return n&&i.unshift({label:"unset",value:"",group:"",disabled:!1}),i},explainDataKey(e){const{queryID:n,columnKey:r}=E(e),i=t.queries.find(a=>a.id===n);return i?{queryID:n,queryName:i.name,columnKey:r}:{queryID:n,queryName:null,columnKey:r}}})).actions(t=>({removeSelf(){f.getParent(t,2).removeByID(t.id)}})).actions(t=>({moveToView(e,n){f.getRoot(t).content.views.findByID(e).removePanelID(t.id),f.getRoot(t).content.views.findByID(n).appendPanelID(t.id),f.getRoot(t).editor.setPath(["_VIEWS_",n,"_PANELS_",t.id])}})),bc=f.types.compose("PanelsModel",ai,f.types.model({list:f.types.optional(f.types.array(yc),[])})).views(t=>({get contentModel(){return f.getRoot(t).content},editorOptions(e,n){const r=t.panelsByIDs(n);r.length!==n.length&&console.warn(`Unfulfilled panels for View[${e}]`);const i=r.map(l=>({label:l.name,value:l.id,_type:"panel",parentID:e})),a="_Add_A_PANEL_";return i.push({label:a,value:a,_type:"ACTION",_action_type:a,parentID:e,Icon:null,children:null}),i}})).actions(t=>({replace(e){t.list=f.castToSnapshot(e)},append(e){t.list.push(e)},appendMultiple(e){e.length!==0&&t.list.push(...e)},remove(e){t.list.splice(e,1)},removeByID(e){const n=t.list.findIndex(r=>r.id===e);n!==-1&&t.list.splice(n,1)},removeByIDs(e){e.forEach(n=>{this.removeByID(n)})},duplicateByID(e){const n=t.list.find(i=>i.id===e);if(!n){console.error(new Error(`[duplicate panel] Can't find a panel by id[${e}]`));return}const r=new Date().getTime().toString();return t.list.push({...n.json,id:r,title:{...n.json.title}}),t.contentModel.layouts.duplicateLayoutItemsByPanelID(n.id,r),r},replaceByIndex(e,n){t.list.splice(e,1,n)}})),XS=si.actions(t=>({getSchema(){const e=t.json,n=[],r=[];t.panels.forEach(l=>{const c=l.getSchema();n.push(c.panel),c.queries.length>0&&r.push(...c.queries)});const i=t.contentModel.layouts.jsonByPanelIDSet(new Set(t.panelIDs));return{views:[e],panels:n,definition:{queries:x.uniqBy(r,l=>l.id)},layouts:i,version:mt}},downloadSchema(){if(t.type===L.Tabs){console.error(new Error("Please choose a tab first"));return}const e=JSON.stringify(this.getSchema(),null,2),n=t.name;Ut(n,e)}})),vc=f.types.compose("ViewsModel",ri,f.types.model({current:f.types.optional(f.types.array(XS),[]),idOfVIE:f.types.string})).views(t=>({get isVIETheFirstView(){return t.current.length===0||!t.idOfVIE?!1:t.current[0].id===t.idOfVIE},get VIE(){return t.current.find(({id:e})=>e===t.idOfVIE)},get options(){return t.current.map(e=>({label:e.name,value:e.id,type:e.type}))},get editorOptions(){const e=f.getRoot(t).content.panels;return t.current.map(n=>({label:n.name,value:n.id,_type:"view",children:e.editorOptions(n.id,n.panelIDs)}))}})).actions(t=>({setIDOfVIE(e){t.idOfVIE=e,t.visibleViewIDs.length=0,t.visibleViewIDs.push(e)},replace(e){t.current.replace(e)},addANewView(e,n,r,i){t.current.push({id:e,name:n,type:r,config:i,panelIDs:[]})},append(e){t.current.push(e)},appendMultiple(e){e.length!==0&&t.current.push(...e)},remove(e){t.current.splice(e,1)},removeByID(e){const n=t.current.findIndex(a=>a.id===e);if(n===-1)return;const r=t.current[n];f.getRoot(t).content.panels.removeByIDs(r.panelIDs),t.current.splice(n,1)},replaceByIndex(e,n){t.current.splice(e,1,n)},addARandomNewView(){const e=new Date().getTime().toString();this.addANewView(e,L.Division,L.Division,{_name:L.Division}),this.setIDOfVIE(e)},removeVIE(){t.current.length!==1&&(this.removeByID(t.idOfVIE),this.setIDOfVIE(t.current[0].id))}}));function xi(t){const e=t.length>0?[t[0].id]:[],n=t.length>0?t[0].id:"";return{current:t.map(i=>{const{_name:a=i.type}=i.config;return{...i,config:{...i.config,_name:a},panelIDs:i.panelIDs}}),visibleViewIDs:e,idOfVIE:n}}const ZS=f.types.model({id:f.types.string,name:f.types.string,dashboard_id:f.types.string,create_time:f.types.string,update_time:f.types.string,version:f.types.string,filters:mc,queries:gc,sqlSnippets:xc,views:vc,panels:bc,layouts:JS,mock_context:Vr,origin:f.types.maybe(f.types.frozen())}).views(t=>({get json(){return{id:t.id,name:t.name,create_time:t.create_time,update_time:t.update_time,dashboard_id:t.dashboard_id,content:{views:t.views.json,panels:t.panels.json,filters:t.filters.json,version:t.version,layouts:t.layouts.json,definition:{queries:t.queries.json,sqlSnippets:t.sqlSnippets.json,mock_context:t.mock_context.current}}}},get contentJSON(){return this.json.content},get filtersChanged(){const e="filters.current";return!x.isEqual(f.getSnapshot(x.get(t,e)),x.get(t.origin,e))},get queriesChanged(){const e="queries.current",n=f.getSnapshot(x.get(t,e)).map(r=>x.pick(r,["id","name","key","type","sql","run_by","react_to","pre_process","post_process","dep_query_ids"]));return!x.isEqual(n,x.get(t.origin,e))},get sqlSnippetsChanged(){const e="sqlSnippets.current";return!x.isEqual(f.getSnapshot(x.get(t,e)),x.get(t.origin,e))},get viewsChanged(){const e="views.current";return!x.isEqual(t.views.json,x.get(t.origin,e))},get panelsChanged(){const e="panels.list";return!x.isEqual(f.getSnapshot(x.get(t,e)),x.get(t.origin,e))},get layoutsChanged(){const e="layouts.list";return!x.isEqual(f.getSnapshot(x.get(t,e)),x.get(t.origin,e))},get mockContextChanged(){const e="mock_context.current";return!x.isEqual(x.get(t,e),x.get(t.origin,e))},get context(){const e=f.getParent(t).context.current;return{...t.mock_context.current,...e}},get payloadForSQL(){const e=f.getParent(t).globalSQLSnippets,n={context:this.context,filters:t.filters.values};return{...n,sql_snippets:gn(t.sqlSnippets.current,"key","value",n),global_sql_snippets:gn(e.list,"id","content",n)}},get payloadForViz(){const e=f.getParent(t).context.current;return{context:{...t.mock_context.current,...e},filters:t.filters.values}},get dashboardState(){return Ts(this.payloadForSQL)},getAdditionalQueryInfo(e){return{content_id:t.id,query_id:e,params:this.dashboardState}},get changed(){return this.filtersChanged||this.queriesChanged||this.sqlSnippetsChanged||this.viewsChanged||this.panelsChanged||this.layoutsChanged||this.mockContextChanged},get data(){return t.queries.current.map(({id:n,data:r})=>({id:n,data:r})).reduce((n,r)=>(n[r.id]=r.data,n),{})},getDataStuffByID(e){const n=t.queries.findByID(e);return n?{data:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).views(t=>({get queriesUsage(){const e=t.panels.idMap,n=[];t.views.current.forEach(i=>{i.panelIDs.forEach(a=>{const l=e.get(a);if(!l)return;const c="panel",u=l.name,d=[{id:i.id,label:i.name}];l.queryIDs.forEach(h=>{n.push({id:a,queryID:h,type:c,type_label:"panel.label",label:u,views:d})})})});const r=t.views.idMap;return t.filters.current.filter(i=>!!x.get(i,"config.options_query_id")).forEach(i=>{n.push({type:"filter",type_label:"filter.label",id:i.id,queryID:x.get(i,"config.options_query_id"),label:i.label,views:i.visibleInViewsIDs.map(a=>{var l;return{id:a,label:((l=r.get(a))==null?void 0:l.name)??a}})})}),t.queries.current.forEach(i=>{i.isTransform&&i.dep_query_ids.forEach(a=>{n.push({type:"transform-query",type_label:"query.transform.full_label",id:i.id,queryID:a,label:i.name,views:[]})})}),x.groupBy(n,"queryID")},get hasUnusedQueries(){return t.queries.current.length>Object.keys(this.queriesUsage).length},findQueryUsage(e){return this.queriesUsage[e]??[]},get sqlSnippetsUsage(){const e=[];return t.queries.current.forEach(n=>{if(!n.typedAsSQL)return;x.uniq(n.sql.match(zn.sqlSnippet)).forEach(i=>{e.push({queryID:n.id,sqlSnippetKey:i,queryName:n.name})})}),x.groupBy(e,"sqlSnippetKey")},get hasUnusedSQLSnippets(){return t.sqlSnippets.current.length>Object.keys(this.sqlSnippetsUsage).length},findSQLSnippetUsage(e){return this.sqlSnippetsUsage[e]??[]}})).actions(t=>({removeUnusedQueries(){const e=new Set(Object.keys(t.queriesUsage)),n=t.queries.current.filter(r=>!e.has(r.id)).map(r=>r.id);t.queries.removeQueries(n)},removeUnusedSQLSnippets(){const e=new Set(Object.keys(t.sqlSnippetsUsage)),n=t.sqlSnippets.current.filter(r=>!e.has(r.key)).map(r=>r.key);t.sqlSnippets.removeByKeys(n)},duplicatePanelByID(e,n){var i;const r=t.panels.duplicateByID(e);r&&((i=t.views.findByID(n))==null||i.appendPanelID(r))},removePanelByID(e,n){var r;t.panels.removeByID(e),t.layouts.removeByPanelID(e),(r=t.views.findByID(n))==null||r.removePanelID(e)},addANewPanel(e){var r;const n=vt.v4();t.panels.append(Nl(n)),(r=t.views.findByID(e))==null||r.appendPanelID(n),t.layouts.addALayoutItem(n)},applyJSONSchema(e){var p;const{views:n,panels:r,filters:i,definition:a={},layouts:l}=e,{queries:c,sqlSnippets:u,mock_context:d}=a,h=new Map;if(Array.isArray(r)){const g=r.map(y=>{const v=vt.v4();return h.set(y.id,v),{...y,id:v}});if(t.panels.appendMultiple(g),!Array.isArray(n)||n.length===0){const y=g.map(v=>v.id);(p=t.views.VIE)==null||p.appendPanelIDs(y)}}if(Array.isArray(n)){const g=n.map(y=>{const v=y.panelIDs.map(C=>h.get(C)??C);return{...y,id:vt.v4(),panelIDs:v}});t.views.appendMultiple(g)}if(Array.isArray(l)){const g=(C,T)=>t.layouts.breakpointNameRecord[C]===T;let y=[];const v=l.filter(C=>g(C.name,C.breakpoint));v.forEach(C=>{C.id==="basis"&&(y=C.list),C.list.forEach(T=>{const D=h.get(T.panelID);T.id=vt.v4(),T.panelID=D})}),t.layouts.list.forEach(C=>{const T=v.find(D=>D.name===C.name&&D.breakpoint===C.breakpoint);if(!T){y.forEach(D=>{C.addLayout(D)});return}T.list.forEach(D=>{C.addLayout(D)})})}Array.isArray(i)&&t.filters.appendMultiple(i),Array.isArray(c)&&t.queries.appendMultiple(c),Array.isArray(u)&&t.sqlSnippets.appendMultiple(u),d&&Object.keys(d).length>0&&t.mock_context.defaults(d)}})).actions(t=>({reset(){f.applySnapshot(t.filters.current,t.origin.filters.current),f.applySnapshot(t.queries.current,t.origin.queries.current),f.applySnapshot(t.sqlSnippets.current,t.origin.sqlSnippets.current),f.applySnapshot(t.views.current,t.origin.views.current),f.applySnapshot(t.panels.list,t.origin.panels.list),f.applySnapshot(t.layouts.list,t.origin.layouts.list),t.mock_context.current=t.origin.mock_context.current},resetFilters(){f.applySnapshot(t.filters.current,t.origin.filters.current)},updateCurrent(e){const{id:n,name:r,content:i}=e;if(!i)throw new Error("unexpected null content when updating a content model");const{version:a,filters:l,views:c,panels:u,definition:{queries:d,sqlSnippets:h,mock_context:p={}}}=i;t.id=n,t.name=r,t.version=a,f.applySnapshot(t.filters.current,l),f.applySnapshot(t.views.current,xi(c).current),f.applySnapshot(t.panels.list,u),f.applySnapshot(t.queries.current,d),f.applySnapshot(t.sqlSnippets.current,h),t.mock_context.current=p}})),yi=f.types.snapshotProcessor(ZS,{preProcessor(t){return{...t,origin:t}},postProcessor(t){delete t.origin;const e=f.castToSnapshot(t.queries.current.map(n=>x.pick(n,["id","key","type","sql"])));return x.defaults({},{queries:{current:e}},t)}});function HS(t,e){e.filters&&f.applySnapshot(t.filters.current,e.filters)}function _c({id:t,name:e,dashboard_id:n,create_time:r,update_time:i,content:a},l,c){if(!a)throw new Error("unexpected null content when creating a content model");const{version:u,filters:d,views:h,panels:p,layouts:g,definition:{queries:y,sqlSnippets:v,mock_context:C={}}}=a;return yi.create({id:t,name:e,dashboard_id:n,create_time:r,update_time:i,version:u,filters:li(d,l,C,c),queries:{current:y},sqlSnippets:{current:v},mock_context:Nr(C),views:xi(h),panels:{list:p},layouts:{list:g,currentBreakpoint:g[0].id}})}const jc=f.types.model({id:f.types.identifier,name:f.types.string,group:f.types.string,content:yi,content_id:f.types.string,datasources:YS,globalSQLSnippets:ti,context:os,editor:KS}).views(t=>({get json(){return{id:t.id,name:t.name,group:t.group,content_id:t.content_id}}})).actions(t=>({updateCurrentContent(e){t.content.updateCurrent(e)},updateCurrent(e,n){const{id:r,name:i,group:a,content_id:l}=e;t.id=r,t.name=i,t.group=a,t.content_id=l,this.updateCurrentContent(n)}}));function wc({id:t,name:e,group:n,content_id:r},i,a,l,c,u){return jc.create({id:t,name:e,group:n,content_id:r,content:_c(i,c,u),datasources:{list:a},globalSQLSnippets:{list:l},context:ni(c),editor:{}})}const ek={translation:{filter:{label:"Filter",labels:"Filters",add:"Add a Filter",manage:"Manage Filters",show_filters:"Show Filters",hide_filters:"Hide Filters",field:{widget:"Widget",visible_in:"Visible in...",key_placeholder:"A unique key to refer",label_placeholder:"Label for this field",auto_submit:"Submit automatically",order:"Placement Order",custom_default_value:{trigger:"Custom",title:"Custom default value",tips:"Tips",tip_1:"Function has the highest priority of getting filter's default value",tip_2:"Leave this editor empty to disable this feature"}},widget:{names:{select:"Select",multi_select:"Multi Select",tree_select:"Tree Select",text_input:"Text Input",checkbox:"Checkbox",date_range:"Date Range"},common:{use_query_data_as_options:"Use query data as options",fetch_options_from_datasource:"Fetch options from datasource",or_fetch_options_from_datasource:"Or fetch options from datasource",selector_option_empty:"Not found",see_data_structure:"Click to see expected data structure",using_query:"Using query",default_selection_count:"Select first N options by default",min_width:"Min width",x_selected:"{{count}} selected"},text_input:{default_value:"Default Value",required:"Required"},select:{width:"Width",required:"Required",clearable:"Clearable",configure_options:"Configure options",default_selection:"Default Selection",no_default_selection:"none",select_first_option_by_default:"Select the first option by default"},multi_select:{width_description:"At least 160px"},tree_select:{strictly:"Parent and children nodes are not associated"},checkbox:{description:"Description",default_checked:"Default checked"},date_range:{required:"Required",allow_single_date:"Allow choosing 1 day",display_format:"Display format",max_days:"Max days",one_day:"1 day",x_days:"{{count}} days",x_max_days:"{{max_days}} days max",default_value:"Default value",default_by_shortcut:"Default by shortcut",defualt_by_shortcut_placeholder:"Priors default value",start_date:"Start date",end_date:"End date",shortcut:{last:{label:"last",d:"yesterday",w:"week",m:"month",m2:"2 months",m3:"3 months",y:"year",full:{d:"yesterday",w:"last week",m:"last month",m2:"last 2 months",m3:"last 3 months",y:"last year"}},recent:{label:"recent",d7:"7 days",d30:"30 days",d60:"60 days",d90:"90 days",d180:"180 days",d365:"365 days",full:{d7:"recent 7 days",d30:"recent 30 days",d60:"recent 60 days",d90:"recent 90 days",d180:"recent 180 days",d365:"recent 365 days"}},this:{label:"this",d:"today",w:"week",m:"month",y:"year",full:{d:"today",w:"this week",m:"this month",y:"this year"}},this_so_far:{label:"this...so far",w:"week",m:"month",y:"year",full:{w:"this week so far",m:"this month so far",y:"this year so far"}}}}}},view:{label:"View",labels:"Views",add:"Add a View",delete:"Delete this View",download_schema:"Download this View",component:{div:{label:"Division"},tabs:{label:"Tabs",tabs_settings:"Tabs Settings",tab:{name:"Tab Name",view:"View",order:"Placement Order",color:"Color",delete:"Delete this tab",switch_to_view:"Swith to View: {{name}}"}},modal:{label:"Modal",modal_settings:"Modal settings",title:"Modal Title",custom_title:"Customize modal title",width:"Width",height:"Height"}}},interactions:{label:"Interactions",add:"Add an interaction",interactions_viewer:"Interactions Viewer",unavailable:"Unavailable",unavailable_reason:"This visualization does not have available interactions to choose from",trigger:{setup:"Setup Trigger",label:"Trigger",payload:"Payload"},operation:{setup:"Operation Settings",label:"Operation",settings:"Settings",variables:"Variables",console_log:{label:"console.log | debug",log_content:"log content"},open_link:{label:"Open Link",url:"URL",open_in_new_tab:"Open in new tab"},open_view:{label:"Open View",view:"View"},set_filter_values:{label:"Set Filter Values",set_filter:"Set filter",with:"with"},clear_filter_values:{label:"Clear Filter Values",select_filter:"Select filters to clear"}}},query_variable:{label:"Query Variable",labels:"Query Variables",add:"Add a Variable",guide:{tabs:{guide:"Guide",variables_in_this_dashboard:"Variables in this dashboard",global_sql_snippets:"Global SQL Snippets"}},open:"See Query Variables"},sql_snippet:{label:"SQL Snippet",labels:"SQL Snippets",add:"Add a SQL Snippet",delete:"Delete this SQL Snippet",delete_unused:"Delete unused SQL Snippets",manage:"Manage SQL Snippets",key:"Key",key_occupied:"This key is occupied by another snippet",edit_snippet:"Edit SQL Snippet",preview_snippet:"Preview SQL Snippet",usage:{label:"Usage"}},global_sql_snippet:{label:"Global SQL Snippet",labels:"Global SQL Snippets",description:"SQL snippets worth sharing between dashboards are managed in System Settings by admins."},common:{titles:{settings:"Settings",edit:"Edit",config:"Config"},pagination:{page_size:"Page Size",total:"Total",total_rows:"Total {{total}} row(s)"},align:{horizontal:{label:"Horizontal Align",left:"left",center:"center",right:"right"},vertical:{label:"Vertical Align",left:"top",center:"center",right:"bottom"}},id:"ID",name:"Name",key:"Key",label:"Label",value:"Value",type:"Type",info:"Info",min:"Min",max:"Max",data_field:"Data Field",name_data_field:"Name Data Field",value_data_field:"Value Data Field",color_data_field:"Color Data Field",enabled:"Enabled",copied:"Copied to clipboard",action:"Action",actions:{open:"Open",close:"Close",save:"Save",save_changes:"Save Changes",revert:"Revert",revert_changes:"Revert Changes",reset_to_default:"Reset to default",select_all:"Select All",clear_selection:"Clear Selection",refresh:"Refresh",download_data:"Download Data",download_schema:"Download Schema",download_screenshot:"Screenshot",enter_fullscreen:"Full Screen",duplicate:"Duplicate",delete:"Delete",cancel:"Cancel",confirm:"Confirm",add_an_option:"Add an Option",edit:"Edit",end_editing:"End editing <1>{{name}}</1>"},tabs:{variant:{label:"Variant",default:"Default",outline:"Outline",pills:"Pills"},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},grow_tabs:"Grow Tabs"},choose_a_tab_first:"Please choose a tab first"},breakpoint:{label_one:"Screen size",label_other:"Screen sizes",add:"Add a screen size",manage:"Manage screen sizes",breakpoint:"Min Width"},context:{label:"Context"},mock_context:{label:"Mock Context",hint:"A valid json string is required"},panel:{label:"Panel",labels:"Panels",add:"Add a Panel",delete:"Delete This Panel",panel_name:"Panel Name",panel_description:"Description",panel_description_click:"Click to see description",show_title:"Show title",use_name_as_title:"Use name as title",settings:{change_view:"Move into Another View",change_view_title:"Move panel into another view",choose_queries:"Choose queries",need_to_choose_queries:"Choose at least 1 query for its data"},style:{label:"Style",width:"Width",width_postfix:"of 36 columns",height:"Height",height_postfix:"px",border:"Border"},variable:{label:"Variable",labels:"Variables",add:"Add a Variable",delete:"Delete this Variable",aggregation:{label:"Aggregation",fallback_value:"Fallback Value",fallback_value_description:"Used when data is empty or the aggregation yields NaN"}}},style:{label:"Style",font_size:{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"Font Weight"},size:{xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"xl"},flex:{justify_content:{label:"Justify Content",left:"Left",center:"Center",right:"Right",space_between:"Space Between",space_around:"Space Around",space_evenly:"Space Evenly"},align_items:{label:"Align Items",start:"Start",center:"Center",end:"End",stretch:"Stretch"}},color:{type:{label:"Color Type",static:"Static",interpolation:"Interpolation",none:"None"},interpolation:{setup:"Setup color interpolation",palette:{label:"Palette",category:{sequential:"Sequential",diverging:"Diverging"},red_green:"Red / Green",yellow_blue:"Yellow / Blue",red:"Red",green:"Green",blue:"Blue",orange:"Orange",mapping:{value_input_label:"Map a value to this color"}}}}},query:{label:"Query",labels:"Queries",add:"Add a Query",delete:"Delete this Query",cant_delete:"Can't delete this query for it's being used, check out Usage tab for details",delete_unused:"Delete unused queries",name:"Name",name_description:"A unique name",manage:"Manage Queries",open:"Open this query",configurations:"Configurations",basics:"Basics",conditions:"Conditions",run_by_condition:{label:"Run query when these are truthy",unset:"Always run this query on load"},re_run_condition:{label:"Re-run query when these changed",unset:"Leave it empty to never re-run this query"},dependency:{label:"Dependency",has_none:"This query has no dependency"},edit_sql:"Edit SQL",preview_sql:"Preview SQL",request:"Request",build_request:"Build Request",process_request:"Process Request",process_result:"Process Result",usage:{label:"Usage",in_views:"In View(s)",unused_description:"This query is not used by any filter or panel"},transform:{label:"Transform",full_label:"Transform Query",data_source:"Use other queries' data",guide:{pick_queries:"Pick queries for data input",write_function:"Write a function for making new data"}}},data:{label:"Data",preview_data:"Preview Data",empty_data:"Empty Data",requires_data:"Requires data"},data_source:{label:"Data Source",explore:"Explore Data Source",explorer:"Data Source Explorer",table_structure:"Table Structure",table_structure_short:"Structure",see_table_structure:"See Table Structure"},visualization:{label:"Visualization",component:"Visualization",label_short:"Viz"},numbro:{format:{label:"Format",absolute:"Absolute",absolute_description:"Non-negative",abbreviation:"Abbreviation",abbreviation_description:"like 1.23k, 1.23m",mantissa:"Mantissa",trim_mantissa:"Trim mantissa",trim_mantissa_description:"hide trailing zero(s)",preview:{open:"Open Preview",close:"Close Preview",input:"In",output:"Out"}}},import:{label:"Import...",title:"Import content with schema json",json_file:"JSON File",this_dashboard:"This dashboard",this_file:"This file"},function_utils:{trigger_text:"About parameter 'utils'",modal_title:"About FunctionUtils",description:"Parameter <code>utils</code> is <code>FunctionUtils</code>, which contains:",document:"Document"},aggregation:{option:{none:"None",sum:"Sum",mean:"Mean",median:"Median",min:"Min",max:"Max",cov:"Coefficient of Variation",std:"Standard Variation",quantile:{label:"Quantile",label_with_hint:"Quantile(99%, 95%, ...)"},custom:{label:"Custom",label_trigger:"Edit Function",title:"Custom Aggregation"}}},chart:{chart_config:"Chart Config",data_field:"Data Field",groups:{merico_suite:"Merico suite",echarts_based_charts:"ECharts-based charts",others:"Others"},label:{label:"Label",label_full:"Label",label_style:"Label Style",label_format:"Label Format"},label_position:{label:"Label Position",off:"Off",top:"Top",left:"Left",right:"Right",bottom:"Bottom",inside:"Inside",inside_top:"Inside Top",inside_left:"Inside Left",inside_center:"Inside Center",inside_right:"Inside Right",inside_bottom:"Inside Bottom",inside_top_left:"Inside Top Left",inside_top_right:"Inside Top Right",inside_bottom_left:"Inside Bottom Left",inside_bottom_right:"Inside Bottom Right",outside:"Outside"},number_or_dynamic_value:{type:{static:"Static",dynamic:"Dynamic"},dynamic:{setup:"Setup",setup_title:"Setup dynamic value",guide:"Dyanmic by a custom function"}},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},symbol_size:{label:"Symbol Size",static:"Static",dynamic:"Dynamic",setup:{label:"Setup",title:"Setup dynamic size",description:"Dynamic by a custom function"}},series:{label:"Series",name:"Name",y_axis:"Y Axis",data_field:"Data Field",add:"Add a series",delete:"Delete this series",line:{label:"Line",line_settings:"Line Settings",line_style:"Line Style",type:{label:"Line Type",solid:"Solid",dashed:"Dashed",dotted:"Dotted"},line_width:"Line Width",step:{label:"Step",off:"Off",start:"Start",middle:"Middle",end:"End"},smooth_line:"Smooth Line",show_name_on_line:"Display Name on Line",show_symbol_on_line:"Show Symbol on Line"},bar:{label:"Bar",stack:"Stack",stack_hint:"Stack bars by this ID",bar_gap:{label:"Bar Gap",no_gap:"No gap between bars",overlap:"Bars overlapping on each other"},bar_width:{min:"Bar Width(min)",exact:"Bar Width",max:"Bar Width(max)"}},scatter:{label:"Scatter"},group_by:{label:"Split into multiple seires by this field...",label_line:"Split into multiple lines by this field..."}},axis:{tick_label:"Tick Label",customize_label:"Customize Label",overflow:{label:"Overflow",max_width:"Max Width",truncate:"Truncate",break_line:"Break Line",break_word:"Break Word",ellipsis:"Ellipsis",section_title:{on_axis:"Overflow on Axis",in_tooltip:"Overflow in Tooltip"}},section_title:{label_format:"Label Format"},type:{value:"Value",category:"Category",time:"Time",log:"Log",click_to_learn_more:"Click <1>here</1> to learn more about these options"}},name_text:{align:{label:"Name Anchor",left:"Left",center:"Center",right:"Right"}},rotate:"Rotate",degree:"degree",padding:"Padding",content_template:{label:"Content Template",hint:"Average: ${avg}"},x_axis:{label:"X Axis",labels:"X Axes",label_format:"Label Format",add:"Add an X Axis",delete:"Delete this X Axis",x_axis_name:"X Axis Name",x_axis_data_field:"X Axis Data Field",x_axis_type:"X Axis Type",layout:"Layout",position:{label:"Position",top:"Top",bottom:"Bottom"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},y_axis:{label:"Y Axis",labels:"Y Axes",label_format:"Label Format",add:"Add a Y Axis",delete:"Delete this Y Axis",y_axis_name:"Y Axis Name",y_axis_name_anchor:"Name Anchor",y_axis_data_field:"Y Axis Data Field",layout:"Layout",position:{label:"Position",left:"Left",right:"Right"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},stats:{label:"Stats",template:{above_chart:"Template for stats above the chart",under_chart:"Template for stats under the chart"}},legend:{label:"Legend",show_legend:"Show Legend",show_in_legend:"Show in legend",hide_in_legend:"Hide in legend",orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"}},tooltip:{label:"Tooltip",additional_metrics:{description:"Set additional metrics to show in scatter's tooltip",add:"Add a metic",delete:"Delete this Metric"},trigger:{label:"Trigger",scatter_point:"Scatter Point",x_axis:"X Axis"}},style:{label:"Style"},color:{label:"Color",or:"or",set_any_color:"Set any color",pick_a_theme_color:"Pick a theme color",background_color:"Background Color",text_color:"Text Color"},behavior:{label:"Behavior",invisible:"Invisible"},heatmap:{heatblock:{label:"Heat Block",min_value:"Min Value",max_value:"Max Value",show_label:"Show Label"}},reference_line:{label:"Reference Line",labels:"Reference Lines",add:"Add a reference line",name_placeholder:"Average Reference Line",delete:"Remove this Reference Line",orientation:{vertical_hint:"Works only when xAxis values are numbers"}},regression_line:{label:"Regression Line",labels:"Regression Lines",add:"Add a line",delete:"Delete this line",method:{label:"Method",linear:"Linear",exponential:"Exponential",logistic:"Logistic",polynomial:"Polynomial",polynomial_order:"Order"}},reference_area:{label:"Reference Area",labels:"Reference Areas",add:"Add a reference area",delete:"Remove this reference area",type:{label:"Type",rectangle:"Rectangle"},direction:{label:"Direction",horizontal:"Horizontal"},boundary:{upper:"Upper Boundary",lower:"Lower Boundary"},content:{label:"Content",content_text:"Content Text",text_position:"Text Position"},endpoint:{labels:"Endpoints",left_bottom_point:"Left-Bottom Point",right_top_point:"Right-Top Point"}},zooming:{label:"Zooming",scroll:{label:"Scroll to zoom",x_axis:"Enable on X Axis",y_axis:"Enable on Y Axis"},slider:{label:"Slider for zooming",x_axis:"Slider for X Axis",y_axis:"Slider for Y Axis",y_axis_disabled:"Not available for now, will overlap y-axis's label"}}},viz:{viz_config_banner:"Visualization Settings"},validation:{number:{require_a_number:"A number is required"}}}},tk={translation:{filter:{label:"筛选器",labels:"筛选器",add:"新增筛选器",manage:"管理筛选器",show_filters:"展开筛选器",hide_filters:"收起筛选器",field:{widget:"控件",visible_in:"在...视图中可见",key_placeholder:"用于引用此筛选器,需保持唯一",label_placeholder:"用于展示的标签文案",auto_submit:"自动提交",order:"排列次序",custom_default_value:{trigger:"自定义",title:"自定义默认值",tips:"提示",tip_1:"在指定筛选器默认值这事上,自定义函数具备最高优先级",tip_2:"清空下方编辑器来禁用本功能"}},widget:{names:{select:"单选",multi_select:"多选",tree_select:"树形选择器",text_input:"文本框",checkbox:"勾选框",date_range:"日期范围"},common:{use_query_data_as_options:"使用所查数据为选项",fetch_options_from_datasource:"从数据源查选项",or_fetch_options_from_datasource:"或从数据源查选项",selector_option_empty:"无选项可用",see_data_structure:"点击查看期望的数据格式",using_query:"在用查询获取选项",default_selection_count:"默认选中前N项",min_width:"控件最小宽度",x_selected:"已选数:{{count}}"},text_input:{default_value:"默认值",required:"必填"},select:{width:"控件宽度",required:"必选",clearable:"可取消选择",configure_options:"配置选项",default_selection:"默认选项",no_default_selection:"无",select_first_option_by_default:"默认选中第一个选项"},multi_select:{width_description:"至少160px"},tree_select:{strictly:"枝叶节点不相关,各选各的"},checkbox:{description:"描述信息",default_checked:"默认勾选"},date_range:{required:"必选",allow_single_date:"允许选一天作为范围",display_format:"展示格式",max_days:"最大选择天数",one_day:"1天",x_days:"{{count}}天",x_max_days:"最多可选{{max_days}}天",default_value:"默认日期范围(具体)",default_by_shortcut:"默认日期范围(快捷方式)",defualt_by_shortcut_placeholder:"优先于左侧",start_date:"开始日期",end_date:"结束日期",shortcut:{last:{label:"过往整周期",d:"昨天",w:"周",m:"月",m2:"两个月",m3:"三个月",y:"年",full:{d:"昨天",w:"上周",m:"上个月",m2:"上两月",m3:"上三月",y:"去年"}},recent:{label:"最近",d7:"7天",d30:"30天",d60:"60天",d90:"90天",d180:"180天",d365:"365天",full:{d7:"近7天",d30:"近30天",d60:"近60天",d90:"近90天",d180:"近180天",d365:"近365天"}},this:{label:"当前整周期",d:"今天",w:"周",m:"月",y:"年",full:{d:"今天",w:"本周",m:"本月",y:"今年"}},this_so_far:{label:"至今",w:"周",m:"月",y:"年",full:{w:"本周至今",m:"本月至今",y:"本年至今"}}}}}},view:{label:"视图",labels:"视图",add:"新增视图",delete:"删除此视图",download_schema:"下载此视图描述文件",component:{div:{label:"内容"},tabs:{label:"标签页",tabs_settings:"标签页设置",tab:{name:"名称",view:"内容视图",order:"排列次序",color:"颜色",delete:"删除这个标签页",switch_to_view:"打开视图: {{name}}"}},modal:{label:"弹窗",modal_settings:"弹窗设置",title:"弹窗标题",custom_title:"自定义弹窗标题",width:"宽度",height:"高度"}}},interactions:{label:"交互",add:"新增交互",interactions_viewer:"纵览交互",unavailable:"不可用",unavailable_reason:"此可视化组件没有交互功能",trigger:{setup:"设置触发动作",label:"触发动作",payload:"触发时的参数"},operation:{setup:"操作设置",label:"操作",settings:"设置",variables:"变量",console_log:{label:"console.log | 调试用",log_content:"打印内容"},open_link:{label:"打开链接",url:"URL",open_in_new_tab:"在新标签页中打开"},open_view:{label:"唤出视图",view:"视图"},set_filter_values:{label:"设置筛选器值",set_filter:"将筛选器的值",with:"设为"},clear_filter_values:{label:"清除筛选器值",select_filter:"选择筛选器以清除其值"}}},query_variable:{label:"查询变量",labels:"查询变量",add:"新增变量",guide:{tabs:{guide:"使用指南",variables_in_this_dashboard:"本看板中的查询变量",global_sql_snippets:"全局SQL片段"}},open:"查看查询变量"},sql_snippet:{label:"SQL片段",labels:"SQL片段",add:"新增SQL片段",delete:"删除这个SQL片段",delete_unused:"删除未用到的SQL片段",manage:"管理SQL片段",key:"键",key_occupied:"此键已被其他SQL片段占用",edit_snippet:"编辑SQL片段",preview_snippet:"预览SQL片段",usage:{label:"使用情况"}},global_sql_snippet:{label:"全局SQL片段",labels:"全局SQL片段",description:"管理员负责在系统设置中维护全局SQL片段"},common:{titles:{settings:"设置",edit:"编辑",config:"配置"},pagination:{page_size:"页容量",total:"共",total_rows:"共 {{total}} 行"},align:{horizontal:{label:"水平对齐",left:"居左",center:"居中",right:"居右"},vertical:{label:"垂直对齐",left:"居上",center:"居中",right:"居下"}},id:"ID",name:"名称",key:"键",label:"标签",value:"值",type:"类型",info:"信息",min:"最小值",max:"最大值",data_field:"数据字段",name_data_field:"名称字段",value_data_field:"值字段",color_data_field:"颜色字段",enabled:"启用",copied:"已复制到剪切板",action:"操作",actions:{open:"打开",close:"关闭",save:"保存",save_changes:"保存改动",revert:"还原",revert_changes:"还原改动",reset_to_default:"重置为初始值",select_all:"全选",clear_selection:"撤销选择",refresh:"刷新",download_data:"下载数据",download_schema:"下载描述文件",download_screenshot:"下载截图",enter_fullscreen:"全屏",duplicate:"复制",delete:"删除",cancel:"取消",confirm:"确认",add_an_option:"新增选项",edit:"编辑",end_editing:"结束编辑 <1>{{name}}</1>"},tabs:{variant:{label:"风格",default:"默认",outline:"轮廓",pills:"胶囊"},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},grow_tabs:"拉伸标签卡宽度"},choose_a_tab_first:"请先选择一个标签页"},breakpoint:{label_one:"屏幕尺寸",label_other:"屏幕尺寸",add:"新增屏幕尺寸",manage:"管理屏幕尺寸",breakpoint:"最小宽度"},context:{label:"上下文"},mock_context:{label:"模拟上下文",hint:"内容格式为JSON"},panel:{label:"卡片",labels:"卡片",add:"新增卡片",delete:"删除这个卡片",panel_name:"卡片名",panel_description:"卡片描述",panel_description_click:"点击查看卡片描述",show_title:"展示卡片标题",use_name_as_title:"使用卡片名作为标题",settings:{change_view:"移至另一个视图下",change_view_title:"移动此卡片至另一个视图下",choose_queries:"关联查询",need_to_choose_queries:"请关联至少一个查询以使用其数据"},style:{label:"样式",width:"宽",width_postfix:"之 36 栏",height:"高",height_postfix:"px",border:"边框"},variable:{label:"变量",labels:"变量",add:"新增变量",delete:"删除此变量",aggregation:{label:"聚合",fallback_value:"兜底值",fallback_value_description:"当数据为空或聚合结果非数字时,使用此兜底值"}}},style:{label:"样式",font_size:{label:"字号",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"字重"},size:{xs:"特小",sm:"小",md:"中",lg:"大",xl:"特大"},flex:{justify_content:{label:"内容分布",left:"从左起",center:"居中",right:"从右起",space_between:"均匀分布,首尾顶格",space_around:"均匀分布,首尾留空一半",space_evenly:"均匀分布,首尾留空"},align_items:{label:"对齐位置",start:"起点对齐",center:"居中对齐",end:"末端对齐",stretch:"拉伸对齐"}},color:{type:{label:"颜色类型",static:"单色",interpolation:"插值取色",none:"无"},interpolation:{setup:"设置取色方案",palette:{label:"色板",category:{sequential:"单色渐变",diverging:"双色渐变"},red_green:"红 / 绿",yellow_blue:"黄 / 蓝",red:"红",green:"绿",blue:"蓝",orange:"橙",mapping:{value_input_label:"映射一个值到此颜色"}}}}},query:{label:"查询",labels:"查询",add:"新增查询",delete:"删除这个查询",cant_delete:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",delete_unused:"删除未用到的查询",name:"名称",name_description:"唯一名称",manage:"管理查询",open:"打开此查询",configurations:"配置",basics:"基本信息",conditions:"条件",run_by_condition:{label:"以下条件满足时,才运行本查询",unset:"看板加载时便运行本查询"},re_run_condition:{label:"当以下条件改变时,重新运行此查询",unset:"留空则永不重新运行此查询"},dependency:{label:"依赖",has_none:"此查询无依赖"},edit_sql:"编辑SQL",preview_sql:"预览SQL",request:"请求",build_request:"构造请求",process_request:"加工请求",process_result:"加工结果",usage:{label:"使用情况",in_views:"所在视图",unused_description:"此查询未被任何筛选器或卡片用到"},transform:{label:"查询变形",full_label:"查询变形",data_source:"基于其他查询的数据,加工出新数据",guide:{pick_queries:"选择一至多个查询作为数据输入",write_function:"编写函数,返回新数据"}}},data:{label:"数据",preview_data:"预览数据",empty_data:"无数据",requires_data:"请先关联查询"},data_source:{label:"数据源",explore:"查看数据源",explorer:"数据源查看器",table_structure:"数据表结构",table_structure_short:"表结构",see_table_structure:"查看数据表结构"},visualization:{label:"可视化",component:"可视化组件",label_short:"可视化"},numbro:{format:{label:"格式",absolute:"绝对值",absolute_description:"非负",abbreviation:"缩写",abbreviation_description:"如1.23k、1.23m",mantissa:"小数",trim_mantissa:"抹零",trim_mantissa_description:"省略末尾的零",preview:{open:"展开预览",close:"收起预览",input:"输入",output:"输出"}}},import:{label:"导入...",title:"自描述文件导入看板内容",json_file:"描述文件(JSON格式)",this_dashboard:"此看板",this_file:"此文件"},function_utils:{trigger_text:"关于utils参数",modal_title:"关于utils参数",description:"参数 <code>utils</code> 是 <code>FunctionUtils</code>,包含以下内容:",document:"文档"},aggregation:{option:{none:"无",sum:"和",mean:"平均值",median:"中位数",min:"最小值",max:"最大值",cov:"变异系数",std:"标准差",quantile:{label:"分位",label_with_hint:"分位(99%, 95%, ...)"},custom:{label:"自定义",label_trigger:"编写函数",title:"自定义聚合方式"}}},chart:{chart_config:"图表设置",data_field:"数据字段",groups:{merico_suite:"思码逸套件",echarts_based_charts:"基于ECharts的图表",others:"其他"},label:{label:"文案",label_full:"标签文案",label_style:"标签文案样式",label_format:"标签文案格式"},label_position:{label:"文案位置",off:"不显示文案",top:"上",left:"左",right:"右",bottom:"下",inside:"内",inside_top:"内-上",inside_left:"内-左",inside_center:"内-中",inside_right:"内-右",inside_bottom:"内-下",inside_top_left:"内-上-左",inside_top_right:"内-上-右",inside_bottom_left:"内-下-左",inside_bottom_right:"内-下-右",outside:"外"},number_or_dynamic_value:{type:{static:"具体值",dynamic:"动态值"},dynamic:{setup:"设置",setup_title:"设置动态值",guide:"由函数确定动态值"}},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},symbol_size:{label:"标记点大小",static:"固定值",dynamic:"动态值",setup:{label:"设置",title:"设置动态值",description:"由函数确定动态值"}},series:{label:"系列",name:"名称",y_axis:"Y轴",data_field:"数据字段",add:"增加一个系列",delete:"删除这个系列",line:{label:"线",line_settings:"线段设置",line_style:"线条样式",type:{label:"类型",solid:"实线",dashed:"方虚线",dotted:"圆点虚线"},line_width:"线宽",step:{label:"阶梯状",off:"不启用",start:"在当前点拐弯",middle:"在当前点与下个点中间拐弯",end:"在下个点拐弯"},smooth_line:"平滑曲线",show_name_on_line:"显示标签文案",show_symbol_on_line:"显示标记点"},bar:{label:"柱",stack:"堆放",stack_hint:"此值相同的柱系列会堆叠在一起",bar_gap:{label:"柱间隔",no_gap:"柱子之间无间隔",overlap:"柱子可互相重叠"},bar_width:{min:"最大柱宽",exact:"柱宽",max:"最大柱宽"}},scatter:{label:"散点"},group_by:{label:"按此字段拆分为多个系列",label_line:"按此字段拆分为多条线"}},axis:{tick_label:"刻度文案",customize_label:"自定义文案",overflow:{label:"溢出",max_width:"最大宽度",truncate:"截断",break_line:"换行",break_word:"断词换行",ellipsis:"省略符",section_title:{on_axis:"轴刻度上文案的溢出",in_tooltip:"提示框中的文案溢出"}},section_title:{label_format:"文案格式"},type:{value:"数值轴",category:"类目轴",time:"时间轴",log:"对数轴",click_to_learn_more:"点击 <1>这里</1> 以进一步了解这些选项"}},name_text:{align:{label:"名称贴靠侧",left:"左",center:"中",right:"右"}},rotate:"旋转",degree:"度",padding:"内间距",content_template:{label:"内容模板",hint:"均值: ${avg}"},x_axis:{label:"X轴",labels:"X轴",label_format:"刻度文案格式",add:"增加一条X轴",delete:"删除这条X轴",x_axis_name:"X轴名称",x_axis_data_field:"X轴数据字段",x_axis_type:"X轴类型",layout:"布局",position:{label:"位置",top:"上",bottom:"下"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},y_axis:{label:"Y轴",labels:"Y轴",label_format:"刻度文案格式",add:"增加一条Y轴",delete:"删除这条Y轴",y_axis_name:"Y轴名称",y_axis_name_anchor:"名称贴靠侧",y_axis_data_field:"Y轴数据字段",layout:"布局",position:{label:"位置",left:"左",right:"右"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},stats:{label:"统计内容",template:{above_chart:"统计内容模板(图表上方)",under_chart:"统计内容模板(图表下方)"}},legend:{label:"图例",show_legend:"显示图例",show_in_legend:"显示在图例中",hide_in_legend:"不显示在图例中",orientation:{label:"布局朝向",horizontal:"横向",vertical:"纵向"}},tooltip:{label:"提示框",additional_metrics:{description:"在此设置更多指标,来展示在散点的提示框",add:"增加一个指标",delete:"删除这个指标"},trigger:{label:"触发者",scatter_point:"散点",x_axis:"X轴"}},style:{label:"样式"},color:{label:"颜色",or:"或",set_any_color:"输入色号",pick_a_theme_color:"选择一个主题色",background_color:"背景色",text_color:"文字颜色"},behavior:{label:"表现",invisible:"隐藏不可见"},heatmap:{heatblock:{label:"热力块",min_value:"最小值",max_value:"最大值",show_label:"展示值文案"}},reference_line:{label:"参考线",labels:"参考线",add:"增加一条参考线",name_placeholder:"均值参考线",delete:"删除这条参考线",orientation:{vertical_hint:"仅当X轴值为数字时可绘制"}},regression_line:{label:"回归线",labels:"回归线",add:"增加一条回归线",delete:"删除这条回归线",method:{label:"方法",linear:"线性回归",exponential:"指数回归",logistic:"指数回归",polynomial:"多项式回归",polynomial_order:"次"}},reference_area:{label:"参考区域",labels:"参考区域",add:"增加一面参考区域",delete:"删除这面参考区域",type:{label:"形状",rectangle:"矩形"},direction:{label:"方向",horizontal:"水平"},boundary:{upper:"上边界",lower:"下边界"},content:{label:"内容",content_text:"内容文字",text_position:"文字位置"},endpoint:{labels:"端点",left_bottom_point:"左下点",right_top_point:"右上点"}},zooming:{label:"缩放",scroll:{label:"滚轮缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用"},slider:{label:"滚动条缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用",y_axis_disabled:"暂不可用,会与Y轴刻度文字重叠"}}},viz:{viz_config_banner:"可视化参数配置"},validation:{number:{require_a_number:"请填写一个数字"}}}},us=nd.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:ek,zh:tk}}).use(sd).use(_.initReactI18next);us.init(),ul.forEach(t=>{var e;(e=t.translation)==null||e.forEach(n=>{us.addResourceBundle(n.lang,"translation",{viz:n.resources},!0,!0)})});function Cc({lang:t,children:e}){return m.useEffect(()=>{us.changeLanguage(t)},[t]),s.jsx(_.I18nextProvider,{i18n:us,children:e})}function Sc(t,e){m.useEffect(()=>{const n=r=>{console.log(r);const{viewID:i}=r.detail;if(!i){console.error(new Error("[Open View] Needs to pick a view first"));return}t.views.appendToVisibles(i),e&&t.views.setIDOfVIE(i)};return window.addEventListener("open-view",n),()=>{window.removeEventListener("open-view",n)}},[t,e]),m.useEffect(()=>{const n=r=>{console.log(r);const{dictionary:i,payload:a}=r.detail;if(!a||Object.keys(a).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}Object.entries(i).forEach(([l,c])=>{t.filters.setValueByKey(l,x.get(a,c))})};return window.addEventListener("set-filter-values",n),()=>{window.removeEventListener("set-filter-values",n)}},[t]),m.useEffect(()=>{function n(i){return Array.isArray(i)?[]:typeof i=="object"?{}:typeof i=="boolean"?!1:typeof i=="string"?"":typeof i=="number"?0:i}const r=i=>{console.log(i);const{filter_keys:a}=i.detail;a.forEach(l=>{const c=x.get(t.filters.values,l),u=n(c);console.log(`${l}: ${u}`),t.filters.setValueByKey(l,u)})};return window.addEventListener("clear-filter-values",r),()=>{window.removeEventListener("clear-filter-values",r)}},[t]),m.useEffect(()=>{const n=r=>{console.log(r);const{urlTemplate:i,openInNewTab:a,enableEncoding:l=!1,payload:c}=r.detail;if(!i){console.error(new Error("[Open Link] URL is empty"));return}function u(p){return x.cloneDeepWith(p,y=>{if(l&&typeof y=="string")return encodeURIComponent(y)})}const h=x.template(i||"")(u({...c,filters:t.payloadForSQL.filters,context:t.payloadForSQL.context}));window.open(h,a?"_blank":"_self","noopener")};return window.addEventListener("open-link",n),()=>{window.removeEventListener("open-link",n)}},[t])}function kc(t){return m.useCallback(e=>e.provideValue(he.pluginManager,t.pluginManager).provideValue(he.vizManager,t.vizManager).provideValue(he.colorManager,t.colorManager),[])}const sI="",nk=S.observer(({saveDashboardChanges:t})=>{const{t:e}=_.useTranslation(),n=Be.useModals(),r=W(),i=()=>{n.openConfirmModal({title:s.jsxs(o.Group,{position:"left",children:[s.jsx(k.IconAlertTriangle,{size:18,color:"red"}),s.jsx(o.Text,{children:"You are reverting changes"})]}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>r.reset(),zIndex:320,withCloseButton:!1})},a=r.changed;return s.jsxs(o.Group,{spacing:0,children:[s.jsx(o.Button,{color:"green",variant:"filled",size:"xs",leftIcon:s.jsx(k.IconDeviceFloppy,{size:18}),onClick:t,disabled:!a,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:e("common.actions.save_changes")}),s.jsxs(o.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!a,children:[s.jsx(o.Menu.Target,{children:s.jsx(o.ActionIcon,{variant:"default",disabled:!a,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:s.jsx(k.IconCaretDown,{size:18})})}),s.jsx(o.Menu.Dropdown,{children:s.jsx(o.Menu.Item,{icon:s.jsx(k.IconRecycle,{size:14,color:"red"}),disabled:!a,onClick:i,children:e("common.actions.revert_changes")})})]})]})}),sk=S.observer(({saveDashboardChanges:t,onExit:e,headerSlot:n=null})=>{_.useTranslation();const r=X(),i=r.content.changed,a=()=>{e({hasChanges:i,dashboardId:r.id})};return s.jsx(o.Header,{height:60,px:"md",py:0,sx:{zIndex:299},children:s.jsxs(o.Group,{position:"apart",sx:{height:60,minWidth:"1000px",position:"relative"},children:[s.jsxs(o.Group,{children:[s.jsx(o.Button,{size:"xs",color:i?"red":"green",leftIcon:s.jsx(k.IconArrowLeft,{size:20}),onClick:a,children:s.jsx(o.Group,{spacing:4,children:s.jsxs(_.Trans,{i18nKey:"common.actions.end_editing",values:{name:r.name},children:["End Editing ",s.jsx(o.Text,{td:"underline",children:r.name})]})})}),s.jsx(nk,{saveDashboardChanges:t})]}),s.jsx(o.Group,{position:"right",sx:{flexGrow:1},children:n})]})})}),Tc={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},rk=S.observer(()=>{var i;const{t}=_.useTranslation(),e=W(),n=((i=e.views.VIE)==null?void 0:i.type)===L.Tabs,r=()=>e.addANewPanel(e.views.idOfVIE);return n?s.jsx(o.Tooltip,{label:t("common.choose_a_tab_first"),children:s.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:s.jsx(k.IconPlaylistAdd,{size:20}),sx:{...Tc,transform:"none !important"},children:t("panel.add")})}):s.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:r,leftIcon:s.jsx(k.IconPlaylistAdd,{size:20}),sx:{...Tc,background:"rgb(231, 245, 255)"},children:t("panel.add")})}),ik=S.observer(({done:t})=>{var te,Q;const{t:e}=_.useTranslation(),r=W().layouts,i=m.useMemo(()=>({list:r.breakpointsInfo}),[r.breakpointsInfo]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d,formState:h}=b.useForm({defaultValues:i}),{fields:p,append:g,remove:y}=b.useFieldArray({control:a,name:"list",rules:{validate:R=>{if(console.log({values:R}),x.uniqBy(R,"breakpoint").length!==R.length)return"Screen sizes should be unique by min width"}}}),v=c("list"),C=p.map((R,ne)=>({...R,...v[ne]})),T=()=>{g({id:vt.v4(),name:"",breakpoint:""})},D=({list:R})=>{const ne=R.filter(Se=>Number.isFinite(Se.breakpoint));r.updateLayoutSetsInfo(ne),t()},M=u(),$=m.useMemo(()=>{const R={list:M.list.filter(ne=>!!ne.name&&Number.isFinite(ne.breakpoint))};return!x.isEqual(R,i)},[M,i]),J=(Q=(te=h.errors.list)==null?void 0:te.root)==null?void 0:Q.message;return s.jsx(s.Fragment,{children:s.jsxs("form",{onSubmit:l(D),children:[s.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,withBorder:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"340px"},children:e("common.name")}),s.jsx("th",{style:{width:"160px"},children:e("breakpoint.breakpoint")}),s.jsx("th",{})]})}),s.jsxs("tbody",{children:[C.map((R,ne)=>s.jsxs("tr",{children:[s.jsx("th",{children:R.id==="basis"?R.name:s.jsx(b.Controller,{name:`list.${ne}.name`,control:a,render:({field:Se})=>s.jsx(o.TextInput,{size:"xs",label:"",required:!0,sx:{flex:1},...Se})})}),s.jsx("td",{children:R.id==="basis"?s.jsxs(o.Text,{ff:"monospace",children:[R.breakpoint,"px"]}):s.jsx(b.Controller,{name:`list.${ne}.breakpoint`,control:a,render:({field:Se})=>s.jsx(o.NumberInput,{size:"xs",label:"",required:!0,max:1e4,hideControls:!0,rightSection:s.jsx(o.Text,{color:"dimmed",children:"px"}),rightSectionProps:{style:{width:"30px"}},sx:{flex:1,fontFamily:"monospace"},styles:{input:{paddingRight:"30px"}},...Se})})}),s.jsx("td",{children:R.id!=="basis"&&s.jsx(o.ActionIcon,{mx:"auto",size:"xs",variant:"subtle",color:"red",onClick:()=>y(ne),children:s.jsx(k.IconTrash,{})})})]},R.id)),s.jsx("tr",{style:{backgroundColor:"transparent"},children:s.jsx("td",{colSpan:3,style:{padding:"0"},children:s.jsx(o.Tooltip,{label:e("breakpoint.add"),children:s.jsx(o.ActionIcon,{variant:"subtle",size:"md",color:"blue",onClick:T,sx:{width:"100%"},children:s.jsx(k.IconPlus,{size:18})})})})})]})]}),s.jsx(o.Text,{mt:6,ta:"right",size:"xs",color:"red",children:J??" "}),s.jsxs(o.Group,{mt:6,position:"apart",children:[s.jsx(o.Button,{color:"orange",size:"xs",onClick:()=>d(),leftIcon:s.jsx(k.IconRecycle,{size:18}),disabled:!$,children:e("common.actions.revert")}),s.jsx(o.Button,{color:"green",size:"xs",type:"submit",leftIcon:s.jsx(k.IconDeviceFloppy,{size:18}),disabled:!$,children:e("common.actions.save_changes")})]})]})})}),ak=S.observer(()=>{const{t}=_.useTranslation(),[e,{open:n,close:r}]=ie.useDisclosure(!1),i=W(),a=i.layouts.currentBreakpoint,l=i.layouts.currentLayoutRange,c=()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},u=()=>{r(),c()};return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{children:[s.jsxs(o.Menu,{withArrow:!0,withinPortal:!0,zIndex:320,trigger:"hover",children:[s.jsx(o.Menu.Target,{children:s.jsx(o.Button,{size:"xs",variant:"subtle",leftIcon:s.jsx(k.IconDevices,{size:16}),sx:{borderRadius:0},children:s.jsxs(o.Group,{spacing:6,children:[s.jsx(o.Text,{size:"xs",fw:"normal",children:l.name}),s.jsx(o.Text,{size:"xs",color:"#777",children:i.layouts.currentRangeText})]})})}),s.jsxs(o.Menu.Dropdown,{children:[i.layouts.breakpointRanges.map(d=>s.jsx(o.Menu.Item,{onClick:()=>i.layouts.setCurrentBreakpoint(d.id),disabled:a===d.id,children:s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Text,{size:"sm",children:d.name}),s.jsx(o.Text,{size:"xs",color:"dimmed",children:d.text})]})},d.id)),s.jsx(o.Menu.Divider,{}),s.jsx(o.Menu.Item,{color:"blue",icon:s.jsx(k.IconSettings,{size:14}),onClick:n,children:s.jsx(o.Text,{size:"sm",children:t("breakpoint.manage")})})]})]}),i.layouts.divisionPreviewScale<1&&s.jsx(o.Text,{size:"xs",color:"dimmed",children:jn(i.layouts.divisionPreviewScale).format({output:"percent",mantissa:0})})]}),s.jsx(o.Modal,{opened:e,onClose:u,title:t("breakpoint.label",{count:2}),withinPortal:!0,zIndex:320,size:600,closeOnClickOutside:!1,children:s.jsx(ik,{done:u})})]})}),Dc={height:"30px",borderRight:"none",borderTop:"none",borderLeft:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},ok=S.observer(()=>{var i;const{t}=_.useTranslation(),e=W(),n=((i=e.views.VIE)==null?void 0:i.type)===L.Tabs,r=()=>{var a;return(a=e.views.VIE)==null?void 0:a.downloadSchema()};return n?s.jsx(o.Tooltip,{label:t("common.choose_a_tab_first"),children:s.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:s.jsx(k.IconCode,{size:16}),sx:{...Dc,transform:"none !important"},children:t("view.download_schema")})}):s.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:r,leftIcon:s.jsx(k.IconCode,{size:16}),sx:{...Dc},children:t("view.download_schema")})}),ds=({headers:t,rows:e})=>s.jsxs(o.Table,{fontSize:"xs",highlightOnHover:!0,sx:{tableLayout:"fixed",fontFamily:"monospace"},children:[s.jsx("thead",{children:t}),s.jsx("tbody",{children:e})]}),lk=({content:t})=>{const{t:e}=_.useTranslation(),n=t.views;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("view.labels")}),s.jsx(ds,{headers:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"160px"},children:e("common.id")}),s.jsx("th",{children:e("common.name")}),s.jsx("th",{children:e("common.type")})]}),rows:n.map(r=>s.jsxs("tr",{children:[s.jsx("td",{children:r.id}),s.jsx("td",{children:r.name}),s.jsx("td",{children:e(`view.component.${r.type}.label`)})]},r.id))})]})},ck=({content:t})=>{const{t:e}=_.useTranslation(),n=t.filters;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("filter.labels")}),s.jsx(ds,{headers:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"160px"},children:e("common.id")}),s.jsx("th",{children:e("common.key")}),s.jsx("th",{children:e("common.label")})]}),rows:n.map(r=>s.jsxs("tr",{children:[s.jsx("td",{children:r.id}),s.jsx("td",{children:r.key}),s.jsx("td",{children:r.label})]},r.id))})]})},uk=({content:t})=>{const{t:e}=_.useTranslation(),n=t.panels;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("panel.labels")}),s.jsx(ds,{headers:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"160px"},children:e("common.id")}),s.jsx("th",{children:e("common.name")}),s.jsx("th",{children:e("visualization.component")})]}),rows:n.map(r=>s.jsxs("tr",{children:[s.jsx("td",{children:r.id}),s.jsx("td",{children:r.name}),s.jsx("td",{children:r.viz.type})]},r.id))})]})},dk=({content:t})=>{var r;const{t:e}=_.useTranslation(),n=(r=t.definition)==null?void 0:r.queries;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("query.labels")}),s.jsx(ds,{headers:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"160px"},children:e("common.id")}),s.jsx("th",{children:e("common.name")}),s.jsx("th",{style:{width:"140px"},children:e("common.type")}),s.jsx("th",{style:{width:"260px"},children:e("data_source.label")})]}),rows:n.map(i=>s.jsxs("tr",{children:[s.jsx("td",{children:i.id}),s.jsx("td",{children:i.name}),s.jsx("td",{children:i.type}),s.jsx("td",{children:i.key})]},i.id))})]})},hk=({content:t})=>{var r;const{t:e}=_.useTranslation(),n=(r=t.definition)==null?void 0:r.sqlSnippets;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("sql_snippet.labels")}),s.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:s.jsx(k.IconPointFilled,{size:10}),children:n.map(i=>s.jsx(o.List.Item,{children:i.key},i.key))})]})},pk=({content:t})=>{var r;const{t:e}=_.useTranslation(),n=Object.keys(((r=t.definition)==null?void 0:r.mock_context)??{});return n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("mock_context.label")}),s.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:s.jsx(k.IconPointFilled,{size:10}),children:n.map(i=>s.jsx(o.List.Item,{children:i},i))})]})},mk=({content:t})=>t?s.jsxs(o.Box,{children:[s.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),s.jsx(o.Text,{ta:"left",c:"dimmed",children:"Preview"}),s.jsxs(o.Stack,{children:[s.jsx(lk,{content:t}),s.jsx(ck,{content:t}),s.jsx(uk,{content:t}),s.jsx(dk,{content:t}),s.jsx(hk,{content:t}),s.jsx(pk,{content:t})]})]}):null;function fk(t){if(t.target===null)throw new Error("FileReader failed with null result");if(typeof t.target.result!="string")throw new Error(`Unparsable file content of type: ${typeof t.target.result}`);let e=JSON.parse(t.target.result);if("content"in e&&(e=e.content),e.version!==mt)throw new Error("Schema version mismatch");return e}const gk=S.observer(({onSuccess:t,stretchModal:e,shrinkModal:n})=>{var D,M;const{t:r}=_.useTranslation(),i=W(),{handleSubmit:a,formState:{errors:l},setValue:c,watch:u,setError:d,clearErrors:h}=b.useForm({defaultValues:{content:null}}),p=({content:$})=>{try{if(!$)throw new Error("please use a valid json file");i.applyJSONSchema($),yt.showNotification({title:"Successful",message:"",color:"green"}),t()}catch(J){console.error(J),yt.showNotification({title:"Failed",message:J.message,color:"red"})}},[g,y]=m.useState(null);m.useEffect(()=>{if(!g)return;const $=new FileReader;$.readAsText(g,"UTF-8"),$.onload=J=>{try{const te=fk(J);c("content",te),h("content")}catch(te){console.error(te),d("content",{type:"custom",message:te.message})}},$.onabort=()=>console.log("🟨 abort"),$.onerror=()=>{$.error&&(console.error($.error),d("content",{type:"custom",message:$.error.message}))}},[g]);const[v]=u(["content"]),C=!v,T=(D=l==null?void 0:l.content)==null?void 0:D.message;return m.useEffect(()=>{!v||T?n():e()},[v,T]),s.jsx(o.Box,{mx:"auto",sx:{position:"relative"},children:s.jsxs("form",{onSubmit:a(p),children:[s.jsx(o.FileInput,{label:r("import.json_file"),required:!0,value:g,onChange:y,error:(M=l==null?void 0:l.content)==null?void 0:M.message,sx:{maxWidth:500}}),T?s.jsx(o.Table,{fontSize:12,mt:10,children:s.jsxs("tbody",{children:[s.jsxs("tr",{children:[s.jsx("th",{children:r("import.this_dashboard")}),s.jsx("td",{children:mt})]}),s.jsxs("tr",{children:[s.jsx("th",{children:r("import.this_file")}),s.jsx("td",{style:{color:"red"},children:v==null?void 0:v.version})]})]})}):s.jsxs(s.Fragment,{children:[s.jsx(mk,{content:v}),s.jsx(o.Group,{position:"right",my:"md",children:s.jsx(o.Button,{type:"submit",color:"green",disabled:C,children:r("common.actions.confirm")})})]})]})})}),zc={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},xk=S.observer(()=>{var d;const{t}=_.useTranslation(),[e,{open:n,close:r}]=ie.useDisclosure(!1),[i,{setTrue:a,setFalse:l}]=N.useBoolean(!1),u=((d=X().content.views.VIE)==null?void 0:d.type)===L.Tabs;return u?s.jsx(o.Tooltip,{label:t("common.choose_a_tab_first"),children:s.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:s.jsx(k.IconFileImport,{size:16}),sx:{...zc,transform:"none !important"},children:t("import.label")})}):s.jsxs(s.Fragment,{children:[s.jsx(o.Button,{variant:"subtle",color:"blue",radius:0,size:"xs",disabled:u||e,onClick:n,leftIcon:s.jsx(k.IconFileImport,{size:16}),sx:{...zc},children:t("import.label")}),s.jsx(o.Modal,{opened:e,onClose:r,title:t("import.title"),trapFocus:!0,onDragStart:h=>{h.stopPropagation()},withinPortal:!0,zIndex:320,size:i?"90vw":500,children:s.jsx(gk,{onSuccess:r,stretchModal:a,shrinkModal:l})})]})}),yk={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},bk=S.observer(()=>s.jsx(o.Box,{sx:yk,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:s.jsxs(o.Group,{position:"apart",align:"center",sx:{height:"30px"},children:[s.jsxs(o.Group,{position:"left",spacing:0,children:[s.jsx(rk,{}),s.jsx(xk,{})]}),s.jsx(ak,{}),s.jsx(o.Group,{position:"right",spacing:0,children:s.jsx(ok,{})})]})})),vk=S.observer(t=>s.jsxs(s.Fragment,{children:[s.jsx(sk,{...t}),s.jsx(bk,{})]})),rI="";function _k(t,e,n){const r=[];return t.filter(i=>"__INTERACTIONS"in i.viz.conf).forEach((i,a)=>{const l=e[i.id];l.data.interactions=x.get(l,"data.interactions",[]);const{__INTERACTIONS:c,__OPERATIONS:u,__TRIGGERS:d}=i.viz.conf;Object.entries(u).forEach(([h,p])=>{const{schemaRef:g,data:y}=p,{config:v}=y;switch(g){case"builtin:op:open-link":let C=v.urlTemplate.substring(0,100);v.urlTemplate.length>=20&&(C+="..."),l.type="interaction",l.data.interactions.push({schemaRef:g,urlTemplate:v.urlTemplate,shortURLTemplate:C});return;case"builtin:op:open_view":r.push({id:`OPERATION--${h}`,source:i.id,target:v.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:g,filters:Object.keys(v.dictionary).map(T=>({key:T,label:n[T]}))});return;case"builtin:op:clear_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:g,filters:v.filter_keys.map(T=>({key:T,label:n[T]}))});return;default:return}})}),r}function jk(t,e){const n=t.filters.keyLabelMap;return{edges:_k(t.panels.list,e,n),edgeNodes:[]}}function Ic(t,e,n){return t*e+t*n}function wk(t,e,n){return t*e+(t-1)*n}const hs=25,bi=40,Mc=25,vi=350,Ck=150,Sk=150,Ec=150,Ac=300,ps=40,Pc=25,kk=300;function Tk(t,e){const n=x.keyBy(e,i=>i.id),r=[];return t.current.forEach((i,a)=>{i.panelIDs.forEach((l,c)=>{const u=Ic(c,ps,Pc)+bi,d=n[l];if(!d){r.push({id:l,_node_type:"panel",parentNode:i.id,data:{label:`!: ${l}`},position:{x:hs,y:u},sourcePosition:ve.Position.Right,targetPosition:ve.Position.Left,style:{width:Ac,height:ps}});return}const h=d.name;r.push({id:d.id,_node_type:"panel",parentNode:i.id,data:{label:h},position:{x:hs,y:u},sourcePosition:ve.Position.Right,targetPosition:ve.Position.Left,style:{width:Ac,height:ps}})})}),r}const Dk={[L.Division]:"Div",[L.Modal]:"Modal",[L.Tabs]:"Tabs"},zk=pc;function Ik(t){return t.current.map((n,r)=>{const i=wk(n.panelIDs.length,ps,Pc)+bi+Mc;let a=[];return n.type===L.Tabs&&(a=n.config.tabsInOrder.map(c=>c.view_id)),{id:n.id,_node_type:"view-root",_view_type:n.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:a,data:{label:`${Dk[n.type]}:${n.name}`},position:{x:0,y:0},sourcePosition:ve.Position.Right,targetPosition:ve.Position.Left,className:"light",style:{backgroundColor:zk[n.type],width:vi,height:i}}})}function Mk(t){const e=x.keyBy(t,n=>n.id);t.forEach(n=>{n._node_type!=="view-root"||n._view_type!==L.Tabs||n._tab_view_ids.forEach(r=>{e[r].parentNode=n.id})})}function Ek(t){const e=Ik(t.views);Mk(e);const n=Tk(t.views,t.panels.list);return[...e,...n]}function Ak({nodeMap:t,nodes:e,edges:n}){e.forEach(r=>{r._node_type!=="view-root"||r._view_type!==L.Tabs||(r.sourcePosition=ve.Position.Bottom,r.style.width=vi+hs*2,r.style.height=Mc+r._tab_view_ids.reduce((i,a)=>{const l=t[a];l.position.y=i,l.position.x=hs;const c=l.style.height;return i+c+20},bi))})}function Pk({nodeMap:t,nodes:e,edges:n}){n.filter(r=>r.label==="Open View").forEach(r=>{const i=t[r.source],a=t[r.target];if(!i||!a||!i.parentNode)return;const l=t[i.parentNode];l._node_type!=="view-root"||a._node_type!=="view-root"||(a._view_level+=1+l._view_level,l._sub_view_ids.push(a.id))}),e.sort((r,i)=>r._node_type==="view-root"&&i._node_type==="view-root"?r._view_level-i._view_level:r._node_type!=="view-root"&&i._node_type!=="view-root"?0:r._node_type==="view-root"?-1:1)}function $k({nodeMap:t,nodes:e,edges:n}){const r={};n.forEach(i=>{if(i.label!=="Open View")return;const a=t[i.source],l=t[i.target];if(a&&l&&a.parentNode){const c=t[a.parentNode],u=c.position.x,d=Number(x.get(l,"style.height",0)),h=Number(c.style.width);l.position.x=u+h+kk,c._view_level===0&&l._sub_view_ids.length===0&&(a.sourcePosition=ve.Position.Left,l.targetPosition=ve.Position.Right,l.position.x*=-1);const g=l.position.x,y=x.get(r,g,0);l.position.y=y,r[g]=y+d+Ec}})}function qk({nodeMap:t,nodes:e,edges:n}){const r=new Set,i=new Set;n.forEach(l=>{r.add(l.source),i.add(l.target)}),e.filter(l=>l._node_type!=="view-root"||l.id==="Main"||l.parentNode?!1:!r.has(l.id)&&!i.has(l.id)).forEach((l,c)=>{l.position.x=Ic(c,vi,Sk),l.position.y=0-Ck-Ec})}function Lk({nodeMap:t,nodes:e,edges:n}){const r={nodeMap:t,nodes:e,edges:n};return qk(r),Pk(r),Ak(r),$k(r),{nodes:e,edges:n}}function Bk(t){const e=Ek(t),n=x.keyBy(e,u=>u.id),{edges:r,edgeNodes:i}=jk(t,n),a=[...e,...i],l=x.keyBy(a,u=>u.id),c={edges:x.uniqBy(r,u=>u.id),nodes:a,nodeMap:l};return Lk(c)}const iI="",_i={"builtin:op:open-link":s.jsx(o.ThemeIcon,{color:"blue",size:20,radius:"xl",children:s.jsx(k.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":s.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:s.jsx(k.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":s.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:s.jsx(k.IconCircleOff,{size:14})})};function Ok(t){const e=[];return t.forEach(n=>{switch(n.schemaRef){case"builtin:op:open-link":e.push({key:n.urlTemplate,icon:_i[n.schemaRef],text:s.jsxs(o.Group,{spacing:4,children:[s.jsx(o.Text,{children:"Open: "}),s.jsx(o.Text,{color:"dimmed",children:n.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":n.filters.forEach(({key:r,label:i})=>{e.push({key:n.schemaRef+r,icon:_i[n.schemaRef],text:s.jsx(o.Group,{spacing:4,children:s.jsxs(o.Text,{children:["Set Filter: ",i]})})})});return;case"builtin:op:clear_filter_values":n.filters.forEach(({key:r,label:i})=>{e.push({key:n.schemaRef+r,icon:_i[n.schemaRef],text:s.jsx(o.Group,{spacing:4,children:s.jsxs(o.Text,{children:["Clear Filter: ",i]})})})});return}}),e}const Vk=m.memo(({data:t,isConnectable:e,sourcePosition:n=ve.Position.Right,targetPosition:r=ve.Position.Left,...i})=>{const a=m.useMemo(()=>Ok(t.interactions),[t.interactions]);return s.jsxs(s.Fragment,{children:[s.jsx(ve.Handle,{type:"target",position:r,isConnectable:e}),s.jsx(o.Box,{sx:{position:"absolute",top:0,right:0},children:s.jsx(q.ChevronsUpRight,{size:12})}),s.jsxs(o.HoverCard,{shadow:"xl",withinPortal:!0,children:[s.jsx(o.HoverCard.Target,{children:s.jsx(o.Text,{children:t.label})}),s.jsx(o.HoverCard.Dropdown,{children:s.jsx(o.List,{spacing:"xs",size:"sm",center:!0,children:a.map(l=>s.jsx(o.List.Item,{icon:l.icon,children:l.text},l.key))})})]}),s.jsx(ve.Handle,{type:"source",position:n,isConnectable:e})]})}),aI="",Nk={interaction:Vk},Fk=S.observer(()=>{const t=de(),{edges:e,nodes:n}=Bk(t);return s.jsxs(ve,{nodes:n,edges:e,onNodesChange:x.noop,onEdgesChange:x.noop,onConnect:x.noop,className:"interactions-viewer",fitView:!0,nodeTypes:Nk,children:[s.jsx(ve.MiniMap,{}),s.jsx(ve.Controls,{}),s.jsx(ve.Background,{})]})}),Gk=S.observer(({opened:t,close:e})=>{const{t:n}=_.useTranslation();return s.jsx(o.Modal,{size:"96vw",opened:t,onClose:e,title:n("interactions.interactions_viewer"),trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{body:{height:"calc(90vh - 54px)"},content:{transform:"none !important"}},zIndex:300,children:s.jsx(Fk,{})})}),Wk={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}};function Qk({onClick:t,name:e,active:n,openSettings:r}){return s.jsxs(o.Box,{sx:{position:"relative"},children:[s.jsx(o.UnstyledButton,{sx:i=>({display:"block",width:"100%",padding:i.spacing.xs,borderRadius:0,position:"relative",color:i.black,"&:hover":{backgroundColor:i.colors.gray[0]},backgroundColor:n?i.colors.gray[2]:"transparent"}),children:s.jsx(o.Group,{sx:{width:"calc(100% - 28px)"},onClick:t,children:s.jsx(o.Text,{size:"sm",children:e})})}),n&&s.jsx(o.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:s.jsx(o.ActionIcon,{onClick:r,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:s.jsx(k.IconAdjustments,{size:16})})})]})}const Rk=S.observer(()=>{const{t}=_.useTranslation(),e=X(),n=W(),r=m.useCallback(a=>()=>n.views.setIDOfVIE(a),[n]),i=a=>{e.editor.open(["_VIEWS_",a])};return s.jsxs(o.Box,{sx:{position:"relative"},children:[n.views.options.map(a=>s.jsx(Qk,{active:n.views.idOfVIE===a.value,name:a.label,onClick:r(a.value),openSettings:()=>i(a.value)},a.value)),s.jsx(o.Divider,{variant:"dashed"}),s.jsx(o.Button,{variant:"subtle",rightIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:n.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:t("view.add")})]})}),Yk=S.observer(()=>{const{t}=_.useTranslation(),e=X(),n=W(),r=()=>{if(!n.queries.firstID){e.editor.open(["_QUERIES_",""]);return}e.editor.open(["_QUERIES_",n.queries.firstID])},i=()=>{if(!n.filters.firstID){e.editor.open(["_FILTERS_",""]);return}e.editor.open(["_FILTERS_",n.filters.firstID])},[a,l]=m.useState(!1),c=()=>l(!0),u=()=>l(!1);return s.jsxs(o.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},zIndex:299,children:[s.jsxs(o.Navbar.Section,{children:[s.jsxs(o.Group,{grow:!0,spacing:0,sx:{...Wk,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[s.jsx(o.Tooltip,{label:t("filter.labels"),withinPortal:!0,children:s.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:i,children:s.jsx(k.IconFilter,{size:18})})}),s.jsx(o.Tooltip,{label:t("query.labels"),withinPortal:!0,children:s.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:r,children:s.jsx(k.IconDatabase,{size:18})})}),s.jsx(o.Tooltip,{label:t("interactions.interactions_viewer"),withinPortal:!0,children:s.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:c,children:s.jsx(k.IconLink,{size:18})})})]}),s.jsx(Gk,{opened:a,close:u})]}),s.jsx(o.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:s.jsx(o.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:t("view.labels")})}),s.jsx(o.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:s.jsx(Rk,{})}),s.jsx(o.Navbar.Section,{children:s.jsx(o.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:s.jsx(o.Button,{size:"xs",leftIcon:s.jsx(k.IconSettings,{size:20}),onClick:()=>e.editor.open([]),children:t("common.titles.settings")})})})]})}),Uk=["function getDefaultValue(filter, utils, context) {",' return "";',"}"].join(`
|
|
449
449
|
`),Kt=S.observer(({filter:t})=>{const{t:e}=_.useTranslation();return s.jsx(To,{label:"",title:e("filter.field.custom_default_value.title"),triggerLabel:e("filter.field.custom_default_value.trigger"),value:t.default_value_func,onChange:t.setDefaultValueFunc,defaultValue:Uk,triggerButtonProps:{size:"xs",color:"grape",sx:{flexGrow:0,alignSelf:"flex-start"},leftIcon:s.jsx(k.IconMathFunction,{size:16})},description:s.jsx(o.Alert,{title:e("filter.field.custom_default_value.tips"),color:"gray",mb:16,children:s.jsxs(o.List,{size:13,type:"ordered",children:[s.jsx(o.List.Item,{children:e("filter.field.custom_default_value.tip_1")}),s.jsx(o.List.Item,{children:e("filter.field.custom_default_value.tip_2")})]})})})}),Kk=S.observer(function({filter:e}){const{t:n}=_.useTranslation(),r=e.config;return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Checkbox,{checked:r.default_value,onChange:i=>r.setDefaultValue(i.currentTarget.checked),label:n("filter.widget.checkbox.default_checked")}),s.jsx(Kt,{filter:e})]}),s.jsx(vr,{label:n("filter.widget.checkbox.description"),value:r.description,onChange:r.setDescription,styles:{root:{flexGrow:1,minHeight:"400px"}}})]})}),Jk=[{label:"2022",value:"YYYY"},{label:"202201",value:"YYYYMM"},{label:"20220101",value:"YYYYMMDD"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],Xk=S.observer(function({filter:e}){const{t:n}=_.useTranslation(),r=e.config,i=m.useMemo(()=>Br().map(({key:a,value:l,group:c})=>({label:n(`filter.widget.date_range.shortcut.${c}.full.${a}`),value:l,group:n(`filter.widget.date_range.shortcut.${c}.label`)})),[]);return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{children:[s.jsx(o.Checkbox,{checked:r.required,onChange:a=>r.setRequired(a.currentTarget.checked),label:n("filter.widget.date_range.required")}),s.jsx(o.Checkbox,{checked:r.allowSingleDateInRange,onChange:a=>r.setAllowSingleDateInRange(a.currentTarget.checked),label:n("filter.widget.date_range.allow_single_date")})]}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(o.Select,{data:Jk,label:n("filter.widget.date_range.display_format"),value:r.inputFormat,onChange:r.setInputFormat}),s.jsx(o.NumberInput,{label:n("filter.widget.date_range.max_days"),min:0,value:r.max_days,onChange:r.setMaxDays,hideControls:!0})]}),s.jsxs(o.Group,{children:[s.jsx(fl,{label:n("filter.widget.date_range.default_value"),config:r,value:r.default_value,onChange:r.setDefaultValue,disabled:!!r.default_shortcut}),s.jsx(o.Select,{data:i,label:n("filter.widget.date_range.default_by_shortcut"),value:r.default_shortcut,onChange:r.setDefaultShortcut,placeholder:n("filter.widget.date_range.default_by_shortcut_placeholder"),clearable:!0,sx:{flexGrow:1},maxDropdownHeight:500})]}),s.jsx(Kt,{filter:e})]})}),ji=S.observer(({value:t,onChange:e})=>{const{t:n}=_.useTranslation(),r=X(),i=W(),a=m.useMemo(()=>i.queries.options,[i.queries.current]),l=a.length===0,c=u=>{r.editor.setPath(["_QUERIES_",u])};return s.jsx(o.Select,{label:s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Text,{children:n("filter.widget.common.use_query_data_as_options")}),t&&s.jsx(o.Button,{size:"xs",leftIcon:s.jsx(k.IconArrowCurveRight,{size:16}),variant:"subtle",color:"blue",onClick:()=>c(t),children:n("query.open")})]}),data:a,value:t,onChange:e,allowDeselect:!1,clearable:!0,sx:{flexGrow:1},disabled:l,error:l?"You need to add a query in Data Settings":void 0,styles:{label:{display:"block"}}})}),Zk=`
|
|
450
450
|
// row
|
|
451
451
|
{
|
|
@@ -476,7 +476,7 @@ WHERE
|
|
|
476
476
|
AND \${global_sql_snippets.account_condition}
|
|
477
477
|
`,Nc=S.observer(function({showSQLSnippets:e=!0,sx:n={}}){const{t:r}=_.useTranslation(),i=X(),a=W(),l=i.context.current,c=(()=>{const u={context:{...a.mock_context.current,...l},filters:a.filters.previewValues};return e&&(u.sql_snippets=a.sqlSnippets.record),JSON.stringify(u,null,2)})();return s.jsx(o.Stack,{sx:{overflow:"hidden",...n},children:s.jsxs(o.Tabs,{defaultValue:"guide",keepMounted:!1,children:[s.jsxs(o.Tabs.List,{grow:!0,children:[s.jsx(o.Tabs.Tab,{value:"guide",icon:s.jsx(k.IconAlertCircle,{size:14}),children:r("query_variable.guide.tabs.guide")}),s.jsx(o.Tabs.Tab,{value:"local_query_vars",icon:s.jsx(k.IconVariable,{size:14}),children:r("query_variable.guide.tabs.variables_in_this_dashboard")}),s.jsx(o.Tabs.Tab,{value:"global_sql_snippets",icon:s.jsx(k.IconVariablePlus,{size:14}),children:r("query_variable.guide.tabs.global_sql_snippets")})]}),s.jsx(o.Tabs.Panel,{value:"guide",pt:"xs",children:s.jsx(bt.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:xT})}),s.jsx(o.Tabs.Panel,{value:"local_query_vars",pt:"xs",children:s.jsx(bt.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:c})}),s.jsx(o.Tabs.Panel,{value:"global_sql_snippets",pt:"xs",children:s.jsxs(o.Stack,{spacing:10,children:[s.jsx(o.Alert,{icon:s.jsx(k.IconAlertCircle,{size:16}),title:r("global_sql_snippet.labels"),children:r("global_sql_snippet.description")}),s.jsx(gT,{})]})})]})})}),ki=S.observer(()=>{const{t}=_.useTranslation(),[e,n]=m.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx(o.Modal,{opened:e,onClose:()=>n(!1),title:t("query_variable.labels"),zIndex:320,size:"800px",children:s.jsx(Nc,{})}),s.jsx(o.Button,{variant:"subtle",onClick:()=>n(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},children:t("query_variable.open")})]})}),Fc={pre:["function build_request({ context, filters }, utils) {"," // build the quest"," return { method: 'POST', url: '/', params: {}, headers: {}, data: {} }","}"].join(`
|
|
478
478
|
`),post:["function process_result(res, utils, state) {"," // your code goes here"," return data","}"].join(`
|
|
479
|
-
`)},yT=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation();return t.typedAsHTTP?s.jsxs(o.Tabs,{defaultValue:"pre_process",orientation:"vertical",sx:{flexGrow:1},children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"pre_process",children:e("query.build_request")}),s.jsx(o.Tabs.Tab,{value:"post_process",children:e("query.process_result")}),s.jsx(ki,{})]}),s.jsx(o.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:s.jsx(Gt,{label:"",value:t.pre_process,onChange:t.setPreProcess,defaultValue:Fc.pre})}),s.jsx(o.Tabs.Panel,{value:"post_process",p:"sm",children:s.jsx(Gt,{label:"",value:t.post_process,onChange:t.setPostProcess,defaultValue:Fc.post})})]}):null}),bT=S.observer(({queryID:t,usage:e})=>{const{t:n}=_.useTranslation(),r=X().editor,i=l=>{if(l.type==="filter"){r.setPath(["_FILTERS_",l.id]);return}if(l.type==="panel"){const c=l.views[0].id;r.setPath(["_VIEWS_",c,"_PANELS_",l.id]);return}},a=l=>{r.setPath(["_VIEWS_",l])};return s.jsx(o.Stack,{py:"sm",px:"md",children:s.jsxs(o.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:100},children:n("common.type")}),s.jsx("th",{style:{width:"calc(50% - 50px)"},children:n("common.name")}),s.jsx("th",{children:n("query.usage.in_views")})]})}),s.jsx("tbody",{children:e.map(l=>s.jsxs("tr",{children:[s.jsx("td",{children:n(
|
|
479
|
+
`)},yT=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation();return t.typedAsHTTP?s.jsxs(o.Tabs,{defaultValue:"pre_process",orientation:"vertical",sx:{flexGrow:1},children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"pre_process",children:e("query.build_request")}),s.jsx(o.Tabs.Tab,{value:"post_process",children:e("query.process_result")}),s.jsx(ki,{})]}),s.jsx(o.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:s.jsx(Gt,{label:"",value:t.pre_process,onChange:t.setPreProcess,defaultValue:Fc.pre})}),s.jsx(o.Tabs.Panel,{value:"post_process",p:"sm",children:s.jsx(Gt,{label:"",value:t.post_process,onChange:t.setPostProcess,defaultValue:Fc.post})})]}):null}),bT=S.observer(({queryID:t,usage:e})=>{const{t:n}=_.useTranslation(),r=X().editor,i=l=>{if(l.type==="filter"){r.setPath(["_FILTERS_",l.id]);return}if(l.type==="panel"){const c=l.views[0].id;r.setPath(["_VIEWS_",c,"_PANELS_",l.id]);return}},a=l=>{r.setPath(["_VIEWS_",l])};return s.jsx(o.Stack,{py:"sm",px:"md",children:s.jsxs(o.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:100},children:n("common.type")}),s.jsx("th",{style:{width:"calc(50% - 50px)"},children:n("common.name")}),s.jsx("th",{children:n("query.usage.in_views")})]})}),s.jsx("tbody",{children:e.map(l=>s.jsxs("tr",{children:[s.jsx("td",{children:n(l.type_label)}),s.jsx("td",{children:s.jsx(o.Anchor,{component:"button",type:"button",onClick:()=>i(l),children:l.label})}),s.jsx("td",{children:s.jsxs(o.Stack,{align:"flex-start",justify:"flex-start",spacing:2,children:[l.views.map(c=>s.jsx(o.Anchor,{component:"button",type:"button",onClick:()=>a(c.id),children:s.jsx(o.Box,{children:c.label})},c.id)),l.views.length===0&&s.jsx(o.Box,{children:"--"})]})})]},l.id))})]})})}),Ti=({value:t,onChange:e,height:n="200px",defaultLanguage:r="sql",theme:i="vs-dark"})=>{const a=c=>{e==null||e(c??"")},l=!e;return s.jsx(Pe,{className:"minimal-monaco-editor",height:n,defaultLanguage:r,value:t,onChange:l?void 0:a,theme:i,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:l||!e,"semanticHighlighting.enabled":!0}})},vT=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation(),n=m.useMemo(()=>x.groupBy(t.dependencies,"type"),[t.dependencies]),r=m.useMemo(()=>t.dependencies.some(a=>!a.valid),[t.dependencies]),i=t.dependencies.length>0;return i?s.jsxs(o.HoverCard,{withinPortal:!0,zIndex:340,shadow:"md",disabled:!i,children:[s.jsx(o.HoverCard.Target,{children:s.jsx(o.Button,{size:"xs",variant:"subtle",color:r?"red":"green",disabled:!i,leftIcon:r?s.jsx(k.IconAlertTriangle,{size:16}):s.jsx(k.IconDiscountCheckFilled,{size:16}),children:e("query.dependency.label")})}),s.jsx(o.HoverCard.Dropdown,{children:s.jsx(o.List,{spacing:"md",size:14,listStyleType:"none",children:Object.entries(n).map(([a,l])=>s.jsxs(o.List.Item,{children:[s.jsx(o.Text,{fw:"bold",ff:"monospace",children:e(`${a}.label`)}),s.jsx(o.List,{withPadding:!0,size:14,sx:{fontFamily:"monospace",svg:{verticalAlign:"middle"}},children:l.map(c=>s.jsx(o.List.Item,{icon:s.jsx(o.Box,{sx:{path:{fill:c.valid?"rgb(18, 184, 134)":"rgb(250, 82, 82)"}},children:s.jsx(k.IconPointFilled,{size:12})}),children:c.key},c.key))})]},a))})})]}):s.jsx(o.Tooltip,{label:e("query.dependency.has_none"),children:s.jsx(o.Button,{size:"xs",variant:"subtle",color:"gray",leftIcon:s.jsx(k.IconHierarchy,{size:16,style:{transform:"rotate(180deg)"}}),sx:{transform:"none !important"},children:e("query.dependency.label")})})}),_T="SELECT 1",jT=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation(),[n,r]=m.useState(t.sql),i=()=>{t.setSQL(n)},a=()=>{r(t.sql)},l=()=>{r(_T)};m.useEffect(()=>{r(t.sql)},[t.sql]);const c=n!==t.sql;return s.jsxs(o.Stack,{spacing:4,sx:{height:"100%"},children:[s.jsxs(o.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[s.jsx(o.Group,{position:"left",children:s.jsx(vT,{queryModel:t})}),s.jsxs(o.Group,{position:"right",children:[s.jsx(o.Button,{onClick:l,size:"xs",variant:"default",leftIcon:s.jsx(k.IconPlayerSkipBack,{size:16}),children:e("common.actions.reset_to_default")}),s.jsx(o.Button,{onClick:a,color:"red",size:"xs",disabled:!c,leftIcon:s.jsx(k.IconRecycle,{size:16}),children:e("common.actions.revert_changes")}),s.jsx(o.Button,{color:"green",size:"xs",onClick:i,disabled:!c,leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),children:e("common.actions.save_changes")})]})]}),s.jsx(Ti,{height:"100%",value:n,onChange:r,theme:"sql-dark",defaultLanguage:"sql"})]})}),wT=({value:t,height:e="200px",defaultLanguage:n="sql"})=>s.jsx(Pe,{className:"preview-sql-in-monaco-editor",height:e,defaultLanguage:n,value:t,onChange:void 0,theme:"vs-light",options:{lineNumbers:"on",folding:!0,lineDecorationsWidth:20,wordWrap:"on",minimap:{enabled:!1},readOnly:!0}}),CT=S.observer(({value:t})=>{const n=de().payloadForSQL,r=m.useMemo(()=>js(t,n),[t,n]);return s.jsx(wT,{height:"100%",value:r})}),Gc={pre:["function process_request({ context, filters, sql }, utils) {"," // modify and return sql"," return sql","}"].join(`
|
|
480
480
|
`),post:["function process_result(data, utils, state) {"," // process data and return the result"," return data","}"].join(`
|
|
481
481
|
`)},ST=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation();return t.typedAsSQL?s.jsxs(o.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%",height:"28px",lineHeight:"28px"}},keepMounted:!1,children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"Edit",children:s.jsx(o.Group,{spacing:14,position:"apart",children:e("query.edit_sql")})}),s.jsx(o.Tabs.Tab,{value:"Preview",children:e("query.preview_sql")}),s.jsx(o.Tabs.Tab,{value:"pre_process",children:e("query.process_request")}),s.jsx(o.Tabs.Tab,{value:"post_process",children:e("query.process_result")}),s.jsx(ki,{}),t.datasource&&s.jsx(Oc,{dataSource:t.datasource})]}),s.jsx(o.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:s.jsx(jT,{queryModel:t})}),s.jsx(o.Tabs.Panel,{value:"Preview",p:0,pl:4,children:s.jsx(CT,{value:t.sql})}),s.jsx(o.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:s.jsx(Gt,{label:"",value:t.pre_process,onChange:t.setPreProcess,defaultValue:Gc.pre})}),s.jsx(o.Tabs.Panel,{value:"post_process",p:"sm",children:s.jsx(Gt,{label:"",value:t.post_process,onChange:t.setPostProcess,defaultValue:Gc.post})})]}):null}),kT={pre:["function transform(queries, state, utils) {"," // use queries & dashboar state to build new data"," const data = []"," return data","}"].join(`
|
|
482
482
|
`),post:""},TT=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation(),n=W();return t.isTransform?s.jsxs(o.Stack,{py:20,px:20,sx:{height:"100%"},children:[s.jsx(o.Text,{size:"sm",children:e("query.transform.guide.pick_queries")}),s.jsx(o.MultiSelect,{data:n.queries.optionsWithoutTransform,value:[...t.dep_query_ids],onChange:t.setDependantQueryIDs,maxDropdownHeight:800}),s.jsx(o.Text,{size:"sm",children:e("query.transform.guide.write_function")}),s.jsx(o.Box,{sx:{flexGrow:1},children:s.jsx(Gt,{label:"",value:t.pre_process,onChange:t.setPreProcess,defaultValue:kT.pre})})]}):null}),yn={height:"calc(100% - 44px)",padding:0},DT=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation(),n=W(),r=m.useMemo(()=>t.datasource?t.typedAsHTTP?"HTTP":"SQL":"Configurations",[t.datasource,t.typedAsHTTP]),[i,a]=m.useState(r);m.useEffect(()=>{a(u=>u!=="Configurations"&&r==="Configurations"?"Configurations":u)},[r]);const l=n.findQueryUsage(t.id),c=l.length===0;return s.jsxs(o.Tabs,{value:i,onTabChange:a,defaultValue:r,orientation:"horizontal",keepMounted:!1,sx:{height:"100vh"},children:[s.jsxs(o.Tabs.List,{grow:!0,children:[s.jsx(o.Tabs.Tab,{value:"Configurations",children:e("query.configurations")}),t.typedAsSQL&&s.jsx(o.Tabs.Tab,{value:"SQL",children:e("query.request")}),t.typedAsHTTP&&s.jsx(o.Tabs.Tab,{value:"HTTP",children:e("query.request")}),t.isTransform&&s.jsx(o.Tabs.Tab,{value:"Transform",children:e("query.transform.label")}),s.jsx(o.Tabs.Tab,{value:"Data",disabled:!t.canPreviewData,children:s.jsx(o.Tooltip,{label:t.guideToPreviewData,disabled:t.canPreviewData,withinPortal:!0,children:s.jsx(o.Text,{children:e("data.preview_data")})})}),s.jsx(o.Tabs.Tab,{value:"Usage",disabled:c,children:s.jsx(o.Tooltip,{label:e("query.usage.unused_description"),disabled:!c,withinPortal:!0,children:s.jsx(o.Text,{children:e("query.usage.label")})})})]}),s.jsx(o.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:s.jsx(mT,{queryModel:t})}),t.typedAsSQL&&s.jsx(o.Tabs.Panel,{value:"SQL",sx:yn,children:s.jsx(o.Stack,{sx:{height:"100%"},children:s.jsx(ST,{queryModel:t})})}),t.typedAsHTTP&&s.jsx(o.Tabs.Panel,{value:"HTTP",sx:yn,children:s.jsx(o.Stack,{sx:{height:"100%"},children:s.jsx(yT,{queryModel:t})})}),t.isTransform&&s.jsx(o.Tabs.Panel,{value:"Transform",sx:yn,children:s.jsx(o.Stack,{sx:{height:"100%"},children:s.jsx(TT,{queryModel:t})})}),s.jsx(o.Tabs.Panel,{value:"Data",sx:{...yn,overflow:"hidden"},children:s.jsx(wi,{id:t.id,moreActions:null,refreshOnMount:!0})}),s.jsx(o.Tabs.Panel,{value:"Usage",sx:{...yn,overflow:"hidden"},children:s.jsx(bT,{queryID:t.id,usage:l})})]})}),zT=S.observer(({id:t})=>{const n=W().queries.findByID(t);return t===""?null:n?s.jsx(DT,{queryModel:n}):s.jsx(o.Text,{size:14,color:"red",children:"Invalid Query ID"})}),IT=S.observer(({value:t})=>{const n=de().payloadForSQL,r=m.useMemo(()=>js(t,n),[t,n]);return s.jsx(Ti,{height:"100%",value:r})}),MT=S.observer(({item:t,remove:e,onKeyChanged:n})=>{const{t:r}=_.useTranslation(),[i,a]=m.useState("SQL"),[l,c]=m.useState(t.key),u=()=>{t.setKey(l),n(l)},d=l!==t.key,h=t.isADuplicatedKey(l),[p,g]=m.useState(t.value),y=()=>{t.setValue(p)};m.useEffect(()=>{c(t.key),g(t.value)},[t]);const v=p!==t.value,C=Be.useModals(),T=()=>{C.openConfirmModal({title:`${r("sql_snippet.delete")}?`,labels:{confirm:r("common.actions.confirm"),cancel:r("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:e,confirmProps:{color:"red"},zIndex:320})};return s.jsxs(o.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[s.jsxs(o.Group,{sx:{alignItems:"end"},spacing:40,children:[s.jsx(o.TextInput,{label:r(h?"sql_snippet.key_occupied":"sql_snippet.key"),value:l,onChange:D=>{c(D.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:s.jsx(o.ActionIcon,{color:"blue",variant:"subtle",onClick:u,disabled:!d||h,children:s.jsx(q.DeviceFloppy,{size:16})}),error:h}),s.jsx(o.Button,{leftIcon:s.jsx(q.Trash,{size:16}),color:"red",variant:"light",onClick:T,children:r("sql_snippet.delete")})]}),s.jsxs(o.Tabs,{value:i,onTabChange:a,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[s.jsxs(o.Tabs.List,{sx:{position:"relative"},children:[s.jsx(o.Tabs.Tab,{value:"SQL",children:r("sql_snippet.edit_snippet")}),s.jsx(o.Tabs.Tab,{value:"Preview",children:r("sql_snippet.preview_snippet")}),s.jsx(ki,{}),s.jsx(o.ActionIcon,{color:"blue",variant:"filled",onClick:y,disabled:!v,sx:{position:"absolute",top:0,right:10},children:s.jsx(q.DeviceFloppy,{size:18})})]}),s.jsx(o.Tabs.Panel,{value:"SQL",pt:"sm",children:s.jsx(Ti,{height:"100%",value:p,onChange:g,defaultLanguage:"sql",theme:"sql-dark"})}),s.jsx(o.Tabs.Panel,{value:"Preview",pt:"sm",children:s.jsx(IT,{value:p})})]})]})}),ET=S.observer(({id:t})=>{const e=X(),n=W(),r=m.useMemo(()=>n.sqlSnippets.findByKey(t),[t]);if(!t)return null;if(!r)return s.jsxs(o.Text,{size:14,children:["SQL Snippet by key[",t,"] is not found"]});const i=()=>{e.editor.setPath(["_SQL_SNIPPETS_",""])},a=()=>{n.sqlSnippets.removeByKey(t),i()},l=c=>{e.editor.setPath(["_SQL_SNIPPETS_",c])};return s.jsx(MT,{item:r,remove:a,onKeyChanged:l})}),AT=S.observer(()=>{const{t}=_.useTranslation(),[e,n]=m.useState([]),r=Be.useModals(),i=X(),a=g=>{i.editor.setPath(["_SQL_SNIPPETS_",g])},l=()=>{r.openConfirmModal({title:"Delete ununsed SQL snippets?",children:s.jsx(o.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.content.removeUnusedSQLSnippets(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.sqlSnippets.downloadSchema(e)},u=m.useMemo(()=>i.content.sqlSnippets.sortedList.map(g=>g.key),[i.content.sqlSnippets.sortedList]),d=()=>{n(u)},h=()=>{n([])},p=i.content.sqlSnippetsUsage;return s.jsxs(o.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[s.jsx(o.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:s.jsx(o.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:t("sql_snippet.manage")})}),s.jsxs(o.Flex,{justify:"space-between",align:"center",px:12,children:[s.jsxs(o.Group,{position:"left",children:[s.jsxs(o.Button.Group,{children:[s.jsx(o.Button,{variant:"default",size:"xs",onClick:d,children:t("common.actions.select_all")}),s.jsx(o.Button,{variant:"default",size:"xs",onClick:h,children:t("common.actions.clear_selection")})]}),s.jsx(o.Button,{size:"xs",color:"blue",leftIcon:s.jsx(k.IconCode,{size:14}),disabled:e.length===0,onClick:c,children:t("common.actions.download_schema")})]}),s.jsx(o.Button,{variant:"subtle",size:"xs",color:"red",leftIcon:s.jsx(k.IconTrash,{size:14}),disabled:!i.content.hasUnusedSQLSnippets,onClick:l,children:t("sql_snippet.delete_unused")})]}),s.jsx(o.Box,{sx:{flexGrow:1,overflow:"auto"},children:s.jsx(o.Checkbox.Group,{size:"xs",value:e,onChange:n,children:s.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"40px"}}),s.jsx("th",{children:t("common.key")}),s.jsx("th",{style:{width:"100px",textAlign:"center"},children:t("sql_snippet.usage.label")}),s.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:t("common.action")})]})}),s.jsx("tbody",{children:i.content.sqlSnippets.sortedList.map(g=>{var v;const y=((v=p[g.key])==null?void 0:v.length)??0;return s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx(o.Checkbox,{value:g.key,styles:{input:{cursor:"pointer"}}})}),s.jsx("td",{children:g.key}),s.jsx("td",{style:{color:y===0?"#ff0000":"#000",fontWeight:y===0?"bold":"normal",textAlign:"center"},children:y}),s.jsx("td",{children:s.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>a(g.key),children:t("common.actions.open")})})]},g.key)})})]})})})]})}),PT=S.observer(({view:t})=>!t||t.type!==L.Division?null:s.jsx(o.Stack,{})),$T=S.observer(({view:t})=>{const{t:e,i18n:n}=_.useTranslation(),r=m.useMemo(()=>[{value:"default",label:e("common.tabs.variant.default")},{value:"outline",label:e("common.tabs.variant.outline")},{value:"pills",label:e("common.tabs.variant.pills")}],[n.language]),i=m.useMemo(()=>[{value:"horizontal",label:e("common.tabs.orientation.horizontal")},{value:"vertical",label:e("common.tabs.orientation.vertical")}],[n.language]);if(!t||t.type!==L.Tabs)return null;const a=t.config;return s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{mt:8,mb:0,label:e("view.component.tabs.tabs_settings"),labelPosition:"center"}),s.jsx(o.Select,{label:e("common.tabs.variant.label"),value:a.variant,onChange:a.setVariant,data:r}),s.jsx(o.Select,{label:e("common.tabs.orientation.label"),value:a.orientation,onChange:a.setOrientation,data:i}),s.jsx(o.Switch,{label:e("common.tabs.grow_tabs"),checked:a.grow,onChange:l=>a.setGrow(l.currentTarget.checked)})]})}),qT=({disabled:t,value:e,onChange:n})=>{const r=i=>{i&&n(i)};return s.jsxs(o.Box,{sx:{position:"relative"},children:[t&&s.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),s.jsx(Pe,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:t}})]})},LT=({value:t,onChange:e})=>{const{t:n}=_.useTranslation(),[r,{setTrue:i,setFalse:a}]=N.useBoolean(),[l,c]=m.useState(t??as),u=y=>{c({...l,enabled:y})},d=()=>{a();const{enabled:y,func_content:v}=l,C={enabled:y,func_content:v};c(C),e(C)},h=()=>{a(),c(t)},p=y=>{c(v=>({...v,func_content:y}))},g=()=>{p(as.func_content)};return s.jsxs(s.Fragment,{children:[s.jsx(o.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:i,sx:{flexGrow:0},children:s.jsx(q.Settings,{size:14})}),s.jsx(o.Modal,{size:800,title:n("view.component.modal.custom_title"),opened:r,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&s.jsxs(o.Stack,{children:[s.jsx(o.Checkbox,{mt:10,label:n("common.enabled"),checked:l.enabled,onChange:y=>u(y.currentTarget.checked)}),s.jsx(qT,{value:l.func_content,onChange:p,disabled:!l.enabled}),s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Button,{onClick:g,color:"red",leftIcon:s.jsx(q.Recycle,{size:20}),children:n("common.actions.revert")}),s.jsxs(o.Group,{position:"right",children:[s.jsx(o.Button,{onClick:h,variant:"subtle",children:n("common.actions.cancel")}),s.jsx(o.Button,{onClick:d,children:n("common.actions.save")})]})]})]})})]})},BT=S.observer(({view:t})=>{const{t:e}=_.useTranslation();if(!t||t.type!==L.Modal)return null;const n=t.config,r=n.custom_modal_title.value;return s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{mt:8,label:e("view.component.modal.modal_settings"),labelPosition:"center"}),s.jsxs(o.Flex,{gap:10,children:[s.jsx(o.TextInput,{label:e("view.component.modal.title"),value:r,onChange:x.noop,disabled:!0,sx:{flexGrow:1}}),s.jsx(LT,{value:n.custom_modal_title,onChange:n.custom_modal_title.replace})]}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(o.TextInput,{label:e("view.component.modal.width"),value:n.width,onChange:i=>n.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),s.jsx(o.TextInput,{label:e("view.component.modal.height"),value:n.height,onChange:i=>n.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),OT=S.observer(({view:t})=>s.jsxs(s.Fragment,{children:[s.jsx(PT,{view:t}),s.jsx(BT,{view:t}),s.jsx($T,{view:t})]})),VT=S.observer(({view:t})=>{const{t:e,i18n:n}=_.useTranslation(),r=m.useMemo(()=>[{label:e("view.component.div.label"),value:L.Division},{label:e("view.component.modal.label"),value:L.Modal},{label:e("view.component.tabs.label"),value:L.Tabs}],[n.language]);return t?s.jsxs(o.Stack,{sx:{position:"relative"},children:[s.jsx(o.TextInput,{label:e("common.name"),value:t.name,onChange:i=>{t.setName(i.currentTarget.value)}}),s.jsx(o.Select,{label:e("common.type"),withinPortal:!0,zIndex:320,value:t.type,onChange:t.setType,data:r}),s.jsx(OT,{view:t})]}):null}),NT=S.observer(({id:t})=>{const{t:e}=_.useTranslation(),n=Be.useModals(),r=X(),i=W();if(t==="")return null;const a=i.views.findByID(t);if(!a)return s.jsxs(o.Text,{size:14,children:["View by ID[",t,"] is not found"]});const l=()=>{r.editor.setPath(["_VIEWS_",""])},c=()=>{n.openConfirmModal({title:`${e("view.delete")}?`,labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.views.removeByID(t),l()},zIndex:320})};return s.jsxs(o.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[s.jsx(o.Group,{position:"right",pt:10,children:s.jsx(o.Button,{size:"xs",color:"red",leftIcon:s.jsx(q.Trash,{size:16}),onClick:c,children:e("view.delete")})}),s.jsx(o.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:s.jsx(VT,{view:a})})]})});function FT(t){return t.length===1&&t[0]==="_QUERY_VARS_"}function GT(t){return t.length===1&&t[0]==="_MOCK_CONTEXT_"}function WT(t){return t.length===1&&t[0]==="_FILTERS_"}function QT(t){return t.length===2&&t[0]==="_FILTERS_"}function RT(t){return t.length===1&&t[0]==="_SQL_SNIPPETS_"}function YT(t){return t.length===2&&t[0]==="_SQL_SNIPPETS_"}function UT(t){return t.length===2&&t[0]==="_QUERIES_"}function KT(t){return t.length===1&&t[0]==="_QUERIES_"}function JT(t){return t.length===2&&t[0]==="_VIEWS_"}function XT(t){return t.length===4&&t[0]==="_VIEWS_"&&t[2]==="_PANELS_"}const ZT=S.observer(()=>s.jsx(o.Stack,{sx:{height:"100%"},p:"sm",children:s.jsx(Nc,{})})),HT=S.observer(()=>{const t=X().editor,e=t.path;return FT(e)?s.jsx(ZT,{}):GT(e)?s.jsx(u1,{}):WT(e)?s.jsx(c1,{}):QT(e)?s.jsx(o.Box,{p:"xs",pl:20,children:s.jsx(l1,{id:e[1]})}):RT(e)?s.jsx(AT,{}):YT(e)?s.jsx(ET,{id:e[1]}):KT(e)?s.jsx(Y1,{}):UT(e)?s.jsx(zT,{id:e[1]}):JT(e)?s.jsx(o.Box,{p:"xs",pl:20,children:s.jsx(NT,{id:e[1]})}):XT(e)?s.jsx(R1,{viewID:e[1],panelID:e[3]}):s.jsx(o.Box,{children:t.path})}),eD=S.observer(()=>s.jsx(HT,{})),tD=S.observer(()=>{const{t}=_.useTranslation(),e=X(),n=()=>{const r=new Date().getTime().toString(),i={id:r,key:r,label:r,order:e.content.filters.current.length+1,type:pe.TextInput,config:Ur(),visibleInViewsIDs:["Main"],auto_submit:!1};e.content.filters.append(i),e.editor.setPath(["_FILTERS_",r])};return s.jsx(o.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("filter.add")})}),nD=S.observer(({parentID:t})=>{const{t:e}=_.useTranslation(),n=W();if(!t)return null;const r=n.views.findByID(t);return!r||r.type===L.Tabs?null:s.jsx(o.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>n.addANewPanel(r.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("panel.add")})}),sD=S.observer(()=>{const{t}=_.useTranslation(),e=X(),n=()=>{const r=new Date().getTime().toString(),i={id:r,name:r,type:ce.Postgresql,key:"",sql:""};e.content.queries.append(i),e.editor.setPath(["_QUERIES_",r])};return s.jsx(o.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("query.add")})}),rD=S.observer(()=>{const{t}=_.useTranslation(),e=X(),n=()=>{const r=new Date().getTime().toString(),i={key:r,value:""};e.content.sqlSnippets.append(i),e.editor.setPath(["_SQL_SNIPPETS_",r])};return s.jsx(o.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("sql_snippet.add")})}),iD=S.observer(()=>{const{t}=_.useTranslation(),e=W();return s.jsx(o.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:e.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("view.add")})}),aD=S.observer(()=>{const{t}=_.useTranslation(),e=X();return s.jsx(o.Button,{variant:"subtle",rightIcon:s.jsx(k.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>e.editor.setPath(["_QUERIES_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:t("query.manage")})}),oD=S.observer(()=>{const{t}=_.useTranslation(),e=X();return s.jsx(o.Button,{variant:"subtle",rightIcon:s.jsx(k.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>e.editor.setPath(["_SQL_SNIPPETS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:t("sql_snippet.manage")})}),lD=S.observer(()=>{const{t}=_.useTranslation(),e=X();return s.jsx(o.Button,{variant:"subtle",rightIcon:s.jsx(k.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>e.editor.setPath(["_FILTERS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:t("filter.manage")})}),cD=S.observer(({action_type:t,parentID:e})=>t==="_Add_A_Filter_"?s.jsx(tD,{}):t==="_Add_A_SQL_SNIPPET_"?s.jsx(rD,{}):t==="_Add_A_QUERY_"?s.jsx(sD,{}):t==="_Add_A_VIEW_"?s.jsx(iD,{}):t==="_Add_A_PANEL_"?s.jsx(nD,{parentID:e}):t==="_QUERIES_SETTINGS_"?s.jsx(aD,{}):t==="_SQL_SNIPPETS_SETTINGS_"?s.jsx(oD,{}):t==="_FILTERS_SETTINGS_"?s.jsx(lD,{}):null),Wc=S.observer(({option:t})=>{var h;const{t:e}=_.useTranslation(),n=X().editor,r=n.isOptionActive,i=r(n.path,t),a=n.isOptionOpened,l=n.navigate,c=a(t),[u,d]=m.useState(c);return m.useEffect(()=>{d(c)},[c]),s.jsx(o.NavLink,{active:i,defaultOpened:c,opened:u,onChange:d,label:e(t.label),onClick:()=>l(t),icon:t.Icon?s.jsx(t.Icon,{size:18}):null,children:(h=t.children)==null?void 0:h.map(p=>p._type==="ACTION"?s.jsx(cD,{action_type:p._action_type,parentID:p.parentID},`_ADD_${p.value}_`):s.jsx(Wc,{option:p},p.value))},t.label)}),uD=S.observer(()=>{const t=X();return s.jsx(o.Box,{sx:{position:"relative"},children:t.editor.navOptions.map(e=>s.jsx(Wc,{option:e},e.value))})}),dD=S.observer(()=>{const{t}=_.useTranslation(),e=X();return s.jsxs(o.Navbar,{p:0,width:{base:220,xs:220,sm:240,md:260,lg:300,xl:320},sx:{height:"100vh - 60px - 60px",".mantine-NavLink-body":{wordWrap:"break-word"}},children:[s.jsx(o.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:s.jsx(o.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:t("common.titles.settings")})}),s.jsx(o.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:s.jsx(uD,{})}),s.jsx(o.Navbar.Section,{children:s.jsx(o.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:s.jsx(o.Button,{size:"xs",color:"red",leftIcon:s.jsx(k.IconX,{size:18}),onClick:()=>e.editor.close(),children:t("common.actions.close")})})})]})}),hD={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden",minWidth:"calc(var(--mantine-navbar-width, 0px) + 1200px)"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},pD=S.observer(()=>{const t=X().editor;return s.jsx(o.Modal,{onClose:()=>t.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:t.settings_open,fullScreen:!0,title:null,transitionProps:{duration:0},withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{body:{padding:"0 !important"},content:{overflowY:"hidden !important"}},children:s.jsx(o.AppShell,{padding:0,navbar:s.jsx(dD,{}),styles:hD,children:s.jsx(eD,{})})})}),mD=t=>t.replace(/([^:])(\/\/+)/g,"$1/");function fD(t){m.useEffect(()=>{if(Pe.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const n=mD(t);Pe.loader.config({paths:{vs:n}}),Pe.loader.init().then(r=>console.log("monaco instance:",r))},[])}fa(),xa();const gD={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},xD=({context:t,dashboard:e,content:n,update:r,className:i="dashboard",config:a,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:h,lang:p},g)=>{fD(a.monacoPath),ws(a);const{data:y=[]}=N.useRequest(Ds),{data:v=[]}=N.useRequest(ya),C=m.useMemo(()=>wc(e,n,y,v,t,u??{}),[e,n]);m.useImperativeHandle(g,()=>C,[C]),Sc(C.content,!0),m.useEffect(()=>{C.context.replace(t)},[t]),m.useEffect(()=>{C.datasources.replace(y)},[y]),m.useEffect(()=>{C.globalSQLSnippets.replace(v)},[v]),m.useEffect(()=>{d==null||d(C.content.filters.values)},[d,C.content.filters.values]),m.useEffect(()=>{u&&C.content.filters.patchValues(u)},[u,C.content.filters.patchValues]),m.useEffect(()=>U.reaction(()=>U.toJS(C.json),$=>{l==null||l($)}),[C]);const T=async()=>{await r(C.json,C.content.json)},D=N.useCreation(qr,[]),M=kc(D);return s.jsx(Cc,{lang:p,children:s.jsx(Be.ModalsProvider,{children:s.jsx(Ls,{children:s.jsx(As,{value:{searchButtonProps:a.searchButtonProps},children:s.jsx(Ms,{value:C,children:s.jsx(Ps,{value:C.content,children:s.jsx(Mn.Provider,{value:{inEditMode:!0},children:s.jsx(it.Provider,{value:D,children:s.jsxs(rs,{configure:M,children:[s.jsx(o.AppShell,{padding:0,header:s.jsx(vk,{onExit:h,saveDashboardChanges:T,headerSlot:c}),navbar:s.jsx(Yk,{}),styles:gD,children:s.jsx(o.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:C.content.views.visibleViews.map($=>s.jsx(dc,{view:$},$.id))})}),s.jsx(pD,{})]})})})})})})})})})},yD=S.observer(m.forwardRef(xD)),oI="",Di=f.types.model({id:f.types.string,name:f.types.string,dashboard_id:f.types.string,create_time:f.types.string,update_time:f.types.string,version:f.types.string,filters:oi,queries:ui,sqlSnippets:hi,views:ri,panels:ai,layouts:di,mock_context:Vr}).views(t=>({get json(){return{id:t.id,name:t.name,create_time:t.create_time,update_time:t.update_time,dashboard_id:t.dashboard_id,content:{views:t.views.json,panels:t.panels.json,filters:t.filters.json,version:t.version,layouts:t.layouts.json,definition:{queries:t.queries.json,sqlSnippets:t.sqlSnippets.json,mock_context:t.mock_context.current}}}},get contentJSON(){return this.json.content},get payloadForSQL(){const e=f.getParent(t).context.current,n=f.getParent(t).globalSQLSnippets,r={context:{...t.mock_context.current,...e},filters:t.filters.values};return{...r,sql_snippets:gn(t.sqlSnippets.current,"key","value",r),global_sql_snippets:gn(n.list,"id","content",r)}},get payloadForViz(){const e=f.getParent(t).context.current;return{context:{...t.mock_context.current,...e},filters:t.filters.values}},get dashboardState(){return Ts(this.payloadForSQL)},getAdditionalQueryInfo(e){return{content_id:t.id,query_id:e,params:this.dashboardState}},get data(){return t.queries.current.map(({id:n,data:r})=>({id:n,data:r})).reduce((n,r)=>(n[r.id]=r.data,n),{})},getDataStuffByID(e){const n=t.queries.findByID(e);return n?{data:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).actions(t=>({}));function Qc({id:t,name:e,dashboard_id:n,create_time:r,update_time:i,content:a},l,c){if(!a)throw new Error("unexpected null content when creating a content model");const{version:u,filters:d,views:h,panels:p,layouts:g,definition:{queries:y,sqlSnippets:v,mock_context:C={}}}=a;return Di.create({id:t,name:e,dashboard_id:n,create_time:r,update_time:i,version:u,filters:li(d,l,C,c),queries:Rl(y),sqlSnippets:Kl(v),mock_context:Nr(C),views:Bl(h),panels:{list:p},layouts:{list:g,currentBreakpoint:g[0].id}})}const Rc=f.types.model({id:f.types.identifier,name:f.types.string,group:f.types.string,content:Di,content_id:f.types.string,datasources:ql,globalSQLSnippets:ti,context:os});function Yc({id:t,name:e,group:n,content_id:r},i,a,l,c,u){return Rc.create({id:t,name:e,group:n,content_id:r,content:Qc(i,c,u),datasources:{list:a},globalSQLSnippets:{list:l},context:ni(c)})}fa(),xa();const bD=({context:t,dashboard:e,content:n,className:r="dashboard",config:i,fullScreenPanelID:a,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,lang:d})=>{ws(i);const{data:h=[]}=N.useRequest(Ds),{data:p=[]}=N.useRequest(ya),g=m.useMemo(()=>Yc(e,n,h,p,t,c??{}),[e,n]);Sc(g.content,!1),m.useEffect(()=>{g.context.replace(t)},[t]),m.useEffect(()=>{g.datasources.replace(h)},[h]),m.useEffect(()=>{g.globalSQLSnippets.replace(p)},[p]),m.useEffect(()=>{u==null||u(g.content.filters.values)},[u,g.content.filters.values]),m.useEffect(()=>{c&&g.content.filters.patchValues(c)},[c,g.content.filters.patchValues]);const y=N.useCreation(qr,[]),v=kc(y);return s.jsx(Cc,{lang:d,children:s.jsx(Be.ModalsProvider,{children:s.jsx(Ls,{children:s.jsx(As,{value:{searchButtonProps:i.searchButtonProps},children:s.jsx(Ms,{value:g,children:s.jsx(Ps,{value:g.content,children:s.jsx(qs.Provider,{value:{fullScreenPanelID:a,setFullScreenPanelID:l},children:s.jsx(Mn.Provider,{value:{inEditMode:!1},children:s.jsx(o.Box,{className:`${r} dashboard-root`,children:s.jsx(it.Provider,{value:y,children:s.jsx(rs,{configure:v,children:g.content.views.visibleViews.map(C=>s.jsx(cs,{view:C},C.id))})})})})})})})})})})})},vD=S.observer(bD);I.extend(wu),I.extend(Cu),I.extend(Su),I.extend(ku),I.extend(Tu),I.extend(Du),I.extend(zu),I.extend(Iu),I.extend(Mu),I.extend(Eu),I.extend($u),I.extend(qu),I.extend(Lu),I.extend(Bu),I.extend(Ou),I.extend(Au),I.extend(Pu),I.extend(Vu),I.extend(Nu),I.extend(Fu),I.extend(Gu),I.extend(Wu),I.extend(Qu),I.extend(Ru),I.extend(Yu),I.extend(Uu),I.extend(Ku),I.extend(Ju),I.extend(Xu),I.extend(Zu),I.extend(ed),I.extend(td),I.extend(Hu),I.tz.setDefault("UTC"),I.updateLocale("en",{weekStart:1});const _D=()=>Promise.resolve().then(()=>Xd).then(({version:t})=>(console.log(`[@devtable/dashboard] version: ${t}`),t));j.APIClient=et,j.CURRENT_SCHEMA_VERSION=mt,j.ContentModel=yi,j.ContentModelContextProvider=Ps,j.ContentRenderModel=Di,j.ContextMeta=os,j.DEFAULT_CUSTOM_MODAL_TITLE=as,j.DashboardApiClient=ua,j.DashboardApiFacadeClient=da,j.DashboardEditor=yD,j.DashboardFilterType=pe,j.DashboardMode=hc,j.DashboardModel=jc,j.DashboardModelContextProvider=Ms,j.DashboardRenderModel=Rc,j.DashboardThemeContextProvider=As,j.DashboardViewEditor=dc,j.DashboardViewRender=cs,j.DataSourceMetaModel=ei,j.DataSourceType=ce,j.DataSourcesMetaModel=ql,j.DatesProvider=Ls,j.DefaultApiClient=ca,j.DescriptionPopover=pi,j.DraftModel=Jl,j.EViewComponentType=L,j.FacadeApiClient=fd,j.FilterCheckboxConfigMeta=Fr,j.FilterDateRangeConfigMeta=Gr,j.FilterMeta=Jr,j.FilterMultiSelectConfigMeta=Qr,j.FilterSelectConfigMeta=Rr,j.FilterTextInputConfigMeta=Yr,j.FilterTreeSelectConfigMeta=Kr,j.FiltersModel=mc,j.FiltersRenderModel=oi,j.FullScreenPanel=ac,j.FullScreenPanelContext=qs,j.GlobalSQLSnippetMeta=Ll,j.GlobalSQLSnippetsMeta=ti,j.LayoutItemMeta=wl,j.LayoutSetMeta=Cl,j.LayoutStateContext=Mn,j.LayoutsRenderModel=di,j.MockContextMeta=Vr,j.MuteQueryModel=Ql,j.Panel=ic,j.PanelContextProvider=$s,j.PanelErrorOrStateMessage=sc,j.PanelMeta=_l,j.PanelModel=yc,j.PanelRender=fi,j.PanelRenderModel=ii,j.PanelStyleMeta=xl,j.PanelTitleMeta=yl,j.PanelVizMeta=vl,j.PanelVizSection=mi,j.PanelsModel=bc,j.PanelsRenderModel=ai,j.QueriesModel=gc,j.QueriesRenderModel=ui,j.QueryMeta=jl,j.QueryModel=fc,j.QueryRenderModel=ci,j.ReadOnlyDashboard=vD,j.SQLSnippetMeta=Sl,j.SQLSnippetRenderModel=Ul,j.SQLSnippetsModel=xc,j.SQLSnippetsRenderModel=hi,j.VariableMeta=bl,j.ViewComponentTypeBackground=pc,j.ViewComponentTypeColor=VS,j.ViewComponentTypeName=OS,j.ViewDivisionConfig=Xr,j.ViewMeta=$l,j.ViewModalConfig=Zr,j.ViewRenderModel=si,j.ViewTabsConfig=Hr,j.ViewsModel=vc,j.ViewsRenderModel=ri,j.Viz=nc,j.applyPartialDashboard=HS,j.configureAPIClient=ws,j.createContentModel=_c,j.createContentRenderModel=Qc,j.createContextMeta=ni,j.createDashboardModel=wc,j.createDashboardRenderModel=Yc,j.createDraft=Xl,j.createFilterCheckboxConfig=kl,j.createFilterDateRangeConfig=Dl,j.createFilterMultiSelectConfig=zl,j.createFilterSelectConfig=Il,j.createFilterTextInputConfig=Ur,j.createFilterTreeSelectConfig=Ml,j.createViewDivisionConfig=El,j.createViewModalConfig=Al,j.createViewTabsConfig=Pl,j.facadeApiClient=ha,j.formatSQLSnippet=gn,j.getInitialDashboardViewsModel=xi,j.getInitialFiltersConfig=li,j.getInitialMockContextMeta=Nr,j.getInitialQueriesRenderModel=Rl,j.getInitialSQLSnippetsRenderModel=Kl,j.getInitialViewsRenderModel=Bl,j.getNewPanel=Nl,j.getVersion=_D,j.initialDashboardContent=sS,j.useDashboardContext=Es,j.useDashboardThemeContext=ka,j.useEditContentModelContext=W,j.useEditDashboardContext=X,j.useEditPanelContext=$e,j.useFullScreenPanelContext=Ma,j.usePanelFullScreen=oc,j.useRenderContentModelContext=de,j.useRenderDashboardContext=Ca,j.useRenderPanelContext=dt,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})});
|