@devtable/dashboard 13.19.0 → 13.21.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.
Files changed (26) hide show
  1. package/dist/components/panel/panel-render/full-screen-render/use-panel-full-screen.d.ts +2 -2
  2. package/dist/components/plugins/editor-components/field-array-tabs/field-array-tabs.d.ts +1 -4
  3. package/dist/components/plugins/editor-components/field-array-tabs/tab-list.d.ts +12 -0
  4. package/dist/components/plugins/editor-components/field-array-tabs/types.d.ts +7 -0
  5. package/dist/components/plugins/plugin-context.d.ts +2 -2
  6. package/dist/components/widgets/function-editor/function-editor.d.ts +8 -0
  7. package/dist/components/widgets/function-editor/index.d.ts +2 -6
  8. package/dist/components/widgets/function-editor/types.d.ts +7 -0
  9. package/dist/components/widgets/inline-function-input/index.d.ts +2 -0
  10. package/dist/components/widgets/modal-function-editor/index.d.ts +8 -2
  11. package/dist/components/widgets/rich-text-editor/dynamic-color-mark/dynamic-color-control.d.ts +4 -0
  12. package/dist/components/widgets/rich-text-editor/dynamic-color-mark/dynamic-color-mark.d.ts +12 -0
  13. package/dist/components/widgets/rich-text-editor/dynamic-color-mark/index.d.ts +3 -0
  14. package/dist/components/widgets/rich-text-editor/dynamic-color-mark/utils.d.ts +9 -0
  15. package/dist/components/widgets/rich-text-editor/readonly-rich-text-editor.d.ts +4 -1
  16. package/dist/contexts/panel-context.d.ts +4 -4
  17. package/dist/dashboard-editor/model/panels/panel.d.ts +1 -1
  18. package/dist/dashboard.es.js +17120 -14185
  19. package/dist/dashboard.umd.js +129 -127
  20. package/dist/i18n/en.d.ts +7 -0
  21. package/dist/i18n/zh.d.ts +7 -0
  22. package/dist/model/render-model/dashboard/content/panels/panel.d.ts +2 -1
  23. package/dist/stats.html +1 -1
  24. package/dist/utils/dashboard-state.d.ts +1 -0
  25. package/dist/version.json +2 -2
  26. package/package.json +5 -1
@@ -1,4 +1,4 @@
1
- (function(j,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("@mantine/core"),require("@mantine/modals"),require("ahooks"),require("mobx"),require("mobx-react-lite"),require("@faker-js/faker"),require("crypto-js"),require("d3-array"),require("dayjs"),require("lodash"),require("mathjs"),require("numbro"),require("axios"),require("@mantine/hooks"),require("popmotion"),require("echarts/core"),require("echarts/charts"),require("echarts/components"),require("echarts/renderers"),require("js-base64"),require("eventemitter2"),require("chroma-js"),require("echarts-for-react/lib/core"),require("echarts-gl"),require("react-hook-form"),require("@mantine/dates"),require("react-i18next"),require("tabler-icons-react"),require("@monaco-editor/react"),require("@tabler/icons-react"),require("@mantine/notifications"),require("d3-regression"),require("@mantine/tiptap"),require("@tiptap/extension-color"),require("@tiptap/extension-highlight"),require("@tiptap/extension-placeholder"),require("@tiptap/extension-subscript"),require("@tiptap/extension-superscript"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-table"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-table-row"),require("@tiptap/extension-underline"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("prosemirror-keymap"),require("prosemirror-commands"),require("prosemirror-schema-list"),require("uuid"),require("@mantine/prism"),require("@tanstack/react-table"),require("react-virtual"),require("rc-select"),require("rc-tree-select"),require("react-grid-layout"),require("mobx-state-tree"),require("performant-array-to-tree"),require("file-saver"),require("dom-to-image-more"),require("jszip"),require("@json2csv/whatwg"),require("dayjs/plugin/advancedFormat"),require("dayjs/plugin/arraySupport"),require("dayjs/plugin/buddhistEra"),require("dayjs/plugin/calendar"),require("dayjs/plugin/customParseFormat"),require("dayjs/plugin/dayOfYear"),require("dayjs/plugin/duration"),require("dayjs/plugin/isBetween"),require("dayjs/plugin/isLeapYear"),require("dayjs/plugin/isMoment"),require("dayjs/plugin/isoWeek"),require("dayjs/plugin/isoWeeksInYear"),require("dayjs/plugin/isSameOrAfter"),require("dayjs/plugin/isSameOrBefore"),require("dayjs/plugin/isToday"),require("dayjs/plugin/isTomorrow"),require("dayjs/plugin/isYesterday"),require("dayjs/plugin/localeData"),require("dayjs/plugin/localizedFormat"),require("dayjs/plugin/minMax"),require("dayjs/plugin/objectSupport"),require("dayjs/plugin/pluralGetSet"),require("dayjs/plugin/preParsePostFormat"),require("dayjs/plugin/quarterOfYear"),require("dayjs/plugin/relativeTime"),require("dayjs/plugin/timezone"),require("dayjs/plugin/toArray"),require("dayjs/plugin/toObject"),require("dayjs/plugin/updateLocale"),require("dayjs/plugin/utc"),require("dayjs/plugin/weekday"),require("dayjs/plugin/weekOfYear"),require("dayjs/plugin/weekYear"),require("i18next"),require("i18next-browser-languagedetector"),require("intl-pluralrules"),require("reactflow")):typeof define=="function"&&define.amd?define(["exports","react","@mantine/core","@mantine/modals","ahooks","mobx","mobx-react-lite","@faker-js/faker","crypto-js","d3-array","dayjs","lodash","mathjs","numbro","axios","@mantine/hooks","popmotion","echarts/core","echarts/charts","echarts/components","echarts/renderers","js-base64","eventemitter2","chroma-js","echarts-for-react/lib/core","echarts-gl","react-hook-form","@mantine/dates","react-i18next","tabler-icons-react","@monaco-editor/react","@tabler/icons-react","@mantine/notifications","d3-regression","@mantine/tiptap","@tiptap/extension-color","@tiptap/extension-highlight","@tiptap/extension-placeholder","@tiptap/extension-subscript","@tiptap/extension-superscript","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-table","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-table-row","@tiptap/extension-underline","@tiptap/react","@tiptap/starter-kit","prosemirror-keymap","prosemirror-commands","prosemirror-schema-list","uuid","@mantine/prism","@tanstack/react-table","react-virtual","rc-select","rc-tree-select","react-grid-layout","mobx-state-tree","performant-array-to-tree","file-saver","dom-to-image-more","jszip","@json2csv/whatwg","dayjs/plugin/advancedFormat","dayjs/plugin/arraySupport","dayjs/plugin/buddhistEra","dayjs/plugin/calendar","dayjs/plugin/customParseFormat","dayjs/plugin/dayOfYear","dayjs/plugin/duration","dayjs/plugin/isBetween","dayjs/plugin/isLeapYear","dayjs/plugin/isMoment","dayjs/plugin/isoWeek","dayjs/plugin/isoWeeksInYear","dayjs/plugin/isSameOrAfter","dayjs/plugin/isSameOrBefore","dayjs/plugin/isToday","dayjs/plugin/isTomorrow","dayjs/plugin/isYesterday","dayjs/plugin/localeData","dayjs/plugin/localizedFormat","dayjs/plugin/minMax","dayjs/plugin/objectSupport","dayjs/plugin/pluralGetSet","dayjs/plugin/preParsePostFormat","dayjs/plugin/quarterOfYear","dayjs/plugin/relativeTime","dayjs/plugin/timezone","dayjs/plugin/toArray","dayjs/plugin/toObject","dayjs/plugin/updateLocale","dayjs/plugin/utc","dayjs/plugin/weekday","dayjs/plugin/weekOfYear","dayjs/plugin/weekYear","i18next","i18next-browser-languagedetector","intl-pluralrules","reactflow"],m):(j=typeof globalThis<"u"?globalThis:j||self,m(j.dashboard={},j.react,j["@mantine/core"],j["@mantine/modals"],j.ahooks,j.mobx,j["mobx-react-lite"],j["@faker-js/faker"],j.CryptoJS,j["d3-array"],j.dayjs,j._,j.mathjs,j.numbro,j.axios,j["@mantine/hooks"],j.popmotion,j["echarts/core"],j["echarts/charts"],j["echarts/components"],j["echarts/renderers"],j["js-base64"],j.eventemitter2,j["chroma-js"],j["echarts-for-react/lib/core"],j["echarts-gl"],j["react-hook-form"],j["@mantine/dates"],j["react-i18next"],j["tabler-icons-react"],j["@monaco-editor/react"],j["@tabler/icons-react"],j["@mantine/notifications"],j["d3-regression"],j["@mantine/tiptap"],j["@tiptap/extension-color"],j["@tiptap/extension-highlight"],j["@tiptap/extension-placeholder"],j["@tiptap/extension-subscript"],j["@tiptap/extension-superscript"],j["@tiptap/extension-text-align"],j["@tiptap/extension-text-style"],j["@tiptap/extension-table"],j["@tiptap/extension-table-cell"],j["@tiptap/extension-table-header"],j["@tiptap/extension-table-row"],j["@tiptap/extension-underline"],j["@tiptap/react"],j["@tiptap/starter-kit"],j["prosemirror-keymap"],j["prosemirror-commands"],j["prosemirror-schema-list"],j.uuid,j["@mantine/prism"],j["@tanstack/react-table"],j["react-virtual"],j["rc-select"],j["rc-tree-select"],j["react-grid-layout"],j["mobx-state-tree"],j["performant-array-to-tree"],j["file-saver"],j["dom-to-image-more"],j.jszip,j["@json2csv/whatwg"],j["dayjs/plugin/advancedFormat"],j["dayjs/plugin/arraySupport"],j["dayjs/plugin/buddhistEra"],j["dayjs/plugin/calendar"],j["dayjs/plugin/customParseFormat"],j["dayjs/plugin/dayOfYear"],j["dayjs/plugin/duration"],j["dayjs/plugin/isBetween"],j["dayjs/plugin/isLeapYear"],j["dayjs/plugin/isMoment"],j["dayjs/plugin/isoWeek"],j["dayjs/plugin/isoWeeksInYear"],j["dayjs/plugin/isSameOrAfter"],j["dayjs/plugin/isSameOrBefore"],j["dayjs/plugin/isToday"],j["dayjs/plugin/isTomorrow"],j["dayjs/plugin/isYesterday"],j["dayjs/plugin/localeData"],j["dayjs/plugin/localizedFormat"],j["dayjs/plugin/minMax"],j["dayjs/plugin/objectSupport"],j["dayjs/plugin/pluralGetSet"],j["dayjs/plugin/preParsePostFormat"],j["dayjs/plugin/quarterOfYear"],j["dayjs/plugin/relativeTime"],j["dayjs/plugin/timezone"],j["dayjs/plugin/toArray"],j["dayjs/plugin/toObject"],j["dayjs/plugin/updateLocale"],j["dayjs/plugin/utc"],j["dayjs/plugin/weekday"],j["dayjs/plugin/weekOfYear"],j["dayjs/plugin/weekYear"],j.i18next,j["i18next-browser-languagedetector"],j["intl-pluralrules"],j.reactflow))})(this,function(j,m,a,Fe,W,J,S,Pu,Wi,nn,I,b,$u,Cn,rt,ie,Dt,Qi,it,vt,Bu,Ri,Ui,dt,Se,Az,y,Yi,_,L,Le,k,_t,Lu,R,Ki,Ji,Xi,Zi,Hi,ea,ta,na,sa,ra,ia,aa,oa,la,Pz,ve,Cs,pt,jt,Je,qu,ca,ua,Sn,x,Ou,kn,da,pa,Vu,Nu,Gu,Fu,Wu,Qu,Ru,Uu,Yu,Ku,Ju,Xu,Zu,Hu,ed,td,nd,sd,rd,id,ad,od,ld,cd,ud,dd,pd,hd,md,xd,gd,fd,yd,bd,vd,_d,$z,we){"use strict";var Iz=Object.defineProperty;var Ez=(j,m,a)=>m in j?Iz(j,m,{enumerable:!0,configurable:!0,writable:!0,value:a}):j[m]=a;var $=(j,m,a)=>(Ez(j,typeof m!="symbol"?m+"":m,a),a);function sn(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const jd=sn(Wi),wd=sn(nn),Vt=sn($u),Ce=sn(Qi),wt=sn(Lu);var Ss={exports:{}},rn={};/**
1
+ (function(w,m){typeof exports=="object"&&typeof module<"u"?m(exports,require("react"),require("@mantine/core"),require("@mantine/modals"),require("ahooks"),require("mobx"),require("mobx-react-lite"),require("@faker-js/faker"),require("crypto-js"),require("d3-array"),require("dayjs"),require("lodash"),require("mathjs"),require("numbro"),require("axios"),require("@mantine/hooks"),require("popmotion"),require("echarts/core"),require("echarts/charts"),require("echarts/components"),require("echarts/renderers"),require("js-base64"),require("eventemitter2"),require("chroma-js"),require("echarts-for-react/lib/core"),require("echarts-gl"),require("react-hook-form"),require("@mantine/dates"),require("react-i18next"),require("tabler-icons-react"),require("@monaco-editor/react"),require("@tabler/icons-react"),require("@mantine/notifications"),require("@dnd-kit/react"),require("react-dom"),require("d3-regression"),require("@mantine/tiptap"),require("@tiptap/extension-color"),require("@tiptap/extension-highlight"),require("@tiptap/extension-placeholder"),require("@tiptap/extension-subscript"),require("@tiptap/extension-superscript"),require("@tiptap/extension-text-align"),require("@tiptap/extension-text-style"),require("@tiptap/extension-table"),require("@tiptap/extension-table-cell"),require("@tiptap/extension-table-header"),require("@tiptap/extension-table-row"),require("@tiptap/extension-underline"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("prosemirror-keymap"),require("prosemirror-commands"),require("prosemirror-schema-list"),require("constrained-editor-plugin"),require("@dnd-kit/helpers"),require("uuid"),require("@mantine/prism"),require("@tanstack/react-table"),require("react-virtual"),require("rc-select"),require("rc-tree-select"),require("react-grid-layout"),require("mobx-state-tree"),require("performant-array-to-tree"),require("file-saver"),require("dom-to-image-more"),require("jszip"),require("@json2csv/whatwg"),require("dayjs/plugin/advancedFormat"),require("dayjs/plugin/arraySupport"),require("dayjs/plugin/buddhistEra"),require("dayjs/plugin/calendar"),require("dayjs/plugin/customParseFormat"),require("dayjs/plugin/dayOfYear"),require("dayjs/plugin/duration"),require("dayjs/plugin/isBetween"),require("dayjs/plugin/isLeapYear"),require("dayjs/plugin/isMoment"),require("dayjs/plugin/isoWeek"),require("dayjs/plugin/isoWeeksInYear"),require("dayjs/plugin/isSameOrAfter"),require("dayjs/plugin/isSameOrBefore"),require("dayjs/plugin/isToday"),require("dayjs/plugin/isTomorrow"),require("dayjs/plugin/isYesterday"),require("dayjs/plugin/localeData"),require("dayjs/plugin/localizedFormat"),require("dayjs/plugin/minMax"),require("dayjs/plugin/objectSupport"),require("dayjs/plugin/pluralGetSet"),require("dayjs/plugin/preParsePostFormat"),require("dayjs/plugin/quarterOfYear"),require("dayjs/plugin/relativeTime"),require("dayjs/plugin/timezone"),require("dayjs/plugin/toArray"),require("dayjs/plugin/toObject"),require("dayjs/plugin/updateLocale"),require("dayjs/plugin/utc"),require("dayjs/plugin/weekday"),require("dayjs/plugin/weekOfYear"),require("dayjs/plugin/weekYear"),require("i18next"),require("i18next-browser-languagedetector"),require("intl-pluralrules"),require("reactflow")):typeof define=="function"&&define.amd?define(["exports","react","@mantine/core","@mantine/modals","ahooks","mobx","mobx-react-lite","@faker-js/faker","crypto-js","d3-array","dayjs","lodash","mathjs","numbro","axios","@mantine/hooks","popmotion","echarts/core","echarts/charts","echarts/components","echarts/renderers","js-base64","eventemitter2","chroma-js","echarts-for-react/lib/core","echarts-gl","react-hook-form","@mantine/dates","react-i18next","tabler-icons-react","@monaco-editor/react","@tabler/icons-react","@mantine/notifications","@dnd-kit/react","react-dom","d3-regression","@mantine/tiptap","@tiptap/extension-color","@tiptap/extension-highlight","@tiptap/extension-placeholder","@tiptap/extension-subscript","@tiptap/extension-superscript","@tiptap/extension-text-align","@tiptap/extension-text-style","@tiptap/extension-table","@tiptap/extension-table-cell","@tiptap/extension-table-header","@tiptap/extension-table-row","@tiptap/extension-underline","@tiptap/react","@tiptap/starter-kit","prosemirror-keymap","prosemirror-commands","prosemirror-schema-list","constrained-editor-plugin","@dnd-kit/helpers","uuid","@mantine/prism","@tanstack/react-table","react-virtual","rc-select","rc-tree-select","react-grid-layout","mobx-state-tree","performant-array-to-tree","file-saver","dom-to-image-more","jszip","@json2csv/whatwg","dayjs/plugin/advancedFormat","dayjs/plugin/arraySupport","dayjs/plugin/buddhistEra","dayjs/plugin/calendar","dayjs/plugin/customParseFormat","dayjs/plugin/dayOfYear","dayjs/plugin/duration","dayjs/plugin/isBetween","dayjs/plugin/isLeapYear","dayjs/plugin/isMoment","dayjs/plugin/isoWeek","dayjs/plugin/isoWeeksInYear","dayjs/plugin/isSameOrAfter","dayjs/plugin/isSameOrBefore","dayjs/plugin/isToday","dayjs/plugin/isTomorrow","dayjs/plugin/isYesterday","dayjs/plugin/localeData","dayjs/plugin/localizedFormat","dayjs/plugin/minMax","dayjs/plugin/objectSupport","dayjs/plugin/pluralGetSet","dayjs/plugin/preParsePostFormat","dayjs/plugin/quarterOfYear","dayjs/plugin/relativeTime","dayjs/plugin/timezone","dayjs/plugin/toArray","dayjs/plugin/toObject","dayjs/plugin/updateLocale","dayjs/plugin/utc","dayjs/plugin/weekday","dayjs/plugin/weekOfYear","dayjs/plugin/weekYear","i18next","i18next-browser-languagedetector","intl-pluralrules","reactflow"],m):(w=typeof globalThis<"u"?globalThis:w||self,m(w.dashboard={},w.react,w["@mantine/core"],w["@mantine/modals"],w.ahooks,w.mobx,w["mobx-react-lite"],w["@faker-js/faker"],w.CryptoJS,w["d3-array"],w.dayjs,w._,w.mathjs,w.numbro,w.axios,w["@mantine/hooks"],w.popmotion,w["echarts/core"],w["echarts/charts"],w["echarts/components"],w["echarts/renderers"],w["js-base64"],w.eventemitter2,w["chroma-js"],w["echarts-for-react/lib/core"],w["echarts-gl"],w["react-hook-form"],w["@mantine/dates"],w["react-i18next"],w["tabler-icons-react"],w["@monaco-editor/react"],w["@tabler/icons-react"],w["@mantine/notifications"],w["@dnd-kit/react"],w["react-dom"],w["d3-regression"],w["@mantine/tiptap"],w["@tiptap/extension-color"],w["@tiptap/extension-highlight"],w["@tiptap/extension-placeholder"],w["@tiptap/extension-subscript"],w["@tiptap/extension-superscript"],w["@tiptap/extension-text-align"],w["@tiptap/extension-text-style"],w["@tiptap/extension-table"],w["@tiptap/extension-table-cell"],w["@tiptap/extension-table-header"],w["@tiptap/extension-table-row"],w["@tiptap/extension-underline"],w["@tiptap/react"],w["@tiptap/starter-kit"],w["prosemirror-keymap"],w["prosemirror-commands"],w["prosemirror-schema-list"],w["constrained-editor-plugin"],w["@dnd-kit/helpers"],w.uuid,w["@mantine/prism"],w["@tanstack/react-table"],w["react-virtual"],w["rc-select"],w["rc-tree-select"],w["react-grid-layout"],w["mobx-state-tree"],w["performant-array-to-tree"],w["file-saver"],w["dom-to-image-more"],w.jszip,w["@json2csv/whatwg"],w["dayjs/plugin/advancedFormat"],w["dayjs/plugin/arraySupport"],w["dayjs/plugin/buddhistEra"],w["dayjs/plugin/calendar"],w["dayjs/plugin/customParseFormat"],w["dayjs/plugin/dayOfYear"],w["dayjs/plugin/duration"],w["dayjs/plugin/isBetween"],w["dayjs/plugin/isLeapYear"],w["dayjs/plugin/isMoment"],w["dayjs/plugin/isoWeek"],w["dayjs/plugin/isoWeeksInYear"],w["dayjs/plugin/isSameOrAfter"],w["dayjs/plugin/isSameOrBefore"],w["dayjs/plugin/isToday"],w["dayjs/plugin/isTomorrow"],w["dayjs/plugin/isYesterday"],w["dayjs/plugin/localeData"],w["dayjs/plugin/localizedFormat"],w["dayjs/plugin/minMax"],w["dayjs/plugin/objectSupport"],w["dayjs/plugin/pluralGetSet"],w["dayjs/plugin/preParsePostFormat"],w["dayjs/plugin/quarterOfYear"],w["dayjs/plugin/relativeTime"],w["dayjs/plugin/timezone"],w["dayjs/plugin/toArray"],w["dayjs/plugin/toObject"],w["dayjs/plugin/updateLocale"],w["dayjs/plugin/utc"],w["dayjs/plugin/weekday"],w["dayjs/plugin/weekOfYear"],w["dayjs/plugin/weekYear"],w.i18next,w["i18next-browser-languagedetector"],w["intl-pluralrules"],w.reactflow))})(this,function(w,m,o,lt,W,X,D,jm,Ql,cr,P,v,wm,Hr,At,he,vn,Ul,Pt,nn,Cm,Yl,Kl,Qt,Pe,SO,b,Xl,_,V,tt,M,rn,es,Sm,km,Q,Jl,Zl,Hl,ec,tc,nc,rc,sc,ic,ac,oc,lc,cc,uc,kO,De,_i,Tm,Dm,Ut,sn,bt,Mm,dc,pc,ts,x,zm,ns,hc,fc,Im,Em,Am,Pm,Om,Lm,Bm,qm,Vm,Nm,$m,Fm,Gm,Wm,Rm,Qm,Um,Ym,Km,Xm,Jm,Zm,Hm,eg,tg,ng,rg,sg,ig,ag,og,lg,cg,ug,dg,pg,TO,Ee){"use strict";var wO=Object.defineProperty;var CO=(w,m,o)=>m in w?wO(w,m,{enumerable:!0,configurable:!0,writable:!0,value:o}):w[m]=o;var B=(w,m,o)=>(CO(w,typeof m!="symbol"?m+"":m,o),o);function ur(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const hg=ur(Ql),fg=ur(cr),On=ur(wm),Ae=ur(Ul),an=ur(km);var ji={exports:{}},dr={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var ha;function Cd(){if(ha)return rn;ha=1;var t=m,e=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,i=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function l(c,u,d){var p,h={},g=null,f=null;d!==void 0&&(g=""+d),u.key!==void 0&&(g=""+u.key),u.ref!==void 0&&(f=u.ref);for(p in u)r.call(u,p)&&!o.hasOwnProperty(p)&&(h[p]=u[p]);if(c&&c.defaultProps)for(p in u=c.defaultProps,u)h[p]===void 0&&(h[p]=u[p]);return{$$typeof:e,type:c,key:g,ref:f,props:h,_owner:i.current}}return rn.Fragment=n,rn.jsx=l,rn.jsxs=l,rn}var an={};/**
9
+ */var mc;function mg(){if(mc)return dr;mc=1;var e=m,t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,i=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,a={key:!0,ref:!0,__self:!0,__source:!0};function l(c,u,d){var p,h={},f=null,g=null;d!==void 0&&(f=""+d),u.key!==void 0&&(f=""+u.key),u.ref!==void 0&&(g=u.ref);for(p in u)s.call(u,p)&&!a.hasOwnProperty(p)&&(h[p]=u[p]);if(c&&c.defaultProps)for(p in u=c.defaultProps,u)h[p]===void 0&&(h[p]=u[p]);return{$$typeof:t,type:c,key:f,ref:g,props:h,_owner:i.current}}return dr.Fragment=n,dr.jsx=l,dr.jsxs=l,dr}var pr={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,108 +14,108 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var ma;function Sd(){return ma||(ma=1,process.env.NODE_ENV!=="production"&&function(){var t=m,e=Symbol.for("react.element"),n=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),g=Symbol.for("react.lazy"),f=Symbol.for("react.offscreen"),v=Symbol.iterator,w="@@iterator";function T(C){if(C===null||typeof C!="object")return null;var M=v&&C[v]||C[w];return typeof M=="function"?M:null}var D=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function z(C){{for(var M=arguments.length,P=new Array(M>1?M-1:0),G=1;G<M;G++)P[G-1]=arguments[G];E("error",C,P)}}function E(C,M,P){{var G=D.ReactDebugCurrentFrame,ee=G.getStackAddendum();ee!==""&&(M+="%s",P=P.concat([ee]));var se=P.map(function(X){return String(X)});se.unshift("Warning: "+M),Function.prototype.apply.call(console[C],console,se)}}var V=!1,F=!1,N=!1,Q=!1,ue=!1,le;le=Symbol.for("react.module.reference");function Ye(C){return!!(typeof C=="string"||typeof C=="function"||C===r||C===o||ue||C===i||C===d||C===p||Q||C===f||V||F||N||typeof C=="object"&&C!==null&&(C.$$typeof===g||C.$$typeof===h||C.$$typeof===l||C.$$typeof===c||C.$$typeof===u||C.$$typeof===le||C.getModuleId!==void 0))}function be(C,M,P){var G=C.displayName;if(G)return G;var ee=M.displayName||M.name||"";return ee!==""?P+"("+ee+")":P}function ys(C){return C.displayName||"Context"}function Ge(C){if(C==null)return null;if(typeof C.tag=="number"&&z("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof C=="function")return C.displayName||C.name||null;if(typeof C=="string")return C;switch(C){case r:return"Fragment";case n:return"Portal";case o:return"Profiler";case i:return"StrictMode";case d:return"Suspense";case p:return"SuspenseList"}if(typeof C=="object")switch(C.$$typeof){case c:var M=C;return ys(M)+".Consumer";case l:var P=C;return ys(P._context)+".Provider";case u:return be(C,C.render,"ForwardRef");case h:var G=C.displayName||null;return G!==null?G:Ge(C.type)||"Memo";case g:{var ee=C,se=ee._payload,X=ee._init;try{return Ge(X(se))}catch{return null}}}return null}var Ot=Object.assign,jn=0,pu,hu,mu,xu,gu,fu,yu;function bu(){}bu.__reactDisabledLog=!0;function az(){{if(jn===0){pu=console.log,hu=console.info,mu=console.warn,xu=console.error,gu=console.group,fu=console.groupCollapsed,yu=console.groupEnd;var C={configurable:!0,enumerable:!0,value:bu,writable:!0};Object.defineProperties(console,{info:C,log:C,warn:C,error:C,group:C,groupCollapsed:C,groupEnd:C})}jn++}}function oz(){{if(jn--,jn===0){var C={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:Ot({},C,{value:pu}),info:Ot({},C,{value:hu}),warn:Ot({},C,{value:mu}),error:Ot({},C,{value:xu}),group:Ot({},C,{value:gu}),groupCollapsed:Ot({},C,{value:fu}),groupEnd:Ot({},C,{value:yu})})}jn<0&&z("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Bi=D.ReactCurrentDispatcher,Li;function bs(C,M,P){{if(Li===void 0)try{throw Error()}catch(ee){var G=ee.stack.trim().match(/\n( *(at )?)/);Li=G&&G[1]||""}return`
18
- `+Li+C}}var qi=!1,vs;{var lz=typeof WeakMap=="function"?WeakMap:Map;vs=new lz}function vu(C,M){if(!C||qi)return"";{var P=vs.get(C);if(P!==void 0)return P}var G;qi=!0;var ee=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var se;se=Bi.current,Bi.current=null,az();try{if(M){var X=function(){throw Error()};if(Object.defineProperty(X.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(X,[])}catch(bt){G=bt}Reflect.construct(C,[],X)}else{try{X.call()}catch(bt){G=bt}C.call(X.prototype)}}else{try{throw Error()}catch(bt){G=bt}C()}}catch(bt){if(bt&&G&&typeof bt.stack=="string"){for(var K=bt.stack.split(`
19
- `),Me=G.stack.split(`
20
- `),pe=K.length-1,xe=Me.length-1;pe>=1&&xe>=0&&K[pe]!==Me[xe];)xe--;for(;pe>=1&&xe>=0;pe--,xe--)if(K[pe]!==Me[xe]){if(pe!==1||xe!==1)do if(pe--,xe--,xe<0||K[pe]!==Me[xe]){var Ke=`
21
- `+K[pe].replace(" at new "," at ");return C.displayName&&Ke.includes("<anonymous>")&&(Ke=Ke.replace("<anonymous>",C.displayName)),typeof C=="function"&&vs.set(C,Ke),Ke}while(pe>=1&&xe>=0);break}}}finally{qi=!1,Bi.current=se,oz(),Error.prepareStackTrace=ee}var tn=C?C.displayName||C.name:"",Au=tn?bs(tn):"";return typeof C=="function"&&vs.set(C,Au),Au}function cz(C,M,P){return vu(C,!1)}function uz(C){var M=C.prototype;return!!(M&&M.isReactComponent)}function _s(C,M,P){if(C==null)return"";if(typeof C=="function")return vu(C,uz(C));if(typeof C=="string")return bs(C);switch(C){case d:return bs("Suspense");case p:return bs("SuspenseList")}if(typeof C=="object")switch(C.$$typeof){case u:return cz(C.render);case h:return _s(C.type,M,P);case g:{var G=C,ee=G._payload,se=G._init;try{return _s(se(ee),M,P)}catch{}}}return""}var js=Object.prototype.hasOwnProperty,_u={},ju=D.ReactDebugCurrentFrame;function ws(C){if(C){var M=C._owner,P=_s(C.type,C._source,M?M.type:null);ju.setExtraStackFrame(P)}else ju.setExtraStackFrame(null)}function dz(C,M,P,G,ee){{var se=Function.call.bind(js);for(var X in C)if(se(C,X)){var K=void 0;try{if(typeof C[X]!="function"){var Me=Error((G||"React class")+": "+P+" type `"+X+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof C[X]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw Me.name="Invariant Violation",Me}K=C[X](M,X,G,P,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(pe){K=pe}K&&!(K instanceof Error)&&(ws(ee),z("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",G||"React class",P,X,typeof K),ws(null)),K instanceof Error&&!(K.message in _u)&&(_u[K.message]=!0,ws(ee),z("Failed %s type: %s",P,K.message),ws(null))}}}var pz=Array.isArray;function Oi(C){return pz(C)}function hz(C){{var M=typeof Symbol=="function"&&Symbol.toStringTag,P=M&&C[Symbol.toStringTag]||C.constructor.name||"Object";return P}}function mz(C){try{return wu(C),!1}catch{return!0}}function wu(C){return""+C}function Cu(C){if(mz(C))return z("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",hz(C)),wu(C)}var wn=D.ReactCurrentOwner,xz={key:!0,ref:!0,__self:!0,__source:!0},Su,ku,Vi;Vi={};function gz(C){if(js.call(C,"ref")){var M=Object.getOwnPropertyDescriptor(C,"ref").get;if(M&&M.isReactWarning)return!1}return C.ref!==void 0}function fz(C){if(js.call(C,"key")){var M=Object.getOwnPropertyDescriptor(C,"key").get;if(M&&M.isReactWarning)return!1}return C.key!==void 0}function yz(C,M){if(typeof C.ref=="string"&&wn.current&&M&&wn.current.stateNode!==M){var P=Ge(wn.current.type);Vi[P]||(z('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',Ge(wn.current.type),C.ref),Vi[P]=!0)}}function bz(C,M){{var P=function(){Su||(Su=!0,z("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",M))};P.isReactWarning=!0,Object.defineProperty(C,"key",{get:P,configurable:!0})}}function vz(C,M){{var P=function(){ku||(ku=!0,z("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",M))};P.isReactWarning=!0,Object.defineProperty(C,"ref",{get:P,configurable:!0})}}var _z=function(C,M,P,G,ee,se,X){var K={$$typeof:e,type:C,key:M,ref:P,props:X,_owner:se};return K._store={},Object.defineProperty(K._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(K,"_self",{configurable:!1,enumerable:!1,writable:!1,value:G}),Object.defineProperty(K,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ee}),Object.freeze&&(Object.freeze(K.props),Object.freeze(K)),K};function jz(C,M,P,G,ee){{var se,X={},K=null,Me=null;P!==void 0&&(Cu(P),K=""+P),fz(M)&&(Cu(M.key),K=""+M.key),gz(M)&&(Me=M.ref,yz(M,ee));for(se in M)js.call(M,se)&&!xz.hasOwnProperty(se)&&(X[se]=M[se]);if(C&&C.defaultProps){var pe=C.defaultProps;for(se in pe)X[se]===void 0&&(X[se]=pe[se])}if(K||Me){var xe=typeof C=="function"?C.displayName||C.name||"Unknown":C;K&&bz(X,xe),Me&&vz(X,xe)}return _z(C,K,Me,ee,G,wn.current,X)}}var Ni=D.ReactCurrentOwner,Tu=D.ReactDebugCurrentFrame;function en(C){if(C){var M=C._owner,P=_s(C.type,C._source,M?M.type:null);Tu.setExtraStackFrame(P)}else Tu.setExtraStackFrame(null)}var Gi;Gi=!1;function Fi(C){return typeof C=="object"&&C!==null&&C.$$typeof===e}function Du(){{if(Ni.current){var C=Ge(Ni.current.type);if(C)return`
17
+ */var gc;function gg(){return gc||(gc=1,process.env.NODE_ENV!=="production"&&function(){var e=m,t=Symbol.for("react.element"),n=Symbol.for("react.portal"),s=Symbol.for("react.fragment"),i=Symbol.for("react.strict_mode"),a=Symbol.for("react.profiler"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),p=Symbol.for("react.suspense_list"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),g=Symbol.for("react.offscreen"),y=Symbol.iterator,j="@@iterator";function k(C){if(C===null||typeof C!="object")return null;var A=y&&C[y]||C[j];return typeof A=="function"?A:null}var S=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function T(C){{for(var A=arguments.length,L=new Array(A>1?A-1:0),G=1;G<A;G++)L[G-1]=arguments[G];z("error",C,L)}}function z(C,A,L){{var G=S.ReactDebugCurrentFrame,ee=G.getStackAddendum();ee!==""&&(A+="%s",L=L.concat([ee]));var oe=L.map(function(J){return String(J)});oe.unshift("Warning: "+A),Function.prototype.apply.call(console[C],console,oe)}}var I=!1,E=!1,N=!1,R=!1,pe=!1,ie;ie=Symbol.for("react.module.reference");function Ie(C){return!!(typeof C=="string"||typeof C=="function"||C===s||C===a||pe||C===i||C===d||C===p||R||C===g||I||E||N||typeof C=="object"&&C!==null&&(C.$$typeof===f||C.$$typeof===h||C.$$typeof===l||C.$$typeof===c||C.$$typeof===u||C.$$typeof===ie||C.getModuleId!==void 0))}function xe(C,A,L){var G=C.displayName;if(G)return G;var ee=A.displayName||A.name||"";return ee!==""?L+"("+ee+")":L}function se(C){return C.displayName||"Context"}function Fe(C){if(C==null)return null;if(typeof C.tag=="number"&&T("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof C=="function")return C.displayName||C.name||null;if(typeof C=="string")return C;switch(C){case s:return"Fragment";case n:return"Portal";case a:return"Profiler";case i:return"StrictMode";case d:return"Suspense";case p:return"SuspenseList"}if(typeof C=="object")switch(C.$$typeof){case c:var A=C;return se(A)+".Consumer";case l:var L=C;return se(L._context)+".Provider";case u:return xe(C,C.render,"ForwardRef");case h:var G=C.displayName||null;return G!==null?G:Fe(C.type)||"Memo";case f:{var ee=C,oe=ee._payload,J=ee._init;try{return Fe(J(oe))}catch{return null}}}return null}var gt=Object.assign,xt=0,Kr,zt,Xr,An,Pn,mi,Jr;function gi(){}gi.__reactDisabledLog=!0;function ar(){{if(xt===0){Kr=console.log,zt=console.info,Xr=console.warn,An=console.error,Pn=console.group,mi=console.groupCollapsed,Jr=console.groupEnd;var C={configurable:!0,enumerable:!0,value:gi,writable:!0};Object.defineProperties(console,{info:C,log:C,warn:C,error:C,group:C,groupCollapsed:C,groupEnd:C})}xt++}}function Bl(){{if(xt--,xt===0){var C={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:gt({},C,{value:Kr}),info:gt({},C,{value:zt}),warn:gt({},C,{value:Xr}),error:gt({},C,{value:An}),group:gt({},C,{value:Pn}),groupCollapsed:gt({},C,{value:mi}),groupEnd:gt({},C,{value:Jr})})}xt<0&&T("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ae=S.ReactCurrentDispatcher,ue;function be(C,A,L){{if(ue===void 0)try{throw Error()}catch(ee){var G=ee.stack.trim().match(/\n( *(at )?)/);ue=G&&G[1]||""}return`
18
+ `+ue+C}}var ot=!1,Wt;{var bn=typeof WeakMap=="function"?WeakMap:Map;Wt=new bn}function It(C,A){if(!C||ot)return"";{var L=Wt.get(C);if(L!==void 0)return L}var G;ot=!0;var ee=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var oe;oe=ae.current,ae.current=null,ar();try{if(A){var J=function(){throw Error()};if(Object.defineProperty(J.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(J,[])}catch(tn){G=tn}Reflect.construct(C,[],J)}else{try{J.call()}catch(tn){G=tn}C.call(J.prototype)}}else{try{throw Error()}catch(tn){G=tn}C()}}catch(tn){if(tn&&G&&typeof tn.stack=="string"){for(var K=tn.stack.split(`
19
+ `),We=G.stack.split(`
20
+ `),ve=K.length-1,we=We.length-1;ve>=1&&we>=0&&K[ve]!==We[we];)we--;for(;ve>=1&&we>=0;ve--,we--)if(K[ve]!==We[we]){if(ve!==1||we!==1)do if(ve--,we--,we<0||K[ve]!==We[we]){var yt=`
21
+ `+K[ve].replace(" at new "," at ");return C.displayName&&yt.includes("<anonymous>")&&(yt=yt.replace("<anonymous>",C.displayName)),typeof C=="function"&&Wt.set(C,yt),yt}while(ve>=1&&we>=0);break}}}finally{ot=!1,ae.current=oe,Bl(),Error.prepareStackTrace=ee}var lr=C?C.displayName||C.name:"",_m=lr?be(lr):"";return typeof C=="function"&&Wt.set(C,_m),_m}function Rt(C,A,L){return It(C,!1)}function Et(C){var A=C.prototype;return!!(A&&A.isReactComponent)}function xi(C,A,L){if(C==null)return"";if(typeof C=="function")return It(C,Et(C));if(typeof C=="string")return be(C);switch(C){case d:return be("Suspense");case p:return be("SuspenseList")}if(typeof C=="object")switch(C.$$typeof){case u:return Rt(C.render);case h:return xi(C.type,A,L);case f:{var G=C,ee=G._payload,oe=G._init;try{return xi(oe(ee),A,L)}catch{}}}return""}var yi=Object.prototype.hasOwnProperty,cm={},um=S.ReactDebugCurrentFrame;function bi(C){if(C){var A=C._owner,L=xi(C.type,C._source,A?A.type:null);um.setExtraStackFrame(L)}else um.setExtraStackFrame(null)}function rO(C,A,L,G,ee){{var oe=Function.call.bind(yi);for(var J in C)if(oe(C,J)){var K=void 0;try{if(typeof C[J]!="function"){var We=Error((G||"React class")+": "+L+" type `"+J+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof C[J]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw We.name="Invariant Violation",We}K=C[J](A,J,G,L,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(ve){K=ve}K&&!(K instanceof Error)&&(bi(ee),T("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",G||"React class",L,J,typeof K),bi(null)),K instanceof Error&&!(K.message in cm)&&(cm[K.message]=!0,bi(ee),T("Failed %s type: %s",L,K.message),bi(null))}}}var sO=Array.isArray;function ql(C){return sO(C)}function iO(C){{var A=typeof Symbol=="function"&&Symbol.toStringTag,L=A&&C[Symbol.toStringTag]||C.constructor.name||"Object";return L}}function aO(C){try{return dm(C),!1}catch{return!0}}function dm(C){return""+C}function pm(C){if(aO(C))return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",iO(C)),dm(C)}var Zr=S.ReactCurrentOwner,oO={key:!0,ref:!0,__self:!0,__source:!0},hm,fm,Vl;Vl={};function lO(C){if(yi.call(C,"ref")){var A=Object.getOwnPropertyDescriptor(C,"ref").get;if(A&&A.isReactWarning)return!1}return C.ref!==void 0}function cO(C){if(yi.call(C,"key")){var A=Object.getOwnPropertyDescriptor(C,"key").get;if(A&&A.isReactWarning)return!1}return C.key!==void 0}function uO(C,A){if(typeof C.ref=="string"&&Zr.current&&A&&Zr.current.stateNode!==A){var L=Fe(Zr.current.type);Vl[L]||(T('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',Fe(Zr.current.type),C.ref),Vl[L]=!0)}}function dO(C,A){{var L=function(){hm||(hm=!0,T("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",A))};L.isReactWarning=!0,Object.defineProperty(C,"key",{get:L,configurable:!0})}}function pO(C,A){{var L=function(){fm||(fm=!0,T("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",A))};L.isReactWarning=!0,Object.defineProperty(C,"ref",{get:L,configurable:!0})}}var hO=function(C,A,L,G,ee,oe,J){var K={$$typeof:t,type:C,key:A,ref:L,props:J,_owner:oe};return K._store={},Object.defineProperty(K._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(K,"_self",{configurable:!1,enumerable:!1,writable:!1,value:G}),Object.defineProperty(K,"_source",{configurable:!1,enumerable:!1,writable:!1,value:ee}),Object.freeze&&(Object.freeze(K.props),Object.freeze(K)),K};function fO(C,A,L,G,ee){{var oe,J={},K=null,We=null;L!==void 0&&(pm(L),K=""+L),cO(A)&&(pm(A.key),K=""+A.key),lO(A)&&(We=A.ref,uO(A,ee));for(oe in A)yi.call(A,oe)&&!oO.hasOwnProperty(oe)&&(J[oe]=A[oe]);if(C&&C.defaultProps){var ve=C.defaultProps;for(oe in ve)J[oe]===void 0&&(J[oe]=ve[oe])}if(K||We){var we=typeof C=="function"?C.displayName||C.name||"Unknown":C;K&&dO(J,we),We&&pO(J,we)}return hO(C,K,We,ee,G,Zr.current,J)}}var Nl=S.ReactCurrentOwner,mm=S.ReactDebugCurrentFrame;function or(C){if(C){var A=C._owner,L=xi(C.type,C._source,A?A.type:null);mm.setExtraStackFrame(L)}else mm.setExtraStackFrame(null)}var $l;$l=!1;function Fl(C){return typeof C=="object"&&C!==null&&C.$$typeof===t}function gm(){{if(Nl.current){var C=Fe(Nl.current.type);if(C)return`
22
22
 
23
- Check the render method of \``+C+"`."}return""}}function wz(C){{if(C!==void 0){var M=C.fileName.replace(/^.*[\\\/]/,""),P=C.lineNumber;return`
23
+ Check the render method of \``+C+"`."}return""}}function mO(C){{if(C!==void 0){var A=C.fileName.replace(/^.*[\\\/]/,""),L=C.lineNumber;return`
24
24
 
25
- Check your code at `+M+":"+P+"."}return""}}var zu={};function Cz(C){{var M=Du();if(!M){var P=typeof C=="string"?C:C.displayName||C.name;P&&(M=`
25
+ Check your code at `+A+":"+L+"."}return""}}var xm={};function gO(C){{var A=gm();if(!A){var L=typeof C=="string"?C:C.displayName||C.name;L&&(A=`
26
26
 
27
- Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(!C._store||C._store.validated||C.key!=null)return;C._store.validated=!0;var P=Cz(M);if(zu[P])return;zu[P]=!0;var G="";C&&C._owner&&C._owner!==Ni.current&&(G=" It was passed a child from "+Ge(C._owner.type)+"."),en(C),z('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',P,G),en(null)}}function Iu(C,M){{if(typeof C!="object")return;if(Oi(C))for(var P=0;P<C.length;P++){var G=C[P];Fi(G)&&Mu(G,M)}else if(Fi(C))C._store&&(C._store.validated=!0);else if(C){var ee=T(C);if(typeof ee=="function"&&ee!==C.entries)for(var se=ee.call(C),X;!(X=se.next()).done;)Fi(X.value)&&Mu(X.value,M)}}}function Sz(C){{var M=C.type;if(M==null||typeof M=="string")return;var P;if(typeof M=="function")P=M.propTypes;else if(typeof M=="object"&&(M.$$typeof===u||M.$$typeof===h))P=M.propTypes;else return;if(P){var G=Ge(M);dz(P,C.props,"prop",G,C)}else if(M.PropTypes!==void 0&&!Gi){Gi=!0;var ee=Ge(M);z("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ee||"Unknown")}typeof M.getDefaultProps=="function"&&!M.getDefaultProps.isReactClassApproved&&z("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function kz(C){{for(var M=Object.keys(C.props),P=0;P<M.length;P++){var G=M[P];if(G!=="children"&&G!=="key"){en(C),z("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",G),en(null);break}}C.ref!==null&&(en(C),z("Invalid attribute `ref` supplied to `React.Fragment`."),en(null))}}function Eu(C,M,P,G,ee,se){{var X=Ye(C);if(!X){var K="";(C===void 0||typeof C=="object"&&C!==null&&Object.keys(C).length===0)&&(K+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var Me=wz(ee);Me?K+=Me:K+=Du();var pe;C===null?pe="null":Oi(C)?pe="array":C!==void 0&&C.$$typeof===e?(pe="<"+(Ge(C.type)||"Unknown")+" />",K=" Did you accidentally export a JSX literal instead of a component?"):pe=typeof C,z("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",pe,K)}var xe=jz(C,M,P,ee,se);if(xe==null)return xe;if(X){var Ke=M.children;if(Ke!==void 0)if(G)if(Oi(Ke)){for(var tn=0;tn<Ke.length;tn++)Iu(Ke[tn],C);Object.freeze&&Object.freeze(Ke)}else z("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else Iu(Ke,C)}return C===r?kz(xe):Sz(xe),xe}}function Tz(C,M,P){return Eu(C,M,P,!0)}function Dz(C,M,P){return Eu(C,M,P,!1)}var zz=Dz,Mz=Tz;an.Fragment=r,an.jsx=zz,an.jsxs=Mz}()),an}process.env.NODE_ENV==="production"?Ss.exports=Cd():Ss.exports=Sd();var s=Ss.exports;const at={CryptoJS:Wi,d3Array:wd,dayjs:I,lodash:b,numbro:Cn,mathjs:Vt,faker:Pu.faker},kd=[{name:"CryptoJS",url:"https://github.com/brix/crypto-js",version:"4.1.1"},{name:"d3Array",url:"https://github.com/d3/d3-array",version:"3.2.0"},{name:"dayjs",url:"https://day.js.org/",version:"1.11.6"},{name:"lodash",url:"https://lodash.com/docs/4.17.15",version:"4.17.21"},{name:"mathjs",url:"https://mathjs.org/",version:"11.7.0"},{name:"numbro",url:"https://numbrojs.com/",version:"2.3.6"},{name:"faker",url:"https://fakerjs.dev/",version:"7.6.0"}],Td=t=>`
27
+ Check the top-level render call using <`+L+">.")}return A}}function ym(C,A){{if(!C._store||C._store.validated||C.key!=null)return;C._store.validated=!0;var L=gO(A);if(xm[L])return;xm[L]=!0;var G="";C&&C._owner&&C._owner!==Nl.current&&(G=" It was passed a child from "+Fe(C._owner.type)+"."),or(C),T('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',L,G),or(null)}}function bm(C,A){{if(typeof C!="object")return;if(ql(C))for(var L=0;L<C.length;L++){var G=C[L];Fl(G)&&ym(G,A)}else if(Fl(C))C._store&&(C._store.validated=!0);else if(C){var ee=k(C);if(typeof ee=="function"&&ee!==C.entries)for(var oe=ee.call(C),J;!(J=oe.next()).done;)Fl(J.value)&&ym(J.value,A)}}}function xO(C){{var A=C.type;if(A==null||typeof A=="string")return;var L;if(typeof A=="function")L=A.propTypes;else if(typeof A=="object"&&(A.$$typeof===u||A.$$typeof===h))L=A.propTypes;else return;if(L){var G=Fe(A);rO(L,C.props,"prop",G,C)}else if(A.PropTypes!==void 0&&!$l){$l=!0;var ee=Fe(A);T("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",ee||"Unknown")}typeof A.getDefaultProps=="function"&&!A.getDefaultProps.isReactClassApproved&&T("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function yO(C){{for(var A=Object.keys(C.props),L=0;L<A.length;L++){var G=A[L];if(G!=="children"&&G!=="key"){or(C),T("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",G),or(null);break}}C.ref!==null&&(or(C),T("Invalid attribute `ref` supplied to `React.Fragment`."),or(null))}}function vm(C,A,L,G,ee,oe){{var J=Ie(C);if(!J){var K="";(C===void 0||typeof C=="object"&&C!==null&&Object.keys(C).length===0)&&(K+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var We=mO(ee);We?K+=We:K+=gm();var ve;C===null?ve="null":ql(C)?ve="array":C!==void 0&&C.$$typeof===t?(ve="<"+(Fe(C.type)||"Unknown")+" />",K=" Did you accidentally export a JSX literal instead of a component?"):ve=typeof C,T("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",ve,K)}var we=fO(C,A,L,ee,oe);if(we==null)return we;if(J){var yt=A.children;if(yt!==void 0)if(G)if(ql(yt)){for(var lr=0;lr<yt.length;lr++)bm(yt[lr],C);Object.freeze&&Object.freeze(yt)}else T("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else bm(yt,C)}return C===s?yO(we):xO(we),we}}function bO(C,A,L){return vm(C,A,L,!0)}function vO(C,A,L){return vm(C,A,L,!1)}var _O=vO,jO=bO;pr.Fragment=s,pr.jsx=_O,pr.jsxs=jO}()),pr}process.env.NODE_ENV==="production"?ji.exports=mg():ji.exports=gg();var r=ji.exports;const vt={CryptoJS:Ql,d3Array:fg,dayjs:P,lodash:v,numbro:Hr,mathjs:On,faker:jm.faker},xg=[{name:"CryptoJS",url:"https://github.com/brix/crypto-js",version:"4.1.1"},{name:"d3Array",url:"https://github.com/d3/d3-array",version:"3.2.0"},{name:"dayjs",url:"https://day.js.org/",version:"1.11.6"},{name:"lodash",url:"https://lodash.com/docs/4.17.15",version:"4.17.21"},{name:"mathjs",url:"https://mathjs.org/",version:"11.7.0"},{name:"numbro",url:"https://numbrojs.com/",version:"2.3.6"},{name:"faker",url:"https://fakerjs.dev/",version:"7.6.0"}],yg=e=>`
28
28
  <tr>
29
- <td><code>${t.name}</code></td>
29
+ <td><code>${e.name}</code></td>
30
30
  <td>
31
31
  <a
32
32
  target="_blank"
33
33
  rel="noopener noreferrer nofollow"
34
- href="${t.url}"
35
- >${t.name}@${t.version}</a
34
+ href="${e.url}"
35
+ >${e.name}@${e.version}</a
36
36
  >
37
37
  </td>
38
38
  </tr>
39
- `,Dd=t=>`
39
+ `,bg=e=>`
40
40
  <p>
41
- ${t("function_utils.description")}
41
+ ${e("function_utils.description")}
42
42
  </p>
43
43
  <table>
44
44
  <thead>
45
45
  <tr>
46
- <th>${t("common.name")}</th>
47
- <th>${t("function_utils.document")}</th>
46
+ <th>${e("common.name")}</th>
47
+ <th>${e("function_utils.document")}</th>
48
48
  </tr>
49
49
  </thead>
50
50
  <tbody>
51
- ${kd.map(Td).join("")}
51
+ ${xg.map(yg).join("")}
52
52
  </tbody>
53
53
  </table>
54
- `;function ks(t,e){const n=Object.keys(e),r=Object.values(e);try{return new Function(...n,`return \`${t}\`;`)(...r)}catch(i){throw n.length===0&&t.includes("$")?new Error("[formatSQL] insufficient payload"):i}}function Ts(t,e){try{return ks(t,e)}catch(n){return console.error(n),n.message}}function zd({sql:t,pre_process:e}){if(!e.trim())return t;try{return new Function(`return ${e}`)()({sql:t},at)}catch(n){return console.error(n),t}}function Md(t,e,n){if(!t.trim())return e;try{return new Function(`return ${t}`)()(e,at,n)}catch(r){return console.error(r),e}}function Id(t){t=t||{};const e=Object.keys(t).sort(),n=[];for(let r=0;r<e.length;r++){const i=e[r];if(i!="authentication"&&t[i])n.push(e[r]+"="+(typeof t[i]=="object"?JSON.stringify(t[i]):t[i]));else{const o=Object.keys(t[i]).sort();for(let l=0;l<o.length;l++){const c=o[l];c!="sign"&&t[i][c]&&n.push(o[l]+"="+(typeof t[i][c]=="object"?JSON.stringify(t[i][c]):t[i][c]))}}}return n.sort().join("&")}function Ed(t,e){let n=Id(t);return n+="&key="+e,jd.MD5(n).toString().toUpperCase()}class xa{constructor(){this.type="default_api_client",this.baseURL="http://localhost:31200",this.app_id="",this.app_secret=""}getAuthentication(e){if(!this.app_id||!this.app_secret)return;const n=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:n,sign:Ed({app_id:this.app_id,nonce_str:n,...e},this.app_secret)}}getRequest(e,n){return(r,i,o,l)=>{const c=this.buildHeader(o),u=this.buildAxiosConfig(e,r,i,o,c,n);return rt(u).then(d=>l?d:d.data).catch(d=>{if(rt.isCancel(d))return Promise.reject(d);const p=b.get(d,"response.data.detail.message",d.message);return Promise.reject(new Error(p))})}}get(e){return this.getRequest("GET",e)}post(e){return this.getRequest("POST",e)}put(e){return this.getRequest("PUT",e)}buildAxiosConfig(e,n,r,i,o,l){const c={baseURL:this.baseURL,method:e,url:n,params:e==="GET"?r:i.params,headers:o,signal:l};return["POST","PUT"].includes(e)&&(c.data=i.string?JSON.stringify(r):r,c.data.authentication=this.getAuthentication(c.data)),c}buildHeader(e){const n=window.localStorage.getItem("token");return{"X-Requested-With":"XMLHttpRequest","Content-Type":e.string?"application/x-www-form-urlencoded":"application/json",authorization:n?`bearer ${n}`:"",...e.headers}}}class Ad{constructor(e){this.implementation=e}getRequest(e,n){return this.implementation.getRequest(e,n)}get(e){return this.getRequest("GET",e)}post(e){return this.getRequest("POST",e)}put(e){return this.getRequest("PUT",e)}}class ga extends xa{constructor(){super(...arguments);$(this,"makeQueryENV",null)}query(n){return async(r,i={})=>{var o;return r.env||(r.env=((o=this.makeQueryENV)==null?void 0:o.call(this))??{error:"failed to run makeQueryENV"}),this.post(n)("/query",r,i)}}httpDataSourceQuery(n){return async(r,i={})=>{var o;return r.env||(r.env=((o=this.makeQueryENV)==null?void 0:o.call(this))??{error:"failed to run makeQueryENV"}),this.getRequest("POST",n)("/query",r,i,!0)}}structure(n){return async(r,i={})=>this.post(n)("/query/structure",r,i)}}class fa{constructor(e){this.implementation=e}query(e){return this.implementation.query(e)}httpDataSourceQuery(e){return this.implementation.httpDataSourceQuery(e)}structure(e){return this.implementation.structure(e)}getRequest(e,n){return this.implementation.getRequest(e,n)}get(e){return this.getRequest("GET",e)}post(e){return this.getRequest("POST",e)}put(e){return this.getRequest("PUT",e)}}const Nt=new ga;function Ds(t){Nt.baseURL!==t.apiBaseURL&&(Nt.baseURL=t.apiBaseURL),t.app_id&&(Nt.app_id=t.app_id),t.app_secret&&(Nt.app_secret=t.app_secret),t.makeQueryENV&&(Nt.makeQueryENV=t.makeQueryENV)}const ya=new fa(Nt),ot=ya,on=m.forwardRef(function({value:e,onChange:n,...r},i){return s.jsx(a.TextInput,{ref:i,value:e,onChange:n,...r})});function A(t){const[e,n]=t.split(".");return{queryID:e,columnKey:n}}function Pd(t){return t.includes(".")?A(t):{queryID:"",columnKey:t}}function Xe(t,e){var i;const{queryID:n,columnKey:r}=A(e);return n?r?((i=t[n])==null?void 0:i.map(o=>o[r]))??[]:t[n]:[]}function Tn(t,e){const{queryID:n}=A(e);return n?t[n]:[]}function $d(t){return Object.values(t)[0]}function Dn(t,e){const{queryID:n,columnKey:r}=A(e);return t[r]}const ba=["function aggregation({ queryData }, utils) {",' return "Aggregation Result";',"}"].join(`
55
- `),Gt={type:"none",config:{},fallback:"0"};function Bd(t){const e=Array.from(t).sort((r,i)=>r-i),n=Math.floor(e.length/2);return e.length%2===0?(e[n-1]+e[n])/2:e[n]}function Ld(t,e){switch(e.type){case"sum":return b.sum(t);case"mean":return b.mean(t);case"median":return Bd(t);case"max":return b.max(t);case"min":return b.min(t);case"quantile":return nn.quantile(t,e.config.p);case"CV":const n=Vt.std(...t),r=Vt.mean(...t);return r?n/r:Number.NaN;case"std":return Vt.std(...t);default:return t}}function zs(t,e){const n=t.map(Number),r=Ld(n,e);return typeof r=="number"?Number.isFinite(r)?r:e.fallback:r??e.fallback}function qd(t,e,n){try{const r=Tn(t,e);return new Function(`return ${n.config.func}`)()({queryData:r},at)}catch(r){return console.error(r),r.message}}function Od(t,e,n){try{const r=Xe(t,e),{method:i}=n.config;return b[i](r)}catch(r){return console.error(r),n.fallback}}function zn(t,e,n){try{return n.type==="custom"?qd(t,e,n):n.type==="pick_record"?Od(t,e,n):zs(Xe(t,e),n)}catch(r){return console.error(r),null}}class Vd{constructor({valueRange:e,colorRange:n}){$(this,"mapper");this.mapper=Dt.interpolate(e,n)}getColor(e){return this.mapper(e)}}const _e={mantissa:0,output:"number",trimMantissa:!1,average:!1,absolute:!1};function U(t,{absolute:e,...n}){if(t===null)return String(t);try{let r=Cn(t).value();if(r===void 0||Number.isNaN(r))throw new Error(`[formatNumber]Not a number: ${t}`);return e&&(r=Math.abs(r)),Cn(r).format(n)}catch(r){return console.debug(r),String(t)}}function Nd(t){return t===null?"null":t===void 0?"undefined":Array.isArray(t)?`Array(${t.length})`:t.toString()}function Ze({data_field:t,aggregation:e},n){return zn(n,t,e)}function Ie({formatter:t,aggregation:e},n){if(typeof n!="string"&&typeof n!="number")return Nd(n);if(e.type==="custom")return n;try{return U(n,t)}catch(r){return console.error(r),n}}function Gd(t,e){if(t.type==="static")return t.staticColor;if(t.type==="continuous")try{if(typeof e!="number")throw new Error(`[getColorByColorConf] Invalid type of aggregated value: ${e}`);return new Vd(t).getColor(e)}catch(n){return console.error(n),"black"}return"black"}function Fd(t,e){const{color:n,data_field:r,aggregation:i,size:o,weight:l}=t,c=zn(e,r,i),u=Ie(t,c);return s.jsx(a.Text,{sx:{fontSize:o,display:"inline"},color:Gd(n,c),weight:l,children:u})}function Wd(t,e){const n={};return t.forEach(r=>{const i=r.name;n[i]=Fd(r,e)}),n}function Qd(t){return t.split(" ").map((e,n)=>s.jsxs(m.Fragment,{children:[e," "]},n))}function Rd(t){const n=t.replaceAll("<br />","<br/>").replaceAll(`
56
- `,"<br/>").split("<br/>");return n.map((i,o)=>{const l=[Qd(i)];return o!==n.length-1&&l.push(s.jsx("br",{},`br-${o}`)),l}).flat().filter(i=>i!==void 0)}function Ms(t){return Rd(t)}function ln(t,e,n){const r=Wd(e,n),i=/^\{(.+)\}(.*)$/;return t.split("$").map((o,l)=>{const c=i.exec(o);if(!c)return Ms(o);const u=r[c[1]];if(!u)return Ms(o);const d=c[2]??"";return s.jsxs(m.Fragment,{children:[u,Ms(d)]},`${o}-${l}`)})}function Ud(t,e){const{data_field:n,aggregation:r}=t,i=zn(e,n,r);return Ie(t,i)}function va(t,e){const n={};return t.forEach(r=>{n[r.name]=Ud(r,e)}),n}function cn(t,e,n){const r=va(e,n),i=/^\{(.+)\}(.*)$/;return t.split("$").map(o=>{const l=i.exec(o);if(!l)return o;const c=r[l[1]];if(!c)return o;const u=l[2]??"";return`${c}${u}`}).join("")}const zt={grid:{axis:"#97999D",scope:"rgba(47,140,192,0.1)",boundary:"#789AB4",reference:"#CFCFD8"},graphics:{compared:{blueDark:"#3E7CAB",blue:"#6398C7",blueLight:"#7CB0DF",blue10:"#6398C71a",redDark:"#AF5F6B",red:"#CD7C88",redLight:"#E794A0",red10:"#CD7C881a"},gradient:{distributed:"linear-gradient(90deg, #1babe6 0%, #2fc8c8 28.63%, #98d44b 48.86%, #ffd057 67.53%, #f5ae53 80.6%, #e76441 91.18%, #b90000 100%)",protrude:"linear-gradient(180deg, #ec73734d 0%, #ec737300 100%)"},level:{lv0:"#6398C7",lv1:"#61B5BF",lv2:"#54D4BB",lv3:"#F5D277",lv4:"#E8BB7F",lv5:"#DB9E84",lv6:"#CB8089"},depth:{dp0:"#FFF7F8",dp1:"#FFE1E1",dp2:"#FDBCBC",dp3:"#F39494",dp4:"#FA4242",dp5:"#E21212"},multiple:{c1:"#66B4DB",c2:"#E46464",c3:"#EEBA00",c4:"#33A678",c5:"#9D88CB",c6:"#939943",c7:"#E49792",c8:"#09A2B8",c9:"#AF5F6B",c10:"#6CA157",c11:"#3E7CAB",c12:"#6398C7",c13:"#E692BA",c14:"#97B566",c15:"#8CACE2",c16:"#CA79AC",c17:"#6DBC80",c18:"#B08F4B",c19:"#39BFA2",c20:"#826BAF"}}};function Yd(){Ce.registerTheme("merico-light",{color:Object.values(zt.graphics.multiple),visualMap:{color:Object.values(zt.graphics.depth).reverse()},axes:[{type:"all",name:"通用坐标轴",axisLineColor:"#97999D",axisTickColor:"#97999D",axisLabelShow:!0,axisLabelColor:"#818388",splitLineShow:!0,splitLineColor:["#E0E6F1"]}]})}function _a(){Yd()}function*Kd(t){const e=zt.graphics[t];if(!e)throw new Error("Invalid palette key provided");const n=Object.values(e);let r=0;for(;;)yield n[r%n.length],r++}function ja(){return{filters:{},context:{}}}function Is(t){const e=ja();if(!t)return ja();const{filters:n=e.filters,context:r=e.context}=t;return{filters:n,context:r}}class je extends m.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}render(){var e;if(this.state.error){const n=()=>{this.setState({error:null})};return s.jsxs(a.Box,{children:[s.jsx(a.Text,{size:"xs",children:(e=this.state.error)==null?void 0:e.message}),s.jsx(a.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}function Jd(t,e={handleError:!0}){return n=>s.jsx(je,{...e,children:s.jsx(t,{...n})})}function Xd(t,e){return new Function(`return ${t}`)()(e,at)}function Zd(t,e,n){return Xd(t,{context:e,filters:n})}function Hd(t,e){try{return new Function(`return ${t.config.processing.pre}`)()(e,at)}catch(n){return console.error(n),e}}function ep(t,e){return new Function(`return ${t.config.processing.post}`)()(e,at)}function tp(t,e,n){return t?new Function(`return ${t}`)()(e,at,n):e}function wa(){Qi.use([Bu.CanvasRenderer,it.BarChart,it.BoxplotChart,it.CustomChart,it.FunnelChart,it.HeatmapChart,it.LineChart,it.PieChart,it.RadarChart,it.ScatterChart,it.SunburstChart,vt.CalendarComponent,vt.DataZoomComponent,vt.GridComponent,vt.LegendComponent,vt.TooltipComponent,vt.MarkLineComponent,vt.MarkAreaComponent,vt.VisualMapComponent])}const Ft=t=>b.cloneDeepWith(t,(e,n)=>{if(n!==void 0&&e)return J.toJS(e)}),Mn={sqlSnippet:new RegExp("(?<=sql_snippets\\.)([^\\?}.]+)","gm"),context:new RegExp("(?<=context\\.)([^\\?}.]+)","gm"),filter:new RegExp("(?<=filters\\.)([^\\?}.]+)","gm")};function np(t,e){const n=Ri.decode(e);n!==t&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:t,after:e,v:n}),console.groupEnd())}async function sp({query:t,name:e,payload:n,additionals:r},i){if(!t.sql)return[];const{type:o,key:l,sql:c,pre_process:u,post_process:d}=t,p=ks(c,n),h=zd({sql:p,pre_process:u}),g=Ri.encode(h);np(h,g);let f=await ot.query(i)({type:o,key:l,query:g,...r},{params:{name:e}});return f=Md(d,f,Is(n)),f}async function rp({type:t,key:e,configString:n,name:r,additionals:i},o){try{return await ot.httpDataSourceQuery(o)({type:t,key:e,query:n,...i},{params:{name:r}})}catch(l){if(rt.isCancel(l))throw l;return console.error(l),l}}async function Es(){try{return(await ot.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(t){return console.error(t),[]}}async function Ca(){try{return(await ot.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(t){return console.error(t),[]}}class Sa{constructor(e){$(this,"rootRef");this.rootRef=J.observable({current:e})}async deleteItem(e){J.runInAction(()=>{b.unset(this.rootRef.current,[e])})}getItem(e){const n=this.getValueFromRoot(e);return Promise.resolve(n)}getValueFromRoot(e){return e===null?J.toJS(this.rootRef.current):b.get(this.rootRef.current,[e])}setItem(e,n){if(e===null)if(b.isObject(n))J.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else J.runInAction(()=>{b.set(this.rootRef.current,[e],n)});return Promise.resolve(this.getItem(e))}watchItem(e,n,r){return J.reaction(()=>this.getValueFromRoot(e),(i,o)=>{n(i,o)},{requiresObservable:!0,fireImmediately:b.get(r,"fireImmediately",!1)})}}class ip{constructor(){$(this,"channels",new Map);$(this,"globalChannel",new Ui)}getChannel(e){const n=this.channels.get(e);if(n)return n;const r=new Ui;return this.channels.set(e,r),r}}class ap{constructor(e){$(this,"instances",new Map);this.pluginManager=e}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(e=>e.manifest.viz)}resolveComponent(e){return this.pluginManager.factory.viz(e)}getOrCreateInstance(e){const n=this.instances.get(e.id);if(n)return n;const r={id:e.id,name:e.viz.type,type:e.viz.type,messageChannels:new ip,instanceData:new Sa(e.viz.conf)};return this.instances.set(e.id,r),r}}function ka(t,e,n,r){return{vizManager:n,locale:"zh",msgChannels:t.messageChannels,instanceData:t.instanceData,pluginData:new Sa({}),colorPalette:{getColor(){return()=>""}},data:e,variables:r}}const op=t=>{const{panel:e,measure:n,vizManager:r,data:i,variables:o}=t,l=r.resolveComponent(e.viz.type),c=r.getOrCreateInstance(e),u={...ka(c,i,r,o),viewport:{width:n.w,height:n.h}},d=l.viewRender;return s.jsx(d,{context:u,instance:c,...b.omit(t,["panel","vizManager","data"])})},lp=t=>{const{vizManager:e,panel:n,data:r,variables:i}=t,o=e.resolveComponent(n.viz.type),l=e.getOrCreateInstance(n),c={...ka(l,r,e,i)},u=o.configRender;return s.jsx(u,{context:c,instance:l,...b.omit(t,["panel","vizManager","data"])})},Ta=(t,e)=>{const n=dt.bezier(t),r=dt.bezier(e);return function(i){return i<50?n(i*2/100).hex():r((i-50)*2/100).hex()}},In=t=>{const e=dt.bezier(t);return function(n){return e(n/100).hex()}},cp={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:Ta(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},up={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:Ta(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},dp={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:In(["#fff7f1","darkred"]),name:"red",category:"sequential"},pp={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:In(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},hp={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:In(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},mp={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:In(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class xp{constructor(e){$(this,"symbol");this.symbol=Symbol(e)}}function ht(t){return new xp(t)}class As{constructor(){$(this,"parent");$(this,"factoryRegistry",new Map);$(this,"instanceRegistry",new Map)}createScoped(){const e=new As;return e.parent=this,e}getRequired(e){return this.get(e)}get(e){if(this.instanceRegistry.has(e.symbol))return this.instanceRegistry.get(e.symbol);const n=this.factoryRegistry.get(e.symbol);if(n){const r=n(this);return this.instanceRegistry.set(e.symbol,r),r}if(this.parent)return this.parent.get(e)}provideFactory(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,n),this}provideValue(e,n){return this.factoryRegistry.has(e.symbol)?console.warn(`Token ${e.symbol.toString()} is already registered`):this.factoryRegistry.set(e.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(e=>{const n=b.get(e,"dispose");b.isFunction(n)&&n.bind(e)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const Da="13.19.0",gp=Object.freeze(Object.defineProperty({__proto__:null,version:Da},Symbol.toStringTag,{value:"Module"}));class fp{constructor(e){$(this,"staticColors",new Map);$(this,"interpolations",new Map);e.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(e){const n=this.encodeColor(e);e.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.staticColors.set(n,e)):e.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`,`the interpolation '${e.name}' has been registered under '${e.category}', previous registered value will be overridden`),this.interpolations.set(n,e))}decodeStaticColor(e){return this.staticColors.get(e)}encodeColor(e){return`\${${e.category}}.{${e.name}}`}decodeInterpolation(e){return this.interpolations.get(e)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class yp{constructor(){$(this,"plugins",new Map);$(this,"vizComponents",new Map);$(this,"factory",{viz:e=>{const n=this.vizComponents.get(e);if(n)return n;throw new Error(`Viz Component (${e}) not found`)}})}install(e){if(this.plugins.has(e.id))throw new Error(`Plugin (${e.id}) has been installed before`);this.plugins.set(e.id,e);for(const n of e.manifest.viz){if(this.vizComponents.has(n.name))throw new Error(`Viz Component (${n.name}) has been installed before`);this.vizComponents.set(n.name,n)}}get installedPlugins(){return Array.from(this.plugins.values())}}class bp{constructor(){$(this,"migrations",[])}version(e,n){return this.migrations.push({version:e,handler:n}),this}run(e,n,r){var l;if(e.from===e.to)return n;if(e.from>e.to)throw new Error(`Can not downgrade from version '${e.from}' to (${e.to})`);const i=this.migrations.filter(c=>c.version>e.from&&c.version<=e.to),o=b.orderBy(i,"version","asc");if(((l=b.last(o))==null?void 0:l.version)!==e.to)throw new Error(`Migration to version ${e.to} not found`);return o.reduce((c,u)=>u.handler(c,r),n)}}class ce extends bp{constructor(){super(),this.configVersions()}version(e,n){return super.version(e,(r,i)=>({version:e,...n(r,i)}))}async migrate({configData:e,panelModel:n}){const r=await e.getItem(null),i=b.get(r,"version",0),o=this.run({from:i,to:this.VERSION},r,{panelModel:n});await e.setItem(null,o)}async needMigration({configData:e}){const n=await e.getItem(null);return b.get(n,"version",0)<this.VERSION}}const q=(t,e)=>{const[n,{setFalse:r}]=W.useBoolean(!0),[i,o]=m.useState();m.useEffect(()=>(t.getItem(e).then(c=>{o(c),r()}),t.watchItem(e,c=>{o(c)})));const l=m.useCallback(async c=>{await t.setItem(e,c),o(c)},[t,e]);return{loading:n,value:i,set:l}},Ee={top:16,right:16,bottom:16,left:16},He=t=>Math.max(0,t-Ee.left-Ee.right),et=t=>Math.max(0,t-Ee.top-Ee.bottom),un=(t,e)=>({width:He(t),height:et(e)}),Ae=({width:t,height:e,children:n})=>s.jsx(a.Box,{pt:Ee.top,pr:Ee.right,pb:Ee.bottom,pl:Ee.left,sx:{width:t,height:e,overflow:"hidden",position:"relative"},children:n}),Ps={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function vp({context:t}){const{value:e}=q(t.instanceData,"config"),n=t.data,{width:r,height:i}=t.viewport,{x_axis_data_key:o,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=b.defaults({},e,Ps),h=m.useMemo(()=>Tn(n,o),[n,o]),{x:g,y:f,z:v}=m.useMemo(()=>({x:A(o),y:A(l),z:A(c)}),[o,l,c]),{min:w,max:T}=m.useMemo(()=>{const z=b.minBy(h,V=>V[v.columnKey]),E=b.maxBy(h,V=>V[v.columnKey]);return{min:b.get(z,v.columnKey),max:b.get(E,v.columnKey)}},[h,v]),D={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:w,max:T,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:p,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(z=>[z[g.columnKey],z[f.columnKey],z[v.columnKey]])}]};return e?s.jsx(Ae,{width:r,height:i,children:s.jsx(Se,{echarts:Ce,option:D,style:un(r,i),notMerge:!0,theme:"merico-light"})}):null}const za=m.createContext(null),$s=za.Provider;function Bs(){const t=m.useContext(za);if(!t)throw new Error("Please use DashboardModelContextProvider");return t}const Z=()=>Bs(),Ma=()=>Bs(),Ia=m.createContext({searchButtonProps:{}}),Ls=Ia.Provider;function Ea(){return m.useContext(Ia)}const Aa=m.createContext(null),qs=Aa.Provider;function Pa(){const t=m.useContext(Aa);if(!t)throw new Error("Please use ContentModelContextProvider");return t}const Y=()=>Pa(),he=()=>Pa(),_p={inEditMode:!1},En=m.createContext(_p),$a=m.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),Os=$a.Provider;function Ba(){const t=m.useContext($a);if(!t.panel)throw new Error("Please use PanelContextProvider");return t}const mt=()=>Ba(),ze=()=>Ba(),jp={fullScreenPanelID:"",setFullScreenPanelID:b.noop},Vs=m.createContext(jp);function La(){const t=m.useContext(Vs);if(!t)throw new Error("Please use FullScreenPanelContext.Provider");return t}const wp={en:"en",zh:"zh-cn"};function Ns({children:t}){const{i18n:e}=_.useTranslation(),n=m.useMemo(()=>{const r=e.language;return wp[r]??"en"},[e.language]);return s.jsx(Yi.DatesProvider,{settings:{locale:n,firstDayOfWeek:1},children:t})}const O=S.observer(m.forwardRef(({label:t,required:e,description:n,value:r,onChange:i,queryID:o,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=ze(),h=m.useMemo(()=>p.dataFieldOptions(r,l,o),[r,l,o]);if(h.length===0){const g=p.explainDataKey(r);return s.jsxs(a.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[s.jsx(a.HoverCard.Target,{children:s.jsx(a.Box,{children:s.jsx(a.TextInput,{label:t,required:e,defaultValue:g.columnKey,readOnly:!0,disabled:!0})})}),s.jsx(a.HoverCard.Dropdown,{children:s.jsxs(a.Group,{position:"left",spacing:0,children:[s.jsx(a.Text,{size:"xs",color:g.queryName?"black":"red",sx:{fontFamily:"monospace"},children:g.queryName??g.queryID}),s.jsx(a.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),s.jsx(a.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:g.columnKey})]})})]})}return s.jsx(a.Select,{ref:d,label:t,description:n,data:h,value:r,onChange:i,required:e,sx:c,maxDropdownHeight:500,...u})}));function Cp({context:t}){const{value:e,set:n}=q(t.instanceData,"config"),r=b.defaults({},e,Ps),{control:i,handleSubmit:o,reset:l}=y.useForm({defaultValues:r});return m.useEffect(()=>{l(r)},[e]),e?s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:o(n),children:[s.jsx(a.Text,{children:"X Axis"}),s.jsxs(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(y.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>s.jsx(O,{label:"Data Field",required:!0,...c})}),s.jsx(y.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>s.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(a.Text,{mt:"lg",children:"Y Axis"}),s.jsxs(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(y.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>s.jsx(O,{label:"Data Field",required:!0,...c})}),s.jsx(y.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>s.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(a.Text,{mt:"lg",children:"Z Axis"}),s.jsxs(a.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(y.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>s.jsx(O,{label:"Data Field",required:!0,...c})}),s.jsx(y.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>s.jsx(a.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(a.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:s.jsxs(a.Button,{color:"blue",type:"submit",children:[s.jsx(L.DeviceFloppy,{size:20}),s.jsx(a.Text,{ml:"md",children:"Save"})]})})]})}):null}const Sp=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function kp(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:o,z_axis_data_key:l,...c}=t;return{...c,x_axis_data_key:r(i),y_axis_data_key:r(o),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class Tp extends ce{constructor(){super(...arguments);$(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:i}=n;return{...n,version:2,config:kp(i,r)}})}}const Dp={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Tp,name:"bar-3d",viewRender:vp,configRender:Cp,createConfig(){return{version:2,config:b.cloneDeep(Ps)}},translation:Sp},zp=({disabled:t,value:e,onChange:n})=>{const r=i=>{i&&n(i)};return s.jsxs(a.Box,{sx:{position:"relative"},children:[t&&s.jsx(a.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),s.jsx(Le,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:t}})]})};function Pe({enabled:t,func_content:e}){return(n,r)=>{if(!t)return n;try{return new Function(`return ${e}`)()(n,r)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function ke(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
57
- `)}}const tt=m.forwardRef(({value:t,onChange:e,triggerButtonText:n},r)=>{const{t:i}=_.useTranslation(),[o,{setTrue:l,setFalse:c}]=W.useBoolean(),[u,d]=m.useState(t);m.useEffect(()=>{d(t)},[t]);const p=T=>{d({...u,enabled:T})},h=()=>{c();const{enabled:T,func_content:D}=u,z={enabled:T,func_content:D};d(z),e(z)},g=()=>{c(),d(t)},f=T=>{d(D=>({...D,func_content:T}))},v=()=>{f(ke().func_content)},w=n??i("chart.axis.customize_label");return s.jsxs(s.Fragment,{children:[s.jsx(a.Button,{variant:"filled",color:"grape",leftIcon:s.jsx(k.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:w}),s.jsx(a.Modal,{size:800,title:w,opened:o,onClose:c,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:o&&s.jsxs(a.Stack,{children:[s.jsx(a.Checkbox,{mt:10,label:i("common.enabled"),checked:u.enabled,onChange:T=>p(T.currentTarget.checked)}),s.jsx(zp,{value:u.func_content,onChange:f,disabled:!u.enabled}),s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Button,{onClick:v,color:"red",leftIcon:s.jsx(L.Recycle,{size:20}),children:i("common.actions.reset_to_default")}),s.jsxs(a.Group,{position:"right",children:[s.jsx(a.Button,{onClick:g,variant:"subtle",children:i("common.actions.cancel")}),s.jsx(a.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),onClick:h,children:i("common.actions.save")})]})]})]})})]})}),Mt={x_axis_scroll:!1,y_axis_scroll:!1,x_axis_slider:!1,y_axis_slider:!1};function qa(){return b.cloneDeep(Mt)}const Mp=[{lang:"en",resources:{boxplot:{viz_name:"Boxplot Chart",box:"Box",outlier:"Outlier",scatter:"Scatter",click_series:{label:"Click box, scatter or outlier"}}}},{lang:"zh",resources:{boxplot:{viz_name:"箱线图",box:"箱体",outlier:"异常点",scatter:"散点",click_series:{label:"点击箱体、散点或异常点"}}}}],Oa={id:"builtin:echarts:click-echart:series",displayName:"viz.boxplot.click_series.label",nameRender:Ep,configRender:Ip,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 Ip(t){return s.jsx(s.Fragment,{})}function Ep(t){const{t:e}=_.useTranslation();return s.jsx(a.Text,{children:e("viz.boxplot.click_series.label")})}const An=m.forwardRef(({sectionTitle:t,value:e,onChange:n},r)=>{const{t:i,i18n:o}=_.useTranslation(),l=u=>d=>{const p=b.cloneDeep(e);b.set(p,u,d),n(p)},c=m.useMemo(()=>[{label:i("chart.axis.overflow.truncate"),value:"truncate"},{label:i("chart.axis.overflow.break_line"),value:"break"},{label:i("chart.axis.overflow.break_word"),value:"breakAll"}],[o.language]);return s.jsxs(a.Stack,{spacing:0,children:[t&&s.jsx(a.Divider,{mb:-5,mt:5,variant:"dotted",label:t,labelPosition:"right",labelProps:{color:"dimmed"}}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(a.NumberInput,{label:i("chart.axis.overflow.max_width"),hideControls:!0,value:e.width,onChange:l("width")}),s.jsx(a.Select,{label:i("chart.axis.overflow.label"),data:c,value:e.overflow,onChange:l("overflow")}),s.jsx(a.TextInput,{label:i("chart.axis.overflow.ellipsis"),value:e.ellipsis,disabled:!0})]})]})}),nt=m.forwardRef(({value:t,onChange:e},n)=>{const{t:r}=_.useTranslation(),i=l=>{e({...t,on_axis:l})},o=l=>{e({...t,in_tooltip:l})};return s.jsxs(a.Stack,{ref:n,spacing:0,children:[s.jsx(An,{sectionTitle:r("chart.axis.overflow.section_title.on_axis"),value:t.on_axis,onChange:i}),s.jsx(An,{sectionTitle:r("chart.axis.overflow.section_title.in_tooltip"),value:t.in_tooltip,onChange:o})]})});function $e(){return{on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}}}function We({overflow:t,width:e}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[t],r=t==="truncate"?"nowrap":"initial",i={truncate:"ellipsis",break:"clip",breakAll:"clip"}[t];return`
58
- max-width: ${e}px;
54
+ `;function wi(e,t){const n=Object.keys(t),s=Object.values(t);try{return new Function(...n,`return \`${e}\`;`)(...s)}catch(i){throw n.length===0&&e.includes("$")?new Error("[formatSQL] insufficient payload"):i}}function Ci(e,t){try{return wi(e,t)}catch(n){return console.error(n),n.message}}function vg({sql:e,pre_process:t}){if(!t.trim())return e;try{return new Function(`return ${t}`)()({sql:e},vt)}catch(n){return console.error(n),e}}function _g(e,t,n){if(!e.trim())return t;try{return new Function(`return ${e}`)()(t,vt,n)}catch(s){return console.error(s),t}}function jg(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let s=0;s<t.length;s++){const i=t[s];if(i!="authentication"&&e[i])n.push(t[s]+"="+(typeof e[i]=="object"?JSON.stringify(e[i]):e[i]));else{const a=Object.keys(e[i]).sort();for(let l=0;l<a.length;l++){const c=a[l];c!="sign"&&e[i][c]&&n.push(a[l]+"="+(typeof e[i][c]=="object"?JSON.stringify(e[i][c]):e[i][c]))}}}return n.sort().join("&")}function wg(e,t){let n=jg(e);return n+="&key="+t,hg.MD5(n).toString().toUpperCase()}class xc{constructor(){this.type="default_api_client",this.baseURL="http://localhost:31200",this.app_id="",this.app_secret=""}getAuthentication(t){if(!this.app_id||!this.app_secret)return;const n=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:n,sign:wg({app_id:this.app_id,nonce_str:n,...t},this.app_secret)}}getRequest(t,n){return(s,i,a,l)=>{const c=this.buildHeader(a),u=this.buildAxiosConfig(t,s,i,a,c,n);return At(u).then(d=>l?d:d.data).catch(d=>{if(At.isCancel(d))return Promise.reject(d);const p=v.get(d,"response.data.detail.message",d.message);return Promise.reject(new Error(p))})}}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}buildAxiosConfig(t,n,s,i,a,l){const c={baseURL:this.baseURL,method:t,url:n,params:t==="GET"?s:i.params,headers:a,signal:l};return["POST","PUT"].includes(t)&&(c.data=i.string?JSON.stringify(s):s,c.data.authentication=this.getAuthentication(c.data)),c}buildHeader(t){const n=window.localStorage.getItem("token");return{"X-Requested-With":"XMLHttpRequest","Content-Type":t.string?"application/x-www-form-urlencoded":"application/json",authorization:n?`bearer ${n}`:"",...t.headers}}}class Cg{constructor(t){this.implementation=t}getRequest(t,n){return this.implementation.getRequest(t,n)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}class yc extends xc{constructor(){super(...arguments);B(this,"makeQueryENV",null)}query(n){return async(s,i={})=>{var a;return s.env||(s.env=((a=this.makeQueryENV)==null?void 0:a.call(this))??{error:"failed to run makeQueryENV"}),this.post(n)("/query",s,i)}}httpDataSourceQuery(n){return async(s,i={})=>{var a;return s.env||(s.env=((a=this.makeQueryENV)==null?void 0:a.call(this))??{error:"failed to run makeQueryENV"}),this.getRequest("POST",n)("/query",s,i,!0)}}structure(n){return async(s,i={})=>this.post(n)("/query/structure",s,i)}}class bc{constructor(t){this.implementation=t}query(t){return this.implementation.query(t)}httpDataSourceQuery(t){return this.implementation.httpDataSourceQuery(t)}structure(t){return this.implementation.structure(t)}getRequest(t,n){return this.implementation.getRequest(t,n)}get(t){return this.getRequest("GET",t)}post(t){return this.getRequest("POST",t)}put(t){return this.getRequest("PUT",t)}}const Ln=new yc;function Si(e){Ln.baseURL!==e.apiBaseURL&&(Ln.baseURL=e.apiBaseURL),e.app_id&&(Ln.app_id=e.app_id),e.app_secret&&(Ln.app_secret=e.app_secret),e.makeQueryENV&&(Ln.makeQueryENV=e.makeQueryENV)}const vc=new bc(Ln),Ot=vc,hr=m.forwardRef(function({value:t,onChange:n,...s},i){return r.jsx(o.TextInput,{ref:i,value:t,onChange:n,...s})});function O(e){const[t,n]=e.split(".");return{queryID:t,columnKey:n}}function Sg(e){return e.includes(".")?O(e):{queryID:"",columnKey:e}}function _t(e,t){var i;const{queryID:n,columnKey:s}=O(t);return n?s?((i=e[n])==null?void 0:i.map(a=>a[s]))??[]:e[n]:[]}function rs(e,t){const{queryID:n}=O(t);return n?e[n]:[]}function kg(e){return Object.values(e)[0]}function ss(e,t){const{queryID:n,columnKey:s}=O(t);return e[s]}const _c=["function aggregation({ queryData }, utils) {",' return "Aggregation Result";',"}"].join(`
55
+ `),Bn={type:"none",config:{},fallback:"0"};function Tg(e){const t=Array.from(e).sort((s,i)=>s-i),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]}function Dg(e,t){switch(t.type){case"sum":return v.sum(e);case"mean":return v.mean(e);case"median":return Tg(e);case"max":return v.max(e);case"min":return v.min(e);case"quantile":return cr.quantile(e,t.config.p);case"CV":const n=On.std(...e),s=On.mean(...e);return s?n/s:Number.NaN;case"std":return On.std(...e);default:return e}}function ki(e,t){const n=e.map(Number),s=Dg(n,t);return typeof s=="number"?Number.isFinite(s)?s:t.fallback:s??t.fallback}function Mg(e,t,n){try{const s=rs(e,t);return new Function(`return ${n.config.func}`)()({queryData:s},vt)}catch(s){return console.error(s),s.message}}function zg(e,t,n){try{const s=_t(e,t),{method:i}=n.config;return v[i](s)}catch(s){return console.error(s),n.fallback}}function is(e,t,n){try{return n.type==="custom"?Mg(e,t,n):n.type==="pick_record"?zg(e,t,n):ki(_t(e,t),n)}catch(s){return console.error(s),null}}class Ig{constructor({valueRange:t,colorRange:n}){B(this,"mapper");this.mapper=vn.interpolate(t,n)}getColor(t){return this.mapper(t)}}const Me={mantissa:0,output:"number",trimMantissa:!1,average:!1,absolute:!1};function U(e,{absolute:t,...n}){if(e===null)return String(e);try{let s=Hr(e).value();if(s===void 0||Number.isNaN(s))throw new Error(`[formatNumber]Not a number: ${e}`);return t&&(s=Math.abs(s)),Hr(s).format(n)}catch(s){return console.debug(s),String(e)}}function Eg(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function jt({data_field:e,aggregation:t},n){return is(n,e,t)}function Re({formatter:e,aggregation:t},n){if(typeof n!="string"&&typeof n!="number")return Eg(n);if(t.type==="custom")return n;try{return U(n,e)}catch(s){return console.error(s),n}}function Ag(e,t){if(e.type==="static")return e.staticColor;if(e.type==="continuous")try{if(typeof t!="number")throw new Error(`[getColorByColorConf] Invalid type of aggregated value: ${t}`);return new Ig(e).getColor(t)}catch(n){return console.error(n),"black"}return"black"}function Pg(e,t){const{color:n,data_field:s,aggregation:i,size:a,weight:l}=e,c=is(t,s,i),u=Re(e,c);return r.jsx(o.Text,{sx:{fontSize:a,display:"inline"},color:Ag(n,c),weight:l,children:u})}function Og(e,t){const n={};return e.forEach(s=>{const i=s.name;n[i]=Pg(s,t)}),n}function Lg(e){return e.split(" ").map((t,n)=>r.jsxs(m.Fragment,{children:[t," "]},n))}function Bg(e){const n=e.replaceAll("<br />","<br/>").replaceAll(`
56
+ `,"<br/>").split("<br/>");return n.map((i,a)=>{const l=[Lg(i)];return a!==n.length-1&&l.push(r.jsx("br",{},`br-${a}`)),l}).flat().filter(i=>i!==void 0)}function Ti(e){return Bg(e)}function fr(e,t,n){const s=Og(t,n),i=/^\{(.+)\}(.*)$/;return e.split("$").map((a,l)=>{const c=i.exec(a);if(!c)return Ti(a);const u=s[c[1]];if(!u)return Ti(a);const d=c[2]??"";return r.jsxs(m.Fragment,{children:[u,Ti(d)]},`${a}-${l}`)})}function qg(e,t){const{data_field:n,aggregation:s}=e,i=is(t,n,s);return Re(e,i)}function jc(e,t){const n={};return e.forEach(s=>{n[s.name]=qg(s,t)}),n}function mr(e,t,n){const s=jc(t,n),i=/^\{(.+)\}(.*)$/;return e.split("$").map(a=>{const l=i.exec(a);if(!l)return a;const c=s[l[1]];if(!c)return a;const u=l[2]??"";return`${c}${u}`}).join("")}const _n={grid:{axis:"#97999D",scope:"rgba(47,140,192,0.1)",boundary:"#789AB4",reference:"#CFCFD8"},graphics:{compared:{blueDark:"#3E7CAB",blue:"#6398C7",blueLight:"#7CB0DF",blue10:"#6398C71a",redDark:"#AF5F6B",red:"#CD7C88",redLight:"#E794A0",red10:"#CD7C881a"},gradient:{distributed:"linear-gradient(90deg, #1babe6 0%, #2fc8c8 28.63%, #98d44b 48.86%, #ffd057 67.53%, #f5ae53 80.6%, #e76441 91.18%, #b90000 100%)",protrude:"linear-gradient(180deg, #ec73734d 0%, #ec737300 100%)"},level:{lv0:"#6398C7",lv1:"#61B5BF",lv2:"#54D4BB",lv3:"#F5D277",lv4:"#E8BB7F",lv5:"#DB9E84",lv6:"#CB8089"},depth:{dp0:"#FFF7F8",dp1:"#FFE1E1",dp2:"#FDBCBC",dp3:"#F39494",dp4:"#FA4242",dp5:"#E21212"},multiple:{c1:"#66B4DB",c2:"#E46464",c3:"#EEBA00",c4:"#33A678",c5:"#9D88CB",c6:"#939943",c7:"#E49792",c8:"#09A2B8",c9:"#AF5F6B",c10:"#6CA157",c11:"#3E7CAB",c12:"#6398C7",c13:"#E692BA",c14:"#97B566",c15:"#8CACE2",c16:"#CA79AC",c17:"#6DBC80",c18:"#B08F4B",c19:"#39BFA2",c20:"#826BAF"}}};function Vg(){Ae.registerTheme("merico-light",{color:Object.values(_n.graphics.multiple),visualMap:{color:Object.values(_n.graphics.depth).reverse()},axes:[{type:"all",name:"通用坐标轴",axisLineColor:"#97999D",axisTickColor:"#97999D",axisLabelShow:!0,axisLabelColor:"#818388",splitLineShow:!0,splitLineColor:["#E0E6F1"]}]})}function wc(){Vg()}function*Ng(e){const t=_n.graphics[e];if(!t)throw new Error("Invalid palette key provided");const n=Object.values(t);let s=0;for(;;)yield n[s%n.length],s++}function Di(){return{filters:{},context:{}}}function Mi(e){const t=Di();if(!e)return Di();const{filters:n=t.filters,context:s=t.context}=e;return{filters:n,context:s}}class ze extends m.Component{constructor(t){super(t),this.state={error:null}}componentDidCatch(t){this.setState({error:t})}render(){var t;if(this.state.error){const n=()=>{this.setState({error:null})};return r.jsxs(o.Box,{children:[r.jsx(o.Text,{size:"xs",children:(t=this.state.error)==null?void 0:t.message}),r.jsx(o.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}function $g(e,t={handleError:!0}){return n=>r.jsx(ze,{...t,children:r.jsx(e,{...n})})}function Fg(e,t){return new Function(`return ${e}`)()(t,vt)}function Gg(e,t,n){return Fg(e,{context:t,filters:n})}function Wg(e,t){try{return new Function(`return ${e.config.processing.pre}`)()(t,vt)}catch(n){return console.error(n),t}}function Rg(e,t){return new Function(`return ${e.config.processing.post}`)()(t,vt)}function Qg(e,t,n){return e?new Function(`return ${e}`)()(t,vt,n):t}function Cc(){Ul.use([Cm.CanvasRenderer,Pt.BarChart,Pt.BoxplotChart,Pt.CustomChart,Pt.FunnelChart,Pt.HeatmapChart,Pt.LineChart,Pt.PieChart,Pt.RadarChart,Pt.ScatterChart,Pt.SunburstChart,nn.CalendarComponent,nn.DataZoomComponent,nn.GridComponent,nn.LegendComponent,nn.TooltipComponent,nn.MarkLineComponent,nn.MarkAreaComponent,nn.VisualMapComponent])}const qn=e=>v.cloneDeepWith(e,(t,n)=>{if(n!==void 0&&t)return X.toJS(t)}),as={sqlSnippet:new RegExp("(?<=sql_snippets\\.)([^\\?}.]+)","gm"),context:new RegExp("(?<=context\\.)([^\\?}.]+)","gm"),filter:new RegExp("(?<=filters\\.)([^\\?}.]+)","gm")};function Ug(e,t){const n=Yl.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function Yg({query:e,name:t,payload:n,additionals:s},i){if(!e.sql)return[];const{type:a,key:l,sql:c,pre_process:u,post_process:d}=e,p=wi(c,n),h=vg({sql:p,pre_process:u}),f=Yl.encode(h);Ug(h,f);let g=await Ot.query(i)({type:a,key:l,query:f,...s},{params:{name:t}});return g=_g(d,g,Mi(n)),g}async function Kg({type:e,key:t,configString:n,name:s,additionals:i},a){try{return await Ot.httpDataSourceQuery(a)({type:e,key:t,query:n,...i},{params:{name:s}})}catch(l){if(At.isCancel(l))throw l;return console.error(l),l}}async function zi(){try{return(await Ot.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function Sc(){try{return(await Ot.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class kc{constructor(t){B(this,"rootRef");this.rootRef=X.observable({current:t})}async deleteItem(t){X.runInAction(()=>{v.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?X.toJS(this.rootRef.current):v.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(v.isObject(n))X.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else X.runInAction(()=>{v.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,s){return X.reaction(()=>this.getValueFromRoot(t),(i,a)=>{n(i,a)},{requiresObservable:!0,fireImmediately:v.get(s,"fireImmediately",!1)})}}class Xg{constructor(){B(this,"channels",new Map);B(this,"globalChannel",new Kl)}getChannel(t){const n=this.channels.get(t);if(n)return n;const s=new Kl;return this.channels.set(t,s),s}}class Jg{constructor(t){B(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const s={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new Xg,instanceData:new kc(t.viz.conf)};return this.instances.set(t.id,s),s}}function Tc(e,t,n,s){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new kc({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const Zg=e=>{const{panel:t,measure:n,vizManager:s,data:i,variables:a}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={...Tc(c,i,s,a),viewport:{width:n.w,height:n.h}},d=l.viewRender;return r.jsx(d,{context:u,instance:c,...v.omit(e,["panel","vizManager","data"])})},Hg=e=>{const{vizManager:t,panel:n,data:s,variables:i}=e,a=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={...Tc(l,s,t,i)},u=a.configRender;return r.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},Dc=(e,t)=>{const n=Qt.bezier(e),s=Qt.bezier(t);return function(i){return i<50?n(i*2/100).hex():s((i-50)*2/100).hex()}},os=e=>{const t=Qt.bezier(e);return function(n){return t(n/100).hex()}},ex={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:Dc(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},tx={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:Dc(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},nx={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:os(["#fff7f1","darkred"]),name:"red",category:"sequential"},rx={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:os(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},sx={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:os(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},ix={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:os(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class ax{constructor(t){B(this,"symbol");this.symbol=Symbol(t)}}function Yt(e){return new ax(e)}class Ii{constructor(){B(this,"parent");B(this,"factoryRegistry",new Map);B(this,"instanceRegistry",new Map)}createScoped(){const t=new Ii;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const s=n(this);return this.instanceRegistry.set(t.symbol,s),s}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=v.get(t,"dispose");v.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}const Mc="13.21.0",ox=Object.freeze(Object.defineProperty({__proto__:null,version:Mc},Symbol.toStringTag,{value:"Module"}));class lx{constructor(t){B(this,"staticColors",new Map);B(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(s=>{this.register(s)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class cx{constructor(){B(this,"plugins",new Map);B(this,"vizComponents",new Map);B(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 ux{constructor(){B(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,s){var l;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(c=>c.version>t.from&&c.version<=t.to),a=v.orderBy(i,"version","asc");if(((l=v.last(a))==null?void 0:l.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return a.reduce((c,u)=>u.handler(c,s),n)}}class ge extends ux{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(s,i)=>({version:t,...n(s,i)}))}async migrate({configData:t,panelModel:n}){const s=await t.getItem(null),i=v.get(s,"version",0),a=this.run({from:i,to:this.VERSION},s,{panelModel:n});await t.setItem(null,a)}async needMigration({configData:t}){const n=await t.getItem(null);return v.get(n,"version",0)<this.VERSION}}const $=(e,t)=>{const[n,{setFalse:s}]=W.useBoolean(!0),[i,a]=m.useState();m.useEffect(()=>(e.getItem(t).then(c=>{a(c),s()}),e.watchItem(t,c=>{a(c)})));const l=m.useCallback(async c=>{await e.setItem(t,c),a(c)},[e,t]);return{loading:n,value:i,set:l}},Qe={top:16,right:16,bottom:16,left:16},wt=e=>Math.max(0,e-Qe.left-Qe.right),Ct=e=>Math.max(0,e-Qe.top-Qe.bottom),gr=(e,t)=>({width:wt(e),height:Ct(t)}),Ue=({width:e,height:t,children:n})=>r.jsx(o.Box,{pt:Qe.top,pr:Qe.right,pb:Qe.bottom,pl:Qe.left,sx:{width:e,height:t,overflow:"hidden",position:"relative"},children:n}),Ei={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};function dx({context:e}){const{value:t}=$(e.instanceData,"config"),n=e.data,{width:s,height:i}=e.viewport,{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=v.defaults({},t,Ei),h=m.useMemo(()=>rs(n,a),[n,a]),{x:f,y:g,z:y}=m.useMemo(()=>({x:O(a),y:O(l),z:O(c)}),[a,l,c]),{min:j,max:k}=m.useMemo(()=>{const T=v.minBy(h,I=>I[y.columnKey]),z=v.maxBy(h,I=>I[y.columnKey]);return{min:v.get(T,y.columnKey),max:v.get(z,y.columnKey)}},[h,y]),S={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:j,max:k,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:d,zAxis3D:p,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:h.map(T=>[T[f.columnKey],T[g.columnKey],T[y.columnKey]])}]};return t?r.jsx(Ue,{width:s,height:i,children:r.jsx(Pe,{echarts:Ae,option:S,style:gr(s,i),notMerge:!0,theme:"merico-light"})}):null}const zc=m.createContext(null),Ai=zc.Provider;function Pi(){const e=m.useContext(zc);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const Z=()=>Pi(),Ic=()=>Pi(),Ec=m.createContext({searchButtonProps:{}}),Oi=Ec.Provider;function Ac(){return m.useContext(Ec)}const Pc=m.createContext(null),Li=Pc.Provider;function Oc(){const e=m.useContext(Pc);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const Y=()=>Oc(),_e=()=>Oc(),px={inEditMode:!1},ls=m.createContext(px),Lc=m.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),Bi=Lc.Provider;function Bc(){const e=m.useContext(Lc);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const Lt=()=>Bc(),Ge=()=>Bc(),hx={fullScreenPanelID:"",setFullScreenPanelID:v.noop},qi=m.createContext(hx);function qc(){const e=m.useContext(qi);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const fx={en:"en",zh:"zh-cn"};function Vi({children:e}){const{i18n:t}=_.useTranslation(),n=m.useMemo(()=>{const s=t.language;return fx[s]??"en"},[t.language]);return r.jsx(Xl.DatesProvider,{settings:{locale:n,firstDayOfWeek:1},children:e})}const F=D.observer(m.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,queryID:a,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=Ge(),h=m.useMemo(()=>p.dataFieldOptions(s,l,a),[s,l,a]);if(h.length===0){const f=p.explainDataKey(s);return r.jsxs(o.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Box,{children:r.jsx(o.TextInput,{label:e,required:t,defaultValue:f.columnKey,readOnly:!0,disabled:!0})})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsxs(o.Group,{position:"left",spacing:0,children:[r.jsx(o.Text,{size:"xs",color:f.queryName?"black":"red",sx:{fontFamily:"monospace"},children:f.queryName??f.queryID}),r.jsx(o.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),r.jsx(o.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:f.columnKey})]})})]})}return r.jsx(o.Select,{ref:d,label:e,description:n,data:h,value:s,onChange:i,required:t,sx:c,maxDropdownHeight:500,...u})}));function mx({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=v.defaults({},t,Ei),{control:i,handleSubmit:a,reset:l}=b.useForm({defaultValues:s});return m.useEffect(()=>{l(s)},[t]),t?r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(o.Text,{children:"X Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Y Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Text,{mt:"lg",children:"Z Axis"}),r.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[r.jsx(b.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>r.jsx(F,{label:"Data Field",required:!0,...c})}),r.jsx(b.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>r.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),r.jsx(o.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:r.jsxs(o.Button,{color:"blue",type:"submit",children:[r.jsx(V.DeviceFloppy,{size:20}),r.jsx(o.Text,{ml:"md",children:"Save"})]})})]})}):null}const gx=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function xx(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:a,z_axis_data_key:l,...c}=e;return{...c,x_axis_data_key:s(i),y_axis_data_key:s(a),z_axis_data_key:s(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class yx extends ge{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:xx(i,s)}})}}const bx={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new yx,name:"bar-3d",viewRender:dx,configRender:mx,createConfig(){return{version:2,config:v.cloneDeep(Ei)}},translation:gx},vx=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(o.Box,{sx:{position:"relative"},children:[e&&r.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(tt,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})};function Ye({enabled:e,func_content:t}){return(n,s)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,s)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function Oe(){return{enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
57
+ `)}}const St=m.forwardRef(({value:e,onChange:t,triggerButtonText:n},s)=>{const{t:i}=_.useTranslation(),[a,{setTrue:l,setFalse:c}]=W.useBoolean(),[u,d]=m.useState(e);m.useEffect(()=>{d(e)},[e]);const p=k=>{d({...u,enabled:k})},h=()=>{c();const{enabled:k,func_content:S}=u,T={enabled:k,func_content:S};d(T),t(T)},f=()=>{c(),d(e)},g=k=>{d(S=>({...S,func_content:k}))},y=()=>{g(Oe().func_content)},j=n??i("chart.axis.customize_label");return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"filled",color:"grape",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:l,sx:{flexGrow:0},children:j}),r.jsx(o.Modal,{size:800,title:j,opened:a,onClose:c,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:a&&r.jsxs(o.Stack,{children:[r.jsx(o.Checkbox,{mt:10,label:i("common.enabled"),checked:u.enabled,onChange:k=>p(k.currentTarget.checked)}),r.jsx(vx,{value:u.func_content,onChange:g,disabled:!u.enabled}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:y,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:i("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:f,variant:"subtle",children:i("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:h,children:i("common.actions.save")})]})]})]})})]})}),jn={x_axis_scroll:!1,y_axis_scroll:!1,x_axis_slider:!1,y_axis_slider:!1};function Vc(){return v.cloneDeep(jn)}const _x=[{lang:"en",resources:{boxplot:{viz_name:"Boxplot Chart",box:"Box",outlier:"Outlier",scatter:"Scatter",click_series:{label:"Click box, scatter or outlier"}}}},{lang:"zh",resources:{boxplot:{viz_name:"箱线图",box:"箱体",outlier:"异常点",scatter:"散点",click_series:{label:"点击箱体、散点或异常点"}}}}],Nc={id:"builtin:echarts:click-echart:series",displayName:"viz.boxplot.click_series.label",nameRender:wx,configRender:jx,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 jx(e){return r.jsx(r.Fragment,{})}function wx(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.boxplot.click_series.label")})}const cs=m.forwardRef(({sectionTitle:e,value:t,onChange:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=u=>d=>{const p=v.cloneDeep(t);v.set(p,u,d),n(p)},c=m.useMemo(()=>[{label:i("chart.axis.overflow.truncate"),value:"truncate"},{label:i("chart.axis.overflow.break_line"),value:"break"},{label:i("chart.axis.overflow.break_word"),value:"breakAll"}],[a.language]);return r.jsxs(o.Stack,{spacing:0,children:[e&&r.jsx(o.Divider,{mb:-5,mt:5,variant:"dotted",label:e,labelPosition:"right",labelProps:{color:"dimmed"}}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.NumberInput,{label:i("chart.axis.overflow.max_width"),hideControls:!0,value:t.width,onChange:l("width")}),r.jsx(o.Select,{label:i("chart.axis.overflow.label"),data:c,value:t.overflow,onChange:l("overflow")}),r.jsx(o.TextInput,{label:i("chart.axis.overflow.ellipsis"),value:t.ellipsis,disabled:!0})]})]})}),kt=m.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),i=l=>{t({...e,on_axis:l})},a=l=>{t({...e,in_tooltip:l})};return r.jsxs(o.Stack,{ref:n,spacing:0,children:[r.jsx(cs,{sectionTitle:s("chart.axis.overflow.section_title.on_axis"),value:e.on_axis,onChange:i}),r.jsx(cs,{sectionTitle:s("chart.axis.overflow.section_title.in_tooltip"),value:e.in_tooltip,onChange:a})]})});function Ke(){return{on_axis:{width:80,overflow:"truncate",ellipsis:"..."},in_tooltip:{width:200,overflow:"break",ellipsis:"..."}}}function ct({overflow:e,width:t}){const n={truncate:"initial",break:"break-all",breakAll:"break-word"}[e],s=e==="truncate"?"nowrap":"initial",i={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e];return`
58
+ max-width: ${t}px;
59
59
  word-break: ${n};
60
- white-space: ${r};
60
+ white-space: ${s};
61
61
  overflow: hidden;
62
62
  text-overflow: ${i};
63
- `}function Qe(t){return{width:t.width,overflow:t.overflow,ellipsis:t.ellipsis}}const Gs={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,formatter:ke(),overflow:$e()}},y_axis:{name:"Y Axis",data_key:"value",label_formatter:_e},tooltip:{metrics:[]},color:"rgba(99, 152, 199, 0.10)",reference_lines:[],legend:{show:!0,top:"10",right:"0",left:"auto",bottom:"auto",orient:"vertical",type:"scroll"},dataZoom:qa()};function It(t,e){return m.useMemo(()=>{const{queryID:n,columnKey:r}=A(e);return b.keyBy(t[n],r)},[t,e])}const qe=(t,e)=>{const[n,r]=m.useState([]);return m.useEffect(()=>t.watchTriggerSnapshotList(i=>r(i.filter(o=>o.schemaRef===e))),[]),n};class Wt{constructor(e,n){this.root=e,this.path=n}async deleteItem(e){e===null&&await this.root.deleteItem(this.path);const n=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,b.omit(n,e))}async getItem(e){const n=await this.root.getItem(this.path);return e===null?n:b.get(n,e)}async setItem(e,n){if(e===null)await this.root.setItem(this.path,n);else{const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...r,[e]:n})}return await this.getItem(e)}watchItem(e,n,r){return e===null?this.root.watchItem(this.path,(i,o)=>{n(i,o)},r):this.root.watchItem(this.path,(i,o)=>{const l=b.get(i,e),c=b.get(o,e);l!==c&&n(l,c)},r)}}const Ap={"builtin:op:debug":1,"builtin:op:clear_filter_values":2,"builtin:op:set_filter_values":3,"builtin:op:open_view":4,"builtin:op:open-link":5};class Fs{constructor(e,n,r){$(this,"attachmentStorage");this.instance=e,this.attachmentKey=n,this.constructInstance=r,this.attachmentStorage=new Wt(e.instanceData,n)}async getInstance(e){if(await this.attachmentStorage.getItem(e))return this.constructInstance(new Wt(this.attachmentStorage,e))}async create(e,n){return await this.attachmentStorage.setItem(e,n),this.constructInstance(new Wt(this.attachmentStorage,e))}async remove(e){await this.attachmentStorage.deleteItem(e)}async list(){const e=await this.attachmentStorage.getItem(null),n=b.orderBy(b.values(e),r=>Ap[r.schemaRef]??10);return Promise.all(n.map(r=>this.constructInstance(new Wt(this.attachmentStorage,r.id))))}}function Pp(t,e){const{value:n,set:r}=q(t.operation.operationData,"config"),[i,o]=m.useState(b.defaults({},n,e)),l=async()=>{await r(i)};return m.useEffect(()=>{o(b.defaults({},n,e))},[n]),{config:i,setConfig:o,commit:l}}function $p(t){const{t:e}=_.useTranslation(),{config:n,setConfig:r,commit:i}=Pp(t,{urlTemplate:"",openInNewTab:!0});async function o(){await i()}async function l(u){r({...n,openInNewTab:u}),await i()}const c=u=>r({...n,urlTemplate:u.currentTarget.value});return s.jsxs(a.Stack,{children:[s.jsx(a.TextInput,{label:e("interactions.operation.open_link.url"),value:n.urlTemplate,onChange:c,onBlur:o}),s.jsx(a.Switch,{label:e("interactions.operation.open_link.open_in_new_tab"),checked:n.openInNewTab,onChange:u=>l(u.currentTarget.checked)})]})}async function Bp(t,e){const{urlTemplate:n,openInNewTab:r}=await e.operationData.getItem("config");window.dispatchEvent(new CustomEvent("open-link",{detail:{urlTemplate:n,openInNewTab:r,payload:t}}))}class Lp extends ce{constructor(){super(...arguments);$(this,"VERSION",1)}configVersions(){this.version(1,n=>n)}}const qp={displayName:"interactions.operation.open_link.label",id:"builtin:op:open-link",configRender:$p,run:Bp,migrator:new Lp,createDefaultConfig:()=>({version:1,config:{urlTemplate:"",openInNewTab:!0}})};function Op(t){const{value:e,set:n}=q(t.operationData,"config"),r=i=>void n({template:i});return[(e==null?void 0:e.template)||"",r]}function Vp(t){const{t:e}=_.useTranslation(),[n,r]=Op(t.operation);return s.jsx(a.TextInput,{defaultValue:n,onBlur:i=>r(i.currentTarget.value),label:e("interactions.operation.console_log.log_content")})}async function Np(t,e){const n=await e.operationData.getItem("config"),r=b.template(n.template||"");console.log("run with payload",t),console.log(r(t))}const Gp={displayName:"interactions.operation.console_log.label",id:"builtin:op:debug",configRender:Vp,run:Np},Fp=S.observer(t=>{const{t:e}=_.useTranslation(),n=Y(),{value:r,set:i}=q(t.operation.operationData,"config");console.log({value:r,viewID:r==null?void 0:r.viewID});const o=(r==null?void 0:r.viewID)||"",l=c=>void i({viewID:c});return s.jsx(a.Select,{defaultValue:o,value:o,onChange:l,label:e("interactions.operation.open_view.view"),data:n.views.options,withinPortal:!0,zIndex:340,maxDropdownHeight:500})});async function Wp(t,e){const r=(await e.operationData.getItem("config")).viewID;window.dispatchEvent(new CustomEvent("open-view",{detail:{viewID:r}}))}const Qp={displayName:"interactions.operation.open_view.label",id:"builtin:op:open_view",configRender:Fp,run:Wp},Rp={"tbody tr":{opacity:.5,transition:"opacity 200ms ease"},"tr[data-affected=true]":{opacity:1}},Up=({value:t="",onChange:e})=>{const[n,r]=m.useState(t);m.useEffect(()=>{r(t)},[t]);const i=()=>{e(n)};return s.jsx(a.TextInput,{size:"xs",label:"",value:n,onChange:o=>r(o.currentTarget.value),sx:{flexGrow:1},rightSection:s.jsx(a.ActionIcon,{color:"green",size:"xs",onClick:i,disabled:n===t,children:s.jsx(k.IconDeviceFloppy,{})})})},Yp={dictionary:{}},Kp=S.observer(t=>{const{t:e}=_.useTranslation(),n=Y(),{value:r=Yp,set:i}=q(t.operation.operationData,"config"),{dictionary:o={}}=r;console.log({value:{...r},dictionary:{...o},filters:[...n.filters.keyLabelOptions]});const l=(c,u)=>{if(u===""){const d={...o};delete d[c],i({dictionary:d});return}i({dictionary:{...o,[c]:u}})};return s.jsxs(a.Table,{sx:Rp,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:e("interactions.operation.set_filter_values.set_filter")}),s.jsx("th",{children:e("interactions.operation.set_filter_values.with")})]})}),s.jsx("tbody",{children:[...n.filters.keyLabelOptions].map(c=>{const u=c.value in o;return s.jsxs("tr",{"data-affected":u,children:[s.jsx("td",{children:c.label}),s.jsx("td",{children:s.jsx(Up,{value:o[c.value],onChange:d=>l(c.value,d)})})]},c.value)})})]})});async function Jp(t,e){const r=(await e.operationData.getItem("config")).dictionary;window.dispatchEvent(new CustomEvent("set-filter-values",{detail:{dictionary:r,payload:t}}))}const Xp={displayName:"interactions.operation.set_filter_values.label",id:"builtin:op:set_filter_values",configRender:Kp,run:Jp},Zp={filter_keys:[]},Hp=S.observer(t=>{const{t:e}=_.useTranslation(),n=Y(),{value:r=Zp,set:i}=q(t.operation.operationData,"config"),{filter_keys:o=[]}=r,l=u=>{i({filter_keys:[...u]})},c=m.useMemo(()=>n.filters.current.map(u=>({label:u.label,value:u.key})),[n.filters.values]);return s.jsx(a.Stack,{spacing:10,children:s.jsx(a.MultiSelect,{label:e("interactions.operation.clear_filter_values.select_filter"),data:c,value:o,onChange:l})})});async function eh(t,e){const r=(await e.operationData.getItem("config")).filter_keys;window.dispatchEvent(new CustomEvent("clear-filter-values",{detail:{filter_keys:r,payload:t}}))}const Pn=[Gp,qp,Qp,Xp,{displayName:"interactions.operation.clear_filter_values.label",id:"builtin:op:clear_filter_values",configRender:Hp,run:eh}];class th{constructor(e,n=Pn){$(this,"attachments");this.operations=n;const r=async i=>{const{id:o,schemaRef:l}=await i.getItem(null);return{id:o,schemaRef:l,operationData:new Wt(i,"data")}};this.attachments=new Fs(e,"__OPERATIONS",r)}async runOperation(e,n){const r=await this.attachments.getInstance(e);if(!r){console.warn(`Operation '${e}' 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(e){return this.operations.find(n=>n.id===e)}async needMigration(){const n=(await this.attachments.list()).map(async r=>{const i={configData:r.operationData},o=this.tryGetSchema(r.schemaRef),l=o==null?void 0:o.migrator;return l&&await l.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),l=o==null?void 0:o.migrator;l&&await l.needMigration(i)&&await l.migrate(i)});await Promise.all(n)}async createOrGetOperation(e,n){var l;if(!this.getOperationSchemaList().some(c=>c.id===n.id))throw new Error(`Operation schema '${n.id}' is not defined`);const i=await this.attachments.getInstance(e);return!i||i.schemaRef!==n.id?await this.attachments.create(e,{id:e,schemaRef:n.id,data:((l=n.createDefaultConfig)==null?void 0:l.call(n))??{}}):i}getOperationList(){return this.attachments.list()}getOperationSchemaList(){return this.operations}removeOperation(e){return this.attachments.remove(e)}async retrieveTrigger(e){return await this.attachments.getInstance(e)}}const Va="__TRIGGERS";class nh{constructor(e,n){$(this,"attachments");this.instance=e,this.component=n;const r=async i=>{const{id:o,schemaRef:l}=await i.getItem(null);return{id:o,schemaRef:l,triggerData:new Wt(i,"data")}};this.attachments=new Fs(e,Va,r)}watchTriggerSnapshotList(e){return this.instance.instanceData.watchItem(Va,n=>{const r=b.values(n).map(i=>({id:b.get(i,"id"),schemaRef:b.get(i,"schemaRef"),config:J.toJS(b.get(i,"data.config"))}));e(r)},{fireImmediately:!0})}async createOrGetTrigger(e,n,r={recreate:!1}){var c;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(e);return!o||r.recreate||o.schemaRef!==n.id?await this.attachments.create(e,{id:e,schemaRef:n.id,data:((c=n==null?void 0:n.createDefaultConfig)==null?void 0:c.call(n))||{}}):o}async getTriggerList(){return await this.attachments.list()}getTriggerSchemaList(){return this.component.triggers||[]}async removeTrigger(e){await this.attachments.remove(e)}async retrieveTrigger(e){return await this.attachments.getInstance(e)}async getMigrationTasks(){const n=(await this.getTriggerList()).map(async r=>{const i=this.getTriggerSchemaList().find(c=>c.id===r.schemaRef),o=i==null?void 0:i.migrator,l={configData:r.triggerData};return o&&await o.needMigration(l)?()=>o.migrate(l):null});return Promise.all(n).then(r=>r.filter(i=>i))}async needMigration(){return(await this.getMigrationTasks()).length>0}async runMigration(){const e=await this.getMigrationTasks();await Promise.all(e.map(n=>n()))}}class Ws{constructor(e,n,r){$(this,"operationManager");$(this,"triggerManager");$(this,"attachments");this.operationManager=new th(e,r),this.triggerManager=new nh(e,n);const i=async o=>{const{id:l,triggerRef:c,operationRef:u}=await o.getItem(null);return{id:l,triggerRef:c,operationRef:u}};this.attachments=new Fs(e,"__INTERACTIONS",i)}async addInteraction(e,n){const r=e.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(e){const n=await this.attachments.getInstance(e);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(e)}async getOperationRefCount(e){return(await this.getInteractionList()).filter(r=>r.operationRef===e).length}async getTriggerRefCount(e){return(await this.getInteractionList()).filter(r=>r.triggerRef===e).length}async runInteraction(e,n){const i=(await this.getInteractionList()).filter(o=>o.triggerRef===e);for(let o of i)try{await this.operationManager.runOperation(o.operationRef,n)}catch(l){console.warn(`Failed to run operation '${o.operationRef}'`,l)}}}const Oe=({vizManager:t,instance:e})=>W.useCreation(()=>new Ws(e,t.resolveComponent(e.type),Pn),[e,t]),Na=t=>{const{t:e}=_.useTranslation(),{title:n="Variables",variables:r}=t,i=ie.useClipboard(),o=l=>{i.copy(l),_t.showNotification({color:"green",message:e("common.copied")})};return s.jsxs(a.Paper,{withBorder:!0,p:"sm",children:[s.jsx(a.Text,{size:"xs",color:"dimmed",mb:"sm",children:n}),s.jsx(a.Stack,{style:{maxHeight:"500px"},children:r.map(l=>s.jsxs(a.Text,{size:"sm",children:[s.jsxs(a.Code,{color:"teal",children:["// ",l.description]}),s.jsx("br",{}),s.jsxs(a.Code,{onClick:()=>o(l.name),style:{cursor:"pointer"},children:[l.name," : ",l.valueType]})]},l.name))})]})};class sh{constructor(e,n){$(this,"operationId");$(this,"operation");$(this,"operationSchema");$(this,"variables",[]);this.operationManager=e,this.instance=n,J.makeAutoObservable(this)}get schemaList(){return this.operationManager.getOperationSchemaList()}async configOperation(e,n){const r=await this.operationManager.retrieveTrigger(e),i=this.operationManager.getOperationSchemaList().find(o=>o.id===(r==null?void 0:r.schemaRef));J.runInAction(()=>{this.operationId=e,this.operation=r,this.operationSchema=i,this.variables=n})}async changeSchema(e){this.operationId&&(await this.operationManager.createOrGetOperation(this.operationId,e),await this.configOperation(this.operationId,this.variables))}}function rh(t){return!!t.operationId}const ih=S.observer(({model:t,onClick:e})=>{var i;const{t:n}=_.useTranslation(),r=(i=t.operationSchema)==null?void 0:i.displayName;return s.jsx(a.Button,{variant:"outline",onClick:e,children:n(r)})}),ah=S.observer(({model:t})=>{const e={operation:t.operation,instance:t.instance,variables:[]};return m.createElement(t.operationSchema.configRender,e)}),oh=S.observer(({model:t})=>{const{t:e,i18n:n}=_.useTranslation(),r=t.schemaList,i=m.useMemo(()=>r.map(l=>({label:e(l.displayName),value:l.id})),[r,n.language]);async function o(l){await t.changeSchema(r.find(c=>c.id===l))}return s.jsx(a.Select,{label:e("interactions.operation.label"),data:i,onChange:o,value:t.operationSchema.id,withinPortal:!0,zIndex:340})}),lh=S.observer(t=>{const{t:e}=_.useTranslation(),[n,{setTrue:r,setFalse:i}]=W.useBoolean(!1),{operationManager:o,operationId:l,instance:c,variables:u}=t,d=W.useCreation(()=>new sh(o,c),[o,c]);return W.useAsyncEffect(async()=>{await d.configOperation(l,u)},[l,d]),rh(d)?s.jsxs(s.Fragment,{children:[s.jsx(ih,{model:d,onClick:r}),s.jsx(a.Modal,{size:600,opened:n,onClose:i,title:e("interactions.operation.setup"),zIndex:320,children:s.jsxs(a.Stack,{children:[s.jsx(oh,{model:d}),s.jsxs(a.Tabs,{defaultValue:"settings",children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"settings",children:e("interactions.operation.settings")}),s.jsx(a.Tabs.Tab,{value:"variables",children:e("interactions.operation.variables")})]}),s.jsx(a.Tabs.Panel,{value:"settings",pt:10,children:s.jsx(ah,{model:d})}),s.jsx(a.Tabs.Panel,{value:"variables",pt:10,children:s.jsx(Na,{title:e("interactions.operation.variables"),variables:d.variables})})]})]})})]}):null});class ch{constructor(e,n){$(this,"triggerId");$(this,"trigger");$(this,"triggerSchema");$(this,"sampleData");this.triggerManager=e,this.instance=n,J.makeAutoObservable(this)}get schemaList(){return this.triggerManager.getTriggerSchemaList()}async configTrigger(e,n){const r=await this.triggerManager.retrieveTrigger(e),i=this.triggerManager.getTriggerSchemaList().find(o=>o.id===(r==null?void 0:r.schemaRef));J.runInAction(()=>{this.triggerId=e,this.trigger=r,this.triggerSchema=i,this.sampleData=n})}async changeSchema(e){this.triggerId&&(await this.triggerManager.createOrGetTrigger(this.triggerId,e),await this.configTrigger(this.triggerId,this.sampleData))}isReady(){return uh(this)}}function uh(t){return!!t.triggerId&&!!t.triggerSchema}function dh(t,e){return W.useCreation(()=>new ch(t,e),[t,e])}const ph=S.observer(({model:t,onClick:e})=>{const n=t.triggerSchema.nameRender,r={trigger:t.trigger,instance:t.instance,sampleData:t.sampleData};return s.jsx(a.Button,{variant:"outline",onClick:e,children:m.createElement(n,r)})}),hh=S.observer(({model:t})=>{const{t:e,i18n:n}=_.useTranslation(),r=t.schemaList,i=m.useMemo(()=>r.map(l=>({label:e(l.displayName),value:l.id})),[r,n.language]);async function o(l){await t.changeSchema(r.find(c=>c.id===l))}return s.jsx(a.Select,{label:e("interactions.trigger.label"),data:i,value:t.triggerSchema.id,onChange:o})}),mh=S.observer(({model:t})=>{const e={trigger:t.trigger,instance:t.instance,sampleData:t.sampleData};return m.createElement(t.triggerSchema.configRender,e)}),xh=S.observer(t=>{const{t:e}=_.useTranslation(),[n,{setTrue:r,setFalse:i}]=W.useBoolean(!1),o=t.model;return s.jsxs(s.Fragment,{children:[s.jsx(a.Modal,{opened:n,onClose:i,title:e("interactions.trigger.setup"),zIndex:320,children:s.jsxs(a.Stack,{children:[s.jsx(hh,{model:o}),s.jsx(mh,{model:o}),s.jsx(Na,{title:e("interactions.trigger.payload"),variables:o.triggerSchema.payload})]})}),s.jsx(ph,{onClick:r,model:o})]})});function gh(t,e){const[n,r]=m.useState([]);return W.useAsyncEffect(async()=>{const i=await t.getInteractionList();r(i)},[e,t]),n}const fh=S.observer(({item:t,manager:e,instance:n,sampleData:r,variables:i,onRemove:o})=>{const{triggerRef:l,operationRef:c}=t,u=dh(e.triggerManager,n);if(W.useAsyncEffect(async()=>{await u.configTrigger(l,r)},[u,l,r]),u.isReady()){const d=[...u.triggerSchema.payload,...i];return s.jsxs(a.Group,{children:[s.jsx(xh,{model:u}),s.jsx(lh,{instance:n,operationId:c,variables:d,operationManager:e.operationManager}),s.jsx(a.ActionIcon,{"aria-label":"delete-interaction",variant:"filled",color:"red",onClick:()=>o(t),children:s.jsx(L.Trash,{size:16})})]})}return null}),yh=t=>{const{t:e}=_.useTranslation(),[n,r]=m.useState(0),{interactionManager:i,instance:o,sampleData:l,variables:c}=t,u=gh(i,n),d=async()=>{const f=await i.triggerManager.createOrGetTrigger(ie.randomId(),i.triggerManager.getTriggerSchemaList()[0]),v=await i.operationManager.createOrGetOperation(ie.randomId(),i.operationManager.getOperationSchemaList()[0]);await i.addInteraction(f,v),r(w=>w+1)};async function p(f){await i.removeInteraction(f.id),r(v=>v+1)}const{data:h=0,loading:g}=W.useRequest(async()=>{try{return(await i.triggerManager.getTriggerSchemaList()).length}catch{return 0}});return s.jsxs(a.Stack,{children:[s.jsx(a.LoadingOverlay,{visible:g}),h===0&&s.jsx(a.Alert,{icon:s.jsx(L.AlertCircle,{size:16}),title:e("interactions.unavailable"),color:"gray",children:e("interactions.unavailable_reason")}),u.map(f=>s.jsx(fh,{onRemove:p,instance:o,sampleData:l,variables:c,item:f,manager:t.interactionManager},f.id)),s.jsx(a.Button,{style:{width:"fit-content"},onClick:()=>d(),disabled:h===0,children:e("interactions.add")})]})},bh=()=>{const{panel:t,data:e}=mt(),n=t.viz,{vizManager:r}=m.useContext(ut),i=t.json,o=W.useCreation(()=>r.getOrCreateInstance(i),[r,i]),l=W.useCreation(()=>new Ws(o,r.resolveComponent(n.type),Pn),[o,n.type]);return m.useEffect(()=>o.instanceData.watchItem(null,b.throttle(c=>{t.viz.setConf(c)},100,{leading:!1,trailing:!0})),[o]),{instance:o,vizManager:r,interactionManager:l,sampleData:e,variables:[]}},vh=()=>{const t=bh();return s.jsx(yh,{...t})},Ga={axisTick:{show:!0,alignWithLabel:!0,lineStyle:{width:2}},axisLine:{show:!0,lineStyle:{width:3}},splitLine:{show:!1},z:3};function _h(t){return b.defaultsDeep({},t,Ga)}const jh=Object.freeze(Object.defineProperty({__proto__:null,getXAxis:_h,xAxis:Ga},Symbol.toStringTag,{value:"Module"})),Fa={axisTick:{show:!1},axisLine:{show:!1,lineStyle:{width:3}},splitLine:{show:!0,lineStyle:{type:"dashed"}}};function wh(t){return b.defaultsDeep({},t,Fa)}const Ch=Object.freeze(Object.defineProperty({__proto__:null,getYAxis:wh,yAxis:Fa},Symbol.toStringTag,{value:"Module"})),Wa={confine:!0,appendToBody:!0};function Sh(t){return b.defaultsDeep({},t,Wa)}const te={...jh,...Ch,...Object.freeze(Object.defineProperty({__proto__:null,getTooltip:Sh,tooltip:Wa},Symbol.toStringTag,{value:"Module"}))};function kh(t,e){const n=[],r=[];return{boxplotData:Object.entries(t).map(([o,l])=>{const c=l.map(D=>D[e]).sort((D,z)=>D-z),u=nn.quantile(c,.25)??0,d=nn.quantile(c,.5)??0,p=nn.quantile(c,.75)??0,h=p-u,g=u-1.5*h,f=p+1.5*h,v=Math.max(c[0],g),w=Math.min(b.last(c)??0,f);return l.filter(D=>{const z=D[e];return z<v||z>w}).forEach(D=>n.push([o,D[e],D])),l.filter(D=>{const z=D[e];return z>=v&&z<=w}).forEach(D=>r.push([o,D[e],D])),{name:o,min:v,q1:u,median:d,q3:p,max:w}}),outliersData:n,scatterData:r}}function Th(t,e){const{x_axis:n,y_axis:r}=t;if(!n.data_key||!r.data_key)return[];const i=A(n.data_key),o=A(r.data_key);if(i.queryID!==o.queryID)throw new Error("Please use the same query for X & Y axis");const l=b.groupBy(e[i.queryID],i.columnKey),{boxplotData:c,outliersData:u,scatterData:d}=kh(l,o.columnKey);return[{source:c},{source:u},{source:d}]}function Dh(t){const e={top:35,left:20,right:15,bottom:25,containLabel:!0};return t.legend.orient==="vertical"&&(e.right=80),t.dataZoom.x_axis_slider&&(e.top=50),e}function zh({config:t,seriesNames:e}){const n={...t.legend,data:[{name:e.Box,icon:"roundRect",itemStyle:{color:t.color}},{name:e.Scatter,icon:"circle",itemStyle:{color:"#ED6A45",opacity:.5}},{name:e.Outlier,icon:"circle",itemStyle:{color:"#ED6A45"}}]};return t.legend.orient==="horizontal"&&t.dataZoom.x_axis_slider&&(n.top=15),n}function Mh(t,e,n){const r=e.reduce((i,o)=>{const l=Ze(o,n);return i[o.name]=Ie(o,l),i},{});return t.map(i=>({name:"refs",type:"scatter",data:[],markLine:{data:[{name:i.name,yAxis:Number(r[i.variable_key])}],silent:!0,symbol:["none","triangle"],symbolRotate:90,symbolSize:[10,8],label:{formatter:function(){return cn(i.template,e,n)},position:"insideEndTop"}}}))}const Qs=["max","q3","median","q1","min"],Rs=[10,40];function Us(t){return t.barLayout({barMinWidth:Rs[0],barMaxWidth:Rs[1],count:2})}function Ih(t,e,n){const{itemStyle:{color:r,borderColor:i,borderWidth:o}}=n,l=Us(e),c=e.value(0),u=t.source[c],{min:d,q1:p,median:h,q3:g,max:f}=u,v={min:e.coord([c,d]),q1:e.coord([c,p]),median:e.coord([c,h]),q3:e.coord([c,g]),max:e.coord([c,f])},w={left:l[1].offset,center:(l[1].offset+l[1].width)/2,right:l[1].width},T={type:"group",children:[]},D=[{x1:v.max[0]+w.left,x2:v.max[0]+w.right,y1:v.max[1],y2:v.max[1]},{x1:v.median[0]+w.left,x2:v.median[0]+w.right,y1:v.median[1],y2:v.median[1]},{x1:v.min[0]+w.left,x2:v.min[0]+w.right,y1:v.min[1],y2:v.min[1]},{x1:v.min[0]+w.center,x2:v.min[0]+w.center,y1:v.min[1],y2:v.q1[1]},{x1:v.max[0]+w.center,x2:v.max[0]+w.center,y1:v.max[1],y2:v.q3[1]}],z={stroke:i,lineWidth:o};return D.forEach(E=>{T.children.push({type:"line",shape:E,style:z})}),T.children.push({type:"rect",shape:{x:v.q1[0]+w.left,y:v.q1[1],width:w.right-w.left,height:v.q3[1]-v.q1[1]},style:{fill:r,stroke:i,lineWidth:o}}),T}function Eh(t,e){const{color:n}=e,r={name:"Box",type:"custom",itemStyle:{color:n,borderColor:"#2F8CC0",borderWidth:2},emphasis:{disabled:!0},boxWidth:Rs,datasetIndex:0};return r.renderItem=(i,o)=>Ih(t,o,r),r}function Ah(t){const e=Us(t),n=e[0].width,r=t.value(0),i=t.value(1),[o,l]=t.coord([r,i]),u=o+e[0].offset+Math.random()*n;return{type:"circle",transition:["shape"],x:u,y:l,shape:{cx:0,cy:0,r:2},style:{fill:t.visual("color"),opacity:.5}}}function Ph(){const t={name:"Scatter",type:"custom",itemStyle:{color:"#ED6A45"},emphasis:{scale:2},datasetIndex:2};return t.renderItem=(e,n)=>Ah(n),t}function $h(t,e){const n=Us(t),r=n[0].width,i=t.value(0),o=t.value(1),[l,c]=t.coord([i,o]),d=l+n[0].offset+Math.random()*r;return{type:"circle",transition:["shape"],x:d,y:c,shape:{cx:0,cy:0,r:3},style:{fill:t.visual("color")}}}function Bh(){const t={name:"Outlier",type:"custom",itemStyle:{color:"#ED6A45"},emphasis:{scale:2},datasetIndex:1};return t.renderItem=(e,n)=>$h(n),t}function Lh(t,e){const n=e[0],r=Eh(n,t),i=Ph(),o=Bh();return[{name:"Placeholder Box",type:"boxplot",ignore:!0,silent:!0,itemStyle:{color:"none",borderColor:"none",opacity:0},boxWidth:[20,80],datasetIndex:0,encode:{y:Qs,x:"name",itemName:["name"],tooltip:Qs}},{name:"Outlier",type:"scatter",symbolSize:7,itemStyle:{color:"transparent"},ignore:!0,silent:!0,emphasis:{disabled:!0},datasetIndex:1},r,i,o]}const qh=(t,e)=>{const n=Qs.map(o=>`
63
+ `}function ut(e){return{width:e.width,overflow:e.overflow,ellipsis:e.ellipsis}}const Ni={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,formatter:Oe(),overflow:Ke()}},y_axis:{name:"Y Axis",data_key:"value",label_formatter:Me},tooltip:{metrics:[]},color:"rgba(99, 152, 199, 0.10)",reference_lines:[],legend:{show:!0,top:"10",right:"0",left:"auto",bottom:"auto",orient:"vertical",type:"scroll"},dataZoom:Vc()};function wn(e,t){return m.useMemo(()=>{const{queryID:n,columnKey:s}=O(t);return v.keyBy(e[n],s)},[e,t])}const nt=(e,t)=>{const[n,s]=m.useState([]);return m.useEffect(()=>e.watchTriggerSnapshotList(i=>s(i.filter(a=>a.schemaRef===t))),[]),n};class Vn{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,v.omit(n,t))}async getItem(t){const n=await this.root.getItem(this.path);return t===null?n:v.get(n,t)}async setItem(t,n){if(t===null)await this.root.setItem(this.path,n);else{const s=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...s,[t]:n})}return await this.getItem(t)}watchItem(t,n,s){return t===null?this.root.watchItem(this.path,(i,a)=>{n(i,a)},s):this.root.watchItem(this.path,(i,a)=>{const l=v.get(i,t),c=v.get(a,t);l!==c&&n(l,c)},s)}}const Cx={"builtin:op:debug":1,"builtin:op:clear_filter_values":2,"builtin:op:set_filter_values":3,"builtin:op:open_view":4,"builtin:op:open-link":5};class $i{constructor(t,n,s){B(this,"attachmentStorage");this.instance=t,this.attachmentKey=n,this.constructInstance=s,this.attachmentStorage=new Vn(t.instanceData,n)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new Vn(this.attachmentStorage,t))}async create(t,n){return await this.attachmentStorage.setItem(t,n),this.constructInstance(new Vn(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null),n=v.orderBy(v.values(t),s=>Cx[s.schemaRef]??10);return Promise.all(n.map(s=>this.constructInstance(new Vn(this.attachmentStorage,s.id))))}}function Sx(e,t){const{value:n,set:s}=$(e.operation.operationData,"config"),[i,a]=m.useState(v.defaults({},n,t)),l=async()=>{await s(i)};return m.useEffect(()=>{a(v.defaults({},n,t))},[n]),{config:i,setConfig:a,commit:l}}function kx(e){const{t}=_.useTranslation(),{config:n,setConfig:s,commit:i}=Sx(e,{urlTemplate:"",openInNewTab:!0});async function a(){await i()}async function l(u){s({...n,openInNewTab:u}),await i()}const c=u=>s({...n,urlTemplate:u.currentTarget.value});return r.jsxs(o.Stack,{children:[r.jsx(o.TextInput,{label:t("interactions.operation.open_link.url"),value:n.urlTemplate,onChange:c,onBlur:a}),r.jsx(o.Switch,{label:t("interactions.operation.open_link.open_in_new_tab"),checked:n.openInNewTab,onChange:u=>l(u.currentTarget.checked)})]})}async function Tx(e,t){const{urlTemplate:n,openInNewTab:s}=await t.operationData.getItem("config");window.dispatchEvent(new CustomEvent("open-link",{detail:{urlTemplate:n,openInNewTab:s,payload:e}}))}class Dx extends ge{constructor(){super(...arguments);B(this,"VERSION",1)}configVersions(){this.version(1,n=>n)}}const Mx={displayName:"interactions.operation.open_link.label",id:"builtin:op:open-link",configRender:kx,run:Tx,migrator:new Dx,createDefaultConfig:()=>({version:1,config:{urlTemplate:"",openInNewTab:!0}})};function zx(e){const{value:t,set:n}=$(e.operationData,"config"),s=i=>void n({template:i});return[(t==null?void 0:t.template)||"",s]}function Ix(e){const{t}=_.useTranslation(),[n,s]=zx(e.operation);return r.jsx(o.TextInput,{defaultValue:n,onBlur:i=>s(i.currentTarget.value),label:t("interactions.operation.console_log.log_content")})}async function Ex(e,t){const n=await t.operationData.getItem("config"),s=v.template(n.template||"");console.log("run with payload",e),console.log(s(e))}const Ax={displayName:"interactions.operation.console_log.label",id:"builtin:op:debug",configRender:Ix,run:Ex},Px=D.observer(e=>{const{t}=_.useTranslation(),n=Y(),{value:s,set:i}=$(e.operation.operationData,"config");console.log({value:s,viewID:s==null?void 0:s.viewID});const a=(s==null?void 0:s.viewID)||"",l=c=>void i({viewID:c});return r.jsx(o.Select,{defaultValue:a,value:a,onChange:l,label:t("interactions.operation.open_view.view"),data:n.views.options,withinPortal:!0,zIndex:340,maxDropdownHeight:500})});async function Ox(e,t){const s=(await t.operationData.getItem("config")).viewID;window.dispatchEvent(new CustomEvent("open-view",{detail:{viewID:s}}))}const Lx={displayName:"interactions.operation.open_view.label",id:"builtin:op:open_view",configRender:Px,run:Ox},Bx={"tbody tr":{opacity:.5,transition:"opacity 200ms ease"},"tr[data-affected=true]":{opacity:1}},qx=({value:e="",onChange:t})=>{const[n,s]=m.useState(e);m.useEffect(()=>{s(e)},[e]);const i=()=>{t(n)};return r.jsx(o.TextInput,{size:"xs",label:"",value:n,onChange:a=>s(a.currentTarget.value),sx:{flexGrow:1},rightSection:r.jsx(o.ActionIcon,{color:"green",size:"xs",onClick:i,disabled:n===e,children:r.jsx(M.IconDeviceFloppy,{})})})},Vx={dictionary:{}},Nx=D.observer(e=>{const{t}=_.useTranslation(),n=Y(),{value:s=Vx,set:i}=$(e.operation.operationData,"config"),{dictionary:a={}}=s;console.log({value:{...s},dictionary:{...a},filters:[...n.filters.keyLabelOptions]});const l=(c,u)=>{if(u===""){const d={...a};delete d[c],i({dictionary:d});return}i({dictionary:{...a,[c]:u}})};return r.jsxs(o.Table,{sx:Bx,children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:t("interactions.operation.set_filter_values.set_filter")}),r.jsx("th",{children:t("interactions.operation.set_filter_values.with")})]})}),r.jsx("tbody",{children:[...n.filters.keyLabelOptions].map(c=>{const u=c.value in a;return r.jsxs("tr",{"data-affected":u,children:[r.jsx("td",{children:c.label}),r.jsx("td",{children:r.jsx(qx,{value:a[c.value],onChange:d=>l(c.value,d)})})]},c.value)})})]})});async function $x(e,t){const s=(await t.operationData.getItem("config")).dictionary;window.dispatchEvent(new CustomEvent("set-filter-values",{detail:{dictionary:s,payload:e}}))}const Fx={displayName:"interactions.operation.set_filter_values.label",id:"builtin:op:set_filter_values",configRender:Nx,run:$x},Gx={filter_keys:[]},Wx=D.observer(e=>{const{t}=_.useTranslation(),n=Y(),{value:s=Gx,set:i}=$(e.operation.operationData,"config"),{filter_keys:a=[]}=s,l=u=>{i({filter_keys:[...u]})},c=m.useMemo(()=>n.filters.current.map(u=>({label:u.label,value:u.key})),[n.filters.values]);return r.jsx(o.Stack,{spacing:10,children:r.jsx(o.MultiSelect,{label:t("interactions.operation.clear_filter_values.select_filter"),data:c,value:a,onChange:l})})});async function Rx(e,t){const s=(await t.operationData.getItem("config")).filter_keys;window.dispatchEvent(new CustomEvent("clear-filter-values",{detail:{filter_keys:s,payload:e}}))}const us=[Ax,Mx,Lx,Fx,{displayName:"interactions.operation.clear_filter_values.label",id:"builtin:op:clear_filter_values",configRender:Wx,run:Rx}];class Qx{constructor(t,n=us){B(this,"attachments");this.operations=n;const s=async i=>{const{id:a,schemaRef:l}=await i.getItem(null);return{id:a,schemaRef:l,operationData:new Vn(i,"data")}};this.attachments=new $i(t,"__OPERATIONS",s)}async runOperation(t,n){const s=await this.attachments.getInstance(t);if(!s){console.warn(`Operation '${t}' is not defined`);return}const i=this.tryGetSchema(s.schemaRef);if(!i){console.warn(`Operation schema '${s.schemaRef}' is not defined`);return}await i.run(n,s)}tryGetSchema(t){return this.operations.find(n=>n.id===t)}async needMigration(){const n=(await this.attachments.list()).map(async s=>{const i={configData:s.operationData},a=this.tryGetSchema(s.schemaRef),l=a==null?void 0:a.migrator;return l&&await l.needMigration(i)});return(await Promise.all(n)).some(s=>s)}async runMigration(){const n=(await this.attachments.list()).map(async s=>{const i={configData:s.operationData},a=this.tryGetSchema(s.schemaRef),l=a==null?void 0:a.migrator;l&&await l.needMigration(i)&&await l.migrate(i)});await Promise.all(n)}async createOrGetOperation(t,n){var l;if(!this.getOperationSchemaList().some(c=>c.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:((l=n.createDefaultConfig)==null?void 0:l.call(n))??{}}):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)}}const $c="__TRIGGERS";class Ux{constructor(t,n){B(this,"attachments");this.instance=t,this.component=n;const s=async i=>{const{id:a,schemaRef:l}=await i.getItem(null);return{id:a,schemaRef:l,triggerData:new Vn(i,"data")}};this.attachments=new $i(t,$c,s)}watchTriggerSnapshotList(t){return this.instance.instanceData.watchItem($c,n=>{const s=v.values(n).map(i=>({id:v.get(i,"id"),schemaRef:v.get(i,"schemaRef"),config:X.toJS(v.get(i,"data.config"))}));t(s)},{fireImmediately:!0})}async createOrGetTrigger(t,n,s={recreate:!1}){var c;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 a=await this.attachments.getInstance(t);return!a||s.recreate||a.schemaRef!==n.id?await this.attachments.create(t,{id:t,schemaRef:n.id,data:((c=n==null?void 0:n.createDefaultConfig)==null?void 0:c.call(n))||{}}):a}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 s=>{const i=this.getTriggerSchemaList().find(c=>c.id===s.schemaRef),a=i==null?void 0:i.migrator,l={configData:s.triggerData};return a&&await a.needMigration(l)?()=>a.migrate(l):null});return Promise.all(n).then(s=>s.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()))}}class Fi{constructor(t,n,s){B(this,"operationManager");B(this,"triggerManager");B(this,"attachments");this.operationManager=new Qx(t,s),this.triggerManager=new Ux(t,n);const i=async a=>{const{id:l,triggerRef:c,operationRef:u}=await a.getItem(null);return{id:l,triggerRef:c,operationRef:u}};this.attachments=new $i(t,"__INTERACTIONS",i)}async addInteraction(t,n){const s=t.id,i=n.id,a=`[${s}]:[${i}]`;await this.attachments.create(a,{id:a,triggerRef:s,operationRef:i})}getInteractionList(){return this.attachments.list()}async removeInteraction(t){const n=await this.attachments.getInstance(t);if(!n)return;const{triggerRef:s,operationRef:i}=n;await this.getTriggerRefCount(s)<=1&&await this.triggerManager.removeTrigger(s),await this.getOperationRefCount(i)<=1&&await this.operationManager.removeOperation(i),await this.attachments.remove(t)}async getOperationRefCount(t){return(await this.getInteractionList()).filter(s=>s.operationRef===t).length}async getTriggerRefCount(t){return(await this.getInteractionList()).filter(s=>s.triggerRef===t).length}async runInteraction(t,n){const i=(await this.getInteractionList()).filter(a=>a.triggerRef===t);for(let a of i)try{await this.operationManager.runOperation(a.operationRef,n)}catch(l){console.warn(`Failed to run operation '${a.operationRef}'`,l)}}}const rt=({vizManager:e,instance:t})=>W.useCreation(()=>new Fi(t,e.resolveComponent(t.type),us),[t,e]),Fc=e=>{const{t}=_.useTranslation(),{title:n="Variables",variables:s}=e,i=he.useClipboard(),a=l=>{i.copy(l),rn.showNotification({color:"green",message:t("common.copied")})};return r.jsxs(o.Paper,{withBorder:!0,p:"sm",children:[r.jsx(o.Text,{size:"xs",color:"dimmed",mb:"sm",children:n}),r.jsx(o.Stack,{style:{maxHeight:"500px"},children:s.map(l=>r.jsxs(o.Text,{size:"sm",children:[r.jsxs(o.Code,{color:"teal",children:["// ",l.description]}),r.jsx("br",{}),r.jsxs(o.Code,{onClick:()=>a(l.name),style:{cursor:"pointer"},children:[l.name," : ",l.valueType]})]},l.name))})]})};class Yx{constructor(t,n){B(this,"operationId");B(this,"operation");B(this,"operationSchema");B(this,"variables",[]);this.operationManager=t,this.instance=n,X.makeAutoObservable(this)}get schemaList(){return this.operationManager.getOperationSchemaList()}async configOperation(t,n){const s=await this.operationManager.retrieveTrigger(t),i=this.operationManager.getOperationSchemaList().find(a=>a.id===(s==null?void 0:s.schemaRef));X.runInAction(()=>{this.operationId=t,this.operation=s,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 Kx(e){return!!e.operationId}const Xx=D.observer(({model:e,onClick:t})=>{var i;const{t:n}=_.useTranslation(),s=(i=e.operationSchema)==null?void 0:i.displayName;return r.jsx(o.Button,{variant:"outline",onClick:t,children:n(s)})}),Jx=D.observer(({model:e})=>{const t={operation:e.operation,instance:e.instance,variables:[]};return m.createElement(e.operationSchema.configRender,t)}),Zx=D.observer(({model:e})=>{const{t,i18n:n}=_.useTranslation(),s=e.schemaList,i=m.useMemo(()=>s.map(l=>({label:t(l.displayName),value:l.id})),[s,n.language]);async function a(l){await e.changeSchema(s.find(c=>c.id===l))}return r.jsx(o.Select,{label:t("interactions.operation.label"),data:i,onChange:a,value:e.operationSchema.id,withinPortal:!0,zIndex:340})}),Hx=D.observer(e=>{const{t}=_.useTranslation(),[n,{setTrue:s,setFalse:i}]=W.useBoolean(!1),{operationManager:a,operationId:l,instance:c,variables:u}=e,d=W.useCreation(()=>new Yx(a,c),[a,c]);return W.useAsyncEffect(async()=>{await d.configOperation(l,u)},[l,d]),Kx(d)?r.jsxs(r.Fragment,{children:[r.jsx(Xx,{model:d,onClick:s}),r.jsx(o.Modal,{size:600,opened:n,onClose:i,title:t("interactions.operation.setup"),zIndex:320,children:r.jsxs(o.Stack,{children:[r.jsx(Zx,{model:d}),r.jsxs(o.Tabs,{defaultValue:"settings",children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"settings",children:t("interactions.operation.settings")}),r.jsx(o.Tabs.Tab,{value:"variables",children:t("interactions.operation.variables")})]}),r.jsx(o.Tabs.Panel,{value:"settings",pt:10,children:r.jsx(Jx,{model:d})}),r.jsx(o.Tabs.Panel,{value:"variables",pt:10,children:r.jsx(Fc,{title:t("interactions.operation.variables"),variables:d.variables})})]})]})})]}):null});class ey{constructor(t,n){B(this,"triggerId");B(this,"trigger");B(this,"triggerSchema");B(this,"sampleData");this.triggerManager=t,this.instance=n,X.makeAutoObservable(this)}get schemaList(){return this.triggerManager.getTriggerSchemaList()}async configTrigger(t,n){const s=await this.triggerManager.retrieveTrigger(t),i=this.triggerManager.getTriggerSchemaList().find(a=>a.id===(s==null?void 0:s.schemaRef));X.runInAction(()=>{this.triggerId=t,this.trigger=s,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 ty(this)}}function ty(e){return!!e.triggerId&&!!e.triggerSchema}function ny(e,t){return W.useCreation(()=>new ey(e,t),[e,t])}const ry=D.observer(({model:e,onClick:t})=>{const n=e.triggerSchema.nameRender,s={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return r.jsx(o.Button,{variant:"outline",onClick:t,children:m.createElement(n,s)})}),sy=D.observer(({model:e})=>{const{t,i18n:n}=_.useTranslation(),s=e.schemaList,i=m.useMemo(()=>s.map(l=>({label:t(l.displayName),value:l.id})),[s,n.language]);async function a(l){await e.changeSchema(s.find(c=>c.id===l))}return r.jsx(o.Select,{label:t("interactions.trigger.label"),data:i,value:e.triggerSchema.id,onChange:a})}),iy=D.observer(({model:e})=>{const t={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return m.createElement(e.triggerSchema.configRender,t)}),ay=D.observer(e=>{const{t}=_.useTranslation(),[n,{setTrue:s,setFalse:i}]=W.useBoolean(!1),a=e.model;return r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:n,onClose:i,title:t("interactions.trigger.setup"),zIndex:320,children:r.jsxs(o.Stack,{children:[r.jsx(sy,{model:a}),r.jsx(iy,{model:a}),r.jsx(Fc,{title:t("interactions.trigger.payload"),variables:a.triggerSchema.payload})]})}),r.jsx(ry,{onClick:s,model:a})]})});function oy(e,t){const[n,s]=m.useState([]);return W.useAsyncEffect(async()=>{const i=await e.getInteractionList();s(i)},[t,e]),n}const ly=D.observer(({item:e,manager:t,instance:n,sampleData:s,variables:i,onRemove:a})=>{const{triggerRef:l,operationRef:c}=e,u=ny(t.triggerManager,n);if(W.useAsyncEffect(async()=>{await u.configTrigger(l,s)},[u,l,s]),u.isReady()){const d=[...u.triggerSchema.payload,...i];return r.jsxs(o.Group,{children:[r.jsx(ay,{model:u}),r.jsx(Hx,{instance:n,operationId:c,variables:d,operationManager:t.operationManager}),r.jsx(o.ActionIcon,{"aria-label":"delete-interaction",variant:"filled",color:"red",onClick:()=>a(e),children:r.jsx(V.Trash,{size:16})})]})}return null}),cy=e=>{const{t}=_.useTranslation(),[n,s]=m.useState(0),{interactionManager:i,instance:a,sampleData:l,variables:c}=e,u=oy(i,n),d=async()=>{const g=await i.triggerManager.createOrGetTrigger(he.randomId(),i.triggerManager.getTriggerSchemaList()[0]),y=await i.operationManager.createOrGetOperation(he.randomId(),i.operationManager.getOperationSchemaList()[0]);await i.addInteraction(g,y),s(j=>j+1)};async function p(g){await i.removeInteraction(g.id),s(y=>y+1)}const{data:h=0,loading:f}=W.useRequest(async()=>{try{return(await i.triggerManager.getTriggerSchemaList()).length}catch{return 0}});return r.jsxs(o.Stack,{children:[r.jsx(o.LoadingOverlay,{visible:f}),h===0&&r.jsx(o.Alert,{icon:r.jsx(V.AlertCircle,{size:16}),title:t("interactions.unavailable"),color:"gray",children:t("interactions.unavailable_reason")}),u.map(g=>r.jsx(ly,{onRemove:p,instance:a,sampleData:l,variables:c,item:g,manager:e.interactionManager},g.id)),r.jsx(o.Button,{style:{width:"fit-content"},onClick:()=>d(),disabled:h===0,children:t("interactions.add")})]})},uy=()=>{const{panel:e,data:t}=Lt(),n=e.viz,{vizManager:s}=m.useContext(Gt),i=e.json,a=W.useCreation(()=>s.getOrCreateInstance(i),[s,i]),l=W.useCreation(()=>new Fi(a,s.resolveComponent(n.type),us),[a,n.type]);return m.useEffect(()=>a.instanceData.watchItem(null,v.throttle(c=>{e.viz.setConf(c)},100,{leading:!1,trailing:!0})),[a]),{instance:a,vizManager:s,interactionManager:l,sampleData:t,variables:[]}},dy=()=>{const e=uy();return r.jsx(cy,{...e})},Gc={axisTick:{show:!0,alignWithLabel:!0,lineStyle:{width:2}},axisLine:{show:!0,lineStyle:{width:3}},splitLine:{show:!1},z:3};function py(e){return v.defaultsDeep({},e,Gc)}const hy=Object.freeze(Object.defineProperty({__proto__:null,getXAxis:py,xAxis:Gc},Symbol.toStringTag,{value:"Module"})),Wc={axisTick:{show:!1},axisLine:{show:!1,lineStyle:{width:3}},splitLine:{show:!0,lineStyle:{type:"dashed"}}};function fy(e){return v.defaultsDeep({},e,Wc)}const my=Object.freeze(Object.defineProperty({__proto__:null,getYAxis:fy,yAxis:Wc},Symbol.toStringTag,{value:"Module"})),Rc={confine:!0,appendToBody:!0};function gy(e){return v.defaultsDeep({},e,Rc)}const te={...hy,...my,...Object.freeze(Object.defineProperty({__proto__:null,getTooltip:gy,tooltip:Rc},Symbol.toStringTag,{value:"Module"}))};function xy(e,t){const n=[],s=[];return{boxplotData:Object.entries(e).map(([a,l])=>{const c=l.map(S=>S[t]).sort((S,T)=>S-T),u=cr.quantile(c,.25)??0,d=cr.quantile(c,.5)??0,p=cr.quantile(c,.75)??0,h=p-u,f=u-1.5*h,g=p+1.5*h,y=Math.max(c[0],f),j=Math.min(v.last(c)??0,g);return l.filter(S=>{const T=S[t];return T<y||T>j}).forEach(S=>n.push([a,S[t],S])),l.filter(S=>{const T=S[t];return T>=y&&T<=j}).forEach(S=>s.push([a,S[t],S])),{name:a,min:y,q1:u,median:d,q3:p,max:j}}),outliersData:n,scatterData:s}}function yy(e,t){const{x_axis:n,y_axis:s}=e;if(!n.data_key||!s.data_key)return[];const i=O(n.data_key),a=O(s.data_key);if(i.queryID!==a.queryID)throw new Error("Please use the same query for X & Y axis");const l=v.groupBy(t[i.queryID],i.columnKey),{boxplotData:c,outliersData:u,scatterData:d}=xy(l,a.columnKey);return[{source:c},{source:u},{source:d}]}function by(e){const t={top:35,left:20,right:15,bottom:25,containLabel:!0};return e.legend.orient==="vertical"&&(t.right=80),e.dataZoom.x_axis_slider&&(t.top=50),t}function vy({config:e,seriesNames:t}){const n={...e.legend,data:[{name:t.Box,icon:"roundRect",itemStyle:{color:e.color}},{name:t.Scatter,icon:"circle",itemStyle:{color:"#ED6A45",opacity:.5}},{name:t.Outlier,icon:"circle",itemStyle:{color:"#ED6A45"}}]};return e.legend.orient==="horizontal"&&e.dataZoom.x_axis_slider&&(n.top=15),n}function _y(e,t,n){const s=t.reduce((i,a)=>{const l=jt(a,n);return i[a.name]=Re(a,l),i},{});return e.map(i=>({name:"refs",type:"scatter",data:[],markLine:{data:[{name:i.name,yAxis:Number(s[i.variable_key])}],silent:!0,symbol:["none","triangle"],symbolRotate:90,symbolSize:[10,8],label:{formatter:function(){return mr(i.template,t,n)},position:"insideEndTop"}}}))}const Gi=["max","q3","median","q1","min"],Wi=[10,40];function Ri(e){return e.barLayout({barMinWidth:Wi[0],barMaxWidth:Wi[1],count:2})}function jy(e,t,n){const{itemStyle:{color:s,borderColor:i,borderWidth:a}}=n,l=Ri(t),c=t.value(0),u=e.source[c],{min:d,q1:p,median:h,q3:f,max:g}=u,y={min:t.coord([c,d]),q1:t.coord([c,p]),median:t.coord([c,h]),q3:t.coord([c,f]),max:t.coord([c,g])},j={left:l[1].offset,center:(l[1].offset+l[1].width)/2,right:l[1].width},k={type:"group",children:[]},S=[{x1:y.max[0]+j.left,x2:y.max[0]+j.right,y1:y.max[1],y2:y.max[1]},{x1:y.median[0]+j.left,x2:y.median[0]+j.right,y1:y.median[1],y2:y.median[1]},{x1:y.min[0]+j.left,x2:y.min[0]+j.right,y1:y.min[1],y2:y.min[1]},{x1:y.min[0]+j.center,x2:y.min[0]+j.center,y1:y.min[1],y2:y.q1[1]},{x1:y.max[0]+j.center,x2:y.max[0]+j.center,y1:y.max[1],y2:y.q3[1]}],T={stroke:i,lineWidth:a};return S.forEach(z=>{k.children.push({type:"line",shape:z,style:T})}),k.children.push({type:"rect",shape:{x:y.q1[0]+j.left,y:y.q1[1],width:j.right-j.left,height:y.q3[1]-y.q1[1]},style:{fill:s,stroke:i,lineWidth:a}}),k}function wy(e,t){const{color:n}=t,s={name:"Box",type:"custom",itemStyle:{color:n,borderColor:"#2F8CC0",borderWidth:2},emphasis:{disabled:!0},boxWidth:Wi,datasetIndex:0};return s.renderItem=(i,a)=>jy(e,a,s),s}function Cy(e){const t=Ri(e),n=t[0].width,s=e.value(0),i=e.value(1),[a,l]=e.coord([s,i]),u=a+t[0].offset+Math.random()*n;return{type:"circle",transition:["shape"],x:u,y:l,shape:{cx:0,cy:0,r:2},style:{fill:e.visual("color"),opacity:.5}}}function Sy(){const e={name:"Scatter",type:"custom",itemStyle:{color:"#ED6A45"},emphasis:{scale:2},datasetIndex:2};return e.renderItem=(t,n)=>Cy(n),e}function ky(e,t){const n=Ri(e),s=n[0].width,i=e.value(0),a=e.value(1),[l,c]=e.coord([i,a]),d=l+n[0].offset+Math.random()*s;return{type:"circle",transition:["shape"],x:d,y:c,shape:{cx:0,cy:0,r:3},style:{fill:e.visual("color")}}}function Ty(){const e={name:"Outlier",type:"custom",itemStyle:{color:"#ED6A45"},emphasis:{scale:2},datasetIndex:1};return e.renderItem=(t,n)=>ky(n),e}function Dy(e,t){const n=t[0],s=wy(n,e),i=Sy(),a=Ty();return[{name:"Placeholder Box",type:"boxplot",ignore:!0,silent:!0,itemStyle:{color:"none",borderColor:"none",opacity:0},boxWidth:[20,80],datasetIndex:0,encode:{y:Gi,x:"name",itemName:["name"],tooltip:Gi}},{name:"Outlier",type:"scatter",symbolSize:7,itemStyle:{color:"transparent"},ignore:!0,silent:!0,emphasis:{disabled:!0},datasetIndex:1},s,i,a]}const My=(e,t)=>{const n=Gi.map(a=>`
64
64
  <tr>
65
- <th style="text-align: right; padding: 0 1em;">${b.capitalize(o)}</th>
65
+ <th style="text-align: right; padding: 0 1em;">${v.capitalize(a)}</th>
66
66
  <td style="text-align: left; padding: 0 1em;">
67
- ${U(e[o],t.y_axis.label_formatter)}
67
+ ${U(t[a],e.y_axis.label_formatter)}
68
68
  </td>
69
69
  </tr>`);return`
70
70
  <div style="text-align: left; margin-bottom: .5em; padding: 0 1em .5em; font-weight: bold; border-bottom: 1px dashed #ddd;">
71
- <div style="${We(t.x_axis.axisLabel.overflow.in_tooltip)}">${e.name}</div>
71
+ <div style="${ct(e.x_axis.axisLabel.overflow.in_tooltip)}">${t.name}</div>
72
72
  </div>
73
73
  <table style="width: auto">
74
74
  <tbody>
75
75
  ${n.join("")}
76
76
  </tbody>
77
77
  </table>
78
- `},Oh=t=>U(t,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Qa(t,e){return t.tooltip.metrics.map(n=>{const r=A(n.data_key);return`
78
+ `},zy=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Qc(e,t){return e.tooltip.metrics.map(n=>{const s=O(n.data_key);return`
79
79
  <tr>
80
80
  <th style="text-align: right; padding: 0 1em;">${n.name}</th>
81
- <td style="text-align: left; padding: 0 1em;">${Oh(e[r.columnKey])}</td>
82
- </tr>`})}function Vh(t,e){const n=We(t.x_axis.axisLabel.overflow.in_tooltip),r=[`<tr>
83
- <th style="text-align: right; padding: 0 1em;">${t.y_axis.name}</th>
84
- <td style="text-align: left; padding: 0 1em;">${e[1]}</td>
81
+ <td style="text-align: left; padding: 0 1em;">${zy(t[s.columnKey])}</td>
82
+ </tr>`})}function Iy(e,t){const n=ct(e.x_axis.axisLabel.overflow.in_tooltip),s=[`<tr>
83
+ <th style="text-align: right; padding: 0 1em;">${e.y_axis.name}</th>
84
+ <td style="text-align: left; padding: 0 1em;">${t[1]}</td>
85
85
  </tr>
86
- `],i=Qa(t,e[2]);return r.push(...i),`
86
+ `],i=Qc(e,t[2]);return s.push(...i),`
87
87
  <div style="text-align: left; margin-bottom: .5em; padding: 0 1em .5em; font-weight: bold; border-bottom: 1px dashed #ddd;">
88
- <div style="${n}">${e[0]}</div>
88
+ <div style="${n}">${t[0]}</div>
89
89
  </div>
90
90
  <table>
91
91
  <tbody>
92
- ${r.join("")}
92
+ ${s.join("")}
93
93
  </tbody>
94
94
  </table>
95
- `}function Nh(t,e){const n=We(t.x_axis.axisLabel.overflow.in_tooltip),r=[`<tr>
96
- <th style="text-align: right; padding: 0 1em;">${t.y_axis.name}</th>
97
- <td style="text-align: left; padding: 0 1em;">${e[1]}</td>
95
+ `}function Ey(e,t){const n=ct(e.x_axis.axisLabel.overflow.in_tooltip),s=[`<tr>
96
+ <th style="text-align: right; padding: 0 1em;">${e.y_axis.name}</th>
97
+ <td style="text-align: left; padding: 0 1em;">${t[1]}</td>
98
98
  </tr>
99
- `],i=Qa(t,e[2]);return r.push(...i),`
99
+ `],i=Qc(e,t[2]);return s.push(...i),`
100
100
  <div style="text-align: left; margin-bottom: .5em; padding: 0 1em .5em; font-weight: bold; border-bottom: 1px dashed #ddd;">
101
- <div style="${n}">${e[0]}</div>
101
+ <div style="${n}">${t[0]}</div>
102
102
  </div>
103
103
  <table>
104
104
  <tbody>
105
- ${r.join("")}
105
+ ${s.join("")}
106
106
  </tbody>
107
107
  </table>
108
- `}const Gh=(t,e)=>n=>{const{seriesName:r,value:i}=n;switch(r){case e.Box:return qh(t,i);case e.Outlier:return Vh(t,i);case e.Scatter:return Nh(t,i)}};function Fh({config:t,seriesNames:e}){return te.getTooltip({trigger:"item",formatter:Gh(t,e)})}function $n(t,e){e||(e="none");const n=[];return t.x_axis_scroll&&n.push({type:"inside",xAxisIndex:[0],filterMode:e,minSpan:1}),t.y_axis_scroll&&n.push({type:"inside",yAxisIndex:[0],filterMode:e,minSpan:1}),t.x_axis_slider&&n.push({type:"slider",xAxisIndex:[0],filterMode:e,bottom:"auto",top:0,height:15,moveHandleSize:0,showDataShadow:!1,minSpan:1}),n}function Wh({min:t,max:e}){if(t<=110)return Math.min(0,t);if(t<=200)return 100;const n=Vt.floor(Vt.log10(t)),r=Math.pow(10,n),i=Math.pow(10,n-1);return t/r<=2?b.round(t,-1*(n-1))-i:b.round(t,-1*n)-r}function Qh(t){return{Box:t("viz.boxplot.box"),Scatter:t("viz.boxplot.scatter"),Outlier:t("viz.boxplot.outlier")}}function Rh({config:t,data:e,variables:n,t:r}){const{x_axis:i,y_axis:o,reference_lines:l}=t,c=Th(t,e),u=Qe(i.axisLabel.overflow.on_axis),d=Qh(r),p=Lh(t,c).map(h=>({...h,name:b.get(d,h.name,h.name)}));return{dataZoom:$n(t.dataZoom,"filter"),grid:Dh(t),dataset:c,legend:zh({config:t,seriesNames:d}),tooltip:Fh({config:t,seriesNames:d}),xAxis:[te.getXAxis({type:"category",name:i.name,nameGap:25,nameLocation:"center",nameTextStyle:{align:"center"},axisLabel:{...i.axisLabel,...u,formatter:Pe(i.axisLabel.formatter)}})],yAxis:[te.getYAxis({name:o.name,minInterval:1,axisLabel:{formatter:function(h){return U(h,o.label_formatter)}},min:Wh})],series:[...p,...Mh(l,n,e)]}}function Uh({context:t,instance:e}){const{t:n}=_.useTranslation(),{value:r}=q(t.instanceData,"config"),{variables:i}=t,o=t.data,{width:l,height:c}=t.viewport,u=b.defaults({},r,Gs),d=Oe({vizManager:t.vizManager,instance:e}),p=qe(d.triggerManager,Oa.id),h=It(o,u.x_axis.data_key),g=m.useCallback(w=>{const T=b.get(h,w.name,{error:"rowData is not found"});p.forEach(D=>{d.runInteraction(D.id,{...w,rowData:T})})},[h,p,d]),f=m.useMemo(()=>({click:g}),[g]),v=m.useMemo(()=>Rh({config:u,data:o,variables:i,t:n}),[u,o,i,n]);return!r||!l||!c?null:s.jsx(Ae,{width:l,height:c,children:s.jsx(Se,{echarts:Ce,option:v,style:un(l,c),onEvents:f,notMerge:!0,theme:"merico-light"})})}function Yh({value:t,onChange:e},n){const{t:r}=_.useTranslation(),{colorManager:i}=m.useContext(ut),o=m.useMemo(()=>i.getStaticColors().map(u=>({label:u.name,group:u.category,value:u.value})),[i]),l=m.useMemo(()=>o.some(c=>c.value===t),[t,o]);return s.jsxs(a.Group,{position:"apart",spacing:4,ref:n,children:[s.jsx(a.TextInput,{placeholder:r("chart.color.set_any_color"),value:l?"":t,onChange:c=>e(c.currentTarget.value),rightSection:s.jsx(a.ColorSwatch,{color:l?"transparent":t,radius:4}),variant:l?"filled":"default",sx:{maxWidth:"46%",flexGrow:1}}),s.jsx(a.Text,{sx:{flexGrow:0},size:"xs",children:r("chart.color.or")}),s.jsx(a.Select,{data:o,value:t,onChange:e,variant:l?"default":"filled",placeholder:r("chart.color.pick_a_theme_color"),icon:s.jsx(a.ColorSwatch,{color:l?t:"transparent",radius:4}),sx:{maxWidth:"46%",flexGrow:1}})]})}const Te=m.forwardRef(Yh);function ge({canSubmit:t}){const{t:e}=_.useTranslation();return s.jsxs(a.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[s.jsx(a.Text,{children:e("viz.viz_config_banner")}),s.jsx(a.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!t,children:s.jsx(k.IconDeviceFloppy,{size:20})})]})}const Bn=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},i)=>{const{t:o,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:o("common.align.horizontal.left"),value:"left"},{label:o("common.align.horizontal.center"),value:"center"},{label:o("common.align.horizontal.right"),value:"right"}],[l.language]);return s.jsx(a.Select,{ref:i,label:t??o("common.align.horizontal.label"),data:c,value:e,onChange:n,sx:r})}),Ra=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},i)=>{const{t:o,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:o("common.align.vertical.top"),value:"top"},{label:o("common.align.vertical.center"),value:"center"},{label:o("common.align.vertical.bottom"),value:"bottom"}],[l.language]);return s.jsx(a.Select,{ref:i,label:t??o("common.align.vertical.label"),data:c,value:e,onChange:n,sx:r})}),Ua=a.createStyles(()=>({palette:{display:"flex",flexFlow:"row nowrap"},paletteItem:{".palette-value":{height:24,overflow:"visible",width:36},".palette-item":{width:"36px",height:36*.618,cursor:"pointer",transition:"transform 100ms ease-in-out","&:hover":{boxShadow:"0 0 0 2px var(--shadow-color)",borderRadius:2,transform:"scale(1.2)"}}}})),Kh=[{from:0,to:0},{from:100,to:100}];class Jh{constructor(){$(this,"steps",new Map);$(this,"interpolation");$(this,"onChange");J.makeAutoObservable(this,{steps:J.observable},{deep:!1}),J.reaction(()=>J.toJS(this.steps),()=>{this.notifyStepChange()})}setSteps(e){for(const n of e)this.steps.set(n.to,n.from)}notifyStepChange(){var e;(e=this.onChange)==null||e.call(this,Array.from(this.steps.entries()).map(([n,r])=>({to:n,from:r})).sort((n,r)=>n.to-r.to||n.from-r.from))}fromProps(e){e.steps.length<2?this.setSteps(Kh):this.setSteps(e.steps),this.interpolation=e.interpolation,this.onChange=e.onChange}changeStep(e,n){e==null?this.steps.delete(n):this.steps.set(n,e)}getStepFromValue(e){return this.steps.get(e)}}function Ya(t){if(typeof t=="number")return String(t)}function Xh(t){const{t:e}=_.useTranslation(),{onChange:n,color:r,index:i,value:o}=t,{classes:l}=Ua(),[c,u]=m.useState(Ya(o)),[d,{setTrue:p,setFalse:h}]=W.useBoolean(!1),g=i%2===1,f=g&&o!=null,v=!g&&o!=null,w=`map ${o} to color ${i}`,T=()=>{u(Ya(o)),h()},D=()=>{h(),n==null||n(Number(c))},z=()=>{h(),n==null||n(null)},E=U(o??null,{output:"number",mantissa:10,trimMantissa:!0,average:!0,absolute:!1}),V=!c||Number.isNaN(Number(c));return s.jsxs("div",{"data-testid":`palette-item-${i}`,className:l.paletteItem,children:[s.jsx(a.Text,{title:w,style:{opacity:f?1:0},color:"dimmed",size:"sm",className:"palette-value--up palette-value",children:E}),s.jsxs(a.Popover,{width:240,trapFocus:!0,opened:d,onClose:h,zIndex:340,withinPortal:!0,children:[s.jsx(a.Popover.Target,{children:s.jsx("div",{"data-testid":"palette-item-target",className:"palette-item",onClick:p,style:{"--shadow-color":dt(r).alpha(.5).hex(),backgroundColor:r}})}),s.jsxs(a.Popover.Dropdown,{children:[s.jsx(a.Tooltip,{withinPortal:!0,zIndex:340,label:e("common.actions.close"),children:s.jsx(a.CloseButton,{"data-testid":"palette-item-cancel",size:"sm",color:"gray",onClick:T,style:{position:"absolute",top:"0.5em",right:"0.8em"}})}),s.jsxs(a.Stack,{children:[s.jsx(a.TextInput,{size:"xs",label:e("style.color.interpolation.palette.mapping.value_input_label"),value:c,onChange:F=>{const N=F.currentTarget.value;u(N)},error:c&&V}),s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Button,{variant:"light",color:"red",size:"xs",onClick:z,leftIcon:s.jsx(k.IconTrash,{size:16}),children:e("common.actions.delete")}),s.jsx(a.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),"data-testid":"palette-item-ok",size:"xs",onClick:D,disabled:V,children:e("common.actions.save")})]})]})]})]}),s.jsx(a.Text,{title:w,style:{opacity:v?1:0},color:"dimmed",size:"sm",className:"palette-value--bottom palette-value",children:E})]})}const Zh=S.observer(({model:t})=>{const{classes:e}=Ua(),n=b.range(0,13,1).map(r=>100/12*r).map(r=>[t.interpolation.getColor(r),r]);return s.jsx("div",{className:e.palette,children:n.map(([r,i],o)=>s.jsx(Xh,{index:o,color:r,value:t.getStepFromValue(i),onChange:l=>t.changeStep(l,i)},r))})}),Hh=S.observer(function(e){const n=W.useCreation(()=>new Jh,[]);return m.useEffect(()=>{n.fromProps(e)}),n.interpolation==null?null:s.jsx(Zh,{model:n})}),em=t=>{const{t:e,i18n:n}=_.useTranslation(),{value:r,onChange:i,colorManager:o}=t,l=o.getColorInterpolations(),[c,u]=m.useState(r),d=o.decodeInterpolation(c.interpolation)||l[0],[p,{setTrue:h,setFalse:g}]=W.useBoolean(),f=m.useMemo(()=>l.map(z=>({label:e(z.displayName),value:o.encodeColor(z),group:e(`style.color.interpolation.palette.category.${z.category}`)})),[n.language]);function v(z){z&&u(E=>({...E,interpolation:z}))}const w=()=>{g(),i==null||i(J.toJS(c))};function T(z){u(E=>({...E,steps:z}))}const D=()=>{g(),u(r)};return s.jsxs(s.Fragment,{children:[s.jsx(a.Button,{variant:"outline",onClick:h,children:e(d==null?void 0:d.displayName)}),s.jsx(a.Modal,{size:508,title:e("style.color.interpolation.setup"),opened:p,onClose:g,zIndex:320,children:p&&s.jsxs(a.Stack,{"data-testid":"color-interpolation-modal",children:[s.jsx(a.Select,{label:e("style.color.interpolation.palette.label"),value:c.interpolation,data:f,onChange:v,withinPortal:!0,zIndex:340,maxDropdownHeight:500}),s.jsx(Hh,{steps:c.steps,interpolation:d,onChange:T}),s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Button,{onClick:D,variant:"subtle",children:e("common.actions.cancel")}),s.jsx(a.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),onClick:w,children:e("common.actions.save")})]})]})})]})},tm=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},i)=>{const{t:o,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:o("style.color.type.static"),value:"static"},{label:o("style.color.type.interpolation"),value:"interpolation"},{label:o("style.color.type.none"),value:"none"}],[l.language]);return s.jsx(a.Select,{ref:i,label:t??o("style.color.type.label"),data:c,value:e,onChange:n,sx:r})}),nm=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},i)=>{const{t:o,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:o("style.flex.justify_content.left"),value:"left"},{label:o("style.flex.justify_content.center"),value:"center"},{label:o("style.flex.justify_content.right"),value:"right"},{label:o("style.flex.justify_content.space_between"),value:"space-between"},{label:o("style.flex.justify_content.space_around"),value:"space-around"},{label:o("style.flex.justify_content.space_evenly"),value:"space-evenly"}],[l.language]);return s.jsx(a.Select,{ref:i,label:t??o("style.flex.justify_content.label"),data:c,value:e,onChange:n,sx:r})}),sm=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},i)=>{const{t:o,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:o("style.flex.align_items.start"),value:"start"},{label:o("style.flex.align_items.center"),value:"center"},{label:o("style.flex.align_items.end"),value:"end"},{label:o("style.flex.align_items.stretch"),value:"stretch"}],[l.language]);return s.jsx(a.Select,{ref:i,label:t??o("style.flex.align_items.label"),data:c,value:e,onChange:n,sx:r})}),rm={tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px"}},ae=({control:t,watch:e,name:n,getItem:r,children:i,addButtonText:o,deleteButtonText:l,renderTabName:c,deleteDisalbed:u})=>{const{fields:d,append:p,remove:h}=y.useFieldArray({control:t,name:n}),g=e(n),f=d.map((w,T)=>({...w,...g[T]})),v=()=>{p(r())};return s.jsxs(a.Tabs,{defaultValue:"0",styles:rm,children:[s.jsxs(a.Tabs.List,{children:[f.map((w,T)=>s.jsx(a.Tabs.Tab,{value:T.toString(),children:c(w,T)},w.id)),s.jsx(a.Tabs.Tab,{onClick:v,value:"add",children:s.jsx(a.Tooltip,{label:o,children:s.jsx(a.Center,{children:s.jsx(k.IconPlus,{size:18,color:"#228be6"})})})})]}),f.map((w,T)=>s.jsx(a.Tabs.Panel,{value:T.toString(),children:s.jsxs(a.Stack,{children:[i({field:w,index:T}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed"}),s.jsx(a.Button,{leftIcon:s.jsx(k.IconTrash,{size:16}),color:"red",variant:"light",onClick:()=>h(T),sx:{top:15,right:5},disabled:u==null?void 0:u({field:w,index:T,fields:f}),children:l})]})},w.id))]})},Ln=m.forwardRef(({value:t,onChange:e},n)=>{const{t:r}=_.useTranslation(),i=o=>l=>{e({...t,[o]:l})};return s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{variant:"dashed",label:r("chart.zooming.scroll.label"),labelPosition:"center"}),s.jsxs(a.Group,{children:[s.jsx(a.Box,{sx:{flexGrow:1},children:s.jsx(a.Switch,{label:r("chart.zooming.scroll.x_axis"),checked:t.x_axis_scroll,onChange:o=>i("x_axis_scroll")(o.currentTarget.checked)})}),s.jsx(a.Box,{sx:{flexGrow:1},children:s.jsx(a.Switch,{label:r("chart.zooming.scroll.y_axis"),checked:t.y_axis_scroll,onChange:o=>i("y_axis_scroll")(o.currentTarget.checked)})})]}),s.jsx(a.Divider,{variant:"dashed",label:r("chart.zooming.slider.label"),labelPosition:"center"}),s.jsxs(a.Group,{children:[s.jsx(a.Box,{sx:{flexGrow:1},children:s.jsx(a.Switch,{label:r("chart.zooming.slider.x_axis"),checked:t.x_axis_slider,onChange:o=>i("x_axis_slider")(o.currentTarget.checked)})}),s.jsx(a.Tooltip,{label:r("chart.zooming.slider.y_axis_disabled"),children:s.jsx(a.Box,{sx:{flexGrow:1},children:s.jsx(a.Switch,{label:r("chart.zooming.slider.y_axis"),disabled:!t.y_axis_slider,checked:t.y_axis_slider,onChange:o=>i("y_axis_slider")(o.currentTarget.checked)})})})]})]})}),Ct=m.forwardRef(({label:t,value:e,onChange:n,sx:r={},disabled:i},o)=>{const{t:l,i18n:c}=_.useTranslation(),u=m.useMemo(()=>[{label:l("chart.orientation.horizontal"),value:"horizontal"},{label:l("chart.orientation.vertical"),value:"vertical"}],[c.language]);return s.jsx(a.Select,{ref:o,label:t??l("chart.orientation.label"),data:u,value:e,onChange:n,sx:r,disabled:i})}),im=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=e("legend"),i=(o,l)=>{const c={...r,orient:o};o==="horizontal"?(c.top="0",c.left="auto",c.right="10",c.bottom="auto"):(c.top="10",c.left="auto",c.right="0",c.bottom="auto"),l(c)};return s.jsxs(a.Stack,{children:[s.jsx(a.Group,{grow:!0,noWrap:!0,mt:20,children:s.jsx(y.Controller,{name:"legend.show",control:t,render:({field:o})=>s.jsx(a.Switch,{label:n("chart.legend.show_legend"),sx:{flex:1},checked:o.value,onChange:l=>o.onChange(l.currentTarget.checked)})})}),s.jsx(a.Group,{children:s.jsx(y.Controller,{name:"legend",control:t,render:({field:o})=>s.jsx(Ct,{sx:{flex:1},value:o.value.orient,onChange:l=>{i(l,o.onChange)},disabled:!r.show})})})]})};function am({control:t,index:e,variableOptions:n}){const{t:r}=_.useTranslation();return s.jsxs(a.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`reference_lines.${e}.name`,control:t,render:({field:i})=>s.jsx(a.TextInput,{label:r("common.name"),placeholder:r("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...i})}),s.jsx(y.Controller,{name:`reference_lines.${e}.variable_key`,control:t,render:({field:i})=>s.jsx(a.Select,{label:r("common.value"),required:!0,data:n,sx:{flex:1},...i})})]}),s.jsx(y.Controller,{name:`reference_lines.${e}.template`,control:t,render:({field:i})=>s.jsx(a.TextInput,{label:r("chart.content_template.label"),placeholder:r("chart.content_template.placeholder"),required:!0,sx:{flex:1},...i})})]})}function om({control:t,watch:e,variables:n}){const{t:r}=_.useTranslation(),i=()=>({name:"",template:"",variable_key:""}),o=m.useMemo(()=>n.map(c=>({label:c.name,value:c.name})),[n]),l=(c,u)=>{const d=c.name.trim();return d||u+1};return s.jsx(ae,{control:t,watch:e,name:"reference_lines",getItem:i,addButtonText:r("chart.reference_line.add"),deleteButtonText:r("chart.reference_line.delete"),renderTabName:l,children:({field:c,index:u})=>s.jsx(am,{control:t,index:u,variableOptions:o})})}const lm=({control:t,index:e})=>{const{t:n}=_.useTranslation();return s.jsx(a.Stack,{children:s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`tooltip.metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:`tooltip.metrics.${e}.data_key`,control:t,render:({field:r})=>s.jsx(O,{label:n("chart.data_field"),required:!0,sx:{flex:1},...r})})]})})},cm=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(o,l)=>{const c=o.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(a.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),s.jsx(ae,{control:t,watch:e,name:"tooltip.metrics",getItem:r,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:o,index:l})=>s.jsx(lm,{control:t,index:l})})]})};function um({control:t,watch:e}){return s.jsx(a.Stack,{children:s.jsx(cm,{control:t,watch:e})})}const xt=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},i)=>{const{t:o}=_.useTranslation();return s.jsx(a.NumberInput,{ref:i,label:t??o("chart.rotate"),hideControls:!0,min:-90,max:90,rightSection:s.jsx(a.Text,{size:"xs",color:"dimmed",children:o("chart.degree")}),sx:r,styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},value:e,onChange:n})}),dm=({control:t,watch:e})=>{const{t:n}=_.useTranslation();return e(["x_axis"]),s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.name",control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("chart.x_axis.x_axis_name"),sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"x_axis.data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("chart.x_axis.x_axis_data_field"),required:!0,sx:{flex:1},...r})})]}),s.jsx(a.Divider,{mb:-15,label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:r})=>s.jsx(xt,{sx:{width:"48%"},...r})}),s.jsx(y.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:r})=>s.jsx(tt,{...r})})]}),s.jsx(y.Controller,{name:"x_axis.axisLabel.overflow",control:t,render:({field:r})=>s.jsx(nt,{...r})})]})},Ys={root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}},pm=["123456789","1234","1234.56789","1.234","0.123456789","-0.123456789"];function hm({format:t}){const{t:e}=_.useTranslation(),[n,{toggle:r}]=ie.useDisclosure(!1);return s.jsxs(a.Box,{children:[s.jsx(a.Button,{variant:"subtle",w:"100%",compact:!0,onClick:r,leftIcon:n?s.jsx(k.IconChevronUp,{size:14}):s.jsx(k.IconChevronDown,{size:14}),children:e(n?"numbro.format.preview.close":"numbro.format.preview.open")}),s.jsx(a.Collapse,{in:n,children:n&&s.jsxs(a.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:e("numbro.format.preview.input")}),s.jsx("th",{children:e("numbro.format.preview.output")})]})}),s.jsx("tbody",{children:pm.map(i=>s.jsxs("tr",{children:[s.jsx("td",{children:i}),s.jsx("td",{children:s.jsx(je,{children:U(i,t)})})]},i))})]})})]})}function mm({value:t,onChange:e},n){const{t:r}=_.useTranslation(),i=d=>{e({...t,output:d})},o=d=>{const p=d===0?!1:t.trimMantissa;e({...t,mantissa:d,trimMantissa:p})},l=d=>{e({...t,trimMantissa:d.currentTarget.checked})},c=d=>{e({...t,average:d.currentTarget.checked})},u=d=>{const p={...t,absolute:d.currentTarget.checked};e(p)};return s.jsxs(a.Stack,{ref:n,children:[s.jsxs(a.Group,{grow:!0,children:[s.jsx(a.Select,{label:r("numbro.format.label"),data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:t.output,onChange:i,sx:{flexGrow:1}}),s.jsx(a.Switch,{label:s.jsxs(a.Stack,{spacing:0,children:[s.jsx(a.Text,{children:r("numbro.format.absolute")}),s.jsx(a.Text,{size:12,color:"gray",children:r("numbro.format.absolute_description")})]}),checked:t.absolute,onChange:u,sx:{flexGrow:1},styles:Ys}),s.jsx(a.Switch,{label:s.jsxs(a.Stack,{spacing:0,children:[s.jsx(a.Text,{children:r("numbro.format.abbreviation")}),s.jsx(a.Text,{size:12,color:"gray",children:r("numbro.format.abbreviation_description")})]}),checked:t.average,onChange:c,disabled:t.output!=="number",sx:{flexGrow:1},styles:Ys})]}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(a.NumberInput,{label:r("numbro.format.mantissa"),defaultValue:0,min:0,step:1,max:4,value:t.mantissa,onChange:o}),s.jsx(a.Switch,{label:s.jsxs(a.Stack,{spacing:0,children:[s.jsx(a.Text,{children:r("numbro.format.trim_mantissa")}),s.jsx(a.Text,{size:12,color:"gray",children:r("numbro.format.trim_mantissa_description")})]}),checked:t.trimMantissa,onChange:l,disabled:t.mantissa===0,styles:Ys}),s.jsx(a.Box,{})]}),s.jsx(hm,{format:t})]})}const Re=m.forwardRef(mm),xm=({control:t,watch:e})=>{const{t:n}=_.useTranslation();return e(["y_axis"]),s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"y_axis.name",control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("chart.y_axis.y_axis_name"),sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"y_axis.data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("chart.y_axis.y_axis_data_field"),required:!0,sx:{flex:1},...r})})]}),s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mt:10,mb:-15,variant:"dashed",label:n("chart.axis.section_title.label_format"),labelPosition:"center"}),s.jsx(y.Controller,{name:"y_axis.label_formatter",control:t,render:({field:r})=>s.jsx(Re,{...r})})]})]})};function gm({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),{variables:i}=t,o=m.useMemo(()=>b.defaults({},n,Gs),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=y.useForm({defaultValues:o});m.useEffect(()=>{p(o)},[o]),u(["x_axis","y_axis","reference_lines","color","dataZoom"]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,n),[h,n]);return s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:c(r),children:[s.jsx(ge,{canSubmit:g}),s.jsxs(a.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"X Axis",children:e("chart.x_axis.label")}),s.jsx(a.Tabs.Tab,{value:"Y Axis",children:e("chart.y_axis.label")}),s.jsx(a.Tabs.Tab,{value:"Legend",children:e("chart.legend.label")}),s.jsx(a.Tabs.Tab,{value:"Tooltip",children:e("chart.tooltip.label")}),s.jsx(a.Tabs.Tab,{value:"Style",children:e("chart.style.label")}),s.jsx(a.Tabs.Tab,{value:"Reference Lines",children:e("chart.reference_line.labels")}),s.jsx(a.Tabs.Tab,{value:"Zooming",children:e("chart.zooming.label")})]}),s.jsx(a.Tabs.Panel,{value:"X Axis",children:s.jsx(dm,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Y Axis",children:s.jsx(xm,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Legend",children:s.jsx(im,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Tooltip",children:s.jsx(um,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Style",children:s.jsxs(a.Stack,{spacing:4,children:[s.jsx(a.Text,{size:"sm",children:e("chart.color.label")}),s.jsx(y.Controller,{name:"color",control:l,render:({field:f})=>s.jsx(Te,{...f})})]})}),s.jsx(a.Tabs.Panel,{value:"Reference Lines",children:s.jsx(om,{variables:i,control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Zooming",children:s.jsx(y.Controller,{name:"dataZoom",control:l,render:({field:f})=>s.jsx(Ln,{...f})})})]})]})})}function fm(t){return b.omit(t,"variables")}function ym(t){const{label_formatter:e=_e,...n}=t.y_axis;return{...t,y_axis:{...n,label_formatter:e}}}function bm(t){const e={rotate:0,formatter:ke()},{axisLabel:n=e,...r}=t.x_axis;return{...t,x_axis:{...r,axisLabel:n}}}function vm(t){const e={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return b.defaultsDeep(e,t)}function _m(t){delete t.config;const{x_axis:e,tooltip:n}=t.x_axis.axisLabel.overflow,r={x_axis:{axisLabel:{overflow:{on_axis:e,in_tooltip:n}}}};return b.defaultsDeep(r,t)}function jm(t){const e={tooltip:{metrics:[]}};return b.defaultsDeep(e,t)}function wm(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis:i,y_axis:o,tooltip:l,...c}=t;return{...c,x_axis:{...i,data_key:r(i.data_key)},y_axis:{...o,data_key:r(o.data_key)},tooltip:{...l,metrics:l.metrics.map(u=>({...u,data_key:r(u.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}function Cm(t){const e={legend:{show:!0,top:"0",right:"10",left:"auto",bottom:"auto",orient:"horizontal",type:"scroll"}};return b.defaultsDeep(e,t)}function Sm(t){const{dataZoom:e,...n}=t;return{...n,dataZoom:e??qa()}}class km extends ce{constructor(){super(...arguments);$(this,"VERSION",9)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,{panelModel:r})=>{const{config:i}=n;return(i.variables||[]).forEach(l=>{r.variables.find(c=>c.name===l.name)||r.addVariable(l)}),{...n,version:2,config:fm(i)}}),this.version(3,n=>{const{config:r}=n;return{...n,version:3,config:ym(r)}}),this.version(4,n=>{const{config:r}=n;return{...n,version:4,config:bm(r)}}),this.version(5,n=>{const{config:r}=n;return{...n,version:5,config:vm(r)}}),this.version(6,n=>{const{config:r}=n;return{...n,version:6,config:_m(r)}}),this.version(7,n=>{const{config:r}=n;return{...n,version:7,config:jm(r)}}),this.version(8,(n,r)=>{const{config:i}=n;return{...n,version:8,config:wm(i,r)}}),this.version(9,n=>{const{config:r}=n;return{...n,version:9,config:Cm(r)}}),this.version(10,n=>{const{config:r}=n;return{...n,version:10,config:Sm(r)}})}}const Tm={displayName:"viz.boxplot.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new km,name:"boxplot",viewRender:Uh,configRender:gm,createConfig(){return{version:10,config:b.cloneDeep(Gs)}},triggers:[Oa],translation:Mp},Ka={id:"builtin:button:click-button",displayName:"viz.button.click.label",nameRender:zm,configRender:Dm,payload:[]};function Dm(t){return s.jsx(s.Fragment,{})}function zm(t){const{t:e}=_.useTranslation();return s.jsx(a.Text,{children:e("viz.button.click.label")})}const Ks={content:"Button",variant:"filled",color:"blue",size:"xs",compact:!1,horizontal_align:"left",vertical_align:"center"},Mm={left:"flex-start",center:"center",right:"flex-end"},Im={top:"flex-start",center:"center",bottom:"flex-end"},Em=S.observer(({context:t,instance:e})=>{const n=Oe({vizManager:t.vizManager,instance:e}),r=qe(n.triggerManager,Ka.id),i=he(),{value:o}=q(t.instanceData,"config"),l=m.useMemo(()=>b.defaultsDeep({},o,Ks),[o]),{content:c,horizontal_align:u,vertical_align:d,...p}=l,{width:h,height:g}=t.viewport,f=i.payloadForSQL,v=()=>{r.forEach(w=>{n.runInteraction(w.id,{})})};return s.jsx(a.Center,{sx:{width:h,height:g,justifyContent:Mm[u],alignItems:Im[d]},children:s.jsx(a.Button,{...p,onClick:v,children:b.template(c)(f)})})}),Am=({value:t,onChange:e,label:n})=>{const r=a.useMantineTheme(),i=m.useCallback(l=>()=>e(l),[e]),o=l=>t===l;return s.jsxs(a.Stack,{spacing:2,children:[s.jsx(a.Text,{size:14,sx:{fontWeight:500},children:n}),s.jsx(a.Group,{position:"left",spacing:"xs",children:Object.keys(r.colors).map(l=>{const c=r.colors[l][6];return s.jsx(a.ColorSwatch,{color:c,onClick:i(l),radius:4,size:26,sx:{cursor:"pointer"},children:o(l)&&s.jsx(a.CheckIcon,{width:10,color:"white"})},l)})})]})},Js=m.forwardRef(({label:t,value:e,onChange:n,sx:r,disabled:i},o)=>{const{t:l}=_.useTranslation(),c=m.useMemo(()=>a.MANTINE_SIZES.map(u=>({label:l(`style.size.${u}`),value:u})),[]);return s.jsx(a.Select,{ref:o,data:c,label:t,value:e,onChange:n,sx:r,disabled:!0})}),Pm=[{label:"Filled",value:"filled"},{label:"Outline",value:"outline"},{label:"Light",value:"light"},{label:"White",value:"white"},{label:"Default",value:"default"},{label:"Subtle",value:"subtle"},{label:"Gradient",value:"gradient",disabled:!0}];function $m({context:t}){const{value:e,set:n}=q(t.instanceData,"config"),r=m.useMemo(()=>b.defaultsDeep({},e,Ks),[e]),i=r;m.useEffect(()=>{!b.isEqual(r,i)&&(console.log("config malformed, resetting to defaults",r,i),n(i))},[r,i]);const{control:o,handleSubmit:l,watch:c,getValues:u,reset:d}=y.useForm({defaultValues:i});m.useEffect(()=>{d(i)},[i]);const p=u(),h=m.useMemo(()=>!b.isEqual(p,r),[p,r]);return c(["content","variant","color","size","compact","horizontal_align","vertical_align"]),s.jsxs("form",{onSubmit:l(n),children:[s.jsx(ge,{canSubmit:h}),s.jsxs(a.Stack,{children:[s.jsx(y.Controller,{control:o,name:"content",render:({field:g})=>s.jsx(a.TextInput,{label:"Content Template",description:"Filter values & context entries are supported",...g,required:!0})}),s.jsx(a.Divider,{mt:"xs",mb:0,label:"Styles",labelPosition:"center",variant:"dashed"}),s.jsxs(a.SimpleGrid,{cols:2,children:[s.jsx(y.Controller,{control:o,name:"variant",render:({field:g})=>s.jsx(a.Select,{label:"Variant",data:Pm,...g})}),s.jsx(y.Controller,{control:o,name:"color",render:({field:g})=>s.jsx(Am,{label:"Theme",...g})})]}),s.jsxs(a.SimpleGrid,{cols:2,children:[s.jsx(y.Controller,{control:o,name:"size",render:({field:g})=>s.jsx(Js,{label:"Size",...g})}),s.jsx(y.Controller,{control:o,name:"compact",render:({field:g})=>s.jsx(a.Checkbox,{label:"Compact",checked:g.value,onChange:f=>g.onChange(f.currentTarget.checked),mt:26})})]}),s.jsxs(a.SimpleGrid,{cols:2,children:[s.jsx(y.Controller,{control:o,name:"horizontal_align",render:({field:g})=>s.jsx(Bn,{...g})}),s.jsx(y.Controller,{control:o,name:"vertical_align",render:({field:g})=>s.jsx(Ra,{...g})})]})]})]})}const Bm=[{lang:"en",resources:{button:{viz_name:"Button",click:{label:"Click this button"}}}},{lang:"zh",resources:{button:{viz_name:"按钮",click:{label:"点击此按钮"}}}}];class Lm extends ce{constructor(){super(...arguments);$(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{horizontal_align:r="left",vertical_align:i="center",...o}=n.config;return{...n,version:2,config:{...o,horizontal_align:r,vertical_align:i}}})}}const qm={displayName:"viz.button.viz_name",displayGroup:"chart.groups.others",migrator:new Lm,name:"button",viewRender:Em,configRender:$m,createConfig(){return{version:2,config:b.cloneDeep(Ks)}},triggers:[Ka],translation:Bm},Xs={id:"builtin:echarts:click-echart:series",displayName:"viz.cartesian_chart.click_series.label",nameRender:Vm,configRender:Om,payload:[{name:"seriesType",description:"'line' | 'scatter' | 'bar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Om(t){return s.jsx(s.Fragment,{})}function Vm(t){const{t:e}=_.useTranslation();return s.jsx(a.Text,{children:e("viz.cartesian_chart.click_series.label")})}const Zs={regressions:[],series:[],stats:{templates:{bottom:"",top:""}},x_axis:{type:"category",axisLabel:{rotate:0,formatter:ke(),overflow:$e()}},tooltip:{metrics:[]},x_axis_data_key:"",x_axis_name:"",y_axes:[{min:"",max:"",name:"Y Axis",show:!0,position:"left",nameAlignment:"center",label_formatter:_e}],reference_lines:[],reference_areas:[],dataZoom:Mt};function Nm(t){const e=t.y_axes.some(i=>!!i.name);let n=15;e&&(n+=20),t.dataZoom.x_axis_slider&&(n+=20);let r=5;return t.x_axis_name&&(r+=15),t.series.some(i=>!i.hide_in_legend)&&(r+=20),{top:n,right:15,bottom:r,left:20,containLabel:!0}}function Gm(t){return t!=="line"?{}:{itemStyle:{opacity:0}}}function Fm(t){switch(t){case"line":return;case"bar":return"roundRect";case"scatter":return"circle"}}function Wm(t){const e={show:!0,bottom:0,left:"center",type:"scroll"};return e.data=t.filter(n=>!n.hide_in_legend).map(({name:n,type:r})=>({name:n,icon:Fm(r),...Gm(r)})),e}function qn(t,e){switch(t.config.method){case"linear":return[...wt.regressionLinear()(e)];case"exponential":return[...wt.regressionExp()(e)];case"logistic":return[...wt.regressionLog()(e)];case"polynomial":return[...wt.regressionPoly().order(t.config.order)(e)];default:return[]}}function Qm(t,e,n,r){const{transform:i,plot:o}=t,l={...o,name:e,data:qn(i,r),showSymbol:!1,tooltip:{show:!1},smooth:!1,custom:{}};return n&&(l.custom={type:"regression-line",targetSeries:n}),l}function Rm({regressions:t=[],x_axis_data_key:e},n){const r=[];if(Object.keys(n).length===0)return r;function i(o,l,c,u){const d=Qm(o,l,c,u);r.push(d)}return t.forEach(o=>{const{name:l,group_by_key:c}=o;if(!c||c===e){const h=Xe(n,o.y_axis_data_key).map((g,f)=>[f,Number(g)]);i(o,l,"",h);return}const{columnKey:u}=A(o.y_axis_data_key),d=b.groupBy(Tn(n,o.y_axis_data_key),c);Object.entries(d).forEach(([p,h])=>{const g=h.map((v,w)=>[w,Number(v[u])]);i(o,p,p,g)})}),r}function Um(t,e){return t.map(n=>({name:"",type:"line",hide_in_legend:!0,data:[],markArea:{itemStyle:{color:n.color},data:[[{yAxis:e[n.y_keys.upper]},{yAxis:e[n.y_keys.lower]}]],silent:!0}}))}function Ym(t,e,n,r){return e?r==="value"?[[n[0],t]]:[t]:[]}function Km(t,e,n,r,i,o){return t.map(l=>{const c=n[l.variable_key],u=l.orientation==="horizontal",d=u?"yAxis":"xAxis",p=u?"insideEndTop":"end",h=Ym(c,u,i,o);return{name:l.name,type:"scatter",hide_in_legend:!l.show_in_legend,xAxisId:"main-x-axis",yAxisIndex:l.yAxisIndex,data:h,symbol:"none",silent:!0,tooltip:{show:!1},markLine:{data:[{name:l.name,[d]:c}],silent:!0,symbol:["none","none"],lineStyle:l.lineStyle,label:{formatter:function(){return l.template?cn(l.template,e,r):""},position:p}}}})}function Hs(t,e,n){const r=Xe(t,e),i=Xe(t,n);return b.zip(r,i)}function Jm(t,e,n,r){const i=Hs(e,n,r);return b.unionBy(i,t,0)}function Xm({dataTemplate:t,data:e,x_axis_data_key:n,y_axis_data_key:r,valueTypedXAxis:i}){return i?Jm(t,e,n,r):Xe(e,r)}function Zm({dataTemplate:t,data:e,aggregation_on_value:n,x_axis_data_key:r,y_axis_data_key:i,valueTypedXAxis:o}){if(!n||n.type==="none")return Xm({dataTemplate:t,data:e,x_axis_data_key:r,y_axis_data_key:i,valueTypedXAxis:o});const l=Hs(e,r,i),c=b.groupBy(l,"0");return t.map(([d])=>{const h=c[d].map(f=>f[1]),g=zs(h,n);return[d,g]})}function Hm({group_by_key:t,data:e,x_axis_data_key:n,y_axis_data_key:r}){const{queryID:i,columnKey:o}=A(t),l=b.groupBy(e[i],o);return Object.entries(l).forEach(([c,u])=>{l[c]=Hs({[i]:u},n,r)}),l}function ex({type:t,...e},n,r,i){if(!t)return 10;if(t==="static"){const{size:d}=e;return d}const{func_content:o}=e,{queryID:l,columnKey:c}=A(r),u=b.keyBy(Tn(n,l),c);return(d,p)=>{let h;p.name?h=u[p.name]:h=n[p.dataIndex];try{return new Function(`return ${o}`)()({rowData:h,params:p,variables:i},{lodash:b,interpolate:Dt.interpolate})}catch(g){return console.error(`[getEchartsSymbolSize] failed parsing custom function, error: ${g.message}`),10}}}function tx({x_axis_data_key:t,x_axis:e},{y_axis_data_key:n,yAxisIndex:r,label_position:i,name:o,group_by_key:l,aggregation_on_value:c,stack:u,color:d,display_name_on_line:p,symbolSize:h,hide_in_legend:g,...f},v,w,T,D){const z=e.type!=="category",E={label:{show:!!i,position:i,formatter:D[r??"default"]},name:o,xAxisId:"main-x-axis",yAxisIndex:r,stack:u,color:d,symbolSize:ex(h,w,t,T),hide_in_legend:g,labelLayout:{hideOverlap:!0},...f};if(f.type==="line"&&(E.lineStyle={shadowColor:"rgba(255,255,255,1)",shadowBlur:0,shadowOffsetX:0,shadowOffsetY:3}),p&&(E.endLabel={show:!0,formatter:o,offset:[-12,12],align:"right"}),!l||l===t)return E.data=Zm({dataTemplate:v,data:w,aggregation_on_value:c,x_axis_data_key:t,y_axis_data_key:n,valueTypedXAxis:z}),E;const V=Hm({group_by_key:l,data:w,x_axis_data_key:t,y_axis_data_key:n});return Object.entries(V).map(([F,N])=>{const Q=b.cloneDeep(E);return Q.name=F,Q.color=void 0,Q.data=N,Q})}function nx(t,e,n,r,i,o){const l=e.map(u=>[u,0]);return t.series.map(u=>tx(t,u,l,n,o,r)).flat().concat(Km(t.reference_lines,i,o,n,e,t.x_axis.type)).concat(Um(t.reference_areas,o))}function sx(t,e){const n=t.find(o=>o.axisDim==="x"&&o.axisId==="main-x-axis");if(!n)return"";const{axisValue:r,axisIndex:i}=n;return Pe(e.x_axis.axisLabel.formatter)(r,i)}const rx=t=>U(t,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function ix(t,e,n,r){const i=n.reduce((o,{yAxisIndex:l,name:c})=>(o[c]=l,o),{});return te.getTooltip({trigger:"axis",formatter:function(o){const l=Array.isArray(o)?o:[o];if(l.length===0)return"";const c=l.map(({seriesName:h,marker:g,value:f})=>{if(Array.isArray(f)&&f.length===2&&(f=f[1]),!h)return f;const v=i[h],w=r[v]??r.default;return`
108
+ `}const Ay=(e,t)=>n=>{const{seriesName:s,value:i}=n;switch(s){case t.Box:return My(e,i);case t.Outlier:return Iy(e,i);case t.Scatter:return Ey(e,i)}};function Py({config:e,seriesNames:t}){return te.getTooltip({trigger:"item",formatter:Ay(e,t)})}function ds(e,t){t||(t="none");const n=[];return e.x_axis_scroll&&n.push({type:"inside",xAxisIndex:[0],filterMode:t,minSpan:1}),e.y_axis_scroll&&n.push({type:"inside",yAxisIndex:[0],filterMode:t,minSpan:1}),e.x_axis_slider&&n.push({type:"slider",xAxisIndex:[0],filterMode:t,bottom:"auto",top:0,height:15,moveHandleSize:0,showDataShadow:!1,minSpan:1}),n}function Oy({min:e,max:t}){if(e<=110)return Math.min(0,e);if(e<=200)return 100;const n=On.floor(On.log10(e)),s=Math.pow(10,n),i=Math.pow(10,n-1);return e/s<=2?v.round(e,-1*(n-1))-i:v.round(e,-1*n)-s}function Ly(e){return{Box:e("viz.boxplot.box"),Scatter:e("viz.boxplot.scatter"),Outlier:e("viz.boxplot.outlier")}}function By({config:e,data:t,variables:n,t:s}){const{x_axis:i,y_axis:a,reference_lines:l}=e,c=yy(e,t),u=ut(i.axisLabel.overflow.on_axis),d=Ly(s),p=Dy(e,c).map(h=>({...h,name:v.get(d,h.name,h.name)}));return{dataZoom:ds(e.dataZoom,"filter"),grid:by(e),dataset:c,legend:vy({config:e,seriesNames:d}),tooltip:Py({config:e,seriesNames:d}),xAxis:[te.getXAxis({type:"category",name:i.name,nameGap:25,nameLocation:"center",nameTextStyle:{align:"center"},axisLabel:{...i.axisLabel,...u,formatter:Ye(i.axisLabel.formatter)}})],yAxis:[te.getYAxis({name:a.name,minInterval:1,axisLabel:{formatter:function(h){return U(h,a.label_formatter)}},min:Oy})],series:[...p,..._y(l,n,t)]}}function qy({context:e,instance:t}){const{t:n}=_.useTranslation(),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=e.data,{width:l,height:c}=e.viewport,u=v.defaults({},s,Ni),d=rt({vizManager:e.vizManager,instance:t}),p=nt(d.triggerManager,Nc.id),h=wn(a,u.x_axis.data_key),f=m.useCallback(j=>{const k=v.get(h,j.name,{error:"rowData is not found"});p.forEach(S=>{d.runInteraction(S.id,{...j,rowData:k})})},[h,p,d]),g=m.useMemo(()=>({click:f}),[f]),y=m.useMemo(()=>By({config:u,data:a,variables:i,t:n}),[u,a,i,n]);return!s||!l||!c?null:r.jsx(Ue,{width:l,height:c,children:r.jsx(Pe,{echarts:Ae,option:y,style:gr(l,c),onEvents:g,notMerge:!0,theme:"merico-light"})})}function Vy({value:e,onChange:t},n){const{t:s}=_.useTranslation(),{colorManager:i}=m.useContext(Gt),a=m.useMemo(()=>i.getStaticColors().map(u=>({label:u.name,group:u.category,value:u.value})),[i]),l=m.useMemo(()=>a.some(c=>c.value===e),[e,a]);return r.jsxs(o.Group,{position:"apart",spacing:4,ref:n,children:[r.jsx(o.TextInput,{placeholder:s("chart.color.set_any_color"),value:l?"":e,onChange:c=>t(c.currentTarget.value),rightSection:r.jsx(o.ColorSwatch,{color:l?"transparent":e,radius:4}),variant:l?"filled":"default",sx:{maxWidth:"46%",flexGrow:1}}),r.jsx(o.Text,{sx:{flexGrow:0},size:"xs",children:s("chart.color.or")}),r.jsx(o.Select,{data:a,value:e,onChange:t,variant:l?"default":"filled",placeholder:s("chart.color.pick_a_theme_color"),icon:r.jsx(o.ColorSwatch,{color:l?e:"transparent",radius:4}),sx:{maxWidth:"46%",flexGrow:1}})]})}const Le=m.forwardRef(Vy);function Ce({canSubmit:e}){const{t}=_.useTranslation();return r.jsxs(o.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[r.jsx(o.Text,{children:t("viz.viz_config_banner")}),r.jsx(o.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!e,children:r.jsx(M.IconDeviceFloppy,{size:20})})]})}const ps=m.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:a("common.align.horizontal.left"),value:"left"},{label:a("common.align.horizontal.center"),value:"center"},{label:a("common.align.horizontal.right"),value:"right"}],[l.language]);return r.jsx(o.Select,{ref:i,label:e??a("common.align.horizontal.label"),data:c,value:t,onChange:n,sx:s})}),Uc=m.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:a("common.align.vertical.top"),value:"top"},{label:a("common.align.vertical.center"),value:"center"},{label:a("common.align.vertical.bottom"),value:"bottom"}],[l.language]);return r.jsx(o.Select,{ref:i,label:e??a("common.align.vertical.label"),data:c,value:t,onChange:n,sx:s})}),Yc=o.createStyles(()=>({palette:{display:"flex",flexFlow:"row nowrap"},paletteItem:{".palette-value":{height:24,overflow:"visible",width:36},".palette-item":{width:"36px",height:36*.618,cursor:"pointer",transition:"transform 100ms ease-in-out","&:hover":{boxShadow:"0 0 0 2px var(--shadow-color)",borderRadius:2,transform:"scale(1.2)"}}}})),Ny=[{from:0,to:0},{from:100,to:100}];class $y{constructor(){B(this,"steps",new Map);B(this,"interpolation");B(this,"onChange");X.makeAutoObservable(this,{steps:X.observable},{deep:!1}),X.reaction(()=>X.toJS(this.steps),()=>{this.notifyStepChange()})}setSteps(t){for(const n of t)this.steps.set(n.to,n.from)}notifyStepChange(){var t;(t=this.onChange)==null||t.call(this,Array.from(this.steps.entries()).map(([n,s])=>({to:n,from:s})).sort((n,s)=>n.to-s.to||n.from-s.from))}fromProps(t){t.steps.length<2?this.setSteps(Ny):this.setSteps(t.steps),this.interpolation=t.interpolation,this.onChange=t.onChange}changeStep(t,n){t==null?this.steps.delete(n):this.steps.set(n,t)}getStepFromValue(t){return this.steps.get(t)}}function Kc(e){if(typeof e=="number")return String(e)}function Fy(e){const{t}=_.useTranslation(),{onChange:n,color:s,index:i,value:a}=e,{classes:l}=Yc(),[c,u]=m.useState(Kc(a)),[d,{setTrue:p,setFalse:h}]=W.useBoolean(!1),f=i%2===1,g=f&&a!=null,y=!f&&a!=null,j=`map ${a} to color ${i}`,k=()=>{u(Kc(a)),h()},S=()=>{h(),n==null||n(Number(c))},T=()=>{h(),n==null||n(null)},z=U(a??null,{output:"number",mantissa:10,trimMantissa:!0,average:!0,absolute:!1}),I=!c||Number.isNaN(Number(c));return r.jsxs("div",{"data-testid":`palette-item-${i}`,className:l.paletteItem,children:[r.jsx(o.Text,{title:j,style:{opacity:g?1:0},color:"dimmed",size:"sm",className:"palette-value--up palette-value",children:z}),r.jsxs(o.Popover,{width:240,trapFocus:!0,opened:d,onClose:h,zIndex:340,withinPortal:!0,children:[r.jsx(o.Popover.Target,{children:r.jsx("div",{"data-testid":"palette-item-target",className:"palette-item",onClick:p,style:{"--shadow-color":Qt(s).alpha(.5).hex(),backgroundColor:s}})}),r.jsxs(o.Popover.Dropdown,{children:[r.jsx(o.Tooltip,{withinPortal:!0,zIndex:340,label:t("common.actions.close"),children:r.jsx(o.CloseButton,{"data-testid":"palette-item-cancel",size:"sm",color:"gray",onClick:k,style:{position:"absolute",top:"0.5em",right:"0.8em"}})}),r.jsxs(o.Stack,{children:[r.jsx(o.TextInput,{size:"xs",label:t("style.color.interpolation.palette.mapping.value_input_label"),value:c,onChange:E=>{const N=E.currentTarget.value;u(N)},error:c&&I}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{variant:"light",color:"red",size:"xs",onClick:T,leftIcon:r.jsx(M.IconTrash,{size:16}),children:t("common.actions.delete")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),"data-testid":"palette-item-ok",size:"xs",onClick:S,disabled:I,children:t("common.actions.save")})]})]})]})]}),r.jsx(o.Text,{title:j,style:{opacity:y?1:0},color:"dimmed",size:"sm",className:"palette-value--bottom palette-value",children:z})]})}const Gy=D.observer(({model:e})=>{const{classes:t}=Yc(),n=v.range(0,13,1).map(s=>100/12*s).map(s=>[e.interpolation.getColor(s),s]);return r.jsx("div",{className:t.palette,children:n.map(([s,i],a)=>r.jsx(Fy,{index:a,color:s,value:e.getStepFromValue(i),onChange:l=>e.changeStep(l,i)},s))})}),Wy=D.observer(function(t){const n=W.useCreation(()=>new $y,[]);return m.useEffect(()=>{n.fromProps(t)}),n.interpolation==null?null:r.jsx(Gy,{model:n})}),Ry=e=>{const{t,i18n:n}=_.useTranslation(),{value:s,onChange:i,colorManager:a}=e,l=a.getColorInterpolations(),[c,u]=m.useState(s),d=a.decodeInterpolation(c.interpolation)||l[0],[p,{setTrue:h,setFalse:f}]=W.useBoolean(),g=m.useMemo(()=>l.map(T=>({label:t(T.displayName),value:a.encodeColor(T),group:t(`style.color.interpolation.palette.category.${T.category}`)})),[n.language]);function y(T){T&&u(z=>({...z,interpolation:T}))}const j=()=>{f(),i==null||i(X.toJS(c))};function k(T){u(z=>({...z,steps:T}))}const S=()=>{f(),u(s)};return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"outline",onClick:h,children:t(d==null?void 0:d.displayName)}),r.jsx(o.Modal,{size:508,title:t("style.color.interpolation.setup"),opened:p,onClose:f,zIndex:320,children:p&&r.jsxs(o.Stack,{"data-testid":"color-interpolation-modal",children:[r.jsx(o.Select,{label:t("style.color.interpolation.palette.label"),value:c.interpolation,data:g,onChange:y,withinPortal:!0,zIndex:340,maxDropdownHeight:500}),r.jsx(Wy,{steps:c.steps,interpolation:d,onChange:k}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:S,variant:"subtle",children:t("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:j,children:t("common.actions.save")})]})]})})]})},Qy=m.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:a("style.color.type.static"),value:"static"},{label:a("style.color.type.interpolation"),value:"interpolation"},{label:a("style.color.type.none"),value:"none"}],[l.language]);return r.jsx(o.Select,{ref:i,label:e??a("style.color.type.label"),data:c,value:t,onChange:n,sx:s})}),Uy=m.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:a("style.flex.justify_content.left"),value:"left"},{label:a("style.flex.justify_content.center"),value:"center"},{label:a("style.flex.justify_content.right"),value:"right"},{label:a("style.flex.justify_content.space_between"),value:"space-between"},{label:a("style.flex.justify_content.space_around"),value:"space-around"},{label:a("style.flex.justify_content.space_evenly"),value:"space-evenly"}],[l.language]);return r.jsx(o.Select,{ref:i,label:e??a("style.flex.justify_content.label"),data:c,value:t,onChange:n,sx:s})}),Yy=m.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:a("style.flex.align_items.start"),value:"start"},{label:a("style.flex.align_items.center"),value:"center"},{label:a("style.flex.align_items.end"),value:"end"},{label:a("style.flex.align_items.stretch"),value:"stretch"}],[l.language]);return r.jsx(o.Select,{ref:i,label:e??a("style.flex.align_items.label"),data:c,value:t,onChange:n,sx:s})});var Ky=Symbol.for("preact-signals");function hs(){if(on>1)on--;else{for(var e,t=!1;xr!==void 0;){var n=xr;for(xr=void 0,Qi++;n!==void 0;){var s=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Jc(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=s}}if(Qi=0,on--,t)throw e}}function Kt(e){if(on>0)return e();on++;try{return e()}finally{hs()}}var ne=void 0;function Nn(e){var t=ne;ne=void 0;try{return e()}finally{ne=t}}var xr=void 0,on=0,Qi=0,fs=0;function Xc(e){if(ne!==void 0){var t=e.n;if(t===void 0||t.t!==ne)return t={i:0,S:e,p:ne.s,n:void 0,t:ne,e:void 0,x:void 0,r:t},ne.s!==void 0&&(ne.s.n=t),ne.s=t,e.n=t,32&ne.f&&e.S(t),t;if(t.i===-1)return t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=ne.s,t.n=void 0,ne.s.n=t,ne.s=t),t}}function Be(e){this.v=e,this.i=0,this.n=void 0,this.t=void 0}Be.prototype.brand=Ky,Be.prototype.h=function(){return!0},Be.prototype.S=function(e){this.t!==e&&e.e===void 0&&(e.x=this.t,this.t!==void 0&&(this.t.e=e),this.t=e)},Be.prototype.U=function(e){if(this.t!==void 0){var t=e.e,n=e.x;t!==void 0&&(t.x=n,e.e=void 0),n!==void 0&&(n.e=t,e.x=void 0),e===this.t&&(this.t=n)}},Be.prototype.subscribe=function(e){var t=this;return Xe(function(){var n=t.value,s=ne;ne=void 0;try{e(n)}finally{ne=s}})},Be.prototype.valueOf=function(){return this.value},Be.prototype.toString=function(){return this.value+""},Be.prototype.toJSON=function(){return this.value},Be.prototype.peek=function(){var e=ne;ne=void 0;try{return this.value}finally{ne=e}},Object.defineProperty(Be.prototype,"value",{get:function(){var e=Xc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Qi>100)throw new Error("Cycle detected");this.v=e,this.i++,fs++,on++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{hs()}}}});function ms(e){return new Be(e)}function Jc(e){for(var t=e.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function Zc(e){for(var t=e.s;t!==void 0;t=t.n){var n=t.S.n;if(n!==void 0&&(t.r=n),t.S.n=t,t.i=-1,t.n===void 0){e.s=t;break}}}function Hc(e){for(var t=e.s,n=void 0;t!==void 0;){var s=t.p;t.i===-1?(t.S.U(t),s!==void 0&&(s.n=t.n),t.n!==void 0&&(t.n.p=s)):n=t,t.S.n=t.r,t.r!==void 0&&(t.r=void 0),t=s}e.s=n}function $n(e){Be.call(this,void 0),this.x=e,this.s=void 0,this.g=fs-1,this.f=4}($n.prototype=new Be).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===fs))return!0;if(this.g=fs,this.f|=1,this.i>0&&!Jc(this))return this.f&=-2,!0;var e=ne;try{Zc(this),ne=this;var t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return ne=e,Hc(this),this.f&=-2,!0},$n.prototype.S=function(e){if(this.t===void 0){this.f|=36;for(var t=this.s;t!==void 0;t=t.n)t.S.S(t)}Be.prototype.S.call(this,e)},$n.prototype.U=function(e){if(this.t!==void 0&&(Be.prototype.U.call(this,e),this.t===void 0)){this.f&=-33;for(var t=this.s;t!==void 0;t=t.n)t.S.U(t)}},$n.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;e!==void 0;e=e.x)e.t.N()}},Object.defineProperty($n.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Xc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function eu(e){return new $n(e)}function tu(e){var t=e.u;if(e.u=void 0,typeof t=="function"){on++;var n=ne;ne=void 0;try{t()}catch(s){throw e.f&=-2,e.f|=8,Ui(e),s}finally{ne=n,hs()}}}function Ui(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,tu(e)}function Xy(e){if(ne!==this)throw new Error("Out-of-order effect");Hc(this),ne=e,this.f&=-2,8&this.f&&Ui(this),hs()}function yr(e){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}yr.prototype.c=function(){var e=this.S();try{if(8&this.f||this.x===void 0)return;var t=this.x();typeof t=="function"&&(this.u=t)}finally{e()}},yr.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,tu(this),Zc(this),on++;var e=ne;return ne=this,Xy.bind(this,e)},yr.prototype.N=function(){2&this.f||(this.f|=2,this.o=xr,xr=this)},yr.prototype.d=function(){this.f|=8,1&this.f||Ui(this)};function Xe(e){var t=new yr(e);try{t.c()}catch(n){throw t.d(),n}return t.d.bind(t)}function gs(e,t){if(t){let n;return eu(()=>{const s=e();return s&&n&&t(n,s)?n:(n=s,s)})}return eu(e)}function Yi(e,t){if(e===t)return!0;if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}if(Array.isArray(e))return!Array.isArray(t)||e.length!==t.length?!1:!e.some((s,i)=>!Yi(s,t[i]));try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function de({get:e},t){return{init(n){return ms(n)},get(){return e.call(this).value},set(n){const s=e.call(this);s.peek()!==n&&(s.value=n)}}}function xs(e,t){const n=new WeakMap;return function(){let s=n.get(this);return s||(s=gs(e.bind(this)),n.set(this,s)),s.value}}function Jy(...e){const t=e.map(Xe);return()=>t.forEach(n=>n())}var Zy=Object.create,Ki=Object.defineProperty,Hy=Object.getOwnPropertyDescriptor,nu=Object.getOwnPropertySymbols,eb=Object.prototype.hasOwnProperty,tb=Object.prototype.propertyIsEnumerable,ru=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Fn=e=>{throw TypeError(e)},su=Math.pow,Xi=(e,t,n)=>t in e?Ki(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,nb=(e,t)=>{for(var n in t||(t={}))eb.call(t,n)&&Xi(e,n,t[n]);if(nu)for(var n of nu(t))tb.call(t,n)&&Xi(e,n,t[n]);return e},iu=(e,t)=>Ki(e,"name",{value:t,configurable:!0}),rb=e=>{var t;return[,,,Zy((t=e==null?void 0:e[ru("metadata")])!=null?t:null)]},au=["class","method","getter","setter","accessor","field","value","get","set"],br=e=>e!==void 0&&typeof e!="function"?Fn("Function expected"):e,sb=(e,t,n,s,i)=>({kind:au[e],name:t,metadata:s,addInitializer:a=>n._?Fn("Already initialized"):i.push(br(a||null))}),ou=(e,t)=>Xi(t,ru("metadata"),e[3]),Cn=(e,t,n,s)=>{for(var i=0,a=e[t>>1],l=a&&a.length;i<l;i++)t&1?a[i].call(n):s=a[i].call(n,s);return s},vr=(e,t,n,s,i,a)=>{var l,c,u,d,p,h=t&7,f=!!(t&8),g=!!(t&16),y=h>3?e.length+1:h?f?1:2:0,j=au[h+5],k=h>3&&(e[y-1]=[]),S=e[y]||(e[y]=[]),T=h&&(!g&&!f&&(i=i.prototype),h<5&&(h>3||!g)&&Hy(h<4?i:{get[n](){return lu(this,a)},set[n](I){return cu(this,a,I)}},n));h?g&&h<4&&iu(a,(h>2?"set ":h>1?"get ":"")+n):iu(i,n);for(var z=s.length-1;z>=0;z--)d=sb(h,n,u={},e[3],S),h&&(d.static=f,d.private=g,p=d.access={has:g?I=>ib(i,I):I=>n in I},h^3&&(p.get=g?I=>(h^1?lu:ab)(I,i,h^4?a:T.get):I=>I[n]),h>2&&(p.set=g?(I,E)=>cu(I,i,E,h^4?a:T.set):(I,E)=>I[n]=E)),c=(0,s[z])(h?h<4?g?a:T[j]:h>4?void 0:{get:T.get,set:T.set}:i,d),u._=1,h^4||c===void 0?br(c)&&(h>4?k.unshift(c):h?g?a=c:T[j]=c:i=c):typeof c!="object"||c===null?Fn("Object expected"):(br(l=c.get)&&(T.get=l),br(l=c.set)&&(T.set=l),br(l=c.init)&&k.unshift(l));return h||ou(e,i),T&&Ki(i,n,T),g?h^4?a:T:i},Ji=(e,t,n)=>t.has(e)||Fn("Cannot "+n),ib=(e,t)=>Object(t)!==t?Fn('Cannot use the "in" operator on this value'):e.has(t),lu=(e,t,n)=>(Ji(e,t,"read from private field"),n?n.call(e):t.get(e)),Zi=(e,t,n)=>t.has(e)?Fn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),cu=(e,t,n,s)=>(Ji(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),ab=(e,t,n)=>(Ji(e,t,"access private method"),n),Xt=class Gl{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new Gl(t.x-n.x,t.y-n.y)}static distance(t,n){return Math.hypot(t.x-n.x,t.y-n.y)}static equals(t,n){return t.x===n.x&&t.y===n.y}static from({x:t,y:n}){return new Gl(t,n)}},ob=class vi{constructor(t,n,s,i){this.left=t,this.top=n,this.width=s,this.height=i,this.scale={x:1,y:1}}get inverseScale(){return{x:1/this.scale.x,y:1/this.scale.y}}translate(t,n){const{top:s,left:i,width:a,height:l,scale:c}=this,u=new vi(i+t,s+n,a,l);return u.scale=nb({},c),u}get boundingRectangle(){const{width:t,height:n,left:s,top:i,right:a,bottom:l}=this;return{width:t,height:n,left:s,top:i,right:a,bottom:l}}get center(){const{left:t,top:n,right:s,bottom:i}=this;return new Xt((t+s)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof vi))return!1;const{left:n,top:s,width:i,height:a}=this;return n===t.left&&s===t.top&&i===t.width&&a===t.height}containsPoint(t){const{top:n,left:s,bottom:i,right:a}=this;return n<=t.y&&t.y<=i&&s<=t.x&&t.x<=a}intersectionArea(t){return t instanceof vi?lb(this,t):0}intersectionRatio(t){const{area:n}=this,s=this.intersectionArea(t);return s/(t.area+n-s)}get bottom(){const{top:t,height:n}=this;return t+n}get right(){const{left:t,width:n}=this;return t+n}};function lb(e,t){const n=Math.max(t.top,e.top),s=Math.max(t.left,e.left),i=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),l=i-s,c=a-n;return s<i&&n<a?l*c:0}var uu=10,du,pu,hu,fu,mu,Je,Hi,ea,ta;mu=[de],fu=[de],hu=[de],pu=[xs],du=[xs];var Gn=class{constructor(e){Cn(Je,5,this),Zi(this,Hi,Cn(Je,8,this)),Cn(Je,11,this),Zi(this,ea,Cn(Je,12,this)),Cn(Je,15,this),Zi(this,ta,Cn(Je,16,this)),Cn(Je,19,this);const t=Xt.from(e);this.initial=t,this.current=t,this.previous=t}get delta(){return Xt.delta(this.current,this.initial)}get direction(){const e={x:this.current.x-this.previous.x,y:this.current.y-this.previous.y};return!e.x&&!e.y?null:Math.abs(e.x)>Math.abs(e.y)?e.x>0?"right":"left":e.y>0?"down":"up"}reset(e){const t=Xt.from(e);Kt(()=>{this.current=t,this.previous=t,this.initial=t})}update(e){const{current:t}=this,n=Xt.from(e);if(Xt.equals(t,n))return;const s={x:n.x-t.x,y:n.y-t.y};(Math.abs(s.x)<uu||Math.abs(s.y)<uu)&&(this.previous=t),this.current=n}};Je=rb(null),Hi=new WeakMap,ea=new WeakMap,ta=new WeakMap,vr(Je,4,"initial",mu,Gn,Hi),vr(Je,4,"previous",fu,Gn,ea),vr(Je,4,"current",hu,Gn,ta),vr(Je,2,"delta",pu,Gn),vr(Je,2,"direction",du,Gn),ou(Je,Gn);function na({x:e,y:t},n){const s=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(su(s,2)+su(i,2))>n:"x"in n&&"y"in n?s>n.x&&i>n.y:"x"in n?s>n.x:"y"in n?i>n.y:!1}var gu=(e=>(e.Horizontal="x",e.Vertical="y",e))(gu||{}),xu=Object.values(gu),cb=Object.create,ra=Object.defineProperty,ub=Object.getOwnPropertyDescriptor,yu=Object.getOwnPropertySymbols,db=Object.prototype.hasOwnProperty,pb=Object.prototype.propertyIsEnumerable,bu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Wn=e=>{throw TypeError(e)},hb=(e,t,n)=>t in e?ra(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vu=(e,t)=>ra(e,"name",{value:t,configurable:!0}),_u=(e,t)=>{var n={};for(var s in e)db.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&yu)for(var s of yu(e))t.indexOf(s)<0&&pb.call(e,s)&&(n[s]=e[s]);return n},ys=e=>{var t;return[,,,cb((t=e==null?void 0:e[bu("metadata")])!=null?t:null)]},ju=["class","method","getter","setter","accessor","field","value","get","set"],_r=e=>e!==void 0&&typeof e!="function"?Wn("Function expected"):e,fb=(e,t,n,s,i)=>({kind:ju[e],name:t,metadata:s,addInitializer:a=>n._?Wn("Already initialized"):i.push(_r(a||null))}),jr=(e,t)=>hb(t,bu("metadata"),e[3]),le=(e,t,n,s)=>{for(var i=0,a=e[t>>1],l=a&&a.length;i<l;i++)t&1?a[i].call(n):s=a[i].call(n,s);return s},Ze=(e,t,n,s,i,a)=>{var l,c,u,d,p,h=t&7,f=!!(t&8),g=!!(t&16),y=h>3?e.length+1:h?f?1:2:0,j=ju[h+5],k=h>3&&(e[y-1]=[]),S=e[y]||(e[y]=[]),T=h&&(!g&&!f&&(i=i.prototype),h<5&&(h>3||!g)&&ub(h<4?i:{get[n](){return bs(this,a)},set[n](I){return ia(this,a,I)}},n));h?g&&h<4&&vu(a,(h>2?"set ":h>1?"get ":"")+n):vu(i,n);for(var z=s.length-1;z>=0;z--)d=fb(h,n,u={},e[3],S),h&&(d.static=f,d.private=g,p=d.access={has:g?I=>mb(i,I):I=>n in I},h^3&&(p.get=g?I=>(h^1?bs:gb)(I,i,h^4?a:T.get):I=>I[n]),h>2&&(p.set=g?(I,E)=>ia(I,i,E,h^4?a:T.set):(I,E)=>I[n]=E)),c=(0,s[z])(h?h<4?g?a:T[j]:h>4?void 0:{get:T.get,set:T.set}:i,d),u._=1,h^4||c===void 0?_r(c)&&(h>4?k.unshift(c):h?g?a=c:T[j]=c:i=c):typeof c!="object"||c===null?Wn("Object expected"):(_r(l=c.get)&&(T.get=l),_r(l=c.set)&&(T.set=l),_r(l=c.init)&&k.unshift(l));return h||jr(e,i),T&&ra(i,n,T),g?h^4?a:T:i},sa=(e,t,n)=>t.has(e)||Wn("Cannot "+n),mb=(e,t)=>Object(t)!==t?Wn('Cannot use the "in" operator on this value'):e.has(t),bs=(e,t,n)=>(sa(e,t,"read from private field"),n?n.call(e):t.get(e)),st=(e,t,n)=>t.has(e)?Wn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ia=(e,t,n,s)=>(sa(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),gb=(e,t,n)=>(sa(e,t,"access private method"),n);function wu(e,t){return{plugin:e,options:t}}function xb(e){return t=>wu(e,t)}function Cu(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var Su,wr,aa;Su=[de];var dt=class{constructor(t,n){this.manager=t,this.options=n,st(this,aa,le(wr,8,this,!1)),le(wr,11,this)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return Nn(()=>this.disabled)}configure(t){this.options=t}destroy(){}static configure(t){return wu(this,t)}};wr=ys(null),aa=new WeakMap,Ze(wr,4,"disabled",Su,dt,aa),jr(wr,dt);var yb=class extends dt{},Cr=(e=>(e[e.Lowest=0]="Lowest",e[e.Low=1]="Low",e[e.Normal=2]="Normal",e[e.High=3]="High",e[e.Highest=4]="Highest",e))(Cr||{}),ku,Tu,Du,Mu,He,oa,la,ca,ua;Mu=[de],Du=[de],Tu=[de],ku=[de];var Sn=class{constructor(e,t){st(this,oa,le(He,8,this)),le(He,11,this),st(this,la,le(He,12,this)),le(He,15,this),st(this,ca,le(He,16,this)),le(He,19,this),st(this,ua,le(He,20,this)),le(He,23,this);const{effects:n,id:s,data:i={},disabled:a=!1}=e;let l=s;this.manager=t,this.id=s,this.data=i,this.disabled=a,this.effects=()=>{var c;return[()=>{const{id:u,manager:d}=this;if(s!==l)return d==null||d.registry.register(this),()=>d==null?void 0:d.registry.unregister(this)},...(c=n==null?void 0:n())!=null?c:[]]},this.destroy=this.destroy.bind(this),t&&queueMicrotask(()=>{var c;(c=this.manager)==null||c.registry.register(this)})}register(){var e;return(e=this.manager)==null?void 0:e.registry.register(this)}unregister(){var e;(e=this.manager)==null||e.registry.unregister(this)}destroy(){var e;(e=this.manager)==null||e.registry.unregister(this)}};He=ys(null),oa=new WeakMap,la=new WeakMap,ca=new WeakMap,ua=new WeakMap,Ze(He,4,"manager",Mu,Sn,oa),Ze(He,4,"id",Du,Sn,la),Ze(He,4,"data",Tu,Sn,ca),Ze(He,4,"disabled",ku,Sn,ua),jr(He,Sn);var zu,Iu,Eu,da,Sr,Bt,pa,ha,kr=class extends(da=Sn,Eu=[de],Iu=[de],zu=[xs],da){constructor(t,n){var s=t,{modifiers:i,type:a,sensors:l}=s,c=_u(s,["modifiers","type","sensors"]);super(c,n),le(Bt,5,this),st(this,Sr),st(this,pa,le(Bt,8,this)),le(Bt,11,this),st(this,ha,le(Bt,12,this,"idle")),le(Bt,15,this),this.type=a,this.sensors=l,this.modifiers=i}set modifiers(t){var n;const{manager:s}=this;(n=bs(this,Sr))==null||n.forEach(i=>i.destroy()),s&&ia(this,Sr,t==null?void 0:t.map(i=>{const{plugin:a,options:l}=Cu(i);return new a(s,l)}))}get modifiers(){return bs(this,Sr)}get isDragSource(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.source)==null?void 0:n.id)===this.id}destroy(){var t;super.destroy(),(t=this.modifiers)==null||t.forEach(n=>n.destroy())}};Bt=ys(da),Sr=new WeakMap,pa=new WeakMap,ha=new WeakMap,Ze(Bt,4,"type",Eu,kr,pa),Ze(Bt,4,"status",Iu,kr,ha),Ze(Bt,2,"isDragSource",zu,kr),jr(Bt,kr);var Au,Pu,Ou,Lu,Bu,qu,fa,Se,ma,ga,xa,ya,ba,ln=class extends(fa=Sn,qu=[de],Bu=[de],Lu=[de],Ou=[de],Pu=[de],Au=[xs],fa){constructor(t,n){var s=t,{accept:i,collisionDetector:a,collisionPriority:l=2,type:c}=s,u=_u(s,["accept","collisionDetector","collisionPriority","type"]);super(u,n),le(Se,5,this),st(this,ma,le(Se,8,this)),le(Se,11,this),st(this,ga,le(Se,12,this)),le(Se,15,this),st(this,xa,le(Se,16,this)),le(Se,19,this),st(this,ya,le(Se,20,this)),le(Se,23,this),st(this,ba,le(Se,24,this)),le(Se,27,this),this.accept=i,this.collisionDetector=a,this.collisionPriority=l,this.type=c}accepts(t){const{accept:n}=this;return n?t.type?Array.isArray(n)?n.includes(t.type):typeof n=="function"?n(t):t.type===n:!1:!0}get isDropTarget(){var t,n;return((n=(t=this.manager)==null?void 0:t.dragOperation.target)==null?void 0:n.id)===this.id}refreshShape(){}};Se=ys(fa),ma=new WeakMap,ga=new WeakMap,xa=new WeakMap,ya=new WeakMap,ba=new WeakMap,Ze(Se,4,"accept",qu,ln,ma),Ze(Se,4,"type",Bu,ln,ga),Ze(Se,4,"collisionDetector",Lu,ln,xa),Ze(Se,4,"collisionPriority",Ou,ln,ya),Ze(Se,4,"shape",Pu,ln,ba),Ze(Se,2,"isDropTarget",Au,ln),jr(Se,ln);var vs=class extends dt{constructor(e,t){super(e,t),this.manager=e,this.options=t}},bb=({dragOperation:e,droppable:t})=>{const n=e.position.current;if(!n)return null;const{id:s}=t;if(!t.shape)return null;if(t.shape.containsPoint(n)){const i=Xt.distance(t.shape.center,n);return{id:s,value:1/i,priority:Cr.High}}return null},vb=({dragOperation:e,droppable:t})=>{if(!t.shape)return null;const{shape:n}=e;if(n==null?void 0:n.current.intersectionArea(t.shape)){const{position:i}=e,l=1/Xt.distance(t.shape.center,i.current);return{id:t.id,value:l,priority:Cr.Normal}}return null},Vu=e=>{var t;return(t=bb(e))!=null?t:vb(e)},_b=e=>{var t;const{dragOperation:n,droppable:s}=e,{shape:i,position:a}=n;if(!s.shape)return null;const c=1/Xt.distance(s.shape.center,(t=i==null?void 0:i.current.center)!=null?t:a.current);return{id:s.id,value:c,priority:Cr.Low}};function Nu(e){const{width:t,height:n,top:s,left:i,bottom:a,right:l}=e.getBoundingClientRect();return{width:t,height:n,top:s,left:i,bottom:a,right:l}}var jb=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function va(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function $u(e){return"nodeType"in e}function Rn(e){var t,n;return e?va(e)?e:$u(e)&&(n=(t=e.ownerDocument)==null?void 0:t.defaultView)!=null?n:window:window}function Fu(e){const{Document:t}=Rn(e);return e instanceof t}function Gu(e){return va(e)?!1:e instanceof Rn(e).HTMLElement}function Tr(e){return e?va(e)?e.document:$u(e)?Fu(e)?e:Gu(e)?e.ownerDocument:document:document:document}function wb(e){const{documentElement:t}=Tr(e),n=t.clientWidth,s=t.clientHeight;return{top:0,left:0,right:n,bottom:s,width:n,height:s}}function Cb(e){const t="input, textarea, select, canvas, [contenteditable]",n=e.cloneNode(!0),s=Array.from(e.querySelectorAll(t));return Array.from(n.querySelectorAll(t)).forEach((a,l)=>{const c=s[l];if(Wu(a)&&Wu(c)&&(a.type!=="file"&&(a.value=c.value),a.type==="radio"&&a.name&&(a.name=`Cloned__${a.name}`)),a instanceof HTMLCanvasElement&&c instanceof HTMLCanvasElement&&c.width>0&&c.height>0){const u=a.getContext("2d");u==null||u.drawImage(c,0,0)}}),n}function Wu(e){return"value"in e}function Qn(e){return"style"in e&&e.style instanceof Rn(e).CSSStyleDeclaration}function Sb(e,t=!1,n){const s=Cb(e);if(Qn(s)&&(t||s.style.setProperty("opacity","0")),s.setAttribute("inert","true"),s.setAttribute("tab-index","-1"),s.setAttribute("aria-hidden","true"),n)for(const[i,a]of Object.entries(n))s.setAttribute(i,a);return s}var Ru=class{constructor(){this.entries=new Set,this.clear=()=>{for(const e of this.entries){const[t,{type:n,listener:s,options:i}]=e;t.removeEventListener(n,s,i)}this.entries.clear()}}bind(e,t){const n=Array.isArray(t)?t:[t],s=[];for(const i of n){const{type:a,listener:l,options:c}=i,u=[e,i];e.addEventListener(a,l,c),this.entries.add(u),s.push(u)}return function(){for(const[a,{type:l,listener:c,options:u}]of s)a.removeEventListener(l,c,u)}}};function _a(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function ja(e){_a(e)&&e.isConnected&&e.hasAttribute("popover")&&e.showPopover()}function Qu(e){return!jb||!e?!1:e===Tr(e).scrollingElement}function Uu(e){const t=Qu(e)?wb(e):Nu(e),n=Qu(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},s={current:{x:e.scrollLeft,y:e.scrollTop},max:{x:e.scrollWidth-n.width,y:e.scrollHeight-n.height}},i=s.current.y<=0,a=s.current.x<=0,l=s.current.y>=s.max.y,c=s.current.x>=s.max.x;return{rect:t,position:s,isTop:i,isLeft:a,isBottom:l,isRight:c}}function kb(e,t){const{isTop:n,isBottom:s,isLeft:i,isRight:a,position:l}=Uu(e),{x:c,y:u}=t??{x:0,y:0},d=!n&&l.current.y+u>0,p=!s&&l.current.y+u<l.max.y,h=!i&&l.current.x+c>0,f=!a&&l.current.x+c<l.max.x;return{top:d,bottom:p,left:h,right:f,x:h||f,y:d||p}}function Tb(e){return e instanceof Rn(e).SVGElement}function cn(e){return Rn(e).getComputedStyle(e)}function Db(e,t=cn(e)){return t.position==="fixed"||t.position==="sticky"}function Mb(e,t=cn(e)){const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].find(i=>{const a=t[i];return typeof a=="string"?n.test(a):!1})!=null}var zb={excludeElement:!0};function _s(e,t=zb){const{limit:n,excludeElement:s}=t,i=new Set;function a(l){if(n!=null&&i.size>=n||!l)return i;if(Fu(l)&&l.scrollingElement!=null&&!i.has(l.scrollingElement))return i.add(l.scrollingElement),i;if(!Gu(l))return Tb(l)?a(l.parentElement):i;if(i.has(l))return i;const c=cn(l);if(s&&l===e||Mb(l,c)&&i.add(l),Db(l,c)){const{scrollingElement:u}=l.ownerDocument;return u&&i.add(u),i}return a(l.parentNode)}return e?a(e):i}function Ib(e){const[t]=_s(e,{limit:1});return t??null}var pt=(e=>(e[e.Idle=0]="Idle",e[e.Forward=1]="Forward",e[e.Reverse=-1]="Reverse",e))(pt||{}),Eb={x:.2,y:.2},Ab={x:10,y:10};function Pb(e,t,n,s=25,i=Eb,a=Ab){const{rect:l,isTop:c,isBottom:u,isLeft:d,isRight:p}=Uu(e),h={x:0,y:0},f={x:0,y:0},g={height:l.height*i.y,width:l.width*i.x};return!c&&t.y<=l.top+g.height&&(n==null?void 0:n.y)!==1&&t.x>=l.left-a.x&&t.x<=l.right+a.x?(h.y=-1,f.y=s*Math.abs((l.top+g.height-t.y)/g.height)):!u&&t.y>=l.bottom-g.height&&(n==null?void 0:n.y)!==-1&&t.x>=l.left-a.x&&t.x<=l.right+a.x&&(h.y=1,f.y=s*Math.abs((l.bottom-g.height-t.y)/g.height)),!p&&t.x>=l.right-g.width&&(n==null?void 0:n.x)!==-1&&t.y>=l.top-a.y&&t.y<=l.bottom+a.y?(h.x=1,f.x=s*Math.abs((l.right-g.width-t.x)/g.width)):!d&&t.x<=l.left+g.width&&(n==null?void 0:n.x)!==1&&t.y>=l.top-a.y&&t.y<=l.bottom+a.y&&(h.x=-1,f.x=s*Math.abs((l.left+g.width-t.x)/g.width)),{direction:h,speed:f}}function Ob(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function Yu(e,t=!1){if(Ob(e)){e.scrollIntoViewIfNeeded(t);return}if(!(e instanceof HTMLElement))return e.scrollIntoView();var[n]=_s(e,{limit:1});if(!(n instanceof HTMLElement))return;const s=cn(n),i=parseInt(s.getPropertyValue("border-top-width")),a=parseInt(s.getPropertyValue("border-left-width")),l=e.offsetTop-n.offsetTop<n.scrollTop,c=e.offsetTop-n.offsetTop+e.clientHeight-i>n.scrollTop+n.clientHeight,u=e.offsetLeft-n.offsetLeft<n.scrollLeft,d=e.offsetLeft-n.offsetLeft+e.clientWidth-a>n.scrollLeft+n.clientWidth,p=l&&!c;(l||c)&&t&&(n.scrollTop=e.offsetTop-n.offsetTop-n.clientHeight/2-i+e.clientHeight/2),(u||d)&&t&&(n.scrollLeft=e.offsetLeft-n.offsetLeft-n.clientWidth/2-a+e.clientWidth/2),(l||c||u||d)&&!t&&e.scrollIntoView(p)}var Lb=class{constructor(){this.tasks=new Set,this.flush=()=>{const e=this.tasks;this.animationFrame=void 0,this.tasks=new Set;for(const t of e)t()}}schedule(e){this.tasks.add(e),this.animationFrame||(this.animationFrame=requestAnimationFrame(this.flush))}},Un=new Lb;function Bb(e,t,n){const{scaleX:s,scaleY:i,x:a,y:l}=t,c=e.left-a-(1-s)*parseFloat(n),u=e.top-l-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),d=s?e.width/s:e.width,p=i?e.height/i:e.height;return{width:d,height:p,top:u,right:c+d,bottom:u+p,left:c}}var Ku=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(Qn(n))for(const[s,i]of Object.entries(e)){const a=`${t}${s}`;this.initial.has(a)||this.initial.set(a,n.style.getPropertyValue(a)),n.style.setProperty(a,typeof i=="string"?i:`${i}px`)}}remove(e,t=""){const{element:n}=this;if(Qn(n))for(const s of e){const i=`${t}${s}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(Qn(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function Xu({element:e,keyframes:t,options:n,onReady:s,onFinish:i}){const a=new Ku(e),{transitionProperty:l}=cn(e),c=l.split(", ");a.set({"transition-property":c.length?c.filter(u=>!u.includes("transform")&&!u.includes("translate")).join(", "):"none"}),s==null||s(),e.animate(t,n).finished.then(()=>{i==null||i(),a.reset()})}function Ju(e){const t=e.getAnimations();if(t.length>0){const[n]=t,{effect:s}=n,i=s instanceof KeyframeEffect?s.getKeyframes():[];if(i.length>0)return i==null?void 0:i[i.length-1]}return null}function js(e){if(e==="none")return null;const[t,n,s="0"]=e.split(" "),i={x:parseFloat(t),y:parseFloat(n),z:parseInt(s,10)};return isNaN(i.x)&&isNaN(i.y)?null:{x:isNaN(i.x)?0:i.x,y:isNaN(i.y)?0:i.y,z:isNaN(i.z)?0:i.z}}function qb(e){const t=Ju(e);if(t){const{translate:s=""}=t;if(typeof s=="string"){const i=js(s);if(i)return i}}const{translate:n}=cn(e);if(n){const s=js(n);if(s)return s}return{x:0,y:0,z:0}}function Vb(e){if(e==="none")return null;const t=e.split(" "),n=parseFloat(t[0]),s=parseFloat(t[1]);return isNaN(n)&&isNaN(s)?null:{x:isNaN(n)?s:n,y:isNaN(s)?n:s}}function Zu(e){var t,n,s,i,a,l,c,u,d;const{scale:p,transform:h,translate:f}=e,g=Vb(p),y=js(f),j=Nb(h);if(!j&&!g&&!y)return null;const k={x:(t=g==null?void 0:g.x)!=null?t:1,y:(n=g==null?void 0:g.y)!=null?n:1},S={x:(s=y==null?void 0:y.x)!=null?s:0,y:(i=y==null?void 0:y.y)!=null?i:0},T={x:(a=j==null?void 0:j.x)!=null?a:0,y:(l=j==null?void 0:j.y)!=null?l:0,scaleX:(c=j==null?void 0:j.scaleX)!=null?c:1,scaleY:(u=j==null?void 0:j.scaleY)!=null?u:1};return{x:S.x+T.x,y:S.y+T.y,z:(d=y==null?void 0:y.z)!=null?d:0,scaleX:k.x*T.scaleX,scaleY:k.y*T.scaleY}}function Nb(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}var qt=class extends ob{constructor(e,t=!1){var n,s;let{top:i,left:a,right:l,bottom:c,width:u,height:d}=Nu(e);const p=cn(e),h=Zu(p),f={x:(n=h==null?void 0:h.scaleX)!=null?n:1,y:(s=h==null?void 0:h.scaleY)!=null?s:1},g=$b(e);if(h&&(t||g)){const y=Bb({top:i,left:a,right:l,bottom:c,width:u,height:d},h,p.transformOrigin);i=y.top,a=y.left,u=y.width,d=y.height}g&&!t&&(i=i+g.y,a=a+g.x,u=u*g.scaleX,d=d*g.scaleY,f.x=g.scaleX,f.y=g.scaleY),super(a,i,u,d),this.scale=f}};function $b(e){const t=Ju(e);if(t){const{transform:n="",translate:s="",scale:i=""}=t;if(n||s||i)return Zu({transform:typeof n=="string"?n:"",translate:typeof s=="string"?s:"",scale:typeof i=="string"?i:""})}return null}function ws(e){return e instanceof KeyboardEvent}var Fb=Object.create,Hu=Object.defineProperty,Gb=Object.defineProperties,Wb=Object.getOwnPropertyDescriptor,Rb=Object.getOwnPropertyDescriptors,Cs=Object.getOwnPropertySymbols,ed=Object.prototype.hasOwnProperty,td=Object.prototype.propertyIsEnumerable,nd=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Dr=e=>{throw TypeError(e)},wa=(e,t,n)=>t in e?Hu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rd=(e,t)=>{for(var n in t||(t={}))ed.call(t,n)&&wa(e,n,t[n]);if(Cs)for(var n of Cs(t))td.call(t,n)&&wa(e,n,t[n]);return e},Qb=(e,t)=>Gb(e,Rb(t)),sd=(e,t)=>{var n={};for(var s in e)ed.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Cs)for(var s of Cs(e))t.indexOf(s)<0&&td.call(e,s)&&(n[s]=e[s]);return n},Ss=e=>{var t;return[,,,Fb((t=e==null?void 0:e[nd("metadata")])!=null?t:null)]},id=["class","method","getter","setter","accessor","field","value","get","set"],Mr=e=>e!==void 0&&typeof e!="function"?Dr("Function expected"):e,Ub=(e,t,n,s,i)=>({kind:id[e],name:t,metadata:s,addInitializer:a=>n._?Dr("Already initialized"):i.push(Mr(a||null))}),ks=(e,t)=>wa(t,nd("metadata"),e[3]),qe=(e,t,n,s)=>{for(var i=0,a=e[t>>1],l=a&&a.length;i<l;i++)t&1?a[i].call(n):s=a[i].call(n,s);return s},un=(e,t,n,s,i,a)=>{for(var l,c,u,d,p,h=t&7,f=!!(t&8),g=!!(t&16),y=e.length+1,j=id[h+5],k=e[y-1]=[],S=e[y]||(e[y]=[]),T=(i=i.prototype,Wb({get[n](){return Vt(this,a)},set[n](I){return Yn(this,a,I)}},n)),z=s.length-1;z>=0;z--)d=Ub(h,n,u={},e[3],S),d.static=f,d.private=g,p=d.access={has:I=>n in I},p.get=I=>I[n],p.set=(I,E)=>I[n]=E,c=(0,s[z])({get:T.get,set:T.set},d),u._=1,c===void 0?Mr(c)&&(T[j]=c):typeof c!="object"||c===null?Dr("Object expected"):(Mr(l=c.get)&&(T.get=l),Mr(l=c.set)&&(T.set=l),Mr(l=c.init)&&k.unshift(l));return T&&Hu(i,n,T),i},ad=(e,t,n)=>t.has(e)||Dr("Cannot "+n),Vt=(e,t,n)=>(ad(e,t,"read from private field"),t.get(e)),ht=(e,t,n)=>t.has(e)?Dr("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Yn=(e,t,n,s)=>(ad(e,t,"write to private field"),t.set(e,n),n),od={role:"button",roleDescription:"draggable",tabIndex:0},Yb="dnd-kit-description",Kb="dnd-kit-announcement",Xb={draggable:"To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item in a given direction. Press space again to drop the item in its new position, or press escape to cancel."},Jb={dragstart({operation:{source:e}}){if(e)return`Picked up draggable item ${e.id}.`},dragover({operation:{source:e,target:t}}){if(e)return t?`Draggable item ${e.id} was moved over droppable target ${t.id}.`:`Draggable item ${e.id} is no longer over a droppable target.`},dragend({operation:{source:e,target:t},canceled:n}){if(e)return n?`Dragging was cancelled. Draggable item ${e.id} was dropped.`:t?`Draggable item ${e.id} was dropped over droppable target ${t.id}`:`Draggable item ${e.id} was dropped.`}};function Zb(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLAnchorElement||e instanceof HTMLButtonElement||e instanceof HTMLAreaElement}var Ca={};function ld(e){const t=Ca[e]==null?0:Ca[e]+1;return Ca[e]=t,`${e}-${t}`}function Hb(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.innerText=t,n}function ev(e){const t=document.createElement("div");return t.id=e,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),t.style.setProperty("position","fixed"),t.style.setProperty("width","1px"),t.style.setProperty("height","1px"),t.style.setProperty("margin","-1px"),t.style.setProperty("border","0"),t.style.setProperty("padding","0"),t.style.setProperty("overflow","hidden"),t.style.setProperty("clip","rect(0 0 0 0)"),t.style.setProperty("clip-path","inset(100%)"),t.style.setProperty("white-space","nowrap"),t}var tv=class extends dt{constructor(e,t){super(e);const{id:n,idPrefix:{description:s=Yb,announcement:i=Kb}={},announcements:a=Jb,screenReaderInstructions:l=Xb}=t??{},c=n?`${s}-${n}`:ld(s),u=n?`${i}-${n}`:ld(i);let d,p;const h=Object.entries(a).map(([y,j])=>this.manager.monitor.addEventListener(y,(k,S)=>{const T=j==null?void 0:j(k,S);T&&p&&(p.innerText=T)})),f=()=>{d=Hb(c,l.draggable),p=ev(u),document.body.append(d,p)},g=Jy(()=>{for(const y of e.registry.draggables.value){const{element:j,handle:k}=y,S=k??j;S&&((!d||!p)&&f(),!Zb(S)&&!S.hasAttribute("tabindex")&&S.setAttribute("tabindex","0"),!S.hasAttribute("role")&&!(S instanceof HTMLButtonElement)&&S.setAttribute("role",od.role),S.hasAttribute("role-description")||S.setAttribute("aria-roledescription",od.roleDescription),S.hasAttribute("aria-describedby")||S.setAttribute("aria-describedby",c),S.setAttribute("aria-pressed",String(y.isDragSource)),S.setAttribute("aria-disabled",String(y.disabled)))}this.destroy=()=>{d==null||d.remove(),p==null||p.remove(),h.forEach(y=>y()),g()}})}},nv=class extends dt{constructor(e,t){super(e,t),this.manager=e,this.destroy=Xe(()=>{var n;const{dragOperation:s}=this.manager,{cursor:i="grabbing"}=(n=this.options)!=null?n:{};if(s.status.initialized){const a=document.createElement("style");return a.innerText=`* { cursor: ${i} !important; }`,document.head.appendChild(a),()=>{a.remove()}}})}},cd="data-dnd-",Ve="--dnd-",dn=`${cd}dragging`,rv=`[${dn}] {position: fixed !important; pointer-events: none !important; touch-action: none !important; z-index: calc(infinity); will-change: transform;top: var(${Ve}top, 0px) !important;left: var(${Ve}left, 0px) !important;width: var(${Ve}width, auto) !important;height: var(${Ve}height, auto) !important;}[${dn}] *{pointer-events: none !important;}[${dn}][style*="${Ve}translate"] {translate: var(${Ve}translate) !important;}[style*="${Ve}transition"] {transition: var(${Ve}transition) !important;}*:where([${dn}][popover]){overflow:visible;background:var(${Ve}background);border:var(${Ve}border);margin:unset;padding:unset;color:inherit;}[${dn}]::backdrop {display: none}`,ud=`${cd}placeholder`,sv=[dn,ud,"popover"],iv=["view-transition-name"],av=class extends dt{constructor(e){super(e);let t,n,s={x:0,y:0},i,a,l=!1;const c=Xe(()=>{if(!t&&e.dragOperation.status.initialized)return t=document.createElement("style"),t.innerText=rv,document.head.prepend(t),c}),u=Xe(()=>{var d;const{dragOperation:p}=e,{position:h,source:f,status:g}=p;if(g.idle){n=void 0,i=void 0,a=void 0,s={x:0,y:0};return}if(!f)return;const{element:y,feedback:j}=f;if(!y||j==="none")return;const k=new qt(y,!0),{width:S,height:T,top:z,left:I}=k,E=new Ku(y),{background:N,border:R,transition:pe,translate:ie}=cn(y),Ie=e.registry.droppables.get(f.id),xe=j==="clone",se=j!=="move"?Sb(y,xe,{[ud]:""}):null,Fe=Nn(()=>ws(e.dragOperation.activatorEvent));if(ie!=="none"){const ae=js(ie);ae&&(s=ae)}if(n||(n={x:I,y:z}),!a){const ae=Nn(()=>h.current);a={x:(ae.x-I)/S,y:(ae.y-z)/T}}const gt={x:n.x-I,y:n.y-z},xt={top:z+gt.y,left:I+gt.x};y.setAttribute(dn,"true"),E.set({width:S,height:T,top:xt.top,left:xt.left,background:N,border:R,translate:i?`${i.x}px ${i.y}px 0`:""},Ve),se&&y.insertAdjacentElement("afterend",se),_a(y)&&(y.hasAttribute("popover")||y.setAttribute("popover",""),ja(y));const Kr=new qt(y,!0),zt={top:xt.top-Kr.top,left:xt.left-Kr.left};zt.left>.01||zt.top>.01?E.set({top:xt.top+zt.top,left:xt.left+zt.left},Ve):(zt.left=0,zt.top=0);const Xr=new ResizeObserver(()=>{if(!se)return;const ae=new qt(se,!0),ue=a??{x:1,y:1},be=(S-ae.width)*ue.x+gt.x,ot=(T-ae.height)*ue.y+gt.y;if(E.set({width:ae.width,height:ae.height,top:z+ot+zt.top,left:I+be+zt.left},Ve),y instanceof HTMLTableRowElement&&se instanceof HTMLTableRowElement){const Wt=Array.from(y.cells),bn=Array.from(se.cells);for(const[It,Rt]of Wt.entries()){const Et=bn[It];Rt.style.width=`${Et.offsetWidth}px`}}e.dragOperation.shape=new qt(y)});Ie&&se&&(Ie.placeholder=se,Nn(Ie.refreshShape)),p.shape=new qt(y),f.status="dragging";let An,Pn;se&&(Xr.observe(se),An=new MutationObserver(()=>{for(const ae of Array.from(y.attributes))if(!(ae.name.startsWith("aria-")||sv.includes(ae.name))){if(ae.name==="style"){if(Qn(y)&&Qn(se)){se.setAttribute("style",xe?"":"opacity: 0;"),se.style.setProperty("transition","none");for(const ue of Object.values(y.style))ue.startsWith(Ve)||iv.includes(ue)||se.style.setProperty(ue,y.style.getPropertyValue(ue))}continue}se.setAttribute(ae.name,ae.value)}xe&&(se.innerHTML=y.innerHTML)}),An.observe(y,{attributes:!0,subtree:!0}),Pn=new MutationObserver(ae=>{for(const ue of ae)if(Array.from(ue.addedNodes).includes(y)){y.insertAdjacentElement("afterend",se),ja(y);return}}),Pn.observe(y.ownerDocument.body,{childList:!0,subtree:!0}));const mi=Xe(function(){var ue,be;const{transform:ot,status:Wt}=p;if(!(!ot.x&&!ot.y&&!l)&&(l||(l=!0),Wt.dragging)){const bn=Fe?"250ms ease":"0ms linear",It=ot.x+s.x,Rt=ot.y+s.y,Et=new qt(y);E.set({transition:`${pe}, translate ${bn}`,translate:`${It}px ${Rt}px 0`},Ve),p.shape=Et.translate(It-((ue=i==null?void 0:i.x)!=null?ue:0),Rt-((be=i==null?void 0:i.y)!=null?be:0)),i={x:It,y:Rt,z:0,scaleX:Et.scale.x,scaleY:Et.scale.y}}}),Jr=(d=e.dragOperation.source)==null?void 0:d.id,gi=()=>{var ae;if(!Fe||Jr==null)return;const ue=e.registry.draggables.get(Jr),be=(ae=ue==null?void 0:ue.handle)!=null?ae:ue==null?void 0:ue.element;be instanceof HTMLElement&&be.focus()};let ar=()=>{An==null||An.disconnect(),Pn==null||Pn.disconnect(),Xr.disconnect(),E.reset(),l&&y.isConnected&&(se==null||se.replaceWith(y)),se==null||se.remove(),y.removeAttribute(dn),_a(y)&&y.removeAttribute("popover"),mi(),Bl(),Ie&&(Ie.placeholder=void 0),f.status="idle",l=!1};const Bl=Xe(function(){if(p.status.dropped){const ue=ar;ar=void 0,f.status="dropping";const be=i;if(!be){ue==null||ue();return}e.renderer.rendering.then(()=>{var ot;ja(y);const Wt=se??y;E.remove(["translate"],Ve);const bn=new qt(Wt),It=new qt(y,!0).translate(be.x,be.y),Rt={x:It.center.x-bn.center.x,y:It.center.y-bn.center.y},Et={x:be.x-Rt.x,y:be.y-Rt.y,z:0};Xu({element:y,keyframes:{translate:[`${be.x}px ${be.y}px ${(ot=be.z)!=null?ot:0}`,`${Et.x}px ${Et.y}px ${Et.z}`]},options:{duration:l?250:0,easing:"ease"},onFinish(){requestAnimationFrame(gi),ue==null||ue()}})})}});return()=>ar==null?void 0:ar()});this.destroy=()=>{c(),u(),t==null||t.remove()}}},zr=!0,ov=!1,dd,pd,hd,fd,pn,Sa,ka;fd=(hd=[de],pt.Forward),pd=(dd=[de],pt.Reverse);var Ir=class{constructor(){ht(this,Sa,qe(pn,8,this,zr)),qe(pn,11,this),ht(this,ka,qe(pn,12,this,zr)),qe(pn,15,this)}isLocked(e){return e===pt.Idle?!1:e==null?this[pt.Forward]===zr&&this[pt.Reverse]===zr:this[e]===zr}unlock(e){e!==pt.Idle&&(this[e]=ov)}};pn=Ss(null),Sa=new WeakMap,ka=new WeakMap,un(pn,4,fd,hd,Ir,Sa),un(pn,4,pd,dd,Ir,ka),ks(pn,Ir);var lv=[pt.Forward,pt.Reverse],md=class{constructor(){this.x=new Ir,this.y=new Ir}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},cv=class extends dt{constructor(e){super(e);const t=ms(new md);let n=null;this.signal=t,Xe(()=>{const{status:s}=e.dragOperation;if(!s.initialized){n=null,t.value=new md;return}const{delta:i}=e.dragOperation.position;if(n){const a={x:gd(i.x,n.x),y:gd(i.y,n.y)},l=t.peek();Kt(()=>{for(const c of xu)for(const u of lv)a[c]===u&&l[c].unlock(u);t.value=l})}n=i})}get current(){return this.signal.peek()}};function gd(e,t){return Math.sign(e-t)}var xd,Ta,Er,Da,hn,Ma,Ts=class extends(Ta=yb,xd=[de],Ta){constructor(e){super(e),ht(this,Da,qe(Er,8,this,!1)),qe(Er,11,this),ht(this,hn),ht(this,Ma,()=>{if(!Vt(this,hn))return;const{element:a,by:l}=Vt(this,hn);a.scrollBy(l.x,l.y)}),this.scroll=a=>{var l;if(this.disabled)return!1;const c=this.getScrollableElements();if(!c)return Yn(this,hn,void 0),!1;const{position:u}=this.manager.dragOperation,d=u==null?void 0:u.current;if(d){const{by:p}=a??{},h=p?{x:yd(p.x),y:yd(p.y)}:void 0,f=h?void 0:this.scrollIntentTracker.current;if(f!=null&&f.isLocked())return!1;for(const g of c){const y=kb(g,p);if(y.x||y.y){const{speed:j,direction:k}=Pb(g,d,h);if(f)for(const S of xu)f[S].isLocked(k[S])&&(j[S]=0,k[S]=0);if(k.x||k.y){const{x:S,y:T}=p??k,z=S*j.x,I=T*j.y;if(z||I){const E=(l=Vt(this,hn))==null?void 0:l.by;if(this.autoScrolling&&E&&(E.x&&!z||E.y&&!I))continue;return Yn(this,hn,{element:g,by:{x:z,y:I}}),Un.schedule(Vt(this,Ma)),!0}}}}}return Yn(this,hn,void 0),!1};let t=null,n=null;const s=gs(()=>{var a;const{position:l}=e.dragOperation;if(!l)return null;const{x:c,y:u}=l.current,d=document.elementFromPoint(c,u);return d&&(t=d),(a=document.elementFromPoint(c,u))!=null?a:t}),i=gs(()=>{const a=s.value;if(!a||a===document.documentElement){const{target:l}=e.dragOperation,c=l==null?void 0:l.element;if(c){const u=_s(c,{excludeElement:!1});return n=u,u}}if(a){const l=_s(a,{excludeElement:!1});return this.autoScrolling&&n&&l.size<(n==null?void 0:n.size)?n:(n=l,l)}return n=null,null},Yi);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new cv(e),this.destroy=e.monitor.addEventListener("dragmove",a=>{this.disabled||a.defaultPrevented||!ws(e.dragOperation.activatorEvent)||!a.by||this.scroll({by:a.by})&&a.preventDefault()})}};Er=Ss(Ta),Da=new WeakMap,hn=new WeakMap,Ma=new WeakMap,un(Er,4,"autoScrolling",xd,Ts,Da),ks(Er,Ts);function yd(e){return e>0?pt.Forward:e<0?pt.Reverse:pt.Idle}var uv=10,bd=class extends dt{constructor(e,t){super(e);const n=e.registry.plugins.get(Ts);if(!n)throw new Error("AutoScroller plugin depends on Scroller plugin");this.destroy=Xe(()=>{if(this.disabled)return;const{position:s,status:i}=e.dragOperation;if(i.dragging)if(n.scroll()){n.autoScrolling=!0;const l=setInterval(n.scroll,uv);return()=>{clearInterval(l)}}else n.autoScrolling=!1})}},dv=class extends dt{constructor(e){super(e),this.manager=e,this.destroy=Xe(()=>{const{dragOperation:t}=this.manager;if(t.status.initialized){const n=document.createElement("style");return n.innerText="* { user-select: none !important;, -webkit-user-select: none !important; }",document.head.appendChild(n),document.addEventListener("selectionchange",vd,{capture:!0}),()=>{document.removeEventListener("selectionchange",vd,{capture:!0}),n.remove()}}})}};function vd(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var _d={start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},Ds=10,Ar,pv=class extends vs{constructor(e,t){super(e),this.manager=e,this.options=t,ht(this,Ar,[]),this.listeners=new Ru,this.handleSourceKeyDown=(n,s,i)=>{if(this.disabled||n.defaultPrevented||!(n.target instanceof Element)||s.disabled||!s.element)return;const{keyboardCodes:a=_d}=i??{};a.start.includes(n.code)&&this.manager.dragOperation.status.idle&&this.handleStart(n,s,i)}}bind(e,t=this.options){return Xe(()=>{var s;const i=(s=e.handle)!=null?s:e.element,a=l=>{l instanceof KeyboardEvent&&this.handleSourceKeyDown(l,e,t)};if(i)return i.addEventListener("keydown",a),()=>{i.removeEventListener("keydown",a)}})}handleStart(e,t,n){const{element:s}=t;if(!s)throw new Error("Source draggable does not have an associated element");e.preventDefault(),e.stopImmediatePropagation(),Yu(s);const{center:i}=new qt(s);Kt(()=>{this.manager.actions.setDragSource(t.id),this.manager.actions.start({event:e,coordinates:{x:i.x,y:i.y}})}),this.sideEffects();const a=Tr(s),l=Rn(a),c=[this.listeners.bind(a,[{type:"keydown",listener:u=>this.handleKeyDown(u,t,n),options:{capture:!0}}]),this.listeners.bind(l,[{type:"resize",listener:()=>this.handleEnd(!0)}])];Vt(this,Ar).push(...c)}handleKeyDown(e,t,n){const{keyboardCodes:s=_d}=n??{};if(Kn(e,[...s.end,...s.cancel])){e.preventDefault();const i=Kn(e,s.cancel);this.handleEnd(i);return}Kn(e,s.up)?this.handleMove("up",e):Kn(e,s.down)&&this.handleMove("down",e),Kn(e,s.left)?this.handleMove("left",e):Kn(e,s.right)&&this.handleMove("right",e)}handleEnd(e){this.manager.actions.stop({canceled:e}),this.cleanup()}handleMove(e,t){const{shape:n}=this.manager.dragOperation,s=t.shiftKey?5:1;let i={x:0,y:0};if(n){switch(e){case"up":i={x:0,y:-Ds*s};break;case"down":i={x:0,y:Ds*s};break;case"left":i={x:-Ds*s,y:0};break;case"right":i={x:Ds*s,y:0};break}(i!=null&&i.x||i!=null&&i.y)&&(t.preventDefault(),this.manager.actions.move({by:i}))}}sideEffects(){const e=this.manager.registry.plugins.get(bd);(e==null?void 0:e.disabled)===!1&&(e.disable(),Vt(this,Ar).push(()=>{e.enable()}))}cleanup(){Vt(this,Ar).forEach(e=>e())}destroy(){this.cleanup(),this.listeners.clear()}};Ar=new WeakMap;function Kn(e,t){return t.includes(e.code)}var Xn,za=class extends vs{constructor(t,n){super(t),this.manager=t,this.options=n,this.listeners=new Ru,this.cleanup=new Set,ht(this,Xn),this.handleCancel=this.handleCancel.bind(this),this.handlePointerUp=this.handlePointerUp.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this)}bind(t,n=this.options){return Xe(()=>{var i;const a=(i=t.handle)!=null?i:t.element,l=c=>{c instanceof PointerEvent&&this.handlePointerDown(c,t,n)};if(a)return mv(a.ownerDocument.defaultView),a.addEventListener("pointerdown",l),()=>{a.removeEventListener("pointerdown",l)}})}handlePointerDown(t,n,s={}){if(this.disabled||!t.isPrimary||t.button!==0||!(t.target instanceof Element)||n.disabled)return;const{target:i}=t,a=i instanceof HTMLElement&&i.draggable&&i.getAttribute("draggable")==="true";this.initialCoordinates={x:t.clientX,y:t.clientY};const{activationConstraints:l}=s,c=typeof l=="function"?l(t,n):l;if(t.stopImmediatePropagation(),!(c!=null&&c.delay)&&!(c!=null&&c.distance))this.handleStart(n,t);else{const{delay:h}=c;if(h){const f=setTimeout(()=>this.handleStart(n,t),h.value);Yn(this,Xn,()=>{clearTimeout(f),Yn(this,Xn,void 0)})}}const u=Tr(t.target),d=this.listeners.bind(u,[{type:"pointermove",listener:h=>this.handlePointerMove(h,n,s)},{type:"pointerup",listener:this.handlePointerUp,options:{capture:!0}},{type:"touchmove",listener:Ia,options:{passive:!1}},{type:"click",listener:Ia},{type:"dragstart",listener:a?this.handleCancel:Ia},{type:"keydown",listener:this.handleKeyDown}]),p=()=>{var h;setTimeout(d),(h=Vt(this,Xn))==null||h.call(this),this.initialCoordinates=void 0,this.cleanup.delete(p)};this.cleanup.add(p)}handlePointerMove(t,n,s){const i={x:t.clientX,y:t.clientY};if(this.manager.dragOperation.status.dragging){t.preventDefault(),t.stopPropagation(),this.manager.actions.move({to:i});return}if(!this.initialCoordinates)return;const a={x:i.x-this.initialCoordinates.x,y:i.y-this.initialCoordinates.y},{activationConstraints:l}=s,c=typeof l=="function"?l(t,n):l,{distance:u,delay:d}=c??{};if(u){if(u.tolerance!=null&&na(a,u.tolerance))return this.handleCancel();if(na(a,u.value))return this.handleStart(n,t)}if(d&&na(a,d.tolerance))return this.handleCancel()}handlePointerUp(t){t.preventDefault(),t.stopPropagation();const{status:n}=this.manager.dragOperation;if(!n.idle){const s=!n.initialized;this.manager.actions.stop({canceled:s})}this.cleanup.forEach(s=>s())}handleKeyDown(t){t.key==="Escape"&&(t.preventDefault(),this.handleCancel())}handleStart(t,n){var s;const{manager:i,initialCoordinates:a}=this;(s=Vt(this,Xn))==null||s.call(this),!(!a||i.dragOperation.status.initialized)&&(n.defaultPrevented||(n.preventDefault(),Kt(()=>{i.actions.setDragSource(t.id),i.actions.start({coordinates:a,event:n})})))}handleCancel(){const{dragOperation:t}=this.manager;t.status.initialized&&this.manager.actions.stop({canceled:!0}),this.cleanup.forEach(n=>n())}destroy(){this.listeners.clear()}};Xn=new WeakMap,za.configure=xb(za);var hv=za;function Ia(e){e.preventDefault()}function fv(){}var jd=new WeakSet;function mv(e){!e||jd.has(e)||(e.addEventListener("touchmove",fv,{capture:!1,passive:!1}),jd.add(e))}hv.configure({activationConstraints(e,t){var n;const{pointerType:s,target:i}=e;if(!(s==="mouse"&&i instanceof Element&&(t.handle===i||(n=t.handle)!=null&&n.contains(i))))return{delay:{value:200,tolerance:10},distance:{value:5}}}});var wd,Cd,Sd,Ea,Tt,Aa,Pa,Oa,Pr=class extends(Ea=kr,Sd=[de],Cd=[de],wd=[de],Ea){constructor(e,t){var n=e,{element:s,effects:i=()=>[],handle:a,feedback:l="default"}=n,c=sd(n,["element","effects","handle","feedback"]);super(rd({effects:()=>[...i(),()=>{var u,d;const{manager:p}=this;if(!p)return;const f=((d=(u=this.sensors)==null?void 0:u.map(Cu))!=null?d:[...p.sensors]).map(g=>{const y=g instanceof vs?g:p.registry.register(g.plugin),j=g instanceof vs?void 0:g.options;return y.bind(this,j)});return function(){f.forEach(y=>y())}}]},c),t),ht(this,Aa,qe(Tt,8,this)),qe(Tt,11,this),ht(this,Pa,qe(Tt,12,this)),qe(Tt,15,this),ht(this,Oa,qe(Tt,16,this)),qe(Tt,19,this),this.element=s,this.handle=a,this.feedback=l}};Tt=Ss(Ea),Aa=new WeakMap,Pa=new WeakMap,Oa=new WeakMap,un(Tt,4,"handle",Sd,Pr,Aa),un(Tt,4,"element",Cd,Pr,Pa),un(Tt,4,"feedback",wd,Pr,Oa),ks(Tt,Pr);var kd,Td,La,fn,Ba,qa,Ms=class extends(La=ln,Td=[de],kd=[de],La){constructor(e,t){var n=e,{element:s,effects:i=()=>[]}=n,a=sd(n,["element","effects"]),l;const{collisionDetector:c=Vu}=a;super(Qb(rd({},a),{collisionDetector:c,effects:()=>[...i(),()=>{const{element:u,manager:d}=this;if(!d)return;const{dragOperation:p}=d;if(u&&p.status.initialized){const h=Ib(u),f=Tr(u),g=h===f.scrollingElement?f:h,y=new IntersectionObserver(S=>{const[T]=S.slice(-1),{width:z,height:I}=T.boundingClientRect;!z&&!I||(this.visible=T.isIntersecting)},{root:g??f,rootMargin:"40%"}),j=new MutationObserver(()=>Un.schedule(this.refreshShape)),k=new ResizeObserver(()=>Un.schedule(this.refreshShape));return u.parentElement&&j.observe(u.parentElement,{childList:!0}),k.observe(u),y.observe(u),()=>{this.shape=void 0,this.visible=void 0,k.disconnect(),j.disconnect(),y.disconnect()}}},()=>{const{manager:u}=this;if(!u)return;const{dragOperation:d}=u,{status:p}=d,h=Nn(()=>d.source);if(p.initialized){if((h==null?void 0:h.type)!=null&&!this.accepts(h))return;Un.schedule(this.refreshShape)}},()=>{var u;if((u=this.manager)!=null&&u.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),ht(this,Ba,qe(fn,8,this)),qe(fn,11,this),ht(this,qa,qe(fn,12,this)),qe(fn,15,this),this.internal={element:ms(s)},this.refreshShape=this.refreshShape.bind(this),(l=this.manager)!=null&&l.dragOperation.status.initialized&&(this.visible=!0)}set element(e){this.internal.element.value=e}get element(){var e,t;return(t=this.placeholder)!=null?t:(e=this.internal)==null?void 0:e.element.value}refreshShape(e){const{element:t,shape:n}=this;if(!t||this.visible===!1){this.shape=void 0;return}const s=new qt(t,e);return s&&(n!=null&&n.equals(s))?n:(this.shape=s,s)}};fn=Ss(La),Ba=new WeakMap,qa=new WeakMap,un(fn,4,"visible",Td,Ms,Ba),un(fn,4,"placeholder",kd,Ms,qa),ks(fn,Ms);var gv=Object.create,Dd=Object.defineProperty,xv=Object.defineProperties,yv=Object.getOwnPropertyDescriptor,bv=Object.getOwnPropertyDescriptors,zs=Object.getOwnPropertySymbols,Md=Object.prototype.hasOwnProperty,zd=Object.prototype.propertyIsEnumerable,vv=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Or=e=>{throw TypeError(e)},Va=(e,t,n)=>t in e?Dd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,_v=(e,t)=>{for(var n in t||(t={}))Md.call(t,n)&&Va(e,n,t[n]);if(zs)for(var n of zs(t))zd.call(t,n)&&Va(e,n,t[n]);return e},jv=(e,t)=>xv(e,bv(t)),wv=(e,t)=>{var n={};for(var s in e)Md.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&zs)for(var s of zs(e))t.indexOf(s)<0&&zd.call(e,s)&&(n[s]=e[s]);return n},Cv=e=>{var t;return[,,,gv((t=void 0)!=null?t:null)]},Id=["class","method","getter","setter","accessor","field","value","get","set"],Lr=e=>e!==void 0&&typeof e!="function"?Or("Function expected"):e,Sv=(e,t,n,s,i)=>({kind:Id[e],name:t,metadata:s,addInitializer:a=>n._?Or("Already initialized"):i.push(Lr(a||null))}),kv=(e,t)=>Va(t,vv("metadata"),e[3]),Is=(e,t,n,s)=>{for(var i=0,a=e[t>>1],l=a&&a.length;i<l;i++)t&1?a[i].call(n):s=a[i].call(n,s);return s},Ed=(e,t,n,s,i,a)=>{for(var l,c,u,d,p,h=t&7,f=!!(t&8),g=!!(t&16),y=e.length+1,j=Id[h+5],k=e[y-1]=[],S=e[y]||(e[y]=[]),T=(i=i.prototype,yv({get[n](){return Tv(this,a)},set[n](I){return Dv(this,a,I)}},n)),z=s.length-1;z>=0;z--)d=Sv(h,n,u={},e[3],S),d.static=f,d.private=g,p=d.access={has:I=>n in I},p.get=I=>I[n],p.set=(I,E)=>I[n]=E,c=(0,s[z])({get:T.get,set:T.set},d),u._=1,c===void 0?Lr(c)&&(T[j]=c):typeof c!="object"||c===null?Or("Object expected"):(Lr(l=c.get)&&(T.get=l),Lr(l=c.set)&&(T.set=l),Lr(l=c.init)&&k.unshift(l));return T&&Dd(i,n,T),i},Ad=(e,t,n)=>t.has(e)||Or("Cannot "+n),Tv=(e,t,n)=>(Ad(e,t,"read from private field"),t.get(e)),Pd=(e,t,n)=>t.has(e)?Or("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),Dv=(e,t,n,s)=>(Ad(e,t,"write to private field"),t.set(e,n),n);function Jn(e){return e instanceof Fa||e instanceof Vd}var Es=10,Mv=class extends dt{constructor(e){super(e);const t=Xe(()=>{const{dragOperation:s}=e;if(ws(s.activatorEvent)&&Jn(s.source)&&s.status.initialized){const i=e.registry.plugins.get(Ts);if(i)return i.disable(),()=>i.enable()}}),n=e.monitor.addEventListener("dragmove",(s,i)=>{queueMicrotask(()=>{if(this.disabled||s.defaultPrevented)return;const{dragOperation:a}=i;if(!ws(a.activatorEvent)||!Jn(a.source)||!a.shape)return;const{actions:l,collisionObserver:c,registry:u}=i,{by:d}=s;if(!d)return;const p=zv(d),{source:h}=a,{center:f}=a.shape.current,g=[];for(const S of u.droppables){const{shape:T,id:z}=S;if(!(!T||z===(h==null?void 0:h.id)&&Jn(S)||(h==null?void 0:h.type)!=null&&!S.accepts(h)))switch(p){case"down":f.y+Es<T.center.y&&g.push(S);break;case"up":f.y-Es>T.center.y&&g.push(S);break;case"left":f.x-Es>T.center.x&&g.push(S);break;case"right":f.x+Es<T.center.x&&g.push(S);break}}s.preventDefault(),c.disable();const y=c.computeCollisions(g,_b),[j]=y;if(!j)return;const{id:k}=j;l.setDropTarget(k).then(()=>{const{source:S}=a;if(!S)return;const T=u.droppables.get(S.id);if(!(T!=null&&T.element))return;const{element:z}=T;Yu(z),Un.schedule(()=>{const I=T.refreshShape();I&&(l.move({to:{x:I.center.x,y:I.center.y}}),l.setDropTarget(S.id).then(()=>{a.shape=I,c.enable()}))})})})});this.destroy=()=>{n(),t()}}};function zv(e){const{x:t,y:n}=e;if(t>0)return"right";if(t<0)return"left";if(n>0)return"down";if(n<0)return"up"}function Iv(e,t,n){if(t===n)return e;const s=e.slice();return s.splice(n,0,s.splice(t,1)[0]),s}var Ev=class extends dt{constructor(e){super(e);const t=s=>{var i;const a=new Map;for(const l of e.registry.droppables)if(l instanceof Fa){const{sortable:c}=l;if(c.group!==s)continue;if(a.has(c.index))throw new Error(`Duplicate sortable index found for same sortable group: ${c.droppable.id} and ${(i=a.get(c.index))==null?void 0:i.droppable.id} have the same index (${c.index}). Make sure each sortable item has a unique index. Use the \`group\` attribute to separate sortables into different groups.`);a.set(c.index,c)}return a},n=[e.monitor.addEventListener("dragover",(s,i)=>{queueMicrotask(()=>{if(this.disabled||s.defaultPrevented)return;const{dragOperation:a}=i,{source:l,target:c}=a;if(!Jn(l)||!Jn(c)||l.sortable===c.sortable||l.sortable.group!==c.sortable.group)return;const u=t(l.sortable.group);i.renderer.rendering.then(()=>{var d;for(const[k,S]of u.entries())if(S.index!==k)return;const p=Array.from(u.values()).sort((k,S)=>k.index-S.index),h=p.indexOf(l.sortable),f=p.indexOf(c.sortable),g=Iv(p,h,f),y=(d=l.sortable.droppable.internal.element.peek())!=null?d:l.sortable.droppable.placeholder,j=c.element;!j||!y||(Od(y,h,j,f),Kt(()=>{for(const[k,S]of g.entries())S.index=k}))})})}),e.monitor.addEventListener("dragend",(s,i)=>{if(!s.canceled)return;const{dragOperation:a}=i,{source:l}=a;Jn(l)&&l.sortable.initialIndex!==l.sortable.index&&queueMicrotask(()=>{const c=t(l.sortable.group);i.renderer.rendering.then(()=>{var u;for(const[f,g]of c.entries())if(g.index!==f)return;const d=Array.from(c.values()).sort((f,g)=>f.index-g.index),p=l.sortable.droppable.element,h=(u=d[l.sortable.initialIndex])==null?void 0:u.element;!h||!p||(Od(p,l.sortable.index,h,l.sortable.initialIndex),Kt(()=>{for(const f of d.values())f.index=f.initialIndex}))})})})];this.destroy=()=>{for(const s of n)s()}}};function Od(e,t,n,s){const i=s<t?"beforebegin":"afterend";n.insertAdjacentElement(i,e)}var Av=[Mv,Ev],Ld={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1},Bd,qd,mn,Na,$a;qd=[de],Bd=[de];var As=class{constructor(e,t){Pd(this,Na,Is(mn,8,this)),Is(mn,11,this),Pd(this,$a,Is(mn,12,this)),Is(mn,15,this);var n=e,{effects:s=()=>[],group:i,index:a,sensors:l,type:c,transition:u=Ld,plugins:d=Av}=n,p=wv(n,["effects","group","index","sensors","type","transition","plugins"]);this.droppable=new Fa(p,t,this),this.draggable=new Vd(jv(_v({},p),{effects:()=>[()=>{var h;return(h=this.manager)==null?void 0:h.monitor.addEventListener("dragstart",()=>{this.initialIndex=this.index,this.previousIndex=this.index})},()=>{const{index:h,previousIndex:f,manager:g}=this;h!==f&&(this.previousIndex=h,this.animate())},()=>{const{target:h}=this,{feedback:f,isDragSource:g}=this.draggable;f=="move"&&g&&(this.droppable.disabled=!h)},()=>{const{manager:h}=this;for(const f of d)h==null||h.registry.register(f)},...s()],type:c,sensors:l}),t,this),this.manager=t,this.index=a,this.previousIndex=a,this.initialIndex=a,this.group=i,this.type=c,this.transition=u,this.destroy=()=>{this.draggable.destroy(),this.droppable.destroy()}}animate(){Nn(()=>{const{manager:e,transition:t}=this,{shape:n}=this.droppable;if(!e)return;const{idle:s}=e.dragOperation.status;!n||!t||s&&!t.idle||Un.schedule(()=>{const{element:i}=this.droppable;if(!i)return;const a=this.refreshShape();if(!a)return;const l={x:n.boundingRectangle.left-a.boundingRectangle.left,y:n.boundingRectangle.top-a.boundingRectangle.top},{x:c,y:u,z:d}=qb(i);(l.x||l.y)&&Xu({element:i,keyframes:{translate:[`${c+l.x}px ${u+l.y}px ${d}`,`${c}px ${u}px ${d}`]},options:t,onFinish:()=>{s&&(this.droppable.shape=void 0)}})})})}get manager(){return this.draggable.manager}set manager(e){this.draggable.manager=e,this.droppable.manager=e}set element(e){this.draggable.element=e,this.droppable.element=e}get element(){var e;return(e=this.droppable.element)!=null?e:this.draggable.element}set target(e){this.droppable.element=e}get target(){return this.droppable.element}set source(e){this.draggable.element=e}get source(){return this.draggable.element}get disabled(){return this.draggable.disabled&&this.droppable.disabled}set feedback(e){this.draggable.feedback=e}set disabled(e){Kt(()=>{this.draggable.disabled=e,this.droppable.disabled=e})}set data(e){Kt(()=>{this.draggable.data=e,this.droppable.data=e})}set handle(e){this.draggable.handle=e}set id(e){Kt(()=>{this.draggable.id=e,this.droppable.id=e})}get id(){return this.droppable.id}set sensors(e){this.draggable.sensors=e}set collisionPriority(e){this.droppable.collisionPriority=e??Cr.Normal}set collisionDetector(e){this.droppable.collisionDetector=e??Vu}set type(e){this.draggable.type=e,this.droppable.type=e}get type(){return this.draggable.type}set accept(e){this.droppable.accept=e}get accept(){return this.droppable.accept}get isDropTarget(){return this.droppable.isDropTarget}get isDragSource(){return this.draggable.isDragSource}get status(){return this.draggable.status}refreshShape(e=!1){return this.droppable.refreshShape(e)}accepts(e){return this.droppable.accepts(e)}register(){var e,t;return(e=this.manager)==null||e.registry.register(this.draggable),(t=this.manager)==null||t.registry.register(this.droppable),()=>this.unregister()}unregister(){var e,t;(e=this.manager)==null||e.registry.unregister(this.draggable),(t=this.manager)==null||t.registry.unregister(this.droppable)}destroy(){this.draggable.destroy(),this.droppable.destroy()}};mn=Cv(),Na=new WeakMap,$a=new WeakMap,Ed(mn,4,"index",qd,As,Na),Ed(mn,4,"group",Bd,As,$a),kv(mn,As);var Vd=class extends Pr{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}},Fa=class extends Ms{constructor(e,t,n){super(e,t),this.sortable=n}refreshShape(e=!1){return super.refreshShape(e)}get index(){return this.sortable.index}};function Nd(e){const t=m.useRef();return t.current||(t.current=e()),t.current}var Pv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",$d=Pv?m.useLayoutEffect:m.useEffect;function Ov(e,t=!1){const n=Nd(()=>e instanceof Be?e:ms(e));let s=n.peek();const i=m.useState(s)[1];return $d(()=>Xe(()=>{s!==(s=n.value)&&(t?Sm.flushSync(()=>i(s)):i(s))}),[t]),n}function Ga(e,t=!1){return Ov(Nd(()=>gs(e)),t)}function Lv(e,t){e()}function Ne(e,t,n=m.useEffect,s=Object.is){const i=m.useRef(e);n(()=>{const a=i.current;s(e,a)||(i.current=e,t(e,a))},[t,e])}function Wa(e){var t;if(e!=null)return typeof e=="object"&&"current"in e?(t=e.current)!=null?t:void 0:e}var Bv=Object.defineProperty,qv=Object.defineProperties,Vv=Object.getOwnPropertyDescriptors,Fd=Object.getOwnPropertySymbols,Nv=Object.prototype.hasOwnProperty,$v=Object.prototype.propertyIsEnumerable,Gd=(e,t,n)=>t in e?Bv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Fv=(e,t)=>{for(var n in t||(t={}))Nv.call(t,n)&&Gd(e,n,t[n]);if(Fd)for(var n of Fd(t))$v.call(t,n)&&Gd(e,n,t[n]);return e},Gv=(e,t)=>qv(e,Vv(t));function Wd(e){const{accept:t,collisionDetector:n,collisionPriority:s,id:i,data:a,index:l,group:c,disabled:u,feedback:d,sensors:p,transition:h=Ld,type:f}=e,g=es.useDragDropManager(),y=Wa(e.handle),j=Wa(e.element),k=Wa(e.target),S=es.useInstance(E=>new As(Gv(Fv({},e),{handle:y,element:j,target:k,feedback:d}),E)),T=Ga(()=>S.isDropTarget),z=Ga(()=>S.isDragSource),I=Ga(()=>S.status);return Ne(i,()=>S.id=i),Ne(l,()=>S.index=l,$d),Ne(f,()=>S.type=f),Ne(c,()=>S.group=c),Ne(t,()=>S.accept=t,void 0,Yi),Ne(a,()=>a&&(S.data=a)),Ne(l,()=>{g!=null&&g.dragOperation.status.idle&&h&&S.refreshShape()},Lv),Ne(y,()=>S.handle=y),Ne(j,()=>S.element=j),Ne(k,()=>S.target=k),Ne(u,()=>S.disabled=u===!0),Ne(p,()=>S.sensors=p),Ne(n,()=>S.collisionDetector=n),Ne(s,()=>S.collisionPriority=s),Ne(d,()=>S.feedback=d??"default"),Ne(h,()=>S.transition=h),{get isDragSource(){return z.value},get isDropTarget(){return T.value},get status(){return I.value},handleRef:m.useCallback(E=>{S.handle=E??void 0},[S]),ref:m.useCallback(E=>{S.element=E??void 0},[S]),sourceRef:m.useCallback(E=>{S.source=E??void 0},[S]),targetRef:m.useCallback(E=>{S.target=E??void 0},[S])}}const Wv=({value:e,index:t,children:n})=>{const[s,{setTrue:i,setFalse:a}]=W.useBoolean(!1),{ref:l,handleRef:c}=Wd({id:e,index:t});return r.jsx(o.Tabs.Tab,{ref:l,value:e,icon:r.jsx(M.IconGripHorizontal,{size:14,color:s?"rgb(34, 139, 230)":"transparent"}),onMouseEnter:i,onMouseLeave:a,children:n})},Rv=({fieldArray:e,add:t,addButtonText:n,renderTabName:s,controlledFields:i})=>{const a=l=>{const{source:c,target:u}=l.operation,d=i.findIndex(h=>h.id===c.id),p=u.index;e.move(d,p)};return r.jsxs(o.Tabs.List,{children:[r.jsx(es.DragDropProvider,{onDragEnd:a,children:i.map((l,c)=>r.jsx(Wv,{value:l.id,index:c,children:s(l,c)},l.id))}),r.jsx(o.Tabs.Tab,{onClick:t,value:"add",children:r.jsx(o.Tooltip,{label:n,children:r.jsx(o.Center,{children:r.jsx(M.IconPlus,{size:18,color:"#228be6"})})})})]})},Qv={tab:{paddingTop:"4px",paddingBottom:"4px"},panel:{padding:"0px"}},fe=({control:e,watch:t,name:n,getItem:s,children:i,addButtonText:a,deleteButtonText:l,renderTabName:c,deleteDisalbed:u})=>{var I;const d=b.useFieldArray({control:e,name:n}),{fields:p,append:h,remove:f}=d,g=t(n),y=p.map((E,N)=>({...E,...g[N]})),j=((I=v.last(y))==null?void 0:I.id)??null,[k,S]=m.useState(j),T=E=>{E!=="add"&&S(E)};m.useEffect(()=>{S(E=>j===E?E:j)},[j]);const z=()=>{const E=s();d.append(E),S(E.id)};return r.jsxs(o.Tabs,{value:k,onTabChange:T,styles:Qv,children:[r.jsx(Rv,{fieldArray:d,add:z,addButtonText:a,renderTabName:c,controlledFields:y}),y.map((E,N)=>r.jsx(o.Tabs.Panel,{value:E.id,children:r.jsxs(o.Stack,{children:[i({field:E,index:N}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed"}),r.jsx(o.Button,{leftIcon:r.jsx(M.IconTrash,{size:16}),color:"red",variant:"light",onClick:()=>f(N),sx:{top:15,right:5},disabled:u==null?void 0:u({field:E,index:N,fields:y}),children:l})]})},E.id))]})},Ps=m.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),i=a=>l=>{t({...e,[a]:l})};return r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{variant:"dashed",label:s("chart.zooming.scroll.label"),labelPosition:"center"}),r.jsxs(o.Group,{children:[r.jsx(o.Box,{sx:{flexGrow:1},children:r.jsx(o.Switch,{label:s("chart.zooming.scroll.x_axis"),checked:e.x_axis_scroll,onChange:a=>i("x_axis_scroll")(a.currentTarget.checked)})}),r.jsx(o.Box,{sx:{flexGrow:1},children:r.jsx(o.Switch,{label:s("chart.zooming.scroll.y_axis"),checked:e.y_axis_scroll,onChange:a=>i("y_axis_scroll")(a.currentTarget.checked)})})]}),r.jsx(o.Divider,{variant:"dashed",label:s("chart.zooming.slider.label"),labelPosition:"center"}),r.jsxs(o.Group,{children:[r.jsx(o.Box,{sx:{flexGrow:1},children:r.jsx(o.Switch,{label:s("chart.zooming.slider.x_axis"),checked:e.x_axis_slider,onChange:a=>i("x_axis_slider")(a.currentTarget.checked)})}),r.jsx(o.Tooltip,{label:s("chart.zooming.slider.y_axis_disabled"),children:r.jsx(o.Box,{sx:{flexGrow:1},children:r.jsx(o.Switch,{label:s("chart.zooming.slider.y_axis"),disabled:!e.y_axis_slider,checked:e.y_axis_slider,onChange:a=>i("y_axis_slider")(a.currentTarget.checked)})})})]})]})}),gn=m.forwardRef(({label:e,value:t,onChange:n,sx:s={},disabled:i},a)=>{const{t:l,i18n:c}=_.useTranslation(),u=m.useMemo(()=>[{label:l("chart.orientation.horizontal"),value:"horizontal"},{label:l("chart.orientation.vertical"),value:"vertical"}],[c.language]);return r.jsx(o.Select,{ref:a,label:e??l("chart.orientation.label"),data:u,value:t,onChange:n,sx:s,disabled:i})}),Uv=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=t("legend"),i=(a,l)=>{const c={...s,orient:a};a==="horizontal"?(c.top="0",c.left="auto",c.right="10",c.bottom="auto"):(c.top="10",c.left="auto",c.right="0",c.bottom="auto"),l(c)};return r.jsxs(o.Stack,{children:[r.jsx(o.Group,{grow:!0,noWrap:!0,mt:20,children:r.jsx(b.Controller,{name:"legend.show",control:e,render:({field:a})=>r.jsx(o.Switch,{label:n("chart.legend.show_legend"),sx:{flex:1},checked:a.value,onChange:l=>a.onChange(l.currentTarget.checked)})})}),r.jsx(o.Group,{children:r.jsx(b.Controller,{name:"legend",control:e,render:({field:a})=>r.jsx(gn,{sx:{flex:1},value:a.value.orient,onChange:l=>{i(l,a.onChange)},disabled:!s.show})})})]})};function Yv({control:e,index:t,variableOptions:n}){const{t:s}=_.useTranslation();return r.jsxs(o.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:i})=>r.jsx(o.TextInput,{label:s("common.name"),placeholder:s("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...i})}),r.jsx(b.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:i})=>r.jsx(o.Select,{label:s("common.value"),required:!0,data:n,sx:{flex:1},...i})})]}),r.jsx(b.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:i})=>r.jsx(o.TextInput,{label:s("chart.content_template.label"),placeholder:s("chart.content_template.placeholder"),required:!0,sx:{flex:1},...i})})]})}function Kv({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>({name:"",template:"",variable_key:""}),a=m.useMemo(()=>n.map(c=>({label:c.name,value:c.name})),[n]),l=(c,u)=>{const d=c.name.trim();return d||u+1};return r.jsx(fe,{control:e,watch:t,name:"reference_lines",getItem:i,addButtonText:s("chart.reference_line.add"),deleteButtonText:s("chart.reference_line.delete"),renderTabName:l,children:({field:c,index:u})=>r.jsx(Yv,{control:e,index:u,variableOptions:a})})}const Xv=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("chart.data_field"),required:!0,sx:{flex:1},...s})})]})})},Jv=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),r.jsx(fe,{control:e,watch:t,name:"tooltip.metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(Xv,{control:e,index:l})})]})};function Zv({control:e,watch:t}){return r.jsx(o.Stack,{children:r.jsx(Jv,{control:e,watch:t})})}const Jt=m.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a}=_.useTranslation();return r.jsx(o.NumberInput,{ref:i,label:e??a("chart.rotate"),hideControls:!0,min:-90,max:90,rightSection:r.jsx(o.Text,{size:"xs",color:"dimmed",children:a("chart.degree")}),sx:s,styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},value:t,onChange:n})}),Hv=({control:e,watch:t})=>{const{t:n}=_.useTranslation();return t(["x_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.x_axis.x_axis_name"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"x_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("chart.x_axis.x_axis_data_field"),required:!0,sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:s})=>r.jsx(Jt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(St,{...s})})]}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(kt,{...s})})]})},Ra={root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}},e_=["123456789","1234","1234.56789","1.234","0.123456789","-0.123456789"];function t_({format:e}){const{t}=_.useTranslation(),[n,{toggle:s}]=he.useDisclosure(!1);return r.jsxs(o.Box,{children:[r.jsx(o.Button,{variant:"subtle",w:"100%",compact:!0,onClick:s,leftIcon:n?r.jsx(M.IconChevronUp,{size:14}):r.jsx(M.IconChevronDown,{size:14}),children:t(n?"numbro.format.preview.close":"numbro.format.preview.open")}),r.jsx(o.Collapse,{in:n,children:n&&r.jsxs(o.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:t("numbro.format.preview.input")}),r.jsx("th",{children:t("numbro.format.preview.output")})]})}),r.jsx("tbody",{children:e_.map(i=>r.jsxs("tr",{children:[r.jsx("td",{children:i}),r.jsx("td",{children:r.jsx(ze,{children:U(i,e)})})]},i))})]})})]})}function n_({value:e,onChange:t},n){const{t:s}=_.useTranslation(),i=d=>{t({...e,output:d})},a=d=>{const p=d===0?!1:e.trimMantissa;t({...e,mantissa:d,trimMantissa:p})},l=d=>{t({...e,trimMantissa:d.currentTarget.checked})},c=d=>{t({...e,average:d.currentTarget.checked})},u=d=>{const p={...e,absolute:d.currentTarget.checked};t(p)};return r.jsxs(o.Stack,{ref:n,children:[r.jsxs(o.Group,{grow:!0,children:[r.jsx(o.Select,{label:s("numbro.format.label"),data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:i,sx:{flexGrow:1}}),r.jsx(o.Switch,{label:r.jsxs(o.Stack,{spacing:0,children:[r.jsx(o.Text,{children:s("numbro.format.absolute")}),r.jsx(o.Text,{size:12,color:"gray",children:s("numbro.format.absolute_description")})]}),checked:e.absolute,onChange:u,sx:{flexGrow:1},styles:Ra}),r.jsx(o.Switch,{label:r.jsxs(o.Stack,{spacing:0,children:[r.jsx(o.Text,{children:s("numbro.format.abbreviation")}),r.jsx(o.Text,{size:12,color:"gray",children:s("numbro.format.abbreviation_description")})]}),checked:e.average,onChange:c,disabled:e.output!=="number",sx:{flexGrow:1},styles:Ra})]}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(o.NumberInput,{label:s("numbro.format.mantissa"),defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:a}),r.jsx(o.Switch,{label:r.jsxs(o.Stack,{spacing:0,children:[r.jsx(o.Text,{children:s("numbro.format.trim_mantissa")}),r.jsx(o.Text,{size:12,color:"gray",children:s("numbro.format.trim_mantissa_description")})]}),checked:e.trimMantissa,onChange:l,disabled:e.mantissa===0,styles:Ra}),r.jsx(o.Box,{})]}),r.jsx(t_,{format:e})]})}const ft=m.forwardRef(n_),r_=({control:e,watch:t})=>{const{t:n}=_.useTranslation();return t(["y_axis"]),r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"y_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.y_axis.y_axis_name"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"y_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("chart.y_axis.y_axis_data_field"),required:!0,sx:{flex:1},...s})})]}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mt:10,mb:-15,variant:"dashed",label:n("chart.axis.section_title.label_format"),labelPosition:"center"}),r.jsx(b.Controller,{name:"y_axis.label_formatter",control:e,render:({field:s})=>r.jsx(ft,{...s})})]})]})};function s_({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=m.useMemo(()=>v.defaults({},n,Ni),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]),u(["x_axis","y_axis","reference_lines","color","dataZoom"]);const h=d(),f=m.useMemo(()=>!v.isEqual(h,n),[h,n]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:c(s),children:[r.jsx(Ce,{canSubmit:f}),r.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Legend",children:t("chart.legend.label")}),r.jsx(o.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")}),r.jsx(o.Tabs.Tab,{value:"Style",children:t("chart.style.label")}),r.jsx(o.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")}),r.jsx(o.Tabs.Tab,{value:"Zooming",children:t("chart.zooming.label")})]}),r.jsx(o.Tabs.Panel,{value:"X Axis",children:r.jsx(Hv,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx(r_,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Legend",children:r.jsx(Uv,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(Zv,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Style",children:r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:t("chart.color.label")}),r.jsx(b.Controller,{name:"color",control:l,render:({field:g})=>r.jsx(Le,{...g})})]})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx(Kv,{variables:i,control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Zooming",children:r.jsx(b.Controller,{name:"dataZoom",control:l,render:({field:g})=>r.jsx(Ps,{...g})})})]})]})})}function i_(e){return v.omit(e,"variables")}function a_(e){const{label_formatter:t=Me,...n}=e.y_axis;return{...e,y_axis:{...n,label_formatter:t}}}function o_(e){const t={rotate:0,formatter:Oe()},{axisLabel:n=t,...s}=e.x_axis;return{...e,x_axis:{...s,axisLabel:n}}}function l_(e){const t={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return v.defaultsDeep(t,e)}function c_(e){delete e.config;const{x_axis:t,tooltip:n}=e.x_axis.axisLabel.overflow,s={x_axis:{axisLabel:{overflow:{on_axis:t,in_tooltip:n}}}};return v.defaultsDeep(s,e)}function u_(e){const t={tooltip:{metrics:[]}};return v.defaultsDeep(t,e)}function d_(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis:i,y_axis:a,tooltip:l,...c}=e;return{...c,x_axis:{...i,data_key:s(i.data_key)},y_axis:{...a,data_key:s(a.data_key)},tooltip:{...l,metrics:l.metrics.map(u=>({...u,data_key:s(u.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}function p_(e){const t={legend:{show:!0,top:"0",right:"10",left:"auto",bottom:"auto",orient:"horizontal",type:"scroll"}};return v.defaultsDeep(t,e)}function h_(e){const{dataZoom:t,...n}=e;return{...n,dataZoom:t??Vc()}}class f_ extends ge{constructor(){super(...arguments);B(this,"VERSION",9)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,{panelModel:s})=>{const{config:i}=n;return(i.variables||[]).forEach(l=>{s.variables.find(c=>c.name===l.name)||s.addVariable(l)}),{...n,version:2,config:i_(i)}}),this.version(3,n=>{const{config:s}=n;return{...n,version:3,config:a_(s)}}),this.version(4,n=>{const{config:s}=n;return{...n,version:4,config:o_(s)}}),this.version(5,n=>{const{config:s}=n;return{...n,version:5,config:l_(s)}}),this.version(6,n=>{const{config:s}=n;return{...n,version:6,config:c_(s)}}),this.version(7,n=>{const{config:s}=n;return{...n,version:7,config:u_(s)}}),this.version(8,(n,s)=>{const{config:i}=n;return{...n,version:8,config:d_(i,s)}}),this.version(9,n=>{const{config:s}=n;return{...n,version:9,config:p_(s)}}),this.version(10,n=>{const{config:s}=n;return{...n,version:10,config:h_(s)}})}}const m_={displayName:"viz.boxplot.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new f_,name:"boxplot",viewRender:qy,configRender:s_,createConfig(){return{version:10,config:v.cloneDeep(Ni)}},triggers:[Nc],translation:_x},Rd={id:"builtin:button:click-button",displayName:"viz.button.click.label",nameRender:x_,configRender:g_,payload:[]};function g_(e){return r.jsx(r.Fragment,{})}function x_(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.button.click.label")})}const Qa={content:"Button",variant:"filled",color:"blue",size:"xs",compact:!1,horizontal_align:"left",vertical_align:"center"},y_={left:"flex-start",center:"center",right:"flex-end"},b_={top:"flex-start",center:"center",bottom:"flex-end"},v_=D.observer(({context:e,instance:t})=>{const n=rt({vizManager:e.vizManager,instance:t}),s=nt(n.triggerManager,Rd.id),i=_e(),{value:a}=$(e.instanceData,"config"),l=m.useMemo(()=>v.defaultsDeep({},a,Qa),[a]),{content:c,horizontal_align:u,vertical_align:d,...p}=l,{width:h,height:f}=e.viewport,g=i.payloadForSQL,y=()=>{s.forEach(j=>{n.runInteraction(j.id,{})})};return r.jsx(o.Center,{sx:{width:h,height:f,justifyContent:y_[u],alignItems:b_[d]},children:r.jsx(o.Button,{...p,onClick:y,children:v.template(c)(g)})})}),__=({value:e,onChange:t,label:n})=>{const s=o.useMantineTheme(),i=m.useCallback(l=>()=>t(l),[t]),a=l=>e===l;return r.jsxs(o.Stack,{spacing:2,children:[r.jsx(o.Text,{size:14,sx:{fontWeight:500},children:n}),r.jsx(o.Group,{position:"left",spacing:"xs",children:Object.keys(s.colors).map(l=>{const c=s.colors[l][6];return r.jsx(o.ColorSwatch,{color:c,onClick:i(l),radius:4,size:26,sx:{cursor:"pointer"},children:a(l)&&r.jsx(o.CheckIcon,{width:10,color:"white"})},l)})})]})},Ua=m.forwardRef(({label:e,value:t,onChange:n,sx:s,disabled:i},a)=>{const{t:l}=_.useTranslation(),c=m.useMemo(()=>o.MANTINE_SIZES.map(u=>({label:l(`style.size.${u}`),value:u})),[]);return r.jsx(o.Select,{ref:a,data:c,label:e,value:t,onChange:n,sx:s,disabled:!0})}),j_=[{label:"Filled",value:"filled"},{label:"Outline",value:"outline"},{label:"Light",value:"light"},{label:"White",value:"white"},{label:"Default",value:"default"},{label:"Subtle",value:"subtle"},{label:"Gradient",value:"gradient",disabled:!0}];function w_({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=m.useMemo(()=>v.defaultsDeep({},t,Qa),[t]),i=s;m.useEffect(()=>{!v.isEqual(s,i)&&(console.log("config malformed, resetting to defaults",s,i),n(i))},[s,i]);const{control:a,handleSubmit:l,watch:c,getValues:u,reset:d}=b.useForm({defaultValues:i});m.useEffect(()=>{d(i)},[i]);const p=u(),h=m.useMemo(()=>!v.isEqual(p,s),[p,s]);return c(["content","variant","color","size","compact","horizontal_align","vertical_align"]),r.jsxs("form",{onSubmit:l(n),children:[r.jsx(Ce,{canSubmit:h}),r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{control:a,name:"content",render:({field:f})=>r.jsx(o.TextInput,{label:"Content Template",description:"Filter values & context entries are supported",...f,required:!0})}),r.jsx(o.Divider,{mt:"xs",mb:0,label:"Styles",labelPosition:"center",variant:"dashed"}),r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(b.Controller,{control:a,name:"variant",render:({field:f})=>r.jsx(o.Select,{label:"Variant",data:j_,...f})}),r.jsx(b.Controller,{control:a,name:"color",render:({field:f})=>r.jsx(__,{label:"Theme",...f})})]}),r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(b.Controller,{control:a,name:"size",render:({field:f})=>r.jsx(Ua,{label:"Size",...f})}),r.jsx(b.Controller,{control:a,name:"compact",render:({field:f})=>r.jsx(o.Checkbox,{label:"Compact",checked:f.value,onChange:g=>f.onChange(g.currentTarget.checked),mt:26})})]}),r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(b.Controller,{control:a,name:"horizontal_align",render:({field:f})=>r.jsx(ps,{...f})}),r.jsx(b.Controller,{control:a,name:"vertical_align",render:({field:f})=>r.jsx(Uc,{...f})})]})]})]})}const C_=[{lang:"en",resources:{button:{viz_name:"Button",click:{label:"Click this button"}}}},{lang:"zh",resources:{button:{viz_name:"按钮",click:{label:"点击此按钮"}}}}];class S_ extends ge{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{horizontal_align:s="left",vertical_align:i="center",...a}=n.config;return{...n,version:2,config:{...a,horizontal_align:s,vertical_align:i}}})}}const k_={displayName:"viz.button.viz_name",displayGroup:"chart.groups.others",migrator:new S_,name:"button",viewRender:v_,configRender:w_,createConfig(){return{version:2,config:v.cloneDeep(Qa)}},triggers:[Rd],translation:C_},Ya={id:"builtin:echarts:click-echart:series",displayName:"viz.cartesian_chart.click_series.label",nameRender:D_,configRender:T_,payload:[{name:"seriesType",description:"'line' | 'scatter' | 'bar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function T_(e){return r.jsx(r.Fragment,{})}function D_(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.cartesian_chart.click_series.label")})}const Ka={regressions:[],series:[],stats:{templates:{bottom:"",top:""}},x_axis:{type:"category",axisLabel:{rotate:0,formatter:Oe(),overflow:Ke()}},tooltip:{metrics:[]},x_axis_data_key:"",x_axis_name:"",y_axes:[{min:"",max:"",name:"Y Axis",show:!0,position:"left",nameAlignment:"center",label_formatter:Me}],reference_lines:[],reference_areas:[],dataZoom:jn};function M_(e){const t=e.y_axes.some(i=>!!i.name);let n=15;t&&(n+=20),e.dataZoom.x_axis_slider&&(n+=20);let s=5;return e.x_axis_name&&(s+=15),e.series.some(i=>!i.hide_in_legend)&&(s+=20),{top:n,right:15,bottom:s,left:20,containLabel:!0}}function z_(e){return e!=="line"?{}:{itemStyle:{opacity:0}}}function I_(e){switch(e){case"line":return;case"bar":return"roundRect";case"scatter":return"circle"}}function E_(e){const t={show:!0,bottom:0,left:"center",type:"scroll"};return t.data=e.filter(n=>!n.hide_in_legend).map(({name:n,type:s})=>({name:n,icon:I_(s),...z_(s)})),t}function Os(e,t){switch(e.config.method){case"linear":return[...an.regressionLinear()(t)];case"exponential":return[...an.regressionExp()(t)];case"logistic":return[...an.regressionLog()(t)];case"polynomial":return[...an.regressionPoly().order(e.config.order)(t)];default:return[]}}function A_(e,t,n,s){const{transform:i,plot:a}=e,l={...a,name:t,data:Os(i,s),showSymbol:!1,tooltip:{show:!1},smooth:!1,custom:{}};return n&&(l.custom={type:"regression-line",targetSeries:n}),l}function P_({regressions:e=[],x_axis_data_key:t},n){const s=[];if(Object.keys(n).length===0)return s;function i(a,l,c,u){const d=A_(a,l,c,u);s.push(d)}return e.forEach(a=>{const{name:l,group_by_key:c}=a;if(!c||c===t){const h=_t(n,a.y_axis_data_key).map((f,g)=>[g,Number(f)]);i(a,l,"",h);return}const{columnKey:u}=O(a.y_axis_data_key),d=v.groupBy(rs(n,a.y_axis_data_key),c);Object.entries(d).forEach(([p,h])=>{const f=h.map((y,j)=>[j,Number(y[u])]);i(a,p,p,f)})}),s}function O_(e,t){return e.map(n=>({name:"",type:"line",hide_in_legend:!0,data:[],markArea:{itemStyle:{color:n.color},data:[[{yAxis:t[n.y_keys.upper]},{yAxis:t[n.y_keys.lower]}]],silent:!0}}))}function L_(e,t,n,s){return t?s==="value"?[[n[0],e]]:[e]:[]}function B_(e,t,n,s,i,a){return e.map(l=>{const c=n[l.variable_key],u=l.orientation==="horizontal",d=u?"yAxis":"xAxis",p=u?"insideEndTop":"end",h=L_(c,u,i,a);return{name:l.name,type:"scatter",hide_in_legend:!l.show_in_legend,xAxisId:"main-x-axis",yAxisIndex:l.yAxisIndex,data:h,symbol:"none",silent:!0,tooltip:{show:!1},markLine:{data:[{name:l.name,[d]:c}],silent:!0,symbol:["none","none"],lineStyle:l.lineStyle,label:{formatter:function(){return l.template?mr(l.template,t,s):""},position:p}}}})}function Xa(e,t,n){const s=_t(e,t),i=_t(e,n);return v.zip(s,i)}function q_(e,t,n,s){const i=Xa(t,n,s);return v.unionBy(i,e,0)}function V_({dataTemplate:e,data:t,x_axis_data_key:n,y_axis_data_key:s,valueTypedXAxis:i}){return i?q_(e,t,n,s):_t(t,s)}function N_({dataTemplate:e,data:t,aggregation_on_value:n,x_axis_data_key:s,y_axis_data_key:i,valueTypedXAxis:a}){if(!n||n.type==="none")return V_({dataTemplate:e,data:t,x_axis_data_key:s,y_axis_data_key:i,valueTypedXAxis:a});const l=Xa(t,s,i),c=v.groupBy(l,"0");return e.map(([d])=>{const h=c[d].map(g=>g[1]),f=ki(h,n);return[d,f]})}function $_({group_by_key:e,data:t,x_axis_data_key:n,y_axis_data_key:s}){const{queryID:i,columnKey:a}=O(e),l=v.groupBy(t[i],a);return Object.entries(l).forEach(([c,u])=>{l[c]=Xa({[i]:u},n,s)}),l}function F_({type:e,...t},n,s,i){if(!e)return 10;if(e==="static"){const{size:d}=t;return d}const{func_content:a}=t,{queryID:l,columnKey:c}=O(s),u=v.keyBy(rs(n,l),c);return(d,p)=>{let h;p.name?h=u[p.name]:h=n[p.dataIndex];try{return new Function(`return ${a}`)()({rowData:h,params:p,variables:i},{lodash:v,interpolate:vn.interpolate})}catch(f){return console.error(`[getEchartsSymbolSize] failed parsing custom function, error: ${f.message}`),10}}}function G_({x_axis_data_key:e,x_axis:t},{y_axis_data_key:n,yAxisIndex:s,label_position:i,name:a,group_by_key:l,aggregation_on_value:c,stack:u,color:d,display_name_on_line:p,symbolSize:h,hide_in_legend:f,...g},y,j,k,S){const T=t.type!=="category",z={label:{show:!!i,position:i,formatter:S[s??"default"]},name:a,xAxisId:"main-x-axis",yAxisIndex:s,stack:u,color:d,symbolSize:F_(h,j,e,k),hide_in_legend:f,labelLayout:{hideOverlap:!0},...g};if(g.type==="line"&&(z.lineStyle={shadowColor:"rgba(255,255,255,1)",shadowBlur:0,shadowOffsetX:0,shadowOffsetY:3}),p&&(z.endLabel={show:!0,formatter:a,offset:[-12,12],align:"right"}),!l||l===e)return z.data=N_({dataTemplate:y,data:j,aggregation_on_value:c,x_axis_data_key:e,y_axis_data_key:n,valueTypedXAxis:T}),z;const I=$_({group_by_key:l,data:j,x_axis_data_key:e,y_axis_data_key:n});return Object.entries(I).map(([E,N])=>{const R=v.cloneDeep(z);return R.name=E,R.color=void 0,R.data=N,R})}function W_(e,t,n,s,i,a){const l=t.map(u=>[u,0]);return e.series.map(u=>G_(e,u,l,n,a,s)).flat().concat(B_(e.reference_lines,i,a,n,t,e.x_axis.type)).concat(O_(e.reference_areas,a))}function R_(e,t){const n=e.find(a=>a.axisDim==="x"&&a.axisId==="main-x-axis");if(!n)return"";const{axisValue:s,axisIndex:i}=n;return Ye(t.x_axis.axisLabel.formatter)(s,i)}const Q_=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function U_(e,t,n,s){const i=n.reduce((a,{yAxisIndex:l,name:c})=>(a[c]=l,a),{});return te.getTooltip({trigger:"axis",formatter:function(a){const l=Array.isArray(a)?a:[a];if(l.length===0)return"";const c=l.map(({seriesName:h,marker:f,value:g})=>{if(Array.isArray(g)&&g.length===2&&(g=g[1]),!h)return g;const y=i[h],j=s[y]??s.default;return`
109
109
  <tr>
110
- <td>${g}</td>
110
+ <td>${f}</td>
111
111
  <th style="text-align: right; padding: 0 1em;">${h}</th>
112
- <td style="text-align: left; padding: 0 1em;">${w({value:f})}</td>
112
+ <td style="text-align: left; padding: 0 1em;">${j({value:g})}</td>
113
113
  </tr>
114
- `}),u=t.tooltip.metrics.map(h=>{const g=Xe(e,h.data_key),f=b.uniq(l.map(({dataIndex:v})=>g[v]));return`<tr>
114
+ `}),u=e.tooltip.metrics.map(h=>{const f=_t(t,h.data_key),g=v.uniq(l.map(({dataIndex:y})=>f[y]));return`<tr>
115
115
  <td />
116
116
  <th style="text-align: right; padding: 0 1em;">${h.name}</th>
117
- ${f.map(v=>`<td style="text-align: left; padding: 0 1em;">${rx(v)}</td>`)}
118
- </tr>`});c.push(...u);const d=We(t.x_axis.axisLabel.overflow.in_tooltip),p=sx(l,t);return`
117
+ ${g.map(y=>`<td style="text-align: left; padding: 0 1em;">${Q_(y)}</td>`)}
118
+ </tr>`});c.push(...u);const d=ct(e.x_axis.axisLabel.overflow.in_tooltip),p=R_(l,e);return`
119
119
  <div style="text-align: left; margin-bottom: .5em; padding: 0 1em .5em; font-weight: bold; border-bottom: 1px dashed #ddd;">
120
120
  <div style="${d}">${p}</div>
121
121
  </div>
@@ -124,12 +124,14 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
124
124
  ${c.join("")}
125
125
  </tbody>
126
126
  </table>
127
- `}})}function ax(t){return t.y_axes.reduce((n,{label_formatter:r},i)=>(n[i]=function(l){let c=l;if(typeof l=="object"&&(Array.isArray(l.value)&&l.value.length===2?c=l.value[1]:c=l.value),!r)return c;try{return U(c,r)}catch(u){return console.error(u),c}},n),{default:({value:n})=>n})}function er(t,e){const n={};return e.map(r=>{const i=Ze(r,t);n[r.name]=Ie(r,i)}),n}function ox(t,e){const{overflow:n,...r}=t.x_axis.axisLabel,i=Qe(n.on_axis),o=e.length===0;return[te.getXAxis({data:e,name:t.x_axis_name??"",nameGap:o?5:void 0,id:"main-x-axis",type:t.x_axis.type,axisLabel:{...r,...i,formatter:Pe(r.formatter)}})]}function lx(t){var e;try{return Array.isArray(t[0])&&((e=t[0])==null?void 0:e.length)>=2?t.map(r=>Number(r[1])):[...t]}catch(n){return console.error(n),[...t]}}function cx(t){if(t.length===0)return{};const e={},n={};return t.forEach(r=>{const i=lx(r.data);if(!n[r.yAxisIndex]){n[r.yAxisIndex]=i;return}n[r.yAxisIndex]=n[r.yAxisIndex].concat(i)}),Object.entries(n).forEach(([r,i])=>{const o=b.minBy(i)??0,l=b.maxBy(i)??0;o==0&&l==0&&(e[r]=1)}),e}function ux(t,e,n){const r=cx(n);return t.y_axes.map(({nameAlignment:i,min:o,max:l,show:c,...u},d)=>{let p=u.position;return p||(p=d>0?"right":"left"),te.getYAxis({...u,minInterval:r[d]??0,show:c,min:o||void 0,max:l||void 0,position:p,axisLabel:{show:c,formatter:e[d]??e.default},nameTextStyle:{align:i},nameLocation:"end",nameGap:c?15:0,splitLine:{show:d===0}})})}const dx={xAxis:[{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"},splitLine:{show:!1},axisTick:{show:!0,alignWithLabel:!0}}]};function px(t,e,n){const r=er(e,n),i=ax(t),o=b.uniq(Xe(e,t.x_axis_data_key)),l=nx(t,o,e,i,n,r),c=Rm(t,e),u={xAxis:ox(t,o),yAxis:ux(t,i,l),series:[...l,...c],tooltip:ix(t,e,l,i),grid:Nm(t),legend:Wm(l),dataZoom:$n(t.dataZoom)};return b.defaultsDeep({},u,dx)}function Ja(t){const e=t.getModel(),n=e.getSeries().map(r=>{if(!r.option.custom)return r.option;const i=e.getColorFromPalette(r.option.custom.targetSeries,null);return r.option.color=i,r.option});t.setOption({...t.getOption(),series:n})}function Xa(t){return t.trim().length>0}function hx({conf:t,data:e,width:n,height:r,interactionManager:i,variables:o}){const l=It(e,t.x_axis_data_key),c=qe(i.triggerManager,Xs.id),u=m.useCallback(f=>{const v=b.get(l,f.name,{error:"rowData is not found"});c.forEach(w=>{i.runInteraction(w.id,{...f,rowData:v})})},[l,c,i]),d=m.useMemo(()=>px(t,e,o),[t,e]),p=m.useRef(),h=m.useMemo(()=>({click:u}),[u]),g=f=>{p.current=f,Ja(f)};return m.useEffect(()=>{p.current&&Ja(p.current)},[d]),!n||!r?null:s.jsx(Se,{echarts:Ce,option:d,style:{width:n,height:r},onEvents:h,onChartReady:g,notMerge:!0,theme:"merico-light"})}function mx({context:t,instance:e}){const n=Oe({vizManager:t.vizManager,instance:e}),{value:r}=q(t.instanceData,"config"),{variables:i}=t,o=m.useMemo(()=>b.defaults({},r,Zs),[r]),l=t.data,{width:c,height:u}=t.viewport,{ref:d,height:p}=ie.useElementSize(),{ref:h,height:g}=ie.useElementSize(),f=m.useMemo(()=>{const{stats:{templates:T}}=o;return{top:ln(T.top,i,l),bottom:ln(T.bottom,i,l)}},[o,l]),v=Math.max(0,et(u)-p-g),w=He(c);return s.jsxs(Ae,{width:c,height:u,children:[s.jsx(a.Text,{ref:d,align:"left",size:"xs",pl:"sm",sx:{display:Xa(o.stats.templates.top)?"block":"none"},children:Object.values(f.top).map((T,D)=>s.jsx(m.Fragment,{children:T},D))}),s.jsx(hx,{variables:i,width:w,height:v,data:l,conf:o,interactionManager:n}),s.jsx(a.Text,{ref:h,align:"left",size:"xs",pl:"sm",sx:{display:Xa(o.stats.templates.bottom)?"block":"none"},children:Object.values(f.bottom).map((T,D)=>s.jsx(m.Fragment,{children:T},D))})]})}function xx({control:t,index:e,variableOptions:n}){const{t:r,i18n:i}=_.useTranslation(),o=m.useMemo(()=>[{label:r("chart.reference_area.type.rectangle"),value:"rectangle"}],[i.language]),l=m.useMemo(()=>[{label:r("chart.reference_area.direction.horizontal"),value:"horizontal"}],[i.language]);return s.jsxs(a.Stack,{my:0,p:0,sx:{position:"relative"},children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`reference_areas.${e}.name`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:r("chart.reference_area.label"),required:!0,sx:{flex:1},...c})}),s.jsx(y.Controller,{name:`reference_areas.${e}.color`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:r("chart.color.label"),required:!0,sx:{flex:1},...c})})]}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`reference_areas.${e}.type`,control:t,render:({field:c})=>s.jsx(a.Select,{label:r("chart.reference_area.type.label"),required:!0,data:o,sx:{flex:1},...c})}),s.jsx(y.Controller,{name:`reference_areas.${e}.direction`,control:t,render:({field:c})=>s.jsx(a.Select,{label:r("chart.reference_area.direction.label"),required:!0,data:l,sx:{flex:1},...c})})]}),s.jsx(a.Divider,{variant:"dashed",label:r("data.label"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`reference_areas.${e}.y_keys.upper`,control:t,render:({field:c})=>s.jsx(a.Select,{label:r("chart.reference_area.boundary.upper"),required:!0,data:n,sx:{flex:1},...c})}),s.jsx(y.Controller,{name:`reference_areas.${e}.y_keys.lower`,control:t,render:({field:c})=>s.jsx(a.Select,{label:r("chart.reference_area.boundary.lower"),required:!0,data:n,sx:{flex:1},...c})})]})]})}function gx({control:t,watch:e,variables:n}){const{t:r}=_.useTranslation(),i=()=>({name:"",color:"rgba(0,0,0,0.1)",type:"rectangle",direction:"horizontal",y_keys:{upper:"",lower:""}}),o=(c,u)=>{const d=c.name.trim();return d||u+1},l=m.useMemo(()=>n.map(c=>({label:c.name,value:c.name})),[n]);return s.jsx(ae,{control:t,watch:e,name:"reference_areas",getItem:i,addButtonText:r("chart.reference_area.add"),deleteButtonText:r("chart.reference_area.delete"),renderTabName:o,children:({field:c,index:u})=>s.jsx(xx,{control:t,index:u,variableOptions:l})})}const Qt=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},i)=>{const{t:o,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:o("chart.series.line.type.solid"),value:"solid"},{label:o("chart.series.line.type.dashed"),value:"dashed"},{label:o("chart.series.line.type.dotted"),value:"dotted"}],[l.language]);return s.jsx(a.Select,{ref:i,label:t??o("chart.series.line.type.label"),data:c,value:e,onChange:n,sx:r})});function fx({control:t,index:e,watch:n,variableOptions:r,yAxisOptions:i}){const{t:o}=_.useTranslation(),l=n(`reference_lines.${e}.orientation`);return s.jsxs(a.Stack,{my:0,p:0,sx:{position:"relative"},children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`reference_lines.${e}.name`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:o("common.name"),placeholder:o("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),s.jsx(y.Controller,{name:`reference_lines.${e}.variable_key`,control:t,render:({field:c})=>s.jsx(a.Select,{label:o("common.data_field"),required:!0,data:r,sx:{flex:1},...c})})]}),s.jsx(y.Controller,{name:`reference_lines.${e}.template`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:o("chart.content_template.label"),placeholder:o("chart.content_template.hint"),sx:{flex:1},...c})}),s.jsxs(a.Group,{grow:!0,children:[s.jsxs(a.Stack,{children:[s.jsx(y.Controller,{name:`reference_lines.${e}.orientation`,control:t,render:({field:c})=>s.jsx(Ct,{label:o("chart.orientation.label"),sx:{flex:1},...c})}),l==="vertical"&&s.jsx(a.Text,{mt:-10,color:"dimmed",size:12,children:o("chart.reference_line.orientation.vertical_hint")})]}),l==="horizontal"&&s.jsx(y.Controller,{name:`reference_lines.${e}.yAxisIndex`,control:t,render:({field:{value:c,onChange:u,...d}})=>s.jsx(a.Select,{label:o("chart.y_axis.label"),data:i,disabled:i.length===0,...d,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){u(0);return}u(Number(p))},sx:{flex:1}})})]}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.style.label"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:`reference_lines.${e}.lineStyle.type`,control:t,render:({field:c})=>s.jsx(Qt,{sx:{flexGrow:1},...c})}),s.jsx(y.Controller,{name:`reference_lines.${e}.lineStyle.width`,control:t,render:({field:c})=>s.jsx(a.NumberInput,{label:o("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),s.jsxs(a.Stack,{spacing:4,children:[s.jsx(a.Text,{size:"sm",children:o("chart.color.label")}),s.jsx(y.Controller,{name:`reference_lines.${e}.lineStyle.color`,control:t,render:({field:c})=>s.jsx(Te,{...c})})]}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.behavior.label"),labelPosition:"center"}),s.jsx(y.Controller,{name:`reference_lines.${e}.show_in_legend`,control:t,render:({field:c})=>s.jsx(a.Checkbox,{label:o("chart.legend.show_in_legend"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})]})}function yx({control:t,watch:e,variables:n}){const{t:r}=_.useTranslation(),i=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,yAxisIndex:0}),o=(d,p)=>{const h=d.name.trim();return h||p+1},l=m.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),c=e("y_axes"),u=m.useMemo(()=>c.map(({name:d},p)=>({label:d,value:p.toString()})),[c]);return s.jsx(ae,{control:t,watch:e,name:"reference_lines",getItem:i,addButtonText:r("chart.reference_line.add"),deleteButtonText:r("chart.reference_line.delete"),renderTabName:o,children:({field:d,index:p})=>s.jsx(fx,{control:t,index:p,watch:e,variableOptions:l,yAxisOptions:u})})}function bx({control:t,regressionItem:e,index:n,yAxisOptions:r}){const{t:i,i18n:o}=_.useTranslation(),l=m.useMemo(()=>[{label:i("chart.regression_line.method.linear"),value:"linear"},{label:i("chart.regression_line.method.exponential"),value:"exponential"},{label:i("chart.regression_line.method.logistic"),value:"logistic"},{label:i("chart.regression_line.method.polynomial"),value:"polynomial"}],[o.language]),c=e.transform.config.method;return s.jsxs(a.Stack,{my:0,p:0,sx:{position:"relative"},children:[s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:`regressions.${n}.name`,control:t,render:({field:u})=>s.jsx(a.TextInput,{label:i("common.name"),required:!0,sx:{flex:1},...u})}),s.jsx(y.Controller,{name:`regressions.${n}.group_by_key`,control:t,render:({field:u})=>s.jsx(O,{label:i("chart.series.group_by.label_line"),clearable:!0,sx:{flex:1},...u})})]}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`regressions.${n}.y_axis_data_key`,control:t,render:({field:u})=>s.jsx(O,{label:i("common.data_field"),required:!0,sx:{flex:1},...u})}),s.jsx(y.Controller,{name:`regressions.${n}.plot.yAxisIndex`,control:t,render:({field:{value:u,onChange:d,...p}})=>s.jsx(a.Select,{label:i("chart.y_axis.label"),data:r,disabled:r.length===0,...p,value:(u==null?void 0:u.toString())??"",onChange:h=>{if(!h){d(0);return}d(Number(h))},sx:{flex:1}})})]}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`regressions.${n}.transform.config.method`,control:t,render:({field:u})=>s.jsx(a.Select,{label:i("chart.regression_line.method.label"),data:l,sx:{flex:1},...u})}),c==="polynomial"&&s.jsx(y.Controller,{name:`regressions.${n}.transform.config.order`,control:t,render:({field:u})=>s.jsx(a.NumberInput,{label:i("chart.regression_line.method.polynomial_order"),sx:{flex:1},...u})})]}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:i("chart.series.line.line_style"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:`regressions.${n}.plot.lineStyle.type`,control:t,render:({field:u})=>s.jsx(Qt,{sx:{flexGrow:1},...u})}),s.jsx(y.Controller,{name:`regressions.${n}.plot.lineStyle.width`,control:t,render:({field:u})=>s.jsx(a.NumberInput,{label:i("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...u})})]}),s.jsxs(a.Stack,{spacing:4,children:[s.jsx(a.Text,{size:"sm",children:"Color"}),s.jsx(y.Controller,{name:`regressions.${n}.plot.color`,control:t,render:({field:u})=>s.jsx(Te,{...u})})]})]})}function vx({control:t,watch:e}){const{t:n}=_.useTranslation(),r=e("y_axes"),i=m.useMemo(()=>r.map(({name:c},u)=>({label:c,value:u.toString()})),[r]),o=()=>({transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},group_by_key:"",name:"",y_axis_data_key:"",plot:{type:"line",yAxisIndex:0,color:"#666666",lineStyle:{type:"solid",width:1}}}),l=(c,u)=>{const d=c.name.trim();return d||u+1};return s.jsx(ae,{control:t,watch:e,name:"regressions",getItem:o,addButtonText:n("chart.regression_line.add"),deleteButtonText:n("chart.regression_line.delete"),renderTabName:l,children:({field:c,index:u})=>s.jsx(bx,{regressionItem:c,control:t,index:u,yAxisOptions:i})})}const _x=({value:t,onChange:e})=>{const n=r=>{r&&e(r)};return s.jsx(a.Box,{children:s.jsx(Le,{height:"500px",defaultLanguage:"javascript",value:t,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},tr={static:{type:"static",size:10},dynamic:{type:"dynamic",func_content:["function getSize({ rowData, params, variables }, { lodash, interpolate }) {"," // your code goes here"," // return 10","}"].join(`
128
- `)}},jx=({value:t,onChange:e})=>{const{t:n}=_.useTranslation(),[r,{setTrue:i,setFalse:o}]=W.useBoolean(),[l,c]=m.useState(t),u=()=>{o();const{type:g,func_content:f}=l,v={type:g,func_content:f};c(v),e(v)},d=()=>{o(),c(t)},p=g=>{c(f=>({...f,func_content:g}))},h=()=>{p(tr.dynamic.func_content)};return s.jsxs(s.Fragment,{children:[s.jsx(a.Box,{sx:{width:"50%"},children:s.jsx(a.Button,{color:"grape",variant:"filled",mt:24,onClick:i,sx:{flexGrow:0},leftIcon:s.jsx(k.IconMathFunction,{size:16}),children:n("chart.symbol_size.setup.label")})}),s.jsx(a.Modal,{size:800,title:n("chart.symbol_size.setup.title"),opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mt:10,mb:-10,label:n("chart.symbol_size.setup.description"),labelPosition:"center",variant:"dashed"}),s.jsx(_x,{value:l.func_content,onChange:p}),s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Button,{onClick:h,color:"red",leftIcon:s.jsx(L.Recycle,{size:20}),children:n("common.actions.reset_to_default")}),s.jsxs(a.Group,{position:"right",children:[s.jsx(a.Button,{onClick:d,variant:"subtle",children:n("common.actions.cancel")}),s.jsx(a.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),onClick:u,children:n("common.actions.save")})]})]})]})})]})},wx=({value:t,onChange:e})=>t.type!=="dynamic"?null:s.jsx(jx,{value:t,onChange:e}),Cx=({value:t,onChange:e})=>{if(t.type!=="static")return null;const n=r=>{e({...t,size:r})};return s.jsx(s.Fragment,{children:s.jsx(a.NumberInput,{defaultValue:18,placeholder:"1 ~ 100",label:" ",hideControls:!0,value:t.size,onChange:n})})},nr=m.forwardRef(({label:t,value:e,onChange:n},r)=>{const{t:i,i18n:o}=_.useTranslation(),l=m.useMemo(()=>[{label:i("chart.symbol_size.static"),value:"static"},{label:i("chart.symbol_size.dynamic"),value:"dynamic"}],[o.language]),c=u=>{n({...tr[u]})};return s.jsxs(a.SimpleGrid,{cols:2,children:[s.jsx(a.Select,{ref:r,label:t??i("chart.symbol_size.label"),data:l,value:e.type,onChange:c,sx:{flexGrow:1}}),s.jsx(Cx,{value:e,onChange:n}),s.jsx(wx,{value:e,onChange:n})]})}),sr={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:"0 !important"},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"},blockquote:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45",margin:"0 0 14px"}};function Za(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),o=e.child(r);if(i==o){n+=i.nodeSize;continue}if(!i.sameMarkup(o))return n;if(i.isText&&i.text!=o.text){for(let l=0;i.text[l]==o.text[l];l++)n++;return n}if(i.content.size||o.content.size){let l=Za(i.content,o.content,n+1);if(l!=null)return l}n+=i.nodeSize}}function Ha(t,e,n,r){for(let i=t.childCount,o=e.childCount;;){if(i==0||o==0)return i==o?null:{a:n,b:r};let l=t.child(--i),c=e.child(--o),u=l.nodeSize;if(l==c){n-=u,r-=u;continue}if(!l.sameMarkup(c))return{a:n,b:r};if(l.isText&&l.text!=c.text){let d=0,p=Math.min(l.text.length,c.text.length);for(;d<p&&l.text[l.text.length-d-1]==c.text[c.text.length-d-1];)d++,n--,r--;return{a:n,b:r}}if(l.content.size||c.content.size){let d=Ha(l.content,c.content,n-1,r-1);if(d)return d}n-=u,r-=u}}class H{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,o){for(let l=0,c=0;c<n;l++){let u=this.content[l],d=c+u.nodeSize;if(d>e&&r(u,i+c,o||null,l)!==!1&&u.content.size){let p=c+1;u.nodesBetween(Math.max(0,e-p),Math.min(u.content.size,n-p),r,i+p)}c=d}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let o="",l=!0;return this.nodesBetween(e,n,(c,u)=>{c.isText?(o+=c.text.slice(Math.max(e,u)-u,n-u),l=!r):c.isLeaf?(i?o+=typeof i=="function"?i(c):i:c.type.spec.leafText&&(o+=c.type.spec.leafText(c)),l=!r):!l&&c.isBlock&&(o+=r,l=!0)},0),o}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),o=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),o=1);o<e.content.length;o++)i.push(e.content[o]);return new H(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let o=0,l=0;l<n;o++){let c=this.content[o],u=l+c.nodeSize;u>e&&((l<e||u>n)&&(c.isText?c=c.cut(Math.max(0,e-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,e-l-1),Math.min(c.content.size,n-l-1))),r.push(c),i+=c.nodeSize),l=u}return new H(r,i)}cutByIndex(e,n){return e==n?H.empty:e==0&&n==this.content.length?this:new H(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),o=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new H(i,o)}addToStart(e){return new H([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new H(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return Za(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Ha(this,e,n,r)}findIndex(e,n=-1){if(e==0)return On(0,e);if(e==this.size)return On(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,i=0;;r++){let o=this.child(r),l=i+o.nodeSize;if(l>=e)return l==e||n>0?On(r+1,l):On(r,i);i=l}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return H.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new H(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return H.empty;let n,r=0;for(let i=0;i<e.length;i++){let o=e[i];r+=o.nodeSize,i&&o.isText&&e[i-1].sameMarkup(o)?(n||(n=e.slice(0,i)),n[n.length-1]=o.withText(n[n.length-1].text+o.text)):n&&n.push(o)}return new H(n||e,r)}static from(e){if(!e)return H.empty;if(e instanceof H)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new H([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}H.empty=new H([],0);const rr={index:0,offset:0};function On(t,e){return rr.index=t,rr.offset=e,rr}function ir(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!ir(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!ir(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}class Ve{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let o=e[i];if(this.eq(o))return e;if(this.type.excludes(o.type))n||(n=e.slice(0,i));else{if(o.type.excludes(this.type))return e;!r&&o.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(o)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&ir(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);return r.create(n.attrs)}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return Ve.none;if(e instanceof Ve)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}}Ve.none=[];class Sx extends Error{}class ne{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=to(this.content,e+this.openStart,n);return r&&new ne(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ne(eo(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ne.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ne(H.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let o=e.firstChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.firstChild)r++;for(let o=e.lastChild;o&&!o.isLeaf&&(n||!o.type.spec.isolating);o=o.lastChild)i++;return new ne(e,r,i)}}ne.empty=new ne(H.empty,0,0);function eo(t,e,n){let{index:r,offset:i}=t.findIndex(e),o=t.maybeChild(r),{index:l,offset:c}=t.findIndex(n);if(i==e||o.isText){if(c!=n&&!t.child(l).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=l)throw new RangeError("Removing non-flat range");return t.replaceChild(r,o.copy(eo(o.content,e-i-1,n-i-1)))}function to(t,e,n,r){let{index:i,offset:o}=t.findIndex(e),l=t.maybeChild(i);if(o==e||l.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=to(l.content,e-o-1,n);return c&&t.replaceChild(i,l.copy(c))}class Vn{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let i=e.nodes[r.node];return i.contentMatch.matchType(i)})}parse(e,n={}){let r=new io(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new io(this,n,!0);return r.addAll(e,n.from,n.to),ne.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let o=this.tags[i];if(Dx(e,o.tag)&&(o.namespace===void 0||e.namespaceURI==o.namespace)&&(!o.context||n.matchesContext(o.context))){if(o.getAttrs){let l=o.getAttrs(e);if(l===!1)continue;o.attrs=l||void 0}return o}}}matchStyle(e,n,r,i){for(let o=i?this.styles.indexOf(i)+1:0;o<this.styles.length;o++){let l=this.styles[o],c=l.style;if(!(c.indexOf(e)!=0||l.context&&!r.matchesContext(l.context)||c.length>e.length&&(c.charCodeAt(e.length)!=61||c.slice(e.length+1)!=n))){if(l.getAttrs){let u=l.getAttrs(n);if(u===!1)continue;l.attrs=u||void 0}return l}}}static schemaRules(e){let n=[];function r(i){let o=i.priority==null?50:i.priority,l=0;for(;l<n.length;l++){let c=n[l];if((c.priority==null?50:c.priority)<o)break}n.splice(l,0,i)}for(let i in e.marks){let o=e.marks[i].spec.parseDOM;o&&o.forEach(l=>{r(l=ao(l)),l.mark||l.ignore||l.clearMark||(l.mark=i)})}for(let i in e.nodes){let o=e.nodes[i].spec.parseDOM;o&&o.forEach(l=>{r(l=ao(l)),l.node||l.ignore||l.mark||(l.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Vn(e,Vn.schemaRules(e)))}}const no={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},kx={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},so={ol:!0,ul:!0},Nn=1,Gn=2,dn=4;function ro(t,e,n){return e!=null?(e?Nn:0)|(e==="full"?Gn:0):t&&t.whitespace=="pre"?Nn|Gn:n&~dn}class Fn{constructor(e,n,r,i,o,l,c){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=i,this.solid=o,this.options=c,this.content=[],this.activeMarks=Ve.none,this.stashMarks=[],this.match=l||(c&dn?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(H.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Nn)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let o=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=o.withText(o.text.slice(0,o.text.length-i[0].length))}}let n=H.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(H.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(e){for(let n=this.stashMarks.length-1;n>=0;n--)if(e.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(e){for(let n=0,r=this.pendingMarks;n<r.length;n++){let i=r[n];(this.type?this.type.allowsMarkType(i.type):Mx(i.type,e))&&!i.isInSet(this.activeMarks)&&(this.activeMarks=i.addToSet(this.activeMarks),this.pendingMarks=i.removeFromSet(this.pendingMarks))}}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!no.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class io{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0;let i=n.topNode,o,l=ro(null,n.preserveWhitespace,0)|(r?dn:0);i?o=new Fn(i.type,i.attrs,Ve.none,Ve.none,!0,n.topMatch||i.type.contentMatch,l):r?o=new Fn(null,null,Ve.none,Ve.none,!0,null,l):o=new Fn(e.schema.topNodeType,null,Ve.none,Ve.none,!0,null,l),this.nodes=[o],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e){if(e.nodeType==3)this.addTextNode(e);else if(e.nodeType==1){let n=e.getAttribute("style");if(!n)this.addElement(e);else{let r=this.readStyles(zx(n));if(!r)return;let[i,o]=r,l=this.top;for(let c=0;c<o.length;c++)this.removePendingMark(o[c],l);for(let c=0;c<i.length;c++)this.addPendingMark(i[c]);this.addElement(e);for(let c=0;c<i.length;c++)this.removePendingMark(i[c],l);for(let c=0;c<o.length;c++)this.addPendingMark(o[c])}}}addTextNode(e){let n=e.nodeValue,r=this.top;if(r.options&Gn||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r.options&Nn)r.options&Gn?n=n.replace(/\r\n?/g,`
129
- `):n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let i=r.content[r.content.length-1],o=e.previousSibling;(!i||o&&o.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n)),this.findInText(e)}else this.findInside(e)}addElement(e,n){let r=e.nodeName.toLowerCase(),i;so.hasOwnProperty(r)&&this.parser.normalizeLists&&Tx(e);let o=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(i=this.parser.matchTag(e,this,n));if(o?o.ignore:kx.hasOwnProperty(r))this.findInside(e),this.ignoreFallback(e);else if(!o||o.skip||o.closeParent){o&&o.closeParent?this.open=Math.max(0,this.open-1):o&&o.skip.nodeType&&(e=o.skip);let l,c=this.top,u=this.needsBlock;if(no.hasOwnProperty(r))c.content.length&&c.content[0].isInline&&this.open&&(this.open--,c=this.top),l=!0,c.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e);return}this.addAll(e),l&&this.sync(c),this.needsBlock=u}else this.addElementByRule(e,o,o.consuming===!1?i:void 0)}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
130
- `))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let n=Ve.none,r=Ve.none;for(let i=0;i<e.length;i+=2)for(let o=void 0;;){let l=this.parser.matchStyle(e[i],e[i+1],this,o);if(!l)break;if(l.ignore)return null;if(l.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(c=>{l.clearMark(c)&&(r=c.addToSet(r))}):n=this.parser.schema.marks[l.mark].create(l.attrs).addToSet(n),l.consuming===!1)o=l;else break}return[n,r]}addElementByRule(e,n,r){let i,o,l;n.node?(o=this.parser.schema.nodes[n.node],o.isLeaf?this.insertNode(o.create(n.attrs))||this.leafFallback(e):i=this.enter(o,n.attrs||null,n.preserveWhitespace)):(l=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(l));let c=this.top;if(o&&o.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(u=>this.insertNode(u));else{let u=e;typeof n.contentElement=="string"?u=e.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(e):n.contentElement&&(u=n.contentElement),this.findAround(e,u,!0),this.addAll(u)}i&&this.sync(c)&&this.open--,l&&this.removePendingMark(l,c)}addAll(e,n,r){let i=n||0;for(let o=n?e.childNodes[n]:e.firstChild,l=r==null?null:e.childNodes[r];o!=l;o=o.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(o);this.findAtPoint(e,i)}findPlace(e){let n,r;for(let i=this.open;i>=0;i--){let o=this.nodes[i],l=o.findWrapping(e);if(l&&(!n||n.length>l.length)&&(n=l,r=o,!l.length)||o.solid)break}if(!n)return!1;this.sync(r);for(let i=0;i<n.length;i++)this.enterInner(n[i],null,!1);return!0}insertNode(e){if(e.isInline&&this.needsBlock&&!this.top.type){let n=this.textblockFromContext();n&&this.enterInner(n)}if(this.findPlace(e)){this.closeExtra();let n=this.top;n.applyPending(e.type),n.match&&(n.match=n.match.matchType(e.type));let r=n.activeMarks;for(let i=0;i<e.marks.length;i++)(!n.type||n.type.allowsMarkType(e.marks[i].type))&&(r=e.marks[i].addToSet(r));return n.content.push(e.mark(r)),!0}return!1}enter(e,n,r){let i=this.findPlace(e.create(n));return i&&this.enterInner(e,n,!0,r),i}enterInner(e,n=null,r=!1,i){this.closeExtra();let o=this.top;o.applyPending(e),o.match=o.match&&o.match.matchType(e);let l=ro(e,i,o.options);o.options&dn&&o.content.length==0&&(l|=dn),this.nodes.push(new Fn(e,n,o.activeMarks,o.pendingMarks,r,null,l)),this.open++}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let n=this.open;n>=0;n--)if(this.nodes[n]==e)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),o=-(r?r.depth+1:0)+(i?0:1),l=(c,u)=>{for(;c>=0;c--){let d=n[c];if(d==""){if(c==n.length-1||c==0)continue;for(;u>=o;u--)if(l(c-1,u))return!0;return!1}else{let p=u>0||u==0&&i?this.nodes[u].type:r&&u>=o?r.node(u-o).type:null;if(!p||p.name!=d&&p.groups.indexOf(d)==-1)return!1;u--}}return!0};return l(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let n=Ix(e,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,n){for(let r=this.open;r>=0;r--){let i=this.nodes[r];if(i.pendingMarks.lastIndexOf(e)>-1)i.pendingMarks=e.removeFromSet(i.pendingMarks);else{i.activeMarks=e.removeFromSet(i.activeMarks);let l=i.popFromStashMark(e);l&&i.type&&i.type.allowsMarkType(l.type)&&(i.activeMarks=l.addToSet(i.activeMarks))}if(i==n)break}}}function Tx(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&so.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function Dx(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function zx(t){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,n,r=[];for(;n=e.exec(t);)r.push(n[1],n[2].trim());return r}function ao(t){let e={};for(let n in t)e[n]=t[n];return e}function Mx(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let o=[],l=c=>{o.push(c);for(let u=0;u<c.edgeCount;u++){let{type:d,next:p}=c.edge(u);if(d==e||o.indexOf(p)<0&&l(p))return!0}};if(l(i.contentMatch))return!0}}function Ix(t,e){for(let n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}const oo=65535,lo=Math.pow(2,16);function Ex(t,e){return t+e*lo}function co(t){return t&oo}function Ax(t){return(t-(t&oo))/lo}const uo=1,po=2,Wn=4,ho=8;class mo{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&ho)>0}get deletedBefore(){return(this.delInfo&(uo|Wn))>0}get deletedAfter(){return(this.delInfo&(po|Wn))>0}get deletedAcross(){return(this.delInfo&Wn)>0}}class Ue{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Ue.empty)return Ue.empty}recover(e){let n=0,r=co(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+Ax(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,o=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?i:0);if(u>e)break;let d=this.ranges[c+o],p=this.ranges[c+l],h=u+d;if(e<=h){let g=d?e==u?-1:e==h?1:n:n,f=u+i+(g<0?0:p);if(r)return f;let v=e==(n<0?u:h)?null:Ex(c/3,e-u),w=e==u?po:e==h?uo:Wn;return(n<0?e!=u:e!=h)&&(w|=ho),new mo(f,w,v)}i+=p-d}return r?e+i:new mo(e+i,0,null)}touches(e,n){let r=0,i=co(n),o=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?r:0);if(u>e)break;let d=this.ranges[c+o],p=u+d;if(e<=p&&c==i*3)return!0;r+=this.ranges[c+l]-d}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let l=this.ranges[i],c=l-(this.inverted?o:0),u=l+(this.inverted?0:o),d=this.ranges[i+n],p=this.ranges[i+r];e(c,c+d,u,u+p),o+=p-d}}invert(){return new Ue(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?Ue.empty:new Ue(e<0?[0,-e,0]:[0,0,e])}}Ue.empty=new Ue([]);const ar=Object.create(null);class Be{getMap(){return Ue.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=ar[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in ar)throw new RangeError("Duplicate use of step JSON ID "+e);return ar[e]=n,n.prototype.jsonID=e,n}}class fe{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new fe(e,null)}static fail(e){return new fe(null,e)}static fromReplace(e,n,r,i){try{return fe.ok(e.replace(n,r,i))}catch(o){if(o instanceof Sx)return fe.fail(o.message);throw o}}}function or(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let o=t.child(i);o.content.size&&(o=o.copy(or(o.content,e,o))),o.isInline&&(o=e(o,n,i)),r.push(o)}return H.fromArray(r)}class Et extends Be{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),o=new ne(or(n.content,(l,c)=>!l.isAtom||!c.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),n.openStart,n.openEnd);return fe.fromReplace(e,this.from,this.to,o)}invert(){return new At(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Et(n.pos,r.pos,this.mark)}merge(e){return e instanceof Et&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Et(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Et(n.from,n.to,e.markFromJSON(n.mark))}}Be.jsonID("addMark",Et);class At extends Be{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ne(or(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return fe.fromReplace(e,this.from,this.to,r)}invert(){return new Et(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new At(n.pos,r.pos,this.mark)}merge(e){return e instanceof At&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new At(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new At(n.from,n.to,e.markFromJSON(n.mark))}}Be.jsonID("removeMark",At);class Pt extends Be{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return fe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return fe.fromReplace(e,this.pos,this.pos+1,new ne(H.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new Pt(this.pos,n.marks[i]);return new Pt(this.pos,this.mark)}}return new pn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Pt(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Pt(n.pos,e.markFromJSON(n.mark))}}Be.jsonID("addNodeMark",Pt);class pn extends Be{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return fe.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return fe.fromReplace(e,this.pos,this.pos+1,new ne(H.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Pt(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new pn(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new pn(n.pos,e.markFromJSON(n.mark))}}Be.jsonID("removeNodeMark",pn);class lt extends Be{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&lr(e,this.from,this.to)?fe.fail("Structure replace would overwrite content"):fe.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new Ue([this.from,this.to-this.from,this.slice.size])}invert(e){return new lt(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new lt(n.pos,Math.max(n.pos,r.pos),this.slice)}merge(e){if(!(e instanceof lt)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?ne.empty:new ne(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new lt(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?ne.empty:new ne(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new lt(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new lt(n.from,n.to,ne.fromJSON(e,n.slice),!!n.structure)}}Be.jsonID("replace",lt);class $t extends Be{constructor(e,n,r,i,o,l,c=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=o,this.insert=l,this.structure=c}apply(e){if(this.structure&&(lr(e,this.from,this.gapFrom)||lr(e,this.gapTo,this.to)))return fe.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return fe.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?fe.fromReplace(e,this.from,this.to,r):fe.fail("Content does not fit in gap")}getMap(){return new Ue([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new $t(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=e.map(this.gapFrom,-1),o=e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||o>r.pos?null:new $t(n.pos,r.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new $t(n.from,n.to,n.gapFrom,n.gapTo,ne.fromJSON(e,n.slice),n.insert,!!n.structure)}}Be.jsonID("replaceAround",$t);function lr(t,e,n){let r=t.resolve(e),i=n-e,o=r.depth;for(;i>0&&o>0&&r.indexAfter(o)==r.node(o).childCount;)o--,i--;if(i>0){let l=r.node(o).maybeChild(r.indexAfter(o));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function Px(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function $x(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let i=t.$from.node(r),o=t.$from.index(r),l=t.$to.indexAfter(r);if(r<t.depth&&i.canReplace(o,l,n))return r;if(r==0||i.type.spec.isolating||!Px(i,o,l))break}return null}function Qn(t,e,n=1,r){let i=t.resolve(e),o=i.depth-n,l=r&&r[r.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!l.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let d=i.depth-1,p=n-2;d>o;d--,p--){let h=i.node(d),g=i.index(d);if(h.type.spec.isolating)return!1;let f=h.content.cutByIndex(g,h.childCount),v=r&&r[p+1];v&&(f=f.replaceChild(0,v.type.create(v.attrs)));let w=r&&r[p]||h;if(!h.canReplace(g+1,h.childCount)||!w.type.validContent(f))return!1}let c=i.indexAfter(o),u=r&&r[0];return i.node(o).canReplaceWith(c,c,u?u.type:i.node(o+1).type)}function xo(t,e){let n=t.resolve(e),r=n.index();return Bx(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Bx(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}class hn extends Be{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return fe.fail("No node at attribute step's position");let r=Object.create(null);for(let o in n.attrs)r[o]=n.attrs[o];r[this.attr]=this.value;let i=n.type.create(r,null,n.marks);return fe.fromReplace(e,this.pos,this.pos+1,new ne(H.from(i),0,n.isLeaf?0:1))}getMap(){return Ue.empty}invert(e){return new hn(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new hn(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new hn(n.pos,n.attr,n.value)}}Be.jsonID("attr",hn);let mn=class extends Error{};mn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},mn.prototype=Object.create(Error.prototype),mn.prototype.constructor=mn,mn.prototype.name="TransformError";const cr=Object.create(null);class oe{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new Lx(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n<e.length;n++)if(e[n].$from.pos!=e[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,n=ne.empty){let r=n.content.lastChild,i=null;for(let c=0;c<n.openEnd;c++)i=r,r=r.lastChild;let o=e.steps.length,l=this.ranges;for(let c=0;c<l.length;c++){let{$from:u,$to:d}=l[c],p=e.mapping.slice(o);e.replaceRange(p.map(u.pos),p.map(d.pos),c?ne.empty:n),c==0&&yo(e,o,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:l,$to:c}=i[o],u=e.mapping.slice(r),d=u.map(l.pos),p=u.map(c.pos);o?e.deleteRange(d,p):(e.replaceRangeWith(d,p,n),yo(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new ye(e):Rt(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let o=e.depth-1;o>=0;o--){let l=n<0?Rt(e.node(0),e.node(o),e.before(o+1),e.index(o),n,r):Rt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,n,r);if(l)return l}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new gt(e.node(0))}static atStart(e){return Rt(e,e,0,0,1)||new gt(e)}static atEnd(e){return Rt(e,e,e.content.size,e.childCount,-1)||new gt(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=cr[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in cr)throw new RangeError("Duplicate use of selection JSON ID "+e);return cr[e]=n,n.prototype.jsonID=e,n}getBookmark(){return ye.between(this.$anchor,this.$head).getBookmark()}}oe.prototype.visible=!0;class Lx{constructor(e,n){this.$from=e,this.$to=n}}let go=!1;function fo(t){!go&&!t.parent.inlineContent&&(go=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class ye extends oe{constructor(e,n=e){fo(e),fo(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return oe.near(r);let i=e.resolve(n.map(this.anchor));return new ye(i.parent.inlineContent?i:r,r)}replace(e,n=ne.empty){if(super.replace(e,n),n==ne.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof ye&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new Rn(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new ye(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let i=e.resolve(n);return new this(i,r==n?i:e.resolve(r))}static between(e,n,r){let i=e.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let o=oe.findFrom(n,r,!0)||oe.findFrom(n,-r,!0);if(o)n=o.$head;else return oe.near(n,r)}return e.parent.inlineContent||(i==0?e=n:(e=(oe.findFrom(e,-r,!0)||oe.findFrom(e,r,!0)).$anchor,e.pos<n.pos!=i<0&&(e=n))),new ye(e,n)}}oe.jsonID("text",ye);class Rn{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Rn(e.map(this.anchor),e.map(this.head))}resolve(e){return ye.between(e.resolve(this.anchor),e.resolve(this.head))}}class Ne extends oe{constructor(e){let n=e.nodeAfter,r=e.node(0).resolve(e.pos+n.nodeSize);super(e,r),this.node=n}map(e,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),o=e.resolve(i);return r?oe.near(o):new Ne(o)}content(){return new ne(H.from(this.node),0,0)}eq(e){return e instanceof Ne&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ur(this.anchor)}static fromJSON(e,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new Ne(e.resolve(n.anchor))}static create(e,n){return new Ne(e.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}Ne.prototype.visible=!1,oe.jsonID("node",Ne);class ur{constructor(e){this.anchor=e}map(e){let{deleted:n,pos:r}=e.mapResult(this.anchor);return n?new Rn(r,r):new ur(r)}resolve(e){let n=e.resolve(this.anchor),r=n.nodeAfter;return r&&Ne.isSelectable(r)?new Ne(n):oe.near(n)}}class gt extends oe{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,n=ne.empty){if(n==ne.empty){e.delete(0,e.doc.content.size);let r=oe.atStart(e.doc);r.eq(e.selection)||e.setSelection(r)}else super.replace(e,n)}toJSON(){return{type:"all"}}static fromJSON(e){return new gt(e)}map(e){return new gt(e)}eq(e){return e instanceof gt}getBookmark(){return qx}}oe.jsonID("all",gt);const qx={map(){return this},resolve(t){return new gt(t)}};function Rt(t,e,n,r,i,o=!1){if(e.inlineContent)return ye.create(t,n);for(let l=r-(i>0?0:1);i>0?l<e.childCount:l>=0;l+=i){let c=e.child(l);if(c.isAtom){if(!o&&Ne.isSelectable(c))return Ne.create(t,n-(i<0?c.nodeSize:0))}else{let u=Rt(t,c,n+i,i<0?c.childCount:0,i,o);if(u)return u}n+=c.nodeSize*i}return null}function yo(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof lt||i instanceof $t))return;let o=t.mapping.maps[r],l;o.forEach((c,u,d,p)=>{l==null&&(l=p)}),t.setSelection(oe.near(t.doc.resolve(l),n))}function bo(t,e){return!e||!t?t:t.bind(e)}class Un{constructor(e,n,r){this.name=e,this.init=bo(n.init,r),this.apply=bo(n.apply,r)}}new Un("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Un("selection",{init(t,e){return t.selection||oe.atStart(e.doc)},apply(t){return t.selection}}),new Un("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Un("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function vo(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=vo(i,e,{})),n[r]=i}return n}class xn{constructor(e){this.spec=e,this.props={},e.props&&vo(e.props,this,this.props),this.key=e.key?e.key.key:_o("plugin")}getState(e){return e[this.key]}}const dr=Object.create(null);function _o(t){return t in dr?t+"$"+ ++dr[t]:(dr[t]=0,t+"$")}class gn{constructor(e="key"){this.key=_o(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}function jo(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:o}=n;return{...e,apply:e.apply.bind(e),applyTransaction:e.applyTransaction.bind(e),filterTransaction:e.filterTransaction,plugins:e.plugins,schema:e.schema,reconfigure:e.reconfigure.bind(e),toJSON:e.toJSON.bind(e),get storedMarks(){return o},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,o=n.storedMarks,n}}}class Ox{constructor(e){this.editor=e.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=e.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:e,editor:n,state:r}=this,{view:i}=n,{tr:o}=r,l=this.buildProps(o);return Object.fromEntries(Object.entries(e).map(([c,u])=>[c,(...p)=>{const h=u(...p)(l);return!o.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(o),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(e,n=!0){const{rawCommands:r,editor:i,state:o}=this,{view:l}=i,c=[],u=!!e,d=e||o.tr,p=()=>(!u&&n&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(d),c.every(g=>g===!0)),h={...Object.fromEntries(Object.entries(r).map(([g,f])=>[g,(...w)=>{const T=this.buildProps(d,n),D=f(...w)(T);return c.push(D),h}])),run:p};return h}createCan(e){const{rawCommands:n,state:r}=this,i=!1,o=e||r.tr,l=this.buildProps(o,i);return{...Object.fromEntries(Object.entries(n).map(([u,d])=>[u,(...p)=>d(...p)({...l,dispatch:void 0})])),chain:()=>this.createChain(o,i)}}buildProps(e,n=!0){const{rawCommands:r,editor:i,state:o}=this,{view:l}=i;o.storedMarks&&e.setStoredMarks(o.storedMarks);const c={tr:e,editor:i,view:l,state:jo({state:o,transaction:e}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(e),can:()=>this.createCan(e),get commands(){return Object.fromEntries(Object.entries(r).map(([u,d])=>[u,(...p)=>d(...p)(c)]))}};return c}}function St(t,e,n){return t.config[e]===void 0&&t.parent?St(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?St(t.parent,e,n):null}):t.config[e]}function Vx(t){const e=t.filter(i=>i.type==="extension"),n=t.filter(i=>i.type==="node"),r=t.filter(i=>i.type==="mark");return{baseExtensions:e,nodeExtensions:n,markExtensions:r}}function De(t,e){if(typeof t=="string"){if(!e.nodes[t])throw Error(`There is no node type named '${t}'. Maybe you forgot to add the extension?`);return e.nodes[t]}return t}function Nx(t){return typeof t=="function"}function Ut(t,e=void 0,...n){return Nx(t)?e?t.bind(e)(...n):t(...n):t}function Gx(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Fx(t){return Object.prototype.toString.call(t).slice(8,-1)}function pr(t){return Fx(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function wo(t,e){const n={...t};return pr(t)&&pr(e)&&Object.keys(e).forEach(r=>{pr(e[r])?r in t?n[r]=wo(t[r],e[r]):Object.assign(n,{[r]:e[r]}):Object.assign(n,{[r]:e[r]})}),n}class ct{constructor(e={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...e},this.name=this.config.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Ut(St(this,"addOptions",{name:this.name}))),this.storage=Ut(St(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ct(e)}configure(e={}){const n=this.extend();return n.options=wo(this.options,e),n.storage=Ut(St(n,"addStorage",{name:n.name,options:n.options})),n}extend(e={}){const n=new ct(e);return n.parent=this,this.child=n,n.name=e.name?e.name:n.parent.name,e.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=Ut(St(n,"addOptions",{name:n.name})),n.storage=Ut(St(n,"addStorage",{name:n.name,options:n.options})),n}}function Wx(t,e,n){const{from:r,to:i}=e,{blockSeparator:o=`
127
+ `}})}function Y_(e){return e.y_axes.reduce((n,{label_formatter:s},i)=>(n[i]=function(l){let c=l;if(typeof l=="object"&&(Array.isArray(l.value)&&l.value.length===2?c=l.value[1]:c=l.value),!s)return c;try{return U(c,s)}catch(u){return console.error(u),c}},n),{default:({value:n})=>n})}function Ja(e,t){const n={};return t.map(s=>{const i=jt(s,e);n[s.name]=Re(s,i)}),n}function K_(e,t){const{overflow:n,...s}=e.x_axis.axisLabel,i=ut(n.on_axis),a=t.length===0;return[te.getXAxis({data:t,name:e.x_axis_name??"",nameGap:a?5:void 0,id:"main-x-axis",type:e.x_axis.type,axisLabel:{...s,...i,formatter:Ye(s.formatter)}})]}function X_(e){var t;if(!e)return[];try{return Array.isArray(e[0])&&((t=e[0])==null?void 0:t.length)>=2?e.map(s=>Number(s[1])):[...e]}catch(n){return console.error(n),[...e]}}function J_(e){if(e.length===0)return{};const t={},n={};return e.forEach(s=>{const i=X_(s.data);if(!n[s.yAxisIndex]){n[s.yAxisIndex]=i;return}n[s.yAxisIndex]=n[s.yAxisIndex].concat(i)}),Object.entries(n).forEach(([s,i])=>{const a=v.minBy(i)??0,l=v.maxBy(i)??0;a==0&&l==0&&(t[s]=1)}),t}function Z_(e,t,n){const s=J_(n);return e.y_axes.map(({nameAlignment:i,min:a,max:l,show:c,...u},d)=>{let p=u.position;return p||(p=d>0?"right":"left"),te.getYAxis({...u,minInterval:s[d]??0,show:c,min:a||void 0,max:l||void 0,position:p,axisLabel:{show:c,formatter:t[d]??t.default},nameTextStyle:{align:i},nameLocation:"end",nameGap:c?15:0,splitLine:{show:d===0}})})}const H_={xAxis:[{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"},splitLine:{show:!1},axisTick:{show:!0,alignWithLabel:!0}}]};function ej(e,t,n){const s=Ja(t,n),i=Y_(e),a=v.uniq(_t(t,e.x_axis_data_key)),l=W_(e,a,t,i,n,s),c=P_(e,t),u={xAxis:K_(e,a),yAxis:Z_(e,i,l),series:[...l,...c],tooltip:U_(e,t,l,i),grid:M_(e),legend:E_(l),dataZoom:ds(e.dataZoom)};return v.defaultsDeep({},u,H_)}function Qd(e){const t=e.getModel(),n=t.getSeries().map(s=>{if(!s.option.custom)return s.option;const i=t.getColorFromPalette(s.option.custom.targetSeries,null);return s.option.color=i,s.option});e.setOption({...e.getOption(),series:n})}function Ud(e){return e.trim().length>0}function tj({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=wn(t,e.x_axis_data_key),c=nt(i.triggerManager,Ya.id),u=m.useCallback(g=>{const y=v.get(l,g.name,{error:"rowData is not found"});c.forEach(j=>{i.runInteraction(j.id,{...g,rowData:y})})},[l,c,i]),d=m.useMemo(()=>ej(e,t,a),[e,t]),p=m.useRef(),h=m.useMemo(()=>({click:u}),[u]),f=g=>{p.current=g,Qd(g)};return m.useEffect(()=>{p.current&&Qd(p.current)},[d]),!n||!s?null:r.jsx(Pe,{echarts:Ae,option:d,style:{width:n,height:s},onEvents:h,onChartReady:f,notMerge:!0,theme:"merico-light"})}function nj({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=m.useMemo(()=>v.defaults({},s,Ka),[s]),l=e.data,{width:c,height:u}=e.viewport,{ref:d,height:p}=he.useElementSize(),{ref:h,height:f}=he.useElementSize(),g=m.useMemo(()=>{const{stats:{templates:k}}=a;return{top:fr(k.top,i,l),bottom:fr(k.bottom,i,l)}},[a,l]),y=Math.max(0,Ct(u)-p-f),j=wt(c);return r.jsxs(Ue,{width:c,height:u,children:[r.jsx(o.Text,{ref:d,align:"left",size:"xs",pl:"sm",sx:{display:Ud(a.stats.templates.top)?"block":"none"},children:Object.values(g.top).map((k,S)=>r.jsx(m.Fragment,{children:k},S))}),r.jsx(tj,{variables:i,width:j,height:y,data:l,conf:a,interactionManager:n}),r.jsx(o.Text,{ref:h,align:"left",size:"xs",pl:"sm",sx:{display:Ud(a.stats.templates.bottom)?"block":"none"},children:Object.values(g.bottom).map((k,S)=>r.jsx(m.Fragment,{children:k},S))})]})}function rj({control:e,index:t,variableOptions:n}){const{t:s,i18n:i}=_.useTranslation(),a=m.useMemo(()=>[{label:s("chart.reference_area.type.rectangle"),value:"rectangle"}],[i.language]),l=m.useMemo(()=>[{label:s("chart.reference_area.direction.horizontal"),value:"horizontal"}],[i.language]);return r.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`reference_areas.${t}.name`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.reference_area.label"),required:!0,sx:{flex:1},...c})}),r.jsx(b.Controller,{name:`reference_areas.${t}.color`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.color.label"),required:!0,sx:{flex:1},...c})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`reference_areas.${t}.type`,control:e,render:({field:c})=>r.jsx(o.Select,{label:s("chart.reference_area.type.label"),required:!0,data:a,sx:{flex:1},...c})}),r.jsx(b.Controller,{name:`reference_areas.${t}.direction`,control:e,render:({field:c})=>r.jsx(o.Select,{label:s("chart.reference_area.direction.label"),required:!0,data:l,sx:{flex:1},...c})})]}),r.jsx(o.Divider,{variant:"dashed",label:s("data.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`reference_areas.${t}.y_keys.upper`,control:e,render:({field:c})=>r.jsx(o.Select,{label:s("chart.reference_area.boundary.upper"),required:!0,data:n,sx:{flex:1},...c})}),r.jsx(b.Controller,{name:`reference_areas.${t}.y_keys.lower`,control:e,render:({field:c})=>r.jsx(o.Select,{label:s("chart.reference_area.boundary.lower"),required:!0,data:n,sx:{flex:1},...c})})]})]})}function sj({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>({name:"",color:"rgba(0,0,0,0.1)",type:"rectangle",direction:"horizontal",y_keys:{upper:"",lower:""}}),a=(c,u)=>{const d=c.name.trim();return d||u+1},l=m.useMemo(()=>n.map(c=>({label:c.name,value:c.name})),[n]);return r.jsx(fe,{control:e,watch:t,name:"reference_areas",getItem:i,addButtonText:s("chart.reference_area.add"),deleteButtonText:s("chart.reference_area.delete"),renderTabName:a,children:({field:c,index:u})=>r.jsx(rj,{control:e,index:u,variableOptions:l})})}const Zn=m.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:a("chart.series.line.type.solid"),value:"solid"},{label:a("chart.series.line.type.dashed"),value:"dashed"},{label:a("chart.series.line.type.dotted"),value:"dotted"}],[l.language]);return r.jsx(o.Select,{ref:i,label:e??a("chart.series.line.type.label"),data:c,value:t,onChange:n,sx:s})});function ij({control:e,index:t,watch:n,variableOptions:s,yAxisOptions:i}){const{t:a}=_.useTranslation(),l=n(`reference_lines.${t}.orientation`);return r.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("common.name"),placeholder:a("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>r.jsx(o.Select,{label:a("common.data_field"),required:!0,data:s,sx:{flex:1},...c})})]}),r.jsx(b.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("chart.content_template.label"),placeholder:a("chart.content_template.hint"),sx:{flex:1},...c})}),r.jsxs(o.Group,{grow:!0,children:[r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>r.jsx(gn,{label:a("chart.orientation.label"),sx:{flex:1},...c})}),l==="vertical"&&r.jsx(o.Text,{mt:-10,color:"dimmed",size:12,children:a("chart.reference_line.orientation.vertical_hint")})]}),l==="horizontal"&&r.jsx(b.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:c,onChange:u,...d}})=>r.jsx(o.Select,{label:a("chart.y_axis.label"),data:i,disabled:i.length===0,...d,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){u(0);return}u(Number(p))},sx:{flex:1}})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.style.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>r.jsx(Zn,{sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>r.jsx(o.NumberInput,{label:a("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:a("chart.color.label")}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>r.jsx(Le,{...c})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.behavior.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`reference_lines.${t}.show_in_legend`,control:e,render:({field:c})=>r.jsx(o.Checkbox,{label:a("chart.legend.show_in_legend"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})]})}function aj({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,yAxisIndex:0}),a=(d,p)=>{const h=d.name.trim();return h||p+1},l=m.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),c=t("y_axes"),u=m.useMemo(()=>c.map(({name:d},p)=>({label:d,value:p.toString()})),[c]);return r.jsx(fe,{control:e,watch:t,name:"reference_lines",getItem:i,addButtonText:s("chart.reference_line.add"),deleteButtonText:s("chart.reference_line.delete"),renderTabName:a,children:({field:d,index:p})=>r.jsx(ij,{control:e,index:p,watch:t,variableOptions:l,yAxisOptions:u})})}function oj({control:e,regressionItem:t,index:n,yAxisOptions:s}){const{t:i,i18n:a}=_.useTranslation(),l=m.useMemo(()=>[{label:i("chart.regression_line.method.linear"),value:"linear"},{label:i("chart.regression_line.method.exponential"),value:"exponential"},{label:i("chart.regression_line.method.logistic"),value:"logistic"},{label:i("chart.regression_line.method.polynomial"),value:"polynomial"}],[a.language]),c=t.transform.config.method;return r.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`regressions.${n}.name`,control:e,render:({field:u})=>r.jsx(o.TextInput,{label:i("common.name"),required:!0,sx:{flex:1},...u})}),r.jsx(b.Controller,{name:`regressions.${n}.group_by_key`,control:e,render:({field:u})=>r.jsx(F,{label:i("chart.series.group_by.label_line"),clearable:!0,sx:{flex:1},...u})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`regressions.${n}.y_axis_data_key`,control:e,render:({field:u})=>r.jsx(F,{label:i("common.data_field"),required:!0,sx:{flex:1},...u})}),r.jsx(b.Controller,{name:`regressions.${n}.plot.yAxisIndex`,control:e,render:({field:{value:u,onChange:d,...p}})=>r.jsx(o.Select,{label:i("chart.y_axis.label"),data:s,disabled:s.length===0,...p,value:(u==null?void 0:u.toString())??"",onChange:h=>{if(!h){d(0);return}d(Number(h))},sx:{flex:1}})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`regressions.${n}.transform.config.method`,control:e,render:({field:u})=>r.jsx(o.Select,{label:i("chart.regression_line.method.label"),data:l,sx:{flex:1},...u})}),c==="polynomial"&&r.jsx(b.Controller,{name:`regressions.${n}.transform.config.order`,control:e,render:({field:u})=>r.jsx(o.NumberInput,{label:i("chart.regression_line.method.polynomial_order"),sx:{flex:1},...u})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:i("chart.series.line.line_style"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`regressions.${n}.plot.lineStyle.type`,control:e,render:({field:u})=>r.jsx(Zn,{sx:{flexGrow:1},...u})}),r.jsx(b.Controller,{name:`regressions.${n}.plot.lineStyle.width`,control:e,render:({field:u})=>r.jsx(o.NumberInput,{label:i("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...u})})]}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:"Color"}),r.jsx(b.Controller,{name:`regressions.${n}.plot.color`,control:e,render:({field:u})=>r.jsx(Le,{...u})})]})]})}function lj({control:e,watch:t}){const{t:n}=_.useTranslation(),s=t("y_axes"),i=m.useMemo(()=>s.map(({name:c},u)=>({label:c,value:u.toString()})),[s]),a=()=>({transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},group_by_key:"",name:"",y_axis_data_key:"",plot:{type:"line",yAxisIndex:0,color:"#666666",lineStyle:{type:"solid",width:1}}}),l=(c,u)=>{const d=c.name.trim();return d||u+1};return r.jsx(fe,{control:e,watch:t,name:"regressions",getItem:a,addButtonText:n("chart.regression_line.add"),deleteButtonText:n("chart.regression_line.delete"),renderTabName:l,children:({field:c,index:u})=>r.jsx(oj,{regressionItem:c,control:e,index:u,yAxisOptions:i})})}const cj=({value:e,onChange:t})=>{const n=s=>{s&&t(s)};return r.jsx(o.Box,{children:r.jsx(tt,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Za={static:{type:"static",size:10},dynamic:{type:"dynamic",func_content:["function getSize({ rowData, params, variables }, { lodash, interpolate }) {"," // your code goes here"," // return 10","}"].join(`
128
+ `)}},uj=({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),[s,{setTrue:i,setFalse:a}]=W.useBoolean(),[l,c]=m.useState(e),u=()=>{a();const{type:f,func_content:g}=l,y={type:f,func_content:g};c(y),t(y)},d=()=>{a(),c(e)},p=f=>{c(g=>({...g,func_content:f}))},h=()=>{p(Za.dynamic.func_content)};return r.jsxs(r.Fragment,{children:[r.jsx(o.Box,{sx:{width:"50%"},children:r.jsx(o.Button,{color:"grape",variant:"filled",mt:24,onClick:i,sx:{flexGrow:0},leftIcon:r.jsx(M.IconMathFunction,{size:16}),children:n("chart.symbol_size.setup.label")})}),r.jsx(o.Modal,{size:800,title:n("chart.symbol_size.setup.title"),opened:s,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mt:10,mb:-10,label:n("chart.symbol_size.setup.description"),labelPosition:"center",variant:"dashed"}),r.jsx(cj,{value:l.func_content,onChange:p}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:h,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:n("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:d,variant:"subtle",children:n("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:u,children:n("common.actions.save")})]})]})]})})]})},dj=({value:e,onChange:t})=>e.type!=="dynamic"?null:r.jsx(uj,{value:e,onChange:t}),pj=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=s=>{t({...e,size:s})};return r.jsx(r.Fragment,{children:r.jsx(o.NumberInput,{defaultValue:18,placeholder:"1 ~ 100",label:" ",hideControls:!0,value:e.size,onChange:n})})},Ha=m.forwardRef(({label:e,value:t,onChange:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=m.useMemo(()=>[{label:i("chart.symbol_size.static"),value:"static"},{label:i("chart.symbol_size.dynamic"),value:"dynamic"}],[a.language]),c=u=>{n({...Za[u]})};return r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(o.Select,{ref:s,label:e??i("chart.symbol_size.label"),data:l,value:t.type,onChange:c,sx:{flexGrow:1}}),r.jsx(pj,{value:t,onChange:n}),r.jsx(dj,{value:t,onChange:n})]})}),eo={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:"0 !important"},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},"table.rich-text-table-render, div.tableWrapper table":{"th, td":{border:"1px solid #eaeaea"},"tr:last-of-type td":{borderBottom:"1px solid #eaeaea"}},".resize-cursor":{cursor:"col-resize"},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"►"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"},blockquote:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45",margin:"0 0 14px"}};function Yd(e,t,n){for(let s=0;;s++){if(s==e.childCount||s==t.childCount)return e.childCount==t.childCount?null:n;let i=e.child(s),a=t.child(s);if(i==a){n+=i.nodeSize;continue}if(!i.sameMarkup(a))return n;if(i.isText&&i.text!=a.text){for(let l=0;i.text[l]==a.text[l];l++)n++;return n}if(i.content.size||a.content.size){let l=Yd(i.content,a.content,n+1);if(l!=null)return l}n+=i.nodeSize}}function Kd(e,t,n,s){for(let i=e.childCount,a=t.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:s};let l=e.child(--i),c=t.child(--a),u=l.nodeSize;if(l==c){n-=u,s-=u;continue}if(!l.sameMarkup(c))return{a:n,b:s};if(l.isText&&l.text!=c.text){let d=0,p=Math.min(l.text.length,c.text.length);for(;d<p&&l.text[l.text.length-d-1]==c.text[c.text.length-d-1];)d++,n--,s--;return{a:n,b:s}}if(l.content.size||c.content.size){let d=Kd(l.content,c.content,n-1,s-1);if(d)return d}n-=u,s-=u}}class H{constructor(t,n){if(this.content=t,this.size=n||0,n==null)for(let s=0;s<t.length;s++)this.size+=t[s].nodeSize}nodesBetween(t,n,s,i=0,a){for(let l=0,c=0;c<n;l++){let u=this.content[l],d=c+u.nodeSize;if(d>t&&s(u,i+c,a||null,l)!==!1&&u.content.size){let p=c+1;u.nodesBetween(Math.max(0,t-p),Math.min(u.content.size,n-p),s,i+p)}c=d}}descendants(t){this.nodesBetween(0,this.size,t)}textBetween(t,n,s,i){let a="",l=!0;return this.nodesBetween(t,n,(c,u)=>{c.isText?(a+=c.text.slice(Math.max(t,u)-u,n-u),l=!s):c.isLeaf?(i?a+=typeof i=="function"?i(c):i:c.type.spec.leafText&&(a+=c.type.spec.leafText(c)),l=!s):!l&&c.isBlock&&(a+=s,l=!0)},0),a}append(t){if(!t.size)return this;if(!this.size)return t;let n=this.lastChild,s=t.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(s)&&(i[i.length-1]=n.withText(n.text+s.text),a=1);a<t.content.length;a++)i.push(t.content[a]);return new H(i,this.size+t.size)}cut(t,n=this.size){if(t==0&&n==this.size)return this;let s=[],i=0;if(n>t)for(let a=0,l=0;l<n;a++){let c=this.content[a],u=l+c.nodeSize;u>t&&((l<t||u>n)&&(c.isText?c=c.cut(Math.max(0,t-l),Math.min(c.text.length,n-l)):c=c.cut(Math.max(0,t-l-1),Math.min(c.content.size,n-l-1))),s.push(c),i+=c.nodeSize),l=u}return new H(s,i)}cutByIndex(t,n){return t==n?H.empty:t==0&&n==this.content.length?this:new H(this.content.slice(t,n))}replaceChild(t,n){let s=this.content[t];if(s==n)return this;let i=this.content.slice(),a=this.size+n.nodeSize-s.nodeSize;return i[t]=n,new H(i,a)}addToStart(t){return new H([t].concat(this.content),this.size+t.nodeSize)}addToEnd(t){return new H(this.content.concat(t),this.size+t.nodeSize)}eq(t){if(this.content.length!=t.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(t.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(t){let n=this.content[t];if(!n)throw new RangeError("Index "+t+" out of range for "+this);return n}maybeChild(t){return this.content[t]||null}forEach(t){for(let n=0,s=0;n<this.content.length;n++){let i=this.content[n];t(i,s,n),s+=i.nodeSize}}findDiffStart(t,n=0){return Yd(this,t,n)}findDiffEnd(t,n=this.size,s=t.size){return Kd(this,t,n,s)}findIndex(t,n=-1){if(t==0)return Ls(0,t);if(t==this.size)return Ls(this.content.length,t);if(t>this.size||t<0)throw new RangeError(`Position ${t} outside of fragment (${this})`);for(let s=0,i=0;;s++){let a=this.child(s),l=i+a.nodeSize;if(l>=t)return l==t||n>0?Ls(s+1,l):Ls(s,i);i=l}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(t=>t.toJSON()):null}static fromJSON(t,n){if(!n)return H.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new H(n.map(t.nodeFromJSON))}static fromArray(t){if(!t.length)return H.empty;let n,s=0;for(let i=0;i<t.length;i++){let a=t[i];s+=a.nodeSize,i&&a.isText&&t[i-1].sameMarkup(a)?(n||(n=t.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}return new H(n||t,s)}static from(t){if(!t)return H.empty;if(t instanceof H)return t;if(Array.isArray(t))return this.fromArray(t);if(t.attrs)return new H([t],t.nodeSize);throw new RangeError("Can not convert "+t+" to a Fragment"+(t.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}H.empty=new H([],0);const to={index:0,offset:0};function Ls(e,t){return to.index=e,to.offset=t,to}function no(e,t){if(e===t)return!0;if(!(e&&typeof e=="object")||!(t&&typeof t=="object"))return!1;let n=Array.isArray(e);if(Array.isArray(t)!=n)return!1;if(n){if(e.length!=t.length)return!1;for(let s=0;s<e.length;s++)if(!no(e[s],t[s]))return!1}else{for(let s in e)if(!(s in t)||!no(e[s],t[s]))return!1;for(let s in t)if(!(s in e))return!1}return!0}let Nt=class Wl{constructor(t,n){this.type=t,this.attrs=n}addToSet(t){let n,s=!1;for(let i=0;i<t.length;i++){let a=t[i];if(this.eq(a))return t;if(this.type.excludes(a.type))n||(n=t.slice(0,i));else{if(a.type.excludes(this.type))return t;!s&&a.type.rank>this.type.rank&&(n||(n=t.slice(0,i)),n.push(this),s=!0),n&&n.push(a)}}return n||(n=t.slice()),s||n.push(this),n}removeFromSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return t.slice(0,n).concat(t.slice(n+1));return t}isInSet(t){for(let n=0;n<t.length;n++)if(this.eq(t[n]))return!0;return!1}eq(t){return this==t||this.type==t.type&&no(this.attrs,t.attrs)}toJSON(){let t={type:this.type.name};for(let n in this.attrs){t.attrs=this.attrs;break}return t}static fromJSON(t,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let s=t.marks[n.type];if(!s)throw new RangeError(`There is no mark type ${n.type} in this schema`);return s.create(n.attrs)}static sameSet(t,n){if(t==n)return!0;if(t.length!=n.length)return!1;for(let s=0;s<t.length;s++)if(!t[s].eq(n[s]))return!1;return!0}static setFrom(t){if(!t||Array.isArray(t)&&t.length==0)return Wl.none;if(t instanceof Wl)return[t];let n=t.slice();return n.sort((s,i)=>s.type.rank-i.type.rank),n}};Nt.none=[];class hj extends Error{}class re{constructor(t,n,s){this.content=t,this.openStart=n,this.openEnd=s}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(t,n){let s=Jd(this.content,t+this.openStart,n);return s&&new re(s,this.openStart,this.openEnd)}removeBetween(t,n){return new re(Xd(this.content,t+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(t){return this.content.eq(t.content)&&this.openStart==t.openStart&&this.openEnd==t.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let t={content:this.content.toJSON()};return this.openStart>0&&(t.openStart=this.openStart),this.openEnd>0&&(t.openEnd=this.openEnd),t}static fromJSON(t,n){if(!n)return re.empty;let s=n.openStart||0,i=n.openEnd||0;if(typeof s!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new re(H.fromJSON(t,n.content),s,i)}static maxOpen(t,n=!0){let s=0,i=0;for(let a=t.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)s++;for(let a=t.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new re(t,s,i)}}re.empty=new re(H.empty,0,0);function Xd(e,t,n){let{index:s,offset:i}=e.findIndex(t),a=e.maybeChild(s),{index:l,offset:c}=e.findIndex(n);if(i==t||a.isText){if(c!=n&&!e.child(l).isText)throw new RangeError("Removing non-flat range");return e.cut(0,t).append(e.cut(n))}if(s!=l)throw new RangeError("Removing non-flat range");return e.replaceChild(s,a.copy(Xd(a.content,t-i-1,n-i-1)))}function Jd(e,t,n,s){let{index:i,offset:a}=e.findIndex(t),l=e.maybeChild(i);if(a==t||l.isText)return s&&!s.canReplace(i,i,n)?null:e.cut(0,t).append(n).append(e.cut(t));let c=Jd(l.content,t-a-1,n);return c&&e.replaceChild(i,l.copy(c))}let fj=class Rl{constructor(t,n){this.schema=t,this.rules=n,this.tags=[],this.styles=[],n.forEach(s=>{s.tag?this.tags.push(s):s.style&&this.styles.push(s)}),this.normalizeLists=!this.tags.some(s=>{if(!/^(ul|ol)\b/.test(s.tag)||!s.node)return!1;let i=t.nodes[s.node];return i.contentMatch.matchType(i)})}parse(t,n={}){let s=new tp(this,n,!1);return s.addAll(t,n.from,n.to),s.finish()}parseSlice(t,n={}){let s=new tp(this,n,!0);return s.addAll(t,n.from,n.to),re.maxOpen(s.finish())}matchTag(t,n,s){for(let i=s?this.tags.indexOf(s)+1:0;i<this.tags.length;i++){let a=this.tags[i];if(xj(t,a.tag)&&(a.namespace===void 0||t.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let l=a.getAttrs(t);if(l===!1)continue;a.attrs=l||void 0}return a}}}matchStyle(t,n,s,i){for(let a=i?this.styles.indexOf(i)+1:0;a<this.styles.length;a++){let l=this.styles[a],c=l.style;if(!(c.indexOf(t)!=0||l.context&&!s.matchesContext(l.context)||c.length>t.length&&(c.charCodeAt(t.length)!=61||c.slice(t.length+1)!=n))){if(l.getAttrs){let u=l.getAttrs(n);if(u===!1)continue;l.attrs=u||void 0}return l}}}static schemaRules(t){let n=[];function s(i){let a=i.priority==null?50:i.priority,l=0;for(;l<n.length;l++){let c=n[l];if((c.priority==null?50:c.priority)<a)break}n.splice(l,0,i)}for(let i in t.marks){let a=t.marks[i].spec.parseDOM;a&&a.forEach(l=>{s(l=np(l)),l.mark||l.ignore||l.clearMark||(l.mark=i)})}for(let i in t.nodes){let a=t.nodes[i].spec.parseDOM;a&&a.forEach(l=>{s(l=np(l)),l.node||l.ignore||l.mark||(l.node=i)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Rl(t,Rl.schemaRules(t)))}};const Zd={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},mj={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Hd={ol:!0,ul:!0},Bs=1,qs=2,Br=4;function ep(e,t,n){return t!=null?(t?Bs:0)|(t==="full"?qs:0):e&&e.whitespace=="pre"?Bs|qs:n&~Br}class Vs{constructor(t,n,s,i,a,l,c){this.type=t,this.attrs=n,this.marks=s,this.pendingMarks=i,this.solid=a,this.options=c,this.content=[],this.activeMarks=Nt.none,this.stashMarks=[],this.match=l||(c&Br?null:t.contentMatch)}findWrapping(t){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(H.from(t));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let s=this.type.contentMatch,i;return(i=s.findWrapping(t.type))?(this.match=s,i):null}}return this.match.findWrapping(t.type)}finish(t){if(!(this.options&Bs)){let s=this.content[this.content.length-1],i;if(s&&s.isText&&(i=/[ \t\r\n\u000c]+$/.exec(s.text))){let a=s;s.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=a.withText(a.text.slice(0,a.text.length-i[0].length))}}let n=H.from(this.content);return!t&&this.match&&(n=n.append(this.match.fillBefore(H.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(t){for(let n=this.stashMarks.length-1;n>=0;n--)if(t.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(t){for(let n=0,s=this.pendingMarks;n<s.length;n++){let i=s[n];(this.type?this.type.allowsMarkType(i.type):bj(i.type,t))&&!i.isInSet(this.activeMarks)&&(this.activeMarks=i.addToSet(this.activeMarks),this.pendingMarks=i.removeFromSet(this.pendingMarks))}}inlineContext(t){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:t.parentNode&&!Zd.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class tp{constructor(t,n,s){this.parser=t,this.options=n,this.isOpen=s,this.open=0;let i=n.topNode,a,l=ep(null,n.preserveWhitespace,0)|(s?Br:0);i?a=new Vs(i.type,i.attrs,Nt.none,Nt.none,!0,n.topMatch||i.type.contentMatch,l):s?a=new Vs(null,null,Nt.none,Nt.none,!0,null,l):a=new Vs(t.schema.topNodeType,null,Nt.none,Nt.none,!0,null,l),this.nodes=[a],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(t){if(t.nodeType==3)this.addTextNode(t);else if(t.nodeType==1){let n=t.getAttribute("style");if(!n)this.addElement(t);else{let s=this.readStyles(yj(n));if(!s)return;let[i,a]=s,l=this.top;for(let c=0;c<a.length;c++)this.removePendingMark(a[c],l);for(let c=0;c<i.length;c++)this.addPendingMark(i[c]);this.addElement(t);for(let c=0;c<i.length;c++)this.removePendingMark(i[c],l);for(let c=0;c<a.length;c++)this.addPendingMark(a[c])}}}addTextNode(t){let n=t.nodeValue,s=this.top;if(s.options&qs||s.inlineContext(t)||/[^ \t\r\n\u000c]/.test(n)){if(s.options&Bs)s.options&qs?n=n.replace(/\r\n?/g,`
129
+ `):n=n.replace(/\r?\n|\r/g," ");else if(n=n.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(n)&&this.open==this.nodes.length-1){let i=s.content[s.content.length-1],a=t.previousSibling;(!i||a&&a.nodeName=="BR"||i.isText&&/[ \t\r\n\u000c]$/.test(i.text))&&(n=n.slice(1))}n&&this.insertNode(this.parser.schema.text(n)),this.findInText(t)}else this.findInside(t)}addElement(t,n){let s=t.nodeName.toLowerCase(),i;Hd.hasOwnProperty(s)&&this.parser.normalizeLists&&gj(t);let a=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,n));if(a?a.ignore:mj.hasOwnProperty(s))this.findInside(t),this.ignoreFallback(t);else if(!a||a.skip||a.closeParent){a&&a.closeParent?this.open=Math.max(0,this.open-1):a&&a.skip.nodeType&&(t=a.skip);let l,c=this.top,u=this.needsBlock;if(Zd.hasOwnProperty(s))c.content.length&&c.content[0].isInline&&this.open&&(this.open--,c=this.top),l=!0,c.type||(this.needsBlock=!0);else if(!t.firstChild){this.leafFallback(t);return}this.addAll(t),l&&this.sync(c),this.needsBlock=u}else this.addElementByRule(t,a,a.consuming===!1?i:void 0)}leafFallback(t){t.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(t.ownerDocument.createTextNode(`
130
+ `))}ignoreFallback(t){t.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(t){let n=Nt.none,s=Nt.none;for(let i=0;i<t.length;i+=2)for(let a=void 0;;){let l=this.parser.matchStyle(t[i],t[i+1],this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?this.top.pendingMarks.concat(this.top.activeMarks).forEach(c=>{l.clearMark(c)&&(s=c.addToSet(s))}):n=this.parser.schema.marks[l.mark].create(l.attrs).addToSet(n),l.consuming===!1)a=l;else break}return[n,s]}addElementByRule(t,n,s){let i,a,l;n.node?(a=this.parser.schema.nodes[n.node],a.isLeaf?this.insertNode(a.create(n.attrs))||this.leafFallback(t):i=this.enter(a,n.attrs||null,n.preserveWhitespace)):(l=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(l));let c=this.top;if(a&&a.isLeaf)this.findInside(t);else if(s)this.addElement(t,s);else if(n.getContent)this.findInside(t),n.getContent(t,this.parser.schema).forEach(u=>this.insertNode(u));else{let u=t;typeof n.contentElement=="string"?u=t.querySelector(n.contentElement):typeof n.contentElement=="function"?u=n.contentElement(t):n.contentElement&&(u=n.contentElement),this.findAround(t,u,!0),this.addAll(u)}i&&this.sync(c)&&this.open--,l&&this.removePendingMark(l,c)}addAll(t,n,s){let i=n||0;for(let a=n?t.childNodes[n]:t.firstChild,l=s==null?null:t.childNodes[s];a!=l;a=a.nextSibling,++i)this.findAtPoint(t,i),this.addDOM(a);this.findAtPoint(t,i)}findPlace(t){let n,s;for(let i=this.open;i>=0;i--){let a=this.nodes[i],l=a.findWrapping(t);if(l&&(!n||n.length>l.length)&&(n=l,s=a,!l.length)||a.solid)break}if(!n)return!1;this.sync(s);for(let i=0;i<n.length;i++)this.enterInner(n[i],null,!1);return!0}insertNode(t){if(t.isInline&&this.needsBlock&&!this.top.type){let n=this.textblockFromContext();n&&this.enterInner(n)}if(this.findPlace(t)){this.closeExtra();let n=this.top;n.applyPending(t.type),n.match&&(n.match=n.match.matchType(t.type));let s=n.activeMarks;for(let i=0;i<t.marks.length;i++)(!n.type||n.type.allowsMarkType(t.marks[i].type))&&(s=t.marks[i].addToSet(s));return n.content.push(t.mark(s)),!0}return!1}enter(t,n,s){let i=this.findPlace(t.create(n));return i&&this.enterInner(t,n,!0,s),i}enterInner(t,n=null,s=!1,i){this.closeExtra();let a=this.top;a.applyPending(t),a.match=a.match&&a.match.matchType(t);let l=ep(t,i,a.options);a.options&Br&&a.content.length==0&&(l|=Br),this.nodes.push(new Vs(t,n,a.activeMarks,a.pendingMarks,s,null,l)),this.open++}closeExtra(t=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(t));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(t){for(let n=this.open;n>=0;n--)if(this.nodes[n]==t)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let t=0;for(let n=this.open;n>=0;n--){let s=this.nodes[n].content;for(let i=s.length-1;i>=0;i--)t+=s[i].nodeSize;n&&t++}return t}findAtPoint(t,n){if(this.find)for(let s=0;s<this.find.length;s++)this.find[s].node==t&&this.find[s].offset==n&&(this.find[s].pos=this.currentPos)}findInside(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&t.nodeType==1&&t.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(t,n,s){if(t!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&t.nodeType==1&&t.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(s?2:4)&&(this.find[i].pos=this.currentPos)}findInText(t){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==t&&(this.find[n].pos=this.currentPos-(t.nodeValue.length-this.find[n].offset))}matchesContext(t){if(t.indexOf("|")>-1)return t.split(/\s*\|\s*/).some(this.matchesContext,this);let n=t.split("/"),s=this.options.context,i=!this.isOpen&&(!s||s.parent.type==this.nodes[0].type),a=-(s?s.depth+1:0)+(i?0:1),l=(c,u)=>{for(;c>=0;c--){let d=n[c];if(d==""){if(c==n.length-1||c==0)continue;for(;u>=a;u--)if(l(c-1,u))return!0;return!1}else{let p=u>0||u==0&&i?this.nodes[u].type:s&&u>=a?s.node(u-a).type:null;if(!p||p.name!=d&&p.groups.indexOf(d)==-1)return!1;u--}}return!0};return l(n.length-1,this.open)}textblockFromContext(){let t=this.options.context;if(t)for(let n=t.depth;n>=0;n--){let s=t.node(n).contentMatchAt(t.indexAfter(n)).defaultType;if(s&&s.isTextblock&&s.defaultAttrs)return s}for(let n in this.parser.schema.nodes){let s=this.parser.schema.nodes[n];if(s.isTextblock&&s.defaultAttrs)return s}}addPendingMark(t){let n=vj(t,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=t.addToSet(this.top.pendingMarks)}removePendingMark(t,n){for(let s=this.open;s>=0;s--){let i=this.nodes[s];if(i.pendingMarks.lastIndexOf(t)>-1)i.pendingMarks=t.removeFromSet(i.pendingMarks);else{i.activeMarks=t.removeFromSet(i.activeMarks);let l=i.popFromStashMark(t);l&&i.type&&i.type.allowsMarkType(l.type)&&(i.activeMarks=l.addToSet(i.activeMarks))}if(i==n)break}}}function gj(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let s=t.nodeType==1?t.nodeName.toLowerCase():null;s&&Hd.hasOwnProperty(s)&&n?(n.appendChild(t),t=n):s=="li"?n=t:s&&(n=null)}}function xj(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function yj(e){let t=/\s*([\w-]+)\s*:\s*([^;]+)/g,n,s=[];for(;n=t.exec(e);)s.push(n[1],n[2].trim());return s}function np(e){let t={};for(let n in e)t[n]=e[n];return t}function bj(e,t){let n=t.schema.nodes;for(let s in n){let i=n[s];if(!i.allowsMarkType(e))continue;let a=[],l=c=>{a.push(c);for(let u=0;u<c.edgeCount;u++){let{type:d,next:p}=c.edge(u);if(d==t||a.indexOf(p)<0&&l(p))return!0}};if(l(i.contentMatch))return!0}}function vj(e,t){for(let n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}const rp=65535,sp=Math.pow(2,16);function _j(e,t){return e+t*sp}function ip(e){return e&rp}function jj(e){return(e-(e&rp))/sp}const ap=1,op=2,Ns=4,lp=8;class cp{constructor(t,n,s){this.pos=t,this.delInfo=n,this.recover=s}get deleted(){return(this.delInfo&lp)>0}get deletedBefore(){return(this.delInfo&(ap|Ns))>0}get deletedAfter(){return(this.delInfo&(op|Ns))>0}get deletedAcross(){return(this.delInfo&Ns)>0}}class mt{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&mt.empty)return mt.empty}recover(t){let n=0,s=ip(t);if(!this.inverted)for(let i=0;i<s;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[s*3]+n+jj(t)}mapResult(t,n=1){return this._map(t,n,!1)}map(t,n=1){return this._map(t,n,!0)}_map(t,n,s){let i=0,a=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?i:0);if(u>t)break;let d=this.ranges[c+a],p=this.ranges[c+l],h=u+d;if(t<=h){let f=d?t==u?-1:t==h?1:n:n,g=u+i+(f<0?0:p);if(s)return g;let y=t==(n<0?u:h)?null:_j(c/3,t-u),j=t==u?op:t==h?ap:Ns;return(n<0?t!=u:t!=h)&&(j|=lp),new cp(g,j,y)}i+=p-d}return s?t+i:new cp(t+i,0,null)}touches(t,n){let s=0,i=ip(n),a=this.inverted?2:1,l=this.inverted?1:2;for(let c=0;c<this.ranges.length;c+=3){let u=this.ranges[c]-(this.inverted?s:0);if(u>t)break;let d=this.ranges[c+a],p=u+d;if(t<=p&&c==i*3)return!0;s+=this.ranges[c+l]-d}return!1}forEach(t){let n=this.inverted?2:1,s=this.inverted?1:2;for(let i=0,a=0;i<this.ranges.length;i+=3){let l=this.ranges[i],c=l-(this.inverted?a:0),u=l+(this.inverted?0:a),d=this.ranges[i+n],p=this.ranges[i+s];t(c,c+d,u,u+p),a+=p-d}}invert(){return new mt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?mt.empty:new mt(t<0?[0,-t,0]:[0,0,t])}}mt.empty=new mt([]);const ro=Object.create(null);class et{getMap(){return mt.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let s=ro[n.stepType];if(!s)throw new RangeError(`No step type ${n.stepType} defined`);return s.fromJSON(t,n)}static jsonID(t,n){if(t in ro)throw new RangeError("Duplicate use of step JSON ID "+t);return ro[t]=n,n.prototype.jsonID=t,n}}class ke{constructor(t,n){this.doc=t,this.failed=n}static ok(t){return new ke(t,null)}static fail(t){return new ke(null,t)}static fromReplace(t,n,s,i){try{return ke.ok(t.replace(n,s,i))}catch(a){if(a instanceof hj)return ke.fail(a.message);throw a}}}function so(e,t,n){let s=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(so(a.content,t,a))),a.isInline&&(a=t(a,n,i)),s.push(a)}return H.fromArray(s)}class kn extends et{constructor(t,n,s){super(),this.from=t,this.to=n,this.mark=s}apply(t){let n=t.slice(this.from,this.to),s=t.resolve(this.from),i=s.node(s.sharedDepth(this.to)),a=new re(so(n.content,(l,c)=>!l.isAtom||!c.type.allowsMarkType(this.mark.type)?l:l.mark(this.mark.addToSet(l.marks)),i),n.openStart,n.openEnd);return ke.fromReplace(t,this.from,this.to,a)}invert(){return new Tn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new kn(n.pos,s.pos,this.mark)}merge(t){return t instanceof kn&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new kn(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new kn(n.from,n.to,t.markFromJSON(n.mark))}}et.jsonID("addMark",kn);class Tn extends et{constructor(t,n,s){super(),this.from=t,this.to=n,this.mark=s}apply(t){let n=t.slice(this.from,this.to),s=new re(so(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),t),n.openStart,n.openEnd);return ke.fromReplace(t,this.from,this.to,s)}invert(){return new kn(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deleted&&s.deleted||n.pos>=s.pos?null:new Tn(n.pos,s.pos,this.mark)}merge(t){return t instanceof Tn&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Tn(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Tn(n.from,n.to,t.markFromJSON(n.mark))}}et.jsonID("removeMark",Tn);class Dn extends et{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return ke.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return ke.fromReplace(t,this.pos,this.pos+1,new re(H.from(s),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let s=this.mark.addToSet(n.marks);if(s.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(s))return new Dn(this.pos,n.marks[i]);return new Dn(this.pos,this.mark)}}return new qr(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Dn(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Dn(n.pos,t.markFromJSON(n.mark))}}et.jsonID("addNodeMark",Dn);class qr extends et{constructor(t,n){super(),this.pos=t,this.mark=n}apply(t){let n=t.nodeAt(this.pos);if(!n)return ke.fail("No node at mark step's position");let s=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return ke.fromReplace(t,this.pos,this.pos+1,new re(H.from(s),0,n.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Dn(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new qr(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new qr(n.pos,t.markFromJSON(n.mark))}}et.jsonID("removeNodeMark",qr);class $t extends et{constructor(t,n,s,i=!1){super(),this.from=t,this.to=n,this.slice=s,this.structure=i}apply(t){return this.structure&&io(t,this.from,this.to)?ke.fail("Structure replace would overwrite content"):ke.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new mt([this.from,this.to-this.from,this.slice.size])}invert(t){return new $t(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1);return n.deletedAcross&&s.deletedAcross?null:new $t(n.pos,Math.max(n.pos,s.pos),this.slice)}merge(t){if(!(t instanceof $t)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?re.empty:new re(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new $t(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?re.empty:new re(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new $t(t.from,this.to,n,this.structure)}else return null}toJSON(){let t={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new $t(n.from,n.to,re.fromJSON(t,n.slice),!!n.structure)}}et.jsonID("replace",$t);class Mn extends et{constructor(t,n,s,i,a,l,c=!1){super(),this.from=t,this.to=n,this.gapFrom=s,this.gapTo=i,this.slice=a,this.insert=l,this.structure=c}apply(t){if(this.structure&&(io(t,this.from,this.gapFrom)||io(t,this.gapTo,this.to)))return ke.fail("Structure gap-replace would overwrite content");let n=t.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return ke.fail("Gap is not a flat range");let s=this.slice.insertAt(this.insert,n.content);return s?ke.fromReplace(t,this.from,this.to,s):ke.fail("Content does not fit in gap")}getMap(){return new mt([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new Mn(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),s=t.mapResult(this.to,-1),i=t.map(this.gapFrom,-1),a=t.map(this.gapTo,1);return n.deletedAcross&&s.deletedAcross||i<n.pos||a>s.pos?null:new Mn(n.pos,s.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let t={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(t.slice=this.slice.toJSON()),this.structure&&(t.structure=!0),t}static fromJSON(t,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Mn(n.from,n.to,n.gapFrom,n.gapTo,re.fromJSON(t,n.slice),n.insert,!!n.structure)}}et.jsonID("replaceAround",Mn);function io(e,t,n){let s=e.resolve(t),i=n-t,a=s.depth;for(;i>0&&a>0&&s.indexAfter(a)==s.node(a).childCount;)a--,i--;if(i>0){let l=s.node(a).maybeChild(s.indexAfter(a));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function wj(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function Cj(e){let n=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let s=e.depth;;--s){let i=e.$from.node(s),a=e.$from.index(s),l=e.$to.indexAfter(s);if(s<e.depth&&i.canReplace(a,l,n))return s;if(s==0||i.type.spec.isolating||!wj(i,a,l))break}return null}function $s(e,t,n=1,s){let i=e.resolve(t),a=i.depth-n,l=s&&s[s.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!l.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let d=i.depth-1,p=n-2;d>a;d--,p--){let h=i.node(d),f=i.index(d);if(h.type.spec.isolating)return!1;let g=h.content.cutByIndex(f,h.childCount),y=s&&s[p+1];y&&(g=g.replaceChild(0,y.type.create(y.attrs)));let j=s&&s[p]||h;if(!h.canReplace(f+1,h.childCount)||!j.type.validContent(g))return!1}let c=i.indexAfter(a),u=s&&s[0];return i.node(a).canReplaceWith(c,c,u?u.type:i.node(a+1).type)}function up(e,t){let n=e.resolve(t),s=n.index();return Sj(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(s,s+1)}function Sj(e,t){return!!(e&&t&&!e.isLeaf&&e.canAppend(t))}class Vr extends et{constructor(t,n,s){super(),this.pos=t,this.attr=n,this.value=s}apply(t){let n=t.nodeAt(this.pos);if(!n)return ke.fail("No node at attribute step's position");let s=Object.create(null);for(let a in n.attrs)s[a]=n.attrs[a];s[this.attr]=this.value;let i=n.type.create(s,null,n.marks);return ke.fromReplace(t,this.pos,this.pos+1,new re(H.from(i),0,n.isLeaf?0:1))}getMap(){return mt.empty}invert(t){return new Vr(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new Vr(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new Vr(n.pos,n.attr,n.value)}}et.jsonID("attr",Vr);let Nr=class extends Error{};Nr=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},Nr.prototype=Object.create(Error.prototype),Nr.prototype.constructor=Nr,Nr.prototype.name="TransformError";const ao=Object.create(null);class me{constructor(t,n,s){this.$anchor=t,this.$head=n,this.ranges=s||[new kj(t.min(n),t.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let t=this.ranges;for(let n=0;n<t.length;n++)if(t[n].$from.pos!=t[n].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(t,n=re.empty){let s=n.content.lastChild,i=null;for(let c=0;c<n.openEnd;c++)i=s,s=s.lastChild;let a=t.steps.length,l=this.ranges;for(let c=0;c<l.length;c++){let{$from:u,$to:d}=l[c],p=t.mapping.slice(a);t.replaceRange(p.map(u.pos),p.map(d.pos),c?re.empty:n),c==0&&hp(t,a,(s?s.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(t,n){let s=t.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:l,$to:c}=i[a],u=t.mapping.slice(s),d=u.map(l.pos),p=u.map(c.pos);a?t.deleteRange(d,p):(t.replaceRangeWith(d,p,n),hp(t,s,n.isInline?-1:1))}}static findFrom(t,n,s=!1){let i=t.parent.inlineContent?new Te(t):Hn(t.node(0),t.parent,t.pos,t.index(),n,s);if(i)return i;for(let a=t.depth-1;a>=0;a--){let l=n<0?Hn(t.node(0),t.node(a),t.before(a+1),t.index(a),n,s):Hn(t.node(0),t.node(a),t.after(a+1),t.index(a)+1,n,s);if(l)return l}return null}static near(t,n=1){return this.findFrom(t,n)||this.findFrom(t,-n)||new Zt(t.node(0))}static atStart(t){return Hn(t,t,0,0,1)||new Zt(t)}static atEnd(t){return Hn(t,t,t.content.size,t.childCount,-1)||new Zt(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=ao[n.type];if(!s)throw new RangeError(`No selection type ${n.type} defined`);return s.fromJSON(t,n)}static jsonID(t,n){if(t in ao)throw new RangeError("Duplicate use of selection JSON ID "+t);return ao[t]=n,n.prototype.jsonID=t,n}getBookmark(){return Te.between(this.$anchor,this.$head).getBookmark()}}me.prototype.visible=!0;class kj{constructor(t,n){this.$from=t,this.$to=n}}let dp=!1;function pp(e){!dp&&!e.parent.inlineContent&&(dp=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Te extends me{constructor(t,n=t){pp(t),pp(n),super(t,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let s=t.resolve(n.map(this.head));if(!s.parent.inlineContent)return me.near(s);let i=t.resolve(n.map(this.anchor));return new Te(i.parent.inlineContent?i:s,s)}replace(t,n=re.empty){if(super.replace(t,n),n==re.empty){let s=this.$from.marksAcross(this.$to);s&&t.ensureMarks(s)}}eq(t){return t instanceof Te&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new Fs(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Te(t.resolve(n.anchor),t.resolve(n.head))}static create(t,n,s=n){let i=t.resolve(n);return new this(i,s==n?i:t.resolve(s))}static between(t,n,s){let i=t.pos-n.pos;if((!s||i)&&(s=i>=0?1:-1),!n.parent.inlineContent){let a=me.findFrom(n,s,!0)||me.findFrom(n,-s,!0);if(a)n=a.$head;else return me.near(n,s)}return t.parent.inlineContent||(i==0?t=n:(t=(me.findFrom(t,-s,!0)||me.findFrom(t,s,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new Te(t,n)}}me.jsonID("text",Te);class Fs{constructor(t,n){this.anchor=t,this.head=n}map(t){return new Fs(t.map(this.anchor),t.map(this.head))}resolve(t){return Te.between(t.resolve(this.anchor),t.resolve(this.head))}}class it extends me{constructor(t){let n=t.nodeAfter,s=t.node(0).resolve(t.pos+n.nodeSize);super(t,s),this.node=n}map(t,n){let{deleted:s,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return s?me.near(a):new it(a)}content(){return new re(H.from(this.node),0,0)}eq(t){return t instanceof it&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new oo(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new it(t.resolve(n.anchor))}static create(t,n){return new it(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}it.prototype.visible=!1,me.jsonID("node",it);class oo{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:s}=t.mapResult(this.anchor);return n?new Fs(s,s):new oo(s)}resolve(t){let n=t.resolve(this.anchor),s=n.nodeAfter;return s&&it.isSelectable(s)?new it(n):me.near(n)}}class Zt extends me{constructor(t){super(t.resolve(0),t.resolve(t.content.size))}replace(t,n=re.empty){if(n==re.empty){t.delete(0,t.doc.content.size);let s=me.atStart(t.doc);s.eq(t.selection)||t.setSelection(s)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new Zt(t)}map(t){return new Zt(t)}eq(t){return t instanceof Zt}getBookmark(){return Tj}}me.jsonID("all",Zt);const Tj={map(){return this},resolve(e){return new Zt(e)}};function Hn(e,t,n,s,i,a=!1){if(t.inlineContent)return Te.create(e,n);for(let l=s-(i>0?0:1);i>0?l<t.childCount:l>=0;l+=i){let c=t.child(l);if(c.isAtom){if(!a&&it.isSelectable(c))return it.create(e,n-(i<0?c.nodeSize:0))}else{let u=Hn(e,c,n+i,i<0?c.childCount:0,i,a);if(u)return u}n+=c.nodeSize*i}return null}function hp(e,t,n){let s=e.steps.length-1;if(s<t)return;let i=e.steps[s];if(!(i instanceof $t||i instanceof Mn))return;let a=e.mapping.maps[s],l;a.forEach((c,u,d,p)=>{l==null&&(l=p)}),e.setSelection(me.near(e.doc.resolve(l),n))}function fp(e,t){return!t||!e?e:e.bind(t)}class Gs{constructor(t,n,s){this.name=t,this.init=fp(n.init,s),this.apply=fp(n.apply,s)}}new Gs("doc",{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new Gs("selection",{init(e,t){return e.selection||me.atStart(t.doc)},apply(e){return e.selection}}),new Gs("storedMarks",{init(e){return e.storedMarks||null},apply(e,t,n,s){return s.selection.$cursor?e.storedMarks:null}}),new Gs("scrollToSelection",{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}});function mp(e,t,n){for(let s in e){let i=e[s];i instanceof Function?i=i.bind(t):s=="handleDOMEvents"&&(i=mp(i,t,{})),n[s]=i}return n}class $r{constructor(t){this.spec=t,this.props={},t.props&&mp(t.props,this,this.props),this.key=t.key?t.key.key:gp("plugin")}getState(t){return t[this.key]}}const lo=Object.create(null);function gp(e){return e in lo?e+"$"+ ++lo[e]:(lo[e]=0,e+"$")}class Fr{constructor(t="key"){this.key=gp(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}function xp(e){const{state:t,transaction:n}=e;let{selection:s}=n,{doc:i}=n,{storedMarks:a}=n;return{...t,apply:t.apply.bind(t),applyTransaction:t.applyTransaction.bind(t),filterTransaction:t.filterTransaction,plugins:t.plugins,schema:t.schema,reconfigure:t.reconfigure.bind(t),toJSON:t.toJSON.bind(t),get storedMarks(){return a},get selection(){return s},get doc(){return i},get tr(){return s=n.selection,i=n.doc,a=n.storedMarks,n}}}class Dj{constructor(t){this.editor=t.editor,this.rawCommands=this.editor.extensionManager.commands,this.customState=t.state}get hasCustomState(){return!!this.customState}get state(){return this.customState||this.editor.state}get commands(){const{rawCommands:t,editor:n,state:s}=this,{view:i}=n,{tr:a}=s,l=this.buildProps(a);return Object.fromEntries(Object.entries(t).map(([c,u])=>[c,(...p)=>{const h=u(...p)(l);return!a.getMeta("preventDispatch")&&!this.hasCustomState&&i.dispatch(a),h}]))}get chain(){return()=>this.createChain()}get can(){return()=>this.createCan()}createChain(t,n=!0){const{rawCommands:s,editor:i,state:a}=this,{view:l}=i,c=[],u=!!t,d=t||a.tr,p=()=>(!u&&n&&!d.getMeta("preventDispatch")&&!this.hasCustomState&&l.dispatch(d),c.every(f=>f===!0)),h={...Object.fromEntries(Object.entries(s).map(([f,g])=>[f,(...j)=>{const k=this.buildProps(d,n),S=g(...j)(k);return c.push(S),h}])),run:p};return h}createCan(t){const{rawCommands:n,state:s}=this,i=!1,a=t||s.tr,l=this.buildProps(a,i);return{...Object.fromEntries(Object.entries(n).map(([u,d])=>[u,(...p)=>d(...p)({...l,dispatch:void 0})])),chain:()=>this.createChain(a,i)}}buildProps(t,n=!0){const{rawCommands:s,editor:i,state:a}=this,{view:l}=i;a.storedMarks&&t.setStoredMarks(a.storedMarks);const c={tr:t,editor:i,view:l,state:xp({state:a,transaction:t}),dispatch:n?()=>{}:void 0,chain:()=>this.createChain(t),can:()=>this.createCan(t),get commands(){return Object.fromEntries(Object.entries(s).map(([u,d])=>[u,(...p)=>d(...p)(c)]))}};return c}}function at(e,t,n){return e.config[t]===void 0&&e.parent?at(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?at(e.parent,t,n):null}):e.config[t]}function Mj(e){const t=e.filter(i=>i.type==="extension"),n=e.filter(i=>i.type==="node"),s=e.filter(i=>i.type==="mark");return{baseExtensions:t,nodeExtensions:n,markExtensions:s}}function $e(e,t){if(typeof e=="string"){if(!t.nodes[e])throw Error(`There is no node type named '${e}'. Maybe you forgot to add the extension?`);return t.nodes[e]}return e}function zj(e){return typeof e=="function"}function Dt(e,t=void 0,...n){return zj(e)?t?e.bind(t)(...n):e(...n):e}function Ij(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function Ej(e){return Object.prototype.toString.call(e).slice(8,-1)}function co(e){return Ej(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function uo(e,t){const n={...e};return co(e)&&co(t)&&Object.keys(t).forEach(s=>{co(t[s])?s in e?n[s]=uo(e[s],t[s]):Object.assign(n,{[s]:t[s]}):Object.assign(n,{[s]:t[s]})}),n}class Ft{constructor(t={}){this.type="extension",this.name="extension",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Dt(at(this,"addOptions",{name:this.name}))),this.storage=Dt(at(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Ft(t)}configure(t={}){const n=this.extend();return n.options=uo(this.options,t),n.storage=Dt(at(n,"addStorage",{name:n.name,options:n.options})),n}extend(t={}){const n=new Ft(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=Dt(at(n,"addOptions",{name:n.name})),n.storage=Dt(at(n,"addStorage",{name:n.name,options:n.options})),n}}function Aj(e,t,n){const{from:s,to:i}=t,{blockSeparator:a=`
131
131
 
132
- `,textSerializers:l={}}=n||{};let c="",u=!0;return t.nodesBetween(r,i,(d,p,h,g)=>{var f;const v=l==null?void 0:l[d.type.name];v?(d.isBlock&&!u&&(c+=o,u=!0),h&&(c+=v({node:d,pos:p,parent:h,index:g,range:e}))):d.isText?(c+=(f=d==null?void 0:d.text)===null||f===void 0?void 0:f.slice(Math.max(r,p)-p,i-p),u=!1):d.isBlock&&!u&&(c+=o,u=!0)}),c}function Qx(t){return Object.fromEntries(Object.entries(t.nodes).filter(([,e])=>e.spec.toText).map(([e,n])=>[e,n.spec.toText]))}ct.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new xn({key:new gn("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:o}=i,l=Math.min(...o.map(p=>p.$from.pos)),c=Math.max(...o.map(p=>p.$to.pos)),u=Qx(n);return Wx(r,{from:l,to:c},{textSerializers:u})}}})]}});const Rx=()=>({editor:t,view:e})=>(requestAnimationFrame(()=>{var n;t.isDestroyed||(e.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),Ux=(t=!1)=>({commands:e})=>e.setContent("",t),Yx=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:o,$to:l})=>{t.doc.nodesBetween(o.pos,l.pos,(c,u)=>{if(c.type.isText)return;const{doc:d,mapping:p}=e,h=d.resolve(p.map(u)),g=d.resolve(p.map(u+c.nodeSize)),f=h.blockRange(g);if(!f)return;const v=$x(f);if(c.type.isTextblock){const{defaultType:w}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(f.start,w)}(v||v===0)&&e.lift(f,v)})}),!0},Kx=t=>e=>t(e),Jx=()=>({state:t,dispatch:e})=>ve.createParagraphNear(t,e),Xx=()=>({tr:t,dispatch:e})=>{const{selection:n}=t,r=n.$anchor.node();if(r.content.size>0)return!1;const i=t.selection.$anchor;for(let o=i.depth;o>0;o-=1)if(i.node(o).type===r.type){if(e){const c=i.before(o),u=i.after(o);t.delete(c,u).scrollIntoView()}return!0}return!1},Zx=t=>({tr:e,state:n,dispatch:r})=>{const i=De(t,n.schema),o=e.selection.$anchor;for(let l=o.depth;l>0;l-=1)if(o.node(l).type===i){if(r){const u=o.before(l),d=o.after(l);e.delete(u,d).scrollIntoView()}return!0}return!1},Hx=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},eg=()=>({state:t,dispatch:e})=>ve.deleteSelection(t,e),tg=()=>({commands:t})=>t.keyboardShortcut("Enter"),ng=()=>({state:t,dispatch:e})=>ve.exitCode(t,e);function Yn(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Gx(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function hr(t,e,n={}){return t.find(r=>r.type===e&&Yn(r.attrs,n))}function sg(t,e,n={}){return!!hr(t,e,n)}function Co(t,e,n={}){if(!t||!e)return;let r=t.parent.childAfter(t.parentOffset);if(t.parentOffset===r.offset&&r.offset!==0&&(r=t.parent.childBefore(t.parentOffset)),!r.node)return;const i=hr([...r.node.marks],e,n);if(!i)return;let o=r.index,l=t.start()+r.offset,c=o+1,u=l+r.node.nodeSize;for(hr([...r.node.marks],e,n);o>0&&i.isInSet(t.parent.child(o-1).marks);)o-=1,l-=t.parent.child(o).nodeSize;for(;c<t.parent.childCount&&sg([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function kt(t,e){if(typeof t=="string"){if(!e.marks[t])throw Error(`There is no mark type named '${t}'. Maybe you forgot to add the extension?`);return e.marks[t]}return t}const rg=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const o=kt(t,r.schema),{doc:l,selection:c}=n,{$from:u,from:d,to:p}=c;if(i){const h=Co(u,o,e);if(h&&h.from<=d&&h.to>=p){const g=ye.create(l,h.from,h.to);n.setSelection(g)}}return!0},ig=t=>e=>{const n=typeof t=="function"?t(e):t;for(let r=0;r<n.length;r+=1)if(n[r](e))return!0;return!1};function So(t){return t instanceof ye}function Bt(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function ag(t,e=null){if(!e)return null;const n=oe.atStart(t),r=oe.atEnd(t);if(e==="start"||e===!0)return n;if(e==="end")return r;const i=n.from,o=r.to;return e==="all"?ye.create(t,Bt(0,i,o),Bt(t.content.size,i,o)):ye.create(t,Bt(e,i,o),Bt(e,i,o))}function mr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const og=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:o})=>{e={scrollIntoView:!0,...e};const l=()=>{mr()&&r.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(r.focus(),e!=null&&e.scrollIntoView&&n.commands.scrollIntoView())})};if(r.hasFocus()&&t===null||t===!1)return!0;if(o&&t===null&&!So(n.state.selection))return l(),!0;const c=ag(i.doc,t)||n.state.selection,u=n.state.selection.eq(c);return o&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),l()),!0},lg=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),cg=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e);function ko(t){const e=`<body>${t}</body>`;return new window.DOMParser().parseFromString(e,"text/html").body}function Kn(t,e,n){if(n={slice:!0,parseOptions:{},...n},typeof t=="object"&&t!==null)try{return Array.isArray(t)&&t.length>0?H.fromArray(t.map(r=>e.nodeFromJSON(r))):e.nodeFromJSON(t)}catch(r){return console.warn("[tiptap warn]: Invalid content.","Passed value:",t,"Error:",r),Kn("",e,n)}if(typeof t=="string"){const r=Vn.fromSchema(e);return n.slice?r.parseSlice(ko(t),n.parseOptions).content:r.parse(ko(t),n.parseOptions)}return Kn("",e,n)}function ug(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof lt||i instanceof $t))return;const o=t.mapping.maps[r];let l=0;o.forEach((c,u,d,p)=>{l===0&&(l=p)}),t.setSelection(oe.near(t.doc.resolve(l),n))}const dg=t=>t.toString().startsWith("<"),pg=(t,e,n)=>({tr:r,dispatch:i,editor:o})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};const l=Kn(e,o.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if(l.toString()==="<>")return!0;let{from:c,to:u}=typeof t=="number"?{from:t,to:t}:t,d=!0,p=!0;if((dg(l)?l:[l]).forEach(g=>{g.check(),d=d?g.isText&&g.marks.length===0:!1,p=p?g.isBlock:!1}),c===u&&p){const{parent:g}=r.doc.resolve(c);g.isTextblock&&!g.type.spec.code&&!g.childCount&&(c-=1,u+=1)}d?Array.isArray(e)?r.insertText(e.map(g=>g.text||"").join(""),c,u):typeof e=="object"&&e&&e.text?r.insertText(e.text,c,u):r.insertText(e,c,u):r.replaceWith(c,u,l),n.updateSelection&&ug(r,r.steps.length-1,-1)}return!0},hg=()=>({state:t,dispatch:e})=>ve.joinUp(t,e),mg=()=>({state:t,dispatch:e})=>ve.joinDown(t,e),xg=()=>({state:t,dispatch:e})=>ve.joinBackward(t,e),gg=()=>({state:t,dispatch:e})=>ve.joinForward(t,e);function To(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function fg(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,o,l;for(let c=0;c<e.length-1;c+=1){const u=e[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))r=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))o=!0;else if(/^mod$/i.test(u))mr()||To()?l=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return r&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),l&&(n=`Meta-${n}`),o&&(n=`Shift-${n}`),n}const yg=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const o=fg(t).split(/-(?!$)/),l=o.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),c=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:o.includes("Alt"),ctrlKey:o.includes("Ctrl"),metaKey:o.includes("Meta"),shiftKey:o.includes("Shift"),bubbles:!0,cancelable:!0}),u=e.captureTransaction(()=>{n.someProp("handleKeyDown",d=>d(n,c))});return u==null||u.steps.forEach(d=>{const p=d.map(r.mapping);p&&i&&r.maybeStep(p)}),!0};function xr(t,e,n={}){const{from:r,to:i,empty:o}=t.selection,l=e?De(e,t.schema):null,c=[];t.doc.nodesBetween(r,i,(h,g)=>{if(h.isText)return;const f=Math.max(r,g),v=Math.min(i,g+h.nodeSize);c.push({node:h,from:f,to:v})});const u=i-r,d=c.filter(h=>l?l.name===h.node.type.name:!0).filter(h=>Yn(h.node.attrs,n,{strict:!1}));return o?!!d.length:d.reduce((h,g)=>h+g.to-g.from,0)>=u}const bg=(t,e={})=>({state:n,dispatch:r})=>{const i=De(t,n.schema);return xr(n,i,e)?ve.lift(n,r):!1},vg=()=>({state:t,dispatch:e})=>ve.liftEmptyBlock(t,e),_g=t=>({state:e,dispatch:n})=>{const r=De(t,e.schema);return Cs.liftListItem(r)(e,n)},jg=()=>({state:t,dispatch:e})=>ve.newlineInCode(t,e);function Do(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function zo(t,e){const n=typeof e=="string"?[e]:e;return Object.keys(t).reduce((r,i)=>(n.includes(i)||(r[i]=t[i]),r),{})}const wg=(t,e)=>({tr:n,state:r,dispatch:i})=>{let o=null,l=null;const c=Do(typeof t=="string"?t:t.name,r.schema);return c?(c==="node"&&(o=De(t,r.schema)),c==="mark"&&(l=kt(t,r.schema)),i&&n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,p)=>{o&&o===d.type&&n.setNodeMarkup(p,void 0,zo(d.attrs,e)),l&&d.marks.length&&d.marks.forEach(h=>{l===h.type&&n.addMark(p,p+d.nodeSize,l.create(zo(h.attrs,e)))})})}),!0):!1},Cg=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),Sg=()=>({tr:t,commands:e})=>e.setTextSelection({from:0,to:t.doc.content.size}),kg=()=>({state:t,dispatch:e})=>ve.selectNodeBackward(t,e),Tg=()=>({state:t,dispatch:e})=>ve.selectNodeForward(t,e),Dg=()=>({state:t,dispatch:e})=>ve.selectParentNode(t,e),zg=()=>({state:t,dispatch:e})=>ve.selectTextblockEnd(t,e),Mg=()=>({state:t,dispatch:e})=>ve.selectTextblockStart(t,e);function Ig(t,e,n={}){return Kn(t,e,{slice:!1,parseOptions:n})}const Eg=(t,e=!1,n={})=>({tr:r,editor:i,dispatch:o})=>{const{doc:l}=r,c=Ig(t,i.schema,n);return o&&r.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!e),!0};function Ag(t){for(let e=0;e<t.edgeCount;e+=1){const{type:n}=t.edge(e);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function Pg(t,e){for(let n=t.depth;n>0;n-=1){const r=t.node(n);if(e(r))return{pos:n>0?t.before(n):0,start:t.start(n),depth:n,node:r}}}function gr(t){return e=>Pg(e.$from,t)}function $g(t,e){const n=kt(e,t.schema),{from:r,to:i,empty:o}=t.selection,l=[];o?(t.storedMarks&&l.push(...t.storedMarks),l.push(...t.selection.$head.marks())):t.doc.nodesBetween(r,i,u=>{l.push(...u.marks)});const c=l.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function Jn(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(o=>o.type===e&&o.name===r);return i?i.attribute.keepOnSplit:!1}))}function Bg(t,e,n={}){const{empty:r,ranges:i}=t.selection,o=e?kt(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>o?o.name===h.type.name:!0).find(h=>Yn(h.attrs,n,{strict:!1}));let l=0;const c=[];if(i.forEach(({$from:h,$to:g})=>{const f=h.pos,v=g.pos;t.doc.nodesBetween(f,v,(w,T)=>{if(!w.isText&&!w.marks.length)return;const D=Math.max(f,T),z=Math.min(v,T+w.nodeSize),E=z-D;l+=E,c.push(...w.marks.map(V=>({mark:V,from:D,to:z})))})}),l===0)return!1;const u=c.filter(h=>o?o.name===h.mark.type.name:!0).filter(h=>Yn(h.mark.attrs,n,{strict:!1})).reduce((h,g)=>h+g.to-g.from,0),d=c.filter(h=>o?h.mark.type!==o&&h.mark.type.excludes(o):!0).reduce((h,g)=>h+g.to-g.from,0);return(u>0?u+d:u)>=l}function Mo(t,e){const{nodeExtensions:n}=Vx(e),r=n.find(l=>l.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},o=Ut(St(r,"group",i));return typeof o!="string"?!1:o.split(" ").includes("list")}function Lg(t,e,n){var r;const{selection:i}=e;let o=null;if(So(i)&&(o=i.$cursor),o){const c=(r=t.storedMarks)!==null&&r!==void 0?r:o.marks();return!!n.isInSet(c)||!c.some(u=>u.type.excludes(n))}const{ranges:l}=i;return l.some(({$from:c,$to:u})=>{let d=c.depth===0?t.doc.inlineContent&&t.doc.type.allowsMarkType(n):!1;return t.doc.nodesBetween(c.pos,u.pos,(p,h,g)=>{if(d)return!1;if(p.isInline){const f=!g||g.type.allowsMarkType(n),v=!!n.isInSet(p.marks)||!p.marks.some(w=>w.type.excludes(n));d=f&&v}return!d}),d})}const qg=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:o}=n,{empty:l,ranges:c}=o,u=kt(t,r.schema);if(i)if(l){const d=$g(r,u);n.addStoredMark(u.create({...d,...e}))}else c.forEach(d=>{const p=d.$from.pos,h=d.$to.pos;r.doc.nodesBetween(p,h,(g,f)=>{const v=Math.max(f,p),w=Math.min(f+g.nodeSize,h);g.marks.find(D=>D.type===u)?g.marks.forEach(D=>{u===D.type&&n.addMark(v,w,u.create({...D.attrs,...e}))}):n.addMark(v,w,u.create(e))})});return Lg(r,n,u)},Og=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),Vg=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const o=De(t,n.schema);return o.isTextblock?i().command(({commands:l})=>ve.setBlockType(o,e)(n)?!0:l.clearNodes()).command(({state:l})=>ve.setBlockType(o,e)(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Ng=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=Bt(t,0,r.content.size),o=Ne.create(r,i);e.setSelection(o)}return!0},Gg=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:o}=typeof t=="number"?{from:t,to:t}:t,l=ye.atStart(r).from,c=ye.atEnd(r).to,u=Bt(i,l,c),d=Bt(o,l,c),p=ye.create(r,u,d);e.setSelection(p)}return!0},Fg=t=>({state:e,dispatch:n})=>{const r=De(t,e.schema);return Cs.sinkListItem(r)(e,n)};function Io(t,e){const n=t.storedMarks||t.selection.$to.parentOffset&&t.selection.$from.marks();if(n){const r=n.filter(i=>e==null?void 0:e.includes(i.type.name));t.tr.ensureMarks(r)}}const Wg=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:o,doc:l}=e,{$from:c,$to:u}=o,d=i.extensionManager.attributes,p=Jn(d,c.node().type.name,c.node().attrs);if(o instanceof Ne&&o.node.isBlock)return!c.parentOffset||!Qn(l,c.pos)?!1:(r&&(t&&Io(n,i.extensionManager.splittableMarks),e.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;if(r){const h=u.parentOffset===u.parent.content.size;o instanceof ye&&e.deleteSelection();const g=c.depth===0?void 0:Ag(c.node(-1).contentMatchAt(c.indexAfter(-1)));let f=h&&g?[{type:g,attrs:p}]:void 0,v=Qn(e.doc,e.mapping.map(c.pos),1,f);if(!f&&!v&&Qn(e.doc,e.mapping.map(c.pos),1,g?[{type:g}]:void 0)&&(v=!0,f=g?[{type:g,attrs:p}]:void 0),v&&(e.split(e.mapping.map(c.pos),1,f),g&&!h&&!c.parentOffset&&c.parent.type!==g)){const w=e.mapping.map(c.before()),T=e.doc.resolve(w);c.node(-1).canReplaceWith(T.index(),T.index()+1,g)&&e.setNodeMarkup(e.mapping.map(c.before()),g)}t&&Io(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},Qg=t=>({tr:e,state:n,dispatch:r,editor:i})=>{var o;const l=De(t,n.schema),{$from:c,$to:u}=n.selection,d=n.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const p=c.node(-1);if(p.type!==l)return!1;const h=i.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(r){let T=H.empty;const D=c.index(-1)?1:c.index(-2)?2:3;for(let Q=c.depth-D;Q>=c.depth-3;Q-=1)T=H.from(c.node(Q).copy(T));const z=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,E=Jn(h,c.node().type.name,c.node().attrs),V=((o=l.contentMatch.defaultType)===null||o===void 0?void 0:o.createAndFill(E))||void 0;T=T.append(H.from(l.createAndFill(null,V)||void 0));const F=c.before(c.depth-(D-1));e.replace(F,c.after(-z),new ne(T,4-D,0));let N=-1;e.doc.nodesBetween(F,e.doc.content.size,(Q,ue)=>{if(N>-1)return!1;Q.isTextblock&&Q.content.size===0&&(N=ue+1)}),N>-1&&e.setSelection(ye.near(e.doc.resolve(N))),e.scrollIntoView()}return!0}const g=u.pos===c.end()?p.contentMatchAt(0).defaultType:null,f=Jn(h,p.type.name,p.attrs),v=Jn(h,c.node().type.name,c.node().attrs);e.delete(c.pos,u.pos);const w=g?[{type:l,attrs:f},{type:g,attrs:v}]:[{type:l,attrs:f}];if(!Qn(e.doc,c.pos,2))return!1;if(r){const{selection:T,storedMarks:D}=n,{splittableMarks:z}=i.extensionManager,E=D||T.$to.parentOffset&&T.$from.marks();if(e.split(c.pos,2,w).scrollIntoView(),!E||!r)return!0;const V=E.filter(F=>z.includes(F.type.name));e.ensureMarks(V)}return!0},fr=(t,e)=>{const n=gr(l=>l.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&xo(t.doc,n.pos)&&t.join(n.pos),!0},yr=(t,e)=>{const n=gr(l=>l.type===e)(t.selection);if(!n)return!0;const r=t.doc.resolve(n.start).after(n.depth);if(r===void 0)return!0;const i=t.doc.nodeAt(r);return n.node.type===(i==null?void 0:i.type)&&xo(t.doc,r)&&t.join(r),!0};var Rg=Object.freeze({__proto__:null,blur:Rx,clearContent:Ux,clearNodes:Yx,command:Kx,createParagraphNear:Jx,deleteCurrentNode:Xx,deleteNode:Zx,deleteRange:Hx,deleteSelection:eg,enter:tg,exitCode:ng,extendMarkRange:rg,first:ig,focus:og,forEach:lg,insertContent:cg,insertContentAt:pg,joinUp:hg,joinDown:mg,joinBackward:xg,joinForward:gg,keyboardShortcut:yg,lift:bg,liftEmptyBlock:vg,liftListItem:_g,newlineInCode:jg,resetAttributes:wg,scrollIntoView:Cg,selectAll:Sg,selectNodeBackward:kg,selectNodeForward:Tg,selectParentNode:Dg,selectTextblockEnd:zg,selectTextblockStart:Mg,setContent:Eg,setMark:qg,setMeta:Og,setNode:Vg,setNodeSelection:Ng,setTextSelection:Gg,sinkListItem:Fg,splitBlock:Wg,splitListItem:Qg,toggleList:(t,e,n,r={})=>({editor:i,tr:o,state:l,dispatch:c,chain:u,commands:d,can:p})=>{const{extensions:h,splittableMarks:g}=i.extensionManager,f=De(t,l.schema),v=De(e,l.schema),{selection:w,storedMarks:T}=l,{$from:D,$to:z}=w,E=D.blockRange(z),V=T||w.$to.parentOffset&&w.$from.marks();if(!E)return!1;const F=gr(N=>Mo(N.type.name,h))(w);if(E.depth>=1&&F&&E.depth-F.depth<=1){if(F.node.type===f)return d.liftListItem(v);if(Mo(F.node.type.name,h)&&f.validContent(F.node.content)&&c)return u().command(()=>(o.setNodeMarkup(F.pos,f),!0)).command(()=>fr(o,f)).command(()=>yr(o,f)).run()}return!n||!V||!c?u().command(()=>p().wrapInList(f,r)?!0:d.clearNodes()).wrapInList(f,r).command(()=>fr(o,f)).command(()=>yr(o,f)).run():u().command(()=>{const N=p().wrapInList(f,r),Q=V.filter(ue=>g.includes(ue.type.name));return o.ensureMarks(Q),N?!0:d.clearNodes()}).wrapInList(f,r).command(()=>fr(o,f)).command(()=>yr(o,f)).run()},toggleMark:(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:o=!1}=n,l=kt(t,r.schema);return Bg(r,l,e)?i.unsetMark(l,{extendEmptyMarkRange:o}):i.setMark(l,e)},toggleNode:(t,e,n={})=>({state:r,commands:i})=>{const o=De(t,r.schema),l=De(e,r.schema);return xr(r,o,n)?i.setNode(l):i.setNode(o,n)},toggleWrap:(t,e={})=>({state:n,commands:r})=>{const i=De(t,n.schema);return xr(n,i,e)?r.lift(i):r.wrapIn(i,e)},undoInputRule:()=>({state:t,dispatch:e})=>{const n=t.plugins;for(let r=0;r<n.length;r+=1){const i=n[r];let o;if(i.spec.isInputRules&&(o=i.getState(t))){if(e){const l=t.tr,c=o.transform;for(let u=c.steps.length-1;u>=0;u-=1)l.step(c.steps[u].invert(c.docs[u]));if(o.text){const u=l.doc.resolve(o.from).marks();l.replaceWith(o.from,o.to,t.schema.text(o.text,u))}else l.delete(o.from,o.to)}return!0}}return!1},unsetAllMarks:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(o=>{t.removeMark(o.$from.pos,o.$to.pos)}),!0},unsetMark:(t,e={})=>({tr:n,state:r,dispatch:i})=>{var o;const{extendEmptyMarkRange:l=!1}=e,{selection:c}=n,u=kt(t,r.schema),{$from:d,empty:p,ranges:h}=c;if(!i)return!0;if(p&&l){let{from:g,to:f}=c;const v=(o=d.marks().find(T=>T.type===u))===null||o===void 0?void 0:o.attrs,w=Co(d,u,v);w&&(g=w.from,f=w.to),n.removeMark(g,f,u)}else h.forEach(g=>{n.removeMark(g.$from.pos,g.$to.pos,u)});return n.removeStoredMark(u),!0},updateAttributes:(t,e={})=>({tr:n,state:r,dispatch:i})=>{let o=null,l=null;const c=Do(typeof t=="string"?t:t.name,r.schema);return c?(c==="node"&&(o=De(t,r.schema)),c==="mark"&&(l=kt(t,r.schema)),i&&n.selection.ranges.forEach(u=>{const d=u.$from.pos,p=u.$to.pos;r.doc.nodesBetween(d,p,(h,g)=>{o&&o===h.type&&n.setNodeMarkup(g,void 0,{...h.attrs,...e}),l&&h.marks.length&&h.marks.forEach(f=>{if(l===f.type){const v=Math.max(g,d),w=Math.min(g+h.nodeSize,p);n.addMark(v,w,l.create({...f.attrs,...e}))}})})}),!0):!1},wrapIn:(t,e={})=>({state:n,dispatch:r})=>{const i=De(t,n.schema);return ve.wrapIn(i,e)(n,r)},wrapInList:(t,e={})=>({state:n,dispatch:r})=>{const i=De(t,n.schema);return Cs.wrapInList(i,e)(n,r)}});ct.create({name:"commands",addCommands(){return{...Rg}}}),ct.create({name:"editable",addProseMirrorPlugins(){return[new xn({key:new gn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),ct.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new xn({key:new gn("focusEvents"),props:{handleDOMEvents:{focus:(e,n)=>{t.isFocused=!0;const r=t.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1},blur:(e,n)=>{t.isFocused=!1;const r=t.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return e.dispatch(r),!1}}}})]}}),ct.create({name:"keymap",addKeyboardShortcuts(){const t=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:u,doc:d}=c,{empty:p,$anchor:h}=u,{pos:g,parent:f}=h,v=oe.atStart(d).from===g;return!p||!v||!f.type.isTextblock||f.textContent.length?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),e=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),r={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:t,"Mod-Backspace":t,"Shift-Backspace":t,Delete:e,"Mod-Delete":e,"Mod-a":()=>this.editor.commands.selectAll()},i={...r},o={...r,"Ctrl-h":t,"Alt-Backspace":t,"Ctrl-d":e,"Ctrl-Alt-Backspace":e,"Alt-Delete":e,"Alt-d":e,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return mr()||To()?o:i},addProseMirrorPlugins(){return[new xn({key:new gn("clearDocument"),appendTransaction:(t,e,n)=>{if(!(t.some(v=>v.docChanged)&&!e.doc.eq(n.doc)))return;const{empty:i,from:o,to:l}=e.selection,c=oe.atStart(e.doc).from,u=oe.atEnd(e.doc).to;if(i||!(o===c&&l===u)||!(n.doc.textBetween(0,n.doc.content.size," "," ").length===0))return;const h=n.tr,g=jo({state:n,transaction:h}),{commands:f}=new Ox({editor:this.editor,state:g});if(f.clearNodes(),!!h.steps.length)return h}})]}}),ct.create({name:"tabindex",addProseMirrorPlugins(){return[new xn({key:new gn("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});const Eo=ct.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:t=>t.style.fontSize.replace(/['"]+/g,""),renderHTML:t=>t.fontSize?{style:`font-size: ${t.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:t=>({chain:e})=>e().setMark("textStyle",{fontSize:t}).run(),unsetFontSize:()=>({chain:t})=>t().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Ug=["8","10","12","14","16","18","20","24","30","36","48","60","72"].map(t=>`${t}px`),Yg=[{label:"auto",value:""}].concat(Ug.map(t=>({label:t,value:t}))),Kg={input:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"}},Jg=({editor:t})=>{const e=t.getAttributes("textStyle").fontSize;return s.jsx(R.RichTextEditor.ControlsGroup,{children:s.jsx(a.NativeSelect,{size:"xs",icon:s.jsx(k.IconTextSize,{stroke:1.5,size:16}),data:Yg,styles:Kg,value:e||"",onChange:n=>{const r=n.currentTarget.value;r?t.chain().focus().setFontSize(r).run():t.chain().focus().unsetFontSize().run()}})})},Xn=({value:t,styles:e={},sx:n={}})=>{const r=oa.useEditor({extensions:[la,aa,R.Link,Hi,Zi,Ji,na.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),ia,ra,sa,ea.configure({types:["heading","paragraph"]}),Xi.configure({placeholder:"This is placeholder"}),ta,Ki.Color,Eo],content:t,editable:!1});m.useEffect(()=>{r==null||r.commands.setContent(t)},[t,r]);const i=m.useMemo(()=>b.defaultsDeep({},{content:sr},e),[e]);return s.jsx(R.RichTextEditor,{editor:r,styles:i,sx:n,children:s.jsx(R.RichTextEditor.Content,{})})};function Ao(){const{t}=_.useTranslation(),[e,{open:n,close:r}]=ie.useDisclosure(!1);return s.jsxs(s.Fragment,{children:[s.jsx(a.Modal,{opened:e,onClose:r,title:t("function_utils.modal_title"),zIndex:330,withinPortal:!0,children:s.jsx(Xn,{value:Dd(t),styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),s.jsx(a.Button,{variant:"light",color:"violet",size:"xs",onClick:n,leftIcon:s.jsx(k.IconInfoCircle,{size:16}),children:t("function_utils.trigger_text")})]})}const Xg=({value:t,onChange:e})=>{const n=r=>{if(!r){e("");return}e(r)};return s.jsx(a.Box,{sx:{position:"relative",flexGrow:1},children:s.jsx(Le,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:t,onChange:n,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}}})})},Yt=m.forwardRef(({value:t,onChange:e,label:n,defaultValue:r},i)=>{const{t:o}=_.useTranslation(),[l,c]=m.useState(t),u=()=>{e(l)},d=()=>{c(t)},p=()=>{c(r)};m.useEffect(()=>{c(t)},[t]);const h=l!==t;return s.jsxs(a.Stack,{spacing:4,sx:{height:"100%"},children:[s.jsxs(a.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[s.jsx(a.Group,{position:"left",children:s.jsx(Ao,{})}),s.jsxs(a.Group,{position:"right",children:[s.jsx(a.Button,{onClick:p,size:"xs",variant:"default",leftIcon:s.jsx(k.IconPlayerSkipBack,{size:16}),children:o("common.actions.reset_to_default")}),s.jsx(a.Button,{onClick:d,color:"red",size:"xs",disabled:!h,leftIcon:s.jsx(k.IconRecycle,{size:16}),children:o("common.actions.revert_changes")}),s.jsx(a.Button,{color:"green",size:"xs",onClick:u,disabled:!h,leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),children:o("common.actions.save_changes")})]})]}),s.jsx(a.Text,{size:14,children:n}),s.jsx(Xg,{value:l,onChange:c})]})}),Po=m.forwardRef(({title:t,value:e,onChange:n,label:r,description:i=null,triggerLabel:o="Edit",triggerButtonProps:l={},defaultValue:c},u)=>{const[d,{open:p,close:h}]=ie.useDisclosure(!1);return s.jsxs(s.Fragment,{children:[s.jsxs(a.Modal,{opened:d,onClose:h,title:t,withinPortal:!0,zIndex:320,size:"900px",children:[i,s.jsx(a.Box,{h:600,children:s.jsx(Yt,{value:e,onChange:n,defaultValue:c,label:r})})]}),s.jsx(a.Button,{onClick:p,...l,children:o})]})});function Zg({label:t,value:e,onChange:n,pt:r="sm",withFallback:i},o){const{t:l,i18n:c}=_.useTranslation();m.useEffect(()=>{typeof e=="string"&&n({type:e,config:{},fallback:"0"})},[e,n]);const u=v=>{switch(v){case"quantile":return n({type:"quantile",config:{p:.99},fallback:e.fallback});case"custom":return n({type:"custom",config:{func:ba},fallback:e.fallback});case"pick_record":return n({type:"pick_record",config:{method:"first"},fallback:e.fallback});default:return n({type:v,config:{},fallback:e.fallback})}},d=v=>{n({type:"quantile",config:{p:v},fallback:e.fallback})},p=v=>{n({type:"custom",config:{func:v},fallback:e.fallback})},h=v=>{n({type:"pick_record",config:{method:v},fallback:e.fallback})},g=v=>{n({...e,fallback:v.currentTarget.value})},f=m.useMemo(()=>[{label:l("aggregation.option.none"),value:"none"},{label:l("aggregation.option.sum"),value:"sum"},{label:l("aggregation.option.min"),value:"min"},{label:l("aggregation.option.mean"),value:"mean"},{label:l("aggregation.option.median"),value:"median"},{label:l("aggregation.option.max"),value:"max"},{label:l("aggregation.option.cov"),value:"CV"},{label:l("aggregation.option.std"),value:"std"},{label:l("aggregation.option.quantile.label_with_hint"),value:"quantile"},{label:l("aggregation.option.pick_record.label"),value:"pick_record"},{label:l("aggregation.option.custom.label"),value:"custom"}],[c.language]);return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,pt:r,children:[s.jsx(a.Select,{ref:o,label:t,data:f,value:e.type,onChange:u,maxDropdownHeight:600}),e.type==="quantile"&&s.jsx(a.NumberInput,{label:"p",value:e.config.p,onChange:d,precision:2,min:.05,step:.05,max:1}),e.type==="pick_record"&&s.jsx(a.Select,{label:l("aggregation.option.pick_record.method.label"),value:e.config.method,onChange:h,data:[{label:l("aggregation.option.pick_record.method.first"),value:"first"},{label:l("aggregation.option.pick_record.method.last"),value:"last"}]}),e.type==="custom"&&s.jsx(Po,{title:l("aggregation.option.custom.title"),label:"",triggerLabel:l("aggregation.option.custom.label_trigger"),value:e.config.func,onChange:p,defaultValue:ba,triggerButtonProps:{size:"xs",sx:{flexGrow:0,alignSelf:"center",marginTop:"22px"},leftIcon:s.jsx(k.IconMathFunction,{size:16}),color:"grape"}})]}),i&&s.jsx(a.TextInput,{label:l("panel.variable.aggregation.fallback_value"),description:l("panel.variable.aggregation.fallback_value_description"),value:e.fallback,onChange:g})]})}const br=m.forwardRef(Zg),Kt=m.forwardRef(({label:t,value:e,onChange:n,options:r,withOffOption:i=!1},o)=>{const{t:l,i18n:c}=_.useTranslation(),u=m.useMemo(()=>{if(r)return r;const d=[{label:l("chart.label_position.top"),value:"top"},{label:l("chart.label_position.left"),value:"left"},{label:l("chart.label_position.right"),value:"right"},{label:l("chart.label_position.bottom"),value:"bottom"},{label:l("chart.label_position.outside"),value:"outside"},{label:l("chart.label_position.inside"),value:"inside"},{label:l("chart.label_position.inside_left"),value:"insideLeft"},{label:l("chart.label_position.inside_right"),value:"insideRight"},{label:l("chart.label_position.inside_top"),value:"insideTop"},{label:l("chart.label_position.inside_bottom"),value:"insideBottom"},{label:l("chart.label_position.inside_top_left"),value:"insideTopLeft"},{label:l("chart.label_position.inside_bottom_left"),value:"insideBottomLeft"},{label:l("chart.label_position.inside_top_right"),value:"insideTopRight"},{label:l("chart.label_position.inside_bottom_right"),value:"insideBottomRight"}];return i&&d.unshift({label:l("chart.label_position.off"),value:""}),d},[c.language,r,i]);return s.jsx(a.Select,{ref:o,label:t,data:u,value:e,onChange:n})});function Hg({control:t,index:e,seriesItem:n}){const{t:r,i18n:i}=_.useTranslation(),o=!!n.barWidth.trim(),l=m.useMemo(()=>[{label:r("chart.series.bar.bar_gap.no_gap"),value:"0%"},{label:r("chart.series.bar.bar_gap.overlap"),value:"-100%"}],[i.language]);return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${e}.stack`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:r("chart.series.bar.stack"),placeholder:r("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),s.jsx(y.Controller,{name:`series.${e}.barGap`,control:t,render:({field:c})=>s.jsx(a.Select,{label:r("chart.series.bar.bar_gap.label"),data:l,sx:{flexGrow:1},...c})})]}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${e}.barMinWidth`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:r("chart.series.bar.bar_width.min"),disabled:o,sx:{flexGrow:1},...c})}),s.jsx(y.Controller,{name:`series.${e}.barWidth`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:r("chart.series.bar.bar_width.exact"),sx:{flexGrow:1},...c})}),s.jsx(y.Controller,{name:`series.${e}.barMaxWidth`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:r("chart.series.bar.bar_width.max"),disabled:o,sx:{flexGrow:1},...c})})]})]})}function ef({control:t,index:e,seriesItem:n}){const{t:r,i18n:i}=_.useTranslation(),o=n.showSymbol,l=m.useMemo(()=>[{label:r("chart.series.line.step.off"),value:"false"},{label:r("chart.series.line.step.start"),value:"start"},{label:r("chart.series.line.step.middle"),value:"middle"},{label:r("chart.series.line.step.end"),value:"end"}],[i.language]);return s.jsxs(s.Fragment,{children:[s.jsx(a.Divider,{mb:-15,variant:"dashed",label:r("chart.series.line.line_settings"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:`series.${e}.lineStyle.type`,control:t,render:({field:c})=>s.jsx(Qt,{sx:{flexGrow:1},...c})}),s.jsx(y.Controller,{name:`series.${e}.lineStyle.width`,control:t,render:({field:c})=>s.jsx(a.NumberInput,{label:r("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),s.jsxs(a.Group,{grow:!0,align:"center",children:[s.jsx(y.Controller,{name:`series.${e}.step`,control:t,render:({field:c})=>s.jsx(a.Select,{label:r("chart.series.line.step.label"),data:l,sx:{flexGrow:1,maxWidth:"48%"},...c,value:String(c.value),onChange:u=>{const d=u==="false"?!1:u;c.onChange(d)}})}),s.jsxs(a.Stack,{children:[s.jsx(y.Controller,{name:`series.${e}.smooth`,control:t,render:({field:c})=>s.jsx(a.Box,{sx:{flexGrow:1},children:s.jsx(a.Switch,{label:r("chart.series.line.smooth_line"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})}),s.jsx(y.Controller,{name:`series.${e}.display_name_on_line`,control:t,render:({field:c})=>s.jsx(a.Box,{sx:{flexGrow:1},children:s.jsx(a.Switch,{label:r("chart.series.line.show_name_on_line"),checked:c.value??!1,onChange:u=>c.onChange(u.currentTarget.checked)})})})]})]}),s.jsxs(a.Stack,{children:[s.jsx(y.Controller,{name:`series.${e}.showSymbol`,control:t,render:({field:c})=>s.jsx(a.Box,{mt:10,mb:-10,sx:{flexGrow:1},children:s.jsx(a.Switch,{label:r("chart.series.line.show_symbol_on_line"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})}),o&&s.jsx(y.Controller,{name:`series.${e}.symbolSize`,control:t,render:({field:c})=>s.jsx(nr,{...c})})]})]})}function tf({control:t,index:e}){return s.jsx(y.Controller,{name:`series.${e}.symbolSize`,control:t,render:({field:n})=>s.jsx(nr,{label:"Size",...n})})}function nf({control:t,index:e,seriesItem:n,yAxisOptions:r}){const{t:i}=_.useTranslation(),o=n.type;return s.jsxs(a.Stack,{my:0,p:0,sx:{position:"relative"},children:[s.jsx(a.Stack,{children:s.jsx(y.Controller,{name:`series.${e}.type`,control:t,render:({field:l})=>s.jsx(a.SegmentedControl,{data:[{label:i("chart.series.line.label"),value:"line"},{label:i("chart.series.bar.label"),value:"bar"},{label:i("chart.series.scatter.label"),value:"scatter"}],...l})})}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${e}.name`,control:t,render:({field:l})=>s.jsx(a.TextInput,{label:i("chart.series.name"),required:!0,sx:{flex:1},...l})}),s.jsx(y.Controller,{name:`series.${e}.yAxisIndex`,control:t,render:({field:{value:l,onChange:c,...u}})=>s.jsx(a.Select,{label:i("chart.series.y_axis"),data:r,disabled:r.length===0,...u,value:(l==null?void 0:l.toString())??"",onChange:d=>{if(!d){c(0);return}c(Number(d))},sx:{flex:1}})})]}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${e}.y_axis_data_key`,control:t,render:({field:l})=>s.jsx(O,{label:i("chart.series.data_field"),required:!0,sx:{flex:1},...l})}),s.jsx(y.Controller,{name:`series.${e}.aggregation_on_value`,control:t,render:({field:l})=>s.jsx(br,{label:i("viz.cartesian_chart.series.aggregation.label"),value:l.value??Gt,onChange:l.onChange,pt:0,withFallback:!1})})]}),s.jsx(a.Group,{grow:!0,children:s.jsx(y.Controller,{name:`series.${e}.group_by_key`,control:t,render:({field:l})=>s.jsx(O,{label:i("chart.series.group_by.label"),clearable:!0,sx:{flex:1},...l})})}),o==="line"&&s.jsx(ef,{index:e,control:t,seriesItem:n}),o==="bar"&&s.jsx(Hg,{index:e,control:t,seriesItem:n}),o==="scatter"&&s.jsx(tf,{index:e,control:t}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.style.label"),labelPosition:"center"}),s.jsx(y.Controller,{name:`series.${e}.label_position`,control:t,render:({field:l})=>s.jsx(Kt,{label:i("chart.label_position.label"),withOffOption:!0,...l})}),s.jsxs(a.Stack,{spacing:4,children:[s.jsx(a.Text,{size:"sm",children:i("chart.color.label")}),s.jsx(y.Controller,{name:`series.${e}.color`,control:t,render:({field:l})=>s.jsx(Te,{...l})})]}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.behavior.label"),labelPosition:"center"}),s.jsx(y.Controller,{name:`series.${e}.hide_in_legend`,control:t,render:({field:l})=>s.jsx(a.Checkbox,{label:i("chart.legend.hide_in_legend"),checked:l.value,onChange:c=>l.onChange(c.currentTarget.checked)})})]})}function sf({control:t,watch:e}){const{t:n}=_.useTranslation(),r=()=>({type:"bar",name:ie.randomId(),showSymbol:!1,symbolSize:tr.static,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",display_name_on_line:!1,stack:"",color:"#000",step:!1,smooth:!1,barMinWidth:"1",barWidth:"10%",barMaxWidth:"10",barGap:"0%",lineStyle:{type:"solid",width:1},hide_in_legend:!1,group_by_key:""}),i=(c,u)=>{const d=c.name.trim();return d||u+1},o=e("y_axes"),l=m.useMemo(()=>o.map(({name:c},u)=>({label:c,value:u.toString()})),[o]);return s.jsx(ae,{control:t,watch:e,name:"series",getItem:r,addButtonText:n("chart.series.add"),deleteButtonText:n("chart.series.delete"),renderTabName:i,children:({field:c,index:u})=>s.jsx(nf,{control:t,index:u,seriesItem:c,yAxisOptions:l})})}function rf({control:t,watch:e}){const{t:n}=_.useTranslation();return e("stats"),s.jsx(a.Stack,{children:s.jsxs(a.Stack,{spacing:0,children:[s.jsx(y.Controller,{name:"stats.templates.top",control:t,render:({field:r})=>s.jsx(on,{label:n("chart.stats.template.above_chart"),py:"md",sx:{flexGrow:1},...r})}),s.jsx(y.Controller,{name:"stats.templates.bottom",control:t,render:({field:r})=>s.jsx(on,{label:n("chart.stats.template.under_chart"),py:"md",sx:{flexGrow:1},...r})})]})})}const af=({control:t,index:e})=>{const{t:n}=_.useTranslation();return s.jsx(a.Stack,{children:s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`tooltip.metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:`tooltip.metrics.${e}.data_key`,control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),required:!0,sx:{flex:1},...r})})]})})},of=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(o,l)=>{const c=o.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(a.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),s.jsx(ae,{control:t,watch:e,name:"tooltip.metrics",getItem:r,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:o,index:l})=>s.jsx(af,{control:t,index:l})})]})};function lf({control:t,watch:e}){return s.jsx(a.Stack,{children:s.jsx(of,{control:t,watch:e})})}const cf=()=>{const{t}=_.useTranslation();return s.jsxs(a.Group,{sx:{display:"inline-flex"},spacing:6,mr:14,children:[s.jsx(a.Text,{children:t("chart.x_axis.x_axis_type")}),s.jsxs(a.HoverCard,{width:340,shadow:"md",position:"top",children:[s.jsx(a.HoverCard.Target,{children:s.jsx(a.ActionIcon,{size:"xs",sx:{transform:"none !important"},children:s.jsx(k.IconInfoCircle,{})})}),s.jsx(a.HoverCard.Dropdown,{children:s.jsx(a.Text,{size:"sm",children:s.jsxs(_.Trans,{i18nKey:"chart.axis.type.click_to_learn_more",children:["Click",s.jsx(a.Anchor,{href:"https://echarts.apache.org/en/option.html#xAxis.type",target:"_blank",mx:3,children:"here"}),"to learn more about these options"]})})})]})]})};function uf({control:t,watch:e}){const{t:n,i18n:r}=_.useTranslation();e(["x_axis_data_key","x_axis_name","x_axis"]);const i=m.useMemo(()=>[{label:n("chart.axis.type.value"),value:"value"},{label:n("chart.axis.type.category"),value:"category"},{label:n("chart.axis.type.time"),value:"time"},{label:n("chart.axis.type.log"),value:"log"}],[r.language]);return s.jsxs(a.Stack,{children:[s.jsx(y.Controller,{name:"x_axis_name",control:t,render:({field:o})=>s.jsx(a.TextInput,{label:n("chart.x_axis.x_axis_name"),sx:{flex:1},...o})}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis_data_key",control:t,render:({field:o})=>s.jsx(O,{label:n("chart.x_axis.x_axis_data_field"),required:!0,sx:{flex:1},...o})}),s.jsx(y.Controller,{name:"x_axis.type",control:t,render:({field:o})=>s.jsx(a.Select,{label:s.jsx(cf,{}),required:!0,data:i,sx:{flex:1},...o})})]}),s.jsx(a.Divider,{mb:-15,label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:o})=>s.jsx(xt,{sx:{width:"48%"},...o})}),s.jsx(y.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:o})=>s.jsx(tt,{...o})})]}),s.jsx(y.Controller,{name:"x_axis.axisLabel.overflow",control:t,render:({field:o})=>s.jsx(nt,{...o})})]})}const Tt=m.forwardRef(({label:t,value:e,onChange:n,sx:r={},disabled:i},o)=>{const{t:l,i18n:c}=_.useTranslation(),u=m.useMemo(()=>[{label:l("chart.name_text.align.left"),value:"left"},{label:l("chart.name_text.align.center"),value:"center"},{label:l("chart.name_text.align.right"),value:"right"}],[c.language]);return s.jsx(a.Select,{ref:o,label:t??l("chart.name_text.align.label"),data:u,value:e,onChange:n,sx:r,disabled:i})}),$o=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},i)=>{const{t:o,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:o("chart.y_axis.position.left"),value:"left"},{label:o("chart.y_axis.position.right"),value:"right"}],[l.language]);return s.jsx(a.Select,{ref:i,label:t??o("chart.y_axis.position.label"),data:c,value:e,onChange:n,sx:r})});function df({control:t,index:e}){const{t:n}=_.useTranslation();return s.jsxs(a.Stack,{my:0,p:"0",sx:{position:"relative"},children:[s.jsx(a.Divider,{mb:-15,mt:15,variant:"dashed",label:n("common.name"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`y_axes.${e}.name`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("chart.y_axis.y_axis_name"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:`y_axes.${e}.nameAlignment`,control:t,render:({field:r})=>s.jsx(Tt,{sx:{flex:1},...r})})]}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.layout"),labelPosition:"center"}),s.jsx(a.Group,{grow:!0,noWrap:!0,children:s.jsx(y.Controller,{name:`y_axes.${e}.position`,control:t,render:({field:r})=>s.jsx($o,{sx:{flex:1},...r})})}),s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.label_format"),labelPosition:"center"}),s.jsx(y.Controller,{name:`y_axes.${e}.label_formatter`,control:t,render:({field:r})=>s.jsx(Re,{...r})})]}),s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.value_range"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:`y_axes.${e}.min`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("chart.y_axis.value_min"),...r})}),s.jsx(y.Controller,{name:`y_axes.${e}.max`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("chart.y_axis.value_max"),...r})})]})]}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:n("chart.y_axis.behavior"),labelPosition:"center"}),s.jsx(y.Controller,{name:`y_axes.${e}.show`,control:t,render:({field:r})=>s.jsx(a.Checkbox,{label:n("chart.y_axis.visible"),checked:r.value,onChange:i=>r.onChange(i.currentTarget.checked)})})]})}function pf({control:t,watch:e}){const{t:n}=_.useTranslation(),r=()=>({name:"",position:"left",nameAlignment:"left",label_formatter:_e,min:"",max:"",show:!0}),i=(l,c)=>{const u=l.name.trim();return u||c+1},o=({field:l,index:c,fields:u})=>u.length<=1;return s.jsx(ae,{control:t,watch:e,name:"y_axes",getItem:r,addButtonText:n("chart.y_axis.add"),deleteButtonText:n("chart.y_axis.delete"),renderTabName:i,deleteDisalbed:o,children:({field:l,index:c})=>s.jsx(df,{control:t,index:c})})}function hf({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),{variables:i}=t,o=m.useMemo(()=>b.defaultsDeep({},n,Zs),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=y.useForm({defaultValues:o});m.useEffect(()=>{p(o)},[o]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,o),[h,o]);return u(["dataZoom"]),s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:c(r),children:[s.jsx(ge,{canSubmit:g}),s.jsxs(a.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"X Axis",children:e("chart.x_axis.label")}),s.jsx(a.Tabs.Tab,{value:"Y Axes",children:e("chart.y_axis.labels")}),s.jsx(a.Tabs.Tab,{value:"Series",children:e("chart.series.label")}),s.jsx(a.Tabs.Tab,{value:"Regression Lines",children:e("chart.regression_line.labels")}),s.jsx(a.Tabs.Tab,{value:"Tooltip",children:e("chart.tooltip.label")}),s.jsx(a.Tabs.Tab,{value:"Stats",children:e("chart.stats.label")}),s.jsx(a.Tabs.Tab,{value:"Reference Lines",children:e("chart.reference_line.labels")}),s.jsx(a.Tabs.Tab,{value:"Reference Areas",children:e("chart.reference_area.labels")}),s.jsx(a.Tabs.Tab,{value:"Zooming",children:e("chart.zooming.label")})]}),s.jsx(a.Tabs.Panel,{value:"X Axis",children:s.jsx(uf,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Y Axes",children:s.jsx(pf,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Series",children:s.jsx(sf,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Regression Lines",children:s.jsx(vx,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Tooltip",children:s.jsx(lf,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Stats",children:s.jsx(rf,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Reference Lines",children:s.jsx(yx,{variables:i,control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Reference Areas",children:s.jsx(gx,{variables:i,control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Zooming",children:s.jsx(y.Controller,{name:"dataZoom",control:l,render:({field:f})=>s.jsx(Ln,{...f})})})]})]})})}function mf(t){const e=b.cloneDeep(b.omit(t,"variables"));return e.stats=b.omit(e.stats,"variables"),e}function xf(t){const{rotate:e,formatter:n=ke()}=t.x_axis.axisLabel;return{...t,x_axis:{...t.x_axis,axisLabel:{rotate:e,formatter:n}}}}function gf(t){const{dataZoom:e=Mt,...n}=t;return{...n,dataZoom:e}}function ff(t){const e={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return b.defaultsDeep(e,t)}function yf(t){const e=t.reference_lines.map(n=>{const{lineStyle:r={type:"dashed",width:1,color:dt.random().css()},show_in_legend:i=!1}=n;return{...n,lineStyle:r,show_in_legend:i}});return{...t,reference_lines:e}}function bf(t){const e=t.reference_lines.map(n=>{const{yAxisIndex:r=0}=n;return{...n,yAxisIndex:r}});return{...t,reference_lines:e}}function vf(t){const e=t.series.map(n=>{const{aggregation_on_group:r=Gt}=n;return{...n,aggregation_on_group:r}});return{...t,series:e}}function _f(t){const e=t.series.map(n=>{const{aggregation_on_value:r=Gt}=n;return{...n,aggregation_on_value:r}});return{...t,series:e}}function jf(t){delete t.config;const{x_axis:e,tooltip:n}=t.x_axis.axisLabel.overflow,r={x_axis:{axisLabel:{overflow:{on_axis:e,in_tooltip:n}}}};return b.defaultsDeep(r,t)}function wf(t){const{series:e,...n}=t;return{...n,series:e.map(r=>{const{barMinWidth:i,barWidth:o,barMaxWidth:l}=r;return i?{...r,barMinWidth:i,barWidth:"",barMaxWidth:l??o}:{...r,barMinWidth:"",barWidth:o,barMaxWidth:""}})}}function Cf(t){const{y_axes:e,...n}=t;return{...n,y_axes:e.map(r=>{const{min:i="",max:o=""}=r;return{...r,min:i,max:o}})}}function Sf(t){const{y_axes:e,...n}=t;return{...n,y_axes:e.map(r=>{const{nameAlignment:i="left"}=r;return{...r,nameAlignment:i}})}}function kf(t){const{y_axes:e,...n}=t;return{...n,y_axes:e.map(r=>{const{show:i=!0}=r;return{...r,show:i}})}}function Tf(t){const{regressions:e,...n}=t;return{...n,regressions:e.map(r=>{const{group_by_key:i=""}=r;return{...r,group_by_key:i}})}}function Df(t){const{series:e,y_axes:n,...r}=t;return{...r,series:e.map(i=>{const{hide_in_legend:o=!1,aggregation_on_value:l=Gt}=i;return{...i,hide_in_legend:o,aggregation_on_value:l}}),y_axes:n.map(i=>{const{min:o="",max:l="",show:c=!0}=i;return{...i,min:o,max:l,show:c}})}}function zf(t){const{type:e="category",...n}=t.x_axis;return{...t,x_axis:{...n,type:e}}}function Mf(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis_data_key:i,series:o,regressions:l,...c}=t;return{...c,x_axis_data_key:r(i),series:o.map(u=>({...u,y_axis_data_key:r(u.y_axis_data_key),group_by_key:r(u.group_by_key)})),regressions:l.map(u=>({...u,y_axis_data_key:r(u.y_axis_data_key),group_by_key:r(u.group_by_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}function If(t){const{tooltip:e={metrics:[]},...n}=t;return{...t,tooltip:e}}const Ef=[{lang:"en",resources:{cartesian_chart:{viz_name:"Cartesian Chart",series:{aggregation:{label:"Aggregation on Value"}},click_series:{label:"Click bar, line or scatter"}}}},{lang:"zh",resources:{cartesian_chart:{viz_name:"复合图",series:{aggregation:{label:"聚合数据"}},click_series:{label:"点击柱、线或散点"}}}}];class Af extends ce{constructor(){super(...arguments);$(this,"VERSION",19)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,{panelModel:r})=>{const{config:i}=n;return(i.variables||[]).forEach(c=>{r.variables.find(u=>u.name===c.name)||r.addVariable(c)}),(b.get(i,"stats.variables")||[]).forEach(c=>{r.variables.find(u=>u.name===c.name)||r.addVariable(c)}),{...n,version:2,config:mf(i)}}),this.version(3,n=>({...n,version:3,config:xf(n.config)})),this.version(4,n=>({...n,version:4,config:gf(n.config)})),this.version(5,n=>({...n,version:5,config:ff(n.config)})),this.version(6,n=>({...n,version:6,config:yf(n.config)})),this.version(7,n=>({...n,version:7,config:bf(n.config)})),this.version(8,n=>({...n,version:8,config:vf(n.config)})),this.version(9,n=>({...n,version:9,config:_f(n.config)})),this.version(10,n=>({...n,version:10,config:jf(n.config)})),this.version(11,n=>({...n,version:11,config:wf(n.config)})),this.version(12,n=>({...n,version:12,config:Cf(n.config)})),this.version(13,n=>({...n,version:13,config:Sf(n.config)})),this.version(14,n=>({...n,version:14,config:kf(n.config)})),this.version(15,n=>({...n,version:15,config:Tf(n.config)})),this.version(16,n=>({...n,version:16,config:Df(n.config)})),this.version(17,n=>({...n,version:17,config:zf(n.config)})),this.version(18,(n,r)=>({...n,version:18,config:Mf(n.config,r)})),this.version(19,n=>({...n,version:19,config:If(n.config)}))}}const Pf={displayName:"viz.cartesian_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Af,name:"cartesian",viewRender:mx,configRender:hf,createConfig(){return{version:19,config:b.cloneDeep(Zs)}},triggers:[Xs],translation:Ef};function $f(t){if(t.enable_value)return t.value}function Bf(t){if(t.enable_value)return t.value}function Lf(t){const e=t.axisLabel.overflow.on_axis.width,n=t.axisLabel.position,r={top:5,left:5,right:5,bottom:5};return t.orient==="vertical"&&b.get(r,n)&&n===t.funnelAlign&&b.set(r,n,e),r}function qf(t,e){return t.series.map(n=>{const{level_name_data_key:r,level_value_data_key:i,axisLabel:o,min:l,max:c,funnelAlign:u,orient:d,...p}=n;if(!r||!i)return{};const h=A(r),g=A(i),f=e[h.queryID].map(w=>({name:w[h.columnKey],value:w[g.columnKey]})),v=Qe(o.overflow.on_axis);return{type:"funnel",...Lf(n),min:$f(l),max:Bf(c),minSize:l.size,maxSize:c.size,...p,label:{show:!0,position:o.position,...v},orient:d,funnelAlign:d==="horizontal"?"center":u,data:f}})}function Of({conf:t,params:e,max:n}){const{name:r,value:i}=e.data,o=U(i/n,{output:"percent",mantissa:2,trimMantissa:!0,absolute:!1});return[{label:`${e.marker} ${r}`,value:`${i} (${o})`,style:{label:"",value:""}}]}function Vf(t,e){var o;const n=A(t.series[0].level_name_data_key),r=A(t.series[0].level_value_data_key),i=(o=b.maxBy(e[n.queryID],r.columnKey))==null?void 0:o[r.columnKey];return l=>{const u=Of({conf:t,params:l,max:i}).map(p=>`
132
+ `,textSerializers:l={}}=n||{};let c="",u=!0;return e.nodesBetween(s,i,(d,p,h,f)=>{var g;const y=l==null?void 0:l[d.type.name];y?(d.isBlock&&!u&&(c+=a,u=!0),h&&(c+=y({node:d,pos:p,parent:h,index:f,range:t}))):d.isText?(c+=(g=d==null?void 0:d.text)===null||g===void 0?void 0:g.slice(Math.max(s,p)-p,i-p),u=!1):d.isBlock&&!u&&(c+=a,u=!0)}),c}function Pj(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}Ft.create({name:"clipboardTextSerializer",addProseMirrorPlugins(){return[new $r({key:new Fr("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:e}=this,{state:t,schema:n}=e,{doc:s,selection:i}=t,{ranges:a}=i,l=Math.min(...a.map(p=>p.$from.pos)),c=Math.max(...a.map(p=>p.$to.pos)),u=Pj(n);return Aj(s,{from:l,to:c},{textSerializers:u})}}})]}});const Oj=()=>({editor:e,view:t})=>(requestAnimationFrame(()=>{var n;e.isDestroyed||(t.dom.blur(),(n=window==null?void 0:window.getSelection())===null||n===void 0||n.removeAllRanges())}),!0),Lj=(e=!1)=>({commands:t})=>t.setContent("",e),Bj=()=>({state:e,tr:t,dispatch:n})=>{const{selection:s}=t,{ranges:i}=s;return n&&i.forEach(({$from:a,$to:l})=>{e.doc.nodesBetween(a.pos,l.pos,(c,u)=>{if(c.type.isText)return;const{doc:d,mapping:p}=t,h=d.resolve(p.map(u)),f=d.resolve(p.map(u+c.nodeSize)),g=h.blockRange(f);if(!g)return;const y=Cj(g);if(c.type.isTextblock){const{defaultType:j}=h.parent.contentMatchAt(h.index());t.setNodeMarkup(g.start,j)}(y||y===0)&&t.lift(g,y)})}),!0},qj=e=>t=>e(t),Vj=()=>({state:e,dispatch:t})=>De.createParagraphNear(e,t),Nj=()=>({tr:e,dispatch:t})=>{const{selection:n}=e,s=n.$anchor.node();if(s.content.size>0)return!1;const i=e.selection.$anchor;for(let a=i.depth;a>0;a-=1)if(i.node(a).type===s.type){if(t){const c=i.before(a),u=i.after(a);e.delete(c,u).scrollIntoView()}return!0}return!1},$j=e=>({tr:t,state:n,dispatch:s})=>{const i=$e(e,n.schema),a=t.selection.$anchor;for(let l=a.depth;l>0;l-=1)if(a.node(l).type===i){if(s){const u=a.before(l),d=a.after(l);t.delete(u,d).scrollIntoView()}return!0}return!1},Fj=e=>({tr:t,dispatch:n})=>{const{from:s,to:i}=e;return n&&t.delete(s,i),!0},Gj=()=>({state:e,dispatch:t})=>De.deleteSelection(e,t),Wj=()=>({commands:e})=>e.keyboardShortcut("Enter"),Rj=()=>({state:e,dispatch:t})=>De.exitCode(e,t);function Ws(e,t,n={strict:!0}){const s=Object.keys(t);return s.length?s.every(i=>n.strict?t[i]===e[i]:Ij(t[i])?t[i].test(e[i]):t[i]===e[i]):!0}function po(e,t,n={}){return e.find(s=>s.type===t&&Ws(s.attrs,n))}function Qj(e,t,n={}){return!!po(e,t,n)}function yp(e,t,n={}){if(!e||!t)return;let s=e.parent.childAfter(e.parentOffset);if(e.parentOffset===s.offset&&s.offset!==0&&(s=e.parent.childBefore(e.parentOffset)),!s.node)return;const i=po([...s.node.marks],t,n);if(!i)return;let a=s.index,l=e.start()+s.offset,c=a+1,u=l+s.node.nodeSize;for(po([...s.node.marks],t,n);a>0&&i.isInSet(e.parent.child(a-1).marks);)a-=1,l-=e.parent.child(a).nodeSize;for(;c<e.parent.childCount&&Qj([...e.parent.child(c).marks],t,n);)u+=e.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function xn(e,t){if(typeof e=="string"){if(!t.marks[e])throw Error(`There is no mark type named '${e}'. Maybe you forgot to add the extension?`);return t.marks[e]}return e}const Uj=(e,t={})=>({tr:n,state:s,dispatch:i})=>{const a=xn(e,s.schema),{doc:l,selection:c}=n,{$from:u,from:d,to:p}=c;if(i){const h=yp(u,a,t);if(h&&h.from<=d&&h.to>=p){const f=Te.create(l,h.from,h.to);n.setSelection(f)}}return!0},Yj=e=>t=>{const n=typeof e=="function"?e(t):e;for(let s=0;s<n.length;s+=1)if(n[s](t))return!0;return!1};function bp(e){return e instanceof Te}function zn(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Kj(e,t=null){if(!t)return null;const n=me.atStart(e),s=me.atEnd(e);if(t==="start"||t===!0)return n;if(t==="end")return s;const i=n.from,a=s.to;return t==="all"?Te.create(e,zn(0,i,a),zn(e.content.size,i,a)):Te.create(e,zn(t,i,a),zn(t,i,a))}function ho(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const Xj=(e=null,t={})=>({editor:n,view:s,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};const l=()=>{ho()&&s.dom.focus(),requestAnimationFrame(()=>{n.isDestroyed||(s.focus(),t!=null&&t.scrollIntoView&&n.commands.scrollIntoView())})};if(s.hasFocus()&&e===null||e===!1)return!0;if(a&&e===null&&!bp(n.state.selection))return l(),!0;const c=Kj(i.doc,e)||n.state.selection,u=n.state.selection.eq(c);return a&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),l()),!0},Jj=(e,t)=>n=>e.every((s,i)=>t(s,{...n,index:i})),Zj=(e,t)=>({tr:n,commands:s})=>s.insertContentAt({from:n.selection.from,to:n.selection.to},e,t);function vp(e){const t=`<body>${e}</body>`;return new window.DOMParser().parseFromString(t,"text/html").body}function Rs(e,t,n){if(n={slice:!0,parseOptions:{},...n},typeof e=="object"&&e!==null)try{return Array.isArray(e)&&e.length>0?H.fromArray(e.map(s=>t.nodeFromJSON(s))):t.nodeFromJSON(e)}catch(s){return console.warn("[tiptap warn]: Invalid content.","Passed value:",e,"Error:",s),Rs("",t,n)}if(typeof e=="string"){const s=fj.fromSchema(t);return n.slice?s.parseSlice(vp(e),n.parseOptions).content:s.parse(vp(e),n.parseOptions)}return Rs("",t,n)}function Hj(e,t,n){const s=e.steps.length-1;if(s<t)return;const i=e.steps[s];if(!(i instanceof $t||i instanceof Mn))return;const a=e.mapping.maps[s];let l=0;a.forEach((c,u,d,p)=>{l===0&&(l=p)}),e.setSelection(me.near(e.doc.resolve(l),n))}const ew=e=>e.toString().startsWith("<"),tw=(e,t,n)=>({tr:s,dispatch:i,editor:a})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};const l=Rs(t,a.schema,{parseOptions:{preserveWhitespace:"full",...n.parseOptions}});if(l.toString()==="<>")return!0;let{from:c,to:u}=typeof e=="number"?{from:e,to:e}:e,d=!0,p=!0;if((ew(l)?l:[l]).forEach(f=>{f.check(),d=d?f.isText&&f.marks.length===0:!1,p=p?f.isBlock:!1}),c===u&&p){const{parent:f}=s.doc.resolve(c);f.isTextblock&&!f.type.spec.code&&!f.childCount&&(c-=1,u+=1)}d?Array.isArray(t)?s.insertText(t.map(f=>f.text||"").join(""),c,u):typeof t=="object"&&t&&t.text?s.insertText(t.text,c,u):s.insertText(t,c,u):s.replaceWith(c,u,l),n.updateSelection&&Hj(s,s.steps.length-1,-1)}return!0},nw=()=>({state:e,dispatch:t})=>De.joinUp(e,t),rw=()=>({state:e,dispatch:t})=>De.joinDown(e,t),sw=()=>({state:e,dispatch:t})=>De.joinBackward(e,t),iw=()=>({state:e,dispatch:t})=>De.joinForward(e,t);function _p(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function aw(e){const t=e.split(/-(?!$)/);let n=t[t.length-1];n==="Space"&&(n=" ");let s,i,a,l;for(let c=0;c<t.length-1;c+=1){const u=t[c];if(/^(cmd|meta|m)$/i.test(u))l=!0;else if(/^a(lt)?$/i.test(u))s=!0;else if(/^(c|ctrl|control)$/i.test(u))i=!0;else if(/^s(hift)?$/i.test(u))a=!0;else if(/^mod$/i.test(u))ho()||_p()?l=!0:i=!0;else throw new Error(`Unrecognized modifier name: ${u}`)}return s&&(n=`Alt-${n}`),i&&(n=`Ctrl-${n}`),l&&(n=`Meta-${n}`),a&&(n=`Shift-${n}`),n}const ow=e=>({editor:t,view:n,tr:s,dispatch:i})=>{const a=aw(e).split(/-(?!$)/),l=a.find(d=>!["Alt","Ctrl","Meta","Shift"].includes(d)),c=new KeyboardEvent("keydown",{key:l==="Space"?" ":l,altKey:a.includes("Alt"),ctrlKey:a.includes("Ctrl"),metaKey:a.includes("Meta"),shiftKey:a.includes("Shift"),bubbles:!0,cancelable:!0}),u=t.captureTransaction(()=>{n.someProp("handleKeyDown",d=>d(n,c))});return u==null||u.steps.forEach(d=>{const p=d.map(s.mapping);p&&i&&s.maybeStep(p)}),!0};function fo(e,t,n={}){const{from:s,to:i,empty:a}=e.selection,l=t?$e(t,e.schema):null,c=[];e.doc.nodesBetween(s,i,(h,f)=>{if(h.isText)return;const g=Math.max(s,f),y=Math.min(i,f+h.nodeSize);c.push({node:h,from:g,to:y})});const u=i-s,d=c.filter(h=>l?l.name===h.node.type.name:!0).filter(h=>Ws(h.node.attrs,n,{strict:!1}));return a?!!d.length:d.reduce((h,f)=>h+f.to-f.from,0)>=u}const lw=(e,t={})=>({state:n,dispatch:s})=>{const i=$e(e,n.schema);return fo(n,i,t)?De.lift(n,s):!1},cw=()=>({state:e,dispatch:t})=>De.liftEmptyBlock(e,t),uw=e=>({state:t,dispatch:n})=>{const s=$e(e,t.schema);return _i.liftListItem(s)(t,n)},dw=()=>({state:e,dispatch:t})=>De.newlineInCode(e,t);function jp(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function wp(e,t){const n=typeof t=="string"?[t]:t;return Object.keys(e).reduce((s,i)=>(n.includes(i)||(s[i]=e[i]),s),{})}const pw=(e,t)=>({tr:n,state:s,dispatch:i})=>{let a=null,l=null;const c=jp(typeof e=="string"?e:e.name,s.schema);return c?(c==="node"&&(a=$e(e,s.schema)),c==="mark"&&(l=xn(e,s.schema)),i&&n.selection.ranges.forEach(u=>{s.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,p)=>{a&&a===d.type&&n.setNodeMarkup(p,void 0,wp(d.attrs,t)),l&&d.marks.length&&d.marks.forEach(h=>{l===h.type&&n.addMark(p,p+d.nodeSize,l.create(wp(h.attrs,t)))})})}),!0):!1},hw=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),fw=()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),mw=()=>({state:e,dispatch:t})=>De.selectNodeBackward(e,t),gw=()=>({state:e,dispatch:t})=>De.selectNodeForward(e,t),xw=()=>({state:e,dispatch:t})=>De.selectParentNode(e,t),yw=()=>({state:e,dispatch:t})=>De.selectTextblockEnd(e,t),bw=()=>({state:e,dispatch:t})=>De.selectTextblockStart(e,t);function vw(e,t,n={}){return Rs(e,t,{slice:!1,parseOptions:n})}const _w=(e,t=!1,n={})=>({tr:s,editor:i,dispatch:a})=>{const{doc:l}=s,c=vw(e,i.schema,n);return a&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!t),!0};function jw(e){for(let t=0;t<e.edgeCount;t+=1){const{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}function ww(e,t){for(let n=e.depth;n>0;n-=1){const s=e.node(n);if(t(s))return{pos:n>0?e.before(n):0,start:e.start(n),depth:n,node:s}}}function mo(e){return t=>ww(t.$from,e)}function Cw(e,t){const n=xn(t,e.schema),{from:s,to:i,empty:a}=e.selection,l=[];a?(e.storedMarks&&l.push(...e.storedMarks),l.push(...e.selection.$head.marks())):e.doc.nodesBetween(s,i,u=>{l.push(...u.marks)});const c=l.find(u=>u.type.name===n.name);return c?{...c.attrs}:{}}function Qs(e,t,n){return Object.fromEntries(Object.entries(n).filter(([s])=>{const i=e.find(a=>a.type===t&&a.name===s);return i?i.attribute.keepOnSplit:!1}))}function Sw(e,t,n={}){const{empty:s,ranges:i}=e.selection,a=t?xn(t,e.schema):null;if(s)return!!(e.storedMarks||e.selection.$from.marks()).filter(h=>a?a.name===h.type.name:!0).find(h=>Ws(h.attrs,n,{strict:!1}));let l=0;const c=[];if(i.forEach(({$from:h,$to:f})=>{const g=h.pos,y=f.pos;e.doc.nodesBetween(g,y,(j,k)=>{if(!j.isText&&!j.marks.length)return;const S=Math.max(g,k),T=Math.min(y,k+j.nodeSize),z=T-S;l+=z,c.push(...j.marks.map(I=>({mark:I,from:S,to:T})))})}),l===0)return!1;const u=c.filter(h=>a?a.name===h.mark.type.name:!0).filter(h=>Ws(h.mark.attrs,n,{strict:!1})).reduce((h,f)=>h+f.to-f.from,0),d=c.filter(h=>a?h.mark.type!==a&&h.mark.type.excludes(a):!0).reduce((h,f)=>h+f.to-f.from,0);return(u>0?u+d:u)>=l}function Cp(e,t){const{nodeExtensions:n}=Mj(t),s=n.find(l=>l.name===e);if(!s)return!1;const i={name:s.name,options:s.options,storage:s.storage},a=Dt(at(s,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function kw(e,t,n){var s;const{selection:i}=t;let a=null;if(bp(i)&&(a=i.$cursor),a){const c=(s=e.storedMarks)!==null&&s!==void 0?s:a.marks();return!!n.isInSet(c)||!c.some(u=>u.type.excludes(n))}const{ranges:l}=i;return l.some(({$from:c,$to:u})=>{let d=c.depth===0?e.doc.inlineContent&&e.doc.type.allowsMarkType(n):!1;return e.doc.nodesBetween(c.pos,u.pos,(p,h,f)=>{if(d)return!1;if(p.isInline){const g=!f||f.type.allowsMarkType(n),y=!!n.isInSet(p.marks)||!p.marks.some(j=>j.type.excludes(n));d=g&&y}return!d}),d})}const Tw=(e,t={})=>({tr:n,state:s,dispatch:i})=>{const{selection:a}=n,{empty:l,ranges:c}=a,u=xn(e,s.schema);if(i)if(l){const d=Cw(s,u);n.addStoredMark(u.create({...d,...t}))}else c.forEach(d=>{const p=d.$from.pos,h=d.$to.pos;s.doc.nodesBetween(p,h,(f,g)=>{const y=Math.max(g,p),j=Math.min(g+f.nodeSize,h);f.marks.find(S=>S.type===u)?f.marks.forEach(S=>{u===S.type&&n.addMark(y,j,u.create({...S.attrs,...t}))}):n.addMark(y,j,u.create(t))})});return kw(s,n,u)},Dw=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),Mw=(e,t={})=>({state:n,dispatch:s,chain:i})=>{const a=$e(e,n.schema);return a.isTextblock?i().command(({commands:l})=>De.setBlockType(a,t)(n)?!0:l.clearNodes()).command(({state:l})=>De.setBlockType(a,t)(l,s)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},zw=e=>({tr:t,dispatch:n})=>{if(n){const{doc:s}=t,i=zn(e,0,s.content.size),a=it.create(s,i);t.setSelection(a)}return!0},Iw=e=>({tr:t,dispatch:n})=>{if(n){const{doc:s}=t,{from:i,to:a}=typeof e=="number"?{from:e,to:e}:e,l=Te.atStart(s).from,c=Te.atEnd(s).to,u=zn(i,l,c),d=zn(a,l,c),p=Te.create(s,u,d);t.setSelection(p)}return!0},Ew=e=>({state:t,dispatch:n})=>{const s=$e(e,t.schema);return _i.sinkListItem(s)(t,n)};function Sp(e,t){const n=e.storedMarks||e.selection.$to.parentOffset&&e.selection.$from.marks();if(n){const s=n.filter(i=>t==null?void 0:t.includes(i.type.name));e.tr.ensureMarks(s)}}const Aw=({keepMarks:e=!0}={})=>({tr:t,state:n,dispatch:s,editor:i})=>{const{selection:a,doc:l}=t,{$from:c,$to:u}=a,d=i.extensionManager.attributes,p=Qs(d,c.node().type.name,c.node().attrs);if(a instanceof it&&a.node.isBlock)return!c.parentOffset||!$s(l,c.pos)?!1:(s&&(e&&Sp(n,i.extensionManager.splittableMarks),t.split(c.pos).scrollIntoView()),!0);if(!c.parent.isBlock)return!1;if(s){const h=u.parentOffset===u.parent.content.size;a instanceof Te&&t.deleteSelection();const f=c.depth===0?void 0:jw(c.node(-1).contentMatchAt(c.indexAfter(-1)));let g=h&&f?[{type:f,attrs:p}]:void 0,y=$s(t.doc,t.mapping.map(c.pos),1,g);if(!g&&!y&&$s(t.doc,t.mapping.map(c.pos),1,f?[{type:f}]:void 0)&&(y=!0,g=f?[{type:f,attrs:p}]:void 0),y&&(t.split(t.mapping.map(c.pos),1,g),f&&!h&&!c.parentOffset&&c.parent.type!==f)){const j=t.mapping.map(c.before()),k=t.doc.resolve(j);c.node(-1).canReplaceWith(k.index(),k.index()+1,f)&&t.setNodeMarkup(t.mapping.map(c.before()),f)}e&&Sp(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return!0},Pw=e=>({tr:t,state:n,dispatch:s,editor:i})=>{var a;const l=$e(e,n.schema),{$from:c,$to:u}=n.selection,d=n.selection.node;if(d&&d.isBlock||c.depth<2||!c.sameParent(u))return!1;const p=c.node(-1);if(p.type!==l)return!1;const h=i.extensionManager.attributes;if(c.parent.content.size===0&&c.node(-1).childCount===c.indexAfter(-1)){if(c.depth===2||c.node(-3).type!==l||c.index(-2)!==c.node(-2).childCount-1)return!1;if(s){let k=H.empty;const S=c.index(-1)?1:c.index(-2)?2:3;for(let R=c.depth-S;R>=c.depth-3;R-=1)k=H.from(c.node(R).copy(k));const T=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,z=Qs(h,c.node().type.name,c.node().attrs),I=((a=l.contentMatch.defaultType)===null||a===void 0?void 0:a.createAndFill(z))||void 0;k=k.append(H.from(l.createAndFill(null,I)||void 0));const E=c.before(c.depth-(S-1));t.replace(E,c.after(-T),new re(k,4-S,0));let N=-1;t.doc.nodesBetween(E,t.doc.content.size,(R,pe)=>{if(N>-1)return!1;R.isTextblock&&R.content.size===0&&(N=pe+1)}),N>-1&&t.setSelection(Te.near(t.doc.resolve(N))),t.scrollIntoView()}return!0}const f=u.pos===c.end()?p.contentMatchAt(0).defaultType:null,g=Qs(h,p.type.name,p.attrs),y=Qs(h,c.node().type.name,c.node().attrs);t.delete(c.pos,u.pos);const j=f?[{type:l,attrs:g},{type:f,attrs:y}]:[{type:l,attrs:g}];if(!$s(t.doc,c.pos,2))return!1;if(s){const{selection:k,storedMarks:S}=n,{splittableMarks:T}=i.extensionManager,z=S||k.$to.parentOffset&&k.$from.marks();if(t.split(c.pos,2,j).scrollIntoView(),!z||!s)return!0;const I=z.filter(E=>T.includes(E.type.name));t.ensureMarks(I)}return!0},go=(e,t)=>{const n=mo(l=>l.type===t)(e.selection);if(!n)return!0;const s=e.doc.resolve(Math.max(0,n.pos-1)).before(n.depth);if(s===void 0)return!0;const i=e.doc.nodeAt(s);return n.node.type===(i==null?void 0:i.type)&&up(e.doc,n.pos)&&e.join(n.pos),!0},xo=(e,t)=>{const n=mo(l=>l.type===t)(e.selection);if(!n)return!0;const s=e.doc.resolve(n.start).after(n.depth);if(s===void 0)return!0;const i=e.doc.nodeAt(s);return n.node.type===(i==null?void 0:i.type)&&up(e.doc,s)&&e.join(s),!0};var Ow=Object.freeze({__proto__:null,blur:Oj,clearContent:Lj,clearNodes:Bj,command:qj,createParagraphNear:Vj,deleteCurrentNode:Nj,deleteNode:$j,deleteRange:Fj,deleteSelection:Gj,enter:Wj,exitCode:Rj,extendMarkRange:Uj,first:Yj,focus:Xj,forEach:Jj,insertContent:Zj,insertContentAt:tw,joinUp:nw,joinDown:rw,joinBackward:sw,joinForward:iw,keyboardShortcut:ow,lift:lw,liftEmptyBlock:cw,liftListItem:uw,newlineInCode:dw,resetAttributes:pw,scrollIntoView:hw,selectAll:fw,selectNodeBackward:mw,selectNodeForward:gw,selectParentNode:xw,selectTextblockEnd:yw,selectTextblockStart:bw,setContent:_w,setMark:Tw,setMeta:Dw,setNode:Mw,setNodeSelection:zw,setTextSelection:Iw,sinkListItem:Ew,splitBlock:Aw,splitListItem:Pw,toggleList:(e,t,n,s={})=>({editor:i,tr:a,state:l,dispatch:c,chain:u,commands:d,can:p})=>{const{extensions:h,splittableMarks:f}=i.extensionManager,g=$e(e,l.schema),y=$e(t,l.schema),{selection:j,storedMarks:k}=l,{$from:S,$to:T}=j,z=S.blockRange(T),I=k||j.$to.parentOffset&&j.$from.marks();if(!z)return!1;const E=mo(N=>Cp(N.type.name,h))(j);if(z.depth>=1&&E&&z.depth-E.depth<=1){if(E.node.type===g)return d.liftListItem(y);if(Cp(E.node.type.name,h)&&g.validContent(E.node.content)&&c)return u().command(()=>(a.setNodeMarkup(E.pos,g),!0)).command(()=>go(a,g)).command(()=>xo(a,g)).run()}return!n||!I||!c?u().command(()=>p().wrapInList(g,s)?!0:d.clearNodes()).wrapInList(g,s).command(()=>go(a,g)).command(()=>xo(a,g)).run():u().command(()=>{const N=p().wrapInList(g,s),R=I.filter(pe=>f.includes(pe.type.name));return a.ensureMarks(R),N?!0:d.clearNodes()}).wrapInList(g,s).command(()=>go(a,g)).command(()=>xo(a,g)).run()},toggleMark:(e,t={},n={})=>({state:s,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,l=xn(e,s.schema);return Sw(s,l,t)?i.unsetMark(l,{extendEmptyMarkRange:a}):i.setMark(l,t)},toggleNode:(e,t,n={})=>({state:s,commands:i})=>{const a=$e(e,s.schema),l=$e(t,s.schema);return fo(s,a,n)?i.setNode(l):i.setNode(a,n)},toggleWrap:(e,t={})=>({state:n,commands:s})=>{const i=$e(e,n.schema);return fo(n,i,t)?s.lift(i):s.wrapIn(i,t)},undoInputRule:()=>({state:e,dispatch:t})=>{const n=e.plugins;for(let s=0;s<n.length;s+=1){const i=n[s];let a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){const l=e.tr,c=a.transform;for(let u=c.steps.length-1;u>=0;u-=1)l.step(c.steps[u].invert(c.docs[u]));if(a.text){const u=l.doc.resolve(a.from).marks();l.replaceWith(a.from,a.to,e.schema.text(a.text,u))}else l.delete(a.from,a.to)}return!0}}return!1},unsetAllMarks:()=>({tr:e,dispatch:t})=>{const{selection:n}=e,{empty:s,ranges:i}=n;return s||t&&i.forEach(a=>{e.removeMark(a.$from.pos,a.$to.pos)}),!0},unsetMark:(e,t={})=>({tr:n,state:s,dispatch:i})=>{var a;const{extendEmptyMarkRange:l=!1}=t,{selection:c}=n,u=xn(e,s.schema),{$from:d,empty:p,ranges:h}=c;if(!i)return!0;if(p&&l){let{from:f,to:g}=c;const y=(a=d.marks().find(k=>k.type===u))===null||a===void 0?void 0:a.attrs,j=yp(d,u,y);j&&(f=j.from,g=j.to),n.removeMark(f,g,u)}else h.forEach(f=>{n.removeMark(f.$from.pos,f.$to.pos,u)});return n.removeStoredMark(u),!0},updateAttributes:(e,t={})=>({tr:n,state:s,dispatch:i})=>{let a=null,l=null;const c=jp(typeof e=="string"?e:e.name,s.schema);return c?(c==="node"&&(a=$e(e,s.schema)),c==="mark"&&(l=xn(e,s.schema)),i&&n.selection.ranges.forEach(u=>{const d=u.$from.pos,p=u.$to.pos;s.doc.nodesBetween(d,p,(h,f)=>{a&&a===h.type&&n.setNodeMarkup(f,void 0,{...h.attrs,...t}),l&&h.marks.length&&h.marks.forEach(g=>{if(l===g.type){const y=Math.max(f,d),j=Math.min(f+h.nodeSize,p);n.addMark(y,j,l.create({...g.attrs,...t}))}})})}),!0):!1},wrapIn:(e,t={})=>({state:n,dispatch:s})=>{const i=$e(e,n.schema);return De.wrapIn(i,t)(n,s)},wrapInList:(e,t={})=>({state:n,dispatch:s})=>{const i=$e(e,n.schema);return _i.wrapInList(i,t)(n,s)}});Ft.create({name:"commands",addCommands(){return{...Ow}}}),Ft.create({name:"editable",addProseMirrorPlugins(){return[new $r({key:new Fr("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Ft.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:e}=this;return[new $r({key:new Fr("focusEvents"),props:{handleDOMEvents:{focus:(t,n)=>{e.isFocused=!0;const s=e.state.tr.setMeta("focus",{event:n}).setMeta("addToHistory",!1);return t.dispatch(s),!1},blur:(t,n)=>{e.isFocused=!1;const s=e.state.tr.setMeta("blur",{event:n}).setMeta("addToHistory",!1);return t.dispatch(s),!1}}}})]}}),Ft.create({name:"keymap",addKeyboardShortcuts(){const e=()=>this.editor.commands.first(({commands:l})=>[()=>l.undoInputRule(),()=>l.command(({tr:c})=>{const{selection:u,doc:d}=c,{empty:p,$anchor:h}=u,{pos:f,parent:g}=h,y=me.atStart(d).from===f;return!p||!y||!g.type.isTextblock||g.textContent.length?!1:l.clearNodes()}),()=>l.deleteSelection(),()=>l.joinBackward(),()=>l.selectNodeBackward()]),t=()=>this.editor.commands.first(({commands:l})=>[()=>l.deleteSelection(),()=>l.deleteCurrentNode(),()=>l.joinForward(),()=>l.selectNodeForward()]),s={Enter:()=>this.editor.commands.first(({commands:l})=>[()=>l.newlineInCode(),()=>l.createParagraphNear(),()=>l.liftEmptyBlock(),()=>l.splitBlock()]),"Mod-Enter":()=>this.editor.commands.exitCode(),Backspace:e,"Mod-Backspace":e,"Shift-Backspace":e,Delete:t,"Mod-Delete":t,"Mod-a":()=>this.editor.commands.selectAll()},i={...s},a={...s,"Ctrl-h":e,"Alt-Backspace":e,"Ctrl-d":t,"Ctrl-Alt-Backspace":t,"Alt-Delete":t,"Alt-d":t,"Ctrl-a":()=>this.editor.commands.selectTextblockStart(),"Ctrl-e":()=>this.editor.commands.selectTextblockEnd()};return ho()||_p()?a:i},addProseMirrorPlugins(){return[new $r({key:new Fr("clearDocument"),appendTransaction:(e,t,n)=>{if(!(e.some(y=>y.docChanged)&&!t.doc.eq(n.doc)))return;const{empty:i,from:a,to:l}=t.selection,c=me.atStart(t.doc).from,u=me.atEnd(t.doc).to;if(i||!(a===c&&l===u)||!(n.doc.textBetween(0,n.doc.content.size," "," ").length===0))return;const h=n.tr,f=xp({state:n,transaction:h}),{commands:g}=new Dj({editor:this.editor,state:f});if(g.clearNodes(),!!h.steps.length)return h}})]}}),Ft.create({name:"tabindex",addProseMirrorPlugins(){return[new $r({key:new Fr("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});class Us{constructor(t={}){this.type="mark",this.name="mark",this.parent=null,this.child=null,this.config={name:this.name,defaultOptions:{}},this.config={...this.config,...t},this.name=this.config.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${this.name}".`),this.options=this.config.defaultOptions,this.config.addOptions&&(this.options=Dt(at(this,"addOptions",{name:this.name}))),this.storage=Dt(at(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Us(t)}configure(t={}){const n=this.extend();return n.options=uo(this.options,t),n.storage=Dt(at(n,"addStorage",{name:n.name,options:n.options})),n}extend(t={}){const n=new Us(t);return n.parent=this,this.child=n,n.name=t.name?t.name:n.parent.name,t.defaultOptions&&console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${n.name}".`),n.options=Dt(at(n,"addOptions",{name:n.name})),n.storage=Dt(at(n,"addStorage",{name:n.name,options:n.options})),n}static handleExit({editor:t,mark:n}){const{tr:s}=t.state,i=t.state.selection.$from;if(i.pos===i.end()){const l=i.marks();if(!!!l.find(d=>(d==null?void 0:d.type.name)===n.name))return!1;const u=l.find(d=>(d==null?void 0:d.type.name)===n.name);return u&&s.removeStoredMark(u),s.insertText(" ",i.pos),t.view.dispatch(s),!0}return!1}}const kp=Ft.create({name:"fontSize",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{fontSize:{default:null,parseHTML:e=>e.style.fontSize.replace(/['"]+/g,""),renderHTML:e=>e.fontSize?{style:`font-size: ${e.fontSize}`}:{}}}}]},addCommands(){return{setFontSize:e=>({chain:t})=>t().setMark("textStyle",{fontSize:e}).run(),unsetFontSize:()=>({chain:e})=>e().setMark("textStyle",{fontSize:null}).removeEmptyTextStyle().run()}}}),Lw=["8","10","12","14","16","18","20","24","30","36","48","60","72"].map(e=>`${e}px`),Bw=[{label:"auto",value:""}].concat(Lw.map(e=>({label:e,value:e}))),qw={input:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"}},Vw=({editor:e})=>{const t=e.getAttributes("textStyle").fontSize;return r.jsx(Q.RichTextEditor.ControlsGroup,{children:r.jsx(o.NativeSelect,{size:"xs",icon:r.jsx(M.IconTextSize,{stroke:1.5,size:16}),data:Bw,styles:qw,value:t||"",onChange:n=>{const s=n.currentTarget.value;s?e.chain().focus().setFontSize(s).run():e.chain().focus().unsetFontSize().run()}})})},yo="function color({ variables }, { filters, context }, utils) {",Tp="}",Nw=[yo,' return "red";',Tp].join(`
133
+ `),$w=e=>!e||e.startsWith(yo)?e:[yo,e,Tp].join(`
134
+ `),Fw=e=>{const n="abcdefghijklmnopqrstuvwxyz",i=`1234567890${n}${n.toUpperCase()}`.split(""),a=new Uint8Array(e);return crypto.getRandomValues(a),a.reduce((l,c)=>`${l}${i[c&61]}`,"")};function Gw(e,t,n){const s={},i=l=>new Function(`return ${$w(l)}`)()({variables:n},t,vt);return e.querySelectorAll("dynamic-color").forEach(l=>{const c=l.getAttribute("data-value");c&&(s[`#${l.id}`]={color:i(c)})}),s}const Gr="data-value",Ww=Gr,Dp="dynamicColor",Mp=Us.create({name:Dp,addAttributes(){return{id:{default:Fw(6),parseHTML:e=>e.getAttribute("id")},[Gr]:{default:null,parseHTML:e=>e.getAttribute(Gr)}}},parseHTML(){return[{tag:"dynamic-color",getAttrs:e=>typeof e=="string"?(console.debug(e),!1):[e.getAttribute(Gr)]}]},renderHTML({HTMLAttributes:e}){return["dynamic-color",e,0]},addCommands(){return{setDynamicColor:e=>({commands:t})=>t.setMark(this.name,{[Gr]:e}),unsetDynamicColor:()=>({commands:e})=>e.unsetMark(this.name)}}}),Rw=({onClick:e})=>{const{t}=_.useTranslation();return r.jsx(o.Tooltip,{label:t("rich_text.dynamic_color.label"),children:r.jsx(o.ActionIcon,{variant:"default","data-rich-text-editor-control":"true",sx:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important",color:"rgb(190, 75, 219)"},onClick:e,children:r.jsx(M.IconMathFunction,{stroke:2,size:16})})})},Qw=({editor:e})=>{const{t}=_.useTranslation(),n=e.getAttributes(Dp)[Ww]??"";return r.jsx(bo,{title:t("rich_text.dynamic_color.edit"),label:"",triggerLabel:"",value:n,onChange:s=>{s?e.chain().focus().setDynamicColor(s).run():e.chain().focus().unsetDynamicColor().run()},defaultValue:Nw,renderTriggerButton:Rw,zIndex:340})},Ys=({value:e,styles:t={},sx:n={},dashboardState:s=Di(),varaiables:i={}})=>{const a=cc.useEditor({extensions:[uc,lc,Q.Link,tc,ec,Zl,sc.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),oc,ac,ic,nc.configure({types:["heading","paragraph"]}),Hl.configure({placeholder:"This is placeholder"}),rc,Jl.Color,kp,Mp],content:e,editable:!1});m.useEffect(()=>{a==null||a.commands.setContent(e)},[e,a]);const l=m.useMemo(()=>new DOMParser().parseFromString(e,"text/html"),[e]),c=m.useMemo(()=>Gw(l,s,i),[l,s,i]),u=m.useMemo(()=>v.defaultsDeep({},{content:{...eo,...c}},t),[t,c]);return r.jsx(Q.RichTextEditor,{editor:a,styles:u,sx:n,children:r.jsx(Q.RichTextEditor.Content,{})})};function zp(){const{t:e}=_.useTranslation(),[t,{open:n,close:s}]=he.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:s,title:e("function_utils.modal_title"),zIndex:330,withinPortal:!0,children:r.jsx(Ys,{value:bg(e),styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),r.jsx(o.Button,{variant:"light",color:"violet",size:"xs",onClick:n,leftIcon:r.jsx(M.IconInfoCircle,{size:16}),children:e("function_utils.trigger_text")})]})}const Uw=({value:e,onChange:t,onMount:n})=>{const s=i=>{if(!i){t("");return}t(i)};return r.jsx(tt,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:e,onChange:s,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}},onMount:n})},er=m.forwardRef(({value:e,onChange:t,label:n,defaultValue:s,restrictions:i=[]},a)=>{const{t:l}=_.useTranslation(),[c,u]=m.useState(e),d=()=>{t(c)},p=()=>{u(e)},h=()=>{u(s)};m.useEffect(()=>{u(e)},[e]);const f=m.useCallback((j,k)=>{if(i.length===0)return;const S=Tm.constrainedEditor(k),T=j.getModel();S.initializeIn(j),S.addRestrictionsTo(T,i)},[]),g=c!==e,y=typeof c=="string"&&c.length===0;return r.jsxs(o.Stack,{spacing:4,sx:{height:"100%"},children:[r.jsxs(o.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[r.jsx(o.Group,{position:"left",children:r.jsx(zp,{})}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:h,size:"xs",variant:"default",leftIcon:r.jsx(M.IconPlayerSkipBack,{size:16}),children:l("common.actions.reset_to_default")}),r.jsx(o.Button,{onClick:p,color:"red",size:"xs",disabled:!g,leftIcon:r.jsx(M.IconRecycle,{size:16}),children:l("common.actions.revert_changes")}),r.jsx(o.Button,{color:"green",size:"xs",onClick:d,disabled:!g,leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),children:l("common.actions.save_changes")})]})]}),r.jsx(o.Text,{size:14,children:n}),r.jsxs(o.Box,{sx:{position:"relative",flexGrow:1},children:[y&&r.jsx(o.Overlay,{center:!0,color:"#fff",opacity:.5,children:r.jsx(o.Button,{color:"blue",radius:"xl",onClick:h,children:l("common.actions.init_with_default")})}),r.jsx(Uw,{value:c,onChange:u,onMount:f})]})]})}),bo=m.forwardRef(({title:e,value:t,onChange:n,label:s,description:i=null,triggerLabel:a="Edit",triggerButtonProps:l={},renderTriggerButton:c,defaultValue:u,zIndex:d=320,restrictions:p},h)=>{const[f,{open:g,close:y}]=he.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Modal,{opened:f,onClose:y,title:e,withinPortal:!0,zIndex:d,size:"900px",children:[i,r.jsx(o.Box,{h:600,children:r.jsx(er,{value:t,onChange:n,defaultValue:u,label:s,restrictions:p})})]}),c==null?void 0:c({onClick:g}),!c&&r.jsx(o.Button,{onClick:g,...l,children:a})]})});function Yw({label:e,value:t,onChange:n,pt:s="sm",withFallback:i},a){const{t:l,i18n:c}=_.useTranslation();m.useEffect(()=>{typeof t=="string"&&n({type:t,config:{},fallback:"0"})},[t,n]);const u=y=>{switch(y){case"quantile":return n({type:"quantile",config:{p:.99},fallback:t.fallback});case"custom":return n({type:"custom",config:{func:_c},fallback:t.fallback});case"pick_record":return n({type:"pick_record",config:{method:"first"},fallback:t.fallback});default:return n({type:y,config:{},fallback:t.fallback})}},d=y=>{n({type:"quantile",config:{p:y},fallback:t.fallback})},p=y=>{n({type:"custom",config:{func:y},fallback:t.fallback})},h=y=>{n({type:"pick_record",config:{method:y},fallback:t.fallback})},f=y=>{n({...t,fallback:y.currentTarget.value})},g=m.useMemo(()=>[{label:l("aggregation.option.none"),value:"none"},{label:l("aggregation.option.sum"),value:"sum"},{label:l("aggregation.option.min"),value:"min"},{label:l("aggregation.option.mean"),value:"mean"},{label:l("aggregation.option.median"),value:"median"},{label:l("aggregation.option.max"),value:"max"},{label:l("aggregation.option.cov"),value:"CV"},{label:l("aggregation.option.std"),value:"std"},{label:l("aggregation.option.quantile.label_with_hint"),value:"quantile"},{label:l("aggregation.option.pick_record.label"),value:"pick_record"},{label:l("aggregation.option.custom.label"),value:"custom"}],[c.language]);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,pt:s,children:[r.jsx(o.Select,{ref:a,label:e,data:g,value:t.type,onChange:u,maxDropdownHeight:600}),t.type==="quantile"&&r.jsx(o.NumberInput,{label:"p",value:t.config.p,onChange:d,precision:2,min:.05,step:.05,max:1}),t.type==="pick_record"&&r.jsx(o.Select,{label:l("aggregation.option.pick_record.method.label"),value:t.config.method,onChange:h,data:[{label:l("aggregation.option.pick_record.method.first"),value:"first"},{label:l("aggregation.option.pick_record.method.last"),value:"last"}]}),t.type==="custom"&&r.jsx(bo,{title:l("aggregation.option.custom.title"),label:"",triggerLabel:l("aggregation.option.custom.label_trigger"),value:t.config.func,onChange:p,defaultValue:_c,triggerButtonProps:{size:"xs",sx:{flexGrow:0,alignSelf:"center",marginTop:"22px"},leftIcon:r.jsx(M.IconMathFunction,{size:16}),color:"grape"}})]}),i&&r.jsx(o.TextInput,{label:l("panel.variable.aggregation.fallback_value"),description:l("panel.variable.aggregation.fallback_value_description"),value:t.fallback,onChange:f})]})}const vo=m.forwardRef(Yw),tr=m.forwardRef(({label:e,value:t,onChange:n,options:s,withOffOption:i=!1},a)=>{const{t:l,i18n:c}=_.useTranslation(),u=m.useMemo(()=>{if(s)return s;const d=[{label:l("chart.label_position.top"),value:"top"},{label:l("chart.label_position.left"),value:"left"},{label:l("chart.label_position.right"),value:"right"},{label:l("chart.label_position.bottom"),value:"bottom"},{label:l("chart.label_position.outside"),value:"outside"},{label:l("chart.label_position.inside"),value:"inside"},{label:l("chart.label_position.inside_left"),value:"insideLeft"},{label:l("chart.label_position.inside_right"),value:"insideRight"},{label:l("chart.label_position.inside_top"),value:"insideTop"},{label:l("chart.label_position.inside_bottom"),value:"insideBottom"},{label:l("chart.label_position.inside_top_left"),value:"insideTopLeft"},{label:l("chart.label_position.inside_bottom_left"),value:"insideBottomLeft"},{label:l("chart.label_position.inside_top_right"),value:"insideTopRight"},{label:l("chart.label_position.inside_bottom_right"),value:"insideBottomRight"}];return i&&d.unshift({label:l("chart.label_position.off"),value:""}),d},[c.language,s,i]);return r.jsx(o.Select,{ref:a,label:e,data:u,value:t,onChange:n})});function Kw({control:e,index:t,seriesItem:n}){const{t:s,i18n:i}=_.useTranslation(),a=!!n.barWidth.trim(),l=m.useMemo(()=>[{label:s("chart.series.bar.bar_gap.no_gap"),value:"0%"},{label:s("chart.series.bar.bar_gap.overlap"),value:"-100%"}],[i.language]);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.stack`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.stack"),placeholder:s("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`series.${t}.barGap`,control:e,render:({field:c})=>r.jsx(o.Select,{label:s("chart.series.bar.bar_gap.label"),data:l,sx:{flexGrow:1},...c})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.barMinWidth`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.bar_width.min"),disabled:a,sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`series.${t}.barWidth`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.bar_width.exact"),sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`series.${t}.barMaxWidth`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.bar_width.max"),disabled:a,sx:{flexGrow:1},...c})})]})]})}function Xw({control:e,index:t,seriesItem:n}){const{t:s,i18n:i}=_.useTranslation(),a=n.showSymbol,l=m.useMemo(()=>[{label:s("chart.series.line.step.off"),value:"false"},{label:s("chart.series.line.step.start"),value:"start"},{label:s("chart.series.line.step.middle"),value:"middle"},{label:s("chart.series.line.step.end"),value:"end"}],[i.language]);return r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:s("chart.series.line.line_settings"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`series.${t}.lineStyle.type`,control:e,render:({field:c})=>r.jsx(Zn,{sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`series.${t}.lineStyle.width`,control:e,render:({field:c})=>r.jsx(o.NumberInput,{label:s("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),r.jsxs(o.Group,{grow:!0,align:"center",children:[r.jsx(b.Controller,{name:`series.${t}.step`,control:e,render:({field:c})=>r.jsx(o.Select,{label:s("chart.series.line.step.label"),data:l,sx:{flexGrow:1,maxWidth:"48%"},...c,value:String(c.value),onChange:u=>{const d=u==="false"?!1:u;c.onChange(d)}})}),r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:`series.${t}.smooth`,control:e,render:({field:c})=>r.jsx(o.Box,{sx:{flexGrow:1},children:r.jsx(o.Switch,{label:s("chart.series.line.smooth_line"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})}),r.jsx(b.Controller,{name:`series.${t}.display_name_on_line`,control:e,render:({field:c})=>r.jsx(o.Box,{sx:{flexGrow:1},children:r.jsx(o.Switch,{label:s("chart.series.line.show_name_on_line"),checked:c.value??!1,onChange:u=>c.onChange(u.currentTarget.checked)})})})]})]}),r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:`series.${t}.showSymbol`,control:e,render:({field:c})=>r.jsx(o.Box,{mt:10,mb:-10,sx:{flexGrow:1},children:r.jsx(o.Switch,{label:s("chart.series.line.show_symbol_on_line"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})}),a&&r.jsx(b.Controller,{name:`series.${t}.symbolSize`,control:e,render:({field:c})=>r.jsx(Ha,{...c})})]})]})}function Jw({control:e,index:t}){return r.jsx(b.Controller,{name:`series.${t}.symbolSize`,control:e,render:({field:n})=>r.jsx(Ha,{label:"Size",...n})})}function Zw({control:e,index:t,seriesItem:n,yAxisOptions:s}){const{t:i}=_.useTranslation(),a=n.type;return r.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[r.jsx(o.Stack,{children:r.jsx(b.Controller,{name:`series.${t}.type`,control:e,render:({field:l})=>r.jsx(o.SegmentedControl,{data:[{label:i("chart.series.line.label"),value:"line"},{label:i("chart.series.bar.label"),value:"bar"},{label:i("chart.series.scatter.label"),value:"scatter"}],...l})})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.name`,control:e,render:({field:l})=>r.jsx(o.TextInput,{label:i("chart.series.name"),required:!0,sx:{flex:1},...l})}),r.jsx(b.Controller,{name:`series.${t}.yAxisIndex`,control:e,render:({field:{value:l,onChange:c,...u}})=>r.jsx(o.Select,{label:i("chart.series.y_axis"),data:s,disabled:s.length===0,...u,value:(l==null?void 0:l.toString())??"",onChange:d=>{if(!d){c(0);return}c(Number(d))},sx:{flex:1}})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.y_axis_data_key`,control:e,render:({field:l})=>r.jsx(F,{label:i("chart.series.data_field"),required:!0,sx:{flex:1},...l})}),r.jsx(b.Controller,{name:`series.${t}.aggregation_on_value`,control:e,render:({field:l})=>r.jsx(vo,{label:i("viz.cartesian_chart.series.aggregation.label"),value:l.value??Bn,onChange:l.onChange,pt:0,withFallback:!1})})]}),r.jsx(o.Group,{grow:!0,children:r.jsx(b.Controller,{name:`series.${t}.group_by_key`,control:e,render:({field:l})=>r.jsx(F,{label:i("chart.series.group_by.label"),clearable:!0,sx:{flex:1},...l})})}),a==="line"&&r.jsx(Xw,{index:t,control:e,seriesItem:n}),a==="bar"&&r.jsx(Kw,{index:t,control:e,seriesItem:n}),a==="scatter"&&r.jsx(Jw,{index:t,control:e}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.style.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`series.${t}.label_position`,control:e,render:({field:l})=>r.jsx(tr,{label:i("chart.label_position.label"),withOffOption:!0,...l})}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:i("chart.color.label")}),r.jsx(b.Controller,{name:`series.${t}.color`,control:e,render:({field:l})=>r.jsx(Le,{...l})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.behavior.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`series.${t}.hide_in_legend`,control:e,render:({field:l})=>r.jsx(o.Checkbox,{label:i("chart.legend.hide_in_legend"),checked:l.value,onChange:c=>l.onChange(c.currentTarget.checked)})})]})}function Hw({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>({type:"bar",name:he.randomId(),showSymbol:!1,symbolSize:Za.static,y_axis_data_key:"value",yAxisIndex:0,label_position:"top",display_name_on_line:!1,stack:"",color:"#000",step:!1,smooth:!1,barMinWidth:"1",barWidth:"10%",barMaxWidth:"10",barGap:"0%",lineStyle:{type:"solid",width:1},hide_in_legend:!1,group_by_key:""}),i=(c,u)=>{const d=c.name.trim();return d||u+1},a=t("y_axes"),l=m.useMemo(()=>a.map(({name:c},u)=>({label:c,value:u.toString()})),[a]);return r.jsx(fe,{control:e,watch:t,name:"series",getItem:s,addButtonText:n("chart.series.add"),deleteButtonText:n("chart.series.delete"),renderTabName:i,children:({field:c,index:u})=>r.jsx(Zw,{control:e,index:u,seriesItem:c,yAxisOptions:l})})}function e0({control:e,watch:t}){const{t:n}=_.useTranslation();return t("stats"),r.jsx(o.Stack,{children:r.jsxs(o.Stack,{spacing:0,children:[r.jsx(b.Controller,{name:"stats.templates.top",control:e,render:({field:s})=>r.jsx(hr,{label:n("chart.stats.template.above_chart"),py:"md",sx:{flexGrow:1},...s})}),r.jsx(b.Controller,{name:"stats.templates.bottom",control:e,render:({field:s})=>r.jsx(hr,{label:n("chart.stats.template.under_chart"),py:"md",sx:{flexGrow:1},...s})})]})})}const t0=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},n0=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),r.jsx(fe,{control:e,watch:t,name:"tooltip.metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(t0,{control:e,index:l})})]})};function r0({control:e,watch:t}){return r.jsx(o.Stack,{children:r.jsx(n0,{control:e,watch:t})})}const s0=()=>{const{t:e}=_.useTranslation();return r.jsxs(o.Group,{sx:{display:"inline-flex"},spacing:6,mr:14,children:[r.jsx(o.Text,{children:e("chart.x_axis.x_axis_type")}),r.jsxs(o.HoverCard,{width:340,shadow:"md",position:"top",children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.ActionIcon,{size:"xs",sx:{transform:"none !important"},children:r.jsx(M.IconInfoCircle,{})})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(o.Text,{size:"sm",children:r.jsxs(_.Trans,{i18nKey:"chart.axis.type.click_to_learn_more",children:["Click",r.jsx(o.Anchor,{href:"https://echarts.apache.org/en/option.html#xAxis.type",target:"_blank",mx:3,children:"here"}),"to learn more about these options"]})})})]})]})};function i0({control:e,watch:t}){const{t:n,i18n:s}=_.useTranslation();t(["x_axis_data_key","x_axis_name","x_axis"]);const i=m.useMemo(()=>[{label:n("chart.axis.type.value"),value:"value"},{label:n("chart.axis.type.category"),value:"category"},{label:n("chart.axis.type.time"),value:"time"},{label:n("chart.axis.type.log"),value:"log"}],[s.language]);return r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:"x_axis_name",control:e,render:({field:a})=>r.jsx(o.TextInput,{label:n("chart.x_axis.x_axis_name"),sx:{flex:1},...a})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis_data_key",control:e,render:({field:a})=>r.jsx(F,{label:n("chart.x_axis.x_axis_data_field"),required:!0,sx:{flex:1},...a})}),r.jsx(b.Controller,{name:"x_axis.type",control:e,render:({field:a})=>r.jsx(o.Select,{label:r.jsx(s0,{}),required:!0,data:i,sx:{flex:1},...a})})]}),r.jsx(o.Divider,{mb:-15,label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:a})=>r.jsx(Jt,{sx:{width:"48%"},...a})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:a})=>r.jsx(St,{...a})})]}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:a})=>r.jsx(kt,{...a})})]})}const yn=m.forwardRef(({label:e,value:t,onChange:n,sx:s={},disabled:i},a)=>{const{t:l,i18n:c}=_.useTranslation(),u=m.useMemo(()=>[{label:l("chart.name_text.align.left"),value:"left"},{label:l("chart.name_text.align.center"),value:"center"},{label:l("chart.name_text.align.right"),value:"right"}],[c.language]);return r.jsx(o.Select,{ref:a,label:e??l("chart.name_text.align.label"),data:u,value:t,onChange:n,sx:s,disabled:i})}),Ip=m.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:a("chart.y_axis.position.left"),value:"left"},{label:a("chart.y_axis.position.right"),value:"right"}],[l.language]);return r.jsx(o.Select,{ref:i,label:e??a("chart.y_axis.position.label"),data:c,value:t,onChange:n,sx:s})});function a0({control:e,index:t}){const{t:n}=_.useTranslation();return r.jsxs(o.Stack,{my:0,p:"0",sx:{position:"relative"},children:[r.jsx(o.Divider,{mb:-15,mt:15,variant:"dashed",label:n("common.name"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.y_axis.y_axis_name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:s})=>r.jsx(yn,{sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.layout"),labelPosition:"center"}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:s})=>r.jsx(Ip,{sx:{flex:1},...s})})}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.label_format"),labelPosition:"center"}),r.jsx(b.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:s})=>r.jsx(ft,{...s})})]}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.value_range"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.y_axis.value_min"),...s})}),r.jsx(b.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.y_axis.value_max"),...s})})]})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:n("chart.y_axis.behavior"),labelPosition:"center"}),r.jsx(b.Controller,{name:`y_axes.${t}.show`,control:e,render:({field:s})=>r.jsx(o.Checkbox,{label:n("chart.y_axis.visible"),checked:s.value,onChange:i=>s.onChange(i.currentTarget.checked)})})]})}function o0({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>({name:"",position:"left",nameAlignment:"left",label_formatter:Me,min:"",max:"",show:!0}),i=(l,c)=>{const u=l.name.trim();return u||c+1},a=({field:l,index:c,fields:u})=>u.length<=1;return r.jsx(fe,{control:e,watch:t,name:"y_axes",getItem:s,addButtonText:n("chart.y_axis.add"),deleteButtonText:n("chart.y_axis.delete"),renderTabName:i,deleteDisalbed:a,children:({field:l,index:c})=>r.jsx(a0,{control:e,index:c})})}function l0({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=m.useMemo(()=>v.defaultsDeep({},n,Ka),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]);const h=d(),f=m.useMemo(()=>!v.isEqual(h,a),[h,a]);return u(["dataZoom"]),r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:c(s),children:[r.jsx(Ce,{canSubmit:f}),r.jsxs(o.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Y Axes",children:t("chart.y_axis.labels")}),r.jsx(o.Tabs.Tab,{value:"Series",children:t("chart.series.label")}),r.jsx(o.Tabs.Tab,{value:"Regression Lines",children:t("chart.regression_line.labels")}),r.jsx(o.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")}),r.jsx(o.Tabs.Tab,{value:"Stats",children:t("chart.stats.label")}),r.jsx(o.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")}),r.jsx(o.Tabs.Tab,{value:"Reference Areas",children:t("chart.reference_area.labels")}),r.jsx(o.Tabs.Tab,{value:"Zooming",children:t("chart.zooming.label")})]}),r.jsx(o.Tabs.Panel,{value:"X Axis",children:r.jsx(i0,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Y Axes",children:r.jsx(o0,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Series",children:r.jsx(Hw,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Regression Lines",children:r.jsx(lj,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(r0,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Stats",children:r.jsx(e0,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx(aj,{variables:i,control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Reference Areas",children:r.jsx(sj,{variables:i,control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Zooming",children:r.jsx(b.Controller,{name:"dataZoom",control:l,render:({field:g})=>r.jsx(Ps,{...g})})})]})]})})}function c0(e){const t=v.cloneDeep(v.omit(e,"variables"));return t.stats=v.omit(t.stats,"variables"),t}function u0(e){const{rotate:t,formatter:n=Oe()}=e.x_axis.axisLabel;return{...e,x_axis:{...e.x_axis,axisLabel:{rotate:t,formatter:n}}}}function d0(e){const{dataZoom:t=jn,...n}=e;return{...n,dataZoom:t}}function p0(e){const t={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return v.defaultsDeep(t,e)}function h0(e){const t=e.reference_lines.map(n=>{const{lineStyle:s={type:"dashed",width:1,color:Qt.random().css()},show_in_legend:i=!1}=n;return{...n,lineStyle:s,show_in_legend:i}});return{...e,reference_lines:t}}function f0(e){const t=e.reference_lines.map(n=>{const{yAxisIndex:s=0}=n;return{...n,yAxisIndex:s}});return{...e,reference_lines:t}}function m0(e){const t=e.series.map(n=>{const{aggregation_on_group:s=Bn}=n;return{...n,aggregation_on_group:s}});return{...e,series:t}}function g0(e){const t=e.series.map(n=>{const{aggregation_on_value:s=Bn}=n;return{...n,aggregation_on_value:s}});return{...e,series:t}}function x0(e){delete e.config;const{x_axis:t,tooltip:n}=e.x_axis.axisLabel.overflow,s={x_axis:{axisLabel:{overflow:{on_axis:t,in_tooltip:n}}}};return v.defaultsDeep(s,e)}function y0(e){const{series:t,...n}=e;return{...n,series:t.map(s=>{const{barMinWidth:i,barWidth:a,barMaxWidth:l}=s;return i?{...s,barMinWidth:i,barWidth:"",barMaxWidth:l??a}:{...s,barMinWidth:"",barWidth:a,barMaxWidth:""}})}}function b0(e){const{y_axes:t,...n}=e;return{...n,y_axes:t.map(s=>{const{min:i="",max:a=""}=s;return{...s,min:i,max:a}})}}function v0(e){const{y_axes:t,...n}=e;return{...n,y_axes:t.map(s=>{const{nameAlignment:i="left"}=s;return{...s,nameAlignment:i}})}}function _0(e){const{y_axes:t,...n}=e;return{...n,y_axes:t.map(s=>{const{show:i=!0}=s;return{...s,show:i}})}}function j0(e){const{regressions:t,...n}=e;return{...n,regressions:t.map(s=>{const{group_by_key:i=""}=s;return{...s,group_by_key:i}})}}function w0(e){const{series:t,y_axes:n,...s}=e;return{...s,series:t.map(i=>{const{hide_in_legend:a=!1,aggregation_on_value:l=Bn}=i;return{...i,hide_in_legend:a,aggregation_on_value:l}}),y_axes:n.map(i=>{const{min:a="",max:l="",show:c=!0}=i;return{...i,min:a,max:l,show:c}})}}function C0(e){const{type:t="category",...n}=e.x_axis;return{...e,x_axis:{...n,type:t}}}function S0(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis_data_key:i,series:a,regressions:l,...c}=e;return{...c,x_axis_data_key:s(i),series:a.map(u=>({...u,y_axis_data_key:s(u.y_axis_data_key),group_by_key:s(u.group_by_key)})),regressions:l.map(u=>({...u,y_axis_data_key:s(u.y_axis_data_key),group_by_key:s(u.group_by_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}function k0(e){const{tooltip:t={metrics:[]},...n}=e;return{...e,tooltip:t}}const T0=[{lang:"en",resources:{cartesian_chart:{viz_name:"Cartesian Chart",series:{aggregation:{label:"Aggregation on Value"}},click_series:{label:"Click bar, line or scatter"}}}},{lang:"zh",resources:{cartesian_chart:{viz_name:"复合图",series:{aggregation:{label:"聚合数据"}},click_series:{label:"点击柱、线或散点"}}}}];class D0 extends ge{constructor(){super(...arguments);B(this,"VERSION",19)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,{panelModel:s})=>{const{config:i}=n;return(i.variables||[]).forEach(c=>{s.variables.find(u=>u.name===c.name)||s.addVariable(c)}),(v.get(i,"stats.variables")||[]).forEach(c=>{s.variables.find(u=>u.name===c.name)||s.addVariable(c)}),{...n,version:2,config:c0(i)}}),this.version(3,n=>({...n,version:3,config:u0(n.config)})),this.version(4,n=>({...n,version:4,config:d0(n.config)})),this.version(5,n=>({...n,version:5,config:p0(n.config)})),this.version(6,n=>({...n,version:6,config:h0(n.config)})),this.version(7,n=>({...n,version:7,config:f0(n.config)})),this.version(8,n=>({...n,version:8,config:m0(n.config)})),this.version(9,n=>({...n,version:9,config:g0(n.config)})),this.version(10,n=>({...n,version:10,config:x0(n.config)})),this.version(11,n=>({...n,version:11,config:y0(n.config)})),this.version(12,n=>({...n,version:12,config:b0(n.config)})),this.version(13,n=>({...n,version:13,config:v0(n.config)})),this.version(14,n=>({...n,version:14,config:_0(n.config)})),this.version(15,n=>({...n,version:15,config:j0(n.config)})),this.version(16,n=>({...n,version:16,config:w0(n.config)})),this.version(17,n=>({...n,version:17,config:C0(n.config)})),this.version(18,(n,s)=>({...n,version:18,config:S0(n.config,s)})),this.version(19,n=>({...n,version:19,config:k0(n.config)}))}}const M0={displayName:"viz.cartesian_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new D0,name:"cartesian",viewRender:nj,configRender:l0,createConfig(){return{version:19,config:v.cloneDeep(Ka)}},triggers:[Ya],translation:T0};function z0(e){if(e.enable_value)return e.value}function I0(e){if(e.enable_value)return e.value}function E0(e){const t=e.axisLabel.overflow.on_axis.width,n=e.axisLabel.position,s={top:5,left:5,right:5,bottom:5};return e.orient==="vertical"&&v.get(s,n)&&n===e.funnelAlign&&v.set(s,n,t),s}function A0(e,t){return e.series.map(n=>{const{level_name_data_key:s,level_value_data_key:i,axisLabel:a,min:l,max:c,funnelAlign:u,orient:d,...p}=n;if(!s||!i)return{};const h=O(s),f=O(i),g=t[h.queryID].map(j=>({name:j[h.columnKey],value:j[f.columnKey]})),y=ut(a.overflow.on_axis);return{type:"funnel",...E0(n),min:z0(l),max:I0(c),minSize:l.size,maxSize:c.size,...p,label:{show:!0,position:a.position,...y},orient:d,funnelAlign:d==="horizontal"?"center":u,data:g}})}function P0({conf:e,params:t,max:n}){const{name:s,value:i}=t.data,a=U(i/n,{output:"percent",mantissa:2,trimMantissa:!0,absolute:!1});return[{label:`${t.marker} ${s}`,value:`${i} (${a})`,style:{label:"",value:""}}]}function O0(e,t){var a;const n=O(e.series[0].level_name_data_key),s=O(e.series[0].level_value_data_key),i=(a=v.maxBy(t[n.queryID],s.columnKey))==null?void 0:a[s.columnKey];return l=>{const u=P0({conf:e,params:l,max:i}).map(p=>`
133
135
  <tr>
134
136
  <th style="text-align: right;">
135
137
  <div style="${p.style.label}">${p.label}</div>
@@ -145,13 +147,13 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
145
147
  <table style="width: auto">
146
148
  <tbody>${u.join("")}</tbody>
147
149
  </table>
148
- `}}function Nf(t,e){return te.getTooltip({trigger:"item",formatter:Vf(t,e)})}function Gf(t,e){return{grid:{top:0,left:0,right:0,bottom:0},tooltip:Nf(t,e),series:qf(t,e)}}function Ff(t){return t||(t=Date.now().toString()),{id:t,name:t,level_name_data_key:"",level_value_data_key:"",min:{value:0,enable_value:!1,size:"0%"},max:{value:0,enable_value:!1,size:"100%"},gap:2,axisLabel:{show:!0,position:"inside",overflow:$e()},sort:"descending",orient:"vertical",funnelAlign:"center"}}const vr={series:[Ff("Funnel")]};function Wf({conf:t,data:e,width:n,height:r}){const i=m.useMemo(()=>Gf(t,e),[t,e]);return s.jsx(Se,{echarts:Ce,option:i,style:{width:n,height:r},notMerge:!0,theme:"merico-light"})}function Qf({context:t}){const{value:e}=q(t.instanceData,"config"),n=m.useMemo(()=>b.defaults({},e,vr),[e]),r=t.data,{width:i,height:o}=t.viewport;return!i||!o?null:s.jsx(Ae,{width:i,height:o,children:s.jsx(Wf,{width:He(i),height:et(o),data:r,conf:n})})}const Rf=({item:t,control:e,index:n,remove:r})=>{const{t:i,i18n:o}=_.useTranslation(),l=t.min.enable_value,c=t.max.enable_value,{orient:u}=t,d=m.useMemo(()=>({horizontal:[{label:i("chart.label_position.top"),value:"top"},{label:i("chart.label_position.inside_center"),value:"inside"},{label:i("chart.label_position.bottom"),value:"bottom"}],vertical:[{label:i("chart.label_position.left"),value:"left"},{label:i("chart.label_position.inside_left"),value:"insideLeft"},{label:i("chart.label_position.inside_center"),value:"inside"},{label:i("chart.label_position.inside_right"),value:"insideRight"},{label:i("chart.label_position.right"),value:"right"}]}),[o.language]),p=m.useMemo(()=>[{label:i("viz.funnel_chart.sort.ascending"),value:"ascending"},{label:i("viz.funnel_chart.sort.descending"),value:"descending"},{label:i("viz.funnel_chart.sort.none"),value:"0"}],[o.language]);return s.jsxs(a.Stack,{children:[s.jsx(a.Group,{grow:!0,noWrap:!0,children:s.jsx(y.Controller,{name:`series.${n}.name`,control:e,render:({field:h})=>s.jsx(a.TextInput,{label:i("viz.funnel_chart.series_name"),...h})})}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${n}.level_name_data_key`,control:e,render:({field:h})=>s.jsx(O,{label:i("viz.funnel_chart.level_name_field"),...h})}),s.jsx(y.Controller,{name:`series.${n}.level_value_data_key`,control:e,render:({field:h})=>s.jsx(O,{label:i("viz.funnel_chart.level_value_field"),...h})})]}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:i("viz.funnel_chart.funnel_style"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${n}.min.value`,control:e,render:({field:h})=>s.jsx(a.NumberInput,{disabled:!l,labelProps:{display:"block"},label:s.jsxs(a.Group,{position:"apart",pr:6,sx:{width:"100%"},children:[s.jsx(a.Text,{children:i("viz.funnel_chart.min_value")}),s.jsx(a.Tooltip,{label:i("viz.funnel_chart.min_value_checkbox_tip"),children:s.jsx(a.Box,{children:s.jsx(y.Controller,{name:`series.${n}.min.enable_value`,control:e,render:({field:g})=>s.jsx(a.Checkbox,{size:"xs",checked:g.value,onChange:f=>g.onChange(f.currentTarget.checked)})})})})]}),...h})}),s.jsx(y.Controller,{name:`series.${n}.min.size`,control:e,render:({field:h})=>s.jsx(a.TextInput,{placeholder:"0%",label:i("viz.funnel_chart.min_size"),...h})})]}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${n}.max.value`,control:e,render:({field:h})=>s.jsx(a.NumberInput,{disabled:!c,labelProps:{display:"block"},label:s.jsxs(a.Group,{position:"apart",pr:6,sx:{width:"100%"},children:[s.jsx(a.Text,{children:i("viz.funnel_chart.max_value")}),s.jsx(a.Tooltip,{label:i("viz.funnel_chart.max_value_checkbox_tip"),children:s.jsx(a.Box,{children:s.jsx(y.Controller,{name:`series.${n}.max.enable_value`,control:e,render:({field:g})=>s.jsx(a.Checkbox,{size:"xs",checked:g.value,onChange:f=>g.onChange(f.currentTarget.checked)})})})})]}),...h})}),s.jsx(y.Controller,{name:`series.${n}.max.size`,control:e,render:({field:h})=>s.jsx(a.TextInput,{placeholder:"100%",label:i("viz.funnel_chart.max_size"),...h})})]}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${n}.orient`,control:e,render:({field:h})=>s.jsx(Ct,{...h})}),s.jsx(y.Controller,{name:`series.${n}.sort`,control:e,render:({field:h})=>s.jsx(a.Select,{label:i("viz.funnel_chart.sort.label"),data:p,...h})})]}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${n}.funnelAlign`,control:e,render:({field:h})=>s.jsx(Tt,{label:i("viz.funnel_chart.align"),disabled:u==="horizontal",...h})}),s.jsx(y.Controller,{name:`series.${n}.gap`,control:e,render:({field:h})=>s.jsx(a.NumberInput,{placeholder:"0, 5, 10...",label:i("viz.funnel_chart.gap"),...h})})]}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.label.label_style"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${n}.axisLabel.position`,control:e,render:({field:h})=>s.jsx(Kt,{label:i("chart.label_position.label"),options:d[u],...h})}),s.jsx(a.Box,{})]}),s.jsx(a.Group,{grow:!0,noWrap:!0,children:s.jsx(y.Controller,{name:`series.${n}.axisLabel.overflow`,control:e,render:({field:h})=>s.jsx(nt,{...h})})})]})},Uf=({control:t,watch:e})=>{const{fields:n,append:r,remove:i}=y.useFieldArray({control:t,name:"series"}),o=e("series"),l=n.map((p,h)=>({...p,...o[h]})),c=b.get(l,"0.id"),[u,d]=m.useState(c??null);return m.useEffect(()=>{c&&d(p=>p!==null?p:c)},[c]),s.jsxs(a.Tabs,{value:u,onTabChange:p=>d(p),styles:{panel:{padding:"0px",paddingTop:"6px"}},children:[s.jsxs(a.Tabs.List,{children:[l.map((p,h)=>s.jsx(a.Tabs.Tab,{value:p.id,children:p.name},p.id)),s.jsx(a.Tabs.Tab,{value:"add",disabled:!0,children:s.jsx(a.Tooltip,{label:"todo",children:s.jsx(a.Center,{children:s.jsx(k.IconPlus,{size:18,color:"#228be6"})})})})]}),l.map((p,h)=>s.jsx(a.Tabs.Panel,{value:p.id,children:s.jsx(Rf,{item:p,control:t,index:h,remove:i})},p.id))]})};function Yf({context:t}){const{value:e,set:n}=q(t.instanceData,"config"),r=m.useMemo(()=>b.defaultsDeep({},e,vr),[e]),{control:i,handleSubmit:o,watch:l,getValues:c,reset:u}=y.useForm({defaultValues:r});m.useEffect(()=>{u(r)},[r]),l([]);const d=c(),p=m.useMemo(()=>!b.isEqual(d,r),[d,r]);return s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:o(n),children:[s.jsx(ge,{canSubmit:p}),s.jsx(Uf,{control:i,watch:l})]})})}const Kf=[{lang:"en",resources:{funnel_chart:{viz_name:"Funnel Chart",series_name:"Series Name",level_name_field:"Level Name Field",level_value_field:"Level Value Field",funnel_style:"Funnel Style",min_value:"Min Value",min_value_checkbox_tip:"Check to enable specific min value",max_value:"Max Value",max_value_checkbox_tip:"Check to enable specific max value",min_size:"Min Size",max_size:"Max Size",sort:{label:"Sort",ascending:"Ascending",descending:"Descending",none:"Use original data order"},gap:"Gap",align:"Align"}}},{lang:"zh",resources:{funnel_chart:{viz_name:"漏斗图",series_name:"系列名称",level_name_field:"层名字段",level_value_field:"层值字段",funnel_style:"漏斗样式",min_value:"最小值",min_value_checkbox_tip:"勾选以启用最小值设置",max_value:"最大值",max_value_checkbox_tip:"勾选以启用最大值设置",min_size:"最小尺寸",max_size:"最大尺寸",sort:{label:"排序",ascending:"升序",descending:"降序",none:"依原始数据的顺序"},gap:"间距",align:"对齐"}}}];function Jf(t){return{series:t.series.map(e=>{const{min:n,minSize:r,max:i,maxSize:o,...l}=e;return{...l,min:{value:n,use_data_min:!1,size:r},max:{value:i,use_data_max:!1,size:o}}})}}function Xf(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=l=>l&&`${n}.${l}`,{series:i,...o}=t;return{...o,series:i.map(l=>({...l,level_name_data_key:r(l.level_name_data_key),level_value_data_key:r(l.level_value_data_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class Zf extends ce{constructor(){super(...arguments);$(this,"VERSION",3)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{config:r}=n;return{...n,version:2,config:Jf(r)}}),this.version(3,(n,r)=>{const{config:i}=n;return{...n,version:3,config:Xf(i,r)}})}}const Hf={displayName:"viz.funnel_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Zf,name:"funnel",viewRender:Qf,configRender:Yf,createConfig:()=>({version:3,config:vr}),translation:Kf};function ey(t){const e=Pe(t.x_axis.axisLabel.formatter),n=Pe(t.y_axis.axisLabel.formatter);return{x_axis:e,y_axis:n}}function ty(t){return{heat_block:function(r){if(!t.heat_block.value_formatter)return r;try{return U(r,t.heat_block.value_formatter)}catch(i){return console.error(i),r}}}}function ny(t){let e=0;return t.x_axis.name&&(e+=20),{show:!0,top:45,left:5,right:5,bottom:e,containLabel:!0,borderColor:"none",backgroundColor:"#E7E7E9",z:1}}function sy(t,e,n){const{heat_block:r}=t;return{type:"heatmap",name:r.name,xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{borderColor:"white",borderWidth:n},data:e,label:r.label,labelLayout:{hideOverlap:!0},z:2}}const ry=t=>U(t,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function iy({conf:t,labelFormatters:e,valueFormatters:n,dataDict:r,params:i}){const{value:o,dataIndex:l}=i,[c,u,d]=o,p={label:t.x_axis.name?t.x_axis.name:"X Axis",value:e.x_axis(c,l),style:{label:"",value:We(t.x_axis.axisLabel.overflow.in_tooltip)}},h={label:t.y_axis.name?t.y_axis.name:"Y Axis",value:e.y_axis(u,l),style:{label:"",value:We(t.y_axis.axisLabel.overflow.in_tooltip)}},g={label:t.heat_block.name,value:n.heat_block(d),style:{label:"",value:""}},f=[p,h,g],v=r[`${c}---${u}`];return v&&t.tooltip.metrics.forEach(w=>{const T=A(w.data_key);f.push({label:w.name,value:ry(b.get(v,T.columnKey,"")),style:{label:"",value:""}})}),f}function ay(t,e,n,r){const{x_axis:i,y_axis:o,heat_block:l}=t,c=A(i.data_key),u=A(o.data_key);A(l.data_key);const d=b.keyBy(e[c.queryID],p=>`${p[c.columnKey]}---${p[u.columnKey]}`);return te.getTooltip({formatter:function(p){const g=iy({conf:t,labelFormatters:n,valueFormatters:r,dataDict:d,params:p}).map(v=>`
150
+ `}}function L0(e,t){return te.getTooltip({trigger:"item",formatter:O0(e,t)})}function B0(e,t){return{grid:{top:0,left:0,right:0,bottom:0},tooltip:L0(e,t),series:A0(e,t)}}function q0(e){return e||(e=Date.now().toString()),{id:e,name:e,level_name_data_key:"",level_value_data_key:"",min:{value:0,enable_value:!1,size:"0%"},max:{value:0,enable_value:!1,size:"100%"},gap:2,axisLabel:{show:!0,position:"inside",overflow:Ke()},sort:"descending",orient:"vertical",funnelAlign:"center"}}const _o={series:[q0("Funnel")]};function V0({conf:e,data:t,width:n,height:s}){const i=m.useMemo(()=>B0(e,t),[e,t]);return r.jsx(Pe,{echarts:Ae,option:i,style:{width:n,height:s},notMerge:!0,theme:"merico-light"})}function N0({context:e}){const{value:t}=$(e.instanceData,"config"),n=m.useMemo(()=>v.defaults({},t,_o),[t]),s=e.data,{width:i,height:a}=e.viewport;return!i||!a?null:r.jsx(Ue,{width:i,height:a,children:r.jsx(V0,{width:wt(i),height:Ct(a),data:s,conf:n})})}const $0=({item:e,control:t,index:n,remove:s})=>{const{t:i,i18n:a}=_.useTranslation(),l=e.min.enable_value,c=e.max.enable_value,{orient:u}=e,d=m.useMemo(()=>({horizontal:[{label:i("chart.label_position.top"),value:"top"},{label:i("chart.label_position.inside_center"),value:"inside"},{label:i("chart.label_position.bottom"),value:"bottom"}],vertical:[{label:i("chart.label_position.left"),value:"left"},{label:i("chart.label_position.inside_left"),value:"insideLeft"},{label:i("chart.label_position.inside_center"),value:"inside"},{label:i("chart.label_position.inside_right"),value:"insideRight"},{label:i("chart.label_position.right"),value:"right"}]}),[a.language]),p=m.useMemo(()=>[{label:i("viz.funnel_chart.sort.ascending"),value:"ascending"},{label:i("viz.funnel_chart.sort.descending"),value:"descending"},{label:i("viz.funnel_chart.sort.none"),value:"0"}],[a.language]);return r.jsxs(o.Stack,{children:[r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:`series.${n}.name`,control:t,render:({field:h})=>r.jsx(o.TextInput,{label:i("viz.funnel_chart.series_name"),...h})})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${n}.level_name_data_key`,control:t,render:({field:h})=>r.jsx(F,{label:i("viz.funnel_chart.level_name_field"),...h})}),r.jsx(b.Controller,{name:`series.${n}.level_value_data_key`,control:t,render:({field:h})=>r.jsx(F,{label:i("viz.funnel_chart.level_value_field"),...h})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("viz.funnel_chart.funnel_style"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${n}.min.value`,control:t,render:({field:h})=>r.jsx(o.NumberInput,{disabled:!l,labelProps:{display:"block"},label:r.jsxs(o.Group,{position:"apart",pr:6,sx:{width:"100%"},children:[r.jsx(o.Text,{children:i("viz.funnel_chart.min_value")}),r.jsx(o.Tooltip,{label:i("viz.funnel_chart.min_value_checkbox_tip"),children:r.jsx(o.Box,{children:r.jsx(b.Controller,{name:`series.${n}.min.enable_value`,control:t,render:({field:f})=>r.jsx(o.Checkbox,{size:"xs",checked:f.value,onChange:g=>f.onChange(g.currentTarget.checked)})})})})]}),...h})}),r.jsx(b.Controller,{name:`series.${n}.min.size`,control:t,render:({field:h})=>r.jsx(o.TextInput,{placeholder:"0%",label:i("viz.funnel_chart.min_size"),...h})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${n}.max.value`,control:t,render:({field:h})=>r.jsx(o.NumberInput,{disabled:!c,labelProps:{display:"block"},label:r.jsxs(o.Group,{position:"apart",pr:6,sx:{width:"100%"},children:[r.jsx(o.Text,{children:i("viz.funnel_chart.max_value")}),r.jsx(o.Tooltip,{label:i("viz.funnel_chart.max_value_checkbox_tip"),children:r.jsx(o.Box,{children:r.jsx(b.Controller,{name:`series.${n}.max.enable_value`,control:t,render:({field:f})=>r.jsx(o.Checkbox,{size:"xs",checked:f.value,onChange:g=>f.onChange(g.currentTarget.checked)})})})})]}),...h})}),r.jsx(b.Controller,{name:`series.${n}.max.size`,control:t,render:({field:h})=>r.jsx(o.TextInput,{placeholder:"100%",label:i("viz.funnel_chart.max_size"),...h})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${n}.orient`,control:t,render:({field:h})=>r.jsx(gn,{...h})}),r.jsx(b.Controller,{name:`series.${n}.sort`,control:t,render:({field:h})=>r.jsx(o.Select,{label:i("viz.funnel_chart.sort.label"),data:p,...h})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${n}.funnelAlign`,control:t,render:({field:h})=>r.jsx(yn,{label:i("viz.funnel_chart.align"),disabled:u==="horizontal",...h})}),r.jsx(b.Controller,{name:`series.${n}.gap`,control:t,render:({field:h})=>r.jsx(o.NumberInput,{placeholder:"0, 5, 10...",label:i("viz.funnel_chart.gap"),...h})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.label.label_style"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${n}.axisLabel.position`,control:t,render:({field:h})=>r.jsx(tr,{label:i("chart.label_position.label"),options:d[u],...h})}),r.jsx(o.Box,{})]}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:`series.${n}.axisLabel.overflow`,control:t,render:({field:h})=>r.jsx(kt,{...h})})})]})},F0=({control:e,watch:t})=>{const{fields:n,append:s,remove:i}=b.useFieldArray({control:e,name:"series"}),a=t("series"),l=n.map((p,h)=>({...p,...a[h]})),c=v.get(l,"0.id"),[u,d]=m.useState(c??null);return m.useEffect(()=>{c&&d(p=>p!==null?p:c)},[c]),r.jsxs(o.Tabs,{value:u,onTabChange:p=>d(p),styles:{panel:{padding:"0px",paddingTop:"6px"}},children:[r.jsxs(o.Tabs.List,{children:[l.map((p,h)=>r.jsx(o.Tabs.Tab,{value:p.id,children:p.name},p.id)),r.jsx(o.Tabs.Tab,{value:"add",disabled:!0,children:r.jsx(o.Tooltip,{label:"todo",children:r.jsx(o.Center,{children:r.jsx(M.IconPlus,{size:18,color:"#228be6"})})})})]}),l.map((p,h)=>r.jsx(o.Tabs.Panel,{value:p.id,children:r.jsx($0,{item:p,control:e,index:h,remove:i})},p.id))]})};function G0({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=m.useMemo(()=>v.defaultsDeep({},t,_o),[t]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});m.useEffect(()=>{u(s)},[s]),l([]);const d=c(),p=m.useMemo(()=>!v.isEqual(d,s),[d,s]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(Ce,{canSubmit:p}),r.jsx(F0,{control:i,watch:l})]})})}const W0=[{lang:"en",resources:{funnel_chart:{viz_name:"Funnel Chart",series_name:"Series Name",level_name_field:"Level Name Field",level_value_field:"Level Value Field",funnel_style:"Funnel Style",min_value:"Min Value",min_value_checkbox_tip:"Check to enable specific min value",max_value:"Max Value",max_value_checkbox_tip:"Check to enable specific max value",min_size:"Min Size",max_size:"Max Size",sort:{label:"Sort",ascending:"Ascending",descending:"Descending",none:"Use original data order"},gap:"Gap",align:"Align"}}},{lang:"zh",resources:{funnel_chart:{viz_name:"漏斗图",series_name:"系列名称",level_name_field:"层名字段",level_value_field:"层值字段",funnel_style:"漏斗样式",min_value:"最小值",min_value_checkbox_tip:"勾选以启用最小值设置",max_value:"最大值",max_value_checkbox_tip:"勾选以启用最大值设置",min_size:"最小尺寸",max_size:"最大尺寸",sort:{label:"排序",ascending:"升序",descending:"降序",none:"依原始数据的顺序"},gap:"间距",align:"对齐"}}}];function R0(e){return{series:e.series.map(t=>{const{min:n,minSize:s,max:i,maxSize:a,...l}=t;return{...l,min:{value:n,use_data_min:!1,size:s},max:{value:i,use_data_max:!1,size:a}}})}}function Q0(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=l=>l&&`${n}.${l}`,{series:i,...a}=e;return{...a,series:i.map(l=>({...l,level_name_data_key:s(l.level_name_data_key),level_value_data_key:s(l.level_value_data_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class U0 extends ge{constructor(){super(...arguments);B(this,"VERSION",3)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{config:s}=n;return{...n,version:2,config:R0(s)}}),this.version(3,(n,s)=>{const{config:i}=n;return{...n,version:3,config:Q0(i,s)}})}}const Y0={displayName:"viz.funnel_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new U0,name:"funnel",viewRender:N0,configRender:G0,createConfig:()=>({version:3,config:_o}),translation:W0};function K0(e){const t=Ye(e.x_axis.axisLabel.formatter),n=Ye(e.y_axis.axisLabel.formatter);return{x_axis:t,y_axis:n}}function X0(e){return{heat_block:function(s){if(!e.heat_block.value_formatter)return s;try{return U(s,e.heat_block.value_formatter)}catch(i){return console.error(i),s}}}}function J0(e){let t=0;return e.x_axis.name&&(t+=20),{show:!0,top:45,left:5,right:5,bottom:t,containLabel:!0,borderColor:"none",backgroundColor:"#E7E7E9",z:1}}function Z0(e,t,n){const{heat_block:s}=e;return{type:"heatmap",name:s.name,xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{borderColor:"white",borderWidth:n},data:t,label:s.label,labelLayout:{hideOverlap:!0},z:2}}const H0=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function eC({conf:e,labelFormatters:t,valueFormatters:n,dataDict:s,params:i}){const{value:a,dataIndex:l}=i,[c,u,d]=a,p={label:e.x_axis.name?e.x_axis.name:"X Axis",value:t.x_axis(c,l),style:{label:"",value:ct(e.x_axis.axisLabel.overflow.in_tooltip)}},h={label:e.y_axis.name?e.y_axis.name:"Y Axis",value:t.y_axis(u,l),style:{label:"",value:ct(e.y_axis.axisLabel.overflow.in_tooltip)}},f={label:e.heat_block.name,value:n.heat_block(d),style:{label:"",value:""}},g=[p,h,f],y=s[`${c}---${u}`];return y&&e.tooltip.metrics.forEach(j=>{const k=O(j.data_key);g.push({label:j.name,value:H0(v.get(y,k.columnKey,"")),style:{label:"",value:""}})}),g}function tC(e,t,n,s){const{x_axis:i,y_axis:a,heat_block:l}=e,c=O(i.data_key),u=O(a.data_key);O(l.data_key);const d=v.keyBy(t[c.queryID],p=>`${p[c.columnKey]}---${p[u.columnKey]}`);return te.getTooltip({formatter:function(p){const f=eC({conf:e,labelFormatters:n,valueFormatters:s,dataDict:d,params:p}).map(y=>`
149
151
  <tr>
150
152
  <th style="text-align: right;">
151
- <div style="${v.style.label}">${v.label}</div>
153
+ <div style="${y.style.label}">${y.label}</div>
152
154
  </th>
153
155
  <td style="text-align: right; padding: 0 1em;">
154
- <div style="${v.style.value}">${v.value}
156
+ <div style="${y.style.value}">${y.value}
155
157
  </td>
156
158
  </tr>
157
159
  `);return`
@@ -164,26 +166,26 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
164
166
  />
165
167
  </tr>
166
168
  </thead>
167
- <tbody>${g.join("")}</tbody>
169
+ <tbody>${f.join("")}</tbody>
168
170
  </table>
169
- `}})}function oy(t,e,n,r){const{overflow:i,rotate:o}=t.x_axis.axisLabel,l=Qe(i.on_axis);return te.getXAxis({id:"main-x-axis",type:"category",data:e,name:t.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:o,...l,formatter:n},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:r>0,interval:0,lineStyle:{type:"solid",color:"white"}},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:3})}function ly(t,e,n,r){const{nameAlignment:i,data_key:o,...l}=t.y_axis,{overflow:c,rotate:u}=t.y_axis.axisLabel,d=Qe(c.on_axis);return te.getYAxis({...l,type:"category",data:e,axisLabel:{rotate:u,...d,formatter:n},axisTick:{show:!0,alignWithLabel:!0},axisLine:{show:!0,lineStyle:{width:3}},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:r>0,interval:0,lineStyle:{type:"solid",color:"white"}},nameTextStyle:{fontWeight:"bold",align:i},nameLocation:"end",nameGap:15,z:3})}const cy=({value:t,onChange:e})=>{const n=r=>{r&&e(r)};return s.jsx(a.Box,{children:s.jsx(Le,{height:"500px",defaultLanguage:"javascript",value:t,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Bo={static:{type:"static",value:10},dynamic:{type:"dynamic",value:["function getValue({ variables }, { lodash, interpolate }) {"," // your code goes here"," return 100;","}"].join(`
170
- `)}},uy=({value:t,onChange:e})=>{const{t:n}=_.useTranslation(),[r,{setTrue:i,setFalse:o}]=W.useBoolean(),[l,c]=m.useState(t),u=()=>{o();const{type:g,value:f}=l,v={type:g,value:f};c(v),e(v)},d=()=>{o(),c(t)},p=g=>{c(f=>({...f,value:g}))},h=()=>{p(Bo.dynamic.value)};return s.jsxs(s.Fragment,{children:[s.jsx(a.Box,{sx:{width:"50%"},children:s.jsx(a.Button,{color:"grape",variant:"filled",leftIcon:s.jsx(k.IconMathFunction,{size:16}),mt:24,onClick:i,sx:{flexGrow:0},children:n("chart.number_or_dynamic_value.dynamic.setup")})}),s.jsx(a.Modal,{size:800,title:n("chart.number_or_dynamic_value.dynamic.setup_title"),opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mt:10,mb:-10,label:n("chart.number_or_dynamic_value.dynamic.guide"),labelPosition:"center",variant:"dashed"}),s.jsx(cy,{value:l.value,onChange:p}),s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Button,{onClick:h,color:"red",leftIcon:s.jsx(L.Recycle,{size:20}),children:n("common.actions.reset_to_default")}),s.jsxs(a.Group,{position:"right",children:[s.jsx(a.Button,{onClick:d,variant:"subtle",children:n("common.actions.cancel")}),s.jsx(a.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),onClick:u,children:n("common.actions.save")})]})]})]})})]})},dy=({value:t,onChange:e})=>t.type!=="dynamic"?null:s.jsx(uy,{value:t,onChange:e}),py=({value:t,onChange:e})=>{if(t.type!=="static")return null;const n=r=>{e({...t,value:r})};return s.jsx(a.NumberInput,{defaultValue:18,label:" ",hideControls:!0,value:t.value,onChange:n})},Lo=m.forwardRef(({label:t="Value",value:e,onChange:n},r)=>{const{t:i,i18n:o}=_.useTranslation(),l=u=>{n({...Bo[u]})},c=m.useMemo(()=>[{label:i("chart.number_or_dynamic_value.type.static"),value:"static"},{label:i("chart.number_or_dynamic_value.type.dynamic"),value:"dynamic"}],[o.language]);return s.jsxs(a.SimpleGrid,{cols:2,children:[s.jsx(a.Select,{ref:r,label:t,data:c,value:e.type,onChange:l,sx:{flexGrow:1}}),s.jsx(py,{value:e,onChange:n}),s.jsx(dy,{value:e,onChange:n})]})});function qo(t,e,n){if(!t.type)return n;if(t.type==="static"){const{value:i}=t;return Number(i)}const{value:r}=t;try{const i=new Function(`return ${r}`)()({variables:e},{lodash:b,interpolate:Dt.interpolate});return Number(i)}catch(i){return console.error(`[getNumberOrDynamicValue] failed parsing custom function, error: ${i.message}`),10}}const Zn=({label:t,field:e})=>{const{t:n}=_.useTranslation();return s.jsx(a.ColorInput,{label:t,placeholder:n("chart.visual_map.skip_range.follow_visual_map"),size:"xs",withinPortal:!0,dropdownZIndex:340,rightSection:e.value?s.jsx(a.CloseButton,{onClick:()=>{e.onChange("")}}):null,...e})},hy=({form:t})=>{const{t:e}=_.useTranslation();return s.jsxs(a.Stack,{children:[s.jsx(y.Controller,{control:t.control,name:"visualMap.skipRange.lt_min",render:({field:n})=>s.jsx(Zn,{field:n,label:e("chart.visual_map.skip_range.lt_min")})}),s.jsx(y.Controller,{control:t.control,name:"visualMap.skipRange.min",render:({field:n})=>s.jsx(Zn,{field:n,label:e("chart.visual_map.skip_range.min")})}),s.jsx(y.Controller,{control:t.control,name:"visualMap.skipRange.max",render:({field:n})=>s.jsx(Zn,{field:n,label:e("chart.visual_map.skip_range.max")})}),s.jsx(y.Controller,{control:t.control,name:"visualMap.skipRange.gt_max",render:({field:n})=>s.jsx(Zn,{field:n,label:e("chart.visual_map.skip_range.gt_max")})})]})};function Oo(t){return{type:"continuous",id:"continuous-example",min:{type:"static",value:0},max:{type:"static",value:100},orient:"horizontal",left:"center",top:"top",text:["",""],calculable:!0,itemWidth:15,itemHeight:140,show:!0,inRange:{color:t??Object.values(zt.graphics.depth)},skipRange:{lt_min:"",min:"",max:"",gt_max:""}}}function my(){return{type:"piecewise",piecewise_mode:"pieces",id:"piecewise-visualmap",min:{type:"static",value:0},max:{type:"static",value:100},align:"auto",orient:"horizontal",left:"center",top:"top",itemWidth:15,itemHeight:15,show:!0,precision:0,pieces:[Vo()],categories:[]}}function ft(){return Oo()}function xy(){return{compared:Object.values(zt.graphics.compared),level:Object.values(zt.graphics.level),depth:Object.values(zt.graphics.depth),yellow_blue:["#8f531d","#ffd347","#e3efe3","#eefaee","#4ecbbf","#003f94"],blue:["#f9fcff","#48b3e9","#003f94"],darkgreen_pink:["#0c525a","#f21f99"],spectrum:["#ff0000","#ffff00","#00ff00","#00ffff","#0000ff","#ff00ff","#ff0000"]}}function Hn(t,e){const{min:n,max:r}=t,i=qo(n,e),o=qo(r,e);if(t.type==="continuous"){const{skipRange:h,text:g,...f}=t;return{...f,min:i,max:o,text:[...g]}}const{piecewise_mode:l,pieces:c,categories:u,...d}=t,p={...d};return delete p.min,delete p.max,l==="pieces"?p.pieces=c.map(h=>{const g={};h.label&&(g.label=h.label),h.color&&(g.color=h.color);const f=Number(h.lower.value);h.lower.value===""?g[h.lower.symbol]=i:Number.isFinite(f)&&(g[h.lower.symbol]=f);const v=Number(h.upper.value);return h.upper.value===""?g[h.upper.symbol]=o:Number.isFinite(v)&&(g[h.upper.symbol]=v),g}):l==="categories"&&(p.categories=u),p}const Jt=t=>({followVisualMap:!t,color:t});function _r(t,e,n,r){if(r.type!=="continuous")return Jt("");const{skipRange:i}=r;return t===e?Jt(i.min):t===n?Jt(i.max):t<e?Jt(i.lt_min):t>n?Jt(i.gt_max):Jt("")}function Vo(){return{lower:{value:"0",symbol:"gt"},upper:{value:"",symbol:"lt"},label:"",color:""}}const gy=xy(),fy=({colors:t,applyPalette:e})=>{const{t:n}=_.useTranslation(),r=`linear-gradient(to right, ${t.join(", ")})`;return s.jsxs(a.Menu,{shadow:"md",width:300,children:[s.jsx(a.Menu.Target,{children:s.jsxs(a.UnstyledButton,{children:[s.jsx(a.Text,{style:{display:"inline-block",fontSize:"0.875rem",fontWeight:500,color:"#212529",wordBreak:"break-word",cursor:"default"},children:n("chart.color.color_gradient")}),s.jsxs(a.Group,{style:{padding:"0.4375rem 0.625rem",border:"0.0625rem solid #ced4da",borderRadius:"0.25rem",columnGap:10},children:[s.jsx(a.Box,{style:{height:"20px",flexGrow:1,backgroundImage:r,borderRadius:4}}),s.jsx(k.IconSelector,{size:14,color:"rgb(134, 142, 150)"})]})]})}),s.jsxs(a.Menu.Dropdown,{children:[s.jsx(a.Menu.Label,{children:n("chart.visual_map.built_in_palettes")}),s.jsx(a.Menu.Divider,{}),Object.entries(gy).map(([i,o])=>s.jsx(a.Tooltip,{label:n("chart.visual_map.use_palette_x",{x:i}),children:s.jsx(a.Menu.Item,{children:s.jsx(a.Box,{style:{height:"20px",width:"100%",backgroundImage:`linear-gradient(to right, ${o.join(", ")})`,borderRadius:4,boxShadow:"0 0 3px 0 #eee",cursor:"pointer"},onClick:()=>{e(o)},title:i})})},i))]})]})},yy=m.forwardRef(({value:t,onChange:e},n)=>{const{t:r}=_.useTranslation(),i=m.useMemo(()=>t.map(g=>({id:pt.v4(),value:g})),[t]),o=g=>{e([...t,g])},l=g=>{const f=[...t];f.splice(g,1),e(f)},c=g=>{e([...g])},u=g=>f=>{const v=[...t];v[g]=f,e(v)},[d,p]=m.useState(""),h=()=>{d&&(o(d),p(""))};return s.jsxs(a.Stack,{ref:n,children:[s.jsx(fy,{colors:t,applyPalette:c}),s.jsx(a.Table,{withBorder:!1,withColumnBorders:!1,sx:{td:{borderTop:"none !important"}},children:s.jsxs("tbody",{children:[i.map((g,f)=>s.jsxs("tr",{children:[s.jsx("td",{style:{width:"60px"},children:s.jsx(a.Badge,{children:f})}),s.jsx("td",{children:s.jsx(a.ColorInput,{styles:{root:{flexGrow:1}},withinPortal:!0,dropdownZIndex:340,size:"xs",value:g.value,onChange:u(f)})}),s.jsx("td",{style:{width:"40px"},children:s.jsx(a.CloseButton,{onClick:()=>l(f)})})]},g.id)),s.jsxs("tr",{children:[s.jsx("td",{style:{width:"60px"}}),s.jsx("td",{children:s.jsx(a.ColorInput,{withinPortal:!0,dropdownZIndex:340,placeholder:r("chart.color.click_to_add_a_color"),value:d,onChange:p,onBlur:h,size:"xs"})}),s.jsx("td",{style:{width:"40px"}})]})]})})]})}),by=({form:t})=>{const{t:e,i18n:n}=_.useTranslation(),r=t.control,i=t.watch("visualMap"),{type:o,orient:l}=i,c=l==="horizontal",u=d=>p=>{p!==""&&d(p)};return o!=="continuous"?null:s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:"visualMap.text.1",control:r,render:({field:d})=>s.jsx(a.TextInput,{label:e("chart.visual_map.min_text"),...d})}),s.jsx(y.Controller,{name:"visualMap.text.0",control:r,render:({field:d})=>s.jsx(a.TextInput,{label:e("chart.visual_map.max_text"),...d})})]}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:"visualMap.orient",control:r,render:({field:d})=>s.jsx(Ct,{sx:{flex:1},...d})}),s.jsx(y.Controller,{name:"visualMap.calculable",control:r,render:({field:d})=>s.jsx(a.Checkbox,{label:e("chart.visual_map.calculable"),checked:d.value,onChange:p=>d.onChange(p.currentTarget.checked),styles:{root:{transform:"translateY(12px)"}}})})]}),s.jsxs(a.Group,{grow:!0,styles:{root:{flexDirection:c?"row-reverse":"row"}},children:[s.jsx(y.Controller,{name:"visualMap.itemWidth",control:r,render:({field:d})=>s.jsx(a.NumberInput,{label:e(c?"chart.visual_map.bar_height":"chart.visual_map.bar_width"),...d,onChange:u(d.onChange)})}),s.jsx(y.Controller,{name:"visualMap.itemHeight",control:r,render:({field:d})=>s.jsx(a.NumberInput,{label:e(c?"chart.visual_map.bar_width":"chart.visual_map.bar_height"),...d,onChange:u(d.onChange)})})]}),s.jsx(y.Controller,{name:"visualMap.inRange.color",control:r,render:({field:d})=>s.jsx(yy,{...d})}),s.jsx(hy,{form:t})]})},vy=({visualMap:t})=>{const{orient:e,itemWidth:n,itemHeight:r}=t,o=e==="horizontal"?n:r,{panel:l}=ze(),c=Hn(t,l.variableValueMap);return s.jsx(je,{children:s.jsx(Se,{echarts:Ce,option:{visualMap:c},style:{width:"100%",height:`${o+40}px`},notMerge:!0,theme:"merico-light"})})},No={lower:[{label:"<",value:"gt"},{label:"≤",value:"gte"}],upper:[{label:">",value:"lt"},{label:"≥",value:"lte"}]},Go={gt:"(",gte:"[",lt:")",lte:"]"},Fo=(t,e)=>t===""?e:Number.isNaN(Number(t))?"INVALID VALUE":t,_y=({form:t,index:e})=>{const{t:n}=_.useTranslation(),{control:r,watch:i}=t,o=i(`visualMap.pieces.${e}`),{lower:l,upper:c}=o,u=[Go[l.symbol],Fo(l.value,n("chart.visual_map.min_value")),",",Fo(c.value,n("chart.visual_map.max_value")),Go[c.symbol]].join(""),[d,p]=m.useState(!1);return s.jsx(a.Group,{noWrap:!0,children:s.jsxs(a.Popover,{width:400,position:"bottom",withArrow:!0,shadow:"md",opened:d,onChange:p,withinPortal:!0,zIndex:340,children:[s.jsx(a.Popover.Target,{children:s.jsx(a.Button,{variant:"subtle",compact:!0,px:0,onClick:()=>p(h=>!h),sx:{fontFamily:"monospace",fontWeight:"normal"},children:u})}),s.jsx(a.Popover.Dropdown,{children:s.jsxs(a.Group,{noWrap:!0,spacing:8,children:[s.jsx(y.Controller,{name:`visualMap.pieces.${e}.lower.value`,control:r,render:({field:h})=>s.jsx(a.TextInput,{...h,placeholder:n("chart.visual_map.min_value"),size:"xs",onChange:g=>h.onChange(g.currentTarget.value),error:h.value!==""&&Number.isNaN(Number(h.value))})}),s.jsx(y.Controller,{name:`visualMap.pieces.${e}.lower.symbol`,control:r,render:({field:h})=>s.jsx(a.Select,{size:"xs",data:No.lower,...h,onChange:g=>h.onChange(g)})}),s.jsx(a.Text,{color:"dimmed",size:"sm",sx:{userSelect:"none",cursor:"default"},children:n("common.value").toLowerCase()}),s.jsx(y.Controller,{name:`visualMap.pieces.${e}.upper.symbol`,control:r,render:({field:h})=>s.jsx(a.Select,{size:"xs",data:No.upper,...h,onChange:g=>h.onChange(g)})}),s.jsx(y.Controller,{name:`visualMap.pieces.${e}.upper.value`,control:r,render:({field:h})=>s.jsx(a.TextInput,{...h,size:"xs",placeholder:n("chart.visual_map.max_value"),onChange:g=>h.onChange(g.currentTarget.value),error:h.value!==""&&Number.isNaN(Number(h.value))})})]})})]})})},jy=({form:t,index:e,remove:n})=>{const{control:r}=t,{t:i}=_.useTranslation();return s.jsxs("tr",{children:[s.jsx("td",{children:(e+1).toString()}),s.jsx("td",{children:s.jsx(_y,{form:t,index:e})}),s.jsx("td",{children:s.jsx(y.Controller,{name:`visualMap.pieces.${e}.label`,control:r,render:({field:o})=>s.jsx(a.TextInput,{size:"xs",placeholder:"",...o,onChange:l=>o.onChange(l.currentTarget.value)})})}),s.jsx("td",{children:s.jsx(y.Controller,{name:`visualMap.pieces.${e}.color`,control:r,render:({field:o})=>s.jsx(a.ColorInput,{label:i(""),placeholder:i("chart.color.label"),size:"xs",withinPortal:!0,dropdownZIndex:340,rightSection:o.value?s.jsx(a.CloseButton,{onClick:()=>{o.onChange("")}}):null,...o})})}),s.jsx("td",{children:s.jsx(a.CloseButton,{onClick:()=>n(e)})})]})},wy=({form:t})=>{const{t:e,i18n:n}=_.useTranslation(),{fields:r,append:i,remove:o}=y.useFieldArray({control:t.control,name:"visualMap.pieces"}),l=t.watch("visualMap.pieces"),c=r.map((d,p)=>({...d,...l[p]})),u=()=>{i(Vo())};return s.jsx(a.Stack,{children:s.jsxs(a.Table,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"40px"}}),s.jsx("th",{children:e("chart.visual_map.piecewise.interval")}),s.jsx("th",{children:e("chart.visual_map.piecewise.piece_label")}),s.jsx("th",{children:e("chart.color.label")}),s.jsx("th",{style:{width:"40px"}})]})}),s.jsx("tbody",{children:c.map((d,p)=>s.jsx(jy,{index:p,form:t,remove:o},d.id))}),s.jsx("tfoot",{children:s.jsxs("tr",{children:[s.jsx("td",{}),s.jsx("td",{colSpan:3,children:s.jsx(a.Button,{mt:10,size:"xs",color:"blue",leftIcon:s.jsx(k.IconPlaylistAdd,{size:20}),onClick:u,sx:{width:"50%"},mx:"auto",children:e("chart.visual_map.piecewise.add_a_piece")})}),s.jsx("td",{})]})})]})})},Cy=({form:t})=>{const{t:e,i18n:n}=_.useTranslation(),r=t.control,i=t.watch("visualMap");m.useMemo(()=>[{label:e("chart.visual_map.piecewise.mode.pieces"),value:"pieces"},{label:e("chart.visual_map.piecewise.mode.categories"),value:"categories"}],[n.language]);const{type:o,orient:l,piecewise_mode:c}=i,u=d=>p=>{p!==""&&d(p)};return o!=="piecewise"?null:s.jsxs(a.Stack,{children:[s.jsx(y.Controller,{name:"visualMap.precision",control:r,render:({field:d})=>s.jsx(a.NumberInput,{label:e("chart.visual_map.precision"),...d,onChange:u(d.onChange)})}),s.jsx(y.Controller,{name:"visualMap.orient",control:r,render:({field:d})=>s.jsx(Ct,{sx:{flex:1},...d})}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:"visualMap.itemWidth",control:r,render:({field:d})=>s.jsx(a.NumberInput,{label:e("chart.visual_map.item_width"),...d,onChange:u(d.onChange)})}),s.jsx(y.Controller,{name:"visualMap.itemHeight",control:r,render:({field:d})=>s.jsx(a.NumberInput,{label:e("chart.visual_map.item_height"),...d,onChange:u(d.onChange)})})]}),c==="pieces"&&s.jsx(wy,{form:t})]})},jr=({form:t})=>{const{t:e,i18n:n}=_.useTranslation(),r=t.control,i=t.watch("visualMap"),o=m.useMemo(()=>[{label:e("chart.visual_map.continuous.label"),value:"continuous"},{label:e("chart.visual_map.piecewise.label"),value:"piecewise"}],[n.language]),l=c=>{switch(c){case"continuous":t.setValue("visualMap",Oo());break;case"piecewise":t.setValue("visualMap",my());break}};return s.jsx(je,{children:s.jsxs(a.Stack,{children:[s.jsx(vy,{visualMap:i}),s.jsx(y.Controller,{name:"visualMap.type",control:r,render:({field:c})=>s.jsx(a.SegmentedControl,{mt:-10,data:o,sx:{flex:1},...c,onChange:l})}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:"visualMap.min",control:r,render:({field:c})=>s.jsx(Lo,{label:e("chart.visual_map.min_value"),...c})}),s.jsx(y.Controller,{name:"visualMap.max",control:r,render:({field:c})=>s.jsx(Lo,{label:e("chart.visual_map.max_value"),...c})})]}),s.jsx(a.Divider,{variant:"dashed"}),s.jsx(by,{form:t}),s.jsx(Cy,{form:t})]})})};function Sy(t,e,n,r){return n<t*10||r<e*10?0:n<t*20||r<e*20?1:2}function ky(t,e,n,r,i){if(!t.x_axis.data_key||!t.y_axis.data_key||!t.heat_block.data_key)return{};const o=n.reduce((E,V)=>{const F=Ze(V,e);return E[V.name]=Ie(V,F),E},{}),l=Hn(t.visualMap,o),{min:c,max:u}=l,d=ey(t),p=ty(t),h=A(t.x_axis.data_key),g=A(t.y_axis.data_key),f=A(t.heat_block.data_key),v=b.uniq(e[h.queryID].map(E=>E[h.columnKey])),w=b.uniq(e[h.queryID].map(E=>E[g.columnKey])),T=e[h.queryID].map(E=>{const V=b.get(E,h.columnKey),F=b.get(E,g.columnKey),N=b.get(E,f.columnKey),Q={value:[V,F,N]},{followVisualMap:ue,color:le}=_r(N,c,u,t.visualMap);return ue||(Q.visualMap=!1,Q.itemStyle={color:le}),Q}),D=Sy(v.length,w.length,r,i);return{xAxis:oy(t,v,d.x_axis,D),yAxis:ly(t,w,d.y_axis,D),series:sy(t,T,D),tooltip:ay(t,e,d,p),grid:ny(t),visualMap:l}}function Ty(t){return s.jsx(s.Fragment,{})}function Dy(t){const{t:e}=_.useTranslation();return s.jsx(a.Text,{children:e("viz.merico_heatmap.click_heatmap.heatblock.label")})}const Wo={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.merico_heatmap.click_heatmap.heatblock.label",nameRender:Dy,configRender:Ty,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]},wr={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,overflow:$e(),formatter:ke()}},y_axis:{name:"Y Axis",data_key:"",nameAlignment:"center",axisLabel:{rotate:0,overflow:$e(),formatter:ke()}},heat_block:{name:"Value",data_key:"",value_formatter:_e,label:{show:!1,fontSize:10}},tooltip:{metrics:[]},visualMap:ft()};function zy({conf:t,data:e,width:n,height:r,interactionManager:i,variables:o}){const l=m.useMemo(()=>{const h=A(t.x_axis.data_key),g=A(t.y_axis.data_key);return b.keyBy(e[h.queryID],f=>`${f[h.columnKey]}---${f[g.columnKey]}`)},[e,t.x_axis.data_key,t.y_axis.data_key]),c=qe(i.triggerManager,Wo.id),u=m.useCallback(h=>{const[g,f]=h.value,v=b.get(l,`${g}---${f}`,{error:"rowData is not found"});c.forEach(w=>{i.runInteraction(w.id,{...h,rowData:v})})},[l,c,i]),d=m.useMemo(()=>({click:u}),[u]),p=m.useMemo(()=>ky(t,e,o,n,r),[t,e,n,r]);return s.jsx(Se,{echarts:Ce,option:p,style:{width:n,height:r},onEvents:d,notMerge:!0,theme:"merico-light"})}function My({context:t,instance:e}){const n=Oe({vizManager:t.vizManager,instance:e}),{value:r}=q(t.instanceData,"config"),{variables:i}=t,o=m.useMemo(()=>b.defaults({},r,wr),[r]),l=t.data,{width:c,height:u}=t.viewport;return!c||!u?null:s.jsx(Ae,{width:c,height:u,children:s.jsx(zy,{variables:i,width:He(c),height:et(u),data:l,conf:o,interactionManager:n})})}function Iy({control:t,watch:e}){const{t:n}=_.useTranslation();e(["heat_block"]);const r=e("heat_block.label.show");return s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"heat_block.data_key",control:t,render:({field:i})=>s.jsx(O,{label:n("common.data_field"),sx:{flex:1},...i})}),s.jsx(y.Controller,{name:"heat_block.name",control:t,render:({field:i})=>s.jsx(a.TextInput,{label:n("common.name"),sx:{flex:1},...i})})]}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("numbro.format.label"),labelPosition:"center"}),s.jsx(y.Controller,{name:"heat_block.value_formatter",control:t,render:({field:i})=>s.jsx(Re,{...i})}),s.jsx(a.Divider,{mb:-5,variant:"dashed",label:n("chart.label.label"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"heat_block.label.show",control:t,render:({field:i})=>s.jsx(a.Switch,{label:n("chart.heatmap.heatblock.show_label"),checked:i.value,onChange:o=>i.onChange(o.currentTarget.checked),sx:{flexGrow:1}})}),s.jsx(y.Controller,{name:"heat_block.label.fontSize",control:t,render:({field:i})=>s.jsx(a.NumberInput,{size:"xs",icon:s.jsx(k.IconTextSize,{size:16}),disabled:!r,...i})})]})]})}const Ey=({control:t,index:e})=>{const{t:n}=_.useTranslation();return s.jsx(a.Stack,{children:s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`tooltip.metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:`tooltip.metrics.${e}.data_key`,control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),required:!0,sx:{flex:1},...r})})]})})},Ay=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(o,l)=>{const c=o.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(a.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),s.jsx(a.Divider,{variant:"dashed",my:10}),s.jsx(ae,{control:t,watch:e,name:"tooltip.metrics",getItem:r,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:o,index:l})=>s.jsx(Ey,{control:t,index:l})})]})};function Py({control:t,watch:e}){return s.jsx(Ay,{control:t,watch:e})}function $y({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["x_axis"]),s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"x_axis.name",control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),sx:{flex:1},...r})})]}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsx(y.Controller,{name:"x_axis.axisLabel.overflow",control:t,render:({field:r})=>s.jsx(nt,{...r})}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:r})=>s.jsx(xt,{sx:{width:"48%"},...r})}),s.jsx(y.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:r})=>s.jsx(tt,{...r})})]})]})}function By({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["y_axis"]),s.jsxs(a.Stack,{my:0,p:"0",sx:{position:"relative"},children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"y_axis.data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"y_axis.name",control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),sx:{flex:1},...r})})]}),s.jsx(a.Group,{grow:!0,noWrap:!0,children:s.jsx(y.Controller,{name:"y_axis.nameAlignment",control:t,render:({field:r})=>s.jsx(Tt,{sx:{flex:1},...r})})}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsx(y.Controller,{name:"y_axis.axisLabel.overflow",control:t,render:({field:r})=>s.jsx(nt,{...r})}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"y_axis.axisLabel.rotate",control:t,render:({field:r})=>s.jsx(xt,{sx:{width:"48%"},...r})}),s.jsx(y.Controller,{name:"y_axis.axisLabel.formatter",control:t,render:({field:r})=>s.jsx(tt,{...r})})]})]})}function Ly({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),i=m.useMemo(()=>n?b.defaults({},n):wr,[n]),o=m.useMemo(()=>b.cloneDeep(i),[i]);m.useEffect(()=>{!b.isEqual(i,o)&&(console.log("config malformed, resetting to defaults",i,o),r(o))},[i,o]);const l=y.useForm({defaultValues:o}),{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=l;m.useEffect(()=>{h(o)},[o]);const g=p(),f=m.useMemo(()=>!b.isEqual(g,i),[g,i]);return s.jsx("form",{onSubmit:u(r),style:{flexGrow:1},children:s.jsxs(a.Stack,{spacing:"xs",sx:{height:"100%"},children:[s.jsx(ge,{canSubmit:f}),s.jsxs(a.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{root:{flexGrow:1},tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"X Axis",children:e("chart.x_axis.label")}),s.jsx(a.Tabs.Tab,{value:"Y Axis",children:e("chart.y_axis.label")}),s.jsx(a.Tabs.Tab,{value:"Heat Block",children:e("chart.heatmap.heatblock.label")}),s.jsx(a.Tabs.Tab,{value:"Visual Map",children:e("chart.visual_map.label")}),s.jsx(a.Tabs.Tab,{value:"Tooltip",children:e("chart.tooltip.label")})]}),s.jsx(a.Tabs.Panel,{value:"X Axis",children:s.jsx($y,{control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Y Axis",children:s.jsx(By,{control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Heat Block",children:s.jsx(Iy,{control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Visual Map",children:s.jsx(jr,{form:l})}),s.jsx(a.Tabs.Panel,{value:"Tooltip",children:s.jsx(Py,{control:c,watch:d})})]})]})})}const qy=[{lang:"en",resources:{heatmap:{viz_name:"Heatmap",click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{heatmap:{viz_name:"热力图",click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function Oy(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=d=>d&&`${n}.${d}`,{x_axis:i,y_axis:o,heat_block:l,tooltip:c,...u}=t;return{...u,x_axis:{...i,data_key:r(i.data_key)},y_axis:{...o,data_key:r(o.data_key)},heat_block:{...l,data_key:r(l.data_key)},tooltip:{...c,metrics:c.metrics.map(d=>({...d,data_key:r(d.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}function Vy(t){return b.defaultsDeep({},t,{heat_block:{label:{show:!1,fontSize:10}}})}function Ny(t){const{heat_block:e}=t;let{min:n,max:r}=e;return typeof n!="number"&&(n=0),typeof r!="number"&&(r=100),{...t,heat_block:{...e,min:{type:"static",value:n},max:{type:"static",value:r}}}}function Gy(t){const{visualMap:e=ft(),heat_block:{min:n,max:r,...i},...o}=t;return{...o,heat_block:i,visualMap:{...ft(),min:n,max:r}}}class Fy extends ce{constructor(){super(...arguments);$(this,"VERSION",5)}configVersions(){this.version(1,n=>(console.log("🟥 unexpected calling"),{version:1,config:n})),this.version(2,(n,r)=>({...n,version:2,config:Oy(n.config,r)})),this.version(3,n=>({...n,version:3,config:Vy(n.config)})),this.version(4,n=>({...n,version:4,config:Ny(n.config)})),this.version(5,n=>({...n,version:5,config:Gy(n.config)}))}}const Wy={displayName:"viz.heatmap.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Fy,name:"heatmap",viewRender:My,configRender:Ly,createConfig:()=>({version:5,config:wr}),triggers:[Wo],translation:qy},Qy=[{lang:"en",resources:{pareto_chart:{viz_name:"Pareto Chart",line_80_20:{label:"80-20 Line",label_template:"Label Template",click_to_see_params:"Click to see params for Label Template",param_section_note_1:"80-20 line stuff",param_section_note_2:"chart configs"},click_series:{label:"Click chart series"}}}},{lang:"zh",resources:{pareto_chart:{viz_name:"帕累托图",line_80_20:{label:"80/20线",label_template:"线上文案模板",click_to_see_params:"点击查看线上文案模板的参数",param_section_note_1:"80-20线相关",param_section_note_2:"图表配置信息"},click_series:{label:"点击柱或线"}}}}],Qo={id:"builtin:echarts:click-echart:series",displayName:"viz.pareto_chart.click_series.label",nameRender:Uy,configRender:Ry,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'line' | 'bar'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Ry(t){return s.jsx(s.Fragment,{})}function Uy(t){const{t:e}=_.useTranslation();return s.jsx(a.Text,{children:e("viz.pareto_chart.click_series.label")})}const Ro={label_template:"${percentage.x} of ${x_axis.name} causes ${percentage.y} of ${bar.name}",color:"#789AB4"},Cr={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,formatter:ke(),overflow:$e()}},data_key:"value",bar:{name:"Value",nameAlignment:"left",color:"#228be6",label_formatter:_e},line:{name:"Value",nameAlignment:"right",color:"red"},dataZoom:Mt,markLine:Ro,reference_lines:[]};function es(t){return U(t,{output:"percent",mantissa:0,absolute:!1})}function Yy(t){const e=t.value[1];try{return es(e)}catch(n){return console.error(n),e}}function Ky(t){function e(n){let r=n;if(typeof n=="object"&&(Array.isArray(n.value)&&n.value.length===2?r=n.value[1]:r=n.value),!t.bar.label_formatter)return r;try{return U(r,t.bar.label_formatter)}catch(i){return console.error(i),r}}return{bar:e,line:Yy,lineValue:es}}function Jy(t,e,n){const{label_template:r}=t.markLine;if(!r)return"";const i={...t,percentage:e,count:n},o=Object.keys(i),l=Object.values(i);return new Function(...o,`return \`${r}\`;`)(...l)}function Xy(t,e){if(e.length===0)return{};const n=e.findIndex(c=>c[1]>=.8);if(n===-1)return{};const r=e[n],i={x:es((n+1)/e.length),y:es(r[1])},o={left:n+1,right:e.length-n-1},l=r[0];return l?{markLine:{name:"",silent:!0,symbol:"triangle",symbolRotate:180,symbolSize:[10,8],data:[{name:"",symbol:"none",xAxis:l,lineStyle:{color:t.markLine.color},label:{formatter:Jy(t,i,o)}}]},markArea:{name:"",silent:!0,itemStyle:{color:"rgba(47, 140, 192, 0.05)"},data:[[{coord:["min",0]},{xAxis:l}]]}}:{}}function Zy(t,e,n){const{x_axis:r,data_key:i}=t;if(!r.data_key||!i)return[];const o=A(r.data_key),l=A(i);if(o.queryID!==l.queryID)throw new Error("Please use the same query for X & Y axis");const c=e[o.queryID].map(g=>[g[o.columnKey],Number(g[l.columnKey])]).sort((g,f)=>f[1]-g[1]),u=c.reduce((g,f)=>g+f[1],0),d=c.reduce((g,f,v)=>{const w=v===0?0:g[v-1][1];return g.push([f[0],w+f[1]]),g},[]).map(g=>[g[0],g[1]/u]),{markLine:p,markArea:h}=Xy(t,d);return[{name:t.bar.name,type:"bar",barMaxWidth:20,itemStyle:{color:t.bar.color},label:{show:!1,position:"top",formatter:n.bar},yAxisIndex:0,data:c},{name:t.line.name,type:"line",itemStyle:{color:t.line.color},symbolSize:2,lineStyle:{width:1,shadowColor:"rgba(255,255,255,1)",shadowBlur:0,shadowOffsetX:0,shadowOffsetY:1},label:{show:!1,position:"top",formatter:n.line},yAxisIndex:1,data:d,markLine:p,markArea:h}]}const Hy=(t,e)=>n=>{const r=Array.isArray(n)?n:[n];if(r.length===0)return"";const i=r.map((c,u)=>{const d=c.seriesName,[p,h]=c.value;if(!d)return h;const g=u===0?e.bar:e.lineValue;return`
171
+ `}})}function nC(e,t,n,s){const{overflow:i,rotate:a}=e.x_axis.axisLabel,l=ut(i.on_axis);return te.getXAxis({id:"main-x-axis",type:"category",data:t,name:e.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:a,...l,formatter:n},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:s>0,interval:0,lineStyle:{type:"solid",color:"white"}},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:3})}function rC(e,t,n,s){const{nameAlignment:i,data_key:a,...l}=e.y_axis,{overflow:c,rotate:u}=e.y_axis.axisLabel,d=ut(c.on_axis);return te.getYAxis({...l,type:"category",data:t,axisLabel:{rotate:u,...d,formatter:n},axisTick:{show:!0,alignWithLabel:!0},axisLine:{show:!0,lineStyle:{width:3}},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:s>0,interval:0,lineStyle:{type:"solid",color:"white"}},nameTextStyle:{fontWeight:"bold",align:i},nameLocation:"end",nameGap:15,z:3})}const sC=({value:e,onChange:t})=>{const n=s=>{s&&t(s)};return r.jsx(o.Box,{children:r.jsx(tt,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Ep={static:{type:"static",value:10},dynamic:{type:"dynamic",value:["function getValue({ variables }, { lodash, interpolate }) {"," // your code goes here"," return 100;","}"].join(`
172
+ `)}},iC=({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),[s,{setTrue:i,setFalse:a}]=W.useBoolean(),[l,c]=m.useState(e),u=()=>{a();const{type:f,value:g}=l,y={type:f,value:g};c(y),t(y)},d=()=>{a(),c(e)},p=f=>{c(g=>({...g,value:f}))},h=()=>{p(Ep.dynamic.value)};return r.jsxs(r.Fragment,{children:[r.jsx(o.Box,{sx:{width:"50%"},children:r.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:i,sx:{flexGrow:0},children:n("chart.number_or_dynamic_value.dynamic.setup")})}),r.jsx(o.Modal,{size:800,title:n("chart.number_or_dynamic_value.dynamic.setup_title"),opened:s,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mt:10,mb:-10,label:n("chart.number_or_dynamic_value.dynamic.guide"),labelPosition:"center",variant:"dashed"}),r.jsx(sC,{value:l.value,onChange:p}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:h,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:n("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:d,variant:"subtle",children:n("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:u,children:n("common.actions.save")})]})]})]})})]})},aC=({value:e,onChange:t})=>e.type!=="dynamic"?null:r.jsx(iC,{value:e,onChange:t}),oC=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=s=>{t({...e,value:s})};return r.jsx(o.NumberInput,{defaultValue:18,label:" ",hideControls:!0,value:e.value,onChange:n})},Ap=m.forwardRef(({label:e="Value",value:t,onChange:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=u=>{n({...Ep[u]})},c=m.useMemo(()=>[{label:i("chart.number_or_dynamic_value.type.static"),value:"static"},{label:i("chart.number_or_dynamic_value.type.dynamic"),value:"dynamic"}],[a.language]);return r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(o.Select,{ref:s,label:e,data:c,value:t.type,onChange:l,sx:{flexGrow:1}}),r.jsx(oC,{value:t,onChange:n}),r.jsx(aC,{value:t,onChange:n})]})});function Pp(e,t,n){if(!e.type)return n;if(e.type==="static"){const{value:i}=e;return Number(i)}const{value:s}=e;try{const i=new Function(`return ${s}`)()({variables:t},{lodash:v,interpolate:vn.interpolate});return Number(i)}catch(i){return console.error(`[getNumberOrDynamicValue] failed parsing custom function, error: ${i.message}`),10}}const Ks=({label:e,field:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.ColorInput,{label:e,placeholder:n("chart.visual_map.skip_range.follow_visual_map"),size:"xs",withinPortal:!0,dropdownZIndex:340,rightSection:t.value?r.jsx(o.CloseButton,{onClick:()=>{t.onChange("")}}):null,...t})},lC=({form:e})=>{const{t}=_.useTranslation();return r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{control:e.control,name:"visualMap.skipRange.lt_min",render:({field:n})=>r.jsx(Ks,{field:n,label:t("chart.visual_map.skip_range.lt_min")})}),r.jsx(b.Controller,{control:e.control,name:"visualMap.skipRange.min",render:({field:n})=>r.jsx(Ks,{field:n,label:t("chart.visual_map.skip_range.min")})}),r.jsx(b.Controller,{control:e.control,name:"visualMap.skipRange.max",render:({field:n})=>r.jsx(Ks,{field:n,label:t("chart.visual_map.skip_range.max")})}),r.jsx(b.Controller,{control:e.control,name:"visualMap.skipRange.gt_max",render:({field:n})=>r.jsx(Ks,{field:n,label:t("chart.visual_map.skip_range.gt_max")})})]})};function Op(e){return{type:"continuous",id:"continuous-example",min:{type:"static",value:0},max:{type:"static",value:100},orient:"horizontal",left:"center",top:"top",text:["",""],calculable:!0,itemWidth:15,itemHeight:140,show:!0,inRange:{color:e??Object.values(_n.graphics.depth)},skipRange:{lt_min:"",min:"",max:"",gt_max:""}}}function cC(){return{type:"piecewise",piecewise_mode:"pieces",id:"piecewise-visualmap",min:{type:"static",value:0},max:{type:"static",value:100},align:"auto",orient:"horizontal",left:"center",top:"top",itemWidth:15,itemHeight:15,show:!0,precision:0,pieces:[Lp()],categories:[]}}function Ht(){return Op()}function uC(){return{compared:Object.values(_n.graphics.compared),level:Object.values(_n.graphics.level),depth:Object.values(_n.graphics.depth),yellow_blue:["#8f531d","#ffd347","#e3efe3","#eefaee","#4ecbbf","#003f94"],blue:["#f9fcff","#48b3e9","#003f94"],darkgreen_pink:["#0c525a","#f21f99"],spectrum:["#ff0000","#ffff00","#00ff00","#00ffff","#0000ff","#ff00ff","#ff0000"]}}function Xs(e,t){const{min:n,max:s}=e,i=Pp(n,t),a=Pp(s,t);if(e.type==="continuous"){const{skipRange:h,text:f,...g}=e;return{...g,min:i,max:a,text:[...f]}}const{piecewise_mode:l,pieces:c,categories:u,...d}=e,p={...d};return delete p.min,delete p.max,l==="pieces"?p.pieces=c.map(h=>{const f={};h.label&&(f.label=h.label),h.color&&(f.color=h.color);const g=Number(h.lower.value);h.lower.value===""?f[h.lower.symbol]=i:Number.isFinite(g)&&(f[h.lower.symbol]=g);const y=Number(h.upper.value);return h.upper.value===""?f[h.upper.symbol]=a:Number.isFinite(y)&&(f[h.upper.symbol]=y),f}):l==="categories"&&(p.categories=u),p}const nr=e=>({followVisualMap:!e,color:e});function jo(e,t,n,s){if(s.type!=="continuous")return nr("");const{skipRange:i}=s;return e===t?nr(i.min):e===n?nr(i.max):e<t?nr(i.lt_min):e>n?nr(i.gt_max):nr("")}function Lp(){return{lower:{value:"0",symbol:"gt"},upper:{value:"",symbol:"lt"},label:"",color:""}}const dC=uC(),pC=({colors:e,applyPalette:t})=>{const{t:n}=_.useTranslation(),s=`linear-gradient(to right, ${e.join(", ")})`;return r.jsxs(o.Menu,{shadow:"md",width:300,children:[r.jsx(o.Menu.Target,{children:r.jsxs(o.UnstyledButton,{children:[r.jsx(o.Text,{style:{display:"inline-block",fontSize:"0.875rem",fontWeight:500,color:"#212529",wordBreak:"break-word",cursor:"default"},children:n("chart.color.color_gradient")}),r.jsxs(o.Group,{style:{padding:"0.4375rem 0.625rem",border:"0.0625rem solid #ced4da",borderRadius:"0.25rem",columnGap:10},children:[r.jsx(o.Box,{style:{height:"20px",flexGrow:1,backgroundImage:s,borderRadius:4}}),r.jsx(M.IconSelector,{size:14,color:"rgb(134, 142, 150)"})]})]})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Label,{children:n("chart.visual_map.built_in_palettes")}),r.jsx(o.Menu.Divider,{}),Object.entries(dC).map(([i,a])=>r.jsx(o.Tooltip,{label:n("chart.visual_map.use_palette_x",{x:i}),children:r.jsx(o.Menu.Item,{children:r.jsx(o.Box,{style:{height:"20px",width:"100%",backgroundImage:`linear-gradient(to right, ${a.join(", ")})`,borderRadius:4,boxShadow:"0 0 3px 0 #eee",cursor:"pointer"},onClick:()=>{t(a)},title:i})})},i))]})]})},hC=({color:e,index:t,handleChange:n,handleRemove:s})=>{const[i,{setTrue:a,setFalse:l}]=W.useBoolean(!1),{ref:c,handleRef:u}=Wd({id:e.id,index:t});return r.jsxs(o.Flex,{ref:c,gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",onMouseEnter:a,onMouseLeave:l,children:[r.jsx(o.Center,{style:{minWidth:"30px",maxWidth:"30px",flex:0},children:i?r.jsx(o.ActionIcon,{size:"xs",ref:u,children:r.jsx(M.IconGripVertical,{})}):r.jsx(o.Badge,{size:"sm",children:t+1})}),r.jsx("div",{style:{flex:1},children:r.jsx(o.ColorInput,{styles:{root:{flexGrow:1}},withinPortal:!0,dropdownZIndex:340,size:"xs",value:e.value,onChange:n})}),r.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0},children:r.jsx(o.CloseButton,{onClick:s})})]})},fC=m.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),i=m.useMemo(()=>e.map(g=>({id:Ut.v4(),value:g})),[e]),a=g=>{t([...e,g])},l=g=>{const y=[...e];y.splice(g,1),t(y)},c=g=>{t([...g])},u=g=>y=>{const j=[...e];j[g]=y,t(j)},[d,p]=m.useState(""),h=()=>{d&&(a(d),p(""))},f=g=>{const{source:y,target:j}=g.operation,k=Dm.move(i,y,j);t(k.map(S=>S.value))};return r.jsxs(o.Stack,{ref:n,children:[r.jsx(pC,{colors:e,applyPalette:c}),r.jsx(es.DragDropProvider,{onDragEnd:f,children:i.map((g,y)=>r.jsx(hC,{color:g,handleChange:u(y),handleRemove:()=>l(y),index:y},g.id))}),r.jsxs(o.Flex,{gap:"sm",justify:"flex-start",align:"center",direction:"row",wrap:"nowrap",children:[r.jsx("div",{style:{minWidth:"30px",maxWidth:"30px",flex:0}}),r.jsx("div",{style:{flex:1},children:r.jsx(o.ColorInput,{withinPortal:!0,dropdownZIndex:340,placeholder:s("chart.color.click_to_add_a_color"),value:d,onChange:p,onBlur:h,size:"xs"})}),r.jsx("div",{style:{minWidth:"40px",maxWidth:"40px",flex:0}})]})]})}),mC=({form:e})=>{const{t,i18n:n}=_.useTranslation(),s=e.control,i=e.watch("visualMap"),{type:a,orient:l}=i,c=l==="horizontal",u=d=>p=>{p!==""&&d(p)};return a!=="continuous"?null:r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:"visualMap.text.1",control:s,render:({field:d})=>r.jsx(o.TextInput,{label:t("chart.visual_map.min_text"),...d})}),r.jsx(b.Controller,{name:"visualMap.text.0",control:s,render:({field:d})=>r.jsx(o.TextInput,{label:t("chart.visual_map.max_text"),...d})})]}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:"visualMap.orient",control:s,render:({field:d})=>r.jsx(gn,{sx:{flex:1},...d})}),r.jsx(b.Controller,{name:"visualMap.calculable",control:s,render:({field:d})=>r.jsx(o.Checkbox,{label:t("chart.visual_map.calculable"),checked:d.value,onChange:p=>d.onChange(p.currentTarget.checked),styles:{root:{transform:"translateY(12px)"}}})})]}),r.jsxs(o.Group,{grow:!0,styles:{root:{flexDirection:c?"row-reverse":"row"}},children:[r.jsx(b.Controller,{name:"visualMap.itemWidth",control:s,render:({field:d})=>r.jsx(o.NumberInput,{label:t(c?"chart.visual_map.bar_height":"chart.visual_map.bar_width"),...d,onChange:u(d.onChange)})}),r.jsx(b.Controller,{name:"visualMap.itemHeight",control:s,render:({field:d})=>r.jsx(o.NumberInput,{label:t(c?"chart.visual_map.bar_width":"chart.visual_map.bar_height"),...d,onChange:u(d.onChange)})})]}),r.jsx(b.Controller,{name:"visualMap.inRange.color",control:s,render:({field:d})=>r.jsx(fC,{...d})}),r.jsx(lC,{form:e})]})},gC=({visualMap:e})=>{const{orient:t,itemWidth:n,itemHeight:s}=e,a=t==="horizontal"?n:s,{panel:l}=Ge(),c=Xs(e,l.variableValueMap);return r.jsx(ze,{children:r.jsx(Pe,{echarts:Ae,option:{visualMap:c},style:{width:"100%",height:`${a+40}px`},notMerge:!0,theme:"merico-light"})})},Bp={lower:[{label:"<",value:"gt"},{label:"≤",value:"gte"}],upper:[{label:">",value:"lt"},{label:"≥",value:"lte"}]},qp={gt:"(",gte:"[",lt:")",lte:"]"},Vp=(e,t)=>e===""?t:Number.isNaN(Number(e))?"INVALID VALUE":e,xC=({form:e,index:t})=>{const{t:n}=_.useTranslation(),{control:s,watch:i}=e,a=i(`visualMap.pieces.${t}`),{lower:l,upper:c}=a,u=[qp[l.symbol],Vp(l.value,n("chart.visual_map.min_value")),",",Vp(c.value,n("chart.visual_map.max_value")),qp[c.symbol]].join(""),[d,p]=m.useState(!1);return r.jsx(o.Group,{noWrap:!0,children:r.jsxs(o.Popover,{width:400,position:"bottom",withArrow:!0,shadow:"md",opened:d,onChange:p,withinPortal:!0,zIndex:340,children:[r.jsx(o.Popover.Target,{children:r.jsx(o.Button,{variant:"subtle",compact:!0,px:0,onClick:()=>p(h=>!h),sx:{fontFamily:"monospace",fontWeight:"normal"},children:u})}),r.jsx(o.Popover.Dropdown,{children:r.jsxs(o.Group,{noWrap:!0,spacing:8,children:[r.jsx(b.Controller,{name:`visualMap.pieces.${t}.lower.value`,control:s,render:({field:h})=>r.jsx(o.TextInput,{...h,placeholder:n("chart.visual_map.min_value"),size:"xs",onChange:f=>h.onChange(f.currentTarget.value),error:h.value!==""&&Number.isNaN(Number(h.value))})}),r.jsx(b.Controller,{name:`visualMap.pieces.${t}.lower.symbol`,control:s,render:({field:h})=>r.jsx(o.Select,{size:"xs",data:Bp.lower,...h,onChange:f=>h.onChange(f)})}),r.jsx(o.Text,{color:"dimmed",size:"sm",sx:{userSelect:"none",cursor:"default"},children:n("common.value").toLowerCase()}),r.jsx(b.Controller,{name:`visualMap.pieces.${t}.upper.symbol`,control:s,render:({field:h})=>r.jsx(o.Select,{size:"xs",data:Bp.upper,...h,onChange:f=>h.onChange(f)})}),r.jsx(b.Controller,{name:`visualMap.pieces.${t}.upper.value`,control:s,render:({field:h})=>r.jsx(o.TextInput,{...h,size:"xs",placeholder:n("chart.visual_map.max_value"),onChange:f=>h.onChange(f.currentTarget.value),error:h.value!==""&&Number.isNaN(Number(h.value))})})]})})]})})},yC=({form:e,index:t,remove:n})=>{const{control:s}=e,{t:i}=_.useTranslation();return r.jsxs("tr",{children:[r.jsx("td",{children:(t+1).toString()}),r.jsx("td",{children:r.jsx(xC,{form:e,index:t})}),r.jsx("td",{children:r.jsx(b.Controller,{name:`visualMap.pieces.${t}.label`,control:s,render:({field:a})=>r.jsx(o.TextInput,{size:"xs",placeholder:"",...a,onChange:l=>a.onChange(l.currentTarget.value)})})}),r.jsx("td",{children:r.jsx(b.Controller,{name:`visualMap.pieces.${t}.color`,control:s,render:({field:a})=>r.jsx(o.ColorInput,{label:i(""),placeholder:i("chart.color.label"),size:"xs",withinPortal:!0,dropdownZIndex:340,rightSection:a.value?r.jsx(o.CloseButton,{onClick:()=>{a.onChange("")}}):null,...a})})}),r.jsx("td",{children:r.jsx(o.CloseButton,{onClick:()=>n(t)})})]})},bC=({form:e})=>{const{t,i18n:n}=_.useTranslation(),{fields:s,append:i,remove:a}=b.useFieldArray({control:e.control,name:"visualMap.pieces"}),l=e.watch("visualMap.pieces"),c=s.map((d,p)=>({...d,...l[p]})),u=()=>{i(Lp())};return r.jsx(o.Stack,{children:r.jsxs(o.Table,{children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"40px"}}),r.jsx("th",{children:t("chart.visual_map.piecewise.interval")}),r.jsx("th",{children:t("chart.visual_map.piecewise.piece_label")}),r.jsx("th",{children:t("chart.color.label")}),r.jsx("th",{style:{width:"40px"}})]})}),r.jsx("tbody",{children:c.map((d,p)=>r.jsx(yC,{index:p,form:e,remove:a},d.id))}),r.jsx("tfoot",{children:r.jsxs("tr",{children:[r.jsx("td",{}),r.jsx("td",{colSpan:3,children:r.jsx(o.Button,{mt:10,size:"xs",color:"blue",leftIcon:r.jsx(M.IconPlaylistAdd,{size:20}),onClick:u,sx:{width:"50%"},mx:"auto",children:t("chart.visual_map.piecewise.add_a_piece")})}),r.jsx("td",{})]})})]})})},vC=({form:e})=>{const{t,i18n:n}=_.useTranslation(),s=e.control,i=e.watch("visualMap");m.useMemo(()=>[{label:t("chart.visual_map.piecewise.mode.pieces"),value:"pieces"},{label:t("chart.visual_map.piecewise.mode.categories"),value:"categories"}],[n.language]);const{type:a,orient:l,piecewise_mode:c}=i,u=d=>p=>{p!==""&&d(p)};return a!=="piecewise"?null:r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:"visualMap.precision",control:s,render:({field:d})=>r.jsx(o.NumberInput,{label:t("chart.visual_map.precision"),...d,onChange:u(d.onChange)})}),r.jsx(b.Controller,{name:"visualMap.orient",control:s,render:({field:d})=>r.jsx(gn,{sx:{flex:1},...d})}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:"visualMap.itemWidth",control:s,render:({field:d})=>r.jsx(o.NumberInput,{label:t("chart.visual_map.item_width"),...d,onChange:u(d.onChange)})}),r.jsx(b.Controller,{name:"visualMap.itemHeight",control:s,render:({field:d})=>r.jsx(o.NumberInput,{label:t("chart.visual_map.item_height"),...d,onChange:u(d.onChange)})})]}),c==="pieces"&&r.jsx(bC,{form:e})]})},wo=({form:e})=>{const{t,i18n:n}=_.useTranslation(),s=e.control,i=e.watch("visualMap"),a=m.useMemo(()=>[{label:t("chart.visual_map.continuous.label"),value:"continuous"},{label:t("chart.visual_map.piecewise.label"),value:"piecewise"}],[n.language]),l=c=>{switch(c){case"continuous":e.setValue("visualMap",Op());break;case"piecewise":e.setValue("visualMap",cC());break}};return r.jsx(ze,{children:r.jsxs(o.Stack,{children:[r.jsx(gC,{visualMap:i}),r.jsx(b.Controller,{name:"visualMap.type",control:s,render:({field:c})=>r.jsx(o.SegmentedControl,{mt:-10,data:a,sx:{flex:1},...c,onChange:l})}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:"visualMap.min",control:s,render:({field:c})=>r.jsx(Ap,{label:t("chart.visual_map.min_value"),...c})}),r.jsx(b.Controller,{name:"visualMap.max",control:s,render:({field:c})=>r.jsx(Ap,{label:t("chart.visual_map.max_value"),...c})})]}),r.jsx(o.Divider,{variant:"dashed"}),r.jsx(mC,{form:e}),r.jsx(vC,{form:e})]})})};function _C(e,t,n,s){return n<e*10||s<t*10?0:n<e*20||s<t*20?1:2}function jC(e,t,n,s,i){if(!e.x_axis.data_key||!e.y_axis.data_key||!e.heat_block.data_key)return{};const a=n.reduce((z,I)=>{const E=jt(I,t);return z[I.name]=Re(I,E),z},{}),l=Xs(e.visualMap,a),{min:c,max:u}=l,d=K0(e),p=X0(e),h=O(e.x_axis.data_key),f=O(e.y_axis.data_key),g=O(e.heat_block.data_key),y=v.uniq(t[h.queryID].map(z=>z[h.columnKey])),j=v.uniq(t[h.queryID].map(z=>z[f.columnKey])),k=t[h.queryID].map(z=>{const I=v.get(z,h.columnKey),E=v.get(z,f.columnKey),N=v.get(z,g.columnKey),R={value:[I,E,N]},{followVisualMap:pe,color:ie}=jo(N,c,u,e.visualMap);return pe||(R.visualMap=!1,R.itemStyle={color:ie}),R}),S=_C(y.length,j.length,s,i);return{xAxis:nC(e,y,d.x_axis,S),yAxis:rC(e,j,d.y_axis,S),series:Z0(e,k,S),tooltip:tC(e,t,d,p),grid:J0(e),visualMap:l}}function wC(e){return r.jsx(r.Fragment,{})}function CC(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.merico_heatmap.click_heatmap.heatblock.label")})}const Np={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.merico_heatmap.click_heatmap.heatblock.label",nameRender:CC,configRender:wC,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]},Co={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,overflow:Ke(),formatter:Oe()}},y_axis:{name:"Y Axis",data_key:"",nameAlignment:"center",axisLabel:{rotate:0,overflow:Ke(),formatter:Oe()}},heat_block:{name:"Value",data_key:"",value_formatter:Me,label:{show:!1,fontSize:10}},tooltip:{metrics:[]},visualMap:Ht()};function SC({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=m.useMemo(()=>{const h=O(e.x_axis.data_key),f=O(e.y_axis.data_key);return v.keyBy(t[h.queryID],g=>`${g[h.columnKey]}---${g[f.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),c=nt(i.triggerManager,Np.id),u=m.useCallback(h=>{const[f,g]=h.value,y=v.get(l,`${f}---${g}`,{error:"rowData is not found"});c.forEach(j=>{i.runInteraction(j.id,{...h,rowData:y})})},[l,c,i]),d=m.useMemo(()=>({click:u}),[u]),p=m.useMemo(()=>jC(e,t,a,n,s),[e,t,n,s]);return r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,theme:"merico-light"})}function kC({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=m.useMemo(()=>v.defaults({},s,Co),[s]),l=e.data,{width:c,height:u}=e.viewport;return!c||!u?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(SC,{variables:i,width:wt(c),height:Ct(u),data:l,conf:a,interactionManager:n})})}function TC({control:e,watch:t}){const{t:n}=_.useTranslation();t(["heat_block"]);const s=t("heat_block.label.show");return r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"heat_block.data_key",control:e,render:({field:i})=>r.jsx(F,{label:n("common.data_field"),sx:{flex:1},...i})}),r.jsx(b.Controller,{name:"heat_block.name",control:e,render:({field:i})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...i})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("numbro.format.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"heat_block.value_formatter",control:e,render:({field:i})=>r.jsx(ft,{...i})}),r.jsx(o.Divider,{mb:-5,variant:"dashed",label:n("chart.label.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"heat_block.label.show",control:e,render:({field:i})=>r.jsx(o.Switch,{label:n("chart.heatmap.heatblock.show_label"),checked:i.value,onChange:a=>i.onChange(a.currentTarget.checked),sx:{flexGrow:1}})}),r.jsx(b.Controller,{name:"heat_block.label.fontSize",control:e,render:({field:i})=>r.jsx(o.NumberInput,{size:"xs",icon:r.jsx(M.IconTextSize,{size:16}),disabled:!s,...i})})]})]})}const DC=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},MC=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(fe,{control:e,watch:t,name:"tooltip.metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(DC,{control:e,index:l})})]})};function zC({control:e,watch:t}){return r.jsx(MC,{control:e,watch:t})}function IC({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["x_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"x_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(kt,{...s})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:s})=>r.jsx(Jt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(St,{...s})})]})]})}function EC({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["y_axis"]),r.jsxs(o.Stack,{my:0,p:"0",sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"y_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"y_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})})]}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"y_axis.nameAlignment",control:e,render:({field:s})=>r.jsx(yn,{sx:{flex:1},...s})})}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(kt,{...s})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"y_axis.axisLabel.rotate",control:e,render:({field:s})=>r.jsx(Jt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(St,{...s})})]})]})}function AC({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=m.useMemo(()=>n?v.defaults({},n):Co,[n]),a=m.useMemo(()=>v.cloneDeep(i),[i]);m.useEffect(()=>{!v.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),s(a))},[i,a]);const l=b.useForm({defaultValues:a}),{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=l;m.useEffect(()=>{h(a)},[a]);const f=p(),g=m.useMemo(()=>!v.isEqual(f,i),[f,i]);return r.jsx("form",{onSubmit:u(s),style:{flexGrow:1},children:r.jsxs(o.Stack,{spacing:"xs",sx:{height:"100%"},children:[r.jsx(Ce,{canSubmit:g}),r.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{root:{flexGrow:1},tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Heat Block",children:t("chart.heatmap.heatblock.label")}),r.jsx(o.Tabs.Tab,{value:"Visual Map",children:t("chart.visual_map.label")}),r.jsx(o.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")})]}),r.jsx(o.Tabs.Panel,{value:"X Axis",children:r.jsx(IC,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx(EC,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Heat Block",children:r.jsx(TC,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Visual Map",children:r.jsx(wo,{form:l})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(zC,{control:c,watch:d})})]})]})})}const PC=[{lang:"en",resources:{heatmap:{viz_name:"Heatmap",click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{heatmap:{viz_name:"热力图",click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function OC(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=d=>d&&`${n}.${d}`,{x_axis:i,y_axis:a,heat_block:l,tooltip:c,...u}=e;return{...u,x_axis:{...i,data_key:s(i.data_key)},y_axis:{...a,data_key:s(a.data_key)},heat_block:{...l,data_key:s(l.data_key)},tooltip:{...c,metrics:c.metrics.map(d=>({...d,data_key:s(d.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}function LC(e){return v.defaultsDeep({},e,{heat_block:{label:{show:!1,fontSize:10}}})}function BC(e){const{heat_block:t}=e;let{min:n,max:s}=t;return typeof n!="number"&&(n=0),typeof s!="number"&&(s=100),{...e,heat_block:{...t,min:{type:"static",value:n},max:{type:"static",value:s}}}}function qC(e){const{visualMap:t=Ht(),heat_block:{min:n,max:s,...i},...a}=e;return{...a,heat_block:i,visualMap:{...Ht(),min:n,max:s}}}class VC extends ge{constructor(){super(...arguments);B(this,"VERSION",5)}configVersions(){this.version(1,n=>(console.log("🟥 unexpected calling"),{version:1,config:n})),this.version(2,(n,s)=>({...n,version:2,config:OC(n.config,s)})),this.version(3,n=>({...n,version:3,config:LC(n.config)})),this.version(4,n=>({...n,version:4,config:BC(n.config)})),this.version(5,n=>({...n,version:5,config:qC(n.config)}))}}const NC={displayName:"viz.heatmap.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new VC,name:"heatmap",viewRender:kC,configRender:AC,createConfig:()=>({version:5,config:Co}),triggers:[Np],translation:PC},$C=[{lang:"en",resources:{pareto_chart:{viz_name:"Pareto Chart",line_80_20:{label:"80-20 Line",label_template:"Label Template",click_to_see_params:"Click to see params for Label Template",param_section_note_1:"80-20 line stuff",param_section_note_2:"chart configs"},click_series:{label:"Click chart series"}}}},{lang:"zh",resources:{pareto_chart:{viz_name:"帕累托图",line_80_20:{label:"80/20线",label_template:"线上文案模板",click_to_see_params:"点击查看线上文案模板的参数",param_section_note_1:"80-20线相关",param_section_note_2:"图表配置信息"},click_series:{label:"点击柱或线"}}}}],$p={id:"builtin:echarts:click-echart:series",displayName:"viz.pareto_chart.click_series.label",nameRender:GC,configRender:FC,payload:[{name:"type",description:"Always 'click'",valueType:"string"},{name:"seriesType",description:"'line' | 'bar'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function FC(e){return r.jsx(r.Fragment,{})}function GC(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.pareto_chart.click_series.label")})}const Fp={label_template:"${percentage.x} of ${x_axis.name} causes ${percentage.y} of ${bar.name}",color:"#789AB4"},So={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,formatter:Oe(),overflow:Ke()}},data_key:"value",bar:{name:"Value",nameAlignment:"left",color:"#228be6",label_formatter:Me},line:{name:"Value",nameAlignment:"right",color:"red"},dataZoom:jn,markLine:Fp,reference_lines:[]};function Js(e){return U(e,{output:"percent",mantissa:0,absolute:!1})}function WC(e){const t=e.value[1];try{return Js(t)}catch(n){return console.error(n),t}}function RC(e){function t(n){let s=n;if(typeof n=="object"&&(Array.isArray(n.value)&&n.value.length===2?s=n.value[1]:s=n.value),!e.bar.label_formatter)return s;try{return U(s,e.bar.label_formatter)}catch(i){return console.error(i),s}}return{bar:t,line:WC,lineValue:Js}}function QC(e,t,n){const{label_template:s}=e.markLine;if(!s)return"";const i={...e,percentage:t,count:n},a=Object.keys(i),l=Object.values(i);return new Function(...a,`return \`${s}\`;`)(...l)}function UC(e,t){if(t.length===0)return{};const n=t.findIndex(c=>c[1]>=.8);if(n===-1)return{};const s=t[n],i={x:Js((n+1)/t.length),y:Js(s[1])},a={left:n+1,right:t.length-n-1},l=s[0];return l?{markLine:{name:"",silent:!0,symbol:"triangle",symbolRotate:180,symbolSize:[10,8],data:[{name:"",symbol:"none",xAxis:l,lineStyle:{color:e.markLine.color},label:{formatter:QC(e,i,a)}}]},markArea:{name:"",silent:!0,itemStyle:{color:"rgba(47, 140, 192, 0.05)"},data:[[{coord:["min",0]},{xAxis:l}]]}}:{}}function YC(e,t,n){const{x_axis:s,data_key:i}=e;if(!s.data_key||!i)return[];const a=O(s.data_key),l=O(i);if(a.queryID!==l.queryID)throw new Error("Please use the same query for X & Y axis");const c=t[a.queryID].map(f=>[f[a.columnKey],Number(f[l.columnKey])]).sort((f,g)=>g[1]-f[1]),u=c.reduce((f,g)=>f+g[1],0),d=c.reduce((f,g,y)=>{const j=y===0?0:f[y-1][1];return f.push([g[0],j+g[1]]),f},[]).map(f=>[f[0],f[1]/u]),{markLine:p,markArea:h}=UC(e,d);return[{name:e.bar.name,type:"bar",barMaxWidth:20,itemStyle:{color:e.bar.color},label:{show:!1,position:"top",formatter:n.bar},yAxisIndex:0,data:c},{name:e.line.name,type:"line",itemStyle:{color:e.line.color},symbolSize:2,lineStyle:{width:1,shadowColor:"rgba(255,255,255,1)",shadowBlur:0,shadowOffsetX:0,shadowOffsetY:1},label:{show:!1,position:"top",formatter:n.line},yAxisIndex:1,data:d,markLine:p,markArea:h}]}const KC=(e,t)=>n=>{const s=Array.isArray(n)?n:[n];if(s.length===0)return"";const i=s.map((c,u)=>{const d=c.seriesName,[p,h]=c.value;if(!d)return h;const f=u===0?t.bar:t.lineValue;return`
171
173
  <tr>
172
174
  <th style="text-align: right; padding: 0 1em;">${d}</th>
173
- <td style="text-align: left; padding: 0 1em;">${g(h)}</td>
175
+ <td style="text-align: left; padding: 0 1em;">${f(h)}</td>
174
176
  </tr>
175
- `}),o=We(t.x_axis.axisLabel.overflow.in_tooltip),l=r[0].name;return`
177
+ `}),a=ct(e.x_axis.axisLabel.overflow.in_tooltip),l=s[0].name;return`
176
178
  <div style="text-align: left; margin-bottom: .5em; padding: 0 1em .5em; font-weight: bold; border-bottom: 1px dashed #ddd;">
177
- <div style="${o}">${l}</div>
179
+ <div style="${a}">${l}</div>
178
180
  </div>
179
181
  <table style="width: auto">
180
182
  <tbody>
181
183
  ${i.join("")}
182
184
  </tbody>
183
185
  </table>
184
- `};function eb(t,e){return te.getTooltip({trigger:"axis",formatter:Hy(t,e)})}function tb(t){const{name:e,axisLabel:n}=t.x_axis,r=Qe(n.overflow.on_axis);return[te.getXAxis({type:"category",id:"main-x-axis",name:e,nameLocation:"middle",nameGap:30,nameTextStyle:{align:"right"},axisLabel:{...n,...r,formatter:Pe(n.formatter)}})]}function nb(t,e){return[te.getYAxis({name:t.bar.name,nameGap:20,minInterval:1,nameTextStyle:{align:t.bar.nameAlignment},position:"left",axisLabel:{show:!0,formatter:e.bar},splitLine:{show:!1}}),te.getYAxis({name:t.line.name,nameGap:20,nameTextStyle:{align:t.line.nameAlignment},position:"right",axisLabel:{show:!0,formatter:e.lineValue}})]}function sb(t,e){return e?[t]:[]}function rb(t,e,n,r){return t.map(i=>{const o=n[i.variable_key],l=i.orientation==="horizontal",c=l?"yAxis":"xAxis",u=l?"insideEndTop":"end",d=sb(o,l);return{name:i.name,type:"scatter",hide_in_legend:!i.show_in_legend,xAxisId:"main-x-axis",yAxisIndex:i.yAxisIndex,data:d,symbol:"none",silent:!0,tooltip:{show:!1},markLine:{data:[{name:i.name,[c]:o}],silent:!0,symbol:["none","none"],lineStyle:i.lineStyle,label:{formatter:function(){return i.template?cn(i.template,e,r):""},position:u}}}})}function ib(t,e,n){const r=er(e,n),i=Ky(t),o={dataZoom:$n(t.dataZoom),tooltip:eb(t,i),xAxis:tb(t),yAxis:nb(t,i),series:[...Zy(t,e,i),...rb(t.reference_lines,n,r,e)],grid:{top:50,left:30,right:15,bottom:5,containLabel:!0}};return console.log(o),o}function ab({context:t,instance:e}){const{variables:n}=t,{value:r}=q(t.instanceData,"config"),i=t.data,{width:o,height:l}=t.viewport,c=b.defaults({},r,Cr),u=ib(c,i,n),d=Oe({vizManager:t.vizManager,instance:e}),p=qe(d.triggerManager,Qo.id),h=It(i,c.x_axis.data_key),g=m.useCallback(v=>{const w=b.get(h,v.name,{error:"rowData is not found"});p.forEach(T=>{d.runInteraction(T.id,{...v,rowData:w})})},[h,p,d]),f=m.useMemo(()=>({click:g}),[g]);return!c||!o||!l?null:s.jsx(Ae,{width:o,height:l,children:s.jsx(Se,{echarts:Ce,option:u,style:un(o,l),onEvents:f,notMerge:!0,theme:"merico-light"})})}function ob({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["bar"]),s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:"bar.name",control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"bar.nameAlignment",control:t,render:({field:r})=>s.jsx(Tt,{sx:{flex:1},...r})})]}),s.jsxs(a.Stack,{spacing:2,children:[s.jsx(a.Text,{size:"sm",children:n("chart.color.label")}),s.jsx(y.Controller,{name:"bar.color",control:t,render:({field:r})=>s.jsx(Te,{...r})})]}),s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("chart.label.label_format"),labelPosition:"center"}),s.jsx(y.Controller,{name:"bar.label_formatter",control:t,render:({field:r})=>s.jsx(Re,{...r})})]})]})}function lb({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["line"]),s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:"line.name",control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"line.nameAlignment",control:t,render:({field:r})=>s.jsx(Tt,{sx:{flex:1},...r})})]}),s.jsxs(a.Stack,{spacing:2,children:[s.jsx(a.Text,{size:"sm",children:n("chart.color.label")}),s.jsx(y.Controller,{name:"line.color",control:t,render:({field:r})=>s.jsx(Te,{...r})})]})]})}const cb=(t,e)=>`
186
+ `};function XC(e,t){return te.getTooltip({trigger:"axis",formatter:KC(e,t)})}function JC(e){const{name:t,axisLabel:n}=e.x_axis,s=ut(n.overflow.on_axis);return[te.getXAxis({type:"category",id:"main-x-axis",name:t,nameLocation:"middle",nameGap:30,nameTextStyle:{align:"right"},axisLabel:{...n,...s,formatter:Ye(n.formatter)}})]}function ZC(e,t){return[te.getYAxis({name:e.bar.name,nameGap:20,minInterval:1,nameTextStyle:{align:e.bar.nameAlignment},position:"left",axisLabel:{show:!0,formatter:t.bar},splitLine:{show:!1}}),te.getYAxis({name:e.line.name,nameGap:20,nameTextStyle:{align:e.line.nameAlignment},position:"right",axisLabel:{show:!0,formatter:t.lineValue}})]}function HC(e,t){return t?[e]:[]}function eS(e,t,n,s){return e.map(i=>{const a=n[i.variable_key],l=i.orientation==="horizontal",c=l?"yAxis":"xAxis",u=l?"insideEndTop":"end",d=HC(a,l);return{name:i.name,type:"scatter",hide_in_legend:!i.show_in_legend,xAxisId:"main-x-axis",yAxisIndex:i.yAxisIndex,data:d,symbol:"none",silent:!0,tooltip:{show:!1},markLine:{data:[{name:i.name,[c]:a}],silent:!0,symbol:["none","none"],lineStyle:i.lineStyle,label:{formatter:function(){return i.template?mr(i.template,t,s):""},position:u}}}})}function tS(e,t,n){const s=Ja(t,n),i=RC(e),a={dataZoom:ds(e.dataZoom),tooltip:XC(e,i),xAxis:JC(e),yAxis:ZC(e,i),series:[...YC(e,t,i),...eS(e.reference_lines,n,s,t)],grid:{top:50,left:30,right:15,bottom:5,containLabel:!0}};return console.log(a),a}function nS({context:e,instance:t}){const{variables:n}=e,{value:s}=$(e.instanceData,"config"),i=e.data,{width:a,height:l}=e.viewport,c=v.defaults({},s,So),u=tS(c,i,n),d=rt({vizManager:e.vizManager,instance:t}),p=nt(d.triggerManager,$p.id),h=wn(i,c.x_axis.data_key),f=m.useCallback(y=>{const j=v.get(h,y.name,{error:"rowData is not found"});p.forEach(k=>{d.runInteraction(k.id,{...y,rowData:j})})},[h,p,d]),g=m.useMemo(()=>({click:f}),[f]);return!c||!a||!l?null:r.jsx(Ue,{width:a,height:l,children:r.jsx(Pe,{echarts:Ae,option:u,style:gr(a,l),onEvents:g,notMerge:!0,theme:"merico-light"})})}function rS({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["bar"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:"bar.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"bar.nameAlignment",control:e,render:({field:s})=>r.jsx(yn,{sx:{flex:1},...s})})]}),r.jsxs(o.Stack,{spacing:2,children:[r.jsx(o.Text,{size:"sm",children:n("chart.color.label")}),r.jsx(b.Controller,{name:"bar.color",control:e,render:({field:s})=>r.jsx(Le,{...s})})]}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.label.label_format"),labelPosition:"center"}),r.jsx(b.Controller,{name:"bar.label_formatter",control:e,render:({field:s})=>r.jsx(ft,{...s})})]})]})}function sS({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["line"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:"line.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"line.nameAlignment",control:e,render:({field:s})=>r.jsx(yn,{sx:{flex:1},...s})})]}),r.jsxs(o.Stack,{spacing:2,children:[r.jsx(o.Text,{size:"sm",children:n("chart.color.label")}),r.jsx(b.Controller,{name:"line.color",control:e,render:({field:s})=>r.jsx(Le,{...s})})]})]})}const iS=(e,t)=>`
185
187
  {
186
- // ${t}
188
+ // ${e}
187
189
  percentage: {
188
190
  x: string; // 20%
189
191
  y: string; // 80%
@@ -193,7 +195,7 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
193
195
  right: number; // 8
194
196
  };
195
197
 
196
- // ${e}
198
+ // ${t}
197
199
  x_axis: {
198
200
  name: string;
199
201
  };
@@ -204,11 +206,11 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
204
206
  name: string;
205
207
  };
206
208
  }
207
- `,ub=()=>{const{t,i18n:e}=_.useTranslation(),[n,r]=m.useState(!1),i=m.useMemo(()=>cb(t("viz.pareto_chart.line_80_20.param_section_note_1"),t("viz.pareto_chart.line_80_20.param_section_note_2")),[e.language]);return s.jsxs(s.Fragment,{children:[s.jsx(a.Button,{variant:"subtle",compact:!0,onClick:()=>r(o=>!o),children:t(n?"common.actions.close":"viz.pareto_chart.line_80_20.click_to_see_params")}),s.jsx(a.Collapse,{in:n,children:s.jsx(jt.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:i})})]})};function db({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["markLine"]),s.jsxs(a.Stack,{children:[s.jsxs(a.Stack,{spacing:2,children:[s.jsx(a.Text,{size:"sm",children:n("chart.color.label")}),s.jsx(y.Controller,{name:"markLine.color",control:t,render:({field:r})=>s.jsx(Te,{...r})})]}),s.jsxs(a.Stack,{spacing:4,children:[s.jsx(y.Controller,{name:"markLine.label_template",control:t,render:({field:r})=>s.jsx(a.Textarea,{autosize:!0,minRows:2,maxRows:4,label:n("viz.pareto_chart.line_80_20.label_template"),sx:{flex:1},...r})}),s.jsx(ub,{})]})]})}function pb({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["x_axis"]),s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.name",control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"x_axis.data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),required:!0,sx:{flex:1},...r})})]}),s.jsx(a.Divider,{mb:-15,label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:r})=>s.jsx(xt,{sx:{width:"48%"},...r})}),s.jsx(y.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:r})=>s.jsx(tt,{...r})})]}),s.jsx(y.Controller,{name:"x_axis.axisLabel.overflow",control:t,render:({field:r})=>s.jsx(nt,{...r})})]})}function hb({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["data_key"]),s.jsx(a.Stack,{children:s.jsx(y.Controller,{name:"data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("chart.y_axis.y_axis_data_field"),required:!0,sx:{flex:1},...r})})})}function mb({control:t,index:e,watch:n,variableOptions:r,yAxisOptions:i}){const{t:o}=_.useTranslation(),l=n(`reference_lines.${e}.orientation`);return s.jsxs(a.Stack,{my:0,p:0,sx:{position:"relative"},children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`reference_lines.${e}.name`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:o("common.name"),placeholder:o("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),s.jsx(y.Controller,{name:`reference_lines.${e}.variable_key`,control:t,render:({field:c})=>s.jsx(a.Select,{label:o("common.data_field"),required:!0,data:r,sx:{flex:1},...c})})]}),s.jsx(y.Controller,{name:`reference_lines.${e}.template`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:o("chart.content_template.label"),placeholder:o("chart.content_template.hint"),sx:{flex:1},...c})}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(a.Stack,{children:s.jsx(y.Controller,{name:`reference_lines.${e}.orientation`,control:t,render:({field:c})=>s.jsx(Ct,{label:o("chart.orientation.label"),sx:{flex:1},...c})})}),l==="horizontal"&&s.jsx(y.Controller,{name:`reference_lines.${e}.yAxisIndex`,control:t,render:({field:{value:c,onChange:u,...d}})=>s.jsx(a.Select,{label:o("chart.y_axis.label"),data:i,disabled:i.length===0,...d,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){u(0);return}u(Number(p))},sx:{flex:1}})})]}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.style.label"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:`reference_lines.${e}.lineStyle.type`,control:t,render:({field:c})=>s.jsx(Qt,{sx:{flexGrow:1},...c})}),s.jsx(y.Controller,{name:`reference_lines.${e}.lineStyle.width`,control:t,render:({field:c})=>s.jsx(a.NumberInput,{label:o("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),s.jsxs(a.Stack,{spacing:4,children:[s.jsx(a.Text,{size:"sm",children:o("chart.color.label")}),s.jsx(y.Controller,{name:`reference_lines.${e}.lineStyle.color`,control:t,render:({field:c})=>s.jsx(Te,{...c})})]})]})}function xb({control:t,watch:e,variables:n}){const{t:r}=_.useTranslation(),i=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,yAxisIndex:0}),o=(d,p)=>{const h=d.name.trim();return h||p+1},l=m.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),c=e(["bar.name","line.name"]),u=m.useMemo(()=>c.map((d,p)=>({label:d,value:p.toString()})),[c]);return s.jsx(ae,{control:t,watch:e,name:"reference_lines",getItem:i,addButtonText:r("chart.reference_line.add"),deleteButtonText:r("chart.reference_line.delete"),renderTabName:o,children:({field:d,index:p})=>s.jsx(mb,{control:t,index:p,watch:e,variableOptions:l,yAxisOptions:u})})}function gb({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),{variables:i}=t,o=m.useMemo(()=>b.defaults({},n,Cr),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=y.useForm({defaultValues:o});m.useEffect(()=>{p(o)},[o]),u(["x_axis","data_key","bar","line","dataZoom"]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,n),[h,n]);return s.jsxs("form",{onSubmit:c(r),children:[s.jsx(ge,{canSubmit:g}),s.jsxs(a.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"X Axis",children:e("chart.x_axis.label")}),s.jsx(a.Tabs.Tab,{value:"Y Axis",children:e("chart.y_axis.label")}),s.jsx(a.Tabs.Tab,{value:"Bar",children:e("chart.series.bar.label")}),s.jsx(a.Tabs.Tab,{value:"Line",children:e("chart.series.line.label")}),s.jsx(a.Tabs.Tab,{value:"80-20 Line",children:e("viz.pareto_chart.line_80_20.label")}),s.jsx(a.Tabs.Tab,{value:"Reference Lines",children:e("chart.reference_line.labels")}),s.jsx(a.Tabs.Tab,{value:"Zooming",children:e("chart.zooming.label")})]}),s.jsx(a.Tabs.Panel,{value:"X Axis",children:s.jsx(pb,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Y Axis",children:s.jsx(hb,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Bar",children:s.jsx(ob,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Line",children:s.jsx(lb,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"80-20 Line",children:s.jsx(db,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Reference Lines",children:s.jsx(xb,{variables:i,control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Zooming",children:s.jsx(y.Controller,{name:"dataZoom",control:l,render:({field:f})=>s.jsx(Ln,{...f})})})]})]})}function fb(t){const{dataZoom:e=Mt,...n}=t;return{...n,dataZoom:e}}function yb(t){const{markLine:e=Ro,...n}=t;return{...n,markLine:e}}function bb(t){const e=b.defaultsDeep({},t.x_axis.axisLabel,{rotate:0,formatter:ke()});return{...t,x_axis:{...t.x_axis,axisLabel:e}}}function vb(t){const{label_formatter:e=_e}=t.bar;return{...t,bar:{...t.bar,label_formatter:e}}}function _b(t){const e={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return b.defaultsDeep(e,t)}function jb(t){const e={bar:{nameAlignment:"left"},line:{nameAlignment:"right"}};return b.defaultsDeep(e,t)}function wb(t){console.log(t);const{x_axis:e,tooltip:n}=t.x_axis.axisLabel.overflow,r={x_axis:{axisLabel:{overflow:{on_axis:e,in_tooltip:n}}}};return b.defaultsDeep(r,t)}function Cb(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis:i,data_key:o,...l}=t;return{...l,x_axis:{...i,data_key:r(i.data_key)},data_key:r(o)}}catch(n){throw console.error("[Migration failed]",n),n}}class Sb extends ce{constructor(){super(...arguments);$(this,"VERSION",9)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:fb(n.config)})),this.version(3,n=>({...n,version:3,config:yb(n.config)})),this.version(4,n=>({...n,version:4,config:bb(n.config)})),this.version(5,n=>({...n,version:5,config:vb(n.config)})),this.version(6,n=>({...n,version:6,config:_b(n.config)})),this.version(7,n=>({...n,version:7,config:jb(n.config)})),this.version(8,n=>({...n,version:8,config:wb(n.config)})),this.version(9,(n,r)=>({...n,version:9,config:Cb(n.config,r)}))}}const kb={displayName:"viz.pareto_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Sb,name:"paretoChart",viewRender:ab,configRender:gb,createConfig(){return{version:9,config:b.cloneDeep(Cr)}},triggers:[Qo],translation:Qy};function Tb(t,e,n){const{label_field:r,value_field:i,color_field:o}=t;if(!r||!i)return{};const l=A(r),c=A(i),u=A(o),d=e[l.queryID].map(h=>({name:h[l.columnKey],value:Number(h[c.columnKey]),color:u.columnKey?h[u.columnKey]:void 0})),p=Kd("multiple");return{type:"pie",name:"pie",radius:["50%","80%"],itemStyle:{color:({data:h})=>h.color?h.color:p.next().value},label:{position:"outer",alignTo:"edge",formatter:`{name|{b}}
208
- {percentage|{d}%}`,minMargin:5,edgeDistance:10,lineHeight:15,rich:{percentage:{color:"#999"}},margin:20},labelLine:{length:15,length2:0,maxSurfaceAngle:80,showAbove:!0},labelLayout:function(h){const g=h.labelRect.x<n/2,f=h.labelLinePoints;return b.set(f,[2,0],g?h.labelRect.x:h.labelRect.x+h.labelRect.width),{labelLinePoints:f}},data:d,top:10,bottom:10,left:10,right:10}}function Db(t,e,n){return{tooltip:te.getTooltip({}),series:Tb(t,e,n)}}const Uo={id:"builtin:echarts:click-pie-chart:series",displayName:"viz.pie_chart.click_series.label",nameRender:Mb,configRender:zb,payload:[{name:"seriesType",description:"'line' | 'scatter' | 'bar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"Value of the series clicked",valueType:"number"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function zb(t){return s.jsx(s.Fragment,{})}function Mb(t){const{t:e}=_.useTranslation();return s.jsx(a.Text,{children:e("viz.pie_chart.click_series.label")})}const Sr={label_field:"",value_field:"",color_field:""};function Ib({conf:t,data:e,width:n,height:r,interactionManager:i}){const o=It(e,t.label_field),l=qe(i.triggerManager,Uo.id),c=m.useCallback(p=>{const h=b.get(o,p.name,{error:"rowData is not found"});l.forEach(g=>{i.runInteraction(g.id,{...p,rowData:h})})},[o,l,i]),u=m.useMemo(()=>Db(t,e,n),[t,e,n]),d=m.useMemo(()=>({click:c}),[c]);return!n||!r||!u.series.name?null:s.jsx(Se,{echarts:Ce,option:u,style:{width:n,height:r},onEvents:d,notMerge:!0,theme:"merico-light"})}function Eb({context:t,instance:e}){const n=Oe({vizManager:t.vizManager,instance:e}),{value:r}=q(t.instanceData,"config"),i=m.useMemo(()=>b.defaults({},r,Sr),[r]),o=t.data,{width:l,height:c}=t.viewport;return!l||!c?null:s.jsx(Ae,{width:l,height:c,children:s.jsx(Ib,{conf:i,width:He(l),height:et(c),data:o,interactionManager:n})})}function Ab({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),i=m.useMemo(()=>b.defaultsDeep({},n,Sr),[n]),o=m.useMemo(()=>b.clone(i),[i]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=y.useForm({defaultValues:o});m.useEffect(()=>{p(o)},[o]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,i),[h,i]);return u(["label_field","value_field","color_field"]),s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:c(r),children:[s.jsx(ge,{canSubmit:g}),s.jsxs(a.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[s.jsx(y.Controller,{control:l,name:"label_field",render:({field:f})=>s.jsx(O,{label:e("common.name_data_field"),required:!0,...f})}),s.jsx(y.Controller,{control:l,name:"value_field",render:({field:f})=>s.jsx(O,{label:e("common.value_data_field"),required:!0,...f})}),s.jsx(y.Controller,{control:l,name:"color_field",render:({field:f})=>s.jsx(O,{label:e("common.color_data_field"),clearable:!0,...f})})]})]})})}const Pb=[{lang:"en",resources:{pie_chart:{viz_name:"Pie Chart",click_series:{label:"Click pie series"}}}},{lang:"zh",resources:{pie_chart:{viz_name:"饼图",click_series:{label:"点击饼瓣"}}}}];function $b(t){const{color_field:e="",...n}=t;return{...n,color_field:e}}function Bb(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{label_field:i,value_field:o,color_field:l}=t;return{label_field:r(i),value_field:r(o),color_field:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class Lb extends ce{constructor(){super(...arguments);$(this,"VERSION",3)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:$b(n.config)})),this.version(3,(n,r)=>({...n,version:3,config:Bb(n.config,r)}))}}const qb={displayName:"viz.pie_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Lb,name:"pie",viewRender:Eb,configRender:Ab,createConfig(){return{version:3,config:b.cloneDeep(Sr)}},triggers:[Uo],translation:Pb};function Ob(t){return s.jsx(s.Fragment,{})}function Vb(t){const{t:e}=_.useTranslation();return s.jsx(a.Text,{children:e("viz.radar_chart.click_series.label")})}const Yo={id:"builtin:echarts:click-radar-chart:series",displayName:"viz.radar_chart.click_series.label",nameRender:Vb,configRender:Ob,payload:[{name:"seriesType",description:"'radar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]},ts={series_name_key:"",additional_series:[],background:{enabled:!0},label:{enabled:!0},dimensions:[]};function Ko(t){return t?e=>{try{return U(e,t)}catch(n){return console.error(n),e}}:e=>e}function Jo(t){return{show:t.label.enabled,formatter:({dimensionIndex:e,value:n})=>Ko(t.dimensions[e].formatter)(n)}}function Xo(t,e){return e.map(({data_key:n})=>{const r=A(n);return t[r.columnKey]})}function Nb(t,e,n){const r=A(e);return t[r.queryID].map(i=>({value:Xo(i,n),name:i[r.columnKey]}))}function Gb(t,e){const{series_name_key:n,dimensions:r}=e;return[{type:"radar",name:"main-radar",data:Nb(t,n,r),symbolSize:4,lineStyle:{width:1},emphasis:{lineStyle:{width:4}},areaStyle:e.background.enabled?{opacity:.4}:void 0,label:Jo(e)}]}function Fb(t,e){const{additional_series:n,dimensions:r}=e;return n.map(o=>{const l=A(o.name_key),c=A(o.color_key);return{type:"radar",colorBy:"data",data:t[l.queryID].map(p=>{const h=p[l.columnKey],g=p[c.columnKey];return{name:h,value:Xo(p,r),itemStyle:{color:g}}}),symbolSize:4,lineStyle:{width:1},emphasis:{lineStyle:{width:4}},areaStyle:e.background.enabled?{opacity:.4}:void 0,label:Jo(e)}}).flat()}function Wb(t,e){return[...Gb(t,e),...Fb(t,e)]}function Qb(t){return({name:e,marker:n,value:r})=>{if(r.length===0)return"";const i=r.map((o,l)=>{const c=t.dimensions[l],u=Ko(c.formatter);return`
209
+ `,aS=()=>{const{t:e,i18n:t}=_.useTranslation(),[n,s]=m.useState(!1),i=m.useMemo(()=>iS(e("viz.pareto_chart.line_80_20.param_section_note_1"),e("viz.pareto_chart.line_80_20.param_section_note_2")),[t.language]);return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"subtle",compact:!0,onClick:()=>s(a=>!a),children:e(n?"common.actions.close":"viz.pareto_chart.line_80_20.click_to_see_params")}),r.jsx(o.Collapse,{in:n,children:r.jsx(sn.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:i})})]})};function oS({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["markLine"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Stack,{spacing:2,children:[r.jsx(o.Text,{size:"sm",children:n("chart.color.label")}),r.jsx(b.Controller,{name:"markLine.color",control:e,render:({field:s})=>r.jsx(Le,{...s})})]}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(b.Controller,{name:"markLine.label_template",control:e,render:({field:s})=>r.jsx(o.Textarea,{autosize:!0,minRows:2,maxRows:4,label:n("viz.pareto_chart.line_80_20.label_template"),sx:{flex:1},...s})}),r.jsx(aS,{})]})]})}function lS({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["x_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"x_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:s})=>r.jsx(Jt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(St,{...s})})]}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(kt,{...s})})]})}function cS({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["data_key"]),r.jsx(o.Stack,{children:r.jsx(b.Controller,{name:"data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("chart.y_axis.y_axis_data_field"),required:!0,sx:{flex:1},...s})})})}function uS({control:e,index:t,watch:n,variableOptions:s,yAxisOptions:i}){const{t:a}=_.useTranslation(),l=n(`reference_lines.${t}.orientation`);return r.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("common.name"),placeholder:a("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>r.jsx(o.Select,{label:a("common.data_field"),required:!0,data:s,sx:{flex:1},...c})})]}),r.jsx(b.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("chart.content_template.label"),placeholder:a("chart.content_template.hint"),sx:{flex:1},...c})}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(o.Stack,{children:r.jsx(b.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>r.jsx(gn,{label:a("chart.orientation.label"),sx:{flex:1},...c})})}),l==="horizontal"&&r.jsx(b.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:c,onChange:u,...d}})=>r.jsx(o.Select,{label:a("chart.y_axis.label"),data:i,disabled:i.length===0,...d,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){u(0);return}u(Number(p))},sx:{flex:1}})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.style.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>r.jsx(Zn,{sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>r.jsx(o.NumberInput,{label:a("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:a("chart.color.label")}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>r.jsx(Le,{...c})})]})]})}function dS({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,yAxisIndex:0}),a=(d,p)=>{const h=d.name.trim();return h||p+1},l=m.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),c=t(["bar.name","line.name"]),u=m.useMemo(()=>c.map((d,p)=>({label:d,value:p.toString()})),[c]);return r.jsx(fe,{control:e,watch:t,name:"reference_lines",getItem:i,addButtonText:s("chart.reference_line.add"),deleteButtonText:s("chart.reference_line.delete"),renderTabName:a,children:({field:d,index:p})=>r.jsx(uS,{control:e,index:p,watch:t,variableOptions:l,yAxisOptions:u})})}function pS({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=m.useMemo(()=>v.defaults({},n,So),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]),u(["x_axis","data_key","bar","line","dataZoom"]);const h=d(),f=m.useMemo(()=>!v.isEqual(h,n),[h,n]);return r.jsxs("form",{onSubmit:c(s),children:[r.jsx(Ce,{canSubmit:f}),r.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Bar",children:t("chart.series.bar.label")}),r.jsx(o.Tabs.Tab,{value:"Line",children:t("chart.series.line.label")}),r.jsx(o.Tabs.Tab,{value:"80-20 Line",children:t("viz.pareto_chart.line_80_20.label")}),r.jsx(o.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")}),r.jsx(o.Tabs.Tab,{value:"Zooming",children:t("chart.zooming.label")})]}),r.jsx(o.Tabs.Panel,{value:"X Axis",children:r.jsx(lS,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx(cS,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Bar",children:r.jsx(rS,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Line",children:r.jsx(sS,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"80-20 Line",children:r.jsx(oS,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx(dS,{variables:i,control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Zooming",children:r.jsx(b.Controller,{name:"dataZoom",control:l,render:({field:g})=>r.jsx(Ps,{...g})})})]})]})}function hS(e){const{dataZoom:t=jn,...n}=e;return{...n,dataZoom:t}}function fS(e){const{markLine:t=Fp,...n}=e;return{...n,markLine:t}}function mS(e){const t=v.defaultsDeep({},e.x_axis.axisLabel,{rotate:0,formatter:Oe()});return{...e,x_axis:{...e.x_axis,axisLabel:t}}}function gS(e){const{label_formatter:t=Me}=e.bar;return{...e,bar:{...e.bar,label_formatter:t}}}function xS(e){const t={x_axis:{axisLabel:{overflow:{x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}}}}};return v.defaultsDeep(t,e)}function yS(e){const t={bar:{nameAlignment:"left"},line:{nameAlignment:"right"}};return v.defaultsDeep(t,e)}function bS(e){console.log(e);const{x_axis:t,tooltip:n}=e.x_axis.axisLabel.overflow,s={x_axis:{axisLabel:{overflow:{on_axis:t,in_tooltip:n}}}};return v.defaultsDeep(s,e)}function vS(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=c=>c&&`${n}.${c}`,{x_axis:i,data_key:a,...l}=e;return{...l,x_axis:{...i,data_key:s(i.data_key)},data_key:s(a)}}catch(n){throw console.error("[Migration failed]",n),n}}class _S extends ge{constructor(){super(...arguments);B(this,"VERSION",9)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:hS(n.config)})),this.version(3,n=>({...n,version:3,config:fS(n.config)})),this.version(4,n=>({...n,version:4,config:mS(n.config)})),this.version(5,n=>({...n,version:5,config:gS(n.config)})),this.version(6,n=>({...n,version:6,config:xS(n.config)})),this.version(7,n=>({...n,version:7,config:yS(n.config)})),this.version(8,n=>({...n,version:8,config:bS(n.config)})),this.version(9,(n,s)=>({...n,version:9,config:vS(n.config,s)}))}}const jS={displayName:"viz.pareto_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new _S,name:"paretoChart",viewRender:nS,configRender:pS,createConfig(){return{version:9,config:v.cloneDeep(So)}},triggers:[$p],translation:$C};function wS(e,t,n){const{label_field:s,value_field:i,color_field:a}=e;if(!s||!i)return{};const l=O(s),c=O(i),u=O(a),d=t[l.queryID].map(h=>({name:h[l.columnKey],value:Number(h[c.columnKey]),color:u.columnKey?h[u.columnKey]:void 0})),p=Ng("multiple");return{type:"pie",name:"pie",radius:["50%","80%"],itemStyle:{color:({data:h})=>h.color?h.color:p.next().value},label:{position:"outer",alignTo:"edge",formatter:`{name|{b}}
210
+ {percentage|{d}%}`,minMargin:5,edgeDistance:10,lineHeight:15,rich:{percentage:{color:"#999"}},margin:20},labelLine:{length:15,length2:0,maxSurfaceAngle:80,showAbove:!0},labelLayout:function(h){const f=h.labelRect.x<n/2,g=h.labelLinePoints;return v.set(g,[2,0],f?h.labelRect.x:h.labelRect.x+h.labelRect.width),{labelLinePoints:g}},data:d,top:10,bottom:10,left:10,right:10}}function CS(e,t,n){return{tooltip:te.getTooltip({}),series:wS(e,t,n)}}const Gp={id:"builtin:echarts:click-pie-chart:series",displayName:"viz.pie_chart.click_series.label",nameRender:kS,configRender:SS,payload:[{name:"seriesType",description:"'line' | 'scatter' | 'bar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"Value of the series clicked",valueType:"number"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function SS(e){return r.jsx(r.Fragment,{})}function kS(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.pie_chart.click_series.label")})}const ko={label_field:"",value_field:"",color_field:""};function TS({conf:e,data:t,width:n,height:s,interactionManager:i}){const a=wn(t,e.label_field),l=nt(i.triggerManager,Gp.id),c=m.useCallback(p=>{const h=v.get(a,p.name,{error:"rowData is not found"});l.forEach(f=>{i.runInteraction(f.id,{...p,rowData:h})})},[a,l,i]),u=m.useMemo(()=>CS(e,t,n),[e,t,n]),d=m.useMemo(()=>({click:c}),[c]);return!n||!s||!u.series.name?null:r.jsx(Pe,{echarts:Ae,option:u,style:{width:n,height:s},onEvents:d,notMerge:!0,theme:"merico-light"})}function DS({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),i=m.useMemo(()=>v.defaults({},s,ko),[s]),a=e.data,{width:l,height:c}=e.viewport;return!l||!c?null:r.jsx(Ue,{width:l,height:c,children:r.jsx(TS,{conf:i,width:wt(l),height:Ct(c),data:a,interactionManager:n})})}function MS({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=m.useMemo(()=>v.defaultsDeep({},n,ko),[n]),a=m.useMemo(()=>v.clone(i),[i]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]);const h=d(),f=m.useMemo(()=>!v.isEqual(h,i),[h,i]);return u(["label_field","value_field","color_field"]),r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:c(s),children:[r.jsx(Ce,{canSubmit:f}),r.jsxs(o.Stack,{mt:"md",spacing:"xs",p:"md",mb:"sm",sx:{border:"1px solid #eee",borderRadius:"5px"},children:[r.jsx(b.Controller,{control:l,name:"label_field",render:({field:g})=>r.jsx(F,{label:t("common.name_data_field"),required:!0,...g})}),r.jsx(b.Controller,{control:l,name:"value_field",render:({field:g})=>r.jsx(F,{label:t("common.value_data_field"),required:!0,...g})}),r.jsx(b.Controller,{control:l,name:"color_field",render:({field:g})=>r.jsx(F,{label:t("common.color_data_field"),clearable:!0,...g})})]})]})})}const zS=[{lang:"en",resources:{pie_chart:{viz_name:"Pie Chart",click_series:{label:"Click pie series"}}}},{lang:"zh",resources:{pie_chart:{viz_name:"饼图",click_series:{label:"点击饼瓣"}}}}];function IS(e){const{color_field:t="",...n}=e;return{...n,color_field:t}}function ES(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=c=>c&&`${n}.${c}`,{label_field:i,value_field:a,color_field:l}=e;return{label_field:s(i),value_field:s(a),color_field:s(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class AS extends ge{constructor(){super(...arguments);B(this,"VERSION",3)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:IS(n.config)})),this.version(3,(n,s)=>({...n,version:3,config:ES(n.config,s)}))}}const PS={displayName:"viz.pie_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new AS,name:"pie",viewRender:DS,configRender:MS,createConfig(){return{version:3,config:v.cloneDeep(ko)}},triggers:[Gp],translation:zS};function OS(e){return r.jsx(r.Fragment,{})}function LS(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.radar_chart.click_series.label")})}const Wp={id:"builtin:echarts:click-radar-chart:series",displayName:"viz.radar_chart.click_series.label",nameRender:LS,configRender:OS,payload:[{name:"seriesType",description:"'radar'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]},Zs={series_name_key:"",additional_series:[],background:{enabled:!0},label:{enabled:!0},dimensions:[]};function Rp(e){return e?t=>{try{return U(t,e)}catch(n){return console.error(n),t}}:t=>t}function Qp(e){return{show:e.label.enabled,formatter:({dimensionIndex:t,value:n})=>Rp(e.dimensions[t].formatter)(n)}}function Up(e,t){return t.map(({data_key:n})=>{const s=O(n);return e[s.columnKey]})}function BS(e,t,n){const s=O(t);return e[s.queryID].map(i=>({value:Up(i,n),name:i[s.columnKey]}))}function qS(e,t){const{series_name_key:n,dimensions:s}=t;return[{type:"radar",name:"main-radar",data:BS(e,n,s),symbolSize:4,lineStyle:{width:1},emphasis:{lineStyle:{width:4}},areaStyle:t.background.enabled?{opacity:.4}:void 0,label:Qp(t)}]}function VS(e,t){const{additional_series:n,dimensions:s}=t;return n.map(a=>{const l=O(a.name_key),c=O(a.color_key);return{type:"radar",colorBy:"data",data:e[l.queryID].map(p=>{const h=p[l.columnKey],f=p[c.columnKey];return{name:h,value:Up(p,s),itemStyle:{color:f}}}),symbolSize:4,lineStyle:{width:1},emphasis:{lineStyle:{width:4}},areaStyle:t.background.enabled?{opacity:.4}:void 0,label:Qp(t)}}).flat()}function NS(e,t){return[...qS(e,t),...VS(e,t)]}function $S(e){return({name:t,marker:n,value:s})=>{if(s.length===0)return"";const i=s.map((a,l)=>{const c=e.dimensions[l],u=Rp(c.formatter);return`
209
211
  <tr>
210
212
  <td style="padding-left: 18px;">${c.name}</td>
211
- <td style="text-align: right; "><strong>${u(o)}</strong></td>
213
+ <td style="text-align: right; "><strong>${u(a)}</strong></td>
212
214
  </tr>
213
215
  `});return`
214
216
  <table>
@@ -225,7 +227,7 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
225
227
  text-align: left;
226
228
  vertical-align: top;
227
229
  "
228
- >${e}</strong>
230
+ >${t}</strong>
229
231
  </th>
230
232
  </tr>
231
233
  </thead>
@@ -233,54 +235,54 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
233
235
  ${i.join("")}
234
236
  </tbody>
235
237
  </table>
236
- `}}const Rb={legend:{show:!0,bottom:0,left:0},tooltip:{trigger:"item"}},Ub=["#66B4DB","#39BFA2","#E46464","#33A678","#EEBA00","#9D88CB","#939943","#E49792","#09A2B8","#AF5F6B","#6CA157","#09A2B8","#6398C7","#E692BA","#97B566","#8CACE2","#CA79AC","#6DBC80","#B08F4B","#826BAF"];function Yb(t,e){const{series_name_key:n,dimensions:r,additional_series:i}=t;if(!n||r.length===0)return{};const l={radar:{indicator:r.map(({name:c,max:u})=>({name:c,max:u})),splitArea:{show:!1}},tooltip:te.getTooltip({backgroundColor:"rgba(255,255,255,0.6)",formatter:Qb(t)}),legend:{show:!0,bottom:0,left:"center",type:"scroll"},series:Wb(e,t),color:Ub};return b.merge({},Rb,l)}function Kb({conf:t,data:e,width:n,height:r,interactionManager:i,variables:o}){const l=m.useMemo(()=>{const{queryID:h,columnKey:g}=A(t.series_name_key),f=b.keyBy(e[h],g),v=t.additional_series.reduce((w,T)=>{const D=A(T.name_key),z=b.keyBy(e[D.queryID],D.columnKey);return{...w,...z}},f);return{...f,...v}},[e,t.series_name_key,t.additional_series]),c=qe(i.triggerManager,Yo.id),u=m.useCallback(h=>{const g=b.get(l,h.name,{error:"rowData is not found"});c.forEach(f=>{i.runInteraction(f.id,{...h,rowData:g})})},[l,c,i]),d=m.useMemo(()=>({click:u}),[u]),p=m.useMemo(()=>Yb(b.defaultsDeep({},t,ts),e),[t,e]);return!n||!r?null:s.jsx(Se,{echarts:Ce,option:p,style:{width:n,height:r},onEvents:d,notMerge:!0,theme:"merico-light"})}function Jb({context:t,instance:e}){const n=Oe({vizManager:t.vizManager,instance:e}),{value:r}=q(t.instanceData,"config"),{variables:i}=t,o=m.useMemo(()=>b.defaults({},r,ts),[r]),l=t.data,{width:c,height:u}=t.viewport;return!c||!u||!o||b.isEmpty(o==null?void 0:o.dimensions)?null:s.jsx(Ae,{width:c,height:u,children:s.jsx(Kb,{variables:i,width:He(c),height:et(u),data:l,conf:o,interactionManager:n})})}function Xb({control:t,index:e}){const{t:n}=_.useTranslation();return s.jsxs(a.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[s.jsx(a.Group,{grow:!0,noWrap:!0,children:s.jsx(y.Controller,{name:`additional_series.${e}.name_key`,control:t,render:({field:r})=>s.jsx(O,{label:n("viz.radar_chart.series.series_name_field"),required:!0,sx:{flex:1},...r})})}),s.jsx(a.Stack,{children:s.jsx(y.Controller,{name:`additional_series.${e}.color_key`,control:t,render:({field:r})=>s.jsx(O,{label:n("viz.radar_chart.style.color_field"),required:!0,clearable:!0,sx:{flex:1},...r})})})]})}function Zb({control:t,watch:e}){const{t:n}=_.useTranslation(),r=()=>({id:new Date().getTime().toString(),name_key:"",color_key:""}),i=(o,l)=>l+1;return s.jsxs(s.Fragment,{children:[s.jsx(a.Alert,{icon:s.jsx(k.IconInfoCircle,{size:16}),title:n("viz.radar_chart.additional_series.label"),children:s.jsxs(_.Trans,{i18nKey:"viz.radar_chart.additional_series.intro",children:["By setting ",s.jsx(a.Mark,{children:"Series Name Key"}),", you may add series from more queries to the chart."]})}),s.jsx(ae,{control:t,watch:e,name:"additional_series",getItem:r,addButtonText:n("viz.radar_chart.additional_series.add"),deleteButtonText:n("viz.radar_chart.additional_series.delete"),renderTabName:i,children:({field:o,index:l})=>s.jsx(Xb,{control:t,index:l})})]})}function Hb({control:t,index:e}){const{t:n}=_.useTranslation();return s.jsxs(a.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,align:"top",children:[s.jsx(y.Controller,{name:`dimensions.${e}.name`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:`dimensions.${e}.data_key`,control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:`dimensions.${e}.max`,control:t,rules:{validate:r=>{if(Number.isNaN(Number(r)))return n("validation.number.require_a_number")}},render:({field:r,fieldState:i})=>{var o;return s.jsx(a.TextInput,{label:n("common.max"),required:!0,sx:{flex:1},...r,error:(o=i.error)==null?void 0:o.message})}})]}),s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("viz.radar_chart.metric.value_formatter"),labelPosition:"center"}),s.jsx(y.Controller,{name:`dimensions.${e}.formatter`,control:t,render:({field:r})=>s.jsx(Re,{...r})})]})]})}function ev({control:t,watch:e}){const{t:n}=_.useTranslation(),r=()=>{const o=new Date().getTime().toString();return{id:o,name:o,data_key:"",max:"100",formatter:_e}},i=(o,l)=>{const c=o.name.trim();return c||l+1};return s.jsx(s.Fragment,{children:s.jsx(ae,{control:t,watch:e,name:"dimensions",getItem:r,addButtonText:n("viz.radar_chart.metric.add"),deleteButtonText:n("viz.radar_chart.metric.delete"),renderTabName:i,children:({field:o,index:l})=>s.jsx(Hb,{control:t,index:l})})})}function tv({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),i=m.useMemo(()=>b.defaultsDeep({},n,ts),[n]),{control:o,handleSubmit:l,watch:c,getValues:u,reset:d,formState:p}=y.useForm({defaultValues:i,mode:"all"});m.useEffect(()=>{d(i)},[i]),c(["series_name_key","background","label"]);const h=u(),g=m.useMemo(()=>!b.isEqual(h,i),[h,i]);return s.jsx("form",{onSubmit:l(r),children:s.jsxs(a.Stack,{spacing:"xs",children:[s.jsx(ge,{canSubmit:g&&p.isValid}),s.jsxs(a.Tabs,{defaultValue:"series",children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"series",children:e("chart.series.label")}),s.jsx(a.Tabs.Tab,{value:"metrics",children:e("viz.radar_chart.metric.labels")}),s.jsx(a.Tabs.Tab,{value:"style",children:e("chart.style.label")}),s.jsx(a.Tabs.Tab,{value:"additional_series",ml:"auto",children:e("viz.radar_chart.additional_series.label")})]}),s.jsx(a.Tabs.Panel,{value:"series",p:"md",children:s.jsx(y.Controller,{name:"series_name_key",control:o,render:({field:f})=>s.jsx(O,{label:e("viz.radar_chart.series.series_name_field"),required:!0,sx:{flex:1},...f})})}),s.jsx(a.Tabs.Panel,{value:"metrics",p:"md",children:s.jsx(ev,{control:o,watch:c})}),s.jsx(a.Tabs.Panel,{value:"style",p:"md",children:s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"background.enabled",control:o,render:({field:f})=>s.jsx(a.Checkbox,{label:e("viz.radar_chart.style.show_background"),checked:f.value,onChange:v=>f.onChange(v.currentTarget.checked)})}),s.jsx(y.Controller,{name:"label.enabled",control:o,render:({field:f})=>s.jsx(a.Checkbox,{label:e("viz.radar_chart.style.show_value_label"),checked:f.value,onChange:v=>f.onChange(v.currentTarget.checked)})})]})}),s.jsx(a.Tabs.Panel,{value:"additional_series",p:"md",children:s.jsx(Zb,{control:o,watch:c})})]})]})})}const nv=[{lang:"en",resources:{radar_chart:{viz_name:"Radar Chart",series:{series_name_field:"Series Name Field"},metric:{labels:"Metrics",value_formatter:"Value Formatter",add:"Add a metric",delete:"Delete this metric"},additional_series:{label:"Additional Series",intro:"By setting <1>Series Name Field</1>, you may add series from more queries to the chart.",add:"Add a series",delete:"Delete"},style:{show_background:"Show background",show_value_label:"Show value label",color_field:"Color Field"},click_series:{label:"Click radar chart series"}}}},{lang:"zh",resources:{radar_chart:{viz_name:"雷达图",series:{series_name_field:"系列名字段"},metric:{labels:"维度",value_formatter:"数据格式",add:"增加一个维度",delete:"删除这个维度"},additional_series:{label:"扩展系列",intro:"在<1>系列名字段</1>中选择不同查询中的字段,从而实现图表系列的扩展",add:"增加一个扩展系列",delete:"删除这个扩展系列"},style:{show_background:"显示背景",show_value_label:"显示标签文案",color_field:"颜色字段"},click_series:{label:"点击雷达系列"}}}}];function sv(t){const{dimensions:e=[],...n}=t;function r({name:i="",data_key:o="",max:l=10,formatter:c=_e}){return{name:i,data_key:o,max:l,formatter:c}}return{...n,dimensions:e.map(r)}}function rv(t){const{dimensions:e=[],...n}=t;return{...n,dimensions:e.map(r=>({...r,id:r.id??r.name}))}}function iv(t){const e={background:{enabled:!0},label:{enabled:!0}};return b.defaultsDeep(e,t)}function av(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{series_name_key:i,dimensions:o,...l}=t;return{...l,series_name_key:r(i),dimensions:o.map(c=>({...c,data_key:r(c.data_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}function ov(t){const e={additional_series:[]};return b.defaultsDeep(e,t)}function lv(t){const e={...t,dimensions:t.dimensions.map(n=>({...n,max:String(n.max)}))};return delete e.additionalSeries,e}class cv extends ce{constructor(){super(...arguments);$(this,"VERSION",7)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{config:r}=n;return{...n,version:2,config:sv(r)}}),this.version(3,n=>{const{config:r}=n;return{...n,version:3,config:rv(r)}}),this.version(4,n=>{const{config:r}=n;return{...n,version:4,config:iv(r)}}),this.version(5,(n,r)=>{const{config:i}=n;return{...n,version:5,config:av(i,r)}}),this.version(6,n=>{const{config:r}=n;return{...n,version:6,config:ov(r)}}),this.version(7,n=>{const{config:r}=n;return{...n,version:7,config:lv(r)}})}}const uv={displayName:"viz.radar_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new cv,name:"radar",viewRender:Jb,configRender:tv,createConfig:()=>({version:7,config:ts}),triggers:[Yo],translation:nv};function dv(t,e){const{plot:n,transform:r}=t.regression;return e.map(i=>({...n,id:`reg-for-${i.name}`,name:i.name,data:qn(r,i.data),color:i.color,showSymbol:!1,smooth:!0,tooltip:{show:!1},custom:{type:"regression-line",targetSeries:i.name}}))}function Zo(t,e){const n=A(t.x_axis.data_key),r=A(t.regression.y_axis_data_key);return b.uniqBy(e.map(i=>[i[n.columnKey],i[r.columnKey]]),0)}function pv(t,e){const{plot:n,transform:r}=t.regression,i=Zo(t,e);return[{type:"scatter",name:t.y_axis.name,data:i,symbolSize:4,color:"red",markLine:{...n,data:[qn(r,i)],color:"blue",smooth:!0,silent:!0,symbol:["none","none"]}}]}function hv(t,e){const{plot:n,transform:r,group_by_key:i}=t.regression,o=A(i),l=b.groupBy(e,o.columnKey);return Object.entries(l).map(([c,u])=>{const d=Zo(t,u);return{type:"scatter",name:c,data:d,symbolSize:4,markLine:{...n,data:[qn(r,d)],smooth:!0,silent:!0,symbol:["none","none"]}}})}function mv(t,e){if(e.length===0)return[];const{group_by_key:n}=t.regression;return n?hv(t,e):pv(t,e)}function xv(t){return Array.isArray(t)||(t=[t]),t.map(e=>({marker:e.marker,label:e.seriesName,x:e.value[0],y:e.value[1]}))}function gv(t){return te.getTooltip({trigger:"axis",formatter:e=>{const n=xv(e);return n.length===0?"":`
238
+ `}}const FS={legend:{show:!0,bottom:0,left:0},tooltip:{trigger:"item"}},GS=["#66B4DB","#39BFA2","#E46464","#33A678","#EEBA00","#9D88CB","#939943","#E49792","#09A2B8","#AF5F6B","#6CA157","#09A2B8","#6398C7","#E692BA","#97B566","#8CACE2","#CA79AC","#6DBC80","#B08F4B","#826BAF"];function WS(e,t){const{series_name_key:n,dimensions:s,additional_series:i}=e;if(!n||s.length===0)return{};const l={radar:{indicator:s.map(({name:c,max:u})=>({name:c,max:u})),splitArea:{show:!1}},tooltip:te.getTooltip({backgroundColor:"rgba(255,255,255,0.6)",formatter:$S(e)}),legend:{show:!0,bottom:0,left:"center",type:"scroll"},series:NS(t,e),color:GS};return v.merge({},FS,l)}function RS({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=m.useMemo(()=>{const{queryID:h,columnKey:f}=O(e.series_name_key),g=v.keyBy(t[h],f),y=e.additional_series.reduce((j,k)=>{const S=O(k.name_key),T=v.keyBy(t[S.queryID],S.columnKey);return{...j,...T}},g);return{...g,...y}},[t,e.series_name_key,e.additional_series]),c=nt(i.triggerManager,Wp.id),u=m.useCallback(h=>{const f=v.get(l,h.name,{error:"rowData is not found"});c.forEach(g=>{i.runInteraction(g.id,{...h,rowData:f})})},[l,c,i]),d=m.useMemo(()=>({click:u}),[u]),p=m.useMemo(()=>WS(v.defaultsDeep({},e,Zs),t),[e,t]);return!n||!s?null:r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,theme:"merico-light"})}function QS({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=m.useMemo(()=>v.defaults({},s,Zs),[s]),l=e.data,{width:c,height:u}=e.viewport;return!c||!u||!a||v.isEmpty(a==null?void 0:a.dimensions)?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(RS,{variables:i,width:wt(c),height:Ct(u),data:l,conf:a,interactionManager:n})})}function US({control:e,index:t}){const{t:n}=_.useTranslation();return r.jsxs(o.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:`additional_series.${t}.name_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("viz.radar_chart.series.series_name_field"),required:!0,sx:{flex:1},...s})})}),r.jsx(o.Stack,{children:r.jsx(b.Controller,{name:`additional_series.${t}.color_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("viz.radar_chart.style.color_field"),required:!0,clearable:!0,sx:{flex:1},...s})})})]})}function YS({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>({id:new Date().getTime().toString(),name_key:"",color_key:""}),i=(a,l)=>l+1;return r.jsxs(r.Fragment,{children:[r.jsx(o.Alert,{icon:r.jsx(M.IconInfoCircle,{size:16}),title:n("viz.radar_chart.additional_series.label"),children:r.jsxs(_.Trans,{i18nKey:"viz.radar_chart.additional_series.intro",children:["By setting ",r.jsx(o.Mark,{children:"Series Name Key"}),", you may add series from more queries to the chart."]})}),r.jsx(fe,{control:e,watch:t,name:"additional_series",getItem:s,addButtonText:n("viz.radar_chart.additional_series.add"),deleteButtonText:n("viz.radar_chart.additional_series.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(US,{control:e,index:l})})]})}function KS({control:e,index:t}){const{t:n}=_.useTranslation();return r.jsxs(o.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,align:"top",children:[r.jsx(b.Controller,{name:`dimensions.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`dimensions.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`dimensions.${t}.max`,control:e,rules:{validate:s=>{if(Number.isNaN(Number(s)))return n("validation.number.require_a_number")}},render:({field:s,fieldState:i})=>{var a;return r.jsx(o.TextInput,{label:n("common.max"),required:!0,sx:{flex:1},...s,error:(a=i.error)==null?void 0:a.message})}})]}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("viz.radar_chart.metric.value_formatter"),labelPosition:"center"}),r.jsx(b.Controller,{name:`dimensions.${t}.formatter`,control:e,render:({field:s})=>r.jsx(ft,{...s})})]})]})}function XS({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>{const a=new Date().getTime().toString();return{id:a,name:a,data_key:"",max:"100",formatter:Me}},i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsx(r.Fragment,{children:r.jsx(fe,{control:e,watch:t,name:"dimensions",getItem:s,addButtonText:n("viz.radar_chart.metric.add"),deleteButtonText:n("viz.radar_chart.metric.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(KS,{control:e,index:l})})})}function JS({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=m.useMemo(()=>v.defaultsDeep({},n,Zs),[n]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d,formState:p}=b.useForm({defaultValues:i,mode:"all"});m.useEffect(()=>{d(i)},[i]),c(["series_name_key","background","label"]);const h=u(),f=m.useMemo(()=>!v.isEqual(h,i),[h,i]);return r.jsx("form",{onSubmit:l(s),children:r.jsxs(o.Stack,{spacing:"xs",children:[r.jsx(Ce,{canSubmit:f&&p.isValid}),r.jsxs(o.Tabs,{defaultValue:"series",children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"series",children:t("chart.series.label")}),r.jsx(o.Tabs.Tab,{value:"metrics",children:t("viz.radar_chart.metric.labels")}),r.jsx(o.Tabs.Tab,{value:"style",children:t("chart.style.label")}),r.jsx(o.Tabs.Tab,{value:"additional_series",ml:"auto",children:t("viz.radar_chart.additional_series.label")})]}),r.jsx(o.Tabs.Panel,{value:"series",p:"md",children:r.jsx(b.Controller,{name:"series_name_key",control:a,render:({field:g})=>r.jsx(F,{label:t("viz.radar_chart.series.series_name_field"),required:!0,sx:{flex:1},...g})})}),r.jsx(o.Tabs.Panel,{value:"metrics",p:"md",children:r.jsx(XS,{control:a,watch:c})}),r.jsx(o.Tabs.Panel,{value:"style",p:"md",children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"background.enabled",control:a,render:({field:g})=>r.jsx(o.Checkbox,{label:t("viz.radar_chart.style.show_background"),checked:g.value,onChange:y=>g.onChange(y.currentTarget.checked)})}),r.jsx(b.Controller,{name:"label.enabled",control:a,render:({field:g})=>r.jsx(o.Checkbox,{label:t("viz.radar_chart.style.show_value_label"),checked:g.value,onChange:y=>g.onChange(y.currentTarget.checked)})})]})}),r.jsx(o.Tabs.Panel,{value:"additional_series",p:"md",children:r.jsx(YS,{control:a,watch:c})})]})]})})}const ZS=[{lang:"en",resources:{radar_chart:{viz_name:"Radar Chart",series:{series_name_field:"Series Name Field"},metric:{labels:"Metrics",value_formatter:"Value Formatter",add:"Add a metric",delete:"Delete this metric"},additional_series:{label:"Additional Series",intro:"By setting <1>Series Name Field</1>, you may add series from more queries to the chart.",add:"Add a series",delete:"Delete"},style:{show_background:"Show background",show_value_label:"Show value label",color_field:"Color Field"},click_series:{label:"Click radar chart series"}}}},{lang:"zh",resources:{radar_chart:{viz_name:"雷达图",series:{series_name_field:"系列名字段"},metric:{labels:"维度",value_formatter:"数据格式",add:"增加一个维度",delete:"删除这个维度"},additional_series:{label:"扩展系列",intro:"在<1>系列名字段</1>中选择不同查询中的字段,从而实现图表系列的扩展",add:"增加一个扩展系列",delete:"删除这个扩展系列"},style:{show_background:"显示背景",show_value_label:"显示标签文案",color_field:"颜色字段"},click_series:{label:"点击雷达系列"}}}}];function HS(e){const{dimensions:t=[],...n}=e;function s({name:i="",data_key:a="",max:l=10,formatter:c=Me}){return{name:i,data_key:a,max:l,formatter:c}}return{...n,dimensions:t.map(s)}}function ek(e){const{dimensions:t=[],...n}=e;return{...n,dimensions:t.map(s=>({...s,id:s.id??s.name}))}}function tk(e){const t={background:{enabled:!0},label:{enabled:!0}};return v.defaultsDeep(t,e)}function nk(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=c=>c&&`${n}.${c}`,{series_name_key:i,dimensions:a,...l}=e;return{...l,series_name_key:s(i),dimensions:a.map(c=>({...c,data_key:s(c.data_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}function rk(e){const t={additional_series:[]};return v.defaultsDeep(t,e)}function sk(e){const t={...e,dimensions:e.dimensions.map(n=>({...n,max:String(n.max)}))};return delete t.additionalSeries,t}class ik extends ge{constructor(){super(...arguments);B(this,"VERSION",7)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{config:s}=n;return{...n,version:2,config:HS(s)}}),this.version(3,n=>{const{config:s}=n;return{...n,version:3,config:ek(s)}}),this.version(4,n=>{const{config:s}=n;return{...n,version:4,config:tk(s)}}),this.version(5,(n,s)=>{const{config:i}=n;return{...n,version:5,config:nk(i,s)}}),this.version(6,n=>{const{config:s}=n;return{...n,version:6,config:rk(s)}}),this.version(7,n=>{const{config:s}=n;return{...n,version:7,config:sk(s)}})}}const ak={displayName:"viz.radar_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new ik,name:"radar",viewRender:QS,configRender:JS,createConfig:()=>({version:7,config:Zs}),triggers:[Wp],translation:ZS};function ok(e,t){const{plot:n,transform:s}=e.regression;return t.map(i=>({...n,id:`reg-for-${i.name}`,name:i.name,data:Os(s,i.data),color:i.color,showSymbol:!1,smooth:!0,tooltip:{show:!1},custom:{type:"regression-line",targetSeries:i.name}}))}function Yp(e,t){const n=O(e.x_axis.data_key),s=O(e.regression.y_axis_data_key);return v.uniqBy(t.map(i=>[i[n.columnKey],i[s.columnKey]]),0)}function lk(e,t){const{plot:n,transform:s}=e.regression,i=Yp(e,t);return[{type:"scatter",name:e.y_axis.name,data:i,symbolSize:4,color:"red",markLine:{...n,data:[Os(s,i)],color:"blue",smooth:!0,silent:!0,symbol:["none","none"]}}]}function ck(e,t){const{plot:n,transform:s,group_by_key:i}=e.regression,a=O(i),l=v.groupBy(t,a.columnKey);return Object.entries(l).map(([c,u])=>{const d=Yp(e,u);return{type:"scatter",name:c,data:d,symbolSize:4,markLine:{...n,data:[Os(s,d)],smooth:!0,silent:!0,symbol:["none","none"]}}})}function uk(e,t){if(t.length===0)return[];const{group_by_key:n}=e.regression;return n?ck(e,t):lk(e,t)}function dk(e){return Array.isArray(e)||(e=[e]),e.map(t=>({marker:t.marker,label:t.seriesName,x:t.value[0],y:t.value[1]}))}function pk(e){return te.getTooltip({trigger:"axis",formatter:t=>{const n=dk(t);return n.length===0?"":`
237
239
  <table style="width: auto">
238
240
  <thead>
239
241
  <tr>
240
242
  <th/>
241
- ${n.map(({marker:i,label:o})=>`<th style="padding: 0 .5em;">${i} ${o}</th>`).join("")}
243
+ ${n.map(({marker:i,label:a})=>`<th style="padding: 0 .5em;">${i} ${a}</th>`).join("")}
242
244
  </tr>
243
245
  </thead>
244
246
  <tbody>
245
247
  <tr>
246
- <th style="text-align: left; padding: 0 .5em;">${t.x_axis.name}</th>
248
+ <th style="text-align: left; padding: 0 .5em;">${e.x_axis.name}</th>
247
249
  ${n.map(({x:i})=>`<td style="text-align: right; padding: 0 .5em;">${i}</td>`).join("")}
248
250
  </tr>
249
251
  <tr>
250
- <th style="text-align: left; padding: 0 .5em;">${t.y_axis.name}</th>
252
+ <th style="text-align: left; padding: 0 .5em;">${e.y_axis.name}</th>
251
253
  ${n.map(({y:i})=>`<td style="text-align: right; padding: 0 .5em;">${i}</td>`).join("")}
252
254
  </tr>
253
255
  </tbody>
254
256
  </table>
255
- `}})}function fv(t){const{overflow:e,format:n,formatter:r,...i}=t.x_axis.axisLabel,o=Qe(e.on_axis);return te.getXAxis({type:"value",name:t.x_axis.name??"",nameLocation:"middle",nameGap:25,axisLabel:{...i,...o,formatter:(l,c)=>{let u=l;try{u=U(l,n)}catch{}return Pe(r)(u,c)}}})}const yv={tooltip:{trigger:"axis"},grid:{top:50,left:5,right:10,bottom:20,containLabel:!0},dataZoom:[{type:"inside",xAxisIndex:[0]},{type:"inside",yAxisIndex:[0]}]};function bv(t,e){const n=mv(t,e),r=dv(t,n),i={xAxis:fv(t),yAxis:te.getYAxis({name:t.y_axis.name??"",nameLocation:"end",nameTextStyle:{align:"left"},nameGap:5}),series:[...n,...r],tooltip:gv(t),legend:{show:!0,type:"scroll",orient:"horizontal",align:"left",right:0,top:0,left:"auto",itemGap:20,padding:[4,8,0,140],data:n.map(o=>o.name)}};return b.defaultsDeep({},i,yv)}const Ho={output:"number",mantissa:2,trimMantissa:!0,absolute:!1};function ns(t,e,n){return 1-(1-t)*(e-1)/(e-n-1)}function vv(t,e,n,r){const{x_axis:i,y_axis:o}=r,l=wt.regressionLinear()(n),{a:c,b:u,rSquared:d}=l;return{name:t,expression:s.jsxs(a.Group,{position:"center",noWrap:!0,spacing:10,children:[s.jsx(a.Text,{children:o.name}),s.jsx(a.Text,{children:"="}),s.jsx(a.Text,{weight:"bold",color:"red",children:U(u,Ho)}),s.jsx(a.Text,{children:"+"}),s.jsx(a.Text,{weight:"bold",color:"red",children:U(c,Ho)}),s.jsx(a.Text,{children:"×"}),s.jsx(a.Text,{children:i.name})]}),rSquared:d,adjustedRSquared:ns(d,e.length,1)}}function _v(t,e,n,r){const{x_axis:i,y_axis:o}=r,{a:l,b:c,rSquared:u}=wt.regressionExp()(n);return{name:t,expression:s.jsxs(a.Group,{position:"center",noWrap:!0,spacing:10,children:[s.jsx(a.Text,{children:o.name}),s.jsx(a.Text,{children:"="}),s.jsx(a.Text,{weight:"bold",color:"gray",children:l}),s.jsx(a.Text,{children:"×"}),s.jsxs(a.Group,{position:"left",noWrap:!0,spacing:2,children:[s.jsx(a.Text,{children:"Math.exp("}),s.jsx(a.Text,{weight:"bold",color:"gray",children:c}),s.jsx(a.Text,{children:"×"}),s.jsx(a.Text,{children:i.name}),s.jsx(a.Text,{children:")"})]})]}),rSquared:u,adjustedRSquared:ns(u,e.length,1)}}function jv(t,e,n,r){const{x_axis:i,y_axis:o}=r,{a:l,b:c,rSquared:u}=wt.regressionLog()(n);return{name:t,expression:s.jsxs(a.Group,{position:"center",noWrap:!0,spacing:10,children:[s.jsx(a.Text,{children:o.name}),s.jsx(a.Text,{children:"="}),s.jsx(a.Text,{weight:"bold",color:"gray",children:l}),s.jsx(a.Text,{children:"×"}),s.jsxs(a.Group,{position:"left",noWrap:!0,spacing:2,children:[s.jsx(a.Text,{children:"Math.log("}),s.jsx(a.Text,{children:i.name}),s.jsx(a.Text,{children:")"}),s.jsx(a.Text,{children:"+"}),s.jsx(a.Text,{weight:"bold",color:"gray",children:c})]})]}),rSquared:u,adjustedRSquared:ns(u,e.length,1)}}function wv(t,e,n,r){const{x_axis:i,y_axis:o,regression:l}=r,c=wt.regressionPoly().order(l.transform.config.order)(n),{rSquared:u}=c;return console.log(c),{name:t,expression:"",rSquared:u,adjustedRSquared:ns(u,e.length,1)}}function el(t,e,n){const{regression:r,x_axis:i}=n,o=A(i.data_key),l=A(r.y_axis_data_key),c=e.map(u=>[u[o.columnKey],u[l.columnKey]]);return r.transform.config.method==="linear"?vv(t,e,c,n):r.transform.config.method==="exponential"?_v(t,e,c,n):r.transform.config.method==="logistic"?jv(t,e,c,n):r.transform.config.method==="polynomial"?wv(t,e,c,n):{name:t,expression:"",rSquared:0,adjustedRSquared:0}}function Cv(t,e){if(!e)return[{name:"",expression:"",rSquared:0,adjustedRSquared:0}];if(!e.regression.group_by_key)return[el("",t,e)];const n=A(e.regression.group_by_key),r=b.groupBy(t,n.columnKey);return Object.entries(r).map(([i,o])=>el(i,o,e))}const Sv={marginTop:"10px","tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function tl({desc:t}){const{t:e}=_.useTranslation(),{expression:n,rSquared:r,adjustedRSquared:i}=t;return n?s.jsx(a.Table,{fontSize:14,sx:Sv,children:s.jsxs("tbody",{children:[s.jsx("tr",{children:s.jsx("td",{colSpan:2,children:s.jsx(a.Text,{align:"center",children:n})})}),s.jsxs("tr",{children:[s.jsx("td",{children:e("viz.regression_chart.r_sq")}),s.jsx("td",{style:{textAlign:"right"},children:U(r,{output:"percent",mantissa:1,absolute:!1})})]}),s.jsxs("tr",{children:[s.jsx("td",{children:e("viz.regression_chart.r_sq_adjusted")}),s.jsx("td",{style:{textAlign:"right"},children:U(i,{output:"percent",mantissa:1,absolute:!1})})]})]})}):s.jsx(a.Text,{children:"Unavailable for this regression method"})}function kv({conf:t,queryData:e}){var r;const n=m.useMemo(()=>Cv(e,t),[t,e]);return t.regression.group_by_key?(console.log(n),s.jsxs(a.Tabs,{defaultValue:(r=n[0])==null?void 0:r.name,color:"gray",children:[s.jsx(a.Tabs.List,{grow:!0,children:n.map(i=>s.jsx(a.Tabs.Tab,{value:i.name,children:i.name},i.name))}),n.map(i=>s.jsx(a.Tabs.Panel,{value:i.name,children:s.jsx(tl,{desc:i})},i.name))]})):s.jsx(tl,{desc:n[0]})}function Tv({conf:t,queryData:e}){const{t:n}=_.useTranslation();return s.jsxs(a.HoverCard,{shadow:"md",withinPortal:!0,zIndex:320,children:[s.jsx(a.HoverCard.Target,{children:s.jsx(a.Button,{size:"xs",variant:"subtle",compact:!0,leftIcon:s.jsx(k.IconInfoCircle,{size:14}),children:n("viz.regression_chart.regression_info")})}),s.jsx(a.HoverCard.Dropdown,{children:s.jsx(je,{children:s.jsx(kv,{conf:t,queryData:e})})})]})}function Dv(t){return s.jsx(a.Group,{position:"apart",sx:{position:"absolute",top:0,left:Ee.left,right:Ee.right,height:"22px",zIndex:1},children:s.jsx(Tv,{...t})})}const kr={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,format:_e,overflow:$e(),formatter:ke()}},y_axis:{name:"Y Axis"},regression:{transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},plot:{type:"line",yAxisIndex:0,color:"#228be6",lineStyle:{type:"solid",width:1}},name:"regression",group_by_key:"",y_axis_data_key:"value"}};function zv({context:t}){const{value:e}=q(t.instanceData,"config"),{width:n,height:r}=t.viewport,i=m.useMemo(()=>{var f;const u=t.data,d=e==null?void 0:e.x_axis.data_key,p=(f=e==null?void 0:e.regression)==null?void 0:f.y_axis_data_key;if(!d||!p)return[];const h=A(d),g=A(p);return u[h.queryID].map(v=>typeof v[g.columnKey]=="number"?v:{...v,[g.columnKey]:Number(v[g.columnKey])})},[t.data,e==null?void 0:e.regression.y_axis_data_key]),o=m.useMemo(()=>bv(b.defaultsDeep({},e,kr),i),[e,i]),l=m.useRef(null),c=u=>{l.current=u};return!n||!r||!e?null:s.jsxs(Ae,{width:n,height:r,children:[s.jsx(Dv,{conf:e,queryData:i}),s.jsx(Se,{echarts:Ce,onChartReady:c,option:o,style:un(n,r),notMerge:!0,theme:"merico-light"})]})}function Mv({control:t,watch:e}){const{t:n,i18n:r}=_.useTranslation();e("regression");const i=e("regression.transform.config.method"),o=e("regression.group_by_key"),l=m.useMemo(()=>[{label:n("chart.regression_line.method.linear"),value:"linear"},{label:n("chart.regression_line.method.exponential"),value:"exponential"},{label:n("chart.regression_line.method.logistic"),value:"logistic"},{label:n("chart.regression_line.method.polynomial"),value:"polynomial"}],[r.language]);return s.jsxs(a.Stack,{children:[s.jsx(a.Group,{grow:!0,noWrap:!0,children:s.jsx(y.Controller,{name:"regression.name",control:t,render:({field:c})=>s.jsx(a.TextInput,{label:n("common.name"),sx:{flex:1},...c})})}),s.jsx(y.Controller,{name:"regression.group_by_key",control:t,render:({field:c})=>s.jsx(O,{label:n("chart.series.group_by.label"),clearable:!0,sx:{flex:1},...c})}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"regression.transform.config.method",control:t,render:({field:c})=>s.jsx(a.Select,{label:n("chart.regression_line.method.label"),data:l,sx:{flex:1},...c})}),i==="polynomial"&&s.jsx(y.Controller,{name:"regression.transform.config.order",control:t,render:({field:c})=>s.jsx(a.NumberInput,{label:n("chart.regression_line.method.polynomial_order"),sx:{flex:1},...c})})]}),!o&&s.jsxs(a.Stack,{spacing:4,children:[s.jsx(a.Text,{size:"sm",children:n("chart.color.label")}),s.jsx(y.Controller,{name:"regression.plot.color",control:t,render:({field:c})=>s.jsx(Te,{...c})})]})]})}function Iv({control:t,watch:e}){return e(["x_axis"]),s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.name",control:t,render:({field:n})=>s.jsx(a.TextInput,{label:"X轴名称",sx:{flex:1},...n})}),s.jsx(y.Controller,{name:"x_axis.data_key",control:t,render:({field:n})=>s.jsx(O,{label:"X轴数据字段",required:!0,sx:{flex:1},...n})})]}),s.jsx(a.Divider,{variant:"dashed",labelPosition:"center",label:"格式化数据"}),s.jsx(a.Stack,{children:s.jsx(y.Controller,{name:"x_axis.axisLabel.format",control:t,render:({field:n})=>s.jsx(Re,{...n})})}),s.jsx(a.Divider,{variant:"dashed",labelPosition:"center",label:"标签文案样式"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:n})=>s.jsx(a.NumberInput,{label:"旋转",hideControls:!0,min:-90,max:90,rightSection:s.jsx(a.Text,{color:"dimmed",children:"度"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),s.jsx(y.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:n})=>s.jsx(tt,{triggerButtonText:"自定义标签文案内容",...n})})]}),s.jsx(y.Controller,{name:"x_axis.axisLabel.overflow",control:t,render:({field:n})=>s.jsx(nt,{...n})})]})}function Ev({control:t,watch:e}){return e(["y_axis","regression.y_axis_data_key"]),s.jsx(a.Stack,{children:s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"y_axis.name",control:t,render:({field:n})=>s.jsx(a.TextInput,{label:"Y轴名称",sx:{flex:1},...n})}),s.jsx(y.Controller,{name:"regression.y_axis_data_key",control:t,render:({field:n})=>s.jsx(O,{label:"Y轴数据字段",required:!0,sx:{flex:1},...n})})]})})}function Av({context:t}){const{value:e,set:n}=q(t.instanceData,"config"),r=m.useMemo(()=>b.defaults({},e,kr),[e]),{control:i,handleSubmit:o,watch:l,getValues:c,reset:u}=y.useForm({defaultValues:r});m.useEffect(()=>{u(r)},[r]),l(["x_axis","y_axis","regression"]);const d=c(),p=m.useMemo(()=>!b.isEqual(d,e),[d,e]);return s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:o(n),children:[s.jsx(ge,{canSubmit:p}),s.jsxs(a.Tabs,{defaultValue:"X轴",orientation:"vertical",styles:{panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"X轴",children:"X轴"}),s.jsx(a.Tabs.Tab,{value:"Y轴",children:"Y轴"}),s.jsx(a.Tabs.Tab,{value:"回归",children:"回归"})]}),s.jsx(a.Tabs.Panel,{value:"X轴",children:s.jsx(Iv,{watch:l,control:i})}),s.jsx(a.Tabs.Panel,{value:"Y轴",children:s.jsx(Ev,{watch:l,control:i})}),s.jsx(a.Tabs.Panel,{value:"回归",children:s.jsx(Mv,{control:i,watch:l})})]})]})})}function Pv(t){const e={x_axis:{axisLabel:{rotate:0,format:_e,overflow:$e(),formatter:ke()}},regression:{group_by_key:""}};return b.defaultsDeep(e,t)}function $v(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{x_axis:i,regression:o,...l}=t;return{...l,x_axis:{...i,data_key:r(i.data_key)},regression:{...o,group_by_key:r(o.group_by_key),y_axis_data_key:r(o.y_axis_data_key)}}}catch(n){throw console.error("[Migration failed]",n),n}}const Bv=[{lang:"en",resources:{regression_chart:{viz_name:"Regression Chart",regression_info:"Regression Info",r_sq:"R-Sq",r_sq_adjusted:"R-Sq(Adjusted)"}}},{lang:"zh",resources:{regression_chart:{viz_name:"回归分析图",regression_info:"回归信息",r_sq:"R方",r_sq_adjusted:"R方(调整)"}}}];class Lv extends ce{constructor(){super(...arguments);$(this,"VERSION",3)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:Pv(n.config)})),this.version(3,(n,r)=>{const{config:i}=n;return{...n,version:3,config:$v(i,r)}})}}const qv={displayName:"viz.regression_chart.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Lv,name:"regressionChart",viewRender:zv,configRender:Av,createConfig(){return{version:3,config:b.cloneDeep(kr)}},translation:Bv},ss={content:""};function Ov(t,e){const n={};return t.forEach(r=>{const{name:i,data_field:o,aggregation:l}=r,c=zn(e,o,l);n[i]=Ie(r,c)}),n}function Vv(t){const e=document.createElement("span");return e.innerHTML=t,e.innerText}function Nv(t,e,n){try{return new Function("payload",`
257
+ `}})}function hk(e){const{overflow:t,format:n,formatter:s,...i}=e.x_axis.axisLabel,a=ut(t.on_axis);return te.getXAxis({type:"value",name:e.x_axis.name??"",nameLocation:"middle",nameGap:25,axisLabel:{...i,...a,formatter:(l,c)=>{let u=l;try{u=U(l,n)}catch{}return Ye(s)(u,c)}}})}const fk={tooltip:{trigger:"axis"},grid:{top:50,left:5,right:10,bottom:20,containLabel:!0},dataZoom:[{type:"inside",xAxisIndex:[0]},{type:"inside",yAxisIndex:[0]}]};function mk(e,t){const n=uk(e,t),s=ok(e,n),i={xAxis:hk(e),yAxis:te.getYAxis({name:e.y_axis.name??"",nameLocation:"end",nameTextStyle:{align:"left"},nameGap:5}),series:[...n,...s],tooltip:pk(e),legend:{show:!0,type:"scroll",orient:"horizontal",align:"left",right:0,top:0,left:"auto",itemGap:20,padding:[4,8,0,140],data:n.map(a=>a.name)}};return v.defaultsDeep({},i,fk)}const Kp={output:"number",mantissa:2,trimMantissa:!0,absolute:!1};function Hs(e,t,n){return 1-(1-e)*(t-1)/(t-n-1)}function gk(e,t,n,s){const{x_axis:i,y_axis:a}=s,l=an.regressionLinear()(n),{a:c,b:u,rSquared:d}=l;return{name:e,expression:r.jsxs(o.Group,{position:"center",noWrap:!0,spacing:10,children:[r.jsx(o.Text,{children:a.name}),r.jsx(o.Text,{children:"="}),r.jsx(o.Text,{weight:"bold",color:"red",children:U(u,Kp)}),r.jsx(o.Text,{children:"+"}),r.jsx(o.Text,{weight:"bold",color:"red",children:U(c,Kp)}),r.jsx(o.Text,{children:"×"}),r.jsx(o.Text,{children:i.name})]}),rSquared:d,adjustedRSquared:Hs(d,t.length,1)}}function xk(e,t,n,s){const{x_axis:i,y_axis:a}=s,{a:l,b:c,rSquared:u}=an.regressionExp()(n);return{name:e,expression:r.jsxs(o.Group,{position:"center",noWrap:!0,spacing:10,children:[r.jsx(o.Text,{children:a.name}),r.jsx(o.Text,{children:"="}),r.jsx(o.Text,{weight:"bold",color:"gray",children:l}),r.jsx(o.Text,{children:"×"}),r.jsxs(o.Group,{position:"left",noWrap:!0,spacing:2,children:[r.jsx(o.Text,{children:"Math.exp("}),r.jsx(o.Text,{weight:"bold",color:"gray",children:c}),r.jsx(o.Text,{children:"×"}),r.jsx(o.Text,{children:i.name}),r.jsx(o.Text,{children:")"})]})]}),rSquared:u,adjustedRSquared:Hs(u,t.length,1)}}function yk(e,t,n,s){const{x_axis:i,y_axis:a}=s,{a:l,b:c,rSquared:u}=an.regressionLog()(n);return{name:e,expression:r.jsxs(o.Group,{position:"center",noWrap:!0,spacing:10,children:[r.jsx(o.Text,{children:a.name}),r.jsx(o.Text,{children:"="}),r.jsx(o.Text,{weight:"bold",color:"gray",children:l}),r.jsx(o.Text,{children:"×"}),r.jsxs(o.Group,{position:"left",noWrap:!0,spacing:2,children:[r.jsx(o.Text,{children:"Math.log("}),r.jsx(o.Text,{children:i.name}),r.jsx(o.Text,{children:")"}),r.jsx(o.Text,{children:"+"}),r.jsx(o.Text,{weight:"bold",color:"gray",children:c})]})]}),rSquared:u,adjustedRSquared:Hs(u,t.length,1)}}function bk(e,t,n,s){const{x_axis:i,y_axis:a,regression:l}=s,c=an.regressionPoly().order(l.transform.config.order)(n),{rSquared:u}=c;return console.log(c),{name:e,expression:"",rSquared:u,adjustedRSquared:Hs(u,t.length,1)}}function Xp(e,t,n){const{regression:s,x_axis:i}=n,a=O(i.data_key),l=O(s.y_axis_data_key),c=t.map(u=>[u[a.columnKey],u[l.columnKey]]);return s.transform.config.method==="linear"?gk(e,t,c,n):s.transform.config.method==="exponential"?xk(e,t,c,n):s.transform.config.method==="logistic"?yk(e,t,c,n):s.transform.config.method==="polynomial"?bk(e,t,c,n):{name:e,expression:"",rSquared:0,adjustedRSquared:0}}function vk(e,t){if(!t)return[{name:"",expression:"",rSquared:0,adjustedRSquared:0}];if(!t.regression.group_by_key)return[Xp("",e,t)];const n=O(t.regression.group_by_key),s=v.groupBy(e,n.columnKey);return Object.entries(s).map(([i,a])=>Xp(i,a,t))}const _k={marginTop:"10px","tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function Jp({desc:e}){const{t}=_.useTranslation(),{expression:n,rSquared:s,adjustedRSquared:i}=e;return n?r.jsx(o.Table,{fontSize:14,sx:_k,children:r.jsxs("tbody",{children:[r.jsx("tr",{children:r.jsx("td",{colSpan:2,children:r.jsx(o.Text,{align:"center",children:n})})}),r.jsxs("tr",{children:[r.jsx("td",{children:t("viz.regression_chart.r_sq")}),r.jsx("td",{style:{textAlign:"right"},children:U(s,{output:"percent",mantissa:1,absolute:!1})})]}),r.jsxs("tr",{children:[r.jsx("td",{children:t("viz.regression_chart.r_sq_adjusted")}),r.jsx("td",{style:{textAlign:"right"},children:U(i,{output:"percent",mantissa:1,absolute:!1})})]})]})}):r.jsx(o.Text,{children:"Unavailable for this regression method"})}function jk({conf:e,queryData:t}){var s;const n=m.useMemo(()=>vk(t,e),[e,t]);return e.regression.group_by_key?(console.log(n),r.jsxs(o.Tabs,{defaultValue:(s=n[0])==null?void 0:s.name,color:"gray",children:[r.jsx(o.Tabs.List,{grow:!0,children:n.map(i=>r.jsx(o.Tabs.Tab,{value:i.name,children:i.name},i.name))}),n.map(i=>r.jsx(o.Tabs.Panel,{value:i.name,children:r.jsx(Jp,{desc:i})},i.name))]})):r.jsx(Jp,{desc:n[0]})}function wk({conf:e,queryData:t}){const{t:n}=_.useTranslation();return r.jsxs(o.HoverCard,{shadow:"md",withinPortal:!0,zIndex:320,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Button,{size:"xs",variant:"subtle",compact:!0,leftIcon:r.jsx(M.IconInfoCircle,{size:14}),children:n("viz.regression_chart.regression_info")})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(ze,{children:r.jsx(jk,{conf:e,queryData:t})})})]})}function Ck(e){return r.jsx(o.Group,{position:"apart",sx:{position:"absolute",top:0,left:Qe.left,right:Qe.right,height:"22px",zIndex:1},children:r.jsx(wk,{...e})})}const To={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,format:Me,overflow:Ke(),formatter:Oe()}},y_axis:{name:"Y Axis"},regression:{transform:{type:"ecStat:regression",config:{method:"linear",order:1,formulaOn:"end"}},plot:{type:"line",yAxisIndex:0,color:"#228be6",lineStyle:{type:"solid",width:1}},name:"regression",group_by_key:"",y_axis_data_key:"value"}};function Sk({context:e}){const{value:t}=$(e.instanceData,"config"),{width:n,height:s}=e.viewport,i=m.useMemo(()=>{var g;const u=e.data,d=t==null?void 0:t.x_axis.data_key,p=(g=t==null?void 0:t.regression)==null?void 0:g.y_axis_data_key;if(!d||!p)return[];const h=O(d),f=O(p);return u[h.queryID].map(y=>typeof y[f.columnKey]=="number"?y:{...y,[f.columnKey]:Number(y[f.columnKey])})},[e.data,t==null?void 0:t.regression.y_axis_data_key]),a=m.useMemo(()=>mk(v.defaultsDeep({},t,To),i),[t,i]),l=m.useRef(null),c=u=>{l.current=u};return!n||!s||!t?null:r.jsxs(Ue,{width:n,height:s,children:[r.jsx(Ck,{conf:t,queryData:i}),r.jsx(Pe,{echarts:Ae,onChartReady:c,option:a,style:gr(n,s),notMerge:!0,theme:"merico-light"})]})}function kk({control:e,watch:t}){const{t:n,i18n:s}=_.useTranslation();t("regression");const i=t("regression.transform.config.method"),a=t("regression.group_by_key"),l=m.useMemo(()=>[{label:n("chart.regression_line.method.linear"),value:"linear"},{label:n("chart.regression_line.method.exponential"),value:"exponential"},{label:n("chart.regression_line.method.logistic"),value:"logistic"},{label:n("chart.regression_line.method.polynomial"),value:"polynomial"}],[s.language]);return r.jsxs(o.Stack,{children:[r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"regression.name",control:e,render:({field:c})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...c})})}),r.jsx(b.Controller,{name:"regression.group_by_key",control:e,render:({field:c})=>r.jsx(F,{label:n("chart.series.group_by.label"),clearable:!0,sx:{flex:1},...c})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"regression.transform.config.method",control:e,render:({field:c})=>r.jsx(o.Select,{label:n("chart.regression_line.method.label"),data:l,sx:{flex:1},...c})}),i==="polynomial"&&r.jsx(b.Controller,{name:"regression.transform.config.order",control:e,render:({field:c})=>r.jsx(o.NumberInput,{label:n("chart.regression_line.method.polynomial_order"),sx:{flex:1},...c})})]}),!a&&r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:n("chart.color.label")}),r.jsx(b.Controller,{name:"regression.plot.color",control:e,render:({field:c})=>r.jsx(Le,{...c})})]})]})}function Tk({control:e,watch:t}){return t(["x_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.name",control:e,render:({field:n})=>r.jsx(o.TextInput,{label:"X轴名称",sx:{flex:1},...n})}),r.jsx(b.Controller,{name:"x_axis.data_key",control:e,render:({field:n})=>r.jsx(F,{label:"X轴数据字段",required:!0,sx:{flex:1},...n})})]}),r.jsx(o.Divider,{variant:"dashed",labelPosition:"center",label:"格式化数据"}),r.jsx(o.Stack,{children:r.jsx(b.Controller,{name:"x_axis.axisLabel.format",control:e,render:({field:n})=>r.jsx(ft,{...n})})}),r.jsx(o.Divider,{variant:"dashed",labelPosition:"center",label:"标签文案样式"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:n})=>r.jsx(o.NumberInput,{label:"旋转",hideControls:!0,min:-90,max:90,rightSection:r.jsx(o.Text,{color:"dimmed",children:"度"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>r.jsx(St,{triggerButtonText:"自定义标签文案内容",...n})})]}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:n})=>r.jsx(kt,{...n})})]})}function Dk({control:e,watch:t}){return t(["y_axis","regression.y_axis_data_key"]),r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"y_axis.name",control:e,render:({field:n})=>r.jsx(o.TextInput,{label:"Y轴名称",sx:{flex:1},...n})}),r.jsx(b.Controller,{name:"regression.y_axis_data_key",control:e,render:({field:n})=>r.jsx(F,{label:"Y轴数据字段",required:!0,sx:{flex:1},...n})})]})})}function Mk({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=m.useMemo(()=>v.defaults({},t,To),[t]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});m.useEffect(()=>{u(s)},[s]),l(["x_axis","y_axis","regression"]);const d=c(),p=m.useMemo(()=>!v.isEqual(d,t),[d,t]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(Ce,{canSubmit:p}),r.jsxs(o.Tabs,{defaultValue:"X轴",orientation:"vertical",styles:{panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X轴",children:"X轴"}),r.jsx(o.Tabs.Tab,{value:"Y轴",children:"Y轴"}),r.jsx(o.Tabs.Tab,{value:"回归",children:"回归"})]}),r.jsx(o.Tabs.Panel,{value:"X轴",children:r.jsx(Tk,{watch:l,control:i})}),r.jsx(o.Tabs.Panel,{value:"Y轴",children:r.jsx(Dk,{watch:l,control:i})}),r.jsx(o.Tabs.Panel,{value:"回归",children:r.jsx(kk,{control:i,watch:l})})]})]})})}function zk(e){const t={x_axis:{axisLabel:{rotate:0,format:Me,overflow:Ke(),formatter:Oe()}},regression:{group_by_key:""}};return v.defaultsDeep(t,e)}function Ik(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=c=>c&&`${n}.${c}`,{x_axis:i,regression:a,...l}=e;return{...l,x_axis:{...i,data_key:s(i.data_key)},regression:{...a,group_by_key:s(a.group_by_key),y_axis_data_key:s(a.y_axis_data_key)}}}catch(n){throw console.error("[Migration failed]",n),n}}const Ek=[{lang:"en",resources:{regression_chart:{viz_name:"Regression Chart",regression_info:"Regression Info",r_sq:"R-Sq",r_sq_adjusted:"R-Sq(Adjusted)"}}},{lang:"zh",resources:{regression_chart:{viz_name:"回归分析图",regression_info:"回归信息",r_sq:"R方",r_sq_adjusted:"R方(调整)"}}}];class Ak extends ge{constructor(){super(...arguments);B(this,"VERSION",3)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:zk(n.config)})),this.version(3,(n,s)=>{const{config:i}=n;return{...n,version:3,config:Ik(i,s)}})}}const Pk={displayName:"viz.regression_chart.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Ak,name:"regressionChart",viewRender:Sk,configRender:Mk,createConfig(){return{version:3,config:v.cloneDeep(To)}},translation:Ek},ei={content:""};function Ok(e,t){const n={};return e.forEach(s=>{const{name:i,data_field:a,aggregation:l}=s,c=is(t,a,l);n[i]=Re(s,c)}),n}function Lk(e){const t=document.createElement("span");return t.innerHTML=e,t.innerText}function Bk(e,t,n){try{return new Function("payload",`
256
258
  const filters = payload.filters;
257
259
  const context = payload.context;
258
- ${Object.entries(e).map(([r,i])=>`const ${r} = '${i}';`).join(`
260
+ ${Object.entries(t).map(([s,i])=>`const ${s} = '${i}';`).join(`
259
261
  `)}
260
- return ${t};
261
- `)(n)}catch(r){return console.error(r),console.log(t),t}}function Gv(t,e,n,r){const i=Ov(e,r),o=/^(.+)\}\}(.*)$/;return t.split("{{").map(l=>{const c=o.exec(l);if(!c)return l;const u=i[c[1]];if(u){const p=c[2]??"";return`${u}${p}`}const d=Vv(c[1]);return`${Nv(d,i,n)}${c[2]}`}).join("")}const Fv=S.observer(({context:t})=>{const e=he(),{value:n}=q(t.instanceData,"config"),{variables:r,data:i}=t,o=m.useMemo(()=>{const l=b.defaults({},n,ss);return l.content?Gv(l.content,r,e.payloadForViz,i):""},[n,r,e.payloadForViz]);return o?s.jsx(Xn,{value:o,styles:{root:{border:"none",height:"100%"},content:{padding:0}}}):null});function Wv(){const{editor:t}=R.useRichTextEditorContext();return s.jsx(R.RichTextEditor.Control,{onClick:()=>t==null?void 0:t.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}),"aria-label":"Insert table",title:"Insert table",children:s.jsx(k.IconBorderAll,{stroke:1.5,size:16})})}const Tr=m.forwardRef(({value:t,onChange:e,styles:n={},label:r,onSubmit:i},o)=>{const[l,c]=m.useState(t),u=oa.useEditor({extensions:[la,aa,R.Link,Hi,Zi,Ji,na.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),ia,ra,sa,ea.configure({types:["heading","paragraph"]}),Xi.configure({placeholder:"This is placeholder"}),ta,Ki.Color,Eo],content:l,onUpdate:({editor:g})=>{c(g.getHTML())}});m.useEffect(()=>{c(t),u==null||u.commands.setContent(t)},[t]);const d=()=>{e(l),i==null||i()},p=t!==l,h=m.useMemo(()=>b.defaultsDeep({},{content:sr},n),[n]);return u?s.jsxs(a.Stack,{spacing:4,sx:{flexGrow:1,position:"relative"},children:[s.jsxs(a.Group,{align:"center",children:[s.jsx(a.Text,{size:14,fw:500,children:r}),s.jsx(a.ActionIcon,{color:"green",disabled:!p,onClick:d,children:s.jsx(k.IconDeviceFloppy,{size:18})})]}),s.jsxs(R.RichTextEditor,{editor:u,styles:h,children:[s.jsxs(R.RichTextEditor.Toolbar,{sticky:!0,stickyOffset:0,children:[s.jsx(R.RichTextEditor.ControlsGroup,{children:s.jsx(R.RichTextEditor.ColorPicker,{colors:["#25262b","#868e96","#fa5252","#e64980","#be4bdb","#7950f2","#4c6ef5","#228be6","#15aabf","#12b886","#40c057","#82c91e","#fab005","#fd7e14"],popoverProps:{zIndex:320}})}),s.jsxs(R.RichTextEditor.ControlsGroup,{children:[s.jsx(R.RichTextEditor.Bold,{}),s.jsx(R.RichTextEditor.Italic,{}),s.jsx(R.RichTextEditor.Underline,{}),s.jsx(R.RichTextEditor.ClearFormatting,{}),s.jsx(R.RichTextEditor.Highlight,{}),s.jsx(R.RichTextEditor.Code,{})]}),s.jsxs(R.RichTextEditor.ControlsGroup,{children:[s.jsx(R.RichTextEditor.H1,{}),s.jsx(R.RichTextEditor.H2,{}),s.jsx(R.RichTextEditor.H3,{}),s.jsx(R.RichTextEditor.H4,{})]}),s.jsxs(R.RichTextEditor.ControlsGroup,{children:[s.jsx(R.RichTextEditor.Blockquote,{}),s.jsx(R.RichTextEditor.Hr,{}),s.jsx(R.RichTextEditor.BulletList,{}),s.jsx(R.RichTextEditor.OrderedList,{}),s.jsx(R.RichTextEditor.Subscript,{}),s.jsx(R.RichTextEditor.Superscript,{})]}),s.jsxs(R.RichTextEditor.ControlsGroup,{children:[s.jsx(R.RichTextEditor.Link,{}),s.jsx(R.RichTextEditor.Unlink,{})]}),s.jsxs(R.RichTextEditor.ControlsGroup,{children:[s.jsx(R.RichTextEditor.AlignLeft,{}),s.jsx(R.RichTextEditor.AlignCenter,{}),s.jsx(R.RichTextEditor.AlignJustify,{}),s.jsx(R.RichTextEditor.AlignRight,{})]}),s.jsx(R.RichTextEditor.ControlsGroup,{children:s.jsx(Wv,{})}),s.jsx(Jg,{editor:u})]}),s.jsx(R.RichTextEditor.Content,{})]})]}):null});function Qv({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),i=m.useMemo(()=>b.defaults({},n,ss),[n]),{control:o,handleSubmit:l,watch:c,reset:u}=y.useForm({defaultValues:i});c("content"),m.useEffect(()=>{u(i)},[i]);const d=m.useRef(null),p=()=>{var h;return(h=d.current)==null?void 0:h.click()};return s.jsx("form",{onSubmit:l(r),style:{flexGrow:1,display:"flex",flexDirection:"column"},children:s.jsxs(a.Stack,{spacing:"xs",sx:{flexGrow:1},children:[s.jsxs(a.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",display:"none"},children:[s.jsx(a.Text,{children:e("viz.rich_text.content.label")}),s.jsx(a.ActionIcon,{ref:d,type:"submit",mr:5,variant:"filled",color:"green",children:s.jsx(L.DeviceFloppy,{size:20})})]}),s.jsx(y.Controller,{name:"content",control:o,render:({field:h})=>s.jsx(Tr,{...h,styles:{root:{flexGrow:1}},label:e("viz.rich_text.content.label"),onSubmit:p})})]})})}const Rv=[{lang:"en",resources:{rich_text:{viz_name:"Rich Text",content:{label:"Content"}}}},{lang:"zh",resources:{rich_text:{viz_name:"富文本",content:{label:"内容"}}}}];class Uv extends ce{constructor(){super(...arguments);$(this,"VERSION",1)}fixMalformedConfig(n){return b.defaults({},n,ss)}configVersions(){this.version(1,n=>({version:1,config:this.fixMalformedConfig(n)}))}}const Yv={displayName:"viz.rich_text.viz_name",displayGroup:"chart.groups.others",migrator:new Uv,name:"richText",viewRender:Fv,configRender:Qv,createConfig(){return{version:1,config:b.cloneDeep(ss)}},translation:Rv},fn={static:{type:"static",color:dt.random().css()},dynamic:{type:"dynamic",func_content:["function getColor({ rowData, params, variables }, { lodash, interpolate }) {"," // your code goes here",' // return "blue"',"}"].join(`
262
- `)}},nl={id:"builtin:echarts:click-scatter-chart:series",displayName:"viz.scatter_chart.click_scatter.trigger",nameRender:Jv,configRender:Kv,payload:[{name:"seriesType",description:'"scatter"',valueType:"string"},{name:"componentType",description:'"series"',valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Kv(t){return s.jsx(s.Fragment,{})}function Jv(t){const{t:e}=_.useTranslation();return s.jsx(a.Text,{children:e("viz.scatter_chart.click_scatter.trigger")})}function sl(){const{on_axis:t,in_tooltip:e}=$e();return{label:t,tooltip:e}}const Dr={scatter:{y_data_key:"",name_data_key:"",symbolSize:{type:"static",size:10},color:fn.static,label_position:"right",label_overflow:sl()},stats:{templates:{top:"",bottom:""}},x_axis:{name:"",data_key:"",axisLabel:{rotate:0,formatter:ke(),overflow:$e()}},y_axes:[{name:"Y Axis",position:"left",nameAlignment:"center",label_formatter:_e,min:"",max:"",show:!0}],tooltip:{trigger:"item",metrics:[]},reference_lines:[],reference_areas:[],dataZoom:Mt};function Xv(t,e){if(!t.x_axis.data_key)return[];const n=A(t.x_axis.data_key);return[{source:e[n.queryID]}]}function Zv(t){const e=t.y_axes.some(i=>!!i.name);let n=15;e&&(n+=20),t.dataZoom.x_axis_slider&&(n+=20);let r=5;return t.x_axis.name&&(r+=15),{top:n,bottom:r}}function Hv(){return{show:!1,bottom:0,left:"center",type:"scroll"}}function rs(t,e){if(t)return e[t]??void 0}function e_({reference_areas:t,variableValueMap:e}){const n=t.map(r=>[{name:r.content.text,value:r.content.text,itemStyle:r.itemStyle,label:r.label,xAxis:rs(r.leftBottomPoint.x_data_key,e),yAxis:rs(r.leftBottomPoint.y_data_key,e)},{xAxis:rs(r.rightTopPoint.x_data_key,e),yAxis:rs(r.rightTopPoint.y_data_key,e)}]);return{type:"scatter",name:"ref_areas",silent:!0,data:[],markArea:{data:n}}}function t_({type:t,...e},n){if(!t)return 10;if(t==="static"){const{size:i}=e;return i}const{func_content:r}=e;return(i,o)=>{const l=o.data;try{return new Function(`return ${r}`)()({rowData:l,params:o,variables:n},{lodash:b,interpolate:Dt.interpolate})}catch(c){return console.error(`[getEchartsSymbolSize] failed parsing custom function, error: ${c.message}`),10}}}function n_({type:t,...e},n){if(!t)return fn.static.color;if(t==="static"){const{color:i}=e;return i}const{func_content:r}=e;return({value:i})=>{try{return new Function(`return ${r}`)()({rowData:i,variables:n},{lodash:b,interpolate:Dt.interpolate})}catch(o){return console.error(`[getSeriesColor] failed parsing custom function, error: ${o.message}`),10}}}function s_(t,e,n,r){return t.map(i=>{const o=i.orientation==="horizontal",l=o?"yAxis":"xAxis",c=o?"insideEndTop":"end";return{name:i.name,type:"line",hide_in_legend:!i.show_in_legend,yAxisIndex:i.yAxisIndex,data:[],lineStyle:i.lineStyle,markLine:{data:[{name:i.name,[l]:Number(n[i.variable_key])}],silent:!0,symbol:["none","none"],lineStyle:i.lineStyle,label:{formatter:function(){return i.template?cn(i.template,e,r):""},position:c}}}})}function r_({x_axis:t,scatter:e},n){const r=A(t.data_key),i=A(e.y_data_key),o=A(e.name_data_key);return{label:{show:!!e.label_position,position:e.label_position,...Qe(e.label_overflow.label),formatter:({value:l})=>l[o.columnKey]},type:"scatter",name:"",xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{color:n_(e.color,n)},symbolSize:t_(e.symbolSize,n),encode:{x:r.columnKey,y:i.columnKey}}}function i_(t,e,n,r){return[r_(t,r)].concat(s_(t.reference_lines,n,r,e)).concat(e_({reference_areas:t.reference_areas,variableValueMap:r}))}function rl(t,e,n){const{x_axis:r}=n;return r.axisLabel.formatter.enabled?Pe(r.axisLabel.formatter)(t,e):t}function a_(t,e){const{x_axis:n,tooltip:r}=e;if(r.trigger==="item"){const c=Dn(t[0].data,n.data_key);return rl(c,0,e)}const i=t.find(c=>c.axisDim==="x"&&c.axisId==="main-x-axis");if(!i)return"";const{axisValue:o,axisIndex:l}=i;return rl(o,l,e)}const o_=t=>U(t,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function l_(t,e){const{scatter:n,tooltip:r}=t;return te.getTooltip({trigger:r.trigger,formatter:function(i){const o=e[0]??e.default,l=Array.isArray(i)?i:[i];if(l.length===0)return"";const c=a_(l,t),u=We(t.scatter.label_overflow.tooltip),d=l.map(({value:v})=>`
262
+ return ${e};
263
+ `)(n)}catch(s){return console.error(s),console.log(e),e}}function qk(e,t,n,s){const i=Ok(t,s),a=/^(.+)\}\}(.*)$/;return e.split("{{").map(l=>{const c=a.exec(l);if(!c)return l;const u=i[c[1]];if(u){const p=c[2]??"";return`${u}${p}`}const d=Lk(c[1]);return`${Bk(d,i,n)}${c[2]}`}).join("")}const Vk=D.observer(({context:e})=>{const t=_e(),{panel:n}=Lt(),{value:s}=$(e.instanceData,"config"),{variables:i,data:a}=e,l=m.useMemo(()=>{const c=v.defaults({},s,ei);return c.content?qk(c.content,i,t.payloadForViz,a):""},[s,i,t.payloadForViz]);return l?r.jsx(Ys,{value:l,styles:{root:{border:"none",height:"100%"},content:{padding:0}},dashboardState:t.dashboardState,varaiables:n.variableValueMap}):null}),Nk={"dynamic-color":{position:"relative"},"dynamic-color:after":{content:'""',position:"absolute",bottom:"-2px",left:0,width:"100%",height:"1px",border:"double 1px purple"}};function $k(){const{editor:e}=Q.useRichTextEditorContext();return r.jsx(Q.RichTextEditor.Control,{onClick:()=>e==null?void 0:e.commands.insertTable({rows:3,cols:3,withHeaderRow:!0}),"aria-label":"Insert table",title:"Insert table",children:r.jsx(M.IconBorderAll,{stroke:1.5,size:16})})}const Do=m.forwardRef(({value:e,onChange:t,styles:n={},label:s,onSubmit:i},a)=>{const[l,c]=m.useState(e),u=cc.useEditor({extensions:[uc,lc,Q.Link,tc,ec,Zl,sc.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),oc,ac,ic,nc.configure({types:["heading","paragraph"]}),Hl.configure({placeholder:"This is placeholder"}),rc,Jl.Color,kp,Mp],content:l,onUpdate:({editor:f})=>{const g=f.getHTML();c(g)}});m.useEffect(()=>{c(e),u==null||u.commands.setContent(e)},[e]);const d=()=>{t(l),i==null||i()},p=e!==l,h=m.useMemo(()=>v.defaultsDeep({},{content:{...eo,...Nk}},n),[n]);return u?r.jsxs(o.Stack,{spacing:4,sx:{flexGrow:1,position:"relative"},children:[r.jsxs(o.Group,{align:"center",children:[r.jsx(o.Text,{size:14,fw:500,children:s}),r.jsx(o.ActionIcon,{color:"green",disabled:!p,onClick:d,children:r.jsx(M.IconDeviceFloppy,{size:18})})]}),r.jsxs(Q.RichTextEditor,{editor:u,styles:h,children:[r.jsxs(Q.RichTextEditor.Toolbar,{sticky:!0,stickyOffset:0,children:[r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.ColorPicker,{colors:["#25262b","#868e96","#fa5252","#e64980","#be4bdb","#7950f2","#4c6ef5","#228be6","#15aabf","#12b886","#40c057","#82c91e","#fab005","#fd7e14"],popoverProps:{zIndex:320}}),r.jsx(Qw,{editor:u})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Bold,{}),r.jsx(Q.RichTextEditor.Italic,{}),r.jsx(Q.RichTextEditor.Underline,{}),r.jsx(Q.RichTextEditor.ClearFormatting,{}),r.jsx(Q.RichTextEditor.Highlight,{}),r.jsx(Q.RichTextEditor.Code,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.H1,{}),r.jsx(Q.RichTextEditor.H2,{}),r.jsx(Q.RichTextEditor.H3,{}),r.jsx(Q.RichTextEditor.H4,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Blockquote,{}),r.jsx(Q.RichTextEditor.Hr,{}),r.jsx(Q.RichTextEditor.BulletList,{}),r.jsx(Q.RichTextEditor.OrderedList,{}),r.jsx(Q.RichTextEditor.Subscript,{}),r.jsx(Q.RichTextEditor.Superscript,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.Link,{}),r.jsx(Q.RichTextEditor.Unlink,{})]}),r.jsxs(Q.RichTextEditor.ControlsGroup,{children:[r.jsx(Q.RichTextEditor.AlignLeft,{}),r.jsx(Q.RichTextEditor.AlignCenter,{}),r.jsx(Q.RichTextEditor.AlignJustify,{}),r.jsx(Q.RichTextEditor.AlignRight,{})]}),r.jsx(Q.RichTextEditor.ControlsGroup,{children:r.jsx($k,{})}),r.jsx(Vw,{editor:u})]}),r.jsx(Q.RichTextEditor.Content,{})]})]}):null});function Fk({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=m.useMemo(()=>v.defaults({},n,ei),[n]),{control:a,handleSubmit:l,watch:c,reset:u}=b.useForm({defaultValues:i});c("content"),m.useEffect(()=>{u(i)},[i]);const d=m.useRef(null),p=()=>{var h;return(h=d.current)==null?void 0:h.click()};return r.jsx("form",{onSubmit:l(s),style:{flexGrow:1,display:"flex",flexDirection:"column"},children:r.jsxs(o.Stack,{spacing:"xs",sx:{flexGrow:1},children:[r.jsxs(o.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",display:"none"},children:[r.jsx(o.Text,{children:t("viz.rich_text.content.label")}),r.jsx(o.ActionIcon,{ref:d,type:"submit",mr:5,variant:"filled",color:"green",children:r.jsx(V.DeviceFloppy,{size:20})})]}),r.jsx(b.Controller,{name:"content",control:a,render:({field:h})=>r.jsx(Do,{...h,styles:{root:{flexGrow:1}},label:t("viz.rich_text.content.label"),onSubmit:p})})]})})}const Gk=[{lang:"en",resources:{rich_text:{viz_name:"Rich Text",content:{label:"Content"}}}},{lang:"zh",resources:{rich_text:{viz_name:"富文本",content:{label:"内容"}}}}];class Wk extends ge{constructor(){super(...arguments);B(this,"VERSION",1)}fixMalformedConfig(n){return v.defaults({},n,ei)}configVersions(){this.version(1,n=>({version:1,config:this.fixMalformedConfig(n)}))}}const Rk={displayName:"viz.rich_text.viz_name",displayGroup:"chart.groups.others",migrator:new Wk,name:"richText",viewRender:Vk,configRender:Fk,createConfig(){return{version:1,config:v.cloneDeep(ei)}},translation:Gk},Wr={static:{type:"static",color:Qt.random().css()},dynamic:{type:"dynamic",func_content:["function getColor({ rowData, params, variables }, { lodash, interpolate }) {"," // your code goes here",' // return "blue"',"}"].join(`
264
+ `)}},Zp={id:"builtin:echarts:click-scatter-chart:series",displayName:"viz.scatter_chart.click_scatter.trigger",nameRender:Uk,configRender:Qk,payload:[{name:"seriesType",description:'"scatter"',valueType:"string"},{name:"componentType",description:'"series"',valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Qk(e){return r.jsx(r.Fragment,{})}function Uk(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.scatter_chart.click_scatter.trigger")})}function Hp(){const{on_axis:e,in_tooltip:t}=Ke();return{label:e,tooltip:t}}const Mo={scatter:{y_data_key:"",name_data_key:"",symbolSize:{type:"static",size:10},color:Wr.static,label_position:"right",label_overflow:Hp()},stats:{templates:{top:"",bottom:""}},x_axis:{name:"",data_key:"",axisLabel:{rotate:0,formatter:Oe(),overflow:Ke()}},y_axes:[{name:"Y Axis",position:"left",nameAlignment:"center",label_formatter:Me,min:"",max:"",show:!0}],tooltip:{trigger:"item",metrics:[]},reference_lines:[],reference_areas:[],dataZoom:jn};function Yk(e,t){if(!e.x_axis.data_key)return[];const n=O(e.x_axis.data_key);return[{source:t[n.queryID]}]}function Kk(e){const t=e.y_axes.some(i=>!!i.name);let n=15;t&&(n+=20),e.dataZoom.x_axis_slider&&(n+=20);let s=5;return e.x_axis.name&&(s+=15),{top:n,bottom:s}}function Xk(){return{show:!1,bottom:0,left:"center",type:"scroll"}}function ti(e,t){if(e)return t[e]??void 0}function Jk({reference_areas:e,variableValueMap:t}){const n=e.map(s=>[{name:s.content.text,value:s.content.text,itemStyle:s.itemStyle,label:s.label,xAxis:ti(s.leftBottomPoint.x_data_key,t),yAxis:ti(s.leftBottomPoint.y_data_key,t)},{xAxis:ti(s.rightTopPoint.x_data_key,t),yAxis:ti(s.rightTopPoint.y_data_key,t)}]);return{type:"scatter",name:"ref_areas",silent:!0,data:[],markArea:{data:n}}}function Zk({type:e,...t},n){if(!e)return 10;if(e==="static"){const{size:i}=t;return i}const{func_content:s}=t;return(i,a)=>{const l=a.data;try{return new Function(`return ${s}`)()({rowData:l,params:a,variables:n},{lodash:v,interpolate:vn.interpolate})}catch(c){return console.error(`[getEchartsSymbolSize] failed parsing custom function, error: ${c.message}`),10}}}function Hk({type:e,...t},n){if(!e)return Wr.static.color;if(e==="static"){const{color:i}=t;return i}const{func_content:s}=t;return({value:i})=>{try{return new Function(`return ${s}`)()({rowData:i,variables:n},{lodash:v,interpolate:vn.interpolate})}catch(a){return console.error(`[getSeriesColor] failed parsing custom function, error: ${a.message}`),10}}}function eT(e,t,n,s){return e.map(i=>{const a=i.orientation==="horizontal",l=a?"yAxis":"xAxis",c=a?"insideEndTop":"end";return{name:i.name,type:"line",hide_in_legend:!i.show_in_legend,yAxisIndex:i.yAxisIndex,data:[],lineStyle:i.lineStyle,markLine:{data:[{name:i.name,[l]:Number(n[i.variable_key])}],silent:!0,symbol:["none","none"],lineStyle:i.lineStyle,label:{formatter:function(){return i.template?mr(i.template,t,s):""},position:c}}}})}function tT({x_axis:e,scatter:t},n){const s=O(e.data_key),i=O(t.y_data_key),a=O(t.name_data_key);return{label:{show:!!t.label_position,position:t.label_position,...ut(t.label_overflow.label),formatter:({value:l})=>l[a.columnKey]},type:"scatter",name:"",xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{color:Hk(t.color,n)},symbolSize:Zk(t.symbolSize,n),encode:{x:s.columnKey,y:i.columnKey}}}function nT(e,t,n,s){return[tT(e,s)].concat(eT(e.reference_lines,n,s,t)).concat(Jk({reference_areas:e.reference_areas,variableValueMap:s}))}function eh(e,t,n){const{x_axis:s}=n;return s.axisLabel.formatter.enabled?Ye(s.axisLabel.formatter)(e,t):e}function rT(e,t){const{x_axis:n,tooltip:s}=t;if(s.trigger==="item"){const c=ss(e[0].data,n.data_key);return eh(c,0,t)}const i=e.find(c=>c.axisDim==="x"&&c.axisId==="main-x-axis");if(!i)return"";const{axisValue:a,axisIndex:l}=i;return eh(a,l,t)}const sT=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function iT(e,t){const{scatter:n,tooltip:s}=e;return te.getTooltip({trigger:s.trigger,formatter:function(i){const a=t[0]??t.default,l=Array.isArray(i)?i:[i];if(l.length===0)return"";const c=rT(l,e),u=ct(e.scatter.label_overflow.tooltip),d=l.map(({value:y})=>`
263
265
  <th style="text-align: right; padding-right: 1em">
264
- <div style="${u}">${Dn(v,n.name_data_key)}</div>
266
+ <div style="${u}">${ss(y,n.name_data_key)}</div>
265
267
  </th>
266
- `);d.unshift("<th></th>");const p=We(t.x_axis.axisLabel.overflow.in_tooltip),h=[`<tr>
267
- <th style="text-align: right;">${t.x_axis.name}</th>
268
- ${l.map(v=>`<td style="text-align: right; padding: 0 1em;"><div style="${p}">${c}</div></td>`).join("")}
268
+ `);d.unshift("<th></th>");const p=ct(e.x_axis.axisLabel.overflow.in_tooltip),h=[`<tr>
269
+ <th style="text-align: right;">${e.x_axis.name}</th>
270
+ ${l.map(y=>`<td style="text-align: right; padding: 0 1em;"><div style="${p}">${c}</div></td>`).join("")}
269
271
  </tr>`,`<tr>
270
- <th style="text-align: right;">${t.y_axes[0].name}</th>
271
- ${l.map(({value:v})=>`
272
+ <th style="text-align: right;">${e.y_axes[0].name}</th>
273
+ ${l.map(({value:y})=>`
272
274
  <td style="text-align: right; padding: 0 1em;">
273
- ${o(Dn(v,n.y_data_key))}
275
+ ${a(ss(y,n.y_data_key))}
274
276
  </td>`).join("")}
275
- </tr>`],g=t.tooltip.metrics.map(v=>`<tr>
276
- <th style="text-align: right;">${v.name}</th>
277
- ${l.map(({value:w})=>`<td style="text-align: right; padding: 0 1em;">${o_(Dn(w,v.data_key))}</td>`).join("")}
278
- </tr>`);return h.push(...g),`
277
+ </tr>`],f=e.tooltip.metrics.map(y=>`<tr>
278
+ <th style="text-align: right;">${y.name}</th>
279
+ ${l.map(({value:j})=>`<td style="text-align: right; padding: 0 1em;">${sT(ss(j,y.data_key))}</td>`).join("")}
280
+ </tr>`);return h.push(...f),`
279
281
  <table style="width: auto">
280
282
  <thead><tr>${d.join("")}</tr></thead>
281
283
  <tbody>${h.join("")}</tbody>
282
284
  </table>
283
- `}})}function c_(t,e){const n=e.every(c=>!Number.isNaN(Number(c))),{overflow:r,...i}=t.x_axis.axisLabel,o=Qe(r.on_axis),l=e.length===0;return[te.getXAxis({data:e,name:t.x_axis.name??"",nameGap:l?5:void 0,id:"main-x-axis",type:n?"value":"category",axisLabel:{...i,...o,formatter:Pe(i.formatter)}})]}function u_(t,e){return t.y_axes.map(({nameAlignment:n,min:r,max:i,...o},l)=>{let c=o.position;return c||(c=l>0?"right":"left"),te.getYAxis({...o,minInterval:1,min:r||void 0,max:i||void 0,position:c,axisLine:{show:!0},axisLabel:{show:!0,formatter:e[l]??e.default},nameTextStyle:{align:n},nameLocation:"end",nameGap:15,splitLine:{show:!1}})})}const d_={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 p_(t,e,n){const r=n.reduce((u,d)=>{const p=Ze(d,e);return u[d.name]=Ie(d,p),u},{}),i=t.y_axes.reduce((u,{label_formatter:d},p)=>(u[p]=function(g){let f=g;if(typeof g=="object"&&(Array.isArray(g.value)&&g.value.length===2?f=g.value[1]:f=g.value),!d)return f;try{return U(f,d)}catch(v){return console.error(v),f}},u),{default:({value:u})=>u}),o=b.uniq(Xe(e,t.x_axis.data_key)),l=i_(t,e,n,r),c={xAxis:c_(t,o),yAxis:u_(t,i),series:l,dataset:Xv(t,e),tooltip:l_(t,i),grid:Zv(t),legend:Hv(),dataZoom:$n(t.dataZoom)};return b.defaultsDeep({},c,d_)}function il(t){return t.trim().length>0}function h_({conf:t,data:e,width:n,height:r,interactionManager:i,variables:o}){const l=It(e,t.x_axis.data_key),c=qe(i.triggerManager,nl.id),u=m.useCallback(h=>{const g=h.data;c.forEach(f=>{i.runInteraction(f.id,{...h,rowData:g})})},[l,c,i]),d=m.useMemo(()=>({click:u}),[u]),p=m.useMemo(()=>p_(t,e,o),[t,e]);return s.jsx(Se,{echarts:Ce,option:p,style:{width:n,height:r},onEvents:d,notMerge:!0,theme:"merico-light"})}function m_({context:t,instance:e}){const n=Oe({vizManager:t.vizManager,instance:e}),{value:r}=q(t.instanceData,"config"),{variables:i}=t,o=m.useMemo(()=>b.defaults({},r,Dr),[r]),l=t.data,{width:c,height:u}=t.viewport,{ref:d,height:p}=ie.useElementSize(),{ref:h,height:g}=ie.useElementSize(),f=m.useMemo(()=>{const{stats:{templates:w}}=o;return{top:ln(w.top,i,l),bottom:ln(w.bottom,i,l)}},[o,l]),v=Math.max(0,et(u)-p-g);return!c||!u?null:s.jsxs(Ae,{width:c,height:u,children:[s.jsx(a.Text,{ref:d,align:"left",size:"xs",pl:"sm",sx:{display:il(o.stats.templates.top)?"block":"none"},children:Object.values(f.top).map(w=>w)}),s.jsx(h_,{variables:i,width:He(c),height:v,data:l,conf:o,interactionManager:n}),s.jsx(a.Text,{ref:h,align:"left",size:"xs",pl:"sm",sx:{display:il(o.stats.templates.bottom)?"block":"none"},children:Object.values(f.bottom).map(w=>w)})]})}const x_=m.forwardRef(({value:t,onChange:e,xAxisOptions:n,yAxisOptions:r,variableOptions:i},o)=>{const{t:l,i18n:c}=_.useTranslation(),u=(d,p)=>{const h=b.cloneDeep(t);b.set(h,d,p),e(h)};return s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mb:-15,variant:"dashed",label:l("chart.reference_area.content.label"),labelPosition:"right"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(a.TextInput,{label:l("chart.reference_area.content.content_text"),value:t.content.text,onChange:d=>u("content.text",d.currentTarget.value)}),s.jsx(Kt,{label:l("chart.reference_area.content.text_position"),value:t.label.position,onChange:d=>u("label.position",d)})]}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:l("chart.reference_area.endpoint.labels"),labelPosition:"right"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[n&&s.jsx(a.Select,{label:l("chart.x_axis.label"),data:n,value:t.xAxisIndex,onChange:d=>u("xAxisIndex",d)}),r&&s.jsx(a.Select,{label:l("chart.y_axis.label"),data:r,value:t.yAxisIndex,onChange:d=>u("xAxisIndex",d)})]}),s.jsxs(a.Stack,{spacing:0,children:[s.jsx(a.Text,{size:14,color:"#212529",fw:500,children:l("chart.reference_area.endpoint.left_bottom_point")}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(a.Select,{icon:s.jsx(a.Text,{children:"x"}),data:i,value:t.leftBottomPoint.x_data_key,onChange:d=>u("leftBottomPoint.x_data_key",d??""),clearable:!0}),s.jsx(a.Select,{icon:s.jsx(a.Text,{children:"y"}),data:i,value:t.leftBottomPoint.y_data_key,onChange:d=>u("leftBottomPoint.y_data_key",d??""),clearable:!0})]})]}),s.jsxs(a.Stack,{spacing:0,children:[s.jsx(a.Text,{size:14,color:"#212529",fw:500,children:l("chart.reference_area.endpoint.right_top_point")}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(a.Select,{icon:s.jsx(a.Text,{children:"x"}),data:i,value:t.rightTopPoint.x_data_key,onChange:d=>u("rightTopPoint.x_data_key",d??""),clearable:!0}),s.jsx(a.Select,{icon:s.jsx(a.Text,{children:"y"}),data:i,value:t.rightTopPoint.y_data_key,onChange:d=>u("rightTopPoint.y_data_key",d??""),clearable:!0})]})]}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:l("chart.style.label"),labelPosition:"right"}),s.jsxs(a.Stack,{spacing:4,children:[s.jsx(a.Text,{size:14,children:l("chart.color.background_color")}),s.jsx(Te,{value:t.itemStyle.color,onChange:d=>u("itemStyle.color",d)})]}),s.jsxs(a.Stack,{spacing:4,children:[s.jsx(a.Text,{size:14,children:l("chart.color.text_color")}),s.jsx(Te,{value:t.label.color,onChange:d=>u("label.color",d)})]})]})});function g_(){const t=new Date().getTime().toString();return{id:t,content:{text:t},itemStyle:{color:"rgba(0,0,0,0.05)"},label:{position:"inside",color:"rgba(0,0,0,0.5)"},leftBottomPoint:{x_data_key:"",y_data_key:""},rightTopPoint:{x_data_key:"",y_data_key:""},xAxisIndex:"0",yAxisIndex:"0"}}function f_({control:t,watch:e,variables:n}){const{t:r}=_.useTranslation(),i=()=>g_(),o=m.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=e("y_axes"),c=m.useMemo(()=>l.map(({name:d},p)=>({label:d,value:p.toString()})),[l]),u=(d,p)=>p+1;return s.jsx(ae,{control:t,watch:e,name:"reference_areas",getItem:i,addButtonText:r("chart.reference_area.add"),deleteButtonText:r("chart.reference_area.delete"),renderTabName:u,children:({field:d,index:p})=>s.jsx(y.Controller,{name:`reference_areas.${p}`,control:t,render:({field:h})=>s.jsx(a.Stack,{children:s.jsx(x_,{variableOptions:o,yAxisOptions:c,...h})})})})}function y_({control:t,index:e,watch:n,variableOptions:r,yAxisOptions:i}){const{t:o}=_.useTranslation(),l=n(`reference_lines.${e}.orientation`);return s.jsxs(a.Stack,{my:0,p:0,sx:{position:"relative"},children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`reference_lines.${e}.name`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:o("common.name"),placeholder:o("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),s.jsx(y.Controller,{name:`reference_lines.${e}.variable_key`,control:t,render:({field:c})=>s.jsx(a.Select,{label:o("common.data_field"),required:!0,data:r,sx:{flex:1},...c})})]}),s.jsx(y.Controller,{name:`reference_lines.${e}.template`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:o("chart.content_template.label"),placeholder:o("chart.content_template.hint"),sx:{flex:1},...c})}),s.jsxs(a.Group,{grow:!0,children:[s.jsxs(a.Stack,{children:[s.jsx(y.Controller,{name:`reference_lines.${e}.orientation`,control:t,render:({field:c})=>s.jsx(Ct,{sx:{flex:1},...c})}),l==="vertical"&&s.jsx(a.Text,{mt:-10,color:"dimmed",size:12,children:o("chart.reference_line.orientation.vertical_hint")})]}),l==="horizontal"&&s.jsx(y.Controller,{name:`reference_lines.${e}.yAxisIndex`,control:t,render:({field:{value:c,onChange:u,...d}})=>s.jsx(a.Select,{label:"Y Axis",data:i,disabled:i.length===0,...d,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){u(0);return}u(Number(p))},sx:{flex:1}})})]}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.style.label"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:`reference_lines.${e}.lineStyle.type`,control:t,render:({field:c})=>s.jsx(Qt,{sx:{flexGrow:1},...c})}),s.jsx(y.Controller,{name:`reference_lines.${e}.lineStyle.width`,control:t,render:({field:c})=>s.jsx(a.NumberInput,{label:o("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),s.jsxs(a.Stack,{spacing:4,children:[s.jsx(a.Text,{size:"sm",children:o("chart.color.label")}),s.jsx(y.Controller,{name:`reference_lines.${e}.lineStyle.color`,control:t,render:({field:c})=>s.jsx(Te,{...c})})]})]})}function b_({control:t,watch:e,variables:n}){const{t:r}=_.useTranslation(),i=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:dt.random().css()},show_in_legend:!1,yAxisIndex:0}),o=m.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=e("y_axes"),c=m.useMemo(()=>l.map(({name:d},p)=>({label:d,value:p.toString()})),[l]),u=(d,p)=>{const h=d.name.trim();return h||p+1};return s.jsx(ae,{control:t,watch:e,name:"reference_lines",getItem:i,addButtonText:r("chart.reference_line.add"),deleteButtonText:r("chart.reference_line.delete"),renderTabName:u,children:({field:d,index:p})=>s.jsx(y_,{control:t,index:p,watch:e,variableOptions:o,yAxisOptions:c})})}const v_=({value:t,onChange:e})=>{const n=r=>{r&&e(r)};return s.jsx(a.Box,{children:s.jsx(Le,{height:"500px",defaultLanguage:"javascript",value:t,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},__=({value:t,onChange:e})=>{const{t:n}=_.useTranslation(),[r,{setTrue:i,setFalse:o}]=W.useBoolean(),[l,c]=m.useState(t),u=()=>{o();const{type:g,func_content:f}=l,v={type:g,func_content:f};c(v),e(v)},d=()=>{o(),c(t)},p=g=>{c(f=>({...f,func_content:g}))},h=()=>{p(fn.dynamic.func_content)};return s.jsxs(s.Fragment,{children:[s.jsx(a.Box,{sx:{width:"50%"},children:s.jsx(a.Button,{color:"grape",variant:"filled",leftIcon:s.jsx(k.IconMathFunction,{size:16}),mt:24,onClick:i,sx:{flexGrow:0},children:n("viz.scatter_chart.color.dynamic.setup")})}),s.jsx(a.Modal,{size:800,title:n("viz.scatter_chart.color.dynamic.setup_title"),opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&s.jsxs(a.Stack,{children:[s.jsx(v_,{value:l.func_content,onChange:p}),s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Button,{onClick:h,color:"red",leftIcon:s.jsx(L.Recycle,{size:20}),children:n("common.actions.reset_to_default")}),s.jsxs(a.Group,{position:"right",children:[s.jsx(a.Button,{onClick:d,variant:"subtle",children:n("common.actions.cancel")}),s.jsx(a.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),onClick:u,children:n("common.actions.save")})]})]})]})})]})},j_=({value:t,onChange:e})=>t.type!=="dynamic"?null:s.jsx(__,{value:t,onChange:e}),w_=({value:t,onChange:e})=>{if(t.type!=="static")return null;const n=r=>{e({...t,color:r})};return s.jsx(a.ColorInput,{label:" ",format:"rgb",value:t.color,onChange:n})},C_=m.forwardRef(({label:t="Color",value:e,onChange:n},r)=>{const{t:i,i18n:o}=_.useTranslation(),l=m.useMemo(()=>[{label:i("viz.scatter_chart.color.type.static"),value:"static"},{label:i("viz.scatter_chart.color.type.dynamic"),value:"dynamic"}],[o.language]),c=u=>{n({...fn[u]})};return s.jsxs(a.SimpleGrid,{cols:2,children:[s.jsx(a.Select,{ref:r,label:t,data:l,value:e.type,onChange:c,sx:{flexGrow:1}}),s.jsx(w_,{value:e,onChange:n}),s.jsx(j_,{value:e,onChange:n})]})}),S_=m.forwardRef(({value:t,onChange:e},n)=>{const{t:r}=_.useTranslation(),i=l=>{e({...t,label:l})},o=l=>{e({...t,tooltip:l})};return s.jsxs(a.Stack,{ref:n,spacing:0,children:[s.jsx(An,{sectionTitle:r("chart.axis.overflow.section_title.on_axis"),value:t.label,onChange:i}),s.jsx(An,{sectionTitle:r("chart.axis.overflow.section_title.in_tooltip"),value:t.tooltip,onChange:o})]})});function k_({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["scatter"]),s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"scatter.name_data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.name_data_field"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"scatter.y_data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.value_data_field"),required:!0,sx:{flex:1},...r})})]}),s.jsx(a.Divider,{mb:-15,label:n("chart.style.label"),labelPosition:"center"}),s.jsx(y.Controller,{name:"scatter.symbolSize",control:t,render:({field:r})=>s.jsx(nr,{...r})}),s.jsx(y.Controller,{name:"scatter.color",control:t,render:({field:r})=>s.jsx(C_,{...r})}),s.jsx(a.Divider,{mb:-15,label:n("chart.label.label"),labelPosition:"center"}),s.jsx(a.Group,{grow:!0,noWrap:!0,children:s.jsx(y.Controller,{name:"scatter.label_position",control:t,render:({field:r})=>s.jsx(Kt,{label:n("chart.label_position.label"),withOffOption:!0,...r,onChange:i=>{i&&r.onChange(i)}})})}),s.jsx(y.Controller,{name:"scatter.label_overflow",control:t,render:({field:r})=>s.jsx(S_,{...r})})]})}function T_({control:t,watch:e}){const{t:n}=_.useTranslation();return e("stats"),s.jsx(a.Stack,{children:s.jsxs(a.Stack,{spacing:0,children:[s.jsx(y.Controller,{name:"stats.templates.top",control:t,render:({field:r})=>s.jsx(on,{label:n("chart.stats.template.above_chart"),py:"md",sx:{flexGrow:1},...r})}),s.jsx(y.Controller,{name:"stats.templates.bottom",control:t,render:({field:r})=>s.jsx(on,{label:n("chart.stats.template.under_chart"),py:"md",sx:{flexGrow:1},...r})})]})})}const D_=({control:t,index:e})=>{const{t:n}=_.useTranslation();return s.jsx(a.Stack,{children:s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`tooltip.metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:`tooltip.metrics.${e}.data_key`,control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),required:!0,sx:{flex:1},...r})})]})})},z_=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(o,l)=>{const c=o.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(a.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),s.jsx(ae,{control:t,watch:e,name:"tooltip.metrics",getItem:r,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:o,index:l})=>s.jsx(D_,{control:t,index:l})})]})};function M_({control:t,watch:e}){const{t:n,i18n:r}=_.useTranslation();e("tooltip.trigger");const i=m.useMemo(()=>[{label:n("chart.tooltip.trigger.scatter_point"),value:"item"},{label:n("chart.tooltip.trigger.x_axis"),value:"axis"}],[r.language]);return s.jsxs(a.Stack,{children:[s.jsx(y.Controller,{name:"tooltip.trigger",control:t,render:({field:o})=>s.jsx(a.Select,{label:n("chart.tooltip.trigger.label"),data:i,sx:{flexGrow:1},...o})}),s.jsx(a.Divider,{variant:"dashed"}),s.jsx(z_,{control:t,watch:e})]})}function I_({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["x_axis"]),s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"x_axis.name",control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),sx:{flex:1},...r})})]}),s.jsx(a.Divider,{mb:-15,label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:r})=>s.jsx(xt,{sx:{width:"48%"},...r})}),s.jsx(y.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:r})=>s.jsx(tt,{...r})})]}),s.jsx(y.Controller,{name:"x_axis.axisLabel.overflow",control:t,render:({field:r})=>s.jsx(nt,{...r})})]})}function E_({control:t,index:e}){const{t:n}=_.useTranslation();return s.jsxs(a.Stack,{my:0,p:"0",sx:{position:"relative"},children:[s.jsx(a.Divider,{mb:-15,mt:15,variant:"dashed",label:n("chart.y_axis.y_axis_name"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`y_axes.${e}.name`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:`y_axes.${e}.nameAlignment`,control:t,render:({field:r})=>s.jsx(Tt,{sx:{flex:1},...r})})]}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.layout"),labelPosition:"center"}),s.jsx(a.Group,{grow:!0,noWrap:!0,children:s.jsx(y.Controller,{name:`y_axes.${e}.position`,control:t,render:({field:r})=>s.jsx($o,{sx:{flex:1},...r})})}),s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.label_format"),labelPosition:"center"}),s.jsx(y.Controller,{name:`y_axes.${e}.label_formatter`,control:t,render:({field:r})=>s.jsx(Re,{...r})})]}),s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.value_range"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:`y_axes.${e}.min`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("chart.y_axis.value_min"),...r})}),s.jsx(y.Controller,{name:`y_axes.${e}.max`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("chart.y_axis.value_max"),...r})})]})]})]})}function A_({control:t,watch:e}){const{t:n}=_.useTranslation(),r=()=>({name:"",label_formatter:_e,min:"",max:"",show:!0,position:"right",nameAlignment:"right"}),i=(l,c)=>{const u=l.name.trim();return u||c+1},o=({field:l,index:c,fields:u})=>u.length<=1;return s.jsx(ae,{control:t,watch:e,name:"y_axes",getItem:r,addButtonText:n("chart.y_axis.add"),deleteButtonText:n("chart.y_axis.delete"),renderTabName:i,deleteDisalbed:o,children:({field:l,index:c})=>s.jsx(E_,{control:t,index:c})})}function P_(t){return t||{templates:{top:"",bottom:""}}}function $_({reference_lines:t=[],stats:e,...n}){return{reference_lines:t,stats:P_(e),...n}}function B_({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),{variables:i}=t,o=m.useMemo(()=>b.defaultsDeep({},n,Dr),[n]),l=m.useMemo(()=>$_(o),[o]);m.useEffect(()=>{!b.isEqual(o,l)&&(console.log("config malformed, resetting to defaults",o,l),r(l))},[o,l]);const{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=y.useForm({defaultValues:l});m.useEffect(()=>{h(l)},[l]);const g=p(),f=m.useMemo(()=>!b.isEqual(g,o),[g,o]);return d(["dataZoom"]),s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:u(r),children:[s.jsx(ge,{canSubmit:f}),s.jsxs(a.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"X Axis",children:e("chart.x_axis.label")}),s.jsx(a.Tabs.Tab,{value:"Y Axes",children:e("chart.y_axis.labels")}),s.jsx(a.Tabs.Tab,{value:"Scatter",children:e("chart.series.scatter.label")}),s.jsx(a.Tabs.Tab,{value:"Tooltip",children:e("chart.tooltip.label")}),s.jsx(a.Tabs.Tab,{value:"Stats",children:e("chart.stats.label")}),s.jsx(a.Tabs.Tab,{value:"Reference Lines",children:e("chart.reference_line.labels")}),s.jsx(a.Tabs.Tab,{value:"Reference Areas",children:e("chart.reference_area.labels")}),s.jsx(a.Tabs.Tab,{value:"Zooming",children:e("chart.zooming.label")})]}),s.jsx(a.Tabs.Panel,{value:"X Axis",children:s.jsx(I_,{control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Y Axes",children:s.jsx(A_,{control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Scatter",children:s.jsx(k_,{control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Tooltip",children:s.jsx(M_,{control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Stats",children:s.jsx(T_,{control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Reference Lines",children:s.jsx(b_,{variables:i,control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Reference Areas",children:s.jsx(f_,{variables:i,control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Zooming",children:s.jsx(y.Controller,{name:"dataZoom",control:c,render:({field:v})=>s.jsx(Ln,{...v})})})]})]})})}const L_=[{lang:"en",resources:{scatter_chart:{viz_name:"Scatter Chart",color:{type:{static:"Static",dynamic:"Dynamic"},dynamic:{setup:"Setup",setup_title:"Setup dynamic color"}},click_scatter:{trigger:"Click Scatter"}}}},{lang:"zh",resources:{scatter_chart:{viz_name:"散点图",color:{type:{static:"具体颜色",dynamic:"动态计算颜色"},dynamic:{setup:"设置",setup_title:"设置动态计算颜色的逻辑"}},click_scatter:{trigger:"点击散点"}}}}];function q_(t){const{dataZoom:e=Mt,...n}=t;return{...n,dataZoom:e}}function O_(t){const e={scatter:{label_overflow:sl()}};return b.defaultsDeep(e,t)}function V_(t){const{color:e}=t.scatter;return typeof e=="string"?{...t,scatter:{...t.scatter,color:{...fn.static,color:e}}}:t}function N_(t){const e=t.reference_lines.map(n=>{const{lineStyle:r={type:"dashed",width:1,color:dt.random().css()},show_in_legend:i=!1,yAxisIndex:o=0}=n;return{...n,lineStyle:r,show_in_legend:i,yAxisIndex:o}});return{...t,reference_lines:e}}function G_(t){const e={tooltip:{trigger:"item"}};return b.defaultsDeep({},t,e)}function F_(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis:i,scatter:o,tooltip:l,...c}=t;return{...c,x_axis:{...i,data_key:r(i.data_key)},scatter:{...o,y_data_key:r(o.y_data_key),name_data_key:r(o.name_data_key)},tooltip:{...l,metrics:l.metrics.map(u=>({...u,data_key:r(u.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}function W_(t){const e={x_axis:{axisLabel:{overflow:$e()}}};return b.defaultsDeep(e,t)}class Q_ extends ce{constructor(){super(...arguments);$(this,"VERSION",10)}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:q_(n.config)})),this.version(4,n=>{const{config:r}=n;return{...n,version:5,config:O_(r)}}),this.version(6,n=>{const{config:r}=n;return{...n,version:6,config:V_(r)}}),this.version(7,n=>{const{config:r}=n;return{...n,version:7,config:N_(r)}}),this.version(8,n=>{const{config:r}=n;return{...n,version:8,config:G_(r)}}),this.version(9,(n,r)=>{const{config:i}=n;return{...n,version:9,config:F_(i,r)}}),this.version(10,(n,r)=>{const{config:i}=n;return{...n,version:10,config:W_(i)}})}}const R_={displayName:"viz.scatter_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Q_,name:"scatterChart",viewRender:m_,configRender:B_,createConfig(){return{version:10,config:b.cloneDeep(Dr)}},triggers:[nl],translation:L_},zr={template:"The variable ${value} is defined in Variables section",vertical_align:"center",horizontal_align:"left"};function U_(t){if("variables"in t)return t;const{align:e,size:n,weight:r,color:i,content:{prefix:o="",data_field:l="value",formatter:c={output:"number",mantissa:0},postfix:u=""}={}}=t;return{align:e,template:`${o} \${value} ${u}`,variables:[{name:"value",data_field:l,aggregation:{type:"none",config:{}},formatter:c,color:i,weight:r,size:n}]}}function Y_(t){return b.omit(t,["variables"])}function K_(t){const{align:e,...n}=t;return{horizontal_align:e,vertical_align:"center",...n}}function J_(t){const e=b.cloneDeep(t),n=b.get(e,"color.valueRange");return n!==void 0&&b.set(e,"color.valueRange",n.map(r=>Number(r))),e}class X_ extends ce{constructor(){super(...arguments);$(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:U_(n)})),this.version(2,(n,{panelModel:r})=>{const{config:i}=n;return(i.variables||[]).forEach(l=>{r.variables.find(c=>c.name===l.name)||r.addVariable(J_(l))}),{...n,version:2,config:Y_(i)}}),this.version(3,n=>{const{config:r}=n;return{...n,version:3,config:K_(r)}})}}const al={id:"builtin:stats:click-stats",displayName:"viz.stats.click_stats.trigger",nameRender:H_,configRender:Z_,payload:[{name:"variables",description:"Panel variables",valueType:"object"}]};function Z_(t){return s.jsx(s.Fragment,{})}function H_(t){const{t:e}=_.useTranslation();return s.jsx(a.Text,{children:e("viz.stats.click_stats.trigger")})}const ej={left:"flex-start",center:"center",right:"flex-end"},tj={top:"flex-start",center:"center",bottom:"flex-end"},nj=S.observer(({context:t,instance:e})=>{const n=Oe({vizManager:t.vizManager,instance:e}),r=qe(n.triggerManager,al.id),i=he(),{value:o=zr}=q(t.instanceData,"config"),{data:l,variables:c}=t,{template:u,horizontal_align:d,vertical_align:p}=o,{width:h,height:g}=t.viewport,f=m.useMemo(()=>{try{return b.template(u)(i.payloadForSQL)}catch{return u}},[i.payloadForSQL,u]),v=m.useMemo(()=>ln(f,c,t.data),[f,c,t.data,t]),w=m.useMemo(()=>c.reduce((z,E)=>{const V=Ze(E,l);return z[E.name]=Ie(E,V),z},{}),[l,c]),T=m.useCallback(()=>{r.forEach(z=>{n.runInteraction(z.id,{variables:w})})},[w,r,n]),D=r.length>0?{cursor:"pointer","&:hover":{textDecoration:"underline"}}:{};return s.jsx(a.Center,{sx:{width:h,height:g,justifyContent:ej[d],alignItems:tj[p]},children:s.jsx(a.Box,{sx:D,onClick:T,children:Object.values(v).map((z,E)=>s.jsx(m.Fragment,{children:z},E))})})});function sj({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),i=m.useMemo(()=>b.defaultsDeep({},n,zr),[n]),{control:o,handleSubmit:l,watch:c,getValues:u,reset:d}=y.useForm({defaultValues:i});m.useEffect(()=>{d(i)},[i]),c(["template","horizontal_align","vertical_align"]);const p=u(),h=m.useMemo(()=>!b.isEqual(p,n),[p,n]);return s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:l(r),children:[s.jsx(ge,{canSubmit:h}),s.jsx(y.Controller,{name:"template",control:o,render:({field:g})=>s.jsx(on,{label:e("chart.content_template.label"),placeholder:e("chart.content_template.hint"),py:"md",sx:{flexGrow:1},...g})}),s.jsxs(a.SimpleGrid,{cols:2,children:[s.jsx(y.Controller,{name:"horizontal_align",control:o,render:({field:g})=>s.jsx(Bn,{...g})}),s.jsx(y.Controller,{control:o,name:"vertical_align",render:({field:g})=>s.jsx(Ra,{...g})})]})]})})}const rj=[{lang:"en",resources:{stats:{viz_name:"Stats",click_stats:{trigger:"Click stats text"}}}},{lang:"zh",resources:{stats:{viz_name:"数据指标",click_stats:{trigger:"点击文字"}}}}],ij={createConfig(){return{version:3,config:zr}},displayName:"viz.stats.viz_name",displayGroup:"chart.groups.others",migrator:new X_,name:"stats",viewRender:nj,configRender:sj,triggers:[al],translation:rj},Mr={label_key:"",value_key:"",group_key:"",levels:[]};function aj(t){const e=new Set(t.map(r=>r.parent_id)),n=new Set(t.map(r=>r.id));return e.forEach(r=>{r===null||n.has(r)||t.push({id:r,name:r,parent_id:null})}),t}function oj(t){const e=aj(t).map(i=>({...i,children:[]})),n=b.keyBy(e,i=>i.id),r=[];return e.forEach(i=>{if(!i.parent_id||!n[i.parent_id]){r.push(i);return}n[i.parent_id].children.push(i)}),r}function lj(t,e){const{label_key:n,value_key:r,group_key:i}=t;if(!n||!r)return[];const o=A(n),l=A(r),c=A(i),u=e[o.queryID].map(d=>({...d,id:d[o.columnKey],parent_id:d[c.columnKey],name:d[o.columnKey],value:d[l.columnKey]?Number(d[l.columnKey]):d[l.columnKey]}));return i?oj(u):u}const cj=t=>({treePathInfo:e,name:n,value:r})=>{if(e.length===1||!t)return n;try{const i=e[e.length-2].value;if(r/i<t)return" "}catch{return n}};function uj(t){const{levels:e}=t;return e.map(n=>{const{show_label_tolerance:r,...i}=n.label;return{...n,label:{...i,formatter:cj(r)}}})}function dj(){return({treePathInfo:t,name:e,value:n,color:r,marker:i,...o})=>{const l=t.slice(0,t.length-1),c=[`<tr>
285
+ `}})}function aT(e,t){const n=t.every(c=>!Number.isNaN(Number(c))),{overflow:s,...i}=e.x_axis.axisLabel,a=ut(s.on_axis),l=t.length===0;return[te.getXAxis({data:t,name:e.x_axis.name??"",nameGap:l?5:void 0,id:"main-x-axis",type:n?"value":"category",axisLabel:{...i,...a,formatter:Ye(i.formatter)}})]}function oT(e,t){return e.y_axes.map(({nameAlignment:n,min:s,max:i,...a},l)=>{let c=a.position;return c||(c=l>0?"right":"left"),te.getYAxis({...a,minInterval:1,min:s||void 0,max:i||void 0,position:c,axisLine:{show:!0},axisLabel:{show:!0,formatter:t[l]??t.default},nameTextStyle:{align:n},nameLocation:"end",nameGap:15,splitLine:{show:!1}})})}const lT={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 cT(e,t,n){const s=n.reduce((u,d)=>{const p=jt(d,t);return u[d.name]=Re(d,p),u},{}),i=e.y_axes.reduce((u,{label_formatter:d},p)=>(u[p]=function(f){let g=f;if(typeof f=="object"&&(Array.isArray(f.value)&&f.value.length===2?g=f.value[1]:g=f.value),!d)return g;try{return U(g,d)}catch(y){return console.error(y),g}},u),{default:({value:u})=>u}),a=v.uniq(_t(t,e.x_axis.data_key)),l=nT(e,t,n,s),c={xAxis:aT(e,a),yAxis:oT(e,i),series:l,dataset:Yk(e,t),tooltip:iT(e,i),grid:Kk(e),legend:Xk(),dataZoom:ds(e.dataZoom)};return v.defaultsDeep({},c,lT)}function th(e){return e.trim().length>0}function uT({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=wn(t,e.x_axis.data_key),c=nt(i.triggerManager,Zp.id),u=m.useCallback(h=>{const f=h.data;c.forEach(g=>{i.runInteraction(g.id,{...h,rowData:f})})},[l,c,i]),d=m.useMemo(()=>({click:u}),[u]),p=m.useMemo(()=>cT(e,t,a),[e,t]);return r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,theme:"merico-light"})}function dT({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=m.useMemo(()=>v.defaults({},s,Mo),[s]),l=e.data,{width:c,height:u}=e.viewport,{ref:d,height:p}=he.useElementSize(),{ref:h,height:f}=he.useElementSize(),g=m.useMemo(()=>{const{stats:{templates:j}}=a;return{top:fr(j.top,i,l),bottom:fr(j.bottom,i,l)}},[a,l]),y=Math.max(0,Ct(u)-p-f);return!c||!u?null:r.jsxs(Ue,{width:c,height:u,children:[r.jsx(o.Text,{ref:d,align:"left",size:"xs",pl:"sm",sx:{display:th(a.stats.templates.top)?"block":"none"},children:Object.values(g.top).map(j=>j)}),r.jsx(uT,{variables:i,width:wt(c),height:y,data:l,conf:a,interactionManager:n}),r.jsx(o.Text,{ref:h,align:"left",size:"xs",pl:"sm",sx:{display:th(a.stats.templates.bottom)?"block":"none"},children:Object.values(g.bottom).map(j=>j)})]})}const pT=m.forwardRef(({value:e,onChange:t,xAxisOptions:n,yAxisOptions:s,variableOptions:i},a)=>{const{t:l,i18n:c}=_.useTranslation(),u=(d,p)=>{const h=v.cloneDeep(e);v.set(h,d,p),t(h)};return r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:l("chart.reference_area.content.label"),labelPosition:"right"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.TextInput,{label:l("chart.reference_area.content.content_text"),value:e.content.text,onChange:d=>u("content.text",d.currentTarget.value)}),r.jsx(tr,{label:l("chart.reference_area.content.text_position"),value:e.label.position,onChange:d=>u("label.position",d)})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:l("chart.reference_area.endpoint.labels"),labelPosition:"right"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[n&&r.jsx(o.Select,{label:l("chart.x_axis.label"),data:n,value:e.xAxisIndex,onChange:d=>u("xAxisIndex",d)}),s&&r.jsx(o.Select,{label:l("chart.y_axis.label"),data:s,value:e.yAxisIndex,onChange:d=>u("xAxisIndex",d)})]}),r.jsxs(o.Stack,{spacing:0,children:[r.jsx(o.Text,{size:14,color:"#212529",fw:500,children:l("chart.reference_area.endpoint.left_bottom_point")}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.Select,{icon:r.jsx(o.Text,{children:"x"}),data:i,value:e.leftBottomPoint.x_data_key,onChange:d=>u("leftBottomPoint.x_data_key",d??""),clearable:!0}),r.jsx(o.Select,{icon:r.jsx(o.Text,{children:"y"}),data:i,value:e.leftBottomPoint.y_data_key,onChange:d=>u("leftBottomPoint.y_data_key",d??""),clearable:!0})]})]}),r.jsxs(o.Stack,{spacing:0,children:[r.jsx(o.Text,{size:14,color:"#212529",fw:500,children:l("chart.reference_area.endpoint.right_top_point")}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.Select,{icon:r.jsx(o.Text,{children:"x"}),data:i,value:e.rightTopPoint.x_data_key,onChange:d=>u("rightTopPoint.x_data_key",d??""),clearable:!0}),r.jsx(o.Select,{icon:r.jsx(o.Text,{children:"y"}),data:i,value:e.rightTopPoint.y_data_key,onChange:d=>u("rightTopPoint.y_data_key",d??""),clearable:!0})]})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:l("chart.style.label"),labelPosition:"right"}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:14,children:l("chart.color.background_color")}),r.jsx(Le,{value:e.itemStyle.color,onChange:d=>u("itemStyle.color",d)})]}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:14,children:l("chart.color.text_color")}),r.jsx(Le,{value:e.label.color,onChange:d=>u("label.color",d)})]})]})});function hT(){const e=new Date().getTime().toString();return{id:e,content:{text:e},itemStyle:{color:"rgba(0,0,0,0.05)"},label:{position:"inside",color:"rgba(0,0,0,0.5)"},leftBottomPoint:{x_data_key:"",y_data_key:""},rightTopPoint:{x_data_key:"",y_data_key:""},xAxisIndex:"0",yAxisIndex:"0"}}function fT({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>hT(),a=m.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=t("y_axes"),c=m.useMemo(()=>l.map(({name:d},p)=>({label:d,value:p.toString()})),[l]),u=(d,p)=>p+1;return r.jsx(fe,{control:e,watch:t,name:"reference_areas",getItem:i,addButtonText:s("chart.reference_area.add"),deleteButtonText:s("chart.reference_area.delete"),renderTabName:u,children:({field:d,index:p})=>r.jsx(b.Controller,{name:`reference_areas.${p}`,control:e,render:({field:h})=>r.jsx(o.Stack,{children:r.jsx(pT,{variableOptions:a,yAxisOptions:c,...h})})})})}function mT({control:e,index:t,watch:n,variableOptions:s,yAxisOptions:i}){const{t:a}=_.useTranslation(),l=n(`reference_lines.${t}.orientation`);return r.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("common.name"),placeholder:a("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>r.jsx(o.Select,{label:a("common.data_field"),required:!0,data:s,sx:{flex:1},...c})})]}),r.jsx(b.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("chart.content_template.label"),placeholder:a("chart.content_template.hint"),sx:{flex:1},...c})}),r.jsxs(o.Group,{grow:!0,children:[r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>r.jsx(gn,{sx:{flex:1},...c})}),l==="vertical"&&r.jsx(o.Text,{mt:-10,color:"dimmed",size:12,children:a("chart.reference_line.orientation.vertical_hint")})]}),l==="horizontal"&&r.jsx(b.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:c,onChange:u,...d}})=>r.jsx(o.Select,{label:"Y Axis",data:i,disabled:i.length===0,...d,value:(c==null?void 0:c.toString())??"",onChange:p=>{if(!p){u(0);return}u(Number(p))},sx:{flex:1}})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.style.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>r.jsx(Zn,{sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>r.jsx(o.NumberInput,{label:a("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:a("chart.color.label")}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>r.jsx(Le,{...c})})]})]})}function gT({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:Qt.random().css()},show_in_legend:!1,yAxisIndex:0}),a=m.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=t("y_axes"),c=m.useMemo(()=>l.map(({name:d},p)=>({label:d,value:p.toString()})),[l]),u=(d,p)=>{const h=d.name.trim();return h||p+1};return r.jsx(fe,{control:e,watch:t,name:"reference_lines",getItem:i,addButtonText:s("chart.reference_line.add"),deleteButtonText:s("chart.reference_line.delete"),renderTabName:u,children:({field:d,index:p})=>r.jsx(mT,{control:e,index:p,watch:t,variableOptions:a,yAxisOptions:c})})}const xT=({value:e,onChange:t})=>{const n=s=>{s&&t(s)};return r.jsx(o.Box,{children:r.jsx(tt,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},yT=({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),[s,{setTrue:i,setFalse:a}]=W.useBoolean(),[l,c]=m.useState(e),u=()=>{a();const{type:f,func_content:g}=l,y={type:f,func_content:g};c(y),t(y)},d=()=>{a(),c(e)},p=f=>{c(g=>({...g,func_content:f}))},h=()=>{p(Wr.dynamic.func_content)};return r.jsxs(r.Fragment,{children:[r.jsx(o.Box,{sx:{width:"50%"},children:r.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:i,sx:{flexGrow:0},children:n("viz.scatter_chart.color.dynamic.setup")})}),r.jsx(o.Modal,{size:800,title:n("viz.scatter_chart.color.dynamic.setup_title"),opened:s,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&r.jsxs(o.Stack,{children:[r.jsx(xT,{value:l.func_content,onChange:p}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:h,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:n("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:d,variant:"subtle",children:n("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:u,children:n("common.actions.save")})]})]})]})})]})},bT=({value:e,onChange:t})=>e.type!=="dynamic"?null:r.jsx(yT,{value:e,onChange:t}),vT=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=s=>{t({...e,color:s})};return r.jsx(o.ColorInput,{label:" ",format:"rgb",value:e.color,onChange:n})},_T=m.forwardRef(({label:e="Color",value:t,onChange:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=m.useMemo(()=>[{label:i("viz.scatter_chart.color.type.static"),value:"static"},{label:i("viz.scatter_chart.color.type.dynamic"),value:"dynamic"}],[a.language]),c=u=>{n({...Wr[u]})};return r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(o.Select,{ref:s,label:e,data:l,value:t.type,onChange:c,sx:{flexGrow:1}}),r.jsx(vT,{value:t,onChange:n}),r.jsx(bT,{value:t,onChange:n})]})}),jT=m.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),i=l=>{t({...e,label:l})},a=l=>{t({...e,tooltip:l})};return r.jsxs(o.Stack,{ref:n,spacing:0,children:[r.jsx(cs,{sectionTitle:s("chart.axis.overflow.section_title.on_axis"),value:e.label,onChange:i}),r.jsx(cs,{sectionTitle:s("chart.axis.overflow.section_title.in_tooltip"),value:e.tooltip,onChange:a})]})});function wT({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["scatter"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"scatter.name_data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.name_data_field"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"scatter.y_data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.value_data_field"),required:!0,sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,label:n("chart.style.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"scatter.symbolSize",control:e,render:({field:s})=>r.jsx(Ha,{...s})}),r.jsx(b.Controller,{name:"scatter.color",control:e,render:({field:s})=>r.jsx(_T,{...s})}),r.jsx(o.Divider,{mb:-15,label:n("chart.label.label"),labelPosition:"center"}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"scatter.label_position",control:e,render:({field:s})=>r.jsx(tr,{label:n("chart.label_position.label"),withOffOption:!0,...s,onChange:i=>{i&&s.onChange(i)}})})}),r.jsx(b.Controller,{name:"scatter.label_overflow",control:e,render:({field:s})=>r.jsx(jT,{...s})})]})}function CT({control:e,watch:t}){const{t:n}=_.useTranslation();return t("stats"),r.jsx(o.Stack,{children:r.jsxs(o.Stack,{spacing:0,children:[r.jsx(b.Controller,{name:"stats.templates.top",control:e,render:({field:s})=>r.jsx(hr,{label:n("chart.stats.template.above_chart"),py:"md",sx:{flexGrow:1},...s})}),r.jsx(b.Controller,{name:"stats.templates.bottom",control:e,render:({field:s})=>r.jsx(hr,{label:n("chart.stats.template.under_chart"),py:"md",sx:{flexGrow:1},...s})})]})})}const ST=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},kT=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),r.jsx(fe,{control:e,watch:t,name:"tooltip.metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(ST,{control:e,index:l})})]})};function TT({control:e,watch:t}){const{t:n,i18n:s}=_.useTranslation();t("tooltip.trigger");const i=m.useMemo(()=>[{label:n("chart.tooltip.trigger.scatter_point"),value:"item"},{label:n("chart.tooltip.trigger.x_axis"),value:"axis"}],[s.language]);return r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:"tooltip.trigger",control:e,render:({field:a})=>r.jsx(o.Select,{label:n("chart.tooltip.trigger.label"),data:i,sx:{flexGrow:1},...a})}),r.jsx(o.Divider,{variant:"dashed"}),r.jsx(kT,{control:e,watch:t})]})}function DT({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["x_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"x_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:s})=>r.jsx(Jt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(St,{...s})})]}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(kt,{...s})})]})}function MT({control:e,index:t}){const{t:n}=_.useTranslation();return r.jsxs(o.Stack,{my:0,p:"0",sx:{position:"relative"},children:[r.jsx(o.Divider,{mb:-15,mt:15,variant:"dashed",label:n("chart.y_axis.y_axis_name"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:s})=>r.jsx(yn,{sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.layout"),labelPosition:"center"}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:s})=>r.jsx(Ip,{sx:{flex:1},...s})})}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.label_format"),labelPosition:"center"}),r.jsx(b.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:s})=>r.jsx(ft,{...s})})]}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.value_range"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.y_axis.value_min"),...s})}),r.jsx(b.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.y_axis.value_max"),...s})})]})]})]})}function zT({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>({name:"",label_formatter:Me,min:"",max:"",show:!0,position:"right",nameAlignment:"right"}),i=(l,c)=>{const u=l.name.trim();return u||c+1},a=({field:l,index:c,fields:u})=>u.length<=1;return r.jsx(fe,{control:e,watch:t,name:"y_axes",getItem:s,addButtonText:n("chart.y_axis.add"),deleteButtonText:n("chart.y_axis.delete"),renderTabName:i,deleteDisalbed:a,children:({field:l,index:c})=>r.jsx(MT,{control:e,index:c})})}function IT(e){return e||{templates:{top:"",bottom:""}}}function ET({reference_lines:e=[],stats:t,...n}){return{reference_lines:e,stats:IT(t),...n}}function AT({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=m.useMemo(()=>v.defaultsDeep({},n,Mo),[n]),l=m.useMemo(()=>ET(a),[a]);m.useEffect(()=>{!v.isEqual(a,l)&&(console.log("config malformed, resetting to defaults",a,l),s(l))},[a,l]);const{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=b.useForm({defaultValues:l});m.useEffect(()=>{h(l)},[l]);const f=p(),g=m.useMemo(()=>!v.isEqual(f,a),[f,a]);return d(["dataZoom"]),r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:u(s),children:[r.jsx(Ce,{canSubmit:g}),r.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Y Axes",children:t("chart.y_axis.labels")}),r.jsx(o.Tabs.Tab,{value:"Scatter",children:t("chart.series.scatter.label")}),r.jsx(o.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")}),r.jsx(o.Tabs.Tab,{value:"Stats",children:t("chart.stats.label")}),r.jsx(o.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")}),r.jsx(o.Tabs.Tab,{value:"Reference Areas",children:t("chart.reference_area.labels")}),r.jsx(o.Tabs.Tab,{value:"Zooming",children:t("chart.zooming.label")})]}),r.jsx(o.Tabs.Panel,{value:"X Axis",children:r.jsx(DT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Y Axes",children:r.jsx(zT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Scatter",children:r.jsx(wT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(TT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Stats",children:r.jsx(CT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx(gT,{variables:i,control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Reference Areas",children:r.jsx(fT,{variables:i,control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Zooming",children:r.jsx(b.Controller,{name:"dataZoom",control:c,render:({field:y})=>r.jsx(Ps,{...y})})})]})]})})}const PT=[{lang:"en",resources:{scatter_chart:{viz_name:"Scatter Chart",color:{type:{static:"Static",dynamic:"Dynamic"},dynamic:{setup:"Setup",setup_title:"Setup dynamic color"}},click_scatter:{trigger:"Click Scatter"}}}},{lang:"zh",resources:{scatter_chart:{viz_name:"散点图",color:{type:{static:"具体颜色",dynamic:"动态计算颜色"},dynamic:{setup:"设置",setup_title:"设置动态计算颜色的逻辑"}},click_scatter:{trigger:"点击散点"}}}}];function OT(e){const{dataZoom:t=jn,...n}=e;return{...n,dataZoom:t}}function LT(e){const t={scatter:{label_overflow:Hp()}};return v.defaultsDeep(t,e)}function BT(e){const{color:t}=e.scatter;return typeof t=="string"?{...e,scatter:{...e.scatter,color:{...Wr.static,color:t}}}:e}function qT(e){const t=e.reference_lines.map(n=>{const{lineStyle:s={type:"dashed",width:1,color:Qt.random().css()},show_in_legend:i=!1,yAxisIndex:a=0}=n;return{...n,lineStyle:s,show_in_legend:i,yAxisIndex:a}});return{...e,reference_lines:t}}function VT(e){const t={tooltip:{trigger:"item"}};return v.defaultsDeep({},e,t)}function NT(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis:i,scatter:a,tooltip:l,...c}=e;return{...c,x_axis:{...i,data_key:s(i.data_key)},scatter:{...a,y_data_key:s(a.y_data_key),name_data_key:s(a.name_data_key)},tooltip:{...l,metrics:l.metrics.map(u=>({...u,data_key:s(u.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}function $T(e){const t={x_axis:{axisLabel:{overflow:Ke()}}};return v.defaultsDeep(t,e)}class FT extends ge{constructor(){super(...arguments);B(this,"VERSION",10)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{tooltip:s={metrics:[]},...i}=n.config;return{...n,version:2,config:{...i,tooltip:s}}}),this.version(3,n=>({...n,version:3,config:OT(n.config)})),this.version(4,n=>{const{config:s}=n;return{...n,version:5,config:LT(s)}}),this.version(6,n=>{const{config:s}=n;return{...n,version:6,config:BT(s)}}),this.version(7,n=>{const{config:s}=n;return{...n,version:7,config:qT(s)}}),this.version(8,n=>{const{config:s}=n;return{...n,version:8,config:VT(s)}}),this.version(9,(n,s)=>{const{config:i}=n;return{...n,version:9,config:NT(i,s)}}),this.version(10,(n,s)=>{const{config:i}=n;return{...n,version:10,config:$T(i)}})}}const GT={displayName:"viz.scatter_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new FT,name:"scatterChart",viewRender:dT,configRender:AT,createConfig(){return{version:10,config:v.cloneDeep(Mo)}},triggers:[Zp],translation:PT},zo={template:"The variable ${value} is defined in Variables section",vertical_align:"center",horizontal_align:"left"};function WT(e){if("variables"in e)return e;const{align:t,size:n,weight:s,color:i,content:{prefix:a="",data_field:l="value",formatter:c={output:"number",mantissa:0},postfix:u=""}={}}=e;return{align:t,template:`${a} \${value} ${u}`,variables:[{name:"value",data_field:l,aggregation:{type:"none",config:{}},formatter:c,color:i,weight:s,size:n}]}}function RT(e){return v.omit(e,["variables"])}function QT(e){const{align:t,...n}=e;return{horizontal_align:t,vertical_align:"center",...n}}function UT(e){const t=v.cloneDeep(e),n=v.get(t,"color.valueRange");return n!==void 0&&v.set(t,"color.valueRange",n.map(s=>Number(s))),t}class YT extends ge{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:WT(n)})),this.version(2,(n,{panelModel:s})=>{const{config:i}=n;return(i.variables||[]).forEach(l=>{s.variables.find(c=>c.name===l.name)||s.addVariable(UT(l))}),{...n,version:2,config:RT(i)}}),this.version(3,n=>{const{config:s}=n;return{...n,version:3,config:QT(s)}})}}const nh={id:"builtin:stats:click-stats",displayName:"viz.stats.click_stats.trigger",nameRender:XT,configRender:KT,payload:[{name:"variables",description:"Panel variables",valueType:"object"}]};function KT(e){return r.jsx(r.Fragment,{})}function XT(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.stats.click_stats.trigger")})}const JT={left:"flex-start",center:"center",right:"flex-end"},ZT={top:"flex-start",center:"center",bottom:"flex-end"},HT=D.observer(({context:e,instance:t})=>{const n=rt({vizManager:e.vizManager,instance:t}),s=nt(n.triggerManager,nh.id),i=_e(),{value:a=zo}=$(e.instanceData,"config"),{data:l,variables:c}=e,{template:u,horizontal_align:d,vertical_align:p}=a,{width:h,height:f}=e.viewport,g=m.useMemo(()=>{try{return v.template(u)(i.payloadForSQL)}catch{return u}},[i.payloadForSQL,u]),y=m.useMemo(()=>fr(g,c,e.data),[g,c,e.data,e]),j=m.useMemo(()=>c.reduce((T,z)=>{const I=jt(z,l);return T[z.name]=Re(z,I),T},{}),[l,c]),k=m.useCallback(()=>{s.forEach(T=>{n.runInteraction(T.id,{variables:j})})},[j,s,n]),S=s.length>0?{cursor:"pointer","&:hover":{textDecoration:"underline"}}:{};return r.jsx(o.Center,{sx:{width:h,height:f,justifyContent:JT[d],alignItems:ZT[p]},children:r.jsx(o.Box,{sx:S,onClick:k,children:Object.values(y).map((T,z)=>r.jsx(m.Fragment,{children:T},z))})})});function e1({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=m.useMemo(()=>v.defaultsDeep({},n,zo),[n]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d}=b.useForm({defaultValues:i});m.useEffect(()=>{d(i)},[i]),c(["template","horizontal_align","vertical_align"]);const p=u(),h=m.useMemo(()=>!v.isEqual(p,n),[p,n]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:l(s),children:[r.jsx(Ce,{canSubmit:h}),r.jsx(b.Controller,{name:"template",control:a,render:({field:f})=>r.jsx(hr,{label:t("chart.content_template.label"),placeholder:t("chart.content_template.hint"),py:"md",sx:{flexGrow:1},...f})}),r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(b.Controller,{name:"horizontal_align",control:a,render:({field:f})=>r.jsx(ps,{...f})}),r.jsx(b.Controller,{control:a,name:"vertical_align",render:({field:f})=>r.jsx(Uc,{...f})})]})]})})}const t1=[{lang:"en",resources:{stats:{viz_name:"Stats",click_stats:{trigger:"Click stats text"}}}},{lang:"zh",resources:{stats:{viz_name:"数据指标",click_stats:{trigger:"点击文字"}}}}],n1={createConfig(){return{version:3,config:zo}},displayName:"viz.stats.viz_name",displayGroup:"chart.groups.others",migrator:new YT,name:"stats",viewRender:HT,configRender:e1,triggers:[nh],translation:t1},Io={label_key:"",value_key:"",group_key:"",levels:[]};function r1(e){const t=new Set(e.map(s=>s.parent_id)),n=new Set(e.map(s=>s.id));return t.forEach(s=>{s===null||n.has(s)||e.push({id:s,name:s,parent_id:null})}),e}function s1(e){const t=r1(e).map(i=>({...i,children:[]})),n=v.keyBy(t,i=>i.id),s=[];return t.forEach(i=>{if(!i.parent_id||!n[i.parent_id]){s.push(i);return}n[i.parent_id].children.push(i)}),s}function i1(e,t){const{label_key:n,value_key:s,group_key:i}=e;if(!n||!s)return[];const a=O(n),l=O(s),c=O(i),u=t[a.queryID].map(d=>({...d,id:d[a.columnKey],parent_id:d[c.columnKey],name:d[a.columnKey],value:d[l.columnKey]?Number(d[l.columnKey]):d[l.columnKey]}));return i?s1(u):u}const a1=e=>({treePathInfo:t,name:n,value:s})=>{if(t.length===1||!e)return n;try{const i=t[t.length-2].value;if(s/i<e)return" "}catch{return n}};function o1(e){const{levels:t}=e;return t.map(n=>{const{show_label_tolerance:s,...i}=n.label;return{...n,label:{...i,formatter:a1(s)}}})}function l1(){return({treePathInfo:e,name:t,value:n,color:s,marker:i,...a})=>{const l=e.slice(0,e.length-1),c=[`<tr>
284
286
  <th style="text-align: right; padding: 0 1em;">Value</th>
285
287
  <td style="text-align: left; padding: 0 1em;">${n}</td>
286
288
  </tr>
@@ -293,14 +295,14 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
293
295
  </tr>
294
296
  `)}),`
295
297
  <div style="text-align: left; margin-bottom: .5em; padding: 0 1em .5em; font-weight: bold; border-bottom: 1px dashed #ddd;">
296
- <div>${i} ${e}</div>
298
+ <div>${i} ${t}</div>
297
299
  </div>
298
300
  <table style="width: auto">
299
301
  <tbody>${c.join("")}</tbody>
300
302
  </table>
301
- `}}function pj(){return te.getTooltip({trigger:"item",formatter:dj()})}const hj={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function mj(t,e,n){n.reduce((o,l)=>{const c=Ze(l,e);return o[l.name]=Ie(l,c),o},{});const i={series:{data:lj(t,e),levels:uj(t)},tooltip:pj()};return b.defaultsDeep({},i,hj)}function xj({context:t}){const{variables:e}=t,{value:n}=q(t.instanceData,"config"),r=m.useMemo(()=>b.defaults({},n,Mr),[n]),i=t.data,{width:o,height:l}=t.viewport,c=m.useMemo(()=>mj(r,i,e),[r,i,e]);return!o||!l?null:s.jsx(Ae,{width:o,height:l,children:s.jsx(Se,{echarts:Ce,option:c,style:un(o,l),notMerge:!0,theme:"merico-light"})})}function gj({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["label_key","value_key","group_key"]),s.jsxs(a.Stack,{children:[s.jsx(y.Controller,{name:"label_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.name_data_field"),required:!0,...r})}),s.jsx(y.Controller,{name:"value_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.value_data_field"),required:!0,...r})}),s.jsx(y.Controller,{name:"group_key",control:t,render:({field:r})=>s.jsx(O,{label:n("viz.sunburst_chart.group_key"),clearable:!0,...r})})]})}const fj=({control:t,index:e})=>{const{t:n,i18n:r}=_.useTranslation(),i=m.useMemo(()=>[{label:n("viz.sunburst_chart.label.rotate.radial"),value:"radial"},{label:n("viz.sunburst_chart.label.rotate.tangential"),value:"tangential"},{label:n("viz.sunburst_chart.label.rotate.none"),value:"0"}],[r.language]);return s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`levels.${e}.r0`,control:t,render:({field:o})=>s.jsx(a.TextInput,{label:n("viz.sunburst_chart.level.inside_radius"),placeholder:"0%",...o})}),s.jsx(y.Controller,{name:`levels.${e}.r`,control:t,render:({field:o})=>s.jsx(a.TextInput,{label:n("viz.sunburst_chart.level.outside_radius"),placeholder:"50%",...o})})]}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:n("chart.label.label_full"),labelPosition:"center"}),s.jsx(y.Controller,{name:`levels.${e}.label.show_label_tolerance`,control:t,render:({field:o})=>s.jsx(a.NumberInput,{label:n("viz.sunburst_chart.label.show_label_tolerance"),precision:4,step:5e-4,min:0,max:1,...o})}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`levels.${e}.label.rotate`,control:t,render:({field:o})=>s.jsx(a.Select,{label:n("viz.sunburst_chart.label.rotate.label"),data:i,...o})}),s.jsx(y.Controller,{name:`levels.${e}.label.align`,control:t,render:({field:o})=>s.jsx(Tt,{...o})})]}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`levels.${e}.label.position`,control:t,render:({field:o})=>s.jsx(Kt,{label:n("chart.label_position.label"),...o,onChange:l=>{l&&o.onChange(l)}})}),s.jsx(y.Controller,{name:`levels.${e}.label.padding`,control:t,render:({field:o})=>s.jsx(a.NumberInput,{label:n("chart.padding"),min:0,hideControls:!0,...o})})]})]})},yj=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=()=>({id:Date.now().toString(),r0:"",r:"",label:{show_label_tolerance:.001,rotate:"0",align:"center",position:"inside",padding:0}}),i=(o,l)=>l+1;return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(a.Text,{size:14,color:"#888",children:n("viz.sunburst_chart.level.hint")})]}),s.jsx(a.Divider,{variant:"dashed",my:10}),s.jsx(ae,{control:t,watch:e,name:"levels",getItem:r,addButtonText:n("viz.sunburst_chart.level.add"),deleteButtonText:n("viz.sunburst_chart.level.delete"),renderTabName:i,children:({field:o,index:l})=>s.jsx(fj,{control:t,index:l})})]})};function bj({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),i=m.useMemo(()=>b.defaultsDeep({},n,Mr),[n]),o=m.useMemo(()=>b.clone(i),[i]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=y.useForm({defaultValues:o});m.useEffect(()=>{p(o)},[o]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,i),[h,i]);u(["label_key","value_key","group_key","levels"]);const[f,v]=m.useState("Data");return s.jsx("form",{onSubmit:c(r),children:s.jsxs(a.Stack,{spacing:"xs",children:[s.jsx(ge,{canSubmit:g}),s.jsxs(a.Tabs,{value:f,onTabChange:v,orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"Data",children:e("data.label")}),s.jsx(a.Tabs.Tab,{value:"Levels",children:e("viz.sunburst_chart.level.labels")})]}),s.jsx(a.Tabs.Panel,{value:"Data",children:s.jsx(gj,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Levels",children:s.jsx(yj,{control:l,watch:u})})]})]})})}const vj=[{lang:"en",resources:{sunburst_chart:{viz_name:"Sunburst Chart",level:{labels:"Levels",hint:"Configure ring style on each level",inside_radius:"Inside Radius",outside_radius:"Outside Radius",add:"Add a level",delete:"Delete this level"},label:{show_label_tolerance:"Hide label when its percentage is less than...",rotate:{label:"Rotate",radial:"Radial",tangential:"Tangential",none:"None"}},group_key:"Group Key"}}},{lang:"zh",resources:{sunburst_chart:{viz_name:"旭日图",level:{labels:"层级",hint:"为每层配置圆环样式",inside_radius:"内径",outside_radius:"外径",add:"增加一层",delete:"删除这一层"},label:{show_label_tolerance:"当百分比低于此值时,隐藏文案",rotate:{label:"旋转",radial:"径向旋转",tangential:"切向旋转",none:"不旋转"}},group_key:"分组字段"}}}];function _j(t){const{label_field:e,value_field:n,...r}=t;return{...r,label_key:e,value_key:n}}function jj(t){const{group_key:e="",...n}=t;return{...n,group_key:e}}function wj(t){const{levels:e=[],...n}=t;return{...n,levels:e}}function Cj(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{label_key:i,value_key:o,group_key:l,...c}=t;return{...c,label_key:r(i),value_key:r(o),group_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class Sj extends ce{constructor(){super(...arguments);$(this,"VERSION",5)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:_j(n.config)})),this.version(3,n=>({...n,version:3,config:jj(n.config)})),this.version(4,n=>({...n,version:4,config:wj(n.config)})),this.version(5,(n,r)=>({...n,version:5,config:Cj(n.config,r)}))}}const kj={displayName:"viz.sunburst_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Sj,name:"sunburst",viewRender:xj,configRender:bj,createConfig(){return{version:5,config:b.cloneDeep(Mr)}},translation:vj};var st=(t=>(t.string="string",t.number="number",t.eloc="eloc",t.percentage="percentage",t.url="url",t.custom="custom",t))(st||{});const ol=["function text({ value, row_data }, utils) {"," return value","}"].join(`
302
- `),ll={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",query_id:"",striped:!0,use_raw_columns:!0,ignored_column_keys:"",verticalSpacing:"14px"},cl={left:"flex-start",center:"center",right:"flex-end"},Tj=({header:t,cx:e})=>{const n=b.get(t.column.columnDef.meta,"align","left");return s.jsxs(a.Text,{className:e("table-head-cell",{"table-head-cell--sortable":t.column.getCanSort()}),onClick:t.column.getToggleSortingHandler(),align:n,sx:{justifyContent:cl[n]},children:[t.isPlaceholder?null:Je.flexRender(t.column.columnDef.header,t.getContext()),s.jsx(Dj,{direction:t.column.getIsSorted()})]})},Dj=({direction:t})=>{switch(t){case"asc":return s.jsx(k.IconArrowUp,{size:16});case"desc":return s.jsx(k.IconArrowDown,{size:"1em"});default:return null}},zj=a.createStyles(t=>({root:{overflow:"auto",position:"relative","& .table-head-cell":{display:"flex",flexFlow:"row nowrap",alignItems:"center",whiteSpace:"nowrap","&.table-head-cell--sortable":{cursor:"pointer",userSelect:"none"}},"&.table-highlight-on-hover tr":{transition:"background-color 0.2s","&:hover":{backgroundColor:t.colorScheme==="dark"?t.colors.dark[5]:t.colors.gray[0]}}},thead:{background:t.colorScheme==="dark"?t.colors.dark[7]:t.white,position:"sticky",top:24,transform:"translateY(-1px)",zIndex:10},info_bar:{position:"sticky",top:0,left:0,right:0,zIndex:10,background:"white"}})),Mj={tableLayout:"fixed",width:"fit-content",minWidth:"100%","thead, tbody":{tr:{width:"fit-content",th:{position:"relative"},"th, td":{padding:"2px 10px",div:{overflow:"hidden",textOverflow:"ellipsis"},"&:first-of-type":{paddingLeft:2,paddingRight:2}}}},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",transform:"translateY(-50%)",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}},ul=a.createStyles((t,e)=>({content:{display:"flex",alignItems:"center",justifyContent:cl[e.align],".table-cell-text":{whiteSpace:"nowrap",cursor:e.clickable?"pointer":"default",textDecoration:e.clickable?"underline":"none"}}}));function Ij(t){return t?dt(t).oklch()[0]>.7?"black":"white":"inherit"}function dl(t){const e=t.tableCellContext.bgColor;return{backgroundColor:e,color:Ij(e)}}function Xt(t){const e=t.tableCellContext.isClickable(),n=ul({clickable:e,align:t.align});return s.jsx("div",{className:n.classes.content,style:{...dl(t)},children:s.jsx(a.Text,{className:"table-cell-text",onClick:t.tableCellContext.getClickHandler(),children:s.jsx("span",{title:t.children,children:t.children})})})}function Ej(t){return s.jsx(Xt,{...t,children:t.value})}function Aj(t){const e=ul({clickable:!0,align:t.align}),n=t.value;return s.jsx("div",{className:e.classes.content,style:{...dl(t)},children:s.jsx(a.Anchor,{className:"table-cell-text",href:n,target:"_blank",color:"black",children:n})})}function Pj(t){const e=U(t.value,{output:"number",average:!0,mantissa:2,trimMantissa:!0,absolute:!1});return s.jsx(Xt,{...t,children:e})}function $j(t){const e=U(t.value,{output:"number",mantissa:0,thousandSeparated:!0,absolute:!1});return s.jsx(Xt,{...t,children:e})}function Bj(t){const e=U(t.value,{output:"percent",mantissa:3,trimMantissa:!0,absolute:!1});return s.jsx(Xt,{...t,children:e})}function Lj(t){const{value:e,row_data:n,func_content:r}=t;if(!r)return s.jsx(Xt,{...t,children:e});const i=new Function(`return ${r}`)()({value:e,row_data:n},at);return s.jsx(Xt,{...t,children:i})}function qj(t){switch(t.type){case st.string:return s.jsx(Ej,{...t});case st.eloc:return s.jsx(Pj,{...t});case st.number:return s.jsx($j,{...t});case st.percentage:return s.jsx(Bj,{...t});case st.url:return s.jsx(Aj,{...t});case st.custom:return s.jsx(Lj,{...t})}}function Oj({tableContainerRef:t,rows:e}){var c,u;const n=qu.useVirtual({parentRef:t,size:e.length,estimateSize:m.useCallback(()=>28,[]),overscan:20}),{virtualItems:r,totalSize:i}=n,o=r.length>0&&((c=r==null?void 0:r[0])==null?void 0:c.start)||0,l=r.length>0?i-(((u=r==null?void 0:r[r.length-1])==null?void 0:u.end)||0):0;return s.jsxs("tbody",{children:[o>0&&s.jsx("tr",{children:s.jsx("td",{style:{height:`${o}px`}})}),r.map(d=>{const p=e[d.index];return s.jsx("tr",{children:p.getVisibleCells().map(h=>s.jsx("td",{children:Je.flexRender(h.column.columnDef.cell,h.getContext())},h.id))},p.id)}),l>0&&s.jsx("tr",{children:s.jsx("td",{style:{height:`${l}px`}})})]})}const Ir={id:"builtin:table:click-cell-content",displayName:"viz.table.click_cell.click_cell_content",nameRender:Fj,configRender:Nj,payload:[{name:"row_index",description:"Index of the row that the cell belongs to",valueType:"number"},{name:"col_index",description:"Index of the column that the cell belongs to",valueType:"number"},{name:"row_data",description:"Data of the row that the cell belongs to",valueType:"object"}]},Vj={column:""};function pl(t,e){const{value:n}=q(t.instanceData,"config"),r={columnsFromConfig:[],columnsFromData:[]};if(n&&(r.columnsFromConfig=n.columns.map((i,o)=>({label:i.label,value:o.toString()}))),!e)return r;if(n!=null&&n.query_id){const i=e[n.query_id];(i==null?void 0:i.length)>0&&(r.columnsFromData=Object.keys(i[0]).map(o=>({label:o,value:o})))}return r}function hl(t){const{value:e}=q(t.instanceData,"config");return(e==null?void 0:e.use_raw_columns)??!1}function Nj(t){const{t:e}=_.useTranslation(),{columnsFromConfig:n,columnsFromData:r}=pl(t.instance,t.sampleData),i=hl(t.instance),o=n.length>0?n:r,{value:l,set:c}=q(t.trigger.triggerData,"config"),{column:u}=b.defaults({},l,Vj),d=p=>{isNaN(+p)?c({column:p}):c({column:+p})};return i?s.jsxs(a.Stack,{children:[s.jsx(a.Alert,{icon:s.jsx(k.IconAlertCircle,{size:"1rem"}),color:"gray",children:s.jsxs(_.Trans,{i18nKey:"viz.table.click_cell.why_column_data_field",children:["Option ",s.jsx(a.Mark,{children:"Use original data columns"})," is enabled, you have to address trigger column by its data field"]})}),s.jsx(a.TextInput,{label:e("viz.table.click_cell.column_data_field"),value:u.toString(),onChange:p=>d(p.currentTarget.value)})]}):s.jsx(a.Select,{clearable:!1,data:o,label:e("viz.table.click_cell.choose_a_column"),value:u.toString(),onChange:d})}function Gj(t,e,n){const{t:r}=_.useTranslation();return t?b.isNumber(t.column)?n?r("viz.table.click_cell.click_cell_of_x_th",{x:t.column+1}):r("viz.table.click_cell.click_cell_of_x",{x:e[t.column].label}):r("viz.table.click_cell.click_cell_of_x",{x:t.column}):r("viz.table.click_cell.click_cell_content")}function Fj(t){const{columnsFromConfig:e}=pl(t.instance),{value:n}=q(t.trigger.triggerData,"config"),r=hl(t.instance);return s.jsx(a.Text,{children:Gj(n,e,r)})}function ml(t,e,n){return Math.min(Math.max(t,e),n)}class Wj{constructor(e){this.steps=e;const n=[],r=new Set;for(const i of e)r.has(i.to)||(n.push(i),r.add(i.to));if(n.sort((i,o)=>i.from-o.from),n.length<2)throw new Error("MultiStepValueMapper requires at least 2 steps");this.steps=n}getLinearFunction(e,n){const r=(n.to-e.to)/(n.from-e.from),i=e.to-r*e.from;return o=>r*o+i}getStepFunctionForValue(e){let n=b.findLastIndex(this.steps,r=>r.from<=e);return n=ml(n,0,this.steps.length-2),this.getLinearFunction(this.steps[n],this.steps[n+1])}mapValue(e){return ml(this.getStepFunctionForValue(e)(e),0,100)}}class Qj{constructor(e,n,r,i,o){this.getColIndex=e,this.cell=n,this.triggers=r,this.interactionManager=i,this.colorManager=o}getClickHandler(){const e=this.getRelatedTrigger();if(e.length!==0)return()=>{const n={row_data:this.cell.row.original,row_index:this.cell.row.index,col_index:this.getColIndex(this.cell)};for(const r of e)this.interactionManager.runInteraction(r.id,n)}}getRelatedTrigger(){return this.triggers.filter(n=>n.schemaRef===Ir.id).filter(n=>{const r=this.getColIndex(this.cell),i=b.get(this.cell.column.columnDef.meta,"value_field"),o=b.get(n.config,"column");return o==r||o==i})}isClickable(){return this.getRelatedTrigger().length>0}get columnConf(){return this.cell.column.columnDef.meta}get bgColor(){const e=this.columnConf.cellBackgroundColor;if(!e||e==="none")return;if(b.isString(e))return e;const n=+this.cell.getValue();if(isFinite(n)){const r=this.colorManager.decodeInterpolation(e.interpolation),o=new Wj(e.steps).mapValue(n);return r==null?void 0:r.getColor(o)}}}const Rj=t=>{const e=Oe(t),n=qe(e.triggerManager,Ir.id),{colorManager:r}=m.useContext(ut);return m.useCallback(i=>new Qj(t.getColIndex,i,n,e,r),[n,e,t.getColIndex])};function xl({queryData:t,width:e,height:n,conf:r,context:i,instance:o}){const{t:l}=_.useTranslation(),{use_raw_columns:c,ignored_column_keys:u,columns:d,...p}=r,{classes:h,cx:g}=zj(),f=m.useMemo(()=>{if(!c)return d;if(!Array.isArray(t)||t.length===0)return[];let le=Object.keys(t[0]);const Ye=new Set(u==null?void 0:u.split(/\r?\n|\r|\n/g).filter(be=>!!be));return Ye.size>0&&(le=le.filter(be=>!Ye.has(be))),le.map(be=>({id:be,label:be,value_field:be,value_type:st.string,align:"left",width:"",cellBackgroundColor:""}))},[c,u,d,t]),v=Rj({getColIndex:m.useCallback(le=>f.indexOf(le.column.columnDef.meta),[f]),vizManager:i.vizManager,instance:o}),w=m.useMemo(()=>{const le=Je.createColumnHelper();return f.map(be=>{const ys=Pd(be.value_field);return le.accessor(ys.columnKey,{cell:Ge=>s.jsx(qj,{tableCellContext:v(Ge.cell),value:Ge.getValue(),type:be.value_type,row_data:Ge.row.original,...be}),header:be.label,enableSorting:!0,meta:be,size:typeof be.width=="number"?be.width:void 0,minSize:typeof be.width=="number"?be.width:void 0})})},[f,v]),[T,D]=m.useState([]),z=Je.useReactTable({data:t,state:{sorting:T},onSortingChange:D,columns:w,columnResizeMode:"onChange",getCoreRowModel:Je.getCoreRowModel(),getSortedRowModel:Je.getSortedRowModel()}),{rows:E}=z.getRowModel(),V=m.useRef(null),F=E.length,N=F>0,Q=N?n-22:n,ue=N?22:0;return s.jsxs("div",{ref:V,style:{height:n,width:e,padding:"0 5px"},"data-enable-scrollbar":!0,className:g(h.root,{"table-highlight-on-hover":r.highlightOnHover}),children:[F>0&&s.jsx(a.Box,{className:h.info_bar,sx:{height:22},children:s.jsx(a.Text,{align:"right",pr:6,size:14,color:"dimmed",fw:"normal",children:l("common.pagination.total_rows",{total:F})})}),s.jsxs(a.Table,{sx:{...Mj,maxHeight:Q},...p,striped:r.striped,children:[s.jsx("thead",{className:h.thead,style:{top:ue},children:z.getHeaderGroups().map(le=>s.jsx("tr",{children:le.headers.map(Ye=>s.jsxs("th",{style:{width:Ye.getSize()},children:[s.jsx(Tj,{header:Ye,cx:g}),s.jsx(a.ActionIcon,{onMouseDown:Ye.getResizeHandler(),onTouchStart:Ye.getResizeHandler(),className:`resizer ${Ye.column.getIsResizing()?"isResizing":""}`,children:s.jsx(k.IconArrowBarToRight,{})})]},Ye.id))},le.id))}),s.jsx(Oj,{tableContainerRef:V,rows:E})]})]})}function gl(){const{t}=_.useTranslation();return s.jsx(a.Text,{color:"gray",align:"center",children:t("data.empty_data")})}function Uj({data:t,width:e,height:n,conf:r,context:i,instance:o}){const{t:l}=_.useTranslation(),{panel:c}=mt(),u=c.firstQueryData??[];if(c.queryIDs.length===0)return s.jsx(a.Text,{color:"gray",align:"center",children:l("panel.settings.need_to_choose_queries")});const{query_id:d}=r;if(!d)return u.length===0?s.jsx(gl,{}):s.jsx(xl,{queryData:u,width:e,height:n,conf:{...r,use_raw_columns:!0,columns:[]},context:i,instance:o});const p=t[d];return!Array.isArray(p)||p.length===0?s.jsx(gl,{}):s.jsx(xl,{queryData:p,width:e,height:n,conf:r,context:i,instance:o})}function Yj({context:t,instance:e}){const n=t.data,{height:r,width:i}=t.viewport,{value:o}=q(t.instanceData,"config");return o?s.jsx(Uj,{data:n,width:i,height:r,conf:o,context:t,instance:e}):null}const Kj=S.observer(m.forwardRef(({label:t,required:e,description:n,value:r,onChange:i,clearable:o=!1,sx:l,...c},u)=>{const{panel:d}=ze(),p=m.useMemo(()=>d.queryOptions(r,o),[r,o]);return p.length===0?s.jsx(a.Box,{children:s.jsx(a.TextInput,{label:t,required:e,defaultValue:r,readOnly:!0,disabled:!0})}):s.jsx(a.Select,{ref:u,label:t,description:n,data:p,value:r,onChange:i,required:e,sx:l,maxDropdownHeight:500,...c})})),Jj=[{from:0,to:0},{from:100,to:100}];function fl(t){return t?b.isString(t)?t==="none"?"none":"static":"interpolation":"none"}function Xj(t,e){var n;return fl(e)==="static"?e:(n=t.getStaticColors()[0])==null?void 0:n.value}function Zj(t,e){return b.isObject(e)?e:{steps:Jj,interpolation:t.encodeColor(t.getColorInterpolations()[0])}}const Hj=m.forwardRef((t,e)=>{const{t:n}=_.useTranslation(),{colorManager:r}=m.useContext(ut),[i,o]=m.useState(fl(t.value)),[l,c]=m.useState(Xj(r,t.value)),u=W.useLatest(l),[d,p]=m.useState(Zj(r,t.value)),h=W.useLatest(d),g=w=>{var T,D,z;o(w||"none"),w==="static"?(T=t.onChange)==null||T.call(t,u.current):w==="none"||!w?(D=t.onChange)==null||D.call(t,"none"):(z=t.onChange)==null||z.call(t,h.current)},f=w=>{var T;c(w),(T=t.onChange)==null||T.call(t,w)},v=w=>{var T;p(w),(T=t.onChange)==null||T.call(t,w)};return s.jsxs(a.Stack,{align:"stretch",children:[s.jsx(tm,{label:n("viz.table.column.cell_background"),value:i||"none",onChange:g}),i==="static"&&s.jsx(Te,{value:l,onChange:f}),i==="interpolation"&&s.jsx(em,{colorManager:r,value:d,onChange:v})]})}),ew=m.forwardRef(({value:t,onChange:e,sx:n},r)=>{const{t:i,i18n:o}=_.useTranslation(),l=m.useMemo(()=>Object.values(st).map(c=>({label:i(`viz.table.column.value_type.${c}`),value:c})),[o.language]);return s.jsx(a.Select,{ref:r,label:i("viz.table.column.value_type.label"),data:l,value:t,onChange:e,maxDropdownHeight:500,sx:n})}),tw=m.forwardRef(({value:t,onChange:e},n)=>{const{t:r}=_.useTranslation(),[i,{setTrue:o,setFalse:l}]=W.useBoolean(),[c,u]=m.useState(t),d=()=>{l(),e(c)},p=()=>{l(),u(t)},h=()=>{u(ol)};return m.useEffect(()=>{u(t)},[t]),s.jsxs(s.Fragment,{children:[s.jsx(a.Button,{color:"grape",variant:"filled",leftIcon:s.jsx(k.IconMathFunction,{size:16}),mt:24,onClick:o,sx:{flexGrow:0},children:r("viz.table.column.custom_cell_content")}),s.jsx(a.Modal,{size:800,title:r("viz.table.column.custom_cell_content"),opened:i,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:i&&s.jsxs(a.Stack,{children:[s.jsx(a.Group,{position:"left",children:s.jsx(Ao,{})}),s.jsx(a.Box,{sx:{position:"relative"},children:s.jsx(Le,{height:"500px",defaultLanguage:"javascript",value:c,onChange:g=>u(g??""),theme:"vs-dark",options:{minimap:{enabled:!1}}})}),s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Button,{onClick:h,color:"red",leftIcon:s.jsx(L.Recycle,{size:20}),children:r("common.actions.reset_to_default")}),s.jsxs(a.Group,{position:"right",children:[s.jsx(a.Button,{onClick:p,variant:"subtle",children:r("common.actions.cancel")}),s.jsx(a.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),onClick:d,children:r("common.actions.save")})]})]})]})})]})}),Er=()=>s.jsx(a.Text,{color:"dimmed",size:12,children:"px"}),nw=({control:t,index:e,watch:n,remove:r,column:i})=>{const{t:o}=_.useTranslation(),l=n(`columns.${e}.value_type`),c=n("query_id");return s.jsxs(a.Stack,{my:0,sx:{position:"relative"},children:[s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:`columns.${e}.label`,control:t,render:({field:u})=>s.jsx(a.TextInput,{label:o("chart.label.label"),required:!0,id:`col-label-${e}`,sx:{flex:1},...u})}),s.jsx(y.Controller,{name:`columns.${e}.value_field`,control:t,render:({field:u})=>s.jsx(O,{label:o("common.data_field"),required:!0,queryID:c,...u})})]}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:`columns.${e}.value_type`,control:t,render:({field:u})=>s.jsx(ew,{sx:{flex:1},...u})}),l===st.custom&&s.jsx(y.Controller,{name:`columns.${e}.func_content`,control:t,render:({field:u})=>s.jsx(tw,{value:u.value??ol,onChange:d=>u.onChange(d??"")})})]}),s.jsx(a.Divider,{mb:-10,variant:"dashed",label:o("style.label"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(a.NumberInput,{hideControls:!0,label:o("viz.table.column.min_width"),rightSection:s.jsx(Er,{}),disabled:!0}),s.jsx(y.Controller,{name:`columns.${e}.width`,control:t,render:({field:u})=>s.jsx(a.NumberInput,{hideControls:!0,label:o("viz.table.column.width"),rightSection:s.jsx(Er,{}),...u})}),s.jsx(a.NumberInput,{hideControls:!0,label:o("viz.table.column.max_width"),rightSection:s.jsx(Er,{}),disabled:!0})]}),s.jsx(a.Group,{grow:!0,noWrap:!0,children:s.jsx(y.Controller,{name:`columns.${e}.align`,control:t,render:({field:u})=>s.jsx(Bn,{...u})})}),s.jsx(y.Controller,{name:`columns.${e}.cellBackgroundColor`,control:t,render:({field:u})=>s.jsx(Hj,{...u})}),s.jsx(a.Divider,{mb:4,mt:12,variant:"dashed"}),s.jsx(a.Button,{leftIcon:s.jsx(L.Trash,{size:16}),color:"red",variant:"light",onClick:()=>r(e),children:o("viz.table.column.delete")})]})},sw=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),{fields:r,append:i,remove:o,update:l}=y.useFieldArray({control:t,name:"columns"}),c=()=>{const d=ie.randomId();i({id:d,label:d,align:"center",value_field:"",value_type:st.string,width:""})};e(["columns","ignored_column_keys"]);const u=e("use_raw_columns");return s.jsxs(s.Fragment,{children:[s.jsx(y.Controller,{name:"use_raw_columns",control:t,render:({field:d})=>s.jsx(a.Switch,{mt:20,mb:20,label:n("viz.table.column.use_original_data_columns"),checked:d.value,onChange:p=>d.onChange(p.currentTarget.checked)})}),u&&s.jsx(y.Controller,{name:"ignored_column_keys",control:t,render:({field:d})=>s.jsx(a.Textarea,{label:n("viz.table.column.ignore_columns_by_these_key"),placeholder:n("viz.table.column.separate_by_line_break"),autosize:!0,minRows:2,maxRows:10,...d})}),!u&&s.jsx(a.Stack,{children:s.jsxs(a.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[s.jsxs(a.Tabs.List,{children:[r.map((d,p)=>s.jsx(a.Tabs.Tab,{value:p.toString(),children:p+1},d.id)),s.jsx(a.Tabs.Tab,{onClick:c,value:"add",children:s.jsx(L.Plus,{size:18,color:"#228be6"})})]}),r.map((d,p)=>s.jsx(a.Tabs.Panel,{value:p.toString(),children:s.jsx(nw,{control:t,watch:e,index:p,column:d,remove:o})},d.id))]})})]})};function rw({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["horizontalSpacing","verticalSpacing","fontSize","striped","highlightOnHover"]),s.jsxs(a.Stack,{spacing:"xs",children:[s.jsxs(a.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[s.jsx(y.Controller,{name:"horizontalSpacing",control:t,render:({field:r})=>s.jsx(Js,{disabled:!0,label:n("viz.table.style.horizontal_spacing"),sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"verticalSpacing",control:t,render:({field:r})=>s.jsx(Js,{disabled:!0,label:n("viz.table.style.vertical_spacing"),sx:{flex:1},...r})})]}),s.jsx(a.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:s.jsx(y.Controller,{name:"fontSize",control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("style.font_size.label"),placeholder:n("style.font_size.placeholder"),required:!0,sx:{flex:1},...r})})}),s.jsxs(a.Group,{position:"apart",grow:!0,children:[s.jsx(y.Controller,{name:"striped",control:t,render:({field:r})=>s.jsx(a.Switch,{label:n("viz.table.style.striped"),checked:r.value,onChange:i=>r.onChange(i.currentTarget.checked)})}),s.jsx(y.Controller,{name:"highlightOnHover",control:t,render:({field:r})=>s.jsx(a.Switch,{label:n("viz.table.style.highlight_on_hover"),checked:r.value,onChange:i=>r.onChange(i.currentTarget.checked)})})]})]})}function iw({columns:t,...e}){return{...e,columns:t.map(({id:n,...r})=>({id:n??ie.randomId(),...r}))}}function aw({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),i=m.useMemo(()=>b.defaultsDeep({},n,ll),[n]),o=m.useMemo(()=>iw(i),[i]);m.useEffect(()=>{!b.isEqual(i,o)&&(console.log("config malformed, resetting to defaults",i,o),r(o))},[i,o]);const{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=y.useForm({defaultValues:o});m.useEffect(()=>{p(o)},[o]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,i),[h,i]);return u(["query_id"]),s.jsxs("form",{onSubmit:c(r),children:[s.jsx(ge,{canSubmit:g}),s.jsxs(a.Tabs,{defaultValue:"Columns",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"Columns",children:e("viz.table.column.labels")}),s.jsx(a.Tabs.Tab,{value:"Style",children:e("style.label")})]}),s.jsxs(a.Tabs.Panel,{value:"Columns",children:[s.jsx(y.Controller,{name:"query_id",control:l,render:({field:f})=>s.jsx(Kj,{label:e("viz.table.column.query_id"),description:e("viz.table.column.query_id_hint"),required:!0,...f})}),s.jsx(a.Divider,{mt:20,mb:10,variant:"dashed"}),s.jsx(sw,{control:l,watch:u})]}),s.jsx(a.Tabs.Panel,{value:"Style",children:s.jsx(rw,{control:l,watch:u})})]})]})}const ow=[{lang:"en",resources:{table:{viz_name:"Table",column:{labels:"Columns",delete:"Delete this column",query_id:"Query",query_id_hint:"Load table data from this query",use_original_data_columns:"Use original data columns",ignore_columns_by_these_key:"Ignore columns by these keys",separate_by_line_break:"Separate by line break",width:"Width",min_width:"Min Width",max_width:"Max Width",cell_background:"Cell background",custom_cell_content:"Custom cell content",value_type:{label:"Value Type",string:"String",number:"Number",percentage:"Percentage",eloc:"ELOC",url:"URL",custom:"Custom"}},style:{horizontal_spacing:"Horizontal Spacing",vertical_spacing:"Vertical Spacing",striped:"Striped",highlight_on_hover:"Hightlight on hover"},click_cell:{label:"Click cell content",click_cell_content:"Click cell content (click to config)",click_cell_of_x:"Click cell of {{ x }}",click_cell_of_x_th:"Click cell by column order {{ x }}",choose_a_column:"Choose a column",why_column_data_field:"Option <1>Use original data columns</1> is enabled, you have to address trigger column by its data field",column_data_field:"Column data field"}}}},{lang:"zh",resources:{table:{viz_name:"表格",column:{labels:"列设置",delete:"删除这个列",query_id:"表格数据来源",query_id_hint:"通过所选的查询获取表格数据",use_original_data_columns:"使用数据本身的列",ignore_columns_by_these_key:"按下述列名忽略列",separate_by_line_break:"以换行符分隔",width:"宽度",min_width:"最小宽度",max_width:"最大宽度",cell_background:"单元格背景",custom_cell_content:"自定义单元格内容",value_type:{label:"数据类型",string:"文本",number:"数字",percentage:"百分比",eloc:"ELOC",url:"URL",custom:"自定义"}},style:{horizontal_spacing:"水平间距",vertical_spacing:"垂直间距",striped:"隔行变色",highlight_on_hover:"鼠标悬停时高亮整行"},click_cell:{label:"点击单元格",click_cell_content:"点击单元格内容",click_cell_of_x:"点击 {{ x }} 列单元格",click_cell_of_x_th:"点击第 {{ x }} 列单元格",choose_a_column:"选择列",why_column_data_field:"选项 <1>使用数据本身的列</1> 已开启,只能通过填写数据字段来指定触发动作的列",column_data_field:"列的数据字段"}}}}];function lw(t){const{columns:e,...n}=t;return{...t,columns:e.map(r=>({...r,align:r.align??"left"}))}}function cw(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=c=>c&&`${n}.${c}`,{id_field:i,columns:o,...l}=t;return{...l,id_field:r(i),columns:o.map(c=>({...c,value_field:r(c.value_field)}))}}catch(n){throw console.error("[Migration failed]",n),n}}function uw(t){const{columns:e,...n}=t;return{...n,columns:e.map(r=>({...r,align:r.align??"left",cellBackgroundColor:r.cellBackgroundColor??"",width:r.width??""}))}}function dw(t){const{id_field:e,...n}=t,{queryID:r}=A(e);return{...n,query_id:r??""}}function pw(t){const{ignored_column_keys:e,...n}=t;return{...n,ignored_column_keys:e??""}}class hw extends ce{constructor(){super(...arguments);$(this,"VERSION",7)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{columns:r,...i}=n.config;return{...n,version:2,config:{...i,columns:r.map(({id:o,...l})=>({id:o??ie.randomId(),...l}))}}}),this.version(3,n=>({...n,version:3,config:lw(n.config)})),this.version(4,(n,r)=>({...n,version:4,config:cw(n.config,r)})),this.version(5,n=>({...n,version:5,config:uw(n.config)})),this.version(6,n=>({...n,version:6,config:dw(n.config)})),this.version(7,n=>({...n,version:7,config:pw(n.config)}))}}const Ar={createConfig(){return{version:7,config:b.cloneDeep(ll)}},displayName:"viz.table.viz_name",displayGroup:"chart.groups.others",migrator:new hw,name:"table",viewRender:Yj,configRender:aw,triggers:[Ir],translation:ow},yl=["function text({ data, variables, filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
303
- `),Pr={func_content:yl,horizontal_align:"left",font_size:"14px",font_weight:"normal"},mw=S.observer(({context:t})=>{const e=he(),{value:n=Pr}=q(t.instanceData,"config"),{variables:r}=t,i=t.data,{func_content:o,horizontal_align:l,font_size:c,font_weight:u}=n,d=m.useMemo(()=>r.reduce((h,g)=>{const f=Ze(g,i);return h[g.name]=Ie(g,f),h},{}),[r,i]),p=m.useMemo(()=>new Function(`return ${o}`)()({data:i,variables:d,filters:e.payloadForSQL.filters,context:e.payloadForSQL.context}),[o,i,d,e.payloadForSQL]);return s.jsx(a.Text,{align:l,weight:u,sx:{fontSize:c},children:p})}),is=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function xw({label:t,value:e,onChange:n},r){var l;const[i,o]=m.useState(((l=is.find(c=>c.label===e))==null?void 0:l.value)??is[0].value);return m.useEffect(()=>{const c=is.find(u=>u.value===i);c&&n(c.label)},[i]),s.jsxs(a.Stack,{spacing:0,mt:"sm",mb:"lg",children:[s.jsx(a.Text,{size:"sm",children:t}),s.jsx(a.Box,{px:"1.5em",children:s.jsx(a.Slider,{label:null,marks:is,value:i,onChange:o,step:25,ref:r})})]})}const bl=m.forwardRef(xw),gw=({value:t,onChange:e})=>{const n=r=>{r&&e(r)};return s.jsx(a.Box,{sx:{position:"relative"},children:s.jsx(Le,{height:"500px",defaultLanguage:"javascript",value:t,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},fw=m.forwardRef(({value:t,onChange:e},n)=>{const{t:r}=_.useTranslation(),[i,{setTrue:o,setFalse:l}]=W.useBoolean(),[c,u]=m.useState(t),d=()=>{l(),e(c)},p=()=>{l(),u(t)},h=()=>{u(yl)};return m.useEffect(()=>{u(t)},[t]),s.jsxs(s.Fragment,{children:[s.jsx(a.Button,{color:"grape",variant:"filled",leftIcon:s.jsx(k.IconMathFunction,{size:16}),mt:24,onClick:o,sx:{flexGrow:0},children:r("viz.text.content.edit")}),s.jsx(a.Modal,{size:800,title:r("viz.text.content.label"),opened:i,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:i&&s.jsxs(a.Stack,{children:[s.jsx(gw,{value:c,onChange:u}),s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Button,{onClick:h,color:"red",leftIcon:s.jsx(L.Recycle,{size:20}),children:r("common.actions.reset_to_default")}),s.jsxs(a.Group,{position:"right",children:[s.jsx(a.Button,{onClick:p,variant:"subtle",children:r("common.actions.cancel")}),s.jsx(a.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),onClick:d,children:r("common.actions.save_changes")})]})]})]})})]})});function yw({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),i=m.useMemo(()=>b.defaultsDeep({},n,Pr),[n]),o=m.useMemo(()=>{const{func_content:f,horizontal_align:v,font_size:w,font_weight:T}=i;return{func_content:f,horizontal_align:v,font_size:w,font_weight:T}},[i]);m.useEffect(()=>{!b.isEqual(i,o)&&(console.log("config malformed, resetting to defaults",i,o),r(o))},[i,o]);const{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=y.useForm({defaultValues:o});m.useEffect(()=>{p(o)},[o]),u(["func_content","horizontal_align","font_size","font_weight"]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,i),[h,i]);return s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:c(r),children:[s.jsx(ge,{canSubmit:g}),s.jsxs(a.Stack,{spacing:10,children:[s.jsx(y.Controller,{name:"func_content",control:l,render:({field:f})=>s.jsx(fw,{...f})}),s.jsx(a.Divider,{mt:10,mb:-10,variant:"dashed",label:e("chart.style.label"),labelPosition:"center"}),s.jsx(y.Controller,{name:"horizontal_align",control:l,render:({field:f})=>s.jsx(Bn,{...f})}),s.jsx(y.Controller,{name:"font_size",control:l,render:({field:f})=>s.jsx(a.TextInput,{label:e("style.font_size.label"),placeholder:e("style.font_size.placeholder"),sx:{flex:1},...f})}),s.jsx(a.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:s.jsx(y.Controller,{name:"font_weight",control:l,render:({field:f})=>s.jsx(bl,{label:e("style.font_weight.label"),...f})})})]})]})})}const bw=[{lang:"en",resources:{text:{viz_name:"Text",content:{label:"Text content",edit:"Edit Content"}}}},{lang:"zh",resources:{text:{viz_name:"文本",content:{label:"文本内容",edit:"编辑文本内容"}}}}];class vw extends ce{constructor(){super(...arguments);$(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const _w={displayName:"viz.text.viz_name",displayGroup:"chart.groups.others",migrator:new vw,name:"text",viewRender:mw,configRender:yw,createConfig(){return{version:1,config:b.cloneDeep(Pr)}},translation:bw},jw=()=>s.jsxs("svg",{width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[s.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22.49 27.79H14.47C13.55 27.79 12.81 28.53 12.81 29.45C12.81 30.37 13.55 31.11 14.47 31.11H22.49C23.41 31.11 24.15 30.37 24.15 29.45C24.15 28.54 23.41 27.79 22.49 27.79ZM34.32 31.28C35.22 31.32 35.7 31.82 35.74 32.76C35.78 33.54 35.37 34.3 34.51 35.04C33.52 35.9 33.03 36.95 33.03 38.19V38.81H34.82V38.25C34.78 37.59 35.07 37.02 35.68 36.52C37.12 35.41 37.82 34.15 37.78 32.75C37.66 30.53 36.5 29.35 34.32 29.23C32.3 29.23 31.05 30.46 30.55 32.93L32.53 33.55C32.82 32.04 33.42 31.28 34.32 31.28ZM35 39.93H32.84V42.21H35V39.93ZM14.83 36.42H18.54C19.46 36.42 20.2 37.17 20.2 38.08C20.2 39 19.46 39.74 18.54 39.74H10.52C9.6 39.74 8.86 39 8.86 38.08C8.86 37.61 9.06 37.19 9.37 36.89H5.66C4.74 36.89 4 36.15 4 35.23C4 34.31 4.74 33.57 5.66 33.57H13.68C14.6 33.57 15.34 34.31 15.34 35.23C15.34 35.7 15.14 36.12 14.83 36.42ZM50.94 36.85H58.74C59.66 36.85 60.4 37.59 60.41 38.51C60.41 39.43 59.67 40.17 58.75 40.17H54.26C54.56 40.47 54.74 40.88 54.74 41.34C54.74 42.26 54 43 53.08 43H50.94V36.85Z",fill:"#B8C0CC"}),s.jsx("path",{d:"M18.39 32.28H16.51V35.02H18.39V32.28Z",fill:"#9399A5"}),s.jsx("path",{d:"M46.87 15H20.69C18.38 15 16.5 16.88 16.5 19.19V26.22H18.38V23.45H49.18V47.68H18.38V41.07H16.5V49.55H51.05V19.19C51.06 16.88 49.18 15 46.87 15ZM39.46 20.73C38.81 20.73 38.29 20.2 38.29 19.56C38.29 18.92 38.82 18.39 39.46 18.39C40.11 18.39 40.63 18.92 40.63 19.56C40.63 20.2 40.11 20.73 39.46 20.73ZM43.22 20.73C42.57 20.73 42.05 20.2 42.05 19.56C42.05 18.92 42.58 18.39 43.22 18.39C43.87 18.39 44.39 18.92 44.39 19.56C44.39 20.2 43.87 20.73 43.22 20.73ZM46.97 20.73C46.32 20.73 45.8 20.2 45.8 19.56C45.8 18.92 46.33 18.39 46.97 18.39C47.62 18.39 48.14 18.92 48.14 19.56C48.14 20.2 47.62 20.73 46.97 20.73Z",fill:"#9399A5"})]});function vl(t,e){const n=b.get(t,e,"");if(n)throw new Error(n)}async function ww(t,e,n,r={}){const i={"X-Requested-With":"XMLHttpRequest","Content-Type":r.string?"application/x-www-form-urlencoded":"application/json",...r.headers},o={baseURL:t,method:"POST",url:e,params:r.params,headers:i};return o.data=r.string?JSON.stringify(n):n,rt(o).then(l=>l.data).catch(l=>Promise.reject(l))}const Cw=({conf:t,panelData:e})=>async()=>{const{expertSystemURL:n,path:r,goal:i,question:o}=t;if(!r||!i||!o)return;const l=$d(e);if(!l)return;const c={dashboard:i,panel:o,data:l};try{const u=n.startsWith("http")?n:window.location.origin;return await ww(u,`/expert/v3/devtable/${r}`,c,{})}catch(u){throw vl(u,"response.data.detail"),vl(u,"response.data.error"),console.error(u),u}},$r={expertSystemURL:"",path:"",goal:"",question:""},Br={height:"100%",overflowY:"auto",...sr},_l=({message:t})=>s.jsx(a.Box,{sx:Br,children:s.jsx("div",{dangerouslySetInnerHTML:{__html:t},style:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45"}})}),Sw=({error:t,width:e,height:n})=>{const r=t.message;if(r.startsWith("<"))return s.jsx(_l,{message:r});const o=n-25-20-30;return s.jsx(a.Center,{sx:{width:"100%",height:o},children:s.jsxs(a.Stack,{align:"center",spacing:20,children:[s.jsx(jw,{}),s.jsx(_l,{message:r})]})})};function kw({context:t}){const{value:e}=q(t.instanceData,"config"),n=m.useMemo(()=>b.defaultsDeep({},e,$r),[e]),{width:r,height:i}=t.viewport,o=t.data,{data:l,error:c,loading:u}=W.useRequest(Cw({conf:n,panelData:o}),{refreshDeps:[o,n]});return!r||!i||!n?null:u?s.jsx(a.Box,{sx:{position:"relative",height:i},children:s.jsx(a.LoadingOverlay,{visible:!0})}):c?s.jsx(a.Box,{sx:Br,"data-enable-scrollbar":!0,children:s.jsx(Sw,{error:c,width:r,height:i})}):!l||!Array.isArray(l.replies)||l.replies.length===0?null:s.jsx(a.Box,{sx:Br,"data-enable-scrollbar":!0,children:l.replies.map((d,p)=>s.jsx("div",{dangerouslySetInnerHTML:{__html:d.interpretation.html}},p))})}function Tw({context:t}){const{value:e,set:n}=q(t.instanceData,"config"),r=m.useMemo(()=>b.defaultsDeep({},e,$r),[e]),{control:i,handleSubmit:o,watch:l,getValues:c,reset:u}=y.useForm({defaultValues:r});m.useEffect(()=>{u(r)},[r]),l(["expertSystemURL","goal","path","question"]);const d=c(),p=m.useMemo(()=>!b.isEqual(d,r),[d,r]);return s.jsx("form",{onSubmit:o(n),children:s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:"expertSystemURL",control:i,render:({field:h})=>s.jsx(a.TextInput,{label:"Expert System URL",...h})}),s.jsx(y.Controller,{name:"path",control:i,render:({field:h})=>s.jsx(a.TextInput,{label:"Path",required:!0,...h})})]}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:"goal",control:i,render:({field:h})=>s.jsx(a.TextInput,{label:"Goal",required:!0,...h})}),s.jsx(y.Controller,{name:"question",control:i,render:({field:h})=>s.jsx(a.TextInput,{label:"Question",required:!0,...h})})]}),s.jsx(a.Divider,{variant:"dashed",mt:16,mb:8}),s.jsx(a.Button,{type:"submit",variant:"filled",color:"blue",leftIcon:s.jsx(L.DeviceFloppy,{size:20}),disabled:!p,sx:{alignSelf:"flex-end"},children:"Submit Changes"})]})})}const Dw=[{lang:"en",resources:{merico_gqm:{viz_name:"Merico GQM"}}},{lang:"zh",resources:{merico_gqm:{viz_name:"思码逸GQM组件"}}}];class zw extends ce{constructor(){super(...arguments);$(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const Mw={displayName:"viz.merico_gqm.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new zw,name:"mericoGQM",viewRender:kw,configRender:Tw,createConfig(){return{version:1,config:b.cloneDeep($r)}},translation:Dw};function Iw(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{calendar:i,heat_block:o,tooltip:l,...c}=t;return{...c,calendar:{...i,data_key:r(i.data_key)},heat_block:{...o,data_key:r(o.data_key)},tooltip:{...l,metrics:l.metrics.map(u=>({...u,data_key:r(u.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}function Ew(t){const{heat_block:e}=t;let{min:n,max:r}=e;return typeof n!="number"&&(n=0),typeof r!="number"&&(r=100),{...t,heat_block:{...e,min:{type:"static",value:n},max:{type:"static",value:r}}}}function Aw(t){const{visualMap:e=ft(),heat_block:{min:n,max:r,...i},...o}=t;return{...o,heat_block:i,visualMap:{...ft(),min:n,max:r}}}const Pw=[{lang:"en",resources:{calendar_heatmap:{viz_name:"Heatmap(Calendar)",calendar:{label:"Calendar",locale:"Langauge"},click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{calendar_heatmap:{viz_name:"日历热力图",calendar:{label:"日历",locale:"语言"},click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function $w(t){return s.jsx(s.Fragment,{})}function Bw(t){const{t:e}=_.useTranslation();return s.jsx(a.Text,{children:e("viz.calendar_heatmap.click_heatmap.heatblock.label")})}const jl={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.calendar_heatmap.click_heatmap.heatblock.label",nameRender:Bw,configRender:$w,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]},Lr={calendar:{data_key:"",locale:"EN"},heat_block:{name:"Value",data_key:"",value_formatter:_e},tooltip:{metrics:[]},visualMap:ft()};function Lw(t,e,n){if(!t)return n[0];try{return[e,I(e).add(1,"year").subtract(1,"day").valueOf()]}catch(r){return console.error(r),n[0]}}function qw(t,e,n){const r=Lw(t,e,n);return{top:50,left:25,right:5,cellSize:["auto",13],range:r,itemStyle:{borderColor:"#eee"},splitLine:{show:!0},dayLabel:{firstDay:1},monthLabel:{position:"end"},yearLabel:{show:!0}}}function Ow(t){return{heat_block:function(r){if(!t.heat_block.value_formatter)return r;try{return U(r,t.heat_block.value_formatter)}catch(i){return console.error(i),r}}}}function Vw(t,e){return{show:!t,selectedMode:"single",top:5,right:5,data:e.map(n=>({name:n,icon:"circle"}))}}function Nw(t,e,n){return t?{type:"heatmap",name:"heatmap",coordinateSystem:"calendar",calendarIndex:0,data:n}:Object.entries(e).map(([r,i])=>({type:"heatmap",name:r,coordinateSystem:"calendar",calendarIndex:0,data:i}))}const Gw=t=>U(t,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Fw({conf:t,valueFormatters:e,dataDict:n,params:r}){const{value:i}=r,[o,l]=i,u=[{label:t.heat_block.name,value:e.heat_block(l),style:{label:"",value:""}}],d=n[o];return d&&t.tooltip.metrics.forEach(p=>{const h=A(p.data_key);u.push({label:p.name,value:Gw(b.get(d,h.columnKey,"")),style:{label:"",value:""}})}),u}function Ww(t,e,n){const r=A(t.calendar.data_key),i=b.keyBy(e[r.queryID],r.columnKey);return te.getTooltip({formatter:function(o){const c=Fw({conf:t,valueFormatters:n,dataDict:i,params:o}).map(p=>`
303
+ `}}function c1(){return te.getTooltip({trigger:"item",formatter:l1()})}const u1={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function d1(e,t,n){n.reduce((a,l)=>{const c=jt(l,t);return a[l.name]=Re(l,c),a},{});const i={series:{data:i1(e,t),levels:o1(e)},tooltip:c1()};return v.defaultsDeep({},i,u1)}function p1({context:e}){const{variables:t}=e,{value:n}=$(e.instanceData,"config"),s=m.useMemo(()=>v.defaults({},n,Io),[n]),i=e.data,{width:a,height:l}=e.viewport,c=m.useMemo(()=>d1(s,i,t),[s,i,t]);return!a||!l?null:r.jsx(Ue,{width:a,height:l,children:r.jsx(Pe,{echarts:Ae,option:c,style:gr(a,l),notMerge:!0,theme:"merico-light"})})}function h1({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["label_key","value_key","group_key"]),r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:"label_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.name_data_field"),required:!0,...s})}),r.jsx(b.Controller,{name:"value_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.value_data_field"),required:!0,...s})}),r.jsx(b.Controller,{name:"group_key",control:e,render:({field:s})=>r.jsx(F,{label:n("viz.sunburst_chart.group_key"),clearable:!0,...s})})]})}const f1=({control:e,index:t})=>{const{t:n,i18n:s}=_.useTranslation(),i=m.useMemo(()=>[{label:n("viz.sunburst_chart.label.rotate.radial"),value:"radial"},{label:n("viz.sunburst_chart.label.rotate.tangential"),value:"tangential"},{label:n("viz.sunburst_chart.label.rotate.none"),value:"0"}],[s.language]);return r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`levels.${t}.r0`,control:e,render:({field:a})=>r.jsx(o.TextInput,{label:n("viz.sunburst_chart.level.inside_radius"),placeholder:"0%",...a})}),r.jsx(b.Controller,{name:`levels.${t}.r`,control:e,render:({field:a})=>r.jsx(o.TextInput,{label:n("viz.sunburst_chart.level.outside_radius"),placeholder:"50%",...a})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:n("chart.label.label_full"),labelPosition:"center"}),r.jsx(b.Controller,{name:`levels.${t}.label.show_label_tolerance`,control:e,render:({field:a})=>r.jsx(o.NumberInput,{label:n("viz.sunburst_chart.label.show_label_tolerance"),precision:4,step:5e-4,min:0,max:1,...a})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`levels.${t}.label.rotate`,control:e,render:({field:a})=>r.jsx(o.Select,{label:n("viz.sunburst_chart.label.rotate.label"),data:i,...a})}),r.jsx(b.Controller,{name:`levels.${t}.label.align`,control:e,render:({field:a})=>r.jsx(yn,{...a})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`levels.${t}.label.position`,control:e,render:({field:a})=>r.jsx(tr,{label:n("chart.label_position.label"),...a,onChange:l=>{l&&a.onChange(l)}})}),r.jsx(b.Controller,{name:`levels.${t}.label.padding`,control:e,render:({field:a})=>r.jsx(o.NumberInput,{label:n("chart.padding"),min:0,hideControls:!0,...a})})]})]})},m1=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),r0:"",r:"",label:{show_label_tolerance:.001,rotate:"0",align:"center",position:"inside",padding:0}}),i=(a,l)=>l+1;return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("viz.sunburst_chart.level.hint")})]}),r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(fe,{control:e,watch:t,name:"levels",getItem:s,addButtonText:n("viz.sunburst_chart.level.add"),deleteButtonText:n("viz.sunburst_chart.level.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(f1,{control:e,index:l})})]})};function g1({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=m.useMemo(()=>v.defaultsDeep({},n,Io),[n]),a=m.useMemo(()=>v.clone(i),[i]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]);const h=d(),f=m.useMemo(()=>!v.isEqual(h,i),[h,i]);u(["label_key","value_key","group_key","levels"]);const[g,y]=m.useState("Data");return r.jsx("form",{onSubmit:c(s),children:r.jsxs(o.Stack,{spacing:"xs",children:[r.jsx(Ce,{canSubmit:f}),r.jsxs(o.Tabs,{value:g,onTabChange:y,orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"Data",children:t("data.label")}),r.jsx(o.Tabs.Tab,{value:"Levels",children:t("viz.sunburst_chart.level.labels")})]}),r.jsx(o.Tabs.Panel,{value:"Data",children:r.jsx(h1,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Levels",children:r.jsx(m1,{control:l,watch:u})})]})]})})}const x1=[{lang:"en",resources:{sunburst_chart:{viz_name:"Sunburst Chart",level:{labels:"Levels",hint:"Configure ring style on each level",inside_radius:"Inside Radius",outside_radius:"Outside Radius",add:"Add a level",delete:"Delete this level"},label:{show_label_tolerance:"Hide label when its percentage is less than...",rotate:{label:"Rotate",radial:"Radial",tangential:"Tangential",none:"None"}},group_key:"Group Key"}}},{lang:"zh",resources:{sunburst_chart:{viz_name:"旭日图",level:{labels:"层级",hint:"为每层配置圆环样式",inside_radius:"内径",outside_radius:"外径",add:"增加一层",delete:"删除这一层"},label:{show_label_tolerance:"当百分比低于此值时,隐藏文案",rotate:{label:"旋转",radial:"径向旋转",tangential:"切向旋转",none:"不旋转"}},group_key:"分组字段"}}}];function y1(e){const{label_field:t,value_field:n,...s}=e;return{...s,label_key:t,value_key:n}}function b1(e){const{group_key:t="",...n}=e;return{...n,group_key:t}}function v1(e){const{levels:t=[],...n}=e;return{...n,levels:t}}function _1(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{label_key:i,value_key:a,group_key:l,...c}=e;return{...c,label_key:s(i),value_key:s(a),group_key:s(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class j1 extends ge{constructor(){super(...arguments);B(this,"VERSION",5)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:y1(n.config)})),this.version(3,n=>({...n,version:3,config:b1(n.config)})),this.version(4,n=>({...n,version:4,config:v1(n.config)})),this.version(5,(n,s)=>({...n,version:5,config:_1(n.config,s)}))}}const w1={displayName:"viz.sunburst_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new j1,name:"sunburst",viewRender:p1,configRender:g1,createConfig(){return{version:5,config:v.cloneDeep(Io)}},translation:x1};var Mt=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e.url="url",e.custom="custom",e))(Mt||{});const rh=["function text({ value, row_data }, utils) {"," return value","}"].join(`
304
+ `),sh={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",query_id:"",striped:!0,use_raw_columns:!0,ignored_column_keys:"",verticalSpacing:"14px"},ih={left:"flex-start",center:"center",right:"flex-end"},C1=({header:e,cx:t})=>{const n=v.get(e.column.columnDef.meta,"align","left");return r.jsxs(o.Text,{className:t("table-head-cell",{"table-head-cell--sortable":e.column.getCanSort()}),onClick:e.column.getToggleSortingHandler(),align:n,sx:{justifyContent:ih[n]},children:[e.isPlaceholder?null:bt.flexRender(e.column.columnDef.header,e.getContext()),r.jsx(S1,{direction:e.column.getIsSorted()})]})},S1=({direction:e})=>{switch(e){case"asc":return r.jsx(M.IconArrowUp,{size:16});case"desc":return r.jsx(M.IconArrowDown,{size:"1em"});default:return null}},k1=o.createStyles(e=>({root:{overflow:"auto",position:"relative","& .table-head-cell":{display:"flex",flexFlow:"row nowrap",alignItems:"center",whiteSpace:"nowrap","&.table-head-cell--sortable":{cursor:"pointer",userSelect:"none"}},"&.table-highlight-on-hover tr":{transition:"background-color 0.2s","&:hover":{backgroundColor:e.colorScheme==="dark"?e.colors.dark[5]:e.colors.gray[0]}}},thead:{background:e.colorScheme==="dark"?e.colors.dark[7]:e.white,position:"sticky",top:24,transform:"translateY(-1px)",zIndex:10},info_bar:{position:"sticky",top:0,left:0,right:0,zIndex:10,background:"white"}})),T1={tableLayout:"fixed",width:"fit-content",minWidth:"100%","thead, tbody":{tr:{width:"fit-content",th:{position:"relative"},"th, td":{padding:"2px 10px",div:{overflow:"hidden",textOverflow:"ellipsis"},"&:first-of-type":{paddingLeft:2,paddingRight:2}}}},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",transform:"translateY(-50%)",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}},ah=o.createStyles((e,t)=>({content:{display:"flex",alignItems:"center",justifyContent:ih[t.align],".table-cell-text":{whiteSpace:"nowrap",cursor:t.clickable?"pointer":"default",textDecoration:t.clickable?"underline":"none"}}}));function D1(e){return e?Qt(e).oklch()[0]>.7?"black":"white":"inherit"}function oh(e){const t=e.tableCellContext.bgColor;return{backgroundColor:t,color:D1(t)}}function rr(e){const t=e.tableCellContext.isClickable(),n=ah({clickable:t,align:e.align});return r.jsx("div",{className:n.classes.content,style:{...oh(e)},children:r.jsx(o.Text,{className:"table-cell-text",onClick:e.tableCellContext.getClickHandler(),children:r.jsx("span",{title:e.children,children:e.children})})})}function M1(e){return r.jsx(rr,{...e,children:e.value})}function z1(e){const t=ah({clickable:!0,align:e.align}),n=e.value;return r.jsx("div",{className:t.classes.content,style:{...oh(e)},children:r.jsx(o.Anchor,{className:"table-cell-text",href:n,target:"_blank",color:"black",children:n})})}function I1(e){const t=U(e.value,{output:"number",average:!0,mantissa:2,trimMantissa:!0,absolute:!1});return r.jsx(rr,{...e,children:t})}function E1(e){const t=U(e.value,{output:"number",mantissa:0,thousandSeparated:!0,absolute:!1});return r.jsx(rr,{...e,children:t})}function A1(e){const t=U(e.value,{output:"percent",mantissa:3,trimMantissa:!0,absolute:!1});return r.jsx(rr,{...e,children:t})}function P1(e){const{value:t,row_data:n,func_content:s}=e;if(!s)return r.jsx(rr,{...e,children:t});const i=new Function(`return ${s}`)()({value:t,row_data:n},vt);return r.jsx(rr,{...e,children:i})}function O1(e){switch(e.type){case Mt.string:return r.jsx(M1,{...e});case Mt.eloc:return r.jsx(I1,{...e});case Mt.number:return r.jsx(E1,{...e});case Mt.percentage:return r.jsx(A1,{...e});case Mt.url:return r.jsx(z1,{...e});case Mt.custom:return r.jsx(P1,{...e})}}function L1({tableContainerRef:e,rows:t}){var c,u;const n=Mm.useVirtual({parentRef:e,size:t.length,estimateSize:m.useCallback(()=>28,[]),overscan:20}),{virtualItems:s,totalSize:i}=n,a=s.length>0&&((c=s==null?void 0:s[0])==null?void 0:c.start)||0,l=s.length>0?i-(((u=s==null?void 0:s[s.length-1])==null?void 0:u.end)||0):0;return r.jsxs("tbody",{children:[a>0&&r.jsx("tr",{children:r.jsx("td",{style:{height:`${a}px`}})}),s.map(d=>{const p=t[d.index];return r.jsx("tr",{children:p.getVisibleCells().map(h=>r.jsx("td",{children:bt.flexRender(h.column.columnDef.cell,h.getContext())},h.id))},p.id)}),l>0&&r.jsx("tr",{children:r.jsx("td",{style:{height:`${l}px`}})})]})}const Eo={id:"builtin:table:click-cell-content",displayName:"viz.table.click_cell.click_cell_content",nameRender:N1,configRender:q1,payload:[{name:"row_index",description:"Index of the row that the cell belongs to",valueType:"number"},{name:"col_index",description:"Index of the column that the cell belongs to",valueType:"number"},{name:"row_data",description:"Data of the row that the cell belongs to",valueType:"object"}]},B1={column:""};function lh(e,t){const{value:n}=$(e.instanceData,"config"),s={columnsFromConfig:[],columnsFromData:[]};if(n&&(s.columnsFromConfig=n.columns.map((i,a)=>({label:i.label,value:a.toString()}))),!t)return s;if(n!=null&&n.query_id){const i=t[n.query_id];(i==null?void 0:i.length)>0&&(s.columnsFromData=Object.keys(i[0]).map(a=>({label:a,value:a})))}return s}function ch(e){const{value:t}=$(e.instanceData,"config");return(t==null?void 0:t.use_raw_columns)??!1}function q1(e){const{t}=_.useTranslation(),{columnsFromConfig:n,columnsFromData:s}=lh(e.instance,e.sampleData),i=ch(e.instance),a=n.length>0?n:s,{value:l,set:c}=$(e.trigger.triggerData,"config"),{column:u}=v.defaults({},l,B1),d=p=>{isNaN(+p)?c({column:p}):c({column:+p})};return i?r.jsxs(o.Stack,{children:[r.jsx(o.Alert,{icon:r.jsx(M.IconAlertCircle,{size:"1rem"}),color:"gray",children:r.jsxs(_.Trans,{i18nKey:"viz.table.click_cell.why_column_data_field",children:["Option ",r.jsx(o.Mark,{children:"Use original data columns"})," is enabled, you have to address trigger column by its data field"]})}),r.jsx(o.TextInput,{label:t("viz.table.click_cell.column_data_field"),value:u.toString(),onChange:p=>d(p.currentTarget.value)})]}):r.jsx(o.Select,{clearable:!1,data:a,label:t("viz.table.click_cell.choose_a_column"),value:u.toString(),onChange:d})}function V1(e,t,n){const{t:s}=_.useTranslation();return e?v.isNumber(e.column)?n?s("viz.table.click_cell.click_cell_of_x_th",{x:e.column+1}):s("viz.table.click_cell.click_cell_of_x",{x:t[e.column].label}):s("viz.table.click_cell.click_cell_of_x",{x:e.column}):s("viz.table.click_cell.click_cell_content")}function N1(e){const{columnsFromConfig:t}=lh(e.instance),{value:n}=$(e.trigger.triggerData,"config"),s=ch(e.instance);return r.jsx(o.Text,{children:V1(n,t,s)})}function uh(e,t,n){return Math.min(Math.max(e,t),n)}class $1{constructor(t){this.steps=t;const n=[],s=new Set;for(const i of t)s.has(i.to)||(n.push(i),s.add(i.to));if(n.sort((i,a)=>i.from-a.from),n.length<2)throw new Error("MultiStepValueMapper requires at least 2 steps");this.steps=n}getLinearFunction(t,n){const s=(n.to-t.to)/(n.from-t.from),i=t.to-s*t.from;return a=>s*a+i}getStepFunctionForValue(t){let n=v.findLastIndex(this.steps,s=>s.from<=t);return n=uh(n,0,this.steps.length-2),this.getLinearFunction(this.steps[n],this.steps[n+1])}mapValue(t){return uh(this.getStepFunctionForValue(t)(t),0,100)}}class F1{constructor(t,n,s,i,a){this.getColIndex=t,this.cell=n,this.triggers=s,this.interactionManager=i,this.colorManager=a}getClickHandler(){const t=this.getRelatedTrigger();if(t.length!==0)return()=>{const n={row_data:this.cell.row.original,row_index:this.cell.row.index,col_index:this.getColIndex(this.cell)};for(const s of t)this.interactionManager.runInteraction(s.id,n)}}getRelatedTrigger(){return this.triggers.filter(n=>n.schemaRef===Eo.id).filter(n=>{const s=this.getColIndex(this.cell),i=v.get(this.cell.column.columnDef.meta,"value_field"),a=v.get(n.config,"column");return a==s||a==i})}isClickable(){return this.getRelatedTrigger().length>0}get columnConf(){return this.cell.column.columnDef.meta}get bgColor(){const t=this.columnConf.cellBackgroundColor;if(!t||t==="none")return;if(v.isString(t))return t;const n=+this.cell.getValue();if(isFinite(n)){const s=this.colorManager.decodeInterpolation(t.interpolation),a=new $1(t.steps).mapValue(n);return s==null?void 0:s.getColor(a)}}}const G1=e=>{const t=rt(e),n=nt(t.triggerManager,Eo.id),{colorManager:s}=m.useContext(Gt);return m.useCallback(i=>new F1(e.getColIndex,i,n,t,s),[n,t,e.getColIndex])};function dh({queryData:e,width:t,height:n,conf:s,context:i,instance:a}){const{t:l}=_.useTranslation(),{use_raw_columns:c,ignored_column_keys:u,columns:d,...p}=s,{classes:h,cx:f}=k1(),g=m.useMemo(()=>{if(!c)return d;if(!Array.isArray(e)||e.length===0)return[];let ie=Object.keys(e[0]);const Ie=new Set(u==null?void 0:u.split(/\r?\n|\r|\n/g).filter(xe=>!!xe));return Ie.size>0&&(ie=ie.filter(xe=>!Ie.has(xe))),ie.map(xe=>({id:xe,label:xe,value_field:xe,value_type:Mt.string,align:"left",width:"",cellBackgroundColor:""}))},[c,u,d,e]),y=G1({getColIndex:m.useCallback(ie=>g.indexOf(ie.column.columnDef.meta),[g]),vizManager:i.vizManager,instance:a}),j=m.useMemo(()=>{const ie=bt.createColumnHelper();return g.map(xe=>{const se=Sg(xe.value_field);return ie.accessor(se.columnKey,{cell:Fe=>r.jsx(O1,{tableCellContext:y(Fe.cell),value:Fe.getValue(),type:xe.value_type,row_data:Fe.row.original,...xe}),header:xe.label,enableSorting:!0,meta:xe,size:typeof xe.width=="number"?xe.width:void 0,minSize:typeof xe.width=="number"?xe.width:void 0})})},[g,y]),[k,S]=m.useState([]),T=bt.useReactTable({data:e,state:{sorting:k},onSortingChange:S,columns:j,columnResizeMode:"onChange",getCoreRowModel:bt.getCoreRowModel(),getSortedRowModel:bt.getSortedRowModel()}),{rows:z}=T.getRowModel(),I=m.useRef(null),E=z.length,N=E>0,R=N?n-22:n,pe=N?22:0;return r.jsxs("div",{ref:I,style:{height:n,width:t,padding:"0 5px"},"data-enable-scrollbar":!0,className:f(h.root,{"table-highlight-on-hover":s.highlightOnHover}),children:[E>0&&r.jsx(o.Box,{className:h.info_bar,sx:{height:22},children:r.jsx(o.Text,{align:"right",pr:6,size:14,color:"dimmed",fw:"normal",children:l("common.pagination.total_rows",{total:E})})}),r.jsxs(o.Table,{sx:{...T1,maxHeight:R},...p,striped:s.striped,children:[r.jsx("thead",{className:h.thead,style:{top:pe},children:T.getHeaderGroups().map(ie=>r.jsx("tr",{children:ie.headers.map(Ie=>r.jsxs("th",{style:{width:Ie.getSize()},children:[r.jsx(C1,{header:Ie,cx:f}),r.jsx(o.ActionIcon,{onMouseDown:Ie.getResizeHandler(),onTouchStart:Ie.getResizeHandler(),className:`resizer ${Ie.column.getIsResizing()?"isResizing":""}`,children:r.jsx(M.IconArrowBarToRight,{})})]},Ie.id))},ie.id))}),r.jsx(L1,{tableContainerRef:I,rows:z})]})]})}function ph(){const{t:e}=_.useTranslation();return r.jsx(o.Text,{color:"gray",align:"center",children:e("data.empty_data")})}function W1({data:e,width:t,height:n,conf:s,context:i,instance:a}){const{t:l}=_.useTranslation(),{panel:c}=Lt(),u=c.firstQueryData??[];if(c.queryIDs.length===0)return r.jsx(o.Text,{color:"gray",align:"center",children:l("panel.settings.need_to_choose_queries")});const{query_id:d}=s;if(!d)return u.length===0?r.jsx(ph,{}):r.jsx(dh,{queryData:u,width:t,height:n,conf:{...s,use_raw_columns:!0,columns:[]},context:i,instance:a});const p=e[d];return!Array.isArray(p)||p.length===0?r.jsx(ph,{}):r.jsx(dh,{queryData:p,width:t,height:n,conf:s,context:i,instance:a})}function R1({context:e,instance:t}){const n=e.data,{height:s,width:i}=e.viewport,{value:a}=$(e.instanceData,"config");return a?r.jsx(W1,{data:n,width:i,height:s,conf:a,context:e,instance:t}):null}const Q1=D.observer(m.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,clearable:a=!1,sx:l,...c},u)=>{const{panel:d}=Ge(),p=m.useMemo(()=>d.queryOptions(s,a),[s,a]);return p.length===0?r.jsx(o.Box,{children:r.jsx(o.TextInput,{label:e,required:t,defaultValue:s,readOnly:!0,disabled:!0})}):r.jsx(o.Select,{ref:u,label:e,description:n,data:p,value:s,onChange:i,required:t,sx:l,maxDropdownHeight:500,...c})})),U1=[{from:0,to:0},{from:100,to:100}];function hh(e){return e?v.isString(e)?e==="none"?"none":"static":"interpolation":"none"}function Y1(e,t){var n;return hh(t)==="static"?t:(n=e.getStaticColors()[0])==null?void 0:n.value}function K1(e,t){return v.isObject(t)?t:{steps:U1,interpolation:e.encodeColor(e.getColorInterpolations()[0])}}const X1=m.forwardRef((e,t)=>{const{t:n}=_.useTranslation(),{colorManager:s}=m.useContext(Gt),[i,a]=m.useState(hh(e.value)),[l,c]=m.useState(Y1(s,e.value)),u=W.useLatest(l),[d,p]=m.useState(K1(s,e.value)),h=W.useLatest(d),f=j=>{var k,S,T;a(j||"none"),j==="static"?(k=e.onChange)==null||k.call(e,u.current):j==="none"||!j?(S=e.onChange)==null||S.call(e,"none"):(T=e.onChange)==null||T.call(e,h.current)},g=j=>{var k;c(j),(k=e.onChange)==null||k.call(e,j)},y=j=>{var k;p(j),(k=e.onChange)==null||k.call(e,j)};return r.jsxs(o.Stack,{align:"stretch",children:[r.jsx(Qy,{label:n("viz.table.column.cell_background"),value:i||"none",onChange:f}),i==="static"&&r.jsx(Le,{value:l,onChange:g}),i==="interpolation"&&r.jsx(Ry,{colorManager:s,value:d,onChange:y})]})}),J1=m.forwardRef(({value:e,onChange:t,sx:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=m.useMemo(()=>Object.values(Mt).map(c=>({label:i(`viz.table.column.value_type.${c}`),value:c})),[a.language]);return r.jsx(o.Select,{ref:s,label:i("viz.table.column.value_type.label"),data:l,value:e,onChange:t,maxDropdownHeight:500,sx:n})}),Z1=m.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),[i,{setTrue:a,setFalse:l}]=W.useBoolean(),[c,u]=m.useState(e),d=()=>{l(),t(c)},p=()=>{l(),u(e)},h=()=>{u(rh)};return m.useEffect(()=>{u(e)},[e]),r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:a,sx:{flexGrow:0},children:s("viz.table.column.custom_cell_content")}),r.jsx(o.Modal,{size:800,title:s("viz.table.column.custom_cell_content"),opened:i,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:i&&r.jsxs(o.Stack,{children:[r.jsx(o.Group,{position:"left",children:r.jsx(zp,{})}),r.jsx(o.Box,{sx:{position:"relative"},children:r.jsx(tt,{height:"500px",defaultLanguage:"javascript",value:c,onChange:f=>u(f??""),theme:"vs-dark",options:{minimap:{enabled:!1}}})}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:h,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:s("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:p,variant:"subtle",children:s("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:d,children:s("common.actions.save")})]})]})]})})]})}),Ao=()=>r.jsx(o.Text,{color:"dimmed",size:12,children:"px"}),H1=({control:e,index:t,watch:n,remove:s,column:i})=>{const{t:a}=_.useTranslation(),l=n(`columns.${t}.value_type`),c=n("query_id");return r.jsxs(o.Stack,{my:0,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`columns.${t}.label`,control:e,render:({field:u})=>r.jsx(o.TextInput,{label:a("chart.label.label"),required:!0,id:`col-label-${t}`,sx:{flex:1},...u})}),r.jsx(b.Controller,{name:`columns.${t}.value_field`,control:e,render:({field:u})=>r.jsx(F,{label:a("common.data_field"),required:!0,queryID:c,...u})})]}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`columns.${t}.value_type`,control:e,render:({field:u})=>r.jsx(J1,{sx:{flex:1},...u})}),l===Mt.custom&&r.jsx(b.Controller,{name:`columns.${t}.func_content`,control:e,render:({field:u})=>r.jsx(Z1,{value:u.value??rh,onChange:d=>u.onChange(d??"")})})]}),r.jsx(o.Divider,{mb:-10,variant:"dashed",label:a("style.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(o.NumberInput,{hideControls:!0,label:a("viz.table.column.min_width"),rightSection:r.jsx(Ao,{}),disabled:!0}),r.jsx(b.Controller,{name:`columns.${t}.width`,control:e,render:({field:u})=>r.jsx(o.NumberInput,{hideControls:!0,label:a("viz.table.column.width"),rightSection:r.jsx(Ao,{}),...u})}),r.jsx(o.NumberInput,{hideControls:!0,label:a("viz.table.column.max_width"),rightSection:r.jsx(Ao,{}),disabled:!0})]}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:`columns.${t}.align`,control:e,render:({field:u})=>r.jsx(ps,{...u})})}),r.jsx(b.Controller,{name:`columns.${t}.cellBackgroundColor`,control:e,render:({field:u})=>r.jsx(X1,{...u})}),r.jsx(o.Divider,{mb:4,mt:12,variant:"dashed"}),r.jsx(o.Button,{leftIcon:r.jsx(V.Trash,{size:16}),color:"red",variant:"light",onClick:()=>s(t),children:a("viz.table.column.delete")})]})},eD=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),{fields:s,append:i,remove:a,update:l}=b.useFieldArray({control:e,name:"columns"}),c=()=>{const d=he.randomId();i({id:d,label:d,align:"center",value_field:"",value_type:Mt.string,width:""})};t(["columns","ignored_column_keys"]);const u=t("use_raw_columns");return r.jsxs(r.Fragment,{children:[r.jsx(b.Controller,{name:"use_raw_columns",control:e,render:({field:d})=>r.jsx(o.Switch,{mt:20,mb:20,label:n("viz.table.column.use_original_data_columns"),checked:d.value,onChange:p=>d.onChange(p.currentTarget.checked)})}),u&&r.jsx(b.Controller,{name:"ignored_column_keys",control:e,render:({field:d})=>r.jsx(o.Textarea,{label:n("viz.table.column.ignore_columns_by_these_key"),placeholder:n("viz.table.column.separate_by_line_break"),autosize:!0,minRows:2,maxRows:10,...d})}),!u&&r.jsx(o.Stack,{children:r.jsxs(o.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[r.jsxs(o.Tabs.List,{children:[s.map((d,p)=>r.jsx(o.Tabs.Tab,{value:p.toString(),children:p+1},d.id)),r.jsx(o.Tabs.Tab,{onClick:c,value:"add",children:r.jsx(V.Plus,{size:18,color:"#228be6"})})]}),s.map((d,p)=>r.jsx(o.Tabs.Panel,{value:p.toString(),children:r.jsx(H1,{control:e,watch:t,index:p,column:d,remove:a})},d.id))]})})]})};function tD({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["horizontalSpacing","verticalSpacing","fontSize","striped","highlightOnHover"]),r.jsxs(o.Stack,{spacing:"xs",children:[r.jsxs(o.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[r.jsx(b.Controller,{name:"horizontalSpacing",control:e,render:({field:s})=>r.jsx(Ua,{disabled:!0,label:n("viz.table.style.horizontal_spacing"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"verticalSpacing",control:e,render:({field:s})=>r.jsx(Ua,{disabled:!0,label:n("viz.table.style.vertical_spacing"),sx:{flex:1},...s})})]}),r.jsx(o.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:r.jsx(b.Controller,{name:"fontSize",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("style.font_size.label"),placeholder:n("style.font_size.placeholder"),required:!0,sx:{flex:1},...s})})}),r.jsxs(o.Group,{position:"apart",grow:!0,children:[r.jsx(b.Controller,{name:"striped",control:e,render:({field:s})=>r.jsx(o.Switch,{label:n("viz.table.style.striped"),checked:s.value,onChange:i=>s.onChange(i.currentTarget.checked)})}),r.jsx(b.Controller,{name:"highlightOnHover",control:e,render:({field:s})=>r.jsx(o.Switch,{label:n("viz.table.style.highlight_on_hover"),checked:s.value,onChange:i=>s.onChange(i.currentTarget.checked)})})]})]})}function nD({columns:e,...t}){return{...t,columns:e.map(({id:n,...s})=>({id:n??he.randomId(),...s}))}}function rD({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=m.useMemo(()=>v.defaultsDeep({},n,sh),[n]),a=m.useMemo(()=>nD(i),[i]);m.useEffect(()=>{!v.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),s(a))},[i,a]);const{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]);const h=d(),f=m.useMemo(()=>!v.isEqual(h,i),[h,i]);return u(["query_id"]),r.jsxs("form",{onSubmit:c(s),children:[r.jsx(Ce,{canSubmit:f}),r.jsxs(o.Tabs,{defaultValue:"Columns",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"Columns",children:t("viz.table.column.labels")}),r.jsx(o.Tabs.Tab,{value:"Style",children:t("style.label")})]}),r.jsxs(o.Tabs.Panel,{value:"Columns",children:[r.jsx(b.Controller,{name:"query_id",control:l,render:({field:g})=>r.jsx(Q1,{label:t("viz.table.column.query_id"),description:t("viz.table.column.query_id_hint"),required:!0,...g})}),r.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(eD,{control:l,watch:u})]}),r.jsx(o.Tabs.Panel,{value:"Style",children:r.jsx(tD,{control:l,watch:u})})]})]})}const sD=[{lang:"en",resources:{table:{viz_name:"Table",column:{labels:"Columns",delete:"Delete this column",query_id:"Query",query_id_hint:"Load table data from this query",use_original_data_columns:"Use original data columns",ignore_columns_by_these_key:"Ignore columns by these keys",separate_by_line_break:"Separate by line break",width:"Width",min_width:"Min Width",max_width:"Max Width",cell_background:"Cell background",custom_cell_content:"Custom cell content",value_type:{label:"Value Type",string:"String",number:"Number",percentage:"Percentage",eloc:"ELOC",url:"URL",custom:"Custom"}},style:{horizontal_spacing:"Horizontal Spacing",vertical_spacing:"Vertical Spacing",striped:"Striped",highlight_on_hover:"Hightlight on hover"},click_cell:{label:"Click cell content",click_cell_content:"Click cell content (click to config)",click_cell_of_x:"Click cell of {{ x }}",click_cell_of_x_th:"Click cell by column order {{ x }}",choose_a_column:"Choose a column",why_column_data_field:"Option <1>Use original data columns</1> is enabled, you have to address trigger column by its data field",column_data_field:"Column data field"}}}},{lang:"zh",resources:{table:{viz_name:"表格",column:{labels:"列设置",delete:"删除这个列",query_id:"表格数据来源",query_id_hint:"通过所选的查询获取表格数据",use_original_data_columns:"使用数据本身的列",ignore_columns_by_these_key:"按下述列名忽略列",separate_by_line_break:"以换行符分隔",width:"宽度",min_width:"最小宽度",max_width:"最大宽度",cell_background:"单元格背景",custom_cell_content:"自定义单元格内容",value_type:{label:"数据类型",string:"文本",number:"数字",percentage:"百分比",eloc:"ELOC",url:"URL",custom:"自定义"}},style:{horizontal_spacing:"水平间距",vertical_spacing:"垂直间距",striped:"隔行变色",highlight_on_hover:"鼠标悬停时高亮整行"},click_cell:{label:"点击单元格",click_cell_content:"点击单元格内容",click_cell_of_x:"点击 {{ x }} 列单元格",click_cell_of_x_th:"点击第 {{ x }} 列单元格",choose_a_column:"选择列",why_column_data_field:"选项 <1>使用数据本身的列</1> 已开启,只能通过填写数据字段来指定触发动作的列",column_data_field:"列的数据字段"}}}}];function iD(e){const{columns:t,...n}=e;return{...e,columns:t.map(s=>({...s,align:s.align??"left"}))}}function aD(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=c=>c&&`${n}.${c}`,{id_field:i,columns:a,...l}=e;return{...l,id_field:s(i),columns:a.map(c=>({...c,value_field:s(c.value_field)}))}}catch(n){throw console.error("[Migration failed]",n),n}}function oD(e){const{columns:t,...n}=e;return{...n,columns:t.map(s=>({...s,align:s.align??"left",cellBackgroundColor:s.cellBackgroundColor??"",width:s.width??""}))}}function lD(e){const{id_field:t,...n}=e,{queryID:s}=O(t);return{...n,query_id:s??""}}function cD(e){const{ignored_column_keys:t,...n}=e;return{...n,ignored_column_keys:t??""}}class uD extends ge{constructor(){super(...arguments);B(this,"VERSION",7)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>{const{columns:s,...i}=n.config;return{...n,version:2,config:{...i,columns:s.map(({id:a,...l})=>({id:a??he.randomId(),...l}))}}}),this.version(3,n=>({...n,version:3,config:iD(n.config)})),this.version(4,(n,s)=>({...n,version:4,config:aD(n.config,s)})),this.version(5,n=>({...n,version:5,config:oD(n.config)})),this.version(6,n=>({...n,version:6,config:lD(n.config)})),this.version(7,n=>({...n,version:7,config:cD(n.config)}))}}const Po={createConfig(){return{version:7,config:v.cloneDeep(sh)}},displayName:"viz.table.viz_name",displayGroup:"chart.groups.others",migrator:new uD,name:"table",viewRender:R1,configRender:rD,triggers:[Eo],translation:sD},fh=["function text({ data, variables, filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
305
+ `),Oo={func_content:fh,horizontal_align:"left",font_size:"14px",font_weight:"normal"},dD=D.observer(({context:e})=>{const t=_e(),{value:n=Oo}=$(e.instanceData,"config"),{variables:s}=e,i=e.data,{func_content:a,horizontal_align:l,font_size:c,font_weight:u}=n,d=m.useMemo(()=>s.reduce((h,f)=>{const g=jt(f,i);return h[f.name]=Re(f,g),h},{}),[s,i]),p=m.useMemo(()=>new Function(`return ${a}`)()({data:i,variables:d,filters:t.payloadForSQL.filters,context:t.payloadForSQL.context}),[a,i,d,t.payloadForSQL]);return r.jsx(o.Text,{align:l,weight:u,sx:{fontSize:c},children:p})}),ni=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function pD({label:e,value:t,onChange:n},s){var l;const[i,a]=m.useState(((l=ni.find(c=>c.label===t))==null?void 0:l.value)??ni[0].value);return m.useEffect(()=>{const c=ni.find(u=>u.value===i);c&&n(c.label)},[i]),r.jsxs(o.Stack,{spacing:0,mt:"sm",mb:"lg",children:[r.jsx(o.Text,{size:"sm",children:e}),r.jsx(o.Box,{px:"1.5em",children:r.jsx(o.Slider,{label:null,marks:ni,value:i,onChange:a,step:25,ref:s})})]})}const mh=m.forwardRef(pD),hD=({value:e,onChange:t})=>{const n=s=>{s&&t(s)};return r.jsx(o.Box,{sx:{position:"relative"},children:r.jsx(tt,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},fD=m.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),[i,{setTrue:a,setFalse:l}]=W.useBoolean(),[c,u]=m.useState(e),d=()=>{l(),t(c)},p=()=>{l(),u(e)},h=()=>{u(fh)};return m.useEffect(()=>{u(e)},[e]),r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:r.jsx(M.IconMathFunction,{size:16}),mt:24,onClick:a,sx:{flexGrow:0},children:s("viz.text.content.edit")}),r.jsx(o.Modal,{size:800,title:s("viz.text.content.label"),opened:i,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:i&&r.jsxs(o.Stack,{children:[r.jsx(hD,{value:c,onChange:u}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:h,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:s("common.actions.reset_to_default")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:p,variant:"subtle",children:s("common.actions.cancel")}),r.jsx(o.Button,{color:"green",leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),onClick:d,children:s("common.actions.save_changes")})]})]})]})})]})});function mD({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=m.useMemo(()=>v.defaultsDeep({},n,Oo),[n]),a=m.useMemo(()=>{const{func_content:g,horizontal_align:y,font_size:j,font_weight:k}=i;return{func_content:g,horizontal_align:y,font_size:j,font_weight:k}},[i]);m.useEffect(()=>{!v.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),s(a))},[i,a]);const{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]),u(["func_content","horizontal_align","font_size","font_weight"]);const h=d(),f=m.useMemo(()=>!v.isEqual(h,i),[h,i]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:c(s),children:[r.jsx(Ce,{canSubmit:f}),r.jsxs(o.Stack,{spacing:10,children:[r.jsx(b.Controller,{name:"func_content",control:l,render:({field:g})=>r.jsx(fD,{...g})}),r.jsx(o.Divider,{mt:10,mb:-10,variant:"dashed",label:t("chart.style.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"horizontal_align",control:l,render:({field:g})=>r.jsx(ps,{...g})}),r.jsx(b.Controller,{name:"font_size",control:l,render:({field:g})=>r.jsx(o.TextInput,{label:t("style.font_size.label"),placeholder:t("style.font_size.placeholder"),sx:{flex:1},...g})}),r.jsx(o.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:r.jsx(b.Controller,{name:"font_weight",control:l,render:({field:g})=>r.jsx(mh,{label:t("style.font_weight.label"),...g})})})]})]})})}const gD=[{lang:"en",resources:{text:{viz_name:"Text",content:{label:"Text content",edit:"Edit Content"}}}},{lang:"zh",resources:{text:{viz_name:"文本",content:{label:"文本内容",edit:"编辑文本内容"}}}}];class xD extends ge{constructor(){super(...arguments);B(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const yD={displayName:"viz.text.viz_name",displayGroup:"chart.groups.others",migrator:new xD,name:"text",viewRender:dD,configRender:mD,createConfig(){return{version:1,config:v.cloneDeep(Oo)}},translation:gD},bD=()=>r.jsxs("svg",{width:"64",height:"64",viewBox:"0 0 64 64",fill:"none",children:[r.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M22.49 27.79H14.47C13.55 27.79 12.81 28.53 12.81 29.45C12.81 30.37 13.55 31.11 14.47 31.11H22.49C23.41 31.11 24.15 30.37 24.15 29.45C24.15 28.54 23.41 27.79 22.49 27.79ZM34.32 31.28C35.22 31.32 35.7 31.82 35.74 32.76C35.78 33.54 35.37 34.3 34.51 35.04C33.52 35.9 33.03 36.95 33.03 38.19V38.81H34.82V38.25C34.78 37.59 35.07 37.02 35.68 36.52C37.12 35.41 37.82 34.15 37.78 32.75C37.66 30.53 36.5 29.35 34.32 29.23C32.3 29.23 31.05 30.46 30.55 32.93L32.53 33.55C32.82 32.04 33.42 31.28 34.32 31.28ZM35 39.93H32.84V42.21H35V39.93ZM14.83 36.42H18.54C19.46 36.42 20.2 37.17 20.2 38.08C20.2 39 19.46 39.74 18.54 39.74H10.52C9.6 39.74 8.86 39 8.86 38.08C8.86 37.61 9.06 37.19 9.37 36.89H5.66C4.74 36.89 4 36.15 4 35.23C4 34.31 4.74 33.57 5.66 33.57H13.68C14.6 33.57 15.34 34.31 15.34 35.23C15.34 35.7 15.14 36.12 14.83 36.42ZM50.94 36.85H58.74C59.66 36.85 60.4 37.59 60.41 38.51C60.41 39.43 59.67 40.17 58.75 40.17H54.26C54.56 40.47 54.74 40.88 54.74 41.34C54.74 42.26 54 43 53.08 43H50.94V36.85Z",fill:"#B8C0CC"}),r.jsx("path",{d:"M18.39 32.28H16.51V35.02H18.39V32.28Z",fill:"#9399A5"}),r.jsx("path",{d:"M46.87 15H20.69C18.38 15 16.5 16.88 16.5 19.19V26.22H18.38V23.45H49.18V47.68H18.38V41.07H16.5V49.55H51.05V19.19C51.06 16.88 49.18 15 46.87 15ZM39.46 20.73C38.81 20.73 38.29 20.2 38.29 19.56C38.29 18.92 38.82 18.39 39.46 18.39C40.11 18.39 40.63 18.92 40.63 19.56C40.63 20.2 40.11 20.73 39.46 20.73ZM43.22 20.73C42.57 20.73 42.05 20.2 42.05 19.56C42.05 18.92 42.58 18.39 43.22 18.39C43.87 18.39 44.39 18.92 44.39 19.56C44.39 20.2 43.87 20.73 43.22 20.73ZM46.97 20.73C46.32 20.73 45.8 20.2 45.8 19.56C45.8 18.92 46.33 18.39 46.97 18.39C47.62 18.39 48.14 18.92 48.14 19.56C48.14 20.2 47.62 20.73 46.97 20.73Z",fill:"#9399A5"})]});function gh(e,t){const n=v.get(e,t,"");if(n)throw new Error(n)}async function vD(e,t,n,s={}){const i={"X-Requested-With":"XMLHttpRequest","Content-Type":s.string?"application/x-www-form-urlencoded":"application/json",...s.headers},a={baseURL:e,method:"POST",url:t,params:s.params,headers:i};return a.data=s.string?JSON.stringify(n):n,At(a).then(l=>l.data).catch(l=>Promise.reject(l))}const _D=({conf:e,panelData:t})=>async()=>{const{expertSystemURL:n,path:s,goal:i,question:a}=e;if(!s||!i||!a)return;const l=kg(t);if(!l)return;const c={dashboard:i,panel:a,data:l};try{const u=n.startsWith("http")?n:window.location.origin;return await vD(u,`/expert/v3/devtable/${s}`,c,{})}catch(u){throw gh(u,"response.data.detail"),gh(u,"response.data.error"),console.error(u),u}},Lo={expertSystemURL:"",path:"",goal:"",question:""},Bo={height:"100%",overflowY:"auto",...eo},xh=({message:e})=>r.jsx(o.Box,{sx:Bo,children:r.jsx("div",{dangerouslySetInnerHTML:{__html:e},style:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45"}})}),jD=({error:e,width:t,height:n})=>{const s=e.message;if(s.startsWith("<"))return r.jsx(xh,{message:s});const a=n-25-20-30;return r.jsx(o.Center,{sx:{width:"100%",height:a},children:r.jsxs(o.Stack,{align:"center",spacing:20,children:[r.jsx(bD,{}),r.jsx(xh,{message:s})]})})};function wD({context:e}){const{value:t}=$(e.instanceData,"config"),n=m.useMemo(()=>v.defaultsDeep({},t,Lo),[t]),{width:s,height:i}=e.viewport,a=e.data,{data:l,error:c,loading:u}=W.useRequest(_D({conf:n,panelData:a}),{refreshDeps:[a,n]});return!s||!i||!n?null:u?r.jsx(o.Box,{sx:{position:"relative",height:i},children:r.jsx(o.LoadingOverlay,{visible:!0})}):c?r.jsx(o.Box,{sx:Bo,"data-enable-scrollbar":!0,children:r.jsx(jD,{error:c,width:s,height:i})}):!l||!Array.isArray(l.replies)||l.replies.length===0?null:r.jsx(o.Box,{sx:Bo,"data-enable-scrollbar":!0,children:l.replies.map((d,p)=>r.jsx("div",{dangerouslySetInnerHTML:{__html:d.interpretation.html}},p))})}function CD({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=m.useMemo(()=>v.defaultsDeep({},t,Lo),[t]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});m.useEffect(()=>{u(s)},[s]),l(["expertSystemURL","goal","path","question"]);const d=c(),p=m.useMemo(()=>!v.isEqual(d,s),[d,s]);return r.jsx("form",{onSubmit:a(n),children:r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:"expertSystemURL",control:i,render:({field:h})=>r.jsx(o.TextInput,{label:"Expert System URL",...h})}),r.jsx(b.Controller,{name:"path",control:i,render:({field:h})=>r.jsx(o.TextInput,{label:"Path",required:!0,...h})})]}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:"goal",control:i,render:({field:h})=>r.jsx(o.TextInput,{label:"Goal",required:!0,...h})}),r.jsx(b.Controller,{name:"question",control:i,render:({field:h})=>r.jsx(o.TextInput,{label:"Question",required:!0,...h})})]}),r.jsx(o.Divider,{variant:"dashed",mt:16,mb:8}),r.jsx(o.Button,{type:"submit",variant:"filled",color:"blue",leftIcon:r.jsx(V.DeviceFloppy,{size:20}),disabled:!p,sx:{alignSelf:"flex-end"},children:"Submit Changes"})]})})}const SD=[{lang:"en",resources:{merico_gqm:{viz_name:"Merico GQM"}}},{lang:"zh",resources:{merico_gqm:{viz_name:"思码逸GQM组件"}}}];class kD extends ge{constructor(){super(...arguments);B(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const TD={displayName:"viz.merico_gqm.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new kD,name:"mericoGQM",viewRender:wD,configRender:CD,createConfig(){return{version:1,config:v.cloneDeep(Lo)}},translation:SD};function DD(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{calendar:i,heat_block:a,tooltip:l,...c}=e;return{...c,calendar:{...i,data_key:s(i.data_key)},heat_block:{...a,data_key:s(a.data_key)},tooltip:{...l,metrics:l.metrics.map(u=>({...u,data_key:s(u.data_key)}))}}}catch(n){throw console.error("[Migration failed]",n),n}}function MD(e){const{heat_block:t}=e;let{min:n,max:s}=t;return typeof n!="number"&&(n=0),typeof s!="number"&&(s=100),{...e,heat_block:{...t,min:{type:"static",value:n},max:{type:"static",value:s}}}}function zD(e){const{visualMap:t=Ht(),heat_block:{min:n,max:s,...i},...a}=e;return{...a,heat_block:i,visualMap:{...Ht(),min:n,max:s}}}const ID=[{lang:"en",resources:{calendar_heatmap:{viz_name:"Heatmap(Calendar)",calendar:{label:"Calendar",locale:"Langauge"},click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{calendar_heatmap:{viz_name:"日历热力图",calendar:{label:"日历",locale:"语言"},click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function ED(e){return r.jsx(r.Fragment,{})}function AD(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.calendar_heatmap.click_heatmap.heatblock.label")})}const yh={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.calendar_heatmap.click_heatmap.heatblock.label",nameRender:AD,configRender:ED,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]},qo={calendar:{data_key:"",locale:"EN"},heat_block:{name:"Value",data_key:"",value_formatter:Me},tooltip:{metrics:[]},visualMap:Ht()};function PD(e,t,n){if(!e)return n[0];try{return[t,P(t).add(1,"year").subtract(1,"day").valueOf()]}catch(s){return console.error(s),n[0]}}function OD(e,t,n){const s=PD(e,t,n);return{top:50,left:25,right:5,cellSize:["auto",13],range:s,itemStyle:{borderColor:"#eee"},splitLine:{show:!0},dayLabel:{firstDay:1},monthLabel:{position:"end"},yearLabel:{show:!0}}}function LD(e){return{heat_block:function(s){if(!e.heat_block.value_formatter)return s;try{return U(s,e.heat_block.value_formatter)}catch(i){return console.error(i),s}}}}function BD(e,t){return{show:!e,selectedMode:"single",top:5,right:5,data:t.map(n=>({name:n,icon:"circle"}))}}function qD(e,t,n){return e?{type:"heatmap",name:"heatmap",coordinateSystem:"calendar",calendarIndex:0,data:n}:Object.entries(t).map(([s,i])=>({type:"heatmap",name:s,coordinateSystem:"calendar",calendarIndex:0,data:i}))}const VD=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function ND({conf:e,valueFormatters:t,dataDict:n,params:s}){const{value:i}=s,[a,l]=i,u=[{label:e.heat_block.name,value:t.heat_block(l),style:{label:"",value:""}}],d=n[a];return d&&e.tooltip.metrics.forEach(p=>{const h=O(p.data_key);u.push({label:p.name,value:VD(v.get(d,h.columnKey,"")),style:{label:"",value:""}})}),u}function $D(e,t,n){const s=O(e.calendar.data_key),i=v.keyBy(t[s.queryID],s.columnKey);return te.getTooltip({formatter:function(a){const c=ND({conf:e,valueFormatters:n,dataDict:i,params:a}).map(p=>`
304
306
  <tr>
305
307
  <th style="text-align: right;">
306
308
  <div style="${p.style.label}">${p.label}</div>
@@ -309,13 +311,13 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
309
311
  <div style="${p.style.value}">${p.value}
310
312
  </td>
311
313
  </tr>
312
- `),u=b.get(o.value,0);return`
314
+ `),u=v.get(a.value,0);return`
313
315
  <table style="width: auto">
314
316
  <thead>
315
317
  <tr colspan="2">
316
318
  <div style="
317
319
  width: 100%; height: 4px; border-radius: 2px; margin-bottom: 6px;
318
- background-color: ${o.color};"
320
+ background-color: ${a.color};"
319
321
  />
320
322
  </tr>
321
323
  <tr>
@@ -326,13 +328,13 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
326
328
  </thead>
327
329
  <tbody>${c.join("")}</tbody>
328
330
  </table>
329
- `}})}const Qw=t=>I(t).get("year");function Rw(t){const e=b.groupBy(t,l=>l.value[2]),n=Object.keys(e),r=t.map(l=>I(l.value[0]).valueOf()),i=b.min(r),o=b.max(r);return{minDate:i??0,maxDate:o??0,dateSpan:I(o).diff(i,"day"),dataByYear:e,years:n}}function Uw(t,e,n){const r=n.reduce((D,z)=>{const E=Ze(z,e);return D[z.name]=Ie(z,E),D},{}),i=Hn(t.visualMap,r),{min:o,max:l}=i,c=Ow(t),u=A(t.calendar.data_key),d=A(t.heat_block.data_key),p=e[u.queryID].map(D=>{const z=b.get(D,u.columnKey),E=b.get(D,d.columnKey),V=Qw(D[u.columnKey]),F={value:[z,E,V]},{followVisualMap:N,color:Q}=_r(E,o,l,t.visualMap);return N||(F.visualMap=!1,F.itemStyle={color:Q}),F}),{dateSpan:h,minDate:g,dataByYear:f,years:v}=Rw(p),w=h<=366;return{calendar:qw(w,g,v),series:Nw(w,f,p),tooltip:Ww(t,e,c),visualMap:{...i,orient:"horizontal",left:w?"center":5,dimension:1},legend:Vw(w,v),grid:{containLabel:!0}}}function Yw({name:t},e){const n=e.getOption();n.calendar.forEach(r=>{r.range=t}),e.setOption(n)}function Kw({conf:t,data:e,width:n,height:r,interactionManager:i,variables:o}){const l=It(e,t.calendar.data_key),c=qe(i.triggerManager,jl.id),u=m.useCallback(h=>{const[g,f]=h.value,v=b.get(l,g,{error:"rowData is not found"});c.forEach(w=>{i.runInteraction(w.id,{...h,rowData:v})})},[l,c,i]),d=m.useMemo(()=>({click:u,legendselectchanged:Yw}),[u]),p=m.useMemo(()=>Uw(t,e,o),[t,e]);return s.jsx(Se,{echarts:Ce,option:p,style:{width:n,height:r},onEvents:d,notMerge:!0,opts:{locale:t.calendar.locale},theme:"merico-light"})}function Jw({context:t,instance:e}){const n=Oe({vizManager:t.vizManager,instance:e}),{value:r}=q(t.instanceData,"config"),{variables:i}=t,o=m.useMemo(()=>b.defaults({},r,Lr),[r]),l=t.data,{width:c,height:u}=t.viewport;return!o.calendar.data_key||!o.heat_block.data_key||!c||!u?null:s.jsx(Ae,{width:c,height:u,children:s.jsx(Kw,{variables:i,width:He(c),height:et(u),data:l,conf:o,interactionManager:n})})}const Xw=[{label:"中文",value:"ZH"},{label:"English",value:"EN"}];function Zw({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["calendar"]),s.jsxs(a.Stack,{children:[s.jsx(a.Group,{grow:!0,noWrap:!0,children:s.jsx(y.Controller,{name:"calendar.data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),sx:{flex:1},...r})})}),s.jsx(y.Controller,{name:"calendar.locale",control:t,render:({field:r})=>s.jsx(a.Select,{label:n("viz.calendar_heatmap.calendar.locale"),data:Xw,sx:{flex:1},...r})})]})}function Hw({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["heat_block"]),s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"heat_block.data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"heat_block.name",control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),sx:{flex:1},...r})})]}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("numbro.format.label"),labelPosition:"center"}),s.jsx(y.Controller,{name:"heat_block.value_formatter",control:t,render:({field:r})=>s.jsx(Re,{...r})})]})}const e0=({control:t,index:e})=>{const{t:n}=_.useTranslation();return s.jsx(a.Stack,{children:s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`tooltip.metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:`tooltip.metrics.${e}.data_key`,control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),required:!0,sx:{flex:1},...r})})]})})},t0=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(o,l)=>{const c=o.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(a.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),s.jsx(a.Divider,{variant:"dashed",my:10}),s.jsx(ae,{control:t,watch:e,name:"tooltip.metrics",getItem:r,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:o,index:l})=>s.jsx(e0,{control:t,index:l})})]})};function n0({control:t,watch:e}){return s.jsx(t0,{control:t,watch:e})}function s0({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),i=m.useMemo(()=>n?b.defaults({},n):Lr,[n]),o=m.useMemo(()=>b.cloneDeep(i),[i]);m.useEffect(()=>{!b.isEqual(i,o)&&(console.log("config malformed, resetting to defaults",i,o),r(o))},[i,o]);const l=y.useForm({defaultValues:o}),{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=l;m.useEffect(()=>{h(o)},[o]);const g=p(),f=m.useMemo(()=>!b.isEqual(g,i),[g,i]);return s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:u(r),children:[s.jsx(ge,{canSubmit:f}),s.jsxs(a.Tabs,{defaultValue:"Calendar",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"Calendar",children:e("viz.calendar_heatmap.calendar.label")}),s.jsx(a.Tabs.Tab,{value:"Heat Block",children:e("chart.heatmap.heatblock.label")}),s.jsx(a.Tabs.Tab,{value:"Visual Map",children:e("chart.visual_map.label")}),s.jsx(a.Tabs.Tab,{value:"Tooltip",children:e("chart.tooltip.label")})]}),s.jsx(a.Tabs.Panel,{value:"Calendar",children:s.jsx(Zw,{control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Heat Block",children:s.jsx(Hw,{control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Visual Map",children:s.jsx(jr,{form:l})}),s.jsx(a.Tabs.Panel,{value:"Tooltip",children:s.jsx(n0,{control:c,watch:d})})]})]})})}class r0 extends ce{constructor(){super(...arguments);$(this,"VERSION",4)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>({...n,version:2,config:Iw(n.config,r)})),this.version(3,n=>({...n,version:3,config:Ew(n.config)})),this.version(4,n=>({...n,version:4,config:Aw(n.config)}))}}const i0={displayName:"viz.calendar_heatmap.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new r0,name:"calendarHeatmap",viewRender:Jw,configRender:s0,createConfig:()=>({version:4,config:Lr}),triggers:[jl],translation:Pw},qr={x_axes:[{id:"initial-x",min:"",max:"",name:"X Axis",data_key:"",position:"bottom",label_formatter:_e,show:!0}],y_axis:{name:"Y Axis",data_key:"",axisLabel:{formatter:ke(),overflow:$e()},nameAlignment:"center"},series:[],tooltip:{metrics:[]},reference_lines:[]};function a0(){const t=new Date().getTime().toString();return{id:t,min:"",max:"",name:t,data_key:"",position:"bottom",label_formatter:_e,show:!0}}function o0(){const t=new Date().getTime().toString();return{id:t,type:"bar",name:t,stack:"",color:"",barGap:"0%",data_key:"",barWidth:"",barMinWidth:"1",barMaxWidth:"10",group_by_key:"",hide_in_legend:!1,invisible:!1,label_position:"right",aggregation_on_value:Gt,xAxisIndex:"0"}}function l0(){const t=new Date().getTime().toString();return{id:t,name:t,template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,xAxisIndex:"0"}}function c0(t){const e=t.x_axes.some(o=>o.position==="top"&&!!o.name&&o.show);let n=0;e&&(n+=15);const r=t.x_axes.some(o=>o.position==="bottom"&&!!o.name&&o.show);let i=0;return r&&(i+=15),t.series.some(o=>!o.hide_in_legend)&&(i+=20),{top:n,right:5,bottom:i,left:5,containLabel:!0}}function u0(t){switch(t){case"bar":return"roundRect";case"scatter":return"circle"}}function d0(t){const e={show:!0,bottom:0,left:"center",type:"scroll"};return e.data=t.filter(n=>!n.hide_in_legend).map(({name:n,type:r})=>({name:n,icon:u0(r)})),e}function p0(t,e,n,r){return t.map(i=>{const o=i.orientation==="horizontal",l=o?"yAxis":"xAxis",c=o?"insideEndTop":"end";return{name:i.name,type:"line",hide_in_legend:!i.show_in_legend,xAxisIndex:i.xAxisIndex,data:[],lineStyle:i.lineStyle,markLine:{data:[{name:i.name,[l]:Number(n[i.variable_key])}],silent:!0,symbol:["none","none"],lineStyle:i.lineStyle,label:{formatter:function(){return i.template?cn(i.template,e,r):""},position:c}}}})}function as(t,e,n){const r=Xe(t,e),i=Xe(t,n);return b.zip(i,r)}function h0(t,e,n,r){const i=as(e,n,r);return b.unionBy(i,t,0)}function m0({dataTemplate:t,data:e,name_data_key:n,value_data_key:r,valueTypedXAxis:i}){return i?h0(t,e,n,r):as(e,n,r)}function x0({dataTemplate:t,data:e,aggregation_on_value:n,name_data_key:r,value_data_key:i,valueTypedXAxis:o}){if(!n||n.type==="none")return m0({dataTemplate:t,data:e,name_data_key:r,value_data_key:i,valueTypedXAxis:o});const l=as(e,r,i),c=b.groupBy(l,"0");return t.map(([d])=>{const h=c[d].map(f=>f[1]),g=zs(h,n);return[d,g]})}function g0({group_by_key:t,data:e,value_data_key:n,name_data_key:r}){const{queryID:i,columnKey:o}=A(t),l=b.groupBy(e[i],o);return Object.entries(l).forEach(([c,u])=>{l[c]=as({[i]:u},r,n)}),l}function f0({y_axis:t},{data_key:e,xAxisIndex:n,label_position:r,name:i,group_by_key:o,aggregation_on_value:l,stack:c,color:u,hide_in_legend:d,invisible:p,id:h,...g},f,v,w,T,D){const z={label:{show:!!r,position:r,formatter:D[n??"default"]},name:i,yAxisId:"main-y-axis",xAxisIndex:n,stack:c,color:p?"transparent":u,hide_in_legend:d,labelLayout:{hideOverlap:!0},emphasis:{disabled:!0},...g};if(!o||o===t.data_key)return z.data=x0({dataTemplate:f,data:w,aggregation_on_value:l,name_data_key:t.data_key,value_data_key:e,valueTypedXAxis:v}),z;const E=g0({group_by_key:o,data:w,name_data_key:t.data_key,value_data_key:e});return Object.entries(E).map(([V,F])=>{const N=b.cloneDeep(z);return N.name=V,N.color=void 0,N.data=F,N})}function y0(t,e,n,r,i,o,l){const c=e.map(d=>[d,0]);return t.series.map(d=>f0(t,d,c,n,r,l,i)).flat().concat(p0(t.reference_lines,o,l,r))}function b0(t,e){const n=t.find(c=>c.axisDim==="y"&&c.axisId==="main-y-axis");if(!n)return"";const{name:r,axisType:i,axisValue:o,axisIndex:l}=n;return i==="yAxis.category"?r:Pe(e.y_axis.axisLabel.formatter)(o,l)}function v0(t,e,n){const r=e.reduce((i,{xAxisIndex:o,name:l})=>(i[l]=o,i),{});return te.getTooltip({trigger:"axis",axisPointer:{type:"shadow"},formatter:function(i){const o=Array.isArray(i)?i:[i];if(o.length===0)return"";const l=o.map(({seriesName:d,marker:p,value:h})=>{if(Array.isArray(h)&&h.length===2&&(h=h[0]),!d)return h;const g=r[d],f=n[g]??n.default;return`
331
+ `}})}const FD=e=>P(e).get("year");function GD(e){const t=v.groupBy(e,l=>l.value[2]),n=Object.keys(t),s=e.map(l=>P(l.value[0]).valueOf()),i=v.min(s),a=v.max(s);return{minDate:i??0,maxDate:a??0,dateSpan:P(a).diff(i,"day"),dataByYear:t,years:n}}function WD(e,t,n){const s=n.reduce((S,T)=>{const z=jt(T,t);return S[T.name]=Re(T,z),S},{}),i=Xs(e.visualMap,s),{min:a,max:l}=i,c=LD(e),u=O(e.calendar.data_key),d=O(e.heat_block.data_key),p=t[u.queryID].map(S=>{const T=v.get(S,u.columnKey),z=v.get(S,d.columnKey),I=FD(S[u.columnKey]),E={value:[T,z,I]},{followVisualMap:N,color:R}=jo(z,a,l,e.visualMap);return N||(E.visualMap=!1,E.itemStyle={color:R}),E}),{dateSpan:h,minDate:f,dataByYear:g,years:y}=GD(p),j=h<=366;return{calendar:OD(j,f,y),series:qD(j,g,p),tooltip:$D(e,t,c),visualMap:{...i,orient:"horizontal",left:j?"center":5,dimension:1},legend:BD(j,y),grid:{containLabel:!0}}}function RD({name:e},t){const n=t.getOption();n.calendar.forEach(s=>{s.range=e}),t.setOption(n)}function QD({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=wn(t,e.calendar.data_key),c=nt(i.triggerManager,yh.id),u=m.useCallback(h=>{const[f,g]=h.value,y=v.get(l,f,{error:"rowData is not found"});c.forEach(j=>{i.runInteraction(j.id,{...h,rowData:y})})},[l,c,i]),d=m.useMemo(()=>({click:u,legendselectchanged:RD}),[u]),p=m.useMemo(()=>WD(e,t,a),[e,t]);return r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,opts:{locale:e.calendar.locale},theme:"merico-light"})}function UD({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=m.useMemo(()=>v.defaults({},s,qo),[s]),l=e.data,{width:c,height:u}=e.viewport;return!a.calendar.data_key||!a.heat_block.data_key||!c||!u?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(QD,{variables:i,width:wt(c),height:Ct(u),data:l,conf:a,interactionManager:n})})}const YD=[{label:"中文",value:"ZH"},{label:"English",value:"EN"}];function KD({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["calendar"]),r.jsxs(o.Stack,{children:[r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"calendar.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),sx:{flex:1},...s})})}),r.jsx(b.Controller,{name:"calendar.locale",control:e,render:({field:s})=>r.jsx(o.Select,{label:n("viz.calendar_heatmap.calendar.locale"),data:YD,sx:{flex:1},...s})})]})}function XD({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["heat_block"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"heat_block.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"heat_block.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("numbro.format.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"heat_block.value_formatter",control:e,render:({field:s})=>r.jsx(ft,{...s})})]})}const JD=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},ZD=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(fe,{control:e,watch:t,name:"tooltip.metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(JD,{control:e,index:l})})]})};function HD({control:e,watch:t}){return r.jsx(ZD,{control:e,watch:t})}function eM({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=m.useMemo(()=>n?v.defaults({},n):qo,[n]),a=m.useMemo(()=>v.cloneDeep(i),[i]);m.useEffect(()=>{!v.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),s(a))},[i,a]);const l=b.useForm({defaultValues:a}),{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=l;m.useEffect(()=>{h(a)},[a]);const f=p(),g=m.useMemo(()=>!v.isEqual(f,i),[f,i]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:u(s),children:[r.jsx(Ce,{canSubmit:g}),r.jsxs(o.Tabs,{defaultValue:"Calendar",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"Calendar",children:t("viz.calendar_heatmap.calendar.label")}),r.jsx(o.Tabs.Tab,{value:"Heat Block",children:t("chart.heatmap.heatblock.label")}),r.jsx(o.Tabs.Tab,{value:"Visual Map",children:t("chart.visual_map.label")}),r.jsx(o.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")})]}),r.jsx(o.Tabs.Panel,{value:"Calendar",children:r.jsx(KD,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Heat Block",children:r.jsx(XD,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Visual Map",children:r.jsx(wo,{form:l})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(HD,{control:c,watch:d})})]})]})})}class tM extends ge{constructor(){super(...arguments);B(this,"VERSION",4)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>({...n,version:2,config:DD(n.config,s)})),this.version(3,n=>({...n,version:3,config:MD(n.config)})),this.version(4,n=>({...n,version:4,config:zD(n.config)}))}}const nM={displayName:"viz.calendar_heatmap.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new tM,name:"calendarHeatmap",viewRender:UD,configRender:eM,createConfig:()=>({version:4,config:qo}),triggers:[yh],translation:ID},Vo={x_axes:[{id:"initial-x",min:"",max:"",name:"X Axis",data_key:"",position:"bottom",label_formatter:Me,show:!0}],y_axis:{name:"Y Axis",data_key:"",axisLabel:{formatter:Oe(),overflow:Ke()},nameAlignment:"center"},series:[],tooltip:{metrics:[]},reference_lines:[]};function rM(){const e=new Date().getTime().toString();return{id:e,min:"",max:"",name:e,data_key:"",position:"bottom",label_formatter:Me,show:!0}}function sM(){const e=new Date().getTime().toString();return{id:e,type:"bar",name:e,stack:"",color:"",barGap:"0%",data_key:"",barWidth:"",barMinWidth:"1",barMaxWidth:"10",group_by_key:"",hide_in_legend:!1,invisible:!1,label_position:"right",aggregation_on_value:Bn,xAxisIndex:"0"}}function iM(){const e=new Date().getTime().toString();return{id:e,name:e,template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:"#868E96"},show_in_legend:!1,xAxisIndex:"0"}}function aM(e){const t=e.x_axes.some(a=>a.position==="top"&&!!a.name&&a.show);let n=0;t&&(n+=15);const s=e.x_axes.some(a=>a.position==="bottom"&&!!a.name&&a.show);let i=0;return s&&(i+=15),e.series.some(a=>!a.hide_in_legend)&&(i+=20),{top:n,right:5,bottom:i,left:5,containLabel:!0}}function oM(e){switch(e){case"bar":return"roundRect";case"scatter":return"circle"}}function lM(e){const t={show:!0,bottom:0,left:"center",type:"scroll"};return t.data=e.filter(n=>!n.hide_in_legend).map(({name:n,type:s})=>({name:n,icon:oM(s)})),t}function cM(e,t,n,s){return e.map(i=>{const a=i.orientation==="horizontal",l=a?"yAxis":"xAxis",c=a?"insideEndTop":"end";return{name:i.name,type:"line",hide_in_legend:!i.show_in_legend,xAxisIndex:i.xAxisIndex,data:[],lineStyle:i.lineStyle,markLine:{data:[{name:i.name,[l]:Number(n[i.variable_key])}],silent:!0,symbol:["none","none"],lineStyle:i.lineStyle,label:{formatter:function(){return i.template?mr(i.template,t,s):""},position:c}}}})}function ri(e,t,n){const s=_t(e,t),i=_t(e,n);return v.zip(i,s)}function uM(e,t,n,s){const i=ri(t,n,s);return v.unionBy(i,e,0)}function dM({dataTemplate:e,data:t,name_data_key:n,value_data_key:s,valueTypedXAxis:i}){return i?uM(e,t,n,s):ri(t,n,s)}function pM({dataTemplate:e,data:t,aggregation_on_value:n,name_data_key:s,value_data_key:i,valueTypedXAxis:a}){if(!n||n.type==="none")return dM({dataTemplate:e,data:t,name_data_key:s,value_data_key:i,valueTypedXAxis:a});const l=ri(t,s,i),c=v.groupBy(l,"0");return e.map(([d])=>{const h=c[d].map(g=>g[1]),f=ki(h,n);return[d,f]})}function hM({group_by_key:e,data:t,value_data_key:n,name_data_key:s}){const{queryID:i,columnKey:a}=O(e),l=v.groupBy(t[i],a);return Object.entries(l).forEach(([c,u])=>{l[c]=ri({[i]:u},s,n)}),l}function fM({y_axis:e},{data_key:t,xAxisIndex:n,label_position:s,name:i,group_by_key:a,aggregation_on_value:l,stack:c,color:u,hide_in_legend:d,invisible:p,id:h,...f},g,y,j,k,S){const T={label:{show:!!s,position:s,formatter:S[n??"default"]},name:i,yAxisId:"main-y-axis",xAxisIndex:n,stack:c,color:p?"transparent":u,hide_in_legend:d,labelLayout:{hideOverlap:!0},emphasis:{disabled:!0},...f};if(!a||a===e.data_key)return T.data=pM({dataTemplate:g,data:j,aggregation_on_value:l,name_data_key:e.data_key,value_data_key:t,valueTypedXAxis:y}),T;const z=hM({group_by_key:a,data:j,name_data_key:e.data_key,value_data_key:t});return Object.entries(z).map(([I,E])=>{const N=v.cloneDeep(T);return N.name=I,N.color=void 0,N.data=E,N})}function mM(e,t,n,s,i,a,l){const c=t.map(d=>[d,0]);return e.series.map(d=>fM(e,d,c,n,s,l,i)).flat().concat(cM(e.reference_lines,a,l,s))}function gM(e,t){const n=e.find(c=>c.axisDim==="y"&&c.axisId==="main-y-axis");if(!n)return"";const{name:s,axisType:i,axisValue:a,axisIndex:l}=n;return i==="yAxis.category"?s:Ye(t.y_axis.axisLabel.formatter)(a,l)}function xM(e,t,n){const s=t.reduce((i,{xAxisIndex:a,name:l})=>(i[l]=a,i),{});return te.getTooltip({trigger:"axis",axisPointer:{type:"shadow"},formatter:function(i){const a=Array.isArray(i)?i:[i];if(a.length===0)return"";const l=a.map(({seriesName:d,marker:p,value:h})=>{if(Array.isArray(h)&&h.length===2&&(h=h[0]),!d)return h;const f=s[d],g=n[f]??n.default;return`
330
332
  <tr>
331
333
  <td>${p}</td>
332
334
  <th style="text-align: right; padding: 0 1em;">${d}</th>
333
- <td style="text-align: left; padding: 0 1em;">${f({value:h})}</td>
335
+ <td style="text-align: left; padding: 0 1em;">${g({value:h})}</td>
334
336
  </tr>
335
- `}),c=We(t.y_axis.axisLabel.overflow.in_tooltip),u=b0(o,t);return`
337
+ `}),c=ct(e.y_axis.axisLabel.overflow.in_tooltip),u=gM(a,e);return`
336
338
  <div style="text-align: left; margin-bottom: .5em; padding: 0 1em .5em; font-weight: bold; border-bottom: 1px dashed #ddd;">
337
339
  <div style="${c}">${u}</div>
338
340
  </div>
@@ -341,7 +343,7 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
341
343
  ${l.join("")}
342
344
  </tbody>
343
345
  </table>
344
- `}})}function _0(t){return t.x_axes.reduce((n,{label_formatter:r},i)=>(n[i]=function(l){let c=l;if(typeof l=="object"&&(Array.isArray(l.value)&&l.value.length===2?c=l.value[0]:c=l.value),!r)return c;try{return U(c,r)}catch(u){return console.error(u),c}},n),{default:({value:n})=>n})}function j0(t,e){const n={};return e.map(r=>{const i=Ze(r,t);n[r.name]=Ie(r,i)}),n}function w0(t,e){return t.x_axes.map(({min:n,max:r,...i},o)=>{let l=i.position;return l||(l=o>0?"bottom":"top"),te.getYAxis({...i,type:"value",min:n||void 0,max:r||void 0,position:l,axisLabel:{show:!0,margin:2,formatter:e[o]??e.default},nameLocation:"center",nameGap:15})})}function C0(t,e){const n=e.every(l=>!Number.isNaN(Number(l))),{overflow:r,...i}=t.y_axis.axisLabel,o=Qe(r.on_axis);return[te.getXAxis({data:e,name:t.y_axis.name??"",nameLocation:"end",nameTextStyle:{align:"center"},id:"main-y-axis",type:n?"value":"category",axisLabel:{...i,...o,formatter:Pe(i.formatter)},z:5})]}function S0(t,e,n){if(!t.y_axis.data_key)return{};const r=j0(e,n),i=_0(t),o=A(t.y_axis.data_key),l=b.uniq(e[o.queryID].map(p=>p[o.columnKey])),c=l.every(p=>!Number.isNaN(Number(p))),u=y0(t,l,c,e,i,n,r);return{xAxis:w0(t,i),yAxis:C0(t,l),series:u,tooltip:v0(t,u,i),grid:c0(t),legend:d0(u)}}function k0({conf:t,data:e,width:n,height:r,interactionManager:i,variables:o}){const l=It(e,t.y_axis.data_key),c=qe(i.triggerManager,Xs.id),u=m.useCallback(h=>{const g=b.get(l,h.name,{error:"rowData is not found"});c.forEach(f=>{i.runInteraction(f.id,{...h,rowData:g})})},[l,c,i]),d=m.useMemo(()=>({click:u}),[u]),p=m.useMemo(()=>S0(t,e,o),[t,e]);return s.jsx(Se,{echarts:Ce,option:p,style:{width:n,height:r},onEvents:d,notMerge:!0,theme:"merico-light"})}function T0({context:t,instance:e}){const n=Oe({vizManager:t.vizManager,instance:e}),{value:r}=q(t.instanceData,"config"),{variables:i}=t,o=m.useMemo(()=>b.defaults({},r,qr),[r]),l=t.data,{width:c,height:u}=t.viewport;return!c||!u?null:s.jsx(Ae,{width:c,height:u,children:s.jsx(k0,{variables:i,width:He(c),height:et(u),data:l,conf:o,interactionManager:n})})}function D0({control:t,index:e,watch:n,variableOptions:r,xAxisOptions:i}){const{t:o}=_.useTranslation(),l=n(`reference_lines.${e}.orientation`);return s.jsxs(a.Stack,{my:0,p:0,pt:10,sx:{position:"relative"},children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`reference_lines.${e}.name`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:o("common.name"),placeholder:o("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),s.jsx(y.Controller,{name:`reference_lines.${e}.variable_key`,control:t,render:({field:c})=>s.jsx(a.Select,{label:o("common.data_field"),required:!0,data:r,sx:{flex:1},...c})})]}),s.jsx(y.Controller,{name:`reference_lines.${e}.template`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:o("chart.content_template.label"),placeholder:o("chart.content_template.hint"),sx:{flex:1},...c})}),s.jsxs(a.Group,{grow:!0,children:[s.jsxs(a.Stack,{children:[s.jsx(y.Controller,{name:`reference_lines.${e}.orientation`,control:t,render:({field:c})=>s.jsx(Ct,{sx:{flex:1},...c})}),l==="vertical"&&s.jsx(a.Text,{mt:-10,color:"dimmed",size:12,children:o("chart.reference_line.orientation.vertical_hint")})]}),l==="horizontal"&&s.jsx(y.Controller,{name:`reference_lines.${e}.xAxisIndex`,control:t,render:({field:c})=>s.jsx(a.Select,{label:o("chart.x_axis.label"),data:i,disabled:i.length===0,sx:{flex:1},...c})})]}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.style.label"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:`reference_lines.${e}.lineStyle.type`,control:t,render:({field:c})=>s.jsx(Qt,{sx:{flexGrow:1},...c})}),s.jsx(y.Controller,{name:`reference_lines.${e}.lineStyle.width`,control:t,render:({field:c})=>s.jsx(a.NumberInput,{label:o("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),s.jsxs(a.Stack,{spacing:4,children:[s.jsx(a.Text,{size:"sm",children:o("chart.color.label")}),s.jsx(y.Controller,{name:`reference_lines.${e}.lineStyle.color`,control:t,render:({field:c})=>s.jsx(Te,{...c})})]}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:o("chart.behavior.label"),labelPosition:"center"}),s.jsx(y.Controller,{name:`reference_lines.${e}.show_in_legend`,control:t,render:({field:c})=>s.jsx(a.Checkbox,{label:o("chart.legend.show_in_legend"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})]})}function z0({control:t,watch:e,variables:n}){const{t:r}=_.useTranslation(),i=()=>l0(),o=m.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=e("x_axes"),c=m.useMemo(()=>l.map(({name:d},p)=>({label:d,value:p.toString()})),[l]),u=(d,p)=>{const h=d.name.trim();return h||p+1};return s.jsx(ae,{control:t,watch:e,name:"reference_lines",getItem:i,addButtonText:r("chart.reference_line.add"),deleteButtonText:r("chart.reference_line.delete"),renderTabName:u,children:({field:d,index:p})=>s.jsx(D0,{control:t,index:p,watch:e,variableOptions:o,xAxisOptions:c})})}function M0({control:t,index:e,seriesItem:n}){const{t:r,i18n:i}=_.useTranslation(),o=!!n.barWidth.trim(),l=m.useMemo(()=>[{label:r("chart.series.bar.bar_gap.no_gap"),value:"0%"},{label:r("chart.series.bar.bar_gap.overlap"),value:"-100%"}],[i.language]);return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${e}.stack`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:r("chart.series.bar.stack"),placeholder:r("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),s.jsx(y.Controller,{name:`series.${e}.barGap`,control:t,render:({field:c})=>s.jsx(a.Select,{label:r("chart.series.bar.bar_gap.label"),data:l,sx:{flexGrow:1},...c})})]}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${e}.barMinWidth`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:r("chart.series.bar.bar_width.min"),disabled:o,sx:{flexGrow:1},...c})}),s.jsx(y.Controller,{name:`series.${e}.barWidth`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:r("chart.series.bar.bar_width.exact"),sx:{flexGrow:1},...c})}),s.jsx(y.Controller,{name:`series.${e}.barMaxWidth`,control:t,render:({field:c})=>s.jsx(a.TextInput,{label:r("chart.series.bar.bar_width.max"),disabled:o,sx:{flexGrow:1},...c})})]})]})}function I0({control:t,index:e,seriesItem:n,xAxisOptions:r}){const{t:i}=_.useTranslation();return s.jsxs(a.Stack,{my:0,p:0,sx:{position:"relative"},children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${e}.name`,control:t,render:({field:o})=>s.jsx(a.TextInput,{label:i("common.name"),required:!0,sx:{flex:1},...o})}),s.jsx(y.Controller,{name:`series.${e}.xAxisIndex`,control:t,render:({field:o})=>s.jsx(a.Select,{label:i("chart.x_axis.label"),data:r,disabled:r.length===0,sx:{flex:1},...o})})]}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`series.${e}.data_key`,control:t,render:({field:o})=>s.jsx(O,{label:i("common.data_field"),required:!0,sx:{flex:1},...o})}),s.jsx(y.Controller,{name:`series.${e}.aggregation_on_value`,control:t,render:({field:o})=>s.jsx(br,{label:i("viz.horizontal_bar_chart.series.aggregation.label"),value:o.value??Gt,onChange:o.onChange,pt:0,withFallback:!1})})]}),s.jsx(a.Group,{grow:!0,children:s.jsx(y.Controller,{name:`series.${e}.group_by_key`,control:t,render:({field:o})=>s.jsx(O,{label:i("chart.series.group_by.label"),clearable:!0,sx:{flex:1},...o})})}),s.jsx(M0,{index:e,control:t,seriesItem:n}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.style.label"),labelPosition:"center"}),s.jsx(y.Controller,{name:`series.${e}.label_position`,control:t,render:({field:o})=>s.jsx(Kt,{label:i("chart.label_position.label"),...o,withOffOption:!0,onChange:l=>{l&&o.onChange(l)}})}),s.jsxs(a.Stack,{spacing:4,children:[s.jsx(a.Text,{size:"sm",children:i("chart.color.label")}),s.jsx(y.Controller,{name:`series.${e}.color`,control:t,render:({field:o})=>s.jsx(Te,{...o})})]}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.behavior.label"),labelPosition:"center"}),s.jsx(y.Controller,{name:`series.${e}.hide_in_legend`,control:t,render:({field:o})=>s.jsx(a.Checkbox,{label:i("chart.legend.hide_in_legend"),checked:o.value,onChange:l=>o.onChange(l.currentTarget.checked)})}),s.jsx(y.Controller,{name:`series.${e}.invisible`,control:t,render:({field:o})=>s.jsx(a.Checkbox,{label:i("chart.behavior.invisible"),checked:o.value,onChange:l=>o.onChange(l.currentTarget.checked)})})]})}function E0({control:t,watch:e}){const{t:n}=_.useTranslation(),r=()=>o0(),i=(c,u)=>{const d=c.name.trim();return d||u+1},o=e("x_axes"),l=m.useMemo(()=>o.map(({name:c},u)=>({label:c,value:u.toString()})),[o]);return s.jsx(ae,{control:t,watch:e,name:"series",getItem:r,addButtonText:n("chart.series.add"),deleteButtonText:n("chart.series.delete"),renderTabName:i,children:({field:c,index:u})=>s.jsx(I0,{control:t,index:u,seriesItem:c,xAxisOptions:l})})}const A0=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},i)=>{const{t:o,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:o("chart.x_axis.position.top"),value:"top"},{label:o("chart.x_axis.position.bottom"),value:"bottom"}],[l.language]);return s.jsx(a.Select,{ref:i,label:t??o("chart.x_axis.position.label"),data:c,value:e,onChange:n,sx:r})});function P0({control:t,index:e}){const{t:n}=_.useTranslation();return s.jsxs(a.Stack,{my:10,p:"0",sx:{position:"relative"},children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`x_axes.${e}.name`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:`x_axes.${e}.position`,control:t,render:({field:r})=>s.jsx(A0,{sx:{flex:1},...r})})]}),s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("chart.x_axis.label_format"),labelPosition:"center"}),s.jsx(y.Controller,{name:`x_axes.${e}.label_formatter`,control:t,render:({field:r})=>s.jsx(Re,{...r})})]}),s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("chart.x_axis.value_range"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(y.Controller,{name:`x_axes.${e}.min`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("chart.x_axis.value_min"),...r})}),s.jsx(y.Controller,{name:`x_axes.${e}.max`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("chart.x_axis.value_max"),...r})})]})]}),s.jsx(a.Divider,{mb:-10,mt:10,variant:"dashed",label:n("chart.x_axis.behavior"),labelPosition:"center"}),s.jsx(y.Controller,{name:`x_axes.${e}.show`,control:t,render:({field:r})=>s.jsx(a.Checkbox,{label:n("chart.x_axis.visible"),checked:r.value,onChange:i=>r.onChange(i.currentTarget.checked)})})]})}function $0({control:t,watch:e}){const{t:n}=_.useTranslation(),r=()=>a0(),i=(o,l)=>{const c=o.name.trim();return c||l+1};return s.jsx(ae,{control:t,watch:e,name:"x_axes",getItem:r,addButtonText:n("chart.x_axis.add"),deleteButtonText:n("chart.x_axis.delete"),renderTabName:i,children:({field:o,index:l})=>s.jsx(P0,{control:t,index:l})})}function B0({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["y_axis"]),s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"y_axis.name",control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"y_axis.data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),required:!0,sx:{flex:1},...r})})]}),s.jsx(a.Divider,{mb:-15,label:n("chart.axis.tick_label"),variant:"dashed",labelPosition:"center"}),s.jsx(a.Group,{grow:!0,noWrap:!0,children:s.jsx(y.Controller,{name:"y_axis.axisLabel.formatter",control:t,render:({field:r})=>s.jsx(tt,{...r})})}),s.jsx(y.Controller,{name:"y_axis.axisLabel.overflow",control:t,render:({field:r})=>s.jsx(nt,{...r})})]})}function L0({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),{variables:i}=t,o=m.useMemo(()=>b.defaultsDeep({},n,qr),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=y.useForm({defaultValues:o});m.useEffect(()=>{p(o)},[o]),u([]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,o),[h,o]);return s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:c(r),children:[s.jsx(ge,{canSubmit:g}),s.jsxs(a.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"X Axes",children:e("chart.x_axis.labels")}),s.jsx(a.Tabs.Tab,{value:"Y Axis",children:e("chart.y_axis.label")}),s.jsx(a.Tabs.Tab,{value:"Series",children:e("chart.series.label")}),s.jsx(a.Tabs.Tab,{value:"Reference Lines",children:e("chart.reference_line.labels")})]}),s.jsx(a.Tabs.Panel,{value:"X Axes",children:s.jsx($0,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Y Axis",children:s.jsx(B0,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Series",children:s.jsx(E0,{control:l,watch:u})}),s.jsx(a.Tabs.Panel,{value:"Reference Lines",children:s.jsx(z0,{variables:i,control:l,watch:u})})]})]})})}const q0=[{lang:"en",resources:{horizontal_bar_chart:{viz_name:"Horizontal Bar Chart",series:{aggregation:{label:"Aggregation on Value"}}}}},{lang:"zh",resources:{horizontal_bar_chart:{viz_name:"水平方向柱图",series:{aggregation:{label:"聚合数据"}}}}}];function O0(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis:i,y_axis:o,series:l,...c}=t;return{...c,x_axis:{...i,data_key:r(i.data_key)},y_axis:{...o,data_key:r(o.data_key)},series:l.map(u=>({...u,data_key:r(u.data_key),group_by_key:r(u.group_by_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class V0 extends ce{constructor(){super(...arguments);$(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:i}=n;return{...n,version:2,config:O0(i,r)}})}}const N0={displayName:"viz.horizontal_bar_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new V0,name:"horizontalBarChart",viewRender:T0,configRender:L0,createConfig:()=>({version:2,config:qr}),translation:q0},Or={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,formatter:ke()}},deviation:{name:"",data_keys:{estimated_value:"",actual_value:""}},metrics:[]};function G0(){return[{top:20,left:30,right:60,height:40,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{top:70,left:30,right:60,height:100,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{top:180,left:30,right:60,bottom:130,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{left:30,right:60,bottom:20,height:100,containLabel:!1,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0}]}const wl=({value:t})=>{try{return U(t[2],{output:"percent",mantissa:0,absolute:!1})}catch(e){return console.error(e),t}};function F0(t,e,n){return{type:"heatmap",name:"准确估算比例",xAxisIndex:0,yAxisIndex:0,data:e.map(i=>{const o=n[i].length,u=(b.countBy(n[i],d=>d.level.diff===0).true??0)/o;return[i,"_y",u]}),label:{show:!0,formatter:wl},labelLayout:{hideOverlap:!0},visualMapIndex:0,tooltip:{trigger:"item",formatter:({color:i,value:o})=>`
346
+ `}})}function yM(e){return e.x_axes.reduce((n,{label_formatter:s},i)=>(n[i]=function(l){let c=l;if(typeof l=="object"&&(Array.isArray(l.value)&&l.value.length===2?c=l.value[0]:c=l.value),!s)return c;try{return U(c,s)}catch(u){return console.error(u),c}},n),{default:({value:n})=>n})}function bM(e,t){const n={};return t.map(s=>{const i=jt(s,e);n[s.name]=Re(s,i)}),n}function vM(e,t){return e.x_axes.map(({min:n,max:s,...i},a)=>{let l=i.position;return l||(l=a>0?"bottom":"top"),te.getYAxis({...i,type:"value",min:n||void 0,max:s||void 0,position:l,axisLabel:{show:!0,margin:2,formatter:t[a]??t.default},nameLocation:"center",nameGap:15})})}function _M(e,t){const n=t.every(l=>!Number.isNaN(Number(l))),{overflow:s,...i}=e.y_axis.axisLabel,a=ut(s.on_axis);return[te.getXAxis({data:t,name:e.y_axis.name??"",nameLocation:"end",nameTextStyle:{align:"center"},id:"main-y-axis",type:n?"value":"category",axisLabel:{...i,...a,formatter:Ye(i.formatter)},z:5})]}function jM(e,t,n){if(!e.y_axis.data_key)return{};const s=bM(t,n),i=yM(e),a=O(e.y_axis.data_key),l=v.uniq(t[a.queryID].map(p=>p[a.columnKey])),c=l.every(p=>!Number.isNaN(Number(p))),u=mM(e,l,c,t,i,n,s);return{xAxis:vM(e,i),yAxis:_M(e,l),series:u,tooltip:xM(e,u,i),grid:aM(e),legend:lM(u)}}function wM({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=wn(t,e.y_axis.data_key),c=nt(i.triggerManager,Ya.id),u=m.useCallback(h=>{const f=v.get(l,h.name,{error:"rowData is not found"});c.forEach(g=>{i.runInteraction(g.id,{...h,rowData:f})})},[l,c,i]),d=m.useMemo(()=>({click:u}),[u]),p=m.useMemo(()=>jM(e,t,a),[e,t]);return r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,theme:"merico-light"})}function CM({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=m.useMemo(()=>v.defaults({},s,Vo),[s]),l=e.data,{width:c,height:u}=e.viewport;return!c||!u?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(wM,{variables:i,width:wt(c),height:Ct(u),data:l,conf:a,interactionManager:n})})}function SM({control:e,index:t,watch:n,variableOptions:s,xAxisOptions:i}){const{t:a}=_.useTranslation(),l=n(`reference_lines.${t}.orientation`);return r.jsxs(o.Stack,{my:0,p:0,pt:10,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("common.name"),placeholder:a("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:c})=>r.jsx(o.Select,{label:a("common.data_field"),required:!0,data:s,sx:{flex:1},...c})})]}),r.jsx(b.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:a("chart.content_template.label"),placeholder:a("chart.content_template.hint"),sx:{flex:1},...c})}),r.jsxs(o.Group,{grow:!0,children:[r.jsxs(o.Stack,{children:[r.jsx(b.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:c})=>r.jsx(gn,{sx:{flex:1},...c})}),l==="vertical"&&r.jsx(o.Text,{mt:-10,color:"dimmed",size:12,children:a("chart.reference_line.orientation.vertical_hint")})]}),l==="horizontal"&&r.jsx(b.Controller,{name:`reference_lines.${t}.xAxisIndex`,control:e,render:({field:c})=>r.jsx(o.Select,{label:a("chart.x_axis.label"),data:i,disabled:i.length===0,sx:{flex:1},...c})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.style.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:c})=>r.jsx(Zn,{sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:c})=>r.jsx(o.NumberInput,{label:a("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:a("chart.color.label")}),r.jsx(b.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:c})=>r.jsx(Le,{...c})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.behavior.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`reference_lines.${t}.show_in_legend`,control:e,render:({field:c})=>r.jsx(o.Checkbox,{label:a("chart.legend.show_in_legend"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})]})}function kM({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>iM(),a=m.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=t("x_axes"),c=m.useMemo(()=>l.map(({name:d},p)=>({label:d,value:p.toString()})),[l]),u=(d,p)=>{const h=d.name.trim();return h||p+1};return r.jsx(fe,{control:e,watch:t,name:"reference_lines",getItem:i,addButtonText:s("chart.reference_line.add"),deleteButtonText:s("chart.reference_line.delete"),renderTabName:u,children:({field:d,index:p})=>r.jsx(SM,{control:e,index:p,watch:t,variableOptions:a,xAxisOptions:c})})}function TM({control:e,index:t,seriesItem:n}){const{t:s,i18n:i}=_.useTranslation(),a=!!n.barWidth.trim(),l=m.useMemo(()=>[{label:s("chart.series.bar.bar_gap.no_gap"),value:"0%"},{label:s("chart.series.bar.bar_gap.overlap"),value:"-100%"}],[i.language]);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.stack`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.stack"),placeholder:s("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`series.${t}.barGap`,control:e,render:({field:c})=>r.jsx(o.Select,{label:s("chart.series.bar.bar_gap.label"),data:l,sx:{flexGrow:1},...c})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.barMinWidth`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.bar_width.min"),disabled:a,sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`series.${t}.barWidth`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.bar_width.exact"),sx:{flexGrow:1},...c})}),r.jsx(b.Controller,{name:`series.${t}.barMaxWidth`,control:e,render:({field:c})=>r.jsx(o.TextInput,{label:s("chart.series.bar.bar_width.max"),disabled:a,sx:{flexGrow:1},...c})})]})]})}function DM({control:e,index:t,seriesItem:n,xAxisOptions:s}){const{t:i}=_.useTranslation();return r.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.name`,control:e,render:({field:a})=>r.jsx(o.TextInput,{label:i("common.name"),required:!0,sx:{flex:1},...a})}),r.jsx(b.Controller,{name:`series.${t}.xAxisIndex`,control:e,render:({field:a})=>r.jsx(o.Select,{label:i("chart.x_axis.label"),data:s,disabled:s.length===0,sx:{flex:1},...a})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`series.${t}.data_key`,control:e,render:({field:a})=>r.jsx(F,{label:i("common.data_field"),required:!0,sx:{flex:1},...a})}),r.jsx(b.Controller,{name:`series.${t}.aggregation_on_value`,control:e,render:({field:a})=>r.jsx(vo,{label:i("viz.horizontal_bar_chart.series.aggregation.label"),value:a.value??Bn,onChange:a.onChange,pt:0,withFallback:!1})})]}),r.jsx(o.Group,{grow:!0,children:r.jsx(b.Controller,{name:`series.${t}.group_by_key`,control:e,render:({field:a})=>r.jsx(F,{label:i("chart.series.group_by.label"),clearable:!0,sx:{flex:1},...a})})}),r.jsx(TM,{index:t,control:e,seriesItem:n}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.style.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`series.${t}.label_position`,control:e,render:({field:a})=>r.jsx(tr,{label:i("chart.label_position.label"),...a,withOffOption:!0,onChange:l=>{l&&a.onChange(l)}})}),r.jsxs(o.Stack,{spacing:4,children:[r.jsx(o.Text,{size:"sm",children:i("chart.color.label")}),r.jsx(b.Controller,{name:`series.${t}.color`,control:e,render:({field:a})=>r.jsx(Le,{...a})})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.behavior.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`series.${t}.hide_in_legend`,control:e,render:({field:a})=>r.jsx(o.Checkbox,{label:i("chart.legend.hide_in_legend"),checked:a.value,onChange:l=>a.onChange(l.currentTarget.checked)})}),r.jsx(b.Controller,{name:`series.${t}.invisible`,control:e,render:({field:a})=>r.jsx(o.Checkbox,{label:i("chart.behavior.invisible"),checked:a.value,onChange:l=>a.onChange(l.currentTarget.checked)})})]})}function MM({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>sM(),i=(c,u)=>{const d=c.name.trim();return d||u+1},a=t("x_axes"),l=m.useMemo(()=>a.map(({name:c},u)=>({label:c,value:u.toString()})),[a]);return r.jsx(fe,{control:e,watch:t,name:"series",getItem:s,addButtonText:n("chart.series.add"),deleteButtonText:n("chart.series.delete"),renderTabName:i,children:({field:c,index:u})=>r.jsx(DM,{control:e,index:u,seriesItem:c,xAxisOptions:l})})}const zM=m.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=m.useMemo(()=>[{label:a("chart.x_axis.position.top"),value:"top"},{label:a("chart.x_axis.position.bottom"),value:"bottom"}],[l.language]);return r.jsx(o.Select,{ref:i,label:e??a("chart.x_axis.position.label"),data:c,value:t,onChange:n,sx:s})});function IM({control:e,index:t}){const{t:n}=_.useTranslation();return r.jsxs(o.Stack,{my:10,p:"0",sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`x_axes.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`x_axes.${t}.position`,control:e,render:({field:s})=>r.jsx(zM,{sx:{flex:1},...s})})]}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.x_axis.label_format"),labelPosition:"center"}),r.jsx(b.Controller,{name:`x_axes.${t}.label_formatter`,control:e,render:({field:s})=>r.jsx(ft,{...s})})]}),r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.x_axis.value_range"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(b.Controller,{name:`x_axes.${t}.min`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.x_axis.value_min"),...s})}),r.jsx(b.Controller,{name:`x_axes.${t}.max`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("chart.x_axis.value_max"),...s})})]})]}),r.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:n("chart.x_axis.behavior"),labelPosition:"center"}),r.jsx(b.Controller,{name:`x_axes.${t}.show`,control:e,render:({field:s})=>r.jsx(o.Checkbox,{label:n("chart.x_axis.visible"),checked:s.value,onChange:i=>s.onChange(i.currentTarget.checked)})})]})}function EM({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>rM(),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsx(fe,{control:e,watch:t,name:"x_axes",getItem:s,addButtonText:n("chart.x_axis.add"),deleteButtonText:n("chart.x_axis.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(IM,{control:e,index:l})})}function AM({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["y_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"y_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"y_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,label:n("chart.axis.tick_label"),variant:"dashed",labelPosition:"center"}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(St,{...s})})}),r.jsx(b.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(kt,{...s})})]})}function PM({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=m.useMemo(()=>v.defaultsDeep({},n,Vo),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]),u([]);const h=d(),f=m.useMemo(()=>!v.isEqual(h,a),[h,a]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:c(s),children:[r.jsx(Ce,{canSubmit:f}),r.jsxs(o.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axes",children:t("chart.x_axis.labels")}),r.jsx(o.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Series",children:t("chart.series.label")}),r.jsx(o.Tabs.Tab,{value:"Reference Lines",children:t("chart.reference_line.labels")})]}),r.jsx(o.Tabs.Panel,{value:"X Axes",children:r.jsx(EM,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx(AM,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Series",children:r.jsx(MM,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx(kM,{variables:i,control:l,watch:u})})]})]})})}const OM=[{lang:"en",resources:{horizontal_bar_chart:{viz_name:"Horizontal Bar Chart",series:{aggregation:{label:"Aggregation on Value"}}}}},{lang:"zh",resources:{horizontal_bar_chart:{viz_name:"水平方向柱图",series:{aggregation:{label:"聚合数据"}}}}}];function LM(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis:i,y_axis:a,series:l,...c}=e;return{...c,x_axis:{...i,data_key:s(i.data_key)},y_axis:{...a,data_key:s(a.data_key)},series:l.map(u=>({...u,data_key:s(u.data_key),group_by_key:s(u.group_by_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class BM extends ge{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:LM(i,s)}})}}const qM={displayName:"viz.horizontal_bar_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new BM,name:"horizontalBarChart",viewRender:CM,configRender:PM,createConfig:()=>({version:2,config:Vo}),translation:OM},No={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,formatter:Oe()}},deviation:{name:"",data_keys:{estimated_value:"",actual_value:""}},metrics:[]};function VM(){return[{top:20,left:30,right:60,height:40,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{top:70,left:30,right:60,height:100,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{top:180,left:30,right:60,bottom:130,containLabel:!0,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0},{left:30,right:60,bottom:20,height:100,containLabel:!1,backgroundColor:"rgba(235, 235, 255, 0.5)",borderWidth:0,show:!0}]}const bh=({value:e})=>{try{return U(e[2],{output:"percent",mantissa:0,absolute:!1})}catch(t){return console.error(t),e}};function NM(e,t,n){return{type:"heatmap",name:"准确估算比例",xAxisIndex:0,yAxisIndex:0,data:t.map(i=>{const a=n[i].length,u=(v.countBy(n[i],d=>d.level.diff===0).true??0)/a;return[i,"_y",u]}),label:{show:!0,formatter:bh},labelLayout:{hideOverlap:!0},visualMapIndex:0,tooltip:{trigger:"item",formatter:({color:i,value:a})=>`
345
347
  <table style="width: auto">
346
348
  <thead>
347
349
  <tr colspan="2">
@@ -352,52 +354,52 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
352
354
  </tr>
353
355
  <tr>
354
356
  <th colspan="2" style="text-align: center;">
355
- <div>${o[0]}</div>
357
+ <div>${a[0]}</div>
356
358
  </th>
357
359
  </tr>
358
360
  </thead>
359
361
  <tbody>
360
362
  <tr>
361
363
  <th style="text-align: right;">准确估算比例</th>
362
- <td style="text-align: left; padding: 0 1em;">${wl({value:o})}</td>
364
+ <td style="text-align: left; padding: 0 1em;">${bh({value:a})}</td>
363
365
  </tr>
364
366
  </tbody>
365
367
  </table>
366
- `},show_in_legend:!1}}function Cl(t){const e=[`background-color: ${t}`];return t==="rgba(255, 255, 255, 1)"&&e.push("box-shadow: 0px 0px 1px 0px rgba(0,0,0,.5)"),e.join(";")}function W0([t,e]){const n={x:t,v:`${e}`};try{n.v=U(e,{output:"number",mantissa:2,trimMantissa:!0,absolute:!1})}catch{}return n}function Q0(t,e,n,r){var u,d;const i=e.map(p=>{const h=n[p],g=b.sumBy(h,f=>f.level.diff);return[p,g/h.length]}),o=Number(((u=b.maxBy(i,p=>p[1]))==null?void 0:u[1])??0),l=Number(((d=b.minBy(i,p=>p[1]))==null?void 0:d[1])??0),c=Dt.interpolate([o,0,l],["#D15A40","#FFF","#418AAF"]);return{type:"bar",name:"平均偏差",xAxisIndex:1,yAxisIndex:1,...r,data:i,itemStyle:{color:({value:p})=>{try{return c(p[1])}catch{return"#FFF"}}},label:{position:"outside",show:!0,formatter:({value:p})=>{try{return U(p[1],{output:"number",mantissa:1,trimMantissa:!0,absolute:!1})}catch{return p[1]}}},tooltip:{trigger:"item",formatter:({color:p,value:h})=>{const{x:g,v:f}=W0(h);return`
368
+ `},show_in_legend:!1}}function vh(e){const t=[`background-color: ${e}`];return e==="rgba(255, 255, 255, 1)"&&t.push("box-shadow: 0px 0px 1px 0px rgba(0,0,0,.5)"),t.join(";")}function $M([e,t]){const n={x:e,v:`${t}`};try{n.v=U(t,{output:"number",mantissa:2,trimMantissa:!0,absolute:!1})}catch{}return n}function FM(e,t,n,s){var u,d;const i=t.map(p=>{const h=n[p],f=v.sumBy(h,g=>g.level.diff);return[p,f/h.length]}),a=Number(((u=v.maxBy(i,p=>p[1]))==null?void 0:u[1])??0),l=Number(((d=v.minBy(i,p=>p[1]))==null?void 0:d[1])??0),c=vn.interpolate([a,0,l],["#D15A40","#FFF","#418AAF"]);return{type:"bar",name:"平均偏差",xAxisIndex:1,yAxisIndex:1,...s,data:i,itemStyle:{color:({value:p})=>{try{return c(p[1])}catch{return"#FFF"}}},label:{position:"outside",show:!0,formatter:({value:p})=>{try{return U(p[1],{output:"number",mantissa:1,trimMantissa:!0,absolute:!1})}catch{return p[1]}}},tooltip:{trigger:"item",formatter:({color:p,value:h})=>{const{x:f,v:g}=$M(h);return`
367
369
  <table style="width: auto">
368
370
  <thead>
369
371
  <tr colspan="2">
370
372
  <div style="
371
373
  width: 100%; height: 4px; border-radius: 2px; margin-bottom: 6px;
372
- ${Cl(p)}
374
+ ${vh(p)}
373
375
  "/>
374
376
  </tr>
375
377
  <tr>
376
378
  <th colspan="2" style="text-align: center;">
377
- <div>${g}</div>
379
+ <div>${f}</div>
378
380
  </th>
379
381
  </tr>
380
382
  </thead>
381
383
  <tbody>
382
384
  <tr>
383
385
  <th style="text-align: right;">平均偏差</th>
384
- <td style="text-align: left; padding: 0 1em;">${f}</td>
386
+ <td style="text-align: left; padding: 0 1em;">${g}</td>
385
387
  </tr>
386
388
  </tbody>
387
389
  </table>
388
- `}},show_in_legend:!1}}function R0([t,e,n,r]){const i={x:t,percentage:`${e}`,count:n,sum:r};try{i.percentage=U(e,{output:"percent",mantissa:2,trimMantissa:!0,absolute:!1})}catch{}return i}function U0(t,e,n,r){const i={};e.forEach(p=>{const h=b.countBy(n[p],f=>f.level.diff),g=b.sum(Object.values(h));Object.entries(h).forEach(([f,v])=>{i[f]||(i[f]=[]);const w=v/g;i[f].push([p,w,v,g])})});const o=Object.entries(i).map(([p])=>Number(p)).sort((p,h)=>p-h),l=Math.max(...o),c=Math.min(...o),u=Dt.interpolate([l,0,c],["#D15A40","#FFF","#418AAF"]);return o.map(p=>({type:"bar",name:p,xAxisIndex:2,yAxisIndex:2,stack:1,...r,color:u(p),data:i[p],tooltip:{trigger:"item",formatter:({color:h,value:g})=>{const{x:f,percentage:v,count:w,sum:T}=R0(g);return`
390
+ `}},show_in_legend:!1}}function GM([e,t,n,s]){const i={x:e,percentage:`${t}`,count:n,sum:s};try{i.percentage=U(t,{output:"percent",mantissa:2,trimMantissa:!0,absolute:!1})}catch{}return i}function WM(e,t,n,s){const i={};t.forEach(p=>{const h=v.countBy(n[p],g=>g.level.diff),f=v.sum(Object.values(h));Object.entries(h).forEach(([g,y])=>{i[g]||(i[g]=[]);const j=y/f;i[g].push([p,j,y,f])})});const a=Object.entries(i).map(([p])=>Number(p)).sort((p,h)=>p-h),l=Math.max(...a),c=Math.min(...a),u=vn.interpolate([l,0,c],["#D15A40","#FFF","#418AAF"]);return a.map(p=>({type:"bar",name:p,xAxisIndex:2,yAxisIndex:2,stack:1,...s,color:u(p),data:i[p],tooltip:{trigger:"item",formatter:({color:h,value:f})=>{const{x:g,percentage:y,count:j,sum:k}=GM(f);return`
389
391
  <table style="width: auto">
390
392
  <thead>
391
393
  <tr colspan="2">
392
394
  <div style="
393
395
  width: 100%; height: 4px; border-radius: 2px; margin-bottom: 6px;
394
- ${Cl(h)}
396
+ ${vh(h)}
395
397
  "
396
398
  />
397
399
  </tr>
398
400
  <tr>
399
401
  <th colspan="2" style="text-align: center;">
400
- ${f}
402
+ ${g}
401
403
  </th>
402
404
  </tr>
403
405
  </thead>
@@ -408,25 +410,25 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
408
410
  </tr>
409
411
  <tr>
410
412
  <th style="text-align: right;">占比</th>
411
- <td style="text-align: left; padding: 0 1em;">${v}</td>
413
+ <td style="text-align: left; padding: 0 1em;">${y}</td>
412
414
  </tr>
413
415
  <tr>
414
416
  <th style="text-align: right;">数量</th>
415
- <td style="text-align: left; padding: 0 1em;">${w}</td>
417
+ <td style="text-align: left; padding: 0 1em;">${j}</td>
416
418
  </tr>
417
419
  <tr>
418
420
  <th style="text-align: right;">总数</th>
419
- <td style="text-align: left; padding: 0 1em;">${T}</td>
421
+ <td style="text-align: left; padding: 0 1em;">${k}</td>
420
422
  </tr>
421
423
  </tbody>
422
424
  </table>
423
- `}},show_in_legend:!0}))}function Y0(t,e,n,r){const i=A(e.data_key),o=e.name,l=n.map(c=>{const u=b.sumBy(r[c],i.columnKey);return[c,u]});return{type:"line",name:o,xAxisIndex:3,yAxisIndex:3,color:"#b41529",data:l,show_in_legend:!1}}function K0(t,e,n,r){const l={barMinWidth:5,barMaxWidth:20};return[F0(t,n,r),Q0(t,n,r,l),...U0(t,n,r,l),Y0(t,e,n,r)]}function J0(t,e){const{axisLabel:n}=t.x_axis;return[{data:e,id:"准确估算比例",gridIndex:0,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:e,id:"平均偏差",gridIndex:1,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!0,lineStyle:{color:"#FFFFFF",width:2}},type:"category"},{data:e,id:"数量占比",gridIndex:2,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:e,id:"代码当量",gridIndex:3,axisTick:{show:!1},type:"category",axisLabel:{...n,formatter:Pe(n.formatter)},axisLine:{show:!1}}]}function X0(t){return[{type:"category",name:"准确估算比例",nameRotate:0,nameGap:5,nameLocation:"end",nameTextStyle:{align:"left"},gridIndex:0,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"平均偏差",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:1,boundaryGap:[1,1],axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"数量占比",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:2,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1},min:0,max:1},{type:"value",gridIndex:3,position:"right",splitNumber:3,axisLabel:{show:!0,verticalAlign:"top",showMinLabel:!1,lineHeight:14},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:t.name,nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:3,position:"left",axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}}]}function Vr(t){return t==1||t==2?1:Vr(t-2)+Vr(t-1)}const Z0=Array.from(new Array(20),(t,e)=>Vr(e+1));function Sl(t){return t<=1?t:Z0.findIndex(e=>t<=e)-1}function H0(t,e){const{x_axis:n,deviation:r}=t,i=A(n.data_key),o=A(r.data_keys.estimated_value),l=A(r.data_keys.actual_value);return e[i.queryID].map(c=>{const u=Sl(c[o.columnKey]),d=Sl(c[l.columnKey]),p=u-d;return{...c,level:{estimated:u,actual:d,diff:p}}})}function eC(t){return t==="rgba(255, 255, 255, 1)"?{borderColor:"rgba(0,0,0,.1)",borderWidth:1}:{}}function tC(t){return{show:!0,orient:"vertical",top:"middle",right:0,data:t.filter(n=>n.show_in_legend).reverse().map(n=>({name:`${n.name}`,color:n.color,itemStyle:eC(n.color)})),tooltip:{show:!0,formatter:"档位偏差:{a}"}}}const nC={tooltip:{trigger:"axis"}};function sC(t,e){const{deviation:n,metrics:r}=t,i=r.find(l=>l.data_key===e);if(i)return i;const o=n.data_keys.actual_value;return{id:o,name:n.name,data_key:o}}function rC(t,e,n){const r=H0(t,n),i=A(t.x_axis.data_key),o=b.uniqBy(n[i.queryID],i.columnKey).map(p=>p[i.columnKey]),l=b.groupBy(r,i.columnKey),c=sC(t,e),u=K0(t,c,o,l),d={xAxis:J0(t,o),yAxis:X0(c),series:u,grid:G0(),visualMap:[{min:0,max:1,calculable:!0,show:!1,seriesIndex:0,color:["#F0F0F0","#418AAF"]}],legend:tC(u)};return b.defaultsDeep({},d,nC)}const iC={input:{border:"none !important",paddingLeft:0,lineHeight:"1.55 !important"}},aC=({conf:t,metricKey:e,setMetricKey:n})=>{const{deviation:r,metrics:i}=t,o=m.useMemo(()=>{const l=i.map(c=>({label:c.name,value:c.data_key}));return l.push({label:r.name?r.name:r.data_keys.actual_value,value:r.data_keys.actual_value}),l},[r,i]);return s.jsxs(a.Group,{spacing:1,children:[s.jsx(a.Text,{size:12,color:"dimmed",sx:{cursor:"default",userSelect:"none"},children:"基线指标"}),s.jsx(a.NativeSelect,{size:"xs",data:o,value:e,onChange:l=>n(l.currentTarget.value),styles:iC})]})},oC={"tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function lC(){return s.jsxs(a.HoverCard,{width:400,shadow:"md",children:[s.jsx(a.HoverCard.Target,{children:s.jsx(a.Button,{size:"xs",variant:"subtle",compact:!0,leftIcon:s.jsx(k.IconInfoCircle,{size:14}),children:"指标说明"})}),s.jsx(a.HoverCard.Dropdown,{children:s.jsx(a.Table,{fontSize:14,sx:oC,children:s.jsxs("tbody",{children:[s.jsxs("tr",{children:[s.jsx("th",{children:"估算偏差"}),s.jsx("td",{children:"使用斐波那契数列(1,2,3,5,8,13)估算故事点,每个数位为一个档位,计算issue实际故事点与估算故事点的档位偏差,即为估算偏差。如估算故事点为5,实际故事点为8,则估算偏差为-1。"})]}),s.jsxs("tr",{children:[s.jsx("th",{children:"准确估算比例"}),s.jsx("td",{children:"偏差在 ± 1 档位内的 issue 均为准确估算,以此计算准确估算的比例。"})]})]})})})]})}function cC(t){return s.jsxs(a.Group,{position:"apart",children:[s.jsx(lC,{}),s.jsx(aC,{...t})]})}function uC({conf:t,data:e,width:n,height:r,metricKey:i}){const o=m.useMemo(()=>rC(t,i,e),[t,e,i]);return s.jsx(Se,{echarts:Ce,option:o,style:{width:n,height:r},notMerge:!0,theme:"merico-light"})}function dC({context:t}){const{value:e}=q(t.instanceData,"config"),n=m.useMemo(()=>b.defaults({},e,Or),[e]),r=t.data,{width:i,height:o}=t.viewport,{x_axis:l,deviation:c}=n,{estimated_value:u,actual_value:d}=c.data_keys,[p,h]=m.useState(d);if(m.useEffect(()=>{h(v=>v||d)},[d]),!l.data_key||!u||!d||!i||!o)return null;const g=Math.max(He(i),300),f=Math.max(et(o),370);return s.jsxs(a.Box,{pt:Ee.top,pr:Ee.right,pb:Ee.bottom,pl:Ee.left,sx:{overflow:"hidden",height:o,width:i},children:[s.jsx(cC,{conf:n,metricKey:p,setMetricKey:h}),s.jsx(uC,{width:g,height:f-30,data:r,conf:n,metricKey:p})]})}function pC({control:t,watch:e}){return e(["deviation"]),s.jsxs(a.Stack,{children:[s.jsx(a.Group,{grow:!0,noWrap:!0,children:s.jsx(y.Controller,{name:"deviation.name",control:t,render:({field:n})=>s.jsx(a.TextInput,{label:"指标名称",sx:{flex:1},...n})})}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"deviation.data_keys.estimated_value",control:t,render:({field:n})=>s.jsx(O,{label:"估算值字段",required:!0,sx:{flex:1},...n})}),s.jsx(y.Controller,{name:"deviation.data_keys.actual_value",control:t,render:({field:n})=>s.jsx(O,{label:"实际值字段",required:!0,sx:{flex:1},...n})})]})]})}const hC=({control:t,index:e})=>{const{t:n}=_.useTranslation();return s.jsx(a.Stack,{children:s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:`metrics.${e}.data_key`,control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),required:!0,sx:{flex:1},...r})})]})})},mC=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(o,l)=>{const c=o.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(a.Text,{size:14,color:"#888",children:"设置可以展示在基线图的指标,例如代码当量"})]}),s.jsx(a.Divider,{variant:"dashed",my:10}),s.jsx(ae,{control:t,watch:e,name:"metrics",getItem:r,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:o,index:l})=>s.jsx(hC,{control:t,index:l})})]})};function xC({control:t,watch:e}){return e(["x_axis"]),s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.data_key",control:t,render:({field:n})=>s.jsx(O,{label:"数据字段",required:!0,sx:{flex:1},...n})}),s.jsx(y.Controller,{name:"x_axis.name",control:t,render:({field:n})=>s.jsx(a.TextInput,{label:"X轴名称",sx:{flex:1},...n})})]}),s.jsx(a.Divider,{mb:-15,label:"点位文案",labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:n})=>s.jsx(xt,{sx:{width:"48%"},...n})}),s.jsx(y.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:n})=>s.jsx(tt,{...n})})]})]})}function gC({context:t}){const{value:e,set:n}=q(t.instanceData,"config"),r=m.useMemo(()=>b.defaultsDeep({},e,Or),[e]),{control:i,handleSubmit:o,watch:l,getValues:c,reset:u}=y.useForm({defaultValues:r});m.useEffect(()=>{u(r)},[r]),l([]);const d=c(),p=m.useMemo(()=>!b.isEqual(d,r),[d,r]);return s.jsx(a.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:o(n),children:[s.jsx(ge,{canSubmit:p}),s.jsxs(a.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"12px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"X Axis",children:"X轴"}),s.jsx(a.Tabs.Tab,{value:"Deviation",children:"偏差"}),s.jsx(a.Tabs.Tab,{value:"Additional Metrics",children:"指标"})]}),s.jsx(a.Tabs.Panel,{value:"X Axis",children:s.jsx(xC,{control:i,watch:l})}),s.jsx(a.Tabs.Panel,{value:"Deviation",children:s.jsx(pC,{control:i,watch:l})}),s.jsx(a.Tabs.Panel,{value:"Additional Metrics",children:s.jsx(mC,{control:i,watch:l})})]})]})})}const fC=[{lang:"en",resources:{merico_estimation_chart:{viz_name:"Merico Estimation Chart"}}},{lang:"zh",resources:{merico_estimation_chart:{viz_name:"思码逸估算分析图"}}}];function yC(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis:i,deviation:o,metrics:l,...c}=t;return{...c,x_axis:{...i,data_key:r(i.data_key)},deviation:{...o,data_keys:{estimated_value:r(o.data_keys.estimated_value),actual_value:r(o.data_keys.actual_value)}},metrics:l.map(u=>({...u,data_key:r(u.data_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class bC extends ce{constructor(){super(...arguments);$(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>{const{config:i}=n;return{...n,version:2,config:yC(i,r)}})}}const vC={displayName:"viz.merico_estimation_chart.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new bC,name:"mericoEstimationChart",viewRender:dC,configRender:gC,createConfig:()=>({version:2,config:Or}),translation:fC},Nr={styles:{justify:"space-around",align:"start"},metrics:[]};function _C(){return{id:new Date().getTime().toString(),names:{value:"Value",basis:"Basis"},data_keys:{value:"",basis:""},formatter:_e,postfix:{type:"text",value:""}}}const kl=({postfix:t})=>t?s.jsxs(s.Fragment,{children:[s.jsx(a.Text,{size:"12px",color:"#818388",sx:{lineHeight:1},children:"/"}),s.jsx(a.Text,{size:"12px",color:"#818388",sx:{lineHeight:1},children:t})]}):null,jC=S.observer(({metric:t,variableValueMap:e})=>{const{names:n,data_keys:r,formatter:i,postfix:o}=t,l=he(),c=m.useMemo(()=>{if(o.type==="text"&&o.value)return o.value;if(o.type==="filter-option-label"&&o.value){const u=l.filters.getSelectOption(o.value);return u?u.label:null}return null},[o,l]);return s.jsxs(a.Stack,{spacing:18,children:[s.jsxs(a.Stack,{spacing:12,children:[s.jsx(a.Text,{size:"14px",color:"#818388",children:n.value}),s.jsxs(a.Group,{spacing:"2px",align:"baseline",children:[s.jsx(a.Text,{size:"24px",fw:"bold",color:"#3D3E45",sx:{lineHeight:1},children:U(e[r.value],i)}),s.jsx(kl,{postfix:c})]})]}),s.jsxs(a.Stack,{spacing:12,children:[s.jsx(a.Text,{size:"14px",color:"#818388",children:n.basis}),s.jsxs(a.Group,{spacing:"2px",align:"baseline",children:[s.jsx(a.Text,{size:"12px",color:"#3D3E45",sx:{lineHeight:1},children:U(e[r.basis],i)}),s.jsx(kl,{postfix:c})]})]})]})}),wC=S.observer(({context:t,instance:e})=>{const{value:n}=q(t.instanceData,"config"),{variables:r}=t,i=m.useMemo(()=>b.defaults({},n,Nr),[n]),o=t.data,l=m.useMemo(()=>er(o,r),[r,o]),{width:c,height:u}=t.viewport;return!c||!u||!i?null:s.jsx(a.Flex,{w:`${c}px`,h:`${u}px`,justify:i.styles.justify,align:i.styles.align,direction:"row",wrap:"nowrap",sx:{overflow:"hidden"},children:i.metrics.map(d=>s.jsx(jC,{metric:d,variableValueMap:l},d.id))})}),CC=S.observer(m.forwardRef(({value:t,onChange:e},n)=>{const{t:r,i18n:i}=_.useTranslation(),l=Y().filters.selects,c=p=>{e({type:p,value:t.value})},u=p=>{e({type:t.type,value:p})},d=m.useMemo(()=>[{label:r("viz.merico_stats.metric.postfix_type.text"),value:"text"},{label:r("viz.merico_stats.metric.postfix_type.filter"),value:"filter-option-label"}],[i.language]);return s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(a.Select,{label:r("viz.merico_stats.metric.postfix_type.label"),data:d,value:t.type,onChange:c}),t.type==="text"&&s.jsx(a.TextInput,{label:r("viz.merico_stats.metric.postfix_content"),value:t.value,onChange:p=>{u(p.currentTarget.value)}}),t.type==="filter-option-label"&&s.jsx(a.Select,{label:r("viz.merico_stats.metric.postfix_filter"),value:t.value,onChange:u,data:l})]})}));function SC({control:t,index:e,watch:n,variableOptions:r}){const{t:i}=_.useTranslation();return n(`metrics.${e}.postfix`),s.jsxs(a.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`metrics.${e}.names.value`,control:t,render:({field:o})=>s.jsx(a.TextInput,{label:i("viz.merico_stats.metric.metric_name"),required:!0,sx:{flex:1},...o})}),s.jsx(y.Controller,{name:`metrics.${e}.data_keys.value`,control:t,render:({field:o})=>s.jsx(a.Select,{label:i("viz.merico_stats.metric.metric_data_field"),required:!0,data:r,sx:{flex:1},...o})})]}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`metrics.${e}.names.basis`,control:t,render:({field:o})=>s.jsx(a.TextInput,{label:i("viz.merico_stats.metric.basis_name"),required:!0,sx:{flex:1},...o})}),s.jsx(y.Controller,{name:`metrics.${e}.data_keys.basis`,control:t,render:({field:o})=>s.jsx(a.Select,{label:i("viz.merico_stats.metric.basis_data_field"),required:!0,data:r,sx:{flex:1},...o})})]}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:i("numbro.format.label"),labelPosition:"center"}),s.jsx(y.Controller,{name:`metrics.${e}.formatter`,control:t,render:({field:o})=>s.jsx(Re,{...o})}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:i("viz.merico_stats.metric.others"),labelPosition:"center"}),s.jsx(y.Controller,{name:`metrics.${e}.postfix`,control:t,render:({field:o})=>s.jsx(CC,{...o})})]})}const kC=({control:t,watch:e,variables:n})=>{const{t:r}=_.useTranslation(),i=()=>_C(),o=(u,d)=>{const p=u.names.value.trim();return p||d+1},l=({field:u,index:d,fields:p})=>p.length<=1,c=m.useMemo(()=>n.map(u=>({label:u.name,value:u.name})),[n]);return s.jsxs(s.Fragment,{children:[s.jsx(a.Divider,{mt:15,variant:"dashed",label:r("viz.merico_stats.metric.labels"),labelPosition:"center"}),s.jsx(ae,{control:t,watch:e,name:"metrics",getItem:i,addButtonText:r("chart.tooltip.additional_metrics.add"),deleteButtonText:r("chart.tooltip.additional_metrics.delete"),renderTabName:o,deleteDisalbed:l,children:({field:u,index:d})=>s.jsx(SC,{control:t,index:d,variableOptions:c,watch:e})})]})};function TC({control:t,watch:e}){const{t:n}=_.useTranslation();return e("styles"),s.jsxs(s.Fragment,{children:[s.jsx(a.Divider,{mt:15,variant:"dashed",label:n("style.label"),labelPosition:"center"}),s.jsxs(a.Group,{children:[s.jsx(y.Controller,{name:"styles.justify",control:t,render:({field:r})=>s.jsx(nm,{sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"styles.align",control:t,render:({field:r})=>s.jsx(sm,{label:n("viz.merico_stats.align_items.label"),sx:{flex:1},...r})})]})]})}function DC({context:t}){const{value:e,set:n}=q(t.instanceData,"config"),{variables:r}=t,i=m.useMemo(()=>b.defaultsDeep({},e,Nr),[e]),{control:o,handleSubmit:l,watch:c,getValues:u,reset:d}=y.useForm({defaultValues:i});m.useEffect(()=>{d(i)},[i]);const p=u(),h=m.useMemo(()=>!b.isEqual(p,i),[p,i]);return s.jsx("form",{onSubmit:l(n),children:s.jsxs(a.Stack,{spacing:"xs",children:[s.jsx(ge,{canSubmit:h}),s.jsx(TC,{control:o,watch:c}),s.jsx(kC,{control:o,watch:c,variables:r})]})})}function zC(t){const{metrics:e,...n}=t;return{...n,metrics:e.map(r=>({...r,postfix:r.postfix??{type:"text",value:""}}))}}const MC=[{lang:"en",resources:{merico_stats:{viz_name:"Merico Stats",align_items:{label:"Vertical Align"},metric:{labels:"Metrics",metric_name:"Metric Name",metric_data_field:"Metric Data Field",basis_name:"Basis Name",basis_data_field:"Basis Data Field",others:"Others",postfix_type:{label:"Postfix Type",text:"Text",filter:"Filter Option Label"},postfix_content:"Postfix Content",postfix_filter:"Postfix Filter"}}}},{lang:"zh",resources:{merico_stats:{viz_name:"思码逸数据指标",align_items:{label:"垂直对齐方式"},metric:{labels:"指标",metric_name:"指标名称",metric_data_field:"指标数据字段",basis_name:"基准名",basis_data_field:"基准数据字段",others:"其他",postfix_type:{label:"后缀类型",text:"文本",filter:"筛选器选项文案"},postfix_content:"后缀文案",postfix_filter:"筛选器"}}}}];class IC extends ce{constructor(){super(...arguments);$(this,"VERSION",2)}configVersions(){this.version(1,n=>({...n,version:1,config:n.config})),this.version(2,n=>({...n,version:2,config:zC(n.config)}))}}const EC={displayName:"viz.merico_stats.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new IC,name:"merico-stats",viewRender:wC,configRender:DC,createConfig:()=>({version:2,config:Nr}),translation:MC},Gr={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,overflow:$e(),formatter:ke()}},y_axis:{name:"Y Axis",data_key:"",nameAlignment:"center",axisLabel:{rotate:0,overflow:$e(),formatter:ke()}},heat_block:{name:"Value",data_key:"",value_formatter:_e,label:{show:!1,fontSize:10}},tooltip:{metrics:[]},visualMap:ft()};function AC({control:t,watch:e}){const{t:n}=_.useTranslation();e(["heat_block"]);const r=e("heat_block.label.show");return s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"heat_block.data_key",control:t,render:({field:i})=>s.jsx(O,{label:n("common.data_field"),required:!0,sx:{flex:1},...i})}),s.jsx(y.Controller,{name:"heat_block.name",control:t,render:({field:i})=>s.jsx(a.TextInput,{label:n("common.name"),sx:{flex:1},...i})})]}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("numbro.format.label"),labelPosition:"center"}),s.jsx(y.Controller,{name:"heat_block.value_formatter",control:t,render:({field:i})=>s.jsx(Re,{...i})}),s.jsx(a.Divider,{mb:-5,variant:"dashed",label:n("chart.label.label"),labelPosition:"center"}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"heat_block.label.show",control:t,render:({field:i})=>s.jsx(a.Switch,{label:n("chart.heatmap.heatblock.show_label"),checked:i.value,onChange:o=>i.onChange(o.currentTarget.checked),sx:{flexGrow:1}})}),s.jsx(y.Controller,{name:"heat_block.label.fontSize",control:t,render:({field:i})=>s.jsx(a.NumberInput,{size:"xs",icon:s.jsx(k.IconTextSize,{size:16}),disabled:!r,...i})})]})]})}const PC=({control:t,index:e})=>{const{t:n}=_.useTranslation();return s.jsx(a.Stack,{children:s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:`tooltip.metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:`tooltip.metrics.${e}.data_key`,control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),required:!0,sx:{flex:1},...r})})]})})},$C=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(o,l)=>{const c=o.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(a.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),s.jsx(a.Divider,{variant:"dashed",my:10}),s.jsx(ae,{control:t,watch:e,name:"tooltip.metrics",getItem:r,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:o,index:l})=>s.jsx(PC,{control:t,index:l})})]})};function BC({control:t,watch:e}){return s.jsx($C,{control:t,watch:e})}function LC({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["x_axis"]),s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"x_axis.name",control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),sx:{flex:1},...r})})]}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsx(y.Controller,{name:"x_axis.axisLabel.overflow",control:t,render:({field:r})=>s.jsx(nt,{...r})}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:r})=>s.jsx(xt,{sx:{width:"48%"},...r})}),s.jsx(y.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:r})=>s.jsx(tt,{...r})})]})]})}function qC({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["y_axis"]),s.jsxs(a.Stack,{my:0,p:"0",sx:{position:"relative"},children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"y_axis.data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),required:!0,sx:{flex:1},...r})}),s.jsx(y.Controller,{name:"y_axis.name",control:t,render:({field:r})=>s.jsx(a.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})})]}),s.jsx(a.Group,{grow:!0,noWrap:!0,children:s.jsx(y.Controller,{name:"y_axis.nameAlignment",control:t,render:({field:r})=>s.jsx(Tt,{sx:{flex:1},...r})})}),s.jsx(a.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsx(y.Controller,{name:"y_axis.axisLabel.overflow",control:t,render:({field:r})=>s.jsx(nt,{...r})}),s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(y.Controller,{name:"y_axis.axisLabel.rotate",control:t,render:({field:r})=>s.jsx(xt,{sx:{width:"48%"},...r})}),s.jsx(y.Controller,{name:"y_axis.axisLabel.formatter",control:t,render:({field:r})=>s.jsx(tt,{...r})})]})]})}function OC({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),i=m.useMemo(()=>n?b.defaults({},n):Gr,[n]),o=m.useMemo(()=>b.cloneDeep(i),[i]);m.useEffect(()=>{!b.isEqual(i,o)&&(console.log("config malformed, resetting to defaults",i,o),r(o))},[i,o]);const l=y.useForm({defaultValues:o}),{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=l;m.useEffect(()=>{h(o)},[o]);const g=p(),f=m.useMemo(()=>!b.isEqual(g,i),[g,i]);return s.jsx("form",{onSubmit:u(r),style:{flexGrow:1},children:s.jsxs(a.Stack,{spacing:"xs",sx:{height:"100%"},children:[s.jsx(ge,{canSubmit:f}),s.jsxs(a.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{root:{flexGrow:1},tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"X Axis",children:e("chart.x_axis.label")}),s.jsx(a.Tabs.Tab,{value:"Y Axis",children:e("chart.y_axis.label")}),s.jsx(a.Tabs.Tab,{value:"Heat Block",children:e("chart.heatmap.heatblock.label")}),s.jsx(a.Tabs.Tab,{value:"Visual Map",children:e("chart.visual_map.label")}),s.jsx(a.Tabs.Tab,{value:"Tooltip",children:e("chart.tooltip.label")})]}),s.jsx(a.Tabs.Panel,{value:"X Axis",children:s.jsx(LC,{control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Y Axis",children:s.jsx(qC,{control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Heat Block",children:s.jsx(AC,{control:c,watch:d})}),s.jsx(a.Tabs.Panel,{value:"Visual Map",children:s.jsx(jr,{form:l})}),s.jsx(a.Tabs.Panel,{value:"Tooltip",children:s.jsx(BC,{control:c,watch:d})})]})]})})}function VC(t){return s.jsx(s.Fragment,{})}function NC(t){const{t:e}=_.useTranslation();return s.jsx(a.Text,{children:e("viz.merico_heatmap.click_heatmap.heatblock.label")})}const Tl={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.merico_heatmap.click_heatmap.heatblock.label",nameRender:NC,configRender:VC,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function GC(t){const e=Pe(t.x_axis.axisLabel.formatter),n=Pe(t.y_axis.axisLabel.formatter);return{x_axis:e,y_axis:n}}function FC(t){return{heat_block:function(r){if(!t.heat_block.value_formatter)return r;try{return U(r,t.heat_block.value_formatter)}catch(i){return console.error(i),r}}}}function WC(t){let e=0;return t.x_axis.name&&(e+=20),{top:45,left:5,right:5,bottom:e,containLabel:!0,borderColor:"none",backgroundColor:"#E7E7E9",z:1}}function QC(t,e){const{heat_block:n}=t;return{type:"heatmap",name:n.name,xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{borderWidth:0},data:e,label:n.label,labelLayout:{hideOverlap:!0},z:2}}const RC=t=>U(t,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function UC({conf:t,labelFormatters:e,valueFormatters:n,dataDict:r,params:i}){const{value:o,dataIndex:l}=i,[c,u,d]=o,p={label:t.x_axis.name?t.x_axis.name:"X Axis",value:e.x_axis(c,l),style:{label:"",value:We(t.x_axis.axisLabel.overflow.in_tooltip)}},h={label:t.y_axis.name?t.y_axis.name:"Y Axis",value:e.y_axis(u,l),style:{label:"",value:We(t.y_axis.axisLabel.overflow.in_tooltip)}},g={label:t.heat_block.name,value:n.heat_block(d),style:{label:"",value:""}},f=[p,h,g],v=r[`${c}---${u}`];return v&&t.tooltip.metrics.forEach(w=>{const T=A(w.data_key);f.push({label:w.name,value:RC(b.get(v,T.columnKey,"")),style:{label:"",value:""}})}),f}function YC(t,e,n,r){const{x_axis:i,y_axis:o,heat_block:l}=t,c=A(i.data_key),u=A(o.data_key);A(l.data_key);const d=b.keyBy(e[c.queryID],p=>`${p[c.columnKey]}---${p[u.columnKey]}`);return te.getTooltip({formatter:function(p){const g=UC({conf:t,labelFormatters:n,valueFormatters:r,dataDict:d,params:p}).map(v=>`
425
+ `}},show_in_legend:!0}))}function RM(e,t,n,s){const i=O(t.data_key),a=t.name,l=n.map(c=>{const u=v.sumBy(s[c],i.columnKey);return[c,u]});return{type:"line",name:a,xAxisIndex:3,yAxisIndex:3,color:"#b41529",data:l,show_in_legend:!1}}function QM(e,t,n,s){const l={barMinWidth:5,barMaxWidth:20};return[NM(e,n,s),FM(e,n,s,l),...WM(e,n,s,l),RM(e,t,n,s)]}function UM(e,t){const{axisLabel:n}=e.x_axis;return[{data:t,id:"准确估算比例",gridIndex:0,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"平均偏差",gridIndex:1,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!0,lineStyle:{color:"#FFFFFF",width:2}},type:"category"},{data:t,id:"数量占比",gridIndex:2,axisTick:{show:!1},axisLabel:{show:!1},axisLine:{show:!1},type:"category"},{data:t,id:"代码当量",gridIndex:3,axisTick:{show:!1},type:"category",axisLabel:{...n,formatter:Ye(n.formatter)},axisLine:{show:!1}}]}function YM(e){return[{type:"category",name:"准确估算比例",nameRotate:0,nameGap:5,nameLocation:"end",nameTextStyle:{align:"left"},gridIndex:0,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"平均偏差",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:1,boundaryGap:[1,1],axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:"数量占比",nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:2,axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1},min:0,max:1},{type:"value",gridIndex:3,position:"right",splitNumber:3,axisLabel:{show:!0,verticalAlign:"top",showMinLabel:!1,lineHeight:14},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}},{type:"value",name:e.name,nameGap:5,nameRotate:90,nameLocation:"middle",gridIndex:3,position:"left",axisLabel:{show:!1},axisTick:{show:!1},axisLine:{show:!1},splitLine:{show:!1}}]}function $o(e){return e==1||e==2?1:$o(e-2)+$o(e-1)}const KM=Array.from(new Array(20),(e,t)=>$o(t+1));function _h(e){return e<=1?e:KM.findIndex(t=>e<=t)-1}function XM(e,t){const{x_axis:n,deviation:s}=e,i=O(n.data_key),a=O(s.data_keys.estimated_value),l=O(s.data_keys.actual_value);return t[i.queryID].map(c=>{const u=_h(c[a.columnKey]),d=_h(c[l.columnKey]),p=u-d;return{...c,level:{estimated:u,actual:d,diff:p}}})}function JM(e){return e==="rgba(255, 255, 255, 1)"?{borderColor:"rgba(0,0,0,.1)",borderWidth:1}:{}}function ZM(e){return{show:!0,orient:"vertical",top:"middle",right:0,data:e.filter(n=>n.show_in_legend).reverse().map(n=>({name:`${n.name}`,color:n.color,itemStyle:JM(n.color)})),tooltip:{show:!0,formatter:"档位偏差:{a}"}}}const HM={tooltip:{trigger:"axis"}};function ez(e,t){const{deviation:n,metrics:s}=e,i=s.find(l=>l.data_key===t);if(i)return i;const a=n.data_keys.actual_value;return{id:a,name:n.name,data_key:a}}function tz(e,t,n){const s=XM(e,n),i=O(e.x_axis.data_key),a=v.uniqBy(n[i.queryID],i.columnKey).map(p=>p[i.columnKey]),l=v.groupBy(s,i.columnKey),c=ez(e,t),u=QM(e,c,a,l),d={xAxis:UM(e,a),yAxis:YM(c),series:u,grid:VM(),visualMap:[{min:0,max:1,calculable:!0,show:!1,seriesIndex:0,color:["#F0F0F0","#418AAF"]}],legend:ZM(u)};return v.defaultsDeep({},d,HM)}const nz={input:{border:"none !important",paddingLeft:0,lineHeight:"1.55 !important"}},rz=({conf:e,metricKey:t,setMetricKey:n})=>{const{deviation:s,metrics:i}=e,a=m.useMemo(()=>{const l=i.map(c=>({label:c.name,value:c.data_key}));return l.push({label:s.name?s.name:s.data_keys.actual_value,value:s.data_keys.actual_value}),l},[s,i]);return r.jsxs(o.Group,{spacing:1,children:[r.jsx(o.Text,{size:12,color:"dimmed",sx:{cursor:"default",userSelect:"none"},children:"基线指标"}),r.jsx(o.NativeSelect,{size:"xs",data:a,value:t,onChange:l=>n(l.currentTarget.value),styles:nz})]})},sz={"tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function iz(){return r.jsxs(o.HoverCard,{width:400,shadow:"md",children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Button,{size:"xs",variant:"subtle",compact:!0,leftIcon:r.jsx(M.IconInfoCircle,{size:14}),children:"指标说明"})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(o.Table,{fontSize:14,sx:sz,children:r.jsxs("tbody",{children:[r.jsxs("tr",{children:[r.jsx("th",{children:"估算偏差"}),r.jsx("td",{children:"使用斐波那契数列(1,2,3,5,8,13)估算故事点,每个数位为一个档位,计算issue实际故事点与估算故事点的档位偏差,即为估算偏差。如估算故事点为5,实际故事点为8,则估算偏差为-1。"})]}),r.jsxs("tr",{children:[r.jsx("th",{children:"准确估算比例"}),r.jsx("td",{children:"偏差在 ± 1 档位内的 issue 均为准确估算,以此计算准确估算的比例。"})]})]})})})]})}function az(e){return r.jsxs(o.Group,{position:"apart",children:[r.jsx(iz,{}),r.jsx(rz,{...e})]})}function oz({conf:e,data:t,width:n,height:s,metricKey:i}){const a=m.useMemo(()=>tz(e,i,t),[e,t,i]);return r.jsx(Pe,{echarts:Ae,option:a,style:{width:n,height:s},notMerge:!0,theme:"merico-light"})}function lz({context:e}){const{value:t}=$(e.instanceData,"config"),n=m.useMemo(()=>v.defaults({},t,No),[t]),s=e.data,{width:i,height:a}=e.viewport,{x_axis:l,deviation:c}=n,{estimated_value:u,actual_value:d}=c.data_keys,[p,h]=m.useState(d);if(m.useEffect(()=>{h(y=>y||d)},[d]),!l.data_key||!u||!d||!i||!a)return null;const f=Math.max(wt(i),300),g=Math.max(Ct(a),370);return r.jsxs(o.Box,{pt:Qe.top,pr:Qe.right,pb:Qe.bottom,pl:Qe.left,sx:{overflow:"hidden",height:a,width:i},children:[r.jsx(az,{conf:n,metricKey:p,setMetricKey:h}),r.jsx(oz,{width:f,height:g-30,data:s,conf:n,metricKey:p})]})}function cz({control:e,watch:t}){return t(["deviation"]),r.jsxs(o.Stack,{children:[r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"deviation.name",control:e,render:({field:n})=>r.jsx(o.TextInput,{label:"指标名称",sx:{flex:1},...n})})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"deviation.data_keys.estimated_value",control:e,render:({field:n})=>r.jsx(F,{label:"估算值字段",required:!0,sx:{flex:1},...n})}),r.jsx(b.Controller,{name:"deviation.data_keys.actual_value",control:e,render:({field:n})=>r.jsx(F,{label:"实际值字段",required:!0,sx:{flex:1},...n})})]})]})}const uz=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},dz=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:"设置可以展示在基线图的指标,例如代码当量"})]}),r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(fe,{control:e,watch:t,name:"metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(uz,{control:e,index:l})})]})};function pz({control:e,watch:t}){return t(["x_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.data_key",control:e,render:({field:n})=>r.jsx(F,{label:"数据字段",required:!0,sx:{flex:1},...n})}),r.jsx(b.Controller,{name:"x_axis.name",control:e,render:({field:n})=>r.jsx(o.TextInput,{label:"X轴名称",sx:{flex:1},...n})})]}),r.jsx(o.Divider,{mb:-15,label:"点位文案",labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:n})=>r.jsx(Jt,{sx:{width:"48%"},...n})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>r.jsx(St,{...n})})]})]})}function hz({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=m.useMemo(()=>v.defaultsDeep({},t,No),[t]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});m.useEffect(()=>{u(s)},[s]),l([]);const d=c(),p=m.useMemo(()=>!v.isEqual(d,s),[d,s]);return r.jsx(o.Stack,{spacing:"xs",children:r.jsxs("form",{onSubmit:a(n),children:[r.jsx(Ce,{canSubmit:p}),r.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"12px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axis",children:"X轴"}),r.jsx(o.Tabs.Tab,{value:"Deviation",children:"偏差"}),r.jsx(o.Tabs.Tab,{value:"Additional Metrics",children:"指标"})]}),r.jsx(o.Tabs.Panel,{value:"X Axis",children:r.jsx(pz,{control:i,watch:l})}),r.jsx(o.Tabs.Panel,{value:"Deviation",children:r.jsx(cz,{control:i,watch:l})}),r.jsx(o.Tabs.Panel,{value:"Additional Metrics",children:r.jsx(dz,{control:i,watch:l})})]})]})})}const fz=[{lang:"en",resources:{merico_estimation_chart:{viz_name:"Merico Estimation Chart"}}},{lang:"zh",resources:{merico_estimation_chart:{viz_name:"思码逸估算分析图"}}}];function mz(e,{panelModel:t}){try{const n=t.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const s=u=>u&&`${n}.${u}`,{x_axis:i,deviation:a,metrics:l,...c}=e;return{...c,x_axis:{...i,data_key:s(i.data_key)},deviation:{...a,data_keys:{estimated_value:s(a.data_keys.estimated_value),actual_value:s(a.data_keys.actual_value)}},metrics:l.map(u=>({...u,data_key:s(u.data_key)}))}}catch(n){throw console.error("[Migration failed]",n),n}}class gz extends ge{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,s)=>{const{config:i}=n;return{...n,version:2,config:mz(i,s)}})}}const xz={displayName:"viz.merico_estimation_chart.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new gz,name:"mericoEstimationChart",viewRender:lz,configRender:hz,createConfig:()=>({version:2,config:No}),translation:fz},Fo={styles:{justify:"space-around",align:"start"},metrics:[]};function yz(){return{id:new Date().getTime().toString(),names:{value:"Value",basis:"Basis"},data_keys:{value:"",basis:""},formatter:Me,postfix:{type:"text",value:""}}}const jh=({postfix:e})=>e?r.jsxs(r.Fragment,{children:[r.jsx(o.Text,{size:"12px",color:"#818388",sx:{lineHeight:1},children:"/"}),r.jsx(o.Text,{size:"12px",color:"#818388",sx:{lineHeight:1},children:e})]}):null,bz=D.observer(({metric:e,variableValueMap:t})=>{const{names:n,data_keys:s,formatter:i,postfix:a}=e,l=_e(),c=m.useMemo(()=>{if(a.type==="text"&&a.value)return a.value;if(a.type==="filter-option-label"&&a.value){const u=l.filters.getSelectOption(a.value);return u?u.label:null}return null},[a,l]);return r.jsxs(o.Stack,{spacing:18,children:[r.jsxs(o.Stack,{spacing:12,children:[r.jsx(o.Text,{size:"14px",color:"#818388",children:n.value}),r.jsxs(o.Group,{spacing:"2px",align:"baseline",children:[r.jsx(o.Text,{size:"24px",fw:"bold",color:"#3D3E45",sx:{lineHeight:1},children:U(t[s.value],i)}),r.jsx(jh,{postfix:c})]})]}),r.jsxs(o.Stack,{spacing:12,children:[r.jsx(o.Text,{size:"14px",color:"#818388",children:n.basis}),r.jsxs(o.Group,{spacing:"2px",align:"baseline",children:[r.jsx(o.Text,{size:"12px",color:"#3D3E45",sx:{lineHeight:1},children:U(t[s.basis],i)}),r.jsx(jh,{postfix:c})]})]})]})}),vz=D.observer(({context:e,instance:t})=>{const{value:n}=$(e.instanceData,"config"),{variables:s}=e,i=m.useMemo(()=>v.defaults({},n,Fo),[n]),a=e.data,l=m.useMemo(()=>Ja(a,s),[s,a]),{width:c,height:u}=e.viewport;return!c||!u||!i?null:r.jsx(o.Flex,{w:`${c}px`,h:`${u}px`,justify:i.styles.justify,align:i.styles.align,direction:"row",wrap:"nowrap",sx:{overflow:"hidden"},children:i.metrics.map(d=>r.jsx(bz,{metric:d,variableValueMap:l},d.id))})}),_z=D.observer(m.forwardRef(({value:e,onChange:t},n)=>{const{t:s,i18n:i}=_.useTranslation(),l=Y().filters.selects,c=p=>{t({type:p,value:e.value})},u=p=>{t({type:e.type,value:p})},d=m.useMemo(()=>[{label:s("viz.merico_stats.metric.postfix_type.text"),value:"text"},{label:s("viz.merico_stats.metric.postfix_type.filter"),value:"filter-option-label"}],[i.language]);return r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.Select,{label:s("viz.merico_stats.metric.postfix_type.label"),data:d,value:e.type,onChange:c}),e.type==="text"&&r.jsx(o.TextInput,{label:s("viz.merico_stats.metric.postfix_content"),value:e.value,onChange:p=>{u(p.currentTarget.value)}}),e.type==="filter-option-label"&&r.jsx(o.Select,{label:s("viz.merico_stats.metric.postfix_filter"),value:e.value,onChange:u,data:l})]})}));function jz({control:e,index:t,watch:n,variableOptions:s}){const{t:i}=_.useTranslation();return n(`metrics.${t}.postfix`),r.jsxs(o.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`metrics.${t}.names.value`,control:e,render:({field:a})=>r.jsx(o.TextInput,{label:i("viz.merico_stats.metric.metric_name"),required:!0,sx:{flex:1},...a})}),r.jsx(b.Controller,{name:`metrics.${t}.data_keys.value`,control:e,render:({field:a})=>r.jsx(o.Select,{label:i("viz.merico_stats.metric.metric_data_field"),required:!0,data:s,sx:{flex:1},...a})})]}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`metrics.${t}.names.basis`,control:e,render:({field:a})=>r.jsx(o.TextInput,{label:i("viz.merico_stats.metric.basis_name"),required:!0,sx:{flex:1},...a})}),r.jsx(b.Controller,{name:`metrics.${t}.data_keys.basis`,control:e,render:({field:a})=>r.jsx(o.Select,{label:i("viz.merico_stats.metric.basis_data_field"),required:!0,data:s,sx:{flex:1},...a})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:i("numbro.format.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:`metrics.${t}.formatter`,control:e,render:({field:a})=>r.jsx(ft,{...a})}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:i("viz.merico_stats.metric.others"),labelPosition:"center"}),r.jsx(b.Controller,{name:`metrics.${t}.postfix`,control:e,render:({field:a})=>r.jsx(_z,{...a})})]})}const wz=({control:e,watch:t,variables:n})=>{const{t:s}=_.useTranslation(),i=()=>yz(),a=(u,d)=>{const p=u.names.value.trim();return p||d+1},l=({field:u,index:d,fields:p})=>p.length<=1,c=m.useMemo(()=>n.map(u=>({label:u.name,value:u.name})),[n]);return r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{mt:15,variant:"dashed",label:s("viz.merico_stats.metric.labels"),labelPosition:"center"}),r.jsx(fe,{control:e,watch:t,name:"metrics",getItem:i,addButtonText:s("chart.tooltip.additional_metrics.add"),deleteButtonText:s("chart.tooltip.additional_metrics.delete"),renderTabName:a,deleteDisalbed:l,children:({field:u,index:d})=>r.jsx(jz,{control:e,index:d,variableOptions:c,watch:t})})]})};function Cz({control:e,watch:t}){const{t:n}=_.useTranslation();return t("styles"),r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{mt:15,variant:"dashed",label:n("style.label"),labelPosition:"center"}),r.jsxs(o.Group,{children:[r.jsx(b.Controller,{name:"styles.justify",control:e,render:({field:s})=>r.jsx(Uy,{sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"styles.align",control:e,render:({field:s})=>r.jsx(Yy,{label:n("viz.merico_stats.align_items.label"),sx:{flex:1},...s})})]})]})}function Sz({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),{variables:s}=e,i=m.useMemo(()=>v.defaultsDeep({},t,Fo),[t]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d}=b.useForm({defaultValues:i});m.useEffect(()=>{d(i)},[i]);const p=u(),h=m.useMemo(()=>!v.isEqual(p,i),[p,i]);return r.jsx("form",{onSubmit:l(n),children:r.jsxs(o.Stack,{spacing:"xs",children:[r.jsx(Ce,{canSubmit:h}),r.jsx(Cz,{control:a,watch:c}),r.jsx(wz,{control:a,watch:c,variables:s})]})})}function kz(e){const{metrics:t,...n}=e;return{...n,metrics:t.map(s=>({...s,postfix:s.postfix??{type:"text",value:""}}))}}const Tz=[{lang:"en",resources:{merico_stats:{viz_name:"Merico Stats",align_items:{label:"Vertical Align"},metric:{labels:"Metrics",metric_name:"Metric Name",metric_data_field:"Metric Data Field",basis_name:"Basis Name",basis_data_field:"Basis Data Field",others:"Others",postfix_type:{label:"Postfix Type",text:"Text",filter:"Filter Option Label"},postfix_content:"Postfix Content",postfix_filter:"Postfix Filter"}}}},{lang:"zh",resources:{merico_stats:{viz_name:"思码逸数据指标",align_items:{label:"垂直对齐方式"},metric:{labels:"指标",metric_name:"指标名称",metric_data_field:"指标数据字段",basis_name:"基准名",basis_data_field:"基准数据字段",others:"其他",postfix_type:{label:"后缀类型",text:"文本",filter:"筛选器选项文案"},postfix_content:"后缀文案",postfix_filter:"筛选器"}}}}];class Dz extends ge{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({...n,version:1,config:n.config})),this.version(2,n=>({...n,version:2,config:kz(n.config)}))}}const Mz={displayName:"viz.merico_stats.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Dz,name:"merico-stats",viewRender:vz,configRender:Sz,createConfig:()=>({version:2,config:Fo}),translation:Tz},Go={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,overflow:Ke(),formatter:Oe()}},y_axis:{name:"Y Axis",data_key:"",nameAlignment:"center",axisLabel:{rotate:0,overflow:Ke(),formatter:Oe()}},heat_block:{name:"Value",data_key:"",value_formatter:Me,label:{show:!1,fontSize:10}},tooltip:{metrics:[]},visualMap:Ht()};function zz({control:e,watch:t}){const{t:n}=_.useTranslation();t(["heat_block"]);const s=t("heat_block.label.show");return r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"heat_block.data_key",control:e,render:({field:i})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...i})}),r.jsx(b.Controller,{name:"heat_block.name",control:e,render:({field:i})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...i})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("numbro.format.label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"heat_block.value_formatter",control:e,render:({field:i})=>r.jsx(ft,{...i})}),r.jsx(o.Divider,{mb:-5,variant:"dashed",label:n("chart.label.label"),labelPosition:"center"}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"heat_block.label.show",control:e,render:({field:i})=>r.jsx(o.Switch,{label:n("chart.heatmap.heatblock.show_label"),checked:i.value,onChange:a=>i.onChange(a.currentTarget.checked),sx:{flexGrow:1}})}),r.jsx(b.Controller,{name:"heat_block.label.fontSize",control:e,render:({field:i})=>r.jsx(o.NumberInput,{size:"xs",icon:r.jsx(M.IconTextSize,{size:16}),disabled:!s,...i})})]})]})}const Iz=({control:e,index:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Stack,{children:r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:`tooltip.metrics.${t}.name`,control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:`tooltip.metrics.${t}.data_key`,control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})})]})})},Ez=({control:e,watch:t})=>{const{t:n}=_.useTranslation(),s=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[r.jsx(V.InfoCircle,{size:14,color:"#888"}),r.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(fe,{control:e,watch:t,name:"tooltip.metrics",getItem:s,addButtonText:n("chart.tooltip.additional_metrics.add"),deleteButtonText:n("chart.tooltip.additional_metrics.delete"),renderTabName:i,children:({field:a,index:l})=>r.jsx(Iz,{control:e,index:l})})]})};function Az({control:e,watch:t}){return r.jsx(Ez,{control:e,watch:t})}function Pz({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["x_axis"]),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"x_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...s})})]}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(kt,{...s})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"x_axis.axisLabel.rotate",control:e,render:({field:s})=>r.jsx(Jt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(St,{...s})})]})]})}function Oz({control:e,watch:t}){const{t:n}=_.useTranslation();return t(["y_axis"]),r.jsxs(o.Stack,{my:0,p:"0",sx:{position:"relative"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"y_axis.data_key",control:e,render:({field:s})=>r.jsx(F,{label:n("common.data_field"),required:!0,sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"y_axis.name",control:e,render:({field:s})=>r.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...s})})]}),r.jsx(o.Group,{grow:!0,noWrap:!0,children:r.jsx(b.Controller,{name:"y_axis.nameAlignment",control:e,render:({field:s})=>r.jsx(yn,{sx:{flex:1},...s})})}),r.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),r.jsx(b.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(kt,{...s})}),r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(b.Controller,{name:"y_axis.axisLabel.rotate",control:e,render:({field:s})=>r.jsx(Jt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(St,{...s})})]})]})}function Lz({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=m.useMemo(()=>n?v.defaults({},n):Go,[n]),a=m.useMemo(()=>v.cloneDeep(i),[i]);m.useEffect(()=>{!v.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),s(a))},[i,a]);const l=b.useForm({defaultValues:a}),{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=l;m.useEffect(()=>{h(a)},[a]);const f=p(),g=m.useMemo(()=>!v.isEqual(f,i),[f,i]);return r.jsx("form",{onSubmit:u(s),style:{flexGrow:1},children:r.jsxs(o.Stack,{spacing:"xs",sx:{height:"100%"},children:[r.jsx(Ce,{canSubmit:g}),r.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{root:{flexGrow:1},tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"X Axis",children:t("chart.x_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Y Axis",children:t("chart.y_axis.label")}),r.jsx(o.Tabs.Tab,{value:"Heat Block",children:t("chart.heatmap.heatblock.label")}),r.jsx(o.Tabs.Tab,{value:"Visual Map",children:t("chart.visual_map.label")}),r.jsx(o.Tabs.Tab,{value:"Tooltip",children:t("chart.tooltip.label")})]}),r.jsx(o.Tabs.Panel,{value:"X Axis",children:r.jsx(Pz,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx(Oz,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Heat Block",children:r.jsx(zz,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Visual Map",children:r.jsx(wo,{form:l})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(Az,{control:c,watch:d})})]})]})})}function Bz(e){return r.jsx(r.Fragment,{})}function qz(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.merico_heatmap.click_heatmap.heatblock.label")})}const wh={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.merico_heatmap.click_heatmap.heatblock.label",nameRender:qz,configRender:Bz,payload:[{name:"seriesType",description:"'heatmap'",valueType:"string"},{name:"componentType",description:"'series'",valueType:"string"},{name:"name",description:"Name of the series clicked",valueType:"string"},{name:"color",description:"Color",valueType:"string"},{name:"value",description:"String-typed number, or series' actual value",valueType:"string"},{name:"rowData",description:"Data of the row",valueType:"object"}]};function Vz(e){const t=Ye(e.x_axis.axisLabel.formatter),n=Ye(e.y_axis.axisLabel.formatter);return{x_axis:t,y_axis:n}}function Nz(e){return{heat_block:function(s){if(!e.heat_block.value_formatter)return s;try{return U(s,e.heat_block.value_formatter)}catch(i){return console.error(i),s}}}}function $z(e){let t=0;return e.x_axis.name&&(t+=20),{top:45,left:5,right:5,bottom:t,containLabel:!0,borderColor:"none",backgroundColor:"#E7E7E9",z:1}}function Fz(e,t){const{heat_block:n}=e;return{type:"heatmap",name:n.name,xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{borderWidth:0},data:t,label:n.label,labelLayout:{hideOverlap:!0},z:2}}const Gz=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Wz({conf:e,labelFormatters:t,valueFormatters:n,dataDict:s,params:i}){const{value:a,dataIndex:l}=i,[c,u,d]=a,p={label:e.x_axis.name?e.x_axis.name:"X Axis",value:t.x_axis(c,l),style:{label:"",value:ct(e.x_axis.axisLabel.overflow.in_tooltip)}},h={label:e.y_axis.name?e.y_axis.name:"Y Axis",value:t.y_axis(u,l),style:{label:"",value:ct(e.y_axis.axisLabel.overflow.in_tooltip)}},f={label:e.heat_block.name,value:n.heat_block(d),style:{label:"",value:""}},g=[p,h,f],y=s[`${c}---${u}`];return y&&e.tooltip.metrics.forEach(j=>{const k=O(j.data_key);g.push({label:j.name,value:Gz(v.get(y,k.columnKey,"")),style:{label:"",value:""}})}),g}function Rz(e,t,n,s){const{x_axis:i,y_axis:a,heat_block:l}=e,c=O(i.data_key),u=O(a.data_key);O(l.data_key);const d=v.keyBy(t[c.queryID],p=>`${p[c.columnKey]}---${p[u.columnKey]}`);return te.getTooltip({formatter:function(p){const f=Wz({conf:e,labelFormatters:n,valueFormatters:s,dataDict:d,params:p}).map(y=>`
424
426
  <tr>
425
427
  <th style="text-align: right;">
426
- <div style="${v.style.label}">${v.label}</div>
428
+ <div style="${y.style.label}">${y.label}</div>
427
429
  </th>
428
430
  <td style="text-align: right; padding: 0 1em;">
429
- <div style="${v.style.value}">${v.value}
431
+ <div style="${y.style.value}">${y.value}
430
432
  </td>
431
433
  </tr>
432
434
  `);return`
@@ -439,21 +441,21 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
439
441
  />
440
442
  </tr>
441
443
  </thead>
442
- <tbody>${g.join("")}</tbody>
444
+ <tbody>${f.join("")}</tbody>
443
445
  </table>
444
- `}})}function KC(t,e,n){const{overflow:r,rotate:i}=t.x_axis.axisLabel,o=Qe(r.on_axis);return te.getXAxis({id:"main-x-axis",type:"category",data:e,name:t.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:i,...o,formatter:n},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:3})}function JC(t,e,n){const{nameAlignment:r,data_key:i,...o}=t.y_axis,{overflow:l,rotate:c}=t.y_axis.axisLabel,u=Qe(l.on_axis);return te.getYAxis({...o,type:"category",data:e,axisLabel:{rotate:c,...u,formatter:n},axisLine:{show:!0,lineStyle:{width:3}},axisTick:{show:!0,alignWithLabel:!0},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameTextStyle:{fontWeight:"bold",align:r},nameLocation:"end",nameGap:15,z:3})}function XC(t,e,n){if(!t.x_axis.data_key||!t.y_axis.data_key||!t.heat_block.data_key)return{};const r=n.reduce((T,D)=>{const z=Ze(D,e);return T[D.name]=Ie(D,z),T},{}),i=GC(t),o=FC(t),l=Hn(t.visualMap,r),{min:c,max:u}=l,d=A(t.x_axis.data_key),p=A(t.y_axis.data_key),h=A(t.heat_block.data_key),g=b.uniq(e[d.queryID].map(T=>T[d.columnKey])),f=b.uniq(e[d.queryID].map(T=>T[p.columnKey])),v=e[d.queryID].map(T=>{const D=b.get(T,d.columnKey),z=b.get(T,p.columnKey),E=b.get(T,h.columnKey),V={value:[D,z,E]},{followVisualMap:F,color:N}=_r(E,c,u,t.visualMap);return F||(V.visualMap=!1,V.itemStyle={color:N}),V});return{xAxis:KC(t,g,i.x_axis),yAxis:JC(t,f,i.y_axis),series:QC(t,v),tooltip:YC(t,e,i,o),grid:WC(t),visualMap:l}}function ZC({conf:t,data:e,width:n,height:r,interactionManager:i,variables:o}){const l=m.useMemo(()=>{const h=A(t.x_axis.data_key),g=A(t.y_axis.data_key);return b.keyBy(e[h.queryID],f=>`${f[h.columnKey]}---${f[g.columnKey]}`)},[e,t.x_axis.data_key,t.y_axis.data_key]),c=qe(i.triggerManager,Tl.id),u=m.useCallback(h=>{const[g,f]=h.value,v=b.get(l,`${g}---${f}`,{error:"rowData is not found"});c.forEach(w=>{i.runInteraction(w.id,{...h,rowData:v})})},[l,c,i]),d=m.useMemo(()=>({click:u}),[u]),p=m.useMemo(()=>XC(t,e,o),[t,e]);return s.jsx(Se,{echarts:Ce,option:p,style:{width:n,height:r},onEvents:d,notMerge:!0,theme:"merico-light"})}function HC({context:t,instance:e}){const n=Oe({vizManager:t.vizManager,instance:e}),{value:r}=q(t.instanceData,"config"),{variables:i}=t,o=m.useMemo(()=>b.defaults({},r,Gr),[r]),l=t.data,{width:c,height:u}=t.viewport;return!c||!u?null:s.jsx(Ae,{width:c,height:u,children:s.jsx(ZC,{variables:i,width:He(c),height:et(u),data:l,conf:o,interactionManager:n})})}const eS=[{lang:"en",resources:{merico_heatmap:{viz_name:"Merico Heatmap",click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{merico_heatmap:{viz_name:"思码逸热力图",click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function tS(t){const{visualMap:e=ft(),heat_block:{min:n,max:r,...i},...o}=t;return{...o,heat_block:i,visualMap:{...ft(),min:n,max:r}}}class nS extends ce{constructor(){super(...arguments);$(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:tS(n.config)}))}}const sS={displayName:"viz.merico_heatmap.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new nS,name:"merico-heatmap",viewRender:HC,configRender:OC,createConfig:()=>({version:2,config:Gr}),triggers:[Tl],translation:eS},rS=[{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(t=>({name:t.name,value:t.value,type:"single",category:"basic"})),iS=[cp,up,hp,pp,dp,mp],Dl=[Ar,ij,_w,Yv,kj,qb,N0,Dp,Tm,Hf,Wy,i0,kb,Pf,R_,uv,qv,Mw,vC,sS,EC,qm],zl=()=>({id:"dashboard",version:Da,manifest:{viz:Dl,color:[...rS,...iS]}}),yn=new yp,me={pluginManager:ht("pluginManager"),vizManager:ht("vizManager"),colorManager:ht("colorManager"),instanceScope:{panelModel:ht("panelModel"),vizInstance:ht("vizInstance"),interactionManager:ht("interactionManager"),migrator:ht("migrator"),operationManager:ht("operationManager"),triggerManager:ht("triggerManager")}},Fr=()=>{try{yn.install(zl())}catch{}const t=new ap(yn),e=new fp(yn);return{pluginManager:yn,vizManager:t,colorManager:e}},ut=m.createContext(Fr());try{yn.install(zl())}catch{}const Wr=m.createContext(null);function os(t){const e=m.useContext(Wr),n=W.useCreation(()=>t.configure(e||new As),[t.configure]),r=W.usePrevious(n);return r&&r!==n&&r.dispose(),s.jsx(Wr.Provider,{value:n,children:t.children})}function Ml(){return m.useContext(Wr)}const aS=({description:t,isDescriptionEmpty:e})=>e?null:s.jsx(a.Tooltip,{color:"white",label:s.jsx(Xn,{value:t,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:s.jsx(a.Box,{sx:{height:"16px",alignSelf:"center"},children:s.jsx(k.IconInfoCircle,{size:16,color:"gray"})})}),oS=S.observer(({label:t,config:{default_value:e,description:n,isDescriptionEmpty:r,...i},value:o,onChange:l})=>s.jsxs(a.Box,{children:[s.jsx(a.Text,{children:" "}),s.jsx(a.Checkbox,{label:s.jsxs(a.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[s.jsx(a.Box,{sx:{flexGrow:1},children:t}),s.jsx(aS,{description:n,isDescriptionEmpty:r})]}),checked:o||!1,onChange:c=>l(c.currentTarget.checked),...i,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),lS=({value:t,onChange:e,close:n,max_days:r,allowSingleDateInRange:i})=>{const{i18n:o}=_.useTranslation(),[l,c]=t,u=m.useMemo(()=>l||new Date,[l]),d=m.useMemo(()=>{if(l&&!c)return l},[l,c]),p=m.useMemo(()=>{if(l&&!c&&r>0)return I(l).add(r-1,"days").toDate()},[l,c,r]),h=g=>{const[f,v]=g;e(g),f&&v&&n()};return s.jsx(Yi.DatePicker,{defaultDate:u,numberOfColumns:2,type:"range",value:t,onChange:h,onNextMonth:console.log,minDate:d,maxDate:p,allowSingleDateInRange:i,locale:o.language})},cS=({begin:t,end:e})=>{const{t:n}=_.useTranslation(),r=m.useMemo(()=>I(e).diff(I(t),"days")+1,[t,e]);if(Number.isNaN(r))return s.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const i=r===1?n("filter.widget.date_range.one_day"):n("filter.widget.date_range.x_days",{count:r});return s.jsx(a.Tooltip,{label:i,children:s.jsx(a.Badge,{size:"sm",children:r})})},uS=({max_days:t})=>{const{t:e}=_.useTranslation();return t?s.jsxs(s.Fragment,{children:[s.jsx(a.Group,{position:"right",children:s.jsx(a.Badge,{size:"xs",children:e("filter.widget.date_range.x_max_days",{max_days:t})})}),s.jsx(a.Divider,{variant:"dashed",my:10})]}):null},Qr=()=>[{key:"d",value:"yesterday",group:"last",getRange:()=>{const t=Date.now();return[I(t).subtract(1,"day").startOf("day").toDate(),I(t).subtract(1,"day").endOf("day").toDate()]}},{key:"w",value:"last week",group:"last",getRange:()=>{const t=Date.now();return[I(t).subtract(1,"week").startOf("week").toDate(),I(t).subtract(1,"week").endOf("week").toDate()]}},{key:"m",value:"last month",group:"last",getRange:()=>{const t=Date.now();return[I(t).subtract(1,"month").startOf("month").toDate(),I(t).subtract(1,"month").endOf("month").toDate()]}},{key:"m2",value:"last 2 months",group:"last",getRange:()=>{const t=Date.now();return[I(t).subtract(2,"month").startOf("month").toDate(),I(t).subtract(1,"month").endOf("month").toDate()]}},{key:"m3",value:"last 3 months",group:"last",getRange:()=>{const t=Date.now();return[I(t).subtract(3,"month").startOf("month").toDate(),I(t).subtract(1,"month").endOf("month").toDate()]}},{key:"y",value:"last year",group:"last",getRange:()=>{const t=Date.now();return[I(t).subtract(1,"year").startOf("year").toDate(),I(t).subtract(1,"year").endOf("year").toDate()]}},{key:"d7",value:"recent 7 days",group:"recent",getRange:()=>{const t=Date.now();return[I(t).subtract(7,"day").startOf("day").toDate(),I(t).subtract(1,"day").endOf("day").toDate()]}},{key:"d30",value:"recent 30 days",group:"recent",getRange:()=>{const t=Date.now();return[I(t).subtract(30,"day").startOf("day").toDate(),I(t).subtract(1,"day").endOf("day").toDate()]}},{key:"d60",value:"recent 60 days",group:"recent",getRange:()=>{const t=Date.now();return[I(t).subtract(60,"day").startOf("day").toDate(),I(t).subtract(1,"day").endOf("day").toDate()]}},{key:"d90",value:"recent 90 days",group:"recent",getRange:()=>{const t=Date.now();return[I(t).subtract(90,"day").startOf("day").toDate(),I(t).subtract(1,"day").endOf("day").toDate()]}},{key:"d180",value:"recent 180 days",group:"recent",getRange:()=>{const t=Date.now();return[I(t).subtract(180,"day").startOf("day").toDate(),I(t).subtract(1,"day").endOf("day").toDate()]}},{key:"d365",value:"recent 365 days",group:"recent",getRange:()=>{const t=Date.now();return[I(t).subtract(365,"day").startOf("day").toDate(),I(t).subtract(1,"day").endOf("day").toDate()]}},{key:"d",value:"today",group:"this",getRange:()=>{const t=Date.now();return[I(t).startOf("day").toDate(),I(t).endOf("day").toDate()]}},{key:"w",value:"this week",group:"this",getRange:()=>{const t=Date.now();return[I(t).startOf("week").toDate(),I(t).endOf("week").toDate()]}},{key:"m",value:"this month",group:"this",getRange:()=>{const t=Date.now();return[I(t).startOf("month").toDate(),I(t).endOf("month").toDate()]}},{key:"y",value:"this year",group:"this",getRange:()=>{const t=Date.now();return[I(t).startOf("year").toDate(),I(t).endOf("year").toDate()]}},{key:"w",value:"this week so far",group:"this_so_far",getRange:()=>{const t=Date.now();return[I(t).startOf("week").toDate(),I(t).toDate()]}},{key:"m",value:"this month so far",group:"this_so_far",getRange:()=>{const t=Date.now();return[I(t).startOf("month").toDate(),I(t).toDate()]}},{key:"y",value:"this year so far",group:"this_so_far",getRange:()=>{const t=Date.now();return[I(t).startOf("year").toDate(),I(t).toDate()]}}];function Il(t){const n=Qr().find(r=>r.value===t);return n?n.getRange():null}const dS=({onChange:t})=>{const{t:e,i18n:n}=_.useTranslation(),r=l=>()=>{const c=l();t(c)},i=m.useMemo(()=>b.groupBy(Qr(),"group"),[]),o=n.language==="zh";return s.jsxs(s.Fragment,{children:[s.jsx(a.Divider,{variant:"dashed",my:10}),s.jsx(a.Table,{withBorder:!1,sx:{"tbody > tr > th, tbody > tr > td":{borderTop:"none",padding:"2px 6px"},"tbody > tr > th":{cursor:"default",userSelect:"none"},td:{paddingLeft:"1px"}},children:s.jsx("tbody",{children:Object.entries(i).map(([l,c])=>s.jsxs("tr",{children:[s.jsx("th",{children:s.jsx(a.Text,{size:"xs",color:"#555",children:e(`filter.widget.date_range.shortcut.${l}.label`)})}),c.map(({key:u,value:d,getRange:p})=>s.jsx("td",{children:s.jsx(a.Button,{compact:!0,size:"xs",variant:"subtle",onClick:r(p),children:e(`filter.widget.date_range.shortcut.${l}.${o?"full.":""}${u}`)})},u))]},l))})})]})},El=t=>({label:{display:"block",height:"21.7px"},input:{borderColor:t?"#228be6":"#e9ecef"}}),pS=({label:t,required:e,value:n,onChange:r,max_days:i,allowSingleDateInRange:o,inputFormat:l})=>{const{t:c}=_.useTranslation(),[u,{open:d,close:p}]=ie.useDisclosure(!1),[h,g]=n,f=h?I(h).format(l):"",v=g?I(g).format(l):"";return s.jsxs(a.Popover,{opened:u,onClose:p,position:"bottom-start",shadow:"md",children:[s.jsxs(a.Group,{position:"left",grow:!0,noWrap:!0,spacing:0,w:"288px",sx:{marginTop:"3px"},children:[s.jsx(a.Popover.Target,{children:s.jsx(a.TextInput,{label:t,labelProps:{title:t},required:e,icon:s.jsx(k.IconCalendar,{size:16}),placeholder:c("filter.widget.date_range.start_date"),readOnly:!0,value:f,onFocus:d,styles:El(u),sx:{".mantine-TextInput-label":{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",width:"calc(240px)",position:"relative",zIndex:1},".mantine-Input-input":{borderRight:"none",borderTopRightRadius:0,borderBottomRightRadius:0}}})}),s.jsx(a.TextInput,{label:s.jsx(a.Group,{position:"right",children:s.jsx(cS,{begin:h,end:g})}),icon:s.jsx(k.IconMinus,{size:16}),placeholder:c("filter.widget.date_range.end_date"),readOnly:!0,disabled:!h,value:v,onFocus:d,styles:El(u),sx:{".mantine-Input-icon":{transform:"translateX(-22px)"},".mantine-Input-input":{borderLeft:"none",borderTopLeftRadius:0,borderBottomLeftRadius:0},".mantine-Input-input[data-disabled]":{backgroundColor:"transparent",backgroundImage:"linear-gradient(to right, #fff 0%, #f1f3f5 30%)",opacity:1},".mantine-Input-input[data-disabled]::placeholder":{opacity:.6}}})]}),s.jsxs(a.Popover.Dropdown,{p:"sm",children:[s.jsx(uS,{max_days:i}),s.jsx(lS,{value:n,onChange:r,close:p,allowSingleDateInRange:o,max_days:i}),s.jsx(dS,{onChange:r})]})]})},Al=S.observer(({label:t,config:e,value:n=[null,null],onChange:r})=>{const{inputFormat:i,required:o,max_days:l,allowSingleDateInRange:c}=e,u=Array.isArray(n)?n.map(p=>p?I(p).toDate():null):[null,null],d=p=>{r(p.map(h=>h&&I(h).format(i)))};return s.jsx(pS,{label:t,value:u,onChange:d,inputFormat:i,allowSingleDateInRange:c,max_days:l,required:o})}),hS=a.createStyles((t,{radius:e=4})=>({root:{borderRadius:t.fn.radius(e),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-select.rc-select-open":{borderColor:"#228be6 !important",".rc-select-selection-overflow-item-rest":{display:"none"},".rc-select-selection-overflow-item-suffix":{display:"block"}},".rc-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-select-selection-search-mirror":{display:"none"},".rc-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:t.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:t.fontSizes.xs,zIndex:300,backgroundColor:"#fff",border:"1px solid #e9ecef",marginTop:6,padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px","&.rc-select-dropdown-slide-up-leave-active":{display:"none"},".rc-select-item-empty":{padding:"8px 12px"},".rc-select-item-option":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px 8px 2px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},flexDirection:"row-reverse",".rc-select-item-option-state":{flexGrow:0,flexShrink:0,width:"30px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},".rc-select-item-option-content":{width:"calc(100% - 30px)",overflow:"hidden",'div[data-role="label"]':{overflowWrap:"break-word"}}},".rc-virtual-list-holder-inner":{alignItems:"flex-start"}}})),Rr=({errorMessage:t})=>{const{t:e}=_.useTranslation();return t?s.jsx(a.Text,{color:"red",size:12,children:t}):s.jsx(a.Text,{color:"dimmed",size:12,children:e("filter.widget.common.selector_option_empty")})},mS=({disabled:t,classNames:e,styles:n,unstyled:r,radius:i,style:o,label:l,value:c,onChange:u,options:d,errorMessage:p,required:h})=>{const{t:g}=_.useTranslation(),{classes:f,cx:v}=hS({radius:i},{name:"MultiSelectWidget",classNames:e,styles:n,unstyled:r}),[w,T]=m.useState(!1),D=N=>{T(N)},z=w&&(c==null?void 0:c.length)>0,[E,V]=m.useState(""),F=m.useMemo(()=>{if(!E)return d;const N=E.toLowerCase(),Q=ue=>{var le;return((le=ue.description)==null?void 0:le.toLowerCase().includes(N))||ue.label.toLowerCase().includes(N)};return d.filter(Q)},[E,d]);return s.jsxs(a.Stack,{spacing:3,children:[s.jsxs(a.Group,{position:"apart",children:[s.jsxs(a.Text,{className:f.label,children:[l,h&&s.jsx("span",{className:f.required,"aria-hidden":"true",children:"*"})]}),z&&s.jsx(a.Tooltip,{label:g("filter.widget.common.x_selected",{count:c.length}),children:s.jsx(a.Badge,{children:c.length})})]}),s.jsx(ca,{disabled:t,allowClear:!0,className:v(f.root,"check-select"),dropdownClassName:v(f.dropdown,""),onDropdownVisibleChange:D,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:o,clearIcon:()=>s.jsx(a.CloseButton,{}),value:c,onChange:u,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:s.jsx(Rr,{errorMessage:p}),maxTagTextLength:10,maxTagPlaceholder:N=>g("filter.widget.common.x_selected",{count:N.length}),searchValue:E,onSearch:V,filterOption:!1,children:F.map(N=>s.jsxs(ca.Option,{title:N.label,children:[s.jsx(a.Text,{size:"sm","data-role":"label",children:N.label}),N.description&&s.jsx(a.Text,{size:"xs",color:"dimmed","data-role":"description",children:N.description})]},N.value))})]})},xS=S.observer(({label:t,config:e,value:n,onChange:r})=>{const i=he(),o=!!e.options_query_id,{state:l,error:c}=i.getDataStuffByID(e.options_query_id),u=l==="loading",d=e.min_width?e.min_width:"200px",p=o?u:!1,h=g=>r(g,!1);return s.jsx(mS,{label:t,options:e.options,style:{minWidth:"160px",width:d,maxWidth:p?d:"unset",borderColor:"#e9ecef"},disabled:p,value:n,onChange:h,errorMessage:c,required:e.required})}),gS=m.forwardRef(({label:t,description:e,...n},r)=>s.jsx("div",{ref:r,...n,children:s.jsx(a.Group,{noWrap:!0,children:s.jsxs("div",{children:[s.jsx(a.Text,{size:"sm","data-role":"label",children:t}),s.jsx(a.Text,{size:"xs",color:"dimmed","data-role":"description",children:e})]})})})),fS=S.observer(({label:t,config:e,value:n,onChange:r})=>{const i=he(),o=!!e.options_query_id,{state:l,error:c}=i.getDataStuffByID(e.options_query_id),u=l==="loading";return s.jsx(a.Select,{label:t,data:e.options,disabled:o?u:!1,value:n,onChange:r,maxDropdownHeight:500,styles:{root:{width:e.width?e.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"},".mantine-Select-nothingFound":{fontSize:"0.75rem",textAlign:"left",padding:"4px 10px"}},itemComponent:gS,searchable:!c,nothingFound:s.jsx(Rr,{errorMessage:c}),clearable:e.clearable})});function yS({label:t,config:e,value:n,onChange:r}){return s.jsx(a.TextInput,{label:t,value:n||"",onChange:i=>r(i.currentTarget.value),...e,styles:{input:{borderColor:"#e9ecef"}}})}const bS=({rotate:t,onClick:e})=>s.jsx("svg",{onClick:e,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${t})`,children:s.jsx("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),vS=({expanded:t,isLeaf:e,value:n,onClick:r,...i})=>(n==="0-0-value"&&console.log(i),e?s.jsx("span",{style:{width:"14px",display:"inline-block"}}):s.jsx(bS,{rotate:t?"0":"-90",onClick:r,...i})),_S=({onClick:t})=>s.jsxs("svg",{onClick:t,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[s.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),s.jsx("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),s.jsx("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),s.jsx("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),jS=({onClick:t,...e})=>s.jsx(_S,{onClick:t,...e}),wS=a.createStyles((t,{radius:e=4})=>({root:{borderRadius:t.fn.radius(e),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:t.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:t.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),CS=({disabled:t,classNames:e,styles:n,unstyled:r,radius:i,style:o,label:l,value:c,onChange:u,treeData:d,errorMessage:p,required:h,treeCheckStrictly:g})=>{const{t:f}=_.useTranslation(),{classes:v,cx:w}=wS({radius:i},{name:"FilterTreeSelectWidget",classNames:e,styles:n,unstyled:r}),[T,D]=m.useState(!1),z=V=>{D(V)},E=T&&(c==null?void 0:c.length)>0;return s.jsxs(a.Stack,{spacing:3,children:[s.jsxs(a.Group,{position:"apart",children:[s.jsxs(a.Text,{className:v.label,children:[l,h&&s.jsx("span",{className:v.required,"aria-hidden":"true",children:"*"})]}),E&&s.jsx(a.Tooltip,{label:f("filter.widget.common.x_selected",{count:c.length}),children:s.jsx(a.Badge,{children:c.length})})]}),s.jsx(ua,{disabled:t,allowClear:!0,treeCheckStrictly:g,labelInValue:!0,className:w(v.root,"check-select"),dropdownClassName:w(v.dropdown,""),onDropdownVisibleChange:z,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,listHeight:510,treeLine:!0,clearIcon:()=>s.jsx(a.CloseButton,{}),switcherIcon:vS,treeIcon:jS,maxTagTextLength:10,value:c,treeData:d,notFoundContent:s.jsx(Rr,{errorMessage:p}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:ua.SHOW_PARENT,onChange:u,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:()=>f("filter.widget.common.x_selected",{count:c.length})})]})},SS=S.observer(({label:t,config:e,value:n,onChange:r})=>{const{treeData:i,treeDataLoading:o,errorMessage:l}=e,c=g=>{const f=g.map(v=>v.value);r(f,!1)},u=m.useMemo(()=>e.initialSelection(n),[n,e.initialSelection]),d=e.min_width?e.min_width:"200px",h=!!e.options_query_id?o:!1;return s.jsx(CS,{disabled:h,style:{minWidth:"160px",width:d,maxWidth:h?d:"unset",borderColor:"#e9ecef"},value:[...u],onChange:c,treeData:i,errorMessage:l,label:t,required:e.required,treeCheckStrictly:e.treeCheckStrictly})}),kS=S.observer(({filter:{type:t,config:e,key:n,...r},formFieldProps:i})=>{switch(t){case"select":return s.jsx(fS,{...r,...i,config:e});case"multi-select":return s.jsx(xS,{...r,...i,config:e});case"tree-select":return s.jsx(SS,{...r,...i,config:e});case"text-input":return s.jsx(yS,{...r,...i,config:e});case"date-range":return s.jsx(Al,{...r,...i,config:e});case"checkbox":return s.jsx(oS,{...r,...i,config:e});default:return null}}),TS=S.observer(m.forwardRef(({filter:t,...e},n)=>s.jsx("div",{className:"filter-root",ref:n,children:s.jsx(je,{children:s.jsx(kS,{filter:t,formFieldProps:e})})}))),DS=({disabled:t})=>{const{searchButtonProps:e}=Ea(),{children:n="Search",type:r,...i}=e;return s.jsx(a.Button,{color:"blue",size:"sm",type:"submit",...i,disabled:t||i.disabled,children:n})};function zS(t){const e=Y();m.useEffect(()=>{var n,r;(r=(n=e.filters).updatePreviewValues)==null||r.call(n,t)},[t])}const MS=({opened:t,toggle:e})=>{const{t:n}=_.useTranslation();return s.jsx(a.Group,{position:"right",ml:-4,mt:-4,mb:t?4:0,children:s.jsx(a.Button,{size:"xs",compact:!0,variant:"subtle",color:t?"gray":"blue",leftIcon:t?s.jsx(k.IconChevronsUp,{size:14}):s.jsx(k.IconChevronsDown,{size:14}),onClick:e,children:n(t?"filter.hide_filters":"filter.show_filters")})})},Pl=S.observer(function({view:e}){const[n,{toggle:r}]=ie.useDisclosure(!0),i=he(),{control:o,handleSubmit:l,reset:c}=y.useForm({defaultValues:i.filters.values,reValidateMode:"onBlur"}),u=y.useWatch({control:o});m.useEffect(()=>{c(i.filters.values)},[i.filters.values,c]),zS(u);const d=i.filters.visibleInView(e.id),p=m.useMemo(()=>d.every(v=>v.should_auto_submit),[d]),h=m.useMemo(()=>d.filter(v=>b.get(v,"config.required",!1)),[d]),g=m.useMemo(()=>h.length===0?!1:h.some(v=>!v.requiredAndPass(u[v.key])),[u,h]);if(d.length===0)return null;const f=(v,w)=>(T,D)=>{w(T),(v.should_auto_submit||D)&&i.filters.setValueByKey(v.key,T)};return s.jsxs("form",{onSubmit:l(i.filters.setValues),children:[s.jsx(MS,{opened:n,toggle:r}),s.jsx(a.Collapse,{in:n,children:s.jsxs(a.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:p?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[s.jsx(a.Group,{align:"flex-start",children:d.map(v=>s.jsx(y.Controller,{name:v.key,control:o,render:({field:w})=>s.jsx(TS,{filter:v,value:w.value,onChange:f(v,w.onChange)})},v.id))}),!p&&s.jsx(a.Group,{sx:{alignSelf:"flex-end"},children:s.jsx(DS,{disabled:g})})]})})]})}),IS={viewPanelInFullScreen:b.noop,inFullScreen:!1},ls=m.createContext(IS),Ur=x.types.model("MockContextMeta",{current:x.types.optional(x.types.frozen(),{})}).views(t=>({get keys(){return Object.keys(t.current)},get keySet(){return new Set(this.keys)},get entries(){return Object.entries(t.current)}})).actions(t=>({replace(e){t.current=e},defaults(e){t.current={...e,...t.current}},get(e){return t.current[e]},set(e,n){t.current[e]=n}}));function Yr(t){return{current:t}}const ES=x.types.model("PanelStyleBorderMeta",{enabled:x.types.boolean}).views(t=>({get json(){const{enabled:e}=t;return{enabled:e}}})).actions(t=>({setEnabled(e){t.enabled=e}})),$l=x.types.model("PanelStyleMeta",{border:ES}).views(t=>({get json(){const{border:e}=t;return{border:e.json}}})).actions(t=>({})),Bl=x.types.model("PanelTitleMeta",{show:x.types.optional(x.types.boolean,!0)}).views(t=>({get json(){const{show:e}=t;return{show:e}}})).actions(t=>({setShow(e){t.show=e}})),Ll=x.types.model("VariableMeta",{name:x.types.string,size:x.types.string,weight:x.types.string,color:x.types.union(x.types.model({type:x.types.literal("static"),staticColor:x.types.string}),x.types.model({type:x.types.literal("continuous"),valueRange:x.types.array(x.types.number),colorRange:x.types.array(x.types.string)}),x.types.model({type:x.types.literal("piecewise")})),formatter:x.types.model({output:x.types.enumeration("Output",["number","percent"]),average:x.types.optional(x.types.boolean,!1),mantissa:x.types.number,trimMantissa:x.types.optional(x.types.boolean,!1),absolute:x.types.optional(x.types.boolean,!1)}),data_field:x.types.string,aggregation:x.types.union(x.types.model({type:x.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:x.types.frozen(),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("quantile"),config:x.types.model({p:x.types.number}),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("pick_record"),config:x.types.model({method:x.types.enumeration("Pick Record Method",["first","last"])}),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("custom"),config:x.types.model({func:x.types.string}),fallback:x.types.optional(x.types.string,"0")}))}).views(t=>({get json(){const{name:e,size:n,weight:r,color:i,formatter:o,data_field:l,aggregation:c}=t;return b.cloneDeep({name:e,size:n,color:i,weight:r,formatter:o,data_field:l,aggregation:c})}})),ql=x.types.model("PanelVizMeta",{type:x.types.string,conf:x.types.frozen()}).views(t=>({get json(){return{conf:t.conf,type:t.type}}})).actions(t=>({setType(e){t.type=e},setConf(e){t.conf=e}})),Ol=x.types.model({id:x.types.string,name:x.types.optional(x.types.string,""),title:Bl,description:x.types.string,queryIDs:x.types.array(x.types.string),viz:ql,style:$l,variables:x.types.optional(x.types.array(Ll),[])}).views(t=>({get json(){const{id:e,name:n,title:r,description:i,queryIDs:o}=t;return{id:e,viz:t.viz.json,name:n,style:t.style.json,title:r.json,queryIDs:[...o],variables:t.variables.map(l=>l.json),description:i}},get queryIDSet(){return new Set(t.queryIDs)}})).actions(t=>({setID(e){t.id=e},setName(e){t.name=e},setDescription(e){t.description=e},addQueryID(e){t.queryIDSet.has(e)||t.queryIDs.push(e)},removeQueryID(e){if(!t.queryIDSet.has(e))return;const n=new Set(t.queryIDSet);n.delete(e),t.queryIDs=x.cast(Array.from(n))},setQueryIDs(e){t.queryIDs=x.cast(e)},addVariable(e){t.variables.push(e)},removeVariable(e){t.variables.remove(e)}}));var de=(t=>(t.Postgresql="postgresql",t.MySQL="mysql",t.HTTP="http",t.Transform="transform",t))(de||{});const Vl=x.types.model("QueryMeta",{id:x.types.string,name:x.types.string,type:x.types.enumeration("DataSourceType",[de.Postgresql,de.MySQL,de.HTTP,de.Transform]),key:x.types.string,sql:x.types.string,pre_process:x.types.optional(x.types.string,""),post_process:x.types.optional(x.types.string,""),run_by:x.types.optional(x.types.array(x.types.string),[]),react_to:x.types.optional(x.types.array(x.types.string),[]),dep_query_ids:x.types.optional(x.types.array(x.types.string),[])}).views(t=>({get valid(){return t.id&&t.type&&t.key&&t.name?t.type===de.HTTP?!!t.pre_process:!!t.sql:!1},get json(){const{id:e,name:n,type:r,key:i,sql:o,run_by:l,react_to:c,pre_process:u,post_process:d,dep_query_ids:p}=t;return Ft({id:e,key:i,sql:o,name:n,type:r,run_by:l,react_to:c,pre_process:u,post_process:d,dep_query_ids:p})}})).actions(t=>({setName(e){t.name=e},setKey(e){t.key=e},setType(e){t.type=e},setSQL(e){t.sql=e},setRunBy(e){t.run_by.length=0,t.run_by.push(...e)},setReactTo(e){t.react_to.length=0,t.react_to.push(...e)},setPreProcess(e){t.pre_process=e},setPostProcess(e){t.post_process=e},setDependantQueryIDs(e){t.dep_query_ids.length=0,t.dep_query_ids.push(...e)}})),Nl=x.types.model("LayoutItemMeta",{id:x.types.identifier,panelID:x.types.string,x:x.types.number,y:x.types.maybeNull(x.types.number),w:x.types.number,h:x.types.number,moved:x.types.optional(x.types.boolean,!1),static:x.types.optional(x.types.boolean,!1)}).views(t=>({get json(){const{id:e,panelID:n,x:r,y:i,w:o,h:l,moved:c}=t;return{h:l,w:o,x:r,y:i===null?0:i,id:e,moved:c,static:t.static,panelID:n}},get contentModel(){return x.getRoot(t).content},get panel(){const{panelID:e}=t;return this.contentModel.panels.findByID(e)},get layoutProperies(){const{id:e,x:n,y:r,w:i,h:o,moved:l}=t;return{id:e,i:e,x:n,y:r===null?1/0:r,w:i,h:o,moved:l,static:t.static}}})).actions(t=>({set(e){const{isDraggable:n,x:r,y:i,w:o,h:l,moved:c}=e;t.x=r,t.y=i,t.w=o,t.h=l,t.moved=!!c,t.static=!!e.static},setWidth(e){t.w=e},setHeight(e){t.h=e}})),Gl=x.types.model("LayoutSetMeta",{id:x.types.identifier,name:x.types.string,breakpoint:x.types.number,list:x.types.optional(x.types.array(Nl),[])}).views(t=>({get json(){const{id:e,name:n,breakpoint:r,list:i}=t;return{id:e,name:n,breakpoint:r,list:i.map(o=>Ft(o.json))}},jsonByPanelIDSet(e){const{id:n,name:r,breakpoint:i,list:o}=t;return{id:n,name:r,breakpoint:i,list:o.filter(l=>e.has(l.panelID)).map(l=>Ft(l.json))}},findByID(e){return t.list.find(n=>n.id===e)},findByPanelID(e){return t.list.find(n=>n.panelID===e)}})).actions(t=>({setName(e){t.name=e},setBreakpoint(e){t.breakpoint=e},addLayout(e){t.list.push(e)},addNewLayout(e){t.list.push({id:pt.v4(),panelID:e,x:0,y:1/0,w:18,h:300,static:!1,moved:!1})},removeByPanelID(e){const n=t.list.findIndex(r=>r.panelID===e);n>=0&&t.list.splice(n,1)},updateLayoutItem(e){const n=t.list.find(r=>r.id===e.i);if(!n){console.error("Trying to update a layout that doesn't exist"),console.log({strangeLayoutItem:e});return}n.set(e)}})),Fl=x.types.model("SQLSnippetMeta",{key:x.types.string,value:x.types.string}).views(t=>({get json(){const{key:e,value:n}=t;return{key:e,value:n}}})).actions(t=>({setKey(e){t.key=e},setValue(e){t.value=e}}));var re=(t=>(t.Select="select",t.MultiSelect="multi-select",t.TreeSelect="tree-select",t.TextInput="text-input",t.Checkbox="checkbox",t.DateRange="date-range",t))(re||{});const Kr=x.types.model("FilterCheckboxConfigMeta",{_name:x.types.literal("checkbox"),description:x.types.optional(x.types.string,""),default_value:x.types.boolean}).views(t=>({get json(){const{_name:e,description:n,default_value:r}=t;return{_name:e,description:n,default_value:r}},get isDescriptionEmpty(){const{description:e}=t;return e===""||e==="<p></p>"}})).actions(t=>({setDefaultValue(e){t.default_value=e},setDescription(e){t.description=e}})),Wl=()=>Kr.create({_name:"checkbox",description:"",default_value:!1});function Ql(t,e){return t.map(n=>{try{return n?I.tz(n,"UTC").format(e):null}catch{return console.log(`[date-range] failed parsing ${n}`),null}})}const AS=x.types.model("FilterDateRangeConfigMeta",{_name:x.types.literal("date-range"),required:x.types.boolean,inputFormat:x.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:x.types.optional(x.types.array(x.types.union(x.types.string,x.types.null)),[null,null]),default_shortcut:x.types.optional(x.types.string,""),clearable:x.types.boolean,max_days:x.types.optional(x.types.number,0),allowSingleDateInRange:x.types.optional(x.types.boolean,!1)}).views(t=>({get json(){const{_name:e,max_days:n,required:r,clearable:i,inputFormat:o,default_value:l,default_shortcut:c,allowSingleDateInRange:u}=t;return{_name:e,max_days:n,required:r,clearable:i,inputFormat:o,default_value:Ql(l,o),default_shortcut:c,allowSingleDateInRange:u}},truthy(e){return Array.isArray(e)&&e.length===2&&e.every(n=>!!n)}})).actions(t=>({setFilterValue(e){try{const n=x.getParent(t);x.getParent(n,2).setValueByKey(n.key,e)}catch(n){console.error(n)}}})).actions(t=>({setRequired(e){t.required=e},setClearable(e){t.clearable=e},setInputFormat(e){t.inputFormat=e},setDefaultValue(e){t.default_value.length=0,t.default_value.push(...e),t.setFilterValue(e)},setDefaultShortcut(e){if(t.default_shortcut=e,!e)return;const n=Il(t.default_shortcut);if(console.log(n),n){const r=n.map(i=>I(i).format(t.inputFormat));t.setFilterValue(r)}},setMaxDays(e){t.max_days=e,e>0&&(t.clearable=!0)},setAllowSingleDateInRange(e){t.allowSingleDateInRange=e}})),Jr=x.types.snapshotProcessor(AS,{preProcessor({default_value:t,...e}){return{...e,default_value:t.map(n=>n===null?null:I.tz(n,"UTC").toISOString())}},postProcessor(t){const{default_value:e,...n}=t;return{...n,default_value:Ql(e,n.inputFormat)}}}),Rl=()=>Jr.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),PS=x.types.model({label:x.types.string,value:x.types.string}).actions(t=>({setLabel(e){t.label=e},setValue(e){t.value=e}})),Xr=x.types.model("FilterConfigModel_BaseSelect",{static_options:x.types.optional(x.types.array(PS),[]),options_query_id:x.types.optional(x.types.string,""),default_selection_count:x.types.optional(x.types.number,0),required:x.types.optional(x.types.boolean,!1)}).views(t=>({get contentModel(){return x.getRoot(t).content},get filter(){return x.getParent(t)},get usingQuery(){return!!t.options_query_id}})).views(t=>({get options(){if(!t.usingQuery)return t.static_options;const{data:e,state:n}=t.contentModel.getDataStuffByID(t.options_query_id);return n==="error"?[]:Array.isArray(e)?e.filter(r=>"label"in r&&"value"in r):[]}})).actions(t=>({setRequired(e){t.required=e},addStaticOption(e){t.static_options.push(e)},removeStaticOption(e){t.static_options.splice(e,1)},setDefaultSelectionCount(e){t.default_selection_count=e},setOptionsQueryID(e){t.options_query_id=e??""}})),Zr=x.types.compose("FilterMultiSelectConfigMeta",x.types.model({_name:x.types.literal("multi-select"),min_width:x.types.optional(x.types.string,""),default_value:x.types.optional(x.types.array(x.types.string),[])}),Xr).views(t=>({get json(){const{_name:e,default_value:n,required:r,min_width:i,static_options:o,options_query_id:l,default_selection_count:c}=t;return Ft({_name:e,required:!!r,min_width:i,default_value:n,static_options:o,options_query_id:l,default_selection_count:c})},get default_selection(){return t.usingQuery?t.options.slice(0,t.default_selection_count).map(e=>e.value):t.filter.formattedDefaultValue},truthy(e){return Array.isArray(e)&&e.length>0}})).actions(t=>({setDefaultValue(e){t.default_value=x.cast(e)},setMinWidth(e){t.min_width=e},setDefaultSelection(){const e=x.getRoot(t).content.filters,n=x.getParent(t).key,r=new Set(t.options.map(o=>o.value)),i=(e.values[n]??[]).filter(o=>r.has(o));i.length>0?e.setValueByKey(n,i):e.setValueByKey(n,t.default_selection)}})).actions(t=>({afterCreate(){x.addDisposer(t,J.reaction(()=>J.toJS(t.default_selection),t.setDefaultSelection,{fireImmediately:!0,delay:0}))}})),Ul=()=>Zr.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),Hr=x.types.compose("FilterConfigModel_Select",x.types.model({_name:x.types.literal("select"),default_value:x.types.string,width:x.types.optional(x.types.string,""),clearable:x.types.optional(x.types.boolean,!1)}),Xr).views(t=>({get json(){const{_name:e,clearable:n,default_value:r,required:i,width:o,static_options:l,options_query_id:c,default_selection_count:u}=t;return Ft({_name:e,width:o,required:i,clearable:n,default_value:r,static_options:l,options_query_id:c,default_selection_count:u})},truthy(e){return!!e},getSelectOption(e){return t.options.find(n=>n.value===e)},get default_selection(){return t.usingQuery?t.default_selection_count>0&&t.options.length>0?t.options[0].value:"":t.filter.formattedDefaultValue}})).actions(t=>({setDefaultValue(e){t.default_value=e},setWidth(e){t.width=e},setClearable(e){t.clearable=e},setDefaultSelection(){var o;const e=x.getRoot(t).content.filters,n=x.getParent(t).key,r=e.values[n],i=(o=t.options.find(l=>l.value===r))==null?void 0:o.value;i?e.setValueByKey(n,i):e.setValueByKey(n,t.default_selection)}})).actions(t=>({afterCreate(){x.addDisposer(t,J.reaction(()=>J.toJS(t.default_selection),t.setDefaultSelection,{fireImmediately:!1,delay:0}))}})),Yl=()=>Hr.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),ei=x.types.model("FilterTextInputConfigMeta",{_name:x.types.literal("text-input"),required:x.types.boolean,default_value:x.types.string}).views(t=>({get json(){const{_name:e,required:n,default_value:r}=t;return{_name:e,required:n,default_value:r}},truthy(e){return typeof e!="string"?!1:!!e.trim()}})).actions(t=>({setRequired(e){t.required=e},setDefaultValue(e){t.default_value=e}})),ti=()=>ei.create({_name:"text-input",required:!1,default_value:""});function $S(t){return Ou.arrayToTree(t,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function BS(t){return t.map(e=>{const{label:n,description:r,...i}=e,o={...i,filterBasis:`${n}___${r??""}`,description:r,label:n};return r&&(o.label=m.createElement("div",{},[m.createElement(a.Text,{key:0,title:e.label},e.label),m.createElement(a.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:e.description},e.description)])),o})}const ni=x.types.compose("FilterTreeSelectConfigMeta",x.types.model({_name:x.types.literal("tree-select"),min_width:x.types.optional(x.types.string,""),default_value:x.types.optional(x.types.array(x.types.string),[]),treeCheckStrictly:x.types.optional(x.types.boolean,!1)}),Xr).views(t=>({get json(){const{_name:e,default_value:n,required:r,min_width:i,static_options:o,options_query_id:l,default_selection_count:c,treeCheckStrictly:u}=t;return{_name:e,required:!!r,min_width:i,default_value:n,static_options:o,options_query_id:l,treeCheckStrictly:u,default_selection_count:c}},get plainData(){const{data:e}=t.contentModel.getDataStuffByID(t.options_query_id);return e},get treeData(){const e=this.plainData,n=BS(e);return $S(n)},get errorMessage(){const{error:e}=t.contentModel.getDataStuffByID(t.options_query_id);return e},get treeDataLoading(){const{state:e}=t.contentModel.getDataStuffByID(t.options_query_id);return e==="loading"},get defaultSelection(){const e=t.filter.formattedDefaultValue;if(Array.isArray(e)&&e.length>0)return e;const{default_selection_count:n}=t;return n?this.treeData.slice(0,n).map(i=>i.value):[]},valueObjects(e){const n=new Set(e);return this.plainData.filter(r=>n.has(r.value))},initialSelection(e){return e?this.valueObjects(e):this.valueObjects(this.defaultSelection)},truthy(e){return Array.isArray(e)&&e.length>0}})).actions(t=>({setDefaultValue(e){t.default_value=x.cast(e)},setMinWidth(e){t.min_width=e},setTreeCheckStrictly(e){t.treeCheckStrictly=e},applyDefaultSelection(){const e=x.getParent(t,1).key,n=t.contentModel.filters,r=n.values[e],i=new Set(t.plainData.map(l=>l.value)),o=(r??[]).filter(l=>i.has(l));o.length>0?n.setValueByKey(e,o):n.setValueByKey(e,t.defaultSelection)},afterCreate(){x.addDisposer(t,J.reaction(()=>JSON.stringify(t.defaultSelection),this.applyDefaultSelection,{fireImmediately:!0,delay:0}))}})),Kl=()=>ni.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),si=x.types.model("FilterMeta",{id:x.types.identifier,key:x.types.string,label:x.types.string,order:x.types.number,visibleInViewsIDs:x.types.array(x.types.string),auto_submit:x.types.optional(x.types.boolean,!1),default_value_func:x.types.optional(x.types.string,""),type:x.types.enumeration("DashboardFilterType",[re.Select,re.MultiSelect,re.TreeSelect,re.TextInput,re.Checkbox,re.DateRange]),config:x.types.union(Hr,Zr,ni,ei,Kr,Jr)}).views(t=>({get contentModel(){return x.getRoot(t).content},get filters(){return this.contentModel.filters},get plainDefaultValue(){const e=t.config.default_value;return Array.isArray(e)?[...e]:e},get usingDefaultValue(){return t.type!==re.TreeSelect},get usingDefaultValueFunc(){return!!t.default_value_func},get formattedDefaultValue(){return this.filters.formattedDefaultValues[t.key]},get auto_submit_supported(){return[re.Select,re.Checkbox,re.DateRange].includes(t.type)}})).views(t=>({get json(){const{id:e,key:n,label:r,order:i,visibleInViewsIDs:o,default_value_func:l,auto_submit:c,type:u,config:d}=t;return{id:e,key:n,type:u,label:r,order:i,config:d.json,auto_submit:c,visibleInViewsIDs:J.toJS(o),default_value_func:l}},get visibleInViewsIDSet(){return new Set(t.visibleInViewsIDs)},get should_auto_submit(){return t.auto_submit_supported&&t.auto_submit},requiredAndPass(e){return b.get(t.config,"required",!1)?b.get(t.config,"truthy",()=>!0)(e):!1}})).actions(t=>({setKey(e){t.key=e},setLabel(e){t.label=e},setOrder(e){t.order=e},setType(e){switch(e){case re.Select:t.config=Yl();break;case re.MultiSelect:t.config=Ul();break;case re.TreeSelect:t.config=Kl();break;case re.TextInput:t.config=ti();break;case re.Checkbox:t.config=Wl();break;case re.DateRange:t.config=Rl();break}t.type=e},setVisibleInViewsIDs(e){t.visibleInViewsIDs.length=0,t.visibleInViewsIDs.push(...e)},setAutoSubmit(e){t.auto_submit=t.auto_submit_supported&&e},setDefaultValueFunc(e){t.default_value_func=e}}));var B=(t=>(t.Division="div",t.Modal="modal",t.Tabs="tabs",t))(B||{});const ri=x.types.model("ViewDivisionConfig",{_name:x.types.literal(B.Division)}).views(t=>({get json(){const{_name:e}=t;return{_name:e}}})),Jl=()=>ri.create({_name:B.Division}),LS=x.types.model("CustomModalTitleModel",{enabled:x.types.optional(x.types.boolean,!1),func_content:x.types.optional(x.types.string,"")}).views(t=>({get json(){const{enabled:e,func_content:n}=t;return{enabled:e,func_content:n}},get value(){const{enabled:e,func_content:n}=t,r=x.getParent(t,2),i=x.getRoot(t);if(!e)return r.name;try{const o={filters:i.content.filters.values,context:i.context.current};return new Function(`return ${n}`)()(o)}catch(o){return console.error(o),r.name}}})).actions(t=>({setEnabled(e){t.enabled=e},setFuncContent(e){t.func_content=e},replace({enabled:e,func_content:n}){t.enabled=e,t.func_content=n}})),cs={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
445
- `)},ii=x.types.model("ViewModalConfig",{_name:x.types.literal(B.Modal),width:x.types.string,height:x.types.string,custom_modal_title:x.types.optional(LS,cs)}).views(t=>({get json(){const{_name:e,width:n,height:r,custom_modal_title:i}=t;return{_name:e,width:n,height:r,custom_modal_title:i.json}}})).actions(t=>({setWidth(e){t.width=e},setHeight(e){t.height=e}})),Xl=()=>ii.create({_name:B.Modal,width:"90vw",height:"90vh"}),qS=x.types.model("ViewTabsTabModel",{id:x.types.identifier,name:x.types.string,view_id:x.types.string,color:x.types.optional(x.types.string,""),order:x.types.optional(x.types.number,0)}).views(t=>({get json(){const{id:e,name:n,view_id:r,color:i,order:o}=t;return{id:e,name:n,color:i,order:o,view_id:r}}})).actions(t=>({setName(e){t.name=e},setViewID(e){t.view_id=e},setColor(e){t.color=e},setOrder(e){t.order=e}})),ai=x.types.model("ViewTabsConfig",{_name:x.types.literal(B.Modal),tabs:x.types.optional(x.types.array(qS),[]),variant:x.types.optional(x.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:x.types.optional(x.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:x.types.optional(x.types.boolean,!1)}).views(t=>({get json(){const{_name:e,variant:n,orientation:r,tabs:i,grow:o}=t;return{grow:o,tabs:i.map(l=>l.json),_name:e,variant:n,orientation:r}},get tabsInOrder(){return b.sortBy(t.tabs,"order")}})).actions(t=>({setVariant(e){t.variant=e},setOrientation(e){t.orientation=e},setGrow(e){t.grow=e},setTabs(e){t.tabs.length=0,t.tabs=x.cast(e)},addTab(){const e=ie.randomId(),n={id:e,name:e,view_id:""};t.tabs.push(n)},removeTab(e){t.tabs.splice(e,1)}})),Zl=()=>ai.create({_name:B.Modal,tabs:[]}),Hl=x.types.model({id:x.types.identifier,name:x.types.string,type:x.types.enumeration("EViewComponentType",[B.Division,B.Modal,B.Tabs]),config:x.types.union(ri,ii,ai),panelIDs:x.types.optional(x.types.array(x.types.string),[])}).views(t=>({get json(){const{id:e,name:n,type:r,config:i}=t;return{id:e,name:n,type:r,config:i.json,panelIDs:t.panelIDs.map(o=>o)}}})).actions(t=>({setName(e){t.name=e},setType(e){if(t.type!==e){switch(e){case B.Division:t.config=Jl();break;case B.Modal:t.config=Xl();break;case B.Tabs:t.config=Zl();break}t.type=e}},appendPanelID(e){t.panelIDs.push(e)},appendPanelIDs(e){t.panelIDs.push(...e)},removePanelID(e){const n=t.panelIDs.filter(r=>r!==e);t.panelIDs.length=0,t.panelIDs.push(...n)}})),yt="11.10.0",OS={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:B.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:yt,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},oi=x.types.model("DataSourceMetaModel",{id:x.types.string,type:x.types.enumeration("DataSourceType",[de.HTTP,de.MySQL,de.Postgresql]),key:x.types.string,config:x.types.frozen()}),ec=x.types.model("DataSourcesMetaModel",{list:x.types.optional(x.types.array(oi),[])}).views(t=>({find({type:e,key:n}){return t.list.find(r=>r.key===n&&r.type===e)},get options(){return t.list.map(e=>({value:e.key,label:e.key}))}})).actions(t=>({replace(e){t.list.length=0,t.list.push(...e)}})),tc=x.types.model({id:x.types.string,content:x.types.string,create_time:x.types.string,update_time:x.types.string,is_preset:x.types.boolean}),li=x.types.model("GlobalSQLSnippetsMeta",{list:x.types.optional(x.types.array(tc),[])}).views(t=>({find(e){return t.list.find(n=>n.id===e)},get options(){return t.list.map(e=>({value:e.id,label:e.id}))}})).actions(t=>({replace(e){t.list.length=0,t.list.push(...e)}})),us=x.types.model("ContextMeta",{current:x.types.optional(x.types.frozen(),{})}).views(t=>({get keys(){return Object.keys(t.current)},get entries(){return Object.entries(t.current)}})).actions(t=>({replace(e){t.current=e},get(e){return t.current[e]},set(e,n){t.current[e]=n}}));function ci(t){return us.create({current:t})}const ui=x.types.compose("ViewRenderModel",Hl,x.types.model({tab:x.types.optional(x.types.string,"")})).views(t=>({get tabs(){return t.config.tabs},get tabInfo(){const e=this.tabs.find(n=>n.id===t.tab);return e?{id:e.id,name:e.name}:null},get tabView(){return t.type!==B.Tabs?null:this.tabs.find(e=>e.id===t.tab)},get tabViewID(){return this.tabView?this.tabView.view_id??"":""},get contentModel(){return x.getParent(t,3)},get panels(){if(t.type!==B.Tabs)return this.contentModel.panels.panelsByIDs(t.panelIDs);const e=this.tabViewID,n=this.contentModel.views.findByID(e);return(n==null?void 0:n.panels)??[]},get renderViewIDs(){const e=[t.id];return t.type===B.Tabs&&e.push(this.tabViewID),e},async downloadScreenshot(e){const n=e.offsetWidth*2+10,r=e.offsetHeight*2+10,i=new pa,o=new Date().getTime(),l=await da.toBlob(e,{bgcolor:"white",width:n,height:r,style:{transformOrigin:"0 0",transform:"scale(2)"}});i.file(`${t.name}_${o}.png`,l),i.file(`dashboard_state_${o}.json`,JSON.stringify(this.contentModel.dashboardState,null,4)),i.generateAsync({type:"blob"}).then(c=>{kn.saveAs(c,`${t.name}_${o}.zip`)}).catch(c=>{console.error(c),_t.notifications.show({color:"red",title:"Failed to download screenshot with dashboard state",message:c.message})})}})).actions(t=>({setTab(e){t.tab=e??""},setTabByTabInfo(e){t.tab=e.id??""}})),di=x.types.model("ViewsRenderModel",{current:x.types.optional(x.types.array(ui),[]),visibleViewIDs:x.types.array(x.types.string)}).views(t=>({get json(){return t.current.map(e=>Ft(e.json))},get idMap(){const e=new Map;return t.current.forEach(n=>{e.set(n.id,n)}),e},findByID(e){return t.current.find(n=>n.id===e)},get firstVisibleView(){const[e]=t.visibleViewIDs;return t.current.find(({id:n})=>n===e)},get visibleViews(){const e=new Set(t.visibleViewIDs);return t.current.filter(({id:n})=>e.has(n))},get firstVisibleTabsView(){return this.visibleViews.find(e=>e.type===B.Tabs)},get firstVisibleTabsViewActiveTab(){const e=this.firstVisibleTabsView;return e?e.tabInfo:null}})).actions(t=>({appendToVisibles(e){new Set(t.visibleViewIDs.map(r=>r)).has(e)||t.visibleViewIDs.push(e)},rmVisibleViewID(e){const n=t.visibleViewIDs.findIndex(r=>r===e);n!==-1&&t.visibleViewIDs.splice(n,1)},setFirstVisibleTabsViewActiveTab(e){if(!e)return;const n=t.firstVisibleTabsView;n==null||n.setTabByTabInfo(e)}}));function nc(t,e){const n=t.length>0?[t[0].id]:[],r=t.map(i=>{const{_name:o=i.type}=i.config,l={...i,tab:"",config:{...i.config,_name:o},panelIDs:i.panelIDs};if(i.type===B.Tabs){const c=b.minBy(i.config.tabs,u=>u.order);l.tab=(c==null?void 0:c.id)??""}return l});return e&&(r[0].tab=e.id),{current:r,visibleViewIDs:n}}const VS=new Vu.AsyncParser({withBOM:!0});async function sc(t){return!Array.isArray(t)||t.length===0?"":await VS.parse(t).promise()}async function NS(t,e){const n=await sc(e),r=new Blob([n],{type:"text/csv"});kn.saveAs(r,`${t}.csv`)}function rc(t){const e=new pa,n=t.map(async({id:r,data:i})=>{const o=await sc(i);e.file(`${r}.csv`,o)});Promise.all(n).then(()=>{e.generateAsync({type:"blob"}).then(r=>{kn.saveAs(r,"dashboard_data.zip")})}).catch(r=>{console.error(r),_t.notifications.show({color:"red",title:"Failed to download data",message:r.message})})}function Zt(t,e){const n=new Blob([e],{type:"application/json"});kn.saveAs(n,`${t}.json`)}const pi=Ol.views(t=>({get contentModel(){return x.getRoot(t).content}})).views(t=>({get queries(){return t.contentModel.queries.findByIDSet(t.queryIDSet)},get firstQuery(){return this.queries.length>0?this.queries[0]:null},get firstQueryData(){return this.firstQuery?this.firstQuery.data:[]},queryByID(e){return this.queries.find(n=>n.id===e)},get data(){return this.queries.reduce((e,n)=>(e[n.id]=n.data,e),{})},get variableStrings(){return va(t.variables,this.data)},get variableValueMap(){const e={},n=this.data;return t.variables.reduce((r,i)=>{const o=Ze(i,n);return r[i.name]=Ie(i,o),r},e),e},get dataLoading(){return this.queries.some(e=>e.state==="loading")},get queryStateMessages(){const e=this.queries.filter(o=>!o.runByConditionsMet);if(e.length===0)return"";const n=new Set,r=new Set;e.forEach(o=>{const l=o.conditionNames;l.context.forEach(c=>n.add(c)),l.filters.forEach(c=>r.add(c))});const i=[];return n.size>0&&(console.log(n),i.push(`context: ${Array.from(n).join(", ")}`)),r.size>0&&i.push(`filter${r.size>1?"s":""}: ${Array.from(r).join(", ")}`),i.length===2&&i.splice(1,0,"and"),i.unshift("Waiting for"),i.join(" ")},get queryErrors(){return this.queries.map(e=>e.error).filter(e=>!!e)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages===""&&!this.dataLoading}})).actions(t=>({refreshData(){t.queries.forEach(e=>e.fetchData(!0))},downloadData(){t.contentModel.queries.downloadDataByQueryIDs(t.queryIDs)},getSchema(){const e=t.json;return e.viz.conf={...e.viz.conf,__INTERACTIONS:{},__OPERATIONS:{},__TRIGGERS:{}},{panel:e,queries:t.queries.map(n=>n.json),layouts:t.contentModel.layouts.jsonByPanelIDSet(new Set([t.id]))}},downloadSchema(){const{panel:e,queries:n,layouts:r}=this.getSchema(),o=JSON.stringify({panels:[e],definition:{queries:n},layouts:r,version:yt},null,2),l=t.name;Zt(l,o)}}));function ic(t){return{id:t,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:Ar.name,conf:Ar.createConfig()},style:{border:{enabled:!0}}}}const hi=x.types.model("PanelsRenderModel",{list:x.types.optional(x.types.array(pi),[])}).views(t=>({get json(){return t.list.map(e=>e.json)},findByID(e){return t.list.find(n=>n.id===e)},get idMap(){const e=new Map;return t.list.forEach(n=>{e.set(n.id,n)}),e}})).views(t=>({panelsByIDs(e){const n=[];return e.forEach(r=>{const i=t.idMap.get(r);i?n.push(i):console.warn(`Panel is not found, id:${r}`)}),n}}));function ac(t){const e=t.config,n=e.default_value;if(n===void 0)return n;if(e._name==="date-range")try{if(e.default_shortcut){const i=Il(e.default_shortcut);if(i)return i.map(o=>I(o).format(e.inputFormat))}const[...r]=n;return r.map(i=>i===null?i:I.tz(i,"UTC").format(e.inputFormat)??i)}catch(r){return console.error(r),n}return n}function GS(t,e){const n=t.default_value_func;try{return new Function(`return ${n}`)()(t,at,e)}catch(r){return console.error(r),ac(t)}}function oc(t,e){var n;return(n=t.default_value_func)!=null&&n.trim()?GS(t,e):ac(t)}function lc(t,e){return t.reduce((n,r)=>(n[r.key]=oc(r,e),n),{})}const mi=x.types.model("FiltersRenderModel",{current:x.types.optional(x.types.array(si),[]),values:x.types.optional(x.types.frozen(),{})}).views(t=>({get json(){return t.current.map(e=>e.json)},get valuesString(){return JSON.stringify(t.values)},get contentModel(){return x.getRoot(t).content},get context(){return this.contentModel.payloadForSQL.context},get initialValuesDep(){return JSON.stringify({filters:t.current.map(({default_value_func:e,config:n})=>({default_value_func:e,config:n})),context:this.contentModel.payloadForSQL.context})},get formattedDefaultValues(){return lc(this.json,this.contentModel.context)},get firstID(){if(t.current.length!==0)return t.current[0].id},findByID(e){return t.current.find(n=>n.id===e)},findByIDSet(e){return t.current.filter(n=>e.has(n.id))},get inOrder(){return b.sortBy(t.current,"order")},get empty(){return t.current.length===0},visibleInView(e){return b.sortBy(t.current.filter(n=>n.visibleInViewsIDSet.has(e)),"order")},get firstFilterValueKey(){return Object.keys(t.values)[0]??""},get keySet(){return new Set(t.current.map(e=>e.key))},get keyLabelMap(){return t.current.reduce((e,n)=>(e[n.key]=n.label,e),{})},getSelectOption(e){const n=this.findByID(e);if(!n||!("getSelectOption"in n.config))return null;const r=t.values[n.key];return n.config.getSelectOption(r)}})).actions(t=>({setValues(e){t.values=e},patchValues(e){t.values=b.defaults({},e,t.values)},setValueByKey(e,n){t.values={...t.values,[e]:n}},applyValuesPatch(e){t.values={...t.values,...e}},getValueByKey(e){return t.values[e]},getSchema(e,n){return{filters:t.findByIDSet(new Set(e)).map(o=>({...o.json,visibleInViewsIDs:n?o.json.visibleInViewsIDs:[]})),version:yt}},downloadSchema(e){const n=JSON.stringify(this.getSchema(e,!1),null,2);Zt("Filters",n)}}));function xi(t,e,n,r){const i=b.defaults({},r,lc(t,{...n,...e}));return{current:t,values:i}}const cc=Vl.views(t=>({get rootModel(){return x.getRoot(t)},get contentModel(){return this.rootModel.content},get conditionOptions(){if(!x.isAlive(t))return[];const{context:e}=this.contentModel.payloadForSQL,n=Object.keys(e).map(l=>({group:"Context",label:l,value:`context.${l}`,description:void 0})),r=this.contentModel.filters.keyLabelOptions.map(l=>({group:"Filters",label:l.label,value:`filters.${l.value}`,description:l.value})),i=[...n,...r],o=new Set(i.map(l=>l.value));return t.run_by.forEach(l=>{o.has(l)||i.push({group:"Invalid",label:l,value:l})}),i},get unmetRunByConditions(){if(!x.isAlive(t))return[];const{run_by:e}=t;if(e.length===0)return[];const n=this.contentModel.payloadForSQL;return e.filter(r=>{const i=b.get(n,r);return Array.isArray(i)?i.length===0:typeof i=="number"?Number.isNaN(i):!i})}})).views(t=>({get payload(){return t.contentModel.payloadForSQL},get formattedSQL(){return Ts(t.sql,this.payload)},get httpConfigString(){const{context:e,filters:n}=this.payload,{name:r,pre_process:i}=t.json,o=Zd(i,e,n);return console.groupCollapsed(`Request config for: ${r}`),console.log(o),console.groupEnd(),JSON.stringify(o)},get typedAsSQL(){return[de.Postgresql,de.MySQL].includes(t.type)},get typedAsHTTP(){return[de.HTTP].includes(t.type)},get isTransform(){return t.type===de.Transform},get reQueryKey(){const{react_to:e=[]}=t;if(e.length===0)return"";const n=t.contentModel.payloadForSQL,r=[...e].reduce((i,o)=>(i[o]=b.get(n,o),i),{});return JSON.stringify(r)},get runByConditionsMet(){return t.unmetRunByConditions.length===0},get conditionNames(){if(t.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:e}=t.contentModel.filters,n=t.unmetRunByConditions.filter(i=>i.startsWith("context.")).map(i=>i.replace("context.","")),r=t.unmetRunByConditions.filter(i=>i.startsWith("filters.")).map(i=>b.get({filters:e},i,i.replace("filters.",""))).filter(i=>!!i);return{context:n,filters:r}},get queries(){return x.getParent(t,2)},get inUse(){return this.queries.isQueryInUse(t.id)},get dependencies(){if(!this.typedAsSQL)return[];const e=b.uniq(t.sql.match(Mn.sqlSnippet)),n=b.uniq(t.sql.match(Mn.filter)),r=b.uniq(t.sql.match(Mn.context)),i=[];return e.forEach(o=>{i.push({type:"sql_snippet",key:o,valid:t.contentModel.sqlSnippets.keySet.has(o)})}),n.forEach(o=>{i.push({type:"filter",key:o,valid:t.contentModel.filters.keySet.has(o)})}),r.forEach(o=>{i.push({type:"context",key:o,valid:t.contentModel.mock_context.keySet.has(o)})}),i}})),gi=x.types.compose("QueryRenderModel",cc,x.types.model({state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),data:x.types.optional(x.types.frozen([]),[]),error:x.types.frozen()})).views(t=>({get datasource(){const{key:e,type:n}=t;return t.rootModel.datasources.find({type:n,key:e})},get additionalQueryInfo(){return t.contentModel.getAdditionalQueryInfo(t.id)},get depQueryModels(){return t.contentModel.queries.findByIDSet(new Set(t.dep_query_ids))},get depQueryModelStates(){return this.depQueryModels.map(e=>e.state)},get depQueryModelStatesString(){return this.depQueryModelStates.toString()}})).views(t=>({get stateMessage(){if(t.state!=="idle")return"";if(!t.runByConditionsMet){const{context:e,filters:n}=t.conditionNames;if(e.length===0&&n.length===0)return"Waiting";const r=[];return e.length>0&&r.push(`context: ${e.join(", ")}`),n.length>0&&r.push(`filter${n.length>1?"s":""}: ${n.join(", ")}`),r.length===2&&r.splice(1,0,"and"),r.unshift("Waiting for"),r.join(" ")}return t.data.length>0?"":"Empty Data"}})).volatile(()=>({controller:new AbortController})).actions(t=>({runSQL:x.flow(function*(){var e;if(t.valid&&((e=t.controller)==null||e.abort(),!!t.runByConditionsMet)){t.controller=new AbortController,t.state="loading";try{const n=t.payload;t.data=yield*x.toGenerator(sp({payload:n,name:t.name,query:t.json,additionals:t.additionalQueryInfo},t.controller.signal)),t.state="idle",t.error=null}catch(n){if(!rt.isCancel(n)){t.data=[];const r=b.get(n,"message","unkown error");t.error=b.get(n,"response.data.detail.message",r),t.state="error"}}}}),runHTTP:x.flow(function*(){var e;if(!(!t.valid||!t.datasource)&&((e=t.controller)==null||e.abort(),!!t.runByConditionsMet)){t.controller=new AbortController,t.state="loading";try{const{type:n,key:r,post_process:i}=t.json;let o=JSON.parse(t.httpConfigString);o=Hd(t.datasource,o);const l=yield*x.toGenerator(rp({type:n,key:r,configString:JSON.stringify(o),name:t.name,additionals:t.additionalQueryInfo},t.controller.signal)),c=ep(t.datasource,l),u=tp(i,c,t.contentModel.dashboardState);t.data=u,t.state="idle",t.error=null}catch(n){if(console.error(n),!rt.isCancel(n)){t.data=[];const r=b.get(n,"message","unkown error");t.error=b.get(n,"response.data.detail.message",r),t.state="error"}}}}),runTransformation(){t.state="loading";try{const n=t.contentModel.queries.findByIDSet(new Set(t.dep_query_ids)).map(l=>({id:l.id,name:l.name,data:b.cloneDeep(l.data)})),r=t.contentModel.dashboardState,i=t.pre_process,o=new Function(`return ${i}`)()(n,r,at);t.data=o,t.state="idle",t.error=null}catch(e){t.data=[],t.error=e.message,t.state="error"}}})).actions(t=>({fetchData:e=>{if(!t.inUse&&!e){console.debug(`🟡 Skipping query[${t.name}]`);return}return console.debug(`🔵 Running query[${t.name}]`),t.isTransform?t.runTransformation():t.typedAsHTTP?t.runHTTP():t.runSQL()},beforeDestroy(){var e;(e=t.controller)==null||e.abort()}})).actions(t=>({afterCreate(){x.addDisposer(t,J.reaction(()=>{var n;return t.isTransform?[t.inUse,t.id,t.key,t.dep_query_ids.toString(),t.pre_process,t.depQueryModelStatesString].join("--"):t.typedAsHTTP?`${t.inUse}--${t.id}--${t.key}--${t.reQueryKey}--${(n=t.datasource)==null?void 0:n.id}`:[t.inUse,t.id,t.key,t.formattedSQL,t.pre_process,t.post_process].join("--")},()=>t.fetchData(!1),{fireImmediately:!0,delay:0}))}})),fi=x.types.model("QueriesRenderModel",{current:x.types.optional(x.types.array(gi),[])}).views(t=>({get idSet(){return new Set(t.current.map(e=>e.id))},get firstID(){if(t.current.length!==0)return t.current[0].id},findByID(e){return t.current.find(n=>n.id===e)},findByIDSet(e){return t.current.filter(n=>e.has(n.id))},get json(){return t.current.filter(e=>e.id&&e.key).map(e=>e.json)},get contentModel(){return x.getParent(t,1)},get visibleQueryIDSet(){const{views:e,filters:n,queries:r}=this.contentModel,i=[];e.visibleViews.forEach(c=>{c.panels.forEach(u=>{i.push(...u.queryIDs)})});const o=b.uniq(e.visibleViews.map(c=>c.renderViewIDs).flat());n.current.forEach(c=>{const u=b.get(c,"config.options_query_id");if(!u)return;o.some(p=>c.visibleInViewsIDSet.has(p))&&i.push(u)}),r.findByIDSet(new Set(i)).forEach(c=>{!c.isTransform||c.dep_query_ids.length===0||i.push(...c.dep_query_ids)});const l=new Set(i);return console.debug("QueryIDs:",l),l},isQueryInUse(e){return this.visibleQueryIDSet.has(e)}})).actions(t=>({downloadAllData(){const e=t.current.map(({name:n,data:r})=>({id:n,data:r}));rc(e)},downloadDataByQueryIDs(e){const n=new Set(e),r=t.current.filter(i=>n.has(i.id)).map(({name:i,data:o})=>({id:i,data:o}));rc(r)},downloadDataByQueryID(e){const n=t.findByID(e);if(!n){console.log("[downloadDataByQueryID] query not found");return}const{name:r,data:i}=n;NS(r,i)},refetchDataByQueryID(e){const n=t.findByID(e);if(!n){console.error(new Error(`[downloadDataByQueryID] query by ID[${e}] not found`));return}return n.fetchData(!0)},getSchema(e){return{definition:{queries:t.findByIDSet(new Set(e)).map(i=>i.json)},version:yt}},downloadSchema(e){const n=JSON.stringify(this.getSchema(e),null,2);Zt("Queries",n)}}));function uc(t){return{current:t}}function dc({min:t,max:e}){const n=`${t}px`,r=Number.isFinite(e)?`${e}px`:"∞";return`[${n}, ${r})`}const yi=x.types.model("LayoutsRenderModel",{list:x.types.array(Gl),currentBreakpoint:x.types.string}).views(t=>({get json(){return t.list.map(e=>e.json)},jsonByPanelIDSet(e){return t.list.map(n=>n.jsonByPanelIDSet(e))},get root(){return x.getRoot(t)},get contentModel(){return this.root.content},get basisLayoutSet(){return t.list.find(e=>e.id==="basis")},get currentLayoutSet(){return t.list.find(e=>e.id===t.currentBreakpoint)},get currentLayoutRange(){return this.breakpointRanges.find(e=>e.id===t.currentBreakpoint)},get currentRangeText(){const e=this.currentLayoutRange;return dc(e)},get cols(){const e={};return t.list.forEach(n=>{e[n.id]=36}),e},get breakpoints(){const e={};return t.list.forEach(n=>{e[n.id]=n.breakpoint}),e},get breakpointNameRecord(){const e={};return t.list.forEach(n=>{e[n.name]=n.breakpoint}),e},get breakpointRanges(){const e=t.list.map(n=>({id:n.id,name:n.name,min:n.breakpoint,max:1/0,text:""}));return e.sort((n,r)=>n.min-r.min).forEach((n,r)=>{r!==e.length-1&&(n.max=e[r+1].min)}),e.forEach(n=>{n.text=dc(n)}),e},get breakpointsInfo(){return t.list.map(e=>({id:e.id,name:e.name,breakpoint:e.breakpoint})).sort((e,n)=>e.breakpoint-n.breakpoint)},get currentBreakpointRange(){return this.breakpointRanges.find(e=>e.id===t.currentBreakpoint)},get currentLayoutPreviewWidth(){const e=this.currentBreakpointRange;if(e)return e.max===1/0?e.min===0?void 0:e.min+1:e.max},items(e){const n=new Set(e);return this.currentLayoutSet.list.filter(i=>n.has(i.panelID))},gridLayouts(e){const n=new Set(e),r={};return t.list.forEach(i=>{r[i.id]=i.list.filter(o=>n.has(o.panelID)).map(o=>o.layoutProperies)}),r},findItemByPanelID(e){return this.currentLayoutSet.findByPanelID(e)}})).actions(t=>({setCurrentBreakpoint(e){console.log("🔴 onBreakpointChange:",e),t.currentBreakpoint=e},afterCreate(){x.addDisposer(t,J.reaction(()=>t.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),pc=Fl.views(t=>({isADuplicatedKey(e){return!e||e===t.key?!1:!!x.getParent(t,2).findByKey(e)}})),bi=x.types.model("SQLSnippetsRenderModel",{current:x.types.optional(x.types.array(pc),[])}).views(t=>({get json(){return t.current.map(e=>e.json)},get record(){return t.current.reduce((e,n)=>(e[n.key]=n.value,e),{})},get keySet(){return new Set(t.current.map(e=>e.key))},get firstKey(){if(t.current.length!==0)return t.current[0].key},findByKey(e){return t.current.find(n=>n.key===e)},findByKeySet(e){return t.current.filter(n=>e.has(n.key))}})).actions(t=>({getSchema(e){return{definition:{sqlSnippets:t.findByKeySet(new Set(e)).map(i=>i.json)},version:yt}},downloadSchema(e){const n=JSON.stringify(this.getSchema(e),null,2);Zt("SQL Snippets",n)}}));function hc(t){return{current:t}}function bn(t,e,n,r){return t.reduce((i,o)=>{try{i[o[e]]=ks(o[n],r)}catch(l){i[o[e]]=l.message}return i},{})}class mc{constructor(e){$(this,"origin");$(this,"copy");this.origin=e,this.copy=x.clone(e),J.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!b.isEqual(x.getSnapshot(this.origin),x.getSnapshot(this.copy))}commit(){x.applySnapshot(this.origin,x.getSnapshot(this.copy))}reset(){x.applySnapshot(this.copy,x.getSnapshot(this.origin))}update(e){x.applySnapshot(this.copy,e)}}const xc=t=>new mc(t),FS=S.observer(()=>{const{t}=_.useTranslation(),e=Z(),{panel:n}=ze(),r=n.realQueryOptions,i=o=>{e.editor.open(["_QUERIES_",o])};return r.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx(a.Divider,{label:t(r.length>1?"query.labels":"query.label"),labelPosition:"center"}),r.map(o=>s.jsx(a.Menu.Item,{onClick:()=>i(o.value),icon:s.jsx(k.IconDatabase,{size:14}),children:o.label},o.value))]})}),WS=S.observer(({view:t,title:e})=>{const{t:n}=_.useTranslation(),r=Z(),i=Y(),o=Fe.useModals(),{panel:l,downloadPanelScreenshot:c}=ze(),{id:u}=l,{viewPanelInFullScreen:d,inFullScreen:p}=m.useContext(ls),h=()=>{i.duplicatePanelByID(u,t.id)},g=()=>{r.editor.open(["_VIEWS_",t.id,"_PANELS_",u])},f=()=>o.openConfirmModal({title:`${n("panel.delete")}?`,labels:{confirm:n("common.actions.confirm"),cancel:n("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.removePanelByID(u,t.id),confirmProps:{color:"red"},zIndex:320}),v=m.useCallback(()=>{d(u)},[u,d]),w=!p&&t.type!==B.Modal;return s.jsx(s.Fragment,{children:s.jsx(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:e,children:s.jsxs(a.Menu,{withinPortal:!0,children:[s.jsx(a.Menu.Target,{children:s.jsx(a.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),s.jsxs(a.Menu.Dropdown,{children:[s.jsx(a.Menu.Item,{onClick:l.refreshData,icon:s.jsx(L.Refresh,{size:14}),children:n("common.actions.refresh")}),s.jsx(a.Menu.Item,{onClick:l.downloadData,icon:s.jsx(L.Download,{size:14}),children:n("common.actions.download_data")}),s.jsx(a.Menu.Item,{onClick:l.downloadSchema,icon:s.jsx(k.IconCode,{size:14}),children:n("common.actions.download_schema")}),s.jsx(a.Menu.Item,{onClick:c,icon:s.jsx(k.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),w&&s.jsx(a.Menu.Item,{onClick:v,icon:s.jsx(L.ArrowsMaximize,{size:14}),disabled:!0,children:n("common.actions.enter_fullscreen")}),s.jsx(FS,{}),s.jsx(a.Divider,{label:n("common.actions.edit"),labelPosition:"center"}),s.jsx(a.Menu.Item,{onClick:g,icon:s.jsx(L.Settings,{size:14}),children:n("common.titles.settings")}),s.jsx(a.Menu.Item,{onClick:h,icon:s.jsx(L.Copy,{size:14}),children:n("common.actions.duplicate")}),s.jsx(a.Menu.Item,{color:"red",onClick:f,icon:s.jsx(L.Trash,{size:14}),children:n("common.actions.delete")})]})]})})})});function QS(t){return t?["<p><br></p>","<p></p>"].includes(t):!0}const vi=S.observer(()=>{const{t}=_.useTranslation(),[e,n]=m.useState(!1),{panel:r}=mt();return QS(r.description)?null:s.jsxs(s.Fragment,{children:[s.jsx(a.Modal,{opened:e,onClose:()=>n(!1),title:r.title.show?r.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:s.jsx(Xn,{value:r.description,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}}})}),s.jsx(a.Tooltip,{label:t("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:s.jsx(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:s.jsx(L.InfoCircle,{size:20})})})]})}),qM="",RS=S.observer(function(){const{panel:e}=mt(),{name:n,title:r}=e;return r.show?s.jsx(a.Group,{grow:!0,position:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:s.jsx(a.Text,{align:"center",lineClamp:1,className:"panel-title-text",children:n})}):null});function US(t){const e=m.useRef(null);return{ref:e,downloadPanelScreenshot:()=>{const r=e.current;if(!r)return;const i=r.offsetWidth*2,o=r.offsetHeight*2;da.toBlob(e.current,{bgcolor:"white",width:i,height:o,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(l=>{window.saveAs(l,`${t.name?t.name:t.viz.type}.png`)})}}}var gc=(t=>(t.migrated="migrated",t.nothingToMigrate="nothingToMigrate",t.checkFailed="checkFailed",t.migrationFailed="migrationFailed",t))(gc||{}),ds=(t=>(t.notStarted="notStarted",t.inProgress="inProgress",t.done="done",t))(ds||{});class YS{constructor(e){$(this,"vizInstance");$(this,"operationManager");$(this,"triggerManager");$(this,"vizManager");$(this,"runningMigration");$(this,"panelModel");$(this,"status","notStarted");this.panelModel=e.getRequired(me.instanceScope.panelModel),this.vizInstance=e.getRequired(me.instanceScope.vizInstance),this.operationManager=e.getRequired(me.instanceScope.operationManager),this.triggerManager=e.getRequired(me.instanceScope.triggerManager),this.vizManager=e.getRequired(me.vizManager)}async createMigrationTask(){const e=[];try{await this.instanceNeedMigration()&&e.push(()=>this.runInstanceMigration()),await this.interactionNeedMigration()&&e.push(()=>this.runInteractionMigration())}catch(n){return console.warn("check migration failed",n),"checkFailed"}if(e.length===0)return"nothingToMigrate";try{return await Promise.all(e.map(n=>n())),"migrated"}catch(n){return console.warn("migration failed",n),"migrationFailed"}}async runMigration(){return this.runningMigration||(this.status="inProgress",this.runningMigration=this.createMigrationTask().then(e=>(this.status="done",e))),this.runningMigration}async runInteractionMigration(){await this.operationManager.runMigration(),await this.triggerManager.runMigration()}async runInstanceMigration(){const e=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData,panelModel:this.panelModel};await e.migrator.migrate(n)}async instanceNeedMigration(){const e=this.vizManager.resolveComponent(this.vizInstance.type),n={configData:this.vizInstance.instanceData};return e.migrator.needMigration(n)}async interactionNeedMigration(){return await this.operationManager.needMigration()||await this.triggerManager.needMigration()}}function fc(t){const{panel:e}=mt();return m.useCallback(n=>{const r=n.getRequired(me.vizManager),i=r.resolveComponent(t.viz.type);return n.createScoped().provideFactory(me.instanceScope.vizInstance,()=>r.getOrCreateInstance(t)).provideFactory(me.instanceScope.interactionManager,o=>{const l=o.getRequired(me.instanceScope.vizInstance);return new Ws(l,i,Pn)}).provideFactory(me.instanceScope.operationManager,o=>o.getRequired(me.instanceScope.interactionManager).operationManager).provideFactory(me.instanceScope.triggerManager,o=>o.getRequired(me.instanceScope.interactionManager).triggerManager).provideValue(me.instanceScope.panelModel,e).provideFactory(me.instanceScope.migrator,o=>new YS(o))},[t.viz.type,t.viz.conf])}function yc(t){const[e,n]=m.useState(!1),r=Ml().getRequired(me.instanceScope.migrator);return W.useAsyncEffect(async()=>{const i=r.status===ds.notStarted;n(r.status===ds.done),r.status===ds.notStarted&&r.runMigration().then(o=>{o===gc.migrated&&i&&(t==null||t())}).finally(()=>{n(!0)})},[r]),e}function bc(t,e){const n=Ml().getRequired(me.instanceScope.vizInstance);return m.useEffect(()=>(n.instanceData.setItem(null,e.viz.conf),n.instanceData.watchItem(null,r=>{t(r)})),[t,e.viz.type]),n}function KS({setVizConf:t,...e}){const{panel:n}=e,r=bc(t,n),i=yc(()=>{_t.showNotification({title:`${n.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return W.useAsyncEffect(async()=>{await r.instanceData.setItem(null,n.viz.conf)},[r,n.viz.type]),i?s.jsx(lp,{...e}):s.jsx(a.Text,{children:"Checking update..."})}function JS(t){const{panel:e,setVizConf:n}=t;bc(n,e);const{inEditMode:r}=m.useContext(En);return yc(()=>{r&&_t.showNotification({title:`${e.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?s.jsx(op,{...t}):s.jsx(a.Text,{children:"Checking update"})}const OM="";function XS(t,e){const{vizManager:n}=m.useContext(ut),{panel:{viz:r,title:i,id:o,name:l,description:c,queryIDs:u,variables:d}}=mt(),p={id:o,name:l,title:i,description:c,queryIDs:u,viz:r},h=fc(p);try{return n.resolveComponent(r.type),s.jsx(os,{configure:h,children:s.jsx(JS,{setVizConf:r.setConf,panel:p,measure:e,data:t,variables:d,vizManager:n})})}catch(g){return console.info(b.get(g,"message")),null}}const vc=S.observer(function({data:e}){const{ref:n,width:r,height:i}=ie.useElementSize(),o=XS(e,{w:r,h:i}),l=r>0&&i>0;return s.jsx("div",{className:"viz-root",ref:n,children:s.jsx(a.Box,{sx:{width:r,height:i,overflow:"hidden"},children:l&&s.jsx(je,{children:o})})})}),_c=S.observer(({panel:t})=>s.jsxs(a.Stack,{children:[t.queryErrors.map((e,n)=>s.jsx(a.Text,{color:"red",size:"sm",align:"center",sx:{fontFamily:"monospace"},children:e},`${n}-${e}`)),s.jsx(a.Text,{color:"gray",align:"center",size:"sm",children:t.queryStateMessages})]})),_i=S.observer(({panel:t})=>s.jsxs(a.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[s.jsx(a.LoadingOverlay,{visible:t.dataLoading,exitTransitionDuration:0}),!t.canRenderViz&&s.jsx(_c,{panel:t}),t.canRenderViz&&s.jsx(vc,{data:t.data})]})),ZS={border:"1px solid #e9ecef"},jc=S.observer(({panel:t,panelStyle:e,dropdownContent:n})=>{const{ref:r,downloadPanelScreenshot:i}=US(t);return t.title.show,s.jsx(Os,{value:{panel:t,data:t.data,loading:t.dataLoading,errors:t.queryErrors,downloadPanelScreenshot:i},children:s.jsxs(a.Box,{className:`panel-root ${t.title.show?"panel-root--show-title":""}`,ref:r,p:0,sx:{...ZS,...e},children:[s.jsx(a.Box,{className:"panel-description-popover-wrapper",children:s.jsx(vi,{})}),n,s.jsx(RS,{}),s.jsx(_i,{panel:t})]})})}),HS={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function ek(t){return t.style.border.enabled?{}:HS}const wc=S.observer(function({panel:e,view:n}){const r=ek(e);return s.jsx(jc,{panel:e,panelStyle:r,dropdownContent:s.jsx(WS,{view:n,title:e.name})})});function tk(t){return!["richText","button"].includes(t)}const nk=S.observer(({view:t,title:e})=>{const{t:n}=_.useTranslation(),{panel:r,downloadPanelScreenshot:i}=mt(),{id:o}=r,{viewPanelInFullScreen:l,inFullScreen:c}=m.useContext(ls),u=m.useCallback(()=>{l(o)},[o,l]),d=!c&&t.type!==B.Modal;return tk(r.viz.type)?s.jsx(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:e,children:s.jsxs(a.Menu,{withinPortal:!0,children:[s.jsx(a.Menu.Target,{children:s.jsx(a.Box,{className:"panel-dropdown-target"})}),s.jsxs(a.Menu.Dropdown,{children:[s.jsx(a.Menu.Item,{onClick:r.refreshData,icon:s.jsx(L.Refresh,{size:14}),children:n("common.actions.refresh")}),s.jsx(a.Menu.Item,{onClick:r.downloadData,icon:s.jsx(L.Download,{size:14}),children:n("common.actions.download_data")}),s.jsx(a.Menu.Item,{onClick:i,icon:s.jsx(k.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),d&&s.jsx(a.Menu.Item,{onClick:u,icon:s.jsx(L.ArrowsMaximize,{size:14}),children:n("common.actions.enter_fullscreen")})]})]})}):null});function sk(t){return t.style.border.enabled?{}:{border:"1px dashed transparent"}}const ji=S.observer(({panel:t,view:e})=>{const n=sk(t);return s.jsx(jc,{panel:t,panelStyle:n,dropdownContent:s.jsx(nk,{title:t.name,view:e})})}),rk={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},Cc=S.observer(function({view:e,panel:n,exitFullScreen:r}){return s.jsx(a.Modal,{opened:!0,fullScreen:!0,onClose:r,title:s.jsx(a.Button,{color:"blue",size:"xs",onClick:r,leftIcon:s.jsx(L.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:rk,children:s.jsx(a.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:s.jsx(ji,{view:e,panel:n})})})});function Sc(t,e,n){const{panels:r}=he(),i=t.id==="Main",[o,l]=m.useState(()=>i&&r.findByID(e)?e:null),c=m.useCallback(h=>{l(h),i&&n(h)},[i,n]),u=m.useCallback(()=>{l(null),i&&n("")},[i,n]),d=o?r.findByID(o):null;return{viewPanelInFullScreen:c,exitFullScreen:u,inFullScreen:!!d,fullScreenPanel:d}}const VM="",ik=m.forwardRef(({h:t},e)=>s.jsx(a.ActionIcon,{ref:e,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:5,right:t>38?5:20,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:s.jsx(L.ArrowsMove,{size:16})})),ak=m.forwardRef(({handleAxis:t,...e},n)=>s.jsx(a.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...e,children:s.jsx(L.ChevronDownRight,{size:16})})),ok=Sn.WidthProvider(Sn.Responsive),lk=S.observer(({view:t,className:e="layout"})=>{const r=Y().layouts,i=r.items(t.panelIDs),o=r.gridLayouts(t.panelIDs),l=(d,p,h,g)=>{console.log("🔴 onResize",d),h.h<30&&(h.h=30,g.h=30),h.w<4&&(h.w=4,g.w=4)},c=(d,p,h)=>{console.log("🔴 onResizeStop",{layouts:d,oldItem:p,newItem:h}),r.updateCurrentLayoutItem(h)},u=(d,p,h)=>{console.log("🔴 onDragStop",{layouts:d,oldItem:p,newItem:h}),r.updateCurrentLayoutItems(d)};return s.jsx(ok,{className:`dashboard-layout ${e}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:r.cols,layouts:o,draggableHandle:".react-grid-customDragHandle",resizeHandle:s.jsx(ak,{}),onResize:l,breakpoints:r.breakpoints,onBreakpointChange:r.setCurrentBreakpoint,onResizeStop:c,onDragStop:u,width:r.currentLayoutPreviewWidth,children:i.map(d=>s.jsxs("div",{"data-grid":d.layoutProperies,className:"panel-grid-item",children:[s.jsx(ik,{h:d.h}),s.jsx(wc,{view:t,panel:d.panel})]},d.id))})}),ck=Sn.WidthProvider(Sn.Responsive),uk=S.observer(({view:t,className:e="layout"})=>{const n=he(),r=n.layouts.items(t.panelIDs),i=n.layouts.gridLayouts(t.panelIDs);return s.jsx(ck,{className:`dashboard-layout ${e}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:n.layouts.cols,layouts:i,breakpoints:n.layouts.breakpoints,onBreakpointChange:n.layouts.setCurrentBreakpoint,children:r.map(o=>s.jsx("div",{"data-grid":o.layoutProperies,className:"panel-grid-item",children:s.jsx(ji,{view:t,panel:o.panel})},o.id))})});function wi(t){const e=m.useRef(null);return{ref:e,downloadScreenshot:()=>{var i;const r=(i=e.current)==null?void 0:i.querySelector(".react-grid-layout");r&&t.downloadScreenshot(r)}}}const dk=S.observer(({downloadScreenshot:t})=>{const{t:e}=_.useTranslation(),[n,{setTrue:r,setFalse:i}]=W.useBoolean(!1),o=Ma(),l=he(),c=()=>{const u=JSON.stringify(l.contentJSON,null,2),d=`${o.name}__${l.name}`;Zt(d,u)};return s.jsxs(a.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[s.jsx(a.Menu.Target,{children:s.jsx(a.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:s.jsx(a.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:r,onMouseLeave:i,sx:{opacity:n?1:.6,transform:`translateX(${n?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:s.jsx(k.IconShare3,{size:"1rem"})})})}),s.jsxs(a.Menu.Dropdown,{children:[s.jsx(a.Menu.Item,{icon:s.jsx(k.IconCamera,{size:14}),onClick:t,children:e("common.actions.download_screenshot")}),s.jsx(a.Menu.Divider,{}),s.jsx(a.Menu.Item,{icon:s.jsx(k.IconDownload,{size:14}),onClick:l.queries.downloadAllData,children:e("common.actions.download_data")}),s.jsx(a.Menu.Item,{icon:s.jsx(k.IconCode,{size:14}),onClick:c,children:e("common.actions.download_schema")})]})]})}),kc=S.observer(({children:t,view:e,sx:n={}})=>{const{ref:r,downloadScreenshot:i}=wi(e);return s.jsxs(s.Fragment,{children:[s.jsx(a.Box,{ref:r,pt:10,pb:10,sx:n,children:t}),s.jsx(dk,{downloadScreenshot:i})]})}),Tc=S.observer(({downloadScreenshot:t})=>s.jsx(a.ActionIcon,{className:"download-screenshot-button",color:"blue",onClick:t,children:s.jsx(k.IconCamera,{size:14})})),pk=S.observer(({children:t,view:e})=>{const n=he(),r=e.config,i=n.views.visibleViewIDs.includes(e.id),o=()=>n.views.rmVisibleViewID(e.id),{ref:l,downloadScreenshot:c}=wi(e);return s.jsx(a.Modal,{size:r.width,centered:!0,opened:i,onClose:o,withCloseButton:!1,title:s.jsxs(a.Group,{position:"apart",px:"1rem",h:"48px",children:[s.jsx(a.Box,{children:r.custom_modal_title.value}),s.jsx(Tc,{downloadScreenshot:c})]}),trapFocus:!0,onDragStart:u=>{u.stopPropagation()},styles:{root:{position:"fixed",zIndex:200,inset:0},overlay:{zIndex:"unset"},inner:{zIndex:"unset",padding:"0 !important"},content:{border:"1px solid #efefef",maxHeight:"unset !important",overflow:"hidden"},body:{maxHeight:r.height,overflow:"auto",position:"relative",paddingBottom:10},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:s.jsx(a.Box,{ref:l,children:t})})}),hk=t=>t.color?{"&[data-active], &[data-active]:hover":{borderColor:t.color?t.color:"..."}}:{},mk=S.observer(({view:t})=>{const e=he(),n=t.config;return s.jsxs(a.Tabs,{className:"render-view-tabs",variant:n.variant,orientation:n.orientation,value:t.tab,onTabChange:t.setTab,styles:{root:{height:"100%",overflow:n.orientation==="horizontal"?"hidden":"auto"},panel:{padding:n.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[s.jsx(a.Tabs.List,{grow:n.grow,children:n.tabsInOrder.map(r=>s.jsx(a.Tabs.Tab,{value:r.id,sx:hk(r),disabled:!r.view_id,children:r.name??r.id},r.id))}),n.tabsInOrder.map(r=>{const i=e.views.findByID(r.view_id);return i?s.jsx(a.Tabs.Panel,{value:r.id,children:s.jsx(ps,{view:i})},r.id):null})]})}),xk=S.observer(({view:t,children:e})=>{switch(t.type){case B.Modal:return s.jsx(pk,{view:t,children:e});case B.Tabs:return s.jsx(mk,{view:t});case B.Division:default:return s.jsx(kc,{view:t,children:e})}}),gk=S.observer(({children:t,view:e})=>{const r=Y().layouts,[i,o]=ie.useResizeObserver();return m.useEffect(()=>{r.setCurrentLayoutWrapperWidth(o.width)},[o.width]),s.jsx(a.Box,{sx:{height:"100%"},ref:i,children:s.jsx(a.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:r.currentLayoutPreviewWidth??"100%",transform:`scale(${r.divisionPreviewScale})`,transformOrigin:"0 0"},children:s.jsx(kc,{view:e,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:t})})})});function Dc(t){return t.replace(/(vw|vh)/,"%")}const fk=S.observer(({children:t,view:e})=>{const n=e.config,{width:r,height:i}=m.useMemo(()=>({width:Dc(n.width),height:Dc(n.height)}),[n.width,n.height]),{ref:o,downloadScreenshot:l}=wi(e);return s.jsx(a.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:s.jsx(a.Modal,{size:n.width,opened:!0,onClose:b.noop,withCloseButton:!1,title:s.jsxs(a.Group,{position:"apart",px:"1rem",h:"48px",children:[s.jsx(a.Box,{children:n.custom_modal_title.value}),s.jsx(Tc,{downloadScreenshot:l})]}),trapFocus:!0,onDragStart:c=>{c.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},inner:{position:"relative",top:"50%",left:"50%",right:"unset",bottom:"unset",transform:"translate(-50%, -50%)",padding:"0 !important",width:r,height:i,maxHeight:i},content:{border:"1px solid #efefef",height:"100%"},body:{maxHeight:"calc(100% - 48px)",overflow:"auto"},header:{padding:0},title:{flexGrow:1}},withinPortal:!1,transitionProps:{duration:0},children:s.jsx(a.Box,{ref:o,children:t})})})}),yk=({variant:t,orientation:e})=>{const n={root:{height:"100%",overflow:"hidden"},tabsList:{backgroundColor:"white"},tab:{},panel:{padding:"16px"}};return t==="pills"&&e==="horizontal"&&(n.tab.paddingTop="6px",n.tab.paddingBottom="6px"),e==="vertical"&&(n.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},n.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),n},bk=t=>t.color?{"&[data-active], &[data-active]:hover":{borderColor:t.color?t.color:"..."}}:{},vk=S.observer(({view:t})=>{const{t:e}=_.useTranslation(),n=Fe.useModals(),r=Y(),i=m.useMemo(()=>r.views.options.filter(u=>u.type===B.Division),[t.id,r.views.options]),o=t.config,l=u=>n.openConfirmModal({title:`${e("view.component.tabs.tab.delete")}?`,labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{o.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),c=o.tabs.length===0;return s.jsxs(a.Tabs,{className:"preview-view-tabs",variant:o.variant,orientation:o.orientation,value:t.tab,onTabChange:t.setTab,styles:yk(o),children:[s.jsxs(a.Tabs.List,{grow:o.grow,children:[o.tabsInOrder.map(u=>s.jsx(a.Tabs.Tab,{value:u.id,sx:bk(u),children:u.name??u.id},u.id)),s.jsx(a.Tabs.Tab,{onClick:o.addTab,value:"add",className:"add-a-tab",children:s.jsx(L.Plus,{size:18,color:"#228be6"})})]}),o.tabsInOrder.map((u,d)=>{const p=r.views.findByID(u.view_id);return s.jsxs(a.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[s.jsxs(a.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[s.jsx(a.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),s.jsxs(a.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[s.jsx(a.TextInput,{label:e("view.component.tabs.tab.name"),required:!0,value:u.name,onChange:h=>u.setName(h.currentTarget.value)}),s.jsx(a.Select,{label:"View",value:u.view_id,onChange:u.setViewID,data:i}),s.jsx(a.NumberInput,{label:e("view.component.tabs.tab.order"),required:!0,value:u.order,onChange:h=>u.setOrder(h||0),min:0,max:1e3,step:1}),s.jsx(a.ColorInput,{label:e("view.component.tabs.tab.color"),value:u.color,onChange:u.setColor,disabled:o.variant!=="default"}),p&&s.jsx(a.Button,{mt:20,variant:"gradient",leftIcon:s.jsx(k.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>r.views.setIDOfVIE(p.id),children:e("view.component.tabs.tab.switch_to_view",{name:p.name})}),s.jsx(a.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>l(d),disabled:c,leftIcon:s.jsx(k.IconTrash,{size:14}),children:e("view.component.tabs.tab.delete")})]})]}),p&&s.jsx(ps,{view:p})]},u.id)})]})}),_k=S.observer(({view:t,children:e})=>{switch(t.type){case B.Modal:return s.jsx(fk,{view:t,children:e});case B.Tabs:return s.jsx(vk,{view:t});case B.Division:default:return s.jsx(gk,{view:t,children:e})}}),zc=S.observer(function({view:e}){const r=Y().layouts.divisionPreviewScale!==1;return s.jsx(ls.Provider,{value:{viewPanelInFullScreen:b.noop,inFullScreen:!1},children:s.jsx(a.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:r?"transparent":"#efefef"},children:s.jsx(_k,{view:e,children:s.jsxs(a.Box,{sx:{position:"relative"},children:[s.jsx(a.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:s.jsx(Pl,{view:e})}),s.jsx(lk,{view:e})]})})})})}),ps=S.observer(function({view:e}){const{fullScreenPanelID:n,setFullScreenPanelID:r}=La(),{viewPanelInFullScreen:i,exitFullScreen:o,inFullScreen:l,fullScreenPanel:c}=Sc(e,n,r);return s.jsx(ls.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:l},children:s.jsxs(a.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:e.type===B.Modal?"0 !important":"100%"},children:[l&&s.jsx(Cc,{view:e,panel:c,exitFullScreen:o}),s.jsx(xk,{view:e,children:s.jsxs(a.Box,{sx:{position:"relative"},children:[!l&&s.jsx(a.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:s.jsx(Pl,{view:e})}),!l&&s.jsx(uk,{view:e})]})})]})})});var Mc=(t=>(t.Use="use",t.Edit="edit",t))(Mc||{});const jk={[B.Division]:"Division",[B.Tabs]:"Tabs",[B.Modal]:"Modal"},Ic={[B.Division]:"rgba(255, 0, 0, 0.2)",[B.Modal]:"rgba(0, 0, 0, 0.2)",[B.Tabs]:"rgba(255, 200, 100, 0.4)"},wk={[B.Division]:"#ff4000",[B.Modal]:"#000",[B.Tabs]:"#ffad18"};function Ck(t,e,n){x.addDisposer(t,x.addMiddleware(t,(r,i)=>{i(r,()=>{x.getType(r.context)===e&&r.type==="action"&&n(r.name,r.context)})}))}const Ec=x.types.compose("FiltersModel",mi,x.types.model("FiltersModel",{previewValues:x.types.optional(x.types.frozen(),{})})).views(t=>({get idSet(){return new Set(t.current.map(e=>e.id))},get keySet(){return new Set(t.current.map(e=>e.key))},get options(){return t.current.map(e=>({label:e.label??e.id,value:e.id,_type:"filter"}))},get selects(){return t.current.filter(e=>e.type===re.Select).map(e=>({label:e.label??e.id,value:e.id}))},get keyLabelOptions(){return t.current.map(e=>({label:e.label??e.key,value:e.key}))},get sortedList(){return b.sortBy(t.current,e=>e.label.toLowerCase())}})).actions(t=>({replace(e){t.current=x.cast(e)},append(e){t.current.push(e)},appendMultiple(e){if(e.length===0)return;const n=e.filter(r=>!t.idSet.has(r.id));t.current.push(...n)},remove(e){t.current.splice(e,1)},removeByID(e){const n=t.current.findIndex(r=>r.id===e);n>=0&&t.current.splice(n,1)},updatePreviewValues(e){t.previewValues=e}})).actions(t=>{function e(){Ck(t.current,si,(n,r)=>{if(n==="setType"){const i=oc(r.config.default_value,r.config);t.setValueByKey(r.key,i),t.updatePreviewValues({...t.previewValues,[r.key]:i})}})}return{afterCreate(){e()}}}),Ac=gi.views(t=>({get canPreviewData(){return t.isTransform?t.dep_query_ids.length>0&&!!t.pre_process:!!t.datasource},get guideToPreviewData(){return t.isTransform?"Need to complete settings in Transform tab":"Need to pick a Data Source first"}})),Pc=x.types.compose("QueriesModel",fi,x.types.model({current:x.types.optional(x.types.array(Ac),[])})).views(t=>({get options(){const e=t.current.map(n=>({value:n.id,label:n.name,_type:"query"}));return b.sortBy(e,n=>n.label.toLowerCase())},get optionsWithoutTransform(){const e=t.current.filter(n=>n.type!==de.Transform).map(n=>({value:n.id,label:n.name,_type:"query"}));return b.sortBy(e,n=>n.label.toLowerCase())},get sortedList(){return b.sortBy(t.current,e=>e.name.toLowerCase())}})).actions(t=>({replace(e){t.current=x.cast(e)},append(e){t.current.push(e)},appendMultiple(e){if(e.length===0)return;const n=e.filter(r=>!t.idSet.has(r.id));t.current.push(...n)},remove(e){t.current.splice(e,1)},replaceByIndex(e,n){t.current.splice(e,1,n)},removeQuery(e){const n=t.current.find(r=>r.id===e);n&&(x.detach(n),t.current.remove(n))},removeQueries(e){const n=new Set(e);t.current.forEach(i=>{n.has(i.id)&&x.detach(i)});const r=[...t.current];b.remove(r,i=>n.has(i.id)),t.current=x.cast(r)}})),$c=bi.views(t=>({get sortedList(){return b.sortBy(t.current,e=>e.key.toLowerCase())},get options(){const e=t.current.map(n=>({label:n.key,value:n.key,_type:"sql_snippet"}));return b.sortBy(e,n=>n.label.toLowerCase())}})).actions(t=>({replace(e){t.current=x.cast(e)},append(e){t.current.push(e)},appendMultiple(e){if(e.length===0)return;const n=e.filter(r=>!t.keySet.has(r.key));t.current.push(...n)},remove(e){t.current.splice(e,1)},removeByKey(e){const n=t.current.findIndex(r=>r.key===e);n>=0&&t.current.splice(n,1)},removeByKeys(e){const n=new Set(e);t.current.forEach(i=>{n.has(i.key)&&x.detach(i)});const r=[...t.current];b.remove(r,i=>n.has(i.key)),t.current=x.cast(r)},replaceByIndex(e,n){t.current.splice(e,1,n)}})),Sk=x.types.model({data:x.types.optional(x.types.frozen(),[]),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(t=>({get loading(){return t.state==="loading"},get empty(){return t.data.length===0}})),kk=x.types.model({data:x.types.optional(x.types.frozen(),[]),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(t=>({get loading(){return t.state==="loading"},get empty(){return t.data.length===0}})),Tk=x.types.model({page:x.types.optional(x.types.number,1),limit:x.types.optional(x.types.number,20),data:x.types.optional(x.types.frozen(),[]),total:x.types.optional(x.types.number,0),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(t=>({get keywords(){return x.getParent(t,1)},get keywordString(){const{table_name:e,table_schema:n}=x.getParent(t,1);return`${n}||${e}`}})).views(t=>({get loading(){return t.state==="loading"},get empty(){return t.data.length===0},get maxPage(){return Math.ceil(t.total/t.limit)},get offset(){return(t.page-1)*t.limit},get countSql(){const{table_name:e,table_schema:n}=t.keywords;return`
446
+ `}})}function Qz(e,t,n){const{overflow:s,rotate:i}=e.x_axis.axisLabel,a=ut(s.on_axis);return te.getXAxis({id:"main-x-axis",type:"category",data:t,name:e.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:i,...a,formatter:n},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:3})}function Uz(e,t,n){const{nameAlignment:s,data_key:i,...a}=e.y_axis,{overflow:l,rotate:c}=e.y_axis.axisLabel,u=ut(l.on_axis);return te.getYAxis({...a,type:"category",data:t,axisLabel:{rotate:c,...u,formatter:n},axisLine:{show:!0,lineStyle:{width:3}},axisTick:{show:!0,alignWithLabel:!0},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameTextStyle:{fontWeight:"bold",align:s},nameLocation:"end",nameGap:15,z:3})}function Yz(e,t,n){if(!e.x_axis.data_key||!e.y_axis.data_key||!e.heat_block.data_key)return{};const s=n.reduce((k,S)=>{const T=jt(S,t);return k[S.name]=Re(S,T),k},{}),i=Vz(e),a=Nz(e),l=Xs(e.visualMap,s),{min:c,max:u}=l,d=O(e.x_axis.data_key),p=O(e.y_axis.data_key),h=O(e.heat_block.data_key),f=v.uniq(t[d.queryID].map(k=>k[d.columnKey])),g=v.uniq(t[d.queryID].map(k=>k[p.columnKey])),y=t[d.queryID].map(k=>{const S=v.get(k,d.columnKey),T=v.get(k,p.columnKey),z=v.get(k,h.columnKey),I={value:[S,T,z]},{followVisualMap:E,color:N}=jo(z,c,u,e.visualMap);return E||(I.visualMap=!1,I.itemStyle={color:N}),I});return{xAxis:Qz(e,f,i.x_axis),yAxis:Uz(e,g,i.y_axis),series:Fz(e,y),tooltip:Rz(e,t,i,a),grid:$z(e),visualMap:l}}function Kz({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=m.useMemo(()=>{const h=O(e.x_axis.data_key),f=O(e.y_axis.data_key);return v.keyBy(t[h.queryID],g=>`${g[h.columnKey]}---${g[f.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),c=nt(i.triggerManager,wh.id),u=m.useCallback(h=>{const[f,g]=h.value,y=v.get(l,`${f}---${g}`,{error:"rowData is not found"});c.forEach(j=>{i.runInteraction(j.id,{...h,rowData:y})})},[l,c,i]),d=m.useMemo(()=>({click:u}),[u]),p=m.useMemo(()=>Yz(e,t,a),[e,t]);return r.jsx(Pe,{echarts:Ae,option:p,style:{width:n,height:s},onEvents:d,notMerge:!0,theme:"merico-light"})}function Xz({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=m.useMemo(()=>v.defaults({},s,Go),[s]),l=e.data,{width:c,height:u}=e.viewport;return!c||!u?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(Kz,{variables:i,width:wt(c),height:Ct(u),data:l,conf:a,interactionManager:n})})}const Jz=[{lang:"en",resources:{merico_heatmap:{viz_name:"Merico Heatmap",click_heatmap:{heatblock:{label:"Click heat block"}}}}},{lang:"zh",resources:{merico_heatmap:{viz_name:"思码逸热力图",click_heatmap:{heatblock:{label:"点击热力块"}}}}}];function Zz(e){const{visualMap:t=Ht(),heat_block:{min:n,max:s,...i},...a}=e;return{...a,heat_block:i,visualMap:{...Ht(),min:n,max:s}}}class Hz extends ge{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:Zz(n.config)}))}}const eI={displayName:"viz.merico_heatmap.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Hz,name:"merico-heatmap",viewRender:Xz,configRender:Lz,createConfig:()=>({version:2,config:Go}),triggers:[wh],translation:Jz},tI=[{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"})),nI=[ex,tx,sx,rx,nx,ix],Ch=[Po,n1,yD,Rk,w1,PS,qM,bx,m_,Y0,NC,nM,jS,M0,GT,ak,Pk,TD,xz,eI,Mz,k_],Sh=()=>({id:"dashboard",version:Mc,manifest:{viz:Ch,color:[...tI,...nI]}}),Rr=new cx,je={pluginManager:Yt("pluginManager"),vizManager:Yt("vizManager"),colorManager:Yt("colorManager"),instanceScope:{panelModel:Yt("panelModel"),vizInstance:Yt("vizInstance"),interactionManager:Yt("interactionManager"),migrator:Yt("migrator"),operationManager:Yt("operationManager"),triggerManager:Yt("triggerManager")}},Wo=()=>{try{Rr.install(Sh())}catch{}const e=new Jg(Rr),t=new lx(Rr);return{pluginManager:Rr,vizManager:e,colorManager:t}},Gt=m.createContext(Wo());try{Rr.install(Sh())}catch{}const Ro=m.createContext(null);function si(e){const t=m.useContext(Ro),n=W.useCreation(()=>e.configure(t||new Ii),[e.configure]),s=W.usePrevious(n);return s&&s!==n&&s.dispose(),r.jsx(Ro.Provider,{value:n,children:e.children})}function kh(){return m.useContext(Ro)}const rI=({description:e,isDescriptionEmpty:t})=>t?null:r.jsx(o.Tooltip,{color:"white",label:r.jsx(Ys,{value:e,styles:{root:{border:"none"},content:{padding:0}}}),styles:{tooltip:{border:"0.0625rem solid rgb(233, 236, 239)",boxShadow:"rgb(0 0 0 / 5%) 0px 0.0625rem 0.1875rem, rgb(0 0 0 / 5%) 0px 1.25rem 1.5625rem -0.3125rem, rgb(0 0 0 / 4%) 0px 0.625rem 0.625rem -0.3125rem"}},withArrow:!0,children:r.jsx(o.Box,{sx:{height:"16px",alignSelf:"center"},children:r.jsx(M.IconInfoCircle,{size:16,color:"gray"})})}),sI=D.observer(({label:e,config:{default_value:t,description:n,isDescriptionEmpty:s,...i},value:a,onChange:l})=>r.jsxs(o.Box,{children:[r.jsx(o.Text,{children:" "}),r.jsx(o.Checkbox,{label:r.jsxs(o.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[r.jsx(o.Box,{sx:{flexGrow:1},children:e}),r.jsx(rI,{description:n,isDescriptionEmpty:s})]}),checked:a||!1,onChange:c=>l(c.currentTarget.checked),...i,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),iI=({value:e,onChange:t,close:n,max_days:s,allowSingleDateInRange:i})=>{const{i18n:a}=_.useTranslation(),[l,c]=e,u=m.useMemo(()=>l||new Date,[l]),d=m.useMemo(()=>{if(l&&!c)return l},[l,c]),p=m.useMemo(()=>{if(l&&!c&&s>0)return P(l).add(s-1,"days").toDate()},[l,c,s]),h=f=>{const[g,y]=f;t(f),g&&y&&n()};return r.jsx(Xl.DatePicker,{defaultDate:u,numberOfColumns:2,type:"range",value:e,onChange:h,onNextMonth:console.log,minDate:d,maxDate:p,allowSingleDateInRange:i,locale:a.language})},aI=({begin:e,end:t})=>{const{t:n}=_.useTranslation(),s=m.useMemo(()=>P(t).diff(P(e),"days")+1,[e,t]);if(Number.isNaN(s))return r.jsx("span",{style:{userSelect:"none",opacity:0,visibility:"hidden"},children:"."});const i=s===1?n("filter.widget.date_range.one_day"):n("filter.widget.date_range.x_days",{count:s});return r.jsx(o.Tooltip,{label:i,children:r.jsx(o.Badge,{size:"sm",children:s})})},oI=({max_days:e})=>{const{t}=_.useTranslation();return e?r.jsxs(r.Fragment,{children:[r.jsx(o.Group,{position:"right",children:r.jsx(o.Badge,{size:"xs",children:t("filter.widget.date_range.x_max_days",{max_days:e})})}),r.jsx(o.Divider,{variant:"dashed",my:10})]}):null},Qo=()=>[{key:"d",value:"yesterday",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"w",value:"last week",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"week").startOf("week").toDate(),P(e).subtract(1,"week").endOf("week").toDate()]}},{key:"m",value:"last month",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"month").startOf("month").toDate(),P(e).subtract(1,"month").endOf("month").toDate()]}},{key:"m2",value:"last 2 months",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(2,"month").startOf("month").toDate(),P(e).subtract(1,"month").endOf("month").toDate()]}},{key:"m3",value:"last 3 months",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(3,"month").startOf("month").toDate(),P(e).subtract(1,"month").endOf("month").toDate()]}},{key:"y",value:"last year",group:"last",getRange:()=>{const e=Date.now();return[P(e).subtract(1,"year").startOf("year").toDate(),P(e).subtract(1,"year").endOf("year").toDate()]}},{key:"d7",value:"recent 7 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(7,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d30",value:"recent 30 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(30,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d60",value:"recent 60 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(60,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d90",value:"recent 90 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(90,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d180",value:"recent 180 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(180,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d365",value:"recent 365 days",group:"recent",getRange:()=>{const e=Date.now();return[P(e).subtract(365,"day").startOf("day").toDate(),P(e).subtract(1,"day").endOf("day").toDate()]}},{key:"d",value:"today",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("day").toDate(),P(e).endOf("day").toDate()]}},{key:"w",value:"this week",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("week").toDate(),P(e).endOf("week").toDate()]}},{key:"m",value:"this month",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("month").toDate(),P(e).endOf("month").toDate()]}},{key:"y",value:"this year",group:"this",getRange:()=>{const e=Date.now();return[P(e).startOf("year").toDate(),P(e).endOf("year").toDate()]}},{key:"w",value:"this week so far",group:"this_so_far",getRange:()=>{const e=Date.now();return[P(e).startOf("week").toDate(),P(e).toDate()]}},{key:"m",value:"this month so far",group:"this_so_far",getRange:()=>{const e=Date.now();return[P(e).startOf("month").toDate(),P(e).toDate()]}},{key:"y",value:"this year so far",group:"this_so_far",getRange:()=>{const e=Date.now();return[P(e).startOf("year").toDate(),P(e).toDate()]}}];function Th(e){const n=Qo().find(s=>s.value===e);return n?n.getRange():null}const lI=({onChange:e})=>{const{t,i18n:n}=_.useTranslation(),s=l=>()=>{const c=l();e(c)},i=m.useMemo(()=>v.groupBy(Qo(),"group"),[]),a=n.language==="zh";return r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{variant:"dashed",my:10}),r.jsx(o.Table,{withBorder:!1,sx:{"tbody > tr > th, tbody > tr > td":{borderTop:"none",padding:"2px 6px"},"tbody > tr > th":{cursor:"default",userSelect:"none"},td:{paddingLeft:"1px"}},children:r.jsx("tbody",{children:Object.entries(i).map(([l,c])=>r.jsxs("tr",{children:[r.jsx("th",{children:r.jsx(o.Text,{size:"xs",color:"#555",children:t(`filter.widget.date_range.shortcut.${l}.label`)})}),c.map(({key:u,value:d,getRange:p})=>r.jsx("td",{children:r.jsx(o.Button,{compact:!0,size:"xs",variant:"subtle",onClick:s(p),children:t(`filter.widget.date_range.shortcut.${l}.${a?"full.":""}${u}`)})},u))]},l))})})]})},Dh=e=>({label:{display:"block",height:"21.7px"},input:{borderColor:e?"#228be6":"#e9ecef"}}),cI=({label:e,required:t,value:n,onChange:s,max_days:i,allowSingleDateInRange:a,inputFormat:l})=>{const{t:c}=_.useTranslation(),[u,{open:d,close:p}]=he.useDisclosure(!1),[h,f]=n,g=h?P(h).format(l):"",y=f?P(f).format(l):"";return r.jsxs(o.Popover,{opened:u,onClose:p,position:"bottom-start",shadow:"md",children:[r.jsxs(o.Group,{position:"left",grow:!0,noWrap:!0,spacing:0,w:"288px",sx:{marginTop:"3px"},children:[r.jsx(o.Popover.Target,{children:r.jsx(o.TextInput,{label:e,labelProps:{title:e},required:t,icon:r.jsx(M.IconCalendar,{size:16}),placeholder:c("filter.widget.date_range.start_date"),readOnly:!0,value:g,onFocus:d,styles:Dh(u),sx:{".mantine-TextInput-label":{textOverflow:"ellipsis",overflow:"hidden",whiteSpace:"nowrap",width:"calc(240px)",position:"relative",zIndex:1},".mantine-Input-input":{borderRight:"none",borderTopRightRadius:0,borderBottomRightRadius:0}}})}),r.jsx(o.TextInput,{label:r.jsx(o.Group,{position:"right",children:r.jsx(aI,{begin:h,end:f})}),icon:r.jsx(M.IconMinus,{size:16}),placeholder:c("filter.widget.date_range.end_date"),readOnly:!0,disabled:!h,value:y,onFocus:d,styles:Dh(u),sx:{".mantine-Input-icon":{transform:"translateX(-22px)"},".mantine-Input-input":{borderLeft:"none",borderTopLeftRadius:0,borderBottomLeftRadius:0},".mantine-Input-input[data-disabled]":{backgroundColor:"transparent",backgroundImage:"linear-gradient(to right, #fff 0%, #f1f3f5 30%)",opacity:1},".mantine-Input-input[data-disabled]::placeholder":{opacity:.6}}})]}),r.jsxs(o.Popover.Dropdown,{p:"sm",children:[r.jsx(oI,{max_days:i}),r.jsx(iI,{value:n,onChange:s,close:p,allowSingleDateInRange:a,max_days:i}),r.jsx(lI,{onChange:s})]})]})},Mh=D.observer(({label:e,config:t,value:n=[null,null],onChange:s})=>{const{inputFormat:i,required:a,max_days:l,allowSingleDateInRange:c}=t,u=Array.isArray(n)?n.map(p=>p?P(p).toDate():null):[null,null],d=p=>{s(p.map(h=>h&&P(h).format(i)))};return r.jsx(cI,{label:e,value:u,onChange:d,inputFormat:i,allowSingleDateInRange:c,max_days:l,required:a})}),uI=o.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-select.rc-select-open":{borderColor:"#228be6 !important",".rc-select-selection-overflow-item-rest":{display:"none"},".rc-select-selection-overflow-item-suffix":{display:"block"}},".rc-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-select-selection-search-mirror":{display:"none"},".rc-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,backgroundColor:"#fff",border:"1px solid #e9ecef",marginTop:6,padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px","&.rc-select-dropdown-slide-up-leave-active":{display:"none"},".rc-select-item-empty":{padding:"8px 12px"},".rc-select-item-option":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px 8px 2px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},flexDirection:"row-reverse",".rc-select-item-option-state":{flexGrow:0,flexShrink:0,width:"30px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},".rc-select-item-option-content":{width:"calc(100% - 30px)",overflow:"hidden",'div[data-role="label"]':{overflowWrap:"break-word"}}},".rc-virtual-list-holder-inner":{alignItems:"flex-start"}}})),Uo=({errorMessage:e})=>{const{t}=_.useTranslation();return e?r.jsx(o.Text,{color:"red",size:12,children:e}):r.jsx(o.Text,{color:"dimmed",size:12,children:t("filter.widget.common.selector_option_empty")})},dI=({disabled:e,classNames:t,styles:n,unstyled:s,radius:i,style:a,label:l,value:c,onChange:u,options:d,errorMessage:p,required:h})=>{const{t:f}=_.useTranslation(),{classes:g,cx:y}=uI({radius:i},{name:"MultiSelectWidget",classNames:t,styles:n,unstyled:s}),[j,k]=m.useState(!1),S=N=>{k(N)},T=j&&(c==null?void 0:c.length)>0,[z,I]=m.useState(""),E=m.useMemo(()=>{if(!z)return d;const N=z.toLowerCase(),R=pe=>{var ie;return((ie=pe.description)==null?void 0:ie.toLowerCase().includes(N))||pe.label.toLowerCase().includes(N)};return d.filter(R)},[z,d]);return r.jsxs(o.Stack,{spacing:3,children:[r.jsxs(o.Group,{position:"apart",children:[r.jsxs(o.Text,{className:g.label,children:[l,h&&r.jsx("span",{className:g.required,"aria-hidden":"true",children:"*"})]}),T&&r.jsx(o.Tooltip,{label:f("filter.widget.common.x_selected",{count:c.length}),children:r.jsx(o.Badge,{children:c.length})})]}),r.jsx(dc,{disabled:e,allowClear:!0,className:y(g.root,"check-select"),dropdownClassName:y(g.dropdown,""),onDropdownVisibleChange:S,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:a,clearIcon:()=>r.jsx(o.CloseButton,{}),value:c,onChange:u,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:r.jsx(Uo,{errorMessage:p}),maxTagTextLength:10,maxTagPlaceholder:N=>f("filter.widget.common.x_selected",{count:N.length}),searchValue:z,onSearch:I,filterOption:!1,children:E.map(N=>r.jsxs(dc.Option,{title:N.label,children:[r.jsx(o.Text,{size:"sm","data-role":"label",children:N.label}),N.description&&r.jsx(o.Text,{size:"xs",color:"dimmed","data-role":"description",children:N.description})]},N.value))})]})},pI=D.observer(({label:e,config:t,value:n,onChange:s})=>{const i=_e(),a=!!t.options_query_id,{state:l,error:c}=i.getDataStuffByID(t.options_query_id),u=l==="loading",d=t.min_width?t.min_width:"200px",p=a?u:!1,h=f=>s(f,!1);return r.jsx(dI,{label:e,options:t.options,style:{minWidth:"160px",width:d,maxWidth:p?d:"unset",borderColor:"#e9ecef"},disabled:p,value:n,onChange:h,errorMessage:c,required:t.required})}),hI=m.forwardRef(({label:e,description:t,...n},s)=>r.jsx("div",{ref:s,...n,children:r.jsx(o.Group,{noWrap:!0,children:r.jsxs("div",{children:[r.jsx(o.Text,{size:"sm","data-role":"label",children:e}),r.jsx(o.Text,{size:"xs",color:"dimmed","data-role":"description",children:t})]})})})),fI=D.observer(({label:e,config:t,value:n,onChange:s})=>{const i=_e(),a=!!t.options_query_id,{state:l,error:c}=i.getDataStuffByID(t.options_query_id),u=l==="loading";return r.jsx(o.Select,{label:e,data:t.options,disabled:a?u:!1,value:n,onChange:s,maxDropdownHeight:500,styles:{root:{width:t.width?t.width:"200px"},input:{borderColor:"#e9ecef"}},sx:{".mantine-Select-item[data-selected] .mantine-Text-root[data-role=description]":{color:"rgba(255,255,255,.7)"},".mantine-Select-nothingFound":{fontSize:"0.75rem",textAlign:"left",padding:"4px 10px"}},itemComponent:hI,searchable:!c,nothingFound:r.jsx(Uo,{errorMessage:c}),clearable:t.clearable})});function mI({label:e,config:t,value:n,onChange:s}){return r.jsx(o.TextInput,{label:e,value:n||"",onChange:i=>s(i.currentTarget.value),...t,styles:{input:{borderColor:"#e9ecef"}}})}const gI=({rotate:e,onClick:t})=>r.jsx("svg",{onClick:t,className:"caret-icon",viewBox:"0 0 1024 1024",focusable:"false","data-icon":"caret-down",width:"14px",height:"14px",fill:"currentColor","aria-hidden":"true",transform:`rotate(${e})`,children:r.jsx("path",{d:"M840.4 300H183.6c-19.7 0-30.7 20.8-18.5 35l328.4 380.8c9.4 10.9 27.5 10.9 37 0L858.9 335c12.2-14.2 1.2-35-18.5-35z"})}),xI=({expanded:e,isLeaf:t,value:n,onClick:s,...i})=>(n==="0-0-value"&&console.log(i),t?r.jsx("span",{style:{width:"14px",display:"inline-block"}}):r.jsx(gI,{rotate:e?"0":"-90",onClick:s,...i})),yI=({onClick:e})=>r.jsxs("svg",{onClick:e,className:"checkbox-icon",width:"16",height:"16",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:"2",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),r.jsx("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),r.jsx("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),r.jsx("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),bI=({onClick:e,...t})=>r.jsx(yI,{onClick:e,...t}),vI=o.createStyles((e,{radius:t=4})=>({root:{borderRadius:e.fn.radius(t),display:"flex",flexWrap:"nowrap",border:"1px solid #ced4da",paddingLeft:"0px",paddingRight:"30px",backgroundColor:"#fff",transition:"border-color 100ms ease",borderColor:"#e9ecef","&.rc-tree-select.rc-tree-select-open":{borderColor:"#228be6 !important",".rc-tree-select-selection-overflow-item-rest":{display:"none"},".rc-tree-select-selection-overflow-item-suffix":{display:"block"}},".rc-tree-select-selector":{height:"auto",lineHeight:1.55,paddingLeft:"12px",resize:"none",boxSizing:"border-box",fontSize:"14px",width:"100%",color:"#000",display:"block",textAlign:"left",minHeight:"36px",cursor:"pointer",flexGrow:1},".rc-tree-select-selection-search-mirror":{display:"none"},".rc-tree-select-selection-search":{flexGrow:1,width:"auto !important"},".rc-tree-select-selection-overflow":{display:"flex",minHeight:"34px",alignItems:"center",flexWrap:"nowrap",marginLeft:"calc(-10px / 2)",boxSizing:"border-box"},".rc-tree-select-selection-overflow-item":{display:"flex",alignItems:"center",backgroundColor:"#f1f3f5",color:"#495057",height:"24px",paddingLeft:"12px",paddingRight:"12px",fontWeight:500,fontSize:"12px",borderRadius:"4px",cursor:"default",userSelect:"none",maxWidth:"calc(100% - 20px)",margin:"calc(10px / 2 - 2px) calc(10px / 2)"},".rc-tree-select-selection-overflow-item-rest":{cursor:"pointer"},".rc-tree-select-selection-overflow-item-suffix":{display:"none",backgroundColor:"transparent",width:"100%",maxWidth:"100%",height:"28px",margin:0,paddingLeft:0,paddingRight:0},input:{flex:1,minWidth:"60px",backgroundColor:"transparent",border:0,outline:0,fontSize:"14px",padding:0,marginLeft:0,color:"inherit",height:"28px",lineHeight:"32px",cursor:"pointer",width:"100%","&::-webkit-search-decoration, &::-webkit-search-cancel-button, &::-webkit-search-results-button, &::-webkit-search-results-decoration":{display:"none"}},".rc-tree-select-clear":{marginRight:"-24px",alignSelf:"center",cursor:"pointer"},"&.rc-tree-select-disabled":{backgroundColor:"rgb(241, 243, 245)",color:"rgb(144, 146, 150)",opacity:.6,"&, .rc-tree-select-selector, input":{cursor:"not-allowed"}}},label:{fontSize:e.fontSizes.sm,fontWeight:500,color:"#212529"},required:{color:"#fa5252",paddingLeft:"3px"},dropdown:{fontSize:e.fontSizes.xs,zIndex:300,paddingTop:"6px","&.rc-tree-select-dropdown-slide-up-leave-active":{display:"none"},".rc-tree-select-tree-list .rc-tree-select-tree-list-holder":{},".rc-tree-select-tree-list, .rc-tree-select-empty":{backgroundColor:"#fff",border:"1px solid #e9ecef",padding:0,boxShadow:"0 1px 3px rgb(0 0 0 / 5%), rgb(0 0 0 / 5%) 0px 10px 15px -5px, rgb(0 0 0 / 4%) 0px 7px 7px -5px",borderRadius:"4px"},".rc-tree-select-empty":{padding:"8px 12px"},".rc-tree-select-tree-treenode":{boxSizing:"border-box",textAlign:"left",width:"100%",padding:"8px 12px",cursor:"pointer",fontSize:"14px",color:"#000",borderRadius:"4px",display:"flex",flexWrap:"nowrap",overflow:"hidden","&:hover":{backgroundColor:"#f1f3f5"},"&.rc-tree-select-tree-treenode-checkbox-checked":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-checked":{stroke:"rgb(64, 192, 87)",animation:"check 200ms linear forwards"}},"&.rc-tree-select-tree-treenode-checkbox-indeterminate":{".rc-tree-select-tree-iconEle .checkbox-icon .checkmark-indeterminate":{fill:"rgb(64, 192, 87)"}},".rc-tree-select-tree-switcher":{height:"16px",alignSelf:"center",paddingRight:"2px",transition:"color 200ms ease","&:hover":{color:"#228be6","svg.caret-icon":{color:"#228be6"}},"svg.caret-icon":{color:"#ced4da",transition:"all 200ms ease"}},".rc-tree-select-tree-node-content-wrapper":{display:"flex",flexWrap:"nowrap",overflow:"hidden",alignItems:"center",gap:"8px",transition:"color 200ms ease","&:hover":{color:"#228be6"}},".rc-tree-select-tree-iconEle":{height:"16px","svg .border":{stroke:"#ced4da"},".checkbox-icon .checkmark-indeterminate":{fill:"transparent",transition:"fill 200ms ease"},".checkbox-icon .checkmark-checked":{transform:"scale(1.2)",transformOrigin:"center center",strokeDasharray:10,strokeDashoffset:-10},"@keyframes check":{"0%":{strokeDashoffset:10},"100%":{strokeDashoffset:0}}},".rc-tree-select-tree-title":{textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden",".rc-tree-select-tree-title-desc":{fontSize:"12px",maxWidth:"100%",textOverflow:"ellipsis",whiteSpace:"nowrap",overflow:"hidden"}},".rc-tree-select-tree-indent":{flexGrow:0,height:0,verticalAlign:"bottom"},".rc-tree-select-tree-indent-unit":{display:"inline-block",width:"1em"}}}})),_I=({disabled:e,classNames:t,styles:n,unstyled:s,radius:i,style:a,label:l,value:c,onChange:u,treeData:d,errorMessage:p,required:h,treeCheckStrictly:f})=>{const{t:g}=_.useTranslation(),{classes:y,cx:j}=vI({radius:i},{name:"FilterTreeSelectWidget",classNames:t,styles:n,unstyled:s}),[k,S]=m.useState(!1),T=I=>{S(I)},z=k&&(c==null?void 0:c.length)>0;return r.jsxs(o.Stack,{spacing:3,children:[r.jsxs(o.Group,{position:"apart",children:[r.jsxs(o.Text,{className:y.label,children:[l,h&&r.jsx("span",{className:y.required,"aria-hidden":"true",children:"*"})]}),z&&r.jsx(o.Tooltip,{label:g("filter.widget.common.x_selected",{count:c.length}),children:r.jsx(o.Badge,{children:c.length})})]}),r.jsx(pc,{disabled:e,allowClear:!0,treeCheckStrictly:f,labelInValue:!0,className:j(y.root,"check-select"),dropdownClassName:j(y.dropdown,""),onDropdownVisibleChange:T,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:a,listHeight:510,treeLine:!0,clearIcon:()=>r.jsx(o.CloseButton,{}),switcherIcon:xI,treeIcon:bI,maxTagTextLength:10,value:c,treeData:d,notFoundContent:r.jsx(Uo,{errorMessage:p}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:pc.SHOW_PARENT,onChange:u,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:()=>g("filter.widget.common.x_selected",{count:c.length})})]})},jI=D.observer(({label:e,config:t,value:n,onChange:s})=>{const{treeData:i,treeDataLoading:a,errorMessage:l}=t,c=f=>{const g=f.map(y=>y.value);s(g,!1)},u=m.useMemo(()=>t.initialSelection(n),[n,t.initialSelection]),d=t.min_width?t.min_width:"200px",h=!!t.options_query_id?a:!1;return r.jsx(_I,{disabled:h,style:{minWidth:"160px",width:d,maxWidth:h?d:"unset",borderColor:"#e9ecef"},value:[...u],onChange:c,treeData:i,errorMessage:l,label:e,required:t.required,treeCheckStrictly:t.treeCheckStrictly})}),wI=D.observer(({filter:{type:e,config:t,key:n,...s},formFieldProps:i})=>{switch(e){case"select":return r.jsx(fI,{...s,...i,config:t});case"multi-select":return r.jsx(pI,{...s,...i,config:t});case"tree-select":return r.jsx(jI,{...s,...i,config:t});case"text-input":return r.jsx(mI,{...s,...i,config:t});case"date-range":return r.jsx(Mh,{...s,...i,config:t});case"checkbox":return r.jsx(sI,{...s,...i,config:t});default:return null}}),CI=D.observer(m.forwardRef(({filter:e,...t},n)=>r.jsx("div",{className:"filter-root",ref:n,children:r.jsx(ze,{children:r.jsx(wI,{filter:e,formFieldProps:t})})}))),SI=({disabled:e})=>{const{searchButtonProps:t}=Ac(),{children:n="Search",type:s,...i}=t;return r.jsx(o.Button,{color:"blue",size:"sm",type:"submit",...i,disabled:e||i.disabled,children:n})};function kI(e){const t=Y();m.useEffect(()=>{var n,s;(s=(n=t.filters).updatePreviewValues)==null||s.call(n,e)},[e])}const TI=({opened:e,toggle:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Group,{position:"right",ml:-4,mt:-4,mb:e?4:0,children:r.jsx(o.Button,{size:"xs",compact:!0,variant:"subtle",color:e?"gray":"blue",leftIcon:e?r.jsx(M.IconChevronsUp,{size:14}):r.jsx(M.IconChevronsDown,{size:14}),onClick:t,children:n(e?"filter.hide_filters":"filter.show_filters")})})},zh=D.observer(function({view:t}){const[n,{toggle:s}]=he.useDisclosure(!0),i=_e(),{control:a,handleSubmit:l,reset:c}=b.useForm({defaultValues:i.filters.values,reValidateMode:"onBlur"}),u=b.useWatch({control:a});m.useEffect(()=>{c(i.filters.values)},[i.filters.values,c]),kI(u);const d=i.filters.visibleInView(t.id),p=m.useMemo(()=>d.every(y=>y.should_auto_submit),[d]),h=m.useMemo(()=>d.filter(y=>v.get(y,"config.required",!1)),[d]),f=m.useMemo(()=>h.length===0?!1:h.some(y=>!y.requiredAndPass(u[y.key])),[u,h]);if(d.length===0)return null;const g=(y,j)=>(k,S)=>{j(k),(y.should_auto_submit||S)&&i.filters.setValueByKey(y.key,k)};return r.jsxs("form",{onSubmit:l(i.filters.setValues),children:[r.jsx(TI,{opened:n,toggle:s}),r.jsx(o.Collapse,{in:n,children:r.jsxs(o.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:p?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[r.jsx(o.Group,{align:"flex-start",children:d.map(y=>r.jsx(b.Controller,{name:y.key,control:a,render:({field:j})=>r.jsx(CI,{filter:y,value:j.value,onChange:g(y,j.onChange)})},y.id))}),!p&&r.jsx(o.Group,{sx:{alignSelf:"flex-end"},children:r.jsx(SI,{disabled:f})})]})})]})}),DI={viewPanelInFullScreen:v.noop,inFullScreen:!1},ii=m.createContext(DI),Yo=x.types.model("MockContextMeta",{current:x.types.optional(x.types.frozen(),{})}).views(e=>({get keys(){return Object.keys(e.current)},get keySet(){return new Set(this.keys)},get entries(){return Object.entries(e.current)}})).actions(e=>({replace(t){e.current=t},defaults(t){e.current={...t,...e.current}},get(t){return e.current[t]},set(t,n){e.current[t]=n}}));function Ko(e){return{current:e}}const MI=x.types.model("PanelStyleBorderMeta",{enabled:x.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),Ih=x.types.model("PanelStyleMeta",{border:MI}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),Eh=x.types.model("PanelTitleMeta",{show:x.types.optional(x.types.boolean,!0)}).views(e=>({get json(){const{show:t}=e;return{show:t}}})).actions(e=>({setShow(t){e.show=t}})),Ah=x.types.model("VariableMeta",{name:x.types.string,size:x.types.string,weight:x.types.string,color:x.types.union(x.types.model({type:x.types.literal("static"),staticColor:x.types.string}),x.types.model({type:x.types.literal("continuous"),valueRange:x.types.array(x.types.number),colorRange:x.types.array(x.types.string)}),x.types.model({type:x.types.literal("piecewise")})),formatter:x.types.model({output:x.types.enumeration("Output",["number","percent"]),average:x.types.optional(x.types.boolean,!1),mantissa:x.types.number,trimMantissa:x.types.optional(x.types.boolean,!1),absolute:x.types.optional(x.types.boolean,!1)}),data_field:x.types.string,aggregation:x.types.union(x.types.model({type:x.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:x.types.frozen(),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("quantile"),config:x.types.model({p:x.types.number}),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("pick_record"),config:x.types.model({method:x.types.enumeration("Pick Record Method",["first","last"])}),fallback:x.types.optional(x.types.string,"0")}),x.types.model({type:x.types.literal("custom"),config:x.types.model({func:x.types.string}),fallback:x.types.optional(x.types.string,"0")}))}).views(e=>({get json(){const{name:t,size:n,weight:s,color:i,formatter:a,data_field:l,aggregation:c}=e;return v.cloneDeep({name:t,size:n,color:i,weight:s,formatter:a,data_field:l,aggregation:c})}})),Ph=x.types.model("PanelVizMeta",{type:x.types.string,conf:x.types.frozen()}).views(e=>({get json(){return{conf:e.conf,type:e.type}}})).actions(e=>({setType(t){e.type=t},setConf(t){e.conf=t}})),Oh=x.types.model({id:x.types.string,name:x.types.optional(x.types.string,""),title:Eh,description:x.types.string,queryIDs:x.types.array(x.types.string),viz:Ph,style:Ih,variables:x.types.optional(x.types.array(Ah),[])}).views(e=>({get json(){const{id:t,name:n,title:s,description:i,queryIDs:a}=e;return{id:t,viz:e.viz.json,name:n,style:e.style.json,title:s.json,queryIDs:[...a],variables:e.variables.map(l=>l.json),description:i}},get queryIDSet(){return new Set(e.queryIDs)}})).actions(e=>({setID(t){e.id=t},setName(t){e.name=t},setDescription(t){e.description=t},addQueryID(t){e.queryIDSet.has(t)||e.queryIDs.push(t)},removeQueryID(t){if(!e.queryIDSet.has(t))return;const n=new Set(e.queryIDSet);n.delete(t),e.queryIDs=x.cast(Array.from(n))},setQueryIDs(t){e.queryIDs=x.cast(t)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)}}));var ye=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e.Transform="transform",e))(ye||{});const Lh=x.types.model("QueryMeta",{id:x.types.string,name:x.types.string,type:x.types.enumeration("DataSourceType",[ye.Postgresql,ye.MySQL,ye.HTTP,ye.Transform]),key:x.types.string,sql:x.types.string,pre_process:x.types.optional(x.types.string,""),post_process:x.types.optional(x.types.string,""),run_by:x.types.optional(x.types.array(x.types.string),[]),react_to:x.types.optional(x.types.array(x.types.string),[]),dep_query_ids:x.types.optional(x.types.array(x.types.string),[])}).views(e=>({get valid(){return e.id&&e.type&&e.key&&e.name?e.type===ye.HTTP?!!e.pre_process:!!e.sql:!1},get json(){const{id:t,name:n,type:s,key:i,sql:a,run_by:l,react_to:c,pre_process:u,post_process:d,dep_query_ids:p}=e;return qn({id:t,key:i,sql:a,name:n,type:s,run_by:l,react_to:c,pre_process:u,post_process:d,dep_query_ids:p})}})).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)},setReactTo(t){e.react_to.length=0,e.react_to.push(...t)},setPreProcess(t){e.pre_process=t},setPostProcess(t){e.post_process=t},setDependantQueryIDs(t){e.dep_query_ids.length=0,e.dep_query_ids.push(...t)}})),Bh=x.types.model("LayoutItemMeta",{id:x.types.identifier,panelID:x.types.string,x:x.types.number,y:x.types.maybeNull(x.types.number),w:x.types.number,h:x.types.number,moved:x.types.optional(x.types.boolean,!1),static:x.types.optional(x.types.boolean,!1)}).views(e=>({get json(){const{id:t,panelID:n,x:s,y:i,w:a,h:l,moved:c}=e;return{h:l,w:a,x:s,y:i===null?0:i,id:t,moved:c,static:e.static,panelID:n}},get contentModel(){return x.getRoot(e).content},get panel(){const{panelID:t}=e;return this.contentModel.panels.findByID(t)},get layoutProperies(){const{id:t,x:n,y:s,w:i,h:a,moved:l}=e;return{id:t,i:t,x:n,y:s===null?1/0:s,w:i,h:a,moved:l,static:e.static}}})).actions(e=>({set(t){const{isDraggable:n,x:s,y:i,w:a,h:l,moved:c}=t;e.x=s,e.y=i,e.w=a,e.h=l,e.moved=!!c,e.static=!!t.static},setWidth(t){e.w=t},setHeight(t){e.h=t}})),qh=x.types.model("LayoutSetMeta",{id:x.types.identifier,name:x.types.string,breakpoint:x.types.number,list:x.types.optional(x.types.array(Bh),[])}).views(e=>({get json(){const{id:t,name:n,breakpoint:s,list:i}=e;return{id:t,name:n,breakpoint:s,list:i.map(a=>qn(a.json))}},jsonByPanelIDSet(t){const{id:n,name:s,breakpoint:i,list:a}=e;return{id:n,name:s,breakpoint:i,list:a.filter(l=>t.has(l.panelID)).map(l=>qn(l.json))}},findByID(t){return e.list.find(n=>n.id===t)},findByPanelID(t){return e.list.find(n=>n.panelID===t)}})).actions(e=>({setName(t){e.name=t},setBreakpoint(t){e.breakpoint=t},addLayout(t){e.list.push(t)},addNewLayout(t){e.list.push({id:Ut.v4(),panelID:t,x:0,y:1/0,w:18,h:300,static:!1,moved:!1})},removeByPanelID(t){const n=e.list.findIndex(s=>s.panelID===t);n>=0&&e.list.splice(n,1)},updateLayoutItem(t){const n=e.list.find(s=>s.id===t.i);if(!n){console.error("Trying to update a layout that doesn't exist"),console.log({strangeLayoutItem:t});return}n.set(t)}})),Vh=x.types.model("SQLSnippetMeta",{key:x.types.string,value:x.types.string}).views(e=>({get json(){const{key:t,value:n}=e;return{key:t,value:n}}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.value=t}}));var ce=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TreeSelect="tree-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(ce||{});const Xo=x.types.model("FilterCheckboxConfigMeta",{_name:x.types.literal("checkbox"),description:x.types.optional(x.types.string,""),default_value:x.types.boolean}).views(e=>({get json(){const{_name:t,description:n,default_value:s}=e;return{_name:t,description:n,default_value:s}},get isDescriptionEmpty(){const{description:t}=e;return t===""||t==="<p></p>"}})).actions(e=>({setDefaultValue(t){e.default_value=t},setDescription(t){e.description=t}})),Nh=()=>Xo.create({_name:"checkbox",description:"",default_value:!1});function $h(e,t){return e.map(n=>{try{return n?P.tz(n,"UTC").format(t):null}catch{return console.log(`[date-range] failed parsing ${n}`),null}})}const zI=x.types.model("FilterDateRangeConfigMeta",{_name:x.types.literal("date-range"),required:x.types.boolean,inputFormat:x.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:x.types.optional(x.types.array(x.types.union(x.types.string,x.types.null)),[null,null]),default_shortcut:x.types.optional(x.types.string,""),clearable:x.types.boolean,max_days:x.types.optional(x.types.number,0),allowSingleDateInRange:x.types.optional(x.types.boolean,!1)}).views(e=>({get json(){const{_name:t,max_days:n,required:s,clearable:i,inputFormat:a,default_value:l,default_shortcut:c,allowSingleDateInRange:u}=e;return{_name:t,max_days:n,required:s,clearable:i,inputFormat:a,default_value:$h(l,a),default_shortcut:c,allowSingleDateInRange:u}},truthy(t){return Array.isArray(t)&&t.length===2&&t.every(n=>!!n)}})).actions(e=>({setFilterValue(t){try{const n=x.getParent(e);x.getParent(n,2).setValueByKey(n.key,t)}catch(n){console.error(n)}}})).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),e.setFilterValue(t)},setDefaultShortcut(t){if(e.default_shortcut=t,!t)return;const n=Th(e.default_shortcut);if(console.log(n),n){const s=n.map(i=>P(i).format(e.inputFormat));e.setFilterValue(s)}},setMaxDays(t){e.max_days=t,t>0&&(e.clearable=!0)},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),Jo=x.types.snapshotProcessor(zI,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>n===null?null:P.tz(n,"UTC").toISOString())}},postProcessor(e){const{default_value:t,...n}=e;return{...n,default_value:$h(t,n.inputFormat)}}}),Fh=()=>Jo.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),II=x.types.model({label:x.types.string,value:x.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),Zo=x.types.model("FilterConfigModel_BaseSelect",{static_options:x.types.optional(x.types.array(II),[]),options_query_id:x.types.optional(x.types.string,""),default_selection_count:x.types.optional(x.types.number,0),required:x.types.optional(x.types.boolean,!1)}).views(e=>({get contentModel(){return x.getRoot(e).content},get filter(){return x.getParent(e)},get usingQuery(){return!!e.options_query_id}})).views(e=>({get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:n}=e.contentModel.getDataStuffByID(e.options_query_id);return n==="error"?[]:Array.isArray(t)?t.filter(s=>"label"in s&&"value"in s):[]}})).actions(e=>({setRequired(t){e.required=t},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??""}})),Ho=x.types.compose("FilterMultiSelectConfigMeta",x.types.model({_name:x.types.literal("multi-select"),min_width:x.types.optional(x.types.string,""),default_value:x.types.optional(x.types.array(x.types.string),[])}),Zo).views(e=>({get json(){const{_name:t,default_value:n,required:s,min_width:i,static_options:a,options_query_id:l,default_selection_count:c}=e;return qn({_name:t,required:!!s,min_width:i,default_value:n,static_options:a,options_query_id:l,default_selection_count:c})},get default_selection(){return e.usingQuery?e.options.slice(0,e.default_selection_count).map(t=>t.value):e.filter.formattedDefaultValue},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=x.cast(t)},setMinWidth(t){e.min_width=t},setDefaultSelection(){const t=x.getRoot(e).content.filters,n=x.getParent(e).key,s=new Set(e.options.map(a=>a.value)),i=(t.values[n]??[]).filter(a=>s.has(a));i.length>0?t.setValueByKey(n,i):t.setValueByKey(n,e.default_selection)}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>X.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!0,delay:0}))}})),Gh=()=>Ho.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),el=x.types.compose("FilterConfigModel_Select",x.types.model({_name:x.types.literal("select"),default_value:x.types.string,width:x.types.optional(x.types.string,""),clearable:x.types.optional(x.types.boolean,!1)}),Zo).views(e=>({get json(){const{_name:t,clearable:n,default_value:s,required:i,width:a,static_options:l,options_query_id:c,default_selection_count:u}=e;return qn({_name:t,width:a,required:i,clearable:n,default_value:s,static_options:l,options_query_id:c,default_selection_count:u})},truthy(t){return!!t},getSelectOption(t){return e.options.find(n=>n.value===t)},get default_selection(){return e.usingQuery?e.default_selection_count>0&&e.options.length>0?e.options[0].value:"":e.filter.formattedDefaultValue}})).actions(e=>({setDefaultValue(t){e.default_value=t},setWidth(t){e.width=t},setClearable(t){e.clearable=t},setDefaultSelection(){var a;const t=x.getRoot(e).content.filters,n=x.getParent(e).key,s=t.values[n],i=(a=e.options.find(l=>l.value===s))==null?void 0:a.value;i?t.setValueByKey(n,i):t.setValueByKey(n,e.default_selection)}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>X.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!1,delay:0}))}})),Wh=()=>el.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),tl=x.types.model("FilterTextInputConfigMeta",{_name:x.types.literal("text-input"),required:x.types.boolean,default_value:x.types.string}).views(e=>({get json(){const{_name:t,required:n,default_value:s}=e;return{_name:t,required:n,default_value:s}},truthy(t){return typeof t!="string"?!1:!!t.trim()}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),nl=()=>tl.create({_name:"text-input",required:!1,default_value:""});function EI(e){return zm.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function AI(e){return e.map(t=>{const{label:n,description:s,...i}=t,a={...i,filterBasis:`${n}___${s??""}`,description:s,label:n};return s&&(a.label=m.createElement("div",{},[m.createElement(o.Text,{key:0,title:t.label},t.label),m.createElement(o.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description},t.description)])),a})}const rl=x.types.compose("FilterTreeSelectConfigMeta",x.types.model({_name:x.types.literal("tree-select"),min_width:x.types.optional(x.types.string,""),default_value:x.types.optional(x.types.array(x.types.string),[]),treeCheckStrictly:x.types.optional(x.types.boolean,!1)}),Zo).views(e=>({get json(){const{_name:t,default_value:n,required:s,min_width:i,static_options:a,options_query_id:l,default_selection_count:c,treeCheckStrictly:u}=e;return{_name:t,required:!!s,min_width:i,default_value:n,static_options:a,options_query_id:l,treeCheckStrictly:u,default_selection_count:c}},get plainData(){const{data:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeData(){const t=this.plainData,n=AI(t);return EI(n)},get errorMessage(){const{error:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t},get treeDataLoading(){const{state:t}=e.contentModel.getDataStuffByID(e.options_query_id);return t==="loading"},get defaultSelection(){const t=e.filter.formattedDefaultValue;if(Array.isArray(t)&&t.length>0)return t;const{default_selection_count:n}=e;return n?this.treeData.slice(0,n).map(i=>i.value):[]},valueObjects(t){const n=new Set(t);return this.plainData.filter(s=>n.has(s.value))},initialSelection(t){return t?this.valueObjects(t):this.valueObjects(this.defaultSelection)},truthy(t){return Array.isArray(t)&&t.length>0}})).actions(e=>({setDefaultValue(t){e.default_value=x.cast(t)},setMinWidth(t){e.min_width=t},setTreeCheckStrictly(t){e.treeCheckStrictly=t},applyDefaultSelection(){const t=x.getParent(e,1).key,n=e.contentModel.filters,s=n.values[t],i=new Set(e.plainData.map(l=>l.value)),a=(s??[]).filter(l=>i.has(l));a.length>0?n.setValueByKey(t,a):n.setValueByKey(t,e.defaultSelection)},afterCreate(){x.addDisposer(e,X.reaction(()=>JSON.stringify(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!0,delay:0}))}})),Rh=()=>rl.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),sl=x.types.model("FilterMeta",{id:x.types.identifier,key:x.types.string,label:x.types.string,order:x.types.number,visibleInViewsIDs:x.types.array(x.types.string),auto_submit:x.types.optional(x.types.boolean,!1),default_value_func:x.types.optional(x.types.string,""),type:x.types.enumeration("DashboardFilterType",[ce.Select,ce.MultiSelect,ce.TreeSelect,ce.TextInput,ce.Checkbox,ce.DateRange]),config:x.types.union(el,Ho,rl,tl,Xo,Jo)}).views(e=>({get contentModel(){return x.getRoot(e).content},get filters(){return this.contentModel.filters},get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==ce.TreeSelect},get usingDefaultValueFunc(){return!!e.default_value_func},get formattedDefaultValue(){return this.filters.formattedDefaultValues[e.key]},get auto_submit_supported(){return[ce.Select,ce.Checkbox,ce.DateRange].includes(e.type)}})).views(e=>({get json(){const{id:t,key:n,label:s,order:i,visibleInViewsIDs:a,default_value_func:l,auto_submit:c,type:u,config:d}=e;return{id:t,key:n,type:u,label:s,order:i,config:d.json,auto_submit:c,visibleInViewsIDs:X.toJS(a),default_value_func:l}},get visibleInViewsIDSet(){return new Set(e.visibleInViewsIDs)},get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return v.get(e.config,"required",!1)?v.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 ce.Select:e.config=Wh();break;case ce.MultiSelect:e.config=Gh();break;case ce.TreeSelect:e.config=Rh();break;case ce.TextInput:e.config=nl();break;case ce.Checkbox:e.config=Nh();break;case ce.DateRange:e.config=Fh();break}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t},setDefaultValueFunc(t){e.default_value_func=t}}));var q=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(q||{});const il=x.types.model("ViewDivisionConfig",{_name:x.types.literal(q.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})),Qh=()=>il.create({_name:q.Division}),PI=x.types.model("CustomModalTitleModel",{enabled:x.types.optional(x.types.boolean,!1),func_content:x.types.optional(x.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,s=x.getParent(e,2),i=x.getRoot(e);if(!t)return s.name;try{const a={filters:i.content.filters.values,context:i.context.current};return new Function(`return ${n}`)()(a)}catch(a){return console.error(a),s.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}})),ai={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
447
+ `)},al=x.types.model("ViewModalConfig",{_name:x.types.literal(q.Modal),width:x.types.string,height:x.types.string,custom_modal_title:x.types.optional(PI,ai)}).views(e=>({get json(){const{_name:t,width:n,height:s,custom_modal_title:i}=e;return{_name:t,width:n,height:s,custom_modal_title:i.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),Uh=()=>al.create({_name:q.Modal,width:"90vw",height:"90vh"}),OI=x.types.model("ViewTabsTabModel",{id:x.types.identifier,name:x.types.string,view_id:x.types.string,color:x.types.optional(x.types.string,""),order:x.types.optional(x.types.number,0)}).views(e=>({get json(){const{id:t,name:n,view_id:s,color:i,order:a}=e;return{id:t,name:n,color:i,order:a,view_id:s}}})).actions(e=>({setName(t){e.name=t},setViewID(t){e.view_id=t},setColor(t){e.color=t},setOrder(t){e.order=t}})),ol=x.types.model("ViewTabsConfig",{_name:x.types.literal(q.Modal),tabs:x.types.optional(x.types.array(OI),[]),variant:x.types.optional(x.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:x.types.optional(x.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:x.types.optional(x.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:n,orientation:s,tabs:i,grow:a}=e;return{grow:a,tabs:i.map(l=>l.json),_name:t,variant:n,orientation:s}},get tabsInOrder(){return v.sortBy(e.tabs,"order")}})).actions(e=>({setVariant(t){e.variant=t},setOrientation(t){e.orientation=t},setGrow(t){e.grow=t},setTabs(t){e.tabs.length=0,e.tabs=x.cast(t)},addTab(){const t=he.randomId(),n={id:t,name:t,view_id:""};e.tabs.push(n)},removeTab(t){e.tabs.splice(t,1)}})),Yh=()=>ol.create({_name:q.Modal,tabs:[]}),Kh=x.types.model({id:x.types.identifier,name:x.types.string,type:x.types.enumeration("EViewComponentType",[q.Division,q.Modal,q.Tabs]),config:x.types.union(il,al,ol),panelIDs:x.types.optional(x.types.array(x.types.string),[])}).views(e=>({get json(){const{id:t,name:n,type:s,config:i}=e;return{id:t,name:n,type:s,config:i.json,panelIDs:e.panelIDs.map(a=>a)}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case q.Division:e.config=Qh();break;case q.Modal:e.config=Uh();break;case q.Tabs:e.config=Yh();break}e.type=t}},appendPanelID(t){e.panelIDs.push(t)},appendPanelIDs(t){e.panelIDs.push(...t)},removePanelID(t){const n=e.panelIDs.filter(s=>s!==t);e.panelIDs.length=0,e.panelIDs.push(...n)}})),en="11.10.0",LI={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:q.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:en,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},ll=x.types.model("DataSourceMetaModel",{id:x.types.string,type:x.types.enumeration("DataSourceType",[ye.HTTP,ye.MySQL,ye.Postgresql]),key:x.types.string,config:x.types.frozen()}),Xh=x.types.model("DataSourcesMetaModel",{list:x.types.optional(x.types.array(ll),[])}).views(e=>({find({type:t,key:n}){return e.list.find(s=>s.key===n&&s.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),Jh=x.types.model({id:x.types.string,content:x.types.string,create_time:x.types.string,update_time:x.types.string,is_preset:x.types.boolean}),cl=x.types.model("GlobalSQLSnippetsMeta",{list:x.types.optional(x.types.array(Jh),[])}).views(e=>({find(t){return e.list.find(n=>n.id===t)},get options(){return e.list.map(t=>({value:t.id,label:t.id}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}})),oi=x.types.model("ContextMeta",{current:x.types.optional(x.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}}));function ul(e){return oi.create({current:e})}const dl=x.types.compose("ViewRenderModel",Kh,x.types.model({tab:x.types.optional(x.types.string,"")})).views(e=>({get tabs(){return e.config.tabs},get tabInfo(){const t=this.tabs.find(n=>n.id===e.tab);return t?{id:t.id,name:t.name}:null},get tabView(){return e.type!==q.Tabs?null:this.tabs.find(t=>t.id===e.tab)},get tabViewID(){return this.tabView?this.tabView.view_id??"":""},get contentModel(){return x.getParent(e,3)},get panels(){if(e.type!==q.Tabs)return this.contentModel.panels.panelsByIDs(e.panelIDs);const t=this.tabViewID,n=this.contentModel.views.findByID(t);return(n==null?void 0:n.panels)??[]},get renderViewIDs(){const t=[e.id];return e.type===q.Tabs&&t.push(this.tabViewID),t},async downloadScreenshot(t){const n=t.offsetWidth*2+10,s=t.offsetHeight*2+10,i=new fc,a=new Date().getTime(),l=await hc.toBlob(t,{bgcolor:"white",width:n,height:s,style:{transformOrigin:"0 0",transform:"scale(2)"}});i.file(`${e.name}_${a}.png`,l),i.file(`dashboard_state_${a}.json`,JSON.stringify(this.contentModel.dashboardState,null,4)),i.generateAsync({type:"blob"}).then(c=>{ns.saveAs(c,`${e.name}_${a}.zip`)}).catch(c=>{console.error(c),rn.notifications.show({color:"red",title:"Failed to download screenshot with dashboard state",message:c.message})})}})).actions(e=>({setTab(t){e.tab=t??""},setTabByTabInfo(t){e.tab=t.id??""}})),pl=x.types.model("ViewsRenderModel",{current:x.types.optional(x.types.array(dl),[]),visibleViewIDs:x.types.array(x.types.string)}).views(e=>({get json(){return e.current.map(t=>qn(t.json))},get idMap(){const t=new Map;return e.current.forEach(n=>{t.set(n.id,n)}),t},findByID(t){return e.current.find(n=>n.id===t)},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 firstVisibleTabsView(){return this.visibleViews.find(t=>t.type===q.Tabs)},get firstVisibleTabsViewActiveTab(){const t=this.firstVisibleTabsView;return t?t.tabInfo:null}})).actions(e=>({appendToVisibles(t){new Set(e.visibleViewIDs.map(s=>s)).has(t)||e.visibleViewIDs.push(t)},rmVisibleViewID(t){const n=e.visibleViewIDs.findIndex(s=>s===t);n!==-1&&e.visibleViewIDs.splice(n,1)},setFirstVisibleTabsViewActiveTab(t){if(!t)return;const n=e.firstVisibleTabsView;n==null||n.setTabByTabInfo(t)}}));function Zh(e,t){const n=e.length>0?[e[0].id]:[],s=e.map(i=>{const{_name:a=i.type}=i.config,l={...i,tab:"",config:{...i.config,_name:a},panelIDs:i.panelIDs};if(i.type===q.Tabs){const c=v.minBy(i.config.tabs,u=>u.order);l.tab=(c==null?void 0:c.id)??""}return l});return t&&(s[0].tab=t.id),{current:s,visibleViewIDs:n}}const BI=new Im.AsyncParser({withBOM:!0});async function Hh(e){return!Array.isArray(e)||e.length===0?"":await BI.parse(e).promise()}async function qI(e,t){const n=await Hh(t),s=new Blob([n],{type:"text/csv"});ns.saveAs(s,`${e}.csv`)}function ef(e){const t=new fc,n=e.map(async({id:s,data:i})=>{const a=await Hh(i);t.file(`${s}.csv`,a)});Promise.all(n).then(()=>{t.generateAsync({type:"blob"}).then(s=>{ns.saveAs(s,"dashboard_data.zip")})}).catch(s=>{console.error(s),rn.notifications.show({color:"red",title:"Failed to download data",message:s.message})})}function sr(e,t){const n=new Blob([t],{type:"application/json"});ns.saveAs(n,`${e}.json`)}const hl=Oh.views(e=>({get contentModel(){return x.getRoot(e).content}})).views(e=>({get queries(){return e.contentModel.queries.findByIDSet(e.queryIDSet)},get firstQuery(){return this.queries.length>0?this.queries[0]:null},get firstQueryData(){return this.firstQuery?this.firstQuery.data:[]},queryByID(t){return this.queries.find(n=>n.id===t)},get data(){return this.queries.reduce((t,n)=>(t[n.id]=n.data,t),{})},get variableStrings(){return jc(e.variables,this.data)},get variableValueMap(){const t={},n=this.data;return e.variables.reduce((s,i)=>{const a=jt(i,n);return s[i.name]=Re(i,a),s},t),t},get dataLoading(){return this.queries.some(t=>t.state==="loading")},get queryStateMessages(){const t=this.queries.filter(a=>!a.runByConditionsMet);if(t.length===0)return"";const n=new Set,s=new Set;t.forEach(a=>{const l=a.conditionNames;l.context.forEach(c=>n.add(c)),l.filters.forEach(c=>s.add(c))});const i=[];return n.size>0&&(console.log(n),i.push(`context: ${Array.from(n).join(", ")}`)),s.size>0&&i.push(`filter${s.size>1?"s":""}: ${Array.from(s).join(", ")}`),i.length===2&&i.splice(1,0,"and"),i.unshift("Waiting for"),i.join(" ")},get queryErrors(){return this.queries.map(t=>t.error).filter(t=>!!t)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages===""&&!this.dataLoading}})).actions(e=>({refreshData(){e.queries.forEach(t=>t.fetchData(!0))},downloadData(){e.contentModel.queries.downloadDataByQueryIDs(e.queryIDs)},getSchema(){const t=e.json;return t.viz.conf={...t.viz.conf,__INTERACTIONS:{},__OPERATIONS:{},__TRIGGERS:{}},{panel:t,queries:e.queries.map(n=>n.json),layouts:e.contentModel.layouts.jsonByPanelIDSet(new Set([e.id]))}},downloadSchema(){const{panel:t,queries:n,layouts:s}=this.getSchema(),a=JSON.stringify({panels:[t],definition:{queries:n},layouts:s,version:en},null,2),l=e.name;sr(l,a)}}));function tf(e){return{id:e,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:Po.name,conf:Po.createConfig()},style:{border:{enabled:!0}}}}const fl=x.types.model("PanelsRenderModel",{list:x.types.optional(x.types.array(hl),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},findByID(t){return e.list.find(n=>n.id===t)},get idMap(){const t=new Map;return e.list.forEach(n=>{t.set(n.id,n)}),t}})).views(e=>({panelsByIDs(t){const n=[];return t.forEach(s=>{const i=e.idMap.get(s);i?n.push(i):console.warn(`Panel is not found, id:${s}`)}),n}}));function nf(e){const t=e.config,n=t.default_value;if(n===void 0)return n;if(t._name==="date-range")try{if(t.default_shortcut){const i=Th(t.default_shortcut);if(i)return i.map(a=>P(a).format(t.inputFormat))}const[...s]=n;return s.map(i=>i===null?i:P.tz(i,"UTC").format(t.inputFormat)??i)}catch(s){return console.error(s),n}return n}function VI(e,t){const n=e.default_value_func;try{return new Function(`return ${n}`)()(e,vt,t)}catch(s){return console.error(s),nf(e)}}function rf(e,t){var n;return(n=e.default_value_func)!=null&&n.trim()?VI(e,t):nf(e)}function sf(e,t){return e.reduce((n,s)=>(n[s.key]=rf(s,t),n),{})}const ml=x.types.model("FiltersRenderModel",{current:x.types.optional(x.types.array(sl),[]),values:x.types.optional(x.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get valuesString(){return JSON.stringify(e.values)},get contentModel(){return x.getRoot(e).content},get context(){return this.contentModel.payloadForSQL.context},get initialValuesDep(){return JSON.stringify({filters:e.current.map(({default_value_func:t,config:n})=>({default_value_func:t,config:n})),context:this.contentModel.payloadForSQL.context})},get formattedDefaultValues(){return sf(this.json,this.contentModel.context)},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},findByIDSet(t){return e.current.filter(n=>t.has(n.id))},get inOrder(){return v.sortBy(e.current,"order")},get empty(){return e.current.length===0},visibleInView(t){return v.sortBy(e.current.filter(n=>n.visibleInViewsIDSet.has(t)),"order")},get firstFilterValueKey(){return Object.keys(e.values)[0]??""},get keySet(){return new Set(e.current.map(t=>t.key))},get keyLabelMap(){return e.current.reduce((t,n)=>(t[n.key]=n.label,t),{})},getSelectOption(t){const n=this.findByID(t);if(!n||!("getSelectOption"in n.config))return null;const s=e.values[n.key];return n.config.getSelectOption(s)}})).actions(e=>({setValues(t){e.values=t},patchValues(t){e.values=v.defaults({},t,e.values)},setValueByKey(t,n){e.values={...e.values,[t]:n}},applyValuesPatch(t){e.values={...e.values,...t}},getValueByKey(t){return e.values[t]},getSchema(t,n){return{filters:e.findByIDSet(new Set(t)).map(a=>({...a.json,visibleInViewsIDs:n?a.json.visibleInViewsIDs:[]})),version:en}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t,!1),null,2);sr("Filters",n)}}));function gl(e,t,n,s){const i=v.defaults({},s,sf(e,{...n,...t}));return{current:e,values:i}}const af=Lh.views(e=>({get rootModel(){return x.getRoot(e)},get contentModel(){return this.rootModel.content},get conditionOptions(){if(!x.isAlive(e))return[];const{context:t}=this.contentModel.payloadForSQL,n=Object.keys(t).map(l=>({group:"Context",label:l,value:`context.${l}`,description:void 0})),s=this.contentModel.filters.keyLabelOptions.map(l=>({group:"Filters",label:l.label,value:`filters.${l.value}`,description:l.value})),i=[...n,...s],a=new Set(i.map(l=>l.value));return e.run_by.forEach(l=>{a.has(l)||i.push({group:"Invalid",label:l,value:l})}),i},get unmetRunByConditions(){if(!x.isAlive(e))return[];const{run_by:t}=e;if(t.length===0)return[];const n=this.contentModel.payloadForSQL;return t.filter(s=>{const i=v.get(n,s);return Array.isArray(i)?i.length===0:typeof i=="number"?Number.isNaN(i):!i})}})).views(e=>({get payload(){return e.contentModel.payloadForSQL},get formattedSQL(){return Ci(e.sql,this.payload)},get httpConfigString(){const{context:t,filters:n}=this.payload,{name:s,pre_process:i}=e.json,a=Gg(i,t,n);return console.groupCollapsed(`Request config for: ${s}`),console.log(a),console.groupEnd(),JSON.stringify(a)},get typedAsSQL(){return[ye.Postgresql,ye.MySQL].includes(e.type)},get typedAsHTTP(){return[ye.HTTP].includes(e.type)},get isTransform(){return e.type===ye.Transform},get reQueryKey(){const{react_to:t=[]}=e;if(t.length===0)return"";const n=e.contentModel.payloadForSQL,s=[...t].reduce((i,a)=>(i[a]=v.get(n,a),i),{});return JSON.stringify(s)},get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=e.contentModel.filters,n=e.unmetRunByConditions.filter(i=>i.startsWith("context.")).map(i=>i.replace("context.","")),s=e.unmetRunByConditions.filter(i=>i.startsWith("filters.")).map(i=>v.get({filters:t},i,i.replace("filters.",""))).filter(i=>!!i);return{context:n,filters:s}},get queries(){return x.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)},get dependencies(){if(!this.typedAsSQL)return[];const t=v.uniq(e.sql.match(as.sqlSnippet)),n=v.uniq(e.sql.match(as.filter)),s=v.uniq(e.sql.match(as.context)),i=[];return t.forEach(a=>{i.push({type:"sql_snippet",key:a,valid:e.contentModel.sqlSnippets.keySet.has(a)})}),n.forEach(a=>{i.push({type:"filter",key:a,valid:e.contentModel.filters.keySet.has(a)})}),s.forEach(a=>{i.push({type:"context",key:a,valid:e.contentModel.mock_context.keySet.has(a)})}),i}})),xl=x.types.compose("QueryRenderModel",af,x.types.model({state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),data:x.types.optional(x.types.frozen([]),[]),error:x.types.frozen()})).views(e=>({get datasource(){const{key:t,type:n}=e;return e.rootModel.datasources.find({type:n,key:t})},get additionalQueryInfo(){return e.contentModel.getAdditionalQueryInfo(e.id)},get depQueryModels(){return e.contentModel.queries.findByIDSet(new Set(e.dep_query_ids))},get depQueryModelStates(){return this.depQueryModels.map(t=>t.state)},get depQueryModelStatesString(){return this.depQueryModelStates.toString()}})).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 s=[];return t.length>0&&s.push(`context: ${t.join(", ")}`),n.length>0&&s.push(`filter${n.length>1?"s":""}: ${n.join(", ")}`),s.length===2&&s.splice(1,0,"and"),s.unshift("Waiting for"),s.join(" ")}return e.data.length>0?"":"Empty Data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:x.flow(function*(){var t;if(e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const n=e.payload;e.data=yield*x.toGenerator(Yg({payload:n,name:e.name,query:e.json,additionals:e.additionalQueryInfo},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(!At.isCancel(n)){e.data=[];const s=v.get(n,"message","unkown error");e.error=v.get(n,"response.data.detail.message",s),e.state="error"}}}}),runHTTP:x.flow(function*(){var t;if(!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{type:n,key:s,post_process:i}=e.json;let a=JSON.parse(e.httpConfigString);a=Wg(e.datasource,a);const l=yield*x.toGenerator(Kg({type:n,key:s,configString:JSON.stringify(a),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=Rg(e.datasource,l),u=Qg(i,c,e.contentModel.dashboardState);e.data=u,e.state="idle",e.error=null}catch(n){if(console.error(n),!At.isCancel(n)){e.data=[];const s=v.get(n,"message","unkown error");e.error=v.get(n,"response.data.detail.message",s),e.state="error"}}}}),runTransformation(){e.state="loading";try{const n=e.contentModel.queries.findByIDSet(new Set(e.dep_query_ids)).map(l=>({id:l.id,name:l.name,data:v.cloneDeep(l.data)})),s=e.contentModel.dashboardState,i=e.pre_process,a=new Function(`return ${i}`)()(n,s,vt);e.data=a,e.state="idle",e.error=null}catch(t){e.data=[],e.error=t.message,e.state="error"}}})).actions(e=>({fetchData:t=>{if(!e.inUse&&!t){console.debug(`🟡 Skipping query[${e.name}]`);return}return console.debug(`🔵 Running query[${e.name}]`),e.isTransform?e.runTransformation():e.typedAsHTTP?e.runHTTP():e.runSQL()},beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>{var n;return e.isTransform?[e.inUse,e.id,e.key,e.dep_query_ids.toString(),e.pre_process,e.depQueryModelStatesString].join("--"):e.typedAsHTTP?`${e.inUse}--${e.id}--${e.key}--${e.reQueryKey}--${(n=e.datasource)==null?void 0:n.id}`:[e.inUse,e.id,e.key,e.formattedSQL,e.pre_process,e.post_process].join("--")},()=>e.fetchData(!1),{fireImmediately:!0,delay:0}))}})),yl=x.types.model("QueriesRenderModel",{current:x.types.optional(x.types.array(xl),[])}).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},findByIDSet(t){return e.current.filter(n=>t.has(n.id))},get json(){return e.current.filter(t=>t.id&&t.key).map(t=>t.json)},get contentModel(){return x.getParent(e,1)},get visibleQueryIDSet(){const{views:t,filters:n,queries:s}=this.contentModel,i=[];t.visibleViews.forEach(c=>{c.panels.forEach(u=>{i.push(...u.queryIDs)})});const a=v.uniq(t.visibleViews.map(c=>c.renderViewIDs).flat());n.current.forEach(c=>{const u=v.get(c,"config.options_query_id");if(!u)return;a.some(p=>c.visibleInViewsIDSet.has(p))&&i.push(u)}),s.findByIDSet(new Set(i)).forEach(c=>{!c.isTransform||c.dep_query_ids.length===0||i.push(...c.dep_query_ids)});const l=new Set(i);return console.debug("QueryIDs:",l),l},isQueryInUse(t){return this.visibleQueryIDSet.has(t)}})).actions(e=>({downloadAllData(){const t=e.current.map(({name:n,data:s})=>({id:n,data:s}));ef(t)},downloadDataByQueryIDs(t){const n=new Set(t),s=e.current.filter(i=>n.has(i.id)).map(({name:i,data:a})=>({id:i,data:a}));ef(s)},downloadDataByQueryID(t){const n=e.findByID(t);if(!n){console.log("[downloadDataByQueryID] query not found");return}const{name:s,data:i}=n;qI(s,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(!0)},getSchema(t){return{definition:{queries:e.findByIDSet(new Set(t)).map(i=>i.json)},version:en}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t),null,2);sr("Queries",n)}}));function of(e){return{current:e}}function lf({min:e,max:t}){const n=`${e}px`,s=Number.isFinite(t)?`${t}px`:"∞";return`[${n}, ${s})`}const bl=x.types.model("LayoutsRenderModel",{list:x.types.array(qh),currentBreakpoint:x.types.string}).views(e=>({get json(){return e.list.map(t=>t.json)},jsonByPanelIDSet(t){return e.list.map(n=>n.jsonByPanelIDSet(t))},get root(){return x.getRoot(e)},get contentModel(){return this.root.content},get basisLayoutSet(){return e.list.find(t=>t.id==="basis")},get currentLayoutSet(){return e.list.find(t=>t.id===e.currentBreakpoint)},get currentLayoutRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentRangeText(){const t=this.currentLayoutRange;return lf(t)},get cols(){const t={};return e.list.forEach(n=>{t[n.id]=36}),t},get breakpoints(){const t={};return e.list.forEach(n=>{t[n.id]=n.breakpoint}),t},get breakpointNameRecord(){const t={};return e.list.forEach(n=>{t[n.name]=n.breakpoint}),t},get breakpointRanges(){const t=e.list.map(n=>({id:n.id,name:n.name,min:n.breakpoint,max:1/0,text:""}));return t.sort((n,s)=>n.min-s.min).forEach((n,s)=>{s!==t.length-1&&(n.max=t[s+1].min)}),t.forEach(n=>{n.text=lf(n)}),t},get breakpointsInfo(){return e.list.map(t=>({id:t.id,name:t.name,breakpoint:t.breakpoint})).sort((t,n)=>t.breakpoint-n.breakpoint)},get currentBreakpointRange(){return this.breakpointRanges.find(t=>t.id===e.currentBreakpoint)},get currentLayoutPreviewWidth(){const t=this.currentBreakpointRange;if(t)return t.max===1/0?t.min===0?void 0:t.min+1:t.max},items(t){const n=new Set(t);return this.currentLayoutSet.list.filter(i=>n.has(i.panelID))},gridLayouts(t){const n=new Set(t),s={};return e.list.forEach(i=>{s[i.id]=i.list.filter(a=>n.has(a.panelID)).map(a=>a.layoutProperies)}),s},findItemByPanelID(t){return this.currentLayoutSet.findByPanelID(t)}})).actions(e=>({setCurrentBreakpoint(t){console.log("🔴 onBreakpointChange:",t),e.currentBreakpoint=t},afterCreate(){x.addDisposer(e,X.reaction(()=>e.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),cf=Vh.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!x.getParent(e,2).findByKey(t)}})),vl=x.types.model("SQLSnippetsRenderModel",{current:x.types.optional(x.types.array(cf),[])}).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 keySet(){return new Set(e.current.map(t=>t.key))},get firstKey(){if(e.current.length!==0)return e.current[0].key},findByKey(t){return e.current.find(n=>n.key===t)},findByKeySet(t){return e.current.filter(n=>t.has(n.key))}})).actions(e=>({getSchema(t){return{definition:{sqlSnippets:e.findByKeySet(new Set(t)).map(i=>i.json)},version:en}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t),null,2);sr("SQL Snippets",n)}}));function uf(e){return{current:e}}function Qr(e,t,n,s){return e.reduce((i,a)=>{try{i[a[t]]=wi(a[n],s)}catch(l){i[a[t]]=l.message}return i},{})}class df{constructor(t){B(this,"origin");B(this,"copy");this.origin=t,this.copy=x.clone(t),X.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!v.isEqual(x.getSnapshot(this.origin),x.getSnapshot(this.copy))}commit(){x.applySnapshot(this.origin,x.getSnapshot(this.copy))}reset(){x.applySnapshot(this.copy,x.getSnapshot(this.origin))}update(t){x.applySnapshot(this.copy,t)}}const pf=e=>new df(e),NI=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),{panel:n}=Ge(),s=n.realQueryOptions,i=a=>{t.editor.open(["_QUERIES_",a])};return s.length===0?null:r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{label:e(s.length>1?"query.labels":"query.label"),labelPosition:"center"}),s.map(a=>r.jsx(o.Menu.Item,{onClick:()=>i(a.value),icon:r.jsx(M.IconDatabase,{size:14}),children:a.label},a.value))]})}),$I=D.observer(({view:e,title:t})=>{const{t:n}=_.useTranslation(),s=Z(),i=Y(),a=lt.useModals(),{panel:l,downloadPanelScreenshot:c}=Ge(),{id:u}=l,{viewPanelInFullScreen:d,inFullScreen:p}=m.useContext(ii),h=()=>{i.duplicatePanelByID(u,e.id)},f=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u])},g=()=>a.openConfirmModal({title:`${n("panel.delete")}?`,labels:{confirm:n("common.actions.confirm"),cancel:n("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.removePanelByID(u,e.id),confirmProps:{color:"red"},zIndex:320}),y=m.useCallback(()=>{d(u)},[u,d]),j=!p&&e.type!==q.Modal;return r.jsx(r.Fragment,{children:r.jsx(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:r.jsxs(o.Menu,{withinPortal:!0,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{onClick:l.refreshData,icon:r.jsx(V.Refresh,{size:14}),children:n("common.actions.refresh")}),r.jsx(o.Menu.Item,{onClick:l.downloadData,icon:r.jsx(V.Download,{size:14}),children:n("common.actions.download_data")}),r.jsx(o.Menu.Item,{onClick:l.downloadSchema,icon:r.jsx(M.IconCode,{size:14}),children:n("common.actions.download_schema")}),r.jsx(o.Menu.Item,{onClick:c,icon:r.jsx(M.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),j&&r.jsx(o.Menu.Item,{onClick:y,icon:r.jsx(V.ArrowsMaximize,{size:14}),disabled:!0,children:n("common.actions.enter_fullscreen")}),r.jsx(NI,{}),r.jsx(o.Divider,{label:n("common.actions.edit"),labelPosition:"center"}),r.jsx(o.Menu.Item,{onClick:f,icon:r.jsx(V.Settings,{size:14}),children:n("common.titles.settings")}),r.jsx(o.Menu.Item,{onClick:h,icon:r.jsx(V.Copy,{size:14}),children:n("common.actions.duplicate")}),r.jsx(o.Menu.Item,{color:"red",onClick:g,icon:r.jsx(V.Trash,{size:14}),children:n("common.actions.delete")})]})]})})})});function FI(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const _l=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=m.useState(!1),{panel:s}=Lt();return FI(s.description)?null:r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:()=>n(!1),title:s.title.show?s.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:r.jsx(Ys,{value:s.description,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}}})}),r.jsx(o.Tooltip,{label:e("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:r.jsx(V.InfoCircle,{size:20})})})]})}),IL="",GI=D.observer(function(){const{panel:t}=Lt(),{name:n,title:s}=t;return s.show?r.jsx(o.Group,{grow:!0,position:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:r.jsx(o.Text,{align:"center",lineClamp:1,className:"panel-title-text",children:n})}):null});function WI(e){const t=m.useRef(null);return{ref:t,downloadPanelScreenshot:()=>{const s=t.current;if(!s)return;const i=s.offsetWidth*2,a=s.offsetHeight*2;hc.toBlob(t.current,{bgcolor:"white",width:i,height:a,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(l=>{window.saveAs(l,`${e.name?e.name:e.viz.type}.png`)})}}}var hf=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(hf||{}),li=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(li||{});class RI{constructor(t){B(this,"vizInstance");B(this,"operationManager");B(this,"triggerManager");B(this,"vizManager");B(this,"runningMigration");B(this,"panelModel");B(this,"status","notStarted");this.panelModel=t.getRequired(je.instanceScope.panelModel),this.vizInstance=t.getRequired(je.instanceScope.vizInstance),this.operationManager=t.getRequired(je.instanceScope.operationManager),this.triggerManager=t.getRequired(je.instanceScope.triggerManager),this.vizManager=t.getRequired(je.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 ff(e){const{panel:t}=Lt();return m.useCallback(n=>{const s=n.getRequired(je.vizManager),i=s.resolveComponent(e.viz.type);return n.createScoped().provideFactory(je.instanceScope.vizInstance,()=>s.getOrCreateInstance(e)).provideFactory(je.instanceScope.interactionManager,a=>{const l=a.getRequired(je.instanceScope.vizInstance);return new Fi(l,i,us)}).provideFactory(je.instanceScope.operationManager,a=>a.getRequired(je.instanceScope.interactionManager).operationManager).provideFactory(je.instanceScope.triggerManager,a=>a.getRequired(je.instanceScope.interactionManager).triggerManager).provideValue(je.instanceScope.panelModel,t).provideFactory(je.instanceScope.migrator,a=>new RI(a))},[e.viz.type,e.viz.conf])}function mf(e){const[t,n]=m.useState(!1),s=kh().getRequired(je.instanceScope.migrator);return W.useAsyncEffect(async()=>{const i=s.status===li.notStarted;n(s.status===li.done),s.status===li.notStarted&&s.runMigration().then(a=>{a===hf.migrated&&i&&(e==null||e())}).finally(()=>{n(!0)})},[s]),t}function gf(e,t){const n=kh().getRequired(je.instanceScope.vizInstance);return m.useEffect(()=>(n.instanceData.setItem(null,t.viz.conf),n.instanceData.watchItem(null,s=>{e(s)})),[e,t.viz.type]),n}function QI({setVizConf:e,...t}){const{panel:n}=t,s=gf(e,n),i=mf(()=>{rn.showNotification({title:`${n.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return W.useAsyncEffect(async()=>{await s.instanceData.setItem(null,n.viz.conf)},[s,n.viz.type]),i?r.jsx(Hg,{...t}):r.jsx(o.Text,{children:"Checking update..."})}function UI(e){const{panel:t,setVizConf:n}=e;gf(n,t);const{inEditMode:s}=m.useContext(ls);return mf(()=>{s&&rn.showNotification({title:`${t.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?r.jsx(Zg,{...e}):r.jsx(o.Text,{children:"Checking update"})}const EL="";function YI(e,t){const{vizManager:n}=m.useContext(Gt),{panel:{viz:s,title:i,id:a,name:l,description:c,queryIDs:u,variables:d}}=Lt(),p={id:a,name:l,title:i,description:c,queryIDs:u,viz:s},h=ff(p);try{return n.resolveComponent(s.type),r.jsx(si,{configure:h,children:r.jsx(UI,{setVizConf:s.setConf,panel:p,measure:t,data:e,variables:d,vizManager:n})})}catch(f){return console.info(v.get(f,"message")),null}}const xf=D.observer(function({data:t}){const{ref:n,width:s,height:i}=he.useElementSize(),a=YI(t,{w:s,h:i}),l=s>0&&i>0;return r.jsx("div",{className:"viz-root",ref:n,children:r.jsx(o.Box,{sx:{width:s,height:i,overflow:"hidden"},children:l&&r.jsx(ze,{children:a})})})}),yf=D.observer(({panel:e})=>r.jsxs(o.Stack,{children:[e.queryErrors.map((t,n)=>r.jsx(o.Text,{color:"red",size:"sm",align:"center",sx:{fontFamily:"monospace"},children:t},`${n}-${t}`)),r.jsx(o.Text,{color:"gray",align:"center",size:"sm",children:e.queryStateMessages})]})),jl=D.observer(({panel:e})=>r.jsxs(o.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[r.jsx(o.LoadingOverlay,{visible:e.dataLoading,exitTransitionDuration:0}),!e.canRenderViz&&r.jsx(yf,{panel:e}),e.canRenderViz&&r.jsx(xf,{data:e.data})]})),KI={border:"1px solid #e9ecef"},bf=D.observer(({panel:e,panelStyle:t,dropdownContent:n})=>{const{ref:s,downloadPanelScreenshot:i}=WI(e);return e.title.show,r.jsx(Bi,{value:{panel:e,data:e.data,loading:e.dataLoading,errors:e.queryErrors,downloadPanelScreenshot:i},children:r.jsxs(o.Box,{className:`panel-root ${e.title.show?"panel-root--show-title":""}`,ref:s,p:0,sx:{...KI,...t},children:[r.jsx(o.Box,{className:"panel-description-popover-wrapper",children:r.jsx(_l,{})}),n,r.jsx(GI,{}),r.jsx(jl,{panel:e})]})})}),XI={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function JI(e){return e.style.border.enabled?{}:XI}const vf=D.observer(function({panel:t,view:n}){const s=JI(t);return r.jsx(bf,{panel:t,panelStyle:s,dropdownContent:r.jsx($I,{view:n,title:t.name})})});function ZI(e){return!["richText","button"].includes(e)}const HI=D.observer(({view:e,title:t})=>{const{t:n}=_.useTranslation(),{panel:s,downloadPanelScreenshot:i}=Lt(),{id:a}=s,{viewPanelInFullScreen:l,inFullScreen:c}=m.useContext(ii),u=m.useCallback(()=>{l(a)},[a,l]),d=!c&&e.type!==q.Modal;return ZI(s.viz.type)?r.jsx(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:t,children:r.jsxs(o.Menu,{withinPortal:!0,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Box,{className:"panel-dropdown-target"})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{onClick:s.refreshData,icon:r.jsx(V.Refresh,{size:14}),children:n("common.actions.refresh")}),r.jsx(o.Menu.Item,{onClick:s.downloadData,icon:r.jsx(V.Download,{size:14}),children:n("common.actions.download_data")}),r.jsx(o.Menu.Item,{onClick:i,icon:r.jsx(M.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),d&&r.jsx(o.Menu.Item,{onClick:u,icon:r.jsx(V.ArrowsMaximize,{size:14}),children:n("common.actions.enter_fullscreen")})]})]})}):null});function eE(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const wl=D.observer(({panel:e,view:t})=>{const n=eE(e);return r.jsx(bf,{panel:e,panelStyle:n,dropdownContent:r.jsx(HI,{title:e.name,view:t})})}),tE={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},_f=D.observer(function({view:t,panel:n,exitFullScreen:s}){return r.jsx(o.Modal,{opened:!0,fullScreen:!0,onClose:s,title:r.jsx(o.Button,{color:"blue",size:"xs",onClick:s,leftIcon:r.jsx(V.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:tE,children:r.jsx(o.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:r.jsx(wl,{view:t,panel:n})})})});function jf(e,t,n){const{panels:s}=_e(),i=e.id==="Main",[a,l]=m.useState(()=>i&&s.findByID(t)?t:null),c=m.useCallback(h=>{l(h),i&&n(h)},[i,n]),u=m.useCallback(()=>{l(null),i&&n("")},[i,n]),d=a?s.findByID(a):null;return{viewPanelInFullScreen:c,exitFullScreen:u,inFullScreen:!!d,fullScreenPanel:d}}const AL="",nE=m.forwardRef(({h:e},t)=>r.jsx(o.ActionIcon,{ref:t,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:5,right:e>38?5:20,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:r.jsx(V.ArrowsMove,{size:16})})),rE=m.forwardRef(({handleAxis:e,...t},n)=>r.jsx(o.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:r.jsx(V.ChevronDownRight,{size:16})})),sE=ts.WidthProvider(ts.Responsive),iE=D.observer(({view:e,className:t="layout"})=>{const s=Y().layouts,i=s.items(e.panelIDs),a=s.gridLayouts(e.panelIDs),l=(d,p,h,f)=>{console.log("🔴 onResize",d),h.h<30&&(h.h=30,f.h=30),h.w<4&&(h.w=4,f.w=4)},c=(d,p,h)=>{console.log("🔴 onResizeStop",{layouts:d,oldItem:p,newItem:h}),s.updateCurrentLayoutItem(h)},u=(d,p,h)=>{console.log("🔴 onDragStop",{layouts:d,oldItem:p,newItem:h}),s.updateCurrentLayoutItems(d)};return r.jsx(sE,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:s.cols,layouts:a,draggableHandle:".react-grid-customDragHandle",resizeHandle:r.jsx(rE,{}),onResize:l,breakpoints:s.breakpoints,onBreakpointChange:s.setCurrentBreakpoint,onResizeStop:c,onDragStop:u,width:s.currentLayoutPreviewWidth,children:i.map(d=>r.jsxs("div",{"data-grid":d.layoutProperies,className:"panel-grid-item",children:[r.jsx(nE,{h:d.h}),r.jsx(vf,{view:e,panel:d.panel})]},d.id))})}),aE=ts.WidthProvider(ts.Responsive),oE=D.observer(({view:e,className:t="layout"})=>{const n=_e(),s=n.layouts.items(e.panelIDs),i=n.layouts.gridLayouts(e.panelIDs);return r.jsx(aE,{className:`dashboard-layout ${t}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:n.layouts.cols,layouts:i,breakpoints:n.layouts.breakpoints,onBreakpointChange:n.layouts.setCurrentBreakpoint,children:s.map(a=>r.jsx("div",{"data-grid":a.layoutProperies,className:"panel-grid-item",children:r.jsx(wl,{view:e,panel:a.panel})},a.id))})});function Cl(e){const t=m.useRef(null);return{ref:t,downloadScreenshot:()=>{var i;const s=(i=t.current)==null?void 0:i.querySelector(".react-grid-layout");s&&e.downloadScreenshot(s)}}}const lE=D.observer(({downloadScreenshot:e})=>{const{t}=_.useTranslation(),[n,{setTrue:s,setFalse:i}]=W.useBoolean(!1),a=Ic(),l=_e(),c=()=>{const u=JSON.stringify(l.contentJSON,null,2),d=`${a.name}__${l.name}`;sr(d,u)};return r.jsxs(o.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:r.jsx(o.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:s,onMouseLeave:i,sx:{opacity:n?1:.6,transform:`translateX(${n?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:r.jsx(M.IconShare3,{size:"1rem"})})})}),r.jsxs(o.Menu.Dropdown,{children:[r.jsx(o.Menu.Item,{icon:r.jsx(M.IconCamera,{size:14}),onClick:e,children:t("common.actions.download_screenshot")}),r.jsx(o.Menu.Divider,{}),r.jsx(o.Menu.Item,{icon:r.jsx(M.IconDownload,{size:14}),onClick:l.queries.downloadAllData,children:t("common.actions.download_data")}),r.jsx(o.Menu.Item,{icon:r.jsx(M.IconCode,{size:14}),onClick:c,children:t("common.actions.download_schema")})]})]})}),wf=D.observer(({children:e,view:t,sx:n={}})=>{const{ref:s,downloadScreenshot:i}=Cl(t);return r.jsxs(r.Fragment,{children:[r.jsx(o.Box,{ref:s,pt:10,pb:10,sx:n,children:e}),r.jsx(lE,{downloadScreenshot:i})]})}),Cf=D.observer(({downloadScreenshot:e})=>r.jsx(o.ActionIcon,{className:"download-screenshot-button",color:"blue",onClick:e,children:r.jsx(M.IconCamera,{size:14})})),cE=D.observer(({children:e,view:t})=>{const n=_e(),s=t.config,i=n.views.visibleViewIDs.includes(t.id),a=()=>n.views.rmVisibleViewID(t.id),{ref:l,downloadScreenshot:c}=Cl(t);return r.jsx(o.Modal,{size:s.width,centered:!0,opened:i,onClose:a,withCloseButton:!1,title:r.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[r.jsx(o.Box,{children:s.custom_modal_title.value}),r.jsx(Cf,{downloadScreenshot:c})]}),trapFocus:!0,onDragStart:u=>{u.stopPropagation()},styles:{root:{position:"fixed",zIndex:200,inset:0},overlay:{zIndex:"unset"},inner:{zIndex:"unset",padding:"0 !important"},content:{border:"1px solid #efefef",maxHeight:"unset !important",overflow:"hidden"},body:{maxHeight:s.height,overflow:"auto",position:"relative",paddingBottom:10},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:r.jsx(o.Box,{ref:l,children:e})})}),uE=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},dE=D.observer(({view:e})=>{const t=_e(),n=e.config;return r.jsxs(o.Tabs,{className:"render-view-tabs",variant:n.variant,orientation:n.orientation,value:e.tab,onTabChange:e.setTab,styles:{root:{height:"100%",overflow:n.orientation==="horizontal"?"hidden":"auto"},panel:{padding:n.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[r.jsx(o.Tabs.List,{grow:n.grow,children:n.tabsInOrder.map(s=>r.jsx(o.Tabs.Tab,{value:s.id,sx:uE(s),disabled:!s.view_id,children:s.name??s.id},s.id))}),n.tabsInOrder.map(s=>{const i=t.views.findByID(s.view_id);return i?r.jsx(o.Tabs.Panel,{value:s.id,children:r.jsx(ci,{view:i})},s.id):null})]})}),pE=D.observer(({view:e,children:t})=>{switch(e.type){case q.Modal:return r.jsx(cE,{view:e,children:t});case q.Tabs:return r.jsx(dE,{view:e});case q.Division:default:return r.jsx(wf,{view:e,children:t})}}),hE=D.observer(({children:e,view:t})=>{const s=Y().layouts,[i,a]=he.useResizeObserver();return m.useEffect(()=>{s.setCurrentLayoutWrapperWidth(a.width)},[a.width]),r.jsx(o.Box,{sx:{height:"100%"},ref:i,children:r.jsx(o.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:s.currentLayoutPreviewWidth??"100%",transform:`scale(${s.divisionPreviewScale})`,transformOrigin:"0 0"},children:r.jsx(wf,{view:t,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:e})})})});function Sf(e){return e.replace(/(vw|vh)/,"%")}const fE=D.observer(({children:e,view:t})=>{const n=t.config,{width:s,height:i}=m.useMemo(()=>({width:Sf(n.width),height:Sf(n.height)}),[n.width,n.height]),{ref:a,downloadScreenshot:l}=Cl(t);return r.jsx(o.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:r.jsx(o.Modal,{size:n.width,opened:!0,onClose:v.noop,withCloseButton:!1,title:r.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[r.jsx(o.Box,{children:n.custom_modal_title.value}),r.jsx(Cf,{downloadScreenshot:l})]}),trapFocus:!0,onDragStart:c=>{c.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},inner:{position:"relative",top:"50%",left:"50%",right:"unset",bottom:"unset",transform:"translate(-50%, -50%)",padding:"0 !important",width:s,height:i,maxHeight:i},content:{border:"1px solid #efefef",height:"100%"},body:{maxHeight:"calc(100% - 48px)",overflow:"auto"},header:{padding:0},title:{flexGrow:1}},withinPortal:!1,transitionProps:{duration:0},children:r.jsx(o.Box,{ref:a,children:e})})})}),mE=({variant:e,orientation:t})=>{const n={root:{height:"100%",overflow:"hidden"},tabsList:{backgroundColor:"white"},tab:{},panel:{padding:"16px"}};return e==="pills"&&t==="horizontal"&&(n.tab.paddingTop="6px",n.tab.paddingBottom="6px"),t==="vertical"&&(n.tab["&.add-a-tab"]={paddingTop:"1px",paddingBottom:"1px"},n.tab["&.add-a-tab .mantine-Tabs-tabLabel"]={marginLeft:"auto",marginRight:"auto"}),n},gE=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},xE=D.observer(({view:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Y(),i=m.useMemo(()=>s.views.options.filter(u=>u.type===q.Division),[e.id,s.views.options]),a=e.config,l=u=>n.openConfirmModal({title:`${t("view.component.tabs.tab.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{a.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),c=a.tabs.length===0;return r.jsxs(o.Tabs,{className:"preview-view-tabs",variant:a.variant,orientation:a.orientation,value:e.tab,onTabChange:e.setTab,styles:mE(a),children:[r.jsxs(o.Tabs.List,{grow:a.grow,children:[a.tabsInOrder.map(u=>r.jsx(o.Tabs.Tab,{value:u.id,sx:gE(u),children:u.name??u.id},u.id)),r.jsx(o.Tabs.Tab,{onClick:a.addTab,value:"add",className:"add-a-tab",children:r.jsx(V.Plus,{size:18,color:"#228be6"})})]}),a.tabsInOrder.map((u,d)=>{const p=s.views.findByID(u.view_id);return r.jsxs(o.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[r.jsxs(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[r.jsx(o.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),r.jsxs(o.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[r.jsx(o.TextInput,{label:t("view.component.tabs.tab.name"),required:!0,value:u.name,onChange:h=>u.setName(h.currentTarget.value)}),r.jsx(o.Select,{label:"View",value:u.view_id,onChange:u.setViewID,data:i}),r.jsx(o.NumberInput,{label:t("view.component.tabs.tab.order"),required:!0,value:u.order,onChange:h=>u.setOrder(h||0),min:0,max:1e3,step:1}),r.jsx(o.ColorInput,{label:t("view.component.tabs.tab.color"),value:u.color,onChange:u.setColor,disabled:a.variant!=="default"}),p&&r.jsx(o.Button,{mt:20,variant:"gradient",leftIcon:r.jsx(M.IconArrowsLeftRight,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>s.views.setIDOfVIE(p.id),children:t("view.component.tabs.tab.switch_to_view",{name:p.name})}),r.jsx(o.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>l(d),disabled:c,leftIcon:r.jsx(M.IconTrash,{size:14}),children:t("view.component.tabs.tab.delete")})]})]}),p&&r.jsx(ci,{view:p})]},u.id)})]})}),yE=D.observer(({view:e,children:t})=>{switch(e.type){case q.Modal:return r.jsx(fE,{view:e,children:t});case q.Tabs:return r.jsx(xE,{view:e});case q.Division:default:return r.jsx(hE,{view:e,children:t})}}),kf=D.observer(function({view:t}){const s=Y().layouts.divisionPreviewScale!==1;return r.jsx(ii.Provider,{value:{viewPanelInFullScreen:v.noop,inFullScreen:!1},children:r.jsx(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:s?"transparent":"#efefef"},children:r.jsx(yE,{view:t,children:r.jsxs(o.Box,{sx:{position:"relative"},children:[r.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:r.jsx(zh,{view:t})}),r.jsx(iE,{view:t})]})})})})}),ci=D.observer(function({view:t}){const{fullScreenPanelID:n,setFullScreenPanelID:s}=qc(),{viewPanelInFullScreen:i,exitFullScreen:a,inFullScreen:l,fullScreenPanel:c}=jf(t,n,s);return r.jsx(ii.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:l},children:r.jsxs(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:t.type===q.Modal?"0 !important":"100%"},children:[l&&r.jsx(_f,{view:t,panel:c,exitFullScreen:a}),r.jsx(pE,{view:t,children:r.jsxs(o.Box,{sx:{position:"relative"},children:[!l&&r.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:r.jsx(zh,{view:t})}),!l&&r.jsx(oE,{view:t})]})})]})})});var Tf=(e=>(e.Use="use",e.Edit="edit",e))(Tf||{});const bE={[q.Division]:"Division",[q.Tabs]:"Tabs",[q.Modal]:"Modal"},Df={[q.Division]:"rgba(255, 0, 0, 0.2)",[q.Modal]:"rgba(0, 0, 0, 0.2)",[q.Tabs]:"rgba(255, 200, 100, 0.4)"},vE={[q.Division]:"#ff4000",[q.Modal]:"#000",[q.Tabs]:"#ffad18"};function _E(e,t,n){x.addDisposer(e,x.addMiddleware(e,(s,i)=>{i(s,()=>{x.getType(s.context)===t&&s.type==="action"&&n(s.name,s.context)})}))}const Mf=x.types.compose("FiltersModel",ml,x.types.model("FiltersModel",{previewValues:x.types.optional(x.types.frozen(),{})})).views(e=>({get idSet(){return new Set(e.current.map(t=>t.id))},get keySet(){return new Set(e.current.map(t=>t.key))},get options(){return e.current.map(t=>({label:t.label??t.id,value:t.id,_type:"filter"}))},get selects(){return e.current.filter(t=>t.type===ce.Select).map(t=>({label:t.label??t.id,value:t.id}))},get keyLabelOptions(){return e.current.map(t=>({label:t.label??t.key,value:t.key}))},get sortedList(){return v.sortBy(e.current,t=>t.label.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.idSet.has(s.id));e.current.push(...n)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(s=>s.id===t);n>=0&&e.current.splice(n,1)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){_E(e.current,sl,(n,s)=>{if(n==="setType"){const i=rf(s.config.default_value,s.config);e.setValueByKey(s.key,i),e.updatePreviewValues({...e.previewValues,[s.key]:i})}})}return{afterCreate(){t()}}}),zf=xl.views(e=>({get canPreviewData(){return e.isTransform?e.dep_query_ids.length>0&&!!e.pre_process:!!e.datasource},get guideToPreviewData(){return e.isTransform?"Need to complete settings in Transform tab":"Need to pick a Data Source first"}})),If=x.types.compose("QueriesModel",yl,x.types.model({current:x.types.optional(x.types.array(zf),[])})).views(e=>({get options(){const t=e.current.map(n=>({value:n.id,label:n.name,_type:"query"}));return v.sortBy(t,n=>n.label.toLowerCase())},get optionsWithoutTransform(){const t=e.current.filter(n=>n.type!==ye.Transform).map(n=>({value:n.id,label:n.name,_type:"query"}));return v.sortBy(t,n=>n.label.toLowerCase())},get sortedList(){return v.sortBy(e.current,t=>t.name.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.idSet.has(s.id));e.current.push(...n)},remove(t){e.current.splice(t,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},removeQuery(t){const n=e.current.find(s=>s.id===t);n&&(x.detach(n),e.current.remove(n))},removeQueries(t){const n=new Set(t);e.current.forEach(i=>{n.has(i.id)&&x.detach(i)});const s=[...e.current];v.remove(s,i=>n.has(i.id)),e.current=x.cast(s)}})),Ef=vl.views(e=>({get sortedList(){return v.sortBy(e.current,t=>t.key.toLowerCase())},get options(){const t=e.current.map(n=>({label:n.key,value:n.key,_type:"sql_snippet"}));return v.sortBy(t,n=>n.label.toLowerCase())}})).actions(e=>({replace(t){e.current=x.cast(t)},append(t){e.current.push(t)},appendMultiple(t){if(t.length===0)return;const n=t.filter(s=>!e.keySet.has(s.key));e.current.push(...n)},remove(t){e.current.splice(t,1)},removeByKey(t){const n=e.current.findIndex(s=>s.key===t);n>=0&&e.current.splice(n,1)},removeByKeys(t){const n=new Set(t);e.current.forEach(i=>{n.has(i.key)&&x.detach(i)});const s=[...e.current];v.remove(s,i=>n.has(i.key)),e.current=x.cast(s)},replaceByIndex(t,n){e.current.splice(t,1,n)}})),jE=x.types.model({data:x.types.optional(x.types.frozen(),[]),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),wE=x.types.model({data:x.types.optional(x.types.frozen(),[]),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),CE=x.types.model({page:x.types.optional(x.types.number,1),limit:x.types.optional(x.types.number,20),data:x.types.optional(x.types.frozen(),[]),total:x.types.optional(x.types.number,0),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get keywords(){return x.getParent(e,1)},get keywordString(){const{table_name:t,table_schema:n}=x.getParent(e,1);return`${n}||${t}`}})).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0},get maxPage(){return Math.ceil(e.total/e.limit)},get offset(){return(e.page-1)*e.limit},get countSql(){const{table_name:t,table_schema:n}=e.keywords;return`
446
448
  SELECT count(*) AS total
447
- FROM ${n}.${e}
448
- `}})).actions(t=>({setPage(e){t.page=e},resetPage(){t.page=1},setLimit(e){t.limit=e}})).actions(t=>({afterCreate(){x.addDisposer(t,J.reaction(()=>t.keywordString,t.resetPage,{fireImmediately:!1,delay:0})),x.addDisposer(t,J.reaction(()=>t.limit,t.resetPage,{fireImmediately:!1,delay:0}))}})),Dk=x.types.model({data:x.types.optional(x.types.frozen(),{}),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(t=>({get loading(){return t.state==="loading"},get empty(){return Object.keys(t.data).length===0}})),zk=x.types.compose("DataSourceModel",oi,x.types.model({tables:x.types.optional(Dk,{}),columns:x.types.optional(Sk,{}),tableData:x.types.optional(Tk,{}),indexes:x.types.optional(kk,{}),table_schema:x.types.optional(x.types.string,""),table_name:x.types.optional(x.types.string,"")})).views(t=>({get sqlDataSourceType(){return t.type},get reloadConditionString(){const{type:e,table_name:n,table_schema:r}=t;return`${e};${n};${r}`}})).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(t=>({setKeywords(e,n){t.table_schema=e,t.table_name=n}})).actions(t=>({initKeywords(){if(t.tables.empty)return;const e=Object.keys(t.tables.data)[0],n=t.tables.data[e][0].table_name;t.setKeywords(e,n)}})).actions(t=>{const e=x.flow(function*(){var n;(n=t.controllers.tables)==null||n.abort(),t.controllers.tables=new AbortController,t.tables.state="loading";try{const r=yield*x.toGenerator(ot.structure(t.controllers.tables.signal)({query_type:"TABLES",type:t.sqlDataSourceType,key:t.key,table_schema:"",table_name:""},{params:{query_type:"TABLES"}}));t.tables.data=b.groupBy(r,"table_schema"),t.tables.state="idle",t.tables.error=null,t.initKeywords()}catch(r){if(!rt.isCancel(r)){t.tables.data={};const i=b.get(r,"message","unkown error");t.tables.error=b.get(r,"response.data.detail.message",i),t.tables.state="error"}}});return{loadTables:e,loadTablesIfEmpty(){t.tables.empty&&e()},loadColumns:x.flow(function*(){var n;(n=t.controllers.columns)==null||n.abort(),t.controllers.columns=new AbortController,t.columns.state="loading";try{t.columns.data=yield*x.toGenerator(ot.structure(t.controllers.columns.signal)({query_type:"COLUMNS",type:t.sqlDataSourceType,key:t.key,table_schema:t.table_schema,table_name:t.table_name},{params:{query_type:"COLUMNS"}})),t.columns.state="idle",t.columns.error=null}catch(r){if(rt.isCancel(r))t.columns.state="idle",t.columns.error=null;else{t.columns.data=[];const i=b.get(r,"message","unkown error");t.columns.error=b.get(r,"response.data.detail.message",i),t.columns.state="error"}}}),loadIndexes:x.flow(function*(){var n;(n=t.controllers.indexes)==null||n.abort(),t.controllers.indexes=new AbortController,t.indexes.state="loading";try{t.indexes.data=yield*x.toGenerator(ot.structure(t.controllers.indexes.signal)({query_type:"INDEXES",type:t.sqlDataSourceType,key:t.key,table_schema:t.table_schema,table_name:t.table_name},{params:{query_type:"INDEXES"}})),t.indexes.state="idle",t.indexes.error=null}catch(r){if(rt.isCancel(r))t.indexes.state="idle",t.indexes.error=null;else{t.indexes.data=[];const i=b.get(r,"message","unkown error");t.indexes.error=b.get(r,"response.data.detail.message",i),t.indexes.state="error"}}}),loadTableData:x.flow(function*(){var r;(r=t.controllers.tableData)==null||r.abort(),t.controllers.tableData=new AbortController;const n=t.tableData;n.state="loading";try{n.data=yield*x.toGenerator(ot.structure(t.controllers.tableData.signal)({query_type:"DATA",type:t.sqlDataSourceType,key:t.key,table_schema:t.table_schema,table_name:t.table_name,limit:n.limit,offset:n.offset},{params:{query_type:"DATA"}}));const[{total:i}]=yield*x.toGenerator(ot.structure(t.controllers.tableData.signal)({query_type:"COUNT",type:t.sqlDataSourceType,key:t.key,table_schema:t.table_schema,table_name:t.table_name},{params:{query_type:"COUNT"}}));n.total=Number(i),n.state="idle",n.error=null}catch(i){if(rt.isCancel(i))n.state="idle",n.error=null;else{n.data=[];const o=b.get(i,"message","unkown error");n.error=b.get(i,"response.data.detail.message",o),n.state="error"}}})}}).actions(t=>({afterCreate(){x.addDisposer(t,J.reaction(()=>t.reloadConditionString,t.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(t=>({afterCreate(){x.addDisposer(t,J.reaction(()=>t.reloadConditionString,t.loadIndexes,{fireImmediately:!1,delay:500})),x.addDisposer(t,J.reaction(()=>`${t.reloadConditionString};limit:${t.tableData.limit};offset:${t.tableData.offset}`,t.loadTableData,{fireImmediately:!1,delay:0}))}})),Mk=x.types.model("DataSourcesModel",{list:x.types.optional(x.types.array(zk),[])}).views(t=>({find({type:e,key:n}){return t.list.find(r=>r.key===n&&r.type===e)},get options(){return t.list.map(e=>({value:e.key,label:e.key}))}})).actions(t=>({replace(e){t.list.length=0,t.list.push(...e)}}));function Lt(t){return{label:t,value:t,_type:"ACTION",_action_type:t,Icon:null,children:null}}function Ik(t){switch(t._type){case"GROUP":case"ACTION":return null;case"query_variables":return["_QUERY_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",t.value];case"sql_snippet":return["_SQL_SNIPPETS_",t.value];case"query":return["_QUERIES_",t.value];case"view":return["_VIEWS_",t.value];case"panel":return t.parentID?["_VIEWS_",t.parentID,"_PANELS_",t.value]:(console.error("[getPathFromOption] parentID is required"),null)}}const Ek=x.types.model("EditorModel",{path:x.types.optional(x.types.frozen(),[]),settings_open:x.types.optional(x.types.boolean,!1)}).views(t=>({get navOptions(){const{content:e}=x.getRoot(t),{filters:n,views:r,sqlSnippets:i,queries:o}=e;return[{label:"query_variable.labels",value:"_QUERY_VARS_",_type:"query_variables",Icon:k.IconVariable},{label:"mock_context.label",value:"_MOCK_CONTEXT_",Icon:k.IconCodeDots,_type:"mock_context"},{label:"filter.labels",value:"_FILTERS_",Icon:k.IconFilter,children:[Lt("_FILTERS_SETTINGS_"),...n.options,Lt("_Add_A_Filter_")],_type:"GROUP"},{label:"sql_snippet.labels",value:"_SQL_SNIPPETS_",Icon:k.IconCopy,children:[Lt("_SQL_SNIPPETS_SETTINGS_"),...i.options,Lt("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"query.labels",value:"_QUERIES_",Icon:k.IconDatabase,children:[Lt("_QUERIES_SETTINGS_"),...o.options,Lt("_Add_A_QUERY_")],_type:"GROUP"},{label:"view.labels",value:"_VIEWS_",Icon:k.IconBoxMultiple,children:[...r.editorOptions,Lt("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(e,n){return e.length===0?!1:e[e.length-1]===n.value},isOptionOpened(e){const{path:n}=t;return n.length===0||!e.children||e.children.length===0?!1:n.includes(e.value)}})).actions(t=>({setPath(e){t.path=e},setSettingsOpen(e){t.settings_open=e}})).actions(t=>({open(e){t.setPath(e),t.setSettingsOpen(!0)},close(){t.setSettingsOpen(!1)},navigate(e){const n=Ik(e);n&&t.setPath(n)}})),Ak=x.types.compose("LayoutsModel",yi,x.types.model({currentLayoutWrapperWidth:x.types.optional(x.types.number,0)})).views(t=>({get divisionPreviewScale(){const e=t.currentLayoutPreviewWidth,n=t.currentLayoutWrapperWidth;return!e||!n||e<=n?1:n/e}})).actions(t=>({addALayoutItem(e){t.list.forEach(n=>{n.addNewLayout(e)})},duplicateLayoutItemsByPanelID(e,n){t.list.forEach(r=>{const i=r.findByPanelID(e);if(!i){console.error(`Can't find a layout item by panelID[${e}] in layoutSet[${r.name}]`);return}r.list.push({...i,id:pt.v4(),panelID:n,y:1/0})})},removeByPanelID(e){t.list.forEach(n=>{n.removeByPanelID(e)})},setCurrentLayoutWrapperWidth(e){t.currentLayoutWrapperWidth=e},addALayoutSet(e,n,r){const i=t.basisLayoutSet,o={id:e,name:n,breakpoint:r,list:i.json.list.map(l=>({...l,id:pt.v4()}))};t.list.push(o)},updateLayoutSetsInfo(e){const n=b.keyBy(t.list,"id");e.forEach(o=>{const l=n[o.id];if(l){l.setName(o.name),l.setBreakpoint(o.breakpoint),delete n[o.id];return}this.addALayoutSet(o.id,o.name,o.breakpoint)});const r=new Set(Object.keys(n)),i=r.size>0;r.forEach(o=>{const l=t.list.findIndex(c=>c.id===o);t.list.splice(l,1)}),i&&t.setCurrentBreakpoint("basis")},updateCurrentLayoutItem(e){t.currentLayoutSet.updateLayoutItem(e)},updateCurrentLayoutItems(e){e.forEach(n=>{t.currentLayoutSet.updateLayoutItem(n)})},append(e){t.list.push(e)},appendMultiple(e){e.length!==0&&t.list.push(...e)},remove(e){t.list.splice(e,1)},removeByID(e){const n=t.list.findIndex(r=>r.id===e);n!==-1&&t.list.splice(n,1)},removeByIDs(e){e.forEach(n=>{this.removeByID(n)})}})),Bc=pi.views(t=>({get realDataFieldOptions(){return t.queryIDs.length===0?[]:t.queries.map(e=>{const n=e.data;return n.length===0?[]:Object.keys(n[0]).map(i=>({label:i,value:`${e.id}.${i}`,group:e.name,group_id:e.id,disabled:!1}))}).flat()},get realQueryOptions(){return t.queryIDs.length===0?[]:t.queries.map(e=>({label:e.name,value:e.id,disabled:!1}))},queryOptions(e,n){const r=[...this.realQueryOptions];return e&&!r.find(i=>i.value===e)&&r.unshift({label:e,value:e,disabled:!0}),n&&r.unshift({label:"unset",value:"",disabled:!1}),r},dataFieldOptions(e,n,r){let i=[...this.realDataFieldOptions];if(r&&(i=i.filter(o=>o.group_id===r)),e&&!i.find(o=>o.value===e)){const o=A(e),l=t.queryByID(o.queryID);i.unshift({label:o.columnKey,value:e,group:l?l.name:o.queryID,group_id:l?l.id:"",disabled:!0})}return n&&i.unshift({label:"unset",value:"",group:"",group_id:"",disabled:!1}),i},explainDataKey(e){const{queryID:n,columnKey:r}=A(e),i=t.queries.find(o=>o.id===n);return i?{queryID:n,queryName:i.name,columnKey:r}:{queryID:n,queryName:null,columnKey:r}}})).actions(t=>({removeSelf(){x.getParent(t,2).removeByID(t.id)}})).actions(t=>({moveToView(e,n){x.getRoot(t).content.views.findByID(e).removePanelID(t.id),x.getRoot(t).content.views.findByID(n).appendPanelID(t.id),x.getRoot(t).editor.setPath(["_VIEWS_",n,"_PANELS_",t.id])}})),Lc=x.types.compose("PanelsModel",hi,x.types.model({list:x.types.optional(x.types.array(Bc),[])})).views(t=>({get contentModel(){return x.getRoot(t).content},editorOptions(e,n){const r=t.panelsByIDs(n);r.length!==n.length&&console.warn(`Unfulfilled panels for View[${e}]`);const i=r.map(l=>({label:l.name,value:l.id,_type:"panel",parentID:e})),o="_Add_A_PANEL_";return i.push({label:o,value:o,_type:"ACTION",_action_type:o,parentID:e,Icon:null,children:null}),i}})).actions(t=>({replace(e){t.list=x.castToSnapshot(e)},append(e){t.list.push(e)},appendMultiple(e){e.length!==0&&t.list.push(...e)},remove(e){t.list.splice(e,1)},removeByID(e){const n=t.list.findIndex(r=>r.id===e);n!==-1&&t.list.splice(n,1)},removeByIDs(e){e.forEach(n=>{this.removeByID(n)})},duplicateByID(e){const n=t.list.find(i=>i.id===e);if(!n){console.error(new Error(`[duplicate panel] Can't find a panel by id[${e}]`));return}const r=new Date().getTime().toString();return t.list.push({...n.json,id:r,title:{...n.json.title}}),t.contentModel.layouts.duplicateLayoutItemsByPanelID(n.id,r),r},replaceByIndex(e,n){t.list.splice(e,1,n)}})),Pk=ui.actions(t=>({getSchema(){const e=t.json,n=[],r=[];t.panels.forEach(l=>{const c=l.getSchema();n.push(c.panel),c.queries.length>0&&r.push(...c.queries)});const i=t.contentModel.layouts.jsonByPanelIDSet(new Set(t.panelIDs));return{views:[e],panels:n,definition:{queries:b.uniqBy(r,l=>l.id)},layouts:i,version:yt}},downloadSchema(){if(t.type===B.Tabs){console.error(new Error("Please choose a tab first"));return}const e=JSON.stringify(this.getSchema(),null,2),n=t.name;Zt(n,e)}})),qc=x.types.compose("ViewsModel",di,x.types.model({current:x.types.optional(x.types.array(Pk),[]),idOfVIE:x.types.string})).views(t=>({get isVIETheFirstView(){return t.current.length===0||!t.idOfVIE?!1:t.current[0].id===t.idOfVIE},get VIE(){return t.current.find(({id:e})=>e===t.idOfVIE)},get options(){return t.current.map(e=>({label:e.name,value:e.id,type:e.type}))},get editorOptions(){const e=x.getRoot(t).content.panels;return t.current.map(n=>({label:n.name,value:n.id,_type:"view",children:e.editorOptions(n.id,n.panelIDs)}))}})).actions(t=>({setIDOfVIE(e){t.idOfVIE=e,t.visibleViewIDs.length=0,t.visibleViewIDs.push(e)},replace(e){t.current.replace(e)},addANewView(e,n,r,i){t.current.push({id:e,name:n,type:r,config:i,panelIDs:[]})},append(e){t.current.push(e)},appendMultiple(e){e.length!==0&&t.current.push(...e)},remove(e){t.current.splice(e,1)},removeByID(e){const n=t.current.findIndex(o=>o.id===e);if(n===-1)return;const r=t.current[n];x.getRoot(t).content.panels.removeByIDs(r.panelIDs),t.current.splice(n,1)},replaceByIndex(e,n){t.current.splice(e,1,n)},addARandomNewView(){const e=new Date().getTime().toString();this.addANewView(e,B.Division,B.Division,{_name:B.Division}),this.setIDOfVIE(e)},removeVIE(){t.current.length!==1&&(this.removeByID(t.idOfVIE),this.setIDOfVIE(t.current[0].id))}}));function Ci(t){const e=t.length>0?[t[0].id]:[],n=t.length>0?t[0].id:"";return{current:t.map(i=>{const{_name:o=i.type}=i.config;return{...i,config:{...i.config,_name:o},panelIDs:i.panelIDs}}),visibleViewIDs:e,idOfVIE:n}}const $k=x.types.model({id:x.types.string,name:x.types.string,dashboard_id:x.types.string,create_time:x.types.string,update_time:x.types.string,version:x.types.string,filters:Ec,queries:Pc,sqlSnippets:$c,views:qc,panels:Lc,layouts:Ak,mock_context:Ur,origin:x.types.maybe(x.types.frozen())}).views(t=>({get json(){return{id:t.id,name:t.name,create_time:t.create_time,update_time:t.update_time,dashboard_id:t.dashboard_id,content:{views:t.views.json,panels:t.panels.json,filters:t.filters.json,version:t.version,layouts:t.layouts.json,definition:{queries:t.queries.json,sqlSnippets:t.sqlSnippets.json,mock_context:t.mock_context.current}}}},get contentJSON(){return this.json.content},get filtersChanged(){const e="filters.current";return!b.isEqual(x.getSnapshot(b.get(t,e)),b.get(t.origin,e))},get queriesChanged(){const e="queries.current",n=x.getSnapshot(b.get(t,e)).map(r=>b.pick(r,["id","name","key","type","sql","run_by","react_to","pre_process","post_process","dep_query_ids"]));return!b.isEqual(n,b.get(t.origin,e))},get sqlSnippetsChanged(){const e="sqlSnippets.current";return!b.isEqual(x.getSnapshot(b.get(t,e)),b.get(t.origin,e))},get viewsChanged(){const e="views.current";return!b.isEqual(t.views.json,b.get(t.origin,e))},get panelsChanged(){const e="panels.list";return!b.isEqual(x.getSnapshot(b.get(t,e)),b.get(t.origin,e))},get layoutsChanged(){const e="layouts.list";return!b.isEqual(x.getSnapshot(b.get(t,e)),b.get(t.origin,e))},get mockContextChanged(){const e="mock_context.current";return!b.isEqual(b.get(t,e),b.get(t.origin,e))},get context(){const e=x.getParent(t).context.current;return{...t.mock_context.current,...e}},get payloadForSQL(){const e=x.getParent(t).globalSQLSnippets,n={context:this.context,filters:t.filters.values};return{...n,sql_snippets:bn(t.sqlSnippets.current,"key","value",n),global_sql_snippets:bn(e.list,"id","content",n)}},get payloadForViz(){const e=x.getParent(t).context.current;return{context:{...t.mock_context.current,...e},filters:t.filters.values}},get dashboardState(){return Is(this.payloadForSQL)},getAdditionalQueryInfo(e){return{content_id:t.id,query_id:e,params:this.dashboardState}},get changed(){return this.filtersChanged||this.queriesChanged||this.sqlSnippetsChanged||this.viewsChanged||this.panelsChanged||this.layoutsChanged||this.mockContextChanged},get data(){return t.queries.current.map(({id:n,data:r})=>({id:n,data:r})).reduce((n,r)=>(n[r.id]=r.data,n),{})},getDataStuffByID(e){const n=t.queries.findByID(e);return n?{data:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).views(t=>({get queriesUsage(){const e=t.panels.idMap,n=[];t.views.current.forEach(i=>{i.panelIDs.forEach(o=>{const l=e.get(o);if(!l)return;const c="panel",u=l.name,d=[{id:i.id,label:i.name}];l.queryIDs.forEach(p=>{n.push({id:o,queryID:p,type:c,type_label:"panel.label",label:u,views:d})})})});const r=t.views.idMap;return t.filters.current.filter(i=>!!b.get(i,"config.options_query_id")).forEach(i=>{n.push({type:"filter",type_label:"filter.label",id:i.id,queryID:b.get(i,"config.options_query_id"),label:i.label,views:i.visibleInViewsIDs.map(o=>{var l;return{id:o,label:((l=r.get(o))==null?void 0:l.name)??o}})})}),t.queries.current.forEach(i=>{i.isTransform&&i.dep_query_ids.forEach(o=>{n.push({type:"transform-query",type_label:"query.transform.full_label",id:i.id,queryID:o,label:i.name,views:[]})})}),b.groupBy(n,"queryID")},get hasUnusedQueries(){return t.queries.current.length>Object.keys(this.queriesUsage).length},findQueryUsage(e){return this.queriesUsage[e]??[]},get sqlSnippetsUsage(){const e=[];return t.queries.current.forEach(n=>{if(!n.typedAsSQL)return;b.uniq(n.sql.match(Mn.sqlSnippet)).forEach(i=>{e.push({queryID:n.id,sqlSnippetKey:i,queryName:n.name})})}),b.groupBy(e,"sqlSnippetKey")},get hasUnusedSQLSnippets(){return t.sqlSnippets.current.length>Object.keys(this.sqlSnippetsUsage).length},findSQLSnippetUsage(e){return this.sqlSnippetsUsage[e]??[]}})).actions(t=>({removeUnusedQueries(){const e=new Set(Object.keys(t.queriesUsage)),n=t.queries.current.filter(r=>!e.has(r.id)).map(r=>r.id);t.queries.removeQueries(n)},removeUnusedSQLSnippets(){const e=new Set(Object.keys(t.sqlSnippetsUsage)),n=t.sqlSnippets.current.filter(r=>!e.has(r.key)).map(r=>r.key);t.sqlSnippets.removeByKeys(n)},duplicatePanelByID(e,n){var i;const r=t.panels.duplicateByID(e);r&&((i=t.views.findByID(n))==null||i.appendPanelID(r))},removePanelByID(e,n){var r;t.panels.removeByID(e),t.layouts.removeByPanelID(e),(r=t.views.findByID(n))==null||r.removePanelID(e)},addANewPanel(e){var r;const n=pt.v4();t.panels.append(ic(n)),(r=t.views.findByID(e))==null||r.appendPanelID(n),t.layouts.addALayoutItem(n)},applyJSONSchema(e){var h;const{views:n,panels:r,filters:i,definition:o={},layouts:l}=e,{queries:c,sqlSnippets:u,mock_context:d}=o,p=new Map;if(Array.isArray(r)){const g=r.map(f=>{const v=pt.v4();return p.set(f.id,v),{...f,id:v}});if(t.panels.appendMultiple(g),!Array.isArray(n)||n.length===0){const f=g.map(v=>v.id);(h=t.views.VIE)==null||h.appendPanelIDs(f)}}if(Array.isArray(n)){const g=n.map(f=>{const v=f.panelIDs.map(w=>p.get(w)??w);return{...f,id:pt.v4(),panelIDs:v}});t.views.appendMultiple(g)}if(Array.isArray(l)){const g=(w,T)=>t.layouts.breakpointNameRecord[w]===T;let f=[];const v=l.filter(w=>g(w.name,w.breakpoint));v.forEach(w=>{w.id==="basis"&&(f=w.list),w.list.forEach(T=>{const D=p.get(T.panelID);T.id=pt.v4(),T.panelID=D})}),t.layouts.list.forEach(w=>{const T=v.find(D=>D.name===w.name&&D.breakpoint===w.breakpoint);if(!T){f.forEach(D=>{w.addLayout(D)});return}T.list.forEach(D=>{w.addLayout(D)})})}Array.isArray(i)&&t.filters.appendMultiple(i),Array.isArray(c)&&t.queries.appendMultiple(c),Array.isArray(u)&&t.sqlSnippets.appendMultiple(u),d&&Object.keys(d).length>0&&t.mock_context.defaults(d)}})).actions(t=>({reset(){x.applySnapshot(t.filters.current,t.origin.filters.current),x.applySnapshot(t.queries.current,t.origin.queries.current),x.applySnapshot(t.sqlSnippets.current,t.origin.sqlSnippets.current),x.applySnapshot(t.views.current,t.origin.views.current),x.applySnapshot(t.panels.list,t.origin.panels.list),x.applySnapshot(t.layouts.list,t.origin.layouts.list),t.mock_context.current=t.origin.mock_context.current},resetFilters(){x.applySnapshot(t.filters.current,t.origin.filters.current)},updateCurrent(e){const{id:n,name:r,content:i}=e;if(!i)throw new Error("unexpected null content when updating a content model");const{version:o,filters:l,views:c,panels:u,definition:{queries:d,sqlSnippets:p,mock_context:h={}}}=i;t.id=n,t.name=r,t.version=o,x.applySnapshot(t.filters.current,l),x.applySnapshot(t.views.current,Ci(c).current),x.applySnapshot(t.panels.list,u),x.applySnapshot(t.queries.current,d),x.applySnapshot(t.sqlSnippets.current,p),t.mock_context.current=h}})),Si=x.types.snapshotProcessor($k,{preProcessor(t){return{...t,origin:t}},postProcessor(t){delete t.origin;const e=x.castToSnapshot(t.queries.current.map(n=>b.pick(n,["id","key","type","sql"])));return b.defaults({},{queries:{current:e}},t)}});function Bk(t,e){e.filters&&x.applySnapshot(t.filters.current,e.filters)}function Oc({id:t,name:e,dashboard_id:n,create_time:r,update_time:i,content:o},l,c){if(!o)throw new Error("unexpected null content when creating a content model");const{version:u,filters:d,views:p,panels:h,layouts:g,definition:{queries:f,sqlSnippets:v,mock_context:w={}}}=o;return Si.create({id:t,name:e,dashboard_id:n,create_time:r,update_time:i,version:u,filters:xi(d,l,w,c),queries:{current:f},sqlSnippets:{current:v},mock_context:Yr(w),views:Ci(p),panels:{list:h},layouts:{list:g,currentBreakpoint:g[0].id}})}const Vc=x.types.model({id:x.types.identifier,name:x.types.string,group:x.types.string,content:Si,content_id:x.types.string,datasources:Mk,globalSQLSnippets:li,context:us,editor:Ek}).views(t=>({get json(){return{id:t.id,name:t.name,group:t.group,content_id:t.content_id}}})).actions(t=>({updateCurrentContent(e){t.content.updateCurrent(e)},updateCurrent(e,n){const{id:r,name:i,group:o,content_id:l}=e;t.id=r,t.name=i,t.group=o,t.content_id=l,this.updateCurrentContent(n)}}));function Nc({id:t,name:e,group:n,content_id:r},i,o,l,c,u){return Vc.create({id:t,name:e,group:n,content_id:r,content:Oc(i,c,u),datasources:{list:o},globalSQLSnippets:{list:l},context:ci(c),editor:{}})}const Lk={translation:{filter:{label:"Filter",labels:"Filters",add:"Add a Filter",manage:"Manage Filters",show_filters:"Show Filters",hide_filters:"Hide Filters",field:{widget:"Widget",visible_in:"Visible in...",key_placeholder:"A unique key to refer",label_placeholder:"Label for this field",auto_submit:"Submit automatically",order:"Placement Order",custom_default_value:{trigger:"Custom",title:"Custom default value",tips:"Tips",tip_1:"Function has the highest priority of getting filter's default value",tip_2:"Leave this editor empty to disable this feature"}},widget:{names:{select:"Select",multi_select:"Multi Select",tree_select:"Tree Select",text_input:"Text Input",checkbox:"Checkbox",date_range:"Date Range"},common:{use_query_data_as_options:"Use query data as options",fetch_options_from_datasource:"Fetch options from datasource",or_fetch_options_from_datasource:"Or fetch options from datasource",selector_option_empty:"Not found",see_data_structure:"Click to see expected data structure",using_query:"Using query",default_selection_count:"Select first N options by default",min_width:"Min width",x_selected:"{{count}} selected"},text_input:{default_value:"Default Value",required:"Required"},select:{width:"Width",required:"Required",clearable:"Clearable",configure_options:"Configure options",default_selection:"Default Selection",no_default_selection:"none",select_first_option_by_default:"Select the first option by default"},multi_select:{width_description:"At least 160px"},tree_select:{strictly:"Parent and children nodes are not associated"},checkbox:{description:"Description",default_checked:"Default checked"},date_range:{required:"Required",allow_single_date:"Allow choosing 1 day",display_format:"Display format",max_days:"Max days",one_day:"1 day",x_days:"{{count}} days",x_max_days:"{{max_days}} days max",default_value:"Default value",default_by_shortcut:"Default by shortcut",default_by_shortcut_placeholder:"Priors default value",start_date:"Start date",end_date:"End date",shortcut:{last:{label:"last",d:"yesterday",w:"week",m:"month",m2:"2 months",m3:"3 months",y:"year",full:{d:"yesterday",w:"last week",m:"last month",m2:"last 2 months",m3:"last 3 months",y:"last year"}},recent:{label:"recent",d7:"7 days",d30:"30 days",d60:"60 days",d90:"90 days",d180:"180 days",d365:"365 days",full:{d7:"recent 7 days",d30:"recent 30 days",d60:"recent 60 days",d90:"recent 90 days",d180:"recent 180 days",d365:"recent 365 days"}},this:{label:"this",d:"today",w:"week",m:"month",y:"year",full:{d:"today",w:"this week",m:"this month",y:"this year"}},this_so_far:{label:"this...so far",w:"week",m:"month",y:"year",full:{w:"this week so far",m:"this month so far",y:"this year so far"}}}}}},view:{label:"View",labels:"Views",add:"Add a View",delete:"Delete this View",download_schema:"Download this View",component:{div:{label:"Division"},tabs:{label:"Tabs",tabs_settings:"Tabs Settings",tab:{name:"Tab Name",view:"View",order:"Placement Order",color:"Color",delete:"Delete this tab",switch_to_view:"Swith to View: {{name}}"}},modal:{label:"Modal",modal_settings:"Modal settings",title:"Modal Title",custom_title:"Customize modal title",width:"Width",height:"Height"}}},interactions:{label:"Interactions",add:"Add an interaction",interactions_viewer:"Interactions Viewer",unavailable:"Unavailable",unavailable_reason:"This visualization does not have available interactions to choose from",trigger:{setup:"Setup Trigger",label:"Trigger",payload:"Payload"},operation:{setup:"Operation Settings",label:"Operation",settings:"Settings",variables:"Variables",console_log:{label:"console.log | debug",log_content:"log content"},open_link:{label:"Open Link",url:"URL",open_in_new_tab:"Open in new tab"},open_view:{label:"Open View",view:"View"},set_filter_values:{label:"Set Filter Values",set_filter:"Set filter",with:"with"},clear_filter_values:{label:"Clear Filter Values",select_filter:"Select filters to clear"}}},query_variable:{label:"Query Variable",labels:"Query Variables",add:"Add a Variable",guide:{tabs:{guide:"Guide",variables_in_this_dashboard:"Variables in this dashboard",global_sql_snippets:"Global SQL Snippets"}},open:"See Query Variables"},sql_snippet:{label:"SQL Snippet",labels:"SQL Snippets",add:"Add a SQL Snippet",delete:"Delete this SQL Snippet",delete_unused:"Delete unused SQL Snippets",manage:"Manage SQL Snippets",key:"Key",key_occupied:"This key is occupied by another snippet",edit_snippet:"Edit SQL Snippet",preview_snippet:"Preview SQL Snippet",usage:{label:"Usage"}},global_sql_snippet:{label:"Global SQL Snippet",labels:"Global SQL Snippets",description:"SQL snippets worth sharing between dashboards are managed in System Settings by admins."},common:{titles:{settings:"Settings",edit:"Edit",config:"Config"},pagination:{page_size:"Page Size",total:"Total",total_rows:"Total {{total}} row(s)"},align:{horizontal:{label:"Horizontal Align",left:"left",center:"center",right:"right"},vertical:{label:"Vertical Align",left:"top",center:"center",right:"bottom"}},id:"ID",name:"Name",key:"Key",label:"Label",value:"Value",type:"Type",info:"Info",min:"Min",max:"Max",data_field:"Data Field",name_data_field:"Name Data Field",value_data_field:"Value Data Field",color_data_field:"Color Data Field",enabled:"Enabled",copied:"Copied to clipboard",action:"Action",actions:{open:"Open",close:"Close",save:"Save",save_changes:"Save Changes",revert:"Revert",revert_changes:"Revert Changes",reset_to_default:"Reset to default",select_all:"Select All",clear_selection:"Clear Selection",refresh:"Refresh",download_data:"Download Data",download_schema:"Download Schema",download_screenshot:"Screenshot",enter_fullscreen:"Full Screen",duplicate:"Duplicate",delete:"Delete",cancel:"Cancel",confirm:"Confirm",add_an_option:"Add an Option",edit:"Edit",end_editing:"End editing <1>{{name}}</1>"},tabs:{variant:{label:"Variant",default:"Default",outline:"Outline",pills:"Pills"},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},grow_tabs:"Grow Tabs"},choose_a_tab_first:"Please choose a tab first"},breakpoint:{label_one:"Screen size",label_other:"Screen sizes",add:"Add a screen size",manage:"Manage screen sizes",breakpoint:"Min Width"},context:{label:"Context"},mock_context:{label:"Mock Context",hint:"A valid json string is required"},panel:{label:"Panel",labels:"Panels",add:"Add a Panel",delete:"Delete This Panel",panel_name:"Panel Name",panel_description:"Description",panel_description_click:"Click to see description",show_title:"Show title",use_name_as_title:"Use name as title",settings:{change_view:"Move into Another View",change_view_title:"Move panel into another view",choose_queries:"Choose queries",need_to_choose_queries:"Choose at least 1 query for its data"},style:{label:"Style",width:"Width",width_postfix:"of 36 columns",height:"Height",height_postfix:"px",border:"Border"},variable:{label:"Variable",labels:"Variables",add:"Add a Variable",delete:"Delete this Variable",aggregation:{label:"Aggregation",fallback_value:"Fallback Value",fallback_value_description:"Used when data is empty or the aggregation yields NaN"}}},style:{label:"Style",font_size:{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"Font Weight"},size:{xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"xl"},flex:{justify_content:{label:"Justify Content",left:"Left",center:"Center",right:"Right",space_between:"Space Between",space_around:"Space Around",space_evenly:"Space Evenly"},align_items:{label:"Align Items",start:"Start",center:"Center",end:"End",stretch:"Stretch"}},color:{type:{label:"Color Type",static:"Static",interpolation:"Interpolation",none:"None"},interpolation:{setup:"Setup color interpolation",palette:{label:"Palette",category:{sequential:"Sequential",diverging:"Diverging"},red_green:"Red / Green",yellow_blue:"Yellow / Blue",red:"Red",green:"Green",blue:"Blue",orange:"Orange",mapping:{value_input_label:"Map a value to this color"}}}}},query:{label:"Query",labels:"Queries",add:"Add a Query",delete:"Delete this Query",cant_delete:"Can't delete this query for it's being used, check out Usage tab for details",delete_unused:"Delete unused queries",name:"Name",name_description:"A unique name",manage:"Manage Queries",open:"Open this query",configurations:"Configurations",basics:"Basics",conditions:"Conditions",run_by_condition:{label:"Run query when these are truthy",unset:"Always run this query on load"},re_run_condition:{label:"Re-run query when these changed",unset:"Leave it empty to never re-run this query"},dependency:{label:"Dependency",has_none:"This query has no dependency"},edit_sql:"Edit SQL",preview_sql:"Preview SQL",request:"Request",build_request:"Build Request",process_request:"Process Request",process_result:"Process Result",usage:{label:"Usage",in_views:"In View(s)",unused_description:"This query is not used by any filter or panel"},transform:{label:"Transform",full_label:"Transform Query",data_source:"Use other queries' data",guide:{pick_queries:"Pick queries for data input",write_function:"Write a function for making new data"}}},data:{label:"Data",preview_data:"Preview Data",empty_data:"Empty Data",requires_data:"Requires data"},data_source:{label:"Data Source",explore:"Explore Data Source",explorer:"Data Source Explorer",table_structure:"Table Structure",table_structure_short:"Structure",see_table_structure:"See Table Structure"},visualization:{label:"Visualization",component:"Visualization",label_short:"Viz"},numbro:{format:{label:"Format",absolute:"Absolute",absolute_description:"Non-negative",abbreviation:"Abbreviation",abbreviation_description:"like 1.23k, 1.23m",mantissa:"Mantissa",trim_mantissa:"Trim mantissa",trim_mantissa_description:"hide trailing zero(s)",preview:{open:"Open Preview",close:"Close Preview",input:"In",output:"Out"}}},import:{label:"Import...",title:"Import content with schema json",json_file:"JSON File",this_dashboard:"This dashboard",this_file:"This file"},function_utils:{trigger_text:"About parameter 'utils'",modal_title:"About FunctionUtils",description:"Parameter <code>utils</code> is <code>FunctionUtils</code>, which contains:",document:"Document"},aggregation:{option:{none:"None",sum:"Sum",mean:"Mean",median:"Median",min:"Min",max:"Max",cov:"Coefficient of Variation",std:"Standard Variation",quantile:{label:"Quantile",label_with_hint:"Quantile(99%, 95%, ...)"},custom:{label:"Custom",label_trigger:"Edit Function",title:"Custom Aggregation"},pick_record:{label:"Pick Record",method:{label:"Record",first:"First Record",last:"Last Record"}}}},chart:{chart_config:"Chart Config",data_field:"Data Field",groups:{merico_suite:"Merico suite",echarts_based_charts:"ECharts-based charts",others:"Others"},label:{label:"Label",label_full:"Label",label_style:"Label Style",label_format:"Label Format"},label_position:{label:"Label Position",off:"Off",top:"Top",left:"Left",right:"Right",bottom:"Bottom",inside:"Inside",inside_top:"Inside Top",inside_left:"Inside Left",inside_center:"Inside Center",inside_right:"Inside Right",inside_bottom:"Inside Bottom",inside_top_left:"Inside Top Left",inside_top_right:"Inside Top Right",inside_bottom_left:"Inside Bottom Left",inside_bottom_right:"Inside Bottom Right",outside:"Outside"},visual_map:{label:"Visual Map",continuous:{label:"Continuous"},piecewise:{label:"Piecewise",mode:{pieces:"Pieces",categories:"Categories"},add_a_piece:"Add a piece",interval:"Interval",piece_label:"Label"},bar_width:"Bar Width",bar_height:"Bar Height",item_width:"Item Width",item_height:"Item Height",calculable:"Show drag handle",min_value:"Min Value",max_value:"Max Value",min_text:"Min Text",max_text:"Max Text",use_palette_x:'Use palette "{{x}}"',built_in_palettes:"Built-in Palettes",precision:"Data Precision",skip_range:{lt_min:"Color for smaller values than min value",min:"Color for min value",max:"Color for max value",gt_max:"Color for greater values than max value",follow_visual_map:"follow gradient rule"}},number_or_dynamic_value:{type:{static:"Static",dynamic:"Dynamic"},dynamic:{setup:"Setup",setup_title:"Setup dynamic value",guide:"Dyanmic by a custom function"}},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},symbol_size:{label:"Symbol Size",static:"Static",dynamic:"Dynamic",setup:{label:"Setup",title:"Setup dynamic size",description:"Dynamic by a custom function"}},series:{label:"Series",name:"Name",y_axis:"Y Axis",data_field:"Data Field",add:"Add a series",delete:"Delete this series",line:{label:"Line",line_settings:"Line Settings",line_style:"Line Style",type:{label:"Line Type",solid:"Solid",dashed:"Dashed",dotted:"Dotted"},line_width:"Line Width",step:{label:"Step",off:"Off",start:"Start",middle:"Middle",end:"End"},smooth_line:"Smooth Line",show_name_on_line:"Display Name on Line",show_symbol_on_line:"Show Symbol on Line"},bar:{label:"Bar",stack:"Stack",stack_hint:"Stack bars by this ID",bar_gap:{label:"Bar Gap",no_gap:"No gap between bars",overlap:"Bars overlapping on each other"},bar_width:{min:"Bar Width(min)",exact:"Bar Width",max:"Bar Width(max)"}},scatter:{label:"Scatter"},group_by:{label:"Split into multiple seires by this field...",label_line:"Split into multiple lines by this field..."}},axis:{tick_label:"Tick Label",customize_label:"Customize Label",overflow:{label:"Overflow",max_width:"Max Width",truncate:"Truncate",break_line:"Break Line",break_word:"Break Word",ellipsis:"Ellipsis",section_title:{on_axis:"Overflow on Axis",in_tooltip:"Overflow in Tooltip"}},section_title:{label_format:"Label Format"},type:{value:"Value",category:"Category",time:"Time",log:"Log",click_to_learn_more:"Click <1>here</1> to learn more about these options"}},name_text:{align:{label:"Name Anchor",left:"Left",center:"Center",right:"Right"}},rotate:"Rotate",degree:"degree",padding:"Padding",content_template:{label:"Content Template",hint:"Average: ${avg}"},x_axis:{label:"X Axis",labels:"X Axes",label_format:"Label Format",add:"Add an X Axis",delete:"Delete this X Axis",x_axis_name:"X Axis Name",x_axis_data_field:"X Axis Data Field",x_axis_type:"X Axis Type",layout:"Layout",position:{label:"Position",top:"Top",bottom:"Bottom"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},y_axis:{label:"Y Axis",labels:"Y Axes",label_format:"Label Format",add:"Add a Y Axis",delete:"Delete this Y Axis",y_axis_name:"Y Axis Name",y_axis_name_anchor:"Name Anchor",y_axis_data_field:"Y Axis Data Field",layout:"Layout",position:{label:"Position",left:"Left",right:"Right"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},stats:{label:"Stats",template:{above_chart:"Template for stats above the chart",under_chart:"Template for stats under the chart"}},legend:{label:"Legend",show_legend:"Show Legend",show_in_legend:"Show in legend",hide_in_legend:"Hide in legend",orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"}},tooltip:{label:"Tooltip",additional_metrics:{description:"Set additional metrics to show in scatter's tooltip",add:"Add a metic",delete:"Delete this Metric"},trigger:{label:"Trigger",scatter_point:"Scatter Point",x_axis:"X Axis"}},style:{label:"Style"},color:{label:"Color",or:"or",set_any_color:"Set any color",pick_a_theme_color:"Pick a theme color",background_color:"Background Color",text_color:"Text Color",click_to_add_a_color:"Click to add a color",color_gradient:"Color Gradient"},behavior:{label:"Behavior",invisible:"Invisible"},heatmap:{heatblock:{label:"Heat Block",show_label:"Show Label"}},reference_line:{label:"Reference Line",labels:"Reference Lines",add:"Add a reference line",name_placeholder:"Average Reference Line",delete:"Remove this Reference Line",orientation:{vertical_hint:"Works only when xAxis values are numbers"}},regression_line:{label:"Regression Line",labels:"Regression Lines",add:"Add a line",delete:"Delete this line",method:{label:"Method",linear:"Linear",exponential:"Exponential",logistic:"Logistic",polynomial:"Polynomial",polynomial_order:"Order"}},reference_area:{label:"Reference Area",labels:"Reference Areas",add:"Add a reference area",delete:"Remove this reference area",type:{label:"Type",rectangle:"Rectangle"},direction:{label:"Direction",horizontal:"Horizontal"},boundary:{upper:"Upper Boundary",lower:"Lower Boundary"},content:{label:"Content",content_text:"Content Text",text_position:"Text Position"},endpoint:{labels:"Endpoints",left_bottom_point:"Left-Bottom Point",right_top_point:"Right-Top Point"}},zooming:{label:"Zooming",scroll:{label:"Scroll to zoom",x_axis:"Enable on X Axis",y_axis:"Enable on Y Axis"},slider:{label:"Slider for zooming",x_axis:"Slider for X Axis",y_axis:"Slider for Y Axis",y_axis_disabled:"Not available for now, will overlap y-axis's label"}}},viz:{viz_config_banner:"Visualization Settings"},validation:{number:{require_a_number:"A number is required"}}}},qk={translation:{filter:{label:"筛选器",labels:"筛选器",add:"新增筛选器",manage:"管理筛选器",show_filters:"展开筛选器",hide_filters:"收起筛选器",field:{widget:"控件",visible_in:"在...视图中可见",key_placeholder:"用于引用此筛选器,需保持唯一",label_placeholder:"用于展示的标签文案",auto_submit:"自动提交",order:"排列次序",custom_default_value:{trigger:"自定义",title:"自定义默认值",tips:"提示",tip_1:"在指定筛选器默认值这事上,自定义函数具备最高优先级",tip_2:"清空下方编辑器来禁用本功能"}},widget:{names:{select:"单选",multi_select:"多选",tree_select:"树形选择器",text_input:"文本框",checkbox:"勾选框",date_range:"日期范围"},common:{use_query_data_as_options:"使用所查数据为选项",fetch_options_from_datasource:"从数据源查选项",or_fetch_options_from_datasource:"或从数据源查选项",selector_option_empty:"无选项可用",see_data_structure:"点击查看期望的数据格式",using_query:"在用查询获取选项",default_selection_count:"默认选中前N项",min_width:"控件最小宽度",x_selected:"已选数:{{count}}"},text_input:{default_value:"默认值",required:"必填"},select:{width:"控件宽度",required:"必选",clearable:"可取消选择",configure_options:"配置选项",default_selection:"默认选项",no_default_selection:"无",select_first_option_by_default:"默认选中第一个选项"},multi_select:{width_description:"至少160px"},tree_select:{strictly:"枝叶节点不相关,各选各的"},checkbox:{description:"描述信息",default_checked:"默认勾选"},date_range:{required:"必选",allow_single_date:"允许选一天作为范围",display_format:"展示格式",max_days:"最大选择天数",one_day:"1天",x_days:"{{count}}天",x_max_days:"最多可选{{max_days}}天",default_value:"默认日期范围(具体)",default_by_shortcut:"默认日期范围(快捷方式)",default_by_shortcut_placeholder:"优先于左侧",start_date:"开始日期",end_date:"结束日期",shortcut:{last:{label:"过往整周期",d:"昨天",w:"周",m:"月",m2:"两个月",m3:"三个月",y:"年",full:{d:"昨天",w:"上周",m:"上个月",m2:"上两月",m3:"上三月",y:"去年"}},recent:{label:"最近",d7:"7天",d30:"30天",d60:"60天",d90:"90天",d180:"180天",d365:"365天",full:{d7:"近7天",d30:"近30天",d60:"近60天",d90:"近90天",d180:"近180天",d365:"近365天"}},this:{label:"当前整周期",d:"今天",w:"周",m:"月",y:"年",full:{d:"今天",w:"本周",m:"本月",y:"今年"}},this_so_far:{label:"至今",w:"周",m:"月",y:"年",full:{w:"本周至今",m:"本月至今",y:"本年至今"}}}}}},view:{label:"视图",labels:"视图",add:"新增视图",delete:"删除此视图",download_schema:"下载此视图描述文件",component:{div:{label:"内容"},tabs:{label:"标签页",tabs_settings:"标签页设置",tab:{name:"名称",view:"内容视图",order:"排列次序",color:"颜色",delete:"删除这个标签页",switch_to_view:"打开视图: {{name}}"}},modal:{label:"弹窗",modal_settings:"弹窗设置",title:"弹窗标题",custom_title:"自定义弹窗标题",width:"宽度",height:"高度"}}},interactions:{label:"交互",add:"新增交互",interactions_viewer:"纵览交互",unavailable:"不可用",unavailable_reason:"此可视化组件没有交互功能",trigger:{setup:"设置触发动作",label:"触发动作",payload:"触发时的参数"},operation:{setup:"操作设置",label:"操作",settings:"设置",variables:"变量",console_log:{label:"console.log | 调试用",log_content:"打印内容"},open_link:{label:"打开链接",url:"URL",open_in_new_tab:"在新标签页中打开"},open_view:{label:"唤出视图",view:"视图"},set_filter_values:{label:"设置筛选器值",set_filter:"将筛选器的值",with:"设为"},clear_filter_values:{label:"清除筛选器值",select_filter:"选择筛选器以清除其值"}}},query_variable:{label:"查询变量",labels:"查询变量",add:"新增变量",guide:{tabs:{guide:"使用指南",variables_in_this_dashboard:"本看板中的查询变量",global_sql_snippets:"全局SQL片段"}},open:"查看查询变量"},sql_snippet:{label:"SQL片段",labels:"SQL片段",add:"新增SQL片段",delete:"删除这个SQL片段",delete_unused:"删除未用到的SQL片段",manage:"管理SQL片段",key:"键",key_occupied:"此键已被其他SQL片段占用",edit_snippet:"编辑SQL片段",preview_snippet:"预览SQL片段",usage:{label:"使用情况"}},global_sql_snippet:{label:"全局SQL片段",labels:"全局SQL片段",description:"管理员负责在系统设置中维护全局SQL片段"},common:{titles:{settings:"设置",edit:"编辑",config:"配置"},pagination:{page_size:"页容量",total:"共",total_rows:"共 {{total}} 行"},align:{horizontal:{label:"水平对齐",left:"居左",center:"居中",right:"居右"},vertical:{label:"垂直对齐",left:"居上",center:"居中",right:"居下"}},id:"ID",name:"名称",key:"键",label:"标签",value:"值",type:"类型",info:"信息",min:"最小值",max:"最大值",data_field:"数据字段",name_data_field:"名称字段",value_data_field:"值字段",color_data_field:"颜色字段",enabled:"启用",copied:"已复制到剪切板",action:"操作",actions:{open:"打开",close:"关闭",save:"保存",save_changes:"保存改动",revert:"还原",revert_changes:"还原改动",reset_to_default:"重置为初始值",select_all:"全选",clear_selection:"撤销选择",refresh:"刷新",download_data:"下载数据",download_schema:"下载描述文件",download_screenshot:"下载截图",enter_fullscreen:"全屏",duplicate:"复制",delete:"删除",cancel:"取消",confirm:"确认",add_an_option:"新增选项",edit:"编辑",end_editing:"结束编辑 <1>{{name}}</1>"},tabs:{variant:{label:"风格",default:"默认",outline:"轮廓",pills:"胶囊"},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},grow_tabs:"拉伸标签卡宽度"},choose_a_tab_first:"请先选择一个标签页"},breakpoint:{label_one:"屏幕尺寸",label_other:"屏幕尺寸",add:"新增屏幕尺寸",manage:"管理屏幕尺寸",breakpoint:"最小宽度"},context:{label:"上下文"},mock_context:{label:"模拟上下文",hint:"内容格式为JSON"},panel:{label:"卡片",labels:"卡片",add:"新增卡片",delete:"删除这个卡片",panel_name:"卡片名",panel_description:"卡片描述",panel_description_click:"点击查看卡片描述",show_title:"展示卡片标题",use_name_as_title:"使用卡片名作为标题",settings:{change_view:"移至另一个视图下",change_view_title:"移动此卡片至另一个视图下",choose_queries:"关联查询",need_to_choose_queries:"请关联至少一个查询以使用其数据"},style:{label:"样式",width:"宽",width_postfix:"之 36 栏",height:"高",height_postfix:"px",border:"边框"},variable:{label:"变量",labels:"变量",add:"新增变量",delete:"删除此变量",aggregation:{label:"聚合",fallback_value:"兜底值",fallback_value_description:"当数据为空或聚合结果非数字时,使用此兜底值"}}},style:{label:"样式",font_size:{label:"字号",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"字重"},size:{xs:"特小",sm:"小",md:"中",lg:"大",xl:"特大"},flex:{justify_content:{label:"内容分布",left:"从左起",center:"居中",right:"从右起",space_between:"均匀分布,首尾顶格",space_around:"均匀分布,首尾留空一半",space_evenly:"均匀分布,首尾留空"},align_items:{label:"对齐位置",start:"起点对齐",center:"居中对齐",end:"末端对齐",stretch:"拉伸对齐"}},color:{type:{label:"颜色类型",static:"单色",interpolation:"插值取色",none:"无"},interpolation:{setup:"设置取色方案",palette:{label:"色板",category:{sequential:"单色渐变",diverging:"双色渐变"},red_green:"红 / 绿",yellow_blue:"黄 / 蓝",red:"红",green:"绿",blue:"蓝",orange:"橙",mapping:{value_input_label:"映射一个值到此颜色"}}}}},query:{label:"查询",labels:"查询",add:"新增查询",delete:"删除这个查询",cant_delete:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",delete_unused:"删除未用到的查询",name:"名称",name_description:"唯一名称",manage:"管理查询",open:"打开此查询",configurations:"配置",basics:"基本信息",conditions:"条件",run_by_condition:{label:"以下条件满足时,才运行本查询",unset:"看板加载时便运行本查询"},re_run_condition:{label:"当以下条件改变时,重新运行此查询",unset:"留空则永不重新运行此查询"},dependency:{label:"依赖",has_none:"此查询无依赖"},edit_sql:"编辑SQL",preview_sql:"预览SQL",request:"请求",build_request:"构造请求",process_request:"加工请求",process_result:"加工结果",usage:{label:"使用情况",in_views:"所在视图",unused_description:"此查询未被任何筛选器或卡片用到"},transform:{label:"查询变形",full_label:"查询变形",data_source:"基于其他查询的数据,加工出新数据",guide:{pick_queries:"选择一至多个查询作为数据输入",write_function:"编写函数,返回新数据"}}},data:{label:"数据",preview_data:"预览数据",empty_data:"无数据",requires_data:"请先关联查询"},data_source:{label:"数据源",explore:"查看数据源",explorer:"数据源查看器",table_structure:"数据表结构",table_structure_short:"表结构",see_table_structure:"查看数据表结构"},visualization:{label:"可视化",component:"可视化组件",label_short:"可视化"},numbro:{format:{label:"格式",absolute:"绝对值",absolute_description:"非负",abbreviation:"缩写",abbreviation_description:"如1.23k、1.23m",mantissa:"小数",trim_mantissa:"抹零",trim_mantissa_description:"省略末尾的零",preview:{open:"展开预览",close:"收起预览",input:"输入",output:"输出"}}},import:{label:"导入...",title:"自描述文件导入看板内容",json_file:"描述文件(JSON格式)",this_dashboard:"此看板",this_file:"此文件"},function_utils:{trigger_text:"关于utils参数",modal_title:"关于utils参数",description:"参数 <code>utils</code> 是 <code>FunctionUtils</code>,包含以下内容:",document:"文档"},aggregation:{option:{none:"无",sum:"和",mean:"平均值",median:"中位数",min:"最小值",max:"最大值",cov:"变异系数",std:"标准差",quantile:{label:"分位",label_with_hint:"分位(99%, 95%, ...)"},custom:{label:"自定义",label_trigger:"编写函数",title:"自定义聚合方式"},pick_record:{label:"直接选择数据",method:{label:"数据记录",first:"第一条",last:"最后一条"}}}},chart:{chart_config:"图表设置",data_field:"数据字段",groups:{merico_suite:"思码逸套件",echarts_based_charts:"基于ECharts的图表",others:"其他"},label:{label:"文案",label_full:"标签文案",label_style:"标签文案样式",label_format:"标签文案格式"},label_position:{label:"文案位置",off:"不显示文案",top:"上",left:"左",right:"右",bottom:"下",inside:"内",inside_top:"内-上",inside_left:"内-左",inside_center:"内-中",inside_right:"内-右",inside_bottom:"内-下",inside_top_left:"内-上-左",inside_top_right:"内-上-右",inside_bottom_left:"内-下-左",inside_bottom_right:"内-下-右",outside:"外"},visual_map:{label:"视觉映射",continuous:{label:"连续型"},piecewise:{label:"分段型",mode:{pieces:"连续数据",categories:"离散数据"},add_a_piece:"加一个分段",interval:"值区间",piece_label:"文案"},bar_width:"长条的宽度",bar_height:"长条的高度",item_width:"小块的宽度",item_height:"小块的高度",calculable:"显示拖拽手柄",min_value:"最小值",max_value:"最大值",min_text:"最小值文案",max_text:"最大值文案",use_palette_x:'使用配色方案"{{x}}"',built_in_palettes:"内置配色方案",precision:"数据精度",skip_range:{lt_min:"小于最小值时的颜色",min:"最小值的颜色",max:"最大值的颜色",gt_max:"大于最大值时的颜色",follow_visual_map:"颜色跟随渐变规则"}},number_or_dynamic_value:{type:{static:"具体值",dynamic:"动态值"},dynamic:{setup:"设置",setup_title:"设置动态值",guide:"由函数确定动态值"}},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},symbol_size:{label:"标记点大小",static:"固定值",dynamic:"动态值",setup:{label:"设置",title:"设置动态值",description:"由函数确定动态值"}},series:{label:"系列",name:"名称",y_axis:"Y轴",data_field:"数据字段",add:"增加一个系列",delete:"删除这个系列",line:{label:"线",line_settings:"线段设置",line_style:"线条样式",type:{label:"类型",solid:"实线",dashed:"方虚线",dotted:"圆点虚线"},line_width:"线宽",step:{label:"阶梯状",off:"不启用",start:"在当前点拐弯",middle:"在当前点与下个点中间拐弯",end:"在下个点拐弯"},smooth_line:"平滑曲线",show_name_on_line:"显示标签文案",show_symbol_on_line:"显示标记点"},bar:{label:"柱",stack:"堆放",stack_hint:"此值相同的柱系列会堆叠在一起",bar_gap:{label:"柱间隔",no_gap:"柱子之间无间隔",overlap:"柱子可互相重叠"},bar_width:{min:"最大柱宽",exact:"柱宽",max:"最大柱宽"}},scatter:{label:"散点"},group_by:{label:"按此字段拆分为多个系列",label_line:"按此字段拆分为多条线"}},axis:{tick_label:"刻度文案",customize_label:"自定义文案",overflow:{label:"溢出",max_width:"最大宽度",truncate:"截断",break_line:"换行",break_word:"断词换行",ellipsis:"省略符",section_title:{on_axis:"轴刻度上文案的溢出",in_tooltip:"提示框中的文案溢出"}},section_title:{label_format:"文案格式"},type:{value:"数值轴",category:"类目轴",time:"时间轴",log:"对数轴",click_to_learn_more:"点击 <1>这里</1> 以进一步了解这些选项"}},name_text:{align:{label:"名称贴靠侧",left:"左",center:"中",right:"右"}},rotate:"旋转",degree:"度",padding:"内间距",content_template:{label:"内容模板",hint:"均值: ${avg}"},x_axis:{label:"X轴",labels:"X轴",label_format:"刻度文案格式",add:"增加一条X轴",delete:"删除这条X轴",x_axis_name:"X轴名称",x_axis_data_field:"X轴数据字段",x_axis_type:"X轴类型",layout:"布局",position:{label:"位置",top:"上",bottom:"下"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},y_axis:{label:"Y轴",labels:"Y轴",label_format:"刻度文案格式",add:"增加一条Y轴",delete:"删除这条Y轴",y_axis_name:"Y轴名称",y_axis_name_anchor:"名称贴靠侧",y_axis_data_field:"Y轴数据字段",layout:"布局",position:{label:"位置",left:"左",right:"右"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},stats:{label:"统计内容",template:{above_chart:"统计内容模板(图表上方)",under_chart:"统计内容模板(图表下方)"}},legend:{label:"图例",show_legend:"显示图例",show_in_legend:"显示在图例中",hide_in_legend:"不显示在图例中",orientation:{label:"布局朝向",horizontal:"横向",vertical:"纵向"}},tooltip:{label:"提示框",additional_metrics:{description:"在此设置更多指标,来展示在散点的提示框",add:"增加一个指标",delete:"删除这个指标"},trigger:{label:"触发者",scatter_point:"散点",x_axis:"X轴"}},style:{label:"样式"},color:{label:"颜色",or:"或",set_any_color:"输入色号",pick_a_theme_color:"选择一个主题色",background_color:"背景色",text_color:"文字颜色",click_to_add_a_color:"点击增加一个颜色",color_gradient:"颜色渐变"},behavior:{label:"表现",invisible:"隐藏不可见"},heatmap:{heatblock:{label:"热力块",show_label:"展示值文案"}},reference_line:{label:"参考线",labels:"参考线",add:"增加一条参考线",name_placeholder:"均值参考线",delete:"删除这条参考线",orientation:{vertical_hint:"仅当X轴值为数字时可绘制"}},regression_line:{label:"回归线",labels:"回归线",add:"增加一条回归线",delete:"删除这条回归线",method:{label:"方法",linear:"线性回归",exponential:"指数回归",logistic:"指数回归",polynomial:"多项式回归",polynomial_order:"次"}},reference_area:{label:"参考区域",labels:"参考区域",add:"增加一面参考区域",delete:"删除这面参考区域",type:{label:"形状",rectangle:"矩形"},direction:{label:"方向",horizontal:"水平"},boundary:{upper:"上边界",lower:"下边界"},content:{label:"内容",content_text:"内容文字",text_position:"文字位置"},endpoint:{labels:"端点",left_bottom_point:"左下点",right_top_point:"右上点"}},zooming:{label:"缩放",scroll:{label:"滚轮缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用"},slider:{label:"滚动条缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用",y_axis_disabled:"暂不可用,会与Y轴刻度文字重叠"}}},viz:{viz_config_banner:"可视化参数配置"},validation:{number:{require_a_number:"请填写一个数字"}}}},hs=vd.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:Lk,zh:qk}}).use(_d).use(_.initReactI18next);hs.init(),Dl.forEach(t=>{var e;(e=t.translation)==null||e.forEach(n=>{hs.addResourceBundle(n.lang,"translation",{viz:n.resources},!0,!0)})});function Gc({lang:t,children:e}){return m.useEffect(()=>{hs.changeLanguage(t)},[t]),s.jsx(_.I18nextProvider,{i18n:hs,children:e})}function ms(t){console.groupCollapsed("Running operation ",t.type),console.log(t),console.groupEnd()}function Fc(t,e){m.useEffect(()=>{const n=r=>{ms(r);const{viewID:i}=r.detail;if(!i){console.error(new Error("[Open View] Needs to pick a view first"));return}t.views.appendToVisibles(i),e&&t.views.setIDOfVIE(i)};return window.addEventListener("open-view",n),()=>{window.removeEventListener("open-view",n)}},[t,e]),m.useEffect(()=>{const n=r=>{ms(r);const{dictionary:i,payload:o}=r.detail;if(!o||Object.keys(o).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}const l={};Object.entries(i).forEach(([c,u])=>{const d=b.get(o,u);l[c]=d}),t.filters.applyValuesPatch(l)};return window.addEventListener("set-filter-values",n),()=>{window.removeEventListener("set-filter-values",n)}},[t]),m.useEffect(()=>{function n(i){return Array.isArray(i)?[]:typeof i=="object"?{}:typeof i=="boolean"?!1:typeof i=="string"?"":typeof i=="number"?0:i}const r=i=>{ms(i);const o={},{filter_keys:l}=i.detail;l.forEach(c=>{const u=b.get(t.filters.values,c),d=n(u);o[c]=d}),t.filters.applyValuesPatch(o)};return window.addEventListener("clear-filter-values",r),()=>{window.removeEventListener("clear-filter-values",r)}},[t]),m.useEffect(()=>{const n=r=>{ms(r);const{urlTemplate:i,openInNewTab:o,enableEncoding:l=!1,payload:c}=r.detail;if(!i){console.error(new Error("[Open Link] URL is empty"));return}function u(h){return b.cloneDeepWith(h,f=>{if(l&&typeof f=="string")return encodeURIComponent(f)})}const p=b.template(i||"")(u({...c,filters:t.payloadForSQL.filters,context:t.payloadForSQL.context}));window.open(p,o?"_blank":"_self","noopener")};return window.addEventListener("open-link",n),()=>{window.removeEventListener("open-link",n)}},[t])}function Wc(t){return m.useCallback(e=>e.provideValue(me.pluginManager,t.pluginManager).provideValue(me.vizManager,t.vizManager).provideValue(me.colorManager,t.colorManager),[])}const NM="",Ok=S.observer(({saveDashboardChanges:t})=>{const{t:e}=_.useTranslation(),n=Fe.useModals(),r=Y(),i=()=>{n.openConfirmModal({title:s.jsxs(a.Group,{position:"left",children:[s.jsx(k.IconAlertTriangle,{size:18,color:"red"}),s.jsx(a.Text,{children:"You are reverting changes"})]}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>r.reset(),zIndex:320,withCloseButton:!1})},o=r.changed;return s.jsxs(a.Group,{spacing:0,children:[s.jsx(a.Button,{color:"green",variant:"filled",size:"xs",leftIcon:s.jsx(k.IconDeviceFloppy,{size:18}),onClick:t,disabled:!o,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:e("common.actions.save_changes")}),s.jsxs(a.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!o,children:[s.jsx(a.Menu.Target,{children:s.jsx(a.ActionIcon,{variant:"default",disabled:!o,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:s.jsx(k.IconCaretDown,{size:18})})}),s.jsx(a.Menu.Dropdown,{children:s.jsx(a.Menu.Item,{icon:s.jsx(k.IconRecycle,{size:14,color:"red"}),disabled:!o,onClick:i,children:e("common.actions.revert_changes")})})]})]})}),Vk=S.observer(({saveDashboardChanges:t,onExit:e,headerSlot:n=null})=>{_.useTranslation();const r=Z(),i=r.content.changed,o=()=>{e({hasChanges:i,dashboardId:r.id})};return s.jsx(a.Header,{height:60,px:"md",py:0,sx:{zIndex:299},children:s.jsxs(a.Group,{position:"apart",sx:{height:60,minWidth:"1000px",position:"relative"},children:[s.jsxs(a.Group,{children:[s.jsx(a.Button,{size:"xs",color:i?"red":"green",leftIcon:s.jsx(k.IconArrowLeft,{size:20}),onClick:o,children:s.jsx(a.Group,{spacing:4,children:s.jsxs(_.Trans,{i18nKey:"common.actions.end_editing",values:{name:r.name},children:["End Editing ",s.jsx(a.Text,{td:"underline",children:r.name})]})})}),s.jsx(Ok,{saveDashboardChanges:t})]}),s.jsx(a.Group,{position:"right",sx:{flexGrow:1},children:n})]})})}),Qc={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},Nk=S.observer(()=>{var i;const{t}=_.useTranslation(),e=Y(),n=((i=e.views.VIE)==null?void 0:i.type)===B.Tabs,r=()=>e.addANewPanel(e.views.idOfVIE);return n?s.jsx(a.Tooltip,{label:t("common.choose_a_tab_first"),children:s.jsx(a.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:s.jsx(k.IconPlaylistAdd,{size:20}),sx:{...Qc,transform:"none !important"},children:t("panel.add")})}):s.jsx(a.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:r,leftIcon:s.jsx(k.IconPlaylistAdd,{size:20}),sx:{...Qc,background:"rgb(231, 245, 255)"},children:t("panel.add")})}),Gk=S.observer(({done:t})=>{var F,N;const{t:e}=_.useTranslation(),r=Y().layouts,i=m.useMemo(()=>({list:r.breakpointsInfo}),[r.breakpointsInfo]),{control:o,handleSubmit:l,watch:c,getValues:u,reset:d,formState:p}=y.useForm({defaultValues:i}),{fields:h,append:g,remove:f}=y.useFieldArray({control:o,name:"list",rules:{validate:Q=>{if(console.log({values:Q}),b.uniqBy(Q,"breakpoint").length!==Q.length)return"Screen sizes should be unique by min width"}}}),v=c("list"),w=h.map((Q,ue)=>({...Q,...v[ue]})),T=()=>{g({id:pt.v4(),name:"",breakpoint:""})},D=({list:Q})=>{const ue=Q.filter(le=>Number.isFinite(le.breakpoint));r.updateLayoutSetsInfo(ue),t()},z=u(),E=m.useMemo(()=>{const Q={list:z.list.filter(ue=>!!ue.name&&Number.isFinite(ue.breakpoint))};return!b.isEqual(Q,i)},[z,i]),V=(N=(F=p.errors.list)==null?void 0:F.root)==null?void 0:N.message;return s.jsx(s.Fragment,{children:s.jsxs("form",{onSubmit:l(D),children:[s.jsxs(a.Table,{fontSize:"sm",highlightOnHover:!0,withBorder:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"340px"},children:e("common.name")}),s.jsx("th",{style:{width:"160px"},children:e("breakpoint.breakpoint")}),s.jsx("th",{})]})}),s.jsxs("tbody",{children:[w.map((Q,ue)=>s.jsxs("tr",{children:[s.jsx("th",{children:Q.id==="basis"?Q.name:s.jsx(y.Controller,{name:`list.${ue}.name`,control:o,render:({field:le})=>s.jsx(a.TextInput,{size:"xs",label:"",required:!0,sx:{flex:1},...le})})}),s.jsx("td",{children:Q.id==="basis"?s.jsxs(a.Text,{ff:"monospace",children:[Q.breakpoint,"px"]}):s.jsx(y.Controller,{name:`list.${ue}.breakpoint`,control:o,render:({field:le})=>s.jsx(a.NumberInput,{size:"xs",label:"",required:!0,max:1e4,hideControls:!0,rightSection:s.jsx(a.Text,{color:"dimmed",children:"px"}),rightSectionProps:{style:{width:"30px"}},sx:{flex:1,fontFamily:"monospace"},styles:{input:{paddingRight:"30px"}},...le})})}),s.jsx("td",{children:Q.id!=="basis"&&s.jsx(a.ActionIcon,{mx:"auto",size:"xs",variant:"subtle",color:"red",onClick:()=>f(ue),children:s.jsx(k.IconTrash,{})})})]},Q.id)),s.jsx("tr",{style:{backgroundColor:"transparent"},children:s.jsx("td",{colSpan:3,style:{padding:"0"},children:s.jsx(a.Tooltip,{label:e("breakpoint.add"),children:s.jsx(a.ActionIcon,{variant:"subtle",size:"md",color:"blue",onClick:T,sx:{width:"100%"},children:s.jsx(k.IconPlus,{size:18})})})})})]})]}),s.jsx(a.Text,{mt:6,ta:"right",size:"xs",color:"red",children:V??" "}),s.jsxs(a.Group,{mt:6,position:"apart",children:[s.jsx(a.Button,{color:"orange",size:"xs",onClick:()=>d(),leftIcon:s.jsx(k.IconRecycle,{size:18}),disabled:!E,children:e("common.actions.revert")}),s.jsx(a.Button,{color:"green",size:"xs",type:"submit",leftIcon:s.jsx(k.IconDeviceFloppy,{size:18}),disabled:!E,children:e("common.actions.save_changes")})]})]})})}),Fk=S.observer(()=>{const{t}=_.useTranslation(),[e,{open:n,close:r}]=ie.useDisclosure(!1),i=Y(),o=i.layouts.currentBreakpoint,l=i.layouts.currentLayoutRange,c=()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},u=()=>{r(),c()};return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{children:[s.jsxs(a.Menu,{withArrow:!0,withinPortal:!0,zIndex:320,trigger:"hover",children:[s.jsx(a.Menu.Target,{children:s.jsx(a.Button,{size:"xs",variant:"subtle",leftIcon:s.jsx(k.IconDevices,{size:16}),sx:{borderRadius:0},children:s.jsxs(a.Group,{spacing:6,children:[s.jsx(a.Text,{size:"xs",fw:"normal",children:l.name}),s.jsx(a.Text,{size:"xs",color:"#777",children:i.layouts.currentRangeText})]})})}),s.jsxs(a.Menu.Dropdown,{children:[i.layouts.breakpointRanges.map(d=>s.jsx(a.Menu.Item,{onClick:()=>i.layouts.setCurrentBreakpoint(d.id),disabled:o===d.id,children:s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Text,{size:"sm",children:d.name}),s.jsx(a.Text,{size:"xs",color:"dimmed",children:d.text})]})},d.id)),s.jsx(a.Menu.Divider,{}),s.jsx(a.Menu.Item,{color:"blue",icon:s.jsx(k.IconSettings,{size:14}),onClick:n,children:s.jsx(a.Text,{size:"sm",children:t("breakpoint.manage")})})]})]}),i.layouts.divisionPreviewScale<1&&s.jsx(a.Text,{size:"xs",color:"dimmed",children:Cn(i.layouts.divisionPreviewScale).format({output:"percent",mantissa:0})})]}),s.jsx(a.Modal,{opened:e,onClose:u,title:t("breakpoint.label",{count:2}),withinPortal:!0,zIndex:320,size:600,closeOnClickOutside:!1,children:s.jsx(Gk,{done:u})})]})}),Rc={height:"30px",borderRight:"none",borderTop:"none",borderLeft:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},Wk=S.observer(()=>{var i;const{t}=_.useTranslation(),e=Y(),n=((i=e.views.VIE)==null?void 0:i.type)===B.Tabs,r=()=>{var o;return(o=e.views.VIE)==null?void 0:o.downloadSchema()};return n?s.jsx(a.Tooltip,{label:t("common.choose_a_tab_first"),children:s.jsx(a.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:s.jsx(k.IconCode,{size:16}),sx:{...Rc,transform:"none !important"},children:t("view.download_schema")})}):s.jsx(a.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:r,leftIcon:s.jsx(k.IconCode,{size:16}),sx:{...Rc},children:t("view.download_schema")})}),xs=({headers:t,rows:e})=>s.jsxs(a.Table,{fontSize:"xs",highlightOnHover:!0,sx:{tableLayout:"fixed",fontFamily:"monospace"},children:[s.jsx("thead",{children:t}),s.jsx("tbody",{children:e})]}),Qk=({content:t})=>{const{t:e}=_.useTranslation(),n=t.views;return!Array.isArray(n)||n.length===0?null:s.jsxs(a.Box,{children:[s.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("view.labels")}),s.jsx(xs,{headers:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"160px"},children:e("common.id")}),s.jsx("th",{children:e("common.name")}),s.jsx("th",{children:e("common.type")})]}),rows:n.map(r=>s.jsxs("tr",{children:[s.jsx("td",{children:r.id}),s.jsx("td",{children:r.name}),s.jsx("td",{children:e(`view.component.${r.type}.label`)})]},r.id))})]})},Rk=({content:t})=>{const{t:e}=_.useTranslation(),n=t.filters;return!Array.isArray(n)||n.length===0?null:s.jsxs(a.Box,{children:[s.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("filter.labels")}),s.jsx(xs,{headers:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"160px"},children:e("common.id")}),s.jsx("th",{children:e("common.key")}),s.jsx("th",{children:e("common.label")})]}),rows:n.map(r=>s.jsxs("tr",{children:[s.jsx("td",{children:r.id}),s.jsx("td",{children:r.key}),s.jsx("td",{children:r.label})]},r.id))})]})},Uk=({content:t})=>{const{t:e}=_.useTranslation(),n=t.panels;return!Array.isArray(n)||n.length===0?null:s.jsxs(a.Box,{children:[s.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("panel.labels")}),s.jsx(xs,{headers:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"160px"},children:e("common.id")}),s.jsx("th",{children:e("common.name")}),s.jsx("th",{children:e("visualization.component")})]}),rows:n.map(r=>s.jsxs("tr",{children:[s.jsx("td",{children:r.id}),s.jsx("td",{children:r.name}),s.jsx("td",{children:r.viz.type})]},r.id))})]})},Yk=({content:t})=>{var r;const{t:e}=_.useTranslation(),n=(r=t.definition)==null?void 0:r.queries;return!Array.isArray(n)||n.length===0?null:s.jsxs(a.Box,{children:[s.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("query.labels")}),s.jsx(xs,{headers:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"160px"},children:e("common.id")}),s.jsx("th",{children:e("common.name")}),s.jsx("th",{style:{width:"140px"},children:e("common.type")}),s.jsx("th",{style:{width:"260px"},children:e("data_source.label")})]}),rows:n.map(i=>s.jsxs("tr",{children:[s.jsx("td",{children:i.id}),s.jsx("td",{children:i.name}),s.jsx("td",{children:i.type}),s.jsx("td",{children:i.key})]},i.id))})]})},Kk=({content:t})=>{var r;const{t:e}=_.useTranslation(),n=(r=t.definition)==null?void 0:r.sqlSnippets;return!Array.isArray(n)||n.length===0?null:s.jsxs(a.Box,{children:[s.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("sql_snippet.labels")}),s.jsx(a.List,{size:"sm",pl:10,ff:"monospace",icon:s.jsx(k.IconPointFilled,{size:10}),children:n.map(i=>s.jsx(a.List.Item,{children:i.key},i.key))})]})},Jk=({content:t})=>{var r;const{t:e}=_.useTranslation(),n=Object.keys(((r=t.definition)==null?void 0:r.mock_context)??{});return n.length===0?null:s.jsxs(a.Box,{children:[s.jsx(a.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("mock_context.label")}),s.jsx(a.List,{size:"sm",pl:10,ff:"monospace",icon:s.jsx(k.IconPointFilled,{size:10}),children:n.map(i=>s.jsx(a.List.Item,{children:i},i))})]})},Xk=({content:t})=>t?s.jsxs(a.Box,{children:[s.jsx(a.Divider,{mt:20,mb:10,variant:"dashed"}),s.jsx(a.Text,{ta:"left",c:"dimmed",children:"Preview"}),s.jsxs(a.Stack,{children:[s.jsx(Qk,{content:t}),s.jsx(Rk,{content:t}),s.jsx(Uk,{content:t}),s.jsx(Yk,{content:t}),s.jsx(Kk,{content:t}),s.jsx(Jk,{content:t})]})]}):null;function Zk(t){if(t.target===null)throw new Error("FileReader failed with null result");if(typeof t.target.result!="string")throw new Error(`Unparsable file content of type: ${typeof t.target.result}`);let e=JSON.parse(t.target.result);if("content"in e&&(e=e.content),e.version!==yt)throw new Error("Schema version mismatch");return e}const Hk=S.observer(({onSuccess:t,stretchModal:e,shrinkModal:n})=>{var D,z;const{t:r}=_.useTranslation(),i=Y(),{handleSubmit:o,formState:{errors:l},setValue:c,watch:u,setError:d,clearErrors:p}=y.useForm({defaultValues:{content:null}}),h=({content:E})=>{try{if(!E)throw new Error("please use a valid json file");i.applyJSONSchema(E),_t.showNotification({title:"Successful",message:"",color:"green"}),t()}catch(V){console.error(V),_t.showNotification({title:"Failed",message:V.message,color:"red"})}},[g,f]=m.useState(null);m.useEffect(()=>{if(!g)return;const E=new FileReader;E.readAsText(g,"UTF-8"),E.onload=V=>{try{const F=Zk(V);c("content",F),p("content")}catch(F){console.error(F),d("content",{type:"custom",message:F.message})}},E.onabort=()=>console.log("🟨 abort"),E.onerror=()=>{E.error&&(console.error(E.error),d("content",{type:"custom",message:E.error.message}))}},[g]);const[v]=u(["content"]),w=!v,T=(D=l==null?void 0:l.content)==null?void 0:D.message;return m.useEffect(()=>{!v||T?n():e()},[v,T]),s.jsx(a.Box,{mx:"auto",sx:{position:"relative"},children:s.jsxs("form",{onSubmit:o(h),children:[s.jsx(a.FileInput,{label:r("import.json_file"),required:!0,value:g,onChange:f,error:(z=l==null?void 0:l.content)==null?void 0:z.message,sx:{maxWidth:500}}),T?s.jsx(a.Table,{fontSize:12,mt:10,children:s.jsxs("tbody",{children:[s.jsxs("tr",{children:[s.jsx("th",{children:r("import.this_dashboard")}),s.jsx("td",{children:yt})]}),s.jsxs("tr",{children:[s.jsx("th",{children:r("import.this_file")}),s.jsx("td",{style:{color:"red"},children:v==null?void 0:v.version})]})]})}):s.jsxs(s.Fragment,{children:[s.jsx(Xk,{content:v}),s.jsx(a.Group,{position:"right",my:"md",children:s.jsx(a.Button,{type:"submit",color:"green",disabled:w,children:r("common.actions.confirm")})})]})]})})}),Uc={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},eT=S.observer(()=>{var d;const{t}=_.useTranslation(),[e,{open:n,close:r}]=ie.useDisclosure(!1),[i,{setTrue:o,setFalse:l}]=W.useBoolean(!1),u=((d=Z().content.views.VIE)==null?void 0:d.type)===B.Tabs;return u?s.jsx(a.Tooltip,{label:t("common.choose_a_tab_first"),children:s.jsx(a.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:s.jsx(k.IconFileImport,{size:16}),sx:{...Uc,transform:"none !important"},children:t("import.label")})}):s.jsxs(s.Fragment,{children:[s.jsx(a.Button,{variant:"subtle",color:"blue",radius:0,size:"xs",disabled:u||e,onClick:n,leftIcon:s.jsx(k.IconFileImport,{size:16}),sx:{...Uc},children:t("import.label")}),s.jsx(a.Modal,{opened:e,onClose:r,title:t("import.title"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},withinPortal:!0,zIndex:320,size:i?"90vw":500,children:s.jsx(Hk,{onSuccess:r,stretchModal:o,shrinkModal:l})})]})}),tT={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},nT=S.observer(()=>s.jsx(a.Box,{sx:tT,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:s.jsxs(a.Group,{position:"apart",align:"center",sx:{height:"30px"},children:[s.jsxs(a.Group,{position:"left",spacing:0,children:[s.jsx(Nk,{}),s.jsx(eT,{})]}),s.jsx(Fk,{}),s.jsx(a.Group,{position:"right",spacing:0,children:s.jsx(Wk,{})})]})})),sT=S.observer(t=>s.jsxs(s.Fragment,{children:[s.jsx(Vk,{...t}),s.jsx(nT,{})]})),GM="";function rT(t,e,n){const r=[];return t.filter(i=>"__INTERACTIONS"in i.viz.conf).forEach((i,o)=>{const l=e[i.id];l.data.interactions=b.get(l,"data.interactions",[]);const{__INTERACTIONS:c,__OPERATIONS:u,__TRIGGERS:d}=i.viz.conf;Object.entries(u).forEach(([p,h])=>{const{schemaRef:g,data:f}=h,{config:v}=f;switch(g){case"builtin:op:open-link":let w=v.urlTemplate.substring(0,100);v.urlTemplate.length>=20&&(w+="..."),l.type="interaction",l.data.interactions.push({schemaRef:g,urlTemplate:v.urlTemplate,shortURLTemplate:w});return;case"builtin:op:open_view":r.push({id:`OPERATION--${p}`,source:i.id,target:v.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:g,filters:Object.keys(v.dictionary).map(T=>({key:T,label:n[T]}))});return;case"builtin:op:clear_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:g,filters:v.filter_keys.map(T=>({key:T,label:n[T]}))});return;default:return}})}),r}function iT(t,e){const n=t.filters.keyLabelMap;return{edges:rT(t.panels.list,e,n),edgeNodes:[]}}function Yc(t,e,n){return t*e+t*n}function aT(t,e,n){return t*e+(t-1)*n}const gs=25,ki=40,Kc=25,Ti=350,oT=150,lT=150,Jc=150,Xc=300,fs=40,Zc=25,cT=300;function uT(t,e){const n=b.keyBy(e,i=>i.id),r=[];return t.current.forEach((i,o)=>{i.panelIDs.forEach((l,c)=>{const u=Yc(c,fs,Zc)+ki,d=n[l];if(!d){r.push({id:l,_node_type:"panel",parentNode:i.id,data:{label:`!: ${l}`},position:{x:gs,y:u},sourcePosition:we.Position.Right,targetPosition:we.Position.Left,style:{width:Xc,height:fs}});return}const p=d.name;r.push({id:d.id,_node_type:"panel",parentNode:i.id,data:{label:p},position:{x:gs,y:u},sourcePosition:we.Position.Right,targetPosition:we.Position.Left,style:{width:Xc,height:fs}})})}),r}const dT={[B.Division]:"Div",[B.Modal]:"Modal",[B.Tabs]:"Tabs"},pT=Ic;function hT(t){return t.current.map((n,r)=>{const i=aT(n.panelIDs.length,fs,Zc)+ki+Kc;let o=[];return n.type===B.Tabs&&(o=n.config.tabsInOrder.map(c=>c.view_id)),{id:n.id,_node_type:"view-root",_view_type:n.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:o,data:{label:`${dT[n.type]}:${n.name}`},position:{x:0,y:0},sourcePosition:we.Position.Right,targetPosition:we.Position.Left,className:"light",style:{backgroundColor:pT[n.type],width:Ti,height:i}}})}function mT(t){const e=b.keyBy(t,n=>n.id);t.forEach(n=>{n._node_type!=="view-root"||n._view_type!==B.Tabs||n._tab_view_ids.forEach(r=>{e[r].parentNode=n.id})})}function xT(t){const e=hT(t.views);mT(e);const n=uT(t.views,t.panels.list);return[...e,...n]}function gT({nodeMap:t,nodes:e,edges:n}){e.forEach(r=>{r._node_type!=="view-root"||r._view_type!==B.Tabs||(r.sourcePosition=we.Position.Bottom,r.style.width=Ti+gs*2,r.style.height=Kc+r._tab_view_ids.reduce((i,o)=>{const l=t[o];l.position.y=i,l.position.x=gs;const c=l.style.height;return i+c+20},ki))})}function fT({nodeMap:t,nodes:e,edges:n}){n.filter(r=>r.label==="Open View").forEach(r=>{const i=t[r.source],o=t[r.target];if(!i||!o||!i.parentNode)return;const l=t[i.parentNode];l._node_type!=="view-root"||o._node_type!=="view-root"||(o._view_level+=1+l._view_level,l._sub_view_ids.push(o.id))}),e.sort((r,i)=>r._node_type==="view-root"&&i._node_type==="view-root"?r._view_level-i._view_level:r._node_type!=="view-root"&&i._node_type!=="view-root"?0:r._node_type==="view-root"?-1:1)}function yT({nodeMap:t,nodes:e,edges:n}){const r={};n.forEach(i=>{if(i.label!=="Open View")return;const o=t[i.source],l=t[i.target];if(o&&l&&o.parentNode){const c=t[o.parentNode],u=c.position.x,d=Number(b.get(l,"style.height",0)),p=Number(c.style.width);l.position.x=u+p+cT,c._view_level===0&&l._sub_view_ids.length===0&&(o.sourcePosition=we.Position.Left,l.targetPosition=we.Position.Right,l.position.x*=-1);const g=l.position.x,f=b.get(r,g,0);l.position.y=f,r[g]=f+d+Jc}})}function bT({nodeMap:t,nodes:e,edges:n}){const r=new Set,i=new Set;n.forEach(l=>{r.add(l.source),i.add(l.target)}),e.filter(l=>l._node_type!=="view-root"||l.id==="Main"||l.parentNode?!1:!r.has(l.id)&&!i.has(l.id)).forEach((l,c)=>{l.position.x=Yc(c,Ti,lT),l.position.y=0-oT-Jc})}function vT({nodeMap:t,nodes:e,edges:n}){const r={nodeMap:t,nodes:e,edges:n};return bT(r),fT(r),gT(r),yT(r),{nodes:e,edges:n}}function _T(t){const e=xT(t),n=b.keyBy(e,u=>u.id),{edges:r,edgeNodes:i}=iT(t,n),o=[...e,...i],l=b.keyBy(o,u=>u.id),c={edges:b.uniqBy(r,u=>u.id),nodes:o,nodeMap:l};return vT(c)}const FM="",Di={"builtin:op:open-link":s.jsx(a.ThemeIcon,{color:"blue",size:20,radius:"xl",children:s.jsx(k.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":s.jsx(a.ThemeIcon,{color:"orange",size:20,radius:"xl",children:s.jsx(k.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":s.jsx(a.ThemeIcon,{color:"orange",size:20,radius:"xl",children:s.jsx(k.IconCircleOff,{size:14})})};function jT(t){const e=[];return t.forEach(n=>{switch(n.schemaRef){case"builtin:op:open-link":e.push({key:n.urlTemplate,icon:Di[n.schemaRef],text:s.jsxs(a.Group,{spacing:4,children:[s.jsx(a.Text,{children:"Open: "}),s.jsx(a.Text,{color:"dimmed",children:n.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":n.filters.forEach(({key:r,label:i})=>{e.push({key:n.schemaRef+r,icon:Di[n.schemaRef],text:s.jsx(a.Group,{spacing:4,children:s.jsxs(a.Text,{children:["Set Filter: ",i]})})})});return;case"builtin:op:clear_filter_values":n.filters.forEach(({key:r,label:i})=>{e.push({key:n.schemaRef+r,icon:Di[n.schemaRef],text:s.jsx(a.Group,{spacing:4,children:s.jsxs(a.Text,{children:["Clear Filter: ",i]})})})});return}}),e}const wT=m.memo(({data:t,isConnectable:e,sourcePosition:n=we.Position.Right,targetPosition:r=we.Position.Left,...i})=>{const o=m.useMemo(()=>jT(t.interactions),[t.interactions]);return s.jsxs(s.Fragment,{children:[s.jsx(we.Handle,{type:"target",position:r,isConnectable:e}),s.jsx(a.Box,{sx:{position:"absolute",top:0,right:0},children:s.jsx(L.ChevronsUpRight,{size:12})}),s.jsxs(a.HoverCard,{shadow:"xl",withinPortal:!0,children:[s.jsx(a.HoverCard.Target,{children:s.jsx(a.Text,{children:t.label})}),s.jsx(a.HoverCard.Dropdown,{children:s.jsx(a.List,{spacing:"xs",size:"sm",center:!0,children:o.map(l=>s.jsx(a.List.Item,{icon:l.icon,children:l.text},l.key))})})]}),s.jsx(we.Handle,{type:"source",position:n,isConnectable:e})]})}),WM="",CT={interaction:wT},ST=S.observer(()=>{const t=he(),{edges:e,nodes:n}=_T(t);return s.jsxs(we,{nodes:n,edges:e,onNodesChange:b.noop,onEdgesChange:b.noop,onConnect:b.noop,className:"interactions-viewer",fitView:!0,nodeTypes:CT,children:[s.jsx(we.MiniMap,{}),s.jsx(we.Controls,{}),s.jsx(we.Background,{})]})}),kT=S.observer(({opened:t,close:e})=>{const{t:n}=_.useTranslation();return s.jsx(a.Modal,{size:"96vw",opened:t,onClose:e,title:n("interactions.interactions_viewer"),trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{body:{height:"calc(90vh - 54px)"},content:{transform:"none !important"}},zIndex:300,children:s.jsx(ST,{})})}),TT={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}};function DT({onClick:t,name:e,active:n,openSettings:r}){return s.jsxs(a.Box,{sx:{position:"relative"},children:[s.jsx(a.UnstyledButton,{sx:i=>({display:"block",width:"100%",padding:i.spacing.xs,borderRadius:0,position:"relative",color:i.black,"&:hover":{backgroundColor:i.colors.gray[0]},backgroundColor:n?i.colors.gray[2]:"transparent"}),children:s.jsx(a.Group,{sx:{width:"calc(100% - 28px)"},onClick:t,children:s.jsx(a.Text,{size:"sm",children:e})})}),n&&s.jsx(a.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:s.jsx(a.ActionIcon,{onClick:r,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:s.jsx(k.IconAdjustments,{size:16})})})]})}const zT=S.observer(()=>{const{t}=_.useTranslation(),e=Z(),n=Y(),r=m.useCallback(o=>()=>n.views.setIDOfVIE(o),[n]),i=o=>{e.editor.open(["_VIEWS_",o])};return s.jsxs(a.Box,{sx:{position:"relative"},children:[n.views.options.map(o=>s.jsx(DT,{active:n.views.idOfVIE===o.value,name:o.label,onClick:r(o.value),openSettings:()=>i(o.value)},o.value)),s.jsx(a.Divider,{variant:"dashed"}),s.jsx(a.Button,{variant:"subtle",rightIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:n.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:t("view.add")})]})}),MT=S.observer(()=>{const{t}=_.useTranslation(),e=Z(),n=Y(),r=()=>{if(!n.queries.firstID){e.editor.open(["_QUERIES_",""]);return}e.editor.open(["_QUERIES_",n.queries.firstID])},i=()=>{if(!n.filters.firstID){e.editor.open(["_FILTERS_",""]);return}e.editor.open(["_FILTERS_",n.filters.firstID])},[o,l]=m.useState(!1),c=()=>l(!0),u=()=>l(!1);return s.jsxs(a.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},zIndex:299,children:[s.jsxs(a.Navbar.Section,{children:[s.jsxs(a.Group,{grow:!0,spacing:0,sx:{...TT,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[s.jsx(a.Tooltip,{label:t("filter.labels"),withinPortal:!0,children:s.jsx(a.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:i,children:s.jsx(k.IconFilter,{size:18})})}),s.jsx(a.Tooltip,{label:t("query.labels"),withinPortal:!0,children:s.jsx(a.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:r,children:s.jsx(k.IconDatabase,{size:18})})}),s.jsx(a.Tooltip,{label:t("interactions.interactions_viewer"),withinPortal:!0,children:s.jsx(a.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:c,children:s.jsx(k.IconLink,{size:18})})})]}),s.jsx(kT,{opened:o,close:u})]}),s.jsx(a.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:s.jsx(a.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:t("view.labels")})}),s.jsx(a.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:s.jsx(zT,{})}),s.jsx(a.Navbar.Section,{children:s.jsx(a.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:s.jsx(a.Button,{size:"xs",leftIcon:s.jsx(k.IconSettings,{size:20}),onClick:()=>e.editor.open([]),children:t("common.titles.settings")})})})]})}),IT={[re.Checkbox]:"true",[re.DateRange]:"[new Date('2023-01-01 00:00:00'), new Date('2024-01-01 00:00:00')]",[re.MultiSelect]:"[]",[re.Select]:'""',[re.TreeSelect]:"[]",[re.TextInput]:'""'},ET=t=>["function getDefaultValue(filter, utils, context) {",` return ${IT[t]};`,"}"].join(`
449
- `),Ht=S.observer(({filter:t})=>{const{t:e}=_.useTranslation();return s.jsx(Po,{label:"",title:e("filter.field.custom_default_value.title"),triggerLabel:e("filter.field.custom_default_value.trigger"),value:t.default_value_func,onChange:t.setDefaultValueFunc,defaultValue:ET(t.type),triggerButtonProps:{size:"xs",color:"grape",sx:{flexGrow:0,alignSelf:"flex-start"},leftIcon:s.jsx(k.IconMathFunction,{size:16})},description:s.jsx(a.Alert,{title:e("filter.field.custom_default_value.tips"),color:"gray",mb:16,children:s.jsxs(a.List,{size:13,type:"ordered",children:[s.jsx(a.List.Item,{children:e("filter.field.custom_default_value.tip_1")}),s.jsx(a.List.Item,{children:e("filter.field.custom_default_value.tip_2")})]})})})}),AT=S.observer(function({filter:e}){const{t:n}=_.useTranslation(),r=e.config;return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Checkbox,{checked:r.default_value,onChange:i=>r.setDefaultValue(i.currentTarget.checked),label:n("filter.widget.checkbox.default_checked")}),s.jsx(Ht,{filter:e})]}),s.jsx(Tr,{label:n("filter.widget.checkbox.description"),value:r.description,onChange:r.setDescription,styles:{root:{flexGrow:1,minHeight:"400px"}}})]})}),PT=[{label:"2022",value:"YYYY"},{label:"202201",value:"YYYYMM"},{label:"20220101",value:"YYYYMMDD"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],$T=S.observer(function({filter:e}){const{t:n}=_.useTranslation(),r=e.config,i=m.useMemo(()=>Qr().map(({key:o,value:l,group:c})=>({label:n(`filter.widget.date_range.shortcut.${c}.full.${o}`),value:l,group:n(`filter.widget.date_range.shortcut.${c}.label`)})),[]);return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{children:[s.jsx(a.Checkbox,{checked:r.required,onChange:o=>r.setRequired(o.currentTarget.checked),label:n("filter.widget.date_range.required")}),s.jsx(a.Checkbox,{checked:r.allowSingleDateInRange,onChange:o=>r.setAllowSingleDateInRange(o.currentTarget.checked),label:n("filter.widget.date_range.allow_single_date")})]}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(a.Select,{data:PT,label:n("filter.widget.date_range.display_format"),value:r.inputFormat,onChange:r.setInputFormat}),s.jsx(a.NumberInput,{label:n("filter.widget.date_range.max_days"),min:0,value:r.max_days,onChange:r.setMaxDays,hideControls:!0})]}),s.jsxs(a.Group,{children:[s.jsx(Al,{label:n("filter.widget.date_range.default_value"),config:r,value:r.default_value,onChange:r.setDefaultValue,disabled:!!r.default_shortcut}),s.jsx(a.Select,{data:i,label:n("filter.widget.date_range.default_by_shortcut"),value:r.default_shortcut,onChange:r.setDefaultShortcut,placeholder:n("filter.widget.date_range.default_by_shortcut_placeholder"),clearable:!0,sx:{flexGrow:1},maxDropdownHeight:500})]}),s.jsx(Ht,{filter:e})]})}),zi=S.observer(({value:t,onChange:e})=>{const{t:n}=_.useTranslation(),r=Z(),i=Y(),o=m.useMemo(()=>i.queries.options,[i.queries.current]),l=o.length===0,c=u=>{r.editor.setPath(["_QUERIES_",u])};return s.jsx(a.Select,{label:s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Text,{children:n("filter.widget.common.use_query_data_as_options")}),t&&s.jsx(a.Button,{size:"xs",leftIcon:s.jsx(k.IconArrowCurveRight,{size:16}),variant:"subtle",color:"blue",onClick:()=>c(t),children:n("query.open")})]}),data:o,value:t,onChange:e,allowDeselect:!1,clearable:!0,sx:{flexGrow:1},disabled:l,error:l?"You need to add a query in Data Settings":void 0,styles:{label:{display:"block"}}})}),BT=`
449
+ FROM ${n}.${t}
450
+ `}})).actions(e=>({setPage(t){e.page=t},resetPage(){e.page=1},setLimit(t){e.limit=t}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>e.keywordString,e.resetPage,{fireImmediately:!1,delay:0})),x.addDisposer(e,X.reaction(()=>e.limit,e.resetPage,{fireImmediately:!1,delay:0}))}})),SE=x.types.model({data:x.types.optional(x.types.frozen(),{}),state:x.types.optional(x.types.enumeration(["idle","loading","error"]),"idle"),error:x.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return Object.keys(e.data).length===0}})),kE=x.types.compose("DataSourceModel",ll,x.types.model({tables:x.types.optional(SE,{}),columns:x.types.optional(jE,{}),tableData:x.types.optional(CE,{}),indexes:x.types.optional(wE,{}),table_schema:x.types.optional(x.types.string,""),table_name:x.types.optional(x.types.string,"")})).views(e=>({get sqlDataSourceType(){return e.type},get reloadConditionString(){const{type:t,table_name:n,table_schema:s}=e;return`${t};${n};${s}`}})).volatile(()=>({controllers:{tables:new AbortController,columns:new AbortController,indexes:new AbortController,tableData:new AbortController}})).actions(e=>({setKeywords(t,n){e.table_schema=t,e.table_name=n}})).actions(e=>({initKeywords(){if(e.tables.empty)return;const t=Object.keys(e.tables.data)[0],n=e.tables.data[t][0].table_name;e.setKeywords(t,n)}})).actions(e=>{const t=x.flow(function*(){var n;(n=e.controllers.tables)==null||n.abort(),e.controllers.tables=new AbortController,e.tables.state="loading";try{const s=yield*x.toGenerator(Ot.structure(e.controllers.tables.signal)({query_type:"TABLES",type:e.sqlDataSourceType,key:e.key,table_schema:"",table_name:""},{params:{query_type:"TABLES"}}));e.tables.data=v.groupBy(s,"table_schema"),e.tables.state="idle",e.tables.error=null,e.initKeywords()}catch(s){if(!At.isCancel(s)){e.tables.data={};const i=v.get(s,"message","unkown error");e.tables.error=v.get(s,"response.data.detail.message",i),e.tables.state="error"}}});return{loadTables:t,loadTablesIfEmpty(){e.tables.empty&&t()},loadColumns:x.flow(function*(){var n;(n=e.controllers.columns)==null||n.abort(),e.controllers.columns=new AbortController,e.columns.state="loading";try{e.columns.data=yield*x.toGenerator(Ot.structure(e.controllers.columns.signal)({query_type:"COLUMNS",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"COLUMNS"}})),e.columns.state="idle",e.columns.error=null}catch(s){if(At.isCancel(s))e.columns.state="idle",e.columns.error=null;else{e.columns.data=[];const i=v.get(s,"message","unkown error");e.columns.error=v.get(s,"response.data.detail.message",i),e.columns.state="error"}}}),loadIndexes:x.flow(function*(){var n;(n=e.controllers.indexes)==null||n.abort(),e.controllers.indexes=new AbortController,e.indexes.state="loading";try{e.indexes.data=yield*x.toGenerator(Ot.structure(e.controllers.indexes.signal)({query_type:"INDEXES",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"INDEXES"}})),e.indexes.state="idle",e.indexes.error=null}catch(s){if(At.isCancel(s))e.indexes.state="idle",e.indexes.error=null;else{e.indexes.data=[];const i=v.get(s,"message","unkown error");e.indexes.error=v.get(s,"response.data.detail.message",i),e.indexes.state="error"}}}),loadTableData:x.flow(function*(){var s;(s=e.controllers.tableData)==null||s.abort(),e.controllers.tableData=new AbortController;const n=e.tableData;n.state="loading";try{n.data=yield*x.toGenerator(Ot.structure(e.controllers.tableData.signal)({query_type:"DATA",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name,limit:n.limit,offset:n.offset},{params:{query_type:"DATA"}}));const[{total:i}]=yield*x.toGenerator(Ot.structure(e.controllers.tableData.signal)({query_type:"COUNT",type:e.sqlDataSourceType,key:e.key,table_schema:e.table_schema,table_name:e.table_name},{params:{query_type:"COUNT"}}));n.total=Number(i),n.state="idle",n.error=null}catch(i){if(At.isCancel(i))n.state="idle",n.error=null;else{n.data=[];const a=v.get(i,"message","unkown error");n.error=v.get(i,"response.data.detail.message",a),n.state="error"}}})}}).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>e.reloadConditionString,e.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(e=>({afterCreate(){x.addDisposer(e,X.reaction(()=>e.reloadConditionString,e.loadIndexes,{fireImmediately:!1,delay:500})),x.addDisposer(e,X.reaction(()=>`${e.reloadConditionString};limit:${e.tableData.limit};offset:${e.tableData.offset}`,e.loadTableData,{fireImmediately:!1,delay:0}))}})),TE=x.types.model("DataSourcesModel",{list:x.types.optional(x.types.array(kE),[])}).views(e=>({find({type:t,key:n}){return e.list.find(s=>s.key===n&&s.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list.length=0,e.list.push(...t)}}));function In(e){return{label:e,value:e,_type:"ACTION",_action_type:e,Icon:null,children:null}}function DE(e){switch(e._type){case"GROUP":case"ACTION":return null;case"query_variables":return["_QUERY_VARS_"];case"mock_context":return["_MOCK_CONTEXT_"];case"filter":return["_FILTERS_",e.value];case"sql_snippet":return["_SQL_SNIPPETS_",e.value];case"query":return["_QUERIES_",e.value];case"view":return["_VIEWS_",e.value];case"panel":return e.parentID?["_VIEWS_",e.parentID,"_PANELS_",e.value]:(console.error("[getPathFromOption] parentID is required"),null)}}const ME=x.types.model("EditorModel",{path:x.types.optional(x.types.frozen(),[]),settings_open:x.types.optional(x.types.boolean,!1)}).views(e=>({get navOptions(){const{content:t}=x.getRoot(e),{filters:n,views:s,sqlSnippets:i,queries:a}=t;return[{label:"query_variable.labels",value:"_QUERY_VARS_",_type:"query_variables",Icon:M.IconVariable},{label:"mock_context.label",value:"_MOCK_CONTEXT_",Icon:M.IconCodeDots,_type:"mock_context"},{label:"filter.labels",value:"_FILTERS_",Icon:M.IconFilter,children:[In("_FILTERS_SETTINGS_"),...n.options,In("_Add_A_Filter_")],_type:"GROUP"},{label:"sql_snippet.labels",value:"_SQL_SNIPPETS_",Icon:M.IconCopy,children:[In("_SQL_SNIPPETS_SETTINGS_"),...i.options,In("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"query.labels",value:"_QUERIES_",Icon:M.IconDatabase,children:[In("_QUERIES_SETTINGS_"),...a.options,In("_Add_A_QUERY_")],_type:"GROUP"},{label:"view.labels",value:"_VIEWS_",Icon:M.IconBoxMultiple,children:[...s.editorOptions,In("_Add_A_VIEW_")],_type:"GROUP"}]},isOptionActive(t,n){return t.length===0?!1:t[t.length-1]===n.value},isOptionOpened(t){const{path:n}=e;return n.length===0||!t.children||t.children.length===0?!1:n.includes(t.value)}})).actions(e=>({setPath(t){e.path=t},setSettingsOpen(t){e.settings_open=t}})).actions(e=>({open(t){e.setPath(t),e.setSettingsOpen(!0)},close(){e.setSettingsOpen(!1)},navigate(t){const n=DE(t);n&&e.setPath(n)}})),zE=x.types.compose("LayoutsModel",bl,x.types.model({currentLayoutWrapperWidth:x.types.optional(x.types.number,0)})).views(e=>({get divisionPreviewScale(){const t=e.currentLayoutPreviewWidth,n=e.currentLayoutWrapperWidth;return!t||!n||t<=n?1:n/t}})).actions(e=>({addALayoutItem(t){e.list.forEach(n=>{n.addNewLayout(t)})},duplicateLayoutItemsByPanelID(t,n){e.list.forEach(s=>{const i=s.findByPanelID(t);if(!i){console.error(`Can't find a layout item by panelID[${t}] in layoutSet[${s.name}]`);return}s.list.push({...i,id:Ut.v4(),panelID:n,y:1/0})})},removeByPanelID(t){e.list.forEach(n=>{n.removeByPanelID(t)})},setCurrentLayoutWrapperWidth(t){e.currentLayoutWrapperWidth=t},addALayoutSet(t,n,s){const i=e.basisLayoutSet,a={id:t,name:n,breakpoint:s,list:i.json.list.map(l=>({...l,id:Ut.v4()}))};e.list.push(a)},updateLayoutSetsInfo(t){const n=v.keyBy(e.list,"id");t.forEach(a=>{const l=n[a.id];if(l){l.setName(a.name),l.setBreakpoint(a.breakpoint),delete n[a.id];return}this.addALayoutSet(a.id,a.name,a.breakpoint)});const s=new Set(Object.keys(n)),i=s.size>0;s.forEach(a=>{const l=e.list.findIndex(c=>c.id===a);e.list.splice(l,1)}),i&&e.setCurrentBreakpoint("basis")},updateCurrentLayoutItem(t){e.currentLayoutSet.updateLayoutItem(t)},updateCurrentLayoutItems(t){t.forEach(n=>{e.currentLayoutSet.updateLayoutItem(n)})},append(t){e.list.push(t)},appendMultiple(t){t.length!==0&&e.list.push(...t)},remove(t){e.list.splice(t,1)},removeByID(t){const n=e.list.findIndex(s=>s.id===t);n!==-1&&e.list.splice(n,1)},removeByIDs(t){t.forEach(n=>{this.removeByID(n)})}})),Af=hl.views(e=>({get realDataFieldOptions(){return e.queryIDs.length===0?[]:e.queries.map(t=>{const n=t.data;return n.length===0?[]:Object.keys(n[0]).map(i=>({label:i,value:`${t.id}.${i}`,group:t.name,group_id:t.id,disabled:!1}))}).flat()},get realQueryOptions(){return e.queryIDs.length===0?[]:e.queries.map(t=>({label:t.name,value:t.id,disabled:!1}))},queryOptions(t,n){const s=[...this.realQueryOptions];return t&&!s.find(i=>i.value===t)&&s.unshift({label:t,value:t,disabled:!0}),n&&s.unshift({label:"unset",value:"",disabled:!1}),s},dataFieldOptions(t,n,s){let i=[...this.realDataFieldOptions];if(s&&(i=i.filter(a=>a.group_id===s)),t&&!i.find(a=>a.value===t)){const a=O(t),l=e.queryByID(a.queryID);i.unshift({label:a.columnKey,value:t,group:l?l.name:a.queryID,group_id:l?l.id:"",disabled:!0})}return n&&i.unshift({label:"unset",value:"",group:"",group_id:"",disabled:!1}),i},explainDataKey(t){const{queryID:n,columnKey:s}=O(t),i=e.queries.find(a=>a.id===n);return i?{queryID:n,queryName:i.name,columnKey:s}:{queryID:n,queryName:null,columnKey:s}}})).actions(e=>({removeSelf(){x.getParent(e,2).removeByID(e.id)}})).actions(e=>({moveToView(t,n){x.getRoot(e).content.views.findByID(t).removePanelID(e.id),x.getRoot(e).content.views.findByID(n).appendPanelID(e.id),x.getRoot(e).editor.setPath(["_VIEWS_",n,"_PANELS_",e.id])}})),Pf=x.types.compose("PanelsModel",fl,x.types.model({list:x.types.optional(x.types.array(Af),[])})).views(e=>({get contentModel(){return x.getRoot(e).content},editorOptions(t,n){const s=e.panelsByIDs(n);s.length!==n.length&&console.warn(`Unfulfilled panels for View[${t}]`);const i=s.map(l=>({label:l.name,value:l.id,_type:"panel",parentID:t})),a="_Add_A_PANEL_";return i.push({label:a,value:a,_type:"ACTION",_action_type:a,parentID:t,Icon:null,children:null}),i}})).actions(e=>({replace(t){e.list=x.castToSnapshot(t)},append(t){e.list.push(t)},appendMultiple(t){t.length!==0&&e.list.push(...t)},remove(t){e.list.splice(t,1)},removeByID(t){const n=e.list.findIndex(s=>s.id===t);n!==-1&&e.list.splice(n,1)},removeByIDs(t){t.forEach(n=>{this.removeByID(n)})},duplicateByID(t){const n=e.list.find(i=>i.id===t);if(!n){console.error(new Error(`[duplicate panel] Can't find a panel by id[${t}]`));return}const s=new Date().getTime().toString();return e.list.push({...n.json,id:s,title:{...n.json.title}}),e.contentModel.layouts.duplicateLayoutItemsByPanelID(n.id,s),s},replaceByIndex(t,n){e.list.splice(t,1,n)}})),IE=dl.actions(e=>({getSchema(){const t=e.json,n=[],s=[];e.panels.forEach(l=>{const c=l.getSchema();n.push(c.panel),c.queries.length>0&&s.push(...c.queries)});const i=e.contentModel.layouts.jsonByPanelIDSet(new Set(e.panelIDs));return{views:[t],panels:n,definition:{queries:v.uniqBy(s,l=>l.id)},layouts:i,version:en}},downloadSchema(){if(e.type===q.Tabs){console.error(new Error("Please choose a tab first"));return}const t=JSON.stringify(this.getSchema(),null,2),n=e.name;sr(n,t)}})),Of=x.types.compose("ViewsModel",pl,x.types.model({current:x.types.optional(x.types.array(IE),[]),idOfVIE:x.types.string})).views(e=>({get isVIETheFirstView(){return e.current.length===0||!e.idOfVIE?!1:e.current[0].id===e.idOfVIE},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}))},get editorOptions(){const t=x.getRoot(e).content.panels;return e.current.map(n=>({label:n.name,value:n.id,_type:"view",children:t.editorOptions(n.id,n.panelIDs)}))}})).actions(e=>({setIDOfVIE(t){e.idOfVIE=t,e.visibleViewIDs.length=0,e.visibleViewIDs.push(t)},replace(t){e.current.replace(t)},addANewView(t,n,s,i){e.current.push({id:t,name:n,type:s,config:i,panelIDs:[]})},append(t){e.current.push(t)},appendMultiple(t){t.length!==0&&e.current.push(...t)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(a=>a.id===t);if(n===-1)return;const s=e.current[n];x.getRoot(e).content.panels.removeByIDs(s.panelIDs),e.current.splice(n,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},addARandomNewView(){const t=new Date().getTime().toString();this.addANewView(t,q.Division,q.Division,{_name:q.Division}),this.setIDOfVIE(t)},removeVIE(){e.current.length!==1&&(this.removeByID(e.idOfVIE),this.setIDOfVIE(e.current[0].id))}}));function Sl(e){const t=e.length>0?[e[0].id]:[],n=e.length>0?e[0].id:"";return{current:e.map(i=>{const{_name:a=i.type}=i.config;return{...i,config:{...i.config,_name:a},panelIDs:i.panelIDs}}),visibleViewIDs:t,idOfVIE:n}}const EE=x.types.model({id:x.types.string,name:x.types.string,dashboard_id:x.types.string,create_time:x.types.string,update_time:x.types.string,version:x.types.string,filters:Mf,queries:If,sqlSnippets:Ef,views:Of,panels:Pf,layouts:zE,mock_context:Yo,origin:x.types.maybe(x.types.frozen())}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,layouts:e.layouts.json,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get contentJSON(){return this.json.content},get filtersChanged(){const t="filters.current";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get queriesChanged(){const t="queries.current",n=x.getSnapshot(v.get(e,t)).map(s=>v.pick(s,["id","name","key","type","sql","run_by","react_to","pre_process","post_process","dep_query_ids"]));return!v.isEqual(n,v.get(e.origin,t))},get sqlSnippetsChanged(){const t="sqlSnippets.current";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get viewsChanged(){const t="views.current";return!v.isEqual(e.views.json,v.get(e.origin,t))},get panelsChanged(){const t="panels.list";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get layoutsChanged(){const t="layouts.list";return!v.isEqual(x.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get mockContextChanged(){const t="mock_context.current";return!v.isEqual(v.get(e,t),v.get(e.origin,t))},get context(){const t=x.getParent(e).context.current;return{...e.mock_context.current,...t}},get payloadForSQL(){const t=x.getParent(e).globalSQLSnippets,n={context:this.context,filters:e.filters.values};return{...n,sql_snippets:Qr(e.sqlSnippets.current,"key","value",n),global_sql_snippets:Qr(t.list,"id","content",n)}},get payloadForViz(){const t=x.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.values}},get dashboardState(){return Mi(this.payloadForSQL)},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardState}},get changed(){return this.filtersChanged||this.queriesChanged||this.sqlSnippetsChanged||this.viewsChanged||this.panelsChanged||this.layoutsChanged||this.mockContextChanged},get data(){return e.queries.current.map(({id:n,data:s})=>({id:n,data:s})).reduce((n,s)=>(n[s.id]=s.data,n),{})},getDataStuffByID(t){const n=e.queries.findByID(t);return n?{data:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).views(e=>({get queriesUsage(){const t=e.panels.idMap,n=[];e.views.current.forEach(i=>{i.panelIDs.forEach(a=>{const l=t.get(a);if(!l)return;const c="panel",u=l.name,d=[{id:i.id,label:i.name}];l.queryIDs.forEach(p=>{n.push({id:a,queryID:p,type:c,type_label:"panel.label",label:u,views:d})})})});const s=e.views.idMap;return e.filters.current.filter(i=>!!v.get(i,"config.options_query_id")).forEach(i=>{n.push({type:"filter",type_label:"filter.label",id:i.id,queryID:v.get(i,"config.options_query_id"),label:i.label,views:i.visibleInViewsIDs.map(a=>{var l;return{id:a,label:((l=s.get(a))==null?void 0:l.name)??a}})})}),e.queries.current.forEach(i=>{i.isTransform&&i.dep_query_ids.forEach(a=>{n.push({type:"transform-query",type_label:"query.transform.full_label",id:i.id,queryID:a,label:i.name,views:[]})})}),v.groupBy(n,"queryID")},get hasUnusedQueries(){return e.queries.current.length>Object.keys(this.queriesUsage).length},findQueryUsage(t){return this.queriesUsage[t]??[]},get sqlSnippetsUsage(){const t=[];return e.queries.current.forEach(n=>{if(!n.typedAsSQL)return;v.uniq(n.sql.match(as.sqlSnippet)).forEach(i=>{t.push({queryID:n.id,sqlSnippetKey:i,queryName:n.name})})}),v.groupBy(t,"sqlSnippetKey")},get hasUnusedSQLSnippets(){return e.sqlSnippets.current.length>Object.keys(this.sqlSnippetsUsage).length},findSQLSnippetUsage(t){return this.sqlSnippetsUsage[t]??[]}})).actions(e=>({removeUnusedQueries(){const t=new Set(Object.keys(e.queriesUsage)),n=e.queries.current.filter(s=>!t.has(s.id)).map(s=>s.id);e.queries.removeQueries(n)},removeUnusedSQLSnippets(){const t=new Set(Object.keys(e.sqlSnippetsUsage)),n=e.sqlSnippets.current.filter(s=>!t.has(s.key)).map(s=>s.key);e.sqlSnippets.removeByKeys(n)},duplicatePanelByID(t,n){var i;const s=e.panels.duplicateByID(t);s&&((i=e.views.findByID(n))==null||i.appendPanelID(s))},removePanelByID(t,n){var s;e.panels.removeByID(t),e.layouts.removeByPanelID(t),(s=e.views.findByID(n))==null||s.removePanelID(t)},addANewPanel(t){var s;const n=Ut.v4();e.panels.append(tf(n)),(s=e.views.findByID(t))==null||s.appendPanelID(n),e.layouts.addALayoutItem(n)},applyJSONSchema(t){var h;const{views:n,panels:s,filters:i,definition:a={},layouts:l}=t,{queries:c,sqlSnippets:u,mock_context:d}=a,p=new Map;if(Array.isArray(s)){const f=s.map(g=>{const y=Ut.v4();return p.set(g.id,y),{...g,id:y}});if(e.panels.appendMultiple(f),!Array.isArray(n)||n.length===0){const g=f.map(y=>y.id);(h=e.views.VIE)==null||h.appendPanelIDs(g)}}if(Array.isArray(n)){const f=n.map(g=>{const y=g.panelIDs.map(j=>p.get(j)??j);return{...g,id:Ut.v4(),panelIDs:y}});e.views.appendMultiple(f)}if(Array.isArray(l)){const f=(j,k)=>e.layouts.breakpointNameRecord[j]===k;let g=[];const y=l.filter(j=>f(j.name,j.breakpoint));y.forEach(j=>{j.id==="basis"&&(g=j.list),j.list.forEach(k=>{const S=p.get(k.panelID);k.id=Ut.v4(),k.panelID=S})}),e.layouts.list.forEach(j=>{const k=y.find(S=>S.name===j.name&&S.breakpoint===j.breakpoint);if(!k){g.forEach(S=>{j.addLayout(S)});return}k.list.forEach(S=>{j.addLayout(S)})})}Array.isArray(i)&&e.filters.appendMultiple(i),Array.isArray(c)&&e.queries.appendMultiple(c),Array.isArray(u)&&e.sqlSnippets.appendMultiple(u),d&&Object.keys(d).length>0&&e.mock_context.defaults(d)}})).actions(e=>({reset(){x.applySnapshot(e.filters.current,e.origin.filters.current),x.applySnapshot(e.queries.current,e.origin.queries.current),x.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),x.applySnapshot(e.views.current,e.origin.views.current),x.applySnapshot(e.panels.list,e.origin.panels.list),x.applySnapshot(e.layouts.list,e.origin.layouts.list),e.mock_context.current=e.origin.mock_context.current},resetFilters(){x.applySnapshot(e.filters.current,e.origin.filters.current)},updateCurrent(t){const{id:n,name:s,content:i}=t;if(!i)throw new Error("unexpected null content when updating a content model");const{version:a,filters:l,views:c,panels:u,definition:{queries:d,sqlSnippets:p,mock_context:h={}}}=i;e.id=n,e.name=s,e.version=a,x.applySnapshot(e.filters.current,l),x.applySnapshot(e.views.current,Sl(c).current),x.applySnapshot(e.panels.list,u),x.applySnapshot(e.queries.current,d),x.applySnapshot(e.sqlSnippets.current,p),e.mock_context.current=h}})),kl=x.types.snapshotProcessor(EE,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=x.castToSnapshot(e.queries.current.map(n=>v.pick(n,["id","key","type","sql"])));return v.defaults({},{queries:{current:t}},e)}});function AE(e,t){t.filters&&x.applySnapshot(e.filters.current,t.filters)}function Lf({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,content:a},l,c){if(!a)throw new Error("unexpected null content when creating a content model");const{version:u,filters:d,views:p,panels:h,layouts:f,definition:{queries:g,sqlSnippets:y,mock_context:j={}}}=a;return kl.create({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,version:u,filters:gl(d,l,j,c),queries:{current:g},sqlSnippets:{current:y},mock_context:Ko(j),views:Sl(p),panels:{list:h},layouts:{list:f,currentBreakpoint:f[0].id}})}const Bf=x.types.model({id:x.types.identifier,name:x.types.string,group:x.types.string,content:kl,content_id:x.types.string,datasources:TE,globalSQLSnippets:cl,context:oi,editor:ME}).views(e=>({get json(){return{id:e.id,name:e.name,group:e.group,content_id:e.content_id}}})).actions(e=>({updateCurrentContent(t){e.content.updateCurrent(t)},updateCurrent(t,n){const{id:s,name:i,group:a,content_id:l}=t;e.id=s,e.name=i,e.group=a,e.content_id=l,this.updateCurrentContent(n)}}));function qf({id:e,name:t,group:n,content_id:s},i,a,l,c,u){return Bf.create({id:e,name:t,group:n,content_id:s,content:Lf(i,c,u),datasources:{list:a},globalSQLSnippets:{list:l},context:ul(c),editor:{}})}const PE={translation:{filter:{label:"Filter",labels:"Filters",add:"Add a Filter",manage:"Manage Filters",show_filters:"Show Filters",hide_filters:"Hide Filters",field:{widget:"Widget",visible_in:"Visible in...",key_placeholder:"A unique key to refer",label_placeholder:"Label for this field",auto_submit:"Submit automatically",order:"Placement Order",custom_default_value:{trigger:"Custom",title:"Custom default value",tips:"Tips",tip_1:"Function has the highest priority of getting filter's default value",tip_2:"Leave this editor empty to disable this feature"}},widget:{names:{select:"Select",multi_select:"Multi Select",tree_select:"Tree Select",text_input:"Text Input",checkbox:"Checkbox",date_range:"Date Range"},common:{use_query_data_as_options:"Use query data as options",fetch_options_from_datasource:"Fetch options from datasource",or_fetch_options_from_datasource:"Or fetch options from datasource",selector_option_empty:"Not found",see_data_structure:"Click to see expected data structure",using_query:"Using query",default_selection_count:"Select first N options by default",min_width:"Min width",x_selected:"{{count}} selected"},text_input:{default_value:"Default Value",required:"Required"},select:{width:"Width",required:"Required",clearable:"Clearable",configure_options:"Configure options",default_selection:"Default Selection",no_default_selection:"none",select_first_option_by_default:"Select the first option by default"},multi_select:{width_description:"At least 160px"},tree_select:{strictly:"Parent and children nodes are not associated"},checkbox:{description:"Description",default_checked:"Default checked"},date_range:{required:"Required",allow_single_date:"Allow choosing 1 day",display_format:"Display format",max_days:"Max days",one_day:"1 day",x_days:"{{count}} days",x_max_days:"{{max_days}} days max",default_value:"Default value",default_by_shortcut:"Default by shortcut",default_by_shortcut_placeholder:"Priors default value",start_date:"Start date",end_date:"End date",shortcut:{last:{label:"last",d:"yesterday",w:"week",m:"month",m2:"2 months",m3:"3 months",y:"year",full:{d:"yesterday",w:"last week",m:"last month",m2:"last 2 months",m3:"last 3 months",y:"last year"}},recent:{label:"recent",d7:"7 days",d30:"30 days",d60:"60 days",d90:"90 days",d180:"180 days",d365:"365 days",full:{d7:"recent 7 days",d30:"recent 30 days",d60:"recent 60 days",d90:"recent 90 days",d180:"recent 180 days",d365:"recent 365 days"}},this:{label:"this",d:"today",w:"week",m:"month",y:"year",full:{d:"today",w:"this week",m:"this month",y:"this year"}},this_so_far:{label:"this...so far",w:"week",m:"month",y:"year",full:{w:"this week so far",m:"this month so far",y:"this year so far"}}}}}},view:{label:"View",labels:"Views",add:"Add a View",delete:"Delete this View",download_schema:"Download this View",component:{div:{label:"Division"},tabs:{label:"Tabs",tabs_settings:"Tabs Settings",tab:{name:"Tab Name",view:"View",order:"Placement Order",color:"Color",delete:"Delete this tab",switch_to_view:"Swith to View: {{name}}"}},modal:{label:"Modal",modal_settings:"Modal settings",title:"Modal Title",custom_title:"Customize modal title",width:"Width",height:"Height"}}},interactions:{label:"Interactions",add:"Add an interaction",interactions_viewer:"Interactions Viewer",unavailable:"Unavailable",unavailable_reason:"This visualization does not have available interactions to choose from",trigger:{setup:"Setup Trigger",label:"Trigger",payload:"Payload"},operation:{setup:"Operation Settings",label:"Operation",settings:"Settings",variables:"Variables",console_log:{label:"console.log | debug",log_content:"log content"},open_link:{label:"Open Link",url:"URL",open_in_new_tab:"Open in new tab"},open_view:{label:"Open View",view:"View"},set_filter_values:{label:"Set Filter Values",set_filter:"Set filter",with:"with"},clear_filter_values:{label:"Clear Filter Values",select_filter:"Select filters to clear"}}},query_variable:{label:"Query Variable",labels:"Query Variables",add:"Add a Variable",guide:{tabs:{guide:"Guide",variables_in_this_dashboard:"Variables in this dashboard",global_sql_snippets:"Global SQL Snippets"}},open:"See Query Variables"},sql_snippet:{label:"SQL Snippet",labels:"SQL Snippets",add:"Add a SQL Snippet",delete:"Delete this SQL Snippet",delete_unused:"Delete unused SQL Snippets",manage:"Manage SQL Snippets",key:"Key",key_occupied:"This key is occupied by another snippet",edit_snippet:"Edit SQL Snippet",preview_snippet:"Preview SQL Snippet",usage:{label:"Usage"}},global_sql_snippet:{label:"Global SQL Snippet",labels:"Global SQL Snippets",description:"SQL snippets worth sharing between dashboards are managed in System Settings by admins."},common:{titles:{settings:"Settings",edit:"Edit",config:"Config"},pagination:{page_size:"Page Size",total:"Total",total_rows:"Total {{total}} row(s)"},align:{horizontal:{label:"Horizontal Align",left:"left",center:"center",right:"right"},vertical:{label:"Vertical Align",left:"top",center:"center",right:"bottom"}},id:"ID",name:"Name",key:"Key",label:"Label",value:"Value",type:"Type",info:"Info",min:"Min",max:"Max",data_field:"Data Field",name_data_field:"Name Data Field",value_data_field:"Value Data Field",color_data_field:"Color Data Field",enabled:"Enabled",copied:"Copied to clipboard",action:"Action",actions:{open:"Open",close:"Close",save:"Save",save_changes:"Save Changes",revert:"Revert",revert_changes:"Revert Changes",reset_to_default:"Reset to default",init_with_default:"Init with default",select_all:"Select All",clear_selection:"Clear Selection",refresh:"Refresh",download_data:"Download Data",download_schema:"Download Schema",download_screenshot:"Screenshot",enter_fullscreen:"Full Screen",duplicate:"Duplicate",delete:"Delete",cancel:"Cancel",confirm:"Confirm",add_an_option:"Add an Option",edit:"Edit",end_editing:"End editing <1>{{name}}</1>"},tabs:{variant:{label:"Variant",default:"Default",outline:"Outline",pills:"Pills"},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},grow_tabs:"Grow Tabs"},choose_a_tab_first:"Please choose a tab first"},breakpoint:{label_one:"Screen size",label_other:"Screen sizes",add:"Add a screen size",manage:"Manage screen sizes",breakpoint:"Min Width"},context:{label:"Context"},mock_context:{label:"Mock Context",hint:"A valid json string is required"},panel:{label:"Panel",labels:"Panels",add:"Add a Panel",delete:"Delete This Panel",panel_name:"Panel Name",panel_description:"Description",panel_description_click:"Click to see description",show_title:"Show title",use_name_as_title:"Use name as title",settings:{change_view:"Move into Another View",change_view_title:"Move panel into another view",choose_queries:"Choose queries",need_to_choose_queries:"Choose at least 1 query for its data"},style:{label:"Style",width:"Width",width_postfix:"of 36 columns",height:"Height",height_postfix:"px",border:"Border"},variable:{label:"Variable",labels:"Variables",add:"Add a Variable",delete:"Delete this Variable",aggregation:{label:"Aggregation",fallback_value:"Fallback Value",fallback_value_description:"Used when data is empty or the aggregation yields NaN"}}},style:{label:"Style",font_size:{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"Font Weight"},size:{xs:"xs",sm:"sm",md:"md",lg:"lg",xl:"xl"},flex:{justify_content:{label:"Justify Content",left:"Left",center:"Center",right:"Right",space_between:"Space Between",space_around:"Space Around",space_evenly:"Space Evenly"},align_items:{label:"Align Items",start:"Start",center:"Center",end:"End",stretch:"Stretch"}},color:{type:{label:"Color Type",static:"Static",interpolation:"Interpolation",none:"None"},interpolation:{setup:"Setup color interpolation",palette:{label:"Palette",category:{sequential:"Sequential",diverging:"Diverging"},red_green:"Red / Green",yellow_blue:"Yellow / Blue",red:"Red",green:"Green",blue:"Blue",orange:"Orange",mapping:{value_input_label:"Map a value to this color"}}}}},query:{label:"Query",labels:"Queries",add:"Add a Query",delete:"Delete this Query",cant_delete:"Can't delete this query for it's being used, check out Usage tab for details",delete_unused:"Delete unused queries",name:"Name",name_description:"A unique name",manage:"Manage Queries",open:"Open this query",configurations:"Configurations",basics:"Basics",conditions:"Conditions",run_by_condition:{label:"Run query when these are truthy",unset:"Always run this query on load"},re_run_condition:{label:"Re-run query when these changed",unset:"Leave it empty to never re-run this query"},dependency:{label:"Dependency",has_none:"This query has no dependency"},edit_sql:"Edit SQL",preview_sql:"Preview SQL",request:"Request",build_request:"Build Request",process_request:"Process Request",process_result:"Process Result",usage:{label:"Usage",in_views:"In View(s)",unused_description:"This query is not used by any filter or panel"},transform:{label:"Transform",full_label:"Transform Query",data_source:"Use other queries' data",guide:{pick_queries:"Pick queries for data input",write_function:"Write a function for making new data"}}},data:{label:"Data",preview_data:"Preview Data",empty_data:"Empty Data",requires_data:"Requires data"},data_source:{label:"Data Source",explore:"Explore Data Source",explorer:"Data Source Explorer",table_structure:"Table Structure",table_structure_short:"Structure",see_table_structure:"See Table Structure"},visualization:{label:"Visualization",component:"Visualization",label_short:"Viz"},numbro:{format:{label:"Format",absolute:"Absolute",absolute_description:"Non-negative",abbreviation:"Abbreviation",abbreviation_description:"like 1.23k, 1.23m",mantissa:"Mantissa",trim_mantissa:"Trim mantissa",trim_mantissa_description:"hide trailing zero(s)",preview:{open:"Open Preview",close:"Close Preview",input:"In",output:"Out"}}},import:{label:"Import...",title:"Import content with schema json",json_file:"JSON File",this_dashboard:"This dashboard",this_file:"This file"},function_utils:{trigger_text:"About parameter 'utils'",modal_title:"About FunctionUtils",description:"Parameter <code>utils</code> is <code>FunctionUtils</code>, which contains:",document:"Document"},aggregation:{option:{none:"None",sum:"Sum",mean:"Mean",median:"Median",min:"Min",max:"Max",cov:"Coefficient of Variation",std:"Standard Variation",quantile:{label:"Quantile",label_with_hint:"Quantile(99%, 95%, ...)"},custom:{label:"Custom",label_trigger:"Edit Function",title:"Custom Aggregation"},pick_record:{label:"Pick Record",method:{label:"Record",first:"First Record",last:"Last Record"}}}},rich_text:{dynamic_color:{label:"Dynamic Color",edit:"Edit dynamic color"}},chart:{chart_config:"Chart Config",data_field:"Data Field",groups:{merico_suite:"Merico suite",echarts_based_charts:"ECharts-based charts",others:"Others"},label:{label:"Label",label_full:"Label",label_style:"Label Style",label_format:"Label Format"},label_position:{label:"Label Position",off:"Off",top:"Top",left:"Left",right:"Right",bottom:"Bottom",inside:"Inside",inside_top:"Inside Top",inside_left:"Inside Left",inside_center:"Inside Center",inside_right:"Inside Right",inside_bottom:"Inside Bottom",inside_top_left:"Inside Top Left",inside_top_right:"Inside Top Right",inside_bottom_left:"Inside Bottom Left",inside_bottom_right:"Inside Bottom Right",outside:"Outside"},visual_map:{label:"Visual Map",continuous:{label:"Continuous"},piecewise:{label:"Piecewise",mode:{pieces:"Pieces",categories:"Categories"},add_a_piece:"Add a piece",interval:"Interval",piece_label:"Label"},bar_width:"Bar Width",bar_height:"Bar Height",item_width:"Item Width",item_height:"Item Height",calculable:"Show drag handle",min_value:"Min Value",max_value:"Max Value",min_text:"Min Text",max_text:"Max Text",use_palette_x:'Use palette "{{x}}"',built_in_palettes:"Built-in Palettes",precision:"Data Precision",skip_range:{lt_min:"Color for smaller values than min value",min:"Color for min value",max:"Color for max value",gt_max:"Color for greater values than max value",follow_visual_map:"follow gradient rule"}},number_or_dynamic_value:{type:{static:"Static",dynamic:"Dynamic"},dynamic:{setup:"Setup",setup_title:"Setup dynamic value",guide:"Dyanmic by a custom function"}},orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"},symbol_size:{label:"Symbol Size",static:"Static",dynamic:"Dynamic",setup:{label:"Setup",title:"Setup dynamic size",description:"Dynamic by a custom function"}},series:{label:"Series",name:"Name",y_axis:"Y Axis",data_field:"Data Field",add:"Add a series",delete:"Delete this series",line:{label:"Line",line_settings:"Line Settings",line_style:"Line Style",type:{label:"Line Type",solid:"Solid",dashed:"Dashed",dotted:"Dotted"},line_width:"Line Width",step:{label:"Step",off:"Off",start:"Start",middle:"Middle",end:"End"},smooth_line:"Smooth Line",show_name_on_line:"Display Name on Line",show_symbol_on_line:"Show Symbol on Line"},bar:{label:"Bar",stack:"Stack",stack_hint:"Stack bars by this ID",bar_gap:{label:"Bar Gap",no_gap:"No gap between bars",overlap:"Bars overlapping on each other"},bar_width:{min:"Bar Width(min)",exact:"Bar Width",max:"Bar Width(max)"}},scatter:{label:"Scatter"},group_by:{label:"Split into multiple seires by this field...",label_line:"Split into multiple lines by this field..."}},axis:{tick_label:"Tick Label",customize_label:"Customize Label",overflow:{label:"Overflow",max_width:"Max Width",truncate:"Truncate",break_line:"Break Line",break_word:"Break Word",ellipsis:"Ellipsis",section_title:{on_axis:"Overflow on Axis",in_tooltip:"Overflow in Tooltip"}},section_title:{label_format:"Label Format"},type:{value:"Value",category:"Category",time:"Time",log:"Log",click_to_learn_more:"Click <1>here</1> to learn more about these options"}},name_text:{align:{label:"Name Anchor",left:"Left",center:"Center",right:"Right"}},rotate:"Rotate",degree:"degree",padding:"Padding",content_template:{label:"Content Template",hint:"Average: ${avg}"},x_axis:{label:"X Axis",labels:"X Axes",label_format:"Label Format",add:"Add an X Axis",delete:"Delete this X Axis",x_axis_name:"X Axis Name",x_axis_data_field:"X Axis Data Field",x_axis_type:"X Axis Type",layout:"Layout",position:{label:"Position",top:"Top",bottom:"Bottom"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},y_axis:{label:"Y Axis",labels:"Y Axes",label_format:"Label Format",add:"Add a Y Axis",delete:"Delete this Y Axis",y_axis_name:"Y Axis Name",y_axis_name_anchor:"Name Anchor",y_axis_data_field:"Y Axis Data Field",layout:"Layout",position:{label:"Position",left:"Left",right:"Right"},value_range:"Value Range",value_min:"Min",value_max:"Max",behavior:"Behavior",visible:"Visible"},stats:{label:"Stats",template:{above_chart:"Template for stats above the chart",under_chart:"Template for stats under the chart"}},legend:{label:"Legend",show_legend:"Show Legend",show_in_legend:"Show in legend",hide_in_legend:"Hide in legend",orientation:{label:"Orientation",horizontal:"Horizontal",vertical:"Vertical"}},tooltip:{label:"Tooltip",additional_metrics:{description:"Set additional metrics to show in scatter's tooltip",add:"Add a metic",delete:"Delete this Metric"},trigger:{label:"Trigger",scatter_point:"Scatter Point",x_axis:"X Axis"}},style:{label:"Style"},color:{label:"Color",or:"or",set_any_color:"Set any color",pick_a_theme_color:"Pick a theme color",background_color:"Background Color",text_color:"Text Color",click_to_add_a_color:"Click to add a color",color_gradient:"Color Gradient"},behavior:{label:"Behavior",invisible:"Invisible"},heatmap:{heatblock:{label:"Heat Block",show_label:"Show Label"}},reference_line:{label:"Reference Line",labels:"Reference Lines",add:"Add a reference line",name_placeholder:"Average Reference Line",delete:"Remove this Reference Line",orientation:{vertical_hint:"Works only when xAxis values are numbers"}},regression_line:{label:"Regression Line",labels:"Regression Lines",add:"Add a line",delete:"Delete this line",method:{label:"Method",linear:"Linear",exponential:"Exponential",logistic:"Logistic",polynomial:"Polynomial",polynomial_order:"Order"}},reference_area:{label:"Reference Area",labels:"Reference Areas",add:"Add a reference area",delete:"Remove this reference area",type:{label:"Type",rectangle:"Rectangle"},direction:{label:"Direction",horizontal:"Horizontal"},boundary:{upper:"Upper Boundary",lower:"Lower Boundary"},content:{label:"Content",content_text:"Content Text",text_position:"Text Position"},endpoint:{labels:"Endpoints",left_bottom_point:"Left-Bottom Point",right_top_point:"Right-Top Point"}},zooming:{label:"Zooming",scroll:{label:"Scroll to zoom",x_axis:"Enable on X Axis",y_axis:"Enable on Y Axis"},slider:{label:"Slider for zooming",x_axis:"Slider for X Axis",y_axis:"Slider for Y Axis",y_axis_disabled:"Not available for now, will overlap y-axis's label"}}},viz:{viz_config_banner:"Visualization Settings"},validation:{number:{require_a_number:"A number is required"}}}},OE={translation:{filter:{label:"筛选器",labels:"筛选器",add:"新增筛选器",manage:"管理筛选器",show_filters:"展开筛选器",hide_filters:"收起筛选器",field:{widget:"控件",visible_in:"在...视图中可见",key_placeholder:"用于引用此筛选器,需保持唯一",label_placeholder:"用于展示的标签文案",auto_submit:"自动提交",order:"排列次序",custom_default_value:{trigger:"自定义",title:"自定义默认值",tips:"提示",tip_1:"在指定筛选器默认值这事上,自定义函数具备最高优先级",tip_2:"清空下方编辑器来禁用本功能"}},widget:{names:{select:"单选",multi_select:"多选",tree_select:"树形选择器",text_input:"文本框",checkbox:"勾选框",date_range:"日期范围"},common:{use_query_data_as_options:"使用所查数据为选项",fetch_options_from_datasource:"从数据源查选项",or_fetch_options_from_datasource:"或从数据源查选项",selector_option_empty:"无选项可用",see_data_structure:"点击查看期望的数据格式",using_query:"在用查询获取选项",default_selection_count:"默认选中前N项",min_width:"控件最小宽度",x_selected:"已选数:{{count}}"},text_input:{default_value:"默认值",required:"必填"},select:{width:"控件宽度",required:"必选",clearable:"可取消选择",configure_options:"配置选项",default_selection:"默认选项",no_default_selection:"无",select_first_option_by_default:"默认选中第一个选项"},multi_select:{width_description:"至少160px"},tree_select:{strictly:"枝叶节点不相关,各选各的"},checkbox:{description:"描述信息",default_checked:"默认勾选"},date_range:{required:"必选",allow_single_date:"允许选一天作为范围",display_format:"展示格式",max_days:"最大选择天数",one_day:"1天",x_days:"{{count}}天",x_max_days:"最多可选{{max_days}}天",default_value:"默认日期范围(具体)",default_by_shortcut:"默认日期范围(快捷方式)",default_by_shortcut_placeholder:"优先于左侧",start_date:"开始日期",end_date:"结束日期",shortcut:{last:{label:"过往整周期",d:"昨天",w:"周",m:"月",m2:"两个月",m3:"三个月",y:"年",full:{d:"昨天",w:"上周",m:"上个月",m2:"上两月",m3:"上三月",y:"去年"}},recent:{label:"最近",d7:"7天",d30:"30天",d60:"60天",d90:"90天",d180:"180天",d365:"365天",full:{d7:"近7天",d30:"近30天",d60:"近60天",d90:"近90天",d180:"近180天",d365:"近365天"}},this:{label:"当前整周期",d:"今天",w:"周",m:"月",y:"年",full:{d:"今天",w:"本周",m:"本月",y:"今年"}},this_so_far:{label:"至今",w:"周",m:"月",y:"年",full:{w:"本周至今",m:"本月至今",y:"本年至今"}}}}}},view:{label:"视图",labels:"视图",add:"新增视图",delete:"删除此视图",download_schema:"下载此视图描述文件",component:{div:{label:"内容"},tabs:{label:"标签页",tabs_settings:"标签页设置",tab:{name:"名称",view:"内容视图",order:"排列次序",color:"颜色",delete:"删除这个标签页",switch_to_view:"打开视图: {{name}}"}},modal:{label:"弹窗",modal_settings:"弹窗设置",title:"弹窗标题",custom_title:"自定义弹窗标题",width:"宽度",height:"高度"}}},interactions:{label:"交互",add:"新增交互",interactions_viewer:"纵览交互",unavailable:"不可用",unavailable_reason:"此可视化组件没有交互功能",trigger:{setup:"设置触发动作",label:"触发动作",payload:"触发时的参数"},operation:{setup:"操作设置",label:"操作",settings:"设置",variables:"变量",console_log:{label:"console.log | 调试用",log_content:"打印内容"},open_link:{label:"打开链接",url:"URL",open_in_new_tab:"在新标签页中打开"},open_view:{label:"唤出视图",view:"视图"},set_filter_values:{label:"设置筛选器值",set_filter:"将筛选器的值",with:"设为"},clear_filter_values:{label:"清除筛选器值",select_filter:"选择筛选器以清除其值"}}},query_variable:{label:"查询变量",labels:"查询变量",add:"新增变量",guide:{tabs:{guide:"使用指南",variables_in_this_dashboard:"本看板中的查询变量",global_sql_snippets:"全局SQL片段"}},open:"查看查询变量"},sql_snippet:{label:"SQL片段",labels:"SQL片段",add:"新增SQL片段",delete:"删除这个SQL片段",delete_unused:"删除未用到的SQL片段",manage:"管理SQL片段",key:"键",key_occupied:"此键已被其他SQL片段占用",edit_snippet:"编辑SQL片段",preview_snippet:"预览SQL片段",usage:{label:"使用情况"}},global_sql_snippet:{label:"全局SQL片段",labels:"全局SQL片段",description:"管理员负责在系统设置中维护全局SQL片段"},common:{titles:{settings:"设置",edit:"编辑",config:"配置"},pagination:{page_size:"页容量",total:"共",total_rows:"共 {{total}} 行"},align:{horizontal:{label:"水平对齐",left:"居左",center:"居中",right:"居右"},vertical:{label:"垂直对齐",left:"居上",center:"居中",right:"居下"}},id:"ID",name:"名称",key:"键",label:"标签",value:"值",type:"类型",info:"信息",min:"最小值",max:"最大值",data_field:"数据字段",name_data_field:"名称字段",value_data_field:"值字段",color_data_field:"颜色字段",enabled:"启用",copied:"已复制到剪切板",action:"操作",actions:{open:"打开",close:"关闭",save:"保存",save_changes:"保存改动",revert:"还原",revert_changes:"还原改动",reset_to_default:"重置为初始值",init_with_default:"初始化",select_all:"全选",clear_selection:"撤销选择",refresh:"刷新",download_data:"下载数据",download_schema:"下载描述文件",download_screenshot:"下载截图",enter_fullscreen:"全屏",duplicate:"复制",delete:"删除",cancel:"取消",confirm:"确认",add_an_option:"新增选项",edit:"编辑",end_editing:"结束编辑 <1>{{name}}</1>"},tabs:{variant:{label:"风格",default:"默认",outline:"轮廓",pills:"胶囊"},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},grow_tabs:"拉伸标签卡宽度"},choose_a_tab_first:"请先选择一个标签页"},breakpoint:{label_one:"屏幕尺寸",label_other:"屏幕尺寸",add:"新增屏幕尺寸",manage:"管理屏幕尺寸",breakpoint:"最小宽度"},context:{label:"上下文"},mock_context:{label:"模拟上下文",hint:"内容格式为JSON"},panel:{label:"卡片",labels:"卡片",add:"新增卡片",delete:"删除这个卡片",panel_name:"卡片名",panel_description:"卡片描述",panel_description_click:"点击查看卡片描述",show_title:"展示卡片标题",use_name_as_title:"使用卡片名作为标题",settings:{change_view:"移至另一个视图下",change_view_title:"移动此卡片至另一个视图下",choose_queries:"关联查询",need_to_choose_queries:"请关联至少一个查询以使用其数据"},style:{label:"样式",width:"宽",width_postfix:"之 36 栏",height:"高",height_postfix:"px",border:"边框"},variable:{label:"变量",labels:"变量",add:"新增变量",delete:"删除此变量",aggregation:{label:"聚合",fallback_value:"兜底值",fallback_value_description:"当数据为空或聚合结果非数字时,使用此兜底值"}}},style:{label:"样式",font_size:{label:"字号",placeholder:"10px, 1em, 1rem, 100%..."},font_weight:{label:"字重"},size:{xs:"特小",sm:"小",md:"中",lg:"大",xl:"特大"},flex:{justify_content:{label:"内容分布",left:"从左起",center:"居中",right:"从右起",space_between:"均匀分布,首尾顶格",space_around:"均匀分布,首尾留空一半",space_evenly:"均匀分布,首尾留空"},align_items:{label:"对齐位置",start:"起点对齐",center:"居中对齐",end:"末端对齐",stretch:"拉伸对齐"}},color:{type:{label:"颜色类型",static:"单色",interpolation:"插值取色",none:"无"},interpolation:{setup:"设置取色方案",palette:{label:"色板",category:{sequential:"单色渐变",diverging:"双色渐变"},red_green:"红 / 绿",yellow_blue:"黄 / 蓝",red:"红",green:"绿",blue:"蓝",orange:"橙",mapping:{value_input_label:"映射一个值到此颜色"}}}}},query:{label:"查询",labels:"查询",add:"新增查询",delete:"删除这个查询",cant_delete:"此查询在使用中,不能删除。请查看“使用情况”标签页以了解详情",delete_unused:"删除未用到的查询",name:"名称",name_description:"唯一名称",manage:"管理查询",open:"打开此查询",configurations:"配置",basics:"基本信息",conditions:"条件",run_by_condition:{label:"以下条件满足时,才运行本查询",unset:"看板加载时便运行本查询"},re_run_condition:{label:"当以下条件改变时,重新运行此查询",unset:"留空则永不重新运行此查询"},dependency:{label:"依赖",has_none:"此查询无依赖"},edit_sql:"编辑SQL",preview_sql:"预览SQL",request:"请求",build_request:"构造请求",process_request:"加工请求",process_result:"加工结果",usage:{label:"使用情况",in_views:"所在视图",unused_description:"此查询未被任何筛选器或卡片用到"},transform:{label:"查询变形",full_label:"查询变形",data_source:"基于其他查询的数据,加工出新数据",guide:{pick_queries:"选择一至多个查询作为数据输入",write_function:"编写函数,返回新数据"}}},data:{label:"数据",preview_data:"预览数据",empty_data:"无数据",requires_data:"请先关联查询"},data_source:{label:"数据源",explore:"查看数据源",explorer:"数据源查看器",table_structure:"数据表结构",table_structure_short:"表结构",see_table_structure:"查看数据表结构"},visualization:{label:"可视化",component:"可视化组件",label_short:"可视化"},numbro:{format:{label:"格式",absolute:"绝对值",absolute_description:"非负",abbreviation:"缩写",abbreviation_description:"如1.23k、1.23m",mantissa:"小数",trim_mantissa:"抹零",trim_mantissa_description:"省略末尾的零",preview:{open:"展开预览",close:"收起预览",input:"输入",output:"输出"}}},import:{label:"导入...",title:"自描述文件导入看板内容",json_file:"描述文件(JSON格式)",this_dashboard:"此看板",this_file:"此文件"},function_utils:{trigger_text:"关于utils参数",modal_title:"关于utils参数",description:"参数 <code>utils</code> 是 <code>FunctionUtils</code>,包含以下内容:",document:"文档"},aggregation:{option:{none:"无",sum:"和",mean:"平均值",median:"中位数",min:"最小值",max:"最大值",cov:"变异系数",std:"标准差",quantile:{label:"分位",label_with_hint:"分位(99%, 95%, ...)"},custom:{label:"自定义",label_trigger:"编写函数",title:"自定义聚合方式"},pick_record:{label:"直接选择数据",method:{label:"数据记录",first:"第一条",last:"最后一条"}}}},rich_text:{dynamic_color:{label:"动态颜色",edit:"编辑动态颜色"}},chart:{chart_config:"图表设置",data_field:"数据字段",groups:{merico_suite:"思码逸套件",echarts_based_charts:"基于ECharts的图表",others:"其他"},label:{label:"文案",label_full:"标签文案",label_style:"标签文案样式",label_format:"标签文案格式"},label_position:{label:"文案位置",off:"不显示文案",top:"上",left:"左",right:"右",bottom:"下",inside:"内",inside_top:"内-上",inside_left:"内-左",inside_center:"内-中",inside_right:"内-右",inside_bottom:"内-下",inside_top_left:"内-上-左",inside_top_right:"内-上-右",inside_bottom_left:"内-下-左",inside_bottom_right:"内-下-右",outside:"外"},visual_map:{label:"视觉映射",continuous:{label:"连续型"},piecewise:{label:"分段型",mode:{pieces:"连续数据",categories:"离散数据"},add_a_piece:"加一个分段",interval:"值区间",piece_label:"文案"},bar_width:"长条的宽度",bar_height:"长条的高度",item_width:"小块的宽度",item_height:"小块的高度",calculable:"显示拖拽手柄",min_value:"最小值",max_value:"最大值",min_text:"最小值文案",max_text:"最大值文案",use_palette_x:'使用配色方案"{{x}}"',built_in_palettes:"内置配色方案",precision:"数据精度",skip_range:{lt_min:"小于最小值时的颜色",min:"最小值的颜色",max:"最大值的颜色",gt_max:"大于最大值时的颜色",follow_visual_map:"颜色跟随渐变规则"}},number_or_dynamic_value:{type:{static:"具体值",dynamic:"动态值"},dynamic:{setup:"设置",setup_title:"设置动态值",guide:"由函数确定动态值"}},orientation:{label:"朝向",horizontal:"水平",vertical:"垂直"},symbol_size:{label:"标记点大小",static:"固定值",dynamic:"动态值",setup:{label:"设置",title:"设置动态值",description:"由函数确定动态值"}},series:{label:"系列",name:"名称",y_axis:"Y轴",data_field:"数据字段",add:"增加一个系列",delete:"删除这个系列",line:{label:"线",line_settings:"线段设置",line_style:"线条样式",type:{label:"类型",solid:"实线",dashed:"方虚线",dotted:"圆点虚线"},line_width:"线宽",step:{label:"阶梯状",off:"不启用",start:"在当前点拐弯",middle:"在当前点与下个点中间拐弯",end:"在下个点拐弯"},smooth_line:"平滑曲线",show_name_on_line:"显示标签文案",show_symbol_on_line:"显示标记点"},bar:{label:"柱",stack:"堆放",stack_hint:"此值相同的柱系列会堆叠在一起",bar_gap:{label:"柱间隔",no_gap:"柱子之间无间隔",overlap:"柱子可互相重叠"},bar_width:{min:"最大柱宽",exact:"柱宽",max:"最大柱宽"}},scatter:{label:"散点"},group_by:{label:"按此字段拆分为多个系列",label_line:"按此字段拆分为多条线"}},axis:{tick_label:"刻度文案",customize_label:"自定义文案",overflow:{label:"溢出",max_width:"最大宽度",truncate:"截断",break_line:"换行",break_word:"断词换行",ellipsis:"省略符",section_title:{on_axis:"轴刻度上文案的溢出",in_tooltip:"提示框中的文案溢出"}},section_title:{label_format:"文案格式"},type:{value:"数值轴",category:"类目轴",time:"时间轴",log:"对数轴",click_to_learn_more:"点击 <1>这里</1> 以进一步了解这些选项"}},name_text:{align:{label:"名称贴靠侧",left:"左",center:"中",right:"右"}},rotate:"旋转",degree:"度",padding:"内间距",content_template:{label:"内容模板",hint:"均值: ${avg}"},x_axis:{label:"X轴",labels:"X轴",label_format:"刻度文案格式",add:"增加一条X轴",delete:"删除这条X轴",x_axis_name:"X轴名称",x_axis_data_field:"X轴数据字段",x_axis_type:"X轴类型",layout:"布局",position:{label:"位置",top:"上",bottom:"下"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},y_axis:{label:"Y轴",labels:"Y轴",label_format:"刻度文案格式",add:"增加一条Y轴",delete:"删除这条Y轴",y_axis_name:"Y轴名称",y_axis_name_anchor:"名称贴靠侧",y_axis_data_field:"Y轴数据字段",layout:"布局",position:{label:"位置",left:"左",right:"右"},value_range:"值范围",value_min:"最小值",value_max:"最大值",behavior:"表现",visible:"可见"},stats:{label:"统计内容",template:{above_chart:"统计内容模板(图表上方)",under_chart:"统计内容模板(图表下方)"}},legend:{label:"图例",show_legend:"显示图例",show_in_legend:"显示在图例中",hide_in_legend:"不显示在图例中",orientation:{label:"布局朝向",horizontal:"横向",vertical:"纵向"}},tooltip:{label:"提示框",additional_metrics:{description:"在此设置更多指标,来展示在散点的提示框",add:"增加一个指标",delete:"删除这个指标"},trigger:{label:"触发者",scatter_point:"散点",x_axis:"X轴"}},style:{label:"样式"},color:{label:"颜色",or:"或",set_any_color:"输入色号",pick_a_theme_color:"选择一个主题色",background_color:"背景色",text_color:"文字颜色",click_to_add_a_color:"点击增加一个颜色",color_gradient:"颜色渐变"},behavior:{label:"表现",invisible:"隐藏不可见"},heatmap:{heatblock:{label:"热力块",show_label:"展示值文案"}},reference_line:{label:"参考线",labels:"参考线",add:"增加一条参考线",name_placeholder:"均值参考线",delete:"删除这条参考线",orientation:{vertical_hint:"仅当X轴值为数字时可绘制"}},regression_line:{label:"回归线",labels:"回归线",add:"增加一条回归线",delete:"删除这条回归线",method:{label:"方法",linear:"线性回归",exponential:"指数回归",logistic:"指数回归",polynomial:"多项式回归",polynomial_order:"次"}},reference_area:{label:"参考区域",labels:"参考区域",add:"增加一面参考区域",delete:"删除这面参考区域",type:{label:"形状",rectangle:"矩形"},direction:{label:"方向",horizontal:"水平"},boundary:{upper:"上边界",lower:"下边界"},content:{label:"内容",content_text:"内容文字",text_position:"文字位置"},endpoint:{labels:"端点",left_bottom_point:"左下点",right_top_point:"右上点"}},zooming:{label:"缩放",scroll:{label:"滚轮缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用"},slider:{label:"滚动条缩放",x_axis:"对X轴启用",y_axis:"对Y轴启用",y_axis_disabled:"暂不可用,会与Y轴刻度文字重叠"}}},viz:{viz_config_banner:"可视化参数配置"},validation:{number:{require_a_number:"请填写一个数字"}}}},ui=dg.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:PE,zh:OE}}).use(pg).use(_.initReactI18next);ui.init(),Ch.forEach(e=>{var t;(t=e.translation)==null||t.forEach(n=>{ui.addResourceBundle(n.lang,"translation",{viz:n.resources},!0,!0)})});function Vf({lang:e,children:t}){return m.useEffect(()=>{ui.changeLanguage(e)},[e]),r.jsx(_.I18nextProvider,{i18n:ui,children:t})}function di(e){console.groupCollapsed("Running operation ",e.type),console.log(e),console.groupEnd()}function Nf(e,t){m.useEffect(()=>{const n=s=>{di(s);const{viewID:i}=s.detail;if(!i){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(i),t&&e.views.setIDOfVIE(i)};return window.addEventListener("open-view",n),()=>{window.removeEventListener("open-view",n)}},[e,t]),m.useEffect(()=>{const n=s=>{di(s);const{dictionary:i,payload:a}=s.detail;if(!a||Object.keys(a).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}const l={};Object.entries(i).forEach(([c,u])=>{const d=v.get(a,u);l[c]=d}),e.filters.applyValuesPatch(l)};return window.addEventListener("set-filter-values",n),()=>{window.removeEventListener("set-filter-values",n)}},[e]),m.useEffect(()=>{function n(i){return Array.isArray(i)?[]:typeof i=="object"?{}:typeof i=="boolean"?!1:typeof i=="string"?"":typeof i=="number"?0:i}const s=i=>{di(i);const a={},{filter_keys:l}=i.detail;l.forEach(c=>{const u=v.get(e.filters.values,c),d=n(u);a[c]=d}),e.filters.applyValuesPatch(a)};return window.addEventListener("clear-filter-values",s),()=>{window.removeEventListener("clear-filter-values",s)}},[e]),m.useEffect(()=>{const n=s=>{di(s);const{urlTemplate:i,openInNewTab:a,enableEncoding:l=!1,payload:c}=s.detail;if(!i){console.error(new Error("[Open Link] URL is empty"));return}function u(h){return v.cloneDeepWith(h,g=>{if(l&&typeof g=="string")return encodeURIComponent(g)})}const p=v.template(i||"")(u({...c,filters:e.payloadForSQL.filters,context:e.payloadForSQL.context}));window.open(p,a?"_blank":"_self","noopener")};return window.addEventListener("open-link",n),()=>{window.removeEventListener("open-link",n)}},[e])}function $f(e){return m.useCallback(t=>t.provideValue(je.pluginManager,e.pluginManager).provideValue(je.vizManager,e.vizManager).provideValue(je.colorManager,e.colorManager),[])}const PL="",LE=D.observer(({saveDashboardChanges:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Y(),i=()=>{n.openConfirmModal({title:r.jsxs(o.Group,{position:"left",children:[r.jsx(M.IconAlertTriangle,{size:18,color:"red"}),r.jsx(o.Text,{children:"You are reverting changes"})]}),labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>s.reset(),zIndex:320,withCloseButton:!1})},a=s.changed;return r.jsxs(o.Group,{spacing:0,children:[r.jsx(o.Button,{color:"green",variant:"filled",size:"xs",leftIcon:r.jsx(M.IconDeviceFloppy,{size:18}),onClick:e,disabled:!a,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:t("common.actions.save_changes")}),r.jsxs(o.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!a,children:[r.jsx(o.Menu.Target,{children:r.jsx(o.ActionIcon,{variant:"default",disabled:!a,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:r.jsx(M.IconCaretDown,{size:18})})}),r.jsx(o.Menu.Dropdown,{children:r.jsx(o.Menu.Item,{icon:r.jsx(M.IconRecycle,{size:14,color:"red"}),disabled:!a,onClick:i,children:t("common.actions.revert_changes")})})]})]})}),BE=D.observer(({saveDashboardChanges:e,onExit:t,headerSlot:n=null})=>{_.useTranslation();const s=Z(),i=s.content.changed,a=()=>{t({hasChanges:i,dashboardId:s.id})};return r.jsx(o.Header,{height:60,px:"md",py:0,sx:{zIndex:299},children:r.jsxs(o.Group,{position:"apart",sx:{height:60,minWidth:"1000px",position:"relative"},children:[r.jsxs(o.Group,{children:[r.jsx(o.Button,{size:"xs",color:i?"red":"green",leftIcon:r.jsx(M.IconArrowLeft,{size:20}),onClick:a,children:r.jsx(o.Group,{spacing:4,children:r.jsxs(_.Trans,{i18nKey:"common.actions.end_editing",values:{name:s.name},children:["End Editing ",r.jsx(o.Text,{td:"underline",children:s.name})]})})}),r.jsx(LE,{saveDashboardChanges:e})]}),r.jsx(o.Group,{position:"right",sx:{flexGrow:1},children:n})]})})}),Ff={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},qE=D.observer(()=>{var i;const{t:e}=_.useTranslation(),t=Y(),n=((i=t.views.VIE)==null?void 0:i.type)===q.Tabs,s=()=>t.addANewPanel(t.views.idOfVIE);return n?r.jsx(o.Tooltip,{label:e("common.choose_a_tab_first"),children:r.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:r.jsx(M.IconPlaylistAdd,{size:20}),sx:{...Ff,transform:"none !important"},children:e("panel.add")})}):r.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:s,leftIcon:r.jsx(M.IconPlaylistAdd,{size:20}),sx:{...Ff,background:"rgb(231, 245, 255)"},children:e("panel.add")})}),VE=D.observer(({done:e})=>{var E,N;const{t}=_.useTranslation(),s=Y().layouts,i=m.useMemo(()=>({list:s.breakpointsInfo}),[s.breakpointsInfo]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d,formState:p}=b.useForm({defaultValues:i}),{fields:h,append:f,remove:g}=b.useFieldArray({control:a,name:"list",rules:{validate:R=>{if(console.log({values:R}),v.uniqBy(R,"breakpoint").length!==R.length)return"Screen sizes should be unique by min width"}}}),y=c("list"),j=h.map((R,pe)=>({...R,...y[pe]})),k=()=>{f({id:Ut.v4(),name:"",breakpoint:""})},S=({list:R})=>{const pe=R.filter(ie=>Number.isFinite(ie.breakpoint));s.updateLayoutSetsInfo(pe),e()},T=u(),z=m.useMemo(()=>{const R={list:T.list.filter(pe=>!!pe.name&&Number.isFinite(pe.breakpoint))};return!v.isEqual(R,i)},[T,i]),I=(N=(E=p.errors.list)==null?void 0:E.root)==null?void 0:N.message;return r.jsx(r.Fragment,{children:r.jsxs("form",{onSubmit:l(S),children:[r.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,withBorder:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"340px"},children:t("common.name")}),r.jsx("th",{style:{width:"160px"},children:t("breakpoint.breakpoint")}),r.jsx("th",{})]})}),r.jsxs("tbody",{children:[j.map((R,pe)=>r.jsxs("tr",{children:[r.jsx("th",{children:R.id==="basis"?R.name:r.jsx(b.Controller,{name:`list.${pe}.name`,control:a,render:({field:ie})=>r.jsx(o.TextInput,{size:"xs",label:"",required:!0,sx:{flex:1},...ie})})}),r.jsx("td",{children:R.id==="basis"?r.jsxs(o.Text,{ff:"monospace",children:[R.breakpoint,"px"]}):r.jsx(b.Controller,{name:`list.${pe}.breakpoint`,control:a,render:({field:ie})=>r.jsx(o.NumberInput,{size:"xs",label:"",required:!0,max:1e4,hideControls:!0,rightSection:r.jsx(o.Text,{color:"dimmed",children:"px"}),rightSectionProps:{style:{width:"30px"}},sx:{flex:1,fontFamily:"monospace"},styles:{input:{paddingRight:"30px"}},...ie})})}),r.jsx("td",{children:R.id!=="basis"&&r.jsx(o.ActionIcon,{mx:"auto",size:"xs",variant:"subtle",color:"red",onClick:()=>g(pe),children:r.jsx(M.IconTrash,{})})})]},R.id)),r.jsx("tr",{style:{backgroundColor:"transparent"},children:r.jsx("td",{colSpan:3,style:{padding:"0"},children:r.jsx(o.Tooltip,{label:t("breakpoint.add"),children:r.jsx(o.ActionIcon,{variant:"subtle",size:"md",color:"blue",onClick:k,sx:{width:"100%"},children:r.jsx(M.IconPlus,{size:18})})})})})]})]}),r.jsx(o.Text,{mt:6,ta:"right",size:"xs",color:"red",children:I??" "}),r.jsxs(o.Group,{mt:6,position:"apart",children:[r.jsx(o.Button,{color:"orange",size:"xs",onClick:()=>d(),leftIcon:r.jsx(M.IconRecycle,{size:18}),disabled:!z,children:t("common.actions.revert")}),r.jsx(o.Button,{color:"green",size:"xs",type:"submit",leftIcon:r.jsx(M.IconDeviceFloppy,{size:18}),disabled:!z,children:t("common.actions.save_changes")})]})]})})}),NE=D.observer(()=>{const{t:e}=_.useTranslation(),[t,{open:n,close:s}]=he.useDisclosure(!1),i=Y(),a=i.layouts.currentBreakpoint,l=i.layouts.currentLayoutRange,c=()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},u=()=>{s(),c()};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{children:[r.jsxs(o.Menu,{withArrow:!0,withinPortal:!0,zIndex:320,trigger:"hover",children:[r.jsx(o.Menu.Target,{children:r.jsx(o.Button,{size:"xs",variant:"subtle",leftIcon:r.jsx(M.IconDevices,{size:16}),sx:{borderRadius:0},children:r.jsxs(o.Group,{spacing:6,children:[r.jsx(o.Text,{size:"xs",fw:"normal",children:l.name}),r.jsx(o.Text,{size:"xs",color:"#777",children:i.layouts.currentRangeText})]})})}),r.jsxs(o.Menu.Dropdown,{children:[i.layouts.breakpointRanges.map(d=>r.jsx(o.Menu.Item,{onClick:()=>i.layouts.setCurrentBreakpoint(d.id),disabled:a===d.id,children:r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Text,{size:"sm",children:d.name}),r.jsx(o.Text,{size:"xs",color:"dimmed",children:d.text})]})},d.id)),r.jsx(o.Menu.Divider,{}),r.jsx(o.Menu.Item,{color:"blue",icon:r.jsx(M.IconSettings,{size:14}),onClick:n,children:r.jsx(o.Text,{size:"sm",children:e("breakpoint.manage")})})]})]}),i.layouts.divisionPreviewScale<1&&r.jsx(o.Text,{size:"xs",color:"dimmed",children:Hr(i.layouts.divisionPreviewScale).format({output:"percent",mantissa:0})})]}),r.jsx(o.Modal,{opened:t,onClose:u,title:e("breakpoint.label",{count:2}),withinPortal:!0,zIndex:320,size:600,closeOnClickOutside:!1,children:r.jsx(VE,{done:u})})]})}),Gf={height:"30px",borderRight:"none",borderTop:"none",borderLeft:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},$E=D.observer(()=>{var i;const{t:e}=_.useTranslation(),t=Y(),n=((i=t.views.VIE)==null?void 0:i.type)===q.Tabs,s=()=>{var a;return(a=t.views.VIE)==null?void 0:a.downloadSchema()};return n?r.jsx(o.Tooltip,{label:e("common.choose_a_tab_first"),children:r.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:r.jsx(M.IconCode,{size:16}),sx:{...Gf,transform:"none !important"},children:e("view.download_schema")})}):r.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:s,leftIcon:r.jsx(M.IconCode,{size:16}),sx:{...Gf},children:e("view.download_schema")})}),pi=({headers:e,rows:t})=>r.jsxs(o.Table,{fontSize:"xs",highlightOnHover:!0,sx:{tableLayout:"fixed",fontFamily:"monospace"},children:[r.jsx("thead",{children:e}),r.jsx("tbody",{children:t})]}),FE=({content:e})=>{const{t}=_.useTranslation(),n=e.views;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("view.labels")}),r.jsx(pi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.name")}),r.jsx("th",{children:t("common.type")})]}),rows:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.id}),r.jsx("td",{children:s.name}),r.jsx("td",{children:t(`view.component.${s.type}.label`)})]},s.id))})]})},GE=({content:e})=>{const{t}=_.useTranslation(),n=e.filters;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("filter.labels")}),r.jsx(pi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.key")}),r.jsx("th",{children:t("common.label")})]}),rows:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.id}),r.jsx("td",{children:s.key}),r.jsx("td",{children:s.label})]},s.id))})]})},WE=({content:e})=>{const{t}=_.useTranslation(),n=e.panels;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("panel.labels")}),r.jsx(pi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.name")}),r.jsx("th",{children:t("visualization.component")})]}),rows:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.id}),r.jsx("td",{children:s.name}),r.jsx("td",{children:s.viz.type})]},s.id))})]})},RE=({content:e})=>{var s;const{t}=_.useTranslation(),n=(s=e.definition)==null?void 0:s.queries;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("query.labels")}),r.jsx(pi,{headers:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"160px"},children:t("common.id")}),r.jsx("th",{children:t("common.name")}),r.jsx("th",{style:{width:"140px"},children:t("common.type")}),r.jsx("th",{style:{width:"260px"},children:t("data_source.label")})]}),rows:n.map(i=>r.jsxs("tr",{children:[r.jsx("td",{children:i.id}),r.jsx("td",{children:i.name}),r.jsx("td",{children:i.type}),r.jsx("td",{children:i.key})]},i.id))})]})},QE=({content:e})=>{var s;const{t}=_.useTranslation(),n=(s=e.definition)==null?void 0:s.sqlSnippets;return!Array.isArray(n)||n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("sql_snippet.labels")}),r.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:r.jsx(M.IconPointFilled,{size:10}),children:n.map(i=>r.jsx(o.List.Item,{children:i.key},i.key))})]})},UE=({content:e})=>{var s;const{t}=_.useTranslation(),n=Object.keys(((s=e.definition)==null?void 0:s.mock_context)??{});return n.length===0?null:r.jsxs(o.Box,{children:[r.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:t("mock_context.label")}),r.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:r.jsx(M.IconPointFilled,{size:10}),children:n.map(i=>r.jsx(o.List.Item,{children:i},i))})]})},YE=({content:e})=>e?r.jsxs(o.Box,{children:[r.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(o.Text,{ta:"left",c:"dimmed",children:"Preview"}),r.jsxs(o.Stack,{children:[r.jsx(FE,{content:e}),r.jsx(GE,{content:e}),r.jsx(WE,{content:e}),r.jsx(RE,{content:e}),r.jsx(QE,{content:e}),r.jsx(UE,{content:e})]})]}):null;function KE(e){if(e.target===null)throw new Error("FileReader failed with null result");if(typeof e.target.result!="string")throw new Error(`Unparsable file content of type: ${typeof e.target.result}`);let t=JSON.parse(e.target.result);if("content"in t&&(t=t.content),t.version!==en)throw new Error("Schema version mismatch");return t}const XE=D.observer(({onSuccess:e,stretchModal:t,shrinkModal:n})=>{var S,T;const{t:s}=_.useTranslation(),i=Y(),{handleSubmit:a,formState:{errors:l},setValue:c,watch:u,setError:d,clearErrors:p}=b.useForm({defaultValues:{content:null}}),h=({content:z})=>{try{if(!z)throw new Error("please use a valid json file");i.applyJSONSchema(z),rn.showNotification({title:"Successful",message:"",color:"green"}),e()}catch(I){console.error(I),rn.showNotification({title:"Failed",message:I.message,color:"red"})}},[f,g]=m.useState(null);m.useEffect(()=>{if(!f)return;const z=new FileReader;z.readAsText(f,"UTF-8"),z.onload=I=>{try{const E=KE(I);c("content",E),p("content")}catch(E){console.error(E),d("content",{type:"custom",message:E.message})}},z.onabort=()=>console.log("🟨 abort"),z.onerror=()=>{z.error&&(console.error(z.error),d("content",{type:"custom",message:z.error.message}))}},[f]);const[y]=u(["content"]),j=!y,k=(S=l==null?void 0:l.content)==null?void 0:S.message;return m.useEffect(()=>{!y||k?n():t()},[y,k]),r.jsx(o.Box,{mx:"auto",sx:{position:"relative"},children:r.jsxs("form",{onSubmit:a(h),children:[r.jsx(o.FileInput,{label:s("import.json_file"),required:!0,value:f,onChange:g,error:(T=l==null?void 0:l.content)==null?void 0:T.message,sx:{maxWidth:500}}),k?r.jsx(o.Table,{fontSize:12,mt:10,children:r.jsxs("tbody",{children:[r.jsxs("tr",{children:[r.jsx("th",{children:s("import.this_dashboard")}),r.jsx("td",{children:en})]}),r.jsxs("tr",{children:[r.jsx("th",{children:s("import.this_file")}),r.jsx("td",{style:{color:"red"},children:y==null?void 0:y.version})]})]})}):r.jsxs(r.Fragment,{children:[r.jsx(YE,{content:y}),r.jsx(o.Group,{position:"right",my:"md",children:r.jsx(o.Button,{type:"submit",color:"green",disabled:j,children:s("common.actions.confirm")})})]})]})})}),Wf={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},JE=D.observer(()=>{var d;const{t:e}=_.useTranslation(),[t,{open:n,close:s}]=he.useDisclosure(!1),[i,{setTrue:a,setFalse:l}]=W.useBoolean(!1),u=((d=Z().content.views.VIE)==null?void 0:d.type)===q.Tabs;return u?r.jsx(o.Tooltip,{label:e("common.choose_a_tab_first"),children:r.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:r.jsx(M.IconFileImport,{size:16}),sx:{...Wf,transform:"none !important"},children:e("import.label")})}):r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"subtle",color:"blue",radius:0,size:"xs",disabled:u||t,onClick:n,leftIcon:r.jsx(M.IconFileImport,{size:16}),sx:{...Wf},children:e("import.label")}),r.jsx(o.Modal,{opened:t,onClose:s,title:e("import.title"),trapFocus:!0,onDragStart:p=>{p.stopPropagation()},withinPortal:!0,zIndex:320,size:i?"90vw":500,children:r.jsx(XE,{onSuccess:s,stretchModal:a,shrinkModal:l})})]})}),ZE={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},HE=D.observer(()=>r.jsx(o.Box,{sx:ZE,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:r.jsxs(o.Group,{position:"apart",align:"center",sx:{height:"30px"},children:[r.jsxs(o.Group,{position:"left",spacing:0,children:[r.jsx(qE,{}),r.jsx(JE,{})]}),r.jsx(NE,{}),r.jsx(o.Group,{position:"right",spacing:0,children:r.jsx($E,{})})]})})),eA=D.observer(e=>r.jsxs(r.Fragment,{children:[r.jsx(BE,{...e}),r.jsx(HE,{})]})),OL="";function tA(e,t,n){const s=[];return e.filter(i=>"__INTERACTIONS"in i.viz.conf).forEach((i,a)=>{const l=t[i.id];l.data.interactions=v.get(l,"data.interactions",[]);const{__INTERACTIONS:c,__OPERATIONS:u,__TRIGGERS:d}=i.viz.conf;Object.entries(u).forEach(([p,h])=>{const{schemaRef:f,data:g}=h,{config:y}=g;switch(f){case"builtin:op:open-link":let j=y.urlTemplate.substring(0,100);y.urlTemplate.length>=20&&(j+="..."),l.type="interaction",l.data.interactions.push({schemaRef:f,urlTemplate:y.urlTemplate,shortURLTemplate:j});return;case"builtin:op:open_view":s.push({id:`OPERATION--${p}`,source:i.id,target:y.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:f,filters:Object.keys(y.dictionary).map(k=>({key:k,label:n[k]}))});return;case"builtin:op:clear_filter_values":l.type="interaction",l.data.interactions.push({schemaRef:f,filters:y.filter_keys.map(k=>({key:k,label:n[k]}))});return;default:return}})}),s}function nA(e,t){const n=e.filters.keyLabelMap;return{edges:tA(e.panels.list,t,n),edgeNodes:[]}}function Rf(e,t,n){return e*t+e*n}function rA(e,t,n){return e*t+(e-1)*n}const hi=25,Tl=40,Qf=25,Dl=350,sA=150,iA=150,Uf=150,Yf=300,fi=40,Kf=25,aA=300;function oA(e,t){const n=v.keyBy(t,i=>i.id),s=[];return e.current.forEach((i,a)=>{i.panelIDs.forEach((l,c)=>{const u=Rf(c,fi,Kf)+Tl,d=n[l];if(!d){s.push({id:l,_node_type:"panel",parentNode:i.id,data:{label:`!: ${l}`},position:{x:hi,y:u},sourcePosition:Ee.Position.Right,targetPosition:Ee.Position.Left,style:{width:Yf,height:fi}});return}const p=d.name;s.push({id:d.id,_node_type:"panel",parentNode:i.id,data:{label:p},position:{x:hi,y:u},sourcePosition:Ee.Position.Right,targetPosition:Ee.Position.Left,style:{width:Yf,height:fi}})})}),s}const lA={[q.Division]:"Div",[q.Modal]:"Modal",[q.Tabs]:"Tabs"},cA=Df;function uA(e){return e.current.map((n,s)=>{const i=rA(n.panelIDs.length,fi,Kf)+Tl+Qf;let a=[];return n.type===q.Tabs&&(a=n.config.tabsInOrder.map(c=>c.view_id)),{id:n.id,_node_type:"view-root",_view_type:n.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:a,data:{label:`${lA[n.type]}:${n.name}`},position:{x:0,y:0},sourcePosition:Ee.Position.Right,targetPosition:Ee.Position.Left,className:"light",style:{backgroundColor:cA[n.type],width:Dl,height:i}}})}function dA(e){const t=v.keyBy(e,n=>n.id);e.forEach(n=>{n._node_type!=="view-root"||n._view_type!==q.Tabs||n._tab_view_ids.forEach(s=>{t[s].parentNode=n.id})})}function pA(e){const t=uA(e.views);dA(t);const n=oA(e.views,e.panels.list);return[...t,...n]}function hA({nodeMap:e,nodes:t,edges:n}){t.forEach(s=>{s._node_type!=="view-root"||s._view_type!==q.Tabs||(s.sourcePosition=Ee.Position.Bottom,s.style.width=Dl+hi*2,s.style.height=Qf+s._tab_view_ids.reduce((i,a)=>{const l=e[a];l.position.y=i,l.position.x=hi;const c=l.style.height;return i+c+20},Tl))})}function fA({nodeMap:e,nodes:t,edges:n}){n.filter(s=>s.label==="Open View").forEach(s=>{const i=e[s.source],a=e[s.target];if(!i||!a||!i.parentNode)return;const l=e[i.parentNode];l._node_type!=="view-root"||a._node_type!=="view-root"||(a._view_level+=1+l._view_level,l._sub_view_ids.push(a.id))}),t.sort((s,i)=>s._node_type==="view-root"&&i._node_type==="view-root"?s._view_level-i._view_level:s._node_type!=="view-root"&&i._node_type!=="view-root"?0:s._node_type==="view-root"?-1:1)}function mA({nodeMap:e,nodes:t,edges:n}){const s={};n.forEach(i=>{if(i.label!=="Open View")return;const a=e[i.source],l=e[i.target];if(a&&l&&a.parentNode){const c=e[a.parentNode],u=c.position.x,d=Number(v.get(l,"style.height",0)),p=Number(c.style.width);l.position.x=u+p+aA,c._view_level===0&&l._sub_view_ids.length===0&&(a.sourcePosition=Ee.Position.Left,l.targetPosition=Ee.Position.Right,l.position.x*=-1);const f=l.position.x,g=v.get(s,f,0);l.position.y=g,s[f]=g+d+Uf}})}function gA({nodeMap:e,nodes:t,edges:n}){const s=new Set,i=new Set;n.forEach(l=>{s.add(l.source),i.add(l.target)}),t.filter(l=>l._node_type!=="view-root"||l.id==="Main"||l.parentNode?!1:!s.has(l.id)&&!i.has(l.id)).forEach((l,c)=>{l.position.x=Rf(c,Dl,iA),l.position.y=0-sA-Uf})}function xA({nodeMap:e,nodes:t,edges:n}){const s={nodeMap:e,nodes:t,edges:n};return gA(s),fA(s),hA(s),mA(s),{nodes:t,edges:n}}function yA(e){const t=pA(e),n=v.keyBy(t,u=>u.id),{edges:s,edgeNodes:i}=nA(e,n),a=[...t,...i],l=v.keyBy(a,u=>u.id),c={edges:v.uniqBy(s,u=>u.id),nodes:a,nodeMap:l};return xA(c)}const LL="",Ml={"builtin:op:open-link":r.jsx(o.ThemeIcon,{color:"blue",size:20,radius:"xl",children:r.jsx(M.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":r.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:r.jsx(M.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":r.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:r.jsx(M.IconCircleOff,{size:14})})};function bA(e){const t=[];return e.forEach(n=>{switch(n.schemaRef){case"builtin:op:open-link":t.push({key:n.urlTemplate,icon:Ml[n.schemaRef],text:r.jsxs(o.Group,{spacing:4,children:[r.jsx(o.Text,{children:"Open: "}),r.jsx(o.Text,{color:"dimmed",children:n.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":n.filters.forEach(({key:s,label:i})=>{t.push({key:n.schemaRef+s,icon:Ml[n.schemaRef],text:r.jsx(o.Group,{spacing:4,children:r.jsxs(o.Text,{children:["Set Filter: ",i]})})})});return;case"builtin:op:clear_filter_values":n.filters.forEach(({key:s,label:i})=>{t.push({key:n.schemaRef+s,icon:Ml[n.schemaRef],text:r.jsx(o.Group,{spacing:4,children:r.jsxs(o.Text,{children:["Clear Filter: ",i]})})})});return}}),t}const vA=m.memo(({data:e,isConnectable:t,sourcePosition:n=Ee.Position.Right,targetPosition:s=Ee.Position.Left,...i})=>{const a=m.useMemo(()=>bA(e.interactions),[e.interactions]);return r.jsxs(r.Fragment,{children:[r.jsx(Ee.Handle,{type:"target",position:s,isConnectable:t}),r.jsx(o.Box,{sx:{position:"absolute",top:0,right:0},children:r.jsx(V.ChevronsUpRight,{size:12})}),r.jsxs(o.HoverCard,{shadow:"xl",withinPortal:!0,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Text,{children:e.label})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(o.List,{spacing:"xs",size:"sm",center:!0,children:a.map(l=>r.jsx(o.List.Item,{icon:l.icon,children:l.text},l.key))})})]}),r.jsx(Ee.Handle,{type:"source",position:n,isConnectable:t})]})}),BL="",_A={interaction:vA},jA=D.observer(()=>{const e=_e(),{edges:t,nodes:n}=yA(e);return r.jsxs(Ee,{nodes:n,edges:t,onNodesChange:v.noop,onEdgesChange:v.noop,onConnect:v.noop,className:"interactions-viewer",fitView:!0,nodeTypes:_A,children:[r.jsx(Ee.MiniMap,{}),r.jsx(Ee.Controls,{}),r.jsx(Ee.Background,{})]})}),wA=D.observer(({opened:e,close:t})=>{const{t:n}=_.useTranslation();return r.jsx(o.Modal,{size:"96vw",opened:e,onClose:t,title:n("interactions.interactions_viewer"),trapFocus:!0,onDragStart:s=>{s.stopPropagation()},styles:{body:{height:"calc(90vh - 54px)"},content:{transform:"none !important"}},zIndex:300,children:r.jsx(jA,{})})}),CA={"> button":{"&:first-of-type":{borderTopRightRadius:0,borderBottomRightRadius:0,borderRightWidth:.5},":not(:first-of-type):not(:last-of-type)":{borderTopRightRadius:0,borderBottomRightRadius:0,borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5,borderRightWidth:.5},"&:last-of-type":{borderTopLeftRadius:0,borderBottomLeftRadius:0,borderLeftWidth:.5}}};function SA({onClick:e,name:t,active:n,openSettings:s}){return r.jsxs(o.Box,{sx:{position:"relative"},children:[r.jsx(o.UnstyledButton,{sx:i=>({display:"block",width:"100%",padding:i.spacing.xs,borderRadius:0,position:"relative",color:i.black,"&:hover":{backgroundColor:i.colors.gray[0]},backgroundColor:n?i.colors.gray[2]:"transparent"}),children:r.jsx(o.Group,{sx:{width:"calc(100% - 28px)"},onClick:e,children:r.jsx(o.Text,{size:"sm",children:t})})}),n&&r.jsx(o.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:r.jsx(o.ActionIcon,{onClick:s,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:r.jsx(M.IconAdjustments,{size:16})})})]})}const kA=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=Y(),s=m.useCallback(a=>()=>n.views.setIDOfVIE(a),[n]),i=a=>{t.editor.open(["_VIEWS_",a])};return r.jsxs(o.Box,{sx:{position:"relative"},children:[n.views.options.map(a=>r.jsx(SA,{active:n.views.idOfVIE===a.value,name:a.label,onClick:s(a.value),openSettings:()=>i(a.value)},a.value)),r.jsx(o.Divider,{variant:"dashed"}),r.jsx(o.Button,{variant:"subtle",rightIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:n.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:e("view.add")})]})}),TA=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=Y(),s=()=>{if(!n.queries.firstID){t.editor.open(["_QUERIES_",""]);return}t.editor.open(["_QUERIES_",n.queries.firstID])},i=()=>{if(!n.filters.firstID){t.editor.open(["_FILTERS_",""]);return}t.editor.open(["_FILTERS_",n.filters.firstID])},[a,l]=m.useState(!1),c=()=>l(!0),u=()=>l(!1);return r.jsxs(o.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},zIndex:299,children:[r.jsxs(o.Navbar.Section,{children:[r.jsxs(o.Group,{grow:!0,spacing:0,sx:{...CA,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[r.jsx(o.Tooltip,{label:e("filter.labels"),withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:i,children:r.jsx(M.IconFilter,{size:18})})}),r.jsx(o.Tooltip,{label:e("query.labels"),withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:s,children:r.jsx(M.IconDatabase,{size:18})})}),r.jsx(o.Tooltip,{label:e("interactions.interactions_viewer"),withinPortal:!0,children:r.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:c,children:r.jsx(M.IconLink,{size:18})})})]}),r.jsx(wA,{opened:a,close:u})]}),r.jsx(o.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:e("view.labels")})}),r.jsx(o.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:r.jsx(kA,{})}),r.jsx(o.Navbar.Section,{children:r.jsx(o.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:r.jsx(o.Button,{size:"xs",leftIcon:r.jsx(M.IconSettings,{size:20}),onClick:()=>t.editor.open([]),children:e("common.titles.settings")})})})]})}),DA={[ce.Checkbox]:"true",[ce.DateRange]:"[new Date('2023-01-01 00:00:00'), new Date('2024-01-01 00:00:00')]",[ce.MultiSelect]:"[]",[ce.Select]:'""',[ce.TreeSelect]:"[]",[ce.TextInput]:'""'},MA=e=>["function getDefaultValue(filter, utils, context) {",` return ${DA[e]};`,"}"].join(`
451
+ `),ir=D.observer(({filter:e})=>{const{t}=_.useTranslation();return r.jsx(bo,{label:"",title:t("filter.field.custom_default_value.title"),triggerLabel:t("filter.field.custom_default_value.trigger"),value:e.default_value_func,onChange:e.setDefaultValueFunc,defaultValue:MA(e.type),triggerButtonProps:{size:"xs",color:"grape",sx:{flexGrow:0,alignSelf:"flex-start"},leftIcon:r.jsx(M.IconMathFunction,{size:16})},description:r.jsx(o.Alert,{title:t("filter.field.custom_default_value.tips"),color:"gray",mb:16,children:r.jsxs(o.List,{size:13,type:"ordered",children:[r.jsx(o.List.Item,{children:t("filter.field.custom_default_value.tip_1")}),r.jsx(o.List.Item,{children:t("filter.field.custom_default_value.tip_2")})]})})})}),zA=D.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config;return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Checkbox,{checked:s.default_value,onChange:i=>s.setDefaultValue(i.currentTarget.checked),label:n("filter.widget.checkbox.default_checked")}),r.jsx(ir,{filter:t})]}),r.jsx(Do,{label:n("filter.widget.checkbox.description"),value:s.description,onChange:s.setDescription,styles:{root:{flexGrow:1,minHeight:"400px"}}})]})}),IA=[{label:"2022",value:"YYYY"},{label:"202201",value:"YYYYMM"},{label:"20220101",value:"YYYYMMDD"},{label:"2022-01",value:"YYYY-MM"},{label:"2022-01-01",value:"YYYY-MM-DD"}],EA=D.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config,i=m.useMemo(()=>Qo().map(({key:a,value:l,group:c})=>({label:n(`filter.widget.date_range.shortcut.${c}.full.${a}`),value:l,group:n(`filter.widget.date_range.shortcut.${c}.label`)})),[]);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{children:[r.jsx(o.Checkbox,{checked:s.required,onChange:a=>s.setRequired(a.currentTarget.checked),label:n("filter.widget.date_range.required")}),r.jsx(o.Checkbox,{checked:s.allowSingleDateInRange,onChange:a=>s.setAllowSingleDateInRange(a.currentTarget.checked),label:n("filter.widget.date_range.allow_single_date")})]}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(o.Select,{data:IA,label:n("filter.widget.date_range.display_format"),value:s.inputFormat,onChange:s.setInputFormat}),r.jsx(o.NumberInput,{label:n("filter.widget.date_range.max_days"),min:0,value:s.max_days,onChange:s.setMaxDays,hideControls:!0})]}),r.jsxs(o.Group,{children:[r.jsx(Mh,{label:n("filter.widget.date_range.default_value"),config:s,value:s.default_value,onChange:s.setDefaultValue,disabled:!!s.default_shortcut}),r.jsx(o.Select,{data:i,label:n("filter.widget.date_range.default_by_shortcut"),value:s.default_shortcut,onChange:s.setDefaultShortcut,placeholder:n("filter.widget.date_range.default_by_shortcut_placeholder"),clearable:!0,sx:{flexGrow:1},maxDropdownHeight:500})]}),r.jsx(ir,{filter:t})]})}),zl=D.observer(({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),s=Z(),i=Y(),a=m.useMemo(()=>i.queries.options,[i.queries.current]),l=a.length===0,c=u=>{s.editor.setPath(["_QUERIES_",u])};return r.jsx(o.Select,{label:r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Text,{children:n("filter.widget.common.use_query_data_as_options")}),e&&r.jsx(o.Button,{size:"xs",leftIcon:r.jsx(M.IconArrowCurveRight,{size:16}),variant:"subtle",color:"blue",onClick:()=>c(e),children:n("query.open")})]}),data:a,value:e,onChange:t,allowDeselect:!1,clearable:!0,sx:{flexGrow:1},disabled:l,error:l?"You need to add a query in Data Settings":void 0,styles:{label:{display:"block"}}})}),AA=`
450
452
  // row
451
453
  {
452
454
  label: string;
453
455
  value: string;
454
456
  description?: string; // optional
455
457
  }
456
- `,Hc=()=>{const{t}=_.useTranslation(),[e,n]=m.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx(a.Button,{variant:"subtle",compact:!0,onClick:()=>n(r=>!r),children:t(e?"common.actions.close":"filter.widget.common.see_data_structure")}),s.jsx(a.Collapse,{in:e,children:s.jsx(jt.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:BT})})]})},LT=S.observer(function({filter:e}){const{t:n}=_.useTranslation(),r=e.config,i=()=>{r.addStaticOption({label:"",value:""})},o=r.static_options,l=[...o];return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Checkbox,{checked:r.required,onChange:c=>r.setRequired(c.currentTarget.checked),label:n("filter.widget.select.required")}),s.jsx(Ht,{filter:e})]}),s.jsx(a.TextInput,{label:n("filter.widget.select.width"),description:n("filter.widget.multi_select.width_description"),value:r.min_width,onChange:c=>r.setMinWidth(c.currentTarget.value),placeholder:"200px"}),s.jsx(a.Divider,{label:n("filter.widget.select.configure_options"),labelPosition:"center"}),s.jsxs(a.Stack,{spacing:10,sx:{position:"relative",minHeight:"50px"},children:[r.usingQuery&&s.jsxs(s.Fragment,{children:[s.jsx(a.Overlay,{opacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),s.jsx(a.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:s.jsx(a.Text,{color:"white",size:16,children:n("filter.widget.common.using_query")})})]}),o.length>0&&s.jsx(a.MultiSelect,{label:n("filter.widget.select.default_selection"),data:l,value:[...r.default_value],onChange:r.setDefaultValue}),o.map((c,u)=>s.jsxs(a.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[s.jsx(a.TextInput,{label:n("common.label"),required:!0,value:r.static_options[u].label,onChange:d=>{r.static_options[u].setLabel(d.currentTarget.value)},sx:{flexGrow:1}}),s.jsx(a.TextInput,{label:n("common.value"),required:!0,value:r.static_options[u].value,onChange:d=>{r.static_options[u].setValue(d.currentTarget.value)},sx:{flexGrow:1}}),s.jsx(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>r.removeStaticOption(u),sx:{position:"absolute",top:28,right:5},children:s.jsx(L.Trash,{size:16})})]},u)),s.jsx(a.Button,{mt:10,size:"xs",color:"blue",leftIcon:s.jsx(L.PlaylistAdd,{size:20}),onClick:i,sx:{width:"50%"},mx:"auto",children:n("common.actions.add_an_option")})]}),s.jsx(a.Divider,{label:n("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),s.jsx(a.NumberInput,{value:r.default_selection_count,onChange:r.setDefaultSelectionCount,label:n("filter.widget.common.default_selection_count")}),s.jsx(zi,{value:r.options_query_id,onChange:r.setOptionsQueryID}),s.jsx(Hc,{})]})}),qT=S.observer(function({filter:e}){const{t:n,i18n:r}=_.useTranslation(),i=e.config,o=()=>{i.addStaticOption({label:"",value:""})},l=i.static_options,c=m.useMemo(()=>[{label:n("filter.widget.select.no_default_selection"),value:""},...l],[r.language,l]);return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Checkbox,{checked:i.required,onChange:u=>i.setRequired(u.currentTarget.checked),label:n("filter.widget.select.required")}),s.jsx(a.Checkbox,{checked:i.clearable,onChange:u=>i.setClearable(u.currentTarget.checked),label:n("filter.widget.select.clearable")}),s.jsx(Ht,{filter:e})]}),s.jsx(a.TextInput,{label:n("filter.widget.select.width"),value:i.width,onChange:u=>i.setWidth(u.currentTarget.value),placeholder:"200px"}),s.jsx(a.Divider,{label:n("filter.widget.select.configure_options"),labelPosition:"center"}),s.jsxs(a.Stack,{spacing:10,sx:{position:"relative",minHeight:"50px"},children:[i.usingQuery&&s.jsxs(s.Fragment,{children:[s.jsx(a.Overlay,{opacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),s.jsx(a.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:s.jsx(a.Text,{color:"white",size:16,children:n("filter.widget.common.using_query")})})]}),l.length>0&&s.jsx(a.Select,{label:n("filter.widget.select.default_selection"),data:c,value:i.default_value,onChange:i.setDefaultValue}),l.map((u,d)=>s.jsxs(a.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[s.jsx(a.TextInput,{label:n("common.label"),required:!0,value:i.static_options[d].label,onChange:p=>{i.static_options[d].setLabel(p.currentTarget.value)},sx:{flexGrow:1}}),s.jsx(a.TextInput,{label:n("common.value"),required:!0,value:i.static_options[d].value,onChange:p=>{i.static_options[d].setValue(p.currentTarget.value)},sx:{flexGrow:1}}),s.jsx(a.ActionIcon,{color:"red",variant:"subtle",onClick:()=>i.removeStaticOption(d),sx:{position:"absolute",top:28,right:5},children:s.jsx(L.Trash,{size:16})})]},d)),s.jsx(a.Button,{size:"xs",color:"blue",leftIcon:s.jsx(L.PlaylistAdd,{size:20}),onClick:o,sx:{width:"50%"},mx:"auto",children:n("common.actions.add_an_option")})]}),s.jsx(a.Divider,{label:n("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),s.jsx(a.Checkbox,{checked:i.default_selection_count===1,onChange:u=>i.setDefaultSelectionCount(u.currentTarget.checked?1:0),label:n("filter.widget.select.select_first_option_by_default")}),s.jsx(zi,{value:i.options_query_id,onChange:i.setOptionsQueryID}),s.jsx(Hc,{})]})}),OT=S.observer(function({filter:e}){const{t:n}=_.useTranslation(),r=e.config;return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{children:[s.jsx(a.TextInput,{label:n("filter.widget.text_input.default_value"),value:r.default_value,onChange:i=>{r.setDefaultValue(i.currentTarget.value)},sx:{flexGrow:1}}),s.jsx(a.Box,{mt:22,children:s.jsx(Ht,{filter:e})})]}),s.jsx(a.Checkbox,{checked:r.required,onChange:i=>r.setRequired(i.currentTarget.checked),label:n("filter.widget.text_input.required")})]})}),VT=`
458
+ `,Xf=()=>{const{t:e}=_.useTranslation(),[t,n]=m.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"subtle",compact:!0,onClick:()=>n(s=>!s),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),r.jsx(o.Collapse,{in:t,children:r.jsx(sn.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:AA})})]})},PA=D.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config,i=()=>{s.addStaticOption({label:"",value:""})},a=s.static_options,l=[...a];return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Checkbox,{checked:s.required,onChange:c=>s.setRequired(c.currentTarget.checked),label:n("filter.widget.select.required")}),r.jsx(ir,{filter:t})]}),r.jsx(o.TextInput,{label:n("filter.widget.select.width"),description:n("filter.widget.multi_select.width_description"),value:s.min_width,onChange:c=>s.setMinWidth(c.currentTarget.value),placeholder:"200px"}),r.jsx(o.Divider,{label:n("filter.widget.select.configure_options"),labelPosition:"center"}),r.jsxs(o.Stack,{spacing:10,sx:{position:"relative",minHeight:"50px"},children:[s.usingQuery&&r.jsxs(r.Fragment,{children:[r.jsx(o.Overlay,{opacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),r.jsx(o.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:r.jsx(o.Text,{color:"white",size:16,children:n("filter.widget.common.using_query")})})]}),a.length>0&&r.jsx(o.MultiSelect,{label:n("filter.widget.select.default_selection"),data:l,value:[...s.default_value],onChange:s.setDefaultValue}),a.map((c,u)=>r.jsxs(o.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[r.jsx(o.TextInput,{label:n("common.label"),required:!0,value:s.static_options[u].label,onChange:d=>{s.static_options[u].setLabel(d.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(o.TextInput,{label:n("common.value"),required:!0,value:s.static_options[u].value,onChange:d=>{s.static_options[u].setValue(d.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(o.ActionIcon,{color:"red",variant:"subtle",onClick:()=>s.removeStaticOption(u),sx:{position:"absolute",top:28,right:5},children:r.jsx(V.Trash,{size:16})})]},u)),r.jsx(o.Button,{mt:10,size:"xs",color:"blue",leftIcon:r.jsx(V.PlaylistAdd,{size:20}),onClick:i,sx:{width:"50%"},mx:"auto",children:n("common.actions.add_an_option")})]}),r.jsx(o.Divider,{label:n("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),r.jsx(o.NumberInput,{value:s.default_selection_count,onChange:s.setDefaultSelectionCount,label:n("filter.widget.common.default_selection_count")}),r.jsx(zl,{value:s.options_query_id,onChange:s.setOptionsQueryID}),r.jsx(Xf,{})]})}),OA=D.observer(function({filter:t}){const{t:n,i18n:s}=_.useTranslation(),i=t.config,a=()=>{i.addStaticOption({label:"",value:""})},l=i.static_options,c=m.useMemo(()=>[{label:n("filter.widget.select.no_default_selection"),value:""},...l],[s.language,l]);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Checkbox,{checked:i.required,onChange:u=>i.setRequired(u.currentTarget.checked),label:n("filter.widget.select.required")}),r.jsx(o.Checkbox,{checked:i.clearable,onChange:u=>i.setClearable(u.currentTarget.checked),label:n("filter.widget.select.clearable")}),r.jsx(ir,{filter:t})]}),r.jsx(o.TextInput,{label:n("filter.widget.select.width"),value:i.width,onChange:u=>i.setWidth(u.currentTarget.value),placeholder:"200px"}),r.jsx(o.Divider,{label:n("filter.widget.select.configure_options"),labelPosition:"center"}),r.jsxs(o.Stack,{spacing:10,sx:{position:"relative",minHeight:"50px"},children:[i.usingQuery&&r.jsxs(r.Fragment,{children:[r.jsx(o.Overlay,{opacity:.8,color:"#000",sx:{left:"-5px",right:"-5px",top:"-5px",bottom:"-5px"}}),r.jsx(o.Center,{sx:{position:"absolute",top:0,left:0,zIndex:200,height:"100%",width:"100%"},children:r.jsx(o.Text,{color:"white",size:16,children:n("filter.widget.common.using_query")})})]}),l.length>0&&r.jsx(o.Select,{label:n("filter.widget.select.default_selection"),data:c,value:i.default_value,onChange:i.setDefaultValue}),l.map((u,d)=>r.jsxs(o.Flex,{gap:10,sx:{position:"relative"},pr:"40px",children:[r.jsx(o.TextInput,{label:n("common.label"),required:!0,value:i.static_options[d].label,onChange:p=>{i.static_options[d].setLabel(p.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(o.TextInput,{label:n("common.value"),required:!0,value:i.static_options[d].value,onChange:p=>{i.static_options[d].setValue(p.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(o.ActionIcon,{color:"red",variant:"subtle",onClick:()=>i.removeStaticOption(d),sx:{position:"absolute",top:28,right:5},children:r.jsx(V.Trash,{size:16})})]},d)),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(V.PlaylistAdd,{size:20}),onClick:a,sx:{width:"50%"},mx:"auto",children:n("common.actions.add_an_option")})]}),r.jsx(o.Divider,{label:n("filter.widget.common.or_fetch_options_from_datasource"),labelPosition:"center"}),r.jsx(o.Checkbox,{checked:i.default_selection_count===1,onChange:u=>i.setDefaultSelectionCount(u.currentTarget.checked?1:0),label:n("filter.widget.select.select_first_option_by_default")}),r.jsx(zl,{value:i.options_query_id,onChange:i.setOptionsQueryID}),r.jsx(Xf,{})]})}),LA=D.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config;return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{children:[r.jsx(o.TextInput,{label:n("filter.widget.text_input.default_value"),value:s.default_value,onChange:i=>{s.setDefaultValue(i.currentTarget.value)},sx:{flexGrow:1}}),r.jsx(o.Box,{mt:22,children:r.jsx(ir,{filter:t})})]}),r.jsx(o.Checkbox,{checked:s.required,onChange:i=>s.setRequired(i.currentTarget.checked),label:n("filter.widget.text_input.required")})]})}),BA=`
457
459
  // row
458
460
  {
459
461
  label: string;
@@ -461,7 +463,7 @@ Check the top-level render call using <`+P+">.")}return M}}function Mu(C,M){{if(
461
463
  parent_value: string;
462
464
  description?: string;
463
465
  }
464
- `,NT=()=>{const{t}=_.useTranslation(),[e,n]=m.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx(a.Button,{variant:"subtle",compact:!0,onClick:()=>n(r=>!r),children:t(e?"common.actions.close":"filter.widget.common.see_data_structure")}),s.jsx(a.Collapse,{in:e,children:s.jsx(jt.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:VT})})]})},GT=S.observer(function({filter:e}){const{t:n}=_.useTranslation(),r=e.config;return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Checkbox,{checked:r.required,onChange:i=>r.setRequired(i.currentTarget.checked),label:n("filter.widget.select.required")}),s.jsx(Ht,{filter:e})]}),s.jsx(a.TextInput,{label:n("filter.widget.common.min_width"),value:r.min_width,onChange:i=>r.setMinWidth(i.currentTarget.value),placeholder:"200px"}),s.jsx(a.Divider,{label:n("filter.widget.common.fetch_options_from_datasource"),labelPosition:"center"}),s.jsx(a.Checkbox,{checked:r.treeCheckStrictly,onChange:i=>r.setTreeCheckStrictly(i.currentTarget.checked),label:n("filter.widget.tree_select.strictly")}),s.jsx(a.NumberInput,{value:r.default_selection_count,onChange:r.setDefaultSelectionCount,label:n("filter.widget.common.default_selection_count")}),s.jsx(zi,{value:r.options_query_id,onChange:r.setOptionsQueryID}),s.jsx(NT,{})]})}),FT=S.observer(function({filter:e}){const{t:n}=_.useTranslation();return s.jsxs(a.Box,{sx:{maxWidth:"480px"},children:[s.jsx(a.Text,{pt:"0",pb:"md",color:"gray",children:n("common.titles.config")}),s.jsx(jt.Prism,{mt:22,language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(e,null,4)})]})}),WT={select:qT,"multi-select":LT,"tree-select":GT,"text-input":OT,checkbox:AT,"date-range":$T},qt={select:"filter.widget.names.select","multi-select":"filter.widget.names.multi_select","tree-select":"filter.widget.names.tree_select","text-input":"filter.widget.names.text_input",checkbox:"filter.widget.names.checkbox","date-range":"filter.widget.names.date_range"},QT=S.observer(function({filter:e}){const{t:n,i18n:r}=_.useTranslation(),i=Y(),o=m.useMemo(()=>WT[e.type],[e.type]),l=m.useMemo(()=>[{label:n(qt.select),value:"select"},{label:n(qt["multi-select"]),value:"multi-select"},{label:n(qt["tree-select"]),value:"tree-select"},{label:n(qt["text-input"]),value:"text-input"},{label:n(qt.checkbox),value:"checkbox"},{label:n(qt["date-range"]),value:"date-range"}],[r.language]);return s.jsxs(a.Group,{grow:!0,spacing:20,align:"top",children:[s.jsxs(a.Box,{sx:{maxWidth:"600px"},children:[s.jsx(a.Text,{pb:"md",color:"gray",children:n("common.titles.edit")}),s.jsxs(a.Stack,{children:[s.jsxs(a.Group,{noWrap:!0,children:[s.jsx(a.NumberInput,{label:n("filter.field.order"),required:!0,value:e.order,onChange:e.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),e.auto_submit_supported&&s.jsx(a.Checkbox,{label:n("filter.field.auto_submit"),checked:e.auto_submit,onChange:c=>e.setAutoSubmit(c.currentTarget.checked),mt:22})]}),s.jsx(a.MultiSelect,{label:n("filter.field.visible_in"),data:i.views.options,value:[...e.visibleInViewsIDs],onChange:e.setVisibleInViewsIDs}),s.jsx(a.TextInput,{label:n("common.key"),placeholder:n("filter.field.key_placeholder"),required:!0,value:e.key,onChange:c=>{e.setKey(c.currentTarget.value)}}),s.jsx(a.TextInput,{label:n("common.label"),placeholder:n("filter.field.label_placeholder"),required:!0,value:e.label,onChange:c=>{e.setLabel(c.currentTarget.value)}}),s.jsx(a.Select,{label:n("filter.field.widget"),data:l,required:!0,value:e.type,onChange:e.setType,maxDropdownHeight:500}),s.jsx(a.Divider,{mb:0,mt:10,variant:"dashed",labelPosition:"center"}),s.jsx(o,{filter:e})]})]}),s.jsx(FT,{filter:e})]})}),RT=S.observer(({id:t})=>{const{t:e}=_.useTranslation(),n=Fe.useModals(),r=Z(),i=Y();if(t==="")return null;const o=i.filters.findByID(t);if(!o)return s.jsxs(a.Text,{size:14,children:["Filter by ID[",t,"] is not found"]});const l=()=>{r.editor.setPath(["_FILTERS_",""])},c=()=>{n.openConfirmModal({title:`${e("filter.delete")}?`,labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.filters.removeByID(t),l()},confirmProps:{color:"red"},zIndex:320})};return s.jsxs(a.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[s.jsx(a.Group,{position:"right",pt:10,children:s.jsx(a.Button,{size:"xs",color:"red",leftIcon:s.jsx(L.Trash,{size:16}),onClick:c,children:e("filter.delete")})}),s.jsx(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:s.jsx(QT,{filter:o})})]})}),UT=S.observer(()=>{const{t}=_.useTranslation(),[e,n]=m.useState([]),r=Z(),i=d=>{r.editor.setPath(["_FILTERS_",d])},o=()=>{r.content.filters.downloadSchema(e)},l=m.useMemo(()=>r.content.filters.sortedList.map(d=>d.id),[r.content.filters.sortedList]),c=()=>{n(l)},u=()=>{n([])};return s.jsxs(a.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[s.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:s.jsx(a.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:t("filter.manage")})}),s.jsx(a.Flex,{justify:"space-between",align:"center",px:12,children:s.jsxs(a.Group,{position:"left",children:[s.jsxs(a.Button.Group,{children:[s.jsx(a.Button,{variant:"default",size:"xs",onClick:c,children:t("common.actions.select_all")}),s.jsx(a.Button,{variant:"default",size:"xs",onClick:u,children:t("common.actions.clear_selection")})]}),s.jsx(a.Button,{size:"xs",color:"blue",leftIcon:s.jsx(k.IconCode,{size:14}),disabled:e.length===0,onClick:o,children:t("common.actions.download_schema")})]})}),s.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:s.jsx(a.Checkbox.Group,{size:"xs",value:e,onChange:n,children:s.jsxs(a.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"40px"}}),s.jsx("th",{style:{width:"300px"},children:t("common.label")}),s.jsx("th",{children:t("common.key")}),s.jsx("th",{style:{width:"100px"},children:t("filter.field.widget")}),s.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:t("common.action")})]})}),s.jsx("tbody",{children:r.content.filters.sortedList.map(d=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx(a.Checkbox,{value:d.id,styles:{input:{cursor:"pointer"}}})}),s.jsx("td",{children:d.label}),s.jsx("td",{children:d.key}),s.jsx("td",{children:t(qt[d.type])}),s.jsx("td",{children:s.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>i(d.id),children:t("common.actions.open")})})]},d.id))})]})})})]})}),YT=S.observer(()=>{const{t}=_.useTranslation(),e=Y(),[n,r]=m.useState(()=>JSON.stringify(e.mock_context.current,null,4)),i=()=>{try{e.mock_context.replace(JSON.parse(n))}catch(l){_t.showNotification({title:"Failed",message:l.message,color:"red"})}},o=m.useMemo(()=>{try{return JSON.stringify(JSON.parse(n))!==JSON.stringify(e.mock_context.current)}catch{return!1}},[n,e.mock_context.current]);return s.jsxs(a.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[s.jsx(a.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:s.jsx(a.Text,{weight:500,children:t("mock_context.label")})}),s.jsxs(a.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[s.jsxs(a.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[s.jsx(a.Text,{children:t("mock_context.hint")}),s.jsx(a.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:n,onChange:r,sx:{flexGrow:1}})]}),s.jsx(a.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!o,onClick:i,children:s.jsx(L.DeviceFloppy,{size:20})})]})]})}),KT=S.observer(()=>{const{t}=_.useTranslation(),{panel:e}=ze();return s.jsx(Tr,{label:t("panel.panel_description"),value:e.description,onChange:e.setDescription,styles:{root:{flexGrow:1}}})}),JT=S.observer(()=>{const{t}=_.useTranslation(),{panel:e}=ze(),n=he().layouts.findItemByPanelID(e.id),{style:r}=e;return s.jsxs(s.Fragment,{children:[s.jsx(a.Divider,{mb:-10,label:t("panel.style.label"),labelPosition:"center",variant:"dashed"}),s.jsxs(a.Stack,{spacing:20,children:[s.jsxs(a.Group,{grow:!0,align:"top",children:[s.jsx(a.NumberInput,{label:t("panel.style.width"),min:1,max:36,step:1,precision:0,rightSection:s.jsx(a.Text,{size:12,children:t("panel.style.width_postfix")}),styles:{rightSection:{width:"auto",maxWidth:"100px",paddingRight:"14px",justifyContent:"flex-end"}},value:n.w,onChange:i=>{i&&n.setWidth(i)}}),s.jsx(a.NumberInput,{label:t("panel.style.height"),rightSection:s.jsx(a.Text,{size:12,children:t("panel.style.height_postfix")}),styles:{rightSection:{width:"40px"}},value:n.h,onChange:i=>{i&&n.setHeight(i)}})]}),s.jsx(a.Checkbox,{ml:6,label:t("panel.style.border"),checked:r.border.enabled,onChange:i=>r.border.setEnabled(i.currentTarget.checked)})]})]})}),XT=()=>s.jsxs("span",{className:"mantine-103svbs mantine-InputWrapper-required mantine-Select-required","aria-hidden":"true",children:[" ","*"]}),ZT=S.observer(()=>{const{t}=_.useTranslation(),{panel:e}=ze(),{name:n}=e,[r,i]=ie.useInputState(n),o=n!==r,l=m.useCallback(()=>{o&&e.setName(r)},[o,r]);m.useEffect(()=>{i(n)},[n]);const c=!r.trim();return s.jsxs(a.Stack,{spacing:4,children:[s.jsxs(a.Group,{align:"center",children:[s.jsxs(a.Text,{size:14,fw:500,children:[t("panel.panel_name"),s.jsx(XT,{})]}),s.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:!o||c,onClick:l,children:s.jsx(k.IconDeviceFloppy,{size:18})})]}),s.jsx(a.TextInput,{value:r,onChange:i,required:!0})]})}),HT=S.observer(()=>{const{t}=_.useTranslation(),{panel:e}=ze();return s.jsx(a.Stack,{spacing:6,mb:10,children:s.jsxs(a.Group,{pl:6,position:"left",spacing:20,children:[s.jsx(a.Checkbox,{size:"sm",checked:e.title.show,onChange:n=>e.title.setShow(n.currentTarget.checked),label:t("panel.show_title"),sx:{userSelect:"none"}}),s.jsx(a.Checkbox,{size:"sm",checked:!0,disabled:!0,label:t("panel.use_name_as_title")})]})})});function e1(){const{t}=_.useTranslation();return s.jsxs(a.Stack,{sx:{height:"100%"},children:[s.jsx(JT,{}),s.jsx(a.Divider,{label:t("common.info"),labelPosition:"center",variant:"dashed"}),s.jsx(ZT,{}),s.jsx(HT,{}),s.jsx(KT,{})]})}const t1={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},"th, td":{wordBreak:"break-word"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function eu({data:t}){const e=m.useMemo(()=>{if(!Array.isArray(t)||t.length===0)return[];const r=Je.createColumnHelper();return Object.keys(t[0]).map(i=>r.accessor(i,{cell:o=>o.getValue()}))},[t]),n=Je.useReactTable({data:t,columns:e,columnResizeMode:"onChange",getCoreRowModel:Je.getCoreRowModel()});return t.length===0?s.jsx(a.Box,{sx:{height:"5em"}}):s.jsx(je,{children:s.jsxs(a.Table,{sx:t1,children:[s.jsx("thead",{children:n.getHeaderGroups().map(r=>s.jsx("tr",{children:r.headers.map(i=>s.jsxs("th",{style:{width:i.getSize()},children:[i.isPlaceholder?null:Je.flexRender(i.column.columnDef.header,i.getContext()),s.jsx(a.ActionIcon,{onMouseDown:i.getResizeHandler(),onTouchStart:i.getResizeHandler(),className:`resizer ${i.column.getIsResizing()?"isResizing":""}`,children:s.jsx(L.ArrowBarToRight,{})})]},i.id))},r.id))}),s.jsx("tbody",{children:n.getRowModel().rows.map(r=>s.jsx("tr",{children:r.getVisibleCells().map(i=>s.jsx("td",{children:s.jsx(je,{children:typeof i.getValue()=="object"?s.jsx("pre",{children:JSON.stringify(i.getValue(),null,2)}):Je.flexRender(i.column.columnDef.cell,i.getContext())})},i.id))},r.id))})]})})}const n1=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],s1={icon:{width:"80px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"80px"}}},r1=({data:t,page:e,setPage:n,limit:r,setLimit:i})=>{const{t:o}=_.useTranslation(),l=t.length,c=Math.ceil(l/r),u=p=>{n(1),i(Number(p))};if(l===0)return null;const d=c===1&&l<=10;return s.jsxs(a.Group,{pt:10,px:10,position:"apart",children:[s.jsxs(a.Group,{position:"left",children:[c>1&&s.jsx(a.Pagination,{size:"sm",value:e,onChange:n,total:c,withEdges:c>7,styles:{control:{height:"30px"}}}),!d&&s.jsx(a.Select,{icon:s.jsx(a.Text,{ta:"center",color:"dimmed",size:14,children:o("common.pagination.page_size")}),size:"xs",styles:s1,data:n1,value:String(r),onChange:u})]}),s.jsx(a.Group,{position:"right",children:s.jsx(a.Text,{color:"dimmed",my:0,size:14,children:o("common.pagination.total_rows",{total:l})})})]})},i1=Jd(({data:t,loading:e})=>{const[n,r]=m.useState(1),[i,o]=m.useState(20),l=m.useMemo(()=>{const c=(n-1)*i,u=c+i;return t.slice(c,u)},[t,n,i]);return s.jsxs(je,{children:[s.jsx(r1,{data:t,page:n,setPage:r,limit:i,setLimit:o}),s.jsxs(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[s.jsx(a.LoadingOverlay,{visible:e,overlayBlur:2}),s.jsx(eu,{data:l})]})]})}),a1=({queryID:t})=>{const e=he(),{state:n,error:r}=e.getDataStuffByID(t),i=m.useMemo(()=>e.queries.findByID(t),[e,t]);return n==="loading"?null:r?s.jsx(a.Text,{mt:10,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:r}):i!=null&&i.stateMessage?s.jsx(a.Text,{mt:10,color:"gray",align:"center",children:i.stateMessage}):null},Mi=S.observer(({id:t,moreActions:e,refreshOnMount:n})=>{const{t:r}=_.useTranslation(),i=he(),{data:o,state:l}=i.getDataStuffByID(t),c=l==="loading",u=m.useCallback(()=>{i.queries.refetchDataByQueryID(t)},[t,i]),d=()=>{i.queries.downloadDataByQueryID(t)};m.useEffect(()=>{n&&u()},[u,n]);const p=!Array.isArray(o)||o.length===0;return s.jsxs(a.Stack,{spacing:0,sx:{height:"100%",border:"1px solid #eee"},children:[s.jsxs(a.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[s.jsx(a.Group,{position:"left",children:s.jsx(a.Text,{weight:500,children:r("data.preview_data")})}),s.jsxs(a.Group,{pr:15,children:[e,s.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:c,onClick:u,children:s.jsx(L.Refresh,{size:16})}),s.jsx(a.ActionIcon,{variant:"subtle",color:"blue",disabled:c||p,onClick:d,children:s.jsx(L.Download,{size:16})})]})]}),s.jsxs(a.Box,{pb:20,sx:{position:"relative",flexGrow:1,overflow:"auto"},children:[s.jsx(a1,{queryID:t}),s.jsx(i1,{data:o,loading:c})]})]})}),o1=S.observer(function(){const{t:e}=_.useTranslation(),n=Z(),r=Y(),{panel:i}=ze(),[o,l]=m.useState(!1),c=d=>{n.editor.setPath(["_QUERIES_",d])},u=i.queryIDs.length;return s.jsxs(s.Fragment,{children:[s.jsx(a.Drawer,{opened:o,onClose:()=>l(!1),title:e("panel.settings.choose_queries"),padding:"xl",size:500,zIndex:320,children:s.jsx(a.Checkbox.Group,{value:[...i.queryIDs],onChange:i.setQueryIDs,children:s.jsx(a.Stack,{spacing:"lg",children:r.queries.options.map(d=>s.jsx(a.Checkbox,{label:d.label,value:d.value},d.value))})})}),s.jsxs(a.Stack,{spacing:6,children:[s.jsx(a.Group,{position:"left",children:s.jsx(a.Button,{variant:"light",size:"sm",leftIcon:s.jsx(k.IconLine,{size:16}),onClick:()=>l(!0),children:e(u===0?"panel.settings.need_to_choose_queries":"panel.settings.choose_queries")})}),u===1&&s.jsx(Mi,{id:i.queryIDs[0],moreActions:s.jsx(a.Tooltip,{label:e("query.open"),children:s.jsx(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(i.queryIDs[0]),children:s.jsx(k.IconArrowCurveRight,{size:16})})})}),u>1&&s.jsxs(a.Tabs,{defaultValue:i.queryIDs[0],children:[s.jsx(a.Tabs.List,{children:i.queries.map(d=>s.jsx(a.Tabs.Tab,{value:d.id,children:d.name},d.id))}),i.queries.map(d=>s.jsx(a.Tabs.Panel,{value:d.id,children:s.jsx(Mi,{id:d.id,moreActions:s.jsx(a.Tooltip,{label:e("query.open"),children:s.jsx(a.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(d.id),children:s.jsx(k.IconArrowCurveRight,{size:16})})})})},d.id))]})]})]})}),l1=S.observer(()=>{const{panel:t}=mt();return s.jsx(je,{children:s.jsx(a.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:s.jsxs(a.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:t.style.border.enabled?"1px":"0px"},children:[s.jsxs(a.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[s.jsx(a.Group,{children:s.jsx(vi,{})}),s.jsx(a.Group,{grow:!0,position:"center",children:s.jsx(a.Text,{lineClamp:1,weight:"bold",children:t.title.show?t.name:""})}),s.jsx(a.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),s.jsx(a.Group,{px:5,pb:5,sx:{flexGrow:1,".panel-viz-section":{height:"calc(100% - 28px)"}},children:s.jsx(_i,{panel:t})})]})})})}),Ii={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{},fallback:"0"},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class c1{constructor(e){$(this,"panel");$(this,"selected");this.panel=e,e.variables.length>0&&(this.selected=e.variables[0]),J.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}get variableOptions(){return this.panel.variables.map(e=>({label:e.name,value:e.name,description:e.aggregation.type}))}addNew(){const e=this.panel.variables.filter(n=>n.name.startsWith(Ii.name)).length;this.panel.addVariable(b.cloneDeep({...Ii,name:`${Ii.name}${e||""}`})),this.selected=b.last(this.panel.variables)}select(e){this.selected=e}selectByName(e){if(!e){console.warn("Unexpected null name when calling selectByName");return}const n=this.variables.find(r=>r.name===e);if(!n){console.error(`Variable by name[${e}] not found`);return}this.selected=n}remove(e){this.selected===e&&(this.selected=void 0);const n=this.panel.variables.indexOf(e);if(this.panel.removeVariable(e),!this.selected&&!b.isEmpty(this.panel.variables)){const r=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[r]}}}function u1(){const{panel:t}=ze();return W.useCreation(()=>new c1(t),[t])}function d1({label:t,value:e,onChange:n},r){const[i,o]=m.useState(Array.isArray(e)?[...e]:[]),l=m.useCallback(()=>{o(g=>[...g,""])},[o]),c=m.useCallback(g=>{o(f=>(f.splice(g,1),[...f]))},[o]),u=m.useMemo(()=>!b.isEqual(i,e),[i,e]),d=()=>{n(i.map(g=>g.toString()))},p=a.useMantineTheme(),h=m.useMemo(()=>Object.entries(p.colors).map(([g,f])=>f[6]),[p]);return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{position:"left",ref:r,children:[s.jsx(a.Text,{children:t}),s.jsx(a.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!u,onClick:d,children:s.jsx(L.DeviceFloppy,{size:20})})]}),s.jsxs(a.Group,{children:[i.map((g,f)=>s.jsx(a.ColorInput,{value:g,onChange:v=>{o(w=>(w.splice(f,1,v),[...w]))},swatches:h,rightSection:s.jsx(a.ActionIcon,{onClick:()=>c(f),color:"red",children:s.jsx(L.Trash,{size:14})}),sx:{width:"45%"}})),s.jsx(a.ActionIcon,{onClick:l,color:"blue",variant:"outline",children:s.jsx(L.PlaylistAdd,{size:20})})]})]})}const p1=m.forwardRef(d1);function h1({label:t,value:e,onChange:n,type:r},i){const[o,l]=m.useState(Array.isArray(e)?[...e]:[]),c=m.useCallback(()=>{l(h=>[...h,""])},[l]),u=m.useCallback(h=>{l(g=>(g.splice(h,1),[...g]))},[l]),d=m.useMemo(()=>!b.isEqual(o.map(String),e.map(String)),[o,e]),p=()=>{n(o.map(h=>r==="number"?Number(h):h.toString()))};return s.jsxs(s.Fragment,{children:[s.jsxs(a.Group,{position:"left",ref:i,children:[s.jsx(a.Text,{children:t}),s.jsx(a.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:p,children:s.jsx(L.DeviceFloppy,{size:20})})]}),s.jsxs(a.Group,{children:[o.map((h,g)=>s.jsx(a.TextInput,{type:r,value:h,onChange:f=>{const v=f.currentTarget.value;l(w=>(w.splice(g,1,v),[...w]))},rightSection:s.jsx(a.ActionIcon,{onClick:()=>u(g),color:"red",children:s.jsx(L.Trash,{size:14})}),sx:{width:"45%"}})),s.jsx(a.ActionIcon,{onClick:c,color:"blue",variant:"outline",children:s.jsx(L.PlaylistAdd,{size:20})})]})]})}const m1=m.forwardRef(h1),x1=m.forwardRef(function({value:e,onChange:n},r){const{t:i}=_.useTranslation(),o=e.color.type,l=(u,d)=>{const p=b.cloneDeep(e);b.set(p,u,d),n(p)},c=u=>{if(u==="static"){n({...e,color:{type:"static",staticColor:"#25262B"}});return}n({...e,color:{type:"continuous",colorRange:[],valueRange:[]}})};return s.jsxs(s.Fragment,{children:[s.jsx(a.Stack,{children:s.jsx(a.TextInput,{label:i("style.font_size.label"),placeholder:i("styles.font_size.placeholder"),sx:{flex:1},value:e.size,onChange:u=>l("size",u.currentTarget.value)})}),s.jsx(a.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:s.jsx(bl,{label:i("style.font_weight.label"),value:e.weight,onChange:u=>l("weight",u)})}),s.jsx(a.Divider,{mt:"lg",mb:0,variant:"dashed",label:i("style.label"),labelPosition:"center"}),s.jsxs(a.Stack,{children:[s.jsx(a.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:e.color.type,onChange:c}),o==="static"&&s.jsx(Te,{value:e.color.staticColor,onChange:u=>l("color.staticColor",u)}),o==="continuous"&&s.jsxs(s.Fragment,{children:[s.jsx(m1,{label:"Value Range",value:e.color.valueRange,type:"number",onChange:u=>l("color.valueRange",u)}),s.jsx(p1,{label:"Color Range",value:e.color.colorRange,onChange:u=>l("color.colorRange",u)})]})]})]})}),g1=m.forwardRef(function({value:e,onChange:n,withStyle:r=!0,remove:i},o){const{t:l}=_.useTranslation(),c=(u,d)=>{const p=b.cloneDeep(e);b.set(p,u,d),n(p)};return s.jsxs(a.Stack,{ref:o,children:[s.jsxs(a.Stack,{spacing:"xs",px:"sm",py:"md",sx:{border:"1px solid #e9ecef"},children:[s.jsxs(a.Group,{grow:!0,noWrap:!0,children:[s.jsx(a.TextInput,{label:l("common.name"),required:!0,value:e.name,onChange:u=>c("name",u.currentTarget.value)}),s.jsx(O,{label:l("common.data_field"),required:!0,value:e.data_field,onChange:u=>c("data_field",u)})]}),s.jsx(br,{label:l("panel.variable.aggregation.label"),pt:0,value:e.aggregation,onChange:u=>c("aggregation",u),withFallback:!0}),e.aggregation.type!=="custom"&&s.jsxs(s.Fragment,{children:[s.jsx(a.Divider,{mt:"xl",mb:0,label:l("numbro.format.label"),labelPosition:"center",variant:"dashed"}),s.jsx(Re,{value:e.formatter,onChange:u=>c("formatter",u)})]})]}),r&&s.jsx(a.Accordion,{variant:"contained",children:s.jsxs(a.Accordion.Item,{value:"Styles",children:[s.jsx(a.Accordion.Control,{icon:s.jsx(a.Text,{size:"xl",children:"🖼️"}),children:l("style.label")}),s.jsx(a.Accordion.Panel,{children:s.jsx(x1,{value:e,onChange:n})})]})}),s.jsx(a.Button,{mt:20,leftIcon:s.jsx(k.IconTrash,{size:16}),color:"red",variant:"light",onClick:i,children:l("panel.variable.delete")})]})}),f1=S.observer(t=>{const{t:e}=_.useTranslation(),n=W.useCreation(()=>xc(t.variable),[t.variable]),r=()=>t.uiModel.remove(t.variable);return s.jsxs(a.Stack,{"data-testid":"variable-editor",align:"stretch",children:[s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Button,{variant:"subtle",size:"xs",disabled:!n.changed,color:"red",onClick:n.reset,leftIcon:s.jsx(k.IconRecycle,{size:18}),children:e("common.actions.revert_changes")}),s.jsx(a.Button,{variant:"filled",size:"xs",disabled:!n.changed,color:"green",onClick:n.commit,leftIcon:s.jsx(k.IconDeviceFloppy,{size:18}),children:e("common.actions.save_changes")})]}),s.jsx(g1,{value:x.getSnapshot(n.copy),onChange:n.update,remove:r})]})});S.observer(t=>{const{uiModel:e}=t;return s.jsx(a.Stack,{className:"var-list",children:e.variables.map(n=>s.jsx(a.Button,{variant:e.selected===n?"filled":"subtle",color:"gray",onClick:()=>e.select(n),children:n.name},n.name))})});const y1=S.observer(({model:t})=>{const{t:e}=_.useTranslation();return s.jsx(a.Overlay,{color:"#fff",opacity:1,sx:{position:"absolute"},children:s.jsx(a.Button,{variant:"light",size:"xs",leftIcon:s.jsx(k.IconPlus,{size:16}),onClick:t.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:e("panel.variable.add")})})}),b1=S.observer(()=>{var n;const{t}=_.useTranslation(),e=u1();return e.variableOptions.length===0?s.jsx(y1,{model:e}):s.jsxs(a.Stack,{pb:20,children:[s.jsxs(a.Group,{position:"left",children:[s.jsx(a.Select,{label:t("panel.variable.labels"),data:e.variableOptions,value:(n=e.selected)==null?void 0:n.name,onChange:e.selectByName,maxDropdownHeight:600,sx:{flexGrow:1}}),s.jsx(a.Button,{variant:"light",size:"xs",leftIcon:s.jsx(k.IconPlus,{size:16}),onClick:e.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:t("panel.variable.add")})]}),s.jsx(a.Divider,{variant:"dashed"}),e.selected?s.jsx(f1,{uiModel:e,variable:e.selected}):s.jsx("span",{children:"Select or create a new variable on right side"})]})}),v1=S.observer(()=>{const{t}=_.useTranslation(),{panel:e}=ze();return Object.keys(e.variableStrings).length===0?null:s.jsxs(a.Stack,{mt:22,spacing:4,children:[s.jsx(a.Text,{size:"sm",fw:500,color:"dimmed",children:t("panel.variable.labels")}),s.jsx(jt.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(e.variableStrings,null,4)})]})});function _1(){const{t}=_.useTranslation(),{vizManager:e}=m.useContext(ut);return m.useMemo(()=>{const n=e.availableVizList.map(r=>({value:r.name,label:t(r.displayName??r.name),group:t(r.displayGroup??"")}));return b.orderBy(n,[r=>r.group,r=>r.label],["asc","asc"])},[e])}const j1=S.observer(({value:t,submit:e})=>{const{t:n}=_.useTranslation(),[r,i]=ie.useInputState(t);m.useEffect(()=>{i(t)},[t]);const o=_1(),l=t!==r;return s.jsx(a.Select,{label:n("visualization.component"),value:r,searchable:!0,onChange:i,data:o,rightSection:s.jsx(a.ActionIcon,{variant:"filled",color:"green",disabled:!l,onClick:()=>e(r),children:s.jsx(L.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),tu=[];function w1(t,e){try{return t.resolveComponent(e).createConfig()}catch{return null}}function C1(){const{data:t,panel:{variables:e,viz:n,title:r,name:i,queryIDs:o,description:l,id:c}}=ze(),{vizManager:u}=m.useContext(ut),d={name:i,title:r,description:l,viz:n,queryIDs:o,id:c},p=fc(d);try{return u.resolveComponent(d.viz.type),s.jsx(os,{configure:p,children:s.jsx(KS,{variables:e,setVizConf:n.setConf,panel:d,vizManager:u,data:t})})}catch(h){return console.info(b.get(h,"message")),null}}const S1=S.observer(()=>{const{data:t,panel:{viz:e}}=ze(),{vizManager:n}=m.useContext(ut),r=m.useCallback(d=>{if(d===e.type)return;const p=w1(n,d);e.setType(d),e.setConf(p||{})},[e.type]),i=d=>{try{e.setConf(JSON.parse(d))}catch(p){console.error(p)}},o=m.useMemo(()=>{var d;return(d=tu.find(p=>p.value===e.type))==null?void 0:d.Panel},[e.type,tu]),l=C1(),c=o?m.createElement(o,{data:t,conf:e.conf,setConf:e.setConf}):null,u=l||c;return s.jsxs(a.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[s.jsx(j1,{submit:r,value:e.type}),s.jsxs(je,{children:[s.jsx(a.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:u}),!u&&s.jsx(a.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(e.conf,null,2),onChange:i})]})]})}),k1=S.observer(({panel:t,sourceViewID:e})=>{const{t:n}=_.useTranslation(),r=Y(),[i,o]=m.useState(e);m.useEffect(()=>{o(e)},[e]);const[l,{open:c,close:u}]=ie.useDisclosure(!1),d=()=>{t.moveToView(e,i),u()};return s.jsxs(s.Fragment,{children:[s.jsx(a.Button,{size:"xs",variant:"subtle",color:"blue",onClick:c,leftIcon:s.jsx(k.IconBoxMultiple,{size:14}),children:n("panel.settings.change_view")}),s.jsx(a.Modal,{opened:l,onClose:u,title:n("panel.settings.change_view_title"),zIndex:320,children:s.jsxs(a.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[s.jsx(a.Radio.Group,{value:i,onChange:o,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:s.jsx(a.Stack,{spacing:"xs",children:r.views.options.map(p=>s.jsx(a.Radio,{value:p.value,label:p.label},p.value))})}),s.jsxs(a.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[s.jsx(a.Button,{size:"xs",color:"red",leftIcon:s.jsx(k.IconX,{size:14}),onClick:u,children:n("common.actions.cancel")}),s.jsx(a.Button,{size:"xs",color:"blue",leftIcon:s.jsx(k.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===e,children:n("common.actions.confirm")})]})]})})]})}),T1={root:{flexGrow:1,width:"100%",minWidth:"1200px",overflow:"hidden"},panel:{width:"100%",minWidth:"1200px",height:"calc(100% - 44px)",padding:10,overflow:"auto"}},Ei=({children:t})=>s.jsxs(a.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"100%",position:"relative"},children:[s.jsx(a.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:t}),s.jsxs(a.Stack,{justify:"flex-start",sx:{alignSelf:"flex-start",width:"600px",flexGrow:0,flexShrink:0},children:[s.jsx(l1,{}),s.jsx(a.Box,{sx:{flexGrow:1},children:s.jsx(v1,{})})]})]});function D1(t){return!["richText","button"].includes(t)}const z1=S.observer(({panel:t})=>{const{t:e}=_.useTranslation(),n=Fe.useModals(),r=Z(),i=Y(),[o,l]=m.useState("Data"),c=t.queries,d=D1(t.viz.type)&&t.dataLoading,p=d||t.queryErrors.length>0||t.queryStateMessages!==""||c.length===0,h=r.editor.path[1];m.useEffect(()=>{l(v=>p&&v==="Visualization"?"Data":v)},[t.id,p]);const g=()=>{r.editor.setPath(["_VIEWS_",h])},f=()=>n.openConfirmModal({title:`${e("panel.delete")}?`,labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.removePanelByID(t.id,h),g()},confirmProps:{color:"red"},zIndex:320});return s.jsxs(Os,{value:{panel:t,data:t.data,loading:d,errors:t.queryErrors,downloadPanelScreenshot:()=>{}},children:[s.jsxs(a.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[s.jsx(a.Text,{pt:9,pb:8,children:t.name}),s.jsxs(a.Group,{position:"right",noWrap:!0,children:[s.jsx(k1,{panel:t,sourceViewID:h}),s.jsx(a.Button,{size:"xs",variant:"subtle",color:"red",onClick:f,leftIcon:s.jsx(k.IconTrash,{size:14}),children:e("panel.delete")})]})]}),s.jsxs(a.Tabs,{value:o,onTabChange:l,keepMounted:!1,styles:T1,children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"Data",disabled:d,children:e("data.label")}),s.jsx(a.Tabs.Tab,{value:"Panel",children:e("panel.label")}),s.jsx(a.Tabs.Tab,{value:"Variables",disabled:p,children:s.jsx(a.Tooltip,{label:e("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:s.jsx(a.Text,{children:e("panel.variable.labels")})})}),s.jsx(a.Tabs.Tab,{value:"Visualization",disabled:p,children:s.jsx(a.Tooltip,{label:e("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:s.jsx(a.Text,{children:e("visualization.label")})})}),s.jsx(a.Tabs.Tab,{value:"Interactions",children:e("interactions.label")})]}),s.jsxs(a.Tabs.Panel,{value:"Data",children:[s.jsx(a.LoadingOverlay,{visible:d,exitTransitionDuration:0}),s.jsx(o1,{})]}),s.jsx(a.Tabs.Panel,{value:"Panel",children:s.jsx(Ei,{children:s.jsx(e1,{})})}),s.jsx(a.Tabs.Panel,{value:"Variables",children:s.jsx(Ei,{children:s.jsx(b1,{})})}),s.jsx(a.Tabs.Panel,{value:"Visualization",children:s.jsx(je,{children:s.jsx(Ei,{children:s.jsx(S1,{})})})}),s.jsx(a.Tabs.Panel,{value:"Interactions",children:s.jsx(je,{children:s.jsx(vh,{})})})]})]})}),M1=S.observer(({viewID:t,panelID:e})=>{const n=Y();if(!n.views.findByID(t))return s.jsxs(a.Text,{size:14,children:["View by ID[",t,"] is not found"]});const i=n.panels.findByID(e);return i?s.jsx(z1,{panel:i}):s.jsxs(a.Text,{size:14,children:["Panel by ID[",e,"] is not found"]})}),I1=S.observer(()=>{const{t}=_.useTranslation(),[e,n]=m.useState([]),r=Fe.useModals(),i=Z(),o=g=>{i.editor.setPath(["_QUERIES_",g])},l=()=>{r.openConfirmModal({title:"Delete ununsed queries?",children:s.jsx(a.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.content.removeUnusedQueries(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.queries.downloadSchema(e)},u=m.useMemo(()=>i.content.queries.sortedList.map(g=>g.id),[i.content.queries.sortedList]),d=()=>{n(u)},p=()=>{n([])},h=i.content.queriesUsage;return s.jsxs(a.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[s.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:s.jsx(a.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:t("query.manage")})}),s.jsxs(a.Flex,{justify:"space-between",align:"center",px:12,children:[s.jsxs(a.Group,{position:"left",children:[s.jsxs(a.Button.Group,{children:[s.jsx(a.Button,{variant:"default",size:"xs",onClick:d,children:t("common.actions.select_all")}),s.jsx(a.Button,{variant:"default",size:"xs",onClick:p,children:t("common.actions.clear_selection")})]}),s.jsx(a.Button,{size:"xs",color:"blue",leftIcon:s.jsx(k.IconCode,{size:14}),disabled:e.length===0,onClick:c,children:t("common.actions.download_schema")})]}),s.jsx(a.Button,{variant:"subtle",size:"xs",color:"red",leftIcon:s.jsx(k.IconTrash,{size:14}),disabled:!i.content.hasUnusedQueries,onClick:l,children:t("query.delete_unused")})]}),s.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:s.jsx(a.Checkbox.Group,{size:"xs",value:e,onChange:n,children:s.jsxs(a.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"40px"}}),s.jsx("th",{children:t("common.name")}),s.jsx("th",{style:{width:"200px"},children:t("data_source.label")}),s.jsx("th",{style:{width:"100px",textAlign:"right"},children:t("common.type")}),s.jsx("th",{style:{width:"100px",textAlign:"center"},children:t("query.usage.label")}),s.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:t("common.action")})]})}),s.jsx("tbody",{children:i.content.queries.sortedList.map(g=>{var v;const f=((v=h[g.id])==null?void 0:v.length)??0;return s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx(a.Checkbox,{value:g.id,styles:{input:{cursor:"pointer"}}})}),s.jsx("td",{children:g.name}),s.jsx("td",{children:g.key}),s.jsx("td",{style:{textAlign:"right"},children:g.type}),s.jsx("td",{style:{color:f===0?"#ff0000":"#000",fontWeight:f===0?"bold":"normal",textAlign:"center"},children:f}),s.jsx("td",{children:s.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>o(g.id),children:t("common.actions.open")})})]},g.id)})})]})})})]})}),E1=t=>{const{t:e}=_.useTranslation(),{queryModel:n}=t,r=Z(),i=Y(),l=i.findQueryUsage(n.id).length>0,c=Fe.useModals(),u=()=>{c.openConfirmModal({title:`${e("query.delete")}?`,labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.queries.removeQuery(n.id),r.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return l?s.jsx(a.Tooltip,{label:e("query.cant_delete"),withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"top-end",children:s.jsx(a.Box,{sx:{alignSelf:"flex-end"},children:s.jsx(a.Button,{disabled:!0,size:"xs",leftIcon:s.jsx(k.IconTrash,{size:16}),children:e("query.delete")})})}):s.jsx(a.Button,{color:"red",size:"xs",onClick:u,leftIcon:s.jsx(k.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:e("query.delete")})},A1=S.observer(E1),nu=({width:t="calc(100% - 32px)",lastWidth:e="50%",height:n,count:r,spacing:i=16,pl:o=0})=>s.jsxs(a.Stack,{spacing:i,mt:6,pl:o,children:[Array.from(new Array(r-1),(l,c)=>s.jsx(a.Skeleton,{width:t,height:n,radius:"xs"},c)),s.jsx(a.Skeleton,{width:e,height:n,radius:"xs"})]}),vn=({value:t})=>t===null||t===""?null:s.jsx(a.Tooltip,{label:t,disabled:!t,multiline:!0,children:s.jsx(a.ActionIcon,{children:s.jsx(k.IconInfoCircle,{size:14})})}),P1=({column:t})=>{const{column_key:e,column_key_text:n}=t;return e?s.jsx(a.Tooltip,{label:n,disabled:!n,children:s.jsx(a.Badge,{children:e})}):null},$1=S.observer(({dataSource:t})=>{const{columns:e}=t;return e.loading?s.jsx(nu,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):e.empty?null:s.jsxs(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[s.jsxs("colgroup",{children:[s.jsx("col",{style:{width:50}}),s.jsx("col",{style:{minWidth:300}}),s.jsx("col",{style:{width:30}}),s.jsx("col",{style:{width:70}}),s.jsx("col",{style:{minWidth:300}}),s.jsx("col",{style:{minWidth:80,width:80}}),s.jsx("col",{style:{minWidth:120,width:120}})]}),s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"#"}),s.jsx("th",{children:"Column Name"}),s.jsx("th",{}),s.jsx("th",{}),s.jsx("th",{children:"Type"}),s.jsx("th",{children:"Nullable"}),s.jsx("th",{children:"Default Value"})]})}),s.jsx("tbody",{children:e.data.map(n=>s.jsxs("tr",{children:[s.jsx("td",{children:n.ordinal_position}),s.jsx("td",{children:n.column_name}),s.jsx("td",{children:s.jsx(vn,{value:n.column_comment})}),s.jsx("td",{children:s.jsx(P1,{column:n})}),s.jsx("td",{children:n.column_type}),s.jsx("td",{children:n.is_nullable}),s.jsx("td",{children:s.jsx(vn,{value:n.column_default})})]},n.column_name))})]})}),B1=S.observer(({dataSource:t})=>{const{indexes:e}=t,n=e.data;return s.jsxs(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[s.jsxs("colgroup",{children:[s.jsx("col",{style:{width:100}}),s.jsx("col",{style:{minWidth:300}}),s.jsx("col",{style:{width:150}}),s.jsx("col",{style:{width:150}}),s.jsx("col",{style:{width:250}})]}),s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Index Length"}),s.jsx("th",{children:"Index Name"}),s.jsx("th",{children:"Index Algorithm"}),s.jsx("th",{children:"Unique"}),s.jsx("th",{children:"Column Name"})]})}),s.jsx("tbody",{children:n.map(r=>s.jsxs("tr",{children:[s.jsx("td",{children:r.index_length}),s.jsx("td",{children:r.index_name}),s.jsx("td",{children:r.index_algorithm}),s.jsx("td",{children:r.is_unique?"YES":"NO"}),s.jsx("td",{children:r.column_name})]},r.index_name))})]})}),L1=S.observer(({dataSource:t})=>{const{indexes:e}=t,n=e.data;return s.jsxs(a.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[s.jsxs("colgroup",{children:[s.jsx("col",{style:{minWidth:300}}),s.jsx("col",{style:{width:150}}),s.jsx("col",{style:{width:100}}),s.jsx("col",{style:{width:100}}),s.jsx("col",{style:{width:100}}),s.jsx("col",{style:{width:100}})]}),s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Index Name"}),s.jsx("th",{children:"Index Algorithm"}),s.jsx("th",{children:"Unique"}),s.jsx("th",{children:"Definition"}),s.jsx("th",{children:"Condition"}),s.jsx("th",{children:"Comment"})]})}),s.jsx("tbody",{children:n.map(r=>s.jsxs("tr",{children:[s.jsx("td",{children:r.index_name}),s.jsx("td",{children:r.index_algorithm}),s.jsx("td",{children:r.is_unique?"YES":"NO"}),s.jsx("td",{children:s.jsx(vn,{value:r.index_definition})}),s.jsx("td",{children:s.jsx(vn,{value:r.condition})}),s.jsx("td",{children:s.jsx(vn,{value:r.comment})})]},r.index_name))})]})}),q1=S.observer(({dataSource:t})=>{const{indexes:e}=t;return e.loading||e.empty?null:t.type===de.MySQL?s.jsx(B1,{dataSource:t}):t.type===de.Postgresql?s.jsx(L1,{dataSource:t}):null}),O1=S.observer(({dataSource:t})=>s.jsxs(a.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[s.jsx(je,{children:s.jsx($1,{dataSource:t})}),s.jsx(je,{children:s.jsx(q1,{dataSource:t})})]}));function V1({table_type:t}){return t==="VIEW"?s.jsx(k.IconEye,{size:14}):t==="BASE TABLE"?s.jsx(k.IconTable,{size:14}):null}const N1=S.observer(({dataSource:t})=>{const{tables:e}=t;return e.loading?s.jsx(nu,{height:"24px",lastWidth:"50%",count:15}):s.jsx(a.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(e.data).map(([n,r])=>s.jsx(a.NavLink,{label:n,icon:s.jsx(k.IconDatabase,{size:14}),defaultOpened:t.table_schema===n,pl:0,childrenOffset:14,children:r.map(i=>s.jsx(a.NavLink,{label:i.table_name,icon:s.jsx(V1,{table_type:i.table_type}),onClick:()=>{t.setKeywords(n,i.table_name)},active:t.table_name===i.table_name},i.table_name))},n))})}),G1=({visible:t})=>s.jsx(a.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:s.jsx(a.LoadingOverlay,{visible:t})}),F1=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],W1={icon:{width:"50px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"50px"}}},Q1=S.observer(({dataSource:t})=>{const{t:e}=_.useTranslation(),{tableData:n}=t;return s.jsxs(a.Group,{pt:10,px:10,position:"apart",children:[s.jsxs(a.Group,{position:"left",children:[n.maxPage>1&&s.jsx(a.Pagination,{size:"sm",value:n.page,onChange:n.setPage,total:n.maxPage,withEdges:n.maxPage>7,styles:{control:{height:"30px"}}}),s.jsx(a.Select,{icon:s.jsx(a.Text,{ta:"center",color:"dimmed",size:14,children:e("common.pagination.page_size")}),size:"xs",styles:W1,data:F1,value:String(n.limit),onChange:r=>n.setLimit(Number(r))})]}),s.jsx(a.Group,{position:"right",children:s.jsx(a.Text,{color:"dimmed",my:0,size:14,children:e("common.pagination.total_rows",{total:n.total})})})]})}),R1=S.observer(({dataSource:t})=>{const e=t.tableData;return e.maxPage===0?s.jsx(a.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:"This table is empty"}):e.error?s.jsx(a.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e.error}):e.page===1&&e.loading?s.jsx(G1,{visible:!0}):s.jsxs(je,{children:[s.jsx(Q1,{dataSource:t}),s.jsxs(a.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[s.jsx(a.LoadingOverlay,{visible:e.loading,overlayBlur:2}),s.jsx(eu,{data:e.data})]})]})}),U1={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},Y1=S.observer(({dataSource:t})=>{const{t:e}=_.useTranslation();return m.useEffect(()=>{t.loadTablesIfEmpty()},[t]),t.tables.error?s.jsx(a.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:t.tables.error}):s.jsxs(a.Flex,{sx:{height:"100%"},children:[s.jsx(a.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:s.jsx(je,{children:s.jsx(N1,{dataSource:t})})}),s.jsxs(a.Tabs,{defaultValue:"structure",styles:U1,children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"structure",icon:s.jsx(k.IconColumns,{size:14}),children:e("data_source.table_structure_short")}),s.jsx(a.Tabs.Tab,{value:"data",icon:s.jsx(k.IconDatabase,{size:14}),children:e("data.label")})]}),s.jsx(a.Tabs.Panel,{value:"structure",children:s.jsx(O1,{dataSource:t})}),s.jsx(a.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:s.jsx(R1,{dataSource:t})})]})]})}),K1={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"20px 20px 10px",borderBottom:"1px solid #efefef",gap:"20px"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},su=S.observer(({dataSource:t,triggerButtonProps:e={}})=>{const{t:n}=_.useTranslation(),[r,i]=m.useState(!1);return t.type==="http"?null:s.jsxs(s.Fragment,{children:[s.jsx(a.Modal,{opened:r,onClose:()=>i(!1),title:s.jsxs(a.Group,{position:"apart",sx:{flexGrow:1},children:[s.jsx(a.Text,{fw:500,children:n("data_source.explorer")}),s.jsxs(a.Group,{spacing:7,children:[s.jsx(a.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:t.key}),s.jsx(a.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:t.type})]})]}),zIndex:320,size:"96vw",styles:K1,children:s.jsx(a.Box,{sx:{height:"calc(100vh - 220px)"},children:s.jsx(Y1,{dataSource:t})})}),s.jsx(a.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...e,children:n("data_source.see_table_structure")})]})}),J1=m.forwardRef(({label:t,type:e,...n},r)=>e===de.Transform?s.jsxs(a.Group,{className:"transform-query-option",position:"left",ref:r,...n,sx:{'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}},children:[s.jsx(k.IconVectorTriangle,{size:14,color:"#228be6"}),s.jsx(a.Text,{color:"blue",children:t})]}):s.jsxs(a.Group,{position:"apart",ref:r,...n,children:[s.jsx(a.Text,{children:t}),s.jsx(a.Text,{children:e})]})),X1=S.observer(({value:t,onChange:e})=>{const{t:n}=_.useTranslation(),r=Z(),{data:i=[],loading:o}=W.useRequest(Es,{refreshDeps:[]},[]),l=m.useMemo(()=>{const p=i.map(h=>({label:h.key,value:h.key,type:h.type}));return p.push({label:n("query.transform.data_source"),value:de.Transform,type:de.Transform}),p},[i]),c=m.useMemo(()=>l.reduce((p,h)=>(p[h.value]=h.type,p),{}),[l]),u=p=>{p!==null&&e({key:p,type:c[p]})},d=m.useMemo(()=>r.datasources.find(t),[r,t]);return s.jsx(a.Select,{data:l,label:s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Box,{children:n("data_source.label")}),d&&s.jsx(su,{dataSource:d,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:J1,rightSection:d?s.jsx(a.Text,{size:"xs",color:"dimmed",children:d.type}):void 0,rightSectionWidth:85,maxDropdownHeight:500,styles:{root:{flex:1},label:{display:"block"},rightSection:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:o,value:t.key,onChange:u})}),ru=m.forwardRef((t,e)=>{const{label:n,description:r,...i}=t;return s.jsx("div",{ref:e,...i,children:s.jsxs(a.Group,{position:"apart",noWrap:!0,children:[s.jsx(a.Text,{children:n}),s.jsx(a.Text,{size:"xs",color:"dimmed",children:r})]})})}),Z1=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation(),[n,r]=m.useState(t.name);return m.useEffect(()=>{r(t.name)},[t.name]),s.jsx(a.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:s.jsxs(a.Stack,{spacing:10,sx:{width:"100%"},children:[s.jsx(a.Divider,{mb:-10,variant:"dashed",label:e("query.basics"),labelPosition:"center"}),s.jsx(a.TextInput,{placeholder:e("query.name_description"),label:e("query.name"),required:!0,sx:{flex:1},value:n,onChange:i=>{r(i.currentTarget.value)},rightSection:s.jsx(a.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>t.setName(n),disabled:n===t.name,children:s.jsx(k.IconDeviceFloppy,{size:16})}),onBlur:()=>{t.setName(n)}}),s.jsx(X1,{value:{type:t.type,key:t.key},onChange:({type:i,key:o})=>{t.setKey(o),t.setType(i)}}),s.jsx(a.Divider,{mt:10,mb:-10,variant:"dashed",label:e("query.conditions"),labelPosition:"center"}),s.jsx(a.MultiSelect,{label:e("query.run_by_condition.label"),placeholder:e("query.run_by_condition.unset"),data:t.conditionOptions,value:[...t.run_by],onChange:t.setRunBy,itemComponent:ru,maxDropdownHeight:500}),t.typedAsHTTP&&s.jsx(a.MultiSelect,{label:e("query.re_run_condition.label"),placeholder:e("query.re_run_condition.label"),data:t.conditionOptions,value:[...t.react_to],onChange:t.setReactTo,itemComponent:ru,maxDropdownHeight:500}),s.jsx(a.Divider,{mt:20,mb:10,variant:"dashed"}),s.jsx(A1,{queryModel:t})]})})});function H1({content:t}){return s.jsxs(a.HoverCard,{width:"60vw",shadow:"md",children:[s.jsx(a.HoverCard.Target,{children:s.jsx(a.ActionIcon,{size:16,color:"blue",children:s.jsx(k.IconEye,{})})}),s.jsx(a.HoverCard.Dropdown,{children:s.jsx(jt.Prism,{language:"sql",noCopy:!0,withLineNumbers:!0,children:t})})]})}const eD=S.observer(()=>{const e=[...Z().globalSQLSnippets.list];return e.length===0?null:s.jsxs(a.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fontSize:"sm",highlightOnHover:!0,children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"Key"}),s.jsx("th",{children:"Value"})]})}),s.jsx("tbody",{children:e.map(n=>{const{id:r,content:i}=n;return s.jsxs("tr",{children:[s.jsx("td",{children:r}),s.jsx("td",{width:200,children:s.jsx(H1,{content:i})})]},r)})})]})}),tD=`
466
+ `,qA=()=>{const{t:e}=_.useTranslation(),[t,n]=m.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{variant:"subtle",compact:!0,onClick:()=>n(s=>!s),children:e(t?"common.actions.close":"filter.widget.common.see_data_structure")}),r.jsx(o.Collapse,{in:t,children:r.jsx(sn.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:BA})})]})},VA=D.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config;return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Checkbox,{checked:s.required,onChange:i=>s.setRequired(i.currentTarget.checked),label:n("filter.widget.select.required")}),r.jsx(ir,{filter:t})]}),r.jsx(o.TextInput,{label:n("filter.widget.common.min_width"),value:s.min_width,onChange:i=>s.setMinWidth(i.currentTarget.value),placeholder:"200px"}),r.jsx(o.Divider,{label:n("filter.widget.common.fetch_options_from_datasource"),labelPosition:"center"}),r.jsx(o.Checkbox,{checked:s.treeCheckStrictly,onChange:i=>s.setTreeCheckStrictly(i.currentTarget.checked),label:n("filter.widget.tree_select.strictly")}),r.jsx(o.NumberInput,{value:s.default_selection_count,onChange:s.setDefaultSelectionCount,label:n("filter.widget.common.default_selection_count")}),r.jsx(zl,{value:s.options_query_id,onChange:s.setOptionsQueryID}),r.jsx(qA,{})]})}),NA=D.observer(function({filter:t}){const{t:n}=_.useTranslation();return r.jsxs(o.Box,{sx:{maxWidth:"480px"},children:[r.jsx(o.Text,{pt:"0",pb:"md",color:"gray",children:n("common.titles.config")}),r.jsx(sn.Prism,{mt:22,language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),$A={select:OA,"multi-select":PA,"tree-select":VA,"text-input":LA,checkbox:zA,"date-range":EA},En={select:"filter.widget.names.select","multi-select":"filter.widget.names.multi_select","tree-select":"filter.widget.names.tree_select","text-input":"filter.widget.names.text_input",checkbox:"filter.widget.names.checkbox","date-range":"filter.widget.names.date_range"},FA=D.observer(function({filter:t}){const{t:n,i18n:s}=_.useTranslation(),i=Y(),a=m.useMemo(()=>$A[t.type],[t.type]),l=m.useMemo(()=>[{label:n(En.select),value:"select"},{label:n(En["multi-select"]),value:"multi-select"},{label:n(En["tree-select"]),value:"tree-select"},{label:n(En["text-input"]),value:"text-input"},{label:n(En.checkbox),value:"checkbox"},{label:n(En["date-range"]),value:"date-range"}],[s.language]);return r.jsxs(o.Group,{grow:!0,spacing:20,align:"top",children:[r.jsxs(o.Box,{sx:{maxWidth:"600px"},children:[r.jsx(o.Text,{pb:"md",color:"gray",children:n("common.titles.edit")}),r.jsxs(o.Stack,{children:[r.jsxs(o.Group,{noWrap:!0,children:[r.jsx(o.NumberInput,{label:n("filter.field.order"),required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&r.jsx(o.Checkbox,{label:n("filter.field.auto_submit"),checked:t.auto_submit,onChange:c=>t.setAutoSubmit(c.currentTarget.checked),mt:22})]}),r.jsx(o.MultiSelect,{label:n("filter.field.visible_in"),data:i.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),r.jsx(o.TextInput,{label:n("common.key"),placeholder:n("filter.field.key_placeholder"),required:!0,value:t.key,onChange:c=>{t.setKey(c.currentTarget.value)}}),r.jsx(o.TextInput,{label:n("common.label"),placeholder:n("filter.field.label_placeholder"),required:!0,value:t.label,onChange:c=>{t.setLabel(c.currentTarget.value)}}),r.jsx(o.Select,{label:n("filter.field.widget"),data:l,required:!0,value:t.type,onChange:t.setType,maxDropdownHeight:500}),r.jsx(o.Divider,{mb:0,mt:10,variant:"dashed",labelPosition:"center"}),r.jsx(a,{filter:t})]})]}),r.jsx(NA,{filter:t})]})}),GA=D.observer(({id:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Z(),i=Y();if(e==="")return null;const a=i.filters.findByID(e);if(!a)return r.jsxs(o.Text,{size:14,children:["Filter by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_FILTERS_",""])},c=()=>{n.openConfirmModal({title:`${t("filter.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.filters.removeByID(e),l()},confirmProps:{color:"red"},zIndex:320})};return r.jsxs(o.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[r.jsx(o.Group,{position:"right",pt:10,children:r.jsx(o.Button,{size:"xs",color:"red",leftIcon:r.jsx(V.Trash,{size:16}),onClick:c,children:t("filter.delete")})}),r.jsx(o.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:r.jsx(FA,{filter:a})})]})}),WA=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=m.useState([]),s=Z(),i=d=>{s.editor.setPath(["_FILTERS_",d])},a=()=>{s.content.filters.downloadSchema(t)},l=m.useMemo(()=>s.content.filters.sortedList.map(d=>d.id),[s.content.filters.sortedList]),c=()=>{n(l)},u=()=>{n([])};return r.jsxs(o.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[r.jsx(o.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:e("filter.manage")})}),r.jsx(o.Flex,{justify:"space-between",align:"center",px:12,children:r.jsxs(o.Group,{position:"left",children:[r.jsxs(o.Button.Group,{children:[r.jsx(o.Button,{variant:"default",size:"xs",onClick:c,children:e("common.actions.select_all")}),r.jsx(o.Button,{variant:"default",size:"xs",onClick:u,children:e("common.actions.clear_selection")})]}),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(M.IconCode,{size:14}),disabled:t.length===0,onClick:a,children:e("common.actions.download_schema")})]})}),r.jsx(o.Box,{sx:{flexGrow:1,overflow:"auto"},children:r.jsx(o.Checkbox.Group,{size:"xs",value:t,onChange:n,children:r.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"40px"}}),r.jsx("th",{style:{width:"300px"},children:e("common.label")}),r.jsx("th",{children:e("common.key")}),r.jsx("th",{style:{width:"100px"},children:e("filter.field.widget")}),r.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),r.jsx("tbody",{children:s.content.filters.sortedList.map(d=>r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx(o.Checkbox,{value:d.id,styles:{input:{cursor:"pointer"}}})}),r.jsx("td",{children:d.label}),r.jsx("td",{children:d.key}),r.jsx("td",{children:e(En[d.type])}),r.jsx("td",{children:r.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>i(d.id),children:e("common.actions.open")})})]},d.id))})]})})})]})}),RA=D.observer(()=>{const{t:e}=_.useTranslation(),t=Y(),[n,s]=m.useState(()=>JSON.stringify(t.mock_context.current,null,4)),i=()=>{try{t.mock_context.replace(JSON.parse(n))}catch(l){rn.showNotification({title:"Failed",message:l.message,color:"red"})}},a=m.useMemo(()=>{try{return JSON.stringify(JSON.parse(n))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[n,t.mock_context.current]);return r.jsxs(o.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[r.jsx(o.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:r.jsx(o.Text,{weight:500,children:e("mock_context.label")})}),r.jsxs(o.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[r.jsxs(o.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[r.jsx(o.Text,{children:e("mock_context.hint")}),r.jsx(o.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:n,onChange:s,sx:{flexGrow:1}})]}),r.jsx(o.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!a,onClick:i,children:r.jsx(V.DeviceFloppy,{size:20})})]})]})}),QA=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge();return r.jsx(Do,{label:e("panel.panel_description"),value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}})}),UA=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge(),n=_e().layouts.findItemByPanelID(t.id),{style:s}=t;return r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{mb:-10,label:e("panel.style.label"),labelPosition:"center",variant:"dashed"}),r.jsxs(o.Stack,{spacing:20,children:[r.jsxs(o.Group,{grow:!0,align:"top",children:[r.jsx(o.NumberInput,{label:e("panel.style.width"),min:1,max:36,step:1,precision:0,rightSection:r.jsx(o.Text,{size:12,children:e("panel.style.width_postfix")}),styles:{rightSection:{width:"auto",maxWidth:"100px",paddingRight:"14px",justifyContent:"flex-end"}},value:n.w,onChange:i=>{i&&n.setWidth(i)}}),r.jsx(o.NumberInput,{label:e("panel.style.height"),rightSection:r.jsx(o.Text,{size:12,children:e("panel.style.height_postfix")}),styles:{rightSection:{width:"40px"}},value:n.h,onChange:i=>{i&&n.setHeight(i)}})]}),r.jsx(o.Checkbox,{ml:6,label:e("panel.style.border"),checked:s.border.enabled,onChange:i=>s.border.setEnabled(i.currentTarget.checked)})]})]})}),YA=()=>r.jsxs("span",{className:"mantine-103svbs mantine-InputWrapper-required mantine-Select-required","aria-hidden":"true",children:[" ","*"]}),KA=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge(),{name:n}=t,[s,i]=he.useInputState(n),a=n!==s,l=m.useCallback(()=>{a&&t.setName(s)},[a,s]);m.useEffect(()=>{i(n)},[n]);const c=!s.trim();return r.jsxs(o.Stack,{spacing:4,children:[r.jsxs(o.Group,{align:"center",children:[r.jsxs(o.Text,{size:14,fw:500,children:[e("panel.panel_name"),r.jsx(YA,{})]}),r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",disabled:!a||c,onClick:l,children:r.jsx(M.IconDeviceFloppy,{size:18})})]}),r.jsx(o.TextInput,{value:s,onChange:i,required:!0})]})}),XA=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge();return r.jsx(o.Stack,{spacing:6,mb:10,children:r.jsxs(o.Group,{pl:6,position:"left",spacing:20,children:[r.jsx(o.Checkbox,{size:"sm",checked:t.title.show,onChange:n=>t.title.setShow(n.currentTarget.checked),label:e("panel.show_title"),sx:{userSelect:"none"}}),r.jsx(o.Checkbox,{size:"sm",checked:!0,disabled:!0,label:e("panel.use_name_as_title")})]})})});function JA(){const{t:e}=_.useTranslation();return r.jsxs(o.Stack,{sx:{height:"100%"},children:[r.jsx(UA,{}),r.jsx(o.Divider,{label:e("common.info"),labelPosition:"center",variant:"dashed"}),r.jsx(KA,{}),r.jsx(XA,{}),r.jsx(QA,{})]})}const ZA={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},"th, td":{wordBreak:"break-word"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1",backgroundColor:"rgb(248, 249, 250)"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function Jf({data:e}){const t=m.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const s=bt.createColumnHelper();return Object.keys(e[0]).map(i=>s.accessor(i,{cell:a=>a.getValue()}))},[e]),n=bt.useReactTable({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:bt.getCoreRowModel()});return e.length===0?r.jsx(o.Box,{sx:{height:"5em"}}):r.jsx(ze,{children:r.jsxs(o.Table,{sx:ZA,children:[r.jsx("thead",{children:n.getHeaderGroups().map(s=>r.jsx("tr",{children:s.headers.map(i=>r.jsxs("th",{style:{width:i.getSize()},children:[i.isPlaceholder?null:bt.flexRender(i.column.columnDef.header,i.getContext()),r.jsx(o.ActionIcon,{onMouseDown:i.getResizeHandler(),onTouchStart:i.getResizeHandler(),className:`resizer ${i.column.getIsResizing()?"isResizing":""}`,children:r.jsx(V.ArrowBarToRight,{})})]},i.id))},s.id))}),r.jsx("tbody",{children:n.getRowModel().rows.map(s=>r.jsx("tr",{children:s.getVisibleCells().map(i=>r.jsx("td",{children:r.jsx(ze,{children:typeof i.getValue()=="object"?r.jsx("pre",{children:JSON.stringify(i.getValue(),null,2)}):bt.flexRender(i.column.columnDef.cell,i.getContext())})},i.id))},s.id))})]})})}const HA=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],eP={icon:{width:"80px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"80px"}}},tP=({data:e,page:t,setPage:n,limit:s,setLimit:i})=>{const{t:a}=_.useTranslation(),l=e.length,c=Math.ceil(l/s),u=p=>{n(1),i(Number(p))};if(l===0)return null;const d=c===1&&l<=10;return r.jsxs(o.Group,{pt:10,px:10,position:"apart",children:[r.jsxs(o.Group,{position:"left",children:[c>1&&r.jsx(o.Pagination,{size:"sm",value:t,onChange:n,total:c,withEdges:c>7,styles:{control:{height:"30px"}}}),!d&&r.jsx(o.Select,{icon:r.jsx(o.Text,{ta:"center",color:"dimmed",size:14,children:a("common.pagination.page_size")}),size:"xs",styles:eP,data:HA,value:String(s),onChange:u})]}),r.jsx(o.Group,{position:"right",children:r.jsx(o.Text,{color:"dimmed",my:0,size:14,children:a("common.pagination.total_rows",{total:l})})})]})},nP=$g(({data:e,loading:t})=>{const[n,s]=m.useState(1),[i,a]=m.useState(20),l=m.useMemo(()=>{const c=(n-1)*i,u=c+i;return e.slice(c,u)},[e,n,i]);return r.jsxs(ze,{children:[r.jsx(tP,{data:e,page:n,setPage:s,limit:i,setLimit:a}),r.jsxs(o.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[r.jsx(o.LoadingOverlay,{visible:t,overlayBlur:2}),r.jsx(Jf,{data:l})]})]})}),rP=({queryID:e})=>{const t=_e(),{state:n,error:s}=t.getDataStuffByID(e),i=m.useMemo(()=>t.queries.findByID(e),[t,e]);return n==="loading"?null:s?r.jsx(o.Text,{mt:10,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:s}):i!=null&&i.stateMessage?r.jsx(o.Text,{mt:10,color:"gray",align:"center",children:i.stateMessage}):null},Il=D.observer(({id:e,moreActions:t,refreshOnMount:n})=>{const{t:s}=_.useTranslation(),i=_e(),{data:a,state:l}=i.getDataStuffByID(e),c=l==="loading",u=m.useCallback(()=>{i.queries.refetchDataByQueryID(e)},[e,i]),d=()=>{i.queries.downloadDataByQueryID(e)};m.useEffect(()=>{n&&u()},[u,n]);const p=!Array.isArray(a)||a.length===0;return r.jsxs(o.Stack,{spacing:0,sx:{height:"100%",border:"1px solid #eee"},children:[r.jsxs(o.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[r.jsx(o.Group,{position:"left",children:r.jsx(o.Text,{weight:500,children:s("data.preview_data")})}),r.jsxs(o.Group,{pr:15,children:[t,r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",disabled:c,onClick:u,children:r.jsx(V.Refresh,{size:16})}),r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",disabled:c||p,onClick:d,children:r.jsx(V.Download,{size:16})})]})]}),r.jsxs(o.Box,{pb:20,sx:{position:"relative",flexGrow:1,overflow:"auto"},children:[r.jsx(rP,{queryID:e}),r.jsx(nP,{data:a,loading:c})]})]})}),sP=D.observer(function(){const{t}=_.useTranslation(),n=Z(),s=Y(),{panel:i}=Ge(),[a,l]=m.useState(!1),c=d=>{n.editor.setPath(["_QUERIES_",d])},u=i.queryIDs.length;return r.jsxs(r.Fragment,{children:[r.jsx(o.Drawer,{opened:a,onClose:()=>l(!1),title:t("panel.settings.choose_queries"),padding:"xl",size:500,zIndex:320,children:r.jsx(o.Checkbox.Group,{value:[...i.queryIDs],onChange:i.setQueryIDs,children:r.jsx(o.Stack,{spacing:"lg",children:s.queries.options.map(d=>r.jsx(o.Checkbox,{label:d.label,value:d.value},d.value))})})}),r.jsxs(o.Stack,{spacing:6,children:[r.jsx(o.Group,{position:"left",children:r.jsx(o.Button,{variant:"light",size:"sm",leftIcon:r.jsx(M.IconLine,{size:16}),onClick:()=>l(!0),children:t(u===0?"panel.settings.need_to_choose_queries":"panel.settings.choose_queries")})}),u===1&&r.jsx(Il,{id:i.queryIDs[0],moreActions:r.jsx(o.Tooltip,{label:t("query.open"),children:r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(i.queryIDs[0]),children:r.jsx(M.IconArrowCurveRight,{size:16})})})}),u>1&&r.jsxs(o.Tabs,{defaultValue:i.queryIDs[0],children:[r.jsx(o.Tabs.List,{children:i.queries.map(d=>r.jsx(o.Tabs.Tab,{value:d.id,children:d.name},d.id))}),i.queries.map(d=>r.jsx(o.Tabs.Panel,{value:d.id,children:r.jsx(Il,{id:d.id,moreActions:r.jsx(o.Tooltip,{label:t("query.open"),children:r.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(d.id),children:r.jsx(M.IconArrowCurveRight,{size:16})})})})},d.id))]})]})]})}),iP=D.observer(()=>{const{panel:e}=Lt();return r.jsx(ze,{children:r.jsx(o.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:r.jsxs(o.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:e.style.border.enabled?"1px":"0px"},children:[r.jsxs(o.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[r.jsx(o.Group,{children:r.jsx(_l,{})}),r.jsx(o.Group,{grow:!0,position:"center",children:r.jsx(o.Text,{lineClamp:1,weight:"bold",children:e.title.show?e.name:""})}),r.jsx(o.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),r.jsx(o.Group,{px:5,pb:5,sx:{flexGrow:1,".panel-viz-section":{height:"calc(100% - 28px)"}},children:r.jsx(jl,{panel:e})})]})})})}),El={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{},fallback:"0"},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class aP{constructor(t){B(this,"panel");B(this,"selected");this.panel=t,t.variables.length>0&&(this.selected=t.variables[0]),X.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}get variableOptions(){return this.panel.variables.map(t=>({label:t.name,value:t.name,description:t.aggregation.type}))}addNew(){const t=this.panel.variables.filter(n=>n.name.startsWith(El.name)).length;this.panel.addVariable(v.cloneDeep({...El,name:`${El.name}${t||""}`})),this.selected=v.last(this.panel.variables)}select(t){this.selected=t}selectByName(t){if(!t){console.warn("Unexpected null name when calling selectByName");return}const n=this.variables.find(s=>s.name===t);if(!n){console.error(`Variable by name[${t}] not found`);return}this.selected=n}remove(t){this.selected===t&&(this.selected=void 0);const n=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!v.isEmpty(this.panel.variables)){const s=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[s]}}}function oP(){const{panel:e}=Ge();return W.useCreation(()=>new aP(e),[e])}function lP({label:e,value:t,onChange:n},s){const[i,a]=m.useState(Array.isArray(t)?[...t]:[]),l=m.useCallback(()=>{a(f=>[...f,""])},[a]),c=m.useCallback(f=>{a(g=>(g.splice(f,1),[...g]))},[a]),u=m.useMemo(()=>!v.isEqual(i,t),[i,t]),d=()=>{n(i.map(f=>f.toString()))},p=o.useMantineTheme(),h=m.useMemo(()=>Object.entries(p.colors).map(([f,g])=>g[6]),[p]);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"left",ref:s,children:[r.jsx(o.Text,{children:e}),r.jsx(o.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!u,onClick:d,children:r.jsx(V.DeviceFloppy,{size:20})})]}),r.jsxs(o.Group,{children:[i.map((f,g)=>r.jsx(o.ColorInput,{value:f,onChange:y=>{a(j=>(j.splice(g,1,y),[...j]))},swatches:h,rightSection:r.jsx(o.ActionIcon,{onClick:()=>c(g),color:"red",children:r.jsx(V.Trash,{size:14})}),sx:{width:"45%"}})),r.jsx(o.ActionIcon,{onClick:l,color:"blue",variant:"outline",children:r.jsx(V.PlaylistAdd,{size:20})})]})]})}const cP=m.forwardRef(lP);function uP({label:e,value:t,onChange:n,type:s},i){const[a,l]=m.useState(Array.isArray(t)?[...t]:[]),c=m.useCallback(()=>{l(h=>[...h,""])},[l]),u=m.useCallback(h=>{l(f=>(f.splice(h,1),[...f]))},[l]),d=m.useMemo(()=>!v.isEqual(a.map(String),t.map(String)),[a,t]),p=()=>{n(a.map(h=>s==="number"?Number(h):h.toString()))};return r.jsxs(r.Fragment,{children:[r.jsxs(o.Group,{position:"left",ref:i,children:[r.jsx(o.Text,{children:e}),r.jsx(o.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:p,children:r.jsx(V.DeviceFloppy,{size:20})})]}),r.jsxs(o.Group,{children:[a.map((h,f)=>r.jsx(o.TextInput,{type:s,value:h,onChange:g=>{const y=g.currentTarget.value;l(j=>(j.splice(f,1,y),[...j]))},rightSection:r.jsx(o.ActionIcon,{onClick:()=>u(f),color:"red",children:r.jsx(V.Trash,{size:14})}),sx:{width:"45%"}})),r.jsx(o.ActionIcon,{onClick:c,color:"blue",variant:"outline",children:r.jsx(V.PlaylistAdd,{size:20})})]})]})}const dP=m.forwardRef(uP),pP=m.forwardRef(function({value:t,onChange:n},s){const{t:i}=_.useTranslation(),a=t.color.type,l=(u,d)=>{const p=v.cloneDeep(t);v.set(p,u,d),n(p)},c=u=>{if(u==="static"){n({...t,color:{type:"static",staticColor:"#25262B"}});return}n({...t,color:{type:"continuous",colorRange:[],valueRange:[]}})};return r.jsxs(r.Fragment,{children:[r.jsx(o.Stack,{children:r.jsx(o.TextInput,{label:i("style.font_size.label"),placeholder:i("styles.font_size.placeholder"),sx:{flex:1},value:t.size,onChange:u=>l("size",u.currentTarget.value)})}),r.jsx(o.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:r.jsx(mh,{label:i("style.font_weight.label"),value:t.weight,onChange:u=>l("weight",u)})}),r.jsx(o.Divider,{mt:"lg",mb:0,variant:"dashed",label:i("style.label"),labelPosition:"center"}),r.jsxs(o.Stack,{children:[r.jsx(o.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:t.color.type,onChange:c}),a==="static"&&r.jsx(Le,{value:t.color.staticColor,onChange:u=>l("color.staticColor",u)}),a==="continuous"&&r.jsxs(r.Fragment,{children:[r.jsx(dP,{label:"Value Range",value:t.color.valueRange,type:"number",onChange:u=>l("color.valueRange",u)}),r.jsx(cP,{label:"Color Range",value:t.color.colorRange,onChange:u=>l("color.colorRange",u)})]})]})]})}),hP=m.forwardRef(function({value:t,onChange:n,withStyle:s=!0,remove:i},a){const{t:l}=_.useTranslation(),c=(u,d)=>{const p=v.cloneDeep(t);v.set(p,u,d),n(p)};return r.jsxs(o.Stack,{ref:a,children:[r.jsxs(o.Stack,{spacing:"xs",px:"sm",py:"md",sx:{border:"1px solid #e9ecef"},children:[r.jsxs(o.Group,{grow:!0,noWrap:!0,children:[r.jsx(o.TextInput,{label:l("common.name"),required:!0,value:t.name,onChange:u=>c("name",u.currentTarget.value)}),r.jsx(F,{label:l("common.data_field"),required:!0,value:t.data_field,onChange:u=>c("data_field",u)})]}),r.jsx(vo,{label:l("panel.variable.aggregation.label"),pt:0,value:t.aggregation,onChange:u=>c("aggregation",u),withFallback:!0}),t.aggregation.type!=="custom"&&r.jsxs(r.Fragment,{children:[r.jsx(o.Divider,{mt:"xl",mb:0,label:l("numbro.format.label"),labelPosition:"center",variant:"dashed"}),r.jsx(ft,{value:t.formatter,onChange:u=>c("formatter",u)})]})]}),s&&r.jsx(o.Accordion,{variant:"contained",children:r.jsxs(o.Accordion.Item,{value:"Styles",children:[r.jsx(o.Accordion.Control,{icon:r.jsx(o.Text,{size:"xl",children:"🖼️"}),children:l("style.label")}),r.jsx(o.Accordion.Panel,{children:r.jsx(pP,{value:t,onChange:n})})]})}),r.jsx(o.Button,{mt:20,leftIcon:r.jsx(M.IconTrash,{size:16}),color:"red",variant:"light",onClick:i,children:l("panel.variable.delete")})]})}),fP=D.observer(e=>{const{t}=_.useTranslation(),n=W.useCreation(()=>pf(e.variable),[e.variable]),s=()=>e.uiModel.remove(e.variable);return r.jsxs(o.Stack,{"data-testid":"variable-editor",align:"stretch",children:[r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{variant:"subtle",size:"xs",disabled:!n.changed,color:"red",onClick:n.reset,leftIcon:r.jsx(M.IconRecycle,{size:18}),children:t("common.actions.revert_changes")}),r.jsx(o.Button,{variant:"filled",size:"xs",disabled:!n.changed,color:"green",onClick:n.commit,leftIcon:r.jsx(M.IconDeviceFloppy,{size:18}),children:t("common.actions.save_changes")})]}),r.jsx(hP,{value:x.getSnapshot(n.copy),onChange:n.update,remove:s})]})});D.observer(e=>{const{uiModel:t}=e;return r.jsx(o.Stack,{className:"var-list",children:t.variables.map(n=>r.jsx(o.Button,{variant:t.selected===n?"filled":"subtle",color:"gray",onClick:()=>t.select(n),children:n.name},n.name))})});const mP=D.observer(({model:e})=>{const{t}=_.useTranslation();return r.jsx(o.Overlay,{color:"#fff",opacity:1,sx:{position:"absolute"},children:r.jsx(o.Button,{variant:"light",size:"xs",leftIcon:r.jsx(M.IconPlus,{size:16}),onClick:e.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:t("panel.variable.add")})})}),gP=D.observer(()=>{var n;const{t:e}=_.useTranslation(),t=oP();return t.variableOptions.length===0?r.jsx(mP,{model:t}):r.jsxs(o.Stack,{pb:20,children:[r.jsxs(o.Group,{position:"left",children:[r.jsx(o.Select,{label:e("panel.variable.labels"),data:t.variableOptions,value:(n=t.selected)==null?void 0:n.name,onChange:t.selectByName,maxDropdownHeight:600,sx:{flexGrow:1}}),r.jsx(o.Button,{variant:"light",size:"xs",leftIcon:r.jsx(M.IconPlus,{size:16}),onClick:t.addNew,sx:{flexGrow:0,flexShrink:0,alignSelf:"flex-end",height:"38px"},children:e("panel.variable.add")})]}),r.jsx(o.Divider,{variant:"dashed"}),t.selected?r.jsx(fP,{uiModel:t,variable:t.selected}):r.jsx("span",{children:"Select or create a new variable on right side"})]})}),xP=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge();return Object.keys(t.variableStrings).length===0?null:r.jsxs(o.Stack,{mt:22,spacing:4,children:[r.jsx(o.Text,{size:"sm",fw:500,color:"dimmed",children:e("panel.variable.labels")}),r.jsx(sn.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t.variableStrings,null,4)})]})});function yP(){const{t:e}=_.useTranslation(),{vizManager:t}=m.useContext(Gt);return m.useMemo(()=>{const n=t.availableVizList.map(s=>({value:s.name,label:e(s.displayName??s.name),group:e(s.displayGroup??"")}));return v.orderBy(n,[s=>s.group,s=>s.label],["asc","asc"])},[t])}const bP=D.observer(({value:e,submit:t})=>{const{t:n}=_.useTranslation(),[s,i]=he.useInputState(e);m.useEffect(()=>{i(e)},[e]);const a=yP(),l=e!==s;return r.jsx(o.Select,{label:n("visualization.component"),value:s,searchable:!0,onChange:i,data:a,rightSection:r.jsx(o.ActionIcon,{variant:"filled",color:"green",disabled:!l,onClick:()=>t(s),children:r.jsx(V.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),Zf=[];function vP(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function _P(){const{data:e,panel:{variables:t,viz:n,title:s,name:i,queryIDs:a,description:l,id:c}}=Ge(),{vizManager:u}=m.useContext(Gt),d={name:i,title:s,description:l,viz:n,queryIDs:a,id:c},p=ff(d);try{return u.resolveComponent(d.viz.type),r.jsx(si,{configure:p,children:r.jsx(QI,{variables:t,setVizConf:n.setConf,panel:d,vizManager:u,data:e})})}catch(h){return console.info(v.get(h,"message")),null}}const jP=D.observer(()=>{const{data:e,panel:{viz:t}}=Ge(),{vizManager:n}=m.useContext(Gt),s=m.useCallback(d=>{if(d===t.type)return;const p=vP(n,d);t.setType(d),t.setConf(p||{})},[t.type]),i=d=>{try{t.setConf(JSON.parse(d))}catch(p){console.error(p)}},a=m.useMemo(()=>{var d;return(d=Zf.find(p=>p.value===t.type))==null?void 0:d.Panel},[t.type,Zf]),l=_P(),c=a?m.createElement(a,{data:e,conf:t.conf,setConf:t.setConf}):null,u=l||c;return r.jsxs(o.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[r.jsx(bP,{submit:s,value:t.type}),r.jsxs(ze,{children:[r.jsx(o.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:u}),!u&&r.jsx(o.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:i})]})]})}),wP=D.observer(({panel:e,sourceViewID:t})=>{const{t:n}=_.useTranslation(),s=Y(),[i,a]=m.useState(t);m.useEffect(()=>{a(t)},[t]);const[l,{open:c,close:u}]=he.useDisclosure(!1),d=()=>{e.moveToView(t,i),u()};return r.jsxs(r.Fragment,{children:[r.jsx(o.Button,{size:"xs",variant:"subtle",color:"blue",onClick:c,leftIcon:r.jsx(M.IconBoxMultiple,{size:14}),children:n("panel.settings.change_view")}),r.jsx(o.Modal,{opened:l,onClose:u,title:n("panel.settings.change_view_title"),zIndex:320,children:r.jsxs(o.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[r.jsx(o.Radio.Group,{value:i,onChange:a,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:r.jsx(o.Stack,{spacing:"xs",children:s.views.options.map(p=>r.jsx(o.Radio,{value:p.value,label:p.label},p.value))})}),r.jsxs(o.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[r.jsx(o.Button,{size:"xs",color:"red",leftIcon:r.jsx(M.IconX,{size:14}),onClick:u,children:n("common.actions.cancel")}),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(M.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===t,children:n("common.actions.confirm")})]})]})})]})}),CP={root:{flexGrow:1,width:"100%",minWidth:"1200px",overflow:"hidden"},panel:{width:"100%",minWidth:"1200px",height:"calc(100% - 44px)",padding:10,overflow:"auto"}},Al=({children:e})=>r.jsxs(o.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"100%",position:"relative"},children:[r.jsx(o.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),r.jsxs(o.Stack,{justify:"flex-start",sx:{alignSelf:"flex-start",width:"600px",flexGrow:0,flexShrink:0},children:[r.jsx(iP,{}),r.jsx(o.Box,{sx:{flexGrow:1},children:r.jsx(xP,{})})]})]});function SP(e){return!["richText","button"].includes(e)}const kP=D.observer(({panel:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Z(),i=Y(),[a,l]=m.useState("Data"),c=e.queries,d=SP(e.viz.type)&&e.dataLoading,p=d||e.queryErrors.length>0||e.queryStateMessages!==""||c.length===0,h=s.editor.path[1];m.useEffect(()=>{l(y=>p&&y==="Visualization"?"Data":y)},[e.id,p]);const f=()=>{s.editor.setPath(["_VIEWS_",h])},g=()=>n.openConfirmModal({title:`${t("panel.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.removePanelByID(e.id,h),f()},confirmProps:{color:"red"},zIndex:320});return r.jsxs(Bi,{value:{panel:e,data:e.data,loading:d,errors:e.queryErrors,downloadPanelScreenshot:()=>{}},children:[r.jsxs(o.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[r.jsx(o.Text,{pt:9,pb:8,children:e.name}),r.jsxs(o.Group,{position:"right",noWrap:!0,children:[r.jsx(wP,{panel:e,sourceViewID:h}),r.jsx(o.Button,{size:"xs",variant:"subtle",color:"red",onClick:g,leftIcon:r.jsx(M.IconTrash,{size:14}),children:t("panel.delete")})]})]}),r.jsxs(o.Tabs,{value:a,onTabChange:l,keepMounted:!1,styles:CP,children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"Data",disabled:d,children:t("data.label")}),r.jsx(o.Tabs.Tab,{value:"Panel",children:t("panel.label")}),r.jsx(o.Tabs.Tab,{value:"Variables",disabled:p,children:r.jsx(o.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:r.jsx(o.Text,{children:t("panel.variable.labels")})})}),r.jsx(o.Tabs.Tab,{value:"Visualization",disabled:p,children:r.jsx(o.Tooltip,{label:t("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:r.jsx(o.Text,{children:t("visualization.label")})})}),r.jsx(o.Tabs.Tab,{value:"Interactions",children:t("interactions.label")})]}),r.jsxs(o.Tabs.Panel,{value:"Data",children:[r.jsx(o.LoadingOverlay,{visible:d,exitTransitionDuration:0}),r.jsx(sP,{})]}),r.jsx(o.Tabs.Panel,{value:"Panel",children:r.jsx(Al,{children:r.jsx(JA,{})})}),r.jsx(o.Tabs.Panel,{value:"Variables",children:r.jsx(Al,{children:r.jsx(gP,{})})}),r.jsx(o.Tabs.Panel,{value:"Visualization",children:r.jsx(ze,{children:r.jsx(Al,{children:r.jsx(jP,{})})})}),r.jsx(o.Tabs.Panel,{value:"Interactions",children:r.jsx(ze,{children:r.jsx(dy,{})})})]})]})}),TP=D.observer(({viewID:e,panelID:t})=>{const n=Y();if(!n.views.findByID(e))return r.jsxs(o.Text,{size:14,children:["View by ID[",e,"] is not found"]});const i=n.panels.findByID(t);return i?r.jsx(kP,{panel:i}):r.jsxs(o.Text,{size:14,children:["Panel by ID[",t,"] is not found"]})}),DP=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=m.useState([]),s=lt.useModals(),i=Z(),a=f=>{i.editor.setPath(["_QUERIES_",f])},l=()=>{s.openConfirmModal({title:"Delete ununsed queries?",children:r.jsx(o.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.content.removeUnusedQueries(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.queries.downloadSchema(t)},u=m.useMemo(()=>i.content.queries.sortedList.map(f=>f.id),[i.content.queries.sortedList]),d=()=>{n(u)},p=()=>{n([])},h=i.content.queriesUsage;return r.jsxs(o.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[r.jsx(o.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:e("query.manage")})}),r.jsxs(o.Flex,{justify:"space-between",align:"center",px:12,children:[r.jsxs(o.Group,{position:"left",children:[r.jsxs(o.Button.Group,{children:[r.jsx(o.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),r.jsx(o.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(M.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),r.jsx(o.Button,{variant:"subtle",size:"xs",color:"red",leftIcon:r.jsx(M.IconTrash,{size:14}),disabled:!i.content.hasUnusedQueries,onClick:l,children:e("query.delete_unused")})]}),r.jsx(o.Box,{sx:{flexGrow:1,overflow:"auto"},children:r.jsx(o.Checkbox.Group,{size:"xs",value:t,onChange:n,children:r.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"40px"}}),r.jsx("th",{children:e("common.name")}),r.jsx("th",{style:{width:"200px"},children:e("data_source.label")}),r.jsx("th",{style:{width:"100px",textAlign:"right"},children:e("common.type")}),r.jsx("th",{style:{width:"100px",textAlign:"center"},children:e("query.usage.label")}),r.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),r.jsx("tbody",{children:i.content.queries.sortedList.map(f=>{var y;const g=((y=h[f.id])==null?void 0:y.length)??0;return r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx(o.Checkbox,{value:f.id,styles:{input:{cursor:"pointer"}}})}),r.jsx("td",{children:f.name}),r.jsx("td",{children:f.key}),r.jsx("td",{style:{textAlign:"right"},children:f.type}),r.jsx("td",{style:{color:g===0?"#ff0000":"#000",fontWeight:g===0?"bold":"normal",textAlign:"center"},children:g}),r.jsx("td",{children:r.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>a(f.id),children:e("common.actions.open")})})]},f.id)})})]})})})]})}),MP=e=>{const{t}=_.useTranslation(),{queryModel:n}=e,s=Z(),i=Y(),l=i.findQueryUsage(n.id).length>0,c=lt.useModals(),u=()=>{c.openConfirmModal({title:`${t("query.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.queries.removeQuery(n.id),s.editor.setPath(["_QUERIES_",""])},confirmProps:{color:"red"},zIndex:320})};return l?r.jsx(o.Tooltip,{label:t("query.cant_delete"),withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,zIndex:320,position:"top-end",children:r.jsx(o.Box,{sx:{alignSelf:"flex-end"},children:r.jsx(o.Button,{disabled:!0,size:"xs",leftIcon:r.jsx(M.IconTrash,{size:16}),children:t("query.delete")})})}):r.jsx(o.Button,{color:"red",size:"xs",onClick:u,leftIcon:r.jsx(M.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:t("query.delete")})},zP=D.observer(MP),Hf=({width:e="calc(100% - 32px)",lastWidth:t="50%",height:n,count:s,spacing:i=16,pl:a=0})=>r.jsxs(o.Stack,{spacing:i,mt:6,pl:a,children:[Array.from(new Array(s-1),(l,c)=>r.jsx(o.Skeleton,{width:e,height:n,radius:"xs"},c)),r.jsx(o.Skeleton,{width:t,height:n,radius:"xs"})]}),Ur=({value:e})=>e===null||e===""?null:r.jsx(o.Tooltip,{label:e,disabled:!e,multiline:!0,children:r.jsx(o.ActionIcon,{children:r.jsx(M.IconInfoCircle,{size:14})})}),IP=({column:e})=>{const{column_key:t,column_key_text:n}=e;return t?r.jsx(o.Tooltip,{label:n,disabled:!n,children:r.jsx(o.Badge,{children:t})}):null},EP=D.observer(({dataSource:e})=>{const{columns:t}=e;return t.loading?r.jsx(Hf,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):t.empty?null:r.jsxs(o.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"1000px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{width:50}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:30}}),r.jsx("col",{style:{width:70}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{minWidth:80,width:80}}),r.jsx("col",{style:{minWidth:120,width:120}})]}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"#"}),r.jsx("th",{children:"Column Name"}),r.jsx("th",{}),r.jsx("th",{}),r.jsx("th",{children:"Type"}),r.jsx("th",{children:"Nullable"}),r.jsx("th",{children:"Default Value"})]})}),r.jsx("tbody",{children:t.data.map(n=>r.jsxs("tr",{children:[r.jsx("td",{children:n.ordinal_position}),r.jsx("td",{children:n.column_name}),r.jsx("td",{children:r.jsx(Ur,{value:n.column_comment})}),r.jsx("td",{children:r.jsx(IP,{column:n})}),r.jsx("td",{children:n.column_type}),r.jsx("td",{children:n.is_nullable}),r.jsx("td",{children:r.jsx(Ur,{value:n.column_default})})]},n.column_name))})]})}),AP=D.observer(({dataSource:e})=>{const{indexes:t}=e,n=t.data;return r.jsxs(o.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"950px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:250}})]}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Index Length"}),r.jsx("th",{children:"Index Name"}),r.jsx("th",{children:"Index Algorithm"}),r.jsx("th",{children:"Unique"}),r.jsx("th",{children:"Column Name"})]})}),r.jsx("tbody",{children:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.index_length}),r.jsx("td",{children:s.index_name}),r.jsx("td",{children:s.index_algorithm}),r.jsx("td",{children:s.is_unique?"YES":"NO"}),r.jsx("td",{children:s.column_name})]},s.index_name))})]})}),PP=D.observer(({dataSource:e})=>{const{indexes:t}=e,n=t.data;return r.jsxs(o.Table,{highlightOnHover:!0,fontSize:14,sx:{width:"auto",minWidth:"850px",alignSelf:"flex-start",flexGrow:0,tableLayout:"fixed",tbody:{fontFamily:"monospace"}},children:[r.jsxs("colgroup",{children:[r.jsx("col",{style:{minWidth:300}}),r.jsx("col",{style:{width:150}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}}),r.jsx("col",{style:{width:100}})]}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Index Name"}),r.jsx("th",{children:"Index Algorithm"}),r.jsx("th",{children:"Unique"}),r.jsx("th",{children:"Definition"}),r.jsx("th",{children:"Condition"}),r.jsx("th",{children:"Comment"})]})}),r.jsx("tbody",{children:n.map(s=>r.jsxs("tr",{children:[r.jsx("td",{children:s.index_name}),r.jsx("td",{children:s.index_algorithm}),r.jsx("td",{children:s.is_unique?"YES":"NO"}),r.jsx("td",{children:r.jsx(Ur,{value:s.index_definition})}),r.jsx("td",{children:r.jsx(Ur,{value:s.condition})}),r.jsx("td",{children:r.jsx(Ur,{value:s.comment})})]},s.index_name))})]})}),OP=D.observer(({dataSource:e})=>{const{indexes:t}=e;return t.loading||t.empty?null:e.type===ye.MySQL?r.jsx(AP,{dataSource:e}):e.type===ye.Postgresql?r.jsx(PP,{dataSource:e}):null}),LP=D.observer(({dataSource:e})=>r.jsxs(o.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[r.jsx(ze,{children:r.jsx(EP,{dataSource:e})}),r.jsx(ze,{children:r.jsx(OP,{dataSource:e})})]}));function BP({table_type:e}){return e==="VIEW"?r.jsx(M.IconEye,{size:14}):e==="BASE TABLE"?r.jsx(M.IconTable,{size:14}):null}const qP=D.observer(({dataSource:e})=>{const{tables:t}=e;return t.loading?r.jsx(Hf,{height:"24px",lastWidth:"50%",count:15}):r.jsx(o.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(t.data).map(([n,s])=>r.jsx(o.NavLink,{label:n,icon:r.jsx(M.IconDatabase,{size:14}),defaultOpened:e.table_schema===n,pl:0,childrenOffset:14,children:s.map(i=>r.jsx(o.NavLink,{label:i.table_name,icon:r.jsx(BP,{table_type:i.table_type}),onClick:()=>{e.setKeywords(n,i.table_name)},active:e.table_name===i.table_name},i.table_name))},n))})}),VP=({visible:e})=>r.jsx(o.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:r.jsx(o.LoadingOverlay,{visible:e})}),NP=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],$P={icon:{width:"50px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"50px"}}},FP=D.observer(({dataSource:e})=>{const{t}=_.useTranslation(),{tableData:n}=e;return r.jsxs(o.Group,{pt:10,px:10,position:"apart",children:[r.jsxs(o.Group,{position:"left",children:[n.maxPage>1&&r.jsx(o.Pagination,{size:"sm",value:n.page,onChange:n.setPage,total:n.maxPage,withEdges:n.maxPage>7,styles:{control:{height:"30px"}}}),r.jsx(o.Select,{icon:r.jsx(o.Text,{ta:"center",color:"dimmed",size:14,children:t("common.pagination.page_size")}),size:"xs",styles:$P,data:NP,value:String(n.limit),onChange:s=>n.setLimit(Number(s))})]}),r.jsx(o.Group,{position:"right",children:r.jsx(o.Text,{color:"dimmed",my:0,size:14,children:t("common.pagination.total_rows",{total:n.total})})})]})}),GP=D.observer(({dataSource:e})=>{const t=e.tableData;return t.maxPage===0?r.jsx(o.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:"This table is empty"}):t.error?r.jsx(o.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:t.error}):t.page===1&&t.loading?r.jsx(VP,{visible:!0}):r.jsxs(ze,{children:[r.jsx(FP,{dataSource:e}),r.jsxs(o.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[r.jsx(o.LoadingOverlay,{visible:t.loading,overlayBlur:2}),r.jsx(Jf,{data:t.data})]})]})}),WP={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},RP=D.observer(({dataSource:e})=>{const{t}=_.useTranslation();return m.useEffect(()=>{e.loadTablesIfEmpty()},[e]),e.tables.error?r.jsx(o.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e.tables.error}):r.jsxs(o.Flex,{sx:{height:"100%"},children:[r.jsx(o.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:r.jsx(ze,{children:r.jsx(qP,{dataSource:e})})}),r.jsxs(o.Tabs,{defaultValue:"structure",styles:WP,children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"structure",icon:r.jsx(M.IconColumns,{size:14}),children:t("data_source.table_structure_short")}),r.jsx(o.Tabs.Tab,{value:"data",icon:r.jsx(M.IconDatabase,{size:14}),children:t("data.label")})]}),r.jsx(o.Tabs.Panel,{value:"structure",children:r.jsx(LP,{dataSource:e})}),r.jsx(o.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:r.jsx(GP,{dataSource:e})})]})]})}),QP={modal:{paddingLeft:"0px !important",paddingRight:"0px !important"},header:{marginBottom:0,padding:"20px 20px 10px",borderBottom:"1px solid #efefef",gap:"20px"},title:{flexGrow:1},body:{padding:"0 0 0 20px"}},em=D.observer(({dataSource:e,triggerButtonProps:t={}})=>{const{t:n}=_.useTranslation(),[s,i]=m.useState(!1);return e.type==="http"?null:r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:s,onClose:()=>i(!1),title:r.jsxs(o.Group,{position:"apart",sx:{flexGrow:1},children:[r.jsx(o.Text,{fw:500,children:n("data_source.explorer")}),r.jsxs(o.Group,{spacing:7,children:[r.jsx(o.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:e.key}),r.jsx(o.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:e.type})]})]}),zIndex:320,size:"96vw",styles:QP,children:r.jsx(o.Box,{sx:{height:"calc(100vh - 220px)"},children:r.jsx(RP,{dataSource:e})})}),r.jsx(o.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...t,children:n("data_source.see_table_structure")})]})}),UP=m.forwardRef(({label:e,type:t,...n},s)=>t===ye.Transform?r.jsxs(o.Group,{className:"transform-query-option",position:"left",ref:s,...n,sx:{'&[data-selected="true"]':{".mantine-Text-root":{color:"white"},svg:{stroke:"white"}}},children:[r.jsx(M.IconVectorTriangle,{size:14,color:"#228be6"}),r.jsx(o.Text,{color:"blue",children:e})]}):r.jsxs(o.Group,{position:"apart",ref:s,...n,children:[r.jsx(o.Text,{children:e}),r.jsx(o.Text,{children:t})]})),YP=D.observer(({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),s=Z(),{data:i=[],loading:a}=W.useRequest(zi,{refreshDeps:[]},[]),l=m.useMemo(()=>{const p=i.map(h=>({label:h.key,value:h.key,type:h.type}));return p.push({label:n("query.transform.data_source"),value:ye.Transform,type:ye.Transform}),p},[i]),c=m.useMemo(()=>l.reduce((p,h)=>(p[h.value]=h.type,p),{}),[l]),u=p=>{p!==null&&t({key:p,type:c[p]})},d=m.useMemo(()=>s.datasources.find(e),[s,e]);return r.jsx(o.Select,{data:l,label:r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Box,{children:n("data_source.label")}),d&&r.jsx(em,{dataSource:d,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:UP,rightSection:d?r.jsx(o.Text,{size:"xs",color:"dimmed",children:d.type}):void 0,rightSectionWidth:85,maxDropdownHeight:500,styles:{root:{flex:1},label:{display:"block"},rightSection:{pointerEvents:"none",justifyContent:"flex-end",paddingRight:"10px",".mantine-Text-root":{userSelect:"none"}}},disabled:a,value:e.key,onChange:u})}),tm=m.forwardRef((e,t)=>{const{label:n,description:s,...i}=e;return r.jsx("div",{ref:t,...i,children:r.jsxs(o.Group,{position:"apart",noWrap:!0,children:[r.jsx(o.Text,{children:n}),r.jsx(o.Text,{size:"xs",color:"dimmed",children:s})]})})}),KP=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),[n,s]=m.useState(e.name);return m.useEffect(()=>{s(e.name)},[e.name]),r.jsx(o.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:r.jsxs(o.Stack,{spacing:10,sx:{width:"100%"},children:[r.jsx(o.Divider,{mb:-10,variant:"dashed",label:t("query.basics"),labelPosition:"center"}),r.jsx(o.TextInput,{placeholder:t("query.name_description"),label:t("query.name"),required:!0,sx:{flex:1},value:n,onChange:i=>{s(i.currentTarget.value)},rightSection:r.jsx(o.ActionIcon,{variant:"filled",color:"blue",size:"sm",onClick:()=>e.setName(n),disabled:n===e.name,children:r.jsx(M.IconDeviceFloppy,{size:16})}),onBlur:()=>{e.setName(n)}}),r.jsx(YP,{value:{type:e.type,key:e.key},onChange:({type:i,key:a})=>{e.setKey(a),e.setType(i)}}),r.jsx(o.Divider,{mt:10,mb:-10,variant:"dashed",label:t("query.conditions"),labelPosition:"center"}),r.jsx(o.MultiSelect,{label:t("query.run_by_condition.label"),placeholder:t("query.run_by_condition.unset"),data:e.conditionOptions,value:[...e.run_by],onChange:e.setRunBy,itemComponent:tm,maxDropdownHeight:500}),e.typedAsHTTP&&r.jsx(o.MultiSelect,{label:t("query.re_run_condition.label"),placeholder:t("query.re_run_condition.label"),data:e.conditionOptions,value:[...e.react_to],onChange:e.setReactTo,itemComponent:tm,maxDropdownHeight:500}),r.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(zP,{queryModel:e})]})})});function XP({content:e}){return r.jsxs(o.HoverCard,{width:"60vw",shadow:"md",children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.ActionIcon,{size:16,color:"blue",children:r.jsx(M.IconEye,{})})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(sn.Prism,{language:"sql",noCopy:!0,withLineNumbers:!0,children:e})})]})}const JP=D.observer(()=>{const t=[...Z().globalSQLSnippets.list];return t.length===0?null:r.jsxs(o.Table,{horizontalSpacing:"xs",verticalSpacing:"xs",fontSize:"sm",highlightOnHover:!0,children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Key"}),r.jsx("th",{children:"Value"})]})}),r.jsx("tbody",{children:t.map(n=>{const{id:s,content:i}=n;return r.jsxs("tr",{children:[r.jsx("td",{children:s}),r.jsx("td",{width:200,children:r.jsx(XP,{content:i})})]},s)})})]})}),ZP=`
465
467
  -- You may reference query variables in SQL or VizConfig.
466
468
  SELECT *
467
469
  FROM commit
@@ -474,9 +476,9 @@ WHERE
474
476
  AND \${sql_snippets.author_email_condition}
475
477
  -- Global SQL snippets (shared between dashboards)
476
478
  AND \${global_sql_snippets.account_condition}
477
- `,iu=S.observer(function({showSQLSnippets:e=!0,sx:n={}}){const{t:r}=_.useTranslation(),i=Z(),o=Y(),l=i.context.current,c=(()=>{const u={context:{...o.mock_context.current,...l},filters:o.filters.previewValues};return e&&(u.sql_snippets=o.sqlSnippets.record),JSON.stringify(u,null,2)})();return s.jsx(a.Stack,{sx:{overflow:"hidden",...n},children:s.jsxs(a.Tabs,{defaultValue:"guide",keepMounted:!1,children:[s.jsxs(a.Tabs.List,{grow:!0,children:[s.jsx(a.Tabs.Tab,{value:"guide",icon:s.jsx(k.IconAlertCircle,{size:14}),children:r("query_variable.guide.tabs.guide")}),s.jsx(a.Tabs.Tab,{value:"local_query_vars",icon:s.jsx(k.IconVariable,{size:14}),children:r("query_variable.guide.tabs.variables_in_this_dashboard")}),s.jsx(a.Tabs.Tab,{value:"global_sql_snippets",icon:s.jsx(k.IconVariablePlus,{size:14}),children:r("query_variable.guide.tabs.global_sql_snippets")})]}),s.jsx(a.Tabs.Panel,{value:"guide",pt:"xs",children:s.jsx(jt.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:tD})}),s.jsx(a.Tabs.Panel,{value:"local_query_vars",pt:"xs",children:s.jsx(jt.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:c})}),s.jsx(a.Tabs.Panel,{value:"global_sql_snippets",pt:"xs",children:s.jsxs(a.Stack,{spacing:10,children:[s.jsx(a.Alert,{icon:s.jsx(k.IconAlertCircle,{size:16}),title:r("global_sql_snippet.labels"),children:r("global_sql_snippet.description")}),s.jsx(eD,{})]})})]})})}),Ai=S.observer(()=>{const{t}=_.useTranslation(),[e,n]=m.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx(a.Modal,{opened:e,onClose:()=>n(!1),title:t("query_variable.labels"),zIndex:320,size:"800px",children:s.jsx(iu,{})}),s.jsx(a.Button,{variant:"subtle",onClick:()=>n(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},children:t("query_variable.open")})]})}),au={pre:["function build_request({ context, filters }, utils) {"," // build the quest"," return { method: 'POST', url: '/', params: {}, headers: {}, data: {} }","}"].join(`
479
+ `,nm=D.observer(function({showSQLSnippets:t=!0,sx:n={}}){const{t:s}=_.useTranslation(),i=Z(),a=Y(),l=i.context.current,c=(()=>{const u={context:{...a.mock_context.current,...l},filters:a.filters.previewValues};return t&&(u.sql_snippets=a.sqlSnippets.record),JSON.stringify(u,null,2)})();return r.jsx(o.Stack,{sx:{overflow:"hidden",...n},children:r.jsxs(o.Tabs,{defaultValue:"guide",keepMounted:!1,children:[r.jsxs(o.Tabs.List,{grow:!0,children:[r.jsx(o.Tabs.Tab,{value:"guide",icon:r.jsx(M.IconAlertCircle,{size:14}),children:s("query_variable.guide.tabs.guide")}),r.jsx(o.Tabs.Tab,{value:"local_query_vars",icon:r.jsx(M.IconVariable,{size:14}),children:s("query_variable.guide.tabs.variables_in_this_dashboard")}),r.jsx(o.Tabs.Tab,{value:"global_sql_snippets",icon:r.jsx(M.IconVariablePlus,{size:14}),children:s("query_variable.guide.tabs.global_sql_snippets")})]}),r.jsx(o.Tabs.Panel,{value:"guide",pt:"xs",children:r.jsx(sn.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:ZP})}),r.jsx(o.Tabs.Panel,{value:"local_query_vars",pt:"xs",children:r.jsx(sn.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:c})}),r.jsx(o.Tabs.Panel,{value:"global_sql_snippets",pt:"xs",children:r.jsxs(o.Stack,{spacing:10,children:[r.jsx(o.Alert,{icon:r.jsx(M.IconAlertCircle,{size:16}),title:s("global_sql_snippet.labels"),children:s("global_sql_snippet.description")}),r.jsx(JP,{})]})})]})})}),Pl=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=m.useState(!1);return r.jsxs(r.Fragment,{children:[r.jsx(o.Modal,{opened:t,onClose:()=>n(!1),title:e("query_variable.labels"),zIndex:320,size:"800px",children:r.jsx(nm,{})}),r.jsx(o.Button,{variant:"subtle",onClick:()=>n(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},children:e("query_variable.open")})]})}),rm={pre:["function build_request({ context, filters }, utils) {"," // build the quest"," return { method: 'POST', url: '/', params: {}, headers: {}, data: {} }","}"].join(`
478
480
  `),post:["function process_result(resp, utils, state) {"," return resp.data","}"].join(`
479
- `)},nD=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation();return t.typedAsHTTP?s.jsxs(a.Tabs,{defaultValue:"pre_process",orientation:"vertical",sx:{flexGrow:1},children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"pre_process",children:e("query.build_request")}),s.jsx(a.Tabs.Tab,{value:"post_process",children:e("query.process_result")}),s.jsx(Ai,{})]}),s.jsx(a.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:s.jsx(Yt,{label:"",value:t.pre_process,onChange:t.setPreProcess,defaultValue:au.pre})}),s.jsx(a.Tabs.Panel,{value:"post_process",p:"sm",children:s.jsx(Yt,{label:"",value:t.post_process,onChange:t.setPostProcess,defaultValue:au.post})})]}):null}),sD=S.observer(({queryID:t,usage:e})=>{const{t:n}=_.useTranslation(),r=Z().editor,i=l=>{if(l.type==="filter"){r.setPath(["_FILTERS_",l.id]);return}if(l.type==="panel"){const c=l.views[0].id;r.setPath(["_VIEWS_",c,"_PANELS_",l.id]);return}},o=l=>{r.setPath(["_VIEWS_",l])};return s.jsx(a.Stack,{py:"sm",px:"md",children:s.jsxs(a.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:100},children:n("common.type")}),s.jsx("th",{style:{width:"calc(50% - 50px)"},children:n("common.name")}),s.jsx("th",{children:n("query.usage.in_views")})]})}),s.jsx("tbody",{children:e.map(l=>s.jsxs("tr",{children:[s.jsx("td",{children:n(l.type_label)}),s.jsx("td",{children:s.jsx(a.Anchor,{component:"button",type:"button",onClick:()=>i(l),children:l.label})}),s.jsx("td",{children:s.jsxs(a.Stack,{align:"flex-start",justify:"flex-start",spacing:2,children:[l.views.map(c=>s.jsx(a.Anchor,{component:"button",type:"button",onClick:()=>o(c.id),children:s.jsx(a.Box,{children:c.label})},c.id)),l.views.length===0&&s.jsx(a.Box,{children:"--"})]})})]},l.id))})]})})}),Pi=({value:t,onChange:e,height:n="200px",defaultLanguage:r="sql",theme:i="vs-dark"})=>{const o=c=>{e==null||e(c??"")},l=!e;return s.jsx(Le,{className:"minimal-monaco-editor",height:n,defaultLanguage:r,value:t,onChange:l?void 0:o,theme:i,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:l||!e,"semanticHighlighting.enabled":!0}})},rD=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation(),n=m.useMemo(()=>b.groupBy(t.dependencies,"type"),[t.dependencies]),r=m.useMemo(()=>t.dependencies.some(o=>!o.valid),[t.dependencies]),i=t.dependencies.length>0;return i?s.jsxs(a.HoverCard,{withinPortal:!0,zIndex:340,shadow:"md",disabled:!i,children:[s.jsx(a.HoverCard.Target,{children:s.jsx(a.Button,{size:"xs",variant:"subtle",color:r?"red":"green",disabled:!i,leftIcon:r?s.jsx(k.IconAlertTriangle,{size:16}):s.jsx(k.IconDiscountCheckFilled,{size:16}),children:e("query.dependency.label")})}),s.jsx(a.HoverCard.Dropdown,{children:s.jsx(a.List,{spacing:"md",size:14,listStyleType:"none",children:Object.entries(n).map(([o,l])=>s.jsxs(a.List.Item,{children:[s.jsx(a.Text,{fw:"bold",ff:"monospace",children:e(`${o}.label`)}),s.jsx(a.List,{withPadding:!0,size:14,sx:{fontFamily:"monospace",svg:{verticalAlign:"middle"}},children:l.map(c=>s.jsx(a.List.Item,{icon:s.jsx(a.Box,{sx:{path:{fill:c.valid?"rgb(18, 184, 134)":"rgb(250, 82, 82)"}},children:s.jsx(k.IconPointFilled,{size:12})}),children:c.key},c.key))})]},o))})})]}):s.jsx(a.Tooltip,{label:e("query.dependency.has_none"),children:s.jsx(a.Button,{size:"xs",variant:"subtle",color:"gray",leftIcon:s.jsx(k.IconHierarchy,{size:16,style:{transform:"rotate(180deg)"}}),sx:{transform:"none !important"},children:e("query.dependency.label")})})}),iD="SELECT 1",aD=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation(),[n,r]=m.useState(t.sql),i=()=>{t.setSQL(n)},o=()=>{r(t.sql)},l=()=>{r(iD)};m.useEffect(()=>{r(t.sql)},[t.sql]);const c=n!==t.sql;return s.jsxs(a.Stack,{spacing:4,sx:{height:"100%"},children:[s.jsxs(a.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[s.jsx(a.Group,{position:"left",children:s.jsx(rD,{queryModel:t})}),s.jsxs(a.Group,{position:"right",children:[s.jsx(a.Button,{onClick:l,size:"xs",variant:"default",leftIcon:s.jsx(k.IconPlayerSkipBack,{size:16}),children:e("common.actions.reset_to_default")}),s.jsx(a.Button,{onClick:o,color:"red",size:"xs",disabled:!c,leftIcon:s.jsx(k.IconRecycle,{size:16}),children:e("common.actions.revert_changes")}),s.jsx(a.Button,{color:"green",size:"xs",onClick:i,disabled:!c,leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),children:e("common.actions.save_changes")})]})]}),s.jsx(Pi,{height:"100%",value:n,onChange:r,theme:"sql-dark",defaultLanguage:"sql"})]})}),oD=({value:t,height:e="200px",defaultLanguage:n="sql"})=>s.jsx(Le,{className:"preview-sql-in-monaco-editor",height:e,defaultLanguage:n,value:t,onChange:void 0,theme:"vs-light",options:{lineNumbers:"on",folding:!0,lineDecorationsWidth:20,wordWrap:"on",minimap:{enabled:!1},readOnly:!0}}),lD=S.observer(({value:t})=>{const n=he().payloadForSQL,r=m.useMemo(()=>Ts(t,n),[t,n]);return s.jsx(oD,{height:"100%",value:r})}),ou={pre:["function process_request({ context, filters, sql }, utils) {"," // modify and return sql"," return sql","}"].join(`
481
+ `)},HP=D.observer(({queryModel:e})=>{const{t}=_.useTranslation();return e.typedAsHTTP?r.jsxs(o.Tabs,{defaultValue:"pre_process",orientation:"vertical",sx:{flexGrow:1},children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"pre_process",children:t("query.build_request")}),r.jsx(o.Tabs.Tab,{value:"post_process",children:t("query.process_result")}),r.jsx(Pl,{})]}),r.jsx(o.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:r.jsx(er,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:rm.pre})}),r.jsx(o.Tabs.Panel,{value:"post_process",p:"sm",children:r.jsx(er,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:rm.post})})]}):null}),e2=D.observer(({queryID:e,usage:t})=>{const{t:n}=_.useTranslation(),s=Z().editor,i=l=>{if(l.type==="filter"){s.setPath(["_FILTERS_",l.id]);return}if(l.type==="panel"){const c=l.views[0].id;s.setPath(["_VIEWS_",c,"_PANELS_",l.id]);return}},a=l=>{s.setPath(["_VIEWS_",l])};return r.jsx(o.Stack,{py:"sm",px:"md",children:r.jsxs(o.Table,{highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:100},children:n("common.type")}),r.jsx("th",{style:{width:"calc(50% - 50px)"},children:n("common.name")}),r.jsx("th",{children:n("query.usage.in_views")})]})}),r.jsx("tbody",{children:t.map(l=>r.jsxs("tr",{children:[r.jsx("td",{children:n(l.type_label)}),r.jsx("td",{children:r.jsx(o.Anchor,{component:"button",type:"button",onClick:()=>i(l),children:l.label})}),r.jsx("td",{children:r.jsxs(o.Stack,{align:"flex-start",justify:"flex-start",spacing:2,children:[l.views.map(c=>r.jsx(o.Anchor,{component:"button",type:"button",onClick:()=>a(c.id),children:r.jsx(o.Box,{children:c.label})},c.id)),l.views.length===0&&r.jsx(o.Box,{children:"--"})]})})]},l.id))})]})})}),Ol=({value:e,onChange:t,height:n="200px",defaultLanguage:s="sql",theme:i="vs-dark"})=>{const a=c=>{t==null||t(c??"")},l=!t;return r.jsx(tt,{className:"minimal-monaco-editor",height:n,defaultLanguage:s,value:e,onChange:l?void 0:a,theme:i,options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:l||!t,"semanticHighlighting.enabled":!0}})},t2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),n=m.useMemo(()=>v.groupBy(e.dependencies,"type"),[e.dependencies]),s=m.useMemo(()=>e.dependencies.some(a=>!a.valid),[e.dependencies]),i=e.dependencies.length>0;return i?r.jsxs(o.HoverCard,{withinPortal:!0,zIndex:340,shadow:"md",disabled:!i,children:[r.jsx(o.HoverCard.Target,{children:r.jsx(o.Button,{size:"xs",variant:"subtle",color:s?"red":"green",disabled:!i,leftIcon:s?r.jsx(M.IconAlertTriangle,{size:16}):r.jsx(M.IconDiscountCheckFilled,{size:16}),children:t("query.dependency.label")})}),r.jsx(o.HoverCard.Dropdown,{children:r.jsx(o.List,{spacing:"md",size:14,listStyleType:"none",children:Object.entries(n).map(([a,l])=>r.jsxs(o.List.Item,{children:[r.jsx(o.Text,{fw:"bold",ff:"monospace",children:t(`${a}.label`)}),r.jsx(o.List,{withPadding:!0,size:14,sx:{fontFamily:"monospace",svg:{verticalAlign:"middle"}},children:l.map(c=>r.jsx(o.List.Item,{icon:r.jsx(o.Box,{sx:{path:{fill:c.valid?"rgb(18, 184, 134)":"rgb(250, 82, 82)"}},children:r.jsx(M.IconPointFilled,{size:12})}),children:c.key},c.key))})]},a))})})]}):r.jsx(o.Tooltip,{label:t("query.dependency.has_none"),children:r.jsx(o.Button,{size:"xs",variant:"subtle",color:"gray",leftIcon:r.jsx(M.IconHierarchy,{size:16,style:{transform:"rotate(180deg)"}}),sx:{transform:"none !important"},children:t("query.dependency.label")})})}),n2="SELECT 1",r2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),[n,s]=m.useState(e.sql),i=()=>{e.setSQL(n)},a=()=>{s(e.sql)},l=()=>{s(n2)};m.useEffect(()=>{s(e.sql)},[e.sql]);const c=n!==e.sql;return r.jsxs(o.Stack,{spacing:4,sx:{height:"100%"},children:[r.jsxs(o.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[r.jsx(o.Group,{position:"left",children:r.jsx(t2,{queryModel:e})}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:l,size:"xs",variant:"default",leftIcon:r.jsx(M.IconPlayerSkipBack,{size:16}),children:t("common.actions.reset_to_default")}),r.jsx(o.Button,{onClick:a,color:"red",size:"xs",disabled:!c,leftIcon:r.jsx(M.IconRecycle,{size:16}),children:t("common.actions.revert_changes")}),r.jsx(o.Button,{color:"green",size:"xs",onClick:i,disabled:!c,leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),children:t("common.actions.save_changes")})]})]}),r.jsx(Ol,{height:"100%",value:n,onChange:s,theme:"sql-dark",defaultLanguage:"sql"})]})}),s2=({value:e,height:t="200px",defaultLanguage:n="sql"})=>r.jsx(tt,{className:"preview-sql-in-monaco-editor",height:t,defaultLanguage:n,value:e,onChange:void 0,theme:"vs-light",options:{lineNumbers:"on",folding:!0,lineDecorationsWidth:20,wordWrap:"on",minimap:{enabled:!1},readOnly:!0}}),i2=D.observer(({value:e})=>{const n=_e().payloadForSQL,s=m.useMemo(()=>Ci(e,n),[e,n]);return r.jsx(s2,{height:"100%",value:s})}),sm={pre:["function process_request({ context, filters, sql }, utils) {"," // modify and return sql"," return sql","}"].join(`
480
482
  `),post:["function process_result(data, utils, state) {"," // process data and return the result"," return data","}"].join(`
481
- `)},cD=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation();return t.typedAsSQL?s.jsxs(a.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%",height:"28px",lineHeight:"28px"}},keepMounted:!1,children:[s.jsxs(a.Tabs.List,{children:[s.jsx(a.Tabs.Tab,{value:"Edit",children:s.jsx(a.Group,{spacing:14,position:"apart",children:e("query.edit_sql")})}),s.jsx(a.Tabs.Tab,{value:"Preview",children:e("query.preview_sql")}),s.jsx(a.Tabs.Tab,{value:"pre_process",children:e("query.process_request")}),s.jsx(a.Tabs.Tab,{value:"post_process",children:e("query.process_result")}),s.jsx(Ai,{}),t.datasource&&s.jsx(su,{dataSource:t.datasource})]}),s.jsx(a.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:s.jsx(aD,{queryModel:t})}),s.jsx(a.Tabs.Panel,{value:"Preview",p:0,pl:4,children:s.jsx(lD,{value:t.sql})}),s.jsx(a.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:s.jsx(Yt,{label:"",value:t.pre_process,onChange:t.setPreProcess,defaultValue:ou.pre})}),s.jsx(a.Tabs.Panel,{value:"post_process",p:"sm",children:s.jsx(Yt,{label:"",value:t.post_process,onChange:t.setPostProcess,defaultValue:ou.post})})]}):null}),uD={pre:["function transform(queries, state, utils) {"," // use queries & dashboar state to build new data"," const data = []"," return data","}"].join(`
482
- `),post:""},dD=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation(),n=Y();return t.isTransform?s.jsxs(a.Stack,{py:20,px:20,sx:{height:"100%"},children:[s.jsx(a.Text,{size:"sm",children:e("query.transform.guide.pick_queries")}),s.jsx(a.MultiSelect,{data:n.queries.optionsWithoutTransform,value:[...t.dep_query_ids],onChange:t.setDependantQueryIDs,maxDropdownHeight:800}),s.jsx(a.Text,{size:"sm",children:e("query.transform.guide.write_function")}),s.jsx(a.Box,{sx:{flexGrow:1},children:s.jsx(Yt,{label:"",value:t.pre_process,onChange:t.setPreProcess,defaultValue:uD.pre})})]}):null}),_n={height:"calc(100% - 44px)",padding:0},pD=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation(),n=Y(),r=m.useMemo(()=>t.datasource?t.typedAsHTTP?"HTTP":"SQL":"Configurations",[t.datasource,t.typedAsHTTP]),[i,o]=m.useState(r);m.useEffect(()=>{o(u=>u!=="Configurations"&&r==="Configurations"?"Configurations":u)},[r]);const l=n.findQueryUsage(t.id),c=l.length===0;return s.jsxs(a.Tabs,{value:i,onTabChange:o,defaultValue:r,orientation:"horizontal",keepMounted:!1,sx:{height:"100vh"},children:[s.jsxs(a.Tabs.List,{grow:!0,children:[s.jsx(a.Tabs.Tab,{value:"Configurations",children:e("query.configurations")}),t.typedAsSQL&&s.jsx(a.Tabs.Tab,{value:"SQL",children:e("query.request")}),t.typedAsHTTP&&s.jsx(a.Tabs.Tab,{value:"HTTP",children:e("query.request")}),t.isTransform&&s.jsx(a.Tabs.Tab,{value:"Transform",children:e("query.transform.label")}),s.jsx(a.Tabs.Tab,{value:"Data",disabled:!t.canPreviewData,children:s.jsx(a.Tooltip,{label:t.guideToPreviewData,disabled:t.canPreviewData,withinPortal:!0,children:s.jsx(a.Text,{children:e("data.preview_data")})})}),s.jsx(a.Tabs.Tab,{value:"Usage",disabled:c,children:s.jsx(a.Tooltip,{label:e("query.usage.unused_description"),disabled:!c,withinPortal:!0,children:s.jsx(a.Text,{children:e("query.usage.label")})})})]}),s.jsx(a.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:s.jsx(Z1,{queryModel:t})}),t.typedAsSQL&&s.jsx(a.Tabs.Panel,{value:"SQL",sx:_n,children:s.jsx(a.Stack,{sx:{height:"100%"},children:s.jsx(cD,{queryModel:t})})}),t.typedAsHTTP&&s.jsx(a.Tabs.Panel,{value:"HTTP",sx:_n,children:s.jsx(a.Stack,{sx:{height:"100%"},children:s.jsx(nD,{queryModel:t})})}),t.isTransform&&s.jsx(a.Tabs.Panel,{value:"Transform",sx:_n,children:s.jsx(a.Stack,{sx:{height:"100%"},children:s.jsx(dD,{queryModel:t})})}),s.jsx(a.Tabs.Panel,{value:"Data",sx:{..._n,overflow:"hidden"},children:s.jsx(Mi,{id:t.id,moreActions:null,refreshOnMount:!0})}),s.jsx(a.Tabs.Panel,{value:"Usage",sx:{..._n,overflow:"hidden"},children:s.jsx(sD,{queryID:t.id,usage:l})})]})}),hD=S.observer(({id:t})=>{const n=Y().queries.findByID(t);return t===""?null:n?s.jsx(pD,{queryModel:n}):s.jsx(a.Text,{size:14,color:"red",children:"Invalid Query ID"})}),mD=S.observer(({value:t})=>{const n=he().payloadForSQL,r=m.useMemo(()=>Ts(t,n),[t,n]);return s.jsx(Pi,{height:"100%",value:r})}),xD=S.observer(({item:t,remove:e,onKeyChanged:n})=>{const{t:r}=_.useTranslation(),[i,o]=m.useState("SQL"),[l,c]=m.useState(t.key),u=()=>{t.setKey(l),n(l)},d=l!==t.key,p=t.isADuplicatedKey(l),[h,g]=m.useState(t.value),f=()=>{t.setValue(h)};m.useEffect(()=>{c(t.key),g(t.value)},[t]);const v=h!==t.value,w=Fe.useModals(),T=()=>{w.openConfirmModal({title:`${r("sql_snippet.delete")}?`,labels:{confirm:r("common.actions.confirm"),cancel:r("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:e,confirmProps:{color:"red"},zIndex:320})};return s.jsxs(a.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[s.jsxs(a.Group,{sx:{alignItems:"end"},spacing:40,children:[s.jsx(a.TextInput,{label:r(p?"sql_snippet.key_occupied":"sql_snippet.key"),value:l,onChange:D=>{c(D.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:s.jsx(a.ActionIcon,{color:"blue",variant:"subtle",onClick:u,disabled:!d||p,children:s.jsx(L.DeviceFloppy,{size:16})}),error:p}),s.jsx(a.Button,{leftIcon:s.jsx(L.Trash,{size:16}),color:"red",variant:"light",onClick:T,children:r("sql_snippet.delete")})]}),s.jsxs(a.Tabs,{value:i,onTabChange:o,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[s.jsxs(a.Tabs.List,{sx:{position:"relative"},children:[s.jsx(a.Tabs.Tab,{value:"SQL",children:r("sql_snippet.edit_snippet")}),s.jsx(a.Tabs.Tab,{value:"Preview",children:r("sql_snippet.preview_snippet")}),s.jsx(Ai,{}),s.jsx(a.ActionIcon,{color:"blue",variant:"filled",onClick:f,disabled:!v,sx:{position:"absolute",top:0,right:10},children:s.jsx(L.DeviceFloppy,{size:18})})]}),s.jsx(a.Tabs.Panel,{value:"SQL",pt:"sm",children:s.jsx(Pi,{height:"100%",value:h,onChange:g,defaultLanguage:"sql",theme:"sql-dark"})}),s.jsx(a.Tabs.Panel,{value:"Preview",pt:"sm",children:s.jsx(mD,{value:h})})]})]})}),gD=S.observer(({id:t})=>{const e=Z(),n=Y(),r=m.useMemo(()=>n.sqlSnippets.findByKey(t),[t]);if(!t)return null;if(!r)return s.jsxs(a.Text,{size:14,children:["SQL Snippet by key[",t,"] is not found"]});const i=()=>{e.editor.setPath(["_SQL_SNIPPETS_",""])},o=()=>{n.sqlSnippets.removeByKey(t),i()},l=c=>{e.editor.setPath(["_SQL_SNIPPETS_",c])};return s.jsx(xD,{item:r,remove:o,onKeyChanged:l})}),fD=S.observer(()=>{const{t}=_.useTranslation(),[e,n]=m.useState([]),r=Fe.useModals(),i=Z(),o=g=>{i.editor.setPath(["_SQL_SNIPPETS_",g])},l=()=>{r.openConfirmModal({title:"Delete ununsed SQL snippets?",children:s.jsx(a.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.content.removeUnusedSQLSnippets(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.sqlSnippets.downloadSchema(e)},u=m.useMemo(()=>i.content.sqlSnippets.sortedList.map(g=>g.key),[i.content.sqlSnippets.sortedList]),d=()=>{n(u)},p=()=>{n([])},h=i.content.sqlSnippetsUsage;return s.jsxs(a.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[s.jsx(a.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:s.jsx(a.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:t("sql_snippet.manage")})}),s.jsxs(a.Flex,{justify:"space-between",align:"center",px:12,children:[s.jsxs(a.Group,{position:"left",children:[s.jsxs(a.Button.Group,{children:[s.jsx(a.Button,{variant:"default",size:"xs",onClick:d,children:t("common.actions.select_all")}),s.jsx(a.Button,{variant:"default",size:"xs",onClick:p,children:t("common.actions.clear_selection")})]}),s.jsx(a.Button,{size:"xs",color:"blue",leftIcon:s.jsx(k.IconCode,{size:14}),disabled:e.length===0,onClick:c,children:t("common.actions.download_schema")})]}),s.jsx(a.Button,{variant:"subtle",size:"xs",color:"red",leftIcon:s.jsx(k.IconTrash,{size:14}),disabled:!i.content.hasUnusedSQLSnippets,onClick:l,children:t("sql_snippet.delete_unused")})]}),s.jsx(a.Box,{sx:{flexGrow:1,overflow:"auto"},children:s.jsx(a.Checkbox.Group,{size:"xs",value:e,onChange:n,children:s.jsxs(a.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"40px"}}),s.jsx("th",{children:t("common.key")}),s.jsx("th",{style:{width:"100px",textAlign:"center"},children:t("sql_snippet.usage.label")}),s.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:t("common.action")})]})}),s.jsx("tbody",{children:i.content.sqlSnippets.sortedList.map(g=>{var v;const f=((v=h[g.key])==null?void 0:v.length)??0;return s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx(a.Checkbox,{value:g.key,styles:{input:{cursor:"pointer"}}})}),s.jsx("td",{children:g.key}),s.jsx("td",{style:{color:f===0?"#ff0000":"#000",fontWeight:f===0?"bold":"normal",textAlign:"center"},children:f}),s.jsx("td",{children:s.jsx(a.Button,{variant:"subtle",size:"xs",onClick:()=>o(g.key),children:t("common.actions.open")})})]},g.key)})})]})})})]})}),yD=S.observer(({view:t})=>!t||t.type!==B.Division?null:s.jsx(a.Stack,{})),bD=S.observer(({view:t})=>{const{t:e,i18n:n}=_.useTranslation(),r=m.useMemo(()=>[{value:"default",label:e("common.tabs.variant.default")},{value:"outline",label:e("common.tabs.variant.outline")},{value:"pills",label:e("common.tabs.variant.pills")}],[n.language]),i=m.useMemo(()=>[{value:"horizontal",label:e("common.tabs.orientation.horizontal")},{value:"vertical",label:e("common.tabs.orientation.vertical")}],[n.language]);if(!t||t.type!==B.Tabs)return null;const o=t.config;return s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mt:8,mb:0,label:e("view.component.tabs.tabs_settings"),labelPosition:"center"}),s.jsx(a.Select,{label:e("common.tabs.variant.label"),value:o.variant,onChange:o.setVariant,data:r}),s.jsx(a.Select,{label:e("common.tabs.orientation.label"),value:o.orientation,onChange:o.setOrientation,data:i}),s.jsx(a.Switch,{label:e("common.tabs.grow_tabs"),checked:o.grow,onChange:l=>o.setGrow(l.currentTarget.checked)})]})}),vD=({disabled:t,value:e,onChange:n})=>{const r=i=>{i&&n(i)};return s.jsxs(a.Box,{sx:{position:"relative"},children:[t&&s.jsx(a.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),s.jsx(Le,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:t}})]})},_D=({value:t,onChange:e})=>{const{t:n}=_.useTranslation(),[r,{setTrue:i,setFalse:o}]=W.useBoolean(),[l,c]=m.useState(t??cs),u=f=>{c({...l,enabled:f})},d=()=>{o();const{enabled:f,func_content:v}=l,w={enabled:f,func_content:v};c(w),e(w)},p=()=>{o(),c(t)},h=f=>{c(v=>({...v,func_content:f}))},g=()=>{h(cs.func_content)};return s.jsxs(s.Fragment,{children:[s.jsx(a.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:i,sx:{flexGrow:0},children:s.jsx(L.Settings,{size:14})}),s.jsx(a.Modal,{size:800,title:n("view.component.modal.custom_title"),opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&s.jsxs(a.Stack,{children:[s.jsx(a.Checkbox,{mt:10,label:n("common.enabled"),checked:l.enabled,onChange:f=>u(f.currentTarget.checked)}),s.jsx(vD,{value:l.func_content,onChange:h,disabled:!l.enabled}),s.jsxs(a.Group,{position:"apart",children:[s.jsx(a.Button,{onClick:g,color:"red",leftIcon:s.jsx(L.Recycle,{size:20}),children:n("common.actions.revert")}),s.jsxs(a.Group,{position:"right",children:[s.jsx(a.Button,{onClick:p,variant:"subtle",children:n("common.actions.cancel")}),s.jsx(a.Button,{onClick:d,children:n("common.actions.save")})]})]})]})})]})},jD=S.observer(({view:t})=>{const{t:e}=_.useTranslation();if(!t||t.type!==B.Modal)return null;const n=t.config,r=n.custom_modal_title.value;return s.jsxs(a.Stack,{children:[s.jsx(a.Divider,{mt:8,label:e("view.component.modal.modal_settings"),labelPosition:"center"}),s.jsxs(a.Flex,{gap:10,children:[s.jsx(a.TextInput,{label:e("view.component.modal.title"),value:r,onChange:b.noop,disabled:!0,sx:{flexGrow:1}}),s.jsx(_D,{value:n.custom_modal_title,onChange:n.custom_modal_title.replace})]}),s.jsxs(a.Group,{grow:!0,children:[s.jsx(a.TextInput,{label:e("view.component.modal.width"),value:n.width,onChange:i=>n.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),s.jsx(a.TextInput,{label:e("view.component.modal.height"),value:n.height,onChange:i=>n.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),wD=S.observer(({view:t})=>s.jsxs(s.Fragment,{children:[s.jsx(yD,{view:t}),s.jsx(jD,{view:t}),s.jsx(bD,{view:t})]})),CD=S.observer(({view:t})=>{const{t:e,i18n:n}=_.useTranslation(),r=m.useMemo(()=>[{label:e("view.component.div.label"),value:B.Division},{label:e("view.component.modal.label"),value:B.Modal},{label:e("view.component.tabs.label"),value:B.Tabs}],[n.language]);return t?s.jsxs(a.Stack,{sx:{position:"relative"},children:[s.jsx(a.TextInput,{label:e("common.name"),value:t.name,onChange:i=>{t.setName(i.currentTarget.value)}}),s.jsx(a.Select,{label:e("common.type"),withinPortal:!0,zIndex:320,value:t.type,onChange:t.setType,data:r}),s.jsx(wD,{view:t})]}):null}),SD=S.observer(({id:t})=>{const{t:e}=_.useTranslation(),n=Fe.useModals(),r=Z(),i=Y();if(t==="")return null;const o=i.views.findByID(t);if(!o)return s.jsxs(a.Text,{size:14,children:["View by ID[",t,"] is not found"]});const l=()=>{r.editor.setPath(["_VIEWS_",""])},c=()=>{n.openConfirmModal({title:`${e("view.delete")}?`,labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.views.removeByID(t),l()},zIndex:320})};return s.jsxs(a.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[s.jsx(a.Group,{position:"right",pt:10,children:s.jsx(a.Button,{size:"xs",color:"red",leftIcon:s.jsx(L.Trash,{size:16}),onClick:c,children:e("view.delete")})}),s.jsx(a.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:s.jsx(CD,{view:o})})]})});function kD(t){return t.length===1&&t[0]==="_QUERY_VARS_"}function TD(t){return t.length===1&&t[0]==="_MOCK_CONTEXT_"}function DD(t){return t.length===1&&t[0]==="_FILTERS_"}function zD(t){return t.length===2&&t[0]==="_FILTERS_"}function MD(t){return t.length===1&&t[0]==="_SQL_SNIPPETS_"}function ID(t){return t.length===2&&t[0]==="_SQL_SNIPPETS_"}function ED(t){return t.length===2&&t[0]==="_QUERIES_"}function AD(t){return t.length===1&&t[0]==="_QUERIES_"}function PD(t){return t.length===2&&t[0]==="_VIEWS_"}function $D(t){return t.length===4&&t[0]==="_VIEWS_"&&t[2]==="_PANELS_"}const BD=S.observer(()=>s.jsx(a.Stack,{sx:{height:"100%"},p:"sm",children:s.jsx(iu,{})})),LD=S.observer(()=>{const t=Z().editor,e=t.path;return kD(e)?s.jsx(BD,{}):TD(e)?s.jsx(YT,{}):DD(e)?s.jsx(UT,{}):zD(e)?s.jsx(a.Box,{p:"xs",pl:20,children:s.jsx(RT,{id:e[1]})}):MD(e)?s.jsx(fD,{}):ID(e)?s.jsx(gD,{id:e[1]}):AD(e)?s.jsx(I1,{}):ED(e)?s.jsx(hD,{id:e[1]}):PD(e)?s.jsx(a.Box,{p:"xs",pl:20,children:s.jsx(SD,{id:e[1]})}):$D(e)?s.jsx(M1,{viewID:e[1],panelID:e[3]}):s.jsx(a.Box,{children:t.path})}),qD=S.observer(()=>s.jsx(LD,{})),OD=S.observer(()=>{const{t}=_.useTranslation(),e=Z(),n=()=>{const r=new Date().getTime().toString(),i={id:r,key:r,label:r,order:e.content.filters.current.length+1,type:re.TextInput,config:ti(),visibleInViewsIDs:["Main"],auto_submit:!1};e.content.filters.append(i),e.editor.setPath(["_FILTERS_",r])};return s.jsx(a.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("filter.add")})}),VD=S.observer(({parentID:t})=>{const{t:e}=_.useTranslation(),n=Y();if(!t)return null;const r=n.views.findByID(t);return!r||r.type===B.Tabs?null:s.jsx(a.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>n.addANewPanel(r.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("panel.add")})}),ND=S.observer(()=>{const{t}=_.useTranslation(),e=Z(),n=()=>{const r=new Date().getTime().toString(),i={id:r,name:r,type:de.Postgresql,key:"",sql:""};e.content.queries.append(i),e.editor.setPath(["_QUERIES_",r])};return s.jsx(a.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("query.add")})}),GD=S.observer(()=>{const{t}=_.useTranslation(),e=Z(),n=()=>{const r=new Date().getTime().toString(),i={key:r,value:""};e.content.sqlSnippets.append(i),e.editor.setPath(["_SQL_SNIPPETS_",r])};return s.jsx(a.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("sql_snippet.add")})}),FD=S.observer(()=>{const{t}=_.useTranslation(),e=Y();return s.jsx(a.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:e.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("view.add")})}),WD=S.observer(()=>{const{t}=_.useTranslation(),e=Z();return s.jsx(a.Button,{variant:"subtle",rightIcon:s.jsx(k.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>e.editor.setPath(["_QUERIES_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:t("query.manage")})}),QD=S.observer(()=>{const{t}=_.useTranslation(),e=Z();return s.jsx(a.Button,{variant:"subtle",rightIcon:s.jsx(k.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>e.editor.setPath(["_SQL_SNIPPETS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:t("sql_snippet.manage")})}),RD=S.observer(()=>{const{t}=_.useTranslation(),e=Z();return s.jsx(a.Button,{variant:"subtle",rightIcon:s.jsx(k.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>e.editor.setPath(["_FILTERS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:t("filter.manage")})}),UD=S.observer(({action_type:t,parentID:e})=>t==="_Add_A_Filter_"?s.jsx(OD,{}):t==="_Add_A_SQL_SNIPPET_"?s.jsx(GD,{}):t==="_Add_A_QUERY_"?s.jsx(ND,{}):t==="_Add_A_VIEW_"?s.jsx(FD,{}):t==="_Add_A_PANEL_"?s.jsx(VD,{parentID:e}):t==="_QUERIES_SETTINGS_"?s.jsx(WD,{}):t==="_SQL_SNIPPETS_SETTINGS_"?s.jsx(QD,{}):t==="_FILTERS_SETTINGS_"?s.jsx(RD,{}):null),lu=S.observer(({option:t})=>{var p;const{t:e}=_.useTranslation(),n=Z().editor,r=n.isOptionActive,i=r(n.path,t),o=n.isOptionOpened,l=n.navigate,c=o(t),[u,d]=m.useState(c);return m.useEffect(()=>{d(c)},[c]),s.jsx(a.NavLink,{active:i,defaultOpened:c,opened:u,onChange:d,label:e(t.label),onClick:()=>l(t),icon:t.Icon?s.jsx(t.Icon,{size:18}):null,children:(p=t.children)==null?void 0:p.map(h=>h._type==="ACTION"?s.jsx(UD,{action_type:h._action_type,parentID:h.parentID},`_ADD_${h.value}_`):s.jsx(lu,{option:h},h.value))},t.label)}),YD=S.observer(()=>{const t=Z();return s.jsx(a.Box,{sx:{position:"relative"},children:t.editor.navOptions.map(e=>s.jsx(lu,{option:e},e.value))})}),KD=S.observer(()=>{const{t}=_.useTranslation(),e=Z();return s.jsxs(a.Navbar,{p:0,width:{base:220,xs:220,sm:240,md:260,lg:300,xl:320},sx:{height:"100vh - 60px - 60px",".mantine-NavLink-body":{wordWrap:"break-word"}},children:[s.jsx(a.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:s.jsx(a.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:t("common.titles.settings")})}),s.jsx(a.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:s.jsx(YD,{})}),s.jsx(a.Navbar.Section,{children:s.jsx(a.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:s.jsx(a.Button,{size:"xs",color:"red",leftIcon:s.jsx(k.IconX,{size:18}),onClick:()=>e.editor.close(),children:t("common.actions.close")})})})]})}),JD={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden",minWidth:"calc(var(--mantine-navbar-width, 0px) + 1200px)"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},XD=S.observer(()=>{const t=Z().editor;return s.jsx(a.Modal,{onClose:()=>t.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:t.settings_open,fullScreen:!0,title:null,transitionProps:{duration:0},withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{body:{padding:"0 !important"},content:{overflowY:"hidden !important"}},children:s.jsx(a.AppShell,{padding:0,navbar:s.jsx(KD,{}),styles:JD,children:s.jsx(qD,{})})})}),ZD=t=>t.replace(/([^:])(\/\/+)/g,"$1/");function HD(t){m.useEffect(()=>{if(Le.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const n=ZD(t);Le.loader.config({paths:{vs:n}}),Le.loader.init().then(r=>console.log("monaco instance:",r))},[])}_a(),wa();const ez={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},tz=({context:t,dashboard:e,content:n,update:r,className:i="dashboard",config:o,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h},g)=>{HD(o.monacoPath),Ds(o);const{data:f=[]}=W.useRequest(Es),{data:v=[]}=W.useRequest(Ca),w=m.useMemo(()=>Nc(e,n,f,v,t,u??{}),[e,n]);m.useImperativeHandle(g,()=>w,[w]),Fc(w.content,!0),m.useEffect(()=>{w.context.replace(t)},[t]),m.useEffect(()=>{w.datasources.replace(f)},[f]),m.useEffect(()=>{w.globalSQLSnippets.replace(v)},[v]),m.useEffect(()=>{d==null||d(w.content.filters.values)},[d,w.content.filters.values]),m.useEffect(()=>{u&&w.content.filters.patchValues(u)},[u,w.content.filters.patchValues]),m.useEffect(()=>J.reaction(()=>J.toJS(w.json),E=>{l==null||l(E)}),[w]);const T=async()=>{await r(w.json,w.content.json)},D=W.useCreation(Fr,[]),z=Wc(D);return W.useWhyDidYouUpdate("@devtable/dashboard editor",{context:t,dashboard:e,content:n,update:r,className:i,config:o,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h}),s.jsx(Gc,{lang:h,children:s.jsx(Fe.ModalsProvider,{children:s.jsx(Ns,{children:s.jsx(Ls,{value:{searchButtonProps:o.searchButtonProps},children:s.jsx($s,{value:w,children:s.jsx(qs,{value:w.content,children:s.jsx(En.Provider,{value:{inEditMode:!0},children:s.jsx(ut.Provider,{value:D,children:s.jsxs(os,{configure:z,children:[s.jsx(a.AppShell,{padding:0,header:s.jsx(sT,{onExit:p,saveDashboardChanges:T,headerSlot:c}),navbar:s.jsx(MT,{}),styles:ez,children:s.jsx(a.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:w.content.views.visibleViews.map(E=>s.jsx(zc,{view:E},E.id))})}),s.jsx(XD,{})]})})})})})})})})})},nz=S.observer(m.forwardRef(tz)),QM="",$i=x.types.model({id:x.types.string,name:x.types.string,dashboard_id:x.types.string,create_time:x.types.string,update_time:x.types.string,version:x.types.string,filters:mi,queries:fi,sqlSnippets:bi,views:di,panels:hi,layouts:yi,mock_context:Ur}).views(t=>({get json(){return{id:t.id,name:t.name,create_time:t.create_time,update_time:t.update_time,dashboard_id:t.dashboard_id,content:{views:t.views.json,panels:t.panels.json,filters:t.filters.json,version:t.version,layouts:t.layouts.json,definition:{queries:t.queries.json,sqlSnippets:t.sqlSnippets.json,mock_context:t.mock_context.current}}}},get contentJSON(){return this.json.content},get payloadForSQL(){const e=x.getParent(t).context.current,n=x.getParent(t).globalSQLSnippets,r={context:{...t.mock_context.current,...e},filters:t.filters.values};return{...r,sql_snippets:bn(t.sqlSnippets.current,"key","value",r),global_sql_snippets:bn(n.list,"id","content",r)}},get payloadForViz(){const e=x.getParent(t).context.current;return{context:{...t.mock_context.current,...e},filters:t.filters.values}},get dashboardState(){return Is(this.payloadForSQL)},getAdditionalQueryInfo(e){return{content_id:t.id,query_id:e,params:this.dashboardState}},get data(){return t.queries.current.map(({id:n,data:r})=>({id:n,data:r})).reduce((n,r)=>(n[r.id]=r.data,n),{})},getDataStuffByID(e){const n=t.queries.findByID(e);return n?{data:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).actions(t=>({}));function cu({id:t,name:e,dashboard_id:n,create_time:r,update_time:i,content:o},l,c,u){if(!o)throw new Error("unexpected null content when creating a content model");const{version:d,filters:p,views:h,panels:g,layouts:f,definition:{queries:v,sqlSnippets:w,mock_context:T={}}}=o;return $i.create({id:t,name:e,dashboard_id:n,create_time:r,update_time:i,version:d,filters:xi(p,l,T,c),queries:uc(v),sqlSnippets:hc(w),mock_context:Yr(T),views:nc(h,u),panels:{list:g},layouts:{list:f,currentBreakpoint:f[0].id}})}const uu=x.types.model({id:x.types.identifier,name:x.types.string,group:x.types.string,content:$i,content_id:x.types.string,datasources:ec,globalSQLSnippets:li,context:us});function du({id:t,name:e,group:n,content_id:r},i,o,l,c,u,d){return uu.create({id:t,name:e,group:n,content_id:r,content:cu(i,c,u,d),datasources:{list:o},globalSQLSnippets:{list:l},context:ci(c)})}_a(),wa();const sz=({context:t,dashboard:e,content:n,className:r="dashboard",config:i,fullScreenPanelID:o,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h})=>{Ds(i);const{data:g=[]}=W.useRequest(Es),{data:f=[]}=W.useRequest(Ca),v=m.useMemo(()=>du(e,n,g,f,t,c??{},d??null),[e,n,d]);Fc(v.content,!1),m.useEffect(()=>{v.context.replace(t)},[t]),m.useEffect(()=>{v.datasources.replace(g)},[g]),m.useEffect(()=>{v.globalSQLSnippets.replace(f)},[f]),m.useEffect(()=>{u==null||u(v.content.filters.values)},[u,v.content.filters.valuesString]),m.useEffect(()=>{c&&v.content.filters.patchValues(c)},[c,v.content.filters.patchValues]),m.useEffect(()=>{p==null||p(v.content.views.firstVisibleTabsViewActiveTab)},[p,v.content.views.firstVisibleTabsViewActiveTab]),m.useEffect(()=>{d&&v.content.views.setFirstVisibleTabsViewActiveTab(d)},[d,v.content.views.setFirstVisibleTabsViewActiveTab]);const w=W.useCreation(Fr,[]),T=Wc(w);return W.useWhyDidYouUpdate("@devtable/dashboard render",{context:t,dashboard:e,content:n,className:r,config:i,fullScreenPanelID:o,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h}),s.jsx(Gc,{lang:h,children:s.jsx(Fe.ModalsProvider,{children:s.jsx(Ns,{children:s.jsx(Ls,{value:{searchButtonProps:i.searchButtonProps},children:s.jsx($s,{value:v,children:s.jsx(qs,{value:v.content,children:s.jsx(Vs.Provider,{value:{fullScreenPanelID:o,setFullScreenPanelID:l},children:s.jsx(En.Provider,{value:{inEditMode:!1},children:s.jsx(a.Box,{className:`${r} dashboard-root`,children:s.jsx(ut.Provider,{value:w,children:s.jsx(os,{configure:T,children:v.content.views.visibleViews.map(D=>s.jsx(ps,{view:D},D.id))})})})})})})})})})})})},rz=S.observer(sz);I.extend(Nu),I.extend(Gu),I.extend(Fu),I.extend(Wu),I.extend(Qu),I.extend(Ru),I.extend(Uu),I.extend(Yu),I.extend(Ku),I.extend(Ju),I.extend(Hu),I.extend(ed),I.extend(td),I.extend(nd),I.extend(sd),I.extend(Xu),I.extend(Zu),I.extend(rd),I.extend(id),I.extend(ad),I.extend(od),I.extend(ld),I.extend(cd),I.extend(ud),I.extend(dd),I.extend(pd),I.extend(hd),I.extend(md),I.extend(xd),I.extend(gd),I.extend(yd),I.extend(bd),I.extend(fd),I.tz.setDefault("UTC"),I.updateLocale("en",{weekStart:1});const iz=()=>Promise.resolve().then(()=>gp).then(({version:t})=>(console.log(`[@devtable/dashboard] version: ${t}`),t));j.APIClient=ot,j.CURRENT_SCHEMA_VERSION=yt,j.ContentModel=Si,j.ContentModelContextProvider=qs,j.ContentRenderModel=$i,j.ContextMeta=us,j.DEFAULT_CUSTOM_MODAL_TITLE=cs,j.DashboardApiClient=ga,j.DashboardApiFacadeClient=fa,j.DashboardEditor=nz,j.DashboardFilterType=re,j.DashboardMode=Mc,j.DashboardModel=Vc,j.DashboardModelContextProvider=$s,j.DashboardRenderModel=uu,j.DashboardThemeContextProvider=Ls,j.DashboardViewEditor=zc,j.DashboardViewRender=ps,j.DataSourceMetaModel=oi,j.DataSourceType=de,j.DataSourcesMetaModel=ec,j.DatesProvider=Ns,j.DefaultApiClient=xa,j.DescriptionPopover=vi,j.DraftModel=mc,j.EViewComponentType=B,j.FacadeApiClient=Ad,j.FilterCheckboxConfigMeta=Kr,j.FilterDateRangeConfigMeta=Jr,j.FilterMeta=si,j.FilterMultiSelectConfigMeta=Zr,j.FilterSelectConfigMeta=Hr,j.FilterTextInputConfigMeta=ei,j.FilterTreeSelectConfigMeta=ni,j.FiltersModel=Ec,j.FiltersRenderModel=mi,j.FullScreenPanel=Cc,j.FullScreenPanelContext=Vs,j.GlobalSQLSnippetMeta=tc,j.GlobalSQLSnippetsMeta=li,j.LayoutItemMeta=Nl,j.LayoutSetMeta=Gl,j.LayoutStateContext=En,j.LayoutsRenderModel=yi,j.MockContextMeta=Ur,j.MuteQueryModel=cc,j.Panel=wc,j.PanelContextProvider=Os,j.PanelErrorOrStateMessage=_c,j.PanelMeta=Ol,j.PanelModel=Bc,j.PanelRender=ji,j.PanelRenderModel=pi,j.PanelStyleMeta=$l,j.PanelTitleMeta=Bl,j.PanelVizMeta=ql,j.PanelVizSection=_i,j.PanelsModel=Lc,j.PanelsRenderModel=hi,j.QueriesModel=Pc,j.QueriesRenderModel=fi,j.QueryMeta=Vl,j.QueryModel=Ac,j.QueryRenderModel=gi,j.ReadOnlyDashboard=rz,j.SQLSnippetMeta=Fl,j.SQLSnippetRenderModel=pc,j.SQLSnippetsModel=$c,j.SQLSnippetsRenderModel=bi,j.VariableMeta=Ll,j.ViewComponentTypeBackground=Ic,j.ViewComponentTypeColor=wk,j.ViewComponentTypeName=jk,j.ViewDivisionConfig=ri,j.ViewMeta=Hl,j.ViewModalConfig=ii,j.ViewRenderModel=ui,j.ViewTabsConfig=ai,j.ViewsModel=qc,j.ViewsRenderModel=di,j.Viz=vc,j.applyPartialDashboard=Bk,j.configureAPIClient=Ds,j.createContentModel=Oc,j.createContentRenderModel=cu,j.createContextMeta=ci,j.createDashboardModel=Nc,j.createDashboardRenderModel=du,j.createDraft=xc,j.createFilterCheckboxConfig=Wl,j.createFilterDateRangeConfig=Rl,j.createFilterMultiSelectConfig=Ul,j.createFilterSelectConfig=Yl,j.createFilterTextInputConfig=ti,j.createFilterTreeSelectConfig=Kl,j.createViewDivisionConfig=Jl,j.createViewModalConfig=Xl,j.createViewTabsConfig=Zl,j.facadeApiClient=ya,j.formatSQLSnippet=bn,j.getInitialDashboardViewsModel=Ci,j.getInitialFiltersConfig=xi,j.getInitialMockContextMeta=Yr,j.getInitialQueriesRenderModel=uc,j.getInitialSQLSnippetsRenderModel=hc,j.getInitialViewsRenderModel=nc,j.getNewPanel=ic,j.getVersion=iz,j.initialDashboardContent=OS,j.useDashboardContext=Bs,j.useDashboardThemeContext=Ea,j.useEditContentModelContext=Y,j.useEditDashboardContext=Z,j.useEditPanelContext=ze,j.useFullScreenPanelContext=La,j.usePanelFullScreen=Sc,j.useRenderContentModelContext=he,j.useRenderDashboardContext=Ma,j.useRenderPanelContext=mt,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})});
483
+ `)},a2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation();return e.typedAsSQL?r.jsxs(o.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%",height:"28px",lineHeight:"28px"}},keepMounted:!1,children:[r.jsxs(o.Tabs.List,{children:[r.jsx(o.Tabs.Tab,{value:"Edit",children:r.jsx(o.Group,{spacing:14,position:"apart",children:t("query.edit_sql")})}),r.jsx(o.Tabs.Tab,{value:"Preview",children:t("query.preview_sql")}),r.jsx(o.Tabs.Tab,{value:"pre_process",children:t("query.process_request")}),r.jsx(o.Tabs.Tab,{value:"post_process",children:t("query.process_result")}),r.jsx(Pl,{}),e.datasource&&r.jsx(em,{dataSource:e.datasource})]}),r.jsx(o.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:r.jsx(r2,{queryModel:e})}),r.jsx(o.Tabs.Panel,{value:"Preview",p:0,pl:4,children:r.jsx(i2,{value:e.sql})}),r.jsx(o.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:r.jsx(er,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:sm.pre})}),r.jsx(o.Tabs.Panel,{value:"post_process",p:"sm",children:r.jsx(er,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:sm.post})})]}):null}),o2={pre:["function transform(queries, state, utils) {"," // use queries & dashboar state to build new data"," const data = []"," return data","}"].join(`
484
+ `),post:""},l2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),n=Y();return e.isTransform?r.jsxs(o.Stack,{py:20,px:20,sx:{height:"100%"},children:[r.jsx(o.Text,{size:"sm",children:t("query.transform.guide.pick_queries")}),r.jsx(o.MultiSelect,{data:n.queries.optionsWithoutTransform,value:[...e.dep_query_ids],onChange:e.setDependantQueryIDs,maxDropdownHeight:800}),r.jsx(o.Text,{size:"sm",children:t("query.transform.guide.write_function")}),r.jsx(o.Box,{sx:{flexGrow:1},children:r.jsx(er,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:o2.pre})})]}):null}),Yr={height:"calc(100% - 44px)",padding:0},c2=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),n=Y(),s=m.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),[i,a]=m.useState(s);m.useEffect(()=>{a(u=>u!=="Configurations"&&s==="Configurations"?"Configurations":u)},[s]);const l=n.findQueryUsage(e.id),c=l.length===0;return r.jsxs(o.Tabs,{value:i,onTabChange:a,defaultValue:s,orientation:"horizontal",keepMounted:!1,sx:{height:"100vh"},children:[r.jsxs(o.Tabs.List,{grow:!0,children:[r.jsx(o.Tabs.Tab,{value:"Configurations",children:t("query.configurations")}),e.typedAsSQL&&r.jsx(o.Tabs.Tab,{value:"SQL",children:t("query.request")}),e.typedAsHTTP&&r.jsx(o.Tabs.Tab,{value:"HTTP",children:t("query.request")}),e.isTransform&&r.jsx(o.Tabs.Tab,{value:"Transform",children:t("query.transform.label")}),r.jsx(o.Tabs.Tab,{value:"Data",disabled:!e.canPreviewData,children:r.jsx(o.Tooltip,{label:e.guideToPreviewData,disabled:e.canPreviewData,withinPortal:!0,children:r.jsx(o.Text,{children:t("data.preview_data")})})}),r.jsx(o.Tabs.Tab,{value:"Usage",disabled:c,children:r.jsx(o.Tooltip,{label:t("query.usage.unused_description"),disabled:!c,withinPortal:!0,children:r.jsx(o.Text,{children:t("query.usage.label")})})})]}),r.jsx(o.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:r.jsx(KP,{queryModel:e})}),e.typedAsSQL&&r.jsx(o.Tabs.Panel,{value:"SQL",sx:Yr,children:r.jsx(o.Stack,{sx:{height:"100%"},children:r.jsx(a2,{queryModel:e})})}),e.typedAsHTTP&&r.jsx(o.Tabs.Panel,{value:"HTTP",sx:Yr,children:r.jsx(o.Stack,{sx:{height:"100%"},children:r.jsx(HP,{queryModel:e})})}),e.isTransform&&r.jsx(o.Tabs.Panel,{value:"Transform",sx:Yr,children:r.jsx(o.Stack,{sx:{height:"100%"},children:r.jsx(l2,{queryModel:e})})}),r.jsx(o.Tabs.Panel,{value:"Data",sx:{...Yr,overflow:"hidden"},children:r.jsx(Il,{id:e.id,moreActions:null,refreshOnMount:!0})}),r.jsx(o.Tabs.Panel,{value:"Usage",sx:{...Yr,overflow:"hidden"},children:r.jsx(e2,{queryID:e.id,usage:l})})]})}),u2=D.observer(({id:e})=>{const n=Y().queries.findByID(e);return e===""?null:n?r.jsx(c2,{queryModel:n}):r.jsx(o.Text,{size:14,color:"red",children:"Invalid Query ID"})}),d2=D.observer(({value:e})=>{const n=_e().payloadForSQL,s=m.useMemo(()=>Ci(e,n),[e,n]);return r.jsx(Ol,{height:"100%",value:s})}),p2=D.observer(({item:e,remove:t,onKeyChanged:n})=>{const{t:s}=_.useTranslation(),[i,a]=m.useState("SQL"),[l,c]=m.useState(e.key),u=()=>{e.setKey(l),n(l)},d=l!==e.key,p=e.isADuplicatedKey(l),[h,f]=m.useState(e.value),g=()=>{e.setValue(h)};m.useEffect(()=>{c(e.key),f(e.value)},[e]);const y=h!==e.value,j=lt.useModals(),k=()=>{j.openConfirmModal({title:`${s("sql_snippet.delete")}?`,labels:{confirm:s("common.actions.confirm"),cancel:s("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:t,confirmProps:{color:"red"},zIndex:320})};return r.jsxs(o.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[r.jsxs(o.Group,{sx:{alignItems:"end"},spacing:40,children:[r.jsx(o.TextInput,{label:s(p?"sql_snippet.key_occupied":"sql_snippet.key"),value:l,onChange:S=>{c(S.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:r.jsx(o.ActionIcon,{color:"blue",variant:"subtle",onClick:u,disabled:!d||p,children:r.jsx(V.DeviceFloppy,{size:16})}),error:p}),r.jsx(o.Button,{leftIcon:r.jsx(V.Trash,{size:16}),color:"red",variant:"light",onClick:k,children:s("sql_snippet.delete")})]}),r.jsxs(o.Tabs,{value:i,onTabChange:a,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[r.jsxs(o.Tabs.List,{sx:{position:"relative"},children:[r.jsx(o.Tabs.Tab,{value:"SQL",children:s("sql_snippet.edit_snippet")}),r.jsx(o.Tabs.Tab,{value:"Preview",children:s("sql_snippet.preview_snippet")}),r.jsx(Pl,{}),r.jsx(o.ActionIcon,{color:"blue",variant:"filled",onClick:g,disabled:!y,sx:{position:"absolute",top:0,right:10},children:r.jsx(V.DeviceFloppy,{size:18})})]}),r.jsx(o.Tabs.Panel,{value:"SQL",pt:"sm",children:r.jsx(Ol,{height:"100%",value:h,onChange:f,defaultLanguage:"sql",theme:"sql-dark"})}),r.jsx(o.Tabs.Panel,{value:"Preview",pt:"sm",children:r.jsx(d2,{value:h})})]})]})}),h2=D.observer(({id:e})=>{const t=Z(),n=Y(),s=m.useMemo(()=>n.sqlSnippets.findByKey(e),[e]);if(!e)return null;if(!s)return r.jsxs(o.Text,{size:14,children:["SQL Snippet by key[",e,"] is not found"]});const i=()=>{t.editor.setPath(["_SQL_SNIPPETS_",""])},a=()=>{n.sqlSnippets.removeByKey(e),i()},l=c=>{t.editor.setPath(["_SQL_SNIPPETS_",c])};return r.jsx(p2,{item:s,remove:a,onKeyChanged:l})}),f2=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=m.useState([]),s=lt.useModals(),i=Z(),a=f=>{i.editor.setPath(["_SQL_SNIPPETS_",f])},l=()=>{s.openConfirmModal({title:"Delete ununsed SQL snippets?",children:r.jsx(o.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.content.removeUnusedSQLSnippets(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.sqlSnippets.downloadSchema(t)},u=m.useMemo(()=>i.content.sqlSnippets.sortedList.map(f=>f.key),[i.content.sqlSnippets.sortedList]),d=()=>{n(u)},p=()=>{n([])},h=i.content.sqlSnippetsUsage;return r.jsxs(o.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[r.jsx(o.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:e("sql_snippet.manage")})}),r.jsxs(o.Flex,{justify:"space-between",align:"center",px:12,children:[r.jsxs(o.Group,{position:"left",children:[r.jsxs(o.Button.Group,{children:[r.jsx(o.Button,{variant:"default",size:"xs",onClick:d,children:e("common.actions.select_all")}),r.jsx(o.Button,{variant:"default",size:"xs",onClick:p,children:e("common.actions.clear_selection")})]}),r.jsx(o.Button,{size:"xs",color:"blue",leftIcon:r.jsx(M.IconCode,{size:14}),disabled:t.length===0,onClick:c,children:e("common.actions.download_schema")})]}),r.jsx(o.Button,{variant:"subtle",size:"xs",color:"red",leftIcon:r.jsx(M.IconTrash,{size:14}),disabled:!i.content.hasUnusedSQLSnippets,onClick:l,children:e("sql_snippet.delete_unused")})]}),r.jsx(o.Box,{sx:{flexGrow:1,overflow:"auto"},children:r.jsx(o.Checkbox.Group,{size:"xs",value:t,onChange:n,children:r.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{style:{width:"40px"}}),r.jsx("th",{children:e("common.key")}),r.jsx("th",{style:{width:"100px",textAlign:"center"},children:e("sql_snippet.usage.label")}),r.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:e("common.action")})]})}),r.jsx("tbody",{children:i.content.sqlSnippets.sortedList.map(f=>{var y;const g=((y=h[f.key])==null?void 0:y.length)??0;return r.jsxs("tr",{children:[r.jsx("td",{children:r.jsx(o.Checkbox,{value:f.key,styles:{input:{cursor:"pointer"}}})}),r.jsx("td",{children:f.key}),r.jsx("td",{style:{color:g===0?"#ff0000":"#000",fontWeight:g===0?"bold":"normal",textAlign:"center"},children:g}),r.jsx("td",{children:r.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>a(f.key),children:e("common.actions.open")})})]},f.key)})})]})})})]})}),m2=D.observer(({view:e})=>!e||e.type!==q.Division?null:r.jsx(o.Stack,{})),g2=D.observer(({view:e})=>{const{t,i18n:n}=_.useTranslation(),s=m.useMemo(()=>[{value:"default",label:t("common.tabs.variant.default")},{value:"outline",label:t("common.tabs.variant.outline")},{value:"pills",label:t("common.tabs.variant.pills")}],[n.language]),i=m.useMemo(()=>[{value:"horizontal",label:t("common.tabs.orientation.horizontal")},{value:"vertical",label:t("common.tabs.orientation.vertical")}],[n.language]);if(!e||e.type!==q.Tabs)return null;const a=e.config;return r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mt:8,mb:0,label:t("view.component.tabs.tabs_settings"),labelPosition:"center"}),r.jsx(o.Select,{label:t("common.tabs.variant.label"),value:a.variant,onChange:a.setVariant,data:s}),r.jsx(o.Select,{label:t("common.tabs.orientation.label"),value:a.orientation,onChange:a.setOrientation,data:i}),r.jsx(o.Switch,{label:t("common.tabs.grow_tabs"),checked:a.grow,onChange:l=>a.setGrow(l.currentTarget.checked)})]})}),x2=({disabled:e,value:t,onChange:n})=>{const s=i=>{i&&n(i)};return r.jsxs(o.Box,{sx:{position:"relative"},children:[e&&r.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),r.jsx(tt,{height:"500px",defaultLanguage:"javascript",value:t,onChange:s,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},y2=({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),[s,{setTrue:i,setFalse:a}]=W.useBoolean(),[l,c]=m.useState(e??ai),u=g=>{c({...l,enabled:g})},d=()=>{a();const{enabled:g,func_content:y}=l,j={enabled:g,func_content:y};c(j),t(j)},p=()=>{a(),c(e)},h=g=>{c(y=>({...y,func_content:g}))},f=()=>{h(ai.func_content)};return r.jsxs(r.Fragment,{children:[r.jsx(o.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:i,sx:{flexGrow:0},children:r.jsx(V.Settings,{size:14})}),r.jsx(o.Modal,{size:800,title:n("view.component.modal.custom_title"),opened:s,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:s&&r.jsxs(o.Stack,{children:[r.jsx(o.Checkbox,{mt:10,label:n("common.enabled"),checked:l.enabled,onChange:g=>u(g.currentTarget.checked)}),r.jsx(x2,{value:l.func_content,onChange:h,disabled:!l.enabled}),r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Button,{onClick:f,color:"red",leftIcon:r.jsx(V.Recycle,{size:20}),children:n("common.actions.revert")}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:p,variant:"subtle",children:n("common.actions.cancel")}),r.jsx(o.Button,{onClick:d,children:n("common.actions.save")})]})]})]})})]})},b2=D.observer(({view:e})=>{const{t}=_.useTranslation();if(!e||e.type!==q.Modal)return null;const n=e.config,s=n.custom_modal_title.value;return r.jsxs(o.Stack,{children:[r.jsx(o.Divider,{mt:8,label:t("view.component.modal.modal_settings"),labelPosition:"center"}),r.jsxs(o.Flex,{gap:10,children:[r.jsx(o.TextInput,{label:t("view.component.modal.title"),value:s,onChange:v.noop,disabled:!0,sx:{flexGrow:1}}),r.jsx(y2,{value:n.custom_modal_title,onChange:n.custom_modal_title.replace})]}),r.jsxs(o.Group,{grow:!0,children:[r.jsx(o.TextInput,{label:t("view.component.modal.width"),value:n.width,onChange:i=>n.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),r.jsx(o.TextInput,{label:t("view.component.modal.height"),value:n.height,onChange:i=>n.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),v2=D.observer(({view:e})=>r.jsxs(r.Fragment,{children:[r.jsx(m2,{view:e}),r.jsx(b2,{view:e}),r.jsx(g2,{view:e})]})),_2=D.observer(({view:e})=>{const{t,i18n:n}=_.useTranslation(),s=m.useMemo(()=>[{label:t("view.component.div.label"),value:q.Division},{label:t("view.component.modal.label"),value:q.Modal},{label:t("view.component.tabs.label"),value:q.Tabs}],[n.language]);return e?r.jsxs(o.Stack,{sx:{position:"relative"},children:[r.jsx(o.TextInput,{label:t("common.name"),value:e.name,onChange:i=>{e.setName(i.currentTarget.value)}}),r.jsx(o.Select,{label:t("common.type"),withinPortal:!0,zIndex:320,value:e.type,onChange:e.setType,data:s}),r.jsx(v2,{view:e})]}):null}),j2=D.observer(({id:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Z(),i=Y();if(e==="")return null;const a=i.views.findByID(e);if(!a)return r.jsxs(o.Text,{size:14,children:["View by ID[",e,"] is not found"]});const l=()=>{s.editor.setPath(["_VIEWS_",""])},c=()=>{n.openConfirmModal({title:`${t("view.delete")}?`,labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.views.removeByID(e),l()},zIndex:320})};return r.jsxs(o.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[r.jsx(o.Group,{position:"right",pt:10,children:r.jsx(o.Button,{size:"xs",color:"red",leftIcon:r.jsx(V.Trash,{size:16}),onClick:c,children:t("view.delete")})}),r.jsx(o.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:r.jsx(_2,{view:a})})]})});function w2(e){return e.length===1&&e[0]==="_QUERY_VARS_"}function C2(e){return e.length===1&&e[0]==="_MOCK_CONTEXT_"}function S2(e){return e.length===1&&e[0]==="_FILTERS_"}function k2(e){return e.length===2&&e[0]==="_FILTERS_"}function T2(e){return e.length===1&&e[0]==="_SQL_SNIPPETS_"}function D2(e){return e.length===2&&e[0]==="_SQL_SNIPPETS_"}function M2(e){return e.length===2&&e[0]==="_QUERIES_"}function z2(e){return e.length===1&&e[0]==="_QUERIES_"}function I2(e){return e.length===2&&e[0]==="_VIEWS_"}function E2(e){return e.length===4&&e[0]==="_VIEWS_"&&e[2]==="_PANELS_"}const A2=D.observer(()=>r.jsx(o.Stack,{sx:{height:"100%"},p:"sm",children:r.jsx(nm,{})})),P2=D.observer(()=>{const e=Z().editor,t=e.path;return w2(t)?r.jsx(A2,{}):C2(t)?r.jsx(RA,{}):S2(t)?r.jsx(WA,{}):k2(t)?r.jsx(o.Box,{p:"xs",pl:20,children:r.jsx(GA,{id:t[1]})}):T2(t)?r.jsx(f2,{}):D2(t)?r.jsx(h2,{id:t[1]}):z2(t)?r.jsx(DP,{}):M2(t)?r.jsx(u2,{id:t[1]}):I2(t)?r.jsx(o.Box,{p:"xs",pl:20,children:r.jsx(j2,{id:t[1]})}):E2(t)?r.jsx(TP,{viewID:t[1],panelID:t[3]}):r.jsx(o.Box,{children:e.path})}),O2=D.observer(()=>r.jsx(P2,{})),L2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=()=>{const s=new Date().getTime().toString(),i={id:s,key:s,label:s,order:t.content.filters.current.length+1,type:ce.TextInput,config:nl(),visibleInViewsIDs:["Main"],auto_submit:!1};t.content.filters.append(i),t.editor.setPath(["_FILTERS_",s])};return r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("filter.add")})}),B2=D.observer(({parentID:e})=>{const{t}=_.useTranslation(),n=Y();if(!e)return null;const s=n.views.findByID(e);return!s||s.type===q.Tabs?null:r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>n.addANewPanel(s.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("panel.add")})}),q2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=()=>{const s=new Date().getTime().toString(),i={id:s,name:s,type:ye.Postgresql,key:"",sql:""};t.content.queries.append(i),t.editor.setPath(["_QUERIES_",s])};return r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("query.add")})}),V2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=()=>{const s=new Date().getTime().toString(),i={key:s,value:""};t.content.sqlSnippets.append(i),t.editor.setPath(["_SQL_SNIPPETS_",s])};return r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("sql_snippet.add")})}),N2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Y();return r.jsx(o.Button,{variant:"subtle",leftIcon:r.jsx(M.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("view.add")})}),$2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z();return r.jsx(o.Button,{variant:"subtle",rightIcon:r.jsx(M.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_QUERIES_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("query.manage")})}),F2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z();return r.jsx(o.Button,{variant:"subtle",rightIcon:r.jsx(M.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_SQL_SNIPPETS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("sql_snippet.manage")})}),G2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z();return r.jsx(o.Button,{variant:"subtle",rightIcon:r.jsx(M.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>t.editor.setPath(["_FILTERS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:e("filter.manage")})}),W2=D.observer(({action_type:e,parentID:t})=>e==="_Add_A_Filter_"?r.jsx(L2,{}):e==="_Add_A_SQL_SNIPPET_"?r.jsx(V2,{}):e==="_Add_A_QUERY_"?r.jsx(q2,{}):e==="_Add_A_VIEW_"?r.jsx(N2,{}):e==="_Add_A_PANEL_"?r.jsx(B2,{parentID:t}):e==="_QUERIES_SETTINGS_"?r.jsx($2,{}):e==="_SQL_SNIPPETS_SETTINGS_"?r.jsx(F2,{}):e==="_FILTERS_SETTINGS_"?r.jsx(G2,{}):null),im=D.observer(({option:e})=>{var p;const{t}=_.useTranslation(),n=Z().editor,s=n.isOptionActive,i=s(n.path,e),a=n.isOptionOpened,l=n.navigate,c=a(e),[u,d]=m.useState(c);return m.useEffect(()=>{d(c)},[c]),r.jsx(o.NavLink,{active:i,defaultOpened:c,opened:u,onChange:d,label:t(e.label),onClick:()=>l(e),icon:e.Icon?r.jsx(e.Icon,{size:18}):null,children:(p=e.children)==null?void 0:p.map(h=>h._type==="ACTION"?r.jsx(W2,{action_type:h._action_type,parentID:h.parentID},`_ADD_${h.value}_`):r.jsx(im,{option:h},h.value))},e.label)}),R2=D.observer(()=>{const e=Z();return r.jsx(o.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>r.jsx(im,{option:t},t.value))})}),Q2=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z();return r.jsxs(o.Navbar,{p:0,width:{base:220,xs:220,sm:240,md:260,lg:300,xl:320},sx:{height:"100vh - 60px - 60px",".mantine-NavLink-body":{wordWrap:"break-word"}},children:[r.jsx(o.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:r.jsx(o.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:e("common.titles.settings")})}),r.jsx(o.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:r.jsx(R2,{})}),r.jsx(o.Navbar.Section,{children:r.jsx(o.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:r.jsx(o.Button,{size:"xs",color:"red",leftIcon:r.jsx(M.IconX,{size:18}),onClick:()=>t.editor.close(),children:e("common.actions.close")})})})]})}),U2={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden",minWidth:"calc(var(--mantine-navbar-width, 0px) + 1200px)"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},Y2=D.observer(()=>{const e=Z().editor;return r.jsx(o.Modal,{onClose:()=>e.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:e.settings_open,fullScreen:!0,title:null,transitionProps:{duration:0},withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{body:{padding:"0 !important"},content:{overflowY:"hidden !important"}},children:r.jsx(o.AppShell,{padding:0,navbar:r.jsx(Q2,{}),styles:U2,children:r.jsx(O2,{})})})}),K2=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function X2(e){m.useEffect(()=>{if(tt.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const n=K2(e);tt.loader.config({paths:{vs:n}}),tt.loader.init().then(s=>console.log("monaco instance:",s))},[])}wc(),Cc();const J2={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},Z2=({context:e,dashboard:t,content:n,update:s,className:i="dashboard",config:a,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h},f)=>{X2(a.monacoPath),Si(a);const{data:g=[]}=W.useRequest(zi),{data:y=[]}=W.useRequest(Sc),j=m.useMemo(()=>qf(t,n,g,y,e,u??{}),[t,n]);m.useImperativeHandle(f,()=>j,[j]),Nf(j.content,!0),m.useEffect(()=>{j.context.replace(e)},[e]),m.useEffect(()=>{j.datasources.replace(g)},[g]),m.useEffect(()=>{j.globalSQLSnippets.replace(y)},[y]),m.useEffect(()=>{d==null||d(j.content.filters.values)},[d,j.content.filters.values]),m.useEffect(()=>{u&&j.content.filters.patchValues(u)},[u,j.content.filters.patchValues]),m.useEffect(()=>X.reaction(()=>X.toJS(j.json),z=>{l==null||l(z)}),[j]);const k=async()=>{await s(j.json,j.content.json)},S=W.useCreation(Wo,[]),T=$f(S);return W.useWhyDidYouUpdate("@devtable/dashboard editor",{context:e,dashboard:t,content:n,update:s,className:i,config:a,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h}),r.jsx(Vf,{lang:h,children:r.jsx(lt.ModalsProvider,{children:r.jsx(Vi,{children:r.jsx(Oi,{value:{searchButtonProps:a.searchButtonProps},children:r.jsx(Ai,{value:j,children:r.jsx(Li,{value:j.content,children:r.jsx(ls.Provider,{value:{inEditMode:!0},children:r.jsx(Gt.Provider,{value:S,children:r.jsxs(si,{configure:T,children:[r.jsx(o.AppShell,{padding:0,header:r.jsx(eA,{onExit:p,saveDashboardChanges:k,headerSlot:c}),navbar:r.jsx(TA,{}),styles:J2,children:r.jsx(o.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:j.content.views.visibleViews.map(z=>r.jsx(kf,{view:z},z.id))})}),r.jsx(Y2,{})]})})})})})})})})})},H2=D.observer(m.forwardRef(Z2)),qL="",Ll=x.types.model({id:x.types.string,name:x.types.string,dashboard_id:x.types.string,create_time:x.types.string,update_time:x.types.string,version:x.types.string,filters:ml,queries:yl,sqlSnippets:vl,views:pl,panels:fl,layouts:bl,mock_context:Yo}).views(e=>({get json(){return{id:e.id,name:e.name,create_time:e.create_time,update_time:e.update_time,dashboard_id:e.dashboard_id,content:{views:e.views.json,panels:e.panels.json,filters:e.filters.json,version:e.version,layouts:e.layouts.json,definition:{queries:e.queries.json,sqlSnippets:e.sqlSnippets.json,mock_context:e.mock_context.current}}}},get contentJSON(){return this.json.content},get payloadForSQL(){const t=x.getParent(e).context.current,n=x.getParent(e).globalSQLSnippets,s={context:{...e.mock_context.current,...t},filters:e.filters.values};return{...s,sql_snippets:Qr(e.sqlSnippets.current,"key","value",s),global_sql_snippets:Qr(n.list,"id","content",s)}},get payloadForViz(){const t=x.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.values}},get dashboardState(){return Mi(this.payloadForSQL)},getAdditionalQueryInfo(t){return{content_id:e.id,query_id:t,params:this.dashboardState}},get data(){return e.queries.current.map(({id:n,data:s})=>({id:n,data:s})).reduce((n,s)=>(n[s.id]=s.data,n),{})},getDataStuffByID(t){const n=e.queries.findByID(t);return n?{data:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],len:0,state:"idle",error:void 0}}})).actions(e=>({}));function am({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,content:a},l,c,u){if(!a)throw new Error("unexpected null content when creating a content model");const{version:d,filters:p,views:h,panels:f,layouts:g,definition:{queries:y,sqlSnippets:j,mock_context:k={}}}=a;return Ll.create({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,version:d,filters:gl(p,l,k,c),queries:of(y),sqlSnippets:uf(j),mock_context:Ko(k),views:Zh(h,u),panels:{list:f},layouts:{list:g,currentBreakpoint:g[0].id}})}const om=x.types.model({id:x.types.identifier,name:x.types.string,group:x.types.string,content:Ll,content_id:x.types.string,datasources:Xh,globalSQLSnippets:cl,context:oi});function lm({id:e,name:t,group:n,content_id:s},i,a,l,c,u,d){return om.create({id:e,name:t,group:n,content_id:s,content:am(i,c,u,d),datasources:{list:a},globalSQLSnippets:{list:l},context:ul(c)})}wc(),Cc();const eO=({context:e,dashboard:t,content:n,className:s="dashboard",config:i,fullScreenPanelID:a,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h})=>{Si(i);const{data:f=[]}=W.useRequest(zi),{data:g=[]}=W.useRequest(Sc),y=m.useMemo(()=>lm(t,n,f,g,e,c??{},d??null),[t,n,d]);Nf(y.content,!1),m.useEffect(()=>{y.context.replace(e)},[e]),m.useEffect(()=>{y.datasources.replace(f)},[f]),m.useEffect(()=>{y.globalSQLSnippets.replace(g)},[g]),m.useEffect(()=>{u==null||u(y.content.filters.values)},[u,y.content.filters.valuesString]),m.useEffect(()=>{c&&y.content.filters.patchValues(c)},[c,y.content.filters.patchValues]),m.useEffect(()=>{p==null||p(y.content.views.firstVisibleTabsViewActiveTab)},[p,y.content.views.firstVisibleTabsViewActiveTab]),m.useEffect(()=>{d&&y.content.views.setFirstVisibleTabsViewActiveTab(d)},[d,y.content.views.setFirstVisibleTabsViewActiveTab]);const j=W.useCreation(Wo,[]),k=$f(j);return W.useWhyDidYouUpdate("@devtable/dashboard render",{context:e,dashboard:t,content:n,className:s,config:i,fullScreenPanelID:a,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h}),r.jsx(Vf,{lang:h,children:r.jsx(lt.ModalsProvider,{children:r.jsx(Vi,{children:r.jsx(Oi,{value:{searchButtonProps:i.searchButtonProps},children:r.jsx(Ai,{value:y,children:r.jsx(Li,{value:y.content,children:r.jsx(qi.Provider,{value:{fullScreenPanelID:a,setFullScreenPanelID:l},children:r.jsx(ls.Provider,{value:{inEditMode:!1},children:r.jsx(o.Box,{className:`${s} dashboard-root`,children:r.jsx(Gt.Provider,{value:j,children:r.jsx(si,{configure:k,children:y.content.views.visibleViews.map(S=>r.jsx(ci,{view:S},S.id))})})})})})})})})})})})},tO=D.observer(eO);P.extend(Em),P.extend(Am),P.extend(Pm),P.extend(Om),P.extend(Lm),P.extend(Bm),P.extend(qm),P.extend(Vm),P.extend(Nm),P.extend($m),P.extend(Wm),P.extend(Rm),P.extend(Qm),P.extend(Um),P.extend(Ym),P.extend(Fm),P.extend(Gm),P.extend(Km),P.extend(Xm),P.extend(Jm),P.extend(Zm),P.extend(Hm),P.extend(eg),P.extend(tg),P.extend(ng),P.extend(rg),P.extend(sg),P.extend(ig),P.extend(ag),P.extend(og),P.extend(cg),P.extend(ug),P.extend(lg),P.tz.setDefault("UTC"),P.updateLocale("en",{weekStart:1});const nO=()=>Promise.resolve().then(()=>ox).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));w.APIClient=Ot,w.CURRENT_SCHEMA_VERSION=en,w.ContentModel=kl,w.ContentModelContextProvider=Li,w.ContentRenderModel=Ll,w.ContextMeta=oi,w.DEFAULT_CUSTOM_MODAL_TITLE=ai,w.DashboardApiClient=yc,w.DashboardApiFacadeClient=bc,w.DashboardEditor=H2,w.DashboardFilterType=ce,w.DashboardMode=Tf,w.DashboardModel=Bf,w.DashboardModelContextProvider=Ai,w.DashboardRenderModel=om,w.DashboardThemeContextProvider=Oi,w.DashboardViewEditor=kf,w.DashboardViewRender=ci,w.DataSourceMetaModel=ll,w.DataSourceType=ye,w.DataSourcesMetaModel=Xh,w.DatesProvider=Vi,w.DefaultApiClient=xc,w.DescriptionPopover=_l,w.DraftModel=df,w.EViewComponentType=q,w.FacadeApiClient=Cg,w.FilterCheckboxConfigMeta=Xo,w.FilterDateRangeConfigMeta=Jo,w.FilterMeta=sl,w.FilterMultiSelectConfigMeta=Ho,w.FilterSelectConfigMeta=el,w.FilterTextInputConfigMeta=tl,w.FilterTreeSelectConfigMeta=rl,w.FiltersModel=Mf,w.FiltersRenderModel=ml,w.FullScreenPanel=_f,w.FullScreenPanelContext=qi,w.GlobalSQLSnippetMeta=Jh,w.GlobalSQLSnippetsMeta=cl,w.LayoutItemMeta=Bh,w.LayoutSetMeta=qh,w.LayoutStateContext=ls,w.LayoutsRenderModel=bl,w.MockContextMeta=Yo,w.MuteQueryModel=af,w.Panel=vf,w.PanelContextProvider=Bi,w.PanelErrorOrStateMessage=yf,w.PanelMeta=Oh,w.PanelModel=Af,w.PanelRender=wl,w.PanelRenderModel=hl,w.PanelStyleMeta=Ih,w.PanelTitleMeta=Eh,w.PanelVizMeta=Ph,w.PanelVizSection=jl,w.PanelsModel=Pf,w.PanelsRenderModel=fl,w.QueriesModel=If,w.QueriesRenderModel=yl,w.QueryMeta=Lh,w.QueryModel=zf,w.QueryRenderModel=xl,w.ReadOnlyDashboard=tO,w.SQLSnippetMeta=Vh,w.SQLSnippetRenderModel=cf,w.SQLSnippetsModel=Ef,w.SQLSnippetsRenderModel=vl,w.VariableMeta=Ah,w.ViewComponentTypeBackground=Df,w.ViewComponentTypeColor=vE,w.ViewComponentTypeName=bE,w.ViewDivisionConfig=il,w.ViewMeta=Kh,w.ViewModalConfig=al,w.ViewRenderModel=dl,w.ViewTabsConfig=ol,w.ViewsModel=Of,w.ViewsRenderModel=pl,w.Viz=xf,w.applyPartialDashboard=AE,w.configureAPIClient=Si,w.createContentModel=Lf,w.createContentRenderModel=am,w.createContextMeta=ul,w.createDashboardModel=qf,w.createDashboardRenderModel=lm,w.createDraft=pf,w.createFilterCheckboxConfig=Nh,w.createFilterDateRangeConfig=Fh,w.createFilterMultiSelectConfig=Gh,w.createFilterSelectConfig=Wh,w.createFilterTextInputConfig=nl,w.createFilterTreeSelectConfig=Rh,w.createViewDivisionConfig=Qh,w.createViewModalConfig=Uh,w.createViewTabsConfig=Yh,w.facadeApiClient=vc,w.formatSQLSnippet=Qr,w.getInitialDashboardViewsModel=Sl,w.getInitialFiltersConfig=gl,w.getInitialMockContextMeta=Ko,w.getInitialQueriesRenderModel=of,w.getInitialSQLSnippetsRenderModel=uf,w.getInitialViewsRenderModel=Zh,w.getNewPanel=tf,w.getVersion=nO,w.initialDashboardContent=LI,w.useDashboardContext=Pi,w.useDashboardThemeContext=Ac,w.useEditContentModelContext=Y,w.useEditDashboardContext=Z,w.useEditPanelContext=Ge,w.useFullScreenPanelContext=qc,w.usePanelFullScreen=jf,w.useRenderContentModelContext=_e,w.useRenderDashboardContext=Ic,w.useRenderPanelContext=Lt,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});