@devtable/dashboard 13.18.0 → 13.20.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.
- package/dist/components/plugins/common-echarts-fields/number-or-dynamic-value/get-number-or-dynamic-value.d.ts +1 -1
- package/dist/components/plugins/editor-components/field-array-tabs/field-array-tabs.d.ts +1 -4
- package/dist/components/plugins/editor-components/field-array-tabs/tab-list.d.ts +12 -0
- package/dist/components/plugins/editor-components/field-array-tabs/types.d.ts +7 -0
- package/dist/components/plugins/viz-components/calendar-heatmap/migrators/index.d.ts +5 -0
- package/dist/components/plugins/viz-components/calendar-heatmap/option/index.d.ts +56 -1
- package/dist/components/plugins/viz-components/calendar-heatmap/option/series.d.ts +3 -4
- package/dist/components/plugins/viz-components/calendar-heatmap/type.d.ts +3 -4
- package/dist/components/plugins/viz-components/merico-heatmap/migrators/index.d.ts +2 -0
- package/dist/components/plugins/viz-components/merico-heatmap/render/option/series.d.ts +2 -2
- package/dist/components/plugins/viz-components/merico-heatmap/render/option/x-axis.d.ts +2 -2
- package/dist/components/plugins/viz-components/merico-heatmap/render/option/y-axis.d.ts +2 -2
- package/dist/components/plugins/viz-components/merico-heatmap/type.d.ts +2 -3
- package/dist/dashboard.es.js +17117 -14347
- package/dist/dashboard.umd.js +122 -122
- package/dist/i18n/en.d.ts +2 -0
- package/dist/i18n/zh.d.ts +2 -0
- package/dist/stats.html +1 -1
- package/dist/version.json +2 -2
- package/package.json +4 -1
- package/dist/components/plugins/viz-components/calendar-heatmap/option/visual-map.d.ts +0 -10
- package/dist/components/plugins/viz-components/merico-heatmap/render/option/visual-map.d.ts +0 -10
package/dist/dashboard.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(w,g){typeof exports=="object"&&typeof module<"u"?g(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("@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","@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"],g):(w=typeof globalThis<"u"?globalThis:w||self,g(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["@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,g,o,lt,W,X,D,gg,Vl,cr,P,v,mg,Zr,It,he,bn,Nl,Et,en,xg,$l,Fl,Gt,Pe,lO,b,Gl,_,V,tt,M,tn,Hr,yg,bg,Q,Wl,Rl,Ql,Ul,Yl,Kl,Xl,Jl,Zl,Hl,ec,tc,nc,rc,cO,De,vi,vg,Wt,nn,bt,_g,sc,ic,es,m,jg,ts,ac,oc,wg,Cg,Sg,kg,Tg,Dg,Mg,zg,Ig,Eg,Ag,Pg,Og,Lg,Bg,qg,Vg,Ng,$g,Fg,Gg,Wg,Rg,Qg,Ug,Yg,Kg,Xg,Jg,Zg,Hg,em,tm,nm,rm,sm,uO,Ee){"use strict";var aO=Object.defineProperty;var oO=(w,g,o)=>g in w?aO(w,g,{enumerable:!0,configurable:!0,writable:!0,value:o}):w[g]=o;var B=(w,g,o)=>(oO(w,typeof g!="symbol"?g+"":g,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 im=ur(Vl),am=ur(cr),Pn=ur(mg),Ae=ur(Nl),rn=ur(bg);var _i={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
|
|
9
|
+
*/var lc;function om(){if(lc)return dr;lc=1;var e=g,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,x=null;d!==void 0&&(f=""+d),u.key!==void 0&&(f=""+u.key),u.ref!==void 0&&(x=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:x,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
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+K[
|
|
17
|
+
*/var cc;function lm(){return cc||(cc=1,process.env.NODE_ENV!=="production"&&function(){var e=g,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"),x=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===x||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 mt=Object.assign,xt=0,Yr,Dt,Kr,En,An,fi,Xr;function gi(){}gi.__reactDisabledLog=!0;function ar(){{if(xt===0){Yr=console.log,Dt=console.info,Kr=console.warn,En=console.error,An=console.group,fi=console.groupCollapsed,Xr=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 El(){{if(xt--,xt===0){var C={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:mt({},C,{value:Yr}),info:mt({},C,{value:Dt}),warn:mt({},C,{value:Kr}),error:mt({},C,{value:En}),group:mt({},C,{value:An}),groupCollapsed:mt({},C,{value:fi}),groupEnd:mt({},C,{value:Xr})})}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,$t;{var yn=typeof WeakMap=="function"?WeakMap:Map;$t=new yn}function Mt(C,A){if(!C||ot)return"";{var L=$t.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(Ht){G=Ht}Reflect.construct(C,[],J)}else{try{J.call()}catch(Ht){G=Ht}C.call(J.prototype)}}else{try{throw Error()}catch(Ht){G=Ht}C()}}catch(Ht){if(Ht&&G&&typeof Ht.stack=="string"){for(var K=Ht.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"&&$t.set(C,yt),yt}while(ve>=1&&we>=0);break}}}finally{ot=!1,ae.current=oe,El(),Error.prepareStackTrace=ee}var lr=C?C.displayName||C.name:"",fg=lr?be(lr):"";return typeof C=="function"&&$t.set(C,fg),fg}function Ft(C,A,L){return Mt(C,!1)}function zt(C){var A=C.prototype;return!!(A&&A.isReactComponent)}function mi(C,A,L){if(C==null)return"";if(typeof C=="function")return Mt(C,zt(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 Ft(C.render);case h:return mi(C.type,A,L);case f:{var G=C,ee=G._payload,oe=G._init;try{return mi(oe(ee),A,L)}catch{}}}return""}var xi=Object.prototype.hasOwnProperty,ng={},rg=S.ReactDebugCurrentFrame;function yi(C){if(C){var A=C._owner,L=mi(C.type,C._source,A?A.type:null);rg.setExtraStackFrame(L)}else rg.setExtraStackFrame(null)}function N2(C,A,L,G,ee){{var oe=Function.call.bind(xi);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)&&(yi(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),yi(null)),K instanceof Error&&!(K.message in ng)&&(ng[K.message]=!0,yi(ee),T("Failed %s type: %s",L,K.message),yi(null))}}}var $2=Array.isArray;function Al(C){return $2(C)}function F2(C){{var A=typeof Symbol=="function"&&Symbol.toStringTag,L=A&&C[Symbol.toStringTag]||C.constructor.name||"Object";return L}}function G2(C){try{return sg(C),!1}catch{return!0}}function sg(C){return""+C}function ig(C){if(G2(C))return T("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",F2(C)),sg(C)}var Jr=S.ReactCurrentOwner,W2={key:!0,ref:!0,__self:!0,__source:!0},ag,og,Pl;Pl={};function R2(C){if(xi.call(C,"ref")){var A=Object.getOwnPropertyDescriptor(C,"ref").get;if(A&&A.isReactWarning)return!1}return C.ref!==void 0}function Q2(C){if(xi.call(C,"key")){var A=Object.getOwnPropertyDescriptor(C,"key").get;if(A&&A.isReactWarning)return!1}return C.key!==void 0}function U2(C,A){if(typeof C.ref=="string"&&Jr.current&&A&&Jr.current.stateNode!==A){var L=Fe(Jr.current.type);Pl[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(Jr.current.type),C.ref),Pl[L]=!0)}}function Y2(C,A){{var L=function(){ag||(ag=!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 K2(C,A){{var L=function(){og||(og=!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 X2=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 J2(C,A,L,G,ee){{var oe,J={},K=null,We=null;L!==void 0&&(ig(L),K=""+L),Q2(A)&&(ig(A.key),K=""+A.key),R2(A)&&(We=A.ref,U2(A,ee));for(oe in A)xi.call(A,oe)&&!W2.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&&Y2(J,we),We&&K2(J,we)}return X2(C,K,We,ee,G,Jr.current,J)}}var Ol=S.ReactCurrentOwner,lg=S.ReactDebugCurrentFrame;function or(C){if(C){var A=C._owner,L=mi(C.type,C._source,A?A.type:null);lg.setExtraStackFrame(L)}else lg.setExtraStackFrame(null)}var Ll;Ll=!1;function Bl(C){return typeof C=="object"&&C!==null&&C.$$typeof===t}function cg(){{if(Ol.current){var C=Fe(Ol.current.type);if(C)return`
|
|
22
22
|
|
|
23
|
-
Check the render method of \``+C+"`."}return""}}function
|
|
23
|
+
Check the render method of \``+C+"`."}return""}}function Z2(C){{if(C!==void 0){var A=C.fileName.replace(/^.*[\\\/]/,""),L=C.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+
|
|
25
|
+
Check your code at `+A+":"+L+"."}return""}}var ug={};function H2(C){{var A=cg();if(!A){var L=typeof C=="string"?C:C.displayName||C.name;L&&(A=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+
|
|
27
|
+
Check the top-level render call using <`+L+">.")}return A}}function dg(C,A){{if(!C._store||C._store.validated||C.key!=null)return;C._store.validated=!0;var L=H2(A);if(ug[L])return;ug[L]=!0;var G="";C&&C._owner&&C._owner!==Ol.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 pg(C,A){{if(typeof C!="object")return;if(Al(C))for(var L=0;L<C.length;L++){var G=C[L];Bl(G)&&dg(G,A)}else if(Bl(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;)Bl(J.value)&&dg(J.value,A)}}}function eO(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);N2(L,C.props,"prop",G,C)}else if(A.PropTypes!==void 0&&!Ll){Ll=!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 tO(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 hg(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=Z2(ee);We?K+=We:K+=cg();var ve;C===null?ve="null":Al(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=J2(C,A,L,ee,oe);if(we==null)return we;if(J){var yt=A.children;if(yt!==void 0)if(G)if(Al(yt)){for(var lr=0;lr<yt.length;lr++)pg(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 pg(yt,C)}return C===s?tO(we):eO(we),we}}function nO(C,A,L){return hg(C,A,L,!0)}function rO(C,A,L){return hg(C,A,L,!1)}var sO=rO,iO=nO;pr.Fragment=s,pr.jsx=sO,pr.jsxs=iO}()),pr}process.env.NODE_ENV==="production"?_i.exports=om():_i.exports=lm();var r=_i.exports;const At={CryptoJS:Vl,d3Array:am,dayjs:P,lodash:v,numbro:Zr,mathjs:Pn,faker:gg.faker},cm=[{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"}],um=e=>`
|
|
28
28
|
<tr>
|
|
29
|
-
<td><code>${
|
|
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="${
|
|
35
|
-
>${
|
|
34
|
+
href="${e.url}"
|
|
35
|
+
>${e.name}@${e.version}</a
|
|
36
36
|
>
|
|
37
37
|
</td>
|
|
38
38
|
</tr>
|
|
39
|
-
`,
|
|
39
|
+
`,dm=e=>`
|
|
40
40
|
<p>
|
|
41
|
-
${
|
|
41
|
+
${e("function_utils.description")}
|
|
42
42
|
</p>
|
|
43
43
|
<table>
|
|
44
44
|
<thead>
|
|
45
45
|
<tr>
|
|
46
|
-
<th>${
|
|
47
|
-
<th>${
|
|
46
|
+
<th>${e("common.name")}</th>
|
|
47
|
+
<th>${e("function_utils.document")}</th>
|
|
48
48
|
</tr>
|
|
49
49
|
</thead>
|
|
50
50
|
<tbody>
|
|
51
|
-
${
|
|
51
|
+
${cm.map(um).join("")}
|
|
52
52
|
</tbody>
|
|
53
53
|
</table>
|
|
54
|
-
`;function
|
|
55
|
-
`),
|
|
56
|
-
`,"<br/>").split("<br/>");return n.map((i,a)=>{const l=[Fd(i)];return a!==n.length-1&&l.push(s.jsx("br",{},`br-${a}`)),l}).flat().filter(i=>i!==void 0)}function Ms(t){return Wd(t)}function cn(t,e,n){const r=Gd(e,n),i=/^\{(.+)\}(.*)$/;return t.split("$").map((a,l)=>{const c=i.exec(a);if(!c)return Ms(a);const u=r[c[1]];if(!u)return Ms(a);const d=c[2]??"";return s.jsxs(m.Fragment,{children:[u,Ms(d)]},`${a}-${l}`)})}function Qd(t,e){const{data_field:n,aggregation:r}=t,i=Mn(e,n,r);return Ie(t,i)}function ba(t,e){const n={};return t.forEach(r=>{n[r.name]=Qd(r,e)}),n}function un(t,e,n){const r=ba(e,n),i=/^\{(.+)\}(.*)$/;return t.split("$").map(a=>{const l=i.exec(a);if(!l)return a;const c=r[l[1]];if(!c)return a;const u=l[2]??"";return`${c}${u}`}).join("")}const Dt={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 Rd(){Ce.registerTheme("merico-light",{color:Object.values(Dt.graphics.multiple),visualMap:{color:Object.values(Dt.graphics.depth).reverse()},axes:[{type:"all",name:"通用坐标轴",axisLineColor:"#97999D",axisTickColor:"#97999D",axisLabelShow:!0,axisLabelColor:"#818388",splitLineShow:!0,splitLineColor:["#E0E6F1"]}]})}function va(){Rd()}function*Ud(t){const e=Dt.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 _a(){return{filters:{},context:{}}}function Is(t){const e=_a();if(!t)return _a();const{filters:n=e.filters,context:r=e.context}=t;return{filters:n,context:r}}class je extends m.Component{constructor(e){super(e),this.state={error:null}}componentDidCatch(e){this.setState({error:e})}render(){var e;if(this.state.error){const n=()=>{this.setState({error:null})};return s.jsxs(o.Box,{children:[s.jsx(o.Text,{size:"xs",children:(e=this.state.error)==null?void 0:e.message}),s.jsx(o.Button,{variant:"subtle",size:"xs",mx:"auto",compact:!0,sx:{display:"block"},onClick:n,children:"Retry"})]})}return this.props.children}}function Yd(t,e={handleError:!0}){return n=>s.jsx(je,{...e,children:s.jsx(t,{...n})})}function Kd(t,e){return new Function(`return ${t}`)()(e,at)}function Jd(t,e,n){return Kd(t,{context:e,filters:n})}function Xd(t,e){try{return new Function(`return ${t.config.processing.pre}`)()(e,at)}catch(n){return console.error(n),e}}function Zd(t,e){return new Function(`return ${t.config.processing.post}`)()(e,at)}function Hd(t,e,n){return t?new Function(`return ${t}`)()(e,at,n):e}function ja(){Wi.use([Pu.CanvasRenderer,it.BarChart,it.BoxplotChart,it.CustomChart,it.FunnelChart,it.HeatmapChart,it.LineChart,it.PieChart,it.RadarChart,it.ScatterChart,it.SunburstChart,bt.CalendarComponent,bt.DataZoomComponent,bt.GridComponent,bt.LegendComponent,bt.TooltipComponent,bt.MarkLineComponent,bt.MarkAreaComponent,bt.VisualMapComponent])}const Gt=t=>b.cloneDeepWith(t,(e,n)=>{if(n!==void 0&&e)return J.toJS(e)}),In={sqlSnippet:new RegExp("(?<=sql_snippets\\.)([^\\?}.]+)","gm"),context:new RegExp("(?<=context\\.)([^\\?}.]+)","gm"),filter:new RegExp("(?<=filters\\.)([^\\?}.]+)","gm")};function ep(t,e){const n=Qi.decode(e);n!==t&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:t,after:e,v:n}),console.groupEnd())}async function tp({query:t,name:e,payload:n,additionals:r},i){if(!t.sql)return[];const{type:a,key:l,sql:c,pre_process:u,post_process:d}=t,p=ks(c,n),h=Td({sql:p,pre_process:u}),g=Qi.encode(h);ep(h,g);let y=await ot.query(i)({type:a,key:l,query:g,...r},{params:{name:e}});return y=Dd(d,y,Is(n)),y}async function np({type:t,key:e,configString:n,name:r,additionals:i},a){try{return await ot.httpDataSourceQuery(a)({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 wa(){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 Ca{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,a)=>{n(i,a)},{requiresObservable:!0,fireImmediately:b.get(r,"fireImmediately",!1)})}}class sp{constructor(){$(this,"channels",new Map);$(this,"globalChannel",new Ri)}getChannel(e){const n=this.channels.get(e);if(n)return n;const r=new Ri;return this.channels.set(e,r),r}}class rp{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 sp,instanceData:new Ca(e.viz.conf)};return this.instances.set(e.id,r),r}}function Sa(t,e,n,r){return{vizManager:n,locale:"zh",msgChannels:t.messageChannels,instanceData:t.instanceData,pluginData:new Ca({}),colorPalette:{getColor(){return()=>""}},data:e,variables:r}}const ip=t=>{const{panel:e,measure:n,vizManager:r,data:i,variables:a}=t,l=r.resolveComponent(e.viz.type),c=r.getOrCreateInstance(e),u={...Sa(c,i,r,a),viewport:{width:n.w,height:n.h}},d=l.viewRender;return s.jsx(d,{context:u,instance:c,...b.omit(t,["panel","vizManager","data"])})},ap=t=>{const{vizManager:e,panel:n,data:r,variables:i}=t,a=e.resolveComponent(n.viz.type),l=e.getOrCreateInstance(n),c={...Sa(l,r,e,i)},u=a.configRender;return s.jsx(u,{context:c,instance:l,...b.omit(t,["panel","vizManager","data"])})},ka=(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()}},En=t=>{const e=dt.bezier(t);return function(n){return e(n/100).hex()}},op={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:ka(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},lp={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:ka(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},cp={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:En(["#fff7f1","darkred"]),name:"red",category:"sequential"},up={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:En(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},dp={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:En(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},pp={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:En(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class hp{constructor(e){$(this,"symbol");this.symbol=Symbol(e)}}function ht(t){return new hp(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 Ta="13.18.0",mp=Object.freeze(Object.defineProperty({__proto__:null,version:Ta},Symbol.toStringTag,{value:"Module"}));class xp{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 gp{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 fp{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),a=b.orderBy(i,"version","asc");if(((l=b.last(a))==null?void 0:l.version)!==e.to)throw new Error(`Migration to version ${e.to} not found`);return a.reduce((c,u)=>u.handler(c,r),n)}}class ce extends fp{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),a=this.run({from:i,to:this.VERSION},r,{panelModel:n});await e.setItem(null,a)}async needMigration({configData:e}){const n=await e.getItem(null);return b.get(n,"version",0)<this.VERSION}}const q=(t,e)=>{const[n,{setFalse:r}]=G.useBoolean(!0),[i,a]=m.useState();m.useEffect(()=>(t.getItem(e).then(c=>{a(c),r()}),t.watchItem(e,c=>{a(c)})));const l=m.useCallback(async c=>{await t.setItem(e,c),a(c)},[t,e]);return{loading:n,value:i,set:l}},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),dn=(t,e)=>({width:He(t),height:et(e)}),Ae=({width:t,height:e,children:n})=>s.jsx(o.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 yp({context:t}){const{value:e}=q(t.instanceData,"config"),n=t.data,{width:r,height:i}=t.viewport,{x_axis_data_key:a,y_axis_data_key:l,z_axis_data_key:c,xAxis3D:u,yAxis3D:d,zAxis3D:p}=b.defaults({},e,Ps),h=m.useMemo(()=>Dn(n,a),[n,a]),{x:g,y,z:v}=m.useMemo(()=>({x:E(a),y:E(l),z:E(c)}),[a,l,c]),{min:w,max:T}=m.useMemo(()=>{const I=b.minBy(h,N=>N[v.columnKey]),A=b.maxBy(h,N=>N[v.columnKey]);return{min:b.get(I,v.columnKey),max:b.get(A,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(I=>[I[g.columnKey],I[y.columnKey],I[v.columnKey]])}]};return e?s.jsx(Ae,{width:r,height:i,children:s.jsx(Se,{echarts:Ce,option:D,style:dn(r,i),notMerge:!0,theme:"merico-light"})}):null}const Da=m.createContext(null),$s=Da.Provider;function Bs(){const t=m.useContext(Da);if(!t)throw new Error("Please use DashboardModelContextProvider");return t}const Z=()=>Bs(),za=()=>Bs(),Ma=m.createContext({searchButtonProps:{}}),Ls=Ma.Provider;function Ia(){return m.useContext(Ma)}const Ea=m.createContext(null),qs=Ea.Provider;function Aa(){const t=m.useContext(Ea);if(!t)throw new Error("Please use ContentModelContextProvider");return t}const Y=()=>Aa(),he=()=>Aa(),bp={inEditMode:!1},An=m.createContext(bp),Pa=m.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),Os=Pa.Provider;function $a(){const t=m.useContext(Pa);if(!t.panel)throw new Error("Please use PanelContextProvider");return t}const mt=()=>$a(),ze=()=>$a(),vp={fullScreenPanelID:"",setFullScreenPanelID:b.noop},Vs=m.createContext(vp);function Ba(){const t=m.useContext(Vs);if(!t)throw new Error("Please use FullScreenPanelContext.Provider");return t}const _p={en:"en",zh:"zh-cn"};function Ns({children:t}){const{i18n:e}=_.useTranslation(),n=m.useMemo(()=>{const r=e.language;return _p[r]??"en"},[e.language]);return s.jsx(Ui.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:a,clearable:l=!1,sx:c,...u},d)=>{const{panel:p}=ze(),h=m.useMemo(()=>p.dataFieldOptions(r,l,a),[r,l,a]);if(h.length===0){const g=p.explainDataKey(r);return s.jsxs(o.HoverCard,{shadow:"md",position:"bottom-start",withinPortal:!0,zIndex:320,children:[s.jsx(o.HoverCard.Target,{children:s.jsx(o.Box,{children:s.jsx(o.TextInput,{label:t,required:e,defaultValue:g.columnKey,readOnly:!0,disabled:!0})})}),s.jsx(o.HoverCard.Dropdown,{children:s.jsxs(o.Group,{position:"left",spacing:0,children:[s.jsx(o.Text,{size:"xs",color:g.queryName?"black":"red",sx:{fontFamily:"monospace"},children:g.queryName??g.queryID}),s.jsx(o.Text,{size:"xs",color:"black",sx:{fontFamily:"monospace"},children:"."}),s.jsx(o.Text,{size:"xs",color:"red",sx:{fontFamily:"monospace"},children:g.columnKey})]})})]})}return s.jsx(o.Select,{ref:d,label:t,description:n,data:h,value:r,onChange:i,required:e,sx:c,maxDropdownHeight:500,...u})}));function jp({context:t}){const{value:e,set:n}=q(t.instanceData,"config"),r=b.defaults({},e,Ps),{control:i,handleSubmit:a,reset:l}=f.useForm({defaultValues:r});return m.useEffect(()=>{l(r)},[e]),e?s.jsx(o.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:a(n),children:[s.jsx(o.Text,{children:"X Axis"}),s.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(f.Controller,{name:"x_axis_data_key",control:i,render:({field:c})=>s.jsx(O,{label:"Data Field",required:!0,...c})}),s.jsx(f.Controller,{name:"xAxis3D.name",control:i,render:({field:c})=>s.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(o.Text,{mt:"lg",children:"Y Axis"}),s.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(f.Controller,{name:"y_axis_data_key",control:i,render:({field:c})=>s.jsx(O,{label:"Data Field",required:!0,...c})}),s.jsx(f.Controller,{name:"yAxis3D.name",control:i,render:({field:c})=>s.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(o.Text,{mt:"lg",children:"Z Axis"}),s.jsxs(o.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[s.jsx(f.Controller,{name:"z_axis_data_key",control:i,render:({field:c})=>s.jsx(O,{label:"Data Field",required:!0,...c})}),s.jsx(f.Controller,{name:"zAxis3D.name",control:i,render:({field:c})=>s.jsx(o.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...c})})]}),s.jsx(o.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:s.jsxs(o.Button,{color:"blue",type:"submit",children:[s.jsx(L.DeviceFloppy,{size:20}),s.jsx(o.Text,{ml:"md",children:"Save"})]})})]})}):null}const wp=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function Cp(t,{panelModel:e}){try{const n=e.queryIDs[0];if(!n)throw new Error("cannot migrate when queryID is empty");const r=u=>u&&`${n}.${u}`,{x_axis_data_key:i,y_axis_data_key:a,z_axis_data_key:l,...c}=t;return{...c,x_axis_data_key:r(i),y_axis_data_key:r(a),z_axis_data_key:r(l)}}catch(n){throw console.error("[Migration failed]",n),n}}class Sp 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:Cp(i,r)}})}}const kp={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Sp,name:"bar-3d",viewRender:yp,configRender:jp,createConfig(){return{version:2,config:b.cloneDeep(Ps)}},translation:wp},Tp=({disabled:t,value:e,onChange:n})=>{const r=i=>{i&&n(i)};return s.jsxs(o.Box,{sx:{position:"relative"},children:[t&&s.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),s.jsx(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
|
|
58
|
-
max-width: ${
|
|
54
|
+
`;function ji(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 wi(e,t){try{return ji(e,t)}catch(n){return console.error(n),n.message}}function pm({sql:e,pre_process:t}){if(!t.trim())return e;try{return new Function(`return ${t}`)()({sql:e},At)}catch(n){return console.error(n),e}}function hm(e,t,n){if(!e.trim())return t;try{return new Function(`return ${e}`)()(t,At,n)}catch(s){return console.error(s),t}}function fm(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 gm(e,t){let n=fm(e);return n+="&key="+t,im.MD5(n).toString().toUpperCase()}class uc{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:gm({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 It(u).then(d=>l?d:d.data).catch(d=>{if(It.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 mm{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 dc extends uc{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 pc{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 On=new dc;function Ci(e){On.baseURL!==e.apiBaseURL&&(On.baseURL=e.apiBaseURL),e.app_id&&(On.app_id=e.app_id),e.app_secret&&(On.app_secret=e.app_secret),e.makeQueryENV&&(On.makeQueryENV=e.makeQueryENV)}const hc=new pc(On),Pt=hc,hr=g.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 xm(e){return e.includes(".")?O(e):{queryID:"",columnKey:e}}function vt(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 ns(e,t){const{queryID:n}=O(t);return n?e[n]:[]}function ym(e){return Object.values(e)[0]}function rs(e,t){const{queryID:n,columnKey:s}=O(t);return e[s]}const fc=["function aggregation({ queryData }, utils) {",' return "Aggregation Result";',"}"].join(`
|
|
55
|
+
`),Ln={type:"none",config:{},fallback:"0"};function bm(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 vm(e,t){switch(t.type){case"sum":return v.sum(e);case"mean":return v.mean(e);case"median":return bm(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=Pn.std(...e),s=Pn.mean(...e);return s?n/s:Number.NaN;case"std":return Pn.std(...e);default:return e}}function Si(e,t){const n=e.map(Number),s=vm(n,t);return typeof s=="number"?Number.isFinite(s)?s:t.fallback:s??t.fallback}function _m(e,t,n){try{const s=ns(e,t);return new Function(`return ${n.config.func}`)()({queryData:s},At)}catch(s){return console.error(s),s.message}}function jm(e,t,n){try{const s=vt(e,t),{method:i}=n.config;return v[i](s)}catch(s){return console.error(s),n.fallback}}function ss(e,t,n){try{return n.type==="custom"?_m(e,t,n):n.type==="pick_record"?jm(e,t,n):Si(vt(e,t),n)}catch(s){return console.error(s),null}}class wm{constructor({valueRange:t,colorRange:n}){B(this,"mapper");this.mapper=bn.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=Zr(e).value();if(s===void 0||Number.isNaN(s))throw new Error(`[formatNumber]Not a number: ${e}`);return t&&(s=Math.abs(s)),Zr(s).format(n)}catch(s){return console.debug(s),String(e)}}function Cm(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function _t({data_field:e,aggregation:t},n){return ss(n,e,t)}function Re({formatter:e,aggregation:t},n){if(typeof n!="string"&&typeof n!="number")return Cm(n);if(t.type==="custom")return n;try{return U(n,e)}catch(s){return console.error(s),n}}function Sm(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 wm(e).getColor(t)}catch(n){return console.error(n),"black"}return"black"}function km(e,t){const{color:n,data_field:s,aggregation:i,size:a,weight:l}=e,c=ss(t,s,i),u=Re(e,c);return r.jsx(o.Text,{sx:{fontSize:a,display:"inline"},color:Sm(n,c),weight:l,children:u})}function Tm(e,t){const n={};return e.forEach(s=>{const i=s.name;n[i]=km(s,t)}),n}function Dm(e){return e.split(" ").map((t,n)=>r.jsxs(g.Fragment,{children:[t," "]},n))}function Mm(e){const n=e.replaceAll("<br />","<br/>").replaceAll(`
|
|
56
|
+
`,"<br/>").split("<br/>");return n.map((i,a)=>{const l=[Dm(i)];return a!==n.length-1&&l.push(r.jsx("br",{},`br-${a}`)),l}).flat().filter(i=>i!==void 0)}function ki(e){return Mm(e)}function fr(e,t,n){const s=Tm(t,n),i=/^\{(.+)\}(.*)$/;return e.split("$").map((a,l)=>{const c=i.exec(a);if(!c)return ki(a);const u=s[c[1]];if(!u)return ki(a);const d=c[2]??"";return r.jsxs(g.Fragment,{children:[u,ki(d)]},`${a}-${l}`)})}function zm(e,t){const{data_field:n,aggregation:s}=e,i=ss(t,n,s);return Re(e,i)}function gc(e,t){const n={};return e.forEach(s=>{n[s.name]=zm(s,t)}),n}function gr(e,t,n){const s=gc(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 vn={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 Im(){Ae.registerTheme("merico-light",{color:Object.values(vn.graphics.multiple),visualMap:{color:Object.values(vn.graphics.depth).reverse()},axes:[{type:"all",name:"通用坐标轴",axisLineColor:"#97999D",axisTickColor:"#97999D",axisLabelShow:!0,axisLabelColor:"#818388",splitLineShow:!0,splitLineColor:["#E0E6F1"]}]})}function mc(){Im()}function*Em(e){const t=vn.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 xc(){return{filters:{},context:{}}}function Ti(e){const t=xc();if(!e)return xc();const{filters:n=t.filters,context:s=t.context}=e;return{filters:n,context:s}}class ze extends g.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 Am(e,t={handleError:!0}){return n=>r.jsx(ze,{...t,children:r.jsx(e,{...n})})}function Pm(e,t){return new Function(`return ${e}`)()(t,At)}function Om(e,t,n){return Pm(e,{context:t,filters:n})}function Lm(e,t){try{return new Function(`return ${e.config.processing.pre}`)()(t,At)}catch(n){return console.error(n),t}}function Bm(e,t){return new Function(`return ${e.config.processing.post}`)()(t,At)}function qm(e,t,n){return e?new Function(`return ${e}`)()(t,At,n):t}function yc(){Nl.use([xg.CanvasRenderer,Et.BarChart,Et.BoxplotChart,Et.CustomChart,Et.FunnelChart,Et.HeatmapChart,Et.LineChart,Et.PieChart,Et.RadarChart,Et.ScatterChart,Et.SunburstChart,en.CalendarComponent,en.DataZoomComponent,en.GridComponent,en.LegendComponent,en.TooltipComponent,en.MarkLineComponent,en.MarkAreaComponent,en.VisualMapComponent])}const Bn=e=>v.cloneDeepWith(e,(t,n)=>{if(n!==void 0&&t)return X.toJS(t)}),is={sqlSnippet:new RegExp("(?<=sql_snippets\\.)([^\\?}.]+)","gm"),context:new RegExp("(?<=context\\.)([^\\?}.]+)","gm"),filter:new RegExp("(?<=filters\\.)([^\\?}.]+)","gm")};function Vm(e,t){const n=$l.decode(t);n!==e&&(console.error("Inconsistent sql"),console.groupCollapsed("Inconsistent sql"),console.table({before:e,after:t,v:n}),console.groupEnd())}async function Nm({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=ji(c,n),h=pm({sql:p,pre_process:u}),f=$l.encode(h);Vm(h,f);let x=await Pt.query(i)({type:a,key:l,query:f,...s},{params:{name:t}});return x=hm(d,x,Ti(n)),x}async function $m({type:e,key:t,configString:n,name:s,additionals:i},a){try{return await Pt.httpDataSourceQuery(a)({type:e,key:t,query:n,...i},{params:{name:s}})}catch(l){if(It.isCancel(l))throw l;return console.error(l),l}}async function Di(){try{return(await Pt.post()("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}},{})).data}catch(e){return console.error(e),[]}}async function bc(){try{return(await Pt.post()("/sql_snippet/list",{filter:{},sort:[{field:"id",order:"ASC"}],pagination:{page:1,pagesize:1e3}},{})).data}catch(e){return console.error(e),[]}}class vc{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 Fm{constructor(){B(this,"channels",new Map);B(this,"globalChannel",new Fl)}getChannel(t){const n=this.channels.get(t);if(n)return n;const s=new Fl;return this.channels.set(t,s),s}}class Gm{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 Fm,instanceData:new vc(t.viz.conf)};return this.instances.set(t.id,s),s}}function _c(e,t,n,s){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new vc({}),colorPalette:{getColor(){return()=>""}},data:t,variables:s}}const Wm=e=>{const{panel:t,measure:n,vizManager:s,data:i,variables:a}=e,l=s.resolveComponent(t.viz.type),c=s.getOrCreateInstance(t),u={..._c(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"])})},Rm=e=>{const{vizManager:t,panel:n,data:s,variables:i}=e,a=t.resolveComponent(n.viz.type),l=t.getOrCreateInstance(n),c={..._c(l,s,t,i)},u=a.configRender;return r.jsx(u,{context:c,instance:l,...v.omit(e,["panel","vizManager","data"])})},jc=(e,t)=>{const n=Gt.bezier(e),s=Gt.bezier(t);return function(i){return i<50?n(i*2/100).hex():s((i-50)*2/100).hex()}},as=e=>{const t=Gt.bezier(e);return function(n){return t(n/100).hex()}},Qm={type:"interpolation",displayName:"style.color.interpolation.palette.red_green",getColor:jc(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},Um={type:"interpolation",displayName:"style.color.interpolation.palette.yellow_blue",getColor:jc(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},Ym={type:"interpolation",displayName:"style.color.interpolation.palette.red",getColor:as(["#fff7f1","darkred"]),name:"red",category:"sequential"},Km={type:"interpolation",displayName:"style.color.interpolation.palette.green",getColor:as(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},Xm={type:"interpolation",displayName:"style.color.interpolation.palette.blue",getColor:as(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},Jm={type:"interpolation",displayName:"style.color.interpolation.palette.orange",getColor:as(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"};class Zm{constructor(t){B(this,"symbol");this.symbol=Symbol(t)}}function Rt(e){return new Zm(e)}class Mi{constructor(){B(this,"parent");B(this,"factoryRegistry",new Map);B(this,"instanceRegistry",new Map)}createScoped(){const t=new Mi;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 wc="13.20.0",Hm=Object.freeze(Object.defineProperty({__proto__:null,version:wc},Symbol.toStringTag,{value:"Module"}));class ex{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 tx{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 nx{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 me extends nx{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]=g.useState();g.useEffect(()=>(e.getItem(t).then(c=>{a(c),s()}),e.watchItem(t,c=>{a(c)})));const l=g.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},jt=e=>Math.max(0,e-Qe.left-Qe.right),wt=e=>Math.max(0,e-Qe.top-Qe.bottom),mr=(e,t)=>({width:jt(e),height:wt(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}),zi={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 rx({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,zi),h=g.useMemo(()=>ns(n,a),[n,a]),{x:f,y:x,z:y}=g.useMemo(()=>({x:O(a),y:O(l),z:O(c)}),[a,l,c]),{min:j,max:k}=g.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[x.columnKey],T[y.columnKey]])}]};return t?r.jsx(Ue,{width:s,height:i,children:r.jsx(Pe,{echarts:Ae,option:S,style:mr(s,i),notMerge:!0,theme:"merico-light"})}):null}const Cc=g.createContext(null),Ii=Cc.Provider;function Ei(){const e=g.useContext(Cc);if(!e)throw new Error("Please use DashboardModelContextProvider");return e}const Z=()=>Ei(),Sc=()=>Ei(),kc=g.createContext({searchButtonProps:{}}),Ai=kc.Provider;function Tc(){return g.useContext(kc)}const Dc=g.createContext(null),Pi=Dc.Provider;function Mc(){const e=g.useContext(Dc);if(!e)throw new Error("Please use ContentModelContextProvider");return e}const Y=()=>Mc(),_e=()=>Mc(),sx={inEditMode:!1},os=g.createContext(sx),zc=g.createContext({panel:null,data:{},loading:!1,errors:[],downloadPanelScreenshot:()=>{}}),Oi=zc.Provider;function Ic(){const e=g.useContext(zc);if(!e.panel)throw new Error("Please use PanelContextProvider");return e}const Qt=()=>Ic(),Ge=()=>Ic(),ix={fullScreenPanelID:"",setFullScreenPanelID:v.noop},Li=g.createContext(ix);function Ec(){const e=g.useContext(Li);if(!e)throw new Error("Please use FullScreenPanelContext.Provider");return e}const ax={en:"en",zh:"zh-cn"};function Bi({children:e}){const{i18n:t}=_.useTranslation(),n=g.useMemo(()=>{const s=t.language;return ax[s]??"en"},[t.language]);return r.jsx(Gl.DatesProvider,{settings:{locale:n,firstDayOfWeek:1},children:e})}const F=D.observer(g.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=g.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 ox({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=v.defaults({},t,zi),{control:i,handleSubmit:a,reset:l}=b.useForm({defaultValues:s});return g.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 lx=[{lang:"en",resources:{bar_chart_3d:{viz_name:"Bar Chart(3D)"}}},{lang:"zh",resources:{bar_chart_3d:{viz_name:"柱图(3D)"}}}];function cx(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 ux extends me{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:cx(i,s)}})}}const dx={displayName:"viz.bar_chart_3d.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new ux,name:"bar-3d",viewRender:rx,configRender:ox,createConfig(){return{version:2,config:v.cloneDeep(zi)}},translation:lx},px=({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 Ct=g.forwardRef(({value:e,onChange:t,triggerButtonText:n},s)=>{const{t:i}=_.useTranslation(),[a,{setTrue:l,setFalse:c}]=W.useBoolean(),[u,d]=g.useState(e);g.useEffect(()=>{d(e)},[e]);const p=k=>{d({...u,enabled:k})},h=()=>{c();const{enabled:k,func_content:S}=u,T={enabled:k,func_content:S};d(T),t(T)},f=()=>{c(),d(e)},x=k=>{d(S=>({...S,func_content:k}))},y=()=>{x(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(px,{value:u.func_content,onChange:x,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")})]})]})]})})]})}),_n={x_axis_scroll:!1,y_axis_scroll:!1,x_axis_slider:!1,y_axis_slider:!1};function Ac(){return v.cloneDeep(_n)}const hx=[{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:"点击箱体、散点或异常点"}}}}],Pc={id:"builtin:echarts:click-echart:series",displayName:"viz.boxplot.click_series.label",nameRender:gx,configRender:fx,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 fx(e){return r.jsx(r.Fragment,{})}function gx(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.boxplot.click_series.label")})}const ls=g.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=g.useMemo(()=>[{label:i("chart.axis.overflow.truncate"),value:"truncate"},{label:i("chart.axis.overflow.break_line"),value:"break"},{label:i("chart.axis.overflow.break_word"),value:"breakAll"}],[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})]})]})}),St=g.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(ls,{sectionTitle:s("chart.axis.overflow.section_title.on_axis"),value:e.on_axis,onChange:i}),r.jsx(ls,{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: ${
|
|
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:La()};function Mt(t,e){return m.useMemo(()=>{const{queryID:n,columnKey:r}=E(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(a=>a.schemaRef===e))),[]),n};class Ft{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,a)=>{n(i,a)},r):this.root.watchItem(this.path,(i,a)=>{const l=b.get(i,e),c=b.get(a,e);l!==c&&n(l,c)},r)}}const Ip={"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 Ft(e.instanceData,n)}async getInstance(e){if(await this.attachmentStorage.getItem(e))return this.constructInstance(new Ft(this.attachmentStorage,e))}async create(e,n){return await this.attachmentStorage.setItem(e,n),this.constructInstance(new Ft(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=>Ip[r.schemaRef]??10);return Promise.all(n.map(r=>this.constructInstance(new Ft(this.attachmentStorage,r.id))))}}function Ep(t,e){const{value:n,set:r}=q(t.operation.operationData,"config"),[i,a]=m.useState(b.defaults({},n,e)),l=async()=>{await r(i)};return m.useEffect(()=>{a(b.defaults({},n,e))},[n]),{config:i,setConfig:a,commit:l}}function Ap(t){const{t:e}=_.useTranslation(),{config:n,setConfig:r,commit:i}=Ep(t,{urlTemplate:"",openInNewTab:!0});async function a(){await i()}async function l(u){r({...n,openInNewTab:u}),await i()}const c=u=>r({...n,urlTemplate:u.currentTarget.value});return s.jsxs(o.Stack,{children:[s.jsx(o.TextInput,{label:e("interactions.operation.open_link.url"),value:n.urlTemplate,onChange:c,onBlur:a}),s.jsx(o.Switch,{label:e("interactions.operation.open_link.open_in_new_tab"),checked:n.openInNewTab,onChange:u=>l(u.currentTarget.checked)})]})}async function Pp(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 $p extends ce{constructor(){super(...arguments);$(this,"VERSION",1)}configVersions(){this.version(1,n=>n)}}const Bp={displayName:"interactions.operation.open_link.label",id:"builtin:op:open-link",configRender:Ap,run:Pp,migrator:new $p,createDefaultConfig:()=>({version:1,config:{urlTemplate:"",openInNewTab:!0}})};function Lp(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 qp(t){const{t:e}=_.useTranslation(),[n,r]=Lp(t.operation);return s.jsx(o.TextInput,{defaultValue:n,onBlur:i=>r(i.currentTarget.value),label:e("interactions.operation.console_log.log_content")})}async function Op(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 Vp={displayName:"interactions.operation.console_log.label",id:"builtin:op:debug",configRender:qp,run:Op},Np=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 a=(r==null?void 0:r.viewID)||"",l=c=>void i({viewID:c});return s.jsx(o.Select,{defaultValue:a,value:a,onChange:l,label:e("interactions.operation.open_view.view"),data:n.views.options,withinPortal:!0,zIndex:340,maxDropdownHeight:500})});async function Gp(t,e){const r=(await e.operationData.getItem("config")).viewID;window.dispatchEvent(new CustomEvent("open-view",{detail:{viewID:r}}))}const Fp={displayName:"interactions.operation.open_view.label",id:"builtin:op:open_view",configRender:Np,run:Gp},Wp={"tbody tr":{opacity:.5,transition:"opacity 200ms ease"},"tr[data-affected=true]":{opacity:1}},Qp=({value:t="",onChange:e})=>{const[n,r]=m.useState(t);m.useEffect(()=>{r(t)},[t]);const i=()=>{e(n)};return s.jsx(o.TextInput,{size:"xs",label:"",value:n,onChange:a=>r(a.currentTarget.value),sx:{flexGrow:1},rightSection:s.jsx(o.ActionIcon,{color:"green",size:"xs",onClick:i,disabled:n===t,children:s.jsx(k.IconDeviceFloppy,{})})})},Rp={dictionary:{}},Up=S.observer(t=>{const{t:e}=_.useTranslation(),n=Y(),{value:r=Rp,set:i}=q(t.operation.operationData,"config"),{dictionary:a={}}=r;console.log({value:{...r},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 s.jsxs(o.Table,{sx:Wp,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 a;return s.jsxs("tr",{"data-affected":u,children:[s.jsx("td",{children:c.label}),s.jsx("td",{children:s.jsx(Qp,{value:a[c.value],onChange:d=>l(c.value,d)})})]},c.value)})})]})});async function Yp(t,e){const r=(await e.operationData.getItem("config")).dictionary;window.dispatchEvent(new CustomEvent("set-filter-values",{detail:{dictionary:r,payload:t}}))}const Kp={displayName:"interactions.operation.set_filter_values.label",id:"builtin:op:set_filter_values",configRender:Up,run:Yp},Jp={filter_keys:[]},Xp=S.observer(t=>{const{t:e}=_.useTranslation(),n=Y(),{value:r=Jp,set:i}=q(t.operation.operationData,"config"),{filter_keys:a=[]}=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(o.Stack,{spacing:10,children:s.jsx(o.MultiSelect,{label:e("interactions.operation.clear_filter_values.select_filter"),data:c,value:a,onChange:l})})});async function Zp(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 $n=[Vp,Bp,Fp,Kp,{displayName:"interactions.operation.clear_filter_values.label",id:"builtin:op:clear_filter_values",configRender:Xp,run:Zp}];class Hp{constructor(e,n=$n){$(this,"attachments");this.operations=n;const r=async i=>{const{id:a,schemaRef:l}=await i.getItem(null);return{id:a,schemaRef:l,operationData:new Ft(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},a=this.tryGetSchema(r.schemaRef),l=a==null?void 0:a.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},a=this.tryGetSchema(r.schemaRef),l=a==null?void 0:a.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 Oa="__TRIGGERS";class eh{constructor(e,n){$(this,"attachments");this.instance=e,this.component=n;const r=async i=>{const{id:a,schemaRef:l}=await i.getItem(null);return{id:a,schemaRef:l,triggerData:new Ft(i,"data")}};this.attachments=new Fs(e,Oa,r)}watchTriggerSnapshotList(e){return this.instance.instanceData.watchItem(Oa,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 a=await this.attachments.getInstance(e);return!a||r.recreate||a.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))||{}}):a}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),a=i==null?void 0:i.migrator,l={configData:r.triggerData};return a&&await a.needMigration(l)?()=>a.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 Hp(e,r),this.triggerManager=new eh(e,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 Fs(e,"__INTERACTIONS",i)}async addInteraction(e,n){const r=e.id,i=n.id,a=`[${r}]:[${i}]`;await this.attachments.create(a,{id:a,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(a=>a.triggerRef===e);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 Oe=({vizManager:t,instance:e})=>G.useCreation(()=>new Ws(e,t.resolveComponent(e.type),$n),[e,t]),Va=t=>{const{t:e}=_.useTranslation(),{title:n="Variables",variables:r}=t,i=ie.useClipboard(),a=l=>{i.copy(l),vt.showNotification({color:"green",message:e("common.copied")})};return s.jsxs(o.Paper,{withBorder:!0,p:"sm",children:[s.jsx(o.Text,{size:"xs",color:"dimmed",mb:"sm",children:n}),s.jsx(o.Stack,{style:{maxHeight:"500px"},children:r.map(l=>s.jsxs(o.Text,{size:"sm",children:[s.jsxs(o.Code,{color:"teal",children:["// ",l.description]}),s.jsx("br",{}),s.jsxs(o.Code,{onClick:()=>a(l.name),style:{cursor:"pointer"},children:[l.name," : ",l.valueType]})]},l.name))})]})};class th{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(a=>a.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 nh(t){return!!t.operationId}const sh=S.observer(({model:t,onClick:e})=>{var i;const{t:n}=_.useTranslation(),r=(i=t.operationSchema)==null?void 0:i.displayName;return s.jsx(o.Button,{variant:"outline",onClick:e,children:n(r)})}),rh=S.observer(({model:t})=>{const e={operation:t.operation,instance:t.instance,variables:[]};return m.createElement(t.operationSchema.configRender,e)}),ih=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 a(l){await t.changeSchema(r.find(c=>c.id===l))}return s.jsx(o.Select,{label:e("interactions.operation.label"),data:i,onChange:a,value:t.operationSchema.id,withinPortal:!0,zIndex:340})}),ah=S.observer(t=>{const{t:e}=_.useTranslation(),[n,{setTrue:r,setFalse:i}]=G.useBoolean(!1),{operationManager:a,operationId:l,instance:c,variables:u}=t,d=G.useCreation(()=>new th(a,c),[a,c]);return G.useAsyncEffect(async()=>{await d.configOperation(l,u)},[l,d]),nh(d)?s.jsxs(s.Fragment,{children:[s.jsx(sh,{model:d,onClick:r}),s.jsx(o.Modal,{size:600,opened:n,onClose:i,title:e("interactions.operation.setup"),zIndex:320,children:s.jsxs(o.Stack,{children:[s.jsx(ih,{model:d}),s.jsxs(o.Tabs,{defaultValue:"settings",children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"settings",children:e("interactions.operation.settings")}),s.jsx(o.Tabs.Tab,{value:"variables",children:e("interactions.operation.variables")})]}),s.jsx(o.Tabs.Panel,{value:"settings",pt:10,children:s.jsx(rh,{model:d})}),s.jsx(o.Tabs.Panel,{value:"variables",pt:10,children:s.jsx(Va,{title:e("interactions.operation.variables"),variables:d.variables})})]})]})})]}):null});class oh{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(a=>a.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 lh(this)}}function lh(t){return!!t.triggerId&&!!t.triggerSchema}function ch(t,e){return G.useCreation(()=>new oh(t,e),[t,e])}const uh=S.observer(({model:t,onClick:e})=>{const n=t.triggerSchema.nameRender,r={trigger:t.trigger,instance:t.instance,sampleData:t.sampleData};return s.jsx(o.Button,{variant:"outline",onClick:e,children:m.createElement(n,r)})}),dh=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 a(l){await t.changeSchema(r.find(c=>c.id===l))}return s.jsx(o.Select,{label:e("interactions.trigger.label"),data:i,value:t.triggerSchema.id,onChange:a})}),ph=S.observer(({model:t})=>{const e={trigger:t.trigger,instance:t.instance,sampleData:t.sampleData};return m.createElement(t.triggerSchema.configRender,e)}),hh=S.observer(t=>{const{t:e}=_.useTranslation(),[n,{setTrue:r,setFalse:i}]=G.useBoolean(!1),a=t.model;return s.jsxs(s.Fragment,{children:[s.jsx(o.Modal,{opened:n,onClose:i,title:e("interactions.trigger.setup"),zIndex:320,children:s.jsxs(o.Stack,{children:[s.jsx(dh,{model:a}),s.jsx(ph,{model:a}),s.jsx(Va,{title:e("interactions.trigger.payload"),variables:a.triggerSchema.payload})]})}),s.jsx(uh,{onClick:r,model:a})]})});function mh(t,e){const[n,r]=m.useState([]);return G.useAsyncEffect(async()=>{const i=await t.getInteractionList();r(i)},[e,t]),n}const xh=S.observer(({item:t,manager:e,instance:n,sampleData:r,variables:i,onRemove:a})=>{const{triggerRef:l,operationRef:c}=t,u=ch(e.triggerManager,n);if(G.useAsyncEffect(async()=>{await u.configTrigger(l,r)},[u,l,r]),u.isReady()){const d=[...u.triggerSchema.payload,...i];return s.jsxs(o.Group,{children:[s.jsx(hh,{model:u}),s.jsx(ah,{instance:n,operationId:c,variables:d,operationManager:e.operationManager}),s.jsx(o.ActionIcon,{"aria-label":"delete-interaction",variant:"filled",color:"red",onClick:()=>a(t),children:s.jsx(L.Trash,{size:16})})]})}return null}),gh=t=>{const{t:e}=_.useTranslation(),[n,r]=m.useState(0),{interactionManager:i,instance:a,sampleData:l,variables:c}=t,u=mh(i,n),d=async()=>{const y=await i.triggerManager.createOrGetTrigger(ie.randomId(),i.triggerManager.getTriggerSchemaList()[0]),v=await i.operationManager.createOrGetOperation(ie.randomId(),i.operationManager.getOperationSchemaList()[0]);await i.addInteraction(y,v),r(w=>w+1)};async function p(y){await i.removeInteraction(y.id),r(v=>v+1)}const{data:h=0,loading:g}=G.useRequest(async()=>{try{return(await i.triggerManager.getTriggerSchemaList()).length}catch{return 0}});return s.jsxs(o.Stack,{children:[s.jsx(o.LoadingOverlay,{visible:g}),h===0&&s.jsx(o.Alert,{icon:s.jsx(L.AlertCircle,{size:16}),title:e("interactions.unavailable"),color:"gray",children:e("interactions.unavailable_reason")}),u.map(y=>s.jsx(xh,{onRemove:p,instance:a,sampleData:l,variables:c,item:y,manager:t.interactionManager},y.id)),s.jsx(o.Button,{style:{width:"fit-content"},onClick:()=>d(),disabled:h===0,children:e("interactions.add")})]})},fh=()=>{const{panel:t,data:e}=mt(),n=t.viz,{vizManager:r}=m.useContext(ut),i=t.json,a=G.useCreation(()=>r.getOrCreateInstance(i),[r,i]),l=G.useCreation(()=>new Ws(a,r.resolveComponent(n.type),$n),[a,n.type]);return m.useEffect(()=>a.instanceData.watchItem(null,b.throttle(c=>{t.viz.setConf(c)},100,{leading:!1,trailing:!0})),[a]),{instance:a,vizManager:r,interactionManager:l,sampleData:e,variables:[]}},yh=()=>{const t=fh();return s.jsx(gh,{...t})},Na={axisTick:{show:!0,alignWithLabel:!0,lineStyle:{width:2}},axisLine:{show:!0,lineStyle:{width:3}},splitLine:{show:!1},z:3};function bh(t){return b.defaultsDeep({},t,Na)}const vh=Object.freeze(Object.defineProperty({__proto__:null,getXAxis:bh,xAxis:Na},Symbol.toStringTag,{value:"Module"})),Ga={axisTick:{show:!1},axisLine:{show:!1,lineStyle:{width:3}},splitLine:{show:!0,lineStyle:{type:"dashed"}}};function _h(t){return b.defaultsDeep({},t,Ga)}const jh=Object.freeze(Object.defineProperty({__proto__:null,getYAxis:_h,yAxis:Ga},Symbol.toStringTag,{value:"Module"})),Fa={confine:!0,appendToBody:!0};function wh(t){return b.defaultsDeep({},t,Fa)}const te={...vh,...jh,...Object.freeze(Object.defineProperty({__proto__:null,getTooltip:wh,tooltip:Fa},Symbol.toStringTag,{value:"Module"}))};function Ch(t,e){const n=[],r=[];return{boxplotData:Object.entries(t).map(([a,l])=>{const c=l.map(D=>D[e]).sort((D,I)=>D-I),u=sn.quantile(c,.25)??0,d=sn.quantile(c,.5)??0,p=sn.quantile(c,.75)??0,h=p-u,g=u-1.5*h,y=p+1.5*h,v=Math.max(c[0],g),w=Math.min(b.last(c)??0,y);return l.filter(D=>{const I=D[e];return I<v||I>w}).forEach(D=>n.push([a,D[e],D])),l.filter(D=>{const I=D[e];return I>=v&&I<=w}).forEach(D=>r.push([a,D[e],D])),{name:a,min:v,q1:u,median:d,q3:p,max:w}}),outliersData:n,scatterData:r}}function Sh(t,e){const{x_axis:n,y_axis:r}=t;if(!n.data_key||!r.data_key)return[];const i=E(n.data_key),a=E(r.data_key);if(i.queryID!==a.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}=Ch(l,a.columnKey);return[{source:c},{source:u},{source:d}]}function kh(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 Th({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 Dh(t,e,n){const r=e.reduce((i,a)=>{const l=Ze(a,n);return i[a.name]=Ie(a,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 un(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 zh(t,e,n){const{itemStyle:{color:r,borderColor:i,borderWidth:a}}=n,l=Us(e),c=e.value(0),u=t.source[c],{min:d,q1:p,median:h,q3:g,max:y}=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,y])},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]}],I={stroke:i,lineWidth:a};return D.forEach(A=>{T.children.push({type:"line",shape:A,style:I})}),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:a}}),T}function Mh(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,a)=>zh(t,a,r),r}function Ih(t){const e=Us(t),n=e[0].width,r=t.value(0),i=t.value(1),[a,l]=t.coord([r,i]),u=a+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 Eh(){const t={name:"Scatter",type:"custom",itemStyle:{color:"#ED6A45"},emphasis:{scale:2},datasetIndex:2};return t.renderItem=(e,n)=>Ih(n),t}function Ah(t,e){const n=Us(t),r=n[0].width,i=t.value(0),a=t.value(1),[l,c]=t.coord([i,a]),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 Ph(){const t={name:"Outlier",type:"custom",itemStyle:{color:"#ED6A45"},emphasis:{scale:2},datasetIndex:1};return t.renderItem=(e,n)=>Ah(n),t}function $h(t,e){const n=e[0],r=Mh(n,t),i=Eh(),a=Ph();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,a]}const Bh=(t,e)=>{const n=Qs.map(a=>`
|
|
63
|
+
`}function ut(e){return{width:e.width,overflow:e.overflow,ellipsis:e.ellipsis}}const qi={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:Ac()};function jn(e,t){return g.useMemo(()=>{const{queryID:n,columnKey:s}=O(t);return v.keyBy(e[n],s)},[e,t])}const nt=(e,t)=>{const[n,s]=g.useState([]);return g.useEffect(()=>e.watchTriggerSnapshotList(i=>s(i.filter(a=>a.schemaRef===t))),[]),n};class qn{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 mx={"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 Vi{constructor(t,n,s){B(this,"attachmentStorage");this.instance=t,this.attachmentKey=n,this.constructInstance=s,this.attachmentStorage=new qn(t.instanceData,n)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new qn(this.attachmentStorage,t))}async create(t,n){return await this.attachmentStorage.setItem(t,n),this.constructInstance(new qn(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=>mx[s.schemaRef]??10);return Promise.all(n.map(s=>this.constructInstance(new qn(this.attachmentStorage,s.id))))}}function xx(e,t){const{value:n,set:s}=$(e.operation.operationData,"config"),[i,a]=g.useState(v.defaults({},n,t)),l=async()=>{await s(i)};return g.useEffect(()=>{a(v.defaults({},n,t))},[n]),{config:i,setConfig:a,commit:l}}function yx(e){const{t}=_.useTranslation(),{config:n,setConfig:s,commit:i}=xx(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 bx(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 vx extends me{constructor(){super(...arguments);B(this,"VERSION",1)}configVersions(){this.version(1,n=>n)}}const _x={displayName:"interactions.operation.open_link.label",id:"builtin:op:open-link",configRender:yx,run:bx,migrator:new vx,createDefaultConfig:()=>({version:1,config:{urlTemplate:"",openInNewTab:!0}})};function jx(e){const{value:t,set:n}=$(e.operationData,"config"),s=i=>void n({template:i});return[(t==null?void 0:t.template)||"",s]}function wx(e){const{t}=_.useTranslation(),[n,s]=jx(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 Cx(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 Sx={displayName:"interactions.operation.console_log.label",id:"builtin:op:debug",configRender:wx,run:Cx},kx=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 Tx(e,t){const s=(await t.operationData.getItem("config")).viewID;window.dispatchEvent(new CustomEvent("open-view",{detail:{viewID:s}}))}const Dx={displayName:"interactions.operation.open_view.label",id:"builtin:op:open_view",configRender:kx,run:Tx},Mx={"tbody tr":{opacity:.5,transition:"opacity 200ms ease"},"tr[data-affected=true]":{opacity:1}},zx=({value:e="",onChange:t})=>{const[n,s]=g.useState(e);g.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,{})})})},Ix={dictionary:{}},Ex=D.observer(e=>{const{t}=_.useTranslation(),n=Y(),{value:s=Ix,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:Mx,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(zx,{value:a[c.value],onChange:d=>l(c.value,d)})})]},c.value)})})]})});async function Ax(e,t){const s=(await t.operationData.getItem("config")).dictionary;window.dispatchEvent(new CustomEvent("set-filter-values",{detail:{dictionary:s,payload:e}}))}const Px={displayName:"interactions.operation.set_filter_values.label",id:"builtin:op:set_filter_values",configRender:Ex,run:Ax},Ox={filter_keys:[]},Lx=D.observer(e=>{const{t}=_.useTranslation(),n=Y(),{value:s=Ox,set:i}=$(e.operation.operationData,"config"),{filter_keys:a=[]}=s,l=u=>{i({filter_keys:[...u]})},c=g.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 Bx(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 cs=[Sx,_x,Dx,Px,{displayName:"interactions.operation.clear_filter_values.label",id:"builtin:op:clear_filter_values",configRender:Lx,run:Bx}];class qx{constructor(t,n=cs){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 qn(i,"data")}};this.attachments=new Vi(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 Oc="__TRIGGERS";class Vx{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 qn(i,"data")}};this.attachments=new Vi(t,Oc,s)}watchTriggerSnapshotList(t){return this.instance.instanceData.watchItem(Oc,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 Ni{constructor(t,n,s){B(this,"operationManager");B(this,"triggerManager");B(this,"attachments");this.operationManager=new qx(t,s),this.triggerManager=new Vx(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 Vi(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 Ni(t,e.resolveComponent(t.type),cs),[t,e]),Lc=e=>{const{t}=_.useTranslation(),{title:n="Variables",variables:s}=e,i=he.useClipboard(),a=l=>{i.copy(l),tn.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 Nx{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 $x(e){return!!e.operationId}const Fx=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)})}),Gx=D.observer(({model:e})=>{const t={operation:e.operation,instance:e.instance,variables:[]};return g.createElement(e.operationSchema.configRender,t)}),Wx=D.observer(({model:e})=>{const{t,i18n:n}=_.useTranslation(),s=e.schemaList,i=g.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})}),Rx=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 Nx(a,c),[a,c]);return W.useAsyncEffect(async()=>{await d.configOperation(l,u)},[l,d]),$x(d)?r.jsxs(r.Fragment,{children:[r.jsx(Fx,{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(Wx,{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(Gx,{model:d})}),r.jsx(o.Tabs.Panel,{value:"variables",pt:10,children:r.jsx(Lc,{title:t("interactions.operation.variables"),variables:d.variables})})]})]})})]}):null});class Qx{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 Ux(this)}}function Ux(e){return!!e.triggerId&&!!e.triggerSchema}function Yx(e,t){return W.useCreation(()=>new Qx(e,t),[e,t])}const Kx=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:g.createElement(n,s)})}),Xx=D.observer(({model:e})=>{const{t,i18n:n}=_.useTranslation(),s=e.schemaList,i=g.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})}),Jx=D.observer(({model:e})=>{const t={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return g.createElement(e.triggerSchema.configRender,t)}),Zx=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(Xx,{model:a}),r.jsx(Jx,{model:a}),r.jsx(Lc,{title:t("interactions.trigger.payload"),variables:a.triggerSchema.payload})]})}),r.jsx(Kx,{onClick:s,model:a})]})});function Hx(e,t){const[n,s]=g.useState([]);return W.useAsyncEffect(async()=>{const i=await e.getInteractionList();s(i)},[t,e]),n}const ey=D.observer(({item:e,manager:t,instance:n,sampleData:s,variables:i,onRemove:a})=>{const{triggerRef:l,operationRef:c}=e,u=Yx(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(Zx,{model:u}),r.jsx(Rx,{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}),ty=e=>{const{t}=_.useTranslation(),[n,s]=g.useState(0),{interactionManager:i,instance:a,sampleData:l,variables:c}=e,u=Hx(i,n),d=async()=>{const x=await i.triggerManager.createOrGetTrigger(he.randomId(),i.triggerManager.getTriggerSchemaList()[0]),y=await i.operationManager.createOrGetOperation(he.randomId(),i.operationManager.getOperationSchemaList()[0]);await i.addInteraction(x,y),s(j=>j+1)};async function p(x){await i.removeInteraction(x.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(x=>r.jsx(ey,{onRemove:p,instance:a,sampleData:l,variables:c,item:x,manager:e.interactionManager},x.id)),r.jsx(o.Button,{style:{width:"fit-content"},onClick:()=>d(),disabled:h===0,children:t("interactions.add")})]})},ny=()=>{const{panel:e,data:t}=Qt(),n=e.viz,{vizManager:s}=g.useContext(Nt),i=e.json,a=W.useCreation(()=>s.getOrCreateInstance(i),[s,i]),l=W.useCreation(()=>new Ni(a,s.resolveComponent(n.type),cs),[a,n.type]);return g.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:[]}},ry=()=>{const e=ny();return r.jsx(ty,{...e})},Bc={axisTick:{show:!0,alignWithLabel:!0,lineStyle:{width:2}},axisLine:{show:!0,lineStyle:{width:3}},splitLine:{show:!1},z:3};function sy(e){return v.defaultsDeep({},e,Bc)}const iy=Object.freeze(Object.defineProperty({__proto__:null,getXAxis:sy,xAxis:Bc},Symbol.toStringTag,{value:"Module"})),qc={axisTick:{show:!1},axisLine:{show:!1,lineStyle:{width:3}},splitLine:{show:!0,lineStyle:{type:"dashed"}}};function ay(e){return v.defaultsDeep({},e,qc)}const oy=Object.freeze(Object.defineProperty({__proto__:null,getYAxis:ay,yAxis:qc},Symbol.toStringTag,{value:"Module"})),Vc={confine:!0,appendToBody:!0};function ly(e){return v.defaultsDeep({},e,Vc)}const te={...iy,...oy,...Object.freeze(Object.defineProperty({__proto__:null,getTooltip:ly,tooltip:Vc},Symbol.toStringTag,{value:"Module"}))};function cy(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,x=p+1.5*h,y=Math.max(c[0],f),j=Math.min(v.last(c)??0,x);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 uy(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}=cy(l,a.columnKey);return[{source:c},{source:u},{source:d}]}function dy(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 py({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 hy(e,t,n){const s=t.reduce((i,a)=>{const l=_t(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 gr(i.template,t,n)},position:"insideEndTop"}}}))}const $i=["max","q3","median","q1","min"],Fi=[10,40];function Gi(e){return e.barLayout({barMinWidth:Fi[0],barMaxWidth:Fi[1],count:2})}function fy(e,t,n){const{itemStyle:{color:s,borderColor:i,borderWidth:a}}=n,l=Gi(t),c=t.value(0),u=e.source[c],{min:d,q1:p,median:h,q3:f,max:x}=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,x])},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 gy(e,t){const{color:n}=t,s={name:"Box",type:"custom",itemStyle:{color:n,borderColor:"#2F8CC0",borderWidth:2},emphasis:{disabled:!0},boxWidth:Fi,datasetIndex:0};return s.renderItem=(i,a)=>fy(e,a,s),s}function my(e){const t=Gi(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 xy(){const e={name:"Scatter",type:"custom",itemStyle:{color:"#ED6A45"},emphasis:{scale:2},datasetIndex:2};return e.renderItem=(t,n)=>my(n),e}function yy(e,t){const n=Gi(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 by(){const e={name:"Outlier",type:"custom",itemStyle:{color:"#ED6A45"},emphasis:{scale:2},datasetIndex:1};return e.renderItem=(t,n)=>yy(n),e}function vy(e,t){const n=t[0],s=gy(n,e),i=xy(),a=by();return[{name:"Placeholder Box",type:"boxplot",ignore:!0,silent:!0,itemStyle:{color:"none",borderColor:"none",opacity:0},boxWidth:[20,80],datasetIndex:0,encode:{y:$i,x:"name",itemName:["name"],tooltip:$i}},{name:"Outlier",type:"scatter",symbolSize:7,itemStyle:{color:"transparent"},ignore:!0,silent:!0,emphasis:{disabled:!0},datasetIndex:1},s,i,a]}const _y=(e,t)=>{const n=$i.map(a=>`
|
|
64
64
|
<tr>
|
|
65
|
-
<th style="text-align: right; padding: 0 1em;">${
|
|
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(
|
|
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="${
|
|
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
|
-
`},
|
|
78
|
+
`},jy=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Nc(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;">${
|
|
82
|
-
</tr>`})}function
|
|
83
|
-
<th style="text-align: right; padding: 0 1em;">${
|
|
84
|
-
<td style="text-align: left; padding: 0 1em;">${
|
|
81
|
+
<td style="text-align: left; padding: 0 1em;">${jy(t[s.columnKey])}</td>
|
|
82
|
+
</tr>`})}function wy(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=
|
|
86
|
+
`],i=Nc(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}">${
|
|
88
|
+
<div style="${n}">${t[0]}</div>
|
|
89
89
|
</div>
|
|
90
90
|
<table>
|
|
91
91
|
<tbody>
|
|
92
|
-
${
|
|
92
|
+
${s.join("")}
|
|
93
93
|
</tbody>
|
|
94
94
|
</table>
|
|
95
|
-
`}function
|
|
96
|
-
<th style="text-align: right; padding: 0 1em;">${
|
|
97
|
-
<td style="text-align: left; padding: 0 1em;">${
|
|
95
|
+
`}function Cy(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=
|
|
99
|
+
`],i=Nc(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}">${
|
|
101
|
+
<div style="${n}">${t[0]}</div>
|
|
102
102
|
</div>
|
|
103
103
|
<table>
|
|
104
104
|
<tbody>
|
|
105
|
-
${
|
|
105
|
+
${s.join("")}
|
|
106
106
|
</tbody>
|
|
107
107
|
</table>
|
|
108
|
-
`}const Vh=(t,e)=>n=>{const{seriesName:r,value:i}=n;switch(r){case e.Box:return Bh(t,i);case e.Outlier:return qh(t,i);case e.Scatter:return Oh(t,i)}};function Nh({config:t,seriesNames:e}){return te.getTooltip({trigger:"item",formatter:Vh(t,e)})}function Bn(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 Gh({min:t,max:e}){if(t<=110)return Math.min(0,t);if(t<=200)return 100;const n=Ot.floor(Ot.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 Fh(t){return{Box:t("viz.boxplot.box"),Scatter:t("viz.boxplot.scatter"),Outlier:t("viz.boxplot.outlier")}}function Wh({config:t,data:e,variables:n,t:r}){const{x_axis:i,y_axis:a,reference_lines:l}=t,c=Sh(t,e),u=Qe(i.axisLabel.overflow.on_axis),d=Fh(r),p=$h(t,c).map(h=>({...h,name:b.get(d,h.name,h.name)}));return{dataZoom:Bn(t.dataZoom,"filter"),grid:kh(t),dataset:c,legend:Th({config:t,seriesNames:d}),tooltip:Nh({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:a.name,minInterval:1,axisLabel:{formatter:function(h){return U(h,a.label_formatter)}},min:Gh})],series:[...p,...Dh(l,n,e)]}}function Qh({context:t,instance:e}){const{t:n}=_.useTranslation(),{value:r}=q(t.instanceData,"config"),{variables:i}=t,a=t.data,{width:l,height:c}=t.viewport,u=b.defaults({},r,Gs),d=Oe({vizManager:t.vizManager,instance:e}),p=qe(d.triggerManager,qa.id),h=Mt(a,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]),y=m.useMemo(()=>({click:g}),[g]),v=m.useMemo(()=>Wh({config:u,data:a,variables:i,t:n}),[u,a,i,n]);return!r||!l||!c?null:s.jsx(Ae,{width:l,height:c,children:s.jsx(Se,{echarts:Ce,option:v,style:dn(l,c),onEvents:y,notMerge:!0,theme:"merico-light"})})}function Rh({value:t,onChange:e},n){const{t:r}=_.useTranslation(),{colorManager:i}=m.useContext(ut),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===t),[t,a]);return s.jsxs(o.Group,{position:"apart",spacing:4,ref:n,children:[s.jsx(o.TextInput,{placeholder:r("chart.color.set_any_color"),value:l?"":t,onChange:c=>e(c.currentTarget.value),rightSection:s.jsx(o.ColorSwatch,{color:l?"transparent":t,radius:4}),variant:l?"filled":"default",sx:{maxWidth:"46%",flexGrow:1}}),s.jsx(o.Text,{sx:{flexGrow:0},size:"xs",children:r("chart.color.or")}),s.jsx(o.Select,{data:a,value:t,onChange:e,variant:l?"default":"filled",placeholder:r("chart.color.pick_a_theme_color"),icon:s.jsx(o.ColorSwatch,{color:l?t:"transparent",radius:4}),sx:{maxWidth:"46%",flexGrow:1}})]})}const Te=m.forwardRef(Rh);function ge({canSubmit:t}){const{t:e}=_.useTranslation();return s.jsxs(o.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[s.jsx(o.Text,{children:e("viz.viz_config_banner")}),s.jsx(o.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!t,children:s.jsx(k.IconDeviceFloppy,{size:20})})]})}const Ln=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},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 s.jsx(o.Select,{ref:i,label:t??a("common.align.horizontal.label"),data:c,value:e,onChange:n,sx:r})}),Qa=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},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 s.jsx(o.Select,{ref:i,label:t??a("common.align.vertical.label"),data:c,value:e,onChange:n,sx:r})}),Ra=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)"}}}})),Uh=[{from:0,to:0},{from:100,to:100}];class Yh{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(Uh):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 Ua(t){if(typeof t=="number")return String(t)}function Kh(t){const{t:e}=_.useTranslation(),{onChange:n,color:r,index:i,value:a}=t,{classes:l}=Ra(),[c,u]=m.useState(Ua(a)),[d,{setTrue:p,setFalse:h}]=G.useBoolean(!1),g=i%2===1,y=g&&a!=null,v=!g&&a!=null,w=`map ${a} to color ${i}`,T=()=>{u(Ua(a)),h()},D=()=>{h(),n==null||n(Number(c))},I=()=>{h(),n==null||n(null)},A=U(a??null,{output:"number",mantissa:10,trimMantissa:!0,average:!0,absolute:!1}),N=!c||Number.isNaN(Number(c));return s.jsxs("div",{"data-testid":`palette-item-${i}`,className:l.paletteItem,children:[s.jsx(o.Text,{title:w,style:{opacity:y?1:0},color:"dimmed",size:"sm",className:"palette-value--up palette-value",children:A}),s.jsxs(o.Popover,{width:240,trapFocus:!0,opened:d,onClose:h,zIndex:340,withinPortal:!0,children:[s.jsx(o.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(o.Popover.Dropdown,{children:[s.jsx(o.Tooltip,{withinPortal:!0,zIndex:340,label:e("common.actions.close"),children:s.jsx(o.CloseButton,{"data-testid":"palette-item-cancel",size:"sm",color:"gray",onClick:T,style:{position:"absolute",top:"0.5em",right:"0.8em"}})}),s.jsxs(o.Stack,{children:[s.jsx(o.TextInput,{size:"xs",label:e("style.color.interpolation.palette.mapping.value_input_label"),value:c,onChange:R=>{const F=R.currentTarget.value;u(F)},error:c&&N}),s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Button,{variant:"light",color:"red",size:"xs",onClick:I,leftIcon:s.jsx(k.IconTrash,{size:16}),children:e("common.actions.delete")}),s.jsx(o.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),"data-testid":"palette-item-ok",size:"xs",onClick:D,disabled:N,children:e("common.actions.save")})]})]})]})]}),s.jsx(o.Text,{title:w,style:{opacity:v?1:0},color:"dimmed",size:"sm",className:"palette-value--bottom palette-value",children:A})]})}const Jh=S.observer(({model:t})=>{const{classes:e}=Ra(),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],a)=>s.jsx(Kh,{index:a,color:r,value:t.getStepFromValue(i),onChange:l=>t.changeStep(l,i)},r))})}),Xh=S.observer(function(e){const n=G.useCreation(()=>new Yh,[]);return m.useEffect(()=>{n.fromProps(e)}),n.interpolation==null?null:s.jsx(Jh,{model:n})}),Zh=t=>{const{t:e,i18n:n}=_.useTranslation(),{value:r,onChange:i,colorManager:a}=t,l=a.getColorInterpolations(),[c,u]=m.useState(r),d=a.decodeInterpolation(c.interpolation)||l[0],[p,{setTrue:h,setFalse:g}]=G.useBoolean(),y=m.useMemo(()=>l.map(I=>({label:e(I.displayName),value:a.encodeColor(I),group:e(`style.color.interpolation.palette.category.${I.category}`)})),[n.language]);function v(I){I&&u(A=>({...A,interpolation:I}))}const w=()=>{g(),i==null||i(J.toJS(c))};function T(I){u(A=>({...A,steps:I}))}const D=()=>{g(),u(r)};return s.jsxs(s.Fragment,{children:[s.jsx(o.Button,{variant:"outline",onClick:h,children:e(d==null?void 0:d.displayName)}),s.jsx(o.Modal,{size:508,title:e("style.color.interpolation.setup"),opened:p,onClose:g,zIndex:320,children:p&&s.jsxs(o.Stack,{"data-testid":"color-interpolation-modal",children:[s.jsx(o.Select,{label:e("style.color.interpolation.palette.label"),value:c.interpolation,data:y,onChange:v,withinPortal:!0,zIndex:340,maxDropdownHeight:500}),s.jsx(Xh,{steps:c.steps,interpolation:d,onChange:T}),s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Button,{onClick:D,variant:"subtle",children:e("common.actions.cancel")}),s.jsx(o.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),onClick:w,children:e("common.actions.save")})]})]})})]})},Hh=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},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 s.jsx(o.Select,{ref:i,label:t??a("style.color.type.label"),data:c,value:e,onChange:n,sx:r})}),em=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},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 s.jsx(o.Select,{ref:i,label:t??a("style.flex.justify_content.label"),data:c,value:e,onChange:n,sx:r})}),tm=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},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 s.jsx(o.Select,{ref:i,label:t??a("style.flex.align_items.label"),data:c,value:e,onChange:n,sx:r})}),nm={tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px"}},ae=({control:t,watch:e,name:n,getItem:r,children:i,addButtonText:a,deleteButtonText:l,renderTabName:c,deleteDisalbed:u})=>{const{fields:d,append:p,remove:h}=f.useFieldArray({control:t,name:n}),g=e(n),y=d.map((w,T)=>({...w,...g[T]})),v=()=>{p(r())};return s.jsxs(o.Tabs,{defaultValue:"0",styles:nm,children:[s.jsxs(o.Tabs.List,{children:[y.map((w,T)=>s.jsx(o.Tabs.Tab,{value:T.toString(),children:c(w,T)},w.id)),s.jsx(o.Tabs.Tab,{onClick:v,value:"add",children:s.jsx(o.Tooltip,{label:a,children:s.jsx(o.Center,{children:s.jsx(k.IconPlus,{size:18,color:"#228be6"})})})})]}),y.map((w,T)=>s.jsx(o.Tabs.Panel,{value:T.toString(),children:s.jsxs(o.Stack,{children:[i({field:w,index:T}),s.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed"}),s.jsx(o.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:y}),children:l})]})},w.id))]})},qn=m.forwardRef(({value:t,onChange:e},n)=>{const{t:r}=_.useTranslation(),i=a=>l=>{e({...t,[a]:l})};return s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{variant:"dashed",label:r("chart.zooming.scroll.label"),labelPosition:"center"}),s.jsxs(o.Group,{children:[s.jsx(o.Box,{sx:{flexGrow:1},children:s.jsx(o.Switch,{label:r("chart.zooming.scroll.x_axis"),checked:t.x_axis_scroll,onChange:a=>i("x_axis_scroll")(a.currentTarget.checked)})}),s.jsx(o.Box,{sx:{flexGrow:1},children:s.jsx(o.Switch,{label:r("chart.zooming.scroll.y_axis"),checked:t.y_axis_scroll,onChange:a=>i("y_axis_scroll")(a.currentTarget.checked)})})]}),s.jsx(o.Divider,{variant:"dashed",label:r("chart.zooming.slider.label"),labelPosition:"center"}),s.jsxs(o.Group,{children:[s.jsx(o.Box,{sx:{flexGrow:1},children:s.jsx(o.Switch,{label:r("chart.zooming.slider.x_axis"),checked:t.x_axis_slider,onChange:a=>i("x_axis_slider")(a.currentTarget.checked)})}),s.jsx(o.Tooltip,{label:r("chart.zooming.slider.y_axis_disabled"),children:s.jsx(o.Box,{sx:{flexGrow:1},children:s.jsx(o.Switch,{label:r("chart.zooming.slider.y_axis"),disabled:!t.y_axis_slider,checked:t.y_axis_slider,onChange:a=>i("y_axis_slider")(a.currentTarget.checked)})})})]})]})}),wt=m.forwardRef(({label:t,value:e,onChange:n,sx:r={},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 s.jsx(o.Select,{ref:a,label:t??l("chart.orientation.label"),data:u,value:e,onChange:n,sx:r,disabled:i})}),sm=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=e("legend"),i=(a,l)=>{const c={...r,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 s.jsxs(o.Stack,{children:[s.jsx(o.Group,{grow:!0,noWrap:!0,mt:20,children:s.jsx(f.Controller,{name:"legend.show",control:t,render:({field:a})=>s.jsx(o.Switch,{label:n("chart.legend.show_legend"),sx:{flex:1},checked:a.value,onChange:l=>a.onChange(l.currentTarget.checked)})})}),s.jsx(o.Group,{children:s.jsx(f.Controller,{name:"legend",control:t,render:({field:a})=>s.jsx(wt,{sx:{flex:1},value:a.value.orient,onChange:l=>{i(l,a.onChange)},disabled:!r.show})})})]})};function rm({control:t,index:e,variableOptions:n}){const{t:r}=_.useTranslation();return s.jsxs(o.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`reference_lines.${e}.name`,control:t,render:({field:i})=>s.jsx(o.TextInput,{label:r("common.name"),placeholder:r("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...i})}),s.jsx(f.Controller,{name:`reference_lines.${e}.variable_key`,control:t,render:({field:i})=>s.jsx(o.Select,{label:r("common.value"),required:!0,data:n,sx:{flex:1},...i})})]}),s.jsx(f.Controller,{name:`reference_lines.${e}.template`,control:t,render:({field:i})=>s.jsx(o.TextInput,{label:r("chart.content_template.label"),placeholder:r("chart.content_template.placeholder"),required:!0,sx:{flex:1},...i})})]})}function im({control:t,watch:e,variables:n}){const{t:r}=_.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 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(rm,{control:t,index:u,variableOptions:a})})}const am=({control:t,index:e})=>{const{t:n}=_.useTranslation();return s.jsx(o.Stack,{children:s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`tooltip.metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(f.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})})]})})},om=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(o.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:a,index:l})=>s.jsx(am,{control:t,index:l})})]})};function lm({control:t,watch:e}){return s.jsx(o.Stack,{children:s.jsx(om,{control:t,watch:e})})}const xt=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},i)=>{const{t:a}=_.useTranslation();return s.jsx(o.NumberInput,{ref:i,label:t??a("chart.rotate"),hideControls:!0,min:-90,max:90,rightSection:s.jsx(o.Text,{size:"xs",color:"dimmed",children:a("chart.degree")}),sx:r,styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},value:e,onChange:n})}),cm=({control:t,watch:e})=>{const{t:n}=_.useTranslation();return e(["x_axis"]),s.jsxs(o.Stack,{children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"x_axis.name",control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("chart.x_axis.x_axis_name"),sx:{flex:1},...r})}),s.jsx(f.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(o.Divider,{mb:-15,label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:r})=>s.jsx(xt,{sx:{width:"48%"},...r})}),s.jsx(f.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:r})=>s.jsx(tt,{...r})})]}),s.jsx(f.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"}},um=["123456789","1234","1234.56789","1.234","0.123456789","-0.123456789"];function dm({format:t}){const{t:e}=_.useTranslation(),[n,{toggle:r}]=ie.useDisclosure(!1);return s.jsxs(o.Box,{children:[s.jsx(o.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(o.Collapse,{in:n,children:n&&s.jsxs(o.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:um.map(i=>s.jsxs("tr",{children:[s.jsx("td",{children:i}),s.jsx("td",{children:s.jsx(je,{children:U(i,t)})})]},i))})]})})]})}function pm({value:t,onChange:e},n){const{t:r}=_.useTranslation(),i=d=>{e({...t,output:d})},a=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(o.Stack,{ref:n,children:[s.jsxs(o.Group,{grow:!0,children:[s.jsx(o.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(o.Switch,{label:s.jsxs(o.Stack,{spacing:0,children:[s.jsx(o.Text,{children:r("numbro.format.absolute")}),s.jsx(o.Text,{size:12,color:"gray",children:r("numbro.format.absolute_description")})]}),checked:t.absolute,onChange:u,sx:{flexGrow:1},styles:Ys}),s.jsx(o.Switch,{label:s.jsxs(o.Stack,{spacing:0,children:[s.jsx(o.Text,{children:r("numbro.format.abbreviation")}),s.jsx(o.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(o.Group,{grow:!0,children:[s.jsx(o.NumberInput,{label:r("numbro.format.mantissa"),defaultValue:0,min:0,step:1,max:4,value:t.mantissa,onChange:a}),s.jsx(o.Switch,{label:s.jsxs(o.Stack,{spacing:0,children:[s.jsx(o.Text,{children:r("numbro.format.trim_mantissa")}),s.jsx(o.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(o.Box,{})]}),s.jsx(dm,{format:t})]})}const Re=m.forwardRef(pm),hm=({control:t,watch:e})=>{const{t:n}=_.useTranslation();return e(["y_axis"]),s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"y_axis.name",control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("chart.y_axis.y_axis_name"),sx:{flex:1},...r})}),s.jsx(f.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(o.Stack,{children:[s.jsx(o.Divider,{mt:10,mb:-15,variant:"dashed",label:n("chart.axis.section_title.label_format"),labelPosition:"center"}),s.jsx(f.Controller,{name:"y_axis.label_formatter",control:t,render:({field:r})=>s.jsx(Re,{...r})})]})]})};function mm({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),{variables:i}=t,a=m.useMemo(()=>b.defaults({},n,Gs),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=f.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]),u(["x_axis","y_axis","reference_lines","color","dataZoom"]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,n),[h,n]);return s.jsx(o.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:c(r),children:[s.jsx(ge,{canSubmit:g}),s.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"X Axis",children:e("chart.x_axis.label")}),s.jsx(o.Tabs.Tab,{value:"Y Axis",children:e("chart.y_axis.label")}),s.jsx(o.Tabs.Tab,{value:"Legend",children:e("chart.legend.label")}),s.jsx(o.Tabs.Tab,{value:"Tooltip",children:e("chart.tooltip.label")}),s.jsx(o.Tabs.Tab,{value:"Style",children:e("chart.style.label")}),s.jsx(o.Tabs.Tab,{value:"Reference Lines",children:e("chart.reference_line.labels")}),s.jsx(o.Tabs.Tab,{value:"Zooming",children:e("chart.zooming.label")})]}),s.jsx(o.Tabs.Panel,{value:"X Axis",children:s.jsx(cm,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Y Axis",children:s.jsx(hm,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Legend",children:s.jsx(sm,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Tooltip",children:s.jsx(lm,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Style",children:s.jsxs(o.Stack,{spacing:4,children:[s.jsx(o.Text,{size:"sm",children:e("chart.color.label")}),s.jsx(f.Controller,{name:"color",control:l,render:({field:y})=>s.jsx(Te,{...y})})]})}),s.jsx(o.Tabs.Panel,{value:"Reference Lines",children:s.jsx(im,{variables:i,control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Zooming",children:s.jsx(f.Controller,{name:"dataZoom",control:l,render:({field:y})=>s.jsx(qn,{...y})})})]})]})})}function xm(t){return b.omit(t,"variables")}function gm(t){const{label_formatter:e=_e,...n}=t.y_axis;return{...t,y_axis:{...n,label_formatter:e}}}function fm(t){const e={rotate:0,formatter:ke()},{axisLabel:n=e,...r}=t.x_axis;return{...t,x_axis:{...r,axisLabel:n}}}function ym(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 bm(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 vm(t){const e={tooltip:{metrics:[]}};return b.defaultsDeep(e,t)}function _m(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:a,tooltip:l,...c}=t;return{...c,x_axis:{...i,data_key:r(i.data_key)},y_axis:{...a,data_key:r(a.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 jm(t){const e={legend:{show:!0,top:"0",right:"10",left:"auto",bottom:"auto",orient:"horizontal",type:"scroll"}};return b.defaultsDeep(e,t)}function wm(t){const{dataZoom:e,...n}=t;return{...n,dataZoom:e??La()}}class Cm 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:xm(i)}}),this.version(3,n=>{const{config:r}=n;return{...n,version:3,config:gm(r)}}),this.version(4,n=>{const{config:r}=n;return{...n,version:4,config:fm(r)}}),this.version(5,n=>{const{config:r}=n;return{...n,version:5,config:ym(r)}}),this.version(6,n=>{const{config:r}=n;return{...n,version:6,config:bm(r)}}),this.version(7,n=>{const{config:r}=n;return{...n,version:7,config:vm(r)}}),this.version(8,(n,r)=>{const{config:i}=n;return{...n,version:8,config:_m(i,r)}}),this.version(9,n=>{const{config:r}=n;return{...n,version:9,config:jm(r)}}),this.version(10,n=>{const{config:r}=n;return{...n,version:10,config:wm(r)}})}}const Sm={displayName:"viz.boxplot.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new Cm,name:"boxplot",viewRender:Qh,configRender:mm,createConfig(){return{version:10,config:b.cloneDeep(Gs)}},triggers:[qa],translation:Dp},Ya={id:"builtin:button:click-button",displayName:"viz.button.click.label",nameRender:Tm,configRender:km,payload:[]};function km(t){return s.jsx(s.Fragment,{})}function Tm(t){const{t:e}=_.useTranslation();return s.jsx(o.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"},Dm={left:"flex-start",center:"center",right:"flex-end"},zm={top:"flex-start",center:"center",bottom:"flex-end"},Mm=S.observer(({context:t,instance:e})=>{const n=Oe({vizManager:t.vizManager,instance:e}),r=qe(n.triggerManager,Ya.id),i=he(),{value:a}=q(t.instanceData,"config"),l=m.useMemo(()=>b.defaultsDeep({},a,Ks),[a]),{content:c,horizontal_align:u,vertical_align:d,...p}=l,{width:h,height:g}=t.viewport,y=i.payloadForSQL,v=()=>{r.forEach(w=>{n.runInteraction(w.id,{})})};return s.jsx(o.Center,{sx:{width:h,height:g,justifyContent:Dm[u],alignItems:zm[d]},children:s.jsx(o.Button,{...p,onClick:v,children:b.template(c)(y)})})}),Im=({value:t,onChange:e,label:n})=>{const r=o.useMantineTheme(),i=m.useCallback(l=>()=>e(l),[e]),a=l=>t===l;return s.jsxs(o.Stack,{spacing:2,children:[s.jsx(o.Text,{size:14,sx:{fontWeight:500},children:n}),s.jsx(o.Group,{position:"left",spacing:"xs",children:Object.keys(r.colors).map(l=>{const c=r.colors[l][6];return s.jsx(o.ColorSwatch,{color:c,onClick:i(l),radius:4,size:26,sx:{cursor:"pointer"},children:a(l)&&s.jsx(o.CheckIcon,{width:10,color:"white"})},l)})})]})},Js=m.forwardRef(({label:t,value:e,onChange:n,sx:r,disabled:i},a)=>{const{t:l}=_.useTranslation(),c=m.useMemo(()=>o.MANTINE_SIZES.map(u=>({label:l(`style.size.${u}`),value:u})),[]);return s.jsx(o.Select,{ref:a,data:c,label:t,value:e,onChange:n,sx:r,disabled:!0})}),Em=[{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 Am({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:a,handleSubmit:l,watch:c,getValues:u,reset:d}=f.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(o.Stack,{children:[s.jsx(f.Controller,{control:a,name:"content",render:({field:g})=>s.jsx(o.TextInput,{label:"Content Template",description:"Filter values & context entries are supported",...g,required:!0})}),s.jsx(o.Divider,{mt:"xs",mb:0,label:"Styles",labelPosition:"center",variant:"dashed"}),s.jsxs(o.SimpleGrid,{cols:2,children:[s.jsx(f.Controller,{control:a,name:"variant",render:({field:g})=>s.jsx(o.Select,{label:"Variant",data:Em,...g})}),s.jsx(f.Controller,{control:a,name:"color",render:({field:g})=>s.jsx(Im,{label:"Theme",...g})})]}),s.jsxs(o.SimpleGrid,{cols:2,children:[s.jsx(f.Controller,{control:a,name:"size",render:({field:g})=>s.jsx(Js,{label:"Size",...g})}),s.jsx(f.Controller,{control:a,name:"compact",render:({field:g})=>s.jsx(o.Checkbox,{label:"Compact",checked:g.value,onChange:y=>g.onChange(y.currentTarget.checked),mt:26})})]}),s.jsxs(o.SimpleGrid,{cols:2,children:[s.jsx(f.Controller,{control:a,name:"horizontal_align",render:({field:g})=>s.jsx(Ln,{...g})}),s.jsx(f.Controller,{control:a,name:"vertical_align",render:({field:g})=>s.jsx(Qa,{...g})})]})]})]})}const Pm=[{lang:"en",resources:{button:{viz_name:"Button",click:{label:"Click this button"}}}},{lang:"zh",resources:{button:{viz_name:"按钮",click:{label:"点击此按钮"}}}}];class $m 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",...a}=n.config;return{...n,version:2,config:{...a,horizontal_align:r,vertical_align:i}}})}}const Bm={displayName:"viz.button.viz_name",displayGroup:"chart.groups.others",migrator:new $m,name:"button",viewRender:Mm,configRender:Am,createConfig(){return{version:2,config:b.cloneDeep(Ks)}},triggers:[Ya],translation:Pm},Xs={id:"builtin:echarts:click-echart:series",displayName:"viz.cartesian_chart.click_series.label",nameRender:qm,configRender:Lm,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 Lm(t){return s.jsx(s.Fragment,{})}function qm(t){const{t:e}=_.useTranslation();return s.jsx(o.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:zt};function Om(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 Vm(t){return t!=="line"?{}:{itemStyle:{opacity:0}}}function Nm(t){switch(t){case"line":return;case"bar":return"roundRect";case"scatter":return"circle"}}function Gm(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:Nm(r),...Vm(r)})),e}function On(t,e){switch(t.config.method){case"linear":return[...jt.regressionLinear()(e)];case"exponential":return[...jt.regressionExp()(e)];case"logistic":return[...jt.regressionLog()(e)];case"polynomial":return[...jt.regressionPoly().order(t.config.order)(e)];default:return[]}}function Fm(t,e,n,r){const{transform:i,plot:a}=t,l={...a,name:e,data:On(i,r),showSymbol:!1,tooltip:{show:!1},smooth:!1,custom:{}};return n&&(l.custom={type:"regression-line",targetSeries:n}),l}function Wm({regressions:t=[],x_axis_data_key:e},n){const r=[];if(Object.keys(n).length===0)return r;function i(a,l,c,u){const d=Fm(a,l,c,u);r.push(d)}return t.forEach(a=>{const{name:l,group_by_key:c}=a;if(!c||c===e){const h=Xe(n,a.y_axis_data_key).map((g,y)=>[y,Number(g)]);i(a,l,"",h);return}const{columnKey:u}=E(a.y_axis_data_key),d=b.groupBy(Dn(n,a.y_axis_data_key),c);Object.entries(d).forEach(([p,h])=>{const g=h.map((v,w)=>[w,Number(v[u])]);i(a,p,p,g)})}),r}function Qm(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 Rm(t,e,n,r){return e?r==="value"?[[n[0],t]]:[t]:[]}function Um(t,e,n,r,i,a){return t.map(l=>{const c=n[l.variable_key],u=l.orientation==="horizontal",d=u?"yAxis":"xAxis",p=u?"insideEndTop":"end",h=Rm(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?un(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 Ym(t,e,n,r){const i=Hs(e,n,r);return b.unionBy(i,t,0)}function Km({dataTemplate:t,data:e,x_axis_data_key:n,y_axis_data_key:r,valueTypedXAxis:i}){return i?Ym(t,e,n,r):Xe(e,r)}function Jm({dataTemplate:t,data:e,aggregation_on_value:n,x_axis_data_key:r,y_axis_data_key:i,valueTypedXAxis:a}){if(!n||n.type==="none")return Km({dataTemplate:t,data:e,x_axis_data_key:r,y_axis_data_key:i,valueTypedXAxis:a});const l=Hs(e,r,i),c=b.groupBy(l,"0");return t.map(([d])=>{const h=c[d].map(y=>y[1]),g=zs(h,n);return[d,g]})}function Xm({group_by_key:t,data:e,x_axis_data_key:n,y_axis_data_key:r}){const{queryID:i,columnKey:a}=E(t),l=b.groupBy(e[i],a);return Object.entries(l).forEach(([c,u])=>{l[c]=Hs({[i]:u},n,r)}),l}function Zm({type:t,...e},n,r,i){if(!t)return 10;if(t==="static"){const{size:d}=e;return d}const{func_content:a}=e,{queryID:l,columnKey:c}=E(r),u=b.keyBy(Dn(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:b,interpolate:Tt.interpolate})}catch(g){return console.error(`[getEchartsSymbolSize] failed parsing custom function, error: ${g.message}`),10}}}function Hm({x_axis_data_key:t,x_axis:e},{y_axis_data_key:n,yAxisIndex:r,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:g,...y},v,w,T,D){const I=e.type!=="category",A={label:{show:!!i,position:i,formatter:D[r??"default"]},name:a,xAxisId:"main-x-axis",yAxisIndex:r,stack:u,color:d,symbolSize:Zm(h,w,t,T),hide_in_legend:g,labelLayout:{hideOverlap:!0},...y};if(y.type==="line"&&(A.lineStyle={shadowColor:"rgba(255,255,255,1)",shadowBlur:0,shadowOffsetX:0,shadowOffsetY:3}),p&&(A.endLabel={show:!0,formatter:a,offset:[-12,12],align:"right"}),!l||l===t)return A.data=Jm({dataTemplate:v,data:w,aggregation_on_value:c,x_axis_data_key:t,y_axis_data_key:n,valueTypedXAxis:I}),A;const N=Xm({group_by_key:l,data:w,x_axis_data_key:t,y_axis_data_key:n});return Object.entries(N).map(([R,F])=>{const Q=b.cloneDeep(A);return Q.name=R,Q.color=void 0,Q.data=F,Q})}function ex(t,e,n,r,i,a){const l=e.map(u=>[u,0]);return t.series.map(u=>Hm(t,u,l,n,a,r)).flat().concat(Um(t.reference_lines,i,a,n,e,t.x_axis.type)).concat(Qm(t.reference_areas,a))}function tx(t,e){const n=t.find(a=>a.axisDim==="x"&&a.axisId==="main-x-axis");if(!n)return"";const{axisValue:r,axisIndex:i}=n;return Pe(e.x_axis.axisLabel.formatter)(r,i)}const nx=t=>U(t,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function sx(t,e,n,r){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:g,value:y})=>{if(Array.isArray(y)&&y.length===2&&(y=y[1]),!h)return y;const v=i[h],w=r[v]??r.default;return`
|
|
108
|
+
`}const Sy=(e,t)=>n=>{const{seriesName:s,value:i}=n;switch(s){case t.Box:return _y(e,i);case t.Outlier:return wy(e,i);case t.Scatter:return Cy(e,i)}};function ky({config:e,seriesNames:t}){return te.getTooltip({trigger:"item",formatter:Sy(e,t)})}function us(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 Ty({min:e,max:t}){if(e<=110)return Math.min(0,e);if(e<=200)return 100;const n=Pn.floor(Pn.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 Dy(e){return{Box:e("viz.boxplot.box"),Scatter:e("viz.boxplot.scatter"),Outlier:e("viz.boxplot.outlier")}}function My({config:e,data:t,variables:n,t:s}){const{x_axis:i,y_axis:a,reference_lines:l}=e,c=uy(e,t),u=ut(i.axisLabel.overflow.on_axis),d=Dy(s),p=vy(e,c).map(h=>({...h,name:v.get(d,h.name,h.name)}));return{dataZoom:us(e.dataZoom,"filter"),grid:dy(e),dataset:c,legend:py({config:e,seriesNames:d}),tooltip:ky({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:Ty})],series:[...p,...hy(l,n,t)]}}function zy({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,qi),d=rt({vizManager:e.vizManager,instance:t}),p=nt(d.triggerManager,Pc.id),h=jn(a,u.x_axis.data_key),f=g.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]),x=g.useMemo(()=>({click:f}),[f]),y=g.useMemo(()=>My({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:mr(l,c),onEvents:x,notMerge:!0,theme:"merico-light"})})}function Iy({value:e,onChange:t},n){const{t:s}=_.useTranslation(),{colorManager:i}=g.useContext(Nt),a=g.useMemo(()=>i.getStaticColors().map(u=>({label:u.name,group:u.category,value:u.value})),[i]),l=g.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=g.forwardRef(Iy);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 ds=g.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=g.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})}),$c=g.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=g.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})}),Fc=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)"}}}})),Ey=[{from:0,to:0},{from:100,to:100}];class Ay{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(Ey):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 Gc(e){if(typeof e=="number")return String(e)}function Py(e){const{t}=_.useTranslation(),{onChange:n,color:s,index:i,value:a}=e,{classes:l}=Fc(),[c,u]=g.useState(Gc(a)),[d,{setTrue:p,setFalse:h}]=W.useBoolean(!1),f=i%2===1,x=f&&a!=null,y=!f&&a!=null,j=`map ${a} to color ${i}`,k=()=>{u(Gc(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:x?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":Gt(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 Oy=D.observer(({model:e})=>{const{classes:t}=Fc(),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(Py,{index:a,color:s,value:e.getStepFromValue(i),onChange:l=>e.changeStep(l,i)},s))})}),Ly=D.observer(function(t){const n=W.useCreation(()=>new Ay,[]);return g.useEffect(()=>{n.fromProps(t)}),n.interpolation==null?null:r.jsx(Oy,{model:n})}),By=e=>{const{t,i18n:n}=_.useTranslation(),{value:s,onChange:i,colorManager:a}=e,l=a.getColorInterpolations(),[c,u]=g.useState(s),d=a.decodeInterpolation(c.interpolation)||l[0],[p,{setTrue:h,setFalse:f}]=W.useBoolean(),x=g.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:x,onChange:y,withinPortal:!0,zIndex:340,maxDropdownHeight:500}),r.jsx(Ly,{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=g.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=g.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})}),Vy=g.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=g.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})}),Ny=g.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=g.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 $y=Symbol.for("preact-signals");function ps(){if(sn>1)sn--;else{for(var e,t=!1;xr!==void 0;){var n=xr;for(xr=void 0,Wi++;n!==void 0;){var s=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&Rc(n))try{n.c()}catch(i){t||(e=i,t=!0)}n=s}}if(Wi=0,sn--,t)throw e}}function Ut(e){if(sn>0)return e();sn++;try{return e()}finally{ps()}}var ne=void 0;function Vn(e){var t=ne;ne=void 0;try{return e()}finally{ne=t}}var xr=void 0,sn=0,Wi=0,hs=0;function Wc(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=$y,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=Wc(this);return e!==void 0&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(Wi>100)throw new Error("Cycle detected");this.v=e,this.i++,hs++,sn++;try{for(var t=this.t;t!==void 0;t=t.x)t.t.N()}finally{ps()}}}});function fs(e){return new Be(e)}function Rc(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 Qc(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 Uc(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 Nn(e){Be.call(this,void 0),this.x=e,this.s=void 0,this.g=hs-1,this.f=4}(Nn.prototype=new Be).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===hs))return!0;if(this.g=hs,this.f|=1,this.i>0&&!Rc(this))return this.f&=-2,!0;var e=ne;try{Qc(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,Uc(this),this.f&=-2,!0},Nn.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)},Nn.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)}},Nn.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(Nn.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var e=Wc(this);if(this.h(),e!==void 0&&(e.i=this.i),16&this.f)throw this.v;return this.v}});function Yc(e){return new Nn(e)}function Kc(e){var t=e.u;if(e.u=void 0,typeof t=="function"){sn++;var n=ne;ne=void 0;try{t()}catch(s){throw e.f&=-2,e.f|=8,Ri(e),s}finally{ne=n,ps()}}}function Ri(e){for(var t=e.s;t!==void 0;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,Kc(e)}function Fy(e){if(ne!==this)throw new Error("Out-of-order effect");Uc(this),ne=e,this.f&=-2,8&this.f&&Ri(this),ps()}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,Kc(this),Qc(this),sn++;var e=ne;return ne=this,Fy.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||Ri(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 Yc(()=>{const s=e();return s&&n&&t(n,s)?n:(n=s,s)})}return Yc(e)}function Qi(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)=>!Qi(s,t[i]));try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}function de({get:e},t){return{init(n){return fs(n)},get(){return e.call(this).value},set(n){const s=e.call(this);s.peek()!==n&&(s.value=n)}}}function ms(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 Gy(...e){const t=e.map(Xe);return()=>t.forEach(n=>n())}var Wy=Object.create,Ui=Object.defineProperty,Ry=Object.getOwnPropertyDescriptor,Xc=Object.getOwnPropertySymbols,Qy=Object.prototype.hasOwnProperty,Uy=Object.prototype.propertyIsEnumerable,Jc=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),$n=e=>{throw TypeError(e)},Zc=Math.pow,Yi=(e,t,n)=>t in e?Ui(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Yy=(e,t)=>{for(var n in t||(t={}))Qy.call(t,n)&&Yi(e,n,t[n]);if(Xc)for(var n of Xc(t))Uy.call(t,n)&&Yi(e,n,t[n]);return e},Hc=(e,t)=>Ui(e,"name",{value:t,configurable:!0}),Ky=e=>{var t;return[,,,Wy((t=e==null?void 0:e[Jc("metadata")])!=null?t:null)]},eu=["class","method","getter","setter","accessor","field","value","get","set"],br=e=>e!==void 0&&typeof e!="function"?$n("Function expected"):e,Xy=(e,t,n,s,i)=>({kind:eu[e],name:t,metadata:s,addInitializer:a=>n._?$n("Already initialized"):i.push(br(a||null))}),tu=(e,t)=>Yi(t,Jc("metadata"),e[3]),wn=(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),x=!!(t&16),y=h>3?e.length+1:h?f?1:2:0,j=eu[h+5],k=h>3&&(e[y-1]=[]),S=e[y]||(e[y]=[]),T=h&&(!x&&!f&&(i=i.prototype),h<5&&(h>3||!x)&&Ry(h<4?i:{get[n](){return nu(this,a)},set[n](I){return ru(this,a,I)}},n));h?x&&h<4&&Hc(a,(h>2?"set ":h>1?"get ":"")+n):Hc(i,n);for(var z=s.length-1;z>=0;z--)d=Xy(h,n,u={},e[3],S),h&&(d.static=f,d.private=x,p=d.access={has:x?I=>Jy(i,I):I=>n in I},h^3&&(p.get=x?I=>(h^1?nu:Zy)(I,i,h^4?a:T.get):I=>I[n]),h>2&&(p.set=x?(I,E)=>ru(I,i,E,h^4?a:T.set):(I,E)=>I[n]=E)),c=(0,s[z])(h?h<4?x?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?x?a=c:T[j]=c:i=c):typeof c!="object"||c===null?$n("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||tu(e,i),T&&Ui(i,n,T),x?h^4?a:T:i},Ki=(e,t,n)=>t.has(e)||$n("Cannot "+n),Jy=(e,t)=>Object(t)!==t?$n('Cannot use the "in" operator on this value'):e.has(t),nu=(e,t,n)=>(Ki(e,t,"read from private field"),n?n.call(e):t.get(e)),Xi=(e,t,n)=>t.has(e)?$n("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ru=(e,t,n,s)=>(Ki(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),Zy=(e,t,n)=>(Ki(e,t,"access private method"),n),Yt=class ql{constructor(t,n){this.x=t,this.y=n}static delta(t,n){return new ql(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 ql(t,n)}},Hy=class bi{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 bi(i+t,s+n,a,l);return u.scale=Yy({},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 Yt((t+s)/2,(n+i)/2)}get area(){const{width:t,height:n}=this;return t*n}equals(t){if(!(t instanceof bi))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 bi?eb(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 eb(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 su=10,iu,au,ou,lu,cu,Je,Ji,Zi,Hi;cu=[de],lu=[de],ou=[de],au=[ms],iu=[ms];var Fn=class{constructor(e){wn(Je,5,this),Xi(this,Ji,wn(Je,8,this)),wn(Je,11,this),Xi(this,Zi,wn(Je,12,this)),wn(Je,15,this),Xi(this,Hi,wn(Je,16,this)),wn(Je,19,this);const t=Yt.from(e);this.initial=t,this.current=t,this.previous=t}get delta(){return Yt.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=Yt.from(e);Ut(()=>{this.current=t,this.previous=t,this.initial=t})}update(e){const{current:t}=this,n=Yt.from(e);if(Yt.equals(t,n))return;const s={x:n.x-t.x,y:n.y-t.y};(Math.abs(s.x)<su||Math.abs(s.y)<su)&&(this.previous=t),this.current=n}};Je=Ky(null),Ji=new WeakMap,Zi=new WeakMap,Hi=new WeakMap,vr(Je,4,"initial",cu,Fn,Ji),vr(Je,4,"previous",lu,Fn,Zi),vr(Je,4,"current",ou,Fn,Hi),vr(Je,2,"delta",au,Fn),vr(Je,2,"direction",iu,Fn),tu(Je,Fn);function ea({x:e,y:t},n){const s=Math.abs(e),i=Math.abs(t);return typeof n=="number"?Math.sqrt(Zc(s,2)+Zc(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 uu=(e=>(e.Horizontal="x",e.Vertical="y",e))(uu||{}),du=Object.values(uu),tb=Object.create,ta=Object.defineProperty,nb=Object.getOwnPropertyDescriptor,pu=Object.getOwnPropertySymbols,rb=Object.prototype.hasOwnProperty,sb=Object.prototype.propertyIsEnumerable,hu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Gn=e=>{throw TypeError(e)},ib=(e,t,n)=>t in e?ta(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,fu=(e,t)=>ta(e,"name",{value:t,configurable:!0}),gu=(e,t)=>{var n={};for(var s in e)rb.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&pu)for(var s of pu(e))t.indexOf(s)<0&&sb.call(e,s)&&(n[s]=e[s]);return n},xs=e=>{var t;return[,,,tb((t=e==null?void 0:e[hu("metadata")])!=null?t:null)]},mu=["class","method","getter","setter","accessor","field","value","get","set"],_r=e=>e!==void 0&&typeof e!="function"?Gn("Function expected"):e,ab=(e,t,n,s,i)=>({kind:mu[e],name:t,metadata:s,addInitializer:a=>n._?Gn("Already initialized"):i.push(_r(a||null))}),jr=(e,t)=>ib(t,hu("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),x=!!(t&16),y=h>3?e.length+1:h?f?1:2:0,j=mu[h+5],k=h>3&&(e[y-1]=[]),S=e[y]||(e[y]=[]),T=h&&(!x&&!f&&(i=i.prototype),h<5&&(h>3||!x)&&nb(h<4?i:{get[n](){return ys(this,a)},set[n](I){return ra(this,a,I)}},n));h?x&&h<4&&fu(a,(h>2?"set ":h>1?"get ":"")+n):fu(i,n);for(var z=s.length-1;z>=0;z--)d=ab(h,n,u={},e[3],S),h&&(d.static=f,d.private=x,p=d.access={has:x?I=>ob(i,I):I=>n in I},h^3&&(p.get=x?I=>(h^1?ys:lb)(I,i,h^4?a:T.get):I=>I[n]),h>2&&(p.set=x?(I,E)=>ra(I,i,E,h^4?a:T.set):(I,E)=>I[n]=E)),c=(0,s[z])(h?h<4?x?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?x?a=c:T[j]=c:i=c):typeof c!="object"||c===null?Gn("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&&ta(i,n,T),x?h^4?a:T:i},na=(e,t,n)=>t.has(e)||Gn("Cannot "+n),ob=(e,t)=>Object(t)!==t?Gn('Cannot use the "in" operator on this value'):e.has(t),ys=(e,t,n)=>(na(e,t,"read from private field"),n?n.call(e):t.get(e)),st=(e,t,n)=>t.has(e)?Gn("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,n),ra=(e,t,n,s)=>(na(e,t,"write to private field"),s?s.call(e,n):t.set(e,n),n),lb=(e,t,n)=>(na(e,t,"access private method"),n);function xu(e,t){return{plugin:e,options:t}}function cb(e){return t=>xu(e,t)}function yu(e){return typeof e=="function"?{plugin:e,options:void 0}:e}var bu,wr,sa;bu=[de];var dt=class{constructor(t,n){this.manager=t,this.options=n,st(this,sa,le(wr,8,this,!1)),le(wr,11,this)}enable(){this.disabled=!1}disable(){this.disabled=!0}isDisabled(){return Vn(()=>this.disabled)}configure(t){this.options=t}destroy(){}static configure(t){return xu(this,t)}};wr=xs(null),sa=new WeakMap,Ze(wr,4,"disabled",bu,dt,sa),jr(wr,dt);var ub=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||{}),vu,_u,ju,wu,He,ia,aa,oa,la;wu=[de],ju=[de],_u=[de],vu=[de];var Cn=class{constructor(e,t){st(this,ia,le(He,8,this)),le(He,11,this),st(this,aa,le(He,12,this)),le(He,15,this),st(this,oa,le(He,16,this)),le(He,19,this),st(this,la,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=xs(null),ia=new WeakMap,aa=new WeakMap,oa=new WeakMap,la=new WeakMap,Ze(He,4,"manager",wu,Cn,ia),Ze(He,4,"id",ju,Cn,aa),Ze(He,4,"data",_u,Cn,oa),Ze(He,4,"disabled",vu,Cn,la),jr(He,Cn);var Cu,Su,ku,ca,Sr,Ot,ua,da,kr=class extends(ca=Cn,ku=[de],Su=[de],Cu=[ms],ca){constructor(t,n){var s=t,{modifiers:i,type:a,sensors:l}=s,c=gu(s,["modifiers","type","sensors"]);super(c,n),le(Ot,5,this),st(this,Sr),st(this,ua,le(Ot,8,this)),le(Ot,11,this),st(this,da,le(Ot,12,this,"idle")),le(Ot,15,this),this.type=a,this.sensors=l,this.modifiers=i}set modifiers(t){var n;const{manager:s}=this;(n=ys(this,Sr))==null||n.forEach(i=>i.destroy()),s&&ra(this,Sr,t==null?void 0:t.map(i=>{const{plugin:a,options:l}=yu(i);return new a(s,l)}))}get modifiers(){return ys(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())}};Ot=xs(ca),Sr=new WeakMap,ua=new WeakMap,da=new WeakMap,Ze(Ot,4,"type",ku,kr,ua),Ze(Ot,4,"status",Su,kr,da),Ze(Ot,2,"isDragSource",Cu,kr),jr(Ot,kr);var Tu,Du,Mu,zu,Iu,Eu,pa,Se,ha,fa,ga,ma,xa,an=class extends(pa=Cn,Eu=[de],Iu=[de],zu=[de],Mu=[de],Du=[de],Tu=[ms],pa){constructor(t,n){var s=t,{accept:i,collisionDetector:a,collisionPriority:l=2,type:c}=s,u=gu(s,["accept","collisionDetector","collisionPriority","type"]);super(u,n),le(Se,5,this),st(this,ha,le(Se,8,this)),le(Se,11,this),st(this,fa,le(Se,12,this)),le(Se,15,this),st(this,ga,le(Se,16,this)),le(Se,19,this),st(this,ma,le(Se,20,this)),le(Se,23,this),st(this,xa,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=xs(pa),ha=new WeakMap,fa=new WeakMap,ga=new WeakMap,ma=new WeakMap,xa=new WeakMap,Ze(Se,4,"accept",Eu,an,ha),Ze(Se,4,"type",Iu,an,fa),Ze(Se,4,"collisionDetector",zu,an,ga),Ze(Se,4,"collisionPriority",Mu,an,ma),Ze(Se,4,"shape",Du,an,xa),Ze(Se,2,"isDropTarget",Tu,an),jr(Se,an);var bs=class extends dt{constructor(e,t){super(e,t),this.manager=e,this.options=t}},db=({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=Yt.distance(t.shape.center,n);return{id:s,value:1/i,priority:Cr.High}}return null},pb=({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/Yt.distance(t.shape.center,i.current);return{id:t.id,value:l,priority:Cr.Normal}}return null},Au=e=>{var t;return(t=db(e))!=null?t:pb(e)},hb=e=>{var t;const{dragOperation:n,droppable:s}=e,{shape:i,position:a}=n;if(!s.shape)return null;const c=1/Yt.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 Pu(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 fb=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ya(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ou(e){return"nodeType"in e}function Wn(e){var t,n;return e?ya(e)?e:Ou(e)&&(n=(t=e.ownerDocument)==null?void 0:t.defaultView)!=null?n:window:window}function Lu(e){const{Document:t}=Wn(e);return e instanceof t}function Bu(e){return ya(e)?!1:e instanceof Wn(e).HTMLElement}function Tr(e){return e?ya(e)?e.document:Ou(e)?Lu(e)?e:Bu(e)?e.ownerDocument:document:document:document}function gb(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 mb(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(qu(a)&&qu(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 qu(e){return"value"in e}function Rn(e){return"style"in e&&e.style instanceof Wn(e).CSSStyleDeclaration}function xb(e,t=!1,n){const s=mb(e);if(Rn(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 Vu=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 ba(e){return"showPopover"in e&&"hidePopover"in e&&typeof e.showPopover=="function"&&typeof e.hidePopover=="function"}function va(e){ba(e)&&e.isConnected&&e.hasAttribute("popover")&&e.showPopover()}function Nu(e){return!fb||!e?!1:e===Tr(e).scrollingElement}function $u(e){const t=Nu(e)?gb(e):Pu(e),n=Nu(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 yb(e,t){const{isTop:n,isBottom:s,isLeft:i,isRight:a,position:l}=$u(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 bb(e){return e instanceof Wn(e).SVGElement}function on(e){return Wn(e).getComputedStyle(e)}function vb(e,t=on(e)){return t.position==="fixed"||t.position==="sticky"}function _b(e,t=on(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 jb={excludeElement:!0};function vs(e,t=jb){const{limit:n,excludeElement:s}=t,i=new Set;function a(l){if(n!=null&&i.size>=n||!l)return i;if(Lu(l)&&l.scrollingElement!=null&&!i.has(l.scrollingElement))return i.add(l.scrollingElement),i;if(!Bu(l))return bb(l)?a(l.parentElement):i;if(i.has(l))return i;const c=on(l);if(s&&l===e||_b(l,c)&&i.add(l),vb(l,c)){const{scrollingElement:u}=l.ownerDocument;return u&&i.add(u),i}return a(l.parentNode)}return e?a(e):i}function wb(e){const[t]=vs(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||{}),Cb={x:.2,y:.2},Sb={x:10,y:10};function kb(e,t,n,s=25,i=Cb,a=Sb){const{rect:l,isTop:c,isBottom:u,isLeft:d,isRight:p}=$u(e),h={x:0,y:0},f={x:0,y:0},x={height:l.height*i.y,width:l.width*i.x};return!c&&t.y<=l.top+x.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+x.height-t.y)/x.height)):!u&&t.y>=l.bottom-x.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-x.height-t.y)/x.height)),!p&&t.x>=l.right-x.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-x.width-t.x)/x.width)):!d&&t.x<=l.left+x.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+x.width-t.x)/x.width)),{direction:h,speed:f}}function Tb(e){return"scrollIntoViewIfNeeded"in e&&typeof e.scrollIntoViewIfNeeded=="function"}function Fu(e,t=!1){if(Tb(e)){e.scrollIntoViewIfNeeded(t);return}if(!(e instanceof HTMLElement))return e.scrollIntoView();var[n]=vs(e,{limit:1});if(!(n instanceof HTMLElement))return;const s=on(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 Db=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))}},Qn=new Db;function Mb(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 Gu=class{constructor(e){this.element=e,this.initial=new Map}set(e,t=""){const{element:n}=this;if(Rn(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(Rn(n))for(const s of e){const i=`${t}${s}`;n.style.removeProperty(i)}}reset(){const{element:e}=this;if(Rn(e)){for(const[t,n]of this.initial)e.style.setProperty(t,n);e.getAttribute("style")===""&&e.removeAttribute("style")}}};function Wu({element:e,keyframes:t,options:n,onReady:s,onFinish:i}){const a=new Gu(e),{transitionProperty:l}=on(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 Ru(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 _s(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 zb(e){const t=Ru(e);if(t){const{translate:s=""}=t;if(typeof s=="string"){const i=_s(s);if(i)return i}}const{translate:n}=on(e);if(n){const s=_s(n);if(s)return s}return{x:0,y:0,z:0}}function Ib(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 Qu(e){var t,n,s,i,a,l,c,u,d;const{scale:p,transform:h,translate:f}=e,x=Ib(p),y=_s(f),j=Eb(h);if(!j&&!x&&!y)return null;const k={x:(t=x==null?void 0:x.x)!=null?t:1,y:(n=x==null?void 0:x.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 Eb(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 Lt=class extends Hy{constructor(e,t=!1){var n,s;let{top:i,left:a,right:l,bottom:c,width:u,height:d}=Pu(e);const p=on(e),h=Qu(p),f={x:(n=h==null?void 0:h.scaleX)!=null?n:1,y:(s=h==null?void 0:h.scaleY)!=null?s:1},x=Ab(e);if(h&&(t||x)){const y=Mb({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}x&&!t&&(i=i+x.y,a=a+x.x,u=u*x.scaleX,d=d*x.scaleY,f.x=x.scaleX,f.y=x.scaleY),super(a,i,u,d),this.scale=f}};function Ab(e){const t=Ru(e);if(t){const{transform:n="",translate:s="",scale:i=""}=t;if(n||s||i)return Qu({transform:typeof n=="string"?n:"",translate:typeof s=="string"?s:"",scale:typeof i=="string"?i:""})}return null}function js(e){return e instanceof KeyboardEvent}var Pb=Object.create,Uu=Object.defineProperty,Ob=Object.defineProperties,Lb=Object.getOwnPropertyDescriptor,Bb=Object.getOwnPropertyDescriptors,ws=Object.getOwnPropertySymbols,Yu=Object.prototype.hasOwnProperty,Ku=Object.prototype.propertyIsEnumerable,Xu=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Dr=e=>{throw TypeError(e)},_a=(e,t,n)=>t in e?Uu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ju=(e,t)=>{for(var n in t||(t={}))Yu.call(t,n)&&_a(e,n,t[n]);if(ws)for(var n of ws(t))Ku.call(t,n)&&_a(e,n,t[n]);return e},qb=(e,t)=>Ob(e,Bb(t)),Zu=(e,t)=>{var n={};for(var s in e)Yu.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&ws)for(var s of ws(e))t.indexOf(s)<0&&Ku.call(e,s)&&(n[s]=e[s]);return n},Cs=e=>{var t;return[,,,Pb((t=e==null?void 0:e[Xu("metadata")])!=null?t:null)]},Hu=["class","method","getter","setter","accessor","field","value","get","set"],Mr=e=>e!==void 0&&typeof e!="function"?Dr("Function expected"):e,Vb=(e,t,n,s,i)=>({kind:Hu[e],name:t,metadata:s,addInitializer:a=>n._?Dr("Already initialized"):i.push(Mr(a||null))}),Ss=(e,t)=>_a(t,Xu("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},ln=(e,t,n,s,i,a)=>{for(var l,c,u,d,p,h=t&7,f=!!(t&8),x=!!(t&16),y=e.length+1,j=Hu[h+5],k=e[y-1]=[],S=e[y]||(e[y]=[]),T=(i=i.prototype,Lb({get[n](){return Bt(this,a)},set[n](I){return Un(this,a,I)}},n)),z=s.length-1;z>=0;z--)d=Vb(h,n,u={},e[3],S),d.static=f,d.private=x,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&&Uu(i,n,T),i},ed=(e,t,n)=>t.has(e)||Dr("Cannot "+n),Bt=(e,t,n)=>(ed(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),Un=(e,t,n,s)=>(ed(e,t,"write to private field"),t.set(e,n),n),td={role:"button",roleDescription:"draggable",tabIndex:0},Nb="dnd-kit-description",$b="dnd-kit-announcement",Fb={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."},Gb={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 Wb(e){return e instanceof HTMLInputElement||e instanceof HTMLSelectElement||e instanceof HTMLTextAreaElement||e instanceof HTMLAnchorElement||e instanceof HTMLButtonElement||e instanceof HTMLAreaElement}var ja={};function nd(e){const t=ja[e]==null?0:ja[e]+1;return ja[e]=t,`${e}-${t}`}function Rb(e,t){const n=document.createElement("div");return n.id=e,n.style.setProperty("display","none"),n.innerText=t,n}function Qb(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 Ub=class extends dt{constructor(e,t){super(e);const{id:n,idPrefix:{description:s=Nb,announcement:i=$b}={},announcements:a=Gb,screenReaderInstructions:l=Fb}=t??{},c=n?`${s}-${n}`:nd(s),u=n?`${i}-${n}`:nd(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=Rb(c,l.draggable),p=Qb(u),document.body.append(d,p)},x=Gy(()=>{for(const y of e.registry.draggables.value){const{element:j,handle:k}=y,S=k??j;S&&((!d||!p)&&f(),!Wb(S)&&!S.hasAttribute("tabindex")&&S.setAttribute("tabindex","0"),!S.hasAttribute("role")&&!(S instanceof HTMLButtonElement)&&S.setAttribute("role",td.role),S.hasAttribute("role-description")||S.setAttribute("aria-roledescription",td.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()),x()}})}},Yb=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()}}})}},rd="data-dnd-",Ve="--dnd-",cn=`${rd}dragging`,Kb=`[${cn}] {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;}[${cn}] *{pointer-events: none !important;}[${cn}][style*="${Ve}translate"] {translate: var(${Ve}translate) !important;}[style*="${Ve}transition"] {transition: var(${Ve}transition) !important;}*:where([${cn}][popover]){overflow:visible;background:var(${Ve}background);border:var(${Ve}border);margin:unset;padding:unset;color:inherit;}[${cn}]::backdrop {display: none}`,sd=`${rd}placeholder`,Xb=[cn,sd,"popover"],Jb=["view-transition-name"],Zb=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=Kb,document.head.prepend(t),c}),u=Xe(()=>{var d;const{dragOperation:p}=e,{position:h,source:f,status:x}=p;if(x.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 Lt(y,!0),{width:S,height:T,top:z,left:I}=k,E=new Gu(y),{background:N,border:R,transition:pe,translate:ie}=on(y),Ie=e.registry.droppables.get(f.id),xe=j==="clone",se=j!=="move"?xb(y,xe,{[sd]:""}):null,Fe=Vn(()=>js(e.dragOperation.activatorEvent));if(ie!=="none"){const ae=_s(ie);ae&&(s=ae)}if(n||(n={x:I,y:z}),!a){const ae=Vn(()=>h.current);a={x:(ae.x-I)/S,y:(ae.y-z)/T}}const mt={x:n.x-I,y:n.y-z},xt={top:z+mt.y,left:I+mt.x};y.setAttribute(cn,"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),ba(y)&&(y.hasAttribute("popover")||y.setAttribute("popover",""),va(y));const Yr=new Lt(y,!0),Dt={top:xt.top-Yr.top,left:xt.left-Yr.left};Dt.left>.01||Dt.top>.01?E.set({top:xt.top+Dt.top,left:xt.left+Dt.left},Ve):(Dt.left=0,Dt.top=0);const Kr=new ResizeObserver(()=>{if(!se)return;const ae=new Lt(se,!0),ue=a??{x:1,y:1},be=(S-ae.width)*ue.x+mt.x,ot=(T-ae.height)*ue.y+mt.y;if(E.set({width:ae.width,height:ae.height,top:z+ot+Dt.top,left:I+be+Dt.left},Ve),y instanceof HTMLTableRowElement&&se instanceof HTMLTableRowElement){const $t=Array.from(y.cells),yn=Array.from(se.cells);for(const[Mt,Ft]of $t.entries()){const zt=yn[Mt];Ft.style.width=`${zt.offsetWidth}px`}}e.dragOperation.shape=new Lt(y)});Ie&&se&&(Ie.placeholder=se,Vn(Ie.refreshShape)),p.shape=new Lt(y),f.status="dragging";let En,An;se&&(Kr.observe(se),En=new MutationObserver(()=>{for(const ae of Array.from(y.attributes))if(!(ae.name.startsWith("aria-")||Xb.includes(ae.name))){if(ae.name==="style"){if(Rn(y)&&Rn(se)){se.setAttribute("style",xe?"":"opacity: 0;"),se.style.setProperty("transition","none");for(const ue of Object.values(y.style))ue.startsWith(Ve)||Jb.includes(ue)||se.style.setProperty(ue,y.style.getPropertyValue(ue))}continue}se.setAttribute(ae.name,ae.value)}xe&&(se.innerHTML=y.innerHTML)}),En.observe(y,{attributes:!0,subtree:!0}),An=new MutationObserver(ae=>{for(const ue of ae)if(Array.from(ue.addedNodes).includes(y)){y.insertAdjacentElement("afterend",se),va(y);return}}),An.observe(y.ownerDocument.body,{childList:!0,subtree:!0}));const fi=Xe(function(){var ue,be;const{transform:ot,status:$t}=p;if(!(!ot.x&&!ot.y&&!l)&&(l||(l=!0),$t.dragging)){const yn=Fe?"250ms ease":"0ms linear",Mt=ot.x+s.x,Ft=ot.y+s.y,zt=new Lt(y);E.set({transition:`${pe}, translate ${yn}`,translate:`${Mt}px ${Ft}px 0`},Ve),p.shape=zt.translate(Mt-((ue=i==null?void 0:i.x)!=null?ue:0),Ft-((be=i==null?void 0:i.y)!=null?be:0)),i={x:Mt,y:Ft,z:0,scaleX:zt.scale.x,scaleY:zt.scale.y}}}),Xr=(d=e.dragOperation.source)==null?void 0:d.id,gi=()=>{var ae;if(!Fe||Xr==null)return;const ue=e.registry.draggables.get(Xr),be=(ae=ue==null?void 0:ue.handle)!=null?ae:ue==null?void 0:ue.element;be instanceof HTMLElement&&be.focus()};let ar=()=>{En==null||En.disconnect(),An==null||An.disconnect(),Kr.disconnect(),E.reset(),l&&y.isConnected&&(se==null||se.replaceWith(y)),se==null||se.remove(),y.removeAttribute(cn),ba(y)&&y.removeAttribute("popover"),fi(),El(),Ie&&(Ie.placeholder=void 0),f.status="idle",l=!1};const El=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;va(y);const $t=se??y;E.remove(["translate"],Ve);const yn=new Lt($t),Mt=new Lt(y,!0).translate(be.x,be.y),Ft={x:Mt.center.x-yn.center.x,y:Mt.center.y-yn.center.y},zt={x:be.x-Ft.x,y:be.y-Ft.y,z:0};Wu({element:y,keyframes:{translate:[`${be.x}px ${be.y}px ${(ot=be.z)!=null?ot:0}`,`${zt.x}px ${zt.y}px ${zt.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,Hb=!1,id,ad,od,ld,un,wa,Ca;ld=(od=[de],pt.Forward),ad=(id=[de],pt.Reverse);var Ir=class{constructor(){ht(this,wa,qe(un,8,this,zr)),qe(un,11,this),ht(this,Ca,qe(un,12,this,zr)),qe(un,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]=Hb)}};un=Cs(null),wa=new WeakMap,Ca=new WeakMap,ln(un,4,ld,od,Ir,wa),ln(un,4,ad,id,Ir,Ca),Ss(un,Ir);var ev=[pt.Forward,pt.Reverse],cd=class{constructor(){this.x=new Ir,this.y=new Ir}isLocked(){return this.x.isLocked()&&this.y.isLocked()}},tv=class extends dt{constructor(e){super(e);const t=fs(new cd);let n=null;this.signal=t,Xe(()=>{const{status:s}=e.dragOperation;if(!s.initialized){n=null,t.value=new cd;return}const{delta:i}=e.dragOperation.position;if(n){const a={x:ud(i.x,n.x),y:ud(i.y,n.y)},l=t.peek();Ut(()=>{for(const c of du)for(const u of ev)a[c]===u&&l[c].unlock(u);t.value=l})}n=i})}get current(){return this.signal.peek()}};function ud(e,t){return Math.sign(e-t)}var dd,Sa,Er,ka,dn,Ta,ks=class extends(Sa=ub,dd=[de],Sa){constructor(e){super(e),ht(this,ka,qe(Er,8,this,!1)),qe(Er,11,this),ht(this,dn),ht(this,Ta,()=>{if(!Bt(this,dn))return;const{element:a,by:l}=Bt(this,dn);a.scrollBy(l.x,l.y)}),this.scroll=a=>{var l;if(this.disabled)return!1;const c=this.getScrollableElements();if(!c)return Un(this,dn,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:pd(p.x),y:pd(p.y)}:void 0,f=h?void 0:this.scrollIntentTracker.current;if(f!=null&&f.isLocked())return!1;for(const x of c){const y=yb(x,p);if(y.x||y.y){const{speed:j,direction:k}=kb(x,d,h);if(f)for(const S of du)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=Bt(this,dn))==null?void 0:l.by;if(this.autoScrolling&&E&&(E.x&&!z||E.y&&!I))continue;return Un(this,dn,{element:x,by:{x:z,y:I}}),Qn.schedule(Bt(this,Ta)),!0}}}}}return Un(this,dn,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=vs(c,{excludeElement:!1});return n=u,u}}if(a){const l=vs(a,{excludeElement:!1});return this.autoScrolling&&n&&l.size<(n==null?void 0:n.size)?n:(n=l,l)}return n=null,null},Qi);this.getScrollableElements=()=>i.value,this.scrollIntentTracker=new tv(e),this.destroy=e.monitor.addEventListener("dragmove",a=>{this.disabled||a.defaultPrevented||!js(e.dragOperation.activatorEvent)||!a.by||this.scroll({by:a.by})&&a.preventDefault()})}};Er=Cs(Sa),ka=new WeakMap,dn=new WeakMap,Ta=new WeakMap,ln(Er,4,"autoScrolling",dd,ks,ka),Ss(Er,ks);function pd(e){return e>0?pt.Forward:e<0?pt.Reverse:pt.Idle}var nv=10,hd=class extends dt{constructor(e,t){super(e);const n=e.registry.plugins.get(ks);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,nv);return()=>{clearInterval(l)}}else n.autoScrolling=!1})}},rv=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",fd,{capture:!0}),()=>{document.removeEventListener("selectionchange",fd,{capture:!0}),n.remove()}}})}};function fd(){var e;(e=document.getSelection())==null||e.removeAllRanges()}var gd={start:["Space","Enter"],cancel:["Escape"],end:["Space","Enter"],up:["ArrowUp"],down:["ArrowDown"],left:["ArrowLeft"],right:["ArrowRight"]},Ts=10,Ar,sv=class extends bs{constructor(e,t){super(e),this.manager=e,this.options=t,ht(this,Ar,[]),this.listeners=new Vu,this.handleSourceKeyDown=(n,s,i)=>{if(this.disabled||n.defaultPrevented||!(n.target instanceof Element)||s.disabled||!s.element)return;const{keyboardCodes:a=gd}=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(),Fu(s);const{center:i}=new Lt(s);Ut(()=>{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=Wn(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)}])];Bt(this,Ar).push(...c)}handleKeyDown(e,t,n){const{keyboardCodes:s=gd}=n??{};if(Yn(e,[...s.end,...s.cancel])){e.preventDefault();const i=Yn(e,s.cancel);this.handleEnd(i);return}Yn(e,s.up)?this.handleMove("up",e):Yn(e,s.down)&&this.handleMove("down",e),Yn(e,s.left)?this.handleMove("left",e):Yn(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:-Ts*s};break;case"down":i={x:0,y:Ts*s};break;case"left":i={x:-Ts*s,y:0};break;case"right":i={x:Ts*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(hd);(e==null?void 0:e.disabled)===!1&&(e.disable(),Bt(this,Ar).push(()=>{e.enable()}))}cleanup(){Bt(this,Ar).forEach(e=>e())}destroy(){this.cleanup(),this.listeners.clear()}};Ar=new WeakMap;function Yn(e,t){return t.includes(e.code)}var Kn,Da=class extends bs{constructor(t,n){super(t),this.manager=t,this.options=n,this.listeners=new Vu,this.cleanup=new Set,ht(this,Kn),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 ov(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);Un(this,Kn,()=>{clearTimeout(f),Un(this,Kn,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:Ma,options:{passive:!1}},{type:"click",listener:Ma},{type:"dragstart",listener:a?this.handleCancel:Ma},{type:"keydown",listener:this.handleKeyDown}]),p=()=>{var h;setTimeout(d),(h=Bt(this,Kn))==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&&ea(a,u.tolerance))return this.handleCancel();if(ea(a,u.value))return this.handleStart(n,t)}if(d&&ea(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=Bt(this,Kn))==null||s.call(this),!(!a||i.dragOperation.status.initialized)&&(n.defaultPrevented||(n.preventDefault(),Ut(()=>{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()}};Kn=new WeakMap,Da.configure=cb(Da);var iv=Da;function Ma(e){e.preventDefault()}function av(){}var md=new WeakSet;function ov(e){!e||md.has(e)||(e.addEventListener("touchmove",av,{capture:!1,passive:!1}),md.add(e))}iv.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 xd,yd,bd,za,kt,Ia,Ea,Aa,Pr=class extends(za=kr,bd=[de],yd=[de],xd=[de],za){constructor(e,t){var n=e,{element:s,effects:i=()=>[],handle:a,feedback:l="default"}=n,c=Zu(n,["element","effects","handle","feedback"]);super(Ju({effects:()=>[...i(),()=>{var u,d;const{manager:p}=this;if(!p)return;const f=((d=(u=this.sensors)==null?void 0:u.map(yu))!=null?d:[...p.sensors]).map(x=>{const y=x instanceof bs?x:p.registry.register(x.plugin),j=x instanceof bs?void 0:x.options;return y.bind(this,j)});return function(){f.forEach(y=>y())}}]},c),t),ht(this,Ia,qe(kt,8,this)),qe(kt,11,this),ht(this,Ea,qe(kt,12,this)),qe(kt,15,this),ht(this,Aa,qe(kt,16,this)),qe(kt,19,this),this.element=s,this.handle=a,this.feedback=l}};kt=Cs(za),Ia=new WeakMap,Ea=new WeakMap,Aa=new WeakMap,ln(kt,4,"handle",bd,Pr,Ia),ln(kt,4,"element",yd,Pr,Ea),ln(kt,4,"feedback",xd,Pr,Aa),Ss(kt,Pr);var vd,_d,Pa,pn,Oa,La,Ds=class extends(Pa=an,_d=[de],vd=[de],Pa){constructor(e,t){var n=e,{element:s,effects:i=()=>[]}=n,a=Zu(n,["element","effects"]),l;const{collisionDetector:c=Au}=a;super(qb(Ju({},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=wb(u),f=Tr(u),x=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:x??f,rootMargin:"40%"}),j=new MutationObserver(()=>Qn.schedule(this.refreshShape)),k=new ResizeObserver(()=>Qn.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=Vn(()=>d.source);if(p.initialized){if((h==null?void 0:h.type)!=null&&!this.accepts(h))return;Qn.schedule(this.refreshShape)}},()=>{var u;if((u=this.manager)!=null&&u.dragOperation.status.initialized)return()=>{this.shape=void 0}}]}),t),ht(this,Oa,qe(pn,8,this)),qe(pn,11,this),ht(this,La,qe(pn,12,this)),qe(pn,15,this),this.internal={element:fs(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 Lt(t,e);return s&&(n!=null&&n.equals(s))?n:(this.shape=s,s)}};pn=Cs(Pa),Oa=new WeakMap,La=new WeakMap,ln(pn,4,"visible",_d,Ds,Oa),ln(pn,4,"placeholder",vd,Ds,La),Ss(pn,Ds);var lv=Object.create,jd=Object.defineProperty,cv=Object.defineProperties,uv=Object.getOwnPropertyDescriptor,dv=Object.getOwnPropertyDescriptors,Ms=Object.getOwnPropertySymbols,wd=Object.prototype.hasOwnProperty,Cd=Object.prototype.propertyIsEnumerable,pv=(e,t)=>(t=Symbol[e])?t:Symbol.for("Symbol."+e),Or=e=>{throw TypeError(e)},Ba=(e,t,n)=>t in e?jd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,hv=(e,t)=>{for(var n in t||(t={}))wd.call(t,n)&&Ba(e,n,t[n]);if(Ms)for(var n of Ms(t))Cd.call(t,n)&&Ba(e,n,t[n]);return e},fv=(e,t)=>cv(e,dv(t)),gv=(e,t)=>{var n={};for(var s in e)wd.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(e!=null&&Ms)for(var s of Ms(e))t.indexOf(s)<0&&Cd.call(e,s)&&(n[s]=e[s]);return n},mv=e=>{var t;return[,,,lv((t=void 0)!=null?t:null)]},Sd=["class","method","getter","setter","accessor","field","value","get","set"],Lr=e=>e!==void 0&&typeof e!="function"?Or("Function expected"):e,xv=(e,t,n,s,i)=>({kind:Sd[e],name:t,metadata:s,addInitializer:a=>n._?Or("Already initialized"):i.push(Lr(a||null))}),yv=(e,t)=>Ba(t,pv("metadata"),e[3]),zs=(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},kd=(e,t,n,s,i,a)=>{for(var l,c,u,d,p,h=t&7,f=!!(t&8),x=!!(t&16),y=e.length+1,j=Sd[h+5],k=e[y-1]=[],S=e[y]||(e[y]=[]),T=(i=i.prototype,uv({get[n](){return bv(this,a)},set[n](I){return vv(this,a,I)}},n)),z=s.length-1;z>=0;z--)d=xv(h,n,u={},e[3],S),d.static=f,d.private=x,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&&jd(i,n,T),i},Td=(e,t,n)=>t.has(e)||Or("Cannot "+n),bv=(e,t,n)=>(Td(e,t,"read from private field"),t.get(e)),Dd=(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),vv=(e,t,n,s)=>(Td(e,t,"write to private field"),t.set(e,n),n);function Xn(e){return e instanceof Na||e instanceof Ad}var Is=10,_v=class extends dt{constructor(e){super(e);const t=Xe(()=>{const{dragOperation:s}=e;if(js(s.activatorEvent)&&Xn(s.source)&&s.status.initialized){const i=e.registry.plugins.get(ks);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(!js(a.activatorEvent)||!Xn(a.source)||!a.shape)return;const{actions:l,collisionObserver:c,registry:u}=i,{by:d}=s;if(!d)return;const p=jv(d),{source:h}=a,{center:f}=a.shape.current,x=[];for(const S of u.droppables){const{shape:T,id:z}=S;if(!(!T||z===(h==null?void 0:h.id)&&Xn(S)||(h==null?void 0:h.type)!=null&&!S.accepts(h)))switch(p){case"down":f.y+Is<T.center.y&&x.push(S);break;case"up":f.y-Is>T.center.y&&x.push(S);break;case"left":f.x-Is>T.center.x&&x.push(S);break;case"right":f.x+Is<T.center.x&&x.push(S);break}}s.preventDefault(),c.disable();const y=c.computeCollisions(x,hb),[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;Fu(z),Qn.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 jv(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 wv(e,t,n){if(t===n)return e;const s=e.slice();return s.splice(n,0,s.splice(t,1)[0]),s}var Cv=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 Na){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(!Xn(l)||!Xn(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),x=wv(p,h,f),y=(d=l.sortable.droppable.internal.element.peek())!=null?d:l.sortable.droppable.placeholder,j=c.element;!j||!y||(Md(y,h,j,f),Ut(()=>{for(const[k,S]of x.entries())S.index=k}))})})}),e.monitor.addEventListener("dragend",(s,i)=>{if(!s.canceled)return;const{dragOperation:a}=i,{source:l}=a;Xn(l)&&l.sortable.initialIndex!==l.sortable.index&&queueMicrotask(()=>{const c=t(l.sortable.group);i.renderer.rendering.then(()=>{var u;for(const[f,x]of c.entries())if(x.index!==f)return;const d=Array.from(c.values()).sort((f,x)=>f.index-x.index),p=l.sortable.droppable.element,h=(u=d[l.sortable.initialIndex])==null?void 0:u.element;!h||!p||(Md(p,l.sortable.index,h,l.sortable.initialIndex),Ut(()=>{for(const f of d.values())f.index=f.initialIndex}))})})})];this.destroy=()=>{for(const s of n)s()}}};function Md(e,t,n,s){const i=s<t?"beforebegin":"afterend";n.insertAdjacentElement(i,e)}var Sv=[_v,Cv],zd={duration:250,easing:"cubic-bezier(0.25, 1, 0.5, 1)",idle:!1},Id,Ed,hn,qa,Va;Ed=[de],Id=[de];var Es=class{constructor(e,t){Dd(this,qa,zs(hn,8,this)),zs(hn,11,this),Dd(this,Va,zs(hn,12,this)),zs(hn,15,this);var n=e,{effects:s=()=>[],group:i,index:a,sensors:l,type:c,transition:u=zd,plugins:d=Sv}=n,p=gv(n,["effects","group","index","sensors","type","transition","plugins"]);this.droppable=new Na(p,t,this),this.draggable=new Ad(fv(hv({},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:x}=this;h!==f&&(this.previousIndex=h,this.animate())},()=>{const{target:h}=this,{feedback:f,isDragSource:x}=this.draggable;f=="move"&&x&&(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(){Vn(()=>{const{manager:e,transition:t}=this,{shape:n}=this.droppable;if(!e)return;const{idle:s}=e.dragOperation.status;!n||!t||s&&!t.idle||Qn.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}=zb(i);(l.x||l.y)&&Wu({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){Ut(()=>{this.draggable.disabled=e,this.droppable.disabled=e})}set data(e){Ut(()=>{this.draggable.data=e,this.droppable.data=e})}set handle(e){this.draggable.handle=e}set id(e){Ut(()=>{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??Au}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()}};hn=mv(),qa=new WeakMap,Va=new WeakMap,kd(hn,4,"index",Ed,Es,qa),kd(hn,4,"group",Id,Es,Va),yv(hn,Es);var Ad=class extends Pr{constructor(e,t,n){super(e,t),this.sortable=n}get index(){return this.sortable.index}},Na=class extends Ds{constructor(e,t,n){super(e,t),this.sortable=n}refreshShape(e=!1){return super.refreshShape(e)}get index(){return this.sortable.index}};function Pd(e){const t=g.useRef();return t.current||(t.current=e()),t.current}var kv=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Od=kv?g.useLayoutEffect:g.useEffect;function Tv(e,t=!1){const n=Pd(()=>e instanceof Be?e:fs(e));let s=n.peek();const i=g.useState(s)[1];return Od(()=>Xe(()=>{s!==(s=n.value)&&(t?yg.flushSync(()=>i(s)):i(s))}),[t]),n}function $a(e,t=!1){return Tv(Pd(()=>gs(e)),t)}function Dv(e,t){e()}function Ne(e,t,n=g.useEffect,s=Object.is){const i=g.useRef(e);n(()=>{const a=i.current;s(e,a)||(i.current=e,t(e,a))},[t,e])}function Fa(e){var t;if(e!=null)return typeof e=="object"&&"current"in e?(t=e.current)!=null?t:void 0:e}var Mv=Object.defineProperty,zv=Object.defineProperties,Iv=Object.getOwnPropertyDescriptors,Ld=Object.getOwnPropertySymbols,Ev=Object.prototype.hasOwnProperty,Av=Object.prototype.propertyIsEnumerable,Bd=(e,t,n)=>t in e?Mv(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Pv=(e,t)=>{for(var n in t||(t={}))Ev.call(t,n)&&Bd(e,n,t[n]);if(Ld)for(var n of Ld(t))Av.call(t,n)&&Bd(e,n,t[n]);return e},Ov=(e,t)=>zv(e,Iv(t));function qd(e){const{accept:t,collisionDetector:n,collisionPriority:s,id:i,data:a,index:l,group:c,disabled:u,feedback:d,sensors:p,transition:h=zd,type:f}=e,x=Hr.useDragDropManager(),y=Fa(e.handle),j=Fa(e.element),k=Fa(e.target),S=Hr.useInstance(E=>new Es(Ov(Pv({},e),{handle:y,element:j,target:k,feedback:d}),E)),T=$a(()=>S.isDropTarget),z=$a(()=>S.isDragSource),I=$a(()=>S.status);return Ne(i,()=>S.id=i),Ne(l,()=>S.index=l,Od),Ne(f,()=>S.type=f),Ne(c,()=>S.group=c),Ne(t,()=>S.accept=t,void 0,Qi),Ne(a,()=>a&&(S.data=a)),Ne(l,()=>{x!=null&&x.dragOperation.status.idle&&h&&S.refreshShape()},Dv),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:g.useCallback(E=>{S.handle=E??void 0},[S]),ref:g.useCallback(E=>{S.element=E??void 0},[S]),sourceRef:g.useCallback(E=>{S.source=E??void 0},[S]),targetRef:g.useCallback(E=>{S.target=E??void 0},[S])}}const Lv=({value:e,index:t,children:n})=>{const[s,{setTrue:i,setFalse:a}]=W.useBoolean(!1),{ref:l,handleRef:c}=qd({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})},Bv=({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(Hr.DragDropProvider,{onDragEnd:a,children:i.map((l,c)=>r.jsx(Lv,{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,x=t(n),y=p.map((E,N)=>({...E,...x[N]})),j=((I=v.last(y))==null?void 0:I.id)??null,[k,S]=g.useState(j),T=E=>{E!=="add"&&S(E)};g.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(Bv,{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))]})},As=g.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)})})})]})]})}),fn=g.forwardRef(({label:e,value:t,onChange:n,sx:s={},disabled:i},a)=>{const{t:l,i18n:c}=_.useTranslation(),u=g.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})}),Vv=({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(fn,{sx:{flex:1},value:a.value.orient,onChange:l=>{i(l,a.onChange)},disabled:!s.show})})})]})};function Nv({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 $v({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>({name:"",template:"",variable_key:""}),a=g.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(Nv,{control:e,index:u,variableOptions:a})})}const Fv=({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})})]})})},Gv=({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(Fv,{control:e,index:l})})]})};function Wv({control:e,watch:t}){return r.jsx(o.Stack,{children:r.jsx(Gv,{control:e,watch:t})})}const Kt=g.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})}),Rv=({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(Kt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(Ct,{...s})})]}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(St,{...s})})]})},Ga={root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}},Qv=["123456789","1234","1234.56789","1.234","0.123456789","-0.123456789"];function Uv({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:Qv.map(i=>r.jsxs("tr",{children:[r.jsx("td",{children:i}),r.jsx("td",{children:r.jsx(ze,{children:U(i,e)})})]},i))})]})})]})}function Yv({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:Ga}),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:Ga})]}),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:Ga}),r.jsx(o.Box,{})]}),r.jsx(Uv,{format:e})]})}const ft=g.forwardRef(Yv),Kv=({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 Xv({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},n,qi),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});g.useEffect(()=>{p(a)},[a]),u(["x_axis","y_axis","reference_lines","color","dataZoom"]);const h=d(),f=g.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(Rv,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx(Kv,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Legend",children:r.jsx(Vv,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(Wv,{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:x})=>r.jsx(Le,{...x})})]})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx($v,{variables:i,control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Zooming",children:r.jsx(b.Controller,{name:"dataZoom",control:l,render:({field:x})=>r.jsx(As,{...x})})})]})]})})}function Jv(e){return v.omit(e,"variables")}function Zv(e){const{label_formatter:t=Me,...n}=e.y_axis;return{...e,y_axis:{...n,label_formatter:t}}}function Hv(e){const t={rotate:0,formatter:Oe()},{axisLabel:n=t,...s}=e.x_axis;return{...e,x_axis:{...s,axisLabel:n}}}function e_(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 t_(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 n_(e){const t={tooltip:{metrics:[]}};return v.defaultsDeep(t,e)}function r_(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 s_(e){const t={legend:{show:!0,top:"0",right:"10",left:"auto",bottom:"auto",orient:"horizontal",type:"scroll"}};return v.defaultsDeep(t,e)}function i_(e){const{dataZoom:t,...n}=e;return{...n,dataZoom:t??Ac()}}class a_ extends me{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:Jv(i)}}),this.version(3,n=>{const{config:s}=n;return{...n,version:3,config:Zv(s)}}),this.version(4,n=>{const{config:s}=n;return{...n,version:4,config:Hv(s)}}),this.version(5,n=>{const{config:s}=n;return{...n,version:5,config:e_(s)}}),this.version(6,n=>{const{config:s}=n;return{...n,version:6,config:t_(s)}}),this.version(7,n=>{const{config:s}=n;return{...n,version:7,config:n_(s)}}),this.version(8,(n,s)=>{const{config:i}=n;return{...n,version:8,config:r_(i,s)}}),this.version(9,n=>{const{config:s}=n;return{...n,version:9,config:s_(s)}}),this.version(10,n=>{const{config:s}=n;return{...n,version:10,config:i_(s)}})}}const o_={displayName:"viz.boxplot.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new a_,name:"boxplot",viewRender:zy,configRender:Xv,createConfig(){return{version:10,config:v.cloneDeep(qi)}},triggers:[Pc],translation:hx},Vd={id:"builtin:button:click-button",displayName:"viz.button.click.label",nameRender:c_,configRender:l_,payload:[]};function l_(e){return r.jsx(r.Fragment,{})}function c_(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.button.click.label")})}const Wa={content:"Button",variant:"filled",color:"blue",size:"xs",compact:!1,horizontal_align:"left",vertical_align:"center"},u_={left:"flex-start",center:"center",right:"flex-end"},d_={top:"flex-start",center:"center",bottom:"flex-end"},p_=D.observer(({context:e,instance:t})=>{const n=rt({vizManager:e.vizManager,instance:t}),s=nt(n.triggerManager,Vd.id),i=_e(),{value:a}=$(e.instanceData,"config"),l=g.useMemo(()=>v.defaultsDeep({},a,Wa),[a]),{content:c,horizontal_align:u,vertical_align:d,...p}=l,{width:h,height:f}=e.viewport,x=i.payloadForSQL,y=()=>{s.forEach(j=>{n.runInteraction(j.id,{})})};return r.jsx(o.Center,{sx:{width:h,height:f,justifyContent:u_[u],alignItems:d_[d]},children:r.jsx(o.Button,{...p,onClick:y,children:v.template(c)(x)})})}),h_=({value:e,onChange:t,label:n})=>{const s=o.useMantineTheme(),i=g.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)})})]})},Ra=g.forwardRef(({label:e,value:t,onChange:n,sx:s,disabled:i},a)=>{const{t:l}=_.useTranslation(),c=g.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})}),f_=[{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 g_({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=g.useMemo(()=>v.defaultsDeep({},t,Wa),[t]),i=s;g.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});g.useEffect(()=>{d(i)},[i]);const p=u(),h=g.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:f_,...f})}),r.jsx(b.Controller,{control:a,name:"color",render:({field:f})=>r.jsx(h_,{label:"Theme",...f})})]}),r.jsxs(o.SimpleGrid,{cols:2,children:[r.jsx(b.Controller,{control:a,name:"size",render:({field:f})=>r.jsx(Ra,{label:"Size",...f})}),r.jsx(b.Controller,{control:a,name:"compact",render:({field:f})=>r.jsx(o.Checkbox,{label:"Compact",checked:f.value,onChange:x=>f.onChange(x.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(ds,{...f})}),r.jsx(b.Controller,{control:a,name:"vertical_align",render:({field:f})=>r.jsx($c,{...f})})]})]})]})}const m_=[{lang:"en",resources:{button:{viz_name:"Button",click:{label:"Click this button"}}}},{lang:"zh",resources:{button:{viz_name:"按钮",click:{label:"点击此按钮"}}}}];class x_ extends me{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 y_={displayName:"viz.button.viz_name",displayGroup:"chart.groups.others",migrator:new x_,name:"button",viewRender:p_,configRender:g_,createConfig(){return{version:2,config:v.cloneDeep(Wa)}},triggers:[Vd],translation:m_},Qa={id:"builtin:echarts:click-echart:series",displayName:"viz.cartesian_chart.click_series.label",nameRender:v_,configRender:b_,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 b_(e){return r.jsx(r.Fragment,{})}function v_(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.cartesian_chart.click_series.label")})}const Ua={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:_n};function __(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 j_(e){return e!=="line"?{}:{itemStyle:{opacity:0}}}function w_(e){switch(e){case"line":return;case"bar":return"roundRect";case"scatter":return"circle"}}function C_(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:w_(s),...j_(s)})),t}function Ps(e,t){switch(e.config.method){case"linear":return[...rn.regressionLinear()(t)];case"exponential":return[...rn.regressionExp()(t)];case"logistic":return[...rn.regressionLog()(t)];case"polynomial":return[...rn.regressionPoly().order(e.config.order)(t)];default:return[]}}function S_(e,t,n,s){const{transform:i,plot:a}=e,l={...a,name:t,data:Ps(i,s),showSymbol:!1,tooltip:{show:!1},smooth:!1,custom:{}};return n&&(l.custom={type:"regression-line",targetSeries:n}),l}function k_({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=S_(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=vt(n,a.y_axis_data_key).map((f,x)=>[x,Number(f)]);i(a,l,"",h);return}const{columnKey:u}=O(a.y_axis_data_key),d=v.groupBy(ns(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 T_(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 D_(e,t,n,s){return t?s==="value"?[[n[0],e]]:[e]:[]}function M_(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=D_(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?gr(l.template,t,s):""},position:p}}}})}function Ya(e,t,n){const s=vt(e,t),i=vt(e,n);return v.zip(s,i)}function z_(e,t,n,s){const i=Ya(t,n,s);return v.unionBy(i,e,0)}function I_({dataTemplate:e,data:t,x_axis_data_key:n,y_axis_data_key:s,valueTypedXAxis:i}){return i?z_(e,t,n,s):vt(t,s)}function E_({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 I_({dataTemplate:e,data:t,x_axis_data_key:s,y_axis_data_key:i,valueTypedXAxis:a});const l=Ya(t,s,i),c=v.groupBy(l,"0");return e.map(([d])=>{const h=c[d].map(x=>x[1]),f=Si(h,n);return[d,f]})}function A_({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]=Ya({[i]:u},n,s)}),l}function P_({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(ns(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:bn.interpolate})}catch(f){return console.error(`[getEchartsSymbolSize] failed parsing custom function, error: ${f.message}`),10}}}function O_({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,...x},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:P_(h,j,e,k),hide_in_legend:f,labelLayout:{hideOverlap:!0},...x};if(x.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=E_({dataTemplate:y,data:j,aggregation_on_value:c,x_axis_data_key:e,y_axis_data_key:n,valueTypedXAxis:T}),z;const I=A_({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 L_(e,t,n,s,i,a){const l=t.map(u=>[u,0]);return e.series.map(u=>O_(e,u,l,n,a,s)).flat().concat(M_(e.reference_lines,i,a,n,t,e.x_axis.type)).concat(T_(e.reference_areas,a))}function B_(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 V_(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:x})=>{if(Array.isArray(x)&&x.length===2&&(x=x[1]),!h)return x;const y=i[h],j=s[y]??s.default;return`
|
|
109
109
|
<tr>
|
|
110
|
-
<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;">${
|
|
112
|
+
<td style="text-align: left; padding: 0 1em;">${j({value:x})}</td>
|
|
113
113
|
</tr>
|
|
114
|
-
`}),u=
|
|
114
|
+
`}),u=e.tooltip.metrics.map(h=>{const f=vt(t,h.data_key),x=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
|
-
${
|
|
118
|
-
</tr>`});c.push(...u);const d=
|
|
117
|
+
${x.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=B_(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,12 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
124
124
|
${c.join("")}
|
|
125
125
|
</tbody>
|
|
126
126
|
</table>
|
|
127
|
-
`}})}function rx(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 ix(t,e){const{overflow:n,...r}=t.x_axis.axisLabel,i=Qe(n.on_axis),a=e.length===0;return[te.getXAxis({data:e,name:t.x_axis_name??"",nameGap:a?5:void 0,id:"main-x-axis",type:t.x_axis.type,axisLabel:{...r,...i,formatter:Pe(r.formatter)}})]}function ax(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 ox(t){if(t.length===0)return{};const e={},n={};return t.forEach(r=>{const i=ax(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 a=b.minBy(i)??0,l=b.maxBy(i)??0;a==0&&l==0&&(e[r]=1)}),e}function lx(t,e,n){const r=ox(n);return t.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:r[d]??0,show:c,min:a||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 cx={xAxis:[{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"},splitLine:{show:!1},axisTick:{show:!0,alignWithLabel:!0}}]};function ux(t,e,n){const r=er(e,n),i=rx(t),a=b.uniq(Xe(e,t.x_axis_data_key)),l=ex(t,a,e,i,n,r),c=Wm(t,e),u={xAxis:ix(t,a),yAxis:lx(t,i,l),series:[...l,...c],tooltip:sx(t,e,l,i),grid:Om(t),legend:Gm(l),dataZoom:Bn(t.dataZoom)};return b.defaultsDeep({},u,cx)}function Ka(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 Ja(t){return t.trim().length>0}function dx({conf:t,data:e,width:n,height:r,interactionManager:i,variables:a}){const l=Mt(e,t.x_axis_data_key),c=qe(i.triggerManager,Xs.id),u=m.useCallback(y=>{const v=b.get(l,y.name,{error:"rowData is not found"});c.forEach(w=>{i.runInteraction(w.id,{...y,rowData:v})})},[l,c,i]),d=m.useMemo(()=>ux(t,e,a),[t,e]),p=m.useRef(),h=m.useMemo(()=>({click:u}),[u]),g=y=>{p.current=y,Ka(y)};return m.useEffect(()=>{p.current&&Ka(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 px({context:t,instance:e}){const n=Oe({vizManager:t.vizManager,instance:e}),{value:r}=q(t.instanceData,"config"),{variables:i}=t,a=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(),y=m.useMemo(()=>{const{stats:{templates:T}}=a;return{top:cn(T.top,i,l),bottom:cn(T.bottom,i,l)}},[a,l]),v=Math.max(0,et(u)-p-g),w=He(c);return s.jsxs(Ae,{width:c,height:u,children:[s.jsx(o.Text,{ref:d,align:"left",size:"xs",pl:"sm",sx:{display:Ja(a.stats.templates.top)?"block":"none"},children:Object.values(y.top).map((T,D)=>s.jsx(m.Fragment,{children:T},D))}),s.jsx(dx,{variables:i,width:w,height:v,data:l,conf:a,interactionManager:n}),s.jsx(o.Text,{ref:h,align:"left",size:"xs",pl:"sm",sx:{display:Ja(a.stats.templates.bottom)?"block":"none"},children:Object.values(y.bottom).map((T,D)=>s.jsx(m.Fragment,{children:T},D))})]})}function hx({control:t,index:e,variableOptions:n}){const{t:r,i18n:i}=_.useTranslation(),a=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(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`reference_areas.${e}.name`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:r("chart.reference_area.label"),required:!0,sx:{flex:1},...c})}),s.jsx(f.Controller,{name:`reference_areas.${e}.color`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:r("chart.color.label"),required:!0,sx:{flex:1},...c})})]}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`reference_areas.${e}.type`,control:t,render:({field:c})=>s.jsx(o.Select,{label:r("chart.reference_area.type.label"),required:!0,data:a,sx:{flex:1},...c})}),s.jsx(f.Controller,{name:`reference_areas.${e}.direction`,control:t,render:({field:c})=>s.jsx(o.Select,{label:r("chart.reference_area.direction.label"),required:!0,data:l,sx:{flex:1},...c})})]}),s.jsx(o.Divider,{variant:"dashed",label:r("data.label"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`reference_areas.${e}.y_keys.upper`,control:t,render:({field:c})=>s.jsx(o.Select,{label:r("chart.reference_area.boundary.upper"),required:!0,data:n,sx:{flex:1},...c})}),s.jsx(f.Controller,{name:`reference_areas.${e}.y_keys.lower`,control:t,render:({field:c})=>s.jsx(o.Select,{label:r("chart.reference_area.boundary.lower"),required:!0,data:n,sx:{flex:1},...c})})]})]})}function mx({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:""}}),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 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:a,children:({field:c,index:u})=>s.jsx(hx,{control:t,index:u,variableOptions:l})})}const Wt=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},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 s.jsx(o.Select,{ref:i,label:t??a("chart.series.line.type.label"),data:c,value:e,onChange:n,sx:r})});function xx({control:t,index:e,watch:n,variableOptions:r,yAxisOptions:i}){const{t:a}=_.useTranslation(),l=n(`reference_lines.${e}.orientation`);return s.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`reference_lines.${e}.name`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:a("common.name"),placeholder:a("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),s.jsx(f.Controller,{name:`reference_lines.${e}.variable_key`,control:t,render:({field:c})=>s.jsx(o.Select,{label:a("common.data_field"),required:!0,data:r,sx:{flex:1},...c})})]}),s.jsx(f.Controller,{name:`reference_lines.${e}.template`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:a("chart.content_template.label"),placeholder:a("chart.content_template.hint"),sx:{flex:1},...c})}),s.jsxs(o.Group,{grow:!0,children:[s.jsxs(o.Stack,{children:[s.jsx(f.Controller,{name:`reference_lines.${e}.orientation`,control:t,render:({field:c})=>s.jsx(wt,{label:a("chart.orientation.label"),sx:{flex:1},...c})}),l==="vertical"&&s.jsx(o.Text,{mt:-10,color:"dimmed",size:12,children:a("chart.reference_line.orientation.vertical_hint")})]}),l==="horizontal"&&s.jsx(f.Controller,{name:`reference_lines.${e}.yAxisIndex`,control:t,render:({field:{value:c,onChange:u,...d}})=>s.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}})})]}),s.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.style.label"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:`reference_lines.${e}.lineStyle.type`,control:t,render:({field:c})=>s.jsx(Wt,{sx:{flexGrow:1},...c})}),s.jsx(f.Controller,{name:`reference_lines.${e}.lineStyle.width`,control:t,render:({field:c})=>s.jsx(o.NumberInput,{label:a("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),s.jsxs(o.Stack,{spacing:4,children:[s.jsx(o.Text,{size:"sm",children:a("chart.color.label")}),s.jsx(f.Controller,{name:`reference_lines.${e}.lineStyle.color`,control:t,render:({field:c})=>s.jsx(Te,{...c})})]}),s.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.behavior.label"),labelPosition:"center"}),s.jsx(f.Controller,{name:`reference_lines.${e}.show_in_legend`,control:t,render:({field:c})=>s.jsx(o.Checkbox,{label:a("chart.legend.show_in_legend"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})]})}function gx({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}),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=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:a,children:({field:d,index:p})=>s.jsx(xx,{control:t,index:p,watch:e,variableOptions:l,yAxisOptions:u})})}function fx({control:t,regressionItem:e,index:n,yAxisOptions:r}){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=e.transform.config.method;return s.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:`regressions.${n}.name`,control:t,render:({field:u})=>s.jsx(o.TextInput,{label:i("common.name"),required:!0,sx:{flex:1},...u})}),s.jsx(f.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(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.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(f.Controller,{name:`regressions.${n}.plot.yAxisIndex`,control:t,render:({field:{value:u,onChange:d,...p}})=>s.jsx(o.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(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`regressions.${n}.transform.config.method`,control:t,render:({field:u})=>s.jsx(o.Select,{label:i("chart.regression_line.method.label"),data:l,sx:{flex:1},...u})}),c==="polynomial"&&s.jsx(f.Controller,{name:`regressions.${n}.transform.config.order`,control:t,render:({field:u})=>s.jsx(o.NumberInput,{label:i("chart.regression_line.method.polynomial_order"),sx:{flex:1},...u})})]}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:i("chart.series.line.line_style"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:`regressions.${n}.plot.lineStyle.type`,control:t,render:({field:u})=>s.jsx(Wt,{sx:{flexGrow:1},...u})}),s.jsx(f.Controller,{name:`regressions.${n}.plot.lineStyle.width`,control:t,render:({field:u})=>s.jsx(o.NumberInput,{label:i("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...u})})]}),s.jsxs(o.Stack,{spacing:4,children:[s.jsx(o.Text,{size:"sm",children:"Color"}),s.jsx(f.Controller,{name:`regressions.${n}.plot.color`,control:t,render:({field:u})=>s.jsx(Te,{...u})})]})]})}function yx({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]),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 s.jsx(ae,{control:t,watch:e,name:"regressions",getItem:a,addButtonText:n("chart.regression_line.add"),deleteButtonText:n("chart.regression_line.delete"),renderTabName:l,children:({field:c,index:u})=>s.jsx(fx,{regressionItem:c,control:t,index:u,yAxisOptions:i})})}const bx=({value:t,onChange:e})=>{const n=r=>{r&&e(r)};return s.jsx(o.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
|
-
`)}},vx=({value:t,onChange:e})=>{const{t:n}=_.useTranslation(),[r,{setTrue:i,setFalse:a}]=G.useBoolean(),[l,c]=m.useState(t),u=()=>{a();const{type:g,func_content:y}=l,v={type:g,func_content:y};c(v),e(v)},d=()=>{a(),c(t)},p=g=>{c(y=>({...y,func_content:g}))},h=()=>{p(tr.dynamic.func_content)};return s.jsxs(s.Fragment,{children:[s.jsx(o.Box,{sx:{width:"50%"},children:s.jsx(o.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(o.Modal,{size:800,title:n("chart.symbol_size.setup.title"),opened:r,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{mt:10,mb:-10,label:n("chart.symbol_size.setup.description"),labelPosition:"center",variant:"dashed"}),s.jsx(bx,{value:l.func_content,onChange:p}),s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Button,{onClick:h,color:"red",leftIcon:s.jsx(L.Recycle,{size:20}),children:n("common.actions.reset_to_default")}),s.jsxs(o.Group,{position:"right",children:[s.jsx(o.Button,{onClick:d,variant:"subtle",children:n("common.actions.cancel")}),s.jsx(o.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),onClick:u,children:n("common.actions.save")})]})]})]})})]})},_x=({value:t,onChange:e})=>t.type!=="dynamic"?null:s.jsx(vx,{value:t,onChange:e}),jx=({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(o.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: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({...tr[u]})};return s.jsxs(o.SimpleGrid,{cols:2,children:[s.jsx(o.Select,{ref:r,label:t??i("chart.symbol_size.label"),data:l,value:e.type,onChange:c,sx:{flexGrow:1}}),s.jsx(jx,{value:e,onChange:n}),s.jsx(_x,{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 Xa(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),a=e.child(r);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=Xa(i.content,a.content,n+1);if(l!=null)return l}n+=i.nodeSize}}function Za(t,e,n,r){for(let i=t.childCount,a=e.childCount;;){if(i==0||a==0)return i==a?null:{a:n,b:r};let l=t.child(--i),c=e.child(--a),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=Za(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,a){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,a||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 a="",l=!0;return this.nodesBetween(e,n,(c,u)=>{c.isText?(a+=c.text.slice(Math.max(e,u)-u,n-u),l=!r):c.isLeaf?(i?a+=typeof i=="function"?i(c):i:c.type.spec.leafText&&(a+=c.type.spec.leafText(c)),l=!r):!l&&c.isBlock&&(a+=r,l=!0)},0),a}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),a=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),a=1);a<e.content.length;a++)i.push(e.content[a]);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 a=0,l=0;l<n;a++){let c=this.content[a],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(),a=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new H(i,a)}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 Xa(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return Za(this,e,n,r)}findIndex(e,n=-1){if(e==0)return Vn(0,e);if(e==this.size)return Vn(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 a=this.child(r),l=i+a.nodeSize;if(l>=e)return l==e||n>0?Vn(r+1,l):Vn(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 a=e[i];r+=a.nodeSize,i&&a.isText&&e[i-1].sameMarkup(a)?(n||(n=e.slice(0,i)),n[n.length-1]=a.withText(n[n.length-1].text+a.text)):n&&n.push(a)}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 Vn(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 a=e[i];if(this.eq(a))return e;if(this.type.excludes(a.type))n||(n=e.slice(0,i));else{if(a.type.excludes(this.type))return e;!r&&a.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(a)}}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 wx 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=eo(this.content,e+this.openStart,n);return r&&new ne(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ne(Ha(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 a=e.firstChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.firstChild)r++;for(let a=e.lastChild;a&&!a.isLeaf&&(n||!a.type.spec.isolating);a=a.lastChild)i++;return new ne(e,r,i)}}ne.empty=new ne(H.empty,0,0);function Ha(t,e,n){let{index:r,offset:i}=t.findIndex(e),a=t.maybeChild(r),{index:l,offset:c}=t.findIndex(n);if(i==e||a.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,a.copy(Ha(a.content,e-i-1,n-i-1)))}function eo(t,e,n,r){let{index:i,offset:a}=t.findIndex(e),l=t.maybeChild(i);if(a==e||l.isText)return r&&!r.canReplace(i,i,n)?null:t.cut(0,e).append(n).append(t.cut(e));let c=eo(l.content,e-a-1,n);return c&&t.replaceChild(i,l.copy(c))}class Nn{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 ro(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new ro(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 a=this.tags[i];if(kx(e,a.tag)&&(a.namespace===void 0||e.namespaceURI==a.namespace)&&(!a.context||n.matchesContext(a.context))){if(a.getAttrs){let l=a.getAttrs(e);if(l===!1)continue;a.attrs=l||void 0}return a}}}matchStyle(e,n,r,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(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 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 e.marks){let a=e.marks[i].spec.parseDOM;a&&a.forEach(l=>{r(l=io(l)),l.mark||l.ignore||l.clearMark||(l.mark=i)})}for(let i in e.nodes){let a=e.nodes[i].spec.parseDOM;a&&a.forEach(l=>{r(l=io(l)),l.node||l.ignore||l.mark||(l.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Nn(e,Nn.schemaRules(e)))}}const to={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},Cx={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},no={ol:!0,ul:!0},Gn=1,Fn=2,pn=4;function so(t,e,n){return e!=null?(e?Gn:0)|(e==="full"?Fn:0):t&&t.whitespace=="pre"?Gn|Fn:n&~pn}class Wn{constructor(e,n,r,i,a,l,c){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=i,this.solid=a,this.options=c,this.content=[],this.activeMarks=Ve.none,this.stashMarks=[],this.match=l||(c&pn?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&Gn)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let a=r;r.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!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):Dx(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&&!to.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class ro{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0;let i=n.topNode,a,l=so(null,n.preserveWhitespace,0)|(r?pn:0);i?a=new Wn(i.type,i.attrs,Ve.none,Ve.none,!0,n.topMatch||i.type.contentMatch,l):r?a=new Wn(null,null,Ve.none,Ve.none,!0,null,l):a=new Wn(e.schema.topNodeType,null,Ve.none,Ve.none,!0,null,l),this.nodes=[a],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(Tx(n));if(!r)return;let[i,a]=r,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(e);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(e){let n=e.nodeValue,r=this.top;if(r.options&Fn||r.inlineContext(e)||/[^ \t\r\n\u000c]/.test(n)){if(r.options&Gn)r.options&Fn?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=
|
|
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 a=void 0;;){let l=this.parser.matchStyle(e[i],e[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)&&(r=c.addToSet(r))}):n=this.parser.schema.marks[l.mark].create(l.attrs).addToSet(n),l.consuming===!1)a=l;else break}return[n,r]}addElementByRule(e,n,r){let i,a,l;n.node?(a=this.parser.schema.nodes[n.node],a.isLeaf?this.insertNode(a.create(n.attrs))||this.leafFallback(e):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(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 a=n?e.childNodes[n]:e.firstChild,l=r==null?null:e.childNodes[r];a!=l;a=a.nextSibling,++i)this.findAtPoint(e,i),this.addDOM(a);this.findAtPoint(e,i)}findPlace(e){let n,r;for(let i=this.open;i>=0;i--){let a=this.nodes[i],l=a.findWrapping(e);if(l&&(!n||n.length>l.length)&&(n=l,r=a,!l.length)||a.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 a=this.top;a.applyPending(e),a.match=a.match&&a.match.matchType(e);let l=so(e,i,a.options);a.options&pn&&a.content.length==0&&(l|=pn),this.nodes.push(new Wn(e,n,a.activeMarks,a.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),a=-(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>=a;u--)if(l(c-1,u))return!0;return!1}else{let p=u>0||u==0&&i?this.nodes[u].type:r&&u>=a?r.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 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=zx(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 Sx(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&no.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function kx(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function Tx(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 io(t){let e={};for(let n in t)e[n]=t[n];return e}function Dx(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))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==e||a.indexOf(p)<0&&l(p))return!0}};if(l(i.contentMatch))return!0}}function zx(t,e){for(let n=0;n<e.length;n++)if(t.eq(e[n]))return e[n]}const ao=65535,oo=Math.pow(2,16);function Mx(t,e){return t+e*oo}function lo(t){return t&ao}function Ix(t){return(t-(t&ao))/oo}const co=1,uo=2,Qn=4,po=8;class ho{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&po)>0}get deletedBefore(){return(this.delInfo&(co|Qn))>0}get deletedAfter(){return(this.delInfo&(uo|Qn))>0}get deletedAcross(){return(this.delInfo&Qn)>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=lo(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+Ix(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,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>e)break;let d=this.ranges[c+a],p=this.ranges[c+l],h=u+d;if(e<=h){let g=d?e==u?-1:e==h?1:n:n,y=u+i+(g<0?0:p);if(r)return y;let v=e==(n<0?u:h)?null:Mx(c/3,e-u),w=e==u?uo:e==h?co:Qn;return(n<0?e!=u:e!=h)&&(w|=po),new ho(y,w,v)}i+=p-d}return r?e+i:new ho(e+i,0,null)}touches(e,n){let r=0,i=lo(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?r:0);if(u>e)break;let d=this.ranges[c+a],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,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+r];e(c,c+d,u,u+p),a+=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(a){if(a instanceof wx)return fe.fail(a.message);throw a}}}function or(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let a=t.child(i);a.content.size&&(a=a.copy(or(a.content,e,a))),a.isInline&&(a=e(a,n,i)),r.push(a)}return H.fromArray(r)}class It 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)),a=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,a)}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 It(n.pos,r.pos,this.mark)}merge(e){return e instanceof It&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new It(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 It(n.from,n.to,e.markFromJSON(n.mark))}}Be.jsonID("addMark",It);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=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 It(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:"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 Et(n.from,n.to,e.markFromJSON(n.mark))}}Be.jsonID("removeMark",Et);class At 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 At(this.pos,n.marks[i]);return new At(this.pos,this.mark)}}return new hn(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new At(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 At(n.pos,e.markFromJSON(n.mark))}}Be.jsonID("addNodeMark",At);class hn 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 At(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new hn(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 hn(n.pos,e.markFromJSON(n.mark))}}Be.jsonID("removeNodeMark",hn);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 Pt extends Be{constructor(e,n,r,i,a,l,c=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=a,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 Pt(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),a=e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new Pt(n.pos,r.pos,i,a,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 Pt(n.from,n.to,n.gapFrom,n.gapTo,ne.fromJSON(e,n.slice),n.insert,!!n.structure)}}Be.jsonID("replaceAround",Pt);function lr(t,e,n){let r=t.resolve(e),i=n-e,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let l=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!l||l.isLeaf)return!0;l=l.firstChild,i--}}return!1}function Ex(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function Ax(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let i=t.$from.node(r),a=t.$from.index(r),l=t.$to.indexAfter(r);if(r<t.depth&&i.canReplace(a,l,n))return r;if(r==0||i.type.spec.isolating||!Ex(i,a,l))break}return null}function Rn(t,e,n=1,r){let i=t.resolve(e),a=i.depth-n,l=r&&r[r.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),g=i.index(d);if(h.type.spec.isolating)return!1;let y=h.content.cutByIndex(g,h.childCount),v=r&&r[p+1];v&&(y=y.replaceChild(0,v.type.create(v.attrs)));let w=r&&r[p]||h;if(!h.canReplace(g+1,h.childCount)||!w.type.validContent(y))return!1}let c=i.indexAfter(a),u=r&&r[0];return i.node(a).canReplaceWith(c,c,u?u.type:i.node(a+1).type)}function mo(t,e){let n=t.resolve(e),r=n.index();return Px(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Px(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}class mn 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 a in n.attrs)r[a]=n.attrs[a];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 mn(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 mn(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 mn(n.pos,n.attr,n.value)}}Be.jsonID("attr",mn);let xn=class extends Error{};xn=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n},xn.prototype=Object.create(Error.prototype),xn.prototype.constructor=xn,xn.prototype.name="TransformError";const cr=Object.create(null);class oe{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new $x(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 a=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(a);e.replaceRange(p.map(u.pos),p.map(d.pos),c?ne.empty:n),c==0&&fo(e,a,(r?r.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,n){let r=e.steps.length,i=this.ranges;for(let a=0;a<i.length;a++){let{$from:l,$to:c}=i[a],u=e.mapping.slice(r),d=u.map(l.pos),p=u.map(c.pos);a?e.deleteRange(d,p):(e.replaceRangeWith(d,p,n),fo(e,r,n.isInline?-1:1))}}static findFrom(e,n,r=!1){let i=e.parent.inlineContent?new ye(e):Qt(e.node(0),e.parent,e.pos,e.index(),n,r);if(i)return i;for(let a=e.depth-1;a>=0;a--){let l=n<0?Qt(e.node(0),e.node(a),e.before(a+1),e.index(a),n,r):Qt(e.node(0),e.node(a),e.after(a+1),e.index(a)+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 Qt(e,e,0,0,1)||new gt(e)}static atEnd(e){return Qt(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 $x{constructor(e,n){this.$from=e,this.$to=n}}let xo=!1;function go(t){!xo&&!t.parent.inlineContent&&(xo=!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){go(e),go(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 Un(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 a=oe.findFrom(n,r,!0)||oe.findFrom(n,-r,!0);if(a)n=a.$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 Un{constructor(e,n){this.anchor=e,this.head=n}map(e){return new Un(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),a=e.resolve(i);return r?oe.near(a):new Ne(a)}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 Un(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 Bx}}oe.jsonID("all",gt);const Bx={map(){return this},resolve(t){return new gt(t)}};function Qt(t,e,n,r,i,a=!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(!a&&Ne.isSelectable(c))return Ne.create(t,n-(i<0?c.nodeSize:0))}else{let u=Qt(t,c,n+i,i<0?c.childCount:0,i,a);if(u)return u}n+=c.nodeSize*i}return null}function fo(t,e,n){let r=t.steps.length-1;if(r<e)return;let i=t.steps[r];if(!(i instanceof lt||i instanceof Pt))return;let a=t.mapping.maps[r],l;a.forEach((c,u,d,p)=>{l==null&&(l=p)}),t.setSelection(oe.near(t.doc.resolve(l),n))}function yo(t,e){return!e||!t?t:t.bind(e)}class Yn{constructor(e,n,r){this.name=e,this.init=yo(n.init,r),this.apply=yo(n.apply,r)}}new Yn("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Yn("selection",{init(t,e){return t.selection||oe.atStart(e.doc)},apply(t){return t.selection}}),new Yn("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Yn("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}});function bo(t,e,n){for(let r in t){let i=t[r];i instanceof Function?i=i.bind(e):r=="handleDOMEvents"&&(i=bo(i,e,{})),n[r]=i}return n}class gn{constructor(e){this.spec=e,this.props={},e.props&&bo(e.props,this,this.props),this.key=e.key?e.key.key:vo("plugin")}getState(e){return e[this.key]}}const dr=Object.create(null);function vo(t){return t in dr?t+"$"+ ++dr[t]:(dr[t]=0,t+"$")}class fn{constructor(e="key"){this.key=vo(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}function _o(t){const{state:e,transaction:n}=t;let{selection:r}=n,{doc:i}=n,{storedMarks:a}=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 a},get selection(){return r},get doc(){return i},get tr(){return r=n.selection,i=n.doc,a=n.storedMarks,n}}}class Lx{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:a}=r,l=this.buildProps(a);return Object.fromEntries(Object.entries(e).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(e,n=!0){const{rawCommands:r,editor:i,state:a}=this,{view:l}=i,c=[],u=!!e,d=e||a.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,y])=>[g,(...w)=>{const T=this.buildProps(d,n),D=y(...w)(T);return c.push(D),h}])),run:p};return h}createCan(e){const{rawCommands:n,state:r}=this,i=!1,a=e||r.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(e,n=!0){const{rawCommands:r,editor:i,state:a}=this,{view:l}=i;a.storedMarks&&e.setStoredMarks(a.storedMarks);const c={tr:e,editor:i,view:l,state:_o({state:a,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 Ct(t,e,n){return t.config[e]===void 0&&t.parent?Ct(t.parent,e,n):typeof t.config[e]=="function"?t.config[e].bind({...n,parent:t.parent?Ct(t.parent,e,n):null}):t.config[e]}function qx(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 Ox(t){return typeof t=="function"}function Rt(t,e=void 0,...n){return Ox(t)?e?t.bind(e)(...n):t(...n):t}function Vx(t){return Object.prototype.toString.call(t)==="[object RegExp]"}function Nx(t){return Object.prototype.toString.call(t).slice(8,-1)}function pr(t){return Nx(t)!=="Object"?!1:t.constructor===Object&&Object.getPrototypeOf(t)===Object.prototype}function jo(t,e){const n={...t};return pr(t)&&pr(e)&&Object.keys(e).forEach(r=>{pr(e[r])?r in t?n[r]=jo(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=Rt(Ct(this,"addOptions",{name:this.name}))),this.storage=Rt(Ct(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(e={}){return new ct(e)}configure(e={}){const n=this.extend();return n.options=jo(this.options,e),n.storage=Rt(Ct(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=Rt(Ct(n,"addOptions",{name:n.name})),n.storage=Rt(Ct(n,"addStorage",{name:n.name,options:n.options})),n}}function Gx(t,e,n){const{from:r,to:i}=e,{blockSeparator:a=`
|
|
127
|
+
`}})}function N_(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 Ka(e,t){const n={};return t.map(s=>{const i=_t(s,e);n[s.name]=Re(s,i)}),n}function $_(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 F_(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 G_(e){if(e.length===0)return{};const t={},n={};return e.forEach(s=>{const i=F_(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 W_(e,t,n){const s=G_(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 R_={xAxis:[{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"},splitLine:{show:!1},axisTick:{show:!0,alignWithLabel:!0}}]};function Q_(e,t,n){const s=Ka(t,n),i=N_(e),a=v.uniq(vt(t,e.x_axis_data_key)),l=L_(e,a,t,i,n,s),c=k_(e,t),u={xAxis:$_(e,a),yAxis:W_(e,i,l),series:[...l,...c],tooltip:V_(e,t,l,i),grid:__(e),legend:C_(l),dataZoom:us(e.dataZoom)};return v.defaultsDeep({},u,R_)}function Nd(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 $d(e){return e.trim().length>0}function U_({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=jn(t,e.x_axis_data_key),c=nt(i.triggerManager,Qa.id),u=g.useCallback(x=>{const y=v.get(l,x.name,{error:"rowData is not found"});c.forEach(j=>{i.runInteraction(j.id,{...x,rowData:y})})},[l,c,i]),d=g.useMemo(()=>Q_(e,t,a),[e,t]),p=g.useRef(),h=g.useMemo(()=>({click:u}),[u]),f=x=>{p.current=x,Nd(x)};return g.useEffect(()=>{p.current&&Nd(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 Y_({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,Ua),[s]),l=e.data,{width:c,height:u}=e.viewport,{ref:d,height:p}=he.useElementSize(),{ref:h,height:f}=he.useElementSize(),x=g.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,wt(u)-p-f),j=jt(c);return r.jsxs(Ue,{width:c,height:u,children:[r.jsx(o.Text,{ref:d,align:"left",size:"xs",pl:"sm",sx:{display:$d(a.stats.templates.top)?"block":"none"},children:Object.values(x.top).map((k,S)=>r.jsx(g.Fragment,{children:k},S))}),r.jsx(U_,{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:$d(a.stats.templates.bottom)?"block":"none"},children:Object.values(x.bottom).map((k,S)=>r.jsx(g.Fragment,{children:k},S))})]})}function K_({control:e,index:t,variableOptions:n}){const{t:s,i18n:i}=_.useTranslation(),a=g.useMemo(()=>[{label:s("chart.reference_area.type.rectangle"),value:"rectangle"}],[i.language]),l=g.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 X_({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=g.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(K_,{control:e,index:u,variableOptions:l})})}const Jn=g.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=g.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 J_({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(fn,{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(Jn,{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 Z_({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=g.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),c=t("y_axes"),u=g.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(J_,{control:e,index:p,watch:t,variableOptions:l,yAxisOptions:u})})}function H_({control:e,regressionItem:t,index:n,yAxisOptions:s}){const{t:i,i18n:a}=_.useTranslation(),l=g.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(Jn,{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 ej({control:e,watch:t}){const{t:n}=_.useTranslation(),s=t("y_axes"),i=g.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(H_,{regressionItem:c,control:e,index:u,yAxisOptions:i})})}const tj=({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}}})})},Xa={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
|
+
`)}},nj=({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),[s,{setTrue:i,setFalse:a}]=W.useBoolean(),[l,c]=g.useState(e),u=()=>{a();const{type:f,func_content:x}=l,y={type:f,func_content:x};c(y),t(y)},d=()=>{a(),c(e)},p=f=>{c(x=>({...x,func_content:f}))},h=()=>{p(Xa.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(tj,{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")})]})]})]})})]})},rj=({value:e,onChange:t})=>e.type!=="dynamic"?null:r.jsx(nj,{value:e,onChange:t}),sj=({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})})},Ja=g.forwardRef(({label:e,value:t,onChange:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=g.useMemo(()=>[{label:i("chart.symbol_size.static"),value:"static"},{label:i("chart.symbol_size.dynamic"),value:"dynamic"}],[a.language]),c=u=>{n({...Xa[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(sj,{value:t,onChange:n}),r.jsx(rj,{value:t,onChange:n})]})}),Za={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 Fd(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=Fd(i.content,a.content,n+1);if(l!=null)return l}n+=i.nodeSize}}function Gd(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=Gd(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 Fd(this,t,n)}findDiffEnd(t,n=this.size,s=t.size){return Gd(this,t,n,s)}findIndex(t,n=-1){if(t==0)return Os(0,t);if(t==this.size)return Os(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?Os(s+1,l):Os(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 Ha={index:0,offset:0};function Os(e,t){return Ha.index=e,Ha.offset=t,Ha}function eo(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(!eo(e[s],t[s]))return!1}else{for(let s in e)if(!(s in t)||!eo(e[s],t[s]))return!1;for(let s in t)if(!(s in e))return!1}return!0}class it{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&&eo(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 it.none;if(t instanceof it)return[t];let n=t.slice();return n.sort((s,i)=>s.type.rank-i.type.rank),n}}it.none=[];class ij 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=Rd(this.content,t+this.openStart,n);return s&&new re(s,this.openStart,this.openEnd)}removeBetween(t,n){return new re(Wd(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 Wd(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(Wd(a.content,t-i-1,n-i-1)))}function Rd(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=Rd(l.content,t-a-1,n);return c&&e.replaceChild(i,l.copy(c))}class Ls{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 Kd(this,n,!1);return s.addAll(t,n.from,n.to),s.finish()}parseSlice(t,n={}){let s=new Kd(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(lj(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=Xd(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=Xd(l)),l.node||l.ignore||l.mark||(l.node=i)})}return n}static fromSchema(t){return t.cached.domParser||(t.cached.domParser=new Ls(t,Ls.schemaRules(t)))}}const Qd={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},aj={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},Ud={ol:!0,ul:!0},Bs=1,qs=2,Br=4;function Yd(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=it.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):uj(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&&!Qd.hasOwnProperty(t.parentNode.nodeName.toLowerCase())}}class Kd{constructor(t,n,s){this.parser=t,this.options=n,this.isOpen=s,this.open=0;let i=n.topNode,a,l=Yd(null,n.preserveWhitespace,0)|(s?Br:0);i?a=new Vs(i.type,i.attrs,it.none,it.none,!0,n.topMatch||i.type.contentMatch,l):s?a=new Vs(null,null,it.none,it.none,!0,null,l):a=new Vs(t.schema.topNodeType,null,it.none,it.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(cj(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;Ud.hasOwnProperty(s)&&this.parser.normalizeLists&&oj(t);let a=this.options.ruleFromNode&&this.options.ruleFromNode(t)||(i=this.parser.matchTag(t,this,n));if(a?a.ignore:aj.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(Qd.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=it.none,s=it.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=Yd(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=dj(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 oj(e){for(let t=e.firstChild,n=null;t;t=t.nextSibling){let s=t.nodeType==1?t.nodeName.toLowerCase():null;s&&Ud.hasOwnProperty(s)&&n?(n.appendChild(t),t=n):s=="li"?n=t:s&&(n=null)}}function lj(e,t){return(e.matches||e.msMatchesSelector||e.webkitMatchesSelector||e.mozMatchesSelector).call(e,t)}function cj(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 Xd(e){let t={};for(let n in e)t[n]=e[n];return t}function uj(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 dj(e,t){for(let n=0;n<t.length;n++)if(e.eq(t[n]))return t[n]}const Jd=65535,Zd=Math.pow(2,16);function pj(e,t){return e+t*Zd}function Hd(e){return e&Jd}function hj(e){return(e-(e&Jd))/Zd}const ep=1,tp=2,Ns=4,np=8;class rp{constructor(t,n,s){this.pos=t,this.delInfo=n,this.recover=s}get deleted(){return(this.delInfo&np)>0}get deletedBefore(){return(this.delInfo&(ep|Ns))>0}get deletedAfter(){return(this.delInfo&(tp|Ns))>0}get deletedAcross(){return(this.delInfo&Ns)>0}}class gt{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&>.empty)return gt.empty}recover(t){let n=0,s=Hd(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+hj(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,x=u+i+(f<0?0:p);if(s)return x;let y=t==(n<0?u:h)?null:pj(c/3,t-u),j=t==u?tp:t==h?ep:Ns;return(n<0?t!=u:t!=h)&&(j|=np),new rp(x,j,y)}i+=p-d}return s?t+i:new rp(t+i,0,null)}touches(t,n){let s=0,i=Hd(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 gt(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(t){return t==0?gt.empty:new gt(t<0?[0,-t,0]:[0,0,t])}}gt.empty=new gt([]);const to=Object.create(null);class et{getMap(){return gt.empty}merge(t){return null}static fromJSON(t,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let s=to[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 to)throw new RangeError("Duplicate use of step JSON ID "+t);return to[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 ij)return ke.fail(a.message);throw a}}}function no(e,t,n){let s=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(no(a.content,t,a))),a.isInline&&(a=t(a,n,i)),s.push(a)}return H.fromArray(s)}class Sn 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(no(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 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 Sn(n.pos,s.pos,this.mark)}merge(t){return t instanceof Sn&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new Sn(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 Sn(n.from,n.to,t.markFromJSON(n.mark))}}et.jsonID("addMark",Sn);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=new re(no(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 Sn(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:"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 kn(n.from,n.to,t.markFromJSON(n.mark))}}et.jsonID("removeMark",kn);class Tn 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 Tn(this.pos,n.marks[i]);return new Tn(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 Tn(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 Tn(n.pos,t.markFromJSON(n.mark))}}et.jsonID("addNodeMark",Tn);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 Tn(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 qt 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&&ro(t,this.from,this.to)?ke.fail("Structure replace would overwrite content"):ke.fromReplace(t,this.from,this.to,this.slice)}getMap(){return new gt([this.from,this.to-this.from,this.slice.size])}invert(t){return new qt(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 qt(n.pos,Math.max(n.pos,s.pos),this.slice)}merge(t){if(!(t instanceof qt)||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 qt(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 qt(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 qt(n.from,n.to,re.fromJSON(t,n.slice),!!n.structure)}}et.jsonID("replace",qt);class Dn 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&&(ro(t,this.from,this.gapFrom)||ro(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 gt([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 Dn(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 Dn(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 Dn(n.from,n.to,n.gapFrom,n.gapTo,re.fromJSON(t,n.slice),n.insert,!!n.structure)}}et.jsonID("replaceAround",Dn);function ro(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 fj(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function gj(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||!fj(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 x=h.content.cutByIndex(f,h.childCount),y=s&&s[p+1];y&&(x=x.replaceChild(0,y.type.create(y.attrs)));let j=s&&s[p]||h;if(!h.canReplace(f+1,h.childCount)||!j.type.validContent(x))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 sp(e,t){let n=e.resolve(t),s=n.index();return mj(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(s,s+1)}function mj(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 gt.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 so=Object.create(null);class ge{constructor(t,n,s){this.$anchor=t,this.$head=n,this.ranges=s||[new xj(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&&op(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),op(t,s,n.isInline?-1:1))}}static findFrom(t,n,s=!1){let i=t.parent.inlineContent?new Te(t):Zn(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?Zn(t.node(0),t.node(a),t.before(a+1),t.index(a),n,s):Zn(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 Xt(t.node(0))}static atStart(t){return Zn(t,t,0,0,1)||new Xt(t)}static atEnd(t){return Zn(t,t,t.content.size,t.childCount,-1)||new Xt(t)}static fromJSON(t,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let s=so[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 so)throw new RangeError("Duplicate use of selection JSON ID "+t);return so[t]=n,n.prototype.jsonID=t,n}getBookmark(){return Te.between(this.$anchor,this.$head).getBookmark()}}ge.prototype.visible=!0;class xj{constructor(t,n){this.$from=t,this.$to=n}}let ip=!1;function ap(e){!ip&&!e.parent.inlineContent&&(ip=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+e.parent.type.name+")"))}class Te extends ge{constructor(t,n=t){ap(t),ap(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 ge.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=ge.findFrom(n,s,!0)||ge.findFrom(n,-s,!0);if(a)n=a.$head;else return ge.near(n,s)}return t.parent.inlineContent||(i==0?t=n:(t=(ge.findFrom(t,-s,!0)||ge.findFrom(t,s,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new Te(t,n)}}ge.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 at extends ge{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?ge.near(a):new at(a)}content(){return new re(H.from(this.node),0,0)}eq(t){return t instanceof at&&t.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new io(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new at(t.resolve(n.anchor))}static create(t,n){return new at(t.resolve(n))}static isSelectable(t){return!t.isText&&t.type.spec.selectable!==!1}}at.prototype.visible=!1,ge.jsonID("node",at);class io{constructor(t){this.anchor=t}map(t){let{deleted:n,pos:s}=t.mapResult(this.anchor);return n?new Fs(s,s):new io(s)}resolve(t){let n=t.resolve(this.anchor),s=n.nodeAfter;return s&&at.isSelectable(s)?new at(n):ge.near(n)}}class Xt extends ge{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=ge.atStart(t.doc);s.eq(t.selection)||t.setSelection(s)}else super.replace(t,n)}toJSON(){return{type:"all"}}static fromJSON(t){return new Xt(t)}map(t){return new Xt(t)}eq(t){return t instanceof Xt}getBookmark(){return yj}}ge.jsonID("all",Xt);const yj={map(){return this},resolve(e){return new Xt(e)}};function Zn(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&&at.isSelectable(c))return at.create(e,n-(i<0?c.nodeSize:0))}else{let u=Zn(e,c,n+i,i<0?c.childCount:0,i,a);if(u)return u}n+=c.nodeSize*i}return null}function op(e,t,n){let s=e.steps.length-1;if(s<t)return;let i=e.steps[s];if(!(i instanceof qt||i instanceof Dn))return;let a=e.mapping.maps[s],l;a.forEach((c,u,d,p)=>{l==null&&(l=p)}),e.setSelection(ge.near(e.doc.resolve(l),n))}function lp(e,t){return!t||!e?e:e.bind(t)}class Gs{constructor(t,n,s){this.name=t,this.init=lp(n.init,s),this.apply=lp(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||ge.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 cp(e,t,n){for(let s in e){let i=e[s];i instanceof Function?i=i.bind(t):s=="handleDOMEvents"&&(i=cp(i,t,{})),n[s]=i}return n}class $r{constructor(t){this.spec=t,this.props={},t.props&&cp(t.props,this,this.props),this.key=t.key?t.key.key:up("plugin")}getState(t){return t[this.key]}}const ao=Object.create(null);function up(e){return e in ao?e+"$"+ ++ao[e]:(ao[e]=0,e+"$")}class Fr{constructor(t="key"){this.key=up(t)}get(t){return t.config.pluginsByKey[this.key]}getState(t){return t[this.key]}}function dp(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 bj{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,x])=>[f,(...j)=>{const k=this.buildProps(d,n),S=x(...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:dp({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 gn(e,t,n){return e.config[t]===void 0&&e.parent?gn(e.parent,t,n):typeof e.config[t]=="function"?e.config[t].bind({...n,parent:e.parent?gn(e.parent,t,n):null}):e.config[t]}function vj(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 _j(e){return typeof e=="function"}function Hn(e,t=void 0,...n){return _j(e)?t?e.bind(t)(...n):e(...n):e}function jj(e){return Object.prototype.toString.call(e)==="[object RegExp]"}function wj(e){return Object.prototype.toString.call(e).slice(8,-1)}function oo(e){return wj(e)!=="Object"?!1:e.constructor===Object&&Object.getPrototypeOf(e)===Object.prototype}function pp(e,t){const n={...e};return oo(e)&&oo(t)&&Object.keys(t).forEach(s=>{oo(t[s])?s in e?n[s]=pp(e[s],t[s]):Object.assign(n,{[s]:t[s]}):Object.assign(n,{[s]:t[s]})}),n}class Vt{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=Hn(gn(this,"addOptions",{name:this.name}))),this.storage=Hn(gn(this,"addStorage",{name:this.name,options:this.options}))||{}}static create(t={}){return new Vt(t)}configure(t={}){const n=this.extend();return n.options=pp(this.options,t),n.storage=Hn(gn(n,"addStorage",{name:n.name,options:n.options})),n}extend(t={}){const n=new Vt(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=Hn(gn(n,"addOptions",{name:n.name})),n.storage=Hn(gn(n,"addStorage",{name:n.name,options:n.options})),n}}function Cj(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 y;const v=l==null?void 0:l[d.type.name];v?(d.isBlock&&!u&&(c+=a,u=!0),h&&(c+=v({node:d,pos:p,parent:h,index:g,range:e}))):d.isText?(c+=(y=d==null?void 0:d.text)===null||y===void 0?void 0:y.slice(Math.max(r,p)-p,i-p),u=!1):d.isBlock&&!u&&(c+=a,u=!0)}),c}function Fx(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 gn({key:new fn("clipboardTextSerializer"),props:{clipboardTextSerializer:()=>{const{editor:t}=this,{state:e,schema:n}=t,{doc:r,selection:i}=e,{ranges:a}=i,l=Math.min(...a.map(p=>p.$from.pos)),c=Math.max(...a.map(p=>p.$to.pos)),u=Fx(n);return Gx(r,{from:l,to:c},{textSerializers:u})}}})]}});const Wx=()=>({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),Qx=(t=!1)=>({commands:e})=>e.setContent("",t),Rx=()=>({state:t,tr:e,dispatch:n})=>{const{selection:r}=e,{ranges:i}=r;return n&&i.forEach(({$from:a,$to:l})=>{t.doc.nodesBetween(a.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)),y=h.blockRange(g);if(!y)return;const v=Ax(y);if(c.type.isTextblock){const{defaultType:w}=h.parent.contentMatchAt(h.index());e.setNodeMarkup(y.start,w)}(v||v===0)&&e.lift(y,v)})}),!0},Ux=t=>e=>t(e),Yx=()=>({state:t,dispatch:e})=>ve.createParagraphNear(t,e),Kx=()=>({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 a=i.depth;a>0;a-=1)if(i.node(a).type===r.type){if(e){const c=i.before(a),u=i.after(a);t.delete(c,u).scrollIntoView()}return!0}return!1},Jx=t=>({tr:e,state:n,dispatch:r})=>{const i=De(t,n.schema),a=e.selection.$anchor;for(let l=a.depth;l>0;l-=1)if(a.node(l).type===i){if(r){const u=a.before(l),d=a.after(l);e.delete(u,d).scrollIntoView()}return!0}return!1},Xx=t=>({tr:e,dispatch:n})=>{const{from:r,to:i}=t;return n&&e.delete(r,i),!0},Zx=()=>({state:t,dispatch:e})=>ve.deleteSelection(t,e),Hx=()=>({commands:t})=>t.keyboardShortcut("Enter"),eg=()=>({state:t,dispatch:e})=>ve.exitCode(t,e);function Kn(t,e,n={strict:!0}){const r=Object.keys(e);return r.length?r.every(i=>n.strict?e[i]===t[i]:Vx(e[i])?e[i].test(t[i]):e[i]===t[i]):!0}function hr(t,e,n={}){return t.find(r=>r.type===e&&Kn(r.attrs,n))}function tg(t,e,n={}){return!!hr(t,e,n)}function wo(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 a=r.index,l=t.start()+r.offset,c=a+1,u=l+r.node.nodeSize;for(hr([...r.node.marks],e,n);a>0&&i.isInSet(t.parent.child(a-1).marks);)a-=1,l-=t.parent.child(a).nodeSize;for(;c<t.parent.childCount&&tg([...t.parent.child(c).marks],e,n);)u+=t.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function St(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 ng=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const a=St(t,r.schema),{doc:l,selection:c}=n,{$from:u,from:d,to:p}=c;if(i){const h=wo(u,a,e);if(h&&h.from<=d&&h.to>=p){const g=ye.create(l,h.from,h.to);n.setSelection(g)}}return!0},sg=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 Co(t){return t instanceof ye}function $t(t=0,e=0,n=0){return Math.min(Math.max(t,e),n)}function rg(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,a=r.to;return e==="all"?ye.create(t,$t(0,i,a),$t(t.content.size,i,a)):ye.create(t,$t(e,i,a),$t(e,i,a))}function mr(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const ig=(t=null,e={})=>({editor:n,view:r,tr:i,dispatch:a})=>{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(a&&t===null&&!Co(n.state.selection))return l(),!0;const c=rg(i.doc,t)||n.state.selection,u=n.state.selection.eq(c);return a&&(u||i.setSelection(c),u&&i.storedMarks&&i.setStoredMarks(i.storedMarks),l()),!0},ag=(t,e)=>n=>t.every((r,i)=>e(r,{...n,index:i})),og=(t,e)=>({tr:n,commands:r})=>r.insertContentAt({from:n.selection.from,to:n.selection.to},t,e);function So(t){const e=`<body>${t}</body>`;return new window.DOMParser().parseFromString(e,"text/html").body}function Jn(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),Jn("",e,n)}if(typeof t=="string"){const r=Nn.fromSchema(e);return n.slice?r.parseSlice(So(t),n.parseOptions).content:r.parse(So(t),n.parseOptions)}return Jn("",e,n)}function lg(t,e,n){const r=t.steps.length-1;if(r<e)return;const i=t.steps[r];if(!(i instanceof lt||i instanceof Pt))return;const a=t.mapping.maps[r];let l=0;a.forEach((c,u,d,p)=>{l===0&&(l=p)}),t.setSelection(oe.near(t.doc.resolve(l),n))}const cg=t=>t.toString().startsWith("<"),ug=(t,e,n)=>({tr:r,dispatch:i,editor:a})=>{if(i){n={parseOptions:{},updateSelection:!0,...n};const l=Jn(e,a.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((cg(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&&lg(r,r.steps.length-1,-1)}return!0},dg=()=>({state:t,dispatch:e})=>ve.joinUp(t,e),pg=()=>({state:t,dispatch:e})=>ve.joinDown(t,e),hg=()=>({state:t,dispatch:e})=>ve.joinBackward(t,e),mg=()=>({state:t,dispatch:e})=>ve.joinForward(t,e);function ko(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function xg(t){const e=t.split(/-(?!$)/);let n=e[e.length-1];n==="Space"&&(n=" ");let r,i,a,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))a=!0;else if(/^mod$/i.test(u))mr()||ko()?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}`),a&&(n=`Shift-${n}`),n}const gg=t=>({editor:e,view:n,tr:r,dispatch:i})=>{const a=xg(t).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=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:a}=t.selection,l=e?De(e,t.schema):null,c=[];t.doc.nodesBetween(r,i,(h,g)=>{if(h.isText)return;const y=Math.max(r,g),v=Math.min(i,g+h.nodeSize);c.push({node:h,from:y,to:v})});const u=i-r,d=c.filter(h=>l?l.name===h.node.type.name:!0).filter(h=>Kn(h.node.attrs,n,{strict:!1}));return a?!!d.length:d.reduce((h,g)=>h+g.to-g.from,0)>=u}const fg=(t,e={})=>({state:n,dispatch:r})=>{const i=De(t,n.schema);return xr(n,i,e)?ve.lift(n,r):!1},yg=()=>({state:t,dispatch:e})=>ve.liftEmptyBlock(t,e),bg=t=>({state:e,dispatch:n})=>{const r=De(t,e.schema);return Cs.liftListItem(r)(e,n)},vg=()=>({state:t,dispatch:e})=>ve.newlineInCode(t,e);function To(t,e){return e.nodes[t]?"node":e.marks[t]?"mark":null}function Do(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 _g=(t,e)=>({tr:n,state:r,dispatch:i})=>{let a=null,l=null;const c=To(typeof t=="string"?t:t.name,r.schema);return c?(c==="node"&&(a=De(t,r.schema)),c==="mark"&&(l=St(t,r.schema)),i&&n.selection.ranges.forEach(u=>{r.doc.nodesBetween(u.$from.pos,u.$to.pos,(d,p)=>{a&&a===d.type&&n.setNodeMarkup(p,void 0,Do(d.attrs,e)),l&&d.marks.length&&d.marks.forEach(h=>{l===h.type&&n.addMark(p,p+d.nodeSize,l.create(Do(h.attrs,e)))})})}),!0):!1},jg=()=>({tr:t,dispatch:e})=>(e&&t.scrollIntoView(),!0),wg=()=>({tr:t,commands:e})=>e.setTextSelection({from:0,to:t.doc.content.size}),Cg=()=>({state:t,dispatch:e})=>ve.selectNodeBackward(t,e),Sg=()=>({state:t,dispatch:e})=>ve.selectNodeForward(t,e),kg=()=>({state:t,dispatch:e})=>ve.selectParentNode(t,e),Tg=()=>({state:t,dispatch:e})=>ve.selectTextblockEnd(t,e),Dg=()=>({state:t,dispatch:e})=>ve.selectTextblockStart(t,e);function zg(t,e,n={}){return Jn(t,e,{slice:!1,parseOptions:n})}const Mg=(t,e=!1,n={})=>({tr:r,editor:i,dispatch:a})=>{const{doc:l}=r,c=zg(t,i.schema,n);return a&&r.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!e),!0};function Ig(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 Eg(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=>Eg(e.$from,t)}function Ag(t,e){const n=St(e,t.schema),{from:r,to:i,empty:a}=t.selection,l=[];a?(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 Xn(t,e,n){return Object.fromEntries(Object.entries(n).filter(([r])=>{const i=t.find(a=>a.type===e&&a.name===r);return i?i.attribute.keepOnSplit:!1}))}function Pg(t,e,n={}){const{empty:r,ranges:i}=t.selection,a=e?St(e,t.schema):null;if(r)return!!(t.storedMarks||t.selection.$from.marks()).filter(h=>a?a.name===h.type.name:!0).find(h=>Kn(h.attrs,n,{strict:!1}));let l=0;const c=[];if(i.forEach(({$from:h,$to:g})=>{const y=h.pos,v=g.pos;t.doc.nodesBetween(y,v,(w,T)=>{if(!w.isText&&!w.marks.length)return;const D=Math.max(y,T),I=Math.min(v,T+w.nodeSize),A=I-D;l+=A,c.push(...w.marks.map(N=>({mark:N,from:D,to:I})))})}),l===0)return!1;const u=c.filter(h=>a?a.name===h.mark.type.name:!0).filter(h=>Kn(h.mark.attrs,n,{strict:!1})).reduce((h,g)=>h+g.to-g.from,0),d=c.filter(h=>a?h.mark.type!==a&&h.mark.type.excludes(a):!0).reduce((h,g)=>h+g.to-g.from,0);return(u>0?u+d:u)>=l}function zo(t,e){const{nodeExtensions:n}=qx(e),r=n.find(l=>l.name===t);if(!r)return!1;const i={name:r.name,options:r.options,storage:r.storage},a=Rt(Ct(r,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function $g(t,e,n){var r;const{selection:i}=e;let a=null;if(Co(i)&&(a=i.$cursor),a){const c=(r=t.storedMarks)!==null&&r!==void 0?r: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?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 y=!g||g.type.allowsMarkType(n),v=!!n.isInSet(p.marks)||!p.marks.some(w=>w.type.excludes(n));d=y&&v}return!d}),d})}const Bg=(t,e={})=>({tr:n,state:r,dispatch:i})=>{const{selection:a}=n,{empty:l,ranges:c}=a,u=St(t,r.schema);if(i)if(l){const d=Ag(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,y)=>{const v=Math.max(y,p),w=Math.min(y+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 $g(r,n,u)},Lg=(t,e)=>({tr:n})=>(n.setMeta(t,e),!0),qg=(t,e={})=>({state:n,dispatch:r,chain:i})=>{const a=De(t,n.schema);return a.isTextblock?i().command(({commands:l})=>ve.setBlockType(a,e)(n)?!0:l.clearNodes()).command(({state:l})=>ve.setBlockType(a,e)(l,r)).run():(console.warn('[tiptap warn]: Currently "setNode()" only supports text block nodes.'),!1)},Og=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,i=$t(t,0,r.content.size),a=Ne.create(r,i);e.setSelection(a)}return!0},Vg=t=>({tr:e,dispatch:n})=>{if(n){const{doc:r}=e,{from:i,to:a}=typeof t=="number"?{from:t,to:t}:t,l=ye.atStart(r).from,c=ye.atEnd(r).to,u=$t(i,l,c),d=$t(a,l,c),p=ye.create(r,u,d);e.setSelection(p)}return!0},Ng=t=>({state:e,dispatch:n})=>{const r=De(t,e.schema);return Cs.sinkListItem(r)(e,n)};function Mo(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 Gg=({keepMarks:t=!0}={})=>({tr:e,state:n,dispatch:r,editor:i})=>{const{selection:a,doc:l}=e,{$from:c,$to:u}=a,d=i.extensionManager.attributes,p=Xn(d,c.node().type.name,c.node().attrs);if(a instanceof Ne&&a.node.isBlock)return!c.parentOffset||!Rn(l,c.pos)?!1:(r&&(t&&Mo(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;a instanceof ye&&e.deleteSelection();const g=c.depth===0?void 0:Ig(c.node(-1).contentMatchAt(c.indexAfter(-1)));let y=h&&g?[{type:g,attrs:p}]:void 0,v=Rn(e.doc,e.mapping.map(c.pos),1,y);if(!y&&!v&&Rn(e.doc,e.mapping.map(c.pos),1,g?[{type:g}]:void 0)&&(v=!0,y=g?[{type:g,attrs:p}]:void 0),v&&(e.split(e.mapping.map(c.pos),1,y),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&&Mo(n,i.extensionManager.splittableMarks),e.scrollIntoView()}return!0},Fg=t=>({tr:e,state:n,dispatch:r,editor:i})=>{var a;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 I=c.indexAfter(-1)<c.node(-2).childCount?1:c.indexAfter(-2)<c.node(-3).childCount?2:3,A=Xn(h,c.node().type.name,c.node().attrs),N=((a=l.contentMatch.defaultType)===null||a===void 0?void 0:a.createAndFill(A))||void 0;T=T.append(H.from(l.createAndFill(null,N)||void 0));const R=c.before(c.depth-(D-1));e.replace(R,c.after(-I),new ne(T,4-D,0));let F=-1;e.doc.nodesBetween(R,e.doc.content.size,(Q,ue)=>{if(F>-1)return!1;Q.isTextblock&&Q.content.size===0&&(F=ue+1)}),F>-1&&e.setSelection(ye.near(e.doc.resolve(F))),e.scrollIntoView()}return!0}const g=u.pos===c.end()?p.contentMatchAt(0).defaultType:null,y=Xn(h,p.type.name,p.attrs),v=Xn(h,c.node().type.name,c.node().attrs);e.delete(c.pos,u.pos);const w=g?[{type:l,attrs:y},{type:g,attrs:v}]:[{type:l,attrs:y}];if(!Rn(e.doc,c.pos,2))return!1;if(r){const{selection:T,storedMarks:D}=n,{splittableMarks:I}=i.extensionManager,A=D||T.$to.parentOffset&&T.$from.marks();if(e.split(c.pos,2,w).scrollIntoView(),!A||!r)return!0;const N=A.filter(R=>I.includes(R.type.name));e.ensureMarks(N)}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)&&mo(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)&&mo(t.doc,r)&&t.join(r),!0};var Wg=Object.freeze({__proto__:null,blur:Wx,clearContent:Qx,clearNodes:Rx,command:Ux,createParagraphNear:Yx,deleteCurrentNode:Kx,deleteNode:Jx,deleteRange:Xx,deleteSelection:Zx,enter:Hx,exitCode:eg,extendMarkRange:ng,first:sg,focus:ig,forEach:ag,insertContent:og,insertContentAt:ug,joinUp:dg,joinDown:pg,joinBackward:hg,joinForward:mg,keyboardShortcut:gg,lift:fg,liftEmptyBlock:yg,liftListItem:bg,newlineInCode:vg,resetAttributes:_g,scrollIntoView:jg,selectAll:wg,selectNodeBackward:Cg,selectNodeForward:Sg,selectParentNode:kg,selectTextblockEnd:Tg,selectTextblockStart:Dg,setContent:Mg,setMark:Bg,setMeta:Lg,setNode:qg,setNodeSelection:Og,setTextSelection:Vg,sinkListItem:Ng,splitBlock:Gg,splitListItem:Fg,toggleList:(t,e,n,r={})=>({editor:i,tr:a,state:l,dispatch:c,chain:u,commands:d,can:p})=>{const{extensions:h,splittableMarks:g}=i.extensionManager,y=De(t,l.schema),v=De(e,l.schema),{selection:w,storedMarks:T}=l,{$from:D,$to:I}=w,A=D.blockRange(I),N=T||w.$to.parentOffset&&w.$from.marks();if(!A)return!1;const R=gr(F=>zo(F.type.name,h))(w);if(A.depth>=1&&R&&A.depth-R.depth<=1){if(R.node.type===y)return d.liftListItem(v);if(zo(R.node.type.name,h)&&y.validContent(R.node.content)&&c)return u().command(()=>(a.setNodeMarkup(R.pos,y),!0)).command(()=>fr(a,y)).command(()=>yr(a,y)).run()}return!n||!N||!c?u().command(()=>p().wrapInList(y,r)?!0:d.clearNodes()).wrapInList(y,r).command(()=>fr(a,y)).command(()=>yr(a,y)).run():u().command(()=>{const F=p().wrapInList(y,r),Q=N.filter(ue=>g.includes(ue.type.name));return a.ensureMarks(Q),F?!0:d.clearNodes()}).wrapInList(y,r).command(()=>fr(a,y)).command(()=>yr(a,y)).run()},toggleMark:(t,e={},n={})=>({state:r,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,l=St(t,r.schema);return Pg(r,l,e)?i.unsetMark(l,{extendEmptyMarkRange:a}):i.setMark(l,e)},toggleNode:(t,e,n={})=>({state:r,commands:i})=>{const a=De(t,r.schema),l=De(e,r.schema);return xr(r,a,n)?i.setNode(l):i.setNode(a,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 a;if(i.spec.isInputRules&&(a=i.getState(t))){if(e){const l=t.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,t.schema.text(a.text,u))}else l.delete(a.from,a.to)}return!0}}return!1},unsetAllMarks:()=>({tr:t,dispatch:e})=>{const{selection:n}=t,{empty:r,ranges:i}=n;return r||e&&i.forEach(a=>{t.removeMark(a.$from.pos,a.$to.pos)}),!0},unsetMark:(t,e={})=>({tr:n,state:r,dispatch:i})=>{var a;const{extendEmptyMarkRange:l=!1}=e,{selection:c}=n,u=St(t,r.schema),{$from:d,empty:p,ranges:h}=c;if(!i)return!0;if(p&&l){let{from:g,to:y}=c;const v=(a=d.marks().find(T=>T.type===u))===null||a===void 0?void 0:a.attrs,w=wo(d,u,v);w&&(g=w.from,y=w.to),n.removeMark(g,y,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 a=null,l=null;const c=To(typeof t=="string"?t:t.name,r.schema);return c?(c==="node"&&(a=De(t,r.schema)),c==="mark"&&(l=St(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)=>{a&&a===h.type&&n.setNodeMarkup(g,void 0,{...h.attrs,...e}),l&&h.marks.length&&h.marks.forEach(y=>{if(l===y.type){const v=Math.max(g,d),w=Math.min(g+h.nodeSize,p);n.addMark(v,w,l.create({...y.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{...Wg}}}),ct.create({name:"editable",addProseMirrorPlugins(){return[new gn({key:new fn("editable"),props:{editable:()=>this.editor.options.editable}})]}}),ct.create({name:"focusEvents",addProseMirrorPlugins(){const{editor:t}=this;return[new gn({key:new fn("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:y}=h,v=oe.atStart(d).from===g;return!p||!v||!y.type.isTextblock||y.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},a={...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()||ko()?a:i},addProseMirrorPlugins(){return[new gn({key:new fn("clearDocument"),appendTransaction:(t,e,n)=>{if(!(t.some(v=>v.docChanged)&&!e.doc.eq(n.doc)))return;const{empty:i,from:a,to:l}=e.selection,c=oe.atStart(e.doc).from,u=oe.atEnd(e.doc).to;if(i||!(a===c&&l===u)||!(n.doc.textBetween(0,n.doc.content.size," "," ").length===0))return;const h=n.tr,g=_o({state:n,transaction:h}),{commands:y}=new Lx({editor:this.editor,state:g});if(y.clearNodes(),!!h.steps.length)return h}})]}}),ct.create({name:"tabindex",addProseMirrorPlugins(){return[new gn({key:new fn("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});const Io=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()}}}),Qg=["8","10","12","14","16","18","20","24","30","36","48","60","72"].map(t=>`${t}px`),Rg=[{label:"auto",value:""}].concat(Qg.map(t=>({label:t,value:t}))),Ug={input:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"}},Yg=({editor:t})=>{const e=t.getAttributes("textStyle").fontSize;return s.jsx(W.RichTextEditor.ControlsGroup,{children:s.jsx(o.NativeSelect,{size:"xs",icon:s.jsx(k.IconTextSize,{stroke:1.5,size:16}),data:Rg,styles:Ug,value:e||"",onChange:n=>{const r=n.currentTarget.value;r?t.chain().focus().setFontSize(r).run():t.chain().focus().unsetFontSize().run()}})})},Zn=({value:t,styles:e={},sx:n={}})=>{const r=aa.useEditor({extensions:[oa,ia,W.Link,Zi,Xi,Ki,ta.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),ra,sa,na,Hi.configure({types:["heading","paragraph"]}),Ji.configure({placeholder:"This is placeholder"}),ea,Yi.Color,Io],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(W.RichTextEditor,{editor:r,styles:i,sx:n,children:s.jsx(W.RichTextEditor.Content,{})})};function Eo(){const{t}=_.useTranslation(),[e,{open:n,close:r}]=ie.useDisclosure(!1);return s.jsxs(s.Fragment,{children:[s.jsx(o.Modal,{opened:e,onClose:r,title:t("function_utils.modal_title"),zIndex:330,withinPortal:!0,children:s.jsx(Zn,{value:kd(t),styles:{root:{border:"none"},content:{padding:0,table:{marginBottom:0}}}})}),s.jsx(o.Button,{variant:"light",color:"violet",size:"xs",onClick:n,leftIcon:s.jsx(k.IconInfoCircle,{size:16}),children:t("function_utils.trigger_text")})]})}const Kg=({value:t,onChange:e})=>{const n=r=>{if(!r){e("");return}e(r)};return s.jsx(o.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}}})})},Ut=m.forwardRef(({value:t,onChange:e,label:n,defaultValue:r},i)=>{const{t:a}=_.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(o.Stack,{spacing:4,sx:{height:"100%"},children:[s.jsxs(o.Group,{mb:6,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[s.jsx(o.Group,{position:"left",children:s.jsx(Eo,{})}),s.jsxs(o.Group,{position:"right",children:[s.jsx(o.Button,{onClick:p,size:"xs",variant:"default",leftIcon:s.jsx(k.IconPlayerSkipBack,{size:16}),children:a("common.actions.reset_to_default")}),s.jsx(o.Button,{onClick:d,color:"red",size:"xs",disabled:!h,leftIcon:s.jsx(k.IconRecycle,{size:16}),children:a("common.actions.revert_changes")}),s.jsx(o.Button,{color:"green",size:"xs",onClick:u,disabled:!h,leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),children:a("common.actions.save_changes")})]})]}),s.jsx(o.Text,{size:14,children:n}),s.jsx(Kg,{value:l,onChange:c})]})}),Ao=m.forwardRef(({title:t,value:e,onChange:n,label:r,description:i=null,triggerLabel:a="Edit",triggerButtonProps:l={},defaultValue:c},u)=>{const[d,{open:p,close:h}]=ie.useDisclosure(!1);return s.jsxs(s.Fragment,{children:[s.jsxs(o.Modal,{opened:d,onClose:h,title:t,withinPortal:!0,zIndex:320,size:"900px",children:[i,s.jsx(o.Box,{h:600,children:s.jsx(Ut,{value:e,onChange:n,defaultValue:c,label:r})})]}),s.jsx(o.Button,{onClick:p,...l,children:a})]})});function Jg({label:t,value:e,onChange:n,pt:r="sm",withFallback:i},a){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:ya},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})},y=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(o.Group,{grow:!0,noWrap:!0,pt:r,children:[s.jsx(o.Select,{ref:a,label:t,data:y,value:e.type,onChange:u,maxDropdownHeight:600}),e.type==="quantile"&&s.jsx(o.NumberInput,{label:"p",value:e.config.p,onChange:d,precision:2,min:.05,step:.05,max:1}),e.type==="pick_record"&&s.jsx(o.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(Ao,{title:l("aggregation.option.custom.title"),label:"",triggerLabel:l("aggregation.option.custom.label_trigger"),value:e.config.func,onChange:p,defaultValue:ya,triggerButtonProps:{size:"xs",sx:{flexGrow:0,alignSelf:"center",marginTop:"22px"},leftIcon:s.jsx(k.IconMathFunction,{size:16}),color:"grape"}})]}),i&&s.jsx(o.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(Jg),Yt=m.forwardRef(({label:t,value:e,onChange:n,options:r,withOffOption:i=!1},a)=>{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(o.Select,{ref:a,label:t,data:u,value:e,onChange:n})});function Xg({control:t,index:e,seriesItem:n}){const{t:r,i18n:i}=_.useTranslation(),a=!!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(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`series.${e}.stack`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:r("chart.series.bar.stack"),placeholder:r("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),s.jsx(f.Controller,{name:`series.${e}.barGap`,control:t,render:({field:c})=>s.jsx(o.Select,{label:r("chart.series.bar.bar_gap.label"),data:l,sx:{flexGrow:1},...c})})]}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`series.${e}.barMinWidth`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:r("chart.series.bar.bar_width.min"),disabled:a,sx:{flexGrow:1},...c})}),s.jsx(f.Controller,{name:`series.${e}.barWidth`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:r("chart.series.bar.bar_width.exact"),sx:{flexGrow:1},...c})}),s.jsx(f.Controller,{name:`series.${e}.barMaxWidth`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:r("chart.series.bar.bar_width.max"),disabled:a,sx:{flexGrow:1},...c})})]})]})}function Zg({control:t,index:e,seriesItem:n}){const{t:r,i18n:i}=_.useTranslation(),a=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(o.Divider,{mb:-15,variant:"dashed",label:r("chart.series.line.line_settings"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:`series.${e}.lineStyle.type`,control:t,render:({field:c})=>s.jsx(Wt,{sx:{flexGrow:1},...c})}),s.jsx(f.Controller,{name:`series.${e}.lineStyle.width`,control:t,render:({field:c})=>s.jsx(o.NumberInput,{label:r("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),s.jsxs(o.Group,{grow:!0,align:"center",children:[s.jsx(f.Controller,{name:`series.${e}.step`,control:t,render:({field:c})=>s.jsx(o.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(o.Stack,{children:[s.jsx(f.Controller,{name:`series.${e}.smooth`,control:t,render:({field:c})=>s.jsx(o.Box,{sx:{flexGrow:1},children:s.jsx(o.Switch,{label:r("chart.series.line.smooth_line"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})}),s.jsx(f.Controller,{name:`series.${e}.display_name_on_line`,control:t,render:({field:c})=>s.jsx(o.Box,{sx:{flexGrow:1},children:s.jsx(o.Switch,{label:r("chart.series.line.show_name_on_line"),checked:c.value??!1,onChange:u=>c.onChange(u.currentTarget.checked)})})})]})]}),s.jsxs(o.Stack,{children:[s.jsx(f.Controller,{name:`series.${e}.showSymbol`,control:t,render:({field:c})=>s.jsx(o.Box,{mt:10,mb:-10,sx:{flexGrow:1},children:s.jsx(o.Switch,{label:r("chart.series.line.show_symbol_on_line"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})}),a&&s.jsx(f.Controller,{name:`series.${e}.symbolSize`,control:t,render:({field:c})=>s.jsx(nr,{...c})})]})]})}function Hg({control:t,index:e}){return s.jsx(f.Controller,{name:`series.${e}.symbolSize`,control:t,render:({field:n})=>s.jsx(nr,{label:"Size",...n})})}function ef({control:t,index:e,seriesItem:n,yAxisOptions:r}){const{t:i}=_.useTranslation(),a=n.type;return s.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[s.jsx(o.Stack,{children:s.jsx(f.Controller,{name:`series.${e}.type`,control:t,render:({field:l})=>s.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})})}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`series.${e}.name`,control:t,render:({field:l})=>s.jsx(o.TextInput,{label:i("chart.series.name"),required:!0,sx:{flex:1},...l})}),s.jsx(f.Controller,{name:`series.${e}.yAxisIndex`,control:t,render:({field:{value:l,onChange:c,...u}})=>s.jsx(o.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(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.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(f.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??Nt,onChange:l.onChange,pt:0,withFallback:!1})})]}),s.jsx(o.Group,{grow:!0,children:s.jsx(f.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})})}),a==="line"&&s.jsx(Zg,{index:e,control:t,seriesItem:n}),a==="bar"&&s.jsx(Xg,{index:e,control:t,seriesItem:n}),a==="scatter"&&s.jsx(Hg,{index:e,control:t}),s.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.style.label"),labelPosition:"center"}),s.jsx(f.Controller,{name:`series.${e}.label_position`,control:t,render:({field:l})=>s.jsx(Yt,{label:i("chart.label_position.label"),withOffOption:!0,...l})}),s.jsxs(o.Stack,{spacing:4,children:[s.jsx(o.Text,{size:"sm",children:i("chart.color.label")}),s.jsx(f.Controller,{name:`series.${e}.color`,control:t,render:({field:l})=>s.jsx(Te,{...l})})]}),s.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.behavior.label"),labelPosition:"center"}),s.jsx(f.Controller,{name:`series.${e}.hide_in_legend`,control:t,render:({field:l})=>s.jsx(o.Checkbox,{label:i("chart.legend.hide_in_legend"),checked:l.value,onChange:c=>l.onChange(c.currentTarget.checked)})})]})}function tf({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},a=e("y_axes"),l=m.useMemo(()=>a.map(({name:c},u)=>({label:c,value:u.toString()})),[a]);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(ef,{control:t,index:u,seriesItem:c,yAxisOptions:l})})}function nf({control:t,watch:e}){const{t:n}=_.useTranslation();return e("stats"),s.jsx(o.Stack,{children:s.jsxs(o.Stack,{spacing:0,children:[s.jsx(f.Controller,{name:"stats.templates.top",control:t,render:({field:r})=>s.jsx(ln,{label:n("chart.stats.template.above_chart"),py:"md",sx:{flexGrow:1},...r})}),s.jsx(f.Controller,{name:"stats.templates.bottom",control:t,render:({field:r})=>s.jsx(ln,{label:n("chart.stats.template.under_chart"),py:"md",sx:{flexGrow:1},...r})})]})})}const sf=({control:t,index:e})=>{const{t:n}=_.useTranslation();return s.jsx(o.Stack,{children:s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`tooltip.metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(f.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})})]})})},rf=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(o.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:a,index:l})=>s.jsx(sf,{control:t,index:l})})]})};function af({control:t,watch:e}){return s.jsx(o.Stack,{children:s.jsx(rf,{control:t,watch:e})})}const of=()=>{const{t}=_.useTranslation();return s.jsxs(o.Group,{sx:{display:"inline-flex"},spacing:6,mr:14,children:[s.jsx(o.Text,{children:t("chart.x_axis.x_axis_type")}),s.jsxs(o.HoverCard,{width:340,shadow:"md",position:"top",children:[s.jsx(o.HoverCard.Target,{children:s.jsx(o.ActionIcon,{size:"xs",sx:{transform:"none !important"},children:s.jsx(k.IconInfoCircle,{})})}),s.jsx(o.HoverCard.Dropdown,{children:s.jsx(o.Text,{size:"sm",children:s.jsxs(_.Trans,{i18nKey:"chart.axis.type.click_to_learn_more",children:["Click",s.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 lf({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(o.Stack,{children:[s.jsx(f.Controller,{name:"x_axis_name",control:t,render:({field:a})=>s.jsx(o.TextInput,{label:n("chart.x_axis.x_axis_name"),sx:{flex:1},...a})}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"x_axis_data_key",control:t,render:({field:a})=>s.jsx(O,{label:n("chart.x_axis.x_axis_data_field"),required:!0,sx:{flex:1},...a})}),s.jsx(f.Controller,{name:"x_axis.type",control:t,render:({field:a})=>s.jsx(o.Select,{label:s.jsx(of,{}),required:!0,data:i,sx:{flex:1},...a})})]}),s.jsx(o.Divider,{mb:-15,label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:a})=>s.jsx(xt,{sx:{width:"48%"},...a})}),s.jsx(f.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:a})=>s.jsx(tt,{...a})})]}),s.jsx(f.Controller,{name:"x_axis.axisLabel.overflow",control:t,render:({field:a})=>s.jsx(nt,{...a})})]})}const kt=m.forwardRef(({label:t,value:e,onChange:n,sx:r={},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 s.jsx(o.Select,{ref:a,label:t??l("chart.name_text.align.label"),data:u,value:e,onChange:n,sx:r,disabled:i})}),Po=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},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 s.jsx(o.Select,{ref:i,label:t??a("chart.y_axis.position.label"),data:c,value:e,onChange:n,sx:r})});function cf({control:t,index:e}){const{t:n}=_.useTranslation();return s.jsxs(o.Stack,{my:0,p:"0",sx:{position:"relative"},children:[s.jsx(o.Divider,{mb:-15,mt:15,variant:"dashed",label:n("common.name"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`y_axes.${e}.name`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("chart.y_axis.y_axis_name"),required:!0,sx:{flex:1},...r})}),s.jsx(f.Controller,{name:`y_axes.${e}.nameAlignment`,control:t,render:({field:r})=>s.jsx(kt,{sx:{flex:1},...r})})]}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.layout"),labelPosition:"center"}),s.jsx(o.Group,{grow:!0,noWrap:!0,children:s.jsx(f.Controller,{name:`y_axes.${e}.position`,control:t,render:({field:r})=>s.jsx(Po,{sx:{flex:1},...r})})}),s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.label_format"),labelPosition:"center"}),s.jsx(f.Controller,{name:`y_axes.${e}.label_formatter`,control:t,render:({field:r})=>s.jsx(Re,{...r})})]}),s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.value_range"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:`y_axes.${e}.min`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("chart.y_axis.value_min"),...r})}),s.jsx(f.Controller,{name:`y_axes.${e}.max`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("chart.y_axis.value_max"),...r})})]})]}),s.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:n("chart.y_axis.behavior"),labelPosition:"center"}),s.jsx(f.Controller,{name:`y_axes.${e}.show`,control:t,render:({field:r})=>s.jsx(o.Checkbox,{label:n("chart.y_axis.visible"),checked:r.value,onChange:i=>r.onChange(i.currentTarget.checked)})})]})}function uf({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},a=({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:a,children:({field:l,index:c})=>s.jsx(cf,{control:t,index:c})})}function df({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),{variables:i}=t,a=m.useMemo(()=>b.defaultsDeep({},n,Zs),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=f.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,a),[h,a]);return u(["dataZoom"]),s.jsx(o.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:c(r),children:[s.jsx(ge,{canSubmit:g}),s.jsxs(o.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"X Axis",children:e("chart.x_axis.label")}),s.jsx(o.Tabs.Tab,{value:"Y Axes",children:e("chart.y_axis.labels")}),s.jsx(o.Tabs.Tab,{value:"Series",children:e("chart.series.label")}),s.jsx(o.Tabs.Tab,{value:"Regression Lines",children:e("chart.regression_line.labels")}),s.jsx(o.Tabs.Tab,{value:"Tooltip",children:e("chart.tooltip.label")}),s.jsx(o.Tabs.Tab,{value:"Stats",children:e("chart.stats.label")}),s.jsx(o.Tabs.Tab,{value:"Reference Lines",children:e("chart.reference_line.labels")}),s.jsx(o.Tabs.Tab,{value:"Reference Areas",children:e("chart.reference_area.labels")}),s.jsx(o.Tabs.Tab,{value:"Zooming",children:e("chart.zooming.label")})]}),s.jsx(o.Tabs.Panel,{value:"X Axis",children:s.jsx(lf,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Y Axes",children:s.jsx(uf,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Series",children:s.jsx(tf,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Regression Lines",children:s.jsx(yx,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Tooltip",children:s.jsx(af,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Stats",children:s.jsx(nf,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Reference Lines",children:s.jsx(gx,{variables:i,control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Reference Areas",children:s.jsx(mx,{variables:i,control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Zooming",children:s.jsx(f.Controller,{name:"dataZoom",control:l,render:({field:y})=>s.jsx(qn,{...y})})})]})]})})}function pf(t){const e=b.cloneDeep(b.omit(t,"variables"));return e.stats=b.omit(e.stats,"variables"),e}function hf(t){const{rotate:e,formatter:n=ke()}=t.x_axis.axisLabel;return{...t,x_axis:{...t.x_axis,axisLabel:{rotate:e,formatter:n}}}}function mf(t){const{dataZoom:e=zt,...n}=t;return{...n,dataZoom:e}}function xf(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 gf(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 ff(t){const e=t.reference_lines.map(n=>{const{yAxisIndex:r=0}=n;return{...n,yAxisIndex:r}});return{...t,reference_lines:e}}function yf(t){const e=t.series.map(n=>{const{aggregation_on_group:r=Nt}=n;return{...n,aggregation_on_group:r}});return{...t,series:e}}function bf(t){const e=t.series.map(n=>{const{aggregation_on_value:r=Nt}=n;return{...n,aggregation_on_value:r}});return{...t,series:e}}function vf(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 _f(t){const{series:e,...n}=t;return{...n,series:e.map(r=>{const{barMinWidth:i,barWidth:a,barMaxWidth:l}=r;return i?{...r,barMinWidth:i,barWidth:"",barMaxWidth:l??a}:{...r,barMinWidth:"",barWidth:a,barMaxWidth:""}})}}function jf(t){const{y_axes:e,...n}=t;return{...n,y_axes:e.map(r=>{const{min:i="",max:a=""}=r;return{...r,min:i,max:a}})}}function wf(t){const{y_axes:e,...n}=t;return{...n,y_axes:e.map(r=>{const{nameAlignment:i="left"}=r;return{...r,nameAlignment:i}})}}function Cf(t){const{y_axes:e,...n}=t;return{...n,y_axes:e.map(r=>{const{show:i=!0}=r;return{...r,show:i}})}}function Sf(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 kf(t){const{series:e,y_axes:n,...r}=t;return{...r,series:e.map(i=>{const{hide_in_legend:a=!1,aggregation_on_value:l=Nt}=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 Tf(t){const{type:e="category",...n}=t.x_axis;return{...t,x_axis:{...n,type:e}}}function Df(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:a,regressions:l,...c}=t;return{...c,x_axis_data_key:r(i),series:a.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 zf(t){const{tooltip:e={metrics:[]},...n}=t;return{...t,tooltip:e}}const Mf=[{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 If 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:pf(i)}}),this.version(3,n=>({...n,version:3,config:hf(n.config)})),this.version(4,n=>({...n,version:4,config:mf(n.config)})),this.version(5,n=>({...n,version:5,config:xf(n.config)})),this.version(6,n=>({...n,version:6,config:gf(n.config)})),this.version(7,n=>({...n,version:7,config:ff(n.config)})),this.version(8,n=>({...n,version:8,config:yf(n.config)})),this.version(9,n=>({...n,version:9,config:bf(n.config)})),this.version(10,n=>({...n,version:10,config:vf(n.config)})),this.version(11,n=>({...n,version:11,config:_f(n.config)})),this.version(12,n=>({...n,version:12,config:jf(n.config)})),this.version(13,n=>({...n,version:13,config:wf(n.config)})),this.version(14,n=>({...n,version:14,config:Cf(n.config)})),this.version(15,n=>({...n,version:15,config:Sf(n.config)})),this.version(16,n=>({...n,version:16,config:kf(n.config)})),this.version(17,n=>({...n,version:17,config:Tf(n.config)})),this.version(18,(n,r)=>({...n,version:18,config:Df(n.config,r)})),this.version(19,n=>({...n,version:19,config:zf(n.config)}))}}const Ef={displayName:"viz.cartesian_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new If,name:"cartesian",viewRender:px,configRender:df,createConfig(){return{version:19,config:b.cloneDeep(Zs)}},triggers:[Xs],translation:Mf};function Af(t){if(t.enable_value)return t.value}function Pf(t){if(t.enable_value)return t.value}function $f(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 Bf(t,e){return t.series.map(n=>{const{level_name_data_key:r,level_value_data_key:i,axisLabel:a,min:l,max:c,funnelAlign:u,orient:d,...p}=n;if(!r||!i)return{};const h=E(r),g=E(i),y=e[h.queryID].map(w=>({name:w[h.columnKey],value:w[g.columnKey]})),v=Qe(a.overflow.on_axis);return{type:"funnel",...$f(n),min:Af(l),max:Pf(c),minSize:l.size,maxSize:c.size,...p,label:{show:!0,position:a.position,...v},orient:d,funnelAlign:d==="horizontal"?"center":u,data:y}})}function Lf({conf:t,params:e,max:n}){const{name:r,value:i}=e.data,a=U(i/n,{output:"percent",mantissa:2,trimMantissa:!0,absolute:!1});return[{label:`${e.marker} ${r}`,value:`${i} (${a})`,style:{label:"",value:""}}]}function qf(t,e){var a;const n=E(t.series[0].level_name_data_key),r=E(t.series[0].level_value_data_key),i=(a=b.maxBy(e[n.queryID],r.columnKey))==null?void 0:a[r.columnKey];return l=>{const u=Lf({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 x;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+=(x=d==null?void 0:d.text)===null||x===void 0?void 0:x.slice(Math.max(s,p)-p,i-p),u=!1):d.isBlock&&!u&&(c+=a,u=!0)}),c}function Sj(e){return Object.fromEntries(Object.entries(e.nodes).filter(([,t])=>t.spec.toText).map(([t,n])=>[t,n.spec.toText]))}Vt.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=Sj(n);return Cj(s,{from:l,to:c},{textSerializers:u})}}})]}});const kj=()=>({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),Tj=(e=!1)=>({commands:t})=>t.setContent("",e),Dj=()=>({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)),x=h.blockRange(f);if(!x)return;const y=gj(x);if(c.type.isTextblock){const{defaultType:j}=h.parent.contentMatchAt(h.index());t.setNodeMarkup(x.start,j)}(y||y===0)&&t.lift(x,y)})}),!0},Mj=e=>t=>e(t),zj=()=>({state:e,dispatch:t})=>De.createParagraphNear(e,t),Ij=()=>({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},Ej=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},Aj=e=>({tr:t,dispatch:n})=>{const{from:s,to:i}=e;return n&&t.delete(s,i),!0},Pj=()=>({state:e,dispatch:t})=>De.deleteSelection(e,t),Oj=()=>({commands:e})=>e.keyboardShortcut("Enter"),Lj=()=>({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]:jj(t[i])?t[i].test(e[i]):t[i]===e[i]):!0}function lo(e,t,n={}){return e.find(s=>s.type===t&&Ws(s.attrs,n))}function Bj(e,t,n={}){return!!lo(e,t,n)}function hp(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=lo([...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(lo([...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&&Bj([...e.parent.child(c).marks],t,n);)u+=e.parent.child(c).nodeSize,c+=1;return{from:l,to:u}}function mn(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 qj=(e,t={})=>({tr:n,state:s,dispatch:i})=>{const a=mn(e,s.schema),{doc:l,selection:c}=n,{$from:u,from:d,to:p}=c;if(i){const h=hp(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},Vj=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 fp(e){return e instanceof Te}function Mn(e=0,t=0,n=0){return Math.min(Math.max(e,t),n)}function Nj(e,t=null){if(!t)return null;const n=ge.atStart(e),s=ge.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,Mn(0,i,a),Mn(e.content.size,i,a)):Te.create(e,Mn(t,i,a),Mn(t,i,a))}function co(){return["iPad Simulator","iPhone Simulator","iPod Simulator","iPad","iPhone","iPod"].includes(navigator.platform)||navigator.userAgent.includes("Mac")&&"ontouchend"in document}const $j=(e=null,t={})=>({editor:n,view:s,tr:i,dispatch:a})=>{t={scrollIntoView:!0,...t};const l=()=>{co()&&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&&!fp(n.state.selection))return l(),!0;const c=Nj(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},Fj=(e,t)=>n=>e.every((s,i)=>t(s,{...n,index:i})),Gj=(e,t)=>({tr:n,commands:s})=>s.insertContentAt({from:n.selection.from,to:n.selection.to},e,t);function gp(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=Ls.fromSchema(t);return n.slice?s.parseSlice(gp(e),n.parseOptions).content:s.parse(gp(e),n.parseOptions)}return Rs("",t,n)}function Wj(e,t,n){const s=e.steps.length-1;if(s<t)return;const i=e.steps[s];if(!(i instanceof qt||i instanceof Dn))return;const a=e.mapping.maps[s];let l=0;a.forEach((c,u,d,p)=>{l===0&&(l=p)}),e.setSelection(ge.near(e.doc.resolve(l),n))}const Rj=e=>e.toString().startsWith("<"),Qj=(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((Rj(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&&Wj(s,s.steps.length-1,-1)}return!0},Uj=()=>({state:e,dispatch:t})=>De.joinUp(e,t),Yj=()=>({state:e,dispatch:t})=>De.joinDown(e,t),Kj=()=>({state:e,dispatch:t})=>De.joinBackward(e,t),Xj=()=>({state:e,dispatch:t})=>De.joinForward(e,t);function mp(){return typeof navigator<"u"?/Mac/.test(navigator.platform):!1}function Jj(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))co()||mp()?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 Zj=e=>({editor:t,view:n,tr:s,dispatch:i})=>{const a=Jj(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 uo(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 x=Math.max(s,f),y=Math.min(i,f+h.nodeSize);c.push({node:h,from:x,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 Hj=(e,t={})=>({state:n,dispatch:s})=>{const i=$e(e,n.schema);return uo(n,i,t)?De.lift(n,s):!1},ew=()=>({state:e,dispatch:t})=>De.liftEmptyBlock(e,t),tw=e=>({state:t,dispatch:n})=>{const s=$e(e,t.schema);return vi.liftListItem(s)(t,n)},nw=()=>({state:e,dispatch:t})=>De.newlineInCode(e,t);function xp(e,t){return t.nodes[e]?"node":t.marks[e]?"mark":null}function yp(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 rw=(e,t)=>({tr:n,state:s,dispatch:i})=>{let a=null,l=null;const c=xp(typeof e=="string"?e:e.name,s.schema);return c?(c==="node"&&(a=$e(e,s.schema)),c==="mark"&&(l=mn(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,yp(d.attrs,t)),l&&d.marks.length&&d.marks.forEach(h=>{l===h.type&&n.addMark(p,p+d.nodeSize,l.create(yp(h.attrs,t)))})})}),!0):!1},sw=()=>({tr:e,dispatch:t})=>(t&&e.scrollIntoView(),!0),iw=()=>({tr:e,commands:t})=>t.setTextSelection({from:0,to:e.doc.content.size}),aw=()=>({state:e,dispatch:t})=>De.selectNodeBackward(e,t),ow=()=>({state:e,dispatch:t})=>De.selectNodeForward(e,t),lw=()=>({state:e,dispatch:t})=>De.selectParentNode(e,t),cw=()=>({state:e,dispatch:t})=>De.selectTextblockEnd(e,t),uw=()=>({state:e,dispatch:t})=>De.selectTextblockStart(e,t);function dw(e,t,n={}){return Rs(e,t,{slice:!1,parseOptions:n})}const pw=(e,t=!1,n={})=>({tr:s,editor:i,dispatch:a})=>{const{doc:l}=s,c=dw(e,i.schema,n);return a&&s.replaceWith(0,l.content.size,c).setMeta("preventUpdate",!t),!0};function hw(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 fw(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 po(e){return t=>fw(t.$from,e)}function gw(e,t){const n=mn(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 mw(e,t,n={}){const{empty:s,ranges:i}=e.selection,a=t?mn(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 x=h.pos,y=f.pos;e.doc.nodesBetween(x,y,(j,k)=>{if(!j.isText&&!j.marks.length)return;const S=Math.max(x,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 bp(e,t){const{nodeExtensions:n}=vj(t),s=n.find(l=>l.name===e);if(!s)return!1;const i={name:s.name,options:s.options,storage:s.storage},a=Hn(gn(s,"group",i));return typeof a!="string"?!1:a.split(" ").includes("list")}function xw(e,t,n){var s;const{selection:i}=t;let a=null;if(fp(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 x=!f||f.type.allowsMarkType(n),y=!!n.isInSet(p.marks)||!p.marks.some(j=>j.type.excludes(n));d=x&&y}return!d}),d})}const yw=(e,t={})=>({tr:n,state:s,dispatch:i})=>{const{selection:a}=n,{empty:l,ranges:c}=a,u=mn(e,s.schema);if(i)if(l){const d=gw(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,x)=>{const y=Math.max(x,p),j=Math.min(x+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 xw(s,n,u)},bw=(e,t)=>({tr:n})=>(n.setMeta(e,t),!0),vw=(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)},_w=e=>({tr:t,dispatch:n})=>{if(n){const{doc:s}=t,i=Mn(e,0,s.content.size),a=at.create(s,i);t.setSelection(a)}return!0},jw=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=Mn(i,l,c),d=Mn(a,l,c),p=Te.create(s,u,d);t.setSelection(p)}return!0},ww=e=>({state:t,dispatch:n})=>{const s=$e(e,t.schema);return vi.sinkListItem(s)(t,n)};function vp(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 Cw=({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 at&&a.node.isBlock)return!c.parentOffset||!$s(l,c.pos)?!1:(s&&(e&&vp(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:hw(c.node(-1).contentMatchAt(c.indexAfter(-1)));let x=h&&f?[{type:f,attrs:p}]:void 0,y=$s(t.doc,t.mapping.map(c.pos),1,x);if(!x&&!y&&$s(t.doc,t.mapping.map(c.pos),1,f?[{type:f}]:void 0)&&(y=!0,x=f?[{type:f,attrs:p}]:void 0),y&&(t.split(t.mapping.map(c.pos),1,x),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&&vp(n,i.extensionManager.splittableMarks),t.scrollIntoView()}return!0},Sw=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,x=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:x},{type:f,attrs:y}]:[{type:l,attrs:x}];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},ho=(e,t)=>{const n=po(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)&&sp(e.doc,n.pos)&&e.join(n.pos),!0},fo=(e,t)=>{const n=po(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)&&sp(e.doc,s)&&e.join(s),!0};var kw=Object.freeze({__proto__:null,blur:kj,clearContent:Tj,clearNodes:Dj,command:Mj,createParagraphNear:zj,deleteCurrentNode:Ij,deleteNode:Ej,deleteRange:Aj,deleteSelection:Pj,enter:Oj,exitCode:Lj,extendMarkRange:qj,first:Vj,focus:$j,forEach:Fj,insertContent:Gj,insertContentAt:Qj,joinUp:Uj,joinDown:Yj,joinBackward:Kj,joinForward:Xj,keyboardShortcut:Zj,lift:Hj,liftEmptyBlock:ew,liftListItem:tw,newlineInCode:nw,resetAttributes:rw,scrollIntoView:sw,selectAll:iw,selectNodeBackward:aw,selectNodeForward:ow,selectParentNode:lw,selectTextblockEnd:cw,selectTextblockStart:uw,setContent:pw,setMark:yw,setMeta:bw,setNode:vw,setNodeSelection:_w,setTextSelection:jw,sinkListItem:ww,splitBlock:Cw,splitListItem:Sw,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,x=$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=po(N=>bp(N.type.name,h))(j);if(z.depth>=1&&E&&z.depth-E.depth<=1){if(E.node.type===x)return d.liftListItem(y);if(bp(E.node.type.name,h)&&x.validContent(E.node.content)&&c)return u().command(()=>(a.setNodeMarkup(E.pos,x),!0)).command(()=>ho(a,x)).command(()=>fo(a,x)).run()}return!n||!I||!c?u().command(()=>p().wrapInList(x,s)?!0:d.clearNodes()).wrapInList(x,s).command(()=>ho(a,x)).command(()=>fo(a,x)).run():u().command(()=>{const N=p().wrapInList(x,s),R=I.filter(pe=>f.includes(pe.type.name));return a.ensureMarks(R),N?!0:d.clearNodes()}).wrapInList(x,s).command(()=>ho(a,x)).command(()=>fo(a,x)).run()},toggleMark:(e,t={},n={})=>({state:s,commands:i})=>{const{extendEmptyMarkRange:a=!1}=n,l=mn(e,s.schema);return mw(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 uo(s,a,n)?i.setNode(l):i.setNode(a,n)},toggleWrap:(e,t={})=>({state:n,commands:s})=>{const i=$e(e,n.schema);return uo(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=mn(e,s.schema),{$from:d,empty:p,ranges:h}=c;if(!i)return!0;if(p&&l){let{from:f,to:x}=c;const y=(a=d.marks().find(k=>k.type===u))===null||a===void 0?void 0:a.attrs,j=hp(d,u,y);j&&(f=j.from,x=j.to),n.removeMark(f,x,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=xp(typeof e=="string"?e:e.name,s.schema);return c?(c==="node"&&(a=$e(e,s.schema)),c==="mark"&&(l=mn(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(x=>{if(l===x.type){const y=Math.max(f,d),j=Math.min(f+h.nodeSize,p);n.addMark(y,j,l.create({...x.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 vi.wrapInList(i,t)(n,s)}});Vt.create({name:"commands",addCommands(){return{...kw}}}),Vt.create({name:"editable",addProseMirrorPlugins(){return[new $r({key:new Fr("editable"),props:{editable:()=>this.editor.options.editable}})]}}),Vt.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}}}})]}}),Vt.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:x}=h,y=ge.atStart(d).from===f;return!p||!y||!x.type.isTextblock||x.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 co()||mp()?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=ge.atStart(t.doc).from,u=ge.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=dp({state:n,transaction:h}),{commands:x}=new bj({editor:this.editor,state:f});if(x.clearNodes(),!!h.steps.length)return h}})]}}),Vt.create({name:"tabindex",addProseMirrorPlugins(){return[new $r({key:new Fr("tabindex"),props:{attributes:this.editor.isEditable?{tabindex:"0"}:{}}})]}});const _p=Vt.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()}}}),Tw=["8","10","12","14","16","18","20","24","30","36","48","60","72"].map(e=>`${e}px`),Dw=[{label:"auto",value:""}].concat(Tw.map(e=>({label:e,value:e}))),Mw={input:{height:"26px",minHeight:"26px",lineHeight:"26px",borderColor:"#ced4da !important"}},zw=({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:Dw,styles:Mw,value:t||"",onChange:n=>{const s=n.currentTarget.value;s?e.chain().focus().setFontSize(s).run():e.chain().focus().unsetFontSize().run()}})})},Us=({value:e,styles:t={},sx:n={}})=>{const s=nc.useEditor({extensions:[rc,tc,Q.Link,Yl,Ul,Rl,Jl.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),ec,Hl,Zl,Kl.configure({types:["heading","paragraph"]}),Ql.configure({placeholder:"This is placeholder"}),Xl,Wl.Color,_p],content:e,editable:!1});g.useEffect(()=>{s==null||s.commands.setContent(e)},[e,s]);const i=g.useMemo(()=>v.defaultsDeep({},{content:Za},t),[t]);return r.jsx(Q.RichTextEditor,{editor:s,styles:i,sx:n,children:r.jsx(Q.RichTextEditor.Content,{})})};function jp(){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(Us,{value:dm(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 Iw=({value:e,onChange:t})=>{const n=s=>{if(!s){t("");return}t(s)};return r.jsx(o.Box,{sx:{position:"relative",flexGrow:1},children:r.jsx(tt,{className:"function-editor",height:"100%",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1}}})})},er=g.forwardRef(({value:e,onChange:t,label:n,defaultValue:s},i)=>{const{t:a}=_.useTranslation(),[l,c]=g.useState(e),u=()=>{t(l)},d=()=>{c(e)},p=()=>{c(s)};g.useEffect(()=>{c(e)},[e]);const h=l!==e;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(jp,{})}),r.jsxs(o.Group,{position:"right",children:[r.jsx(o.Button,{onClick:p,size:"xs",variant:"default",leftIcon:r.jsx(M.IconPlayerSkipBack,{size:16}),children:a("common.actions.reset_to_default")}),r.jsx(o.Button,{onClick:d,color:"red",size:"xs",disabled:!h,leftIcon:r.jsx(M.IconRecycle,{size:16}),children:a("common.actions.revert_changes")}),r.jsx(o.Button,{color:"green",size:"xs",onClick:u,disabled:!h,leftIcon:r.jsx(M.IconDeviceFloppy,{size:16}),children:a("common.actions.save_changes")})]})]}),r.jsx(o.Text,{size:14,children:n}),r.jsx(Iw,{value:l,onChange:c})]})}),wp=g.forwardRef(({title:e,value:t,onChange:n,label:s,description:i=null,triggerLabel:a="Edit",triggerButtonProps:l={},defaultValue:c},u)=>{const[d,{open:p,close:h}]=he.useDisclosure(!1);return r.jsxs(r.Fragment,{children:[r.jsxs(o.Modal,{opened:d,onClose:h,title:e,withinPortal:!0,zIndex:320,size:"900px",children:[i,r.jsx(o.Box,{h:600,children:r.jsx(er,{value:t,onChange:n,defaultValue:c,label:s})})]}),r.jsx(o.Button,{onClick:p,...l,children:a})]})});function Ew({label:e,value:t,onChange:n,pt:s="sm",withFallback:i},a){const{t:l,i18n:c}=_.useTranslation();g.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:fc},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})},x=g.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:x,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(wp,{title:l("aggregation.option.custom.title"),label:"",triggerLabel:l("aggregation.option.custom.label_trigger"),value:t.config.func,onChange:p,defaultValue:fc,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 go=g.forwardRef(Ew),tr=g.forwardRef(({label:e,value:t,onChange:n,options:s,withOffOption:i=!1},a)=>{const{t:l,i18n:c}=_.useTranslation(),u=g.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 Aw({control:e,index:t,seriesItem:n}){const{t:s,i18n:i}=_.useTranslation(),a=!!n.barWidth.trim(),l=g.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 Pw({control:e,index:t,seriesItem:n}){const{t:s,i18n:i}=_.useTranslation(),a=n.showSymbol,l=g.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(Jn,{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(Ja,{...c})})]})]})}function Ow({control:e,index:t}){return r.jsx(b.Controller,{name:`series.${t}.symbolSize`,control:e,render:({field:n})=>r.jsx(Ja,{label:"Size",...n})})}function Lw({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(go,{label:i("viz.cartesian_chart.series.aggregation.label"),value:l.value??Ln,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(Pw,{index:t,control:e,seriesItem:n}),a==="bar"&&r.jsx(Aw,{index:t,control:e,seriesItem:n}),a==="scatter"&&r.jsx(Ow,{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 Bw({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>({type:"bar",name:he.randomId(),showSymbol:!1,symbolSize:Xa.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=g.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(Lw,{control:e,index:u,seriesItem:c,yAxisOptions:l})})}function qw({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 Vw=({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})})]})})},Nw=({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(Vw,{control:e,index:l})})]})};function $w({control:e,watch:t}){return r.jsx(o.Stack,{children:r.jsx(Nw,{control:e,watch:t})})}const Fw=()=>{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 Gw({control:e,watch:t}){const{t:n,i18n:s}=_.useTranslation();t(["x_axis_data_key","x_axis_name","x_axis"]);const i=g.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(Fw,{}),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(Kt,{sx:{width:"48%"},...a})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:a})=>r.jsx(Ct,{...a})})]}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:a})=>r.jsx(St,{...a})})]})}const xn=g.forwardRef(({label:e,value:t,onChange:n,sx:s={},disabled:i},a)=>{const{t:l,i18n:c}=_.useTranslation(),u=g.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})}),Cp=g.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=g.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 Ww({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(xn,{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(Cp,{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 Rw({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(Ww,{control:e,index:c})})}function Qw({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaultsDeep({},n,Ua),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});g.useEffect(()=>{p(a)},[a]);const h=d(),f=g.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(Gw,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Y Axes",children:r.jsx(Rw,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Series",children:r.jsx(Bw,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Regression Lines",children:r.jsx(ej,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx($w,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Stats",children:r.jsx(qw,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx(Z_,{variables:i,control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Reference Areas",children:r.jsx(X_,{variables:i,control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Zooming",children:r.jsx(b.Controller,{name:"dataZoom",control:l,render:({field:x})=>r.jsx(As,{...x})})})]})]})})}function Uw(e){const t=v.cloneDeep(v.omit(e,"variables"));return t.stats=v.omit(t.stats,"variables"),t}function Yw(e){const{rotate:t,formatter:n=Oe()}=e.x_axis.axisLabel;return{...e,x_axis:{...e.x_axis,axisLabel:{rotate:t,formatter:n}}}}function Kw(e){const{dataZoom:t=_n,...n}=e;return{...n,dataZoom:t}}function Xw(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 Jw(e){const t=e.reference_lines.map(n=>{const{lineStyle:s={type:"dashed",width:1,color:Gt.random().css()},show_in_legend:i=!1}=n;return{...n,lineStyle:s,show_in_legend:i}});return{...e,reference_lines:t}}function Zw(e){const t=e.reference_lines.map(n=>{const{yAxisIndex:s=0}=n;return{...n,yAxisIndex:s}});return{...e,reference_lines:t}}function Hw(e){const t=e.series.map(n=>{const{aggregation_on_group:s=Ln}=n;return{...n,aggregation_on_group:s}});return{...e,series:t}}function e0(e){const t=e.series.map(n=>{const{aggregation_on_value:s=Ln}=n;return{...n,aggregation_on_value:s}});return{...e,series:t}}function t0(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 n0(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 r0(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 s0(e){const{y_axes:t,...n}=e;return{...n,y_axes:t.map(s=>{const{nameAlignment:i="left"}=s;return{...s,nameAlignment:i}})}}function i0(e){const{y_axes:t,...n}=e;return{...n,y_axes:t.map(s=>{const{show:i=!0}=s;return{...s,show:i}})}}function a0(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 o0(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=Ln}=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 l0(e){const{type:t="category",...n}=e.x_axis;return{...e,x_axis:{...n,type:t}}}function c0(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 u0(e){const{tooltip:t={metrics:[]},...n}=e;return{...e,tooltip:t}}const d0=[{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 p0 extends me{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:Uw(i)}}),this.version(3,n=>({...n,version:3,config:Yw(n.config)})),this.version(4,n=>({...n,version:4,config:Kw(n.config)})),this.version(5,n=>({...n,version:5,config:Xw(n.config)})),this.version(6,n=>({...n,version:6,config:Jw(n.config)})),this.version(7,n=>({...n,version:7,config:Zw(n.config)})),this.version(8,n=>({...n,version:8,config:Hw(n.config)})),this.version(9,n=>({...n,version:9,config:e0(n.config)})),this.version(10,n=>({...n,version:10,config:t0(n.config)})),this.version(11,n=>({...n,version:11,config:n0(n.config)})),this.version(12,n=>({...n,version:12,config:r0(n.config)})),this.version(13,n=>({...n,version:13,config:s0(n.config)})),this.version(14,n=>({...n,version:14,config:i0(n.config)})),this.version(15,n=>({...n,version:15,config:a0(n.config)})),this.version(16,n=>({...n,version:16,config:o0(n.config)})),this.version(17,n=>({...n,version:17,config:l0(n.config)})),this.version(18,(n,s)=>({...n,version:18,config:c0(n.config,s)})),this.version(19,n=>({...n,version:19,config:u0(n.config)}))}}const h0={displayName:"viz.cartesian_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new p0,name:"cartesian",viewRender:Y_,configRender:Qw,createConfig(){return{version:19,config:v.cloneDeep(Ua)}},triggers:[Qa],translation:d0};function f0(e){if(e.enable_value)return e.value}function g0(e){if(e.enable_value)return e.value}function m0(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 x0(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),x=t[h.queryID].map(j=>({name:j[h.columnKey],value:j[f.columnKey]})),y=ut(a.overflow.on_axis);return{type:"funnel",...m0(n),min:f0(l),max:g0(c),minSize:l.size,maxSize:c.size,...p,label:{show:!0,position:a.position,...y},orient:d,funnelAlign:d==="horizontal"?"center":u,data:x}})}function y0({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 b0(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=y0({conf:e,params:l,max:i}).map(p=>`
|
|
133
133
|
<tr>
|
|
134
134
|
<th style="text-align: right;">
|
|
135
135
|
<div style="${p.style.label}">${p.label}</div>
|
|
@@ -145,13 +145,13 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
145
145
|
<table style="width: auto">
|
|
146
146
|
<tbody>${u.join("")}</tbody>
|
|
147
147
|
</table>
|
|
148
|
-
`}}function
|
|
148
|
+
`}}function v0(e,t){return te.getTooltip({trigger:"item",formatter:b0(e,t)})}function _0(e,t){return{grid:{top:0,left:0,right:0,bottom:0},tooltip:v0(e,t),series:x0(e,t)}}function j0(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 mo={series:[j0("Funnel")]};function w0({conf:e,data:t,width:n,height:s}){const i=g.useMemo(()=>_0(e,t),[e,t]);return r.jsx(Pe,{echarts:Ae,option:i,style:{width:n,height:s},notMerge:!0,theme:"merico-light"})}function C0({context:e}){const{value:t}=$(e.instanceData,"config"),n=g.useMemo(()=>v.defaults({},t,mo),[t]),s=e.data,{width:i,height:a}=e.viewport;return!i||!a?null:r.jsx(Ue,{width:i,height:a,children:r.jsx(w0,{width:jt(i),height:wt(a),data:s,conf:n})})}const S0=({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=g.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=g.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:x=>f.onChange(x.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:x=>f.onChange(x.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(fn,{...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(xn,{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(St,{...h})})})]})},k0=({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]=g.useState(c??null);return g.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(S0,{item:p,control:e,index:h,remove:i})},p.id))]})};function T0({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=g.useMemo(()=>v.defaultsDeep({},t,mo),[t]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});g.useEffect(()=>{u(s)},[s]),l([]);const d=c(),p=g.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(k0,{control:i,watch:l})]})})}const D0=[{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 M0(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 z0(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 I0 extends me{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:M0(s)}}),this.version(3,(n,s)=>{const{config:i}=n;return{...n,version:3,config:z0(i,s)}})}}const E0={displayName:"viz.funnel_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new I0,name:"funnel",viewRender:C0,configRender:T0,createConfig:()=>({version:3,config:mo}),translation:D0};function A0(e){const t=Ye(e.x_axis.axisLabel.formatter),n=Ye(e.y_axis.axisLabel.formatter);return{x_axis:t,y_axis:n}}function P0(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 O0(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 L0(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 B0=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function q0({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:""}},x=[p,h,f],y=s[`${c}---${u}`];return y&&e.tooltip.metrics.forEach(j=>{const k=O(j.data_key);x.push({label:j.name,value:B0(v.get(y,k.columnKey,"")),style:{label:"",value:""}})}),x}function V0(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=q0({conf:e,labelFormatters:n,valueFormatters:s,dataDict:d,params:p}).map(y=>`
|
|
149
149
|
<tr>
|
|
150
150
|
<th style="text-align: right;">
|
|
151
|
-
<div style="${
|
|
151
|
+
<div style="${y.style.label}">${y.label}</div>
|
|
152
152
|
</th>
|
|
153
153
|
<td style="text-align: right; padding: 0 1em;">
|
|
154
|
-
<div style="${
|
|
154
|
+
<div style="${y.style.value}">${y.value}
|
|
155
155
|
</td>
|
|
156
156
|
</tr>
|
|
157
157
|
`);return`
|
|
@@ -164,15 +164,15 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
164
164
|
/>
|
|
165
165
|
</tr>
|
|
166
166
|
</thead>
|
|
167
|
-
<tbody>${
|
|
167
|
+
<tbody>${f.join("")}</tbody>
|
|
168
168
|
</table>
|
|
169
|
-
`}})}function
|
|
170
|
-
`)}},ly=({value:t,onChange:e})=>{const{t:n}=_.useTranslation(),[r,{setTrue:i,setFalse:a}]=G.useBoolean(),[l,c]=m.useState(t),u=()=>{a();const{type:g,value:y}=l,v={type:g,value:y};c(v),e(v)},d=()=>{a(),c(t)},p=g=>{c(y=>({...y,value:g}))},h=()=>{p($o.dynamic.value)};return s.jsxs(s.Fragment,{children:[s.jsx(o.Box,{sx:{width:"50%"},children:s.jsx(o.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(o.Modal,{size:800,title:n("chart.number_or_dynamic_value.dynamic.setup_title"),opened:r,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{mt:10,mb:-10,label:n("chart.number_or_dynamic_value.dynamic.guide"),labelPosition:"center",variant:"dashed"}),s.jsx(oy,{value:l.value,onChange:p}),s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Button,{onClick:h,color:"red",leftIcon:s.jsx(L.Recycle,{size:20}),children:n("common.actions.reset_to_default")}),s.jsxs(o.Group,{position:"right",children:[s.jsx(o.Button,{onClick:d,variant:"subtle",children:n("common.actions.cancel")}),s.jsx(o.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),onClick:u,children:n("common.actions.save")})]})]})]})})]})},cy=({value:t,onChange:e})=>t.type!=="dynamic"?null:s.jsx(ly,{value:t,onChange:e}),uy=({value:t,onChange:e})=>{if(t.type!=="static")return null;const n=r=>{e({...t,value:r})};return s.jsx(o.NumberInput,{defaultValue:18,label:" ",hideControls:!0,value:t.value,onChange:n})},Kt=m.forwardRef(({label:t="Value",value:e,onChange:n},r)=>{const{t:i,i18n:a}=_.useTranslation(),l=u=>{n({...$o[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 s.jsxs(o.SimpleGrid,{cols:2,children:[s.jsx(o.Select,{ref:r,label:t,data:c,value:e.type,onChange:l,sx:{flexGrow:1}}),s.jsx(uy,{value:e,onChange:n}),s.jsx(cy,{value:e,onChange:n})]})});function Jt(t,e,n){if(!t.type)return n;if(t.type==="static"){const{value:i}=t;return i}const{value:r}=t;try{return new Function(`return ${r}`)()({variables:e},{lodash:b,interpolate:Tt.interpolate})}catch(i){return console.error(`[getNumberOrDynamicValue] failed parsing custom function, error: ${i.message}`),10}}const Hn=({label:t,field:e})=>{const{t:n}=_.useTranslation();return s.jsx(o.ColorInput,{label:t,placeholder:n("chart.visual_map.skip_range.follow_visual_map"),size:"xs",withinPortal:!0,dropdownZIndex:340,rightSection:e.value?s.jsx(o.CloseButton,{onClick:()=>{e.onChange("")}}):null,...e})},dy=({form:t})=>{const{t:e}=_.useTranslation();return s.jsxs(o.Stack,{children:[s.jsx(f.Controller,{control:t.control,name:"visualMap.skipRange.lt_min",render:({field:n})=>s.jsx(Hn,{field:n,label:e("chart.visual_map.skip_range.lt_min")})}),s.jsx(f.Controller,{control:t.control,name:"visualMap.skipRange.min",render:({field:n})=>s.jsx(Hn,{field:n,label:e("chart.visual_map.skip_range.min")})}),s.jsx(f.Controller,{control:t.control,name:"visualMap.skipRange.max",render:({field:n})=>s.jsx(Hn,{field:n,label:e("chart.visual_map.skip_range.max")})}),s.jsx(f.Controller,{control:t.control,name:"visualMap.skipRange.gt_max",render:({field:n})=>s.jsx(Hn,{field:n,label:e("chart.visual_map.skip_range.gt_max")})})]})};function Bo(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(Dt.graphics.depth)},skipRange:{lt_min:"",min:"",max:"",gt_max:""}}}function py(){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:[qo()],categories:[]}}function _r(){return Bo()}function hy(){return{compared:Object.values(Dt.graphics.compared),level:Object.values(Dt.graphics.level),depth:Object.values(Dt.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 Lo(t,e){const{min:n,max:r}=t,i=Jt(n,e),a=Jt(r,e);if(t.type==="continuous"){const{skipRange:h,text:g,...y}=t;return{...y,min:i,max:a,text:[...g]}}const{piecewise_mode:l,pieces:c,categories:u,...d}=t,p={...d,min:i,max:a};return l==="pieces"?p.pieces=c.map(h=>{const g={};h.label&&(g.label=h.label),h.color&&(g.color=h.color);const y=Number(h.lower.value);h.lower.value!==""&&Number.isFinite(y)&&(g[h.lower.symbol]=y);const v=Number(h.upper.value);return h.upper.value!==""&&Number.isFinite(v)&&(g[h.upper.symbol]=v),g}):l==="categories"&&(p.categories=u),p}const Xt=t=>({followVisualMap:!t,color:t});function my(t,e,n,r){if(r.type!=="continuous")return Xt("");const{skipRange:i}=r;return t===e?Xt(i.min):t===n?Xt(i.max):t<e?Xt(i.lt_min):t>n?Xt(i.gt_max):Xt("")}function qo(){return{lower:{value:"0",symbol:"gt"},upper:{value:"",symbol:"lt"},label:"",color:""}}const xy=hy(),gy=({colors:t,applyPalette:e})=>{const{t:n}=_.useTranslation(),r=`linear-gradient(to right, ${t.join(", ")})`;return s.jsxs(o.Menu,{shadow:"md",width:300,children:[s.jsx(o.Menu.Target,{children:s.jsxs(o.UnstyledButton,{children:[s.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")}),s.jsxs(o.Group,{style:{padding:"0.4375rem 0.625rem",border:"0.0625rem solid #ced4da",borderRadius:"0.25rem",columnGap:10},children:[s.jsx(o.Box,{style:{height:"20px",flexGrow:1,backgroundImage:r,borderRadius:4}}),s.jsx(k.IconSelector,{size:14,color:"rgb(134, 142, 150)"})]})]})}),s.jsxs(o.Menu.Dropdown,{children:[s.jsx(o.Menu.Label,{children:n("chart.visual_map.built_in_palettes")}),s.jsx(o.Menu.Divider,{}),Object.entries(xy).map(([i,a])=>s.jsx(o.Tooltip,{label:n("chart.visual_map.use_palette_x",{x:i}),children:s.jsx(o.Menu.Item,{children:s.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:()=>{e(a)},title:i})})},i))]})]})},fy=m.forwardRef(({value:t,onChange:e},n)=>{const{t:r}=_.useTranslation(),i=m.useMemo(()=>t.map(g=>({id:pt.v4(),value:g})),[t]),a=g=>{e([...t,g])},l=g=>{const y=[...t];y.splice(g,1),e(y)},c=g=>{e([...g])},u=g=>y=>{const v=[...t];v[g]=y,e(v)},[d,p]=m.useState(""),h=()=>{d&&(a(d),p(""))};return s.jsxs(o.Stack,{ref:n,children:[s.jsx(gy,{colors:t,applyPalette:c}),s.jsx(o.Table,{withBorder:!1,withColumnBorders:!1,sx:{td:{borderTop:"none !important"}},children:s.jsxs("tbody",{children:[i.map((g,y)=>s.jsxs("tr",{children:[s.jsx("td",{style:{width:"60px"},children:s.jsx(o.Badge,{children:y})}),s.jsx("td",{children:s.jsx(o.ColorInput,{styles:{root:{flexGrow:1}},withinPortal:!0,dropdownZIndex:340,size:"xs",value:g.value,onChange:u(y)})}),s.jsx("td",{style:{width:"40px"},children:s.jsx(o.CloseButton,{onClick:()=>l(y)})})]},g.id)),s.jsxs("tr",{children:[s.jsx("td",{style:{width:"60px"}}),s.jsx("td",{children:s.jsx(o.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"}})]})]})})]})}),yy=({form:t})=>{const{t:e,i18n:n}=_.useTranslation(),r=t.control,i=t.watch("visualMap"),{type:a,orient:l}=i,c=l==="horizontal",u=d=>p=>{p!==""&&d(p)};return a!=="continuous"?null:s.jsxs(o.Stack,{children:[s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:"visualMap.text.1",control:r,render:({field:d})=>s.jsx(o.TextInput,{label:e("chart.visual_map.min_text"),...d})}),s.jsx(f.Controller,{name:"visualMap.text.0",control:r,render:({field:d})=>s.jsx(o.TextInput,{label:e("chart.visual_map.max_text"),...d})})]}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:"visualMap.orient",control:r,render:({field:d})=>s.jsx(wt,{sx:{flex:1},...d})}),s.jsx(f.Controller,{name:"visualMap.calculable",control:r,render:({field:d})=>s.jsx(o.Checkbox,{label:e("chart.visual_map.calculable"),checked:d.value,onChange:p=>d.onChange(p.currentTarget.checked),styles:{root:{transform:"translateY(12px)"}}})})]}),s.jsxs(o.Group,{grow:!0,styles:{root:{flexDirection:c?"row-reverse":"row"}},children:[s.jsx(f.Controller,{name:"visualMap.itemWidth",control:r,render:({field:d})=>s.jsx(o.NumberInput,{label:e(c?"chart.visual_map.bar_height":"chart.visual_map.bar_width"),...d,onChange:u(d.onChange)})}),s.jsx(f.Controller,{name:"visualMap.itemHeight",control:r,render:({field:d})=>s.jsx(o.NumberInput,{label:e(c?"chart.visual_map.bar_width":"chart.visual_map.bar_height"),...d,onChange:u(d.onChange)})})]}),s.jsx(f.Controller,{name:"visualMap.inRange.color",control:r,render:({field:d})=>s.jsx(fy,{...d})}),s.jsx(dy,{form:t})]})},by=({visualMap:t})=>{const{orient:e,itemWidth:n,itemHeight:r}=t,a=e==="horizontal"?n:r,{panel:l}=ze(),c=Lo(t,l.variableValueMap);return s.jsx(je,{children:s.jsx(Se,{echarts:Ce,option:{visualMap:c},style:{width:"100%",height:`${a+40}px`},notMerge:!0,theme:"merico-light"})})},Oo={lower:[{label:"<",value:"gt"},{label:"≤",value:"gte"}],upper:[{label:">",value:"lt"},{label:"≥",value:"lte"}]},Vo={gt:"(",gte:"[",lt:")",lte:"]"},No=(t,e)=>t===""||Number.isNaN(Number(t))?e+"∞":e+t,vy=({form:t,index:e})=>{const{control:n,watch:r}=t,i=r(`visualMap.pieces.${e}`),{lower:a,upper:l}=i,c=[Vo[a.symbol],No(a.value,"-"),",",No(l.value,""),Vo[l.symbol]].join(""),[u,d]=m.useState(!1);return s.jsx(o.Group,{noWrap:!0,children:s.jsxs(o.Popover,{width:400,position:"bottom",withArrow:!0,shadow:"md",opened:u,onChange:d,withinPortal:!0,zIndex:340,children:[s.jsx(o.Popover.Target,{children:s.jsx(o.Button,{variant:"subtle",compact:!0,px:0,onClick:()=>d(p=>!p),sx:{fontFamily:"monospace",fontWeight:"normal"},children:c})}),s.jsx(o.Popover.Dropdown,{children:s.jsxs(o.Group,{noWrap:!0,spacing:8,children:[s.jsx(f.Controller,{name:`visualMap.pieces.${e}.lower.value`,control:n,render:({field:p})=>s.jsx(o.TextInput,{...p,placeholder:"∞",size:"xs",onChange:h=>p.onChange(h.currentTarget.value),error:p.value!==""&&Number.isNaN(Number(p.value)),styles:{input:{"&::placeholder":{fontSize:"16px"}}}})}),s.jsx(f.Controller,{name:`visualMap.pieces.${e}.lower.symbol`,control:n,render:({field:p})=>s.jsx(o.Select,{size:"xs",data:Oo.lower,...p,onChange:h=>p.onChange(h)})}),s.jsx(o.Text,{color:"dimmed",size:"sm",sx:{userSelect:"none",cursor:"default"},children:"value"}),s.jsx(f.Controller,{name:`visualMap.pieces.${e}.upper.symbol`,control:n,render:({field:p})=>s.jsx(o.Select,{size:"xs",data:Oo.upper,...p,onChange:h=>p.onChange(h)})}),s.jsx(f.Controller,{name:`visualMap.pieces.${e}.upper.value`,control:n,render:({field:p})=>s.jsx(o.TextInput,{...p,size:"xs",placeholder:"∞",onChange:h=>p.onChange(h.currentTarget.value),error:p.value!==""&&Number.isNaN(Number(p.value)),styles:{input:{"&::placeholder":{fontSize:"16px"}}}})})]})})]})})},_y=({form:t,index:e,remove:n})=>{const{control:r}=t,{t:i}=_.useTranslation();return s.jsxs("tr",{children:[s.jsx("td",{children:e.toString()}),s.jsx("td",{children:s.jsx(vy,{form:t,index:e})}),s.jsx("td",{children:s.jsx(f.Controller,{name:`visualMap.pieces.${e}.label`,control:r,render:({field:a})=>s.jsx(o.TextInput,{size:"xs",placeholder:"",...a,onChange:l=>a.onChange(l.currentTarget.value)})})}),s.jsx("td",{children:s.jsx(f.Controller,{name:`visualMap.pieces.${e}.color`,control:r,render:({field:a})=>s.jsx(o.ColorInput,{label:i(""),placeholder:i("chart.color.label"),size:"xs",withinPortal:!0,dropdownZIndex:340,rightSection:a.value?s.jsx(o.CloseButton,{onClick:()=>{a.onChange("")}}):null,...a})})}),s.jsx("td",{children:s.jsx(o.CloseButton,{onClick:()=>n(e)})})]})},jy=({form:t})=>{const{t:e,i18n:n}=_.useTranslation(),{fields:r,append:i,remove:a}=f.useFieldArray({control:t.control,name:"visualMap.pieces"}),l=t.watch("visualMap.pieces"),c=r.map((d,p)=>({...d,...l[p]})),u=()=>{i(qo())};return s.jsx(o.Stack,{children:s.jsxs(o.Table,{children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"40px"}}),s.jsx("th",{children:"Interval"}),s.jsx("th",{children:"Label"}),s.jsx("th",{children:"Color"}),s.jsx("th",{style:{width:"40px"}})]})}),s.jsx("tbody",{children:c.map((d,p)=>s.jsx(_y,{index:p,form:t,remove:a},d.id))}),s.jsx("tfoot",{children:s.jsxs("tr",{children:[s.jsx("td",{}),s.jsx("td",{colSpan:3,children:s.jsx(o.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",{})]})})]})})},wy=({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:a,orient:l,piecewise_mode:c}=i,u=d=>p=>{p!==""&&d(p)};return a!=="piecewise"?null:s.jsxs(o.Stack,{children:[s.jsx(f.Controller,{name:"visualMap.precision",control:r,render:({field:d})=>s.jsx(o.NumberInput,{label:e("chart.visual_map.precision"),...d,onChange:u(d.onChange)})}),s.jsx(f.Controller,{name:"visualMap.orient",control:r,render:({field:d})=>s.jsx(wt,{sx:{flex:1},...d})}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:"visualMap.itemWidth",control:r,render:({field:d})=>s.jsx(o.NumberInput,{label:e("chart.visual_map.item_width"),...d,onChange:u(d.onChange)})}),s.jsx(f.Controller,{name:"visualMap.itemHeight",control:r,render:({field:d})=>s.jsx(o.NumberInput,{label:e("chart.visual_map.item_height"),...d,onChange:u(d.onChange)})})]}),c==="pieces"&&s.jsx(jy,{form:t})]})},Cy=({form:t})=>{const{t:e,i18n:n}=_.useTranslation(),r=t.control,i=t.watch("visualMap"),a=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",Bo());break;case"piecewise":t.setValue("visualMap",py());break}};return s.jsx(je,{children:s.jsxs(o.Stack,{children:[s.jsx(by,{visualMap:i}),s.jsx(f.Controller,{name:"visualMap.type",control:r,render:({field:c})=>s.jsx(o.SegmentedControl,{mt:-10,data:a,sx:{flex:1},...c,onChange:l})}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:"visualMap.min",control:r,render:({field:c})=>s.jsx(Kt,{label:e("chart.visual_map.min_value"),...c})}),s.jsx(f.Controller,{name:"visualMap.max",control:r,render:({field:c})=>s.jsx(Kt,{label:e("chart.visual_map.max_value"),...c})})]}),s.jsx(o.Divider,{variant:"dashed"}),s.jsx(yy,{form:t}),s.jsx(wy,{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 a=n.reduce((A,N)=>{const R=Ze(N,e);return A[N.name]=Ie(N,R),A},{}),l=Lo(t.visualMap,a),{min:c,max:u}=l,d=Zf(t),p=Hf(t),h=E(t.x_axis.data_key),g=E(t.y_axis.data_key),y=E(t.heat_block.data_key),v=b.uniq(e[h.queryID].map(A=>A[h.columnKey])),w=b.uniq(e[h.queryID].map(A=>A[g.columnKey])),T=e[h.queryID].map(A=>{const N=b.get(A,h.columnKey),R=b.get(A,g.columnKey),F=b.get(A,y.columnKey),Q={value:[N,R,F]},{followVisualMap:ue,color:le}=my(F,c,u,t.visualMap);return ue||(Q.visualMap=!1,Q.itemStyle={color:le}),Q}),D=Sy(v.length,w.length,r,i);return{xAxis:iy(t,v,d.x_axis,D),yAxis:ay(t,w,d.y_axis,D),series:ty(t,T,D),tooltip:ry(t,e,d,p),grid:ey(t),visualMap:l}}function Ty(t){return s.jsx(s.Fragment,{})}function Dy(t){const{t:e}=_.useTranslation();return s.jsx(o.Text,{children:e("viz.merico_heatmap.click_heatmap.heatblock.label")})}const Go={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"}]},jr={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:_r()};function zy({conf:t,data:e,width:n,height:r,interactionManager:i,variables:a}){const l=m.useMemo(()=>{const h=E(t.x_axis.data_key),g=E(t.y_axis.data_key);return b.keyBy(e[h.queryID],y=>`${y[h.columnKey]}---${y[g.columnKey]}`)},[e,t.x_axis.data_key,t.y_axis.data_key]),c=qe(i.triggerManager,Go.id),u=m.useCallback(h=>{const[g,y]=h.value,v=b.get(l,`${g}---${y}`,{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,a,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,a=m.useMemo(()=>b.defaults({},r,jr),[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:a,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(o.Stack,{children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.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(f.Controller,{name:"heat_block.name",control:t,render:({field:i})=>s.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...i})})]}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("numbro.format.label"),labelPosition:"center"}),s.jsx(f.Controller,{name:"heat_block.value_formatter",control:t,render:({field:i})=>s.jsx(Re,{...i})}),s.jsx(o.Divider,{mb:-5,variant:"dashed",label:n("chart.label.label"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"heat_block.label.show",control:t,render:({field:i})=>s.jsx(o.Switch,{label:n("chart.heatmap.heatblock.show_label"),checked:i.value,onChange:a=>i.onChange(a.currentTarget.checked),sx:{flexGrow:1}})}),s.jsx(f.Controller,{name:"heat_block.label.fontSize",control:t,render:({field:i})=>s.jsx(o.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(o.Stack,{children:s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`tooltip.metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(f.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=(a,l)=>{const c=a.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),s.jsx(o.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:a,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(o.Stack,{children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.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(f.Controller,{name:"x_axis.name",control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...r})})]}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsx(f.Controller,{name:"x_axis.axisLabel.overflow",control:t,render:({field:r})=>s.jsx(nt,{...r})}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:r})=>s.jsx(xt,{sx:{width:"48%"},...r})}),s.jsx(f.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(o.Stack,{my:0,p:"0",sx:{position:"relative"},children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.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(f.Controller,{name:"y_axis.name",control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...r})})]}),s.jsx(o.Group,{grow:!0,noWrap:!0,children:s.jsx(f.Controller,{name:"y_axis.nameAlignment",control:t,render:({field:r})=>s.jsx(kt,{sx:{flex:1},...r})})}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsx(f.Controller,{name:"y_axis.axisLabel.overflow",control:t,render:({field:r})=>s.jsx(nt,{...r})}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"y_axis.axisLabel.rotate",control:t,render:({field:r})=>s.jsx(xt,{sx:{width:"48%"},...r})}),s.jsx(f.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):jr,[n]),a=m.useMemo(()=>b.cloneDeep(i),[i]);m.useEffect(()=>{!b.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),r(a))},[i,a]);const l=f.useForm({defaultValues:a}),{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=l;m.useEffect(()=>{h(a)},[a]);const g=p(),y=m.useMemo(()=>!b.isEqual(g,i),[g,i]);return s.jsx("form",{onSubmit:u(r),style:{flexGrow:1},children:s.jsxs(o.Stack,{spacing:"xs",sx:{height:"100%"},children:[s.jsx(ge,{canSubmit:y}),s.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{root:{flexGrow:1},tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"X Axis",children:e("chart.x_axis.label")}),s.jsx(o.Tabs.Tab,{value:"Y Axis",children:e("chart.y_axis.label")}),s.jsx(o.Tabs.Tab,{value:"Heat Block",children:e("chart.heatmap.heatblock.label")}),s.jsx(o.Tabs.Tab,{value:"Visual Map",children:e("chart.visual_map.label")}),s.jsx(o.Tabs.Tab,{value:"Tooltip",children:e("chart.tooltip.label")})]}),s.jsx(o.Tabs.Panel,{value:"X Axis",children:s.jsx($y,{control:c,watch:d})}),s.jsx(o.Tabs.Panel,{value:"Y Axis",children:s.jsx(By,{control:c,watch:d})}),s.jsx(o.Tabs.Panel,{value:"Heat Block",children:s.jsx(Iy,{control:c,watch:d})}),s.jsx(o.Tabs.Panel,{value:"Visual Map",children:s.jsx(Cy,{form:l})}),s.jsx(o.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:a,heat_block:l,tooltip:c,...u}=t;return{...u,x_axis:{...i,data_key:r(i.data_key)},y_axis:{...a,data_key:r(a.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=_r(),heat_block:{min:n,max:r,...i},...a}=t;return{...a,heat_block:i,visualMap:{..._r(),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:jr}),triggers:[Go],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:"点击柱或线"}}}}],Fo={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(o.Text,{children:e("viz.pareto_chart.click_series.label")})}const Wo={label_template:"${percentage.x} of ${x_axis.name} causes ${percentage.y} of ${bar.name}",color:"#789AB4"},wr={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:zt,markLine:Wo,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},a=Object.keys(i),l=Object.values(i);return new Function(...a,`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])},a={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,a)}}]},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 a=E(r.data_key),l=E(i);if(a.queryID!==l.queryID)throw new Error("Please use the same query for X & Y axis");const c=e[a.queryID].map(g=>[g[a.columnKey],Number(g[l.columnKey])]).sort((g,y)=>y[1]-g[1]),u=c.reduce((g,y)=>g+y[1],0),d=c.reduce((g,y,v)=>{const w=v===0?0:g[v-1][1];return g.push([y[0],w+y[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`
|
|
169
|
+
`}})}function N0(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 $0(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 F0=({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}}})})},Sp={static:{type:"static",value:10},dynamic:{type:"dynamic",value:["function getValue({ variables }, { lodash, interpolate }) {"," // your code goes here"," return 100;","}"].join(`
|
|
170
|
+
`)}},G0=({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),[s,{setTrue:i,setFalse:a}]=W.useBoolean(),[l,c]=g.useState(e),u=()=>{a();const{type:f,value:x}=l,y={type:f,value:x};c(y),t(y)},d=()=>{a(),c(e)},p=f=>{c(x=>({...x,value:f}))},h=()=>{p(Sp.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(F0,{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")})]})]})]})})]})},W0=({value:e,onChange:t})=>e.type!=="dynamic"?null:r.jsx(G0,{value:e,onChange:t}),R0=({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})},kp=g.forwardRef(({label:e="Value",value:t,onChange:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=u=>{n({...Sp[u]})},c=g.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(R0,{value:t,onChange:n}),r.jsx(W0,{value:t,onChange:n})]})});function Tp(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:bn.interpolate});return Number(i)}catch(i){return console.error(`[getNumberOrDynamicValue] failed parsing custom function, error: ${i.message}`),10}}const Ys=({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})},Q0=({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(Ys,{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(Ys,{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(Ys,{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(Ys,{field:n,label:t("chart.visual_map.skip_range.gt_max")})})]})};function Dp(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(vn.graphics.depth)},skipRange:{lt_min:"",min:"",max:"",gt_max:""}}}function U0(){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:[Mp()],categories:[]}}function Jt(){return Dp()}function Y0(){return{compared:Object.values(vn.graphics.compared),level:Object.values(vn.graphics.level),depth:Object.values(vn.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 Ks(e,t){const{min:n,max:s}=e,i=Tp(n,t),a=Tp(s,t);if(e.type==="continuous"){const{skipRange:h,text:f,...x}=e;return{...x,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 x=Number(h.lower.value);h.lower.value===""?f[h.lower.symbol]=i:Number.isFinite(x)&&(f[h.lower.symbol]=x);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 xo(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 Mp(){return{lower:{value:"0",symbol:"gt"},upper:{value:"",symbol:"lt"},label:"",color:""}}const K0=Y0(),X0=({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(K0).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))]})]})},J0=({color:e,index:t,handleChange:n,handleRemove:s})=>{const[i,{setTrue:a,setFalse:l}]=W.useBoolean(!1),{ref:c,handleRef:u}=qd({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})})]})},Z0=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),i=g.useMemo(()=>e.map(x=>({id:Wt.v4(),value:x})),[e]),a=x=>{t([...e,x])},l=x=>{const y=[...e];y.splice(x,1),t(y)},c=x=>{t([...x])},u=x=>y=>{const j=[...e];j[x]=y,t(j)},[d,p]=g.useState(""),h=()=>{d&&(a(d),p(""))},f=x=>{const{source:y,target:j}=x.operation,k=vg.move(i,y,j);t(k.map(S=>S.value))};return r.jsxs(o.Stack,{ref:n,children:[r.jsx(X0,{colors:e,applyPalette:c}),r.jsx(Hr.DragDropProvider,{onDragEnd:f,children:i.map((x,y)=>r.jsx(J0,{color:x,handleChange:u(y),handleRemove:()=>l(y),index:y},x.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}})]})]})}),H0=({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(fn,{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(Z0,{...d})}),r.jsx(Q0,{form:e})]})},eC=({visualMap:e})=>{const{orient:t,itemWidth:n,itemHeight:s}=e,a=t==="horizontal"?n:s,{panel:l}=Ge(),c=Ks(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"})})},zp={lower:[{label:"<",value:"gt"},{label:"≤",value:"gte"}],upper:[{label:">",value:"lt"},{label:"≥",value:"lte"}]},Ip={gt:"(",gte:"[",lt:")",lte:"]"},Ep=(e,t)=>e===""?t:Number.isNaN(Number(e))?"INVALID VALUE":e,tC=({form:e,index:t})=>{const{t:n}=_.useTranslation(),{control:s,watch:i}=e,a=i(`visualMap.pieces.${t}`),{lower:l,upper:c}=a,u=[Ip[l.symbol],Ep(l.value,n("chart.visual_map.min_value")),",",Ep(c.value,n("chart.visual_map.max_value")),Ip[c.symbol]].join(""),[d,p]=g.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:zp.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:zp.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))})})]})})]})})},nC=({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(tC,{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)})})]})},rC=({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(Mp())};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(nC,{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",{})]})})]})})},sC=({form:e})=>{const{t,i18n:n}=_.useTranslation(),s=e.control,i=e.watch("visualMap");g.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(fn,{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(rC,{form:e})]})},yo=({form:e})=>{const{t,i18n:n}=_.useTranslation(),s=e.control,i=e.watch("visualMap"),a=g.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",Dp());break;case"piecewise":e.setValue("visualMap",U0());break}};return r.jsx(ze,{children:r.jsxs(o.Stack,{children:[r.jsx(eC,{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(kp,{label:t("chart.visual_map.min_value"),...c})}),r.jsx(b.Controller,{name:"visualMap.max",control:s,render:({field:c})=>r.jsx(kp,{label:t("chart.visual_map.max_value"),...c})})]}),r.jsx(o.Divider,{variant:"dashed"}),r.jsx(H0,{form:e}),r.jsx(sC,{form:e})]})})};function iC(e,t,n,s){return n<e*10||s<t*10?0:n<e*20||s<t*20?1:2}function aC(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=_t(I,t);return z[I.name]=Re(I,E),z},{}),l=Ks(e.visualMap,a),{min:c,max:u}=l,d=A0(e),p=P0(e),h=O(e.x_axis.data_key),f=O(e.y_axis.data_key),x=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,x.columnKey),R={value:[I,E,N]},{followVisualMap:pe,color:ie}=xo(N,c,u,e.visualMap);return pe||(R.visualMap=!1,R.itemStyle={color:ie}),R}),S=iC(y.length,j.length,s,i);return{xAxis:N0(e,y,d.x_axis,S),yAxis:$0(e,j,d.y_axis,S),series:L0(e,k,S),tooltip:V0(e,t,d,p),grid:O0(e),visualMap:l}}function oC(e){return r.jsx(r.Fragment,{})}function lC(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.merico_heatmap.click_heatmap.heatblock.label")})}const Ap={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.merico_heatmap.click_heatmap.heatblock.label",nameRender:lC,configRender:oC,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"}]},bo={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:Jt()};function cC({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=g.useMemo(()=>{const h=O(e.x_axis.data_key),f=O(e.y_axis.data_key);return v.keyBy(t[h.queryID],x=>`${x[h.columnKey]}---${x[f.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),c=nt(i.triggerManager,Ap.id),u=g.useCallback(h=>{const[f,x]=h.value,y=v.get(l,`${f}---${x}`,{error:"rowData is not found"});c.forEach(j=>{i.runInteraction(j.id,{...h,rowData:y})})},[l,c,i]),d=g.useMemo(()=>({click:u}),[u]),p=g.useMemo(()=>aC(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 uC({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,bo),[s]),l=e.data,{width:c,height:u}=e.viewport;return!c||!u?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(cC,{variables:i,width:jt(c),height:wt(u),data:l,conf:a,interactionManager:n})})}function dC({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 pC=({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})})]})})},hC=({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(pC,{control:e,index:l})})]})};function fC({control:e,watch:t}){return r.jsx(hC,{control:e,watch:t})}function gC({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(St,{...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(Kt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(Ct,{...s})})]})]})}function mC({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(xn,{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(St,{...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(Kt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(Ct,{...s})})]})]})}function xC({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>n?v.defaults({},n):bo,[n]),a=g.useMemo(()=>v.cloneDeep(i),[i]);g.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;g.useEffect(()=>{h(a)},[a]);const f=p(),x=g.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:x}),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(gC,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx(mC,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Heat Block",children:r.jsx(dC,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Visual Map",children:r.jsx(yo,{form:l})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(fC,{control:c,watch:d})})]})]})})}const yC=[{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 bC(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 vC(e){return v.defaultsDeep({},e,{heat_block:{label:{show:!1,fontSize:10}}})}function _C(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 jC(e){const{visualMap:t=Jt(),heat_block:{min:n,max:s,...i},...a}=e;return{...a,heat_block:i,visualMap:{...Jt(),min:n,max:s}}}class wC extends me{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:bC(n.config,s)})),this.version(3,n=>({...n,version:3,config:vC(n.config)})),this.version(4,n=>({...n,version:4,config:_C(n.config)})),this.version(5,n=>({...n,version:5,config:jC(n.config)}))}}const CC={displayName:"viz.heatmap.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new wC,name:"heatmap",viewRender:uC,configRender:xC,createConfig:()=>({version:5,config:bo}),triggers:[Ap],translation:yC},SC=[{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:"点击柱或线"}}}}],Pp={id:"builtin:echarts:click-echart:series",displayName:"viz.pareto_chart.click_series.label",nameRender:TC,configRender:kC,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 kC(e){return r.jsx(r.Fragment,{})}function TC(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.pareto_chart.click_series.label")})}const Op={label_template:"${percentage.x} of ${x_axis.name} causes ${percentage.y} of ${bar.name}",color:"#789AB4"},vo={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:_n,markLine:Op,reference_lines:[]};function Xs(e){return U(e,{output:"percent",mantissa:0,absolute:!1})}function DC(e){const t=e.value[1];try{return Xs(t)}catch(n){return console.error(n),t}}function MC(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:DC,lineValue:Xs}}function zC(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 IC(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:Xs((n+1)/t.length),y:Xs(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:zC(e,i,a)}}]},markArea:{name:"",silent:!0,itemStyle:{color:"rgba(47, 140, 192, 0.05)"},data:[[{coord:["min",0]},{xAxis:l}]]}}:{}}function EC(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,x)=>x[1]-f[1]),u=c.reduce((f,x)=>f+x[1],0),d=c.reduce((f,x,y)=>{const j=y===0?0:f[y-1][1];return f.push([x[0],j+x[1]]),f},[]).map(f=>[f[0],f[1]/u]),{markLine:p,markArea:h}=IC(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 AC=(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
171
|
<tr>
|
|
172
172
|
<th style="text-align: right; padding: 0 1em;">${d}</th>
|
|
173
|
-
<td style="text-align: left; padding: 0 1em;">${
|
|
173
|
+
<td style="text-align: left; padding: 0 1em;">${f(h)}</td>
|
|
174
174
|
</tr>
|
|
175
|
-
`}),a=
|
|
175
|
+
`}),a=ct(e.x_axis.axisLabel.overflow.in_tooltip),l=s[0].name;return`
|
|
176
176
|
<div style="text-align: left; margin-bottom: .5em; padding: 0 1em .5em; font-weight: bold; border-bottom: 1px dashed #ddd;">
|
|
177
177
|
<div style="${a}">${l}</div>
|
|
178
178
|
</div>
|
|
@@ -181,9 +181,9 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
181
181
|
${i.join("")}
|
|
182
182
|
</tbody>
|
|
183
183
|
</table>
|
|
184
|
-
`};function
|
|
184
|
+
`};function PC(e,t){return te.getTooltip({trigger:"axis",formatter:AC(e,t)})}function OC(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 LC(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 BC(e,t){return t?[e]:[]}function qC(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=BC(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?gr(i.template,t,s):""},position:u}}}})}function VC(e,t,n){const s=Ka(t,n),i=MC(e),a={dataZoom:us(e.dataZoom),tooltip:PC(e,i),xAxis:OC(e),yAxis:LC(e,i),series:[...EC(e,t,i),...qC(e.reference_lines,n,s,t)],grid:{top:50,left:30,right:15,bottom:5,containLabel:!0}};return console.log(a),a}function NC({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,vo),u=VC(c,i,n),d=rt({vizManager:e.vizManager,instance:t}),p=nt(d.triggerManager,Pp.id),h=jn(i,c.x_axis.data_key),f=g.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]),x=g.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:mr(a,l),onEvents:x,notMerge:!0,theme:"merico-light"})})}function $C({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(xn,{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 FC({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(xn,{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 GC=(e,t)=>`
|
|
185
185
|
{
|
|
186
|
-
// ${
|
|
186
|
+
// ${e}
|
|
187
187
|
percentage: {
|
|
188
188
|
x: string; // 20%
|
|
189
189
|
y: string; // 80%
|
|
@@ -193,7 +193,7 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
193
193
|
right: number; // 8
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
// ${
|
|
196
|
+
// ${t}
|
|
197
197
|
x_axis: {
|
|
198
198
|
name: string;
|
|
199
199
|
};
|
|
@@ -204,8 +204,8 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
204
204
|
name: string;
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
|
-
`,
|
|
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
|
|
207
|
+
`,WC=()=>{const{t:e,i18n:t}=_.useTranslation(),[n,s]=g.useState(!1),i=g.useMemo(()=>GC(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(nn.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:i})})]})};function RC({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(WC,{})]})]})}function QC({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(Kt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(Ct,{...s})})]}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(St,{...s})})]})}function UC({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 YC({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(fn,{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(Jn,{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 KC({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=g.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),c=t(["bar.name","line.name"]),u=g.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(YC,{control:e,index:p,watch:t,variableOptions:l,yAxisOptions:u})})}function XC({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},n,vo),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});g.useEffect(()=>{p(a)},[a]),u(["x_axis","data_key","bar","line","dataZoom"]);const h=d(),f=g.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(QC,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx(UC,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Bar",children:r.jsx($C,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Line",children:r.jsx(FC,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"80-20 Line",children:r.jsx(RC,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx(KC,{variables:i,control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Zooming",children:r.jsx(b.Controller,{name:"dataZoom",control:l,render:({field:x})=>r.jsx(As,{...x})})})]})]})}function JC(e){const{dataZoom:t=_n,...n}=e;return{...n,dataZoom:t}}function ZC(e){const{markLine:t=Op,...n}=e;return{...n,markLine:t}}function HC(e){const t=v.defaultsDeep({},e.x_axis.axisLabel,{rotate:0,formatter:Oe()});return{...e,x_axis:{...e.x_axis,axisLabel:t}}}function eS(e){const{label_formatter:t=Me}=e.bar;return{...e,bar:{...e.bar,label_formatter:t}}}function tS(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 nS(e){const t={bar:{nameAlignment:"left"},line:{nameAlignment:"right"}};return v.defaultsDeep(t,e)}function rS(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 sS(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 iS extends me{constructor(){super(...arguments);B(this,"VERSION",9)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:JC(n.config)})),this.version(3,n=>({...n,version:3,config:ZC(n.config)})),this.version(4,n=>({...n,version:4,config:HC(n.config)})),this.version(5,n=>({...n,version:5,config:eS(n.config)})),this.version(6,n=>({...n,version:6,config:tS(n.config)})),this.version(7,n=>({...n,version:7,config:nS(n.config)})),this.version(8,n=>({...n,version:8,config:rS(n.config)})),this.version(9,(n,s)=>({...n,version:9,config:sS(n.config,s)}))}}const aS={displayName:"viz.pareto_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new iS,name:"paretoChart",viewRender:NC,configRender:XC,createConfig(){return{version:9,config:v.cloneDeep(vo)}},triggers:[Pp],translation:SC};function oS(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=Em("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 f=h.labelRect.x<n/2,x=h.labelLinePoints;return v.set(x,[2,0],f?h.labelRect.x:h.labelRect.x+h.labelRect.width),{labelLinePoints:x}},data:d,top:10,bottom:10,left:10,right:10}}function lS(e,t,n){return{tooltip:te.getTooltip({}),series:oS(e,t,n)}}const Lp={id:"builtin:echarts:click-pie-chart:series",displayName:"viz.pie_chart.click_series.label",nameRender:uS,configRender:cS,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 cS(e){return r.jsx(r.Fragment,{})}function uS(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.pie_chart.click_series.label")})}const _o={label_field:"",value_field:"",color_field:""};function dS({conf:e,data:t,width:n,height:s,interactionManager:i}){const a=jn(t,e.label_field),l=nt(i.triggerManager,Lp.id),c=g.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=g.useMemo(()=>lS(e,t,n),[e,t,n]),d=g.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 pS({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),i=g.useMemo(()=>v.defaults({},s,_o),[s]),a=e.data,{width:l,height:c}=e.viewport;return!l||!c?null:r.jsx(Ue,{width:l,height:c,children:r.jsx(dS,{conf:i,width:jt(l),height:wt(c),data:a,interactionManager:n})})}function hS({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>v.defaultsDeep({},n,_o),[n]),a=g.useMemo(()=>v.clone(i),[i]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});g.useEffect(()=>{p(a)},[a]);const h=d(),f=g.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:x})=>r.jsx(F,{label:t("common.name_data_field"),required:!0,...x})}),r.jsx(b.Controller,{control:l,name:"value_field",render:({field:x})=>r.jsx(F,{label:t("common.value_data_field"),required:!0,...x})}),r.jsx(b.Controller,{control:l,name:"color_field",render:({field:x})=>r.jsx(F,{label:t("common.color_data_field"),clearable:!0,...x})})]})]})})}const fS=[{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 gS(e){const{color_field:t="",...n}=e;return{...n,color_field:t}}function mS(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 xS extends me{constructor(){super(...arguments);B(this,"VERSION",3)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:gS(n.config)})),this.version(3,(n,s)=>({...n,version:3,config:mS(n.config,s)}))}}const yS={displayName:"viz.pie_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new xS,name:"pie",viewRender:pS,configRender:hS,createConfig(){return{version:3,config:v.cloneDeep(_o)}},triggers:[Lp],translation:fS};function bS(e){return r.jsx(r.Fragment,{})}function vS(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.radar_chart.click_series.label")})}const Bp={id:"builtin:echarts:click-radar-chart:series",displayName:"viz.radar_chart.click_series.label",nameRender:vS,configRender:bS,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"}]},Js={series_name_key:"",additional_series:[],background:{enabled:!0},label:{enabled:!0},dimensions:[]};function qp(e){return e?t=>{try{return U(t,e)}catch(n){return console.error(n),t}}:t=>t}function Vp(e){return{show:e.label.enabled,formatter:({dimensionIndex:t,value:n})=>qp(e.dimensions[t].formatter)(n)}}function Np(e,t){return t.map(({data_key:n})=>{const s=O(n);return e[s.columnKey]})}function _S(e,t,n){const s=O(t);return e[s.queryID].map(i=>({value:Np(i,n),name:i[s.columnKey]}))}function jS(e,t){const{series_name_key:n,dimensions:s}=t;return[{type:"radar",name:"main-radar",data:_S(e,n,s),symbolSize:4,lineStyle:{width:1},emphasis:{lineStyle:{width:4}},areaStyle:t.background.enabled?{opacity:.4}:void 0,label:Vp(t)}]}function wS(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:Np(p,s),itemStyle:{color:f}}}),symbolSize:4,lineStyle:{width:1},emphasis:{lineStyle:{width:4}},areaStyle:t.background.enabled?{opacity:.4}:void 0,label:Vp(t)}}).flat()}function CS(e,t){return[...jS(e,t),...wS(e,t)]}function SS(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=qp(c.formatter);return`
|
|
209
209
|
<tr>
|
|
210
210
|
<td style="padding-left: 18px;">${c.name}</td>
|
|
211
211
|
<td style="text-align: right; "><strong>${u(a)}</strong></td>
|
|
@@ -225,7 +225,7 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
225
225
|
text-align: left;
|
|
226
226
|
vertical-align: top;
|
|
227
227
|
"
|
|
228
|
-
>${
|
|
228
|
+
>${t}</strong>
|
|
229
229
|
</th>
|
|
230
230
|
</tr>
|
|
231
231
|
</thead>
|
|
@@ -233,7 +233,7 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
233
233
|
${i.join("")}
|
|
234
234
|
</tbody>
|
|
235
235
|
</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:a}){const l=m.useMemo(()=>{const{queryID:h,columnKey:g}=E(t.series_name_key),y=b.keyBy(e[h],g),v=t.additional_series.reduce((w,T)=>{const D=E(T.name_key),I=b.keyBy(e[D.queryID],D.columnKey);return{...w,...I}},y);return{...y,...v}},[e,t.series_name_key,t.additional_series]),c=qe(i.triggerManager,Ro.id),u=m.useCallback(h=>{const g=b.get(l,h.name,{error:"rowData is not found"});c.forEach(y=>{i.runInteraction(y.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,a=m.useMemo(()=>b.defaults({},r,ts),[r]),l=t.data,{width:c,height:u}=t.viewport;return!c||!u||!a||b.isEmpty(a==null?void 0:a.dimensions)?null:s.jsx(Ae,{width:c,height:u,children:s.jsx(Kb,{variables:i,width:He(c),height:et(u),data:l,conf:a,interactionManager:n})})}function Xb({control:t,index:e}){const{t:n}=_.useTranslation();return s.jsxs(o.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[s.jsx(o.Group,{grow:!0,noWrap:!0,children:s.jsx(f.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(o.Stack,{children:s.jsx(f.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=(a,l)=>l+1;return s.jsxs(s.Fragment,{children:[s.jsx(o.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(o.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:a,index:l})=>s.jsx(Xb,{control:t,index:l})})]})}function Hb({control:t,index:e}){const{t:n}=_.useTranslation();return s.jsxs(o.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,align:"top",children:[s.jsx(f.Controller,{name:`dimensions.${e}.name`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(f.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(f.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 a;return s.jsx(o.TextInput,{label:n("common.max"),required:!0,sx:{flex:1},...r,error:(a=i.error)==null?void 0:a.message})}})]}),s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("viz.radar_chart.metric.value_formatter"),labelPosition:"center"}),s.jsx(f.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 a=new Date().getTime().toString();return{id:a,name:a,data_key:"",max:"100",formatter:_e}},i=(a,l)=>{const c=a.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:a,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:a,handleSubmit:l,watch:c,getValues:u,reset:d,formState:p}=f.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(o.Stack,{spacing:"xs",children:[s.jsx(ge,{canSubmit:g&&p.isValid}),s.jsxs(o.Tabs,{defaultValue:"series",children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"series",children:e("chart.series.label")}),s.jsx(o.Tabs.Tab,{value:"metrics",children:e("viz.radar_chart.metric.labels")}),s.jsx(o.Tabs.Tab,{value:"style",children:e("chart.style.label")}),s.jsx(o.Tabs.Tab,{value:"additional_series",ml:"auto",children:e("viz.radar_chart.additional_series.label")})]}),s.jsx(o.Tabs.Panel,{value:"series",p:"md",children:s.jsx(f.Controller,{name:"series_name_key",control:a,render:({field:y})=>s.jsx(O,{label:e("viz.radar_chart.series.series_name_field"),required:!0,sx:{flex:1},...y})})}),s.jsx(o.Tabs.Panel,{value:"metrics",p:"md",children:s.jsx(ev,{control:a,watch:c})}),s.jsx(o.Tabs.Panel,{value:"style",p:"md",children:s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"background.enabled",control:a,render:({field:y})=>s.jsx(o.Checkbox,{label:e("viz.radar_chart.style.show_background"),checked:y.value,onChange:v=>y.onChange(v.currentTarget.checked)})}),s.jsx(f.Controller,{name:"label.enabled",control:a,render:({field:y})=>s.jsx(o.Checkbox,{label:e("viz.radar_chart.style.show_value_label"),checked:y.value,onChange:v=>y.onChange(v.currentTarget.checked)})})]})}),s.jsx(o.Tabs.Panel,{value:"additional_series",p:"md",children:s.jsx(Zb,{control:a,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:a="",max:l=10,formatter:c=_e}){return{name:i,data_key:a,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:a,...l}=t;return{...l,series_name_key:r(i),dimensions:a.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:[Ro],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:On(r,i.data),color:i.color,showSymbol:!1,smooth:!0,tooltip:{show:!1},custom:{type:"regression-line",targetSeries:i.name}}))}function Jo(t,e){const n=E(t.x_axis.data_key),r=E(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=Jo(t,e);return[{type:"scatter",name:t.y_axis.name,data:i,symbolSize:4,color:"red",markLine:{...n,data:[On(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,a=E(i),l=b.groupBy(e,a.columnKey);return Object.entries(l).map(([c,u])=>{const d=Jo(t,u);return{type:"scatter",name:c,data:d,symbolSize:4,markLine:{...n,data:[On(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?"":`
|
|
236
|
+
`}}const kS={legend:{show:!0,bottom:0,left:0},tooltip:{trigger:"item"}},TS=["#66B4DB","#39BFA2","#E46464","#33A678","#EEBA00","#9D88CB","#939943","#E49792","#09A2B8","#AF5F6B","#6CA157","#09A2B8","#6398C7","#E692BA","#97B566","#8CACE2","#CA79AC","#6DBC80","#B08F4B","#826BAF"];function DS(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:SS(e)}),legend:{show:!0,bottom:0,left:"center",type:"scroll"},series:CS(t,e),color:TS};return v.merge({},kS,l)}function MS({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=g.useMemo(()=>{const{queryID:h,columnKey:f}=O(e.series_name_key),x=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}},x);return{...x,...y}},[t,e.series_name_key,e.additional_series]),c=nt(i.triggerManager,Bp.id),u=g.useCallback(h=>{const f=v.get(l,h.name,{error:"rowData is not found"});c.forEach(x=>{i.runInteraction(x.id,{...h,rowData:f})})},[l,c,i]),d=g.useMemo(()=>({click:u}),[u]),p=g.useMemo(()=>DS(v.defaultsDeep({},e,Js),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 zS({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,Js),[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(MS,{variables:i,width:jt(c),height:wt(u),data:l,conf:a,interactionManager:n})})}function IS({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 ES({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(IS,{control:e,index:l})})]})}function AS({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 PS({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(AS,{control:e,index:l})})})}function OS({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>v.defaultsDeep({},n,Js),[n]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d,formState:p}=b.useForm({defaultValues:i,mode:"all"});g.useEffect(()=>{d(i)},[i]),c(["series_name_key","background","label"]);const h=u(),f=g.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:x})=>r.jsx(F,{label:t("viz.radar_chart.series.series_name_field"),required:!0,sx:{flex:1},...x})})}),r.jsx(o.Tabs.Panel,{value:"metrics",p:"md",children:r.jsx(PS,{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:x})=>r.jsx(o.Checkbox,{label:t("viz.radar_chart.style.show_background"),checked:x.value,onChange:y=>x.onChange(y.currentTarget.checked)})}),r.jsx(b.Controller,{name:"label.enabled",control:a,render:({field:x})=>r.jsx(o.Checkbox,{label:t("viz.radar_chart.style.show_value_label"),checked:x.value,onChange:y=>x.onChange(y.currentTarget.checked)})})]})}),r.jsx(o.Tabs.Panel,{value:"additional_series",p:"md",children:r.jsx(ES,{control:a,watch:c})})]})]})})}const LS=[{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 BS(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 qS(e){const{dimensions:t=[],...n}=e;return{...n,dimensions:t.map(s=>({...s,id:s.id??s.name}))}}function VS(e){const t={background:{enabled:!0},label:{enabled:!0}};return v.defaultsDeep(t,e)}function NS(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 $S(e){const t={additional_series:[]};return v.defaultsDeep(t,e)}function FS(e){const t={...e,dimensions:e.dimensions.map(n=>({...n,max:String(n.max)}))};return delete t.additionalSeries,t}class GS extends me{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:BS(s)}}),this.version(3,n=>{const{config:s}=n;return{...n,version:3,config:qS(s)}}),this.version(4,n=>{const{config:s}=n;return{...n,version:4,config:VS(s)}}),this.version(5,(n,s)=>{const{config:i}=n;return{...n,version:5,config:NS(i,s)}}),this.version(6,n=>{const{config:s}=n;return{...n,version:6,config:$S(s)}}),this.version(7,n=>{const{config:s}=n;return{...n,version:7,config:FS(s)}})}}const WS={displayName:"viz.radar_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new GS,name:"radar",viewRender:zS,configRender:OS,createConfig:()=>({version:7,config:Js}),triggers:[Bp],translation:LS};function RS(e,t){const{plot:n,transform:s}=e.regression;return t.map(i=>({...n,id:`reg-for-${i.name}`,name:i.name,data:Ps(s,i.data),color:i.color,showSymbol:!1,smooth:!0,tooltip:{show:!1},custom:{type:"regression-line",targetSeries:i.name}}))}function $p(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 QS(e,t){const{plot:n,transform:s}=e.regression,i=$p(e,t);return[{type:"scatter",name:e.y_axis.name,data:i,symbolSize:4,color:"red",markLine:{...n,data:[Ps(s,i)],color:"blue",smooth:!0,silent:!0,symbol:["none","none"]}}]}function US(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=$p(e,u);return{type:"scatter",name:c,data:d,symbolSize:4,markLine:{...n,data:[Ps(s,d)],smooth:!0,silent:!0,symbol:["none","none"]}}})}function YS(e,t){if(t.length===0)return[];const{group_by_key:n}=e.regression;return n?US(e,t):QS(e,t)}function KS(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 XS(e){return te.getTooltip({trigger:"axis",formatter:t=>{const n=KS(t);return n.length===0?"":`
|
|
237
237
|
<table style="width: auto">
|
|
238
238
|
<thead>
|
|
239
239
|
<tr>
|
|
@@ -243,44 +243,44 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
243
243
|
</thead>
|
|
244
244
|
<tbody>
|
|
245
245
|
<tr>
|
|
246
|
-
<th style="text-align: left; padding: 0 .5em;">${
|
|
246
|
+
<th style="text-align: left; padding: 0 .5em;">${e.x_axis.name}</th>
|
|
247
247
|
${n.map(({x:i})=>`<td style="text-align: right; padding: 0 .5em;">${i}</td>`).join("")}
|
|
248
248
|
</tr>
|
|
249
249
|
<tr>
|
|
250
|
-
<th style="text-align: left; padding: 0 .5em;">${
|
|
250
|
+
<th style="text-align: left; padding: 0 .5em;">${e.y_axis.name}</th>
|
|
251
251
|
${n.map(({y:i})=>`<td style="text-align: right; padding: 0 .5em;">${i}</td>`).join("")}
|
|
252
252
|
</tr>
|
|
253
253
|
</tbody>
|
|
254
254
|
</table>
|
|
255
|
-
`}})}function fv(t){const{overflow:e,format:n,formatter:r,...i}=t.x_axis.axisLabel,a=Qe(e.on_axis);return te.getXAxis({type:"value",name:t.x_axis.name??"",nameLocation:"middle",nameGap:25,axisLabel:{...i,...a,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(a=>a.name)}};return b.defaultsDeep({},i,yv)}const Xo={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:a}=r,l=jt.regressionLinear()(n),{a:c,b:u,rSquared:d}=l;return{name:t,expression:s.jsxs(o.Group,{position:"center",noWrap:!0,spacing:10,children:[s.jsx(o.Text,{children:a.name}),s.jsx(o.Text,{children:"="}),s.jsx(o.Text,{weight:"bold",color:"red",children:U(u,Xo)}),s.jsx(o.Text,{children:"+"}),s.jsx(o.Text,{weight:"bold",color:"red",children:U(c,Xo)}),s.jsx(o.Text,{children:"×"}),s.jsx(o.Text,{children:i.name})]}),rSquared:d,adjustedRSquared:ns(d,e.length,1)}}function _v(t,e,n,r){const{x_axis:i,y_axis:a}=r,{a:l,b:c,rSquared:u}=jt.regressionExp()(n);return{name:t,expression:s.jsxs(o.Group,{position:"center",noWrap:!0,spacing:10,children:[s.jsx(o.Text,{children:a.name}),s.jsx(o.Text,{children:"="}),s.jsx(o.Text,{weight:"bold",color:"gray",children:l}),s.jsx(o.Text,{children:"×"}),s.jsxs(o.Group,{position:"left",noWrap:!0,spacing:2,children:[s.jsx(o.Text,{children:"Math.exp("}),s.jsx(o.Text,{weight:"bold",color:"gray",children:c}),s.jsx(o.Text,{children:"×"}),s.jsx(o.Text,{children:i.name}),s.jsx(o.Text,{children:")"})]})]}),rSquared:u,adjustedRSquared:ns(u,e.length,1)}}function jv(t,e,n,r){const{x_axis:i,y_axis:a}=r,{a:l,b:c,rSquared:u}=jt.regressionLog()(n);return{name:t,expression:s.jsxs(o.Group,{position:"center",noWrap:!0,spacing:10,children:[s.jsx(o.Text,{children:a.name}),s.jsx(o.Text,{children:"="}),s.jsx(o.Text,{weight:"bold",color:"gray",children:l}),s.jsx(o.Text,{children:"×"}),s.jsxs(o.Group,{position:"left",noWrap:!0,spacing:2,children:[s.jsx(o.Text,{children:"Math.log("}),s.jsx(o.Text,{children:i.name}),s.jsx(o.Text,{children:")"}),s.jsx(o.Text,{children:"+"}),s.jsx(o.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:a,regression:l}=r,c=jt.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 Zo(t,e,n){const{regression:r,x_axis:i}=n,a=E(i.data_key),l=E(r.y_axis_data_key),c=e.map(u=>[u[a.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[Zo("",t,e)];const n=E(e.regression.group_by_key),r=b.groupBy(t,n.columnKey);return Object.entries(r).map(([i,a])=>Zo(i,a,e))}const Sv={marginTop:"10px","tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function Ho({desc:t}){const{t:e}=_.useTranslation(),{expression:n,rSquared:r,adjustedRSquared:i}=t;return n?s.jsx(o.Table,{fontSize:14,sx:Sv,children:s.jsxs("tbody",{children:[s.jsx("tr",{children:s.jsx("td",{colSpan:2,children:s.jsx(o.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(o.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(o.Tabs,{defaultValue:(r=n[0])==null?void 0:r.name,color:"gray",children:[s.jsx(o.Tabs.List,{grow:!0,children:n.map(i=>s.jsx(o.Tabs.Tab,{value:i.name,children:i.name},i.name))}),n.map(i=>s.jsx(o.Tabs.Panel,{value:i.name,children:s.jsx(Ho,{desc:i})},i.name))]})):s.jsx(Ho,{desc:n[0]})}function Tv({conf:t,queryData:e}){const{t:n}=_.useTranslation();return s.jsxs(o.HoverCard,{shadow:"md",withinPortal:!0,zIndex:320,children:[s.jsx(o.HoverCard.Target,{children:s.jsx(o.Button,{size:"xs",variant:"subtle",compact:!0,leftIcon:s.jsx(k.IconInfoCircle,{size:14}),children:n("viz.regression_chart.regression_info")})}),s.jsx(o.HoverCard.Dropdown,{children:s.jsx(je,{children:s.jsx(kv,{conf:t,queryData:e})})})]})}function Dv(t){return s.jsx(o.Group,{position:"apart",sx:{position:"absolute",top:0,left:Ee.left,right:Ee.right,height:"22px",zIndex:1},children:s.jsx(Tv,{...t})})}const Sr={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 y;const u=t.data,d=e==null?void 0:e.x_axis.data_key,p=(y=e==null?void 0:e.regression)==null?void 0:y.y_axis_data_key;if(!d||!p)return[];const h=E(d),g=E(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]),a=m.useMemo(()=>bv(b.defaultsDeep({},e,Sr),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:a,style:dn(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"),a=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(o.Stack,{children:[s.jsx(o.Group,{grow:!0,noWrap:!0,children:s.jsx(f.Controller,{name:"regression.name",control:t,render:({field:c})=>s.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...c})})}),s.jsx(f.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(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"regression.transform.config.method",control:t,render:({field:c})=>s.jsx(o.Select,{label:n("chart.regression_line.method.label"),data:l,sx:{flex:1},...c})}),i==="polynomial"&&s.jsx(f.Controller,{name:"regression.transform.config.order",control:t,render:({field:c})=>s.jsx(o.NumberInput,{label:n("chart.regression_line.method.polynomial_order"),sx:{flex:1},...c})})]}),!a&&s.jsxs(o.Stack,{spacing:4,children:[s.jsx(o.Text,{size:"sm",children:n("chart.color.label")}),s.jsx(f.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(o.Stack,{children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"x_axis.name",control:t,render:({field:n})=>s.jsx(o.TextInput,{label:"X轴名称",sx:{flex:1},...n})}),s.jsx(f.Controller,{name:"x_axis.data_key",control:t,render:({field:n})=>s.jsx(O,{label:"X轴数据字段",required:!0,sx:{flex:1},...n})})]}),s.jsx(o.Divider,{variant:"dashed",labelPosition:"center",label:"格式化数据"}),s.jsx(o.Stack,{children:s.jsx(f.Controller,{name:"x_axis.axisLabel.format",control:t,render:({field:n})=>s.jsx(Re,{...n})})}),s.jsx(o.Divider,{variant:"dashed",labelPosition:"center",label:"标签文案样式"}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:n})=>s.jsx(o.NumberInput,{label:"旋转",hideControls:!0,min:-90,max:90,rightSection:s.jsx(o.Text,{color:"dimmed",children:"度"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...n})}),s.jsx(f.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:n})=>s.jsx(tt,{triggerButtonText:"自定义标签文案内容",...n})})]}),s.jsx(f.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(o.Stack,{children:s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"y_axis.name",control:t,render:({field:n})=>s.jsx(o.TextInput,{label:"Y轴名称",sx:{flex:1},...n})}),s.jsx(f.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,Sr),[e]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=f.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(o.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:a(n),children:[s.jsx(ge,{canSubmit:p}),s.jsxs(o.Tabs,{defaultValue:"X轴",orientation:"vertical",styles:{panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"X轴",children:"X轴"}),s.jsx(o.Tabs.Tab,{value:"Y轴",children:"Y轴"}),s.jsx(o.Tabs.Tab,{value:"回归",children:"回归"})]}),s.jsx(o.Tabs.Panel,{value:"X轴",children:s.jsx(Iv,{watch:l,control:i})}),s.jsx(o.Tabs.Panel,{value:"Y轴",children:s.jsx(Ev,{watch:l,control:i})}),s.jsx(o.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:a,...l}=t;return{...l,x_axis:{...i,data_key:r(i.data_key)},regression:{...a,group_by_key:r(a.group_by_key),y_axis_data_key:r(a.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(Sr)}},translation:Bv},ss={content:""};function Ov(t,e){const n={};return t.forEach(r=>{const{name:i,data_field:a,aggregation:l}=r,c=Mn(e,a,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",`
|
|
255
|
+
`}})}function JS(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 ZS={tooltip:{trigger:"axis"},grid:{top:50,left:5,right:10,bottom:20,containLabel:!0},dataZoom:[{type:"inside",xAxisIndex:[0]},{type:"inside",yAxisIndex:[0]}]};function HS(e,t){const n=YS(e,t),s=RS(e,n),i={xAxis:JS(e),yAxis:te.getYAxis({name:e.y_axis.name??"",nameLocation:"end",nameTextStyle:{align:"left"},nameGap:5}),series:[...n,...s],tooltip:XS(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,ZS)}const Fp={output:"number",mantissa:2,trimMantissa:!0,absolute:!1};function Zs(e,t,n){return 1-(1-e)*(t-1)/(t-n-1)}function ek(e,t,n,s){const{x_axis:i,y_axis:a}=s,l=rn.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,Fp)}),r.jsx(o.Text,{children:"+"}),r.jsx(o.Text,{weight:"bold",color:"red",children:U(c,Fp)}),r.jsx(o.Text,{children:"×"}),r.jsx(o.Text,{children:i.name})]}),rSquared:d,adjustedRSquared:Zs(d,t.length,1)}}function tk(e,t,n,s){const{x_axis:i,y_axis:a}=s,{a:l,b:c,rSquared:u}=rn.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:Zs(u,t.length,1)}}function nk(e,t,n,s){const{x_axis:i,y_axis:a}=s,{a:l,b:c,rSquared:u}=rn.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:Zs(u,t.length,1)}}function rk(e,t,n,s){const{x_axis:i,y_axis:a,regression:l}=s,c=rn.regressionPoly().order(l.transform.config.order)(n),{rSquared:u}=c;return console.log(c),{name:e,expression:"",rSquared:u,adjustedRSquared:Zs(u,t.length,1)}}function Gp(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"?ek(e,t,c,n):s.transform.config.method==="exponential"?tk(e,t,c,n):s.transform.config.method==="logistic"?nk(e,t,c,n):s.transform.config.method==="polynomial"?rk(e,t,c,n):{name:e,expression:"",rSquared:0,adjustedRSquared:0}}function sk(e,t){if(!t)return[{name:"",expression:"",rSquared:0,adjustedRSquared:0}];if(!t.regression.group_by_key)return[Gp("",e,t)];const n=O(t.regression.group_by_key),s=v.groupBy(e,n.columnKey);return Object.entries(s).map(([i,a])=>Gp(i,a,t))}const ik={marginTop:"10px","tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function Wp({desc:e}){const{t}=_.useTranslation(),{expression:n,rSquared:s,adjustedRSquared:i}=e;return n?r.jsx(o.Table,{fontSize:14,sx:ik,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 ak({conf:e,queryData:t}){var s;const n=g.useMemo(()=>sk(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(Wp,{desc:i})},i.name))]})):r.jsx(Wp,{desc:n[0]})}function ok({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(ak,{conf:e,queryData:t})})})]})}function lk(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(ok,{...e})})}const jo={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 ck({context:e}){const{value:t}=$(e.instanceData,"config"),{width:n,height:s}=e.viewport,i=g.useMemo(()=>{var x;const u=e.data,d=t==null?void 0:t.x_axis.data_key,p=(x=t==null?void 0:t.regression)==null?void 0:x.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=g.useMemo(()=>HS(v.defaultsDeep({},t,jo),i),[t,i]),l=g.useRef(null),c=u=>{l.current=u};return!n||!s||!t?null:r.jsxs(Ue,{width:n,height:s,children:[r.jsx(lk,{conf:t,queryData:i}),r.jsx(Pe,{echarts:Ae,onChartReady:c,option:a,style:mr(n,s),notMerge:!0,theme:"merico-light"})]})}function uk({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=g.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 dk({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(Ct,{triggerButtonText:"自定义标签文案内容",...n})})]}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:n})=>r.jsx(St,{...n})})]})}function pk({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 hk({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=g.useMemo(()=>v.defaults({},t,jo),[t]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});g.useEffect(()=>{u(s)},[s]),l(["x_axis","y_axis","regression"]);const d=c(),p=g.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(dk,{watch:l,control:i})}),r.jsx(o.Tabs.Panel,{value:"Y轴",children:r.jsx(pk,{watch:l,control:i})}),r.jsx(o.Tabs.Panel,{value:"回归",children:r.jsx(uk,{control:i,watch:l})})]})]})})}function fk(e){const t={x_axis:{axisLabel:{rotate:0,format:Me,overflow:Ke(),formatter:Oe()}},regression:{group_by_key:""}};return v.defaultsDeep(t,e)}function gk(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 mk=[{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 xk extends me{constructor(){super(...arguments);B(this,"VERSION",3)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:fk(n.config)})),this.version(3,(n,s)=>{const{config:i}=n;return{...n,version:3,config:gk(i,s)}})}}const yk={displayName:"viz.regression_chart.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new xk,name:"regressionChart",viewRender:ck,configRender:hk,createConfig(){return{version:3,config:v.cloneDeep(jo)}},translation:mk},Hs={content:""};function bk(e,t){const n={};return e.forEach(s=>{const{name:i,data_field:a,aggregation:l}=s,c=ss(t,a,l);n[i]=Re(s,c)}),n}function vk(e){const t=document.createElement("span");return t.innerHTML=e,t.innerText}function _k(e,t,n){try{return new Function("payload",`
|
|
256
256
|
const filters = payload.filters;
|
|
257
257
|
const context = payload.context;
|
|
258
|
-
${Object.entries(
|
|
258
|
+
${Object.entries(t).map(([s,i])=>`const ${s} = '${i}';`).join(`
|
|
259
259
|
`)}
|
|
260
|
-
return ${
|
|
261
|
-
`)(n)}catch(
|
|
262
|
-
`)}},
|
|
260
|
+
return ${e};
|
|
261
|
+
`)(n)}catch(s){return console.error(s),console.log(e),e}}function jk(e,t,n,s){const i=bk(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=vk(c[1]);return`${_k(d,i,n)}${c[2]}`}).join("")}const wk=D.observer(({context:e})=>{const t=_e(),{value:n}=$(e.instanceData,"config"),{variables:s,data:i}=e,a=g.useMemo(()=>{const l=v.defaults({},n,Hs);return l.content?jk(l.content,s,t.payloadForViz,i):""},[n,s,t.payloadForViz]);return a?r.jsx(Us,{value:a,styles:{root:{border:"none",height:"100%"},content:{padding:0}}}):null});function Ck(){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 wo=g.forwardRef(({value:e,onChange:t,styles:n={},label:s,onSubmit:i},a)=>{const[l,c]=g.useState(e),u=nc.useEditor({extensions:[rc,tc,Q.Link,Yl,Ul,Rl,Jl.configure({resizable:!1,HTMLAttributes:{class:"rich-text-table-render"}}),ec,Hl,Zl,Kl.configure({types:["heading","paragraph"]}),Ql.configure({placeholder:"This is placeholder"}),Xl,Wl.Color,_p],content:l,onUpdate:({editor:f})=>{c(f.getHTML())}});g.useEffect(()=>{c(e),u==null||u.commands.setContent(e)},[e]);const d=()=>{t(l),i==null||i()},p=e!==l,h=g.useMemo(()=>v.defaultsDeep({},{content:Za},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.jsx(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.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(Ck,{})}),r.jsx(zw,{editor:u})]}),r.jsx(Q.RichTextEditor.Content,{})]})]}):null});function Sk({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>v.defaults({},n,Hs),[n]),{control:a,handleSubmit:l,watch:c,reset:u}=b.useForm({defaultValues:i});c("content"),g.useEffect(()=>{u(i)},[i]);const d=g.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(wo,{...h,styles:{root:{flexGrow:1}},label:t("viz.rich_text.content.label"),onSubmit:p})})]})})}const kk=[{lang:"en",resources:{rich_text:{viz_name:"Rich Text",content:{label:"Content"}}}},{lang:"zh",resources:{rich_text:{viz_name:"富文本",content:{label:"内容"}}}}];class Tk extends me{constructor(){super(...arguments);B(this,"VERSION",1)}fixMalformedConfig(n){return v.defaults({},n,Hs)}configVersions(){this.version(1,n=>({version:1,config:this.fixMalformedConfig(n)}))}}const Dk={displayName:"viz.rich_text.viz_name",displayGroup:"chart.groups.others",migrator:new Tk,name:"richText",viewRender:wk,configRender:Sk,createConfig(){return{version:1,config:v.cloneDeep(Hs)}},translation:kk},Gr={static:{type:"static",color:Gt.random().css()},dynamic:{type:"dynamic",func_content:["function getColor({ rowData, params, variables }, { lodash, interpolate }) {"," // your code goes here",' // return "blue"',"}"].join(`
|
|
262
|
+
`)}},Rp={id:"builtin:echarts:click-scatter-chart:series",displayName:"viz.scatter_chart.click_scatter.trigger",nameRender:zk,configRender:Mk,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 Mk(e){return r.jsx(r.Fragment,{})}function zk(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.scatter_chart.click_scatter.trigger")})}function Qp(){const{on_axis:e,in_tooltip:t}=Ke();return{label:e,tooltip:t}}const Co={scatter:{y_data_key:"",name_data_key:"",symbolSize:{type:"static",size:10},color:Gr.static,label_position:"right",label_overflow:Qp()},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:_n};function Ik(e,t){if(!e.x_axis.data_key)return[];const n=O(e.x_axis.data_key);return[{source:t[n.queryID]}]}function Ek(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 Ak(){return{show:!1,bottom:0,left:"center",type:"scroll"}}function ei(e,t){if(e)return t[e]??void 0}function Pk({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:ei(s.leftBottomPoint.x_data_key,t),yAxis:ei(s.leftBottomPoint.y_data_key,t)},{xAxis:ei(s.rightTopPoint.x_data_key,t),yAxis:ei(s.rightTopPoint.y_data_key,t)}]);return{type:"scatter",name:"ref_areas",silent:!0,data:[],markArea:{data:n}}}function Ok({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:bn.interpolate})}catch(c){return console.error(`[getEchartsSymbolSize] failed parsing custom function, error: ${c.message}`),10}}}function Lk({type:e,...t},n){if(!e)return Gr.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:bn.interpolate})}catch(a){return console.error(`[getSeriesColor] failed parsing custom function, error: ${a.message}`),10}}}function Bk(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?gr(i.template,t,s):""},position:c}}}})}function qk({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:Lk(t.color,n)},symbolSize:Ok(t.symbolSize,n),encode:{x:s.columnKey,y:i.columnKey}}}function Vk(e,t,n,s){return[qk(e,s)].concat(Bk(e.reference_lines,n,s,t)).concat(Pk({reference_areas:e.reference_areas,variableValueMap:s}))}function Up(e,t,n){const{x_axis:s}=n;return s.axisLabel.formatter.enabled?Ye(s.axisLabel.formatter)(e,t):e}function Nk(e,t){const{x_axis:n,tooltip:s}=t;if(s.trigger==="item"){const c=rs(e[0].data,n.data_key);return Up(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 Up(a,l,t)}const $k=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Fk(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=Nk(l,e),u=ct(e.scatter.label_overflow.tooltip),d=l.map(({value:y})=>`
|
|
263
263
|
<th style="text-align: right; padding-right: 1em">
|
|
264
|
-
<div style="${u}">${
|
|
264
|
+
<div style="${u}">${rs(y,n.name_data_key)}</div>
|
|
265
265
|
</th>
|
|
266
|
-
`);d.unshift("<th></th>");const p=
|
|
267
|
-
<th style="text-align: right;">${
|
|
268
|
-
${l.map(
|
|
266
|
+
`);d.unshift("<th></th>");const p=ct(e.x_axis.axisLabel.overflow.in_tooltip),h=[`<tr>
|
|
267
|
+
<th style="text-align: right;">${e.x_axis.name}</th>
|
|
268
|
+
${l.map(y=>`<td style="text-align: right; padding: 0 1em;"><div style="${p}">${c}</div></td>`).join("")}
|
|
269
269
|
</tr>`,`<tr>
|
|
270
|
-
<th style="text-align: right;">${
|
|
271
|
-
${l.map(({value:
|
|
270
|
+
<th style="text-align: right;">${e.y_axes[0].name}</th>
|
|
271
|
+
${l.map(({value:y})=>`
|
|
272
272
|
<td style="text-align: right; padding: 0 1em;">
|
|
273
|
-
${a(
|
|
273
|
+
${a(rs(y,n.y_data_key))}
|
|
274
274
|
</td>`).join("")}
|
|
275
|
-
</tr>`],
|
|
276
|
-
<th style="text-align: right;">${
|
|
277
|
-
${l.map(({value:
|
|
278
|
-
</tr>`);return h.push(...
|
|
275
|
+
</tr>`],f=e.tooltip.metrics.map(y=>`<tr>
|
|
276
|
+
<th style="text-align: right;">${y.name}</th>
|
|
277
|
+
${l.map(({value:j})=>`<td style="text-align: right; padding: 0 1em;">${$k(rs(j,y.data_key))}</td>`).join("")}
|
|
278
|
+
</tr>`);return h.push(...f),`
|
|
279
279
|
<table style="width: auto">
|
|
280
280
|
<thead><tr>${d.join("")}</tr></thead>
|
|
281
281
|
<tbody>${h.join("")}</tbody>
|
|
282
282
|
</table>
|
|
283
|
-
`}})}function c_(t,e){const n=e.every(c=>!Number.isNaN(Number(c))),{overflow:r,...i}=t.x_axis.axisLabel,a=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,...a,formatter:Pe(i.formatter)}})]}function u_(t,e){return t.y_axes.map(({nameAlignment:n,min:r,max:i,...a},l)=>{let c=a.position;return c||(c=l>0?"right":"left"),te.getYAxis({...a,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 y=g;if(typeof g=="object"&&(Array.isArray(g.value)&&g.value.length===2?y=g.value[1]:y=g.value),!d)return y;try{return U(y,d)}catch(v){return console.error(v),y}},u),{default:({value:u})=>u}),a=b.uniq(Xe(e,t.x_axis.data_key)),l=i_(t,e,n,r),c={xAxis:c_(t,a),yAxis:u_(t,i),series:l,dataset:Xv(t,e),tooltip:l_(t,i),grid:Zv(t),legend:Hv(),dataZoom:Bn(t.dataZoom)};return b.defaultsDeep({},c,d_)}function sl(t){return t.trim().length>0}function h_({conf:t,data:e,width:n,height:r,interactionManager:i,variables:a}){const l=Mt(e,t.x_axis.data_key),c=qe(i.triggerManager,el.id),u=m.useCallback(h=>{const g=h.data;c.forEach(y=>{i.runInteraction(y.id,{...h,rowData:g})})},[l,c,i]),d=m.useMemo(()=>({click:u}),[u]),p=m.useMemo(()=>p_(t,e,a),[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,a=m.useMemo(()=>b.defaults({},r,Tr),[r]),l=t.data,{width:c,height:u}=t.viewport,{ref:d,height:p}=ie.useElementSize(),{ref:h,height:g}=ie.useElementSize(),y=m.useMemo(()=>{const{stats:{templates:w}}=a;return{top:cn(w.top,i,l),bottom:cn(w.bottom,i,l)}},[a,l]),v=Math.max(0,et(u)-p-g);return!c||!u?null:s.jsxs(Ae,{width:c,height:u,children:[s.jsx(o.Text,{ref:d,align:"left",size:"xs",pl:"sm",sx:{display:sl(a.stats.templates.top)?"block":"none"},children:Object.values(y.top).map(w=>w)}),s.jsx(h_,{variables:i,width:He(c),height:v,data:l,conf:a,interactionManager:n}),s.jsx(o.Text,{ref:h,align:"left",size:"xs",pl:"sm",sx:{display:sl(a.stats.templates.bottom)?"block":"none"},children:Object.values(y.bottom).map(w=>w)})]})}const x_=m.forwardRef(({value:t,onChange:e,xAxisOptions:n,yAxisOptions:r,variableOptions:i},a)=>{const{t:l,i18n:c}=_.useTranslation(),u=(d,p)=>{const h=b.cloneDeep(t);b.set(h,d,p),e(h)};return s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{mb:-15,variant:"dashed",label:l("chart.reference_area.content.label"),labelPosition:"right"}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(o.TextInput,{label:l("chart.reference_area.content.content_text"),value:t.content.text,onChange:d=>u("content.text",d.currentTarget.value)}),s.jsx(Yt,{label:l("chart.reference_area.content.text_position"),value:t.label.position,onChange:d=>u("label.position",d)})]}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:l("chart.reference_area.endpoint.labels"),labelPosition:"right"}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[n&&s.jsx(o.Select,{label:l("chart.x_axis.label"),data:n,value:t.xAxisIndex,onChange:d=>u("xAxisIndex",d)}),r&&s.jsx(o.Select,{label:l("chart.y_axis.label"),data:r,value:t.yAxisIndex,onChange:d=>u("xAxisIndex",d)})]}),s.jsxs(o.Stack,{spacing:0,children:[s.jsx(o.Text,{size:14,color:"#212529",fw:500,children:l("chart.reference_area.endpoint.left_bottom_point")}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(o.Select,{icon:s.jsx(o.Text,{children:"x"}),data:i,value:t.leftBottomPoint.x_data_key,onChange:d=>u("leftBottomPoint.x_data_key",d??""),clearable:!0}),s.jsx(o.Select,{icon:s.jsx(o.Text,{children:"y"}),data:i,value:t.leftBottomPoint.y_data_key,onChange:d=>u("leftBottomPoint.y_data_key",d??""),clearable:!0})]})]}),s.jsxs(o.Stack,{spacing:0,children:[s.jsx(o.Text,{size:14,color:"#212529",fw:500,children:l("chart.reference_area.endpoint.right_top_point")}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(o.Select,{icon:s.jsx(o.Text,{children:"x"}),data:i,value:t.rightTopPoint.x_data_key,onChange:d=>u("rightTopPoint.x_data_key",d??""),clearable:!0}),s.jsx(o.Select,{icon:s.jsx(o.Text,{children:"y"}),data:i,value:t.rightTopPoint.y_data_key,onChange:d=>u("rightTopPoint.y_data_key",d??""),clearable:!0})]})]}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:l("chart.style.label"),labelPosition:"right"}),s.jsxs(o.Stack,{spacing:4,children:[s.jsx(o.Text,{size:14,children:l("chart.color.background_color")}),s.jsx(Te,{value:t.itemStyle.color,onChange:d=>u("itemStyle.color",d)})]}),s.jsxs(o.Stack,{spacing:4,children:[s.jsx(o.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_(),a=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(f.Controller,{name:`reference_areas.${p}`,control:t,render:({field:h})=>s.jsx(o.Stack,{children:s.jsx(x_,{variableOptions:a,yAxisOptions:c,...h})})})})}function y_({control:t,index:e,watch:n,variableOptions:r,yAxisOptions:i}){const{t:a}=_.useTranslation(),l=n(`reference_lines.${e}.orientation`);return s.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`reference_lines.${e}.name`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:a("common.name"),placeholder:a("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),s.jsx(f.Controller,{name:`reference_lines.${e}.variable_key`,control:t,render:({field:c})=>s.jsx(o.Select,{label:a("common.data_field"),required:!0,data:r,sx:{flex:1},...c})})]}),s.jsx(f.Controller,{name:`reference_lines.${e}.template`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:a("chart.content_template.label"),placeholder:a("chart.content_template.hint"),sx:{flex:1},...c})}),s.jsxs(o.Group,{grow:!0,children:[s.jsxs(o.Stack,{children:[s.jsx(f.Controller,{name:`reference_lines.${e}.orientation`,control:t,render:({field:c})=>s.jsx(wt,{sx:{flex:1},...c})}),l==="vertical"&&s.jsx(o.Text,{mt:-10,color:"dimmed",size:12,children:a("chart.reference_line.orientation.vertical_hint")})]}),l==="horizontal"&&s.jsx(f.Controller,{name:`reference_lines.${e}.yAxisIndex`,control:t,render:({field:{value:c,onChange:u,...d}})=>s.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}})})]}),s.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.style.label"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:`reference_lines.${e}.lineStyle.type`,control:t,render:({field:c})=>s.jsx(Wt,{sx:{flexGrow:1},...c})}),s.jsx(f.Controller,{name:`reference_lines.${e}.lineStyle.width`,control:t,render:({field:c})=>s.jsx(o.NumberInput,{label:a("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),s.jsxs(o.Stack,{spacing:4,children:[s.jsx(o.Text,{size:"sm",children:a("chart.color.label")}),s.jsx(f.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}),a=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:a,yAxisOptions:c})})}const v_=({value:t,onChange:e})=>{const n=r=>{r&&e(r)};return s.jsx(o.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:a}]=G.useBoolean(),[l,c]=m.useState(t),u=()=>{a();const{type:g,func_content:y}=l,v={type:g,func_content:y};c(v),e(v)},d=()=>{a(),c(t)},p=g=>{c(y=>({...y,func_content:g}))},h=()=>{p(yn.dynamic.func_content)};return s.jsxs(s.Fragment,{children:[s.jsx(o.Box,{sx:{width:"50%"},children:s.jsx(o.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(o.Modal,{size:800,title:n("viz.scatter_chart.color.dynamic.setup_title"),opened:r,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&s.jsxs(o.Stack,{children:[s.jsx(v_,{value:l.func_content,onChange:p}),s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Button,{onClick:h,color:"red",leftIcon:s.jsx(L.Recycle,{size:20}),children:n("common.actions.reset_to_default")}),s.jsxs(o.Group,{position:"right",children:[s.jsx(o.Button,{onClick:d,variant:"subtle",children:n("common.actions.cancel")}),s.jsx(o.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(o.ColorInput,{label:" ",format:"rgb",value:t.color,onChange:n})},C_=m.forwardRef(({label:t="Color",value:e,onChange:n},r)=>{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({...yn[u]})};return s.jsxs(o.SimpleGrid,{cols:2,children:[s.jsx(o.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})},a=l=>{e({...t,tooltip:l})};return s.jsxs(o.Stack,{ref:n,spacing:0,children:[s.jsx(Pn,{sectionTitle:r("chart.axis.overflow.section_title.on_axis"),value:t.label,onChange:i}),s.jsx(Pn,{sectionTitle:r("chart.axis.overflow.section_title.in_tooltip"),value:t.tooltip,onChange:a})]})});function k_({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["scatter"]),s.jsxs(o.Stack,{children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.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(f.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(o.Divider,{mb:-15,label:n("chart.style.label"),labelPosition:"center"}),s.jsx(f.Controller,{name:"scatter.symbolSize",control:t,render:({field:r})=>s.jsx(nr,{...r})}),s.jsx(f.Controller,{name:"scatter.color",control:t,render:({field:r})=>s.jsx(C_,{...r})}),s.jsx(o.Divider,{mb:-15,label:n("chart.label.label"),labelPosition:"center"}),s.jsx(o.Group,{grow:!0,noWrap:!0,children:s.jsx(f.Controller,{name:"scatter.label_position",control:t,render:({field:r})=>s.jsx(Yt,{label:n("chart.label_position.label"),withOffOption:!0,...r,onChange:i=>{i&&r.onChange(i)}})})}),s.jsx(f.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(o.Stack,{children:s.jsxs(o.Stack,{spacing:0,children:[s.jsx(f.Controller,{name:"stats.templates.top",control:t,render:({field:r})=>s.jsx(ln,{label:n("chart.stats.template.above_chart"),py:"md",sx:{flexGrow:1},...r})}),s.jsx(f.Controller,{name:"stats.templates.bottom",control:t,render:({field:r})=>s.jsx(ln,{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(o.Stack,{children:s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`tooltip.metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(f.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=(a,l)=>{const c=a.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(o.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:a,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(o.Stack,{children:[s.jsx(f.Controller,{name:"tooltip.trigger",control:t,render:({field:a})=>s.jsx(o.Select,{label:n("chart.tooltip.trigger.label"),data:i,sx:{flexGrow:1},...a})}),s.jsx(o.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(o.Stack,{children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.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(f.Controller,{name:"x_axis.name",control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...r})})]}),s.jsx(o.Divider,{mb:-15,label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:r})=>s.jsx(xt,{sx:{width:"48%"},...r})}),s.jsx(f.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:r})=>s.jsx(tt,{...r})})]}),s.jsx(f.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(o.Stack,{my:0,p:"0",sx:{position:"relative"},children:[s.jsx(o.Divider,{mb:-15,mt:15,variant:"dashed",label:n("chart.y_axis.y_axis_name"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`y_axes.${e}.name`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(f.Controller,{name:`y_axes.${e}.nameAlignment`,control:t,render:({field:r})=>s.jsx(kt,{sx:{flex:1},...r})})]}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.layout"),labelPosition:"center"}),s.jsx(o.Group,{grow:!0,noWrap:!0,children:s.jsx(f.Controller,{name:`y_axes.${e}.position`,control:t,render:({field:r})=>s.jsx(Po,{sx:{flex:1},...r})})}),s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.label_format"),labelPosition:"center"}),s.jsx(f.Controller,{name:`y_axes.${e}.label_formatter`,control:t,render:({field:r})=>s.jsx(Re,{...r})})]}),s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.y_axis.value_range"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:`y_axes.${e}.min`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("chart.y_axis.value_min"),...r})}),s.jsx(f.Controller,{name:`y_axes.${e}.max`,control:t,render:({field:r})=>s.jsx(o.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},a=({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:a,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,a=m.useMemo(()=>b.defaultsDeep({},n,Tr),[n]),l=m.useMemo(()=>$_(a),[a]);m.useEffect(()=>{!b.isEqual(a,l)&&(console.log("config malformed, resetting to defaults",a,l),r(l))},[a,l]);const{control:c,handleSubmit:u,watch:d,getValues:p,reset:h}=f.useForm({defaultValues:l});m.useEffect(()=>{h(l)},[l]);const g=p(),y=m.useMemo(()=>!b.isEqual(g,a),[g,a]);return d(["dataZoom"]),s.jsx(o.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:u(r),children:[s.jsx(ge,{canSubmit:y}),s.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"X Axis",children:e("chart.x_axis.label")}),s.jsx(o.Tabs.Tab,{value:"Y Axes",children:e("chart.y_axis.labels")}),s.jsx(o.Tabs.Tab,{value:"Scatter",children:e("chart.series.scatter.label")}),s.jsx(o.Tabs.Tab,{value:"Tooltip",children:e("chart.tooltip.label")}),s.jsx(o.Tabs.Tab,{value:"Stats",children:e("chart.stats.label")}),s.jsx(o.Tabs.Tab,{value:"Reference Lines",children:e("chart.reference_line.labels")}),s.jsx(o.Tabs.Tab,{value:"Reference Areas",children:e("chart.reference_area.labels")}),s.jsx(o.Tabs.Tab,{value:"Zooming",children:e("chart.zooming.label")})]}),s.jsx(o.Tabs.Panel,{value:"X Axis",children:s.jsx(I_,{control:c,watch:d})}),s.jsx(o.Tabs.Panel,{value:"Y Axes",children:s.jsx(A_,{control:c,watch:d})}),s.jsx(o.Tabs.Panel,{value:"Scatter",children:s.jsx(k_,{control:c,watch:d})}),s.jsx(o.Tabs.Panel,{value:"Tooltip",children:s.jsx(M_,{control:c,watch:d})}),s.jsx(o.Tabs.Panel,{value:"Stats",children:s.jsx(T_,{control:c,watch:d})}),s.jsx(o.Tabs.Panel,{value:"Reference Lines",children:s.jsx(b_,{variables:i,control:c,watch:d})}),s.jsx(o.Tabs.Panel,{value:"Reference Areas",children:s.jsx(f_,{variables:i,control:c,watch:d})}),s.jsx(o.Tabs.Panel,{value:"Zooming",children:s.jsx(f.Controller,{name:"dataZoom",control:c,render:({field:v})=>s.jsx(qn,{...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=zt,...n}=t;return{...n,dataZoom:e}}function O_(t){const e={scatter:{label_overflow:tl()}};return b.defaultsDeep(e,t)}function V_(t){const{color:e}=t.scatter;return typeof e=="string"?{...t,scatter:{...t.scatter,color:{...yn.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:a=0}=n;return{...n,lineStyle:r,show_in_legend:i,yAxisIndex:a}});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:a,tooltip:l,...c}=t;return{...c,x_axis:{...i,data_key:r(i.data_key)},scatter:{...a,y_data_key:r(a.y_data_key),name_data_key:r(a.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(Tr)}},triggers:[el],translation:L_},Dr={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:a="",data_field:l="value",formatter:c={output:"number",mantissa:0},postfix:u=""}={}}=t;return{align:e,template:`${a} \${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 rl={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(o.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,rl.id),i=he(),{value:a=Dr}=q(t.instanceData,"config"),{data:l,variables:c}=t,{template:u,horizontal_align:d,vertical_align:p}=a,{width:h,height:g}=t.viewport,y=m.useMemo(()=>{try{return b.template(u)(i.payloadForSQL)}catch{return u}},[i.payloadForSQL,u]),v=m.useMemo(()=>cn(y,c,t.data),[y,c,t.data,t]),w=m.useMemo(()=>c.reduce((I,A)=>{const N=Ze(A,l);return I[A.name]=Ie(A,N),I},{}),[l,c]),T=m.useCallback(()=>{r.forEach(I=>{n.runInteraction(I.id,{variables:w})})},[w,r,n]),D=r.length>0?{cursor:"pointer","&:hover":{textDecoration:"underline"}}:{};return s.jsx(o.Center,{sx:{width:h,height:g,justifyContent:ej[d],alignItems:tj[p]},children:s.jsx(o.Box,{sx:D,onClick:T,children:Object.values(v).map((I,A)=>s.jsx(m.Fragment,{children:I},A))})})});function sj({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),i=m.useMemo(()=>b.defaultsDeep({},n,Dr),[n]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d}=f.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(o.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:l(r),children:[s.jsx(ge,{canSubmit:h}),s.jsx(f.Controller,{name:"template",control:a,render:({field:g})=>s.jsx(ln,{label:e("chart.content_template.label"),placeholder:e("chart.content_template.hint"),py:"md",sx:{flexGrow:1},...g})}),s.jsxs(o.SimpleGrid,{cols:2,children:[s.jsx(f.Controller,{name:"horizontal_align",control:a,render:({field:g})=>s.jsx(Ln,{...g})}),s.jsx(f.Controller,{control:a,name:"vertical_align",render:({field:g})=>s.jsx(Qa,{...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:Dr}},displayName:"viz.stats.viz_name",displayGroup:"chart.groups.others",migrator:new X_,name:"stats",viewRender:nj,configRender:sj,triggers:[rl],translation:rj},zr={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 a=E(n),l=E(r),c=E(i),u=e[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?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,...a})=>{const l=t.slice(0,t.length-1),c=[`<tr>
|
|
283
|
+
`}})}function Gk(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 Wk(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 Rk={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 Qk(e,t,n){const s=n.reduce((u,d)=>{const p=_t(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 x=f;if(typeof f=="object"&&(Array.isArray(f.value)&&f.value.length===2?x=f.value[1]:x=f.value),!d)return x;try{return U(x,d)}catch(y){return console.error(y),x}},u),{default:({value:u})=>u}),a=v.uniq(vt(t,e.x_axis.data_key)),l=Vk(e,t,n,s),c={xAxis:Gk(e,a),yAxis:Wk(e,i),series:l,dataset:Ik(e,t),tooltip:Fk(e,i),grid:Ek(e),legend:Ak(),dataZoom:us(e.dataZoom)};return v.defaultsDeep({},c,Rk)}function Yp(e){return e.trim().length>0}function Uk({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=jn(t,e.x_axis.data_key),c=nt(i.triggerManager,Rp.id),u=g.useCallback(h=>{const f=h.data;c.forEach(x=>{i.runInteraction(x.id,{...h,rowData:f})})},[l,c,i]),d=g.useMemo(()=>({click:u}),[u]),p=g.useMemo(()=>Qk(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 Yk({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,Co),[s]),l=e.data,{width:c,height:u}=e.viewport,{ref:d,height:p}=he.useElementSize(),{ref:h,height:f}=he.useElementSize(),x=g.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,wt(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:Yp(a.stats.templates.top)?"block":"none"},children:Object.values(x.top).map(j=>j)}),r.jsx(Uk,{variables:i,width:jt(c),height:y,data:l,conf:a,interactionManager:n}),r.jsx(o.Text,{ref:h,align:"left",size:"xs",pl:"sm",sx:{display:Yp(a.stats.templates.bottom)?"block":"none"},children:Object.values(x.bottom).map(j=>j)})]})}const Kk=g.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 Xk(){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 Jk({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>Xk(),a=g.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=t("y_axes"),c=g.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(Kk,{variableOptions:a,yAxisOptions:c,...h})})})})}function Zk({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(fn,{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(Jn,{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 Hk({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>({name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:Gt.random().css()},show_in_legend:!1,yAxisIndex:0}),a=g.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=t("y_axes"),c=g.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(Zk,{control:e,index:p,watch:t,variableOptions:a,yAxisOptions:c})})}const eT=({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}}})})},tT=({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),[s,{setTrue:i,setFalse:a}]=W.useBoolean(),[l,c]=g.useState(e),u=()=>{a();const{type:f,func_content:x}=l,y={type:f,func_content:x};c(y),t(y)},d=()=>{a(),c(e)},p=f=>{c(x=>({...x,func_content:f}))},h=()=>{p(Gr.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(eT,{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")})]})]})]})})]})},nT=({value:e,onChange:t})=>e.type!=="dynamic"?null:r.jsx(tT,{value:e,onChange:t}),rT=({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})},sT=g.forwardRef(({label:e="Color",value:t,onChange:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=g.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({...Gr[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(rT,{value:t,onChange:n}),r.jsx(nT,{value:t,onChange:n})]})}),iT=g.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(ls,{sectionTitle:s("chart.axis.overflow.section_title.on_axis"),value:e.label,onChange:i}),r.jsx(ls,{sectionTitle:s("chart.axis.overflow.section_title.in_tooltip"),value:e.tooltip,onChange:a})]})});function aT({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(Ja,{...s})}),r.jsx(b.Controller,{name:"scatter.color",control:e,render:({field:s})=>r.jsx(sT,{...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(iT,{...s})})]})}function oT({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 lT=({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})})]})})},cT=({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(lT,{control:e,index:l})})]})};function uT({control:e,watch:t}){const{t:n,i18n:s}=_.useTranslation();t("tooltip.trigger");const i=g.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(cT,{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(Kt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(Ct,{...s})})]}),r.jsx(b.Controller,{name:"x_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(St,{...s})})]})}function pT({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(xn,{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(Cp,{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 hT({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(pT,{control:e,index:c})})}function fT(e){return e||{templates:{top:"",bottom:""}}}function gT({reference_lines:e=[],stats:t,...n}){return{reference_lines:e,stats:fT(t),...n}}function mT({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaultsDeep({},n,Co),[n]),l=g.useMemo(()=>gT(a),[a]);g.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});g.useEffect(()=>{h(l)},[l]);const f=p(),x=g.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:x}),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(hT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Scatter",children:r.jsx(aT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(uT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Stats",children:r.jsx(oT,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx(Hk,{variables:i,control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Reference Areas",children:r.jsx(Jk,{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(As,{...y})})})]})]})})}const xT=[{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 yT(e){const{dataZoom:t=_n,...n}=e;return{...n,dataZoom:t}}function bT(e){const t={scatter:{label_overflow:Qp()}};return v.defaultsDeep(t,e)}function vT(e){const{color:t}=e.scatter;return typeof t=="string"?{...e,scatter:{...e.scatter,color:{...Gr.static,color:t}}}:e}function _T(e){const t=e.reference_lines.map(n=>{const{lineStyle:s={type:"dashed",width:1,color:Gt.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 jT(e){const t={tooltip:{trigger:"item"}};return v.defaultsDeep({},e,t)}function wT(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 CT(e){const t={x_axis:{axisLabel:{overflow:Ke()}}};return v.defaultsDeep(t,e)}class ST extends me{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:yT(n.config)})),this.version(4,n=>{const{config:s}=n;return{...n,version:5,config:bT(s)}}),this.version(6,n=>{const{config:s}=n;return{...n,version:6,config:vT(s)}}),this.version(7,n=>{const{config:s}=n;return{...n,version:7,config:_T(s)}}),this.version(8,n=>{const{config:s}=n;return{...n,version:8,config:jT(s)}}),this.version(9,(n,s)=>{const{config:i}=n;return{...n,version:9,config:wT(i,s)}}),this.version(10,(n,s)=>{const{config:i}=n;return{...n,version:10,config:CT(i)}})}}const kT={displayName:"viz.scatter_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new ST,name:"scatterChart",viewRender:Yk,configRender:mT,createConfig(){return{version:10,config:v.cloneDeep(Co)}},triggers:[Rp],translation:xT},So={template:"The variable ${value} is defined in Variables section",vertical_align:"center",horizontal_align:"left"};function TT(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 DT(e){return v.omit(e,["variables"])}function MT(e){const{align:t,...n}=e;return{horizontal_align:t,vertical_align:"center",...n}}function zT(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 IT extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:TT(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(zT(l))}),{...n,version:2,config:DT(i)}}),this.version(3,n=>{const{config:s}=n;return{...n,version:3,config:MT(s)}})}}const Kp={id:"builtin:stats:click-stats",displayName:"viz.stats.click_stats.trigger",nameRender:AT,configRender:ET,payload:[{name:"variables",description:"Panel variables",valueType:"object"}]};function ET(e){return r.jsx(r.Fragment,{})}function AT(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.stats.click_stats.trigger")})}const PT={left:"flex-start",center:"center",right:"flex-end"},OT={top:"flex-start",center:"center",bottom:"flex-end"},LT=D.observer(({context:e,instance:t})=>{const n=rt({vizManager:e.vizManager,instance:t}),s=nt(n.triggerManager,Kp.id),i=_e(),{value:a=So}=$(e.instanceData,"config"),{data:l,variables:c}=e,{template:u,horizontal_align:d,vertical_align:p}=a,{width:h,height:f}=e.viewport,x=g.useMemo(()=>{try{return v.template(u)(i.payloadForSQL)}catch{return u}},[i.payloadForSQL,u]),y=g.useMemo(()=>fr(x,c,e.data),[x,c,e.data,e]),j=g.useMemo(()=>c.reduce((T,z)=>{const I=_t(z,l);return T[z.name]=Re(z,I),T},{}),[l,c]),k=g.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:PT[d],alignItems:OT[p]},children:r.jsx(o.Box,{sx:S,onClick:k,children:Object.values(y).map((T,z)=>r.jsx(g.Fragment,{children:T},z))})})});function BT({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>v.defaultsDeep({},n,So),[n]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d}=b.useForm({defaultValues:i});g.useEffect(()=>{d(i)},[i]),c(["template","horizontal_align","vertical_align"]);const p=u(),h=g.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(ds,{...f})}),r.jsx(b.Controller,{control:a,name:"vertical_align",render:({field:f})=>r.jsx($c,{...f})})]})]})})}const qT=[{lang:"en",resources:{stats:{viz_name:"Stats",click_stats:{trigger:"Click stats text"}}}},{lang:"zh",resources:{stats:{viz_name:"数据指标",click_stats:{trigger:"点击文字"}}}}],VT={createConfig(){return{version:3,config:So}},displayName:"viz.stats.viz_name",displayGroup:"chart.groups.others",migrator:new IT,name:"stats",viewRender:LT,configRender:BT,triggers:[Kp],translation:qT},ko={label_key:"",value_key:"",group_key:"",levels:[]};function NT(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 $T(e){const t=NT(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 FT(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?$T(u):u}const GT=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 WT(e){const{levels:t}=e;return t.map(n=>{const{show_label_tolerance:s,...i}=n.label;return{...n,label:{...i,formatter:GT(s)}}})}function RT(){return({treePathInfo:e,name:t,value:n,color:s,marker:i,...a})=>{const l=e.slice(0,e.length-1),c=[`<tr>
|
|
284
284
|
<th style="text-align: right; padding: 0 1em;">Value</th>
|
|
285
285
|
<td style="text-align: left; padding: 0 1em;">${n}</td>
|
|
286
286
|
</tr>
|
|
@@ -293,14 +293,14 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
293
293
|
</tr>
|
|
294
294
|
`)}),`
|
|
295
295
|
<div style="text-align: left; margin-bottom: .5em; padding: 0 1em .5em; font-weight: bold; border-bottom: 1px dashed #ddd;">
|
|
296
|
-
<div>${i} ${
|
|
296
|
+
<div>${i} ${t}</div>
|
|
297
297
|
</div>
|
|
298
298
|
<table style="width: auto">
|
|
299
299
|
<tbody>${c.join("")}</tbody>
|
|
300
300
|
</table>
|
|
301
|
-
`}}function
|
|
302
|
-
`),al={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",query_id:"",striped:!0,use_raw_columns:!0,ignored_column_keys:"",verticalSpacing:"14px"},ol={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(o.Text,{className:e("table-head-cell",{"table-head-cell--sortable":t.column.getCanSort()}),onClick:t.column.getToggleSortingHandler(),align:n,sx:{justifyContent:ol[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=o.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"}}},ll=o.createStyles((t,e)=>({content:{display:"flex",alignItems:"center",justifyContent:ol[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 cl(t){const e=t.tableCellContext.bgColor;return{backgroundColor:e,color:Ij(e)}}function Zt(t){const e=t.tableCellContext.isClickable(),n=ll({clickable:e,align:t.align});return s.jsx("div",{className:n.classes.content,style:{...cl(t)},children:s.jsx(o.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(Zt,{...t,children:t.value})}function Aj(t){const e=ll({clickable:!0,align:t.align}),n=t.value;return s.jsx("div",{className:e.classes.content,style:{...cl(t)},children:s.jsx(o.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(Zt,{...t,children:e})}function $j(t){const e=U(t.value,{output:"number",mantissa:0,thousandSeparated:!0,absolute:!1});return s.jsx(Zt,{...t,children:e})}function Bj(t){const e=U(t.value,{output:"percent",mantissa:3,trimMantissa:!0,absolute:!1});return s.jsx(Zt,{...t,children:e})}function Lj(t){const{value:e,row_data:n,func_content:r}=t;if(!r)return s.jsx(Zt,{...t,children:e});const i=new Function(`return ${r}`)()({value:e,row_data:n},at);return s.jsx(Zt,{...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=Bu.useVirtual({parentRef:t,size:e.length,estimateSize:m.useCallback(()=>28,[]),overscan:20}),{virtualItems:r,totalSize:i}=n,a=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:[a>0&&s.jsx("tr",{children:s.jsx("td",{style:{height:`${a}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 Mr={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 ul(t,e){const{value:n}=q(t.instanceData,"config"),r={columnsFromConfig:[],columnsFromData:[]};if(n&&(r.columnsFromConfig=n.columns.map((i,a)=>({label:i.label,value:a.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(a=>({label:a,value:a})))}return r}function dl(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}=ul(t.instance,t.sampleData),i=dl(t.instance),a=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(o.Stack,{children:[s.jsx(o.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(o.Mark,{children:"Use original data columns"})," is enabled, you have to address trigger column by its data field"]})}),s.jsx(o.TextInput,{label:e("viz.table.click_cell.column_data_field"),value:u.toString(),onChange:p=>d(p.currentTarget.value)})]}):s.jsx(o.Select,{clearable:!1,data:a,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}=ul(t.instance),{value:n}=q(t.trigger.triggerData,"config"),r=dl(t.instance);return s.jsx(o.Text,{children:Gj(n,e,r)})}function pl(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,a)=>i.from-a.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 a=>r*a+i}getStepFunctionForValue(e){let n=b.findLastIndex(this.steps,r=>r.from<=e);return n=pl(n,0,this.steps.length-2),this.getLinearFunction(this.steps[n],this.steps[n+1])}mapValue(e){return pl(this.getStepFunctionForValue(e)(e),0,100)}}class Qj{constructor(e,n,r,i,a){this.getColIndex=e,this.cell=n,this.triggers=r,this.interactionManager=i,this.colorManager=a}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===Mr.id).filter(n=>{const r=this.getColIndex(this.cell),i=b.get(this.cell.column.columnDef.meta,"value_field"),a=b.get(n.config,"column");return a==r||a==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),a=new Wj(e.steps).mapValue(n);return r==null?void 0:r.getColor(a)}}}const Rj=t=>{const e=Oe(t),n=qe(e.triggerManager,Mr.id),{colorManager:r}=m.useContext(ut);return m.useCallback(i=>new Qj(t.getColIndex,i,n,e,r),[n,e,t.getColIndex])};function hl({queryData:t,width:e,height:n,conf:r,context:i,instance:a}){const{t:l}=_.useTranslation(),{use_raw_columns:c,ignored_column_keys:u,columns:d,...p}=r,{classes:h,cx:g}=zj(),y=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=>y.indexOf(le.column.columnDef.meta),[y]),vizManager:i.vizManager,instance:a}),w=m.useMemo(()=>{const le=Je.createColumnHelper();return y.map(be=>{const ys=Ed(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})})},[y,v]),[T,D]=m.useState([]),I=Je.useReactTable({data:t,state:{sorting:T},onSortingChange:D,columns:w,columnResizeMode:"onChange",getCoreRowModel:Je.getCoreRowModel(),getSortedRowModel:Je.getSortedRowModel()}),{rows:A}=I.getRowModel(),N=m.useRef(null),R=A.length,F=R>0,Q=F?n-22:n,ue=F?22:0;return s.jsxs("div",{ref:N,style:{height:n,width:e,padding:"0 5px"},"data-enable-scrollbar":!0,className:g(h.root,{"table-highlight-on-hover":r.highlightOnHover}),children:[R>0&&s.jsx(o.Box,{className:h.info_bar,sx:{height:22},children:s.jsx(o.Text,{align:"right",pr:6,size:14,color:"dimmed",fw:"normal",children:l("common.pagination.total_rows",{total:R})})}),s.jsxs(o.Table,{sx:{...Mj,maxHeight:Q},...p,striped:r.striped,children:[s.jsx("thead",{className:h.thead,style:{top:ue},children:I.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(o.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:N,rows:A})]})]})}function ml(){const{t}=_.useTranslation();return s.jsx(o.Text,{color:"gray",align:"center",children:t("data.empty_data")})}function Uj({data:t,width:e,height:n,conf:r,context:i,instance:a}){const{t:l}=_.useTranslation(),{panel:c}=mt(),u=c.firstQueryData??[];if(c.queryIDs.length===0)return s.jsx(o.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(ml,{}):s.jsx(hl,{queryData:u,width:e,height:n,conf:{...r,use_raw_columns:!0,columns:[]},context:i,instance:a});const p=t[d];return!Array.isArray(p)||p.length===0?s.jsx(ml,{}):s.jsx(hl,{queryData:p,width:e,height:n,conf:r,context:i,instance:a})}function Yj({context:t,instance:e}){const n=t.data,{height:r,width:i}=t.viewport,{value:a}=q(t.instanceData,"config");return a?s.jsx(Uj,{data:n,width:i,height:r,conf:a,context:t,instance:e}):null}const Kj=S.observer(m.forwardRef(({label:t,required:e,description:n,value:r,onChange:i,clearable:a=!1,sx:l,...c},u)=>{const{panel:d}=ze(),p=m.useMemo(()=>d.queryOptions(r,a),[r,a]);return p.length===0?s.jsx(o.Box,{children:s.jsx(o.TextInput,{label:t,required:e,defaultValue:r,readOnly:!0,disabled:!0})}):s.jsx(o.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 xl(t){return t?b.isString(t)?t==="none"?"none":"static":"interpolation":"none"}function Xj(t,e){var n;return xl(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,a]=m.useState(xl(t.value)),[l,c]=m.useState(Xj(r,t.value)),u=G.useLatest(l),[d,p]=m.useState(Zj(r,t.value)),h=G.useLatest(d),g=w=>{var T,D,I;a(w||"none"),w==="static"?(T=t.onChange)==null||T.call(t,u.current):w==="none"||!w?(D=t.onChange)==null||D.call(t,"none"):(I=t.onChange)==null||I.call(t,h.current)},y=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(o.Stack,{align:"stretch",children:[s.jsx(Hh,{label:n("viz.table.column.cell_background"),value:i||"none",onChange:g}),i==="static"&&s.jsx(Te,{value:l,onChange:y}),i==="interpolation"&&s.jsx(Zh,{colorManager:r,value:d,onChange:v})]})}),ew=m.forwardRef(({value:t,onChange:e,sx:n},r)=>{const{t:i,i18n:a}=_.useTranslation(),l=m.useMemo(()=>Object.values(st).map(c=>({label:i(`viz.table.column.value_type.${c}`),value:c})),[a.language]);return s.jsx(o.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:a,setFalse:l}]=G.useBoolean(),[c,u]=m.useState(t),d=()=>{l(),e(c)},p=()=>{l(),u(t)},h=()=>{u(il)};return m.useEffect(()=>{u(t)},[t]),s.jsxs(s.Fragment,{children:[s.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:s.jsx(k.IconMathFunction,{size:16}),mt:24,onClick:a,sx:{flexGrow:0},children:r("viz.table.column.custom_cell_content")}),s.jsx(o.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(o.Stack,{children:[s.jsx(o.Group,{position:"left",children:s.jsx(Eo,{})}),s.jsx(o.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(o.Group,{position:"apart",children:[s.jsx(o.Button,{onClick:h,color:"red",leftIcon:s.jsx(L.Recycle,{size:20}),children:r("common.actions.reset_to_default")}),s.jsxs(o.Group,{position:"right",children:[s.jsx(o.Button,{onClick:p,variant:"subtle",children:r("common.actions.cancel")}),s.jsx(o.Button,{color:"green",leftIcon:s.jsx(k.IconDeviceFloppy,{size:16}),onClick:d,children:r("common.actions.save")})]})]})]})})]})}),Ir=()=>s.jsx(o.Text,{color:"dimmed",size:12,children:"px"}),nw=({control:t,index:e,watch:n,remove:r,column:i})=>{const{t:a}=_.useTranslation(),l=n(`columns.${e}.value_type`),c=n("query_id");return s.jsxs(o.Stack,{my:0,sx:{position:"relative"},children:[s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:`columns.${e}.label`,control:t,render:({field:u})=>s.jsx(o.TextInput,{label:a("chart.label.label"),required:!0,id:`col-label-${e}`,sx:{flex:1},...u})}),s.jsx(f.Controller,{name:`columns.${e}.value_field`,control:t,render:({field:u})=>s.jsx(O,{label:a("common.data_field"),required:!0,queryID:c,...u})})]}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:`columns.${e}.value_type`,control:t,render:({field:u})=>s.jsx(ew,{sx:{flex:1},...u})}),l===st.custom&&s.jsx(f.Controller,{name:`columns.${e}.func_content`,control:t,render:({field:u})=>s.jsx(tw,{value:u.value??il,onChange:d=>u.onChange(d??"")})})]}),s.jsx(o.Divider,{mb:-10,variant:"dashed",label:a("style.label"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(o.NumberInput,{hideControls:!0,label:a("viz.table.column.min_width"),rightSection:s.jsx(Ir,{}),disabled:!0}),s.jsx(f.Controller,{name:`columns.${e}.width`,control:t,render:({field:u})=>s.jsx(o.NumberInput,{hideControls:!0,label:a("viz.table.column.width"),rightSection:s.jsx(Ir,{}),...u})}),s.jsx(o.NumberInput,{hideControls:!0,label:a("viz.table.column.max_width"),rightSection:s.jsx(Ir,{}),disabled:!0})]}),s.jsx(o.Group,{grow:!0,noWrap:!0,children:s.jsx(f.Controller,{name:`columns.${e}.align`,control:t,render:({field:u})=>s.jsx(Ln,{...u})})}),s.jsx(f.Controller,{name:`columns.${e}.cellBackgroundColor`,control:t,render:({field:u})=>s.jsx(Hj,{...u})}),s.jsx(o.Divider,{mb:4,mt:12,variant:"dashed"}),s.jsx(o.Button,{leftIcon:s.jsx(L.Trash,{size:16}),color:"red",variant:"light",onClick:()=>r(e),children:a("viz.table.column.delete")})]})},sw=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),{fields:r,append:i,remove:a,update:l}=f.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(f.Controller,{name:"use_raw_columns",control:t,render:({field:d})=>s.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&&s.jsx(f.Controller,{name:"ignored_column_keys",control:t,render:({field:d})=>s.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&&s.jsx(o.Stack,{children:s.jsxs(o.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[s.jsxs(o.Tabs.List,{children:[r.map((d,p)=>s.jsx(o.Tabs.Tab,{value:p.toString(),children:p+1},d.id)),s.jsx(o.Tabs.Tab,{onClick:c,value:"add",children:s.jsx(L.Plus,{size:18,color:"#228be6"})})]}),r.map((d,p)=>s.jsx(o.Tabs.Panel,{value:p.toString(),children:s.jsx(nw,{control:t,watch:e,index:p,column:d,remove:a})},d.id))]})})]})};function rw({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["horizontalSpacing","verticalSpacing","fontSize","striped","highlightOnHover"]),s.jsxs(o.Stack,{spacing:"xs",children:[s.jsxs(o.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:[s.jsx(f.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(f.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(o.Group,{position:"apart",mb:"lg",grow:!0,sx:{"> *":{flexGrow:1}},children:s.jsx(f.Controller,{name:"fontSize",control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("style.font_size.label"),placeholder:n("style.font_size.placeholder"),required:!0,sx:{flex:1},...r})})}),s.jsxs(o.Group,{position:"apart",grow:!0,children:[s.jsx(f.Controller,{name:"striped",control:t,render:({field:r})=>s.jsx(o.Switch,{label:n("viz.table.style.striped"),checked:r.value,onChange:i=>r.onChange(i.currentTarget.checked)})}),s.jsx(f.Controller,{name:"highlightOnHover",control:t,render:({field:r})=>s.jsx(o.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,al),[n]),a=m.useMemo(()=>iw(i),[i]);m.useEffect(()=>{!b.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),r(a))},[i,a]);const{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=f.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]);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(o.Tabs,{defaultValue:"Columns",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"Columns",children:e("viz.table.column.labels")}),s.jsx(o.Tabs.Tab,{value:"Style",children:e("style.label")})]}),s.jsxs(o.Tabs.Panel,{value:"Columns",children:[s.jsx(f.Controller,{name:"query_id",control:l,render:({field:y})=>s.jsx(Kj,{label:e("viz.table.column.query_id"),description:e("viz.table.column.query_id_hint"),required:!0,...y})}),s.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),s.jsx(sw,{control:l,watch:u})]}),s.jsx(o.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:a,...l}=t;return{...l,id_field:r(i),columns:a.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}=E(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:a,...l})=>({id:a??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 Er={createConfig(){return{version:7,config:b.cloneDeep(al)}},displayName:"viz.table.viz_name",displayGroup:"chart.groups.others",migrator:new hw,name:"table",viewRender:Yj,configRender:aw,triggers:[Mr],translation:ow},gl=["function text({ data, variables, filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
303
|
-
`),Ar={func_content:gl,horizontal_align:"left",font_size:"14px",font_weight:"normal"},mw=S.observer(({context:t})=>{const e=he(),{value:n=Ar}=q(t.instanceData,"config"),{variables:r}=t,i=t.data,{func_content:a,horizontal_align:l,font_size:c,font_weight:u}=n,d=m.useMemo(()=>r.reduce((h,g)=>{const y=Ze(g,i);return h[g.name]=Ie(g,y),h},{}),[r,i]),p=m.useMemo(()=>new Function(`return ${a}`)()({data:i,variables:d,filters:e.payloadForSQL.filters,context:e.payloadForSQL.context}),[a,i,d,e.payloadForSQL]);return s.jsx(o.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,a]=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(o.Stack,{spacing:0,mt:"sm",mb:"lg",children:[s.jsx(o.Text,{size:"sm",children:t}),s.jsx(o.Box,{px:"1.5em",children:s.jsx(o.Slider,{label:null,marks:is,value:i,onChange:a,step:25,ref:r})})]})}const fl=m.forwardRef(xw),gw=({value:t,onChange:e})=>{const n=r=>{r&&e(r)};return s.jsx(o.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:a,setFalse:l}]=G.useBoolean(),[c,u]=m.useState(t),d=()=>{l(),e(c)},p=()=>{l(),u(t)},h=()=>{u(gl)};return m.useEffect(()=>{u(t)},[t]),s.jsxs(s.Fragment,{children:[s.jsx(o.Button,{color:"grape",variant:"filled",leftIcon:s.jsx(k.IconMathFunction,{size:16}),mt:24,onClick:a,sx:{flexGrow:0},children:r("viz.text.content.edit")}),s.jsx(o.Modal,{size:800,title:r("viz.text.content.label"),opened:i,onClose:l,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:i&&s.jsxs(o.Stack,{children:[s.jsx(gw,{value:c,onChange:u}),s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Button,{onClick:h,color:"red",leftIcon:s.jsx(L.Recycle,{size:20}),children:r("common.actions.reset_to_default")}),s.jsxs(o.Group,{position:"right",children:[s.jsx(o.Button,{onClick:p,variant:"subtle",children:r("common.actions.cancel")}),s.jsx(o.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,Ar),[n]),a=m.useMemo(()=>{const{func_content:y,horizontal_align:v,font_size:w,font_weight:T}=i;return{func_content:y,horizontal_align:v,font_size:w,font_weight:T}},[i]);m.useEffect(()=>{!b.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),r(a))},[i,a]);const{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=f.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]),u(["func_content","horizontal_align","font_size","font_weight"]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,i),[h,i]);return s.jsx(o.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:c(r),children:[s.jsx(ge,{canSubmit:g}),s.jsxs(o.Stack,{spacing:10,children:[s.jsx(f.Controller,{name:"func_content",control:l,render:({field:y})=>s.jsx(fw,{...y})}),s.jsx(o.Divider,{mt:10,mb:-10,variant:"dashed",label:e("chart.style.label"),labelPosition:"center"}),s.jsx(f.Controller,{name:"horizontal_align",control:l,render:({field:y})=>s.jsx(Ln,{...y})}),s.jsx(f.Controller,{name:"font_size",control:l,render:({field:y})=>s.jsx(o.TextInput,{label:e("style.font_size.label"),placeholder:e("style.font_size.placeholder"),sx:{flex:1},...y})}),s.jsx(o.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:s.jsx(f.Controller,{name:"font_weight",control:l,render:({field:y})=>s.jsx(fl,{label:e("style.font_weight.label"),...y})})})]})]})})}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(Ar)}},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 yl(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},a={baseURL:t,method:"POST",url:e,params:r.params,headers:i};return a.data=r.string?JSON.stringify(n):n,rt(a).then(l=>l.data).catch(l=>Promise.reject(l))}const Cw=({conf:t,panelData:e})=>async()=>{const{expertSystemURL:n,path:r,goal:i,question:a}=t;if(!r||!i||!a)return;const l=Ad(e);if(!l)return;const c={dashboard:i,panel:a,data:l};try{const u=n.startsWith("http")?n:window.location.origin;return await ww(u,`/expert/v3/devtable/${r}`,c,{})}catch(u){throw yl(u,"response.data.detail"),yl(u,"response.data.error"),console.error(u),u}},Pr={expertSystemURL:"",path:"",goal:"",question:""},$r={height:"100%",overflowY:"auto",...sr},bl=({message:t})=>s.jsx(o.Box,{sx:$r,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(bl,{message:r});const a=n-25-20-30;return s.jsx(o.Center,{sx:{width:"100%",height:a},children:s.jsxs(o.Stack,{align:"center",spacing:20,children:[s.jsx(jw,{}),s.jsx(bl,{message:r})]})})};function kw({context:t}){const{value:e}=q(t.instanceData,"config"),n=m.useMemo(()=>b.defaultsDeep({},e,Pr),[e]),{width:r,height:i}=t.viewport,a=t.data,{data:l,error:c,loading:u}=G.useRequest(Cw({conf:n,panelData:a}),{refreshDeps:[a,n]});return!r||!i||!n?null:u?s.jsx(o.Box,{sx:{position:"relative",height:i},children:s.jsx(o.LoadingOverlay,{visible:!0})}):c?s.jsx(o.Box,{sx:$r,"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(o.Box,{sx:$r,"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,Pr),[e]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=f.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:a(n),children:s.jsxs(o.Stack,{children:[s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:"expertSystemURL",control:i,render:({field:h})=>s.jsx(o.TextInput,{label:"Expert System URL",...h})}),s.jsx(f.Controller,{name:"path",control:i,render:({field:h})=>s.jsx(o.TextInput,{label:"Path",required:!0,...h})})]}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:"goal",control:i,render:({field:h})=>s.jsx(o.TextInput,{label:"Goal",required:!0,...h})}),s.jsx(f.Controller,{name:"question",control:i,render:({field:h})=>s.jsx(o.TextInput,{label:"Question",required:!0,...h})})]}),s.jsx(o.Divider,{variant:"dashed",mt:16,mb:8}),s.jsx(o.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(Pr)}},translation:Dw};function Iw(t,e,n){if(!t)return n[0];try{return[e,M(e).add(1,"year").subtract(1,"day").valueOf()]}catch(r){return console.error(r),n[0]}}function Ew(t,e,n){const r=Iw(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 Aw(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 Pw(t,e){return{show:!t,selectedMode:"single",top:5,right:5,data:e.map(n=>({name:n,icon:"circle"}))}}function $w(t,e,n,r){const{calendar:i,heat_block:a}=t,l=E(i.data_key),c=E(a.data_key);return e?{type:"heatmap",name:"heatmap",coordinateSystem:"calendar",calendarIndex:0,data:r[l.queryID].map(u=>[b.get(u,l.columnKey),b.get(u,c.columnKey)])}:Object.entries(n).map(([u,d])=>({type:"heatmap",name:u,coordinateSystem:"calendar",calendarIndex:0,data:d.map(p=>[b.get(p,l.columnKey),b.get(p,c.columnKey)])}))}const Bw=t=>U(t,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Lw({conf:t,valueFormatters:e,dataDict:n,params:r}){const{value:i}=r,[a,l]=i,u=[{label:t.heat_block.name,value:e.heat_block(l),style:{label:"",value:""}}],d=n[a];return d&&t.tooltip.metrics.forEach(p=>{const h=E(p.data_key);u.push({label:p.name,value:Bw(b.get(d,h.columnKey,"")),style:{label:"",value:""}})}),u}function qw(t,e,n){const r=E(t.calendar.data_key),i=b.keyBy(e[r.queryID],r.columnKey);return te.getTooltip({formatter:function(a){const c=Lw({conf:t,valueFormatters:n,dataDict:i,params:a}).map(p=>`
|
|
301
|
+
`}}function QT(){return te.getTooltip({trigger:"item",formatter:RT()})}const UT={tooltip:{show:!0},series:{type:"sunburst",radius:[0,"90%"],emphasis:{focus:"ancestor"}}};function YT(e,t,n){n.reduce((a,l)=>{const c=_t(l,t);return a[l.name]=Re(l,c),a},{});const i={series:{data:FT(e,t),levels:WT(e)},tooltip:QT()};return v.defaultsDeep({},i,UT)}function KT({context:e}){const{variables:t}=e,{value:n}=$(e.instanceData,"config"),s=g.useMemo(()=>v.defaults({},n,ko),[n]),i=e.data,{width:a,height:l}=e.viewport,c=g.useMemo(()=>YT(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:mr(a,l),notMerge:!0,theme:"merico-light"})})}function XT({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 JT=({control:e,index:t})=>{const{t:n,i18n:s}=_.useTranslation(),i=g.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(xn,{...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})})]})]})},ZT=({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(JT,{control:e,index:l})})]})};function HT({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>v.defaultsDeep({},n,ko),[n]),a=g.useMemo(()=>v.clone(i),[i]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});g.useEffect(()=>{p(a)},[a]);const h=d(),f=g.useMemo(()=>!v.isEqual(h,i),[h,i]);u(["label_key","value_key","group_key","levels"]);const[x,y]=g.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:x,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(XT,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Levels",children:r.jsx(ZT,{control:l,watch:u})})]})]})})}const e1=[{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 t1(e){const{label_field:t,value_field:n,...s}=e;return{...s,label_key:t,value_key:n}}function n1(e){const{group_key:t="",...n}=e;return{...n,group_key:t}}function r1(e){const{levels:t=[],...n}=e;return{...n,levels:t}}function s1(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 i1 extends me{constructor(){super(...arguments);B(this,"VERSION",5)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:t1(n.config)})),this.version(3,n=>({...n,version:3,config:n1(n.config)})),this.version(4,n=>({...n,version:4,config:r1(n.config)})),this.version(5,(n,s)=>({...n,version:5,config:s1(n.config,s)}))}}const a1={displayName:"viz.sunburst_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new i1,name:"sunburst",viewRender:KT,configRender:HT,createConfig(){return{version:5,config:v.cloneDeep(ko)}},translation:e1};var Tt=(e=>(e.string="string",e.number="number",e.eloc="eloc",e.percentage="percentage",e.url="url",e.custom="custom",e))(Tt||{});const Xp=["function text({ value, row_data }, utils) {"," return value","}"].join(`
|
|
302
|
+
`),Jp={columns:[],fontSize:"14px",highlightOnHover:!0,horizontalSpacing:"14px",query_id:"",striped:!0,use_raw_columns:!0,ignored_column_keys:"",verticalSpacing:"14px"},Zp={left:"flex-start",center:"center",right:"flex-end"},o1=({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:Zp[n]},children:[e.isPlaceholder?null:bt.flexRender(e.column.columnDef.header,e.getContext()),r.jsx(l1,{direction:e.column.getIsSorted()})]})},l1=({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}},c1=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"}})),u1={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"}}},Hp=o.createStyles((e,t)=>({content:{display:"flex",alignItems:"center",justifyContent:Zp[t.align],".table-cell-text":{whiteSpace:"nowrap",cursor:t.clickable?"pointer":"default",textDecoration:t.clickable?"underline":"none"}}}));function d1(e){return e?Gt(e).oklch()[0]>.7?"black":"white":"inherit"}function eh(e){const t=e.tableCellContext.bgColor;return{backgroundColor:t,color:d1(t)}}function rr(e){const t=e.tableCellContext.isClickable(),n=Hp({clickable:t,align:e.align});return r.jsx("div",{className:n.classes.content,style:{...eh(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 p1(e){return r.jsx(rr,{...e,children:e.value})}function h1(e){const t=Hp({clickable:!0,align:e.align}),n=e.value;return r.jsx("div",{className:t.classes.content,style:{...eh(e)},children:r.jsx(o.Anchor,{className:"table-cell-text",href:n,target:"_blank",color:"black",children:n})})}function f1(e){const t=U(e.value,{output:"number",average:!0,mantissa:2,trimMantissa:!0,absolute:!1});return r.jsx(rr,{...e,children:t})}function g1(e){const t=U(e.value,{output:"number",mantissa:0,thousandSeparated:!0,absolute:!1});return r.jsx(rr,{...e,children:t})}function m1(e){const t=U(e.value,{output:"percent",mantissa:3,trimMantissa:!0,absolute:!1});return r.jsx(rr,{...e,children:t})}function x1(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},At);return r.jsx(rr,{...e,children:i})}function y1(e){switch(e.type){case Tt.string:return r.jsx(p1,{...e});case Tt.eloc:return r.jsx(f1,{...e});case Tt.number:return r.jsx(g1,{...e});case Tt.percentage:return r.jsx(m1,{...e});case Tt.url:return r.jsx(h1,{...e});case Tt.custom:return r.jsx(x1,{...e})}}function b1({tableContainerRef:e,rows:t}){var c,u;const n=_g.useVirtual({parentRef:e,size:t.length,estimateSize:g.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 To={id:"builtin:table:click-cell-content",displayName:"viz.table.click_cell.click_cell_content",nameRender:w1,configRender:_1,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"}]},v1={column:""};function th(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 nh(e){const{value:t}=$(e.instanceData,"config");return(t==null?void 0:t.use_raw_columns)??!1}function _1(e){const{t}=_.useTranslation(),{columnsFromConfig:n,columnsFromData:s}=th(e.instance,e.sampleData),i=nh(e.instance),a=n.length>0?n:s,{value:l,set:c}=$(e.trigger.triggerData,"config"),{column:u}=v.defaults({},l,v1),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 j1(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 w1(e){const{columnsFromConfig:t}=th(e.instance),{value:n}=$(e.trigger.triggerData,"config"),s=nh(e.instance);return r.jsx(o.Text,{children:j1(n,t,s)})}function rh(e,t,n){return Math.min(Math.max(e,t),n)}class C1{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=rh(n,0,this.steps.length-2),this.getLinearFunction(this.steps[n],this.steps[n+1])}mapValue(t){return rh(this.getStepFunctionForValue(t)(t),0,100)}}class S1{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===To.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 C1(t.steps).mapValue(n);return s==null?void 0:s.getColor(a)}}}const k1=e=>{const t=rt(e),n=nt(t.triggerManager,To.id),{colorManager:s}=g.useContext(Nt);return g.useCallback(i=>new S1(e.getColIndex,i,n,t,s),[n,t,e.getColIndex])};function sh({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}=c1(),x=g.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:Tt.string,align:"left",width:"",cellBackgroundColor:""}))},[c,u,d,e]),y=k1({getColIndex:g.useCallback(ie=>x.indexOf(ie.column.columnDef.meta),[x]),vizManager:i.vizManager,instance:a}),j=g.useMemo(()=>{const ie=bt.createColumnHelper();return x.map(xe=>{const se=xm(xe.value_field);return ie.accessor(se.columnKey,{cell:Fe=>r.jsx(y1,{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})})},[x,y]),[k,S]=g.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=g.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:{...u1,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(o1,{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(b1,{tableContainerRef:I,rows:z})]})]})}function ih(){const{t:e}=_.useTranslation();return r.jsx(o.Text,{color:"gray",align:"center",children:e("data.empty_data")})}function T1({data:e,width:t,height:n,conf:s,context:i,instance:a}){const{t:l}=_.useTranslation(),{panel:c}=Qt(),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(ih,{}):r.jsx(sh,{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(ih,{}):r.jsx(sh,{queryData:p,width:t,height:n,conf:s,context:i,instance:a})}function D1({context:e,instance:t}){const n=e.data,{height:s,width:i}=e.viewport,{value:a}=$(e.instanceData,"config");return a?r.jsx(T1,{data:n,width:i,height:s,conf:a,context:e,instance:t}):null}const M1=D.observer(g.forwardRef(({label:e,required:t,description:n,value:s,onChange:i,clearable:a=!1,sx:l,...c},u)=>{const{panel:d}=Ge(),p=g.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})})),z1=[{from:0,to:0},{from:100,to:100}];function ah(e){return e?v.isString(e)?e==="none"?"none":"static":"interpolation":"none"}function I1(e,t){var n;return ah(t)==="static"?t:(n=e.getStaticColors()[0])==null?void 0:n.value}function E1(e,t){return v.isObject(t)?t:{steps:z1,interpolation:e.encodeColor(e.getColorInterpolations()[0])}}const A1=g.forwardRef((e,t)=>{const{t:n}=_.useTranslation(),{colorManager:s}=g.useContext(Nt),[i,a]=g.useState(ah(e.value)),[l,c]=g.useState(I1(s,e.value)),u=W.useLatest(l),[d,p]=g.useState(E1(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)},x=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:x}),i==="interpolation"&&r.jsx(By,{colorManager:s,value:d,onChange:y})]})}),P1=g.forwardRef(({value:e,onChange:t,sx:n},s)=>{const{t:i,i18n:a}=_.useTranslation(),l=g.useMemo(()=>Object.values(Tt).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})}),O1=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),[i,{setTrue:a,setFalse:l}]=W.useBoolean(),[c,u]=g.useState(e),d=()=>{l(),t(c)},p=()=>{l(),u(e)},h=()=>{u(Xp)};return g.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(jp,{})}),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")})]})]})]})})]})}),Do=()=>r.jsx(o.Text,{color:"dimmed",size:12,children:"px"}),L1=({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(P1,{sx:{flex:1},...u})}),l===Tt.custom&&r.jsx(b.Controller,{name:`columns.${t}.func_content`,control:e,render:({field:u})=>r.jsx(O1,{value:u.value??Xp,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(Do,{}),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(Do,{}),...u})}),r.jsx(o.NumberInput,{hideControls:!0,label:a("viz.table.column.max_width"),rightSection:r.jsx(Do,{}),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(ds,{...u})})}),r.jsx(b.Controller,{name:`columns.${t}.cellBackgroundColor`,control:e,render:({field:u})=>r.jsx(A1,{...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")})]})},B1=({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:Tt.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(L1,{control:e,watch:t,index:p,column:d,remove:a})},d.id))]})})]})};function q1({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(Ra,{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(Ra,{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 V1({columns:e,...t}){return{...t,columns:e.map(({id:n,...s})=>({id:n??he.randomId(),...s}))}}function N1({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>v.defaultsDeep({},n,Jp),[n]),a=g.useMemo(()=>V1(i),[i]);g.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});g.useEffect(()=>{p(a)},[a]);const h=d(),f=g.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:x})=>r.jsx(M1,{label:t("viz.table.column.query_id"),description:t("viz.table.column.query_id_hint"),required:!0,...x})}),r.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(B1,{control:l,watch:u})]}),r.jsx(o.Tabs.Panel,{value:"Style",children:r.jsx(q1,{control:l,watch:u})})]})]})}const $1=[{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 F1(e){const{columns:t,...n}=e;return{...e,columns:t.map(s=>({...s,align:s.align??"left"}))}}function G1(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 W1(e){const{columns:t,...n}=e;return{...n,columns:t.map(s=>({...s,align:s.align??"left",cellBackgroundColor:s.cellBackgroundColor??"",width:s.width??""}))}}function R1(e){const{id_field:t,...n}=e,{queryID:s}=O(t);return{...n,query_id:s??""}}function Q1(e){const{ignored_column_keys:t,...n}=e;return{...n,ignored_column_keys:t??""}}class U1 extends me{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:F1(n.config)})),this.version(4,(n,s)=>({...n,version:4,config:G1(n.config,s)})),this.version(5,n=>({...n,version:5,config:W1(n.config)})),this.version(6,n=>({...n,version:6,config:R1(n.config)})),this.version(7,n=>({...n,version:7,config:Q1(n.config)}))}}const Mo={createConfig(){return{version:7,config:v.cloneDeep(Jp)}},displayName:"viz.table.viz_name",displayGroup:"chart.groups.others",migrator:new U1,name:"table",viewRender:D1,configRender:N1,triggers:[To],translation:$1},oh=["function text({ data, variables, filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
303
|
+
`),zo={func_content:oh,horizontal_align:"left",font_size:"14px",font_weight:"normal"},Y1=D.observer(({context:e})=>{const t=_e(),{value:n=zo}=$(e.instanceData,"config"),{variables:s}=e,i=e.data,{func_content:a,horizontal_align:l,font_size:c,font_weight:u}=n,d=g.useMemo(()=>s.reduce((h,f)=>{const x=_t(f,i);return h[f.name]=Re(f,x),h},{}),[s,i]),p=g.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})}),ti=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function K1({label:e,value:t,onChange:n},s){var l;const[i,a]=g.useState(((l=ti.find(c=>c.label===t))==null?void 0:l.value)??ti[0].value);return g.useEffect(()=>{const c=ti.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:ti,value:i,onChange:a,step:25,ref:s})})]})}const lh=g.forwardRef(K1),X1=({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}}})})},J1=g.forwardRef(({value:e,onChange:t},n)=>{const{t:s}=_.useTranslation(),[i,{setTrue:a,setFalse:l}]=W.useBoolean(),[c,u]=g.useState(e),d=()=>{l(),t(c)},p=()=>{l(),u(e)},h=()=>{u(oh)};return g.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(X1,{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 Z1({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>v.defaultsDeep({},n,zo),[n]),a=g.useMemo(()=>{const{func_content:x,horizontal_align:y,font_size:j,font_weight:k}=i;return{func_content:x,horizontal_align:y,font_size:j,font_weight:k}},[i]);g.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});g.useEffect(()=>{p(a)},[a]),u(["func_content","horizontal_align","font_size","font_weight"]);const h=d(),f=g.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:x})=>r.jsx(J1,{...x})}),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:x})=>r.jsx(ds,{...x})}),r.jsx(b.Controller,{name:"font_size",control:l,render:({field:x})=>r.jsx(o.TextInput,{label:t("style.font_size.label"),placeholder:t("style.font_size.placeholder"),sx:{flex:1},...x})}),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:x})=>r.jsx(lh,{label:t("style.font_weight.label"),...x})})})]})]})})}const H1=[{lang:"en",resources:{text:{viz_name:"Text",content:{label:"Text content",edit:"Edit Content"}}}},{lang:"zh",resources:{text:{viz_name:"文本",content:{label:"文本内容",edit:"编辑文本内容"}}}}];class eD extends me{constructor(){super(...arguments);B(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const tD={displayName:"viz.text.viz_name",displayGroup:"chart.groups.others",migrator:new eD,name:"text",viewRender:Y1,configRender:Z1,createConfig(){return{version:1,config:v.cloneDeep(zo)}},translation:H1},nD=()=>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 ch(e,t){const n=v.get(e,t,"");if(n)throw new Error(n)}async function rD(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,It(a).then(l=>l.data).catch(l=>Promise.reject(l))}const sD=({conf:e,panelData:t})=>async()=>{const{expertSystemURL:n,path:s,goal:i,question:a}=e;if(!s||!i||!a)return;const l=ym(t);if(!l)return;const c={dashboard:i,panel:a,data:l};try{const u=n.startsWith("http")?n:window.location.origin;return await rD(u,`/expert/v3/devtable/${s}`,c,{})}catch(u){throw ch(u,"response.data.detail"),ch(u,"response.data.error"),console.error(u),u}},Io={expertSystemURL:"",path:"",goal:"",question:""},Eo={height:"100%",overflowY:"auto",...Za},uh=({message:e})=>r.jsx(o.Box,{sx:Eo,children:r.jsx("div",{dangerouslySetInnerHTML:{__html:e},style:{fontSize:"14px",lineHeight:"32px",color:"#3D3E45"}})}),iD=({error:e,width:t,height:n})=>{const s=e.message;if(s.startsWith("<"))return r.jsx(uh,{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(nD,{}),r.jsx(uh,{message:s})]})})};function aD({context:e}){const{value:t}=$(e.instanceData,"config"),n=g.useMemo(()=>v.defaultsDeep({},t,Io),[t]),{width:s,height:i}=e.viewport,a=e.data,{data:l,error:c,loading:u}=W.useRequest(sD({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:Eo,"data-enable-scrollbar":!0,children:r.jsx(iD,{error:c,width:s,height:i})}):!l||!Array.isArray(l.replies)||l.replies.length===0?null:r.jsx(o.Box,{sx:Eo,"data-enable-scrollbar":!0,children:l.replies.map((d,p)=>r.jsx("div",{dangerouslySetInnerHTML:{__html:d.interpretation.html}},p))})}function oD({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=g.useMemo(()=>v.defaultsDeep({},t,Io),[t]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});g.useEffect(()=>{u(s)},[s]),l(["expertSystemURL","goal","path","question"]);const d=c(),p=g.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 lD=[{lang:"en",resources:{merico_gqm:{viz_name:"Merico GQM"}}},{lang:"zh",resources:{merico_gqm:{viz_name:"思码逸GQM组件"}}}];class cD extends me{constructor(){super(...arguments);B(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const uD={displayName:"viz.merico_gqm.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new cD,name:"mericoGQM",viewRender:aD,configRender:oD,createConfig(){return{version:1,config:v.cloneDeep(Io)}},translation:lD};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 pD(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 hD(e){const{visualMap:t=Jt(),heat_block:{min:n,max:s,...i},...a}=e;return{...a,heat_block:i,visualMap:{...Jt(),min:n,max:s}}}const fD=[{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 gD(e){return r.jsx(r.Fragment,{})}function mD(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.calendar_heatmap.click_heatmap.heatblock.label")})}const dh={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.calendar_heatmap.click_heatmap.heatblock.label",nameRender:mD,configRender:gD,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"}]},Ao={calendar:{data_key:"",locale:"EN"},heat_block:{name:"Value",data_key:"",value_formatter:Me},tooltip:{metrics:[]},visualMap:Jt()};function xD(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 yD(e,t,n){const s=xD(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 bD(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 vD(e,t){return{show:!e,selectedMode:"single",top:5,right:5,data:t.map(n=>({name:n,icon:"circle"}))}}function _D(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 jD=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function wD({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:jD(v.get(d,h.columnKey,"")),style:{label:"",value:""}})}),u}function CD(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=wD({conf:e,valueFormatters:n,dataDict:i,params:a}).map(p=>`
|
|
304
304
|
<tr>
|
|
305
305
|
<th style="text-align: right;">
|
|
306
306
|
<div style="${p.style.label}">${p.label}</div>
|
|
@@ -309,7 +309,7 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
309
309
|
<div style="${p.style.value}">${p.value}
|
|
310
310
|
</td>
|
|
311
311
|
</tr>
|
|
312
|
-
`),u=
|
|
312
|
+
`),u=v.get(a.value,0);return`
|
|
313
313
|
<table style="width: auto">
|
|
314
314
|
<thead>
|
|
315
315
|
<tr colspan="2">
|
|
@@ -326,13 +326,13 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
326
326
|
</thead>
|
|
327
327
|
<tbody>${c.join("")}</tbody>
|
|
328
328
|
</table>
|
|
329
|
-
`}})}function Ow(t,e,n){const r=Jt(t.heat_block.min,n),i=Jt(t.heat_block.max,n);return{min:r,max:i,calculable:!0,orient:"horizontal",left:e?"center":5,top:0,itemWidth:15}}const Vw={grid:{containLabel:!0}},Nw=t=>M(t).get("year");function Gw(t,e){const n=E(t.calendar.data_key),r=e[n.queryID],i=b.groupBy(r,d=>Nw(d[n.columnKey])),a=Object.keys(i),l=r.map(d=>M(d[n.columnKey]).valueOf()),c=b.min(l),u=b.max(l);return{minDate:c??0,maxDate:u??0,dateSpan:M(u).diff(c,"day"),dataByYear:i,years:a}}function Fw(t,e,n){const r=n.reduce((h,g)=>{const y=Ze(g,e);return h[g.name]=Ie(g,y),h},{}),i=Aw(t),{dateSpan:a,minDate:l,dataByYear:c,years:u}=Gw(t,e),d=a<=366,p={calendar:Ew(d,l,u),series:$w(t,d,c,e),tooltip:qw(t,e,i),visualMap:Ow(t,d,r),legend:Pw(d,u)};return b.defaultsDeep({},p,Vw)}function Ww(t){return s.jsx(s.Fragment,{})}function Qw(t){const{t:e}=_.useTranslation();return s.jsx(o.Text,{children:e("viz.calendar_heatmap.click_heatmap.heatblock.label")})}const vl={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.calendar_heatmap.click_heatmap.heatblock.label",nameRender:Qw,configRender:Ww,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"}]},Br={calendar:{data_key:"",locale:"EN"},heat_block:{min:{type:"static",value:0},max:{type:"static",value:100},name:"Value",data_key:"",value_formatter:_e},tooltip:{metrics:[]}};function Rw({name:t},e){const n=e.getOption();n.calendar.forEach(r=>{r.range=t}),e.setOption(n)}function Uw({conf:t,data:e,width:n,height:r,interactionManager:i,variables:a}){const l=Mt(e,t.calendar.data_key),c=qe(i.triggerManager,vl.id),u=m.useCallback(h=>{const[g,y]=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:Rw}),[u]),p=m.useMemo(()=>Fw(t,e,a),[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 Yw({context:t,instance:e}){const n=Oe({vizManager:t.vizManager,instance:e}),{value:r}=q(t.instanceData,"config"),{variables:i}=t,a=m.useMemo(()=>b.defaults({},r,Br),[r]),l=t.data,{width:c,height:u}=t.viewport;return!a.calendar.data_key||!a.heat_block.data_key||!c||!u?null:s.jsx(Ae,{width:c,height:u,children:s.jsx(Uw,{variables:i,width:He(c),height:et(u),data:l,conf:a,interactionManager:n})})}function Kw({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["heat_block"]),s.jsxs(o.Stack,{children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.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(f.Controller,{name:"heat_block.name",control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...r})})]}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"heat_block.min",control:t,render:({field:r})=>s.jsx(Kt,{label:n("chart.heatmap.heatblock.min_value"),...r})}),s.jsx(f.Controller,{name:"heat_block.max",control:t,render:({field:r})=>s.jsx(Kt,{label:n("chart.heatmap.heatblock.max_value"),...r})})]}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("numbro.format.label"),labelPosition:"center"}),s.jsx(f.Controller,{name:"heat_block.value_formatter",control:t,render:({field:r})=>s.jsx(Re,{...r})})]})}const Jw=({control:t,index:e})=>{const{t:n}=_.useTranslation();return s.jsx(o.Stack,{children:s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`tooltip.metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(f.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})})]})})},Xw=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),s.jsx(o.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:a,index:l})=>s.jsx(Jw,{control:t,index:l})})]})};function Zw({control:t,watch:e}){return s.jsx(Xw,{control:t,watch:e})}const Hw=[{label:"中文",value:"ZH"},{label:"English",value:"EN"}];function e0({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["calendar"]),s.jsxs(o.Stack,{children:[s.jsx(o.Group,{grow:!0,noWrap:!0,children:s.jsx(f.Controller,{name:"calendar.data_key",control:t,render:({field:r})=>s.jsx(O,{label:n("common.data_field"),sx:{flex:1},...r})})}),s.jsx(f.Controller,{name:"calendar.locale",control:t,render:({field:r})=>s.jsx(o.Select,{label:n("viz.calendar_heatmap.calendar.locale"),data:Hw,sx:{flex:1},...r})})]})}function t0({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),i=m.useMemo(()=>b.defaultsDeep({},n,Br),[n]),a=m.useMemo(()=>b.cloneDeep(i),[i]);m.useEffect(()=>{!b.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),r(a))},[i,a]);const{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=f.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,i),[h,i]);return s.jsx(o.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:c(r),children:[s.jsx(ge,{canSubmit:g}),s.jsxs(o.Tabs,{defaultValue:"Calendar",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"Calendar",children:e("viz.calendar_heatmap.calendar.label")}),s.jsx(o.Tabs.Tab,{value:"Heat Block",children:e("chart.heatmap.heatblock.label")}),s.jsx(o.Tabs.Tab,{value:"Tooltip",children:e("chart.tooltip.label")})]}),s.jsx(o.Tabs.Panel,{value:"Calendar",children:s.jsx(e0,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Heat Block",children:s.jsx(Kw,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Tooltip",children:s.jsx(Zw,{control:l,watch:u})})]})]})})}const n0=[{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 s0(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:a,tooltip:l,...c}=t;return{...c,calendar:{...i,data_key:r(i.data_key)},heat_block:{...a,data_key:r(a.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 r0(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}}}}class i0 extends ce{constructor(){super(...arguments);$(this,"VERSION",3)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,(n,r)=>({...n,version:2,config:s0(n.config,r)})),this.version(3,n=>({...n,version:3,config:r0(n.config)}))}}const a0={displayName:"viz.calendar_heatmap.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new i0,name:"calendarHeatmap",viewRender:Yw,configRender:t0,createConfig:()=>({version:3,config:Br}),triggers:[vl],translation:n0},Lr={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 o0(){const t=new Date().getTime().toString();return{id:t,min:"",max:"",name:t,data_key:"",position:"bottom",label_formatter:_e,show:!0}}function l0(){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:Nt,xAxisIndex:"0"}}function c0(){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 u0(t){const e=t.x_axes.some(a=>a.position==="top"&&!!a.name&&a.show);let n=0;e&&(n+=15);const r=t.x_axes.some(a=>a.position==="bottom"&&!!a.name&&a.show);let i=0;return r&&(i+=15),t.series.some(a=>!a.hide_in_legend)&&(i+=20),{top:n,right:5,bottom:i,left:5,containLabel:!0}}function d0(t){switch(t){case"bar":return"roundRect";case"scatter":return"circle"}}function p0(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:d0(r)})),e}function h0(t,e,n,r){return t.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?un(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 m0(t,e,n,r){const i=as(e,n,r);return b.unionBy(i,t,0)}function x0({dataTemplate:t,data:e,name_data_key:n,value_data_key:r,valueTypedXAxis:i}){return i?m0(t,e,n,r):as(e,n,r)}function g0({dataTemplate:t,data:e,aggregation_on_value:n,name_data_key:r,value_data_key:i,valueTypedXAxis:a}){if(!n||n.type==="none")return x0({dataTemplate:t,data:e,name_data_key:r,value_data_key:i,valueTypedXAxis:a});const l=as(e,r,i),c=b.groupBy(l,"0");return t.map(([d])=>{const h=c[d].map(y=>y[1]),g=zs(h,n);return[d,g]})}function f0({group_by_key:t,data:e,value_data_key:n,name_data_key:r}){const{queryID:i,columnKey:a}=E(t),l=b.groupBy(e[i],a);return Object.entries(l).forEach(([c,u])=>{l[c]=as({[i]:u},r,n)}),l}function y0({y_axis:t},{data_key:e,xAxisIndex:n,label_position:r,name:i,group_by_key:a,aggregation_on_value:l,stack:c,color:u,hide_in_legend:d,invisible:p,id:h,...g},y,v,w,T,D){const I={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(!a||a===t.data_key)return I.data=g0({dataTemplate:y,data:w,aggregation_on_value:l,name_data_key:t.data_key,value_data_key:e,valueTypedXAxis:v}),I;const A=f0({group_by_key:a,data:w,name_data_key:t.data_key,value_data_key:e});return Object.entries(A).map(([N,R])=>{const F=b.cloneDeep(I);return F.name=N,F.color=void 0,F.data=R,F})}function b0(t,e,n,r,i,a,l){const c=e.map(d=>[d,0]);return t.series.map(d=>y0(t,d,c,n,r,l,i)).flat().concat(h0(t.reference_lines,a,l,r))}function v0(t,e){const n=t.find(c=>c.axisDim==="y"&&c.axisId==="main-y-axis");if(!n)return"";const{name:r,axisType:i,axisValue:a,axisIndex:l}=n;return i==="yAxis.category"?r:Pe(e.y_axis.axisLabel.formatter)(a,l)}function _0(t,e,n){const r=e.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 g=r[d],y=n[g]??n.default;return`
|
|
329
|
+
`}})}const SD=e=>P(e).get("year");function kD(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 TD(e,t,n){const s=n.reduce((S,T)=>{const z=_t(T,t);return S[T.name]=Re(T,z),S},{}),i=Ks(e.visualMap,s),{min:a,max:l}=i,c=bD(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=SD(S[u.columnKey]),E={value:[T,z,I]},{followVisualMap:N,color:R}=xo(z,a,l,e.visualMap);return N||(E.visualMap=!1,E.itemStyle={color:R}),E}),{dateSpan:h,minDate:f,dataByYear:x,years:y}=kD(p),j=h<=366;return{calendar:yD(j,f,y),series:_D(j,x,p),tooltip:CD(e,t,c),visualMap:{...i,orient:"horizontal",left:j?"center":5,dimension:1},legend:vD(j,y),grid:{containLabel:!0}}}function DD({name:e},t){const n=t.getOption();n.calendar.forEach(s=>{s.range=e}),t.setOption(n)}function MD({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=jn(t,e.calendar.data_key),c=nt(i.triggerManager,dh.id),u=g.useCallback(h=>{const[f,x]=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=g.useMemo(()=>({click:u,legendselectchanged:DD}),[u]),p=g.useMemo(()=>TD(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 zD({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,Ao),[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(MD,{variables:i,width:jt(c),height:wt(u),data:l,conf:a,interactionManager:n})})}const ID=[{label:"中文",value:"ZH"},{label:"English",value:"EN"}];function ED({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:ID,sx:{flex:1},...s})})]})}function AD({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 PD=({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})})]})})},OD=({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(PD,{control:e,index:l})})]})};function LD({control:e,watch:t}){return r.jsx(OD,{control:e,watch:t})}function BD({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>n?v.defaults({},n):Ao,[n]),a=g.useMemo(()=>v.cloneDeep(i),[i]);g.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;g.useEffect(()=>{h(a)},[a]);const f=p(),x=g.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:x}),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(ED,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Heat Block",children:r.jsx(AD,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Visual Map",children:r.jsx(yo,{form:l})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(LD,{control:c,watch:d})})]})]})})}class qD extends me{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:pD(n.config)})),this.version(4,n=>({...n,version:4,config:hD(n.config)}))}}const VD={displayName:"viz.calendar_heatmap.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new qD,name:"calendarHeatmap",viewRender:zD,configRender:BD,createConfig:()=>({version:4,config:Ao}),triggers:[dh],translation:fD},Po={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 ND(){const e=new Date().getTime().toString();return{id:e,min:"",max:"",name:e,data_key:"",position:"bottom",label_formatter:Me,show:!0}}function $D(){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:Ln,xAxisIndex:"0"}}function FD(){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 GD(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 WD(e){switch(e){case"bar":return"roundRect";case"scatter":return"circle"}}function RD(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:WD(s)})),t}function QD(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?gr(i.template,t,s):""},position:c}}}})}function ni(e,t,n){const s=vt(e,t),i=vt(e,n);return v.zip(i,s)}function UD(e,t,n,s){const i=ni(t,n,s);return v.unionBy(i,e,0)}function YD({dataTemplate:e,data:t,name_data_key:n,value_data_key:s,valueTypedXAxis:i}){return i?UD(e,t,n,s):ni(t,n,s)}function KD({dataTemplate:e,data:t,aggregation_on_value:n,name_data_key:s,value_data_key:i,valueTypedXAxis:a}){if(!n||n.type==="none")return YD({dataTemplate:e,data:t,name_data_key:s,value_data_key:i,valueTypedXAxis:a});const l=ni(t,s,i),c=v.groupBy(l,"0");return e.map(([d])=>{const h=c[d].map(x=>x[1]),f=Si(h,n);return[d,f]})}function XD({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]=ni({[i]:u},s,n)}),l}function JD({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},x,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=KD({dataTemplate:x,data:j,aggregation_on_value:l,name_data_key:e.data_key,value_data_key:t,valueTypedXAxis:y}),T;const z=XD({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 ZD(e,t,n,s,i,a,l){const c=t.map(d=>[d,0]);return e.series.map(d=>JD(e,d,c,n,s,l,i)).flat().concat(QD(e.reference_lines,a,l,s))}function HD(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 eM(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],x=n[f]??n.default;return`
|
|
330
330
|
<tr>
|
|
331
331
|
<td>${p}</td>
|
|
332
332
|
<th style="text-align: right; padding: 0 1em;">${d}</th>
|
|
333
|
-
<td style="text-align: left; padding: 0 1em;">${
|
|
333
|
+
<td style="text-align: left; padding: 0 1em;">${x({value:h})}</td>
|
|
334
334
|
</tr>
|
|
335
|
-
`}),c=
|
|
335
|
+
`}),c=ct(e.y_axis.axisLabel.overflow.in_tooltip),u=HD(a,e);return`
|
|
336
336
|
<div style="text-align: left; margin-bottom: .5em; padding: 0 1em .5em; font-weight: bold; border-bottom: 1px dashed #ddd;">
|
|
337
337
|
<div style="${c}">${u}</div>
|
|
338
338
|
</div>
|
|
@@ -341,7 +341,7 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
341
341
|
${l.join("")}
|
|
342
342
|
</tbody>
|
|
343
343
|
</table>
|
|
344
|
-
`}})}function j0(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 w0(t,e){const n={};return e.map(r=>{const i=Ze(r,t);n[r.name]=Ie(r,i)}),n}function C0(t,e){return t.x_axes.map(({min:n,max:r,...i},a)=>{let l=i.position;return l||(l=a>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[a]??e.default},nameLocation:"center",nameGap:15})})}function S0(t,e){const n=e.every(l=>!Number.isNaN(Number(l))),{overflow:r,...i}=t.y_axis.axisLabel,a=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,...a,formatter:Pe(i.formatter)},z:5})]}function k0(t,e,n){if(!t.y_axis.data_key)return{};const r=w0(e,n),i=j0(t),a=E(t.y_axis.data_key),l=b.uniq(e[a.queryID].map(p=>p[a.columnKey])),c=l.every(p=>!Number.isNaN(Number(p))),u=b0(t,l,c,e,i,n,r);return{xAxis:C0(t,i),yAxis:S0(t,l),series:u,tooltip:_0(t,u,i),grid:u0(t),legend:p0(u)}}function T0({conf:t,data:e,width:n,height:r,interactionManager:i,variables:a}){const l=Mt(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(y=>{i.runInteraction(y.id,{...h,rowData:g})})},[l,c,i]),d=m.useMemo(()=>({click:u}),[u]),p=m.useMemo(()=>k0(t,e,a),[t,e]);return s.jsx(Se,{echarts:Ce,option:p,style:{width:n,height:r},onEvents:d,notMerge:!0,theme:"merico-light"})}function D0({context:t,instance:e}){const n=Oe({vizManager:t.vizManager,instance:e}),{value:r}=q(t.instanceData,"config"),{variables:i}=t,a=m.useMemo(()=>b.defaults({},r,Lr),[r]),l=t.data,{width:c,height:u}=t.viewport;return!c||!u?null:s.jsx(Ae,{width:c,height:u,children:s.jsx(T0,{variables:i,width:He(c),height:et(u),data:l,conf:a,interactionManager:n})})}function z0({control:t,index:e,watch:n,variableOptions:r,xAxisOptions:i}){const{t:a}=_.useTranslation(),l=n(`reference_lines.${e}.orientation`);return s.jsxs(o.Stack,{my:0,p:0,pt:10,sx:{position:"relative"},children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`reference_lines.${e}.name`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:a("common.name"),placeholder:a("chart.reference_line.name_placeholder"),required:!0,sx:{flex:1},...c})}),s.jsx(f.Controller,{name:`reference_lines.${e}.variable_key`,control:t,render:({field:c})=>s.jsx(o.Select,{label:a("common.data_field"),required:!0,data:r,sx:{flex:1},...c})})]}),s.jsx(f.Controller,{name:`reference_lines.${e}.template`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:a("chart.content_template.label"),placeholder:a("chart.content_template.hint"),sx:{flex:1},...c})}),s.jsxs(o.Group,{grow:!0,children:[s.jsxs(o.Stack,{children:[s.jsx(f.Controller,{name:`reference_lines.${e}.orientation`,control:t,render:({field:c})=>s.jsx(wt,{sx:{flex:1},...c})}),l==="vertical"&&s.jsx(o.Text,{mt:-10,color:"dimmed",size:12,children:a("chart.reference_line.orientation.vertical_hint")})]}),l==="horizontal"&&s.jsx(f.Controller,{name:`reference_lines.${e}.xAxisIndex`,control:t,render:({field:c})=>s.jsx(o.Select,{label:a("chart.x_axis.label"),data:i,disabled:i.length===0,sx:{flex:1},...c})})]}),s.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.style.label"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:`reference_lines.${e}.lineStyle.type`,control:t,render:({field:c})=>s.jsx(Wt,{sx:{flexGrow:1},...c})}),s.jsx(f.Controller,{name:`reference_lines.${e}.lineStyle.width`,control:t,render:({field:c})=>s.jsx(o.NumberInput,{label:a("chart.series.line.line_width"),min:1,max:10,sx:{flexGrow:1},...c})})]}),s.jsxs(o.Stack,{spacing:4,children:[s.jsx(o.Text,{size:"sm",children:a("chart.color.label")}),s.jsx(f.Controller,{name:`reference_lines.${e}.lineStyle.color`,control:t,render:({field:c})=>s.jsx(Te,{...c})})]}),s.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:a("chart.behavior.label"),labelPosition:"center"}),s.jsx(f.Controller,{name:`reference_lines.${e}.show_in_legend`,control:t,render:({field:c})=>s.jsx(o.Checkbox,{label:a("chart.legend.show_in_legend"),checked:c.value,onChange:u=>c.onChange(u.currentTarget.checked)})})]})}function M0({control:t,watch:e,variables:n}){const{t:r}=_.useTranslation(),i=()=>c0(),a=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(z0,{control:t,index:p,watch:e,variableOptions:a,xAxisOptions:c})})}function I0({control:t,index:e,seriesItem:n}){const{t:r,i18n:i}=_.useTranslation(),a=!!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(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`series.${e}.stack`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:r("chart.series.bar.stack"),placeholder:r("chart.series.bar.stack_hint"),sx:{flexGrow:1},...c})}),s.jsx(f.Controller,{name:`series.${e}.barGap`,control:t,render:({field:c})=>s.jsx(o.Select,{label:r("chart.series.bar.bar_gap.label"),data:l,sx:{flexGrow:1},...c})})]}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`series.${e}.barMinWidth`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:r("chart.series.bar.bar_width.min"),disabled:a,sx:{flexGrow:1},...c})}),s.jsx(f.Controller,{name:`series.${e}.barWidth`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:r("chart.series.bar.bar_width.exact"),sx:{flexGrow:1},...c})}),s.jsx(f.Controller,{name:`series.${e}.barMaxWidth`,control:t,render:({field:c})=>s.jsx(o.TextInput,{label:r("chart.series.bar.bar_width.max"),disabled:a,sx:{flexGrow:1},...c})})]})]})}function E0({control:t,index:e,seriesItem:n,xAxisOptions:r}){const{t:i}=_.useTranslation();return s.jsxs(o.Stack,{my:0,p:0,sx:{position:"relative"},children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`series.${e}.name`,control:t,render:({field:a})=>s.jsx(o.TextInput,{label:i("common.name"),required:!0,sx:{flex:1},...a})}),s.jsx(f.Controller,{name:`series.${e}.xAxisIndex`,control:t,render:({field:a})=>s.jsx(o.Select,{label:i("chart.x_axis.label"),data:r,disabled:r.length===0,sx:{flex:1},...a})})]}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`series.${e}.data_key`,control:t,render:({field:a})=>s.jsx(O,{label:i("common.data_field"),required:!0,sx:{flex:1},...a})}),s.jsx(f.Controller,{name:`series.${e}.aggregation_on_value`,control:t,render:({field:a})=>s.jsx(br,{label:i("viz.horizontal_bar_chart.series.aggregation.label"),value:a.value??Nt,onChange:a.onChange,pt:0,withFallback:!1})})]}),s.jsx(o.Group,{grow:!0,children:s.jsx(f.Controller,{name:`series.${e}.group_by_key`,control:t,render:({field:a})=>s.jsx(O,{label:i("chart.series.group_by.label"),clearable:!0,sx:{flex:1},...a})})}),s.jsx(I0,{index:e,control:t,seriesItem:n}),s.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.style.label"),labelPosition:"center"}),s.jsx(f.Controller,{name:`series.${e}.label_position`,control:t,render:({field:a})=>s.jsx(Yt,{label:i("chart.label_position.label"),...a,withOffOption:!0,onChange:l=>{l&&a.onChange(l)}})}),s.jsxs(o.Stack,{spacing:4,children:[s.jsx(o.Text,{size:"sm",children:i("chart.color.label")}),s.jsx(f.Controller,{name:`series.${e}.color`,control:t,render:({field:a})=>s.jsx(Te,{...a})})]}),s.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:i("chart.behavior.label"),labelPosition:"center"}),s.jsx(f.Controller,{name:`series.${e}.hide_in_legend`,control:t,render:({field:a})=>s.jsx(o.Checkbox,{label:i("chart.legend.hide_in_legend"),checked:a.value,onChange:l=>a.onChange(l.currentTarget.checked)})}),s.jsx(f.Controller,{name:`series.${e}.invisible`,control:t,render:({field:a})=>s.jsx(o.Checkbox,{label:i("chart.behavior.invisible"),checked:a.value,onChange:l=>a.onChange(l.currentTarget.checked)})})]})}function A0({control:t,watch:e}){const{t:n}=_.useTranslation(),r=()=>l0(),i=(c,u)=>{const d=c.name.trim();return d||u+1},a=e("x_axes"),l=m.useMemo(()=>a.map(({name:c},u)=>({label:c,value:u.toString()})),[a]);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(E0,{control:t,index:u,seriesItem:c,xAxisOptions:l})})}const P0=m.forwardRef(({label:t,value:e,onChange:n,sx:r={}},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 s.jsx(o.Select,{ref:i,label:t??a("chart.x_axis.position.label"),data:c,value:e,onChange:n,sx:r})});function $0({control:t,index:e}){const{t:n}=_.useTranslation();return s.jsxs(o.Stack,{my:10,p:"0",sx:{position:"relative"},children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`x_axes.${e}.name`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(f.Controller,{name:`x_axes.${e}.position`,control:t,render:({field:r})=>s.jsx(P0,{sx:{flex:1},...r})})]}),s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.x_axis.label_format"),labelPosition:"center"}),s.jsx(f.Controller,{name:`x_axes.${e}.label_formatter`,control:t,render:({field:r})=>s.jsx(Re,{...r})})]}),s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.x_axis.value_range"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(f.Controller,{name:`x_axes.${e}.min`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("chart.x_axis.value_min"),...r})}),s.jsx(f.Controller,{name:`x_axes.${e}.max`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("chart.x_axis.value_max"),...r})})]})]}),s.jsx(o.Divider,{mb:-10,mt:10,variant:"dashed",label:n("chart.x_axis.behavior"),labelPosition:"center"}),s.jsx(f.Controller,{name:`x_axes.${e}.show`,control:t,render:({field:r})=>s.jsx(o.Checkbox,{label:n("chart.x_axis.visible"),checked:r.value,onChange:i=>r.onChange(i.currentTarget.checked)})})]})}function B0({control:t,watch:e}){const{t:n}=_.useTranslation(),r=()=>o0(),i=(a,l)=>{const c=a.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:a,index:l})=>s.jsx($0,{control:t,index:l})})}function L0({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["y_axis"]),s.jsxs(o.Stack,{children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"y_axis.name",control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...r})}),s.jsx(f.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(o.Divider,{mb:-15,label:n("chart.axis.tick_label"),variant:"dashed",labelPosition:"center"}),s.jsx(o.Group,{grow:!0,noWrap:!0,children:s.jsx(f.Controller,{name:"y_axis.axisLabel.formatter",control:t,render:({field:r})=>s.jsx(tt,{...r})})}),s.jsx(f.Controller,{name:"y_axis.axisLabel.overflow",control:t,render:({field:r})=>s.jsx(nt,{...r})})]})}function q0({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),{variables:i}=t,a=m.useMemo(()=>b.defaultsDeep({},n,Lr),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=f.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]),u([]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,a),[h,a]);return s.jsx(o.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:c(r),children:[s.jsx(ge,{canSubmit:g}),s.jsxs(o.Tabs,{defaultValue:"Series",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"X Axes",children:e("chart.x_axis.labels")}),s.jsx(o.Tabs.Tab,{value:"Y Axis",children:e("chart.y_axis.label")}),s.jsx(o.Tabs.Tab,{value:"Series",children:e("chart.series.label")}),s.jsx(o.Tabs.Tab,{value:"Reference Lines",children:e("chart.reference_line.labels")})]}),s.jsx(o.Tabs.Panel,{value:"X Axes",children:s.jsx(B0,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Y Axis",children:s.jsx(L0,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Series",children:s.jsx(A0,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Reference Lines",children:s.jsx(M0,{variables:i,control:l,watch:u})})]})]})})}const O0=[{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 V0(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:a,series:l,...c}=t;return{...c,x_axis:{...i,data_key:r(i.data_key)},y_axis:{...a,data_key:r(a.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 N0 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:V0(i,r)}})}}const G0={displayName:"viz.horizontal_bar_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new N0,name:"horizontalBarChart",viewRender:D0,configRender:q0,createConfig:()=>({version:2,config:Lr}),translation:O0},qr={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,formatter:ke()}},deviation:{name:"",data_keys:{estimated_value:"",actual_value:""}},metrics:[]};function F0(){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 _l=({value:t})=>{try{return U(t[2],{output:"percent",mantissa:0,absolute:!1})}catch(e){return console.error(e),t}};function W0(t,e,n){return{type:"heatmap",name:"准确估算比例",xAxisIndex:0,yAxisIndex:0,data:e.map(i=>{const a=n[i].length,u=(b.countBy(n[i],d=>d.level.diff===0).true??0)/a;return[i,"_y",u]}),label:{show:!0,formatter:_l},labelLayout:{hideOverlap:!0},visualMapIndex:0,tooltip:{trigger:"item",formatter:({color:i,value:a})=>`
|
|
344
|
+
`}})}function tM(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 nM(e,t){const n={};return t.map(s=>{const i=_t(s,e);n[s.name]=Re(s,i)}),n}function rM(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 sM(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 iM(e,t,n){if(!e.y_axis.data_key)return{};const s=nM(t,n),i=tM(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=ZD(e,l,c,t,i,n,s);return{xAxis:rM(e,i),yAxis:sM(e,l),series:u,tooltip:eM(e,u,i),grid:GD(e),legend:RD(u)}}function aM({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=jn(t,e.y_axis.data_key),c=nt(i.triggerManager,Qa.id),u=g.useCallback(h=>{const f=v.get(l,h.name,{error:"rowData is not found"});c.forEach(x=>{i.runInteraction(x.id,{...h,rowData:f})})},[l,c,i]),d=g.useMemo(()=>({click:u}),[u]),p=g.useMemo(()=>iM(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 oM({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,Po),[s]),l=e.data,{width:c,height:u}=e.viewport;return!c||!u?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(aM,{variables:i,width:jt(c),height:wt(u),data:l,conf:a,interactionManager:n})})}function lM({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(fn,{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(Jn,{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 cM({control:e,watch:t,variables:n}){const{t:s}=_.useTranslation(),i=()=>FD(),a=g.useMemo(()=>n.map(d=>({label:d.name,value:d.name})),[n]),l=t("x_axes"),c=g.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(lM,{control:e,index:p,watch:t,variableOptions:a,xAxisOptions:c})})}function uM({control:e,index:t,seriesItem:n}){const{t:s,i18n:i}=_.useTranslation(),a=!!n.barWidth.trim(),l=g.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(go,{label:i("viz.horizontal_bar_chart.series.aggregation.label"),value:a.value??Ln,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(uM,{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 pM({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>$D(),i=(c,u)=>{const d=c.name.trim();return d||u+1},a=t("x_axes"),l=g.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 hM=g.forwardRef(({label:e,value:t,onChange:n,sx:s={}},i)=>{const{t:a,i18n:l}=_.useTranslation(),c=g.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 fM({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(hM,{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 gM({control:e,watch:t}){const{t:n}=_.useTranslation(),s=()=>ND(),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(fM,{control:e,index:l})})}function mM({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(Ct,{...s})})}),r.jsx(b.Controller,{name:"y_axis.axisLabel.overflow",control:e,render:({field:s})=>r.jsx(St,{...s})})]})}function xM({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaultsDeep({},n,Po),[n]),{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=b.useForm({defaultValues:a});g.useEffect(()=>{p(a)},[a]),u([]);const h=d(),f=g.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(gM,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx(mM,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Series",children:r.jsx(pM,{control:l,watch:u})}),r.jsx(o.Tabs.Panel,{value:"Reference Lines",children:r.jsx(cM,{variables:i,control:l,watch:u})})]})]})})}const yM=[{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 bM(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 vM extends me{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:bM(i,s)}})}}const _M={displayName:"viz.horizontal_bar_chart.viz_name",displayGroup:"chart.groups.echarts_based_charts",migrator:new vM,name:"horizontalBarChart",viewRender:oM,configRender:xM,createConfig:()=>({version:2,config:Po}),translation:yM},Oo={x_axis:{name:"",data_key:"",axisLabel:{rotate:0,formatter:Oe()}},deviation:{name:"",data_keys:{estimated_value:"",actual_value:""}},metrics:[]};function jM(){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 ph=({value:e})=>{try{return U(e[2],{output:"percent",mantissa:0,absolute:!1})}catch(t){return console.error(t),e}};function wM(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:ph},labelLayout:{hideOverlap:!0},visualMapIndex:0,tooltip:{trigger:"item",formatter:({color:i,value:a})=>`
|
|
345
345
|
<table style="width: auto">
|
|
346
346
|
<thead>
|
|
347
347
|
<tr colspan="2">
|
|
@@ -359,45 +359,45 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
359
359
|
<tbody>
|
|
360
360
|
<tr>
|
|
361
361
|
<th style="text-align: right;">准确估算比例</th>
|
|
362
|
-
<td style="text-align: left; padding: 0 1em;">${
|
|
362
|
+
<td style="text-align: left; padding: 0 1em;">${ph({value:a})}</td>
|
|
363
363
|
</tr>
|
|
364
364
|
</tbody>
|
|
365
365
|
</table>
|
|
366
|
-
`},show_in_legend:!1}}function
|
|
366
|
+
`},show_in_legend:!1}}function hh(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 CM([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 SM(e,t,n,s){var u,d;const i=t.map(p=>{const h=n[p],f=v.sumBy(h,x=>x.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=bn.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:x}=CM(h);return`
|
|
367
367
|
<table style="width: auto">
|
|
368
368
|
<thead>
|
|
369
369
|
<tr colspan="2">
|
|
370
370
|
<div style="
|
|
371
371
|
width: 100%; height: 4px; border-radius: 2px; margin-bottom: 6px;
|
|
372
|
-
${
|
|
372
|
+
${hh(p)}
|
|
373
373
|
"/>
|
|
374
374
|
</tr>
|
|
375
375
|
<tr>
|
|
376
376
|
<th colspan="2" style="text-align: center;">
|
|
377
|
-
<div>${
|
|
377
|
+
<div>${f}</div>
|
|
378
378
|
</th>
|
|
379
379
|
</tr>
|
|
380
380
|
</thead>
|
|
381
381
|
<tbody>
|
|
382
382
|
<tr>
|
|
383
383
|
<th style="text-align: right;">平均偏差</th>
|
|
384
|
-
<td style="text-align: left; padding: 0 1em;">${
|
|
384
|
+
<td style="text-align: left; padding: 0 1em;">${x}</td>
|
|
385
385
|
</tr>
|
|
386
386
|
</tbody>
|
|
387
387
|
</table>
|
|
388
|
-
`}},show_in_legend:!1}}function
|
|
388
|
+
`}},show_in_legend:!1}}function kM([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 TM(e,t,n,s){const i={};t.forEach(p=>{const h=v.countBy(n[p],x=>x.level.diff),f=v.sum(Object.values(h));Object.entries(h).forEach(([x,y])=>{i[x]||(i[x]=[]);const j=y/f;i[x].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=bn.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,percentage:y,count:j,sum:k}=kM(f);return`
|
|
389
389
|
<table style="width: auto">
|
|
390
390
|
<thead>
|
|
391
391
|
<tr colspan="2">
|
|
392
392
|
<div style="
|
|
393
393
|
width: 100%; height: 4px; border-radius: 2px; margin-bottom: 6px;
|
|
394
|
-
${
|
|
394
|
+
${hh(h)}
|
|
395
395
|
"
|
|
396
396
|
/>
|
|
397
397
|
</tr>
|
|
398
398
|
<tr>
|
|
399
399
|
<th colspan="2" style="text-align: center;">
|
|
400
|
-
${
|
|
400
|
+
${x}
|
|
401
401
|
</th>
|
|
402
402
|
</tr>
|
|
403
403
|
</thead>
|
|
@@ -408,25 +408,25 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
408
408
|
</tr>
|
|
409
409
|
<tr>
|
|
410
410
|
<th style="text-align: right;">占比</th>
|
|
411
|
-
<td style="text-align: left; padding: 0 1em;">${
|
|
411
|
+
<td style="text-align: left; padding: 0 1em;">${y}</td>
|
|
412
412
|
</tr>
|
|
413
413
|
<tr>
|
|
414
414
|
<th style="text-align: right;">数量</th>
|
|
415
|
-
<td style="text-align: left; padding: 0 1em;">${
|
|
415
|
+
<td style="text-align: left; padding: 0 1em;">${j}</td>
|
|
416
416
|
</tr>
|
|
417
417
|
<tr>
|
|
418
418
|
<th style="text-align: right;">总数</th>
|
|
419
|
-
<td style="text-align: left; padding: 0 1em;">${
|
|
419
|
+
<td style="text-align: left; padding: 0 1em;">${k}</td>
|
|
420
420
|
</tr>
|
|
421
421
|
</tbody>
|
|
422
422
|
</table>
|
|
423
|
-
`}},show_in_legend:!0}))}function K0(t,e,n,r){const i=E(e.data_key),a=e.name,l=n.map(c=>{const u=b.sumBy(r[c],i.columnKey);return[c,u]});return{type:"line",name:a,xAxisIndex:3,yAxisIndex:3,color:"#b41529",data:l,show_in_legend:!1}}function J0(t,e,n,r){const l={barMinWidth:5,barMaxWidth:20};return[W0(t,n,r),R0(t,n,r,l),...Y0(t,n,r,l),K0(t,e,n,r)]}function X0(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 Z0(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 Or(t){return t==1||t==2?1:Or(t-2)+Or(t-1)}const H0=Array.from(new Array(20),(t,e)=>Or(e+1));function wl(t){return t<=1?t:H0.findIndex(e=>t<=e)-1}function eC(t,e){const{x_axis:n,deviation:r}=t,i=E(n.data_key),a=E(r.data_keys.estimated_value),l=E(r.data_keys.actual_value);return e[i.queryID].map(c=>{const u=wl(c[a.columnKey]),d=wl(c[l.columnKey]),p=u-d;return{...c,level:{estimated:u,actual:d,diff:p}}})}function tC(t){return t==="rgba(255, 255, 255, 1)"?{borderColor:"rgba(0,0,0,.1)",borderWidth:1}:{}}function nC(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:tC(n.color)})),tooltip:{show:!0,formatter:"档位偏差:{a}"}}}const sC={tooltip:{trigger:"axis"}};function rC(t,e){const{deviation:n,metrics:r}=t,i=r.find(l=>l.data_key===e);if(i)return i;const a=n.data_keys.actual_value;return{id:a,name:n.name,data_key:a}}function iC(t,e,n){const r=eC(t,n),i=E(t.x_axis.data_key),a=b.uniqBy(n[i.queryID],i.columnKey).map(p=>p[i.columnKey]),l=b.groupBy(r,i.columnKey),c=rC(t,e),u=J0(t,c,a,l),d={xAxis:X0(t,a),yAxis:Z0(c),series:u,grid:F0(),visualMap:[{min:0,max:1,calculable:!0,show:!1,seriesIndex:0,color:["#F0F0F0","#418AAF"]}],legend:nC(u)};return b.defaultsDeep({},d,sC)}const aC={input:{border:"none !important",paddingLeft:0,lineHeight:"1.55 !important"}},oC=({conf:t,metricKey:e,setMetricKey:n})=>{const{deviation:r,metrics:i}=t,a=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(o.Group,{spacing:1,children:[s.jsx(o.Text,{size:12,color:"dimmed",sx:{cursor:"default",userSelect:"none"},children:"基线指标"}),s.jsx(o.NativeSelect,{size:"xs",data:a,value:e,onChange:l=>n(l.currentTarget.value),styles:aC})]})},lC={"tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function cC(){return s.jsxs(o.HoverCard,{width:400,shadow:"md",children:[s.jsx(o.HoverCard.Target,{children:s.jsx(o.Button,{size:"xs",variant:"subtle",compact:!0,leftIcon:s.jsx(k.IconInfoCircle,{size:14}),children:"指标说明"})}),s.jsx(o.HoverCard.Dropdown,{children:s.jsx(o.Table,{fontSize:14,sx:lC,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 uC(t){return s.jsxs(o.Group,{position:"apart",children:[s.jsx(cC,{}),s.jsx(oC,{...t})]})}function dC({conf:t,data:e,width:n,height:r,metricKey:i}){const a=m.useMemo(()=>iC(t,i,e),[t,e,i]);return s.jsx(Se,{echarts:Ce,option:a,style:{width:n,height:r},notMerge:!0,theme:"merico-light"})}function pC({context:t}){const{value:e}=q(t.instanceData,"config"),n=m.useMemo(()=>b.defaults({},e,qr),[e]),r=t.data,{width:i,height:a}=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||!a)return null;const g=Math.max(He(i),300),y=Math.max(et(a),370);return s.jsxs(o.Box,{pt:Ee.top,pr:Ee.right,pb:Ee.bottom,pl:Ee.left,sx:{overflow:"hidden",height:a,width:i},children:[s.jsx(uC,{conf:n,metricKey:p,setMetricKey:h}),s.jsx(dC,{width:g,height:y-30,data:r,conf:n,metricKey:p})]})}function hC({control:t,watch:e}){return e(["deviation"]),s.jsxs(o.Stack,{children:[s.jsx(o.Group,{grow:!0,noWrap:!0,children:s.jsx(f.Controller,{name:"deviation.name",control:t,render:({field:n})=>s.jsx(o.TextInput,{label:"指标名称",sx:{flex:1},...n})})}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"deviation.data_keys.estimated_value",control:t,render:({field:n})=>s.jsx(O,{label:"估算值字段",required:!0,sx:{flex:1},...n})}),s.jsx(f.Controller,{name:"deviation.data_keys.actual_value",control:t,render:({field:n})=>s.jsx(O,{label:"实际值字段",required:!0,sx:{flex:1},...n})})]})]})}const mC=({control:t,index:e})=>{const{t:n}=_.useTranslation();return s.jsx(o.Stack,{children:s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(f.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})})]})})},xC=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(o.Text,{size:14,color:"#888",children:"设置可以展示在基线图的指标,例如代码当量"})]}),s.jsx(o.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:a,index:l})=>s.jsx(mC,{control:t,index:l})})]})};function gC({control:t,watch:e}){return e(["x_axis"]),s.jsxs(o.Stack,{children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"x_axis.data_key",control:t,render:({field:n})=>s.jsx(O,{label:"数据字段",required:!0,sx:{flex:1},...n})}),s.jsx(f.Controller,{name:"x_axis.name",control:t,render:({field:n})=>s.jsx(o.TextInput,{label:"X轴名称",sx:{flex:1},...n})})]}),s.jsx(o.Divider,{mb:-15,label:"点位文案",labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:n})=>s.jsx(xt,{sx:{width:"48%"},...n})}),s.jsx(f.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:n})=>s.jsx(tt,{...n})})]})]})}function fC({context:t}){const{value:e,set:n}=q(t.instanceData,"config"),r=m.useMemo(()=>b.defaultsDeep({},e,qr),[e]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=f.useForm({defaultValues:r});m.useEffect(()=>{u(r)},[r]),l([]);const d=c(),p=m.useMemo(()=>!b.isEqual(d,r),[d,r]);return s.jsx(o.Stack,{spacing:"xs",children:s.jsxs("form",{onSubmit:a(n),children:[s.jsx(ge,{canSubmit:p}),s.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"12px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"X Axis",children:"X轴"}),s.jsx(o.Tabs.Tab,{value:"Deviation",children:"偏差"}),s.jsx(o.Tabs.Tab,{value:"Additional Metrics",children:"指标"})]}),s.jsx(o.Tabs.Panel,{value:"X Axis",children:s.jsx(gC,{control:i,watch:l})}),s.jsx(o.Tabs.Panel,{value:"Deviation",children:s.jsx(hC,{control:i,watch:l})}),s.jsx(o.Tabs.Panel,{value:"Additional Metrics",children:s.jsx(xC,{control:i,watch:l})})]})]})})}const yC=[{lang:"en",resources:{merico_estimation_chart:{viz_name:"Merico Estimation Chart"}}},{lang:"zh",resources:{merico_estimation_chart:{viz_name:"思码逸估算分析图"}}}];function bC(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:a,metrics:l,...c}=t;return{...c,x_axis:{...i,data_key:r(i.data_key)},deviation:{...a,data_keys:{estimated_value:r(a.data_keys.estimated_value),actual_value:r(a.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 vC 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:bC(i,r)}})}}const _C={displayName:"viz.merico_estimation_chart.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new vC,name:"mericoEstimationChart",viewRender:pC,configRender:fC,createConfig:()=>({version:2,config:qr}),translation:yC},Vr={styles:{justify:"space-around",align:"start"},metrics:[]};function jC(){return{id:new Date().getTime().toString(),names:{value:"Value",basis:"Basis"},data_keys:{value:"",basis:""},formatter:_e,postfix:{type:"text",value:""}}}const Cl=({postfix:t})=>t?s.jsxs(s.Fragment,{children:[s.jsx(o.Text,{size:"12px",color:"#818388",sx:{lineHeight:1},children:"/"}),s.jsx(o.Text,{size:"12px",color:"#818388",sx:{lineHeight:1},children:t})]}):null,wC=S.observer(({metric:t,variableValueMap:e})=>{const{names:n,data_keys:r,formatter:i,postfix:a}=t,l=he(),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 s.jsxs(o.Stack,{spacing:18,children:[s.jsxs(o.Stack,{spacing:12,children:[s.jsx(o.Text,{size:"14px",color:"#818388",children:n.value}),s.jsxs(o.Group,{spacing:"2px",align:"baseline",children:[s.jsx(o.Text,{size:"24px",fw:"bold",color:"#3D3E45",sx:{lineHeight:1},children:U(e[r.value],i)}),s.jsx(Cl,{postfix:c})]})]}),s.jsxs(o.Stack,{spacing:12,children:[s.jsx(o.Text,{size:"14px",color:"#818388",children:n.basis}),s.jsxs(o.Group,{spacing:"2px",align:"baseline",children:[s.jsx(o.Text,{size:"12px",color:"#3D3E45",sx:{lineHeight:1},children:U(e[r.basis],i)}),s.jsx(Cl,{postfix:c})]})]})]})}),CC=S.observer(({context:t,instance:e})=>{const{value:n}=q(t.instanceData,"config"),{variables:r}=t,i=m.useMemo(()=>b.defaults({},n,Vr),[n]),a=t.data,l=m.useMemo(()=>er(a,r),[r,a]),{width:c,height:u}=t.viewport;return!c||!u||!i?null:s.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=>s.jsx(wC,{metric:d,variableValueMap:l},d.id))})}),SC=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(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(o.Select,{label:r("viz.merico_stats.metric.postfix_type.label"),data:d,value:t.type,onChange:c}),t.type==="text"&&s.jsx(o.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(o.Select,{label:r("viz.merico_stats.metric.postfix_filter"),value:t.value,onChange:u,data:l})]})}));function kC({control:t,index:e,watch:n,variableOptions:r}){const{t:i}=_.useTranslation();return n(`metrics.${e}.postfix`),s.jsxs(o.Stack,{my:0,p:"md",pr:40,sx:{border:"1px solid #eee",position:"relative"},children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`metrics.${e}.names.value`,control:t,render:({field:a})=>s.jsx(o.TextInput,{label:i("viz.merico_stats.metric.metric_name"),required:!0,sx:{flex:1},...a})}),s.jsx(f.Controller,{name:`metrics.${e}.data_keys.value`,control:t,render:({field:a})=>s.jsx(o.Select,{label:i("viz.merico_stats.metric.metric_data_field"),required:!0,data:r,sx:{flex:1},...a})})]}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`metrics.${e}.names.basis`,control:t,render:({field:a})=>s.jsx(o.TextInput,{label:i("viz.merico_stats.metric.basis_name"),required:!0,sx:{flex:1},...a})}),s.jsx(f.Controller,{name:`metrics.${e}.data_keys.basis`,control:t,render:({field:a})=>s.jsx(o.Select,{label:i("viz.merico_stats.metric.basis_data_field"),required:!0,data:r,sx:{flex:1},...a})})]}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:i("numbro.format.label"),labelPosition:"center"}),s.jsx(f.Controller,{name:`metrics.${e}.formatter`,control:t,render:({field:a})=>s.jsx(Re,{...a})}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:i("viz.merico_stats.metric.others"),labelPosition:"center"}),s.jsx(f.Controller,{name:`metrics.${e}.postfix`,control:t,render:({field:a})=>s.jsx(SC,{...a})})]})}const TC=({control:t,watch:e,variables:n})=>{const{t:r}=_.useTranslation(),i=()=>jC(),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 s.jsxs(s.Fragment,{children:[s.jsx(o.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:a,deleteDisalbed:l,children:({field:u,index:d})=>s.jsx(kC,{control:t,index:d,variableOptions:c,watch:e})})]})};function DC({control:t,watch:e}){const{t:n}=_.useTranslation();return e("styles"),s.jsxs(s.Fragment,{children:[s.jsx(o.Divider,{mt:15,variant:"dashed",label:n("style.label"),labelPosition:"center"}),s.jsxs(o.Group,{children:[s.jsx(f.Controller,{name:"styles.justify",control:t,render:({field:r})=>s.jsx(em,{sx:{flex:1},...r})}),s.jsx(f.Controller,{name:"styles.align",control:t,render:({field:r})=>s.jsx(tm,{label:n("viz.merico_stats.align_items.label"),sx:{flex:1},...r})})]})]})}function zC({context:t}){const{value:e,set:n}=q(t.instanceData,"config"),{variables:r}=t,i=m.useMemo(()=>b.defaultsDeep({},e,Vr),[e]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d}=f.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(o.Stack,{spacing:"xs",children:[s.jsx(ge,{canSubmit:h}),s.jsx(DC,{control:a,watch:c}),s.jsx(TC,{control:a,watch:c,variables:r})]})})}function MC(t){const{metrics:e,...n}=t;return{...n,metrics:e.map(r=>({...r,postfix:r.postfix??{type:"text",value:""}}))}}const IC=[{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 EC 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:MC(n.config)}))}}const AC={displayName:"viz.merico_stats.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new EC,name:"merico-stats",viewRender:CC,configRender:zC,createConfig:()=>({version:2,config:Vr}),translation:IC},Nr={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:{min:{type:"static",value:0},max:{type:"static",value:100},name:"Value",data_key:"",value_formatter:_e,label:{show:!1,fontSize:10}},tooltip:{metrics:[]}};function PC({control:t,watch:e}){const{t:n}=_.useTranslation();e(["heat_block"]);const r=e("heat_block.label.show");return s.jsxs(o.Stack,{children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.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(f.Controller,{name:"heat_block.name",control:t,render:({field:i})=>s.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...i})})]}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"heat_block.min",control:t,render:({field:i})=>s.jsx(Kt,{label:n("chart.heatmap.heatblock.min_value"),...i})}),s.jsx(f.Controller,{name:"heat_block.max",control:t,render:({field:i})=>s.jsx(Kt,{label:n("chart.heatmap.heatblock.max_value"),...i})})]}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("numbro.format.label"),labelPosition:"center"}),s.jsx(f.Controller,{name:"heat_block.value_formatter",control:t,render:({field:i})=>s.jsx(Re,{...i})}),s.jsx(o.Divider,{mb:-5,variant:"dashed",label:n("chart.label.label"),labelPosition:"center"}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"heat_block.label.show",control:t,render:({field:i})=>s.jsx(o.Switch,{label:n("chart.heatmap.heatblock.show_label"),checked:i.value,onChange:a=>i.onChange(a.currentTarget.checked),sx:{flexGrow:1}})}),s.jsx(f.Controller,{name:"heat_block.label.fontSize",control:t,render:({field:i})=>s.jsx(o.NumberInput,{size:"xs",icon:s.jsx(k.IconTextSize,{size:16}),disabled:!r,...i})})]})]})}const $C=({control:t,index:e})=>{const{t:n}=_.useTranslation();return s.jsx(o.Stack,{children:s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:`tooltip.metrics.${e}.name`,control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})}),s.jsx(f.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})})]})})},BC=({control:t,watch:e})=>{const{t:n}=_.useTranslation(),r=()=>({id:Date.now().toString(),data_key:"",name:""}),i=(a,l)=>{const c=a.name.trim();return c||l+1};return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[s.jsx(L.InfoCircle,{size:14,color:"#888"}),s.jsx(o.Text,{size:14,color:"#888",children:n("chart.tooltip.additional_metrics.description")})]}),s.jsx(o.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:a,index:l})=>s.jsx($C,{control:t,index:l})})]})};function LC({control:t,watch:e}){return s.jsx(BC,{control:t,watch:e})}function qC({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["x_axis"]),s.jsxs(o.Stack,{children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.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(f.Controller,{name:"x_axis.name",control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),sx:{flex:1},...r})})]}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsx(f.Controller,{name:"x_axis.axisLabel.overflow",control:t,render:({field:r})=>s.jsx(nt,{...r})}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:r})=>s.jsx(xt,{sx:{width:"48%"},...r})}),s.jsx(f.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:r})=>s.jsx(tt,{...r})})]})]})}function OC({control:t,watch:e}){const{t:n}=_.useTranslation();return e(["y_axis"]),s.jsxs(o.Stack,{my:0,p:"0",sx:{position:"relative"},children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.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(f.Controller,{name:"y_axis.name",control:t,render:({field:r})=>s.jsx(o.TextInput,{label:n("common.name"),required:!0,sx:{flex:1},...r})})]}),s.jsx(o.Group,{grow:!0,noWrap:!0,children:s.jsx(f.Controller,{name:"y_axis.nameAlignment",control:t,render:({field:r})=>s.jsx(kt,{sx:{flex:1},...r})})}),s.jsx(o.Divider,{mb:-15,variant:"dashed",label:n("chart.axis.tick_label"),labelPosition:"center"}),s.jsx(f.Controller,{name:"y_axis.axisLabel.overflow",control:t,render:({field:r})=>s.jsx(nt,{...r})}),s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(f.Controller,{name:"y_axis.axisLabel.rotate",control:t,render:({field:r})=>s.jsx(xt,{sx:{width:"48%"},...r})}),s.jsx(f.Controller,{name:"y_axis.axisLabel.formatter",control:t,render:({field:r})=>s.jsx(tt,{...r})})]})]})}function VC({context:t}){const{t:e}=_.useTranslation(),{value:n,set:r}=q(t.instanceData,"config"),i=m.useMemo(()=>b.defaultsDeep({},n,Nr),[n]),a=m.useMemo(()=>b.cloneDeep(i),[i]);m.useEffect(()=>{!b.isEqual(i,a)&&(console.log("config malformed, resetting to defaults",i,a),r(a))},[i,a]);const{control:l,handleSubmit:c,watch:u,getValues:d,reset:p}=f.useForm({defaultValues:a});m.useEffect(()=>{p(a)},[a]);const h=d(),g=m.useMemo(()=>!b.isEqual(h,i),[h,i]);return s.jsx("form",{onSubmit:c(r),style:{flexGrow:1},children:s.jsxs(o.Stack,{spacing:"xs",sx:{height:"100%"},children:[s.jsx(ge,{canSubmit:g}),s.jsxs(o.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{root:{flexGrow:1},tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"X Axis",children:e("chart.x_axis.label")}),s.jsx(o.Tabs.Tab,{value:"Y Axis",children:e("chart.y_axis.label")}),s.jsx(o.Tabs.Tab,{value:"Heat Block",children:e("chart.heatmap.heatblock.label")}),s.jsx(o.Tabs.Tab,{value:"Tooltip",children:e("chart.tooltip.label")})]}),s.jsx(o.Tabs.Panel,{value:"X Axis",children:s.jsx(qC,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Y Axis",children:s.jsx(OC,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Heat Block",children:s.jsx(PC,{control:l,watch:u})}),s.jsx(o.Tabs.Panel,{value:"Tooltip",children:s.jsx(LC,{control:l,watch:u})})]})]})})}function NC(t){return s.jsx(s.Fragment,{})}function GC(t){const{t:e}=_.useTranslation();return s.jsx(o.Text,{children:e("viz.merico_heatmap.click_heatmap.heatblock.label")})}const Sl={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.merico_heatmap.click_heatmap.heatblock.label",nameRender:GC,configRender:NC,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 FC(t){const e=Pe(t.x_axis.axisLabel.formatter),n=Pe(t.y_axis.axisLabel.formatter);return{x_axis:e,y_axis:n}}function WC(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 QC(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 RC(t,e){const{x_axis:n,y_axis:r,heat_block:i}=t,a=E(n.data_key),l=E(r.data_key),c=E(i.data_key),u=e[a.queryID].map(d=>[b.get(d,a.columnKey),b.get(d,l.columnKey),b.get(d,c.columnKey)]);return{type:"heatmap",name:i.name,xAxisId:"main-x-axis",yAxisIndex:0,datasetIndex:0,itemStyle:{borderWidth:0},data:u,label:i.label,labelLayout:{hideOverlap:!0},z:2}}const UC=t=>U(t,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function YC({conf:t,labelFormatters:e,valueFormatters:n,dataDict:r,params:i}){const{value:a,dataIndex:l}=i,[c,u,d]=a,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:""}},y=[p,h,g],v=r[`${c}---${u}`];return v&&t.tooltip.metrics.forEach(w=>{const T=E(w.data_key);y.push({label:w.name,value:UC(b.get(v,T.columnKey,"")),style:{label:"",value:""}})}),y}function KC(t,e,n,r){const{x_axis:i,y_axis:a,heat_block:l}=t,c=E(i.data_key),u=E(a.data_key);E(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=YC({conf:t,labelFormatters:n,valueFormatters:r,dataDict:d,params:p}).map(v=>`
|
|
423
|
+
`}},show_in_legend:!0}))}function DM(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 MM(e,t,n,s){const l={barMinWidth:5,barMaxWidth:20};return[wM(e,n,s),SM(e,n,s,l),...TM(e,n,s,l),DM(e,t,n,s)]}function zM(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 IM(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 Lo(e){return e==1||e==2?1:Lo(e-2)+Lo(e-1)}const EM=Array.from(new Array(20),(e,t)=>Lo(t+1));function fh(e){return e<=1?e:EM.findIndex(t=>e<=t)-1}function AM(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=fh(c[a.columnKey]),d=fh(c[l.columnKey]),p=u-d;return{...c,level:{estimated:u,actual:d,diff:p}}})}function PM(e){return e==="rgba(255, 255, 255, 1)"?{borderColor:"rgba(0,0,0,.1)",borderWidth:1}:{}}function OM(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:PM(n.color)})),tooltip:{show:!0,formatter:"档位偏差:{a}"}}}const LM={tooltip:{trigger:"axis"}};function BM(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 qM(e,t,n){const s=AM(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=BM(e,t),u=MM(e,c,a,l),d={xAxis:zM(e,a),yAxis:IM(c),series:u,grid:jM(),visualMap:[{min:0,max:1,calculable:!0,show:!1,seriesIndex:0,color:["#F0F0F0","#418AAF"]}],legend:OM(u)};return v.defaultsDeep({},d,LM)}const VM={input:{border:"none !important",paddingLeft:0,lineHeight:"1.55 !important"}},NM=({conf:e,metricKey:t,setMetricKey:n})=>{const{deviation:s,metrics:i}=e,a=g.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:VM})]})},$M={"tbody th, tbody td":{padding:"7px 10px"},"tbody tr:not(:first-of-type) th":{borderTop:"1px solid #dee2e6"}};function FM(){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:$M,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 GM(e){return r.jsxs(o.Group,{position:"apart",children:[r.jsx(FM,{}),r.jsx(NM,{...e})]})}function WM({conf:e,data:t,width:n,height:s,metricKey:i}){const a=g.useMemo(()=>qM(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 RM({context:e}){const{value:t}=$(e.instanceData,"config"),n=g.useMemo(()=>v.defaults({},t,Oo),[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]=g.useState(d);if(g.useEffect(()=>{h(y=>y||d)},[d]),!l.data_key||!u||!d||!i||!a)return null;const f=Math.max(jt(i),300),x=Math.max(wt(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(GM,{conf:n,metricKey:p,setMetricKey:h}),r.jsx(WM,{width:f,height:x-30,data:s,conf:n,metricKey:p})]})}function QM({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 UM=({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})})]})})},YM=({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(UM,{control:e,index:l})})]})};function KM({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(Kt,{sx:{width:"48%"},...n})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:n})=>r.jsx(Ct,{...n})})]})]})}function XM({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),s=g.useMemo(()=>v.defaultsDeep({},t,Oo),[t]),{control:i,handleSubmit:a,watch:l,getValues:c,reset:u}=b.useForm({defaultValues:s});g.useEffect(()=>{u(s)},[s]),l([]);const d=c(),p=g.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(KM,{control:i,watch:l})}),r.jsx(o.Tabs.Panel,{value:"Deviation",children:r.jsx(QM,{control:i,watch:l})}),r.jsx(o.Tabs.Panel,{value:"Additional Metrics",children:r.jsx(YM,{control:i,watch:l})})]})]})})}const JM=[{lang:"en",resources:{merico_estimation_chart:{viz_name:"Merico Estimation Chart"}}},{lang:"zh",resources:{merico_estimation_chart:{viz_name:"思码逸估算分析图"}}}];function ZM(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 HM extends me{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:ZM(i,s)}})}}const ez={displayName:"viz.merico_estimation_chart.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new HM,name:"mericoEstimationChart",viewRender:RM,configRender:XM,createConfig:()=>({version:2,config:Oo}),translation:JM},Bo={styles:{justify:"space-around",align:"start"},metrics:[]};function tz(){return{id:new Date().getTime().toString(),names:{value:"Value",basis:"Basis"},data_keys:{value:"",basis:""},formatter:Me,postfix:{type:"text",value:""}}}const gh=({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,nz=D.observer(({metric:e,variableValueMap:t})=>{const{names:n,data_keys:s,formatter:i,postfix:a}=e,l=_e(),c=g.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(gh,{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(gh,{postfix:c})]})]})]})}),rz=D.observer(({context:e,instance:t})=>{const{value:n}=$(e.instanceData,"config"),{variables:s}=e,i=g.useMemo(()=>v.defaults({},n,Bo),[n]),a=e.data,l=g.useMemo(()=>Ka(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(nz,{metric:d,variableValueMap:l},d.id))})}),sz=D.observer(g.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=g.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 iz({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(sz,{...a})})]})}const az=({control:e,watch:t,variables:n})=>{const{t:s}=_.useTranslation(),i=()=>tz(),a=(u,d)=>{const p=u.names.value.trim();return p||d+1},l=({field:u,index:d,fields:p})=>p.length<=1,c=g.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(iz,{control:e,index:d,variableOptions:c,watch:t})})]})};function oz({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(Vy,{sx:{flex:1},...s})}),r.jsx(b.Controller,{name:"styles.align",control:e,render:({field:s})=>r.jsx(Ny,{label:n("viz.merico_stats.align_items.label"),sx:{flex:1},...s})})]})]})}function lz({context:e}){const{value:t,set:n}=$(e.instanceData,"config"),{variables:s}=e,i=g.useMemo(()=>v.defaultsDeep({},t,Bo),[t]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d}=b.useForm({defaultValues:i});g.useEffect(()=>{d(i)},[i]);const p=u(),h=g.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(oz,{control:a,watch:c}),r.jsx(az,{control:a,watch:c,variables:s})]})})}function cz(e){const{metrics:t,...n}=e;return{...n,metrics:t.map(s=>({...s,postfix:s.postfix??{type:"text",value:""}}))}}const uz=[{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 me{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:cz(n.config)}))}}const pz={displayName:"viz.merico_stats.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new dz,name:"merico-stats",viewRender:rz,configRender:lz,createConfig:()=>({version:2,config:Bo}),translation:uz},qo={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:Jt()};function hz({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 fz=({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})})]})})},gz=({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(fz,{control:e,index:l})})]})};function mz({control:e,watch:t}){return r.jsx(gz,{control:e,watch:t})}function xz({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(St,{...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(Kt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"x_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(Ct,{...s})})]})]})}function yz({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(xn,{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(St,{...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(Kt,{sx:{width:"48%"},...s})}),r.jsx(b.Controller,{name:"y_axis.axisLabel.formatter",control:e,render:({field:s})=>r.jsx(Ct,{...s})})]})]})}function bz({context:e}){const{t}=_.useTranslation(),{value:n,set:s}=$(e.instanceData,"config"),i=g.useMemo(()=>n?v.defaults({},n):qo,[n]),a=g.useMemo(()=>v.cloneDeep(i),[i]);g.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;g.useEffect(()=>{h(a)},[a]);const f=p(),x=g.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:x}),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(xz,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Y Axis",children:r.jsx(yz,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Heat Block",children:r.jsx(hz,{control:c,watch:d})}),r.jsx(o.Tabs.Panel,{value:"Visual Map",children:r.jsx(yo,{form:l})}),r.jsx(o.Tabs.Panel,{value:"Tooltip",children:r.jsx(mz,{control:c,watch:d})})]})]})})}function vz(e){return r.jsx(r.Fragment,{})}function _z(e){const{t}=_.useTranslation();return r.jsx(o.Text,{children:t("viz.merico_heatmap.click_heatmap.heatblock.label")})}const mh={id:"builtin:echarts:click-heatmap:heat-block",displayName:"viz.merico_heatmap.click_heatmap.heatblock.label",nameRender:_z,configRender:vz,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 jz(e){const t=Ye(e.x_axis.axisLabel.formatter),n=Ye(e.y_axis.axisLabel.formatter);return{x_axis:t,y_axis:n}}function wz(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 Cz(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 Sz(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 kz=e=>U(e,{output:"number",trimMantissa:!0,mantissa:2,absolute:!1});function Tz({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:""}},x=[p,h,f],y=s[`${c}---${u}`];return y&&e.tooltip.metrics.forEach(j=>{const k=O(j.data_key);x.push({label:j.name,value:kz(v.get(y,k.columnKey,"")),style:{label:"",value:""}})}),x}function Dz(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=Tz({conf:e,labelFormatters:n,valueFormatters:s,dataDict:d,params:p}).map(y=>`
|
|
424
424
|
<tr>
|
|
425
425
|
<th style="text-align: right;">
|
|
426
|
-
<div style="${
|
|
426
|
+
<div style="${y.style.label}">${y.label}</div>
|
|
427
427
|
</th>
|
|
428
428
|
<td style="text-align: right; padding: 0 1em;">
|
|
429
|
-
<div style="${
|
|
429
|
+
<div style="${y.style.value}">${y.value}
|
|
430
430
|
</td>
|
|
431
431
|
</tr>
|
|
432
432
|
`);return`
|
|
@@ -439,21 +439,21 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
439
439
|
/>
|
|
440
440
|
</tr>
|
|
441
441
|
</thead>
|
|
442
|
-
<tbody>${
|
|
442
|
+
<tbody>${f.join("")}</tbody>
|
|
443
443
|
</table>
|
|
444
|
-
`}})}function JC(t,e){const n=Jt(t.heat_block.min,e),r=Jt(t.heat_block.max,e);return{min:n,max:r,calculable:!0,orient:"horizontal",left:"center",top:0,itemWidth:15}}function XC(t,e,n){const r=E(t.x_axis.data_key),i=b.uniq(e[r.queryID].map(u=>u[r.columnKey])),{overflow:a,rotate:l}=t.x_axis.axisLabel,c=Qe(a.on_axis);return te.getXAxis({id:"main-x-axis",type:"category",data:i,name:t.x_axis.name??"",align:"center",axisTick:{show:!0,alignWithLabel:!0},axisLabel:{rotate:l,...c,formatter:n},splitArea:{show:!1,areaStyle:{color:"#E7E7E9"}},splitLine:{show:!1},nameLocation:"center",nameGap:25,nameTextStyle:{fontWeight:"bold",align:"center"},z:3})}function ZC(t,e,n){const r=E(t.x_axis.data_key),i=E(t.y_axis.data_key),{nameAlignment:a,data_key:l,...c}=t.y_axis,u=b.uniq(e[r.queryID].map(g=>g[i.columnKey])),{overflow:d,rotate:p}=t.y_axis.axisLabel,h=Qe(d.on_axis);return te.getYAxis({...c,type:"category",data:u,axisLabel:{rotate:p,...h,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:a},nameLocation:"end",nameGap:15,z:3})}function HC(t,e,n){if(!t.x_axis.data_key||!t.y_axis.data_key||!t.heat_block.data_key)return{};const r=n.reduce((c,u)=>{const d=Ze(u,e);return c[u.name]=Ie(u,d),c},{}),i=FC(t),a=WC(t);return{xAxis:XC(t,e,i.x_axis),yAxis:ZC(t,e,i.y_axis),series:RC(t,e),tooltip:KC(t,e,i,a),grid:QC(t),visualMap:JC(t,r)}}function eS({conf:t,data:e,width:n,height:r,interactionManager:i,variables:a}){const l=m.useMemo(()=>{const h=E(t.x_axis.data_key),g=E(t.y_axis.data_key);return b.keyBy(e[h.queryID],y=>`${y[h.columnKey]}---${y[g.columnKey]}`)},[e,t.x_axis.data_key,t.y_axis.data_key]),c=qe(i.triggerManager,Sl.id),u=m.useCallback(h=>{const[g,y]=h.value,v=b.get(l,`${g}---${y}`,{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(()=>HC(t,e,a),[t,e]);return s.jsx(Se,{echarts:Ce,option:p,style:{width:n,height:r},onEvents:d,notMerge:!0,theme:"merico-light"})}function tS({context:t,instance:e}){const n=Oe({vizManager:t.vizManager,instance:e}),{value:r}=q(t.instanceData,"config"),{variables:i}=t,a=m.useMemo(()=>b.defaults({},r,Nr),[r]),l=t.data,{width:c,height:u}=t.viewport;return!c||!u?null:s.jsx(Ae,{width:c,height:u,children:s.jsx(eS,{variables:i,width:He(c),height:et(u),data:l,conf:a,interactionManager:n})})}const nS=[{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:"点击热力块"}}}}}];class sS extends ce{constructor(){super(...arguments);$(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const rS={displayName:"viz.merico_heatmap.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new sS,name:"merico-heatmap",viewRender:tS,configRender:VC,createConfig:()=>({version:1,config:Nr}),triggers:[Sl],translation:nS},iS=[{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"})),aS=[op,lp,dp,up,cp,pp],kl=[Er,ij,_w,Yv,kj,qb,G0,kp,Sm,Xf,Wy,a0,kb,Ef,R_,uv,qv,Mw,_C,rS,AC,Bm],Tl=()=>({id:"dashboard",version:Ta,manifest:{viz:kl,color:[...iS,...aS]}}),bn=new gp,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")}},Gr=()=>{try{bn.install(Tl())}catch{}const t=new rp(bn),e=new xp(bn);return{pluginManager:bn,vizManager:t,colorManager:e}},ut=m.createContext(Gr());try{bn.install(Tl())}catch{}const Fr=m.createContext(null);function os(t){const e=m.useContext(Fr),n=G.useCreation(()=>t.configure(e||new As),[t.configure]),r=G.usePrevious(n);return r&&r!==n&&r.dispose(),s.jsx(Fr.Provider,{value:n,children:t.children})}function Dl(){return m.useContext(Fr)}const oS=({description:t,isDescriptionEmpty:e})=>e?null:s.jsx(o.Tooltip,{color:"white",label:s.jsx(Zn,{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(o.Box,{sx:{height:"16px",alignSelf:"center"},children:s.jsx(k.IconInfoCircle,{size:16,color:"gray"})})}),lS=S.observer(({label:t,config:{default_value:e,description:n,isDescriptionEmpty:r,...i},value:a,onChange:l})=>s.jsxs(o.Box,{children:[s.jsx(o.Text,{children:" "}),s.jsx(o.Checkbox,{label:s.jsxs(o.Group,{noWrap:!0,position:"apart",align:"middle",spacing:6,children:[s.jsx(o.Box,{sx:{flexGrow:1},children:t}),s.jsx(oS,{description:n,isDescriptionEmpty:r})]}),checked:a||!1,onChange:c=>l(c.currentTarget.checked),...i,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),cS=({value:t,onChange:e,close:n,max_days:r,allowSingleDateInRange:i})=>{const{i18n:a}=_.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 M(l).add(r-1,"days").toDate()},[l,c,r]),h=g=>{const[y,v]=g;e(g),y&&v&&n()};return s.jsx(Ui.DatePicker,{defaultDate:u,numberOfColumns:2,type:"range",value:t,onChange:h,onNextMonth:console.log,minDate:d,maxDate:p,allowSingleDateInRange:i,locale:a.language})},uS=({begin:t,end:e})=>{const{t:n}=_.useTranslation(),r=m.useMemo(()=>M(e).diff(M(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(o.Tooltip,{label:i,children:s.jsx(o.Badge,{size:"sm",children:r})})},dS=({max_days:t})=>{const{t:e}=_.useTranslation();return t?s.jsxs(s.Fragment,{children:[s.jsx(o.Group,{position:"right",children:s.jsx(o.Badge,{size:"xs",children:e("filter.widget.date_range.x_max_days",{max_days:t})})}),s.jsx(o.Divider,{variant:"dashed",my:10})]}):null},Wr=()=>[{key:"d",value:"yesterday",group:"last",getRange:()=>{const t=Date.now();return[M(t).subtract(1,"day").startOf("day").toDate(),M(t).subtract(1,"day").endOf("day").toDate()]}},{key:"w",value:"last week",group:"last",getRange:()=>{const t=Date.now();return[M(t).subtract(1,"week").startOf("week").toDate(),M(t).subtract(1,"week").endOf("week").toDate()]}},{key:"m",value:"last month",group:"last",getRange:()=>{const t=Date.now();return[M(t).subtract(1,"month").startOf("month").toDate(),M(t).subtract(1,"month").endOf("month").toDate()]}},{key:"m2",value:"last 2 months",group:"last",getRange:()=>{const t=Date.now();return[M(t).subtract(2,"month").startOf("month").toDate(),M(t).subtract(1,"month").endOf("month").toDate()]}},{key:"m3",value:"last 3 months",group:"last",getRange:()=>{const t=Date.now();return[M(t).subtract(3,"month").startOf("month").toDate(),M(t).subtract(1,"month").endOf("month").toDate()]}},{key:"y",value:"last year",group:"last",getRange:()=>{const t=Date.now();return[M(t).subtract(1,"year").startOf("year").toDate(),M(t).subtract(1,"year").endOf("year").toDate()]}},{key:"d7",value:"recent 7 days",group:"recent",getRange:()=>{const t=Date.now();return[M(t).subtract(7,"day").startOf("day").toDate(),M(t).subtract(1,"day").endOf("day").toDate()]}},{key:"d30",value:"recent 30 days",group:"recent",getRange:()=>{const t=Date.now();return[M(t).subtract(30,"day").startOf("day").toDate(),M(t).subtract(1,"day").endOf("day").toDate()]}},{key:"d60",value:"recent 60 days",group:"recent",getRange:()=>{const t=Date.now();return[M(t).subtract(60,"day").startOf("day").toDate(),M(t).subtract(1,"day").endOf("day").toDate()]}},{key:"d90",value:"recent 90 days",group:"recent",getRange:()=>{const t=Date.now();return[M(t).subtract(90,"day").startOf("day").toDate(),M(t).subtract(1,"day").endOf("day").toDate()]}},{key:"d180",value:"recent 180 days",group:"recent",getRange:()=>{const t=Date.now();return[M(t).subtract(180,"day").startOf("day").toDate(),M(t).subtract(1,"day").endOf("day").toDate()]}},{key:"d365",value:"recent 365 days",group:"recent",getRange:()=>{const t=Date.now();return[M(t).subtract(365,"day").startOf("day").toDate(),M(t).subtract(1,"day").endOf("day").toDate()]}},{key:"d",value:"today",group:"this",getRange:()=>{const t=Date.now();return[M(t).startOf("day").toDate(),M(t).endOf("day").toDate()]}},{key:"w",value:"this week",group:"this",getRange:()=>{const t=Date.now();return[M(t).startOf("week").toDate(),M(t).endOf("week").toDate()]}},{key:"m",value:"this month",group:"this",getRange:()=>{const t=Date.now();return[M(t).startOf("month").toDate(),M(t).endOf("month").toDate()]}},{key:"y",value:"this year",group:"this",getRange:()=>{const t=Date.now();return[M(t).startOf("year").toDate(),M(t).endOf("year").toDate()]}},{key:"w",value:"this week so far",group:"this_so_far",getRange:()=>{const t=Date.now();return[M(t).startOf("week").toDate(),M(t).toDate()]}},{key:"m",value:"this month so far",group:"this_so_far",getRange:()=>{const t=Date.now();return[M(t).startOf("month").toDate(),M(t).toDate()]}},{key:"y",value:"this year so far",group:"this_so_far",getRange:()=>{const t=Date.now();return[M(t).startOf("year").toDate(),M(t).toDate()]}}];function zl(t){const n=Wr().find(r=>r.value===t);return n?n.getRange():null}const pS=({onChange:t})=>{const{t:e,i18n:n}=_.useTranslation(),r=l=>()=>{const c=l();t(c)},i=m.useMemo(()=>b.groupBy(Wr(),"group"),[]),a=n.language==="zh";return s.jsxs(s.Fragment,{children:[s.jsx(o.Divider,{variant:"dashed",my:10}),s.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:s.jsx("tbody",{children:Object.entries(i).map(([l,c])=>s.jsxs("tr",{children:[s.jsx("th",{children:s.jsx(o.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(o.Button,{compact:!0,size:"xs",variant:"subtle",onClick:r(p),children:e(`filter.widget.date_range.shortcut.${l}.${a?"full.":""}${u}`)})},u))]},l))})})]})},Ml=t=>({label:{display:"block",height:"21.7px"},input:{borderColor:t?"#228be6":"#e9ecef"}}),hS=({label:t,required:e,value:n,onChange:r,max_days:i,allowSingleDateInRange:a,inputFormat:l})=>{const{t:c}=_.useTranslation(),[u,{open:d,close:p}]=ie.useDisclosure(!1),[h,g]=n,y=h?M(h).format(l):"",v=g?M(g).format(l):"";return s.jsxs(o.Popover,{opened:u,onClose:p,position:"bottom-start",shadow:"md",children:[s.jsxs(o.Group,{position:"left",grow:!0,noWrap:!0,spacing:0,w:"288px",sx:{marginTop:"3px"},children:[s.jsx(o.Popover.Target,{children:s.jsx(o.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:y,onFocus:d,styles:Ml(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(o.TextInput,{label:s.jsx(o.Group,{position:"right",children:s.jsx(uS,{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:Ml(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(o.Popover.Dropdown,{p:"sm",children:[s.jsx(dS,{max_days:i}),s.jsx(cS,{value:n,onChange:r,close:p,allowSingleDateInRange:a,max_days:i}),s.jsx(pS,{onChange:r})]})]})},Il=S.observer(({label:t,config:e,value:n=[null,null],onChange:r})=>{const{inputFormat:i,required:a,max_days:l,allowSingleDateInRange:c}=e,u=Array.isArray(n)?n.map(p=>p?M(p).toDate():null):[null,null],d=p=>{r(p.map(h=>h&&M(h).format(i)))};return s.jsx(hS,{label:t,value:u,onChange:d,inputFormat:i,allowSingleDateInRange:c,max_days:l,required:a})}),mS=o.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"}}})),Qr=({errorMessage:t})=>{const{t:e}=_.useTranslation();return t?s.jsx(o.Text,{color:"red",size:12,children:t}):s.jsx(o.Text,{color:"dimmed",size:12,children:e("filter.widget.common.selector_option_empty")})},xS=({disabled:t,classNames:e,styles:n,unstyled:r,radius:i,style:a,label:l,value:c,onChange:u,options:d,errorMessage:p,required:h})=>{const{t:g}=_.useTranslation(),{classes:y,cx:v}=mS({radius:i},{name:"MultiSelectWidget",classNames:e,styles:n,unstyled:r}),[w,T]=m.useState(!1),D=F=>{T(F)},I=w&&(c==null?void 0:c.length)>0,[A,N]=m.useState(""),R=m.useMemo(()=>{if(!A)return d;const F=A.toLowerCase(),Q=ue=>{var le;return((le=ue.description)==null?void 0:le.toLowerCase().includes(F))||ue.label.toLowerCase().includes(F)};return d.filter(Q)},[A,d]);return s.jsxs(o.Stack,{spacing:3,children:[s.jsxs(o.Group,{position:"apart",children:[s.jsxs(o.Text,{className:y.label,children:[l,h&&s.jsx("span",{className:y.required,"aria-hidden":"true",children:"*"})]}),I&&s.jsx(o.Tooltip,{label:g("filter.widget.common.x_selected",{count:c.length}),children:s.jsx(o.Badge,{children:c.length})})]}),s.jsx(la,{disabled:t,allowClear:!0,className:v(y.root,"check-select"),dropdownClassName:v(y.dropdown,""),onDropdownVisibleChange:D,transitionName:"rc-select-dropdown-slide-up",choiceTransitionName:"rc-select-selection__choice-zoom",style:a,clearIcon:()=>s.jsx(o.CloseButton,{}),value:c,onChange:u,onSelect:console.log,mode:"multiple",maxTagCount:0,notFoundContent:s.jsx(Qr,{errorMessage:p}),maxTagTextLength:10,maxTagPlaceholder:F=>g("filter.widget.common.x_selected",{count:F.length}),searchValue:A,onSearch:N,filterOption:!1,children:R.map(F=>s.jsxs(la.Option,{title:F.label,children:[s.jsx(o.Text,{size:"sm","data-role":"label",children:F.label}),F.description&&s.jsx(o.Text,{size:"xs",color:"dimmed","data-role":"description",children:F.description})]},F.value))})]})},gS=S.observer(({label:t,config:e,value:n,onChange:r})=>{const i=he(),a=!!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=a?u:!1,h=g=>r(g,!1);return s.jsx(xS,{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})}),fS=m.forwardRef(({label:t,description:e,...n},r)=>s.jsx("div",{ref:r,...n,children:s.jsx(o.Group,{noWrap:!0,children:s.jsxs("div",{children:[s.jsx(o.Text,{size:"sm","data-role":"label",children:t}),s.jsx(o.Text,{size:"xs",color:"dimmed","data-role":"description",children:e})]})})})),yS=S.observer(({label:t,config:e,value:n,onChange:r})=>{const i=he(),a=!!e.options_query_id,{state:l,error:c}=i.getDataStuffByID(e.options_query_id),u=l==="loading";return s.jsx(o.Select,{label:t,data:e.options,disabled:a?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:fS,searchable:!c,nothingFound:s.jsx(Qr,{errorMessage:c}),clearable:e.clearable})});function bS({label:t,config:e,value:n,onChange:r}){return s.jsx(o.TextInput,{label:t,value:n||"",onChange:i=>r(i.currentTarget.value),...e,styles:{input:{borderColor:"#e9ecef"}}})}const vS=({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"})}),_S=({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(vS,{rotate:t?"0":"-90",onClick:r,...i})),jS=({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"})]}),wS=({onClick:t,...e})=>s.jsx(jS,{onClick:t,...e}),CS=o.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"}}}})),SS=({disabled:t,classNames:e,styles:n,unstyled:r,radius:i,style:a,label:l,value:c,onChange:u,treeData:d,errorMessage:p,required:h,treeCheckStrictly:g})=>{const{t:y}=_.useTranslation(),{classes:v,cx:w}=CS({radius:i},{name:"FilterTreeSelectWidget",classNames:e,styles:n,unstyled:r}),[T,D]=m.useState(!1),I=N=>{D(N)},A=T&&(c==null?void 0:c.length)>0;return s.jsxs(o.Stack,{spacing:3,children:[s.jsxs(o.Group,{position:"apart",children:[s.jsxs(o.Text,{className:v.label,children:[l,h&&s.jsx("span",{className:v.required,"aria-hidden":"true",children:"*"})]}),A&&s.jsx(o.Tooltip,{label:y("filter.widget.common.x_selected",{count:c.length}),children:s.jsx(o.Badge,{children:c.length})})]}),s.jsx(ca,{disabled:t,allowClear:!0,treeCheckStrictly:g,labelInValue:!0,className:w(v.root,"check-select"),dropdownClassName:w(v.dropdown,""),onDropdownVisibleChange:I,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:a,listHeight:510,treeLine:!0,clearIcon:()=>s.jsx(o.CloseButton,{}),switcherIcon:_S,treeIcon:wS,maxTagTextLength:10,value:c,treeData:d,notFoundContent:s.jsx(Qr,{errorMessage:p}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:ca.SHOW_PARENT,onChange:u,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:()=>y("filter.widget.common.x_selected",{count:c.length})})]})},kS=S.observer(({label:t,config:e,value:n,onChange:r})=>{const{treeData:i,treeDataLoading:a,errorMessage:l}=e,c=g=>{const y=g.map(v=>v.value);r(y,!1)},u=m.useMemo(()=>e.initialSelection(n),[n,e.initialSelection]),d=e.min_width?e.min_width:"200px",h=!!e.options_query_id?a:!1;return s.jsx(SS,{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})}),TS=S.observer(({filter:{type:t,config:e,key:n,...r},formFieldProps:i})=>{switch(t){case"select":return s.jsx(yS,{...r,...i,config:e});case"multi-select":return s.jsx(gS,{...r,...i,config:e});case"tree-select":return s.jsx(kS,{...r,...i,config:e});case"text-input":return s.jsx(bS,{...r,...i,config:e});case"date-range":return s.jsx(Il,{...r,...i,config:e});case"checkbox":return s.jsx(lS,{...r,...i,config:e});default:return null}}),DS=S.observer(m.forwardRef(({filter:t,...e},n)=>s.jsx("div",{className:"filter-root",ref:n,children:s.jsx(je,{children:s.jsx(TS,{filter:t,formFieldProps:e})})}))),zS=({disabled:t})=>{const{searchButtonProps:e}=Ia(),{children:n="Search",type:r,...i}=e;return s.jsx(o.Button,{color:"blue",size:"sm",type:"submit",...i,disabled:t||i.disabled,children:n})};function MS(t){const e=Y();m.useEffect(()=>{var n,r;(r=(n=e.filters).updatePreviewValues)==null||r.call(n,t)},[t])}const IS=({opened:t,toggle:e})=>{const{t:n}=_.useTranslation();return s.jsx(o.Group,{position:"right",ml:-4,mt:-4,mb:t?4:0,children:s.jsx(o.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")})})},El=S.observer(function({view:e}){const[n,{toggle:r}]=ie.useDisclosure(!0),i=he(),{control:a,handleSubmit:l,reset:c}=f.useForm({defaultValues:i.filters.values,reValidateMode:"onBlur"}),u=f.useWatch({control:a});m.useEffect(()=>{c(i.filters.values)},[i.filters.values,c]),MS(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 y=(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(IS,{opened:n,toggle:r}),s.jsx(o.Collapse,{in:n,children:s.jsxs(o.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:p?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[s.jsx(o.Group,{align:"flex-start",children:d.map(v=>s.jsx(f.Controller,{name:v.key,control:a,render:({field:w})=>s.jsx(DS,{filter:v,value:w.value,onChange:y(v,w.onChange)})},v.id))}),!p&&s.jsx(o.Group,{sx:{alignSelf:"flex-end"},children:s.jsx(zS,{disabled:g})})]})})]})}),ES={viewPanelInFullScreen:b.noop,inFullScreen:!1},ls=m.createContext(ES),Rr=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 Ur(t){return{current:t}}const AS=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}})),Al=x.types.model("PanelStyleMeta",{border:AS}).views(t=>({get json(){const{border:e}=t;return{border:e.json}}})).actions(t=>({})),Pl=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}})),$l=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:a,data_field:l,aggregation:c}=t;return b.cloneDeep({name:e,size:n,color:i,weight:r,formatter:a,data_field:l,aggregation:c})}})),Bl=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}})),Ll=x.types.model({id:x.types.string,name:x.types.optional(x.types.string,""),title:Pl,description:x.types.string,queryIDs:x.types.array(x.types.string),viz:Bl,style:Al,variables:x.types.optional(x.types.array($l),[])}).views(t=>({get json(){const{id:e,name:n,title:r,description:i,queryIDs:a}=t;return{id:e,viz:t.viz.json,name:n,style:t.style.json,title:r.json,queryIDs:[...a],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 ql=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:a,run_by:l,react_to:c,pre_process:u,post_process:d,dep_query_ids:p}=t;return Gt({id:e,key:i,sql:a,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)}})),Ol=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:a,h:l,moved:c}=t;return{h:l,w:a,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:a,moved:l}=t;return{id:e,i:e,x:n,y:r===null?1/0:r,w:i,h:a,moved:l,static:t.static}}})).actions(t=>({set(e){const{isDraggable:n,x:r,y:i,w:a,h:l,moved:c}=e;t.x=r,t.y=i,t.w=a,t.h=l,t.moved=!!c,t.static=!!e.static},setWidth(e){t.w=e},setHeight(e){t.h=e}})),Vl=x.types.model("LayoutSetMeta",{id:x.types.identifier,name:x.types.string,breakpoint:x.types.number,list:x.types.optional(x.types.array(Ol),[])}).views(t=>({get json(){const{id:e,name:n,breakpoint:r,list:i}=t;return{id:e,name:n,breakpoint:r,list:i.map(a=>Gt(a.json))}},jsonByPanelIDSet(e){const{id:n,name:r,breakpoint:i,list:a}=t;return{id:n,name:r,breakpoint:i,list:a.filter(l=>e.has(l.panelID)).map(l=>Gt(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)}})),Nl=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 Yr=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}})),Gl=()=>Yr.create({_name:"checkbox",description:"",default_value:!1});function Fl(t,e){return t.map(n=>{try{return n?M.tz(n,"UTC").format(e):null}catch{return console.log(`[date-range] failed parsing ${n}`),null}})}const PS=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:a,default_value:l,default_shortcut:c,allowSingleDateInRange:u}=t;return{_name:e,max_days:n,required:r,clearable:i,inputFormat:a,default_value:Fl(l,a),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=zl(t.default_shortcut);if(console.log(n),n){const r=n.map(i=>M(i).format(t.inputFormat));t.setFilterValue(r)}},setMaxDays(e){t.max_days=e,e>0&&(t.clearable=!0)},setAllowSingleDateInRange(e){t.allowSingleDateInRange=e}})),Kr=x.types.snapshotProcessor(PS,{preProcessor({default_value:t,...e}){return{...e,default_value:t.map(n=>n===null?null:M.tz(n,"UTC").toISOString())}},postProcessor(t){const{default_value:e,...n}=t;return{...n,default_value:Fl(e,n.inputFormat)}}}),Wl=()=>Kr.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),$S=x.types.model({label:x.types.string,value:x.types.string}).actions(t=>({setLabel(e){t.label=e},setValue(e){t.value=e}})),Jr=x.types.model("FilterConfigModel_BaseSelect",{static_options:x.types.optional(x.types.array($S),[]),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??""}})),Xr=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),[])}),Jr).views(t=>({get json(){const{_name:e,default_value:n,required:r,min_width:i,static_options:a,options_query_id:l,default_selection_count:c}=t;return Gt({_name:e,required:!!r,min_width:i,default_value:n,static_options:a,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(a=>a.value)),i=(e.values[n]??[]).filter(a=>r.has(a));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}))}})),Ql=()=>Xr.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),Zr=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)}),Jr).views(t=>({get json(){const{_name:e,clearable:n,default_value:r,required:i,width:a,static_options:l,options_query_id:c,default_selection_count:u}=t;return Gt({_name:e,width:a,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 a;const e=x.getRoot(t).content.filters,n=x.getParent(t).key,r=e.values[n],i=(a=t.options.find(l=>l.value===r))==null?void 0:a.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}))}})),Rl=()=>Zr.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),Hr=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}})),ei=()=>Hr.create({_name:"text-input",required:!1,default_value:""});function BS(t){return Lu.arrayToTree(t,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function LS(t){return t.map(e=>{const{label:n,description:r,...i}=e,a={...i,filterBasis:`${n}___${r??""}`,description:r,label:n};return r&&(a.label=m.createElement("div",{},[m.createElement(o.Text,{key:0,title:e.label},e.label),m.createElement(o.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:e.description},e.description)])),a})}const ti=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)}),Jr).views(t=>({get json(){const{_name:e,default_value:n,required:r,min_width:i,static_options:a,options_query_id:l,default_selection_count:c,treeCheckStrictly:u}=t;return{_name:e,required:!!r,min_width:i,default_value:n,static_options:a,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=LS(e);return BS(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)),a=(r??[]).filter(l=>i.has(l));a.length>0?n.setValueByKey(e,a):n.setValueByKey(e,t.defaultSelection)},afterCreate(){x.addDisposer(t,J.reaction(()=>JSON.stringify(t.defaultSelection),this.applyDefaultSelection,{fireImmediately:!0,delay:0}))}})),Ul=()=>ti.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),ni=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(Zr,Xr,ti,Hr,Yr,Kr)}).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:a,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(a),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=Rl();break;case re.MultiSelect:t.config=Ql();break;case re.TreeSelect:t.config=Ul();break;case re.TextInput:t.config=ei();break;case re.Checkbox:t.config=Gl();break;case re.DateRange:t.config=Wl();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 si=x.types.model("ViewDivisionConfig",{_name:x.types.literal(B.Division)}).views(t=>({get json(){const{_name:e}=t;return{_name:e}}})),Yl=()=>si.create({_name:B.Division}),qS=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 a={filters:i.content.filters.values,context:i.context.current};return new Function(`return ${n}`)()(a)}catch(a){return console.error(a),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
|
-
`)},ri=x.types.model("ViewModalConfig",{_name:x.types.literal(B.Modal),width:x.types.string,height:x.types.string,custom_modal_title:x.types.optional(qS,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}})),Kl=()=>ri.create({_name:B.Modal,width:"90vw",height:"90vh"}),OS=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:a}=t;return{id:e,name:n,color:i,order:a,view_id:r}}})).actions(t=>({setName(e){t.name=e},setViewID(e){t.view_id=e},setColor(e){t.color=e},setOrder(e){t.order=e}})),ii=x.types.model("ViewTabsConfig",{_name:x.types.literal(B.Modal),tabs:x.types.optional(x.types.array(OS),[]),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:a}=t;return{grow:a,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)}})),Jl=()=>ii.create({_name:B.Modal,tabs:[]}),Xl=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(si,ri,ii),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(a=>a)}}})).actions(t=>({setName(e){t.name=e},setType(e){if(t.type!==e){switch(e){case B.Division:t.config=Yl();break;case B.Modal:t.config=Kl();break;case B.Tabs:t.config=Jl();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)}})),ft="11.10.0",VS={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:B.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:ft,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},ai=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()}),Zl=x.types.model("DataSourcesMetaModel",{list:x.types.optional(x.types.array(ai),[])}).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)}})),Hl=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}),oi=x.types.model("GlobalSQLSnippetsMeta",{list:x.types.optional(x.types.array(Hl),[])}).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 li(t){return us.create({current:t})}const ci=x.types.compose("ViewRenderModel",Xl,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 da,a=new Date().getTime(),l=await ua.toBlob(e,{bgcolor:"white",width:n,height:r,style:{transformOrigin:"0 0",transform:"scale(2)"}});i.file(`${t.name}_${a}.png`,l),i.file(`dashboard_state_${a}.json`,JSON.stringify(this.contentModel.dashboardState,null,4)),i.generateAsync({type:"blob"}).then(c=>{Tn.saveAs(c,`${t.name}_${a}.zip`)}).catch(c=>{console.error(c),vt.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??""}})),ui=x.types.model("ViewsRenderModel",{current:x.types.optional(x.types.array(ci),[]),visibleViewIDs:x.types.array(x.types.string)}).views(t=>({get json(){return t.current.map(e=>Gt(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 ec(t,e){const n=t.length>0?[t[0].id]:[],r=t.map(i=>{const{_name:a=i.type}=i.config,l={...i,tab:"",config:{...i.config,_name:a},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 NS=new qu.AsyncParser({withBOM:!0});async function tc(t){return!Array.isArray(t)||t.length===0?"":await NS.parse(t).promise()}async function GS(t,e){const n=await tc(e),r=new Blob([n],{type:"text/csv"});Tn.saveAs(r,`${t}.csv`)}function nc(t){const e=new da,n=t.map(async({id:r,data:i})=>{const a=await tc(i);e.file(`${r}.csv`,a)});Promise.all(n).then(()=>{e.generateAsync({type:"blob"}).then(r=>{Tn.saveAs(r,"dashboard_data.zip")})}).catch(r=>{console.error(r),vt.notifications.show({color:"red",title:"Failed to download data",message:r.message})})}function Ht(t,e){const n=new Blob([e],{type:"application/json"});Tn.saveAs(n,`${t}.json`)}const di=Ll.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 ba(t.variables,this.data)},get variableValueMap(){const e={},n=this.data;return t.variables.reduce((r,i)=>{const a=Ze(i,n);return r[i.name]=Ie(i,a),r},e),e},get dataLoading(){return this.queries.some(e=>e.state==="loading")},get queryStateMessages(){const e=this.queries.filter(a=>!a.runByConditionsMet);if(e.length===0)return"";const n=new Set,r=new Set;e.forEach(a=>{const l=a.conditionNames;l.context.forEach(c=>n.add(c)),l.filters.forEach(c=>r.add(c))});const i=[];return n.size>0&&(console.log(n),i.push(`context: ${Array.from(n).join(", ")}`)),r.size>0&&i.push(`filter${r.size>1?"s":""}: ${Array.from(r).join(", ")}`),i.length===2&&i.splice(1,0,"and"),i.unshift("Waiting for"),i.join(" ")},get queryErrors(){return this.queries.map(e=>e.error).filter(e=>!!e)},get canRenderViz(){return this.queryErrors.length===0&&this.queryStateMessages===""&&!this.dataLoading}})).actions(t=>({refreshData(){t.queries.forEach(e=>e.fetchData(!0))},downloadData(){t.contentModel.queries.downloadDataByQueryIDs(t.queryIDs)},getSchema(){const e=t.json;return e.viz.conf={...e.viz.conf,__INTERACTIONS:{},__OPERATIONS:{},__TRIGGERS:{}},{panel:e,queries:t.queries.map(n=>n.json),layouts:t.contentModel.layouts.jsonByPanelIDSet(new Set([t.id]))}},downloadSchema(){const{panel:e,queries:n,layouts:r}=this.getSchema(),a=JSON.stringify({panels:[e],definition:{queries:n},layouts:r,version:ft},null,2),l=t.name;Ht(l,a)}}));function sc(t){return{id:t,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:Er.name,conf:Er.createConfig()},style:{border:{enabled:!0}}}}const pi=x.types.model("PanelsRenderModel",{list:x.types.optional(x.types.array(di),[])}).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 rc(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=zl(e.default_shortcut);if(i)return i.map(a=>M(a).format(e.inputFormat))}const[...r]=n;return r.map(i=>i===null?i:M.tz(i,"UTC").format(e.inputFormat)??i)}catch(r){return console.error(r),n}return n}function FS(t,e){const n=t.default_value_func;try{return new Function(`return ${n}`)()(t,at,e)}catch(r){return console.error(r),rc(t)}}function ic(t,e){var n;return(n=t.default_value_func)!=null&&n.trim()?FS(t,e):rc(t)}function ac(t,e){return t.reduce((n,r)=>(n[r.key]=ic(r,e),n),{})}const hi=x.types.model("FiltersRenderModel",{current:x.types.optional(x.types.array(ni),[]),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 ac(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(a=>({...a.json,visibleInViewsIDs:n?a.json.visibleInViewsIDs:[]})),version:ft}},downloadSchema(e){const n=JSON.stringify(this.getSchema(e,!1),null,2);Ht("Filters",n)}}));function mi(t,e,n,r){const i=b.defaults({},r,ac(t,{...n,...e}));return{current:t,values:i}}const oc=ql.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],a=new Set(i.map(l=>l.value));return t.run_by.forEach(l=>{a.has(l)||i.push({group:"Invalid",label:l,value:l})}),i},get unmetRunByConditions(){if(!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,a=Jd(i,e,n);return console.groupCollapsed(`Request config for: ${r}`),console.log(a),console.groupEnd(),JSON.stringify(a)},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,a)=>(i[a]=b.get(n,a),i),{});return JSON.stringify(r)},get runByConditionsMet(){return t.unmetRunByConditions.length===0},get conditionNames(){if(t.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:e}=t.contentModel.filters,n=t.unmetRunByConditions.filter(i=>i.startsWith("context.")).map(i=>i.replace("context.","")),r=t.unmetRunByConditions.filter(i=>i.startsWith("filters.")).map(i=>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(In.sqlSnippet)),n=b.uniq(t.sql.match(In.filter)),r=b.uniq(t.sql.match(In.context)),i=[];return e.forEach(a=>{i.push({type:"sql_snippet",key:a,valid:t.contentModel.sqlSnippets.keySet.has(a)})}),n.forEach(a=>{i.push({type:"filter",key:a,valid:t.contentModel.filters.keySet.has(a)})}),r.forEach(a=>{i.push({type:"context",key:a,valid:t.contentModel.mock_context.keySet.has(a)})}),i}})),xi=x.types.compose("QueryRenderModel",oc,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(tp({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 a=JSON.parse(t.httpConfigString);a=Xd(t.datasource,a);const l=yield*x.toGenerator(np({type:n,key:r,configString:JSON.stringify(a),name:t.name,additionals:t.additionalQueryInfo},t.controller.signal)),c=Zd(t.datasource,l),u=Hd(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,a=new Function(`return ${i}`)()(n,r,at);t.data=a,t.state="idle",t.error=null}catch(e){t.data=[],t.error=e.message,t.state="error"}}})).actions(t=>({fetchData:e=>{if(!t.inUse&&!e){console.debug(`🟡 Skipping query[${t.name}]`);return}return console.debug(`🔵 Running query[${t.name}]`),t.isTransform?t.runTransformation():t.typedAsHTTP?t.runHTTP():t.runSQL()},beforeDestroy(){var e;(e=t.controller)==null||e.abort()}})).actions(t=>({afterCreate(){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}))}})),gi=x.types.model("QueriesRenderModel",{current:x.types.optional(x.types.array(xi),[])}).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 a=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;a.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}));nc(e)},downloadDataByQueryIDs(e){const n=new Set(e),r=t.current.filter(i=>n.has(i.id)).map(({name:i,data:a})=>({id:i,data:a}));nc(r)},downloadDataByQueryID(e){const n=t.findByID(e);if(!n){console.log("[downloadDataByQueryID] query not found");return}const{name:r,data:i}=n;GS(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:ft}},downloadSchema(e){const n=JSON.stringify(this.getSchema(e),null,2);Ht("Queries",n)}}));function lc(t){return{current:t}}function cc({min:t,max:e}){const n=`${t}px`,r=Number.isFinite(e)?`${e}px`:"∞";return`[${n}, ${r})`}const fi=x.types.model("LayoutsRenderModel",{list:x.types.array(Vl),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 cc(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=cc(n)}),e},get breakpointsInfo(){return t.list.map(e=>({id:e.id,name:e.name,breakpoint:e.breakpoint})).sort((e,n)=>e.breakpoint-n.breakpoint)},get currentBreakpointRange(){return this.breakpointRanges.find(e=>e.id===t.currentBreakpoint)},get currentLayoutPreviewWidth(){const e=this.currentBreakpointRange;if(e)return e.max===1/0?e.min===0?void 0:e.min+1:e.max},items(e){const n=new Set(e);return this.currentLayoutSet.list.filter(i=>n.has(i.panelID))},gridLayouts(e){const n=new Set(e),r={};return t.list.forEach(i=>{r[i.id]=i.list.filter(a=>n.has(a.panelID)).map(a=>a.layoutProperies)}),r},findItemByPanelID(e){return this.currentLayoutSet.findByPanelID(e)}})).actions(t=>({setCurrentBreakpoint(e){console.log("🔴 onBreakpointChange:",e),t.currentBreakpoint=e},afterCreate(){x.addDisposer(t,J.reaction(()=>t.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),uc=Nl.views(t=>({isADuplicatedKey(e){return!e||e===t.key?!1:!!x.getParent(t,2).findByKey(e)}})),yi=x.types.model("SQLSnippetsRenderModel",{current:x.types.optional(x.types.array(uc),[])}).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:ft}},downloadSchema(e){const n=JSON.stringify(this.getSchema(e),null,2);Ht("SQL Snippets",n)}}));function dc(t){return{current:t}}function vn(t,e,n,r){return t.reduce((i,a)=>{try{i[a[e]]=ks(a[n],r)}catch(l){i[a[e]]=l.message}return i},{})}class pc{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 hc=t=>new pc(t),WS=S.observer(()=>{const{t}=_.useTranslation(),e=Z(),{panel:n}=ze(),r=n.realQueryOptions,i=a=>{e.editor.open(["_QUERIES_",a])};return r.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx(o.Divider,{label:t(r.length>1?"query.labels":"query.label"),labelPosition:"center"}),r.map(a=>s.jsx(o.Menu.Item,{onClick:()=>i(a.value),icon:s.jsx(k.IconDatabase,{size:14}),children:a.label},a.value))]})}),QS=S.observer(({view:t,title:e})=>{const{t:n}=_.useTranslation(),r=Z(),i=Y(),a=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])},y=()=>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,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(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:e,children:s.jsxs(o.Menu,{withinPortal:!0,children:[s.jsx(o.Menu.Target,{children:s.jsx(o.Box,{className:"panel-dropdown-target",sx:{width:"100%"}})}),s.jsxs(o.Menu.Dropdown,{children:[s.jsx(o.Menu.Item,{onClick:l.refreshData,icon:s.jsx(L.Refresh,{size:14}),children:n("common.actions.refresh")}),s.jsx(o.Menu.Item,{onClick:l.downloadData,icon:s.jsx(L.Download,{size:14}),children:n("common.actions.download_data")}),s.jsx(o.Menu.Item,{onClick:l.downloadSchema,icon:s.jsx(k.IconCode,{size:14}),children:n("common.actions.download_schema")}),s.jsx(o.Menu.Item,{onClick:c,icon:s.jsx(k.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),w&&s.jsx(o.Menu.Item,{onClick:v,icon:s.jsx(L.ArrowsMaximize,{size:14}),disabled:!0,children:n("common.actions.enter_fullscreen")}),s.jsx(WS,{}),s.jsx(o.Divider,{label:n("common.actions.edit"),labelPosition:"center"}),s.jsx(o.Menu.Item,{onClick:g,icon:s.jsx(L.Settings,{size:14}),children:n("common.titles.settings")}),s.jsx(o.Menu.Item,{onClick:h,icon:s.jsx(L.Copy,{size:14}),children:n("common.actions.duplicate")}),s.jsx(o.Menu.Item,{color:"red",onClick:y,icon:s.jsx(L.Trash,{size:14}),children:n("common.actions.delete")})]})]})})})});function RS(t){return t?["<p><br></p>","<p></p>"].includes(t):!0}const bi=S.observer(()=>{const{t}=_.useTranslation(),[e,n]=m.useState(!1),{panel:r}=mt();return RS(r.description)?null:s.jsxs(s.Fragment,{children:[s.jsx(o.Modal,{opened:e,onClose:()=>n(!1),title:r.title.show?r.name:"",withCloseButton:!1,withinPortal:!0,zIndex:310,children:s.jsx(Zn,{value:r.description,styles:{root:{border:"none"},content:{padding:0}},sx:{".mantine-RichTextEditor-content .ProseMirror":{padding:"0 !important"}}})}),s.jsx(o.Tooltip,{label:t("panel.panel_description_click"),position:"top-start",withinPortal:!0,children:s.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:s.jsx(L.InfoCircle,{size:20})})})]})}),OM="",US=S.observer(function(){const{panel:e}=mt(),{name:n,title:r}=e;return r.show?s.jsx(o.Group,{grow:!0,position:"center",className:"panel-title-wrapper",sx:{flexGrow:1},children:s.jsx(o.Text,{align:"center",lineClamp:1,className:"panel-title-text",children:n})}):null});function YS(t){const e=m.useRef(null);return{ref:e,downloadPanelScreenshot:()=>{const r=e.current;if(!r)return;const i=r.offsetWidth*2,a=r.offsetHeight*2;ua.toBlob(e.current,{bgcolor:"white",width:i,height:a,style:{border:"none",borderRadius:0,transformOrigin:"0 0",transform:"scale(2)"}}).then(l=>{window.saveAs(l,`${t.name?t.name:t.viz.type}.png`)})}}}var mc=(t=>(t.migrated="migrated",t.nothingToMigrate="nothingToMigrate",t.checkFailed="checkFailed",t.migrationFailed="migrationFailed",t))(mc||{}),ds=(t=>(t.notStarted="notStarted",t.inProgress="inProgress",t.done="done",t))(ds||{});class KS{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 xc(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,a=>{const l=a.getRequired(me.instanceScope.vizInstance);return new Ws(l,i,$n)}).provideFactory(me.instanceScope.operationManager,a=>a.getRequired(me.instanceScope.interactionManager).operationManager).provideFactory(me.instanceScope.triggerManager,a=>a.getRequired(me.instanceScope.interactionManager).triggerManager).provideValue(me.instanceScope.panelModel,e).provideFactory(me.instanceScope.migrator,a=>new KS(a))},[t.viz.type,t.viz.conf])}function gc(t){const[e,n]=m.useState(!1),r=Dl().getRequired(me.instanceScope.migrator);return G.useAsyncEffect(async()=>{const i=r.status===ds.notStarted;n(r.status===ds.done),r.status===ds.notStarted&&r.runMigration().then(a=>{a===mc.migrated&&i&&(t==null||t())}).finally(()=>{n(!0)})},[r]),e}function fc(t,e){const n=Dl().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 JS({setVizConf:t,...e}){const{panel:n}=e,r=fc(t,n),i=gc(()=>{vt.showNotification({title:`${n.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return G.useAsyncEffect(async()=>{await r.instanceData.setItem(null,n.viz.conf)},[r,n.viz.type]),i?s.jsx(ap,{...e}):s.jsx(o.Text,{children:"Checking update..."})}function XS(t){const{panel:e,setVizConf:n}=t;fc(n,e);const{inEditMode:r}=m.useContext(An);return gc(()=>{r&&vt.showNotification({title:`${e.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?s.jsx(ip,{...t}):s.jsx(o.Text,{children:"Checking update"})}const VM="";function ZS(t,e){const{vizManager:n}=m.useContext(ut),{panel:{viz:r,title:i,id:a,name:l,description:c,queryIDs:u,variables:d}}=mt(),p={id:a,name:l,title:i,description:c,queryIDs:u,viz:r},h=xc(p);try{return n.resolveComponent(r.type),s.jsx(os,{configure:h,children:s.jsx(XS,{setVizConf:r.setConf,panel:p,measure:e,data:t,variables:d,vizManager:n})})}catch(g){return console.info(b.get(g,"message")),null}}const yc=S.observer(function({data:e}){const{ref:n,width:r,height:i}=ie.useElementSize(),a=ZS(e,{w:r,h:i}),l=r>0&&i>0;return s.jsx("div",{className:"viz-root",ref:n,children:s.jsx(o.Box,{sx:{width:r,height:i,overflow:"hidden"},children:l&&s.jsx(je,{children:a})})})}),bc=S.observer(({panel:t})=>s.jsxs(o.Stack,{children:[t.queryErrors.map((e,n)=>s.jsx(o.Text,{color:"red",size:"sm",align:"center",sx:{fontFamily:"monospace"},children:e},`${n}-${e}`)),s.jsx(o.Text,{color:"gray",align:"center",size:"sm",children:t.queryStateMessages})]})),vi=S.observer(({panel:t})=>s.jsxs(o.Flex,{className:"panel-viz-section",direction:"column",sx:{position:"relative",width:"100%"},children:[s.jsx(o.LoadingOverlay,{visible:t.dataLoading,exitTransitionDuration:0}),!t.canRenderViz&&s.jsx(bc,{panel:t}),t.canRenderViz&&s.jsx(yc,{data:t.data})]})),HS={border:"1px solid #e9ecef"},vc=S.observer(({panel:t,panelStyle:e,dropdownContent:n})=>{const{ref:r,downloadPanelScreenshot:i}=YS(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(o.Box,{className:`panel-root ${t.title.show?"panel-root--show-title":""}`,ref:r,p:0,sx:{...HS,...e},children:[s.jsx(o.Box,{className:"panel-description-popover-wrapper",children:s.jsx(bi,{})}),n,s.jsx(US,{}),s.jsx(vi,{panel:t})]})})}),ek={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function tk(t){return t.style.border.enabled?{}:ek}const _c=S.observer(function({panel:e,view:n}){const r=tk(e);return s.jsx(vc,{panel:e,panelStyle:r,dropdownContent:s.jsx(QS,{view:n,title:e.name})})});function nk(t){return!["richText","button"].includes(t)}const sk=S.observer(({view:t,title:e})=>{const{t:n}=_.useTranslation(),{panel:r,downloadPanelScreenshot:i}=mt(),{id:a}=r,{viewPanelInFullScreen:l,inFullScreen:c}=m.useContext(ls),u=m.useCallback(()=>{l(a)},[a,l]),d=!c&&t.type!==B.Modal;return nk(r.viz.type)?s.jsx(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},title:e,children:s.jsxs(o.Menu,{withinPortal:!0,children:[s.jsx(o.Menu.Target,{children:s.jsx(o.Box,{className:"panel-dropdown-target"})}),s.jsxs(o.Menu.Dropdown,{children:[s.jsx(o.Menu.Item,{onClick:r.refreshData,icon:s.jsx(L.Refresh,{size:14}),children:n("common.actions.refresh")}),s.jsx(o.Menu.Item,{onClick:r.downloadData,icon:s.jsx(L.Download,{size:14}),children:n("common.actions.download_data")}),s.jsx(o.Menu.Item,{onClick:i,icon:s.jsx(k.IconCamera,{size:14}),children:n("common.actions.download_screenshot")}),d&&s.jsx(o.Menu.Item,{onClick:u,icon:s.jsx(L.ArrowsMaximize,{size:14}),children:n("common.actions.enter_fullscreen")})]})]})}):null});function rk(t){return t.style.border.enabled?{}:{border:"1px dashed transparent"}}const _i=S.observer(({panel:t,view:e})=>{const n=rk(t);return s.jsx(vc,{panel:t,panelStyle:n,dropdownContent:s.jsx(sk,{title:t.name,view:e})})}),ik={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},jc=S.observer(function({view:e,panel:n,exitFullScreen:r}){return s.jsx(o.Modal,{opened:!0,fullScreen:!0,onClose:r,title:s.jsx(o.Button,{color:"blue",size:"xs",onClick:r,leftIcon:s.jsx(L.ArrowLeft,{size:20}),children:"Exit fullscreen"}),styles:ik,children:s.jsx(o.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:s.jsx(_i,{view:e,panel:n})})})});function wc(t,e,n){const{panels:r}=he(),i=t.id==="Main",[a,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=a?r.findByID(a):null;return{viewPanelInFullScreen:c,exitFullScreen:u,inFullScreen:!!d,fullScreenPanel:d}}const NM="",ak=m.forwardRef(({h:t},e)=>s.jsx(o.ActionIcon,{ref:e,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:5,right:t>38?5:20,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:s.jsx(L.ArrowsMove,{size:16})})),ok=m.forwardRef(({handleAxis:t,...e},n)=>s.jsx(o.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...e,children:s.jsx(L.ChevronDownRight,{size:16})})),lk=kn.WidthProvider(kn.Responsive),ck=S.observer(({view:t,className:e="layout"})=>{const r=Y().layouts,i=r.items(t.panelIDs),a=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(lk,{className:`dashboard-layout ${e}`,rowHeight:1,margin:[0,0],isBounded:!0,isDraggable:!0,isResizable:!0,cols:r.cols,layouts:a,draggableHandle:".react-grid-customDragHandle",resizeHandle:s.jsx(ok,{}),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(ak,{h:d.h}),s.jsx(_c,{view:t,panel:d.panel})]},d.id))})}),uk=kn.WidthProvider(kn.Responsive),dk=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(uk,{className:`dashboard-layout ${e}`,rowHeight:1,margin:[0,0],isDraggable:!1,isResizable:!1,cols:n.layouts.cols,layouts:i,breakpoints:n.layouts.breakpoints,onBreakpointChange:n.layouts.setCurrentBreakpoint,children:r.map(a=>s.jsx("div",{"data-grid":a.layoutProperies,className:"panel-grid-item",children:s.jsx(_i,{view:t,panel:a.panel})},a.id))})});function ji(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 pk=S.observer(({downloadScreenshot:t})=>{const{t:e}=_.useTranslation(),[n,{setTrue:r,setFalse:i}]=G.useBoolean(!1),a=za(),l=he(),c=()=>{const u=JSON.stringify(l.contentJSON,null,2),d=`${a.name}__${l.name}`;Ht(d,u)};return s.jsxs(o.Menu,{shadow:"md",width:200,trigger:"hover",openDelay:200,closeDelay:400,withinPortal:!0,position:"bottom-end",children:[s.jsx(o.Menu.Target,{children:s.jsx(o.Affix,{position:{bottom:"20px",right:"10px"},zIndex:1,children:s.jsx(o.ActionIcon,{size:"md",variant:"gradient",gradient:{from:"indigo",to:"cyan"},onMouseEnter:r,onMouseLeave:i,sx:{opacity:n?1:.6,transform:`translateX(${n?0:"2px"})`,transition:"all ease 300ms",borderRadius:"50%"},children:s.jsx(k.IconShare3,{size:"1rem"})})})}),s.jsxs(o.Menu.Dropdown,{children:[s.jsx(o.Menu.Item,{icon:s.jsx(k.IconCamera,{size:14}),onClick:t,children:e("common.actions.download_screenshot")}),s.jsx(o.Menu.Divider,{}),s.jsx(o.Menu.Item,{icon:s.jsx(k.IconDownload,{size:14}),onClick:l.queries.downloadAllData,children:e("common.actions.download_data")}),s.jsx(o.Menu.Item,{icon:s.jsx(k.IconCode,{size:14}),onClick:c,children:e("common.actions.download_schema")})]})]})}),Cc=S.observer(({children:t,view:e,sx:n={}})=>{const{ref:r,downloadScreenshot:i}=ji(e);return s.jsxs(s.Fragment,{children:[s.jsx(o.Box,{ref:r,pt:10,pb:10,sx:n,children:t}),s.jsx(pk,{downloadScreenshot:i})]})}),Sc=S.observer(({downloadScreenshot:t})=>s.jsx(o.ActionIcon,{className:"download-screenshot-button",color:"blue",onClick:t,children:s.jsx(k.IconCamera,{size:14})})),hk=S.observer(({children:t,view:e})=>{const n=he(),r=e.config,i=n.views.visibleViewIDs.includes(e.id),a=()=>n.views.rmVisibleViewID(e.id),{ref:l,downloadScreenshot:c}=ji(e);return s.jsx(o.Modal,{size:r.width,centered:!0,opened:i,onClose:a,withCloseButton:!1,title:s.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[s.jsx(o.Box,{children:r.custom_modal_title.value}),s.jsx(Sc,{downloadScreenshot:c})]}),trapFocus:!0,onDragStart:u=>{u.stopPropagation()},styles:{root:{position:"fixed",zIndex:200,inset:0},overlay:{zIndex:"unset"},inner:{zIndex:"unset",padding:"0 !important"},content:{border:"1px solid #efefef",maxHeight:"unset !important",overflow:"hidden"},body:{maxHeight:r.height,overflow:"auto",position:"relative",paddingBottom:10},header:{padding:0},title:{flexGrow:1}},transitionProps:{duration:0},children:s.jsx(o.Box,{ref:l,children:t})})}),mk=t=>t.color?{"&[data-active], &[data-active]:hover":{borderColor:t.color?t.color:"..."}}:{},xk=S.observer(({view:t})=>{const e=he(),n=t.config;return s.jsxs(o.Tabs,{className:"render-view-tabs",variant:n.variant,orientation:n.orientation,value:t.tab,onTabChange:t.setTab,styles:{root:{height:"100%",overflow:n.orientation==="horizontal"?"hidden":"auto"},panel:{padding:n.orientation==="horizontal"?"0px 0px 36px":"0",height:"100%",overflow:"auto"}},keepMounted:!1,children:[s.jsx(o.Tabs.List,{grow:n.grow,children:n.tabsInOrder.map(r=>s.jsx(o.Tabs.Tab,{value:r.id,sx:mk(r),disabled:!r.view_id,children:r.name??r.id},r.id))}),n.tabsInOrder.map(r=>{const i=e.views.findByID(r.view_id);return i?s.jsx(o.Tabs.Panel,{value:r.id,children:s.jsx(ps,{view:i})},r.id):null})]})}),gk=S.observer(({view:t,children:e})=>{switch(t.type){case B.Modal:return s.jsx(hk,{view:t,children:e});case B.Tabs:return s.jsx(xk,{view:t});case B.Division:default:return s.jsx(Cc,{view:t,children:e})}}),fk=S.observer(({children:t,view:e})=>{const r=Y().layouts,[i,a]=ie.useResizeObserver();return m.useEffect(()=>{r.setCurrentLayoutWrapperWidth(a.width)},[a.width]),s.jsx(o.Box,{sx:{height:"100%"},ref:i,children:s.jsx(o.Box,{sx:{paddingBottom:"100px",background:"white",margin:"0 auto",width:r.currentLayoutPreviewWidth??"100%",transform:`scale(${r.divisionPreviewScale})`,transformOrigin:"0 0"},children:s.jsx(Cc,{view:e,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:t})})})});function kc(t){return t.replace(/(vw|vh)/,"%")}const yk=S.observer(({children:t,view:e})=>{const n=e.config,{width:r,height:i}=m.useMemo(()=>({width:kc(n.width),height:kc(n.height)}),[n.width,n.height]),{ref:a,downloadScreenshot:l}=ji(e);return s.jsx(o.Box,{sx:{height:"100%","> div:not(.mantine-Modal-root)":{height:"100%"}},children:s.jsx(o.Modal,{size:n.width,opened:!0,onClose:b.noop,withCloseButton:!1,title:s.jsxs(o.Group,{position:"apart",px:"1rem",h:"48px",children:[s.jsx(o.Box,{children:n.custom_modal_title.value}),s.jsx(Sc,{downloadScreenshot:l})]}),trapFocus:!0,onDragStart:c=>{c.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},inner:{position:"relative",top:"50%",left:"50%",right:"unset",bottom:"unset",transform:"translate(-50%, -50%)",padding:"0 !important",width:r,height:i,maxHeight:i},content:{border:"1px solid #efefef",height:"100%"},body:{maxHeight:"calc(100% - 48px)",overflow:"auto"},header:{padding:0},title:{flexGrow:1}},withinPortal:!1,transitionProps:{duration:0},children:s.jsx(o.Box,{ref:a,children:t})})})}),bk=({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},vk=t=>t.color?{"&[data-active], &[data-active]:hover":{borderColor:t.color?t.color:"..."}}:{},_k=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]),a=t.config,l=u=>n.openConfirmModal({title:`${e("view.component.tabs.tab.delete")}?`,labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{a.removeTab(u)},confirmProps:{color:"red"},zIndex:320}),c=a.tabs.length===0;return s.jsxs(o.Tabs,{className:"preview-view-tabs",variant:a.variant,orientation:a.orientation,value:t.tab,onTabChange:t.setTab,styles:bk(a),children:[s.jsxs(o.Tabs.List,{grow:a.grow,children:[a.tabsInOrder.map(u=>s.jsx(o.Tabs.Tab,{value:u.id,sx:vk(u),children:u.name??u.id},u.id)),s.jsx(o.Tabs.Tab,{onClick:a.addTab,value:"add",className:"add-a-tab",children:s.jsx(L.Plus,{size:18,color:"#228be6"})})]}),a.tabsInOrder.map((u,d)=>{const p=r.views.findByID(u.view_id);return s.jsxs(o.Tabs.Panel,{value:u.id,sx:{position:"relative"},children:[s.jsxs(o.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[s.jsx(o.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),s.jsxs(o.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[s.jsx(o.TextInput,{label:e("view.component.tabs.tab.name"),required:!0,value:u.name,onChange:h=>u.setName(h.currentTarget.value)}),s.jsx(o.Select,{label:"View",value:u.view_id,onChange:u.setViewID,data:i}),s.jsx(o.NumberInput,{label:e("view.component.tabs.tab.order"),required:!0,value:u.order,onChange:h=>u.setOrder(h||0),min:0,max:1e3,step:1}),s.jsx(o.ColorInput,{label:e("view.component.tabs.tab.color"),value:u.color,onChange:u.setColor,disabled:a.variant!=="default"}),p&&s.jsx(o.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(o.Button,{mt:20,variant:"subtle",color:"red",onClick:()=>l(d),disabled:c,leftIcon:s.jsx(k.IconTrash,{size:14}),children:e("view.component.tabs.tab.delete")})]})]}),p&&s.jsx(ps,{view:p})]},u.id)})]})}),jk=S.observer(({view:t,children:e})=>{switch(t.type){case B.Modal:return s.jsx(yk,{view:t,children:e});case B.Tabs:return s.jsx(_k,{view:t});case B.Division:default:return s.jsx(fk,{view:t,children:e})}}),Tc=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(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{background:r?"transparent":"#efefef"},children:s.jsx(jk,{view:e,children:s.jsxs(o.Box,{sx:{position:"relative"},children:[s.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:s.jsx(El,{view:e})}),s.jsx(ck,{view:e})]})})})})}),ps=S.observer(function({view:e}){const{fullScreenPanelID:n,setFullScreenPanelID:r}=Ba(),{viewPanelInFullScreen:i,exitFullScreen:a,inFullScreen:l,fullScreenPanel:c}=wc(e,n,r);return s.jsx(ls.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:l},children:s.jsxs(o.Box,{className:"dashboard-view","data-enable-scrollbar":!0,sx:{height:e.type===B.Modal?"0 !important":"100%"},children:[l&&s.jsx(jc,{view:e,panel:c,exitFullScreen:a}),s.jsx(gk,{view:e,children:s.jsxs(o.Box,{sx:{position:"relative"},children:[!l&&s.jsx(o.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:s.jsx(El,{view:e})}),!l&&s.jsx(dk,{view:e})]})})]})})});var Dc=(t=>(t.Use="use",t.Edit="edit",t))(Dc||{});const wk={[B.Division]:"Division",[B.Tabs]:"Tabs",[B.Modal]:"Modal"},zc={[B.Division]:"rgba(255, 0, 0, 0.2)",[B.Modal]:"rgba(0, 0, 0, 0.2)",[B.Tabs]:"rgba(255, 200, 100, 0.4)"},Ck={[B.Division]:"#ff4000",[B.Modal]:"#000",[B.Tabs]:"#ffad18"};function Sk(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 Mc=x.types.compose("FiltersModel",hi,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(){Sk(t.current,ni,(n,r)=>{if(n==="setType"){const i=ic(r.config.default_value,r.config);t.setValueByKey(r.key,i),t.updatePreviewValues({...t.previewValues,[r.key]:i})}})}return{afterCreate(){e()}}}),Ic=xi.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"}})),Ec=x.types.compose("QueriesModel",gi,x.types.model({current:x.types.optional(x.types.array(Ic),[])})).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)}})),Ac=yi.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)}})),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({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}})),Dk=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`
|
|
444
|
+
`}})}function Mz(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 zz(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 Iz(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=_t(S,t);return k[S.name]=Re(S,T),k},{}),i=jz(e),a=wz(e),l=Ks(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])),x=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}=xo(z,c,u,e.visualMap);return E||(I.visualMap=!1,I.itemStyle={color:N}),I});return{xAxis:Mz(e,f,i.x_axis),yAxis:zz(e,x,i.y_axis),series:Sz(e,y),tooltip:Dz(e,t,i,a),grid:Cz(e),visualMap:l}}function Ez({conf:e,data:t,width:n,height:s,interactionManager:i,variables:a}){const l=g.useMemo(()=>{const h=O(e.x_axis.data_key),f=O(e.y_axis.data_key);return v.keyBy(t[h.queryID],x=>`${x[h.columnKey]}---${x[f.columnKey]}`)},[t,e.x_axis.data_key,e.y_axis.data_key]),c=nt(i.triggerManager,mh.id),u=g.useCallback(h=>{const[f,x]=h.value,y=v.get(l,`${f}---${x}`,{error:"rowData is not found"});c.forEach(j=>{i.runInteraction(j.id,{...h,rowData:y})})},[l,c,i]),d=g.useMemo(()=>({click:u}),[u]),p=g.useMemo(()=>Iz(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 Az({context:e,instance:t}){const n=rt({vizManager:e.vizManager,instance:t}),{value:s}=$(e.instanceData,"config"),{variables:i}=e,a=g.useMemo(()=>v.defaults({},s,qo),[s]),l=e.data,{width:c,height:u}=e.viewport;return!c||!u?null:r.jsx(Ue,{width:c,height:u,children:r.jsx(Ez,{variables:i,width:jt(c),height:wt(u),data:l,conf:a,interactionManager:n})})}const Pz=[{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 Oz(e){const{visualMap:t=Jt(),heat_block:{min:n,max:s,...i},...a}=e;return{...a,heat_block:i,visualMap:{...Jt(),min:n,max:s}}}class Lz extends me{constructor(){super(...arguments);B(this,"VERSION",2)}configVersions(){this.version(1,n=>({version:1,config:n})),this.version(2,n=>({...n,version:2,config:Oz(n.config)}))}}const Bz={displayName:"viz.merico_heatmap.viz_name",displayGroup:"chart.groups.merico_suite",migrator:new Lz,name:"merico-heatmap",viewRender:Az,configRender:bz,createConfig:()=>({version:2,config:qo}),triggers:[mh],translation:Pz},qz=[{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"})),Vz=[Qm,Um,Xm,Km,Ym,Jm],xh=[Mo,VT,tD,Dk,a1,yS,_M,dx,o_,E0,CC,VD,aS,h0,kT,WS,yk,uD,ez,Bz,pz,y_],yh=()=>({id:"dashboard",version:wc,manifest:{viz:xh,color:[...qz,...Vz]}}),Wr=new tx,je={pluginManager:Rt("pluginManager"),vizManager:Rt("vizManager"),colorManager:Rt("colorManager"),instanceScope:{panelModel:Rt("panelModel"),vizInstance:Rt("vizInstance"),interactionManager:Rt("interactionManager"),migrator:Rt("migrator"),operationManager:Rt("operationManager"),triggerManager:Rt("triggerManager")}},Vo=()=>{try{Wr.install(yh())}catch{}const e=new Gm(Wr),t=new ex(Wr);return{pluginManager:Wr,vizManager:e,colorManager:t}},Nt=g.createContext(Vo());try{Wr.install(yh())}catch{}const No=g.createContext(null);function ri(e){const t=g.useContext(No),n=W.useCreation(()=>e.configure(t||new Mi),[e.configure]),s=W.usePrevious(n);return s&&s!==n&&s.dispose(),r.jsx(No.Provider,{value:n,children:e.children})}function bh(){return g.useContext(No)}const Nz=({description:e,isDescriptionEmpty:t})=>t?null:r.jsx(o.Tooltip,{color:"white",label:r.jsx(Us,{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"})})}),$z=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(Nz,{description:n,isDescriptionEmpty:s})]}),checked:a||!1,onChange:c=>l(c.currentTarget.checked),...i,pt:".4em",styles:{input:{borderColor:"#e9ecef"}}})]})),Fz=({value:e,onChange:t,close:n,max_days:s,allowSingleDateInRange:i})=>{const{i18n:a}=_.useTranslation(),[l,c]=e,u=g.useMemo(()=>l||new Date,[l]),d=g.useMemo(()=>{if(l&&!c)return l},[l,c]),p=g.useMemo(()=>{if(l&&!c&&s>0)return P(l).add(s-1,"days").toDate()},[l,c,s]),h=f=>{const[x,y]=f;t(f),x&&y&&n()};return r.jsx(Gl.DatePicker,{defaultDate:u,numberOfColumns:2,type:"range",value:e,onChange:h,onNextMonth:console.log,minDate:d,maxDate:p,allowSingleDateInRange:i,locale:a.language})},Gz=({begin:e,end:t})=>{const{t:n}=_.useTranslation(),s=g.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})})},Wz=({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},$o=()=>[{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 vh(e){const n=$o().find(s=>s.value===e);return n?n.getRange():null}const Rz=({onChange:e})=>{const{t,i18n:n}=_.useTranslation(),s=l=>()=>{const c=l();e(c)},i=g.useMemo(()=>v.groupBy($o(),"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))})})]})},_h=e=>({label:{display:"block",height:"21.7px"},input:{borderColor:e?"#228be6":"#e9ecef"}}),Qz=({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,x=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:x,onFocus:d,styles:_h(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(Gz,{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:_h(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(Wz,{max_days:i}),r.jsx(Fz,{value:n,onChange:s,close:p,allowSingleDateInRange:a,max_days:i}),r.jsx(Rz,{onChange:s})]})]})},jh=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(Qz,{label:e,value:u,onChange:d,inputFormat:i,allowSingleDateInRange:c,max_days:l,required:a})}),Uz=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"}}})),Fo=({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")})},Yz=({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:x,cx:y}=Uz({radius:i},{name:"MultiSelectWidget",classNames:t,styles:n,unstyled:s}),[j,k]=g.useState(!1),S=N=>{k(N)},T=j&&(c==null?void 0:c.length)>0,[z,I]=g.useState(""),E=g.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:x.label,children:[l,h&&r.jsx("span",{className:x.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(sc,{disabled:e,allowClear:!0,className:y(x.root,"check-select"),dropdownClassName:y(x.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(Fo,{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(sc.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))})]})},Kz=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(Yz,{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})}),Xz=g.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})]})})})),Jz=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:Xz,searchable:!c,nothingFound:r.jsx(Fo,{errorMessage:c}),clearable:t.clearable})});function Zz({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 Hz=({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"})}),eI=({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(Hz,{rotate:e?"0":"-90",onClick:s,...i})),tI=({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"})]}),nI=({onClick:e,...t})=>r.jsx(tI,{onClick:e,...t}),rI=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"}}}})),sI=({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:x}=_.useTranslation(),{classes:y,cx:j}=rI({radius:i},{name:"FilterTreeSelectWidget",classNames:t,styles:n,unstyled:s}),[k,S]=g.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:x("filter.widget.common.x_selected",{count:c.length}),children:r.jsx(o.Badge,{children:c.length})})]}),r.jsx(ic,{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:eI,treeIcon:nI,maxTagTextLength:10,value:c,treeData:d,notFoundContent:r.jsx(Fo,{errorMessage:p}),treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:ic.SHOW_PARENT,onChange:u,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:()=>x("filter.widget.common.x_selected",{count:c.length})})]})},iI=D.observer(({label:e,config:t,value:n,onChange:s})=>{const{treeData:i,treeDataLoading:a,errorMessage:l}=t,c=f=>{const x=f.map(y=>y.value);s(x,!1)},u=g.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(sI,{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})}),aI=D.observer(({filter:{type:e,config:t,key:n,...s},formFieldProps:i})=>{switch(e){case"select":return r.jsx(Jz,{...s,...i,config:t});case"multi-select":return r.jsx(Kz,{...s,...i,config:t});case"tree-select":return r.jsx(iI,{...s,...i,config:t});case"text-input":return r.jsx(Zz,{...s,...i,config:t});case"date-range":return r.jsx(jh,{...s,...i,config:t});case"checkbox":return r.jsx($z,{...s,...i,config:t});default:return null}}),oI=D.observer(g.forwardRef(({filter:e,...t},n)=>r.jsx("div",{className:"filter-root",ref:n,children:r.jsx(ze,{children:r.jsx(aI,{filter:e,formFieldProps:t})})}))),lI=({disabled:e})=>{const{searchButtonProps:t}=Tc(),{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 cI(e){const t=Y();g.useEffect(()=>{var n,s;(s=(n=t.filters).updatePreviewValues)==null||s.call(n,e)},[e])}const uI=({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")})})},wh=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});g.useEffect(()=>{c(i.filters.values)},[i.filters.values,c]),cI(u);const d=i.filters.visibleInView(t.id),p=g.useMemo(()=>d.every(y=>y.should_auto_submit),[d]),h=g.useMemo(()=>d.filter(y=>v.get(y,"config.required",!1)),[d]),f=g.useMemo(()=>h.length===0?!1:h.some(y=>!y.requiredAndPass(u[y.key])),[u,h]);if(d.length===0)return null;const x=(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(uI,{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(oI,{filter:y,value:j.value,onChange:x(y,j.onChange)})},y.id))}),!p&&r.jsx(o.Group,{sx:{alignSelf:"flex-end"},children:r.jsx(lI,{disabled:f})})]})})]})}),dI={viewPanelInFullScreen:v.noop,inFullScreen:!1},si=g.createContext(dI),Go=m.types.model("MockContextMeta",{current:m.types.optional(m.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 Wo(e){return{current:e}}const pI=m.types.model("PanelStyleBorderMeta",{enabled:m.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),Ch=m.types.model("PanelStyleMeta",{border:pI}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),Sh=m.types.model("PanelTitleMeta",{show:m.types.optional(m.types.boolean,!0)}).views(e=>({get json(){const{show:t}=e;return{show:t}}})).actions(e=>({setShow(t){e.show=t}})),kh=m.types.model("VariableMeta",{name:m.types.string,size:m.types.string,weight:m.types.string,color:m.types.union(m.types.model({type:m.types.literal("static"),staticColor:m.types.string}),m.types.model({type:m.types.literal("continuous"),valueRange:m.types.array(m.types.number),colorRange:m.types.array(m.types.string)}),m.types.model({type:m.types.literal("piecewise")})),formatter:m.types.model({output:m.types.enumeration("Output",["number","percent"]),average:m.types.optional(m.types.boolean,!1),mantissa:m.types.number,trimMantissa:m.types.optional(m.types.boolean,!1),absolute:m.types.optional(m.types.boolean,!1)}),data_field:m.types.string,aggregation:m.types.union(m.types.model({type:m.types.enumeration(["none","sum","mean","median","min","max","CV","std"]),config:m.types.frozen(),fallback:m.types.optional(m.types.string,"0")}),m.types.model({type:m.types.literal("quantile"),config:m.types.model({p:m.types.number}),fallback:m.types.optional(m.types.string,"0")}),m.types.model({type:m.types.literal("pick_record"),config:m.types.model({method:m.types.enumeration("Pick Record Method",["first","last"])}),fallback:m.types.optional(m.types.string,"0")}),m.types.model({type:m.types.literal("custom"),config:m.types.model({func:m.types.string}),fallback:m.types.optional(m.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})}})),Th=m.types.model("PanelVizMeta",{type:m.types.string,conf:m.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}})),Dh=m.types.model({id:m.types.string,name:m.types.optional(m.types.string,""),title:Sh,description:m.types.string,queryIDs:m.types.array(m.types.string),viz:Th,style:Ch,variables:m.types.optional(m.types.array(kh),[])}).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=m.cast(Array.from(n))},setQueryIDs(t){e.queryIDs=m.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 Mh=m.types.model("QueryMeta",{id:m.types.string,name:m.types.string,type:m.types.enumeration("DataSourceType",[ye.Postgresql,ye.MySQL,ye.HTTP,ye.Transform]),key:m.types.string,sql:m.types.string,pre_process:m.types.optional(m.types.string,""),post_process:m.types.optional(m.types.string,""),run_by:m.types.optional(m.types.array(m.types.string),[]),react_to:m.types.optional(m.types.array(m.types.string),[]),dep_query_ids:m.types.optional(m.types.array(m.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 Bn({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)}})),zh=m.types.model("LayoutItemMeta",{id:m.types.identifier,panelID:m.types.string,x:m.types.number,y:m.types.maybeNull(m.types.number),w:m.types.number,h:m.types.number,moved:m.types.optional(m.types.boolean,!1),static:m.types.optional(m.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 m.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}})),Ih=m.types.model("LayoutSetMeta",{id:m.types.identifier,name:m.types.string,breakpoint:m.types.number,list:m.types.optional(m.types.array(zh),[])}).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=>Bn(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=>Bn(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:Wt.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)}})),Eh=m.types.model("SQLSnippetMeta",{key:m.types.string,value:m.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 Ro=m.types.model("FilterCheckboxConfigMeta",{_name:m.types.literal("checkbox"),description:m.types.optional(m.types.string,""),default_value:m.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}})),Ah=()=>Ro.create({_name:"checkbox",description:"",default_value:!1});function Ph(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 hI=m.types.model("FilterDateRangeConfigMeta",{_name:m.types.literal("date-range"),required:m.types.boolean,inputFormat:m.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:m.types.optional(m.types.array(m.types.union(m.types.string,m.types.null)),[null,null]),default_shortcut:m.types.optional(m.types.string,""),clearable:m.types.boolean,max_days:m.types.optional(m.types.number,0),allowSingleDateInRange:m.types.optional(m.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:Ph(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=m.getParent(e);m.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=vh(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}})),Qo=m.types.snapshotProcessor(hI,{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:Ph(t,n.inputFormat)}}}),Oh=()=>Qo.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),fI=m.types.model({label:m.types.string,value:m.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),Uo=m.types.model("FilterConfigModel_BaseSelect",{static_options:m.types.optional(m.types.array(fI),[]),options_query_id:m.types.optional(m.types.string,""),default_selection_count:m.types.optional(m.types.number,0),required:m.types.optional(m.types.boolean,!1)}).views(e=>({get contentModel(){return m.getRoot(e).content},get filter(){return m.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??""}})),Yo=m.types.compose("FilterMultiSelectConfigMeta",m.types.model({_name:m.types.literal("multi-select"),min_width:m.types.optional(m.types.string,""),default_value:m.types.optional(m.types.array(m.types.string),[])}),Uo).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 Bn({_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=m.cast(t)},setMinWidth(t){e.min_width=t},setDefaultSelection(){const t=m.getRoot(e).content.filters,n=m.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(){m.addDisposer(e,X.reaction(()=>X.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!0,delay:0}))}})),Lh=()=>Yo.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),Ko=m.types.compose("FilterConfigModel_Select",m.types.model({_name:m.types.literal("select"),default_value:m.types.string,width:m.types.optional(m.types.string,""),clearable:m.types.optional(m.types.boolean,!1)}),Uo).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 Bn({_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=m.getRoot(e).content.filters,n=m.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(){m.addDisposer(e,X.reaction(()=>X.toJS(e.default_selection),e.setDefaultSelection,{fireImmediately:!1,delay:0}))}})),Bh=()=>Ko.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),Xo=m.types.model("FilterTextInputConfigMeta",{_name:m.types.literal("text-input"),required:m.types.boolean,default_value:m.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}})),Jo=()=>Xo.create({_name:"text-input",required:!1,default_value:""});function gI(e){return jg.arrayToTree(e,{id:"value",parentId:"parent_value",childrenField:"children",dataField:null})}function mI(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=g.createElement("div",{},[g.createElement(o.Text,{key:0,title:t.label},t.label),g.createElement(o.Text,{key:1,className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description},t.description)])),a})}const Zo=m.types.compose("FilterTreeSelectConfigMeta",m.types.model({_name:m.types.literal("tree-select"),min_width:m.types.optional(m.types.string,""),default_value:m.types.optional(m.types.array(m.types.string),[]),treeCheckStrictly:m.types.optional(m.types.boolean,!1)}),Uo).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=mI(t);return gI(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=m.cast(t)},setMinWidth(t){e.min_width=t},setTreeCheckStrictly(t){e.treeCheckStrictly=t},applyDefaultSelection(){const t=m.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(){m.addDisposer(e,X.reaction(()=>JSON.stringify(e.defaultSelection),this.applyDefaultSelection,{fireImmediately:!0,delay:0}))}})),qh=()=>Zo.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),Ho=m.types.model("FilterMeta",{id:m.types.identifier,key:m.types.string,label:m.types.string,order:m.types.number,visibleInViewsIDs:m.types.array(m.types.string),auto_submit:m.types.optional(m.types.boolean,!1),default_value_func:m.types.optional(m.types.string,""),type:m.types.enumeration("DashboardFilterType",[ce.Select,ce.MultiSelect,ce.TreeSelect,ce.TextInput,ce.Checkbox,ce.DateRange]),config:m.types.union(Ko,Yo,Zo,Xo,Ro,Qo)}).views(e=>({get contentModel(){return m.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=Bh();break;case ce.MultiSelect:e.config=Lh();break;case ce.TreeSelect:e.config=qh();break;case ce.TextInput:e.config=Jo();break;case ce.Checkbox:e.config=Ah();break;case ce.DateRange:e.config=Oh();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 el=m.types.model("ViewDivisionConfig",{_name:m.types.literal(q.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})),Vh=()=>el.create({_name:q.Division}),xI=m.types.model("CustomModalTitleModel",{enabled:m.types.optional(m.types.boolean,!1),func_content:m.types.optional(m.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=m.getParent(e,2),i=m.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}})),ii={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
|
|
445
|
+
`)},tl=m.types.model("ViewModalConfig",{_name:m.types.literal(q.Modal),width:m.types.string,height:m.types.string,custom_modal_title:m.types.optional(xI,ii)}).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}})),Nh=()=>tl.create({_name:q.Modal,width:"90vw",height:"90vh"}),yI=m.types.model("ViewTabsTabModel",{id:m.types.identifier,name:m.types.string,view_id:m.types.string,color:m.types.optional(m.types.string,""),order:m.types.optional(m.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}})),nl=m.types.model("ViewTabsConfig",{_name:m.types.literal(q.Modal),tabs:m.types.optional(m.types.array(yI),[]),variant:m.types.optional(m.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:m.types.optional(m.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:m.types.optional(m.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=m.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)}})),$h=()=>nl.create({_name:q.Modal,tabs:[]}),Fh=m.types.model({id:m.types.identifier,name:m.types.string,type:m.types.enumeration("EViewComponentType",[q.Division,q.Modal,q.Tabs]),config:m.types.union(el,tl,nl),panelIDs:m.types.optional(m.types.array(m.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=Vh();break;case q.Modal:e.config=Nh();break;case q.Tabs:e.config=$h();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)}})),Zt="11.10.0",bI={definition:{sqlSnippets:[],queries:[],mock_context:{}},views:[{id:"Main",name:"Main",type:q.Division,config:{},panelIDs:[]}],panels:[],filters:[],version:Zt,layouts:[{id:"basis",name:"basis",list:[],breakpoint:0}]},rl=m.types.model("DataSourceMetaModel",{id:m.types.string,type:m.types.enumeration("DataSourceType",[ye.HTTP,ye.MySQL,ye.Postgresql]),key:m.types.string,config:m.types.frozen()}),Gh=m.types.model("DataSourcesMetaModel",{list:m.types.optional(m.types.array(rl),[])}).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)}})),Wh=m.types.model({id:m.types.string,content:m.types.string,create_time:m.types.string,update_time:m.types.string,is_preset:m.types.boolean}),sl=m.types.model("GlobalSQLSnippetsMeta",{list:m.types.optional(m.types.array(Wh),[])}).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)}})),ai=m.types.model("ContextMeta",{current:m.types.optional(m.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 il(e){return ai.create({current:e})}const al=m.types.compose("ViewRenderModel",Fh,m.types.model({tab:m.types.optional(m.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 m.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 oc,a=new Date().getTime(),l=await ac.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=>{ts.saveAs(c,`${e.name}_${a}.zip`)}).catch(c=>{console.error(c),tn.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??""}})),ol=m.types.model("ViewsRenderModel",{current:m.types.optional(m.types.array(al),[]),visibleViewIDs:m.types.array(m.types.string)}).views(e=>({get json(){return e.current.map(t=>Bn(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 Rh(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 vI=new wg.AsyncParser({withBOM:!0});async function Qh(e){return!Array.isArray(e)||e.length===0?"":await vI.parse(e).promise()}async function _I(e,t){const n=await Qh(t),s=new Blob([n],{type:"text/csv"});ts.saveAs(s,`${e}.csv`)}function Uh(e){const t=new oc,n=e.map(async({id:s,data:i})=>{const a=await Qh(i);t.file(`${s}.csv`,a)});Promise.all(n).then(()=>{t.generateAsync({type:"blob"}).then(s=>{ts.saveAs(s,"dashboard_data.zip")})}).catch(s=>{console.error(s),tn.notifications.show({color:"red",title:"Failed to download data",message:s.message})})}function sr(e,t){const n=new Blob([t],{type:"application/json"});ts.saveAs(n,`${e}.json`)}const ll=Dh.views(e=>({get contentModel(){return m.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 gc(e.variables,this.data)},get variableValueMap(){const t={},n=this.data;return e.variables.reduce((s,i)=>{const a=_t(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:Zt},null,2),l=e.name;sr(l,a)}}));function Yh(e){return{id:e,name:"Panel",title:{show:!0},description:"<p></p>",queryIDs:[],viz:{type:Mo.name,conf:Mo.createConfig()},style:{border:{enabled:!0}}}}const cl=m.types.model("PanelsRenderModel",{list:m.types.optional(m.types.array(ll),[])}).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 Kh(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=vh(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 jI(e,t){const n=e.default_value_func;try{return new Function(`return ${n}`)()(e,At,t)}catch(s){return console.error(s),Kh(e)}}function Xh(e,t){var n;return(n=e.default_value_func)!=null&&n.trim()?jI(e,t):Kh(e)}function Jh(e,t){return e.reduce((n,s)=>(n[s.key]=Xh(s,t),n),{})}const ul=m.types.model("FiltersRenderModel",{current:m.types.optional(m.types.array(Ho),[]),values:m.types.optional(m.types.frozen(),{})}).views(e=>({get json(){return e.current.map(t=>t.json)},get valuesString(){return JSON.stringify(e.values)},get contentModel(){return m.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 Jh(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:Zt}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t,!1),null,2);sr("Filters",n)}}));function dl(e,t,n,s){const i=v.defaults({},s,Jh(e,{...n,...t}));return{current:e,values:i}}const Zh=Mh.views(e=>({get rootModel(){return m.getRoot(e)},get contentModel(){return this.rootModel.content},get conditionOptions(){if(!m.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(!m.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 wi(e.sql,this.payload)},get httpConfigString(){const{context:t,filters:n}=this.payload,{name:s,pre_process:i}=e.json,a=Om(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 m.getParent(e,2)},get inUse(){return this.queries.isQueryInUse(e.id)},get dependencies(){if(!this.typedAsSQL)return[];const t=v.uniq(e.sql.match(is.sqlSnippet)),n=v.uniq(e.sql.match(is.filter)),s=v.uniq(e.sql.match(is.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}})),pl=m.types.compose("QueryRenderModel",Zh,m.types.model({state:m.types.optional(m.types.enumeration(["idle","loading","error"]),"idle"),data:m.types.optional(m.types.frozen([]),[]),error:m.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:m.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*m.toGenerator(Nm({payload:n,name:e.name,query:e.json,additionals:e.additionalQueryInfo},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(!It.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:m.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=Lm(e.datasource,a);const l=yield*m.toGenerator($m({type:n,key:s,configString:JSON.stringify(a),name:e.name,additionals:e.additionalQueryInfo},e.controller.signal)),c=Bm(e.datasource,l),u=qm(i,c,e.contentModel.dashboardState);e.data=u,e.state="idle",e.error=null}catch(n){if(console.error(n),!It.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,At);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(){m.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}))}})),hl=m.types.model("QueriesRenderModel",{current:m.types.optional(m.types.array(pl),[])}).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 m.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}));Uh(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}));Uh(s)},downloadDataByQueryID(t){const n=e.findByID(t);if(!n){console.log("[downloadDataByQueryID] query not found");return}const{name:s,data:i}=n;_I(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:Zt}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t),null,2);sr("Queries",n)}}));function Hh(e){return{current:e}}function ef({min:e,max:t}){const n=`${e}px`,s=Number.isFinite(t)?`${t}px`:"∞";return`[${n}, ${s})`}const fl=m.types.model("LayoutsRenderModel",{list:m.types.array(Ih),currentBreakpoint:m.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 m.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 ef(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=ef(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(){m.addDisposer(e,X.reaction(()=>e.currentBreakpoint,()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},{fireImmediately:!1,delay:0}))}})),tf=Eh.views(e=>({isADuplicatedKey(t){return!t||t===e.key?!1:!!m.getParent(e,2).findByKey(t)}})),gl=m.types.model("SQLSnippetsRenderModel",{current:m.types.optional(m.types.array(tf),[])}).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:Zt}},downloadSchema(t){const n=JSON.stringify(this.getSchema(t),null,2);sr("SQL Snippets",n)}}));function nf(e){return{current:e}}function Rr(e,t,n,s){return e.reduce((i,a)=>{try{i[a[t]]=ji(a[n],s)}catch(l){i[a[t]]=l.message}return i},{})}class rf{constructor(t){B(this,"origin");B(this,"copy");this.origin=t,this.copy=m.clone(t),X.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!v.isEqual(m.getSnapshot(this.origin),m.getSnapshot(this.copy))}commit(){m.applySnapshot(this.origin,m.getSnapshot(this.copy))}reset(){m.applySnapshot(this.copy,m.getSnapshot(this.origin))}update(t){m.applySnapshot(this.copy,t)}}const sf=e=>new rf(e),wI=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))]})}),CI=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}=g.useContext(si),h=()=>{i.duplicatePanelByID(u,e.id)},f=()=>{s.editor.open(["_VIEWS_",e.id,"_PANELS_",u])},x=()=>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=g.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(wI,{}),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:x,icon:r.jsx(V.Trash,{size:14}),children:n("common.actions.delete")})]})]})})})});function SI(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const ml=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState(!1),{panel:s}=Qt();return SI(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(Us,{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})})})]})}),hL="",kI=D.observer(function(){const{panel:t}=Qt(),{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 TI(e){const t=g.useRef(null);return{ref:t,downloadPanelScreenshot:()=>{const s=t.current;if(!s)return;const i=s.offsetWidth*2,a=s.offsetHeight*2;ac.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 af=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(af||{}),oi=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(oi||{});class DI{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 of(e){const{panel:t}=Qt();return g.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 Ni(l,i,cs)}).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 DI(a))},[e.viz.type,e.viz.conf])}function lf(e){const[t,n]=g.useState(!1),s=bh().getRequired(je.instanceScope.migrator);return W.useAsyncEffect(async()=>{const i=s.status===oi.notStarted;n(s.status===oi.done),s.status===oi.notStarted&&s.runMigration().then(a=>{a===af.migrated&&i&&(e==null||e())}).finally(()=>{n(!0)})},[s]),t}function cf(e,t){const n=bh().getRequired(je.instanceScope.vizInstance);return g.useEffect(()=>(n.instanceData.setItem(null,t.viz.conf),n.instanceData.watchItem(null,s=>{e(s)})),[e,t.viz.type]),n}function MI({setVizConf:e,...t}){const{panel:n}=t,s=cf(e,n),i=lf(()=>{tn.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(Rm,{...t}):r.jsx(o.Text,{children:"Checking update..."})}function zI(e){const{panel:t,setVizConf:n}=e;cf(n,t);const{inEditMode:s}=g.useContext(os);return lf(()=>{s&&tn.showNotification({title:`${t.name} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?r.jsx(Wm,{...e}):r.jsx(o.Text,{children:"Checking update"})}const fL="";function II(e,t){const{vizManager:n}=g.useContext(Nt),{panel:{viz:s,title:i,id:a,name:l,description:c,queryIDs:u,variables:d}}=Qt(),p={id:a,name:l,title:i,description:c,queryIDs:u,viz:s},h=of(p);try{return n.resolveComponent(s.type),r.jsx(ri,{configure:h,children:r.jsx(zI,{setVizConf:s.setConf,panel:p,measure:t,data:e,variables:d,vizManager:n})})}catch(f){return console.info(v.get(f,"message")),null}}const uf=D.observer(function({data:t}){const{ref:n,width:s,height:i}=he.useElementSize(),a=II(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})})})}),df=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})]})),xl=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(df,{panel:e}),e.canRenderViz&&r.jsx(uf,{data:e.data})]})),EI={border:"1px solid #e9ecef"},pf=D.observer(({panel:e,panelStyle:t,dropdownContent:n})=>{const{ref:s,downloadPanelScreenshot:i}=TI(e);return e.title.show,r.jsx(Oi,{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:{...EI,...t},children:[r.jsx(o.Box,{className:"panel-description-popover-wrapper",children:r.jsx(ml,{})}),n,r.jsx(kI,{}),r.jsx(xl,{panel:e})]})})}),AI={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function PI(e){return e.style.border.enabled?{}:AI}const hf=D.observer(function({panel:t,view:n}){const s=PI(t);return r.jsx(pf,{panel:t,panelStyle:s,dropdownContent:r.jsx(CI,{view:n,title:t.name})})});function OI(e){return!["richText","button"].includes(e)}const LI=D.observer(({view:e,title:t})=>{const{t:n}=_.useTranslation(),{panel:s,downloadPanelScreenshot:i}=Qt(),{id:a}=s,{viewPanelInFullScreen:l,inFullScreen:c}=g.useContext(si),u=g.useCallback(()=>{l(a)},[a,l]),d=!c&&e.type!==q.Modal;return OI(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 BI(e){return e.style.border.enabled?{}:{border:"1px dashed transparent"}}const yl=D.observer(({panel:e,view:t})=>{const n=BI(e);return r.jsx(pf,{panel:e,panelStyle:n,dropdownContent:r.jsx(LI,{title:e.name,view:t})})}),qI={modal:{display:"flex",flexDirection:"column",flexWrap:"nowrap"},body:{display:"flex",height:"calc(100vh - 88px)"}},ff=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:qI,children:r.jsx(o.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:r.jsx(yl,{view:t,panel:n})})})});function gf(e,t,n){const{panels:s}=_e(),i=e.id==="Main",[a,l]=g.useState(()=>i&&s.findByID(t)?t:null),c=g.useCallback(h=>{l(h),i&&n(h)},[i,n]),u=g.useCallback(()=>{l(null),i&&n("")},[i,n]),d=a?s.findByID(a):null;return{viewPanelInFullScreen:c,exitFullScreen:u,inFullScreen:!!d,fullScreenPanel:d}}const gL="",VI=g.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})})),NI=g.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})})),$I=es.WidthProvider(es.Responsive),FI=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($I,{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(NI,{}),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(VI,{h:d.h}),r.jsx(hf,{view:e,panel:d.panel})]},d.id))})}),GI=es.WidthProvider(es.Responsive),WI=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(GI,{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(yl,{view:e,panel:a.panel})},a.id))})});function bl(e){const t=g.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 RI=D.observer(({downloadScreenshot:e})=>{const{t}=_.useTranslation(),[n,{setTrue:s,setFalse:i}]=W.useBoolean(!1),a=Sc(),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")})]})]})}),mf=D.observer(({children:e,view:t,sx:n={}})=>{const{ref:s,downloadScreenshot:i}=bl(t);return r.jsxs(r.Fragment,{children:[r.jsx(o.Box,{ref:s,pt:10,pb:10,sx:n,children:e}),r.jsx(RI,{downloadScreenshot:i})]})}),xf=D.observer(({downloadScreenshot:e})=>r.jsx(o.ActionIcon,{className:"download-screenshot-button",color:"blue",onClick:e,children:r.jsx(M.IconCamera,{size:14})})),QI=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}=bl(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(xf,{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})})}),UI=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},YI=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:UI(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(li,{view:i})},s.id):null})]})}),KI=D.observer(({view:e,children:t})=>{switch(e.type){case q.Modal:return r.jsx(QI,{view:e,children:t});case q.Tabs:return r.jsx(YI,{view:e});case q.Division:default:return r.jsx(mf,{view:e,children:t})}}),XI=D.observer(({children:e,view:t})=>{const s=Y().layouts,[i,a]=he.useResizeObserver();return g.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(mf,{view:t,sx:{paddingTop:"0px !important",".dashboard-sticky-area > form":{paddingBottom:"5px"},".dashboard-layout":{marginTop:0,marginBottom:0}},children:e})})})});function yf(e){return e.replace(/(vw|vh)/,"%")}const JI=D.observer(({children:e,view:t})=>{const n=t.config,{width:s,height:i}=g.useMemo(()=>({width:yf(n.width),height:yf(n.height)}),[n.width,n.height]),{ref:a,downloadScreenshot:l}=bl(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(xf,{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})})})}),ZI=({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},HI=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},eE=D.observer(({view:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Y(),i=g.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:ZI(a),children:[r.jsxs(o.Tabs.List,{grow:a.grow,children:[a.tabsInOrder.map(u=>r.jsx(o.Tabs.Tab,{value:u.id,sx:HI(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(li,{view:p})]},u.id)})]})}),tE=D.observer(({view:e,children:t})=>{switch(e.type){case q.Modal:return r.jsx(JI,{view:e,children:t});case q.Tabs:return r.jsx(eE,{view:e});case q.Division:default:return r.jsx(XI,{view:e,children:t})}}),bf=D.observer(function({view:t}){const s=Y().layouts.divisionPreviewScale!==1;return r.jsx(si.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(tE,{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(wh,{view:t})}),r.jsx(FI,{view:t})]})})})})}),li=D.observer(function({view:t}){const{fullScreenPanelID:n,setFullScreenPanelID:s}=Ec(),{viewPanelInFullScreen:i,exitFullScreen:a,inFullScreen:l,fullScreenPanel:c}=gf(t,n,s);return r.jsx(si.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(ff,{view:t,panel:c,exitFullScreen:a}),r.jsx(KI,{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(wh,{view:t})}),!l&&r.jsx(WI,{view:t})]})})]})})});var vf=(e=>(e.Use="use",e.Edit="edit",e))(vf||{});const nE={[q.Division]:"Division",[q.Tabs]:"Tabs",[q.Modal]:"Modal"},_f={[q.Division]:"rgba(255, 0, 0, 0.2)",[q.Modal]:"rgba(0, 0, 0, 0.2)",[q.Tabs]:"rgba(255, 200, 100, 0.4)"},rE={[q.Division]:"#ff4000",[q.Modal]:"#000",[q.Tabs]:"#ffad18"};function sE(e,t,n){m.addDisposer(e,m.addMiddleware(e,(s,i)=>{i(s,()=>{m.getType(s.context)===t&&s.type==="action"&&n(s.name,s.context)})}))}const jf=m.types.compose("FiltersModel",ul,m.types.model("FiltersModel",{previewValues:m.types.optional(m.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=m.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(){sE(e.current,Ho,(n,s)=>{if(n==="setType"){const i=Xh(s.config.default_value,s.config);e.setValueByKey(s.key,i),e.updatePreviewValues({...e.previewValues,[s.key]:i})}})}return{afterCreate(){t()}}}),wf=pl.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"}})),Cf=m.types.compose("QueriesModel",hl,m.types.model({current:m.types.optional(m.types.array(wf),[])})).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=m.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&&(m.detach(n),e.current.remove(n))},removeQueries(t){const n=new Set(t);e.current.forEach(i=>{n.has(i.id)&&m.detach(i)});const s=[...e.current];v.remove(s,i=>n.has(i.id)),e.current=m.cast(s)}})),Sf=gl.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=m.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)&&m.detach(i)});const s=[...e.current];v.remove(s,i=>n.has(i.key)),e.current=m.cast(s)},replaceByIndex(t,n){e.current.splice(t,1,n)}})),iE=m.types.model({data:m.types.optional(m.types.frozen(),[]),state:m.types.optional(m.types.enumeration(["idle","loading","error"]),"idle"),error:m.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),aE=m.types.model({data:m.types.optional(m.types.frozen(),[]),state:m.types.optional(m.types.enumeration(["idle","loading","error"]),"idle"),error:m.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return e.data.length===0}})),oE=m.types.model({page:m.types.optional(m.types.number,1),limit:m.types.optional(m.types.number,20),data:m.types.optional(m.types.frozen(),[]),total:m.types.optional(m.types.number,0),state:m.types.optional(m.types.enumeration(["idle","loading","error"]),"idle"),error:m.types.frozen()}).views(e=>({get keywords(){return m.getParent(e,1)},get keywordString(){const{table_name:t,table_schema:n}=m.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
446
|
SELECT count(*) AS total
|
|
447
|
-
FROM ${n}.${
|
|
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}))}})),zk=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}})),Mk=x.types.compose("DataSourceModel",ai,x.types.model({tables:x.types.optional(zk,{}),columns:x.types.optional(kk,{}),tableData:x.types.optional(Dk,{}),indexes:x.types.optional(Tk,{}),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 a=b.get(i,"message","unkown error");n.error=b.get(i,"response.data.detail.message",a),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}))}})),Ik=x.types.model("DataSourcesModel",{list:x.types.optional(x.types.array(Mk),[])}).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 Bt(t){return{label:t,value:t,_type:"ACTION",_action_type:t,Icon:null,children:null}}function Ek(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 Ak=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:a}=e;return[{label:"query_variable.labels",value:"_QUERY_VARS_",_type:"query_variables",Icon:k.IconVariable},{label:"mock_context.label",value:"_MOCK_CONTEXT_",Icon:k.IconCodeDots,_type:"mock_context"},{label:"filter.labels",value:"_FILTERS_",Icon:k.IconFilter,children:[Bt("_FILTERS_SETTINGS_"),...n.options,Bt("_Add_A_Filter_")],_type:"GROUP"},{label:"sql_snippet.labels",value:"_SQL_SNIPPETS_",Icon:k.IconCopy,children:[Bt("_SQL_SNIPPETS_SETTINGS_"),...i.options,Bt("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"query.labels",value:"_QUERIES_",Icon:k.IconDatabase,children:[Bt("_QUERIES_SETTINGS_"),...a.options,Bt("_Add_A_QUERY_")],_type:"GROUP"},{label:"view.labels",value:"_VIEWS_",Icon:k.IconBoxMultiple,children:[...r.editorOptions,Bt("_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=Ek(e);n&&t.setPath(n)}})),Pk=x.types.compose("LayoutsModel",fi,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,a={id:e,name:n,breakpoint:r,list:i.json.list.map(l=>({...l,id:pt.v4()}))};t.list.push(a)},updateLayoutSetsInfo(e){const n=b.keyBy(t.list,"id");e.forEach(a=>{const l=n[a.id];if(l){l.setName(a.name),l.setBreakpoint(a.breakpoint),delete n[a.id];return}this.addALayoutSet(a.id,a.name,a.breakpoint)});const r=new Set(Object.keys(n)),i=r.size>0;r.forEach(a=>{const l=t.list.findIndex(c=>c.id===a);t.list.splice(l,1)}),i&&t.setCurrentBreakpoint("basis")},updateCurrentLayoutItem(e){t.currentLayoutSet.updateLayoutItem(e)},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)})}})),Pc=di.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(a=>a.group_id===r)),e&&!i.find(a=>a.value===e)){const a=E(e),l=t.queryByID(a.queryID);i.unshift({label:a.columnKey,value:e,group:l?l.name:a.queryID,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}=E(e),i=t.queries.find(a=>a.id===n);return i?{queryID:n,queryName:i.name,columnKey:r}:{queryID:n,queryName:null,columnKey:r}}})).actions(t=>({removeSelf(){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])}})),$c=x.types.compose("PanelsModel",pi,x.types.model({list:x.types.optional(x.types.array(Pc),[])})).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})),a="_Add_A_PANEL_";return i.push({label:a,value:a,_type:"ACTION",_action_type:a,parentID:e,Icon:null,children:null}),i}})).actions(t=>({replace(e){t.list=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)}})),$k=ci.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:ft}},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;Ht(n,e)}})),Bc=x.types.compose("ViewsModel",ui,x.types.model({current:x.types.optional(x.types.array($k),[]),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(a=>a.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 wi(t){const e=t.length>0?[t[0].id]:[],n=t.length>0?t[0].id:"";return{current:t.map(i=>{const{_name:a=i.type}=i.config;return{...i,config:{...i.config,_name:a},panelIDs:i.panelIDs}}),visibleViewIDs:e,idOfVIE:n}}const Bk=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:Mc,queries:Ec,sqlSnippets:Ac,views:Bc,panels:$c,layouts:Pk,mock_context:Rr,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:vn(t.sqlSnippets.current,"key","value",n),global_sql_snippets:vn(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(a=>{const l=e.get(a);if(!l)return;const c="panel",u=l.name,d=[{id:i.id,label:i.name}];l.queryIDs.forEach(p=>{n.push({id:a,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(a=>{var l;return{id:a,label:((l=r.get(a))==null?void 0:l.name)??a}})})}),t.queries.current.forEach(i=>{i.isTransform&&i.dep_query_ids.forEach(a=>{n.push({type:"transform-query",type_label:"query.transform.full_label",id:i.id,queryID:a,label:i.name,views:[]})})}),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(In.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(sc(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:a={},layouts:l}=e,{queries:c,sqlSnippets:u,mock_context:d}=a,p=new Map;if(Array.isArray(r)){const g=r.map(y=>{const v=pt.v4();return p.set(y.id,v),{...y,id:v}});if(t.panels.appendMultiple(g),!Array.isArray(n)||n.length===0){const y=g.map(v=>v.id);(h=t.views.VIE)==null||h.appendPanelIDs(y)}}if(Array.isArray(n)){const g=n.map(y=>{const v=y.panelIDs.map(w=>p.get(w)??w);return{...y,id:pt.v4(),panelIDs:v}});t.views.appendMultiple(g)}if(Array.isArray(l)){const g=(w,T)=>t.layouts.breakpointNameRecord[w]===T;let y=[];const v=l.filter(w=>g(w.name,w.breakpoint));v.forEach(w=>{w.id==="basis"&&(y=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){y.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:a,filters:l,views:c,panels:u,definition:{queries:d,sqlSnippets:p,mock_context:h={}}}=i;t.id=n,t.name=r,t.version=a,x.applySnapshot(t.filters.current,l),x.applySnapshot(t.views.current,wi(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}})),Ci=x.types.snapshotProcessor(Bk,{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 Lk(t,e){e.filters&&x.applySnapshot(t.filters.current,e.filters)}function Lc({id:t,name:e,dashboard_id:n,create_time:r,update_time:i,content:a},l,c){if(!a)throw new Error("unexpected null content when creating a content model");const{version:u,filters:d,views:p,panels:h,layouts:g,definition:{queries:y,sqlSnippets:v,mock_context:w={}}}=a;return Ci.create({id:t,name:e,dashboard_id:n,create_time:r,update_time:i,version:u,filters:mi(d,l,w,c),queries:{current:y},sqlSnippets:{current:v},mock_context:Ur(w),views:wi(p),panels:{list:h},layouts:{list:g,currentBreakpoint:g[0].id}})}const qc=x.types.model({id:x.types.identifier,name:x.types.string,group:x.types.string,content:Ci,content_id:x.types.string,datasources:Ik,globalSQLSnippets:oi,context:us,editor:Ak}).views(t=>({get json(){return{id:t.id,name:t.name,group:t.group,content_id:t.content_id}}})).actions(t=>({updateCurrentContent(e){t.content.updateCurrent(e)},updateCurrent(e,n){const{id:r,name:i,group:a,content_id:l}=e;t.id=r,t.name=i,t.group=a,t.content_id=l,this.updateCurrentContent(n)}}));function Oc({id:t,name:e,group:n,content_id:r},i,a,l,c,u){return qc.create({id:t,name:e,group:n,content_id:r,content:Lc(i,c,u),datasources:{list:a},globalSQLSnippets:{list:l},context:li(c),editor:{}})}const qk={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"},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"}}}},Ok={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:"加一个分段"},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=yd.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:qk,zh:Ok}}).use(bd).use(_.initReactI18next);hs.init(),kl.forEach(t=>{var e;(e=t.translation)==null||e.forEach(n=>{hs.addResourceBundle(n.lang,"translation",{viz:n.resources},!0,!0)})});function Vc({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 Nc(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:a}=r.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=b.get(a,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 a={},{filter_keys:l}=i.detail;l.forEach(c=>{const u=b.get(t.filters.values,c),d=n(u);a[c]=d}),t.filters.applyValuesPatch(a)};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:a,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,y=>{if(l&&typeof y=="string")return encodeURIComponent(y)})}const p=b.template(i||"")(u({...c,filters:t.payloadForSQL.filters,context:t.payloadForSQL.context}));window.open(p,a?"_blank":"_self","noopener")};return window.addEventListener("open-link",n),()=>{window.removeEventListener("open-link",n)}},[t])}function Gc(t){return m.useCallback(e=>e.provideValue(me.pluginManager,t.pluginManager).provideValue(me.vizManager,t.vizManager).provideValue(me.colorManager,t.colorManager),[])}const GM="",Vk=S.observer(({saveDashboardChanges:t})=>{const{t:e}=_.useTranslation(),n=Fe.useModals(),r=Y(),i=()=>{n.openConfirmModal({title:s.jsxs(o.Group,{position:"left",children:[s.jsx(k.IconAlertTriangle,{size:18,color:"red"}),s.jsx(o.Text,{children:"You are reverting changes"})]}),labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},confirmProps:{color:"red"},onCancel:()=>console.log("Cancel"),onConfirm:()=>r.reset(),zIndex:320,withCloseButton:!1})},a=r.changed;return s.jsxs(o.Group,{spacing:0,children:[s.jsx(o.Button,{color:"green",variant:"filled",size:"xs",leftIcon:s.jsx(k.IconDeviceFloppy,{size:18}),onClick:t,disabled:!a,sx:{borderTopRightRadius:0,borderBottomRightRadius:0},children:e("common.actions.save_changes")}),s.jsxs(o.Menu,{width:200,trigger:"hover",openDelay:100,closeDelay:400,withinPortal:!0,zIndex:320,disabled:!a,children:[s.jsx(o.Menu.Target,{children:s.jsx(o.ActionIcon,{variant:"default",disabled:!a,sx:{height:"30px",borderTopLeftRadius:0,borderBottomLeftRadius:0,svg:{fill:"rgb(173, 181, 189)",stroke:"none"}},children:s.jsx(k.IconCaretDown,{size:18})})}),s.jsx(o.Menu.Dropdown,{children:s.jsx(o.Menu.Item,{icon:s.jsx(k.IconRecycle,{size:14,color:"red"}),disabled:!a,onClick:i,children:e("common.actions.revert_changes")})})]})]})}),Nk=S.observer(({saveDashboardChanges:t,onExit:e,headerSlot:n=null})=>{_.useTranslation();const r=Z(),i=r.content.changed,a=()=>{e({hasChanges:i,dashboardId:r.id})};return s.jsx(o.Header,{height:60,px:"md",py:0,sx:{zIndex:299},children:s.jsxs(o.Group,{position:"apart",sx:{height:60,minWidth:"1000px",position:"relative"},children:[s.jsxs(o.Group,{children:[s.jsx(o.Button,{size:"xs",color:i?"red":"green",leftIcon:s.jsx(k.IconArrowLeft,{size:20}),onClick:a,children:s.jsx(o.Group,{spacing:4,children:s.jsxs(_.Trans,{i18nKey:"common.actions.end_editing",values:{name:r.name},children:["End Editing ",s.jsx(o.Text,{td:"underline",children:r.name})]})})}),s.jsx(Vk,{saveDashboardChanges:t})]}),s.jsx(o.Group,{position:"right",sx:{flexGrow:1},children:n})]})})}),Fc={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},Gk=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(o.Tooltip,{label:t("common.choose_a_tab_first"),children:s.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:s.jsx(k.IconPlaylistAdd,{size:20}),sx:{...Fc,transform:"none !important"},children:t("panel.add")})}):s.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:r,leftIcon:s.jsx(k.IconPlaylistAdd,{size:20}),sx:{...Fc,background:"rgb(231, 245, 255)"},children:t("panel.add")})}),Fk=S.observer(({done:t})=>{var R,F;const{t:e}=_.useTranslation(),r=Y().layouts,i=m.useMemo(()=>({list:r.breakpointsInfo}),[r.breakpointsInfo]),{control:a,handleSubmit:l,watch:c,getValues:u,reset:d,formState:p}=f.useForm({defaultValues:i}),{fields:h,append:g,remove:y}=f.useFieldArray({control:a,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()},I=u(),A=m.useMemo(()=>{const Q={list:I.list.filter(ue=>!!ue.name&&Number.isFinite(ue.breakpoint))};return!b.isEqual(Q,i)},[I,i]),N=(F=(R=p.errors.list)==null?void 0:R.root)==null?void 0:F.message;return s.jsx(s.Fragment,{children:s.jsxs("form",{onSubmit:l(D),children:[s.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,withBorder:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"340px"},children:e("common.name")}),s.jsx("th",{style:{width:"160px"},children:e("breakpoint.breakpoint")}),s.jsx("th",{})]})}),s.jsxs("tbody",{children:[w.map((Q,ue)=>s.jsxs("tr",{children:[s.jsx("th",{children:Q.id==="basis"?Q.name:s.jsx(f.Controller,{name:`list.${ue}.name`,control:a,render:({field:le})=>s.jsx(o.TextInput,{size:"xs",label:"",required:!0,sx:{flex:1},...le})})}),s.jsx("td",{children:Q.id==="basis"?s.jsxs(o.Text,{ff:"monospace",children:[Q.breakpoint,"px"]}):s.jsx(f.Controller,{name:`list.${ue}.breakpoint`,control:a,render:({field:le})=>s.jsx(o.NumberInput,{size:"xs",label:"",required:!0,max:1e4,hideControls:!0,rightSection:s.jsx(o.Text,{color:"dimmed",children:"px"}),rightSectionProps:{style:{width:"30px"}},sx:{flex:1,fontFamily:"monospace"},styles:{input:{paddingRight:"30px"}},...le})})}),s.jsx("td",{children:Q.id!=="basis"&&s.jsx(o.ActionIcon,{mx:"auto",size:"xs",variant:"subtle",color:"red",onClick:()=>y(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(o.Tooltip,{label:e("breakpoint.add"),children:s.jsx(o.ActionIcon,{variant:"subtle",size:"md",color:"blue",onClick:T,sx:{width:"100%"},children:s.jsx(k.IconPlus,{size:18})})})})})]})]}),s.jsx(o.Text,{mt:6,ta:"right",size:"xs",color:"red",children:N??" "}),s.jsxs(o.Group,{mt:6,position:"apart",children:[s.jsx(o.Button,{color:"orange",size:"xs",onClick:()=>d(),leftIcon:s.jsx(k.IconRecycle,{size:18}),disabled:!A,children:e("common.actions.revert")}),s.jsx(o.Button,{color:"green",size:"xs",type:"submit",leftIcon:s.jsx(k.IconDeviceFloppy,{size:18}),disabled:!A,children:e("common.actions.save_changes")})]})]})})}),Wk=S.observer(()=>{const{t}=_.useTranslation(),[e,{open:n,close:r}]=ie.useDisclosure(!1),i=Y(),a=i.layouts.currentBreakpoint,l=i.layouts.currentLayoutRange,c=()=>{setTimeout(()=>{window.dispatchEvent(new Event("resize"))},32)},u=()=>{r(),c()};return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{children:[s.jsxs(o.Menu,{withArrow:!0,withinPortal:!0,zIndex:320,trigger:"hover",children:[s.jsx(o.Menu.Target,{children:s.jsx(o.Button,{size:"xs",variant:"subtle",leftIcon:s.jsx(k.IconDevices,{size:16}),sx:{borderRadius:0},children:s.jsxs(o.Group,{spacing:6,children:[s.jsx(o.Text,{size:"xs",fw:"normal",children:l.name}),s.jsx(o.Text,{size:"xs",color:"#777",children:i.layouts.currentRangeText})]})})}),s.jsxs(o.Menu.Dropdown,{children:[i.layouts.breakpointRanges.map(d=>s.jsx(o.Menu.Item,{onClick:()=>i.layouts.setCurrentBreakpoint(d.id),disabled:a===d.id,children:s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Text,{size:"sm",children:d.name}),s.jsx(o.Text,{size:"xs",color:"dimmed",children:d.text})]})},d.id)),s.jsx(o.Menu.Divider,{}),s.jsx(o.Menu.Item,{color:"blue",icon:s.jsx(k.IconSettings,{size:14}),onClick:n,children:s.jsx(o.Text,{size:"sm",children:t("breakpoint.manage")})})]})]}),i.layouts.divisionPreviewScale<1&&s.jsx(o.Text,{size:"xs",color:"dimmed",children:Sn(i.layouts.divisionPreviewScale).format({output:"percent",mantissa:0})})]}),s.jsx(o.Modal,{opened:e,onClose:u,title:t("breakpoint.label",{count:2}),withinPortal:!0,zIndex:320,size:600,closeOnClickOutside:!1,children:s.jsx(Fk,{done:u})})]})}),Wc={height:"30px",borderRight:"none",borderTop:"none",borderLeft:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},Qk=S.observer(()=>{var i;const{t}=_.useTranslation(),e=Y(),n=((i=e.views.VIE)==null?void 0:i.type)===B.Tabs,r=()=>{var a;return(a=e.views.VIE)==null?void 0:a.downloadSchema()};return n?s.jsx(o.Tooltip,{label:t("common.choose_a_tab_first"),children:s.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:s.jsx(k.IconCode,{size:16}),sx:{...Wc,transform:"none !important"},children:t("view.download_schema")})}):s.jsx(o.Button,{variant:"outline",color:"blue",radius:0,size:"xs",onClick:r,leftIcon:s.jsx(k.IconCode,{size:16}),sx:{...Wc},children:t("view.download_schema")})}),xs=({headers:t,rows:e})=>s.jsxs(o.Table,{fontSize:"xs",highlightOnHover:!0,sx:{tableLayout:"fixed",fontFamily:"monospace"},children:[s.jsx("thead",{children:t}),s.jsx("tbody",{children:e})]}),Rk=({content:t})=>{const{t:e}=_.useTranslation(),n=t.views;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("view.labels")}),s.jsx(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))})]})},Uk=({content:t})=>{const{t:e}=_.useTranslation(),n=t.filters;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("filter.labels")}),s.jsx(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))})]})},Yk=({content:t})=>{const{t:e}=_.useTranslation(),n=t.panels;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("panel.labels")}),s.jsx(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))})]})},Kk=({content:t})=>{var r;const{t:e}=_.useTranslation(),n=(r=t.definition)==null?void 0:r.queries;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("query.labels")}),s.jsx(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))})]})},Jk=({content:t})=>{var r;const{t:e}=_.useTranslation(),n=(r=t.definition)==null?void 0:r.sqlSnippets;return!Array.isArray(n)||n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("sql_snippet.labels")}),s.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:s.jsx(k.IconPointFilled,{size:10}),children:n.map(i=>s.jsx(o.List.Item,{children:i.key},i.key))})]})},Xk=({content:t})=>{var r;const{t:e}=_.useTranslation(),n=Object.keys(((r=t.definition)==null?void 0:r.mock_context)??{});return n.length===0?null:s.jsxs(o.Box,{children:[s.jsx(o.Text,{pl:10,size:"sm",fw:500,c:"dimmed",ta:"center",children:e("mock_context.label")}),s.jsx(o.List,{size:"sm",pl:10,ff:"monospace",icon:s.jsx(k.IconPointFilled,{size:10}),children:n.map(i=>s.jsx(o.List.Item,{children:i},i))})]})},Zk=({content:t})=>t?s.jsxs(o.Box,{children:[s.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),s.jsx(o.Text,{ta:"left",c:"dimmed",children:"Preview"}),s.jsxs(o.Stack,{children:[s.jsx(Rk,{content:t}),s.jsx(Uk,{content:t}),s.jsx(Yk,{content:t}),s.jsx(Kk,{content:t}),s.jsx(Jk,{content:t}),s.jsx(Xk,{content:t})]})]}):null;function Hk(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!==ft)throw new Error("Schema version mismatch");return e}const eT=S.observer(({onSuccess:t,stretchModal:e,shrinkModal:n})=>{var D,I;const{t:r}=_.useTranslation(),i=Y(),{handleSubmit:a,formState:{errors:l},setValue:c,watch:u,setError:d,clearErrors:p}=f.useForm({defaultValues:{content:null}}),h=({content:A})=>{try{if(!A)throw new Error("please use a valid json file");i.applyJSONSchema(A),vt.showNotification({title:"Successful",message:"",color:"green"}),t()}catch(N){console.error(N),vt.showNotification({title:"Failed",message:N.message,color:"red"})}},[g,y]=m.useState(null);m.useEffect(()=>{if(!g)return;const A=new FileReader;A.readAsText(g,"UTF-8"),A.onload=N=>{try{const R=Hk(N);c("content",R),p("content")}catch(R){console.error(R),d("content",{type:"custom",message:R.message})}},A.onabort=()=>console.log("🟨 abort"),A.onerror=()=>{A.error&&(console.error(A.error),d("content",{type:"custom",message:A.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(o.Box,{mx:"auto",sx:{position:"relative"},children:s.jsxs("form",{onSubmit:a(h),children:[s.jsx(o.FileInput,{label:r("import.json_file"),required:!0,value:g,onChange:y,error:(I=l==null?void 0:l.content)==null?void 0:I.message,sx:{maxWidth:500}}),T?s.jsx(o.Table,{fontSize:12,mt:10,children:s.jsxs("tbody",{children:[s.jsxs("tr",{children:[s.jsx("th",{children:r("import.this_dashboard")}),s.jsx("td",{children:ft})]}),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(Zk,{content:v}),s.jsx(o.Group,{position:"right",my:"md",children:s.jsx(o.Button,{type:"submit",color:"green",disabled:w,children:r("common.actions.confirm")})})]})]})})}),Qc={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},tT=S.observer(()=>{var d;const{t}=_.useTranslation(),[e,{open:n,close:r}]=ie.useDisclosure(!1),[i,{setTrue:a,setFalse:l}]=G.useBoolean(!1),u=((d=Z().content.views.VIE)==null?void 0:d.type)===B.Tabs;return u?s.jsx(o.Tooltip,{label:t("common.choose_a_tab_first"),children:s.jsx(o.Button,{variant:"outline",color:"gray",radius:0,size:"xs",leftIcon:s.jsx(k.IconFileImport,{size:16}),sx:{...Qc,transform:"none !important"},children:t("import.label")})}):s.jsxs(s.Fragment,{children:[s.jsx(o.Button,{variant:"subtle",color:"blue",radius:0,size:"xs",disabled:u||e,onClick:n,leftIcon:s.jsx(k.IconFileImport,{size:16}),sx:{...Qc},children:t("import.label")}),s.jsx(o.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(eT,{onSuccess:r,stretchModal:a,shrinkModal:l})})]})}),nT={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},sT=S.observer(()=>s.jsx(o.Box,{sx:nT,pl:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:s.jsxs(o.Group,{position:"apart",align:"center",sx:{height:"30px"},children:[s.jsxs(o.Group,{position:"left",spacing:0,children:[s.jsx(Gk,{}),s.jsx(tT,{})]}),s.jsx(Wk,{}),s.jsx(o.Group,{position:"right",spacing:0,children:s.jsx(Qk,{})})]})})),rT=S.observer(t=>s.jsxs(s.Fragment,{children:[s.jsx(Nk,{...t}),s.jsx(sT,{})]})),FM="";function iT(t,e,n){const r=[];return t.filter(i=>"__INTERACTIONS"in i.viz.conf).forEach((i,a)=>{const l=e[i.id];l.data.interactions=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:y}=h,{config:v}=y;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 aT(t,e){const n=t.filters.keyLabelMap;return{edges:iT(t.panels.list,e,n),edgeNodes:[]}}function Rc(t,e,n){return t*e+t*n}function oT(t,e,n){return t*e+(t-1)*n}const gs=25,Si=40,Uc=25,ki=350,lT=150,cT=150,Yc=150,Kc=300,fs=40,Jc=25,uT=300;function dT(t,e){const n=b.keyBy(e,i=>i.id),r=[];return t.current.forEach((i,a)=>{i.panelIDs.forEach((l,c)=>{const u=Rc(c,fs,Jc)+Si,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:Kc,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:Kc,height:fs}})})}),r}const pT={[B.Division]:"Div",[B.Modal]:"Modal",[B.Tabs]:"Tabs"},hT=zc;function mT(t){return t.current.map((n,r)=>{const i=oT(n.panelIDs.length,fs,Jc)+Si+Uc;let a=[];return n.type===B.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:`${pT[n.type]}:${n.name}`},position:{x:0,y:0},sourcePosition:we.Position.Right,targetPosition:we.Position.Left,className:"light",style:{backgroundColor:hT[n.type],width:ki,height:i}}})}function xT(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 gT(t){const e=mT(t.views);xT(e);const n=dT(t.views,t.panels.list);return[...e,...n]}function fT({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=ki+gs*2,r.style.height=Uc+r._tab_view_ids.reduce((i,a)=>{const l=t[a];l.position.y=i,l.position.x=gs;const c=l.style.height;return i+c+20},Si))})}function yT({nodeMap:t,nodes:e,edges:n}){n.filter(r=>r.label==="Open View").forEach(r=>{const i=t[r.source],a=t[r.target];if(!i||!a||!i.parentNode)return;const l=t[i.parentNode];l._node_type!=="view-root"||a._node_type!=="view-root"||(a._view_level+=1+l._view_level,l._sub_view_ids.push(a.id))}),e.sort((r,i)=>r._node_type==="view-root"&&i._node_type==="view-root"?r._view_level-i._view_level:r._node_type!=="view-root"&&i._node_type!=="view-root"?0:r._node_type==="view-root"?-1:1)}function bT({nodeMap:t,nodes:e,edges:n}){const r={};n.forEach(i=>{if(i.label!=="Open View")return;const a=t[i.source],l=t[i.target];if(a&&l&&a.parentNode){const c=t[a.parentNode],u=c.position.x,d=Number(b.get(l,"style.height",0)),p=Number(c.style.width);l.position.x=u+p+uT,c._view_level===0&&l._sub_view_ids.length===0&&(a.sourcePosition=we.Position.Left,l.targetPosition=we.Position.Right,l.position.x*=-1);const g=l.position.x,y=b.get(r,g,0);l.position.y=y,r[g]=y+d+Yc}})}function vT({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=Rc(c,ki,cT),l.position.y=0-lT-Yc})}function _T({nodeMap:t,nodes:e,edges:n}){const r={nodeMap:t,nodes:e,edges:n};return vT(r),yT(r),fT(r),bT(r),{nodes:e,edges:n}}function jT(t){const e=gT(t),n=b.keyBy(e,u=>u.id),{edges:r,edgeNodes:i}=aT(t,n),a=[...e,...i],l=b.keyBy(a,u=>u.id),c={edges:b.uniqBy(r,u=>u.id),nodes:a,nodeMap:l};return _T(c)}const WM="",Ti={"builtin:op:open-link":s.jsx(o.ThemeIcon,{color:"blue",size:20,radius:"xl",children:s.jsx(k.IconCircleDashed,{size:14})}),"builtin:op:set_filter_values":s.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:s.jsx(k.IconCircleDot,{size:14})}),"builtin:op:clear_filter_values":s.jsx(o.ThemeIcon,{color:"orange",size:20,radius:"xl",children:s.jsx(k.IconCircleOff,{size:14})})};function wT(t){const e=[];return t.forEach(n=>{switch(n.schemaRef){case"builtin:op:open-link":e.push({key:n.urlTemplate,icon:Ti[n.schemaRef],text:s.jsxs(o.Group,{spacing:4,children:[s.jsx(o.Text,{children:"Open: "}),s.jsx(o.Text,{color:"dimmed",children:n.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":n.filters.forEach(({key:r,label:i})=>{e.push({key:n.schemaRef+r,icon:Ti[n.schemaRef],text:s.jsx(o.Group,{spacing:4,children:s.jsxs(o.Text,{children:["Set Filter: ",i]})})})});return;case"builtin:op:clear_filter_values":n.filters.forEach(({key:r,label:i})=>{e.push({key:n.schemaRef+r,icon:Ti[n.schemaRef],text:s.jsx(o.Group,{spacing:4,children:s.jsxs(o.Text,{children:["Clear Filter: ",i]})})})});return}}),e}const CT=m.memo(({data:t,isConnectable:e,sourcePosition:n=we.Position.Right,targetPosition:r=we.Position.Left,...i})=>{const a=m.useMemo(()=>wT(t.interactions),[t.interactions]);return s.jsxs(s.Fragment,{children:[s.jsx(we.Handle,{type:"target",position:r,isConnectable:e}),s.jsx(o.Box,{sx:{position:"absolute",top:0,right:0},children:s.jsx(L.ChevronsUpRight,{size:12})}),s.jsxs(o.HoverCard,{shadow:"xl",withinPortal:!0,children:[s.jsx(o.HoverCard.Target,{children:s.jsx(o.Text,{children:t.label})}),s.jsx(o.HoverCard.Dropdown,{children:s.jsx(o.List,{spacing:"xs",size:"sm",center:!0,children:a.map(l=>s.jsx(o.List.Item,{icon:l.icon,children:l.text},l.key))})})]}),s.jsx(we.Handle,{type:"source",position:n,isConnectable:e})]})}),QM="",ST={interaction:CT},kT=S.observer(()=>{const t=he(),{edges:e,nodes:n}=jT(t);return s.jsxs(we,{nodes:n,edges:e,onNodesChange:b.noop,onEdgesChange:b.noop,onConnect:b.noop,className:"interactions-viewer",fitView:!0,nodeTypes:ST,children:[s.jsx(we.MiniMap,{}),s.jsx(we.Controls,{}),s.jsx(we.Background,{})]})}),TT=S.observer(({opened:t,close:e})=>{const{t:n}=_.useTranslation();return s.jsx(o.Modal,{size:"96vw",opened:t,onClose:e,title:n("interactions.interactions_viewer"),trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{body:{height:"calc(90vh - 54px)"},content:{transform:"none !important"}},zIndex:300,children:s.jsx(kT,{})})}),DT={"> 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 zT({onClick:t,name:e,active:n,openSettings:r}){return s.jsxs(o.Box,{sx:{position:"relative"},children:[s.jsx(o.UnstyledButton,{sx:i=>({display:"block",width:"100%",padding:i.spacing.xs,borderRadius:0,position:"relative",color:i.black,"&:hover":{backgroundColor:i.colors.gray[0]},backgroundColor:n?i.colors.gray[2]:"transparent"}),children:s.jsx(o.Group,{sx:{width:"calc(100% - 28px)"},onClick:t,children:s.jsx(o.Text,{size:"sm",children:e})})}),n&&s.jsx(o.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:s.jsx(o.ActionIcon,{onClick:r,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:s.jsx(k.IconAdjustments,{size:16})})})]})}const MT=S.observer(()=>{const{t}=_.useTranslation(),e=Z(),n=Y(),r=m.useCallback(a=>()=>n.views.setIDOfVIE(a),[n]),i=a=>{e.editor.open(["_VIEWS_",a])};return s.jsxs(o.Box,{sx:{position:"relative"},children:[n.views.options.map(a=>s.jsx(zT,{active:n.views.idOfVIE===a.value,name:a.label,onClick:r(a.value),openSettings:()=>i(a.value)},a.value)),s.jsx(o.Divider,{variant:"dashed"}),s.jsx(o.Button,{variant:"subtle",rightIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",color:"blue",onClick:n.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:t("view.add")})]})}),IT=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])},[a,l]=m.useState(!1),c=()=>l(!0),u=()=>l(!1);return s.jsxs(o.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},zIndex:299,children:[s.jsxs(o.Navbar.Section,{children:[s.jsxs(o.Group,{grow:!0,spacing:0,sx:{...DT,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[s.jsx(o.Tooltip,{label:t("filter.labels"),withinPortal:!0,children:s.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:i,children:s.jsx(k.IconFilter,{size:18})})}),s.jsx(o.Tooltip,{label:t("query.labels"),withinPortal:!0,children:s.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:r,children:s.jsx(k.IconDatabase,{size:18})})}),s.jsx(o.Tooltip,{label:t("interactions.interactions_viewer"),withinPortal:!0,children:s.jsx(o.ActionIcon,{variant:"default",radius:0,size:"md",sx:{height:"30px"},onClick:c,children:s.jsx(k.IconLink,{size:18})})})]}),s.jsx(TT,{opened:a,close:u})]}),s.jsx(o.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:s.jsx(o.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:t("view.labels")})}),s.jsx(o.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:s.jsx(MT,{})}),s.jsx(o.Navbar.Section,{children:s.jsx(o.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:s.jsx(o.Button,{size:"xs",leftIcon:s.jsx(k.IconSettings,{size:20}),onClick:()=>e.editor.open([]),children:t("common.titles.settings")})})})]})}),ET={[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]:'""'},AT=t=>["function getDefaultValue(filter, utils, context) {",` return ${ET[t]};`,"}"].join(`
|
|
449
|
-
`),
|
|
447
|
+
FROM ${n}.${t}
|
|
448
|
+
`}})).actions(e=>({setPage(t){e.page=t},resetPage(){e.page=1},setLimit(t){e.limit=t}})).actions(e=>({afterCreate(){m.addDisposer(e,X.reaction(()=>e.keywordString,e.resetPage,{fireImmediately:!1,delay:0})),m.addDisposer(e,X.reaction(()=>e.limit,e.resetPage,{fireImmediately:!1,delay:0}))}})),lE=m.types.model({data:m.types.optional(m.types.frozen(),{}),state:m.types.optional(m.types.enumeration(["idle","loading","error"]),"idle"),error:m.types.frozen()}).views(e=>({get loading(){return e.state==="loading"},get empty(){return Object.keys(e.data).length===0}})),cE=m.types.compose("DataSourceModel",rl,m.types.model({tables:m.types.optional(lE,{}),columns:m.types.optional(iE,{}),tableData:m.types.optional(oE,{}),indexes:m.types.optional(aE,{}),table_schema:m.types.optional(m.types.string,""),table_name:m.types.optional(m.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=m.flow(function*(){var n;(n=e.controllers.tables)==null||n.abort(),e.controllers.tables=new AbortController,e.tables.state="loading";try{const s=yield*m.toGenerator(Pt.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(!It.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:m.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*m.toGenerator(Pt.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(It.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:m.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*m.toGenerator(Pt.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(It.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:m.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*m.toGenerator(Pt.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*m.toGenerator(Pt.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(It.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(){m.addDisposer(e,X.reaction(()=>e.reloadConditionString,e.loadColumns,{fireImmediately:!1,delay:500}))}})).actions(e=>({afterCreate(){m.addDisposer(e,X.reaction(()=>e.reloadConditionString,e.loadIndexes,{fireImmediately:!1,delay:500})),m.addDisposer(e,X.reaction(()=>`${e.reloadConditionString};limit:${e.tableData.limit};offset:${e.tableData.offset}`,e.loadTableData,{fireImmediately:!1,delay:0}))}})),uE=m.types.model("DataSourcesModel",{list:m.types.optional(m.types.array(cE),[])}).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 zn(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 pE=m.types.model("EditorModel",{path:m.types.optional(m.types.frozen(),[]),settings_open:m.types.optional(m.types.boolean,!1)}).views(e=>({get navOptions(){const{content:t}=m.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:[zn("_FILTERS_SETTINGS_"),...n.options,zn("_Add_A_Filter_")],_type:"GROUP"},{label:"sql_snippet.labels",value:"_SQL_SNIPPETS_",Icon:M.IconCopy,children:[zn("_SQL_SNIPPETS_SETTINGS_"),...i.options,zn("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"query.labels",value:"_QUERIES_",Icon:M.IconDatabase,children:[zn("_QUERIES_SETTINGS_"),...a.options,zn("_Add_A_QUERY_")],_type:"GROUP"},{label:"view.labels",value:"_VIEWS_",Icon:M.IconBoxMultiple,children:[...s.editorOptions,zn("_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)}})),hE=m.types.compose("LayoutsModel",fl,m.types.model({currentLayoutWrapperWidth:m.types.optional(m.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:Wt.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:Wt.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)})}})),kf=ll.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(){m.getParent(e,2).removeByID(e.id)}})).actions(e=>({moveToView(t,n){m.getRoot(e).content.views.findByID(t).removePanelID(e.id),m.getRoot(e).content.views.findByID(n).appendPanelID(e.id),m.getRoot(e).editor.setPath(["_VIEWS_",n,"_PANELS_",e.id])}})),Tf=m.types.compose("PanelsModel",cl,m.types.model({list:m.types.optional(m.types.array(kf),[])})).views(e=>({get contentModel(){return m.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=m.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)}})),fE=al.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:Zt}},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)}})),Df=m.types.compose("ViewsModel",ol,m.types.model({current:m.types.optional(m.types.array(fE),[]),idOfVIE:m.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=m.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];m.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 vl(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 gE=m.types.model({id:m.types.string,name:m.types.string,dashboard_id:m.types.string,create_time:m.types.string,update_time:m.types.string,version:m.types.string,filters:jf,queries:Cf,sqlSnippets:Sf,views:Df,panels:Tf,layouts:hE,mock_context:Go,origin:m.types.maybe(m.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(m.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get queriesChanged(){const t="queries.current",n=m.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(m.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(m.getSnapshot(v.get(e,t)),v.get(e.origin,t))},get layoutsChanged(){const t="layouts.list";return!v.isEqual(m.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=m.getParent(e).context.current;return{...e.mock_context.current,...t}},get payloadForSQL(){const t=m.getParent(e).globalSQLSnippets,n={context:this.context,filters:e.filters.values};return{...n,sql_snippets:Rr(e.sqlSnippets.current,"key","value",n),global_sql_snippets:Rr(t.list,"id","content",n)}},get payloadForViz(){const t=m.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.values}},get dashboardState(){return Ti(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(is.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=Wt.v4();e.panels.append(Yh(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(x=>{const y=Wt.v4();return p.set(x.id,y),{...x,id:y}});if(e.panels.appendMultiple(f),!Array.isArray(n)||n.length===0){const x=f.map(y=>y.id);(h=e.views.VIE)==null||h.appendPanelIDs(x)}}if(Array.isArray(n)){const f=n.map(x=>{const y=x.panelIDs.map(j=>p.get(j)??j);return{...x,id:Wt.v4(),panelIDs:y}});e.views.appendMultiple(f)}if(Array.isArray(l)){const f=(j,k)=>e.layouts.breakpointNameRecord[j]===k;let x=[];const y=l.filter(j=>f(j.name,j.breakpoint));y.forEach(j=>{j.id==="basis"&&(x=j.list),j.list.forEach(k=>{const S=p.get(k.panelID);k.id=Wt.v4(),k.panelID=S})}),e.layouts.list.forEach(j=>{const k=y.find(S=>S.name===j.name&&S.breakpoint===j.breakpoint);if(!k){x.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(){m.applySnapshot(e.filters.current,e.origin.filters.current),m.applySnapshot(e.queries.current,e.origin.queries.current),m.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),m.applySnapshot(e.views.current,e.origin.views.current),m.applySnapshot(e.panels.list,e.origin.panels.list),m.applySnapshot(e.layouts.list,e.origin.layouts.list),e.mock_context.current=e.origin.mock_context.current},resetFilters(){m.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,m.applySnapshot(e.filters.current,l),m.applySnapshot(e.views.current,vl(c).current),m.applySnapshot(e.panels.list,u),m.applySnapshot(e.queries.current,d),m.applySnapshot(e.sqlSnippets.current,p),e.mock_context.current=h}})),_l=m.types.snapshotProcessor(gE,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=m.castToSnapshot(e.queries.current.map(n=>v.pick(n,["id","key","type","sql"])));return v.defaults({},{queries:{current:t}},e)}});function mE(e,t){t.filters&&m.applySnapshot(e.filters.current,t.filters)}function Mf({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:x,sqlSnippets:y,mock_context:j={}}}=a;return _l.create({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,version:u,filters:dl(d,l,j,c),queries:{current:x},sqlSnippets:{current:y},mock_context:Wo(j),views:vl(p),panels:{list:h},layouts:{list:f,currentBreakpoint:f[0].id}})}const zf=m.types.model({id:m.types.identifier,name:m.types.string,group:m.types.string,content:_l,content_id:m.types.string,datasources:uE,globalSQLSnippets:sl,context:ai,editor:pE}).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 If({id:e,name:t,group:n,content_id:s},i,a,l,c,u){return zf.create({id:e,name:t,group:n,content_id:s,content:Mf(i,c,u),datasources:{list:a},globalSQLSnippets:{list:l},context:il(c),editor:{}})}const xE={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"}}}},yE={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:"请填写一个数字"}}}},ci=rm.createInstance({debug:!1,fallbackLng:"en",interpolation:{escapeValue:!1},resources:{en:xE,zh:yE}}).use(sm).use(_.initReactI18next);ci.init(),xh.forEach(e=>{var t;(t=e.translation)==null||t.forEach(n=>{ci.addResourceBundle(n.lang,"translation",{viz:n.resources},!0,!0)})});function Ef({lang:e,children:t}){return g.useEffect(()=>{ci.changeLanguage(e)},[e]),r.jsx(_.I18nextProvider,{i18n:ci,children:t})}function ui(e){console.groupCollapsed("Running operation ",e.type),console.log(e),console.groupEnd()}function Af(e,t){g.useEffect(()=>{const n=s=>{ui(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]),g.useEffect(()=>{const n=s=>{ui(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]),g.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=>{ui(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]),g.useEffect(()=>{const n=s=>{ui(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,x=>{if(l&&typeof x=="string")return encodeURIComponent(x)})}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 Pf(e){return g.useCallback(t=>t.provideValue(je.pluginManager,e.pluginManager).provideValue(je.vizManager,e.vizManager).provideValue(je.colorManager,e.colorManager),[])}const mL="",bE=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")})})]})]})}),vE=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(bE,{saveDashboardChanges:e})]}),r.jsx(o.Group,{position:"right",sx:{flexGrow:1},children:n})]})})}),Of={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"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=()=>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:{...Of,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:{...Of,background:"rgb(231, 245, 255)"},children:e("panel.add")})}),jE=D.observer(({done:e})=>{var E,N;const{t}=_.useTranslation(),s=Y().layouts,i=g.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:x}=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:Wt.v4(),name:"",breakpoint:""})},S=({list:R})=>{const pe=R.filter(ie=>Number.isFinite(ie.breakpoint));s.updateLayoutSetsInfo(pe),e()},T=u(),z=g.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:()=>x(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")})]})]})})}),wE=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:Zr(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(jE,{done:u})})]})}),Lf={height:"30px",borderRight:"none",borderTop:"none",borderLeft:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},CE=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:{...Lf,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:{...Lf},children:e("view.download_schema")})}),di=({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})]}),SE=({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(di,{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))})]})},kE=({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(di,{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))})]})},TE=({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(di,{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))})]})},DE=({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(di,{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))})]})},ME=({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))})]})},zE=({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))})]})},IE=({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(SE,{content:e}),r.jsx(kE,{content:e}),r.jsx(TE,{content:e}),r.jsx(DE,{content:e}),r.jsx(ME,{content:e}),r.jsx(zE,{content:e})]})]}):null;function EE(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!==Zt)throw new Error("Schema version mismatch");return t}const AE=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),tn.showNotification({title:"Successful",message:"",color:"green"}),e()}catch(I){console.error(I),tn.showNotification({title:"Failed",message:I.message,color:"red"})}},[f,x]=g.useState(null);g.useEffect(()=>{if(!f)return;const z=new FileReader;z.readAsText(f,"UTF-8"),z.onload=I=>{try{const E=EE(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 g.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:x,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:Zt})]}),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(IE,{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")})})]})]})})}),Bf={height:"30px",borderLeft:"none",borderTop:"none",borderRight:"1px solid #e9ecef",borderBottom:"1px solid #e9ecef"},PE=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:{...Bf,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:{...Bf},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(AE,{onSuccess:s,stretchModal:a,shrinkModal:l})})]})}),OE={position:"fixed",top:60,left:0,right:0,height:30,zIndex:299,borderBottom:"1px solid #e9ecef",background:"rgba(233,236,239, 0.15)"},LE=D.observer(()=>r.jsx(o.Box,{sx:OE,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(_E,{}),r.jsx(PE,{})]}),r.jsx(wE,{}),r.jsx(o.Group,{position:"right",spacing:0,children:r.jsx(CE,{})})]})})),BE=D.observer(e=>r.jsxs(r.Fragment,{children:[r.jsx(vE,{...e}),r.jsx(LE,{})]})),xL="";function qE(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:x}=h,{config:y}=x;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 VE(e,t){const n=e.filters.keyLabelMap;return{edges:qE(e.panels.list,t,n),edgeNodes:[]}}function qf(e,t,n){return e*t+e*n}function NE(e,t,n){return e*t+(e-1)*n}const pi=25,jl=40,Vf=25,wl=350,$E=150,FE=150,Nf=150,$f=300,hi=40,Ff=25,GE=300;function WE(e,t){const n=v.keyBy(t,i=>i.id),s=[];return e.current.forEach((i,a)=>{i.panelIDs.forEach((l,c)=>{const u=qf(c,hi,Ff)+jl,d=n[l];if(!d){s.push({id:l,_node_type:"panel",parentNode:i.id,data:{label:`!: ${l}`},position:{x:pi,y:u},sourcePosition:Ee.Position.Right,targetPosition:Ee.Position.Left,style:{width:$f,height:hi}});return}const p=d.name;s.push({id:d.id,_node_type:"panel",parentNode:i.id,data:{label:p},position:{x:pi,y:u},sourcePosition:Ee.Position.Right,targetPosition:Ee.Position.Left,style:{width:$f,height:hi}})})}),s}const RE={[q.Division]:"Div",[q.Modal]:"Modal",[q.Tabs]:"Tabs"},QE=_f;function UE(e){return e.current.map((n,s)=>{const i=NE(n.panelIDs.length,hi,Ff)+jl+Vf;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:`${RE[n.type]}:${n.name}`},position:{x:0,y:0},sourcePosition:Ee.Position.Right,targetPosition:Ee.Position.Left,className:"light",style:{backgroundColor:QE[n.type],width:wl,height:i}}})}function YE(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 KE(e){const t=UE(e.views);YE(t);const n=WE(e.views,e.panels.list);return[...t,...n]}function XE({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=wl+pi*2,s.style.height=Vf+s._tab_view_ids.reduce((i,a)=>{const l=e[a];l.position.y=i,l.position.x=pi;const c=l.style.height;return i+c+20},jl))})}function JE({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 ZE({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+GE,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,x=v.get(s,f,0);l.position.y=x,s[f]=x+d+Nf}})}function HE({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=qf(c,wl,FE),l.position.y=0-$E-Nf})}function eA({nodeMap:e,nodes:t,edges:n}){const s={nodeMap:e,nodes:t,edges:n};return HE(s),JE(s),XE(s),ZE(s),{nodes:t,edges:n}}function tA(e){const t=KE(e),n=v.keyBy(t,u=>u.id),{edges:s,edgeNodes:i}=VE(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 eA(c)}const yL="",Cl={"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 nA(e){const t=[];return e.forEach(n=>{switch(n.schemaRef){case"builtin:op:open-link":t.push({key:n.urlTemplate,icon:Cl[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:Cl[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:Cl[n.schemaRef],text:r.jsx(o.Group,{spacing:4,children:r.jsxs(o.Text,{children:["Clear Filter: ",i]})})})});return}}),t}const rA=g.memo(({data:e,isConnectable:t,sourcePosition:n=Ee.Position.Right,targetPosition:s=Ee.Position.Left,...i})=>{const a=g.useMemo(()=>nA(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="",sA={interaction:rA},iA=D.observer(()=>{const e=_e(),{edges:t,nodes:n}=tA(e);return r.jsxs(Ee,{nodes:n,edges:t,onNodesChange:v.noop,onEdgesChange:v.noop,onConnect:v.noop,className:"interactions-viewer",fitView:!0,nodeTypes:sA,children:[r.jsx(Ee.MiniMap,{}),r.jsx(Ee.Controls,{}),r.jsx(Ee.Background,{})]})}),aA=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(iA,{})})}),oA={"> 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 lA({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 cA=D.observer(()=>{const{t:e}=_.useTranslation(),t=Z(),n=Y(),s=g.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(lA,{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")})]})}),uA=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]=g.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:{...oA,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(aA,{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(cA,{})}),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]:'""'},pA=e=>["function getDefaultValue(filter, utils, context) {",` return ${dA[e]};`,"}"].join(`
|
|
449
|
+
`),ir=D.observer(({filter:e})=>{const{t}=_.useTranslation();return r.jsx(wp,{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:pA(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")})]})})})}),hA=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(wo,{label:n("filter.widget.checkbox.description"),value:s.description,onChange:s.setDescription,styles:{root:{flexGrow:1,minHeight:"400px"}}})]})}),fA=[{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"}],gA=D.observer(function({filter:t}){const{t:n}=_.useTranslation(),s=t.config,i=g.useMemo(()=>$o().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:fA,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(jh,{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})]})}),Sl=D.observer(({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),s=Z(),i=Y(),a=g.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"}}})}),mA=`
|
|
450
450
|
// row
|
|
451
451
|
{
|
|
452
452
|
label: string;
|
|
453
453
|
value: string;
|
|
454
454
|
description?: string; // optional
|
|
455
455
|
}
|
|
456
|
-
`,
|
|
456
|
+
`,Gf=()=>{const{t:e}=_.useTranslation(),[t,n]=g.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(nn.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:mA})})]})},xA=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(Sl,{value:s.options_query_id,onChange:s.setOptionsQueryID}),r.jsx(Gf,{})]})}),yA=D.observer(function({filter:t}){const{t:n,i18n:s}=_.useTranslation(),i=t.config,a=()=>{i.addStaticOption({label:"",value:""})},l=i.static_options,c=g.useMemo(()=>[{label:n("filter.widget.select.no_default_selection"),value:""},...l],[s.language,l]);return r.jsxs(r.Fragment,{children:[r.jsxs(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(Sl,{value:i.options_query_id,onChange:i.setOptionsQueryID}),r.jsx(Gf,{})]})}),bA=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")})]})}),vA=`
|
|
457
457
|
// row
|
|
458
458
|
{
|
|
459
459
|
label: string;
|
|
@@ -461,7 +461,7 @@ Check the top-level render call using <`+P+">.")}return z}}function Du(C,z){{if(
|
|
|
461
461
|
parent_value: string;
|
|
462
462
|
description?: string;
|
|
463
463
|
}
|
|
464
|
-
`,GT=()=>{const{t}=_.useTranslation(),[e,n]=m.useState(!1);return s.jsxs(s.Fragment,{children:[s.jsx(o.Button,{variant:"subtle",compact:!0,onClick:()=>n(r=>!r),children:t(e?"common.actions.close":"filter.widget.common.see_data_structure")}),s.jsx(o.Collapse,{in:e,children:s.jsx(_t.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:NT})})]})},FT=S.observer(function({filter:e}){const{t:n}=_.useTranslation(),r=e.config;return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Checkbox,{checked:r.required,onChange:i=>r.setRequired(i.currentTarget.checked),label:n("filter.widget.select.required")}),s.jsx(en,{filter:e})]}),s.jsx(o.TextInput,{label:n("filter.widget.common.min_width"),value:r.min_width,onChange:i=>r.setMinWidth(i.currentTarget.value),placeholder:"200px"}),s.jsx(o.Divider,{label:n("filter.widget.common.fetch_options_from_datasource"),labelPosition:"center"}),s.jsx(o.Checkbox,{checked:r.treeCheckStrictly,onChange:i=>r.setTreeCheckStrictly(i.currentTarget.checked),label:n("filter.widget.tree_select.strictly")}),s.jsx(o.NumberInput,{value:r.default_selection_count,onChange:r.setDefaultSelectionCount,label:n("filter.widget.common.default_selection_count")}),s.jsx(Di,{value:r.options_query_id,onChange:r.setOptionsQueryID}),s.jsx(GT,{})]})}),WT=S.observer(function({filter:e}){const{t:n}=_.useTranslation();return s.jsxs(o.Box,{sx:{maxWidth:"480px"},children:[s.jsx(o.Text,{pt:"0",pb:"md",color:"gray",children:n("common.titles.config")}),s.jsx(_t.Prism,{mt:22,language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(e,null,4)})]})}),QT={select:OT,"multi-select":qT,"tree-select":FT,"text-input":VT,checkbox:PT,"date-range":BT},Lt={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"},RT=S.observer(function({filter:e}){const{t:n,i18n:r}=_.useTranslation(),i=Y(),a=m.useMemo(()=>QT[e.type],[e.type]),l=m.useMemo(()=>[{label:n(Lt.select),value:"select"},{label:n(Lt["multi-select"]),value:"multi-select"},{label:n(Lt["tree-select"]),value:"tree-select"},{label:n(Lt["text-input"]),value:"text-input"},{label:n(Lt.checkbox),value:"checkbox"},{label:n(Lt["date-range"]),value:"date-range"}],[r.language]);return s.jsxs(o.Group,{grow:!0,spacing:20,align:"top",children:[s.jsxs(o.Box,{sx:{maxWidth:"600px"},children:[s.jsx(o.Text,{pb:"md",color:"gray",children:n("common.titles.edit")}),s.jsxs(o.Stack,{children:[s.jsxs(o.Group,{noWrap:!0,children:[s.jsx(o.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(o.Checkbox,{label:n("filter.field.auto_submit"),checked:e.auto_submit,onChange:c=>e.setAutoSubmit(c.currentTarget.checked),mt:22})]}),s.jsx(o.MultiSelect,{label:n("filter.field.visible_in"),data:i.views.options,value:[...e.visibleInViewsIDs],onChange:e.setVisibleInViewsIDs}),s.jsx(o.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(o.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(o.Select,{label:n("filter.field.widget"),data:l,required:!0,value:e.type,onChange:e.setType,maxDropdownHeight:500}),s.jsx(o.Divider,{mb:0,mt:10,variant:"dashed",labelPosition:"center"}),s.jsx(a,{filter:e})]})]}),s.jsx(WT,{filter:e})]})}),UT=S.observer(({id:t})=>{const{t:e}=_.useTranslation(),n=Fe.useModals(),r=Z(),i=Y();if(t==="")return null;const a=i.filters.findByID(t);if(!a)return s.jsxs(o.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(o.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[s.jsx(o.Group,{position:"right",pt:10,children:s.jsx(o.Button,{size:"xs",color:"red",leftIcon:s.jsx(L.Trash,{size:16}),onClick:c,children:e("filter.delete")})}),s.jsx(o.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:s.jsx(RT,{filter:a})})]})}),YT=S.observer(()=>{const{t}=_.useTranslation(),[e,n]=m.useState([]),r=Z(),i=d=>{r.editor.setPath(["_FILTERS_",d])},a=()=>{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(o.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[s.jsx(o.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:s.jsx(o.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:t("filter.manage")})}),s.jsx(o.Flex,{justify:"space-between",align:"center",px:12,children:s.jsxs(o.Group,{position:"left",children:[s.jsxs(o.Button.Group,{children:[s.jsx(o.Button,{variant:"default",size:"xs",onClick:c,children:t("common.actions.select_all")}),s.jsx(o.Button,{variant:"default",size:"xs",onClick:u,children:t("common.actions.clear_selection")})]}),s.jsx(o.Button,{size:"xs",color:"blue",leftIcon:s.jsx(k.IconCode,{size:14}),disabled:e.length===0,onClick:a,children:t("common.actions.download_schema")})]})}),s.jsx(o.Box,{sx:{flexGrow:1,overflow:"auto"},children:s.jsx(o.Checkbox.Group,{size:"xs",value:e,onChange:n,children:s.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"40px"}}),s.jsx("th",{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(o.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(Lt[d.type])}),s.jsx("td",{children:s.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>i(d.id),children:t("common.actions.open")})})]},d.id))})]})})})]})}),KT=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){vt.showNotification({title:"Failed",message:l.message,color:"red"})}},a=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(o.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[s.jsx(o.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:s.jsx(o.Text,{weight:500,children:t("mock_context.label")})}),s.jsxs(o.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[s.jsxs(o.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[s.jsx(o.Text,{children:t("mock_context.hint")}),s.jsx(o.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:n,onChange:r,sx:{flexGrow:1}})]}),s.jsx(o.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!a,onClick:i,children:s.jsx(L.DeviceFloppy,{size:20})})]})]})}),JT=S.observer(()=>{const{t}=_.useTranslation(),{panel:e}=ze();return s.jsx(kr,{label:t("panel.panel_description"),value:e.description,onChange:e.setDescription,styles:{root:{flexGrow:1}}})}),XT=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(o.Divider,{mb:-10,label:t("panel.style.label"),labelPosition:"center",variant:"dashed"}),s.jsxs(o.Stack,{spacing:20,children:[s.jsxs(o.Group,{grow:!0,align:"top",children:[s.jsx(o.NumberInput,{label:t("panel.style.width"),min:1,max:36,step:1,precision:0,rightSection:s.jsx(o.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(o.NumberInput,{label:t("panel.style.height"),rightSection:s.jsx(o.Text,{size:12,children:t("panel.style.height_postfix")}),styles:{rightSection:{width:"40px"}},value:n.h,onChange:i=>{i&&n.setHeight(i)}})]}),s.jsx(o.Checkbox,{ml:6,label:t("panel.style.border"),checked:r.border.enabled,onChange:i=>r.border.setEnabled(i.currentTarget.checked)})]})]})}),ZT=()=>s.jsxs("span",{className:"mantine-103svbs mantine-InputWrapper-required mantine-Select-required","aria-hidden":"true",children:[" ","*"]}),HT=S.observer(()=>{const{t}=_.useTranslation(),{panel:e}=ze(),{name:n}=e,[r,i]=ie.useInputState(n),a=n!==r,l=m.useCallback(()=>{a&&e.setName(r)},[a,r]);m.useEffect(()=>{i(n)},[n]);const c=!r.trim();return s.jsxs(o.Stack,{spacing:4,children:[s.jsxs(o.Group,{align:"center",children:[s.jsxs(o.Text,{size:14,fw:500,children:[t("panel.panel_name"),s.jsx(ZT,{})]}),s.jsx(o.ActionIcon,{variant:"subtle",color:"blue",disabled:!a||c,onClick:l,children:s.jsx(k.IconDeviceFloppy,{size:18})})]}),s.jsx(o.TextInput,{value:r,onChange:i,required:!0})]})}),e1=S.observer(()=>{const{t}=_.useTranslation(),{panel:e}=ze();return s.jsx(o.Stack,{spacing:6,mb:10,children:s.jsxs(o.Group,{pl:6,position:"left",spacing:20,children:[s.jsx(o.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(o.Checkbox,{size:"sm",checked:!0,disabled:!0,label:t("panel.use_name_as_title")})]})})});function t1(){const{t}=_.useTranslation();return s.jsxs(o.Stack,{sx:{height:"100%"},children:[s.jsx(XT,{}),s.jsx(o.Divider,{label:t("common.info"),labelPosition:"center",variant:"dashed"}),s.jsx(HT,{}),s.jsx(e1,{}),s.jsx(JT,{})]})}const n1={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 Zc({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:a=>a.getValue()}))},[t]),n=Je.useReactTable({data:t,columns:e,columnResizeMode:"onChange",getCoreRowModel:Je.getCoreRowModel()});return t.length===0?s.jsx(o.Box,{sx:{height:"5em"}}):s.jsx(je,{children:s.jsxs(o.Table,{sx:n1,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(o.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 s1=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],r1={icon:{width:"80px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"80px"}}},i1=({data:t,page:e,setPage:n,limit:r,setLimit:i})=>{const{t:a}=_.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(o.Group,{pt:10,px:10,position:"apart",children:[s.jsxs(o.Group,{position:"left",children:[c>1&&s.jsx(o.Pagination,{size:"sm",value:e,onChange:n,total:c,withEdges:c>7,styles:{control:{height:"30px"}}}),!d&&s.jsx(o.Select,{icon:s.jsx(o.Text,{ta:"center",color:"dimmed",size:14,children:a("common.pagination.page_size")}),size:"xs",styles:r1,data:s1,value:String(r),onChange:u})]}),s.jsx(o.Group,{position:"right",children:s.jsx(o.Text,{color:"dimmed",my:0,size:14,children:a("common.pagination.total_rows",{total:l})})})]})},a1=Yd(({data:t,loading:e})=>{const[n,r]=m.useState(1),[i,a]=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(i1,{data:t,page:n,setPage:r,limit:i,setLimit:a}),s.jsxs(o.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[s.jsx(o.LoadingOverlay,{visible:e,overlayBlur:2}),s.jsx(Zc,{data:l})]})]})}),o1=({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(o.Text,{mt:10,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:r}):i!=null&&i.stateMessage?s.jsx(o.Text,{mt:10,color:"gray",align:"center",children:i.stateMessage}):null},zi=S.observer(({id:t,moreActions:e,refreshOnMount:n})=>{const{t:r}=_.useTranslation(),i=he(),{data:a,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(a)||a.length===0;return s.jsxs(o.Stack,{spacing:0,sx:{height:"100%",border:"1px solid #eee"},children:[s.jsxs(o.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[s.jsx(o.Group,{position:"left",children:s.jsx(o.Text,{weight:500,children:r("data.preview_data")})}),s.jsxs(o.Group,{pr:15,children:[e,s.jsx(o.ActionIcon,{variant:"subtle",color:"blue",disabled:c,onClick:u,children:s.jsx(L.Refresh,{size:16})}),s.jsx(o.ActionIcon,{variant:"subtle",color:"blue",disabled:c||p,onClick:d,children:s.jsx(L.Download,{size:16})})]})]}),s.jsxs(o.Box,{pb:20,sx:{position:"relative",flexGrow:1,overflow:"auto"},children:[s.jsx(o1,{queryID:t}),s.jsx(a1,{data:a,loading:c})]})]})}),l1=S.observer(function(){const{t:e}=_.useTranslation(),n=Z(),r=Y(),{panel:i}=ze(),[a,l]=m.useState(!1),c=d=>{n.editor.setPath(["_QUERIES_",d])},u=i.queryIDs.length;return s.jsxs(s.Fragment,{children:[s.jsx(o.Drawer,{opened:a,onClose:()=>l(!1),title:e("panel.settings.choose_queries"),padding:"xl",size:500,zIndex:320,children:s.jsx(o.Checkbox.Group,{value:[...i.queryIDs],onChange:i.setQueryIDs,children:s.jsx(o.Stack,{spacing:"lg",children:r.queries.options.map(d=>s.jsx(o.Checkbox,{label:d.label,value:d.value},d.value))})})}),s.jsxs(o.Stack,{spacing:6,children:[s.jsx(o.Group,{position:"left",children:s.jsx(o.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(zi,{id:i.queryIDs[0],moreActions:s.jsx(o.Tooltip,{label:e("query.open"),children:s.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(i.queryIDs[0]),children:s.jsx(k.IconArrowCurveRight,{size:16})})})}),u>1&&s.jsxs(o.Tabs,{defaultValue:i.queryIDs[0],children:[s.jsx(o.Tabs.List,{children:i.queries.map(d=>s.jsx(o.Tabs.Tab,{value:d.id,children:d.name},d.id))}),i.queries.map(d=>s.jsx(o.Tabs.Panel,{value:d.id,children:s.jsx(zi,{id:d.id,moreActions:s.jsx(o.Tooltip,{label:e("query.open"),children:s.jsx(o.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>c(d.id),children:s.jsx(k.IconArrowCurveRight,{size:16})})})})},d.id))]})]})]})}),c1=S.observer(()=>{const{panel:t}=mt();return s.jsx(je,{children:s.jsx(o.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:s.jsxs(o.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(o.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[s.jsx(o.Group,{children:s.jsx(bi,{})}),s.jsx(o.Group,{grow:!0,position:"center",children:s.jsx(o.Text,{lineClamp:1,weight:"bold",children:t.title.show?t.name:""})}),s.jsx(o.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),s.jsx(o.Group,{px:5,pb:5,sx:{flexGrow:1,".panel-viz-section":{height:"calc(100% - 28px)"}},children:s.jsx(vi,{panel:t})})]})})})}),Mi={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 u1{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(Mi.name)).length;this.panel.addVariable(b.cloneDeep({...Mi,name:`${Mi.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 d1(){const{panel:t}=ze();return G.useCreation(()=>new u1(t),[t])}function p1({label:t,value:e,onChange:n},r){const[i,a]=m.useState(Array.isArray(e)?[...e]:[]),l=m.useCallback(()=>{a(g=>[...g,""])},[a]),c=m.useCallback(g=>{a(y=>(y.splice(g,1),[...y]))},[a]),u=m.useMemo(()=>!b.isEqual(i,e),[i,e]),d=()=>{n(i.map(g=>g.toString()))},p=o.useMantineTheme(),h=m.useMemo(()=>Object.entries(p.colors).map(([g,y])=>y[6]),[p]);return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{position:"left",ref:r,children:[s.jsx(o.Text,{children:t}),s.jsx(o.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!u,onClick:d,children:s.jsx(L.DeviceFloppy,{size:20})})]}),s.jsxs(o.Group,{children:[i.map((g,y)=>s.jsx(o.ColorInput,{value:g,onChange:v=>{a(w=>(w.splice(y,1,v),[...w]))},swatches:h,rightSection:s.jsx(o.ActionIcon,{onClick:()=>c(y),color:"red",children:s.jsx(L.Trash,{size:14})}),sx:{width:"45%"}})),s.jsx(o.ActionIcon,{onClick:l,color:"blue",variant:"outline",children:s.jsx(L.PlaylistAdd,{size:20})})]})]})}const h1=m.forwardRef(p1);function m1({label:t,value:e,onChange:n,type:r},i){const[a,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(a.map(String),e.map(String)),[a,e]),p=()=>{n(a.map(h=>r==="number"?Number(h):h.toString()))};return s.jsxs(s.Fragment,{children:[s.jsxs(o.Group,{position:"left",ref:i,children:[s.jsx(o.Text,{children:t}),s.jsx(o.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!d,onClick:p,children:s.jsx(L.DeviceFloppy,{size:20})})]}),s.jsxs(o.Group,{children:[a.map((h,g)=>s.jsx(o.TextInput,{type:r,value:h,onChange:y=>{const v=y.currentTarget.value;l(w=>(w.splice(g,1,v),[...w]))},rightSection:s.jsx(o.ActionIcon,{onClick:()=>u(g),color:"red",children:s.jsx(L.Trash,{size:14})}),sx:{width:"45%"}})),s.jsx(o.ActionIcon,{onClick:c,color:"blue",variant:"outline",children:s.jsx(L.PlaylistAdd,{size:20})})]})]})}const x1=m.forwardRef(m1),g1=m.forwardRef(function({value:e,onChange:n},r){const{t:i}=_.useTranslation(),a=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(o.Stack,{children:s.jsx(o.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(o.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:s.jsx(fl,{label:i("style.font_weight.label"),value:e.weight,onChange:u=>l("weight",u)})}),s.jsx(o.Divider,{mt:"lg",mb:0,variant:"dashed",label:i("style.label"),labelPosition:"center"}),s.jsxs(o.Stack,{children:[s.jsx(o.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:e.color.type,onChange:c}),a==="static"&&s.jsx(Te,{value:e.color.staticColor,onChange:u=>l("color.staticColor",u)}),a==="continuous"&&s.jsxs(s.Fragment,{children:[s.jsx(x1,{label:"Value Range",value:e.color.valueRange,type:"number",onChange:u=>l("color.valueRange",u)}),s.jsx(h1,{label:"Color Range",value:e.color.colorRange,onChange:u=>l("color.colorRange",u)})]})]})]})}),f1=m.forwardRef(function({value:e,onChange:n,withStyle:r=!0,remove:i},a){const{t:l}=_.useTranslation(),c=(u,d)=>{const p=b.cloneDeep(e);b.set(p,u,d),n(p)};return s.jsxs(o.Stack,{ref:a,children:[s.jsxs(o.Stack,{spacing:"xs",px:"sm",py:"md",sx:{border:"1px solid #e9ecef"},children:[s.jsxs(o.Group,{grow:!0,noWrap:!0,children:[s.jsx(o.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(o.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(o.Accordion,{variant:"contained",children:s.jsxs(o.Accordion.Item,{value:"Styles",children:[s.jsx(o.Accordion.Control,{icon:s.jsx(o.Text,{size:"xl",children:"🖼️"}),children:l("style.label")}),s.jsx(o.Accordion.Panel,{children:s.jsx(g1,{value:e,onChange:n})})]})}),s.jsx(o.Button,{mt:20,leftIcon:s.jsx(k.IconTrash,{size:16}),color:"red",variant:"light",onClick:i,children:l("panel.variable.delete")})]})}),y1=S.observer(t=>{const{t:e}=_.useTranslation(),n=G.useCreation(()=>hc(t.variable),[t.variable]),r=()=>t.uiModel.remove(t.variable);return s.jsxs(o.Stack,{"data-testid":"variable-editor",align:"stretch",children:[s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.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(o.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(f1,{value:x.getSnapshot(n.copy),onChange:n.update,remove:r})]})});S.observer(t=>{const{uiModel:e}=t;return s.jsx(o.Stack,{className:"var-list",children:e.variables.map(n=>s.jsx(o.Button,{variant:e.selected===n?"filled":"subtle",color:"gray",onClick:()=>e.select(n),children:n.name},n.name))})});const b1=S.observer(({model:t})=>{const{t:e}=_.useTranslation();return s.jsx(o.Overlay,{color:"#fff",opacity:1,sx:{position:"absolute"},children:s.jsx(o.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")})})}),v1=S.observer(()=>{var n;const{t}=_.useTranslation(),e=d1();return e.variableOptions.length===0?s.jsx(b1,{model:e}):s.jsxs(o.Stack,{pb:20,children:[s.jsxs(o.Group,{position:"left",children:[s.jsx(o.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(o.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(o.Divider,{variant:"dashed"}),e.selected?s.jsx(y1,{uiModel:e,variable:e.selected}):s.jsx("span",{children:"Select or create a new variable on right side"})]})}),_1=S.observer(()=>{const{t}=_.useTranslation(),{panel:e}=ze();return Object.keys(e.variableStrings).length===0?null:s.jsxs(o.Stack,{mt:22,spacing:4,children:[s.jsx(o.Text,{size:"sm",fw:500,color:"dimmed",children:t("panel.variable.labels")}),s.jsx(_t.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(e.variableStrings,null,4)})]})});function j1(){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 w1=S.observer(({value:t,submit:e})=>{const{t:n}=_.useTranslation(),[r,i]=ie.useInputState(t);m.useEffect(()=>{i(t)},[t]);const a=j1(),l=t!==r;return s.jsx(o.Select,{label:n("visualization.component"),value:r,searchable:!0,onChange:i,data:a,rightSection:s.jsx(o.ActionIcon,{variant:"filled",color:"green",disabled:!l,onClick:()=>e(r),children:s.jsx(L.DeviceFloppy,{size:20})}),maxDropdownHeight:600})}),Hc=[];function C1(t,e){try{return t.resolveComponent(e).createConfig()}catch{return null}}function S1(){const{data:t,panel:{variables:e,viz:n,title:r,name:i,queryIDs:a,description:l,id:c}}=ze(),{vizManager:u}=m.useContext(ut),d={name:i,title:r,description:l,viz:n,queryIDs:a,id:c},p=xc(d);try{return u.resolveComponent(d.viz.type),s.jsx(os,{configure:p,children:s.jsx(JS,{variables:e,setVizConf:n.setConf,panel:d,vizManager:u,data:t})})}catch(h){return console.info(b.get(h,"message")),null}}const k1=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=C1(n,d);e.setType(d),e.setConf(p||{})},[e.type]),i=d=>{try{e.setConf(JSON.parse(d))}catch(p){console.error(p)}},a=m.useMemo(()=>{var d;return(d=Hc.find(p=>p.value===e.type))==null?void 0:d.Panel},[e.type,Hc]),l=S1(),c=a?m.createElement(a,{data:t,conf:e.conf,setConf:e.setConf}):null,u=l||c;return s.jsxs(o.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[s.jsx(w1,{submit:r,value:e.type}),s.jsxs(je,{children:[s.jsx(o.Stack,{pb:10,sx:{flexGrow:1,maxHeight:"100%",overflow:"auto"},children:u}),!u&&s.jsx(o.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(e.conf,null,2),onChange:i})]})]})}),T1=S.observer(({panel:t,sourceViewID:e})=>{const{t:n}=_.useTranslation(),r=Y(),[i,a]=m.useState(e);m.useEffect(()=>{a(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(o.Button,{size:"xs",variant:"subtle",color:"blue",onClick:c,leftIcon:s.jsx(k.IconBoxMultiple,{size:14}),children:n("panel.settings.change_view")}),s.jsx(o.Modal,{opened:l,onClose:u,title:n("panel.settings.change_view_title"),zIndex:320,children:s.jsxs(o.Stack,{sx:{maxHeight:"calc(100vh - 185px)",overflow:"hidden"},children:[s.jsx(o.Radio.Group,{value:i,onChange:a,pb:10,sx:{flexGrow:1,maxHeight:"calc(100vh - 185px - 30px)",overflow:"auto"},children:s.jsx(o.Stack,{spacing:"xs",children:r.views.options.map(p=>s.jsx(o.Radio,{value:p.value,label:p.label},p.value))})}),s.jsxs(o.Group,{noWrap:!0,position:"apart",sx:{flexGrow:0,flexShrink:0},children:[s.jsx(o.Button,{size:"xs",color:"red",leftIcon:s.jsx(k.IconX,{size:14}),onClick:u,children:n("common.actions.cancel")}),s.jsx(o.Button,{size:"xs",color:"blue",leftIcon:s.jsx(k.IconDeviceFloppy,{size:14}),onClick:d,disabled:i===e,children:n("common.actions.confirm")})]})]})})]})}),D1={root:{flexGrow:1,width:"100%",minWidth:"1200px",overflow:"hidden"},panel:{width:"100%",minWidth:"1200px",height:"calc(100% - 44px)",padding:10,overflow:"auto"}},Ii=({children:t})=>s.jsxs(o.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"100%",position:"relative"},children:[s.jsx(o.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:t}),s.jsxs(o.Stack,{justify:"flex-start",sx:{alignSelf:"flex-start",width:"600px",flexGrow:0,flexShrink:0},children:[s.jsx(c1,{}),s.jsx(o.Box,{sx:{flexGrow:1},children:s.jsx(_1,{})})]})]});function z1(t){return!["richText","button"].includes(t)}const M1=S.observer(({panel:t})=>{const{t:e}=_.useTranslation(),n=Fe.useModals(),r=Z(),i=Y(),[a,l]=m.useState("Data"),c=t.queries,d=z1(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])},y=()=>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(o.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[s.jsx(o.Text,{pt:9,pb:8,children:t.name}),s.jsxs(o.Group,{position:"right",noWrap:!0,children:[s.jsx(T1,{panel:t,sourceViewID:h}),s.jsx(o.Button,{size:"xs",variant:"subtle",color:"red",onClick:y,leftIcon:s.jsx(k.IconTrash,{size:14}),children:e("panel.delete")})]})]}),s.jsxs(o.Tabs,{value:a,onTabChange:l,keepMounted:!1,styles:D1,children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"Data",disabled:d,children:e("data.label")}),s.jsx(o.Tabs.Tab,{value:"Panel",children:e("panel.label")}),s.jsx(o.Tabs.Tab,{value:"Variables",disabled:p,children:s.jsx(o.Tooltip,{label:e("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:s.jsx(o.Text,{children:e("panel.variable.labels")})})}),s.jsx(o.Tabs.Tab,{value:"Visualization",disabled:p,children:s.jsx(o.Tooltip,{label:e("data.requires_data"),disabled:!p,withinPortal:!0,zIndex:310,children:s.jsx(o.Text,{children:e("visualization.label")})})}),s.jsx(o.Tabs.Tab,{value:"Interactions",children:e("interactions.label")})]}),s.jsxs(o.Tabs.Panel,{value:"Data",children:[s.jsx(o.LoadingOverlay,{visible:d,exitTransitionDuration:0}),s.jsx(l1,{})]}),s.jsx(o.Tabs.Panel,{value:"Panel",children:s.jsx(Ii,{children:s.jsx(t1,{})})}),s.jsx(o.Tabs.Panel,{value:"Variables",children:s.jsx(Ii,{children:s.jsx(v1,{})})}),s.jsx(o.Tabs.Panel,{value:"Visualization",children:s.jsx(je,{children:s.jsx(Ii,{children:s.jsx(k1,{})})})}),s.jsx(o.Tabs.Panel,{value:"Interactions",children:s.jsx(je,{children:s.jsx(yh,{})})})]})]})}),I1=S.observer(({viewID:t,panelID:e})=>{const n=Y();if(!n.views.findByID(t))return s.jsxs(o.Text,{size:14,children:["View by ID[",t,"] is not found"]});const i=n.panels.findByID(e);return i?s.jsx(M1,{panel:i}):s.jsxs(o.Text,{size:14,children:["Panel by ID[",e,"] is not found"]})}),E1=S.observer(()=>{const{t}=_.useTranslation(),[e,n]=m.useState([]),r=Fe.useModals(),i=Z(),a=g=>{i.editor.setPath(["_QUERIES_",g])},l=()=>{r.openConfirmModal({title:"Delete ununsed queries?",children:s.jsx(o.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.content.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(o.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[s.jsx(o.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:s.jsx(o.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:t("query.manage")})}),s.jsxs(o.Flex,{justify:"space-between",align:"center",px:12,children:[s.jsxs(o.Group,{position:"left",children:[s.jsxs(o.Button.Group,{children:[s.jsx(o.Button,{variant:"default",size:"xs",onClick:d,children:t("common.actions.select_all")}),s.jsx(o.Button,{variant:"default",size:"xs",onClick:p,children:t("common.actions.clear_selection")})]}),s.jsx(o.Button,{size:"xs",color:"blue",leftIcon:s.jsx(k.IconCode,{size:14}),disabled:e.length===0,onClick:c,children:t("common.actions.download_schema")})]}),s.jsx(o.Button,{variant:"subtle",size:"xs",color:"red",leftIcon:s.jsx(k.IconTrash,{size:14}),disabled:!i.content.hasUnusedQueries,onClick:l,children:t("query.delete_unused")})]}),s.jsx(o.Box,{sx:{flexGrow:1,overflow:"auto"},children:s.jsx(o.Checkbox.Group,{size:"xs",value:e,onChange:n,children:s.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"40px"}}),s.jsx("th",{children:t("common.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 y=((v=h[g.id])==null?void 0:v.length)??0;return s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx(o.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:y===0?"#ff0000":"#000",fontWeight:y===0?"bold":"normal",textAlign:"center"},children:y}),s.jsx("td",{children:s.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>a(g.id),children:t("common.actions.open")})})]},g.id)})})]})})})]})}),A1=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(o.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(o.Box,{sx:{alignSelf:"flex-end"},children:s.jsx(o.Button,{disabled:!0,size:"xs",leftIcon:s.jsx(k.IconTrash,{size:16}),children:e("query.delete")})})}):s.jsx(o.Button,{color:"red",size:"xs",onClick:u,leftIcon:s.jsx(k.IconTrash,{size:16}),sx:{alignSelf:"flex-end"},children:e("query.delete")})},P1=S.observer(A1),eu=({width:t="calc(100% - 32px)",lastWidth:e="50%",height:n,count:r,spacing:i=16,pl:a=0})=>s.jsxs(o.Stack,{spacing:i,mt:6,pl:a,children:[Array.from(new Array(r-1),(l,c)=>s.jsx(o.Skeleton,{width:t,height:n,radius:"xs"},c)),s.jsx(o.Skeleton,{width:e,height:n,radius:"xs"})]}),_n=({value:t})=>t===null||t===""?null:s.jsx(o.Tooltip,{label:t,disabled:!t,multiline:!0,children:s.jsx(o.ActionIcon,{children:s.jsx(k.IconInfoCircle,{size:14})})}),$1=({column:t})=>{const{column_key:e,column_key_text:n}=t;return e?s.jsx(o.Tooltip,{label:n,disabled:!n,children:s.jsx(o.Badge,{children:e})}):null},B1=S.observer(({dataSource:t})=>{const{columns:e}=t;return e.loading?s.jsx(eu,{height:"24px",width:"100%",lastWidth:"100%",count:20,pl:6}):e.empty?null:s.jsxs(o.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(_n,{value:n.column_comment})}),s.jsx("td",{children:s.jsx($1,{column:n})}),s.jsx("td",{children:n.column_type}),s.jsx("td",{children:n.is_nullable}),s.jsx("td",{children:s.jsx(_n,{value:n.column_default})})]},n.column_name))})]})}),L1=S.observer(({dataSource:t})=>{const{indexes:e}=t,n=e.data;return s.jsxs(o.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))})]})}),q1=S.observer(({dataSource:t})=>{const{indexes:e}=t,n=e.data;return s.jsxs(o.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(_n,{value:r.index_definition})}),s.jsx("td",{children:s.jsx(_n,{value:r.condition})}),s.jsx("td",{children:s.jsx(_n,{value:r.comment})})]},r.index_name))})]})}),O1=S.observer(({dataSource:t})=>{const{indexes:e}=t;return e.loading||e.empty?null:t.type===de.MySQL?s.jsx(L1,{dataSource:t}):t.type===de.Postgresql?s.jsx(q1,{dataSource:t}):null}),V1=S.observer(({dataSource:t})=>s.jsxs(o.Stack,{spacing:40,pt:10,sx:{flexGrow:1,overflow:"auto",position:"relative"},children:[s.jsx(je,{children:s.jsx(B1,{dataSource:t})}),s.jsx(je,{children:s.jsx(O1,{dataSource:t})})]}));function N1({table_type:t}){return t==="VIEW"?s.jsx(k.IconEye,{size:14}):t==="BASE TABLE"?s.jsx(k.IconTable,{size:14}):null}const G1=S.observer(({dataSource:t})=>{const{tables:e}=t;return e.loading?s.jsx(eu,{height:"24px",lastWidth:"50%",count:15}):s.jsx(o.Box,{h:"100%",sx:{overflow:"auto",".mantine-NavLink-label":{fontFamily:"monospace"}},children:Object.entries(e.data).map(([n,r])=>s.jsx(o.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(o.NavLink,{label:i.table_name,icon:s.jsx(N1,{table_type:i.table_type}),onClick:()=>{t.setKeywords(n,i.table_name)},active:t.table_name===i.table_name},i.table_name))},n))})}),F1=({visible:t})=>s.jsx(o.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:s.jsx(o.LoadingOverlay,{visible:t})}),W1=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],Q1={icon:{width:"50px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"50px"}}},R1=S.observer(({dataSource:t})=>{const{t:e}=_.useTranslation(),{tableData:n}=t;return s.jsxs(o.Group,{pt:10,px:10,position:"apart",children:[s.jsxs(o.Group,{position:"left",children:[n.maxPage>1&&s.jsx(o.Pagination,{size:"sm",value:n.page,onChange:n.setPage,total:n.maxPage,withEdges:n.maxPage>7,styles:{control:{height:"30px"}}}),s.jsx(o.Select,{icon:s.jsx(o.Text,{ta:"center",color:"dimmed",size:14,children:e("common.pagination.page_size")}),size:"xs",styles:Q1,data:W1,value:String(n.limit),onChange:r=>n.setLimit(Number(r))})]}),s.jsx(o.Group,{position:"right",children:s.jsx(o.Text,{color:"dimmed",my:0,size:14,children:e("common.pagination.total_rows",{total:n.total})})})]})}),U1=S.observer(({dataSource:t})=>{const e=t.tableData;return e.maxPage===0?s.jsx(o.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:"This table is empty"}):e.error?s.jsx(o.Text,{mt:20,color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:e.error}):e.page===1&&e.loading?s.jsx(F1,{visible:!0}):s.jsxs(je,{children:[s.jsx(R1,{dataSource:t}),s.jsxs(o.Box,{py:10,sx:{width:"100%",height:"calc(100% - 42px)",overflow:"auto",position:"relative"},children:[s.jsx(o.LoadingOverlay,{visible:e.loading,overlayBlur:2}),s.jsx(Zc,{data:e.data})]})]})}),Y1={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},K1=S.observer(({dataSource:t})=>{const{t:e}=_.useTranslation();return m.useEffect(()=>{t.loadTablesIfEmpty()},[t]),t.tables.error?s.jsx(o.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:t.tables.error}):s.jsxs(o.Flex,{sx:{height:"100%"},children:[s.jsx(o.Box,{w:300,sx:{flexGrow:0,flexShrink:0,position:"relative"},children:s.jsx(je,{children:s.jsx(G1,{dataSource:t})})}),s.jsxs(o.Tabs,{defaultValue:"structure",styles:Y1,children:[s.jsxs(o.Tabs.List,{children:[s.jsx(o.Tabs.Tab,{value:"structure",icon:s.jsx(k.IconColumns,{size:14}),children:e("data_source.table_structure_short")}),s.jsx(o.Tabs.Tab,{value:"data",icon:s.jsx(k.IconDatabase,{size:14}),children:e("data.label")})]}),s.jsx(o.Tabs.Panel,{value:"structure",children:s.jsx(V1,{dataSource:t})}),s.jsx(o.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:s.jsx(U1,{dataSource:t})})]})]})}),J1={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"}},tu=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(o.Modal,{opened:r,onClose:()=>i(!1),title:s.jsxs(o.Group,{position:"apart",sx:{flexGrow:1},children:[s.jsx(o.Text,{fw:500,children:n("data_source.explorer")}),s.jsxs(o.Group,{spacing:7,children:[s.jsx(o.Badge,{variant:"gradient",gradient:{from:"indigo",to:"cyan"},children:t.key}),s.jsx(o.Badge,{variant:"gradient",gradient:{from:"orange",to:"red"},children:t.type})]})]}),zIndex:320,size:"96vw",styles:J1,children:s.jsx(o.Box,{sx:{height:"calc(100vh - 220px)"},children:s.jsx(K1,{dataSource:t})})}),s.jsx(o.Button,{variant:"subtle",onClick:()=>i(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},...e,children:n("data_source.see_table_structure")})]})}),X1=m.forwardRef(({label:t,type:e,...n},r)=>e===de.Transform?s.jsxs(o.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(o.Text,{color:"blue",children:t})]}):s.jsxs(o.Group,{position:"apart",ref:r,...n,children:[s.jsx(o.Text,{children:t}),s.jsx(o.Text,{children:e})]})),Z1=S.observer(({value:t,onChange:e})=>{const{t:n}=_.useTranslation(),r=Z(),{data:i=[],loading:a}=G.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(o.Select,{data:l,label:s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Box,{children:n("data_source.label")}),d&&s.jsx(tu,{dataSource:d,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:X1,rightSection:d?s.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:t.key,onChange:u})}),nu=m.forwardRef((t,e)=>{const{label:n,description:r,...i}=t;return s.jsx("div",{ref:e,...i,children:s.jsxs(o.Group,{position:"apart",noWrap:!0,children:[s.jsx(o.Text,{children:n}),s.jsx(o.Text,{size:"xs",color:"dimmed",children:r})]})})}),H1=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation(),[n,r]=m.useState(t.name);return m.useEffect(()=>{r(t.name)},[t.name]),s.jsx(o.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:s.jsxs(o.Stack,{spacing:10,sx:{width:"100%"},children:[s.jsx(o.Divider,{mb:-10,variant:"dashed",label:e("query.basics"),labelPosition:"center"}),s.jsx(o.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(o.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(Z1,{value:{type:t.type,key:t.key},onChange:({type:i,key:a})=>{t.setKey(a),t.setType(i)}}),s.jsx(o.Divider,{mt:10,mb:-10,variant:"dashed",label:e("query.conditions"),labelPosition:"center"}),s.jsx(o.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:nu,maxDropdownHeight:500}),t.typedAsHTTP&&s.jsx(o.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:nu,maxDropdownHeight:500}),s.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),s.jsx(P1,{queryModel:t})]})})});function eD({content:t}){return s.jsxs(o.HoverCard,{width:"60vw",shadow:"md",children:[s.jsx(o.HoverCard.Target,{children:s.jsx(o.ActionIcon,{size:16,color:"blue",children:s.jsx(k.IconEye,{})})}),s.jsx(o.HoverCard.Dropdown,{children:s.jsx(_t.Prism,{language:"sql",noCopy:!0,withLineNumbers:!0,children:t})})]})}const tD=S.observer(()=>{const e=[...Z().globalSQLSnippets.list];return e.length===0?null:s.jsxs(o.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(eD,{content:i})})]},r)})})]})}),nD=`
|
|
464
|
+
`,_A=()=>{const{t:e}=_.useTranslation(),[t,n]=g.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(nn.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:vA})})]})},jA=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(Sl,{value:s.options_query_id,onChange:s.setOptionsQueryID}),r.jsx(_A,{})]})}),wA=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(nn.Prism,{mt:22,language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),CA={select:yA,"multi-select":xA,"tree-select":jA,"text-input":bA,checkbox:hA,"date-range":gA},In={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"},SA=D.observer(function({filter:t}){const{t:n,i18n:s}=_.useTranslation(),i=Y(),a=g.useMemo(()=>CA[t.type],[t.type]),l=g.useMemo(()=>[{label:n(In.select),value:"select"},{label:n(In["multi-select"]),value:"multi-select"},{label:n(In["tree-select"]),value:"tree-select"},{label:n(In["text-input"]),value:"text-input"},{label:n(In.checkbox),value:"checkbox"},{label:n(In["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(wA,{filter:t})]})}),kA=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(SA,{filter:a})})]})}),TA=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.useState([]),s=Z(),i=d=>{s.editor.setPath(["_FILTERS_",d])},a=()=>{s.content.filters.downloadSchema(t)},l=g.useMemo(()=>s.content.filters.sortedList.map(d=>d.id),[s.content.filters.sortedList]),c=()=>{n(l)},u=()=>{n([])};return r.jsxs(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(In[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))})]})})})]})}),DA=D.observer(()=>{const{t:e}=_.useTranslation(),t=Y(),[n,s]=g.useState(()=>JSON.stringify(t.mock_context.current,null,4)),i=()=>{try{t.mock_context.replace(JSON.parse(n))}catch(l){tn.showNotification({title:"Failed",message:l.message,color:"red"})}},a=g.useMemo(()=>{try{return JSON.stringify(JSON.parse(n))!==JSON.stringify(t.mock_context.current)}catch{return!1}},[n,t.mock_context.current]);return r.jsxs(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})})]})]})}),MA=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge();return r.jsx(wo,{label:e("panel.panel_description"),value:t.description,onChange:t.setDescription,styles:{root:{flexGrow:1}}})}),zA=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)})]})]})}),IA=()=>r.jsxs("span",{className:"mantine-103svbs mantine-InputWrapper-required mantine-Select-required","aria-hidden":"true",children:[" ","*"]}),EA=D.observer(()=>{const{t:e}=_.useTranslation(),{panel:t}=Ge(),{name:n}=t,[s,i]=he.useInputState(n),a=n!==s,l=g.useCallback(()=>{a&&t.setName(s)},[a,s]);g.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(IA,{})]}),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})]})}),AA=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 PA(){const{t:e}=_.useTranslation();return r.jsxs(o.Stack,{sx:{height:"100%"},children:[r.jsx(zA,{}),r.jsx(o.Divider,{label:e("common.info"),labelPosition:"center",variant:"dashed"}),r.jsx(EA,{}),r.jsx(AA,{}),r.jsx(MA,{})]})}const OA={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 Wf({data:e}){const t=g.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:OA,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 LA=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],BA={icon:{width:"80px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"80px"}}},qA=({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:BA,data:LA,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})})})]})},VA=Am(({data:e,loading:t})=>{const[n,s]=g.useState(1),[i,a]=g.useState(20),l=g.useMemo(()=>{const c=(n-1)*i,u=c+i;return e.slice(c,u)},[e,n,i]);return r.jsxs(ze,{children:[r.jsx(qA,{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(Wf,{data:l})]})]})}),NA=({queryID:e})=>{const t=_e(),{state:n,error:s}=t.getDataStuffByID(e),i=g.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},kl=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=g.useCallback(()=>{i.queries.refetchDataByQueryID(e)},[e,i]),d=()=>{i.queries.downloadDataByQueryID(e)};g.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(NA,{queryID:e}),r.jsx(VA,{data:a,loading:c})]})]})}),$A=D.observer(function(){const{t}=_.useTranslation(),n=Z(),s=Y(),{panel:i}=Ge(),[a,l]=g.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(kl,{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(kl,{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))]})]})]})}),FA=D.observer(()=>{const{panel:e}=Qt();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(ml,{})}),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(xl,{panel:e})})]})})})}),Tl={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 GA{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(Tl.name)).length;this.panel.addVariable(v.cloneDeep({...Tl,name:`${Tl.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 WA(){const{panel:e}=Ge();return W.useCreation(()=>new GA(e),[e])}function RA({label:e,value:t,onChange:n},s){const[i,a]=g.useState(Array.isArray(t)?[...t]:[]),l=g.useCallback(()=>{a(f=>[...f,""])},[a]),c=g.useCallback(f=>{a(x=>(x.splice(f,1),[...x]))},[a]),u=g.useMemo(()=>!v.isEqual(i,t),[i,t]),d=()=>{n(i.map(f=>f.toString()))},p=o.useMantineTheme(),h=g.useMemo(()=>Object.entries(p.colors).map(([f,x])=>x[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,x)=>r.jsx(o.ColorInput,{value:f,onChange:y=>{a(j=>(j.splice(x,1,y),[...j]))},swatches:h,rightSection:r.jsx(o.ActionIcon,{onClick:()=>c(x),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 QA=g.forwardRef(RA);function UA({label:e,value:t,onChange:n,type:s},i){const[a,l]=g.useState(Array.isArray(t)?[...t]:[]),c=g.useCallback(()=>{l(h=>[...h,""])},[l]),u=g.useCallback(h=>{l(f=>(f.splice(h,1),[...f]))},[l]),d=g.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:x=>{const y=x.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 YA=g.forwardRef(UA),KA=g.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(lh,{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(YA,{label:"Value Range",value:t.color.valueRange,type:"number",onChange:u=>l("color.valueRange",u)}),r.jsx(QA,{label:"Color Range",value:t.color.colorRange,onChange:u=>l("color.colorRange",u)})]})]})]})}),XA=g.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(go,{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(KA,{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")})]})}),JA=D.observer(e=>{const{t}=_.useTranslation(),n=W.useCreation(()=>sf(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(XA,{value:m.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 ZA=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")})})}),HA=D.observer(()=>{var n;const{t:e}=_.useTranslation(),t=WA();return t.variableOptions.length===0?r.jsx(ZA,{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(JA,{uiModel:t,variable:t.selected}):r.jsx("span",{children:"Select or create a new variable on right side"})]})}),eP=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(nn.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t.variableStrings,null,4)})]})});function tP(){const{t:e}=_.useTranslation(),{vizManager:t}=g.useContext(Nt);return g.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 nP=D.observer(({value:e,submit:t})=>{const{t:n}=_.useTranslation(),[s,i]=he.useInputState(e);g.useEffect(()=>{i(e)},[e]);const a=tP(),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})}),Rf=[];function rP(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function sP(){const{data:e,panel:{variables:t,viz:n,title:s,name:i,queryIDs:a,description:l,id:c}}=Ge(),{vizManager:u}=g.useContext(Nt),d={name:i,title:s,description:l,viz:n,queryIDs:a,id:c},p=of(d);try{return u.resolveComponent(d.viz.type),r.jsx(ri,{configure:p,children:r.jsx(MI,{variables:t,setVizConf:n.setConf,panel:d,vizManager:u,data:e})})}catch(h){return console.info(v.get(h,"message")),null}}const iP=D.observer(()=>{const{data:e,panel:{viz:t}}=Ge(),{vizManager:n}=g.useContext(Nt),s=g.useCallback(d=>{if(d===t.type)return;const p=rP(n,d);t.setType(d),t.setConf(p||{})},[t.type]),i=d=>{try{t.setConf(JSON.parse(d))}catch(p){console.error(p)}},a=g.useMemo(()=>{var d;return(d=Rf.find(p=>p.value===t.type))==null?void 0:d.Panel},[t.type,Rf]),l=sP(),c=a?g.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(nP,{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})]})]})}),aP=D.observer(({panel:e,sourceViewID:t})=>{const{t:n}=_.useTranslation(),s=Y(),[i,a]=g.useState(t);g.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")})]})]})})]})}),oP={root:{flexGrow:1,width:"100%",minWidth:"1200px",overflow:"hidden"},panel:{width:"100%",minWidth:"1200px",height:"calc(100% - 44px)",padding:10,overflow:"auto"}},Dl=({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(FA,{}),r.jsx(o.Box,{sx:{flexGrow:1},children:r.jsx(eP,{})})]})]});function lP(e){return!["richText","button"].includes(e)}const cP=D.observer(({panel:e})=>{const{t}=_.useTranslation(),n=lt.useModals(),s=Z(),i=Y(),[a,l]=g.useState("Data"),c=e.queries,d=lP(e.viz.type)&&e.dataLoading,p=d||e.queryErrors.length>0||e.queryStateMessages!==""||c.length===0,h=s.editor.path[1];g.useEffect(()=>{l(y=>p&&y==="Visualization"?"Data":y)},[e.id,p]);const f=()=>{s.editor.setPath(["_VIEWS_",h])},x=()=>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(Oi,{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(aP,{panel:e,sourceViewID:h}),r.jsx(o.Button,{size:"xs",variant:"subtle",color:"red",onClick:x,leftIcon:r.jsx(M.IconTrash,{size:14}),children:t("panel.delete")})]})]}),r.jsxs(o.Tabs,{value:a,onTabChange:l,keepMounted:!1,styles:oP,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($A,{})]}),r.jsx(o.Tabs.Panel,{value:"Panel",children:r.jsx(Dl,{children:r.jsx(PA,{})})}),r.jsx(o.Tabs.Panel,{value:"Variables",children:r.jsx(Dl,{children:r.jsx(HA,{})})}),r.jsx(o.Tabs.Panel,{value:"Visualization",children:r.jsx(ze,{children:r.jsx(Dl,{children:r.jsx(iP,{})})})}),r.jsx(o.Tabs.Panel,{value:"Interactions",children:r.jsx(ze,{children:r.jsx(ry,{})})})]})]})}),uP=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(cP,{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]=g.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=g.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 x=((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:x===0?"#ff0000":"#000",fontWeight:x===0?"bold":"normal",textAlign:"center"},children:x}),r.jsx("td",{children:r.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>a(f.id),children:e("common.actions.open")})})]},f.id)})})]})})})]})}),pP=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")})},hP=D.observer(pP),Qf=({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"})]}),Qr=({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})})}),fP=({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},gP=D.observer(({dataSource:e})=>{const{columns:t}=e;return t.loading?r.jsx(Qf,{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(Qr,{value:n.column_comment})}),r.jsx("td",{children:r.jsx(fP,{column:n})}),r.jsx("td",{children:n.column_type}),r.jsx("td",{children:n.is_nullable}),r.jsx("td",{children:r.jsx(Qr,{value:n.column_default})})]},n.column_name))})]})}),mP=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))})]})}),xP=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(Qr,{value:s.index_definition})}),r.jsx("td",{children:r.jsx(Qr,{value:s.condition})}),r.jsx("td",{children:r.jsx(Qr,{value:s.comment})})]},s.index_name))})]})}),yP=D.observer(({dataSource:e})=>{const{indexes:t}=e;return t.loading||t.empty?null:e.type===ye.MySQL?r.jsx(mP,{dataSource:e}):e.type===ye.Postgresql?r.jsx(xP,{dataSource:e}):null}),bP=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(gP,{dataSource:e})}),r.jsx(ze,{children:r.jsx(yP,{dataSource:e})})]}));function vP({table_type:e}){return e==="VIEW"?r.jsx(M.IconEye,{size:14}):e==="BASE TABLE"?r.jsx(M.IconTable,{size:14}):null}const _P=D.observer(({dataSource:e})=>{const{tables:t}=e;return t.loading?r.jsx(Qf,{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(vP,{table_type:i.table_type}),onClick:()=>{e.setKeywords(n,i.table_name)},active:e.table_name===i.table_name},i.table_name))},n))})}),jP=({visible:e})=>r.jsx(o.Box,{py:10,sx:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:r.jsx(o.LoadingOverlay,{visible:e})}),wP=[{label:"10",value:"10"},{label:"20",value:"20"},{label:"50",value:"50"},{label:"100",value:"100"}],CP={icon:{width:"50px",textAlign:"center"},input:{"&[data-with-icon]":{paddingLeft:"50px"}}},SP=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:CP,data:wP,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})})})]})}),kP=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(jP,{visible:!0}):r.jsxs(ze,{children:[r.jsx(SP,{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(Wf,{data:t.data})]})]})}),TP={root:{flexGrow:1,overflow:"auto",borderLeft:"1px solid #efefef"},tabsList:{borderBottom:"1px solid #efefef"},tab:{minWidth:120}},DP=D.observer(({dataSource:e})=>{const{t}=_.useTranslation();return g.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(_P,{dataSource:e})})}),r.jsxs(o.Tabs,{defaultValue:"structure",styles:TP,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(bP,{dataSource:e})}),r.jsx(o.Tabs.Panel,{value:"data",sx:{width:"100%",height:"calc(100% - 36px)",overflow:"hidden"},children:r.jsx(kP,{dataSource:e})})]})]})}),MP={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"}},Uf=D.observer(({dataSource:e,triggerButtonProps:t={}})=>{const{t:n}=_.useTranslation(),[s,i]=g.useState(!1);return e.type==="http"?null:r.jsxs(r.Fragment,{children:[r.jsx(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:MP,children:r.jsx(o.Box,{sx:{height:"calc(100vh - 220px)"},children:r.jsx(DP,{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")})]})}),zP=g.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})]})),IP=D.observer(({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),s=Z(),{data:i=[],loading:a}=W.useRequest(Di,{refreshDeps:[]},[]),l=g.useMemo(()=>{const p=i.map(h=>({label:h.key,value:h.key,type:h.type}));return p.push({label:n("query.transform.data_source"),value:ye.Transform,type:ye.Transform}),p},[i]),c=g.useMemo(()=>l.reduce((p,h)=>(p[h.value]=h.type,p),{}),[l]),u=p=>{p!==null&&t({key:p,type:c[p]})},d=g.useMemo(()=>s.datasources.find(e),[s,e]);return r.jsx(o.Select,{data:l,label:r.jsxs(o.Group,{position:"apart",children:[r.jsx(o.Box,{children:n("data_source.label")}),d&&r.jsx(Uf,{dataSource:d,triggerButtonProps:{compact:!0,size:"xs",px:10}})]}),itemComponent:zP,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})}),Yf=g.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})]})})}),EP=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),[n,s]=g.useState(e.name);return g.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(IP,{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:Yf,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:Yf,maxDropdownHeight:500}),r.jsx(o.Divider,{mt:20,mb:10,variant:"dashed"}),r.jsx(hP,{queryModel:e})]})})});function AP({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(nn.Prism,{language:"sql",noCopy:!0,withLineNumbers:!0,children:e})})]})}const PP=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(AP,{content:i})})]},s)})})]})}),OP=`
|
|
465
465
|
-- You may reference query variables in SQL or VizConfig.
|
|
466
466
|
SELECT *
|
|
467
467
|
FROM commit
|
|
@@ -474,9 +474,9 @@ WHERE
|
|
|
474
474
|
AND \${sql_snippets.author_email_condition}
|
|
475
475
|
-- Global SQL snippets (shared between dashboards)
|
|
476
476
|
AND \${global_sql_snippets.account_condition}
|
|
477
|
-
`,
|
|
477
|
+
`,Kf=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(nn.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:OP})}),r.jsx(o.Tabs.Panel,{value:"local_query_vars",pt:"xs",children:r.jsx(nn.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(PP,{})]})})]})})}),Ml=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.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(Kf,{})}),r.jsx(o.Button,{variant:"subtle",onClick:()=>n(!0),px:16,styles:{inner:{justifyContent:"flex-start"}},children:e("query_variable.open")})]})}),Xf={pre:["function build_request({ context, filters }, utils) {"," // build the quest"," return { method: 'POST', url: '/', params: {}, headers: {}, data: {} }","}"].join(`
|
|
478
478
|
`),post:["function process_result(resp, utils, state) {"," return resp.data","}"].join(`
|
|
479
|
-
`)},
|
|
479
|
+
`)},LP=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(Ml,{})]}),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:Xf.pre})}),r.jsx(o.Tabs.Panel,{value:"post_process",p:"sm",children:r.jsx(er,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:Xf.post})})]}):null}),BP=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))})]})})}),zl=({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}})},qP=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),n=g.useMemo(()=>v.groupBy(e.dependencies,"type"),[e.dependencies]),s=g.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")})})}),VP="SELECT 1",NP=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),[n,s]=g.useState(e.sql),i=()=>{e.setSQL(n)},a=()=>{s(e.sql)},l=()=>{s(VP)};g.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(qP,{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(zl,{height:"100%",value:n,onChange:s,theme:"sql-dark",defaultLanguage:"sql"})]})}),$P=({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}}),FP=D.observer(({value:e})=>{const n=_e().payloadForSQL,s=g.useMemo(()=>wi(e,n),[e,n]);return r.jsx($P,{height:"100%",value:s})}),Jf={pre:["function process_request({ context, filters, sql }, utils) {"," // modify and return sql"," return sql","}"].join(`
|
|
480
480
|
`),post:["function process_result(data, utils, state) {"," // process data and return the result"," return data","}"].join(`
|
|
481
|
-
`)},
|
|
482
|
-
`),post:""},pD=S.observer(({queryModel:t})=>{const{t:e}=_.useTranslation(),n=Y();return t.isTransform?s.jsxs(o.Stack,{py:20,px:20,sx:{height:"100%"},children:[s.jsx(o.Text,{size:"sm",children:e("query.transform.guide.pick_queries")}),s.jsx(o.MultiSelect,{data:n.queries.optionsWithoutTransform,value:[...t.dep_query_ids],onChange:t.setDependantQueryIDs,maxDropdownHeight:800}),s.jsx(o.Text,{size:"sm",children:e("query.transform.guide.write_function")}),s.jsx(o.Box,{sx:{flexGrow:1},children:s.jsx(Ut,{label:"",value:t.pre_process,onChange:t.setPreProcess,defaultValue:dD.pre})})]}):null}),jn={height:"calc(100% - 44px)",padding:0},hD=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,a]=m.useState(r);m.useEffect(()=>{a(u=>u!=="Configurations"&&r==="Configurations"?"Configurations":u)},[r]);const l=n.findQueryUsage(t.id),c=l.length===0;return s.jsxs(o.Tabs,{value:i,onTabChange:a,defaultValue:r,orientation:"horizontal",keepMounted:!1,sx:{height:"100vh"},children:[s.jsxs(o.Tabs.List,{grow:!0,children:[s.jsx(o.Tabs.Tab,{value:"Configurations",children:e("query.configurations")}),t.typedAsSQL&&s.jsx(o.Tabs.Tab,{value:"SQL",children:e("query.request")}),t.typedAsHTTP&&s.jsx(o.Tabs.Tab,{value:"HTTP",children:e("query.request")}),t.isTransform&&s.jsx(o.Tabs.Tab,{value:"Transform",children:e("query.transform.label")}),s.jsx(o.Tabs.Tab,{value:"Data",disabled:!t.canPreviewData,children:s.jsx(o.Tooltip,{label:t.guideToPreviewData,disabled:t.canPreviewData,withinPortal:!0,children:s.jsx(o.Text,{children:e("data.preview_data")})})}),s.jsx(o.Tabs.Tab,{value:"Usage",disabled:c,children:s.jsx(o.Tooltip,{label:e("query.usage.unused_description"),disabled:!c,withinPortal:!0,children:s.jsx(o.Text,{children:e("query.usage.label")})})})]}),s.jsx(o.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:s.jsx(H1,{queryModel:t})}),t.typedAsSQL&&s.jsx(o.Tabs.Panel,{value:"SQL",sx:jn,children:s.jsx(o.Stack,{sx:{height:"100%"},children:s.jsx(uD,{queryModel:t})})}),t.typedAsHTTP&&s.jsx(o.Tabs.Panel,{value:"HTTP",sx:jn,children:s.jsx(o.Stack,{sx:{height:"100%"},children:s.jsx(sD,{queryModel:t})})}),t.isTransform&&s.jsx(o.Tabs.Panel,{value:"Transform",sx:jn,children:s.jsx(o.Stack,{sx:{height:"100%"},children:s.jsx(pD,{queryModel:t})})}),s.jsx(o.Tabs.Panel,{value:"Data",sx:{...jn,overflow:"hidden"},children:s.jsx(zi,{id:t.id,moreActions:null,refreshOnMount:!0})}),s.jsx(o.Tabs.Panel,{value:"Usage",sx:{...jn,overflow:"hidden"},children:s.jsx(rD,{queryID:t.id,usage:l})})]})}),mD=S.observer(({id:t})=>{const n=Y().queries.findByID(t);return t===""?null:n?s.jsx(hD,{queryModel:n}):s.jsx(o.Text,{size:14,color:"red",children:"Invalid Query ID"})}),xD=S.observer(({value:t})=>{const n=he().payloadForSQL,r=m.useMemo(()=>Ts(t,n),[t,n]);return s.jsx(Ai,{height:"100%",value:r})}),gD=S.observer(({item:t,remove:e,onKeyChanged:n})=>{const{t:r}=_.useTranslation(),[i,a]=m.useState("SQL"),[l,c]=m.useState(t.key),u=()=>{t.setKey(l),n(l)},d=l!==t.key,p=t.isADuplicatedKey(l),[h,g]=m.useState(t.value),y=()=>{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(o.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[s.jsxs(o.Group,{sx:{alignItems:"end"},spacing:40,children:[s.jsx(o.TextInput,{label:r(p?"sql_snippet.key_occupied":"sql_snippet.key"),value:l,onChange:D=>{c(D.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:s.jsx(o.ActionIcon,{color:"blue",variant:"subtle",onClick:u,disabled:!d||p,children:s.jsx(L.DeviceFloppy,{size:16})}),error:p}),s.jsx(o.Button,{leftIcon:s.jsx(L.Trash,{size:16}),color:"red",variant:"light",onClick:T,children:r("sql_snippet.delete")})]}),s.jsxs(o.Tabs,{value:i,onTabChange:a,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[s.jsxs(o.Tabs.List,{sx:{position:"relative"},children:[s.jsx(o.Tabs.Tab,{value:"SQL",children:r("sql_snippet.edit_snippet")}),s.jsx(o.Tabs.Tab,{value:"Preview",children:r("sql_snippet.preview_snippet")}),s.jsx(Ei,{}),s.jsx(o.ActionIcon,{color:"blue",variant:"filled",onClick:y,disabled:!v,sx:{position:"absolute",top:0,right:10},children:s.jsx(L.DeviceFloppy,{size:18})})]}),s.jsx(o.Tabs.Panel,{value:"SQL",pt:"sm",children:s.jsx(Ai,{height:"100%",value:h,onChange:g,defaultLanguage:"sql",theme:"sql-dark"})}),s.jsx(o.Tabs.Panel,{value:"Preview",pt:"sm",children:s.jsx(xD,{value:h})})]})]})}),fD=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(o.Text,{size:14,children:["SQL Snippet by key[",t,"] is not found"]});const i=()=>{e.editor.setPath(["_SQL_SNIPPETS_",""])},a=()=>{n.sqlSnippets.removeByKey(t),i()},l=c=>{e.editor.setPath(["_SQL_SNIPPETS_",c])};return s.jsx(gD,{item:r,remove:a,onKeyChanged:l})}),yD=S.observer(()=>{const{t}=_.useTranslation(),[e,n]=m.useState([]),r=Fe.useModals(),i=Z(),a=g=>{i.editor.setPath(["_SQL_SNIPPETS_",g])},l=()=>{r.openConfirmModal({title:"Delete ununsed SQL snippets?",children:s.jsx(o.Text,{size:"sm",children:"This action cannot be undone."}),labels:{confirm:t("common.actions.confirm"),cancel:t("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>i.content.removeUnusedSQLSnippets(),confirmProps:{color:"red"},zIndex:320})},c=()=>{i.content.sqlSnippets.downloadSchema(e)},u=m.useMemo(()=>i.content.sqlSnippets.sortedList.map(g=>g.key),[i.content.sqlSnippets.sortedList]),d=()=>{n(u)},p=()=>{n([])},h=i.content.sqlSnippetsUsage;return s.jsxs(o.Stack,{sx:{height:"100%"},spacing:"sm",pb:"59px",children:[s.jsx(o.Box,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:s.jsx(o.Text,{px:"md",align:"left",sx:{userSelect:"none",cursor:"default"},children:t("sql_snippet.manage")})}),s.jsxs(o.Flex,{justify:"space-between",align:"center",px:12,children:[s.jsxs(o.Group,{position:"left",children:[s.jsxs(o.Button.Group,{children:[s.jsx(o.Button,{variant:"default",size:"xs",onClick:d,children:t("common.actions.select_all")}),s.jsx(o.Button,{variant:"default",size:"xs",onClick:p,children:t("common.actions.clear_selection")})]}),s.jsx(o.Button,{size:"xs",color:"blue",leftIcon:s.jsx(k.IconCode,{size:14}),disabled:e.length===0,onClick:c,children:t("common.actions.download_schema")})]}),s.jsx(o.Button,{variant:"subtle",size:"xs",color:"red",leftIcon:s.jsx(k.IconTrash,{size:14}),disabled:!i.content.hasUnusedSQLSnippets,onClick:l,children:t("sql_snippet.delete_unused")})]}),s.jsx(o.Box,{sx:{flexGrow:1,overflow:"auto"},children:s.jsx(o.Checkbox.Group,{size:"xs",value:e,onChange:n,children:s.jsxs(o.Table,{fontSize:"sm",highlightOnHover:!0,sx:{tableLayout:"fixed"},children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{style:{width:"40px"}}),s.jsx("th",{children:t("common.key")}),s.jsx("th",{style:{width:"100px",textAlign:"center"},children:t("sql_snippet.usage.label")}),s.jsx("th",{style:{width:"300px",paddingLeft:"24px"},children:t("common.action")})]})}),s.jsx("tbody",{children:i.content.sqlSnippets.sortedList.map(g=>{var v;const y=((v=h[g.key])==null?void 0:v.length)??0;return s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx(o.Checkbox,{value:g.key,styles:{input:{cursor:"pointer"}}})}),s.jsx("td",{children:g.key}),s.jsx("td",{style:{color:y===0?"#ff0000":"#000",fontWeight:y===0?"bold":"normal",textAlign:"center"},children:y}),s.jsx("td",{children:s.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>a(g.key),children:t("common.actions.open")})})]},g.key)})})]})})})]})}),bD=S.observer(({view:t})=>!t||t.type!==B.Division?null:s.jsx(o.Stack,{})),vD=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 a=t.config;return s.jsxs(o.Stack,{children:[s.jsx(o.Divider,{mt:8,mb:0,label:e("view.component.tabs.tabs_settings"),labelPosition:"center"}),s.jsx(o.Select,{label:e("common.tabs.variant.label"),value:a.variant,onChange:a.setVariant,data:r}),s.jsx(o.Select,{label:e("common.tabs.orientation.label"),value:a.orientation,onChange:a.setOrientation,data:i}),s.jsx(o.Switch,{label:e("common.tabs.grow_tabs"),checked:a.grow,onChange:l=>a.setGrow(l.currentTarget.checked)})]})}),_D=({disabled:t,value:e,onChange:n})=>{const r=i=>{i&&n(i)};return s.jsxs(o.Box,{sx:{position:"relative"},children:[t&&s.jsx(o.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),s.jsx(Le,{height:"500px",defaultLanguage:"javascript",value:e,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:t}})]})},jD=({value:t,onChange:e})=>{const{t:n}=_.useTranslation(),[r,{setTrue:i,setFalse:a}]=G.useBoolean(),[l,c]=m.useState(t??cs),u=y=>{c({...l,enabled:y})},d=()=>{a();const{enabled:y,func_content:v}=l,w={enabled:y,func_content:v};c(w),e(w)},p=()=>{a(),c(t)},h=y=>{c(v=>({...v,func_content:y}))},g=()=>{h(cs.func_content)};return s.jsxs(s.Fragment,{children:[s.jsx(o.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:i,sx:{flexGrow:0},children:s.jsx(L.Settings,{size:14})}),s.jsx(o.Modal,{size:800,title:n("view.component.modal.custom_title"),opened:r,onClose:a,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&s.jsxs(o.Stack,{children:[s.jsx(o.Checkbox,{mt:10,label:n("common.enabled"),checked:l.enabled,onChange:y=>u(y.currentTarget.checked)}),s.jsx(_D,{value:l.func_content,onChange:h,disabled:!l.enabled}),s.jsxs(o.Group,{position:"apart",children:[s.jsx(o.Button,{onClick:g,color:"red",leftIcon:s.jsx(L.Recycle,{size:20}),children:n("common.actions.revert")}),s.jsxs(o.Group,{position:"right",children:[s.jsx(o.Button,{onClick:p,variant:"subtle",children:n("common.actions.cancel")}),s.jsx(o.Button,{onClick:d,children:n("common.actions.save")})]})]})]})})]})},wD=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(o.Stack,{children:[s.jsx(o.Divider,{mt:8,label:e("view.component.modal.modal_settings"),labelPosition:"center"}),s.jsxs(o.Flex,{gap:10,children:[s.jsx(o.TextInput,{label:e("view.component.modal.title"),value:r,onChange:b.noop,disabled:!0,sx:{flexGrow:1}}),s.jsx(jD,{value:n.custom_modal_title,onChange:n.custom_modal_title.replace})]}),s.jsxs(o.Group,{grow:!0,children:[s.jsx(o.TextInput,{label:e("view.component.modal.width"),value:n.width,onChange:i=>n.setWidth(i.currentTarget.value),placeholder:"600px / 50vw"}),s.jsx(o.TextInput,{label:e("view.component.modal.height"),value:n.height,onChange:i=>n.setHeight(i.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),CD=S.observer(({view:t})=>s.jsxs(s.Fragment,{children:[s.jsx(bD,{view:t}),s.jsx(wD,{view:t}),s.jsx(vD,{view:t})]})),SD=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(o.Stack,{sx:{position:"relative"},children:[s.jsx(o.TextInput,{label:e("common.name"),value:t.name,onChange:i=>{t.setName(i.currentTarget.value)}}),s.jsx(o.Select,{label:e("common.type"),withinPortal:!0,zIndex:320,value:t.type,onChange:t.setType,data:r}),s.jsx(CD,{view:t})]}):null}),kD=S.observer(({id:t})=>{const{t:e}=_.useTranslation(),n=Fe.useModals(),r=Z(),i=Y();if(t==="")return null;const a=i.views.findByID(t);if(!a)return s.jsxs(o.Text,{size:14,children:["View by ID[",t,"] is not found"]});const l=()=>{r.editor.setPath(["_VIEWS_",""])},c=()=>{n.openConfirmModal({title:`${e("view.delete")}?`,labels:{confirm:e("common.actions.confirm"),cancel:e("common.actions.cancel")},onCancel:()=>console.log("Cancel"),onConfirm:()=>{i.views.removeByID(t),l()},zIndex:320})};return s.jsxs(o.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[s.jsx(o.Group,{position:"right",pt:10,children:s.jsx(o.Button,{size:"xs",color:"red",leftIcon:s.jsx(L.Trash,{size:16}),onClick:c,children:e("view.delete")})}),s.jsx(o.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:s.jsx(SD,{view:a})})]})});function TD(t){return t.length===1&&t[0]==="_QUERY_VARS_"}function DD(t){return t.length===1&&t[0]==="_MOCK_CONTEXT_"}function zD(t){return t.length===1&&t[0]==="_FILTERS_"}function MD(t){return t.length===2&&t[0]==="_FILTERS_"}function ID(t){return t.length===1&&t[0]==="_SQL_SNIPPETS_"}function ED(t){return t.length===2&&t[0]==="_SQL_SNIPPETS_"}function AD(t){return t.length===2&&t[0]==="_QUERIES_"}function PD(t){return t.length===1&&t[0]==="_QUERIES_"}function $D(t){return t.length===2&&t[0]==="_VIEWS_"}function BD(t){return t.length===4&&t[0]==="_VIEWS_"&&t[2]==="_PANELS_"}const LD=S.observer(()=>s.jsx(o.Stack,{sx:{height:"100%"},p:"sm",children:s.jsx(su,{})})),qD=S.observer(()=>{const t=Z().editor,e=t.path;return TD(e)?s.jsx(LD,{}):DD(e)?s.jsx(KT,{}):zD(e)?s.jsx(YT,{}):MD(e)?s.jsx(o.Box,{p:"xs",pl:20,children:s.jsx(UT,{id:e[1]})}):ID(e)?s.jsx(yD,{}):ED(e)?s.jsx(fD,{id:e[1]}):PD(e)?s.jsx(E1,{}):AD(e)?s.jsx(mD,{id:e[1]}):$D(e)?s.jsx(o.Box,{p:"xs",pl:20,children:s.jsx(kD,{id:e[1]})}):BD(e)?s.jsx(I1,{viewID:e[1],panelID:e[3]}):s.jsx(o.Box,{children:t.path})}),OD=S.observer(()=>s.jsx(qD,{})),VD=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:ei(),visibleInViewsIDs:["Main"],auto_submit:!1};e.content.filters.append(i),e.editor.setPath(["_FILTERS_",r])};return s.jsx(o.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("filter.add")})}),ND=S.observer(({parentID:t})=>{const{t:e}=_.useTranslation(),n=Y();if(!t)return null;const r=n.views.findByID(t);return!r||r.type===B.Tabs?null:s.jsx(o.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:()=>n.addANewPanel(r.id),sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:e("panel.add")})}),GD=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(o.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("query.add")})}),FD=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(o.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("sql_snippet.add")})}),WD=S.observer(()=>{const{t}=_.useTranslation(),e=Y();return s.jsx(o.Button,{variant:"subtle",leftIcon:s.jsx(k.IconPlus,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:e.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:t("view.add")})}),QD=S.observer(()=>{const{t}=_.useTranslation(),e=Z();return s.jsx(o.Button,{variant:"subtle",rightIcon:s.jsx(k.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>e.editor.setPath(["_QUERIES_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:t("query.manage")})}),RD=S.observer(()=>{const{t}=_.useTranslation(),e=Z();return s.jsx(o.Button,{variant:"subtle",rightIcon:s.jsx(k.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>e.editor.setPath(["_SQL_SNIPPETS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:t("sql_snippet.manage")})}),UD=S.observer(()=>{const{t}=_.useTranslation(),e=Z();return s.jsx(o.Button,{variant:"subtle",rightIcon:s.jsx(k.IconSettings,{size:14}),size:"sm",px:12,mb:0,color:"blue",onClick:()=>e.editor.setPath(["_FILTERS_"]),sx:{width:"100%",borderRadius:0,fontWeight:"normal"},styles:{inner:{justifyContent:"space-between"}},children:t("filter.manage")})}),YD=S.observer(({action_type:t,parentID:e})=>t==="_Add_A_Filter_"?s.jsx(VD,{}):t==="_Add_A_SQL_SNIPPET_"?s.jsx(FD,{}):t==="_Add_A_QUERY_"?s.jsx(GD,{}):t==="_Add_A_VIEW_"?s.jsx(WD,{}):t==="_Add_A_PANEL_"?s.jsx(ND,{parentID:e}):t==="_QUERIES_SETTINGS_"?s.jsx(QD,{}):t==="_SQL_SNIPPETS_SETTINGS_"?s.jsx(RD,{}):t==="_FILTERS_SETTINGS_"?s.jsx(UD,{}):null),au=S.observer(({option:t})=>{var p;const{t:e}=_.useTranslation(),n=Z().editor,r=n.isOptionActive,i=r(n.path,t),a=n.isOptionOpened,l=n.navigate,c=a(t),[u,d]=m.useState(c);return m.useEffect(()=>{d(c)},[c]),s.jsx(o.NavLink,{active:i,defaultOpened:c,opened:u,onChange:d,label:e(t.label),onClick:()=>l(t),icon:t.Icon?s.jsx(t.Icon,{size:18}):null,children:(p=t.children)==null?void 0:p.map(h=>h._type==="ACTION"?s.jsx(YD,{action_type:h._action_type,parentID:h.parentID},`_ADD_${h.value}_`):s.jsx(au,{option:h},h.value))},t.label)}),KD=S.observer(()=>{const t=Z();return s.jsx(o.Box,{sx:{position:"relative"},children:t.editor.navOptions.map(e=>s.jsx(au,{option:e},e.value))})}),JD=S.observer(()=>{const{t}=_.useTranslation(),e=Z();return s.jsxs(o.Navbar,{p:0,width:{base:220,xs:220,sm:240,md:260,lg:300,xl:320},sx:{height:"100vh - 60px - 60px",".mantine-NavLink-body":{wordWrap:"break-word"}},children:[s.jsx(o.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:s.jsx(o.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:t("common.titles.settings")})}),s.jsx(o.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:s.jsx(KD,{})}),s.jsx(o.Navbar.Section,{children:s.jsx(o.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:s.jsx(o.Button,{size:"xs",color:"red",leftIcon:s.jsx(k.IconX,{size:18}),onClick:()=>e.editor.close(),children:t("common.actions.close")})})})]})}),XD={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"}},ZD=S.observer(()=>{const t=Z().editor;return s.jsx(o.Modal,{onClose:()=>t.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:t.settings_open,fullScreen:!0,title:null,transitionProps:{duration:0},withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{body:{padding:"0 !important"},content:{overflowY:"hidden !important"}},children:s.jsx(o.AppShell,{padding:0,navbar:s.jsx(JD,{}),styles:XD,children:s.jsx(OD,{})})})}),HD=t=>t.replace(/([^:])(\/\/+)/g,"$1/");function ez(t){m.useEffect(()=>{if(Le.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const n=HD(t);Le.loader.config({paths:{vs:n}}),Le.loader.init().then(r=>console.log("monaco instance:",r))},[])}va(),ja();const tz={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},nz=({context:t,dashboard:e,content:n,update:r,className:i="dashboard",config:a,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h},g)=>{ez(a.monacoPath),Ds(a);const{data:y=[]}=G.useRequest(Es),{data:v=[]}=G.useRequest(wa),w=m.useMemo(()=>Oc(e,n,y,v,t,u??{}),[e,n]);m.useImperativeHandle(g,()=>w,[w]),Nc(w.content,!0),m.useEffect(()=>{w.context.replace(t)},[t]),m.useEffect(()=>{w.datasources.replace(y)},[y]),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),A=>{l==null||l(A)}),[w]);const T=async()=>{await r(w.json,w.content.json)},D=G.useCreation(Gr,[]),I=Gc(D);return G.useWhyDidYouUpdate("@devtable/dashboard editor",{context:t,dashboard:e,content:n,update:r,className:i,config:a,onChange:l,headerSlot:c,filterValues:u,onFilterValuesChange:d,onExit:p,lang:h}),s.jsx(Vc,{lang:h,children:s.jsx(Fe.ModalsProvider,{children:s.jsx(Ns,{children:s.jsx(Ls,{value:{searchButtonProps:a.searchButtonProps},children:s.jsx($s,{value:w,children:s.jsx(qs,{value:w.content,children:s.jsx(An.Provider,{value:{inEditMode:!0},children:s.jsx(ut.Provider,{value:D,children:s.jsxs(os,{configure:I,children:[s.jsx(o.AppShell,{padding:0,header:s.jsx(rT,{onExit:p,saveDashboardChanges:T,headerSlot:c}),navbar:s.jsx(IT,{}),styles:tz,children:s.jsx(o.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:w.content.views.visibleViews.map(A=>s.jsx(Tc,{view:A},A.id))})}),s.jsx(ZD,{})]})})})})})})})})})},sz=S.observer(m.forwardRef(nz)),RM="",Pi=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:hi,queries:gi,sqlSnippets:yi,views:ui,panels:pi,layouts:fi,mock_context:Rr}).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:vn(t.sqlSnippets.current,"key","value",r),global_sql_snippets:vn(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 ou({id:t,name:e,dashboard_id:n,create_time:r,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:g,layouts:y,definition:{queries:v,sqlSnippets:w,mock_context:T={}}}=a;return Pi.create({id:t,name:e,dashboard_id:n,create_time:r,update_time:i,version:d,filters:mi(p,l,T,c),queries:lc(v),sqlSnippets:dc(w),mock_context:Ur(T),views:ec(h,u),panels:{list:g},layouts:{list:y,currentBreakpoint:y[0].id}})}const lu=x.types.model({id:x.types.identifier,name:x.types.string,group:x.types.string,content:Pi,content_id:x.types.string,datasources:Zl,globalSQLSnippets:oi,context:us});function cu({id:t,name:e,group:n,content_id:r},i,a,l,c,u,d){return lu.create({id:t,name:e,group:n,content_id:r,content:ou(i,c,u,d),datasources:{list:a},globalSQLSnippets:{list:l},context:li(c)})}va(),ja();const rz=({context:t,dashboard:e,content:n,className:r="dashboard",config:i,fullScreenPanelID:a,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h})=>{Ds(i);const{data:g=[]}=G.useRequest(Es),{data:y=[]}=G.useRequest(wa),v=m.useMemo(()=>cu(e,n,g,y,t,c??{},d??null),[e,n,d]);Nc(v.content,!1),m.useEffect(()=>{v.context.replace(t)},[t]),m.useEffect(()=>{v.datasources.replace(g)},[g]),m.useEffect(()=>{v.globalSQLSnippets.replace(y)},[y]),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=G.useCreation(Gr,[]),T=Gc(w);return G.useWhyDidYouUpdate("@devtable/dashboard render",{context:t,dashboard:e,content:n,className:r,config:i,fullScreenPanelID:a,setFullScreenPanelID:l,filterValues:c,onFilterValuesChange:u,activeTab:d,onActiveTabChange:p,lang:h}),s.jsx(Vc,{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:a,setFullScreenPanelID:l},children:s.jsx(An.Provider,{value:{inEditMode:!1},children:s.jsx(o.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))})})})})})})})})})})})},iz=S.observer(rz);M.extend(Ou),M.extend(Vu),M.extend(Nu),M.extend(Gu),M.extend(Fu),M.extend(Wu),M.extend(Qu),M.extend(Ru),M.extend(Uu),M.extend(Yu),M.extend(Xu),M.extend(Zu),M.extend(Hu),M.extend(ed),M.extend(td),M.extend(Ku),M.extend(Ju),M.extend(nd),M.extend(sd),M.extend(rd),M.extend(id),M.extend(ad),M.extend(od),M.extend(ld),M.extend(cd),M.extend(ud),M.extend(dd),M.extend(pd),M.extend(hd),M.extend(md),M.extend(gd),M.extend(fd),M.extend(xd),M.tz.setDefault("UTC"),M.updateLocale("en",{weekStart:1});const az=()=>Promise.resolve().then(()=>mp).then(({version:t})=>(console.log(`[@devtable/dashboard] version: ${t}`),t));j.APIClient=ot,j.CURRENT_SCHEMA_VERSION=ft,j.ContentModel=Ci,j.ContentModelContextProvider=qs,j.ContentRenderModel=Pi,j.ContextMeta=us,j.DEFAULT_CUSTOM_MODAL_TITLE=cs,j.DashboardApiClient=xa,j.DashboardApiFacadeClient=ga,j.DashboardEditor=sz,j.DashboardFilterType=re,j.DashboardMode=Dc,j.DashboardModel=qc,j.DashboardModelContextProvider=$s,j.DashboardRenderModel=lu,j.DashboardThemeContextProvider=Ls,j.DashboardViewEditor=Tc,j.DashboardViewRender=ps,j.DataSourceMetaModel=ai,j.DataSourceType=de,j.DataSourcesMetaModel=Zl,j.DatesProvider=Ns,j.DefaultApiClient=ma,j.DescriptionPopover=bi,j.DraftModel=pc,j.EViewComponentType=B,j.FacadeApiClient=Id,j.FilterCheckboxConfigMeta=Yr,j.FilterDateRangeConfigMeta=Kr,j.FilterMeta=ni,j.FilterMultiSelectConfigMeta=Xr,j.FilterSelectConfigMeta=Zr,j.FilterTextInputConfigMeta=Hr,j.FilterTreeSelectConfigMeta=ti,j.FiltersModel=Mc,j.FiltersRenderModel=hi,j.FullScreenPanel=jc,j.FullScreenPanelContext=Vs,j.GlobalSQLSnippetMeta=Hl,j.GlobalSQLSnippetsMeta=oi,j.LayoutItemMeta=Ol,j.LayoutSetMeta=Vl,j.LayoutStateContext=An,j.LayoutsRenderModel=fi,j.MockContextMeta=Rr,j.MuteQueryModel=oc,j.Panel=_c,j.PanelContextProvider=Os,j.PanelErrorOrStateMessage=bc,j.PanelMeta=Ll,j.PanelModel=Pc,j.PanelRender=_i,j.PanelRenderModel=di,j.PanelStyleMeta=Al,j.PanelTitleMeta=Pl,j.PanelVizMeta=Bl,j.PanelVizSection=vi,j.PanelsModel=$c,j.PanelsRenderModel=pi,j.QueriesModel=Ec,j.QueriesRenderModel=gi,j.QueryMeta=ql,j.QueryModel=Ic,j.QueryRenderModel=xi,j.ReadOnlyDashboard=iz,j.SQLSnippetMeta=Nl,j.SQLSnippetRenderModel=uc,j.SQLSnippetsModel=Ac,j.SQLSnippetsRenderModel=yi,j.VariableMeta=$l,j.ViewComponentTypeBackground=zc,j.ViewComponentTypeColor=Ck,j.ViewComponentTypeName=wk,j.ViewDivisionConfig=si,j.ViewMeta=Xl,j.ViewModalConfig=ri,j.ViewRenderModel=ci,j.ViewTabsConfig=ii,j.ViewsModel=Bc,j.ViewsRenderModel=ui,j.Viz=yc,j.applyPartialDashboard=Lk,j.configureAPIClient=Ds,j.createContentModel=Lc,j.createContentRenderModel=ou,j.createContextMeta=li,j.createDashboardModel=Oc,j.createDashboardRenderModel=cu,j.createDraft=hc,j.createFilterCheckboxConfig=Gl,j.createFilterDateRangeConfig=Wl,j.createFilterMultiSelectConfig=Ql,j.createFilterSelectConfig=Rl,j.createFilterTextInputConfig=ei,j.createFilterTreeSelectConfig=Ul,j.createViewDivisionConfig=Yl,j.createViewModalConfig=Kl,j.createViewTabsConfig=Jl,j.facadeApiClient=fa,j.formatSQLSnippet=vn,j.getInitialDashboardViewsModel=wi,j.getInitialFiltersConfig=mi,j.getInitialMockContextMeta=Ur,j.getInitialQueriesRenderModel=lc,j.getInitialSQLSnippetsRenderModel=dc,j.getInitialViewsRenderModel=ec,j.getNewPanel=sc,j.getVersion=az,j.initialDashboardContent=VS,j.useDashboardContext=Bs,j.useDashboardThemeContext=Ia,j.useEditContentModelContext=Y,j.useEditDashboardContext=Z,j.useEditPanelContext=ze,j.useFullScreenPanelContext=Ba,j.usePanelFullScreen=wc,j.useRenderContentModelContext=he,j.useRenderDashboardContext=za,j.useRenderPanelContext=mt,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"})});
|
|
481
|
+
`)},GP=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(Ml,{}),e.datasource&&r.jsx(Uf,{dataSource:e.datasource})]}),r.jsx(o.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:r.jsx(NP,{queryModel:e})}),r.jsx(o.Tabs.Panel,{value:"Preview",p:0,pl:4,children:r.jsx(FP,{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:Jf.pre})}),r.jsx(o.Tabs.Panel,{value:"post_process",p:"sm",children:r.jsx(er,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:Jf.post})})]}):null}),WP={pre:["function transform(queries, state, utils) {"," // use queries & dashboar state to build new data"," const data = []"," return data","}"].join(`
|
|
482
|
+
`),post:""},RP=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:WP.pre})})]}):null}),Ur={height:"calc(100% - 44px)",padding:0},QP=D.observer(({queryModel:e})=>{const{t}=_.useTranslation(),n=Y(),s=g.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),[i,a]=g.useState(s);g.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(EP,{queryModel:e})}),e.typedAsSQL&&r.jsx(o.Tabs.Panel,{value:"SQL",sx:Ur,children:r.jsx(o.Stack,{sx:{height:"100%"},children:r.jsx(GP,{queryModel:e})})}),e.typedAsHTTP&&r.jsx(o.Tabs.Panel,{value:"HTTP",sx:Ur,children:r.jsx(o.Stack,{sx:{height:"100%"},children:r.jsx(LP,{queryModel:e})})}),e.isTransform&&r.jsx(o.Tabs.Panel,{value:"Transform",sx:Ur,children:r.jsx(o.Stack,{sx:{height:"100%"},children:r.jsx(RP,{queryModel:e})})}),r.jsx(o.Tabs.Panel,{value:"Data",sx:{...Ur,overflow:"hidden"},children:r.jsx(kl,{id:e.id,moreActions:null,refreshOnMount:!0})}),r.jsx(o.Tabs.Panel,{value:"Usage",sx:{...Ur,overflow:"hidden"},children:r.jsx(BP,{queryID:e.id,usage:l})})]})}),UP=D.observer(({id:e})=>{const n=Y().queries.findByID(e);return e===""?null:n?r.jsx(QP,{queryModel:n}):r.jsx(o.Text,{size:14,color:"red",children:"Invalid Query ID"})}),YP=D.observer(({value:e})=>{const n=_e().payloadForSQL,s=g.useMemo(()=>wi(e,n),[e,n]);return r.jsx(zl,{height:"100%",value:s})}),KP=D.observer(({item:e,remove:t,onKeyChanged:n})=>{const{t:s}=_.useTranslation(),[i,a]=g.useState("SQL"),[l,c]=g.useState(e.key),u=()=>{e.setKey(l),n(l)},d=l!==e.key,p=e.isADuplicatedKey(l),[h,f]=g.useState(e.value),x=()=>{e.setValue(h)};g.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(Ml,{}),r.jsx(o.ActionIcon,{color:"blue",variant:"filled",onClick:x,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(zl,{height:"100%",value:h,onChange:f,defaultLanguage:"sql",theme:"sql-dark"})}),r.jsx(o.Tabs.Panel,{value:"Preview",pt:"sm",children:r.jsx(YP,{value:h})})]})]})}),XP=D.observer(({id:e})=>{const t=Z(),n=Y(),s=g.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(KP,{item:s,remove:a,onKeyChanged:l})}),JP=D.observer(()=>{const{t:e}=_.useTranslation(),[t,n]=g.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=g.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 x=((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:x===0?"#ff0000":"#000",fontWeight:x===0?"bold":"normal",textAlign:"center"},children:x}),r.jsx("td",{children:r.jsx(o.Button,{variant:"subtle",size:"xs",onClick:()=>a(f.key),children:e("common.actions.open")})})]},f.key)})})]})})})]})}),ZP=D.observer(({view:e})=>!e||e.type!==q.Division?null:r.jsx(o.Stack,{})),HP=D.observer(({view:e})=>{const{t,i18n:n}=_.useTranslation(),s=g.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=g.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)})]})}),e2=({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}})]})},t2=({value:e,onChange:t})=>{const{t:n}=_.useTranslation(),[s,{setTrue:i,setFalse:a}]=W.useBoolean(),[l,c]=g.useState(e??ii),u=x=>{c({...l,enabled:x})},d=()=>{a();const{enabled:x,func_content:y}=l,j={enabled:x,func_content:y};c(j),t(j)},p=()=>{a(),c(e)},h=x=>{c(y=>({...y,func_content:x}))},f=()=>{h(ii.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:x=>u(x.currentTarget.checked)}),r.jsx(e2,{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")})]})]})]})})]})},n2=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(t2,{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"})]})]})}),r2=D.observer(({view:e})=>r.jsxs(r.Fragment,{children:[r.jsx(ZP,{view:e}),r.jsx(n2,{view:e}),r.jsx(HP,{view:e})]})),s2=D.observer(({view:e})=>{const{t,i18n:n}=_.useTranslation(),s=g.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(r2,{view:e})]}):null}),i2=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(s2,{view:a})})]})});function a2(e){return e.length===1&&e[0]==="_QUERY_VARS_"}function o2(e){return e.length===1&&e[0]==="_MOCK_CONTEXT_"}function l2(e){return e.length===1&&e[0]==="_FILTERS_"}function c2(e){return e.length===2&&e[0]==="_FILTERS_"}function u2(e){return e.length===1&&e[0]==="_SQL_SNIPPETS_"}function d2(e){return e.length===2&&e[0]==="_SQL_SNIPPETS_"}function p2(e){return e.length===2&&e[0]==="_QUERIES_"}function h2(e){return e.length===1&&e[0]==="_QUERIES_"}function f2(e){return e.length===2&&e[0]==="_VIEWS_"}function g2(e){return e.length===4&&e[0]==="_VIEWS_"&&e[2]==="_PANELS_"}const m2=D.observer(()=>r.jsx(o.Stack,{sx:{height:"100%"},p:"sm",children:r.jsx(Kf,{})})),x2=D.observer(()=>{const e=Z().editor,t=e.path;return a2(t)?r.jsx(m2,{}):o2(t)?r.jsx(DA,{}):l2(t)?r.jsx(TA,{}):c2(t)?r.jsx(o.Box,{p:"xs",pl:20,children:r.jsx(kA,{id:t[1]})}):u2(t)?r.jsx(JP,{}):d2(t)?r.jsx(XP,{id:t[1]}):h2(t)?r.jsx(dP,{}):p2(t)?r.jsx(UP,{id:t[1]}):f2(t)?r.jsx(o.Box,{p:"xs",pl:20,children:r.jsx(i2,{id:t[1]})}):g2(t)?r.jsx(uP,{viewID:t[1],panelID:t[3]}):r.jsx(o.Box,{children:e.path})}),y2=D.observer(()=>r.jsx(x2,{})),b2=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:Jo(),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")})}),v2=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")})}),_2=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")})}),j2=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")})}),w2=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")})}),C2=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")})}),S2=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")})}),k2=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")})}),T2=D.observer(({action_type:e,parentID:t})=>e==="_Add_A_Filter_"?r.jsx(b2,{}):e==="_Add_A_SQL_SNIPPET_"?r.jsx(j2,{}):e==="_Add_A_QUERY_"?r.jsx(_2,{}):e==="_Add_A_VIEW_"?r.jsx(w2,{}):e==="_Add_A_PANEL_"?r.jsx(v2,{parentID:t}):e==="_QUERIES_SETTINGS_"?r.jsx(C2,{}):e==="_SQL_SNIPPETS_SETTINGS_"?r.jsx(S2,{}):e==="_FILTERS_SETTINGS_"?r.jsx(k2,{}):null),Zf=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]=g.useState(c);return g.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(T2,{action_type:h._action_type,parentID:h.parentID},`_ADD_${h.value}_`):r.jsx(Zf,{option:h},h.value))},e.label)}),D2=D.observer(()=>{const e=Z();return r.jsx(o.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>r.jsx(Zf,{option:t},t.value))})}),M2=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(D2,{})}),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")})})})]})}),z2={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"}},I2=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(M2,{}),styles:z2,children:r.jsx(y2,{})})})}),E2=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function A2(e){g.useEffect(()=>{if(tt.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const n=E2(e);tt.loader.config({paths:{vs:n}}),tt.loader.init().then(s=>console.log("monaco instance:",s))},[])}mc(),yc();const P2={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60+30,height:"100vh"}},O2=({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)=>{A2(a.monacoPath),Ci(a);const{data:x=[]}=W.useRequest(Di),{data:y=[]}=W.useRequest(bc),j=g.useMemo(()=>If(t,n,x,y,e,u??{}),[t,n]);g.useImperativeHandle(f,()=>j,[j]),Af(j.content,!0),g.useEffect(()=>{j.context.replace(e)},[e]),g.useEffect(()=>{j.datasources.replace(x)},[x]),g.useEffect(()=>{j.globalSQLSnippets.replace(y)},[y]),g.useEffect(()=>{d==null||d(j.content.filters.values)},[d,j.content.filters.values]),g.useEffect(()=>{u&&j.content.filters.patchValues(u)},[u,j.content.filters.patchValues]),g.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(Vo,[]),T=Pf(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(Ef,{lang:h,children:r.jsx(lt.ModalsProvider,{children:r.jsx(Bi,{children:r.jsx(Ai,{value:{searchButtonProps:a.searchButtonProps},children:r.jsx(Ii,{value:j,children:r.jsx(Pi,{value:j.content,children:r.jsx(os.Provider,{value:{inEditMode:!0},children:r.jsx(Nt.Provider,{value:S,children:r.jsxs(ri,{configure:T,children:[r.jsx(o.AppShell,{padding:0,header:r.jsx(BE,{onExit:p,saveDashboardChanges:k,headerSlot:c}),navbar:r.jsx(uA,{}),styles:P2,children:r.jsx(o.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:j.content.views.visibleViews.map(z=>r.jsx(bf,{view:z},z.id))})}),r.jsx(I2,{})]})})})})})})})})})},L2=D.observer(g.forwardRef(O2)),vL="",Il=m.types.model({id:m.types.string,name:m.types.string,dashboard_id:m.types.string,create_time:m.types.string,update_time:m.types.string,version:m.types.string,filters:ul,queries:hl,sqlSnippets:gl,views:ol,panels:cl,layouts:fl,mock_context:Go}).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=m.getParent(e).context.current,n=m.getParent(e).globalSQLSnippets,s={context:{...e.mock_context.current,...t},filters:e.filters.values};return{...s,sql_snippets:Rr(e.sqlSnippets.current,"key","value",s),global_sql_snippets:Rr(n.list,"id","content",s)}},get payloadForViz(){const t=m.getParent(e).context.current;return{context:{...e.mock_context.current,...t},filters:e.filters.values}},get dashboardState(){return Ti(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 Hf({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:x,definition:{queries:y,sqlSnippets:j,mock_context:k={}}}=a;return Il.create({id:e,name:t,dashboard_id:n,create_time:s,update_time:i,version:d,filters:dl(p,l,k,c),queries:Hh(y),sqlSnippets:nf(j),mock_context:Wo(k),views:Rh(h,u),panels:{list:f},layouts:{list:x,currentBreakpoint:x[0].id}})}const eg=m.types.model({id:m.types.identifier,name:m.types.string,group:m.types.string,content:Il,content_id:m.types.string,datasources:Gh,globalSQLSnippets:sl,context:ai});function tg({id:e,name:t,group:n,content_id:s},i,a,l,c,u,d){return eg.create({id:e,name:t,group:n,content_id:s,content:Hf(i,c,u,d),datasources:{list:a},globalSQLSnippets:{list:l},context:il(c)})}mc(),yc();const B2=({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})=>{Ci(i);const{data:f=[]}=W.useRequest(Di),{data:x=[]}=W.useRequest(bc),y=g.useMemo(()=>tg(t,n,f,x,e,c??{},d??null),[t,n,d]);Af(y.content,!1),g.useEffect(()=>{y.context.replace(e)},[e]),g.useEffect(()=>{y.datasources.replace(f)},[f]),g.useEffect(()=>{y.globalSQLSnippets.replace(x)},[x]),g.useEffect(()=>{u==null||u(y.content.filters.values)},[u,y.content.filters.valuesString]),g.useEffect(()=>{c&&y.content.filters.patchValues(c)},[c,y.content.filters.patchValues]),g.useEffect(()=>{p==null||p(y.content.views.firstVisibleTabsViewActiveTab)},[p,y.content.views.firstVisibleTabsViewActiveTab]),g.useEffect(()=>{d&&y.content.views.setFirstVisibleTabsViewActiveTab(d)},[d,y.content.views.setFirstVisibleTabsViewActiveTab]);const j=W.useCreation(Vo,[]),k=Pf(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(Ef,{lang:h,children:r.jsx(lt.ModalsProvider,{children:r.jsx(Bi,{children:r.jsx(Ai,{value:{searchButtonProps:i.searchButtonProps},children:r.jsx(Ii,{value:y,children:r.jsx(Pi,{value:y.content,children:r.jsx(Li.Provider,{value:{fullScreenPanelID:a,setFullScreenPanelID:l},children:r.jsx(os.Provider,{value:{inEditMode:!1},children:r.jsx(o.Box,{className:`${s} dashboard-root`,children:r.jsx(Nt.Provider,{value:j,children:r.jsx(ri,{configure:k,children:y.content.views.visibleViews.map(S=>r.jsx(li,{view:S},S.id))})})})})})})})})})})})},q2=D.observer(B2);P.extend(Cg),P.extend(Sg),P.extend(kg),P.extend(Tg),P.extend(Dg),P.extend(Mg),P.extend(zg),P.extend(Ig),P.extend(Eg),P.extend(Ag),P.extend(Lg),P.extend(Bg),P.extend(qg),P.extend(Vg),P.extend(Ng),P.extend(Pg),P.extend(Og),P.extend($g),P.extend(Fg),P.extend(Gg),P.extend(Wg),P.extend(Rg),P.extend(Qg),P.extend(Ug),P.extend(Yg),P.extend(Kg),P.extend(Xg),P.extend(Jg),P.extend(Zg),P.extend(Hg),P.extend(tm),P.extend(nm),P.extend(em),P.tz.setDefault("UTC"),P.updateLocale("en",{weekStart:1});const V2=()=>Promise.resolve().then(()=>Hm).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));w.APIClient=Pt,w.CURRENT_SCHEMA_VERSION=Zt,w.ContentModel=_l,w.ContentModelContextProvider=Pi,w.ContentRenderModel=Il,w.ContextMeta=ai,w.DEFAULT_CUSTOM_MODAL_TITLE=ii,w.DashboardApiClient=dc,w.DashboardApiFacadeClient=pc,w.DashboardEditor=L2,w.DashboardFilterType=ce,w.DashboardMode=vf,w.DashboardModel=zf,w.DashboardModelContextProvider=Ii,w.DashboardRenderModel=eg,w.DashboardThemeContextProvider=Ai,w.DashboardViewEditor=bf,w.DashboardViewRender=li,w.DataSourceMetaModel=rl,w.DataSourceType=ye,w.DataSourcesMetaModel=Gh,w.DatesProvider=Bi,w.DefaultApiClient=uc,w.DescriptionPopover=ml,w.DraftModel=rf,w.EViewComponentType=q,w.FacadeApiClient=mm,w.FilterCheckboxConfigMeta=Ro,w.FilterDateRangeConfigMeta=Qo,w.FilterMeta=Ho,w.FilterMultiSelectConfigMeta=Yo,w.FilterSelectConfigMeta=Ko,w.FilterTextInputConfigMeta=Xo,w.FilterTreeSelectConfigMeta=Zo,w.FiltersModel=jf,w.FiltersRenderModel=ul,w.FullScreenPanel=ff,w.FullScreenPanelContext=Li,w.GlobalSQLSnippetMeta=Wh,w.GlobalSQLSnippetsMeta=sl,w.LayoutItemMeta=zh,w.LayoutSetMeta=Ih,w.LayoutStateContext=os,w.LayoutsRenderModel=fl,w.MockContextMeta=Go,w.MuteQueryModel=Zh,w.Panel=hf,w.PanelContextProvider=Oi,w.PanelErrorOrStateMessage=df,w.PanelMeta=Dh,w.PanelModel=kf,w.PanelRender=yl,w.PanelRenderModel=ll,w.PanelStyleMeta=Ch,w.PanelTitleMeta=Sh,w.PanelVizMeta=Th,w.PanelVizSection=xl,w.PanelsModel=Tf,w.PanelsRenderModel=cl,w.QueriesModel=Cf,w.QueriesRenderModel=hl,w.QueryMeta=Mh,w.QueryModel=wf,w.QueryRenderModel=pl,w.ReadOnlyDashboard=q2,w.SQLSnippetMeta=Eh,w.SQLSnippetRenderModel=tf,w.SQLSnippetsModel=Sf,w.SQLSnippetsRenderModel=gl,w.VariableMeta=kh,w.ViewComponentTypeBackground=_f,w.ViewComponentTypeColor=rE,w.ViewComponentTypeName=nE,w.ViewDivisionConfig=el,w.ViewMeta=Fh,w.ViewModalConfig=tl,w.ViewRenderModel=al,w.ViewTabsConfig=nl,w.ViewsModel=Df,w.ViewsRenderModel=ol,w.Viz=uf,w.applyPartialDashboard=mE,w.configureAPIClient=Ci,w.createContentModel=Mf,w.createContentRenderModel=Hf,w.createContextMeta=il,w.createDashboardModel=If,w.createDashboardRenderModel=tg,w.createDraft=sf,w.createFilterCheckboxConfig=Ah,w.createFilterDateRangeConfig=Oh,w.createFilterMultiSelectConfig=Lh,w.createFilterSelectConfig=Bh,w.createFilterTextInputConfig=Jo,w.createFilterTreeSelectConfig=qh,w.createViewDivisionConfig=Vh,w.createViewModalConfig=Nh,w.createViewTabsConfig=$h,w.facadeApiClient=hc,w.formatSQLSnippet=Rr,w.getInitialDashboardViewsModel=vl,w.getInitialFiltersConfig=dl,w.getInitialMockContextMeta=Wo,w.getInitialQueriesRenderModel=Hh,w.getInitialSQLSnippetsRenderModel=nf,w.getInitialViewsRenderModel=Rh,w.getNewPanel=Yh,w.getVersion=V2,w.initialDashboardContent=bI,w.useDashboardContext=Ei,w.useDashboardThemeContext=Tc,w.useEditContentModelContext=Y,w.useEditDashboardContext=Z,w.useEditPanelContext=Ge,w.useFullScreenPanelContext=Ec,w.usePanelFullScreen=gf,w.useRenderContentModelContext=_e,w.useRenderDashboardContext=Sc,w.useRenderPanelContext=Qt,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|