@devtable/dashboard 7.10.1 → 7.11.0

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.
@@ -19275,7 +19275,7 @@ const xF = (e) => {
19275
19275
  getColor: ol(["#fff7f1", "darkorange", "#b60000"]),
19276
19276
  name: "orange",
19277
19277
  category: "sequential"
19278
- }, jb = "@devtable/dashboard", bd = "7.10.1", Kb = "Apache-2.0", Bb = {
19278
+ }, jb = "@devtable/dashboard", bd = "7.11.0", Kb = "Apache-2.0", Bb = {
19279
19279
  access: "public",
19280
19280
  registry: "https://registry.npmjs.org/"
19281
19281
  }, Wb = [
@@ -34779,11 +34779,7 @@ const MB = q.forwardRef(({
34779
34779
  },
34780
34780
  children: /* @__PURE__ */ b(Le, {
34781
34781
  className: "dashboard-view",
34782
- mx: -10,
34783
- sx: {
34784
- position: "relative",
34785
- height: "100%"
34786
- },
34782
+ "data-enable-scrollbar": !0,
34787
34783
  children: [s && /* @__PURE__ */ l(tw, {
34788
34784
  view: t,
34789
34785
  panel: c,
@@ -34881,11 +34877,7 @@ const MB = q.forwardRef(({
34881
34877
  },
34882
34878
  children: /* @__PURE__ */ b(Le, {
34883
34879
  className: "dashboard-view",
34884
- mx: -10,
34885
- sx: {
34886
- position: "relative",
34887
- height: "100%"
34888
- },
34880
+ "data-enable-scrollbar": !0,
34889
34881
  children: [a && /* @__PURE__ */ l(tw, {
34890
34882
  view: t,
34891
34883
  panel: s,
@@ -136,7 +136,7 @@ WHERE
136
136
  description?: string;
137
137
  }
138
138
  `,h2=()=>{const[e,t]=x.useState(!1);return w(De,{children:[l(f.Button,{variant:"subtle",compact:!0,onClick:()=>t(n=>!n),children:e?"Close":"Click to see expected data structure"}),l(f.Collapse,{in:e,children:l(Or.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:p2})})]})},g2=le.observer(function({config:t}){return w(De,{children:[l(f.TextInput,{label:"Min-width",value:t.min_width,onChange:n=>t.setMinWidth(n.currentTarget.value),placeholder:"200px"}),l(f.Divider,{label:"Fetch options from database",labelPosition:"center"}),l(f.NumberInput,{value:t.default_selection_count,onChange:t.setDefaultSelectionCount,label:"Select first N options by default"}),l(Au,{value:t.options_query_id,onChange:t.setOptionsQueryID}),l(h2,{})]})}),v2=le.observer(function({filter:t}){const n=t.plainDefaultValue,[r,i]=W.default.useState(n);return W.default.useEffect(()=>{!t.usingDefaultValue||i(n)},[n]),w(f.Box,{sx:{maxWidth:"30em"},children:[l(f.Text,{pb:"md",color:"gray",children:"Preview"}),l(Bh,{filter:t,value:r,onChange:i}),l(f.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),l(Or.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),m2={select:d2,"multi-select":c2,"tree-select":g2,"text-input":f2,checkbox:a2,"date-range":l2},y2=[{label:"Select",value:"select"},{label:"Multi Select",value:"multi-select"},{label:"Tree Select",value:"tree-select"},{label:"Text Input",value:"text-input"},{label:"Checkbox",value:"checkbox"},{label:"Date Range",value:"date-range"}],b2=le.observer(function({filter:t,index:n}){const r=ot(),i=W.default.useMemo(()=>m2[t.type],[t.type]);return w(f.SimpleGrid,{cols:2,children:[w(f.Box,{pl:"md",children:[l(f.Text,{pb:"md",color:"gray",children:"Edit"}),w(f.Stack,{sx:{maxWidth:"30em"},children:[w(f.Group,{noWrap:!0,children:[l(f.NumberInput,{label:"Placement Order",required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&l(f.Checkbox,{label:"Submit automatically",checked:t.auto_submit,onChange:o=>t.setAutoSubmit(o.currentTarget.checked),mt:22})]}),l(f.MultiSelect,{label:"Visible in...",data:r.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),l(f.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:t.key,onChange:o=>{t.setKey(o.currentTarget.value)}}),l(f.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:t.label,onChange:o=>{t.setLabel(o.currentTarget.value)}}),l(f.Select,{label:"Widget",data:y2,required:!0,value:t.type,onChange:t.setType}),l(i,{config:t.config,index:n})]})]}),l(v2,{filter:t})]})}),$j="",w2=le.observer(function(){const t=ot(),n=t.filters.current,r=()=>{const i=St.randomId(),o={id:i,key:i,label:i,order:n.length+1,type:Ht.TextInput,config:wm(),visibleInViewsIDs:["Main"],auto_submit:!1};t.filters.append(o)};return w(f.Box,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)"},p:0,children:[l(f.Group,{sx:{position:"absolute",top:"16px",right:"16px"},children:l(f.Button,{size:"xs",color:"red",leftIcon:l(oe.Recycle,{size:20}),disabled:!t.filtersChanged,onClick:t.resetFilters,children:"Revert Changes"})}),l(f.Tabs,{className:"filter-settings-tabs",orientation:"vertical",defaultValue:t.filters.firstID,styles:{root:{display:"block"}},keepMounted:!1,children:w(f.Group,{sx:{height:"100%"},children:[w(f.Stack,{sx:{height:"100%"},children:[l(f.Tabs.List,{position:"left",sx:{flexGrow:1,width:"200px"},children:t.filters.current.map(i=>l(f.Tabs.Tab,{value:i.id,sx:{maxWidth:"100%",overflow:"scroll"},children:i.label},i.id))}),l(f.Button,{size:"xs",color:"blue",leftIcon:l(oe.PlaylistAdd,{size:20}),onClick:r,children:"Add a Filter"})]}),l(f.Box,{sx:{flexGrow:1,height:"100%"},children:t.filters.current.map((i,o)=>l(f.Tabs.Panel,{value:i.id,sx:{height:"100%"},children:w(f.Stack,{sx:{height:"100%"},spacing:"sm",children:[l(f.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"scroll"},children:l(b2,{filter:i,index:o})}),l(f.Group,{position:"right",pt:10,children:l(f.Button,{size:"xs",color:"red",leftIcon:l(oe.Trash,{size:20}),onClick:()=>t.filters.remove(o),children:"Delete this filter"})})]})},i.id))})]})})]})}),x2=le.observer(function({opened:t,close:n}){const{freezeLayout:r}=W.default.useContext(vn);return W.default.useEffect(()=>{r(t)},[t]),l(f.Modal,{size:"96vw",overflow:"inside",opened:t,onClose:n,title:"Filters",trapFocus:!0,onDragStart:i=>{i.stopPropagation()},withCloseButton:!1,children:l(w2,{})})}),S2=le.observer(()=>{const t=ot().views.VIE;return!t||t.type!==wt.Division?null:w(f.Stack,{children:[l(f.Divider,{mt:8,mb:0,label:"Division settings",labelPosition:"center"}),l(f.Text,{align:"center",size:"xs",color:"dimmed",children:"Under construction"})]})}),C2=({disabled:e,value:t,onChange:n})=>{const r=i=>{!i||n(i)};return w(f.Box,{sx:{position:"relative"},children:[e&&l(f.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),l(Gn.default,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1,readOnly:e}}})]})},Pu={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
139
- `)},_2=({value:e,onChange:t})=>{const[n,{setTrue:r,setFalse:i}]=tt.useBoolean(),[o,a]=x.useState(e!=null?e:Pu),s=h=>{a({...o,enabled:h})},u=()=>{i();const{enabled:h,func_content:g}=o,v={enabled:h,func_content:g};a(v),t(v)},c=()=>{i(),a(e)},d=h=>{a(g=>({...g,func_content:h}))},p=()=>{d(Pu.func_content)};return w(De,{children:[l(f.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:r,sx:{flexGrow:0},children:l(oe.Settings,{size:14})}),l(f.Modal,{size:800,title:"Customize modal title",opened:n,onClose:i,closeOnClickOutside:!1,withCloseButton:!1,children:n&&w(f.Stack,{children:[l(f.Checkbox,{mt:10,label:"Enabled",checked:o.enabled,onChange:h=>s(h.currentTarget.checked)}),l(C2,{value:o.func_content,onChange:d,disabled:!o.enabled}),w(f.Group,{position:"apart",children:[l(f.Button,{onClick:p,color:"red",leftIcon:l(oe.Recycle,{size:20}),children:"Rest"}),w(f.Group,{position:"right",children:[l(f.Button,{onClick:c,variant:"subtle",children:"Cancel"}),l(f.Button,{onClick:u,children:"OK"})]})]})]})})]})},E2=le.observer(()=>{const t=ot().views.VIE;if(!t||t.type!==wt.Modal)return null;const n=t.config,r=n.custom_modal_title.value;return w(f.Stack,{children:[l(f.Divider,{mt:8,label:"Modal settings",labelPosition:"center"}),w(f.Flex,{gap:10,children:[l(f.TextInput,{label:"Modal Title",value:r,onChange:Se.default.noop,disabled:!0,sx:{flexGrow:1}}),l(_2,{value:n.custom_modal_title,onChange:n.custom_modal_title.replace})]}),w(f.Group,{grow:!0,children:[l(f.TextInput,{label:"Width",value:n.width,onChange:i=>n.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),l(f.TextInput,{label:"Height",value:n.height,onChange:i=>n.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),T2=le.observer(()=>w(De,{children:[l(S2,{}),l(E2,{})]})),M2=[{label:"Division",value:wt.Division},{label:"Modal",value:wt.Modal}],O2=le.observer(()=>{const t=ot().views.VIE;return t?w(f.Stack,{sx:{position:"relative"},children:[l(f.TextInput,{label:"Name",value:t.name,onChange:n=>{t.setName(n.currentTarget.value)}}),l(f.Select,{label:"Type",value:t.type,onChange:t.setType,data:M2}),l(T2,{})]}):null}),D2=le.observer(({opened:e,close:t})=>{var i;const n=ot(),{freezeLayout:r}=W.default.useContext(vn);return W.default.useEffect(()=>{r(e)},[e]),l(f.Modal,{size:"500px",overflow:"inside",opened:e,onClose:t,withCloseButton:!1,styles:{header:{width:"100%"},title:{width:"100%"}},title:w(f.Group,{position:"apart",children:[w(f.Text,{sx:{flexGrow:1},children:["Editing ",(i=n.views.VIE)==null?void 0:i.name]}),l(f.ActionIcon,{size:18,color:"red",onClick:n.views.removeVIE,disabled:n.views.isVIETheFirstView,children:l(oe.Trash,{size:18})})]}),trapFocus:!0,onDragStart:o=>{o.stopPropagation()},children:l(O2,{})})}),R2=x.forwardRef(({label:e,type:t,...n},r)=>t!=="TRIGGER_TO_ADD"?l("div",{ref:r,...n,children:w(f.Group,{noWrap:!0,position:"apart",children:[l(f.Text,{size:"sm",children:e}),l(f.Text,{size:"xs",color:"dimmed",children:t})]})}):l("div",{ref:r,...n,children:l(f.Group,{noWrap:!0,grow:!0,children:l(f.Text,{size:"sm",align:"center",color:"#228be6",children:e})})})),Sm="TRIGGER_TO_ADD",k2=le.observer(({value:e,onChange:t,triggerAdd:n,triggerEdit:r,options:i})=>{const o=x.useMemo(()=>[...i,{label:"Add a View",value:Sm,type:"TRIGGER_TO_ADD"}],[i,n]),a=s=>{s!==Sm?t(s):n()};return w(f.Flex,{gap:0,sx:{minWidth:"400px"},children:[l(f.Select,{value:e,onChange:a,placeholder:"Pick a View",itemComponent:R2,data:o,nothingFound:"Empty",sx:{flexGrow:1},styles:{input:{borderTopRightRadius:0,borderBottomRightRadius:0}}}),l(f.ActionIcon,{onClick:r,variant:"default",size:36,sx:{borderLeft:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,"&:active":{transform:"none",svg:{transform:"translateY(1px)"}}},children:l(oe.Settings,{size:20})})]})}),A2=le.observer(()=>{const e=ot(),[t,n]=x.useState(!1),r=()=>{n(!0)},i=()=>{n(!1)};return w(De,{children:[l(k2,{value:e.views.idOfVIE,onChange:e.views.setIDOfVIE,triggerAdd:e.views.addARandomNewView,triggerEdit:r,options:e.views.options}),l(D2,{opened:t,close:i})]})}),Cm={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}},_m=le.observer(function({saveChanges:t}){const n=ot(),r=W.default.useCallback(()=>{const E=n.queries.json,M=n.views.json,R=n.sqlSnippets.json,L=n.filters.current,F=n.mock_context.current;return{filters:L,views:M,definition:{sqlSnippets:R,queries:E,mock_context:F},version:n.version}},[n]),i=()=>{n.reset()},o=n.changed,{inEditMode:a,inUseMode:s}=W.default.useContext(vn),[u,c]=W.default.useState(!1),d=()=>c(!0),p=()=>c(!1),[h,g]=W.default.useState(!1),v=()=>g(!0),m=()=>g(!1),[b,y]=W.default.useState(!1),_=()=>y(!0),S=()=>y(!1),C=()=>{const E=JSON.stringify(r(),null,2);E$(n.name,E)};return s?null:w(f.Group,{position:"apart",pt:0,px:10,pb:"xs",children:[l(f.Group,{position:"left",children:a&&l(A2,{})}),w(f.Group,{position:"right",sx:{button:{minWidth:"40px"}},children:[l(f.Button,{variant:"filled",size:"xs",disabled:!n.views.VIE,onClick:n.views.addAPanelToVIE,leftIcon:l(oe.PlaylistAdd,{size:20}),children:"Add a Panel"}),w(f.Group,{spacing:0,sx:Cm,children:[l(f.Tooltip,{label:"Filters",children:l(f.ActionIcon,{variant:"default",size:"md",onClick:v,children:l(oe.Filter,{size:20})})}),l(f.Tooltip,{label:"Data Settings",children:l(f.ActionIcon,{variant:"default",size:"md",onClick:d,children:l(oe.Database,{size:20})})}),l(f.Tooltip,{label:"Interactions Viewer",children:l(f.ActionIcon,{variant:"default",size:"md",onClick:_,children:l(oe.Link,{size:20})})})]}),w(f.Group,{spacing:0,sx:Cm,children:[l(f.Tooltip,{label:"Save Changes",children:l(f.ActionIcon,{variant:"default",size:"md",onClick:t,disabled:!o,children:l(oe.DeviceFloppy,{size:20,color:"green"})})}),l(f.Tooltip,{label:"Revert Changes",children:l(f.ActionIcon,{variant:"default",size:"md",disabled:!o,onClick:i,children:l(oe.Recycle,{size:20,color:"red"})})})]}),w(f.Menu,{width:180,trigger:"hover",children:[l(f.Menu.Target,{children:l(f.ActionIcon,{variant:"default",size:"md",children:l(oe.Share,{size:20})})}),w(f.Menu.Dropdown,{children:[l(f.Menu.Item,{icon:l(oe.Download,{size:14}),onClick:n.queries.downloadAllData,children:"Download Data"}),l(f.Menu.Item,{icon:l(oe.Code,{size:14}),onClick:C,children:"Download Schema"})]})]})]}),l(x2,{opened:h,close:m}),l(o2,{opened:u,close:p}),l(C$,{opened:b,close:S})]})}),Lj="",Em=Qt.Mark.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["span",Qt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:e,commands:t})=>{const n=Qt.getMarkAttributes(e,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:t.unsetMark(this.name)}}}}),Tm=Qt.Extension.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;return(t=e.style.color)===null||t===void 0?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),P2=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))$/,N2=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))/g,Mm=Qt.Mark.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",Qt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Qt.markInputRule({find:P2,type:this.type})]},addPasteRules(){return[Qt.markPasteRule({find:N2,type:this.type})]}}),Om=Qt.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Yb.Plugin({props:{decorations:({doc:e,selection:t})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,i=[];if(!n)return null;const o=e.type.createAndFill(),a=(o==null?void 0:o.sameMarkup(e))&&o.content.findDiffStart(e.content)===null;return e.descendants((s,u)=>{const c=r>=u&&r<=u+s.nodeSize,d=!s.isLeaf&&!s.childCount;if((c||!this.options.showOnlyCurrent)&&d){const p=[this.options.emptyNodeClass];a&&p.push(this.options.emptyEditorClass);const h=Fc.Decoration.node(u,u+s.nodeSize,{class:p.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:u,hasAnchor:c}):this.options.placeholder});i.push(h)}return this.options.includeChildren}),Fc.DecorationSet.create(e,i)}}})]}}),Dm=Qt.Mark.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(e){return e!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sub",Qt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),Rm=Qt.Mark.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(e){return e!=="super"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sup",Qt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),km=Qt.Extension.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:"left"}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>e.style.textAlign||this.options.defaultAlignment,renderHTML:e=>e.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.every(n=>t.updateAttributes(n,{textAlign:e})):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.every(t=>e.resetAttributes(t,"textAlign"))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Am=Qt.Mark.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",Qt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Nu={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"}}},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:'"\u25BA"',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"}},Pm=({value:e,styles:t={}})=>{const n=Bc.useEditor({extensions:[Kc.default,Am,et.Link,Rm,Dm,Mm,km.configure({types:["heading","paragraph"]}),Om.configure({placeholder:"This is placeholder"}),Em,Tm],content:e,editable:!1}),r=x.useMemo(()=>Se.default.defaultsDeep({},{content:Nu},t),[t]);return l(et.RichTextEditor,{editor:n,styles:r,children:l(et.RichTextEditor.Content,{})})};function I2(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const Nm=le.observer(()=>{const{freezeLayout:e}=W.default.useContext(vn),[t,n]=W.default.useState(!1),{panel:r}=Gt();return W.default.useEffect(()=>{e(t)},[t]),I2(r.description)?null:w(De,{children:[l(f.Modal,{opened:t,onClose:()=>n(!1),title:r.title,withCloseButton:!1,children:l(Pm,{value:r.description,styles:{root:{border:"none"},content:{padding:0}}})}),l(f.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:l(f.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:l(oe.InfoCircle,{size:20})})})]})}),Im=e=>{const{title:t="Variables",variables:n}=e,r=St.useClipboard(),i=o=>{r.copy(o),ko.showNotification({color:"green",message:"Copied to clipboard"})};return w(f.Paper,{withBorder:!0,p:"sm",children:[l(f.Text,{size:"xs",color:"dimmed",mb:"sm",children:t}),l(f.Stack,{style:{maxHeight:"500px"},children:n.map(o=>w(f.Text,{size:"sm",children:[w(f.Code,{color:"teal",children:["// ",o.description]}),l("br",{}),w(f.Code,{onClick:()=>i(o.name),style:{cursor:"pointer"},children:[o.name," : ",o.valueType]})]},o.name))})]})};class $2{constructor(t,n){ke(this,"operationId");ke(this,"operation");ke(this,"operationSchema");ke(this,"variables",[]);this.operationManager=t,this.instance=n,zt.makeAutoObservable(this)}get schemaList(){return this.operationManager.getOperationSchemaList()}async configOperation(t,n){const r=await this.operationManager.retrieveTrigger(t),i=this.operationManager.getOperationSchemaList().find(o=>o.id===(r==null?void 0:r.schemaRef));zt.runInAction(()=>{this.operationId=t,this.operation=r,this.operationSchema=i,this.variables=n})}async changeSchema(t){this.operationId&&(await this.operationManager.createOrGetOperation(this.operationId,t),await this.configOperation(this.operationId,this.variables))}}function L2(e){return!!e.operationId}const V2=le.observer(({model:e,onClick:t})=>{var r;const n=(r=e.operationSchema)==null?void 0:r.displayName;return l(f.Button,{variant:"outline",onClick:t,children:n})}),z2=le.observer(({model:e})=>{const t={operation:e.operation,instance:e.instance,variables:[]};return x.createElement(e.operationSchema.configRender,t)});function F2({model:e}){const t=e.schemaList,n=t.map(i=>({label:i.displayName,value:i.id}));async function r(i){await e.changeSchema(t.find(o=>o.id===i))}return l(f.Select,{label:"Operation",data:n,onChange:r,value:e.operationSchema.id})}const B2=le.observer(e=>{const[t,{setTrue:n,setFalse:r}]=tt.useBoolean(!1),{operationManager:i,operationId:o,instance:a,variables:s}=e,u=tt.useCreation(()=>new $2(i,a),[i,a]);return tt.useAsyncEffect(async()=>{await u.configOperation(o,s)},[o,u]),L2(u)?w(De,{children:[l(V2,{model:u,onClick:n}),l(f.Modal,{size:600,opened:t,onClose:r,title:"Operation Settings",closeButtonLabel:"close",children:w(f.Stack,{children:[l(F2,{model:u}),l(z2,{model:u}),l(Im,{title:"Variables",variables:u.variables})]})})]}):null});class j2{constructor(t,n){ke(this,"triggerId");ke(this,"trigger");ke(this,"triggerSchema");ke(this,"sampleData");this.triggerManager=t,this.instance=n,zt.makeAutoObservable(this)}get schemaList(){return this.triggerManager.getTriggerSchemaList()}async configTrigger(t,n){const r=await this.triggerManager.retrieveTrigger(t),i=this.triggerManager.getTriggerSchemaList().find(o=>o.id===(r==null?void 0:r.schemaRef));zt.runInAction(()=>{this.triggerId=t,this.trigger=r,this.triggerSchema=i,this.sampleData=n})}async changeSchema(t){this.triggerId&&(await this.triggerManager.createOrGetTrigger(this.triggerId,t),await this.configTrigger(this.triggerId,this.sampleData))}isReady(){return G2(this)}}function G2(e){return!!e.triggerId&&!!e.triggerSchema}function K2(e,t){return tt.useCreation(()=>new j2(e,t),[e,t])}const H2=le.observer(({model:e,onClick:t})=>{const n=e.triggerSchema.nameRender,r={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return l(f.Button,{variant:"outline",onClick:t,children:x.createElement(n,r)})}),q2=le.observer(({model:e})=>{const t=e.schemaList,n=t.map(i=>({label:i.displayName,value:i.id}));async function r(i){await e.changeSchema(t.find(o=>o.id===i))}return l(f.Select,{label:"Trigger",data:n,value:e.triggerSchema.id,onChange:r})}),W2=le.observer(({model:e})=>{const t={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return x.createElement(e.triggerSchema.configRender,t)}),U2=le.observer(e=>{const[t,{setTrue:n,setFalse:r}]=tt.useBoolean(!1),i=e.model;return w(De,{children:[l(f.Modal,{opened:t,onClose:r,title:"Setup Trigger",closeButtonLabel:"close setup",children:w(f.Stack,{children:[l(q2,{model:i}),l(W2,{model:i}),l(Im,{title:"Payload",variables:i.triggerSchema.payload})]})}),l(H2,{onClick:n,model:i})]})});class Ti{constructor(t,n){this.root=t,this.path=n}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const n=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,H.omit(n,t))}async getItem(t){const n=await this.root.getItem(this.path);return t===null?n:H.get(n,t)}async setItem(t,n){if(t===null)await this.root.setItem(this.path,n);else{const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...r,[t]:n})}return await this.getItem(t)}watchItem(t,n,r){return t===null?this.root.watchItem(this.path,(i,o)=>{n(i,o)},r):this.root.watchItem(this.path,(i,o)=>{const a=H.get(i,t),s=H.get(o,t);a!==s&&n(a,s)},r)}}class Iu{constructor(t,n,r){ke(this,"attachmentStorage");this.instance=t,this.attachmentKey=n,this.constructInstance=r,this.attachmentStorage=new Ti(t.instanceData,n)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new Ti(this.attachmentStorage,t))}async create(t,n){return await this.attachmentStorage.setItem(t,n),this.constructInstance(new Ti(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(H.values(t).map(n=>this.constructInstance(new Ti(this.attachmentStorage,n.id))))}}class $m{constructor(t){ke(this,"rootRef");this.rootRef=zt.observable({current:t})}async deleteItem(t){zt.runInAction(()=>{H.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?zt.toJS(this.rootRef.current):H.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(H.isObject(n))zt.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else zt.runInAction(()=>{H.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return zt.reaction(()=>this.getValueFromRoot(t),(i,o)=>{n(i,o)},{requiresObservable:!0,fireImmediately:H.get(r,"fireImmediately",!1)})}}class Y2{constructor(){ke(this,"channels",new Map);ke(this,"globalChannel",new Hc.default)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new Hc.default;return this.channels.set(t,r),r}}class X2{constructor(t){ke(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 Y2,instanceData:new $m(t.viz.conf)};return this.instances.set(t.id,r),r}}function Lm(e,t,n,r){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new $m({}),colorPalette:{getColor(){return()=>""}},data:t,variables:r}}const Q2=e=>{const{panel:t,vizManager:n,data:r,variables:i}=e,o=n.resolveComponent(t.viz.type),a=n.getOrCreateInstance(t),s={...Lm(a,r,n,i),viewport:{width:t.layout.w,height:t.layout.h}},u=o.viewRender;return l(u,{context:s,instance:a,...H.omit(e,["panel","vizManager","data"])})},Z2=e=>{const{vizManager:t,panel:n,panelInfoEditor:r,data:i,variables:o}=e,a=t.resolveComponent(n.viz.type),s=t.getOrCreateInstance(n),u={...Lm(s,i,t,o),panelInfoEditor:r},c=a.configRender;return l(c,{context:u,instance:s,...H.omit(e,["panel","vizManager","data","panelInfoEditor"])})},Vm=(e,t)=>{const n=Ai.default.bezier(e),r=Ai.default.bezier(t);return function(i){return i<50?n(i*2/100).hex():r((i-50)*2/100).hex()}},Ua=e=>{const t=Ai.default.bezier(e);return function(n){return t(n/100).hex()}},J2={type:"interpolation",displayName:"Red / Green",getColor:Vm(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},eL={type:"interpolation",displayName:"Yellow / Blue",getColor:Vm(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},tL={type:"interpolation",displayName:"Red",getColor:Ua(["#fff7f1","darkred"]),name:"red",category:"sequential"},nL={type:"interpolation",displayName:"Green",getColor:Ua(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},rL={type:"interpolation",displayName:"Blue",getColor:Ua(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},iL={type:"interpolation",displayName:"Orange",getColor:Ua(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},zm="@devtable/dashboard",$u="7.10.1",Fm="Apache-2.0",Bm={access:"public",registry:"https://registry.npmjs.org/"},jm=["dist"],Gm="./dist/dashboard.umd.js",Km="./dist/dashboard.es.js",Hm="./dist/index.d.ts",qm={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Wm={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},Um={"@monaco-editor/react":"4.4.6","@types/chroma-js":"^2.1.4","file-saver":"2.0.5","performant-array-to-tree":"1.11.0",popmotion:"^11.0.3","rc-tree-select":"5.5.5",reactflow:"^11.5.3"},Ym={"@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@testing-library/cypress":"^8.0.3","@testing-library/jest-dom":"^5.16.4","@testing-library/react":"^13.3.0","@testing-library/react-hooks":"^8.0.1","@testing-library/user-event":"^14.3.0","@tiptap/extension-code-block-lowlight":"^2.0.0-beta.209","@tiptap/extension-color":"^2.0.0-beta.209","@tiptap/extension-highlight":"^2.0.0-beta.209","@tiptap/extension-link":"^2.0.0-beta.209","@tiptap/extension-placeholder":"^2.0.0-beta.209","@tiptap/extension-subscript":"^2.0.0-beta.209","@tiptap/extension-superscript":"^2.0.0-beta.209","@tiptap/extension-text-align":"^2.0.0-beta.209","@tiptap/extension-text-style":"^2.0.0-beta.209","@tiptap/extension-underline":"^2.0.0-beta.209","@tiptap/react":"^2.0.0-beta.209","@tiptap/starter-kit":"^2.0.0-beta.209","@types/crypto-js":"v4.1.1","@types/d3-array":"3.0.3","@types/eventemitter2":"^4.1.0","@types/file-saver":"2.0.5","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2",ahooks:"^3.3.11",ajv:"8.11.0",axios:"^0.27.2","crypto-js":"^4.1.1",cypress:"^10.6.0","cypress-wait-until":"^1.7.2",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9","echarts-stat":"1.2.0",jsdom:"^20.0.0","jsdom-testing-mocks":"^1.5.0",lodash:"^4.17.21",lowlight:"^2.8.0",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","rollup-plugin-visualizer":"5.6.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3"},Xm={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@tanstack/react-table":"^8.5.13","@tiptap/extension-code-block-lowlight":"^2.0.0-beta.209","@tiptap/extension-color":"^2.0.0-beta.209","@tiptap/extension-highlight":"^2.0.0-beta.209","@tiptap/extension-link":"^2.0.0-beta.209","@tiptap/extension-placeholder":"^2.0.0-beta.209","@tiptap/extension-subscript":"^2.0.0-beta.209","@tiptap/extension-superscript":"^2.0.0-beta.209","@tiptap/extension-text-align":"^2.0.0-beta.209","@tiptap/extension-text-style":"^2.0.0-beta.209","@tiptap/extension-underline":"^2.0.0-beta.209","@tiptap/react":"^2.0.0-beta.209","@tiptap/starter-kit":"^2.0.0-beta.209",ahooks:"^3.3.11",axios:"^0.27.2","chroma-js":"^2.4.2","d3-array":"3.2.0","d3-regression":"1.2.8",dayjs:"1.11.6",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9","echarts-stat":"1.2.0",eventemitter2:"^6.4.6",jszip:"3.10.1",lodash:"^4.17.21",lowlight:"^2.8.0",mobx:"^6.6.1","mobx-react-lite":"^3.4.0","mobx-state-tree":"^5.1.5",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","react-virtual":"^2.10.4","tabler-icons-react":"^1.48.0"},oL=Object.freeze(Object.defineProperty({__proto__:null,name:zm,version:$u,license:Fm,publishConfig:Bm,files:jm,main:Gm,module:Km,types:Hm,exports:qm,scripts:Wm,dependencies:Um,devDependencies:Ym,peerDependencies:Xm,default:{name:zm,version:$u,license:Fm,publishConfig:Bm,files:jm,main:Gm,module:Km,types:Hm,exports:qm,scripts:Wm,dependencies:Um,devDependencies:Ym,peerDependencies:Xm}},Symbol.toStringTag,{value:"Module"}));class aL{constructor(t){ke(this,"staticColors",new Map);ke(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 sL{constructor(){ke(this,"plugins",new Map);ke(this,"vizComponents",new Map);ke(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 lL{constructor(){ke(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,r){var a;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(s=>s.version>t.from&&s.version<=t.to),o=H.orderBy(i,"version","asc");if(((a=H.last(o))==null?void 0:a.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((s,u)=>u.handler(s,r),n)}}class en extends lL{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(r,i)=>({version:t,...n(r,i)}))}async migrate({configData:t,panelModel:n}){const r=await t.getItem(null),i=H.get(r,"version",0),o=this.run({from:i,to:this.VERSION},r,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return H.get(n,"version",0)<this.VERSION}}const Ze=(e,t)=>{const[n,{setFalse:r}]=tt.useBoolean(!0),[i,o]=x.useState();x.useEffect(()=>(e.getItem(t).then(s=>{o(s),r()}),e.watchItem(t,s=>{o(s)})));const a=x.useCallback(async s=>{await e.setItem(t,s),o(s)},[e,t]);return{loading:n,value:i,set:a}},Lu={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"}};Rt.use([lt.GridComponent,lt.VisualMapComponent,lt.LegendComponent,lt.TooltipComponent,jn.CanvasRenderer]);function uL({context:e}){const{value:t}=Ze(e.instanceData,"config"),n=e.data,{width:r,height:i}=e.viewport,{x_axis_data_key:o,y_axis_data_key:a,z_axis_data_key:s,xAxis3D:u,yAxis3D:c,zAxis3D:d}=H.defaults({},t,Lu),p=x.useMemo(()=>{const v=H.minBy(n,m=>m[s]);return H.get(v,s)},[n,s]),h=x.useMemo(()=>{const v=H.maxBy(n,m=>m[s]);return H.get(v,s)},[n,s]),g={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:p,max:h,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:c,zAxis3D:d,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:n.map(v=>[v[o],v[a],v[s]])}]};return t?l(Kn.default,{echarts:Rt,option:g,style:{width:r,height:i}}):null}function cL({label:e,required:t,value:n,onChange:r,data:i,clearable:o=!1,sx:a,...s},u){const c=W.default.useMemo(()=>{if(!Array.isArray(i)||i.length===0)return[];const p=Object.keys(i[0]).map(h=>({label:h,value:h}));return o?p.concat([{label:"unset",value:""}]):p},[i]);return l(f.Select,{ref:u,label:e,data:c,value:n,onChange:r,required:t,sx:a,...s})}const vt=W.default.forwardRef(cL);function dL({context:e}){const{value:t,set:n}=Ze(e.instanceData,"config"),r=e.data,i=H.defaults({},t,Lu),{control:o,handleSubmit:a,reset:s}=G.useForm({defaultValues:i});return x.useEffect(()=>{s(i)},[t]),t?l(f.Stack,{mt:"md",spacing:"xs",children:w("form",{onSubmit:a(n),children:[l(f.Text,{children:"X Axis"}),w(f.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(G.Controller,{name:"x_axis_data_key",control:o,render:({field:u})=>l(vt,{label:"Data Field",required:!0,data:r,...u})}),l(G.Controller,{name:"xAxis3D.name",control:o,render:({field:u})=>l(f.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(f.Text,{mt:"lg",children:"Y Axis"}),w(f.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(G.Controller,{name:"y_axis_data_key",control:o,render:({field:u})=>l(vt,{label:"Data Field",required:!0,data:r,...u})}),l(G.Controller,{name:"yAxis3D.name",control:o,render:({field:u})=>l(f.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(f.Text,{mt:"lg",children:"Z Axis"}),w(f.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(G.Controller,{name:"z_axis_data_key",control:o,render:({field:u})=>l(vt,{label:"Data Field",required:!0,data:r,...u})}),l(G.Controller,{name:"zAxis3D.name",control:o,render:({field:u})=>l(f.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(f.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:w(f.Button,{color:"blue",type:"submit",children:[l(oe.DeviceFloppy,{size:20}),l(f.Text,{ml:"md",children:"Save"})]})})]})}):null}class fL extends en{constructor(){super(...arguments);ke(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const pL={displayName:"Bar Chart (3D)",migrator:new fL,name:"bar-3d",viewRender:uL,configRender:dL,createConfig(){return{version:1,config:H.cloneDeep(Lu)}}},Ln={mantissa:0,output:"number",trimMantissa:!1,average:!1};function hL({value:e,onChange:t},n){const r=s=>{t({...e,output:s})},i=s=>{const u=s===0?!1:e.trimMantissa;t({...e,mantissa:s,trimMantissa:u})},o=s=>{t({...e,trimMantissa:s.currentTarget.checked})},a=s=>{t({...e,average:s.currentTarget.checked})};return w(f.Stack,{ref:n,children:[w(f.Group,{grow:!0,children:[l(f.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:r,sx:{flexGrow:1}}),l(f.Switch,{label:w(f.Stack,{spacing:0,children:[l(f.Text,{children:"Average"}),l(f.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:a,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),w(f.Group,{grow:!0,children:[l(f.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:i}),l(f.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),w(f.Stack,{spacing:0,children:[l(f.Text,{weight:"bold",children:"Preview"}),l(qr,{children:w(f.Group,{position:"apart",children:[w(f.Text,{size:12,color:"gray",children:["123456789 ",l(oe.ArrowRight,{size:9})," ",jt.default(123456789).format(e)]}),w(f.Text,{size:12,color:"gray",children:["1234 ",l(oe.ArrowRight,{size:9})," ",jt.default(1234).format(e)]}),w(f.Text,{size:12,color:"gray",children:["0.1234 ",l(oe.ArrowRight,{size:9})," ",jt.default(.1234).format(e)]})]})})]})]})}const Gr=W.default.forwardRef(hL),Kr={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
139
+ `)},_2=({value:e,onChange:t})=>{const[n,{setTrue:r,setFalse:i}]=tt.useBoolean(),[o,a]=x.useState(e!=null?e:Pu),s=h=>{a({...o,enabled:h})},u=()=>{i();const{enabled:h,func_content:g}=o,v={enabled:h,func_content:g};a(v),t(v)},c=()=>{i(),a(e)},d=h=>{a(g=>({...g,func_content:h}))},p=()=>{d(Pu.func_content)};return w(De,{children:[l(f.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:r,sx:{flexGrow:0},children:l(oe.Settings,{size:14})}),l(f.Modal,{size:800,title:"Customize modal title",opened:n,onClose:i,closeOnClickOutside:!1,withCloseButton:!1,children:n&&w(f.Stack,{children:[l(f.Checkbox,{mt:10,label:"Enabled",checked:o.enabled,onChange:h=>s(h.currentTarget.checked)}),l(C2,{value:o.func_content,onChange:d,disabled:!o.enabled}),w(f.Group,{position:"apart",children:[l(f.Button,{onClick:p,color:"red",leftIcon:l(oe.Recycle,{size:20}),children:"Rest"}),w(f.Group,{position:"right",children:[l(f.Button,{onClick:c,variant:"subtle",children:"Cancel"}),l(f.Button,{onClick:u,children:"OK"})]})]})]})})]})},E2=le.observer(()=>{const t=ot().views.VIE;if(!t||t.type!==wt.Modal)return null;const n=t.config,r=n.custom_modal_title.value;return w(f.Stack,{children:[l(f.Divider,{mt:8,label:"Modal settings",labelPosition:"center"}),w(f.Flex,{gap:10,children:[l(f.TextInput,{label:"Modal Title",value:r,onChange:Se.default.noop,disabled:!0,sx:{flexGrow:1}}),l(_2,{value:n.custom_modal_title,onChange:n.custom_modal_title.replace})]}),w(f.Group,{grow:!0,children:[l(f.TextInput,{label:"Width",value:n.width,onChange:i=>n.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),l(f.TextInput,{label:"Height",value:n.height,onChange:i=>n.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),T2=le.observer(()=>w(De,{children:[l(S2,{}),l(E2,{})]})),M2=[{label:"Division",value:wt.Division},{label:"Modal",value:wt.Modal}],O2=le.observer(()=>{const t=ot().views.VIE;return t?w(f.Stack,{sx:{position:"relative"},children:[l(f.TextInput,{label:"Name",value:t.name,onChange:n=>{t.setName(n.currentTarget.value)}}),l(f.Select,{label:"Type",value:t.type,onChange:t.setType,data:M2}),l(T2,{})]}):null}),D2=le.observer(({opened:e,close:t})=>{var i;const n=ot(),{freezeLayout:r}=W.default.useContext(vn);return W.default.useEffect(()=>{r(e)},[e]),l(f.Modal,{size:"500px",overflow:"inside",opened:e,onClose:t,withCloseButton:!1,styles:{header:{width:"100%"},title:{width:"100%"}},title:w(f.Group,{position:"apart",children:[w(f.Text,{sx:{flexGrow:1},children:["Editing ",(i=n.views.VIE)==null?void 0:i.name]}),l(f.ActionIcon,{size:18,color:"red",onClick:n.views.removeVIE,disabled:n.views.isVIETheFirstView,children:l(oe.Trash,{size:18})})]}),trapFocus:!0,onDragStart:o=>{o.stopPropagation()},children:l(O2,{})})}),R2=x.forwardRef(({label:e,type:t,...n},r)=>t!=="TRIGGER_TO_ADD"?l("div",{ref:r,...n,children:w(f.Group,{noWrap:!0,position:"apart",children:[l(f.Text,{size:"sm",children:e}),l(f.Text,{size:"xs",color:"dimmed",children:t})]})}):l("div",{ref:r,...n,children:l(f.Group,{noWrap:!0,grow:!0,children:l(f.Text,{size:"sm",align:"center",color:"#228be6",children:e})})})),Sm="TRIGGER_TO_ADD",k2=le.observer(({value:e,onChange:t,triggerAdd:n,triggerEdit:r,options:i})=>{const o=x.useMemo(()=>[...i,{label:"Add a View",value:Sm,type:"TRIGGER_TO_ADD"}],[i,n]),a=s=>{s!==Sm?t(s):n()};return w(f.Flex,{gap:0,sx:{minWidth:"400px"},children:[l(f.Select,{value:e,onChange:a,placeholder:"Pick a View",itemComponent:R2,data:o,nothingFound:"Empty",sx:{flexGrow:1},styles:{input:{borderTopRightRadius:0,borderBottomRightRadius:0}}}),l(f.ActionIcon,{onClick:r,variant:"default",size:36,sx:{borderLeft:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,"&:active":{transform:"none",svg:{transform:"translateY(1px)"}}},children:l(oe.Settings,{size:20})})]})}),A2=le.observer(()=>{const e=ot(),[t,n]=x.useState(!1),r=()=>{n(!0)},i=()=>{n(!1)};return w(De,{children:[l(k2,{value:e.views.idOfVIE,onChange:e.views.setIDOfVIE,triggerAdd:e.views.addARandomNewView,triggerEdit:r,options:e.views.options}),l(D2,{opened:t,close:i})]})}),Cm={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}},_m=le.observer(function({saveChanges:t}){const n=ot(),r=W.default.useCallback(()=>{const E=n.queries.json,M=n.views.json,R=n.sqlSnippets.json,L=n.filters.current,F=n.mock_context.current;return{filters:L,views:M,definition:{sqlSnippets:R,queries:E,mock_context:F},version:n.version}},[n]),i=()=>{n.reset()},o=n.changed,{inEditMode:a,inUseMode:s}=W.default.useContext(vn),[u,c]=W.default.useState(!1),d=()=>c(!0),p=()=>c(!1),[h,g]=W.default.useState(!1),v=()=>g(!0),m=()=>g(!1),[b,y]=W.default.useState(!1),_=()=>y(!0),S=()=>y(!1),C=()=>{const E=JSON.stringify(r(),null,2);E$(n.name,E)};return s?null:w(f.Group,{position:"apart",pt:0,px:10,pb:"xs",children:[l(f.Group,{position:"left",children:a&&l(A2,{})}),w(f.Group,{position:"right",sx:{button:{minWidth:"40px"}},children:[l(f.Button,{variant:"filled",size:"xs",disabled:!n.views.VIE,onClick:n.views.addAPanelToVIE,leftIcon:l(oe.PlaylistAdd,{size:20}),children:"Add a Panel"}),w(f.Group,{spacing:0,sx:Cm,children:[l(f.Tooltip,{label:"Filters",children:l(f.ActionIcon,{variant:"default",size:"md",onClick:v,children:l(oe.Filter,{size:20})})}),l(f.Tooltip,{label:"Data Settings",children:l(f.ActionIcon,{variant:"default",size:"md",onClick:d,children:l(oe.Database,{size:20})})}),l(f.Tooltip,{label:"Interactions Viewer",children:l(f.ActionIcon,{variant:"default",size:"md",onClick:_,children:l(oe.Link,{size:20})})})]}),w(f.Group,{spacing:0,sx:Cm,children:[l(f.Tooltip,{label:"Save Changes",children:l(f.ActionIcon,{variant:"default",size:"md",onClick:t,disabled:!o,children:l(oe.DeviceFloppy,{size:20,color:"green"})})}),l(f.Tooltip,{label:"Revert Changes",children:l(f.ActionIcon,{variant:"default",size:"md",disabled:!o,onClick:i,children:l(oe.Recycle,{size:20,color:"red"})})})]}),w(f.Menu,{width:180,trigger:"hover",children:[l(f.Menu.Target,{children:l(f.ActionIcon,{variant:"default",size:"md",children:l(oe.Share,{size:20})})}),w(f.Menu.Dropdown,{children:[l(f.Menu.Item,{icon:l(oe.Download,{size:14}),onClick:n.queries.downloadAllData,children:"Download Data"}),l(f.Menu.Item,{icon:l(oe.Code,{size:14}),onClick:C,children:"Download Schema"})]})]})]}),l(x2,{opened:h,close:m}),l(o2,{opened:u,close:p}),l(C$,{opened:b,close:S})]})}),Lj="",Em=Qt.Mark.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["span",Qt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:e,commands:t})=>{const n=Qt.getMarkAttributes(e,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:t.unsetMark(this.name)}}}}),Tm=Qt.Extension.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;return(t=e.style.color)===null||t===void 0?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),P2=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))$/,N2=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))/g,Mm=Qt.Mark.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",Qt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Qt.markInputRule({find:P2,type:this.type})]},addPasteRules(){return[Qt.markPasteRule({find:N2,type:this.type})]}}),Om=Qt.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new Yb.Plugin({props:{decorations:({doc:e,selection:t})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,i=[];if(!n)return null;const o=e.type.createAndFill(),a=(o==null?void 0:o.sameMarkup(e))&&o.content.findDiffStart(e.content)===null;return e.descendants((s,u)=>{const c=r>=u&&r<=u+s.nodeSize,d=!s.isLeaf&&!s.childCount;if((c||!this.options.showOnlyCurrent)&&d){const p=[this.options.emptyNodeClass];a&&p.push(this.options.emptyEditorClass);const h=Fc.Decoration.node(u,u+s.nodeSize,{class:p.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:u,hasAnchor:c}):this.options.placeholder});i.push(h)}return this.options.includeChildren}),Fc.DecorationSet.create(e,i)}}})]}}),Dm=Qt.Mark.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(e){return e!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sub",Qt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),Rm=Qt.Mark.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(e){return e!=="super"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sup",Qt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),km=Qt.Extension.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:"left"}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>e.style.textAlign||this.options.defaultAlignment,renderHTML:e=>e.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.every(n=>t.updateAttributes(n,{textAlign:e})):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.every(t=>e.resetAttributes(t,"textAlign"))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),Am=Qt.Mark.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",Qt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),Nu={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"}}},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:'"\u25BA"',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"}},Pm=({value:e,styles:t={}})=>{const n=Bc.useEditor({extensions:[Kc.default,Am,et.Link,Rm,Dm,Mm,km.configure({types:["heading","paragraph"]}),Om.configure({placeholder:"This is placeholder"}),Em,Tm],content:e,editable:!1}),r=x.useMemo(()=>Se.default.defaultsDeep({},{content:Nu},t),[t]);return l(et.RichTextEditor,{editor:n,styles:r,children:l(et.RichTextEditor.Content,{})})};function I2(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const Nm=le.observer(()=>{const{freezeLayout:e}=W.default.useContext(vn),[t,n]=W.default.useState(!1),{panel:r}=Gt();return W.default.useEffect(()=>{e(t)},[t]),I2(r.description)?null:w(De,{children:[l(f.Modal,{opened:t,onClose:()=>n(!1),title:r.title,withCloseButton:!1,children:l(Pm,{value:r.description,styles:{root:{border:"none"},content:{padding:0}}})}),l(f.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:l(f.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:l(oe.InfoCircle,{size:20})})})]})}),Im=e=>{const{title:t="Variables",variables:n}=e,r=St.useClipboard(),i=o=>{r.copy(o),ko.showNotification({color:"green",message:"Copied to clipboard"})};return w(f.Paper,{withBorder:!0,p:"sm",children:[l(f.Text,{size:"xs",color:"dimmed",mb:"sm",children:t}),l(f.Stack,{style:{maxHeight:"500px"},children:n.map(o=>w(f.Text,{size:"sm",children:[w(f.Code,{color:"teal",children:["// ",o.description]}),l("br",{}),w(f.Code,{onClick:()=>i(o.name),style:{cursor:"pointer"},children:[o.name," : ",o.valueType]})]},o.name))})]})};class $2{constructor(t,n){ke(this,"operationId");ke(this,"operation");ke(this,"operationSchema");ke(this,"variables",[]);this.operationManager=t,this.instance=n,zt.makeAutoObservable(this)}get schemaList(){return this.operationManager.getOperationSchemaList()}async configOperation(t,n){const r=await this.operationManager.retrieveTrigger(t),i=this.operationManager.getOperationSchemaList().find(o=>o.id===(r==null?void 0:r.schemaRef));zt.runInAction(()=>{this.operationId=t,this.operation=r,this.operationSchema=i,this.variables=n})}async changeSchema(t){this.operationId&&(await this.operationManager.createOrGetOperation(this.operationId,t),await this.configOperation(this.operationId,this.variables))}}function L2(e){return!!e.operationId}const V2=le.observer(({model:e,onClick:t})=>{var r;const n=(r=e.operationSchema)==null?void 0:r.displayName;return l(f.Button,{variant:"outline",onClick:t,children:n})}),z2=le.observer(({model:e})=>{const t={operation:e.operation,instance:e.instance,variables:[]};return x.createElement(e.operationSchema.configRender,t)});function F2({model:e}){const t=e.schemaList,n=t.map(i=>({label:i.displayName,value:i.id}));async function r(i){await e.changeSchema(t.find(o=>o.id===i))}return l(f.Select,{label:"Operation",data:n,onChange:r,value:e.operationSchema.id})}const B2=le.observer(e=>{const[t,{setTrue:n,setFalse:r}]=tt.useBoolean(!1),{operationManager:i,operationId:o,instance:a,variables:s}=e,u=tt.useCreation(()=>new $2(i,a),[i,a]);return tt.useAsyncEffect(async()=>{await u.configOperation(o,s)},[o,u]),L2(u)?w(De,{children:[l(V2,{model:u,onClick:n}),l(f.Modal,{size:600,opened:t,onClose:r,title:"Operation Settings",closeButtonLabel:"close",children:w(f.Stack,{children:[l(F2,{model:u}),l(z2,{model:u}),l(Im,{title:"Variables",variables:u.variables})]})})]}):null});class j2{constructor(t,n){ke(this,"triggerId");ke(this,"trigger");ke(this,"triggerSchema");ke(this,"sampleData");this.triggerManager=t,this.instance=n,zt.makeAutoObservable(this)}get schemaList(){return this.triggerManager.getTriggerSchemaList()}async configTrigger(t,n){const r=await this.triggerManager.retrieveTrigger(t),i=this.triggerManager.getTriggerSchemaList().find(o=>o.id===(r==null?void 0:r.schemaRef));zt.runInAction(()=>{this.triggerId=t,this.trigger=r,this.triggerSchema=i,this.sampleData=n})}async changeSchema(t){this.triggerId&&(await this.triggerManager.createOrGetTrigger(this.triggerId,t),await this.configTrigger(this.triggerId,this.sampleData))}isReady(){return G2(this)}}function G2(e){return!!e.triggerId&&!!e.triggerSchema}function K2(e,t){return tt.useCreation(()=>new j2(e,t),[e,t])}const H2=le.observer(({model:e,onClick:t})=>{const n=e.triggerSchema.nameRender,r={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return l(f.Button,{variant:"outline",onClick:t,children:x.createElement(n,r)})}),q2=le.observer(({model:e})=>{const t=e.schemaList,n=t.map(i=>({label:i.displayName,value:i.id}));async function r(i){await e.changeSchema(t.find(o=>o.id===i))}return l(f.Select,{label:"Trigger",data:n,value:e.triggerSchema.id,onChange:r})}),W2=le.observer(({model:e})=>{const t={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return x.createElement(e.triggerSchema.configRender,t)}),U2=le.observer(e=>{const[t,{setTrue:n,setFalse:r}]=tt.useBoolean(!1),i=e.model;return w(De,{children:[l(f.Modal,{opened:t,onClose:r,title:"Setup Trigger",closeButtonLabel:"close setup",children:w(f.Stack,{children:[l(q2,{model:i}),l(W2,{model:i}),l(Im,{title:"Payload",variables:i.triggerSchema.payload})]})}),l(H2,{onClick:n,model:i})]})});class Ti{constructor(t,n){this.root=t,this.path=n}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const n=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,H.omit(n,t))}async getItem(t){const n=await this.root.getItem(this.path);return t===null?n:H.get(n,t)}async setItem(t,n){if(t===null)await this.root.setItem(this.path,n);else{const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...r,[t]:n})}return await this.getItem(t)}watchItem(t,n,r){return t===null?this.root.watchItem(this.path,(i,o)=>{n(i,o)},r):this.root.watchItem(this.path,(i,o)=>{const a=H.get(i,t),s=H.get(o,t);a!==s&&n(a,s)},r)}}class Iu{constructor(t,n,r){ke(this,"attachmentStorage");this.instance=t,this.attachmentKey=n,this.constructInstance=r,this.attachmentStorage=new Ti(t.instanceData,n)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new Ti(this.attachmentStorage,t))}async create(t,n){return await this.attachmentStorage.setItem(t,n),this.constructInstance(new Ti(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(H.values(t).map(n=>this.constructInstance(new Ti(this.attachmentStorage,n.id))))}}class $m{constructor(t){ke(this,"rootRef");this.rootRef=zt.observable({current:t})}async deleteItem(t){zt.runInAction(()=>{H.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?zt.toJS(this.rootRef.current):H.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(H.isObject(n))zt.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else zt.runInAction(()=>{H.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return zt.reaction(()=>this.getValueFromRoot(t),(i,o)=>{n(i,o)},{requiresObservable:!0,fireImmediately:H.get(r,"fireImmediately",!1)})}}class Y2{constructor(){ke(this,"channels",new Map);ke(this,"globalChannel",new Hc.default)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new Hc.default;return this.channels.set(t,r),r}}class X2{constructor(t){ke(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 Y2,instanceData:new $m(t.viz.conf)};return this.instances.set(t.id,r),r}}function Lm(e,t,n,r){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new $m({}),colorPalette:{getColor(){return()=>""}},data:t,variables:r}}const Q2=e=>{const{panel:t,vizManager:n,data:r,variables:i}=e,o=n.resolveComponent(t.viz.type),a=n.getOrCreateInstance(t),s={...Lm(a,r,n,i),viewport:{width:t.layout.w,height:t.layout.h}},u=o.viewRender;return l(u,{context:s,instance:a,...H.omit(e,["panel","vizManager","data"])})},Z2=e=>{const{vizManager:t,panel:n,panelInfoEditor:r,data:i,variables:o}=e,a=t.resolveComponent(n.viz.type),s=t.getOrCreateInstance(n),u={...Lm(s,i,t,o),panelInfoEditor:r},c=a.configRender;return l(c,{context:u,instance:s,...H.omit(e,["panel","vizManager","data","panelInfoEditor"])})},Vm=(e,t)=>{const n=Ai.default.bezier(e),r=Ai.default.bezier(t);return function(i){return i<50?n(i*2/100).hex():r((i-50)*2/100).hex()}},Ua=e=>{const t=Ai.default.bezier(e);return function(n){return t(n/100).hex()}},J2={type:"interpolation",displayName:"Red / Green",getColor:Vm(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},eL={type:"interpolation",displayName:"Yellow / Blue",getColor:Vm(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},tL={type:"interpolation",displayName:"Red",getColor:Ua(["#fff7f1","darkred"]),name:"red",category:"sequential"},nL={type:"interpolation",displayName:"Green",getColor:Ua(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},rL={type:"interpolation",displayName:"Blue",getColor:Ua(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},iL={type:"interpolation",displayName:"Orange",getColor:Ua(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},zm="@devtable/dashboard",$u="7.11.0",Fm="Apache-2.0",Bm={access:"public",registry:"https://registry.npmjs.org/"},jm=["dist"],Gm="./dist/dashboard.umd.js",Km="./dist/dashboard.es.js",Hm="./dist/index.d.ts",qm={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Wm={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},Um={"@monaco-editor/react":"4.4.6","@types/chroma-js":"^2.1.4","file-saver":"2.0.5","performant-array-to-tree":"1.11.0",popmotion:"^11.0.3","rc-tree-select":"5.5.5",reactflow:"^11.5.3"},Ym={"@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@testing-library/cypress":"^8.0.3","@testing-library/jest-dom":"^5.16.4","@testing-library/react":"^13.3.0","@testing-library/react-hooks":"^8.0.1","@testing-library/user-event":"^14.3.0","@tiptap/extension-code-block-lowlight":"^2.0.0-beta.209","@tiptap/extension-color":"^2.0.0-beta.209","@tiptap/extension-highlight":"^2.0.0-beta.209","@tiptap/extension-link":"^2.0.0-beta.209","@tiptap/extension-placeholder":"^2.0.0-beta.209","@tiptap/extension-subscript":"^2.0.0-beta.209","@tiptap/extension-superscript":"^2.0.0-beta.209","@tiptap/extension-text-align":"^2.0.0-beta.209","@tiptap/extension-text-style":"^2.0.0-beta.209","@tiptap/extension-underline":"^2.0.0-beta.209","@tiptap/react":"^2.0.0-beta.209","@tiptap/starter-kit":"^2.0.0-beta.209","@types/crypto-js":"v4.1.1","@types/d3-array":"3.0.3","@types/eventemitter2":"^4.1.0","@types/file-saver":"2.0.5","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2",ahooks:"^3.3.11",ajv:"8.11.0",axios:"^0.27.2","crypto-js":"^4.1.1",cypress:"^10.6.0","cypress-wait-until":"^1.7.2",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9","echarts-stat":"1.2.0",jsdom:"^20.0.0","jsdom-testing-mocks":"^1.5.0",lodash:"^4.17.21",lowlight:"^2.8.0",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","rollup-plugin-visualizer":"5.6.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3"},Xm={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@tanstack/react-table":"^8.5.13","@tiptap/extension-code-block-lowlight":"^2.0.0-beta.209","@tiptap/extension-color":"^2.0.0-beta.209","@tiptap/extension-highlight":"^2.0.0-beta.209","@tiptap/extension-link":"^2.0.0-beta.209","@tiptap/extension-placeholder":"^2.0.0-beta.209","@tiptap/extension-subscript":"^2.0.0-beta.209","@tiptap/extension-superscript":"^2.0.0-beta.209","@tiptap/extension-text-align":"^2.0.0-beta.209","@tiptap/extension-text-style":"^2.0.0-beta.209","@tiptap/extension-underline":"^2.0.0-beta.209","@tiptap/react":"^2.0.0-beta.209","@tiptap/starter-kit":"^2.0.0-beta.209",ahooks:"^3.3.11",axios:"^0.27.2","chroma-js":"^2.4.2","d3-array":"3.2.0","d3-regression":"1.2.8",dayjs:"1.11.6",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9","echarts-stat":"1.2.0",eventemitter2:"^6.4.6",jszip:"3.10.1",lodash:"^4.17.21",lowlight:"^2.8.0",mobx:"^6.6.1","mobx-react-lite":"^3.4.0","mobx-state-tree":"^5.1.5",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","react-virtual":"^2.10.4","tabler-icons-react":"^1.48.0"},oL=Object.freeze(Object.defineProperty({__proto__:null,name:zm,version:$u,license:Fm,publishConfig:Bm,files:jm,main:Gm,module:Km,types:Hm,exports:qm,scripts:Wm,dependencies:Um,devDependencies:Ym,peerDependencies:Xm,default:{name:zm,version:$u,license:Fm,publishConfig:Bm,files:jm,main:Gm,module:Km,types:Hm,exports:qm,scripts:Wm,dependencies:Um,devDependencies:Ym,peerDependencies:Xm}},Symbol.toStringTag,{value:"Module"}));class aL{constructor(t){ke(this,"staticColors",new Map);ke(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 sL{constructor(){ke(this,"plugins",new Map);ke(this,"vizComponents",new Map);ke(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 lL{constructor(){ke(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,r){var a;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(s=>s.version>t.from&&s.version<=t.to),o=H.orderBy(i,"version","asc");if(((a=H.last(o))==null?void 0:a.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((s,u)=>u.handler(s,r),n)}}class en extends lL{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(r,i)=>({version:t,...n(r,i)}))}async migrate({configData:t,panelModel:n}){const r=await t.getItem(null),i=H.get(r,"version",0),o=this.run({from:i,to:this.VERSION},r,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return H.get(n,"version",0)<this.VERSION}}const Ze=(e,t)=>{const[n,{setFalse:r}]=tt.useBoolean(!0),[i,o]=x.useState();x.useEffect(()=>(e.getItem(t).then(s=>{o(s),r()}),e.watchItem(t,s=>{o(s)})));const a=x.useCallback(async s=>{await e.setItem(t,s),o(s)},[e,t]);return{loading:n,value:i,set:a}},Lu={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"}};Rt.use([lt.GridComponent,lt.VisualMapComponent,lt.LegendComponent,lt.TooltipComponent,jn.CanvasRenderer]);function uL({context:e}){const{value:t}=Ze(e.instanceData,"config"),n=e.data,{width:r,height:i}=e.viewport,{x_axis_data_key:o,y_axis_data_key:a,z_axis_data_key:s,xAxis3D:u,yAxis3D:c,zAxis3D:d}=H.defaults({},t,Lu),p=x.useMemo(()=>{const v=H.minBy(n,m=>m[s]);return H.get(v,s)},[n,s]),h=x.useMemo(()=>{const v=H.maxBy(n,m=>m[s]);return H.get(v,s)},[n,s]),g={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:p,max:h,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:c,zAxis3D:d,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:n.map(v=>[v[o],v[a],v[s]])}]};return t?l(Kn.default,{echarts:Rt,option:g,style:{width:r,height:i}}):null}function cL({label:e,required:t,value:n,onChange:r,data:i,clearable:o=!1,sx:a,...s},u){const c=W.default.useMemo(()=>{if(!Array.isArray(i)||i.length===0)return[];const p=Object.keys(i[0]).map(h=>({label:h,value:h}));return o?p.concat([{label:"unset",value:""}]):p},[i]);return l(f.Select,{ref:u,label:e,data:c,value:n,onChange:r,required:t,sx:a,...s})}const vt=W.default.forwardRef(cL);function dL({context:e}){const{value:t,set:n}=Ze(e.instanceData,"config"),r=e.data,i=H.defaults({},t,Lu),{control:o,handleSubmit:a,reset:s}=G.useForm({defaultValues:i});return x.useEffect(()=>{s(i)},[t]),t?l(f.Stack,{mt:"md",spacing:"xs",children:w("form",{onSubmit:a(n),children:[l(f.Text,{children:"X Axis"}),w(f.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(G.Controller,{name:"x_axis_data_key",control:o,render:({field:u})=>l(vt,{label:"Data Field",required:!0,data:r,...u})}),l(G.Controller,{name:"xAxis3D.name",control:o,render:({field:u})=>l(f.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(f.Text,{mt:"lg",children:"Y Axis"}),w(f.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(G.Controller,{name:"y_axis_data_key",control:o,render:({field:u})=>l(vt,{label:"Data Field",required:!0,data:r,...u})}),l(G.Controller,{name:"yAxis3D.name",control:o,render:({field:u})=>l(f.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(f.Text,{mt:"lg",children:"Z Axis"}),w(f.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(G.Controller,{name:"z_axis_data_key",control:o,render:({field:u})=>l(vt,{label:"Data Field",required:!0,data:r,...u})}),l(G.Controller,{name:"zAxis3D.name",control:o,render:({field:u})=>l(f.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(f.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:w(f.Button,{color:"blue",type:"submit",children:[l(oe.DeviceFloppy,{size:20}),l(f.Text,{ml:"md",children:"Save"})]})})]})}):null}class fL extends en{constructor(){super(...arguments);ke(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const pL={displayName:"Bar Chart (3D)",migrator:new fL,name:"bar-3d",viewRender:uL,configRender:dL,createConfig(){return{version:1,config:H.cloneDeep(Lu)}}},Ln={mantissa:0,output:"number",trimMantissa:!1,average:!1};function hL({value:e,onChange:t},n){const r=s=>{t({...e,output:s})},i=s=>{const u=s===0?!1:e.trimMantissa;t({...e,mantissa:s,trimMantissa:u})},o=s=>{t({...e,trimMantissa:s.currentTarget.checked})},a=s=>{t({...e,average:s.currentTarget.checked})};return w(f.Stack,{ref:n,children:[w(f.Group,{grow:!0,children:[l(f.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:r,sx:{flexGrow:1}}),l(f.Switch,{label:w(f.Stack,{spacing:0,children:[l(f.Text,{children:"Average"}),l(f.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:a,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),w(f.Group,{grow:!0,children:[l(f.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:i}),l(f.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),w(f.Stack,{spacing:0,children:[l(f.Text,{weight:"bold",children:"Preview"}),l(qr,{children:w(f.Group,{position:"apart",children:[w(f.Text,{size:12,color:"gray",children:["123456789 ",l(oe.ArrowRight,{size:9})," ",jt.default(123456789).format(e)]}),w(f.Text,{size:12,color:"gray",children:["1234 ",l(oe.ArrowRight,{size:9})," ",jt.default(1234).format(e)]}),w(f.Text,{size:12,color:"gray",children:["0.1234 ",l(oe.ArrowRight,{size:9})," ",jt.default(.1234).format(e)]})]})})]})]})}const Gr=W.default.forwardRef(hL),Kr={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
140
140
  `)},Sr={x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}},Qm={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:vL,configRender:gL,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 gL(e){return l(De,{})}function vL(e){return l(f.Text,{children:"Click chart's series"})}const Vu={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,formatter:{...Kr},overflow:Sr}},y_axis:{name:"Y Axis",data_key:"value",label_formatter:Ln},color:"#228be6",reference_lines:[]},Mi=(e,t)=>{const[n,r]=x.useState([]);return x.useEffect(()=>e.watchTriggerSnapshotList(i=>r(i.filter(o=>o.schemaRef===t))),[]),n},Oi=({vizManager:e,instance:t})=>tt.useCreation(()=>new Ac(t,e.resolveComponent(t.type),us),[t,e]),Zm="__TRIGGERS";class mL{constructor(t,n){ke(this,"attachments");this.instance=t,this.component=n;const r=async i=>{const{id:o,schemaRef:a}=await i.getItem(null);return{id:o,schemaRef:a,triggerData:new Ti(i,"data")}};this.attachments=new Iu(t,Zm,r)}watchTriggerSnapshotList(t){return this.instance.instanceData.watchItem(Zm,n=>{const r=H.values(n).map(i=>({id:H.get(i,"id"),schemaRef:H.get(i,"schemaRef"),config:zt.toJS(H.get(i,"data.config"))}));t(r)},{fireImmediately:!0})}async createOrGetTrigger(t,n,r={recreate:!1}){var s;if(!this.getTriggerSchemaList().some(u=>u.id===n.id))throw new Error(`Trigger schema '${n.id}' is not defined in component '${this.component.name}'`);const o=await this.attachments.getInstance(t);return!o||r.recreate||o.schemaRef!==n.id?await this.attachments.create(t,{id:t,schemaRef:n.id,data:((s=n==null?void 0:n.createDefaultConfig)==null?void 0:s.call(n))||{}}):o}async getTriggerList(){return await this.attachments.list()}getTriggerSchemaList(){return this.component.triggers||[]}async removeTrigger(t){await this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}async getMigrationTasks(){const n=(await this.getTriggerList()).map(async r=>{const i=this.getTriggerSchemaList().find(s=>s.id===r.schemaRef),o=i==null?void 0:i.migrator,a={configData:r.triggerData};return o&&await o.needMigration(a)?()=>o.migrate(a):null});return Promise.all(n).then(r=>r.filter(i=>i))}async needMigration(){return(await this.getMigrationTasks()).length>0}async runMigration(){const t=await this.getMigrationTasks();await Promise.all(t.map(n=>n()))}}const bo=x.forwardRef(function({value:t,onChange:n,...r},i){return l(f.TextInput,{ref:i,value:t,onChange:n,...r})}),yL=[{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:"Quantile(99%, 95%, ...)",value:"quantile"}];function bL({label:e,value:t,onChange:n},r){x.useEffect(()=>{typeof t=="string"&&(console.log(t),n({type:t,config:{}}))},[t,n]);const i=a=>{n(a==="quantile"?{type:"quantile",config:{p:.99}}:{type:a,config:{}})},o=a=>{n({type:"quantile",config:{p:a}})};return w(f.Group,{grow:!0,noWrap:!0,pt:"sm",children:[l(f.Select,{ref:r,label:e,data:yL,value:t.type,onChange:i}),t.type==="quantile"&&l(f.NumberInput,{label:"p",value:t.config.p,onChange:o,precision:2,min:.05,step:.05,max:1})]})}const Jm=W.default.forwardRef(bL);function wL({label:e,value:t,onChange:n},r){const[i,o]=W.default.useState(Array.isArray(t)?[...t]:[]),a=W.default.useCallback(()=>{o(h=>[...h,""])},[o]),s=W.default.useCallback(h=>{o(g=>(g.splice(h,1),[...g]))},[o]),u=W.default.useMemo(()=>!Se.default.isEqual(i,t),[i,t]),c=()=>{n(i.map(h=>h.toString()))},d=f.useMantineTheme(),p=W.default.useMemo(()=>Object.entries(d.colors).map(([h,g])=>g[6]),[d]);return w(De,{children:[w(f.Group,{position:"left",ref:r,children:[l(f.Text,{children:e}),l(f.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!u,onClick:c,children:l(oe.DeviceFloppy,{size:20})})]}),w(f.Group,{children:[i.map((h,g)=>l(f.ColorInput,{value:h,onChange:v=>{o(m=>(m.splice(g,1,v),[...m]))},swatches:p,rightSection:l(f.ActionIcon,{onClick:()=>s(g),color:"red",children:l(oe.Trash,{size:14})}),sx:{width:"45%"}})),l(f.ActionIcon,{onClick:a,color:"blue",variant:"outline",children:l(oe.PlaylistAdd,{size:20})})]})]})}const xL=W.default.forwardRef(wL);function SL({value:e,onChange:t},n){const{colorManager:r}=x.useContext(Fn),i=W.default.useMemo(()=>r.getStaticColors().map(s=>({label:s.name,group:s.category,value:s.value})),[r]),o=W.default.useMemo(()=>i.some(a=>a.value===e),[e,i]);return w(f.Group,{position:"apart",spacing:4,ref:n,children:[l(f.TextInput,{placeholder:"Set any color",value:o?"":e,onChange:a=>t(a.currentTarget.value),rightSection:l(f.ColorSwatch,{color:o?"transparent":e,radius:4}),variant:o?"filled":"default",sx:{maxWidth:"46%",flexGrow:1}}),l(f.Text,{sx:{flexGrow:0},children:"or"}),l(f.Select,{data:i,value:e,onChange:t,variant:o?"default":"filled",placeholder:"Pick a theme color",icon:l(f.ColorSwatch,{color:o?e:"transparent",radius:4}),sx:{maxWidth:"46%",flexGrow:1}})]})}const Vn=W.default.forwardRef(SL),Ya=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function CL({label:e,value:t,onChange:n},r){var a,s;const[i,o]=W.default.useState((s=(a=Ya.find(u=>u.label===t))==null?void 0:a.value)!=null?s:Ya[0].value);return W.default.useEffect(()=>{const u=Ya.find(c=>c.value===i);u&&n(u.label)},[i]),w(f.Stack,{spacing:0,mt:"sm",mb:"lg",children:[l(f.Text,{size:"sm",children:e}),l(f.Slider,{label:null,marks:Ya,value:i,onChange:o,step:25,placeholder:"Pick a font size",px:"1em",ref:r})]})}const ey=W.default.forwardRef(CL);function _L({label:e,value:t,onChange:n,type:r},i){const[o,a]=W.default.useState(Array.isArray(t)?[...t]:[]),s=W.default.useCallback(()=>{a(p=>[...p,""])},[a]),u=W.default.useCallback(p=>{a(h=>(h.splice(p,1),[...h]))},[a]),c=W.default.useMemo(()=>!Se.default.isEqual(o.map(String),t.map(String)),[o,t]),d=()=>{n(o.map(p=>r==="number"?Number(p):p.toString()))};return w(De,{children:[w(f.Group,{position:"left",ref:i,children:[l(f.Text,{children:e}),l(f.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!c,onClick:d,children:l(oe.DeviceFloppy,{size:20})})]}),w(f.Group,{children:[o.map((p,h)=>l(f.TextInput,{type:r,value:p,onChange:g=>{const v=g.currentTarget.value;a(m=>(m.splice(h,1,v),[...m]))},rightSection:l(f.ActionIcon,{onClick:()=>u(h),color:"red",children:l(oe.Trash,{size:14})}),sx:{width:"45%"}})),l(f.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:l(oe.PlaylistAdd,{size:20})})]})]})}const EL=W.default.forwardRef(_L),ty=W.default.forwardRef(function({value:t,onChange:n},r){const i=t.color.type,o=(a,s)=>{const u=Se.default.cloneDeep(t);Se.default.set(u,a,s),n(u)};return w(De,{children:[l(f.Divider,{my:"xs",label:"Typography",labelPosition:"center"}),l(f.Stack,{children:l(f.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},value:t.size,onChange:a=>o("size",a.currentTarget.value)})}),l(f.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:l(ey,{label:"Font Weight",value:t.weight,onChange:a=>o("weight",a)})}),l(f.Divider,{my:"xs",label:"Style",labelPosition:"center"}),w(f.Stack,{children:[l(f.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:t.color.type,onChange:a=>o("color.type",a)}),i==="static"&&l(Vn,{value:t.color.staticColor,onChange:a=>o("color.staticColor",a)}),i==="continuous"&&w(De,{children:[l(EL,{label:"Value Range",value:t.color.valueRange,type:"number",onChange:a=>o("color.valueRange",a)}),l(xL,{label:"Color Range",value:t.color.colorRange,onChange:a=>o("color.colorRange",a)})]})]})]})});W.default.forwardRef(function({value:t,onChange:n,data:r,withStyle:i=!0},o){const a=(s,u)=>{const c=Se.default.cloneDeep(t);Se.default.set(c,s,u),n(c)};return w(f.Box,{px:"sm",py:"md",ref:o,children:[l(f.Text,{weight:"bold",pb:0,children:t.name}),l(f.Divider,{my:"xs",label:"Data",labelPosition:"center"}),w(f.Group,{grow:!0,noWrap:!0,children:[l(f.TextInput,{label:"Name",required:!0,value:t.name,onChange:s=>a("name",s.currentTarget.value)}),l(vt,{label:"Data Field",required:!0,data:r,value:t.data_field,onChange:s=>a("data_field",s)})]}),l(Jm,{label:"Aggregation",value:t.aggregation,onChange:s=>a("aggregation",s)}),l(f.Divider,{my:"xs",label:"Format",labelPosition:"center"}),l(Gr,{value:t.formatter,onChange:s=>a("formatter",s)}),i&&l(ty,{value:t,onChange:n})]})});function TL(e){const t=Array.from(e).sort((r,i)=>r-i),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]}function ML(e,t){const n=e[t],r=Number(n);return isFinite(r)?r:0}function zu(e,t,n){var i,o,a,s;const r=e.map(u=>ML(u,t));switch(n.type){case"sum":return Se.default.sum(r);case"mean":return Se.default.mean(r);case"median":return TL(r);case"max":return(i=Se.default.max(r))!=null?i:0;case"min":return(o=Se.default.min(r))!=null?o:0;case"quantile":return(a=Ao.quantile(r,n.config.p))!=null?a:0;default:return(s=e[0])==null?void 0:s[t]}}var ny=function(){},wo=function(){};process.env.NODE_ENV!=="production"&&(ny=function(e,t){!e&&typeof console<"u"&&console.warn(t)},wo=function(e,t){if(!e)throw new Error(t)});const OL=(e,t,n)=>Math.min(Math.max(n,e),t),ry=(e,t,n)=>{const r=t-e;return r===0?1:(n-e)/r},Fu=(e,t,n)=>-n*e+n*t+e,iy=(e,t)=>n=>Math.max(Math.min(n,t),e),xo=e=>e%1?Number(e.toFixed(5)):e,Xa=/(-)?([\d]*\.?[\d])+/g,Bu=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,DL=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function So(e){return typeof e=="string"}const Qa={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},oy=Object.assign(Object.assign({},Qa),{transform:iy(0,1)});Object.assign(Object.assign({},Qa),{default:1});const Co=(e=>({test:t=>So(t)&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}))("%");Object.assign(Object.assign({},Co),{parse:e=>Co.parse(e)/100,transform:e=>Co.transform(e*100)});const ju=(e,t)=>n=>Boolean(So(n)&&DL.test(n)&&n.startsWith(e)||t&&Object.prototype.hasOwnProperty.call(n,t)),ay=(e,t,n)=>r=>{if(!So(r))return r;const[i,o,a,s]=r.match(Xa);return{[e]:parseFloat(i),[t]:parseFloat(o),[n]:parseFloat(a),alpha:s!==void 0?parseFloat(s):1}},Hr={test:ju("hsl","hue"),parse:ay("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+Co.transform(xo(t))+", "+Co.transform(xo(n))+", "+xo(oy.transform(r))+")"},RL=iy(0,255),Gu=Object.assign(Object.assign({},Qa),{transform:e=>Math.round(RL(e))}),Cr={test:ju("rgb","red"),parse:ay("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+Gu.transform(e)+", "+Gu.transform(t)+", "+Gu.transform(n)+", "+xo(oy.transform(r))+")"};function kL(e){let t="",n="",r="",i="";return e.length>5?(t=e.substr(1,2),n=e.substr(3,2),r=e.substr(5,2),i=e.substr(7,2)):(t=e.substr(1,1),n=e.substr(2,1),r=e.substr(3,1),i=e.substr(4,1),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const Ku={test:ju("#"),parse:kL,transform:Cr.transform},Za={test:e=>Cr.test(e)||Ku.test(e)||Hr.test(e),parse:e=>Cr.test(e)?Cr.parse(e):Hr.test(e)?Hr.parse(e):Ku.parse(e),transform:e=>So(e)?e:e.hasOwnProperty("red")?Cr.transform(e):Hr.transform(e)},sy="${c}",ly="${n}";function AL(e){var t,n,r,i;return isNaN(e)&&So(e)&&((n=(t=e.match(Xa))===null||t===void 0?void 0:t.length)!==null&&n!==void 0?n:0)+((i=(r=e.match(Bu))===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0)>0}function uy(e){typeof e=="number"&&(e=`${e}`);const t=[];let n=0;const r=e.match(Bu);r&&(n=r.length,e=e.replace(Bu,sy),t.push(...r.map(Za.parse)));const i=e.match(Xa);return i&&(e=e.replace(Xa,ly),t.push(...i.map(Qa.parse))),{values:t,numColors:n,tokenised:e}}function cy(e){return uy(e).values}function dy(e){const{values:t,numColors:n,tokenised:r}=uy(e),i=t.length;return o=>{let a=r;for(let s=0;s<i;s++)a=a.replace(s<n?sy:ly,s<n?Za.transform(o[s]):xo(o[s]));return a}}const PL=e=>typeof e=="number"?0:e;function NL(e){const t=cy(e);return dy(e)(t.map(PL))}const fy={test:AL,parse:cy,createTransformer:dy,getAnimatableNone:NL};function Hu(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function py({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,o=0,a=0;if(!t)i=o=a=n;else{const s=n<.5?n*(1+t):n+t-n*t,u=2*n-s;i=Hu(u,s,e+1/3),o=Hu(u,s,e),a=Hu(u,s,e-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(a*255),alpha:r}}const IL=(e,t,n)=>{const r=e*e,i=t*t;return Math.sqrt(Math.max(0,n*(i-r)+r))},$L=[Ku,Cr,Hr],hy=e=>$L.find(t=>t.test(e)),gy=e=>`'${e}' is not an animatable color. Use the equivalent color code instead.`,vy=(e,t)=>{let n=hy(e),r=hy(t);wo(!!n,gy(e)),wo(!!r,gy(t));let i=n.parse(e),o=r.parse(t);n===Hr&&(i=py(i),n=Cr),r===Hr&&(o=py(o),r=Cr);const a=Object.assign({},i);return s=>{for(const u in a)u!=="alpha"&&(a[u]=IL(i[u],o[u],s));return a.alpha=Fu(i.alpha,o.alpha,s),n.transform(a)}},LL=e=>typeof e=="number",VL=(e,t)=>n=>t(e(n)),my=(...e)=>e.reduce(VL);function yy(e,t){return LL(e)?n=>Fu(e,t,n):Za.test(e)?vy(e,t):xy(e,t)}const by=(e,t)=>{const n=[...e],r=n.length,i=e.map((o,a)=>yy(o,t[a]));return o=>{for(let a=0;a<r;a++)n[a]=i[a](o);return n}},zL=(e,t)=>{const n=Object.assign(Object.assign({},e),t),r={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=yy(e[i],t[i]));return i=>{for(const o in r)n[o]=r[o](i);return n}};function wy(e){const t=fy.parse(e),n=t.length;let r=0,i=0,o=0;for(let a=0;a<n;a++)r||typeof t[a]=="number"?r++:t[a].hue!==void 0?o++:i++;return{parsed:t,numNumbers:r,numRGB:i,numHSL:o}}const xy=(e,t)=>{const n=fy.createTransformer(t),r=wy(e),i=wy(t);return r.numHSL===i.numHSL&&r.numRGB===i.numRGB&&r.numNumbers>=i.numNumbers?my(by(r.parsed,i.parsed),n):(ny(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),a=>`${a>0?t:e}`)},FL=(e,t)=>n=>Fu(e,t,n);function BL(e){if(typeof e=="number")return FL;if(typeof e=="string")return Za.test(e)?vy:xy;if(Array.isArray(e))return by;if(typeof e=="object")return zL}function jL(e,t,n){const r=[],i=n||BL(e[0]),o=e.length-1;for(let a=0;a<o;a++){let s=i(e[a],e[a+1]);if(t){const u=Array.isArray(t)?t[a]:t;s=my(u,s)}r.push(s)}return r}function GL([e,t],[n]){return r=>n(ry(e,t,r))}function KL(e,t){const n=e.length,r=n-1;return i=>{let o=0,a=!1;if(i<=e[0]?a=!0:i>=e[r]&&(o=r-1,a=!0),!a){let u=1;for(;u<n&&!(e[u]>i||u===r);u++);o=u-1}const s=ry(e[o],e[o+1],i);return t[o](s)}}function qu(e,t,{clamp:n=!0,ease:r,mixer:i}={}){const o=e.length;wo(o===t.length,"Both input and output ranges must be the same length"),wo(!r||!Array.isArray(r)||r.length===o-1,"Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values."),e[0]>e[o-1]&&(e=[].concat(e),t=[].concat(t),e.reverse(),t.reverse());const a=jL(t,r,i),s=o===2?GL(e,a):KL(e,a);return n?u=>s(OL(e[0],e[o-1],u)):s}class HL{constructor({valueRange:t,colorRange:n}){ke(this,"mapper");this.mapper=qu(t,n)}getColor(t){return this.mapper(t)}}function qL(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Wu({data_field:e,aggregation:t},n){return zu(n,e,t)}function _o({formatter:e},t){return["string","number"].includes(typeof t)?jt.default(t).format(e):qL(t)}function WL(e,t){if(e.type==="static")return e.staticColor;if(e.type==="continuous")try{return new HL(e).getColor(t)}catch{return"black"}return"black"}function Sy(e,t){const{color:n,data_field:r,aggregation:i,size:o,weight:a}=e,s=zu(t,r,i),u=_o(e,s);return l(f.Text,{sx:{fontSize:o,display:"inline"},color:WL(n,s),weight:a,children:u})}function UL(e,t){const n={};return e.forEach(r=>{const i=r.name;n[i]=Sy(r,t)}),n}function YL(e){return e.split(" ").map((t,n)=>w(W.default.Fragment,{children:[t,"\xA0"]},n))}function XL(e){const n=e.replaceAll("<br />","<br/>").replaceAll(`
141
141
  `,"<br/>").split("<br/>");return n.map((i,o)=>{const a=[YL(i)];return o!==n.length-1&&a.push(l("br",{})),a}).flat().filter(i=>i!==void 0)}function Uu(e){return XL(e)}function Eo(e,t,n){const r=UL(t,n),i=/^\{(.+)\}(.*)$/;return e.split("$").map(o=>{var c;const a=i.exec(o);if(!a)return Uu(o);const s=r[a[1]];if(!s)return Uu(o);const u=(c=a[2])!=null?c:"";return w(De,{children:[s,Uu(u)]})})}function QL(e,t){const n={};return e.forEach(r=>{const{name:i,data_field:o,aggregation:a}=r,s=zu(t,o,a);n[i]=_o(r,s)}),n}function Yu(e,t,n){const r=QL(t,n),i=/^\{(.+)\}(.*)$/;return e.split("$").map(o=>{var c;const a=i.exec(o);if(!a)return o;const s=r[a[1]];if(!s)return o;const u=(c=a[2])!=null?c:"";return`${s}${u}`}).join("")}function Ja({enabled:e,func_content:t}){return(n,r)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,r)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function es(e){return{width:e.width,overflow:e.overflow,ellipsis:e.ellipsis}}function To(e){const t={truncate:"initial",break:"break-all",breakAll:"break-word"}[e.overflow],n=e.overflow==="truncate"?"nowrap":"initial",r={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e.overflow];return`
142
142
  max-width: ${e.width}px;
@@ -289,4 +289,4 @@ WHERE
289
289
  </table>
290
290
  `}}}function GB(e,t){var i;const n=t.every(o=>!Number.isNaN(Number(o))),{axisLabel:r}=e.x_axis;return[{data:t,name:(i=e.x_axis.name)!=null?i:"",id:"main-x-axis",axisTick:{show:!0,alignWithLabel:!0},type:n?"value":"category",axisLabel:{...r,formatter:nb(r.formatter)}}]}function KB(e,t){return e.y_axes.map(({nameAlignment:n,min:r,max:i,...o},a)=>{var u;let s=o.position;return s||(s=a>0?"right":"left"),{...o,min:r||void 0,max:i||void 0,position:s,axisLabel:{show:!0,formatter:(u=t[a])!=null?u:t.default},axisLine:{show:!0},nameTextStyle:{fontWeight:"bold",align:n},nameLocation:"end",nameGap:15,splitLine:{show:!1}}})}function HB(){return{show:!1,bottom:0,left:"center",type:"scroll"}}const qB={tooltip:{trigger:"axis"},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 WB(e,t,n){const r=n.reduce((c,d)=>{const p=Wu(d,t);return c[d.name]=_o(d,p),c},{}),i=e.y_axes.reduce((c,{label_formatter:d},p)=>(c[p]=function(g){let v=g;if(typeof g=="object"&&(Array.isArray(g.value)&&g.value.length===2?v=g.value[1]:v=g.value),!d)return v;try{return jt.default(v).format(d)}catch(m){return console.error(m),v}},c),{default:({value:c})=>c}),o=Se.default.uniq(t.map(c=>c[e.x_axis.data_key])),a=o.every(c=>!Number.isNaN(Number(c))),s=zB(e,o,a,t,i,n,r),u={xAxis:GB(e,o),yAxis:KB(e,i),series:s,dataset:[{source:t}],tooltip:jB(e,i),grid:NB(e),legend:HB(),dataZoom:ec(e.dataZoom)};return H.defaultsDeep({},u,qB)}Rt.use([lt.DataZoomComponent,dn.BarChart,dn.LineChart,dn.ScatterChart,lt.GridComponent,lt.LegendComponent,lt.TooltipComponent,jn.CanvasRenderer,lt.MarkLineComponent,lt.MarkAreaComponent]),Rt.registerTransform(hs.transform.regression);function rb(e){return e.trim().length>0}function UB({conf:e,data:t,width:n,height:r,interactionManager:i,variables:o}){const a=x.useMemo(()=>Se.default.keyBy(t,e.x_axis.data_key),[t,e.x_axis.data_key]),s=Mi(i.triggerManager,Jy.id),u=x.useCallback(p=>{const h=p.value[0],g=Se.default.get(a,h,{error:"rowData is not found"});s.forEach(v=>{i.runInteraction(v.id,{...p,rowData:g})})},[a,s,i]),c=x.useMemo(()=>({click:u}),[u]),d=W.default.useMemo(()=>WB(e,t,o),[e,t]);return!n||!r?null:l(Kn.default,{echarts:Rt,option:d,style:{width:n,height:r},onEvents:c})}function YB({context:e,instance:t}){const n=Oi({vizManager:e.vizManager,instance:t}),{value:r}=Ze(e.instanceData,"config"),{variables:i}=e,o=x.useMemo(()=>H.defaults({},r,Dc),[r]),a=e.data,{width:s,height:u}=e.viewport,{ref:c,width:d,height:p}=St.useElementSize(),{ref:h,width:g,height:v}=St.useElementSize(),m=W.default.useMemo(()=>{const{stats:{templates:y}}=o;return{top:Eo(y.top,i,a),bottom:Eo(y.bottom,i,a)}},[o,a]),b=x.useMemo(()=>{let y=u;return d&&(y-=p),g&&(y-=v),Math.max(0,y)},[u,d,p,g,v]);return w(f.Box,{children:[rb(o.stats.templates.top)&&l(f.Text,{ref:c,align:"left",size:"xs",pl:"sm",children:Object.values(m.top).map(y=>y)}),l(UB,{variables:i,width:s,height:b,data:a,conf:o,interactionManager:n}),rb(o.stats.templates.bottom)&&l(f.Text,{ref:h,align:"left",size:"xs",pl:"sm",children:Object.values(m.bottom).map(y=>y)})]})}const XB=[{label:"Horizontal",value:"horizontal"},{label:"Vertical",value:"vertical"}];function QB({control:e,index:t,remove:n,watch:r,variableOptions:i}){const o=r(`reference_lines.${t}.orientation`);return w(f.Stack,{my:0,p:0,sx:{position:"relative"},children:[w(f.Group,{grow:!0,noWrap:!0,children:[l(G.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:a})=>l(f.TextInput,{label:"Name",placeholder:"Average Reference Line",required:!0,sx:{flex:1},...a})}),l(G.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:a})=>l(f.Select,{label:"Value",required:!0,data:i,sx:{flex:1},...a})})]}),l(G.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:a})=>l(f.TextInput,{label:"Content Template",placeholder:"Average: ${avg}",required:!0,sx:{flex:1},...a})}),l(G.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:a})=>l(f.Select,{label:"Orientation",data:XB,required:!0,sx:{flex:1},...a})}),o==="vertical"&&l(f.Text,{mt:-10,color:"dimmed",size:12,children:"Works only when xAxis values are numbers"}),l(f.Button,{leftIcon:l(oe.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),sx:{top:15,right:5},children:"Delete this Reference Line"})]},t)}function ZB({control:e,watch:t,variables:n}){const{fields:r,append:i,remove:o}=G.useFieldArray({control:e,name:"reference_lines"}),a=t("reference_lines"),s=r.map((d,p)=>({...d,...a[p]})),u=()=>i({name:"",template:"",variable_key:"",orientation:"horizontal"}),c=x.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]);return w(f.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px"}},children:[w(f.Tabs.List,{children:[s.map((d,p)=>l(f.Tabs.Tab,{value:p.toString(),children:p+1},p)),l(f.Tabs.Tab,{onClick:u,value:"add",children:l(f.ActionIcon,{children:l(oe.Plus,{size:18,color:"#228be6"})})})]}),s.map((d,p)=>l(f.Tabs.Panel,{value:p.toString(),children:l(QB,{control:e,index:p,remove:o,watch:t,variableOptions:c})},p))]})}const JB=x.forwardRef(({value:e,onChange:t},n)=>{const r=o=>{t({...e,label:o})},i=o=>{t({...e,tooltip:o})};return w(f.Stack,{ref:n,spacing:0,children:[l(ts,{sectionTitle:"Overflow on Chart",value:e.label,onChange:r}),l(ts,{sectionTitle:"Overflow in Tooltip",value:e.tooltip,onChange:i})]})}),e5=({value:e,onChange:t})=>{const n=r=>{!r||t(r)};return l(f.Box,{children:l(Gn.default,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},ib={static:{type:"static",size:10},dynamic:{type:"dynamic",func_content:["function getSize({ rowData, params, variables }, { lodash, interpolate }) {"," // your code goes here"," // return 10","}"].join(`
291
291
  `)}},t5=({value:e,onChange:t,data:n})=>{const[r,{setTrue:i,setFalse:o}]=tt.useBoolean(),[a,s]=x.useState(e),u=()=>{o();const{type:h,func_content:g}=a,v={type:h,func_content:g};s(v),t(v)},c=()=>{o(),s(e)},d=h=>{s(g=>({...g,func_content:h}))},p=()=>{d(ib.dynamic.func_content)};return w(De,{children:[l(f.Box,{sx:{width:"50%"},children:l(f.Button,{variant:"filled",mt:24,onClick:i,sx:{flexGrow:0},children:"Setup"})}),l(f.Modal,{size:800,title:"Setup dynamic size",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,children:r&&w(f.Stack,{children:[l(f.Divider,{mt:10,mb:-10,label:"Dynamic by a custom function",labelPosition:"center",variant:"dashed"}),l(e5,{value:a.func_content,onChange:d}),w(f.Group,{position:"apart",children:[l(f.Button,{onClick:p,color:"red",leftIcon:l(oe.Recycle,{size:20}),children:"Rest"}),w(f.Group,{position:"right",children:[l(f.Button,{onClick:c,variant:"subtle",children:"Cancel"}),l(f.Button,{onClick:u,children:"OK"})]})]})]})})]})},n5=({value:e,onChange:t,data:n})=>e.type!=="dynamic"?null:l(t5,{value:e,onChange:t,data:n}),r5=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=r=>{t({...e,size:r})};return l(De,{children:l(f.NumberInput,{defaultValue:18,placeholder:"1 ~ 100",label:" ",hideControls:!0,value:e.size,onChange:n})})},i5=[{label:"Static",value:"static"},{label:"Dynamic",value:"dynamic"}],o5=x.forwardRef(({label:e="Size",value:t,onChange:n,data:r},i)=>{const o=a=>{n({...ib[a]})};return w(f.SimpleGrid,{cols:2,children:[l(f.Select,{ref:i,label:e,data:i5,value:t.type,onChange:o,sx:{flexGrow:1}}),l(r5,{value:t,onChange:n}),l(n5,{value:t,onChange:n,data:r})]})}),a5=[{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 s5({data:e,control:t,watch:n}){return n(["scatter"]),w(f.Stack,{children:[w(f.Group,{grow:!0,noWrap:!0,children:[l(G.Controller,{name:"scatter.name_data_key",control:t,render:({field:r})=>l(vt,{label:"Name Data Field",required:!0,data:e,sx:{flex:1},...r})}),l(G.Controller,{name:"scatter.y_data_key",control:t,render:({field:r})=>l(vt,{label:"Value Data Field",required:!0,data:e,sx:{flex:1},...r})})]}),l(f.Divider,{mb:-15,label:"Style",labelPosition:"center"}),l(G.Controller,{name:"scatter.symbolSize",control:t,render:({field:r})=>l(o5,{label:"Size",data:e,...r})}),w(f.Stack,{spacing:4,children:[l(f.Text,{size:"sm",children:"Color"}),l(G.Controller,{name:"scatter.color",control:t,render:({field:r})=>l(Vn,{...r})})]}),l(f.Divider,{mb:-15,label:"Label",labelPosition:"center"}),l(f.Group,{grow:!0,noWrap:!0,children:l(G.Controller,{name:"scatter.label_position",control:t,render:({field:r})=>l(f.Select,{label:"Label Position",data:a5,...r})})}),l(G.Controller,{name:"scatter.label_overflow",control:t,render:({field:r})=>l(JB,{...r})})]})}function l5({control:e,watch:t}){return t("stats"),l(f.Stack,{children:w(f.Stack,{spacing:0,children:[l(G.Controller,{name:"stats.templates.top",control:e,render:({field:n})=>l(bo,{label:"Template for stats above the chart",py:"md",sx:{flexGrow:1},...n})}),l(G.Controller,{name:"stats.templates.bottom",control:e,render:({field:n})=>l(bo,{label:"Template for stats under the chart",py:"md",sx:{flexGrow:1},...n})})]})})}const u5=({control:e,data:t,index:n,remove:r})=>w(f.Stack,{children:[w(f.Group,{grow:!0,noWrap:!0,children:[l(G.Controller,{name:`tooltip.metrics.${n}.name`,control:e,render:({field:i})=>l(f.TextInput,{label:"Name",required:!0,sx:{flex:1},...i})}),l(G.Controller,{name:`tooltip.metrics.${n}.data_key`,control:e,render:({field:i})=>l(vt,{label:"Value Field",required:!0,data:t,sx:{flex:1},...i})})]}),l(f.Divider,{mb:-10,mt:10,variant:"dashed"}),l(f.Button,{leftIcon:l(oe.Trash,{size:16}),color:"red",variant:"light",onClick:()=>r(n),sx:{top:15,right:5},children:"Delete this Metric"})]}),c5=({control:e,watch:t,data:n})=>{const{fields:r,append:i,remove:o}=G.useFieldArray({control:e,name:"tooltip.metrics"}),a=t("tooltip.metrics"),s=r.map((h,g)=>({...h,...a[g]})),u=()=>i({id:Date.now().toString(),data_key:"",name:""}),c=t("tooltip.metrics.0.id"),[d,p]=x.useState(()=>c!=null?c:null);return x.useEffect(()=>{c&&p(h=>h!==null?h:c)},[c]),w(De,{children:[w(f.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[l(oe.InfoCircle,{size:14,color:"#888"}),l(f.Text,{size:14,color:"#888",children:"Condigure additional metrics to show in tooltip"})]}),l(f.Divider,{variant:"dashed",my:10}),w(f.Tabs,{value:d,onTabChange:h=>p(h),styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[w(f.Tabs.List,{children:[s.map((h,g)=>l(f.Tabs.Tab,{value:h.id,children:h.name?h.name:g},h.id)),l(f.Tabs.Tab,{onClick:u,value:"add",children:l(f.ActionIcon,{children:l(oe.Plus,{size:18,color:"#228be6"})})})]}),s.map((h,g)=>l(f.Tabs.Panel,{value:h.id,children:l(u5,{control:e,index:g,remove:o,data:n},h.id)},h.id))]})]})};function d5({data:e,control:t,watch:n}){return l(c5,{control:t,watch:n,data:e})}const f5=({disabled:e,value:t,onChange:n})=>{const r=i=>{!i||n(i)};return w(f.Box,{sx:{position:"relative"},children:[e&&l(f.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),l(Gn.default,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1,readOnly:e}}})]})},p5=x.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:i,setFalse:o}]=tt.useBoolean(),[a,s]=x.useState(e),u=g=>{s({...a,enabled:g})},c=()=>{o();const{enabled:g,func_content:v}=a,m={enabled:g,func_content:v};s(m),t(m)},d=()=>{o(),s(e)},p=g=>{s(v=>({...v,func_content:g}))},h=()=>{p(eb.func_content)};return w(De,{children:[l(f.Button,{variant:"filled",mt:24,onClick:i,sx:{flexGrow:0},children:"Customize Label"}),l(f.Modal,{size:800,title:"Customize label content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,children:r&&w(f.Stack,{children:[l(f.Checkbox,{mt:10,label:"Enabled",checked:a.enabled,onChange:g=>u(g.currentTarget.checked)}),l(f5,{value:a.func_content,onChange:p,disabled:!a.enabled}),w(f.Group,{position:"apart",children:[l(f.Button,{onClick:h,color:"red",leftIcon:l(oe.Recycle,{size:20}),children:"Rest"}),w(f.Group,{position:"right",children:[l(f.Button,{onClick:d,variant:"subtle",children:"Cancel"}),l(f.Button,{onClick:c,children:"OK"})]})]})]})})]})});function h5({data:e,control:t,watch:n}){return n(["x_axis"]),w(f.Stack,{children:[w(f.Group,{grow:!0,noWrap:!0,children:[l(G.Controller,{name:"x_axis.data_key",control:t,render:({field:r})=>l(vt,{label:"Data Field",required:!0,data:e,sx:{flex:1},...r})}),l(G.Controller,{name:"x_axis.name",control:t,render:({field:r})=>l(f.TextInput,{label:"Name",sx:{flex:1},...r})})]}),l(f.Divider,{mb:-15,label:"Tick Label",labelPosition:"center"}),w(f.Group,{grow:!0,noWrap:!0,children:[l(G.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:r})=>l(f.NumberInput,{label:"Rotate",hideControls:!0,min:-90,max:90,rightSection:l(f.Text,{color:"dimmed",children:"degree"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...r})}),l(G.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:r})=>l(p5,{data:e,...r})})]})]})}const g5=[{label:"left",value:"left"},{label:"center",value:"center"},{label:"right",value:"right"}],v5=[{label:"left",value:"left"},{label:"right",value:"right"}];function m5({control:e,index:t,remove:n}){return w(f.Stack,{my:0,p:"0",sx:{position:"relative"},children:[l(f.Divider,{mb:-15,mt:15,variant:"dashed",label:"Name",labelPosition:"center"}),w(f.Group,{grow:!0,noWrap:!0,children:[l(G.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:r})=>l(f.TextInput,{label:"Name",required:!0,sx:{flex:1},...r})}),l(G.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:r})=>l(f.Select,{label:"Align",required:!0,data:g5,sx:{flex:1},...r})})]}),l(f.Divider,{mb:-15,variant:"dashed",label:"Layout",labelPosition:"center"}),l(f.Group,{grow:!0,noWrap:!0,children:l(G.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:r})=>l(f.Select,{label:"Position",required:!0,data:v5,sx:{flex:1},...r})})}),w(f.Stack,{children:[l(f.Divider,{mb:-15,variant:"dashed",label:"Label Format",labelPosition:"center"}),l(G.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:r})=>l(Gr,{...r})})]}),w(f.Stack,{children:[l(f.Divider,{mb:-15,variant:"dashed",label:"Value Range",labelPosition:"center"}),w(f.Group,{grow:!0,children:[l(G.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:r})=>l(f.TextInput,{label:"Min",...r})}),l(G.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:r})=>l(f.TextInput,{label:"Max",...r})})]})]}),l(f.Button,{mt:20,leftIcon:l(oe.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),disabled:t===0,children:"Delete this YAxis"})]})}function y5({control:e,watch:t}){const{fields:n,append:r,remove:i}=G.useFieldArray({control:e,name:"y_axes"}),o=t("y_axes"),a=n.map((u,c)=>({...u,...o[c]})),s=()=>r({name:"",label_formatter:Ln});return w(f.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px"}},children:[w(f.Tabs.List,{children:[a.map((u,c)=>l(f.Tabs.Tab,{value:c.toString(),children:c+1},c)),l(f.Tabs.Tab,{onClick:s,value:"add",children:l(f.ActionIcon,{children:l(oe.Plus,{size:18,color:"#228be6"})})})]}),a.map((u,c)=>l(f.Tabs.Panel,{value:c.toString(),children:l(m5,{control:e,index:c,remove:i})},c))]})}function b5(e){return e||{templates:{top:"",bottom:""}}}function w5({reference_lines:e=[],stats:t,...n}){return{reference_lines:e,stats:b5(t),...n}}function x5({context:e}){const{value:t,set:n}=Ze(e.instanceData,"config"),{variables:r}=e,i=e.data,o=x.useMemo(()=>H.defaultsDeep({},t,Dc),[t]),a=x.useMemo(()=>w5(o),[o]);x.useEffect(()=>{!H.isEqual(o,a)&&(console.log("config malformed, resetting to defaults",o,a),n(a))},[o,a]);const{control:s,handleSubmit:u,watch:c,getValues:d,reset:p}=G.useForm({defaultValues:a});x.useEffect(()=>{p(a)},[a]);const h=d(),g=x.useMemo(()=>!H.isEqual(h,o),[h,o]);return c(["dataZoom"]),l(f.Stack,{mt:"md",spacing:"xs",children:w("form",{onSubmit:u(n),children:[w(f.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(f.Text,{children:"Chart Config"}),l(f.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!g,children:l(oe.DeviceFloppy,{size:20})})]}),w(f.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[w(f.Tabs.List,{children:[l(f.Tabs.Tab,{value:"X Axis",children:"X Axis"}),l(f.Tabs.Tab,{value:"Y Axes",children:"Y Axes"}),l(f.Tabs.Tab,{value:"Scatter",children:"Scatter"}),l(f.Tabs.Tab,{value:"Tooltip",children:"Tooltip"}),l(f.Tabs.Tab,{value:"Stats",children:"Stats"}),l(f.Tabs.Tab,{value:"Reference Lines",children:"Reference Lines"}),l(f.Tabs.Tab,{value:"Zooming",children:"Zooming"})]}),l(f.Tabs.Panel,{value:"X Axis",children:l(h5,{control:s,watch:c,data:i})}),l(f.Tabs.Panel,{value:"Y Axes",children:l(y5,{control:s,watch:c})}),l(f.Tabs.Panel,{value:"Scatter",children:l(s5,{control:s,watch:c,data:i})}),l(f.Tabs.Panel,{value:"Tooltip",children:l(d5,{control:s,watch:c,data:i})}),l(f.Tabs.Panel,{value:"Stats",children:l(l5,{control:s,watch:c,data:i})}),l(f.Tabs.Panel,{value:"Reference Lines",children:l(ZB,{variables:r,control:s,watch:c})}),l(f.Tabs.Panel,{value:"Zooming",children:l(G.Controller,{name:"dataZoom",control:s,render:({field:v})=>l(nc,{...v})})})]})]})})}function S5(e){const{dataZoom:t=Di,...n}=e;return{...n,dataZoom:t}}function C5(e){const t={scatter:{label_overflow:tb}};return Se.default.defaultsDeep(t,e)}class _5 extends en{constructor(){super(...arguments);ke(this,"VERSION",4)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{tooltip:r={metrics:[]},...i}=n.config;return{...n,version:2,config:{...i,tooltip:r}}}),this.version(3,n=>({...n,version:3,config:S5(n.config)})),this.version(4,n=>{const{config:r}=n;return{...n,version:5,config:C5(r)}})}}const E5={displayName:"Scatter Chart",migrator:new _5,name:"scatterChart",viewRender:YB,configRender:x5,createConfig(){return{version:4,config:H.cloneDeep(Dc)}},triggers:[Jy]},ob=["function text({ data, variables, filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
292
- `),Rc={func_content:ob,horizontal_align:"left",font_size:"14px",font_weight:"normal"},T5=le.observer(({context:e})=>{const t=ot(),{value:n=Rc}=Ze(e.instanceData,"config"),{variables:r}=e,{func_content:i,horizontal_align:o,font_size:a,font_weight:s}=n,u=x.useMemo(()=>new Function(`return ${i}`)()({data:e.data,variables:r,filters:t.filters.values,context:t.context.current}),[i,e.data,r,t.filters.values,t.context.current]);return l(f.Text,{align:o,weight:s,sx:{fontSize:a},children:u})}),M5=({value:e,onChange:t})=>{const n=r=>{!r||t(r)};return l(f.Box,{sx:{position:"relative"},children:l(Gn.default,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},O5=x.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:i,setFalse:o}]=tt.useBoolean(),[a,s]=x.useState(e),u=()=>{o(),t(a)},c=()=>{o(),s(e)},d=()=>{s(ob)};return x.useEffect(()=>{s(e)},[e]),w(De,{children:[l(f.Button,{variant:"filled",mt:24,onClick:i,sx:{flexGrow:0},children:"Edit Content"}),l(f.Modal,{size:800,title:"Text content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,children:r&&w(f.Stack,{children:[l(M5,{value:a,onChange:s}),w(f.Group,{position:"apart",children:[l(f.Button,{onClick:d,color:"red",leftIcon:l(oe.Recycle,{size:20}),children:"Rest"}),w(f.Group,{position:"right",children:[l(f.Button,{onClick:c,variant:"subtle",children:"Cancel"}),l(f.Button,{onClick:u,children:"OK"})]})]})]})})]})}),D5=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}];function R5({context:e}){const{value:t,set:n}=Ze(e.instanceData,"config"),r=x.useMemo(()=>H.defaultsDeep({},t,Rc),[t]),i=x.useMemo(()=>{const{func_content:h,horizontal_align:g,font_size:v,font_weight:m}=r;return{func_content:h,horizontal_align:g,font_size:v,font_weight:m}},[r]);x.useEffect(()=>{!H.isEqual(r,i)&&(console.log("config malformed, resetting to defaults",r,i),n(i))},[r,i]);const{control:o,handleSubmit:a,watch:s,getValues:u,reset:c}=G.useForm({defaultValues:i});W.default.useEffect(()=>{c(i)},[i]),s(["func_content","horizontal_align","font_size","font_weight"]);const d=u(),p=W.default.useMemo(()=>!Se.default.isEqual(d,r),[d,r]);return l(f.Stack,{mt:"md",spacing:"xs",children:w("form",{onSubmit:a(n),children:[w(f.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(f.Text,{weight:500,children:"Configurations"}),l(f.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!p,children:l(oe.DeviceFloppy,{size:20})})]}),w(f.Stack,{spacing:10,children:[l(G.Controller,{name:"func_content",control:o,render:({field:h})=>l(O5,{...h})}),l(f.Divider,{mt:10,mb:-10,variant:"dashed",label:"Style",labelPosition:"center"}),l(G.Controller,{name:"horizontal_align",control:o,render:({field:h})=>l(f.Select,{label:"Horizontal Alignment",data:D5,...h})}),l(G.Controller,{name:"font_size",control:o,render:({field:h})=>l(f.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},...h})}),l(f.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:l(G.Controller,{name:"font_weight",control:o,render:({field:h})=>l(ey,{label:"Font Weight",...h})})})]})]})})}class k5 extends en{constructor(){super(...arguments);ke(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const A5={displayName:"Text",migrator:new k5,name:"text",viewRender:T5,configRender:R5,createConfig(){return{version:1,config:H.cloneDeep(Rc)}}},P5=[{value:"#25262B",name:"Dark"},{value:"#868E96",name:"Gray"},{value:"#FA5252",name:"Red"},{value:"#E64980",name:"Pink"},{value:"#BE4BDB",name:"Grape"},{value:"#7950F2",name:"Violet"},{value:"#4C6EF5",name:"Indigo"},{value:"#228BE6",name:"Blue"},{value:"#15AABF",name:"Cyan"},{value:"#12B886",name:"Teal"},{value:"#40C057",name:"Green"},{value:"#82C91E",name:"Lime"},{value:"#FAB005",name:"Yellow"},{value:"#FD7E14",name:"Orange"}].map(e=>({name:e.name,value:e.value,type:"single",category:"basic"})),N5=[J2,eL,rL,nL,tL,iL],ab=()=>({id:"dashboard",version:$u,manifest:{viz:[Tc,t3,A5,WF,a3,xF,pL,yV,vF,jz,E5,AF,GF,kB,AV],color:[...P5,...N5]}}),Do=new sL,$t={pluginManager:Hn("pluginManager"),vizManager:Hn("vizManager"),colorManager:Hn("colorManager"),instanceScope:{panelModel:Hn("panelModel"),vizInstance:Hn("vizInstance"),interactionManager:Hn("interactionManager"),migrator:Hn("migrator"),operationManager:Hn("operationManager"),triggerManager:Hn("triggerManager")}},kc=()=>{try{Do.install(ab())}catch{}const e=new X2(Do),t=new aL(Do);return{pluginManager:Do,vizManager:e,colorManager:t}},Fn=x.createContext(kc());try{Do.install(ab())}catch{}function I5(e,t){const{value:n,set:r}=Ze(e.operation.operationData,"config"),[i,o]=x.useState(H.defaults({},n,t)),a=async()=>{await r(i)};return x.useEffect(()=>{o(H.defaults({},n,t))},[n]),{config:i,setConfig:o,commit:a}}function $5(e){const{config:t,setConfig:n,commit:r}=I5(e,{urlTemplate:"",openInNewTab:!0});async function i(){await r()}async function o(s){n({...t,openInNewTab:s}),await r()}const a=s=>n({...t,urlTemplate:s.currentTarget.value});return w(f.Stack,{children:[l(f.TextInput,{label:"Url",value:t.urlTemplate,onChange:a,onBlur:i}),l(f.Switch,{label:"Open in new Tab",checked:t.openInNewTab,onChange:s=>o(s.currentTarget.checked)})]})}async function L5(e,t){const{urlTemplate:n,openInNewTab:r}=await t.operationData.getItem("config");window.dispatchEvent(new CustomEvent("open-link",{detail:{urlTemplate:n,openInNewTab:r,payload:e}}))}class V5 extends en{constructor(){super(...arguments);ke(this,"VERSION",1)}configVersions(){this.version(1,n=>n)}}const z5={displayName:"Open Link",id:"builtin:op:open-link",configRender:$5,run:L5,migrator:new V5,createDefaultConfig:()=>({version:1,config:{urlTemplate:"",openInNewTab:!0}})};function F5(e){const{value:t,set:n}=Ze(e.operationData,"config"),r=i=>void n({template:i});return[(t==null?void 0:t.template)||"",r]}function B5(e){const[t,n]=F5(e.operation);return l(f.TextInput,{defaultValue:t,onBlur:r=>n(r.currentTarget.value),label:"console.log"})}async function j5(e,t){const n=await t.operationData.getItem("config"),r=H.template(n.template||"");console.log("run with payload",e),console.log(r(e))}const G5={displayName:"console.log (debug)",id:"builtin:op:debug",configRender:B5,run:j5},K5=le.observer(e=>{const t=ot(),{value:n,set:r}=Ze(e.operation.operationData,"config");console.log({value:n,viewID:n==null?void 0:n.viewID});const i=(n==null?void 0:n.viewID)||"",o=a=>void r({viewID:a});return l(f.Select,{defaultValue:i,value:i,onChange:o,label:"View",data:t.views.options})});async function H5(e,t){const r=(await t.operationData.getItem("config")).viewID;window.dispatchEvent(new CustomEvent("open-view",{detail:{viewID:r}}))}const q5={displayName:"Open View",id:"builtin:op:open_view",configRender:K5,run:H5},W5={dictionary:{}},U5=le.observer(e=>{const t=ot(),{value:n=W5,set:r}=Ze(e.operation.operationData,"config"),{dictionary:i={}}=n,o=(u,c)=>{r({dictionary:{...i,[u]:c}})},a=()=>{o(t.filters.firstFilterValueKey,"")},s=u=>{const c={...i};delete c[u],r({dictionary:c})};return w(f.Stack,{spacing:10,children:[l(f.Text,{children:"Mapping Rules"}),Object.entries(i).map(([u,c])=>w(f.Flex,{justify:"space-between",gap:10,children:[l(f.TextInput,{label:"Payload key",value:c,onChange:d=>{o(u,d.currentTarget.value)},sx:{flexGrow:1}}),l(vt,{data:[t.filters.values],value:u,onChange:d=>{o(d,c)},label:"Filter key",sx:{flexGrow:1}}),l(f.ActionIcon,{onClick:()=>s(u),sx:{marginTop:"26px",flexGrow:0},children:l(oe.Trash,{size:14,color:"red"})})]},u)),l(f.Button,{size:"xs",onClick:a,sx:{alignSelf:"center",width:"300px"},children:"Add one mapping rule"})]})});async function Y5(e,t){const r=(await t.operationData.getItem("config")).dictionary;window.dispatchEvent(new CustomEvent("set-filter-values",{detail:{dictionary:r,payload:e}}))}const X5={displayName:"Set Filter Values",id:"builtin:op:set_filter_values",configRender:U5,run:Y5},Q5={filter_keys:[]},Z5=le.observer(e=>{const t=ot(),{value:n=Q5,set:r}=Ze(e.operation.operationData,"config"),{filter_keys:i=[]}=n,o=s=>{r({filter_keys:[...s]})},a=x.useMemo(()=>t.filters.current.map(s=>({label:s.label,value:s.key})),[t.filters.values]);return l(f.Stack,{spacing:10,children:l(f.MultiSelect,{label:"Select Filters to Clear",data:a,value:i,onChange:o})})});async function J5(e,t){const r=(await t.operationData.getItem("config")).filter_keys;window.dispatchEvent(new CustomEvent("clear-filter-values",{detail:{filter_keys:r,payload:e}}))}const us=[G5,z5,q5,X5,{displayName:"Clear Filter Values",id:"builtin:op:clear_filter_values",configRender:Z5,run:J5}];class e4{constructor(t,n=us){ke(this,"attachments");this.operations=n;const r=async i=>{const{id:o,schemaRef:a}=await i.getItem(null);return{id:o,schemaRef:a,operationData:new Ti(i,"data")}};this.attachments=new Iu(t,"__OPERATIONS",r)}async runOperation(t,n){const r=await this.attachments.getInstance(t);if(!r){console.warn(`Operation '${t}' is not defined`);return}const i=this.tryGetSchema(r.schemaRef);if(!i){console.warn(`Operation schema '${r.schemaRef}' is not defined`);return}await i.run(n,r)}tryGetSchema(t){return this.operations.find(n=>n.id===t)}async needMigration(){const n=(await this.attachments.list()).map(async r=>{const i={configData:r.operationData},o=this.tryGetSchema(r.schemaRef),a=o==null?void 0:o.migrator;return a&&await a.needMigration(i)});return(await Promise.all(n)).some(r=>r)}async runMigration(){const n=(await this.attachments.list()).map(async r=>{const i={configData:r.operationData},o=this.tryGetSchema(r.schemaRef),a=o==null?void 0:o.migrator;a&&await a.needMigration(i)&&await a.migrate(i)});await Promise.all(n)}async createOrGetOperation(t,n){var a,s;if(!this.getOperationSchemaList().some(u=>u.id===n.id))throw new Error(`Operation schema '${n.id}' is not defined`);const i=await this.attachments.getInstance(t);return!i||i.schemaRef!==n.id?await this.attachments.create(t,{id:t,schemaRef:n.id,data:(s=(a=n.createDefaultConfig)==null?void 0:a.call(n))!=null?s:{}}):i}getOperationList(){return this.attachments.list()}getOperationSchemaList(){return this.operations}removeOperation(t){return this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}}class Ac{constructor(t,n,r){ke(this,"operationManager");ke(this,"triggerManager");ke(this,"attachments");this.operationManager=new e4(t,r),this.triggerManager=new mL(t,n);const i=async o=>{const{id:a,triggerRef:s,operationRef:u}=await o.getItem(null);return{id:a,triggerRef:s,operationRef:u}};this.attachments=new Iu(t,"__INTERACTIONS",i)}async addInteraction(t,n){const r=t.id,i=n.id,o=`[${r}]:[${i}]`;await this.attachments.create(o,{id:o,triggerRef:r,operationRef:i})}getInteractionList(){return this.attachments.list()}async removeInteraction(t){const n=await this.attachments.getInstance(t);if(!n)return;const{triggerRef:r,operationRef:i}=n;await this.getTriggerRefCount(r)<=1&&await this.triggerManager.removeTrigger(r),await this.getOperationRefCount(i)<=1&&await this.operationManager.removeOperation(i),await this.attachments.remove(t)}async getOperationRefCount(t){return(await this.getInteractionList()).filter(r=>r.operationRef===t).length}async getTriggerRefCount(t){return(await this.getInteractionList()).filter(r=>r.triggerRef===t).length}async runInteraction(t,n){const i=(await this.getInteractionList()).filter(o=>o.triggerRef===t);await Promise.all(i.map(async o=>{try{return await this.operationManager.runOperation(o.operationRef,n)}catch(a){console.warn(`Failed to run operation '${o.operationRef}'`,a)}}))}}function t4(e,t){const[n,r]=x.useState([]);return tt.useAsyncEffect(async()=>{const i=await e.getInteractionList();r(i)},[t]),n}const n4=le.observer(({item:e,manager:t,instance:n,sampleData:r,variables:i,onRemove:o})=>{const{triggerRef:a,operationRef:s}=e,u=K2(t.triggerManager,n);if(tt.useAsyncEffect(async()=>{await u.configTrigger(a,r)},[u,a,r]),u.isReady()){const c=[...u.triggerSchema.payload,...i];return w(f.Group,{children:[l(U2,{model:u}),l(B2,{instance:n,operationId:s,variables:c,operationManager:t.operationManager}),l(f.ActionIcon,{"aria-label":"delete-interaction",variant:"filled",color:"red",onClick:()=>o(e),children:l(oe.Trash,{size:16})})]})}return null}),r4=e=>{const[t,n]=x.useState(0),{interactionManager:r,instance:i,sampleData:o,variables:a}=e,s=t4(r,t),u=async()=>{const h=await r.triggerManager.createOrGetTrigger(St.randomId(),r.triggerManager.getTriggerSchemaList()[0]),g=await r.operationManager.createOrGetOperation(St.randomId(),r.operationManager.getOperationSchemaList()[0]);await r.addInteraction(h,g),n(v=>v+1)};async function c(h){await r.removeInteraction(h.id),n(g=>g+1)}const{data:d=0,loading:p}=tt.useRequest(async()=>{try{return(await r.triggerManager.getTriggerSchemaList()).length}catch{return 0}});return w(f.Stack,{children:[l(f.LoadingOverlay,{visible:p}),d===0&&l(f.Alert,{icon:l(oe.AlertCircle,{size:16}),title:"Unavailable",color:"gray",children:"This visualization does not have available interactions to choose from"}),s.map(h=>l(n4,{onRemove:c,instance:i,sampleData:o,variables:a,item:h,manager:e.interactionManager},h.id)),l(f.Button,{style:{width:"fit-content"},onClick:()=>u(),disabled:d===0,children:"Add interaction"})]})},i4=()=>{const{panel:e,data:t}=Gt(),n=e.viz,{vizManager:r}=x.useContext(Fn),i=e.json,o=tt.useCreation(()=>r.getOrCreateInstance(i),[r,n.type]),a=tt.useCreation(()=>new Ac(o,r.resolveComponent(n.type),us),[o,n.type]);return x.useEffect(()=>o.instanceData.watchItem(null,H.throttle(s=>{e.viz.setConf(s)},100,{leading:!1,trailing:!0})),[o]),{instance:o,vizManager:r,interactionManager:a,sampleData:t,variables:[]}},o4=()=>{const e=i4();return l(r4,{...e})},a4=le.observer(()=>{const{panel:e}=Gt(),[t,n]=W.default.useState(e.description),r=e.description!==t,i=W.default.useCallback(()=>{!r||e.setDescription(t)},[r,t]);return w(f.Stack,{spacing:4,sx:{flexGrow:1},children:[w(f.Group,{align:"end",children:[l(f.Text,{sx:{flexGrow:1},children:"Description"}),l(f.ActionIcon,{variant:"subtle",color:"blue",disabled:!r,onClick:i,children:l(oe.DeviceFloppy,{size:20})})]}),l(ky,{value:t,onChange:n,styles:{root:{flexGrow:1}}})]})}),s4=le.observer(()=>{const{panel:e}=Gt(),{style:t}=e;return l(De,{children:l(f.Switch,{label:"Border",checked:t.border.enabled,onChange:n=>t.border.setEnabled(n.currentTarget.checked)})})}),l4=le.observer(()=>{const{panel:{title:e,style:{border:t}}}=Gt();return l(qr,{children:w(f.Stack,{mx:"auto",mt:"xl",p:"5px",spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:t.enabled?"1px":"0px"},children:[w(f.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[l(f.Group,{children:l(Nm,{})}),l(f.Group,{grow:!0,position:"center",children:l(f.Text,{lineClamp:1,weight:"bold",children:e})}),l(f.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),l(f.Group,{sx:{background:"#eee",flexGrow:1}})]})})}),u4=le.observer(()=>{const{panel:e}=Gt(),{title:t,setTitle:n}=e,[r,i]=St.useInputState(t),o=t!==r,a=W.default.useCallback(()=>{!o||n(r)},[o,r]);return l(f.TextInput,{value:r,onChange:i,label:w(f.Group,{align:"apart",children:[l(f.Text,{sx:{flexGrow:1},children:"Panel Title"}),l(f.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:a,children:l(oe.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function c4(){return w(f.Group,{grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[w(f.Stack,{sx:{width:"40%",flexShrink:0,flexGrow:0,height:"100%"},children:[l(f.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),l(s4,{}),l(f.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),l(u4,{}),l(a4,{})]}),l(f.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:l(l4,{})})]})}const d4=le.observer(function(){const t=ot(),{panel:{queryID:n,setQueryID:r}}=Gt(),i=W.default.useMemo(()=>t.queries.current.map(o=>({value:o.id,label:o.name})),[t.queries.current]);return w(f.Stack,{children:[w(f.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[l(f.Text,{children:"Select a Query"}),l(f.Select,{data:i,value:n,onChange:r,allowDeselect:!1,clearable:!1,sx:{flexGrow:"1 !important"}})]}),l(vm,{id:n})]})});var sb=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(sb||{}),cs=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(cs||{});class f4{constructor(t){ke(this,"vizInstance");ke(this,"operationManager");ke(this,"triggerManager");ke(this,"vizManager");ke(this,"runningMigration");ke(this,"panelModel");ke(this,"status","notStarted");this.panelModel=t.getRequired($t.instanceScope.panelModel),this.vizInstance=t.getRequired($t.instanceScope.vizInstance),this.operationManager=t.getRequired($t.instanceScope.operationManager),this.triggerManager=t.getRequired($t.instanceScope.triggerManager),this.vizManager=t.getRequired($t.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(n){return console.warn("check migration failed",n),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(n=>n())),"migrated"}catch(n){return console.warn("migration failed",n),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(t=>(this.status="done",t))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(n)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData};return t.migrator.needMigration(n)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function lb(e){const{panel:t}=Gt();return x.useCallback(n=>{const r=n.getRequired($t.vizManager),i=r.resolveComponent(e.viz.type);return n.createScoped().provideFactory($t.instanceScope.vizInstance,()=>r.getOrCreateInstance(e)).provideFactory($t.instanceScope.interactionManager,o=>{const a=o.getRequired($t.instanceScope.vizInstance);return new Ac(a,i,us)}).provideFactory($t.instanceScope.operationManager,o=>o.getRequired($t.instanceScope.interactionManager).operationManager).provideFactory($t.instanceScope.triggerManager,o=>o.getRequired($t.instanceScope.interactionManager).triggerManager).provideValue($t.instanceScope.panelModel,t).provideFactory($t.instanceScope.migrator,o=>new f4(o))},[e.viz.type,e.viz.conf])}function ub(e){const[t,n]=x.useState(!1),r=Xc().getRequired($t.instanceScope.migrator);return tt.useAsyncEffect(async()=>{const i=r.status===cs.notStarted;n(r.status===cs.done),r.status===cs.notStarted&&r.runMigration().then(o=>{o===sb.migrated&&i&&(e==null||e())}).finally(()=>{n(!0)})},[r]),t}function cb(e,t){const n=Xc().getRequired($t.instanceScope.vizInstance);return x.useEffect(()=>n.instanceData.watchItem(null,r=>{e(r)}),[e,t.viz.type]),n}function p4({setVizConf:e,...t}){const{panel:n}=t,r=cb(e,n),i=ub(()=>{ko.showNotification({title:`${n.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return tt.useAsyncEffect(async()=>{await r.instanceData.setItem(null,n.viz.conf)},[r,n.viz.type]),i?l(Z2,{...t}):l(f.Text,{children:"Checking update..."})}function h4(e){const{panel:t,setVizConf:n}=e;return cb(n,t),ub(()=>{ko.showNotification({title:`${t.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?l(Q2,{...e}):l(f.Text,{children:"Checking update"})}const Zj="";function g4(e,t){const{vizManager:n}=x.useContext(Fn),{panel:{viz:r,title:i,id:o,description:a,queryID:s,variables:u}}=Gt(),c={title:i,id:o,description:a,queryID:s,viz:r,layout:t},d=lb(c);try{return n.resolveComponent(r.type),l(Io,{configure:d,children:l(h4,{setVizConf:r.setConf,panel:c,data:e,variables:u,vizManager:n})})}catch(p){return console.info(H.get(p,"message")),null}}const v4=["richText","button"],db=le.observer(function({height:t,viz:n,data:r,loading:i,error:o,query:a}){const{ref:s,width:u,height:c}=St.useElementSize(),d=g4(r,{w:u,h:c});if(v4.includes(n.type))return l("div",{className:"viz-root",style:{height:t},ref:s,children:l(qr,{children:d})});if(i)return l("div",{className:"viz-root",style:{height:t},ref:s,children:l(f.LoadingOverlay,{visible:i,exitTransitionDuration:0})});const h=!!o,g=!h&&!!(a!=null&&a.stateMessage),v=!h&&!g;return w("div",{className:"viz-root",style:{height:t},ref:s,children:[h&&l(f.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:o}),g&&l(f.Text,{color:"gray",align:"center",children:a.stateMessage}),v&&l(qr,{children:d})]})}),m4=le.observer(()=>{const{data:e,loading:t,panel:{viz:n}}=Gt();return l(db,{viz:n,data:e,loading:t,height:"100%"})}),Pc=[];function y4(){const{vizManager:e}=x.useContext(Fn);return x.useMemo(()=>e.availableVizList.map(t=>({value:t.name,label:t.displayName})).concat(Pc),[e])}function b4(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function w4(){const{data:e,panel:{variables:t,viz:n,title:r,queryID:i,description:o,setDescription:a,setTitle:s,setQueryID:u,id:c}}=Gt(),{vizManager:d}=x.useContext(Fn),p={title:r,description:o,viz:n,queryID:i,id:c},h={setDescription:a,setQueryID:u,setTitle:s},g=lb(p);try{return d.resolveComponent(p.viz.type),l(Io,{configure:g,children:l(p4,{variables:t,setVizConf:n.setConf,panel:p,panelInfoEditor:h,vizManager:d,data:e})})}catch(v){return console.info(H.get(v,"message")),null}}const x4=le.observer(()=>{const{data:e,panel:{viz:t}}=Gt(),[n,r]=St.useInputState(t.type),i=t.type!==n,{vizManager:o}=x.useContext(Fn),a=W.default.useCallback(()=>{if(!i)return;const g=b4(o,n);t.setType(n),t.setConf(g||{})},[t,i,n]),s=g=>{try{t.setConf(JSON.parse(g))}catch(v){console.error(v)}},u=W.default.useMemo(()=>{var g;return(g=Pc.find(v=>v.value===n))==null?void 0:g.Panel},[n,Pc]),c=w4(),d=u?x.createElement(u,{data:e,conf:t.conf,setConf:t.setConf}):null,p=c||d,h=y4();return w(De,{children:[l(f.Select,{label:"Visualization",value:n,onChange:r,data:h,rightSection:l(f.ActionIcon,{disabled:!i,onClick:a,children:l(oe.DeviceFloppy,{size:20})})}),p,!p&&l(f.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:s})]})});function S4(){return w(f.Group,{grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[l(f.Stack,{sx:{width:"40%",flexShrink:0,flexGrow:0,overflow:"scroll",height:"100%"},children:l(x4,{})}),l(f.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:l(m4,{})})]})}const C4=N.types.model("VariableModel",{name:N.types.string,size:N.types.string,weight:N.types.string,color:N.types.union(N.types.model({type:N.types.literal("static"),staticColor:N.types.string}),N.types.model({type:N.types.literal("continuous"),valueRange:N.types.array(N.types.number),colorRange:N.types.array(N.types.string)}),N.types.model({type:N.types.literal("piecewise")})),formatter:N.types.model({output:N.types.enumeration("Output",["number","percent"]),mantissa:N.types.number,average:N.types.optional(N.types.boolean,!1),trimMantissa:N.types.optional(N.types.boolean,!1)}),data_field:N.types.string,aggregation:N.types.union(N.types.model({type:N.types.enumeration(["none","sum","mean","median","min","max"]),config:N.types.frozen()}),N.types.model({type:N.types.literal("quantile"),config:N.types.model({p:N.types.number})}))}).views(e=>({get json(){return N.getSnapshot(e)}}));class _4{constructor(t){ke(this,"origin");ke(this,"copy");this.origin=t,this.copy=N.clone(t),zt.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!H.isEqual(N.getSnapshot(this.origin),N.getSnapshot(this.copy))}commit(){N.applySnapshot(this.origin,N.getSnapshot(this.copy))}update(t){N.applySnapshot(this.copy,t)}}const E4=e=>new _4(e),Nc={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{}},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class T4{constructor(t){ke(this,"panel");ke(this,"selected");this.panel=t,zt.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const t=this.panel.variables.filter(n=>n.name.startsWith(Nc.name)).length;this.panel.addVariable(H.cloneDeep({...Nc,name:`${Nc.name}${t||""}`})),this.selected=H.last(this.panel.variables)}select(t){this.selected=t}remove(t){this.selected===t&&(this.selected=void 0);const n=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!H.isEmpty(this.panel.variables)){const r=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[r]}}}function M4(){const{panel:e}=Gt();return tt.useCreation(()=>new T4(e),[e])}const O4=W.default.forwardRef(function({value:t,onChange:n,data:r,withStyle:i=!0},o){const a=(s,u)=>{const c=Se.default.cloneDeep(t);Se.default.set(c,s,u),n(c)};return w(f.Box,{px:"sm",py:"md",ref:o,children:[w(f.Group,{grow:!0,noWrap:!0,children:[l(f.TextInput,{label:"Name",required:!0,value:t.name,onChange:s=>a("name",s.currentTarget.value)}),l(vt,{label:"Data Field",required:!0,data:r,value:t.data_field,onChange:s=>a("data_field",s)})]}),l(Jm,{label:"Aggregation",value:t.aggregation,onChange:s=>a("aggregation",s)}),l(f.Divider,{my:"xs",label:"Format",labelPosition:"center"}),l(Gr,{value:t.formatter,onChange:s=>a("formatter",s)}),i&&l(ty,{value:t,onChange:n})]})}),fb=f.createStyles(e=>({root:{height:"100%",overflow:"hidden",".var-list-container":{"& > *":{height:"100%"},width:250,height:"100%"},".var-list-actions":{height:"fit-content",flexShrink:0,width:"100%"},".var-list":{flex:"1 1 auto",overflow:"auto",minHeight:0,"& > *":{flex:"0 0 auto"}}},config:{height:"100%",overflow:"auto",paddingRight:10}})),D4=e=>{const{uiModel:t}=e;return l(f.Stack,{className:"var-list",children:t.variables.map(n=>l(f.Button,{variant:t.selected===n?"filled":"subtle",color:"gray",onClick:()=>t.select(n),children:n.name},n.name))})},R4=le.observer(D4),k4=({variable:e,data:t})=>l(f.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:l(f.Paper,{withBorder:!0,p:"md",children:Sy(e,t)})}),A4=le.observer(k4),P4=e=>{const t=tt.useCreation(()=>E4(e.variable),[e.variable]),{classes:n}=fb(),{data:r}=Gt();return w(f.Group,{style:{height:"100%"},align:"start",children:[w(f.Stack,{"data-testid":"variable-editor",align:"stretch",className:n.config,children:[w(f.Group,{position:"right",children:[l(f.ActionIcon,{variant:"filled",disabled:!t.changed,color:"primary",onClick:t.commit,children:l(y$,{})}),l(f.ActionIcon,{color:"red",onClick:()=>e.uiModel.remove(e.variable),children:l(fm,{})})]}),l(O4,{value:N.getSnapshot(t.copy),onChange:t.update,data:r})]}),l(A4,{variable:N.getSnapshot(t.copy),data:r})]})},N4=le.observer(P4),I4=()=>{const e=M4(),{classes:t}=fb();return w(f.Group,{className:t.root,noWrap:!0,align:"start",children:[l(f.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:w(f.Stack,{justify:"space-between",children:[l(f.Box,{className:"var-list-actions",children:l(f.Button,{variant:"light",size:"sm",onClick:e.addNew,fullWidth:!0,children:"Add Variable"})}),l(R4,{uiModel:e})]})}),e.selected?l(De,{children:l(N4,{uiModel:e,variable:e.selected})}):l("span",{children:"Select or create a new variable on right side"})]})},$4=le.observer(I4),L4=le.observer(function({opened:t,close:n}){const{freezeLayout:r}=W.default.useContext(vn),[i,o]=x.useState("Visualization"),{panel:a,loading:s}=Gt(),{id:u,title:c}=a;return W.default.useEffect(()=>{r(t)},[t]),l(f.Modal,{size:"96vw",overflow:"inside",opened:t,onClose:n,title:`Editing Panel - ${c.trim()?c:u}`,trapFocus:!0,onDragStart:d=>{d.stopPropagation()},children:l(f.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",minHeight:"unset",maxHeight:"100%",width:"100%",padding:"16px"}},padding:"md",children:w(f.Tabs,{value:i,onTabChange:o,className:"panel-settings-tabs",children:[w(f.Tabs.List,{children:[l(f.Tabs.Tab,{value:"Data",children:"Data"}),l(f.Tabs.Tab,{value:"Panel",children:"Panel"}),l(f.Tabs.Tab,{value:"Variables",children:"Variables"}),l(f.Tabs.Tab,{value:"Visualization",children:"Visualization"}),l(f.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),w(f.Tabs.Panel,{value:"Data",pt:"sm",children:[l(f.LoadingOverlay,{visible:s,exitTransitionDuration:0}),l(d4,{})]}),l(f.Tabs.Panel,{value:"Panel",pt:"sm",children:i==="Panel"&&l(c4,{})}),l(f.Tabs.Panel,{value:"Variables",pt:"sm",children:i==="Variables"&&l($4,{})}),l(f.Tabs.Panel,{value:"Visualization",pt:"sm",children:i==="Visualization"&&l(S4,{})}),l(f.Tabs.Panel,{value:"Interactions",pt:"sm",children:l(qr,{children:l(o4,{})})})]})})})}),V4=le.observer(({view:e})=>{const t=ot(),n=ps.useModals(),[r,i]=W.default.useState(!1),o=()=>i(!0),a=()=>i(!1),{panel:s}=Gt(),{id:u,query:c}=s,{inEditMode:d}=W.default.useContext(vn),p=()=>c==null?void 0:c.fetchData(),{viewPanelInFullScreen:h,inFullScreen:g}=W.default.useContext(bs),v=()=>{e.panels.duplicateByID(u)},m=()=>n.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>e.panels.removeByID(u)}),b=W.default.useCallback(()=>{h(u)},[u,h]),y=!g&&e.type!==wt.Modal;return w(De,{children:[l(f.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:w(f.Menu,{withinPortal:!0,children:[l(f.Menu.Target,{children:l(f.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),w(f.Menu.Dropdown,{children:[l(f.Menu.Item,{onClick:p,icon:l(oe.Refresh,{size:14}),children:"Refresh"}),l(f.Menu.Item,{onClick:()=>t.queries.downloadDataByQueryID(c),icon:l(oe.Download,{size:14}),children:"Download Data"}),y&&l(f.Menu.Item,{onClick:b,icon:l(oe.ArrowsMaximize,{size:14}),children:"Full Screen"}),d&&w(De,{children:[l(f.Divider,{label:"Edit",labelPosition:"center"}),l(f.Menu.Item,{onClick:o,icon:l(oe.Settings,{size:14}),children:"Settings"}),l(f.Menu.Item,{onClick:v,icon:l(oe.Copy,{size:14}),children:"Duplicate"}),l(f.Menu.Item,{color:"red",onClick:m,icon:l(oe.Trash,{size:14}),children:"Delete"})]})]})]})}),d&&l(L4,{opened:r,close:a})]})}),Jj="",z4=le.observer(function(){const{panel:t}=Gt(),{title:n}=t;return n?l(f.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:l(f.Text,{align:"center",lineClamp:1,weight:"bold",children:n})}):null});function F4(e){return!["richText","button"].includes(e)}const B4={border:"1px solid #e9ecef"},pb={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function j4(e,t,n){return e.style.border.enabled?B4:n||t?pb:{border:"1px dashed transparent"}}const ds=le.observer(function({panel:t,view:n}){const r=ot(),{inEditMode:i}=x.useContext(vn),{data:o,state:a,error:s}=r.getDataStuffByID(t.queryID),u=r.queries.findByID(t.queryID),c=F4(t.viz.type),d=c&&a==="loading",p=t.title?"calc(100% - 25px - 5px)":"100%",h=j4(t,c,i),g=c||i;return l(ed,{value:{panel:t,data:o,loading:d},children:w(f.Box,{className:"panel-root",p:5,pt:0,sx:{...h},children:[l(f.Box,{sx:{position:"absolute",left:0,top:0,height:28,zIndex:310},children:l(Nm,{})}),g&&l(V4,{view:n}),l(z4,{}),l(db,{viz:t.viz,data:o,loading:d,error:s,height:p,query:u})]})})}),hb=le.observer(function({view:t,panel:n,exitFullScreen:r}){return w(f.Stack,{px:"10px",pb:"5px",sx:{height:"100%",flexGrow:1,justifyContent:"flex-start"},children:[l(f.Group,{sx:{flexGrow:0},children:l(f.Button,{variant:"default",size:"sm",onClick:r,leftIcon:l(oe.ArrowLeft,{size:20}),children:"Exit fullscreen"})}),l(f.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:l(ds,{view:t,panel:n})})]})});function gb(e,t,n){const r=e.id==="Main",[i,o]=W.default.useState(()=>r&&e.panels.findByID(t)?t:null),a=W.default.useCallback(d=>{o(d),r&&n(d)},[r,n]),s=W.default.useCallback(()=>{o(null),r&&n("")},[r,n]),u=i?e.panels.findByID(i):null;return{viewPanelInFullScreen:a,exitFullScreen:s,inFullScreen:!!u,fullScreenPanel:u}}const eG="",G4=W.default.forwardRef(({handleAxis:e},t)=>l(f.ActionIcon,{ref:t,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:l(oe.ArrowsMove,{size:16})})),K4=W.default.forwardRef(({handleAxis:e,...t},n)=>l(f.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:-5,right:-5,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:l(oe.ChevronDownRight,{size:16})})),H4=gs.WidthProvider(qc.default),q4=le.observer(function({view:t,className:n="layout",rowHeight:r=10,isDraggable:i,isResizable:o}){const a=W.default.useCallback(s=>{s.forEach(({i:u,...c})=>{const d=t.panels.findByID(u);!d||d.layout.set(c)})},[t]);return l(H4,{onLayoutChange:a,className:`dashboard-layout ${n}`,rowHeight:r,layout:t.panels.layouts,isDraggable:i,isResizable:o,draggableHandle:".react-grid-customDragHandle",resizeHandle:l(K4,{}),children:t.panels.list.map((s,u)=>w("div",{"data-grid":{...s.layout},style:{position:"relative"},children:[i&&l(G4,{}),l(ds,{view:t,panel:s})]},s.id))})}),W4=gs.WidthProvider(qc.default),U4=le.observer(function({view:t,className:n="layout",rowHeight:r=10}){return l(W4,{className:`dashboard-layout ${n}`,rowHeight:r,isDraggable:!1,isResizable:!1,layout:t.panels.layouts,children:t.panels.list.map(i=>l("div",{"data-grid":i.layout,children:l(ds,{view:t,panel:i})},i.id))})}),Y4=le.observer(({children:e})=>l(f.Box,{children:e})),X4=le.observer(({children:e,view:t})=>{const n=t.config;return l(f.Modal,{size:n.width,overflow:"inside",opened:!0,onClose:Se.default.noop,withCloseButton:!1,title:n.custom_modal_title.value,trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{root:{position:"relative",height:"calc(100% - 44px)"},overlay:{position:"absolute !important"},modal:{border:"1px solid #efefef"},body:{maxHeight:"calc(100vh - 325px)"}},withinPortal:!1,transitionDuration:0,children:e})}),Q4=le.observer(({view:e,children:t})=>{switch(e.type){case wt.Modal:return l(X4,{view:e,children:t});case wt.Division:default:return l(Y4,{children:t})}}),vb=le.observer(function({view:t,saveDashboardChanges:n,fullScreenPanelID:r,setFullScreenPanelID:i}){const{viewPanelInFullScreen:o,exitFullScreen:a,inFullScreen:s,fullScreenPanel:u}=gb(t,r,i);return l(bs.Provider,{value:{viewPanelInFullScreen:o,inFullScreen:s},children:w(f.Box,{className:"dashboard-view",mx:-10,sx:{position:"relative",height:"100%"},children:[s&&l(hb,{view:t,panel:u,exitFullScreen:a}),!s&&l(_m,{saveChanges:n}),l(Q4,{view:t,children:w(f.Box,{sx:{position:"relative"},children:[!s&&l(f.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:l(jh,{view:t})}),!s&&l(q4,{view:t,isDraggable:!0,isResizable:!0})]})})]})})}),Z4=le.observer(({children:e})=>l(f.Box,{children:e})),J4=le.observer(({children:e,view:t})=>{const n=ot(),r=t.config,i=n.views.visibleViewIDs.includes(t.id),o=()=>n.views.rmVisibleViewID(t.id);return l(f.Modal,{size:r.width,centered:!0,overflow:"inside",opened:i,onClose:o,withCloseButton:!1,title:r.custom_modal_title.value,trapFocus:!0,onDragStart:a=>{a.stopPropagation()},styles:{modal:{border:"1px solid #efefef"},body:{maxHeight:r.height,overflow:"scroll"}},transitionDuration:0,children:e})}),ej=le.observer(({view:e,children:t})=>{switch(e.type){case wt.Modal:return l(J4,{view:e,children:t});case wt.Division:default:return l(Z4,{children:t})}}),mb=le.observer(function({view:t,fullScreenPanelID:n,setFullScreenPanelID:r}){const{viewPanelInFullScreen:i,exitFullScreen:o,inFullScreen:a,fullScreenPanel:s}=gb(t,n,r);return l(bs.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:a},children:w(f.Box,{className:"dashboard-view",mx:-10,sx:{position:"relative",height:"100%"},children:[a&&l(hb,{view:t,panel:s,exitFullScreen:o}),!a&&l(_m,{saveChanges:Se.default.noop}),l(ej,{view:t,children:w(f.Box,{sx:{position:"relative"},children:[!a&&l(f.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:l(jh,{view:t})}),!a&&l(U4,{view:t})]})})]})})}),yb=N.types.model("FilterConfigModel_Checkbox",{_name:N.types.literal("checkbox"),default_value:N.types.boolean}).actions(e=>({setDefaultValue(t){e.default_value=t}})),tj=()=>yb.create({_name:"checkbox",default_value:!1}),nj=N.types.model("FilterConfigModel_DateRange",{_name:N.types.literal("date-range"),required:N.types.boolean,inputFormat:N.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:N.types.optional(N.types.array(N.types.union(N.types.string,N.types.null)),[null,null]),clearable:N.types.boolean,max_days:N.types.optional(N.types.number,0),allowSingleDateInRange:N.types.optional(N.types.boolean,!1)}).views(e=>({truthy(t){return Array.isArray(t)&&t.length===2&&t.every(n=>!!n)}})).views(e=>({getMaxDate(t){const{max_days:n}=e;if(!(!n||!t))return _n.default(t).startOf("day").add(n,"days").toDate()},getMinDate(t){const{max_days:n}=e;if(!(!n||!t))return _n.default(t).startOf("day").subtract(n,"days").toDate()}})).actions(e=>({setRequired(t){e.required=t},setClearable(t){e.clearable=t},setInputFormat(t){e.inputFormat=t},setDefaultValue(t){e.default_value.length=0,e.default_value.push(...t)},setMaxDays(t){e.max_days=t,t>0&&(e.clearable=!0)},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),bb=N.types.snapshotProcessor(nj,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>n===null?null:_n.default.tz(n,"UTC").toISOString())}},postProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>{try{return n?_n.default.tz(n,"UTC").format(t.inputFormat):null}catch{return console.log(`[date-range] failed parsing ${n}`),null}})}}}),rj=()=>bb.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),ij=N.types.model({label:N.types.string,value:N.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),Ic=N.types.model("FilterConfigModel_BaseSelect",{static_options:N.types.optional(N.types.array(ij),[]),options_query_id:N.types.optional(N.types.string,""),default_selection_count:N.types.optional(N.types.number,0)}).views(e=>({get usingQuery(){return!!e.options_query_id}})).views(e=>({get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:n,error:r}=N.getRoot(e).getDataStuffByID(e.options_query_id);return n==="idle"?t:[]}})).actions(e=>({addStaticOption(t){e.static_options.push(t)},removeStaticOption(t){e.static_options.splice(t,1)},setDefaultSelectionCount(t){e.default_selection_count=t},setOptionsQueryID(t){e.options_query_id=t!=null?t:""}})),wb=N.types.compose("FilterConfigModel_MultiSelect",N.types.model({_name:N.types.literal("multi-select"),default_value:N.types.optional(N.types.array(N.types.string),[]),min_width:N.types.optional(N.types.string,"")}),Ic).actions(e=>({setDefaultValue(t){e.default_value=N.cast(t)},setMinWidth(t){e.min_width=t}})),oj=()=>wb.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),xb=N.types.compose("FilterConfigModel_TreeSelect",N.types.model({_name:N.types.literal("tree-select"),default_value:N.types.optional(N.types.array(N.types.string),[]),min_width:N.types.optional(N.types.string,"")}),Ic).actions(e=>({setDefaultValue(t){e.default_value=N.cast(t)},setMinWidth(t){e.min_width=t}})),aj=()=>xb.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),Sb=N.types.compose("FilterConfigModel_Select",N.types.model({_name:N.types.literal("select"),default_value:N.types.string,required:N.types.boolean,width:N.types.optional(N.types.string,"")}),Ic).views(e=>({truthy(t){return!!t}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t},setWidth(t){e.width=t}})),sj=()=>Sb.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),$c=N.types.model("FilterModel",{id:N.types.identifier,key:N.types.string,label:N.types.string,order:N.types.number,visibleInViewsIDs:N.types.array(N.types.string),auto_submit:N.types.optional(N.types.boolean,!1),type:N.types.enumeration("DashboardFilterType",[Ht.Select,Ht.MultiSelect,Ht.TreeSelect,Ht.TextInput,Ht.Checkbox,Ht.DateRange]),config:N.types.union(Sb,wb,xb,bm,yb,bb)}).views(e=>({get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==Ht.TreeSelect},get auto_submit_supported(){return[Ht.Select,Ht.Checkbox,Ht.DateRange].includes(e.type)}})).views(e=>({get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return Se.default.get(e.config,"required",!1)?Se.default.get(e.config,"truthy",()=>!0)(t):!1}})).actions(e=>({setKey(t){e.key=t},setLabel(t){e.label=t},setOrder(t){e.order=t},setType(t){switch(t){case Ht.Select:e.config=sj();break;case Ht.MultiSelect:e.config=oj();break;case Ht.TreeSelect:e.config=aj();break;case Ht.TextInput:e.config=wm();break;case Ht.Checkbox:e.config=tj();break;case Ht.DateRange:e.config=rj();break}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t}}));function Cb(e,t){if(e===void 0)return e;if(t._name==="date-range")try{return e.map(r=>{const i=_n.default.tz(r,"UTC").format(t.inputFormat);return i!=null?i:r})}catch(n){return console.error(n),e}return e}function _b(e){return e.reduce((t,n)=>(t[n.key]=Cb(n.config.default_value,n.config),t),{})}function lj(e,t,n){N.addDisposer(e,N.addMiddleware(e,(r,i)=>{i(r,()=>{N.getType(r.context)===t&&r.type==="action"&&n(r.name,r.context)})}))}const Eb=N.types.model("FiltersModel",{current:N.types.optional(N.types.array($c),[]),values:N.types.optional(N.types.frozen(),{}),previewValues:N.types.optional(N.types.frozen(),{})}).views(e=>({get firstID(){if(e.current.length!==0)return e.current[0].id},get inOrder(){return Se.default.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return Se.default.sortBy(e.current.filter(n=>n.visibleInViewsIDs.includes(t)),"order")},get firstFilterValueKey(){var t;return(t=Object.keys(e.values)[0])!=null?t:""},get keyLabelMap(){return e.current.reduce((t,n)=>(t[n.key]=n.label,t),{})}})).actions(e=>({replace(t){e.current=N.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},setValues(t){e.values=t},setValueByKey(t,n){e.values={...e.values,[t]:n}},getValueByKey(t){return e.values[t]},refreshValues(){console.log("refreshing values"),e.values=_b(e.current)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){lj(e.current,$c,(n,r)=>{if(n==="setType"){const i=Cb(r.config.default_value,r.config);e.setValueByKey(r.key,i),e.updatePreviewValues({...e.previewValues,[r.key]:i})}})}return{afterCreate(){t()}}});function Tb(e){return{current:e,values:_b(e)}}const uj=N.types.model("QueryModel",{id:N.types.string,name:N.types.string,type:N.types.enumeration("DataSourceType",[Sn.Postgresql,Sn.MySQL,Sn.HTTP]),key:N.types.string,sql:N.types.string,pre_process:N.types.optional(N.types.string,""),post_process:N.types.optional(N.types.string,""),run_by:N.types.optional(N.types.array(N.types.string),[])}).views(e=>({get valid(){return e.id&&e.type&&e.key&&e.name?e.type===Sn.HTTP?!!e.pre_process:!!e.sql:!1},get json(){const{id:t,name:n,type:r,key:i,sql:o,run_by:a,pre_process:s,post_process:u}=e;return{id:t,name:n,type:r,key:i,sql:o,run_by:a,pre_process:s,post_process:u}},get conditionOptions(){const{context:t,mock_context:n,filterValues:r}=N.getRoot(e).payloadForSQL,i=Object.keys({...n,...t}).map(s=>`context.${s}`),o=Object.keys(r).map(s=>`filters.${s}`);return[...i,...o].map(s=>({label:s.split(".")[1],value:s,group:Se.default.capitalize(s.split(".")[0])}))},get unmetRunByConditions(){const{run_by:t}=e;if(t.length===0)return[];const{context:n,mock_context:r,filterValues:i}=N.getRoot(e).payloadForSQL,o={context:{...r,...n},filters:i};return t.filter(a=>{const s=Se.default.get(o,a);return Array.isArray(s)?s.length===0:typeof s=="number"?Number.isNaN(s):!s})}})).views(e=>({get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=N.getRoot(e).filters,n=e.unmetRunByConditions.filter(i=>i.startsWith("context.")).map(i=>i.split("context.")[0]),r=e.unmetRunByConditions.filter(i=>i.startsWith("filters.")).map(i=>Se.default.get({filters:t},i)).filter(i=>!!i);return{context:n,filters:r}}})).actions(e=>({setName(t){e.name=t},setKey(t){e.key=t},setType(t){e.type=t},setSQL(t){e.sql=t},setRunBy(t){e.run_by.length=0,e.run_by.push(...t)},setPreProcess(t){e.pre_process=t},setPostProcess(t){e.post_process=t}})),Mb=N.types.compose("QueryModel",uj,N.types.model({state:N.types.optional(N.types.enumeration(["idle","loading","error"]),"idle"),data:N.types.optional(N.types.array(N.types.frozen()),[]),error:N.types.frozen()})).views(e=>({get formattedSQL(){const{context:t,mock_context:n,sqlSnippets:r,filterValues:i}=N.getRoot(e).payloadForSQL;return hm(e.sql,t,n,r,i)},get typedAsSQL(){return[Sn.Postgresql,Sn.MySQL].includes(e.type)},get typedAsHTTP(){return[Sn.HTTP].includes(e.type)},get datasource(){const{key:t,type:n}=e;return N.getRoot(e).datasources.find({type:n,key:t})}})).views(e=>({get stateMessage(){if(e.state!=="idle")return"";if(!e.runByConditionsMet){const{context:t,filters:n}=e.conditionNames;if(t.length===0&&n.length===0)return"Waiting";const r=[];return t.length>0&&r.push(`context: ${t.join(", ")}`),n.length>0&&r.push(`filter${n.length>1?"s":""}: ${n.join(", ")}`),r.length===2&&r.splice(1,0,"and"),r.unshift("Waiting for"),r.join(" ")}return e.data.length>0?"":"Empty Data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:N.flow(function*(){var t;if(!!e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{context:n,mock_context:r,sqlSnippets:i,filterValues:o}=N.getRoot(e).payloadForSQL;e.data=yield*N.toGenerator(z$({context:n,mock_context:r,sqlSnippets:i,title:e.name,query:e.json,filterValues:o},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(!Po.default.isCancel(n)){e.data.length=0;const r=H.get(n,"message","unkown error");e.error=H.get(n,"response.data.detail.message",r),e.state="error"}}}}),runHTTP:N.flow(function*(){var t;if(console.log("runHTTP, ",e.datasource),!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{context:n,mock_context:r,filterValues:i}=N.getRoot(e).payloadForSQL;e.data=yield*N.toGenerator(F$({context:n,mock_context:r,query:e.json,filterValues:i,datasource:e.datasource},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(console.error(n),!Po.default.isCancel(n)){e.data.length=0;const r=H.get(n,"message","unkown error");e.error=H.get(n,"response.data.detail.message",r),e.state="error"}}}})})).actions(e=>({fetchData:e.typedAsHTTP?e.runHTTP:e.runSQL,beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){N.addDisposer(e,zt.reaction(()=>{var t;return e.typedAsHTTP?`${e.id}--${e.key}--${e.pre_process}--${e.post_process}--${(t=e.datasource)==null?void 0:t.id}`:`${e.id}--${e.key}--${e.formattedSQL}`},e.fetchData,{fireImmediately:!0,delay:0}))}})),Ob=N.types.model("QueriesModel",{current:N.types.optional(N.types.array(Mb),[])}).views(e=>({get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},get options(){return e.current.map(t=>({value:t.id,label:t.name}))}})).views(e=>({get json(){return e.current.filter(t=>t.id).map(t=>t.json)}})).actions(e=>({replace(t){e.current=N.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},downloadAllData(){const t=e.current.map(({name:n,data:r})=>({id:n,data:r.toJSON()}));T$(t)},downloadDataByQueryID(t){if(!t){console.log("[downloadDataByQueryID] query not found");return}const{name:n,data:r}=t,i=pm(r);_$(n,i)},refetchDataByQueryID(t){const n=e.findByID(t);if(!n){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return n.fetchData()},removeQuery(t){const n=e.current.find(r=>r.id===t);n&&(N.detach(n),e.current.remove(n))}})),Db=N.types.model("SQLSnippetModel",{key:N.types.string,value:N.types.string}).views(e=>({get json(){const{key:t,value:n}=e;return{key:t,value:n}},isADuplicatedKey(t){return!t||t===e.key?!1:!!N.getParent(e,2).findByKey(t)}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.value=t}})),Rb=N.types.model("SQLSnippetsModel",{current:N.types.optional(N.types.array(Db),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,n)=>(t[n.key]=n.value,t),{})},get firstKey(){if(e.current.length!==0)return e.current[0].key},findByKey(t){return e.current.find(n=>n.key===t)}})).actions(e=>({replace(t){e.current=N.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},replaceByIndex(t,n){e.current.splice(t,1,n)}})),kb=N.types.model("ContextModel",{current:N.types.optional(N.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}})),cj=N.types.model("DataSourcesModel",{list:N.types.optional(N.types.frozen(),[])}).views(e=>({find({type:t,key:n}){return e.list.find(r=>r.key===n&&r.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list=t}})),dj=N.types.model("MockContextModel",{current:N.types.optional(N.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}})),Ab=N.types.model("ViewModel_Division",{_name:N.types.literal(wt.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})).actions(e=>({})),fj=()=>Ab.create({_name:wt.Division}),pj=N.types.model("CustomModalTitleModel",{enabled:N.types.optional(N.types.boolean,!1),func_content:N.types.optional(N.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:n}=e;return{enabled:t,func_content:n}},get value(){const{enabled:t,func_content:n}=e,r=N.getParent(e,2),i=N.getRoot(e);if(!t)return r.name;try{const o={filters:i.filters.values,context:i.context.current};return new Function(`return ${n}`)()(o)}catch(o){return console.error(o),r.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:n}){e.enabled=t,e.func_content=n}})),Pb=N.types.model("ViewModel_Modal",{_name:N.types.literal(wt.Modal),width:N.types.string,height:N.types.string,custom_modal_title:N.types.optional(pj,Pu)}).views(e=>({get json(){const{_name:t,width:n,height:r,custom_modal_title:i}=e;return{_name:t,width:n,height:r,custom_modal_title:i.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),hj=()=>Pb.create({_name:wt.Modal,width:"90vw",height:"90vh"}),gj=N.types.model("PanelLayoutModel",{x:N.types.number,y:N.types.number,w:N.types.number,h:N.types.number,moved:N.types.optional(N.types.boolean,!1),static:N.types.optional(N.types.boolean,!1)}).views(e=>({get json(){const{x:t,y:n,w:r,h:i,moved:o}=e;return{x:t,y:n,w:r,h:i,moved:o,static:e.static}}})).actions(e=>({set(t){const{x:n,y:r,w:i,h:o,moved:a}=t;e.x=n,e.y=r,e.w=i,e.h=o,e.moved=!!a,e.static=!!t.static}})),vj=N.types.model("PanelStyleBorderModel",{enabled:N.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),mj=N.types.model("PanelStyleModel",{border:vj}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),yj=N.types.model("PanelVizModel",{type:N.types.string,conf:N.types.frozen()}).views(e=>({get json(){return{type:e.type,conf:e.conf}}})).actions(e=>({setType(t){e.type=t},setConf(t){e.conf=t}})),bj=N.types.model({id:N.types.string,title:N.types.string,description:N.types.string,layout:gj,queryID:N.types.string,viz:yj,style:mj,variables:N.types.optional(N.types.array(C4),[])}).views(e=>({get query(){return N.getParentOfType(e,fs).queries.findByID(e.queryID)},get json(){const{id:t,title:n,description:r,queryID:i}=e;return{id:t,title:n,description:r,layout:e.layout.json,queryID:i,viz:e.viz.json,style:e.style.json,variables:e.variables.map(o=>o.json)}}})).actions(e=>({setID(t){e.id=t},setTitle(t){e.title=t},setDescription(t){e.description=t},setQueryID(t){if(N.getParentOfType(e,fs).queries.findByID(t))e.queryID=t;else throw new Error(`Query with id ${t} does not exist`)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)}})),wj=N.types.model("PanelsModel",{list:N.types.optional(N.types.array(bj),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},get layouts(){return e.list.map(t=>({...t.layout.json,i:t.id}))},findByID(t){return e.list.find(n=>n.id===t)}})).actions(e=>({replace(t){e.list=N.castToSnapshot(t)},addANewPanel(){const t=St.randomId();e.list.push({id:t,layout:{x:0,y:1/0,w:3,h:15},title:`Panel - ${t}`,description:"<p><br></p>",queryID:"",viz:{type:Tc.name,conf:Tc.createConfig()},style:{border:{enabled:!0}}})},append(t){e.list.push(t)},remove(t){e.list.splice(t,1)},removeByID(t){const n=e.list.findIndex(r=>r.id===t);n!==-1&&e.list.splice(n,1)},duplicateByID(t){const n=e.list.find(r=>r.id===t);if(!n){console.error(new Error(`[duplicate panel] Can't find a panel by id[${t}]`));return}e.list.push({...n.json,id:St.randomId(),layout:{...n.layout,x:0,y:1/0,moved:!1}})},replaceByIndex(t,n){e.list.splice(t,1,n)}})),Nb=N.types.model({id:N.types.identifier,name:N.types.string,type:N.types.enumeration("EViewComponentType",[wt.Division,wt.Modal]),config:N.types.union(Ab,Pb),panels:wj}).views(e=>({get json(){const{id:t,name:n,type:r,config:i}=e;return{id:t,name:n,type:r,config:i.json,panels:e.panels.json}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case wt.Division:e.config=fj();break;case wt.Modal:e.config=hj();break}e.type=t}}})).actions(e=>({})),Ib=N.types.model("ViewsModel",{current:N.types.optional(N.types.array(Nb),[]),visibleViewIDs:N.types.array(N.types.string),idOfVIE:N.types.string}).views(e=>({get json(){return e.current.map(t=>t.json)},findByID(t){return e.current.find(n=>n.id===t)},get isVIETheFirstView(){return e.current.length===0||!e.idOfVIE?!1:e.current[0].id===e.idOfVIE},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:n})=>n===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:n})=>t.has(n))},get VIE(){return e.current.find(({id:t})=>t===e.idOfVIE)},get options(){return e.current.map(t=>({label:t.name,value:t.id,type:t.type}))}})).actions(e=>({replace(t){e.current.replace(t)},addANewView(t,n,r){e.current.push({id:t,name:t,type:n,config:r,panels:{list:[]}})},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(r=>r.id===t);n!==-1&&e.current.splice(n,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},setIDOfVIE(t){e.idOfVIE=t,e.visibleViewIDs.length=0,e.visibleViewIDs.push(t)},addAPanelToVIE(){var t;(t=e.VIE)==null||t.panels.addANewPanel()},appendToVisibles(t){new Set(e.visibleViewIDs.map(r=>r)).has(t)||e.visibleViewIDs.push(t)}})).actions(e=>({addARandomNewView(){const t=St.randomId();e.addANewView(t,wt.Division,{_name:wt.Division}),e.setIDOfVIE(t)},removeVIE(){e.current.length!==1&&(e.removeByID(e.idOfVIE),e.setIDOfVIE(e.current[0].id))},rmVisibleViewID(t){const n=e.visibleViewIDs.findIndex(r=>r===t);n!==-1&&e.visibleViewIDs.splice(n,1)}}));function $b(e){const t=e.length>0?[e[0].id]:[],n=e.length>0?e[0].id:"";return{current:e.map(i=>{const{_name:o=i.type}=i.config;return{...i,config:{...i.config,_name:o},panels:{list:i.panels}}}),visibleViewIDs:t,idOfVIE:n}}const xj=N.types.model({id:N.types.identifier,name:N.types.string,version:N.types.string,datasources:cj,filters:Eb,queries:Ob,sqlSnippets:Rb,views:Ib,context:kb,mock_context:dj,origin:N.types.maybe(N.types.frozen())}).views(e=>({get filtersChanged(){const t="filters.current";return!H.isEqual(N.getSnapshot(H.get(e,t)),H.get(e.origin,t))},get queriesChanged(){const t="queries.current",n=N.getSnapshot(H.get(e,t)).map(r=>H.pick(r,["id","name","key","type","sql","run_by","pre_process","post_process"]));return!H.isEqual(n,H.get(e.origin,t))},get sqlSnippetsChanged(){const t="sqlSnippets.current";return!H.isEqual(N.getSnapshot(H.get(e,t)),H.get(e.origin,t))},get viewsChanged(){const t="views.current";return!H.isEqual(N.getSnapshot(H.get(e,t)),H.get(e.origin,t))},get mockContextChanged(){const t="mock_context.current";return!H.isEqual(H.get(e,t),H.get(e.origin,t))}})).views(e=>({get payloadForSQL(){return{context:e.context.current,mock_context:e.mock_context.current,sqlSnippets:e.sqlSnippets.current,filterValues:e.filters.values}},get changed(){return e.filtersChanged||e.queriesChanged||e.sqlSnippetsChanged||e.viewsChanged||e.mockContextChanged},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(),dataProxy:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],dataProxy:null,len:0,state:"idle",error:void 0}},getDataStateByID(t){var n,r;return(r=(n=e.queries.findByID(t))==null?void 0:n.state)!=null?r:[]},getDataErrorByID(t){var n,r;return(r=(n=e.queries.findByID(t))==null?void 0:n.error)!=null?r:[]}})).views(e=>({findDependingPanels(t){return e.views.current.flatMap(n=>n.panels.list.filter(r=>r.queryID===t).map(r=>r.title))}})).actions(e=>({reset(){N.applySnapshot(e.filters.current,e.origin.filters.current),N.applySnapshot(e.queries.current,e.origin.queries.current),N.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),N.applySnapshot(e.views.current,e.origin.views.current),e.mock_context.current=e.origin.mock_context.current},resetFilters(){N.applySnapshot(e.filters.current,e.origin.filters.current)}})),fs=N.types.snapshotProcessor(xj,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=N.castToSnapshot(e.queries.current.map(n=>H.pick(n,["id","key","type","sql"])));return H.defaults({},{queries:{current:t}},e)}});function Lc({id:e,name:t,version:n,filters:r,views:i,definition:{queries:o,sqlSnippets:a,mock_context:s={}}},u,c){return fs.create({id:e,name:t,version:n,datasources:{list:u},filters:Tb(r),queries:{current:o},sqlSnippets:{current:a},context:{current:c},mock_context:{current:s},views:$b(i)})}function Vc(e){return W.default.useCallback(t=>t.provideValue($t.pluginManager,e.pluginManager).provideValue($t.vizManager,e.vizManager).provideValue($t.colorManager,e.colorManager),[])}const tG="",Sj=le.observer(function({context:t,dashboard:n,update:r,className:i="dashboard",config:o,fullScreenPanelID:a,setFullScreenPanelID:s}){gm(o);const{data:u=[]}=tt.useRequest(Ru),[c,d]=W.default.useState(!1),p=W.default.useMemo(()=>Lc(n,u,t),[n]);Wc(p,!0),W.default.useEffect(()=>{p.context.replace(t)},[t]),W.default.useEffect(()=>{p.datasources.replace(u)},[u]);const h=async()=>{const m=[...p.queries.json],b=[...p.sqlSnippets.json],y=[...p.views.json],_={...p.mock_context.current},S={...n,filters:[...p.filters.current],views:y,definition:{sqlSnippets:b,queries:m,mock_context:_}};await r(S)},g=tt.useCreation(kc,[]),v=Vc(g);return l(ps.ModalsProvider,{children:l(ws,{value:p,children:l(vn.Provider,{value:{layoutFrozen:c,freezeLayout:d,inEditMode:!0,inUseMode:!1},children:l(f.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:l(Fn.Provider,{value:g,children:l(Io,{configure:v,children:p.views.visibleViews.map(m=>l(vb,{view:m,saveDashboardChanges:h,fullScreenPanelID:a,setFullScreenPanelID:s},m.id))})})})})})})}),Cj=le.observer(({context:e,dashboard:t,className:n="dashboard",config:r,fullScreenPanelID:i,setFullScreenPanelID:o})=>{gm(r);const{data:a=[]}=tt.useRequest(Ru),s=W.default.useMemo(()=>Lc(t,a,e),[t]);Wc(s,!1),W.default.useEffect(()=>{s.context.replace(e)},[e]),W.default.useEffect(()=>{s.datasources.replace(a)},[a]);const u=tt.useCreation(kc,[]),c=Vc(u);return l(ps.ModalsProvider,{children:l(ws,{value:s,children:l(vn.Provider,{value:{layoutFrozen:!0,freezeLayout:Se.default.noop,inEditMode:!1,inUseMode:!0},children:l(f.Box,{className:`${n} dashboard-root`,children:l(Fn.Provider,{value:u,children:l(Io,{configure:c,children:s.views.visibleViews.map(d=>l(mb,{view:d,fullScreenPanelID:i,setFullScreenPanelID:o},d.id))})})})})})})});var Lb={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(fn,function(){var n={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(i,o,a){var s,u=function(h,g,v){v===void 0&&(v={});var m=new Date(h),b=function(y,_){_===void 0&&(_={});var S=_.timeZoneName||"short",C=y+"|"+S,E=r[C];return E||(E=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:y,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:S}),r[C]=E),E}(g,v);return b.formatToParts(m)},c=function(h,g){for(var v=u(h,g),m=[],b=0;b<v.length;b+=1){var y=v[b],_=y.type,S=y.value,C=n[_];C>=0&&(m[C]=parseInt(S,10))}var E=m[3],M=E===24?0:E,R=m[0]+"-"+m[1]+"-"+m[2]+" "+M+":"+m[4]+":"+m[5]+":000",L=+h;return(a.utc(R).valueOf()-(L-=L%1e3))/6e4},d=o.prototype;d.tz=function(h,g){h===void 0&&(h=s);var v=this.utcOffset(),m=this.toDate(),b=m.toLocaleString("en-US",{timeZone:h}),y=Math.round((m-new Date(b))/1e3/60),_=a(b).$set("millisecond",this.$ms).utcOffset(15*-Math.round(m.getTimezoneOffset()/15)-y,!0);if(g){var S=_.utcOffset();_=_.add(v-S,"minute")}return _.$x.$timezone=h,_},d.offsetName=function(h){var g=this.$x.$timezone||a.tz.guess(),v=u(this.valueOf(),g,{timeZoneName:h}).find(function(m){return m.type.toLowerCase()==="timezonename"});return v&&v.value};var p=d.startOf;d.startOf=function(h,g){if(!this.$x||!this.$x.$timezone)return p.call(this,h,g);var v=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return p.call(v,h,g).tz(this.$x.$timezone,!0)},a.tz=function(h,g,v){var m=v&&g,b=v||g||s,y=c(+a(),b);if(typeof h!="string")return a(h).tz(b);var _=function(M,R,L){var F=M-60*R*1e3,A=c(F,L);if(R===A)return[F,R];var O=c(F-=60*(A-R)*1e3,L);return A===O?[F,A]:[M-60*Math.min(A,O)*1e3,Math.max(A,O)]}(a.utc(h,m).valueOf(),y,b),S=_[0],C=_[1],E=a(S).utcOffset(C);return E.$x.$timezone=b,E},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(h){s=h}}})})(Lb);const _j=Lb.exports;var Vb={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(fn,function(){var n="minute",r=/[+-]\d\d(?::?\d\d)?/g,i=/([+-]|\d\d)/g;return function(o,a,s){var u=a.prototype;s.utc=function(m){var b={date:m,utc:!0,args:arguments};return new a(b)},u.utc=function(m){var b=s(this.toDate(),{locale:this.$L,utc:!0});return m?b.add(this.utcOffset(),n):b},u.local=function(){return s(this.toDate(),{locale:this.$L,utc:!1})};var c=u.parse;u.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),c.call(this,m)};var d=u.init;u.init=function(){if(this.$u){var m=this.$d;this.$y=m.getUTCFullYear(),this.$M=m.getUTCMonth(),this.$D=m.getUTCDate(),this.$W=m.getUTCDay(),this.$H=m.getUTCHours(),this.$m=m.getUTCMinutes(),this.$s=m.getUTCSeconds(),this.$ms=m.getUTCMilliseconds()}else d.call(this)};var p=u.utcOffset;u.utcOffset=function(m,b){var y=this.$utils().u;if(y(m))return this.$u?0:y(this.$offset)?p.call(this):this.$offset;if(typeof m=="string"&&(m=function(E){E===void 0&&(E="");var M=E.match(r);if(!M)return null;var R=(""+M[0]).match(i)||["-",0,0],L=R[0],F=60*+R[1]+ +R[2];return F===0?0:L==="+"?F:-F}(m),m===null))return this;var _=Math.abs(m)<=16?60*m:m,S=this;if(b)return S.$offset=_,S.$u=m===0,S;if(m!==0){var C=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(S=this.local().add(_+C,n)).$offset=_,S.$x.$localOffset=C}else S=this.utc();return S};var h=u.format;u.format=function(m){var b=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,b)},u.valueOf=function(){var m=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*m},u.isUTC=function(){return!!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var g=u.toDate;u.toDate=function(m){return m==="s"&&this.$offset?s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():g.call(this)};var v=u.diff;u.diff=function(m,b,y){if(m&&this.$u===m.$u)return v.call(this,m,b,y);var _=this.local(),S=s(m).local();return v.call(_,S,b,y)}}})})(Vb);const Ej=Vb.exports,Tj=()=>Promise.resolve().then(()=>oL).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));_n.default.extend(Ej),_n.default.extend(_j),_n.default.tz.setDefault("UTC"),pe.ContextModel=kb,pe.Dashboard=Sj,pe.DashboardFilterType=om,pe.DashboardMode=im,pe.DashboardModel=fs,pe.EViewComponentType=wt,pe.FilterModel=$c,pe.FiltersModel=Eb,pe.LayoutStateContext=vn,pe.MainDashboardView=vb,pe.ModelContextProvider=ws,pe.Panel=ds,pe.PanelContextProvider=ed,pe.QueriesModel=Ob,pe.QueryModel=Mb,pe.ReadOnlyDashboard=Cj,pe.ReadOnlyDashboardView=mb,pe.SQLSnippetModel=Db,pe.SQLSnippetsModel=Rb,pe.ViewModel=Nb,pe.ViewsModel=Ib,pe.createDashboardModel=Lc,pe.createDashboardViewsModel=$b,pe.getInitialFiltersPayload=Tb,pe.getVersion=Tj,pe.useModelContext=ot,pe.usePanelContext=Gt,pe.useTopLevelServices=Vc,Object.defineProperties(pe,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
292
+ `),Rc={func_content:ob,horizontal_align:"left",font_size:"14px",font_weight:"normal"},T5=le.observer(({context:e})=>{const t=ot(),{value:n=Rc}=Ze(e.instanceData,"config"),{variables:r}=e,{func_content:i,horizontal_align:o,font_size:a,font_weight:s}=n,u=x.useMemo(()=>new Function(`return ${i}`)()({data:e.data,variables:r,filters:t.filters.values,context:t.context.current}),[i,e.data,r,t.filters.values,t.context.current]);return l(f.Text,{align:o,weight:s,sx:{fontSize:a},children:u})}),M5=({value:e,onChange:t})=>{const n=r=>{!r||t(r)};return l(f.Box,{sx:{position:"relative"},children:l(Gn.default,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},O5=x.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:i,setFalse:o}]=tt.useBoolean(),[a,s]=x.useState(e),u=()=>{o(),t(a)},c=()=>{o(),s(e)},d=()=>{s(ob)};return x.useEffect(()=>{s(e)},[e]),w(De,{children:[l(f.Button,{variant:"filled",mt:24,onClick:i,sx:{flexGrow:0},children:"Edit Content"}),l(f.Modal,{size:800,title:"Text content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,children:r&&w(f.Stack,{children:[l(M5,{value:a,onChange:s}),w(f.Group,{position:"apart",children:[l(f.Button,{onClick:d,color:"red",leftIcon:l(oe.Recycle,{size:20}),children:"Rest"}),w(f.Group,{position:"right",children:[l(f.Button,{onClick:c,variant:"subtle",children:"Cancel"}),l(f.Button,{onClick:u,children:"OK"})]})]})]})})]})}),D5=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}];function R5({context:e}){const{value:t,set:n}=Ze(e.instanceData,"config"),r=x.useMemo(()=>H.defaultsDeep({},t,Rc),[t]),i=x.useMemo(()=>{const{func_content:h,horizontal_align:g,font_size:v,font_weight:m}=r;return{func_content:h,horizontal_align:g,font_size:v,font_weight:m}},[r]);x.useEffect(()=>{!H.isEqual(r,i)&&(console.log("config malformed, resetting to defaults",r,i),n(i))},[r,i]);const{control:o,handleSubmit:a,watch:s,getValues:u,reset:c}=G.useForm({defaultValues:i});W.default.useEffect(()=>{c(i)},[i]),s(["func_content","horizontal_align","font_size","font_weight"]);const d=u(),p=W.default.useMemo(()=>!Se.default.isEqual(d,r),[d,r]);return l(f.Stack,{mt:"md",spacing:"xs",children:w("form",{onSubmit:a(n),children:[w(f.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(f.Text,{weight:500,children:"Configurations"}),l(f.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!p,children:l(oe.DeviceFloppy,{size:20})})]}),w(f.Stack,{spacing:10,children:[l(G.Controller,{name:"func_content",control:o,render:({field:h})=>l(O5,{...h})}),l(f.Divider,{mt:10,mb:-10,variant:"dashed",label:"Style",labelPosition:"center"}),l(G.Controller,{name:"horizontal_align",control:o,render:({field:h})=>l(f.Select,{label:"Horizontal Alignment",data:D5,...h})}),l(G.Controller,{name:"font_size",control:o,render:({field:h})=>l(f.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},...h})}),l(f.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:l(G.Controller,{name:"font_weight",control:o,render:({field:h})=>l(ey,{label:"Font Weight",...h})})})]})]})})}class k5 extends en{constructor(){super(...arguments);ke(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const A5={displayName:"Text",migrator:new k5,name:"text",viewRender:T5,configRender:R5,createConfig(){return{version:1,config:H.cloneDeep(Rc)}}},P5=[{value:"#25262B",name:"Dark"},{value:"#868E96",name:"Gray"},{value:"#FA5252",name:"Red"},{value:"#E64980",name:"Pink"},{value:"#BE4BDB",name:"Grape"},{value:"#7950F2",name:"Violet"},{value:"#4C6EF5",name:"Indigo"},{value:"#228BE6",name:"Blue"},{value:"#15AABF",name:"Cyan"},{value:"#12B886",name:"Teal"},{value:"#40C057",name:"Green"},{value:"#82C91E",name:"Lime"},{value:"#FAB005",name:"Yellow"},{value:"#FD7E14",name:"Orange"}].map(e=>({name:e.name,value:e.value,type:"single",category:"basic"})),N5=[J2,eL,rL,nL,tL,iL],ab=()=>({id:"dashboard",version:$u,manifest:{viz:[Tc,t3,A5,WF,a3,xF,pL,yV,vF,jz,E5,AF,GF,kB,AV],color:[...P5,...N5]}}),Do=new sL,$t={pluginManager:Hn("pluginManager"),vizManager:Hn("vizManager"),colorManager:Hn("colorManager"),instanceScope:{panelModel:Hn("panelModel"),vizInstance:Hn("vizInstance"),interactionManager:Hn("interactionManager"),migrator:Hn("migrator"),operationManager:Hn("operationManager"),triggerManager:Hn("triggerManager")}},kc=()=>{try{Do.install(ab())}catch{}const e=new X2(Do),t=new aL(Do);return{pluginManager:Do,vizManager:e,colorManager:t}},Fn=x.createContext(kc());try{Do.install(ab())}catch{}function I5(e,t){const{value:n,set:r}=Ze(e.operation.operationData,"config"),[i,o]=x.useState(H.defaults({},n,t)),a=async()=>{await r(i)};return x.useEffect(()=>{o(H.defaults({},n,t))},[n]),{config:i,setConfig:o,commit:a}}function $5(e){const{config:t,setConfig:n,commit:r}=I5(e,{urlTemplate:"",openInNewTab:!0});async function i(){await r()}async function o(s){n({...t,openInNewTab:s}),await r()}const a=s=>n({...t,urlTemplate:s.currentTarget.value});return w(f.Stack,{children:[l(f.TextInput,{label:"Url",value:t.urlTemplate,onChange:a,onBlur:i}),l(f.Switch,{label:"Open in new Tab",checked:t.openInNewTab,onChange:s=>o(s.currentTarget.checked)})]})}async function L5(e,t){const{urlTemplate:n,openInNewTab:r}=await t.operationData.getItem("config");window.dispatchEvent(new CustomEvent("open-link",{detail:{urlTemplate:n,openInNewTab:r,payload:e}}))}class V5 extends en{constructor(){super(...arguments);ke(this,"VERSION",1)}configVersions(){this.version(1,n=>n)}}const z5={displayName:"Open Link",id:"builtin:op:open-link",configRender:$5,run:L5,migrator:new V5,createDefaultConfig:()=>({version:1,config:{urlTemplate:"",openInNewTab:!0}})};function F5(e){const{value:t,set:n}=Ze(e.operationData,"config"),r=i=>void n({template:i});return[(t==null?void 0:t.template)||"",r]}function B5(e){const[t,n]=F5(e.operation);return l(f.TextInput,{defaultValue:t,onBlur:r=>n(r.currentTarget.value),label:"console.log"})}async function j5(e,t){const n=await t.operationData.getItem("config"),r=H.template(n.template||"");console.log("run with payload",e),console.log(r(e))}const G5={displayName:"console.log (debug)",id:"builtin:op:debug",configRender:B5,run:j5},K5=le.observer(e=>{const t=ot(),{value:n,set:r}=Ze(e.operation.operationData,"config");console.log({value:n,viewID:n==null?void 0:n.viewID});const i=(n==null?void 0:n.viewID)||"",o=a=>void r({viewID:a});return l(f.Select,{defaultValue:i,value:i,onChange:o,label:"View",data:t.views.options})});async function H5(e,t){const r=(await t.operationData.getItem("config")).viewID;window.dispatchEvent(new CustomEvent("open-view",{detail:{viewID:r}}))}const q5={displayName:"Open View",id:"builtin:op:open_view",configRender:K5,run:H5},W5={dictionary:{}},U5=le.observer(e=>{const t=ot(),{value:n=W5,set:r}=Ze(e.operation.operationData,"config"),{dictionary:i={}}=n,o=(u,c)=>{r({dictionary:{...i,[u]:c}})},a=()=>{o(t.filters.firstFilterValueKey,"")},s=u=>{const c={...i};delete c[u],r({dictionary:c})};return w(f.Stack,{spacing:10,children:[l(f.Text,{children:"Mapping Rules"}),Object.entries(i).map(([u,c])=>w(f.Flex,{justify:"space-between",gap:10,children:[l(f.TextInput,{label:"Payload key",value:c,onChange:d=>{o(u,d.currentTarget.value)},sx:{flexGrow:1}}),l(vt,{data:[t.filters.values],value:u,onChange:d=>{o(d,c)},label:"Filter key",sx:{flexGrow:1}}),l(f.ActionIcon,{onClick:()=>s(u),sx:{marginTop:"26px",flexGrow:0},children:l(oe.Trash,{size:14,color:"red"})})]},u)),l(f.Button,{size:"xs",onClick:a,sx:{alignSelf:"center",width:"300px"},children:"Add one mapping rule"})]})});async function Y5(e,t){const r=(await t.operationData.getItem("config")).dictionary;window.dispatchEvent(new CustomEvent("set-filter-values",{detail:{dictionary:r,payload:e}}))}const X5={displayName:"Set Filter Values",id:"builtin:op:set_filter_values",configRender:U5,run:Y5},Q5={filter_keys:[]},Z5=le.observer(e=>{const t=ot(),{value:n=Q5,set:r}=Ze(e.operation.operationData,"config"),{filter_keys:i=[]}=n,o=s=>{r({filter_keys:[...s]})},a=x.useMemo(()=>t.filters.current.map(s=>({label:s.label,value:s.key})),[t.filters.values]);return l(f.Stack,{spacing:10,children:l(f.MultiSelect,{label:"Select Filters to Clear",data:a,value:i,onChange:o})})});async function J5(e,t){const r=(await t.operationData.getItem("config")).filter_keys;window.dispatchEvent(new CustomEvent("clear-filter-values",{detail:{filter_keys:r,payload:e}}))}const us=[G5,z5,q5,X5,{displayName:"Clear Filter Values",id:"builtin:op:clear_filter_values",configRender:Z5,run:J5}];class e4{constructor(t,n=us){ke(this,"attachments");this.operations=n;const r=async i=>{const{id:o,schemaRef:a}=await i.getItem(null);return{id:o,schemaRef:a,operationData:new Ti(i,"data")}};this.attachments=new Iu(t,"__OPERATIONS",r)}async runOperation(t,n){const r=await this.attachments.getInstance(t);if(!r){console.warn(`Operation '${t}' is not defined`);return}const i=this.tryGetSchema(r.schemaRef);if(!i){console.warn(`Operation schema '${r.schemaRef}' is not defined`);return}await i.run(n,r)}tryGetSchema(t){return this.operations.find(n=>n.id===t)}async needMigration(){const n=(await this.attachments.list()).map(async r=>{const i={configData:r.operationData},o=this.tryGetSchema(r.schemaRef),a=o==null?void 0:o.migrator;return a&&await a.needMigration(i)});return(await Promise.all(n)).some(r=>r)}async runMigration(){const n=(await this.attachments.list()).map(async r=>{const i={configData:r.operationData},o=this.tryGetSchema(r.schemaRef),a=o==null?void 0:o.migrator;a&&await a.needMigration(i)&&await a.migrate(i)});await Promise.all(n)}async createOrGetOperation(t,n){var a,s;if(!this.getOperationSchemaList().some(u=>u.id===n.id))throw new Error(`Operation schema '${n.id}' is not defined`);const i=await this.attachments.getInstance(t);return!i||i.schemaRef!==n.id?await this.attachments.create(t,{id:t,schemaRef:n.id,data:(s=(a=n.createDefaultConfig)==null?void 0:a.call(n))!=null?s:{}}):i}getOperationList(){return this.attachments.list()}getOperationSchemaList(){return this.operations}removeOperation(t){return this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}}class Ac{constructor(t,n,r){ke(this,"operationManager");ke(this,"triggerManager");ke(this,"attachments");this.operationManager=new e4(t,r),this.triggerManager=new mL(t,n);const i=async o=>{const{id:a,triggerRef:s,operationRef:u}=await o.getItem(null);return{id:a,triggerRef:s,operationRef:u}};this.attachments=new Iu(t,"__INTERACTIONS",i)}async addInteraction(t,n){const r=t.id,i=n.id,o=`[${r}]:[${i}]`;await this.attachments.create(o,{id:o,triggerRef:r,operationRef:i})}getInteractionList(){return this.attachments.list()}async removeInteraction(t){const n=await this.attachments.getInstance(t);if(!n)return;const{triggerRef:r,operationRef:i}=n;await this.getTriggerRefCount(r)<=1&&await this.triggerManager.removeTrigger(r),await this.getOperationRefCount(i)<=1&&await this.operationManager.removeOperation(i),await this.attachments.remove(t)}async getOperationRefCount(t){return(await this.getInteractionList()).filter(r=>r.operationRef===t).length}async getTriggerRefCount(t){return(await this.getInteractionList()).filter(r=>r.triggerRef===t).length}async runInteraction(t,n){const i=(await this.getInteractionList()).filter(o=>o.triggerRef===t);await Promise.all(i.map(async o=>{try{return await this.operationManager.runOperation(o.operationRef,n)}catch(a){console.warn(`Failed to run operation '${o.operationRef}'`,a)}}))}}function t4(e,t){const[n,r]=x.useState([]);return tt.useAsyncEffect(async()=>{const i=await e.getInteractionList();r(i)},[t]),n}const n4=le.observer(({item:e,manager:t,instance:n,sampleData:r,variables:i,onRemove:o})=>{const{triggerRef:a,operationRef:s}=e,u=K2(t.triggerManager,n);if(tt.useAsyncEffect(async()=>{await u.configTrigger(a,r)},[u,a,r]),u.isReady()){const c=[...u.triggerSchema.payload,...i];return w(f.Group,{children:[l(U2,{model:u}),l(B2,{instance:n,operationId:s,variables:c,operationManager:t.operationManager}),l(f.ActionIcon,{"aria-label":"delete-interaction",variant:"filled",color:"red",onClick:()=>o(e),children:l(oe.Trash,{size:16})})]})}return null}),r4=e=>{const[t,n]=x.useState(0),{interactionManager:r,instance:i,sampleData:o,variables:a}=e,s=t4(r,t),u=async()=>{const h=await r.triggerManager.createOrGetTrigger(St.randomId(),r.triggerManager.getTriggerSchemaList()[0]),g=await r.operationManager.createOrGetOperation(St.randomId(),r.operationManager.getOperationSchemaList()[0]);await r.addInteraction(h,g),n(v=>v+1)};async function c(h){await r.removeInteraction(h.id),n(g=>g+1)}const{data:d=0,loading:p}=tt.useRequest(async()=>{try{return(await r.triggerManager.getTriggerSchemaList()).length}catch{return 0}});return w(f.Stack,{children:[l(f.LoadingOverlay,{visible:p}),d===0&&l(f.Alert,{icon:l(oe.AlertCircle,{size:16}),title:"Unavailable",color:"gray",children:"This visualization does not have available interactions to choose from"}),s.map(h=>l(n4,{onRemove:c,instance:i,sampleData:o,variables:a,item:h,manager:e.interactionManager},h.id)),l(f.Button,{style:{width:"fit-content"},onClick:()=>u(),disabled:d===0,children:"Add interaction"})]})},i4=()=>{const{panel:e,data:t}=Gt(),n=e.viz,{vizManager:r}=x.useContext(Fn),i=e.json,o=tt.useCreation(()=>r.getOrCreateInstance(i),[r,n.type]),a=tt.useCreation(()=>new Ac(o,r.resolveComponent(n.type),us),[o,n.type]);return x.useEffect(()=>o.instanceData.watchItem(null,H.throttle(s=>{e.viz.setConf(s)},100,{leading:!1,trailing:!0})),[o]),{instance:o,vizManager:r,interactionManager:a,sampleData:t,variables:[]}},o4=()=>{const e=i4();return l(r4,{...e})},a4=le.observer(()=>{const{panel:e}=Gt(),[t,n]=W.default.useState(e.description),r=e.description!==t,i=W.default.useCallback(()=>{!r||e.setDescription(t)},[r,t]);return w(f.Stack,{spacing:4,sx:{flexGrow:1},children:[w(f.Group,{align:"end",children:[l(f.Text,{sx:{flexGrow:1},children:"Description"}),l(f.ActionIcon,{variant:"subtle",color:"blue",disabled:!r,onClick:i,children:l(oe.DeviceFloppy,{size:20})})]}),l(ky,{value:t,onChange:n,styles:{root:{flexGrow:1}}})]})}),s4=le.observer(()=>{const{panel:e}=Gt(),{style:t}=e;return l(De,{children:l(f.Switch,{label:"Border",checked:t.border.enabled,onChange:n=>t.border.setEnabled(n.currentTarget.checked)})})}),l4=le.observer(()=>{const{panel:{title:e,style:{border:t}}}=Gt();return l(qr,{children:w(f.Stack,{mx:"auto",mt:"xl",p:"5px",spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:t.enabled?"1px":"0px"},children:[w(f.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[l(f.Group,{children:l(Nm,{})}),l(f.Group,{grow:!0,position:"center",children:l(f.Text,{lineClamp:1,weight:"bold",children:e})}),l(f.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),l(f.Group,{sx:{background:"#eee",flexGrow:1}})]})})}),u4=le.observer(()=>{const{panel:e}=Gt(),{title:t,setTitle:n}=e,[r,i]=St.useInputState(t),o=t!==r,a=W.default.useCallback(()=>{!o||n(r)},[o,r]);return l(f.TextInput,{value:r,onChange:i,label:w(f.Group,{align:"apart",children:[l(f.Text,{sx:{flexGrow:1},children:"Panel Title"}),l(f.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:a,children:l(oe.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function c4(){return w(f.Group,{grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%"},children:[w(f.Stack,{sx:{width:"40%",flexShrink:0,flexGrow:0,height:"100%"},children:[l(f.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),l(s4,{}),l(f.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),l(u4,{}),l(a4,{})]}),l(f.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:l(l4,{})})]})}const d4=le.observer(function(){const t=ot(),{panel:{queryID:n,setQueryID:r}}=Gt(),i=W.default.useMemo(()=>t.queries.current.map(o=>({value:o.id,label:o.name})),[t.queries.current]);return w(f.Stack,{children:[w(f.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[l(f.Text,{children:"Select a Query"}),l(f.Select,{data:i,value:n,onChange:r,allowDeselect:!1,clearable:!1,sx:{flexGrow:"1 !important"}})]}),l(vm,{id:n})]})});var sb=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(sb||{}),cs=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(cs||{});class f4{constructor(t){ke(this,"vizInstance");ke(this,"operationManager");ke(this,"triggerManager");ke(this,"vizManager");ke(this,"runningMigration");ke(this,"panelModel");ke(this,"status","notStarted");this.panelModel=t.getRequired($t.instanceScope.panelModel),this.vizInstance=t.getRequired($t.instanceScope.vizInstance),this.operationManager=t.getRequired($t.instanceScope.operationManager),this.triggerManager=t.getRequired($t.instanceScope.triggerManager),this.vizManager=t.getRequired($t.vizManager)}async createMigrationTask(){const t=[];try{await this.instanceNeedMigration()&&t.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&t.push(()=>this.runInteractionMigration())}catch(n){return console.warn("check migration failed",n),"checkFailed"}if(t.length===0)return"nothingToMigrate";try{return await Promise.all(t.map(n=>n())),"migrated"}catch(n){return console.warn("migration failed",n),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(t=>(this.status="done",t))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await t.migrator.migrate(n)}async instanceNeedMigration(){const t=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData};return t.migrator.needMigration(n)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function lb(e){const{panel:t}=Gt();return x.useCallback(n=>{const r=n.getRequired($t.vizManager),i=r.resolveComponent(e.viz.type);return n.createScoped().provideFactory($t.instanceScope.vizInstance,()=>r.getOrCreateInstance(e)).provideFactory($t.instanceScope.interactionManager,o=>{const a=o.getRequired($t.instanceScope.vizInstance);return new Ac(a,i,us)}).provideFactory($t.instanceScope.operationManager,o=>o.getRequired($t.instanceScope.interactionManager).operationManager).provideFactory($t.instanceScope.triggerManager,o=>o.getRequired($t.instanceScope.interactionManager).triggerManager).provideValue($t.instanceScope.panelModel,t).provideFactory($t.instanceScope.migrator,o=>new f4(o))},[e.viz.type,e.viz.conf])}function ub(e){const[t,n]=x.useState(!1),r=Xc().getRequired($t.instanceScope.migrator);return tt.useAsyncEffect(async()=>{const i=r.status===cs.notStarted;n(r.status===cs.done),r.status===cs.notStarted&&r.runMigration().then(o=>{o===sb.migrated&&i&&(e==null||e())}).finally(()=>{n(!0)})},[r]),t}function cb(e,t){const n=Xc().getRequired($t.instanceScope.vizInstance);return x.useEffect(()=>n.instanceData.watchItem(null,r=>{e(r)}),[e,t.viz.type]),n}function p4({setVizConf:e,...t}){const{panel:n}=t,r=cb(e,n),i=ub(()=>{ko.showNotification({title:`${n.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return tt.useAsyncEffect(async()=>{await r.instanceData.setItem(null,n.viz.conf)},[r,n.viz.type]),i?l(Z2,{...t}):l(f.Text,{children:"Checking update..."})}function h4(e){const{panel:t,setVizConf:n}=e;return cb(n,t),ub(()=>{ko.showNotification({title:`${t.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?l(Q2,{...e}):l(f.Text,{children:"Checking update"})}const Zj="";function g4(e,t){const{vizManager:n}=x.useContext(Fn),{panel:{viz:r,title:i,id:o,description:a,queryID:s,variables:u}}=Gt(),c={title:i,id:o,description:a,queryID:s,viz:r,layout:t},d=lb(c);try{return n.resolveComponent(r.type),l(Io,{configure:d,children:l(h4,{setVizConf:r.setConf,panel:c,data:e,variables:u,vizManager:n})})}catch(p){return console.info(H.get(p,"message")),null}}const v4=["richText","button"],db=le.observer(function({height:t,viz:n,data:r,loading:i,error:o,query:a}){const{ref:s,width:u,height:c}=St.useElementSize(),d=g4(r,{w:u,h:c});if(v4.includes(n.type))return l("div",{className:"viz-root",style:{height:t},ref:s,children:l(qr,{children:d})});if(i)return l("div",{className:"viz-root",style:{height:t},ref:s,children:l(f.LoadingOverlay,{visible:i,exitTransitionDuration:0})});const h=!!o,g=!h&&!!(a!=null&&a.stateMessage),v=!h&&!g;return w("div",{className:"viz-root",style:{height:t},ref:s,children:[h&&l(f.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:o}),g&&l(f.Text,{color:"gray",align:"center",children:a.stateMessage}),v&&l(qr,{children:d})]})}),m4=le.observer(()=>{const{data:e,loading:t,panel:{viz:n}}=Gt();return l(db,{viz:n,data:e,loading:t,height:"100%"})}),Pc=[];function y4(){const{vizManager:e}=x.useContext(Fn);return x.useMemo(()=>e.availableVizList.map(t=>({value:t.name,label:t.displayName})).concat(Pc),[e])}function b4(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function w4(){const{data:e,panel:{variables:t,viz:n,title:r,queryID:i,description:o,setDescription:a,setTitle:s,setQueryID:u,id:c}}=Gt(),{vizManager:d}=x.useContext(Fn),p={title:r,description:o,viz:n,queryID:i,id:c},h={setDescription:a,setQueryID:u,setTitle:s},g=lb(p);try{return d.resolveComponent(p.viz.type),l(Io,{configure:g,children:l(p4,{variables:t,setVizConf:n.setConf,panel:p,panelInfoEditor:h,vizManager:d,data:e})})}catch(v){return console.info(H.get(v,"message")),null}}const x4=le.observer(()=>{const{data:e,panel:{viz:t}}=Gt(),[n,r]=St.useInputState(t.type),i=t.type!==n,{vizManager:o}=x.useContext(Fn),a=W.default.useCallback(()=>{if(!i)return;const g=b4(o,n);t.setType(n),t.setConf(g||{})},[t,i,n]),s=g=>{try{t.setConf(JSON.parse(g))}catch(v){console.error(v)}},u=W.default.useMemo(()=>{var g;return(g=Pc.find(v=>v.value===n))==null?void 0:g.Panel},[n,Pc]),c=w4(),d=u?x.createElement(u,{data:e,conf:t.conf,setConf:t.setConf}):null,p=c||d,h=y4();return w(De,{children:[l(f.Select,{label:"Visualization",value:n,onChange:r,data:h,rightSection:l(f.ActionIcon,{disabled:!i,onClick:a,children:l(oe.DeviceFloppy,{size:20})})}),p,!p&&l(f.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:s})]})});function S4(){return w(f.Group,{grow:!0,noWrap:!0,align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[l(f.Stack,{sx:{width:"40%",flexShrink:0,flexGrow:0,overflow:"scroll",height:"100%"},children:l(x4,{})}),l(f.Box,{sx:{height:"100%",flexGrow:1,maxWidth:"60%"},children:l(m4,{})})]})}const C4=N.types.model("VariableModel",{name:N.types.string,size:N.types.string,weight:N.types.string,color:N.types.union(N.types.model({type:N.types.literal("static"),staticColor:N.types.string}),N.types.model({type:N.types.literal("continuous"),valueRange:N.types.array(N.types.number),colorRange:N.types.array(N.types.string)}),N.types.model({type:N.types.literal("piecewise")})),formatter:N.types.model({output:N.types.enumeration("Output",["number","percent"]),mantissa:N.types.number,average:N.types.optional(N.types.boolean,!1),trimMantissa:N.types.optional(N.types.boolean,!1)}),data_field:N.types.string,aggregation:N.types.union(N.types.model({type:N.types.enumeration(["none","sum","mean","median","min","max"]),config:N.types.frozen()}),N.types.model({type:N.types.literal("quantile"),config:N.types.model({p:N.types.number})}))}).views(e=>({get json(){return N.getSnapshot(e)}}));class _4{constructor(t){ke(this,"origin");ke(this,"copy");this.origin=t,this.copy=N.clone(t),zt.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!H.isEqual(N.getSnapshot(this.origin),N.getSnapshot(this.copy))}commit(){N.applySnapshot(this.origin,N.getSnapshot(this.copy))}update(t){N.applySnapshot(this.copy,t)}}const E4=e=>new _4(e),Nc={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{}},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class T4{constructor(t){ke(this,"panel");ke(this,"selected");this.panel=t,zt.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const t=this.panel.variables.filter(n=>n.name.startsWith(Nc.name)).length;this.panel.addVariable(H.cloneDeep({...Nc,name:`${Nc.name}${t||""}`})),this.selected=H.last(this.panel.variables)}select(t){this.selected=t}remove(t){this.selected===t&&(this.selected=void 0);const n=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!H.isEmpty(this.panel.variables)){const r=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[r]}}}function M4(){const{panel:e}=Gt();return tt.useCreation(()=>new T4(e),[e])}const O4=W.default.forwardRef(function({value:t,onChange:n,data:r,withStyle:i=!0},o){const a=(s,u)=>{const c=Se.default.cloneDeep(t);Se.default.set(c,s,u),n(c)};return w(f.Box,{px:"sm",py:"md",ref:o,children:[w(f.Group,{grow:!0,noWrap:!0,children:[l(f.TextInput,{label:"Name",required:!0,value:t.name,onChange:s=>a("name",s.currentTarget.value)}),l(vt,{label:"Data Field",required:!0,data:r,value:t.data_field,onChange:s=>a("data_field",s)})]}),l(Jm,{label:"Aggregation",value:t.aggregation,onChange:s=>a("aggregation",s)}),l(f.Divider,{my:"xs",label:"Format",labelPosition:"center"}),l(Gr,{value:t.formatter,onChange:s=>a("formatter",s)}),i&&l(ty,{value:t,onChange:n})]})}),fb=f.createStyles(e=>({root:{height:"100%",overflow:"hidden",".var-list-container":{"& > *":{height:"100%"},width:250,height:"100%"},".var-list-actions":{height:"fit-content",flexShrink:0,width:"100%"},".var-list":{flex:"1 1 auto",overflow:"auto",minHeight:0,"& > *":{flex:"0 0 auto"}}},config:{height:"100%",overflow:"auto",paddingRight:10}})),D4=e=>{const{uiModel:t}=e;return l(f.Stack,{className:"var-list",children:t.variables.map(n=>l(f.Button,{variant:t.selected===n?"filled":"subtle",color:"gray",onClick:()=>t.select(n),children:n.name},n.name))})},R4=le.observer(D4),k4=({variable:e,data:t})=>l(f.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:l(f.Paper,{withBorder:!0,p:"md",children:Sy(e,t)})}),A4=le.observer(k4),P4=e=>{const t=tt.useCreation(()=>E4(e.variable),[e.variable]),{classes:n}=fb(),{data:r}=Gt();return w(f.Group,{style:{height:"100%"},align:"start",children:[w(f.Stack,{"data-testid":"variable-editor",align:"stretch",className:n.config,children:[w(f.Group,{position:"right",children:[l(f.ActionIcon,{variant:"filled",disabled:!t.changed,color:"primary",onClick:t.commit,children:l(y$,{})}),l(f.ActionIcon,{color:"red",onClick:()=>e.uiModel.remove(e.variable),children:l(fm,{})})]}),l(O4,{value:N.getSnapshot(t.copy),onChange:t.update,data:r})]}),l(A4,{variable:N.getSnapshot(t.copy),data:r})]})},N4=le.observer(P4),I4=()=>{const e=M4(),{classes:t}=fb();return w(f.Group,{className:t.root,noWrap:!0,align:"start",children:[l(f.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:w(f.Stack,{justify:"space-between",children:[l(f.Box,{className:"var-list-actions",children:l(f.Button,{variant:"light",size:"sm",onClick:e.addNew,fullWidth:!0,children:"Add Variable"})}),l(R4,{uiModel:e})]})}),e.selected?l(De,{children:l(N4,{uiModel:e,variable:e.selected})}):l("span",{children:"Select or create a new variable on right side"})]})},$4=le.observer(I4),L4=le.observer(function({opened:t,close:n}){const{freezeLayout:r}=W.default.useContext(vn),[i,o]=x.useState("Visualization"),{panel:a,loading:s}=Gt(),{id:u,title:c}=a;return W.default.useEffect(()=>{r(t)},[t]),l(f.Modal,{size:"96vw",overflow:"inside",opened:t,onClose:n,title:`Editing Panel - ${c.trim()?c:u}`,trapFocus:!0,onDragStart:d=>{d.stopPropagation()},children:l(f.AppShell,{sx:{height:"90vh",maxHeight:"calc(100vh - 185px)",".mantine-AppShell-body":{height:"100%"},main:{height:"100%",minHeight:"unset",maxHeight:"100%",width:"100%",padding:"16px"}},padding:"md",children:w(f.Tabs,{value:i,onTabChange:o,className:"panel-settings-tabs",children:[w(f.Tabs.List,{children:[l(f.Tabs.Tab,{value:"Data",children:"Data"}),l(f.Tabs.Tab,{value:"Panel",children:"Panel"}),l(f.Tabs.Tab,{value:"Variables",children:"Variables"}),l(f.Tabs.Tab,{value:"Visualization",children:"Visualization"}),l(f.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),w(f.Tabs.Panel,{value:"Data",pt:"sm",children:[l(f.LoadingOverlay,{visible:s,exitTransitionDuration:0}),l(d4,{})]}),l(f.Tabs.Panel,{value:"Panel",pt:"sm",children:i==="Panel"&&l(c4,{})}),l(f.Tabs.Panel,{value:"Variables",pt:"sm",children:i==="Variables"&&l($4,{})}),l(f.Tabs.Panel,{value:"Visualization",pt:"sm",children:i==="Visualization"&&l(S4,{})}),l(f.Tabs.Panel,{value:"Interactions",pt:"sm",children:l(qr,{children:l(o4,{})})})]})})})}),V4=le.observer(({view:e})=>{const t=ot(),n=ps.useModals(),[r,i]=W.default.useState(!1),o=()=>i(!0),a=()=>i(!1),{panel:s}=Gt(),{id:u,query:c}=s,{inEditMode:d}=W.default.useContext(vn),p=()=>c==null?void 0:c.fetchData(),{viewPanelInFullScreen:h,inFullScreen:g}=W.default.useContext(bs),v=()=>{e.panels.duplicateByID(u)},m=()=>n.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>e.panels.removeByID(u)}),b=W.default.useCallback(()=>{h(u)},[u,h]),y=!g&&e.type!==wt.Modal;return w(De,{children:[l(f.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:w(f.Menu,{withinPortal:!0,children:[l(f.Menu.Target,{children:l(f.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),w(f.Menu.Dropdown,{children:[l(f.Menu.Item,{onClick:p,icon:l(oe.Refresh,{size:14}),children:"Refresh"}),l(f.Menu.Item,{onClick:()=>t.queries.downloadDataByQueryID(c),icon:l(oe.Download,{size:14}),children:"Download Data"}),y&&l(f.Menu.Item,{onClick:b,icon:l(oe.ArrowsMaximize,{size:14}),children:"Full Screen"}),d&&w(De,{children:[l(f.Divider,{label:"Edit",labelPosition:"center"}),l(f.Menu.Item,{onClick:o,icon:l(oe.Settings,{size:14}),children:"Settings"}),l(f.Menu.Item,{onClick:v,icon:l(oe.Copy,{size:14}),children:"Duplicate"}),l(f.Menu.Item,{color:"red",onClick:m,icon:l(oe.Trash,{size:14}),children:"Delete"})]})]})]})}),d&&l(L4,{opened:r,close:a})]})}),Jj="",z4=le.observer(function(){const{panel:t}=Gt(),{title:n}=t;return n?l(f.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:l(f.Text,{align:"center",lineClamp:1,weight:"bold",children:n})}):null});function F4(e){return!["richText","button"].includes(e)}const B4={border:"1px solid #e9ecef"},pb={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function j4(e,t,n){return e.style.border.enabled?B4:n||t?pb:{border:"1px dashed transparent"}}const ds=le.observer(function({panel:t,view:n}){const r=ot(),{inEditMode:i}=x.useContext(vn),{data:o,state:a,error:s}=r.getDataStuffByID(t.queryID),u=r.queries.findByID(t.queryID),c=F4(t.viz.type),d=c&&a==="loading",p=t.title?"calc(100% - 25px - 5px)":"100%",h=j4(t,c,i),g=c||i;return l(ed,{value:{panel:t,data:o,loading:d},children:w(f.Box,{className:"panel-root",p:5,pt:0,sx:{...h},children:[l(f.Box,{sx:{position:"absolute",left:0,top:0,height:28,zIndex:310},children:l(Nm,{})}),g&&l(V4,{view:n}),l(z4,{}),l(db,{viz:t.viz,data:o,loading:d,error:s,height:p,query:u})]})})}),hb=le.observer(function({view:t,panel:n,exitFullScreen:r}){return w(f.Stack,{px:"10px",pb:"5px",sx:{height:"100%",flexGrow:1,justifyContent:"flex-start"},children:[l(f.Group,{sx:{flexGrow:0},children:l(f.Button,{variant:"default",size:"sm",onClick:r,leftIcon:l(oe.ArrowLeft,{size:20}),children:"Exit fullscreen"})}),l(f.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:l(ds,{view:t,panel:n})})]})});function gb(e,t,n){const r=e.id==="Main",[i,o]=W.default.useState(()=>r&&e.panels.findByID(t)?t:null),a=W.default.useCallback(d=>{o(d),r&&n(d)},[r,n]),s=W.default.useCallback(()=>{o(null),r&&n("")},[r,n]),u=i?e.panels.findByID(i):null;return{viewPanelInFullScreen:a,exitFullScreen:s,inFullScreen:!!u,fullScreenPanel:u}}const eG="",G4=W.default.forwardRef(({handleAxis:e},t)=>l(f.ActionIcon,{ref:t,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:l(oe.ArrowsMove,{size:16})})),K4=W.default.forwardRef(({handleAxis:e,...t},n)=>l(f.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:-5,right:-5,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:l(oe.ChevronDownRight,{size:16})})),H4=gs.WidthProvider(qc.default),q4=le.observer(function({view:t,className:n="layout",rowHeight:r=10,isDraggable:i,isResizable:o}){const a=W.default.useCallback(s=>{s.forEach(({i:u,...c})=>{const d=t.panels.findByID(u);!d||d.layout.set(c)})},[t]);return l(H4,{onLayoutChange:a,className:`dashboard-layout ${n}`,rowHeight:r,layout:t.panels.layouts,isDraggable:i,isResizable:o,draggableHandle:".react-grid-customDragHandle",resizeHandle:l(K4,{}),children:t.panels.list.map((s,u)=>w("div",{"data-grid":{...s.layout},style:{position:"relative"},children:[i&&l(G4,{}),l(ds,{view:t,panel:s})]},s.id))})}),W4=gs.WidthProvider(qc.default),U4=le.observer(function({view:t,className:n="layout",rowHeight:r=10}){return l(W4,{className:`dashboard-layout ${n}`,rowHeight:r,isDraggable:!1,isResizable:!1,layout:t.panels.layouts,children:t.panels.list.map(i=>l("div",{"data-grid":i.layout,children:l(ds,{view:t,panel:i})},i.id))})}),Y4=le.observer(({children:e})=>l(f.Box,{children:e})),X4=le.observer(({children:e,view:t})=>{const n=t.config;return l(f.Modal,{size:n.width,overflow:"inside",opened:!0,onClose:Se.default.noop,withCloseButton:!1,title:n.custom_modal_title.value,trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{root:{position:"relative",height:"calc(100% - 44px)"},overlay:{position:"absolute !important"},modal:{border:"1px solid #efefef"},body:{maxHeight:"calc(100vh - 325px)"}},withinPortal:!1,transitionDuration:0,children:e})}),Q4=le.observer(({view:e,children:t})=>{switch(e.type){case wt.Modal:return l(X4,{view:e,children:t});case wt.Division:default:return l(Y4,{children:t})}}),vb=le.observer(function({view:t,saveDashboardChanges:n,fullScreenPanelID:r,setFullScreenPanelID:i}){const{viewPanelInFullScreen:o,exitFullScreen:a,inFullScreen:s,fullScreenPanel:u}=gb(t,r,i);return l(bs.Provider,{value:{viewPanelInFullScreen:o,inFullScreen:s},children:w(f.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:[s&&l(hb,{view:t,panel:u,exitFullScreen:a}),!s&&l(_m,{saveChanges:n}),l(Q4,{view:t,children:w(f.Box,{sx:{position:"relative"},children:[!s&&l(f.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:l(jh,{view:t})}),!s&&l(q4,{view:t,isDraggable:!0,isResizable:!0})]})})]})})}),Z4=le.observer(({children:e})=>l(f.Box,{children:e})),J4=le.observer(({children:e,view:t})=>{const n=ot(),r=t.config,i=n.views.visibleViewIDs.includes(t.id),o=()=>n.views.rmVisibleViewID(t.id);return l(f.Modal,{size:r.width,centered:!0,overflow:"inside",opened:i,onClose:o,withCloseButton:!1,title:r.custom_modal_title.value,trapFocus:!0,onDragStart:a=>{a.stopPropagation()},styles:{modal:{border:"1px solid #efefef"},body:{maxHeight:r.height,overflow:"scroll"}},transitionDuration:0,children:e})}),ej=le.observer(({view:e,children:t})=>{switch(e.type){case wt.Modal:return l(J4,{view:e,children:t});case wt.Division:default:return l(Z4,{children:t})}}),mb=le.observer(function({view:t,fullScreenPanelID:n,setFullScreenPanelID:r}){const{viewPanelInFullScreen:i,exitFullScreen:o,inFullScreen:a,fullScreenPanel:s}=gb(t,n,r);return l(bs.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:a},children:w(f.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:[a&&l(hb,{view:t,panel:s,exitFullScreen:o}),!a&&l(_m,{saveChanges:Se.default.noop}),l(ej,{view:t,children:w(f.Box,{sx:{position:"relative"},children:[!a&&l(f.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:l(jh,{view:t})}),!a&&l(U4,{view:t})]})})]})})}),yb=N.types.model("FilterConfigModel_Checkbox",{_name:N.types.literal("checkbox"),default_value:N.types.boolean}).actions(e=>({setDefaultValue(t){e.default_value=t}})),tj=()=>yb.create({_name:"checkbox",default_value:!1}),nj=N.types.model("FilterConfigModel_DateRange",{_name:N.types.literal("date-range"),required:N.types.boolean,inputFormat:N.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:N.types.optional(N.types.array(N.types.union(N.types.string,N.types.null)),[null,null]),clearable:N.types.boolean,max_days:N.types.optional(N.types.number,0),allowSingleDateInRange:N.types.optional(N.types.boolean,!1)}).views(e=>({truthy(t){return Array.isArray(t)&&t.length===2&&t.every(n=>!!n)}})).views(e=>({getMaxDate(t){const{max_days:n}=e;if(!(!n||!t))return _n.default(t).startOf("day").add(n,"days").toDate()},getMinDate(t){const{max_days:n}=e;if(!(!n||!t))return _n.default(t).startOf("day").subtract(n,"days").toDate()}})).actions(e=>({setRequired(t){e.required=t},setClearable(t){e.clearable=t},setInputFormat(t){e.inputFormat=t},setDefaultValue(t){e.default_value.length=0,e.default_value.push(...t)},setMaxDays(t){e.max_days=t,t>0&&(e.clearable=!0)},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),bb=N.types.snapshotProcessor(nj,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>n===null?null:_n.default.tz(n,"UTC").toISOString())}},postProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>{try{return n?_n.default.tz(n,"UTC").format(t.inputFormat):null}catch{return console.log(`[date-range] failed parsing ${n}`),null}})}}}),rj=()=>bb.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),ij=N.types.model({label:N.types.string,value:N.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),Ic=N.types.model("FilterConfigModel_BaseSelect",{static_options:N.types.optional(N.types.array(ij),[]),options_query_id:N.types.optional(N.types.string,""),default_selection_count:N.types.optional(N.types.number,0)}).views(e=>({get usingQuery(){return!!e.options_query_id}})).views(e=>({get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:n,error:r}=N.getRoot(e).getDataStuffByID(e.options_query_id);return n==="idle"?t:[]}})).actions(e=>({addStaticOption(t){e.static_options.push(t)},removeStaticOption(t){e.static_options.splice(t,1)},setDefaultSelectionCount(t){e.default_selection_count=t},setOptionsQueryID(t){e.options_query_id=t!=null?t:""}})),wb=N.types.compose("FilterConfigModel_MultiSelect",N.types.model({_name:N.types.literal("multi-select"),default_value:N.types.optional(N.types.array(N.types.string),[]),min_width:N.types.optional(N.types.string,"")}),Ic).actions(e=>({setDefaultValue(t){e.default_value=N.cast(t)},setMinWidth(t){e.min_width=t}})),oj=()=>wb.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),xb=N.types.compose("FilterConfigModel_TreeSelect",N.types.model({_name:N.types.literal("tree-select"),default_value:N.types.optional(N.types.array(N.types.string),[]),min_width:N.types.optional(N.types.string,"")}),Ic).actions(e=>({setDefaultValue(t){e.default_value=N.cast(t)},setMinWidth(t){e.min_width=t}})),aj=()=>xb.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),Sb=N.types.compose("FilterConfigModel_Select",N.types.model({_name:N.types.literal("select"),default_value:N.types.string,required:N.types.boolean,width:N.types.optional(N.types.string,"")}),Ic).views(e=>({truthy(t){return!!t}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t},setWidth(t){e.width=t}})),sj=()=>Sb.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),$c=N.types.model("FilterModel",{id:N.types.identifier,key:N.types.string,label:N.types.string,order:N.types.number,visibleInViewsIDs:N.types.array(N.types.string),auto_submit:N.types.optional(N.types.boolean,!1),type:N.types.enumeration("DashboardFilterType",[Ht.Select,Ht.MultiSelect,Ht.TreeSelect,Ht.TextInput,Ht.Checkbox,Ht.DateRange]),config:N.types.union(Sb,wb,xb,bm,yb,bb)}).views(e=>({get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==Ht.TreeSelect},get auto_submit_supported(){return[Ht.Select,Ht.Checkbox,Ht.DateRange].includes(e.type)}})).views(e=>({get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return Se.default.get(e.config,"required",!1)?Se.default.get(e.config,"truthy",()=>!0)(t):!1}})).actions(e=>({setKey(t){e.key=t},setLabel(t){e.label=t},setOrder(t){e.order=t},setType(t){switch(t){case Ht.Select:e.config=sj();break;case Ht.MultiSelect:e.config=oj();break;case Ht.TreeSelect:e.config=aj();break;case Ht.TextInput:e.config=wm();break;case Ht.Checkbox:e.config=tj();break;case Ht.DateRange:e.config=rj();break}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t}}));function Cb(e,t){if(e===void 0)return e;if(t._name==="date-range")try{return e.map(r=>{const i=_n.default.tz(r,"UTC").format(t.inputFormat);return i!=null?i:r})}catch(n){return console.error(n),e}return e}function _b(e){return e.reduce((t,n)=>(t[n.key]=Cb(n.config.default_value,n.config),t),{})}function lj(e,t,n){N.addDisposer(e,N.addMiddleware(e,(r,i)=>{i(r,()=>{N.getType(r.context)===t&&r.type==="action"&&n(r.name,r.context)})}))}const Eb=N.types.model("FiltersModel",{current:N.types.optional(N.types.array($c),[]),values:N.types.optional(N.types.frozen(),{}),previewValues:N.types.optional(N.types.frozen(),{})}).views(e=>({get firstID(){if(e.current.length!==0)return e.current[0].id},get inOrder(){return Se.default.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return Se.default.sortBy(e.current.filter(n=>n.visibleInViewsIDs.includes(t)),"order")},get firstFilterValueKey(){var t;return(t=Object.keys(e.values)[0])!=null?t:""},get keyLabelMap(){return e.current.reduce((t,n)=>(t[n.key]=n.label,t),{})}})).actions(e=>({replace(t){e.current=N.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},setValues(t){e.values=t},setValueByKey(t,n){e.values={...e.values,[t]:n}},getValueByKey(t){return e.values[t]},refreshValues(){console.log("refreshing values"),e.values=_b(e.current)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){lj(e.current,$c,(n,r)=>{if(n==="setType"){const i=Cb(r.config.default_value,r.config);e.setValueByKey(r.key,i),e.updatePreviewValues({...e.previewValues,[r.key]:i})}})}return{afterCreate(){t()}}});function Tb(e){return{current:e,values:_b(e)}}const uj=N.types.model("QueryModel",{id:N.types.string,name:N.types.string,type:N.types.enumeration("DataSourceType",[Sn.Postgresql,Sn.MySQL,Sn.HTTP]),key:N.types.string,sql:N.types.string,pre_process:N.types.optional(N.types.string,""),post_process:N.types.optional(N.types.string,""),run_by:N.types.optional(N.types.array(N.types.string),[])}).views(e=>({get valid(){return e.id&&e.type&&e.key&&e.name?e.type===Sn.HTTP?!!e.pre_process:!!e.sql:!1},get json(){const{id:t,name:n,type:r,key:i,sql:o,run_by:a,pre_process:s,post_process:u}=e;return{id:t,name:n,type:r,key:i,sql:o,run_by:a,pre_process:s,post_process:u}},get conditionOptions(){const{context:t,mock_context:n,filterValues:r}=N.getRoot(e).payloadForSQL,i=Object.keys({...n,...t}).map(s=>`context.${s}`),o=Object.keys(r).map(s=>`filters.${s}`);return[...i,...o].map(s=>({label:s.split(".")[1],value:s,group:Se.default.capitalize(s.split(".")[0])}))},get unmetRunByConditions(){const{run_by:t}=e;if(t.length===0)return[];const{context:n,mock_context:r,filterValues:i}=N.getRoot(e).payloadForSQL,o={context:{...r,...n},filters:i};return t.filter(a=>{const s=Se.default.get(o,a);return Array.isArray(s)?s.length===0:typeof s=="number"?Number.isNaN(s):!s})}})).views(e=>({get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=N.getRoot(e).filters,n=e.unmetRunByConditions.filter(i=>i.startsWith("context.")).map(i=>i.split("context.")[0]),r=e.unmetRunByConditions.filter(i=>i.startsWith("filters.")).map(i=>Se.default.get({filters:t},i)).filter(i=>!!i);return{context:n,filters:r}}})).actions(e=>({setName(t){e.name=t},setKey(t){e.key=t},setType(t){e.type=t},setSQL(t){e.sql=t},setRunBy(t){e.run_by.length=0,e.run_by.push(...t)},setPreProcess(t){e.pre_process=t},setPostProcess(t){e.post_process=t}})),Mb=N.types.compose("QueryModel",uj,N.types.model({state:N.types.optional(N.types.enumeration(["idle","loading","error"]),"idle"),data:N.types.optional(N.types.array(N.types.frozen()),[]),error:N.types.frozen()})).views(e=>({get formattedSQL(){const{context:t,mock_context:n,sqlSnippets:r,filterValues:i}=N.getRoot(e).payloadForSQL;return hm(e.sql,t,n,r,i)},get typedAsSQL(){return[Sn.Postgresql,Sn.MySQL].includes(e.type)},get typedAsHTTP(){return[Sn.HTTP].includes(e.type)},get datasource(){const{key:t,type:n}=e;return N.getRoot(e).datasources.find({type:n,key:t})}})).views(e=>({get stateMessage(){if(e.state!=="idle")return"";if(!e.runByConditionsMet){const{context:t,filters:n}=e.conditionNames;if(t.length===0&&n.length===0)return"Waiting";const r=[];return t.length>0&&r.push(`context: ${t.join(", ")}`),n.length>0&&r.push(`filter${n.length>1?"s":""}: ${n.join(", ")}`),r.length===2&&r.splice(1,0,"and"),r.unshift("Waiting for"),r.join(" ")}return e.data.length>0?"":"Empty Data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:N.flow(function*(){var t;if(!!e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{context:n,mock_context:r,sqlSnippets:i,filterValues:o}=N.getRoot(e).payloadForSQL;e.data=yield*N.toGenerator(z$({context:n,mock_context:r,sqlSnippets:i,title:e.name,query:e.json,filterValues:o},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(!Po.default.isCancel(n)){e.data.length=0;const r=H.get(n,"message","unkown error");e.error=H.get(n,"response.data.detail.message",r),e.state="error"}}}}),runHTTP:N.flow(function*(){var t;if(console.log("runHTTP, ",e.datasource),!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{context:n,mock_context:r,filterValues:i}=N.getRoot(e).payloadForSQL;e.data=yield*N.toGenerator(F$({context:n,mock_context:r,query:e.json,filterValues:i,datasource:e.datasource},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(console.error(n),!Po.default.isCancel(n)){e.data.length=0;const r=H.get(n,"message","unkown error");e.error=H.get(n,"response.data.detail.message",r),e.state="error"}}}})})).actions(e=>({fetchData:e.typedAsHTTP?e.runHTTP:e.runSQL,beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){N.addDisposer(e,zt.reaction(()=>{var t;return e.typedAsHTTP?`${e.id}--${e.key}--${e.pre_process}--${e.post_process}--${(t=e.datasource)==null?void 0:t.id}`:`${e.id}--${e.key}--${e.formattedSQL}`},e.fetchData,{fireImmediately:!0,delay:0}))}})),Ob=N.types.model("QueriesModel",{current:N.types.optional(N.types.array(Mb),[])}).views(e=>({get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},get options(){return e.current.map(t=>({value:t.id,label:t.name}))}})).views(e=>({get json(){return e.current.filter(t=>t.id).map(t=>t.json)}})).actions(e=>({replace(t){e.current=N.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},downloadAllData(){const t=e.current.map(({name:n,data:r})=>({id:n,data:r.toJSON()}));T$(t)},downloadDataByQueryID(t){if(!t){console.log("[downloadDataByQueryID] query not found");return}const{name:n,data:r}=t,i=pm(r);_$(n,i)},refetchDataByQueryID(t){const n=e.findByID(t);if(!n){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return n.fetchData()},removeQuery(t){const n=e.current.find(r=>r.id===t);n&&(N.detach(n),e.current.remove(n))}})),Db=N.types.model("SQLSnippetModel",{key:N.types.string,value:N.types.string}).views(e=>({get json(){const{key:t,value:n}=e;return{key:t,value:n}},isADuplicatedKey(t){return!t||t===e.key?!1:!!N.getParent(e,2).findByKey(t)}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.value=t}})),Rb=N.types.model("SQLSnippetsModel",{current:N.types.optional(N.types.array(Db),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get record(){return e.current.reduce((t,n)=>(t[n.key]=n.value,t),{})},get firstKey(){if(e.current.length!==0)return e.current[0].key},findByKey(t){return e.current.find(n=>n.key===t)}})).actions(e=>({replace(t){e.current=N.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},replaceByIndex(t,n){e.current.splice(t,1,n)}})),kb=N.types.model("ContextModel",{current:N.types.optional(N.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}})),cj=N.types.model("DataSourcesModel",{list:N.types.optional(N.types.frozen(),[])}).views(e=>({find({type:t,key:n}){return e.list.find(r=>r.key===n&&r.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list=t}})),dj=N.types.model("MockContextModel",{current:N.types.optional(N.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},get(t){return e.current[t]},set(t,n){e.current[t]=n}})),Ab=N.types.model("ViewModel_Division",{_name:N.types.literal(wt.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})).actions(e=>({})),fj=()=>Ab.create({_name:wt.Division}),pj=N.types.model("CustomModalTitleModel",{enabled:N.types.optional(N.types.boolean,!1),func_content:N.types.optional(N.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:n}=e;return{enabled:t,func_content:n}},get value(){const{enabled:t,func_content:n}=e,r=N.getParent(e,2),i=N.getRoot(e);if(!t)return r.name;try{const o={filters:i.filters.values,context:i.context.current};return new Function(`return ${n}`)()(o)}catch(o){return console.error(o),r.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:n}){e.enabled=t,e.func_content=n}})),Pb=N.types.model("ViewModel_Modal",{_name:N.types.literal(wt.Modal),width:N.types.string,height:N.types.string,custom_modal_title:N.types.optional(pj,Pu)}).views(e=>({get json(){const{_name:t,width:n,height:r,custom_modal_title:i}=e;return{_name:t,width:n,height:r,custom_modal_title:i.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),hj=()=>Pb.create({_name:wt.Modal,width:"90vw",height:"90vh"}),gj=N.types.model("PanelLayoutModel",{x:N.types.number,y:N.types.number,w:N.types.number,h:N.types.number,moved:N.types.optional(N.types.boolean,!1),static:N.types.optional(N.types.boolean,!1)}).views(e=>({get json(){const{x:t,y:n,w:r,h:i,moved:o}=e;return{x:t,y:n,w:r,h:i,moved:o,static:e.static}}})).actions(e=>({set(t){const{x:n,y:r,w:i,h:o,moved:a}=t;e.x=n,e.y=r,e.w=i,e.h=o,e.moved=!!a,e.static=!!t.static}})),vj=N.types.model("PanelStyleBorderModel",{enabled:N.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),mj=N.types.model("PanelStyleModel",{border:vj}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),yj=N.types.model("PanelVizModel",{type:N.types.string,conf:N.types.frozen()}).views(e=>({get json(){return{type:e.type,conf:e.conf}}})).actions(e=>({setType(t){e.type=t},setConf(t){e.conf=t}})),bj=N.types.model({id:N.types.string,title:N.types.string,description:N.types.string,layout:gj,queryID:N.types.string,viz:yj,style:mj,variables:N.types.optional(N.types.array(C4),[])}).views(e=>({get query(){return N.getParentOfType(e,fs).queries.findByID(e.queryID)},get json(){const{id:t,title:n,description:r,queryID:i}=e;return{id:t,title:n,description:r,layout:e.layout.json,queryID:i,viz:e.viz.json,style:e.style.json,variables:e.variables.map(o=>o.json)}}})).actions(e=>({setID(t){e.id=t},setTitle(t){e.title=t},setDescription(t){e.description=t},setQueryID(t){if(N.getParentOfType(e,fs).queries.findByID(t))e.queryID=t;else throw new Error(`Query with id ${t} does not exist`)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)}})),wj=N.types.model("PanelsModel",{list:N.types.optional(N.types.array(bj),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},get layouts(){return e.list.map(t=>({...t.layout.json,i:t.id}))},findByID(t){return e.list.find(n=>n.id===t)}})).actions(e=>({replace(t){e.list=N.castToSnapshot(t)},addANewPanel(){const t=St.randomId();e.list.push({id:t,layout:{x:0,y:1/0,w:3,h:15},title:`Panel - ${t}`,description:"<p><br></p>",queryID:"",viz:{type:Tc.name,conf:Tc.createConfig()},style:{border:{enabled:!0}}})},append(t){e.list.push(t)},remove(t){e.list.splice(t,1)},removeByID(t){const n=e.list.findIndex(r=>r.id===t);n!==-1&&e.list.splice(n,1)},duplicateByID(t){const n=e.list.find(r=>r.id===t);if(!n){console.error(new Error(`[duplicate panel] Can't find a panel by id[${t}]`));return}e.list.push({...n.json,id:St.randomId(),layout:{...n.layout,x:0,y:1/0,moved:!1}})},replaceByIndex(t,n){e.list.splice(t,1,n)}})),Nb=N.types.model({id:N.types.identifier,name:N.types.string,type:N.types.enumeration("EViewComponentType",[wt.Division,wt.Modal]),config:N.types.union(Ab,Pb),panels:wj}).views(e=>({get json(){const{id:t,name:n,type:r,config:i}=e;return{id:t,name:n,type:r,config:i.json,panels:e.panels.json}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case wt.Division:e.config=fj();break;case wt.Modal:e.config=hj();break}e.type=t}}})).actions(e=>({})),Ib=N.types.model("ViewsModel",{current:N.types.optional(N.types.array(Nb),[]),visibleViewIDs:N.types.array(N.types.string),idOfVIE:N.types.string}).views(e=>({get json(){return e.current.map(t=>t.json)},findByID(t){return e.current.find(n=>n.id===t)},get isVIETheFirstView(){return e.current.length===0||!e.idOfVIE?!1:e.current[0].id===e.idOfVIE},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:n})=>n===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:n})=>t.has(n))},get VIE(){return e.current.find(({id:t})=>t===e.idOfVIE)},get options(){return e.current.map(t=>({label:t.name,value:t.id,type:t.type}))}})).actions(e=>({replace(t){e.current.replace(t)},addANewView(t,n,r){e.current.push({id:t,name:t,type:n,config:r,panels:{list:[]}})},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(r=>r.id===t);n!==-1&&e.current.splice(n,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},setIDOfVIE(t){e.idOfVIE=t,e.visibleViewIDs.length=0,e.visibleViewIDs.push(t)},addAPanelToVIE(){var t;(t=e.VIE)==null||t.panels.addANewPanel()},appendToVisibles(t){new Set(e.visibleViewIDs.map(r=>r)).has(t)||e.visibleViewIDs.push(t)}})).actions(e=>({addARandomNewView(){const t=St.randomId();e.addANewView(t,wt.Division,{_name:wt.Division}),e.setIDOfVIE(t)},removeVIE(){e.current.length!==1&&(e.removeByID(e.idOfVIE),e.setIDOfVIE(e.current[0].id))},rmVisibleViewID(t){const n=e.visibleViewIDs.findIndex(r=>r===t);n!==-1&&e.visibleViewIDs.splice(n,1)}}));function $b(e){const t=e.length>0?[e[0].id]:[],n=e.length>0?e[0].id:"";return{current:e.map(i=>{const{_name:o=i.type}=i.config;return{...i,config:{...i.config,_name:o},panels:{list:i.panels}}}),visibleViewIDs:t,idOfVIE:n}}const xj=N.types.model({id:N.types.identifier,name:N.types.string,version:N.types.string,datasources:cj,filters:Eb,queries:Ob,sqlSnippets:Rb,views:Ib,context:kb,mock_context:dj,origin:N.types.maybe(N.types.frozen())}).views(e=>({get filtersChanged(){const t="filters.current";return!H.isEqual(N.getSnapshot(H.get(e,t)),H.get(e.origin,t))},get queriesChanged(){const t="queries.current",n=N.getSnapshot(H.get(e,t)).map(r=>H.pick(r,["id","name","key","type","sql","run_by","pre_process","post_process"]));return!H.isEqual(n,H.get(e.origin,t))},get sqlSnippetsChanged(){const t="sqlSnippets.current";return!H.isEqual(N.getSnapshot(H.get(e,t)),H.get(e.origin,t))},get viewsChanged(){const t="views.current";return!H.isEqual(N.getSnapshot(H.get(e,t)),H.get(e.origin,t))},get mockContextChanged(){const t="mock_context.current";return!H.isEqual(H.get(e,t),H.get(e.origin,t))}})).views(e=>({get payloadForSQL(){return{context:e.context.current,mock_context:e.mock_context.current,sqlSnippets:e.sqlSnippets.current,filterValues:e.filters.values}},get changed(){return e.filtersChanged||e.queriesChanged||e.sqlSnippetsChanged||e.viewsChanged||e.mockContextChanged},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(),dataProxy:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],dataProxy:null,len:0,state:"idle",error:void 0}},getDataStateByID(t){var n,r;return(r=(n=e.queries.findByID(t))==null?void 0:n.state)!=null?r:[]},getDataErrorByID(t){var n,r;return(r=(n=e.queries.findByID(t))==null?void 0:n.error)!=null?r:[]}})).views(e=>({findDependingPanels(t){return e.views.current.flatMap(n=>n.panels.list.filter(r=>r.queryID===t).map(r=>r.title))}})).actions(e=>({reset(){N.applySnapshot(e.filters.current,e.origin.filters.current),N.applySnapshot(e.queries.current,e.origin.queries.current),N.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),N.applySnapshot(e.views.current,e.origin.views.current),e.mock_context.current=e.origin.mock_context.current},resetFilters(){N.applySnapshot(e.filters.current,e.origin.filters.current)}})),fs=N.types.snapshotProcessor(xj,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=N.castToSnapshot(e.queries.current.map(n=>H.pick(n,["id","key","type","sql"])));return H.defaults({},{queries:{current:t}},e)}});function Lc({id:e,name:t,version:n,filters:r,views:i,definition:{queries:o,sqlSnippets:a,mock_context:s={}}},u,c){return fs.create({id:e,name:t,version:n,datasources:{list:u},filters:Tb(r),queries:{current:o},sqlSnippets:{current:a},context:{current:c},mock_context:{current:s},views:$b(i)})}function Vc(e){return W.default.useCallback(t=>t.provideValue($t.pluginManager,e.pluginManager).provideValue($t.vizManager,e.vizManager).provideValue($t.colorManager,e.colorManager),[])}const tG="",Sj=le.observer(function({context:t,dashboard:n,update:r,className:i="dashboard",config:o,fullScreenPanelID:a,setFullScreenPanelID:s}){gm(o);const{data:u=[]}=tt.useRequest(Ru),[c,d]=W.default.useState(!1),p=W.default.useMemo(()=>Lc(n,u,t),[n]);Wc(p,!0),W.default.useEffect(()=>{p.context.replace(t)},[t]),W.default.useEffect(()=>{p.datasources.replace(u)},[u]);const h=async()=>{const m=[...p.queries.json],b=[...p.sqlSnippets.json],y=[...p.views.json],_={...p.mock_context.current},S={...n,filters:[...p.filters.current],views:y,definition:{sqlSnippets:b,queries:m,mock_context:_}};await r(S)},g=tt.useCreation(kc,[]),v=Vc(g);return l(ps.ModalsProvider,{children:l(ws,{value:p,children:l(vn.Provider,{value:{layoutFrozen:c,freezeLayout:d,inEditMode:!0,inUseMode:!1},children:l(f.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:l(Fn.Provider,{value:g,children:l(Io,{configure:v,children:p.views.visibleViews.map(m=>l(vb,{view:m,saveDashboardChanges:h,fullScreenPanelID:a,setFullScreenPanelID:s},m.id))})})})})})})}),Cj=le.observer(({context:e,dashboard:t,className:n="dashboard",config:r,fullScreenPanelID:i,setFullScreenPanelID:o})=>{gm(r);const{data:a=[]}=tt.useRequest(Ru),s=W.default.useMemo(()=>Lc(t,a,e),[t]);Wc(s,!1),W.default.useEffect(()=>{s.context.replace(e)},[e]),W.default.useEffect(()=>{s.datasources.replace(a)},[a]);const u=tt.useCreation(kc,[]),c=Vc(u);return l(ps.ModalsProvider,{children:l(ws,{value:s,children:l(vn.Provider,{value:{layoutFrozen:!0,freezeLayout:Se.default.noop,inEditMode:!1,inUseMode:!0},children:l(f.Box,{className:`${n} dashboard-root`,children:l(Fn.Provider,{value:u,children:l(Io,{configure:c,children:s.views.visibleViews.map(d=>l(mb,{view:d,fullScreenPanelID:i,setFullScreenPanelID:o},d.id))})})})})})})});var Lb={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(fn,function(){var n={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(i,o,a){var s,u=function(h,g,v){v===void 0&&(v={});var m=new Date(h),b=function(y,_){_===void 0&&(_={});var S=_.timeZoneName||"short",C=y+"|"+S,E=r[C];return E||(E=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:y,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:S}),r[C]=E),E}(g,v);return b.formatToParts(m)},c=function(h,g){for(var v=u(h,g),m=[],b=0;b<v.length;b+=1){var y=v[b],_=y.type,S=y.value,C=n[_];C>=0&&(m[C]=parseInt(S,10))}var E=m[3],M=E===24?0:E,R=m[0]+"-"+m[1]+"-"+m[2]+" "+M+":"+m[4]+":"+m[5]+":000",L=+h;return(a.utc(R).valueOf()-(L-=L%1e3))/6e4},d=o.prototype;d.tz=function(h,g){h===void 0&&(h=s);var v=this.utcOffset(),m=this.toDate(),b=m.toLocaleString("en-US",{timeZone:h}),y=Math.round((m-new Date(b))/1e3/60),_=a(b).$set("millisecond",this.$ms).utcOffset(15*-Math.round(m.getTimezoneOffset()/15)-y,!0);if(g){var S=_.utcOffset();_=_.add(v-S,"minute")}return _.$x.$timezone=h,_},d.offsetName=function(h){var g=this.$x.$timezone||a.tz.guess(),v=u(this.valueOf(),g,{timeZoneName:h}).find(function(m){return m.type.toLowerCase()==="timezonename"});return v&&v.value};var p=d.startOf;d.startOf=function(h,g){if(!this.$x||!this.$x.$timezone)return p.call(this,h,g);var v=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return p.call(v,h,g).tz(this.$x.$timezone,!0)},a.tz=function(h,g,v){var m=v&&g,b=v||g||s,y=c(+a(),b);if(typeof h!="string")return a(h).tz(b);var _=function(M,R,L){var F=M-60*R*1e3,A=c(F,L);if(R===A)return[F,R];var O=c(F-=60*(A-R)*1e3,L);return A===O?[F,A]:[M-60*Math.min(A,O)*1e3,Math.max(A,O)]}(a.utc(h,m).valueOf(),y,b),S=_[0],C=_[1],E=a(S).utcOffset(C);return E.$x.$timezone=b,E},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(h){s=h}}})})(Lb);const _j=Lb.exports;var Vb={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(fn,function(){var n="minute",r=/[+-]\d\d(?::?\d\d)?/g,i=/([+-]|\d\d)/g;return function(o,a,s){var u=a.prototype;s.utc=function(m){var b={date:m,utc:!0,args:arguments};return new a(b)},u.utc=function(m){var b=s(this.toDate(),{locale:this.$L,utc:!0});return m?b.add(this.utcOffset(),n):b},u.local=function(){return s(this.toDate(),{locale:this.$L,utc:!1})};var c=u.parse;u.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),c.call(this,m)};var d=u.init;u.init=function(){if(this.$u){var m=this.$d;this.$y=m.getUTCFullYear(),this.$M=m.getUTCMonth(),this.$D=m.getUTCDate(),this.$W=m.getUTCDay(),this.$H=m.getUTCHours(),this.$m=m.getUTCMinutes(),this.$s=m.getUTCSeconds(),this.$ms=m.getUTCMilliseconds()}else d.call(this)};var p=u.utcOffset;u.utcOffset=function(m,b){var y=this.$utils().u;if(y(m))return this.$u?0:y(this.$offset)?p.call(this):this.$offset;if(typeof m=="string"&&(m=function(E){E===void 0&&(E="");var M=E.match(r);if(!M)return null;var R=(""+M[0]).match(i)||["-",0,0],L=R[0],F=60*+R[1]+ +R[2];return F===0?0:L==="+"?F:-F}(m),m===null))return this;var _=Math.abs(m)<=16?60*m:m,S=this;if(b)return S.$offset=_,S.$u=m===0,S;if(m!==0){var C=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(S=this.local().add(_+C,n)).$offset=_,S.$x.$localOffset=C}else S=this.utc();return S};var h=u.format;u.format=function(m){var b=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return h.call(this,b)},u.valueOf=function(){var m=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*m},u.isUTC=function(){return!!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var g=u.toDate;u.toDate=function(m){return m==="s"&&this.$offset?s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():g.call(this)};var v=u.diff;u.diff=function(m,b,y){if(m&&this.$u===m.$u)return v.call(this,m,b,y);var _=this.local(),S=s(m).local();return v.call(_,S,b,y)}}})})(Vb);const Ej=Vb.exports,Tj=()=>Promise.resolve().then(()=>oL).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));_n.default.extend(Ej),_n.default.extend(_j),_n.default.tz.setDefault("UTC"),pe.ContextModel=kb,pe.Dashboard=Sj,pe.DashboardFilterType=om,pe.DashboardMode=im,pe.DashboardModel=fs,pe.EViewComponentType=wt,pe.FilterModel=$c,pe.FiltersModel=Eb,pe.LayoutStateContext=vn,pe.MainDashboardView=vb,pe.ModelContextProvider=ws,pe.Panel=ds,pe.PanelContextProvider=ed,pe.QueriesModel=Ob,pe.QueryModel=Mb,pe.ReadOnlyDashboard=Cj,pe.ReadOnlyDashboardView=mb,pe.SQLSnippetModel=Db,pe.SQLSnippetsModel=Rb,pe.ViewModel=Nb,pe.ViewsModel=Ib,pe.createDashboardModel=Lc,pe.createDashboardViewsModel=$b,pe.getInitialFiltersPayload=Tb,pe.getVersion=Tj,pe.useModelContext=ot,pe.usePanelContext=Gt,pe.useTopLevelServices=Vc,Object.defineProperties(pe,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
package/dist/style.css CHANGED
@@ -1 +1 @@
1
- .react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;cursor:-webkit-grab;cursor:grab}.react-flow__pane.selection{cursor:pointer}.react-flow__pane.dragging{cursor:-webkit-grabbing;cursor:grabbing}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow .react-flow__edges{pointer-events:none;overflow:visible}.react-flow__edge-path,.react-flow__connection-path{stroke:#b1b1b7;stroke-width:1;fill:none}.react-flow__edge{pointer-events:visibleStroke;cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;-webkit-animation:dashdraw .5s linear infinite;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;-webkit-animation:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge:focus .react-flow__edge-path,.react-flow__edge:focus-visible .react-flow__edge-path{stroke:#555}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge-textbg{fill:#fff}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;-webkit-animation:dashdraw .5s linear infinite;animation:dashdraw .5s linear infinite}.react-flow__connectionline{z-index:1001}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:-webkit-grab;cursor:grab}.react-flow__node.dragging{cursor:-webkit-grabbing;cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:-webkit-grab;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background:#1a192b;border:1px solid white;border-radius:100%}.react-flow__handle.connectable{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:-4px;transform:translate(-50%)}.react-flow__handle-top{left:50%;top:-4px;transform:translate(-50%)}.react-flow__handle-left{top:50%;left:-4px;transform:translateY(-50%)}.react-flow__handle-right{right:-4px;top:50%;transform:translateY(-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.center{left:50%;transform:translate(-50%)}.react-flow__attribution{font-size:10px;background:rgba(255,255,255,.5);padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@-webkit-keyframes dashdraw{0%{stroke-dashoffset:10}}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-default,.react-flow__node-input,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:3px;width:150px;font-size:12px;color:#222;text-align:center;border-width:1px;border-style:solid;border-color:#1a192b;background-color:#fff}.react-flow__node-default.selectable:hover,.react-flow__node-input.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:0 1px 4px 1px #00000014}.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:0 0 0 .5px #1a192b}.react-flow__node-group{background-color:#f0f0f040}.react-flow__nodesselection-rect,.react-flow__selection{background:rgba(0,89,220,.08);border:1px dotted rgba(0,89,220,.8)}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls{box-shadow:0 0 2px 1px #00000014}.react-flow__controls-button{border:none;background:#fefefe;border-bottom:1px solid #eee;box-sizing:content-box;display:flex;justify-content:center;align-items:center;width:16px;height:16px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none;padding:5px}.react-flow__controls-button:hover{background:#f4f4f4}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px}.react-flow__minimap{background-color:#fff}.react-flow__node-interaction{padding:10px;border-radius:3px;width:150px;font-size:12px;color:#222;text-align:center;border-width:1px;border-style:solid;border-color:#1a192b;background-color:#fff}.filter-settings-tabs{width:100%;height:100%}.filter-settings-tabs .mantine-Tabs-panel{height:calc(100% - 25px)}.filter-settings-tabs .mantine-Tabs-tabsListWrapper{flex:0}.filter-settings-tabs .mantine-Tabs-body{flex:1;overflow:scroll}.panel-root{height:100%;width:100%;max-width:100%;background:transparent;border-radius:4px;position:relative}.panel-settings-tabs{width:100%;height:100%}.panel-settings-tabs .mantine-Tabs-panel{height:calc(100% - 25px)}.panel-settings-tabs .mantine-Tabs-tabsListWrapper{flex:0}.panel-settings-tabs .mantine-Tabs-body{flex:1;overflow:scroll}.viz-root{width:100%;overflow:scroll;flex-grow:1;background-color:#fff}.panel-dropdown-target{text-align:center;transition:background-color .3s ease}.panel-dropdown-target:hover{cursor:pointer;background-color:#6464640d}.react-grid-item{padding:0}.remove-panel{position:absolute;right:2px;top:0;cursor:pointer}.code-textarea textarea{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.dashboard-root{overflow:scroll;overflow-x:hidden;padding:0 0 10px;height:100%}.dashboard-sticky-area{z-index:100;background:white;margin:0;padding:0 10px}.mantine-RichTextEditor-root{overflow-y:scroll!important;-ms-overflow-style:initial!important}*:not(.mantine-RichTextEditor-root):not([data-enable-scrollbar])::-webkit-scrollbar{width:0!important;height:0!important}*:not([data-enable-scrollbar]){overflow:-moz-scrollbars-none;-ms-overflow-style:none}.minimal-monaco-editor{border-radius:4px;overflow:hidden;background-color:#1e1e1e;padding-top:14px}
1
+ .react-flow__container{position:absolute;width:100%;height:100%;top:0;left:0}.react-flow__pane{z-index:1;cursor:-webkit-grab;cursor:grab}.react-flow__pane.selection{cursor:pointer}.react-flow__pane.dragging{cursor:-webkit-grabbing;cursor:grabbing}.react-flow__viewport{transform-origin:0 0;z-index:2;pointer-events:none}.react-flow__renderer{z-index:4}.react-flow__selection{z-index:6}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible{outline:none}.react-flow .react-flow__edges{pointer-events:none;overflow:visible}.react-flow__edge-path,.react-flow__connection-path{stroke:#b1b1b7;stroke-width:1;fill:none}.react-flow__edge{pointer-events:visibleStroke;cursor:pointer}.react-flow__edge.animated path{stroke-dasharray:5;-webkit-animation:dashdraw .5s linear infinite;animation:dashdraw .5s linear infinite}.react-flow__edge.animated path.react-flow__edge-interaction{stroke-dasharray:none;-webkit-animation:none;animation:none}.react-flow__edge.inactive{pointer-events:none}.react-flow__edge.selected,.react-flow__edge:focus,.react-flow__edge:focus-visible{outline:none}.react-flow__edge.selected .react-flow__edge-path,.react-flow__edge:focus .react-flow__edge-path,.react-flow__edge:focus-visible .react-flow__edge-path{stroke:#555}.react-flow__edge-textwrapper{pointer-events:all}.react-flow__edge-textbg{fill:#fff}.react-flow__edge .react-flow__edge-text{pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none}.react-flow__connection{pointer-events:none}.react-flow__connection .animated{stroke-dasharray:5;-webkit-animation:dashdraw .5s linear infinite;animation:dashdraw .5s linear infinite}.react-flow__connectionline{z-index:1001}.react-flow__nodes{pointer-events:none;transform-origin:0 0}.react-flow__node{position:absolute;-webkit-user-select:none;-moz-user-select:none;user-select:none;pointer-events:all;transform-origin:0 0;box-sizing:border-box;cursor:-webkit-grab;cursor:grab}.react-flow__node.dragging{cursor:-webkit-grabbing;cursor:grabbing}.react-flow__nodesselection{z-index:3;transform-origin:left top;pointer-events:none}.react-flow__nodesselection-rect{position:absolute;pointer-events:all;cursor:-webkit-grab;cursor:grab}.react-flow__handle{position:absolute;pointer-events:none;min-width:5px;min-height:5px;width:6px;height:6px;background:#1a192b;border:1px solid white;border-radius:100%}.react-flow__handle.connectable{pointer-events:all;cursor:crosshair}.react-flow__handle-bottom{top:auto;left:50%;bottom:-4px;transform:translate(-50%)}.react-flow__handle-top{left:50%;top:-4px;transform:translate(-50%)}.react-flow__handle-left{top:50%;left:-4px;transform:translateY(-50%)}.react-flow__handle-right{right:-4px;top:50%;transform:translateY(-50%)}.react-flow__edgeupdater{cursor:move;pointer-events:all}.react-flow__panel{position:absolute;z-index:5;margin:15px}.react-flow__panel.top{top:0}.react-flow__panel.bottom{bottom:0}.react-flow__panel.left{left:0}.react-flow__panel.right{right:0}.react-flow__panel.center{left:50%;transform:translate(-50%)}.react-flow__attribution{font-size:10px;background:rgba(255,255,255,.5);padding:2px 3px;margin:0}.react-flow__attribution a{text-decoration:none;color:#999}@-webkit-keyframes dashdraw{0%{stroke-dashoffset:10}}@keyframes dashdraw{0%{stroke-dashoffset:10}}.react-flow__edgelabel-renderer{position:absolute;width:100%;height:100%;pointer-events:none}.react-flow__edge.updating .react-flow__edge-path{stroke:#777}.react-flow__edge-text{font-size:10px}.react-flow__node.selectable:focus,.react-flow__node.selectable:focus-visible{outline:none}.react-flow__node-default,.react-flow__node-input,.react-flow__node-output,.react-flow__node-group{padding:10px;border-radius:3px;width:150px;font-size:12px;color:#222;text-align:center;border-width:1px;border-style:solid;border-color:#1a192b;background-color:#fff}.react-flow__node-default.selectable:hover,.react-flow__node-input.selectable:hover,.react-flow__node-output.selectable:hover,.react-flow__node-group.selectable:hover{box-shadow:0 1px 4px 1px #00000014}.react-flow__node-default.selectable.selected,.react-flow__node-default.selectable:focus,.react-flow__node-default.selectable:focus-visible,.react-flow__node-input.selectable.selected,.react-flow__node-input.selectable:focus,.react-flow__node-input.selectable:focus-visible,.react-flow__node-output.selectable.selected,.react-flow__node-output.selectable:focus,.react-flow__node-output.selectable:focus-visible,.react-flow__node-group.selectable.selected,.react-flow__node-group.selectable:focus,.react-flow__node-group.selectable:focus-visible{box-shadow:0 0 0 .5px #1a192b}.react-flow__node-group{background-color:#f0f0f040}.react-flow__nodesselection-rect,.react-flow__selection{background:rgba(0,89,220,.08);border:1px dotted rgba(0,89,220,.8)}.react-flow__nodesselection-rect:focus,.react-flow__nodesselection-rect:focus-visible,.react-flow__selection:focus,.react-flow__selection:focus-visible{outline:none}.react-flow__controls{box-shadow:0 0 2px 1px #00000014}.react-flow__controls-button{border:none;background:#fefefe;border-bottom:1px solid #eee;box-sizing:content-box;display:flex;justify-content:center;align-items:center;width:16px;height:16px;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;user-select:none;padding:5px}.react-flow__controls-button:hover{background:#f4f4f4}.react-flow__controls-button svg{width:100%;max-width:12px;max-height:12px}.react-flow__minimap{background-color:#fff}.react-flow__node-interaction{padding:10px;border-radius:3px;width:150px;font-size:12px;color:#222;text-align:center;border-width:1px;border-style:solid;border-color:#1a192b;background-color:#fff}.filter-settings-tabs{width:100%;height:100%}.filter-settings-tabs .mantine-Tabs-panel{height:calc(100% - 25px)}.filter-settings-tabs .mantine-Tabs-tabsListWrapper{flex:0}.filter-settings-tabs .mantine-Tabs-body{flex:1;overflow:scroll}.panel-root{height:100%;width:100%;max-width:100%;background:transparent;border-radius:4px;position:relative}.panel-settings-tabs{width:100%;height:100%}.panel-settings-tabs .mantine-Tabs-panel{height:calc(100% - 25px)}.panel-settings-tabs .mantine-Tabs-tabsListWrapper{flex:0}.panel-settings-tabs .mantine-Tabs-body{flex:1;overflow:scroll}.viz-root{width:100%;overflow:scroll;flex-grow:1;background-color:#fff}.panel-dropdown-target{text-align:center;transition:background-color .3s ease}.panel-dropdown-target:hover{cursor:pointer;background-color:#6464640d}.react-grid-item{padding:0}.remove-panel{position:absolute;right:2px;top:0;cursor:pointer}.code-textarea textarea{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace}.dashboard-root{overflow:scroll;overflow-x:hidden;padding:0;height:100%}.dashboard-view{position:relative;height:100%;overflow-y:scroll;overflow-x:hidden;-ms-overflow-style:initial!important}.dashboard-sticky-area{z-index:100;background:white;margin:0;padding:0 10px}.mantine-RichTextEditor-root{overflow-y:scroll!important;-ms-overflow-style:initial!important}*:not(.mantine-RichTextEditor-root):not(.dashboard-view):not(.mantine-Modal-body):not([data-enable-scrollbar])::-webkit-scrollbar{width:0!important;height:0!important}*:not([data-enable-scrollbar]){overflow:-moz-scrollbars-none;-ms-overflow-style:none}.minimal-monaco-editor{border-radius:4px;overflow:hidden;background-color:#1e1e1e;padding-top:14px}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devtable/dashboard",
3
- "version": "7.10.1",
3
+ "version": "7.11.0",
4
4
  "license": "Apache-2.0",
5
5
  "publishConfig": {
6
6
  "access": "public",