@devtable/dashboard 10.14.1 → 10.14.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dashboard.es.js +11 -11
- package/dist/dashboard.umd.js +10 -10
- package/dist/stats.html +1 -1
- package/package.json +1 -1
package/dist/dashboard.umd.js
CHANGED
|
@@ -51,7 +51,7 @@ Check the top-level render call using <`+P+">.")}return z}}function bu(S,z){{if(
|
|
|
51
51
|
${Lu.map(Pu).join("")}
|
|
52
52
|
</tbody>
|
|
53
53
|
</table>
|
|
54
|
-
`;function fr(e,t){const n=Object.keys(t),r=Object.values(t);try{return new Function(...n,`return \`${e}\`;`)(...r)}catch(a){throw n.length===0&&e.includes("$")?new Error("[formatSQL] insufficient payload"):a}}function gr(e,t){try{return fr(e,t)}catch(n){return console.error(n),n.message}}function Vu({sql:e,pre_process:t}){if(!t.trim())return e;try{return new Function(`return ${t}`)()({sql:e},Ot)}catch(n){return console.error(n),e}}function Nu(e,t){if(!e.trim())return t;try{return new Function(`return ${e}`)()(t,Ot)}catch(n){return console.error(n),t}}function qu(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let r=0;r<t.length;r++){const a=t[r];if(a!="authentication"&&e[a])n.push(t[r]+"="+(typeof e[a]=="object"?JSON.stringify(e[a]):e[a]));else{const o=Object.keys(e[a]).sort();for(let l=0;l<o.length;l++){const u=o[l];u!="sign"&&e[a][u]&&n.push(o[l]+"="+(typeof e[a][u]=="object"?JSON.stringify(e[a][u]):e[a][u]))}}}return n.sort().join("&")}function Fu(e,t){let n=qu(e);return n+="&key="+t,Da.MD5(n).toString().toUpperCase()}const qe={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(e){if(!this.app_id||!this.app_secret)return;const t=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:t,sign:Fu({app_id:this.app_id,nonce_str:t,...e},this.app_secret)}},getRequest(e,t){return(n,r,a={})=>{const o=window.localStorage.getItem("token"),l={"X-Requested-With":"XMLHttpRequest","Content-Type":a.string?"application/x-www-form-urlencoded":"application/json",authorization:o?`bearer ${o}`:"",...a.headers},u={baseURL:this.baseURL,method:e,url:n,params:e==="GET"?r:a.params,headers:l,signal:t};return["POST","PUT"].includes(e)&&(u.data=a.string?JSON.stringify(r):r,u.data.authentication=this.getAuthentication(u.data)),ht(u).then(c=>c.data).catch(c=>Promise.reject(c))}},makeQueryENV:null,query(e){return async(t,n={})=>{var r;return t.env||(t.env=((r=this.makeQueryENV)==null?void 0:r.call(this))??{error:"failed to run makeQueryENV"}),this.getRequest("POST",e)("/query",t,n)}}};function Ka(e){qe.baseURL!==e.apiBaseURL&&(qe.baseURL=e.apiBaseURL),e.app_id&&(qe.app_id=e.app_id),e.app_secret&&(qe.app_secret=e.app_secret),e.makeQueryENV&&(qe.makeQueryENV=e.makeQueryENV)}async function Gu({query:e,payload:t},n){if(!e.sql)return[];const{type:r,key:a,sql:o,pre_process:l,post_process:u}=e,c=fr(o,t),d=Vu({sql:c,pre_process:l});let f=await qe.query(n)({type:r,key:a,query:d},{});return f=Nu(u,f),f}async function Wu({type:e,key:t,configString:n},r){return await qe.query(r)({type:e,key:t,query:n},{})}async function mr(){try{return(await qe.getRequest("POST")("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}})).data}catch(e){return console.error(e),[]}}async function Ua(){try{return(await qe.getRequest("POST")("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}})).data}catch(e){return console.error(e),[]}}class Xa{constructor(t){q(this,"rootRef");this.rootRef=re.observable({current:t})}async deleteItem(t){re.runInAction(()=>{x.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?re.toJS(this.rootRef.current):x.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(x.isObject(n))re.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else re.runInAction(()=>{x.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return re.reaction(()=>this.getValueFromRoot(t),(a,o)=>{n(a,o)},{requiresObservable:!0,fireImmediately:x.get(r,"fireImmediately",!1)})}}class ju{constructor(){q(this,"channels",new Map);q(this,"globalChannel",new Ma)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new Ma;return this.channels.set(t,r),r}}class Ru{constructor(t){q(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const r={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new ju,instanceData:new Xa(t.viz.conf)};return this.instances.set(t.id,r),r}}function Ja(e,t,n,r){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new Xa({}),colorPalette:{getColor(){return()=>""}},data:t,variables:r}}const Yu=e=>{const{panel:t,vizManager:n,data:r,variables:a}=e,o=n.resolveComponent(t.viz.type),l=n.getOrCreateInstance(t),u={...Ja(l,r,n,a),viewport:{width:t.layout.w,height:t.layout.h}},c=o.viewRender;return i(c,{context:u,instance:l,...x.omit(e,["panel","vizManager","data"])})},Qu=e=>{const{vizManager:t,panel:n,panelInfoEditor:r,data:a,variables:o}=e,l=t.resolveComponent(n.viz.type),u=t.getOrCreateInstance(n),c={...Ja(u,a,t,o),panelInfoEditor:r},d=l.configRender;return i(d,{context:c,instance:u,...x.omit(e,["panel","vizManager","data","panelInfoEditor"])})},Za=(e,t)=>{const n=ot.bezier(e),r=ot.bezier(t);return function(a){return a<50?n(a*2/100).hex():r((a-50)*2/100).hex()}},bn=e=>{const t=ot.bezier(e);return function(n){return t(n/100).hex()}},Ku={type:"interpolation",displayName:"Red / Green",getColor:Za(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Uu={type:"interpolation",displayName:"Yellow / Blue",getColor:Za(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Xu={type:"interpolation",displayName:"Red",getColor:bn(["#fff7f1","darkred"]),name:"red",category:"sequential"},Ju={type:"interpolation",displayName:"Green",getColor:bn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Zu={type:"interpolation",displayName:"Blue",getColor:bn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Hu={type:"interpolation",displayName:"Orange",getColor:bn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class ec{constructor(t){q(this,"symbol");this.symbol=Symbol(t)}}function lt(e){return new ec(e)}class yr{constructor(){q(this,"parent");q(this,"factoryRegistry",new Map);q(this,"instanceRegistry",new Map)}createScoped(){const t=new yr;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const r=n(this);return this.instanceRegistry.set(t.symbol,r),r}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=x.get(t,"dispose");x.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const Ha="10.14.1",tc=Object.freeze(Object.defineProperty({__proto__:null,version:Ha},Symbol.toStringTag,{value:"Module"}));class nc{constructor(t){q(this,"staticColors",new Map);q(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class rc{constructor(){q(this,"plugins",new Map);q(this,"vizComponents",new Map);q(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class ic{constructor(){q(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,r){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const a=this.migrations.filter(u=>u.version>t.from&&u.version<=t.to),o=x.orderBy(a,"version","asc");if(((l=x.last(o))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((u,c)=>c.handler(u,r),n)}}class be extends ic{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(r,a)=>({version:t,...n(r,a)}))}async migrate({configData:t,panelModel:n}){const r=await t.getItem(null),a=x.get(r,"version",0),o=this.run({from:a,to:this.VERSION},r,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return x.get(n,"version",0)<this.VERSION}}const W=(e,t)=>{const[n,{setFalse:r}]=X.useBoolean(!0),[a,o]=y.useState();y.useEffect(()=>(e.getItem(t).then(u=>{o(u),r()}),e.watchItem(t,u=>{o(u)})));const l=y.useCallback(async u=>{await e.setItem(t,u),o(u)},[e,t]);return{loading:n,value:a,set:l}},br={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 V(e){const[t,n]=e.split(".");return{queryID:t,columnKey:n}}function ac(e){return e.includes(".")?V(e):{queryID:"",columnKey:e}}function ut(e,t){var a;const{queryID:n,columnKey:r}=V(t);return n?r?((a=e[n])==null?void 0:a.map(o=>o[r]))??[]:e[n]:[]}function vn(e,t){const{queryID:n}=V(t);return n?e[n]:[]}function sc(e){return Object.values(e)[0]}function xn(e,t){const{queryID:n,columnKey:r}=V(t);return e[r]}oe.use([G.GridComponent,G.VisualMapComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function oc({context:e}){const{value:t}=W(e.instanceData,"config"),n=e.data,{width:r,height:a}=e.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:u,xAxis3D:c,yAxis3D:d,zAxis3D:f}=x.defaults({},t,br),h=y.useMemo(()=>vn(n,o),[n,o]),{x:g,y:m,z:C}=y.useMemo(()=>({x:V(o),y:V(l),z:V(u)}),[o,l,u]),{min:w,max:_}=y.useMemo(()=>{const I=x.minBy(h,N=>N[C.columnKey]),L=x.maxBy(h,N=>N[C.columnKey]);return{min:x.get(I,C.columnKey),max:x.get(L,C.columnKey)}},[h,C]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:w,max:_,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:c,yAxis3D:d,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(I=>[I[g.columnKey],I[m.columnKey],I[C.columnKey]])}]};return t?i(Ne,{echarts:oe,option:T,style:{width:r,height:a},notMerge:!0,theme:"merico-light"}):null}const es=y.createContext(null),vr=es.Provider;function xr(){const e=y.useContext(es);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const me=()=>xr(),wr=()=>xr(),ts=y.createContext(null),Cr=ts.Provider;function ns(){const e=y.useContext(ts);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const le=()=>ns(),we=()=>ns(),lc={inEditMode:!1},wn=y.createContext(lc),rs=y.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),Sr=rs.Provider;function is(){const e=y.useContext(rs);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const gt=()=>is(),Je=()=>is(),uc={fullScreenPanelID:"",setFullScreenPanelID:x.noop},_r=y.createContext(uc);function as(){const e=y.useContext(_r);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const j=k.observer(y.forwardRef(({label:e,required:t,value:n,onChange:r,clearable:a=!1,sx:o,...l},u)=>{const{panel:c}=Je(),d=y.useMemo(()=>{const f=[...c.dataFieldOptions];return a&&f.unshift({label:"unset",value:"",group:""}),f},[c.dataFieldOptions]);return i(s.Select,{ref:u,label:e,data:d,value:n,onChange:r,required:t,sx:o,maxDropdownHeight:500,...l})}));function cc({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=x.defaults({},t,br),{control:a,handleSubmit:o,reset:l}=v.useForm({defaultValues:r});return y.useEffect(()=>{l(r)},[t]),t?i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[i(s.Text,{children:"X Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"x_axis_data_key",control:a,render:({field:u})=>i(j,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"xAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Text,{mt:"lg",children:"Y Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"y_axis_data_key",control:a,render:({field:u})=>i(j,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"yAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Text,{mt:"lg",children:"Z Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"z_axis_data_key",control:a,render:({field:u})=>i(j,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"zAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(s.Button,{color:"blue",type:"submit",children:[i(D.DeviceFloppy,{size:20}),i(s.Text,{ml:"md",children:"Save"})]})})]})}):null}function dc(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis_data_key:a,y_axis_data_key:o,z_axis_data_key:l,...u}=e;return{...u,x_axis_data_key:r(a),y_axis_data_key:r(o),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class pc extends be{constructor(){super(...arguments);q(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:a}=n;return{...n,version:2,config:dc(a,r)}})}}const hc={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new pc,name:"bar-3d",viewRender:oc,configRender:cc,createConfig(){return{version:2,config:x.cloneDeep(br)}}};class Fe extends y.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const n=()=>{this.setState({error:null})};return p(s.Box,{children:[i(s.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),i(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}const $e={mantissa:0,output:"number",trimMantissa:!1,average:!1};function fc({value:e,onChange:t},n){const r=u=>{t({...e,output:u})},a=u=>{const c=u===0?!1:e.trimMantissa;t({...e,mantissa:u,trimMantissa:c})},o=u=>{t({...e,trimMantissa:u.currentTarget.checked})},l=u=>{t({...e,average:u.currentTarget.checked})};return p(s.Stack,{ref:n,children:[p(s.Group,{grow:!0,children:[i(s.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:r,sx:{flexGrow:1}}),i(s.Switch,{label:p(s.Stack,{spacing:0,children:[i(s.Text,{children:"Average"}),i(s.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:l,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(s.Group,{grow:!0,children:[i(s.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:a}),i(s.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(s.Stack,{spacing:0,children:[i(s.Text,{weight:"bold",children:"Preview"}),i(Fe,{children:p(s.Group,{position:"apart",children:[p(s.Text,{size:12,color:"gray",children:["123456789 ",i(D.ArrowRight,{size:9})," ",H(123456789).format(e)]}),p(s.Text,{size:12,color:"gray",children:["1234 ",i(D.ArrowRight,{size:9})," ",H(1234).format(e)]}),p(s.Text,{size:12,color:"gray",children:["0.1234 ",i(D.ArrowRight,{size:9})," ",H(.1234).format(e)]})]})})]})]})}const Re=y.forwardRef(fc),rt={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
54
|
+
`;function fr(e,t){const n=Object.keys(t),r=Object.values(t);try{return new Function(...n,`return \`${e}\`;`)(...r)}catch(a){throw n.length===0&&e.includes("$")?new Error("[formatSQL] insufficient payload"):a}}function gr(e,t){try{return fr(e,t)}catch(n){return console.error(n),n.message}}function Vu({sql:e,pre_process:t}){if(!t.trim())return e;try{return new Function(`return ${t}`)()({sql:e},Ot)}catch(n){return console.error(n),e}}function Nu(e,t){if(!e.trim())return t;try{return new Function(`return ${e}`)()(t,Ot)}catch(n){return console.error(n),t}}function qu(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let r=0;r<t.length;r++){const a=t[r];if(a!="authentication"&&e[a])n.push(t[r]+"="+(typeof e[a]=="object"?JSON.stringify(e[a]):e[a]));else{const o=Object.keys(e[a]).sort();for(let l=0;l<o.length;l++){const u=o[l];u!="sign"&&e[a][u]&&n.push(o[l]+"="+(typeof e[a][u]=="object"?JSON.stringify(e[a][u]):e[a][u]))}}}return n.sort().join("&")}function Fu(e,t){let n=qu(e);return n+="&key="+t,Da.MD5(n).toString().toUpperCase()}const qe={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(e){if(!this.app_id||!this.app_secret)return;const t=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:t,sign:Fu({app_id:this.app_id,nonce_str:t,...e},this.app_secret)}},getRequest(e,t){return(n,r,a={})=>{const o=window.localStorage.getItem("token"),l={"X-Requested-With":"XMLHttpRequest","Content-Type":a.string?"application/x-www-form-urlencoded":"application/json",authorization:o?`bearer ${o}`:"",...a.headers},u={baseURL:this.baseURL,method:e,url:n,params:e==="GET"?r:a.params,headers:l,signal:t};return["POST","PUT"].includes(e)&&(u.data=a.string?JSON.stringify(r):r,u.data.authentication=this.getAuthentication(u.data)),ht(u).then(c=>c.data).catch(c=>Promise.reject(c))}},makeQueryENV:null,query(e){return async(t,n={})=>{var r;return t.env||(t.env=((r=this.makeQueryENV)==null?void 0:r.call(this))??{error:"failed to run makeQueryENV"}),this.getRequest("POST",e)("/query",t,n)}}};function Ka(e){qe.baseURL!==e.apiBaseURL&&(qe.baseURL=e.apiBaseURL),e.app_id&&(qe.app_id=e.app_id),e.app_secret&&(qe.app_secret=e.app_secret),e.makeQueryENV&&(qe.makeQueryENV=e.makeQueryENV)}async function Gu({query:e,payload:t},n){if(!e.sql)return[];const{type:r,key:a,sql:o,pre_process:l,post_process:u}=e,c=fr(o,t),d=Vu({sql:c,pre_process:l});let f=await qe.query(n)({type:r,key:a,query:d},{});return f=Nu(u,f),f}async function Wu({type:e,key:t,configString:n},r){return await qe.query(r)({type:e,key:t,query:n},{})}async function mr(){try{return(await qe.getRequest("POST")("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}})).data}catch(e){return console.error(e),[]}}async function Ua(){try{return(await qe.getRequest("POST")("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}})).data}catch(e){return console.error(e),[]}}class Xa{constructor(t){q(this,"rootRef");this.rootRef=re.observable({current:t})}async deleteItem(t){re.runInAction(()=>{x.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?re.toJS(this.rootRef.current):x.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(x.isObject(n))re.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else re.runInAction(()=>{x.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return re.reaction(()=>this.getValueFromRoot(t),(a,o)=>{n(a,o)},{requiresObservable:!0,fireImmediately:x.get(r,"fireImmediately",!1)})}}class ju{constructor(){q(this,"channels",new Map);q(this,"globalChannel",new Ma)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new Ma;return this.channels.set(t,r),r}}class Ru{constructor(t){q(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const r={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new ju,instanceData:new Xa(t.viz.conf)};return this.instances.set(t.id,r),r}}function Ja(e,t,n,r){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new Xa({}),colorPalette:{getColor(){return()=>""}},data:t,variables:r}}const Yu=e=>{const{panel:t,vizManager:n,data:r,variables:a}=e,o=n.resolveComponent(t.viz.type),l=n.getOrCreateInstance(t),u={...Ja(l,r,n,a),viewport:{width:t.layout.w,height:t.layout.h}},c=o.viewRender;return i(c,{context:u,instance:l,...x.omit(e,["panel","vizManager","data"])})},Qu=e=>{const{vizManager:t,panel:n,panelInfoEditor:r,data:a,variables:o}=e,l=t.resolveComponent(n.viz.type),u=t.getOrCreateInstance(n),c={...Ja(u,a,t,o),panelInfoEditor:r},d=l.configRender;return i(d,{context:c,instance:u,...x.omit(e,["panel","vizManager","data","panelInfoEditor"])})},Za=(e,t)=>{const n=ot.bezier(e),r=ot.bezier(t);return function(a){return a<50?n(a*2/100).hex():r((a-50)*2/100).hex()}},bn=e=>{const t=ot.bezier(e);return function(n){return t(n/100).hex()}},Ku={type:"interpolation",displayName:"Red / Green",getColor:Za(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Uu={type:"interpolation",displayName:"Yellow / Blue",getColor:Za(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Xu={type:"interpolation",displayName:"Red",getColor:bn(["#fff7f1","darkred"]),name:"red",category:"sequential"},Ju={type:"interpolation",displayName:"Green",getColor:bn(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Zu={type:"interpolation",displayName:"Blue",getColor:bn(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Hu={type:"interpolation",displayName:"Orange",getColor:bn(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class ec{constructor(t){q(this,"symbol");this.symbol=Symbol(t)}}function lt(e){return new ec(e)}class yr{constructor(){q(this,"parent");q(this,"factoryRegistry",new Map);q(this,"instanceRegistry",new Map)}createScoped(){const t=new yr;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const r=n(this);return this.instanceRegistry.set(t.symbol,r),r}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=x.get(t,"dispose");x.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const Ha="10.14.2",tc=Object.freeze(Object.defineProperty({__proto__:null,version:Ha},Symbol.toStringTag,{value:"Module"}));class nc{constructor(t){q(this,"staticColors",new Map);q(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class rc{constructor(){q(this,"plugins",new Map);q(this,"vizComponents",new Map);q(this,"factory",{viz:t=>{const n=this.vizComponents.get(t);if(n)return n;throw new Error(`Viz Component (${t}) not found`)}})}install(t){if(this.plugins.has(t.id))throw new Error(`Plugin (${t.id}) has been installed before`);this.plugins.set(t.id,t);for(const n of t.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class ic{constructor(){q(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,r){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const a=this.migrations.filter(u=>u.version>t.from&&u.version<=t.to),o=x.orderBy(a,"version","asc");if(((l=x.last(o))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((u,c)=>c.handler(u,r),n)}}class be extends ic{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(r,a)=>({version:t,...n(r,a)}))}async migrate({configData:t,panelModel:n}){const r=await t.getItem(null),a=x.get(r,"version",0),o=this.run({from:a,to:this.VERSION},r,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return x.get(n,"version",0)<this.VERSION}}const W=(e,t)=>{const[n,{setFalse:r}]=X.useBoolean(!0),[a,o]=y.useState();y.useEffect(()=>(e.getItem(t).then(u=>{o(u),r()}),e.watchItem(t,u=>{o(u)})));const l=y.useCallback(async u=>{await e.setItem(t,u),o(u)},[e,t]);return{loading:n,value:a,set:l}},br={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 V(e){const[t,n]=e.split(".");return{queryID:t,columnKey:n}}function ac(e){return e.includes(".")?V(e):{queryID:"",columnKey:e}}function ut(e,t){var a;const{queryID:n,columnKey:r}=V(t);return n?r?((a=e[n])==null?void 0:a.map(o=>o[r]))??[]:e[n]:[]}function vn(e,t){const{queryID:n}=V(t);return n?e[n]:[]}function sc(e){return Object.values(e)[0]}function xn(e,t){const{queryID:n,columnKey:r}=V(t);return e[r]}oe.use([G.GridComponent,G.VisualMapComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function oc({context:e}){const{value:t}=W(e.instanceData,"config"),n=e.data,{width:r,height:a}=e.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:u,xAxis3D:c,yAxis3D:d,zAxis3D:f}=x.defaults({},t,br),h=y.useMemo(()=>vn(n,o),[n,o]),{x:g,y:m,z:C}=y.useMemo(()=>({x:V(o),y:V(l),z:V(u)}),[o,l,u]),{min:w,max:_}=y.useMemo(()=>{const I=x.minBy(h,N=>N[C.columnKey]),L=x.maxBy(h,N=>N[C.columnKey]);return{min:x.get(I,C.columnKey),max:x.get(L,C.columnKey)}},[h,C]),T={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:w,max:_,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:c,yAxis3D:d,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(I=>[I[g.columnKey],I[m.columnKey],I[C.columnKey]])}]};return t?i(Ne,{echarts:oe,option:T,style:{width:r,height:a},notMerge:!0,theme:"merico-light"}):null}const es=y.createContext(null),vr=es.Provider;function xr(){const e=y.useContext(es);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const me=()=>xr(),wr=()=>xr(),ts=y.createContext(null),Cr=ts.Provider;function ns(){const e=y.useContext(ts);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const le=()=>ns(),we=()=>ns(),lc={inEditMode:!1},wn=y.createContext(lc),rs=y.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),Sr=rs.Provider;function is(){const e=y.useContext(rs);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const gt=()=>is(),Je=()=>is(),uc={fullScreenPanelID:"",setFullScreenPanelID:x.noop},_r=y.createContext(uc);function as(){const e=y.useContext(_r);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const j=k.observer(y.forwardRef(({label:e,required:t,value:n,onChange:r,clearable:a=!1,sx:o,...l},u)=>{const{panel:c}=Je(),d=y.useMemo(()=>{const f=[...c.dataFieldOptions];return a&&f.unshift({label:"unset",value:"",group:""}),f},[c.dataFieldOptions]);return i(s.Select,{ref:u,label:e,data:d,value:n,onChange:r,required:t,sx:o,maxDropdownHeight:500,...l})}));function cc({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=x.defaults({},t,br),{control:a,handleSubmit:o,reset:l}=v.useForm({defaultValues:r});return y.useEffect(()=>{l(r)},[t]),t?i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[i(s.Text,{children:"X Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"x_axis_data_key",control:a,render:({field:u})=>i(j,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"xAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Text,{mt:"lg",children:"Y Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"y_axis_data_key",control:a,render:({field:u})=>i(j,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"yAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Text,{mt:"lg",children:"Z Axis"}),p(s.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[i(v.Controller,{name:"z_axis_data_key",control:a,render:({field:u})=>i(j,{label:"Data Field",required:!0,...u})}),i(v.Controller,{name:"zAxis3D.name",control:a,render:({field:u})=>i(s.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),i(s.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:p(s.Button,{color:"blue",type:"submit",children:[i(D.DeviceFloppy,{size:20}),i(s.Text,{ml:"md",children:"Save"})]})})]})}):null}function dc(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis_data_key:a,y_axis_data_key:o,z_axis_data_key:l,...u}=e;return{...u,x_axis_data_key:r(a),y_axis_data_key:r(o),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class pc extends be{constructor(){super(...arguments);q(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:a}=n;return{...n,version:2,config:dc(a,r)}})}}const hc={displayName:"Bar Chart (3D)",displayGroup:"ECharts-based charts",migrator:new pc,name:"bar-3d",viewRender:oc,configRender:cc,createConfig(){return{version:2,config:x.cloneDeep(br)}}};class Fe extends y.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const n=()=>{this.setState({error:null})};return p(s.Box,{children:[i(s.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),i(s.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}const $e={mantissa:0,output:"number",trimMantissa:!1,average:!1};function fc({value:e,onChange:t},n){const r=u=>{t({...e,output:u})},a=u=>{const c=u===0?!1:e.trimMantissa;t({...e,mantissa:u,trimMantissa:c})},o=u=>{t({...e,trimMantissa:u.currentTarget.checked})},l=u=>{t({...e,average:u.currentTarget.checked})};return p(s.Stack,{ref:n,children:[p(s.Group,{grow:!0,children:[i(s.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:r,sx:{flexGrow:1}}),i(s.Switch,{label:p(s.Stack,{spacing:0,children:[i(s.Text,{children:"Average"}),i(s.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:l,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),p(s.Group,{grow:!0,children:[i(s.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:a}),i(s.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),p(s.Stack,{spacing:0,children:[i(s.Text,{weight:"bold",children:"Preview"}),i(Fe,{children:p(s.Group,{position:"apart",children:[p(s.Text,{size:12,color:"gray",children:["123456789 ",i(D.ArrowRight,{size:9})," ",H(123456789).format(e)]}),p(s.Text,{size:12,color:"gray",children:["1234 ",i(D.ArrowRight,{size:9})," ",H(1234).format(e)]}),p(s.Text,{size:12,color:"gray",children:["0.1234 ",i(D.ArrowRight,{size:9})," ",H(.1234).format(e)]})]})})]})]})}const Re=y.forwardRef(fc),rt={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
55
55
|
`)},ss={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:mc,configRender:gc,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 gc(e){return i(B,{})}function mc(e){return i(s.Text,{children:"Click chart's series"})}const yc=[{label:"Truncate",value:"truncate"},{label:"Break Line",value:"break"},{label:"Break Word",value:"breakAll"}],Cn=y.forwardRef(({sectionTitle:e,value:t,onChange:n},r)=>{const a=o=>l=>{const u=x.cloneDeep(t);x.set(u,o,l),n(u)};return p(s.Stack,{spacing:0,children:[e&&i(s.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),p(s.Group,{grow:!0,noWrap:!0,children:[i(s.NumberInput,{label:"Max Width",hideControls:!0,value:t.width,onChange:a("width")}),i(s.Select,{label:"Overflow",data:yc,value:t.overflow,onChange:a("overflow")}),i(s.TextInput,{label:"Ellipsis",value:t.ellipsis,disabled:!0})]})]})}),mt=y.forwardRef(({value:e,onChange:t},n)=>{const r=o=>{t({...e,on_axis:o})},a=o=>{t({...e,in_tooltip:o})};return p(s.Stack,{ref:n,spacing:0,children:[i(Cn,{sectionTitle:"Overflow on Axis",value:e.on_axis,onChange:r}),i(Cn,{sectionTitle:"Overflow in Tooltip",value:e.in_tooltip,onChange:a})]})}),Ze={on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}};function yt({overflow:e,width:t}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],r=e==="truncate"?"nowrap":"initial",a={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
|
|
56
56
|
max-width: ${t}px;
|
|
57
57
|
word-break: ${n};
|
|
@@ -98,7 +98,7 @@ Check the top-level render call using <`+P+">.")}return z}}function bu(S,z){{if(
|
|
|
98
98
|
</tbody>
|
|
99
99
|
</table>
|
|
100
100
|
`}const hd=e=>t=>{const{componentSubType:n,value:r}=t;return n==="scatter"?pd(e,r):cd(e,r)};function fd({config:e}){return{trigger:"item",confine:!0,formatter:hd(e)}}const Jt=y.forwardRef(function({value:t,onChange:n,...r},a){return i(s.TextInput,{ref:a,value:t,onChange:n,...r})}),gd=[{label:"None",value:"none"},{label:"Sum",value:"sum"},{label:"Mean",value:"mean"},{label:"Median",value:"median"},{label:"Max",value:"max"},{label:"Min",value:"min"},{label:"Coefficient of Variation",value:"CV"},{label:"Standard Variation",value:"std"},{label:"Quantile(99%, 95%, ...)",value:"quantile"}];function md({label:e,value:t,onChange:n,pt:r="sm"},a){y.useEffect(()=>{typeof t=="string"&&(console.log(t),n({type:t,config:{}}))},[t,n]);const o=u=>{n(u==="quantile"?{type:"quantile",config:{p:.99}}:{type:u,config:{}})},l=u=>{n({type:"quantile",config:{p:u}})};return p(s.Group,{grow:!0,noWrap:!0,pt:r,children:[i(s.Select,{ref:a,label:e,data:gd,value:t.type,onChange:o}),t.type==="quantile"&&i(s.NumberInput,{label:"p",value:t.config.p,onChange:l,precision:2,min:.05,step:.05,max:1})]})}const _n=y.forwardRef(md);function yd({label:e,value:t,onChange:n},r){const[a,o]=y.useState(Array.isArray(t)?[...t]:[]),l=y.useCallback(()=>{o(g=>[...g,""])},[o]),u=y.useCallback(g=>{o(m=>(m.splice(g,1),[...m]))},[o]),c=y.useMemo(()=>!x.isEqual(a,t),[a,t]),d=()=>{n(a.map(g=>g.toString()))},f=s.useMantineTheme(),h=y.useMemo(()=>Object.entries(f.colors).map(([g,m])=>m[6]),[f]);return p(B,{children:[p(s.Group,{position:"left",ref:r,children:[i(s.Text,{children:e}),i(s.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!c,onClick:d,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Group,{children:[a.map((g,m)=>i(s.ColorInput,{value:g,onChange:C=>{o(w=>(w.splice(m,1,C),[...w]))},swatches:h,rightSection:i(s.ActionIcon,{onClick:()=>u(m),color:"red",children:i(D.Trash,{size:14})}),sx:{width:"45%"}})),i(s.ActionIcon,{onClick:l,color:"blue",variant:"outline",children:i(D.PlaylistAdd,{size:20})})]})]})}const bd=y.forwardRef(yd);function vd({value:e,onChange:t},n){const{colorManager:r}=y.useContext(st),a=y.useMemo(()=>r.getStaticColors().map(u=>({label:u.name,group:u.category,value:u.value})),[r]),o=y.useMemo(()=>a.some(l=>l.value===e),[e,a]);return p(s.Group,{position:"apart",spacing:4,ref:n,children:[i(s.TextInput,{placeholder:"Set any color",value:o?"":e,onChange:l=>t(l.currentTarget.value),rightSection:i(s.ColorSwatch,{color:o?"transparent":e,radius:4}),variant:o?"filled":"default",sx:{maxWidth:"46%",flexGrow:1}}),i(s.Text,{sx:{flexGrow:0},children:"or"}),i(s.Select,{data:a,value:e,onChange:t,variant:o?"default":"filled",placeholder:"Pick a theme color",icon:i(s.ColorSwatch,{color:o?e:"transparent",radius:4}),sx:{maxWidth:"46%",flexGrow:1}})]})}const Pe=y.forwardRef(vd),kn=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function xd({label:e,value:t,onChange:n},r){var l;const[a,o]=y.useState(((l=kn.find(u=>u.label===t))==null?void 0:l.value)??kn[0].value);return y.useEffect(()=>{const u=kn.find(c=>c.value===a);u&&n(u.label)},[a]),p(s.Stack,{spacing:0,mt:"sm",mb:"lg",children:[i(s.Text,{size:"sm",children:e}),i(s.Slider,{label:null,marks:kn,value:a,onChange:o,step:25,placeholder:"Pick a font size",px:"1em",ref:r})]})}const us=y.forwardRef(xd);function wd({label:e,value:t,onChange:n,type:r},a){const[o,l]=y.useState(Array.isArray(t)?[...t]:[]),u=y.useCallback(()=>{l(h=>[...h,""])},[l]),c=y.useCallback(h=>{l(g=>(g.splice(h,1),[...g]))},[l]),d=y.useMemo(()=>!x.isEqual(o.map(String),t.map(String)),[o,t]),f=()=>{n(o.map(h=>r==="number"?Number(h):h.toString()))};return p(B,{children:[p(s.Group,{position:"left",ref:a,children:[i(s.Text,{children:e}),i(s.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:f,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Group,{children:[o.map((h,g)=>i(s.TextInput,{type:r,value:h,onChange:m=>{const C=m.currentTarget.value;l(w=>(w.splice(g,1,C),[...w]))},rightSection:i(s.ActionIcon,{onClick:()=>c(g),color:"red",children:i(D.Trash,{size:14})}),sx:{width:"45%"}})),i(s.ActionIcon,{onClick:u,color:"blue",variant:"outline",children:i(D.PlaylistAdd,{size:20})})]})]})}const Cd=y.forwardRef(wd),cs=y.forwardRef(function({value:t,onChange:n},r){const a=t.color.type,o=(l,u)=>{const c=x.cloneDeep(t);x.set(c,l,u),n(c)};return p(B,{children:[i(s.Divider,{my:"xs",label:"Typography",labelPosition:"center"}),i(s.Stack,{children:i(s.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},value:t.size,onChange:l=>o("size",l.currentTarget.value)})}),i(s.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:i(us,{label:"Font Weight",value:t.weight,onChange:l=>o("weight",l)})}),i(s.Divider,{my:"xs",label:"Style",labelPosition:"center"}),p(s.Stack,{children:[i(s.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:t.color.type,onChange:l=>o("color.type",l)}),a==="static"&&i(Pe,{value:t.color.staticColor,onChange:l=>o("color.staticColor",l)}),a==="continuous"&&p(B,{children:[i(Cd,{label:"Value Range",value:t.color.valueRange,type:"number",onChange:l=>o("color.valueRange",l)}),i(bd,{label:"Color Range",value:t.color.colorRange,onChange:l=>o("color.colorRange",l)})]})]})]})});y.forwardRef(function({value:t,onChange:n,withStyle:r=!0},a){const o=(l,u)=>{const c=x.cloneDeep(t);x.set(c,l,u),n(c)};return p(s.Box,{px:"sm",py:"md",ref:a,children:[i(s.Text,{weight:"bold",pb:0,children:t.name}),i(s.Divider,{my:"xs",label:"Data",labelPosition:"center"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(s.TextInput,{label:"Name",required:!0,value:t.name,onChange:l=>o("name",l.currentTarget.value)}),i(j,{label:"Data Field",required:!0,value:t.data_field,onChange:l=>o("data_field",l)})]}),i(_n,{label:"Aggregation",value:t.aggregation,onChange:l=>o("aggregation",l)}),i(s.Divider,{my:"xs",label:"Format",labelPosition:"center"}),i(Re,{value:t.formatter,onChange:l=>o("formatter",l)}),r&&i(cs,{value:t,onChange:n})]})});const Bt={type:"none",config:{}};function Sd(e){const t=Array.from(e).sort((r,a)=>r-a),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]}function _d(e){const t=Number(e);return isFinite(t)?t:0}function kd(e,t){switch(t.type){case"sum":return x.sum(e);case"mean":return x.mean(e);case"median":return Sd(e);case"max":return x.max(e)??0;case"min":return x.min(e)??0;case"quantile":return Qt.quantile(e,t.config.p)??0;case"CV":const n=yn.std(...e),r=yn.mean(...e);return r?n/r:"N/A";case"std":return yn.std(...e);default:return e}}function Ir(e,t){const n=e.map(_d);return kd(n,t)}function Tn(e,t,n){try{return Ir(ut(e,t),n)}catch(r){return console.error(r),null}}class Td{constructor({valueRange:t,colorRange:n}){q(this,"mapper");this.mapper=_t.interpolate(t,n)}getColor(t){return this.mapper(t)}}function Dd(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function bt({data_field:e,aggregation:t},n){return Tn(n,e,t)}function tt({formatter:e},t){if(!["string","number"].includes(typeof t))return Dd(t);try{return H(t).format(e)}catch(n){return console.error(n),t}}function Md(e,t){if(e.type==="static")return e.staticColor;if(e.type==="continuous")try{if(typeof t!="number")throw new Error(`[getColorByColorConf] Invalid type of aggregated value: ${t}`);return new Td(e).getColor(t)}catch(n){return console.error(n),"black"}return"black"}function ds(e,t){const{color:n,data_field:r,aggregation:a,size:o,weight:l}=e,u=Tn(t,r,a),c=tt(e,u);return i(s.Text,{sx:{fontSize:o,display:"inline"},color:Md(n,u),weight:l,children:c})}function Id(e,t){const n={};return e.forEach(r=>{const a=r.name;n[a]=ds(r,t)}),n}function Ed(e){return e.split(" ").map((t,n)=>p(y.Fragment,{children:[t," "]},n))}function Ad(e){const n=e.replaceAll("<br />","<br/>").replaceAll(`
|
|
101
|
-
`,"<br/>").split("<br/>");return n.map((a,o)=>{const l=[Ed(a)];return o!==n.length-1&&l.push(i("br",{},`br-${o}`)),l}).flat().filter(a=>a!==void 0)}function Er(e){return Ad(e)}function Zt(e,t,n){const r=Id(t,n),a=/^\{(.+)\}(.*)$/;return e.split("$").map((o,l)=>{const u=a.exec(o);if(!u)return Er(o);const c=r[u[1]];if(!c)return Er(o);const d=u[2]??"";return p(y.Fragment,{children:[c,Er(d)]},`${o}-${l}`)})}function zd(e,t){const n={};return e.forEach(r=>{const{name:a,data_field:o,aggregation:l}=r,u=Tn(t,o,l);n[a]=tt(r,u)}),n}function Dn(e,t,n){const r=zd(t,n),a=/^\{(.+)\}(.*)$/;return e.split("$").map(o=>{const l=a.exec(o);if(!l)return o;const u=r[l[1]];if(!u)return o;const c=l[2]??"";return`${u}${c}`}).join("")}function $d(e,t,n){const r=t.reduce((a,o)=>{const l=bt(o,n);return a[o.name]=tt(o,l),a},{});return e.map(a=>({name:"refs",type:"scatter",data:[],markLine:{data:[{name:a.name,yAxis:Number(r[a.variable_key])}],silent:!0,symbol:["none","none"],label:{formatter:function(){return Dn(a.template,t,n)},position:"insideEndTop"}}}))}function Od({config:e,data:t,variables:n}){const{x_axis:r,y_axis:a,reference_lines:o}=e,l=sd(e,t),u=ct(r.axisLabel.overflow.on_axis),c=ld(e);return{grid:{top:30,left:20,right:15,bottom:25,containLabel:!0},dataset:l,legend:od({config:e}),tooltip:fd({config:e}),xAxis:[{type:"category",name:r.name,nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold",align:"center"},axisTick:{show:!0,alignWithLabel:!0},axisLabel:{...r.axisLabel,...u,formatter:Pt(r.axisLabel.formatter)}}],yAxis:[{name:a.name,nameTextStyle:{fontWeight:"bold"},axisLine:{show:!0},axisLabel:{formatter:function(d){return H(d).format(a.label_formatter)}}}],series:[...c,...$d(o,n,t)]}}oe.use([G.DataZoomComponent,pe.BoxplotChart,G.MarkLineComponent,G.GridComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function Ld({context:e,instance:t}){const{value:n}=W(e.instanceData,"config"),{variables:r}=e,a=e.data,{width:o,height:l}=e.viewport,u=x.defaults({},n,kr),c=et({vizManager:e.vizManager,instance:t}),d=He(c.triggerManager,ss.id),f=Tt(a,u.x_axis.data_key),h=y.useCallback(C=>{const w=x.get(f,C.name,{error:"rowData is not found"});d.forEach(_=>{c.runInteraction(_.id,{...C,rowData:w})})},[f,d,c]),g=y.useMemo(()=>({click:h}),[h]),m=y.useMemo(()=>Od({config:u,data:a,variables:r}),[u,a,r]);return!n||!o||!l?null:i(s.Box,{sx:{width:o,height:l,overflow:"hidden"},children:i(Ne,{echarts:oe,option:m,style:{width:o,height:l},onEvents:g,notMerge:!0,theme:"merico-light"})})}function Pd({control:e,index:t,remove:n,variableOptions:r}){return p(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:a})=>i(s.TextInput,{label:"Name",placeholder:"Average Reference Line",required:!0,sx:{flex:1},...a})}),i(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:a})=>i(s.Select,{label:"Value",required:!0,data:r,sx:{flex:1},...a})})]}),i(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:a})=>i(s.TextInput,{label:"Content Template",placeholder:"Average: ${avg}",required:!0,sx:{flex:1},...a})}),i(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>n(t),sx:{position:"absolute",top:15,right:5},children:i(D.Trash,{size:16})})]},t)}function Bd({control:e,watch:t,variables:n}){const{fields:r,append:a,remove:o}=v.useFieldArray({control:e,name:"reference_lines"}),l=t("reference_lines"),u=r.map((f,h)=>({...f,...l[h]})),c=()=>a({name:"",template:"",variable_key:""}),d=y.useMemo(()=>n.map(f=>({label:f.name,value:f.name})),[n]);return p(s.Stack,{children:[u.map((f,h)=>i(Pd,{control:e,index:h,remove:o,variableOptions:d},f.id)),i(s.Group,{position:"center",mt:"xs",children:i(s.Button,{onClick:c,children:"Add a Reference Line"})})]})}const Vd=({disabled:e,value:t,onChange:n})=>{const r=a=>{a&&n(a)};return p(s.Box,{sx:{position:"relative"},children:[e&&i(s.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),i(Ae,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},Mn=y.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:a,setFalse:o}]=X.useBoolean(),[l,u]=y.useState(e);y.useEffect(()=>{u(e)},[e]);const c=m=>{u({...l,enabled:m})},d=()=>{o();const{enabled:m,func_content:C}=l,w={enabled:m,func_content:C};u(w),t(w)},f=()=>{o(),u(e)},h=m=>{u(C=>({...C,func_content:m}))},g=()=>{h(rt.func_content)};return p(B,{children:[i(s.Button,{variant:"filled",mt:24,onClick:a,sx:{flexGrow:0},children:"Customize Label"}),i(s.Modal,{size:800,title:"Customize label content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&p(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:l.enabled,onChange:m=>c(m.currentTarget.checked)}),i(Vd,{value:l.func_content,onChange:h,disabled:!l.enabled}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:g,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Rest"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:f,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:d,children:"OK"})]})]})]})})]})}),Nd=({control:e,watch:t})=>(t(["x_axis"]),p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.name",control:e,render:({field:n})=>i(s.TextInput,{label:"X Axis Name",sx:{flex:1},...n})}),i(v.Controller,{name:"x_axis.data_key",control:e,render:({field:n})=>i(j,{label:"X Axis Data Field",required:!0,sx:{flex:1},...n})})]}),i(s.Divider,{mb:-15,label:"Tick Label",labelPosition:"center"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:n})=>i(s.NumberInput,{label:"Rotate",hideControls:!0,min:-90,max:90,rightSection:i(s.Text,{color:"dimmed",children:"degree"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),i(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>i(Mn,{...n})})]}),i(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:n})=>i(mt,{...n})})]})),qd=({control:e,watch:t})=>(t(["y_axis"]),p(B,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"y_axis.name",control:e,render:({field:n})=>i(s.TextInput,{label:"Y Axis Name",sx:{flex:1},...n})}),i(v.Controller,{name:"y_axis.data_key",control:e,render:({field:n})=>i(j,{label:"Y Axis Data Field",required:!0,sx:{flex:1},...n})})]}),p(s.Stack,{children:[i(s.Divider,{mb:-15,variant:"dashed",label:"Label Format",labelPosition:"center"}),i(v.Controller,{name:"y_axis.label_formatter",control:e,render:({field:n})=>i(Re,{...n})})]})]})),Fd=({control:e,index:t,remove:n})=>p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:r})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...r})}),i(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:r})=>i(j,{label:"Value Field",required:!0,sx:{flex:1},...r})})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed"}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),sx:{top:15,right:5},children:"Delete this Metric"})]}),Gd=({control:e,watch:t})=>{const{fields:n,append:r,remove:a}=v.useFieldArray({control:e,name:"tooltip.metrics"}),o=t("tooltip.metrics"),l=n.map((h,g)=>({...h,...o[g]})),u=()=>r({id:Date.now().toString(),data_key:"",name:""}),c=t("tooltip.metrics.0.id"),[d,f]=y.useState(()=>c??null);return y.useEffect(()=>{c&&f(h=>h!==null?h:c)},[c]),p(B,{children:[p(s.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[i(D.InfoCircle,{size:14,color:"#888"}),i(s.Text,{size:14,color:"#888",children:"Set additional metrics to show in scatter's tooltip"})]}),p(s.Tabs,{value:d,onTabChange:h=>f(h),styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[p(s.Tabs.List,{children:[l.map((h,g)=>i(s.Tabs.Tab,{value:h.id,children:h.name?h.name:g},h.id)),i(s.Tabs.Tab,{onClick:u,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),l.map((h,g)=>i(s.Tabs.Panel,{value:h.id,children:i(Fd,{control:e,index:g,remove:a},h.id)},h.id))]})]})};function Wd({control:e,watch:t}){return i(s.Stack,{children:i(Gd,{control:e,watch:t})})}function jd({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),{variables:r}=e,a=y.useMemo(()=>x.defaults({},t,kr),[t]),{control:o,handleSubmit:l,watch:u,getValues:c,reset:d}=v.useForm({defaultValues:a});y.useEffect(()=>{d(a)},[a]),u(["x_axis","y_axis","reference_lines","color"]);const f=c(),h=y.useMemo(()=>!x.isEqual(f,t),[f,t]);return i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:l(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"X Axis",children:"X Axis"}),i(s.Tabs.Tab,{value:"Y Axis",children:"Y Axis"}),i(s.Tabs.Tab,{value:"Tooltip",children:"Tooltip"}),i(s.Tabs.Tab,{value:"Style",children:"Style"}),i(s.Tabs.Tab,{value:"Reference Lines",children:"Reference Lines"})]}),i(s.Tabs.Panel,{value:"X Axis",children:i(Nd,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Y Axis",children:i(qd,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Tooltip",children:i(Wd,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Style",children:p(s.Stack,{spacing:4,children:[i(s.Text,{size:"sm",children:"Color"}),i(v.Controller,{name:"color",control:o,render:({field:g})=>i(Pe,{...g})})]})}),i(s.Tabs.Panel,{value:"Reference Lines",children:i(Bd,{variables:r,control:o,watch:u})})]})]})})}function Rd(e){return x.omit(e,"variables")}function Yd(e){const{label_formatter:t=$e,...n}=e.y_axis;return{...e,y_axis:{...n,label_formatter:t}}}function Qd(e){const t={rotate:0,formatter:{...rt}},{axisLabel:n=t,...r}=e.x_axis;return{...e,x_axis:{...r,axisLabel:n}}}function Kd(e){const t={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return x.defaultsDeep(t,e)}function Ud(e){delete e.config;const{x_axis:t,tooltip:n}=e.x_axis.axisLabel.overflow,r={x_axis:{axisLabel:{overflow:{on_axis:t,in_tooltip:n}}}};return x.defaultsDeep(r,e)}function Xd(e){const t={tooltip:{metrics:[]}};return x.defaultsDeep(t,e)}function Jd(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis:a,y_axis:o,tooltip:l,...u}=e;return{...u,x_axis:{...a,data_key:r(a.data_key)},y_axis:{...o,data_key:r(o.data_key)},tooltip:{...l,metrics:l.metrics.map(c=>({...c,data_key:r(c.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}class Zd extends be{constructor(){super(...arguments);q(this,"VERSION",8)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,{panelModel:r})=>{const{config:a}=n;return(a.variables||[]).forEach(l=>{r.variables.find(u=>u.name===l.name)||r.addVariable(l)}),{...n,version:2,config:Rd(a)}}),this.version(3,n=>{const{config:r}=n;return{...n,version:3,config:Yd(r)}}),this.version(4,n=>{const{config:r}=n;return{...n,version:4,config:Qd(r)}}),this.version(5,n=>{const{config:r}=n;return{...n,version:5,config:Kd(r)}}),this.version(6,n=>{const{config:r}=n;return{...n,version:6,config:Ud(r)}}),this.version(7,n=>{const{config:r}=n;return{...n,version:7,config:Xd(r)}}),this.version(8,(n,r)=>{const{config:a}=n;return{...n,version:8,config:Jd(a,r)}})}}const Hd={displayName:"Boxplot Chart",displayGroup:"ECharts-based charts",migrator:new Zd,name:"boxplot",viewRender:Ld,configRender:jd,createConfig(){return{version:8,config:x.cloneDeep(kr)}},triggers:[ss]},ps={id:"builtin:button:click-button",displayName:"Click Button",nameRender:tp,configRender:ep,payload:[]};function ep(e){return i(B,{})}function tp(e){return i(s.Text,{children:"Click this button"})}const Ar={content:"Button",variant:"filled",color:"blue",size:"xs",compact:!1,horizontal_align:"left",vertical_align:"center"},np={left:"flex-start",center:"center",right:"flex-end"},rp={top:"flex-start",center:"center",bottom:"flex-end"},ip=k.observer(({context:e,instance:t})=>{const n=et({vizManager:e.vizManager,instance:t}),r=He(n.triggerManager,ps.id),a=we(),{value:o}=W(e.instanceData,"config"),l=y.useMemo(()=>x.defaultsDeep({},o,Ar),[o]),{content:u,horizontal_align:c,vertical_align:d,...f}=l,{width:h,height:g}=e.viewport,m=a.payloadForSQL,C=()=>{r.forEach(w=>{n.runInteraction(w.id,{})})};return i(s.Center,{sx:{width:h,height:g,justifyContent:np[c],alignItems:rp[d]},children:i(s.Button,{...f,onClick:C,children:x.template(u)(m)})})}),ap=({value:e,onChange:t,label:n})=>{const r=s.useMantineTheme(),a=y.useCallback(l=>()=>t(l),[t]),o=l=>e===l;return p(s.Stack,{spacing:2,children:[i(s.Text,{size:14,sx:{fontWeight:500},children:n}),i(s.Group,{position:"left",spacing:"xs",children:Object.keys(r.colors).map(l=>{const u=r.colors[l][6];return i(s.ColorSwatch,{color:u,onClick:a(l),radius:4,size:26,sx:{cursor:"pointer"},children:o(l)&&i(s.CheckIcon,{width:10,color:"white"})},l)})})]})},sp=s.MANTINE_SIZES.map(e=>({label:e.toUpperCase(),value:e})),op=({label:e,value:t,onChange:n})=>i(s.Select,{data:sp,label:e,value:t,onChange:n}),lp=[{label:"Filled",value:"filled"},{label:"Outline",value:"outline"},{label:"Light",value:"light"},{label:"White",value:"white"},{label:"Default",value:"default"},{label:"Subtle",value:"subtle"},{label:"Gradient",value:"gradient",disabled:!0}],up=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}],cp=[{label:"Top",value:"top"},{label:"Center",value:"center"},{label:"Bottom",value:"bottom"}];function dp({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaultsDeep({},t,Ar),[t]),a=r;y.useEffect(()=>{!x.isEqual(r,a)&&(console.log("config malformed, resetting to defaults",r,a),n(a))},[r,a]);const{control:o,handleSubmit:l,watch:u,getValues:c,reset:d}=v.useForm({defaultValues:a});y.useEffect(()=>{d(a)},[a]);const f=c(),h=y.useMemo(()=>!x.isEqual(f,r),[f,r]);return u(["content","variant","color","size","compact","horizontal_align","vertical_align"]),p("form",{onSubmit:l(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Stack,{children:[i(v.Controller,{control:o,name:"content",render:({field:g})=>i(s.TextInput,{label:"Content Template",description:"Filter values & context entries are supported",...g,required:!0})}),i(s.Divider,{mt:"xs",mb:0,label:"Styles",labelPosition:"center",variant:"dashed"}),p(s.SimpleGrid,{cols:2,children:[i(v.Controller,{control:o,name:"variant",render:({field:g})=>i(s.Select,{label:"Variant",data:lp,...g})}),i(v.Controller,{control:o,name:"color",render:({field:g})=>i(ap,{label:"Theme",...g})})]}),p(s.SimpleGrid,{cols:2,children:[i(v.Controller,{control:o,name:"size",render:({field:g})=>i(op,{label:"Size",...g})}),i(v.Controller,{control:o,name:"compact",render:({field:g})=>i(s.Checkbox,{label:"Compact",checked:g.value,onChange:m=>g.onChange(m.currentTarget.checked),mt:26})})]}),p(s.SimpleGrid,{cols:2,children:[i(v.Controller,{control:o,name:"horizontal_align",render:({field:g})=>i(s.Select,{label:"Horizontal Alignment",data:up,...g})}),i(v.Controller,{control:o,name:"vertical_align",render:({field:g})=>i(s.Select,{label:"Vertical Alignment",data:cp,...g})})]})]})]})}class pp extends be{constructor(){super(...arguments);q(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{horizontal_align:r="left",vertical_align:a="center",...o}=n.config;return{...n,version:2,config:{...o,horizontal_align:r,vertical_align:a}}})}}const hp={displayName:"Button",displayGroup:"Others",migrator:new pp,name:"button",viewRender:ip,configRender:dp,createConfig(){return{version:2,config:x.cloneDeep(Ar)}},triggers:[ps]},zr={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:gp,configRender:fp,payload:[{name:"seriesType",description:"'line' | 'scatter' | 'bar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function fp(e){return i(B,{})}function gp(e){return i(s.Text,{children:"Click chart's series"})}const Vt={x_axis_scroll:!1,y_axis_scroll:!1,x_axis_slider:!1,y_axis_slider:!1},$r={regressions:[],series:[],stats:{templates:{bottom:"",top:""}},x_axis:{type:"category",axisLabel:{rotate:0,formatter:{...rt},overflow:Ze}},x_axis_data_key:"",x_axis_name:"",y_axes:[{min:"",max:"",name:"Y Axis",show:!0,position:"left",nameAlignment:"center",label_formatter:$e}],reference_lines:[],reference_areas:[],dataZoom:Vt};function Or(e){const t=[];return e.x_axis_scroll&&t.push({type:"inside",xAxisIndex:[0],filterMode:"none",minSpan:1}),e.y_axis_scroll&&t.push({type:"inside",yAxisIndex:[0],filterMode:"none",minSpan:1}),e.x_axis_slider&&t.push({type:"slider",xAxisIndex:[0],filterMode:"none",bottom:"auto",top:0,height:15,moveHandleSize:0,showDataShadow:!1,minSpan:1}),t}function mp(e){const t=e.y_axes.some(a=>!!a.name);let n=15;t&&(n+=20),e.dataZoom.x_axis_slider&&(n+=20);let r=5;return e.x_axis_name&&(r+=15),e.series.some(a=>!a.hide_in_legend)&&(r+=20),{top:n,right:15,bottom:r,left:20,containLabel:!0}}function yp(e){return e!=="line"?{}:{itemStyle:{opacity:0}}}function bp(e){switch(e){case"line":return;case"bar":return"roundRect";case"scatter":return"circle"}}function vp(e){const t={show:!0,bottom:0,left:"center",type:"scroll"};return t.data=e.filter(n=>!n.hide_in_legend).map(({name:n,type:r})=>({name:n,icon:bp(r),...yp(r)})),t}function In(e,t){switch(e.config.method){case"linear":return[...ft.regressionLinear()(t)];case"exponential":return[...ft.regressionExp()(t)];case"logarithmic":return[...ft.regressionLog()(t)];case"polynomial":return[...ft.regressionPoly().order(e.config.order)(t)];default:return[]}}function xp(e,t,n,r){const{transform:a,plot:o}=e,l={...o,name:t,data:In(a,r),showSymbol:!1,tooltip:{show:!1},smooth:!1,custom:{}};return n&&(l.custom={type:"regression-line",targetSeries:n}),l}function wp({regressions:e=[],x_axis_data_key:t},n){const r=[];if(Object.keys(n).length===0)return r;function a(o,l,u,c){const d=xp(o,l,u,c);r.push(d)}return e.forEach(o=>{const{name:l,group_by_key:u}=o;if(!u||u===t){const h=ut(n,o.y_axis_data_key).map((g,m)=>[m,Number(g)]);a(o,l,"",h);return}const{columnKey:c}=V(o.y_axis_data_key),d=x.groupBy(vn(n,o.y_axis_data_key),u);Object.entries(d).forEach(([f,h])=>{const g=h.map((C,w)=>[w,Number(C[c])]);a(o,f,f,g)})}),r}function Cp(e,t){return e.map(n=>({name:"",type:"line",hide_in_legend:!0,data:[],markArea:{itemStyle:{color:n.color},data:[[{yAxis:t[n.y_keys.upper]},{yAxis:t[n.y_keys.lower]}]],silent:!0}}))}function Sp(e,t,n,r){return e.map(a=>{const o=a.orientation==="horizontal",l=o?"yAxis":"xAxis",u=o?"insideEndTop":"end";return{name:a.name,type:"line",hide_in_legend:!a.show_in_legend,yAxisIndex:a.yAxisIndex,data:[],lineStyle:a.lineStyle,markLine:{data:[{name:a.name,[l]:Number(n[a.variable_key])}],silent:!0,symbol:["none","none"],lineStyle:a.lineStyle,label:{formatter:function(){return a.template?Dn(a.template,t,r):""},position:u}}}})}function _p({type:e,...t},n,r,a){if(!e)return 10;if(e==="static"){const{size:d}=t;return d}const{func_content:o}=t,{queryID:l,columnKey:u}=V(r),c=x.keyBy(vn(n,l),u);return(d,f)=>{let h;f.name?h=c[f.name]:h=n[f.dataIndex];try{return new Function(`return ${o}`)()({rowData:h,params:f,variables:a},{lodash:x,interpolate:_t.interpolate})}catch(g){return console.error(`[getEchartsSymbolSize] failed parsing custom function, error: ${g.message}`),10}}}function Lr(e,t,n){const r=ut(e,t),a=ut(e,n);return x.zip(r,a)}function kp(e,t,n,r){const a=Lr(t,n,r);return x.unionBy(a,e,0)}function Tp({dataTemplate:e,data:t,x_axis_data_key:n,y_axis_data_key:r,valueTypedXAxis:a}){return a?kp(e,t,n,r):ut(t,r)}function Dp({dataTemplate:e,data:t,aggregation_on_value:n,x_axis_data_key:r,y_axis_data_key:a,valueTypedXAxis:o}){if(!n||n.type==="none")return Tp({dataTemplate:e,data:t,x_axis_data_key:r,y_axis_data_key:a,valueTypedXAxis:o});const l=Lr(t,r,a),u=x.groupBy(l,"0");return e.map(([d])=>{const h=u[d].map(m=>m[1]),g=Ir(h,n);return[d,g]})}function Mp({group_by_key:e,data:t,x_axis_data_key:n,y_axis_data_key:r}){const{queryID:a,columnKey:o}=V(e),l=x.groupBy(t[a],o);return Object.entries(l).forEach(([u,c])=>{l[u]=Lr({[a]:c},n,r)}),l}function Ip({x_axis_data_key:e,x_axis:t},{y_axis_data_key:n,yAxisIndex:r,label_position:a,name:o,group_by_key:l,aggregation_on_value:u,stack:c,color:d,display_name_on_line:f,symbolSize:h,hide_in_legend:g,...m},C,w,_,T){const I=t.type!=="category",L={label:{show:!!a,position:a,formatter:T[r??"default"]},name:o,xAxisId:"main-x-axis",yAxisIndex:r,stack:c,color:d,symbolSize:_p(h,w,e,_),hide_in_legend:g,labelLayout:{hideOverlap:!0},...m};if(f&&(L.endLabel={show:!0,formatter:o,offset:[-12,12],align:"right"}),!l||l===e)return L.data=Dp({dataTemplate:C,data:w,aggregation_on_value:u,x_axis_data_key:e,y_axis_data_key:n,valueTypedXAxis:I}),L;const N=Mp({group_by_key:l,data:w,x_axis_data_key:e,y_axis_data_key:n});return Object.entries(N).map(([O,A])=>{const E=x.cloneDeep(L);return E.name=O,E.color=void 0,E.data=A,E})}function Ep(e,t,n,r,a,o){const l=t.map(c=>[c,0]);return e.series.map(c=>Ip(e,c,l,n,o,r)).flat().concat(Sp(e.reference_lines,a,o,n)).concat(Cp(e.reference_areas,o))}function Ap(e,t){const n=e.find(o=>o.axisDim==="x"&&o.axisId==="main-x-axis");if(!n)return"";const{axisValue:r,axisIndex:a}=n;return Pt(t.x_axis.axisLabel.formatter)(r,a)}function zp(e,t,n){const r=t.reduce((a,{yAxisIndex:o,name:l})=>(a[l]=o,a),{});return{trigger:"axis",confine:!0,formatter:function(a){const o=Array.isArray(a)?a:[a];if(o.length===0)return"";const l=o.map(({seriesName:d,marker:f,value:h})=>{if(Array.isArray(h)&&h.length===2&&(h=h[1]),!d)return h;const g=r[d],m=n[g]??n.default;return`
|
|
101
|
+
`,"<br/>").split("<br/>");return n.map((a,o)=>{const l=[Ed(a)];return o!==n.length-1&&l.push(i("br",{},`br-${o}`)),l}).flat().filter(a=>a!==void 0)}function Er(e){return Ad(e)}function Zt(e,t,n){const r=Id(t,n),a=/^\{(.+)\}(.*)$/;return e.split("$").map((o,l)=>{const u=a.exec(o);if(!u)return Er(o);const c=r[u[1]];if(!c)return Er(o);const d=u[2]??"";return p(y.Fragment,{children:[c,Er(d)]},`${o}-${l}`)})}function zd(e,t){const n={};return e.forEach(r=>{const{name:a,data_field:o,aggregation:l}=r,u=Tn(t,o,l);n[a]=tt(r,u)}),n}function Dn(e,t,n){const r=zd(t,n),a=/^\{(.+)\}(.*)$/;return e.split("$").map(o=>{const l=a.exec(o);if(!l)return o;const u=r[l[1]];if(!u)return o;const c=l[2]??"";return`${u}${c}`}).join("")}function $d(e,t,n){const r=t.reduce((a,o)=>{const l=bt(o,n);return a[o.name]=tt(o,l),a},{});return e.map(a=>({name:"refs",type:"scatter",data:[],markLine:{data:[{name:a.name,yAxis:Number(r[a.variable_key])}],silent:!0,symbol:["none","none"],label:{formatter:function(){return Dn(a.template,t,n)},position:"insideEndTop"}}}))}function Od({config:e,data:t,variables:n}){const{x_axis:r,y_axis:a,reference_lines:o}=e,l=sd(e,t),u=ct(r.axisLabel.overflow.on_axis),c=ld(e);return{grid:{top:30,left:20,right:15,bottom:25,containLabel:!0},dataset:l,legend:od({config:e}),tooltip:fd({config:e}),xAxis:[{type:"category",name:r.name,nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold",align:"center"},axisTick:{show:!0,alignWithLabel:!0},axisLabel:{...r.axisLabel,...u,formatter:Pt(r.axisLabel.formatter)}}],yAxis:[{name:a.name,nameTextStyle:{fontWeight:"bold"},axisLine:{show:!0},axisLabel:{formatter:function(d){return H(d).format(a.label_formatter)}}}],series:[...c,...$d(o,n,t)]}}oe.use([G.DataZoomComponent,pe.BoxplotChart,G.MarkLineComponent,G.GridComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function Ld({context:e,instance:t}){const{value:n}=W(e.instanceData,"config"),{variables:r}=e,a=e.data,{width:o,height:l}=e.viewport,u=x.defaults({},n,kr),c=et({vizManager:e.vizManager,instance:t}),d=He(c.triggerManager,ss.id),f=Tt(a,u.x_axis.data_key),h=y.useCallback(C=>{const w=x.get(f,C.name,{error:"rowData is not found"});d.forEach(_=>{c.runInteraction(_.id,{...C,rowData:w})})},[f,d,c]),g=y.useMemo(()=>({click:h}),[h]),m=y.useMemo(()=>Od({config:u,data:a,variables:r}),[u,a,r]);return!n||!o||!l?null:i(s.Box,{sx:{width:o,height:l,overflow:"hidden"},children:i(Ne,{echarts:oe,option:m,style:{width:o,height:l},onEvents:g,notMerge:!0,theme:"merico-light"})})}function Pd({control:e,index:t,remove:n,variableOptions:r}){return p(s.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:a})=>i(s.TextInput,{label:"Name",placeholder:"Average Reference Line",required:!0,sx:{flex:1},...a})}),i(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:a})=>i(s.Select,{label:"Value",required:!0,data:r,sx:{flex:1},...a})})]}),i(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:a})=>i(s.TextInput,{label:"Content Template",placeholder:"Average: ${avg}",required:!0,sx:{flex:1},...a})}),i(s.ActionIcon,{color:"red",variant:"subtle",onClick:()=>n(t),sx:{position:"absolute",top:15,right:5},children:i(D.Trash,{size:16})})]},t)}function Bd({control:e,watch:t,variables:n}){const{fields:r,append:a,remove:o}=v.useFieldArray({control:e,name:"reference_lines"}),l=t("reference_lines"),u=r.map((f,h)=>({...f,...l[h]})),c=()=>a({name:"",template:"",variable_key:""}),d=y.useMemo(()=>n.map(f=>({label:f.name,value:f.name})),[n]);return p(s.Stack,{children:[u.map((f,h)=>i(Pd,{control:e,index:h,remove:o,variableOptions:d},f.id)),i(s.Group,{position:"center",mt:"xs",children:i(s.Button,{onClick:c,children:"Add a Reference Line"})})]})}const Vd=({disabled:e,value:t,onChange:n})=>{const r=a=>{a&&n(a)};return p(s.Box,{sx:{position:"relative"},children:[e&&i(s.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),i(Ae,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},Mn=y.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:a,setFalse:o}]=X.useBoolean(),[l,u]=y.useState(e);y.useEffect(()=>{u(e)},[e]);const c=m=>{u({...l,enabled:m})},d=()=>{o();const{enabled:m,func_content:C}=l,w={enabled:m,func_content:C};u(w),t(w)},f=()=>{o(),u(e)},h=m=>{u(C=>({...C,func_content:m}))},g=()=>{h(rt.func_content)};return p(B,{children:[i(s.Button,{variant:"filled",mt:24,onClick:a,sx:{flexGrow:0},children:"Customize Label"}),i(s.Modal,{size:800,title:"Customize label content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&p(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:l.enabled,onChange:m=>c(m.currentTarget.checked)}),i(Vd,{value:l.func_content,onChange:h,disabled:!l.enabled}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:g,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Reset"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:f,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:d,children:"OK"})]})]})]})})]})}),Nd=({control:e,watch:t})=>(t(["x_axis"]),p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.name",control:e,render:({field:n})=>i(s.TextInput,{label:"X Axis Name",sx:{flex:1},...n})}),i(v.Controller,{name:"x_axis.data_key",control:e,render:({field:n})=>i(j,{label:"X Axis Data Field",required:!0,sx:{flex:1},...n})})]}),i(s.Divider,{mb:-15,label:"Tick Label",labelPosition:"center"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:n})=>i(s.NumberInput,{label:"Rotate",hideControls:!0,min:-90,max:90,rightSection:i(s.Text,{color:"dimmed",children:"degree"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),i(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>i(Mn,{...n})})]}),i(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:n})=>i(mt,{...n})})]})),qd=({control:e,watch:t})=>(t(["y_axis"]),p(B,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"y_axis.name",control:e,render:({field:n})=>i(s.TextInput,{label:"Y Axis Name",sx:{flex:1},...n})}),i(v.Controller,{name:"y_axis.data_key",control:e,render:({field:n})=>i(j,{label:"Y Axis Data Field",required:!0,sx:{flex:1},...n})})]}),p(s.Stack,{children:[i(s.Divider,{mb:-15,variant:"dashed",label:"Label Format",labelPosition:"center"}),i(v.Controller,{name:"y_axis.label_formatter",control:e,render:({field:n})=>i(Re,{...n})})]})]})),Fd=({control:e,index:t,remove:n})=>p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:r})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...r})}),i(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:r})=>i(j,{label:"Value Field",required:!0,sx:{flex:1},...r})})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed"}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),sx:{top:15,right:5},children:"Delete this Metric"})]}),Gd=({control:e,watch:t})=>{const{fields:n,append:r,remove:a}=v.useFieldArray({control:e,name:"tooltip.metrics"}),o=t("tooltip.metrics"),l=n.map((h,g)=>({...h,...o[g]})),u=()=>r({id:Date.now().toString(),data_key:"",name:""}),c=t("tooltip.metrics.0.id"),[d,f]=y.useState(()=>c??null);return y.useEffect(()=>{c&&f(h=>h!==null?h:c)},[c]),p(B,{children:[p(s.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[i(D.InfoCircle,{size:14,color:"#888"}),i(s.Text,{size:14,color:"#888",children:"Set additional metrics to show in scatter's tooltip"})]}),p(s.Tabs,{value:d,onTabChange:h=>f(h),styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[p(s.Tabs.List,{children:[l.map((h,g)=>i(s.Tabs.Tab,{value:h.id,children:h.name?h.name:g},h.id)),i(s.Tabs.Tab,{onClick:u,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),l.map((h,g)=>i(s.Tabs.Panel,{value:h.id,children:i(Fd,{control:e,index:g,remove:a},h.id)},h.id))]})]})};function Wd({control:e,watch:t}){return i(s.Stack,{children:i(Gd,{control:e,watch:t})})}function jd({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),{variables:r}=e,a=y.useMemo(()=>x.defaults({},t,kr),[t]),{control:o,handleSubmit:l,watch:u,getValues:c,reset:d}=v.useForm({defaultValues:a});y.useEffect(()=>{d(a)},[a]),u(["x_axis","y_axis","reference_lines","color"]);const f=c(),h=y.useMemo(()=>!x.isEqual(f,t),[f,t]);return i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:l(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"X Axis",children:"X Axis"}),i(s.Tabs.Tab,{value:"Y Axis",children:"Y Axis"}),i(s.Tabs.Tab,{value:"Tooltip",children:"Tooltip"}),i(s.Tabs.Tab,{value:"Style",children:"Style"}),i(s.Tabs.Tab,{value:"Reference Lines",children:"Reference Lines"})]}),i(s.Tabs.Panel,{value:"X Axis",children:i(Nd,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Y Axis",children:i(qd,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Tooltip",children:i(Wd,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Style",children:p(s.Stack,{spacing:4,children:[i(s.Text,{size:"sm",children:"Color"}),i(v.Controller,{name:"color",control:o,render:({field:g})=>i(Pe,{...g})})]})}),i(s.Tabs.Panel,{value:"Reference Lines",children:i(Bd,{variables:r,control:o,watch:u})})]})]})})}function Rd(e){return x.omit(e,"variables")}function Yd(e){const{label_formatter:t=$e,...n}=e.y_axis;return{...e,y_axis:{...n,label_formatter:t}}}function Qd(e){const t={rotate:0,formatter:{...rt}},{axisLabel:n=t,...r}=e.x_axis;return{...e,x_axis:{...r,axisLabel:n}}}function Kd(e){const t={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return x.defaultsDeep(t,e)}function Ud(e){delete e.config;const{x_axis:t,tooltip:n}=e.x_axis.axisLabel.overflow,r={x_axis:{axisLabel:{overflow:{on_axis:t,in_tooltip:n}}}};return x.defaultsDeep(r,e)}function Xd(e){const t={tooltip:{metrics:[]}};return x.defaultsDeep(t,e)}function Jd(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis:a,y_axis:o,tooltip:l,...u}=e;return{...u,x_axis:{...a,data_key:r(a.data_key)},y_axis:{...o,data_key:r(o.data_key)},tooltip:{...l,metrics:l.metrics.map(c=>({...c,data_key:r(c.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}class Zd extends be{constructor(){super(...arguments);q(this,"VERSION",8)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,{panelModel:r})=>{const{config:a}=n;return(a.variables||[]).forEach(l=>{r.variables.find(u=>u.name===l.name)||r.addVariable(l)}),{...n,version:2,config:Rd(a)}}),this.version(3,n=>{const{config:r}=n;return{...n,version:3,config:Yd(r)}}),this.version(4,n=>{const{config:r}=n;return{...n,version:4,config:Qd(r)}}),this.version(5,n=>{const{config:r}=n;return{...n,version:5,config:Kd(r)}}),this.version(6,n=>{const{config:r}=n;return{...n,version:6,config:Ud(r)}}),this.version(7,n=>{const{config:r}=n;return{...n,version:7,config:Xd(r)}}),this.version(8,(n,r)=>{const{config:a}=n;return{...n,version:8,config:Jd(a,r)}})}}const Hd={displayName:"Boxplot Chart",displayGroup:"ECharts-based charts",migrator:new Zd,name:"boxplot",viewRender:Ld,configRender:jd,createConfig(){return{version:8,config:x.cloneDeep(kr)}},triggers:[ss]},ps={id:"builtin:button:click-button",displayName:"Click Button",nameRender:tp,configRender:ep,payload:[]};function ep(e){return i(B,{})}function tp(e){return i(s.Text,{children:"Click this button"})}const Ar={content:"Button",variant:"filled",color:"blue",size:"xs",compact:!1,horizontal_align:"left",vertical_align:"center"},np={left:"flex-start",center:"center",right:"flex-end"},rp={top:"flex-start",center:"center",bottom:"flex-end"},ip=k.observer(({context:e,instance:t})=>{const n=et({vizManager:e.vizManager,instance:t}),r=He(n.triggerManager,ps.id),a=we(),{value:o}=W(e.instanceData,"config"),l=y.useMemo(()=>x.defaultsDeep({},o,Ar),[o]),{content:u,horizontal_align:c,vertical_align:d,...f}=l,{width:h,height:g}=e.viewport,m=a.payloadForSQL,C=()=>{r.forEach(w=>{n.runInteraction(w.id,{})})};return i(s.Center,{sx:{width:h,height:g,justifyContent:np[c],alignItems:rp[d]},children:i(s.Button,{...f,onClick:C,children:x.template(u)(m)})})}),ap=({value:e,onChange:t,label:n})=>{const r=s.useMantineTheme(),a=y.useCallback(l=>()=>t(l),[t]),o=l=>e===l;return p(s.Stack,{spacing:2,children:[i(s.Text,{size:14,sx:{fontWeight:500},children:n}),i(s.Group,{position:"left",spacing:"xs",children:Object.keys(r.colors).map(l=>{const u=r.colors[l][6];return i(s.ColorSwatch,{color:u,onClick:a(l),radius:4,size:26,sx:{cursor:"pointer"},children:o(l)&&i(s.CheckIcon,{width:10,color:"white"})},l)})})]})},sp=s.MANTINE_SIZES.map(e=>({label:e.toUpperCase(),value:e})),op=({label:e,value:t,onChange:n})=>i(s.Select,{data:sp,label:e,value:t,onChange:n}),lp=[{label:"Filled",value:"filled"},{label:"Outline",value:"outline"},{label:"Light",value:"light"},{label:"White",value:"white"},{label:"Default",value:"default"},{label:"Subtle",value:"subtle"},{label:"Gradient",value:"gradient",disabled:!0}],up=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}],cp=[{label:"Top",value:"top"},{label:"Center",value:"center"},{label:"Bottom",value:"bottom"}];function dp({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaultsDeep({},t,Ar),[t]),a=r;y.useEffect(()=>{!x.isEqual(r,a)&&(console.log("config malformed, resetting to defaults",r,a),n(a))},[r,a]);const{control:o,handleSubmit:l,watch:u,getValues:c,reset:d}=v.useForm({defaultValues:a});y.useEffect(()=>{d(a)},[a]);const f=c(),h=y.useMemo(()=>!x.isEqual(f,r),[f,r]);return u(["content","variant","color","size","compact","horizontal_align","vertical_align"]),p("form",{onSubmit:l(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Stack,{children:[i(v.Controller,{control:o,name:"content",render:({field:g})=>i(s.TextInput,{label:"Content Template",description:"Filter values & context entries are supported",...g,required:!0})}),i(s.Divider,{mt:"xs",mb:0,label:"Styles",labelPosition:"center",variant:"dashed"}),p(s.SimpleGrid,{cols:2,children:[i(v.Controller,{control:o,name:"variant",render:({field:g})=>i(s.Select,{label:"Variant",data:lp,...g})}),i(v.Controller,{control:o,name:"color",render:({field:g})=>i(ap,{label:"Theme",...g})})]}),p(s.SimpleGrid,{cols:2,children:[i(v.Controller,{control:o,name:"size",render:({field:g})=>i(op,{label:"Size",...g})}),i(v.Controller,{control:o,name:"compact",render:({field:g})=>i(s.Checkbox,{label:"Compact",checked:g.value,onChange:m=>g.onChange(m.currentTarget.checked),mt:26})})]}),p(s.SimpleGrid,{cols:2,children:[i(v.Controller,{control:o,name:"horizontal_align",render:({field:g})=>i(s.Select,{label:"Horizontal Alignment",data:up,...g})}),i(v.Controller,{control:o,name:"vertical_align",render:({field:g})=>i(s.Select,{label:"Vertical Alignment",data:cp,...g})})]})]})]})}class pp extends be{constructor(){super(...arguments);q(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{horizontal_align:r="left",vertical_align:a="center",...o}=n.config;return{...n,version:2,config:{...o,horizontal_align:r,vertical_align:a}}})}}const hp={displayName:"Button",displayGroup:"Others",migrator:new pp,name:"button",viewRender:ip,configRender:dp,createConfig(){return{version:2,config:x.cloneDeep(Ar)}},triggers:[ps]},zr={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:gp,configRender:fp,payload:[{name:"seriesType",description:"'line' | 'scatter' | 'bar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function fp(e){return i(B,{})}function gp(e){return i(s.Text,{children:"Click chart's series"})}const Vt={x_axis_scroll:!1,y_axis_scroll:!1,x_axis_slider:!1,y_axis_slider:!1},$r={regressions:[],series:[],stats:{templates:{bottom:"",top:""}},x_axis:{type:"category",axisLabel:{rotate:0,formatter:{...rt},overflow:Ze}},x_axis_data_key:"",x_axis_name:"",y_axes:[{min:"",max:"",name:"Y Axis",show:!0,position:"left",nameAlignment:"center",label_formatter:$e}],reference_lines:[],reference_areas:[],dataZoom:Vt};function Or(e){const t=[];return e.x_axis_scroll&&t.push({type:"inside",xAxisIndex:[0],filterMode:"none",minSpan:1}),e.y_axis_scroll&&t.push({type:"inside",yAxisIndex:[0],filterMode:"none",minSpan:1}),e.x_axis_slider&&t.push({type:"slider",xAxisIndex:[0],filterMode:"none",bottom:"auto",top:0,height:15,moveHandleSize:0,showDataShadow:!1,minSpan:1}),t}function mp(e){const t=e.y_axes.some(a=>!!a.name);let n=15;t&&(n+=20),e.dataZoom.x_axis_slider&&(n+=20);let r=5;return e.x_axis_name&&(r+=15),e.series.some(a=>!a.hide_in_legend)&&(r+=20),{top:n,right:15,bottom:r,left:20,containLabel:!0}}function yp(e){return e!=="line"?{}:{itemStyle:{opacity:0}}}function bp(e){switch(e){case"line":return;case"bar":return"roundRect";case"scatter":return"circle"}}function vp(e){const t={show:!0,bottom:0,left:"center",type:"scroll"};return t.data=e.filter(n=>!n.hide_in_legend).map(({name:n,type:r})=>({name:n,icon:bp(r),...yp(r)})),t}function In(e,t){switch(e.config.method){case"linear":return[...ft.regressionLinear()(t)];case"exponential":return[...ft.regressionExp()(t)];case"logarithmic":return[...ft.regressionLog()(t)];case"polynomial":return[...ft.regressionPoly().order(e.config.order)(t)];default:return[]}}function xp(e,t,n,r){const{transform:a,plot:o}=e,l={...o,name:t,data:In(a,r),showSymbol:!1,tooltip:{show:!1},smooth:!1,custom:{}};return n&&(l.custom={type:"regression-line",targetSeries:n}),l}function wp({regressions:e=[],x_axis_data_key:t},n){const r=[];if(Object.keys(n).length===0)return r;function a(o,l,u,c){const d=xp(o,l,u,c);r.push(d)}return e.forEach(o=>{const{name:l,group_by_key:u}=o;if(!u||u===t){const h=ut(n,o.y_axis_data_key).map((g,m)=>[m,Number(g)]);a(o,l,"",h);return}const{columnKey:c}=V(o.y_axis_data_key),d=x.groupBy(vn(n,o.y_axis_data_key),u);Object.entries(d).forEach(([f,h])=>{const g=h.map((C,w)=>[w,Number(C[c])]);a(o,f,f,g)})}),r}function Cp(e,t){return e.map(n=>({name:"",type:"line",hide_in_legend:!0,data:[],markArea:{itemStyle:{color:n.color},data:[[{yAxis:t[n.y_keys.upper]},{yAxis:t[n.y_keys.lower]}]],silent:!0}}))}function Sp(e,t,n,r){return e.map(a=>{const o=a.orientation==="horizontal",l=o?"yAxis":"xAxis",u=o?"insideEndTop":"end";return{name:a.name,type:"line",hide_in_legend:!a.show_in_legend,yAxisIndex:a.yAxisIndex,data:[],lineStyle:a.lineStyle,markLine:{data:[{name:a.name,[l]:Number(n[a.variable_key])}],silent:!0,symbol:["none","none"],lineStyle:a.lineStyle,label:{formatter:function(){return a.template?Dn(a.template,t,r):""},position:u}}}})}function _p({type:e,...t},n,r,a){if(!e)return 10;if(e==="static"){const{size:d}=t;return d}const{func_content:o}=t,{queryID:l,columnKey:u}=V(r),c=x.keyBy(vn(n,l),u);return(d,f)=>{let h;f.name?h=c[f.name]:h=n[f.dataIndex];try{return new Function(`return ${o}`)()({rowData:h,params:f,variables:a},{lodash:x,interpolate:_t.interpolate})}catch(g){return console.error(`[getEchartsSymbolSize] failed parsing custom function, error: ${g.message}`),10}}}function Lr(e,t,n){const r=ut(e,t),a=ut(e,n);return x.zip(r,a)}function kp(e,t,n,r){const a=Lr(t,n,r);return x.unionBy(a,e,0)}function Tp({dataTemplate:e,data:t,x_axis_data_key:n,y_axis_data_key:r,valueTypedXAxis:a}){return a?kp(e,t,n,r):ut(t,r)}function Dp({dataTemplate:e,data:t,aggregation_on_value:n,x_axis_data_key:r,y_axis_data_key:a,valueTypedXAxis:o}){if(!n||n.type==="none")return Tp({dataTemplate:e,data:t,x_axis_data_key:r,y_axis_data_key:a,valueTypedXAxis:o});const l=Lr(t,r,a),u=x.groupBy(l,"0");return e.map(([d])=>{const h=u[d].map(m=>m[1]),g=Ir(h,n);return[d,g]})}function Mp({group_by_key:e,data:t,x_axis_data_key:n,y_axis_data_key:r}){const{queryID:a,columnKey:o}=V(e),l=x.groupBy(t[a],o);return Object.entries(l).forEach(([u,c])=>{l[u]=Lr({[a]:c},n,r)}),l}function Ip({x_axis_data_key:e,x_axis:t},{y_axis_data_key:n,yAxisIndex:r,label_position:a,name:o,group_by_key:l,aggregation_on_value:u,stack:c,color:d,display_name_on_line:f,symbolSize:h,hide_in_legend:g,...m},C,w,_,T){const I=t.type!=="category",L={label:{show:!!a,position:a,formatter:T[r??"default"]},name:o,xAxisId:"main-x-axis",yAxisIndex:r,stack:c,color:d,symbolSize:_p(h,w,e,_),hide_in_legend:g,labelLayout:{hideOverlap:!0},...m};if(f&&(L.endLabel={show:!0,formatter:o,offset:[-12,12],align:"right"}),!l||l===e)return L.data=Dp({dataTemplate:C,data:w,aggregation_on_value:u,x_axis_data_key:e,y_axis_data_key:n,valueTypedXAxis:I}),L;const N=Mp({group_by_key:l,data:w,x_axis_data_key:e,y_axis_data_key:n});return Object.entries(N).map(([O,A])=>{const E=x.cloneDeep(L);return E.name=O,E.color=void 0,E.data=A,E})}function Ep(e,t,n,r,a,o){const l=t.map(c=>[c,0]);return e.series.map(c=>Ip(e,c,l,n,o,r)).flat().concat(Sp(e.reference_lines,a,o,n)).concat(Cp(e.reference_areas,o))}function Ap(e,t){const n=e.find(o=>o.axisDim==="x"&&o.axisId==="main-x-axis");if(!n)return"";const{axisValue:r,axisIndex:a}=n;return Pt(t.x_axis.axisLabel.formatter)(r,a)}function zp(e,t,n){const r=t.reduce((a,{yAxisIndex:o,name:l})=>(a[l]=o,a),{});return{trigger:"axis",confine:!0,formatter:function(a){const o=Array.isArray(a)?a:[a];if(o.length===0)return"";const l=o.map(({seriesName:d,marker:f,value:h})=>{if(Array.isArray(h)&&h.length===2&&(h=h[1]),!d)return h;const g=r[d],m=n[g]??n.default;return`
|
|
102
102
|
<tr>
|
|
103
103
|
<td>${f}</td>
|
|
104
104
|
<th style="text-align: right; padding: 0 1em;">${d}</th>
|
|
@@ -114,7 +114,7 @@ Check the top-level render call using <`+P+">.")}return z}}function bu(S,z){{if(
|
|
|
114
114
|
</tbody>
|
|
115
115
|
</table>
|
|
116
116
|
`}}}function $p(e){return e.y_axes.reduce((n,{label_formatter:r},a)=>(n[a]=function(l){let u=l;if(typeof l=="object"&&(Array.isArray(l.value)&&l.value.length===2?u=l.value[1]:u=l.value),!r)return u;try{return H(u).format(r)}catch(c){return console.error(c),u}},n),{default:({value:n})=>n})}function hs(e,t){const n={};return t.map(r=>{const a=bt(r,e);n[r.name]=tt(r,a)}),n}function Op(e,t){const{overflow:n,...r}=e.x_axis.axisLabel,a=ct(n.on_axis);return[{data:t,name:e.x_axis_name??"",id:"main-x-axis",axisTick:{show:!0,alignWithLabel:!0},type:e.x_axis.type,axisLabel:{...r,...a,formatter:Pt(r.formatter)}}]}function Lp(e,t){return e.y_axes.map(({nameAlignment:n,min:r,max:a,show:o,...l},u)=>{let c=l.position;return c||(c=u>0?"right":"left"),{...l,show:o,min:r||void 0,max:a||void 0,position:c,axisLabel:{show:o,formatter:t[u]??t.default},axisLine:{show:o},nameTextStyle:{fontWeight:"bold",align:n},nameLocation:"end",nameGap:o?15:0,splitLine:{show:!1}}})}const Pp={xAxis:[{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"},splitLine:{show:!1},axisTick:{show:!0,alignWithLabel:!0}}]};function Bp(e,t,n){const r=hs(t,n),a=$p(e),o=x.uniq(ut(t,e.x_axis_data_key)),l=Ep(e,o,t,a,n,r),u=wp(e,t),c={xAxis:Op(e,o),yAxis:Lp(e,a),series:[...l,...u],tooltip:zp(e,l,a),grid:mp(e),legend:vp(l),dataZoom:Or(e.dataZoom)};return x.defaultsDeep({},c,Pp)}function fs(e){const t=e.getModel(),n=t.getSeries().map(r=>{if(!r.option.custom)return r.option;const a=t.getColorFromPalette(r.option.custom.targetSeries,null);return r.option.color=a,r.option});e.setOption({...e.getOption(),series:n})}oe.use([G.DataZoomComponent,pe.BarChart,pe.LineChart,pe.ScatterChart,G.GridComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer,G.MarkLineComponent,G.MarkAreaComponent]);function gs(e){return e.trim().length>0}function Vp({conf:e,data:t,width:n,height:r,interactionManager:a,variables:o}){const l=Tt(t,e.x_axis_data_key),u=He(a.triggerManager,zr.id),c=y.useCallback(m=>{const C=x.get(l,m.name,{error:"rowData is not found"});u.forEach(w=>{a.runInteraction(w.id,{...m,rowData:C})})},[l,u,a]),d=y.useMemo(()=>Bp(e,t,o),[e,t]),f=y.useRef(),h=y.useMemo(()=>({click:c}),[c]),g=m=>{f.current=m,fs(m)};return y.useEffect(()=>{f.current&&fs(f.current)},[d]),!n||!r?null:i(Ne,{echarts:oe,option:d,style:{width:n,height:r},onEvents:h,onChartReady:g,notMerge:!0,theme:"merico-light"})}function Np({context:e,instance:t}){const n=et({vizManager:e.vizManager,instance:t}),{value:r}=W(e.instanceData,"config"),{variables:a}=e,o=y.useMemo(()=>x.defaults({},r,$r),[r]),l=e.data,{width:u,height:c}=e.viewport,{ref:d,height:f}=Ee.useElementSize(),{ref:h,height:g}=Ee.useElementSize(),m=y.useMemo(()=>{const{stats:{templates:w}}=o;return{top:Zt(w.top,a,l),bottom:Zt(w.bottom,a,l)}},[o,l]),C=Math.max(0,c-f-g);return p(s.Box,{sx:{width:u,height:c,overflow:"hidden"},children:[i(s.Text,{ref:d,align:"left",size:"xs",pl:"sm",sx:{display:gs(o.stats.templates.top)?"block":"none"},children:Object.values(m.top).map((w,_)=>i(y.Fragment,{children:w},_))}),i(Vp,{variables:a,width:u,height:C,data:l,conf:o,interactionManager:n}),i(s.Text,{ref:h,align:"left",size:"xs",pl:"sm",sx:{display:gs(o.stats.templates.bottom)?"block":"none"},children:Object.values(m.bottom).map((w,_)=>i(y.Fragment,{children:w},_))})]})}const Pr=y.forwardRef(({value:e,onChange:t},n)=>{const r=a=>o=>{t({...e,[a]:o})};return p(s.Stack,{children:[i(s.Divider,{variant:"dashed",label:"Scroll to Zoom",labelPosition:"center"}),p(s.Group,{children:[i(s.Box,{sx:{flexGrow:1},children:i(s.Switch,{label:"Enable on X Axis",checked:e.x_axis_scroll,onChange:a=>r("x_axis_scroll")(a.currentTarget.checked)})}),i(s.Box,{sx:{flexGrow:1},children:i(s.Switch,{label:"Enable on Y Axis",checked:e.y_axis_scroll,onChange:a=>r("y_axis_scroll")(a.currentTarget.checked)})})]}),i(s.Divider,{variant:"dashed",label:"Slider for Zooming",labelPosition:"center"}),p(s.Group,{children:[i(s.Box,{sx:{flexGrow:1},children:i(s.Switch,{label:"Slider for X Axis",checked:e.x_axis_slider,onChange:a=>r("x_axis_slider")(a.currentTarget.checked)})}),i(s.Tooltip,{label:"Not available for now, will overlap y-axis's label",children:i(s.Box,{sx:{flexGrow:1},children:i(s.Switch,{label:"Slider for Y Axis",disabled:!e.y_axis_slider,checked:e.y_axis_slider,onChange:a=>r("y_axis_slider")(a.currentTarget.checked)})})})]})]})}),qp=[{label:"Rectangle",value:"rectangle"}],Fp=[{label:"Horizontal",value:"horizontal"}];function Gp({control:e,index:t,remove:n,variableOptions:r}){return p(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`reference_areas.${t}.name`,control:e,render:({field:a})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...a})}),i(v.Controller,{name:`reference_areas.${t}.color`,control:e,render:({field:a})=>i(s.TextInput,{label:"Color",required:!0,sx:{flex:1},...a})})]}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`reference_areas.${t}.type`,control:e,render:({field:a})=>i(s.Select,{label:"Type",required:!0,data:qp,sx:{flex:1},...a})}),i(v.Controller,{name:`reference_areas.${t}.direction`,control:e,render:({field:a})=>i(s.Select,{label:"Direction",required:!0,data:Fp,sx:{flex:1},...a})})]}),i(s.Divider,{variant:"dashed",label:"Data",labelPosition:"center"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`reference_areas.${t}.y_keys.upper`,control:e,render:({field:a})=>i(s.Select,{label:"Upper Boundary",required:!0,data:r,sx:{flex:1},...a})}),i(v.Controller,{name:`reference_areas.${t}.y_keys.lower`,control:e,render:({field:a})=>i(s.Select,{label:"Lower Boundary",required:!0,data:r,sx:{flex:1},...a})})]}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),sx:{top:15,right:5},children:"Delete this Reference Area"})]},t)}function Wp({control:e,watch:t,variables:n}){const{fields:r,append:a,remove:o}=v.useFieldArray({control:e,name:"reference_areas"}),l=t("reference_areas"),u=r.map((f,h)=>({...f,...l[h]})),c=()=>a({name:"",color:"rgba(0,0,0,0.1)",type:"rectangle",direction:"horizontal",y_keys:{upper:"",lower:""}}),d=y.useMemo(()=>n.map(f=>({label:f.name,value:f.name})),[n]);return p(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"6px 0px 0px"}},children:[p(s.Tabs.List,{children:[u.map((f,h)=>i(s.Tabs.Tab,{value:h.toString(),children:h+1},h)),i(s.Tabs.Tab,{onClick:c,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),u.map((f,h)=>i(s.Tabs.Panel,{value:h.toString(),children:i(Gp,{control:e,index:h,remove:o,variableOptions:d})},h))]})}const jp=[{label:"solid",value:"solid"},{label:"dashed",value:"dashed"},{label:"dotted",value:"dotted"}],Rp=[{label:"Horizontal",value:"horizontal"},{label:"Vertical",value:"vertical"}];function Yp({control:e,index:t,remove:n,watch:r,variableOptions:a,yAxisOptions:o}){const l=r(`reference_lines.${t}.orientation`);return p(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:u})=>i(s.TextInput,{label:"Name",placeholder:"Average Reference Line",required:!0,sx:{flex:1},...u})}),i(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:u})=>i(s.Select,{label:"Value",required:!0,data:a,sx:{flex:1},...u})})]}),i(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:u})=>i(s.TextInput,{label:"Content Template",placeholder:"Average: ${avg}",sx:{flex:1},...u})}),p(s.Group,{grow:!0,children:[p(s.Stack,{children:[i(v.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:u})=>i(s.Select,{label:"Orientation",data:Rp,required:!0,sx:{flex:1},...u})}),l==="vertical"&&i(s.Text,{mt:-10,color:"dimmed",size:12,children:"Works only when xAxis values are numbers"})]}),l==="horizontal"&&i(v.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:u,onChange:c,...d}})=>i(s.Select,{label:"Y Axis",data:o,disabled:o.length===0,...d,value:(u==null?void 0:u.toString())??"",onChange:f=>{if(!f){c(0);return}c(Number(f))},sx:{flex:1}})})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed",label:"Style",labelPosition:"center"}),p(s.Group,{grow:!0,children:[i(v.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:u})=>i(s.Select,{label:"Line Type",data:jp,sx:{flexGrow:1},...u})}),i(v.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:u})=>i(s.NumberInput,{label:"Line Width",min:1,max:10,sx:{flexGrow:1},...u})})]}),p(s.Stack,{spacing:4,children:[i(s.Text,{size:"sm",children:"Color"}),i(v.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:u})=>i(Pe,{...u})})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed",label:"Behavior",labelPosition:"center"}),i(v.Controller,{name:`reference_lines.${t}.show_in_legend`,control:e,render:({field:u})=>i(s.Checkbox,{label:"Show in legend",checked:u.value,onChange:c=>u.onChange(c.currentTarget.checked)})}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),sx:{top:15,right:5},children:"Delete this Reference Line"})]},t)}function Qp({control:e,watch:t,variables:n}){const{fields:r,append:a,remove:o}=v.useFieldArray({control:e,name:"reference_lines"}),l=t("reference_lines"),u=r.map((g,m)=>({...g,...l[m]})),c=()=>{a({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,yAxisIndex:0})},d=y.useMemo(()=>n.map(g=>({label:g.name,value:g.name})),[n]),f=t("y_axes"),h=y.useMemo(()=>f.map(({name:g},m)=>({label:g,value:m.toString()})),[f]);return p(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px"}},children:[p(s.Tabs.List,{children:[u.map((g,m)=>i(s.Tabs.Tab,{value:m.toString(),children:m+1},m)),i(s.Tabs.Tab,{onClick:c,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),u.map((g,m)=>i(s.Tabs.Panel,{value:m.toString(),children:i(Yp,{control:e,index:m,remove:o,watch:t,variableOptions:d,yAxisOptions:h})},m))]})}const Kp=[{label:"Linear",value:"linear"},{label:"Exponential",value:"exponential"},{label:"Logarithmic",value:"logarithmic"},{label:"Polynomial",value:"polynomial"}],Up=[{label:"solid",value:"solid"},{label:"dashed",value:"dashed"},{label:"dotted",value:"dotted"}];function Xp({control:e,regressionItem:t,index:n,remove:r,yAxisOptions:a}){const o=t.transform.config.method;return p(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[p(s.Group,{grow:!0,children:[i(v.Controller,{name:`regressions.${n}.name`,control:e,render:({field:l})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...l})}),i(v.Controller,{name:`regressions.${n}.group_by_key`,control:e,render:({field:l})=>i(j,{label:"Split into multiple regression lines by this key...",clearable:!0,sx:{flex:1},...l})})]}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`regressions.${n}.y_axis_data_key`,control:e,render:({field:l})=>i(j,{label:"Value Field",required:!0,sx:{flex:1},...l})}),i(v.Controller,{name:`regressions.${n}.plot.yAxisIndex`,control:e,render:({field:{value:l,onChange:u,...c}})=>i(s.Select,{label:"Y Axis",data:a,disabled:a.length===0,...c,value:(l==null?void 0:l.toString())??"",onChange:d=>{if(!d){u(0);return}u(Number(d))},sx:{flex:1}})})]}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`regressions.${n}.transform.config.method`,control:e,render:({field:l})=>i(s.Select,{label:"Method",data:Kp,sx:{flex:1},...l})}),o==="polynomial"&&i(v.Controller,{name:`regressions.${n}.transform.config.order`,control:e,render:({field:l})=>i(s.NumberInput,{label:"Order",sx:{flex:1},...l})})]}),i(s.Divider,{mb:-15,variant:"dashed",label:"Line Style",labelPosition:"center"}),p(s.Group,{grow:!0,children:[i(v.Controller,{name:`regressions.${n}.plot.lineStyle.type`,control:e,render:({field:l})=>i(s.Select,{label:"Line Type",data:Up,sx:{flexGrow:1},...l})}),i(v.Controller,{name:`regressions.${n}.plot.lineStyle.width`,control:e,render:({field:l})=>i(s.NumberInput,{label:"Line Width",min:1,max:10,sx:{flexGrow:1},...l})})]}),p(s.Stack,{spacing:4,children:[i(s.Text,{size:"sm",children:"Color"}),i(v.Controller,{name:`regressions.${n}.plot.color`,control:e,render:({field:l})=>i(Pe,{...l})})]}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>r(n),sx:{top:15,right:5},children:"Delete this Regression Line"})]},n)}function Jp({control:e,watch:t}){const{fields:n,append:r,remove:a}=v.useFieldArray({control:e,name:"regressions"}),o=t("regressions"),l=n.map((f,h)=>({...f,...o[h]})),u=t("y_axes"),c=y.useMemo(()=>u.map(({name:f},h)=>({label:f,value:h.toString()})),[u]),d=()=>r({transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},group_by_key:"",name:"",y_axis_data_key:"",plot:{type:"line",yAxisIndex:0,color:"#666666",lineStyle:{type:"solid",width:1}}});return p(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[p(s.Tabs.List,{children:[l.map((f,h)=>i(s.Tabs.Tab,{value:h.toString(),children:h+1},h)),i(s.Tabs.Tab,{onClick:d,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),l.map((f,h)=>i(s.Tabs.Panel,{value:h.toString(),children:i(Xp,{regressionItem:f,control:e,index:h,remove:a,yAxisOptions:c},h)},h))]})}const Br={static:{type:"static",size:10},dynamic:{type:"dynamic",func_content:["function getSize({ rowData, params, variables }, { lodash, interpolate }) {"," // your code goes here"," // return 10","}"].join(`
|
|
117
|
-
`)}},Zp=[{label:"No gap between bars",value:"0%"},{label:"Bars overlapping on each other",value:"-100%"}];function Hp({control:e,index:t,seriesItem:n}){const r=!!n.barWidth.trim();return p(B,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`series.${t}.stack`,control:e,render:({field:a})=>i(s.TextInput,{label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1},...a})}),i(v.Controller,{name:`series.${t}.barGap`,control:e,render:({field:a})=>i(s.Select,{label:"Bar Gap",data:Zp,sx:{flexGrow:1},...a})})]}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`series.${t}.barMinWidth`,control:e,render:({field:a})=>i(s.TextInput,{label:"Bar Width(Min)",disabled:r,sx:{flexGrow:1},...a})}),i(v.Controller,{name:`series.${t}.barWidth`,control:e,render:({field:a})=>i(s.TextInput,{label:"Bar Width",sx:{flexGrow:1},...a})}),i(v.Controller,{name:`series.${t}.barMaxWidth`,control:e,render:({field:a})=>i(s.TextInput,{label:"Bar Width(Max)",disabled:r,sx:{flexGrow:1},...a})})]})]})}const eh=({value:e,onChange:t})=>{const n=r=>{r&&t(r)};return i(s.Box,{children:i(Ae,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},th=({value:e,onChange:t})=>{const[n,{setTrue:r,setFalse:a}]=X.useBoolean(),[o,l]=y.useState(e),u=()=>{a();const{type:h,func_content:g}=o,m={type:h,func_content:g};l(m),t(m)},c=()=>{a(),l(e)},d=h=>{l(g=>({...g,func_content:h}))},f=()=>{d(Br.dynamic.func_content)};return p(B,{children:[i(s.Box,{sx:{width:"50%"},children:i(s.Button,{variant:"filled",mt:24,onClick:r,sx:{flexGrow:0},children:"Setup"})}),i(s.Modal,{size:800,title:"Setup dynamic size",opened:n,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:n&&p(s.Stack,{children:[i(s.Divider,{mt:10,mb:-10,label:"Dynamic by a custom function",labelPosition:"center",variant:"dashed"}),i(eh,{value:o.func_content,onChange:d}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:f,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Rest"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:c,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:u,children:"OK"})]})]})]})})]})},nh=({value:e,onChange:t})=>e.type!=="dynamic"?null:i(th,{value:e,onChange:t}),rh=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=r=>{t({...e,size:r})};return i(B,{children:i(s.NumberInput,{defaultValue:18,placeholder:"1 ~ 100",label:" ",hideControls:!0,value:e.size,onChange:n})})},ih=[{label:"Static",value:"static"},{label:"Dynamic",value:"dynamic"}],ms=y.forwardRef(({label:e="Size",value:t,onChange:n},r)=>{const a=o=>{n({...Br[o]})};return p(s.SimpleGrid,{cols:2,children:[i(s.Select,{ref:r,label:e,data:ih,value:t.type,onChange:a,sx:{flexGrow:1}}),i(rh,{value:t,onChange:n}),i(nh,{value:t,onChange:n})]})}),ah=[{label:"off",value:"false"},{label:"start",value:"start"},{label:"middle",value:"middle"},{label:"end",value:"end"}],sh=[{label:"solid",value:"solid"},{label:"dashed",value:"dashed"},{label:"dotted",value:"dotted"}];function oh({control:e,index:t,seriesItem:n}){const r=n.showSymbol;return p(B,{children:[i(s.Divider,{mb:-15,variant:"dashed",label:"Line Settings",labelPosition:"center"}),p(s.Group,{grow:!0,children:[i(v.Controller,{name:`series.${t}.lineStyle.type`,control:e,render:({field:a})=>i(s.Select,{label:"Line Type",data:sh,sx:{flexGrow:1},...a})}),i(v.Controller,{name:`series.${t}.lineStyle.width`,control:e,render:({field:a})=>i(s.NumberInput,{label:"Line Width",min:1,max:10,sx:{flexGrow:1},...a})})]}),p(s.Group,{grow:!0,align:"center",children:[i(v.Controller,{name:`series.${t}.step`,control:e,render:({field:a})=>i(s.Select,{label:"Step",data:ah,sx:{flexGrow:1,maxWidth:"48%"},...a,value:String(a.value),onChange:o=>{const l=o==="false"?!1:o;a.onChange(l)}})}),p(s.Stack,{children:[i(v.Controller,{name:`series.${t}.smooth`,control:e,render:({field:a})=>i(s.Box,{sx:{flexGrow:1},children:i(s.Switch,{label:"Smooth Line",checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})})}),i(v.Controller,{name:`series.${t}.display_name_on_line`,control:e,render:({field:a})=>i(s.Box,{sx:{flexGrow:1},children:i(s.Switch,{label:"Display Name on Line",checked:a.value??!1,onChange:o=>a.onChange(o.currentTarget.checked)})})})]})]}),p(s.Stack,{children:[i(v.Controller,{name:`series.${t}.showSymbol`,control:e,render:({field:a})=>i(s.Box,{mt:10,mb:-10,sx:{flexGrow:1},children:i(s.Switch,{label:"Show Symbol on Line",checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})})}),r&&i(v.Controller,{name:`series.${t}.symbolSize`,control:e,render:({field:a})=>i(ms,{label:"Symbol Size",...a})})]})]})}function lh({control:e,index:t}){return i(v.Controller,{name:`series.${t}.symbolSize`,control:e,render:({field:n})=>i(ms,{label:"Size",...n})})}const uh=[{label:"off",value:""},{label:"top",value:"top"},{label:"left",value:"left"},{label:"right",value:"right"},{label:"bottom",value:"bottom"},{label:"inside",value:"inside"},{label:"insideLeft",value:"insideLeft"},{label:"insideRight",value:"insideRight"},{label:"insideTop",value:"insideTop"},{label:"insideBottom",value:"insideBottom"},{label:"insideTopLeft",value:"insideTopLeft"},{label:"insideBottomLeft",value:"insideBottomLeft"},{label:"insideTopRight",value:"insideTopRight"},{label:"insideBottomRight",value:"insideBottomRight"}];function ch({control:e,index:t,remove:n,seriesItem:r,yAxisOptions:a}){const o=r.type;return p(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[i(s.Stack,{children:i(v.Controller,{name:`series.${t}.type`,control:e,render:({field:l})=>i(s.SegmentedControl,{data:[{label:"Line",value:"line"},{label:"Bar",value:"bar"},{label:"Scatter",value:"scatter"}],...l})})}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`series.${t}.name`,control:e,render:({field:l})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...l})}),i(v.Controller,{name:`series.${t}.yAxisIndex`,control:e,render:({field:{value:l,onChange:u,...c}})=>i(s.Select,{label:"Y Axis",data:a,disabled:a.length===0,...c,value:(l==null?void 0:l.toString())??"",onChange:d=>{if(!d){u(0);return}u(Number(d))},sx:{flex:1}})})]}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`series.${t}.y_axis_data_key`,control:e,render:({field:l})=>i(j,{label:"Value Field",required:!0,sx:{flex:1},...l})}),i(v.Controller,{name:`series.${t}.aggregation_on_value`,control:e,render:({field:l})=>i(_n,{label:"Aggregation on Value",value:l.value??Bt,onChange:l.onChange,pt:0})})]}),i(s.Group,{grow:!0,children:i(v.Controller,{name:`series.${t}.group_by_key`,control:e,render:({field:l})=>i(j,{label:"Split into multiple series by this key...",clearable:!0,sx:{flex:1},...l})})}),o==="line"&&i(oh,{index:t,control:e,seriesItem:r}),o==="bar"&&i(Hp,{index:t,control:e,seriesItem:r}),o==="scatter"&&i(lh,{index:t,control:e}),i(s.Divider,{mb:-10,mt:10,variant:"dashed",label:"Style",labelPosition:"center"}),i(v.Controller,{name:`series.${t}.label_position`,control:e,render:({field:l})=>i(s.Select,{label:"Label Position",data:uh,...l})}),p(s.Stack,{spacing:4,children:[i(s.Text,{size:"sm",children:"Color"}),i(v.Controller,{name:`series.${t}.color`,control:e,render:({field:l})=>i(Pe,{...l})})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed",label:"Behavior",labelPosition:"center"}),i(v.Controller,{name:`series.${t}.hide_in_legend`,control:e,render:({field:l})=>i(s.Checkbox,{label:"Hide in legend",checked:l.value,onChange:u=>l.onChange(u.currentTarget.checked)})}),i(s.Divider,{mb:-10,mt:10,variant:"dashed"}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),sx:{top:15,right:5},children:"Delete this Series"})]},t)}function dh({control:e,watch:t}){const{fields:n,append:r,remove:a}=v.useFieldArray({control:e,name:"series"}),o=t("series"),l=n.map((f,h)=>({...f,...o[h]})),u=()=>{const f={type:"bar",name:Ee.randomId(),showSymbol:!1,symbolSize:Br.static,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",display_name_on_line:!1,stack:"",color:"#000",step:!1,smooth:!1,barMinWidth:"1",barWidth:"10%",barMaxWidth:"10",barGap:"0%",lineStyle:{type:"solid",width:1},hide_in_legend:!1,group_by_key:""};r(f)},c=t("y_axes"),d=y.useMemo(()=>c.map(({name:f},h)=>({label:f,value:h.toString()})),[c]);return p(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[p(s.Tabs.List,{children:[l.map((f,h)=>i(s.Tabs.Tab,{value:h.toString(),children:h+1},f.id)),i(s.Tabs.Tab,{onClick:u,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),l.map((f,h)=>i(s.Tabs.Panel,{value:h.toString(),children:i(ch,{control:e,index:h,remove:a,seriesItem:f,yAxisOptions:d},f.id)},f.id))]})}function ph({control:e,watch:t}){return t("stats"),i(s.Stack,{children:p(s.Stack,{spacing:0,children:[i(v.Controller,{name:"stats.templates.top",control:e,render:({field:n})=>i(Jt,{label:"Template for stats above the chart",py:"md",sx:{flexGrow:1},...n})}),i(v.Controller,{name:"stats.templates.bottom",control:e,render:({field:n})=>i(Jt,{label:"Template for stats under the chart",py:"md",sx:{flexGrow:1},...n})})]})})}const hh=()=>p(s.Group,{sx:{display:"inline-flex"},spacing:6,mr:14,children:[i(s.Text,{children:"X Axis Data Type"}),p(s.HoverCard,{width:340,shadow:"md",position:"top",children:[i(s.HoverCard.Target,{children:i(s.ActionIcon,{size:"xs",sx:{transform:"none !important"},children:i($.IconInfoCircle,{})})}),i(s.HoverCard.Dropdown,{children:p(s.Text,{size:"sm",children:["Click",i(s.Anchor,{href:"https://echarts.apache.org/en/option.html#xAxis.type",target:"_blank",mx:4,children:"here"}),"to learn more about these options"]})})]})]}),fh=[{label:"Value",value:"value"},{label:"Category",value:"category"},{label:"Time",value:"time"},{label:"Log",value:"log"}];function gh({control:e,watch:t}){return t(["x_axis_data_key","x_axis_name","x_axis"]),p(s.Stack,{children:[i(v.Controller,{name:"x_axis_name",control:e,render:({field:n})=>i(s.TextInput,{label:"X Axis Name",sx:{flex:1},...n})}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis_data_key",control:e,render:({field:n})=>i(j,{label:"X Axis Data Field",required:!0,sx:{flex:1},...n})}),i(v.Controller,{name:"x_axis.type",control:e,render:({field:n})=>i(s.Select,{label:i(hh,{}),required:!0,data:fh,sx:{flex:1},...n})})]}),i(s.Divider,{mb:-15,label:"Tick Label",labelPosition:"center"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:n})=>i(s.NumberInput,{label:"Rotate",hideControls:!0,min:-90,max:90,rightSection:i(s.Text,{color:"dimmed",children:"degree"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),i(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>i(Mn,{...n})})]}),i(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:n})=>i(mt,{...n})})]})}const mh=[{label:"left",value:"left"},{label:"center",value:"center"},{label:"right",value:"right"}],yh=[{label:"left",value:"left"},{label:"right",value:"right"}];function bh({control:e,index:t,remove:n}){return p(s.Stack,{my:0,p:"0",sx:{position:"relative"},children:[i(s.Divider,{mb:-15,mt:15,variant:"dashed",label:"Name",labelPosition:"center"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:r})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...r})}),i(v.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:r})=>i(s.Select,{label:"Align",required:!0,data:mh,sx:{flex:1},...r})})]}),i(s.Divider,{mb:-15,variant:"dashed",label:"Layout",labelPosition:"center"}),i(s.Group,{grow:!0,noWrap:!0,children:i(v.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:r})=>i(s.Select,{label:"Position",required:!0,data:yh,sx:{flex:1},...r})})}),p(s.Stack,{children:[i(s.Divider,{mb:-15,variant:"dashed",label:"Label Format",labelPosition:"center"}),i(v.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:r})=>i(Re,{...r})})]}),p(s.Stack,{children:[i(s.Divider,{mb:-15,variant:"dashed",label:"Value Range",labelPosition:"center"}),p(s.Group,{grow:!0,children:[i(v.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:r})=>i(s.TextInput,{label:"Min",...r})}),i(v.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:r})=>i(s.TextInput,{label:"Max",...r})})]})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed",label:"Behavior",labelPosition:"center"}),i(v.Controller,{name:`y_axes.${t}.show`,control:e,render:({field:r})=>i(s.Checkbox,{label:"Visible",checked:r.value,onChange:a=>r.onChange(a.currentTarget.checked)})}),i(s.Button,{mt:20,leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),disabled:t===0,children:"Delete this YAxis"})]})}function vh({control:e,watch:t}){const{fields:n,append:r,remove:a}=v.useFieldArray({control:e,name:"y_axes"}),o=t("y_axes"),l=n.map((c,d)=>({...c,...o[d]})),u=()=>r({name:"",position:"left",nameAlignment:"left",label_formatter:$e,min:"",max:"",show:!0});return p(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px"}},children:[p(s.Tabs.List,{children:[l.map((c,d)=>i(s.Tabs.Tab,{value:d.toString(),children:d+1},d)),i(s.Tabs.Tab,{onClick:u,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),l.map((c,d)=>i(s.Tabs.Panel,{value:d.toString(),children:i(bh,{control:e,index:d,remove:a})},d))]})}function xh({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),{variables:r}=e,a=y.useMemo(()=>x.defaultsDeep({},t,$r),[t]),{control:o,handleSubmit:l,watch:u,getValues:c,reset:d}=v.useForm({defaultValues:a});y.useEffect(()=>{d(a)},[a]);const f=c(),h=y.useMemo(()=>!x.isEqual(f,a),[f,a]);return u(["dataZoom"]),i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:l(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"X Axis",children:"X Axis"}),i(s.Tabs.Tab,{value:"Y Axes",children:"Y Axes"}),i(s.Tabs.Tab,{value:"Series",children:"Series"}),i(s.Tabs.Tab,{value:"Regression Lines",children:"Regression Lines"}),i(s.Tabs.Tab,{value:"Stats",children:"Stats"}),i(s.Tabs.Tab,{value:"Reference Lines",children:"Reference Lines"}),i(s.Tabs.Tab,{value:"Reference Areas",children:"Reference Areas"}),i(s.Tabs.Tab,{value:"Zooming",children:"Zooming"})]}),i(s.Tabs.Panel,{value:"X Axis",children:i(gh,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Y Axes",children:i(vh,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Series",children:i(dh,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Regression Lines",children:i(Jp,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Stats",children:i(ph,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Reference Lines",children:i(Qp,{variables:r,control:o,watch:u})}),i(s.Tabs.Panel,{value:"Reference Areas",children:i(Wp,{variables:r,control:o,watch:u})}),i(s.Tabs.Panel,{value:"Zooming",children:i(v.Controller,{name:"dataZoom",control:o,render:({field:g})=>i(Pr,{...g})})})]})]})})}function wh(e){const t=x.cloneDeep(x.omit(e,"variables"));return t.stats=x.omit(t.stats,"variables"),t}function Ch(e){const{rotate:t,formatter:n=rt}=e.x_axis.axisLabel;return{...e,x_axis:{...e.x_axis,axisLabel:{rotate:t,formatter:n}}}}function Sh(e){const{dataZoom:t=Vt,...n}=e;return{...n,dataZoom:t}}function _h(e){const t={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return x.defaultsDeep(t,e)}function kh(e){const t=e.reference_lines.map(n=>{const{lineStyle:r={type:"dashed",width:1,color:ot.random().css()},show_in_legend:a=!1}=n;return{...n,lineStyle:r,show_in_legend:a}});return{...e,reference_lines:t}}function Th(e){const t=e.reference_lines.map(n=>{const{yAxisIndex:r=0}=n;return{...n,yAxisIndex:r}});return{...e,reference_lines:t}}function Dh(e){const t=e.series.map(n=>{const{aggregation_on_group:r=Bt}=n;return{...n,aggregation_on_group:r}});return{...e,series:t}}function Mh(e){const t=e.series.map(n=>{const{aggregation_on_value:r=Bt}=n;return{...n,aggregation_on_value:r}});return{...e,series:t}}function Ih(e){delete e.config;const{x_axis:t,tooltip:n}=e.x_axis.axisLabel.overflow,r={x_axis:{axisLabel:{overflow:{on_axis:t,in_tooltip:n}}}};return x.defaultsDeep(r,e)}function Eh(e){const{series:t,...n}=e;return{...n,series:t.map(r=>{const{barMinWidth:a,barWidth:o,barMaxWidth:l}=r;return a?{...r,barMinWidth:a,barWidth:"",barMaxWidth:l??o}:{...r,barMinWidth:"",barWidth:o,barMaxWidth:""}})}}function Ah(e){const{y_axes:t,...n}=e;return{...n,y_axes:t.map(r=>{const{min:a="",max:o=""}=r;return{...r,min:a,max:o}})}}function zh(e){const{y_axes:t,...n}=e;return{...n,y_axes:t.map(r=>{const{nameAlignment:a="left"}=r;return{...r,nameAlignment:a}})}}function $h(e){const{y_axes:t,...n}=e;return{...n,y_axes:t.map(r=>{const{show:a=!0}=r;return{...r,show:a}})}}function Oh(e){const{regressions:t,...n}=e;return{...n,regressions:t.map(r=>{const{group_by_key:a=""}=r;return{...r,group_by_key:a}})}}function Lh(e){const{series:t,y_axes:n,...r}=e;return{...r,series:t.map(a=>{const{hide_in_legend:o=!1,aggregation_on_value:l=Bt}=a;return{...a,hide_in_legend:o,aggregation_on_value:l}}),y_axes:n.map(a=>{const{min:o="",max:l="",show:u=!0}=a;return{...a,min:o,max:l,show:u}})}}function Ph(e){const{type:t="category",...n}=e.x_axis;return{...e,x_axis:{...n,type:t}}}function Bh(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis_data_key:a,series:o,regressions:l,...u}=e;return{...u,x_axis_data_key:r(a),series:o.map(c=>({...c,y_axis_data_key:r(c.y_axis_data_key),group_by_key:r(c.group_by_key)})),regressions:l.map(c=>({...c,y_axis_data_key:r(c.y_axis_data_key),group_by_key:r(c.group_by_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class Vh extends be{constructor(){super(...arguments);q(this,"VERSION",18)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,{panelModel:r})=>{const{config:a}=n;return(a.variables||[]).forEach(u=>{r.variables.find(c=>c.name===u.name)||r.addVariable(u)}),(x.get(a,"stats.variables")||[]).forEach(u=>{r.variables.find(c=>c.name===u.name)||r.addVariable(u)}),{...n,version:2,config:wh(a)}}),this.version(3,n=>({...n,version:3,config:Ch(n.config)})),this.version(4,n=>({...n,version:4,config:Sh(n.config)})),this.version(5,n=>({...n,version:5,config:_h(n.config)})),this.version(6,n=>({...n,version:6,config:kh(n.config)})),this.version(7,n=>({...n,version:7,config:Th(n.config)})),this.version(8,n=>({...n,version:8,config:Dh(n.config)})),this.version(9,n=>({...n,version:9,config:Mh(n.config)})),this.version(10,n=>({...n,version:10,config:Ih(n.config)})),this.version(11,n=>({...n,version:11,config:Eh(n.config)})),this.version(12,n=>({...n,version:12,config:Ah(n.config)})),this.version(13,n=>({...n,version:13,config:zh(n.config)})),this.version(14,n=>({...n,version:14,config:$h(n.config)})),this.version(15,n=>({...n,version:15,config:Oh(n.config)})),this.version(16,n=>({...n,version:16,config:Lh(n.config)})),this.version(17,n=>({...n,version:17,config:Ph(n.config)})),this.version(18,(n,r)=>({...n,version:18,config:Bh(n.config,r)}))}}const Nh={displayName:"Cartesian Chart",displayGroup:"ECharts-based charts",migrator:new Vh,name:"cartesian",viewRender:Np,configRender:xh,createConfig(){return{version:18,config:x.cloneDeep($r)}},triggers:[zr]};function qh(e){if(e.enable_value)return e.value}function Fh(e){if(e.enable_value)return e.value}function Gh(e){const t=e.axisLabel.overflow.on_axis.width,n=e.axisLabel.position,r={top:5,left:5,right:5,bottom:5};return e.orient==="vertical"&&x.get(r,n)&&n===e.funnelAlign&&x.set(r,n,t),r}function Wh(e,t){return e.series.map(n=>{const{level_name_data_key:r,level_value_data_key:a,axisLabel:o,min:l,max:u,funnelAlign:c,orient:d,...f}=n;if(!r||!a)return{};const h=V(r),g=V(a),m=t[h.queryID].map(w=>({name:w[h.columnKey],value:w[g.columnKey]})),C=ct(o.overflow.on_axis);return{type:"funnel",...Gh(n),min:qh(l),max:Fh(u),minSize:l.size,maxSize:u.size,...f,label:{show:!0,position:o.position,...C},orient:d,funnelAlign:d==="horizontal"?"center":c,data:m}})}function jh({conf:e,params:t,max:n}){const{name:r,value:a}=t.data,o=H(a/n).format({output:"percent",mantissa:2,trimMantissa:!0});return[{label:`${t.marker} ${r}`,value:`${a} (${o})`,style:{label:"",value:""}}]}function Rh(e,t){var o;const n=V(e.series[0].level_name_data_key),r=V(e.series[0].level_value_data_key),a=(o=x.maxBy(t[n.queryID],r.columnKey))==null?void 0:o[r.columnKey];return l=>{const c=jh({conf:e,params:l,max:a}).map(f=>`
|
|
117
|
+
`)}},Zp=[{label:"No gap between bars",value:"0%"},{label:"Bars overlapping on each other",value:"-100%"}];function Hp({control:e,index:t,seriesItem:n}){const r=!!n.barWidth.trim();return p(B,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`series.${t}.stack`,control:e,render:({field:a})=>i(s.TextInput,{label:"Stack",placeholder:"Stack bars by this ID",sx:{flexGrow:1},...a})}),i(v.Controller,{name:`series.${t}.barGap`,control:e,render:({field:a})=>i(s.Select,{label:"Bar Gap",data:Zp,sx:{flexGrow:1},...a})})]}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`series.${t}.barMinWidth`,control:e,render:({field:a})=>i(s.TextInput,{label:"Bar Width(Min)",disabled:r,sx:{flexGrow:1},...a})}),i(v.Controller,{name:`series.${t}.barWidth`,control:e,render:({field:a})=>i(s.TextInput,{label:"Bar Width",sx:{flexGrow:1},...a})}),i(v.Controller,{name:`series.${t}.barMaxWidth`,control:e,render:({field:a})=>i(s.TextInput,{label:"Bar Width(Max)",disabled:r,sx:{flexGrow:1},...a})})]})]})}const eh=({value:e,onChange:t})=>{const n=r=>{r&&t(r)};return i(s.Box,{children:i(Ae,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},th=({value:e,onChange:t})=>{const[n,{setTrue:r,setFalse:a}]=X.useBoolean(),[o,l]=y.useState(e),u=()=>{a();const{type:h,func_content:g}=o,m={type:h,func_content:g};l(m),t(m)},c=()=>{a(),l(e)},d=h=>{l(g=>({...g,func_content:h}))},f=()=>{d(Br.dynamic.func_content)};return p(B,{children:[i(s.Box,{sx:{width:"50%"},children:i(s.Button,{variant:"filled",mt:24,onClick:r,sx:{flexGrow:0},children:"Setup"})}),i(s.Modal,{size:800,title:"Setup dynamic size",opened:n,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:n&&p(s.Stack,{children:[i(s.Divider,{mt:10,mb:-10,label:"Dynamic by a custom function",labelPosition:"center",variant:"dashed"}),i(eh,{value:o.func_content,onChange:d}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:f,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Reset"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:c,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:u,children:"OK"})]})]})]})})]})},nh=({value:e,onChange:t})=>e.type!=="dynamic"?null:i(th,{value:e,onChange:t}),rh=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=r=>{t({...e,size:r})};return i(B,{children:i(s.NumberInput,{defaultValue:18,placeholder:"1 ~ 100",label:" ",hideControls:!0,value:e.size,onChange:n})})},ih=[{label:"Static",value:"static"},{label:"Dynamic",value:"dynamic"}],ms=y.forwardRef(({label:e="Size",value:t,onChange:n},r)=>{const a=o=>{n({...Br[o]})};return p(s.SimpleGrid,{cols:2,children:[i(s.Select,{ref:r,label:e,data:ih,value:t.type,onChange:a,sx:{flexGrow:1}}),i(rh,{value:t,onChange:n}),i(nh,{value:t,onChange:n})]})}),ah=[{label:"off",value:"false"},{label:"start",value:"start"},{label:"middle",value:"middle"},{label:"end",value:"end"}],sh=[{label:"solid",value:"solid"},{label:"dashed",value:"dashed"},{label:"dotted",value:"dotted"}];function oh({control:e,index:t,seriesItem:n}){const r=n.showSymbol;return p(B,{children:[i(s.Divider,{mb:-15,variant:"dashed",label:"Line Settings",labelPosition:"center"}),p(s.Group,{grow:!0,children:[i(v.Controller,{name:`series.${t}.lineStyle.type`,control:e,render:({field:a})=>i(s.Select,{label:"Line Type",data:sh,sx:{flexGrow:1},...a})}),i(v.Controller,{name:`series.${t}.lineStyle.width`,control:e,render:({field:a})=>i(s.NumberInput,{label:"Line Width",min:1,max:10,sx:{flexGrow:1},...a})})]}),p(s.Group,{grow:!0,align:"center",children:[i(v.Controller,{name:`series.${t}.step`,control:e,render:({field:a})=>i(s.Select,{label:"Step",data:ah,sx:{flexGrow:1,maxWidth:"48%"},...a,value:String(a.value),onChange:o=>{const l=o==="false"?!1:o;a.onChange(l)}})}),p(s.Stack,{children:[i(v.Controller,{name:`series.${t}.smooth`,control:e,render:({field:a})=>i(s.Box,{sx:{flexGrow:1},children:i(s.Switch,{label:"Smooth Line",checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})})}),i(v.Controller,{name:`series.${t}.display_name_on_line`,control:e,render:({field:a})=>i(s.Box,{sx:{flexGrow:1},children:i(s.Switch,{label:"Display Name on Line",checked:a.value??!1,onChange:o=>a.onChange(o.currentTarget.checked)})})})]})]}),p(s.Stack,{children:[i(v.Controller,{name:`series.${t}.showSymbol`,control:e,render:({field:a})=>i(s.Box,{mt:10,mb:-10,sx:{flexGrow:1},children:i(s.Switch,{label:"Show Symbol on Line",checked:a.value,onChange:o=>a.onChange(o.currentTarget.checked)})})}),r&&i(v.Controller,{name:`series.${t}.symbolSize`,control:e,render:({field:a})=>i(ms,{label:"Symbol Size",...a})})]})]})}function lh({control:e,index:t}){return i(v.Controller,{name:`series.${t}.symbolSize`,control:e,render:({field:n})=>i(ms,{label:"Size",...n})})}const uh=[{label:"off",value:""},{label:"top",value:"top"},{label:"left",value:"left"},{label:"right",value:"right"},{label:"bottom",value:"bottom"},{label:"inside",value:"inside"},{label:"insideLeft",value:"insideLeft"},{label:"insideRight",value:"insideRight"},{label:"insideTop",value:"insideTop"},{label:"insideBottom",value:"insideBottom"},{label:"insideTopLeft",value:"insideTopLeft"},{label:"insideBottomLeft",value:"insideBottomLeft"},{label:"insideTopRight",value:"insideTopRight"},{label:"insideBottomRight",value:"insideBottomRight"}];function ch({control:e,index:t,remove:n,seriesItem:r,yAxisOptions:a}){const o=r.type;return p(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[i(s.Stack,{children:i(v.Controller,{name:`series.${t}.type`,control:e,render:({field:l})=>i(s.SegmentedControl,{data:[{label:"Line",value:"line"},{label:"Bar",value:"bar"},{label:"Scatter",value:"scatter"}],...l})})}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`series.${t}.name`,control:e,render:({field:l})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...l})}),i(v.Controller,{name:`series.${t}.yAxisIndex`,control:e,render:({field:{value:l,onChange:u,...c}})=>i(s.Select,{label:"Y Axis",data:a,disabled:a.length===0,...c,value:(l==null?void 0:l.toString())??"",onChange:d=>{if(!d){u(0);return}u(Number(d))},sx:{flex:1}})})]}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`series.${t}.y_axis_data_key`,control:e,render:({field:l})=>i(j,{label:"Value Field",required:!0,sx:{flex:1},...l})}),i(v.Controller,{name:`series.${t}.aggregation_on_value`,control:e,render:({field:l})=>i(_n,{label:"Aggregation on Value",value:l.value??Bt,onChange:l.onChange,pt:0})})]}),i(s.Group,{grow:!0,children:i(v.Controller,{name:`series.${t}.group_by_key`,control:e,render:({field:l})=>i(j,{label:"Split into multiple series by this key...",clearable:!0,sx:{flex:1},...l})})}),o==="line"&&i(oh,{index:t,control:e,seriesItem:r}),o==="bar"&&i(Hp,{index:t,control:e,seriesItem:r}),o==="scatter"&&i(lh,{index:t,control:e}),i(s.Divider,{mb:-10,mt:10,variant:"dashed",label:"Style",labelPosition:"center"}),i(v.Controller,{name:`series.${t}.label_position`,control:e,render:({field:l})=>i(s.Select,{label:"Label Position",data:uh,...l})}),p(s.Stack,{spacing:4,children:[i(s.Text,{size:"sm",children:"Color"}),i(v.Controller,{name:`series.${t}.color`,control:e,render:({field:l})=>i(Pe,{...l})})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed",label:"Behavior",labelPosition:"center"}),i(v.Controller,{name:`series.${t}.hide_in_legend`,control:e,render:({field:l})=>i(s.Checkbox,{label:"Hide in legend",checked:l.value,onChange:u=>l.onChange(u.currentTarget.checked)})}),i(s.Divider,{mb:-10,mt:10,variant:"dashed"}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),sx:{top:15,right:5},children:"Delete this Series"})]},t)}function dh({control:e,watch:t}){const{fields:n,append:r,remove:a}=v.useFieldArray({control:e,name:"series"}),o=t("series"),l=n.map((f,h)=>({...f,...o[h]})),u=()=>{const f={type:"bar",name:Ee.randomId(),showSymbol:!1,symbolSize:Br.static,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",display_name_on_line:!1,stack:"",color:"#000",step:!1,smooth:!1,barMinWidth:"1",barWidth:"10%",barMaxWidth:"10",barGap:"0%",lineStyle:{type:"solid",width:1},hide_in_legend:!1,group_by_key:""};r(f)},c=t("y_axes"),d=y.useMemo(()=>c.map(({name:f},h)=>({label:f,value:h.toString()})),[c]);return p(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[p(s.Tabs.List,{children:[l.map((f,h)=>i(s.Tabs.Tab,{value:h.toString(),children:h+1},f.id)),i(s.Tabs.Tab,{onClick:u,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),l.map((f,h)=>i(s.Tabs.Panel,{value:h.toString(),children:i(ch,{control:e,index:h,remove:a,seriesItem:f,yAxisOptions:d},f.id)},f.id))]})}function ph({control:e,watch:t}){return t("stats"),i(s.Stack,{children:p(s.Stack,{spacing:0,children:[i(v.Controller,{name:"stats.templates.top",control:e,render:({field:n})=>i(Jt,{label:"Template for stats above the chart",py:"md",sx:{flexGrow:1},...n})}),i(v.Controller,{name:"stats.templates.bottom",control:e,render:({field:n})=>i(Jt,{label:"Template for stats under the chart",py:"md",sx:{flexGrow:1},...n})})]})})}const hh=()=>p(s.Group,{sx:{display:"inline-flex"},spacing:6,mr:14,children:[i(s.Text,{children:"X Axis Data Type"}),p(s.HoverCard,{width:340,shadow:"md",position:"top",children:[i(s.HoverCard.Target,{children:i(s.ActionIcon,{size:"xs",sx:{transform:"none !important"},children:i($.IconInfoCircle,{})})}),i(s.HoverCard.Dropdown,{children:p(s.Text,{size:"sm",children:["Click",i(s.Anchor,{href:"https://echarts.apache.org/en/option.html#xAxis.type",target:"_blank",mx:4,children:"here"}),"to learn more about these options"]})})]})]}),fh=[{label:"Value",value:"value"},{label:"Category",value:"category"},{label:"Time",value:"time"},{label:"Log",value:"log"}];function gh({control:e,watch:t}){return t(["x_axis_data_key","x_axis_name","x_axis"]),p(s.Stack,{children:[i(v.Controller,{name:"x_axis_name",control:e,render:({field:n})=>i(s.TextInput,{label:"X Axis Name",sx:{flex:1},...n})}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis_data_key",control:e,render:({field:n})=>i(j,{label:"X Axis Data Field",required:!0,sx:{flex:1},...n})}),i(v.Controller,{name:"x_axis.type",control:e,render:({field:n})=>i(s.Select,{label:i(hh,{}),required:!0,data:fh,sx:{flex:1},...n})})]}),i(s.Divider,{mb:-15,label:"Tick Label",labelPosition:"center"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:n})=>i(s.NumberInput,{label:"Rotate",hideControls:!0,min:-90,max:90,rightSection:i(s.Text,{color:"dimmed",children:"degree"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),i(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>i(Mn,{...n})})]}),i(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:n})=>i(mt,{...n})})]})}const mh=[{label:"left",value:"left"},{label:"center",value:"center"},{label:"right",value:"right"}],yh=[{label:"left",value:"left"},{label:"right",value:"right"}];function bh({control:e,index:t,remove:n}){return p(s.Stack,{my:0,p:"0",sx:{position:"relative"},children:[i(s.Divider,{mb:-15,mt:15,variant:"dashed",label:"Name",labelPosition:"center"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:r})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...r})}),i(v.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:r})=>i(s.Select,{label:"Align",required:!0,data:mh,sx:{flex:1},...r})})]}),i(s.Divider,{mb:-15,variant:"dashed",label:"Layout",labelPosition:"center"}),i(s.Group,{grow:!0,noWrap:!0,children:i(v.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:r})=>i(s.Select,{label:"Position",required:!0,data:yh,sx:{flex:1},...r})})}),p(s.Stack,{children:[i(s.Divider,{mb:-15,variant:"dashed",label:"Label Format",labelPosition:"center"}),i(v.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:r})=>i(Re,{...r})})]}),p(s.Stack,{children:[i(s.Divider,{mb:-15,variant:"dashed",label:"Value Range",labelPosition:"center"}),p(s.Group,{grow:!0,children:[i(v.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:r})=>i(s.TextInput,{label:"Min",...r})}),i(v.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:r})=>i(s.TextInput,{label:"Max",...r})})]})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed",label:"Behavior",labelPosition:"center"}),i(v.Controller,{name:`y_axes.${t}.show`,control:e,render:({field:r})=>i(s.Checkbox,{label:"Visible",checked:r.value,onChange:a=>r.onChange(a.currentTarget.checked)})}),i(s.Button,{mt:20,leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),disabled:t===0,children:"Delete this YAxis"})]})}function vh({control:e,watch:t}){const{fields:n,append:r,remove:a}=v.useFieldArray({control:e,name:"y_axes"}),o=t("y_axes"),l=n.map((c,d)=>({...c,...o[d]})),u=()=>r({name:"",position:"left",nameAlignment:"left",label_formatter:$e,min:"",max:"",show:!0});return p(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px"}},children:[p(s.Tabs.List,{children:[l.map((c,d)=>i(s.Tabs.Tab,{value:d.toString(),children:d+1},d)),i(s.Tabs.Tab,{onClick:u,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),l.map((c,d)=>i(s.Tabs.Panel,{value:d.toString(),children:i(bh,{control:e,index:d,remove:a})},d))]})}function xh({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),{variables:r}=e,a=y.useMemo(()=>x.defaultsDeep({},t,$r),[t]),{control:o,handleSubmit:l,watch:u,getValues:c,reset:d}=v.useForm({defaultValues:a});y.useEffect(()=>{d(a)},[a]);const f=c(),h=y.useMemo(()=>!x.isEqual(f,a),[f,a]);return u(["dataZoom"]),i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:l(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"X Axis",children:"X Axis"}),i(s.Tabs.Tab,{value:"Y Axes",children:"Y Axes"}),i(s.Tabs.Tab,{value:"Series",children:"Series"}),i(s.Tabs.Tab,{value:"Regression Lines",children:"Regression Lines"}),i(s.Tabs.Tab,{value:"Stats",children:"Stats"}),i(s.Tabs.Tab,{value:"Reference Lines",children:"Reference Lines"}),i(s.Tabs.Tab,{value:"Reference Areas",children:"Reference Areas"}),i(s.Tabs.Tab,{value:"Zooming",children:"Zooming"})]}),i(s.Tabs.Panel,{value:"X Axis",children:i(gh,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Y Axes",children:i(vh,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Series",children:i(dh,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Regression Lines",children:i(Jp,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Stats",children:i(ph,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Reference Lines",children:i(Qp,{variables:r,control:o,watch:u})}),i(s.Tabs.Panel,{value:"Reference Areas",children:i(Wp,{variables:r,control:o,watch:u})}),i(s.Tabs.Panel,{value:"Zooming",children:i(v.Controller,{name:"dataZoom",control:o,render:({field:g})=>i(Pr,{...g})})})]})]})})}function wh(e){const t=x.cloneDeep(x.omit(e,"variables"));return t.stats=x.omit(t.stats,"variables"),t}function Ch(e){const{rotate:t,formatter:n=rt}=e.x_axis.axisLabel;return{...e,x_axis:{...e.x_axis,axisLabel:{rotate:t,formatter:n}}}}function Sh(e){const{dataZoom:t=Vt,...n}=e;return{...n,dataZoom:t}}function _h(e){const t={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return x.defaultsDeep(t,e)}function kh(e){const t=e.reference_lines.map(n=>{const{lineStyle:r={type:"dashed",width:1,color:ot.random().css()},show_in_legend:a=!1}=n;return{...n,lineStyle:r,show_in_legend:a}});return{...e,reference_lines:t}}function Th(e){const t=e.reference_lines.map(n=>{const{yAxisIndex:r=0}=n;return{...n,yAxisIndex:r}});return{...e,reference_lines:t}}function Dh(e){const t=e.series.map(n=>{const{aggregation_on_group:r=Bt}=n;return{...n,aggregation_on_group:r}});return{...e,series:t}}function Mh(e){const t=e.series.map(n=>{const{aggregation_on_value:r=Bt}=n;return{...n,aggregation_on_value:r}});return{...e,series:t}}function Ih(e){delete e.config;const{x_axis:t,tooltip:n}=e.x_axis.axisLabel.overflow,r={x_axis:{axisLabel:{overflow:{on_axis:t,in_tooltip:n}}}};return x.defaultsDeep(r,e)}function Eh(e){const{series:t,...n}=e;return{...n,series:t.map(r=>{const{barMinWidth:a,barWidth:o,barMaxWidth:l}=r;return a?{...r,barMinWidth:a,barWidth:"",barMaxWidth:l??o}:{...r,barMinWidth:"",barWidth:o,barMaxWidth:""}})}}function Ah(e){const{y_axes:t,...n}=e;return{...n,y_axes:t.map(r=>{const{min:a="",max:o=""}=r;return{...r,min:a,max:o}})}}function zh(e){const{y_axes:t,...n}=e;return{...n,y_axes:t.map(r=>{const{nameAlignment:a="left"}=r;return{...r,nameAlignment:a}})}}function $h(e){const{y_axes:t,...n}=e;return{...n,y_axes:t.map(r=>{const{show:a=!0}=r;return{...r,show:a}})}}function Oh(e){const{regressions:t,...n}=e;return{...n,regressions:t.map(r=>{const{group_by_key:a=""}=r;return{...r,group_by_key:a}})}}function Lh(e){const{series:t,y_axes:n,...r}=e;return{...r,series:t.map(a=>{const{hide_in_legend:o=!1,aggregation_on_value:l=Bt}=a;return{...a,hide_in_legend:o,aggregation_on_value:l}}),y_axes:n.map(a=>{const{min:o="",max:l="",show:u=!0}=a;return{...a,min:o,max:l,show:u}})}}function Ph(e){const{type:t="category",...n}=e.x_axis;return{...e,x_axis:{...n,type:t}}}function Bh(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis_data_key:a,series:o,regressions:l,...u}=e;return{...u,x_axis_data_key:r(a),series:o.map(c=>({...c,y_axis_data_key:r(c.y_axis_data_key),group_by_key:r(c.group_by_key)})),regressions:l.map(c=>({...c,y_axis_data_key:r(c.y_axis_data_key),group_by_key:r(c.group_by_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class Vh extends be{constructor(){super(...arguments);q(this,"VERSION",18)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,{panelModel:r})=>{const{config:a}=n;return(a.variables||[]).forEach(u=>{r.variables.find(c=>c.name===u.name)||r.addVariable(u)}),(x.get(a,"stats.variables")||[]).forEach(u=>{r.variables.find(c=>c.name===u.name)||r.addVariable(u)}),{...n,version:2,config:wh(a)}}),this.version(3,n=>({...n,version:3,config:Ch(n.config)})),this.version(4,n=>({...n,version:4,config:Sh(n.config)})),this.version(5,n=>({...n,version:5,config:_h(n.config)})),this.version(6,n=>({...n,version:6,config:kh(n.config)})),this.version(7,n=>({...n,version:7,config:Th(n.config)})),this.version(8,n=>({...n,version:8,config:Dh(n.config)})),this.version(9,n=>({...n,version:9,config:Mh(n.config)})),this.version(10,n=>({...n,version:10,config:Ih(n.config)})),this.version(11,n=>({...n,version:11,config:Eh(n.config)})),this.version(12,n=>({...n,version:12,config:Ah(n.config)})),this.version(13,n=>({...n,version:13,config:zh(n.config)})),this.version(14,n=>({...n,version:14,config:$h(n.config)})),this.version(15,n=>({...n,version:15,config:Oh(n.config)})),this.version(16,n=>({...n,version:16,config:Lh(n.config)})),this.version(17,n=>({...n,version:17,config:Ph(n.config)})),this.version(18,(n,r)=>({...n,version:18,config:Bh(n.config,r)}))}}const Nh={displayName:"Cartesian Chart",displayGroup:"ECharts-based charts",migrator:new Vh,name:"cartesian",viewRender:Np,configRender:xh,createConfig(){return{version:18,config:x.cloneDeep($r)}},triggers:[zr]};function qh(e){if(e.enable_value)return e.value}function Fh(e){if(e.enable_value)return e.value}function Gh(e){const t=e.axisLabel.overflow.on_axis.width,n=e.axisLabel.position,r={top:5,left:5,right:5,bottom:5};return e.orient==="vertical"&&x.get(r,n)&&n===e.funnelAlign&&x.set(r,n,t),r}function Wh(e,t){return e.series.map(n=>{const{level_name_data_key:r,level_value_data_key:a,axisLabel:o,min:l,max:u,funnelAlign:c,orient:d,...f}=n;if(!r||!a)return{};const h=V(r),g=V(a),m=t[h.queryID].map(w=>({name:w[h.columnKey],value:w[g.columnKey]})),C=ct(o.overflow.on_axis);return{type:"funnel",...Gh(n),min:qh(l),max:Fh(u),minSize:l.size,maxSize:u.size,...f,label:{show:!0,position:o.position,...C},orient:d,funnelAlign:d==="horizontal"?"center":c,data:m}})}function jh({conf:e,params:t,max:n}){const{name:r,value:a}=t.data,o=H(a/n).format({output:"percent",mantissa:2,trimMantissa:!0});return[{label:`${t.marker} ${r}`,value:`${a} (${o})`,style:{label:"",value:""}}]}function Rh(e,t){var o;const n=V(e.series[0].level_name_data_key),r=V(e.series[0].level_value_data_key),a=(o=x.maxBy(t[n.queryID],r.columnKey))==null?void 0:o[r.columnKey];return l=>{const c=jh({conf:e,params:l,max:a}).map(f=>`
|
|
118
118
|
<tr>
|
|
119
119
|
<th style="text-align: right;">
|
|
120
120
|
<div style="${f.style.label}">${f.label}</div>
|
|
@@ -152,8 +152,8 @@ Check the top-level render call using <`+P+">.")}return z}}function bu(S,z){{if(
|
|
|
152
152
|
<tbody>${g.join("")}</tbody>
|
|
153
153
|
</table>
|
|
154
154
|
`}}}const yf=({value:e,onChange:t})=>{const n=r=>{r&&t(r)};return i(s.Box,{children:i(Ae,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},bs={static:{type:"static",value:10},dynamic:{type:"dynamic",value:["function getValue({ variables }, { lodash, interpolate }) {"," // your code goes here"," return 100;","}"].join(`
|
|
155
|
-
`)}},bf=({value:e,onChange:t})=>{const[n,{setTrue:r,setFalse:a}]=X.useBoolean(),[o,l]=y.useState(e),u=()=>{a();const{type:h,value:g}=o,m={type:h,value:g};l(m),t(m)},c=()=>{a(),l(e)},d=h=>{l(g=>({...g,value:h}))},f=()=>{d(bs.dynamic.value)};return p(B,{children:[i(s.Box,{sx:{width:"50%"},children:i(s.Button,{variant:"filled",mt:24,onClick:r,sx:{flexGrow:0},children:"Setup"})}),i(s.Modal,{size:800,title:"Setup dynamic value",opened:n,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:n&&p(s.Stack,{children:[i(s.Divider,{mt:10,mb:-10,label:"Dynamic by a custom function",labelPosition:"center",variant:"dashed"}),i(yf,{value:o.value,onChange:d}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:f,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"
|
|
156
|
-
`)},xs=y.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:a,setFalse:o}]=X.useBoolean(),[l,u]=y.useState(e);y.useEffect(()=>{u(e)},[e]);const c=m=>{u({...l,enabled:m})},d=()=>{o();const{enabled:m,func_content:C}=l,w={enabled:m,func_content:C};u(w),t(w)},f=()=>{o(),u(e)},h=m=>{u(C=>({...C,func_content:m}))},g=()=>{h(Pf.func_content)};return p(B,{children:[i(s.Button,{variant:"filled",mt:24,onClick:a,sx:{flexGrow:0},children:"Customize Label"}),i(s.Modal,{size:800,title:"Customize label content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&p(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:l.enabled,onChange:m=>c(m.currentTarget.checked)}),i(Lf,{value:l.func_content,onChange:h,disabled:!l.enabled}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:g,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"
|
|
155
|
+
`)}},bf=({value:e,onChange:t})=>{const[n,{setTrue:r,setFalse:a}]=X.useBoolean(),[o,l]=y.useState(e),u=()=>{a();const{type:h,value:g}=o,m={type:h,value:g};l(m),t(m)},c=()=>{a(),l(e)},d=h=>{l(g=>({...g,value:h}))},f=()=>{d(bs.dynamic.value)};return p(B,{children:[i(s.Box,{sx:{width:"50%"},children:i(s.Button,{variant:"filled",mt:24,onClick:r,sx:{flexGrow:0},children:"Setup"})}),i(s.Modal,{size:800,title:"Setup dynamic value",opened:n,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:n&&p(s.Stack,{children:[i(s.Divider,{mt:10,mb:-10,label:"Dynamic by a custom function",labelPosition:"center",variant:"dashed"}),i(yf,{value:o.value,onChange:d}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:f,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Reset"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:c,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:u,children:"OK"})]})]})]})})]})},vf=({value:e,onChange:t})=>e.type!=="dynamic"?null:i(bf,{value:e,onChange:t}),xf=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=r=>{t({...e,value:r})};return i(s.NumberInput,{defaultValue:18,label:" ",hideControls:!0,value:e.value,onChange:n})},wf=[{label:"Static",value:"static"},{label:"Dynamic",value:"dynamic"}],En=y.forwardRef(({label:e="Value",value:t,onChange:n},r)=>{const a=o=>{n({...bs[o]})};return p(s.SimpleGrid,{cols:2,children:[i(s.Select,{ref:r,label:e,data:wf,value:t.type,onChange:a,sx:{flexGrow:1}}),i(xf,{value:t,onChange:n}),i(vf,{value:t,onChange:n})]})});function An(e,t,n){if(!e.type)return n;if(e.type==="static"){const{value:a}=e;return a}const{value:r}=e;try{return console.log("returning here"),new Function(`return ${r}`)()({variables:t},{lodash:x,interpolate:_t.interpolate})}catch(a){return console.error(`[getNumberOrDynamicValue] failed parsing custom function, error: ${a.message}`),10}}function Cf(e,t){const n=An(e.heat_block.min,t),r=An(e.heat_block.max,t);return{min:n,max:r,calculable:!0,orient:"horizontal",left:"center",top:0,itemWidth:15}}function Sf(e,t,n){const r=V(e.x_axis.data_key),a=x.uniq(t[r.queryID].map(c=>c[r.columnKey])),{overflow:o,rotate:l}=e.x_axis.axisLabel,u=ct(o.on_axis);return{id:"main-x-axis",type:"category",data:a,name:e.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:l,...u,formatter:n},splitArea:{show:!0},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:1}}function _f(e,t,n){const r=V(e.x_axis.data_key),a=V(e.y_axis.data_key),{nameAlignment:o,data_key:l,...u}=e.y_axis,c=x.uniq(t[r.queryID].map(g=>g[a.columnKey])),{overflow:d,rotate:f}=e.y_axis.axisLabel,h=ct(d.on_axis);return{...u,type:"category",data:c,axisLabel:{rotate:f,...h,formatter:n},axisLine:{show:!0,color:"blue"},axisTick:{show:!0,alignWithLabel:!0},splitArea:{show:!0},nameTextStyle:{fontWeight:"bold",align:o},nameLocation:"end",nameGap:15,z:1}}const kf={tooltip:{confine:!0}};function Tf(e,t,n){if(!e.x_axis.data_key||!e.y_axis.data_key||!e.heat_block.data_key)return{};const r=n.reduce((u,c)=>{const d=bt(c,t);return u[c.name]=tt(c,d),u},{}),a=cf(e),o=df(e),l={xAxis:Sf(e,t,a.x_axis),yAxis:_f(e,t,a.y_axis),series:hf(e,t),tooltip:mf(e,t,a,o),grid:pf(e),visualMap:Cf(e,r)};return x.defaultsDeep({},l,kf)}function Df(e){return i(B,{})}function Mf(e){return i(s.Text,{children:"Click heat block"})}const vs={id:"builtin:echarts:click-heatmap:heat-block",displayName:"Click Heat Block",nameRender:Mf,configRender:Df,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]},qr={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,overflow:Ze,formatter:{...rt}}},y_axis:{name:"Y Axis",data_key:"",nameAlignment:"center",axisLabel:{rotate:0,overflow:Ze,formatter:{...rt}}},heat_block:{min:{type:"static",value:0},max:{type:"static",value:100},name:"Value",data_key:"",value_formatter:$e,label:{show:!1,fontSize:10}},tooltip:{metrics:[]}};oe.use([G.DataZoomComponent,pe.HeatmapChart,G.GridComponent,G.LegendComponent,G.TooltipComponent,G.VisualMapComponent,Ve.CanvasRenderer]);function If({conf:e,data:t,width:n,height:r,interactionManager:a,variables:o}){const l=y.useMemo(()=>{const h=V(e.x_axis.data_key),g=V(e.y_axis.data_key);return x.keyBy(t[h.queryID],m=>`${m[h.columnKey]}---${m[g.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),u=He(a.triggerManager,vs.id),c=y.useCallback(h=>{const[g,m]=h.value,C=x.get(l,`${g}---${m}`,{error:"rowData is not found"});u.forEach(w=>{a.runInteraction(w.id,{...h,rowData:C})})},[l,u,a]),d=y.useMemo(()=>({click:c}),[c]),f=y.useMemo(()=>Tf(e,t,o),[e,t]);return!n||!r?null:i(Ne,{echarts:oe,option:f,style:{width:n,height:r},onEvents:d,notMerge:!0,theme:"merico-light"})}function Ef({context:e,instance:t}){const n=et({vizManager:e.vizManager,instance:t}),{value:r}=W(e.instanceData,"config"),{variables:a}=e,o=y.useMemo(()=>x.defaults({},r,qr),[r]),l=e.data,{width:u,height:c}=e.viewport;return i(s.Box,{children:i(If,{variables:a,width:u,height:c,data:l,conf:o,interactionManager:n})})}function Af({control:e,watch:t}){t(["heat_block"]);const n=t("heat_block.label.show");return p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"heat_block.data_key",control:e,render:({field:r})=>i(j,{label:"Data Field",required:!0,sx:{flex:1},...r})}),i(v.Controller,{name:"heat_block.name",control:e,render:({field:r})=>i(s.TextInput,{label:"Name",sx:{flex:1},...r})})]}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"heat_block.min",control:e,render:({field:r})=>i(En,{label:"Min Value",...r})}),i(v.Controller,{name:"heat_block.max",control:e,render:({field:r})=>i(En,{label:"Max Value",...r})})]}),i(s.Divider,{mb:-15,variant:"dashed",label:"Value Format",labelPosition:"center"}),i(v.Controller,{name:"heat_block.value_formatter",control:e,render:({field:r})=>i(Re,{...r})}),i(s.Divider,{mb:-5,variant:"dashed",label:"Label",labelPosition:"center"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"heat_block.label.show",control:e,render:({field:r})=>i(s.Switch,{label:"Show label",checked:r.value,onChange:a=>r.onChange(a.currentTarget.checked),sx:{flexGrow:1}})}),i(v.Controller,{name:"heat_block.label.fontSize",control:e,render:({field:r})=>i(s.NumberInput,{size:"xs",icon:i($.IconTextSize,{size:16}),disabled:!n,...r})})]})]})}const zf=({control:e,index:t,remove:n})=>p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:r})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...r})}),i(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:r})=>i(j,{label:"Value Field",required:!0,sx:{flex:1},...r})})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed"}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),sx:{top:15,right:5},children:"Delete this Metric"})]}),$f=({control:e,watch:t})=>{const{fields:n,append:r,remove:a}=v.useFieldArray({control:e,name:"tooltip.metrics"}),o=t("tooltip.metrics"),l=n.map((h,g)=>({...h,...o[g]})),u=()=>r({id:Date.now().toString(),data_key:"",name:""}),c=t("tooltip.metrics.0.id"),[d,f]=y.useState(()=>c??null);return y.useEffect(()=>{c&&f(h=>h!==null?h:c)},[c]),p(B,{children:[p(s.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[i(D.InfoCircle,{size:14,color:"#888"}),i(s.Text,{size:14,color:"#888",children:"Configure additional metrics to show in tooltip"})]}),i(s.Divider,{variant:"dashed",my:10}),p(s.Tabs,{value:d,onTabChange:h=>f(h),styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[p(s.Tabs.List,{children:[l.map((h,g)=>i(s.Tabs.Tab,{value:h.id,children:h.name?h.name:g},h.id)),i(s.Tabs.Tab,{onClick:u,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),l.map((h,g)=>i(s.Tabs.Panel,{value:h.id,children:i(zf,{control:e,index:g,remove:a},h.id)},h.id))]})]})};function Of({control:e,watch:t}){return i($f,{control:e,watch:t})}const Lf=({disabled:e,value:t,onChange:n})=>{const r=a=>{a&&n(a)};return p(s.Box,{sx:{position:"relative"},children:[e&&i(s.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),i(Ae,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},Pf={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
156
|
+
`)},xs=y.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:a,setFalse:o}]=X.useBoolean(),[l,u]=y.useState(e);y.useEffect(()=>{u(e)},[e]);const c=m=>{u({...l,enabled:m})},d=()=>{o();const{enabled:m,func_content:C}=l,w={enabled:m,func_content:C};u(w),t(w)},f=()=>{o(),u(e)},h=m=>{u(C=>({...C,func_content:m}))},g=()=>{h(Pf.func_content)};return p(B,{children:[i(s.Button,{variant:"filled",mt:24,onClick:a,sx:{flexGrow:0},children:"Customize Label"}),i(s.Modal,{size:800,title:"Customize label content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&p(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:l.enabled,onChange:m=>c(m.currentTarget.checked)}),i(Lf,{value:l.func_content,onChange:h,disabled:!l.enabled}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:g,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Reset"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:f,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:d,children:"OK"})]})]})]})})]})});function Bf({control:e,watch:t}){return t(["x_axis"]),p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.data_key",control:e,render:({field:n})=>i(j,{label:"Data Field",required:!0,sx:{flex:1},...n})}),i(v.Controller,{name:"x_axis.name",control:e,render:({field:n})=>i(s.TextInput,{label:"Name",sx:{flex:1},...n})})]}),i(s.Divider,{mb:-15,variant:"dashed",label:"Tick Label",labelPosition:"center"}),i(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:n})=>i(mt,{...n})}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:n})=>i(s.NumberInput,{label:"Rotate",hideControls:!0,min:-90,max:90,rightSection:i(s.Text,{color:"dimmed",children:"degree"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),i(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>i(xs,{...n})})]})]})}const Vf=[{label:"left",value:"left"},{label:"center",value:"center"},{label:"right",value:"right"}];function Nf({control:e,watch:t}){return t(["y_axis"]),p(s.Stack,{my:0,p:"0",sx:{position:"relative"},children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"y_axis.data_key",control:e,render:({field:n})=>i(j,{label:"Data Field",required:!0,sx:{flex:1},...n})}),i(v.Controller,{name:"y_axis.name",control:e,render:({field:n})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...n})})]}),i(s.Group,{grow:!0,noWrap:!0,children:i(v.Controller,{name:"y_axis.nameAlignment",control:e,render:({field:n})=>i(s.Select,{label:"Name Alignment",required:!0,data:Vf,sx:{flex:1},...n})})}),i(s.Divider,{mb:-15,variant:"dashed",label:"Tick Label",labelPosition:"center"}),i(v.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:n})=>i(mt,{...n})}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"y_axis.axisLabel.rotate",control:e,render:({field:n})=>i(s.NumberInput,{label:"Rotate",hideControls:!0,min:-90,max:90,rightSection:i(s.Text,{color:"dimmed",children:"degree"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),i(v.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:n})=>i(xs,{...n})})]})]})}function qf({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaultsDeep({},t,qr),[t]),a=y.useMemo(()=>x.cloneDeep(r),[r]);y.useEffect(()=>{!x.isEqual(r,a)&&(console.log("config malformed, resetting to defaults",r,a),n(a))},[r,a]);const{control:o,handleSubmit:l,watch:u,getValues:c,reset:d}=v.useForm({defaultValues:a});y.useEffect(()=>{d(a)},[a]);const f=c(),h=y.useMemo(()=>!x.isEqual(f,r),[f,r]);return i("form",{onSubmit:l(n),style:{flexGrow:1},children:p(s.Stack,{spacing:"xs",sx:{height:"100%"},children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{root:{flexGrow:1},tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"X Axis",children:"X Axis"}),i(s.Tabs.Tab,{value:"Y Axis",children:"Y Axis"}),i(s.Tabs.Tab,{value:"Heat Block",children:"Heat Block"}),i(s.Tabs.Tab,{value:"Tooltip",children:"Tooltip"})]}),i(s.Tabs.Panel,{value:"X Axis",children:i(Bf,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Y Axis",children:i(Nf,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Heat Block",children:i(Af,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Tooltip",children:i(Of,{control:o,watch:u})})]})]})})}function Ff(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=d=>d&&`${n}.${d}`,{x_axis:a,y_axis:o,heat_block:l,tooltip:u,...c}=e;return{...c,x_axis:{...a,data_key:r(a.data_key)},y_axis:{...o,data_key:r(o.data_key)},heat_block:{...l,data_key:r(l.data_key)},tooltip:{...u,metrics:u.metrics.map(d=>({...d,data_key:r(d.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}function Gf(e){return x.defaultsDeep({},e,{heat_block:{label:{show:!1,fontSize:10}}})}function Wf(e){const{heat_block:t}=e;let{min:n,max:r}=t;return typeof n!="number"&&(n=0),typeof r!="number"&&(r=100),{...e,heat_block:{...t,min:{type:"static",value:n},max:{type:"static",value:r}}}}class jf extends be{constructor(){super(...arguments);q(this,"VERSION",4)}configVersions(){this.version(1,n=>(console.log("🟥 unexpected calling"),{version:1,config:n})),this.version(2,(n,r)=>({...n,version:2,config:Ff(n.config,r)})),this.version(3,n=>({...n,version:3,config:Gf(n.config)})),this.version(4,n=>({...n,version:4,config:Wf(n.config)}))}}const Rf={displayName:"Heatmap",displayGroup:"ECharts-based charts",migrator:new jf,name:"heatmap",viewRender:Ef,configRender:qf,createConfig:()=>({version:4,config:qr}),triggers:[vs]},ws={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:Qf,configRender:Yf,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'line' | 'bar'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Yf(e){return i(B,{})}function Qf(e){return i(s.Text,{children:"Click chart's series"})}const Cs={label_template:"${percentage.x} of ${x_axis.name} causes ${percentage.y} of ${bar.name}",color:"rgba(0,0,0,0.3)"},Fr={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,formatter:{...rt},overflow:Ze}},data_key:"value",bar:{name:"Value",nameAlignment:"left",color:"#228be6",label_formatter:$e},line:{name:"Value",nameAlignment:"right",color:"red"},dataZoom:Vt,markLine:Cs};function zn(e){return H(e).format({output:"percent",mantissa:0})}function Kf(e){const t=e.value[1];try{return zn(t)}catch(n){return console.error(n),t}}function Uf(e){function t(n){let r=n;if(typeof n=="object"&&(Array.isArray(n.value)&&n.value.length===2?r=n.value[1]:r=n.value),!e.bar.label_formatter)return r;try{return H(r).format(e.bar.label_formatter)}catch(a){return console.error(a),r}}return{bar:t,line:Kf,lineValue:zn}}function Xf(e,t,n){const{label_template:r}=e.markLine;if(!r)return"";const a={...e,percentage:t,count:n},o=Object.keys(a),l=Object.values(a);return new Function(...o,`return \`${r}\`;`)(...l)}function Jf(e,t){if(t.length===0)return{};const n=t.findIndex(u=>u[1]>=.8);if(n===-1)return{};const r=t[n],a={x:zn((n+1)/t.length),y:zn(r[1])},o={left:n+1,right:t.length-n-1},l=r[0];return l?{name:"",silent:!0,symbol:"triangle",symbolRotate:180,symbolSize:[10,8],data:[{name:"",symbol:"none",xAxis:l,lineStyle:{color:e.markLine.color},label:{formatter:Xf(e,a,o)}}]}:{}}function Zf(e,t,n){const{x_axis:r,data_key:a}=e;if(!r.data_key||!a)return[];const o=V(r.data_key),l=V(a);if(o.queryID!==l.queryID)throw new Error("Please use the same query for X & Y axis");const u=t[o.queryID].map(h=>[h[o.columnKey],Number(h[l.columnKey])]).sort((h,g)=>g[1]-h[1]),c=u.reduce((h,g)=>h+g[1],0),d=u.reduce((h,g,m)=>{const C=m===0?0:h[m-1][1];return h.push([g[0],C+g[1]]),h},[]).map(h=>[h[0],h[1]/c]),f=Jf(e,d);return[{name:e.bar.name,type:"bar",barMaxWidth:20,itemStyle:{color:e.bar.color},label:{show:!1,position:"top",formatter:n.bar},yAxisIndex:0,data:u},{name:e.line.name,type:"line",itemStyle:{color:e.line.color},symbolSize:2,lineStyle:{width:1},label:{show:!1,position:"top",formatter:n.line},yAxisIndex:1,data:d,markLine:f}]}const Hf=(e,t)=>n=>{const r=Array.isArray(n)?n:[n];if(r.length===0)return"";const a=r.map((u,c)=>{const d=u.seriesName,[f,h]=u.value;if(!d)return h;const g=c===0?t.bar:t.lineValue;return`
|
|
157
157
|
<tr>
|
|
158
158
|
<th style="text-align: right; padding: 0 1em;">${d}</th>
|
|
159
159
|
<td style="text-align: left; padding: 0 1em;">${g(h)}</td>
|
|
@@ -239,7 +239,7 @@ Check the top-level render call using <`+P+">.")}return z}}function bu(S,z){{if(
|
|
|
239
239
|
</tbody>
|
|
240
240
|
</table>
|
|
241
241
|
`}}}function Es({enabled:e,func_content:t}){return(n,r)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,r)}catch(a){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${a.message}`),n}}}function fm(e){const{overflow:t,format:n,formatter:r,...a}=e.x_axis.axisLabel,o=ct(t.on_axis);return{type:"value",name:e.x_axis.name??"",nameLocation:"middle",nameGap:25,axisTick:{show:!0,alignWithLabel:!0},axisLabel:{...a,...o,formatter:(l,u)=>{let c=l;try{c=H(l).format(n)}catch{}return Es(r)(c,u)}}}}const gm={tooltip:{trigger:"axis"},grid:{top:50,left:5,right:10,bottom:20,containLabel:!0},dataZoom:[{type:"inside",xAxisIndex:[0]},{type:"inside",yAxisIndex:[0]}]};function mm(e,t){const n=dm(e,t),r=lm(e,n),a={xAxis:fm(e),yAxis:{name:e.y_axis.name??"",nameLocation:"end",nameTextStyle:{align:"left"},nameGap:5,axisLine:{show:!0}},series:[...n,...r],tooltip:hm(e),legend:{show:!0,type:"scroll",orient:"horizontal",align:"left",right:0,top:0,left:"auto",itemGap:20,padding:[4,8,0,140],data:n.map(o=>o.name)}};return x.defaultsDeep({},a,gm)}function On(e,t,n){return 1-(1-e)*(t-1)/(t-n-1)}function ym(e,t,n,r){const{x_axis:a,y_axis:o}=r,l=ft.regressionLinear()(n),{a:u,b:c,rSquared:d}=l;return{name:e,expression:p(s.Group,{position:"center",noWrap:!0,spacing:10,children:[i(s.Text,{children:o.name}),i(s.Text,{children:"="}),i(s.Text,{weight:"bold",color:"red",children:H(c).format({mantissa:2,trimMantissa:!0})}),i(s.Text,{children:"+"}),i(s.Text,{weight:"bold",color:"red",children:H(u).format({mantissa:2,trimMantissa:!0})}),i(s.Text,{children:"×"}),i(s.Text,{children:a.name})]}),rSquared:d,adjustedRSquared:On(d,t.length,1)}}function bm(e,t,n,r){const{x_axis:a,y_axis:o}=r,{a:l,b:u,rSquared:c}=ft.regressionExp()(n);return{name:e,expression:p(s.Group,{position:"center",noWrap:!0,spacing:10,children:[i(s.Text,{children:o.name}),i(s.Text,{children:"="}),i(s.Text,{weight:"bold",color:"gray",children:l}),i(s.Text,{children:"×"}),p(s.Group,{position:"left",noWrap:!0,spacing:2,children:[i(s.Text,{children:"Math.exp("}),i(s.Text,{weight:"bold",color:"gray",children:u}),i(s.Text,{children:"×"}),i(s.Text,{children:a.name}),i(s.Text,{children:")"})]})]}),rSquared:c,adjustedRSquared:On(c,t.length,1)}}function vm(e,t,n,r){const{x_axis:a,y_axis:o}=r,{a:l,b:u,rSquared:c}=ft.regressionLog()(n);return{name:e,expression:p(s.Group,{position:"center",noWrap:!0,spacing:10,children:[i(s.Text,{children:o.name}),i(s.Text,{children:"="}),i(s.Text,{weight:"bold",color:"gray",children:l}),i(s.Text,{children:"×"}),p(s.Group,{position:"left",noWrap:!0,spacing:2,children:[i(s.Text,{children:"Math.log("}),i(s.Text,{children:a.name}),i(s.Text,{children:")"}),i(s.Text,{children:"+"}),i(s.Text,{weight:"bold",color:"gray",children:u})]})]}),rSquared:c,adjustedRSquared:On(c,t.length,1)}}function xm(e,t,n,r){const{x_axis:a,y_axis:o,regression:l}=r,u=ft.regressionPoly().order(l.transform.config.order)(n),{rSquared:c}=u;return console.log(u),{name:e,expression:"",rSquared:c,adjustedRSquared:On(c,t.length,1)}}function As(e,t,n){const{regression:r,x_axis:a}=n,o=V(a.data_key),l=V(r.y_axis_data_key),u=t.map(c=>[c[o.columnKey],c[l.columnKey]]);return r.transform.config.method==="linear"?ym(e,t,u,n):r.transform.config.method==="exponential"?bm(e,t,u,n):r.transform.config.method==="logarithmic"?vm(e,t,u,n):r.transform.config.method==="polynomial"?xm(e,t,u,n):{name:e,expression:"",rSquared:0,adjustedRSquared:0}}function wm(e,t){if(!t)return[{name:"",expression:"",rSquared:0,adjustedRSquared:0}];if(!t.regression.group_by_key)return[As("",e,t)];const n=V(t.regression.group_by_key),r=x.groupBy(e,n.columnKey);return Object.entries(r).map(([a,o])=>As(a,o,t))}const Cm={marginTop:"10px","tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function zs({desc:e}){const{expression:t,rSquared:n,adjustedRSquared:r}=e;return t?i(s.Table,{fontSize:14,sx:Cm,children:p("tbody",{children:[i("tr",{children:i("td",{colSpan:2,children:i(s.Text,{align:"center",children:t})})}),p("tr",{children:[i("td",{children:"R-Sq"}),i("td",{style:{textAlign:"right"},children:H(n).format({output:"percent",mantissa:1})})]}),p("tr",{children:[i("td",{children:"R-Sq(Adjusted)"}),i("td",{style:{textAlign:"right"},children:H(r).format({output:"percent",mantissa:1})})]})]})}):i(s.Text,{children:"Unavailable for this regression method"})}function Sm({conf:e,queryData:t}){var r;const n=y.useMemo(()=>wm(t,e),[e,t]);return e.regression.group_by_key?(console.log(n),p(s.Tabs,{defaultValue:(r=n[0])==null?void 0:r.name,color:"gray",children:[i(s.Tabs.List,{grow:!0,children:n.map(a=>i(s.Tabs.Tab,{value:a.name,children:a.name},a.name))}),n.map(a=>i(s.Tabs.Panel,{value:a.name,children:i(zs,{desc:a})},a.name))]})):i(zs,{desc:n[0]})}function _m({conf:e,queryData:t}){return p(s.HoverCard,{shadow:"md",withinPortal:!0,zIndex:320,children:[i(s.HoverCard.Target,{children:i(s.Button,{size:"xs",variant:"subtle",compact:!0,leftIcon:i($.IconInfoCircle,{size:14}),children:"Regression Info"})}),i(s.HoverCard.Dropdown,{children:i(Fe,{children:i(Sm,{conf:e,queryData:t})})})]})}function km(e){return i(s.Group,{position:"apart",sx:{position:"absolute",top:0,left:0,height:"22px",zIndex:1},children:i(_m,{...e})})}const Ln={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
|
|
242
|
-
`)},jr={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,format:$e,overflow:Ze,formatter:{...Ln}}},y_axis:{name:"Y Axis"},regression:{transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},plot:{type:"line",yAxisIndex:0,color:"#228be6",lineStyle:{type:"solid",width:1}},name:"regression",group_by_key:"",y_axis_data_key:"value"}};oe.use([G.DataZoomComponent,pe.ScatterChart,G.GridComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function Tm({context:e}){const{value:t}=W(e.instanceData,"config"),{width:n,height:r}=e.viewport,a=y.useMemo(()=>{var m;const c=e.data,d=t==null?void 0:t.x_axis.data_key,f=(m=t==null?void 0:t.regression)==null?void 0:m.y_axis_data_key;if(!d||!f)return[];const h=V(d),g=V(f);return c[h.queryID].map(C=>typeof C[g.columnKey]=="number"?C:{...C,[g.columnKey]:Number(C[g.columnKey])})},[e.data,t==null?void 0:t.regression.y_axis_data_key]),o=y.useMemo(()=>mm(x.defaultsDeep({},t,jr),a),[t,a]),l=y.useRef(null),u=c=>{l.current=c};return!n||!r||!t?null:p(s.Box,{sx:{position:"relative"},children:[i(km,{conf:t,queryData:a}),i(Ne,{echarts:oe,onChartReady:u,option:o,style:{width:n,height:r},notMerge:!0,theme:"merico-light"})]})}const Dm=[{label:"Linear",value:"linear"},{label:"Exponential",value:"exponential"},{label:"Logarithmic",value:"logarithmic"},{label:"Polynomial",value:"polynomial"}];function Mm({control:e,watch:t}){t("regression");const n=t("regression.transform.config.method"),r=t("regression.group_by_key");return p(s.Stack,{children:[i(s.Group,{grow:!0,noWrap:!0,children:i(v.Controller,{name:"regression.name",control:e,render:({field:a})=>i(s.TextInput,{label:"回归线名称",sx:{flex:1},...a})})}),i(v.Controller,{name:"regression.group_by_key",control:e,render:({field:a})=>i(j,{label:"按此字段将数据分为多个系列",clearable:!0,sx:{flex:1},...a})}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"regression.transform.config.method",control:e,render:({field:a})=>i(s.Select,{label:"回归方法",data:Dm,sx:{flex:1},...a})}),n==="polynomial"&&i(v.Controller,{name:"regression.transform.config.order",control:e,render:({field:a})=>i(s.NumberInput,{label:"次",sx:{flex:1},...a})})]}),!r&&p(s.Stack,{spacing:4,children:[i(s.Text,{size:"sm",children:"颜色"}),i(v.Controller,{name:"regression.plot.color",control:e,render:({field:a})=>i(Pe,{...a})})]})]})}const Im=({disabled:e,value:t,onChange:n})=>{const r=a=>{a&&n(a)};return p(s.Box,{sx:{position:"relative"},children:[e&&i(s.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),i(Ae,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},$s=y.forwardRef(({value:e,onChange:t,triggerButtonText:n="Customize Label"},r)=>{const[a,{setTrue:o,setFalse:l}]=X.useBoolean(),[u,c]=y.useState(e);y.useEffect(()=>{c(e)},[e]);const d=C=>{c({...u,enabled:C})},f=()=>{l();const{enabled:C,func_content:w}=u,_={enabled:C,func_content:w};c(_),t(_)},h=()=>{l(),c(e)},g=C=>{c(w=>({...w,func_content:C}))},m=()=>{g(Ln.func_content)};return p(B,{children:[i(s.Button,{variant:"filled",mt:24,onClick:o,sx:{flexGrow:0},children:n}),i(s.Modal,{size:800,title:"Customize label content",opened:a,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&p(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:u.enabled,onChange:C=>d(C.currentTarget.checked)}),i(Im,{value:u.func_content,onChange:g,disabled:!u.enabled}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:m,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Rest"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:h,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:f,children:"OK"})]})]})]})})]})});function Em({control:e,watch:t}){return t(["x_axis"]),p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.name",control:e,render:({field:n})=>i(s.TextInput,{label:"X轴名称",sx:{flex:1},...n})}),i(v.Controller,{name:"x_axis.data_key",control:e,render:({field:n})=>i(j,{label:"X轴数据字段",required:!0,sx:{flex:1},...n})})]}),i(s.Divider,{variant:"dashed",labelPosition:"center",label:"格式化数据"}),i(s.Stack,{children:i(v.Controller,{name:"x_axis.axisLabel.format",control:e,render:({field:n})=>i(Re,{...n})})}),i(s.Divider,{variant:"dashed",labelPosition:"center",label:"标签文案样式"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:n})=>i(s.NumberInput,{label:"旋转",hideControls:!0,min:-90,max:90,rightSection:i(s.Text,{color:"dimmed",children:"度"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),i(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>i($s,{triggerButtonText:"自定义标签文案内容",...n})})]}),i(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:n})=>i(mt,{...n})})]})}function Am({control:e,watch:t}){return t(["y_axis","regression.y_axis_data_key"]),i(s.Stack,{children:p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"y_axis.name",control:e,render:({field:n})=>i(s.TextInput,{label:"Y轴名称",sx:{flex:1},...n})}),i(v.Controller,{name:"regression.y_axis_data_key",control:e,render:({field:n})=>i(j,{label:"Y轴数据字段",required:!0,sx:{flex:1},...n})})]})})}function zm({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaults({},t,jr),[t]),{control:a,handleSubmit:o,watch:l,getValues:u,reset:c}=v.useForm({defaultValues:r});y.useEffect(()=>{c(r)},[r]),l(["x_axis","y_axis","regression"]);const d=u(),f=y.useMemo(()=>!x.isEqual(d,t),[d,t]);return i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!f,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Tabs,{defaultValue:"X轴",orientation:"vertical",styles:{panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"X轴",children:"X轴"}),i(s.Tabs.Tab,{value:"Y轴",children:"Y轴"}),i(s.Tabs.Tab,{value:"回归",children:"回归"})]}),i(s.Tabs.Panel,{value:"X轴",children:i(Em,{watch:l,control:a})}),i(s.Tabs.Panel,{value:"Y轴",children:i(Am,{watch:l,control:a})}),i(s.Tabs.Panel,{value:"回归",children:i(Mm,{control:a,watch:l})})]})]})})}function $m(e){const t={x_axis:{axisLabel:{rotate:0,format:$e,overflow:Ze,formatter:Ln}},regression:{group_by_key:""}};return x.defaultsDeep(t,e)}function Om(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis:a,regression:o,...l}=e;return{...l,x_axis:{...a,data_key:r(a.data_key)},regression:{...o,group_by_key:r(o.group_by_key),y_axis_data_key:r(o.y_axis_data_key)}}}catch(n){throw console.error("[Migration failed]",n),n}}class Lm extends be{constructor(){super(...arguments);q(this,"VERSION",3)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:$m(n.config)})),this.version(3,(n,r)=>{const{config:a}=n;return{...n,version:3,config:Om(a,r)}})}}const Pm={displayName:"Regression Chart",displayGroup:"Merico suite",migrator:new Lm,name:"regressionChart",viewRender:Tm,configRender:zm,createConfig(){return{version:3,config:x.cloneDeep(jr)}}},Pn={content:""},Rr={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"},blockquote:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45",margin:"0 0 14px"}};function Os(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let a=e.child(r),o=t.child(r);if(a==o){n+=a.nodeSize;continue}if(!a.sameMarkup(o))return n;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)n++;return n}if(a.content.size||o.content.size){let l=Os(a.content,o.content,n+1);if(l!=null)return l}n+=a.nodeSize}}function Ls(e,t,n,r){for(let a=e.childCount,o=t.childCount;;){if(a==0||o==0)return a==o?null:{a:n,b:r};let l=e.child(--a),u=t.child(--o),c=l.nodeSize;if(l==u){n-=c,r-=c;continue}if(!l.sameMarkup(u))return{a:n,b:r};if(l.isText&&l.text!=u.text){let d=0,f=Math.min(l.text.length,u.text.length);for(;d<f&&l.text[l.text.length-d-1]==u.text[u.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(l.content.size||u.content.size){let d=Ls(l.content,u.content,n-1,r-1);if(d)return d}n-=c,r-=c}}class ie{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let r=0;r<t.length;r++)this.size+=t[r].nodeSize}nodesBetween(t,n,r,a=0,o){for(let l=0,u=0;u<n;l++){let c=this.content[l],d=u+c.nodeSize;if(d>t&&r(c,a+u,o||null,l)!==!1&&c.content.size){let f=u+1;c.nodesBetween(Math.max(0,t-f),Math.min(c.content.size,n-f),r,a+f)}u=d}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,r,a){let o="",l=!0;return this.nodesBetween(t,n,(u,c)=>{u.isText?(o+=u.text.slice(Math.max(t,c)-c,n-c),l=!r):u.isLeaf?(a?o+=typeof a=="function"?a(u):a:u.type.spec.leafText&&(o+=u.type.spec.leafText(u)),l=!r):!l&&u.isBlock&&(o+=r,l=!0)},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,a=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(a[a.length-1]=n.withText(n.text+r.text),o=1);o<t.content.length;o++)a.push(t.content[o]);return new ie(a,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],a=0;if(n>t)for(let o=0,l=0;l<n;o++){let u=this.content[o],c=l+u.nodeSize;c>t&&((l<t||c>n)&&(u.isText?u=u.cut(Math.max(0,t-l),Math.min(u.text.length,n-l)):u=u.cut(Math.max(0,t-l-1),Math.min(u.content.size,n-l-1))),r.push(u),a+=u.nodeSize),l=c}return new ie(r,a)}cutByIndex(t,n){return t==n?ie.empty:t==0&&n==this.content.length?this:new ie(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let a=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return a[t]=n,new ie(a,o)}addToStart(t){return new ie([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new ie(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,r=0;n<this.content.length;n++){let a=this.content[n];t(a,r,n),r+=a.nodeSize}}findDiffStart(t,n=0){return Os(this,t,n)}findDiffEnd(t,n=this.size,r=t.size){return Ls(this,t,n,r)}findIndex(t,n=-1){if(t==0)return Bn(0,t);if(t==this.size)return Bn(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let r=0,a=0;;r++){let o=this.child(r),l=a+o.nodeSize;if(l>=t)return l==t||n>0?Bn(r+1,l):Bn(r,a);a=l}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return ie.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new ie(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return ie.empty;let n,r=0;for(let a=0;a<t.length;a++){let o=t[a];r+=o.nodeSize,a&&o.isText&&t[a-1].sameMarkup(o)?(n||(n=t.slice(0,a)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new ie(n||t,r)}static from(t){if(!t)return ie.empty;if(t instanceof ie)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new ie([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ie.empty=new ie([],0);const Yr={index:0,offset:0};function Bn(e,t){return Yr.index=e,Yr.offset=t,Yr}function Qr(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!Qr(e[r],t[r]))return!1}else{for(let r in e)if(!(r in t)||!Qr(e[r],t[r]))return!1;for(let r in t)if(!(r in e))return!1}return!0}class We{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,r=!1;for(let a=0;a<t.length;a++){let o=t[a];if(this.eq(o))return t;if(this.type.excludes(o.type))n||(n=t.slice(0,a));else{if(o.type.excludes(this.type))return t;!r&&o.type.rank>this.type.rank&&(n||(n=t.slice(0,a)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=t.slice()),r||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&Qr(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(n[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return We.none;if(t instanceof We)return[t];let n=t.slice();return n.sort((r,a)=>r.type.rank-a.type.rank),n}}We.none=[];class Bm extends Error{}class ce{constructor(t,n,r){this.content=t,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Bs(this.content,t+this.openStart,n);return r&&new ce(r,this.openStart,this.openEnd)}removeBetween(t,n){return new ce(Ps(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return ce.empty;let r=n.openStart||0,a=n.openEnd||0;if(typeof r!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ce(ie.fromJSON(t,n.content),r,a)}static maxOpen(t,n=!0){let r=0,a=0;for(let o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=t.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)a++;return new ce(t,r,a)}}ce.empty=new ce(ie.empty,0,0);function Ps(e,t,n){let{index:r,offset:a}=e.findIndex(t),o=e.maybeChild(r),{index:l,offset:u}=e.findIndex(n);if(a==t||o.isText){if(u!=n&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(r,o.copy(Ps(o.content,t-a-1,n-a-1)))}function Bs(e,t,n,r){let{index:a,offset:o}=e.findIndex(t),l=e.maybeChild(a);if(o==t||l.isText)return r&&!r.canReplace(a,a,n)?null:e.cut(0,t).append(n).append(e.cut(t));let u=Bs(l.content,t-o-1,n);return u&&e.replaceChild(a,l.copy(u))}class Vn{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let a=t.nodes[r.node];return a.contentMatch.matchType(a)})}parse(t,n={}){let r=new Fs(this,n,!1);return r.addAll(t,n.from,n.to),r.finish()}parseSlice(t,n={}){let r=new Fs(this,n,!0);return r.addAll(t,n.from,n.to),ce.maxOpen(r.finish())}matchTag(t,n,r){for(let a=r?this.tags.indexOf(r)+1:0;a<this.tags.length;a++){let o=this.tags[a];if(qm(t,o.tag)&&(o.namespace===void 0||t.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let l=o.getAttrs(t);if(l===!1)continue;o.attrs=l||void 0}return o}}}matchStyle(t,n,r,a){for(let o=a?this.styles.indexOf(a)+1:0;o<this.styles.length;o++){let l=this.styles[o],u=l.style;if(!(u.indexOf(t)!=0||l.context&&!r.matchesContext(l.context)||u.length>t.length&&(u.charCodeAt(t.length)!=61||u.slice(t.length+1)!=n))){if(l.getAttrs){let c=l.getAttrs(n);if(c===!1)continue;l.attrs=c||void 0}return l}}}static schemaRules(t){let n=[];function r(a){let o=a.priority==null?50:a.priority,l=0;for(;l<n.length;l++){let u=n[l];if((u.priority==null?50:u.priority)<o)break}n.splice(l,0,a)}for(let a in t.marks){let o=t.marks[a].spec.parseDOM;o&&o.forEach(l=>{r(l=Gs(l)),l.mark||l.ignore||l.clearMark||(l.mark=a)})}for(let a in t.nodes){let o=t.nodes[a].spec.parseDOM;o&&o.forEach(l=>{r(l=Gs(l)),l.node||l.ignore||l.mark||(l.node=a)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Vn(t,Vn.schemaRules(t)))}}const Vs={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Vm={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ns={ol:!0,ul:!0},Nn=1,qn=2,Ht=4;function qs(e,t,n){return t!=null?(t?Nn:0)|(t==="full"?qn:0):e&&e.whitespace=="pre"?Nn|qn:n&~Ht}class Fn{constructor(t,n,r,a,o,l,u){this.type=t,this.attrs=n,this.marks=r,this.pendingMarks=a,this.solid=o,this.options=u,this.content=[],this.activeMarks=We.none,this.stashMarks=[],this.match=l||(u&Ht?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(ie.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,a;return(a=r.findWrapping(t.type))?(this.match=r,a):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Nn)){let r=this.content[this.content.length-1],a;if(r&&r.isText&&(a=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-a[0].length))}}let n=ie.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(ie.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(t){for(let n=this.stashMarks.length-1;n>=0;n--)if(t.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(t){for(let n=0,r=this.pendingMarks;n<r.length;n++){let a=r[n];(this.type?this.type.allowsMarkType(a.type):Gm(a.type,t))&&!a.isInSet(this.activeMarks)&&(this.activeMarks=a.addToSet(this.activeMarks),this.pendingMarks=a.removeFromSet(this.pendingMarks))}}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Vs.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Fs{constructor(t,n,r){this.parser=t,this.options=n,this.isOpen=r,this.open=0;let a=n.topNode,o,l=qs(null,n.preserveWhitespace,0)|(r?Ht:0);a?o=new Fn(a.type,a.attrs,We.none,We.none,!0,n.topMatch||a.type.contentMatch,l):r?o=new Fn(null,null,We.none,We.none,!0,null,l):o=new Fn(t.schema.topNodeType,null,We.none,We.none,!0,null,l),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t){if(t.nodeType==3)this.addTextNode(t);else if(t.nodeType==1){let n=t.getAttribute("style");if(!n)this.addElement(t);else{let r=this.readStyles(Fm(n));if(!r)return;let[a,o]=r,l=this.top;for(let u=0;u<o.length;u++)this.removePendingMark(o[u],l);for(let u=0;u<a.length;u++)this.addPendingMark(a[u]);this.addElement(t);for(let u=0;u<a.length;u++)this.removePendingMark(a[u],l);for(let u=0;u<o.length;u++)this.addPendingMark(o[u])}}}addTextNode(t){let n=t.nodeValue,r=this.top;if(r.options&qn||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(n)){if(r.options&Nn)r.options&qn?n=n.replace(/\r\n?/g,`
|
|
242
|
+
`)},jr={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,format:$e,overflow:Ze,formatter:{...Ln}}},y_axis:{name:"Y Axis"},regression:{transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},plot:{type:"line",yAxisIndex:0,color:"#228be6",lineStyle:{type:"solid",width:1}},name:"regression",group_by_key:"",y_axis_data_key:"value"}};oe.use([G.DataZoomComponent,pe.ScatterChart,G.GridComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer]);function Tm({context:e}){const{value:t}=W(e.instanceData,"config"),{width:n,height:r}=e.viewport,a=y.useMemo(()=>{var m;const c=e.data,d=t==null?void 0:t.x_axis.data_key,f=(m=t==null?void 0:t.regression)==null?void 0:m.y_axis_data_key;if(!d||!f)return[];const h=V(d),g=V(f);return c[h.queryID].map(C=>typeof C[g.columnKey]=="number"?C:{...C,[g.columnKey]:Number(C[g.columnKey])})},[e.data,t==null?void 0:t.regression.y_axis_data_key]),o=y.useMemo(()=>mm(x.defaultsDeep({},t,jr),a),[t,a]),l=y.useRef(null),u=c=>{l.current=c};return!n||!r||!t?null:p(s.Box,{sx:{position:"relative"},children:[i(km,{conf:t,queryData:a}),i(Ne,{echarts:oe,onChartReady:u,option:o,style:{width:n,height:r},notMerge:!0,theme:"merico-light"})]})}const Dm=[{label:"Linear",value:"linear"},{label:"Exponential",value:"exponential"},{label:"Logarithmic",value:"logarithmic"},{label:"Polynomial",value:"polynomial"}];function Mm({control:e,watch:t}){t("regression");const n=t("regression.transform.config.method"),r=t("regression.group_by_key");return p(s.Stack,{children:[i(s.Group,{grow:!0,noWrap:!0,children:i(v.Controller,{name:"regression.name",control:e,render:({field:a})=>i(s.TextInput,{label:"回归线名称",sx:{flex:1},...a})})}),i(v.Controller,{name:"regression.group_by_key",control:e,render:({field:a})=>i(j,{label:"按此字段将数据分为多个系列",clearable:!0,sx:{flex:1},...a})}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"regression.transform.config.method",control:e,render:({field:a})=>i(s.Select,{label:"回归方法",data:Dm,sx:{flex:1},...a})}),n==="polynomial"&&i(v.Controller,{name:"regression.transform.config.order",control:e,render:({field:a})=>i(s.NumberInput,{label:"次",sx:{flex:1},...a})})]}),!r&&p(s.Stack,{spacing:4,children:[i(s.Text,{size:"sm",children:"颜色"}),i(v.Controller,{name:"regression.plot.color",control:e,render:({field:a})=>i(Pe,{...a})})]})]})}const Im=({disabled:e,value:t,onChange:n})=>{const r=a=>{a&&n(a)};return p(s.Box,{sx:{position:"relative"},children:[e&&i(s.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),i(Ae,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},$s=y.forwardRef(({value:e,onChange:t,triggerButtonText:n="Customize Label"},r)=>{const[a,{setTrue:o,setFalse:l}]=X.useBoolean(),[u,c]=y.useState(e);y.useEffect(()=>{c(e)},[e]);const d=C=>{c({...u,enabled:C})},f=()=>{l();const{enabled:C,func_content:w}=u,_={enabled:C,func_content:w};c(_),t(_)},h=()=>{l(),c(e)},g=C=>{c(w=>({...w,func_content:C}))},m=()=>{g(Ln.func_content)};return p(B,{children:[i(s.Button,{variant:"filled",mt:24,onClick:o,sx:{flexGrow:0},children:n}),i(s.Modal,{size:800,title:"Customize label content",opened:a,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&p(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:u.enabled,onChange:C=>d(C.currentTarget.checked)}),i(Im,{value:u.func_content,onChange:g,disabled:!u.enabled}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:m,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Reset"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:h,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:f,children:"OK"})]})]})]})})]})});function Em({control:e,watch:t}){return t(["x_axis"]),p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.name",control:e,render:({field:n})=>i(s.TextInput,{label:"X轴名称",sx:{flex:1},...n})}),i(v.Controller,{name:"x_axis.data_key",control:e,render:({field:n})=>i(j,{label:"X轴数据字段",required:!0,sx:{flex:1},...n})})]}),i(s.Divider,{variant:"dashed",labelPosition:"center",label:"格式化数据"}),i(s.Stack,{children:i(v.Controller,{name:"x_axis.axisLabel.format",control:e,render:({field:n})=>i(Re,{...n})})}),i(s.Divider,{variant:"dashed",labelPosition:"center",label:"标签文案样式"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:n})=>i(s.NumberInput,{label:"旋转",hideControls:!0,min:-90,max:90,rightSection:i(s.Text,{color:"dimmed",children:"度"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),i(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>i($s,{triggerButtonText:"自定义标签文案内容",...n})})]}),i(v.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:n})=>i(mt,{...n})})]})}function Am({control:e,watch:t}){return t(["y_axis","regression.y_axis_data_key"]),i(s.Stack,{children:p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"y_axis.name",control:e,render:({field:n})=>i(s.TextInput,{label:"Y轴名称",sx:{flex:1},...n})}),i(v.Controller,{name:"regression.y_axis_data_key",control:e,render:({field:n})=>i(j,{label:"Y轴数据字段",required:!0,sx:{flex:1},...n})})]})})}function zm({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaults({},t,jr),[t]),{control:a,handleSubmit:o,watch:l,getValues:u,reset:c}=v.useForm({defaultValues:r});y.useEffect(()=>{c(r)},[r]),l(["x_axis","y_axis","regression"]);const d=u(),f=y.useMemo(()=>!x.isEqual(d,t),[d,t]);return i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!f,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Tabs,{defaultValue:"X轴",orientation:"vertical",styles:{panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"X轴",children:"X轴"}),i(s.Tabs.Tab,{value:"Y轴",children:"Y轴"}),i(s.Tabs.Tab,{value:"回归",children:"回归"})]}),i(s.Tabs.Panel,{value:"X轴",children:i(Em,{watch:l,control:a})}),i(s.Tabs.Panel,{value:"Y轴",children:i(Am,{watch:l,control:a})}),i(s.Tabs.Panel,{value:"回归",children:i(Mm,{control:a,watch:l})})]})]})})}function $m(e){const t={x_axis:{axisLabel:{rotate:0,format:$e,overflow:Ze,formatter:Ln}},regression:{group_by_key:""}};return x.defaultsDeep(t,e)}function Om(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis:a,regression:o,...l}=e;return{...l,x_axis:{...a,data_key:r(a.data_key)},regression:{...o,group_by_key:r(o.group_by_key),y_axis_data_key:r(o.y_axis_data_key)}}}catch(n){throw console.error("[Migration failed]",n),n}}class Lm extends be{constructor(){super(...arguments);q(this,"VERSION",3)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:$m(n.config)})),this.version(3,(n,r)=>{const{config:a}=n;return{...n,version:3,config:Om(a,r)}})}}const Pm={displayName:"Regression Chart",displayGroup:"Merico suite",migrator:new Lm,name:"regressionChart",viewRender:Tm,configRender:zm,createConfig(){return{version:3,config:x.cloneDeep(jr)}}},Pn={content:""},Rr={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"},blockquote:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45",margin:"0 0 14px"}};function Os(e,t,n){for(let r=0;;r++){if(r==e.childCount||r==t.childCount)return e.childCount==t.childCount?null:n;let a=e.child(r),o=t.child(r);if(a==o){n+=a.nodeSize;continue}if(!a.sameMarkup(o))return n;if(a.isText&&a.text!=o.text){for(let l=0;a.text[l]==o.text[l];l++)n++;return n}if(a.content.size||o.content.size){let l=Os(a.content,o.content,n+1);if(l!=null)return l}n+=a.nodeSize}}function Ls(e,t,n,r){for(let a=e.childCount,o=t.childCount;;){if(a==0||o==0)return a==o?null:{a:n,b:r};let l=e.child(--a),u=t.child(--o),c=l.nodeSize;if(l==u){n-=c,r-=c;continue}if(!l.sameMarkup(u))return{a:n,b:r};if(l.isText&&l.text!=u.text){let d=0,f=Math.min(l.text.length,u.text.length);for(;d<f&&l.text[l.text.length-d-1]==u.text[u.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(l.content.size||u.content.size){let d=Ls(l.content,u.content,n-1,r-1);if(d)return d}n-=c,r-=c}}class ie{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let r=0;r<t.length;r++)this.size+=t[r].nodeSize}nodesBetween(t,n,r,a=0,o){for(let l=0,u=0;u<n;l++){let c=this.content[l],d=u+c.nodeSize;if(d>t&&r(c,a+u,o||null,l)!==!1&&c.content.size){let f=u+1;c.nodesBetween(Math.max(0,t-f),Math.min(c.content.size,n-f),r,a+f)}u=d}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,r,a){let o="",l=!0;return this.nodesBetween(t,n,(u,c)=>{u.isText?(o+=u.text.slice(Math.max(t,c)-c,n-c),l=!r):u.isLeaf?(a?o+=typeof a=="function"?a(u):a:u.type.spec.leafText&&(o+=u.type.spec.leafText(u)),l=!r):!l&&u.isBlock&&(o+=r,l=!0)},0),o}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,r=t.firstChild,a=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(a[a.length-1]=n.withText(n.text+r.text),o=1);o<t.content.length;o++)a.push(t.content[o]);return new ie(a,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let r=[],a=0;if(n>t)for(let o=0,l=0;l<n;o++){let u=this.content[o],c=l+u.nodeSize;c>t&&((l<t||c>n)&&(u.isText?u=u.cut(Math.max(0,t-l),Math.min(u.text.length,n-l)):u=u.cut(Math.max(0,t-l-1),Math.min(u.content.size,n-l-1))),r.push(u),a+=u.nodeSize),l=c}return new ie(r,a)}cutByIndex(t,n){return t==n?ie.empty:t==0&&n==this.content.length?this:new ie(this.content.slice(t,n))}replaceChild(t,n){let r=this.content[t];if(r==n)return this;let a=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return a[t]=n,new ie(a,o)}addToStart(t){return new ie([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new ie(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,r=0;n<this.content.length;n++){let a=this.content[n];t(a,r,n),r+=a.nodeSize}}findDiffStart(t,n=0){return Os(this,t,n)}findDiffEnd(t,n=this.size,r=t.size){return Ls(this,t,n,r)}findIndex(t,n=-1){if(t==0)return Bn(0,t);if(t==this.size)return Bn(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let r=0,a=0;;r++){let o=this.child(r),l=a+o.nodeSize;if(l>=t)return l==t||n>0?Bn(r+1,l):Bn(r,a);a=l}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return ie.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new ie(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return ie.empty;let n,r=0;for(let a=0;a<t.length;a++){let o=t[a];r+=o.nodeSize,a&&o.isText&&t[a-1].sameMarkup(o)?(n||(n=t.slice(0,a)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new ie(n||t,r)}static from(t){if(!t)return ie.empty;if(t instanceof ie)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new ie([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}ie.empty=new ie([],0);const Yr={index:0,offset:0};function Bn(e,t){return Yr.index=e,Yr.offset=t,Yr}function Qr(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let r=0;r<e.length;r++)if(!Qr(e[r],t[r]))return!1}else{for(let r in e)if(!(r in t)||!Qr(e[r],t[r]))return!1;for(let r in t)if(!(r in e))return!1}return!0}class We{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,r=!1;for(let a=0;a<t.length;a++){let o=t[a];if(this.eq(o))return t;if(this.type.excludes(o.type))n||(n=t.slice(0,a));else{if(o.type.excludes(this.type))return t;!r&&o.type.rank>this.type.rank&&(n||(n=t.slice(0,a)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=t.slice()),r||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&Qr(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=t.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let r=0;r<t.length;r++)if(!t[r].eq(n[r]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return We.none;if(t instanceof We)return[t];let n=t.slice();return n.sort((r,a)=>r.type.rank-a.type.rank),n}}We.none=[];class Bm extends Error{}class ce{constructor(t,n,r){this.content=t,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let r=Bs(this.content,t+this.openStart,n);return r&&new ce(r,this.openStart,this.openEnd)}removeBetween(t,n){return new ce(Ps(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return ce.empty;let r=n.openStart||0,a=n.openEnd||0;if(typeof r!="number"||typeof a!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ce(ie.fromJSON(t,n.content),r,a)}static maxOpen(t,n=!0){let r=0,a=0;for(let o=t.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=t.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)a++;return new ce(t,r,a)}}ce.empty=new ce(ie.empty,0,0);function Ps(e,t,n){let{index:r,offset:a}=e.findIndex(t),o=e.maybeChild(r),{index:l,offset:u}=e.findIndex(n);if(a==t||o.isText){if(u!=n&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(r!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(r,o.copy(Ps(o.content,t-a-1,n-a-1)))}function Bs(e,t,n,r){let{index:a,offset:o}=e.findIndex(t),l=e.maybeChild(a);if(o==t||l.isText)return r&&!r.canReplace(a,a,n)?null:e.cut(0,t).append(n).append(e.cut(t));let u=Bs(l.content,t-o-1,n);return u&&e.replaceChild(a,l.copy(u))}class Vn{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let a=t.nodes[r.node];return a.contentMatch.matchType(a)})}parse(t,n={}){let r=new Fs(this,n,!1);return r.addAll(t,n.from,n.to),r.finish()}parseSlice(t,n={}){let r=new Fs(this,n,!0);return r.addAll(t,n.from,n.to),ce.maxOpen(r.finish())}matchTag(t,n,r){for(let a=r?this.tags.indexOf(r)+1:0;a<this.tags.length;a++){let o=this.tags[a];if(qm(t,o.tag)&&(o.namespace===void 0||t.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let l=o.getAttrs(t);if(l===!1)continue;o.attrs=l||void 0}return o}}}matchStyle(t,n,r,a){for(let o=a?this.styles.indexOf(a)+1:0;o<this.styles.length;o++){let l=this.styles[o],u=l.style;if(!(u.indexOf(t)!=0||l.context&&!r.matchesContext(l.context)||u.length>t.length&&(u.charCodeAt(t.length)!=61||u.slice(t.length+1)!=n))){if(l.getAttrs){let c=l.getAttrs(n);if(c===!1)continue;l.attrs=c||void 0}return l}}}static schemaRules(t){let n=[];function r(a){let o=a.priority==null?50:a.priority,l=0;for(;l<n.length;l++){let u=n[l];if((u.priority==null?50:u.priority)<o)break}n.splice(l,0,a)}for(let a in t.marks){let o=t.marks[a].spec.parseDOM;o&&o.forEach(l=>{r(l=Gs(l)),l.mark||l.ignore||l.clearMark||(l.mark=a)})}for(let a in t.nodes){let o=t.nodes[a].spec.parseDOM;o&&o.forEach(l=>{r(l=Gs(l)),l.node||l.ignore||l.mark||(l.node=a)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Vn(t,Vn.schemaRules(t)))}}const Vs={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},Vm={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ns={ol:!0,ul:!0},Nn=1,qn=2,Ht=4;function qs(e,t,n){return t!=null?(t?Nn:0)|(t==="full"?qn:0):e&&e.whitespace=="pre"?Nn|qn:n&~Ht}class Fn{constructor(t,n,r,a,o,l,u){this.type=t,this.attrs=n,this.marks=r,this.pendingMarks=a,this.solid=o,this.options=u,this.content=[],this.activeMarks=We.none,this.stashMarks=[],this.match=l||(u&Ht?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(ie.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,a;return(a=r.findWrapping(t.type))?(this.match=r,a):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Nn)){let r=this.content[this.content.length-1],a;if(r&&r.isText&&(a=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==a[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-a[0].length))}}let n=ie.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(ie.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(t){for(let n=this.stashMarks.length-1;n>=0;n--)if(t.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(t){for(let n=0,r=this.pendingMarks;n<r.length;n++){let a=r[n];(this.type?this.type.allowsMarkType(a.type):Gm(a.type,t))&&!a.isInSet(this.activeMarks)&&(this.activeMarks=a.addToSet(this.activeMarks),this.pendingMarks=a.removeFromSet(this.pendingMarks))}}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Vs.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Fs{constructor(t,n,r){this.parser=t,this.options=n,this.isOpen=r,this.open=0;let a=n.topNode,o,l=qs(null,n.preserveWhitespace,0)|(r?Ht:0);a?o=new Fn(a.type,a.attrs,We.none,We.none,!0,n.topMatch||a.type.contentMatch,l):r?o=new Fn(null,null,We.none,We.none,!0,null,l):o=new Fn(t.schema.topNodeType,null,We.none,We.none,!0,null,l),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t){if(t.nodeType==3)this.addTextNode(t);else if(t.nodeType==1){let n=t.getAttribute("style");if(!n)this.addElement(t);else{let r=this.readStyles(Fm(n));if(!r)return;let[a,o]=r,l=this.top;for(let u=0;u<o.length;u++)this.removePendingMark(o[u],l);for(let u=0;u<a.length;u++)this.addPendingMark(a[u]);this.addElement(t);for(let u=0;u<a.length;u++)this.removePendingMark(a[u],l);for(let u=0;u<o.length;u++)this.addPendingMark(o[u])}}}addTextNode(t){let n=t.nodeValue,r=this.top;if(r.options&qn||r.inlineContext(t)||/[^ \t\r\n\u000c]/.test(n)){if(r.options&Nn)r.options&qn?n=n.replace(/\r\n?/g,`
|
|
243
243
|
`):n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let a=r.content[r.content.length-1],o=t.previousSibling;(!a||o&&o.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n)),this.findInText(t)}else this.findInside(t)}addElement(t,n){let r=t.nodeName.toLowerCase(),a;Ns.hasOwnProperty(r)&&this.parser.normalizeLists&&Nm(t);let o=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(a=this.parser.matchTag(t,this,n));if(o?o.ignore:Vm.hasOwnProperty(r))this.findInside(t),this.ignoreFallback(t);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(t=o.skip);let l,u=this.top,c=this.needsBlock;if(Vs.hasOwnProperty(r))u.content.length&&u.content[0].isInline&&this.open&&(this.open--,u=this.top),l=!0,u.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t);return}this.addAll(t),l&&this.sync(u),this.needsBlock=c}else this.addElementByRule(t,o,o.consuming===!1?a:void 0)}leafFallback(t){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
|
|
244
244
|
`))}ignoreFallback(t){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(t){let n=We.none,r=We.none;for(let a=0;a<t.length;a+=2)for(let o=void 0;;){let l=this.parser.matchStyle(t[a],t[a+1],this,o);if(!l)break;if(l.ignore)return null;if(l.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(u=>{l.clearMark(u)&&(r=u.addToSet(r))}):n=this.parser.schema.marks[l.mark].create(l.attrs).addToSet(n),l.consuming===!1)o=l;else break}return[n,r]}addElementByRule(t,n,r){let a,o,l;n.node?(o=this.parser.schema.nodes[n.node],o.isLeaf?this.insertNode(o.create(n.attrs))||this.leafFallback(t):a=this.enter(o,n.attrs||null,n.preserveWhitespace)):(l=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(l));let u=this.top;if(o&&o.isLeaf)this.findInside(t);else if(r)this.addElement(t,r);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(c=>this.insertNode(c));else{let c=t;typeof n.contentElement=="string"?c=t.querySelector(n.contentElement):typeof n.contentElement=="function"?c=n.contentElement(t):n.contentElement&&(c=n.contentElement),this.findAround(t,c,!0),this.addAll(c)}a&&this.sync(u)&&this.open--,l&&this.removePendingMark(l,u)}addAll(t,n,r){let a=n||0;for(let o=n?t.childNodes[n]:t.firstChild,l=r==null?null:t.childNodes[r];o!=l;o=o.nextSibling,++a)this.findAtPoint(t,a),this.addDOM(o);this.findAtPoint(t,a)}findPlace(t){let n,r;for(let a=this.open;a>=0;a--){let o=this.nodes[a],l=o.findWrapping(t);if(l&&(!n||n.length>l.length)&&(n=l,r=o,!l.length)||o.solid)break}if(!n)return!1;this.sync(r);for(let a=0;a<n.length;a++)this.enterInner(n[a],null,!1);return!0}insertNode(t){if(t.isInline&&this.needsBlock&&!this.top.type){let n=this.textblockFromContext();n&&this.enterInner(n)}if(this.findPlace(t)){this.closeExtra();let n=this.top;n.applyPending(t.type),n.match&&(n.match=n.match.matchType(t.type));let r=n.activeMarks;for(let a=0;a<t.marks.length;a++)(!n.type||n.type.allowsMarkType(t.marks[a].type))&&(r=t.marks[a].addToSet(r));return n.content.push(t.mark(r)),!0}return!1}enter(t,n,r){let a=this.findPlace(t.create(n));return a&&this.enterInner(t,n,!0,r),a}enterInner(t,n=null,r=!1,a){this.closeExtra();let o=this.top;o.applyPending(t),o.match=o.match&&o.match.matchType(t);let l=qs(t,a,o.options);o.options&Ht&&o.content.length==0&&(l|=Ht),this.nodes.push(new Fn(t,n,o.activeMarks,o.pendingMarks,r,null,l)),this.open++}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let n=this.open;n>=0;n--)if(this.nodes[n]==t)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let a=r.length-1;a>=0;a--)t+=r[a].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==t&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,r){if(t!=n&&this.find)for(let a=0;a<this.find.length;a++)this.find[a].pos==null&&t.nodeType==1&&t.contains(this.find[a].node)&&n.compareDocumentPosition(this.find[a].node)&(r?2:4)&&(this.find[a].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),r=this.options.context,a=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(a?0:1),l=(u,c)=>{for(;u>=0;u--){let d=n[u];if(d==""){if(u==n.length-1||u==0)continue;for(;c>=o;c--)if(l(u-1,c))return!0;return!1}else{let f=c>0||c==0&&a?this.nodes[c].type:r&&c>=o?r.node(c-o).type:null;if(!f||f.name!=d&&f.groups.indexOf(d)==-1)return!1;c--}}return!0};return l(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(t){let n=Wm(t,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)}removePendingMark(t,n){for(let r=this.open;r>=0;r--){let a=this.nodes[r];if(a.pendingMarks.lastIndexOf(t)>-1)a.pendingMarks=t.removeFromSet(a.pendingMarks);else{a.activeMarks=t.removeFromSet(a.activeMarks);let l=a.popFromStashMark(t);l&&a.type&&a.type.allowsMarkType(l.type)&&(a.activeMarks=l.addToSet(a.activeMarks))}if(a==n)break}}}function Nm(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let r=t.nodeType==1?t.nodeName.toLowerCase():null;r&&Ns.hasOwnProperty(r)&&n?(n.appendChild(t),t=n):r=="li"?n=t:r&&(n=null)}}function qm(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function Fm(e){let t=/\s*([\w-]+)\s*:\s*([^;]+)/g,n,r=[];for(;n=t.exec(e);)r.push(n[1],n[2].trim());return r}function Gs(e){let t={};for(let n in e)t[n]=e[n];return t}function Gm(e,t){let n=t.schema.nodes;for(let r in n){let a=n[r];if(!a.allowsMarkType(e))continue;let o=[],l=u=>{o.push(u);for(let c=0;c<u.edgeCount;c++){let{type:d,next:f}=u.edge(c);if(d==t||o.indexOf(f)<0&&l(f))return!0}};if(l(a.contentMatch))return!0}}function Wm(e,t){for(let n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}const Ws=65535,js=Math.pow(2,16);function jm(e,t){return e+t*js}function Rs(e){return e&Ws}function Rm(e){return(e-(e&Ws))/js}const Ys=1,Qs=2,Gn=4,Ks=8;class Us{constructor(t,n,r){this.pos=t,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&Ks)>0}get deletedBefore(){return(this.delInfo&(Ys|Gn))>0}get deletedAfter(){return(this.delInfo&(Qs|Gn))>0}get deletedAcross(){return(this.delInfo&Gn)>0}}class Ye{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&Ye.empty)return Ye.empty}recover(t){let n=0,r=Rs(t);if(!this.inverted)for(let a=0;a<r;a++)n+=this.ranges[a*3+2]-this.ranges[a*3+1];return this.ranges[r*3]+n+Rm(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,r){let a=0,o=this.inverted?2:1,l=this.inverted?1:2;for(let u=0;u<this.ranges.length;u+=3){let c=this.ranges[u]-(this.inverted?a:0);if(c>t)break;let d=this.ranges[u+o],f=this.ranges[u+l],h=c+d;if(t<=h){let g=d?t==c?-1:t==h?1:n:n,m=c+a+(g<0?0:f);if(r)return m;let C=t==(n<0?c:h)?null:jm(u/3,t-c),w=t==c?Qs:t==h?Ys:Gn;return(n<0?t!=c:t!=h)&&(w|=Ks),new Us(m,w,C)}a+=f-d}return r?t+a:new Us(t+a,0,null)}touches(t,n){let r=0,a=Rs(n),o=this.inverted?2:1,l=this.inverted?1:2;for(let u=0;u<this.ranges.length;u+=3){let c=this.ranges[u]-(this.inverted?r:0);if(c>t)break;let d=this.ranges[u+o],f=c+d;if(t<=f&&u==a*3)return!0;r+=this.ranges[u+l]-d}return!1}forEach(t){let n=this.inverted?2:1,r=this.inverted?1:2;for(let a=0,o=0;a<this.ranges.length;a+=3){let l=this.ranges[a],u=l-(this.inverted?o:0),c=l+(this.inverted?0:o),d=this.ranges[a+n],f=this.ranges[a+r];t(u,u+d,c,c+f),o+=f-d}}invert(){return new Ye(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?Ye.empty:new Ye(t<0?[0,-t,0]:[0,0,t])}}Ye.empty=new Ye([]);const Kr=Object.create(null);class Ge{getMap(){return Ye.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=Kr[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in Kr)throw new RangeError("Duplicate use of step JSON ID "+t);return Kr[t]=n,n.prototype.jsonID=t,n}}class Te{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new Te(t,null)}static fail(t){return new Te(null,t)}static fromReplace(t,n,r,a){try{return Te.ok(t.replace(n,r,a))}catch(o){if(o instanceof Bm)return Te.fail(o.message);throw o}}}function Ur(e,t,n){let r=[];for(let a=0;a<e.childCount;a++){let o=e.child(a);o.content.size&&(o=o.copy(Ur(o.content,t,o))),o.isInline&&(o=t(o,n,a)),r.push(o)}return ie.fromArray(r)}class Dt extends Ge{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=t.resolve(this.from),a=r.node(r.sharedDepth(this.to)),o=new ce(Ur(n.content,(l,u)=>!l.isAtom||!u.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),a),n.openStart,n.openEnd);return Te.fromReplace(t,this.from,this.to,o)}invert(){return new Mt(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Dt(n.pos,r.pos,this.mark)}merge(t){return t instanceof Dt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Dt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Dt(n.from,n.to,t.markFromJSON(n.mark))}}Ge.jsonID("addMark",Dt);class Mt extends Ge{constructor(t,n,r){super(),this.from=t,this.to=n,this.mark=r}apply(t){let n=t.slice(this.from,this.to),r=new ce(Ur(n.content,a=>a.mark(this.mark.removeFromSet(a.marks)),t),n.openStart,n.openEnd);return Te.fromReplace(t,this.from,this.to,r)}invert(){return new Dt(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Mt(n.pos,r.pos,this.mark)}merge(t){return t instanceof Mt&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Mt(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Mt(n.from,n.to,t.markFromJSON(n.mark))}}Ge.jsonID("removeMark",Mt);class It extends Ge{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return Te.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Te.fromReplace(t,this.pos,this.pos+1,new ce(ie.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let a=0;a<n.marks.length;a++)if(!n.marks[a].isInSet(r))return new It(this.pos,n.marks[a]);return new It(this.pos,this.mark)}}return new en(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new It(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new It(n.pos,t.markFromJSON(n.mark))}}Ge.jsonID("addNodeMark",It);class en extends Ge{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return Te.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return Te.fromReplace(t,this.pos,this.pos+1,new ce(ie.from(r),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new It(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new en(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new en(n.pos,t.markFromJSON(n.mark))}}Ge.jsonID("removeNodeMark",en);class it extends Ge{constructor(t,n,r,a=!1){super(),this.from=t,this.to=n,this.slice=r,this.structure=a}apply(t){return this.structure&&Xr(t,this.from,this.to)?Te.fail("Structure replace would overwrite content"):Te.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new Ye([this.from,this.to-this.from,this.slice.size])}invert(t){return new it(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new it(n.pos,Math.max(n.pos,r.pos),this.slice)}merge(t){if(!(t instanceof it)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?ce.empty:new ce(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new it(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?ce.empty:new ce(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new it(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new it(n.from,n.to,ce.fromJSON(t,n.slice),!!n.structure)}}Ge.jsonID("replace",it);class Et extends Ge{constructor(t,n,r,a,o,l,u=!1){super(),this.from=t,this.to=n,this.gapFrom=r,this.gapTo=a,this.slice=o,this.insert=l,this.structure=u}apply(t){if(this.structure&&(Xr(t,this.from,this.gapFrom)||Xr(t,this.gapTo,this.to)))return Te.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return Te.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?Te.fromReplace(t,this.from,this.to,r):Te.fail("Content does not fit in gap")}getMap(){return new Ye([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new Et(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),a=t.map(this.gapFrom,-1),o=t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||a<n.pos||o>r.pos?null:new Et(n.pos,r.pos,a,o,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Et(n.from,n.to,n.gapFrom,n.gapTo,ce.fromJSON(t,n.slice),n.insert,!!n.structure)}}Ge.jsonID("replaceAround",Et);function Xr(e,t,n){let r=e.resolve(t),a=n-t,o=r.depth;for(;a>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,a--;if(a>0){let l=r.node(o).maybeChild(r.indexAfter(o));for(;a>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,a--}}return!1}function Ym(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Qm(e){let n=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let r=e.depth;;--r){let a=e.$from.node(r),o=e.$from.index(r),l=e.$to.indexAfter(r);if(r<e.depth&&a.canReplace(o,l,n))return r;if(r==0||a.type.spec.isolating||!Ym(a,o,l))break}return null}function Wn(e,t,n=1,r){let a=e.resolve(t),o=a.depth-n,l=r&&r[r.length-1]||a.parent;if(o<0||a.parent.type.spec.isolating||!a.parent.canReplace(a.index(),a.parent.childCount)||!l.type.validContent(a.parent.content.cutByIndex(a.index(),a.parent.childCount)))return!1;for(let d=a.depth-1,f=n-2;d>o;d--,f--){let h=a.node(d),g=a.index(d);if(h.type.spec.isolating)return!1;let m=h.content.cutByIndex(g,h.childCount),C=r&&r[f+1];C&&(m=m.replaceChild(0,C.type.create(C.attrs)));let w=r&&r[f]||h;if(!h.canReplace(g+1,h.childCount)||!w.type.validContent(m))return!1}let u=a.indexAfter(o),c=r&&r[0];return a.node(o).canReplaceWith(u,u,c?c.type:a.node(o+1).type)}function Xs(e,t){let n=e.resolve(t),r=n.index();return Km(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Km(e,t){return!!(e&&t&&!e.isLeaf&&e.canAppend(t))}class tn extends Ge{constructor(t,n,r){super(),this.pos=t,this.attr=n,this.value=r}apply(t){let n=t.nodeAt(this.pos);if(!n)return Te.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let a=n.type.create(r,null,n.marks);return Te.fromReplace(t,this.pos,this.pos+1,new ce(ie.from(a),0,n.isLeaf?0:1))}getMap(){return Ye.empty}invert(t){return new tn(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new tn(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new tn(n.pos,n.attr,n.value)}}Ge.jsonID("attr",tn);let nn=class extends Error{};nn=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},nn.prototype=Object.create(Error.prototype),nn.prototype.constructor=nn,nn.prototype.name="TransformError";const Jr=Object.create(null);class he{constructor(t,n,r){this.$anchor=t,this.$head=n,this.ranges=r||[new Um(t.min(n),t.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let n=0;n<t.length;n++)if(t[n].$from.pos!=t[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,n=ce.empty){let r=n.content.lastChild,a=null;for(let u=0;u<n.openEnd;u++)a=r,r=r.lastChild;let o=t.steps.length,l=this.ranges;for(let u=0;u<l.length;u++){let{$from:c,$to:d}=l[u],f=t.mapping.slice(o);t.replaceRange(f.map(c.pos),f.map(d.pos),u?ce.empty:n),u==0&&Hs(t,o,(r?r.isInline:a&&a.isTextblock)?-1:1)}}replaceWith(t,n){let r=t.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:l,$to:u}=a[o],c=t.mapping.slice(r),d=c.map(l.pos),f=c.map(u.pos);o?t.deleteRange(d,f):(t.replaceRangeWith(d,f,n),Hs(t,r,n.isInline?-1:1))}}static findFrom(t,n,r=!1){let a=t.parent.inlineContent?new De(t):Nt(t.node(0),t.parent,t.pos,t.index(),n,r);if(a)return a;for(let o=t.depth-1;o>=0;o--){let l=n<0?Nt(t.node(0),t.node(o),t.before(o+1),t.index(o),n,r):Nt(t.node(0),t.node(o),t.after(o+1),t.index(o)+1,n,r);if(l)return l}return null}static near(t,n=1){return this.findFrom(t,n)||this.findFrom(t,-n)||new dt(t.node(0))}static atStart(t){return Nt(t,t,0,0,1)||new dt(t)}static atEnd(t){return Nt(t,t,t.content.size,t.childCount,-1)||new dt(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=Jr[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(t,n)}static jsonID(t,n){if(t in Jr)throw new RangeError("Duplicate use of selection JSON ID "+t);return Jr[t]=n,n.prototype.jsonID=t,n}getBookmark(){return De.between(this.$anchor,this.$head).getBookmark()}}he.prototype.visible=!0;class Um{constructor(t,n){this.$from=t,this.$to=n}}let Js=!1;function Zs(e){!Js&&!e.parent.inlineContent&&(Js=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class De extends he{constructor(t,n=t){Zs(t),Zs(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return he.near(r);let a=t.resolve(n.map(this.anchor));return new De(a.parent.inlineContent?a:r,r)}replace(t,n=ce.empty){if(super.replace(t,n),n==ce.empty){let r=this.$from.marksAcross(this.$to);r&&t.ensureMarks(r)}}eq(t){return t instanceof De&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new jn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new De(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,r=n){let a=t.resolve(n);return new this(a,r==n?a:t.resolve(r))}static between(t,n,r){let a=t.pos-n.pos;if((!r||a)&&(r=a>=0?1:-1),!n.parent.inlineContent){let o=he.findFrom(n,r,!0)||he.findFrom(n,-r,!0);if(o)n=o.$head;else return he.near(n,r)}return t.parent.inlineContent||(a==0?t=n:(t=(he.findFrom(t,-r,!0)||he.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=a<0&&(t=n))),new De(t,n)}}he.jsonID("text",De);class jn{constructor(t,n){this.anchor=t,this.head=n}map(t){return new jn(t.map(this.anchor),t.map(this.head))}resolve(t){return De.between(t.resolve(this.anchor),t.resolve(this.head))}}class je extends he{constructor(t){let n=t.nodeAfter,r=t.node(0).resolve(t.pos+n.nodeSize);super(t,r),this.node=n}map(t,n){let{deleted:r,pos:a}=n.mapResult(this.anchor),o=t.resolve(a);return r?he.near(o):new je(o)}content(){return new ce(ie.from(this.node),0,0)}eq(t){return t instanceof je&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new Zr(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new je(t.resolve(n.anchor))}static create(t,n){return new je(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}je.prototype.visible=!1,he.jsonID("node",je);class Zr{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new jn(r,r):new Zr(r)}resolve(t){let n=t.resolve(this.anchor),r=n.nodeAfter;return r&&je.isSelectable(r)?new je(n):he.near(n)}}class dt extends he{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=ce.empty){if(n==ce.empty){t.delete(0,t.doc.content.size);let r=he.atStart(t.doc);r.eq(t.selection)||t.setSelection(r)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new dt(t)}map(t){return new dt(t)}eq(t){return t instanceof dt}getBookmark(){return Xm}}he.jsonID("all",dt);const Xm={map(){return this},resolve(e){return new dt(e)}};function Nt(e,t,n,r,a,o=!1){if(t.inlineContent)return De.create(e,n);for(let l=r-(a>0?0:1);a>0?l<t.childCount:l>=0;l+=a){let u=t.child(l);if(u.isAtom){if(!o&&je.isSelectable(u))return je.create(e,n-(a<0?u.nodeSize:0))}else{let c=Nt(e,u,n+a,a<0?u.childCount:0,a,o);if(c)return c}n+=u.nodeSize*a}return null}function Hs(e,t,n){let r=e.steps.length-1;if(r<t)return;let a=e.steps[r];if(!(a instanceof it||a instanceof Et))return;let o=e.mapping.maps[r],l;o.forEach((u,c,d,f)=>{l==null&&(l=f)}),e.setSelection(he.near(e.doc.resolve(l),n))}function eo(e,t){return!t||!e?e:e.bind(t)}class Rn{constructor(t,n,r){this.name=t,this.init=eo(n.init,r),this.apply=eo(n.apply,r)}}new Rn("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Rn("selection",{init(e,t){return e.selection||he.atStart(t.doc)},apply(e){return e.selection}}),new Rn("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new Rn("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}});function to(e,t,n){for(let r in e){let a=e[r];a instanceof Function?a=a.bind(t):r=="handleDOMEvents"&&(a=to(a,t,{})),n[r]=a}return n}class rn{constructor(t){this.spec=t,this.props={},t.props&&to(t.props,this,this.props),this.key=t.key?t.key.key:no("plugin")}getState(t){return t[this.key]}}const Hr=Object.create(null);function no(e){return e in Hr?e+"$"+ ++Hr[e]:(Hr[e]=0,e+"$")}class an{constructor(t="key"){this.key=no(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}function ro(e){const{state:t,transaction:n}=e;let{selection:r}=n,{doc:a}=n,{storedMarks:o}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),filterTransaction:t.filterTransaction,plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return o},get selection(){return r},get doc(){return a},get tr(){return r=n.selection,a=n.doc,o=n.storedMarks,n}}}class Jm{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:n,state:r}=this,{view:a}=n,{tr:o}=r,l=this.buildProps(o);return Object.fromEntries(Object.entries(t).map(([u,c])=>[u,(...f)=>{const h=c(...f)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&a.dispatch(o),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){const{rawCommands:r,editor:a,state:o}=this,{view:l}=a,u=[],c=!!t,d=t||o.tr,f=()=>(!c&&n&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(d),u.every(g=>g===!0)),h={...Object.fromEntries(Object.entries(r).map(([g,m])=>[g,(...w)=>{const _=this.buildProps(d,n),T=m(...w)(_);return u.push(T),h}])),run:f};return h}createCan(t){const{rawCommands:n,state:r}=this,a=!1,o=t||r.tr,l=this.buildProps(o,a);return{...Object.fromEntries(Object.entries(n).map(([c,d])=>[c,(...f)=>d(...f)({...l,dispatch:void 0})])),chain:()=>this.createChain(o,a)}}buildProps(t,n=!0){const{rawCommands:r,editor:a,state:o}=this,{view:l}=a;o.storedMarks&&t.setStoredMarks(o.storedMarks);const u={tr:t,editor:a,view:l,state:ro({state:o,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(r).map(([c,d])=>[c,(...f)=>d(...f)(u)]))}};return u}}function vt(e,t,n){return e.config[t]===void 0&&e.parent?vt(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?vt(e.parent,t,n):null}):e.config[t]}function Zm(e){const t=e.filter(a=>a.type==="extension"),n=e.filter(a=>a.type==="node"),r=e.filter(a=>a.type==="mark");return{baseExtensions:t,nodeExtensions:n,markExtensions:r}}function Oe(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function Hm(e){return typeof e=="function"}function qt(e,t=void 0,...n){return Hm(e)?t?e.bind(t)(...n):e(...n):e}function ey(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function ty(e){return Object.prototype.toString.call(e).slice(8,-1)}function ei(e){return ty(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function io(e,t){const n={...e};return ei(e)&&ei(t)&&Object.keys(t).forEach(r=>{ei(t[r])?r in e?n[r]=io(e[r],t[r]):Object.assign(n,{[r]:t[r]}):Object.assign(n,{[r]:t[r]})}),n}class at{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=qt(vt(this,"addOptions",{name:this.name}))),this.storage=qt(vt(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new at(t)}configure(t={}){const n=this.extend();return n.options=io(this.options,t),n.storage=qt(vt(n,"addStorage",{name:n.name,options:n.options})),n}extend(t={}){const n=new at(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=qt(vt(n,"addOptions",{name:n.name})),n.storage=qt(vt(n,"addStorage",{name:n.name,options:n.options})),n}}function ny(e,t,n){const{from:r,to:a}=t,{blockSeparator:o=`
|
|
245
245
|
|
|
@@ -273,7 +273,7 @@ Check the top-level render call using <`+P+">.")}return z}}function bu(S,z){{if(
|
|
|
273
273
|
<tbody>${f.join("")}</tbody>
|
|
274
274
|
</table>
|
|
275
275
|
`}}}function zb(e,t){const n=t.every(a=>!Number.isNaN(Number(a))),{axisLabel:r}=e.x_axis;return[{data:t,name:e.x_axis.name??"",id:"main-x-axis",axisTick:{show:!0,alignWithLabel:!0},type:n?"value":"category",axisLabel:{...r,formatter:bo(r.formatter)}}]}function $b(e,t){return e.y_axes.map(({nameAlignment:n,min:r,max:a,...o},l)=>{let u=o.position;return u||(u=l>0?"right":"left"),{...o,min:r||void 0,max:a||void 0,position:u,axisLabel:{show:!0,formatter:t[l]??t.default},axisLine:{show:!0},nameTextStyle:{fontWeight:"bold",align:n},nameLocation:"end",nameGap:15,splitLine:{show:!1}}})}const Ob={xAxis:[{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"},splitLine:{show:!1},axisTick:{show:!0,alignWithLabel:!0}}],grid:{top:10,left:20,right:15,bottom:25,containLabel:!0}};function Lb(e,t,n){const r=n.reduce((c,d)=>{const f=bt(d,t);return c[d.name]=tt(d,f),c},{}),a=e.y_axes.reduce((c,{label_formatter:d},f)=>(c[f]=function(g){let m=g;if(typeof g=="object"&&(Array.isArray(g.value)&&g.value.length===2?m=g.value[1]:m=g.value),!d)return m;try{return H(m).format(d)}catch(C){return console.error(C),m}},c),{default:({value:c})=>c}),o=x.uniq(ut(t,e.x_axis.data_key)),l=Mb(e,t,n,r),u={xAxis:zb(e,o),yAxis:$b(e,a),series:l,dataset:xb(e,t),tooltip:Ab(e,a),grid:wb(e),legend:Cb(),dataZoom:Or(e.dataZoom)};return x.defaultsDeep({},u,Ob)}oe.use([G.DataZoomComponent,pe.BarChart,pe.LineChart,pe.ScatterChart,G.GridComponent,G.LegendComponent,G.TooltipComponent,Ve.CanvasRenderer,G.MarkLineComponent,G.MarkAreaComponent]);function xo(e){return e.trim().length>0}function Pb({conf:e,data:t,width:n,height:r,interactionManager:a,variables:o}){const l=Tt(t,e.x_axis.data_key),u=He(a.triggerManager,go.id),c=y.useCallback(h=>{const g=h.data;u.forEach(m=>{a.runInteraction(m.id,{...h,rowData:g})})},[l,u,a]),d=y.useMemo(()=>({click:c}),[c]),f=y.useMemo(()=>Lb(e,t,o),[e,t]);return i(Ne,{echarts:oe,option:f,style:{width:n,height:r},onEvents:d,notMerge:!0,theme:"merico-light"})}function Bb({context:e,instance:t}){const n=et({vizManager:e.vizManager,instance:t}),{value:r}=W(e.instanceData,"config"),{variables:a}=e,o=y.useMemo(()=>x.defaults({},r,li),[r]),l=e.data,{width:u,height:c}=e.viewport,{ref:d,height:f}=Ee.useElementSize(),{ref:h,height:g}=Ee.useElementSize(),m=y.useMemo(()=>{const{stats:{templates:w}}=o;return{top:Zt(w.top,a,l),bottom:Zt(w.bottom,a,l)}},[o,l]),C=Math.max(0,c-f-g);return!u||!c?null:p(s.Box,{children:[i(s.Text,{ref:d,align:"left",size:"xs",pl:"sm",sx:{display:xo(o.stats.templates.top)?"block":"none"},children:Object.values(m.top).map(w=>w)}),i(Pb,{variables:a,width:u,height:C,data:l,conf:o,interactionManager:n}),i(s.Text,{ref:h,align:"left",size:"xs",pl:"sm",sx:{display:xo(o.stats.templates.bottom)?"block":"none"},children:Object.values(m.bottom).map(w=>w)})]})}const Vb=y.forwardRef(({value:e,onChange:t,xAxisOptions:n,yAxisOptions:r,variableOptions:a},o)=>{const l=(u,c)=>{const d=x.cloneDeep(e);x.set(d,u,c),t(d)};return p(s.Stack,{children:[i(s.Divider,{mb:-15,variant:"dashed",label:"Content",labelPosition:"right"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(s.TextInput,{label:"Content Text",value:e.content.text,onChange:u=>l("content.text",u.currentTarget.value)}),i(Nr,{label:"Text Position",value:e.label.position,onChange:u=>l("label.position",u)})]}),i(s.Divider,{mb:-15,variant:"dashed",label:"Endpoints",labelPosition:"right"}),p(s.Group,{grow:!0,noWrap:!0,children:[n&&i(s.Select,{label:"X Axis",data:n,value:e.xAxisIndex,onChange:u=>l("xAxisIndex",u)}),r&&i(s.Select,{label:"Y Axis",data:r,value:e.yAxisIndex,onChange:u=>l("xAxisIndex",u)})]}),p(s.Stack,{spacing:0,children:[i(s.Text,{size:14,color:"#212529",fw:500,children:"Left-Bottom Point"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(s.Select,{icon:i(s.Text,{children:"x"}),data:a,value:e.leftBottomPoint.x_data_key,onChange:u=>l("leftBottomPoint.x_data_key",u??""),clearable:!0}),i(s.Select,{icon:i(s.Text,{children:"y"}),data:a,value:e.leftBottomPoint.y_data_key,onChange:u=>l("leftBottomPoint.y_data_key",u??""),clearable:!0})]})]}),p(s.Stack,{spacing:0,children:[i(s.Text,{size:14,color:"#212529",fw:500,children:"Right-Top Point"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(s.Select,{icon:i(s.Text,{children:"x"}),data:a,value:e.rightTopPoint.x_data_key,onChange:u=>l("rightTopPoint.x_data_key",u??""),clearable:!0}),i(s.Select,{icon:i(s.Text,{children:"y"}),data:a,value:e.rightTopPoint.y_data_key,onChange:u=>l("rightTopPoint.y_data_key",u??""),clearable:!0})]})]}),i(s.Divider,{mb:-15,variant:"dashed",label:"Style",labelPosition:"right"}),p(s.Stack,{spacing:4,children:[i(s.Text,{size:14,children:"Background Color"}),i(Pe,{value:e.itemStyle.color,onChange:u=>l("itemStyle.color",u)})]}),p(s.Stack,{spacing:4,children:[i(s.Text,{size:14,children:"Text Color"}),i(Pe,{value:e.label.color,onChange:u=>l("label.color",u)})]})]})});function Nb(){const e=new Date().getTime().toString();return{id:e,content:{text:e},itemStyle:{color:"rgba(0,0,0,0.05)"},label:{position:"inside",color:"rgba(0,0,0,0.5)"},leftBottomPoint:{x_data_key:"",y_data_key:""},rightTopPoint:{x_data_key:"",y_data_key:""},xAxisIndex:"0",yAxisIndex:"0"}}function qb({control:e,watch:t,variables:n}){const{fields:r,append:a,remove:o}=v.useFieldArray({control:e,name:"reference_areas"}),l=t("reference_areas"),u=r.map((g,m)=>({...g,...l[m]})),c=()=>{const g=Nb();a(g)},d=y.useMemo(()=>n.map(g=>({label:g.name,value:g.name})),[n]),f=t("y_axes"),h=y.useMemo(()=>f.map(({name:g},m)=>({label:g,value:m.toString()})),[f]);return p(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px"}},children:[p(s.Tabs.List,{children:[u.map((g,m)=>i(s.Tabs.Tab,{value:m.toString(),children:m+1},m)),i(s.Tabs.Tab,{onClick:c,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),u.map((g,m)=>i(s.Tabs.Panel,{value:m.toString(),children:i(v.Controller,{name:`reference_areas.${m}`,control:e,render:({field:C})=>p(s.Stack,{children:[i(Vb,{variableOptions:d,yAxisOptions:h,...C}),i(s.Divider,{mb:-10,mt:10,variant:"dashed"}),i(s.Button,{leftIcon:i($.IconTrash,{size:16}),color:"red",variant:"light",onClick:()=>o(m),children:"Delete this Reference Area"})]})})},m))]})}const Fb=[{label:"solid",value:"solid"},{label:"dashed",value:"dashed"},{label:"dotted",value:"dotted"}],Gb=[{label:"Horizontal",value:"horizontal"},{label:"Vertical",value:"vertical"}];function Wb({control:e,index:t,remove:n,watch:r,variableOptions:a,yAxisOptions:o}){const l=r(`reference_lines.${t}.orientation`);return p(s.Stack,{my:0,p:0,sx:{position:"relative"},children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:u})=>i(s.TextInput,{label:"Name",placeholder:"Average Reference Line",required:!0,sx:{flex:1},...u})}),i(v.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:u})=>i(s.Select,{label:"Value",required:!0,data:a,sx:{flex:1},...u})})]}),i(v.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:u})=>i(s.TextInput,{label:"Content Template",placeholder:"Average: ${avg}",sx:{flex:1},...u})}),p(s.Group,{grow:!0,children:[p(s.Stack,{children:[i(v.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:u})=>i(s.Select,{label:"Orientation",data:Gb,required:!0,sx:{flex:1},...u})}),l==="vertical"&&i(s.Text,{mt:-10,color:"dimmed",size:12,children:"Works only when xAxis values are numbers"})]}),l==="horizontal"&&i(v.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:u,onChange:c,...d}})=>i(s.Select,{label:"Y Axis",data:o,disabled:o.length===0,...d,value:(u==null?void 0:u.toString())??"",onChange:f=>{if(!f){c(0);return}c(Number(f))},sx:{flex:1}})})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed",label:"Style",labelPosition:"center"}),p(s.Group,{grow:!0,children:[i(v.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:u})=>i(s.Select,{label:"Line Type",data:Fb,sx:{flexGrow:1},...u})}),i(v.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:u})=>i(s.NumberInput,{label:"Line Width",min:1,max:10,sx:{flexGrow:1},...u})})]}),p(s.Stack,{spacing:4,children:[i(s.Text,{size:"sm",children:"Color"}),i(v.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:u})=>i(Pe,{...u})})]}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),sx:{top:15,right:5},children:"Delete this Reference Line"})]},t)}function jb({control:e,watch:t,variables:n}){const{fields:r,append:a,remove:o}=v.useFieldArray({control:e,name:"reference_lines"}),l=t("reference_lines"),u=r.map((g,m)=>({...g,...l[m]})),c=()=>{const g={name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:ot.random().css()},show_in_legend:!1,yAxisIndex:0};a(g)},d=y.useMemo(()=>n.map(g=>({label:g.name,value:g.name})),[n]),f=t("y_axes"),h=y.useMemo(()=>f.map(({name:g},m)=>({label:g,value:m.toString()})),[f]);return p(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px"}},children:[p(s.Tabs.List,{children:[u.map((g,m)=>i(s.Tabs.Tab,{value:m.toString(),children:m+1},m)),i(s.Tabs.Tab,{onClick:c,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),u.map((g,m)=>i(s.Tabs.Panel,{value:m.toString(),children:i(Wb,{control:e,index:m,remove:o,watch:t,variableOptions:d,yAxisOptions:h})},m))]})}const Rb=({value:e,onChange:t})=>{const n=r=>{r&&t(r)};return i(s.Box,{children:i(Ae,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Yb=({value:e,onChange:t})=>{const[n,{setTrue:r,setFalse:a}]=X.useBoolean(),[o,l]=y.useState(e),u=()=>{a();const{type:h,func_content:g}=o,m={type:h,func_content:g};l(m),t(m)},c=()=>{a(),l(e)},d=h=>{l(g=>({...g,func_content:h}))},f=()=>{d(sn.dynamic.func_content)};return p(B,{children:[i(s.Box,{sx:{width:"50%"},children:i(s.Button,{variant:"filled",mt:24,onClick:r,sx:{flexGrow:0},children:"Setup"})}),i(s.Modal,{size:800,title:"Setup dynamic color",opened:n,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:n&&p(s.Stack,{children:[i(s.Divider,{mt:10,mb:-10,label:"Dynamic by a custom function",labelPosition:"center",variant:"dashed"}),i(Rb,{value:o.func_content,onChange:d}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:f,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Reset"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:c,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:u,children:"OK"})]})]})]})})]})},Qb=({value:e,onChange:t})=>e.type!=="dynamic"?null:i(Yb,{value:e,onChange:t}),Kb=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=r=>{t({...e,color:r})};return i(s.ColorInput,{label:" ",format:"rgb",value:e.color,onChange:n})},Ub=[{label:"Static",value:"static"},{label:"Dynamic",value:"dynamic"}],Xb=y.forwardRef(({label:e="Color",value:t,onChange:n},r)=>{const a=o=>{n({...sn[o]})};return p(s.SimpleGrid,{cols:2,children:[i(s.Select,{ref:r,label:e,data:Ub,value:t.type,onChange:a,sx:{flexGrow:1}}),i(Kb,{value:t,onChange:n}),i(Qb,{value:t,onChange:n})]})}),Jb=y.forwardRef(({value:e,onChange:t},n)=>{const r=o=>{t({...e,label:o})},a=o=>{t({...e,tooltip:o})};return p(s.Stack,{ref:n,spacing:0,children:[i(Cn,{sectionTitle:"Overflow on Chart",value:e.label,onChange:r}),i(Cn,{sectionTitle:"Overflow in Tooltip",value:e.tooltip,onChange:a})]})}),Zb=({value:e,onChange:t})=>{const n=r=>{r&&t(r)};return i(s.Box,{children:i(Ae,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},wo={static:{type:"static",size:10},dynamic:{type:"dynamic",func_content:["function getSize({ rowData, params, variables }, { lodash, interpolate }) {"," // your code goes here"," // return 10","}"].join(`
|
|
276
|
-
`)}},Hb=({value:e,onChange:t})=>{const[n,{setTrue:r,setFalse:a}]=X.useBoolean(),[o,l]=y.useState(e),u=()=>{a();const{type:h,func_content:g}=o,m={type:h,func_content:g};l(m),t(m)},c=()=>{a(),l(e)},d=h=>{l(g=>({...g,func_content:h}))},f=()=>{d(wo.dynamic.func_content)};return p(B,{children:[i(s.Box,{sx:{width:"50%"},children:i(s.Button,{variant:"filled",mt:24,onClick:r,sx:{flexGrow:0},children:"Setup"})}),i(s.Modal,{size:800,title:"Setup dynamic size",opened:n,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:n&&p(s.Stack,{children:[i(s.Divider,{mt:10,mb:-10,label:"Dynamic by a custom function",labelPosition:"center",variant:"dashed"}),i(Zb,{value:o.func_content,onChange:d}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:f,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Rest"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:c,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:u,children:"OK"})]})]})]})})]})},ev=({value:e,onChange:t})=>e.type!=="dynamic"?null:i(Hb,{value:e,onChange:t}),tv=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=r=>{t({...e,size:r})};return i(B,{children:i(s.NumberInput,{defaultValue:18,placeholder:"1 ~ 100",label:" ",hideControls:!0,value:e.size,onChange:n})})},nv=[{label:"Static",value:"static"},{label:"Dynamic",value:"dynamic"}],rv=y.forwardRef(({label:e="Size",value:t,onChange:n},r)=>{const a=o=>{n({...wo[o]})};return p(s.SimpleGrid,{cols:2,children:[i(s.Select,{ref:r,label:e,data:nv,value:t.type,onChange:a,sx:{flexGrow:1}}),i(tv,{value:t,onChange:n}),i(ev,{value:t,onChange:n})]})}),iv=[{label:"off",value:""},{label:"top",value:"top"},{label:"left",value:"left"},{label:"right",value:"right"},{label:"bottom",value:"bottom"},{label:"inside",value:"inside"},{label:"insideLeft",value:"insideLeft"},{label:"insideRight",value:"insideRight"},{label:"insideTop",value:"insideTop"},{label:"insideBottom",value:"insideBottom"},{label:"insideTopLeft",value:"insideTopLeft"},{label:"insideBottomLeft",value:"insideBottomLeft"},{label:"insideTopRight",value:"insideTopRight"},{label:"insideBottomRight",value:"insideBottomRight"}];function av({control:e,watch:t}){return t(["scatter"]),p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"scatter.name_data_key",control:e,render:({field:n})=>i(j,{label:"Name Data Field",required:!0,sx:{flex:1},...n})}),i(v.Controller,{name:"scatter.y_data_key",control:e,render:({field:n})=>i(j,{label:"Value Data Field",required:!0,sx:{flex:1},...n})})]}),i(s.Divider,{mb:-15,label:"Style",labelPosition:"center"}),i(v.Controller,{name:"scatter.symbolSize",control:e,render:({field:n})=>i(rv,{label:"Size",...n})}),i(v.Controller,{name:"scatter.color",control:e,render:({field:n})=>i(Xb,{...n})}),i(s.Divider,{mb:-15,label:"Label",labelPosition:"center"}),i(s.Group,{grow:!0,noWrap:!0,children:i(v.Controller,{name:"scatter.label_position",control:e,render:({field:n})=>i(s.Select,{label:"Label Position",data:iv,...n})})}),i(v.Controller,{name:"scatter.label_overflow",control:e,render:({field:n})=>i(Jb,{...n})})]})}function sv({control:e,watch:t}){return t("stats"),i(s.Stack,{children:p(s.Stack,{spacing:0,children:[i(v.Controller,{name:"stats.templates.top",control:e,render:({field:n})=>i(Jt,{label:"Template for stats above the chart",py:"md",sx:{flexGrow:1},...n})}),i(v.Controller,{name:"stats.templates.bottom",control:e,render:({field:n})=>i(Jt,{label:"Template for stats under the chart",py:"md",sx:{flexGrow:1},...n})})]})})}const ov=({control:e,index:t,remove:n})=>p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:r})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...r})}),i(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:r})=>i(j,{label:"Value Field",required:!0,sx:{flex:1},...r})})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed"}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),sx:{top:15,right:5},children:"Delete this Metric"})]}),lv=({control:e,watch:t})=>{const{fields:n,append:r,remove:a}=v.useFieldArray({control:e,name:"tooltip.metrics"}),o=t("tooltip.metrics"),l=n.map((h,g)=>({...h,...o[g]})),u=()=>r({id:Date.now().toString(),data_key:"",name:""}),c=t("tooltip.metrics.0.id"),[d,f]=y.useState(()=>c??null);return y.useEffect(()=>{c&&f(h=>h!==null?h:c)},[c]),p(B,{children:[p(s.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[i(D.InfoCircle,{size:14,color:"#888"}),i(s.Text,{size:14,color:"#888",children:"Configure additional metrics to show in tooltip"})]}),p(s.Tabs,{value:d,onTabChange:h=>f(h),styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[p(s.Tabs.List,{children:[l.map((h,g)=>i(s.Tabs.Tab,{value:h.id,children:h.name?h.name:g},h.id)),i(s.Tabs.Tab,{onClick:u,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),l.map((h,g)=>i(s.Tabs.Panel,{value:h.id,children:i(ov,{control:e,index:g,remove:a},h.id)},h.id))]})]})},uv=[{label:"Scatter Point",value:"item"},{label:"X Axis",value:"axis"}];function cv({control:e,watch:t}){return t("tooltip.trigger"),p(s.Stack,{children:[i(v.Controller,{name:"tooltip.trigger",control:e,render:({field:n})=>i(s.Select,{label:"Trigger",data:uv,sx:{flexGrow:1},...n})}),i(s.Divider,{variant:"dashed"}),i(lv,{control:e,watch:t})]})}const dv=({disabled:e,value:t,onChange:n})=>{const r=a=>{a&&n(a)};return p(s.Box,{sx:{position:"relative"},children:[e&&i(s.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),i(Ae,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},pv=y.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:a,setFalse:o}]=X.useBoolean(),[l,u]=y.useState(e);y.useEffect(()=>{u(e)},[e]);const c=m=>{u({...l,enabled:m})},d=()=>{o();const{enabled:m,func_content:C}=l,w={enabled:m,func_content:C};u(w),t(w)},f=()=>{o(),u(e)},h=m=>{u(C=>({...C,func_content:m}))},g=()=>{h(mo.func_content)};return p(B,{children:[i(s.Button,{variant:"filled",mt:24,onClick:a,sx:{flexGrow:0},children:"Customize Label"}),i(s.Modal,{size:800,title:"Customize label content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&p(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:l.enabled,onChange:m=>c(m.currentTarget.checked)}),i(dv,{value:l.func_content,onChange:h,disabled:!l.enabled}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:g,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Rest"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:f,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:d,children:"OK"})]})]})]})})]})});function hv({control:e,watch:t}){return t(["x_axis"]),p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.data_key",control:e,render:({field:n})=>i(j,{label:"Data Field",required:!0,sx:{flex:1},...n})}),i(v.Controller,{name:"x_axis.name",control:e,render:({field:n})=>i(s.TextInput,{label:"Name",sx:{flex:1},...n})})]}),i(s.Divider,{mb:-15,label:"Tick Label",labelPosition:"center"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:n})=>i(s.NumberInput,{label:"Rotate",hideControls:!0,min:-90,max:90,rightSection:i(s.Text,{color:"dimmed",children:"degree"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),i(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>i(pv,{...n})})]})]})}const fv=[{label:"left",value:"left"},{label:"center",value:"center"},{label:"right",value:"right"}],gv=[{label:"left",value:"left"},{label:"right",value:"right"}];function mv({control:e,index:t,remove:n}){return p(s.Stack,{my:0,p:"0",sx:{position:"relative"},children:[i(s.Divider,{mb:-15,mt:15,variant:"dashed",label:"Name",labelPosition:"center"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:r})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...r})}),i(v.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:r})=>i(s.Select,{label:"Align",required:!0,data:fv,sx:{flex:1},...r})})]}),i(s.Divider,{mb:-15,variant:"dashed",label:"Layout",labelPosition:"center"}),i(s.Group,{grow:!0,noWrap:!0,children:i(v.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:r})=>i(s.Select,{label:"Position",required:!0,data:gv,sx:{flex:1},...r})})}),p(s.Stack,{children:[i(s.Divider,{mb:-15,variant:"dashed",label:"Label Format",labelPosition:"center"}),i(v.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:r})=>i(Re,{...r})})]}),p(s.Stack,{children:[i(s.Divider,{mb:-15,variant:"dashed",label:"Value Range",labelPosition:"center"}),p(s.Group,{grow:!0,children:[i(v.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:r})=>i(s.TextInput,{label:"Min",...r})}),i(v.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:r})=>i(s.TextInput,{label:"Max",...r})})]})]}),i(s.Button,{mt:20,leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),disabled:t===0,children:"Delete this YAxis"})]})}function yv({control:e,watch:t}){const{fields:n,append:r,remove:a}=v.useFieldArray({control:e,name:"y_axes"}),o=t("y_axes"),l=n.map((c,d)=>({...c,...o[d]})),u=()=>r({name:"",label_formatter:$e,min:"",max:"",show:!0,position:"right",nameAlignment:"right"});return p(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px"}},children:[p(s.Tabs.List,{children:[l.map((c,d)=>i(s.Tabs.Tab,{value:d.toString(),children:d+1},d)),i(s.Tabs.Tab,{onClick:u,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),l.map((c,d)=>i(s.Tabs.Panel,{value:d.toString(),children:i(mv,{control:e,index:d,remove:a})},d))]})}function bv(e){return e||{templates:{top:"",bottom:""}}}function vv({reference_lines:e=[],stats:t,...n}){return{reference_lines:e,stats:bv(t),...n}}function xv({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),{variables:r}=e,a=y.useMemo(()=>x.defaultsDeep({},t,li),[t]),o=y.useMemo(()=>vv(a),[a]);y.useEffect(()=>{!x.isEqual(a,o)&&(console.log("config malformed, resetting to defaults",a,o),n(o))},[a,o]);const{control:l,handleSubmit:u,watch:c,getValues:d,reset:f}=v.useForm({defaultValues:o});y.useEffect(()=>{f(o)},[o]);const h=d(),g=y.useMemo(()=>!x.isEqual(h,a),[h,a]);return c(["dataZoom"]),i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:u(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!g,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"X Axis",children:"X Axis"}),i(s.Tabs.Tab,{value:"Y Axes",children:"Y Axes"}),i(s.Tabs.Tab,{value:"Scatter",children:"Scatter"}),i(s.Tabs.Tab,{value:"Tooltip",children:"Tooltip"}),i(s.Tabs.Tab,{value:"Stats",children:"Stats"}),i(s.Tabs.Tab,{value:"Reference Lines",children:"Reference Lines"}),i(s.Tabs.Tab,{value:"Reference Areas",children:"Reference Areas"}),i(s.Tabs.Tab,{value:"Zooming",children:"Zooming"})]}),i(s.Tabs.Panel,{value:"X Axis",children:i(hv,{control:l,watch:c})}),i(s.Tabs.Panel,{value:"Y Axes",children:i(yv,{control:l,watch:c})}),i(s.Tabs.Panel,{value:"Scatter",children:i(av,{control:l,watch:c})}),i(s.Tabs.Panel,{value:"Tooltip",children:i(cv,{control:l,watch:c})}),i(s.Tabs.Panel,{value:"Stats",children:i(sv,{control:l,watch:c})}),i(s.Tabs.Panel,{value:"Reference Lines",children:i(jb,{variables:r,control:l,watch:c})}),i(s.Tabs.Panel,{value:"Reference Areas",children:i(qb,{variables:r,control:l,watch:c})}),i(s.Tabs.Panel,{value:"Zooming",children:i(v.Controller,{name:"dataZoom",control:l,render:({field:m})=>i(Pr,{...m})})})]})]})})}function wv(e){const{dataZoom:t=Vt,...n}=e;return{...n,dataZoom:t}}function Cv(e){const t={scatter:{label_overflow:yo}};return x.defaultsDeep(t,e)}function Sv(e){const{color:t}=e.scatter;return typeof t=="string"?{...e,scatter:{...e.scatter,color:{...sn.static,color:t}}}:e}function _v(e){const t=e.reference_lines.map(n=>{const{lineStyle:r={type:"dashed",width:1,color:ot.random().css()},show_in_legend:a=!1,yAxisIndex:o=0}=n;return{...n,lineStyle:r,show_in_legend:a,yAxisIndex:o}});return{...e,reference_lines:t}}function kv(e){const t={tooltip:{trigger:"item"}};return x.defaultsDeep({},e,t)}function Tv(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis:a,scatter:o,tooltip:l,...u}=e;return{...u,x_axis:{...a,data_key:r(a.data_key)},scatter:{...o,y_data_key:r(o.y_data_key),name_data_key:r(o.name_data_key)},tooltip:{...l,metrics:l.metrics.map(c=>({...c,data_key:r(c.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}class Dv extends be{constructor(){super(...arguments);q(this,"VERSION",9)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{tooltip:r={metrics:[]},...a}=n.config;return{...n,version:2,config:{...a,tooltip:r}}}),this.version(3,n=>({...n,version:3,config:wv(n.config)})),this.version(4,n=>{const{config:r}=n;return{...n,version:5,config:Cv(r)}}),this.version(6,n=>{const{config:r}=n;return{...n,version:6,config:Sv(r)}}),this.version(7,n=>{const{config:r}=n;return{...n,version:7,config:_v(r)}}),this.version(8,n=>{const{config:r}=n;return{...n,version:8,config:kv(r)}}),this.version(9,(n,r)=>{const{config:a}=n;return{...n,version:9,config:Tv(a,r)}})}}const Mv={displayName:"Scatter Chart",displayGroup:"ECharts-based charts",migrator:new Dv,name:"scatterChart",viewRender:Bb,configRender:xv,createConfig(){return{version:9,config:x.cloneDeep(li)}},triggers:[go]},ui={template:"The variable ${value} is defined in Variables section",vertical_align:"center",horizontal_align:"left"};function Iv(e){if("variables"in e)return e;const{align:t,size:n,weight:r,color:a,content:{prefix:o="",data_field:l="value",formatter:u={output:"number",mantissa:0},postfix:c=""}={}}=e;return{align:t,template:`${o} \${value} ${c}`,variables:[{name:"value",data_field:l,aggregation:{type:"none",config:{}},formatter:u,color:a,weight:r,size:n}]}}function Ev(e){return x.omit(e,["variables"])}function Av(e){const{align:t,...n}=e;return{horizontal_align:t,vertical_align:"center",...n}}function zv(e){const t=x.cloneDeep(e),n=x.get(t,"color.valueRange");return n!==void 0&&x.set(t,"color.valueRange",n.map(r=>Number(r))),t}class $v extends be{constructor(){super(...arguments);q(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:Iv(n)})),this.version(2,(n,{panelModel:r})=>{const{config:a}=n;return(a.variables||[]).forEach(l=>{r.variables.find(u=>u.name===l.name)||r.addVariable(zv(l))}),{...n,version:2,config:Ev(a)}}),this.version(3,n=>{const{config:r}=n;return{...n,version:3,config:Av(r)}})}}const Ov={left:"flex-start",center:"center",right:"flex-end"},Lv={top:"flex-start",center:"center",bottom:"flex-end"},Pv=k.observer(({context:e})=>{const t=we(),{value:n=ui}=W(e.instanceData,"config"),{variables:r}=e,{template:a,horizontal_align:o,vertical_align:l}=n,{width:u,height:c}=e.viewport,d=y.useMemo(()=>{try{return x.template(a)(t.payloadForSQL)}catch{return a}},[t.payloadForSQL,a]),f=y.useMemo(()=>Zt(d,r,e.data),[d,r,e.data,e]);return i(s.Center,{sx:{width:u,height:c,justifyContent:Ov[o],alignItems:Lv[l]},children:i(s.Box,{children:Object.values(f).map((h,g)=>i(y.Fragment,{children:h},g))})})}),Bv=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}],Vv=[{label:"Top",value:"top"},{label:"Center",value:"center"},{label:"Bottom",value:"bottom"}];function Nv({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaultsDeep({},t,ui),[t]),{control:a,handleSubmit:o,watch:l,getValues:u,reset:c}=v.useForm({defaultValues:r});y.useEffect(()=>{c(r)},[r]),l(["template","horizontal_align","vertical_align"]);const d=u(),f=y.useMemo(()=>!x.isEqual(d,t),[d,t]);return i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{weight:500,children:"Stats Configurations"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!f,children:i(D.DeviceFloppy,{size:20})})]}),i(v.Controller,{name:"template",control:a,render:({field:h})=>i(Jt,{label:"Template",py:"md",sx:{flexGrow:1},...h})}),p(s.SimpleGrid,{cols:2,children:[i(v.Controller,{name:"horizontal_align",control:a,render:({field:h})=>i(s.Select,{label:"Horizontal Alignment",data:Bv,...h})}),i(v.Controller,{control:a,name:"vertical_align",render:({field:h})=>i(s.Select,{label:"Vertical Alignment",data:Vv,...h})})]})]})})}const qv={createConfig(){return{version:3,config:ui}},displayName:"Stats",displayGroup:"Others",migrator:new $v,name:"stats",viewRender:Pv,configRender:Nv},ci={label_key:"",value_key:"",group_key:"",levels:[]};function Fv(e){const t=new Set(e.map(r=>r.parent_id)),n=new Set(e.map(r=>r.id));return t.forEach(r=>{r===null||n.has(r)||e.push({id:r,name:r,parent_id:null})}),e}function Gv(e){const t=Fv(e).map(a=>({...a,children:[]})),n=x.keyBy(t,a=>a.id),r=[];return t.forEach(a=>{if(!a.parent_id||!n[a.parent_id]){r.push(a);return}n[a.parent_id].children.push(a)}),r}function Wv(e,t){const{label_key:n,value_key:r,group_key:a}=e;if(!n||!r)return[];const o=V(n),l=V(r),u=V(a),c=t[o.queryID].map(d=>({...d,id:d[o.columnKey],parent_id:d[u.columnKey],name:d[o.columnKey],value:d[l.columnKey]?Number(d[l.columnKey]):d[l.columnKey]}));return a?Gv(c):c}const jv=e=>({treePathInfo:t,name:n,value:r})=>{if(t.length===1||!e)return n;try{const a=t[t.length-2].value;if(r/a<e)return" "}catch{return n}};function Rv(e){const{levels:t}=e;return t.map(n=>{const{show_label_tolerance:r,...a}=n.label;return{...n,label:{...a,formatter:jv(r)}}})}function Yv(){return({treePathInfo:e,name:t,value:n,color:r,marker:a,...o})=>{const l=e.slice(0,e.length-1),u=[`<tr>
|
|
276
|
+
`)}},Hb=({value:e,onChange:t})=>{const[n,{setTrue:r,setFalse:a}]=X.useBoolean(),[o,l]=y.useState(e),u=()=>{a();const{type:h,func_content:g}=o,m={type:h,func_content:g};l(m),t(m)},c=()=>{a(),l(e)},d=h=>{l(g=>({...g,func_content:h}))},f=()=>{d(wo.dynamic.func_content)};return p(B,{children:[i(s.Box,{sx:{width:"50%"},children:i(s.Button,{variant:"filled",mt:24,onClick:r,sx:{flexGrow:0},children:"Setup"})}),i(s.Modal,{size:800,title:"Setup dynamic size",opened:n,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:n&&p(s.Stack,{children:[i(s.Divider,{mt:10,mb:-10,label:"Dynamic by a custom function",labelPosition:"center",variant:"dashed"}),i(Zb,{value:o.func_content,onChange:d}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:f,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Reset"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:c,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:u,children:"OK"})]})]})]})})]})},ev=({value:e,onChange:t})=>e.type!=="dynamic"?null:i(Hb,{value:e,onChange:t}),tv=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=r=>{t({...e,size:r})};return i(B,{children:i(s.NumberInput,{defaultValue:18,placeholder:"1 ~ 100",label:" ",hideControls:!0,value:e.size,onChange:n})})},nv=[{label:"Static",value:"static"},{label:"Dynamic",value:"dynamic"}],rv=y.forwardRef(({label:e="Size",value:t,onChange:n},r)=>{const a=o=>{n({...wo[o]})};return p(s.SimpleGrid,{cols:2,children:[i(s.Select,{ref:r,label:e,data:nv,value:t.type,onChange:a,sx:{flexGrow:1}}),i(tv,{value:t,onChange:n}),i(ev,{value:t,onChange:n})]})}),iv=[{label:"off",value:""},{label:"top",value:"top"},{label:"left",value:"left"},{label:"right",value:"right"},{label:"bottom",value:"bottom"},{label:"inside",value:"inside"},{label:"insideLeft",value:"insideLeft"},{label:"insideRight",value:"insideRight"},{label:"insideTop",value:"insideTop"},{label:"insideBottom",value:"insideBottom"},{label:"insideTopLeft",value:"insideTopLeft"},{label:"insideBottomLeft",value:"insideBottomLeft"},{label:"insideTopRight",value:"insideTopRight"},{label:"insideBottomRight",value:"insideBottomRight"}];function av({control:e,watch:t}){return t(["scatter"]),p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"scatter.name_data_key",control:e,render:({field:n})=>i(j,{label:"Name Data Field",required:!0,sx:{flex:1},...n})}),i(v.Controller,{name:"scatter.y_data_key",control:e,render:({field:n})=>i(j,{label:"Value Data Field",required:!0,sx:{flex:1},...n})})]}),i(s.Divider,{mb:-15,label:"Style",labelPosition:"center"}),i(v.Controller,{name:"scatter.symbolSize",control:e,render:({field:n})=>i(rv,{label:"Size",...n})}),i(v.Controller,{name:"scatter.color",control:e,render:({field:n})=>i(Xb,{...n})}),i(s.Divider,{mb:-15,label:"Label",labelPosition:"center"}),i(s.Group,{grow:!0,noWrap:!0,children:i(v.Controller,{name:"scatter.label_position",control:e,render:({field:n})=>i(s.Select,{label:"Label Position",data:iv,...n})})}),i(v.Controller,{name:"scatter.label_overflow",control:e,render:({field:n})=>i(Jb,{...n})})]})}function sv({control:e,watch:t}){return t("stats"),i(s.Stack,{children:p(s.Stack,{spacing:0,children:[i(v.Controller,{name:"stats.templates.top",control:e,render:({field:n})=>i(Jt,{label:"Template for stats above the chart",py:"md",sx:{flexGrow:1},...n})}),i(v.Controller,{name:"stats.templates.bottom",control:e,render:({field:n})=>i(Jt,{label:"Template for stats under the chart",py:"md",sx:{flexGrow:1},...n})})]})})}const ov=({control:e,index:t,remove:n})=>p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:r})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...r})}),i(v.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:r})=>i(j,{label:"Value Field",required:!0,sx:{flex:1},...r})})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed"}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),sx:{top:15,right:5},children:"Delete this Metric"})]}),lv=({control:e,watch:t})=>{const{fields:n,append:r,remove:a}=v.useFieldArray({control:e,name:"tooltip.metrics"}),o=t("tooltip.metrics"),l=n.map((h,g)=>({...h,...o[g]})),u=()=>r({id:Date.now().toString(),data_key:"",name:""}),c=t("tooltip.metrics.0.id"),[d,f]=y.useState(()=>c??null);return y.useEffect(()=>{c&&f(h=>h!==null?h:c)},[c]),p(B,{children:[p(s.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[i(D.InfoCircle,{size:14,color:"#888"}),i(s.Text,{size:14,color:"#888",children:"Configure additional metrics to show in tooltip"})]}),p(s.Tabs,{value:d,onTabChange:h=>f(h),styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[p(s.Tabs.List,{children:[l.map((h,g)=>i(s.Tabs.Tab,{value:h.id,children:h.name?h.name:g},h.id)),i(s.Tabs.Tab,{onClick:u,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),l.map((h,g)=>i(s.Tabs.Panel,{value:h.id,children:i(ov,{control:e,index:g,remove:a},h.id)},h.id))]})]})},uv=[{label:"Scatter Point",value:"item"},{label:"X Axis",value:"axis"}];function cv({control:e,watch:t}){return t("tooltip.trigger"),p(s.Stack,{children:[i(v.Controller,{name:"tooltip.trigger",control:e,render:({field:n})=>i(s.Select,{label:"Trigger",data:uv,sx:{flexGrow:1},...n})}),i(s.Divider,{variant:"dashed"}),i(lv,{control:e,watch:t})]})}const dv=({disabled:e,value:t,onChange:n})=>{const r=a=>{a&&n(a)};return p(s.Box,{sx:{position:"relative"},children:[e&&i(s.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),i(Ae,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},pv=y.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:a,setFalse:o}]=X.useBoolean(),[l,u]=y.useState(e);y.useEffect(()=>{u(e)},[e]);const c=m=>{u({...l,enabled:m})},d=()=>{o();const{enabled:m,func_content:C}=l,w={enabled:m,func_content:C};u(w),t(w)},f=()=>{o(),u(e)},h=m=>{u(C=>({...C,func_content:m}))},g=()=>{h(mo.func_content)};return p(B,{children:[i(s.Button,{variant:"filled",mt:24,onClick:a,sx:{flexGrow:0},children:"Customize Label"}),i(s.Modal,{size:800,title:"Customize label content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&p(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:l.enabled,onChange:m=>c(m.currentTarget.checked)}),i(dv,{value:l.func_content,onChange:h,disabled:!l.enabled}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:g,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Reset"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:f,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:d,children:"OK"})]})]})]})})]})});function hv({control:e,watch:t}){return t(["x_axis"]),p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.data_key",control:e,render:({field:n})=>i(j,{label:"Data Field",required:!0,sx:{flex:1},...n})}),i(v.Controller,{name:"x_axis.name",control:e,render:({field:n})=>i(s.TextInput,{label:"Name",sx:{flex:1},...n})})]}),i(s.Divider,{mb:-15,label:"Tick Label",labelPosition:"center"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:n})=>i(s.NumberInput,{label:"Rotate",hideControls:!0,min:-90,max:90,rightSection:i(s.Text,{color:"dimmed",children:"degree"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),i(v.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>i(pv,{...n})})]})]})}const fv=[{label:"left",value:"left"},{label:"center",value:"center"},{label:"right",value:"right"}],gv=[{label:"left",value:"left"},{label:"right",value:"right"}];function mv({control:e,index:t,remove:n}){return p(s.Stack,{my:0,p:"0",sx:{position:"relative"},children:[i(s.Divider,{mb:-15,mt:15,variant:"dashed",label:"Name",labelPosition:"center"}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:r})=>i(s.TextInput,{label:"Name",required:!0,sx:{flex:1},...r})}),i(v.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:r})=>i(s.Select,{label:"Align",required:!0,data:fv,sx:{flex:1},...r})})]}),i(s.Divider,{mb:-15,variant:"dashed",label:"Layout",labelPosition:"center"}),i(s.Group,{grow:!0,noWrap:!0,children:i(v.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:r})=>i(s.Select,{label:"Position",required:!0,data:gv,sx:{flex:1},...r})})}),p(s.Stack,{children:[i(s.Divider,{mb:-15,variant:"dashed",label:"Label Format",labelPosition:"center"}),i(v.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:r})=>i(Re,{...r})})]}),p(s.Stack,{children:[i(s.Divider,{mb:-15,variant:"dashed",label:"Value Range",labelPosition:"center"}),p(s.Group,{grow:!0,children:[i(v.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:r})=>i(s.TextInput,{label:"Min",...r})}),i(v.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:r})=>i(s.TextInput,{label:"Max",...r})})]})]}),i(s.Button,{mt:20,leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),disabled:t===0,children:"Delete this YAxis"})]})}function yv({control:e,watch:t}){const{fields:n,append:r,remove:a}=v.useFieldArray({control:e,name:"y_axes"}),o=t("y_axes"),l=n.map((c,d)=>({...c,...o[d]})),u=()=>r({name:"",label_formatter:$e,min:"",max:"",show:!0,position:"right",nameAlignment:"right"});return p(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px"}},children:[p(s.Tabs.List,{children:[l.map((c,d)=>i(s.Tabs.Tab,{value:d.toString(),children:d+1},d)),i(s.Tabs.Tab,{onClick:u,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),l.map((c,d)=>i(s.Tabs.Panel,{value:d.toString(),children:i(mv,{control:e,index:d,remove:a})},d))]})}function bv(e){return e||{templates:{top:"",bottom:""}}}function vv({reference_lines:e=[],stats:t,...n}){return{reference_lines:e,stats:bv(t),...n}}function xv({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),{variables:r}=e,a=y.useMemo(()=>x.defaultsDeep({},t,li),[t]),o=y.useMemo(()=>vv(a),[a]);y.useEffect(()=>{!x.isEqual(a,o)&&(console.log("config malformed, resetting to defaults",a,o),n(o))},[a,o]);const{control:l,handleSubmit:u,watch:c,getValues:d,reset:f}=v.useForm({defaultValues:o});y.useEffect(()=>{f(o)},[o]);const h=d(),g=y.useMemo(()=>!x.isEqual(h,a),[h,a]);return c(["dataZoom"]),i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:u(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Chart Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!g,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"X Axis",children:"X Axis"}),i(s.Tabs.Tab,{value:"Y Axes",children:"Y Axes"}),i(s.Tabs.Tab,{value:"Scatter",children:"Scatter"}),i(s.Tabs.Tab,{value:"Tooltip",children:"Tooltip"}),i(s.Tabs.Tab,{value:"Stats",children:"Stats"}),i(s.Tabs.Tab,{value:"Reference Lines",children:"Reference Lines"}),i(s.Tabs.Tab,{value:"Reference Areas",children:"Reference Areas"}),i(s.Tabs.Tab,{value:"Zooming",children:"Zooming"})]}),i(s.Tabs.Panel,{value:"X Axis",children:i(hv,{control:l,watch:c})}),i(s.Tabs.Panel,{value:"Y Axes",children:i(yv,{control:l,watch:c})}),i(s.Tabs.Panel,{value:"Scatter",children:i(av,{control:l,watch:c})}),i(s.Tabs.Panel,{value:"Tooltip",children:i(cv,{control:l,watch:c})}),i(s.Tabs.Panel,{value:"Stats",children:i(sv,{control:l,watch:c})}),i(s.Tabs.Panel,{value:"Reference Lines",children:i(jb,{variables:r,control:l,watch:c})}),i(s.Tabs.Panel,{value:"Reference Areas",children:i(qb,{variables:r,control:l,watch:c})}),i(s.Tabs.Panel,{value:"Zooming",children:i(v.Controller,{name:"dataZoom",control:l,render:({field:m})=>i(Pr,{...m})})})]})]})})}function wv(e){const{dataZoom:t=Vt,...n}=e;return{...n,dataZoom:t}}function Cv(e){const t={scatter:{label_overflow:yo}};return x.defaultsDeep(t,e)}function Sv(e){const{color:t}=e.scatter;return typeof t=="string"?{...e,scatter:{...e.scatter,color:{...sn.static,color:t}}}:e}function _v(e){const t=e.reference_lines.map(n=>{const{lineStyle:r={type:"dashed",width:1,color:ot.random().css()},show_in_legend:a=!1,yAxisIndex:o=0}=n;return{...n,lineStyle:r,show_in_legend:a,yAxisIndex:o}});return{...e,reference_lines:t}}function kv(e){const t={tooltip:{trigger:"item"}};return x.defaultsDeep({},e,t)}function Tv(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis:a,scatter:o,tooltip:l,...u}=e;return{...u,x_axis:{...a,data_key:r(a.data_key)},scatter:{...o,y_data_key:r(o.y_data_key),name_data_key:r(o.name_data_key)},tooltip:{...l,metrics:l.metrics.map(c=>({...c,data_key:r(c.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}class Dv extends be{constructor(){super(...arguments);q(this,"VERSION",9)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{tooltip:r={metrics:[]},...a}=n.config;return{...n,version:2,config:{...a,tooltip:r}}}),this.version(3,n=>({...n,version:3,config:wv(n.config)})),this.version(4,n=>{const{config:r}=n;return{...n,version:5,config:Cv(r)}}),this.version(6,n=>{const{config:r}=n;return{...n,version:6,config:Sv(r)}}),this.version(7,n=>{const{config:r}=n;return{...n,version:7,config:_v(r)}}),this.version(8,n=>{const{config:r}=n;return{...n,version:8,config:kv(r)}}),this.version(9,(n,r)=>{const{config:a}=n;return{...n,version:9,config:Tv(a,r)}})}}const Mv={displayName:"Scatter Chart",displayGroup:"ECharts-based charts",migrator:new Dv,name:"scatterChart",viewRender:Bb,configRender:xv,createConfig(){return{version:9,config:x.cloneDeep(li)}},triggers:[go]},ui={template:"The variable ${value} is defined in Variables section",vertical_align:"center",horizontal_align:"left"};function Iv(e){if("variables"in e)return e;const{align:t,size:n,weight:r,color:a,content:{prefix:o="",data_field:l="value",formatter:u={output:"number",mantissa:0},postfix:c=""}={}}=e;return{align:t,template:`${o} \${value} ${c}`,variables:[{name:"value",data_field:l,aggregation:{type:"none",config:{}},formatter:u,color:a,weight:r,size:n}]}}function Ev(e){return x.omit(e,["variables"])}function Av(e){const{align:t,...n}=e;return{horizontal_align:t,vertical_align:"center",...n}}function zv(e){const t=x.cloneDeep(e),n=x.get(t,"color.valueRange");return n!==void 0&&x.set(t,"color.valueRange",n.map(r=>Number(r))),t}class $v extends be{constructor(){super(...arguments);q(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:Iv(n)})),this.version(2,(n,{panelModel:r})=>{const{config:a}=n;return(a.variables||[]).forEach(l=>{r.variables.find(u=>u.name===l.name)||r.addVariable(zv(l))}),{...n,version:2,config:Ev(a)}}),this.version(3,n=>{const{config:r}=n;return{...n,version:3,config:Av(r)}})}}const Ov={left:"flex-start",center:"center",right:"flex-end"},Lv={top:"flex-start",center:"center",bottom:"flex-end"},Pv=k.observer(({context:e})=>{const t=we(),{value:n=ui}=W(e.instanceData,"config"),{variables:r}=e,{template:a,horizontal_align:o,vertical_align:l}=n,{width:u,height:c}=e.viewport,d=y.useMemo(()=>{try{return x.template(a)(t.payloadForSQL)}catch{return a}},[t.payloadForSQL,a]),f=y.useMemo(()=>Zt(d,r,e.data),[d,r,e.data,e]);return i(s.Center,{sx:{width:u,height:c,justifyContent:Ov[o],alignItems:Lv[l]},children:i(s.Box,{children:Object.values(f).map((h,g)=>i(y.Fragment,{children:h},g))})})}),Bv=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}],Vv=[{label:"Top",value:"top"},{label:"Center",value:"center"},{label:"Bottom",value:"bottom"}];function Nv({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaultsDeep({},t,ui),[t]),{control:a,handleSubmit:o,watch:l,getValues:u,reset:c}=v.useForm({defaultValues:r});y.useEffect(()=>{c(r)},[r]),l(["template","horizontal_align","vertical_align"]);const d=u(),f=y.useMemo(()=>!x.isEqual(d,t),[d,t]);return i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:o(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{weight:500,children:"Stats Configurations"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!f,children:i(D.DeviceFloppy,{size:20})})]}),i(v.Controller,{name:"template",control:a,render:({field:h})=>i(Jt,{label:"Template",py:"md",sx:{flexGrow:1},...h})}),p(s.SimpleGrid,{cols:2,children:[i(v.Controller,{name:"horizontal_align",control:a,render:({field:h})=>i(s.Select,{label:"Horizontal Alignment",data:Bv,...h})}),i(v.Controller,{control:a,name:"vertical_align",render:({field:h})=>i(s.Select,{label:"Vertical Alignment",data:Vv,...h})})]})]})})}const qv={createConfig(){return{version:3,config:ui}},displayName:"Stats",displayGroup:"Others",migrator:new $v,name:"stats",viewRender:Pv,configRender:Nv},ci={label_key:"",value_key:"",group_key:"",levels:[]};function Fv(e){const t=new Set(e.map(r=>r.parent_id)),n=new Set(e.map(r=>r.id));return t.forEach(r=>{r===null||n.has(r)||e.push({id:r,name:r,parent_id:null})}),e}function Gv(e){const t=Fv(e).map(a=>({...a,children:[]})),n=x.keyBy(t,a=>a.id),r=[];return t.forEach(a=>{if(!a.parent_id||!n[a.parent_id]){r.push(a);return}n[a.parent_id].children.push(a)}),r}function Wv(e,t){const{label_key:n,value_key:r,group_key:a}=e;if(!n||!r)return[];const o=V(n),l=V(r),u=V(a),c=t[o.queryID].map(d=>({...d,id:d[o.columnKey],parent_id:d[u.columnKey],name:d[o.columnKey],value:d[l.columnKey]?Number(d[l.columnKey]):d[l.columnKey]}));return a?Gv(c):c}const jv=e=>({treePathInfo:t,name:n,value:r})=>{if(t.length===1||!e)return n;try{const a=t[t.length-2].value;if(r/a<e)return" "}catch{return n}};function Rv(e){const{levels:t}=e;return t.map(n=>{const{show_label_tolerance:r,...a}=n.label;return{...n,label:{...a,formatter:jv(r)}}})}function Yv(){return({treePathInfo:e,name:t,value:n,color:r,marker:a,...o})=>{const l=e.slice(0,e.length-1),u=[`<tr>
|
|
277
277
|
<th style="text-align: right; padding: 0 1em;">Value</th>
|
|
278
278
|
<td style="text-align: left; padding: 0 1em;">${n}</td>
|
|
279
279
|
</tr>
|
|
@@ -292,8 +292,8 @@ Check the top-level render call using <`+P+">.")}return z}}function bu(S,z){{if(
|
|
|
292
292
|
<tbody>${u.join("")}</tbody>
|
|
293
293
|
</table>
|
|
294
294
|
`}}function Qv(){return{show:!0,trigger:"item",confine:!0,formatter:Yv()}}const Kv={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function Uv(e,t,n){n.reduce((o,l)=>{const u=bt(l,t);return o[l.name]=tt(l,u),o},{});const a={series:{data:Wv(e,t),levels:Rv(e)},tooltip:Qv()};return x.defaultsDeep({},a,Kv)}oe.use([pe.SunburstChart,Ve.CanvasRenderer]);function Xv({context:e}){const{variables:t}=e,{value:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaults({},n,ci),[n]),a=e.data,{width:o,height:l}=e.viewport,u=y.useMemo(()=>Uv(r,a,t),[r,a,t]);return!o||!l?null:i(Ne,{echarts:oe,option:u,style:{width:o,height:l},notMerge:!0,theme:"merico-light"})}function Jv({control:e,watch:t}){return t(["label_key","value_key","group_key"]),p(s.Stack,{children:[i(v.Controller,{name:"label_key",control:e,render:({field:n})=>i(j,{label:"Label Key",required:!0,...n})}),i(v.Controller,{name:"value_key",control:e,render:({field:n})=>i(j,{label:"Value Key",required:!0,...n})}),i(v.Controller,{name:"group_key",control:e,render:({field:n})=>i(j,{label:"Group Key",clearable:!0,...n})})]})}const Zv=[{label:"Radial",value:"radial"},{label:"Tangential",value:"tangential"},{label:"None",value:"0"}],Hv=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}],ex=({control:e,index:t,remove:n})=>p(s.Stack,{children:[p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`levels.${t}.r0`,control:e,render:({field:r})=>i(s.TextInput,{label:"Inside Radius",placeholder:"0%",...r})}),i(v.Controller,{name:`levels.${t}.r`,control:e,render:({field:r})=>i(s.TextInput,{label:"Outside Radius",placeholder:"50%",...r})})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed",label:"Label Style",labelPosition:"center"}),i(v.Controller,{name:`levels.${t}.label.show_label_tolerance`,control:e,render:({field:r})=>i(s.NumberInput,{label:"Hide label when its percentage is less than...",precision:4,step:5e-4,min:0,max:1,...r})}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`levels.${t}.label.rotate`,control:e,render:({field:r})=>i(s.Select,{label:"Rotate",data:Zv,...r})}),i(v.Controller,{name:`levels.${t}.label.align`,control:e,render:({field:r})=>i(s.Select,{label:"Align",data:Hv,...r})})]}),p(s.Group,{grow:!0,noWrap:!0,children:[i(v.Controller,{name:`levels.${t}.label.position`,control:e,render:({field:r})=>i(Nr,{label:"Position",...r})}),i(v.Controller,{name:`levels.${t}.label.padding`,control:e,render:({field:r})=>i(s.NumberInput,{label:"Padding",min:0,hideControls:!0,...r})})]}),i(s.Divider,{mb:-10,mt:10,variant:"dashed"}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),sx:{top:15,right:5},children:"Delete this Level"})]}),tx=({control:e,watch:t})=>{const{fields:n,append:r,remove:a}=v.useFieldArray({control:e,name:"levels"}),o=t("levels"),l=n.map((h,g)=>({...h,...o[g]})),u=()=>r({id:Date.now().toString(),r0:"",r:"",label:{show_label_tolerance:.001,rotate:"0",align:"center",position:"inside",padding:0}}),c=t("levels.0.id"),[d,f]=y.useState(()=>c??null);return y.useEffect(()=>{c&&f(h=>h!==null?h:c)},[c]),p(B,{children:[p(s.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[i(D.InfoCircle,{size:14,color:"#888"}),i(s.Text,{size:14,color:"#888",children:"Configure ring style on each level"})]}),i(s.Divider,{variant:"dashed",my:10}),p(s.Tabs,{value:d,onTabChange:h=>f(h),styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[p(s.Tabs.List,{children:[l.map((h,g)=>i(s.Tabs.Tab,{value:h.id,children:g},h.id)),i(s.Tabs.Tab,{onClick:u,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),l.map((h,g)=>i(s.Tabs.Panel,{value:h.id,children:i(ex,{control:e,index:g,remove:a},h.id)},h.id))]})]})};function nx({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaultsDeep({},t,ci),[t]),a=y.useMemo(()=>x.clone(r),[r]),{control:o,handleSubmit:l,watch:u,getValues:c,reset:d}=v.useForm({defaultValues:a});y.useEffect(()=>{d(a)},[a]);const f=c(),h=y.useMemo(()=>!x.isEqual(f,r),[f,r]);u(["label_key","value_key","group_key","levels"]);const[g,m]=y.useState("Data");return i("form",{onSubmit:l(n),children:p(s.Stack,{spacing:"xs",children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Sunburst Config"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Tabs,{value:g,onTabChange:m,orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"Data",children:"Data"}),i(s.Tabs.Tab,{value:"Levels",children:"Levels"})]}),i(s.Tabs.Panel,{value:"Data",children:i(Jv,{control:o,watch:u})}),i(s.Tabs.Panel,{value:"Levels",children:i(tx,{control:o,watch:u})})]})]})})}function rx(e){const{label_field:t,value_field:n,...r}=e;return{...r,label_key:t,value_key:n}}function ix(e){const{group_key:t="",...n}=e;return{...n,group_key:t}}function ax(e){const{levels:t=[],...n}=e;return{...n,levels:t}}function sx(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{label_key:a,value_key:o,group_key:l,...u}=e;return{...u,label_key:r(a),value_key:r(o),group_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class ox extends be{constructor(){super(...arguments);q(this,"VERSION",5)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:rx(n.config)})),this.version(3,n=>({...n,version:3,config:ix(n.config)})),this.version(4,n=>({...n,version:4,config:ax(n.config)})),this.version(5,(n,r)=>({...n,version:5,config:sx(n.config,r)}))}}const lx={displayName:"Sunburst Chart",displayGroup:"ECharts-based charts",migrator:new ox,name:"sunburst",viewRender:Xv,configRender:nx,createConfig(){return{version:5,config:x.cloneDeep(ci)}}};var nt=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e.custom="custom",e))(nt||{});const Co=["function text({ value }) {"," // your code goes here"," return value","}"].join(`
|
|
295
|
-
`),So={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",id_field:"",striped:!0,use_raw_columns:!0,verticalSpacing:"14px"},_o={left:"flex-start",center:"center",right:"flex-end"},ux=({header:e,cx:t})=>{const n=x.get(e.column.columnDef.meta,"align","left");return p(s.Text,{className:t("table-head-cell",{"table-head-cell--sortable":e.column.getCanSort()}),onClick:e.column.getToggleSortingHandler(),align:n,sx:{justifyContent:_o[n]},children:[e.isPlaceholder?null:Xe.flexRender(e.column.columnDef.header,e.getContext()),i(cx,{direction:e.column.getIsSorted()})]})},cx=({direction:e})=>{switch(e){case"asc":return i($.IconArrowUp,{size:16});case"desc":return i($.IconArrowDown,{size:"1em"});default:return null}},di={id:"builtin:table:click-cell-content",displayName:"Click Cell Content",nameRender:fx,configRender:px,payload:[{name:"row_index",description:"Index of the row that the cell belongs to",valueType:"number"},{name:"col_index",description:"Index of the column that the cell belongs to",valueType:"number"},{name:"row_data",description:"Data of the row that the cell belongs to",valueType:"object"}]},dx={column:""};function ko(e,t){const{value:n}=W(e.instanceData,"config"),r={columnsFromConfig:[],columnsFromData:[]};if(n&&(r.columnsFromConfig=n.columns.map((a,o)=>({label:a.label,value:o.toString()}))),!t)return r;if(n!=null&&n.id_field){const a=vn(t,n.id_field);(a==null?void 0:a.length)>0&&(r.columnsFromData=Object.keys(a[0]).map(o=>({label:o,value:o})))}return r}function px(e){const{columnsFromConfig:t,columnsFromData:n}=ko(e.instance,e.sampleData),r=t.length>0?t:n,{value:a,set:o}=W(e.trigger.triggerData,"config"),{column:l}=x.defaults({},a,dx),u=c=>{isNaN(+c)?o({column:c}):o({column:+c})};return i(s.Select,{clearable:!1,data:r,label:"Choose a column",value:l.toString(),onChange:u})}function hx(e,t){return e?x.isNumber(e.column)?`Click cell of ${t[e.column].label}`:`Click cell of ${e.column}`:"Click cell content (click to config)"}function fx(e){const{columnsFromConfig:t}=ko(e.instance),{value:n}=W(e.trigger.triggerData,"config");return i(s.Text,{children:hx(n,t)})}const gx=s.createStyles(e=>({root:{overflow:"auto",position:"relative","& .table-head-cell":{display:"flex",flexFlow:"row nowrap",alignItems:"center",whiteSpace:"nowrap","&.table-head-cell--sortable":{cursor:"pointer",userSelect:"none"}},"&.table-highlight-on-hover tr":{transition:"background-color 0.2s","&:hover":{backgroundColor:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[0]}}},thead:{background:e.colorScheme==="dark"?e.colors.dark[7]:e.white,position:"sticky",top:24,transform:"translateY(-1px)",zIndex:10},info_bar:{position:"sticky",top:0,left:0,right:0,zIndex:10,background:"white"}})),mx={tableLayout:"fixed","thead, tbody":{tr:{"th, td":{padding:"2px 10px",div:{overflow:"hidden",textOverflow:"ellipsis"},"&:first-of-type":{paddingLeft:2,paddingRight:2}}}}};function To(e,t,n){return Math.min(Math.max(e,t),n)}class yx{constructor(t){this.steps=t;const n=[],r=new Set;for(const a of t)r.has(a.to)||(n.push(a),r.add(a.to));if(n.sort((a,o)=>a.from-o.from),n.length<2)throw new Error("MultiStepValueMapper requires at least 2 steps");this.steps=n}getLinearFunction(t,n){const r=(n.to-t.to)/(n.from-t.from),a=t.to-r*t.from;return o=>r*o+a}getStepFunctionForValue(t){let n=x.findLastIndex(this.steps,r=>r.from<=t);return n=To(n,0,this.steps.length-2),this.getLinearFunction(this.steps[n],this.steps[n+1])}mapValue(t){return To(this.getStepFunctionForValue(t)(t),0,100)}}class bx{constructor(t,n,r,a,o){this.getColIndex=t,this.cell=n,this.triggers=r,this.interactionManager=a,this.colorManager=o}getClickHandler(){const t=this.getRelatedTrigger();if(t.length!==0)return()=>{const n={row_data:this.cell.row.original,row_index:this.cell.row.index,col_index:this.getColIndex(this.cell)};for(const r of t)this.interactionManager.runInteraction(r.id,n)}}getRelatedTrigger(){return this.triggers.filter(n=>n.schemaRef===di.id).filter(n=>{const r=this.getColIndex(this.cell),a=x.get(this.cell.column.columnDef.meta,"value_field"),o=x.get(n.config,"column");return o==r||o==a})}isClickable(){return this.getRelatedTrigger().length>0}get columnConf(){return this.cell.column.columnDef.meta}get bgColor(){const t=this.columnConf.cellBackgroundColor;if(!t||t==="none")return;if(x.isString(t))return t;const n=+this.cell.getValue();if(isFinite(n)){const r=this.colorManager.decodeInterpolation(t.interpolation),o=new yx(t.steps).mapValue(n);return r==null?void 0:r.getColor(o)}}}const vx=s.createStyles((e,t)=>({content:{display:"flex",alignItems:"center",justifyContent:_o[t.align],".table-cell-text":{whiteSpace:"nowrap",cursor:t.clickable?"pointer":"default",textDecoration:t.clickable?"underline":"none"}}}));function xx(e){return e?ot(e).oklch()[0]>.7?"black":"white":"inherit"}function wx(e){const t=e.tableCellContext.bgColor;return{backgroundColor:t,color:xx(t)}}function Ft(e){const t=e.tableCellContext.isClickable(),n=vx({clickable:t,align:e.align});return i("div",{className:n.classes.content,style:{...wx(e)},children:i(s.Text,{className:"table-cell-text",onClick:e.tableCellContext.getClickHandler(),children:i("span",{title:e.children,children:e.children})})})}function Cx(e){return i(Ft,{...e,children:e.value})}function Sx(e){const t=H(e.value).format({average:!0,mantissa:2,trimMantissa:!0});return i(Ft,{...e,children:t})}function _x(e){const t=H(e.value).format({thousandSeparated:!0});return i(Ft,{...e,children:t})}function kx(e){const t=H(e.value).format({output:"percent",mantissa:3});return i(Ft,{...e,children:t})}function Tx(e){const t=e.value,n=e.func_content;if(!n)return i(Ft,{...e,children:t});const r=new Function(`return ${n}`)()({value:t});return i(Ft,{...e,children:r})}function Dx(e){switch(e.type){case nt.string:return i(Cx,{...e});case nt.eloc:return i(Sx,{...e});case nt.number:return i(_x,{...e});case nt.percentage:return i(kx,{...e});case nt.custom:return i(Tx,{...e})}}const Mx=e=>{const t=et(e),n=He(t.triggerManager,di.id),{colorManager:r}=y.useContext(st);return y.useCallback(a=>new bx(e.getColIndex,a,n,t,r),[n,t,e.getColIndex])};function Ix({data:e,width:t,height:n,conf:r,context:a,instance:o}){var ye,Ie;const{id_field:l,use_raw_columns:u,columns:c,...d}=r,{classes:f,cx:h}=gx(),g=y.useMemo(()=>{if(!l)return[];const fe=V(l);return e[fe.queryID]},[e,l]),m=y.useMemo(()=>u?!Array.isArray(g)||g.length===0?[]:Object.keys(g[0]).map(fe=>({id:fe,label:fe,value_field:fe,value_type:nt.string,align:"left",width:"",cellBackgroundColor:""})):c,[u,c,g]),C=Mx({getColIndex:y.useCallback(fe=>m.indexOf(fe.column.columnDef.meta),[m]),vizManager:a.vizManager,instance:o}),w=y.useMemo(()=>{const fe=Xe.createColumnHelper();return m.map(ge=>{const Le=ac(ge.value_field);return fe.accessor(Le.columnKey,{cell:Qe=>i(Dx,{tableCellContext:C(Qe.cell),value:Qe.getValue(),type:ge.value_type,...ge}),header:ge.label,enableSorting:!0,meta:ge,size:typeof ge.width=="number"?ge.width:void 0,minSize:typeof ge.width=="number"?ge.width:void 0})})},[m,C]),[_,T]=y.useState([]),I=Xe.useReactTable({data:g,state:{sorting:_},onSortingChange:T,columns:w,getCoreRowModel:Xe.getCoreRowModel(),getSortedRowModel:Xe.getSortedRowModel()}),{rows:L}=I.getRowModel(),N=y.useRef(null),O=Tu.useVirtual({parentRef:N,size:L.length,estimateSize:y.useCallback(()=>28,[]),overscan:20}),{virtualItems:A,totalSize:E}=O,F=A.length>0&&((ye=A==null?void 0:A[0])==null?void 0:ye.start)||0,U=A.length>0?E-(((Ie=A==null?void 0:A[A.length-1])==null?void 0:Ie.end)||0):0,Q=L.length,Z=Q>0,se=Z?n-22:n,ue=Z?22:0;return!Array.isArray(g)||g.length===0?i(s.Text,{color:"gray",align:"center",children:"Empty Data"}):p("div",{ref:N,style:{height:n,width:t},"data-enable-scrollbar":!0,className:h(f.root,{"table-highlight-on-hover":r.highlightOnHover}),children:[Q>0&&i(s.Box,{className:f.info_bar,sx:{height:22},children:p(s.Text,{align:"right",pr:6,size:14,color:"dimmed",fw:"normal",children:["Total: ",Q]})}),p(s.Table,{sx:{...mx,maxHeight:se},...d,striped:r.striped,children:[i("thead",{className:f.thead,style:{top:ue},children:I.getHeaderGroups().map(fe=>i("tr",{children:fe.headers.map(ve=>i("th",{style:{width:ve.getSize()},children:i(ux,{header:ve,cx:h})},ve.id))},fe.id))}),p("tbody",{children:[F>0&&i("tr",{children:i("td",{style:{height:`${F}px`}})}),A.map(fe=>{const ve=L[fe.index];return i("tr",{children:ve.getVisibleCells().map(ge=>i("td",{children:Xe.flexRender(ge.column.columnDef.cell,ge.getContext())},ge.id))},ve.id)}),U>0&&i("tr",{children:i("td",{style:{height:`${U}px`}})})]})]})]})}function Ex({context:e,instance:t}){const n=e.data,{height:r,width:a}=e.viewport,{value:o}=W(e.instanceData,"config");return o?o.id_field?i(Ix,{data:n,width:a,height:r,conf:o,context:e,instance:t}):i(s.Text,{color:"red",align:"center",children:"ID Field is not set, can't render a table without it"}):null}const Do=s.createStyles(()=>({palette:{display:"flex",flexFlow:"row nowrap"},paletteItem:{".palette-value":{height:24,overflow:"visible",width:36},".palette-item":{width:"36px",height:36*.618,cursor:"pointer",transition:"transform 100ms ease-in-out","&:hover":{boxShadow:"0 0 0 2px var(--shadow-color)",borderRadius:2,transform:"scale(1.2)"}}}})),Ax=[{from:0,to:0},{from:100,to:100}];class zx{constructor(){q(this,"steps",new Map);q(this,"interpolation");q(this,"onChange");re.makeAutoObservable(this,{steps:re.observable},{deep:!1}),re.reaction(()=>re.toJS(this.steps),()=>{this.notifyStepChange()})}setSteps(t){for(const n of t)this.steps.set(n.to,n.from)}notifyStepChange(){var t;(t=this.onChange)==null||t.call(this,Array.from(this.steps.entries()).map(([n,r])=>({to:n,from:r})).sort((n,r)=>n.to-r.to||n.from-r.from))}fromProps(t){t.steps.length<2?this.setSteps(Ax):this.setSteps(t.steps),this.interpolation=t.interpolation,this.onChange=t.onChange}changeStep(t,n){t==null?this.steps.delete(n):this.steps.set(n,t)}getStepFromValue(t){return this.steps.get(t)}}function $x(e){const{onChange:t,color:n,index:r,value:a}=e,{classes:o}=Do(),[l,u]=y.useState(a),[c,{setTrue:d,setFalse:f}]=X.useBoolean(!1),h=r%2===1,g=h&&a!=null,m=!h&&a!=null,C=`map ${a} to color ${r}`,w=()=>{u(a),f()},_=()=>{f(),t==null||t(l)},T=H(a).format({average:!0});return p("div",{"data-testid":`palette-item-${r}`,className:o.paletteItem,children:[i(s.Text,{title:C,style:{opacity:g?1:0},color:"dimmed",size:"sm",className:"palette-value--up palette-value",children:T}),p(s.Popover,{width:200,trapFocus:!0,opened:c,onClose:f,children:[i(s.Popover.Target,{children:i("div",{"data-testid":"palette-item-target",className:"palette-item",onClick:d,style:{"--shadow-color":ot(n).alpha(.5).hex(),backgroundColor:n}})}),i(s.Popover.Dropdown,{children:p(s.Stack,{children:[i(s.NumberInput,{size:"xs",label:"Map a value to this color",value:l,onChange:u}),p(s.Group,{position:"right",children:[i(s.Button,{variant:"subtle",size:"xs",onClick:w,children:"Cancel"}),i(s.Button,{"data-testid":"palette-item-ok",size:"xs",onClick:_,children:"OK"})]})]})})]}),i(s.Text,{title:C,style:{opacity:m?1:0},color:"dimmed",size:"sm",className:"palette-value--bottom palette-value",children:T})]})}const Ox=k.observer(({model:e})=>{const{classes:t}=Do(),n=x.range(0,13,1).map(r=>100/12*r).map(r=>[e.interpolation.getColor(r),r]);return i("div",{className:t.palette,children:n.map(([r,a],o)=>i($x,{index:o,color:r,value:e.getStepFromValue(a),onChange:l=>e.changeStep(l,a)},r))})}),Lx=k.observer(function(t){const n=X.useCreation(()=>new zx,[]);return y.useEffect(()=>{n.fromProps(t)}),n.interpolation==null?null:i(Ox,{model:n})}),Px=e=>{const{value:t,onChange:n,colorManager:r}=e,a=r.getColorInterpolations(),[o,l]=y.useState(t),u=r.decodeInterpolation(o.interpolation)||a[0],[c,{setTrue:d,setFalse:f}]=X.useBoolean(),h=a.map(_=>({label:_.displayName,value:r.encodeColor(_),group:_.category}));function g(_){_&&l(T=>({...T,interpolation:_}))}const m=()=>{f(),n==null||n(re.toJS(o))};function C(_){l(T=>({...T,steps:_}))}const w=()=>{f(),l(t)};return p(B,{children:[i(s.Button,{variant:"outline",onClick:d,children:u==null?void 0:u.displayName}),i(s.Modal,{size:508,title:"Setup color interpolation",opened:c,onClose:f,zIndex:320,children:c&&p(s.Stack,{"data-testid":"color-interpolation-modal",children:[i(s.Select,{label:"Color style",value:o.interpolation,data:h,onChange:g}),i(Lx,{steps:o.steps,interpolation:u,onChange:C}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:w,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:m,children:"OK"})]})]})})]})},Bx=["static","interpolation","none"].map(e=>({label:x.capitalize(e),value:e})),Vx=[{from:0,to:0},{from:100,to:100}];function Mo(e){return e?x.isString(e)?e==="none"?"none":"static":"interpolation":"none"}function Nx(e,t){var n;return Mo(t)==="static"?t:(n=e.getStaticColors()[0])==null?void 0:n.value}function qx(e,t){return x.isObject(t)?t:{steps:Vx,interpolation:e.encodeColor(e.getColorInterpolations()[0])}}const Fx=y.forwardRef((e,t)=>{const{colorManager:n}=y.useContext(st),[r,a]=y.useState(Mo(e.value)),[o,l]=y.useState(Nx(n,e.value)),u=X.useLatest(o),[c,d]=y.useState(qx(n,e.value)),f=X.useLatest(c),h=C=>{var w,_,T;a(C||"none"),C==="static"?(w=e.onChange)==null||w.call(e,u.current):C==="none"||!C?(_=e.onChange)==null||_.call(e,"none"):(T=e.onChange)==null||T.call(e,f.current)},g=C=>{var w;l(C),(w=e.onChange)==null||w.call(e,C)},m=C=>{var w;d(C),(w=e.onChange)==null||w.call(e,C)};return p(s.Stack,{align:"stretch",children:[i(s.Select,{label:"Cell background",value:r||"none",onChange:h,data:Bx}),r==="static"&&i(Pe,{value:o,onChange:g}),r==="interpolation"&&i(Px,{colorManager:n,value:c,onChange:m})]})}),Gx={[nt.eloc]:"ELOC"},Wx=Object.values(nt).map(e=>({label:x.get(Gx,e,x.capitalize(e)),value:e})),jx=y.forwardRef(({label:e,value:t,onChange:n,sx:r},a)=>i(s.Select,{ref:a,label:e,data:Wx,value:t,onChange:n,sx:r})),Rx=y.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:a,setFalse:o}]=X.useBoolean(),[l,u]=y.useState(e),c=()=>{o(),t(l)},d=()=>{o(),u(e)},f=()=>{u(Co)};return y.useEffect(()=>{u(e)},[e]),p(B,{children:[i(s.Button,{variant:"filled",mt:24,onClick:a,sx:{flexGrow:0},children:"Custom Cell Content"}),i(s.Modal,{size:800,title:"Custom cell content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&p(s.Stack,{children:[i(s.Box,{sx:{position:"relative"},children:i(Ae,{height:"500px",defaultLanguage:"javascript",value:l,onChange:h=>u(h??""),theme:"vs-dark",options:{minimap:{enabled:!1}}})}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:f,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Rest"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:d,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:c,children:"OK"})]})]})]})})]})}),Yx=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}],pi=()=>i(s.Text,{color:"dimmed",size:12,children:"px"}),Qx=({control:e,index:t,watch:n,remove:r,column:a})=>{const o=n(`columns.${t}.value_type`);return p(s.Stack,{my:0,sx:{position:"relative"},children:[p(s.Group,{grow:!0,children:[i(v.Controller,{name:`columns.${t}.label`,control:e,render:({field:l})=>i(s.TextInput,{label:"Label",required:!0,id:`col-label-${t}`,sx:{flex:1},...l})}),i(v.Controller,{name:`columns.${t}.value_field`,control:e,render:({field:l})=>i(j,{label:"Value Field",required:!0,...l})})]}),p(s.Group,{grow:!0,children:[i(v.Controller,{name:`columns.${t}.value_type`,control:e,render:({field:l})=>i(jx,{label:"Value Type",sx:{flex:1},...l})}),o===nt.custom&&i(v.Controller,{name:`columns.${t}.func_content`,control:e,render:({field:l})=>i(Rx,{value:l.value??Co,onChange:u=>l.onChange(u??"")})})]}),i(s.Divider,{mb:-10,variant:"dashed",label:"Style",labelPosition:"center"}),p(s.Group,{grow:!0,children:[i(s.NumberInput,{hideControls:!0,label:"Min Width",rightSection:i(pi,{}),disabled:!0}),i(v.Controller,{name:`columns.${t}.width`,control:e,render:({field:l})=>i(s.NumberInput,{hideControls:!0,label:"Width",rightSection:i(pi,{}),...l})}),i(s.NumberInput,{hideControls:!0,label:"Max Width",rightSection:i(pi,{}),disabled:!0})]}),i(s.Group,{grow:!0,noWrap:!0,children:i(v.Controller,{name:`columns.${t}.align`,control:e,render:({field:l})=>i(s.Select,{label:"Alignment",data:Yx,...l})})}),i(v.Controller,{name:`columns.${t}.cellBackgroundColor`,control:e,render:({field:l})=>i(Fx,{...l})}),i(s.Divider,{mb:4,mt:12,variant:"dashed"}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>r(t),children:"Delete this column"})]})},Kx=({control:e,watch:t})=>{const{fields:n,append:r,remove:a,update:o}=v.useFieldArray({control:e,name:"columns"}),l=()=>{const c=Ee.randomId();r({id:c,label:c,align:"center",value_field:"",value_type:nt.string,width:""})};t("columns");const u=t("use_raw_columns");return p(B,{children:[i(v.Controller,{name:"use_raw_columns",control:e,render:({field:c})=>i(s.Switch,{mt:20,mb:20,label:"Use Original Data Columns",checked:c.value,onChange:d=>c.onChange(d.currentTarget.checked)})}),!u&&i(s.Stack,{children:p(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[p(s.Tabs.List,{children:[n.map((c,d)=>i(s.Tabs.Tab,{value:d.toString(),children:d+1},c.id)),i(s.Tabs.Tab,{onClick:l,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),n.map((c,d)=>i(s.Tabs.Panel,{value:d.toString(),children:i(Qx,{control:e,watch:t,index:d,column:c,remove:a},d)},c.id))]})})]})};function Ux({control:e,watch:t}){return t(["horizontalSpacing","verticalSpacing","fontSize","striped","highlightOnHover"]),p(s.Stack,{spacing:"xs",children:[p(s.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[i(v.Controller,{name:"horizontalSpacing",control:e,render:({field:n})=>i(s.TextInput,{label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...n})}),i(v.Controller,{name:"verticalSpacing",control:e,render:({field:n})=>i(s.TextInput,{label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...n})})]}),i(s.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:i(v.Controller,{name:"fontSize",control:e,render:({field:n})=>i(s.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...n})})}),p(s.Group,{position:"apart",grow:!0,children:[i(v.Controller,{name:"striped",control:e,render:({field:n})=>i(s.Switch,{label:"Striped",checked:n.value,onChange:r=>n.onChange(r.currentTarget.checked)})}),i(v.Controller,{name:"highlightOnHover",control:e,render:({field:n})=>i(s.Switch,{label:"Highlight on hover",checked:n.value,onChange:r=>n.onChange(r.currentTarget.checked)})})]})]})}function Xx({columns:e,...t}){return{...t,columns:e.map(({id:n,...r})=>({id:n??Ee.randomId(),...r}))}}function Jx({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaultsDeep({},t,So),[t]),a=y.useMemo(()=>Xx(r),[r]);y.useEffect(()=>{!x.isEqual(r,a)&&(console.log("config malformed, resetting to defaults",r,a),n(a))},[r,a]);const{control:o,handleSubmit:l,watch:u,getValues:c,reset:d}=v.useForm({defaultValues:a});y.useEffect(()=>{d(a)},[a]);const f=c(),h=y.useMemo(()=>!x.isEqual(f,r),[f,r]);return u(["id_field"]),p("form",{onSubmit:l(n),children:[p(s.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Table Config"}),i(s.ActionIcon,{type:"submit","aria-label":"save config",mr:5,variant:"filled",color:"blue",disabled:!h,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Tabs,{defaultValue:"Columns",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"Columns",children:"Columns"}),i(s.Tabs.Tab,{value:"Style",children:"Style"})]}),p(s.Tabs.Panel,{value:"Columns",children:[i(v.Controller,{name:"id_field",control:o,render:({field:g})=>i(j,{label:"ID Field",required:!0,...g})}),i(s.Divider,{mt:20,mb:10,variant:"dashed"}),i(Kx,{control:o,watch:u})]}),i(s.Tabs.Panel,{value:"Style",children:i(Ux,{control:o,watch:u})})]})]})}function Zx(e){const{columns:t,...n}=e;return{...e,columns:t.map(r=>({...r,align:r.align??"left"}))}}function Hx(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{id_field:a,columns:o,...l}=e;return{...l,id_field:r(a),columns:o.map(u=>({...u,value_field:r(u.value_field)}))}}catch(n){throw console.error("[Migration failed]",n),n}}function e0(e){const{columns:t,...n}=e;return{...n,columns:t.map(r=>({...r,align:r.align??"left",cellBackgroundColor:r.cellBackgroundColor??"",width:r.width??""}))}}class t0 extends be{constructor(){super(...arguments);q(this,"VERSION",5)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{columns:r,...a}=n.config;return{...n,version:2,config:{...a,columns:r.map(({id:o,...l})=>({id:o??Ee.randomId(),...l}))}}}),this.version(3,n=>({...n,version:3,config:Zx(n.config)})),this.version(4,(n,r)=>({...n,version:4,config:Hx(n.config,r)})),this.version(5,n=>({...n,version:5,config:e0(n.config)}))}}const hi={createConfig(){return{version:5,config:x.cloneDeep(So)}},displayName:"Table",displayGroup:"Others",migrator:new t0,name:"table",viewRender:Ex,configRender:Jx,triggers:[di]},Io=["function text({ data, variables, filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
296
|
-
`),fi={func_content:Io,horizontal_align:"left",font_size:"14px",font_weight:"normal"},n0=k.observer(({context:e})=>{const t=we(),{value:n=fi}=W(e.instanceData,"config"),{variables:r}=e,a=e.data,{func_content:o,horizontal_align:l,font_size:u,font_weight:c}=n,d=y.useMemo(()=>r.reduce((h,g)=>{const m=bt(g,a);return h[g.name]=tt(g,m),h},{}),[r,a]),f=y.useMemo(()=>new Function(`return ${o}`)()({data:a,variables:d,filters:t.payloadForSQL.filters,context:t.payloadForSQL.context}),[o,a,d,t.payloadForSQL]);return i(s.Text,{align:l,weight:c,sx:{fontSize:u},children:f})}),r0=({value:e,onChange:t})=>{const n=r=>{r&&t(r)};return i(s.Box,{sx:{position:"relative"},children:i(Ae,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},i0=y.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:a,setFalse:o}]=X.useBoolean(),[l,u]=y.useState(e),c=()=>{o(),t(l)},d=()=>{o(),u(e)},f=()=>{u(Io)};return y.useEffect(()=>{u(e)},[e]),p(B,{children:[i(s.Button,{variant:"filled",mt:24,onClick:a,sx:{flexGrow:0},children:"Edit Content"}),i(s.Modal,{size:800,title:"Text content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&p(s.Stack,{children:[i(r0,{value:l,onChange:u}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:f,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Rest"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:d,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:c,children:"OK"})]})]})]})})]})}),a0=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}];function s0({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaultsDeep({},t,fi),[t]),a=y.useMemo(()=>{const{func_content:g,horizontal_align:m,font_size:C,font_weight:w}=r;return{func_content:g,horizontal_align:m,font_size:C,font_weight:w}},[r]);y.useEffect(()=>{!x.isEqual(r,a)&&(console.log("config malformed, resetting to defaults",r,a),n(a))},[r,a]);const{control:o,handleSubmit:l,watch:u,getValues:c,reset:d}=v.useForm({defaultValues:a});y.useEffect(()=>{d(a)},[a]),u(["func_content","horizontal_align","font_size","font_weight"]);const f=c(),h=y.useMemo(()=>!x.isEqual(f,r),[f,r]);return i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:l(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{weight:500,children:"Configurations"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Stack,{spacing:10,children:[i(v.Controller,{name:"func_content",control:o,render:({field:g})=>i(i0,{...g})}),i(s.Divider,{mt:10,mb:-10,variant:"dashed",label:"Style",labelPosition:"center"}),i(v.Controller,{name:"horizontal_align",control:o,render:({field:g})=>i(s.Select,{label:"Horizontal Alignment",data:a0,...g})}),i(v.Controller,{name:"font_size",control:o,render:({field:g})=>i(s.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},...g})}),i(s.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:i(v.Controller,{name:"font_weight",control:o,render:({field:g})=>i(us,{label:"Font Weight",...g})})})]})]})})}class o0 extends be{constructor(){super(...arguments);q(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const l0={displayName:"Text",displayGroup:"Others",migrator:new o0,name:"text",viewRender:n0,configRender:s0,createConfig(){return{version:1,config:x.cloneDeep(fi)}}},u0=()=>p("svg",{width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[i("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22.49 27.79H14.47C13.55 27.79 12.81 28.53 12.81 29.45C12.81 30.37 13.55 31.11 14.47 31.11H22.49C23.41 31.11 24.15 30.37 24.15 29.45C24.15 28.54 23.41 27.79 22.49 27.79ZM34.32 31.28C35.22 31.32 35.7 31.82 35.74 32.76C35.78 33.54 35.37 34.3 34.51 35.04C33.52 35.9 33.03 36.95 33.03 38.19V38.81H34.82V38.25C34.78 37.59 35.07 37.02 35.68 36.52C37.12 35.41 37.82 34.15 37.78 32.75C37.66 30.53 36.5 29.35 34.32 29.23C32.3 29.23 31.05 30.46 30.55 32.93L32.53 33.55C32.82 32.04 33.42 31.28 34.32 31.28ZM35 39.93H32.84V42.21H35V39.93ZM14.83 36.42H18.54C19.46 36.42 20.2 37.17 20.2 38.08C20.2 39 19.46 39.74 18.54 39.74H10.52C9.6 39.74 8.86 39 8.86 38.08C8.86 37.61 9.06 37.19 9.37 36.89H5.66C4.74 36.89 4 36.15 4 35.23C4 34.31 4.74 33.57 5.66 33.57H13.68C14.6 33.57 15.34 34.31 15.34 35.23C15.34 35.7 15.14 36.12 14.83 36.42ZM50.94 36.85H58.74C59.66 36.85 60.4 37.59 60.41 38.51C60.41 39.43 59.67 40.17 58.75 40.17H54.26C54.56 40.47 54.74 40.88 54.74 41.34C54.74 42.26 54 43 53.08 43H50.94V36.85Z",fill:"#B8C0CC"}),i("path",{d:"M18.39 32.28H16.51V35.02H18.39V32.28Z",fill:"#9399A5"}),i("path",{d:"M46.87 15H20.69C18.38 15 16.5 16.88 16.5 19.19V26.22H18.38V23.45H49.18V47.68H18.38V41.07H16.5V49.55H51.05V19.19C51.06 16.88 49.18 15 46.87 15ZM39.46 20.73C38.81 20.73 38.29 20.2 38.29 19.56C38.29 18.92 38.82 18.39 39.46 18.39C40.11 18.39 40.63 18.92 40.63 19.56C40.63 20.2 40.11 20.73 39.46 20.73ZM43.22 20.73C42.57 20.73 42.05 20.2 42.05 19.56C42.05 18.92 42.58 18.39 43.22 18.39C43.87 18.39 44.39 18.92 44.39 19.56C44.39 20.2 43.87 20.73 43.22 20.73ZM46.97 20.73C46.32 20.73 45.8 20.2 45.8 19.56C45.8 18.92 46.33 18.39 46.97 18.39C47.62 18.39 48.14 18.92 48.14 19.56C48.14 20.2 47.62 20.73 46.97 20.73Z",fill:"#9399A5"})]});function Eo(e,t){const n=x.get(e,t,"");if(n)throw new Error(n)}async function c0(e,t,n,r={}){const a={"X-Requested-With":"XMLHttpRequest","Content-Type":r.string?"application/x-www-form-urlencoded":"application/json",...r.headers},o={baseURL:e,method:"POST",url:t,params:r.params,headers:a};return o.data=r.string?JSON.stringify(n):n,ht(o).then(l=>l.data).catch(l=>Promise.reject(l))}const d0=({conf:e,panelData:t})=>async()=>{const{expertSystemURL:n,path:r,goal:a,question:o}=e;if(!r||!a||!o)return;const l=sc(t);if(!l)return;const u={dashboard:a,panel:o,data:l};try{const c=n.startsWith("http")?n:window.location.origin;return await c0(c,`/expert/v3/devtable/${r}`,u,{})}catch(c){throw Eo(c,"response.data.detail"),Eo(c,"response.data.error"),console.error(c),c}},gi={expertSystemURL:"",path:"",goal:"",question:""},mi={height:"100%",overflowY:"auto",...Rr},Ao=({message:e})=>i(s.Box,{sx:mi,children:i("div",{dangerouslySetInnerHTML:{__html:e},style:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45"}})}),p0=({error:e,width:t,height:n})=>{const r=e.message;if(r.startsWith("<"))return i(Ao,{message:r});const o=n-25-20-30;return i(s.Center,{sx:{width:"100%",height:o},children:p(s.Stack,{align:"center",spacing:20,children:[i(u0,{}),i(Ao,{message:r})]})})};function h0({context:e}){const{value:t}=W(e.instanceData,"config"),n=y.useMemo(()=>x.defaultsDeep({},t,gi),[t]),{width:r,height:a}=e.viewport,o=e.data,{data:l,error:u,loading:c}=X.useRequest(d0({conf:n,panelData:o}),{refreshDeps:[o,n]});return!r||!a||!n?null:c?i(s.Box,{sx:{position:"relative",height:a},children:i(s.LoadingOverlay,{visible:!0})}):u?i(s.Box,{sx:mi,"data-enable-scrollbar":!0,children:i(p0,{error:u,width:r,height:a})}):!l||!Array.isArray(l.replies)||l.replies.length===0?null:i(s.Box,{sx:mi,"data-enable-scrollbar":!0,children:l.replies.map((d,f)=>i("div",{dangerouslySetInnerHTML:{__html:d.interpretation.html}},f))})}function f0({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaultsDeep({},t,gi),[t]),{control:a,handleSubmit:o,watch:l,getValues:u,reset:c}=v.useForm({defaultValues:r});y.useEffect(()=>{c(r)},[r]),l(["expertSystemURL","goal","path","question"]);const d=u(),f=y.useMemo(()=>!x.isEqual(d,r),[d,r]);return i("form",{onSubmit:o(n),children:p(s.Stack,{children:[p(s.Group,{grow:!0,children:[i(v.Controller,{name:"expertSystemURL",control:a,render:({field:h})=>i(s.TextInput,{label:"Expert System URL",...h})}),i(v.Controller,{name:"path",control:a,render:({field:h})=>i(s.TextInput,{label:"Path",required:!0,...h})})]}),p(s.Group,{grow:!0,children:[i(v.Controller,{name:"goal",control:a,render:({field:h})=>i(s.TextInput,{label:"Goal",required:!0,...h})}),i(v.Controller,{name:"question",control:a,render:({field:h})=>i(s.TextInput,{label:"Question",required:!0,...h})})]}),i(s.Divider,{variant:"dashed",mt:16,mb:8}),i(s.Button,{type:"submit",variant:"filled",color:"blue",leftIcon:i(D.DeviceFloppy,{size:20}),disabled:!f,sx:{alignSelf:"flex-end"},children:"Submit Changes"})]})})}class g0 extends be{constructor(){super(...arguments);q(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const m0={displayName:"Merico GQM",displayGroup:"Merico suite",migrator:new g0,name:"mericoGQM",viewRender:h0,configRender:f0,createConfig(){return{version:1,config:x.cloneDeep(gi)}}};function y0(e,t,n){if(!e)return n[0];try{return[t,Y(t).add(1,"year").subtract(1,"day").valueOf()]}catch(r){return console.error(r),n[0]}}function b0(e,t,n){const r=y0(e,t,n);return{top:50,left:25,right:5,cellSize:["auto",13],range:r,itemStyle:{borderColor:"#eee"},splitLine:{show:!0},dayLabel:{firstDay:1},monthLabel:{position:"end"},yearLabel:{show:!0}}}function v0(e){return{heat_block:function(r){if(!e.heat_block.value_formatter)return r;try{return H(r).format(e.heat_block.value_formatter)}catch(a){return console.error(a),r}}}}function x0(e,t){return{show:!e,selectedMode:"single",top:5,right:5,data:t.map(n=>({name:n,icon:"circle"}))}}function w0(e,t,n,r){const{calendar:a,heat_block:o}=e,l=V(a.data_key),u=V(o.data_key);return t?{type:"heatmap",name:"heatmap",coordinateSystem:"calendar",calendarIndex:0,data:r[l.queryID].map(c=>[x.get(c,l.columnKey),x.get(c,u.columnKey)])}:Object.entries(n).map(([c,d])=>({type:"heatmap",name:c,coordinateSystem:"calendar",calendarIndex:0,data:d.map(f=>[x.get(f,l.columnKey),x.get(f,u.columnKey)])}))}const C0=e=>{try{return H(e).format({trimMantissa:!0,mantissa:2})}catch{return e}};function S0({conf:e,valueFormatters:t,dataDict:n,params:r}){const{value:a}=r,[o,l]=a,c=[{label:e.heat_block.name,value:t.heat_block(l),style:{label:"",value:""}}],d=n[o];return d&&e.tooltip.metrics.forEach(f=>{const h=V(f.data_key);c.push({label:f.name,value:C0(x.get(d,h.columnKey,"")),style:{label:"",value:""}})}),c}function _0(e,t,n){const r=V(e.calendar.data_key),a=x.keyBy(t[r.queryID],r.columnKey);return{confine:!0,formatter:function(o){const u=S0({conf:e,valueFormatters:n,dataDict:a,params:o}).map(f=>`
|
|
295
|
+
`),So={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",id_field:"",striped:!0,use_raw_columns:!0,verticalSpacing:"14px"},_o={left:"flex-start",center:"center",right:"flex-end"},ux=({header:e,cx:t})=>{const n=x.get(e.column.columnDef.meta,"align","left");return p(s.Text,{className:t("table-head-cell",{"table-head-cell--sortable":e.column.getCanSort()}),onClick:e.column.getToggleSortingHandler(),align:n,sx:{justifyContent:_o[n]},children:[e.isPlaceholder?null:Xe.flexRender(e.column.columnDef.header,e.getContext()),i(cx,{direction:e.column.getIsSorted()})]})},cx=({direction:e})=>{switch(e){case"asc":return i($.IconArrowUp,{size:16});case"desc":return i($.IconArrowDown,{size:"1em"});default:return null}},di={id:"builtin:table:click-cell-content",displayName:"Click Cell Content",nameRender:fx,configRender:px,payload:[{name:"row_index",description:"Index of the row that the cell belongs to",valueType:"number"},{name:"col_index",description:"Index of the column that the cell belongs to",valueType:"number"},{name:"row_data",description:"Data of the row that the cell belongs to",valueType:"object"}]},dx={column:""};function ko(e,t){const{value:n}=W(e.instanceData,"config"),r={columnsFromConfig:[],columnsFromData:[]};if(n&&(r.columnsFromConfig=n.columns.map((a,o)=>({label:a.label,value:o.toString()}))),!t)return r;if(n!=null&&n.id_field){const a=vn(t,n.id_field);(a==null?void 0:a.length)>0&&(r.columnsFromData=Object.keys(a[0]).map(o=>({label:o,value:o})))}return r}function px(e){const{columnsFromConfig:t,columnsFromData:n}=ko(e.instance,e.sampleData),r=t.length>0?t:n,{value:a,set:o}=W(e.trigger.triggerData,"config"),{column:l}=x.defaults({},a,dx),u=c=>{isNaN(+c)?o({column:c}):o({column:+c})};return i(s.Select,{clearable:!1,data:r,label:"Choose a column",value:l.toString(),onChange:u})}function hx(e,t){return e?x.isNumber(e.column)?`Click cell of ${t[e.column].label}`:`Click cell of ${e.column}`:"Click cell content (click to config)"}function fx(e){const{columnsFromConfig:t}=ko(e.instance),{value:n}=W(e.trigger.triggerData,"config");return i(s.Text,{children:hx(n,t)})}const gx=s.createStyles(e=>({root:{overflow:"auto",position:"relative","& .table-head-cell":{display:"flex",flexFlow:"row nowrap",alignItems:"center",whiteSpace:"nowrap","&.table-head-cell--sortable":{cursor:"pointer",userSelect:"none"}},"&.table-highlight-on-hover tr":{transition:"background-color 0.2s","&:hover":{backgroundColor:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[0]}}},thead:{background:e.colorScheme==="dark"?e.colors.dark[7]:e.white,position:"sticky",top:24,transform:"translateY(-1px)",zIndex:10},info_bar:{position:"sticky",top:0,left:0,right:0,zIndex:10,background:"white"}})),mx={tableLayout:"fixed","thead, tbody":{tr:{"th, td":{padding:"2px 10px",div:{overflow:"hidden",textOverflow:"ellipsis"},"&:first-of-type":{paddingLeft:2,paddingRight:2}}}}};function To(e,t,n){return Math.min(Math.max(e,t),n)}class yx{constructor(t){this.steps=t;const n=[],r=new Set;for(const a of t)r.has(a.to)||(n.push(a),r.add(a.to));if(n.sort((a,o)=>a.from-o.from),n.length<2)throw new Error("MultiStepValueMapper requires at least 2 steps");this.steps=n}getLinearFunction(t,n){const r=(n.to-t.to)/(n.from-t.from),a=t.to-r*t.from;return o=>r*o+a}getStepFunctionForValue(t){let n=x.findLastIndex(this.steps,r=>r.from<=t);return n=To(n,0,this.steps.length-2),this.getLinearFunction(this.steps[n],this.steps[n+1])}mapValue(t){return To(this.getStepFunctionForValue(t)(t),0,100)}}class bx{constructor(t,n,r,a,o){this.getColIndex=t,this.cell=n,this.triggers=r,this.interactionManager=a,this.colorManager=o}getClickHandler(){const t=this.getRelatedTrigger();if(t.length!==0)return()=>{const n={row_data:this.cell.row.original,row_index:this.cell.row.index,col_index:this.getColIndex(this.cell)};for(const r of t)this.interactionManager.runInteraction(r.id,n)}}getRelatedTrigger(){return this.triggers.filter(n=>n.schemaRef===di.id).filter(n=>{const r=this.getColIndex(this.cell),a=x.get(this.cell.column.columnDef.meta,"value_field"),o=x.get(n.config,"column");return o==r||o==a})}isClickable(){return this.getRelatedTrigger().length>0}get columnConf(){return this.cell.column.columnDef.meta}get bgColor(){const t=this.columnConf.cellBackgroundColor;if(!t||t==="none")return;if(x.isString(t))return t;const n=+this.cell.getValue();if(isFinite(n)){const r=this.colorManager.decodeInterpolation(t.interpolation),o=new yx(t.steps).mapValue(n);return r==null?void 0:r.getColor(o)}}}const vx=s.createStyles((e,t)=>({content:{display:"flex",alignItems:"center",justifyContent:_o[t.align],".table-cell-text":{whiteSpace:"nowrap",cursor:t.clickable?"pointer":"default",textDecoration:t.clickable?"underline":"none"}}}));function xx(e){return e?ot(e).oklch()[0]>.7?"black":"white":"inherit"}function wx(e){const t=e.tableCellContext.bgColor;return{backgroundColor:t,color:xx(t)}}function Ft(e){const t=e.tableCellContext.isClickable(),n=vx({clickable:t,align:e.align});return i("div",{className:n.classes.content,style:{...wx(e)},children:i(s.Text,{className:"table-cell-text",onClick:e.tableCellContext.getClickHandler(),children:i("span",{title:e.children,children:e.children})})})}function Cx(e){return i(Ft,{...e,children:e.value})}function Sx(e){const t=H(e.value).format({average:!0,mantissa:2,trimMantissa:!0});return i(Ft,{...e,children:t})}function _x(e){const t=H(e.value).format({thousandSeparated:!0});return i(Ft,{...e,children:t})}function kx(e){const t=H(e.value).format({output:"percent",mantissa:3});return i(Ft,{...e,children:t})}function Tx(e){const t=e.value,n=e.func_content;if(!n)return i(Ft,{...e,children:t});const r=new Function(`return ${n}`)()({value:t});return i(Ft,{...e,children:r})}function Dx(e){switch(e.type){case nt.string:return i(Cx,{...e});case nt.eloc:return i(Sx,{...e});case nt.number:return i(_x,{...e});case nt.percentage:return i(kx,{...e});case nt.custom:return i(Tx,{...e})}}const Mx=e=>{const t=et(e),n=He(t.triggerManager,di.id),{colorManager:r}=y.useContext(st);return y.useCallback(a=>new bx(e.getColIndex,a,n,t,r),[n,t,e.getColIndex])};function Ix({data:e,width:t,height:n,conf:r,context:a,instance:o}){var ye,Ie;const{id_field:l,use_raw_columns:u,columns:c,...d}=r,{classes:f,cx:h}=gx(),g=y.useMemo(()=>{if(!l)return[];const fe=V(l);return e[fe.queryID]},[e,l]),m=y.useMemo(()=>u?!Array.isArray(g)||g.length===0?[]:Object.keys(g[0]).map(fe=>({id:fe,label:fe,value_field:fe,value_type:nt.string,align:"left",width:"",cellBackgroundColor:""})):c,[u,c,g]),C=Mx({getColIndex:y.useCallback(fe=>m.indexOf(fe.column.columnDef.meta),[m]),vizManager:a.vizManager,instance:o}),w=y.useMemo(()=>{const fe=Xe.createColumnHelper();return m.map(ge=>{const Le=ac(ge.value_field);return fe.accessor(Le.columnKey,{cell:Qe=>i(Dx,{tableCellContext:C(Qe.cell),value:Qe.getValue(),type:ge.value_type,...ge}),header:ge.label,enableSorting:!0,meta:ge,size:typeof ge.width=="number"?ge.width:void 0,minSize:typeof ge.width=="number"?ge.width:void 0})})},[m,C]),[_,T]=y.useState([]),I=Xe.useReactTable({data:g,state:{sorting:_},onSortingChange:T,columns:w,getCoreRowModel:Xe.getCoreRowModel(),getSortedRowModel:Xe.getSortedRowModel()}),{rows:L}=I.getRowModel(),N=y.useRef(null),O=Tu.useVirtual({parentRef:N,size:L.length,estimateSize:y.useCallback(()=>28,[]),overscan:20}),{virtualItems:A,totalSize:E}=O,F=A.length>0&&((ye=A==null?void 0:A[0])==null?void 0:ye.start)||0,U=A.length>0?E-(((Ie=A==null?void 0:A[A.length-1])==null?void 0:Ie.end)||0):0,Q=L.length,Z=Q>0,se=Z?n-22:n,ue=Z?22:0;return!Array.isArray(g)||g.length===0?i(s.Text,{color:"gray",align:"center",children:"Empty Data"}):p("div",{ref:N,style:{height:n,width:t},"data-enable-scrollbar":!0,className:h(f.root,{"table-highlight-on-hover":r.highlightOnHover}),children:[Q>0&&i(s.Box,{className:f.info_bar,sx:{height:22},children:p(s.Text,{align:"right",pr:6,size:14,color:"dimmed",fw:"normal",children:["Total: ",Q]})}),p(s.Table,{sx:{...mx,maxHeight:se},...d,striped:r.striped,children:[i("thead",{className:f.thead,style:{top:ue},children:I.getHeaderGroups().map(fe=>i("tr",{children:fe.headers.map(ve=>i("th",{style:{width:ve.getSize()},children:i(ux,{header:ve,cx:h})},ve.id))},fe.id))}),p("tbody",{children:[F>0&&i("tr",{children:i("td",{style:{height:`${F}px`}})}),A.map(fe=>{const ve=L[fe.index];return i("tr",{children:ve.getVisibleCells().map(ge=>i("td",{children:Xe.flexRender(ge.column.columnDef.cell,ge.getContext())},ge.id))},ve.id)}),U>0&&i("tr",{children:i("td",{style:{height:`${U}px`}})})]})]})]})}function Ex({context:e,instance:t}){const n=e.data,{height:r,width:a}=e.viewport,{value:o}=W(e.instanceData,"config");return o?o.id_field?i(Ix,{data:n,width:a,height:r,conf:o,context:e,instance:t}):i(s.Text,{color:"red",align:"center",children:"ID Field is not set, can't render a table without it"}):null}const Do=s.createStyles(()=>({palette:{display:"flex",flexFlow:"row nowrap"},paletteItem:{".palette-value":{height:24,overflow:"visible",width:36},".palette-item":{width:"36px",height:36*.618,cursor:"pointer",transition:"transform 100ms ease-in-out","&:hover":{boxShadow:"0 0 0 2px var(--shadow-color)",borderRadius:2,transform:"scale(1.2)"}}}})),Ax=[{from:0,to:0},{from:100,to:100}];class zx{constructor(){q(this,"steps",new Map);q(this,"interpolation");q(this,"onChange");re.makeAutoObservable(this,{steps:re.observable},{deep:!1}),re.reaction(()=>re.toJS(this.steps),()=>{this.notifyStepChange()})}setSteps(t){for(const n of t)this.steps.set(n.to,n.from)}notifyStepChange(){var t;(t=this.onChange)==null||t.call(this,Array.from(this.steps.entries()).map(([n,r])=>({to:n,from:r})).sort((n,r)=>n.to-r.to||n.from-r.from))}fromProps(t){t.steps.length<2?this.setSteps(Ax):this.setSteps(t.steps),this.interpolation=t.interpolation,this.onChange=t.onChange}changeStep(t,n){t==null?this.steps.delete(n):this.steps.set(n,t)}getStepFromValue(t){return this.steps.get(t)}}function $x(e){const{onChange:t,color:n,index:r,value:a}=e,{classes:o}=Do(),[l,u]=y.useState(a),[c,{setTrue:d,setFalse:f}]=X.useBoolean(!1),h=r%2===1,g=h&&a!=null,m=!h&&a!=null,C=`map ${a} to color ${r}`,w=()=>{u(a),f()},_=()=>{f(),t==null||t(l)},T=H(a).format({average:!0});return p("div",{"data-testid":`palette-item-${r}`,className:o.paletteItem,children:[i(s.Text,{title:C,style:{opacity:g?1:0},color:"dimmed",size:"sm",className:"palette-value--up palette-value",children:T}),p(s.Popover,{width:200,trapFocus:!0,opened:c,onClose:f,children:[i(s.Popover.Target,{children:i("div",{"data-testid":"palette-item-target",className:"palette-item",onClick:d,style:{"--shadow-color":ot(n).alpha(.5).hex(),backgroundColor:n}})}),i(s.Popover.Dropdown,{children:p(s.Stack,{children:[i(s.NumberInput,{size:"xs",label:"Map a value to this color",value:l,onChange:u}),p(s.Group,{position:"right",children:[i(s.Button,{variant:"subtle",size:"xs",onClick:w,children:"Cancel"}),i(s.Button,{"data-testid":"palette-item-ok",size:"xs",onClick:_,children:"OK"})]})]})})]}),i(s.Text,{title:C,style:{opacity:m?1:0},color:"dimmed",size:"sm",className:"palette-value--bottom palette-value",children:T})]})}const Ox=k.observer(({model:e})=>{const{classes:t}=Do(),n=x.range(0,13,1).map(r=>100/12*r).map(r=>[e.interpolation.getColor(r),r]);return i("div",{className:t.palette,children:n.map(([r,a],o)=>i($x,{index:o,color:r,value:e.getStepFromValue(a),onChange:l=>e.changeStep(l,a)},r))})}),Lx=k.observer(function(t){const n=X.useCreation(()=>new zx,[]);return y.useEffect(()=>{n.fromProps(t)}),n.interpolation==null?null:i(Ox,{model:n})}),Px=e=>{const{value:t,onChange:n,colorManager:r}=e,a=r.getColorInterpolations(),[o,l]=y.useState(t),u=r.decodeInterpolation(o.interpolation)||a[0],[c,{setTrue:d,setFalse:f}]=X.useBoolean(),h=a.map(_=>({label:_.displayName,value:r.encodeColor(_),group:_.category}));function g(_){_&&l(T=>({...T,interpolation:_}))}const m=()=>{f(),n==null||n(re.toJS(o))};function C(_){l(T=>({...T,steps:_}))}const w=()=>{f(),l(t)};return p(B,{children:[i(s.Button,{variant:"outline",onClick:d,children:u==null?void 0:u.displayName}),i(s.Modal,{size:508,title:"Setup color interpolation",opened:c,onClose:f,zIndex:320,children:c&&p(s.Stack,{"data-testid":"color-interpolation-modal",children:[i(s.Select,{label:"Color style",value:o.interpolation,data:h,onChange:g}),i(Lx,{steps:o.steps,interpolation:u,onChange:C}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:w,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:m,children:"OK"})]})]})})]})},Bx=["static","interpolation","none"].map(e=>({label:x.capitalize(e),value:e})),Vx=[{from:0,to:0},{from:100,to:100}];function Mo(e){return e?x.isString(e)?e==="none"?"none":"static":"interpolation":"none"}function Nx(e,t){var n;return Mo(t)==="static"?t:(n=e.getStaticColors()[0])==null?void 0:n.value}function qx(e,t){return x.isObject(t)?t:{steps:Vx,interpolation:e.encodeColor(e.getColorInterpolations()[0])}}const Fx=y.forwardRef((e,t)=>{const{colorManager:n}=y.useContext(st),[r,a]=y.useState(Mo(e.value)),[o,l]=y.useState(Nx(n,e.value)),u=X.useLatest(o),[c,d]=y.useState(qx(n,e.value)),f=X.useLatest(c),h=C=>{var w,_,T;a(C||"none"),C==="static"?(w=e.onChange)==null||w.call(e,u.current):C==="none"||!C?(_=e.onChange)==null||_.call(e,"none"):(T=e.onChange)==null||T.call(e,f.current)},g=C=>{var w;l(C),(w=e.onChange)==null||w.call(e,C)},m=C=>{var w;d(C),(w=e.onChange)==null||w.call(e,C)};return p(s.Stack,{align:"stretch",children:[i(s.Select,{label:"Cell background",value:r||"none",onChange:h,data:Bx}),r==="static"&&i(Pe,{value:o,onChange:g}),r==="interpolation"&&i(Px,{colorManager:n,value:c,onChange:m})]})}),Gx={[nt.eloc]:"ELOC"},Wx=Object.values(nt).map(e=>({label:x.get(Gx,e,x.capitalize(e)),value:e})),jx=y.forwardRef(({label:e,value:t,onChange:n,sx:r},a)=>i(s.Select,{ref:a,label:e,data:Wx,value:t,onChange:n,sx:r})),Rx=y.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:a,setFalse:o}]=X.useBoolean(),[l,u]=y.useState(e),c=()=>{o(),t(l)},d=()=>{o(),u(e)},f=()=>{u(Co)};return y.useEffect(()=>{u(e)},[e]),p(B,{children:[i(s.Button,{variant:"filled",mt:24,onClick:a,sx:{flexGrow:0},children:"Custom Cell Content"}),i(s.Modal,{size:800,title:"Custom cell content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&p(s.Stack,{children:[i(s.Box,{sx:{position:"relative"},children:i(Ae,{height:"500px",defaultLanguage:"javascript",value:l,onChange:h=>u(h??""),theme:"vs-dark",options:{minimap:{enabled:!1}}})}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:f,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Reset"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:d,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:c,children:"OK"})]})]})]})})]})}),Yx=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}],pi=()=>i(s.Text,{color:"dimmed",size:12,children:"px"}),Qx=({control:e,index:t,watch:n,remove:r,column:a})=>{const o=n(`columns.${t}.value_type`);return p(s.Stack,{my:0,sx:{position:"relative"},children:[p(s.Group,{grow:!0,children:[i(v.Controller,{name:`columns.${t}.label`,control:e,render:({field:l})=>i(s.TextInput,{label:"Label",required:!0,id:`col-label-${t}`,sx:{flex:1},...l})}),i(v.Controller,{name:`columns.${t}.value_field`,control:e,render:({field:l})=>i(j,{label:"Value Field",required:!0,...l})})]}),p(s.Group,{grow:!0,children:[i(v.Controller,{name:`columns.${t}.value_type`,control:e,render:({field:l})=>i(jx,{label:"Value Type",sx:{flex:1},...l})}),o===nt.custom&&i(v.Controller,{name:`columns.${t}.func_content`,control:e,render:({field:l})=>i(Rx,{value:l.value??Co,onChange:u=>l.onChange(u??"")})})]}),i(s.Divider,{mb:-10,variant:"dashed",label:"Style",labelPosition:"center"}),p(s.Group,{grow:!0,children:[i(s.NumberInput,{hideControls:!0,label:"Min Width",rightSection:i(pi,{}),disabled:!0}),i(v.Controller,{name:`columns.${t}.width`,control:e,render:({field:l})=>i(s.NumberInput,{hideControls:!0,label:"Width",rightSection:i(pi,{}),...l})}),i(s.NumberInput,{hideControls:!0,label:"Max Width",rightSection:i(pi,{}),disabled:!0})]}),i(s.Group,{grow:!0,noWrap:!0,children:i(v.Controller,{name:`columns.${t}.align`,control:e,render:({field:l})=>i(s.Select,{label:"Alignment",data:Yx,...l})})}),i(v.Controller,{name:`columns.${t}.cellBackgroundColor`,control:e,render:({field:l})=>i(Fx,{...l})}),i(s.Divider,{mb:4,mt:12,variant:"dashed"}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:()=>r(t),children:"Delete this column"})]})},Kx=({control:e,watch:t})=>{const{fields:n,append:r,remove:a,update:o}=v.useFieldArray({control:e,name:"columns"}),l=()=>{const c=Ee.randomId();r({id:c,label:c,align:"center",value_field:"",value_type:nt.string,width:""})};t("columns");const u=t("use_raw_columns");return p(B,{children:[i(v.Controller,{name:"use_raw_columns",control:e,render:({field:c})=>i(s.Switch,{mt:20,mb:20,label:"Use Original Data Columns",checked:c.value,onChange:d=>c.onChange(d.currentTarget.checked)})}),!u&&i(s.Stack,{children:p(s.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[p(s.Tabs.List,{children:[n.map((c,d)=>i(s.Tabs.Tab,{value:d.toString(),children:d+1},c.id)),i(s.Tabs.Tab,{onClick:l,value:"add",children:i(D.Plus,{size:18,color:"#228be6"})})]}),n.map((c,d)=>i(s.Tabs.Panel,{value:d.toString(),children:i(Qx,{control:e,watch:t,index:d,column:c,remove:a},d)},c.id))]})})]})};function Ux({control:e,watch:t}){return t(["horizontalSpacing","verticalSpacing","fontSize","striped","highlightOnHover"]),p(s.Stack,{spacing:"xs",children:[p(s.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[i(v.Controller,{name:"horizontalSpacing",control:e,render:({field:n})=>i(s.TextInput,{label:"Horizontal Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...n})}),i(v.Controller,{name:"verticalSpacing",control:e,render:({field:n})=>i(s.TextInput,{label:"Vertical Spacing",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...n})})]}),i(s.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:i(v.Controller,{name:"fontSize",control:e,render:({field:n})=>i(s.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",required:!0,sx:{flex:1},...n})})}),p(s.Group,{position:"apart",grow:!0,children:[i(v.Controller,{name:"striped",control:e,render:({field:n})=>i(s.Switch,{label:"Striped",checked:n.value,onChange:r=>n.onChange(r.currentTarget.checked)})}),i(v.Controller,{name:"highlightOnHover",control:e,render:({field:n})=>i(s.Switch,{label:"Highlight on hover",checked:n.value,onChange:r=>n.onChange(r.currentTarget.checked)})})]})]})}function Xx({columns:e,...t}){return{...t,columns:e.map(({id:n,...r})=>({id:n??Ee.randomId(),...r}))}}function Jx({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaultsDeep({},t,So),[t]),a=y.useMemo(()=>Xx(r),[r]);y.useEffect(()=>{!x.isEqual(r,a)&&(console.log("config malformed, resetting to defaults",r,a),n(a))},[r,a]);const{control:o,handleSubmit:l,watch:u,getValues:c,reset:d}=v.useForm({defaultValues:a});y.useEffect(()=>{d(a)},[a]);const f=c(),h=y.useMemo(()=>!x.isEqual(f,r),[f,r]);return u(["id_field"]),p("form",{onSubmit:l(n),children:[p(s.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{children:"Table Config"}),i(s.ActionIcon,{type:"submit","aria-label":"save config",mr:5,variant:"filled",color:"blue",disabled:!h,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Tabs,{defaultValue:"Columns",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"Columns",children:"Columns"}),i(s.Tabs.Tab,{value:"Style",children:"Style"})]}),p(s.Tabs.Panel,{value:"Columns",children:[i(v.Controller,{name:"id_field",control:o,render:({field:g})=>i(j,{label:"ID Field",required:!0,...g})}),i(s.Divider,{mt:20,mb:10,variant:"dashed"}),i(Kx,{control:o,watch:u})]}),i(s.Tabs.Panel,{value:"Style",children:i(Ux,{control:o,watch:u})})]})]})}function Zx(e){const{columns:t,...n}=e;return{...e,columns:t.map(r=>({...r,align:r.align??"left"}))}}function Hx(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{id_field:a,columns:o,...l}=e;return{...l,id_field:r(a),columns:o.map(u=>({...u,value_field:r(u.value_field)}))}}catch(n){throw console.error("[Migration failed]",n),n}}function e0(e){const{columns:t,...n}=e;return{...n,columns:t.map(r=>({...r,align:r.align??"left",cellBackgroundColor:r.cellBackgroundColor??"",width:r.width??""}))}}class t0 extends be{constructor(){super(...arguments);q(this,"VERSION",5)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{columns:r,...a}=n.config;return{...n,version:2,config:{...a,columns:r.map(({id:o,...l})=>({id:o??Ee.randomId(),...l}))}}}),this.version(3,n=>({...n,version:3,config:Zx(n.config)})),this.version(4,(n,r)=>({...n,version:4,config:Hx(n.config,r)})),this.version(5,n=>({...n,version:5,config:e0(n.config)}))}}const hi={createConfig(){return{version:5,config:x.cloneDeep(So)}},displayName:"Table",displayGroup:"Others",migrator:new t0,name:"table",viewRender:Ex,configRender:Jx,triggers:[di]},Io=["function text({ data, variables, filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
296
|
+
`),fi={func_content:Io,horizontal_align:"left",font_size:"14px",font_weight:"normal"},n0=k.observer(({context:e})=>{const t=we(),{value:n=fi}=W(e.instanceData,"config"),{variables:r}=e,a=e.data,{func_content:o,horizontal_align:l,font_size:u,font_weight:c}=n,d=y.useMemo(()=>r.reduce((h,g)=>{const m=bt(g,a);return h[g.name]=tt(g,m),h},{}),[r,a]),f=y.useMemo(()=>new Function(`return ${o}`)()({data:a,variables:d,filters:t.payloadForSQL.filters,context:t.payloadForSQL.context}),[o,a,d,t.payloadForSQL]);return i(s.Text,{align:l,weight:c,sx:{fontSize:u},children:f})}),r0=({value:e,onChange:t})=>{const n=r=>{r&&t(r)};return i(s.Box,{sx:{position:"relative"},children:i(Ae,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},i0=y.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:a,setFalse:o}]=X.useBoolean(),[l,u]=y.useState(e),c=()=>{o(),t(l)},d=()=>{o(),u(e)},f=()=>{u(Io)};return y.useEffect(()=>{u(e)},[e]),p(B,{children:[i(s.Button,{variant:"filled",mt:24,onClick:a,sx:{flexGrow:0},children:"Edit Content"}),i(s.Modal,{size:800,title:"Text content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&p(s.Stack,{children:[i(r0,{value:l,onChange:u}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:f,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Reset"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:d,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:c,children:"OK"})]})]})]})})]})}),a0=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}];function s0({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaultsDeep({},t,fi),[t]),a=y.useMemo(()=>{const{func_content:g,horizontal_align:m,font_size:C,font_weight:w}=r;return{func_content:g,horizontal_align:m,font_size:C,font_weight:w}},[r]);y.useEffect(()=>{!x.isEqual(r,a)&&(console.log("config malformed, resetting to defaults",r,a),n(a))},[r,a]);const{control:o,handleSubmit:l,watch:u,getValues:c,reset:d}=v.useForm({defaultValues:a});y.useEffect(()=>{d(a)},[a]),u(["func_content","horizontal_align","font_size","font_weight"]);const f=c(),h=y.useMemo(()=>!x.isEqual(f,r),[f,r]);return i(s.Stack,{spacing:"xs",children:p("form",{onSubmit:l(n),children:[p(s.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[i(s.Text,{weight:500,children:"Configurations"}),i(s.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:i(D.DeviceFloppy,{size:20})})]}),p(s.Stack,{spacing:10,children:[i(v.Controller,{name:"func_content",control:o,render:({field:g})=>i(i0,{...g})}),i(s.Divider,{mt:10,mb:-10,variant:"dashed",label:"Style",labelPosition:"center"}),i(v.Controller,{name:"horizontal_align",control:o,render:({field:g})=>i(s.Select,{label:"Horizontal Alignment",data:a0,...g})}),i(v.Controller,{name:"font_size",control:o,render:({field:g})=>i(s.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},...g})}),i(s.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:i(v.Controller,{name:"font_weight",control:o,render:({field:g})=>i(us,{label:"Font Weight",...g})})})]})]})})}class o0 extends be{constructor(){super(...arguments);q(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const l0={displayName:"Text",displayGroup:"Others",migrator:new o0,name:"text",viewRender:n0,configRender:s0,createConfig(){return{version:1,config:x.cloneDeep(fi)}}},u0=()=>p("svg",{width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[i("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22.49 27.79H14.47C13.55 27.79 12.81 28.53 12.81 29.45C12.81 30.37 13.55 31.11 14.47 31.11H22.49C23.41 31.11 24.15 30.37 24.15 29.45C24.15 28.54 23.41 27.79 22.49 27.79ZM34.32 31.28C35.22 31.32 35.7 31.82 35.74 32.76C35.78 33.54 35.37 34.3 34.51 35.04C33.52 35.9 33.03 36.95 33.03 38.19V38.81H34.82V38.25C34.78 37.59 35.07 37.02 35.68 36.52C37.12 35.41 37.82 34.15 37.78 32.75C37.66 30.53 36.5 29.35 34.32 29.23C32.3 29.23 31.05 30.46 30.55 32.93L32.53 33.55C32.82 32.04 33.42 31.28 34.32 31.28ZM35 39.93H32.84V42.21H35V39.93ZM14.83 36.42H18.54C19.46 36.42 20.2 37.17 20.2 38.08C20.2 39 19.46 39.74 18.54 39.74H10.52C9.6 39.74 8.86 39 8.86 38.08C8.86 37.61 9.06 37.19 9.37 36.89H5.66C4.74 36.89 4 36.15 4 35.23C4 34.31 4.74 33.57 5.66 33.57H13.68C14.6 33.57 15.34 34.31 15.34 35.23C15.34 35.7 15.14 36.12 14.83 36.42ZM50.94 36.85H58.74C59.66 36.85 60.4 37.59 60.41 38.51C60.41 39.43 59.67 40.17 58.75 40.17H54.26C54.56 40.47 54.74 40.88 54.74 41.34C54.74 42.26 54 43 53.08 43H50.94V36.85Z",fill:"#B8C0CC"}),i("path",{d:"M18.39 32.28H16.51V35.02H18.39V32.28Z",fill:"#9399A5"}),i("path",{d:"M46.87 15H20.69C18.38 15 16.5 16.88 16.5 19.19V26.22H18.38V23.45H49.18V47.68H18.38V41.07H16.5V49.55H51.05V19.19C51.06 16.88 49.18 15 46.87 15ZM39.46 20.73C38.81 20.73 38.29 20.2 38.29 19.56C38.29 18.92 38.82 18.39 39.46 18.39C40.11 18.39 40.63 18.92 40.63 19.56C40.63 20.2 40.11 20.73 39.46 20.73ZM43.22 20.73C42.57 20.73 42.05 20.2 42.05 19.56C42.05 18.92 42.58 18.39 43.22 18.39C43.87 18.39 44.39 18.92 44.39 19.56C44.39 20.2 43.87 20.73 43.22 20.73ZM46.97 20.73C46.32 20.73 45.8 20.2 45.8 19.56C45.8 18.92 46.33 18.39 46.97 18.39C47.62 18.39 48.14 18.92 48.14 19.56C48.14 20.2 47.62 20.73 46.97 20.73Z",fill:"#9399A5"})]});function Eo(e,t){const n=x.get(e,t,"");if(n)throw new Error(n)}async function c0(e,t,n,r={}){const a={"X-Requested-With":"XMLHttpRequest","Content-Type":r.string?"application/x-www-form-urlencoded":"application/json",...r.headers},o={baseURL:e,method:"POST",url:t,params:r.params,headers:a};return o.data=r.string?JSON.stringify(n):n,ht(o).then(l=>l.data).catch(l=>Promise.reject(l))}const d0=({conf:e,panelData:t})=>async()=>{const{expertSystemURL:n,path:r,goal:a,question:o}=e;if(!r||!a||!o)return;const l=sc(t);if(!l)return;const u={dashboard:a,panel:o,data:l};try{const c=n.startsWith("http")?n:window.location.origin;return await c0(c,`/expert/v3/devtable/${r}`,u,{})}catch(c){throw Eo(c,"response.data.detail"),Eo(c,"response.data.error"),console.error(c),c}},gi={expertSystemURL:"",path:"",goal:"",question:""},mi={height:"100%",overflowY:"auto",...Rr},Ao=({message:e})=>i(s.Box,{sx:mi,children:i("div",{dangerouslySetInnerHTML:{__html:e},style:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45"}})}),p0=({error:e,width:t,height:n})=>{const r=e.message;if(r.startsWith("<"))return i(Ao,{message:r});const o=n-25-20-30;return i(s.Center,{sx:{width:"100%",height:o},children:p(s.Stack,{align:"center",spacing:20,children:[i(u0,{}),i(Ao,{message:r})]})})};function h0({context:e}){const{value:t}=W(e.instanceData,"config"),n=y.useMemo(()=>x.defaultsDeep({},t,gi),[t]),{width:r,height:a}=e.viewport,o=e.data,{data:l,error:u,loading:c}=X.useRequest(d0({conf:n,panelData:o}),{refreshDeps:[o,n]});return!r||!a||!n?null:c?i(s.Box,{sx:{position:"relative",height:a},children:i(s.LoadingOverlay,{visible:!0})}):u?i(s.Box,{sx:mi,"data-enable-scrollbar":!0,children:i(p0,{error:u,width:r,height:a})}):!l||!Array.isArray(l.replies)||l.replies.length===0?null:i(s.Box,{sx:mi,"data-enable-scrollbar":!0,children:l.replies.map((d,f)=>i("div",{dangerouslySetInnerHTML:{__html:d.interpretation.html}},f))})}function f0({context:e}){const{value:t,set:n}=W(e.instanceData,"config"),r=y.useMemo(()=>x.defaultsDeep({},t,gi),[t]),{control:a,handleSubmit:o,watch:l,getValues:u,reset:c}=v.useForm({defaultValues:r});y.useEffect(()=>{c(r)},[r]),l(["expertSystemURL","goal","path","question"]);const d=u(),f=y.useMemo(()=>!x.isEqual(d,r),[d,r]);return i("form",{onSubmit:o(n),children:p(s.Stack,{children:[p(s.Group,{grow:!0,children:[i(v.Controller,{name:"expertSystemURL",control:a,render:({field:h})=>i(s.TextInput,{label:"Expert System URL",...h})}),i(v.Controller,{name:"path",control:a,render:({field:h})=>i(s.TextInput,{label:"Path",required:!0,...h})})]}),p(s.Group,{grow:!0,children:[i(v.Controller,{name:"goal",control:a,render:({field:h})=>i(s.TextInput,{label:"Goal",required:!0,...h})}),i(v.Controller,{name:"question",control:a,render:({field:h})=>i(s.TextInput,{label:"Question",required:!0,...h})})]}),i(s.Divider,{variant:"dashed",mt:16,mb:8}),i(s.Button,{type:"submit",variant:"filled",color:"blue",leftIcon:i(D.DeviceFloppy,{size:20}),disabled:!f,sx:{alignSelf:"flex-end"},children:"Submit Changes"})]})})}class g0 extends be{constructor(){super(...arguments);q(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const m0={displayName:"Merico GQM",displayGroup:"Merico suite",migrator:new g0,name:"mericoGQM",viewRender:h0,configRender:f0,createConfig(){return{version:1,config:x.cloneDeep(gi)}}};function y0(e,t,n){if(!e)return n[0];try{return[t,Y(t).add(1,"year").subtract(1,"day").valueOf()]}catch(r){return console.error(r),n[0]}}function b0(e,t,n){const r=y0(e,t,n);return{top:50,left:25,right:5,cellSize:["auto",13],range:r,itemStyle:{borderColor:"#eee"},splitLine:{show:!0},dayLabel:{firstDay:1},monthLabel:{position:"end"},yearLabel:{show:!0}}}function v0(e){return{heat_block:function(r){if(!e.heat_block.value_formatter)return r;try{return H(r).format(e.heat_block.value_formatter)}catch(a){return console.error(a),r}}}}function x0(e,t){return{show:!e,selectedMode:"single",top:5,right:5,data:t.map(n=>({name:n,icon:"circle"}))}}function w0(e,t,n,r){const{calendar:a,heat_block:o}=e,l=V(a.data_key),u=V(o.data_key);return t?{type:"heatmap",name:"heatmap",coordinateSystem:"calendar",calendarIndex:0,data:r[l.queryID].map(c=>[x.get(c,l.columnKey),x.get(c,u.columnKey)])}:Object.entries(n).map(([c,d])=>({type:"heatmap",name:c,coordinateSystem:"calendar",calendarIndex:0,data:d.map(f=>[x.get(f,l.columnKey),x.get(f,u.columnKey)])}))}const C0=e=>{try{return H(e).format({trimMantissa:!0,mantissa:2})}catch{return e}};function S0({conf:e,valueFormatters:t,dataDict:n,params:r}){const{value:a}=r,[o,l]=a,c=[{label:e.heat_block.name,value:t.heat_block(l),style:{label:"",value:""}}],d=n[o];return d&&e.tooltip.metrics.forEach(f=>{const h=V(f.data_key);c.push({label:f.name,value:C0(x.get(d,h.columnKey,"")),style:{label:"",value:""}})}),c}function _0(e,t,n){const r=V(e.calendar.data_key),a=x.keyBy(t[r.queryID],r.columnKey);return{confine:!0,formatter:function(o){const u=S0({conf:e,valueFormatters:n,dataDict:a,params:o}).map(f=>`
|
|
297
297
|
<tr>
|
|
298
298
|
<th style="text-align: right;">
|
|
299
299
|
<div style="${f.style.label}">${f.label}</div>
|
|
@@ -510,4 +510,4 @@ WHERE
|
|
|
510
510
|
`),post:["function process_result(res, utils) {"," // your code goes here"," return data","}"].join(`
|
|
511
511
|
`)},xk=k.observer(({queryModel:e})=>e.typedAsHTTP?p(s.Tabs,{defaultValue:"pre_process",orientation:"vertical",sx:{flexGrow:1},children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"pre_process",children:"Build Request"}),i(s.Tabs.Tab,{value:"post_process",children:"Process Result"}),i(Vi,{})]}),i(s.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:i(or,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:au.pre})}),i(s.Tabs.Panel,{value:"post_process",p:"sm",children:i(or,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:au.post})})]}):null),wk=k.observer(({queryID:e,usage:t})=>{const n=me().editor,r=o=>{if(o.type==="filter"){n.setPath(["_FILTERS_",o.id]);return}if(o.type==="panel"){const l=o.views[0].id;n.setPath(["_VIEWS_",l,"_PANELS_",o.id]);return}},a=o=>{n.setPath(["_VIEWS_",o])};return i(s.Stack,{py:"sm",px:"md",children:p(s.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[i("thead",{children:p("tr",{children:[i("th",{style:{width:100},children:"Type"}),i("th",{style:{width:"calc(50% - 50px)"},children:"Name"}),i("th",{children:"In View(s)"})]})}),i("tbody",{children:t.map(o=>p("tr",{children:[i("td",{children:x.capitalize(o.type)}),i("td",{children:i(s.Anchor,{component:"button",type:"button",onClick:()=>r(o),children:o.label})}),i("td",{children:p(s.Stack,{align:"flex-start",justify:"flex-start",spacing:2,children:[o.views.map(l=>i(s.Anchor,{component:"button",type:"button",onClick:()=>a(l.id),children:i(s.Box,{children:l.label})})),o.views.length===0&&i(s.Box,{children:"--"})]})})]},o.id))})]})})}),Ni=({value:e,onChange:t,height:n="200px",defaultLanguage:r="sql",theme:a="vs-dark"})=>{const o=u=>{t==null||t(u??"")},l=!t;return i(Ae,{className:"minimal-monaco-editor",height:n,defaultLanguage:r,value:e,onChange:l?void 0:o,theme:a,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:l||!t,"semanticHighlighting.enabled":!0}})},Ck=({value:e,onChange:t,defaultValue:n})=>{const[r,a]=y.useState(e),o=()=>{t(r)},l=()=>{a(e)},u=()=>{a(n)};y.useEffect(()=>{a(e)},[e]);const c=r!==e;return p(s.Stack,{spacing:4,sx:{height:"100%"},children:[p(s.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[i(s.Group,{position:"left",children:i(s.Button,{onClick:u,size:"xs",variant:"default",leftIcon:i($.IconPlayerSkipBack,{size:16}),children:"Reset to default"})}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:l,color:"red",size:"xs",disabled:!c,leftIcon:i($.IconRecycle,{size:16}),children:"Revert Changes"}),i(s.Button,{size:"xs",onClick:o,disabled:!c,leftIcon:i($.IconDeviceFloppy,{size:16}),children:"Confirm Changes"})]})]}),i(Ni,{height:"100%",value:r,onChange:a,theme:"sql-dark",defaultLanguage:"sql"})]})},Sk=({value:e,height:t="200px",defaultLanguage:n="sql"})=>i(Ae,{className:"preview-sql-in-monaco-editor",height:t,defaultLanguage:n,value:e,onChange:void 0,theme:"vs-light",options:{lineNumbers:"on",folding:!0,lineDecorationsWidth:20,wordWrap:"on",minimap:{enabled:!1},readOnly:!0}}),_k=k.observer(({value:e})=>{const n=we().payloadForSQL,r=y.useMemo(()=>gr(e,n),[e,n]);return i(Sk,{height:"100%",value:r})}),su={pre:["function process_request({ context, filters, sql }, utils) {"," // modify and return sql"," return sql","}"].join(`
|
|
512
512
|
`),post:["function process_result(data, utils) {"," // process data and return the result"," return data","}"].join(`
|
|
513
|
-
`)},kk=k.observer(({queryModel:e})=>e.typedAsSQL?p(s.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%",height:"28px",lineHeight:"28px"}},keepMounted:!1,children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"Edit",children:i(s.Group,{spacing:14,position:"apart",children:"Edit SQL"})}),i(s.Tabs.Tab,{value:"Preview",children:"Preview SQL"}),i(s.Tabs.Tab,{value:"pre_process",children:"Process Request"}),i(s.Tabs.Tab,{value:"post_process",children:"Process Result"}),i(Vi,{}),e.datasource&&i(ru,{dataSource:e.datasource})]}),i(s.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:i(Ck,{value:e.sql,onChange:e.setSQL,defaultValue:"SELECT 1"})}),i(s.Tabs.Panel,{value:"Preview",p:0,pl:4,children:i(_k,{value:e.sql})}),i(s.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:i(or,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:su.pre})}),i(s.Tabs.Panel,{value:"post_process",p:"sm",children:i(or,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:su.post})})]}):null),lr={height:"calc(100% - 44px)",padding:0},Tk=k.observer(({queryModel:e})=>{const t=le(),n=y.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),[r,a]=y.useState(n);y.useEffect(()=>{a(u=>u!=="Configurations"&&n==="Configurations"?"Configurations":u)},[n]);const o=t.findQueryUsage(e.id),l=o.length===0;return i(s.Stack,{sx:{flexGrow:1},my:0,p:0,children:p(s.Tabs,{value:r,onTabChange:a,defaultValue:n,orientation:"horizontal",keepMounted:!1,sx:{flexGrow:1},children:[p(s.Tabs.List,{grow:!0,children:[i(s.Tabs.Tab,{value:"Configurations",children:"Configurations"}),e.typedAsSQL&&i(s.Tabs.Tab,{value:"SQL",children:"Request"}),e.typedAsHTTP&&i(s.Tabs.Tab,{value:"HTTP",children:"Request"}),i(s.Tabs.Tab,{value:"Data",disabled:!e.datasource,children:i(s.Tooltip,{label:"Need to pick a Data Source first",disabled:e.datasource,withinPortal:!0,children:i(s.Text,{children:"Data"})})}),i(s.Tabs.Tab,{value:"Usage",disabled:l,children:i(s.Tooltip,{label:"This query is not used for any filter or panel",disabled:!l,withinPortal:!0,children:i(s.Text,{children:"Usage"})})})]}),i(s.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:i(fk,{queryModel:e})}),e.typedAsSQL&&i(s.Tabs.Panel,{value:"SQL",sx:lr,children:i(s.Stack,{sx:{height:"100%"},children:i(kk,{queryModel:e})})}),e.typedAsHTTP&&i(s.Tabs.Panel,{value:"HTTP",sx:lr,children:i(s.Stack,{sx:{height:"100%"},children:i(xk,{queryModel:e})})}),i(s.Tabs.Panel,{value:"Data",sx:{...lr,overflow:"hidden"},children:i(Pi,{id:e.id})}),i(s.Tabs.Panel,{value:"Usage",sx:{...lr,overflow:"hidden"},children:i(wk,{queryID:e.id,usage:o})})]})})}),Dk=k.observer(({id:e})=>{const n=le().queries.findByID(e);return e===""?null:n?i(s.Stack,{sx:{height:"100%"},spacing:"sm",children:i(Tk,{queryModel:n})}):i(s.Text,{size:14,color:"red",children:"Invalid Query ID"})}),Mk=k.observer(({value:e})=>{const n=we().payloadForSQL,r=y.useMemo(()=>gr(e,n),[e,n]);return i(Ni,{height:"100%",value:r})}),Ik=k.observer(({item:e,remove:t,onKeyChanged:n})=>{const[r,a]=y.useState("SQL"),[o,l]=y.useState(e.key),u=()=>{e.setKey(o),n(o)},c=o!==e.key,d=e.isADuplicatedKey(o),[f,h]=y.useState(e.value),g=()=>{e.setValue(f)};y.useEffect(()=>{l(e.key),h(e.value)},[e]);const m=f!==e.value,C=Ue.useModals(),w=()=>{C.openConfirmModal({title:"Delete this SQL snippet?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:t,confirmProps:{color:"red"},zIndex:320})};return p(s.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[p(s.Group,{sx:{alignItems:"end"},spacing:40,children:[i(s.TextInput,{label:d?"This key is occupied by another snippet":"Key",value:o,onChange:_=>{l(_.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:i(s.ActionIcon,{color:"blue",variant:"subtle",onClick:u,disabled:!c||d,children:i(D.DeviceFloppy,{size:16})}),error:d}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:w,children:"Delete this SQL Snippet"})]}),p(s.Tabs,{value:r,onTabChange:a,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[p(s.Tabs.List,{sx:{position:"relative"},children:[i(s.Tabs.Tab,{value:"SQL",children:"SQL"}),i(s.Tabs.Tab,{value:"Preview",children:"Preview"}),i(Vi,{}),i(s.ActionIcon,{color:"blue",variant:"filled",onClick:g,disabled:!m,sx:{position:"absolute",top:0,right:10},children:i(D.DeviceFloppy,{size:18})})]}),i(s.Tabs.Panel,{value:"SQL",pt:"sm",children:i(Ni,{height:"100%",value:f,onChange:h,defaultLanguage:"sql",theme:"sql-dark"})}),i(s.Tabs.Panel,{value:"Preview",pt:"sm",children:i(Mk,{value:f})})]})]})}),Ek=k.observer(({id:e})=>{const t=me(),n=le(),r=y.useMemo(()=>n.sqlSnippets.findByKey(e),[e]);if(!e)return null;if(!r)return p(s.Text,{size:14,children:["SQL Snippet by key[",e,"] is not found"]});const a=()=>{t.editor.setPath(["_SQL_SNIPPETS_",""])};return i(Ik,{item:r,remove:()=>{n.sqlSnippets.removeByKey(e),a()},onKeyChanged:u=>{t.editor.setPath(["_SQL_SNIPPETS_",u])}})}),Ak=k.observer(({view:e})=>!e||e.type!==R.Division?null:p(s.Stack,{children:[i(s.Divider,{mt:8,mb:0,label:"Division settings",labelPosition:"center"}),i(s.Text,{align:"center",size:"xs",color:"dimmed",children:"Under construction"})]})),zk=[{value:"default",label:"Default"},{value:"outline",label:"Outline"},{value:"pills",label:"Pills"}],$k=[{value:"horizontal",label:"Horizontal"},{value:"vertical",label:"Vertical"}],Ok=k.observer(({view:e})=>{if(!e||e.type!==R.Tabs)return null;const t=e.config;return p(s.Stack,{children:[i(s.Divider,{mt:8,mb:0,label:"Tabs settings",labelPosition:"center"}),i(s.Select,{label:"Variant",value:t.variant,onChange:t.setVariant,data:zk}),i(s.Select,{label:"Orientation",value:t.orientation,onChange:t.setOrientation,data:$k}),i(s.Switch,{label:"Grow Tabs",checked:t.grow,onChange:n=>t.setGrow(n.currentTarget.checked)})]})}),Lk=({disabled:e,value:t,onChange:n})=>{const r=a=>{a&&n(a)};return p(s.Box,{sx:{position:"relative"},children:[e&&i(s.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),i(Ae,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},Pk=({value:e,onChange:t})=>{const[n,{setTrue:r,setFalse:a}]=X.useBoolean(),[o,l]=y.useState(e??ki),u=g=>{l({...o,enabled:g})},c=()=>{a();const{enabled:g,func_content:m}=o,C={enabled:g,func_content:m};l(C),t(C)},d=()=>{a(),l(e)},f=g=>{l(m=>({...m,func_content:g}))},h=()=>{f(ki.func_content)};return p(B,{children:[i(s.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:r,sx:{flexGrow:0},children:i(D.Settings,{size:14})}),i(s.Modal,{size:800,title:"Customize modal title",opened:n,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:n&&p(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:o.enabled,onChange:g=>u(g.currentTarget.checked)}),i(Lk,{value:o.func_content,onChange:f,disabled:!o.enabled}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:h,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Rest"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:d,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:c,children:"OK"})]})]})]})})]})},Bk=k.observer(({view:e})=>{if(!e||e.type!==R.Modal)return null;const t=e.config,n=t.custom_modal_title.value;return p(s.Stack,{children:[i(s.Divider,{mt:8,label:"Modal settings",labelPosition:"center"}),p(s.Flex,{gap:10,children:[i(s.TextInput,{label:"Modal Title",value:n,onChange:x.noop,disabled:!0,sx:{flexGrow:1}}),i(Pk,{value:t.custom_modal_title,onChange:t.custom_modal_title.replace})]}),p(s.Group,{grow:!0,children:[i(s.TextInput,{label:"Width",value:t.width,onChange:r=>t.setWidth(r.currentTarget.value),placeholder:"600px / 50vw"}),i(s.TextInput,{label:"Height",value:t.height,onChange:r=>t.setHeight(r.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),Vk=k.observer(({view:e})=>p(B,{children:[i(Ak,{view:e}),i(Bk,{view:e}),i(Ok,{view:e})]})),Nk=[{label:"Division",value:R.Division},{label:"Modal",value:R.Modal},{label:"Tabs",value:R.Tabs}],qk=k.observer(({view:e})=>e?p(s.Stack,{sx:{position:"relative"},children:[i(s.TextInput,{label:"Name",value:e.name,onChange:t=>{e.setName(t.currentTarget.value)}}),i(s.Select,{label:"Type",withinPortal:!0,zIndex:320,value:e.type,onChange:e.setType,data:Nk}),i(Vk,{view:e})]}):null),Fk=k.observer(({id:e})=>{const t=Ue.useModals(),n=me(),r=le();if(e==="")return null;const a=r.views.findByID(e);if(!a)return p(s.Text,{size:14,children:["View by ID[",e,"] is not found"]});const o=()=>{n.editor.setPath(["_VIEWS_",""])},l=()=>{t.openConfirmModal({title:"Delete this view?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.views.removeByID(e),o()},zIndex:320})};return p(s.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[i(s.Group,{position:"right",pt:10,children:i(s.Button,{size:"xs",color:"red",leftIcon:i(D.Trash,{size:16}),onClick:l,children:"Delete this view"})}),i(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:i(qk,{view:a})})]})});function Gk(e){return e.length===1&&e[0]==="_QUERY_VARS_"}function Wk(e){return e.length===1&&e[0]==="_MOCK_CONTEXT_"}function jk(e){return e.length===2&&e[0]==="_FILTERS_"}function Rk(e){return e.length===2&&e[0]==="_SQL_SNIPPETS_"}function Yk(e){return e.length===2&&e[0]==="_QUERIES_"}function Qk(e){return e.length===2&&e[0]==="_VIEWS_"}function Kk(e){return e.length===4&&e[0]==="_VIEWS_"&&e[2]==="_PANELS_"}const Uk=k.observer(()=>i(s.Stack,{sx:{height:"100%"},p:"sm",children:i(iu,{})})),Xk=k.observer(()=>{const e=me().editor,t=e.path;return Gk(t)?i(Uk,{}):Wk(t)?i(b_,{}):jk(t)?i(s.Box,{p:"xs",pl:20,children:i(y_,{id:t[1]})}):Rk(t)?i(Ek,{id:t[1]}):Yk(t)?i(Dk,{id:t[1]}):Qk(t)?i(s.Box,{p:"xs",pl:20,children:i(Fk,{id:t[1]})}):Kk(t)?i(Q_,{viewID:t[1],panelID:t[3]}):i(s.Box,{children:e.path})}),Jk=k.observer(()=>i(Xk,{})),Zk=k.observer(()=>{const e=me(),t=()=>{const n=new Date().getTime().toString(),r={id:n,key:n,label:n,order:e.content.filters.current.length+1,type:_e.TextInput,config:Jo(),visibleInViewsIDs:["Main"],auto_submit:!1};e.content.filters.append(r),e.editor.setPath(["_FILTERS_",n])};return i(s.Button,{variant:"subtle",leftIcon:i($.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Filter"})}),Hk=k.observer(({parentID:e})=>{const t=le();if(!e)return null;const n=t.views.findByID(e);return n?i(s.Button,{variant:"subtle",leftIcon:i($.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>t.addANewPanel(n.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Panel"}):null}),eT=k.observer(()=>{const e=me(),t=()=>{const n=new Date().getTime().toString(),r={id:n,name:n,type:Se.Postgresql,key:"",sql:""};e.content.queries.append(r),e.editor.setPath(["_QUERIES_",n])};return i(s.Button,{variant:"subtle",leftIcon:i($.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Query"})}),tT=k.observer(()=>{const e=me(),t=()=>{const n=new Date().getTime().toString(),r={key:n,value:""};e.content.sqlSnippets.append(r),e.editor.setPath(["_SQL_SNIPPETS_",n])};return i(s.Button,{variant:"subtle",leftIcon:i($.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a SQL Snippet"})}),nT=k.observer(()=>{const e=le();return i(s.Button,{variant:"subtle",leftIcon:i($.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:"Add a View"})}),rT=k.observer(({action_type:e,parentID:t})=>e==="_Add_A_Filter_"?i(Zk,{}):e==="_Add_A_SQL_SNIPPET_"?i(tT,{}):e==="_Add_A_QUERY_"?i(eT,{}):e==="_Add_A_VIEW_"?i(nT,{}):e==="_Add_A_PANEL_"?i(Hk,{parentID:t}):null),ou=k.observer(({option:e})=>{var d;const t=me().editor,n=t.isOptionActive,r=n(t.path,e),a=t.isOptionOpened,o=t.navigate,l=a(e),[u,c]=y.useState(l);return y.useEffect(()=>{c(l)},[l]),i(s.NavLink,{active:r,defaultOpened:l,opened:u,onChange:c,label:e.label,onClick:()=>o(e),icon:e.Icon?i(e.Icon,{size:18}):null,children:(d=e.children)==null?void 0:d.map(f=>f._type==="ACTION"?i(rT,{action_type:f._action_type,parentID:f.parentID},`_ADD_${f.value}_`):i(ou,{option:f},f.value))},e.label)}),iT=k.observer(()=>{const e=me();return i(s.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>i(ou,{option:t},t.value))})}),aT=k.observer(()=>{const e=me();return p(s.Navbar,{p:0,width:{base:200,xs:200,sm:220,md:240,lg:280,xl:300},sx:{height:"100vh - 60px - 60px"},children:[i(s.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:i(s.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Settings"})}),i(s.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:i(iT,{})}),i(s.Navbar.Section,{children:i(s.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:i(s.Button,{size:"xs",color:"red",leftIcon:i($.IconX,{size:18}),onClick:()=>e.editor.close(),children:"Close"})})})]})}),sT={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},oT=k.observer(()=>{const e=me().editor;return i(s.Modal,{onClose:()=>e.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:e.settings_open,fullScreen:!0,title:null,transitionProps:{duration:0},withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{body:{padding:"0 !important"}},children:i(s.AppShell,{padding:0,navbar:i(aT,{}),styles:sT,children:i(Jk,{})})})}),lT=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function uT(e){y.useEffect(()=>{if(Ae.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const n=lT(e);Ae.loader.config({paths:{vs:n}}),Ae.loader.init().then(r=>console.log("monaco instance:",r))},[])}Ss();const cT={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},dT=({context:e,dashboard:t,content:n,update:r,className:a="dashboard",config:o,onChange:l,headerSlot:u},c)=>{uT(o.monacoPath),Ka(o);const{data:d=[]}=X.useRequest(mr),{data:f=[]}=X.useRequest(Ua),h=y.useMemo(()=>Wl(t,n,d,f,e),[t,n]);y.useImperativeHandle(c,()=>h,[h]),jl(h.content,!0),y.useEffect(()=>{h.context.replace(e)},[e]),y.useEffect(()=>{h.datasources.replace(d)},[d]),y.useEffect(()=>{h.globalSQLSnippets.replace(f)},[f]),y.useEffect(()=>re.reaction(()=>re.toJS(h.json),w=>{l==null||l(w)}),[h]);const g=async()=>{await r(h.json,h.content.json)},m=X.useCreation(Ci,[]),C=Rl(m);return i(Ue.ModalsProvider,{children:i(vr,{value:h,children:i(Cr,{value:h.content,children:i(wn.Provider,{value:{inEditMode:!0},children:i(st.Provider,{value:m,children:p(Zn,{configure:C,children:[i(s.AppShell,{padding:0,header:i(IS,{saveDashboardChanges:g,headerSlot:u}),navbar:i(n_,{}),styles:cT,children:i(s.Box,{className:`${a} dashboard-root`,sx:{position:"relative"},children:h.content.views.visibleViews.map(w=>i(zl,{view:w},w.id))})}),i(oT,{})]})})})})})})},pT=k.observer(y.forwardRef(dT)),wM="",lu=b.types.model({id:b.types.string,name:b.types.string,dashboard_id:b.types.string,create_time:b.types.string,update_time:b.types.string,version:b.types.string,filters:cl,queries:yl,sqlSnippets:bl,views:sl,panels:ll,mock_context:Wo}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get payloadForSQL(){const t=b.getParent(e).context.current,n=b.getParent(e).globalSQLSnippets,r={context:{...e.mock_context.current,...t},filters:e.filters.values};return{...r,sql_snippets:tr(e.sqlSnippets.current,"key","value",r),global_sql_snippets:tr(n.list,"id","content",r)}},get payloadForViz(){const t=b.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.values}},get data(){return e.queries.current.map(({id:n,data:r})=>({id:n,data:r})).reduce((n,r)=>(n[r.id]=r.data,n),{})},getDataStuffByID(t){const n=e.queries.findByID(t);return n?{data:n.data.toJSON(),len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).actions(e=>({}));function hT({id:e,name:t,dashboard_id:n,create_time:r,update_time:a,content:o}){if(!o)throw new Error("unexpected null content when creating a content model");const{version:l,filters:u,views:c,panels:d,definition:{queries:f,sqlSnippets:h,mock_context:g={}}}=o;return lu.create({id:e,name:t,dashboard_id:n,create_time:r,update_time:a,version:l,filters:dl(u),queries:T1(f),sqlSnippets:M1(h),mock_context:jo(g),views:g1(c),panels:{list:d}})}const fT=b.types.model({id:b.types.identifier,name:b.types.string,group:b.types.string,content:lu,content_id:b.types.string,datasources:h1,globalSQLSnippets:il,context:Ti});function gT({id:e,name:t,group:n,content_id:r},a,o,l,u){return fT.create({id:e,name:t,group:n,content_id:r,content:hT(a),datasources:{list:o},globalSQLSnippets:{list:l},context:al(u)})}Ss();const mT=k.observer(({context:e,dashboard:t,content:n,className:r="dashboard",config:a,fullScreenPanelID:o,setFullScreenPanelID:l})=>{Ka(a);const{data:u=[]}=X.useRequest(mr),{data:c=[]}=X.useRequest(Ua),d=y.useMemo(()=>gT(t,n,u,c,e),[t,n]);jl(d.content,!1),y.useEffect(()=>{d.context.replace(e)},[e]),y.useEffect(()=>{d.datasources.replace(u)},[u]),y.useEffect(()=>{d.globalSQLSnippets.replace(c)},[c]);const f=X.useCreation(Ci,[]),h=Rl(f);return i(Ue.ModalsProvider,{children:i(vr,{value:d,children:i(Cr,{value:d.content,children:i(_r.Provider,{value:{fullScreenPanelID:o,setFullScreenPanelID:l},children:i(wn.Provider,{value:{inEditMode:!1},children:i(s.Box,{className:`${r} dashboard-root`,children:i(st.Provider,{value:f,children:i(Zn,{configure:h,children:d.content.views.visibleViews.map(g=>i(rr,{view:g},g.id))})})})})})})})})});var qi={},yT={get exports(){return qi},set exports(e){qi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){var a=r.prototype,o=a.format;a.format=function(l){var u=this,c=this.$locale();if(!this.isValid())return o.bind(this)(l);var d=this.$utils(),f=(l||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(h){switch(h){case"Q":return Math.ceil((u.$M+1)/3);case"Do":return c.ordinal(u.$D);case"gggg":return u.weekYear();case"GGGG":return u.isoWeekYear();case"wo":return c.ordinal(u.week(),"W");case"w":case"ww":return d.s(u.week(),h==="w"?1:2,"0");case"W":case"WW":return d.s(u.isoWeek(),h==="W"?1:2,"0");case"k":case"kk":return d.s(String(u.$H===0?24:u.$H),h==="k"?1:2,"0");case"X":return Math.floor(u.$d.getTime()/1e3);case"x":return u.$d.getTime();case"z":return"["+u.offsetName()+"]";case"zzz":return"["+u.offsetName("long")+"]";default:return h}});return o.bind(this)(f)}}})})(yT);const bT=qi;var Fi={},vT={get exports(){return Fi},set exports(e){Fi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){var o=r.prototype,l=function(c){var d=c.date,f=c.utc;return Array.isArray(d)?f?d.length?new Date(Date.UTC.apply(null,d)):new Date:d.length===1?a(String(d[0])).toDate():new(Function.prototype.bind.apply(Date,[null].concat(d))):d},u=o.parse;o.parse=function(c){c.date=l.bind(this)(c),u.bind(this)(c)}}})})(vT);const xT=Fi;var Gi={},wT={get exports(){return Gi},set exports(e){Gi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){var a=r.prototype;a.$g=function(g,m,C){return this.$utils().u(g)?this[m]:this.$set(C,g)},a.set=function(g,m){return this.$set(g,m)};var o=a.startOf;a.startOf=function(g,m){return this.$d=o.bind(this)(g,m).toDate(),this.init(),this};var l=a.add;a.add=function(g,m){return this.$d=l.bind(this)(g,m).toDate(),this.init(),this};var u=a.locale;a.locale=function(g,m){return g?(this.$L=u.bind(this)(g,m).$L,this):this.$L};var c=a.daysInMonth;a.daysInMonth=function(){return c.bind(this.clone())()};var d=a.isSame;a.isSame=function(g,m){return d.bind(this.clone())(g,m)};var f=a.isBefore;a.isBefore=function(g,m){return f.bind(this.clone())(g,m)};var h=a.isAfter;a.isAfter=function(g,m){return h.bind(this.clone())(g,m)}}})})(wT);const CT=Gi;var Wi={},ST={get exports(){return Wi},set exports(e){Wi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){var a=r.prototype,o=a.format;a.format=function(l){var u=this,c=(l||"YYYY-MM-DDTHH:mm:ssZ").replace(/(\[[^\]]+])|BBBB|BB/g,function(d,f){var h,g=String(u.$y+543),m=d==="BB"?[g.slice(-2),2]:[g,4];return f||(h=u.$utils()).s.apply(h,m.concat(["0"]))});return o.bind(this)(c)}}})})(ST);const _T=Wi;var ji={},kT={get exports(){return ji},set exports(e){ji=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){var o="h:mm A",l={lastDay:"[Yesterday at] "+o,sameDay:"[Today at] "+o,nextDay:"[Tomorrow at] "+o,nextWeek:"dddd [at] "+o,lastWeek:"[Last] dddd [at] "+o,sameElse:"MM/DD/YYYY"};r.prototype.calendar=function(u,c){var d=c||this.$locale().calendar||l,f=a(u||void 0).startOf("d"),h=this.diff(f,"d",!0),g="sameElse",m=h<-6?g:h<-1?"lastWeek":h<0?"lastDay":h<1?"sameDay":h<2?"nextDay":h<7?"nextWeek":g,C=d[m]||l[m];return typeof C=="function"?C.call(this,a()):this.format(C)}}})})(kT);const TT=ji;var Ri={},DT={get exports(){return Ri},set exports(e){Ri=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},r=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,a=/\d\d/,o=/\d\d?/,l=/\d*[^-_:/,()\s\d]+/,u={},c=function(w){return(w=+w)+(w>68?1900:2e3)},d=function(w){return function(_){this[w]=+_}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(w){(this.zone||(this.zone={})).offset=function(_){if(!_||_==="Z")return 0;var T=_.match(/([+-]|\d\d)/g),I=60*T[1]+(+T[2]||0);return I===0?0:T[0]==="+"?-I:I}(w)}],h=function(w){var _=u[w];return _&&(_.indexOf?_:_.s.concat(_.f))},g=function(w,_){var T,I=u.meridiem;if(I){for(var L=1;L<=24;L+=1)if(w.indexOf(I(L,0,_))>-1){T=L>12;break}}else T=w===(_?"pm":"PM");return T},m={A:[l,function(w){this.afternoon=g(w,!1)}],a:[l,function(w){this.afternoon=g(w,!0)}],S:[/\d/,function(w){this.milliseconds=100*+w}],SS:[a,function(w){this.milliseconds=10*+w}],SSS:[/\d{3}/,function(w){this.milliseconds=+w}],s:[o,d("seconds")],ss:[o,d("seconds")],m:[o,d("minutes")],mm:[o,d("minutes")],H:[o,d("hours")],h:[o,d("hours")],HH:[o,d("hours")],hh:[o,d("hours")],D:[o,d("day")],DD:[a,d("day")],Do:[l,function(w){var _=u.ordinal,T=w.match(/\d+/);if(this.day=T[0],_)for(var I=1;I<=31;I+=1)_(I).replace(/\[|\]/g,"")===w&&(this.day=I)}],M:[o,d("month")],MM:[a,d("month")],MMM:[l,function(w){var _=h("months"),T=(h("monthsShort")||_.map(function(I){return I.slice(0,3)})).indexOf(w)+1;if(T<1)throw new Error;this.month=T%12||T}],MMMM:[l,function(w){var _=h("months").indexOf(w)+1;if(_<1)throw new Error;this.month=_%12||_}],Y:[/[+-]?\d+/,d("year")],YY:[a,function(w){this.year=c(w)}],YYYY:[/\d{4}/,d("year")],Z:f,ZZ:f};function C(w){var _,T;_=w,T=u&&u.formats;for(var I=(w=_.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(U,Q,Z){var se=Z&&Z.toUpperCase();return Q||T[Z]||n[Z]||T[se].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(ue,ye,Ie){return ye||Ie.slice(1)})})).match(r),L=I.length,N=0;N<L;N+=1){var O=I[N],A=m[O],E=A&&A[0],F=A&&A[1];I[N]=F?{regex:E,parser:F}:O.replace(/^\[|\]$/g,"")}return function(U){for(var Q={},Z=0,se=0;Z<L;Z+=1){var ue=I[Z];if(typeof ue=="string")se+=ue.length;else{var ye=ue.regex,Ie=ue.parser,fe=U.slice(se),ve=ye.exec(fe)[0];Ie.call(Q,ve),U=U.replace(ve,"")}}return function(ge){var Le=ge.afternoon;if(Le!==void 0){var Qe=ge.hours;Le?Qe<12&&(ge.hours+=12):Qe===12&&(ge.hours=0),delete ge.afternoon}}(Q),Q}}return function(w,_,T){T.p.customParseFormat=!0,w&&w.parseTwoDigitYear&&(c=w.parseTwoDigitYear);var I=_.prototype,L=I.parse;I.parse=function(N){var O=N.date,A=N.utc,E=N.args;this.$u=A;var F=E[1];if(typeof F=="string"){var U=E[2]===!0,Q=E[3]===!0,Z=U||Q,se=E[2];Q&&(se=E[2]),u=this.$locale(),!U&&se&&(u=T.Ls[se]),this.$d=function(fe,ve,ge){try{if(["x","X"].indexOf(ve)>-1)return new Date((ve==="X"?1e3:1)*fe);var Le=C(ve)(fe),Qe=Le.year,zt=Le.month,ur=Le.day,cr=Le.hours,xa=Le.minutes,wa=Le.seconds,un=Le.milliseconds,Gt=Le.zone,wt=new Date,$t=ur||(Qe||zt?1:wt.getDate()),Ct=Qe||wt.getFullYear(),Wt=0;Qe&&!zt||(Wt=zt>0?zt-1:wt.getMonth());var jt=cr||0,cn=xa||0,dn=wa||0,St=un||0;return Gt?new Date(Date.UTC(Ct,Wt,$t,jt,cn,dn,St+60*Gt.offset*1e3)):ge?new Date(Date.UTC(Ct,Wt,$t,jt,cn,dn,St)):new Date(Ct,Wt,$t,jt,cn,dn,St)}catch{return new Date("")}}(O,F,A),this.init(),se&&se!==!0&&(this.$L=this.locale(se).$L),Z&&O!=this.format(F)&&(this.$d=new Date("")),u={}}else if(F instanceof Array)for(var ue=F.length,ye=1;ye<=ue;ye+=1){E[1]=F[ye-1];var Ie=T.apply(this,E);if(Ie.isValid()){this.$d=Ie.$d,this.$L=Ie.$L,this.init();break}ye===ue&&(this.$d=new Date(""))}else L.call(this,N)}}})})(DT);const MT=Ri;var Yi={},IT={get exports(){return Yi},set exports(e){Yi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){r.prototype.dayOfYear=function(o){var l=Math.round((a(this).startOf("day")-a(this).startOf("year"))/864e5)+1;return o==null?l:this.add(o-l,"day")}}})})(IT);const ET=Yi;var Qi={},AT={get exports(){return Qi},set exports(e){Qi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n,r,a=1e3,o=6e4,l=36e5,u=864e5,c=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,d=31536e6,f=2592e6,h=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,g={years:d,months:f,days:u,hours:l,minutes:o,seconds:a,milliseconds:1,weeks:6048e5},m=function(O){return O instanceof N},C=function(O,A,E){return new N(O,E,A.$l)},w=function(O){return r.p(O)+"s"},_=function(O){return O<0},T=function(O){return _(O)?Math.ceil(O):Math.floor(O)},I=function(O){return Math.abs(O)},L=function(O,A){return O?_(O)?{negative:!0,format:""+I(O)+A}:{negative:!1,format:""+O+A}:{negative:!1,format:""}},N=function(){function O(E,F,U){var Q=this;if(this.$d={},this.$l=U,E===void 0&&(this.$ms=0,this.parseFromMilliseconds()),F)return C(E*g[w(F)],this);if(typeof E=="number")return this.$ms=E,this.parseFromMilliseconds(),this;if(typeof E=="object")return Object.keys(E).forEach(function(ue){Q.$d[w(ue)]=E[ue]}),this.calMilliseconds(),this;if(typeof E=="string"){var Z=E.match(h);if(Z){var se=Z.slice(2).map(function(ue){return ue!=null?Number(ue):0});return this.$d.years=se[0],this.$d.months=se[1],this.$d.weeks=se[2],this.$d.days=se[3],this.$d.hours=se[4],this.$d.minutes=se[5],this.$d.seconds=se[6],this.calMilliseconds(),this}}return this}var A=O.prototype;return A.calMilliseconds=function(){var E=this;this.$ms=Object.keys(this.$d).reduce(function(F,U){return F+(E.$d[U]||0)*g[U]},0)},A.parseFromMilliseconds=function(){var E=this.$ms;this.$d.years=T(E/d),E%=d,this.$d.months=T(E/f),E%=f,this.$d.days=T(E/u),E%=u,this.$d.hours=T(E/l),E%=l,this.$d.minutes=T(E/o),E%=o,this.$d.seconds=T(E/a),E%=a,this.$d.milliseconds=E},A.toISOString=function(){var E=L(this.$d.years,"Y"),F=L(this.$d.months,"M"),U=+this.$d.days||0;this.$d.weeks&&(U+=7*this.$d.weeks);var Q=L(U,"D"),Z=L(this.$d.hours,"H"),se=L(this.$d.minutes,"M"),ue=this.$d.seconds||0;this.$d.milliseconds&&(ue+=this.$d.milliseconds/1e3);var ye=L(ue,"S"),Ie=E.negative||F.negative||Q.negative||Z.negative||se.negative||ye.negative,fe=Z.format||se.format||ye.format?"T":"",ve=(Ie?"-":"")+"P"+E.format+F.format+Q.format+fe+Z.format+se.format+ye.format;return ve==="P"||ve==="-P"?"P0D":ve},A.toJSON=function(){return this.toISOString()},A.format=function(E){var F=E||"YYYY-MM-DDTHH:mm:ss",U={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return F.replace(c,function(Q,Z){return Z||String(U[Q])})},A.as=function(E){return this.$ms/g[w(E)]},A.get=function(E){var F=this.$ms,U=w(E);return U==="milliseconds"?F%=1e3:F=U==="weeks"?T(F/g[U]):this.$d[U],F===0?0:F},A.add=function(E,F,U){var Q;return Q=F?E*g[w(F)]:m(E)?E.$ms:C(E,this).$ms,C(this.$ms+Q*(U?-1:1),this)},A.subtract=function(E,F){return this.add(E,F,!0)},A.locale=function(E){var F=this.clone();return F.$l=E,F},A.clone=function(){return C(this.$ms,this)},A.humanize=function(E){return n().add(this.$ms,"ms").locale(this.$l).fromNow(!E)},A.milliseconds=function(){return this.get("milliseconds")},A.asMilliseconds=function(){return this.as("milliseconds")},A.seconds=function(){return this.get("seconds")},A.asSeconds=function(){return this.as("seconds")},A.minutes=function(){return this.get("minutes")},A.asMinutes=function(){return this.as("minutes")},A.hours=function(){return this.get("hours")},A.asHours=function(){return this.as("hours")},A.days=function(){return this.get("days")},A.asDays=function(){return this.as("days")},A.weeks=function(){return this.get("weeks")},A.asWeeks=function(){return this.as("weeks")},A.months=function(){return this.get("months")},A.asMonths=function(){return this.as("months")},A.years=function(){return this.get("years")},A.asYears=function(){return this.as("years")},O}();return function(O,A,E){n=E,r=E().$utils(),E.duration=function(Q,Z){var se=E.locale();return C(Q,{$l:se},Z)},E.isDuration=m;var F=A.prototype.add,U=A.prototype.subtract;A.prototype.add=function(Q,Z){return m(Q)&&(Q=Q.asMilliseconds()),F.bind(this)(Q,Z)},A.prototype.subtract=function(Q,Z){return m(Q)&&(Q=Q.asMilliseconds()),U.bind(this)(Q,Z)}}})})(AT);const zT=Qi;var Ki={},$T={get exports(){return Ki},set exports(e){Ki=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){r.prototype.isBetween=function(o,l,u,c){var d=a(o),f=a(l),h=(c=c||"()")[0]==="(",g=c[1]===")";return(h?this.isAfter(d,u):!this.isBefore(d,u))&&(g?this.isBefore(f,u):!this.isAfter(f,u))||(h?this.isBefore(d,u):!this.isAfter(d,u))&&(g?this.isAfter(f,u):!this.isBefore(f,u))}}})})($T);const OT=Ki;var Ui={},LT={get exports(){return Ui},set exports(e){Ui=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}})})(LT);const PT=Ui;var Xi={},BT={get exports(){return Xi},set exports(e){Xi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){a.isMoment=function(o){return a.isDayjs(o)}}})})(BT);const VT=Xi;var Ji={},NT={get exports(){return Ji},set exports(e){Ji=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n="day";return function(r,a,o){var l=function(d){return d.add(4-d.isoWeekday(),n)},u=a.prototype;u.isoWeekYear=function(){return l(this).year()},u.isoWeek=function(d){if(!this.$utils().u(d))return this.add(7*(d-this.isoWeek()),n);var f,h,g,m,C=l(this),w=(f=this.isoWeekYear(),h=this.$u,g=(h?o.utc:o)().year(f).startOf("year"),m=4-g.isoWeekday(),g.isoWeekday()>4&&(m+=7),g.add(m,n));return C.diff(w,"week")+1},u.isoWeekday=function(d){return this.$utils().u(d)?this.day()||7:this.day(this.day()%7?d:d-7)};var c=u.startOf;u.startOf=function(d,f){var h=this.$utils(),g=!!h.u(f)||f;return h.p(d)==="isoweek"?g?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):c.bind(this)(d,f)}}})})(NT);const qT=Ji;var Zi={},FT={get exports(){return Zi},set exports(e){Zi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.isoWeeksInYear=function(){var a=this.isLeapYear(),o=this.endOf("y").day();return o===4||a&&o===5?53:52}}})})(FT);const GT=Zi;var Hi={},WT={get exports(){return Hi},set exports(e){Hi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.isSameOrAfter=function(a,o){return this.isSame(a,o)||this.isAfter(a,o)}}})})(WT);const jT=Hi;var ea={},RT={get exports(){return ea},set exports(e){ea=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.isSameOrBefore=function(a,o){return this.isSame(a,o)||this.isBefore(a,o)}}})})(RT);const YT=ea;var ta={},QT={get exports(){return ta},set exports(e){ta=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){r.prototype.isToday=function(){var o="YYYY-MM-DD",l=a();return this.format(o)===l.format(o)}}})})(QT);const KT=ta;var na={},UT={get exports(){return na},set exports(e){na=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){r.prototype.isTomorrow=function(){var o="YYYY-MM-DD",l=a().add(1,"day");return this.format(o)===l.format(o)}}})})(UT);const XT=na;var ra={},JT={get exports(){return ra},set exports(e){ra=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){r.prototype.isYesterday=function(){var o="YYYY-MM-DD",l=a().subtract(1,"day");return this.format(o)===l.format(o)}}})})(JT);const ZT=ra;var ia={},HT={get exports(){return ia},set exports(e){ia=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){var o=r.prototype,l=function(h){return h&&(h.indexOf?h:h.s)},u=function(h,g,m,C,w){var _=h.name?h:h.$locale(),T=l(_[g]),I=l(_[m]),L=T||I.map(function(O){return O.slice(0,C)});if(!w)return L;var N=_.weekStart;return L.map(function(O,A){return L[(A+(N||0))%7]})},c=function(){return a.Ls[a.locale()]},d=function(h,g){return h.formats[g]||function(m){return m.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(C,w,_){return w||_.slice(1)})}(h.formats[g.toUpperCase()])},f=function(){var h=this;return{months:function(g){return g?g.format("MMMM"):u(h,"months")},monthsShort:function(g){return g?g.format("MMM"):u(h,"monthsShort","months",3)},firstDayOfWeek:function(){return h.$locale().weekStart||0},weekdays:function(g){return g?g.format("dddd"):u(h,"weekdays")},weekdaysMin:function(g){return g?g.format("dd"):u(h,"weekdaysMin","weekdays",2)},weekdaysShort:function(g){return g?g.format("ddd"):u(h,"weekdaysShort","weekdays",3)},longDateFormat:function(g){return d(h.$locale(),g)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};o.localeData=function(){return f.bind(this)()},a.localeData=function(){var h=c();return{firstDayOfWeek:function(){return h.weekStart||0},weekdays:function(){return a.weekdays()},weekdaysShort:function(){return a.weekdaysShort()},weekdaysMin:function(){return a.weekdaysMin()},months:function(){return a.months()},monthsShort:function(){return a.monthsShort()},longDateFormat:function(g){return d(h,g)},meridiem:h.meridiem,ordinal:h.ordinal}},a.months=function(){return u(c(),"months")},a.monthsShort=function(){return u(c(),"monthsShort","months",3)},a.weekdays=function(h){return u(c(),"weekdays",null,null,h)},a.weekdaysShort=function(h){return u(c(),"weekdaysShort","weekdays",3,h)},a.weekdaysMin=function(h){return u(c(),"weekdaysMin","weekdays",2,h)}}})})(HT);const eD=ia;var aa={},tD={get exports(){return aa},set exports(e){aa=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(r,a,o){var l=a.prototype,u=l.format;o.en.formats=n,l.format=function(c){c===void 0&&(c="YYYY-MM-DDTHH:mm:ssZ");var d=this.$locale().formats,f=function(h,g){return h.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(m,C,w){var _=w&&w.toUpperCase();return C||g[w]||n[w]||g[_].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(T,I,L){return I||L.slice(1)})})}(c,d===void 0?{}:d);return u.call(this,f)}}})})(tD);const nD=aa;var sa={},rD={get exports(){return sa},set exports(e){sa=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){var o=function(l,u){if(!u||!u.length||!u[0]||u.length===1&&!u[0].length)return null;var c;u.length===1&&u[0].length>0&&(u=u[0]),c=u[0];for(var d=1;d<u.length;d+=1)u[d].isValid()&&!u[d][l](c)||(c=u[d]);return c};a.max=function(){var l=[].slice.call(arguments,0);return o("isAfter",l)},a.min=function(){var l=[].slice.call(arguments,0);return o("isBefore",l)}}})})(rD);const iD=sa;var oa={},aD={get exports(){return oa},set exports(e){oa=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){var o=r.prototype,l=function(g){var m,C=g.date,w=g.utc,_={};if(!((m=C)instanceof Date||m instanceof Array||o.$utils().u(m)||m.constructor.name!=="Object")){if(!Object.keys(C).length)return new Date;var T=w?a.utc():a();Object.keys(C).forEach(function(U){var Q,Z;_[Q=U,Z=o.$utils().p(Q),Z==="date"?"day":Z]=C[U]});var I=_.day||(_.year||_.month>=0?1:T.date()),L=_.year||T.year(),N=_.month>=0?_.month:_.year||_.day?0:T.month(),O=_.hour||0,A=_.minute||0,E=_.second||0,F=_.millisecond||0;return w?new Date(Date.UTC(L,N,I,O,A,E,F)):new Date(L,N,I,O,A,E,F)}return C},u=o.parse;o.parse=function(g){g.date=l.bind(this)(g),u.bind(this)(g)};var c=o.set,d=o.add,f=o.subtract,h=function(g,m,C,w){w===void 0&&(w=1);var _=Object.keys(m),T=this;return _.forEach(function(I){T=g.bind(T)(m[I]*w,I)}),T};o.set=function(g,m){return m=m===void 0?g:m,g.constructor.name==="Object"?h.bind(this)(function(C,w){return c.bind(this)(w,C)},m,g):c.bind(this)(g,m)},o.add=function(g,m){return g.constructor.name==="Object"?h.bind(this)(d,g,m):d.bind(this)(g,m)},o.subtract=function(g,m){return g.constructor.name==="Object"?h.bind(this)(d,g,m,-1):f.bind(this)(g,m)}}})})(aD);const sD=oa;var la={},oD={get exports(){return la},set exports(e){la=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){var a=r.prototype;["milliseconds","seconds","minutes","hours","days","weeks","isoWeeks","months","quarters","years","dates"].forEach(function(o){a[o]=a[o.replace(/s$/,"")]})}})})(oD);const lD=la;var ua={},uD={get exports(){return ua},set exports(e){ua=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){var a=r.prototype.parse;r.prototype.parse=function(u){if(typeof u.date=="string"){var c=this.$locale();u.date=c&&c.preparse?c.preparse(u.date):u.date}return a.bind(this)(u)};var o=r.prototype.format;r.prototype.format=function(){for(var u=arguments.length,c=new Array(u),d=0;d<u;d++)c[d]=arguments[d];var f=o.call.apply(o,[this].concat(c)),h=this.$locale();return h&&h.postformat?h.postformat(f):f};var l=r.prototype.fromToBase;l&&(r.prototype.fromToBase=function(u,c,d,f){var h=this.$locale()||d.$locale();return l.call(this,u,c,d,f,h&&h.postformat)})}})})(uD);const cD=ua;var ca={},dD={get exports(){return ca},set exports(e){ca=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n="month",r="quarter";return function(a,o){var l=o.prototype;l.quarter=function(d){return this.$utils().u(d)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(d-1))};var u=l.add;l.add=function(d,f){return d=Number(d),this.$utils().p(f)===r?this.add(3*d,n):u.bind(this)(d,f)};var c=l.startOf;l.startOf=function(d,f){var h=this.$utils(),g=!!h.u(f)||f;if(h.p(d)===r){var m=this.quarter()-1;return g?this.month(3*m).startOf(n).startOf("day"):this.month(3*m+2).endOf(n).endOf("day")}return c.bind(this)(d,f)}}})})(dD);const pD=ca;var da={},hD={get exports(){return da},set exports(e){da=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){n=n||{};var o=r.prototype,l={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function u(d,f,h,g){return o.fromToBase(d,f,h,g)}a.en.relativeTime=l,o.fromToBase=function(d,f,h,g,m){for(var C,w,_,T=h.$locale().relativeTime||l,I=n.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],L=I.length,N=0;N<L;N+=1){var O=I[N];O.d&&(C=g?a(d).diff(h,O.d,!0):h.diff(d,O.d,!0));var A=(n.rounding||Math.round)(Math.abs(C));if(_=C>0,A<=O.r||!O.r){A<=1&&N>0&&(O=I[N-1]);var E=T[O.l];m&&(A=m(""+A)),w=typeof E=="string"?E.replace("%d",A):E(A,f,O.l,_);break}}if(f)return w;var F=_?T.future:T.past;return typeof F=="function"?F(w):F.replace("%s",w)},o.to=function(d,f){return u(d,f,this,!0)},o.from=function(d,f){return u(d,f,this)};var c=function(d){return d.$u?a.utc():a()};o.toNow=function(d){return this.to(c(this),d)},o.fromNow=function(d){return this.from(c(this),d)}}})})(hD);const fD=da;var pa={},gD={get exports(){return pa},set exports(e){pa=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(a,o,l){var u,c=function(g,m,C){C===void 0&&(C={});var w=new Date(g),_=function(T,I){I===void 0&&(I={});var L=I.timeZoneName||"short",N=T+"|"+L,O=r[N];return O||(O=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:T,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:L}),r[N]=O),O}(m,C);return _.formatToParts(w)},d=function(g,m){for(var C=c(g,m),w=[],_=0;_<C.length;_+=1){var T=C[_],I=T.type,L=T.value,N=n[I];N>=0&&(w[N]=parseInt(L,10))}var O=w[3],A=O===24?0:O,E=w[0]+"-"+w[1]+"-"+w[2]+" "+A+":"+w[4]+":"+w[5]+":000",F=+g;return(l.utc(E).valueOf()-(F-=F%1e3))/6e4},f=o.prototype;f.tz=function(g,m){g===void 0&&(g=u);var C=this.utcOffset(),w=this.toDate(),_=w.toLocaleString("en-US",{timeZone:g}),T=Math.round((w-new Date(_))/1e3/60),I=l(_).$set("millisecond",this.$ms).utcOffset(15*-Math.round(w.getTimezoneOffset()/15)-T,!0);if(m){var L=I.utcOffset();I=I.add(C-L,"minute")}return I.$x.$timezone=g,I},f.offsetName=function(g){var m=this.$x.$timezone||l.tz.guess(),C=c(this.valueOf(),m,{timeZoneName:g}).find(function(w){return w.type.toLowerCase()==="timezonename"});return C&&C.value};var h=f.startOf;f.startOf=function(g,m){if(!this.$x||!this.$x.$timezone)return h.call(this,g,m);var C=l(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return h.call(C,g,m).tz(this.$x.$timezone,!0)},l.tz=function(g,m,C){var w=C&&m,_=C||m||u,T=d(+l(),_);if(typeof g!="string")return l(g).tz(_);var I=function(A,E,F){var U=A-60*E*1e3,Q=d(U,F);if(E===Q)return[U,E];var Z=d(U-=60*(Q-E)*1e3,F);return Q===Z?[U,Q]:[A-60*Math.min(Q,Z)*1e3,Math.max(Q,Z)]}(l.utc(g,w).valueOf(),T,_),L=I[0],N=I[1],O=l(L).utcOffset(N);return O.$x.$timezone=_,O},l.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},l.tz.setDefault=function(g){u=g}}})})(gD);const mD=pa;var ha={},yD={get exports(){return ha},set exports(e){ha=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.toArray=function(){return[this.$y,this.$M,this.$D,this.$H,this.$m,this.$s,this.$ms]}}})})(yD);const bD=ha;var fa={},vD={get exports(){return fa},set exports(e){fa=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.toObject=function(){return{years:this.$y,months:this.$M,date:this.$D,hours:this.$H,minutes:this.$m,seconds:this.$s,milliseconds:this.$ms}}}})})(vD);const xD=fa;var ga={},wD={get exports(){return ga},set exports(e){ga=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){a.updateLocale=function(o,l){var u=a.Ls[o];if(u)return(l?Object.keys(l):[]).forEach(function(c){u[c]=l[c]}),u}}})})(wD);const CD=ga;var ma={},SD={get exports(){return ma},set exports(e){ma=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n="minute",r=/[+-]\d\d(?::?\d\d)?/g,a=/([+-]|\d\d)/g;return function(o,l,u){var c=l.prototype;u.utc=function(w){var _={date:w,utc:!0,args:arguments};return new l(_)},c.utc=function(w){var _=u(this.toDate(),{locale:this.$L,utc:!0});return w?_.add(this.utcOffset(),n):_},c.local=function(){return u(this.toDate(),{locale:this.$L,utc:!1})};var d=c.parse;c.parse=function(w){w.utc&&(this.$u=!0),this.$utils().u(w.$offset)||(this.$offset=w.$offset),d.call(this,w)};var f=c.init;c.init=function(){if(this.$u){var w=this.$d;this.$y=w.getUTCFullYear(),this.$M=w.getUTCMonth(),this.$D=w.getUTCDate(),this.$W=w.getUTCDay(),this.$H=w.getUTCHours(),this.$m=w.getUTCMinutes(),this.$s=w.getUTCSeconds(),this.$ms=w.getUTCMilliseconds()}else f.call(this)};var h=c.utcOffset;c.utcOffset=function(w,_){var T=this.$utils().u;if(T(w))return this.$u?0:T(this.$offset)?h.call(this):this.$offset;if(typeof w=="string"&&(w=function(O){O===void 0&&(O="");var A=O.match(r);if(!A)return null;var E=(""+A[0]).match(a)||["-",0,0],F=E[0],U=60*+E[1]+ +E[2];return U===0?0:F==="+"?U:-U}(w),w===null))return this;var I=Math.abs(w)<=16?60*w:w,L=this;if(_)return L.$offset=I,L.$u=w===0,L;if(w!==0){var N=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(L=this.local().add(I+N,n)).$offset=I,L.$x.$localOffset=N}else L=this.utc();return L};var g=c.format;c.format=function(w){var _=w||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return g.call(this,_)},c.valueOf=function(){var w=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*w},c.isUTC=function(){return!!this.$u},c.toISOString=function(){return this.toDate().toISOString()},c.toString=function(){return this.toDate().toUTCString()};var m=c.toDate;c.toDate=function(w){return w==="s"&&this.$offset?u(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():m.call(this)};var C=c.diff;c.diff=function(w,_,T){if(w&&this.$u===w.$u)return C.call(this,w,_,T);var I=this.local(),L=u(w).local();return C.call(I,L,_,T)}}})})(SD);const _D=ma;var ya={},kD={get exports(){return ya},set exports(e){ya=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.weekday=function(a){var o=this.$locale().weekStart||0,l=this.$W,u=(l<o?l+7:l)-o;return this.$utils().u(a)?u:this.subtract(u,"day").add(a,"day")}}})})(kD);const TD=ya;var ba={},DD={get exports(){return ba},set exports(e){ba=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n="week",r="year";return function(a,o,l){var u=o.prototype;u.week=function(c){if(c===void 0&&(c=null),c!==null)return this.add(7*(c-this.week()),"day");var d=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var f=l(this).startOf(r).add(1,r).date(d),h=l(this).endOf(n);if(f.isBefore(h))return 1}var g=l(this).startOf(r).date(d).startOf(n).subtract(1,"millisecond"),m=this.diff(g,n,!0);return m<0?l(this).startOf("week").week():Math.ceil(m)},u.weeks=function(c){return c===void 0&&(c=null),this.week(c)}}})})(DD);const MD=ba;var va={},ID={get exports(){return va},set exports(e){va=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.weekYear=function(){var a=this.month(),o=this.week(),l=this.year();return o===1&&a===11?l+1:a===0&&o>=52?l-1:l}}})})(ID);const ED=va;Y.extend(bT),Y.extend(xT),Y.extend(CT),Y.extend(_T),Y.extend(TT),Y.extend(MT),Y.extend(ET),Y.extend(zT),Y.extend(OT),Y.extend(PT),Y.extend(VT),Y.extend(jT),Y.extend(YT),Y.extend(KT),Y.extend(XT),Y.extend(ZT),Y.extend(qT),Y.extend(GT),Y.extend(eD),Y.extend(nD),Y.extend(iD),Y.extend(sD),Y.extend(lD),Y.extend(cD),Y.extend(pD),Y.extend(fD),Y.extend(mD),Y.extend(bD),Y.extend(xD),Y.extend(CD),Y.extend(_D),Y.extend(MD),Y.extend(ED),Y.extend(TD),Y.tz.setDefault("UTC");const AD=()=>Promise.resolve().then(()=>tc).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));M.ContentModel=Ai,M.ContentModelContextProvider=Cr,M.DashboardEditor=pT,M.DashboardFilterType=_e,M.DashboardMode=$l,M.DashboardModel=Gl,M.DashboardModelContextProvider=vr,M.DashboardViewEditor=zl,M.DashboardViewRender=rr,M.DescriptionPopover=Di,M.FiltersModel=Ll,M.FullScreenPanel=Dl,M.FullScreenPanelContext=_r,M.LayoutStateContext=wn,M.Panel=Tl,M.PanelContextProvider=Sr,M.PanelErrorOrStateMessage=_l,M.PanelModel=Vl,M.PanelRender=Ii,M.PanelVizSection=Mi,M.PanelsModel=Nl,M.QueriesModel=Pl,M.ReadOnlyDashboard=mT,M.SQLSnippetsModel=Bl,M.ViewComponentTypeBackground=Ol,M.ViewComponentTypeColor=dS,M.ViewComponentTypeName=cS,M.ViewsModel=ql,M.Viz=Sl,M.applyPartialDashboard=SS,M.createContentModel=Fl,M.createDashboardModel=Wl,M.getInitialDashboardViewsModel=Ei,M.getVersion=AD,M.initialDashboardContent=pS,M.useDashboardContext=xr,M.useEditContentModelContext=le,M.useEditDashboardContext=me,M.useEditPanelContext=Je,M.useFullScreenPanelContext=as,M.usePanelFullScreen=Ml,M.useRenderContentModelContext=we,M.useRenderDashboardContext=wr,M.useRenderPanelContext=gt,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|
|
513
|
+
`)},kk=k.observer(({queryModel:e})=>e.typedAsSQL?p(s.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%",height:"28px",lineHeight:"28px"}},keepMounted:!1,children:[p(s.Tabs.List,{children:[i(s.Tabs.Tab,{value:"Edit",children:i(s.Group,{spacing:14,position:"apart",children:"Edit SQL"})}),i(s.Tabs.Tab,{value:"Preview",children:"Preview SQL"}),i(s.Tabs.Tab,{value:"pre_process",children:"Process Request"}),i(s.Tabs.Tab,{value:"post_process",children:"Process Result"}),i(Vi,{}),e.datasource&&i(ru,{dataSource:e.datasource})]}),i(s.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:i(Ck,{value:e.sql,onChange:e.setSQL,defaultValue:"SELECT 1"})}),i(s.Tabs.Panel,{value:"Preview",p:0,pl:4,children:i(_k,{value:e.sql})}),i(s.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:i(or,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:su.pre})}),i(s.Tabs.Panel,{value:"post_process",p:"sm",children:i(or,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:su.post})})]}):null),lr={height:"calc(100% - 44px)",padding:0},Tk=k.observer(({queryModel:e})=>{const t=le(),n=y.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),[r,a]=y.useState(n);y.useEffect(()=>{a(u=>u!=="Configurations"&&n==="Configurations"?"Configurations":u)},[n]);const o=t.findQueryUsage(e.id),l=o.length===0;return i(s.Stack,{sx:{flexGrow:1},my:0,p:0,children:p(s.Tabs,{value:r,onTabChange:a,defaultValue:n,orientation:"horizontal",keepMounted:!1,sx:{flexGrow:1},children:[p(s.Tabs.List,{grow:!0,children:[i(s.Tabs.Tab,{value:"Configurations",children:"Configurations"}),e.typedAsSQL&&i(s.Tabs.Tab,{value:"SQL",children:"Request"}),e.typedAsHTTP&&i(s.Tabs.Tab,{value:"HTTP",children:"Request"}),i(s.Tabs.Tab,{value:"Data",disabled:!e.datasource,children:i(s.Tooltip,{label:"Need to pick a Data Source first",disabled:e.datasource,withinPortal:!0,children:i(s.Text,{children:"Data"})})}),i(s.Tabs.Tab,{value:"Usage",disabled:l,children:i(s.Tooltip,{label:"This query is not used for any filter or panel",disabled:!l,withinPortal:!0,children:i(s.Text,{children:"Usage"})})})]}),i(s.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:i(fk,{queryModel:e})}),e.typedAsSQL&&i(s.Tabs.Panel,{value:"SQL",sx:lr,children:i(s.Stack,{sx:{height:"100%"},children:i(kk,{queryModel:e})})}),e.typedAsHTTP&&i(s.Tabs.Panel,{value:"HTTP",sx:lr,children:i(s.Stack,{sx:{height:"100%"},children:i(xk,{queryModel:e})})}),i(s.Tabs.Panel,{value:"Data",sx:{...lr,overflow:"hidden"},children:i(Pi,{id:e.id})}),i(s.Tabs.Panel,{value:"Usage",sx:{...lr,overflow:"hidden"},children:i(wk,{queryID:e.id,usage:o})})]})})}),Dk=k.observer(({id:e})=>{const n=le().queries.findByID(e);return e===""?null:n?i(s.Stack,{sx:{height:"100%"},spacing:"sm",children:i(Tk,{queryModel:n})}):i(s.Text,{size:14,color:"red",children:"Invalid Query ID"})}),Mk=k.observer(({value:e})=>{const n=we().payloadForSQL,r=y.useMemo(()=>gr(e,n),[e,n]);return i(Ni,{height:"100%",value:r})}),Ik=k.observer(({item:e,remove:t,onKeyChanged:n})=>{const[r,a]=y.useState("SQL"),[o,l]=y.useState(e.key),u=()=>{e.setKey(o),n(o)},c=o!==e.key,d=e.isADuplicatedKey(o),[f,h]=y.useState(e.value),g=()=>{e.setValue(f)};y.useEffect(()=>{l(e.key),h(e.value)},[e]);const m=f!==e.value,C=Ue.useModals(),w=()=>{C.openConfirmModal({title:"Delete this SQL snippet?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:t,confirmProps:{color:"red"},zIndex:320})};return p(s.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[p(s.Group,{sx:{alignItems:"end"},spacing:40,children:[i(s.TextInput,{label:d?"This key is occupied by another snippet":"Key",value:o,onChange:_=>{l(_.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:i(s.ActionIcon,{color:"blue",variant:"subtle",onClick:u,disabled:!c||d,children:i(D.DeviceFloppy,{size:16})}),error:d}),i(s.Button,{leftIcon:i(D.Trash,{size:16}),color:"red",variant:"light",onClick:w,children:"Delete this SQL Snippet"})]}),p(s.Tabs,{value:r,onTabChange:a,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[p(s.Tabs.List,{sx:{position:"relative"},children:[i(s.Tabs.Tab,{value:"SQL",children:"SQL"}),i(s.Tabs.Tab,{value:"Preview",children:"Preview"}),i(Vi,{}),i(s.ActionIcon,{color:"blue",variant:"filled",onClick:g,disabled:!m,sx:{position:"absolute",top:0,right:10},children:i(D.DeviceFloppy,{size:18})})]}),i(s.Tabs.Panel,{value:"SQL",pt:"sm",children:i(Ni,{height:"100%",value:f,onChange:h,defaultLanguage:"sql",theme:"sql-dark"})}),i(s.Tabs.Panel,{value:"Preview",pt:"sm",children:i(Mk,{value:f})})]})]})}),Ek=k.observer(({id:e})=>{const t=me(),n=le(),r=y.useMemo(()=>n.sqlSnippets.findByKey(e),[e]);if(!e)return null;if(!r)return p(s.Text,{size:14,children:["SQL Snippet by key[",e,"] is not found"]});const a=()=>{t.editor.setPath(["_SQL_SNIPPETS_",""])};return i(Ik,{item:r,remove:()=>{n.sqlSnippets.removeByKey(e),a()},onKeyChanged:u=>{t.editor.setPath(["_SQL_SNIPPETS_",u])}})}),Ak=k.observer(({view:e})=>!e||e.type!==R.Division?null:p(s.Stack,{children:[i(s.Divider,{mt:8,mb:0,label:"Division settings",labelPosition:"center"}),i(s.Text,{align:"center",size:"xs",color:"dimmed",children:"Under construction"})]})),zk=[{value:"default",label:"Default"},{value:"outline",label:"Outline"},{value:"pills",label:"Pills"}],$k=[{value:"horizontal",label:"Horizontal"},{value:"vertical",label:"Vertical"}],Ok=k.observer(({view:e})=>{if(!e||e.type!==R.Tabs)return null;const t=e.config;return p(s.Stack,{children:[i(s.Divider,{mt:8,mb:0,label:"Tabs settings",labelPosition:"center"}),i(s.Select,{label:"Variant",value:t.variant,onChange:t.setVariant,data:zk}),i(s.Select,{label:"Orientation",value:t.orientation,onChange:t.setOrientation,data:$k}),i(s.Switch,{label:"Grow Tabs",checked:t.grow,onChange:n=>t.setGrow(n.currentTarget.checked)})]})}),Lk=({disabled:e,value:t,onChange:n})=>{const r=a=>{a&&n(a)};return p(s.Box,{sx:{position:"relative"},children:[e&&i(s.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),i(Ae,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},Pk=({value:e,onChange:t})=>{const[n,{setTrue:r,setFalse:a}]=X.useBoolean(),[o,l]=y.useState(e??ki),u=g=>{l({...o,enabled:g})},c=()=>{a();const{enabled:g,func_content:m}=o,C={enabled:g,func_content:m};l(C),t(C)},d=()=>{a(),l(e)},f=g=>{l(m=>({...m,func_content:g}))},h=()=>{f(ki.func_content)};return p(B,{children:[i(s.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:r,sx:{flexGrow:0},children:i(D.Settings,{size:14})}),i(s.Modal,{size:800,title:"Customize modal title",opened:n,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:n&&p(s.Stack,{children:[i(s.Checkbox,{mt:10,label:"Enabled",checked:o.enabled,onChange:g=>u(g.currentTarget.checked)}),i(Lk,{value:o.func_content,onChange:f,disabled:!o.enabled}),p(s.Group,{position:"apart",children:[i(s.Button,{onClick:h,color:"red",leftIcon:i(D.Recycle,{size:20}),children:"Reset"}),p(s.Group,{position:"right",children:[i(s.Button,{onClick:d,variant:"subtle",children:"Cancel"}),i(s.Button,{onClick:c,children:"OK"})]})]})]})})]})},Bk=k.observer(({view:e})=>{if(!e||e.type!==R.Modal)return null;const t=e.config,n=t.custom_modal_title.value;return p(s.Stack,{children:[i(s.Divider,{mt:8,label:"Modal settings",labelPosition:"center"}),p(s.Flex,{gap:10,children:[i(s.TextInput,{label:"Modal Title",value:n,onChange:x.noop,disabled:!0,sx:{flexGrow:1}}),i(Pk,{value:t.custom_modal_title,onChange:t.custom_modal_title.replace})]}),p(s.Group,{grow:!0,children:[i(s.TextInput,{label:"Width",value:t.width,onChange:r=>t.setWidth(r.currentTarget.value),placeholder:"600px / 50vw"}),i(s.TextInput,{label:"Height",value:t.height,onChange:r=>t.setHeight(r.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),Vk=k.observer(({view:e})=>p(B,{children:[i(Ak,{view:e}),i(Bk,{view:e}),i(Ok,{view:e})]})),Nk=[{label:"Division",value:R.Division},{label:"Modal",value:R.Modal},{label:"Tabs",value:R.Tabs}],qk=k.observer(({view:e})=>e?p(s.Stack,{sx:{position:"relative"},children:[i(s.TextInput,{label:"Name",value:e.name,onChange:t=>{e.setName(t.currentTarget.value)}}),i(s.Select,{label:"Type",withinPortal:!0,zIndex:320,value:e.type,onChange:e.setType,data:Nk}),i(Vk,{view:e})]}):null),Fk=k.observer(({id:e})=>{const t=Ue.useModals(),n=me(),r=le();if(e==="")return null;const a=r.views.findByID(e);if(!a)return p(s.Text,{size:14,children:["View by ID[",e,"] is not found"]});const o=()=>{n.editor.setPath(["_VIEWS_",""])},l=()=>{t.openConfirmModal({title:"Delete this view?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{r.views.removeByID(e),o()},zIndex:320})};return p(s.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[i(s.Group,{position:"right",pt:10,children:i(s.Button,{size:"xs",color:"red",leftIcon:i(D.Trash,{size:16}),onClick:l,children:"Delete this view"})}),i(s.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:i(qk,{view:a})})]})});function Gk(e){return e.length===1&&e[0]==="_QUERY_VARS_"}function Wk(e){return e.length===1&&e[0]==="_MOCK_CONTEXT_"}function jk(e){return e.length===2&&e[0]==="_FILTERS_"}function Rk(e){return e.length===2&&e[0]==="_SQL_SNIPPETS_"}function Yk(e){return e.length===2&&e[0]==="_QUERIES_"}function Qk(e){return e.length===2&&e[0]==="_VIEWS_"}function Kk(e){return e.length===4&&e[0]==="_VIEWS_"&&e[2]==="_PANELS_"}const Uk=k.observer(()=>i(s.Stack,{sx:{height:"100%"},p:"sm",children:i(iu,{})})),Xk=k.observer(()=>{const e=me().editor,t=e.path;return Gk(t)?i(Uk,{}):Wk(t)?i(b_,{}):jk(t)?i(s.Box,{p:"xs",pl:20,children:i(y_,{id:t[1]})}):Rk(t)?i(Ek,{id:t[1]}):Yk(t)?i(Dk,{id:t[1]}):Qk(t)?i(s.Box,{p:"xs",pl:20,children:i(Fk,{id:t[1]})}):Kk(t)?i(Q_,{viewID:t[1],panelID:t[3]}):i(s.Box,{children:e.path})}),Jk=k.observer(()=>i(Xk,{})),Zk=k.observer(()=>{const e=me(),t=()=>{const n=new Date().getTime().toString(),r={id:n,key:n,label:n,order:e.content.filters.current.length+1,type:_e.TextInput,config:Jo(),visibleInViewsIDs:["Main"],auto_submit:!1};e.content.filters.append(r),e.editor.setPath(["_FILTERS_",n])};return i(s.Button,{variant:"subtle",leftIcon:i($.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Filter"})}),Hk=k.observer(({parentID:e})=>{const t=le();if(!e)return null;const n=t.views.findByID(e);return n?i(s.Button,{variant:"subtle",leftIcon:i($.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>t.addANewPanel(n.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Panel"}):null}),eT=k.observer(()=>{const e=me(),t=()=>{const n=new Date().getTime().toString(),r={id:n,name:n,type:Se.Postgresql,key:"",sql:""};e.content.queries.append(r),e.editor.setPath(["_QUERIES_",n])};return i(s.Button,{variant:"subtle",leftIcon:i($.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Query"})}),tT=k.observer(()=>{const e=me(),t=()=>{const n=new Date().getTime().toString(),r={key:n,value:""};e.content.sqlSnippets.append(r),e.editor.setPath(["_SQL_SNIPPETS_",n])};return i(s.Button,{variant:"subtle",leftIcon:i($.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a SQL Snippet"})}),nT=k.observer(()=>{const e=le();return i(s.Button,{variant:"subtle",leftIcon:i($.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:"Add a View"})}),rT=k.observer(({action_type:e,parentID:t})=>e==="_Add_A_Filter_"?i(Zk,{}):e==="_Add_A_SQL_SNIPPET_"?i(tT,{}):e==="_Add_A_QUERY_"?i(eT,{}):e==="_Add_A_VIEW_"?i(nT,{}):e==="_Add_A_PANEL_"?i(Hk,{parentID:t}):null),ou=k.observer(({option:e})=>{var d;const t=me().editor,n=t.isOptionActive,r=n(t.path,e),a=t.isOptionOpened,o=t.navigate,l=a(e),[u,c]=y.useState(l);return y.useEffect(()=>{c(l)},[l]),i(s.NavLink,{active:r,defaultOpened:l,opened:u,onChange:c,label:e.label,onClick:()=>o(e),icon:e.Icon?i(e.Icon,{size:18}):null,children:(d=e.children)==null?void 0:d.map(f=>f._type==="ACTION"?i(rT,{action_type:f._action_type,parentID:f.parentID},`_ADD_${f.value}_`):i(ou,{option:f},f.value))},e.label)}),iT=k.observer(()=>{const e=me();return i(s.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>i(ou,{option:t},t.value))})}),aT=k.observer(()=>{const e=me();return p(s.Navbar,{p:0,width:{base:200,xs:200,sm:220,md:240,lg:280,xl:300},sx:{height:"100vh - 60px - 60px"},children:[i(s.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:i(s.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Settings"})}),i(s.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:i(iT,{})}),i(s.Navbar.Section,{children:i(s.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:i(s.Button,{size:"xs",color:"red",leftIcon:i($.IconX,{size:18}),onClick:()=>e.editor.close(),children:"Close"})})})]})}),sT={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},oT=k.observer(()=>{const e=me().editor;return i(s.Modal,{onClose:()=>e.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:e.settings_open,fullScreen:!0,title:null,transitionProps:{duration:0},withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{body:{padding:"0 !important"}},children:i(s.AppShell,{padding:0,navbar:i(aT,{}),styles:sT,children:i(Jk,{})})})}),lT=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function uT(e){y.useEffect(()=>{if(Ae.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const n=lT(e);Ae.loader.config({paths:{vs:n}}),Ae.loader.init().then(r=>console.log("monaco instance:",r))},[])}Ss();const cT={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},dT=({context:e,dashboard:t,content:n,update:r,className:a="dashboard",config:o,onChange:l,headerSlot:u},c)=>{uT(o.monacoPath),Ka(o);const{data:d=[]}=X.useRequest(mr),{data:f=[]}=X.useRequest(Ua),h=y.useMemo(()=>Wl(t,n,d,f,e),[t,n]);y.useImperativeHandle(c,()=>h,[h]),jl(h.content,!0),y.useEffect(()=>{h.context.replace(e)},[e]),y.useEffect(()=>{h.datasources.replace(d)},[d]),y.useEffect(()=>{h.globalSQLSnippets.replace(f)},[f]),y.useEffect(()=>re.reaction(()=>re.toJS(h.json),w=>{l==null||l(w)}),[h]);const g=async()=>{await r(h.json,h.content.json)},m=X.useCreation(Ci,[]),C=Rl(m);return i(Ue.ModalsProvider,{children:i(vr,{value:h,children:i(Cr,{value:h.content,children:i(wn.Provider,{value:{inEditMode:!0},children:i(st.Provider,{value:m,children:p(Zn,{configure:C,children:[i(s.AppShell,{padding:0,header:i(IS,{saveDashboardChanges:g,headerSlot:u}),navbar:i(n_,{}),styles:cT,children:i(s.Box,{className:`${a} dashboard-root`,sx:{position:"relative"},children:h.content.views.visibleViews.map(w=>i(zl,{view:w},w.id))})}),i(oT,{})]})})})})})})},pT=k.observer(y.forwardRef(dT)),wM="",lu=b.types.model({id:b.types.string,name:b.types.string,dashboard_id:b.types.string,create_time:b.types.string,update_time:b.types.string,version:b.types.string,filters:cl,queries:yl,sqlSnippets:bl,views:sl,panels:ll,mock_context:Wo}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get payloadForSQL(){const t=b.getParent(e).context.current,n=b.getParent(e).globalSQLSnippets,r={context:{...e.mock_context.current,...t},filters:e.filters.values};return{...r,sql_snippets:tr(e.sqlSnippets.current,"key","value",r),global_sql_snippets:tr(n.list,"id","content",r)}},get payloadForViz(){const t=b.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.values}},get data(){return e.queries.current.map(({id:n,data:r})=>({id:n,data:r})).reduce((n,r)=>(n[r.id]=r.data,n),{})},getDataStuffByID(t){const n=e.queries.findByID(t);return n?{data:n.data.toJSON(),len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).actions(e=>({}));function hT({id:e,name:t,dashboard_id:n,create_time:r,update_time:a,content:o}){if(!o)throw new Error("unexpected null content when creating a content model");const{version:l,filters:u,views:c,panels:d,definition:{queries:f,sqlSnippets:h,mock_context:g={}}}=o;return lu.create({id:e,name:t,dashboard_id:n,create_time:r,update_time:a,version:l,filters:dl(u),queries:T1(f),sqlSnippets:M1(h),mock_context:jo(g),views:g1(c),panels:{list:d}})}const fT=b.types.model({id:b.types.identifier,name:b.types.string,group:b.types.string,content:lu,content_id:b.types.string,datasources:h1,globalSQLSnippets:il,context:Ti});function gT({id:e,name:t,group:n,content_id:r},a,o,l,u){return fT.create({id:e,name:t,group:n,content_id:r,content:hT(a),datasources:{list:o},globalSQLSnippets:{list:l},context:al(u)})}Ss();const mT=k.observer(({context:e,dashboard:t,content:n,className:r="dashboard",config:a,fullScreenPanelID:o,setFullScreenPanelID:l})=>{Ka(a);const{data:u=[]}=X.useRequest(mr),{data:c=[]}=X.useRequest(Ua),d=y.useMemo(()=>gT(t,n,u,c,e),[t,n]);jl(d.content,!1),y.useEffect(()=>{d.context.replace(e)},[e]),y.useEffect(()=>{d.datasources.replace(u)},[u]),y.useEffect(()=>{d.globalSQLSnippets.replace(c)},[c]);const f=X.useCreation(Ci,[]),h=Rl(f);return i(Ue.ModalsProvider,{children:i(vr,{value:d,children:i(Cr,{value:d.content,children:i(_r.Provider,{value:{fullScreenPanelID:o,setFullScreenPanelID:l},children:i(wn.Provider,{value:{inEditMode:!1},children:i(s.Box,{className:`${r} dashboard-root`,children:i(st.Provider,{value:f,children:i(Zn,{configure:h,children:d.content.views.visibleViews.map(g=>i(rr,{view:g},g.id))})})})})})})})})});var qi={},yT={get exports(){return qi},set exports(e){qi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){var a=r.prototype,o=a.format;a.format=function(l){var u=this,c=this.$locale();if(!this.isValid())return o.bind(this)(l);var d=this.$utils(),f=(l||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,function(h){switch(h){case"Q":return Math.ceil((u.$M+1)/3);case"Do":return c.ordinal(u.$D);case"gggg":return u.weekYear();case"GGGG":return u.isoWeekYear();case"wo":return c.ordinal(u.week(),"W");case"w":case"ww":return d.s(u.week(),h==="w"?1:2,"0");case"W":case"WW":return d.s(u.isoWeek(),h==="W"?1:2,"0");case"k":case"kk":return d.s(String(u.$H===0?24:u.$H),h==="k"?1:2,"0");case"X":return Math.floor(u.$d.getTime()/1e3);case"x":return u.$d.getTime();case"z":return"["+u.offsetName()+"]";case"zzz":return"["+u.offsetName("long")+"]";default:return h}});return o.bind(this)(f)}}})})(yT);const bT=qi;var Fi={},vT={get exports(){return Fi},set exports(e){Fi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){var o=r.prototype,l=function(c){var d=c.date,f=c.utc;return Array.isArray(d)?f?d.length?new Date(Date.UTC.apply(null,d)):new Date:d.length===1?a(String(d[0])).toDate():new(Function.prototype.bind.apply(Date,[null].concat(d))):d},u=o.parse;o.parse=function(c){c.date=l.bind(this)(c),u.bind(this)(c)}}})})(vT);const xT=Fi;var Gi={},wT={get exports(){return Gi},set exports(e){Gi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){var a=r.prototype;a.$g=function(g,m,C){return this.$utils().u(g)?this[m]:this.$set(C,g)},a.set=function(g,m){return this.$set(g,m)};var o=a.startOf;a.startOf=function(g,m){return this.$d=o.bind(this)(g,m).toDate(),this.init(),this};var l=a.add;a.add=function(g,m){return this.$d=l.bind(this)(g,m).toDate(),this.init(),this};var u=a.locale;a.locale=function(g,m){return g?(this.$L=u.bind(this)(g,m).$L,this):this.$L};var c=a.daysInMonth;a.daysInMonth=function(){return c.bind(this.clone())()};var d=a.isSame;a.isSame=function(g,m){return d.bind(this.clone())(g,m)};var f=a.isBefore;a.isBefore=function(g,m){return f.bind(this.clone())(g,m)};var h=a.isAfter;a.isAfter=function(g,m){return h.bind(this.clone())(g,m)}}})})(wT);const CT=Gi;var Wi={},ST={get exports(){return Wi},set exports(e){Wi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){var a=r.prototype,o=a.format;a.format=function(l){var u=this,c=(l||"YYYY-MM-DDTHH:mm:ssZ").replace(/(\[[^\]]+])|BBBB|BB/g,function(d,f){var h,g=String(u.$y+543),m=d==="BB"?[g.slice(-2),2]:[g,4];return f||(h=u.$utils()).s.apply(h,m.concat(["0"]))});return o.bind(this)(c)}}})})(ST);const _T=Wi;var ji={},kT={get exports(){return ji},set exports(e){ji=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){var o="h:mm A",l={lastDay:"[Yesterday at] "+o,sameDay:"[Today at] "+o,nextDay:"[Tomorrow at] "+o,nextWeek:"dddd [at] "+o,lastWeek:"[Last] dddd [at] "+o,sameElse:"MM/DD/YYYY"};r.prototype.calendar=function(u,c){var d=c||this.$locale().calendar||l,f=a(u||void 0).startOf("d"),h=this.diff(f,"d",!0),g="sameElse",m=h<-6?g:h<-1?"lastWeek":h<0?"lastDay":h<1?"sameDay":h<2?"nextDay":h<7?"nextWeek":g,C=d[m]||l[m];return typeof C=="function"?C.call(this,a()):this.format(C)}}})})(kT);const TT=ji;var Ri={},DT={get exports(){return Ri},set exports(e){Ri=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},r=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,a=/\d\d/,o=/\d\d?/,l=/\d*[^-_:/,()\s\d]+/,u={},c=function(w){return(w=+w)+(w>68?1900:2e3)},d=function(w){return function(_){this[w]=+_}},f=[/[+-]\d\d:?(\d\d)?|Z/,function(w){(this.zone||(this.zone={})).offset=function(_){if(!_||_==="Z")return 0;var T=_.match(/([+-]|\d\d)/g),I=60*T[1]+(+T[2]||0);return I===0?0:T[0]==="+"?-I:I}(w)}],h=function(w){var _=u[w];return _&&(_.indexOf?_:_.s.concat(_.f))},g=function(w,_){var T,I=u.meridiem;if(I){for(var L=1;L<=24;L+=1)if(w.indexOf(I(L,0,_))>-1){T=L>12;break}}else T=w===(_?"pm":"PM");return T},m={A:[l,function(w){this.afternoon=g(w,!1)}],a:[l,function(w){this.afternoon=g(w,!0)}],S:[/\d/,function(w){this.milliseconds=100*+w}],SS:[a,function(w){this.milliseconds=10*+w}],SSS:[/\d{3}/,function(w){this.milliseconds=+w}],s:[o,d("seconds")],ss:[o,d("seconds")],m:[o,d("minutes")],mm:[o,d("minutes")],H:[o,d("hours")],h:[o,d("hours")],HH:[o,d("hours")],hh:[o,d("hours")],D:[o,d("day")],DD:[a,d("day")],Do:[l,function(w){var _=u.ordinal,T=w.match(/\d+/);if(this.day=T[0],_)for(var I=1;I<=31;I+=1)_(I).replace(/\[|\]/g,"")===w&&(this.day=I)}],M:[o,d("month")],MM:[a,d("month")],MMM:[l,function(w){var _=h("months"),T=(h("monthsShort")||_.map(function(I){return I.slice(0,3)})).indexOf(w)+1;if(T<1)throw new Error;this.month=T%12||T}],MMMM:[l,function(w){var _=h("months").indexOf(w)+1;if(_<1)throw new Error;this.month=_%12||_}],Y:[/[+-]?\d+/,d("year")],YY:[a,function(w){this.year=c(w)}],YYYY:[/\d{4}/,d("year")],Z:f,ZZ:f};function C(w){var _,T;_=w,T=u&&u.formats;for(var I=(w=_.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(U,Q,Z){var se=Z&&Z.toUpperCase();return Q||T[Z]||n[Z]||T[se].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(ue,ye,Ie){return ye||Ie.slice(1)})})).match(r),L=I.length,N=0;N<L;N+=1){var O=I[N],A=m[O],E=A&&A[0],F=A&&A[1];I[N]=F?{regex:E,parser:F}:O.replace(/^\[|\]$/g,"")}return function(U){for(var Q={},Z=0,se=0;Z<L;Z+=1){var ue=I[Z];if(typeof ue=="string")se+=ue.length;else{var ye=ue.regex,Ie=ue.parser,fe=U.slice(se),ve=ye.exec(fe)[0];Ie.call(Q,ve),U=U.replace(ve,"")}}return function(ge){var Le=ge.afternoon;if(Le!==void 0){var Qe=ge.hours;Le?Qe<12&&(ge.hours+=12):Qe===12&&(ge.hours=0),delete ge.afternoon}}(Q),Q}}return function(w,_,T){T.p.customParseFormat=!0,w&&w.parseTwoDigitYear&&(c=w.parseTwoDigitYear);var I=_.prototype,L=I.parse;I.parse=function(N){var O=N.date,A=N.utc,E=N.args;this.$u=A;var F=E[1];if(typeof F=="string"){var U=E[2]===!0,Q=E[3]===!0,Z=U||Q,se=E[2];Q&&(se=E[2]),u=this.$locale(),!U&&se&&(u=T.Ls[se]),this.$d=function(fe,ve,ge){try{if(["x","X"].indexOf(ve)>-1)return new Date((ve==="X"?1e3:1)*fe);var Le=C(ve)(fe),Qe=Le.year,zt=Le.month,ur=Le.day,cr=Le.hours,xa=Le.minutes,wa=Le.seconds,un=Le.milliseconds,Gt=Le.zone,wt=new Date,$t=ur||(Qe||zt?1:wt.getDate()),Ct=Qe||wt.getFullYear(),Wt=0;Qe&&!zt||(Wt=zt>0?zt-1:wt.getMonth());var jt=cr||0,cn=xa||0,dn=wa||0,St=un||0;return Gt?new Date(Date.UTC(Ct,Wt,$t,jt,cn,dn,St+60*Gt.offset*1e3)):ge?new Date(Date.UTC(Ct,Wt,$t,jt,cn,dn,St)):new Date(Ct,Wt,$t,jt,cn,dn,St)}catch{return new Date("")}}(O,F,A),this.init(),se&&se!==!0&&(this.$L=this.locale(se).$L),Z&&O!=this.format(F)&&(this.$d=new Date("")),u={}}else if(F instanceof Array)for(var ue=F.length,ye=1;ye<=ue;ye+=1){E[1]=F[ye-1];var Ie=T.apply(this,E);if(Ie.isValid()){this.$d=Ie.$d,this.$L=Ie.$L,this.init();break}ye===ue&&(this.$d=new Date(""))}else L.call(this,N)}}})})(DT);const MT=Ri;var Yi={},IT={get exports(){return Yi},set exports(e){Yi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){r.prototype.dayOfYear=function(o){var l=Math.round((a(this).startOf("day")-a(this).startOf("year"))/864e5)+1;return o==null?l:this.add(o-l,"day")}}})})(IT);const ET=Yi;var Qi={},AT={get exports(){return Qi},set exports(e){Qi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n,r,a=1e3,o=6e4,l=36e5,u=864e5,c=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,d=31536e6,f=2592e6,h=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,g={years:d,months:f,days:u,hours:l,minutes:o,seconds:a,milliseconds:1,weeks:6048e5},m=function(O){return O instanceof N},C=function(O,A,E){return new N(O,E,A.$l)},w=function(O){return r.p(O)+"s"},_=function(O){return O<0},T=function(O){return _(O)?Math.ceil(O):Math.floor(O)},I=function(O){return Math.abs(O)},L=function(O,A){return O?_(O)?{negative:!0,format:""+I(O)+A}:{negative:!1,format:""+O+A}:{negative:!1,format:""}},N=function(){function O(E,F,U){var Q=this;if(this.$d={},this.$l=U,E===void 0&&(this.$ms=0,this.parseFromMilliseconds()),F)return C(E*g[w(F)],this);if(typeof E=="number")return this.$ms=E,this.parseFromMilliseconds(),this;if(typeof E=="object")return Object.keys(E).forEach(function(ue){Q.$d[w(ue)]=E[ue]}),this.calMilliseconds(),this;if(typeof E=="string"){var Z=E.match(h);if(Z){var se=Z.slice(2).map(function(ue){return ue!=null?Number(ue):0});return this.$d.years=se[0],this.$d.months=se[1],this.$d.weeks=se[2],this.$d.days=se[3],this.$d.hours=se[4],this.$d.minutes=se[5],this.$d.seconds=se[6],this.calMilliseconds(),this}}return this}var A=O.prototype;return A.calMilliseconds=function(){var E=this;this.$ms=Object.keys(this.$d).reduce(function(F,U){return F+(E.$d[U]||0)*g[U]},0)},A.parseFromMilliseconds=function(){var E=this.$ms;this.$d.years=T(E/d),E%=d,this.$d.months=T(E/f),E%=f,this.$d.days=T(E/u),E%=u,this.$d.hours=T(E/l),E%=l,this.$d.minutes=T(E/o),E%=o,this.$d.seconds=T(E/a),E%=a,this.$d.milliseconds=E},A.toISOString=function(){var E=L(this.$d.years,"Y"),F=L(this.$d.months,"M"),U=+this.$d.days||0;this.$d.weeks&&(U+=7*this.$d.weeks);var Q=L(U,"D"),Z=L(this.$d.hours,"H"),se=L(this.$d.minutes,"M"),ue=this.$d.seconds||0;this.$d.milliseconds&&(ue+=this.$d.milliseconds/1e3);var ye=L(ue,"S"),Ie=E.negative||F.negative||Q.negative||Z.negative||se.negative||ye.negative,fe=Z.format||se.format||ye.format?"T":"",ve=(Ie?"-":"")+"P"+E.format+F.format+Q.format+fe+Z.format+se.format+ye.format;return ve==="P"||ve==="-P"?"P0D":ve},A.toJSON=function(){return this.toISOString()},A.format=function(E){var F=E||"YYYY-MM-DDTHH:mm:ss",U={Y:this.$d.years,YY:r.s(this.$d.years,2,"0"),YYYY:r.s(this.$d.years,4,"0"),M:this.$d.months,MM:r.s(this.$d.months,2,"0"),D:this.$d.days,DD:r.s(this.$d.days,2,"0"),H:this.$d.hours,HH:r.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:r.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:r.s(this.$d.seconds,2,"0"),SSS:r.s(this.$d.milliseconds,3,"0")};return F.replace(c,function(Q,Z){return Z||String(U[Q])})},A.as=function(E){return this.$ms/g[w(E)]},A.get=function(E){var F=this.$ms,U=w(E);return U==="milliseconds"?F%=1e3:F=U==="weeks"?T(F/g[U]):this.$d[U],F===0?0:F},A.add=function(E,F,U){var Q;return Q=F?E*g[w(F)]:m(E)?E.$ms:C(E,this).$ms,C(this.$ms+Q*(U?-1:1),this)},A.subtract=function(E,F){return this.add(E,F,!0)},A.locale=function(E){var F=this.clone();return F.$l=E,F},A.clone=function(){return C(this.$ms,this)},A.humanize=function(E){return n().add(this.$ms,"ms").locale(this.$l).fromNow(!E)},A.milliseconds=function(){return this.get("milliseconds")},A.asMilliseconds=function(){return this.as("milliseconds")},A.seconds=function(){return this.get("seconds")},A.asSeconds=function(){return this.as("seconds")},A.minutes=function(){return this.get("minutes")},A.asMinutes=function(){return this.as("minutes")},A.hours=function(){return this.get("hours")},A.asHours=function(){return this.as("hours")},A.days=function(){return this.get("days")},A.asDays=function(){return this.as("days")},A.weeks=function(){return this.get("weeks")},A.asWeeks=function(){return this.as("weeks")},A.months=function(){return this.get("months")},A.asMonths=function(){return this.as("months")},A.years=function(){return this.get("years")},A.asYears=function(){return this.as("years")},O}();return function(O,A,E){n=E,r=E().$utils(),E.duration=function(Q,Z){var se=E.locale();return C(Q,{$l:se},Z)},E.isDuration=m;var F=A.prototype.add,U=A.prototype.subtract;A.prototype.add=function(Q,Z){return m(Q)&&(Q=Q.asMilliseconds()),F.bind(this)(Q,Z)},A.prototype.subtract=function(Q,Z){return m(Q)&&(Q=Q.asMilliseconds()),U.bind(this)(Q,Z)}}})})(AT);const zT=Qi;var Ki={},$T={get exports(){return Ki},set exports(e){Ki=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){r.prototype.isBetween=function(o,l,u,c){var d=a(o),f=a(l),h=(c=c||"()")[0]==="(",g=c[1]===")";return(h?this.isAfter(d,u):!this.isBefore(d,u))&&(g?this.isBefore(f,u):!this.isAfter(f,u))||(h?this.isBefore(d,u):!this.isAfter(d,u))&&(g?this.isAfter(f,u):!this.isBefore(f,u))}}})})($T);const OT=Ki;var Ui={},LT={get exports(){return Ui},set exports(e){Ui=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.isLeapYear=function(){return this.$y%4==0&&this.$y%100!=0||this.$y%400==0}}})})(LT);const PT=Ui;var Xi={},BT={get exports(){return Xi},set exports(e){Xi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){a.isMoment=function(o){return a.isDayjs(o)}}})})(BT);const VT=Xi;var Ji={},NT={get exports(){return Ji},set exports(e){Ji=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n="day";return function(r,a,o){var l=function(d){return d.add(4-d.isoWeekday(),n)},u=a.prototype;u.isoWeekYear=function(){return l(this).year()},u.isoWeek=function(d){if(!this.$utils().u(d))return this.add(7*(d-this.isoWeek()),n);var f,h,g,m,C=l(this),w=(f=this.isoWeekYear(),h=this.$u,g=(h?o.utc:o)().year(f).startOf("year"),m=4-g.isoWeekday(),g.isoWeekday()>4&&(m+=7),g.add(m,n));return C.diff(w,"week")+1},u.isoWeekday=function(d){return this.$utils().u(d)?this.day()||7:this.day(this.day()%7?d:d-7)};var c=u.startOf;u.startOf=function(d,f){var h=this.$utils(),g=!!h.u(f)||f;return h.p(d)==="isoweek"?g?this.date(this.date()-(this.isoWeekday()-1)).startOf("day"):this.date(this.date()-1-(this.isoWeekday()-1)+7).endOf("day"):c.bind(this)(d,f)}}})})(NT);const qT=Ji;var Zi={},FT={get exports(){return Zi},set exports(e){Zi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.isoWeeksInYear=function(){var a=this.isLeapYear(),o=this.endOf("y").day();return o===4||a&&o===5?53:52}}})})(FT);const GT=Zi;var Hi={},WT={get exports(){return Hi},set exports(e){Hi=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.isSameOrAfter=function(a,o){return this.isSame(a,o)||this.isAfter(a,o)}}})})(WT);const jT=Hi;var ea={},RT={get exports(){return ea},set exports(e){ea=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.isSameOrBefore=function(a,o){return this.isSame(a,o)||this.isBefore(a,o)}}})})(RT);const YT=ea;var ta={},QT={get exports(){return ta},set exports(e){ta=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){r.prototype.isToday=function(){var o="YYYY-MM-DD",l=a();return this.format(o)===l.format(o)}}})})(QT);const KT=ta;var na={},UT={get exports(){return na},set exports(e){na=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){r.prototype.isTomorrow=function(){var o="YYYY-MM-DD",l=a().add(1,"day");return this.format(o)===l.format(o)}}})})(UT);const XT=na;var ra={},JT={get exports(){return ra},set exports(e){ra=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){r.prototype.isYesterday=function(){var o="YYYY-MM-DD",l=a().subtract(1,"day");return this.format(o)===l.format(o)}}})})(JT);const ZT=ra;var ia={},HT={get exports(){return ia},set exports(e){ia=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){var o=r.prototype,l=function(h){return h&&(h.indexOf?h:h.s)},u=function(h,g,m,C,w){var _=h.name?h:h.$locale(),T=l(_[g]),I=l(_[m]),L=T||I.map(function(O){return O.slice(0,C)});if(!w)return L;var N=_.weekStart;return L.map(function(O,A){return L[(A+(N||0))%7]})},c=function(){return a.Ls[a.locale()]},d=function(h,g){return h.formats[g]||function(m){return m.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(C,w,_){return w||_.slice(1)})}(h.formats[g.toUpperCase()])},f=function(){var h=this;return{months:function(g){return g?g.format("MMMM"):u(h,"months")},monthsShort:function(g){return g?g.format("MMM"):u(h,"monthsShort","months",3)},firstDayOfWeek:function(){return h.$locale().weekStart||0},weekdays:function(g){return g?g.format("dddd"):u(h,"weekdays")},weekdaysMin:function(g){return g?g.format("dd"):u(h,"weekdaysMin","weekdays",2)},weekdaysShort:function(g){return g?g.format("ddd"):u(h,"weekdaysShort","weekdays",3)},longDateFormat:function(g){return d(h.$locale(),g)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};o.localeData=function(){return f.bind(this)()},a.localeData=function(){var h=c();return{firstDayOfWeek:function(){return h.weekStart||0},weekdays:function(){return a.weekdays()},weekdaysShort:function(){return a.weekdaysShort()},weekdaysMin:function(){return a.weekdaysMin()},months:function(){return a.months()},monthsShort:function(){return a.monthsShort()},longDateFormat:function(g){return d(h,g)},meridiem:h.meridiem,ordinal:h.ordinal}},a.months=function(){return u(c(),"months")},a.monthsShort=function(){return u(c(),"monthsShort","months",3)},a.weekdays=function(h){return u(c(),"weekdays",null,null,h)},a.weekdaysShort=function(h){return u(c(),"weekdaysShort","weekdays",3,h)},a.weekdaysMin=function(h){return u(c(),"weekdaysMin","weekdays",2,h)}}})})(HT);const eD=ia;var aa={},tD={get exports(){return aa},set exports(e){aa=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"};return function(r,a,o){var l=a.prototype,u=l.format;o.en.formats=n,l.format=function(c){c===void 0&&(c="YYYY-MM-DDTHH:mm:ssZ");var d=this.$locale().formats,f=function(h,g){return h.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(m,C,w){var _=w&&w.toUpperCase();return C||g[w]||n[w]||g[_].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(T,I,L){return I||L.slice(1)})})}(c,d===void 0?{}:d);return u.call(this,f)}}})})(tD);const nD=aa;var sa={},rD={get exports(){return sa},set exports(e){sa=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){var o=function(l,u){if(!u||!u.length||!u[0]||u.length===1&&!u[0].length)return null;var c;u.length===1&&u[0].length>0&&(u=u[0]),c=u[0];for(var d=1;d<u.length;d+=1)u[d].isValid()&&!u[d][l](c)||(c=u[d]);return c};a.max=function(){var l=[].slice.call(arguments,0);return o("isAfter",l)},a.min=function(){var l=[].slice.call(arguments,0);return o("isBefore",l)}}})})(rD);const iD=sa;var oa={},aD={get exports(){return oa},set exports(e){oa=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){var o=r.prototype,l=function(g){var m,C=g.date,w=g.utc,_={};if(!((m=C)instanceof Date||m instanceof Array||o.$utils().u(m)||m.constructor.name!=="Object")){if(!Object.keys(C).length)return new Date;var T=w?a.utc():a();Object.keys(C).forEach(function(U){var Q,Z;_[Q=U,Z=o.$utils().p(Q),Z==="date"?"day":Z]=C[U]});var I=_.day||(_.year||_.month>=0?1:T.date()),L=_.year||T.year(),N=_.month>=0?_.month:_.year||_.day?0:T.month(),O=_.hour||0,A=_.minute||0,E=_.second||0,F=_.millisecond||0;return w?new Date(Date.UTC(L,N,I,O,A,E,F)):new Date(L,N,I,O,A,E,F)}return C},u=o.parse;o.parse=function(g){g.date=l.bind(this)(g),u.bind(this)(g)};var c=o.set,d=o.add,f=o.subtract,h=function(g,m,C,w){w===void 0&&(w=1);var _=Object.keys(m),T=this;return _.forEach(function(I){T=g.bind(T)(m[I]*w,I)}),T};o.set=function(g,m){return m=m===void 0?g:m,g.constructor.name==="Object"?h.bind(this)(function(C,w){return c.bind(this)(w,C)},m,g):c.bind(this)(g,m)},o.add=function(g,m){return g.constructor.name==="Object"?h.bind(this)(d,g,m):d.bind(this)(g,m)},o.subtract=function(g,m){return g.constructor.name==="Object"?h.bind(this)(d,g,m,-1):f.bind(this)(g,m)}}})})(aD);const sD=oa;var la={},oD={get exports(){return la},set exports(e){la=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){var a=r.prototype;["milliseconds","seconds","minutes","hours","days","weeks","isoWeeks","months","quarters","years","dates"].forEach(function(o){a[o]=a[o.replace(/s$/,"")]})}})})(oD);const lD=la;var ua={},uD={get exports(){return ua},set exports(e){ua=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){var a=r.prototype.parse;r.prototype.parse=function(u){if(typeof u.date=="string"){var c=this.$locale();u.date=c&&c.preparse?c.preparse(u.date):u.date}return a.bind(this)(u)};var o=r.prototype.format;r.prototype.format=function(){for(var u=arguments.length,c=new Array(u),d=0;d<u;d++)c[d]=arguments[d];var f=o.call.apply(o,[this].concat(c)),h=this.$locale();return h&&h.postformat?h.postformat(f):f};var l=r.prototype.fromToBase;l&&(r.prototype.fromToBase=function(u,c,d,f){var h=this.$locale()||d.$locale();return l.call(this,u,c,d,f,h&&h.postformat)})}})})(uD);const cD=ua;var ca={},dD={get exports(){return ca},set exports(e){ca=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n="month",r="quarter";return function(a,o){var l=o.prototype;l.quarter=function(d){return this.$utils().u(d)?Math.ceil((this.month()+1)/3):this.month(this.month()%3+3*(d-1))};var u=l.add;l.add=function(d,f){return d=Number(d),this.$utils().p(f)===r?this.add(3*d,n):u.bind(this)(d,f)};var c=l.startOf;l.startOf=function(d,f){var h=this.$utils(),g=!!h.u(f)||f;if(h.p(d)===r){var m=this.quarter()-1;return g?this.month(3*m).startOf(n).startOf("day"):this.month(3*m+2).endOf(n).endOf("day")}return c.bind(this)(d,f)}}})})(dD);const pD=ca;var da={},hD={get exports(){return da},set exports(e){da=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){n=n||{};var o=r.prototype,l={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function u(d,f,h,g){return o.fromToBase(d,f,h,g)}a.en.relativeTime=l,o.fromToBase=function(d,f,h,g,m){for(var C,w,_,T=h.$locale().relativeTime||l,I=n.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],L=I.length,N=0;N<L;N+=1){var O=I[N];O.d&&(C=g?a(d).diff(h,O.d,!0):h.diff(d,O.d,!0));var A=(n.rounding||Math.round)(Math.abs(C));if(_=C>0,A<=O.r||!O.r){A<=1&&N>0&&(O=I[N-1]);var E=T[O.l];m&&(A=m(""+A)),w=typeof E=="string"?E.replace("%d",A):E(A,f,O.l,_);break}}if(f)return w;var F=_?T.future:T.past;return typeof F=="function"?F(w):F.replace("%s",w)},o.to=function(d,f){return u(d,f,this,!0)},o.from=function(d,f){return u(d,f,this)};var c=function(d){return d.$u?a.utc():a()};o.toNow=function(d){return this.to(c(this),d)},o.fromNow=function(d){return this.from(c(this),d)}}})})(hD);const fD=da;var pa={},gD={get exports(){return pa},set exports(e){pa=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(a,o,l){var u,c=function(g,m,C){C===void 0&&(C={});var w=new Date(g),_=function(T,I){I===void 0&&(I={});var L=I.timeZoneName||"short",N=T+"|"+L,O=r[N];return O||(O=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:T,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:L}),r[N]=O),O}(m,C);return _.formatToParts(w)},d=function(g,m){for(var C=c(g,m),w=[],_=0;_<C.length;_+=1){var T=C[_],I=T.type,L=T.value,N=n[I];N>=0&&(w[N]=parseInt(L,10))}var O=w[3],A=O===24?0:O,E=w[0]+"-"+w[1]+"-"+w[2]+" "+A+":"+w[4]+":"+w[5]+":000",F=+g;return(l.utc(E).valueOf()-(F-=F%1e3))/6e4},f=o.prototype;f.tz=function(g,m){g===void 0&&(g=u);var C=this.utcOffset(),w=this.toDate(),_=w.toLocaleString("en-US",{timeZone:g}),T=Math.round((w-new Date(_))/1e3/60),I=l(_).$set("millisecond",this.$ms).utcOffset(15*-Math.round(w.getTimezoneOffset()/15)-T,!0);if(m){var L=I.utcOffset();I=I.add(C-L,"minute")}return I.$x.$timezone=g,I},f.offsetName=function(g){var m=this.$x.$timezone||l.tz.guess(),C=c(this.valueOf(),m,{timeZoneName:g}).find(function(w){return w.type.toLowerCase()==="timezonename"});return C&&C.value};var h=f.startOf;f.startOf=function(g,m){if(!this.$x||!this.$x.$timezone)return h.call(this,g,m);var C=l(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return h.call(C,g,m).tz(this.$x.$timezone,!0)},l.tz=function(g,m,C){var w=C&&m,_=C||m||u,T=d(+l(),_);if(typeof g!="string")return l(g).tz(_);var I=function(A,E,F){var U=A-60*E*1e3,Q=d(U,F);if(E===Q)return[U,E];var Z=d(U-=60*(Q-E)*1e3,F);return Q===Z?[U,Q]:[A-60*Math.min(Q,Z)*1e3,Math.max(Q,Z)]}(l.utc(g,w).valueOf(),T,_),L=I[0],N=I[1],O=l(L).utcOffset(N);return O.$x.$timezone=_,O},l.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},l.tz.setDefault=function(g){u=g}}})})(gD);const mD=pa;var ha={},yD={get exports(){return ha},set exports(e){ha=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.toArray=function(){return[this.$y,this.$M,this.$D,this.$H,this.$m,this.$s,this.$ms]}}})})(yD);const bD=ha;var fa={},vD={get exports(){return fa},set exports(e){fa=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.toObject=function(){return{years:this.$y,months:this.$M,date:this.$D,hours:this.$H,minutes:this.$m,seconds:this.$s,milliseconds:this.$ms}}}})})(vD);const xD=fa;var ga={},wD={get exports(){return ga},set exports(e){ga=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r,a){a.updateLocale=function(o,l){var u=a.Ls[o];if(u)return(l?Object.keys(l):[]).forEach(function(c){u[c]=l[c]}),u}}})})(wD);const CD=ga;var ma={},SD={get exports(){return ma},set exports(e){ma=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n="minute",r=/[+-]\d\d(?::?\d\d)?/g,a=/([+-]|\d\d)/g;return function(o,l,u){var c=l.prototype;u.utc=function(w){var _={date:w,utc:!0,args:arguments};return new l(_)},c.utc=function(w){var _=u(this.toDate(),{locale:this.$L,utc:!0});return w?_.add(this.utcOffset(),n):_},c.local=function(){return u(this.toDate(),{locale:this.$L,utc:!1})};var d=c.parse;c.parse=function(w){w.utc&&(this.$u=!0),this.$utils().u(w.$offset)||(this.$offset=w.$offset),d.call(this,w)};var f=c.init;c.init=function(){if(this.$u){var w=this.$d;this.$y=w.getUTCFullYear(),this.$M=w.getUTCMonth(),this.$D=w.getUTCDate(),this.$W=w.getUTCDay(),this.$H=w.getUTCHours(),this.$m=w.getUTCMinutes(),this.$s=w.getUTCSeconds(),this.$ms=w.getUTCMilliseconds()}else f.call(this)};var h=c.utcOffset;c.utcOffset=function(w,_){var T=this.$utils().u;if(T(w))return this.$u?0:T(this.$offset)?h.call(this):this.$offset;if(typeof w=="string"&&(w=function(O){O===void 0&&(O="");var A=O.match(r);if(!A)return null;var E=(""+A[0]).match(a)||["-",0,0],F=E[0],U=60*+E[1]+ +E[2];return U===0?0:F==="+"?U:-U}(w),w===null))return this;var I=Math.abs(w)<=16?60*w:w,L=this;if(_)return L.$offset=I,L.$u=w===0,L;if(w!==0){var N=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(L=this.local().add(I+N,n)).$offset=I,L.$x.$localOffset=N}else L=this.utc();return L};var g=c.format;c.format=function(w){var _=w||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return g.call(this,_)},c.valueOf=function(){var w=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*w},c.isUTC=function(){return!!this.$u},c.toISOString=function(){return this.toDate().toISOString()},c.toString=function(){return this.toDate().toUTCString()};var m=c.toDate;c.toDate=function(w){return w==="s"&&this.$offset?u(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():m.call(this)};var C=c.diff;c.diff=function(w,_,T){if(w&&this.$u===w.$u)return C.call(this,w,_,T);var I=this.local(),L=u(w).local();return C.call(I,L,_,T)}}})})(SD);const _D=ma;var ya={},kD={get exports(){return ya},set exports(e){ya=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.weekday=function(a){var o=this.$locale().weekStart||0,l=this.$W,u=(l<o?l+7:l)-o;return this.$utils().u(a)?u:this.subtract(u,"day").add(a,"day")}}})})(kD);const TD=ya;var ba={},DD={get exports(){return ba},set exports(e){ba=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){var n="week",r="year";return function(a,o,l){var u=o.prototype;u.week=function(c){if(c===void 0&&(c=null),c!==null)return this.add(7*(c-this.week()),"day");var d=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var f=l(this).startOf(r).add(1,r).date(d),h=l(this).endOf(n);if(f.isBefore(h))return 1}var g=l(this).startOf(r).date(d).startOf(n).subtract(1,"millisecond"),m=this.diff(g,n,!0);return m<0?l(this).startOf("week").week():Math.ceil(m)},u.weeks=function(c){return c===void 0&&(c=null),this.week(c)}}})})(DD);const MD=ba;var va={},ID={get exports(){return va},set exports(e){va=e}};(function(e,t){(function(n,r){e.exports=r()})(te,function(){return function(n,r){r.prototype.weekYear=function(){var a=this.month(),o=this.week(),l=this.year();return o===1&&a===11?l+1:a===0&&o>=52?l-1:l}}})})(ID);const ED=va;Y.extend(bT),Y.extend(xT),Y.extend(CT),Y.extend(_T),Y.extend(TT),Y.extend(MT),Y.extend(ET),Y.extend(zT),Y.extend(OT),Y.extend(PT),Y.extend(VT),Y.extend(jT),Y.extend(YT),Y.extend(KT),Y.extend(XT),Y.extend(ZT),Y.extend(qT),Y.extend(GT),Y.extend(eD),Y.extend(nD),Y.extend(iD),Y.extend(sD),Y.extend(lD),Y.extend(cD),Y.extend(pD),Y.extend(fD),Y.extend(mD),Y.extend(bD),Y.extend(xD),Y.extend(CD),Y.extend(_D),Y.extend(MD),Y.extend(ED),Y.extend(TD),Y.tz.setDefault("UTC");const AD=()=>Promise.resolve().then(()=>tc).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));M.ContentModel=Ai,M.ContentModelContextProvider=Cr,M.DashboardEditor=pT,M.DashboardFilterType=_e,M.DashboardMode=$l,M.DashboardModel=Gl,M.DashboardModelContextProvider=vr,M.DashboardViewEditor=zl,M.DashboardViewRender=rr,M.DescriptionPopover=Di,M.FiltersModel=Ll,M.FullScreenPanel=Dl,M.FullScreenPanelContext=_r,M.LayoutStateContext=wn,M.Panel=Tl,M.PanelContextProvider=Sr,M.PanelErrorOrStateMessage=_l,M.PanelModel=Vl,M.PanelRender=Ii,M.PanelVizSection=Mi,M.PanelsModel=Nl,M.QueriesModel=Pl,M.ReadOnlyDashboard=mT,M.SQLSnippetsModel=Bl,M.ViewComponentTypeBackground=Ol,M.ViewComponentTypeColor=dS,M.ViewComponentTypeName=cS,M.ViewsModel=ql,M.Viz=Sl,M.applyPartialDashboard=SS,M.createContentModel=Fl,M.createDashboardModel=Wl,M.getInitialDashboardViewsModel=Ei,M.getVersion=AD,M.initialDashboardContent=pS,M.useDashboardContext=xr,M.useEditContentModelContext=le,M.useEditDashboardContext=me,M.useEditPanelContext=Je,M.useFullScreenPanelContext=as,M.usePanelFullScreen=Ml,M.useRenderContentModelContext=we,M.useRenderDashboardContext=wr,M.useRenderPanelContext=gt,Object.defineProperty(M,Symbol.toStringTag,{value:"Module"})});
|