@devtable/dashboard 8.13.5 → 8.13.7

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.
@@ -1,4 +1,4 @@
1
- (function(de,x){typeof exports=="object"&&typeof module<"u"?x(exports,require("react"),require("@mantine/core"),require("@mantine/modals"),require("ahooks"),require("mobx-react-lite"),require("lodash"),require("react-hook-form"),require("@mantine/dates"),require("dayjs"),require("tabler-icons-react"),require("react-dom"),require("react-grid-layout"),require("@mantine/tiptap"),require("@tiptap/core"),require("prosemirror-state"),require("prosemirror-view"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("mobx"),require("eventemitter2"),require("chroma-js"),require("echarts-gl"),require("echarts/core"),require("echarts/components"),require("echarts/renderers"),require("echarts-for-react/lib/core"),require("numbro"),require("echarts/charts"),require("@mantine/hooks"),require("@mantine/notifications"),require("d3-array"),require("@monaco-editor/react"),require("echarts-stat"),require("@mantine/prism"),require("d3-regression"),require("react-virtual"),require("axios"),require("crypto-js"),require("mobx-state-tree"),require("jszip")):typeof define=="function"&&define.amd?define(["exports","react","@mantine/core","@mantine/modals","ahooks","mobx-react-lite","lodash","react-hook-form","@mantine/dates","dayjs","tabler-icons-react","react-dom","react-grid-layout","@mantine/tiptap","@tiptap/core","prosemirror-state","prosemirror-view","@tiptap/react","@tiptap/starter-kit","mobx","eventemitter2","chroma-js","echarts-gl","echarts/core","echarts/components","echarts/renderers","echarts-for-react/lib/core","numbro","echarts/charts","@mantine/hooks","@mantine/notifications","d3-array","@monaco-editor/react","echarts-stat","@mantine/prism","d3-regression","react-virtual","axios","crypto-js","mobx-state-tree","jszip"],x):(de=typeof globalThis<"u"?globalThis:de||self,x(de.dashboard={},de.React,de["@mantine/core"],de["@mantine/modals"],de.ahooks,de["mobx-react-lite"],de._,de["react-hook-form"],de["@mantine/dates"],de.dayjs,de["tabler-icons-react"],de.ReactDOM,de["react-grid-layout"],de["@mantine/tiptap"],de["@tiptap/core"],de["prosemirror-state"],de["prosemirror-view"],de["@tiptap/react"],de["@tiptap/starter-kit"],de.mobx,de.eventemitter2,de["chroma-js"],de["echarts-gl"],de["echarts/core"],de["echarts/components"],de["echarts/renderers"],de["echarts-for-react/lib/core"],de.numbro,de["echarts/charts"],de["@mantine/hooks"],de["@mantine/notifications"],de["d3-array"],de["@monaco-editor/react"],de["echarts-stat"],de["@mantine/prism"],de["d3-regression"],de["react-virtual"],de.axios,de["crypto-js"],de["mobx-state-tree"],de.jszip))})(this,function(de,x,d,Kn,tt,te,H,j,d0,f0,le,p0,Os,nt,Jt,h0,sd,ld,g0,Ft,v0,qr,p6,m0,ut,Hn,y0,b0,pn,Ut,No,$o,Lo,Ds,Ur,w0,x0,S0,C0,D,_0){"use strict";var d6=Object.defineProperty;var f6=(de,x,d)=>x in de?d6(de,x,{enumerable:!0,configurable:!0,writable:!0,value:d}):de[x]=d;var Re=(de,x,d)=>(f6(de,typeof x!="symbol"?x+"":x,d),d);const ln=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function Rs(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Z=ln(x),T=Rs(x),fe=ln(H),En=ln(f0),Ni=ln(p0),ud=ln(Os),cd=ln(g0),dd=ln(v0),$i=ln(qr),Rt=Rs(m0),Wn=ln(y0),Bt=ln(b0),Tn=ln(Lo),ur=Rs(w0),Vo=ln(S0),fd=ln(C0),E0=ln(_0);function pd(e,t){x.useEffect(()=>{const n=r=>{console.log(r);const{viewID:i}=r.detail;if(!i){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(i),t&&e.views.setIDOfVIE(i)};return window.addEventListener("open-view",n),()=>{window.removeEventListener("open-view",n)}},[e,t]),x.useEffect(()=>{const n=r=>{console.log(r);const{dictionary:i,payload:o}=r.detail;if(!o||Object.keys(o).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}Object.entries(i).forEach(([a,s])=>{e.filters.setValueByKey(a,fe.default.get(o,s))})};return window.addEventListener("set-filter-values",n),()=>{window.removeEventListener("set-filter-values",n)}},[e]),x.useEffect(()=>{function n(i){return Array.isArray(i)?[]:typeof i=="object"?{}:typeof i=="boolean"?!1:typeof i=="string"?"":typeof i=="number"?0:i}const r=i=>{console.log(i);const{filter_keys:o}=i.detail;o.forEach(a=>{const s=fe.default.get(e.filters.values,a),u=n(s);console.log(`${a}: ${u}`),e.filters.setValueByKey(a,u)})};return window.addEventListener("clear-filter-values",r),()=>{window.removeEventListener("clear-filter-values",r)}},[e]),x.useEffect(()=>{const n=r=>{console.log(r);const{urlTemplate:i,openInNewTab:o,enableEncoding:a=!1,payload:s}=r.detail;if(!i){console.error(new Error("[Open Link] URL is empty"));return}function u(h){return H.cloneDeepWith(h,g=>{if(a&&typeof g=="string")return encodeURIComponent(g)})}const f=H.template(i||"")(u({...s,filters:e.filters.values,context:e.context.current}));window.open(f,o?"_blank":"_self","noopener")};return window.addEventListener("open-link",n),()=>{window.removeEventListener("open-link",n)}},[e])}class T0{constructor(t){Re(this,"symbol");this.symbol=Symbol(t)}}function qn(e){return new T0(e)}class As{constructor(){Re(this,"parent");Re(this,"factoryRegistry",new Map);Re(this,"instanceRegistry",new Map)}createScoped(){const t=new As;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const r=n(this);return this.instanceRegistry.set(t.symbol,r),r}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=H.get(t,"dispose");H.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}var hn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function M0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var zo={exports:{}},Li={};/**
1
+ (function(de,x){typeof exports=="object"&&typeof module<"u"?x(exports,require("react"),require("@mantine/core"),require("@mantine/modals"),require("ahooks"),require("mobx-react-lite"),require("lodash"),require("react-hook-form"),require("@mantine/dates"),require("dayjs"),require("tabler-icons-react"),require("react-dom"),require("react-grid-layout"),require("@mantine/tiptap"),require("@tiptap/core"),require("prosemirror-state"),require("prosemirror-view"),require("@tiptap/react"),require("@tiptap/starter-kit"),require("mobx"),require("eventemitter2"),require("chroma-js"),require("echarts-gl"),require("echarts/core"),require("echarts/components"),require("echarts/renderers"),require("echarts-for-react/lib/core"),require("numbro"),require("echarts/charts"),require("@mantine/hooks"),require("@mantine/notifications"),require("d3-array"),require("@monaco-editor/react"),require("echarts-stat"),require("@mantine/prism"),require("d3-regression"),require("react-virtual"),require("axios"),require("crypto-js"),require("mobx-state-tree"),require("jszip")):typeof define=="function"&&define.amd?define(["exports","react","@mantine/core","@mantine/modals","ahooks","mobx-react-lite","lodash","react-hook-form","@mantine/dates","dayjs","tabler-icons-react","react-dom","react-grid-layout","@mantine/tiptap","@tiptap/core","prosemirror-state","prosemirror-view","@tiptap/react","@tiptap/starter-kit","mobx","eventemitter2","chroma-js","echarts-gl","echarts/core","echarts/components","echarts/renderers","echarts-for-react/lib/core","numbro","echarts/charts","@mantine/hooks","@mantine/notifications","d3-array","@monaco-editor/react","echarts-stat","@mantine/prism","d3-regression","react-virtual","axios","crypto-js","mobx-state-tree","jszip"],x):(de=typeof globalThis<"u"?globalThis:de||self,x(de.dashboard={},de.React,de["@mantine/core"],de["@mantine/modals"],de.ahooks,de["mobx-react-lite"],de._,de["react-hook-form"],de["@mantine/dates"],de.dayjs,de["tabler-icons-react"],de.ReactDOM,de["react-grid-layout"],de["@mantine/tiptap"],de["@tiptap/core"],de["prosemirror-state"],de["prosemirror-view"],de["@tiptap/react"],de["@tiptap/starter-kit"],de.mobx,de.eventemitter2,de["chroma-js"],de["echarts-gl"],de["echarts/core"],de["echarts/components"],de["echarts/renderers"],de["echarts-for-react/lib/core"],de.numbro,de["echarts/charts"],de["@mantine/hooks"],de["@mantine/notifications"],de["d3-array"],de["@monaco-editor/react"],de["echarts-stat"],de["@mantine/prism"],de["d3-regression"],de["react-virtual"],de.axios,de["crypto-js"],de["mobx-state-tree"],de.jszip))})(this,function(de,x,d,Kn,tt,te,H,j,d0,f0,le,p0,Os,nt,Jt,h0,sd,ld,g0,Ft,v0,qr,h6,m0,ut,Hn,y0,b0,pn,Ut,No,$o,Lo,Ds,Ur,w0,x0,S0,C0,D,_0){"use strict";var f6=Object.defineProperty;var p6=(de,x,d)=>x in de?f6(de,x,{enumerable:!0,configurable:!0,writable:!0,value:d}):de[x]=d;var Re=(de,x,d)=>(p6(de,typeof x!="symbol"?x+"":x,d),d);const ln=e=>e&&typeof e=="object"&&"default"in e?e:{default:e};function Rs(e){if(e&&e.__esModule)return e;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,r.get?r:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const Z=ln(x),T=Rs(x),fe=ln(H),En=ln(f0),Ni=ln(p0),ud=ln(Os),cd=ln(g0),dd=ln(v0),$i=ln(qr),Rt=Rs(m0),Wn=ln(y0),Bt=ln(b0),Tn=ln(Lo),ur=Rs(w0),Vo=ln(S0),fd=ln(C0),E0=ln(_0);function pd(e,t){x.useEffect(()=>{const n=r=>{console.log(r);const{viewID:i}=r.detail;if(!i){console.error(new Error("[Open View] Needs to pick a view first"));return}e.views.appendToVisibles(i),t&&e.views.setIDOfVIE(i)};return window.addEventListener("open-view",n),()=>{window.removeEventListener("open-view",n)}},[e,t]),x.useEffect(()=>{const n=r=>{console.log(r);const{dictionary:i,payload:o}=r.detail;if(!o||Object.keys(o).length===0){console.error(new Error("[Set Filter Values] payload is empty"));return}Object.entries(i).forEach(([a,s])=>{e.filters.setValueByKey(a,fe.default.get(o,s))})};return window.addEventListener("set-filter-values",n),()=>{window.removeEventListener("set-filter-values",n)}},[e]),x.useEffect(()=>{function n(i){return Array.isArray(i)?[]:typeof i=="object"?{}:typeof i=="boolean"?!1:typeof i=="string"?"":typeof i=="number"?0:i}const r=i=>{console.log(i);const{filter_keys:o}=i.detail;o.forEach(a=>{const s=fe.default.get(e.filters.values,a),u=n(s);console.log(`${a}: ${u}`),e.filters.setValueByKey(a,u)})};return window.addEventListener("clear-filter-values",r),()=>{window.removeEventListener("clear-filter-values",r)}},[e]),x.useEffect(()=>{const n=r=>{console.log(r);const{urlTemplate:i,openInNewTab:o,enableEncoding:a=!1,payload:s}=r.detail;if(!i){console.error(new Error("[Open Link] URL is empty"));return}function u(h){return H.cloneDeepWith(h,g=>{if(a&&typeof g=="string")return encodeURIComponent(g)})}const f=H.template(i||"")(u({...s,filters:e.filters.values,context:e.context.current}));window.open(f,o?"_blank":"_self","noopener")};return window.addEventListener("open-link",n),()=>{window.removeEventListener("open-link",n)}},[e])}class T0{constructor(t){Re(this,"symbol");this.symbol=Symbol(t)}}function qn(e){return new T0(e)}class As{constructor(){Re(this,"parent");Re(this,"factoryRegistry",new Map);Re(this,"instanceRegistry",new Map)}createScoped(){const t=new As;return t.parent=this,t}getRequired(t){return this.get(t)}get(t){if(this.instanceRegistry.has(t.symbol))return this.instanceRegistry.get(t.symbol);const n=this.factoryRegistry.get(t.symbol);if(n){const r=n(this);return this.instanceRegistry.set(t.symbol,r),r}if(this.parent)return this.parent.get(t)}provideFactory(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,n),this}provideValue(t,n){return this.factoryRegistry.has(t.symbol)?console.warn(`Token ${t.symbol.toString()} is already registered`):this.factoryRegistry.set(t.symbol,()=>n),this}dispose(){this.instanceRegistry.forEach(t=>{const n=H.get(t,"dispose");H.isFunction(n)&&n.bind(t)()}),this.instanceRegistry.clear(),this.factoryRegistry.clear()}}var hn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function M0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var zo={exports:{}},Li={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.min.js
4
4
  *
@@ -69,10 +69,10 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
69
69
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function gr(e,t){return Px(e)||Ix(e,t)||Nx(e,t)||$x()}function _f(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit".concat(e)]="webkit".concat(t),n["Moz".concat(e)]="moz".concat(t),n["ms".concat(e)]="MS".concat(t),n["O".concat(e)]="o".concat(t.toLowerCase()),n}function Lx(e,t){var n={animationend:_f("Animation","AnimationEnd"),transitionend:_f("Transition","TransitionEnd")};return e&&("AnimationEvent"in t||delete n.animationend.animation,"TransitionEvent"in t||delete n.transitionend.transition),n}var Vx=Lx(Xr(),typeof window<"u"?window:{}),Ef={};if(Xr()){var zx=document.createElement("div");Ef=zx.style}var Qo={};function Tf(e){if(Qo[e])return Qo[e];var t=Vx[e];if(t)for(var n=Object.keys(t),r=n.length,i=0;i<r;i+=1){var o=n[i];if(Object.prototype.hasOwnProperty.call(t,o)&&o in Ef)return Qo[e]=t[o],Qo[e]}return""}var Mf=Tf("animationend"),kf=Tf("transitionend"),Fx=!!(Mf&&kf),Of=Mf||"animationend",Df=kf||"transitionend";function Rf(e,t){if(!e)return null;if(hr(e)==="object"){var n=t.replace(/-\w/g,function(r){return r[1].toUpperCase()});return e[n]}return"".concat(e,"-").concat(t)}var ni="none",Zo="appear",Jo="enter",ea="leave",Af="none",Zn="prepare",ri="start",ii="active",Zs="end";const Bx=function(){var e=T.useRef(null);function t(){Nt.cancel(e.current)}function n(r){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:2;t();var o=Nt(function(){i<=1?r({isCanceled:function(){return o!==e.current}}):n(r,i-1)});e.current=o}return T.useEffect(function(){return function(){t()}},[]),[n,t]};var Pf=Xr()?x.useLayoutEffect:x.useEffect,If=[Zn,ri,ii,Zs],Nf=!1,jx=!0;function $f(e){return e===ii||e===Zs}const Gx=function(e,t){var n=fr(Af),r=gr(n,2),i=r[0],o=r[1],a=Bx(),s=gr(a,2),u=s[0],c=s[1];function f(){o(Zn,!0)}return Pf(function(){if(i!==Af&&i!==Zs){var h=If.indexOf(i),p=If[h+1],g=t(i);g===Nf?o(p,!0):u(function(v){function m(){v.isCanceled()||o(p,!0)}g===!0?m():Promise.resolve(g).then(m)})}},[e,i]),T.useEffect(function(){return function(){c()}},[]),[f,i]},Kx=function(e){var t=x.useRef(),n=x.useRef(e);n.current=e;var r=T.useCallback(function(a){n.current(a)},[]);function i(a){a&&(a.removeEventListener(Df,r),a.removeEventListener(Of,r))}function o(a){t.current&&t.current!==a&&i(t.current),a&&a!==t.current&&(a.addEventListener(Df,r),a.addEventListener(Of,r),t.current=a)}return T.useEffect(function(){return function(){i(t.current)}},[]),[o,i]};function Hx(e,t,n,r){var i=r.motionEnter,o=i===void 0?!0:i,a=r.motionAppear,s=a===void 0?!0:a,u=r.motionLeave,c=u===void 0?!0:u,f=r.motionDeadline,h=r.motionLeaveImmediately,p=r.onAppearPrepare,g=r.onEnterPrepare,v=r.onLeavePrepare,m=r.onAppearStart,w=r.onEnterStart,b=r.onLeaveStart,_=r.onAppearActive,C=r.onEnterActive,S=r.onLeaveActive,E=r.onAppearEnd,k=r.onEnterEnd,A=r.onLeaveEnd,L=r.onVisibleChanged,F=fr(),P=gr(F,2),O=P[0],N=P[1],z=fr(ni),M=gr(z,2),$=M[0],I=M[1],R=fr(null),B=gr(R,2),G=B[0],K=B[1],W=x.useRef(!1),ee=x.useRef(null);function ne(){return n()}var U=x.useRef(!1);function X(ve){var _e=ne();if(!(ve&&!ve.deadline&&ve.target!==_e)){var ke=U.current,ge;$===Zo&&ke?ge=E==null?void 0:E(_e,ve):$===Jo&&ke?ge=k==null?void 0:k(_e,ve):$===ea&&ke&&(ge=A==null?void 0:A(_e,ve)),$!==ni&&ke&&ge!==!1&&(I(ni,!0),K(null,!0))}}var ce=Kx(X),ue=gr(ce,1),se=ue[0],ae=T.useMemo(function(){var ve,_e,ke;switch($){case Zo:return ve={},wn(ve,Zn,p),wn(ve,ri,m),wn(ve,ii,_),ve;case Jo:return _e={},wn(_e,Zn,g),wn(_e,ri,w),wn(_e,ii,C),_e;case ea:return ke={},wn(ke,Zn,v),wn(ke,ri,b),wn(ke,ii,S),ke;default:return{}}},[$]),xe=Gx($,function(ve){if(ve===Zn){var _e=ae[Zn];return _e?_e(ne()):Nf}if(re in ae){var ke;K(((ke=ae[re])===null||ke===void 0?void 0:ke.call(ae,ne(),null))||null)}return re===ii&&(se(ne()),f>0&&(clearTimeout(ee.current),ee.current=setTimeout(function(){X({deadline:!0})},f))),jx}),be=gr(xe,2),Y=be[0],re=be[1],Se=$f(re);U.current=Se,Pf(function(){N(t);var ve=W.current;if(W.current=!0,!!e){var _e;!ve&&t&&s&&(_e=Zo),ve&&t&&o&&(_e=Jo),(ve&&!t&&c||!ve&&h&&!t&&c)&&(_e=ea),_e&&(I(_e),Y())}},[t]),x.useEffect(function(){($===Zo&&!s||$===Jo&&!o||$===ea&&!c)&&I(ni)},[s,o,c]),x.useEffect(function(){return function(){W.current=!1,clearTimeout(ee.current)}},[]);var q=T.useRef(!1);x.useEffect(function(){O&&(q.current=!0),O!==void 0&&$===ni&&((q.current||O)&&(L==null||L(O)),q.current=!0)},[O,$]);var we=G;return ae[Zn]&&re===ri&&(we=Nn({transition:"none"},we)),[$,re,we,O!=null?O:t]}function Wx(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Lf(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,xf(r.key),r)}}function qx(e,t,n){return t&&Lf(e.prototype,t),n&&Lf(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Js(e,t){return Js=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},Js(e,t)}function Ux(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Js(e,t)}function ta(e){return ta=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ta(e)}function Yx(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Xx(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Qx(e,t){if(t&&(hr(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Xx(e)}function Zx(e){var t=Yx();return function(){var r=ta(e),i;if(t){var o=ta(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return Qx(this,i)}}var Jx=function(e){Ux(n,e);var t=Zx(n);function n(){return Wx(this,n),t.apply(this,arguments)}return qx(n,[{key:"render",value:function(){return this.props.children}}]),n}(T.Component);function eS(e){var t=e;hr(e)==="object"&&(t=e.transitionSupport);function n(i){return!!(i.motionName&&t)}var r=T.forwardRef(function(i,o){var a=i.visible,s=a===void 0?!0:a,u=i.removeOnLeave,c=u===void 0?!0:u,f=i.forceRender,h=i.children,p=i.motionName,g=i.leavedClassName,v=i.eventProps,m=n(i),w=x.useRef(),b=x.useRef();function _(){try{return w.current instanceof HTMLElement?w.current:Ki(b.current)}catch{return null}}var C=Hx(m,s,_,i),S=gr(C,4),E=S[0],k=S[1],A=S[2],L=S[3],F=T.useRef(L);L&&(F.current=!0);var P=T.useCallback(function(R){w.current=R,Bd(o,R)},[o]),O,N=Nn(Nn({},v),{},{visible:s});if(!h)O=null;else if(E===ni||!n(i))L?O=h(Nn({},N),P):!c&&F.current?O=h(Nn(Nn({},N),{},{className:g}),P):f?O=h(Nn(Nn({},N),{},{style:{display:"none"}}),P):O=null;else{var z,M;k===Zn?M="prepare":$f(k)?M="active":k===ri&&(M="start"),O=h(Nn(Nn({},N),{},{className:pt(Rf(p,E),(z={},wn(z,Rf(p,"".concat(E,"-").concat(M)),M),wn(z,p,typeof p=="string"),z)),style:A}),P)}if(T.isValidElement(O)&&Ks(O)){var $=O,I=$.ref;I||(O=T.cloneElement(O,{ref:P}))}return l(Jx,{ref:b,children:O})});return r.displayName="CSSMotion",r}const na=eS(Fx);function Vf(e){var t=e.prefixCls,n=e.motion,r=e.animation,i=e.transitionName;return n||(r?{motionName:"".concat(t,"-").concat(r)}:i?{motionName:i}:null)}function tS(e){var t=e.prefixCls,n=e.visible,r=e.zIndex,i=e.mask,o=e.maskMotion,a=e.maskAnimation,s=e.maskTransitionName;if(!i)return null;var u={};return(o||s||a)&&(u=en({motionAppear:!0},Vf({motion:o,prefixCls:t,transitionName:s,animation:a}))),l(na,{...u,visible:n,removeOnLeave:!0,children:function(c){var f=c.className;return l("div",{style:{zIndex:r},className:pt("".concat(t,"-mask"),f)})}})}function nS(e){if(Array.isArray(e))return e}function rS(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(f){c=!0,i=f}finally{try{if(!u&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}function zf(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function iS(e,t){if(!!e){if(typeof e=="string")return zf(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return zf(e,t)}}function oS(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
70
70
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ff(e,t){return nS(e)||rS(e,t)||iS(e,t)||oS()}function el(e){return el=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},el(e)}const aS=function(e){if(!e)return!1;if(e instanceof HTMLElement&&e.offsetParent)return!0;if(e instanceof SVGGraphicsElement&&e.getBBox){var t=e.getBBox(),n=t.width,r=t.height;if(n||r)return!0}if(e instanceof HTMLElement&&e.getBoundingClientRect){var i=e.getBoundingClientRect(),o=i.width,a=i.height;if(o||a)return!0}return!1};function Bf(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function jf(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Bf(Object(n),!0).forEach(function(r){sS(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Bf(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function tl(e){return tl=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tl(e)}function sS(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Ui,lS={Webkit:"-webkit-",Moz:"-moz-",ms:"-ms-",O:"-o-"};function ra(){if(Ui!==void 0)return Ui;Ui="";var e=document.createElement("p").style,t="Transform";for(var n in lS)n+t in e&&(Ui=n);return Ui}function Gf(){return ra()?"".concat(ra(),"TransitionProperty"):"transitionProperty"}function ia(){return ra()?"".concat(ra(),"Transform"):"transform"}function Kf(e,t){var n=Gf();n&&(e.style[n]=t,n!=="transitionProperty"&&(e.style.transitionProperty=t))}function nl(e,t){var n=ia();n&&(e.style[n]=t,n!=="transform"&&(e.style.transform=t))}function uS(e){return e.style.transitionProperty||e.style[Gf()]}function cS(e){var t=window.getComputedStyle(e,null),n=t.getPropertyValue("transform")||t.getPropertyValue(ia());if(n&&n!=="none"){var r=n.replace(/[^0-9\-.,]/g,"").split(",");return{x:parseFloat(r[12]||r[4],0),y:parseFloat(r[13]||r[5],0)}}return{x:0,y:0}}var dS=/matrix\((.*)\)/,fS=/matrix3d\((.*)\)/;function pS(e,t){var n=window.getComputedStyle(e,null),r=n.getPropertyValue("transform")||n.getPropertyValue(ia());if(r&&r!=="none"){var i,o=r.match(dS);if(o)o=o[1],i=o.split(",").map(function(s){return parseFloat(s,10)}),i[4]=t.x,i[5]=t.y,nl(e,"matrix(".concat(i.join(","),")"));else{var a=r.match(fS)[1];i=a.split(",").map(function(s){return parseFloat(s,10)}),i[12]=t.x,i[13]=t.y,nl(e,"matrix3d(".concat(i.join(","),")"))}}else nl(e,"translateX(".concat(t.x,"px) translateY(").concat(t.y,"px) translateZ(0)"))}var hS=/[\-+]?(?:\d*\.|)\d+(?:[eE][\-+]?\d+|)/.source,Yi;function Hf(e){var t=e.style.display;e.style.display="none",e.offsetHeight,e.style.display=t}function oi(e,t,n){var r=n;if(tl(t)==="object"){for(var i in t)t.hasOwnProperty(i)&&oi(e,i,t[i]);return}if(typeof r<"u"){typeof r=="number"&&(r="".concat(r,"px")),e.style[t]=r;return}return Yi(e,t)}function gS(e){var t,n,r,i=e.ownerDocument,o=i.body,a=i&&i.documentElement;return t=e.getBoundingClientRect(),n=Math.floor(t.left),r=Math.floor(t.top),n-=a.clientLeft||o.clientLeft||0,r-=a.clientTop||o.clientTop||0,{left:n,top:r}}function Wf(e,t){var n=e["page".concat(t?"Y":"X","Offset")],r="scroll".concat(t?"Top":"Left");if(typeof n!="number"){var i=e.document;n=i.documentElement[r],typeof n!="number"&&(n=i.body[r])}return n}function qf(e){return Wf(e)}function Uf(e){return Wf(e,!0)}function Xi(e){var t=gS(e),n=e.ownerDocument,r=n.defaultView||n.parentWindow;return t.left+=qf(r),t.top+=Uf(r),t}function rl(e){return e!=null&&e==e.window}function Yf(e){return rl(e)?e.document:e.nodeType===9?e:e.ownerDocument}function vS(e,t,n){var r=n,i="",o=Yf(e);return r=r||o.defaultView.getComputedStyle(e,null),r&&(i=r.getPropertyValue(t)||r[t]),i}var mS=new RegExp("^(".concat(hS,")(?!px)[a-z%]+$"),"i"),yS=/^(top|right|bottom|left)$/,il="currentStyle",ol="runtimeStyle",Ar="left",bS="px";function wS(e,t){var n=e[il]&&e[il][t];if(mS.test(n)&&!yS.test(t)){var r=e.style,i=r[Ar],o=e[ol][Ar];e[ol][Ar]=e[il][Ar],r[Ar]=t==="fontSize"?"1em":n||0,n=r.pixelLeft+bS,r[Ar]=i,e[ol][Ar]=o}return n===""?"auto":n}typeof window<"u"&&(Yi=window.getComputedStyle?vS:wS);function oa(e,t){return e==="left"?t.useCssRight?"right":e:t.useCssBottom?"bottom":e}function Xf(e){if(e==="left")return"right";if(e==="right")return"left";if(e==="top")return"bottom";if(e==="bottom")return"top"}function Qf(e,t,n){oi(e,"position")==="static"&&(e.style.position="relative");var r=-999,i=-999,o=oa("left",n),a=oa("top",n),s=Xf(o),u=Xf(a);o!=="left"&&(r=999),a!=="top"&&(i=999);var c="",f=Xi(e);("left"in t||"top"in t)&&(c=uS(e)||"",Kf(e,"none")),"left"in t&&(e.style[s]="",e.style[o]="".concat(r,"px")),"top"in t&&(e.style[u]="",e.style[a]="".concat(i,"px")),Hf(e);var h=Xi(e),p={};for(var g in t)if(t.hasOwnProperty(g)){var v=oa(g,n),m=g==="left"?r:i,w=f[g]-h[g];v===g?p[v]=m+w:p[v]=m-w}oi(e,p),Hf(e),("left"in t||"top"in t)&&Kf(e,c);var b={};for(var _ in t)if(t.hasOwnProperty(_)){var C=oa(_,n),S=t[_]-f[_];_===C?b[C]=p[C]+S:b[C]=p[C]-S}oi(e,b)}function xS(e,t){var n=Xi(e),r=cS(e),i={x:r.x,y:r.y};"left"in t&&(i.x=r.x+t.left-n.left),"top"in t&&(i.y=r.y+t.top-n.top),pS(e,i)}function SS(e,t,n){if(n.ignoreShake){var r=Xi(e),i=r.left.toFixed(0),o=r.top.toFixed(0),a=t.left.toFixed(0),s=t.top.toFixed(0);if(i===a&&o===s)return}n.useCssRight||n.useCssBottom?Qf(e,t,n):n.useCssTransform&&ia()in document.body.style?xS(e,t):Qf(e,t,n)}function al(e,t){for(var n=0;n<e.length;n++)t(e[n])}function Zf(e){return Yi(e,"boxSizing")==="border-box"}var CS=["margin","border","padding"],sl=-1,_S=2,ll=1,ES=0;function TS(e,t,n){var r={},i=e.style,o;for(o in t)t.hasOwnProperty(o)&&(r[o]=i[o],i[o]=t[o]);n.call(e);for(o in t)t.hasOwnProperty(o)&&(i[o]=r[o])}function Qi(e,t,n){var r=0,i,o,a;for(o=0;o<t.length;o++)if(i=t[o],i)for(a=0;a<n.length;a++){var s=void 0;i==="border"?s="".concat(i).concat(n[a],"Width"):s=i+n[a],r+=parseFloat(Yi(e,s))||0}return r}var $n={getParent:function(t){var n=t;do n.nodeType===11&&n.host?n=n.host:n=n.parentNode;while(n&&n.nodeType!==1&&n.nodeType!==9);return n}};al(["Width","Height"],function(e){$n["doc".concat(e)]=function(t){var n=t.document;return Math.max(n.documentElement["scroll".concat(e)],n.body["scroll".concat(e)],$n["viewport".concat(e)](n))},$n["viewport".concat(e)]=function(t){var n="client".concat(e),r=t.document,i=r.body,o=r.documentElement,a=o[n];return r.compatMode==="CSS1Compat"&&a||i&&i[n]||a}});function Jf(e,t,n){var r=n;if(rl(e))return t==="width"?$n.viewportWidth(e):$n.viewportHeight(e);if(e.nodeType===9)return t==="width"?$n.docWidth(e):$n.docHeight(e);var i=t==="width"?["Left","Right"]:["Top","Bottom"],o=Math.floor(t==="width"?e.getBoundingClientRect().width:e.getBoundingClientRect().height),a=Zf(e),s=0;(o==null||o<=0)&&(o=void 0,s=Yi(e,t),(s==null||Number(s)<0)&&(s=e.style[t]||0),s=Math.floor(parseFloat(s))||0),r===void 0&&(r=a?ll:sl);var u=o!==void 0||a,c=o||s;return r===sl?u?c-Qi(e,["border","padding"],i):s:u?r===ll?c:c+(r===_S?-Qi(e,["border"],i):Qi(e,["margin"],i)):s+Qi(e,CS.slice(r),i)}var MS={position:"absolute",visibility:"hidden",display:"block"};function ep(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];var r,i=t[0];return i.offsetWidth!==0?r=Jf.apply(void 0,t):TS(i,MS,function(){r=Jf.apply(void 0,t)}),r}al(["width","height"],function(e){var t=e.charAt(0).toUpperCase()+e.slice(1);$n["outer".concat(t)]=function(r,i){return r&&ep(r,e,i?ES:ll)};var n=e==="width"?["Left","Right"]:["Top","Bottom"];$n[e]=function(r,i){var o=i;if(o!==void 0){if(r){var a=Zf(r);return a&&(o+=Qi(r,["padding","border"],n)),oi(r,e,o)}return}return r&&ep(r,e,sl)}});function tp(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n]);return e}var je={getWindow:function(t){if(t&&t.document&&t.setTimeout)return t;var n=t.ownerDocument||t;return n.defaultView||n.parentWindow},getDocument:Yf,offset:function(t,n,r){if(typeof n<"u")SS(t,n,r||{});else return Xi(t)},isWindow:rl,each:al,css:oi,clone:function(t){var n,r={};for(n in t)t.hasOwnProperty(n)&&(r[n]=t[n]);var i=t.overflow;if(i)for(n in t)t.hasOwnProperty(n)&&(r.overflow[n]=t.overflow[n]);return r},mix:tp,getWindowScrollLeft:function(t){return qf(t)},getWindowScrollTop:function(t){return Uf(t)},merge:function(){for(var t={},n=0;n<arguments.length;n++)je.mix(t,n<0||arguments.length<=n?void 0:arguments[n]);return t},viewportWidth:0,viewportHeight:0};tp(je,$n);var ul=je.getParent;function cl(e){if(je.isWindow(e)||e.nodeType===9)return null;var t=je.getDocument(e),n=t.body,r,i=je.css(e,"position"),o=i==="fixed"||i==="absolute";if(!o)return e.nodeName.toLowerCase()==="html"?null:ul(e);for(r=ul(e);r&&r!==n&&r.nodeType!==9;r=ul(r))if(i=je.css(r,"position"),i!=="static")return r;return null}var np=je.getParent;function kS(e){if(je.isWindow(e)||e.nodeType===9)return!1;var t=je.getDocument(e),n=t.body,r=null;for(r=np(e);r&&r!==n&&r!==t;r=np(r)){var i=je.css(r,"position");if(i==="fixed")return!0}return!1}function dl(e,t){for(var n={left:0,right:1/0,top:0,bottom:1/0},r=cl(e),i=je.getDocument(e),o=i.defaultView||i.parentWindow,a=i.body,s=i.documentElement;r;){if((navigator.userAgent.indexOf("MSIE")===-1||r.clientWidth!==0)&&r!==a&&r!==s&&je.css(r,"overflow")!=="visible"){var u=je.offset(r);u.left+=r.clientLeft,u.top+=r.clientTop,n.top=Math.max(n.top,u.top),n.right=Math.min(n.right,u.left+r.clientWidth),n.bottom=Math.min(n.bottom,u.top+r.clientHeight),n.left=Math.max(n.left,u.left)}else if(r===a||r===s)break;r=cl(r)}var c=null;if(!je.isWindow(e)&&e.nodeType!==9){c=e.style.position;var f=je.css(e,"position");f==="absolute"&&(e.style.position="fixed")}var h=je.getWindowScrollLeft(o),p=je.getWindowScrollTop(o),g=je.viewportWidth(o),v=je.viewportHeight(o),m=s.scrollWidth,w=s.scrollHeight,b=window.getComputedStyle(a);if(b.overflowX==="hidden"&&(m=o.innerWidth),b.overflowY==="hidden"&&(w=o.innerHeight),e.style&&(e.style.position=c),t||kS(e))n.left=Math.max(n.left,h),n.top=Math.max(n.top,p),n.right=Math.min(n.right,h+g),n.bottom=Math.min(n.bottom,p+v);else{var _=Math.max(m,h+g);n.right=Math.min(n.right,_);var C=Math.max(w,p+v);n.bottom=Math.min(n.bottom,C)}return n.top>=0&&n.left>=0&&n.bottom>n.top&&n.right>n.left?n:null}function OS(e,t,n,r){var i=je.clone(e),o={width:t.width,height:t.height};return r.adjustX&&i.left<n.left&&(i.left=n.left),r.resizeWidth&&i.left>=n.left&&i.left+o.width>n.right&&(o.width-=i.left+o.width-n.right),r.adjustX&&i.left+o.width>n.right&&(i.left=Math.max(n.right-o.width,n.left)),r.adjustY&&i.top<n.top&&(i.top=n.top),r.resizeHeight&&i.top>=n.top&&i.top+o.height>n.bottom&&(o.height-=i.top+o.height-n.bottom),r.adjustY&&i.top+o.height>n.bottom&&(i.top=Math.max(n.bottom-o.height,n.top)),je.mix(i,o)}function fl(e){var t,n,r;if(!je.isWindow(e)&&e.nodeType!==9)t=je.offset(e),n=je.outerWidth(e),r=je.outerHeight(e);else{var i=je.getWindow(e);t={left:je.getWindowScrollLeft(i),top:je.getWindowScrollTop(i)},n=je.viewportWidth(i),r=je.viewportHeight(i)}return t.width=n,t.height=r,t}function rp(e,t){var n=t.charAt(0),r=t.charAt(1),i=e.width,o=e.height,a=e.left,s=e.top;return n==="c"?s+=o/2:n==="b"&&(s+=o),r==="c"?a+=i/2:r==="r"&&(a+=i),{left:a,top:s}}function aa(e,t,n,r,i){var o=rp(t,n[1]),a=rp(e,n[0]),s=[a.left-o.left,a.top-o.top];return{left:Math.round(e.left-s[0]+r[0]-i[0]),top:Math.round(e.top-s[1]+r[1]-i[1])}}function ip(e,t,n){return e.left<n.left||e.left+t.width>n.right}function op(e,t,n){return e.top<n.top||e.top+t.height>n.bottom}function DS(e,t,n){return e.left>n.right||e.left+t.width<n.left}function RS(e,t,n){return e.top>n.bottom||e.top+t.height<n.top}function sa(e,t,n){var r=[];return je.each(e,function(i){r.push(i.replace(t,function(o){return n[o]}))}),r}function la(e,t){return e[t]=-e[t],e}function ap(e,t){var n;return/%$/.test(e)?n=parseInt(e.substring(0,e.length-1),10)/100*t:n=parseInt(e,10),n||0}function sp(e,t){e[0]=ap(e[0],t.width),e[1]=ap(e[1],t.height)}function lp(e,t,n,r){var i=n.points,o=n.offset||[0,0],a=n.targetOffset||[0,0],s=n.overflow,u=n.source||e;o=[].concat(o),a=[].concat(a),s=s||{};var c={},f=0,h=!!(s&&s.alwaysByViewport),p=dl(u,h),g=fl(u);sp(o,g),sp(a,t);var v=aa(g,t,i,o,a),m=je.merge(g,v);if(p&&(s.adjustX||s.adjustY)&&r){if(s.adjustX&&ip(v,g,p)){var w=sa(i,/[lr]/gi,{l:"r",r:"l"}),b=la(o,0),_=la(a,0),C=aa(g,t,w,b,_);DS(C,g,p)||(f=1,i=w,o=b,a=_)}if(s.adjustY&&op(v,g,p)){var S=sa(i,/[tb]/gi,{t:"b",b:"t"}),E=la(o,1),k=la(a,1),A=aa(g,t,S,E,k);RS(A,g,p)||(f=1,i=S,o=E,a=k)}f&&(v=aa(g,t,i,o,a),je.mix(m,v));var L=ip(v,g,p),F=op(v,g,p);if(L||F){var P=i;L&&(P=sa(i,/[lr]/gi,{l:"r",r:"l"})),F&&(P=sa(i,/[tb]/gi,{t:"b",b:"t"})),i=P,o=n.offset||[0,0],a=n.targetOffset||[0,0]}c.adjustX=s.adjustX&&L,c.adjustY=s.adjustY&&F,(c.adjustX||c.adjustY)&&(m=OS(v,g,p,c))}return m.width!==g.width&&je.css(u,"width",je.width(u)+m.width-g.width),m.height!==g.height&&je.css(u,"height",je.height(u)+m.height-g.height),je.offset(u,{left:m.left,top:m.top},{useCssRight:n.useCssRight,useCssBottom:n.useCssBottom,useCssTransform:n.useCssTransform,ignoreShake:n.ignoreShake}),{points:i,offset:o,targetOffset:a,overflow:c}}function AS(e,t){var n=dl(e,t),r=fl(e);return!n||r.left+r.width<=n.left||r.top+r.height<=n.top||r.left>=n.right||r.top>=n.bottom}function pl(e,t,n){var r=n.target||t,i=fl(r),o=!AS(r,n.overflow&&n.overflow.alwaysByViewport);return lp(e,i,n,o)}pl.__getOffsetParent=cl,pl.__getVisibleRectForElement=dl;function PS(e,t,n){var r,i,o=je.getDocument(e),a=o.defaultView||o.parentWindow,s=je.getWindowScrollLeft(a),u=je.getWindowScrollTop(a),c=je.viewportWidth(a),f=je.viewportHeight(a);"pageX"in t?r=t.pageX:r=s+t.clientX,"pageY"in t?i=t.pageY:i=u+t.clientY;var h={left:r,top:i,width:0,height:0},p=r>=0&&r<=s+c&&i>=0&&i<=u+f,g=[n.points[0],"cc"];return lp(e,h,jf(jf({},n),{},{points:g}),p)}function IS(){this.__data__=[],this.size=0}var NS=IS;function $S(e,t){return e===t||e!==e&&t!==t}var up=$S,LS=up;function VS(e,t){for(var n=e.length;n--;)if(LS(e[n][0],t))return n;return-1}var ua=VS,zS=ua,FS=Array.prototype,BS=FS.splice;function jS(e){var t=this.__data__,n=zS(t,e);if(n<0)return!1;var r=t.length-1;return n==r?t.pop():BS.call(t,n,1),--this.size,!0}var GS=jS,KS=ua;function HS(e){var t=this.__data__,n=KS(t,e);return n<0?void 0:t[n][1]}var WS=HS,qS=ua;function US(e){return qS(this.__data__,e)>-1}var YS=US,XS=ua;function QS(e,t){var n=this.__data__,r=XS(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this}var ZS=QS,JS=NS,eC=GS,tC=WS,nC=YS,rC=ZS;function ai(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ai.prototype.clear=JS,ai.prototype.delete=eC,ai.prototype.get=tC,ai.prototype.has=nC,ai.prototype.set=rC;var ca=ai,iC=ca;function oC(){this.__data__=new iC,this.size=0}var aC=oC;function sC(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n}var lC=sC;function uC(e){return this.__data__.get(e)}var cC=uC;function dC(e){return this.__data__.has(e)}var fC=dC,pC=typeof hn=="object"&&hn&&hn.Object===Object&&hn,cp=pC,hC=cp,gC=typeof self=="object"&&self&&self.Object===Object&&self,vC=hC||gC||Function("return this")(),Jn=vC,mC=Jn,yC=mC.Symbol,hl=yC,dp=hl,fp=Object.prototype,bC=fp.hasOwnProperty,wC=fp.toString,Zi=dp?dp.toStringTag:void 0;function xC(e){var t=bC.call(e,Zi),n=e[Zi];try{e[Zi]=void 0;var r=!0}catch{}var i=wC.call(e);return r&&(t?e[Zi]=n:delete e[Zi]),i}var SC=xC,CC=Object.prototype,_C=CC.toString;function EC(e){return _C.call(e)}var TC=EC,pp=hl,MC=SC,kC=TC,OC="[object Null]",DC="[object Undefined]",hp=pp?pp.toStringTag:void 0;function RC(e){return e==null?e===void 0?DC:OC:hp&&hp in Object(e)?MC(e):kC(e)}var da=RC;function AC(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}var gp=AC,PC=da,IC=gp,NC="[object AsyncFunction]",$C="[object Function]",LC="[object GeneratorFunction]",VC="[object Proxy]";function zC(e){if(!IC(e))return!1;var t=PC(e);return t==$C||t==LC||t==NC||t==VC}var vp=zC,FC=Jn,BC=FC["__core-js_shared__"],jC=BC,gl=jC,mp=function(){var e=/[^.]+$/.exec(gl&&gl.keys&&gl.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}();function GC(e){return!!mp&&mp in e}var KC=GC,HC=Function.prototype,WC=HC.toString;function qC(e){if(e!=null){try{return WC.call(e)}catch{}try{return e+""}catch{}}return""}var yp=qC,UC=vp,YC=KC,XC=gp,QC=yp,ZC=/[\\^$.*+?()[\]{}|]/g,JC=/^\[object .+?Constructor\]$/,e_=Function.prototype,t_=Object.prototype,n_=e_.toString,r_=t_.hasOwnProperty,i_=RegExp("^"+n_.call(r_).replace(ZC,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function o_(e){if(!XC(e)||YC(e))return!1;var t=UC(e)?i_:JC;return t.test(QC(e))}var a_=o_;function s_(e,t){return e==null?void 0:e[t]}var l_=s_,u_=a_,c_=l_;function d_(e,t){var n=c_(e,t);return u_(n)?n:void 0}var si=d_,f_=si,p_=Jn,h_=f_(p_,"Map"),vl=h_,g_=si,v_=g_(Object,"create"),fa=v_,bp=fa;function m_(){this.__data__=bp?bp(null):{},this.size=0}var y_=m_;function b_(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}var w_=b_,x_=fa,S_="__lodash_hash_undefined__",C_=Object.prototype,__=C_.hasOwnProperty;function E_(e){var t=this.__data__;if(x_){var n=t[e];return n===S_?void 0:n}return __.call(t,e)?t[e]:void 0}var T_=E_,M_=fa,k_=Object.prototype,O_=k_.hasOwnProperty;function D_(e){var t=this.__data__;return M_?t[e]!==void 0:O_.call(t,e)}var R_=D_,A_=fa,P_="__lodash_hash_undefined__";function I_(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=A_&&t===void 0?P_:t,this}var N_=I_,$_=y_,L_=w_,V_=T_,z_=R_,F_=N_;function li(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}li.prototype.clear=$_,li.prototype.delete=L_,li.prototype.get=V_,li.prototype.has=z_,li.prototype.set=F_;var B_=li,wp=B_,j_=ca,G_=vl;function K_(){this.size=0,this.__data__={hash:new wp,map:new(G_||j_),string:new wp}}var H_=K_;function W_(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}var q_=W_,U_=q_;function Y_(e,t){var n=e.__data__;return U_(t)?n[typeof t=="string"?"string":"hash"]:n.map}var pa=Y_,X_=pa;function Q_(e){var t=X_(this,e).delete(e);return this.size-=t?1:0,t}var Z_=Q_,J_=pa;function e1(e){return J_(this,e).get(e)}var t1=e1,n1=pa;function r1(e){return n1(this,e).has(e)}var i1=r1,o1=pa;function a1(e,t){var n=o1(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this}var s1=a1,l1=H_,u1=Z_,c1=t1,d1=i1,f1=s1;function ui(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}ui.prototype.clear=l1,ui.prototype.delete=u1,ui.prototype.get=c1,ui.prototype.has=d1,ui.prototype.set=f1;var xp=ui,p1=ca,h1=vl,g1=xp,v1=200;function m1(e,t){var n=this.__data__;if(n instanceof p1){var r=n.__data__;if(!h1||r.length<v1-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new g1(r)}return n.set(e,t),this.size=n.size,this}var y1=m1,b1=ca,w1=aC,x1=lC,S1=cC,C1=fC,_1=y1;function ci(e){var t=this.__data__=new b1(e);this.size=t.size}ci.prototype.clear=w1,ci.prototype.delete=x1,ci.prototype.get=S1,ci.prototype.has=C1,ci.prototype.set=_1;var E1=ci,T1="__lodash_hash_undefined__";function M1(e){return this.__data__.set(e,T1),this}var k1=M1;function O1(e){return this.__data__.has(e)}var D1=O1,R1=xp,A1=k1,P1=D1;function ha(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new R1;++t<n;)this.add(e[t])}ha.prototype.add=ha.prototype.push=A1,ha.prototype.has=P1;var I1=ha;function N1(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}var $1=N1;function L1(e,t){return e.has(t)}var V1=L1,z1=I1,F1=$1,B1=V1,j1=1,G1=2;function K1(e,t,n,r,i,o){var a=n&j1,s=e.length,u=t.length;if(s!=u&&!(a&&u>s))return!1;var c=o.get(e),f=o.get(t);if(c&&f)return c==t&&f==e;var h=-1,p=!0,g=n&G1?new z1:void 0;for(o.set(e,t),o.set(t,e);++h<s;){var v=e[h],m=t[h];if(r)var w=a?r(m,v,h,t,e,o):r(v,m,h,e,t,o);if(w!==void 0){if(w)continue;p=!1;break}if(g){if(!F1(t,function(b,_){if(!B1(g,_)&&(v===b||i(v,b,n,r,o)))return g.push(_)})){p=!1;break}}else if(!(v===m||i(v,m,n,r,o))){p=!1;break}}return o.delete(e),o.delete(t),p}var Sp=K1,H1=Jn,W1=H1.Uint8Array,q1=W1;function U1(e){var t=-1,n=Array(e.size);return e.forEach(function(r,i){n[++t]=[i,r]}),n}var Y1=U1;function X1(e){var t=-1,n=Array(e.size);return e.forEach(function(r){n[++t]=r}),n}var Q1=X1,Cp=hl,_p=q1,Z1=up,J1=Sp,eE=Y1,tE=Q1,nE=1,rE=2,iE="[object Boolean]",oE="[object Date]",aE="[object Error]",sE="[object Map]",lE="[object Number]",uE="[object RegExp]",cE="[object Set]",dE="[object String]",fE="[object Symbol]",pE="[object ArrayBuffer]",hE="[object DataView]",Ep=Cp?Cp.prototype:void 0,ml=Ep?Ep.valueOf:void 0;function gE(e,t,n,r,i,o,a){switch(n){case hE:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case pE:return!(e.byteLength!=t.byteLength||!o(new _p(e),new _p(t)));case iE:case oE:case lE:return Z1(+e,+t);case aE:return e.name==t.name&&e.message==t.message;case uE:case dE:return e==t+"";case sE:var s=eE;case cE:var u=r&nE;if(s||(s=tE),e.size!=t.size&&!u)return!1;var c=a.get(e);if(c)return c==t;r|=rE,a.set(e,t);var f=J1(s(e),s(t),r,i,o,a);return a.delete(e),f;case fE:if(ml)return ml.call(e)==ml.call(t)}return!1}var vE=gE;function mE(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var yE=mE,bE=Array.isArray,yl=bE,wE=yE,xE=yl;function SE(e,t,n){var r=t(e);return xE(e)?r:wE(r,n(e))}var CE=SE;function _E(e,t){for(var n=-1,r=e==null?0:e.length,i=0,o=[];++n<r;){var a=e[n];t(a,n,e)&&(o[i++]=a)}return o}var EE=_E;function TE(){return[]}var ME=TE,kE=EE,OE=ME,DE=Object.prototype,RE=DE.propertyIsEnumerable,Tp=Object.getOwnPropertySymbols,AE=Tp?function(e){return e==null?[]:(e=Object(e),kE(Tp(e),function(t){return RE.call(e,t)}))}:OE,PE=AE;function IE(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var NE=IE;function $E(e){return e!=null&&typeof e=="object"}var ga=$E,LE=da,VE=ga,zE="[object Arguments]";function FE(e){return VE(e)&&LE(e)==zE}var BE=FE,Mp=BE,jE=ga,kp=Object.prototype,GE=kp.hasOwnProperty,KE=kp.propertyIsEnumerable,HE=Mp(function(){return arguments}())?Mp:function(e){return jE(e)&&GE.call(e,"callee")&&!KE.call(e,"callee")},WE=HE,va={exports:{}};function qE(){return!1}var UE=qE;(function(e,t){var n=Jn,r=UE,i=t&&!t.nodeType&&t,o=i&&!0&&e&&!e.nodeType&&e,a=o&&o.exports===i,s=a?n.Buffer:void 0,u=s?s.isBuffer:void 0,c=u||r;e.exports=c})(va,va.exports);var YE=9007199254740991,XE=/^(?:0|[1-9]\d*)$/;function QE(e,t){var n=typeof e;return t=t==null?YE:t,!!t&&(n=="number"||n!="symbol"&&XE.test(e))&&e>-1&&e%1==0&&e<t}var ZE=QE,JE=9007199254740991;function eT(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=JE}var Op=eT,tT=da,nT=Op,rT=ga,iT="[object Arguments]",oT="[object Array]",aT="[object Boolean]",sT="[object Date]",lT="[object Error]",uT="[object Function]",cT="[object Map]",dT="[object Number]",fT="[object Object]",pT="[object RegExp]",hT="[object Set]",gT="[object String]",vT="[object WeakMap]",mT="[object ArrayBuffer]",yT="[object DataView]",bT="[object Float32Array]",wT="[object Float64Array]",xT="[object Int8Array]",ST="[object Int16Array]",CT="[object Int32Array]",_T="[object Uint8Array]",ET="[object Uint8ClampedArray]",TT="[object Uint16Array]",MT="[object Uint32Array]",St={};St[bT]=St[wT]=St[xT]=St[ST]=St[CT]=St[_T]=St[ET]=St[TT]=St[MT]=!0,St[iT]=St[oT]=St[mT]=St[aT]=St[yT]=St[sT]=St[lT]=St[uT]=St[cT]=St[dT]=St[fT]=St[pT]=St[hT]=St[gT]=St[vT]=!1;function kT(e){return rT(e)&&nT(e.length)&&!!St[tT(e)]}var OT=kT;function DT(e){return function(t){return e(t)}}var RT=DT,bl={exports:{}};(function(e,t){var n=cp,r=t&&!t.nodeType&&t,i=r&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===r,a=o&&n.process,s=function(){try{var u=i&&i.require&&i.require("util").types;return u||a&&a.binding&&a.binding("util")}catch{}}();e.exports=s})(bl,bl.exports);var AT=OT,PT=RT,Dp=bl.exports,Rp=Dp&&Dp.isTypedArray,IT=Rp?PT(Rp):AT,Ap=IT,NT=NE,$T=WE,LT=yl,VT=va.exports,zT=ZE,FT=Ap,BT=Object.prototype,jT=BT.hasOwnProperty;function GT(e,t){var n=LT(e),r=!n&&$T(e),i=!n&&!r&&VT(e),o=!n&&!r&&!i&&FT(e),a=n||r||i||o,s=a?NT(e.length,String):[],u=s.length;for(var c in e)(t||jT.call(e,c))&&!(a&&(c=="length"||i&&(c=="offset"||c=="parent")||o&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||zT(c,u)))&&s.push(c);return s}var KT=GT,HT=Object.prototype;function WT(e){var t=e&&e.constructor,n=typeof t=="function"&&t.prototype||HT;return e===n}var qT=WT;function UT(e,t){return function(n){return e(t(n))}}var YT=UT,XT=YT,QT=XT(Object.keys,Object),ZT=QT,JT=qT,eM=ZT,tM=Object.prototype,nM=tM.hasOwnProperty;function rM(e){if(!JT(e))return eM(e);var t=[];for(var n in Object(e))nM.call(e,n)&&n!="constructor"&&t.push(n);return t}var iM=rM,oM=vp,aM=Op;function sM(e){return e!=null&&aM(e.length)&&!oM(e)}var lM=sM,uM=KT,cM=iM,dM=lM;function fM(e){return dM(e)?uM(e):cM(e)}var pM=fM,hM=CE,gM=PE,vM=pM;function mM(e){return hM(e,vM,gM)}var yM=mM,Pp=yM,bM=1,wM=Object.prototype,xM=wM.hasOwnProperty;function SM(e,t,n,r,i,o){var a=n&bM,s=Pp(e),u=s.length,c=Pp(t),f=c.length;if(u!=f&&!a)return!1;for(var h=u;h--;){var p=s[h];if(!(a?p in t:xM.call(t,p)))return!1}var g=o.get(e),v=o.get(t);if(g&&v)return g==t&&v==e;var m=!0;o.set(e,t),o.set(t,e);for(var w=a;++h<u;){p=s[h];var b=e[p],_=t[p];if(r)var C=a?r(_,b,p,t,e,o):r(b,_,p,e,t,o);if(!(C===void 0?b===_||i(b,_,n,r,o):C)){m=!1;break}w||(w=p=="constructor")}if(m&&!w){var S=e.constructor,E=t.constructor;S!=E&&"constructor"in e&&"constructor"in t&&!(typeof S=="function"&&S instanceof S&&typeof E=="function"&&E instanceof E)&&(m=!1)}return o.delete(e),o.delete(t),m}var CM=SM,_M=si,EM=Jn,TM=_M(EM,"DataView"),MM=TM,kM=si,OM=Jn,DM=kM(OM,"Promise"),RM=DM,AM=si,PM=Jn,IM=AM(PM,"Set"),NM=IM,$M=si,LM=Jn,VM=$M(LM,"WeakMap"),zM=VM,wl=MM,xl=vl,Sl=RM,Cl=NM,_l=zM,Ip=da,di=yp,Np="[object Map]",FM="[object Object]",$p="[object Promise]",Lp="[object Set]",Vp="[object WeakMap]",zp="[object DataView]",BM=di(wl),jM=di(xl),GM=di(Sl),KM=di(Cl),HM=di(_l),Pr=Ip;(wl&&Pr(new wl(new ArrayBuffer(1)))!=zp||xl&&Pr(new xl)!=Np||Sl&&Pr(Sl.resolve())!=$p||Cl&&Pr(new Cl)!=Lp||_l&&Pr(new _l)!=Vp)&&(Pr=function(e){var t=Ip(e),n=t==FM?e.constructor:void 0,r=n?di(n):"";if(r)switch(r){case BM:return zp;case jM:return Np;case GM:return $p;case KM:return Lp;case HM:return Vp}return t});var WM=Pr,El=E1,qM=Sp,UM=vE,YM=CM,Fp=WM,Bp=yl,jp=va.exports,XM=Ap,QM=1,Gp="[object Arguments]",Kp="[object Array]",ma="[object Object]",ZM=Object.prototype,Hp=ZM.hasOwnProperty;function JM(e,t,n,r,i,o){var a=Bp(e),s=Bp(t),u=a?Kp:Fp(e),c=s?Kp:Fp(t);u=u==Gp?ma:u,c=c==Gp?ma:c;var f=u==ma,h=c==ma,p=u==c;if(p&&jp(e)){if(!jp(t))return!1;a=!0,f=!1}if(p&&!f)return o||(o=new El),a||XM(e)?qM(e,t,n,r,i,o):UM(e,t,u,n,r,i,o);if(!(n&QM)){var g=f&&Hp.call(e,"__wrapped__"),v=h&&Hp.call(t,"__wrapped__");if(g||v){var m=g?e.value():e,w=v?t.value():t;return o||(o=new El),i(m,w,n,r,o)}}return p?(o||(o=new El),YM(e,t,n,r,i,o)):!1}var ek=JM,tk=ek,Wp=ga;function qp(e,t,n,r,i){return e===t?!0:e==null||t==null||!Wp(e)&&!Wp(t)?e!==e&&t!==t:tk(e,t,n,r,qp,i)}var nk=qp,rk=nk;function ik(e,t){return rk(e,t)}var ok=ik;function ak(e,t){return e===t?!0:!e||!t?!1:"pageX"in t&&"pageY"in t?e.pageX===t.pageX&&e.pageY===t.pageY:"clientX"in t&&"clientY"in t?e.clientX===t.clientX&&e.clientY===t.clientY:!1}function sk(e,t){e!==document.activeElement&&Xo(t,e)&&typeof e.focus=="function"&&e.focus()}function Up(e,t){var n=null,r=null;function i(a){var s=Ff(a,1),u=s[0].target;if(!!document.documentElement.contains(u)){var c=u.getBoundingClientRect(),f=c.width,h=c.height,p=Math.floor(f),g=Math.floor(h);(n!==p||r!==g)&&Promise.resolve().then(function(){t({width:p,height:g})}),n=p,r=g}}var o=new of(i);return e&&o.observe(e),function(){o.disconnect()}}const lk=function(e,t){var n=Z.default.useRef(!1),r=Z.default.useRef(null);function i(){window.clearTimeout(r.current)}function o(a){if(i(),!n.current||a===!0){if(e()===!1)return;n.current=!0,r.current=window.setTimeout(function(){n.current=!1},t)}else r.current=window.setTimeout(function(){n.current=!1,o()},t)}return[o,function(){n.current=!1,i()}]};function Yp(e){return typeof e!="function"?null:e()}function Xp(e){return el(e)!=="object"||!e?null:e}var uk=function(t,n){var r=t.children,i=t.disabled,o=t.target,a=t.align,s=t.onAlign,u=t.monitorWindowResize,c=t.monitorBufferTime,f=c===void 0?0:c,h=Z.default.useRef({}),p=Z.default.useRef(),g=Z.default.Children.only(r),v=Z.default.useRef({});v.current.disabled=i,v.current.target=o,v.current.align=a,v.current.onAlign=s;var m=lk(function(){var k=v.current,A=k.disabled,L=k.target,F=k.align,P=k.onAlign;if(!A&&L){var O=p.current,N,z=Yp(L),M=Xp(L);h.current.element=z,h.current.point=M,h.current.align=F;var $=document,I=$.activeElement;return z&&aS(z)?N=pl(O,z,F):M&&(N=PS(O,M,F)),sk(I,O),P&&N&&P(O,N),!0}return!1},f),w=Ff(m,2),b=w[0],_=w[1],C=Z.default.useRef({cancel:function(){}}),S=Z.default.useRef({cancel:function(){}});Z.default.useEffect(function(){var k=Yp(o),A=Xp(o);p.current!==S.current.element&&(S.current.cancel(),S.current.element=p.current,S.current.cancel=Up(p.current,b)),(h.current.element!==k||!ak(h.current.point,A)||!ok(h.current.align,a))&&(b(),C.current.element!==k&&(C.current.cancel(),C.current.element=k,C.current.cancel=Up(k,b)))}),Z.default.useEffect(function(){i?_():b()},[i]);var E=Z.default.useRef(null);return Z.default.useEffect(function(){u?E.current||(E.current=qi(window,"resize",b)):E.current&&(E.current.remove(),E.current=null)},[u]),Z.default.useEffect(function(){return function(){C.current.cancel(),S.current.cancel(),E.current&&E.current.remove(),_()}},[]),Z.default.useImperativeHandle(n,function(){return{forceAlign:function(){return b(!0)}}}),Z.default.isValidElement(g)&&(g=Z.default.cloneElement(g,{ref:Bi(g.ref,p)})),g},Qp=Z.default.forwardRef(uk);Qp.displayName="Align";function Tl(){/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */Tl=function(){return e};var e={},t=Object.prototype,n=t.hasOwnProperty,r=typeof Symbol=="function"?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function s(P,O,N){return Object.defineProperty(P,O,{value:N,enumerable:!0,configurable:!0,writable:!0}),P[O]}try{s({},"")}catch{s=function(N,z,M){return N[z]=M}}function u(P,O,N,z){var M=O&&O.prototype instanceof h?O:h,$=Object.create(M.prototype),I=new A(z||[]);return $._invoke=function(R,B,G){var K="suspendedStart";return function(W,ee){if(K==="executing")throw new Error("Generator is already running");if(K==="completed"){if(W==="throw")throw ee;return F()}for(G.method=W,G.arg=ee;;){var ne=G.delegate;if(ne){var U=S(ne,G);if(U){if(U===f)continue;return U}}if(G.method==="next")G.sent=G._sent=G.arg;else if(G.method==="throw"){if(K==="suspendedStart")throw K="completed",G.arg;G.dispatchException(G.arg)}else G.method==="return"&&G.abrupt("return",G.arg);K="executing";var X=c(R,B,G);if(X.type==="normal"){if(K=G.done?"completed":"suspendedYield",X.arg===f)continue;return{value:X.arg,done:G.done}}X.type==="throw"&&(K="completed",G.method="throw",G.arg=X.arg)}}}(P,N,I),$}function c(P,O,N){try{return{type:"normal",arg:P.call(O,N)}}catch(z){return{type:"throw",arg:z}}}e.wrap=u;var f={};function h(){}function p(){}function g(){}var v={};s(v,i,function(){return this});var m=Object.getPrototypeOf,w=m&&m(m(L([])));w&&w!==t&&n.call(w,i)&&(v=w);var b=g.prototype=h.prototype=Object.create(v);function _(P){["next","throw","return"].forEach(function(O){s(P,O,function(N){return this._invoke(O,N)})})}function C(P,O){function N(M,$,I,R){var B=c(P[M],P,$);if(B.type!=="throw"){var G=B.arg,K=G.value;return K&&Fi(K)=="object"&&n.call(K,"__await")?O.resolve(K.__await).then(function(W){N("next",W,I,R)},function(W){N("throw",W,I,R)}):O.resolve(K).then(function(W){G.value=W,I(G)},function(W){return N("throw",W,I,R)})}R(B.arg)}var z;this._invoke=function(M,$){function I(){return new O(function(R,B){N(M,$,R,B)})}return z=z?z.then(I,I):I()}}function S(P,O){var N=P.iterator[O.method];if(N===void 0){if(O.delegate=null,O.method==="throw"){if(P.iterator.return&&(O.method="return",O.arg=void 0,S(P,O),O.method==="throw"))return f;O.method="throw",O.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var z=c(N,P.iterator,O.arg);if(z.type==="throw")return O.method="throw",O.arg=z.arg,O.delegate=null,f;var M=z.arg;return M?M.done?(O[P.resultName]=M.value,O.next=P.nextLoc,O.method!=="return"&&(O.method="next",O.arg=void 0),O.delegate=null,f):M:(O.method="throw",O.arg=new TypeError("iterator result is not an object"),O.delegate=null,f)}function E(P){var O={tryLoc:P[0]};1 in P&&(O.catchLoc=P[1]),2 in P&&(O.finallyLoc=P[2],O.afterLoc=P[3]),this.tryEntries.push(O)}function k(P){var O=P.completion||{};O.type="normal",delete O.arg,P.completion=O}function A(P){this.tryEntries=[{tryLoc:"root"}],P.forEach(E,this),this.reset(!0)}function L(P){if(P){var O=P[i];if(O)return O.call(P);if(typeof P.next=="function")return P;if(!isNaN(P.length)){var N=-1,z=function M(){for(;++N<P.length;)if(n.call(P,N))return M.value=P[N],M.done=!1,M;return M.value=void 0,M.done=!0,M};return z.next=z}}return{next:F}}function F(){return{value:void 0,done:!0}}return p.prototype=g,s(b,"constructor",g),s(g,"constructor",p),p.displayName=s(g,a,"GeneratorFunction"),e.isGeneratorFunction=function(P){var O=typeof P=="function"&&P.constructor;return!!O&&(O===p||(O.displayName||O.name)==="GeneratorFunction")},e.mark=function(P){return Object.setPrototypeOf?Object.setPrototypeOf(P,g):(P.__proto__=g,s(P,a,"GeneratorFunction")),P.prototype=Object.create(b),P},e.awrap=function(P){return{__await:P}},_(C.prototype),s(C.prototype,o,function(){return this}),e.AsyncIterator=C,e.async=function(P,O,N,z,M){M===void 0&&(M=Promise);var $=new C(u(P,O,N,z),M);return e.isGeneratorFunction(O)?$:$.next().then(function(I){return I.done?I.value:$.next()})},_(b),s(b,a,"Generator"),s(b,i,function(){return this}),s(b,"toString",function(){return"[object Generator]"}),e.keys=function(P){var O=[];for(var N in P)O.push(N);return O.reverse(),function z(){for(;O.length;){var M=O.pop();if(M in P)return z.value=M,z.done=!1,z}return z.done=!0,z}},e.values=L,A.prototype={constructor:A,reset:function(O){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!O)for(var N in this)N.charAt(0)==="t"&&n.call(this,N)&&!isNaN(+N.slice(1))&&(this[N]=void 0)},stop:function(){this.done=!0;var O=this.tryEntries[0].completion;if(O.type==="throw")throw O.arg;return this.rval},dispatchException:function(O){if(this.done)throw O;var N=this;function z(G,K){return I.type="throw",I.arg=O,N.next=G,K&&(N.method="next",N.arg=void 0),!!K}for(var M=this.tryEntries.length-1;M>=0;--M){var $=this.tryEntries[M],I=$.completion;if($.tryLoc==="root")return z("end");if($.tryLoc<=this.prev){var R=n.call($,"catchLoc"),B=n.call($,"finallyLoc");if(R&&B){if(this.prev<$.catchLoc)return z($.catchLoc,!0);if(this.prev<$.finallyLoc)return z($.finallyLoc)}else if(R){if(this.prev<$.catchLoc)return z($.catchLoc,!0)}else{if(!B)throw new Error("try statement without catch or finally");if(this.prev<$.finallyLoc)return z($.finallyLoc)}}}},abrupt:function(O,N){for(var z=this.tryEntries.length-1;z>=0;--z){var M=this.tryEntries[z];if(M.tryLoc<=this.prev&&n.call(M,"finallyLoc")&&this.prev<M.finallyLoc){var $=M;break}}$&&(O==="break"||O==="continue")&&$.tryLoc<=N&&N<=$.finallyLoc&&($=null);var I=$?$.completion:{};return I.type=O,I.arg=N,$?(this.method="next",this.next=$.finallyLoc,f):this.complete(I)},complete:function(O,N){if(O.type==="throw")throw O.arg;return O.type==="break"||O.type==="continue"?this.next=O.arg:O.type==="return"?(this.rval=this.arg=O.arg,this.method="return",this.next="end"):O.type==="normal"&&N&&(this.next=N),f},finish:function(O){for(var N=this.tryEntries.length-1;N>=0;--N){var z=this.tryEntries[N];if(z.finallyLoc===O)return this.complete(z.completion,z.afterLoc),k(z),f}},catch:function(O){for(var N=this.tryEntries.length-1;N>=0;--N){var z=this.tryEntries[N];if(z.tryLoc===O){var M=z.completion;if(M.type==="throw"){var $=M.arg;k(z)}return $}}throw new Error("illegal catch attempt")},delegateYield:function(O,N,z){return this.delegate={iterator:L(O),resultName:N,nextLoc:z},this.method==="next"&&(this.arg=void 0),f}},e}function Zp(e,t,n,r,i,o,a){try{var s=e[o](a),u=s.value}catch(c){n(c);return}s.done?t(u):Promise.resolve(u).then(r,i)}function ck(e){return function(){var t=this,n=arguments;return new Promise(function(r,i){var o=e.apply(t,n);function a(u){Zp(o,r,i,a,s,"next",u)}function s(u){Zp(o,r,i,a,s,"throw",u)}a(void 0)})}}var Jp=["measure","alignPre","align",null,"motion"];const dk=function(e,t){var n=fr(null),r=Mn(n,2),i=r[0],o=r[1],a=x.useRef();function s(f){o(f,!0)}function u(){Nt.cancel(a.current)}function c(f){u(),a.current=Nt(function(){s(function(h){switch(i){case"align":return"motion";case"motion":return"stable"}return h}),f==null||f()})}return x.useEffect(function(){s("measure")},[e]),x.useEffect(function(){switch(i){case"measure":t();break}i&&(a.current=Nt(ck(Tl().mark(function f(){var h,p;return Tl().wrap(function(v){for(;;)switch(v.prev=v.next){case 0:h=Jp.indexOf(i),p=Jp[h+1],p&&h!==-1&&s(p);case 3:case"end":return v.stop()}},f)}))))},[i]),x.useEffect(function(){return function(){u()}},[]),[i,c]},fk=function(e){var t=T.useState({width:0,height:0}),n=Mn(t,2),r=n[0],i=n[1];function o(s){var u=s.offsetWidth,c=s.offsetHeight,f=s.getBoundingClientRect(),h=f.width,p=f.height;Math.abs(u-h)<1&&Math.abs(c-p)<1&&(u=h,c=p),i({width:u,height:c})}var a=T.useMemo(function(){var s={};if(e){var u=r.width,c=r.height;e.indexOf("height")!==-1&&c?s.height=c:e.indexOf("minHeight")!==-1&&c&&(s.minHeight=c),e.indexOf("width")!==-1&&u?s.width=u:e.indexOf("minWidth")!==-1&&u&&(s.minWidth=u)}return s},[e,r]);return[a,o]};var eh=T.forwardRef(function(e,t){var n=e.visible,r=e.prefixCls,i=e.className,o=e.style,a=e.children,s=e.zIndex,u=e.stretch,c=e.destroyPopupOnHide,f=e.forceRender,h=e.align,p=e.point,g=e.getRootDomNode,v=e.getClassNameFromAlign,m=e.onAlign,w=e.onMouseEnter,b=e.onMouseLeave,_=e.onMouseDown,C=e.onTouchStart,S=e.onClick,E=x.useRef(),k=x.useRef(),A=x.useState(),L=Mn(A,2),F=L[0],P=L[1],O=fk(u),N=Mn(O,2),z=N[0],M=N[1];function $(){u&&M(g())}var I=dk(n,$),R=Mn(I,2),B=R[0],G=R[1],K=x.useState(0),W=Mn(K,2),ee=W[0],ne=W[1],U=x.useRef();Yn(function(){B==="alignPre"&&ne(0)},[B]);function X(){return p||g}function ce(){var re;(re=E.current)===null||re===void 0||re.forceAlign()}function ue(re,Se){var q=v(Se);F!==q&&P(q),ne(function(we){return we+1}),B==="align"&&(m==null||m(re,Se))}Yn(function(){B==="align"&&(ee<3?ce():G(function(){var re;(re=U.current)===null||re===void 0||re.call(U)}))},[ee]);var se=en({},Vf(e));["onAppearEnd","onEnterEnd","onLeaveEnd"].forEach(function(re){var Se=se[re];se[re]=function(q,we){return G(),Se==null?void 0:Se(q,we)}});function ae(){return new Promise(function(re){U.current=re})}T.useEffect(function(){!se.motionName&&B==="motion"&&G()},[se.motionName,B]),T.useImperativeHandle(t,function(){return{forceAlign:ce,getElement:function(){return k.current}}});var xe=en(en({},z),{},{zIndex:s,opacity:B==="motion"||B==="stable"||!n?void 0:0,pointerEvents:!n&&B!=="stable"?"none":void 0},o),be=!0;h!=null&&h.points&&(B==="align"||B==="stable")&&(be=!1);var Y=a;return T.Children.count(a)>1&&(Y=l("div",{className:"".concat(r,"-content"),children:a})),l(na,{visible:n,ref:k,leavedClassName:"".concat(r,"-hidden"),...se,onAppearPrepare:ae,onEnterPrepare:ae,removeOnLeave:c,forceRender:f,children:function(re,Se){var q=re.className,we=re.style,ve=pt(r,i,F,q);return l(Qp,{target:X(),ref:E,monitorWindowResize:!0,disabled:be,align:h,onAlign:ue,children:l("div",{ref:Se,className:ve,onMouseEnter:w,onMouseLeave:b,onMouseDownCapture:_,onTouchStartCapture:C,onClick:S,style:en(en({},we),xe),children:Y})},"popup")}})});eh.displayName="PopupInner";var th=T.forwardRef(function(e,t){var n=e.prefixCls,r=e.visible,i=e.zIndex,o=e.children,a=e.mobile;a=a===void 0?{}:a;var s=a.popupClassName,u=a.popupStyle,c=a.popupMotion,f=c===void 0?{}:c,h=a.popupRender,p=e.onClick,g=T.useRef();T.useImperativeHandle(t,function(){return{forceAlign:function(){},getElement:function(){return g.current}}});var v=en({zIndex:i},u),m=o;return T.Children.count(o)>1&&(m=l("div",{className:"".concat(n,"-content"),children:o})),h&&(m=h(m)),l(na,{visible:r,ref:g,removeOnLeave:!0,...f,children:function(w,b){var _=w.className,C=w.style,S=pt(n,s,_);return l("div",{ref:b,className:S,onClick:p,style:en(en({},C),v),children:m})}})});th.displayName="MobilePopupInner";var pk=["visible","mobile"],nh=T.forwardRef(function(e,t){var n=e.visible,r=e.mobile,i=Rx(e,pk),o=x.useState(n),a=Mn(o,2),s=a[0],u=a[1],c=x.useState(!1),f=Mn(c,2),h=f[0],p=f[1],g=en(en({},i),{},{visible:s});x.useEffect(function(){u(n),n&&r&&p(Vd())},[n,r]);var v=h?l(th,{...g,mobile:r,ref:t}):l(eh,{...g,ref:t});return y("div",{children:[l(tS,{...g}),v]})});nh.displayName="Popup";var rh=T.createContext(null);function Ml(){}function hk(){return""}function gk(e){return e?e.ownerDocument:window.document}var vk=["onClick","onMouseDown","onTouchStart","onMouseEnter","onMouseLeave","onFocus","onBlur","onContextMenu"];function mk(e){var t=function(n){Sx(i,n);var r=Ex(i);function i(o){var a;wx(this,i),a=r.call(this,o),Ye(Ze(a),"popupRef",T.createRef()),Ye(Ze(a),"triggerRef",T.createRef()),Ye(Ze(a),"portalContainer",void 0),Ye(Ze(a),"attachId",void 0),Ye(Ze(a),"clickOutsideHandler",void 0),Ye(Ze(a),"touchOutsideHandler",void 0),Ye(Ze(a),"contextMenuOutsideHandler1",void 0),Ye(Ze(a),"contextMenuOutsideHandler2",void 0),Ye(Ze(a),"mouseDownTimeout",void 0),Ye(Ze(a),"focusTime",void 0),Ye(Ze(a),"preClickTime",void 0),Ye(Ze(a),"preTouchTime",void 0),Ye(Ze(a),"delayTimer",void 0),Ye(Ze(a),"hasPopupMouseDown",void 0),Ye(Ze(a),"onMouseEnter",function(u){var c=a.props.mouseEnterDelay;a.fireEvents("onMouseEnter",u),a.delaySetPopupVisible(!0,c,c?null:u)}),Ye(Ze(a),"onMouseMove",function(u){a.fireEvents("onMouseMove",u),a.setPoint(u)}),Ye(Ze(a),"onMouseLeave",function(u){a.fireEvents("onMouseLeave",u),a.delaySetPopupVisible(!1,a.props.mouseLeaveDelay)}),Ye(Ze(a),"onPopupMouseEnter",function(){a.clearDelayTimer()}),Ye(Ze(a),"onPopupMouseLeave",function(u){var c;u.relatedTarget&&!u.relatedTarget.setTimeout&&Xo((c=a.popupRef.current)===null||c===void 0?void 0:c.getElement(),u.relatedTarget)||a.delaySetPopupVisible(!1,a.props.mouseLeaveDelay)}),Ye(Ze(a),"onFocus",function(u){a.fireEvents("onFocus",u),a.clearDelayTimer(),a.isFocusToShow()&&(a.focusTime=Date.now(),a.delaySetPopupVisible(!0,a.props.focusDelay))}),Ye(Ze(a),"onMouseDown",function(u){a.fireEvents("onMouseDown",u),a.preClickTime=Date.now()}),Ye(Ze(a),"onTouchStart",function(u){a.fireEvents("onTouchStart",u),a.preTouchTime=Date.now()}),Ye(Ze(a),"onBlur",function(u){a.fireEvents("onBlur",u),a.clearDelayTimer(),a.isBlurToHide()&&a.delaySetPopupVisible(!1,a.props.blurDelay)}),Ye(Ze(a),"onContextMenu",function(u){u.preventDefault(),a.fireEvents("onContextMenu",u),a.setPopupVisible(!0,u)}),Ye(Ze(a),"onContextMenuClose",function(){a.isContextMenuToShow()&&a.close()}),Ye(Ze(a),"onClick",function(u){if(a.fireEvents("onClick",u),a.focusTime){var c;if(a.preClickTime&&a.preTouchTime?c=Math.min(a.preClickTime,a.preTouchTime):a.preClickTime?c=a.preClickTime:a.preTouchTime&&(c=a.preTouchTime),Math.abs(c-a.focusTime)<20)return;a.focusTime=0}a.preClickTime=0,a.preTouchTime=0,a.isClickToShow()&&(a.isClickToHide()||a.isBlurToHide())&&u&&u.preventDefault&&u.preventDefault();var f=!a.state.popupVisible;(a.isClickToHide()&&!f||f&&a.isClickToShow())&&a.setPopupVisible(!a.state.popupVisible,u)}),Ye(Ze(a),"onPopupMouseDown",function(){if(a.hasPopupMouseDown=!0,clearTimeout(a.mouseDownTimeout),a.mouseDownTimeout=window.setTimeout(function(){a.hasPopupMouseDown=!1},0),a.context){var u;(u=a.context).onPopupMouseDown.apply(u,arguments)}}),Ye(Ze(a),"onDocumentClick",function(u){if(!(a.props.mask&&!a.props.maskClosable)){var c=u.target,f=a.getRootDomNode(),h=a.getPopupDomNode();(!Xo(f,c)||a.isContextMenuOnly())&&!Xo(h,c)&&!a.hasPopupMouseDown&&a.close()}}),Ye(Ze(a),"getRootDomNode",function(){var u=a.props.getTriggerDOMNode;if(u)return u(a.triggerRef.current);try{var c=Ki(a.triggerRef.current);if(c)return c}catch{}return Ni.default.findDOMNode(Ze(a))}),Ye(Ze(a),"getPopupClassNameFromAlign",function(u){var c=[],f=a.props,h=f.popupPlacement,p=f.builtinPlacements,g=f.prefixCls,v=f.alignPoint,m=f.getPopupClassNameFromAlign;return h&&p&&c.push(Ox(p,g,u,v)),m&&c.push(m(u)),c.join(" ")}),Ye(Ze(a),"getComponent",function(){var u=a.props,c=u.prefixCls,f=u.destroyPopupOnHide,h=u.popupClassName,p=u.onPopupAlign,g=u.popupMotion,v=u.popupAnimation,m=u.popupTransitionName,w=u.popupStyle,b=u.mask,_=u.maskAnimation,C=u.maskTransitionName,S=u.maskMotion,E=u.zIndex,k=u.popup,A=u.stretch,L=u.alignPoint,F=u.mobile,P=u.forceRender,O=u.onPopupClick,N=a.state,z=N.popupVisible,M=N.point,$=a.getPopupAlign(),I={};return a.isMouseEnterToShow()&&(I.onMouseEnter=a.onPopupMouseEnter),a.isMouseLeaveToHide()&&(I.onMouseLeave=a.onPopupMouseLeave),I.onMouseDown=a.onPopupMouseDown,I.onTouchStart=a.onPopupMouseDown,l(nh,{prefixCls:c,destroyPopupOnHide:f,visible:z,point:L&&M,className:h,align:$,onAlign:p,animation:v,getClassNameFromAlign:a.getPopupClassNameFromAlign,...I,stretch:A,getRootDomNode:a.getRootDomNode,style:w,mask:b,zIndex:E,transitionName:m,maskAnimation:_,maskTransitionName:C,maskMotion:S,ref:a.popupRef,motion:g,mobile:F,forceRender:P,onClick:O,children:typeof k=="function"?k():k})}),Ye(Ze(a),"attachParent",function(u){Nt.cancel(a.attachId);var c=a.props,f=c.getPopupContainer,h=c.getDocument,p=a.getRootDomNode(),g;f?(p||f.length===0)&&(g=f(p)):g=h(a.getRootDomNode()).body,g?g.appendChild(u):a.attachId=Nt(function(){a.attachParent(u)})}),Ye(Ze(a),"getContainer",function(){if(!a.portalContainer){var u=a.props.getDocument,c=u(a.getRootDomNode()).createElement("div");c.style.position="absolute",c.style.top="0",c.style.left="0",c.style.width="100%",a.portalContainer=c}return a.attachParent(a.portalContainer),a.portalContainer}),Ye(Ze(a),"setPoint",function(u){var c=a.props.alignPoint;!c||!u||a.setState({point:{pageX:u.pageX,pageY:u.pageY}})}),Ye(Ze(a),"handlePortalUpdate",function(){a.state.prevPopupVisible!==a.state.popupVisible&&a.props.afterPopupVisibleChange(a.state.popupVisible)}),Ye(Ze(a),"triggerContextValue",{onPopupMouseDown:a.onPopupMouseDown});var s;return"popupVisible"in o?s=!!o.popupVisible:s=!!o.defaultPopupVisible,a.state={prevPopupVisible:s,popupVisible:s},vk.forEach(function(u){a["fire".concat(u)]=function(c){a.fireEvents(u,c)}}),a}return xx(i,[{key:"componentDidMount",value:function(){this.componentDidUpdate()}},{key:"componentDidUpdate",value:function(){var a=this.props,s=this.state;if(s.popupVisible){var u;!this.clickOutsideHandler&&(this.isClickToHide()||this.isContextMenuToShow())&&(u=a.getDocument(this.getRootDomNode()),this.clickOutsideHandler=qi(u,"mousedown",this.onDocumentClick)),this.touchOutsideHandler||(u=u||a.getDocument(this.getRootDomNode()),this.touchOutsideHandler=qi(u,"touchstart",this.onDocumentClick)),!this.contextMenuOutsideHandler1&&this.isContextMenuToShow()&&(u=u||a.getDocument(this.getRootDomNode()),this.contextMenuOutsideHandler1=qi(u,"scroll",this.onContextMenuClose)),!this.contextMenuOutsideHandler2&&this.isContextMenuToShow()&&(this.contextMenuOutsideHandler2=qi(window,"blur",this.onContextMenuClose));return}this.clearOutsideHandler()}},{key:"componentWillUnmount",value:function(){this.clearDelayTimer(),this.clearOutsideHandler(),clearTimeout(this.mouseDownTimeout),Nt.cancel(this.attachId)}},{key:"getPopupDomNode",value:function(){var a;return((a=this.popupRef.current)===null||a===void 0?void 0:a.getElement())||null}},{key:"getPopupAlign",value:function(){var a=this.props,s=a.popupPlacement,u=a.popupAlign,c=a.builtinPlacements;return s&&c?kx(c,s,u):u}},{key:"setPopupVisible",value:function(a,s){var u=this.props.alignPoint,c=this.state.popupVisible;this.clearDelayTimer(),c!==a&&("popupVisible"in this.props||this.setState({popupVisible:a,prevPopupVisible:c}),this.props.onPopupVisibleChange(a)),u&&s&&a&&this.setPoint(s)}},{key:"delaySetPopupVisible",value:function(a,s,u){var c=this,f=s*1e3;if(this.clearDelayTimer(),f){var h=u?{pageX:u.pageX,pageY:u.pageY}:null;this.delayTimer=window.setTimeout(function(){c.setPopupVisible(a,h),c.clearDelayTimer()},f)}else this.setPopupVisible(a,u)}},{key:"clearDelayTimer",value:function(){this.delayTimer&&(clearTimeout(this.delayTimer),this.delayTimer=null)}},{key:"clearOutsideHandler",value:function(){this.clickOutsideHandler&&(this.clickOutsideHandler.remove(),this.clickOutsideHandler=null),this.contextMenuOutsideHandler1&&(this.contextMenuOutsideHandler1.remove(),this.contextMenuOutsideHandler1=null),this.contextMenuOutsideHandler2&&(this.contextMenuOutsideHandler2.remove(),this.contextMenuOutsideHandler2=null),this.touchOutsideHandler&&(this.touchOutsideHandler.remove(),this.touchOutsideHandler=null)}},{key:"createTwoChains",value:function(a){var s=this.props.children.props,u=this.props;return s[a]&&u[a]?this["fire".concat(a)]:s[a]||u[a]}},{key:"isClickToShow",value:function(){var a=this.props,s=a.action,u=a.showAction;return s.indexOf("click")!==-1||u.indexOf("click")!==-1}},{key:"isContextMenuOnly",value:function(){var a=this.props.action;return a==="contextMenu"||a.length===1&&a[0]==="contextMenu"}},{key:"isContextMenuToShow",value:function(){var a=this.props,s=a.action,u=a.showAction;return s.indexOf("contextMenu")!==-1||u.indexOf("contextMenu")!==-1}},{key:"isClickToHide",value:function(){var a=this.props,s=a.action,u=a.hideAction;return s.indexOf("click")!==-1||u.indexOf("click")!==-1}},{key:"isMouseEnterToShow",value:function(){var a=this.props,s=a.action,u=a.showAction;return s.indexOf("hover")!==-1||u.indexOf("mouseEnter")!==-1}},{key:"isMouseLeaveToHide",value:function(){var a=this.props,s=a.action,u=a.hideAction;return s.indexOf("hover")!==-1||u.indexOf("mouseLeave")!==-1}},{key:"isFocusToShow",value:function(){var a=this.props,s=a.action,u=a.showAction;return s.indexOf("focus")!==-1||u.indexOf("focus")!==-1}},{key:"isBlurToHide",value:function(){var a=this.props,s=a.action,u=a.hideAction;return s.indexOf("focus")!==-1||u.indexOf("blur")!==-1}},{key:"forcePopupAlign",value:function(){if(this.state.popupVisible){var a;(a=this.popupRef.current)===null||a===void 0||a.forceAlign()}}},{key:"fireEvents",value:function(a,s){var u=this.props.children.props[a];u&&u(s);var c=this.props[a];c&&c(s)}},{key:"close",value:function(){this.setPopupVisible(!1)}},{key:"render",value:function(){var a=this.state.popupVisible,s=this.props,u=s.children,c=s.forceRender,f=s.alignPoint,h=s.className,p=s.autoDestroy,g=T.Children.only(u),v={key:"trigger"};this.isContextMenuToShow()?v.onContextMenu=this.onContextMenu:v.onContextMenu=this.createTwoChains("onContextMenu"),this.isClickToHide()||this.isClickToShow()?(v.onClick=this.onClick,v.onMouseDown=this.onMouseDown,v.onTouchStart=this.onTouchStart):(v.onClick=this.createTwoChains("onClick"),v.onMouseDown=this.createTwoChains("onMouseDown"),v.onTouchStart=this.createTwoChains("onTouchStart")),this.isMouseEnterToShow()?(v.onMouseEnter=this.onMouseEnter,f&&(v.onMouseMove=this.onMouseMove)):v.onMouseEnter=this.createTwoChains("onMouseEnter"),this.isMouseLeaveToHide()?v.onMouseLeave=this.onMouseLeave:v.onMouseLeave=this.createTwoChains("onMouseLeave"),this.isFocusToShow()||this.isBlurToHide()?(v.onFocus=this.onFocus,v.onBlur=this.onBlur):(v.onFocus=this.createTwoChains("onFocus"),v.onBlur=this.createTwoChains("onBlur"));var m=pt(g&&g.props&&g.props.className,h);m&&(v.className=m);var w=en({},v);Ks(g)&&(w.ref=Bi(this.triggerRef,g.ref));var b=T.cloneElement(g,w),_;return(a||this.popupRef.current||c)&&(_=l(e,{getContainer:this.getContainer,didUpdate:this.handlePortalUpdate,children:this.getComponent()},"portal")),!a&&p&&(_=null),y(rh.Provider,{value:this.triggerContextValue,children:[b,_]})}}],[{key:"getDerivedStateFromProps",value:function(a,s){var u=a.popupVisible,c={};return u!==void 0&&s.popupVisible!==u&&(c.popupVisible=u,c.prevPopupVisible=s.popupVisible),c}}]),i}(T.Component);return Ye(t,"contextType",rh),Ye(t,"defaultProps",{prefixCls:"rc-trigger-popup",getPopupClassNameFromAlign:hk,getDocument:gk,onPopupVisibleChange:Ml,afterPopupVisibleChange:Ml,onPopupAlign:Ml,popupClassName:"",mouseEnterDelay:0,mouseLeaveDelay:.1,focusDelay:0,blurDelay:.15,popupStyle:{},destroyPopupOnHide:!1,popupAlign:{},defaultPopupVisible:!1,mask:!1,maskClosable:!0,action:[],showAction:[],hideAction:[],autoDestroy:!1}),t}const yk=mk(Tx);var bk=["prefixCls","disabled","visible","children","popupElement","containerWidth","animation","transitionName","dropdownStyle","dropdownClassName","direction","placement","dropdownMatchSelectWidth","dropdownRender","dropdownAlign","getPopupContainer","empty","getTriggerDOMNode","onPopupVisibleChange","onPopupMouseEnter"],wk=function(t){var n=t===!0?0:1;return{bottomLeft:{points:["tl","bl"],offset:[0,4],overflow:{adjustX:n,adjustY:1}},bottomRight:{points:["tr","br"],offset:[0,4],overflow:{adjustX:n,adjustY:1}},topLeft:{points:["bl","tl"],offset:[0,-4],overflow:{adjustX:n,adjustY:1}},topRight:{points:["br","tr"],offset:[0,-4],overflow:{adjustX:n,adjustY:1}}}},xk=function(t,n){var r=t.prefixCls;t.disabled;var i=t.visible,o=t.children,a=t.popupElement,s=t.containerWidth,u=t.animation,c=t.transitionName,f=t.dropdownStyle,h=t.dropdownClassName,p=t.direction,g=p===void 0?"ltr":p,v=t.placement,m=t.dropdownMatchSelectWidth,w=t.dropdownRender,b=t.dropdownAlign,_=t.getPopupContainer,C=t.empty,S=t.getTriggerDOMNode,E=t.onPopupVisibleChange,k=t.onPopupMouseEnter,A=Yr(t,bk),L="".concat(r,"-dropdown"),F=a;w&&(F=w(a));var P=T.useMemo(function(){return wk(m)},[m]),O=u?"".concat(L,"-").concat(u):c,N=T.useRef(null);T.useImperativeHandle(n,function(){return{getPopupElement:function(){return N.current}}});var z=Pt({minWidth:s},f);return typeof m=="number"?z.width=m:m&&(z.width=s),l(yk,{...A,showAction:E?["click"]:[],hideAction:E?["click"]:[],popupPlacement:v||(g==="rtl"?"bottomRight":"bottomLeft"),builtinPlacements:P,prefixCls:L,popupTransitionName:O,popup:l("div",{ref:N,onMouseEnter:k,children:F}),popupAlign:b,popupVisible:i,getPopupContainer:_,popupClassName:pt(h,At({},"".concat(L,"-empty"),C)),popupStyle:z,getTriggerDOMNode:S,onPopupVisibleChange:E,children:o})},ih=T.forwardRef(xk);ih.displayName="SelectTrigger";function Sk(e){return Od(e)||Md(e)||Fs(e)||Dd()}function oh(e,t){var n=e.key,r;return"value"in e&&(r=e.value),n!=null?n:r!==void 0?r:"rc-index-key-".concat(t)}function ah(e,t){var n=e||{},r=n.label,i=n.value,o=n.options;return{label:r||(t?"children":"label"),value:i||"value",options:o||"options"}}function Ck(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.fieldNames,r=t.childrenAsData,i=[],o=ah(n,!1),a=o.label,s=o.value,u=o.options;function c(f,h){f.forEach(function(p){var g=p[a];if(h||!(u in p)){var v=p[s];i.push({key:oh(p,i.length),groupOption:h,data:p,label:g,value:v})}else{var m=g;m===void 0&&r&&(m=p.label),i.push({key:oh(p,i.length),group:!0,data:p,label:m}),c(p[u],!0)}})}return c(e,!1),i}function kl(e){var t=Pt({},e);return"props"in t||Object.defineProperty(t,"props",{get:function(){return it(!1,"Return type is option instead of Option instance. Please read value directly instead of reading from `props`."),t}}),t}function _k(e,t){if(!t||!t.length)return null;var n=!1;function r(o,a){var s=Sk(a),u=s[0],c=s.slice(1);if(!u)return[o];var f=o.split(u);return n=n||f.length>1,f.reduce(function(h,p){return[].concat(bn(h),bn(r(p,c)))},[]).filter(function(h){return h})}var i=r(e,t);return n?i:null}var Ek=["id","prefixCls","className","showSearch","tagRender","direction","omitDomProps","displayValues","onDisplayValuesChange","emptyOptions","notFoundContent","onClear","mode","disabled","loading","getInputElement","getRawInputElement","open","defaultOpen","onDropdownVisibleChange","activeValue","onActiveValueChange","activeDescendantId","searchValue","autoClearSearchValue","onSearch","onSearchSplit","tokenSeparators","allowClear","showArrow","inputIcon","clearIcon","OptionList","animation","transitionName","dropdownStyle","dropdownClassName","dropdownMatchSelectWidth","dropdownRender","dropdownAlign","placement","getPopupContainer","showAction","onFocus","onBlur","onKeyUp","onKeyDown","onMouseDown"],Tk=["value","onChange","removeIcon","placeholder","autoFocus","maxTagCount","maxTagTextLength","maxTagPlaceholder","choiceTransitionName","onInputKeyDown","onPopupScroll","tabIndex"];function ya(e){return e==="tags"||e==="multiple"}var Ol=T.forwardRef(function(e,t){var n,r,i=e.id,o=e.prefixCls,a=e.className,s=e.showSearch,u=e.tagRender,c=e.direction,f=e.omitDomProps,h=e.displayValues,p=e.onDisplayValuesChange,g=e.emptyOptions,v=e.notFoundContent,m=v===void 0?"Not Found":v,w=e.onClear,b=e.mode,_=e.disabled,C=e.loading,S=e.getInputElement,E=e.getRawInputElement,k=e.open,A=e.defaultOpen,L=e.onDropdownVisibleChange,F=e.activeValue,P=e.onActiveValueChange,O=e.activeDescendantId,N=e.searchValue,z=e.autoClearSearchValue,M=e.onSearch,$=e.onSearchSplit,I=e.tokenSeparators,R=e.allowClear,B=e.showArrow,G=e.inputIcon,K=e.clearIcon,W=e.OptionList,ee=e.animation,ne=e.transitionName,U=e.dropdownStyle,X=e.dropdownClassName,ce=e.dropdownMatchSelectWidth,ue=e.dropdownRender,se=e.dropdownAlign,ae=e.placement,xe=e.getPopupContainer,be=e.showAction,Y=be===void 0?[]:be,re=e.onFocus,Se=e.onBlur,q=e.onKeyUp,we=e.onKeyDown,ve=e.onMouseDown,_e=Yr(e,Ek),ke=ya(b),ge=(s!==void 0?s:ke)||b==="combobox",Ke=Pt({},_e);Tk.forEach(function(Ue){delete Ke[Ue]}),f==null||f.forEach(function(Ue){delete Ke[Ue]});var Pe=T.useState(!1),Xe=It(Pe,2),Ee=Xe[0],Fe=Xe[1];T.useEffect(function(){Fe(Vd())},[]);var Le=T.useRef(null),Ve=T.useRef(null),ct=T.useRef(null),at=T.useRef(null),We=T.useRef(null),st=sw(),Ce=It(st,3),Ie=Ce[0],et=Ce[1],Mt=Ce[2];T.useImperativeHandle(t,function(){var Ue,Be;return{focus:(Ue=at.current)===null||Ue===void 0?void 0:Ue.focus,blur:(Be=at.current)===null||Be===void 0?void 0:Be.blur,scrollTo:function(fn){var zt;return(zt=We.current)===null||zt===void 0?void 0:zt.scrollTo(fn)}}});var lt=T.useMemo(function(){var Ue;if(b!=="combobox")return N;var Be=(Ue=h[0])===null||Ue===void 0?void 0:Ue.value;return typeof Be=="string"||typeof Be=="number"?String(Be):""},[N,b,h]),kt=b==="combobox"&&typeof S=="function"&&S()||null,dt=typeof E=="function"&&E(),Gt=aw(Ve,dt==null||(n=dt.props)===null||n===void 0?void 0:n.ref),Ot=zi(void 0,{defaultValue:A,value:k}),bt=It(Ot,2),_t=bt[0],Ht=bt[1],vt=_t,cn=!m&&g;(_||cn&&vt&&b==="combobox")&&(vt=!1);var Vt=cn?!1:vt,ie=T.useCallback(function(Ue){var Be=Ue!==void 0?Ue:!vt;_||(Ht(Be),vt!==Be&&(L==null||L(Be)))},[_,vt,Ht,L]),pe=T.useMemo(function(){return(I||[]).some(function(Ue){return[`
71
71
  `,`\r
72
- `].includes(Ue)})},[I]),me=function(Be,on,fn){var zt=!0,mn=Be;P==null||P(null);var In=fn?null:_k(Be,I);return b!=="combobox"&&In&&(mn="",$==null||$(In),ie(!1),zt=!1),M&&lt!==mn&&M(mn,{source:on?"typing":"effect"}),zt},Ae=function(Be){!Be||!Be.trim()||M(Be,{source:"submit"})};T.useEffect(function(){!vt&&!ke&&b!=="combobox"&&me("",!1,!1)},[vt]),T.useEffect(function(){_t&&_&&Ht(!1),_&&et(!1)},[_]);var Qe=Kd(),ft=It(Qe,2),Wt=ft[0],qt=ft[1],dn=function(Be){var on=Wt(),fn=Be.which;if(fn===oe.ENTER&&(b!=="combobox"&&Be.preventDefault(),vt||ie(!0)),qt(!!lt),fn===oe.BACKSPACE&&!on&&ke&&!lt&&h.length){for(var zt=bn(h),mn=null,In=zt.length-1;In>=0;In-=1){var Io=zt[In];if(!Io.disabled){zt.splice(In,1),mn=Io;break}}mn&&p(zt,{type:"remove",values:[mn]})}for(var Mr=arguments.length,Ii=new Array(Mr>1?Mr-1:0),kr=1;kr<Mr;kr++)Ii[kr-1]=arguments[kr];if(vt&&We.current){var c0;(c0=We.current).onKeyDown.apply(c0,[Be].concat(Ii))}we==null||we.apply(void 0,[Be].concat(Ii))},xt=function(Be){for(var on=arguments.length,fn=new Array(on>1?on-1:0),zt=1;zt<on;zt++)fn[zt-1]=arguments[zt];if(vt&&We.current){var mn;(mn=We.current).onKeyUp.apply(mn,[Be].concat(fn))}q==null||q.apply(void 0,[Be].concat(fn))},V=function(Be){var on=h.filter(function(fn){return fn!==Be});p(on,{type:"remove",values:[Be]})},J=T.useRef(!1),Q=function(){et(!0),_||(re&&!J.current&&re.apply(void 0,arguments),Y.includes("focus")&&ie(!0)),J.current=!0},he=function(){et(!1,function(){J.current=!1,ie(!1)}),!_&&(lt&&(b==="tags"?M(lt,{source:"submit"}):b==="multiple"&&M("",{source:"blur"})),Se&&Se.apply(void 0,arguments))},ye=[];T.useEffect(function(){return function(){ye.forEach(function(Ue){return clearTimeout(Ue)}),ye.splice(0,ye.length)}},[]);var Te=function(Be){var on,fn=Be.target,zt=(on=ct.current)===null||on===void 0?void 0:on.getPopupElement();if(zt&&zt.contains(fn)){var mn=setTimeout(function(){var Ii=ye.indexOf(mn);if(Ii!==-1&&ye.splice(Ii,1),Mt(),!Ee&&!zt.contains(document.activeElement)){var kr;(kr=at.current)===null||kr===void 0||kr.focus()}});ye.push(mn)}for(var In=arguments.length,Io=new Array(In>1?In-1:0),Mr=1;Mr<In;Mr++)Io[Mr-1]=arguments[Mr];ve==null||ve.apply(void 0,[Be].concat(Io))},Ne=T.useState(null),De=It(Ne,2),Ge=De[0],ze=De[1],qe=T.useState({}),Ct=It(qe,2),rn=Ct[1];function vn(){rn({})}Yn(function(){if(Vt){var Ue,Be=Math.ceil((Ue=Le.current)===null||Ue===void 0?void 0:Ue.offsetWidth);Ge!==Be&&!Number.isNaN(Be)&&ze(Be)}},[Vt]);var Dt;dt&&(Dt=function(Be){ie(Be)}),lw(function(){var Ue;return[Le.current,(Ue=ct.current)===null||Ue===void 0?void 0:Ue.getPopupElement()]},Vt,ie,!!dt);var Gn=T.useMemo(function(){return Pt(Pt({},e),{},{notFoundContent:m,open:vt,triggerOpen:Vt,id:i,showSearch:ge,multiple:ke,toggleOpen:ie})},[e,m,Vt,vt,i,ge,ke,ie]),lr=B!==void 0?B:C||!ke&&b!=="combobox",an;lr&&(an=l(Uo,{className:pt("".concat(o,"-arrow"),At({},"".concat(o,"-arrow-loading"),C)),customizeIcon:G,customizeIconProps:{loading:C,searchValue:lt,open:vt,focused:Ie,showSearch:ge}}));var sn,l6=function(){var Be;w==null||w(),(Be=at.current)===null||Be===void 0||Be.focus(),p([],{type:"clear",values:h}),me("",!1,!1)};!_&&R&&(h.length||lt)&&!(b==="combobox"&&lt==="")&&(sn=l(Uo,{className:"".concat(o,"-clear"),onMouseDown:l6,customizeIcon:K,children:"\xD7"}));var u6=l(W,{ref:We}),c6=pt(o,a,(r={},At(r,"".concat(o,"-focused"),Ie),At(r,"".concat(o,"-multiple"),ke),At(r,"".concat(o,"-single"),!ke),At(r,"".concat(o,"-allow-clear"),R),At(r,"".concat(o,"-show-arrow"),lr),At(r,"".concat(o,"-disabled"),_),At(r,"".concat(o,"-loading"),C),At(r,"".concat(o,"-open"),vt),At(r,"".concat(o,"-customize-input"),kt),At(r,"".concat(o,"-show-search"),ge),r)),u0=l(ih,{ref:ct,disabled:_,prefixCls:o,visible:Vt,popupElement:u6,containerWidth:Ge,animation:ee,transitionName:ne,dropdownStyle:U,dropdownClassName:X,direction:c,dropdownMatchSelectWidth:ce,dropdownRender:ue,dropdownAlign:se,placement:ae,getPopupContainer:xe,empty:g,getTriggerDOMNode:function(){return Ve.current},onPopupVisibleChange:Dt,onPopupMouseEnter:vn,children:dt?T.cloneElement(dt,{ref:Gt}):l(bf,{...e,domRef:Ve,prefixCls:o,inputElement:kt,ref:at,id:i,showSearch:ge,autoClearSearchValue:z,mode:b,activeDescendantId:O,tagRender:u,values:h,open:vt,onToggleOpen:ie,activeValue:F,searchValue:lt,onSearch:me,onSearchSubmit:Ae,onRemove:V,tokenWithEnter:pe})}),ad;return dt?ad=u0:ad=y("div",{className:c6,...Ke,ref:Le,onMouseDown:Te,onKeyDown:dn,onKeyUp:xt,onFocus:Q,onBlur:he,children:[Ie&&!vt&&l("span",{style:{width:0,height:0,position:"absolute",overflow:"hidden",opacity:0},"aria-live":"polite",children:"".concat(h.map(function(Ue){var Be=Ue.label,on=Ue.value;return["number","string"].includes(Un(Be))?Be:on}).join(", "))}),u0,an,sn]}),l(jd.Provider,{value:Gn,children:ad})});process.env.NODE_ENV!=="production"&&(Ol.displayName="BaseSelect");const Mk=function(e,t){var n=T.useRef({values:new Map,options:new Map}),r=T.useMemo(function(){var o=n.current,a=o.values,s=o.options,u=e.map(function(h){if(h.label===void 0){var p;return Pt(Pt({},h),{},{label:(p=a.get(h.value))===null||p===void 0?void 0:p.label})}return h}),c=new Map,f=new Map;return u.forEach(function(h){c.set(h.value,h),f.set(h.value,t.get(h.value)||s.get(h.value))}),n.current.values=c,n.current.options=f,u},[e,t]),i=T.useCallback(function(o){return t.get(o)||n.current.options.get(o)},[t]);return[r,i]};function Dl(e,t){return Xs(e).join("").toUpperCase().includes(t)}const kk=function(e,t,n,r,i){return T.useMemo(function(){if(!n||r===!1)return e;var o=t.options,a=t.label,s=t.value,u=[],c=typeof r=="function",f=n.toUpperCase(),h=c?r:function(g,v){return i?Dl(v[i],f):v[o]?Dl(v[a!=="children"?a:"label"],f):Dl(v[s],f)},p=c?function(g){return kl(g)}:function(g){return g};return e.forEach(function(g){if(g[o]){var v=h(n,p(g));if(v)u.push(g);else{var m=g[o].filter(function(w){return h(n,p(w))});m.length&&u.push(Pt(Pt({},g),{},At({},o,m)))}return}h(n,p(g))&&u.push(g)}),u},[e,r,i,n,t])};var sh=0,Ok=process.env.NODE_ENV!=="test"&&Xr();function Dk(){var e;return Ok?(e=sh,sh+=1):e="TEST_OR_SSR",e}function lh(e){var t=T.useState(),n=It(t,2),r=n[0],i=n[1];return T.useEffect(function(){i("rc_select_".concat(Dk()))},[]),e||r}var Rk=["children","value"],Ak=["children"];function Pk(e){var t=e,n=t.key,r=t.props,i=r.children,o=r.value,a=Yr(r,Rk);return Pt({key:n,value:o!==void 0?o:n,children:i},a)}function Rl(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return pr(e).map(function(n,r){if(!T.isValidElement(n)||!n.type)return null;var i=n,o=i.type.isSelectOptGroup,a=i.key,s=i.props,u=s.children,c=Yr(s,Ak);return t||!o?Pk(n):Pt(Pt({key:"__RC_SELECT_GRP__".concat(a===null?r:a,"__"),label:a},c),{},{options:Rl(u)})}).filter(function(n){return n})}function Ik(e,t,n,r,i){return T.useMemo(function(){var o=e,a=!e;a&&(o=Rl(t));var s=new Map,u=new Map,c=function(p,g,v){v&&typeof v=="string"&&p.set(g[v],g)};function f(h){for(var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,g=0;g<h.length;g+=1){var v=h[g];!v[n.options]||p?(s.set(v[n.value],v),c(u,v,n.label),c(u,v,r),c(u,v,i)):f(v[n.options],!0)}}return f(o),{options:o,valueOptions:s,labelOptions:u}},[e,t,n,r,i])}function uh(e){var t=T.useRef();t.current=e;var n=T.useCallback(function(){return t.current.apply(t,arguments)},[]);return n}var ch=function(){return null};ch.isSelectOptGroup=!0;var dh=function(){return null};dh.isSelectOption=!0;function fh(e,t){var n=en({},e);return Array.isArray(t)&&t.forEach(function(r){delete n[r]}),n}function vr(e){return vr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vr(e)}function Nk(e,t){if(vr(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(vr(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ph(e){var t=Nk(e,"string");return vr(t)==="symbol"?t:String(t)}function Ji(e,t,n){return t=ph(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function hh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function eo(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hh(Object(n),!0).forEach(function(r){Ji(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hh(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function $k(e){if(Array.isArray(e))return e}function Lk(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(f){c=!0,i=f}finally{try{if(!u&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}function gh(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Vk(e,t){if(!!e){if(typeof e=="string")return gh(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return gh(e,t)}}function zk(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
72
+ `].includes(Ue)})},[I]),me=function(Be,on,fn){var zt=!0,mn=Be;P==null||P(null);var In=fn?null:_k(Be,I);return b!=="combobox"&&In&&(mn="",$==null||$(In),ie(!1),zt=!1),M&&lt!==mn&&M(mn,{source:on?"typing":"effect"}),zt},Ae=function(Be){!Be||!Be.trim()||M(Be,{source:"submit"})};T.useEffect(function(){!vt&&!ke&&b!=="combobox"&&me("",!1,!1)},[vt]),T.useEffect(function(){_t&&_&&Ht(!1),_&&et(!1)},[_]);var Qe=Kd(),ft=It(Qe,2),Wt=ft[0],qt=ft[1],dn=function(Be){var on=Wt(),fn=Be.which;if(fn===oe.ENTER&&(b!=="combobox"&&Be.preventDefault(),vt||ie(!0)),qt(!!lt),fn===oe.BACKSPACE&&!on&&ke&&!lt&&h.length){for(var zt=bn(h),mn=null,In=zt.length-1;In>=0;In-=1){var Io=zt[In];if(!Io.disabled){zt.splice(In,1),mn=Io;break}}mn&&p(zt,{type:"remove",values:[mn]})}for(var Mr=arguments.length,Ii=new Array(Mr>1?Mr-1:0),kr=1;kr<Mr;kr++)Ii[kr-1]=arguments[kr];if(vt&&We.current){var c0;(c0=We.current).onKeyDown.apply(c0,[Be].concat(Ii))}we==null||we.apply(void 0,[Be].concat(Ii))},xt=function(Be){for(var on=arguments.length,fn=new Array(on>1?on-1:0),zt=1;zt<on;zt++)fn[zt-1]=arguments[zt];if(vt&&We.current){var mn;(mn=We.current).onKeyUp.apply(mn,[Be].concat(fn))}q==null||q.apply(void 0,[Be].concat(fn))},V=function(Be){var on=h.filter(function(fn){return fn!==Be});p(on,{type:"remove",values:[Be]})},J=T.useRef(!1),Q=function(){et(!0),_||(re&&!J.current&&re.apply(void 0,arguments),Y.includes("focus")&&ie(!0)),J.current=!0},he=function(){et(!1,function(){J.current=!1,ie(!1)}),!_&&(lt&&(b==="tags"?M(lt,{source:"submit"}):b==="multiple"&&M("",{source:"blur"})),Se&&Se.apply(void 0,arguments))},ye=[];T.useEffect(function(){return function(){ye.forEach(function(Ue){return clearTimeout(Ue)}),ye.splice(0,ye.length)}},[]);var Te=function(Be){var on,fn=Be.target,zt=(on=ct.current)===null||on===void 0?void 0:on.getPopupElement();if(zt&&zt.contains(fn)){var mn=setTimeout(function(){var Ii=ye.indexOf(mn);if(Ii!==-1&&ye.splice(Ii,1),Mt(),!Ee&&!zt.contains(document.activeElement)){var kr;(kr=at.current)===null||kr===void 0||kr.focus()}});ye.push(mn)}for(var In=arguments.length,Io=new Array(In>1?In-1:0),Mr=1;Mr<In;Mr++)Io[Mr-1]=arguments[Mr];ve==null||ve.apply(void 0,[Be].concat(Io))},Ne=T.useState(null),De=It(Ne,2),Ge=De[0],ze=De[1],qe=T.useState({}),Ct=It(qe,2),rn=Ct[1];function vn(){rn({})}Yn(function(){if(Vt){var Ue,Be=Math.ceil((Ue=Le.current)===null||Ue===void 0?void 0:Ue.offsetWidth);Ge!==Be&&!Number.isNaN(Be)&&ze(Be)}},[Vt]);var Dt;dt&&(Dt=function(Be){ie(Be)}),lw(function(){var Ue;return[Le.current,(Ue=ct.current)===null||Ue===void 0?void 0:Ue.getPopupElement()]},Vt,ie,!!dt);var Gn=T.useMemo(function(){return Pt(Pt({},e),{},{notFoundContent:m,open:vt,triggerOpen:Vt,id:i,showSearch:ge,multiple:ke,toggleOpen:ie})},[e,m,Vt,vt,i,ge,ke,ie]),lr=B!==void 0?B:C||!ke&&b!=="combobox",an;lr&&(an=l(Uo,{className:pt("".concat(o,"-arrow"),At({},"".concat(o,"-arrow-loading"),C)),customizeIcon:G,customizeIconProps:{loading:C,searchValue:lt,open:vt,focused:Ie,showSearch:ge}}));var sn,u6=function(){var Be;w==null||w(),(Be=at.current)===null||Be===void 0||Be.focus(),p([],{type:"clear",values:h}),me("",!1,!1)};!_&&R&&(h.length||lt)&&!(b==="combobox"&&lt==="")&&(sn=l(Uo,{className:"".concat(o,"-clear"),onMouseDown:u6,customizeIcon:K,children:"\xD7"}));var c6=l(W,{ref:We}),d6=pt(o,a,(r={},At(r,"".concat(o,"-focused"),Ie),At(r,"".concat(o,"-multiple"),ke),At(r,"".concat(o,"-single"),!ke),At(r,"".concat(o,"-allow-clear"),R),At(r,"".concat(o,"-show-arrow"),lr),At(r,"".concat(o,"-disabled"),_),At(r,"".concat(o,"-loading"),C),At(r,"".concat(o,"-open"),vt),At(r,"".concat(o,"-customize-input"),kt),At(r,"".concat(o,"-show-search"),ge),r)),u0=l(ih,{ref:ct,disabled:_,prefixCls:o,visible:Vt,popupElement:c6,containerWidth:Ge,animation:ee,transitionName:ne,dropdownStyle:U,dropdownClassName:X,direction:c,dropdownMatchSelectWidth:ce,dropdownRender:ue,dropdownAlign:se,placement:ae,getPopupContainer:xe,empty:g,getTriggerDOMNode:function(){return Ve.current},onPopupVisibleChange:Dt,onPopupMouseEnter:vn,children:dt?T.cloneElement(dt,{ref:Gt}):l(bf,{...e,domRef:Ve,prefixCls:o,inputElement:kt,ref:at,id:i,showSearch:ge,autoClearSearchValue:z,mode:b,activeDescendantId:O,tagRender:u,values:h,open:vt,onToggleOpen:ie,activeValue:F,searchValue:lt,onSearch:me,onSearchSubmit:Ae,onRemove:V,tokenWithEnter:pe})}),ad;return dt?ad=u0:ad=y("div",{className:d6,...Ke,ref:Le,onMouseDown:Te,onKeyDown:dn,onKeyUp:xt,onFocus:Q,onBlur:he,children:[Ie&&!vt&&l("span",{style:{width:0,height:0,position:"absolute",overflow:"hidden",opacity:0},"aria-live":"polite",children:"".concat(h.map(function(Ue){var Be=Ue.label,on=Ue.value;return["number","string"].includes(Un(Be))?Be:on}).join(", "))}),u0,an,sn]}),l(jd.Provider,{value:Gn,children:ad})});process.env.NODE_ENV!=="production"&&(Ol.displayName="BaseSelect");const Mk=function(e,t){var n=T.useRef({values:new Map,options:new Map}),r=T.useMemo(function(){var o=n.current,a=o.values,s=o.options,u=e.map(function(h){if(h.label===void 0){var p;return Pt(Pt({},h),{},{label:(p=a.get(h.value))===null||p===void 0?void 0:p.label})}return h}),c=new Map,f=new Map;return u.forEach(function(h){c.set(h.value,h),f.set(h.value,t.get(h.value)||s.get(h.value))}),n.current.values=c,n.current.options=f,u},[e,t]),i=T.useCallback(function(o){return t.get(o)||n.current.options.get(o)},[t]);return[r,i]};function Dl(e,t){return Xs(e).join("").toUpperCase().includes(t)}const kk=function(e,t,n,r,i){return T.useMemo(function(){if(!n||r===!1)return e;var o=t.options,a=t.label,s=t.value,u=[],c=typeof r=="function",f=n.toUpperCase(),h=c?r:function(g,v){return i?Dl(v[i],f):v[o]?Dl(v[a!=="children"?a:"label"],f):Dl(v[s],f)},p=c?function(g){return kl(g)}:function(g){return g};return e.forEach(function(g){if(g[o]){var v=h(n,p(g));if(v)u.push(g);else{var m=g[o].filter(function(w){return h(n,p(w))});m.length&&u.push(Pt(Pt({},g),{},At({},o,m)))}return}h(n,p(g))&&u.push(g)}),u},[e,r,i,n,t])};var sh=0,Ok=process.env.NODE_ENV!=="test"&&Xr();function Dk(){var e;return Ok?(e=sh,sh+=1):e="TEST_OR_SSR",e}function lh(e){var t=T.useState(),n=It(t,2),r=n[0],i=n[1];return T.useEffect(function(){i("rc_select_".concat(Dk()))},[]),e||r}var Rk=["children","value"],Ak=["children"];function Pk(e){var t=e,n=t.key,r=t.props,i=r.children,o=r.value,a=Yr(r,Rk);return Pt({key:n,value:o!==void 0?o:n,children:i},a)}function Rl(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return pr(e).map(function(n,r){if(!T.isValidElement(n)||!n.type)return null;var i=n,o=i.type.isSelectOptGroup,a=i.key,s=i.props,u=s.children,c=Yr(s,Ak);return t||!o?Pk(n):Pt(Pt({key:"__RC_SELECT_GRP__".concat(a===null?r:a,"__"),label:a},c),{},{options:Rl(u)})}).filter(function(n){return n})}function Ik(e,t,n,r,i){return T.useMemo(function(){var o=e,a=!e;a&&(o=Rl(t));var s=new Map,u=new Map,c=function(p,g,v){v&&typeof v=="string"&&p.set(g[v],g)};function f(h){for(var p=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,g=0;g<h.length;g+=1){var v=h[g];!v[n.options]||p?(s.set(v[n.value],v),c(u,v,n.label),c(u,v,r),c(u,v,i)):f(v[n.options],!0)}}return f(o),{options:o,valueOptions:s,labelOptions:u}},[e,t,n,r,i])}function uh(e){var t=T.useRef();t.current=e;var n=T.useCallback(function(){return t.current.apply(t,arguments)},[]);return n}var ch=function(){return null};ch.isSelectOptGroup=!0;var dh=function(){return null};dh.isSelectOption=!0;function fh(e,t){var n=en({},e);return Array.isArray(t)&&t.forEach(function(r){delete n[r]}),n}function vr(e){return vr=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},vr(e)}function Nk(e,t){if(vr(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(vr(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ph(e){var t=Nk(e,"string");return vr(t)==="symbol"?t:String(t)}function Ji(e,t,n){return t=ph(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function hh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function eo(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?hh(Object(n),!0).forEach(function(r){Ji(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hh(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function $k(e){if(Array.isArray(e))return e}function Lk(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(f){c=!0,i=f}finally{try{if(!u&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}function gh(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function Vk(e,t){if(!!e){if(typeof e=="string")return gh(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return gh(e,t)}}function zk(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
73
73
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function mr(e,t){return $k(e)||Lk(e,t)||Vk(e,t)||zk()}function Fk(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o<r.length;o++)i=r[o],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Bk(e,t){if(e==null)return{};var n=Fk(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&(!Object.prototype.propertyIsEnumerable.call(e,r)||(n[r]=e[r]))}return n}var vh=T.forwardRef(function(e,t){var n=e.height,r=e.offset,i=e.children,o=e.prefixCls,a=e.onInnerResize,s={},u={display:"flex",flexDirection:"column"};return r!==void 0&&(s={height:n,position:"relative",overflow:"hidden"},u=eo(eo({},u),{},{transform:"translateY(".concat(r,"px)"),position:"absolute",left:0,right:0,top:0})),l("div",{style:s,children:l(Wo,{onResize:function(f){var h=f.offsetHeight;h&&a&&a()},children:l("div",{style:u,className:pt(Ji({},"".concat(o,"-holder-inner"),o)),ref:t,children:i})})})});vh.displayName="Filler";function mh(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function yh(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,ph(r.key),r)}}function bh(e,t,n){return t&&yh(e.prototype,t),n&&yh(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function Al(e,t){return Al=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},Al(e,t)}function jk(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Al(e,t)}function ba(e){return ba=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},ba(e)}function Gk(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function Kk(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Hk(e,t){if(t&&(vr(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return Kk(e)}function Wk(e){var t=Gk();return function(){var r=ba(e),i;if(t){var o=ba(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return Hk(this,i)}}var qk=20;function wh(e){return"touches"in e?e.touches[0].pageY:e.pageY}var Uk=function(e){jk(n,e);var t=Wk(n);function n(){var r;mh(this,n);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return r=t.call.apply(t,[this].concat(o)),r.moveRaf=null,r.scrollbarRef=T.createRef(),r.thumbRef=T.createRef(),r.visibleTimeout=null,r.state={dragging:!1,pageY:null,startTop:null,visible:!1},r.delayHidden=function(){clearTimeout(r.visibleTimeout),r.setState({visible:!0}),r.visibleTimeout=setTimeout(function(){r.setState({visible:!1})},2e3)},r.onScrollbarTouchStart=function(s){s.preventDefault()},r.onContainerMouseDown=function(s){s.stopPropagation(),s.preventDefault()},r.patchEvents=function(){window.addEventListener("mousemove",r.onMouseMove),window.addEventListener("mouseup",r.onMouseUp),r.thumbRef.current.addEventListener("touchmove",r.onMouseMove),r.thumbRef.current.addEventListener("touchend",r.onMouseUp)},r.removeEvents=function(){var s;window.removeEventListener("mousemove",r.onMouseMove),window.removeEventListener("mouseup",r.onMouseUp),(s=r.scrollbarRef.current)===null||s===void 0||s.removeEventListener("touchstart",r.onScrollbarTouchStart),r.thumbRef.current&&(r.thumbRef.current.removeEventListener("touchstart",r.onMouseDown),r.thumbRef.current.removeEventListener("touchmove",r.onMouseMove),r.thumbRef.current.removeEventListener("touchend",r.onMouseUp)),Nt.cancel(r.moveRaf)},r.onMouseDown=function(s){var u=r.props.onStartMove;r.setState({dragging:!0,pageY:wh(s),startTop:r.getTop()}),u(),r.patchEvents(),s.stopPropagation(),s.preventDefault()},r.onMouseMove=function(s){var u=r.state,c=u.dragging,f=u.pageY,h=u.startTop,p=r.props.onScroll;if(Nt.cancel(r.moveRaf),c){var g=wh(s)-f,v=h+g,m=r.getEnableScrollRange(),w=r.getEnableHeightRange(),b=w?v/w:0,_=Math.ceil(b*m);r.moveRaf=Nt(function(){p(_)})}},r.onMouseUp=function(){var s=r.props.onStopMove;r.setState({dragging:!1}),s(),r.removeEvents()},r.getSpinHeight=function(){var s=r.props,u=s.height,c=s.count,f=u/c*10;return f=Math.max(f,qk),f=Math.min(f,u/2),Math.floor(f)},r.getEnableScrollRange=function(){var s=r.props,u=s.scrollHeight,c=s.height;return u-c||0},r.getEnableHeightRange=function(){var s=r.props.height,u=r.getSpinHeight();return s-u||0},r.getTop=function(){var s=r.props.scrollTop,u=r.getEnableScrollRange(),c=r.getEnableHeightRange();if(s===0||u===0)return 0;var f=s/u;return f*c},r.showScroll=function(){var s=r.props,u=s.height,c=s.scrollHeight;return c>u},r}return bh(n,[{key:"componentDidMount",value:function(){this.scrollbarRef.current.addEventListener("touchstart",this.onScrollbarTouchStart),this.thumbRef.current.addEventListener("touchstart",this.onMouseDown)}},{key:"componentDidUpdate",value:function(i){i.scrollTop!==this.props.scrollTop&&this.delayHidden()}},{key:"componentWillUnmount",value:function(){this.removeEvents(),clearTimeout(this.visibleTimeout)}},{key:"render",value:function(){var i=this.state,o=i.dragging,a=i.visible,s=this.props.prefixCls,u=this.getSpinHeight(),c=this.getTop(),f=this.showScroll(),h=f&&a;return l("div",{ref:this.scrollbarRef,className:pt("".concat(s,"-scrollbar"),Ji({},"".concat(s,"-scrollbar-show"),f)),style:{width:8,top:0,bottom:0,right:0,position:"absolute",display:h?null:"none"},onMouseDown:this.onContainerMouseDown,onMouseMove:this.delayHidden,children:l("div",{ref:this.thumbRef,className:pt("".concat(s,"-scrollbar-thumb"),Ji({},"".concat(s,"-scrollbar-thumb-moving"),o)),style:{width:"100%",height:u,top:c,left:0,position:"absolute",background:"rgba(0, 0, 0, 0.5)",borderRadius:99,cursor:"pointer",userSelect:"none"},onMouseDown:this.onMouseDown})})}}]),n}(T.Component);function Yk(e){var t=e.children,n=e.setRef,r=T.useCallback(function(i){n(i)},[]);return T.cloneElement(t,{ref:r})}function Xk(e,t,n,r,i,o){var a=o.getKey;return e.slice(t,n+1).map(function(s,u){var c=t+u,f=i(s,c,{}),h=a(s);return l(Yk,{setRef:function(g){return r(s,g)},children:f},h)})}var Qk=function(){function e(){mh(this,e),this.maps=void 0,this.maps=Object.create(null)}return bh(e,[{key:"set",value:function(n,r){this.maps[n]=r}},{key:"get",value:function(n){return this.maps[n]}}]),e}();function Zk(e,t,n){var r=T.useState(0),i=mr(r,2),o=i[0],a=i[1],s=x.useRef(new Map),u=x.useRef(new Qk),c=x.useRef();function f(){Nt.cancel(c.current)}function h(){f(),c.current=Nt(function(){s.current.forEach(function(g,v){if(g&&g.offsetParent){var m=Ki(g),w=m.offsetHeight;u.current.get(v)!==w&&u.current.set(v,m.offsetHeight)}}),a(function(g){return g+1})})}function p(g,v){var m=e(g),w=s.current.get(m);v?(s.current.set(m,v),h()):s.current.delete(m),!w!=!v&&(v?t==null||t(g):n==null||n(g))}return x.useEffect(function(){return f},[]),[p,h,u.current,o]}function Jk(e,t,n,r,i,o,a,s){var u=T.useRef();return function(c){if(c==null){s();return}if(Nt.cancel(u.current),typeof c=="number")a(c);else if(c&&vr(c)==="object"){var f,h=c.align;"index"in c?f=c.index:f=t.findIndex(function(m){return i(m)===c.key});var p=c.offset,g=p===void 0?0:p,v=function m(w,b){if(!(w<0||!e.current)){var _=e.current.clientHeight,C=!1,S=b;if(_){for(var E=b||h,k=0,A=0,L=0,F=Math.min(t.length,f),P=0;P<=F;P+=1){var O=i(t[P]);A=k;var N=n.get(O);L=A+(N===void 0?r:N),k=L,P===f&&N===void 0&&(C=!0)}var z=null;switch(E){case"top":z=A-g;break;case"bottom":z=L-_+g;break;default:{var M=e.current.scrollTop,$=M+_;A<M?S="top":L>$&&(S="bottom")}}z!==null&&z!==e.current.scrollTop&&a(z)}u.current=Nt(function(){C&&o(),m(w-1,S)})}};v(3)}}}function eO(e,t,n){var r=e.length,i=t.length,o,a;if(r===0&&i===0)return null;r<i?(o=e,a=t):(o=t,a=e);var s={__EMPTY_ITEM__:!0};function u(v){return v!==void 0?n(v):s}for(var c=null,f=Math.abs(r-i)!==1,h=0;h<a.length;h+=1){var p=u(o[h]),g=u(a[h]);if(p!==g){c=h,f=f||p!==u(a[h+1]);break}}return c===null?null:{index:c,multiple:f}}function tO(e,t,n){var r=T.useState(e),i=mr(r,2),o=i[0],a=i[1],s=T.useState(null),u=mr(s,2),c=u[0],f=u[1];return T.useEffect(function(){var h=eO(o||[],e||[],t);(h==null?void 0:h.index)!==void 0&&(n==null||n(h.index),f(e[h.index])),a(e)},[e]),[c]}var nO=(typeof navigator>"u"?"undefined":vr(navigator))==="object"&&/Firefox/i.test(navigator.userAgent);const xh=function(e,t){var n=x.useRef(!1),r=x.useRef(null);function i(){clearTimeout(r.current),n.current=!0,r.current=setTimeout(function(){n.current=!1},50)}var o=x.useRef({top:e,bottom:t});return o.current.top=e,o.current.bottom=t,function(a){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,u=a<0&&o.current.top||a>0&&o.current.bottom;return s&&u?(clearTimeout(r.current),n.current=!1):(!u||n.current)&&i(),!n.current&&u}};function rO(e,t,n,r){var i=x.useRef(0),o=x.useRef(null),a=x.useRef(null),s=x.useRef(!1),u=xh(t,n);function c(h){if(!!e){Nt.cancel(o.current);var p=h.deltaY;i.current+=p,a.current=p,!u(p)&&(nO||h.preventDefault(),o.current=Nt(function(){var g=s.current?10:1;r(i.current*g),i.current=0}))}}function f(h){!e||(s.current=h.detail===a.current)}return[c,f]}var iO=14/15;function oO(e,t,n){var r=x.useRef(!1),i=x.useRef(0),o=x.useRef(null),a=x.useRef(null),s,u=function(p){if(r.current){var g=Math.ceil(p.touches[0].pageY),v=i.current-g;i.current=g,n(v)&&p.preventDefault(),clearInterval(a.current),a.current=setInterval(function(){v*=iO,(!n(v,!0)||Math.abs(v)<=.1)&&clearInterval(a.current)},16)}},c=function(){r.current=!1,s()},f=function(p){s(),p.touches.length===1&&!r.current&&(r.current=!0,i.current=Math.ceil(p.touches[0].pageY),o.current=p.target,o.current.addEventListener("touchmove",u),o.current.addEventListener("touchend",c))};s=function(){o.current&&(o.current.removeEventListener("touchmove",u),o.current.removeEventListener("touchend",c))},Yn(function(){return e&&t.current.addEventListener("touchstart",f),function(){var h;(h=t.current)===null||h===void 0||h.removeEventListener("touchstart",f),s(),clearInterval(a.current)}},[e])}var aO=["prefixCls","className","height","itemHeight","fullHeight","style","data","children","itemKey","virtual","component","onScroll","onVisibleChange"],sO=[],lO={overflowY:"auto",overflowAnchor:"none"};function uO(e,t){var n=e.prefixCls,r=n===void 0?"rc-virtual-list":n,i=e.className,o=e.height,a=e.itemHeight,s=e.fullHeight,u=s===void 0?!0:s,c=e.style,f=e.data,h=e.children,p=e.itemKey,g=e.virtual,v=e.component,m=v===void 0?"div":v,w=e.onScroll,b=e.onVisibleChange,_=Bk(e,aO),C=!!(g!==!1&&o&&a),S=C&&f&&a*f.length>o,E=x.useState(0),k=mr(E,2),A=k[0],L=k[1],F=x.useState(!1),P=mr(F,2),O=P[0],N=P[1],z=pt(r,i),M=f||sO,$=x.useRef(),I=x.useRef(),R=x.useRef(),B=T.useCallback(function(Ce){return typeof p=="function"?p(Ce):Ce==null?void 0:Ce[p]},[p]),G={getKey:B};function K(Ce){L(function(Ie){var et;typeof Ce=="function"?et=Ce(Ie):et=Ce;var Mt=ke(et);return $.current.scrollTop=Mt,Mt})}var W=x.useRef({start:0,end:M.length}),ee=x.useRef(),ne=tO(M,B),U=mr(ne,1),X=U[0];ee.current=X;var ce=Zk(B,null,null),ue=mr(ce,4),se=ue[0],ae=ue[1],xe=ue[2],be=ue[3],Y=T.useMemo(function(){if(!C)return{scrollHeight:void 0,start:0,end:M.length-1,offset:void 0};if(!S){var Ce;return{scrollHeight:((Ce=I.current)===null||Ce===void 0?void 0:Ce.offsetHeight)||0,start:0,end:M.length-1,offset:void 0}}for(var Ie=0,et,Mt,lt,kt=M.length,dt=0;dt<kt;dt+=1){var Gt=M[dt],Ot=B(Gt),bt=xe.get(Ot),_t=Ie+(bt===void 0?a:bt);_t>=A&&et===void 0&&(et=dt,Mt=Ie),_t>A+o&&lt===void 0&&(lt=dt),Ie=_t}return et===void 0&&(et=0,Mt=0,lt=Math.ceil(o/a)),lt===void 0&&(lt=M.length-1),lt=Math.min(lt+1,M.length),{scrollHeight:Ie,start:et,end:lt,offset:Mt}},[S,C,A,M,be,o]),re=Y.scrollHeight,Se=Y.start,q=Y.end,we=Y.offset;W.current.start=Se,W.current.end=q;var ve=re-o,_e=x.useRef(ve);_e.current=ve;function ke(Ce){var Ie=Ce;return Number.isNaN(_e.current)||(Ie=Math.min(Ie,_e.current)),Ie=Math.max(Ie,0),Ie}var ge=A<=0,Ke=A>=ve,Pe=xh(ge,Ke);function Xe(Ce){var Ie=Ce;K(Ie)}function Ee(Ce){var Ie=Ce.currentTarget.scrollTop;Ie!==A&&K(Ie),w==null||w(Ce)}var Fe=rO(C,ge,Ke,function(Ce){K(function(Ie){var et=Ie+Ce;return et})}),Le=mr(Fe,2),Ve=Le[0],ct=Le[1];oO(C,$,function(Ce,Ie){return Pe(Ce,Ie)?!1:(Ve({preventDefault:function(){},deltaY:Ce}),!0)}),Yn(function(){function Ce(Ie){C&&Ie.preventDefault()}return $.current.addEventListener("wheel",Ve),$.current.addEventListener("DOMMouseScroll",ct),$.current.addEventListener("MozMousePixelScroll",Ce),function(){$.current&&($.current.removeEventListener("wheel",Ve),$.current.removeEventListener("DOMMouseScroll",ct),$.current.removeEventListener("MozMousePixelScroll",Ce))}},[C]);var at=Jk($,M,xe,a,B,ae,K,function(){var Ce;(Ce=R.current)===null||Ce===void 0||Ce.delayHidden()});T.useImperativeHandle(t,function(){return{scrollTo:at}}),Yn(function(){if(b){var Ce=M.slice(Se,q+1);b(Ce,M)}},[Se,q,M]);var We=Xk(M,Se,q,se,h,G),st=null;return o&&(st=eo(Ji({},u?"height":"maxHeight",o),lO),C&&(st.overflowY="hidden",O&&(st.pointerEvents="none"))),y("div",{style:eo(eo({},c),{},{position:"relative"}),className:z,..._,children:[l(m,{className:"".concat(r,"-holder"),style:st,ref:$,onScroll:Ee,children:l(vh,{prefixCls:r,height:re,offset:we,onInnerResize:ae,ref:I,children:We})}),C&&l(Uk,{ref:R,prefixCls:r,scrollTop:A,height:o,scrollHeight:re,count:M.length,onScroll:Xe,onStartMove:function(){N(!0)},onStopMove:function(){N(!1)}})]})}var Pl=T.forwardRef(uO);Pl.displayName="List";function cO(){return/(mac\sos|macintosh)/i.test(navigator.appVersion)}var Sh=T.createContext(null),dO=["disabled","title","children","style","className"];function Ch(e){return typeof e=="string"||typeof e=="number"}var fO=function(t,n){var r=Gd(),i=r.prefixCls,o=r.id,a=r.open,s=r.multiple,u=r.mode,c=r.searchValue,f=r.toggleOpen,h=r.notFoundContent,p=r.onPopupScroll,g=T.useContext(Sh),v=g.flattenOptions,m=g.onActiveValue,w=g.defaultActiveFirstOption,b=g.onSelect,_=g.menuItemSelectedIcon,C=g.rawValues,S=g.fieldNames,E=g.virtual,k=g.listHeight,A=g.listItemHeight,L="".concat(i,"-item"),F=Gs(function(){return v},[a,v],function(U,X){return X[0]&&U[1]!==X[1]}),P=T.useRef(null),O=function(X){X.preventDefault()},N=function(X){P.current&&P.current.scrollTo(typeof X=="number"?{index:X}:X)},z=function(X){for(var ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:1,ue=F.length,se=0;se<ue;se+=1){var ae=(X+se*ce+ue)%ue,xe=F[ae],be=xe.group,Y=xe.data;if(!be&&!Y.disabled)return ae}return-1},M=T.useState(function(){return z(0)}),$=It(M,2),I=$[0],R=$[1],B=function(X){var ce=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;R(X);var ue={source:ce?"keyboard":"mouse"},se=F[X];if(!se){m(null,-1,ue);return}m(se.value,X,ue)};x.useEffect(function(){B(w!==!1?z(0):-1)},[F.length,c]);var G=T.useCallback(function(U){return C.has(U)&&u!=="combobox"},[u,bn(C).toString(),C.size]);x.useEffect(function(){var U=setTimeout(function(){if(!s&&a&&C.size===1){var ce=Array.from(C)[0],ue=F.findIndex(function(se){var ae=se.data;return ae.value===ce});ue!==-1&&(B(ue),N(ue))}});if(a){var X;(X=P.current)===null||X===void 0||X.scrollTo(void 0)}return function(){return clearTimeout(U)}},[a,c]);var K=function(X){X!==void 0&&b(X,{selected:!C.has(X)}),s||f(!1)};if(T.useImperativeHandle(n,function(){return{onKeyDown:function(X){var ce=X.which,ue=X.ctrlKey;switch(ce){case oe.N:case oe.P:case oe.UP:case oe.DOWN:{var se=0;if(ce===oe.UP?se=-1:ce===oe.DOWN?se=1:cO()&&ue&&(ce===oe.N?se=1:ce===oe.P&&(se=-1)),se!==0){var ae=z(I+se,se);N(ae),B(ae,!0)}break}case oe.ENTER:{var xe=F[I];xe&&!xe.data.disabled?K(xe.value):K(void 0),a&&X.preventDefault();break}case oe.ESC:f(!1),a&&X.stopPropagation()}},onKeyUp:function(){},scrollTo:function(X){N(X)}}}),F.length===0)return l("div",{role:"listbox",id:"".concat(o,"_list"),className:"".concat(L,"-empty"),onMouseDown:O,children:h});var W=Object.keys(S).map(function(U){return S[U]}),ee=function(X){return X.label},ne=function(X){var ce=F[X];if(!ce)return null;var ue=ce.data||{},se=ue.value,ae=ce.group,xe=Qr(ue,!0),be=ee(ce);return ce?x.createElement("div",{"aria-label":typeof be=="string"&&!ae?be:null,...xe,key:X,role:ae?"presentation":"option",id:"".concat(o,"_list_").concat(X),"aria-selected":G(se)},se):null};return y(Oe,{children:[y("div",{role:"listbox",id:"".concat(o,"_list"),style:{height:0,width:0,overflow:"hidden"},children:[ne(I-1),ne(I),ne(I+1)]}),l(Pl,{itemKey:"key",ref:P,data:F,height:k,itemHeight:A,fullHeight:!1,onMouseDown:O,onScroll:p,virtual:E,children:function(U,X){var ce,ue=U.group,se=U.groupOption,ae=U.data,xe=U.label,be=U.value,Y=ae.key;if(ue){var re,Se=(re=ae.title)!==null&&re!==void 0?re:Ch(xe)?xe.toString():void 0;return l("div",{className:pt(L,"".concat(L,"-group")),title:Se,children:xe!==void 0?xe:Y})}var q=ae.disabled,we=ae.title;ae.children;var ve=ae.style,_e=ae.className,ke=Yr(ae,dO),ge=fh(ke,W),Ke=G(be),Pe="".concat(L,"-option"),Xe=pt(L,Pe,_e,(ce={},At(ce,"".concat(Pe,"-grouped"),se),At(ce,"".concat(Pe,"-active"),I===X&&!q),At(ce,"".concat(Pe,"-disabled"),q),At(ce,"".concat(Pe,"-selected"),Ke),ce)),Ee=ee(U),Fe=!_||typeof _=="function"||Ke,Le=typeof Ee=="number"?Ee:Ee||be,Ve=Ch(Le)?Le.toString():void 0;return we!==void 0&&(Ve=we),y("div",{...Qr(ge),"aria-selected":Ke,className:Xe,title:Ve,onMouseMove:function(){I===X||q||B(X)},onClick:function(){q||K(be)},style:ve,children:[l("div",{className:"".concat(Pe,"-content"),children:Le}),T.isValidElement(_)||Ke,Fe&&l(Uo,{className:"".concat(L,"-option-state"),customizeIcon:_,customizeIconProps:{isSelected:Ke},children:Ke?"\u2713":null})]})}})]})},_h=T.forwardRef(fO);_h.displayName="OptionList";function pO(e){var t=e.mode,n=e.options,r=e.children,i=e.backfill,o=e.allowClear,a=e.placeholder,s=e.getInputElement,u=e.showSearch,c=e.onSearch,f=e.defaultOpen,h=e.autoFocus,p=e.labelInValue,g=e.value,v=e.inputValue,m=e.optionLabelProp,w=ya(t),b=u!==void 0?u:w||t==="combobox",_=n||Rl(r);if(it(t!=="tags"||_.every(function(k){return!k.disabled}),"Please avoid setting option to disabled in tags mode since user can always type text as tag."),t==="tags"||t==="combobox"){var C=_.some(function(k){return k.options?k.options.some(function(A){return typeof("value"in A?A.value:A.key)=="number"}):typeof("value"in k?k.value:k.key)=="number"});it(!C,"`value` of Option should not use number type when `mode` is `tags` or `combobox`.")}if(it(t!=="combobox"||!m,"`combobox` mode not support `optionLabelProp`. Please set `value` on Option directly."),it(t==="combobox"||!i,"`backfill` only works with `combobox` mode."),it(t==="combobox"||!s,"`getInputElement` only work with `combobox` mode."),$d(t!=="combobox"||!s||!o||!a,"Customize `getInputElement` should customize clear and placeholder logic instead of configuring `allowClear` and `placeholder`."),c&&!b&&t!=="combobox"&&t!=="tags"&&it(!1,"`onSearch` should work with `showSearch` instead of use alone."),$d(!f||h,"`defaultOpen` makes Select open without focus which means it will not close by click outside. You can set `autoFocus` if needed."),g!=null){var S=Xs(g);it(!p||S.every(function(k){return Un(k)==="object"&&("key"in k||"value"in k)}),"`value` should in shape of `{ value: string | number, label?: ReactNode }` when you set `labelInValue` to `true`"),it(!w||Array.isArray(g),"`value` should be array when `mode` is `multiple` or `tags`")}if(r){var E=null;pr(r).some(function(k){if(!T.isValidElement(k)||!k.type)return!1;var A=k,L=A.type;if(L.isSelectOption)return!1;if(L.isSelectOptGroup){var F=pr(k.props.children).every(function(P){return!T.isValidElement(P)||!k.type||P.type.isSelectOption?!0:(E=P.type,!1)});return!F}return E=L,!0}),E&&it(!1,"`children` should be `Select.Option` or `Select.OptGroup` instead of `".concat(E.displayName||E.name||E,"`.")),it(v===void 0,"`inputValue` is deprecated, please use `searchValue` instead.")}}function hO(e,t){if(e){var n=function r(i){for(var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,a=0;a<i.length;a++){var s=i[a];if(s[t==null?void 0:t.value]===null)return it(!1,"`value` in Select options should not be `null`."),!0;if(!o&&Array.isArray(s[t==null?void 0:t.options])&&r(s[t==null?void 0:t.options],!0))break}};n(e)}}var gO=["id","mode","prefixCls","backfill","fieldNames","inputValue","searchValue","onSearch","autoClearSearchValue","onSelect","onDeselect","dropdownMatchSelectWidth","filterOption","filterSort","optionFilterProp","optionLabelProp","options","children","defaultActiveFirstOption","menuItemSelectedIcon","virtual","listHeight","listItemHeight","value","defaultValue","labelInValue","onChange"],vO=["inputValue"];function mO(e){return!e||Un(e)!=="object"}var Eh=T.forwardRef(function(e,t){var n=e.id,r=e.mode,i=e.prefixCls,o=i===void 0?"rc-select":i,a=e.backfill,s=e.fieldNames,u=e.inputValue,c=e.searchValue,f=e.onSearch,h=e.autoClearSearchValue,p=h===void 0?!0:h,g=e.onSelect,v=e.onDeselect,m=e.dropdownMatchSelectWidth,w=m===void 0?!0:m,b=e.filterOption,_=e.filterSort,C=e.optionFilterProp,S=e.optionLabelProp,E=e.options,k=e.children,A=e.defaultActiveFirstOption,L=e.menuItemSelectedIcon,F=e.virtual,P=e.listHeight,O=P===void 0?200:P,N=e.listItemHeight,z=N===void 0?20:N,M=e.value,$=e.defaultValue,I=e.labelInValue,R=e.onChange,B=Yr(e,gO),G=lh(n),K=ya(r),W=!!(!E&&k),ee=T.useMemo(function(){return b===void 0&&r==="combobox"?!1:b},[b,r]),ne=T.useMemo(function(){return ah(s,W)},[JSON.stringify(s),W]),U=zi("",{value:c!==void 0?c:u,postState:function(pe){return pe||""}}),X=It(U,2),ce=X[0],ue=X[1],se=Ik(E,k,ne,C,S),ae=se.valueOptions,xe=se.labelOptions,be=se.options,Y=T.useCallback(function(ie){var pe=Xs(ie);return pe.map(function(me){var Ae,Qe,ft,Wt,qt;if(mO(me))Ae=me;else{var dn;ft=me.key,Qe=me.label,Ae=(dn=me.value)!==null&&dn!==void 0?dn:ft}var xt=ae.get(Ae);if(xt){var V;if(Qe===void 0&&(Qe=xt==null?void 0:xt[S||ne.label]),ft===void 0&&(ft=(V=xt==null?void 0:xt.key)!==null&&V!==void 0?V:Ae),Wt=xt==null?void 0:xt.disabled,qt=xt==null?void 0:xt.title,process.env.NODE_ENV!=="production"&&!S){var J=xt==null?void 0:xt[ne.label];J!==void 0&&J!==Qe&&it(!1,"`label` of `value` is not same as `label` in Select options.")}}return{label:Qe,value:Ae,key:ft,disabled:Wt,title:qt}})},[ne,S,ae]),re=zi($,{value:M}),Se=It(re,2),q=Se[0],we=Se[1],ve=T.useMemo(function(){var ie,pe=Y(q);return r==="combobox"&&!((ie=pe[0])!==null&&ie!==void 0&&ie.value)?[]:pe},[q,Y,r]),_e=Mk(ve,ae),ke=It(_e,2),ge=ke[0],Ke=ke[1],Pe=T.useMemo(function(){if(!r&&ge.length===1){var ie=ge[0];if(ie.value===null&&(ie.label===null||ie.label===void 0))return[]}return ge.map(function(pe){var me;return Pt(Pt({},pe),{},{label:(me=pe.label)!==null&&me!==void 0?me:pe.value})})},[r,ge]),Xe=T.useMemo(function(){return new Set(ge.map(function(ie){return ie.value}))},[ge]);T.useEffect(function(){if(r==="combobox"){var ie,pe=(ie=ge[0])===null||ie===void 0?void 0:ie.value;ue(px(pe)?String(pe):"")}},[ge]);var Ee=uh(function(ie,pe){var me,Ae=pe!=null?pe:ie;return me={},At(me,ne.value,ie),At(me,ne.label,Ae),me}),Fe=T.useMemo(function(){if(r!=="tags")return be;var ie=bn(be),pe=function(Ae){return ae.has(Ae)};return bn(ge).sort(function(me,Ae){return me.value<Ae.value?-1:1}).forEach(function(me){var Ae=me.value;pe(Ae)||ie.push(Ee(Ae,me.label))}),ie},[Ee,be,ae,ge,r]),Le=kk(Fe,ne,ce,ee,C),Ve=T.useMemo(function(){return r!=="tags"||!ce||Le.some(function(ie){return ie[C||"value"]===ce})?Le:[Ee(ce)].concat(bn(Le))},[Ee,C,r,Le,ce]),ct=T.useMemo(function(){return _?bn(Ve).sort(function(ie,pe){return _(ie,pe)}):Ve},[Ve,_]),at=T.useMemo(function(){return Ck(ct,{fieldNames:ne,childrenAsData:W})},[ct,ne,W]),We=function(pe){var me=Y(pe);if(we(me),R&&(me.length!==ge.length||me.some(function(ft,Wt){var qt;return((qt=ge[Wt])===null||qt===void 0?void 0:qt.value)!==(ft==null?void 0:ft.value)}))){var Ae=I?me:me.map(function(ft){return ft.value}),Qe=me.map(function(ft){return kl(Ke(ft.value))});R(K?Ae:Ae[0],K?Qe:Qe[0])}},st=T.useState(null),Ce=It(st,2),Ie=Ce[0],et=Ce[1],Mt=T.useState(0),lt=It(Mt,2),kt=lt[0],dt=lt[1],Gt=A!==void 0?A:r!=="combobox",Ot=T.useCallback(function(ie,pe){var me=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},Ae=me.source,Qe=Ae===void 0?"keyboard":Ae;dt(pe),a&&r==="combobox"&&ie!==null&&Qe==="keyboard"&&et(String(ie))},[a,r]),bt=function(pe,me,Ae){var Qe=function(){var ye,Te=Ke(pe);return[I?{label:Te==null?void 0:Te[ne.label],value:pe,key:(ye=Te==null?void 0:Te.key)!==null&&ye!==void 0?ye:pe}:pe,kl(Te)]};if(me&&g){var ft=Qe(),Wt=It(ft,2),qt=Wt[0],dn=Wt[1];g(qt,dn)}else if(!me&&v&&Ae!=="clear"){var xt=Qe(),V=It(xt,2),J=V[0],Q=V[1];v(J,Q)}},_t=uh(function(ie,pe){var me,Ae=K?pe.selected:!0;Ae?me=K?[].concat(bn(ge),[ie]):[ie]:me=ge.filter(function(Qe){return Qe.value!==ie}),We(me),bt(ie,Ae),r==="combobox"?et(""):(!ya||p)&&(ue(""),et(""))}),Ht=function(pe,me){We(pe);var Ae=me.type,Qe=me.values;(Ae==="remove"||Ae==="clear")&&Qe.forEach(function(ft){bt(ft.value,!1,Ae)})},vt=function(pe,me){if(ue(pe),et(null),me.source==="submit"){var Ae=(pe||"").trim();if(Ae){var Qe=Array.from(new Set([].concat(bn(Xe),[Ae])));We(Qe),bt(Ae,!0),ue("")}return}me.source!=="blur"&&(r==="combobox"&&We(pe),f==null||f(pe))},cn=function(pe){var me=pe;r!=="tags"&&(me=pe.map(function(Qe){var ft=xe.get(Qe);return ft==null?void 0:ft.value}).filter(function(Qe){return Qe!==void 0}));var Ae=Array.from(new Set([].concat(bn(Xe),bn(me))));We(Ae),Ae.forEach(function(Qe){bt(Qe,!0)})},Vt=T.useMemo(function(){var ie=F!==!1&&w!==!1;return Pt(Pt({},se),{},{flattenOptions:at,onActiveValue:Ot,defaultActiveFirstOption:Gt,onSelect:_t,menuItemSelectedIcon:L,rawValues:Xe,fieldNames:ne,virtual:ie,listHeight:O,listItemHeight:z,childrenAsData:W})},[se,at,Ot,Gt,_t,L,Xe,ne,F,w,O,z,W]);return process.env.NODE_ENV!=="production"&&(pO(e),hO(be,ne)),l(Sh.Provider,{value:Vt,children:l(Ol,{...B,id:G,prefixCls:o,ref:t,omitDomProps:vO,mode:r,displayValues:Pe,onDisplayValuesChange:Ht,searchValue:ce,onSearch:vt,autoClearSearchValue:p,onSearchSplit:cn,dropdownMatchSelectWidth:w,OptionList:_h,emptyOptions:!at.length,activeValue:Ie,activeDescendantId:"".concat(G,"_list_").concat(kt)})})});process.env.NODE_ENV!=="production"&&(Eh.displayName="Select");var Th=Eh;Th.Option=dh,Th.OptGroup=ch;function Mh(e,t){var n=new Set;return e.forEach(function(r){t.has(r)||n.add(r)}),n}function yO(e){var t=e||{},n=t.disabled,r=t.disableCheckbox,i=t.checkable;return!!(n||r)||i===!1}function bO(e,t,n,r){for(var i=new Set(e),o=new Set,a=0;a<=n;a+=1){var s=t.get(a)||new Set;s.forEach(function(h){var p=h.key,g=h.node,v=h.children,m=v===void 0?[]:v;i.has(p)&&!r(g)&&m.filter(function(w){return!r(w.node)}).forEach(function(w){i.add(w.key)})})}for(var u=new Set,c=n;c>=0;c-=1){var f=t.get(c)||new Set;f.forEach(function(h){var p=h.parent,g=h.node;if(!(r(g)||!h.parent||u.has(h.parent.key))){if(r(h.parent.node)){u.add(p.key);return}var v=!0,m=!1;(p.children||[]).filter(function(w){return!r(w.node)}).forEach(function(w){var b=w.key,_=i.has(b);v&&!_&&(v=!1),!m&&(_||o.has(b))&&(m=!0)}),v&&i.add(p.key),m&&o.add(p.key),u.add(p.key)}})}return{checkedKeys:Array.from(i),halfCheckedKeys:Array.from(Mh(o,i))}}function wO(e,t,n,r,i){for(var o=new Set(e),a=new Set(t),s=0;s<=r;s+=1){var u=n.get(s)||new Set;u.forEach(function(p){var g=p.key,v=p.node,m=p.children,w=m===void 0?[]:m;!o.has(g)&&!a.has(g)&&!i(v)&&w.filter(function(b){return!i(b.node)}).forEach(function(b){o.delete(b.key)})})}a=new Set;for(var c=new Set,f=r;f>=0;f-=1){var h=n.get(f)||new Set;h.forEach(function(p){var g=p.parent,v=p.node;if(!(i(v)||!p.parent||c.has(p.parent.key))){if(i(p.parent.node)){c.add(g.key);return}var m=!0,w=!1;(g.children||[]).filter(function(b){return!i(b.node)}).forEach(function(b){var _=b.key,C=o.has(_);m&&!C&&(m=!1),!w&&(C||a.has(_))&&(w=!0)}),m||o.delete(g.key),w&&a.add(g.key),c.add(g.key)}})}return{checkedKeys:Array.from(o),halfCheckedKeys:Array.from(Mh(a,o))}}function fi(e,t,n,r){var i=[],o;r?o=r:o=yO;var a=new Set(e.filter(function(f){var h=!!n[f];return h||i.push(f),h})),s=new Map,u=0;Object.keys(n).forEach(function(f){var h=n[f],p=h.level,g=s.get(p);g||(g=new Set,s.set(p,g)),g.add(h),u=Math.max(u,p)}),it(!i.length,"Tree missing follow keys: ".concat(i.slice(0,100).map(function(f){return"'".concat(f,"'")}).join(", ")));var c;return t===!0?c=bO(a,s,u,o):c=wO(a,t.halfCheckedKeys,s,u,o),c}function wa(){return wa=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},wa.apply(this,arguments)}function er(e){return er=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},er(e)}function xO(e,t){if(er(e)!=="object"||e===null)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||"default");if(er(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function kh(e){var t=xO(e,"string");return er(t)==="symbol"?t:String(t)}function Et(e,t,n){return t=kh(t),t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Oh(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(e,i).enumerable})),n.push.apply(n,r)}return n}function Xt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]!=null?arguments[t]:{};t%2?Oh(Object(n),!0).forEach(function(r){Et(e,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Oh(Object(n)).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))})}return e}function Il(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function SO(e){if(Array.isArray(e))return Il(e)}function CO(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}function Dh(e,t){if(!!e){if(typeof e=="string")return Il(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if(n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set")return Array.from(e);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Il(e,t)}}function _O(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
74
74
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Ir(e){return SO(e)||CO(e)||Dh(e)||_O()}function Rh(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Ah(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,kh(r.key),r)}}function Ph(e,t,n){return t&&Ah(e.prototype,t),n&&Ah(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function tr(e){if(e===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function Nl(e,t){return Nl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(r,i){return r.__proto__=i,r},Nl(e,t)}function Ih(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&Nl(e,t)}function xa(e){return xa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},xa(e)}function EO(){if(typeof Reflect>"u"||!Reflect.construct||Reflect.construct.sham)return!1;if(typeof Proxy=="function")return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch{return!1}}function TO(e,t){if(t&&(er(t)==="object"||typeof t=="function"))return t;if(t!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return tr(e)}function Nh(e){var t=EO();return function(){var r=xa(e),i;if(t){var o=xa(this).constructor;i=Reflect.construct(r,arguments,o)}else i=r.apply(this,arguments);return TO(this,i)}}var $l=T.createContext(null);function MO(e,t){if(e==null)return{};var n={},r=Object.keys(e),i,o;for(o=0;o<r.length;o++)i=r[o],!(t.indexOf(i)>=0)&&(n[i]=e[i]);return n}function Sa(e,t){if(e==null)return{};var n=MO(e,t),r,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i<o.length;i++)r=o[i],!(t.indexOf(r)>=0)&&(!Object.prototype.propertyIsEnumerable.call(e,r)||(n[r]=e[r]))}return n}var kO=function(t){for(var n=t.prefixCls,r=t.level,i=t.isStart,o=t.isEnd,a="".concat(n,"-indent-unit"),s=[],u=0;u<r;u+=1){var c;s.push(l("span",{className:pt(a,(c={},Et(c,"".concat(a,"-start"),i[u]),Et(c,"".concat(a,"-end"),o[u]),c))},u))}return l("span",{"aria-hidden":"true",className:"".concat(n,"-indent"),children:s})};const OO=T.memo(kO);var DO=["children"];function to(e,t){return e!=null?e:t}function Ca(e){var t=e||{},n=t.title,r=t._title,i=t.key,o=t.children,a=n||"title";return{title:a,_title:r||[a],key:i||"key",children:o||"children"}}function RO(e,t){var n=new Map;function r(i){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";(i||[]).forEach(function(a){var s=a[t.key],u=a[t.children];it(s!=null,"Tree node must have a certain key: [".concat(o).concat(s,"]"));var c=String(s);it(!n.has(c)||s===null||s===void 0,"Same 'key' exist in the Tree: ".concat(c)),n.set(c,!0),r(u,"".concat(o).concat(c," > "))})}r(e)}function AO(e){function t(n){var r=pr(n);return r.map(function(i){if(!LO(i))return it(!i,"Tree/TreeNode can only accept TreeNode as children."),null;var o=i.key,a=i.props,s=a.children,u=Sa(a,DO),c=Xt({key:o},u),f=t(s);return f.length&&(c.children=f),c}).filter(function(i){return i})}return t(e)}function Ll(e,t,n){var r=Ca(n),i=r._title,o=r.key,a=r.children,s=new Set(t===!0?[]:t),u=[];function c(f){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null;return f.map(function(p,g){for(var v=zh(h?h.pos:"0",g),m=to(p[o],v),w,b=0;b<i.length;b+=1){var _=i[b];if(p[_]!==void 0){w=p[_];break}}var C=Xt(Xt({},fh(p,[].concat(Ir(i),[o,a]))),{},{title:w,key:m,parent:h,pos:v,children:null,data:p,isStart:[].concat(Ir(h?h.isStart:[]),[g===0]),isEnd:[].concat(Ir(h?h.isEnd:[]),[g===f.length-1])});return u.push(C),t===!0||s.has(m)?C.children=c(p[a]||[],C):C.children=[],C})}return c(e),u}function PO(e,t,n){var r={};er(n)==="object"?r=n:r={externalGetKey:n},r=r||{};var i=r,o=i.childrenPropName,a=i.externalGetKey,s=i.fieldNames,u=Ca(s),c=u.key,f=u.children,h=o||f,p;a?typeof a=="string"?p=function(m){return m[a]}:typeof a=="function"&&(p=function(m){return a(m)}):p=function(m,w){return to(m[c],w)};function g(v,m,w,b){var _=v?v[h]:e,C=v?zh(w.pos,m):"0",S=v?[].concat(Ir(b),[v]):[];if(v){var E=p(v,C),k={node:v,index:m,pos:C,key:E,parentPos:w.node?w.pos:null,level:w.level+1,nodes:S};t(k)}_&&_.forEach(function(A,L){g(A,L,{node:v,pos:C,level:w?w.level+1:-1},S)})}g(null)}function $h(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},n=t.initWrapper,r=t.processEntity,i=t.onProcessFinished,o=t.externalGetKey,a=t.childrenPropName,s=t.fieldNames,u=arguments.length>2?arguments[2]:void 0,c=o||u,f={},h={},p={posEntities:f,keyEntities:h};return n&&(p=n(p)||p),PO(e,function(g){var v=g.node,m=g.index,w=g.pos,b=g.key,_=g.parentPos,C=g.level,S=g.nodes,E={node:v,nodes:S,index:m,key:b,pos:w,level:C},k=to(b,w);f[w]=E,h[k]=E,E.parent=f[_],E.parent&&(E.parent.children=E.parent.children||[],E.parent.children.push(E)),r&&r(E,p)},{externalGetKey:c,childrenPropName:a,fieldNames:s}),i&&i(p),p}function no(e,t){var n=t.expandedKeys,r=t.selectedKeys,i=t.loadedKeys,o=t.loadingKeys,a=t.checkedKeys,s=t.halfCheckedKeys,u=t.dragOverNodeKey,c=t.dropPosition,f=t.keyEntities,h=f[e],p={eventKey:e,expanded:n.indexOf(e)!==-1,selected:r.indexOf(e)!==-1,loaded:i.indexOf(e)!==-1,loading:o.indexOf(e)!==-1,checked:a.indexOf(e)!==-1,halfChecked:s.indexOf(e)!==-1,pos:String(h?h.pos:""),dragOver:u===e&&c===0,dragOverGapTop:u===e&&c===-1,dragOverGapBottom:u===e&&c===1};return p}function $t(e){var t=e.data,n=e.expanded,r=e.selected,i=e.checked,o=e.loaded,a=e.loading,s=e.halfChecked,u=e.dragOver,c=e.dragOverGapTop,f=e.dragOverGapBottom,h=e.pos,p=e.active,g=e.eventKey,v=Xt(Xt({},t),{},{expanded:n,selected:r,checked:i,loaded:o,loading:a,halfChecked:s,dragOver:u,dragOverGapTop:c,dragOverGapBottom:f,pos:h,active:p,key:g});return"props"in v||Object.defineProperty(v,"props",{get:function(){return it(!1,"Second param return from event is node data instead of TreeNode instance. Please read value directly instead of reading from `props`."),e}}),v}var IO=["eventKey","className","style","dragOver","dragOverGapTop","dragOverGapBottom","isLeaf","isStart","isEnd","expanded","selected","checked","halfChecked","loading","domRef","active","data","onMouseMove","selectable"],Lh="open",Vh="close",NO="---",$O=function(e){Ih(n,e);var t=Nh(n);function n(){var r;Rh(this,n);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return r=t.call.apply(t,[this].concat(o)),r.state={dragNodeHighlight:!1},r.selectHandle=void 0,r.onSelectorClick=function(s){var u=r.props.context.onNodeClick;u(s,$t(r.props)),r.isSelectable()?r.onSelect(s):r.onCheck(s)},r.onSelectorDoubleClick=function(s){var u=r.props.context.onNodeDoubleClick;u(s,$t(r.props))},r.onSelect=function(s){if(!r.isDisabled()){var u=r.props.context.onNodeSelect;s.preventDefault(),u(s,$t(r.props))}},r.onCheck=function(s){if(!r.isDisabled()){var u=r.props,c=u.disableCheckbox,f=u.checked,h=r.props.context.onNodeCheck;if(!(!r.isCheckable()||c)){s.preventDefault();var p=!f;h(s,$t(r.props),p)}}},r.onMouseEnter=function(s){var u=r.props.context.onNodeMouseEnter;u(s,$t(r.props))},r.onMouseLeave=function(s){var u=r.props.context.onNodeMouseLeave;u(s,$t(r.props))},r.onContextMenu=function(s){var u=r.props.context.onNodeContextMenu;u(s,$t(r.props))},r.onDragStart=function(s){var u=r.props.context.onNodeDragStart;s.stopPropagation(),r.setState({dragNodeHighlight:!0}),u(s,tr(r));try{s.dataTransfer.setData("text/plain","")}catch{}},r.onDragEnter=function(s){var u=r.props.context.onNodeDragEnter;s.preventDefault(),s.stopPropagation(),u(s,tr(r))},r.onDragOver=function(s){var u=r.props.context.onNodeDragOver;s.preventDefault(),s.stopPropagation(),u(s,tr(r))},r.onDragLeave=function(s){var u=r.props.context.onNodeDragLeave;s.stopPropagation(),u(s,tr(r))},r.onDragEnd=function(s){var u=r.props.context.onNodeDragEnd;s.stopPropagation(),r.setState({dragNodeHighlight:!1}),u(s,tr(r))},r.onDrop=function(s){var u=r.props.context.onNodeDrop;s.preventDefault(),s.stopPropagation(),r.setState({dragNodeHighlight:!1}),u(s,tr(r))},r.onExpand=function(s){var u=r.props,c=u.loading,f=u.context.onNodeExpand;c||f(s,$t(r.props))},r.setSelectHandle=function(s){r.selectHandle=s},r.getNodeState=function(){var s=r.props.expanded;return r.isLeaf()?null:s?Lh:Vh},r.hasChildren=function(){var s=r.props.eventKey,u=r.props.context.keyEntities,c=u[s]||{},f=c.children;return!!(f||[]).length},r.isLeaf=function(){var s=r.props,u=s.isLeaf,c=s.loaded,f=r.props.context.loadData,h=r.hasChildren();return u===!1?!1:u||!f&&!h||f&&c&&!h},r.isDisabled=function(){var s=r.props.disabled,u=r.props.context.disabled;return!!(u||s)},r.isCheckable=function(){var s=r.props.checkable,u=r.props.context.checkable;return!u||s===!1?!1:u},r.syncLoadData=function(s){var u=s.expanded,c=s.loading,f=s.loaded,h=r.props.context,p=h.loadData,g=h.onNodeLoad;c||p&&u&&!r.isLeaf()&&!r.hasChildren()&&!f&&g($t(r.props))},r.isDraggable=function(){var s=r.props,u=s.data,c=s.context.draggable;return!!(c&&(!c.nodeDraggable||c.nodeDraggable(u)))},r.renderDragHandler=function(){var s=r.props.context,u=s.draggable,c=s.prefixCls;return u!=null&&u.icon?l("span",{className:"".concat(c,"-draggable-icon"),children:u.icon}):null},r.renderSwitcherIconDom=function(s){var u=r.props.switcherIcon,c=r.props.context.switcherIcon,f=u||c;return typeof f=="function"?f(Xt(Xt({},r.props),{},{isLeaf:s})):f},r.renderSwitcher=function(){var s=r.props.expanded,u=r.props.context.prefixCls;if(r.isLeaf()){var c=r.renderSwitcherIconDom(!0);return c!==!1?l("span",{className:pt("".concat(u,"-switcher"),"".concat(u,"-switcher-noop")),children:c}):null}var f=pt("".concat(u,"-switcher"),"".concat(u,"-switcher_").concat(s?Lh:Vh)),h=r.renderSwitcherIconDom(!1);return h!==!1?l("span",{onClick:r.onExpand,className:f,children:h}):null},r.renderCheckbox=function(){var s=r.props,u=s.checked,c=s.halfChecked,f=s.disableCheckbox,h=r.props.context.prefixCls,p=r.isDisabled(),g=r.isCheckable();if(!g)return null;var v=typeof g!="boolean"?g:null;return l("span",{className:pt("".concat(h,"-checkbox"),u&&"".concat(h,"-checkbox-checked"),!u&&c&&"".concat(h,"-checkbox-indeterminate"),(p||f)&&"".concat(h,"-checkbox-disabled")),onClick:r.onCheck,children:v})},r.renderIcon=function(){var s=r.props.loading,u=r.props.context.prefixCls;return l("span",{className:pt("".concat(u,"-iconEle"),"".concat(u,"-icon__").concat(r.getNodeState()||"docu"),s&&"".concat(u,"-icon_loading"))})},r.renderSelector=function(){var s=r.state.dragNodeHighlight,u=r.props,c=u.title,f=u.selected,h=u.icon,p=u.loading,g=u.data,v=r.props.context,m=v.prefixCls,w=v.showIcon,b=v.icon,_=v.loadData,C=v.titleRender,S=r.isDisabled(),E="".concat(m,"-node-content-wrapper"),k;if(w){var A=h||b;k=A?l("span",{className:pt("".concat(m,"-iconEle"),"".concat(m,"-icon__customize")),children:typeof A=="function"?A(r.props):A}):r.renderIcon()}else _&&p&&(k=r.renderIcon());var L;typeof c=="function"?L=c(g):C?L=C(g):L=c;var F=l("span",{className:"".concat(m,"-title"),children:L});return y("span",{ref:r.setSelectHandle,title:typeof c=="string"?c:"",className:pt("".concat(E),"".concat(E,"-").concat(r.getNodeState()||"normal"),!S&&(f||s)&&"".concat(m,"-node-selected")),onMouseEnter:r.onMouseEnter,onMouseLeave:r.onMouseLeave,onContextMenu:r.onContextMenu,onClick:r.onSelectorClick,onDoubleClick:r.onSelectorDoubleClick,children:[k,F,r.renderDropIndicator()]})},r.renderDropIndicator=function(){var s=r.props,u=s.disabled,c=s.eventKey,f=r.props.context,h=f.draggable,p=f.dropLevelOffset,g=f.dropPosition,v=f.prefixCls,m=f.indent,w=f.dropIndicatorRender,b=f.dragOverNodeKey,_=f.direction,C=!!h,S=!u&&C&&b===c;return S?w({dropPosition:g,dropLevelOffset:p,indent:m,prefixCls:v,direction:_}):null},r}return Ph(n,[{key:"componentDidMount",value:function(){this.syncLoadData(this.props)}},{key:"componentDidUpdate",value:function(){this.syncLoadData(this.props)}},{key:"isSelectable",value:function(){var i=this.props.selectable,o=this.props.context.selectable;return typeof i=="boolean"?i:o}},{key:"render",value:function(){var i,o=this.props,a=o.eventKey,s=o.className,u=o.style,c=o.dragOver,f=o.dragOverGapTop,h=o.dragOverGapBottom,p=o.isLeaf,g=o.isStart,v=o.isEnd,m=o.expanded,w=o.selected,b=o.checked,_=o.halfChecked,C=o.loading,S=o.domRef,E=o.active;o.data;var k=o.onMouseMove,A=o.selectable,L=Sa(o,IO),F=this.props.context,P=F.prefixCls,O=F.filterTreeNode,N=F.keyEntities,z=F.dropContainerKey,M=F.dropTargetKey,$=F.draggingNodeKey,I=this.isDisabled(),R=Qr(L,{aria:!0,data:!0}),B=N[a]||{},G=B.level,K=v[v.length-1],W=this.isDraggable(),ee=!I&&W,ne=$===a,U=A!==void 0?{"aria-selected":!!A}:void 0;return y("div",{ref:S,className:pt(s,"".concat(P,"-treenode"),(i={},Et(i,"".concat(P,"-treenode-disabled"),I),Et(i,"".concat(P,"-treenode-switcher-").concat(m?"open":"close"),!p),Et(i,"".concat(P,"-treenode-checkbox-checked"),b),Et(i,"".concat(P,"-treenode-checkbox-indeterminate"),_),Et(i,"".concat(P,"-treenode-selected"),w),Et(i,"".concat(P,"-treenode-loading"),C),Et(i,"".concat(P,"-treenode-active"),E),Et(i,"".concat(P,"-treenode-leaf-last"),K),Et(i,"".concat(P,"-treenode-draggable"),W),Et(i,"dragging",ne),Et(i,"drop-target",M===a),Et(i,"drop-container",z===a),Et(i,"drag-over",!I&&c),Et(i,"drag-over-gap-top",!I&&f),Et(i,"drag-over-gap-bottom",!I&&h),Et(i,"filter-node",O&&O($t(this.props))),i)),style:u,draggable:ee,"aria-grabbed":ne,onDragStart:ee?this.onDragStart:void 0,onDragEnter:W?this.onDragEnter:void 0,onDragOver:W?this.onDragOver:void 0,onDragLeave:W?this.onDragLeave:void 0,onDrop:W?this.onDrop:void 0,onDragEnd:W?this.onDragEnd:void 0,onMouseMove:k,...U,...R,children:[l(OO,{prefixCls:P,level:G,isStart:g,isEnd:v}),this.renderDragHandler(),this.renderSwitcher(),this.renderCheckbox(),this.renderSelector()]})}}]),n}(T.Component),pi=function(t){return l($l.Consumer,{children:function(n){return l($O,{...t,context:n})}})};pi.displayName="TreeNode",pi.defaultProps={title:NO},pi.isTreeNode=1;function nr(e,t){if(!e)return[];var n=e.slice(),r=n.indexOf(t);return r>=0&&n.splice(r,1),n}function yr(e,t){var n=(e||[]).slice();return n.indexOf(t)===-1&&n.push(t),n}function Vl(e){return e.split("-")}function zh(e,t){return"".concat(e,"-").concat(t)}function LO(e){return e&&e.type&&e.type.isTreeNode}function VO(e,t){var n=[],r=t[e];function i(){var o=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[];o.forEach(function(a){var s=a.key,u=a.children;n.push(s),i(u)})}return i(r.children),n}function zO(e){if(e.parent){var t=Vl(e.pos);return Number(t[t.length-1])===e.parent.children.length-1}return!1}function FO(e){var t=Vl(e.pos);return Number(t[t.length-1])===0}function Fh(e,t,n,r,i,o,a,s,u,c){var f,h=e.clientX,p=e.clientY,g=e.target.getBoundingClientRect(),v=g.top,m=g.height,w=(c==="rtl"?-1:1)*(((i==null?void 0:i.x)||0)-h),b=(w-12)/r,_=s[n.props.eventKey];if(p<v+m/2){var C=a.findIndex(function($){return $.key===_.key}),S=C<=0?0:C-1,E=a[S].key;_=s[E]}var k=_.key,A=_,L=_.key,F=0,P=0;if(!u.includes(k))for(var O=0;O<b&&zO(_);O+=1)_=_.parent,P+=1;var N=t.props.data,z=_.node,M=!0;return FO(_)&&_.level===0&&p<v+m/2&&o({dragNode:N,dropNode:z,dropPosition:-1})&&_.key===n.props.eventKey?F=-1:(A.children||[]).length&&u.includes(L)?o({dragNode:N,dropNode:z,dropPosition:0})?F=0:M=!1:P===0?b>-1.5?o({dragNode:N,dropNode:z,dropPosition:1})?F=1:M=!1:o({dragNode:N,dropNode:z,dropPosition:0})?F=0:o({dragNode:N,dropNode:z,dropPosition:1})?F=1:M=!1:o({dragNode:N,dropNode:z,dropPosition:1})?F=1:M=!1,{dropPosition:F,dropLevelOffset:P,dropTargetKey:_.key,dropTargetPos:_.pos,dragOverNodeKey:L,dropContainerKey:F===0?null:((f=_.parent)===null||f===void 0?void 0:f.key)||null,dropAllowed:M}}function Bh(e,t){if(!!e){var n=t.multiple;return n?e.slice():e.length?[e[0]]:e}}function zl(e){if(!e)return null;var t;if(Array.isArray(e))t={checkedKeys:e,halfCheckedKeys:void 0};else if(er(e)==="object")t={checkedKeys:e.checked||void 0,halfCheckedKeys:e.halfChecked||void 0};else return it(!1,"`checkedKeys` is not an array or an object"),null;return t}function jh(e,t){var n=new Set;function r(i){if(!n.has(i)){var o=t[i];if(!!o){n.add(i);var a=o.parent,s=o.node;s.disabled||a&&r(a.key)}}}return(e||[]).forEach(function(i){r(i)}),Ir(n)}function Gh(e){if(e==null)throw new TypeError("Cannot destructure "+e)}function BO(e){if(Array.isArray(e))return e}function jO(e,t){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var r,i,o,a,s=[],u=!0,c=!1;try{if(o=(n=n.call(e)).next,t===0){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=o.call(n)).done)&&(s.push(r.value),s.length!==t);u=!0);}catch(f){c=!0,i=f}finally{try{if(!u&&n.return!=null&&(a=n.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}function GO(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
75
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hi(e,t){return BO(e)||jO(e,t)||Dh(e,t)||GO()}var KO=["className","style","motion","motionNodes","motionType","onMotionStart","onMotionEnd","active","treeNodeRequiredProps"],Kh=function(t,n){var r=t.className,i=t.style,o=t.motion,a=t.motionNodes,s=t.motionType,u=t.onMotionStart,c=t.onMotionEnd,f=t.active,h=t.treeNodeRequiredProps,p=Sa(t,KO),g=T.useState(!0),v=hi(g,2),m=v[0],w=v[1],b=T.useContext($l),_=b.prefixCls,C=T.useRef(!1),S=function(){C.current||c(),C.current=!0};return x.useEffect(function(){a&&s==="hide"&&m&&w(!1)},[a]),x.useEffect(function(){return a&&u(),function(){a&&S()}},[]),a?l(na,{ref:n,visible:m,...o,motionAppear:s==="show",onAppearEnd:S,onLeaveEnd:S,children:function(E,k){var A=E.className,L=E.style;return l("div",{ref:k,className:pt("".concat(_,"-treenode-motion"),A),style:L,children:a.map(function(F){var P=wa({},(Gh(F.data),F.data)),O=F.title,N=F.key,z=F.isStart,M=F.isEnd;delete P.children;var $=no(N,h);return x.createElement(pi,{...P,...$,title:O,active:f,data:F.data,key:N,isStart:z,isEnd:M})})})}}):l(pi,{domRef:n,className:r,style:i,...p,active:f})};Kh.displayName="MotionTreeNode";var HO=T.forwardRef(Kh);function WO(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=e.length,r=t.length;if(Math.abs(n-r)!==1)return{add:!1,key:null};function i(o,a){var s=new Map;o.forEach(function(c){s.set(c,!0)});var u=a.filter(function(c){return!s.has(c)});return u.length===1?u[0]:null}return n<r?{add:!0,key:i(e,t)}:{add:!1,key:i(t,e)}}function Hh(e,t,n){var r=e.findIndex(function(s){return s.key===n}),i=e[r+1],o=t.findIndex(function(s){return s.key===n});if(i){var a=t.findIndex(function(s){return s.key===i.key});return t.slice(o+1,a)}return t.slice(o+1)}var qO=["prefixCls","data","selectable","checkable","expandedKeys","selectedKeys","checkedKeys","loadedKeys","loadingKeys","halfCheckedKeys","keyEntities","disabled","dragging","dragOverNodeKey","dropPosition","motion","height","itemHeight","virtual","focusable","activeItem","focused","tabIndex","onKeyDown","onFocus","onBlur","onActiveChange","onListChangeStart","onListChangeEnd"],Wh={width:0,height:0,display:"flex",overflow:"hidden",opacity:0,border:0,padding:0,margin:0},UO=function(){},Nr="RC_TREE_MOTION_".concat(Math.random()),Fl={key:Nr},qh={key:Nr,level:0,index:0,pos:"0",node:Fl,nodes:[Fl]},Uh={parent:null,children:[],pos:qh.pos,data:Fl,title:null,key:Nr,isStart:[],isEnd:[]};function Yh(e,t,n,r){return t===!1||!n?e:e.slice(0,Math.ceil(n/r)+1)}function Xh(e){var t=e.key,n=e.pos;return to(t,n)}function YO(e){for(var t=String(e.data.key),n=e;n.parent;)n=n.parent,t="".concat(n.data.key," > ").concat(t);return t}var Qh=T.forwardRef(function(e,t){var n=e.prefixCls,r=e.data;e.selectable,e.checkable;var i=e.expandedKeys,o=e.selectedKeys,a=e.checkedKeys,s=e.loadedKeys,u=e.loadingKeys,c=e.halfCheckedKeys,f=e.keyEntities,h=e.disabled,p=e.dragging,g=e.dragOverNodeKey,v=e.dropPosition,m=e.motion,w=e.height,b=e.itemHeight,_=e.virtual,C=e.focusable,S=e.activeItem,E=e.focused,k=e.tabIndex,A=e.onKeyDown,L=e.onFocus,F=e.onBlur,P=e.onActiveChange,O=e.onListChangeStart,N=e.onListChangeEnd,z=Sa(e,qO),M=T.useRef(null),$=T.useRef(null);T.useImperativeHandle(t,function(){return{scrollTo:function(Ke){M.current.scrollTo(Ke)},getIndentWidth:function(){return $.current.offsetWidth}}});var I=T.useState(i),R=hi(I,2),B=R[0],G=R[1],K=T.useState(r),W=hi(K,2),ee=W[0],ne=W[1],U=T.useState(r),X=hi(U,2),ce=X[0],ue=X[1],se=T.useState([]),ae=hi(se,2),xe=ae[0],be=ae[1],Y=T.useState(null),re=hi(Y,2),Se=re[0],q=re[1],we=T.useRef(r);we.current=r;function ve(){var ge=we.current;ne(ge),ue(ge),be([]),q(null),N()}T.useEffect(function(){G(i);var ge=WO(B,i);if(ge.key!==null)if(ge.add){var Ke=ee.findIndex(function(Ve){var ct=Ve.key;return ct===ge.key}),Pe=Yh(Hh(ee,r,ge.key),_,w,b),Xe=ee.slice();Xe.splice(Ke+1,0,Uh),ue(Xe),be(Pe),q("show")}else{var Ee=r.findIndex(function(Ve){var ct=Ve.key;return ct===ge.key}),Fe=Yh(Hh(r,ee,ge.key),_,w,b),Le=r.slice();Le.splice(Ee+1,0,Uh),ue(Le),be(Fe),q("hide")}else ee!==r&&(ne(r),ue(r))},[i,r]),T.useEffect(function(){p||ve()},[p]);var _e=m?ce:r,ke={expandedKeys:i,selectedKeys:o,loadedKeys:s,loadingKeys:u,checkedKeys:a,halfCheckedKeys:c,dragOverNodeKey:g,dropPosition:v,keyEntities:f};return y(Oe,{children:[E&&S&&l("span",{style:Wh,"aria-live":"assertive",children:YO(S)}),l("div",{children:l("input",{style:Wh,disabled:C===!1||h,tabIndex:C!==!1?k:null,onKeyDown:A,onFocus:L,onBlur:F,value:"",onChange:UO,"aria-label":"for screen reader"})}),l("div",{className:"".concat(n,"-treenode"),"aria-hidden":!0,style:{position:"absolute",pointerEvents:"none",visibility:"hidden",height:0,overflow:"hidden",border:0,padding:0},children:l("div",{className:"".concat(n,"-indent"),children:l("div",{ref:$,className:"".concat(n,"-indent-unit")})})}),l(Pl,{...z,data:_e,itemKey:Xh,height:w,fullHeight:!1,virtual:_,itemHeight:b,prefixCls:"".concat(n,"-list"),ref:M,onVisibleChange:function(Ke,Pe){var Xe=new Set(Ke),Ee=Pe.filter(function(Fe){return!Xe.has(Fe)});Ee.some(function(Fe){return Xh(Fe)===Nr})&&ve()},children:function(ge){var Ke=ge.pos,Pe=wa({},(Gh(ge.data),ge.data)),Xe=ge.title,Ee=ge.key,Fe=ge.isStart,Le=ge.isEnd,Ve=to(Ee,Ke);delete Pe.key,delete Pe.children;var ct=no(Ve,ke);return l(HO,{...Pe,...ct,title:Xe,active:!!S&&Ee===S.key,pos:Ke,data:ge.data,isStart:Fe,isEnd:Le,motion:m,motionNodes:Ee===Nr?xe:null,motionType:Se,onMotionStart:O,onMotionEnd:ve,treeNodeRequiredProps:ke,onMouseMove:function(){P(null)}})}})]})});Qh.displayName="NodeList";function XO(e){var t=e.dropPosition,n=e.dropLevelOffset,r=e.indent,i={pointerEvents:"none",position:"absolute",right:0,backgroundColor:"red",height:2};switch(t){case-1:i.top=0,i.left=-n*r;break;case 1:i.bottom=0,i.left=-n*r;break;case 0:i.bottom=0,i.left=r;break}return l("div",{style:i})}var QO=10,Bl=function(e){Ih(n,e);var t=Nh(n);function n(){var r;Rh(this,n);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return r=t.call.apply(t,[this].concat(o)),r.destroyed=!1,r.delayedDragEnterLogic=void 0,r.loadingRetryTimes={},r.state={keyEntities:{},indent:null,selectedKeys:[],checkedKeys:[],halfCheckedKeys:[],loadedKeys:[],loadingKeys:[],expandedKeys:[],draggingNodeKey:null,dragChildrenKeys:[],dropTargetKey:null,dropPosition:null,dropContainerKey:null,dropLevelOffset:null,dropTargetPos:null,dropAllowed:!0,dragOverNodeKey:null,treeData:[],flattenNodes:[],focused:!1,activeKey:null,listChanging:!1,prevProps:null,fieldNames:Ca()},r.dragStartMousePosition=null,r.dragNode=void 0,r.currentMouseOverDroppableNodeKey=null,r.listRef=T.createRef(),r.onNodeDragStart=function(s,u){var c=r.state,f=c.expandedKeys,h=c.keyEntities,p=r.props.onDragStart,g=u.props.eventKey;r.dragNode=u,r.dragStartMousePosition={x:s.clientX,y:s.clientY};var v=nr(f,g);r.setState({draggingNodeKey:g,dragChildrenKeys:VO(g,h),indent:r.listRef.current.getIndentWidth()}),r.setExpandedKeys(v),window.addEventListener("dragend",r.onWindowDragEnd),p==null||p({event:s,node:$t(u.props)})},r.onNodeDragEnter=function(s,u){var c=r.state,f=c.expandedKeys,h=c.keyEntities,p=c.dragChildrenKeys,g=c.flattenNodes,v=c.indent,m=r.props,w=m.onDragEnter,b=m.onExpand,_=m.allowDrop,C=m.direction,S=u.props,E=S.pos,k=S.eventKey,A=tr(r),L=A.dragNode;if(r.currentMouseOverDroppableNodeKey!==k&&(r.currentMouseOverDroppableNodeKey=k),!L){r.resetDragState();return}var F=Fh(s,L,u,v,r.dragStartMousePosition,_,g,h,f,C),P=F.dropPosition,O=F.dropLevelOffset,N=F.dropTargetKey,z=F.dropContainerKey,M=F.dropTargetPos,$=F.dropAllowed,I=F.dragOverNodeKey;if(p.indexOf(N)!==-1||!$){r.resetDragState();return}if(r.delayedDragEnterLogic||(r.delayedDragEnterLogic={}),Object.keys(r.delayedDragEnterLogic).forEach(function(R){clearTimeout(r.delayedDragEnterLogic[R])}),L.props.eventKey!==u.props.eventKey&&(s.persist(),r.delayedDragEnterLogic[E]=window.setTimeout(function(){if(r.state.draggingNodeKey!==null){var R=Ir(f),B=h[u.props.eventKey];B&&(B.children||[]).length&&(R=yr(f,u.props.eventKey)),"expandedKeys"in r.props||r.setExpandedKeys(R),b==null||b(R,{node:$t(u.props),expanded:!0,nativeEvent:s.nativeEvent})}},800)),L.props.eventKey===N&&O===0){r.resetDragState();return}r.setState({dragOverNodeKey:I,dropPosition:P,dropLevelOffset:O,dropTargetKey:N,dropContainerKey:z,dropTargetPos:M,dropAllowed:$}),w==null||w({event:s,node:$t(u.props),expandedKeys:f})},r.onNodeDragOver=function(s,u){var c=r.state,f=c.dragChildrenKeys,h=c.flattenNodes,p=c.keyEntities,g=c.expandedKeys,v=c.indent,m=r.props,w=m.onDragOver,b=m.allowDrop,_=m.direction,C=tr(r),S=C.dragNode;if(!!S){var E=Fh(s,S,u,v,r.dragStartMousePosition,b,h,p,g,_),k=E.dropPosition,A=E.dropLevelOffset,L=E.dropTargetKey,F=E.dropContainerKey,P=E.dropAllowed,O=E.dropTargetPos,N=E.dragOverNodeKey;f.indexOf(L)!==-1||!P||(S.props.eventKey===L&&A===0?r.state.dropPosition===null&&r.state.dropLevelOffset===null&&r.state.dropTargetKey===null&&r.state.dropContainerKey===null&&r.state.dropTargetPos===null&&r.state.dropAllowed===!1&&r.state.dragOverNodeKey===null||r.resetDragState():k===r.state.dropPosition&&A===r.state.dropLevelOffset&&L===r.state.dropTargetKey&&F===r.state.dropContainerKey&&O===r.state.dropTargetPos&&P===r.state.dropAllowed&&N===r.state.dragOverNodeKey||r.setState({dropPosition:k,dropLevelOffset:A,dropTargetKey:L,dropContainerKey:F,dropTargetPos:O,dropAllowed:P,dragOverNodeKey:N}),w==null||w({event:s,node:$t(u.props)}))}},r.onNodeDragLeave=function(s,u){r.currentMouseOverDroppableNodeKey===u.props.eventKey&&!s.currentTarget.contains(s.relatedTarget)&&(r.resetDragState(),r.currentMouseOverDroppableNodeKey=null);var c=r.props.onDragLeave;c==null||c({event:s,node:$t(u.props)})},r.onWindowDragEnd=function(s){r.onNodeDragEnd(s,null,!0),window.removeEventListener("dragend",r.onWindowDragEnd)},r.onNodeDragEnd=function(s,u){var c=r.props.onDragEnd;r.setState({dragOverNodeKey:null}),r.cleanDragState(),c==null||c({event:s,node:$t(u.props)}),r.dragNode=null,window.removeEventListener("dragend",r.onWindowDragEnd)},r.onNodeDrop=function(s,u){var c,f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,h=r.state,p=h.dragChildrenKeys,g=h.dropPosition,v=h.dropTargetKey,m=h.dropTargetPos,w=h.dropAllowed;if(!!w){var b=r.props.onDrop;if(r.setState({dragOverNodeKey:null}),r.cleanDragState(),v!==null){var _=Xt(Xt({},no(v,r.getTreeNodeRequiredProps())),{},{active:((c=r.getActiveItem())===null||c===void 0?void 0:c.key)===v,data:r.state.keyEntities[v].node}),C=p.indexOf(v)!==-1;it(!C,"Can not drop to dragNode's children node. This is a bug of rc-tree. Please report an issue.");var S=Vl(m),E={event:s,node:$t(_),dragNode:r.dragNode?$t(r.dragNode.props):null,dragNodesKeys:[r.dragNode.props.eventKey].concat(p),dropToGap:g!==0,dropPosition:g+Number(S[S.length-1])};f||b==null||b(E),r.dragNode=null}}},r.cleanDragState=function(){var s=r.state.draggingNodeKey;s!==null&&r.setState({draggingNodeKey:null,dropPosition:null,dropContainerKey:null,dropTargetKey:null,dropLevelOffset:null,dropAllowed:!0,dragOverNodeKey:null}),r.dragStartMousePosition=null,r.currentMouseOverDroppableNodeKey=null},r.triggerExpandActionExpand=function(s,u){var c=r.state,f=c.expandedKeys,h=c.flattenNodes,p=u.expanded,g=u.key,v=u.isLeaf;if(!(v||s.shiftKey||s.metaKey||s.ctrlKey)){var m=h.filter(function(b){return b.key===g})[0],w=$t(Xt(Xt({},no(g,r.getTreeNodeRequiredProps())),{},{data:m.data}));r.setExpandedKeys(p?nr(f,g):yr(f,g)),r.onNodeExpand(s,w)}},r.onNodeClick=function(s,u){var c=r.props,f=c.onClick,h=c.expandAction;h==="click"&&r.triggerExpandActionExpand(s,u),f==null||f(s,u)},r.onNodeDoubleClick=function(s,u){var c=r.props,f=c.onDoubleClick,h=c.expandAction;h==="doubleClick"&&r.triggerExpandActionExpand(s,u),f==null||f(s,u)},r.onNodeSelect=function(s,u){var c=r.state.selectedKeys,f=r.state,h=f.keyEntities,p=f.fieldNames,g=r.props,v=g.onSelect,m=g.multiple,w=u.selected,b=u[p.key],_=!w;_?m?c=yr(c,b):c=[b]:c=nr(c,b);var C=c.map(function(S){var E=h[S];return E?E.node:null}).filter(function(S){return S});r.setUncontrolledState({selectedKeys:c}),v==null||v(c,{event:"select",selected:_,node:u,selectedNodes:C,nativeEvent:s.nativeEvent})},r.onNodeCheck=function(s,u,c){var f=r.state,h=f.keyEntities,p=f.checkedKeys,g=f.halfCheckedKeys,v=r.props,m=v.checkStrictly,w=v.onCheck,b=u.key,_,C={event:"check",node:u,checked:c,nativeEvent:s.nativeEvent};if(m){var S=c?yr(p,b):nr(p,b),E=nr(g,b);_={checked:S,halfChecked:E},C.checkedNodes=S.map(function(O){return h[O]}).filter(function(O){return O}).map(function(O){return O.node}),r.setUncontrolledState({checkedKeys:S})}else{var k=fi([].concat(Ir(p),[b]),!0,h),A=k.checkedKeys,L=k.halfCheckedKeys;if(!c){var F=new Set(A);F.delete(b);var P=fi(Array.from(F),{checked:!1,halfCheckedKeys:L},h);A=P.checkedKeys,L=P.halfCheckedKeys}_=A,C.checkedNodes=[],C.checkedNodesPositions=[],C.halfCheckedKeys=L,A.forEach(function(O){var N=h[O];if(!!N){var z=N.node,M=N.pos;C.checkedNodes.push(z),C.checkedNodesPositions.push({node:z,pos:M})}}),r.setUncontrolledState({checkedKeys:A},!1,{halfCheckedKeys:L})}w==null||w(_,C)},r.onNodeLoad=function(s){var u=s.key,c=new Promise(function(f,h){r.setState(function(p){var g=p.loadedKeys,v=g===void 0?[]:g,m=p.loadingKeys,w=m===void 0?[]:m,b=r.props,_=b.loadData,C=b.onLoad;if(!_||v.indexOf(u)!==-1||w.indexOf(u)!==-1)return null;var S=_(s);return S.then(function(){var E=r.state.loadedKeys,k=yr(E,u);C==null||C(k,{event:"load",node:s}),r.setUncontrolledState({loadedKeys:k}),r.setState(function(A){return{loadingKeys:nr(A.loadingKeys,u)}}),f()}).catch(function(E){if(r.setState(function(A){return{loadingKeys:nr(A.loadingKeys,u)}}),r.loadingRetryTimes[u]=(r.loadingRetryTimes[u]||0)+1,r.loadingRetryTimes[u]>=QO){var k=r.state.loadedKeys;it(!1,"Retry for `loadData` many times but still failed. No more retry."),r.setUncontrolledState({loadedKeys:yr(k,u)}),f()}h(E)}),{loadingKeys:yr(w,u)}})});return c.catch(function(){}),c},r.onNodeMouseEnter=function(s,u){var c=r.props.onMouseEnter;c==null||c({event:s,node:u})},r.onNodeMouseLeave=function(s,u){var c=r.props.onMouseLeave;c==null||c({event:s,node:u})},r.onNodeContextMenu=function(s,u){var c=r.props.onRightClick;c&&(s.preventDefault(),c({event:s,node:u}))},r.onFocus=function(){var s=r.props.onFocus;r.setState({focused:!0});for(var u=arguments.length,c=new Array(u),f=0;f<u;f++)c[f]=arguments[f];s==null||s.apply(void 0,c)},r.onBlur=function(){var s=r.props.onBlur;r.setState({focused:!1}),r.onActiveChange(null);for(var u=arguments.length,c=new Array(u),f=0;f<u;f++)c[f]=arguments[f];s==null||s.apply(void 0,c)},r.getTreeNodeRequiredProps=function(){var s=r.state,u=s.expandedKeys,c=s.selectedKeys,f=s.loadedKeys,h=s.loadingKeys,p=s.checkedKeys,g=s.halfCheckedKeys,v=s.dragOverNodeKey,m=s.dropPosition,w=s.keyEntities;return{expandedKeys:u||[],selectedKeys:c||[],loadedKeys:f||[],loadingKeys:h||[],checkedKeys:p||[],halfCheckedKeys:g||[],dragOverNodeKey:v,dropPosition:m,keyEntities:w}},r.setExpandedKeys=function(s){var u=r.state,c=u.treeData,f=u.fieldNames,h=Ll(c,s,f);r.setUncontrolledState({expandedKeys:s,flattenNodes:h},!0)},r.onNodeExpand=function(s,u){var c=r.state.expandedKeys,f=r.state,h=f.listChanging,p=f.fieldNames,g=r.props,v=g.onExpand,m=g.loadData,w=u.expanded,b=u[p.key];if(!h){var _=c.indexOf(b),C=!w;if(it(w&&_!==-1||!w&&_===-1,"Expand state not sync with index check"),C?c=yr(c,b):c=nr(c,b),r.setExpandedKeys(c),v==null||v(c,{node:u,expanded:C,nativeEvent:s.nativeEvent}),C&&m){var S=r.onNodeLoad(u);S&&S.then(function(){var E=Ll(r.state.treeData,c,p);r.setUncontrolledState({flattenNodes:E})}).catch(function(){var E=r.state.expandedKeys,k=nr(E,b);r.setExpandedKeys(k)})}}},r.onListChangeStart=function(){r.setUncontrolledState({listChanging:!0})},r.onListChangeEnd=function(){setTimeout(function(){r.setUncontrolledState({listChanging:!1})})},r.onActiveChange=function(s){var u=r.state.activeKey,c=r.props.onActiveChange;u!==s&&(r.setState({activeKey:s}),s!==null&&r.scrollTo({key:s}),c==null||c(s))},r.getActiveItem=function(){var s=r.state,u=s.activeKey,c=s.flattenNodes;return u===null?null:c.find(function(f){var h=f.key;return h===u})||null},r.offsetActiveKey=function(s){var u=r.state,c=u.flattenNodes,f=u.activeKey,h=c.findIndex(function(v){var m=v.key;return m===f});h===-1&&s<0&&(h=c.length),h=(h+s+c.length)%c.length;var p=c[h];if(p){var g=p.key;r.onActiveChange(g)}else r.onActiveChange(null)},r.onKeyDown=function(s){var u=r.state,c=u.activeKey,f=u.expandedKeys,h=u.checkedKeys,p=u.fieldNames,g=r.props,v=g.onKeyDown,m=g.checkable,w=g.selectable;switch(s.which){case oe.UP:{r.offsetActiveKey(-1),s.preventDefault();break}case oe.DOWN:{r.offsetActiveKey(1),s.preventDefault();break}}var b=r.getActiveItem();if(b&&b.data){var _=r.getTreeNodeRequiredProps(),C=b.data.isLeaf===!1||!!(b.data[p.children]||[]).length,S=$t(Xt(Xt({},no(c,_)),{},{data:b.data,active:!0}));switch(s.which){case oe.LEFT:{C&&f.includes(c)?r.onNodeExpand({},S):b.parent&&r.onActiveChange(b.parent.key),s.preventDefault();break}case oe.RIGHT:{C&&!f.includes(c)?r.onNodeExpand({},S):b.children&&b.children.length&&r.onActiveChange(b.children[0].key),s.preventDefault();break}case oe.ENTER:case oe.SPACE:{m&&!S.disabled&&S.checkable!==!1&&!S.disableCheckbox?r.onNodeCheck({},S,!h.includes(c)):!m&&w&&!S.disabled&&S.selectable!==!1&&r.onNodeSelect({},S);break}}}v==null||v(s)},r.setUncontrolledState=function(s){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(!r.destroyed){var f=!1,h=!0,p={};Object.keys(s).forEach(function(g){if(g in r.props){h=!1;return}f=!0,p[g]=s[g]}),f&&(!u||h)&&r.setState(Xt(Xt({},p),c))}},r.scrollTo=function(s){r.listRef.current.scrollTo(s)},r}return Ph(n,[{key:"componentDidMount",value:function(){this.destroyed=!1,this.onUpdated()}},{key:"componentDidUpdate",value:function(){this.onUpdated()}},{key:"onUpdated",value:function(){var i=this.props.activeKey;i!==void 0&&i!==this.state.activeKey&&(this.setState({activeKey:i}),i!==null&&this.scrollTo({key:i}))}},{key:"componentWillUnmount",value:function(){window.removeEventListener("dragend",this.onWindowDragEnd),this.destroyed=!0}},{key:"resetDragState",value:function(){this.setState({dragOverNodeKey:null,dropPosition:null,dropLevelOffset:null,dropTargetKey:null,dropContainerKey:null,dropTargetPos:null,dropAllowed:!1})}},{key:"render",value:function(){var i,o=this.state,a=o.focused,s=o.flattenNodes,u=o.keyEntities,c=o.draggingNodeKey,f=o.activeKey,h=o.dropLevelOffset,p=o.dropContainerKey,g=o.dropTargetKey,v=o.dropPosition,m=o.dragOverNodeKey,w=o.indent,b=this.props,_=b.prefixCls,C=b.className,S=b.style,E=b.showLine,k=b.focusable,A=b.tabIndex,L=A===void 0?0:A,F=b.selectable,P=b.showIcon,O=b.icon,N=b.switcherIcon,z=b.draggable,M=b.checkable,$=b.checkStrictly,I=b.disabled,R=b.motion,B=b.loadData,G=b.filterTreeNode,K=b.height,W=b.itemHeight,ee=b.virtual,ne=b.titleRender,U=b.dropIndicatorRender,X=b.onContextMenu,ce=b.onScroll,ue=b.direction,se=b.rootClassName,ae=b.rootStyle,xe=Qr(this.props,{aria:!0,data:!0}),be;return z&&(er(z)==="object"?be=z:typeof z=="function"?be={nodeDraggable:z}:be={}),l($l.Provider,{value:{prefixCls:_,selectable:F,showIcon:P,icon:O,switcherIcon:N,draggable:be,draggingNodeKey:c,checkable:M,checkStrictly:$,disabled:I,keyEntities:u,dropLevelOffset:h,dropContainerKey:p,dropTargetKey:g,dropPosition:v,dragOverNodeKey:m,indent:w,direction:ue,dropIndicatorRender:U,loadData:B,filterTreeNode:G,titleRender:ne,onNodeClick:this.onNodeClick,onNodeDoubleClick:this.onNodeDoubleClick,onNodeExpand:this.onNodeExpand,onNodeSelect:this.onNodeSelect,onNodeCheck:this.onNodeCheck,onNodeLoad:this.onNodeLoad,onNodeMouseEnter:this.onNodeMouseEnter,onNodeMouseLeave:this.onNodeMouseLeave,onNodeContextMenu:this.onNodeContextMenu,onNodeDragStart:this.onNodeDragStart,onNodeDragEnter:this.onNodeDragEnter,onNodeDragOver:this.onNodeDragOver,onNodeDragLeave:this.onNodeDragLeave,onNodeDragEnd:this.onNodeDragEnd,onNodeDrop:this.onNodeDrop},children:l("div",{role:"tree",className:pt(_,C,se,(i={},Et(i,"".concat(_,"-show-line"),E),Et(i,"".concat(_,"-focused"),a),Et(i,"".concat(_,"-active-focused"),f!==null),i)),style:ae,children:l(Qh,{ref:this.listRef,prefixCls:_,style:S,data:s,disabled:I,selectable:F,checkable:!!M,motion:R,dragging:c!==null,height:K,itemHeight:W,virtual:ee,focusable:k,focused:a,tabIndex:L,activeItem:this.getActiveItem(),onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onActiveChange:this.onActiveChange,onListChangeStart:this.onListChangeStart,onListChangeEnd:this.onListChangeEnd,onContextMenu:X,onScroll:ce,...this.getTreeNodeRequiredProps(),...xe})})})}}],[{key:"getDerivedStateFromProps",value:function(i,o){var a=o.prevProps,s={prevProps:i};function u(k){return!a&&k in i||a&&a[k]!==i[k]}var c,f=o.fieldNames;if(u("fieldNames")&&(f=Ca(i.fieldNames),s.fieldNames=f),u("treeData")?c=i.treeData:u("children")&&(it(!1,"`children` of Tree is deprecated. Please use `treeData` instead."),c=AO(i.children)),c){s.treeData=c;var h=$h(c,{fieldNames:f});s.keyEntities=Xt(Et({},Nr,qh),h.keyEntities),process.env.NODE_ENV!=="production"&&RO(c,f)}var p=s.keyEntities||o.keyEntities;if(u("expandedKeys")||a&&u("autoExpandParent"))s.expandedKeys=i.autoExpandParent||!a&&i.defaultExpandParent?jh(i.expandedKeys,p):i.expandedKeys;else if(!a&&i.defaultExpandAll){var g=Xt({},p);delete g[Nr],s.expandedKeys=Object.keys(g).map(function(k){return g[k].key})}else!a&&i.defaultExpandedKeys&&(s.expandedKeys=i.autoExpandParent||i.defaultExpandParent?jh(i.defaultExpandedKeys,p):i.defaultExpandedKeys);if(s.expandedKeys||delete s.expandedKeys,c||s.expandedKeys){var v=Ll(c||o.treeData,s.expandedKeys||o.expandedKeys,f);s.flattenNodes=v}if(i.selectable&&(u("selectedKeys")?s.selectedKeys=Bh(i.selectedKeys,i):!a&&i.defaultSelectedKeys&&(s.selectedKeys=Bh(i.defaultSelectedKeys,i))),i.checkable){var m;if(u("checkedKeys")?m=zl(i.checkedKeys)||{}:!a&&i.defaultCheckedKeys?m=zl(i.defaultCheckedKeys)||{}:c&&(m=zl(i.checkedKeys)||{checkedKeys:o.checkedKeys,halfCheckedKeys:o.halfCheckedKeys}),m){var w=m,b=w.checkedKeys,_=b===void 0?[]:b,C=w.halfCheckedKeys,S=C===void 0?[]:C;if(!i.checkStrictly){var E=fi(_,!0,p);_=E.checkedKeys,S=E.halfCheckedKeys}s.checkedKeys=_,s.halfCheckedKeys=S}}return u("loadedKeys")&&(s.loadedKeys=i.loadedKeys),s}}]),n}(T.Component);Bl.defaultProps={prefixCls:"rc-tree",showLine:!1,showIcon:!0,selectable:!0,multiple:!1,checkable:!1,disabled:!1,checkStrictly:!1,draggable:!1,defaultExpandParent:!0,autoExpandParent:!1,defaultExpandAll:!1,defaultExpandedKeys:[],defaultCheckedKeys:[],defaultSelectedKeys:[],dropIndicatorRender:XO,allowDrop:function(){return!0},expandAction:!1},Bl.TreeNode=pi;var Zh=T.createContext(null),Jh=T.createContext(null);function eg(e){return Array.isArray(e)?e:e!==void 0?[e]:[]}function ZO(e){var t=e||{},n=t.label,r=t.value,i=t.children,o=r||"value";return{_title:n?[n]:["title","label"],value:o,key:o,children:i||"children"}}function jl(e){return!e||e.disabled||e.disableCheckbox||e.checkable===!1}function JO(e,t){var n=[];function r(i){i.forEach(function(o){var a=o[t.children];a&&(n.push(o[t.value]),r(a))})}return r(e),n}function Gl(e){return e==null}var eD={width:0,height:0,display:"flex",overflow:"hidden",opacity:0,border:0,padding:0,margin:0},tD=function(t,n){var r=Gd(),i=r.prefixCls,o=r.multiple,a=r.searchValue,s=r.toggleOpen,u=r.open,c=r.notFoundContent,f=T.useContext(Jh),h=f.virtual,p=f.listHeight,g=f.listItemHeight,v=f.treeData,m=f.fieldNames,w=f.onSelect,b=f.dropdownMatchSelectWidth,_=f.treeExpandAction,C=T.useContext(Zh),S=C.checkable,E=C.checkedKeys,k=C.halfCheckedKeys,A=C.treeExpandedKeys,L=C.treeDefaultExpandAll,F=C.treeDefaultExpandedKeys,P=C.onTreeExpand,O=C.treeIcon,N=C.showTreeIcon,z=C.switcherIcon,M=C.treeLine,$=C.treeNodeFilterProp,I=C.loadData,R=C.treeLoadedKeys,B=C.treeMotion,G=C.onTreeLoad,K=C.keyEntities,W=T.useRef(),ee=Gs(function(){return v},[u,v],function(Ee,Fe){return Fe[0]&&Ee[1]!==Fe[1]}),ne=T.useMemo(function(){return S?{checked:E,halfChecked:k}:null},[S,E,k]);T.useEffect(function(){if(u&&!o&&E.length){var Ee;(Ee=W.current)===null||Ee===void 0||Ee.scrollTo({key:E[0]})}},[u]);var U=String(a).toLowerCase(),X=function(Fe){return U?String(Fe[$]).toLowerCase().includes(U):!1},ce=T.useState(F),ue=dr(ce,2),se=ue[0],ae=ue[1],xe=T.useState(null),be=dr(xe,2),Y=be[0],re=be[1],Se=T.useMemo(function(){return A?cr(A):a?Y:se},[se,Y,A,a]);T.useEffect(function(){a&&re(JO(v,m))},[a]);var q=function(Fe){ae(Fe),re(Fe),P&&P(Fe)},we=function(Fe){Fe.preventDefault()},ve=function(Fe,Le){var Ve=Le.node;S&&jl(Ve)||(w(Ve.key,{selected:!E.includes(Ve.key)}),o||s(!1))},_e=T.useState(null),ke=dr(_e,2),ge=ke[0],Ke=ke[1],Pe=K[ge];if(T.useImperativeHandle(n,function(){var Ee;return{scrollTo:(Ee=W.current)===null||Ee===void 0?void 0:Ee.scrollTo,onKeyDown:function(Le){var Ve,ct=Le.which;switch(ct){case oe.UP:case oe.DOWN:case oe.LEFT:case oe.RIGHT:(Ve=W.current)===null||Ve===void 0||Ve.onKeyDown(Le);break;case oe.ENTER:{if(Pe){var at=(Pe==null?void 0:Pe.node)||{},We=at.selectable,st=at.value;We!==!1&&ve(null,{node:{key:ge},selected:!E.includes(st)})}break}case oe.ESC:s(!1)}},onKeyUp:function(){}}}),ee.length===0)return l("div",{role:"listbox",className:"".concat(i,"-empty"),onMouseDown:we,children:c});var Xe={fieldNames:m};return R&&(Xe.loadedKeys=R),Se&&(Xe.expandedKeys=Se),y("div",{onMouseDown:we,children:[Pe&&u&&l("span",{style:eD,"aria-live":"assertive",children:Pe.node.value}),l(Bl,{ref:W,focusable:!1,prefixCls:"".concat(i,"-tree"),treeData:ee,height:p,itemHeight:g,virtual:h!==!1&&b!==!1,multiple:o,icon:O,showIcon:N,switcherIcon:z,showLine:M,loadData:a?null:I,motion:B,activeKey:ge,checkable:S,checkStrictly:!0,checkedKeys:ne,selectedKeys:S?[]:E,defaultExpandAll:L,...Xe,onActiveChange:Ke,onSelect:ve,onCheck:ve,onExpand:q,onLoad:G,filterTreeNode:X,expandAction:_})]})},tg=T.forwardRef(tD);tg.displayName="OptionList";var ng=function(){return null},nD="SHOW_ALL",Kl="SHOW_PARENT",Hl="SHOW_CHILD";function rg(e,t,n,r){var i=new Set(e);return t===Hl?e.filter(function(o){var a=n[o];return!(a&&a.children&&a.children.some(function(s){var u=s.node;return i.has(u[r.value])})&&a.children.every(function(s){var u=s.node;return jl(u)||i.has(u[r.value])}))}):t===Kl?e.filter(function(o){var a=n[o],s=a?a.parent:null;return!(s&&!jl(s.node)&&i.has(s.key))}):e}var rD=["children","value"];function ig(e){return pr(e).map(function(t){if(!T.isValidElement(t)||!t.type)return null;var n=t,r=n.key,i=n.props,o=i.children,a=i.value,s=Td(i,rD),u=yn({key:r,value:a},s),c=ig(o);return c.length&&(u.children=c),u}).filter(function(t){return t})}function Wl(e){if(!e)return e;var t=yn({},e);return"props"in t||Object.defineProperty(t,"props",{get:function(){return it(!1,"New `rc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access."),t}}),t}function iD(e,t,n,r,i,o){var a=null,s=null;function u(){function c(f){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"0",p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return f.map(function(g,v){var m="".concat(h,"-").concat(v),w=g[o.value],b=n.includes(w),_=c(g[o.children]||[],m,b),C=l(ng,{...g,children:_.map(function(E){return E.node})});if(t===w&&(a=C),b){var S={pos:m,node:C,children:_};return p||s.push(S),S}return null}).filter(function(g){return g})}s||(s=[],c(r),s.sort(function(f,h){var p=f.node.props.value,g=h.node.props.value,v=n.indexOf(p),m=n.indexOf(g);return v-m}))}Object.defineProperty(e,"triggerNode",{get:function(){return it(!1,"`triggerNode` is deprecated. Please consider decoupling data with node."),u(),a}}),Object.defineProperty(e,"allCheckedNodes",{get:function(){return it(!1,"`allCheckedNodes` is deprecated. Please consider decoupling data with node."),u(),i?s:s.map(function(f){var h=f.node;return h})}})}function oD(e,t){var n=t.id,r=t.pId,i=t.rootPId,o={},a=[],s=e.map(function(u){var c=yn({},u),f=c[n];return o[f]=c,c.key=c.key||f,c});return s.forEach(function(u){var c=u[r],f=o[c];f&&(f.children=f.children||[],f.children.push(u)),(c===i||!f&&i===null)&&a.push(u)}),a}function aD(e,t,n){return T.useMemo(function(){return e?n?oD(e,yn({id:"id",pId:"pId",rootPId:null},n!==!0?n:{})):e:ig(t)},[t,n,e])}const sD=function(e){var t=T.useRef({valueLabels:new Map});return T.useMemo(function(){var n=t.current.valueLabels,r=new Map,i=e.map(function(o){var a,s=o.value,u=(a=o.label)!==null&&a!==void 0?a:n.get(s);return r.set(s,u),yn(yn({},o),{},{label:u})});return t.current.valueLabels=r,[i]},[e])};function og(e){var t=T.useRef();t.current=e;var n=T.useCallback(function(){return t.current.apply(t,arguments)},[]);return n}const lD=function(e,t){return T.useMemo(function(){var n=$h(e,{fieldNames:t,initWrapper:function(i){return yn(yn({},i),{},{valueEntities:new Map})},processEntity:function(i,o){var a=i.node[t.value];if(process.env.NODE_ENV!=="production"){var s=i.node.key;it(!Gl(a),"TreeNode `value` is invalidate: undefined"),it(!o.valueEntities.has(a),"Same `value` exist in the tree: ".concat(a)),it(!s||String(s)===String(a),"`key` or `value` with TreeNode must be the same or you can remove one of them. key: ".concat(s,", value: ").concat(a,"."))}o.valueEntities.set(a,i)}});return n},[e,t])},uD=function(e,t,n,r){return T.useMemo(function(){var i=e.map(function(u){var c=u.value;return c}),o=t.map(function(u){var c=u.value;return c}),a=i.filter(function(u){return!r[u]});if(n){var s=fi(i,!0,r);i=s.checkedKeys,o=s.halfCheckedKeys}return[Array.from(new Set([].concat(cr(a),cr(i)))),o]},[e,t,n,r])},cD=function(e,t,n){var r=n.treeNodeFilterProp,i=n.filterTreeNode,o=n.fieldNames,a=o.children;return T.useMemo(function(){if(!t||i===!1)return e;var s;if(typeof i=="function")s=i;else{var u=t.toUpperCase();s=function(h,p){var g=p[r];return String(g).toUpperCase().includes(u)}}function c(f){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return f.map(function(p){var g=p[a],v=h||s(t,Wl(p)),m=c(g||[],v);return v||m.length?yn(yn({},p),{},_d({isLeaf:void 0},a,m)):null}).filter(function(p){return p})}return c(e)},[e,t,a,r,i])};function dD(e){var t=e.searchPlaceholder,n=e.treeCheckStrictly,r=e.treeCheckable,i=e.labelInValue,o=e.value,a=e.multiple;it(!t,"`searchPlaceholder` has been removed."),n&&i===!1&&it(!1,"`treeCheckStrictly` will force set `labelInValue` to `true`."),(i||n)&&it(eg(o).every(function(s){return s&&Rr(s)==="object"&&"value"in s}),"Invalid prop `value` supplied to `TreeSelect`. You should use { label: string, value: string | number } or [{ label: string, value: string | number }] instead."),n||a||r?it(!o||Array.isArray(o),"`value` should be an array when `TreeSelect` is checkable or multiple."):it(!Array.isArray(o),"`value` should not be array when `TreeSelect` is single mode.")}var fD=["id","prefixCls","value","defaultValue","onChange","onSelect","onDeselect","searchValue","inputValue","onSearch","autoClearSearchValue","filterTreeNode","treeNodeFilterProp","showCheckedStrategy","treeNodeLabelProp","multiple","treeCheckable","treeCheckStrictly","labelInValue","fieldNames","treeDataSimpleMode","treeData","children","loadData","treeLoadedKeys","onTreeLoad","treeDefaultExpandAll","treeExpandedKeys","treeDefaultExpandedKeys","onTreeExpand","treeExpandAction","virtual","listHeight","listItemHeight","onDropdownVisibleChange","dropdownMatchSelectWidth","treeLine","treeIcon","showTreeIcon","switcherIcon","treeMotion"];function pD(e){return!e||Rr(e)!=="object"}var ag=T.forwardRef(function(e,t){var n=e.id,r=e.prefixCls,i=r===void 0?"rc-tree-select":r,o=e.value,a=e.defaultValue,s=e.onChange,u=e.onSelect,c=e.onDeselect,f=e.searchValue,h=e.inputValue,p=e.onSearch,g=e.autoClearSearchValue,v=g===void 0?!0:g,m=e.filterTreeNode,w=e.treeNodeFilterProp,b=w===void 0?"value":w,_=e.showCheckedStrategy,C=_===void 0?Hl:_,S=e.treeNodeLabelProp,E=e.multiple,k=e.treeCheckable,A=e.treeCheckStrictly,L=e.labelInValue,F=e.fieldNames,P=e.treeDataSimpleMode,O=e.treeData,N=e.children,z=e.loadData,M=e.treeLoadedKeys,$=e.onTreeLoad,I=e.treeDefaultExpandAll,R=e.treeExpandedKeys,B=e.treeDefaultExpandedKeys,G=e.onTreeExpand,K=e.treeExpandAction,W=e.virtual,ee=e.listHeight,ne=ee===void 0?200:ee,U=e.listItemHeight,X=U===void 0?20:U,ce=e.onDropdownVisibleChange,ue=e.dropdownMatchSelectWidth,se=ue===void 0?!0:ue,ae=e.treeLine,xe=e.treeIcon,be=e.showTreeIcon,Y=e.switcherIcon,re=e.treeMotion,Se=Td(e,fD),q=lh(n),we=k&&!A,ve=k||A,_e=A||L,ke=ve||E,ge=zi(a,{value:o}),Ke=dr(ge,2),Pe=Ke[0],Xe=Ke[1];process.env.NODE_ENV!=="production"&&dD(e);var Ee=T.useMemo(function(){return ZO(F)},[JSON.stringify(F)]),Fe=zi("",{value:f!==void 0?f:h,postState:function(he){return he||""}}),Le=dr(Fe,2),Ve=Le[0],ct=Le[1],at=function(he){ct(he),p==null||p(he)},We=aD(O,N,P),st=lD(We,Ee),Ce=st.keyEntities,Ie=st.valueEntities,et=T.useCallback(function(Q){var he=[],ye=[];return Q.forEach(function(Te){Ie.has(Te)?ye.push(Te):he.push(Te)}),{missingRawValues:he,existRawValues:ye}},[Ie]),Mt=cD(We,Ve,{fieldNames:Ee,treeNodeFilterProp:b,filterTreeNode:m}),lt=T.useCallback(function(Q){if(Q){if(S)return Q[S];for(var he=Ee._title,ye=0;ye<he.length;ye+=1){var Te=Q[he[ye]];if(Te!==void 0)return Te}}},[Ee,S]),kt=T.useCallback(function(Q){var he=eg(Q);return he.map(function(ye){return pD(ye)?{value:ye}:ye})},[]),dt=T.useCallback(function(Q){var he=kt(Q);return he.map(function(ye){var Te=ye.label,Ne=ye.value,De=ye.halfChecked,Ge,ze=Ie.get(Ne);if(ze){var qe;Te=(qe=Te)!==null&&qe!==void 0?qe:lt(ze.node),Ge=ze.node.disabled}else if(Te===void 0){var Ct=kt(Pe).find(function(rn){return rn.value===Ne});Te=Ct.label}return{label:Te,value:Ne,halfChecked:De,disabled:Ge}})},[Ie,lt,kt,Pe]),Gt=T.useMemo(function(){return kt(Pe)},[kt,Pe]),Ot=T.useMemo(function(){var Q=[],he=[];return Gt.forEach(function(ye){ye.halfChecked?he.push(ye):Q.push(ye)}),[Q,he]},[Gt]),bt=dr(Ot,2),_t=bt[0],Ht=bt[1],vt=T.useMemo(function(){return _t.map(function(Q){return Q.value})},[_t]),cn=uD(_t,Ht,we,Ce),Vt=dr(cn,2),ie=Vt[0],pe=Vt[1],me=T.useMemo(function(){var Q=rg(ie,C,Ce,Ee),he=Q.map(function(De){var Ge,ze,qe;return(Ge=(ze=Ce[De])===null||ze===void 0||(qe=ze.node)===null||qe===void 0?void 0:qe[Ee.value])!==null&&Ge!==void 0?Ge:De}),ye=he.map(function(De){var Ge=_t.find(function(ze){return ze.value===De});return{value:De,label:Ge==null?void 0:Ge.label}}),Te=dt(ye),Ne=Te[0];return!ke&&Ne&&Gl(Ne.value)&&Gl(Ne.label)?[]:Te.map(function(De){var Ge;return yn(yn({},De),{},{label:(Ge=De.label)!==null&&Ge!==void 0?Ge:De.value})})},[Ee,ke,ie,_t,dt,C,Ce]),Ae=sD(me),Qe=dr(Ae,1),ft=Qe[0],Wt=og(function(Q,he,ye){var Te=dt(Q);if(Xe(Te),v&&ct(""),s){var Ne=Q;if(we){var De=rg(Q,C,Ce,Ee);Ne=De.map(function(an){var sn=Ie.get(an);return sn?sn.node[Ee.value]:an})}var Ge=he||{triggerValue:void 0,selected:void 0},ze=Ge.triggerValue,qe=Ge.selected,Ct=Ne;if(A){var rn=Ht.filter(function(an){return!Ne.includes(an.value)});Ct=[].concat(cr(Ct),cr(rn))}var vn=dt(Ct),Dt={preValue:_t,triggerValue:ze},Gn=!0;(A||ye==="selection"&&!qe)&&(Gn=!1),iD(Dt,ze,Q,We,Gn,Ee),ve?Dt.checked=qe:Dt.selected=qe;var lr=_e?vn:vn.map(function(an){return an.value});s(ke?lr:lr[0],_e?null:vn.map(function(an){return an.label}),Dt)}}),qt=T.useCallback(function(Q,he){var ye,Te=he.selected,Ne=he.source,De=Ce[Q],Ge=De==null?void 0:De.node,ze=(ye=Ge==null?void 0:Ge[Ee.value])!==null&&ye!==void 0?ye:Q;if(!ke)Wt([ze],{selected:!0,triggerValue:ze},"option");else{var qe=Te?[].concat(cr(vt),[ze]):ie.filter(function(sn){return sn!==ze});if(we){var Ct=et(qe),rn=Ct.missingRawValues,vn=Ct.existRawValues,Dt=vn.map(function(sn){return Ie.get(sn).key}),Gn;if(Te){var lr=fi(Dt,!0,Ce);Gn=lr.checkedKeys}else{var an=fi(Dt,{checked:!1,halfCheckedKeys:pe},Ce);Gn=an.checkedKeys}qe=[].concat(cr(rn),cr(Gn.map(function(sn){return Ce[sn].node[Ee.value]})))}Wt(qe,{selected:Te,triggerValue:ze},Ne||"option")}Te||!ke?u==null||u(ze,Wl(Ge)):c==null||c(ze,Wl(Ge))},[et,Ie,Ce,Ee,ke,vt,Wt,we,u,c,ie,pe]),dn=T.useCallback(function(Q){if(ce){var he={};Object.defineProperty(he,"documentClickClose",{get:function(){return it(!1,"Second param of `onDropdownVisibleChange` has been removed."),!1}}),ce(Q,he)}},[ce]),xt=og(function(Q,he){var ye=Q.map(function(Te){return Te.value});if(he.type==="clear"){Wt(ye,{},"selection");return}he.values.length&&qt(he.values[0].value,{selected:!1,source:"selection"})}),V=T.useMemo(function(){return{virtual:W,dropdownMatchSelectWidth:se,listHeight:ne,listItemHeight:X,treeData:Mt,fieldNames:Ee,onSelect:qt,treeExpandAction:K}},[W,se,ne,X,Mt,Ee,qt,K]),J=T.useMemo(function(){return{checkable:ve,loadData:z,treeLoadedKeys:M,onTreeLoad:$,checkedKeys:ie,halfCheckedKeys:pe,treeDefaultExpandAll:I,treeExpandedKeys:R,treeDefaultExpandedKeys:B,onTreeExpand:G,treeIcon:xe,treeMotion:re,showTreeIcon:be,switcherIcon:Y,treeLine:ae,treeNodeFilterProp:b,keyEntities:Ce}},[ve,z,M,$,ie,pe,I,R,B,G,xe,re,be,Y,ae,b,Ce]);return l(Jh.Provider,{value:V,children:l(Zh.Provider,{value:J,children:l(Ol,{ref:t,...Se,id:q,prefixCls:i,mode:ke?"multiple":void 0,displayValues:ft,onDisplayValuesChange:xt,searchValue:Ve,onSearch:at,OptionList:tg,emptyOptions:!We.length,onDropdownVisibleChange:dn,dropdownMatchSelectWidth:se})})})});process.env.NODE_ENV!=="production"&&(ag.displayName="TreeSelect");var ro=ag;ro.TreeNode=ng,ro.SHOW_ALL=nD,ro.SHOW_PARENT=Kl,ro.SHOW_CHILD=Hl;const hD=({rotate:e,onClick:t})=>l("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:l("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"})}),gD=({expanded:e,isLeaf:t,value:n,onClick:r,...i})=>(n==="0-0-value"&&console.log(i),t?l("span",{style:{width:"14px",display:"inline-block"}}):l(hD,{rotate:e?"0":"-90",onClick:r,...i})),vD=({onClick:e})=>y("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:[l("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),l("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),l("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),l("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),mD=({onClick:e,...t})=>l(vD,{onClick:e,...t}),yD=d.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"},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"}}}})),bD=({disabled:e,classNames:t,styles:n,unstyled:r,radius:i,style:o,label:a,value:s,onChange:u,treeData:c})=>{const{classes:f,cx:h}=yD({radius:i},{name:"FilterTreeSelectWidget",classNames:t,styles:n,unstyled:r}),[p,g]=x.useState((s==null?void 0:s.length)>0),v=w=>{g(w)},m=p&&(s==null?void 0:s.length)>0;return y(d.Stack,{spacing:3,children:[y(d.Group,{position:"apart",children:[l(d.Text,{className:f.label,children:a}),m&&l(d.Tooltip,{label:`${s.length} selected`,children:l(d.Badge,{children:s.length})})]}),l(ro,{disabled:e,allowClear:!0,className:h(f.root,"check-select"),dropdownClassName:h(f.dropdown,""),onDropdownVisibleChange:v,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,treeLine:!0,clearIcon:()=>l(d.CloseButton,{}),switcherIcon:gD,treeIcon:mD,maxTagTextLength:10,value:s,treeData:c,treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:Kl,onChange:u,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:w=>`${w.length} selected`})]})};function wD(e){return e.map(t=>{const{label:n,description:r,...i}=t,o={...i,filterBasis:`${n}___${r!=null?r:""}`,description:r,label:n};return r&&(o.label=y("div",{children:[l(d.Text,{title:t.label,children:t.label}),l(d.Text,{className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description,children:t.description})]})),o})}const xD=te.observer(({label:e,config:t,value:n,onChange:r})=>{const i=$e(),{state:o,dataProxy:a,len:s}=i.getDataStuffByID(t.options_query_id),u=o==="loading",c=x.useMemo(()=>{if(!a)return[];const g=[...a],v=wD(g);return L0(v)},[a,s]);x.useEffect(()=>{const{default_selection_count:g}=t;if(!g)return;if(c.length===0){console.log("[filter.tree-select] Resetting to empty"),r([],!0);return}const v=c.slice(0,g).map(m=>m.value);console.log(`[filter.tree-select] Selecting first ${g} option(s)`),r(v,!0)},[t.default_selection_count,c]);const f=t.min_width?t.min_width:"200px",p=!!t.options_query_id?u:!1;return l(bD,{disabled:p,style:{minWidth:f,maxWidth:p?f:"unset",borderColor:"#e9ecef"},value:n,onChange:g=>r(g,!1),treeData:c,label:e})}),SD=te.observer(({filter:{type:e,config:t,key:n,...r},formFieldProps:i})=>{switch(e){case"select":return l(N0,{...r,...i,config:t});case"multi-select":return l(I0,{...r,...i,config:t});case"tree-select":return l(xD,{...r,...i,config:t});case"text-input":return l($0,{...r,...i,config:t});case"date-range":return l(yd,{...r,...i,config:t});case"checkbox":return l(R0,{...r,...i,config:t});default:return null}}),sg=te.observer(Z.default.forwardRef(({filter:e,...t},n)=>l("div",{className:"filter-root",ref:n,children:l(Or,{children:l(SD,{filter:e,formFieldProps:t})})}))),lg=te.observer(function({view:t}){const n=$e(),{control:r,handleSubmit:i,reset:o}=j.useForm({defaultValues:n.filters.values,reValidateMode:"onBlur"}),a=j.useWatch({control:r});x.useEffect(()=>{o(n.filters.values)},[n.filters.values,o]),x.useEffect(()=>{n.filters.updatePreviewValues(a)},[a]);const s=n.filters.visibleInView(t.id),u=x.useMemo(()=>s.every(p=>p.should_auto_submit),[s]),c=x.useMemo(()=>s.filter(p=>fe.default.get(p,"config.required",!1)),[s]),f=x.useMemo(()=>c.length===0?!1:c.some(p=>!p.requiredAndPass(a[p.key])),[a,c]);if(s.length===0)return null;const h=(p,g)=>(v,m)=>{g(v),(p.should_auto_submit||m)&&n.filters.setValueByKey(p.key,v)};return l("form",{onSubmit:i(n.filters.setValues),children:y(d.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:u?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[l(d.Group,{align:"flex-start",children:s.map(p=>l(j.Controller,{name:p.key,control:r,render:({field:g})=>l(sg,{filter:p,value:g.value,onChange:h(p,g.onChange)})},p.id))}),!u&&l(d.Group,{sx:{alignSelf:"flex-end"},children:l(d.Button,{color:"blue",size:"sm",type:"submit",disabled:f,children:"Search"})})]})})}),h6="",ug=Jt.Mark.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["span",Jt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:e,commands:t})=>{const n=Jt.getMarkAttributes(e,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:t.unsetMark(this.name)}}}}),cg=Jt.Extension.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;return(t=e.style.color)===null||t===void 0?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),CD=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))$/,_D=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))/g,dg=Jt.Mark.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",Jt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Jt.markInputRule({find:CD,type:this.type})]},addPasteRules(){return[Jt.markPasteRule({find:_D,type:this.type})]}}),fg=Jt.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new h0.Plugin({props:{decorations:({doc:e,selection:t})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,i=[];if(!n)return null;const o=e.type.createAndFill(),a=(o==null?void 0:o.sameMarkup(e))&&o.content.findDiffStart(e.content)===null;return e.descendants((s,u)=>{const c=r>=u&&r<=u+s.nodeSize,f=!s.isLeaf&&!s.childCount;if((c||!this.options.showOnlyCurrent)&&f){const h=[this.options.emptyNodeClass];a&&h.push(this.options.emptyEditorClass);const p=sd.Decoration.node(u,u+s.nodeSize,{class:h.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:u,hasAnchor:c}):this.options.placeholder});i.push(p)}return this.options.includeChildren}),sd.DecorationSet.create(e,i)}}})]}}),pg=Jt.Mark.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(e){return e!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sub",Jt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),hg=Jt.Mark.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(e){return e!=="super"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sup",Jt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),gg=Jt.Extension.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:"left"}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>e.style.textAlign||this.options.defaultAlignment,renderHTML:e=>e.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.every(n=>t.updateAttributes(n,{textAlign:e})):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.every(t=>e.resetAttributes(t,"textAlign"))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),vg=Jt.Mark.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",Jt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),ql={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"\u25BA"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"}},mg=({value:e,styles:t={}})=>{const n=ld.useEditor({extensions:[cd.default,vg,nt.Link,hg,pg,dg,gg.configure({types:["heading","paragraph"]}),fg.configure({placeholder:"This is placeholder"}),ug,cg],content:e,editable:!1}),r=x.useMemo(()=>fe.default.defaultsDeep({},{content:ql},t),[t]);return l(nt.RichTextEditor,{editor:n,styles:r,children:l(nt.RichTextEditor.Content,{})})};function ED(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const yg=te.observer(()=>{const{freezeLayout:e}=Z.default.useContext(Dr),[t,n]=Z.default.useState(!1),{panel:r}=Yt();return Z.default.useEffect(()=>{e(t)},[t]),ED(r.description)?null:y(Oe,{children:[l(d.Modal,{opened:t,onClose:()=>n(!1),title:r.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:l(mg,{value:r.description,styles:{root:{border:"none"},content:{padding:0}}})}),l(d.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:l(d.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:l(le.InfoCircle,{size:20})})})]})}),TD=te.observer(({view:e})=>{const t=$e(),n=Kn.useModals(),{panel:r}=Yt(),{id:i,query:o}=r,{inEditMode:a}=Z.default.useContext(Dr),s=()=>o==null?void 0:o.fetchData(),{viewPanelInFullScreen:u,inFullScreen:c}=Z.default.useContext(Is),f=()=>{e.panels.duplicateByID(i)},h=()=>{t.editor.open(["_VIEWS_",e.id,"_PANELS_",i])},p=()=>n.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>e.panels.removeByID(i),confirmProps:{color:"red"},zIndex:320}),g=Z.default.useCallback(()=>{u(i)},[i,u]),v=!c&&e.type!==rt.Modal;return l(Oe,{children:l(d.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:y(d.Menu,{withinPortal:!0,children:[l(d.Menu.Target,{children:l(d.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),y(d.Menu.Dropdown,{children:[l(d.Menu.Item,{onClick:s,icon:l(le.Refresh,{size:14}),children:"Refresh"}),l(d.Menu.Item,{onClick:()=>{var m;return t.queries.downloadDataByQueryID((m=o==null?void 0:o.id)!=null?m:"")},icon:l(le.Download,{size:14}),children:"Download Data"}),v&&l(d.Menu.Item,{onClick:g,icon:l(le.ArrowsMaximize,{size:14}),disabled:a,children:"Full Screen"}),a&&y(Oe,{children:[l(d.Divider,{label:"Edit",labelPosition:"center"}),l(d.Menu.Item,{onClick:h,icon:l(le.Settings,{size:14}),children:"Settings"}),l(d.Menu.Item,{onClick:f,icon:l(le.Copy,{size:14}),children:"Duplicate"}),l(d.Menu.Item,{color:"red",onClick:p,icon:l(le.Trash,{size:14}),children:"Delete"})]})]})]})})})}),g6="",MD=te.observer(function(){const{panel:t}=Yt(),{title:n}=t;return n?l(d.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:l(d.Text,{align:"center",lineClamp:1,weight:"bold",children:n})}):null}),gi=(e,t)=>{const[n,r]=x.useState([]);return x.useEffect(()=>e.watchTriggerSnapshotList(i=>r(i.filter(o=>o.schemaRef===t))),[]),n};class vi{constructor(t,n){this.root=t,this.path=n}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const n=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,H.omit(n,t))}async getItem(t){const n=await this.root.getItem(this.path);return t===null?n:H.get(n,t)}async setItem(t,n){if(t===null)await this.root.setItem(this.path,n);else{const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...r,[t]:n})}return await this.getItem(t)}watchItem(t,n,r){return t===null?this.root.watchItem(this.path,(i,o)=>{n(i,o)},r):this.root.watchItem(this.path,(i,o)=>{const a=H.get(i,t),s=H.get(o,t);a!==s&&n(a,s)},r)}}class Ul{constructor(t,n,r){Re(this,"attachmentStorage");this.instance=t,this.attachmentKey=n,this.constructInstance=r,this.attachmentStorage=new vi(t.instanceData,n)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new vi(this.attachmentStorage,t))}async create(t,n){return await this.attachmentStorage.setItem(t,n),this.constructInstance(new vi(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(H.values(t).map(n=>this.constructInstance(new vi(this.attachmentStorage,n.id))))}}class bg{constructor(t){Re(this,"rootRef");this.rootRef=Ft.observable({current:t})}async deleteItem(t){Ft.runInAction(()=>{H.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?Ft.toJS(this.rootRef.current):H.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(H.isObject(n))Ft.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else Ft.runInAction(()=>{H.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return Ft.reaction(()=>this.getValueFromRoot(t),(i,o)=>{n(i,o)},{requiresObservable:!0,fireImmediately:H.get(r,"fireImmediately",!1)})}}class kD{constructor(){Re(this,"channels",new Map);Re(this,"globalChannel",new dd.default)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new dd.default;return this.channels.set(t,r),r}}class OD{constructor(t){Re(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const r={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new kD,instanceData:new bg(t.viz.conf)};return this.instances.set(t.id,r),r}}function wg(e,t,n,r){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new bg({}),colorPalette:{getColor(){return()=>""}},data:t,variables:r}}const DD=e=>{const{panel:t,vizManager:n,data:r,variables:i}=e,o=n.resolveComponent(t.viz.type),a=n.getOrCreateInstance(t),s={...wg(a,r,n,i),viewport:{width:t.layout.w,height:t.layout.h}},u=o.viewRender;return l(u,{context:s,instance:a,...H.omit(e,["panel","vizManager","data"])})},RD=e=>{const{vizManager:t,panel:n,panelInfoEditor:r,data:i,variables:o}=e,a=t.resolveComponent(n.viz.type),s=t.getOrCreateInstance(n),u={...wg(s,i,t,o),panelInfoEditor:r},c=a.configRender;return l(c,{context:u,instance:s,...H.omit(e,["panel","vizManager","data","panelInfoEditor"])})},xg=(e,t)=>{const n=$i.default.bezier(e),r=$i.default.bezier(t);return function(i){return i<50?n(i*2/100).hex():r((i-50)*2/100).hex()}},_a=e=>{const t=$i.default.bezier(e);return function(n){return t(n/100).hex()}},AD={type:"interpolation",displayName:"Red / Green",getColor:xg(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},PD={type:"interpolation",displayName:"Yellow / Blue",getColor:xg(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},ID={type:"interpolation",displayName:"Red",getColor:_a(["#fff7f1","darkred"]),name:"red",category:"sequential"},ND={type:"interpolation",displayName:"Green",getColor:_a(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},$D={type:"interpolation",displayName:"Blue",getColor:_a(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},LD={type:"interpolation",displayName:"Orange",getColor:_a(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},Sg="@devtable/dashboard",Yl="8.13.5",Cg="Apache-2.0",_g={access:"public",registry:"https://registry.npmjs.org/"},Eg=["dist"],Tg="./dist/dashboard.umd.js",Mg="./dist/dashboard.es.js",kg="./dist/index.d.ts",Og={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Dg={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},Rg={"@monaco-editor/react":"4.4.6","@types/chroma-js":"^2.1.4","file-saver":"2.0.5","monaco-editor":"0.36.0","performant-array-to-tree":"1.11.0",popmotion:"^11.0.3","rc-tree-select":"5.5.5",reactflow:"^11.5.3"},Ag={"@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@testing-library/cypress":"^8.0.3","@testing-library/jest-dom":"^5.16.4","@testing-library/react":"^13.3.0","@testing-library/react-hooks":"^8.0.1","@testing-library/user-event":"^14.3.0","@tiptap/extension-code-block-lowlight":"^2.0.0-beta.209","@tiptap/extension-color":"^2.0.0-beta.209","@tiptap/extension-highlight":"^2.0.0-beta.209","@tiptap/extension-link":"^2.0.0-beta.209","@tiptap/extension-placeholder":"^2.0.0-beta.209","@tiptap/extension-subscript":"^2.0.0-beta.209","@tiptap/extension-superscript":"^2.0.0-beta.209","@tiptap/extension-text-align":"^2.0.0-beta.209","@tiptap/extension-text-style":"^2.0.0-beta.209","@tiptap/extension-underline":"^2.0.0-beta.209","@tiptap/react":"^2.0.0-beta.209","@tiptap/starter-kit":"^2.0.0-beta.209","@types/crypto-js":"v4.1.1","@types/d3-array":"3.0.3","@types/eventemitter2":"^4.1.0","@types/file-saver":"2.0.5","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2",ahooks:"^3.3.11",ajv:"8.11.0",axios:"^0.27.2","crypto-js":"^4.1.1",cypress:"^10.6.0","cypress-wait-until":"^1.7.2",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9","echarts-stat":"1.2.0",jsdom:"^20.0.0","jsdom-testing-mocks":"^1.5.0",lodash:"^4.17.21",lowlight:"^2.8.0",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","rollup-plugin-visualizer":"5.6.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3","vite-plugin-static-copy":"0.13.1"},Pg={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@tanstack/react-table":"^8.5.13","@tiptap/extension-code-block-lowlight":"^2.0.0-beta.209","@tiptap/extension-color":"^2.0.0-beta.209","@tiptap/extension-highlight":"^2.0.0-beta.209","@tiptap/extension-link":"^2.0.0-beta.209","@tiptap/extension-placeholder":"^2.0.0-beta.209","@tiptap/extension-subscript":"^2.0.0-beta.209","@tiptap/extension-superscript":"^2.0.0-beta.209","@tiptap/extension-text-align":"^2.0.0-beta.209","@tiptap/extension-text-style":"^2.0.0-beta.209","@tiptap/extension-underline":"^2.0.0-beta.209","@tiptap/react":"^2.0.0-beta.209","@tiptap/starter-kit":"^2.0.0-beta.209",ahooks:"^3.3.11",axios:"^0.27.2","chroma-js":"^2.4.2","d3-array":"3.2.0","d3-regression":"1.2.8",dayjs:"1.11.6",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9","echarts-stat":"1.2.0",eventemitter2:"^6.4.6",jszip:"3.10.1",lodash:"^4.17.21",lowlight:"^2.8.0",mobx:"^6.6.1","mobx-react-lite":"^3.4.0","mobx-state-tree":"^5.1.5",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","react-virtual":"^2.10.4","tabler-icons-react":"^1.48.0"},VD=Object.freeze(Object.defineProperty({__proto__:null,name:Sg,version:Yl,license:Cg,publishConfig:_g,files:Eg,main:Tg,module:Mg,types:kg,exports:Og,scripts:Dg,dependencies:Rg,devDependencies:Ag,peerDependencies:Pg,default:{name:Sg,version:Yl,license:Cg,publishConfig:_g,files:Eg,main:Tg,module:Mg,types:kg,exports:Og,scripts:Dg,dependencies:Rg,devDependencies:Ag,peerDependencies:Pg}},Symbol.toStringTag,{value:"Module"}));class zD{constructor(t){Re(this,"staticColors",new Map);Re(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class FD{constructor(){Re(this,"plugins",new Map);Re(this,"vizComponents",new Map);Re(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 BD{constructor(){Re(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,r){var a;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(s=>s.version>t.from&&s.version<=t.to),o=H.orderBy(i,"version","asc");if(((a=H.last(o))==null?void 0:a.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((s,u)=>u.handler(s,r),n)}}class tn extends BD{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(r,i)=>({version:t,...n(r,i)}))}async migrate({configData:t,panelModel:n}){const r=await t.getItem(null),i=H.get(r,"version",0),o=this.run({from:i,to:this.VERSION},r,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return H.get(n,"version",0)<this.VERSION}}const Je=(e,t)=>{const[n,{setFalse:r}]=tt.useBoolean(!0),[i,o]=x.useState();x.useEffect(()=>(e.getItem(t).then(s=>{o(s),r()}),e.watchItem(t,s=>{o(s)})));const a=x.useCallback(async s=>{await e.setItem(t,s),o(s)},[e,t]);return{loading:n,value:i,set:a}},Xl={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};Rt.use([ut.GridComponent,ut.VisualMapComponent,ut.LegendComponent,ut.TooltipComponent,Hn.CanvasRenderer]);function jD({context:e}){const{value:t}=Je(e.instanceData,"config"),n=e.data,{width:r,height:i}=e.viewport,{x_axis_data_key:o,y_axis_data_key:a,z_axis_data_key:s,xAxis3D:u,yAxis3D:c,zAxis3D:f}=H.defaults({},t,Xl),h=x.useMemo(()=>{const v=H.minBy(n,m=>m[s]);return H.get(v,s)},[n,s]),p=x.useMemo(()=>{const v=H.maxBy(n,m=>m[s]);return H.get(v,s)},[n,s]),g={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:h,max:p,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:c,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:n.map(v=>[v[o],v[a],v[s]])}]};return t?l(Wn.default,{echarts:Rt,option:g,style:{width:r,height:i},notMerge:!0}):null}function GD({label:e,required:t,value:n,onChange:r,data:i,clearable:o=!1,sx:a,...s},u){const c=Z.default.useMemo(()=>{if(!Array.isArray(i)||i.length===0)return[];const h=Object.keys(i[0]).map(p=>({label:p,value:p}));return o?h.concat([{label:"unset",value:""}]):h},[i]);return l(d.Select,{ref:u,label:e,data:c,value:n,onChange:r,required:t,sx:a,...s})}const mt=Z.default.forwardRef(GD);function KD({context:e}){const{value:t,set:n}=Je(e.instanceData,"config"),r=e.data,i=H.defaults({},t,Xl),{control:o,handleSubmit:a,reset:s}=j.useForm({defaultValues:i});return x.useEffect(()=>{s(i)},[t]),t?l(d.Stack,{spacing:"xs",children:y("form",{onSubmit:a(n),children:[l(d.Text,{children:"X Axis"}),y(d.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(j.Controller,{name:"x_axis_data_key",control:o,render:({field:u})=>l(mt,{label:"Data Field",required:!0,data:r,...u})}),l(j.Controller,{name:"xAxis3D.name",control:o,render:({field:u})=>l(d.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(d.Text,{mt:"lg",children:"Y Axis"}),y(d.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(j.Controller,{name:"y_axis_data_key",control:o,render:({field:u})=>l(mt,{label:"Data Field",required:!0,data:r,...u})}),l(j.Controller,{name:"yAxis3D.name",control:o,render:({field:u})=>l(d.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(d.Text,{mt:"lg",children:"Z Axis"}),y(d.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(j.Controller,{name:"z_axis_data_key",control:o,render:({field:u})=>l(mt,{label:"Data Field",required:!0,data:r,...u})}),l(j.Controller,{name:"zAxis3D.name",control:o,render:({field:u})=>l(d.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(d.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:y(d.Button,{color:"blue",type:"submit",children:[l(le.DeviceFloppy,{size:20}),l(d.Text,{ml:"md",children:"Save"})]})})]})}):null}class HD extends tn{constructor(){super(...arguments);Re(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const WD={displayName:"Bar Chart (3D)",migrator:new HD,name:"bar-3d",viewRender:jD,configRender:KD,createConfig(){return{version:1,config:H.cloneDeep(Xl)}}},Ln={mantissa:0,output:"number",trimMantissa:!1,average:!1};function qD({value:e,onChange:t},n){const r=s=>{t({...e,output:s})},i=s=>{const u=s===0?!1:e.trimMantissa;t({...e,mantissa:s,trimMantissa:u})},o=s=>{t({...e,trimMantissa:s.currentTarget.checked})},a=s=>{t({...e,average:s.currentTarget.checked})};return y(d.Stack,{ref:n,children:[y(d.Group,{grow:!0,children:[l(d.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:r,sx:{flexGrow:1}}),l(d.Switch,{label:y(d.Stack,{spacing:0,children:[l(d.Text,{children:"Average"}),l(d.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:a,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),y(d.Group,{grow:!0,children:[l(d.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:i}),l(d.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),y(d.Stack,{spacing:0,children:[l(d.Text,{weight:"bold",children:"Preview"}),l(Or,{children:y(d.Group,{position:"apart",children:[y(d.Text,{size:12,color:"gray",children:["123456789 ",l(le.ArrowRight,{size:9})," ",Bt.default(123456789).format(e)]}),y(d.Text,{size:12,color:"gray",children:["1234 ",l(le.ArrowRight,{size:9})," ",Bt.default(1234).format(e)]}),y(d.Text,{size:12,color:"gray",children:["0.1234 ",l(le.ArrowRight,{size:9})," ",Bt.default(.1234).format(e)]})]})})]})]})}const $r=Z.default.forwardRef(qD),Lr={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
75
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function hi(e,t){return BO(e)||jO(e,t)||Dh(e,t)||GO()}var KO=["className","style","motion","motionNodes","motionType","onMotionStart","onMotionEnd","active","treeNodeRequiredProps"],Kh=function(t,n){var r=t.className,i=t.style,o=t.motion,a=t.motionNodes,s=t.motionType,u=t.onMotionStart,c=t.onMotionEnd,f=t.active,h=t.treeNodeRequiredProps,p=Sa(t,KO),g=T.useState(!0),v=hi(g,2),m=v[0],w=v[1],b=T.useContext($l),_=b.prefixCls,C=T.useRef(!1),S=function(){C.current||c(),C.current=!0};return x.useEffect(function(){a&&s==="hide"&&m&&w(!1)},[a]),x.useEffect(function(){return a&&u(),function(){a&&S()}},[]),a?l(na,{ref:n,visible:m,...o,motionAppear:s==="show",onAppearEnd:S,onLeaveEnd:S,children:function(E,k){var A=E.className,L=E.style;return l("div",{ref:k,className:pt("".concat(_,"-treenode-motion"),A),style:L,children:a.map(function(F){var P=wa({},(Gh(F.data),F.data)),O=F.title,N=F.key,z=F.isStart,M=F.isEnd;delete P.children;var $=no(N,h);return x.createElement(pi,{...P,...$,title:O,active:f,data:F.data,key:N,isStart:z,isEnd:M})})})}}):l(pi,{domRef:n,className:r,style:i,...p,active:f})};Kh.displayName="MotionTreeNode";var HO=T.forwardRef(Kh);function WO(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:[],n=e.length,r=t.length;if(Math.abs(n-r)!==1)return{add:!1,key:null};function i(o,a){var s=new Map;o.forEach(function(c){s.set(c,!0)});var u=a.filter(function(c){return!s.has(c)});return u.length===1?u[0]:null}return n<r?{add:!0,key:i(e,t)}:{add:!1,key:i(t,e)}}function Hh(e,t,n){var r=e.findIndex(function(s){return s.key===n}),i=e[r+1],o=t.findIndex(function(s){return s.key===n});if(i){var a=t.findIndex(function(s){return s.key===i.key});return t.slice(o+1,a)}return t.slice(o+1)}var qO=["prefixCls","data","selectable","checkable","expandedKeys","selectedKeys","checkedKeys","loadedKeys","loadingKeys","halfCheckedKeys","keyEntities","disabled","dragging","dragOverNodeKey","dropPosition","motion","height","itemHeight","virtual","focusable","activeItem","focused","tabIndex","onKeyDown","onFocus","onBlur","onActiveChange","onListChangeStart","onListChangeEnd"],Wh={width:0,height:0,display:"flex",overflow:"hidden",opacity:0,border:0,padding:0,margin:0},UO=function(){},Nr="RC_TREE_MOTION_".concat(Math.random()),Fl={key:Nr},qh={key:Nr,level:0,index:0,pos:"0",node:Fl,nodes:[Fl]},Uh={parent:null,children:[],pos:qh.pos,data:Fl,title:null,key:Nr,isStart:[],isEnd:[]};function Yh(e,t,n,r){return t===!1||!n?e:e.slice(0,Math.ceil(n/r)+1)}function Xh(e){var t=e.key,n=e.pos;return to(t,n)}function YO(e){for(var t=String(e.data.key),n=e;n.parent;)n=n.parent,t="".concat(n.data.key," > ").concat(t);return t}var Qh=T.forwardRef(function(e,t){var n=e.prefixCls,r=e.data;e.selectable,e.checkable;var i=e.expandedKeys,o=e.selectedKeys,a=e.checkedKeys,s=e.loadedKeys,u=e.loadingKeys,c=e.halfCheckedKeys,f=e.keyEntities,h=e.disabled,p=e.dragging,g=e.dragOverNodeKey,v=e.dropPosition,m=e.motion,w=e.height,b=e.itemHeight,_=e.virtual,C=e.focusable,S=e.activeItem,E=e.focused,k=e.tabIndex,A=e.onKeyDown,L=e.onFocus,F=e.onBlur,P=e.onActiveChange,O=e.onListChangeStart,N=e.onListChangeEnd,z=Sa(e,qO),M=T.useRef(null),$=T.useRef(null);T.useImperativeHandle(t,function(){return{scrollTo:function(Ke){M.current.scrollTo(Ke)},getIndentWidth:function(){return $.current.offsetWidth}}});var I=T.useState(i),R=hi(I,2),B=R[0],G=R[1],K=T.useState(r),W=hi(K,2),ee=W[0],ne=W[1],U=T.useState(r),X=hi(U,2),ce=X[0],ue=X[1],se=T.useState([]),ae=hi(se,2),xe=ae[0],be=ae[1],Y=T.useState(null),re=hi(Y,2),Se=re[0],q=re[1],we=T.useRef(r);we.current=r;function ve(){var ge=we.current;ne(ge),ue(ge),be([]),q(null),N()}T.useEffect(function(){G(i);var ge=WO(B,i);if(ge.key!==null)if(ge.add){var Ke=ee.findIndex(function(Ve){var ct=Ve.key;return ct===ge.key}),Pe=Yh(Hh(ee,r,ge.key),_,w,b),Xe=ee.slice();Xe.splice(Ke+1,0,Uh),ue(Xe),be(Pe),q("show")}else{var Ee=r.findIndex(function(Ve){var ct=Ve.key;return ct===ge.key}),Fe=Yh(Hh(r,ee,ge.key),_,w,b),Le=r.slice();Le.splice(Ee+1,0,Uh),ue(Le),be(Fe),q("hide")}else ee!==r&&(ne(r),ue(r))},[i,r]),T.useEffect(function(){p||ve()},[p]);var _e=m?ce:r,ke={expandedKeys:i,selectedKeys:o,loadedKeys:s,loadingKeys:u,checkedKeys:a,halfCheckedKeys:c,dragOverNodeKey:g,dropPosition:v,keyEntities:f};return y(Oe,{children:[E&&S&&l("span",{style:Wh,"aria-live":"assertive",children:YO(S)}),l("div",{children:l("input",{style:Wh,disabled:C===!1||h,tabIndex:C!==!1?k:null,onKeyDown:A,onFocus:L,onBlur:F,value:"",onChange:UO,"aria-label":"for screen reader"})}),l("div",{className:"".concat(n,"-treenode"),"aria-hidden":!0,style:{position:"absolute",pointerEvents:"none",visibility:"hidden",height:0,overflow:"hidden",border:0,padding:0},children:l("div",{className:"".concat(n,"-indent"),children:l("div",{ref:$,className:"".concat(n,"-indent-unit")})})}),l(Pl,{...z,data:_e,itemKey:Xh,height:w,fullHeight:!1,virtual:_,itemHeight:b,prefixCls:"".concat(n,"-list"),ref:M,onVisibleChange:function(Ke,Pe){var Xe=new Set(Ke),Ee=Pe.filter(function(Fe){return!Xe.has(Fe)});Ee.some(function(Fe){return Xh(Fe)===Nr})&&ve()},children:function(ge){var Ke=ge.pos,Pe=wa({},(Gh(ge.data),ge.data)),Xe=ge.title,Ee=ge.key,Fe=ge.isStart,Le=ge.isEnd,Ve=to(Ee,Ke);delete Pe.key,delete Pe.children;var ct=no(Ve,ke);return l(HO,{...Pe,...ct,title:Xe,active:!!S&&Ee===S.key,pos:Ke,data:ge.data,isStart:Fe,isEnd:Le,motion:m,motionNodes:Ee===Nr?xe:null,motionType:Se,onMotionStart:O,onMotionEnd:ve,treeNodeRequiredProps:ke,onMouseMove:function(){P(null)}})}})]})});Qh.displayName="NodeList";function XO(e){var t=e.dropPosition,n=e.dropLevelOffset,r=e.indent,i={pointerEvents:"none",position:"absolute",right:0,backgroundColor:"red",height:2};switch(t){case-1:i.top=0,i.left=-n*r;break;case 1:i.bottom=0,i.left=-n*r;break;case 0:i.bottom=0,i.left=r;break}return l("div",{style:i})}var QO=10,Bl=function(e){Ih(n,e);var t=Nh(n);function n(){var r;Rh(this,n);for(var i=arguments.length,o=new Array(i),a=0;a<i;a++)o[a]=arguments[a];return r=t.call.apply(t,[this].concat(o)),r.destroyed=!1,r.delayedDragEnterLogic=void 0,r.loadingRetryTimes={},r.state={keyEntities:{},indent:null,selectedKeys:[],checkedKeys:[],halfCheckedKeys:[],loadedKeys:[],loadingKeys:[],expandedKeys:[],draggingNodeKey:null,dragChildrenKeys:[],dropTargetKey:null,dropPosition:null,dropContainerKey:null,dropLevelOffset:null,dropTargetPos:null,dropAllowed:!0,dragOverNodeKey:null,treeData:[],flattenNodes:[],focused:!1,activeKey:null,listChanging:!1,prevProps:null,fieldNames:Ca()},r.dragStartMousePosition=null,r.dragNode=void 0,r.currentMouseOverDroppableNodeKey=null,r.listRef=T.createRef(),r.onNodeDragStart=function(s,u){var c=r.state,f=c.expandedKeys,h=c.keyEntities,p=r.props.onDragStart,g=u.props.eventKey;r.dragNode=u,r.dragStartMousePosition={x:s.clientX,y:s.clientY};var v=nr(f,g);r.setState({draggingNodeKey:g,dragChildrenKeys:VO(g,h),indent:r.listRef.current.getIndentWidth()}),r.setExpandedKeys(v),window.addEventListener("dragend",r.onWindowDragEnd),p==null||p({event:s,node:$t(u.props)})},r.onNodeDragEnter=function(s,u){var c=r.state,f=c.expandedKeys,h=c.keyEntities,p=c.dragChildrenKeys,g=c.flattenNodes,v=c.indent,m=r.props,w=m.onDragEnter,b=m.onExpand,_=m.allowDrop,C=m.direction,S=u.props,E=S.pos,k=S.eventKey,A=tr(r),L=A.dragNode;if(r.currentMouseOverDroppableNodeKey!==k&&(r.currentMouseOverDroppableNodeKey=k),!L){r.resetDragState();return}var F=Fh(s,L,u,v,r.dragStartMousePosition,_,g,h,f,C),P=F.dropPosition,O=F.dropLevelOffset,N=F.dropTargetKey,z=F.dropContainerKey,M=F.dropTargetPos,$=F.dropAllowed,I=F.dragOverNodeKey;if(p.indexOf(N)!==-1||!$){r.resetDragState();return}if(r.delayedDragEnterLogic||(r.delayedDragEnterLogic={}),Object.keys(r.delayedDragEnterLogic).forEach(function(R){clearTimeout(r.delayedDragEnterLogic[R])}),L.props.eventKey!==u.props.eventKey&&(s.persist(),r.delayedDragEnterLogic[E]=window.setTimeout(function(){if(r.state.draggingNodeKey!==null){var R=Ir(f),B=h[u.props.eventKey];B&&(B.children||[]).length&&(R=yr(f,u.props.eventKey)),"expandedKeys"in r.props||r.setExpandedKeys(R),b==null||b(R,{node:$t(u.props),expanded:!0,nativeEvent:s.nativeEvent})}},800)),L.props.eventKey===N&&O===0){r.resetDragState();return}r.setState({dragOverNodeKey:I,dropPosition:P,dropLevelOffset:O,dropTargetKey:N,dropContainerKey:z,dropTargetPos:M,dropAllowed:$}),w==null||w({event:s,node:$t(u.props),expandedKeys:f})},r.onNodeDragOver=function(s,u){var c=r.state,f=c.dragChildrenKeys,h=c.flattenNodes,p=c.keyEntities,g=c.expandedKeys,v=c.indent,m=r.props,w=m.onDragOver,b=m.allowDrop,_=m.direction,C=tr(r),S=C.dragNode;if(!!S){var E=Fh(s,S,u,v,r.dragStartMousePosition,b,h,p,g,_),k=E.dropPosition,A=E.dropLevelOffset,L=E.dropTargetKey,F=E.dropContainerKey,P=E.dropAllowed,O=E.dropTargetPos,N=E.dragOverNodeKey;f.indexOf(L)!==-1||!P||(S.props.eventKey===L&&A===0?r.state.dropPosition===null&&r.state.dropLevelOffset===null&&r.state.dropTargetKey===null&&r.state.dropContainerKey===null&&r.state.dropTargetPos===null&&r.state.dropAllowed===!1&&r.state.dragOverNodeKey===null||r.resetDragState():k===r.state.dropPosition&&A===r.state.dropLevelOffset&&L===r.state.dropTargetKey&&F===r.state.dropContainerKey&&O===r.state.dropTargetPos&&P===r.state.dropAllowed&&N===r.state.dragOverNodeKey||r.setState({dropPosition:k,dropLevelOffset:A,dropTargetKey:L,dropContainerKey:F,dropTargetPos:O,dropAllowed:P,dragOverNodeKey:N}),w==null||w({event:s,node:$t(u.props)}))}},r.onNodeDragLeave=function(s,u){r.currentMouseOverDroppableNodeKey===u.props.eventKey&&!s.currentTarget.contains(s.relatedTarget)&&(r.resetDragState(),r.currentMouseOverDroppableNodeKey=null);var c=r.props.onDragLeave;c==null||c({event:s,node:$t(u.props)})},r.onWindowDragEnd=function(s){r.onNodeDragEnd(s,null,!0),window.removeEventListener("dragend",r.onWindowDragEnd)},r.onNodeDragEnd=function(s,u){var c=r.props.onDragEnd;r.setState({dragOverNodeKey:null}),r.cleanDragState(),c==null||c({event:s,node:$t(u.props)}),r.dragNode=null,window.removeEventListener("dragend",r.onWindowDragEnd)},r.onNodeDrop=function(s,u){var c,f=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1,h=r.state,p=h.dragChildrenKeys,g=h.dropPosition,v=h.dropTargetKey,m=h.dropTargetPos,w=h.dropAllowed;if(!!w){var b=r.props.onDrop;if(r.setState({dragOverNodeKey:null}),r.cleanDragState(),v!==null){var _=Xt(Xt({},no(v,r.getTreeNodeRequiredProps())),{},{active:((c=r.getActiveItem())===null||c===void 0?void 0:c.key)===v,data:r.state.keyEntities[v].node}),C=p.indexOf(v)!==-1;it(!C,"Can not drop to dragNode's children node. This is a bug of rc-tree. Please report an issue.");var S=Vl(m),E={event:s,node:$t(_),dragNode:r.dragNode?$t(r.dragNode.props):null,dragNodesKeys:[r.dragNode.props.eventKey].concat(p),dropToGap:g!==0,dropPosition:g+Number(S[S.length-1])};f||b==null||b(E),r.dragNode=null}}},r.cleanDragState=function(){var s=r.state.draggingNodeKey;s!==null&&r.setState({draggingNodeKey:null,dropPosition:null,dropContainerKey:null,dropTargetKey:null,dropLevelOffset:null,dropAllowed:!0,dragOverNodeKey:null}),r.dragStartMousePosition=null,r.currentMouseOverDroppableNodeKey=null},r.triggerExpandActionExpand=function(s,u){var c=r.state,f=c.expandedKeys,h=c.flattenNodes,p=u.expanded,g=u.key,v=u.isLeaf;if(!(v||s.shiftKey||s.metaKey||s.ctrlKey)){var m=h.filter(function(b){return b.key===g})[0],w=$t(Xt(Xt({},no(g,r.getTreeNodeRequiredProps())),{},{data:m.data}));r.setExpandedKeys(p?nr(f,g):yr(f,g)),r.onNodeExpand(s,w)}},r.onNodeClick=function(s,u){var c=r.props,f=c.onClick,h=c.expandAction;h==="click"&&r.triggerExpandActionExpand(s,u),f==null||f(s,u)},r.onNodeDoubleClick=function(s,u){var c=r.props,f=c.onDoubleClick,h=c.expandAction;h==="doubleClick"&&r.triggerExpandActionExpand(s,u),f==null||f(s,u)},r.onNodeSelect=function(s,u){var c=r.state.selectedKeys,f=r.state,h=f.keyEntities,p=f.fieldNames,g=r.props,v=g.onSelect,m=g.multiple,w=u.selected,b=u[p.key],_=!w;_?m?c=yr(c,b):c=[b]:c=nr(c,b);var C=c.map(function(S){var E=h[S];return E?E.node:null}).filter(function(S){return S});r.setUncontrolledState({selectedKeys:c}),v==null||v(c,{event:"select",selected:_,node:u,selectedNodes:C,nativeEvent:s.nativeEvent})},r.onNodeCheck=function(s,u,c){var f=r.state,h=f.keyEntities,p=f.checkedKeys,g=f.halfCheckedKeys,v=r.props,m=v.checkStrictly,w=v.onCheck,b=u.key,_,C={event:"check",node:u,checked:c,nativeEvent:s.nativeEvent};if(m){var S=c?yr(p,b):nr(p,b),E=nr(g,b);_={checked:S,halfChecked:E},C.checkedNodes=S.map(function(O){return h[O]}).filter(function(O){return O}).map(function(O){return O.node}),r.setUncontrolledState({checkedKeys:S})}else{var k=fi([].concat(Ir(p),[b]),!0,h),A=k.checkedKeys,L=k.halfCheckedKeys;if(!c){var F=new Set(A);F.delete(b);var P=fi(Array.from(F),{checked:!1,halfCheckedKeys:L},h);A=P.checkedKeys,L=P.halfCheckedKeys}_=A,C.checkedNodes=[],C.checkedNodesPositions=[],C.halfCheckedKeys=L,A.forEach(function(O){var N=h[O];if(!!N){var z=N.node,M=N.pos;C.checkedNodes.push(z),C.checkedNodesPositions.push({node:z,pos:M})}}),r.setUncontrolledState({checkedKeys:A},!1,{halfCheckedKeys:L})}w==null||w(_,C)},r.onNodeLoad=function(s){var u=s.key,c=new Promise(function(f,h){r.setState(function(p){var g=p.loadedKeys,v=g===void 0?[]:g,m=p.loadingKeys,w=m===void 0?[]:m,b=r.props,_=b.loadData,C=b.onLoad;if(!_||v.indexOf(u)!==-1||w.indexOf(u)!==-1)return null;var S=_(s);return S.then(function(){var E=r.state.loadedKeys,k=yr(E,u);C==null||C(k,{event:"load",node:s}),r.setUncontrolledState({loadedKeys:k}),r.setState(function(A){return{loadingKeys:nr(A.loadingKeys,u)}}),f()}).catch(function(E){if(r.setState(function(A){return{loadingKeys:nr(A.loadingKeys,u)}}),r.loadingRetryTimes[u]=(r.loadingRetryTimes[u]||0)+1,r.loadingRetryTimes[u]>=QO){var k=r.state.loadedKeys;it(!1,"Retry for `loadData` many times but still failed. No more retry."),r.setUncontrolledState({loadedKeys:yr(k,u)}),f()}h(E)}),{loadingKeys:yr(w,u)}})});return c.catch(function(){}),c},r.onNodeMouseEnter=function(s,u){var c=r.props.onMouseEnter;c==null||c({event:s,node:u})},r.onNodeMouseLeave=function(s,u){var c=r.props.onMouseLeave;c==null||c({event:s,node:u})},r.onNodeContextMenu=function(s,u){var c=r.props.onRightClick;c&&(s.preventDefault(),c({event:s,node:u}))},r.onFocus=function(){var s=r.props.onFocus;r.setState({focused:!0});for(var u=arguments.length,c=new Array(u),f=0;f<u;f++)c[f]=arguments[f];s==null||s.apply(void 0,c)},r.onBlur=function(){var s=r.props.onBlur;r.setState({focused:!1}),r.onActiveChange(null);for(var u=arguments.length,c=new Array(u),f=0;f<u;f++)c[f]=arguments[f];s==null||s.apply(void 0,c)},r.getTreeNodeRequiredProps=function(){var s=r.state,u=s.expandedKeys,c=s.selectedKeys,f=s.loadedKeys,h=s.loadingKeys,p=s.checkedKeys,g=s.halfCheckedKeys,v=s.dragOverNodeKey,m=s.dropPosition,w=s.keyEntities;return{expandedKeys:u||[],selectedKeys:c||[],loadedKeys:f||[],loadingKeys:h||[],checkedKeys:p||[],halfCheckedKeys:g||[],dragOverNodeKey:v,dropPosition:m,keyEntities:w}},r.setExpandedKeys=function(s){var u=r.state,c=u.treeData,f=u.fieldNames,h=Ll(c,s,f);r.setUncontrolledState({expandedKeys:s,flattenNodes:h},!0)},r.onNodeExpand=function(s,u){var c=r.state.expandedKeys,f=r.state,h=f.listChanging,p=f.fieldNames,g=r.props,v=g.onExpand,m=g.loadData,w=u.expanded,b=u[p.key];if(!h){var _=c.indexOf(b),C=!w;if(it(w&&_!==-1||!w&&_===-1,"Expand state not sync with index check"),C?c=yr(c,b):c=nr(c,b),r.setExpandedKeys(c),v==null||v(c,{node:u,expanded:C,nativeEvent:s.nativeEvent}),C&&m){var S=r.onNodeLoad(u);S&&S.then(function(){var E=Ll(r.state.treeData,c,p);r.setUncontrolledState({flattenNodes:E})}).catch(function(){var E=r.state.expandedKeys,k=nr(E,b);r.setExpandedKeys(k)})}}},r.onListChangeStart=function(){r.setUncontrolledState({listChanging:!0})},r.onListChangeEnd=function(){setTimeout(function(){r.setUncontrolledState({listChanging:!1})})},r.onActiveChange=function(s){var u=r.state.activeKey,c=r.props.onActiveChange;u!==s&&(r.setState({activeKey:s}),s!==null&&r.scrollTo({key:s}),c==null||c(s))},r.getActiveItem=function(){var s=r.state,u=s.activeKey,c=s.flattenNodes;return u===null?null:c.find(function(f){var h=f.key;return h===u})||null},r.offsetActiveKey=function(s){var u=r.state,c=u.flattenNodes,f=u.activeKey,h=c.findIndex(function(v){var m=v.key;return m===f});h===-1&&s<0&&(h=c.length),h=(h+s+c.length)%c.length;var p=c[h];if(p){var g=p.key;r.onActiveChange(g)}else r.onActiveChange(null)},r.onKeyDown=function(s){var u=r.state,c=u.activeKey,f=u.expandedKeys,h=u.checkedKeys,p=u.fieldNames,g=r.props,v=g.onKeyDown,m=g.checkable,w=g.selectable;switch(s.which){case oe.UP:{r.offsetActiveKey(-1),s.preventDefault();break}case oe.DOWN:{r.offsetActiveKey(1),s.preventDefault();break}}var b=r.getActiveItem();if(b&&b.data){var _=r.getTreeNodeRequiredProps(),C=b.data.isLeaf===!1||!!(b.data[p.children]||[]).length,S=$t(Xt(Xt({},no(c,_)),{},{data:b.data,active:!0}));switch(s.which){case oe.LEFT:{C&&f.includes(c)?r.onNodeExpand({},S):b.parent&&r.onActiveChange(b.parent.key),s.preventDefault();break}case oe.RIGHT:{C&&!f.includes(c)?r.onNodeExpand({},S):b.children&&b.children.length&&r.onActiveChange(b.children[0].key),s.preventDefault();break}case oe.ENTER:case oe.SPACE:{m&&!S.disabled&&S.checkable!==!1&&!S.disableCheckbox?r.onNodeCheck({},S,!h.includes(c)):!m&&w&&!S.disabled&&S.selectable!==!1&&r.onNodeSelect({},S);break}}}v==null||v(s)},r.setUncontrolledState=function(s){var u=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,c=arguments.length>2&&arguments[2]!==void 0?arguments[2]:null;if(!r.destroyed){var f=!1,h=!0,p={};Object.keys(s).forEach(function(g){if(g in r.props){h=!1;return}f=!0,p[g]=s[g]}),f&&(!u||h)&&r.setState(Xt(Xt({},p),c))}},r.scrollTo=function(s){r.listRef.current.scrollTo(s)},r}return Ph(n,[{key:"componentDidMount",value:function(){this.destroyed=!1,this.onUpdated()}},{key:"componentDidUpdate",value:function(){this.onUpdated()}},{key:"onUpdated",value:function(){var i=this.props.activeKey;i!==void 0&&i!==this.state.activeKey&&(this.setState({activeKey:i}),i!==null&&this.scrollTo({key:i}))}},{key:"componentWillUnmount",value:function(){window.removeEventListener("dragend",this.onWindowDragEnd),this.destroyed=!0}},{key:"resetDragState",value:function(){this.setState({dragOverNodeKey:null,dropPosition:null,dropLevelOffset:null,dropTargetKey:null,dropContainerKey:null,dropTargetPos:null,dropAllowed:!1})}},{key:"render",value:function(){var i,o=this.state,a=o.focused,s=o.flattenNodes,u=o.keyEntities,c=o.draggingNodeKey,f=o.activeKey,h=o.dropLevelOffset,p=o.dropContainerKey,g=o.dropTargetKey,v=o.dropPosition,m=o.dragOverNodeKey,w=o.indent,b=this.props,_=b.prefixCls,C=b.className,S=b.style,E=b.showLine,k=b.focusable,A=b.tabIndex,L=A===void 0?0:A,F=b.selectable,P=b.showIcon,O=b.icon,N=b.switcherIcon,z=b.draggable,M=b.checkable,$=b.checkStrictly,I=b.disabled,R=b.motion,B=b.loadData,G=b.filterTreeNode,K=b.height,W=b.itemHeight,ee=b.virtual,ne=b.titleRender,U=b.dropIndicatorRender,X=b.onContextMenu,ce=b.onScroll,ue=b.direction,se=b.rootClassName,ae=b.rootStyle,xe=Qr(this.props,{aria:!0,data:!0}),be;return z&&(er(z)==="object"?be=z:typeof z=="function"?be={nodeDraggable:z}:be={}),l($l.Provider,{value:{prefixCls:_,selectable:F,showIcon:P,icon:O,switcherIcon:N,draggable:be,draggingNodeKey:c,checkable:M,checkStrictly:$,disabled:I,keyEntities:u,dropLevelOffset:h,dropContainerKey:p,dropTargetKey:g,dropPosition:v,dragOverNodeKey:m,indent:w,direction:ue,dropIndicatorRender:U,loadData:B,filterTreeNode:G,titleRender:ne,onNodeClick:this.onNodeClick,onNodeDoubleClick:this.onNodeDoubleClick,onNodeExpand:this.onNodeExpand,onNodeSelect:this.onNodeSelect,onNodeCheck:this.onNodeCheck,onNodeLoad:this.onNodeLoad,onNodeMouseEnter:this.onNodeMouseEnter,onNodeMouseLeave:this.onNodeMouseLeave,onNodeContextMenu:this.onNodeContextMenu,onNodeDragStart:this.onNodeDragStart,onNodeDragEnter:this.onNodeDragEnter,onNodeDragOver:this.onNodeDragOver,onNodeDragLeave:this.onNodeDragLeave,onNodeDragEnd:this.onNodeDragEnd,onNodeDrop:this.onNodeDrop},children:l("div",{role:"tree",className:pt(_,C,se,(i={},Et(i,"".concat(_,"-show-line"),E),Et(i,"".concat(_,"-focused"),a),Et(i,"".concat(_,"-active-focused"),f!==null),i)),style:ae,children:l(Qh,{ref:this.listRef,prefixCls:_,style:S,data:s,disabled:I,selectable:F,checkable:!!M,motion:R,dragging:c!==null,height:K,itemHeight:W,virtual:ee,focusable:k,focused:a,tabIndex:L,activeItem:this.getActiveItem(),onFocus:this.onFocus,onBlur:this.onBlur,onKeyDown:this.onKeyDown,onActiveChange:this.onActiveChange,onListChangeStart:this.onListChangeStart,onListChangeEnd:this.onListChangeEnd,onContextMenu:X,onScroll:ce,...this.getTreeNodeRequiredProps(),...xe})})})}}],[{key:"getDerivedStateFromProps",value:function(i,o){var a=o.prevProps,s={prevProps:i};function u(k){return!a&&k in i||a&&a[k]!==i[k]}var c,f=o.fieldNames;if(u("fieldNames")&&(f=Ca(i.fieldNames),s.fieldNames=f),u("treeData")?c=i.treeData:u("children")&&(it(!1,"`children` of Tree is deprecated. Please use `treeData` instead."),c=AO(i.children)),c){s.treeData=c;var h=$h(c,{fieldNames:f});s.keyEntities=Xt(Et({},Nr,qh),h.keyEntities),process.env.NODE_ENV!=="production"&&RO(c,f)}var p=s.keyEntities||o.keyEntities;if(u("expandedKeys")||a&&u("autoExpandParent"))s.expandedKeys=i.autoExpandParent||!a&&i.defaultExpandParent?jh(i.expandedKeys,p):i.expandedKeys;else if(!a&&i.defaultExpandAll){var g=Xt({},p);delete g[Nr],s.expandedKeys=Object.keys(g).map(function(k){return g[k].key})}else!a&&i.defaultExpandedKeys&&(s.expandedKeys=i.autoExpandParent||i.defaultExpandParent?jh(i.defaultExpandedKeys,p):i.defaultExpandedKeys);if(s.expandedKeys||delete s.expandedKeys,c||s.expandedKeys){var v=Ll(c||o.treeData,s.expandedKeys||o.expandedKeys,f);s.flattenNodes=v}if(i.selectable&&(u("selectedKeys")?s.selectedKeys=Bh(i.selectedKeys,i):!a&&i.defaultSelectedKeys&&(s.selectedKeys=Bh(i.defaultSelectedKeys,i))),i.checkable){var m;if(u("checkedKeys")?m=zl(i.checkedKeys)||{}:!a&&i.defaultCheckedKeys?m=zl(i.defaultCheckedKeys)||{}:c&&(m=zl(i.checkedKeys)||{checkedKeys:o.checkedKeys,halfCheckedKeys:o.halfCheckedKeys}),m){var w=m,b=w.checkedKeys,_=b===void 0?[]:b,C=w.halfCheckedKeys,S=C===void 0?[]:C;if(!i.checkStrictly){var E=fi(_,!0,p);_=E.checkedKeys,S=E.halfCheckedKeys}s.checkedKeys=_,s.halfCheckedKeys=S}}return u("loadedKeys")&&(s.loadedKeys=i.loadedKeys),s}}]),n}(T.Component);Bl.defaultProps={prefixCls:"rc-tree",showLine:!1,showIcon:!0,selectable:!0,multiple:!1,checkable:!1,disabled:!1,checkStrictly:!1,draggable:!1,defaultExpandParent:!0,autoExpandParent:!1,defaultExpandAll:!1,defaultExpandedKeys:[],defaultCheckedKeys:[],defaultSelectedKeys:[],dropIndicatorRender:XO,allowDrop:function(){return!0},expandAction:!1},Bl.TreeNode=pi;var Zh=T.createContext(null),Jh=T.createContext(null);function eg(e){return Array.isArray(e)?e:e!==void 0?[e]:[]}function ZO(e){var t=e||{},n=t.label,r=t.value,i=t.children,o=r||"value";return{_title:n?[n]:["title","label"],value:o,key:o,children:i||"children"}}function jl(e){return!e||e.disabled||e.disableCheckbox||e.checkable===!1}function JO(e,t){var n=[];function r(i){i.forEach(function(o){var a=o[t.children];a&&(n.push(o[t.value]),r(a))})}return r(e),n}function Gl(e){return e==null}var eD={width:0,height:0,display:"flex",overflow:"hidden",opacity:0,border:0,padding:0,margin:0},tD=function(t,n){var r=Gd(),i=r.prefixCls,o=r.multiple,a=r.searchValue,s=r.toggleOpen,u=r.open,c=r.notFoundContent,f=T.useContext(Jh),h=f.virtual,p=f.listHeight,g=f.listItemHeight,v=f.treeData,m=f.fieldNames,w=f.onSelect,b=f.dropdownMatchSelectWidth,_=f.treeExpandAction,C=T.useContext(Zh),S=C.checkable,E=C.checkedKeys,k=C.halfCheckedKeys,A=C.treeExpandedKeys,L=C.treeDefaultExpandAll,F=C.treeDefaultExpandedKeys,P=C.onTreeExpand,O=C.treeIcon,N=C.showTreeIcon,z=C.switcherIcon,M=C.treeLine,$=C.treeNodeFilterProp,I=C.loadData,R=C.treeLoadedKeys,B=C.treeMotion,G=C.onTreeLoad,K=C.keyEntities,W=T.useRef(),ee=Gs(function(){return v},[u,v],function(Ee,Fe){return Fe[0]&&Ee[1]!==Fe[1]}),ne=T.useMemo(function(){return S?{checked:E,halfChecked:k}:null},[S,E,k]);T.useEffect(function(){if(u&&!o&&E.length){var Ee;(Ee=W.current)===null||Ee===void 0||Ee.scrollTo({key:E[0]})}},[u]);var U=String(a).toLowerCase(),X=function(Fe){return U?String(Fe[$]).toLowerCase().includes(U):!1},ce=T.useState(F),ue=dr(ce,2),se=ue[0],ae=ue[1],xe=T.useState(null),be=dr(xe,2),Y=be[0],re=be[1],Se=T.useMemo(function(){return A?cr(A):a?Y:se},[se,Y,A,a]);T.useEffect(function(){a&&re(JO(v,m))},[a]);var q=function(Fe){ae(Fe),re(Fe),P&&P(Fe)},we=function(Fe){Fe.preventDefault()},ve=function(Fe,Le){var Ve=Le.node;S&&jl(Ve)||(w(Ve.key,{selected:!E.includes(Ve.key)}),o||s(!1))},_e=T.useState(null),ke=dr(_e,2),ge=ke[0],Ke=ke[1],Pe=K[ge];if(T.useImperativeHandle(n,function(){var Ee;return{scrollTo:(Ee=W.current)===null||Ee===void 0?void 0:Ee.scrollTo,onKeyDown:function(Le){var Ve,ct=Le.which;switch(ct){case oe.UP:case oe.DOWN:case oe.LEFT:case oe.RIGHT:(Ve=W.current)===null||Ve===void 0||Ve.onKeyDown(Le);break;case oe.ENTER:{if(Pe){var at=(Pe==null?void 0:Pe.node)||{},We=at.selectable,st=at.value;We!==!1&&ve(null,{node:{key:ge},selected:!E.includes(st)})}break}case oe.ESC:s(!1)}},onKeyUp:function(){}}}),ee.length===0)return l("div",{role:"listbox",className:"".concat(i,"-empty"),onMouseDown:we,children:c});var Xe={fieldNames:m};return R&&(Xe.loadedKeys=R),Se&&(Xe.expandedKeys=Se),y("div",{onMouseDown:we,children:[Pe&&u&&l("span",{style:eD,"aria-live":"assertive",children:Pe.node.value}),l(Bl,{ref:W,focusable:!1,prefixCls:"".concat(i,"-tree"),treeData:ee,height:p,itemHeight:g,virtual:h!==!1&&b!==!1,multiple:o,icon:O,showIcon:N,switcherIcon:z,showLine:M,loadData:a?null:I,motion:B,activeKey:ge,checkable:S,checkStrictly:!0,checkedKeys:ne,selectedKeys:S?[]:E,defaultExpandAll:L,...Xe,onActiveChange:Ke,onSelect:ve,onCheck:ve,onExpand:q,onLoad:G,filterTreeNode:X,expandAction:_})]})},tg=T.forwardRef(tD);tg.displayName="OptionList";var ng=function(){return null},nD="SHOW_ALL",Kl="SHOW_PARENT",Hl="SHOW_CHILD";function rg(e,t,n,r){var i=new Set(e);return t===Hl?e.filter(function(o){var a=n[o];return!(a&&a.children&&a.children.some(function(s){var u=s.node;return i.has(u[r.value])})&&a.children.every(function(s){var u=s.node;return jl(u)||i.has(u[r.value])}))}):t===Kl?e.filter(function(o){var a=n[o],s=a?a.parent:null;return!(s&&!jl(s.node)&&i.has(s.key))}):e}var rD=["children","value"];function ig(e){return pr(e).map(function(t){if(!T.isValidElement(t)||!t.type)return null;var n=t,r=n.key,i=n.props,o=i.children,a=i.value,s=Td(i,rD),u=yn({key:r,value:a},s),c=ig(o);return c.length&&(u.children=c),u}).filter(function(t){return t})}function Wl(e){if(!e)return e;var t=yn({},e);return"props"in t||Object.defineProperty(t,"props",{get:function(){return it(!1,"New `rc-tree-select` not support return node instance as argument anymore. Please consider to remove `props` access."),t}}),t}function iD(e,t,n,r,i,o){var a=null,s=null;function u(){function c(f){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"0",p=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return f.map(function(g,v){var m="".concat(h,"-").concat(v),w=g[o.value],b=n.includes(w),_=c(g[o.children]||[],m,b),C=l(ng,{...g,children:_.map(function(E){return E.node})});if(t===w&&(a=C),b){var S={pos:m,node:C,children:_};return p||s.push(S),S}return null}).filter(function(g){return g})}s||(s=[],c(r),s.sort(function(f,h){var p=f.node.props.value,g=h.node.props.value,v=n.indexOf(p),m=n.indexOf(g);return v-m}))}Object.defineProperty(e,"triggerNode",{get:function(){return it(!1,"`triggerNode` is deprecated. Please consider decoupling data with node."),u(),a}}),Object.defineProperty(e,"allCheckedNodes",{get:function(){return it(!1,"`allCheckedNodes` is deprecated. Please consider decoupling data with node."),u(),i?s:s.map(function(f){var h=f.node;return h})}})}function oD(e,t){var n=t.id,r=t.pId,i=t.rootPId,o={},a=[],s=e.map(function(u){var c=yn({},u),f=c[n];return o[f]=c,c.key=c.key||f,c});return s.forEach(function(u){var c=u[r],f=o[c];f&&(f.children=f.children||[],f.children.push(u)),(c===i||!f&&i===null)&&a.push(u)}),a}function aD(e,t,n){return T.useMemo(function(){return e?n?oD(e,yn({id:"id",pId:"pId",rootPId:null},n!==!0?n:{})):e:ig(t)},[t,n,e])}const sD=function(e){var t=T.useRef({valueLabels:new Map});return T.useMemo(function(){var n=t.current.valueLabels,r=new Map,i=e.map(function(o){var a,s=o.value,u=(a=o.label)!==null&&a!==void 0?a:n.get(s);return r.set(s,u),yn(yn({},o),{},{label:u})});return t.current.valueLabels=r,[i]},[e])};function og(e){var t=T.useRef();t.current=e;var n=T.useCallback(function(){return t.current.apply(t,arguments)},[]);return n}const lD=function(e,t){return T.useMemo(function(){var n=$h(e,{fieldNames:t,initWrapper:function(i){return yn(yn({},i),{},{valueEntities:new Map})},processEntity:function(i,o){var a=i.node[t.value];if(process.env.NODE_ENV!=="production"){var s=i.node.key;it(!Gl(a),"TreeNode `value` is invalidate: undefined"),it(!o.valueEntities.has(a),"Same `value` exist in the tree: ".concat(a)),it(!s||String(s)===String(a),"`key` or `value` with TreeNode must be the same or you can remove one of them. key: ".concat(s,", value: ").concat(a,"."))}o.valueEntities.set(a,i)}});return n},[e,t])},uD=function(e,t,n,r){return T.useMemo(function(){var i=e.map(function(u){var c=u.value;return c}),o=t.map(function(u){var c=u.value;return c}),a=i.filter(function(u){return!r[u]});if(n){var s=fi(i,!0,r);i=s.checkedKeys,o=s.halfCheckedKeys}return[Array.from(new Set([].concat(cr(a),cr(i)))),o]},[e,t,n,r])},cD=function(e,t,n){var r=n.treeNodeFilterProp,i=n.filterTreeNode,o=n.fieldNames,a=o.children;return T.useMemo(function(){if(!t||i===!1)return e;var s;if(typeof i=="function")s=i;else{var u=t.toUpperCase();s=function(h,p){var g=p[r];return String(g).toUpperCase().includes(u)}}function c(f){var h=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return f.map(function(p){var g=p[a],v=h||s(t,Wl(p)),m=c(g||[],v);return v||m.length?yn(yn({},p),{},_d({isLeaf:void 0},a,m)):null}).filter(function(p){return p})}return c(e)},[e,t,a,r,i])};function dD(e){var t=e.searchPlaceholder,n=e.treeCheckStrictly,r=e.treeCheckable,i=e.labelInValue,o=e.value,a=e.multiple;it(!t,"`searchPlaceholder` has been removed."),n&&i===!1&&it(!1,"`treeCheckStrictly` will force set `labelInValue` to `true`."),(i||n)&&it(eg(o).every(function(s){return s&&Rr(s)==="object"&&"value"in s}),"Invalid prop `value` supplied to `TreeSelect`. You should use { label: string, value: string | number } or [{ label: string, value: string | number }] instead."),n||a||r?it(!o||Array.isArray(o),"`value` should be an array when `TreeSelect` is checkable or multiple."):it(!Array.isArray(o),"`value` should not be array when `TreeSelect` is single mode.")}var fD=["id","prefixCls","value","defaultValue","onChange","onSelect","onDeselect","searchValue","inputValue","onSearch","autoClearSearchValue","filterTreeNode","treeNodeFilterProp","showCheckedStrategy","treeNodeLabelProp","multiple","treeCheckable","treeCheckStrictly","labelInValue","fieldNames","treeDataSimpleMode","treeData","children","loadData","treeLoadedKeys","onTreeLoad","treeDefaultExpandAll","treeExpandedKeys","treeDefaultExpandedKeys","onTreeExpand","treeExpandAction","virtual","listHeight","listItemHeight","onDropdownVisibleChange","dropdownMatchSelectWidth","treeLine","treeIcon","showTreeIcon","switcherIcon","treeMotion"];function pD(e){return!e||Rr(e)!=="object"}var ag=T.forwardRef(function(e,t){var n=e.id,r=e.prefixCls,i=r===void 0?"rc-tree-select":r,o=e.value,a=e.defaultValue,s=e.onChange,u=e.onSelect,c=e.onDeselect,f=e.searchValue,h=e.inputValue,p=e.onSearch,g=e.autoClearSearchValue,v=g===void 0?!0:g,m=e.filterTreeNode,w=e.treeNodeFilterProp,b=w===void 0?"value":w,_=e.showCheckedStrategy,C=_===void 0?Hl:_,S=e.treeNodeLabelProp,E=e.multiple,k=e.treeCheckable,A=e.treeCheckStrictly,L=e.labelInValue,F=e.fieldNames,P=e.treeDataSimpleMode,O=e.treeData,N=e.children,z=e.loadData,M=e.treeLoadedKeys,$=e.onTreeLoad,I=e.treeDefaultExpandAll,R=e.treeExpandedKeys,B=e.treeDefaultExpandedKeys,G=e.onTreeExpand,K=e.treeExpandAction,W=e.virtual,ee=e.listHeight,ne=ee===void 0?200:ee,U=e.listItemHeight,X=U===void 0?20:U,ce=e.onDropdownVisibleChange,ue=e.dropdownMatchSelectWidth,se=ue===void 0?!0:ue,ae=e.treeLine,xe=e.treeIcon,be=e.showTreeIcon,Y=e.switcherIcon,re=e.treeMotion,Se=Td(e,fD),q=lh(n),we=k&&!A,ve=k||A,_e=A||L,ke=ve||E,ge=zi(a,{value:o}),Ke=dr(ge,2),Pe=Ke[0],Xe=Ke[1];process.env.NODE_ENV!=="production"&&dD(e);var Ee=T.useMemo(function(){return ZO(F)},[JSON.stringify(F)]),Fe=zi("",{value:f!==void 0?f:h,postState:function(he){return he||""}}),Le=dr(Fe,2),Ve=Le[0],ct=Le[1],at=function(he){ct(he),p==null||p(he)},We=aD(O,N,P),st=lD(We,Ee),Ce=st.keyEntities,Ie=st.valueEntities,et=T.useCallback(function(Q){var he=[],ye=[];return Q.forEach(function(Te){Ie.has(Te)?ye.push(Te):he.push(Te)}),{missingRawValues:he,existRawValues:ye}},[Ie]),Mt=cD(We,Ve,{fieldNames:Ee,treeNodeFilterProp:b,filterTreeNode:m}),lt=T.useCallback(function(Q){if(Q){if(S)return Q[S];for(var he=Ee._title,ye=0;ye<he.length;ye+=1){var Te=Q[he[ye]];if(Te!==void 0)return Te}}},[Ee,S]),kt=T.useCallback(function(Q){var he=eg(Q);return he.map(function(ye){return pD(ye)?{value:ye}:ye})},[]),dt=T.useCallback(function(Q){var he=kt(Q);return he.map(function(ye){var Te=ye.label,Ne=ye.value,De=ye.halfChecked,Ge,ze=Ie.get(Ne);if(ze){var qe;Te=(qe=Te)!==null&&qe!==void 0?qe:lt(ze.node),Ge=ze.node.disabled}else if(Te===void 0){var Ct=kt(Pe).find(function(rn){return rn.value===Ne});Te=Ct.label}return{label:Te,value:Ne,halfChecked:De,disabled:Ge}})},[Ie,lt,kt,Pe]),Gt=T.useMemo(function(){return kt(Pe)},[kt,Pe]),Ot=T.useMemo(function(){var Q=[],he=[];return Gt.forEach(function(ye){ye.halfChecked?he.push(ye):Q.push(ye)}),[Q,he]},[Gt]),bt=dr(Ot,2),_t=bt[0],Ht=bt[1],vt=T.useMemo(function(){return _t.map(function(Q){return Q.value})},[_t]),cn=uD(_t,Ht,we,Ce),Vt=dr(cn,2),ie=Vt[0],pe=Vt[1],me=T.useMemo(function(){var Q=rg(ie,C,Ce,Ee),he=Q.map(function(De){var Ge,ze,qe;return(Ge=(ze=Ce[De])===null||ze===void 0||(qe=ze.node)===null||qe===void 0?void 0:qe[Ee.value])!==null&&Ge!==void 0?Ge:De}),ye=he.map(function(De){var Ge=_t.find(function(ze){return ze.value===De});return{value:De,label:Ge==null?void 0:Ge.label}}),Te=dt(ye),Ne=Te[0];return!ke&&Ne&&Gl(Ne.value)&&Gl(Ne.label)?[]:Te.map(function(De){var Ge;return yn(yn({},De),{},{label:(Ge=De.label)!==null&&Ge!==void 0?Ge:De.value})})},[Ee,ke,ie,_t,dt,C,Ce]),Ae=sD(me),Qe=dr(Ae,1),ft=Qe[0],Wt=og(function(Q,he,ye){var Te=dt(Q);if(Xe(Te),v&&ct(""),s){var Ne=Q;if(we){var De=rg(Q,C,Ce,Ee);Ne=De.map(function(an){var sn=Ie.get(an);return sn?sn.node[Ee.value]:an})}var Ge=he||{triggerValue:void 0,selected:void 0},ze=Ge.triggerValue,qe=Ge.selected,Ct=Ne;if(A){var rn=Ht.filter(function(an){return!Ne.includes(an.value)});Ct=[].concat(cr(Ct),cr(rn))}var vn=dt(Ct),Dt={preValue:_t,triggerValue:ze},Gn=!0;(A||ye==="selection"&&!qe)&&(Gn=!1),iD(Dt,ze,Q,We,Gn,Ee),ve?Dt.checked=qe:Dt.selected=qe;var lr=_e?vn:vn.map(function(an){return an.value});s(ke?lr:lr[0],_e?null:vn.map(function(an){return an.label}),Dt)}}),qt=T.useCallback(function(Q,he){var ye,Te=he.selected,Ne=he.source,De=Ce[Q],Ge=De==null?void 0:De.node,ze=(ye=Ge==null?void 0:Ge[Ee.value])!==null&&ye!==void 0?ye:Q;if(!ke)Wt([ze],{selected:!0,triggerValue:ze},"option");else{var qe=Te?[].concat(cr(vt),[ze]):ie.filter(function(sn){return sn!==ze});if(we){var Ct=et(qe),rn=Ct.missingRawValues,vn=Ct.existRawValues,Dt=vn.map(function(sn){return Ie.get(sn).key}),Gn;if(Te){var lr=fi(Dt,!0,Ce);Gn=lr.checkedKeys}else{var an=fi(Dt,{checked:!1,halfCheckedKeys:pe},Ce);Gn=an.checkedKeys}qe=[].concat(cr(rn),cr(Gn.map(function(sn){return Ce[sn].node[Ee.value]})))}Wt(qe,{selected:Te,triggerValue:ze},Ne||"option")}Te||!ke?u==null||u(ze,Wl(Ge)):c==null||c(ze,Wl(Ge))},[et,Ie,Ce,Ee,ke,vt,Wt,we,u,c,ie,pe]),dn=T.useCallback(function(Q){if(ce){var he={};Object.defineProperty(he,"documentClickClose",{get:function(){return it(!1,"Second param of `onDropdownVisibleChange` has been removed."),!1}}),ce(Q,he)}},[ce]),xt=og(function(Q,he){var ye=Q.map(function(Te){return Te.value});if(he.type==="clear"){Wt(ye,{},"selection");return}he.values.length&&qt(he.values[0].value,{selected:!1,source:"selection"})}),V=T.useMemo(function(){return{virtual:W,dropdownMatchSelectWidth:se,listHeight:ne,listItemHeight:X,treeData:Mt,fieldNames:Ee,onSelect:qt,treeExpandAction:K}},[W,se,ne,X,Mt,Ee,qt,K]),J=T.useMemo(function(){return{checkable:ve,loadData:z,treeLoadedKeys:M,onTreeLoad:$,checkedKeys:ie,halfCheckedKeys:pe,treeDefaultExpandAll:I,treeExpandedKeys:R,treeDefaultExpandedKeys:B,onTreeExpand:G,treeIcon:xe,treeMotion:re,showTreeIcon:be,switcherIcon:Y,treeLine:ae,treeNodeFilterProp:b,keyEntities:Ce}},[ve,z,M,$,ie,pe,I,R,B,G,xe,re,be,Y,ae,b,Ce]);return l(Jh.Provider,{value:V,children:l(Zh.Provider,{value:J,children:l(Ol,{ref:t,...Se,id:q,prefixCls:i,mode:ke?"multiple":void 0,displayValues:ft,onDisplayValuesChange:xt,searchValue:Ve,onSearch:at,OptionList:tg,emptyOptions:!We.length,onDropdownVisibleChange:dn,dropdownMatchSelectWidth:se})})})});process.env.NODE_ENV!=="production"&&(ag.displayName="TreeSelect");var ro=ag;ro.TreeNode=ng,ro.SHOW_ALL=nD,ro.SHOW_PARENT=Kl,ro.SHOW_CHILD=Hl;const hD=({rotate:e,onClick:t})=>l("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:l("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"})}),gD=({expanded:e,isLeaf:t,value:n,onClick:r,...i})=>(n==="0-0-value"&&console.log(i),t?l("span",{style:{width:"14px",display:"inline-block"}}):l(hD,{rotate:e?"0":"-90",onClick:r,...i})),vD=({onClick:e})=>y("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:[l("path",{stroke:"none",d:"M0 0h24v24H0z",fill:"none"}),l("rect",{className:"border",x:"4",y:"4",width:"16",height:"16",rx:"2"}),l("rect",{className:"checkmark-indeterminate",x:"8",y:"8",width:"8",height:"8",rx:"2",stroke:"none"}),l("path",{className:"checkmark-checked",d:"M9 12l2 2l4 -4"})]}),mD=({onClick:e,...t})=>l(vD,{onClick:e,...t}),yD=d.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"},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"}}}})),bD=({disabled:e,classNames:t,styles:n,unstyled:r,radius:i,style:o,label:a,value:s,onChange:u,treeData:c})=>{const{classes:f,cx:h}=yD({radius:i},{name:"FilterTreeSelectWidget",classNames:t,styles:n,unstyled:r}),[p,g]=x.useState((s==null?void 0:s.length)>0),v=w=>{g(w)},m=p&&(s==null?void 0:s.length)>0;return y(d.Stack,{spacing:3,children:[y(d.Group,{position:"apart",children:[l(d.Text,{className:f.label,children:a}),m&&l(d.Tooltip,{label:`${s.length} selected`,children:l(d.Badge,{children:s.length})})]}),l(ro,{disabled:e,allowClear:!0,className:h(f.root,"check-select"),dropdownClassName:h(f.dropdown,""),onDropdownVisibleChange:v,transitionName:"rc-tree-select-dropdown-slide-up",choiceTransitionName:"rc-tree-select-selection__choice-zoom",style:o,treeLine:!0,clearIcon:()=>l(d.CloseButton,{}),switcherIcon:gD,treeIcon:mD,maxTagTextLength:10,value:s,treeData:c,treeNodeFilterProp:"filterBasis",treeCheckable:!0,showCheckedStrategy:Kl,onChange:u,onSelect:console.log,maxTagCount:0,maxTagPlaceholder:w=>`${w.length} selected`})]})};function wD(e){return e.map(t=>{const{label:n,description:r,...i}=t,o={...i,filterBasis:`${n}___${r!=null?r:""}`,description:r,label:n};return r&&(o.label=y("div",{children:[l(d.Text,{title:t.label,children:t.label}),l(d.Text,{className:"rc-tree-select-tree-title-desc",color:"dimmed",title:t.description,children:t.description})]})),o})}const xD=te.observer(({label:e,config:t,value:n,onChange:r})=>{const i=$e(),{state:o,dataProxy:a,len:s}=i.getDataStuffByID(t.options_query_id),u=o==="loading",c=x.useMemo(()=>{if(!a)return[];const g=[...a],v=wD(g);return L0(v)},[a,s]);x.useEffect(()=>{const{default_selection_count:g}=t;if(!g)return;if(c.length===0){console.log("[filter.tree-select] Resetting to empty"),r([],!0);return}const v=c.slice(0,g).map(m=>m.value);console.log(`[filter.tree-select] Selecting first ${g} option(s)`),r(v,!0)},[t.default_selection_count,c]);const f=t.min_width?t.min_width:"200px",p=!!t.options_query_id?u:!1;return l(bD,{disabled:p,style:{minWidth:f,maxWidth:p?f:"unset",borderColor:"#e9ecef"},value:n,onChange:g=>r(g,!1),treeData:c,label:e})}),SD=te.observer(({filter:{type:e,config:t,key:n,...r},formFieldProps:i})=>{switch(e){case"select":return l(N0,{...r,...i,config:t});case"multi-select":return l(I0,{...r,...i,config:t});case"tree-select":return l(xD,{...r,...i,config:t});case"text-input":return l($0,{...r,...i,config:t});case"date-range":return l(yd,{...r,...i,config:t});case"checkbox":return l(R0,{...r,...i,config:t});default:return null}}),sg=te.observer(Z.default.forwardRef(({filter:e,...t},n)=>l("div",{className:"filter-root",ref:n,children:l(Or,{children:l(SD,{filter:e,formFieldProps:t})})}))),lg=te.observer(function({view:t}){const n=$e(),{control:r,handleSubmit:i,reset:o}=j.useForm({defaultValues:n.filters.values,reValidateMode:"onBlur"}),a=j.useWatch({control:r});x.useEffect(()=>{o(n.filters.values)},[n.filters.values,o]),x.useEffect(()=>{n.filters.updatePreviewValues(a)},[a]);const s=n.filters.visibleInView(t.id),u=x.useMemo(()=>s.every(p=>p.should_auto_submit),[s]),c=x.useMemo(()=>s.filter(p=>fe.default.get(p,"config.required",!1)),[s]),f=x.useMemo(()=>c.length===0?!1:c.some(p=>!p.requiredAndPass(a[p.key])),[a,c]);if(s.length===0)return null;const h=(p,g)=>(v,m)=>{g(v),(p.should_auto_submit||m)&&n.filters.setValueByKey(p.key,v)};return l("form",{onSubmit:i(n.filters.setValues),children:y(d.Group,{className:"dashboard-filters",position:"apart",noWrap:!0,sx:u?{}:{border:"1px solid #e9ecef",borderRadius:"4px",padding:"16px"},children:[l(d.Group,{align:"flex-start",children:s.map(p=>l(j.Controller,{name:p.key,control:r,render:({field:g})=>l(sg,{filter:p,value:g.value,onChange:h(p,g.onChange)})},p.id))}),!u&&l(d.Group,{sx:{alignSelf:"flex-end"},children:l(d.Button,{color:"blue",size:"sm",type:"submit",disabled:f,children:"Search"})})]})})}),g6="",ug=Jt.Mark.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:e=>e.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["span",Jt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:e,commands:t})=>{const n=Jt.getMarkAttributes(e,this.type);return Object.entries(n).some(([,i])=>!!i)?!0:t.unsetMark(this.name)}}}}),cg=Jt.Extension.create({name:"color",addOptions(){return{types:["textStyle"]}},addGlobalAttributes(){return[{types:this.options.types,attributes:{color:{default:null,parseHTML:e=>{var t;return(t=e.style.color)===null||t===void 0?void 0:t.replace(/['"]+/g,"")},renderHTML:e=>e.color?{style:`color: ${e.color}`}:{}}}}]},addCommands(){return{setColor:e=>({chain:t})=>t().setMark("textStyle",{color:e}).run(),unsetColor:()=>({chain:e})=>e().setMark("textStyle",{color:null}).removeEmptyTextStyle().run()}}}),CD=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))$/,_D=/(?:^|\s)((?:==)((?:[^~=]+))(?:==))/g,dg=Jt.Mark.create({name:"highlight",addOptions(){return{multicolor:!1,HTMLAttributes:{}}},addAttributes(){return this.options.multicolor?{color:{default:null,parseHTML:e=>e.getAttribute("data-color")||e.style.backgroundColor,renderHTML:e=>e.color?{"data-color":e.color,style:`background-color: ${e.color}; color: inherit`}:{}}}:{}},parseHTML(){return[{tag:"mark"}]},renderHTML({HTMLAttributes:e}){return["mark",Jt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setHighlight:e=>({commands:t})=>t.setMark(this.name,e),toggleHighlight:e=>({commands:t})=>t.toggleMark(this.name,e),unsetHighlight:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-h":()=>this.editor.commands.toggleHighlight()}},addInputRules(){return[Jt.markInputRule({find:CD,type:this.type})]},addPasteRules(){return[Jt.markPasteRule({find:_D,type:this.type})]}}),fg=Jt.Extension.create({name:"placeholder",addOptions(){return{emptyEditorClass:"is-editor-empty",emptyNodeClass:"is-empty",placeholder:"Write something \u2026",showOnlyWhenEditable:!0,showOnlyCurrent:!0,includeChildren:!1}},addProseMirrorPlugins(){return[new h0.Plugin({props:{decorations:({doc:e,selection:t})=>{const n=this.editor.isEditable||!this.options.showOnlyWhenEditable,{anchor:r}=t,i=[];if(!n)return null;const o=e.type.createAndFill(),a=(o==null?void 0:o.sameMarkup(e))&&o.content.findDiffStart(e.content)===null;return e.descendants((s,u)=>{const c=r>=u&&r<=u+s.nodeSize,f=!s.isLeaf&&!s.childCount;if((c||!this.options.showOnlyCurrent)&&f){const h=[this.options.emptyNodeClass];a&&h.push(this.options.emptyEditorClass);const p=sd.Decoration.node(u,u+s.nodeSize,{class:h.join(" "),"data-placeholder":typeof this.options.placeholder=="function"?this.options.placeholder({editor:this.editor,node:s,pos:u,hasAnchor:c}):this.options.placeholder});i.push(p)}return this.options.includeChildren}),sd.DecorationSet.create(e,i)}}})]}}),pg=Jt.Mark.create({name:"subscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sub"},{style:"vertical-align",getAttrs(e){return e!=="sub"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sub",Jt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setSubscript:()=>({commands:e})=>e.setMark(this.name),toggleSubscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSubscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-,":()=>this.editor.commands.toggleSubscript()}}}),hg=Jt.Mark.create({name:"superscript",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"sup"},{style:"vertical-align",getAttrs(e){return e!=="super"?!1:null}}]},renderHTML({HTMLAttributes:e}){return["sup",Jt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setSuperscript:()=>({commands:e})=>e.setMark(this.name),toggleSuperscript:()=>({commands:e})=>e.toggleMark(this.name),unsetSuperscript:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-.":()=>this.editor.commands.toggleSuperscript()}}}),gg=Jt.Extension.create({name:"textAlign",addOptions(){return{types:[],alignments:["left","center","right","justify"],defaultAlignment:"left"}},addGlobalAttributes(){return[{types:this.options.types,attributes:{textAlign:{default:this.options.defaultAlignment,parseHTML:e=>e.style.textAlign||this.options.defaultAlignment,renderHTML:e=>e.textAlign===this.options.defaultAlignment?{}:{style:`text-align: ${e.textAlign}`}}}}]},addCommands(){return{setTextAlign:e=>({commands:t})=>this.options.alignments.includes(e)?this.options.types.every(n=>t.updateAttributes(n,{textAlign:e})):!1,unsetTextAlign:()=>({commands:e})=>this.options.types.every(t=>e.resetAttributes(t,"textAlign"))}},addKeyboardShortcuts(){return{"Mod-Shift-l":()=>this.editor.commands.setTextAlign("left"),"Mod-Shift-e":()=>this.editor.commands.setTextAlign("center"),"Mod-Shift-r":()=>this.editor.commands.setTextAlign("right"),"Mod-Shift-j":()=>this.editor.commands.setTextAlign("justify")}}}),vg=Jt.Mark.create({name:"underline",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"u"},{style:"text-decoration",consuming:!1,getAttrs:e=>e.includes("underline")?{}:!1}]},renderHTML({HTMLAttributes:e}){return["u",Jt.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{setUnderline:()=>({commands:e})=>e.setMark(this.name),toggleUnderline:()=>({commands:e})=>e.toggleMark(this.name),unsetUnderline:()=>({commands:e})=>e.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-u":()=>this.editor.commands.toggleUnderline(),"Mod-U":()=>this.editor.commands.toggleUnderline()}}}),ql={fontSize:"14px",lineHeight:"32px",color:"#3D3E45",ul:{paddingLeft:"2em",margin:"6px 0 0"},p:{margin:0},a:{WebkitTapHighlightColor:"transparent",color:"rgb(34, 139, 230)",textDecoration:"none","&:hover":{textDecoration:"underline"},"&:active, &:hover":{outlineWidth:0}},table:{tr:{"th, td":{padding:"0 .5em"}}},details:{summary:{listStyle:"none",cursor:"pointer",transition:"color 300ms ease",userSelect:"none"},"summary::-webkit-details-marker":{display:"none"},"summary:hover":{color:"black","&::before":{opacity:1}},"summary::before":{content:'"\u25BA"',fontSize:"10px",margin:"0px 5px",opacity:.5,display:"inline-block",transition:"opacity 300ms ease, transform 300ms ease"}},"details[open] summary::before":{transform:"rotate(90deg)"},"details + details":{marginTop:"10px"}},mg=({value:e,styles:t={}})=>{const n=ld.useEditor({extensions:[cd.default,vg,nt.Link,hg,pg,dg,gg.configure({types:["heading","paragraph"]}),fg.configure({placeholder:"This is placeholder"}),ug,cg],content:e,editable:!1}),r=x.useMemo(()=>fe.default.defaultsDeep({},{content:ql},t),[t]);return l(nt.RichTextEditor,{editor:n,styles:r,children:l(nt.RichTextEditor.Content,{})})};function ED(e){return e?["<p><br></p>","<p></p>"].includes(e):!0}const yg=te.observer(()=>{const{freezeLayout:e}=Z.default.useContext(Dr),[t,n]=Z.default.useState(!1),{panel:r}=Yt();return Z.default.useEffect(()=>{e(t)},[t]),ED(r.description)?null:y(Oe,{children:[l(d.Modal,{opened:t,onClose:()=>n(!1),title:r.title,withCloseButton:!1,withinPortal:!0,zIndex:310,children:l(mg,{value:r.description,styles:{root:{border:"none"},content:{padding:0}}})}),l(d.Tooltip,{label:"Click to see description",position:"top-start",withinPortal:!0,children:l(d.ActionIcon,{variant:"subtle",color:"blue",onClick:()=>n(i=>!i),sx:{verticalAlign:"baseline",cursor:"pointer"},children:l(le.InfoCircle,{size:20})})})]})}),TD=te.observer(({view:e})=>{const t=$e(),n=Kn.useModals(),{panel:r}=Yt(),{id:i,query:o}=r,{inEditMode:a}=Z.default.useContext(Dr),s=()=>o==null?void 0:o.fetchData(),{viewPanelInFullScreen:u,inFullScreen:c}=Z.default.useContext(Is),f=()=>{e.panels.duplicateByID(i)},h=()=>{t.editor.open(["_VIEWS_",e.id,"_PANELS_",i])},p=()=>n.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>e.panels.removeByID(i),confirmProps:{color:"red"},zIndex:320}),g=Z.default.useCallback(()=>{u(i)},[i,u]),v=!c&&e.type!==rt.Modal;return l(Oe,{children:l(d.Box,{sx:{position:"absolute",top:0,left:0,right:0,zIndex:300},children:y(d.Menu,{withinPortal:!0,children:[l(d.Menu.Target,{children:l(d.Box,{className:"panel-dropdown-target",sx:{width:"100%",height:"25px"}})}),y(d.Menu.Dropdown,{children:[l(d.Menu.Item,{onClick:s,icon:l(le.Refresh,{size:14}),children:"Refresh"}),l(d.Menu.Item,{onClick:()=>{var m;return t.queries.downloadDataByQueryID((m=o==null?void 0:o.id)!=null?m:"")},icon:l(le.Download,{size:14}),children:"Download Data"}),v&&l(d.Menu.Item,{onClick:g,icon:l(le.ArrowsMaximize,{size:14}),disabled:a,children:"Full Screen"}),a&&y(Oe,{children:[l(d.Divider,{label:"Edit",labelPosition:"center"}),l(d.Menu.Item,{onClick:h,icon:l(le.Settings,{size:14}),children:"Settings"}),l(d.Menu.Item,{onClick:f,icon:l(le.Copy,{size:14}),children:"Duplicate"}),l(d.Menu.Item,{color:"red",onClick:p,icon:l(le.Trash,{size:14}),children:"Delete"})]})]})]})})})}),v6="",MD=te.observer(function(){const{panel:t}=Yt(),{title:n}=t;return n?l(d.Group,{grow:!0,position:"center",px:20,className:"panel-title-wrapper",sx:{flexGrow:1},children:l(d.Text,{align:"center",lineClamp:1,weight:"bold",children:n})}):null}),gi=(e,t)=>{const[n,r]=x.useState([]);return x.useEffect(()=>e.watchTriggerSnapshotList(i=>r(i.filter(o=>o.schemaRef===t))),[]),n};class vi{constructor(t,n){this.root=t,this.path=n}async deleteItem(t){t===null&&await this.root.deleteItem(this.path);const n=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,H.omit(n,t))}async getItem(t){const n=await this.root.getItem(this.path);return t===null?n:H.get(n,t)}async setItem(t,n){if(t===null)await this.root.setItem(this.path,n);else{const r=await this.root.getItem(this.path)||{};await this.root.setItem(this.path,{...r,[t]:n})}return await this.getItem(t)}watchItem(t,n,r){return t===null?this.root.watchItem(this.path,(i,o)=>{n(i,o)},r):this.root.watchItem(this.path,(i,o)=>{const a=H.get(i,t),s=H.get(o,t);a!==s&&n(a,s)},r)}}class Ul{constructor(t,n,r){Re(this,"attachmentStorage");this.instance=t,this.attachmentKey=n,this.constructInstance=r,this.attachmentStorage=new vi(t.instanceData,n)}async getInstance(t){if(await this.attachmentStorage.getItem(t))return this.constructInstance(new vi(this.attachmentStorage,t))}async create(t,n){return await this.attachmentStorage.setItem(t,n),this.constructInstance(new vi(this.attachmentStorage,t))}async remove(t){await this.attachmentStorage.deleteItem(t)}async list(){const t=await this.attachmentStorage.getItem(null);return Promise.all(H.values(t).map(n=>this.constructInstance(new vi(this.attachmentStorage,n.id))))}}class bg{constructor(t){Re(this,"rootRef");this.rootRef=Ft.observable({current:t})}async deleteItem(t){Ft.runInAction(()=>{H.unset(this.rootRef.current,[t])})}getItem(t){const n=this.getValueFromRoot(t);return Promise.resolve(n)}getValueFromRoot(t){return t===null?Ft.toJS(this.rootRef.current):H.get(this.rootRef.current,[t])}setItem(t,n){if(t===null)if(H.isObject(n))Ft.runInAction(()=>{this.rootRef.current=n});else throw new Error("Cannot set root value to non-object");else Ft.runInAction(()=>{H.set(this.rootRef.current,[t],n)});return Promise.resolve(this.getItem(t))}watchItem(t,n,r){return Ft.reaction(()=>this.getValueFromRoot(t),(i,o)=>{n(i,o)},{requiresObservable:!0,fireImmediately:H.get(r,"fireImmediately",!1)})}}class kD{constructor(){Re(this,"channels",new Map);Re(this,"globalChannel",new dd.default)}getChannel(t){const n=this.channels.get(t);if(n)return n;const r=new dd.default;return this.channels.set(t,r),r}}class OD{constructor(t){Re(this,"instances",new Map);this.pluginManager=t}get availableVizList(){return this.pluginManager.installedPlugins.flatMap(t=>t.manifest.viz)}resolveComponent(t){return this.pluginManager.factory.viz(t)}getOrCreateInstance(t){const n=this.instances.get(t.id);if(n)return n;const r={id:t.id,name:t.viz.type,type:t.viz.type,messageChannels:new kD,instanceData:new bg(t.viz.conf)};return this.instances.set(t.id,r),r}}function wg(e,t,n,r){return{vizManager:n,locale:"zh",msgChannels:e.messageChannels,instanceData:e.instanceData,pluginData:new bg({}),colorPalette:{getColor(){return()=>""}},data:t,variables:r}}const DD=e=>{const{panel:t,vizManager:n,data:r,variables:i}=e,o=n.resolveComponent(t.viz.type),a=n.getOrCreateInstance(t),s={...wg(a,r,n,i),viewport:{width:t.layout.w,height:t.layout.h}},u=o.viewRender;return l(u,{context:s,instance:a,...H.omit(e,["panel","vizManager","data"])})},RD=e=>{const{vizManager:t,panel:n,panelInfoEditor:r,data:i,variables:o}=e,a=t.resolveComponent(n.viz.type),s=t.getOrCreateInstance(n),u={...wg(s,i,t,o),panelInfoEditor:r},c=a.configRender;return l(c,{context:u,instance:s,...H.omit(e,["panel","vizManager","data","panelInfoEditor"])})},xg=(e,t)=>{const n=$i.default.bezier(e),r=$i.default.bezier(t);return function(i){return i<50?n(i*2/100).hex():r((i-50)*2/100).hex()}},_a=e=>{const t=$i.default.bezier(e);return function(n){return t(n/100).hex()}},AD={type:"interpolation",displayName:"Red / Green",getColor:xg(["darkred","deeppink","lightyellow"],["lightyellow","lightgreen","teal"]),name:"red-green",category:"diverging"},PD={type:"interpolation",displayName:"Yellow / Blue",getColor:xg(["#8f531d","#ffd347","#e3efe3"],["#eefaee","#4ecbbf","#003f94"]),name:"yellow-blue",category:"diverging"},ID={type:"interpolation",displayName:"Red",getColor:_a(["#fff7f1","darkred"]),name:"red",category:"sequential"},ND={type:"interpolation",displayName:"Green",getColor:_a(["#f0ffed","darkgreen"]),name:"green",category:"sequential"},$D={type:"interpolation",displayName:"Blue",getColor:_a(["#f9fcff","#48b3e9","darkblue"]),name:"blue",category:"sequential"},LD={type:"interpolation",displayName:"Orange",getColor:_a(["#fff7f1","darkorange","#b60000"]),name:"orange",category:"sequential"},Sg="@devtable/dashboard",Yl="8.13.7",Cg="Apache-2.0",_g={access:"public",registry:"https://registry.npmjs.org/"},Eg=["dist"],Tg="./dist/dashboard.umd.js",Mg="./dist/dashboard.es.js",kg="./dist/index.d.ts",Og={".":{import:"./dist/dashboard.es.js",require:"./dist/dashboard.umd.js"},"./dist/style.css":{import:"./dist/style.css",require:"./dist/style.css"}},Dg={"dev-build":"tsc && vite build --watch",build:"tsc && vite build",preview:"vite preview",test:"vitest","test:ui":"vitest --ui",coverage:"vitest --coverage"},Rg={"@monaco-editor/react":"4.4.6","@types/chroma-js":"^2.1.4","file-saver":"2.0.5","monaco-editor":"0.36.0","performant-array-to-tree":"1.11.0",popmotion:"^11.0.3","rc-tree-select":"5.5.5",reactflow:"^11.5.3"},Ag={"@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@testing-library/cypress":"^8.0.3","@testing-library/jest-dom":"^5.16.4","@testing-library/react":"^13.3.0","@testing-library/react-hooks":"^8.0.1","@testing-library/user-event":"^14.3.0","@tiptap/extension-code-block-lowlight":"^2.0.0-beta.209","@tiptap/extension-color":"^2.0.0-beta.209","@tiptap/extension-highlight":"^2.0.0-beta.209","@tiptap/extension-link":"^2.0.0-beta.209","@tiptap/extension-placeholder":"^2.0.0-beta.209","@tiptap/extension-subscript":"^2.0.0-beta.209","@tiptap/extension-superscript":"^2.0.0-beta.209","@tiptap/extension-text-align":"^2.0.0-beta.209","@tiptap/extension-text-style":"^2.0.0-beta.209","@tiptap/extension-underline":"^2.0.0-beta.209","@tiptap/react":"^2.0.0-beta.209","@tiptap/starter-kit":"^2.0.0-beta.209","@types/crypto-js":"v4.1.1","@types/d3-array":"3.0.3","@types/eventemitter2":"^4.1.0","@types/file-saver":"2.0.5","@types/lodash":"^4.14.182","@types/react":"^18.0.0","@types/react-dom":"^18.0.0","@types/react-grid-layout":"^1.3.2",ahooks:"^3.3.11",ajv:"8.11.0",axios:"^0.27.2","crypto-js":"^4.1.1",cypress:"^10.6.0","cypress-wait-until":"^1.7.2",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9","echarts-stat":"1.2.0",jsdom:"^20.0.0","jsdom-testing-mocks":"^1.5.0",lodash:"^4.17.21",lowlight:"^2.8.0",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","rollup-plugin-visualizer":"5.6.0","tabler-icons-react":"^1.48.0",typescript:"^4.6.3","vite-plugin-static-copy":"0.13.1"},Pg={"@emotion/react":"11.10.0","@mantine/core":"5.9.5","@mantine/dates":"5.9.5","@mantine/form":"5.9.5","@mantine/hooks":"5.9.5","@mantine/modals":"5.9.5","@mantine/notifications":"5.9.5","@mantine/prism":"5.9.5","@mantine/tiptap":"5.9.5","@tabler/icons":"^1.118.0","@tanstack/react-table":"^8.5.13","@tiptap/extension-code-block-lowlight":"^2.0.0-beta.209","@tiptap/extension-color":"^2.0.0-beta.209","@tiptap/extension-highlight":"^2.0.0-beta.209","@tiptap/extension-link":"^2.0.0-beta.209","@tiptap/extension-placeholder":"^2.0.0-beta.209","@tiptap/extension-subscript":"^2.0.0-beta.209","@tiptap/extension-superscript":"^2.0.0-beta.209","@tiptap/extension-text-align":"^2.0.0-beta.209","@tiptap/extension-text-style":"^2.0.0-beta.209","@tiptap/extension-underline":"^2.0.0-beta.209","@tiptap/react":"^2.0.0-beta.209","@tiptap/starter-kit":"^2.0.0-beta.209",ahooks:"^3.3.11",axios:"^0.27.2","chroma-js":"^2.4.2","d3-array":"3.2.0","d3-regression":"1.2.8",dayjs:"1.11.6",echarts:"^5.3.2","echarts-for-react":"^3.0.2","echarts-gl":"^2.0.9","echarts-stat":"1.2.0",eventemitter2:"^6.4.6",jszip:"3.10.1",lodash:"^4.17.21",lowlight:"^2.8.0",mobx:"^6.6.1","mobx-react-lite":"^3.4.0","mobx-state-tree":"^5.1.5",numbro:"^2.3.6","prosemirror-commands":"^1.5.0","prosemirror-dropcursor":"^1.6.1","prosemirror-gapcursor":"^1.3.1","prosemirror-history":"^1.3.0","prosemirror-keymap":"^1.2.0","prosemirror-schema-list":"^1.2.2",react:"^16.8.0 || 17.x || 18.x","react-dom":"^16.8.0 || 17.x || 18.x","react-grid-layout":"^1.3.4","react-hook-form":"^7.31.2","react-virtual":"^2.10.4","tabler-icons-react":"^1.48.0"},VD=Object.freeze(Object.defineProperty({__proto__:null,name:Sg,version:Yl,license:Cg,publishConfig:_g,files:Eg,main:Tg,module:Mg,types:kg,exports:Og,scripts:Dg,dependencies:Rg,devDependencies:Ag,peerDependencies:Pg,default:{name:Sg,version:Yl,license:Cg,publishConfig:_g,files:Eg,main:Tg,module:Mg,types:kg,exports:Og,scripts:Dg,dependencies:Rg,devDependencies:Ag,peerDependencies:Pg}},Symbol.toStringTag,{value:"Module"}));class zD{constructor(t){Re(this,"staticColors",new Map);Re(this,"interpolations",new Map);t.installedPlugins.forEach(n=>{n.manifest.color.forEach(r=>{this.register(r)})})}getStaticColors(){return Array.from(this.staticColors.values())}register(t){const n=this.encodeColor(t);t.type==="single"?(this.staticColors.has(n)&&console.warn(`the color '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.staticColors.set(n,t)):t.type==="interpolation"&&(this.interpolations.has(n)&&console.warn(`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`,`the interpolation '${t.name}' has been registered under '${t.category}', previous registered value will be overridden`),this.interpolations.set(n,t))}decodeStaticColor(t){return this.staticColors.get(t)}encodeColor(t){return`\${${t.category}}.{${t.name}}`}decodeInterpolation(t){return this.interpolations.get(t)}getColorInterpolations(){return Array.from(this.interpolations.values())}}class FD{constructor(){Re(this,"plugins",new Map);Re(this,"vizComponents",new Map);Re(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 BD{constructor(){Re(this,"migrations",[])}version(t,n){return this.migrations.push({version:t,handler:n}),this}run(t,n,r){var a;if(t.from===t.to)return n;if(t.from>t.to)throw new Error(`Can not downgrade from version '${t.from}' to (${t.to})`);const i=this.migrations.filter(s=>s.version>t.from&&s.version<=t.to),o=H.orderBy(i,"version","asc");if(((a=H.last(o))==null?void 0:a.version)!==t.to)throw new Error(`Migration to version ${t.to} not found`);return o.reduce((s,u)=>u.handler(s,r),n)}}class tn extends BD{constructor(){super(),this.configVersions()}version(t,n){return super.version(t,(r,i)=>({version:t,...n(r,i)}))}async migrate({configData:t,panelModel:n}){const r=await t.getItem(null),i=H.get(r,"version",0),o=this.run({from:i,to:this.VERSION},r,{panelModel:n});await t.setItem(null,o)}async needMigration({configData:t}){const n=await t.getItem(null);return H.get(n,"version",0)<this.VERSION}}const Je=(e,t)=>{const[n,{setFalse:r}]=tt.useBoolean(!0),[i,o]=x.useState();x.useEffect(()=>(e.getItem(t).then(s=>{o(s),r()}),e.watchItem(t,s=>{o(s)})));const a=x.useCallback(async s=>{await e.setItem(t,s),o(s)},[e,t]);return{loading:n,value:i,set:a}},Xl={x_axis_data_key:"",y_axis_data_key:"",z_axis_data_key:"",xAxis3D:{type:"value",name:"X Axis Name"},yAxis3D:{type:"value",name:"Y Axis Name"},zAxis3D:{type:"value",name:"Z Axis Name"}};Rt.use([ut.GridComponent,ut.VisualMapComponent,ut.LegendComponent,ut.TooltipComponent,Hn.CanvasRenderer]);function jD({context:e}){const{value:t}=Je(e.instanceData,"config"),n=e.data,{width:r,height:i}=e.viewport,{x_axis_data_key:o,y_axis_data_key:a,z_axis_data_key:s,xAxis3D:u,yAxis3D:c,zAxis3D:f}=H.defaults({},t,Xl),h=x.useMemo(()=>{const v=H.minBy(n,m=>m[s]);return H.get(v,s)},[n,s]),p=x.useMemo(()=>{const v=H.maxBy(n,m=>m[s]);return H.get(v,s)},[n,s]),g={tooltip:{},backgroundColor:"#fff",visualMap:{show:!0,dimension:2,min:h,max:p,inRange:{color:["#313695","#4575b4","#74add1","#abd9e9","#e0f3f8","#ffffbf","#fee090","#fdae61","#f46d43","#d73027","#a50026"]}},xAxis3D:u,yAxis3D:c,zAxis3D:f,grid3D:{viewControl:{projection:"orthographic",autoRotate:!1},light:{main:{shadow:!0,quality:"ultra",intensity:1.5}}},series:[{type:"bar3D",wireframe:{},data:n.map(v=>[v[o],v[a],v[s]])}]};return t?l(Wn.default,{echarts:Rt,option:g,style:{width:r,height:i},notMerge:!0}):null}function GD({label:e,required:t,value:n,onChange:r,data:i,clearable:o=!1,sx:a,...s},u){const c=Z.default.useMemo(()=>{if(!Array.isArray(i)||i.length===0)return[];const h=Object.keys(i[0]).map(p=>({label:p,value:p}));return o?h.concat([{label:"unset",value:""}]):h},[i]);return l(d.Select,{ref:u,label:e,data:c,value:n,onChange:r,required:t,sx:a,...s})}const mt=Z.default.forwardRef(GD);function KD({context:e}){const{value:t,set:n}=Je(e.instanceData,"config"),r=e.data,i=H.defaults({},t,Xl),{control:o,handleSubmit:a,reset:s}=j.useForm({defaultValues:i});return x.useEffect(()=>{s(i)},[t]),t?l(d.Stack,{spacing:"xs",children:y("form",{onSubmit:a(n),children:[l(d.Text,{children:"X Axis"}),y(d.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(j.Controller,{name:"x_axis_data_key",control:o,render:({field:u})=>l(mt,{label:"Data Field",required:!0,data:r,...u})}),l(j.Controller,{name:"xAxis3D.name",control:o,render:({field:u})=>l(d.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(d.Text,{mt:"lg",children:"Y Axis"}),y(d.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(j.Controller,{name:"y_axis_data_key",control:o,render:({field:u})=>l(mt,{label:"Data Field",required:!0,data:r,...u})}),l(j.Controller,{name:"yAxis3D.name",control:o,render:({field:u})=>l(d.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(d.Text,{mt:"lg",children:"Z Axis"}),y(d.Group,{position:"apart",grow:!0,p:"md",sx:{position:"relative",border:"1px solid #eee"},children:[l(j.Controller,{name:"z_axis_data_key",control:o,render:({field:u})=>l(mt,{label:"Data Field",required:!0,data:r,...u})}),l(j.Controller,{name:"zAxis3D.name",control:o,render:({field:u})=>l(d.TextInput,{sx:{flexGrow:1},size:"md",label:"Name",...u})})]}),l(d.Group,{position:"center",mt:"xl",grow:!0,sx:{width:"60%"},mx:"auto",children:y(d.Button,{color:"blue",type:"submit",children:[l(le.DeviceFloppy,{size:20}),l(d.Text,{ml:"md",children:"Save"})]})})]})}):null}class HD extends tn{constructor(){super(...arguments);Re(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const WD={displayName:"Bar Chart (3D)",migrator:new HD,name:"bar-3d",viewRender:jD,configRender:KD,createConfig(){return{version:1,config:H.cloneDeep(Xl)}}},Ln={mantissa:0,output:"number",trimMantissa:!1,average:!1};function qD({value:e,onChange:t},n){const r=s=>{t({...e,output:s})},i=s=>{const u=s===0?!1:e.trimMantissa;t({...e,mantissa:s,trimMantissa:u})},o=s=>{t({...e,trimMantissa:s.currentTarget.checked})},a=s=>{t({...e,average:s.currentTarget.checked})};return y(d.Stack,{ref:n,children:[y(d.Group,{grow:!0,children:[l(d.Select,{label:"Format",data:[{label:"1234",value:"number"},{label:"99%",value:"percent"}],value:e.output,onChange:r,sx:{flexGrow:1}}),l(d.Switch,{label:y(d.Stack,{spacing:0,children:[l(d.Text,{children:"Average"}),l(d.Text,{size:12,color:"gray",children:"like 1.234k, 1.234m"})]}),checked:e.average,onChange:a,disabled:e.output!=="number",sx:{flexGrow:1},styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"},label:{display:"block"}}})]}),y(d.Group,{grow:!0,children:[l(d.NumberInput,{label:"Mantissa",defaultValue:0,min:0,step:1,max:4,value:e.mantissa,onChange:i}),l(d.Switch,{label:"Trim mantissa",checked:e.trimMantissa,onChange:o,disabled:e.mantissa===0,styles:{root:{alignSelf:"flex-end"},body:{alignItems:"center"}}})]}),y(d.Stack,{spacing:0,children:[l(d.Text,{weight:"bold",children:"Preview"}),l(Or,{children:y(d.Group,{position:"apart",children:[y(d.Text,{size:12,color:"gray",children:["123456789 ",l(le.ArrowRight,{size:9})," ",Bt.default(123456789).format(e)]}),y(d.Text,{size:12,color:"gray",children:["1234 ",l(le.ArrowRight,{size:9})," ",Bt.default(1234).format(e)]}),y(d.Text,{size:12,color:"gray",children:["0.1234 ",l(le.ArrowRight,{size:9})," ",Bt.default(.1234).format(e)]})]})})]})]})}const $r=Z.default.forwardRef(qD),Lr={enabled:!1,func_content:["function label(value, index) {"," // your code goes here"," // return value","}"].join(`
76
76
  `)},br={x_axis:{width:80,overflow:"truncate",ellipsis:"..."},tooltip:{width:200,overflow:"break",ellipsis:"..."}},Ig={id:"builtin:echarts:click-echart:series",displayName:"Click Chart Series",nameRender:YD,configRender:UD,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 UD(e){return l(Oe,{})}function YD(e){return l(d.Text,{children:"Click chart's series"})}const Ql={x_axis:{name:"X Axis",data_key:"",axisLabel:{rotate:0,formatter:{...Lr},overflow:br}},y_axis:{name:"Y Axis",data_key:"value",label_formatter:Ln},color:"#228be6",reference_lines:[]},io=x.forwardRef(function({value:t,onChange:n,...r},i){return l(d.TextInput,{ref:i,value:t,onChange:n,...r})}),XD=[{label:"None",value:"none"},{label:"Sum",value:"sum"},{label:"Mean",value:"mean"},{label:"Median",value:"median"},{label:"Max",value:"max"},{label:"Min",value:"min"},{label:"Quantile(99%, 95%, ...)",value:"quantile"}];function QD({label:e,value:t,onChange:n,pt:r="sm"},i){x.useEffect(()=>{typeof t=="string"&&(console.log(t),n({type:t,config:{}}))},[t,n]);const o=s=>{n(s==="quantile"?{type:"quantile",config:{p:.99}}:{type:s,config:{}})},a=s=>{n({type:"quantile",config:{p:s}})};return y(d.Group,{grow:!0,noWrap:!0,pt:r,children:[l(d.Select,{ref:i,label:e,data:XD,value:t.type,onChange:o}),t.type==="quantile"&&l(d.NumberInput,{label:"p",value:t.config.p,onChange:a,precision:2,min:.05,step:.05,max:1})]})}const Zl=Z.default.forwardRef(QD);function ZD({label:e,value:t,onChange:n},r){const[i,o]=Z.default.useState(Array.isArray(t)?[...t]:[]),a=Z.default.useCallback(()=>{o(p=>[...p,""])},[o]),s=Z.default.useCallback(p=>{o(g=>(g.splice(p,1),[...g]))},[o]),u=Z.default.useMemo(()=>!fe.default.isEqual(i,t),[i,t]),c=()=>{n(i.map(p=>p.toString()))},f=d.useMantineTheme(),h=Z.default.useMemo(()=>Object.entries(f.colors).map(([p,g])=>g[6]),[f]);return y(Oe,{children:[y(d.Group,{position:"left",ref:r,children:[l(d.Text,{children:e}),l(d.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!u,onClick:c,children:l(le.DeviceFloppy,{size:20})})]}),y(d.Group,{children:[i.map((p,g)=>l(d.ColorInput,{value:p,onChange:v=>{o(m=>(m.splice(g,1,v),[...m]))},swatches:h,rightSection:l(d.ActionIcon,{onClick:()=>s(g),color:"red",children:l(le.Trash,{size:14})}),sx:{width:"45%"}})),l(d.ActionIcon,{onClick:a,color:"blue",variant:"outline",children:l(le.PlaylistAdd,{size:20})})]})]})}const JD=Z.default.forwardRef(ZD);function e2({value:e,onChange:t},n){const{colorManager:r}=x.useContext(zn),i=Z.default.useMemo(()=>r.getStaticColors().map(s=>({label:s.name,group:s.category,value:s.value})),[r]),o=Z.default.useMemo(()=>i.some(a=>a.value===e),[e,i]);return y(d.Group,{position:"apart",spacing:4,ref:n,children:[l(d.TextInput,{placeholder:"Set any color",value:o?"":e,onChange:a=>t(a.currentTarget.value),rightSection:l(d.ColorSwatch,{color:o?"transparent":e,radius:4}),variant:o?"filled":"default",sx:{maxWidth:"46%",flexGrow:1}}),l(d.Text,{sx:{flexGrow:0},children:"or"}),l(d.Select,{data:i,value:e,onChange:t,variant:o?"default":"filled",placeholder:"Pick a theme color",icon:l(d.ColorSwatch,{color:o?e:"transparent",radius:4}),sx:{maxWidth:"46%",flexGrow:1}})]})}const kn=Z.default.forwardRef(e2),Ea=[{label:"initial",value:0},{label:"500",value:25},{label:"700",value:50},{label:"semibold",value:75},{label:"bold",value:100}];function t2({label:e,value:t,onChange:n},r){var a,s;const[i,o]=Z.default.useState((s=(a=Ea.find(u=>u.label===t))==null?void 0:a.value)!=null?s:Ea[0].value);return Z.default.useEffect(()=>{const u=Ea.find(c=>c.value===i);u&&n(u.label)},[i]),y(d.Stack,{spacing:0,mt:"sm",mb:"lg",children:[l(d.Text,{size:"sm",children:e}),l(d.Slider,{label:null,marks:Ea,value:i,onChange:o,step:25,placeholder:"Pick a font size",px:"1em",ref:r})]})}const Ng=Z.default.forwardRef(t2);function n2({label:e,value:t,onChange:n,type:r},i){const[o,a]=Z.default.useState(Array.isArray(t)?[...t]:[]),s=Z.default.useCallback(()=>{a(h=>[...h,""])},[a]),u=Z.default.useCallback(h=>{a(p=>(p.splice(h,1),[...p]))},[a]),c=Z.default.useMemo(()=>!fe.default.isEqual(o.map(String),t.map(String)),[o,t]),f=()=>{n(o.map(h=>r==="number"?Number(h):h.toString()))};return y(Oe,{children:[y(d.Group,{position:"left",ref:i,children:[l(d.Text,{children:e}),l(d.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!c,onClick:f,children:l(le.DeviceFloppy,{size:20})})]}),y(d.Group,{children:[o.map((h,p)=>l(d.TextInput,{type:r,value:h,onChange:g=>{const v=g.currentTarget.value;a(m=>(m.splice(p,1,v),[...m]))},rightSection:l(d.ActionIcon,{onClick:()=>u(p),color:"red",children:l(le.Trash,{size:14})}),sx:{width:"45%"}})),l(d.ActionIcon,{onClick:s,color:"blue",variant:"outline",children:l(le.PlaylistAdd,{size:20})})]})]})}const r2=Z.default.forwardRef(n2),$g=Z.default.forwardRef(function({value:t,onChange:n},r){const i=t.color.type,o=(a,s)=>{const u=fe.default.cloneDeep(t);fe.default.set(u,a,s),n(u)};return y(Oe,{children:[l(d.Divider,{my:"xs",label:"Typography",labelPosition:"center"}),l(d.Stack,{children:l(d.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},value:t.size,onChange:a=>o("size",a.currentTarget.value)})}),l(d.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:l(Ng,{label:"Font Weight",value:t.weight,onChange:a=>o("weight",a)})}),l(d.Divider,{my:"xs",label:"Style",labelPosition:"center"}),y(d.Stack,{children:[l(d.Select,{label:"Color Type",data:[{label:"Static Color",value:"static"},{label:"Continuous Color",value:"continuous"}],value:t.color.type,onChange:a=>o("color.type",a)}),i==="static"&&l(kn,{value:t.color.staticColor,onChange:a=>o("color.staticColor",a)}),i==="continuous"&&y(Oe,{children:[l(r2,{label:"Value Range",value:t.color.valueRange,type:"number",onChange:a=>o("color.valueRange",a)}),l(JD,{label:"Color Range",value:t.color.colorRange,onChange:a=>o("color.colorRange",a)})]})]})]})});Z.default.forwardRef(function({value:t,onChange:n,data:r,withStyle:i=!0},o){const a=(s,u)=>{const c=fe.default.cloneDeep(t);fe.default.set(c,s,u),n(c)};return y(d.Box,{px:"sm",py:"md",ref:o,children:[l(d.Text,{weight:"bold",pb:0,children:t.name}),l(d.Divider,{my:"xs",label:"Data",labelPosition:"center"}),y(d.Group,{grow:!0,noWrap:!0,children:[l(d.TextInput,{label:"Name",required:!0,value:t.name,onChange:s=>a("name",s.currentTarget.value)}),l(mt,{label:"Data Field",required:!0,data:r,value:t.data_field,onChange:s=>a("data_field",s)})]}),l(Zl,{label:"Aggregation",value:t.aggregation,onChange:s=>a("aggregation",s)}),l(d.Divider,{my:"xs",label:"Format",labelPosition:"center"}),l($r,{value:t.formatter,onChange:s=>a("formatter",s)}),i&&l($g,{value:t,onChange:n})]})});const Ta={type:"none",config:{}};function i2(e){const t=Array.from(e).sort((r,i)=>r-i),n=Math.floor(t.length/2);return t.length%2===0?(t[n-1]+t[n])/2:t[n]}function o2(e,t){const n=e[t],r=Number(n);return isFinite(r)?r:0}function Ma(e,t,n){var r,i,o;try{const a=e.map(s=>o2(s,t));switch(n.type){case"sum":return fe.default.sum(a);case"mean":return fe.default.mean(a);case"median":return i2(a);case"max":return(r=fe.default.max(a))!=null?r:0;case"min":return(i=fe.default.min(a))!=null?i:0;case"quantile":return(o=$o.quantile(a,n.config.p))!=null?o:0;default:return a}}catch(a){return console.error(a),null}}var Lg=function(){},oo=function(){};process.env.NODE_ENV!=="production"&&(Lg=function(e,t){!e&&typeof console<"u"&&console.warn(t)},oo=function(e,t){if(!e)throw new Error(t)});const a2=(e,t,n)=>Math.min(Math.max(n,e),t),Vg=(e,t,n)=>{const r=t-e;return r===0?1:(n-e)/r},Jl=(e,t,n)=>-n*e+n*t+e,zg=(e,t)=>n=>Math.max(Math.min(n,t),e),ao=e=>e%1?Number(e.toFixed(5)):e,ka=/(-)?([\d]*\.?[\d])+/g,eu=/(#[0-9a-f]{6}|#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))/gi,s2=/^(#[0-9a-f]{3}|#(?:[0-9a-f]{2}){2,4}|(rgb|hsl)a?\((-?[\d\.]+%?[,\s]+){2,3}\s*\/*\s*[\d\.]+%?\))$/i;function so(e){return typeof e=="string"}const Oa={test:e=>typeof e=="number",parse:parseFloat,transform:e=>e},Fg=Object.assign(Object.assign({},Oa),{transform:zg(0,1)});Object.assign(Object.assign({},Oa),{default:1});const lo=(e=>({test:t=>so(t)&&t.endsWith(e)&&t.split(" ").length===1,parse:parseFloat,transform:t=>`${t}${e}`}))("%");Object.assign(Object.assign({},lo),{parse:e=>lo.parse(e)/100,transform:e=>lo.transform(e*100)});const tu=(e,t)=>n=>Boolean(so(n)&&s2.test(n)&&n.startsWith(e)||t&&Object.prototype.hasOwnProperty.call(n,t)),Bg=(e,t,n)=>r=>{if(!so(r))return r;const[i,o,a,s]=r.match(ka);return{[e]:parseFloat(i),[t]:parseFloat(o),[n]:parseFloat(a),alpha:s!==void 0?parseFloat(s):1}},Vr={test:tu("hsl","hue"),parse:Bg("hue","saturation","lightness"),transform:({hue:e,saturation:t,lightness:n,alpha:r=1})=>"hsla("+Math.round(e)+", "+lo.transform(ao(t))+", "+lo.transform(ao(n))+", "+ao(Fg.transform(r))+")"},l2=zg(0,255),nu=Object.assign(Object.assign({},Oa),{transform:e=>Math.round(l2(e))}),wr={test:tu("rgb","red"),parse:Bg("red","green","blue"),transform:({red:e,green:t,blue:n,alpha:r=1})=>"rgba("+nu.transform(e)+", "+nu.transform(t)+", "+nu.transform(n)+", "+ao(Fg.transform(r))+")"};function u2(e){let t="",n="",r="",i="";return e.length>5?(t=e.substr(1,2),n=e.substr(3,2),r=e.substr(5,2),i=e.substr(7,2)):(t=e.substr(1,1),n=e.substr(2,1),r=e.substr(3,1),i=e.substr(4,1),t+=t,n+=n,r+=r,i+=i),{red:parseInt(t,16),green:parseInt(n,16),blue:parseInt(r,16),alpha:i?parseInt(i,16)/255:1}}const ru={test:tu("#"),parse:u2,transform:wr.transform},Da={test:e=>wr.test(e)||ru.test(e)||Vr.test(e),parse:e=>wr.test(e)?wr.parse(e):Vr.test(e)?Vr.parse(e):ru.parse(e),transform:e=>so(e)?e:e.hasOwnProperty("red")?wr.transform(e):Vr.transform(e)},jg="${c}",Gg="${n}";function c2(e){var t,n,r,i;return isNaN(e)&&so(e)&&((n=(t=e.match(ka))===null||t===void 0?void 0:t.length)!==null&&n!==void 0?n:0)+((i=(r=e.match(eu))===null||r===void 0?void 0:r.length)!==null&&i!==void 0?i:0)>0}function Kg(e){typeof e=="number"&&(e=`${e}`);const t=[];let n=0;const r=e.match(eu);r&&(n=r.length,e=e.replace(eu,jg),t.push(...r.map(Da.parse)));const i=e.match(ka);return i&&(e=e.replace(ka,Gg),t.push(...i.map(Oa.parse))),{values:t,numColors:n,tokenised:e}}function Hg(e){return Kg(e).values}function Wg(e){const{values:t,numColors:n,tokenised:r}=Kg(e),i=t.length;return o=>{let a=r;for(let s=0;s<i;s++)a=a.replace(s<n?jg:Gg,s<n?Da.transform(o[s]):ao(o[s]));return a}}const d2=e=>typeof e=="number"?0:e;function f2(e){const t=Hg(e);return Wg(e)(t.map(d2))}const qg={test:c2,parse:Hg,createTransformer:Wg,getAnimatableNone:f2};function iu(e,t,n){return n<0&&(n+=1),n>1&&(n-=1),n<1/6?e+(t-e)*6*n:n<1/2?t:n<2/3?e+(t-e)*(2/3-n)*6:e}function Ug({hue:e,saturation:t,lightness:n,alpha:r}){e/=360,t/=100,n/=100;let i=0,o=0,a=0;if(!t)i=o=a=n;else{const s=n<.5?n*(1+t):n+t-n*t,u=2*n-s;i=iu(u,s,e+1/3),o=iu(u,s,e),a=iu(u,s,e-1/3)}return{red:Math.round(i*255),green:Math.round(o*255),blue:Math.round(a*255),alpha:r}}const p2=(e,t,n)=>{const r=e*e,i=t*t;return Math.sqrt(Math.max(0,n*(i-r)+r))},h2=[ru,wr,Vr],Yg=e=>h2.find(t=>t.test(e)),Xg=e=>`'${e}' is not an animatable color. Use the equivalent color code instead.`,Qg=(e,t)=>{let n=Yg(e),r=Yg(t);oo(!!n,Xg(e)),oo(!!r,Xg(t));let i=n.parse(e),o=r.parse(t);n===Vr&&(i=Ug(i),n=wr),r===Vr&&(o=Ug(o),r=wr);const a=Object.assign({},i);return s=>{for(const u in a)u!=="alpha"&&(a[u]=p2(i[u],o[u],s));return a.alpha=Jl(i.alpha,o.alpha,s),n.transform(a)}},g2=e=>typeof e=="number",v2=(e,t)=>n=>t(e(n)),Zg=(...e)=>e.reduce(v2);function Jg(e,t){return g2(e)?n=>Jl(e,t,n):Da.test(e)?Qg(e,t):nv(e,t)}const ev=(e,t)=>{const n=[...e],r=n.length,i=e.map((o,a)=>Jg(o,t[a]));return o=>{for(let a=0;a<r;a++)n[a]=i[a](o);return n}},m2=(e,t)=>{const n=Object.assign(Object.assign({},e),t),r={};for(const i in n)e[i]!==void 0&&t[i]!==void 0&&(r[i]=Jg(e[i],t[i]));return i=>{for(const o in r)n[o]=r[o](i);return n}};function tv(e){const t=qg.parse(e),n=t.length;let r=0,i=0,o=0;for(let a=0;a<n;a++)r||typeof t[a]=="number"?r++:t[a].hue!==void 0?o++:i++;return{parsed:t,numNumbers:r,numRGB:i,numHSL:o}}const nv=(e,t)=>{const n=qg.createTransformer(t),r=tv(e),i=tv(t);return r.numHSL===i.numHSL&&r.numRGB===i.numRGB&&r.numNumbers>=i.numNumbers?Zg(ev(r.parsed,i.parsed),n):(Lg(!0,`Complex values '${e}' and '${t}' too different to mix. Ensure all colors are of the same type, and that each contains the same quantity of number and color values. Falling back to instant transition.`),a=>`${a>0?t:e}`)},y2=(e,t)=>n=>Jl(e,t,n);function b2(e){if(typeof e=="number")return y2;if(typeof e=="string")return Da.test(e)?Qg:nv;if(Array.isArray(e))return ev;if(typeof e=="object")return m2}function w2(e,t,n){const r=[],i=n||b2(e[0]),o=e.length-1;for(let a=0;a<o;a++){let s=i(e[a],e[a+1]);if(t){const u=Array.isArray(t)?t[a]:t;s=Zg(u,s)}r.push(s)}return r}function x2([e,t],[n]){return r=>n(Vg(e,t,r))}function S2(e,t){const n=e.length,r=n-1;return i=>{let o=0,a=!1;if(i<=e[0]?a=!0:i>=e[r]&&(o=r-1,a=!0),!a){let u=1;for(;u<n&&!(e[u]>i||u===r);u++);o=u-1}const s=Vg(e[o],e[o+1],i);return t[o](s)}}function Ra(e,t,{clamp:n=!0,ease:r,mixer:i}={}){const o=e.length;oo(o===t.length,"Both input and output ranges must be the same length"),oo(!r||!Array.isArray(r)||r.length===o-1,"Array of easing functions must be of length `input.length - 1`, as it applies to the transitions **between** the defined values."),e[0]>e[o-1]&&(e=[].concat(e),t=[].concat(t),e.reverse(),t.reverse());const a=w2(t,r,i),s=o===2?x2(e,a):S2(e,a);return n?u=>s(a2(e[0],e[o-1],u)):s}class C2{constructor({valueRange:t,colorRange:n}){Re(this,"mapper");this.mapper=Ra(t,n)}getColor(t){return this.mapper(t)}}function _2(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?`Array(${e.length})`:e.toString()}function Aa({data_field:e,aggregation:t},n){return Ma(n,e,t)}function mi({formatter:e},t){return["string","number"].includes(typeof t)?Bt.default(t).format(e):_2(t)}function E2(e,t){if(e.type==="static")return e.staticColor;if(e.type==="continuous")try{if(Array.isArray(t)||t===null)throw new Error(`[getColorByColorConf] Invalid type of aggregated value: ${t}`);return new C2(e).getColor(t)}catch(n){return console.error(n),"black"}return"black"}function rv(e,t){const{color:n,data_field:r,aggregation:i,size:o,weight:a}=e,s=Ma(t,r,i),u=mi(e,s);return l(d.Text,{sx:{fontSize:o,display:"inline"},color:E2(n,s),weight:a,children:u})}function T2(e,t){const n={};return e.forEach(r=>{const i=r.name;n[i]=rv(r,t)}),n}function M2(e){return e.split(" ").map((t,n)=>y(Z.default.Fragment,{children:[t,"\xA0"]},n))}function k2(e){const n=e.replaceAll("<br />","<br/>").replaceAll(`
77
77
  `,"<br/>").split("<br/>");return n.map((i,o)=>{const a=[M2(i)];return o!==n.length-1&&a.push(l("br",{})),a}).flat().filter(i=>i!==void 0)}function ou(e){return k2(e)}function uo(e,t,n){const r=T2(t,n),i=/^\{(.+)\}(.*)$/;return e.split("$").map(o=>{var c;const a=i.exec(o);if(!a)return ou(o);const s=r[a[1]];if(!s)return ou(o);const u=(c=a[2])!=null?c:"";return y(Oe,{children:[s,ou(u)]})})}function O2(e,t){const n={};return e.forEach(r=>{const{name:i,data_field:o,aggregation:a}=r,s=Ma(t,o,a);n[i]=mi(r,s)}),n}function au(e,t,n){const r=O2(t,n),i=/^\{(.+)\}(.*)$/;return e.split("$").map(o=>{var c;const a=i.exec(o);if(!a)return o;const s=r[a[1]];if(!s)return o;const u=(c=a[2])!=null?c:"";return`${s}${u}`}).join("")}function Pa({enabled:e,func_content:t}){return(n,r)=>{if(!e)return n;try{return new Function(`return ${t}`)()(n,r)}catch(i){return console.error(`[getEchartsXAxisLabel] failed parsing custom function, error: ${i.message}`),n}}}function Ia(e){return{width:e.width,overflow:e.overflow,ellipsis:e.ellipsis}}function co(e){const t={truncate:"initial",break:"break-all",breakAll:"break-word"}[e.overflow],n=e.overflow==="truncate"?"nowrap":"initial",r={truncate:"ellipsis",break:"clip",breakAll:"clip"}[e.overflow];return`
78
78
  max-width: ${e.width}px;
@@ -244,9 +244,9 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
244
244
  </table>
245
245
  `}}}function F$(e,t){var i;const n=t.every(o=>!Number.isNaN(Number(o))),{axisLabel:r}=e.x_axis;return[{data:t,name:(i=e.x_axis.name)!=null?i:"",id:"main-x-axis",axisTick:{show:!0,alignWithLabel:!0},type:n?"value":"category",axisLabel:{...r,formatter:Bv(r.formatter)}}]}function B$(e,t){return e.y_axes.map(({nameAlignment:n,min:r,max:i,...o},a)=>{var u;let s=o.position;return s||(s=a>0?"right":"left"),{...o,min:r||void 0,max:i||void 0,position:s,axisLabel:{show:!0,formatter:(u=t[a])!=null?u:t.default},axisLine:{show:!0},nameTextStyle:{fontWeight:"bold",align:n},nameLocation:"end",nameGap:15,splitLine:{show:!1}}})}function j$(){return{show:!1,bottom:0,left:"center",type:"scroll"}}const G$={tooltip:{trigger:"axis"},xAxis:[{type:"category",nameGap:25,nameLocation:"center",nameTextStyle:{fontWeight:"bold"},splitLine:{show:!1},axisTick:{show:!0,alignWithLabel:!0}}],grid:{top:10,left:20,right:15,bottom:25,containLabel:!0}};function K$(e,t,n){const r=n.reduce((c,f)=>{const h=Aa(f,t);return c[f.name]=mi(f,h),c},{}),i=e.y_axes.reduce((c,{label_formatter:f},h)=>(c[h]=function(g){let v=g;if(typeof g=="object"&&(Array.isArray(g.value)&&g.value.length===2?v=g.value[1]:v=g.value),!f)return v;try{return Bt.default(v).format(f)}catch(m){return console.error(m),v}},c),{default:({value:c})=>c}),o=fe.default.uniq(t.map(c=>c[e.x_axis.data_key])),a=o.every(c=>!Number.isNaN(Number(c))),s=$$(e,o,a,t,i,n,r),u={xAxis:F$(e,o),yAxis:B$(e,i),series:s,dataset:[{source:t}],tooltip:z$(e,i),grid:D$(e),legend:j$(),dataZoom:du(e.dataZoom)};return H.defaultsDeep({},u,G$)}Rt.use([ut.DataZoomComponent,pn.BarChart,pn.LineChart,pn.ScatterChart,ut.GridComponent,ut.LegendComponent,ut.TooltipComponent,Hn.CanvasRenderer,ut.MarkLineComponent,ut.MarkAreaComponent]),Rt.registerTransform(Ds.transform.regression);function jv(e){return e.trim().length>0}function H$({conf:e,data:t,width:n,height:r,interactionManager:i,variables:o}){const a=x.useMemo(()=>fe.default.keyBy(t,e.x_axis.data_key),[t,e.x_axis.data_key]),s=gi(i.triggerManager,Vv.id),u=x.useCallback(h=>{const p=h.value[0],g=fe.default.get(a,p,{error:"rowData is not found"});s.forEach(v=>{i.runInteraction(v.id,{...h,rowData:g})})},[a,s,i]),c=x.useMemo(()=>({click:u}),[u]),f=Z.default.useMemo(()=>K$(e,t,o),[e,t]);return!n||!r?null:l(Wn.default,{echarts:Rt,option:f,style:{width:n,height:r},onEvents:c,notMerge:!0})}function W$({context:e,instance:t}){const n=wi({vizManager:e.vizManager,instance:t}),{value:r}=Je(e.instanceData,"config"),{variables:i}=e,o=x.useMemo(()=>H.defaults({},r,Bu),[r]),a=e.data,{width:s,height:u}=e.viewport,{ref:c,height:f}=Ut.useElementSize(),{ref:h,height:p}=Ut.useElementSize(),g=Z.default.useMemo(()=>{const{stats:{templates:m}}=o;return{top:uo(m.top,i,a),bottom:uo(m.bottom,i,a)}},[o,a]),v=Math.max(0,u-f-p);return y(d.Box,{children:[l(d.Text,{ref:c,align:"left",size:"xs",pl:"sm",sx:{display:jv(o.stats.templates.top)?"block":"none"},children:Object.values(g.top).map(m=>m)}),l(H$,{variables:i,width:s,height:v,data:a,conf:o,interactionManager:n}),l(d.Text,{ref:h,align:"left",size:"xs",pl:"sm",sx:{display:jv(o.stats.templates.bottom)?"block":"none"},children:Object.values(g.bottom).map(m=>m)})]})}const q$=[{label:"solid",value:"solid"},{label:"dashed",value:"dashed"},{label:"dotted",value:"dotted"}],U$=[{label:"Horizontal",value:"horizontal"},{label:"Vertical",value:"vertical"}];function Y$({control:e,index:t,remove:n,watch:r,variableOptions:i,yAxisOptions:o}){const a=r(`reference_lines.${t}.orientation`);return y(d.Stack,{my:0,p:0,sx:{position:"relative"},children:[y(d.Group,{grow:!0,noWrap:!0,children:[l(j.Controller,{name:`reference_lines.${t}.name`,control:e,render:({field:s})=>l(d.TextInput,{label:"Name",placeholder:"Average Reference Line",required:!0,sx:{flex:1},...s})}),l(j.Controller,{name:`reference_lines.${t}.variable_key`,control:e,render:({field:s})=>l(d.Select,{label:"Value",required:!0,data:i,sx:{flex:1},...s})})]}),l(j.Controller,{name:`reference_lines.${t}.template`,control:e,render:({field:s})=>l(d.TextInput,{label:"Content Template",placeholder:"Average: ${avg}",sx:{flex:1},...s})}),y(d.Group,{grow:!0,children:[y(d.Stack,{children:[l(j.Controller,{name:`reference_lines.${t}.orientation`,control:e,render:({field:s})=>l(d.Select,{label:"Orientation",data:U$,required:!0,sx:{flex:1},...s})}),a==="vertical"&&l(d.Text,{mt:-10,color:"dimmed",size:12,children:"Works only when xAxis values are numbers"})]}),a==="horizontal"&&l(j.Controller,{name:`reference_lines.${t}.yAxisIndex`,control:e,render:({field:{value:s,onChange:u,...c}})=>{var f;return l(d.Select,{label:"Y Axis",data:o,disabled:o.length===0,...c,value:(f=s==null?void 0:s.toString())!=null?f:"",onChange:h=>{if(!h){u(0);return}u(Number(h))},sx:{flex:1}})}})]}),l(d.Divider,{mb:-10,mt:10,variant:"dashed",label:"Style",labelPosition:"center"}),y(d.Group,{grow:!0,children:[l(j.Controller,{name:`reference_lines.${t}.lineStyle.type`,control:e,render:({field:s})=>l(d.Select,{label:"Line Type",data:q$,sx:{flexGrow:1},...s})}),l(j.Controller,{name:`reference_lines.${t}.lineStyle.width`,control:e,render:({field:s})=>l(d.NumberInput,{label:"Line Width",min:1,max:10,sx:{flexGrow:1},...s})})]}),y(d.Stack,{spacing:4,children:[l(d.Text,{size:"sm",children:"Color"}),l(j.Controller,{name:`reference_lines.${t}.lineStyle.color`,control:e,render:({field:s})=>l(kn,{...s})})]}),l(d.Button,{leftIcon:l(le.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),sx:{top:15,right:5},children:"Delete this Reference Line"})]},t)}function X$({control:e,watch:t,variables:n}){const{fields:r,append:i,remove:o}=j.useFieldArray({control:e,name:"reference_lines"}),a=t("reference_lines"),s=r.map((p,g)=>({...p,...a[g]})),u=()=>{const p={name:"",template:"",variable_key:"",orientation:"horizontal",lineStyle:{type:"dashed",width:1,color:qr.random().css()},show_in_legend:!1,yAxisIndex:0};i(p)},c=x.useMemo(()=>n.map(p=>({label:p.name,value:p.name})),[n]),f=t("y_axes"),h=x.useMemo(()=>f.map(({name:p},g)=>({label:p,value:g.toString()})),[f]);return y(d.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px"}},children:[y(d.Tabs.List,{children:[s.map((p,g)=>l(d.Tabs.Tab,{value:g.toString(),children:g+1},g)),l(d.Tabs.Tab,{onClick:u,value:"add",children:l(le.Plus,{size:18,color:"#228be6"})})]}),s.map((p,g)=>l(d.Tabs.Panel,{value:g.toString(),children:l(Y$,{control:e,index:g,remove:o,watch:t,variableOptions:c,yAxisOptions:h})},g))]})}const Q$=({value:e,onChange:t})=>{const n=r=>{!r||t(r)};return l(d.Box,{children:l(Tn.default,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Z$=({value:e,onChange:t,data:n})=>{const[r,{setTrue:i,setFalse:o}]=tt.useBoolean(),[a,s]=x.useState(e),u=()=>{o();const{type:p,func_content:g}=a,v={type:p,func_content:g};s(v),t(v)},c=()=>{o(),s(e)},f=p=>{s(g=>({...g,func_content:p}))},h=()=>{f(ho.dynamic.func_content)};return y(Oe,{children:[l(d.Box,{sx:{width:"50%"},children:l(d.Button,{variant:"filled",mt:24,onClick:i,sx:{flexGrow:0},children:"Setup"})}),l(d.Modal,{size:800,title:"Setup dynamic color",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&y(d.Stack,{children:[l(d.Divider,{mt:10,mb:-10,label:"Dynamic by a custom function",labelPosition:"center",variant:"dashed"}),l(Q$,{value:a.func_content,onChange:f}),y(d.Group,{position:"apart",children:[l(d.Button,{onClick:h,color:"red",leftIcon:l(le.Recycle,{size:20}),children:"Rest"}),y(d.Group,{position:"right",children:[l(d.Button,{onClick:c,variant:"subtle",children:"Cancel"}),l(d.Button,{onClick:u,children:"OK"})]})]})]})})]})},J$=({value:e,onChange:t,data:n})=>e.type!=="dynamic"?null:l(Z$,{value:e,onChange:t,data:n}),eL=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=r=>{t({...e,color:r})};return l(d.ColorInput,{label:" ",format:"rgb",value:e.color,onChange:n})},tL=[{label:"Static",value:"static"},{label:"Dynamic",value:"dynamic"}],nL=x.forwardRef(({label:e="Color",value:t,onChange:n,data:r},i)=>{const o=a=>{n({...ho[a]})};return y(d.SimpleGrid,{cols:2,children:[l(d.Select,{ref:i,label:e,data:tL,value:t.type,onChange:o,sx:{flexGrow:1}}),l(eL,{value:t,onChange:n}),l(J$,{value:t,onChange:n,data:r})]})}),rL=x.forwardRef(({value:e,onChange:t},n)=>{const r=o=>{t({...e,label:o})},i=o=>{t({...e,tooltip:o})};return y(d.Stack,{ref:n,spacing:0,children:[l(Na,{sectionTitle:"Overflow on Chart",value:e.label,onChange:r}),l(Na,{sectionTitle:"Overflow in Tooltip",value:e.tooltip,onChange:i})]})}),iL=({value:e,onChange:t})=>{const n=r=>{!r||t(r)};return l(d.Box,{children:l(Tn.default,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},Gv={static:{type:"static",size:10},dynamic:{type:"dynamic",func_content:["function getSize({ rowData, params, variables }, { lodash, interpolate }) {"," // your code goes here"," // return 10","}"].join(`
246
246
  `)}},oL=({value:e,onChange:t,data:n})=>{const[r,{setTrue:i,setFalse:o}]=tt.useBoolean(),[a,s]=x.useState(e),u=()=>{o();const{type:p,func_content:g}=a,v={type:p,func_content:g};s(v),t(v)},c=()=>{o(),s(e)},f=p=>{s(g=>({...g,func_content:p}))},h=()=>{f(Gv.dynamic.func_content)};return y(Oe,{children:[l(d.Box,{sx:{width:"50%"},children:l(d.Button,{variant:"filled",mt:24,onClick:i,sx:{flexGrow:0},children:"Setup"})}),l(d.Modal,{size:800,title:"Setup dynamic size",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&y(d.Stack,{children:[l(d.Divider,{mt:10,mb:-10,label:"Dynamic by a custom function",labelPosition:"center",variant:"dashed"}),l(iL,{value:a.func_content,onChange:f}),y(d.Group,{position:"apart",children:[l(d.Button,{onClick:h,color:"red",leftIcon:l(le.Recycle,{size:20}),children:"Rest"}),y(d.Group,{position:"right",children:[l(d.Button,{onClick:c,variant:"subtle",children:"Cancel"}),l(d.Button,{onClick:u,children:"OK"})]})]})]})})]})},aL=({value:e,onChange:t,data:n})=>e.type!=="dynamic"?null:l(oL,{value:e,onChange:t,data:n}),sL=({value:e,onChange:t})=>{if(e.type!=="static")return null;const n=r=>{t({...e,size:r})};return l(Oe,{children:l(d.NumberInput,{defaultValue:18,placeholder:"1 ~ 100",label:" ",hideControls:!0,value:e.size,onChange:n})})},lL=[{label:"Static",value:"static"},{label:"Dynamic",value:"dynamic"}],uL=x.forwardRef(({label:e="Size",value:t,onChange:n,data:r},i)=>{const o=a=>{n({...Gv[a]})};return y(d.SimpleGrid,{cols:2,children:[l(d.Select,{ref:i,label:e,data:lL,value:t.type,onChange:o,sx:{flexGrow:1}}),l(sL,{value:t,onChange:n}),l(aL,{value:t,onChange:n,data:r})]})}),cL=[{label:"off",value:""},{label:"top",value:"top"},{label:"left",value:"left"},{label:"right",value:"right"},{label:"bottom",value:"bottom"},{label:"inside",value:"inside"},{label:"insideLeft",value:"insideLeft"},{label:"insideRight",value:"insideRight"},{label:"insideTop",value:"insideTop"},{label:"insideBottom",value:"insideBottom"},{label:"insideTopLeft",value:"insideTopLeft"},{label:"insideBottomLeft",value:"insideBottomLeft"},{label:"insideTopRight",value:"insideTopRight"},{label:"insideBottomRight",value:"insideBottomRight"}];function dL({data:e,control:t,watch:n}){return n(["scatter"]),y(d.Stack,{children:[y(d.Group,{grow:!0,noWrap:!0,children:[l(j.Controller,{name:"scatter.name_data_key",control:t,render:({field:r})=>l(mt,{label:"Name Data Field",required:!0,data:e,sx:{flex:1},...r})}),l(j.Controller,{name:"scatter.y_data_key",control:t,render:({field:r})=>l(mt,{label:"Value Data Field",required:!0,data:e,sx:{flex:1},...r})})]}),l(d.Divider,{mb:-15,label:"Style",labelPosition:"center"}),l(j.Controller,{name:"scatter.symbolSize",control:t,render:({field:r})=>l(uL,{label:"Size",data:e,...r})}),l(j.Controller,{name:"scatter.color",control:t,render:({field:r})=>l(nL,{data:e,...r})}),l(d.Divider,{mb:-15,label:"Label",labelPosition:"center"}),l(d.Group,{grow:!0,noWrap:!0,children:l(j.Controller,{name:"scatter.label_position",control:t,render:({field:r})=>l(d.Select,{label:"Label Position",data:cL,...r})})}),l(j.Controller,{name:"scatter.label_overflow",control:t,render:({field:r})=>l(rL,{...r})})]})}function fL({control:e,watch:t}){return t("stats"),l(d.Stack,{children:y(d.Stack,{spacing:0,children:[l(j.Controller,{name:"stats.templates.top",control:e,render:({field:n})=>l(io,{label:"Template for stats above the chart",py:"md",sx:{flexGrow:1},...n})}),l(j.Controller,{name:"stats.templates.bottom",control:e,render:({field:n})=>l(io,{label:"Template for stats under the chart",py:"md",sx:{flexGrow:1},...n})})]})})}const pL=({control:e,data:t,index:n,remove:r})=>y(d.Stack,{children:[y(d.Group,{grow:!0,noWrap:!0,children:[l(j.Controller,{name:`tooltip.metrics.${n}.name`,control:e,render:({field:i})=>l(d.TextInput,{label:"Name",required:!0,sx:{flex:1},...i})}),l(j.Controller,{name:`tooltip.metrics.${n}.data_key`,control:e,render:({field:i})=>l(mt,{label:"Value Field",required:!0,data:t,sx:{flex:1},...i})})]}),l(d.Divider,{mb:-10,mt:10,variant:"dashed"}),l(d.Button,{leftIcon:l(le.Trash,{size:16}),color:"red",variant:"light",onClick:()=>r(n),sx:{top:15,right:5},children:"Delete this Metric"})]}),hL=({control:e,watch:t,data:n})=>{const{fields:r,append:i,remove:o}=j.useFieldArray({control:e,name:"tooltip.metrics"}),a=t("tooltip.metrics"),s=r.map((p,g)=>({...p,...a[g]})),u=()=>i({id:Date.now().toString(),data_key:"",name:""}),c=t("tooltip.metrics.0.id"),[f,h]=x.useState(()=>c!=null?c:null);return x.useEffect(()=>{c&&h(p=>p!==null?p:c)},[c]),y(Oe,{children:[y(d.Group,{spacing:2,sx:{cursor:"default",userSelect:"none"},children:[l(le.InfoCircle,{size:14,color:"#888"}),l(d.Text,{size:14,color:"#888",children:"Configure additional metrics to show in tooltip"})]}),l(d.Divider,{variant:"dashed",my:10}),y(d.Tabs,{value:f,onTabChange:p=>h(p),styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px",paddingTop:"6px"}},children:[y(d.Tabs.List,{children:[s.map((p,g)=>l(d.Tabs.Tab,{value:p.id,children:p.name?p.name:g},p.id)),l(d.Tabs.Tab,{onClick:u,value:"add",children:l(le.Plus,{size:18,color:"#228be6"})})]}),s.map((p,g)=>l(d.Tabs.Panel,{value:p.id,children:l(pL,{control:e,index:g,remove:o,data:n},p.id)},p.id))]})]})};function gL({data:e,control:t,watch:n}){return l(hL,{control:t,watch:n,data:e})}const vL=({disabled:e,value:t,onChange:n})=>{const r=i=>{!i||n(i)};return y(d.Box,{sx:{position:"relative"},children:[e&&l(d.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),l(Tn.default,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},mL=x.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:i,setFalse:o}]=tt.useBoolean(),[a,s]=x.useState(e),u=g=>{s({...a,enabled:g})},c=()=>{o();const{enabled:g,func_content:v}=a,m={enabled:g,func_content:v};s(m),t(m)},f=()=>{o(),s(e)},h=g=>{s(v=>({...v,func_content:g}))},p=()=>{h(zv.func_content)};return x.useEffect(()=>{s(e)},[e]),y(Oe,{children:[l(d.Button,{variant:"filled",mt:24,onClick:i,sx:{flexGrow:0},children:"Customize Label"}),l(d.Modal,{size:800,title:"Customize label content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&y(d.Stack,{children:[l(d.Checkbox,{mt:10,label:"Enabled",checked:a.enabled,onChange:g=>u(g.currentTarget.checked)}),l(vL,{value:a.func_content,onChange:h,disabled:!a.enabled}),y(d.Group,{position:"apart",children:[l(d.Button,{onClick:p,color:"red",leftIcon:l(le.Recycle,{size:20}),children:"Rest"}),y(d.Group,{position:"right",children:[l(d.Button,{onClick:f,variant:"subtle",children:"Cancel"}),l(d.Button,{onClick:c,children:"OK"})]})]})]})})]})});function yL({data:e,control:t,watch:n}){return n(["x_axis"]),y(d.Stack,{children:[y(d.Group,{grow:!0,noWrap:!0,children:[l(j.Controller,{name:"x_axis.data_key",control:t,render:({field:r})=>l(mt,{label:"Data Field",required:!0,data:e,sx:{flex:1},...r})}),l(j.Controller,{name:"x_axis.name",control:t,render:({field:r})=>l(d.TextInput,{label:"Name",sx:{flex:1},...r})})]}),l(d.Divider,{mb:-15,label:"Tick Label",labelPosition:"center"}),y(d.Group,{grow:!0,noWrap:!0,children:[l(j.Controller,{name:"x_axis.axisLabel.rotate",control:t,render:({field:r})=>l(d.NumberInput,{label:"Rotate",hideControls:!0,min:-90,max:90,rightSection:l(d.Text,{color:"dimmed",children:"degree"}),sx:{width:"48%"},styles:{rightSection:{width:"4em",justifyContent:"flex-end",paddingRight:"6px"}},...r})}),l(j.Controller,{name:"x_axis.axisLabel.formatter",control:t,render:({field:r})=>l(mL,{data:e,...r})})]})]})}const bL=[{label:"left",value:"left"},{label:"center",value:"center"},{label:"right",value:"right"}],wL=[{label:"left",value:"left"},{label:"right",value:"right"}];function xL({control:e,index:t,remove:n}){return y(d.Stack,{my:0,p:"0",sx:{position:"relative"},children:[l(d.Divider,{mb:-15,mt:15,variant:"dashed",label:"Name",labelPosition:"center"}),y(d.Group,{grow:!0,noWrap:!0,children:[l(j.Controller,{name:`y_axes.${t}.name`,control:e,render:({field:r})=>l(d.TextInput,{label:"Name",required:!0,sx:{flex:1},...r})}),l(j.Controller,{name:`y_axes.${t}.nameAlignment`,control:e,render:({field:r})=>l(d.Select,{label:"Align",required:!0,data:bL,sx:{flex:1},...r})})]}),l(d.Divider,{mb:-15,variant:"dashed",label:"Layout",labelPosition:"center"}),l(d.Group,{grow:!0,noWrap:!0,children:l(j.Controller,{name:`y_axes.${t}.position`,control:e,render:({field:r})=>l(d.Select,{label:"Position",required:!0,data:wL,sx:{flex:1},...r})})}),y(d.Stack,{children:[l(d.Divider,{mb:-15,variant:"dashed",label:"Label Format",labelPosition:"center"}),l(j.Controller,{name:`y_axes.${t}.label_formatter`,control:e,render:({field:r})=>l($r,{...r})})]}),y(d.Stack,{children:[l(d.Divider,{mb:-15,variant:"dashed",label:"Value Range",labelPosition:"center"}),y(d.Group,{grow:!0,children:[l(j.Controller,{name:`y_axes.${t}.min`,control:e,render:({field:r})=>l(d.TextInput,{label:"Min",...r})}),l(j.Controller,{name:`y_axes.${t}.max`,control:e,render:({field:r})=>l(d.TextInput,{label:"Max",...r})})]})]}),l(d.Button,{mt:20,leftIcon:l(le.Trash,{size:16}),color:"red",variant:"light",onClick:()=>n(t),disabled:t===0,children:"Delete this YAxis"})]})}function SL({control:e,watch:t}){const{fields:n,append:r,remove:i}=j.useFieldArray({control:e,name:"y_axes"}),o=t("y_axes"),a=n.map((u,c)=>({...u,...o[c]})),s=()=>r({name:"",label_formatter:Ln});return y(d.Tabs,{defaultValue:"0",styles:{tab:{paddingTop:"0px",paddingBottom:"0px"},panel:{padding:"0px"}},children:[y(d.Tabs.List,{children:[a.map((u,c)=>l(d.Tabs.Tab,{value:c.toString(),children:c+1},c)),l(d.Tabs.Tab,{onClick:s,value:"add",children:l(le.Plus,{size:18,color:"#228be6"})})]}),a.map((u,c)=>l(d.Tabs.Panel,{value:c.toString(),children:l(xL,{control:e,index:c,remove:i})},c))]})}function CL(e){return e||{templates:{top:"",bottom:""}}}function _L({reference_lines:e=[],stats:t,...n}){return{reference_lines:e,stats:CL(t),...n}}function EL({context:e}){const{value:t,set:n}=Je(e.instanceData,"config"),{variables:r}=e,i=e.data,o=x.useMemo(()=>H.defaultsDeep({},t,Bu),[t]),a=x.useMemo(()=>_L(o),[o]);x.useEffect(()=>{!H.isEqual(o,a)&&(console.log("config malformed, resetting to defaults",o,a),n(a))},[o,a]);const{control:s,handleSubmit:u,watch:c,getValues:f,reset:h}=j.useForm({defaultValues:a});x.useEffect(()=>{h(a)},[a]);const p=f(),g=x.useMemo(()=>!H.isEqual(p,o),[p,o]);return c(["dataZoom"]),l(d.Stack,{spacing:"xs",children:y("form",{onSubmit:u(n),children:[y(d.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(d.Text,{children:"Chart Config"}),l(d.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!g,children:l(le.DeviceFloppy,{size:20})})]}),y(d.Tabs,{defaultValue:"X Axis",orientation:"vertical",styles:{tab:{paddingLeft:"6px",paddingRight:"6px"},panel:{paddingTop:"6px",paddingLeft:"12px"}},children:[y(d.Tabs.List,{children:[l(d.Tabs.Tab,{value:"X Axis",children:"X Axis"}),l(d.Tabs.Tab,{value:"Y Axes",children:"Y Axes"}),l(d.Tabs.Tab,{value:"Scatter",children:"Scatter"}),l(d.Tabs.Tab,{value:"Tooltip",children:"Tooltip"}),l(d.Tabs.Tab,{value:"Stats",children:"Stats"}),l(d.Tabs.Tab,{value:"Reference Lines",children:"Reference Lines"}),l(d.Tabs.Tab,{value:"Zooming",children:"Zooming"})]}),l(d.Tabs.Panel,{value:"X Axis",children:l(yL,{control:s,watch:c,data:i})}),l(d.Tabs.Panel,{value:"Y Axes",children:l(SL,{control:s,watch:c})}),l(d.Tabs.Panel,{value:"Scatter",children:l(dL,{control:s,watch:c,data:i})}),l(d.Tabs.Panel,{value:"Tooltip",children:l(gL,{control:s,watch:c,data:i})}),l(d.Tabs.Panel,{value:"Stats",children:l(fL,{control:s,watch:c,data:i})}),l(d.Tabs.Panel,{value:"Reference Lines",children:l(X$,{variables:r,control:s,watch:c})}),l(d.Tabs.Panel,{value:"Zooming",children:l(j.Controller,{name:"dataZoom",control:s,render:({field:v})=>l(hu,{...v})})})]})]})})}function TL(e){const{dataZoom:t=yi,...n}=e;return{...n,dataZoom:t}}function ML(e){const t={scatter:{label_overflow:Fv}};return fe.default.defaultsDeep(t,e)}function kL(e){const{color:t}=e.scatter;return typeof t=="string"?{...e,scatter:{...e.scatter,color:{...ho.static,color:t}}}:e}function OL(e){const t=e.reference_lines.map(n=>{const{lineStyle:r={type:"dashed",width:1,color:qr.random().css()},show_in_legend:i=!1,yAxisIndex:o=0}=n;return{...n,lineStyle:r,show_in_legend:i,yAxisIndex:o}});return{...e,reference_lines:t}}class DL extends tn{constructor(){super(...arguments);Re(this,"VERSION",7)}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:TL(n.config)})),this.version(4,n=>{const{config:r}=n;return{...n,version:5,config:ML(r)}}),this.version(6,n=>{const{config:r}=n;return{...n,version:6,config:kL(r)}}),this.version(7,n=>{const{config:r}=n;return{...n,version:7,config:OL(r)}})}}const RL={displayName:"Scatter Chart",migrator:new DL,name:"scatterChart",viewRender:W$,configRender:EL,createConfig(){return{version:7,config:H.cloneDeep(Bu)}},triggers:[Vv]},Kv=["function text({ data, variables, filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
247
- `),ju={func_content:Kv,horizontal_align:"left",font_size:"14px",font_weight:"normal"},AL=te.observer(({context:e})=>{const t=$e(),{value:n=ju}=Je(e.instanceData,"config"),{variables:r}=e,{func_content:i,horizontal_align:o,font_size:a,font_weight:s}=n,u=x.useMemo(()=>new Function(`return ${i}`)()({data:e.data,variables:r,filters:t.filters.values,context:t.context.current}),[i,e.data,r,t.filters.values,t.context.current]);return l(d.Text,{align:o,weight:s,sx:{fontSize:a},children:u})}),PL=({value:e,onChange:t})=>{const n=r=>{!r||t(r)};return l(d.Box,{sx:{position:"relative"},children:l(Tn.default,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},IL=x.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:i,setFalse:o}]=tt.useBoolean(),[a,s]=x.useState(e),u=()=>{o(),t(a)},c=()=>{o(),s(e)},f=()=>{s(Kv)};return x.useEffect(()=>{s(e)},[e]),y(Oe,{children:[l(d.Button,{variant:"filled",mt:24,onClick:i,sx:{flexGrow:0},children:"Edit Content"}),l(d.Modal,{size:800,title:"Text content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&y(d.Stack,{children:[l(PL,{value:a,onChange:s}),y(d.Group,{position:"apart",children:[l(d.Button,{onClick:f,color:"red",leftIcon:l(le.Recycle,{size:20}),children:"Rest"}),y(d.Group,{position:"right",children:[l(d.Button,{onClick:c,variant:"subtle",children:"Cancel"}),l(d.Button,{onClick:u,children:"OK"})]})]})]})})]})}),NL=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}];function $L({context:e}){const{value:t,set:n}=Je(e.instanceData,"config"),r=x.useMemo(()=>H.defaultsDeep({},t,ju),[t]),i=x.useMemo(()=>{const{func_content:p,horizontal_align:g,font_size:v,font_weight:m}=r;return{func_content:p,horizontal_align:g,font_size:v,font_weight:m}},[r]);x.useEffect(()=>{!H.isEqual(r,i)&&(console.log("config malformed, resetting to defaults",r,i),n(i))},[r,i]);const{control:o,handleSubmit:a,watch:s,getValues:u,reset:c}=j.useForm({defaultValues:i});Z.default.useEffect(()=>{c(i)},[i]),s(["func_content","horizontal_align","font_size","font_weight"]);const f=u(),h=Z.default.useMemo(()=>!fe.default.isEqual(f,r),[f,r]);return l(d.Stack,{spacing:"xs",children:y("form",{onSubmit:a(n),children:[y(d.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(d.Text,{weight:500,children:"Configurations"}),l(d.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:l(le.DeviceFloppy,{size:20})})]}),y(d.Stack,{spacing:10,children:[l(j.Controller,{name:"func_content",control:o,render:({field:p})=>l(IL,{...p})}),l(d.Divider,{mt:10,mb:-10,variant:"dashed",label:"Style",labelPosition:"center"}),l(j.Controller,{name:"horizontal_align",control:o,render:({field:p})=>l(d.Select,{label:"Horizontal Alignment",data:NL,...p})}),l(j.Controller,{name:"font_size",control:o,render:({field:p})=>l(d.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},...p})}),l(d.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:l(j.Controller,{name:"font_weight",control:o,render:({field:p})=>l(Ng,{label:"Font Weight",...p})})})]})]})})}class LL extends tn{constructor(){super(...arguments);Re(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const VL={displayName:"Text",migrator:new LL,name:"text",viewRender:AL,configRender:$L,createConfig(){return{version:1,config:H.cloneDeep(ju)}}},zL=[{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"})),FL=[AD,PD,$D,ND,ID,LD],Hv=()=>({id:"dashboard",version:Yl,manifest:{viz:[Vu,LI,VL,OI,oN,dP,WD,X2,aP,OA,RL,SP,PP,M$,cR],color:[...zL,...FL]}}),go=new FD,Lt={pluginManager:qn("pluginManager"),vizManager:qn("vizManager"),colorManager:qn("colorManager"),instanceScope:{panelModel:qn("panelModel"),vizInstance:qn("vizInstance"),interactionManager:qn("interactionManager"),migrator:qn("migrator"),operationManager:qn("operationManager"),triggerManager:qn("triggerManager")}},Gu=()=>{try{go.install(Hv())}catch{}const e=new OD(go),t=new zD(go);return{pluginManager:go,vizManager:e,colorManager:t}},zn=x.createContext(Gu());try{go.install(Hv())}catch{}function BL(e,t){const{value:n,set:r}=Je(e.operation.operationData,"config"),[i,o]=x.useState(H.defaults({},n,t)),a=async()=>{await r(i)};return x.useEffect(()=>{o(H.defaults({},n,t))},[n]),{config:i,setConfig:o,commit:a}}function jL(e){const{config:t,setConfig:n,commit:r}=BL(e,{urlTemplate:"",openInNewTab:!0});async function i(){await r()}async function o(s){n({...t,openInNewTab:s}),await r()}const a=s=>n({...t,urlTemplate:s.currentTarget.value});return y(d.Stack,{children:[l(d.TextInput,{label:"Url",value:t.urlTemplate,onChange:a,onBlur:i}),l(d.Switch,{label:"Open in new Tab",checked:t.openInNewTab,onChange:s=>o(s.currentTarget.checked)})]})}async function GL(e,t){const{urlTemplate:n,openInNewTab:r}=await t.operationData.getItem("config");window.dispatchEvent(new CustomEvent("open-link",{detail:{urlTemplate:n,openInNewTab:r,payload:e}}))}class KL extends tn{constructor(){super(...arguments);Re(this,"VERSION",1)}configVersions(){this.version(1,n=>n)}}const HL={displayName:"Open Link",id:"builtin:op:open-link",configRender:jL,run:GL,migrator:new KL,createDefaultConfig:()=>({version:1,config:{urlTemplate:"",openInNewTab:!0}})};function WL(e){const{value:t,set:n}=Je(e.operationData,"config"),r=i=>void n({template:i});return[(t==null?void 0:t.template)||"",r]}function qL(e){const[t,n]=WL(e.operation);return l(d.TextInput,{defaultValue:t,onBlur:r=>n(r.currentTarget.value),label:"console.log"})}async function UL(e,t){const n=await t.operationData.getItem("config"),r=H.template(n.template||"");console.log("run with payload",e),console.log(r(e))}const YL={displayName:"console.log (debug)",id:"builtin:op:debug",configRender:qL,run:UL},XL=te.observer(e=>{const t=$e(),{value:n,set:r}=Je(e.operation.operationData,"config");console.log({value:n,viewID:n==null?void 0:n.viewID});const i=(n==null?void 0:n.viewID)||"",o=a=>void r({viewID:a});return l(d.Select,{defaultValue:i,value:i,onChange:o,label:"View",data:t.views.options})});async function QL(e,t){const r=(await t.operationData.getItem("config")).viewID;window.dispatchEvent(new CustomEvent("open-view",{detail:{viewID:r}}))}const ZL={displayName:"Open View",id:"builtin:op:open_view",configRender:XL,run:QL},JL={dictionary:{}},eV=te.observer(e=>{const t=$e(),{value:n=JL,set:r}=Je(e.operation.operationData,"config"),{dictionary:i={}}=n,o=(u,c)=>{r({dictionary:{...i,[u]:c}})},a=()=>{o(t.filters.firstFilterValueKey,"")},s=u=>{const c={...i};delete c[u],r({dictionary:c})};return y(d.Stack,{spacing:10,children:[l(d.Text,{children:"Mapping Rules"}),Object.entries(i).map(([u,c])=>y(d.Flex,{justify:"space-between",gap:10,children:[l(d.TextInput,{label:"Payload key",value:c,onChange:f=>{o(u,f.currentTarget.value)},sx:{flexGrow:1}}),l(mt,{data:[t.filters.values],value:u,onChange:f=>{o(f,c)},label:"Filter key",sx:{flexGrow:1}}),l(d.ActionIcon,{onClick:()=>s(u),sx:{marginTop:"26px",flexGrow:0},children:l(le.Trash,{size:14,color:"red"})})]},u)),l(d.Button,{size:"xs",onClick:a,sx:{alignSelf:"center",width:"300px"},children:"Add one mapping rule"})]})});async function tV(e,t){const r=(await t.operationData.getItem("config")).dictionary;window.dispatchEvent(new CustomEvent("set-filter-values",{detail:{dictionary:r,payload:e}}))}const nV={displayName:"Set Filter Values",id:"builtin:op:set_filter_values",configRender:eV,run:tV},rV={filter_keys:[]},iV=te.observer(e=>{const t=$e(),{value:n=rV,set:r}=Je(e.operation.operationData,"config"),{filter_keys:i=[]}=n,o=s=>{r({filter_keys:[...s]})},a=x.useMemo(()=>t.filters.current.map(s=>({label:s.label,value:s.key})),[t.filters.values]);return l(d.Stack,{spacing:10,children:l(d.MultiSelect,{label:"Select Filters to Clear",data:a,value:i,onChange:o})})});async function oV(e,t){const r=(await t.operationData.getItem("config")).filter_keys;window.dispatchEvent(new CustomEvent("clear-filter-values",{detail:{filter_keys:r,payload:e}}))}const Wa=[YL,HL,ZL,nV,{displayName:"Clear Filter Values",id:"builtin:op:clear_filter_values",configRender:iV,run:oV}];class aV{constructor(t,n=Wa){Re(this,"attachments");this.operations=n;const r=async i=>{const{id:o,schemaRef:a}=await i.getItem(null);return{id:o,schemaRef:a,operationData:new vi(i,"data")}};this.attachments=new Ul(t,"__OPERATIONS",r)}async runOperation(t,n){const r=await this.attachments.getInstance(t);if(!r){console.warn(`Operation '${t}' is not defined`);return}const i=this.tryGetSchema(r.schemaRef);if(!i){console.warn(`Operation schema '${r.schemaRef}' is not defined`);return}await i.run(n,r)}tryGetSchema(t){return this.operations.find(n=>n.id===t)}async needMigration(){const n=(await this.attachments.list()).map(async r=>{const i={configData:r.operationData},o=this.tryGetSchema(r.schemaRef),a=o==null?void 0:o.migrator;return a&&await a.needMigration(i)});return(await Promise.all(n)).some(r=>r)}async runMigration(){const n=(await this.attachments.list()).map(async r=>{const i={configData:r.operationData},o=this.tryGetSchema(r.schemaRef),a=o==null?void 0:o.migrator;a&&await a.needMigration(i)&&await a.migrate(i)});await Promise.all(n)}async createOrGetOperation(t,n){var a,s;if(!this.getOperationSchemaList().some(u=>u.id===n.id))throw new Error(`Operation schema '${n.id}' is not defined`);const i=await this.attachments.getInstance(t);return!i||i.schemaRef!==n.id?await this.attachments.create(t,{id:t,schemaRef:n.id,data:(s=(a=n.createDefaultConfig)==null?void 0:a.call(n))!=null?s:{}}):i}getOperationList(){return this.attachments.list()}getOperationSchemaList(){return this.operations}removeOperation(t){return this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}}const Wv="__TRIGGERS";class sV{constructor(t,n){Re(this,"attachments");this.instance=t,this.component=n;const r=async i=>{const{id:o,schemaRef:a}=await i.getItem(null);return{id:o,schemaRef:a,triggerData:new vi(i,"data")}};this.attachments=new Ul(t,Wv,r)}watchTriggerSnapshotList(t){return this.instance.instanceData.watchItem(Wv,n=>{const r=H.values(n).map(i=>({id:H.get(i,"id"),schemaRef:H.get(i,"schemaRef"),config:Ft.toJS(H.get(i,"data.config"))}));t(r)},{fireImmediately:!0})}async createOrGetTrigger(t,n,r={recreate:!1}){var s;if(!this.getTriggerSchemaList().some(u=>u.id===n.id))throw new Error(`Trigger schema '${n.id}' is not defined in component '${this.component.name}'`);const o=await this.attachments.getInstance(t);return!o||r.recreate||o.schemaRef!==n.id?await this.attachments.create(t,{id:t,schemaRef:n.id,data:((s=n==null?void 0:n.createDefaultConfig)==null?void 0:s.call(n))||{}}):o}async getTriggerList(){return await this.attachments.list()}getTriggerSchemaList(){return this.component.triggers||[]}async removeTrigger(t){await this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}async getMigrationTasks(){const n=(await this.getTriggerList()).map(async r=>{const i=this.getTriggerSchemaList().find(s=>s.id===r.schemaRef),o=i==null?void 0:i.migrator,a={configData:r.triggerData};return o&&await o.needMigration(a)?()=>o.migrate(a):null});return Promise.all(n).then(r=>r.filter(i=>i))}async needMigration(){return(await this.getMigrationTasks()).length>0}async runMigration(){const t=await this.getMigrationTasks();await Promise.all(t.map(n=>n()))}}class Ku{constructor(t,n,r){Re(this,"operationManager");Re(this,"triggerManager");Re(this,"attachments");this.operationManager=new aV(t,r),this.triggerManager=new sV(t,n);const i=async o=>{const{id:a,triggerRef:s,operationRef:u}=await o.getItem(null);return{id:a,triggerRef:s,operationRef:u}};this.attachments=new Ul(t,"__INTERACTIONS",i)}async addInteraction(t,n){const r=t.id,i=n.id,o=`[${r}]:[${i}]`;await this.attachments.create(o,{id:o,triggerRef:r,operationRef:i})}getInteractionList(){return this.attachments.list()}async removeInteraction(t){const n=await this.attachments.getInstance(t);if(!n)return;const{triggerRef:r,operationRef:i}=n;await this.getTriggerRefCount(r)<=1&&await this.triggerManager.removeTrigger(r),await this.getOperationRefCount(i)<=1&&await this.operationManager.removeOperation(i),await this.attachments.remove(t)}async getOperationRefCount(t){return(await this.getInteractionList()).filter(r=>r.operationRef===t).length}async getTriggerRefCount(t){return(await this.getInteractionList()).filter(r=>r.triggerRef===t).length}async runInteraction(t,n){const i=(await this.getInteractionList()).filter(o=>o.triggerRef===t);await Promise.all(i.map(async o=>{try{return await this.operationManager.runOperation(o.operationRef,n)}catch(a){console.warn(`Failed to run operation '${o.operationRef}'`,a)}}))}}const wi=({vizManager:e,instance:t})=>tt.useCreation(()=>new Ku(t,e.resolveComponent(t.type),Wa),[t,e]),qv=e=>{const{title:t="Variables",variables:n}=e,r=Ut.useClipboard(),i=o=>{r.copy(o),No.showNotification({color:"green",message:"Copied to clipboard"})};return y(d.Paper,{withBorder:!0,p:"sm",children:[l(d.Text,{size:"xs",color:"dimmed",mb:"sm",children:t}),l(d.Stack,{style:{maxHeight:"500px"},children:n.map(o=>y(d.Text,{size:"sm",children:[y(d.Code,{color:"teal",children:["// ",o.description]}),l("br",{}),y(d.Code,{onClick:()=>i(o.name),style:{cursor:"pointer"},children:[o.name," : ",o.valueType]})]},o.name))})]})};class lV{constructor(t,n){Re(this,"operationId");Re(this,"operation");Re(this,"operationSchema");Re(this,"variables",[]);this.operationManager=t,this.instance=n,Ft.makeAutoObservable(this)}get schemaList(){return this.operationManager.getOperationSchemaList()}async configOperation(t,n){const r=await this.operationManager.retrieveTrigger(t),i=this.operationManager.getOperationSchemaList().find(o=>o.id===(r==null?void 0:r.schemaRef));Ft.runInAction(()=>{this.operationId=t,this.operation=r,this.operationSchema=i,this.variables=n})}async changeSchema(t){this.operationId&&(await this.operationManager.createOrGetOperation(this.operationId,t),await this.configOperation(this.operationId,this.variables))}}function uV(e){return!!e.operationId}const cV=te.observer(({model:e,onClick:t})=>{var r;const n=(r=e.operationSchema)==null?void 0:r.displayName;return l(d.Button,{variant:"outline",onClick:t,children:n})}),dV=te.observer(({model:e})=>{const t={operation:e.operation,instance:e.instance,variables:[]};return x.createElement(e.operationSchema.configRender,t)});function fV({model:e}){const t=e.schemaList,n=t.map(i=>({label:i.displayName,value:i.id}));async function r(i){await e.changeSchema(t.find(o=>o.id===i))}return l(d.Select,{label:"Operation",data:n,onChange:r,value:e.operationSchema.id})}const pV=te.observer(e=>{const[t,{setTrue:n,setFalse:r}]=tt.useBoolean(!1),{operationManager:i,operationId:o,instance:a,variables:s}=e,u=tt.useCreation(()=>new lV(i,a),[i,a]);return tt.useAsyncEffect(async()=>{await u.configOperation(o,s)},[o,u]),uV(u)?y(Oe,{children:[l(cV,{model:u,onClick:n}),l(d.Modal,{size:600,opened:t,onClose:r,title:"Operation Settings",closeButtonLabel:"close",zIndex:320,children:y(d.Stack,{children:[l(fV,{model:u}),l(dV,{model:u}),l(qv,{title:"Variables",variables:u.variables})]})})]}):null});class hV{constructor(t,n){Re(this,"triggerId");Re(this,"trigger");Re(this,"triggerSchema");Re(this,"sampleData");this.triggerManager=t,this.instance=n,Ft.makeAutoObservable(this)}get schemaList(){return this.triggerManager.getTriggerSchemaList()}async configTrigger(t,n){const r=await this.triggerManager.retrieveTrigger(t),i=this.triggerManager.getTriggerSchemaList().find(o=>o.id===(r==null?void 0:r.schemaRef));Ft.runInAction(()=>{this.triggerId=t,this.trigger=r,this.triggerSchema=i,this.sampleData=n})}async changeSchema(t){this.triggerId&&(await this.triggerManager.createOrGetTrigger(this.triggerId,t),await this.configTrigger(this.triggerId,this.sampleData))}isReady(){return gV(this)}}function gV(e){return!!e.triggerId&&!!e.triggerSchema}function vV(e,t){return tt.useCreation(()=>new hV(e,t),[e,t])}const mV=te.observer(({model:e,onClick:t})=>{const n=e.triggerSchema.nameRender,r={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return l(d.Button,{variant:"outline",onClick:t,children:x.createElement(n,r)})}),yV=te.observer(({model:e})=>{const t=e.schemaList,n=t.map(i=>({label:i.displayName,value:i.id}));async function r(i){await e.changeSchema(t.find(o=>o.id===i))}return l(d.Select,{label:"Trigger",data:n,value:e.triggerSchema.id,onChange:r})}),bV=te.observer(({model:e})=>{const t={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return x.createElement(e.triggerSchema.configRender,t)}),wV=te.observer(e=>{const[t,{setTrue:n,setFalse:r}]=tt.useBoolean(!1),i=e.model;return y(Oe,{children:[l(d.Modal,{opened:t,onClose:r,title:"Setup Trigger",closeButtonLabel:"close setup",zIndex:320,children:y(d.Stack,{children:[l(yV,{model:i}),l(bV,{model:i}),l(qv,{title:"Payload",variables:i.triggerSchema.payload})]})}),l(mV,{onClick:n,model:i})]})});function xV(e,t){const[n,r]=x.useState([]);return tt.useAsyncEffect(async()=>{const i=await e.getInteractionList();r(i)},[t,e]),n}const SV=te.observer(({item:e,manager:t,instance:n,sampleData:r,variables:i,onRemove:o})=>{const{triggerRef:a,operationRef:s}=e,u=vV(t.triggerManager,n);if(tt.useAsyncEffect(async()=>{await u.configTrigger(a,r)},[u,a,r]),u.isReady()){const c=[...u.triggerSchema.payload,...i];return y(d.Group,{children:[l(wV,{model:u}),l(pV,{instance:n,operationId:s,variables:c,operationManager:t.operationManager}),l(d.ActionIcon,{"aria-label":"delete-interaction",variant:"filled",color:"red",onClick:()=>o(e),children:l(le.Trash,{size:16})})]})}return null}),CV=e=>{const[t,n]=x.useState(0),{interactionManager:r,instance:i,sampleData:o,variables:a}=e,s=xV(r,t),u=async()=>{const p=await r.triggerManager.createOrGetTrigger(Ut.randomId(),r.triggerManager.getTriggerSchemaList()[0]),g=await r.operationManager.createOrGetOperation(Ut.randomId(),r.operationManager.getOperationSchemaList()[0]);await r.addInteraction(p,g),n(v=>v+1)};async function c(p){await r.removeInteraction(p.id),n(g=>g+1)}const{data:f=0,loading:h}=tt.useRequest(async()=>{try{return(await r.triggerManager.getTriggerSchemaList()).length}catch{return 0}});return y(d.Stack,{children:[l(d.LoadingOverlay,{visible:h}),f===0&&l(d.Alert,{icon:l(le.AlertCircle,{size:16}),title:"Unavailable",color:"gray",children:"This visualization does not have available interactions to choose from"}),s.map(p=>l(SV,{onRemove:c,instance:i,sampleData:o,variables:a,item:p,manager:e.interactionManager},p.id)),l(d.Button,{style:{width:"fit-content"},onClick:()=>u(),disabled:f===0,children:"Add interaction"})]})},_V=()=>{const{panel:e,data:t}=Yt(),n=e.viz,{vizManager:r}=x.useContext(zn),i=e.json,o=tt.useCreation(()=>r.getOrCreateInstance(i),[r,i]),a=tt.useCreation(()=>new Ku(o,r.resolveComponent(n.type),Wa),[o,n.type]);return x.useEffect(()=>o.instanceData.watchItem(null,H.throttle(s=>{e.viz.setConf(s)},100,{leading:!1,trailing:!0})),[o]),{instance:o,vizManager:r,interactionManager:a,sampleData:t,variables:[]}},EV=()=>{const e=_V();return l(CV,{...e})};var Uv=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(Uv||{}),qa=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(qa||{});class TV{constructor(t){Re(this,"vizInstance");Re(this,"operationManager");Re(this,"triggerManager");Re(this,"vizManager");Re(this,"runningMigration");Re(this,"panelModel");Re(this,"status","notStarted");this.panelModel=t.getRequired(Lt.instanceScope.panelModel),this.vizInstance=t.getRequired(Lt.instanceScope.vizInstance),this.operationManager=t.getRequired(Lt.instanceScope.operationManager),this.triggerManager=t.getRequired(Lt.instanceScope.triggerManager),this.vizManager=t.getRequired(Lt.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 Yv(e){const{panel:t}=Yt();return x.useCallback(n=>{const r=n.getRequired(Lt.vizManager),i=r.resolveComponent(e.viz.type);return n.createScoped().provideFactory(Lt.instanceScope.vizInstance,()=>r.getOrCreateInstance(e)).provideFactory(Lt.instanceScope.interactionManager,o=>{const a=o.getRequired(Lt.instanceScope.vizInstance);return new Ku(a,i,Wa)}).provideFactory(Lt.instanceScope.operationManager,o=>o.getRequired(Lt.instanceScope.interactionManager).operationManager).provideFactory(Lt.instanceScope.triggerManager,o=>o.getRequired(Lt.instanceScope.interactionManager).triggerManager).provideValue(Lt.instanceScope.panelModel,t).provideFactory(Lt.instanceScope.migrator,o=>new TV(o))},[e.viz.type,e.viz.conf])}function Xv(e){const[t,n]=x.useState(!1),r=vd().getRequired(Lt.instanceScope.migrator);return tt.useAsyncEffect(async()=>{const i=r.status===qa.notStarted;n(r.status===qa.done),r.status===qa.notStarted&&r.runMigration().then(o=>{o===Uv.migrated&&i&&(e==null||e())}).finally(()=>{n(!0)})},[r]),t}function Qv(e,t){const n=vd().getRequired(Lt.instanceScope.vizInstance);return x.useEffect(()=>(n.instanceData.setItem(null,t.viz.conf),n.instanceData.watchItem(null,r=>{e(r)})),[e,t.viz.type]),n}function MV({setVizConf:e,...t}){const{panel:n}=t,r=Qv(e,n),i=Xv(()=>{No.showNotification({title:`${n.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return tt.useAsyncEffect(async()=>{await r.instanceData.setItem(null,n.viz.conf)},[r,n.viz.type]),i?l(RD,{...t}):l(d.Text,{children:"Checking update..."})}function kV(e){const{panel:t,setVizConf:n}=e;return Qv(n,t),Xv(()=>{No.showNotification({title:`${t.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?l(DD,{...e}):l(d.Text,{children:"Checking update"})}const D6="";function OV(e,t){const{vizManager:n}=x.useContext(zn),{panel:{viz:r,title:i,id:o,description:a,queryID:s,variables:u}}=Yt(),c={title:i,id:o,description:a,queryID:s,viz:r,layout:t},f=Yv(c);try{return n.resolveComponent(r.type),l(Fo,{configure:f,children:l(kV,{setVizConf:r.setConf,panel:c,data:e,variables:u,vizManager:n})})}catch(h){return console.info(H.get(h,"message")),null}}const DV=["richText","button"],Zv=te.observer(function({height:t,viz:n,data:r,loading:i,error:o,query:a}){const{ref:s,width:u,height:c}=Ut.useElementSize(),f=OV(r,{w:u,h:c});if(DV.includes(n.type))return l("div",{className:"viz-root",style:{height:t},ref:s,children:l(Or,{children:f})});if(i)return l("div",{className:"viz-root",style:{height:t},ref:s,children:l(d.LoadingOverlay,{visible:i,exitTransitionDuration:0})});const p=!!o,g=!p&&!!(a!=null&&a.stateMessage),v=!p&&!g;return y("div",{className:"viz-root",style:{height:t},ref:s,children:[p&&l(d.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:o}),g&&l(d.Text,{color:"gray",align:"center",children:a.stateMessage}),v&&l(Or,{children:f})]})});function RV(e){return!["richText","button"].includes(e)}const AV={border:"1px solid #e9ecef"},Jv={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function PV(e,t,n){return e.style.border.enabled?AV:n||t?Jv:{border:"1px dashed transparent"}}const Ua=te.observer(function({panel:t,view:n}){const r=$e(),{inEditMode:i}=x.useContext(Dr),{data:o,state:a,error:s}=r.getDataStuffByID(t.queryID),u=r.queries.findByID(t.queryID),c=RV(t.viz.type),f=c&&a==="loading",h=t.title?"calc(100% - 25px - 5px)":"100%",p=PV(t,c,i),g=c||i;return l($s,{value:{panel:t,data:o,loading:f},children:y(d.Box,{className:"panel-root",p:5,pt:0,sx:{...p},children:[l(d.Box,{sx:{position:"absolute",left:0,top:0,height:28,zIndex:310},children:l(yg,{})}),g&&l(TD,{view:n}),l(MD,{}),l(Zv,{viz:t.viz,data:o,loading:f,error:s,height:h,query:u})]})})}),R6="",IV=Z.default.forwardRef(({handleAxis:e},t)=>l(d.ActionIcon,{ref:t,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:l(le.ArrowsMove,{size:16})})),NV=Z.default.forwardRef(({handleAxis:e,...t},n)=>l(d.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:-5,right:-5,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:l(le.ChevronDownRight,{size:16})})),$V=Os.WidthProvider(ud.default),LV=te.observer(function({view:t,className:n="layout",rowHeight:r=10,isDraggable:i,isResizable:o}){const a=Z.default.useCallback(s=>{s.forEach(({i:u,...c})=>{const f=t.panels.findByID(u);!f||f.layout.set(c)})},[t]);return l($V,{onLayoutChange:a,className:`dashboard-layout ${n}`,rowHeight:r,layout:t.panels.layouts,isDraggable:i,isResizable:o,draggableHandle:".react-grid-customDragHandle",resizeHandle:l(NV,{}),children:t.panels.list.map((s,u)=>y("div",{"data-grid":{...s.layout},style:{position:"relative"},children:[i&&l(IV,{}),l(Ua,{view:t,panel:s})]},s.id))})}),VV=Os.WidthProvider(ud.default),zV=te.observer(function({view:t,className:n="layout",rowHeight:r=10}){return l(VV,{className:`dashboard-layout ${n}`,rowHeight:r,isDraggable:!1,isResizable:!1,layout:t.panels.layouts,children:t.panels.list.map(i=>l("div",{"data-grid":i.layout,children:l(Ua,{view:t,panel:i})},i.id))})});var em=(e=>(e.Use="use",e.Edit="edit",e))(em||{}),rt=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(rt||{});const FV={div:"Division",tabs:"Tabs",modal:"Modal"},tm={div:"rgba(255, 0, 0, 0.2)",modal:"rgba(0, 0, 0, 0.2)",tabs:"rgba(255, 200, 100, 0.4)"},BV={div:"#ff4000",modal:"#000",tabs:"#ffad18"};var Hu=(e=>(e.Select="select",e.TreeSelect="tree-select",e.MultiSelect="multi-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(Hu||{});const jV=te.observer(({children:e})=>l(d.Box,{pt:10,pb:100,children:e})),GV=te.observer(({children:e,view:t})=>{const n=t.config;return l(d.Modal,{size:n.width,overflow:"inside",opened:!0,onClose:fe.default.noop,withCloseButton:!1,title:n.custom_modal_title.value,trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},modal:{border:"1px solid #efefef"},body:{maxHeight:"calc(100vh - 325px)"}},withinPortal:!1,transitionDuration:0,children:e})}),KV=({variant:e,orientation:t})=>{const n={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},HV=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},WV=te.observer(({children:e,view:t})=>{const n=$e(),r=x.useMemo(()=>n.views.options.filter(o=>o.type===rt.Division),[t.id,n.views.options]),i=t.config;return y(d.Box,{className:"preview-view-tabs",children:[y(d.Tabs,{variant:i.variant,orientation:i.orientation,defaultValue:i.tabs.length>0?i.tabs[0].id:"0",styles:KV(i),children:[y(d.Tabs.List,{grow:i.grow,children:[i.tabs.map(o=>{var a;return l(d.Tabs.Tab,{value:o.id,sx:HV(o),children:(a=o.name)!=null?a:o.id},o.id)}),l(d.Tabs.Tab,{onClick:i.addTab,value:"add",className:"add-a-tab",children:l(le.Plus,{size:18,color:"#228be6"})})]}),i.tabs.map(o=>{const a=n.views.findByID(o.view_id);return y(d.Tabs.Panel,{value:o.id,sx:{position:"relative"},children:[y(d.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[l(d.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),y(d.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[l(d.TextInput,{label:"Tab Name",value:o.name,onChange:s=>o.setName(s.currentTarget.value)}),l(d.Select,{label:"View",value:o.view_id,onChange:o.setViewID,data:r}),l(d.ColorInput,{label:"Color",value:o.color,onChange:o.setColor,disabled:i.variant!=="default"}),a&&y(d.Button,{mt:20,variant:"gradient",leftIcon:l(qP,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>n.views.setIDOfVIE(a.id),children:["Swith to View: ",a.name]})]})]}),a&&l(Ya,{view:a})]},o.id)})]}),e]})}),qV=te.observer(({view:e,children:t})=>{switch(e.type){case rt.Modal:return l(GV,{view:e,children:t});case rt.Tabs:return l(WV,{view:e,children:t});case rt.Division:default:return l(jV,{children:t})}}),nm=te.observer(function({view:t}){return l(Is.Provider,{value:{viewPanelInFullScreen:fe.default.noop,inFullScreen:!1},children:l(d.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:l(qV,{view:t,children:y(d.Box,{sx:{position:"relative"},children:[l(d.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:l(lg,{view:t})}),l(LV,{view:t,isDraggable:!0,isResizable:!0})]})})})})}),UV=te.observer(function({view:t,panel:n,exitFullScreen:r}){return y(d.Stack,{px:"10px",pb:"5px",sx:{height:"100%",flexGrow:1,justifyContent:"flex-start"},children:[l(d.Group,{sx:{flexGrow:0},children:l(d.Button,{variant:"default",size:"sm",onClick:r,leftIcon:l(le.ArrowLeft,{size:20}),children:"Exit fullscreen"})}),l(d.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:l(Ua,{view:t,panel:n})})]})});function YV(e,t,n){const r=e.id==="Main",[i,o]=Z.default.useState(()=>r&&e.panels.findByID(t)?t:null),a=Z.default.useCallback(f=>{o(f),r&&n(f)},[r,n]),s=Z.default.useCallback(()=>{o(null),r&&n("")},[r,n]),u=i?e.panels.findByID(i):null;return{viewPanelInFullScreen:a,exitFullScreen:s,inFullScreen:!!u,fullScreenPanel:u}}const XV=te.observer(({children:e})=>l(d.Box,{children:e})),QV=te.observer(({children:e,view:t})=>{const n=$e(),r=t.config,i=n.views.visibleViewIDs.includes(t.id),o=()=>n.views.rmVisibleViewID(t.id);return l(d.Modal,{size:r.width,centered:!0,overflow:"inside",opened:i,onClose:o,withCloseButton:!1,title:r.custom_modal_title.value,trapFocus:!0,onDragStart:a=>{a.stopPropagation()},styles:{modal:{border:"1px solid #efefef"},body:{maxHeight:r.height,overflow:"auto"}},transitionDuration:0,children:e})}),ZV=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},JV=te.observer(({children:e,view:t})=>{const n=$e(),r=t.config;return y(d.Box,{className:"render-view-tabs",children:[y(d.Tabs,{variant:r.variant,orientation:r.orientation,defaultValue:r.tabs.length>0?r.tabs[0].id:"0",styles:{panel:{padding:"16px 0px"}},keepMounted:!1,children:[l(d.Tabs.List,{grow:r.grow,children:r.tabs.map(i=>{var o;return l(d.Tabs.Tab,{value:i.id,sx:ZV(i),disabled:!i.view_id,children:(o=i.name)!=null?o:i.id},i.id)})}),r.tabs.map(i=>{const o=n.views.findByID(i.view_id);return o?l(d.Tabs.Panel,{value:i.id,children:l(Ya,{view:o})},i.id):null})]}),e]})}),ez=te.observer(({view:e,children:t})=>{switch(e.type){case rt.Modal:return l(QV,{view:e,children:t});case rt.Tabs:return l(JV,{view:e,children:t});case rt.Division:default:return l(XV,{children:t})}}),Ya=te.observer(function({view:t}){const{fullScreenPanelID:n,setFullScreenPanelID:r}=wd(),{viewPanelInFullScreen:i,exitFullScreen:o,inFullScreen:a,fullScreenPanel:s}=YV(t,n,r);return l(Is.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:a},children:y(d.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:[a&&l(UV,{view:t,panel:s,exitFullScreen:o}),l(ez,{view:t,children:y(d.Box,{sx:{position:"relative"},children:[!a&&l(d.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:l(lg,{view:t})}),!a&&l(zV,{view:t})]})})]})})});function tz(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let r=0;r<t.length;r++){const i=t[r];if(i!="authentication"&&e[i])n.push(t[r]+"="+(typeof e[i]=="object"?JSON.stringify(e[i]):e[i]));else{const o=Object.keys(e[i]).sort();for(let a=0;a<o.length;a++){const s=o[a];s!="sign"&&e[i][s]&&n.push(o[a]+"="+(typeof e[i][s]=="object"?JSON.stringify(e[i][s]):e[i][s]))}}}return n.sort().join("&")}function nz(e,t){let n=tz(e);return n+="&key="+t,fd.default.MD5(n).toString().toUpperCase()}const zr={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(e){if(!this.app_id||!this.app_secret)return;const t=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:t,sign:nz({app_id:this.app_id,nonce_str:t,...e},this.app_secret)}},getRequest(e,t){return(n,r,i={})=>{const o=window.localStorage.getItem("token"),a={"X-Requested-With":"XMLHttpRequest","Content-Type":i.string?"application/x-www-form-urlencoded":"application/json",authorization:o?`bearer ${o}`:"",...i.headers},s={baseURL:this.baseURL,method:e,url:n,params:e==="GET"?r:i.params,headers:a,signal:t};return["POST","PUT"].includes(e)&&(s.data=i.string?JSON.stringify(r):r,s.data.authentication=this.getAuthentication(s.data)),Vo.default(s).then(u=>u.data).catch(u=>Promise.reject(u))}}};function rm(e){zr.baseURL!==e.apiBaseURL&&(zr.baseURL=e.apiBaseURL),e.app_id&&(zr.app_id=e.app_id),e.app_secret&&(zr.app_secret=e.app_secret)}const im=D.types.model("FilterConfigModel_Checkbox",{_name:D.types.literal("checkbox"),default_value:D.types.boolean}).actions(e=>({setDefaultValue(t){e.default_value=t}})),rz=()=>im.create({_name:"checkbox",default_value:!1});var Sn=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e))(Sn||{}),Qt=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TreeSelect="tree-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(Qt||{});D.types.model({type:D.types.enumeration("DataSourceType",[Sn.Postgresql,Sn.MySQL,Sn.HTTP]),key:D.types.string,sql:D.types.string});const iz=D.types.model("FilterConfigModel_DateRange",{_name:D.types.literal("date-range"),required:D.types.boolean,inputFormat:D.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:D.types.optional(D.types.array(D.types.union(D.types.string,D.types.null)),[null,null]),clearable:D.types.boolean,max_days:D.types.optional(D.types.number,0),allowSingleDateInRange:D.types.optional(D.types.boolean,!1)}).views(e=>({truthy(t){return Array.isArray(t)&&t.length===2&&t.every(n=>!!n)}})).views(e=>({getMaxDate(t){const{max_days:n}=e;if(!(!n||!t))return En.default(t).startOf("day").add(n,"days").toDate()},getMinDate(t){const{max_days:n}=e;if(!(!n||!t))return En.default(t).startOf("day").subtract(n,"days").toDate()}})).actions(e=>({setFilterValue(t){try{const n=D.getParent(e);D.getRoot(e).filters.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)},setMaxDays(t){e.max_days=t,t>0&&(e.clearable=!0)},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),om=D.types.snapshotProcessor(iz,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>n===null?null:En.default.tz(n,"UTC").toISOString())}},postProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>{try{return n?En.default.tz(n,"UTC").format(t.inputFormat):null}catch{return console.log(`[date-range] failed parsing ${n}`),null}})}}}),oz=()=>om.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),az=D.types.model({label:D.types.string,value:D.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),Wu=D.types.model("FilterConfigModel_BaseSelect",{static_options:D.types.optional(D.types.array(az),[]),options_query_id:D.types.optional(D.types.string,""),default_selection_count:D.types.optional(D.types.number,0)}).views(e=>({get usingQuery(){return!!e.options_query_id}})).views(e=>({get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:n,error:r}=D.getRoot(e).getDataStuffByID(e.options_query_id);return n==="idle"?t:[]}})).actions(e=>({addStaticOption(t){e.static_options.push(t)},removeStaticOption(t){e.static_options.splice(t,1)},setDefaultSelectionCount(t){e.default_selection_count=t},setOptionsQueryID(t){e.options_query_id=t!=null?t:""}})),am=D.types.compose("FilterConfigModel_MultiSelect",D.types.model({_name:D.types.literal("multi-select"),default_value:D.types.optional(D.types.array(D.types.string),[]),min_width:D.types.optional(D.types.string,"")}),Wu).actions(e=>({setDefaultValue(t){e.default_value=D.cast(t)},setMinWidth(t){e.min_width=t}})),sz=()=>am.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),sm=D.types.compose("FilterConfigModel_TreeSelect",D.types.model({_name:D.types.literal("tree-select"),default_value:D.types.optional(D.types.array(D.types.string),[]),min_width:D.types.optional(D.types.string,"")}),Wu).actions(e=>({setDefaultValue(t){e.default_value=D.cast(t)},setMinWidth(t){e.min_width=t}})),lz=()=>sm.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),lm=D.types.compose("FilterConfigModel_Select",D.types.model({_name:D.types.literal("select"),default_value:D.types.string,required:D.types.boolean,width:D.types.optional(D.types.string,"")}),Wu).views(e=>({truthy(t){return!!t}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t},setWidth(t){e.width=t}})),uz=()=>lm.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),um=D.types.model("FilterConfigModel_TextInput",{_name:D.types.literal("text-input"),required:D.types.boolean,default_value:D.types.string}).views(e=>({truthy(t){return typeof t!="string"?!1:!!t.trim()}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),cm=()=>um.create({_name:"text-input",required:!1,default_value:""}),qu=D.types.model("FilterModel",{id:D.types.identifier,key:D.types.string,label:D.types.string,order:D.types.number,visibleInViewsIDs:D.types.array(D.types.string),auto_submit:D.types.optional(D.types.boolean,!1),type:D.types.enumeration("DashboardFilterType",[Qt.Select,Qt.MultiSelect,Qt.TreeSelect,Qt.TextInput,Qt.Checkbox,Qt.DateRange]),config:D.types.union(lm,am,sm,um,im,om)}).views(e=>({get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==Qt.TreeSelect},get auto_submit_supported(){return[Qt.Select,Qt.Checkbox,Qt.DateRange].includes(e.type)}})).views(e=>({get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return fe.default.get(e.config,"required",!1)?fe.default.get(e.config,"truthy",()=>!0)(t):!1}})).actions(e=>({setKey(t){e.key=t},setLabel(t){e.label=t},setOrder(t){e.order=t},setType(t){switch(t){case Qt.Select:e.config=uz();break;case Qt.MultiSelect:e.config=sz();break;case Qt.TreeSelect:e.config=lz();break;case Qt.TextInput:e.config=cm();break;case Qt.Checkbox:e.config=rz();break;case Qt.DateRange:e.config=oz();break}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t}}));function dm(e,t){if(e===void 0)return e;if(t._name==="date-range")try{const[...n]=e;return n.map(r=>{if(r===null)return r;const i=En.default.tz(r,"UTC").format(t.inputFormat);return i!=null?i:r})}catch(n){return console.error(n),e}return e}function fm(e){return e.reduce((t,n)=>(t[n.key]=dm(n.config.default_value,n.config),t),{})}function cz(e,t,n){D.addDisposer(e,D.addMiddleware(e,(r,i)=>{i(r,()=>{D.getType(r.context)===t&&r.type==="action"&&n(r.name,r.context)})}))}const pm=D.types.model("FiltersModel",{current:D.types.optional(D.types.array(qu),[]),values:D.types.optional(D.types.frozen(),{}),previewValues:D.types.optional(D.types.frozen(),{})}).views(e=>({get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},get inOrder(){return fe.default.sortBy(e.current,"order")},get options(){return e.current.map(t=>{var n;return{label:(n=t.label)!=null?n:t.id,value:t.id,_type:"filter"}})},get empty(){return e.current.length===0},visibleInView(t){return fe.default.sortBy(e.current.filter(n=>n.visibleInViewsIDs.includes(t)),"order")},get firstFilterValueKey(){var t;return(t=Object.keys(e.values)[0])!=null?t:""},get keyLabelMap(){return e.current.reduce((t,n)=>(t[n.key]=n.label,t),{})}})).actions(e=>({replace(t){e.current=D.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(r=>r.id===t);n>=0&&e.current.splice(n,1)},setValues(t){e.values=t},setValueByKey(t,n){e.values={...e.values,[t]:n}},getValueByKey(t){return e.values[t]},refreshValues(){console.log("refreshing values"),e.values=fm(e.current)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){cz(e.current,qu,(n,r)=>{if(n==="setType"){const i=dm(r.config.default_value,r.config);e.setValueByKey(r.key,i),e.updatePreviewValues({...e.previewValues,[r.key]:i})}})}return{afterCreate(){t()}}});function hm(e){return{current:e,values:fm(e)}}var Xa={exports:{}};(function(e,t){(function(n,r){r()})(hn,function(){function n(c,f){return typeof f>"u"?f={autoBom:!1}:typeof f!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),f={autoBom:!f}),f.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(c.type)?new Blob(["\uFEFF",c],{type:c.type}):c}function r(c,f,h){var p=new XMLHttpRequest;p.open("GET",c),p.responseType="blob",p.onload=function(){u(p.response,f,h)},p.onerror=function(){console.error("could not download file")},p.send()}function i(c){var f=new XMLHttpRequest;f.open("HEAD",c,!1);try{f.send()}catch{}return 200<=f.status&&299>=f.status}function o(c){try{c.dispatchEvent(new MouseEvent("click"))}catch{var f=document.createEvent("MouseEvents");f.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),c.dispatchEvent(f)}}var a=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof hn=="object"&&hn.global===hn?hn:void 0,s=a.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),u=a.saveAs||(typeof window!="object"||window!==a?function(){}:"download"in HTMLAnchorElement.prototype&&!s?function(c,f,h){var p=a.URL||a.webkitURL,g=document.createElement("a");f=f||c.name||"download",g.download=f,g.rel="noopener",typeof c=="string"?(g.href=c,g.origin===location.origin?o(g):i(g.href)?r(c,f,h):o(g,g.target="_blank")):(g.href=p.createObjectURL(c),setTimeout(function(){p.revokeObjectURL(g.href)},4e4),setTimeout(function(){o(g)},0))}:"msSaveOrOpenBlob"in navigator?function(c,f,h){if(f=f||c.name||"download",typeof c!="string")navigator.msSaveOrOpenBlob(n(c,h),f);else if(i(c))r(c,f,h);else{var p=document.createElement("a");p.href=c,p.target="_blank",setTimeout(function(){o(p)})}}:function(c,f,h,p){if(p=p||open("","_blank"),p&&(p.document.title=p.document.body.innerText="downloading..."),typeof c=="string")return r(c,f,h);var g=c.type==="application/octet-stream",v=/constructor/i.test(a.HTMLElement)||a.safari,m=/CriOS\/[\d]+/.test(navigator.userAgent);if((m||g&&v||s)&&typeof FileReader<"u"){var w=new FileReader;w.onloadend=function(){var C=w.result;C=m?C:C.replace(/^data:[^;]*;/,"data:attachment/file;"),p?p.location.href=C:location=C,p=null},w.readAsDataURL(c)}else{var b=a.URL||a.webkitURL,_=b.createObjectURL(c);p?p.location=_:location.href=_,p=null,setTimeout(function(){b.revokeObjectURL(_)},4e4)}});a.saveAs=u.saveAs=u,e.exports=u})})(Xa);function dz(e,t){const n=new Blob([t],{type:"text/csv"});Xa.exports.saveAs(n,`${e}.csv`)}function fz(e,t){const n=new Blob([t],{type:"application/json"});Xa.exports.saveAs(n,`${e}.json`)}function pz(e){const t=new E0.default;e.forEach(({id:n,data:r})=>{t.file(`${n}.csv`,gm(r))}),t.generateAsync({type:"blob"}).then(n=>{Xa.exports.saveAs(n,"dashboard_data.zip")})}function gm(e){if(!Array.isArray(e)||e.length===0)return"";const t=[],n=Object.keys(e[0]);return t.push(n.join(",")),e.forEach(r=>{const i=Object.values(r).join(",");t.push(i)}),t.join(`
247
+ `),ju={func_content:Kv,horizontal_align:"left",font_size:"14px",font_weight:"normal"},AL=te.observer(({context:e})=>{const t=$e(),{value:n=ju}=Je(e.instanceData,"config"),{variables:r}=e,{func_content:i,horizontal_align:o,font_size:a,font_weight:s}=n,u=x.useMemo(()=>new Function(`return ${i}`)()({data:e.data,variables:r,filters:t.filters.values,context:t.context.current}),[i,e.data,r,t.filters.values,t.context.current]);return l(d.Text,{align:o,weight:s,sx:{fontSize:a},children:u})}),PL=({value:e,onChange:t})=>{const n=r=>{!r||t(r)};return l(d.Box,{sx:{position:"relative"},children:l(Tn.default,{height:"500px",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},IL=x.forwardRef(({value:e,onChange:t},n)=>{const[r,{setTrue:i,setFalse:o}]=tt.useBoolean(),[a,s]=x.useState(e),u=()=>{o(),t(a)},c=()=>{o(),s(e)},f=()=>{s(Kv)};return x.useEffect(()=>{s(e)},[e]),y(Oe,{children:[l(d.Button,{variant:"filled",mt:24,onClick:i,sx:{flexGrow:0},children:"Edit Content"}),l(d.Modal,{size:800,title:"Text content",opened:r,onClose:o,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:r&&y(d.Stack,{children:[l(PL,{value:a,onChange:s}),y(d.Group,{position:"apart",children:[l(d.Button,{onClick:f,color:"red",leftIcon:l(le.Recycle,{size:20}),children:"Rest"}),y(d.Group,{position:"right",children:[l(d.Button,{onClick:c,variant:"subtle",children:"Cancel"}),l(d.Button,{onClick:u,children:"OK"})]})]})]})})]})}),NL=[{label:"Left",value:"left"},{label:"Center",value:"center"},{label:"Right",value:"right"}];function $L({context:e}){const{value:t,set:n}=Je(e.instanceData,"config"),r=x.useMemo(()=>H.defaultsDeep({},t,ju),[t]),i=x.useMemo(()=>{const{func_content:p,horizontal_align:g,font_size:v,font_weight:m}=r;return{func_content:p,horizontal_align:g,font_size:v,font_weight:m}},[r]);x.useEffect(()=>{!H.isEqual(r,i)&&(console.log("config malformed, resetting to defaults",r,i),n(i))},[r,i]);const{control:o,handleSubmit:a,watch:s,getValues:u,reset:c}=j.useForm({defaultValues:i});Z.default.useEffect(()=>{c(i)},[i]),s(["func_content","horizontal_align","font_size","font_weight"]);const f=u(),h=Z.default.useMemo(()=>!fe.default.isEqual(f,r),[f,r]);return l(d.Stack,{spacing:"xs",children:y("form",{onSubmit:a(n),children:[y(d.Group,{position:"left",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[l(d.Text,{weight:500,children:"Configurations"}),l(d.ActionIcon,{type:"submit",mr:5,variant:"filled",color:"blue",disabled:!h,children:l(le.DeviceFloppy,{size:20})})]}),y(d.Stack,{spacing:10,children:[l(j.Controller,{name:"func_content",control:o,render:({field:p})=>l(IL,{...p})}),l(d.Divider,{mt:10,mb:-10,variant:"dashed",label:"Style",labelPosition:"center"}),l(j.Controller,{name:"horizontal_align",control:o,render:({field:p})=>l(d.Select,{label:"Horizontal Alignment",data:NL,...p})}),l(j.Controller,{name:"font_size",control:o,render:({field:p})=>l(d.TextInput,{label:"Font Size",placeholder:"10px, 1em, 1rem, 100%...",sx:{flex:1},...p})}),l(d.Group,{position:"apart",grow:!0,sx:{"> *":{flexGrow:1,maxWidth:"100%"}},children:l(j.Controller,{name:"font_weight",control:o,render:({field:p})=>l(Ng,{label:"Font Weight",...p})})})]})]})})}class LL extends tn{constructor(){super(...arguments);Re(this,"VERSION",1)}configVersions(){this.version(1,n=>({version:1,config:n}))}}const VL={displayName:"Text",migrator:new LL,name:"text",viewRender:AL,configRender:$L,createConfig(){return{version:1,config:H.cloneDeep(ju)}}},zL=[{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"})),FL=[AD,PD,$D,ND,ID,LD],Hv=()=>({id:"dashboard",version:Yl,manifest:{viz:[Vu,LI,VL,OI,oN,dP,WD,X2,aP,OA,RL,SP,PP,M$,cR],color:[...zL,...FL]}}),go=new FD,Lt={pluginManager:qn("pluginManager"),vizManager:qn("vizManager"),colorManager:qn("colorManager"),instanceScope:{panelModel:qn("panelModel"),vizInstance:qn("vizInstance"),interactionManager:qn("interactionManager"),migrator:qn("migrator"),operationManager:qn("operationManager"),triggerManager:qn("triggerManager")}},Gu=()=>{try{go.install(Hv())}catch{}const e=new OD(go),t=new zD(go);return{pluginManager:go,vizManager:e,colorManager:t}},zn=x.createContext(Gu());try{go.install(Hv())}catch{}function BL(e,t){const{value:n,set:r}=Je(e.operation.operationData,"config"),[i,o]=x.useState(H.defaults({},n,t)),a=async()=>{await r(i)};return x.useEffect(()=>{o(H.defaults({},n,t))},[n]),{config:i,setConfig:o,commit:a}}function jL(e){const{config:t,setConfig:n,commit:r}=BL(e,{urlTemplate:"",openInNewTab:!0});async function i(){await r()}async function o(s){n({...t,openInNewTab:s}),await r()}const a=s=>n({...t,urlTemplate:s.currentTarget.value});return y(d.Stack,{children:[l(d.TextInput,{label:"Url",value:t.urlTemplate,onChange:a,onBlur:i}),l(d.Switch,{label:"Open in new Tab",checked:t.openInNewTab,onChange:s=>o(s.currentTarget.checked)})]})}async function GL(e,t){const{urlTemplate:n,openInNewTab:r}=await t.operationData.getItem("config");window.dispatchEvent(new CustomEvent("open-link",{detail:{urlTemplate:n,openInNewTab:r,payload:e}}))}class KL extends tn{constructor(){super(...arguments);Re(this,"VERSION",1)}configVersions(){this.version(1,n=>n)}}const HL={displayName:"Open Link",id:"builtin:op:open-link",configRender:jL,run:GL,migrator:new KL,createDefaultConfig:()=>({version:1,config:{urlTemplate:"",openInNewTab:!0}})};function WL(e){const{value:t,set:n}=Je(e.operationData,"config"),r=i=>void n({template:i});return[(t==null?void 0:t.template)||"",r]}function qL(e){const[t,n]=WL(e.operation);return l(d.TextInput,{defaultValue:t,onBlur:r=>n(r.currentTarget.value),label:"console.log"})}async function UL(e,t){const n=await t.operationData.getItem("config"),r=H.template(n.template||"");console.log("run with payload",e),console.log(r(e))}const YL={displayName:"console.log (debug)",id:"builtin:op:debug",configRender:qL,run:UL},XL=te.observer(e=>{const t=$e(),{value:n,set:r}=Je(e.operation.operationData,"config");console.log({value:n,viewID:n==null?void 0:n.viewID});const i=(n==null?void 0:n.viewID)||"",o=a=>void r({viewID:a});return l(d.Select,{defaultValue:i,value:i,onChange:o,label:"View",data:t.views.options})});async function QL(e,t){const r=(await t.operationData.getItem("config")).viewID;window.dispatchEvent(new CustomEvent("open-view",{detail:{viewID:r}}))}const ZL={displayName:"Open View",id:"builtin:op:open_view",configRender:XL,run:QL},JL={dictionary:{}},eV=te.observer(e=>{const t=$e(),{value:n=JL,set:r}=Je(e.operation.operationData,"config"),{dictionary:i={}}=n,o=(u,c)=>{r({dictionary:{...i,[u]:c}})},a=()=>{o(t.filters.firstFilterValueKey,"")},s=u=>{const c={...i};delete c[u],r({dictionary:c})};return y(d.Stack,{spacing:10,children:[l(d.Text,{children:"Mapping Rules"}),Object.entries(i).map(([u,c])=>y(d.Flex,{justify:"space-between",gap:10,children:[l(d.TextInput,{label:"Payload key",value:c,onChange:f=>{o(u,f.currentTarget.value)},sx:{flexGrow:1}}),l(mt,{data:[t.filters.values],value:u,onChange:f=>{o(f,c)},label:"Filter key",sx:{flexGrow:1}}),l(d.ActionIcon,{onClick:()=>s(u),sx:{marginTop:"26px",flexGrow:0},children:l(le.Trash,{size:14,color:"red"})})]},u)),l(d.Button,{size:"xs",onClick:a,sx:{alignSelf:"center",width:"300px"},children:"Add one mapping rule"})]})});async function tV(e,t){const r=(await t.operationData.getItem("config")).dictionary;window.dispatchEvent(new CustomEvent("set-filter-values",{detail:{dictionary:r,payload:e}}))}const nV={displayName:"Set Filter Values",id:"builtin:op:set_filter_values",configRender:eV,run:tV},rV={filter_keys:[]},iV=te.observer(e=>{const t=$e(),{value:n=rV,set:r}=Je(e.operation.operationData,"config"),{filter_keys:i=[]}=n,o=s=>{r({filter_keys:[...s]})},a=x.useMemo(()=>t.filters.current.map(s=>({label:s.label,value:s.key})),[t.filters.values]);return l(d.Stack,{spacing:10,children:l(d.MultiSelect,{label:"Select Filters to Clear",data:a,value:i,onChange:o})})});async function oV(e,t){const r=(await t.operationData.getItem("config")).filter_keys;window.dispatchEvent(new CustomEvent("clear-filter-values",{detail:{filter_keys:r,payload:e}}))}const Wa=[YL,HL,ZL,nV,{displayName:"Clear Filter Values",id:"builtin:op:clear_filter_values",configRender:iV,run:oV}];class aV{constructor(t,n=Wa){Re(this,"attachments");this.operations=n;const r=async i=>{const{id:o,schemaRef:a}=await i.getItem(null);return{id:o,schemaRef:a,operationData:new vi(i,"data")}};this.attachments=new Ul(t,"__OPERATIONS",r)}async runOperation(t,n){const r=await this.attachments.getInstance(t);if(!r){console.warn(`Operation '${t}' is not defined`);return}const i=this.tryGetSchema(r.schemaRef);if(!i){console.warn(`Operation schema '${r.schemaRef}' is not defined`);return}await i.run(n,r)}tryGetSchema(t){return this.operations.find(n=>n.id===t)}async needMigration(){const n=(await this.attachments.list()).map(async r=>{const i={configData:r.operationData},o=this.tryGetSchema(r.schemaRef),a=o==null?void 0:o.migrator;return a&&await a.needMigration(i)});return(await Promise.all(n)).some(r=>r)}async runMigration(){const n=(await this.attachments.list()).map(async r=>{const i={configData:r.operationData},o=this.tryGetSchema(r.schemaRef),a=o==null?void 0:o.migrator;a&&await a.needMigration(i)&&await a.migrate(i)});await Promise.all(n)}async createOrGetOperation(t,n){var a,s;if(!this.getOperationSchemaList().some(u=>u.id===n.id))throw new Error(`Operation schema '${n.id}' is not defined`);const i=await this.attachments.getInstance(t);return!i||i.schemaRef!==n.id?await this.attachments.create(t,{id:t,schemaRef:n.id,data:(s=(a=n.createDefaultConfig)==null?void 0:a.call(n))!=null?s:{}}):i}getOperationList(){return this.attachments.list()}getOperationSchemaList(){return this.operations}removeOperation(t){return this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}}const Wv="__TRIGGERS";class sV{constructor(t,n){Re(this,"attachments");this.instance=t,this.component=n;const r=async i=>{const{id:o,schemaRef:a}=await i.getItem(null);return{id:o,schemaRef:a,triggerData:new vi(i,"data")}};this.attachments=new Ul(t,Wv,r)}watchTriggerSnapshotList(t){return this.instance.instanceData.watchItem(Wv,n=>{const r=H.values(n).map(i=>({id:H.get(i,"id"),schemaRef:H.get(i,"schemaRef"),config:Ft.toJS(H.get(i,"data.config"))}));t(r)},{fireImmediately:!0})}async createOrGetTrigger(t,n,r={recreate:!1}){var s;if(!this.getTriggerSchemaList().some(u=>u.id===n.id))throw new Error(`Trigger schema '${n.id}' is not defined in component '${this.component.name}'`);const o=await this.attachments.getInstance(t);return!o||r.recreate||o.schemaRef!==n.id?await this.attachments.create(t,{id:t,schemaRef:n.id,data:((s=n==null?void 0:n.createDefaultConfig)==null?void 0:s.call(n))||{}}):o}async getTriggerList(){return await this.attachments.list()}getTriggerSchemaList(){return this.component.triggers||[]}async removeTrigger(t){await this.attachments.remove(t)}async retrieveTrigger(t){return await this.attachments.getInstance(t)}async getMigrationTasks(){const n=(await this.getTriggerList()).map(async r=>{const i=this.getTriggerSchemaList().find(s=>s.id===r.schemaRef),o=i==null?void 0:i.migrator,a={configData:r.triggerData};return o&&await o.needMigration(a)?()=>o.migrate(a):null});return Promise.all(n).then(r=>r.filter(i=>i))}async needMigration(){return(await this.getMigrationTasks()).length>0}async runMigration(){const t=await this.getMigrationTasks();await Promise.all(t.map(n=>n()))}}class Ku{constructor(t,n,r){Re(this,"operationManager");Re(this,"triggerManager");Re(this,"attachments");this.operationManager=new aV(t,r),this.triggerManager=new sV(t,n);const i=async o=>{const{id:a,triggerRef:s,operationRef:u}=await o.getItem(null);return{id:a,triggerRef:s,operationRef:u}};this.attachments=new Ul(t,"__INTERACTIONS",i)}async addInteraction(t,n){const r=t.id,i=n.id,o=`[${r}]:[${i}]`;await this.attachments.create(o,{id:o,triggerRef:r,operationRef:i})}getInteractionList(){return this.attachments.list()}async removeInteraction(t){const n=await this.attachments.getInstance(t);if(!n)return;const{triggerRef:r,operationRef:i}=n;await this.getTriggerRefCount(r)<=1&&await this.triggerManager.removeTrigger(r),await this.getOperationRefCount(i)<=1&&await this.operationManager.removeOperation(i),await this.attachments.remove(t)}async getOperationRefCount(t){return(await this.getInteractionList()).filter(r=>r.operationRef===t).length}async getTriggerRefCount(t){return(await this.getInteractionList()).filter(r=>r.triggerRef===t).length}async runInteraction(t,n){const i=(await this.getInteractionList()).filter(o=>o.triggerRef===t);await Promise.all(i.map(async o=>{try{return await this.operationManager.runOperation(o.operationRef,n)}catch(a){console.warn(`Failed to run operation '${o.operationRef}'`,a)}}))}}const wi=({vizManager:e,instance:t})=>tt.useCreation(()=>new Ku(t,e.resolveComponent(t.type),Wa),[t,e]),qv=e=>{const{title:t="Variables",variables:n}=e,r=Ut.useClipboard(),i=o=>{r.copy(o),No.showNotification({color:"green",message:"Copied to clipboard"})};return y(d.Paper,{withBorder:!0,p:"sm",children:[l(d.Text,{size:"xs",color:"dimmed",mb:"sm",children:t}),l(d.Stack,{style:{maxHeight:"500px"},children:n.map(o=>y(d.Text,{size:"sm",children:[y(d.Code,{color:"teal",children:["// ",o.description]}),l("br",{}),y(d.Code,{onClick:()=>i(o.name),style:{cursor:"pointer"},children:[o.name," : ",o.valueType]})]},o.name))})]})};class lV{constructor(t,n){Re(this,"operationId");Re(this,"operation");Re(this,"operationSchema");Re(this,"variables",[]);this.operationManager=t,this.instance=n,Ft.makeAutoObservable(this)}get schemaList(){return this.operationManager.getOperationSchemaList()}async configOperation(t,n){const r=await this.operationManager.retrieveTrigger(t),i=this.operationManager.getOperationSchemaList().find(o=>o.id===(r==null?void 0:r.schemaRef));Ft.runInAction(()=>{this.operationId=t,this.operation=r,this.operationSchema=i,this.variables=n})}async changeSchema(t){this.operationId&&(await this.operationManager.createOrGetOperation(this.operationId,t),await this.configOperation(this.operationId,this.variables))}}function uV(e){return!!e.operationId}const cV=te.observer(({model:e,onClick:t})=>{var r;const n=(r=e.operationSchema)==null?void 0:r.displayName;return l(d.Button,{variant:"outline",onClick:t,children:n})}),dV=te.observer(({model:e})=>{const t={operation:e.operation,instance:e.instance,variables:[]};return x.createElement(e.operationSchema.configRender,t)});function fV({model:e}){const t=e.schemaList,n=t.map(i=>({label:i.displayName,value:i.id}));async function r(i){await e.changeSchema(t.find(o=>o.id===i))}return l(d.Select,{label:"Operation",data:n,onChange:r,value:e.operationSchema.id})}const pV=te.observer(e=>{const[t,{setTrue:n,setFalse:r}]=tt.useBoolean(!1),{operationManager:i,operationId:o,instance:a,variables:s}=e,u=tt.useCreation(()=>new lV(i,a),[i,a]);return tt.useAsyncEffect(async()=>{await u.configOperation(o,s)},[o,u]),uV(u)?y(Oe,{children:[l(cV,{model:u,onClick:n}),l(d.Modal,{size:600,opened:t,onClose:r,title:"Operation Settings",closeButtonLabel:"close",zIndex:320,children:y(d.Stack,{children:[l(fV,{model:u}),l(dV,{model:u}),l(qv,{title:"Variables",variables:u.variables})]})})]}):null});class hV{constructor(t,n){Re(this,"triggerId");Re(this,"trigger");Re(this,"triggerSchema");Re(this,"sampleData");this.triggerManager=t,this.instance=n,Ft.makeAutoObservable(this)}get schemaList(){return this.triggerManager.getTriggerSchemaList()}async configTrigger(t,n){const r=await this.triggerManager.retrieveTrigger(t),i=this.triggerManager.getTriggerSchemaList().find(o=>o.id===(r==null?void 0:r.schemaRef));Ft.runInAction(()=>{this.triggerId=t,this.trigger=r,this.triggerSchema=i,this.sampleData=n})}async changeSchema(t){this.triggerId&&(await this.triggerManager.createOrGetTrigger(this.triggerId,t),await this.configTrigger(this.triggerId,this.sampleData))}isReady(){return gV(this)}}function gV(e){return!!e.triggerId&&!!e.triggerSchema}function vV(e,t){return tt.useCreation(()=>new hV(e,t),[e,t])}const mV=te.observer(({model:e,onClick:t})=>{const n=e.triggerSchema.nameRender,r={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return l(d.Button,{variant:"outline",onClick:t,children:x.createElement(n,r)})}),yV=te.observer(({model:e})=>{const t=e.schemaList,n=t.map(i=>({label:i.displayName,value:i.id}));async function r(i){await e.changeSchema(t.find(o=>o.id===i))}return l(d.Select,{label:"Trigger",data:n,value:e.triggerSchema.id,onChange:r})}),bV=te.observer(({model:e})=>{const t={trigger:e.trigger,instance:e.instance,sampleData:e.sampleData};return x.createElement(e.triggerSchema.configRender,t)}),wV=te.observer(e=>{const[t,{setTrue:n,setFalse:r}]=tt.useBoolean(!1),i=e.model;return y(Oe,{children:[l(d.Modal,{opened:t,onClose:r,title:"Setup Trigger",closeButtonLabel:"close setup",zIndex:320,children:y(d.Stack,{children:[l(yV,{model:i}),l(bV,{model:i}),l(qv,{title:"Payload",variables:i.triggerSchema.payload})]})}),l(mV,{onClick:n,model:i})]})});function xV(e,t){const[n,r]=x.useState([]);return tt.useAsyncEffect(async()=>{const i=await e.getInteractionList();r(i)},[t,e]),n}const SV=te.observer(({item:e,manager:t,instance:n,sampleData:r,variables:i,onRemove:o})=>{const{triggerRef:a,operationRef:s}=e,u=vV(t.triggerManager,n);if(tt.useAsyncEffect(async()=>{await u.configTrigger(a,r)},[u,a,r]),u.isReady()){const c=[...u.triggerSchema.payload,...i];return y(d.Group,{children:[l(wV,{model:u}),l(pV,{instance:n,operationId:s,variables:c,operationManager:t.operationManager}),l(d.ActionIcon,{"aria-label":"delete-interaction",variant:"filled",color:"red",onClick:()=>o(e),children:l(le.Trash,{size:16})})]})}return null}),CV=e=>{const[t,n]=x.useState(0),{interactionManager:r,instance:i,sampleData:o,variables:a}=e,s=xV(r,t),u=async()=>{const p=await r.triggerManager.createOrGetTrigger(Ut.randomId(),r.triggerManager.getTriggerSchemaList()[0]),g=await r.operationManager.createOrGetOperation(Ut.randomId(),r.operationManager.getOperationSchemaList()[0]);await r.addInteraction(p,g),n(v=>v+1)};async function c(p){await r.removeInteraction(p.id),n(g=>g+1)}const{data:f=0,loading:h}=tt.useRequest(async()=>{try{return(await r.triggerManager.getTriggerSchemaList()).length}catch{return 0}});return y(d.Stack,{children:[l(d.LoadingOverlay,{visible:h}),f===0&&l(d.Alert,{icon:l(le.AlertCircle,{size:16}),title:"Unavailable",color:"gray",children:"This visualization does not have available interactions to choose from"}),s.map(p=>l(SV,{onRemove:c,instance:i,sampleData:o,variables:a,item:p,manager:e.interactionManager},p.id)),l(d.Button,{style:{width:"fit-content"},onClick:()=>u(),disabled:f===0,children:"Add interaction"})]})},_V=()=>{const{panel:e,data:t}=Yt(),n=e.viz,{vizManager:r}=x.useContext(zn),i=e.json,o=tt.useCreation(()=>r.getOrCreateInstance(i),[r,i]),a=tt.useCreation(()=>new Ku(o,r.resolveComponent(n.type),Wa),[o,n.type]);return x.useEffect(()=>o.instanceData.watchItem(null,H.throttle(s=>{e.viz.setConf(s)},100,{leading:!1,trailing:!0})),[o]),{instance:o,vizManager:r,interactionManager:a,sampleData:t,variables:[]}},EV=()=>{const e=_V();return l(CV,{...e})};var Uv=(e=>(e.migrated="migrated",e.nothingToMigrate="nothingToMigrate",e.checkFailed="checkFailed",e.migrationFailed="migrationFailed",e))(Uv||{}),qa=(e=>(e.notStarted="notStarted",e.inProgress="inProgress",e.done="done",e))(qa||{});class TV{constructor(t){Re(this,"vizInstance");Re(this,"operationManager");Re(this,"triggerManager");Re(this,"vizManager");Re(this,"runningMigration");Re(this,"panelModel");Re(this,"status","notStarted");this.panelModel=t.getRequired(Lt.instanceScope.panelModel),this.vizInstance=t.getRequired(Lt.instanceScope.vizInstance),this.operationManager=t.getRequired(Lt.instanceScope.operationManager),this.triggerManager=t.getRequired(Lt.instanceScope.triggerManager),this.vizManager=t.getRequired(Lt.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 Yv(e){const{panel:t}=Yt();return x.useCallback(n=>{const r=n.getRequired(Lt.vizManager),i=r.resolveComponent(e.viz.type);return n.createScoped().provideFactory(Lt.instanceScope.vizInstance,()=>r.getOrCreateInstance(e)).provideFactory(Lt.instanceScope.interactionManager,o=>{const a=o.getRequired(Lt.instanceScope.vizInstance);return new Ku(a,i,Wa)}).provideFactory(Lt.instanceScope.operationManager,o=>o.getRequired(Lt.instanceScope.interactionManager).operationManager).provideFactory(Lt.instanceScope.triggerManager,o=>o.getRequired(Lt.instanceScope.interactionManager).triggerManager).provideValue(Lt.instanceScope.panelModel,t).provideFactory(Lt.instanceScope.migrator,o=>new TV(o))},[e.viz.type,e.viz.conf])}function Xv(e){const[t,n]=x.useState(!1),r=vd().getRequired(Lt.instanceScope.migrator);return tt.useAsyncEffect(async()=>{const i=r.status===qa.notStarted;n(r.status===qa.done),r.status===qa.notStarted&&r.runMigration().then(o=>{o===Uv.migrated&&i&&(e==null||e())}).finally(()=>{n(!0)})},[r]),t}function Qv(e,t){const n=vd().getRequired(Lt.instanceScope.vizInstance);return x.useEffect(()=>(n.instanceData.setItem(null,t.viz.conf),n.instanceData.watchItem(null,r=>{e(r)})),[e,t.viz.type]),n}function MV({setVizConf:e,...t}){const{panel:n}=t,r=Qv(e,n),i=Xv(()=>{No.showNotification({title:`${n.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})});return tt.useAsyncEffect(async()=>{await r.instanceData.setItem(null,n.viz.conf)},[r,n.viz.type]),i?l(RD,{...t}):l(d.Text,{children:"Checking update..."})}function kV(e){const{panel:t,setVizConf:n}=e;return Qv(n,t),Xv(()=>{No.showNotification({title:`${t.title} - Updated`,message:"Your plugin configuration has been migrated to the latest version"})})?l(DD,{...e}):l(d.Text,{children:"Checking update"})}const R6="";function OV(e,t){const{vizManager:n}=x.useContext(zn),{panel:{viz:r,title:i,id:o,description:a,queryID:s,variables:u}}=Yt(),c={title:i,id:o,description:a,queryID:s,viz:r,layout:t},f=Yv(c);try{return n.resolveComponent(r.type),l(Fo,{configure:f,children:l(kV,{setVizConf:r.setConf,panel:c,data:e,variables:u,vizManager:n})})}catch(h){return console.info(H.get(h,"message")),null}}const DV=["richText","button"],Zv=te.observer(function({height:t,viz:n,data:r,loading:i,error:o,query:a}){const{ref:s,width:u,height:c}=Ut.useElementSize(),f=OV(r,{w:u,h:c});if(DV.includes(n.type))return l("div",{className:"viz-root",style:{height:t},ref:s,children:l(Or,{children:f})});if(i)return l("div",{className:"viz-root",style:{height:t},ref:s,children:l(d.LoadingOverlay,{visible:i,exitTransitionDuration:0})});const p=!!o,g=!p&&!!(a!=null&&a.stateMessage),v=!p&&!g;return y("div",{className:"viz-root",style:{height:t},ref:s,children:[p&&l(d.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:o}),g&&l(d.Text,{color:"gray",align:"center",children:a.stateMessage}),v&&l(Or,{children:f})]})});function RV(e){return!["richText","button"].includes(e)}const AV={border:"1px solid #e9ecef"},Jv={border:"1px dashed transparent",transition:"border-color 300ms ease","&:hover":{borderColor:"#e9ecef"}};function PV(e,t,n){return e.style.border.enabled?AV:n||t?Jv:{border:"1px dashed transparent"}}const Ua=te.observer(function({panel:t,view:n}){const r=$e(),{inEditMode:i}=x.useContext(Dr),{data:o,state:a,error:s}=r.getDataStuffByID(t.queryID),u=r.queries.findByID(t.queryID),c=RV(t.viz.type),f=c&&a==="loading",h=t.title?"calc(100% - 25px - 5px)":"100%",p=PV(t,c,i),g=c||i;return l($s,{value:{panel:t,data:o,loading:f},children:y(d.Box,{className:"panel-root",p:5,pt:0,sx:{...p},children:[l(d.Box,{sx:{position:"absolute",left:0,top:0,height:28,zIndex:310},children:l(yg,{})}),g&&l(TD,{view:n}),l(MD,{}),l(Zv,{viz:t.viz,data:o,loading:f,error:s,height:h,query:u})]})})}),A6="",IV=Z.default.forwardRef(({handleAxis:e},t)=>l(d.ActionIcon,{ref:t,className:"react-grid-customDragHandle",sx:{userSelect:"none",cursor:"grab",position:"absolute",top:0,right:0,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",children:l(le.ArrowsMove,{size:16})})),NV=Z.default.forwardRef(({handleAxis:e,...t},n)=>l(d.ActionIcon,{ref:n,className:"react-grid-customResizeHandle",sx:{userSelect:"none",cursor:"nwse-resize",position:"absolute",bottom:-5,right:-5,zIndex:400,"&:hover":{color:"#228be6"}},variant:"transparent",...t,children:l(le.ChevronDownRight,{size:16})})),$V=Os.WidthProvider(ud.default),LV=te.observer(function({view:t,className:n="layout",rowHeight:r=10,isDraggable:i,isResizable:o}){const a=Z.default.useCallback(s=>{s.forEach(({i:u,...c})=>{const f=t.panels.findByID(u);!f||f.layout.set(c)})},[t]);return l($V,{onLayoutChange:a,className:`dashboard-layout ${n}`,rowHeight:r,layout:t.panels.layouts,isDraggable:i,isResizable:o,draggableHandle:".react-grid-customDragHandle",resizeHandle:l(NV,{}),children:t.panels.list.map((s,u)=>y("div",{"data-grid":{...s.layout},style:{position:"relative"},children:[i&&l(IV,{}),l(Ua,{view:t,panel:s})]},s.id))})}),VV=Os.WidthProvider(ud.default),zV=te.observer(function({view:t,className:n="layout",rowHeight:r=10}){return l(VV,{className:`dashboard-layout ${n}`,rowHeight:r,isDraggable:!1,isResizable:!1,layout:t.panels.layouts,children:t.panels.list.map(i=>l("div",{"data-grid":i.layout,children:l(Ua,{view:t,panel:i})},i.id))})});var em=(e=>(e.Use="use",e.Edit="edit",e))(em||{}),rt=(e=>(e.Division="div",e.Modal="modal",e.Tabs="tabs",e))(rt||{});const FV={div:"Division",tabs:"Tabs",modal:"Modal"},tm={div:"rgba(255, 0, 0, 0.2)",modal:"rgba(0, 0, 0, 0.2)",tabs:"rgba(255, 200, 100, 0.4)"},BV={div:"#ff4000",modal:"#000",tabs:"#ffad18"};var Hu=(e=>(e.Select="select",e.TreeSelect="tree-select",e.MultiSelect="multi-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(Hu||{});const jV=te.observer(({children:e})=>l(d.Box,{pt:10,pb:100,children:e})),GV=te.observer(({children:e,view:t})=>{const n=t.config;return l(d.Modal,{size:n.width,overflow:"inside",opened:!0,onClose:fe.default.noop,withCloseButton:!1,title:n.custom_modal_title.value,trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{root:{position:"relative",height:"100%"},overlay:{position:"absolute !important"},modal:{border:"1px solid #efefef"},body:{maxHeight:"calc(100vh - 325px)"}},withinPortal:!1,transitionDuration:0,children:e})}),KV=({variant:e,orientation:t})=>{const n={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},HV=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},WV=te.observer(({children:e,view:t})=>{const n=$e(),r=x.useMemo(()=>n.views.options.filter(o=>o.type===rt.Division),[t.id,n.views.options]),i=t.config;return y(d.Box,{className:"preview-view-tabs",children:[y(d.Tabs,{variant:i.variant,orientation:i.orientation,defaultValue:i.tabs.length>0?i.tabs[0].id:"0",styles:KV(i),children:[y(d.Tabs.List,{grow:i.grow,children:[i.tabs.map(o=>{var a;return l(d.Tabs.Tab,{value:o.id,sx:HV(o),children:(a=o.name)!=null?a:o.id},o.id)}),l(d.Tabs.Tab,{onClick:i.addTab,value:"add",className:"add-a-tab",children:l(le.Plus,{size:18,color:"#228be6"})})]}),i.tabs.map(o=>{const a=n.views.findByID(o.view_id);return y(d.Tabs.Panel,{value:o.id,sx:{position:"relative"},children:[y(d.Box,{sx:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:200},children:[l(d.Overlay,{opacity:.8,color:"#FFF",blur:10,zIndex:100}),y(d.Stack,{mx:"auto",mt:100,sx:{width:"300px",position:"relative",zIndex:200},children:[l(d.TextInput,{label:"Tab Name",value:o.name,onChange:s=>o.setName(s.currentTarget.value)}),l(d.Select,{label:"View",value:o.view_id,onChange:o.setViewID,data:r}),l(d.ColorInput,{label:"Color",value:o.color,onChange:o.setColor,disabled:i.variant!=="default"}),a&&y(d.Button,{mt:20,variant:"gradient",leftIcon:l(qP,{size:18}),gradient:{from:"cyan",to:"indigo"},onClick:()=>n.views.setIDOfVIE(a.id),children:["Swith to View: ",a.name]})]})]}),a&&l(Ya,{view:a})]},o.id)})]}),e]})}),qV=te.observer(({view:e,children:t})=>{switch(e.type){case rt.Modal:return l(GV,{view:e,children:t});case rt.Tabs:return l(WV,{view:e,children:t});case rt.Division:default:return l(jV,{children:t})}}),nm=te.observer(function({view:t}){return l(Is.Provider,{value:{viewPanelInFullScreen:fe.default.noop,inFullScreen:!1},children:l(d.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:l(qV,{view:t,children:y(d.Box,{sx:{position:"relative"},children:[l(d.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:l(lg,{view:t})}),l(LV,{view:t,isDraggable:!0,isResizable:!0})]})})})})}),UV=te.observer(function({view:t,panel:n,exitFullScreen:r}){return y(d.Stack,{px:"10px",pb:"5px",sx:{height:"100%",flexGrow:1,justifyContent:"flex-start"},children:[l(d.Group,{sx:{flexGrow:0},children:l(d.Button,{variant:"default",size:"sm",onClick:r,leftIcon:l(le.ArrowLeft,{size:20}),children:"Exit fullscreen"})}),l(d.Group,{grow:!0,sx:{flexGrow:1,flexShrink:0},children:l(Ua,{view:t,panel:n})})]})});function YV(e,t,n){const r=e.id==="Main",[i,o]=Z.default.useState(()=>r&&e.panels.findByID(t)?t:null),a=Z.default.useCallback(f=>{o(f),r&&n(f)},[r,n]),s=Z.default.useCallback(()=>{o(null),r&&n("")},[r,n]),u=i?e.panels.findByID(i):null;return{viewPanelInFullScreen:a,exitFullScreen:s,inFullScreen:!!u,fullScreenPanel:u}}const XV=te.observer(({children:e})=>l(d.Box,{children:e})),QV=te.observer(({children:e,view:t})=>{const n=$e(),r=t.config,i=n.views.visibleViewIDs.includes(t.id),o=()=>n.views.rmVisibleViewID(t.id);return l(d.Modal,{size:r.width,centered:!0,overflow:"inside",opened:i,onClose:o,withCloseButton:!1,title:r.custom_modal_title.value,trapFocus:!0,onDragStart:a=>{a.stopPropagation()},styles:{modal:{border:"1px solid #efefef"},body:{maxHeight:r.height,overflow:"auto"}},transitionDuration:0,children:e})}),ZV=e=>e.color?{"&[data-active], &[data-active]:hover":{borderColor:e.color?e.color:"..."}}:{},JV=te.observer(({children:e,view:t})=>{const n=$e(),r=t.config;return y(d.Box,{className:"render-view-tabs",children:[y(d.Tabs,{variant:r.variant,orientation:r.orientation,defaultValue:r.tabs.length>0?r.tabs[0].id:"0",styles:{panel:{padding:"16px 0px"}},keepMounted:!1,children:[l(d.Tabs.List,{grow:r.grow,children:r.tabs.map(i=>{var o;return l(d.Tabs.Tab,{value:i.id,sx:ZV(i),disabled:!i.view_id,children:(o=i.name)!=null?o:i.id},i.id)})}),r.tabs.map(i=>{const o=n.views.findByID(i.view_id);return o?l(d.Tabs.Panel,{value:i.id,children:l(Ya,{view:o})},i.id):null})]}),e]})}),ez=te.observer(({view:e,children:t})=>{switch(e.type){case rt.Modal:return l(QV,{view:e,children:t});case rt.Tabs:return l(JV,{view:e,children:t});case rt.Division:default:return l(XV,{children:t})}}),Ya=te.observer(function({view:t}){const{fullScreenPanelID:n,setFullScreenPanelID:r}=wd(),{viewPanelInFullScreen:i,exitFullScreen:o,inFullScreen:a,fullScreenPanel:s}=YV(t,n,r);return l(Is.Provider,{value:{viewPanelInFullScreen:i,inFullScreen:a},children:y(d.Box,{className:"dashboard-view","data-enable-scrollbar":!0,children:[a&&l(UV,{view:t,panel:s,exitFullScreen:o}),l(ez,{view:t,children:y(d.Box,{sx:{position:"relative"},children:[!a&&l(d.Box,{className:"dashboard-sticky-area",sx:{position:"sticky",top:"0px"},children:l(lg,{view:t})}),!a&&l(zV,{view:t})]})})]})})});function tz(e){e=e||{};const t=Object.keys(e).sort(),n=[];for(let r=0;r<t.length;r++){const i=t[r];if(i!="authentication"&&e[i])n.push(t[r]+"="+(typeof e[i]=="object"?JSON.stringify(e[i]):e[i]));else{const o=Object.keys(e[i]).sort();for(let a=0;a<o.length;a++){const s=o[a];s!="sign"&&e[i][s]&&n.push(o[a]+"="+(typeof e[i][s]=="object"?JSON.stringify(e[i][s]):e[i][s]))}}}return n.sort().join("&")}function nz(e,t){let n=tz(e);return n+="&key="+t,fd.default.MD5(n).toString().toUpperCase()}const zr={baseURL:"http://localhost:31200",app_id:"",app_secret:"",getAuthentication(e){if(!this.app_id||!this.app_secret)return;const t=new Date().getTime().toString();return{app_id:this.app_id,nonce_str:t,sign:nz({app_id:this.app_id,nonce_str:t,...e},this.app_secret)}},getRequest(e,t){return(n,r,i={})=>{const o=window.localStorage.getItem("token"),a={"X-Requested-With":"XMLHttpRequest","Content-Type":i.string?"application/x-www-form-urlencoded":"application/json",authorization:o?`bearer ${o}`:"",...i.headers},s={baseURL:this.baseURL,method:e,url:n,params:e==="GET"?r:i.params,headers:a,signal:t};return["POST","PUT"].includes(e)&&(s.data=i.string?JSON.stringify(r):r,s.data.authentication=this.getAuthentication(s.data)),Vo.default(s).then(u=>u.data).catch(u=>Promise.reject(u))}}};function rm(e){zr.baseURL!==e.apiBaseURL&&(zr.baseURL=e.apiBaseURL),e.app_id&&(zr.app_id=e.app_id),e.app_secret&&(zr.app_secret=e.app_secret)}const im=D.types.model("FilterConfigModel_Checkbox",{_name:D.types.literal("checkbox"),default_value:D.types.boolean}).actions(e=>({setDefaultValue(t){e.default_value=t}})),rz=()=>im.create({_name:"checkbox",default_value:!1});var Sn=(e=>(e.Postgresql="postgresql",e.MySQL="mysql",e.HTTP="http",e))(Sn||{}),Qt=(e=>(e.Select="select",e.MultiSelect="multi-select",e.TreeSelect="tree-select",e.TextInput="text-input",e.Checkbox="checkbox",e.DateRange="date-range",e))(Qt||{});D.types.model({type:D.types.enumeration("DataSourceType",[Sn.Postgresql,Sn.MySQL,Sn.HTTP]),key:D.types.string,sql:D.types.string});const iz=D.types.model("FilterConfigModel_DateRange",{_name:D.types.literal("date-range"),required:D.types.boolean,inputFormat:D.types.enumeration("DateRangeInputFormat",["YYYY","YYYYMM","YYYYMMDD","YYYY-MM","YYYY-MM-DD"]),default_value:D.types.optional(D.types.array(D.types.union(D.types.string,D.types.null)),[null,null]),clearable:D.types.boolean,max_days:D.types.optional(D.types.number,0),allowSingleDateInRange:D.types.optional(D.types.boolean,!1)}).views(e=>({truthy(t){return Array.isArray(t)&&t.length===2&&t.every(n=>!!n)}})).views(e=>({getMaxDate(t){const{max_days:n}=e;if(!(!n||!t))return En.default(t).startOf("day").add(n,"days").toDate()},getMinDate(t){const{max_days:n}=e;if(!(!n||!t))return En.default(t).startOf("day").subtract(n,"days").toDate()}})).actions(e=>({setFilterValue(t){try{const n=D.getParent(e);D.getRoot(e).filters.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)},setMaxDays(t){e.max_days=t,t>0&&(e.clearable=!0)},setAllowSingleDateInRange(t){e.allowSingleDateInRange=t}})),om=D.types.snapshotProcessor(iz,{preProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>n===null?null:En.default.tz(n,"UTC").toISOString())}},postProcessor({default_value:e,...t}){return{...t,default_value:e.map(n=>{try{return n?En.default.tz(n,"UTC").format(t.inputFormat):null}catch{return console.log(`[date-range] failed parsing ${n}`),null}})}}}),oz=()=>om.create({_name:"date-range",required:!1,inputFormat:"YYYY-MM-DD",clearable:!1,default_value:[null,null]}),az=D.types.model({label:D.types.string,value:D.types.string}).actions(e=>({setLabel(t){e.label=t},setValue(t){e.value=t}})),Wu=D.types.model("FilterConfigModel_BaseSelect",{static_options:D.types.optional(D.types.array(az),[]),options_query_id:D.types.optional(D.types.string,""),default_selection_count:D.types.optional(D.types.number,0)}).views(e=>({get usingQuery(){return!!e.options_query_id}})).views(e=>({get options(){if(!e.usingQuery)return e.static_options;const{data:t,state:n,error:r}=D.getRoot(e).getDataStuffByID(e.options_query_id);return n==="idle"?t:[]}})).actions(e=>({addStaticOption(t){e.static_options.push(t)},removeStaticOption(t){e.static_options.splice(t,1)},setDefaultSelectionCount(t){e.default_selection_count=t},setOptionsQueryID(t){e.options_query_id=t!=null?t:""}})),am=D.types.compose("FilterConfigModel_MultiSelect",D.types.model({_name:D.types.literal("multi-select"),default_value:D.types.optional(D.types.array(D.types.string),[]),min_width:D.types.optional(D.types.string,"")}),Wu).actions(e=>({setDefaultValue(t){e.default_value=D.cast(t)},setMinWidth(t){e.min_width=t}})),sz=()=>am.create({_name:"multi-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),sm=D.types.compose("FilterConfigModel_TreeSelect",D.types.model({_name:D.types.literal("tree-select"),default_value:D.types.optional(D.types.array(D.types.string),[]),min_width:D.types.optional(D.types.string,"")}),Wu).actions(e=>({setDefaultValue(t){e.default_value=D.cast(t)},setMinWidth(t){e.min_width=t}})),lz=()=>sm.create({_name:"tree-select",default_value:[],static_options:[],options_query_id:"",default_selection_count:0}),lm=D.types.compose("FilterConfigModel_Select",D.types.model({_name:D.types.literal("select"),default_value:D.types.string,required:D.types.boolean,width:D.types.optional(D.types.string,"")}),Wu).views(e=>({truthy(t){return!!t}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t},setWidth(t){e.width=t}})),uz=()=>lm.create({_name:"select",required:!1,default_value:"",static_options:[],options_query_id:"",default_selection_count:0}),um=D.types.model("FilterConfigModel_TextInput",{_name:D.types.literal("text-input"),required:D.types.boolean,default_value:D.types.string}).views(e=>({truthy(t){return typeof t!="string"?!1:!!t.trim()}})).actions(e=>({setRequired(t){e.required=t},setDefaultValue(t){e.default_value=t}})),cm=()=>um.create({_name:"text-input",required:!1,default_value:""}),qu=D.types.model("FilterModel",{id:D.types.identifier,key:D.types.string,label:D.types.string,order:D.types.number,visibleInViewsIDs:D.types.array(D.types.string),auto_submit:D.types.optional(D.types.boolean,!1),type:D.types.enumeration("DashboardFilterType",[Qt.Select,Qt.MultiSelect,Qt.TreeSelect,Qt.TextInput,Qt.Checkbox,Qt.DateRange]),config:D.types.union(lm,am,sm,um,im,om)}).views(e=>({get plainDefaultValue(){const t=e.config.default_value;return Array.isArray(t)?[...t]:t},get usingDefaultValue(){return e.type!==Qt.TreeSelect},get auto_submit_supported(){return[Qt.Select,Qt.Checkbox,Qt.DateRange].includes(e.type)}})).views(e=>({get should_auto_submit(){return e.auto_submit_supported&&e.auto_submit},requiredAndPass(t){return fe.default.get(e.config,"required",!1)?fe.default.get(e.config,"truthy",()=>!0)(t):!1}})).actions(e=>({setKey(t){e.key=t},setLabel(t){e.label=t},setOrder(t){e.order=t},setType(t){switch(t){case Qt.Select:e.config=uz();break;case Qt.MultiSelect:e.config=sz();break;case Qt.TreeSelect:e.config=lz();break;case Qt.TextInput:e.config=cm();break;case Qt.Checkbox:e.config=rz();break;case Qt.DateRange:e.config=oz();break}e.type=t},setVisibleInViewsIDs(t){e.visibleInViewsIDs.length=0,e.visibleInViewsIDs.push(...t)},setAutoSubmit(t){e.auto_submit=e.auto_submit_supported&&t}}));function dm(e,t){if(e===void 0)return e;if(t._name==="date-range")try{const[...n]=e;return n.map(r=>{if(r===null)return r;const i=En.default.tz(r,"UTC").format(t.inputFormat);return i!=null?i:r})}catch(n){return console.error(n),e}return e}function fm(e){return e.reduce((t,n)=>(t[n.key]=dm(n.config.default_value,n.config),t),{})}function cz(e,t,n){D.addDisposer(e,D.addMiddleware(e,(r,i)=>{i(r,()=>{D.getType(r.context)===t&&r.type==="action"&&n(r.name,r.context)})}))}const pm=D.types.model("FiltersModel",{current:D.types.optional(D.types.array(qu),[]),values:D.types.optional(D.types.frozen(),{}),previewValues:D.types.optional(D.types.frozen(),{})}).views(e=>({get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},get inOrder(){return fe.default.sortBy(e.current,"order")},get options(){return e.current.map(t=>{var n;return{label:(n=t.label)!=null?n:t.id,value:t.id,_type:"filter"}})},get empty(){return e.current.length===0},visibleInView(t){return fe.default.sortBy(e.current.filter(n=>n.visibleInViewsIDs.includes(t)),"order")},get firstFilterValueKey(){var t;return(t=Object.keys(e.values)[0])!=null?t:""},get keyLabelMap(){return e.current.reduce((t,n)=>(t[n.key]=n.label,t),{})}})).actions(e=>({replace(t){e.current=D.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(r=>r.id===t);n>=0&&e.current.splice(n,1)},setValues(t){e.values=t},setValueByKey(t,n){e.values={...e.values,[t]:n}},getValueByKey(t){return e.values[t]},refreshValues(){console.log("refreshing values"),e.values=fm(e.current)},updatePreviewValues(t){e.previewValues=t}})).actions(e=>{function t(){cz(e.current,qu,(n,r)=>{if(n==="setType"){const i=dm(r.config.default_value,r.config);e.setValueByKey(r.key,i),e.updatePreviewValues({...e.previewValues,[r.key]:i})}})}return{afterCreate(){t()}}});function hm(e){return{current:e,values:fm(e)}}var Xa={exports:{}};(function(e,t){(function(n,r){r()})(hn,function(){function n(c,f){return typeof f>"u"?f={autoBom:!1}:typeof f!="object"&&(console.warn("Deprecated: Expected third argument to be a object"),f={autoBom:!f}),f.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(c.type)?new Blob(["\uFEFF",c],{type:c.type}):c}function r(c,f,h){var p=new XMLHttpRequest;p.open("GET",c),p.responseType="blob",p.onload=function(){u(p.response,f,h)},p.onerror=function(){console.error("could not download file")},p.send()}function i(c){var f=new XMLHttpRequest;f.open("HEAD",c,!1);try{f.send()}catch{}return 200<=f.status&&299>=f.status}function o(c){try{c.dispatchEvent(new MouseEvent("click"))}catch{var f=document.createEvent("MouseEvents");f.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),c.dispatchEvent(f)}}var a=typeof window=="object"&&window.window===window?window:typeof self=="object"&&self.self===self?self:typeof hn=="object"&&hn.global===hn?hn:void 0,s=a.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),u=a.saveAs||(typeof window!="object"||window!==a?function(){}:"download"in HTMLAnchorElement.prototype&&!s?function(c,f,h){var p=a.URL||a.webkitURL,g=document.createElement("a");f=f||c.name||"download",g.download=f,g.rel="noopener",typeof c=="string"?(g.href=c,g.origin===location.origin?o(g):i(g.href)?r(c,f,h):o(g,g.target="_blank")):(g.href=p.createObjectURL(c),setTimeout(function(){p.revokeObjectURL(g.href)},4e4),setTimeout(function(){o(g)},0))}:"msSaveOrOpenBlob"in navigator?function(c,f,h){if(f=f||c.name||"download",typeof c!="string")navigator.msSaveOrOpenBlob(n(c,h),f);else if(i(c))r(c,f,h);else{var p=document.createElement("a");p.href=c,p.target="_blank",setTimeout(function(){o(p)})}}:function(c,f,h,p){if(p=p||open("","_blank"),p&&(p.document.title=p.document.body.innerText="downloading..."),typeof c=="string")return r(c,f,h);var g=c.type==="application/octet-stream",v=/constructor/i.test(a.HTMLElement)||a.safari,m=/CriOS\/[\d]+/.test(navigator.userAgent);if((m||g&&v||s)&&typeof FileReader<"u"){var w=new FileReader;w.onloadend=function(){var C=w.result;C=m?C:C.replace(/^data:[^;]*;/,"data:attachment/file;"),p?p.location.href=C:location=C,p=null},w.readAsDataURL(c)}else{var b=a.URL||a.webkitURL,_=b.createObjectURL(c);p?p.location=_:location.href=_,p=null,setTimeout(function(){b.revokeObjectURL(_)},4e4)}});a.saveAs=u.saveAs=u,e.exports=u})})(Xa);function dz(e,t){const n=new Blob([t],{type:"text/csv"});Xa.exports.saveAs(n,`${e}.csv`)}function fz(e,t){const n=new Blob([t],{type:"application/json"});Xa.exports.saveAs(n,`${e}.json`)}function pz(e){const t=new E0.default;e.forEach(({id:n,data:r})=>{t.file(`${n}.csv`,gm(r))}),t.generateAsync({type:"blob"}).then(n=>{Xa.exports.saveAs(n,"dashboard_data.zip")})}function gm(e){if(!Array.isArray(e)||e.length===0)return"";const t=[],n=Object.keys(e[0]);return t.push(n.join(",")),e.forEach(r=>{const i=Object.values(r).join(",");t.push(i)}),t.join(`
248
248
  `)}const Qa={CryptoJS:fd.default,dayjs:En.default,lodash:fe.default,numbro:Bt.default};function hz(e,t){return new Function(`return ${e}`)()(t,Qa)}function gz(e,t,n){return{context:{...t,...e},filters:n}}function vz(e,t,n,r){const i=gz(t,n,r);return hz(e,i)}function mz(e,t){try{return new Function(`return ${e.config.processing.pre}`)()(t,Qa)}catch(n){return console.error(n),t}}function yz(e,t){try{return new Function(`return ${e.config.processing.post}`)()(t,Qa)}catch(n){return console.error(n),t}}function bz(e,t){try{return new Function(`return ${e}`)()(t,Qa)}catch(n){return console.error(n),t}}function wz(e,t,n,r){const i=Yu(t,n,[],r),o=Object.keys(i),a=Object.values(i);try{return new Function(...o,`return \`${e}\`;`)(...a)}catch(s){return console.info(s),s.message}}function Uu(e,t={}){const n=Object.keys(t),r=Object.values(t);try{return new Function(...n,`return \`${e}\`;`)(...r)}catch(i){throw n.length===0&&e.includes("$")?new Error("[formatSQL] insufficient params"):i}}function Yu(e,t,n,r){const i={...t,...e},o={context:i,filters:r},a=n.reduce((s,u)=>(s[u.key]=Uu(u.value,o),s),{});return fe.default.merge({},{context:i,filters:r,sql_snippets:a})}function vm(e,t,n,r,i){try{const o=Yu(t,n,r,i);return Uu(e,o)}catch(o){return console.error(o),o.message}}async function xz({context:e,mock_context:t,sqlSnippets:n,title:r,query:i,filterValues:o},a){if(!i.sql)return[];const{type:s,key:u,sql:c}=i,f=c.includes("$"),h=Yu(e,t,n,o),p=Uu(c,h);return f&&(console.groupCollapsed(`Final SQL for: ${r}`),console.log(p),console.groupEnd()),await zr.getRequest("POST",a)("/query",{type:s,key:u,query:p},{})}async function Sz({context:e,mock_context:t,query:n,filterValues:r,datasource:i},o){const{type:a,key:s,name:u,pre_process:c,post_process:f}=n;let h=vz(c,e,t,r);console.groupCollapsed(`Request config for: ${u}`),console.log(h),console.groupEnd(),h=mz(i,h);const p=JSON.stringify(h),g=await zr.getRequest("POST",o)("/query",{type:a,key:s,query:p},{});let v=yz(i,g);return v=bz(f,v),v}async function Xu(){try{return(await zr.getRequest("POST")("/datasource/list",{filter:{},sort:[{field:"create_time",order:"ASC"}],pagination:{page:1,pagesize:100}})).data}catch(e){return console.error(e),[]}}const Cz=D.types.model("QueryModel",{id:D.types.string,name:D.types.string,type:D.types.enumeration("DataSourceType",[Sn.Postgresql,Sn.MySQL,Sn.HTTP]),key:D.types.string,sql:D.types.string,pre_process:D.types.optional(D.types.string,""),post_process:D.types.optional(D.types.string,""),run_by:D.types.optional(D.types.array(D.types.string),[])}).views(e=>({get valid(){return e.id&&e.type&&e.key&&e.name?e.type===Sn.HTTP?!!e.pre_process:!!e.sql:!1},get json(){const{id:t,name:n,type:r,key:i,sql:o,run_by:a,pre_process:s,post_process:u}=e;return{id:t,key:i,sql:o,name:n,type:r,run_by:a,pre_process:s,post_process:u}},get conditionOptions(){const{context:t,mock_context:n,filterValues:r}=D.getRoot(e).payloadForSQL,i=Object.keys({...n,...t}).map(s=>`context.${s}`),o=Object.keys(r).map(s=>`filters.${s}`);return[...i,...o].map(s=>({label:s.split(".")[1],value:s,group:fe.default.capitalize(s.split(".")[0])}))},get unmetRunByConditions(){const{run_by:t}=e;if(t.length===0)return[];const{context:n,mock_context:r,filterValues:i}=D.getRoot(e).payloadForSQL,o={context:{...r,...n},filters:i};return t.filter(a=>{const s=fe.default.get(o,a);return Array.isArray(s)?s.length===0:typeof s=="number"?Number.isNaN(s):!s})}})).views(e=>({get runByConditionsMet(){return e.unmetRunByConditions.length===0},get conditionNames(){if(e.unmetRunByConditions.length===0)return{context:[],filters:[]};const{keyLabelMap:t}=D.getRoot(e).filters,n=e.unmetRunByConditions.filter(i=>i.startsWith("context.")).map(i=>i.split("context.")[0]),r=e.unmetRunByConditions.filter(i=>i.startsWith("filters.")).map(i=>fe.default.get({filters:t},i)).filter(i=>!!i);return{context:n,filters:r}}})).actions(e=>({setName(t){e.name=t},setKey(t){e.key=t},setType(t){e.type=t},setSQL(t){e.sql=t},setRunBy(t){e.run_by.length=0,e.run_by.push(...t)},setPreProcess(t){e.pre_process=t},setPostProcess(t){e.post_process=t}})),mm=D.types.compose("QueryModel",Cz,D.types.model({state:D.types.optional(D.types.enumeration(["idle","loading","error"]),"idle"),data:D.types.optional(D.types.array(D.types.frozen()),[]),error:D.types.frozen()})).views(e=>({get formattedSQL(){const{context:t,mock_context:n,sqlSnippets:r,filterValues:i}=D.getRoot(e).payloadForSQL;return vm(e.sql,t,n,r,i)},get typedAsSQL(){return[Sn.Postgresql,Sn.MySQL].includes(e.type)},get typedAsHTTP(){return[Sn.HTTP].includes(e.type)},get datasource(){const{key:t,type:n}=e;return D.getRoot(e).datasources.find({type:n,key:t})}})).views(e=>({get stateMessage(){if(e.state!=="idle")return"";if(!e.runByConditionsMet){const{context:t,filters:n}=e.conditionNames;if(t.length===0&&n.length===0)return"Waiting";const r=[];return t.length>0&&r.push(`context: ${t.join(", ")}`),n.length>0&&r.push(`filter${n.length>1?"s":""}: ${n.join(", ")}`),r.length===2&&r.splice(1,0,"and"),r.unshift("Waiting for"),r.join(" ")}return e.data.length>0?"":"Empty Data"}})).volatile(()=>({controller:new AbortController})).actions(e=>({runSQL:D.flow(function*(){var t;if(!!e.valid&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{context:n,mock_context:r,sqlSnippets:i,filterValues:o}=D.getRoot(e).payloadForSQL;e.data=yield*D.toGenerator(xz({context:n,mock_context:r,sqlSnippets:i,title:e.name,query:e.json,filterValues:o},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(!Vo.default.isCancel(n)){e.data.length=0;const r=H.get(n,"message","unkown error");e.error=H.get(n,"response.data.detail.message",r),e.state="error"}}}}),runHTTP:D.flow(function*(){var t;if(console.log("runHTTP, ",e.datasource),!(!e.valid||!e.datasource)&&((t=e.controller)==null||t.abort(),!!e.runByConditionsMet)){e.controller=new AbortController,e.state="loading";try{const{context:n,mock_context:r,filterValues:i}=D.getRoot(e).payloadForSQL;e.data=yield*D.toGenerator(Sz({context:n,mock_context:r,query:e.json,filterValues:i,datasource:e.datasource},e.controller.signal)),e.state="idle",e.error=null}catch(n){if(console.error(n),!Vo.default.isCancel(n)){e.data.length=0;const r=H.get(n,"message","unkown error");e.error=H.get(n,"response.data.detail.message",r),e.state="error"}}}})})).actions(e=>({fetchData:e.typedAsHTTP?e.runHTTP:e.runSQL,beforeDestroy(){var t;(t=e.controller)==null||t.abort()}})).actions(e=>({afterCreate(){D.addDisposer(e,Ft.reaction(()=>{var t;return e.typedAsHTTP?`${e.id}--${e.key}--${e.pre_process}--${e.post_process}--${(t=e.datasource)==null?void 0:t.id}`:`${e.id}--${e.key}--${e.formattedSQL}`},e.fetchData,{fireImmediately:!0,delay:0}))}})),ym=D.types.model("QueriesModel",{current:D.types.optional(D.types.array(mm),[])}).views(e=>({get firstID(){if(e.current.length!==0)return e.current[0].id},findByID(t){return e.current.find(n=>n.id===t)},get options(){return e.current.map(t=>({value:t.id,label:t.name,_type:"query"}))}})).views(e=>({get json(){return e.current.filter(t=>t.id).map(t=>t.json)}})).actions(e=>({replace(t){e.current=D.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},downloadAllData(){const t=e.current.map(({name:n,data:r})=>({id:n,data:r.toJSON()}));pz(t)},downloadDataByQueryID(t){const n=e.findByID(t);if(!n){console.log("[downloadDataByQueryID] query not found");return}const{name:r,data:i}=n,o=gm(i);dz(r,o)},refetchDataByQueryID(t){const n=e.findByID(t);if(!n){console.error(new Error(`[downloadDataByQueryID] query by ID[${t}] not found`));return}return n.fetchData()},removeQuery(t){const n=e.current.find(r=>r.id===t);n&&(D.detach(n),e.current.remove(n))}})),bm=D.types.model("SQLSnippetModel",{key:D.types.string,value:D.types.string}).views(e=>({get json(){const{key:t,value:n}=e;return{key:t,value:n}},isADuplicatedKey(t){return!t||t===e.key?!1:!!D.getParent(e,2).findByKey(t)}})).actions(e=>({setKey(t){e.key=t},setValue(t){e.value=t}})),wm=D.types.model("SQLSnippetsModel",{current:D.types.optional(D.types.array(bm),[])}).views(e=>({get json(){return e.current.map(t=>t.json)},get options(){return e.current.map(t=>({label:t.key,value:t.key,_type:"sql_snippet"}))},get record(){return e.current.reduce((t,n)=>(t[n.key]=n.value,t),{})},get firstKey(){if(e.current.length!==0)return e.current[0].key},findByKey(t){return e.current.find(n=>n.key===t)}})).actions(e=>({replace(t){e.current=D.cast(t)},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByKey(t){const n=e.current.findIndex(r=>r.key===t);n>=0&&e.current.splice(n,1)},replaceByIndex(t,n){e.current.splice(t,1,n)}})),xm=D.types.model("ContextModel",{current:D.types.optional(D.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}})),_z=D.types.model("DataSourcesModel",{list:D.types.optional(D.types.frozen(),[])}).views(e=>({find({type:t,key:n}){return e.list.find(r=>r.key===n&&r.type===t)},get options(){return e.list.map(t=>({value:t.key,label:t.key}))}})).actions(e=>({replace(t){e.list=t}}));function Za(e){return{label:e,value:e,_type:"ACTION",_action_type:e,Icon:null,children:null}}function Ez(e){switch(e._type){case"GROUP":case"ACTION":return null;case"global_variables":return["_GLOBAL_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 Tz=D.types.model("EditorModel",{path:D.types.optional(D.types.frozen(),[]),settings_open:D.types.optional(D.types.boolean,!1)}).views(e=>({get navOptions(){const{filters:t,views:n,sqlSnippets:r,queries:i}=D.getRoot(e);return[{label:"Global Variables",value:"_GLOBAL_VARS_",_type:"global_variables",Icon:_I},{label:"Mock Context",value:"_MOCK_CONTEXT_",Icon:rI,_type:"mock_context"},{label:"Filters",value:"_FILTERS_",Icon:pv,children:[...t.options,Za("_Add_A_Filter_")],_type:"GROUP"},{label:"SQL Snipepts",value:"_SQL_SNIPPETS_",Icon:sI,children:[...r.options,Za("_Add_A_SQL_SNIPPET_")],_type:"GROUP"},{label:"Queries",value:"_QUERIES_",Icon:fv,children:[...i.options,Za("_Add_A_QUERY_")],_type:"GROUP"},{label:"Views",value:"_VIEWS_",Icon:YP,children:[...n.editorOptions,Za("_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=Ez(t);n&&e.setPath(n)}})),Mz=D.types.model("MockContextModel",{current:D.types.optional(D.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}})),Sm=D.types.model("ViewModel_Division",{_name:D.types.literal(rt.Division)}).views(e=>({get json(){const{_name:t}=e;return{_name:t}}})).actions(e=>({})),kz=()=>Sm.create({_name:rt.Division}),Qu={enabled:!1,func_content:["function text({ filters, context}) {"," // your code goes here",' return "text"',"}"].join(`
249
- `)},Oz=D.types.model("CustomModalTitleModel",{enabled:D.types.optional(D.types.boolean,!1),func_content:D.types.optional(D.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:n}=e;return{enabled:t,func_content:n}},get value(){const{enabled:t,func_content:n}=e,r=D.getParent(e,2),i=D.getRoot(e);if(!t)return r.name;try{const o={filters:i.filters.values,context:i.context.current};return new Function(`return ${n}`)()(o)}catch(o){return console.error(o),r.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:n}){e.enabled=t,e.func_content=n}})),Cm=D.types.model("ViewModel_Modal",{_name:D.types.literal(rt.Modal),width:D.types.string,height:D.types.string,custom_modal_title:D.types.optional(Oz,Qu)}).views(e=>({get json(){const{_name:t,width:n,height:r,custom_modal_title:i}=e;return{_name:t,width:n,height:r,custom_modal_title:i.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),Dz=()=>Cm.create({_name:rt.Modal,width:"90vw",height:"90vh"}),Rz=D.types.model("PanelLayoutModel",{x:D.types.number,y:D.types.number,w:D.types.number,h:D.types.number,moved:D.types.optional(D.types.boolean,!1),static:D.types.optional(D.types.boolean,!1)}).views(e=>({get json(){const{x:t,y:n,w:r,h:i,moved:o}=e;return{h:i,w:r,x:t,y:n,moved:o,static:e.static}}})).actions(e=>({set(t){const{x:n,y:r,w:i,h:o,moved:a}=t;e.x=n,e.y=r,e.w=i,e.h=o,e.moved=!!a,e.static=!!t.static}})),Az=D.types.model("PanelStyleBorderModel",{enabled:D.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),Pz=D.types.model("PanelStyleModel",{border:Az}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),Iz=D.types.model("PanelVizModel",{type:D.types.string,conf:D.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}})),Nz=D.types.model("VariableModel",{name:D.types.string,size:D.types.string,weight:D.types.string,color:D.types.union(D.types.model({type:D.types.literal("static"),staticColor:D.types.string}),D.types.model({type:D.types.literal("continuous"),valueRange:D.types.array(D.types.number),colorRange:D.types.array(D.types.string)}),D.types.model({type:D.types.literal("piecewise")})),formatter:D.types.model({output:D.types.enumeration("Output",["number","percent"]),mantissa:D.types.number,average:D.types.optional(D.types.boolean,!1),trimMantissa:D.types.optional(D.types.boolean,!1)}),data_field:D.types.string,aggregation:D.types.union(D.types.model({type:D.types.enumeration(["none","sum","mean","median","min","max"]),config:D.types.frozen()}),D.types.model({type:D.types.literal("quantile"),config:D.types.model({p:D.types.number})}))}).views(e=>({get json(){return D.getSnapshot(e)}}));class $z{constructor(t){Re(this,"origin");Re(this,"copy");this.origin=t,this.copy=D.clone(t),Ft.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!H.isEqual(D.getSnapshot(this.origin),D.getSnapshot(this.copy))}commit(){D.applySnapshot(this.origin,D.getSnapshot(this.copy))}update(t){D.applySnapshot(this.copy,t)}}const Lz=e=>new $z(e),Vz=D.types.model({id:D.types.string,title:D.types.string,description:D.types.string,layout:Rz,queryID:D.types.string,viz:Iz,style:Pz,variables:D.types.optional(D.types.array(Nz),[])}).views(e=>({get query(){return D.getParentOfType(e,Ja).queries.findByID(e.queryID)},get json(){const{id:t,title:n,description:r,queryID:i}=e;return{id:t,viz:e.viz.json,style:e.style.json,title:n,layout:e.layout.json,queryID:i,variables:e.variables.map(o=>o.json),description:r}}})).actions(e=>({setID(t){e.id=t},setTitle(t){e.title=t},setDescription(t){e.description=t},setQueryID(t){if(D.getParentOfType(e,Ja).queries.findByID(t))e.queryID=t;else throw new Error(`Query with id ${t} does not exist`)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)},removeSelf(){D.getParent(e,2).removeByID(e.id)}})),zz=D.types.model("PanelsModel",{list:D.types.optional(D.types.array(Vz),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},get layouts(){return e.list.map(t=>({...t.layout.json,i:t.id}))},findByID(t){return e.list.find(n=>n.id===t)},get editorOptions(){const t=D.getParent(e,1).id,n=e.list.map(i=>({label:i.title?i.title:fe.default.capitalize(i.viz.type),value:i.id,_type:"panel",parentID:t})),r="_Add_A_PANEL_";return n.push({label:r,value:r,_type:"ACTION",_action_type:r,parentID:t,Icon:null,children:null}),n}})).actions(e=>({replace(t){e.list=D.castToSnapshot(t)},addANewPanel(){const t=new Date().getTime().toString();e.list.push({id:t,layout:{x:0,y:1/0,w:3,h:15},title:t,description:"<p></p>",queryID:"",viz:{type:Vu.name,conf:Vu.createConfig()},style:{border:{enabled:!0}}})},append(t){e.list.push(t)},remove(t){e.list.splice(t,1)},removeByID(t){const n=e.list.findIndex(r=>r.id===t);n!==-1&&e.list.splice(n,1)},duplicateByID(t){const n=e.list.find(r=>r.id===t);if(!n){console.error(new Error(`[duplicate panel] Can't find a panel by id[${t}]`));return}e.list.push({...n.json,id:Ut.randomId(),layout:{...n.layout,y:1/0,moved:!1}})},replaceByIndex(t,n){e.list.splice(t,1,n)}})),Fz=D.types.model("ViewModel_Tabs_Tab",{id:D.types.identifier,name:D.types.string,view_id:D.types.string,color:D.types.optional(D.types.string,"")}).views(e=>({get json(){const{id:t,name:n,view_id:r,color:i}=e;return{id:t,name:n,view_id:r,color:i}}})).actions(e=>({setName(t){e.name=t},setViewID(t){e.view_id=t},setColor(t){e.color=t}})),_m=D.types.model("ViewModel_Tabs",{_name:D.types.literal(rt.Modal),tabs:D.types.optional(D.types.array(Fz),[]),variant:D.types.optional(D.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:D.types.optional(D.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:D.types.optional(D.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:n,orientation:r,tabs:i,grow:o}=e;return{_name:t,variant:n,orientation:r,grow:o,tabs:i.map(a=>a.json)}}})).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=D.cast(t)},addTab(){const t=Ut.randomId(),n={id:t,name:t,view_id:""};e.tabs.push(n)},removeTab(t){e.tabs.splice(t,1)}})),Bz=()=>_m.create({_name:rt.Modal,tabs:[]}),Em=D.types.model({id:D.types.identifier,name:D.types.string,type:D.types.enumeration("EViewComponentType",[rt.Division,rt.Modal,rt.Tabs]),config:D.types.union(Sm,Cm,_m),panels:zz}).views(e=>({get json(){const{id:t,name:n,type:r,config:i}=e;return{id:t,name:n,type:r,config:i.json,panels:e.panels.json}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case rt.Division:e.config=kz();break;case rt.Modal:e.config=Dz();break;case rt.Tabs:e.config=Bz();break}e.type=t}}})).actions(e=>({})),Tm=D.types.model("ViewsModel",{current:D.types.optional(D.types.array(Em),[]),visibleViewIDs:D.types.array(D.types.string),idOfVIE:D.types.string}).views(e=>({get json(){return e.current.map(t=>t.json)},findByID(t){return e.current.find(n=>n.id===t)},get isVIETheFirstView(){return e.current.length===0||!e.idOfVIE?!1:e.current[0].id===e.idOfVIE},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:n})=>n===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:n})=>t.has(n))},get VIE(){return e.current.find(({id:t})=>t===e.idOfVIE)},get options(){return e.current.map(t=>({label:t.name,value:t.id,type:t.type}))},get editorOptions(){return e.current.map(t=>({label:t.name,value:t.id,_type:"view",children:t.panels.editorOptions}))}})).actions(e=>({replace(t){e.current.replace(t)},addANewView(t,n,r,i){e.current.push({id:t,name:n,type:r,config:i,panels:{list:[]}})},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(r=>r.id===t);n!==-1&&e.current.splice(n,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},setIDOfVIE(t){e.idOfVIE=t,e.visibleViewIDs.length=0,e.visibleViewIDs.push(t)},addAPanelToVIE(){var t;(t=e.VIE)==null||t.panels.addANewPanel()},appendToVisibles(t){new Set(e.visibleViewIDs.map(r=>r)).has(t)||e.visibleViewIDs.push(t)}})).actions(e=>({addARandomNewView(){const t=new Date().getTime().toString();e.addANewView(t,rt.Division,rt.Division,{_name:rt.Division}),e.setIDOfVIE(t)},removeVIE(){e.current.length!==1&&(e.removeByID(e.idOfVIE),e.setIDOfVIE(e.current[0].id))},rmVisibleViewID(t){const n=e.visibleViewIDs.findIndex(r=>r===t);n!==-1&&e.visibleViewIDs.splice(n,1)}}));function Mm(e){const t=e.length>0?[e[0].id]:[],n=e.length>0?e[0].id:"";return{current:e.map(i=>{const{_name:o=i.type}=i.config;return{...i,config:{...i.config,_name:o},panels:{list:i.panels}}}),visibleViewIDs:t,idOfVIE:n}}const jz=D.types.model({id:D.types.identifier,name:D.types.string,version:D.types.string,datasources:_z,filters:pm,queries:ym,sqlSnippets:wm,views:Tm,context:xm,mock_context:Mz,editor:Tz,origin:D.types.maybe(D.types.frozen())}).views(e=>({get filtersChanged(){const t="filters.current";return!H.isEqual(D.getSnapshot(H.get(e,t)),H.get(e.origin,t))},get queriesChanged(){const t="queries.current",n=D.getSnapshot(H.get(e,t)).map(r=>H.pick(r,["id","name","key","type","sql","run_by","pre_process","post_process"]));return!H.isEqual(n,H.get(e.origin,t))},get sqlSnippetsChanged(){const t="sqlSnippets.current";return!H.isEqual(D.getSnapshot(H.get(e,t)),H.get(e.origin,t))},get viewsChanged(){const t="views.current";return!H.isEqual(D.getSnapshot(H.get(e,t)),H.get(e.origin,t))},get mockContextChanged(){const t="mock_context.current";return!H.isEqual(H.get(e,t),H.get(e.origin,t))}})).views(e=>({get payloadForSQL(){return{context:e.context.current,mock_context:e.mock_context.current,sqlSnippets:e.sqlSnippets.current,filterValues:e.filters.values}},get changed(){return e.filtersChanged||e.queriesChanged||e.sqlSnippetsChanged||e.viewsChanged||e.mockContextChanged},get data(){return e.queries.current.map(({id:n,data:r})=>({id:n,data:r})).reduce((n,r)=>(n[r.id]=r.data,n),{})},getDataStuffByID(t){const n=e.queries.findByID(t);return n?{data:n.data.toJSON(),dataProxy:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],dataProxy:null,len:0,state:"idle",error:void 0}},getDataStateByID(t){var n,r;return(r=(n=e.queries.findByID(t))==null?void 0:n.state)!=null?r:[]},getDataErrorByID(t){var n,r;return(r=(n=e.queries.findByID(t))==null?void 0:n.error)!=null?r:[]}})).views(e=>({findQueryUsage(t){const n=e.views.current.flatMap(i=>i.panels.list.filter(o=>o.queryID===t).map(o=>({type:"panel",id:o.id,label:o.title?o.title:o.viz.type,viewID:i.id}))),r=e.filters.current.filter(i=>fe.default.get(i,"config.options_query_id")===t).map(i=>({type:"filter",id:i.id,label:i.label}));return n.concat(r)}})).actions(e=>({reset(){D.applySnapshot(e.filters.current,e.origin.filters.current),D.applySnapshot(e.queries.current,e.origin.queries.current),D.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),D.applySnapshot(e.views.current,e.origin.views.current),e.mock_context.current=e.origin.mock_context.current},resetFilters(){D.applySnapshot(e.filters.current,e.origin.filters.current)}})),Ja=D.types.snapshotProcessor(jz,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=D.castToSnapshot(e.queries.current.map(n=>H.pick(n,["id","key","type","sql"])));return H.defaults({},{queries:{current:t}},e)}});function Zu({id:e,name:t,version:n,filters:r,views:i,definition:{queries:o,sqlSnippets:a,mock_context:s={}}},u,c){return Ja.create({id:e,name:t,version:n,datasources:{list:u},filters:hm(r),queries:{current:o},sqlSnippets:{current:a},context:{current:c},mock_context:{current:s},views:Mm(i),editor:{}})}function Ju(e){return Z.default.useCallback(t=>t.provideValue(Lt.pluginManager,e.pluginManager).provideValue(Lt.vizManager,e.vizManager).provideValue(Lt.colorManager,e.colorManager),[])}const A6="";var km;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(km||(km={})),process.env.NODE_ENV;function Om(e){var t={};if(e){var n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));var r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}/**
249
+ `)},Oz=D.types.model("CustomModalTitleModel",{enabled:D.types.optional(D.types.boolean,!1),func_content:D.types.optional(D.types.string,"")}).views(e=>({get json(){const{enabled:t,func_content:n}=e;return{enabled:t,func_content:n}},get value(){const{enabled:t,func_content:n}=e,r=D.getParent(e,2),i=D.getRoot(e);if(!t)return r.name;try{const o={filters:i.filters.values,context:i.context.current};return new Function(`return ${n}`)()(o)}catch(o){return console.error(o),r.name}}})).actions(e=>({setEnabled(t){e.enabled=t},setFuncContent(t){e.func_content=t},replace({enabled:t,func_content:n}){e.enabled=t,e.func_content=n}})),Cm=D.types.model("ViewModel_Modal",{_name:D.types.literal(rt.Modal),width:D.types.string,height:D.types.string,custom_modal_title:D.types.optional(Oz,Qu)}).views(e=>({get json(){const{_name:t,width:n,height:r,custom_modal_title:i}=e;return{_name:t,width:n,height:r,custom_modal_title:i.json}}})).actions(e=>({setWidth(t){e.width=t},setHeight(t){e.height=t}})),Dz=()=>Cm.create({_name:rt.Modal,width:"90vw",height:"90vh"}),Rz=D.types.model("PanelLayoutModel",{x:D.types.number,y:D.types.number,w:D.types.number,h:D.types.number,moved:D.types.optional(D.types.boolean,!1),static:D.types.optional(D.types.boolean,!1)}).views(e=>({get json(){const{x:t,y:n,w:r,h:i,moved:o}=e;return{h:i,w:r,x:t,y:n,moved:o,static:e.static}}})).actions(e=>({set(t){const{x:n,y:r,w:i,h:o,moved:a}=t;e.x=n,e.y=r,e.w=i,e.h=o,e.moved=!!a,e.static=!!t.static}})),Az=D.types.model("PanelStyleBorderModel",{enabled:D.types.boolean}).views(e=>({get json(){const{enabled:t}=e;return{enabled:t}}})).actions(e=>({setEnabled(t){e.enabled=t}})),Pz=D.types.model("PanelStyleModel",{border:Az}).views(e=>({get json(){const{border:t}=e;return{border:t.json}}})).actions(e=>({})),Iz=D.types.model("PanelVizModel",{type:D.types.string,conf:D.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}})),Nz=D.types.model("VariableModel",{name:D.types.string,size:D.types.string,weight:D.types.string,color:D.types.union(D.types.model({type:D.types.literal("static"),staticColor:D.types.string}),D.types.model({type:D.types.literal("continuous"),valueRange:D.types.array(D.types.number),colorRange:D.types.array(D.types.string)}),D.types.model({type:D.types.literal("piecewise")})),formatter:D.types.model({output:D.types.enumeration("Output",["number","percent"]),mantissa:D.types.number,average:D.types.optional(D.types.boolean,!1),trimMantissa:D.types.optional(D.types.boolean,!1)}),data_field:D.types.string,aggregation:D.types.union(D.types.model({type:D.types.enumeration(["none","sum","mean","median","min","max"]),config:D.types.frozen()}),D.types.model({type:D.types.literal("quantile"),config:D.types.model({p:D.types.number})}))}).views(e=>({get json(){return D.getSnapshot(e)}}));class $z{constructor(t){Re(this,"origin");Re(this,"copy");this.origin=t,this.copy=D.clone(t),Ft.makeAutoObservable(this,{},{autoBind:!0,deep:!1})}get changed(){return!H.isEqual(D.getSnapshot(this.origin),D.getSnapshot(this.copy))}commit(){D.applySnapshot(this.origin,D.getSnapshot(this.copy))}update(t){D.applySnapshot(this.copy,t)}}const Lz=e=>new $z(e),Vz=D.types.model({id:D.types.string,title:D.types.string,description:D.types.string,layout:Rz,queryID:D.types.string,viz:Iz,style:Pz,variables:D.types.optional(D.types.array(Nz),[])}).views(e=>({get query(){return D.getParentOfType(e,Ja).queries.findByID(e.queryID)},get json(){const{id:t,title:n,description:r,queryID:i}=e;return{id:t,viz:e.viz.json,style:e.style.json,title:n,layout:e.layout.json,queryID:i,variables:e.variables.map(o=>o.json),description:r}}})).actions(e=>({setID(t){e.id=t},setTitle(t){e.title=t},setDescription(t){e.description=t},setQueryID(t){if(D.getParentOfType(e,Ja).queries.findByID(t))e.queryID=t;else throw new Error(`Query with id ${t} does not exist`)},addVariable(t){e.variables.push(t)},removeVariable(t){e.variables.remove(t)},removeSelf(){D.getParent(e,2).removeByID(e.id)}})),zz=D.types.model("PanelsModel",{list:D.types.optional(D.types.array(Vz),[])}).views(e=>({get json(){return e.list.map(t=>t.json)},get layouts(){return e.list.map(t=>({...t.layout.json,i:t.id}))},findByID(t){return e.list.find(n=>n.id===t)},get editorOptions(){const t=D.getParent(e,1).id,n=e.list.map(i=>({label:i.title?i.title:fe.default.capitalize(i.viz.type),value:i.id,_type:"panel",parentID:t})),r="_Add_A_PANEL_";return n.push({label:r,value:r,_type:"ACTION",_action_type:r,parentID:t,Icon:null,children:null}),n}})).actions(e=>({replace(t){e.list=D.castToSnapshot(t)},addANewPanel(){const t=new Date().getTime().toString();e.list.push({id:t,layout:{x:0,y:1/0,w:3,h:15},title:t,description:"<p></p>",queryID:"",viz:{type:Vu.name,conf:Vu.createConfig()},style:{border:{enabled:!0}}})},append(t){e.list.push(t)},remove(t){e.list.splice(t,1)},removeByID(t){const n=e.list.findIndex(r=>r.id===t);n!==-1&&e.list.splice(n,1)},duplicateByID(t){const n=e.list.find(r=>r.id===t);if(!n){console.error(new Error(`[duplicate panel] Can't find a panel by id[${t}]`));return}e.list.push({...n.json,id:Ut.randomId(),layout:{...n.layout,y:1/0,moved:!1}})},replaceByIndex(t,n){e.list.splice(t,1,n)}})),Fz=D.types.model("ViewModel_Tabs_Tab",{id:D.types.identifier,name:D.types.string,view_id:D.types.string,color:D.types.optional(D.types.string,"")}).views(e=>({get json(){const{id:t,name:n,view_id:r,color:i}=e;return{id:t,name:n,view_id:r,color:i}}})).actions(e=>({setName(t){e.name=t},setViewID(t){e.view_id=t},setColor(t){e.color=t}})),_m=D.types.model("ViewModel_Tabs",{_name:D.types.literal(rt.Modal),tabs:D.types.optional(D.types.array(Fz),[]),variant:D.types.optional(D.types.enumeration("variant",["default","outline","pills"]),"default"),orientation:D.types.optional(D.types.enumeration("orientation",["horizontal","vertical"]),"horizontal"),grow:D.types.optional(D.types.boolean,!1)}).views(e=>({get json(){const{_name:t,variant:n,orientation:r,tabs:i,grow:o}=e;return{_name:t,variant:n,orientation:r,grow:o,tabs:i.map(a=>a.json)}}})).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=D.cast(t)},addTab(){const t=Ut.randomId(),n={id:t,name:t,view_id:""};e.tabs.push(n)},removeTab(t){e.tabs.splice(t,1)}})),Bz=()=>_m.create({_name:rt.Modal,tabs:[]}),Em=D.types.model({id:D.types.identifier,name:D.types.string,type:D.types.enumeration("EViewComponentType",[rt.Division,rt.Modal,rt.Tabs]),config:D.types.union(Sm,Cm,_m),panels:zz}).views(e=>({get json(){const{id:t,name:n,type:r,config:i}=e;return{id:t,name:n,type:r,config:i.json,panels:e.panels.json}}})).actions(e=>({setName(t){e.name=t},setType(t){if(e.type!==t){switch(t){case rt.Division:e.config=kz();break;case rt.Modal:e.config=Dz();break;case rt.Tabs:e.config=Bz();break}e.type=t}}})).actions(e=>({})),Tm=D.types.model("ViewsModel",{current:D.types.optional(D.types.array(Em),[]),visibleViewIDs:D.types.array(D.types.string),idOfVIE:D.types.string}).views(e=>({get json(){return e.current.map(t=>t.json)},findByID(t){return e.current.find(n=>n.id===t)},get isVIETheFirstView(){return e.current.length===0||!e.idOfVIE?!1:e.current[0].id===e.idOfVIE},get firstVisibleView(){const[t]=e.visibleViewIDs;return e.current.find(({id:n})=>n===t)},get visibleViews(){const t=new Set(e.visibleViewIDs);return e.current.filter(({id:n})=>t.has(n))},get VIE(){return e.current.find(({id:t})=>t===e.idOfVIE)},get options(){return e.current.map(t=>({label:t.name,value:t.id,type:t.type}))},get editorOptions(){return e.current.map(t=>({label:t.name,value:t.id,_type:"view",children:t.panels.editorOptions}))}})).actions(e=>({replace(t){e.current.replace(t)},addANewView(t,n,r,i){e.current.push({id:t,name:n,type:r,config:i,panels:{list:[]}})},append(t){e.current.push(t)},remove(t){e.current.splice(t,1)},removeByID(t){const n=e.current.findIndex(r=>r.id===t);n!==-1&&e.current.splice(n,1)},replaceByIndex(t,n){e.current.splice(t,1,n)},setIDOfVIE(t){e.idOfVIE=t,e.visibleViewIDs.length=0,e.visibleViewIDs.push(t)},addAPanelToVIE(){var t;(t=e.VIE)==null||t.panels.addANewPanel()},appendToVisibles(t){new Set(e.visibleViewIDs.map(r=>r)).has(t)||e.visibleViewIDs.push(t)}})).actions(e=>({addARandomNewView(){const t=new Date().getTime().toString();e.addANewView(t,rt.Division,rt.Division,{_name:rt.Division}),e.setIDOfVIE(t)},removeVIE(){e.current.length!==1&&(e.removeByID(e.idOfVIE),e.setIDOfVIE(e.current[0].id))},rmVisibleViewID(t){const n=e.visibleViewIDs.findIndex(r=>r===t);n!==-1&&e.visibleViewIDs.splice(n,1)}}));function Mm(e){const t=e.length>0?[e[0].id]:[],n=e.length>0?e[0].id:"";return{current:e.map(i=>{const{_name:o=i.type}=i.config;return{...i,config:{...i.config,_name:o},panels:{list:i.panels}}}),visibleViewIDs:t,idOfVIE:n}}const jz=D.types.model({id:D.types.identifier,name:D.types.string,version:D.types.string,datasources:_z,filters:pm,queries:ym,sqlSnippets:wm,views:Tm,context:xm,mock_context:Mz,editor:Tz,origin:D.types.maybe(D.types.frozen())}).views(e=>({get filtersChanged(){const t="filters.current";return!H.isEqual(D.getSnapshot(H.get(e,t)),H.get(e.origin,t))},get queriesChanged(){const t="queries.current",n=D.getSnapshot(H.get(e,t)).map(r=>H.pick(r,["id","name","key","type","sql","run_by","pre_process","post_process"]));return!H.isEqual(n,H.get(e.origin,t))},get sqlSnippetsChanged(){const t="sqlSnippets.current";return!H.isEqual(D.getSnapshot(H.get(e,t)),H.get(e.origin,t))},get viewsChanged(){const t="views.current";return!H.isEqual(D.getSnapshot(H.get(e,t)),H.get(e.origin,t))},get mockContextChanged(){const t="mock_context.current";return!H.isEqual(H.get(e,t),H.get(e.origin,t))}})).views(e=>({get payloadForSQL(){return{context:e.context.current,mock_context:e.mock_context.current,sqlSnippets:e.sqlSnippets.current,filterValues:e.filters.values}},get changed(){return e.filtersChanged||e.queriesChanged||e.sqlSnippetsChanged||e.viewsChanged||e.mockContextChanged},get data(){return e.queries.current.map(({id:n,data:r})=>({id:n,data:r})).reduce((n,r)=>(n[r.id]=r.data,n),{})},getDataStuffByID(t){const n=e.queries.findByID(t);return n?{data:n.data.toJSON(),dataProxy:n.data,len:n.data.length,state:n.state,error:n.error}:{data:[],dataProxy:null,len:0,state:"idle",error:void 0}},getDataStateByID(t){var n,r;return(r=(n=e.queries.findByID(t))==null?void 0:n.state)!=null?r:[]},getDataErrorByID(t){var n,r;return(r=(n=e.queries.findByID(t))==null?void 0:n.error)!=null?r:[]}})).views(e=>({findQueryUsage(t){const n=e.views.current.flatMap(i=>i.panels.list.filter(o=>o.queryID===t).map(o=>({type:"panel",id:o.id,label:o.title?o.title:o.viz.type,viewID:i.id}))),r=e.filters.current.filter(i=>fe.default.get(i,"config.options_query_id")===t).map(i=>({type:"filter",id:i.id,label:i.label}));return n.concat(r)}})).actions(e=>({reset(){D.applySnapshot(e.filters.current,e.origin.filters.current),D.applySnapshot(e.queries.current,e.origin.queries.current),D.applySnapshot(e.sqlSnippets.current,e.origin.sqlSnippets.current),D.applySnapshot(e.views.current,e.origin.views.current),e.mock_context.current=e.origin.mock_context.current},resetFilters(){D.applySnapshot(e.filters.current,e.origin.filters.current)}})),Ja=D.types.snapshotProcessor(jz,{preProcessor(e){return{...e,origin:e}},postProcessor(e){delete e.origin;const t=D.castToSnapshot(e.queries.current.map(n=>H.pick(n,["id","key","type","sql"])));return H.defaults({},{queries:{current:t}},e)}});function Zu({id:e,name:t,version:n,filters:r,views:i,definition:{queries:o,sqlSnippets:a,mock_context:s={}}},u,c){return Ja.create({id:e,name:t,version:n,datasources:{list:u},filters:hm(r),queries:{current:o},sqlSnippets:{current:a},context:{current:c},mock_context:{current:s},views:Mm(i),editor:{}})}function Ju(e){return Z.default.useCallback(t=>t.provideValue(Lt.pluginManager,e.pluginManager).provideValue(Lt.vizManager,e.vizManager).provideValue(Lt.colorManager,e.colorManager),[])}const P6="";var km;(function(e){e.Pop="POP",e.Push="PUSH",e.Replace="REPLACE"})(km||(km={})),process.env.NODE_ENV;function Om(e){var t={};if(e){var n=e.indexOf("#");n>=0&&(t.hash=e.substr(n),e=e.substr(0,n));var r=e.indexOf("?");r>=0&&(t.search=e.substr(r),e=e.substr(0,r)),e&&(t.pathname=e)}return t}/**
250
250
  * React Router v6.3.0
251
251
  *
252
252
  * Copyright (c) Remix Software Inc.
@@ -288,7 +288,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
288
288
  * This source code is licensed under the MIT license found in the
289
289
  * LICENSE file in the root directory of this source tree.
290
290
  */var Bm;function rF(){return Bm||(Bm=1,process.env.NODE_ENV!=="production"&&function(){typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error);var e=Z.default,t=zm();function n(f,h){return f===h&&(f!==0||1/f===1/h)||f!==f&&h!==h}var r=typeof Object.is=="function"?Object.is:n,i=t.useSyncExternalStore,o=e.useRef,a=e.useEffect,s=e.useMemo,u=e.useDebugValue;function c(f,h,p,g,v){var m=o(null),w;m.current===null?(w={hasValue:!1,value:null},m.current=w):w=m.current;var b=s(function(){var E=!1,k,A,L=function(N){if(!E){E=!0,k=N;var z=g(N);if(v!==void 0&&w.hasValue){var M=w.value;if(v(M,z))return A=M,M}return A=z,z}var $=k,I=A;if(r($,N))return I;var R=g(N);return v!==void 0&&v(I,R)?I:(k=N,A=R,R)},F=p===void 0?null:p,P=function(){return L(h())},O=F===null?void 0:function(){return L(F())};return[P,O]},[h,p,g,v]),_=b[0],C=b[1],S=i(f,_,C);return a(function(){w.hasValue=!0,w.value=S},[S]),u(S),S}oc.useSyncExternalStoreWithSelector=c,typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop=="function"&&__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error)}()),oc}(function(e){process.env.NODE_ENV==="production"?e.exports=nF():e.exports=rF()})(Nm);const iF=M0(Nm.exports),{useSyncExternalStoreWithSelector:oF}=iF;function aF(e,t=e.getState,n){const r=oF(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return x.useDebugValue(r),r}function nn(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r<n.length;r++)if(!Object.prototype.hasOwnProperty.call(t,n[r])||!Object.is(e[n[r]],t[n[r]]))return!1;return!0}var sF={value:()=>{}};function ts(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new ns(n)}function ns(e){this._=e}function lF(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}ns.prototype=ts.prototype={constructor:ns,on:function(e,t){var n=this._,r=lF(e+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(e=r[o]).type)&&(i=uF(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<a;)if(i=(e=r[o]).type)n[i]=jm(n[i],e.name,t);else if(t==null)for(i in n)n[i]=jm(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new ns(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function uF(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function jm(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=sF,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var ac="http://www.w3.org/1999/xhtml";const Gm={svg:"http://www.w3.org/2000/svg",xhtml:ac,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function rs(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Gm.hasOwnProperty(t)?{space:Gm[t],local:e}:e}function cF(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ac&&t.documentElement.namespaceURI===ac?t.createElement(e):t.createElementNS(n,e)}}function dF(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function Km(e){var t=rs(e);return(t.local?dF:cF)(t)}function fF(){}function sc(e){return e==null?fF:function(){return this.querySelector(e)}}function pF(e){typeof e!="function"&&(e=sc(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],a=o.length,s=r[i]=new Array(a),u,c,f=0;f<a;++f)(u=o[f])&&(c=e.call(u,u.__data__,f,o))&&("__data__"in u&&(c.__data__=u.__data__),s[f]=c);return new gn(r,this._parents)}function hF(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function gF(){return[]}function Hm(e){return e==null?gF:function(){return this.querySelectorAll(e)}}function vF(e){return function(){return hF(e.apply(this,arguments))}}function mF(e){typeof e=="function"?e=vF(e):e=Hm(e);for(var t=this._groups,n=t.length,r=[],i=[],o=0;o<n;++o)for(var a=t[o],s=a.length,u,c=0;c<s;++c)(u=a[c])&&(r.push(e.call(u,u.__data__,c,a)),i.push(u));return new gn(r,i)}function Wm(e){return function(){return this.matches(e)}}function qm(e){return function(t){return t.matches(e)}}var yF=Array.prototype.find;function bF(e){return function(){return yF.call(this.children,e)}}function wF(){return this.firstElementChild}function xF(e){return this.select(e==null?wF:bF(typeof e=="function"?e:qm(e)))}var SF=Array.prototype.filter;function CF(){return Array.from(this.children)}function _F(e){return function(){return SF.call(this.children,e)}}function EF(e){return this.selectAll(e==null?CF:_F(typeof e=="function"?e:qm(e)))}function TF(e){typeof e!="function"&&(e=Wm(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],a=o.length,s=r[i]=[],u,c=0;c<a;++c)(u=o[c])&&e.call(u,u.__data__,c,o)&&s.push(u);return new gn(r,this._parents)}function Um(e){return new Array(e.length)}function MF(){return new gn(this._enter||this._groups.map(Um),this._parents)}function is(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}is.prototype={constructor:is,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function kF(e){return function(){return e}}function OF(e,t,n,r,i,o){for(var a=0,s,u=t.length,c=o.length;a<c;++a)(s=t[a])?(s.__data__=o[a],r[a]=s):n[a]=new is(e,o[a]);for(;a<u;++a)(s=t[a])&&(i[a]=s)}function DF(e,t,n,r,i,o,a){var s,u,c=new Map,f=t.length,h=o.length,p=new Array(f),g;for(s=0;s<f;++s)(u=t[s])&&(p[s]=g=a.call(u,u.__data__,s,t)+"",c.has(g)?i[s]=u:c.set(g,u));for(s=0;s<h;++s)g=a.call(e,o[s],s,o)+"",(u=c.get(g))?(r[s]=u,u.__data__=o[s],c.delete(g)):n[s]=new is(e,o[s]);for(s=0;s<f;++s)(u=t[s])&&c.get(p[s])===u&&(i[s]=u)}function RF(e){return e.__data__}function AF(e,t){if(!arguments.length)return Array.from(this,RF);var n=t?DF:OF,r=this._parents,i=this._groups;typeof e!="function"&&(e=kF(e));for(var o=i.length,a=new Array(o),s=new Array(o),u=new Array(o),c=0;c<o;++c){var f=r[c],h=i[c],p=h.length,g=PF(e.call(f,f&&f.__data__,c,r)),v=g.length,m=s[c]=new Array(v),w=a[c]=new Array(v),b=u[c]=new Array(p);n(f,h,m,w,b,g,t);for(var _=0,C=0,S,E;_<v;++_)if(S=m[_]){for(_>=C&&(C=_+1);!(E=w[C])&&++C<v;);S._next=E||null}}return a=new gn(a,r),a._enter=s,a._exit=u,a}function PF(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function IF(){return new gn(this._exit||this._groups.map(Um),this._parents)}function NF(e,t,n){var r=this.enter(),i=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}function $F(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,o=r.length,a=Math.min(i,o),s=new Array(i),u=0;u<a;++u)for(var c=n[u],f=r[u],h=c.length,p=s[u]=new Array(h),g,v=0;v<h;++v)(g=c[v]||f[v])&&(p[v]=g);for(;u<i;++u)s[u]=n[u];return new gn(s,this._parents)}function LF(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,o=r[i],a;--i>=0;)(a=r[i])&&(o&&a.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(a,o),o=a);return this}function VF(e){e||(e=zF);function t(h,p){return h&&p?e(h.__data__,p.__data__):!h-!p}for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var a=n[o],s=a.length,u=i[o]=new Array(s),c,f=0;f<s;++f)(c=a[f])&&(u[f]=c);u.sort(t)}return new gn(i,this._parents).order()}function zF(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function FF(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function BF(){return Array.from(this)}function jF(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length;i<o;++i){var a=r[i];if(a)return a}return null}function GF(){let e=0;for(const t of this)++e;return e}function KF(){return!this.node()}function HF(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],o=0,a=i.length,s;o<a;++o)(s=i[o])&&e.call(s,s.__data__,o,i);return this}function WF(e){return function(){this.removeAttribute(e)}}function qF(e){return function(){this.removeAttributeNS(e.space,e.local)}}function UF(e,t){return function(){this.setAttribute(e,t)}}function YF(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function XF(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function QF(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function ZF(e,t){var n=rs(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?qF:WF:typeof t=="function"?n.local?QF:XF:n.local?YF:UF)(n,t))}function Ym(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function JF(e){return function(){this.style.removeProperty(e)}}function e3(e,t,n){return function(){this.style.setProperty(e,t,n)}}function t3(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function n3(e,t,n){return arguments.length>1?this.each((t==null?JF:typeof t=="function"?t3:e3)(e,t,n==null?"":n)):xi(this.node(),e)}function xi(e,t){return e.style.getPropertyValue(t)||Ym(e).getComputedStyle(e,null).getPropertyValue(t)}function r3(e){return function(){delete this[e]}}function i3(e,t){return function(){this[e]=t}}function o3(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function a3(e,t){return arguments.length>1?this.each((t==null?r3:typeof t=="function"?o3:i3)(e,t)):this.node()[e]}function Xm(e){return e.trim().split(/^|\s+/)}function lc(e){return e.classList||new Qm(e)}function Qm(e){this._node=e,this._names=Xm(e.getAttribute("class")||"")}Qm.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Zm(e,t){for(var n=lc(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function Jm(e,t){for(var n=lc(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function s3(e){return function(){Zm(this,e)}}function l3(e){return function(){Jm(this,e)}}function u3(e,t){return function(){(t.apply(this,arguments)?Zm:Jm)(this,e)}}function c3(e,t){var n=Xm(e+"");if(arguments.length<2){for(var r=lc(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?u3:t?s3:l3)(n,t))}function d3(){this.textContent=""}function f3(e){return function(){this.textContent=e}}function p3(e){return function(){var t=e.apply(this,arguments);this.textContent=t==null?"":t}}function h3(e){return arguments.length?this.each(e==null?d3:(typeof e=="function"?p3:f3)(e)):this.node().textContent}function g3(){this.innerHTML=""}function v3(e){return function(){this.innerHTML=e}}function m3(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t==null?"":t}}function y3(e){return arguments.length?this.each(e==null?g3:(typeof e=="function"?m3:v3)(e)):this.node().innerHTML}function b3(){this.nextSibling&&this.parentNode.appendChild(this)}function w3(){return this.each(b3)}function x3(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function S3(){return this.each(x3)}function C3(e){var t=typeof e=="function"?e:Km(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function _3(){return null}function E3(e,t){var n=typeof e=="function"?e:Km(e),r=t==null?_3:typeof t=="function"?t:sc(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function T3(){var e=this.parentNode;e&&e.removeChild(this)}function M3(){return this.each(T3)}function k3(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function O3(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function D3(e){return this.select(e?O3:k3)}function R3(e){return arguments.length?this.property("__data__",e):this.node().__data__}function A3(e){return function(t){e.call(this,t,this.__data__)}}function P3(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function I3(e){return function(){var t=this.__on;if(!!t){for(var n=0,r=-1,i=t.length,o;n<i;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function N3(e,t,n){return function(){var r=this.__on,i,o=A3(t);if(r){for(var a=0,s=r.length;a<s;++a)if((i=r[a]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),i.value=t;return}}this.addEventListener(e.type,o,n),i={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(i):this.__on=[i]}}function $3(e,t,n){var r=P3(e+""),i,o=r.length,a;if(arguments.length<2){var s=this.node().__on;if(s){for(var u=0,c=s.length,f;u<c;++u)for(i=0,f=s[u];i<o;++i)if((a=r[i]).type===f.type&&a.name===f.name)return f.value}return}for(s=t?N3:I3,i=0;i<o;++i)this.each(s(r[i],t,n));return this}function ey(e,t,n){var r=Ym(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function L3(e,t){return function(){return ey(this,e,t)}}function V3(e,t){return function(){return ey(this,e,t.apply(this,arguments))}}function z3(e,t){return this.each((typeof t=="function"?V3:L3)(e,t))}function*F3(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length,a;i<o;++i)(a=r[i])&&(yield a)}var ty=[null];function gn(e,t){this._groups=e,this._parents=t}function vo(){return new gn([[document.documentElement]],ty)}function B3(){return this}gn.prototype=vo.prototype={constructor:gn,select:pF,selectAll:mF,selectChild:xF,selectChildren:EF,filter:TF,data:AF,enter:MF,exit:IF,join:NF,merge:$F,selection:B3,order:LF,sort:VF,call:FF,nodes:BF,node:jF,size:GF,empty:KF,each:HF,attr:ZF,style:n3,property:a3,classed:c3,text:h3,html:y3,raise:w3,lower:S3,append:C3,insert:E3,remove:M3,clone:D3,datum:R3,on:$3,dispatch:z3,[Symbol.iterator]:F3};function Cn(e){return typeof e=="string"?new gn([[document.querySelector(e)]],[document.documentElement]):new gn([[e]],ty)}function j3(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Dn(e,t){if(e=j3(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const G3={passive:!1},mo={capture:!0,passive:!1};function uc(e){e.stopImmediatePropagation()}function Si(e){e.preventDefault(),e.stopImmediatePropagation()}function ny(e){var t=e.document.documentElement,n=Cn(e).on("dragstart.drag",Si,mo);"onselectstart"in t?n.on("selectstart.drag",Si,mo):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function ry(e,t){var n=e.document.documentElement,r=Cn(e).on("dragstart.drag",null);t&&(r.on("click.drag",Si,mo),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const os=e=>()=>e;function cc(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:o,x:a,y:s,dx:u,dy:c,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:f}})}cc.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function K3(e){return!e.ctrlKey&&!e.button}function H3(){return this.parentNode}function W3(e,t){return t==null?{x:e.x,y:e.y}:t}function q3(){return navigator.maxTouchPoints||"ontouchstart"in this}function U3(){var e=K3,t=H3,n=W3,r=q3,i={},o=ts("start","drag","end"),a=0,s,u,c,f,h=0;function p(S){S.on("mousedown.drag",g).filter(r).on("touchstart.drag",w).on("touchmove.drag",b,G3).on("touchend.drag touchcancel.drag",_).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(S,E){if(!(f||!e.call(this,S,E))){var k=C(this,t.call(this,S,E),S,E,"mouse");!k||(Cn(S.view).on("mousemove.drag",v,mo).on("mouseup.drag",m,mo),ny(S.view),uc(S),c=!1,s=S.clientX,u=S.clientY,k("start",S))}}function v(S){if(Si(S),!c){var E=S.clientX-s,k=S.clientY-u;c=E*E+k*k>h}i.mouse("drag",S)}function m(S){Cn(S.view).on("mousemove.drag mouseup.drag",null),ry(S.view,c),Si(S),i.mouse("end",S)}function w(S,E){if(!!e.call(this,S,E)){var k=S.changedTouches,A=t.call(this,S,E),L=k.length,F,P;for(F=0;F<L;++F)(P=C(this,A,S,E,k[F].identifier,k[F]))&&(uc(S),P("start",S,k[F]))}}function b(S){var E=S.changedTouches,k=E.length,A,L;for(A=0;A<k;++A)(L=i[E[A].identifier])&&(Si(S),L("drag",S,E[A]))}function _(S){var E=S.changedTouches,k=E.length,A,L;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),A=0;A<k;++A)(L=i[E[A].identifier])&&(uc(S),L("end",S,E[A]))}function C(S,E,k,A,L,F){var P=o.copy(),O=Dn(F||k,E),N,z,M;if((M=n.call(S,new cc("beforestart",{sourceEvent:k,target:p,identifier:L,active:a,x:O[0],y:O[1],dx:0,dy:0,dispatch:P}),A))!=null)return N=M.x-O[0]||0,z=M.y-O[1]||0,function $(I,R,B){var G=O,K;switch(I){case"start":i[L]=$,K=a++;break;case"end":delete i[L],--a;case"drag":O=Dn(B||R,E),K=a;break}P.call(I,S,new cc(I,{sourceEvent:R,subject:M,target:p,identifier:L,active:K,x:O[0]+N,y:O[1]+z,dx:O[0]-G[0],dy:O[1]-G[1],dispatch:P}),A)}}return p.filter=function(S){return arguments.length?(e=typeof S=="function"?S:os(!!S),p):e},p.container=function(S){return arguments.length?(t=typeof S=="function"?S:os(S),p):t},p.subject=function(S){return arguments.length?(n=typeof S=="function"?S:os(S),p):n},p.touchable=function(S){return arguments.length?(r=typeof S=="function"?S:os(!!S),p):r},p.on=function(){var S=o.on.apply(o,arguments);return S===o?p:S},p.clickDistance=function(S){return arguments.length?(h=(S=+S)*S,p):Math.sqrt(h)},p}function dc(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function iy(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function yo(){}var bo=.7,as=1/bo,Ci="\\s*([+-]?\\d+)\\s*",wo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Fn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Y3=/^#([0-9a-f]{3,8})$/,X3=new RegExp(`^rgb\\(${Ci},${Ci},${Ci}\\)$`),Q3=new RegExp(`^rgb\\(${Fn},${Fn},${Fn}\\)$`),Z3=new RegExp(`^rgba\\(${Ci},${Ci},${Ci},${wo}\\)$`),J3=new RegExp(`^rgba\\(${Fn},${Fn},${Fn},${wo}\\)$`),e4=new RegExp(`^hsl\\(${wo},${Fn},${Fn}\\)$`),t4=new RegExp(`^hsla\\(${wo},${Fn},${Fn},${wo}\\)$`),oy={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};dc(yo,xo,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:ay,formatHex:ay,formatHex8:n4,formatHsl:r4,formatRgb:sy,toString:sy});function ay(){return this.rgb().formatHex()}function n4(){return this.rgb().formatHex8()}function r4(){return fy(this).formatHsl()}function sy(){return this.rgb().formatRgb()}function xo(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=Y3.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ly(t):n===3?new un(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?ss(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?ss(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=X3.exec(e))?new un(t[1],t[2],t[3],1):(t=Q3.exec(e))?new un(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=Z3.exec(e))?ss(t[1],t[2],t[3],t[4]):(t=J3.exec(e))?ss(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=e4.exec(e))?dy(t[1],t[2]/100,t[3]/100,1):(t=t4.exec(e))?dy(t[1],t[2]/100,t[3]/100,t[4]):oy.hasOwnProperty(e)?ly(oy[e]):e==="transparent"?new un(NaN,NaN,NaN,0):null}function ly(e){return new un(e>>16&255,e>>8&255,e&255,1)}function ss(e,t,n,r){return r<=0&&(e=t=n=NaN),new un(e,t,n,r)}function i4(e){return e instanceof yo||(e=xo(e)),e?(e=e.rgb(),new un(e.r,e.g,e.b,e.opacity)):new un}function fc(e,t,n,r){return arguments.length===1?i4(e):new un(e,t,n,r==null?1:r)}function un(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}dc(un,fc,iy(yo,{brighter(e){return e=e==null?as:Math.pow(as,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?bo:Math.pow(bo,e),new un(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new un(Fr(this.r),Fr(this.g),Fr(this.b),ls(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:uy,formatHex:uy,formatHex8:o4,formatRgb:cy,toString:cy}));function uy(){return`#${Br(this.r)}${Br(this.g)}${Br(this.b)}`}function o4(){return`#${Br(this.r)}${Br(this.g)}${Br(this.b)}${Br((isNaN(this.opacity)?1:this.opacity)*255)}`}function cy(){const e=ls(this.opacity);return`${e===1?"rgb(":"rgba("}${Fr(this.r)}, ${Fr(this.g)}, ${Fr(this.b)}${e===1?")":`, ${e})`}`}function ls(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Fr(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Br(e){return e=Fr(e),(e<16?"0":"")+e.toString(16)}function dy(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Rn(e,t,n,r)}function fy(e){if(e instanceof Rn)return new Rn(e.h,e.s,e.l,e.opacity);if(e instanceof yo||(e=xo(e)),!e)return new Rn;if(e instanceof Rn)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),a=NaN,s=o-i,u=(o+i)/2;return s?(t===o?a=(n-r)/s+(n<r)*6:n===o?a=(r-t)/s+2:a=(t-n)/s+4,s/=u<.5?o+i:2-o-i,a*=60):s=u>0&&u<1?0:a,new Rn(a,s,u,e.opacity)}function a4(e,t,n,r){return arguments.length===1?fy(e):new Rn(e,t,n,r==null?1:r)}function Rn(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}dc(Rn,a4,iy(yo,{brighter(e){return e=e==null?as:Math.pow(as,e),new Rn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?bo:Math.pow(bo,e),new Rn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new un(pc(e>=240?e-240:e+120,i,r),pc(e,i,r),pc(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new Rn(py(this.h),us(this.s),us(this.l),ls(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=ls(this.opacity);return`${e===1?"hsl(":"hsla("}${py(this.h)}, ${us(this.s)*100}%, ${us(this.l)*100}%${e===1?")":`, ${e})`}`}}));function py(e){return e=(e||0)%360,e<0?e+360:e}function us(e){return Math.max(0,Math.min(1,e||0))}function pc(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const hy=e=>()=>e;function s4(e,t){return function(n){return e+n*t}}function l4(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function u4(e){return(e=+e)==1?gy:function(t,n){return n-t?l4(t,n,e):hy(isNaN(t)?n:t)}}function gy(e,t){var n=t-e;return n?s4(e,n):hy(isNaN(e)?t:e)}const vy=function e(t){var n=u4(t);function r(i,o){var a=n((i=fc(i)).r,(o=fc(o)).r),s=n(i.g,o.g),u=n(i.b,o.b),c=gy(i.opacity,o.opacity);return function(f){return i.r=a(f),i.g=s(f),i.b=u(f),i.opacity=c(f),i+""}}return r.gamma=e,r}(1);function Cr(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var hc=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,gc=new RegExp(hc.source,"g");function c4(e){return function(){return e}}function d4(e){return function(t){return e(t)+""}}function f4(e,t){var n=hc.lastIndex=gc.lastIndex=0,r,i,o,a=-1,s=[],u=[];for(e=e+"",t=t+"";(r=hc.exec(e))&&(i=gc.exec(t));)(o=i.index)>n&&(o=t.slice(n,o),s[a]?s[a]+=o:s[++a]=o),(r=r[0])===(i=i[0])?s[a]?s[a]+=i:s[++a]=i:(s[++a]=null,u.push({i:a,x:Cr(r,i)})),n=gc.lastIndex;return n<t.length&&(o=t.slice(n),s[a]?s[a]+=o:s[++a]=o),s.length<2?u[0]?d4(u[0].x):c4(t):(t=u.length,function(c){for(var f=0,h;f<t;++f)s[(h=u[f]).i]=h.x(c);return s.join("")})}var my=180/Math.PI,vc={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function yy(e,t,n,r,i,o){var a,s,u;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(u=e*n+t*r)&&(n-=e*u,r-=t*u),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,u/=s),e*r<t*n&&(e=-e,t=-t,u=-u,a=-a),{translateX:i,translateY:o,rotate:Math.atan2(t,e)*my,skewX:Math.atan(u)*my,scaleX:a,scaleY:s}}var cs;function p4(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?vc:yy(t.a,t.b,t.c,t.d,t.e,t.f)}function h4(e){return e==null||(cs||(cs=document.createElementNS("http://www.w3.org/2000/svg","g")),cs.setAttribute("transform",e),!(e=cs.transform.baseVal.consolidate()))?vc:(e=e.matrix,yy(e.a,e.b,e.c,e.d,e.e,e.f))}function by(e,t,n,r){function i(c){return c.length?c.pop()+" ":""}function o(c,f,h,p,g,v){if(c!==h||f!==p){var m=g.push("translate(",null,t,null,n);v.push({i:m-4,x:Cr(c,h)},{i:m-2,x:Cr(f,p)})}else(h||p)&&g.push("translate("+h+t+p+n)}function a(c,f,h,p){c!==f?(c-f>180?f+=360:f-c>180&&(c+=360),p.push({i:h.push(i(h)+"rotate(",null,r)-2,x:Cr(c,f)})):f&&h.push(i(h)+"rotate("+f+r)}function s(c,f,h,p){c!==f?p.push({i:h.push(i(h)+"skewX(",null,r)-2,x:Cr(c,f)}):f&&h.push(i(h)+"skewX("+f+r)}function u(c,f,h,p,g,v){if(c!==h||f!==p){var m=g.push(i(g)+"scale(",null,",",null,")");v.push({i:m-4,x:Cr(c,h)},{i:m-2,x:Cr(f,p)})}else(h!==1||p!==1)&&g.push(i(g)+"scale("+h+","+p+")")}return function(c,f){var h=[],p=[];return c=e(c),f=e(f),o(c.translateX,c.translateY,f.translateX,f.translateY,h,p),a(c.rotate,f.rotate,h,p),s(c.skewX,f.skewX,h,p),u(c.scaleX,c.scaleY,f.scaleX,f.scaleY,h,p),c=f=null,function(g){for(var v=-1,m=p.length,w;++v<m;)h[(w=p[v]).i]=w.x(g);return h.join("")}}}var g4=by(p4,"px, ","px)","deg)"),v4=by(h4,", ",")",")"),m4=1e-12;function wy(e){return((e=Math.exp(e))+1/e)/2}function y4(e){return((e=Math.exp(e))-1/e)/2}function b4(e){return((e=Math.exp(2*e))-1)/(e+1)}const w4=function e(t,n,r){function i(o,a){var s=o[0],u=o[1],c=o[2],f=a[0],h=a[1],p=a[2],g=f-s,v=h-u,m=g*g+v*v,w,b;if(m<m4)b=Math.log(p/c)/t,w=function(A){return[s+A*g,u+A*v,c*Math.exp(t*A*b)]};else{var _=Math.sqrt(m),C=(p*p-c*c+r*m)/(2*c*n*_),S=(p*p-c*c-r*m)/(2*p*n*_),E=Math.log(Math.sqrt(C*C+1)-C),k=Math.log(Math.sqrt(S*S+1)-S);b=(k-E)/t,w=function(A){var L=A*b,F=wy(E),P=c/(n*_)*(F*b4(t*L+E)-y4(E));return[s+P*g,u+P*v,c*F/wy(t*L+E)]}}return w.duration=b*1e3*t/Math.SQRT2,w}return i.rho=function(o){var a=Math.max(.001,+o),s=a*a,u=s*s;return e(a,s,u)},i}(Math.SQRT2,2,4);var _i=0,So=0,Co=0,xy=1e3,ds,_o,fs=0,jr=0,ps=0,Eo=typeof performance=="object"&&performance.now?performance:Date,Sy=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function mc(){return jr||(Sy(x4),jr=Eo.now()+ps)}function x4(){jr=0}function hs(){this._call=this._time=this._next=null}hs.prototype=Cy.prototype={constructor:hs,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?mc():+n)+(t==null?0:+t),!this._next&&_o!==this&&(_o?_o._next=this:ds=this,_o=this),this._call=e,this._time=n,yc()},stop:function(){this._call&&(this._call=null,this._time=1/0,yc())}};function Cy(e,t,n){var r=new hs;return r.restart(e,t,n),r}function S4(){mc(),++_i;for(var e=ds,t;e;)(t=jr-e._time)>=0&&e._call.call(void 0,t),e=e._next;--_i}function _y(){jr=(fs=Eo.now())+ps,_i=So=0;try{S4()}finally{_i=0,_4(),jr=0}}function C4(){var e=Eo.now(),t=e-fs;t>xy&&(ps-=t,fs=e)}function _4(){for(var e,t=ds,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:ds=n);_o=e,yc(r)}function yc(e){if(!_i){So&&(So=clearTimeout(So));var t=e-jr;t>24?(e<1/0&&(So=setTimeout(_y,e-Eo.now()-ps)),Co&&(Co=clearInterval(Co))):(Co||(fs=Eo.now(),Co=setInterval(C4,xy)),_i=1,Sy(_y))}}function Ey(e,t,n){var r=new hs;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var E4=ts("start","end","cancel","interrupt"),T4=[],Ty=0,My=1,bc=2,gs=3,ky=4,wc=5,vs=6;function ms(e,t,n,r,i,o){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;M4(e,n,{name:t,index:r,group:i,on:E4,tween:T4,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Ty})}function xc(e,t){var n=An(e,t);if(n.state>Ty)throw new Error("too late; already scheduled");return n}function Bn(e,t){var n=An(e,t);if(n.state>gs)throw new Error("too late; already running");return n}function An(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function M4(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Cy(o,0,n.time);function o(c){n.state=My,n.timer.restart(a,n.delay,n.time),n.delay<=c&&a(c-n.delay)}function a(c){var f,h,p,g;if(n.state!==My)return u();for(f in r)if(g=r[f],g.name===n.name){if(g.state===gs)return Ey(a);g.state===ky?(g.state=vs,g.timer.stop(),g.on.call("interrupt",e,e.__data__,g.index,g.group),delete r[f]):+f<t&&(g.state=vs,g.timer.stop(),g.on.call("cancel",e,e.__data__,g.index,g.group),delete r[f])}if(Ey(function(){n.state===gs&&(n.state=ky,n.timer.restart(s,n.delay,n.time),s(c))}),n.state=bc,n.on.call("start",e,e.__data__,n.index,n.group),n.state===bc){for(n.state=gs,i=new Array(p=n.tween.length),f=0,h=-1;f<p;++f)(g=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(i[++h]=g);i.length=h+1}}function s(c){for(var f=c<n.duration?n.ease.call(null,c/n.duration):(n.timer.restart(u),n.state=wc,1),h=-1,p=i.length;++h<p;)i[h].call(e,f);n.state===wc&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=vs,n.timer.stop(),delete r[t];for(var c in r)return;delete e.__transition}}function ys(e,t){var n=e.__transition,r,i,o=!0,a;if(!!n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){o=!1;continue}i=r.state>bc&&r.state<wc,r.state=vs,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}o&&delete e.__transition}}function k4(e){return this.each(function(){ys(this,e)})}function O4(e,t){var n,r;return function(){var i=Bn(this,e),o=i.tween;if(o!==n){r=n=o;for(var a=0,s=r.length;a<s;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}i.tween=r}}function D4(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var o=Bn(this,e),a=o.tween;if(a!==r){i=(r=a).slice();for(var s={name:t,value:n},u=0,c=i.length;u<c;++u)if(i[u].name===t){i[u]=s;break}u===c&&i.push(s)}o.tween=i}}function R4(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=An(this.node(),n).tween,i=0,o=r.length,a;i<o;++i)if((a=r[i]).name===e)return a.value;return null}return this.each((t==null?O4:D4)(n,e,t))}function Sc(e,t,n){var r=e._id;return e.each(function(){var i=Bn(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return An(i,r).value[t]}}function Oy(e,t){var n;return(typeof t=="number"?Cr:t instanceof xo?vy:(n=xo(t))?(t=n,vy):f4)(e,t)}function A4(e){return function(){this.removeAttribute(e)}}function P4(e){return function(){this.removeAttributeNS(e.space,e.local)}}function I4(e,t,n){var r,i=n+"",o;return function(){var a=this.getAttribute(e);return a===i?null:a===r?o:o=t(r=a,n)}}function N4(e,t,n){var r,i=n+"",o;return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?o:o=t(r=a,n)}}function $4(e,t,n){var r,i,o;return function(){var a,s=n(this),u;return s==null?void this.removeAttribute(e):(a=this.getAttribute(e),u=s+"",a===u?null:a===r&&u===i?o:(i=u,o=t(r=a,s)))}}function L4(e,t,n){var r,i,o;return function(){var a,s=n(this),u;return s==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),u=s+"",a===u?null:a===r&&u===i?o:(i=u,o=t(r=a,s)))}}function V4(e,t){var n=rs(e),r=n==="transform"?v4:Oy;return this.attrTween(e,typeof t=="function"?(n.local?L4:$4)(n,r,Sc(this,"attr."+e,t)):t==null?(n.local?P4:A4)(n):(n.local?N4:I4)(n,r,t))}function z4(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function F4(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function B4(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&F4(e,o)),n}return i._value=t,i}function j4(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&z4(e,o)),n}return i._value=t,i}function G4(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=rs(e);return this.tween(n,(r.local?B4:j4)(r,t))}function K4(e,t){return function(){xc(this,e).delay=+t.apply(this,arguments)}}function H4(e,t){return t=+t,function(){xc(this,e).delay=t}}function W4(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?K4:H4)(t,e)):An(this.node(),t).delay}function q4(e,t){return function(){Bn(this,e).duration=+t.apply(this,arguments)}}function U4(e,t){return t=+t,function(){Bn(this,e).duration=t}}function Y4(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?q4:U4)(t,e)):An(this.node(),t).duration}function X4(e,t){if(typeof t!="function")throw new Error;return function(){Bn(this,e).ease=t}}function Q4(e){var t=this._id;return arguments.length?this.each(X4(t,e)):An(this.node(),t).ease}function Z4(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Bn(this,e).ease=n}}function J4(e){if(typeof e!="function")throw new Error;return this.each(Z4(this._id,e))}function eB(e){typeof e!="function"&&(e=Wm(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],a=o.length,s=r[i]=[],u,c=0;c<a;++c)(u=o[c])&&e.call(u,u.__data__,c,o)&&s.push(u);return new ir(r,this._parents,this._name,this._id)}function tB(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,o=Math.min(r,i),a=new Array(r),s=0;s<o;++s)for(var u=t[s],c=n[s],f=u.length,h=a[s]=new Array(f),p,g=0;g<f;++g)(p=u[g]||c[g])&&(h[g]=p);for(;s<r;++s)a[s]=t[s];return new ir(a,this._parents,this._name,this._id)}function nB(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function rB(e,t,n){var r,i,o=nB(t)?xc:Bn;return function(){var a=o(this,e),s=a.on;s!==r&&(i=(r=s).copy()).on(t,n),a.on=i}}function iB(e,t){var n=this._id;return arguments.length<2?An(this.node(),n).on.on(e):this.each(rB(n,e,t))}function oB(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function aB(){return this.on("end.remove",oB(this._id))}function sB(e){var t=this._name,n=this._id;typeof e!="function"&&(e=sc(e));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a<i;++a)for(var s=r[a],u=s.length,c=o[a]=new Array(u),f,h,p=0;p<u;++p)(f=s[p])&&(h=e.call(f,f.__data__,p,s))&&("__data__"in f&&(h.__data__=f.__data__),c[p]=h,ms(c[p],t,n,p,c,An(f,n)));return new ir(o,this._parents,t,n)}function lB(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Hm(e));for(var r=this._groups,i=r.length,o=[],a=[],s=0;s<i;++s)for(var u=r[s],c=u.length,f,h=0;h<c;++h)if(f=u[h]){for(var p=e.call(f,f.__data__,h,u),g,v=An(f,n),m=0,w=p.length;m<w;++m)(g=p[m])&&ms(g,t,n,m,p,v);o.push(p),a.push(f)}return new ir(o,a,t,n)}var uB=vo.prototype.constructor;function cB(){return new uB(this._groups,this._parents)}function dB(e,t){var n,r,i;return function(){var o=xi(this,e),a=(this.style.removeProperty(e),xi(this,e));return o===a?null:o===n&&a===r?i:i=t(n=o,r=a)}}function Dy(e){return function(){this.style.removeProperty(e)}}function fB(e,t,n){var r,i=n+"",o;return function(){var a=xi(this,e);return a===i?null:a===r?o:o=t(r=a,n)}}function pB(e,t,n){var r,i,o;return function(){var a=xi(this,e),s=n(this),u=s+"";return s==null&&(u=s=(this.style.removeProperty(e),xi(this,e))),a===u?null:a===r&&u===i?o:(i=u,o=t(r=a,s))}}function hB(e,t){var n,r,i,o="style."+t,a="end."+o,s;return function(){var u=Bn(this,e),c=u.on,f=u.value[o]==null?s||(s=Dy(t)):void 0;(c!==n||i!==f)&&(r=(n=c).copy()).on(a,i=f),u.on=r}}function gB(e,t,n){var r=(e+="")=="transform"?g4:Oy;return t==null?this.styleTween(e,dB(e,r)).on("end.style."+e,Dy(e)):typeof t=="function"?this.styleTween(e,pB(e,r,Sc(this,"style."+e,t))).each(hB(this._id,e)):this.styleTween(e,fB(e,r,t),n).on("end.style."+e,null)}function vB(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function mB(e,t,n){var r,i;function o(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&vB(e,a,n)),r}return o._value=t,o}function yB(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,mB(e,t,n==null?"":n))}function bB(e){return function(){this.textContent=e}}function wB(e){return function(){var t=e(this);this.textContent=t==null?"":t}}function xB(e){return this.tween("text",typeof e=="function"?wB(Sc(this,"text",e)):bB(e==null?"":e+""))}function SB(e){return function(t){this.textContent=e.call(this,t)}}function CB(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&SB(i)),t}return r._value=e,r}function _B(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,CB(e))}function EB(){for(var e=this._name,t=this._id,n=Ry(),r=this._groups,i=r.length,o=0;o<i;++o)for(var a=r[o],s=a.length,u,c=0;c<s;++c)if(u=a[c]){var f=An(u,t);ms(u,e,n,c,a,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new ir(r,this._parents,e,n)}function TB(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(o,a){var s={value:a},u={value:function(){--i===0&&o()}};n.each(function(){var c=Bn(this,r),f=c.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(s),t._.interrupt.push(s),t._.end.push(u)),c.on=t}),i===0&&o()})}var MB=0;function ir(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Ry(){return++MB}var or=vo.prototype;ir.prototype={constructor:ir,select:sB,selectAll:lB,selectChild:or.selectChild,selectChildren:or.selectChildren,filter:eB,merge:tB,selection:cB,transition:EB,call:or.call,nodes:or.nodes,node:or.node,size:or.size,empty:or.empty,each:or.each,on:iB,attr:V4,attrTween:G4,style:gB,styleTween:yB,text:xB,textTween:_B,remove:aB,tween:R4,delay:W4,duration:Y4,ease:Q4,easeVarying:J4,end:TB,[Symbol.iterator]:or[Symbol.iterator]};function kB(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var OB={time:null,delay:0,duration:250,ease:kB};function DB(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function RB(e){var t,n;e instanceof ir?(t=e._id,e=e._name):(t=Ry(),(n=OB).time=mc(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var a=r[o],s=a.length,u,c=0;c<s;++c)(u=a[c])&&ms(u,e,t,c,a,n||DB(u,t));return new ir(r,this._parents,e,t)}vo.prototype.interrupt=k4,vo.prototype.transition=RB;const bs=e=>()=>e;function AB(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function ar(e,t,n){this.k=e,this.x=t,this.y=n}ar.prototype={constructor:ar,scale:function(e){return e===1?this:new ar(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ar(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var sr=new ar(1,0,0);ar.prototype;function Cc(e){e.stopImmediatePropagation()}function To(e){e.preventDefault(),e.stopImmediatePropagation()}function PB(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function IB(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function Ay(){return this.__zoom||sr}function NB(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function $B(){return navigator.maxTouchPoints||"ontouchstart"in this}function LB(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function Py(){var e=PB,t=IB,n=LB,r=NB,i=$B,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],s=250,u=w4,c=ts("start","zoom","end"),f,h,p,g=500,v=150,m=0,w=10;function b(M){M.property("__zoom",Ay).on("wheel.zoom",L,{passive:!1}).on("mousedown.zoom",F).on("dblclick.zoom",P).filter(i).on("touchstart.zoom",O).on("touchmove.zoom",N).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(M,$,I,R){var B=M.selection?M.selection():M;B.property("__zoom",Ay),M!==B?E(M,$,I,R):B.interrupt().each(function(){k(this,arguments).event(R).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},b.scaleBy=function(M,$,I,R){b.scaleTo(M,function(){var B=this.__zoom.k,G=typeof $=="function"?$.apply(this,arguments):$;return B*G},I,R)},b.scaleTo=function(M,$,I,R){b.transform(M,function(){var B=t.apply(this,arguments),G=this.__zoom,K=I==null?S(B):typeof I=="function"?I.apply(this,arguments):I,W=G.invert(K),ee=typeof $=="function"?$.apply(this,arguments):$;return n(C(_(G,ee),K,W),B,a)},I,R)},b.translateBy=function(M,$,I,R){b.transform(M,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),a)},null,R)},b.translateTo=function(M,$,I,R,B){b.transform(M,function(){var G=t.apply(this,arguments),K=this.__zoom,W=R==null?S(G):typeof R=="function"?R.apply(this,arguments):R;return n(sr.translate(W[0],W[1]).scale(K.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof I=="function"?-I.apply(this,arguments):-I),G,a)},R,B)};function _(M,$){return $=Math.max(o[0],Math.min(o[1],$)),$===M.k?M:new ar($,M.x,M.y)}function C(M,$,I){var R=$[0]-I[0]*M.k,B=$[1]-I[1]*M.k;return R===M.x&&B===M.y?M:new ar(M.k,R,B)}function S(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function E(M,$,I,R){M.on("start.zoom",function(){k(this,arguments).event(R).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(R).end()}).tween("zoom",function(){var B=this,G=arguments,K=k(B,G).event(R),W=t.apply(B,G),ee=I==null?S(W):typeof I=="function"?I.apply(B,G):I,ne=Math.max(W[1][0]-W[0][0],W[1][1]-W[0][1]),U=B.__zoom,X=typeof $=="function"?$.apply(B,G):$,ce=u(U.invert(ee).concat(ne/U.k),X.invert(ee).concat(ne/X.k));return function(ue){if(ue===1)ue=X;else{var se=ce(ue),ae=ne/se[2];ue=new ar(ae,ee[0]-se[0]*ae,ee[1]-se[1]*ae)}K.zoom(null,ue)}})}function k(M,$,I){return!I&&M.__zooming||new A(M,$)}function A(M,$){this.that=M,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,$),this.taps=0}A.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,$){return this.mouse&&M!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var $=Cn(this.that).datum();c.call(M,this.that,new AB(M,{sourceEvent:this.sourceEvent,target:b,type:M,transform:this.that.__zoom,dispatch:c}),$)}};function L(M,...$){if(!e.apply(this,arguments))return;var I=k(this,$).event(M),R=this.__zoom,B=Math.max(o[0],Math.min(o[1],R.k*Math.pow(2,r.apply(this,arguments)))),G=Dn(M);if(I.wheel)(I.mouse[0][0]!==G[0]||I.mouse[0][1]!==G[1])&&(I.mouse[1]=R.invert(I.mouse[0]=G)),clearTimeout(I.wheel);else{if(R.k===B)return;I.mouse=[G,R.invert(G)],ys(this),I.start()}To(M),I.wheel=setTimeout(K,v),I.zoom("mouse",n(C(_(R,B),I.mouse[0],I.mouse[1]),I.extent,a));function K(){I.wheel=null,I.end()}}function F(M,...$){if(p||!e.apply(this,arguments))return;var I=M.currentTarget,R=k(this,$,!0).event(M),B=Cn(M.view).on("mousemove.zoom",ee,!0).on("mouseup.zoom",ne,!0),G=Dn(M,I),K=M.clientX,W=M.clientY;ny(M.view),Cc(M),R.mouse=[G,this.__zoom.invert(G)],ys(this),R.start();function ee(U){if(To(U),!R.moved){var X=U.clientX-K,ce=U.clientY-W;R.moved=X*X+ce*ce>m}R.event(U).zoom("mouse",n(C(R.that.__zoom,R.mouse[0]=Dn(U,I),R.mouse[1]),R.extent,a))}function ne(U){B.on("mousemove.zoom mouseup.zoom",null),ry(U.view,R.moved),To(U),R.event(U).end()}}function P(M,...$){if(!!e.apply(this,arguments)){var I=this.__zoom,R=Dn(M.changedTouches?M.changedTouches[0]:M,this),B=I.invert(R),G=I.k*(M.shiftKey?.5:2),K=n(C(_(I,G),R,B),t.apply(this,$),a);To(M),s>0?Cn(this).transition().duration(s).call(E,K,R,M):Cn(this).call(b.transform,K,R,M)}}function O(M,...$){if(!!e.apply(this,arguments)){var I=M.touches,R=I.length,B=k(this,$,M.changedTouches.length===R).event(M),G,K,W,ee;for(Cc(M),K=0;K<R;++K)W=I[K],ee=Dn(W,this),ee=[ee,this.__zoom.invert(ee),W.identifier],B.touch0?!B.touch1&&B.touch0[2]!==ee[2]&&(B.touch1=ee,B.taps=0):(B.touch0=ee,G=!0,B.taps=1+!!f);f&&(f=clearTimeout(f)),G&&(B.taps<2&&(h=ee[0],f=setTimeout(function(){f=null},g)),ys(this),B.start())}}function N(M,...$){if(!!this.__zooming){var I=k(this,$).event(M),R=M.changedTouches,B=R.length,G,K,W,ee;for(To(M),G=0;G<B;++G)K=R[G],W=Dn(K,this),I.touch0&&I.touch0[2]===K.identifier?I.touch0[0]=W:I.touch1&&I.touch1[2]===K.identifier&&(I.touch1[0]=W);if(K=I.that.__zoom,I.touch1){var ne=I.touch0[0],U=I.touch0[1],X=I.touch1[0],ce=I.touch1[1],ue=(ue=X[0]-ne[0])*ue+(ue=X[1]-ne[1])*ue,se=(se=ce[0]-U[0])*se+(se=ce[1]-U[1])*se;K=_(K,Math.sqrt(ue/se)),W=[(ne[0]+X[0])/2,(ne[1]+X[1])/2],ee=[(U[0]+ce[0])/2,(U[1]+ce[1])/2]}else if(I.touch0)W=I.touch0[0],ee=I.touch0[1];else return;I.zoom("touch",n(C(K,W,ee),I.extent,a))}}function z(M,...$){if(!!this.__zooming){var I=k(this,$).event(M),R=M.changedTouches,B=R.length,G,K;for(Cc(M),p&&clearTimeout(p),p=setTimeout(function(){p=null},g),G=0;G<B;++G)K=R[G],I.touch0&&I.touch0[2]===K.identifier?delete I.touch0:I.touch1&&I.touch1[2]===K.identifier&&delete I.touch1;if(I.touch1&&!I.touch0&&(I.touch0=I.touch1,delete I.touch1),I.touch0)I.touch0[1]=this.__zoom.invert(I.touch0[0]);else if(I.end(),I.taps===2&&(K=Dn(K,this),Math.hypot(h[0]-K[0],h[1]-K[1])<w)){var W=Cn(this).on("dblclick.zoom");W&&W.apply(this,arguments)}}}return b.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:bs(+M),b):r},b.filter=function(M){return arguments.length?(e=typeof M=="function"?M:bs(!!M),b):e},b.touchable=function(M){return arguments.length?(i=typeof M=="function"?M:bs(!!M),b):i},b.extent=function(M){return arguments.length?(t=typeof M=="function"?M:bs([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),b):t},b.scaleExtent=function(M){return arguments.length?(o[0]=+M[0],o[1]=+M[1],b):[o[0],o[1]]},b.translateExtent=function(M){return arguments.length?(a[0][0]=+M[0][0],a[1][0]=+M[1][0],a[0][1]=+M[0][1],a[1][1]=+M[1][1],b):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},b.constrain=function(M){return arguments.length?(n=M,b):n},b.duration=function(M){return arguments.length?(s=+M,b):s},b.interpolate=function(M){return arguments.length?(u=M,b):u},b.on=function(){var M=c.on.apply(c,arguments);return M===c?b:M},b.clickDistance=function(M){return arguments.length?(m=(M=+M)*M,b):Math.sqrt(m)},b.tapDistance=function(M){return arguments.length?(w=+M,b):w},b}const ws=x.createContext(null),VB=ws.Provider,jn={"001":()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001","002":()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.","003":e=>`Node type "${e}" not found. Using fallback type "default".`,"004":()=>"The React Flow parent container needs a width and a height to render the graph.","005":()=>"Only child nodes can use a parent extent.","006":()=>"Can't create edge. An edge needs a source and a target.","007":e=>`The old edge with id=${e} does not exist.`,"009":e=>`Marker type "${e}" doesn't exist.`,"008":(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,"010":()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.","011":e=>`Edge type "${e}" not found. Using fallback type "default".`},Iy=jn["001"]();function Tt(e,t){const n=x.useContext(ws);if(n===null)throw new Error(Iy);return aF(n,e,t)}const Kt=()=>{const e=x.useContext(ws);if(e===null)throw new Error(Iy);return x.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},zB=e=>e.userSelectionActive?"none":"all";function _c({position:e,children:t,className:n,style:r,...i}){const o=Tt(zB),a=`${e}`.split("-");return l("div",{className:Zt(["react-flow__panel",n,...a]),style:{...r,pointerEvents:o},...i,children:t})}function FB({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:l(_c,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:l("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const BB=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:i=!0,labelBgStyle:o={},labelBgPadding:a=[2,4],labelBgBorderRadius:s=2,children:u,className:c,...f})=>{const h=x.useRef(null),[p,g]=x.useState({x:0,y:0,width:0,height:0}),v=Zt(["react-flow__edge-textwrapper",c]);return x.useEffect(()=>{if(h.current){const m=h.current.getBBox();g({x:m.x,y:m.y,width:m.width,height:m.height})}},[n]),typeof n>"u"||!n?null:y("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:v,visibility:p.width?"visible":"hidden",...f,children:[i&&l("rect",{width:p.width+2*a[0],x:-a[0],y:-a[1],height:p.height+2*a[1],className:"react-flow__edge-textbg",style:o,rx:s,ry:s}),l("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:h,style:r,children:n}),u]})};var jB=x.memo(BB);const Ec=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ei=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Tc=(e={x:0,y:0},t)=>({x:Ei(e.x,t[0][0],t[1][0]),y:Ei(e.y,t[0][1],t[1][1])}),Ny=(e,t,n)=>e<t?Ei(Math.abs(e-t),1,50)/50:e>n?-Ei(Math.abs(e-n),1,50)/50:0,$y=(e,t)=>{const n=Ny(e.x,35,t.width-35)*20,r=Ny(e.y,35,t.height-35)*20;return[n,r]},Ly=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Vy=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),xs=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),zy=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Fy=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),GB=(e,t)=>zy(Vy(xs(e),xs(t))),Mc=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},KB=e=>_n(e.width)&&_n(e.height)&&_n(e.x)&&_n(e.y),_n=e=>!isNaN(e)&&isFinite(e),jt=Symbol.for("internals"),By=["Enter"," ","Escape"],kc=(e,t)=>{process.env.NODE_ENV==="development"&&console.warn(`[React Flow]: ${t} Help: https://reactflow.dev/error#${e}`)},HB=e=>"nativeEvent"in e;function Oc(e){var r,i;const t=HB(e)?e.nativeEvent:e,n=((i=(r=t.composedPath)==null?void 0:r.call(t))==null?void 0:i[0])||e.target;return e.ctrlKey||e.metaKey||e.shiftKey?!1:["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const jy=e=>"clientX"in e,_r=(e,t)=>{var o,a,s,u;const n=jy(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,i=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:r-((s=t==null?void 0:t.left)!=null?s:0),y:i-((u=t==null?void 0:t.top)!=null?u:0)}},Mo=({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:s,labelBgBorderRadius:u,style:c,markerEnd:f,markerStart:h,interactionWidth:p=20})=>y(Oe,{children:[l("path",{style:c,d:e,fill:"none",className:"react-flow__edge-path",markerEnd:f,markerStart:h}),p&&l("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:p,className:"react-flow__edge-interaction"}),r&&_n(t)&&_n(n)?l(jB,{x:t,y:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:s,labelBgBorderRadius:u}):null]});Mo.displayName="BaseEdge";function ko(e,t,n){return n===void 0?n:r=>{const i=t().edges.find(o=>o.id===e);i&&n(r,{...i})}}function Gy({sourceX:e,sourceY:t,targetX:n,targetY:r}){const i=Math.abs(n-e)/2,o=n<e?n+i:n-i,a=Math.abs(r-t)/2,s=r<t?r+a:r-a;return[o,s,i,a]}function Ky({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:o,targetControlX:a,targetControlY:s}){const u=e*.125+i*.375+a*.375+n*.125,c=t*.125+o*.375+s*.375+r*.125,f=Math.abs(u-e),h=Math.abs(c-t);return[u,c,f,h]}var Gr;(function(e){e.Strict="strict",e.Loose="loose"})(Gr||(Gr={}));var Ti;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ti||(Ti={}));var Oo;(function(e){e.Partial="partial",e.Full="full"})(Oo||(Oo={}));var Er;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Er||(Er={}));var Ss;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ss||(Ss={}));var Me;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Me||(Me={}));function Hy({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Me.Left||e===Me.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function Wy({sourceX:e,sourceY:t,sourcePosition:n=Me.Bottom,targetX:r,targetY:i,targetPosition:o=Me.Top}){const[a,s]=Hy({pos:n,x1:e,y1:t,x2:r,y2:i}),[u,c]=Hy({pos:o,x1:r,y1:i,x2:e,y2:t}),[f,h,p,g]=Ky({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:a,sourceControlY:s,targetControlX:u,targetControlY:c});return[`M${e},${t} C${a},${s} ${u},${c} ${r},${i}`,f,h,p,g]}const Dc=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=Me.Bottom,targetPosition:o=Me.Top,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:g,markerStart:v,interactionWidth:m})=>{const[w,b,_]=Wy({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:o});return l(Mo,{path:w,labelX:b,labelY:_,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:g,markerStart:v,interactionWidth:m})});Dc.displayName="SimpleBezierEdge";const qy={[Me.Left]:{x:-1,y:0},[Me.Right]:{x:1,y:0},[Me.Top]:{x:0,y:-1},[Me.Bottom]:{x:0,y:1}},WB=({source:e,sourcePosition:t=Me.Bottom,target:n})=>t===Me.Left||t===Me.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Uy=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function qB({source:e,sourcePosition:t=Me.Bottom,target:n,targetPosition:r=Me.Top,center:i,offset:o}){const a=qy[t],s=qy[r],u={x:e.x+a.x*o,y:e.y+a.y*o},c={x:n.x+s.x*o,y:n.y+s.y*o},f=WB({source:u,sourcePosition:t,target:c}),h=f.x!==0?"x":"y",p=f[h];let g=[],v,m;const[w,b,_,C]=Gy({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[h]*s[h]===-1){v=i.x||w,m=i.y||b;const E=[{x:v,y:u.y},{x:v,y:c.y}],k=[{x:u.x,y:m},{x:c.x,y:m}];a[h]===p?g=h==="x"?E:k:g=h==="x"?k:E}else{const E=[{x:u.x,y:c.y}],k=[{x:c.x,y:u.y}];if(h==="x"?g=a.x===p?k:E:g=a.y===p?E:k,t!==r){const A=h==="x"?"y":"x",L=a[h]===s[A],F=u[A]>c[A],P=u[A]<c[A];(a[h]===1&&(!L&&F||L&&P)||a[h]!==1&&(!L&&P||L&&F))&&(g=h==="x"?E:k)}v=g[0].x,m=g[0].y}return[[e,u,...g,c,n],v,m,_,C]}function UB(e,t,n,r){const i=Math.min(Uy(e,t)/2,Uy(t,n)/2,r),{x:o,y:a}=t;if(e.x===o&&o===n.x||e.y===a&&a===n.y)return`L${o} ${a}`;if(e.y===a){const c=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${o+i*c},${a}Q ${o},${a} ${o},${a+i*f}`}const s=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${o},${a+i*u}Q ${o},${a} ${o+i*s},${a}`}function Rc({sourceX:e,sourceY:t,sourcePosition:n=Me.Bottom,targetX:r,targetY:i,targetPosition:o=Me.Top,borderRadius:a=5,centerX:s,centerY:u,offset:c=20}){const[f,h,p,g,v]=qB({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:o,center:{x:s,y:u},offset:c});return[f.reduce((w,b,_)=>{let C="";return _>0&&_<f.length-1?C=UB(f[_-1],b,f[_+1],a):C=`${_===0?"M":"L"}${b.x} ${b.y}`,w+=C,w},""),h,p,g,v]}const Cs=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:c,style:f,sourcePosition:h=Me.Bottom,targetPosition:p=Me.Top,markerEnd:g,markerStart:v,pathOptions:m,interactionWidth:w})=>{const[b,_,C]=Rc({sourceX:e,sourceY:t,sourcePosition:h,targetX:n,targetY:r,targetPosition:p,borderRadius:m==null?void 0:m.borderRadius,offset:m==null?void 0:m.offset});return l(Mo,{path:b,labelX:_,labelY:C,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:c,style:f,markerEnd:g,markerStart:v,interactionWidth:w})});Cs.displayName="SmoothStepEdge";const Ac=x.memo(e=>{var t;return l(Cs,{...e,pathOptions:x.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});Ac.displayName="StepEdge";function YB({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[i,o,a,s]=Gy({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,o,a,s]}const Pc=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:c,style:f,markerEnd:h,markerStart:p,interactionWidth:g})=>{const[v,m,w]=YB({sourceX:e,sourceY:t,targetX:n,targetY:r});return l(Mo,{path:v,labelX:m,labelY:w,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:c,style:f,markerEnd:h,markerStart:p,interactionWidth:g})});Pc.displayName="StraightEdge";function _s(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function Yy({pos:e,x1:t,y1:n,x2:r,y2:i,c:o}){switch(e){case Me.Left:return[t-_s(t-r,o),n];case Me.Right:return[t+_s(r-t,o),n];case Me.Top:return[t,n-_s(n-i,o)];case Me.Bottom:return[t,n+_s(i-n,o)]}}function Xy({sourceX:e,sourceY:t,sourcePosition:n=Me.Bottom,targetX:r,targetY:i,targetPosition:o=Me.Top,curvature:a=.25}){const[s,u]=Yy({pos:n,x1:e,y1:t,x2:r,y2:i,c:a}),[c,f]=Yy({pos:o,x1:r,y1:i,x2:e,y2:t,c:a}),[h,p,g,v]=Ky({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:u,targetControlX:c,targetControlY:f});return[`M${e},${t} C${s},${u} ${c},${f} ${r},${i}`,h,p,g,v]}const Es=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=Me.Bottom,targetPosition:o=Me.Top,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:g,markerStart:v,pathOptions:m,interactionWidth:w})=>{const[b,_,C]=Xy({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:o,curvature:m==null?void 0:m.curvature});return l(Mo,{path:b,labelX:_,labelY:C,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:g,markerStart:v,interactionWidth:w})});Es.displayName="BezierEdge";const Ic=x.createContext(null),XB=Ic.Provider;Ic.Consumer;const QB=()=>x.useContext(Ic),ZB=e=>"id"in e&&"source"in e&&"target"in e,JB=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,Nc=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,e5=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),t5=(e,t)=>{if(!e.source||!e.target)return kc("006",jn["006"]()),t;let n;return ZB(e)?n={...e}:n={...e,id:JB(e)},e5(n,t)?t:t.concat(n)},Qy=({x:e,y:t},[n,r,i],o,[a,s])=>{const u={x:(e-n)/i,y:(t-r)/i};return o?{x:a*Math.round(u.x/a),y:s*Math.round(u.y/s)}:u},n5=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r}),Kr=(e,t=[0,0])=>{var o,a;if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=((o=e.width)!=null?o:0)*t[0],r=((a=e.height)!=null?a:0)*t[1],i={x:e.position.x-n,y:e.position.y-r};return{...i,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:i}},$c=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,i)=>{const{x:o,y:a}=Kr(i,t).positionAbsolute;return Vy(r,xs({x:o,y:a,width:i.width||0,height:i.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return zy(n)},Zy=(e,t,[n,r,i]=[0,0,1],o=!1,a=!1,s=[0,0])=>{const u={x:(t.x-n)/i,y:(t.y-r)/i,width:t.width/i,height:t.height/i},c=[];return e.forEach(f=>{const{width:h,height:p,selectable:g=!0,hidden:v=!1}=f;if(a&&!g||v)return!1;const{positionAbsolute:m}=Kr(f,s),w={x:m.x,y:m.y,width:h||0,height:p||0},b=Mc(u,w),_=typeof h>"u"||typeof p>"u"||h===null||p===null,C=o&&b>0,S=(h||0)*(p||0);(_||C||b>=S||f.dragging)&&c.push(f)}),c},Jy=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},eb=(e,t,n,r,i,o=.1)=>{const a=t/(e.width*(1+o)),s=n/(e.height*(1+o)),u=Math.min(a,s),c=Ei(u,r,i),f=e.x+e.width/2,h=e.y+e.height/2,p=t/2-f*c,g=n/2-h*c;return[p,g,c]},Hr=(e,t=0)=>e.transition().duration(t);function tb(e,t,n,r){return(t[n]||[]).reduce((i,o)=>{var a,s,u,c;return`${e.id}-${o.id}-${n}`!==r&&i.push({id:o.id||null,type:n,nodeId:e.id,x:((s=(a=e.positionAbsolute)==null?void 0:a.x)!=null?s:0)+o.x+o.width/2,y:((c=(u=e.positionAbsolute)==null?void 0:u.y)!=null?c:0)+o.y+o.height/2}),i},[])}function r5(e,t,n){let r=null,i=1/0;return n.forEach(o=>{const a=Math.sqrt(Math.pow(o.x-e.x,2)+Math.pow(o.y-e.y,2));a<=t&&a<i&&(i=a,r=o)}),r}const i5={source:null,target:null,sourceHandle:null,targetHandle:null};function nb(e,t,n,r,i,o,a,s){const u=o==="target",c=s.querySelector(`.react-flow__handle[data-id="${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`),{x:f,y:h}=_r(e),p=s.elementFromPoint(f,h),g=p!=null&&p.classList.contains("react-flow__handle")?p:c,v={handleDomNode:g,isValid:!1,connection:i5};if(g){const m=rb(void 0,g),w=g.getAttribute("data-nodeid"),b=g.getAttribute("data-handleid"),_={source:u?w:r,sourceHandle:u?b:i,target:u?r:w,targetHandle:u?i:b};v.connection=_,(n===Gr.Strict?u&&m==="source"||!u&&m==="target":w!==r||b!==i)&&(v.isValid=a(_))}return v}function o5({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((i,o)=>{if(o[jt]){const{handleBounds:a}=o[jt];let s=[],u=[];a&&(s=tb(o,a,"source",`${t}-${n}-${r}`),u=tb(o,a,"target",`${t}-${n}-${r}`)),i.push(...s,...u)}return i},[])}function rb(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Lc(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function a5(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function ib({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:i,getState:o,setState:a,isValidConnection:s,edgeUpdaterType:u,onEdgeUpdateEnd:c}){const f=Ly(e.target),{connectionMode:h,domNode:p,autoPanOnConnect:g,connectionRadius:v,onConnectStart:m,panBy:w,getNodes:b,cancelConnection:_}=o();let C=0,S;const{x:E,y:k}=_r(e),A=f==null?void 0:f.elementFromPoint(E,k),L=rb(u,A),F=p==null?void 0:p.getBoundingClientRect();if(!F||!L)return;let P,O=_r(e,F),N=!1,z=null,M=!1;const $=o5({nodes:b(),nodeId:n,handleId:t,handleType:L}),I=()=>{if(!g)return;const[G,K]=$y(O,F);w({x:G,y:K}),C=requestAnimationFrame(I)};a({connectionPosition:O,connectionNodeId:n,connectionHandleId:t,connectionHandleType:L,connectionStatus:null}),m==null||m(e,{nodeId:n,handleId:t,handleType:L});function R(G){const{transform:K}=o();O=_r(G,F),S=r5(Qy(O,K,!1,[1,1]),v,$),N||(I(),N=!0);const{handleDomNode:W,...ee}=nb(G,S,h,n,t,i?"target":"source",s,f);if(a({connectionPosition:S&&ee.isValid?n5({x:S.x,y:S.y},K):O,connectionStatus:a5(!!S,ee.isValid)}),!S&&!ee.isValid)return Lc(P);z=ee.connection,M=ee.isValid,z.source!==z.target&&W&&(Lc(P),P=W,W.classList.add("connecting","react-flow__handle-connecting"),W.classList.toggle("valid",M),W.classList.toggle("react-flow__handle-valid",M))}function B(G){var K,W;z&&M&&S&&(r==null||r(z)),(W=(K=o()).onConnectEnd)==null||W.call(K,G),u&&(c==null||c(G)),Lc(P),_(),cancelAnimationFrame(C),N=!1,M=!1,z=null,S=null,f.removeEventListener("mousemove",R),f.removeEventListener("mouseup",B),f.removeEventListener("touchmove",R),f.removeEventListener("touchend",B)}f.addEventListener("mousemove",R),f.addEventListener("mouseup",B),f.addEventListener("touchmove",R),f.addEventListener("touchend",B)}const s5=()=>!0,l5=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),ob=x.forwardRef(({type:e="source",position:t=Me.Top,isValidConnection:n=s5,isConnectable:r=!0,id:i,onConnect:o,children:a,className:s,onMouseDown:u,onTouchStart:c,...f},h)=>{var k,A;const p=Kt(),g=QB();if(!g)return(A=(k=p.getState()).onError)==null||A.call(k,"010",jn["010"]()),null;const{connectionStartHandle:v,connectOnClick:m,noPanClassName:w}=Tt(l5,nn),b=i||null,_=e==="target",C=L=>{const{defaultEdgeOptions:F,onConnect:P,hasDefaultEdges:O}=p.getState(),N={...F,...L};if(O){const{edges:z}=p.getState();p.setState({edges:t5(N,z)})}P==null||P(N),o==null||o(N)},S=L=>{const F=jy(L);(F&&L.button===0||!F)&&ib({event:L,handleId:b,nodeId:g,onConnect:C,isTarget:_,getState:p.getState,setState:p.setState,isValidConnection:n}),F?u==null||u(L):c==null||c(L)},E=L=>{const{onClickConnectStart:F,onClickConnectEnd:P,connectionMode:O}=p.getState();if(!v){F==null||F(L,{nodeId:g,handleId:b,handleType:e}),p.setState({connectionStartHandle:{nodeId:g,type:e,handleId:b}});return}const N=Ly(L.target),{connection:z,isValid:M}=nb(L,{nodeId:g,id:b,type:e},O,v.nodeId,v.handleId||null,v.type,n,N);M&&C(z),P==null||P(L),p.setState({connectionStartHandle:null})};return l("div",{"data-handleid":b,"data-nodeid":g,"data-handlepos":t,"data-id":`${g}-${b}-${e}`,className:Zt(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",w,s,{source:!_,target:_,connectable:r,connecting:(v==null?void 0:v.nodeId)===g&&(v==null?void 0:v.handleId)===b&&(v==null?void 0:v.type)===e}]),onMouseDown:S,onTouchStart:S,onClick:m?E:void 0,ref:h,...f,children:a})});ob.displayName="Handle";var Mi=x.memo(ob);const ab=({data:e,isConnectable:t,targetPosition:n=Me.Top,sourcePosition:r=Me.Bottom})=>y(Oe,{children:[l(Mi,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,l(Mi,{type:"source",position:r,isConnectable:t})]});ab.displayName="DefaultNode";var Vc=x.memo(ab);const sb=({data:e,isConnectable:t,sourcePosition:n=Me.Bottom})=>y(Oe,{children:[e==null?void 0:e.label,l(Mi,{type:"source",position:n,isConnectable:t})]});sb.displayName="InputNode";var lb=x.memo(sb);const ub=({data:e,isConnectable:t,targetPosition:n=Me.Top})=>y(Oe,{children:[l(Mi,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]});ub.displayName="OutputNode";var cb=x.memo(ub);const zc=()=>null;zc.displayName="GroupNode";const u5=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected)}),Ts=e=>e.id;function c5(e,t){return nn(e.selectedNodes.map(Ts),t.selectedNodes.map(Ts))&&nn(e.selectedEdges.map(Ts),t.selectedEdges.map(Ts))}const db=x.memo(({onSelectionChange:e})=>{const t=Kt(),{selectedNodes:n,selectedEdges:r}=Tt(u5,c5);return x.useEffect(()=>{var o,a;const i={nodes:n,edges:r};e==null||e(i),(a=(o=t.getState()).onSelectionChange)==null||a.call(o,i)},[n,r,e]),null});db.displayName="SelectionListener";const d5=e=>!!e.onSelectionChange;function f5({onSelectionChange:e}){const t=Tt(d5);return e||t?l(db,{onSelectionChange:e}):null}const p5=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function ki(e,t){x.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function ot(e,t,n){x.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const h5=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:i,onConnectStart:o,onConnectEnd:a,onClickConnectStart:s,onClickConnectEnd:u,nodesDraggable:c,nodesConnectable:f,nodesFocusable:h,edgesFocusable:p,elevateNodesOnSelect:g,minZoom:v,maxZoom:m,nodeExtent:w,onNodesChange:b,onEdgesChange:_,elementsSelectable:C,connectionMode:S,snapGrid:E,snapToGrid:k,translateExtent:A,connectOnClick:L,defaultEdgeOptions:F,fitView:P,fitViewOptions:O,onNodesDelete:N,onEdgesDelete:z,onNodeDrag:M,onNodeDragStart:$,onNodeDragStop:I,onSelectionDrag:R,onSelectionDragStart:B,onSelectionDragStop:G,noPanClassName:K,nodeOrigin:W,rfId:ee,autoPanOnConnect:ne,autoPanOnNodeDrag:U,onError:X,connectionRadius:ce})=>{const{setNodes:ue,setEdges:se,setDefaultNodesAndEdges:ae,setMinZoom:xe,setMaxZoom:be,setTranslateExtent:Y,setNodeExtent:re,reset:Se}=Tt(p5,nn),q=Kt();return x.useEffect(()=>{const we=r==null?void 0:r.map(ve=>({...ve,...F}));return ae(n,we),()=>{Se()}},[]),ot("defaultEdgeOptions",F,q.setState),ot("connectionMode",S,q.setState),ot("onConnect",i,q.setState),ot("onConnectStart",o,q.setState),ot("onConnectEnd",a,q.setState),ot("onClickConnectStart",s,q.setState),ot("onClickConnectEnd",u,q.setState),ot("nodesDraggable",c,q.setState),ot("nodesConnectable",f,q.setState),ot("nodesFocusable",h,q.setState),ot("edgesFocusable",p,q.setState),ot("elementsSelectable",C,q.setState),ot("elevateNodesOnSelect",g,q.setState),ot("snapToGrid",k,q.setState),ot("snapGrid",E,q.setState),ot("onNodesChange",b,q.setState),ot("onEdgesChange",_,q.setState),ot("connectOnClick",L,q.setState),ot("fitViewOnInit",P,q.setState),ot("fitViewOnInitOptions",O,q.setState),ot("onNodesDelete",N,q.setState),ot("onEdgesDelete",z,q.setState),ot("onNodeDrag",M,q.setState),ot("onNodeDragStart",$,q.setState),ot("onNodeDragStop",I,q.setState),ot("onSelectionDrag",R,q.setState),ot("onSelectionDragStart",B,q.setState),ot("onSelectionDragStop",G,q.setState),ot("noPanClassName",K,q.setState),ot("nodeOrigin",W,q.setState),ot("rfId",ee,q.setState),ot("autoPanOnConnect",ne,q.setState),ot("autoPanOnNodeDrag",U,q.setState),ot("onError",X,q.setState),ot("connectionRadius",ce,q.setState),ki(e,ue),ki(t,se),ki(v,xe),ki(m,be),ki(A,Y),ki(w,re),null},fb={display:"none"},g5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},pb="react-flow__node-desc",hb="react-flow__edge-desc",v5="react-flow__aria-live",m5=e=>e.ariaLiveMessage;function y5({rfId:e}){const t=Tt(m5);return l("div",{id:`${v5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:g5,children:t})}function b5({rfId:e,disableKeyboardA11y:t}){return y(Oe,{children:[y("div",{id:`${pb}-${e}`,style:fb,children:["Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "]}),l("div",{id:`${hb}-${e}`,style:fb,children:"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."}),!t&&l(y5,{rfId:e})]})}const w5=(e,t,n)=>n===Me.Left?e-t:n===Me.Right?e+t:e,x5=(e,t,n)=>n===Me.Top?e-t:n===Me.Bottom?e+t:e,gb="react-flow__edgeupdater",vb=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:o,onMouseOut:a,type:s})=>l("circle",{onMouseDown:i,onMouseEnter:o,onMouseOut:a,className:Zt([gb,`${gb}-${s}`]),cx:w5(t,r,e),cy:x5(n,r,e),r,stroke:"transparent",fill:"transparent"});var Oi=e=>{const t=({id:n,className:r,type:i,data:o,onClick:a,onEdgeDoubleClick:s,selected:u,animated:c,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:g,labelBgPadding:v,labelBgBorderRadius:m,style:w,source:b,target:_,sourceX:C,sourceY:S,targetX:E,targetY:k,sourcePosition:A,targetPosition:L,elementsSelectable:F,hidden:P,sourceHandleId:O,targetHandleId:N,onContextMenu:z,onMouseEnter:M,onMouseMove:$,onMouseLeave:I,edgeUpdaterRadius:R,onEdgeUpdate:B,onEdgeUpdateStart:G,onEdgeUpdateEnd:K,markerEnd:W,markerStart:ee,rfId:ne,ariaLabel:U,isFocusable:X,pathOptions:ce,interactionWidth:ue})=>{const se=x.useRef(null),[ae,xe]=x.useState(!1),[be,Y]=x.useState(!1),re=Kt(),Se=x.useMemo(()=>`url(#${Nc(ee,ne)})`,[ee,ne]),q=x.useMemo(()=>`url(#${Nc(W,ne)})`,[W,ne]);if(P)return null;const we=We=>{const{edges:st,addSelectedEdges:Ce}=re.getState();if(F&&(re.setState({nodesSelectionActive:!1}),Ce([n])),a){const Ie=st.find(et=>et.id===n);a(We,Ie)}},ve=ko(n,re.getState,s),_e=ko(n,re.getState,z),ke=ko(n,re.getState,M),ge=ko(n,re.getState,$),Ke=ko(n,re.getState,I),Pe=(We,st)=>{const Ce=st?_:b,Ie=(st?N:O)||null,et=st?"target":"source",Mt=()=>!0,lt=st,kt=re.getState().edges.find(Ot=>Ot.id===n);Y(!0),G==null||G(We,kt,et);const dt=Ot=>{Y(!1),K==null||K(Ot,kt,et)};ib({event:We,handleId:Ie,nodeId:Ce,onConnect:Ot=>B==null?void 0:B(kt,Ot),isTarget:lt,getState:re.getState,setState:re.setState,isValidConnection:Mt,edgeUpdaterType:et,onEdgeUpdateEnd:dt})},Xe=We=>Pe(We,!0),Ee=We=>Pe(We,!1),Fe=()=>xe(!0),Le=()=>xe(!1),Ve=!F&&!a,ct=typeof B<"u",at=We=>{var st;if(By.includes(We.key)&&F){const{unselectNodesAndEdges:Ce,addSelectedEdges:Ie,edges:et}=re.getState();We.key==="Escape"?((st=se.current)==null||st.blur(),Ce({edges:[et.find(lt=>lt.id===n)]})):Ie([n])}};return y("g",{className:Zt(["react-flow__edge",`react-flow__edge-${i}`,r,{selected:u,animated:c,inactive:Ve,updating:ae}]),onClick:we,onDoubleClick:ve,onContextMenu:_e,onMouseEnter:ke,onMouseMove:ge,onMouseLeave:Ke,onKeyDown:X?at:void 0,tabIndex:X?0:void 0,role:X?"button":void 0,"data-testid":`rf__edge-${n}`,"aria-label":U===null?void 0:U||`Edge from ${b} to ${_}`,"aria-describedby":X?`${hb}-${ne}`:void 0,ref:se,children:[!be&&l(e,{id:n,source:b,target:_,selected:u,animated:c,label:f,labelStyle:h,labelShowBg:p,labelBgStyle:g,labelBgPadding:v,labelBgBorderRadius:m,data:o,style:w,sourceX:C,sourceY:S,targetX:E,targetY:k,sourcePosition:A,targetPosition:L,sourceHandleId:O,targetHandleId:N,markerStart:Se,markerEnd:q,pathOptions:ce,interactionWidth:ue}),ct&&y(Oe,{children:[l(vb,{position:A,centerX:C,centerY:S,radius:R,onMouseDown:Xe,onMouseEnter:Fe,onMouseOut:Le,type:"source"}),l(vb,{position:L,centerX:E,centerY:k,radius:R,onMouseDown:Ee,onMouseEnter:Fe,onMouseOut:Le,type:"target"})]})]})};return t.displayName="EdgeWrapper",x.memo(t)};function S5(e){const t={default:Oi(e.default||Es),straight:Oi(e.bezier||Pc),step:Oi(e.step||Ac),smoothstep:Oi(e.step||Cs),simplebezier:Oi(e.simplebezier||Dc)},n={},r=Object.keys(e).filter(i=>!["default","bezier"].includes(i)).reduce((i,o)=>(i[o]=Oi(e[o]||Es),i),n);return{...t,...r}}function mb(e,t,n=null){const r=((n==null?void 0:n.x)||0)+t.x,i=((n==null?void 0:n.y)||0)+t.y,o=(n==null?void 0:n.width)||t.width,a=(n==null?void 0:n.height)||t.height;switch(e){case Me.Top:return{x:r+o/2,y:i};case Me.Right:return{x:r+o,y:i+a/2};case Me.Bottom:return{x:r+o/2,y:i+a};case Me.Left:return{x:r,y:i+a/2}}}function yb(e,t){return e?t?e.find(n=>n.id===t):e.length===1?e[0]:null:null}const C5=(e,t,n,r,i,o)=>{const a=mb(n,e,t),s=mb(o,r,i);return{sourceX:a.x,sourceY:a.y,targetX:s.x,targetY:s.y}};function _5({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:i,targetHeight:o,width:a,height:s,transform:u}){const c={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+i),y2:Math.max(e.y+r,t.y+o)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const f=xs({x:(0-u[0])/u[2],y:(0-u[1])/u[2],width:a/u[2],height:s/u[2]}),h=Math.max(0,Math.min(f.x2,c.x2)-Math.max(f.x,c.x)),p=Math.max(0,Math.min(f.y2,c.y2)-Math.max(f.y,c.y));return Math.ceil(h*p)>0}function bb(e){var r,i,o,a,s;const t=((r=e==null?void 0:e[jt])==null?void 0:r.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((i=e==null?void 0:e.positionAbsolute)==null?void 0:i.x)<"u"&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.y)<"u";return[{x:((a=e==null?void 0:e.positionAbsolute)==null?void 0:a.x)||0,y:((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}function wb(e,t){if(!e.parentNode)return!1;const n=t.get(e.parentNode);return n?n.selected?!0:wb(n,t):!1}function xb(e,t,n){let r=e;do{if(r!=null&&r.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function E5(e,t,n,r){return Array.from(e.values()).filter(i=>(i.selected||i.id===r)&&(!i.parentNode||!wb(i,e))&&(i.draggable||t&&typeof i.draggable>"u")).map(i=>{var o,a,s,u;return{id:i.id,position:i.position||{x:0,y:0},positionAbsolute:i.positionAbsolute||{x:0,y:0},distance:{x:n.x-((a=(o=i.positionAbsolute)==null?void 0:o.x)!=null?a:0),y:n.y-((u=(s=i.positionAbsolute)==null?void 0:s.y)!=null?u:0)},delta:{x:0,y:0},extent:i.extent,parentNode:i.parentNode,width:i.width,height:i.height}})}function Sb(e,t,n,r,i=[0,0],o){let a=e.extent||r;if(e.extent==="parent")if(e.parentNode&&e.width&&e.height){const c=n.get(e.parentNode),{x:f,y:h}=Kr(c,i).positionAbsolute;a=c&&_n(f)&&_n(h)&&_n(c.width)&&_n(c.height)?[[f+e.width*i[0],h+e.height*i[1]],[f+c.width-e.width+e.width*i[0],h+c.height-e.height+e.height*i[1]]]:a}else o==null||o("005",jn["005"]()),a=r;else if(e.extent&&e.parentNode){const c=n.get(e.parentNode),{x:f,y:h}=Kr(c,i).positionAbsolute;a=[[e.extent[0][0]+f,e.extent[0][1]+h],[e.extent[1][0]+f,e.extent[1][1]+h]]}let s={x:0,y:0};if(e.parentNode){const c=n.get(e.parentNode);s=Kr(c,i).positionAbsolute}const u=a?Tc(t,a):t;return{position:{x:u.x-s.x,y:u.y-s.y},positionAbsolute:u}}function Fc({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(i=>({...n.get(i.id),position:i.position,positionAbsolute:i.positionAbsolute}));return[e?r.find(i=>i.id===e):r[0],r]}const Cb=(e,t,n,r)=>{const i=t.querySelectorAll(e);if(!i||!i.length)return null;const o=Array.from(i),a=t.getBoundingClientRect(),s={x:a.width*r[0],y:a.height*r[1]};return o.map(u=>{const c=u.getBoundingClientRect();return{id:u.getAttribute("data-handleid"),position:u.getAttribute("data-handlepos"),x:(c.left-a.left-s.x)/n,y:(c.top-a.top-s.y)/n,...Ec(u)}})};function Do(e,t,n){return n===void 0?n:r=>{const i=t().nodeInternals.get(e);n(r,{...i})}}function Bc({id:e,store:t,unselect:n=!1}){const{addSelectedNodes:r,unselectNodesAndEdges:i,multiSelectionActive:o,nodeInternals:a}=t.getState(),s=a.get(e);t.setState({nodesSelectionActive:!1}),s.selected?(n||s.selected&&o)&&i({nodes:[s]}):r([e])}function T5(){const e=Kt();return x.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:i,snapToGrid:o}=e.getState(),a=n.touches?n.touches[0].clientX:n.clientX,s=n.touches?n.touches[0].clientY:n.clientY,u={x:(a-r[0])/r[2],y:(s-r[1])/r[2]};return{xSnapped:o?i[0]*Math.round(u.x/i[0]):u.x,ySnapped:o?i[1]*Math.round(u.y/i[1]):u.y,...u}},[])}function jc(e){return(t,n,r)=>e==null?void 0:e(t,r)}function _b({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:o,selectNodesOnDrag:a}){const s=Kt(),[u,c]=x.useState(!1),f=x.useRef([]),h=x.useRef({x:null,y:null}),p=x.useRef(0),g=x.useRef(null),v=x.useRef({x:0,y:0}),m=x.useRef(null),w=x.useRef(!1),b=T5();return x.useEffect(()=>{if(e!=null&&e.current){const _=Cn(e.current),C=({x:E,y:k})=>{const{nodeInternals:A,onNodeDrag:L,onSelectionDrag:F,updateNodePositions:P,nodeExtent:O,snapGrid:N,snapToGrid:z,nodeOrigin:M,onError:$}=s.getState();h.current={x:E,y:k};let I=!1;if(f.current=f.current.map(B=>{const G={x:E-B.distance.x,y:k-B.distance.y};z&&(G.x=N[0]*Math.round(G.x/N[0]),G.y=N[1]*Math.round(G.y/N[1]));const K=Sb(B,G,A,O,M,$);return I=I||B.position.x!==K.position.x||B.position.y!==K.position.y,B.position=K.position,B.positionAbsolute=K.positionAbsolute,B}),!I)return;P(f.current,!0,!0),c(!0);const R=i?L:jc(F);if(R&&m.current){const[B,G]=Fc({nodeId:i,dragItems:f.current,nodeInternals:A});R(m.current,B,G)}},S=()=>{var A,L;if(!g.current)return;const[E,k]=$y(v.current,g.current);if(E!==0||k!==0){const{transform:F,panBy:P}=s.getState();h.current.x=((A=h.current.x)!=null?A:0)-E/F[2],h.current.y=((L=h.current.y)!=null?L:0)-k/F[2],C(h.current),P({x:E,y:k})}p.current=requestAnimationFrame(S)};if(t)_.on(".drag",null);else{const E=U3().on("start",k=>{var I;const{nodeInternals:A,multiSelectionActive:L,domNode:F,nodesDraggable:P,unselectNodesAndEdges:O,onNodeDragStart:N,onSelectionDragStart:z}=s.getState(),M=i?N:jc(z);!a&&!L&&i&&((I=A.get(i))!=null&&I.selected||O()),i&&o&&a&&Bc({id:i,store:s});const $=b(k);if(h.current=$,f.current=E5(A,P,$,i),M&&f.current){const[R,B]=Fc({nodeId:i,dragItems:f.current,nodeInternals:A});M(k.sourceEvent,R,B)}g.current=(F==null?void 0:F.getBoundingClientRect())||null,v.current=_r(k.sourceEvent,g.current)}).on("drag",k=>{const A=b(k),{autoPanOnNodeDrag:L}=s.getState();!w.current&&L&&(w.current=!0,S()),(h.current.x!==A.xSnapped||h.current.y!==A.ySnapped)&&f.current&&(m.current=k.sourceEvent,v.current=_r(k.sourceEvent,g.current),C(A))}).on("end",k=>{if(c(!1),w.current=!1,cancelAnimationFrame(p.current),f.current){const{updateNodePositions:A,nodeInternals:L,onNodeDragStop:F,onSelectionDragStop:P}=s.getState(),O=i?F:jc(P);if(A(f.current,!1,!1),O){const[N,z]=Fc({nodeId:i,dragItems:f.current,nodeInternals:L});O(k.sourceEvent,N,z)}}}).filter(k=>{const A=k.target;return!k.button&&(!n||!xb(A,`.${n}`,e))&&(!r||xb(A,r,e))});return _.call(E),()=>{_.on(".drag",null)}}}},[e,t,n,r,o,s,i,a,b]),u}function Eb(){const e=Kt();return x.useCallback(n=>{const{nodeInternals:r,nodeExtent:i,updateNodePositions:o,getNodes:a,snapToGrid:s,snapGrid:u,onError:c,nodesDraggable:f}=e.getState(),h=a().filter(_=>_.selected&&(_.draggable||f&&typeof _.draggable>"u")),p=s?u[0]:5,g=s?u[1]:5,v=n.isShiftPressed?4:1,m=n.x*p*v,w=n.y*g*v,b=h.map(_=>{if(_.positionAbsolute){const C={x:_.positionAbsolute.x+m,y:_.positionAbsolute.y+w};s&&(C.x=u[0]*Math.round(C.x/u[0]),C.y=u[1]*Math.round(C.y/u[1]));const{positionAbsolute:S,position:E}=Sb(_,C,r,i,void 0,c);_.position=E,_.positionAbsolute=S}return _});o(b,!0,!1)},[])}const Di={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Ro=e=>{const t=({id:n,type:r,data:i,xPos:o,yPos:a,xPosOrigin:s,yPosOrigin:u,selected:c,onClick:f,onMouseEnter:h,onMouseMove:p,onMouseLeave:g,onContextMenu:v,onDoubleClick:m,style:w,className:b,isDraggable:_,isSelectable:C,isConnectable:S,isFocusable:E,selectNodesOnDrag:k,sourcePosition:A,targetPosition:L,hidden:F,resizeObserver:P,dragHandle:O,zIndex:N,isParent:z,noDragClassName:M,noPanClassName:$,initialized:I,disableKeyboardA11y:R,ariaLabel:B,rfId:G})=>{const K=Kt(),W=x.useRef(null),ee=x.useRef(A),ne=x.useRef(L),U=x.useRef(r),X=C||_||f||h||p||g,ce=Eb(),ue=Do(n,K.getState,h),se=Do(n,K.getState,p),ae=Do(n,K.getState,g),xe=Do(n,K.getState,v),be=Do(n,K.getState,m),Y=q=>{if(C&&(!k||!_)&&Bc({id:n,store:K}),f){const we=K.getState().nodeInternals.get(n);f(q,{...we})}},re=q=>{var we;if(!Oc(q))if(By.includes(q.key)&&C){const ve=q.key==="Escape";ve&&((we=W.current)==null||we.blur()),Bc({id:n,store:K,unselect:ve})}else!R&&_&&c&&Object.prototype.hasOwnProperty.call(Di,q.key)&&(K.setState({ariaLiveMessage:`Moved selected node ${q.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~a}`}),ce({x:Di[q.key].x,y:Di[q.key].y,isShiftPressed:q.shiftKey}))};x.useEffect(()=>{if(W.current&&!F){const q=W.current;return P==null||P.observe(q),()=>P==null?void 0:P.unobserve(q)}},[F]),x.useEffect(()=>{const q=U.current!==r,we=ee.current!==A,ve=ne.current!==L;W.current&&(q||we||ve)&&(q&&(U.current=r),we&&(ee.current=A),ve&&(ne.current=L),K.getState().updateNodeDimensions([{id:n,nodeElement:W.current,forceUpdate:!0}]))},[n,r,A,L]);const Se=_b({nodeRef:W,disabled:F||!_,noDragClassName:M,handleSelector:O,nodeId:n,isSelectable:C,selectNodesOnDrag:k});return F?null:l("div",{className:Zt(["react-flow__node",`react-flow__node-${r}`,{[$]:_},b,{selected:c,selectable:C,parent:z,dragging:Se}]),ref:W,style:{zIndex:N,transform:`translate(${s}px,${u}px)`,pointerEvents:X?"all":"none",visibility:I?"visible":"hidden",...w},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:ue,onMouseMove:se,onMouseLeave:ae,onContextMenu:xe,onClick:Y,onDoubleClick:be,onKeyDown:E?re:void 0,tabIndex:E?0:void 0,role:E?"button":void 0,"aria-describedby":R?void 0:`${pb}-${G}`,"aria-label":B,children:l(XB,{value:n,children:l(e,{id:n,data:i,type:r,xPos:o,yPos:a,selected:c,isConnectable:S,sourcePosition:A,targetPosition:L,dragging:Se,dragHandle:O,zIndex:N})})})};return t.displayName="NodeWrapper",x.memo(t)};function M5(e){const t={input:Ro(e.input||lb),default:Ro(e.default||Vc),output:Ro(e.output||cb),group:Ro(e.group||zc)},n={},r=Object.keys(e).filter(i=>!["input","default","output","group"].includes(i)).reduce((i,o)=>(i[o]=Ro(e[o]||Vc),i),n);return{...t,...r}}const k5=({x:e,y:t,width:n,height:r,origin:i})=>!n||!r?{x:e,y:t}:i[0]<0||i[1]<0||i[0]>1||i[1]>1?{x:e,y:t}:{x:e-n*i[0],y:t-r*i[1]},O5=typeof document<"u"?document:null;var Ao=(e=null,t={target:O5})=>{const[n,r]=x.useState(!1),i=x.useRef(new Set([])),[o,a]=x.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.split("+")),c=u.reduce((f,h)=>f.concat(...h),[]);return[u,c]}return[[],[]]},[e]);return x.useEffect(()=>{var s,u;if(e!==null){const c=p=>{if(Oc(p))return!1;const g=Mb(p.code,a);i.current.add(p[g]),Tb(o,i.current,!1)&&(p.preventDefault(),r(!0))},f=p=>{if(Oc(p))return!1;const g=Mb(p.code,a);Tb(o,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(p[g])},h=()=>{i.current.clear(),r(!1)};return(s=t==null?void 0:t.target)==null||s.addEventListener("keydown",c),(u=t==null?void 0:t.target)==null||u.addEventListener("keyup",f),window.addEventListener("blur",h),()=>{var p,g;(p=t==null?void 0:t.target)==null||p.removeEventListener("keydown",c),(g=t==null?void 0:t.target)==null||g.removeEventListener("keyup",f),window.removeEventListener("blur",h)}}},[e,r]),n};function Tb(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function Mb(e,t){return t.includes(e)?"code":"key"}function kb(e,t,n,r){var a,s,u,c,f,h,p,g;if(!e.parentNode)return n;const i=t.get(e.parentNode),o=Kr(i,r);return kb(i,t,{x:((a=n.x)!=null?a:0)+o.x,y:((s=n.y)!=null?s:0)+o.y,z:((c=(u=i[jt])==null?void 0:u.z)!=null?c:0)>((f=n.z)!=null?f:0)?(p=(h=i[jt])==null?void 0:h.z)!=null?p:0:(g=n.z)!=null?g:0},r)}function Ob(e,t,n){e.forEach(r=>{var i,o;if(r.parentNode&&!e.has(r.parentNode))throw new Error(`Parent node ${r.parentNode} not found`);if(r.parentNode||(n==null?void 0:n[r.id])){const{x:a,y:s,z:u}=kb(r,e,{...r.position,z:(o=(i=r[jt])==null?void 0:i.z)!=null?o:0},t);r.positionAbsolute={x:a,y:s},r[jt].z=u,n!=null&&n[r.id]&&(r[jt].isParent=!0)}})}function Gc(e,t,n,r){const i=new Map,o={},a=r?1e3:0;return e.forEach(s=>{var h;const u=(_n(s.zIndex)?s.zIndex:0)+(s.selected?a:0),c=t.get(s.id),f={width:c==null?void 0:c.width,height:c==null?void 0:c.height,...s,positionAbsolute:{x:s.position.x,y:s.position.y}};s.parentNode&&(f.parentNode=s.parentNode,o[s.parentNode]=!0),Object.defineProperty(f,jt,{enumerable:!1,value:{handleBounds:(h=c==null?void 0:c[jt])==null?void 0:h.handleBounds,z:u}}),i.set(s.id,f)}),Ob(i,n,o),i}function Db(e,t={}){var p,g,v;const{getNodes:n,width:r,height:i,minZoom:o,maxZoom:a,d3Zoom:s,d3Selection:u,fitViewOnInitDone:c,fitViewOnInit:f,nodeOrigin:h}=e();if((t.initial&&!c&&f||!t.initial)&&s&&u){const m=n().filter(b=>t.includeHiddenNodes?b.width&&b.height:!b.hidden),w=m.every(b=>b.width&&b.height);if(m.length>0&&w){const b=$c(m,h),[_,C,S]=eb(b,r,i,(p=t.minZoom)!=null?p:o,(g=t.maxZoom)!=null?g:a,(v=t.padding)!=null?v:.1),E=sr.translate(_,C).scale(S);return typeof t.duration=="number"&&t.duration>0?s.transform(Hr(u,t.duration),E):s.transform(u,E),!0}}return!1}function D5(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[jt]:r[jt],selected:n.selected})}),new Map(t)}function R5(e,t){return t.map(n=>{const r=e.find(i=>i.id===n.id);return r&&(n.selected=r.selected),n})}function Ms({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:i,edges:o,onNodesChange:a,onEdgesChange:s,hasDefaultNodes:u,hasDefaultEdges:c}=n();e!=null&&e.length&&(u&&r({nodeInternals:D5(e,i)}),a==null||a(e)),t!=null&&t.length&&(c&&r({edges:R5(t,o)}),s==null||s(t))}const Wr=()=>{},A5={zoomIn:Wr,zoomOut:Wr,zoomTo:Wr,getZoom:()=>1,setViewport:Wr,getViewport:()=>({x:0,y:0,zoom:1}),fitView:Wr,setCenter:Wr,fitBounds:Wr,project:e=>e,viewportInitialized:!1},P5=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),I5=()=>{const e=Kt(),{d3Zoom:t,d3Selection:n}=Tt(P5,nn);return x.useMemo(()=>n&&t?{zoomIn:i=>t.scaleBy(Hr(n,i==null?void 0:i.duration),1.2),zoomOut:i=>t.scaleBy(Hr(n,i==null?void 0:i.duration),1/1.2),zoomTo:(i,o)=>t.scaleTo(Hr(n,o==null?void 0:o.duration),i),getZoom:()=>e.getState().transform[2],setViewport:(i,o)=>{var f,h,p;const[a,s,u]=e.getState().transform,c=sr.translate((f=i.x)!=null?f:a,(h=i.y)!=null?h:s).scale((p=i.zoom)!=null?p:u);t.transform(Hr(n,o==null?void 0:o.duration),c)},getViewport:()=>{const[i,o,a]=e.getState().transform;return{x:i,y:o,zoom:a}},fitView:i=>Db(e.getState,i),setCenter:(i,o,a)=>{const{width:s,height:u,maxZoom:c}=e.getState(),f=typeof(a==null?void 0:a.zoom)<"u"?a.zoom:c,h=s/2-i*f,p=u/2-o*f,g=sr.translate(h,p).scale(f);t.transform(Hr(n,a==null?void 0:a.duration),g)},fitBounds:(i,o)=>{var v;const{width:a,height:s,minZoom:u,maxZoom:c}=e.getState(),[f,h,p]=eb(i,a,s,u,c,(v=o==null?void 0:o.padding)!=null?v:.1),g=sr.translate(f,h).scale(p);t.transform(Hr(n,o==null?void 0:o.duration),g)},project:i=>{const{transform:o,snapToGrid:a,snapGrid:s}=e.getState();return Qy(i,o,a,s)},viewportInitialized:!0}:A5,[t,n])};function Kc(){const e=I5(),t=Kt(),n=x.useCallback(()=>t.getState().getNodes().map(m=>({...m})),[]),r=x.useCallback(m=>t.getState().nodeInternals.get(m),[]),i=x.useCallback(()=>{const{edges:m=[]}=t.getState();return m.map(w=>({...w}))},[]),o=x.useCallback(m=>{const{edges:w=[]}=t.getState();return w.find(b=>b.id===m)},[]),a=x.useCallback(m=>{const{getNodes:w,setNodes:b,hasDefaultNodes:_,onNodesChange:C}=t.getState(),S=w(),E=typeof m=="function"?m(S):m;if(_)b(E);else if(C){const k=E.length===0?S.map(A=>({type:"remove",id:A.id})):E.map(A=>({item:A,type:"reset"}));C(k)}},[]),s=x.useCallback(m=>{const{edges:w=[],setEdges:b,hasDefaultEdges:_,onEdgesChange:C}=t.getState(),S=typeof m=="function"?m(w):m;if(_)b(S);else if(C){const E=S.length===0?w.map(k=>({type:"remove",id:k.id})):S.map(k=>({item:k,type:"reset"}));C(E)}},[]),u=x.useCallback(m=>{const w=Array.isArray(m)?m:[m],{getNodes:b,setNodes:_,hasDefaultNodes:C,onNodesChange:S}=t.getState();if(C){const k=[...b(),...w];_(k)}else if(S){const E=w.map(k=>({item:k,type:"add"}));S(E)}},[]),c=x.useCallback(m=>{const w=Array.isArray(m)?m:[m],{edges:b=[],setEdges:_,hasDefaultEdges:C,onEdgesChange:S}=t.getState();if(C)_([...b,...w]);else if(S){const E=w.map(k=>({item:k,type:"add"}));S(E)}},[]),f=x.useCallback(()=>{const{getNodes:m,edges:w=[],transform:b}=t.getState(),[_,C,S]=b;return{nodes:m().map(E=>({...E})),edges:w.map(E=>({...E})),viewport:{x:_,y:C,zoom:S}}},[]),h=x.useCallback(({nodes:m,edges:w})=>{const{nodeInternals:b,getNodes:_,edges:C,hasDefaultNodes:S,hasDefaultEdges:E,onNodesDelete:k,onEdgesDelete:A,onNodesChange:L,onEdgesChange:F}=t.getState(),P=(m||[]).map($=>$.id),O=(w||[]).map($=>$.id),N=_().reduce(($,I)=>{const R=!P.includes(I.id)&&I.parentNode&&$.find(G=>G.id===I.parentNode);return(typeof I.deletable=="boolean"?I.deletable:!0)&&(P.includes(I.id)||R)&&$.push(I),$},[]),z=C.filter($=>typeof $.deletable=="boolean"?$.deletable:!0),M=z.filter($=>O.includes($.id));if(N||M){const $=Jy(N,z),I=[...M,...$],R=I.reduce((B,G)=>(B.includes(G.id)||B.push(G.id),B),[]);if((E||S)&&(E&&t.setState({edges:C.filter(B=>!R.includes(B.id))}),S&&(N.forEach(B=>{b.delete(B.id)}),t.setState({nodeInternals:new Map(b)}))),R.length>0&&(A==null||A(I),F&&F(R.map(B=>({id:B,type:"remove"})))),N.length>0&&(k==null||k(N),L)){const B=N.map(G=>({id:G.id,type:"remove"}));L(B)}}},[]),p=x.useCallback(m=>{const w=KB(m),b=w?null:t.getState().nodeInternals.get(m.id);return[w?m:Fy(b),b,w]},[]),g=x.useCallback((m,w=!0,b)=>{const[_,C,S]=p(m);return _?(b||t.getState().getNodes()).filter(E=>{if(!S&&(E.id===C.id||!E.positionAbsolute))return!1;const k=Fy(E),A=Mc(k,_);return w&&A>0||A>=m.width*m.height}):[]},[]),v=x.useCallback((m,w,b=!0)=>{const[_]=p(m);if(!_)return!1;const C=Mc(_,w);return b&&C>0||C>=m.width*m.height},[]);return x.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:i,getEdge:o,setNodes:a,setEdges:s,addNodes:u,addEdges:c,toObject:f,deleteElements:h,getIntersectingNodes:g,isNodeIntersecting:v}),[e,n,r,i,o,a,s,u,c,f,h,g,v])}var N5=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Kt(),{deleteElements:r}=Kc(),i=Ao(e),o=Ao(t);x.useEffect(()=>{if(i){const{edges:a,getNodes:s}=n.getState(),u=s().filter(f=>f.selected),c=a.filter(f=>f.selected);r({nodes:u,edges:c}),n.setState({nodesSelectionActive:!1})}},[i]),x.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function $5(e){const t=Kt();x.useEffect(()=>{let n;const r=()=>{var o,a;if(!e.current)return;const i=Ec(e.current);(i.height===0||i.width===0)&&((a=(o=t.getState()).onError)==null||a.call(o,"004",jn["004"]())),t.setState({width:i.width||500,height:i.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const Hc={position:"absolute",width:"100%",height:"100%",top:0,left:0},L5=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Wc=e=>({x:e.x,y:e.y,zoom:e.k}),Ri=(e,t)=>e.target.closest(`.${t}`),Rb=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),V5=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),z5=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:i=!0,zoomOnPinch:o=!0,panOnScroll:a=!1,panOnScrollSpeed:s=.5,panOnScrollMode:u=Ti.Free,zoomOnDoubleClick:c=!0,elementsSelectable:f,panOnDrag:h=!0,defaultViewport:p,translateExtent:g,minZoom:v,maxZoom:m,zoomActivationKeyCode:w,preventScrolling:b=!0,children:_,noWheelClassName:C,noPanClassName:S})=>{const E=x.useRef(),k=Kt(),A=x.useRef(!1),L=x.useRef(!1),F=x.useRef(null),P=x.useRef({x:0,y:0,zoom:0}),{d3Zoom:O,d3Selection:N,d3ZoomHandler:z,userSelectionActive:M}=Tt(V5,nn),$=Ao(w),I=x.useRef(0);return $5(F),x.useEffect(()=>{if(F.current){const R=F.current.getBoundingClientRect(),B=Py().scaleExtent([v,m]).translateExtent(g),G=Cn(F.current).call(B),K=sr.translate(p.x,p.y).scale(Ei(p.zoom,v,m)),W=[[0,0],[R.width,R.height]],ee=B.constrain()(K,W,g);B.transform(G,ee),k.setState({d3Zoom:B,d3Selection:G,d3ZoomHandler:G.on("wheel.zoom"),transform:[ee.x,ee.y,ee.k],domNode:F.current.closest(".react-flow")})}},[]),x.useEffect(()=>{N&&O&&(a&&!$&&!M?N.on("wheel.zoom",R=>{if(Ri(R,C))return!1;R.preventDefault(),R.stopImmediatePropagation();const B=N.property("__zoom").k||1;if(R.ctrlKey&&o){const ee=Dn(R),ne=-R.deltaY*(R.deltaMode===1?.05:R.deltaMode?1:.002)*10,U=B*Math.pow(2,ne);O.scaleTo(N,U,ee);return}const G=R.deltaMode===1?20:1,K=u===Ti.Vertical?0:R.deltaX*G,W=u===Ti.Horizontal?0:R.deltaY*G;O.translateBy(N,-(K/B)*s,-(W/B)*s)}):typeof z<"u"&&N.on("wheel.zoom",function(R,B){if(!b||Ri(R,C))return null;R.preventDefault(),z.call(this,R,B)}))},[M,a,u,N,O,z,$,o,b,C]),x.useEffect(()=>{O&&O.on("start",R=>{var G;if(!R.sourceEvent)return null;I.current=R.sourceEvent.button;const{onViewportChangeStart:B}=k.getState();if(A.current=!0,((G=R.sourceEvent)==null?void 0:G.type)==="mousedown"&&k.setState({paneDragging:!0}),t||B){const K=Wc(R.transform);P.current=K,B==null||B(K),t==null||t(R.sourceEvent,K)}})},[O,t]),x.useEffect(()=>{O&&(M&&!A.current?O.on("zoom",null):M||O.on("zoom",R=>{var G;const{onViewportChange:B}=k.getState();if(k.setState({transform:[R.transform.x,R.transform.y,R.transform.k]}),L.current=!!(r&&Rb(h,(G=I.current)!=null?G:0)),e||B){const K=Wc(R.transform);B==null||B(K),e==null||e(R.sourceEvent,K)}}))},[M,O,e,h,r]),x.useEffect(()=>{O&&O.on("end",R=>{var G;if(!R.sourceEvent)return null;const{onViewportChangeEnd:B}=k.getState();if(A.current=!1,k.setState({paneDragging:!1}),r&&Rb(h,(G=I.current)!=null?G:0)&&!L.current&&r(R.sourceEvent),L.current=!1,(n||B)&&L5(P.current,R.transform)){const K=Wc(R.transform);P.current=K,clearTimeout(E.current),E.current=setTimeout(()=>{B==null||B(K),n==null||n(R.sourceEvent,K)},a?150:0)}})},[O,a,h,n,r]),x.useEffect(()=>{O&&O.filter(R=>{const B=$||i,G=o&&R.ctrlKey;if(R.button===1&&R.type==="mousedown"&&(Ri(R,"react-flow__node")||Ri(R,"react-flow__edge")))return!0;if(!h&&!B&&!a&&!c&&!o||M||!c&&R.type==="dblclick"||Ri(R,C)&&R.type==="wheel"||Ri(R,S)&&R.type!=="wheel"||!o&&R.ctrlKey&&R.type==="wheel"||!B&&!a&&!G&&R.type==="wheel"||!h&&(R.type==="mousedown"||R.type==="touchstart")||Array.isArray(h)&&!h.includes(R.button)&&(R.type==="mousedown"||R.type==="touchstart"))return!1;const K=Array.isArray(h)&&h.includes(R.button)||!R.button||R.button<=1;return(!R.ctrlKey||R.type==="wheel")&&K})},[M,O,i,o,a,c,h,f,$]),l("div",{className:"react-flow__renderer",ref:F,style:Hc,children:_})},F5=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function B5(){const{userSelectionActive:e,userSelectionRect:t}=Tt(F5,nn);return e&&t?l("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function Ab(e,t){var r,i;const n=e.find(o=>o.id===t.parentNode);if(n){const o=t.position.x+t.width-n.width,a=t.position.y+t.height-n.height;if(o>0||a>0||t.position.x<0||t.position.y<0){if(n.style={...n.style},n.style.width=(r=n.style.width)!=null?r:n.width,n.style.height=(i=n.style.height)!=null?i:n.height,o>0&&(n.style.width+=o),a>0&&(n.style.height+=a),t.position.x<0){const s=Math.abs(t.position.x);n.position.x=n.position.x-s,n.style.width+=s,t.position.x=0}if(t.position.y<0){const s=Math.abs(t.position.y);n.position.y=n.position.y-s,n.style.height+=s,t.position.y=0}n.width=n.style.width,n.height=n.style.height}}}function j5(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,i)=>{const o=e.filter(s=>s.id===i.id);if(o.length===0)return r.push(i),r;const a={...i};for(const s of o)if(s)switch(s.type){case"select":{a.selected=s.selected;break}case"position":{typeof s.position<"u"&&(a.position=s.position),typeof s.positionAbsolute<"u"&&(a.positionAbsolute=s.positionAbsolute),typeof s.dragging<"u"&&(a.dragging=s.dragging),a.expandParent&&Ab(r,a);break}case"dimensions":{typeof s.dimensions<"u"&&(a.width=s.dimensions.width,a.height=s.dimensions.height),typeof s.updateStyle<"u"&&(a.style={...a.style||{},...s.dimensions}),typeof s.resizing=="boolean"&&(a.resizing=s.resizing),a.expandParent&&Ab(r,a);break}case"remove":return r}return r.push(a),r},n)}function G5(e,t){return j5(e,t)}const Tr=(e,t)=>({id:e,type:"select",selected:t});function Ai(e,t){return e.reduce((n,r)=>{const i=t.includes(r.id);return!r.selected&&i?(r.selected=!0,n.push(Tr(r.id,!0))):r.selected&&!i&&(r.selected=!1,n.push(Tr(r.id,!1))),n},[])}const qc=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},K5=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),Pb=x.memo(({isSelecting:e,selectionMode:t=Oo.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:i,onPaneClick:o,onPaneContextMenu:a,onPaneScroll:s,onPaneMouseEnter:u,onPaneMouseMove:c,onPaneMouseLeave:f,children:h})=>{const p=x.useRef(null),g=Kt(),v=x.useRef(0),m=x.useRef(0),w=x.useRef(),{userSelectionActive:b,elementsSelectable:_,dragging:C}=Tt(K5,nn),S=()=>{g.setState({userSelectionActive:!1,userSelectionRect:null}),v.current=0,m.current=0},E=z=>{o==null||o(z),g.getState().resetSelectedElements(),g.setState({nodesSelectionActive:!1})},k=z=>{if(Array.isArray(n)&&(n==null?void 0:n.includes(2))){z.preventDefault();return}a==null||a(z)},A=s?z=>s(z):void 0,L=z=>{const{resetSelectedElements:M,domNode:$}=g.getState();if(w.current=$==null?void 0:$.getBoundingClientRect(),!_||!e||z.button!==0||z.target!==p.current||!w.current)return;const{x:I,y:R}=_r(z,w.current);M(),g.setState({userSelectionRect:{width:0,height:0,startX:I,startY:R,x:I,y:R}}),r==null||r(z)},F=z=>{var xe,be;const{userSelectionRect:M,nodeInternals:$,edges:I,transform:R,onNodesChange:B,onEdgesChange:G,nodeOrigin:K,getNodes:W}=g.getState();if(!e||!w.current||!M)return;g.setState({userSelectionActive:!0,nodesSelectionActive:!1});const ee=_r(z,w.current),ne=(xe=M.startX)!=null?xe:0,U=(be=M.startY)!=null?be:0,X={...M,x:ee.x<ne?ee.x:ne,y:ee.y<U?ee.y:U,width:Math.abs(ee.x-ne),height:Math.abs(ee.y-U)},ce=W(),ue=Zy($,X,R,t===Oo.Partial,!0,K),se=Jy(ue,I).map(Y=>Y.id),ae=ue.map(Y=>Y.id);if(v.current!==ae.length){v.current=ae.length;const Y=Ai(ce,ae);Y.length&&(B==null||B(Y))}if(m.current!==se.length){m.current=se.length;const Y=Ai(I,se);Y.length&&(G==null||G(Y))}g.setState({userSelectionRect:X})},P=z=>{if(z.button!==0)return;const{userSelectionRect:M}=g.getState();!b&&M&&z.target===p.current&&(E==null||E(z)),g.setState({nodesSelectionActive:v.current>0}),S(),i==null||i(z)},O=z=>{b&&(g.setState({nodesSelectionActive:v.current>0}),i==null||i(z)),S()},N=_&&(e||b);return y("div",{className:Zt(["react-flow__pane",{dragging:C,selection:e}]),onClick:N?void 0:qc(E,p),onContextMenu:qc(k,p),onWheel:qc(A,p),onMouseEnter:N?void 0:u,onMouseDown:N?L:void 0,onMouseMove:N?F:c,onMouseUp:N?P:void 0,onMouseLeave:N?O:f,ref:p,style:Hc,children:[h,l(B5,{})]})});Pb.displayName="Pane";const H5=e=>{const t=e.getNodes().filter(n=>n.selected);return{...$c(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function W5({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Kt(),{width:i,height:o,x:a,y:s,transformString:u,userSelectionActive:c}=Tt(H5,nn),f=Eb(),h=x.useRef(null);if(x.useEffect(()=>{var v;n||(v=h.current)==null||v.focus({preventScroll:!0})},[n]),_b({nodeRef:h}),c||!i||!o)return null;const p=e?v=>{const m=r.getState().getNodes().filter(w=>w.selected);e(v,m)}:void 0,g=v=>{Object.prototype.hasOwnProperty.call(Di,v.key)&&f({x:Di[v.key].x,y:Di[v.key].y,isShiftPressed:v.shiftKey})};return l("div",{className:Zt(["react-flow__nodesselection","react-flow__container",t]),style:{transform:u},children:l("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:g,style:{width:i,height:o,top:s,left:a}})})}var q5=x.memo(W5);const U5=e=>e.nodesSelectionActive,Ib=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:a,deleteKeyCode:s,onMove:u,onMoveStart:c,onMoveEnd:f,selectionKeyCode:h,selectionOnDrag:p,selectionMode:g,onSelectionStart:v,onSelectionEnd:m,multiSelectionKeyCode:w,panActivationKeyCode:b,zoomActivationKeyCode:_,elementsSelectable:C,zoomOnScroll:S,zoomOnPinch:E,panOnScroll:k,panOnScrollSpeed:A,panOnScrollMode:L,zoomOnDoubleClick:F,panOnDrag:P,defaultViewport:O,translateExtent:N,minZoom:z,maxZoom:M,preventScrolling:$,onSelectionContextMenu:I,noWheelClassName:R,noPanClassName:B,disableKeyboardA11y:G})=>{const K=Tt(U5),W=Ao(h),ne=Ao(b)||P,U=W||p&&ne!==!0;return N5({deleteKeyCode:s,multiSelectionKeyCode:w}),l(z5,{onMove:u,onMoveStart:c,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:C,zoomOnScroll:S,zoomOnPinch:E,panOnScroll:k,panOnScrollSpeed:A,panOnScrollMode:L,zoomOnDoubleClick:F,panOnDrag:!W&&ne,defaultViewport:O,translateExtent:N,minZoom:z,maxZoom:M,zoomActivationKeyCode:_,preventScrolling:$,noWheelClassName:R,noPanClassName:B,children:y(Pb,{onSelectionStart:v,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:ne,isSelecting:!!U,selectionMode:g,children:[e,K&&l(q5,{onSelectionContextMenu:I,noPanClassName:B,disableKeyboardA11y:G})]})})};Ib.displayName="FlowRenderer";var Y5=x.memo(Ib);function X5(e){return Tt(x.useCallback(n=>e?Zy(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}const Q5=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),Nb=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,updateNodeDimensions:o,onError:a}=Tt(Q5,nn),s=X5(e.onlyRenderVisibleElements),u=x.useRef(),c=x.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(h=>{const p=h.map(g=>({id:g.target.getAttribute("data-id"),nodeElement:g.target,forceUpdate:!0}));o(p)});return u.current=f,f},[]);return x.useEffect(()=>()=>{var f;(f=u==null?void 0:u.current)==null||f.disconnect()},[]),l("div",{className:"react-flow__nodes",style:Hc,children:s.map(f=>{var E,k,A,L,F,P,O;let h=f.type||"default";e.nodeTypes[h]||(a==null||a("003",jn["003"](h)),h="default");const p=e.nodeTypes[h]||e.nodeTypes.default,g=!!(f.draggable||t&&typeof f.draggable>"u"),v=!!(f.selectable||i&&typeof f.selectable>"u"),m=!!(f.connectable||n&&typeof f.connectable>"u"),w=!!(f.focusable||r&&typeof f.focusable>"u"),b=e.nodeExtent?Tc(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,_=(E=b==null?void 0:b.x)!=null?E:0,C=(k=b==null?void 0:b.y)!=null?k:0,S=k5({x:_,y:C,width:(A=f.width)!=null?A:0,height:(L=f.height)!=null?L:0,origin:e.nodeOrigin});return l(p,{id:f.id,className:f.className,style:f.style,type:h,data:f.data,sourcePosition:f.sourcePosition||Me.Bottom,targetPosition:f.targetPosition||Me.Top,hidden:f.hidden,xPos:_,yPos:C,xPosOrigin:S.x,yPosOrigin:S.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!f.selected,isDraggable:g,isSelectable:v,isConnectable:m,isFocusable:w,resizeObserver:c,dragHandle:f.dragHandle,zIndex:(P=(F=f[jt])==null?void 0:F.z)!=null?P:0,isParent:!!((O=f[jt])!=null&&O.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel},f.id)})})};Nb.displayName="NodeRenderer";var Z5=x.memo(Nb);const J5=[{level:0,isMaxLevel:!0,edges:[]}];function ej(e,t,n=!1){let r=-1;const i=e.reduce((a,s)=>{var f,h,p,g;const u=_n(s.zIndex);let c=u?s.zIndex:0;return n&&(c=u?s.zIndex:Math.max(((h=(f=t.get(s.source))==null?void 0:f[jt])==null?void 0:h.z)||0,((g=(p=t.get(s.target))==null?void 0:p[jt])==null?void 0:g.z)||0)),a[c]?a[c].push(s):a[c]=[s],r=c>r?c:r,a},{}),o=Object.entries(i).map(([a,s])=>{const u=+a;return{edges:s,level:u,isMaxLevel:u===r}});return o.length===0?J5:o}function tj(e,t,n){const r=Tt(x.useCallback(i=>e?i.edges.filter(o=>{const a=t.get(o.source),s=t.get(o.target);return(a==null?void 0:a.width)&&(a==null?void 0:a.height)&&(s==null?void 0:s.width)&&(s==null?void 0:s.height)&&_5({sourcePos:a.positionAbsolute||{x:0,y:0},targetPos:s.positionAbsolute||{x:0,y:0},sourceWidth:a.width,sourceHeight:a.height,targetWidth:s.width,targetHeight:s.height,width:i.width,height:i.height,transform:i.transform})}):i.edges,[e,t]));return ej(r,t,n)}const nj=({color:e="none",strokeWidth:t=1})=>l("polyline",{stroke:e,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:t,fill:"none",points:"-5,-4 0,0 -5,4"}),rj=({color:e="none",strokeWidth:t=1})=>l("polyline",{stroke:e,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:t,fill:e,points:"-5,-4 0,0 -5,4 -5,-4"}),$b={[Ss.Arrow]:nj,[Ss.ArrowClosed]:rj};function ij(e){const t=Kt();return x.useMemo(()=>{var i,o;return Object.prototype.hasOwnProperty.call($b,e)?$b[e]:((o=(i=t.getState()).onError)==null||o.call(i,"009",jn["009"](e)),null)},[e])}const oj=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:o="strokeWidth",strokeWidth:a,orient:s="auto-start-reverse"})=>{const u=ij(t);return u?l("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:s,refX:"0",refY:"0",children:l(u,{color:n,strokeWidth:a})}):null},aj=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((i,o)=>([o.markerStart,o.markerEnd].forEach(a=>{if(a&&typeof a=="object"){const s=Nc(a,t);r.includes(s)||(i.push({id:s,color:a.color||e,...a}),r.push(s))}}),i),[]).sort((i,o)=>i.id.localeCompare(o.id))},Lb=({defaultColor:e,rfId:t})=>{const n=Tt(x.useCallback(aj({defaultColor:e,rfId:t}),[e,t]),(r,i)=>!(r.length!==i.length||r.some((o,a)=>o.id!==i[a].id)));return l("defs",{children:n.map(r=>l(oj,{id:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient},r.id))})};Lb.displayName="MarkerDefinitions";var sj=x.memo(Lb);const lj=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),Vb=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:i,noPanClassName:o,onEdgeUpdate:a,onEdgeContextMenu:s,onEdgeMouseEnter:u,onEdgeMouseMove:c,onEdgeMouseLeave:f,onEdgeClick:h,edgeUpdaterRadius:p,onEdgeDoubleClick:g,onEdgeUpdateStart:v,onEdgeUpdateEnd:m,children:w})=>{const{edgesFocusable:b,elementsSelectable:_,width:C,height:S,connectionMode:E,nodeInternals:k,onError:A}=Tt(lj,nn),L=tj(t,k,n);return C?y(Oe,{children:[L.map(({level:F,edges:P,isMaxLevel:O})=>y("svg",{style:{zIndex:F},width:C,height:S,className:"react-flow__edges react-flow__container",children:[O&&l(sj,{defaultColor:e,rfId:r}),l("g",{children:P.map(N=>{var be,Y;const[z,M,$]=bb(k.get(N.source)),[I,R,B]=bb(k.get(N.target));if(!$||!B)return null;let G=N.type||"default";i[G]||(A==null||A("011",jn["011"](G)),G="default");const K=i[G]||i.default,W=E===Gr.Strict?R.target:((be=R.target)!=null?be:[]).concat((Y=R.source)!=null?Y:[]),ee=yb(M.source,N.sourceHandle),ne=yb(W,N.targetHandle),U=(ee==null?void 0:ee.position)||Me.Bottom,X=(ne==null?void 0:ne.position)||Me.Top,ce=!!(N.focusable||b&&typeof N.focusable>"u");if(!ee||!ne)return A==null||A("008",jn["008"](ee,N)),null;const{sourceX:ue,sourceY:se,targetX:ae,targetY:xe}=C5(z,ee,U,I,ne,X);return l(K,{id:N.id,className:Zt([N.className,o]),type:G,data:N.data,selected:!!N.selected,animated:!!N.animated,hidden:!!N.hidden,label:N.label,labelStyle:N.labelStyle,labelShowBg:N.labelShowBg,labelBgStyle:N.labelBgStyle,labelBgPadding:N.labelBgPadding,labelBgBorderRadius:N.labelBgBorderRadius,style:N.style,source:N.source,target:N.target,sourceHandleId:N.sourceHandle,targetHandleId:N.targetHandle,markerEnd:N.markerEnd,markerStart:N.markerStart,sourceX:ue,sourceY:se,targetX:ae,targetY:xe,sourcePosition:U,targetPosition:X,elementsSelectable:_,onEdgeUpdate:a,onContextMenu:s,onMouseEnter:u,onMouseMove:c,onMouseLeave:f,onClick:h,edgeUpdaterRadius:p,onEdgeDoubleClick:g,onEdgeUpdateStart:v,onEdgeUpdateEnd:m,rfId:r,ariaLabel:N.ariaLabel,isFocusable:ce,pathOptions:"pathOptions"in N?N.pathOptions:void 0,interactionWidth:N.interactionWidth},N.id)})})]},F)),w]}):null};Vb.displayName="EdgeRenderer";var uj=x.memo(Vb);const cj=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function dj({children:e}){const t=Tt(cj);return l("div",{className:"react-flow__viewport react-flow__container",style:{transform:t},children:e})}function fj(e){const t=Kc(),n=x.useRef(!1);x.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const pj={[Me.Left]:Me.Right,[Me.Right]:Me.Left,[Me.Top]:Me.Bottom,[Me.Bottom]:Me.Top},zb=({nodeId:e,handleType:t,style:n,type:r=Er.Bezier,CustomComponent:i,connectionStatus:o})=>{var k,A,L,F,P,O,N;const{fromNode:a,handleId:s,toX:u,toY:c,connectionMode:f}=Tt(x.useCallback(z=>({fromNode:z.nodeInternals.get(e),handleId:z.connectionHandleId,toX:(z.connectionPosition.x-z.transform[0])/z.transform[2],toY:(z.connectionPosition.y-z.transform[1])/z.transform[2],connectionMode:z.connectionMode}),[e]),nn),h=(k=a==null?void 0:a[jt])==null?void 0:k.handleBounds;let p=h==null?void 0:h[t];if(f===Gr.Loose&&(p=p||(h==null?void 0:h[t==="source"?"target":"source"])),!a||!p)return null;const g=s?p.find(z=>z.id===s):p[0],v=g?g.x+g.width/2:((A=a.width)!=null?A:0)/2,m=g?g.y+g.height/2:(L=a.height)!=null?L:0,w=((P=(F=a.positionAbsolute)==null?void 0:F.x)!=null?P:0)+v,b=((N=(O=a.positionAbsolute)==null?void 0:O.y)!=null?N:0)+m,_=g==null?void 0:g.position,C=_?pj[_]:null;if(!_||!C)return null;if(i)return l(i,{connectionLineType:r,connectionLineStyle:n,fromNode:a,fromHandle:g,fromX:w,fromY:b,toX:u,toY:c,fromPosition:_,toPosition:C,connectionStatus:o});let S="";const E={sourceX:w,sourceY:b,sourcePosition:_,targetX:u,targetY:c,targetPosition:C};return r===Er.Bezier?[S]=Xy(E):r===Er.Step?[S]=Rc({...E,borderRadius:0}):r===Er.SmoothStep?[S]=Rc(E):r===Er.SimpleBezier?[S]=Wy(E):S=`M${w},${b} ${u},${c}`,l("path",{d:S,fill:"none",className:"react-flow__connection-path",style:n})};zb.displayName="ConnectionLine";const hj=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function gj({containerStyle:e,style:t,type:n,component:r}){const{nodeId:i,handleType:o,nodesConnectable:a,width:s,height:u,connectionStatus:c}=Tt(hj,nn);return!(i&&o&&s&&a)?null:l("svg",{style:e,width:s,height:u,className:"react-flow__edges react-flow__connectionline react-flow__container",children:l("g",{className:Zt(["react-flow__connection",c]),children:l(zb,{nodeId:i,handleType:o,style:t,type:n,CustomComponent:r,connectionStatus:c})})})}const Fb=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:i,onInit:o,onNodeClick:a,onEdgeClick:s,onNodeDoubleClick:u,onEdgeDoubleClick:c,onNodeMouseEnter:f,onNodeMouseMove:h,onNodeMouseLeave:p,onNodeContextMenu:g,onSelectionContextMenu:v,onSelectionStart:m,onSelectionEnd:w,connectionLineType:b,connectionLineStyle:_,connectionLineComponent:C,connectionLineContainerStyle:S,selectionKeyCode:E,selectionOnDrag:k,selectionMode:A,multiSelectionKeyCode:L,panActivationKeyCode:F,zoomActivationKeyCode:P,deleteKeyCode:O,onlyRenderVisibleElements:N,elementsSelectable:z,selectNodesOnDrag:M,defaultViewport:$,translateExtent:I,minZoom:R,maxZoom:B,preventScrolling:G,defaultMarkerColor:K,zoomOnScroll:W,zoomOnPinch:ee,panOnScroll:ne,panOnScrollSpeed:U,panOnScrollMode:X,zoomOnDoubleClick:ce,panOnDrag:ue,onPaneClick:se,onPaneMouseEnter:ae,onPaneMouseMove:xe,onPaneMouseLeave:be,onPaneScroll:Y,onPaneContextMenu:re,onEdgeUpdate:Se,onEdgeContextMenu:q,onEdgeMouseEnter:we,onEdgeMouseMove:ve,onEdgeMouseLeave:_e,edgeUpdaterRadius:ke,onEdgeUpdateStart:ge,onEdgeUpdateEnd:Ke,noDragClassName:Pe,noWheelClassName:Xe,noPanClassName:Ee,elevateEdgesOnSelect:Fe,disableKeyboardA11y:Le,nodeOrigin:Ve,nodeExtent:ct,rfId:at})=>(fj(o),l(Y5,{onPaneClick:se,onPaneMouseEnter:ae,onPaneMouseMove:xe,onPaneMouseLeave:be,onPaneContextMenu:re,onPaneScroll:Y,deleteKeyCode:O,selectionKeyCode:E,selectionOnDrag:k,selectionMode:A,onSelectionStart:m,onSelectionEnd:w,multiSelectionKeyCode:L,panActivationKeyCode:F,zoomActivationKeyCode:P,elementsSelectable:z,onMove:n,onMoveStart:r,onMoveEnd:i,zoomOnScroll:W,zoomOnPinch:ee,zoomOnDoubleClick:ce,panOnScroll:ne,panOnScrollSpeed:U,panOnScrollMode:X,panOnDrag:ue,defaultViewport:$,translateExtent:I,minZoom:R,maxZoom:B,onSelectionContextMenu:v,preventScrolling:G,noDragClassName:Pe,noWheelClassName:Xe,noPanClassName:Ee,disableKeyboardA11y:Le,children:y(dj,{children:[l(uj,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:c,onEdgeUpdate:Se,onlyRenderVisibleElements:N,onEdgeContextMenu:q,onEdgeMouseEnter:we,onEdgeMouseMove:ve,onEdgeMouseLeave:_e,onEdgeUpdateStart:ge,onEdgeUpdateEnd:Ke,edgeUpdaterRadius:ke,defaultMarkerColor:K,noPanClassName:Ee,elevateEdgesOnSelect:!!Fe,disableKeyboardA11y:Le,rfId:at,children:l(gj,{style:_,type:b,component:C,containerStyle:S})}),l("div",{className:"react-flow__edgelabel-renderer"}),l(Z5,{nodeTypes:e,onNodeClick:a,onNodeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:h,onNodeMouseLeave:p,onNodeContextMenu:g,selectNodesOnDrag:M,onlyRenderVisibleElements:N,noPanClassName:Ee,noDragClassName:Pe,disableKeyboardA11y:Le,nodeOrigin:Ve,nodeExtent:ct,rfId:at})]})}));Fb.displayName="GraphView";var vj=x.memo(Fb);const Uc=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Pi={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Uc,nodeExtent:Uc,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Gr.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,multiSelectionActive:!1,connectionStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:kc},mj=()=>Jz((e,t)=>({...Pi,setNodes:n=>{const{nodeInternals:r,nodeOrigin:i,elevateNodesOnSelect:o}=t();e({nodeInternals:Gc(n,r,i,o)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(i=>({...r,...i}))})},setDefaultNodesAndEdges:(n,r)=>{const i=typeof n<"u",o=typeof r<"u",a=i?Gc(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:a,edges:o?r:[],hasDefaultNodes:i,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:i,fitViewOnInit:o,fitViewOnInitDone:a,fitViewOnInitOptions:s,domNode:u,nodeOrigin:c}=t(),f=u==null?void 0:u.querySelector(".react-flow__viewport");if(!f)return;const h=window.getComputedStyle(f),{m22:p}=new window.DOMMatrixReadOnly(h.transform),g=n.reduce((m,w)=>{const b=i.get(w.id);if(b){const _=Ec(w.nodeElement);!!(_.width&&_.height&&(b.width!==_.width||b.height!==_.height||w.forceUpdate))&&(i.set(b.id,{...b,[jt]:{...b[jt],handleBounds:{source:Cb(".source",w.nodeElement,p,c),target:Cb(".target",w.nodeElement,p,c)}},..._}),m.push({id:b.id,type:"dimensions",dimensions:_}))}return m},[]);Ob(i,c);const v=a||o&&!a&&Db(t,{initial:!0,...s});e({nodeInternals:new Map(i),fitViewOnInitDone:v}),(g==null?void 0:g.length)>0&&(r==null||r(g))},updateNodePositions:(n,r=!0,i=!1)=>{const{triggerNodeChanges:o}=t(),a=n.map(s=>{const u={id:s.id,type:"position",dragging:i};return r&&(u.positionAbsolute=s.positionAbsolute,u.position=s.position),u});o(a)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:i,hasDefaultNodes:o,nodeOrigin:a,getNodes:s,elevateNodesOnSelect:u}=t();if(n!=null&&n.length){if(o){const c=G5(n,s()),f=Gc(c,i,a,u);e({nodeInternals:f})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:i,getNodes:o}=t();let a,s=null;r?a=n.map(u=>Tr(u,!0)):(a=Ai(o(),n),s=Ai(i,[])),Ms({changedNodes:a,changedEdges:s,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:i,getNodes:o}=t();let a,s=null;r?a=n.map(u=>Tr(u,!0)):(a=Ai(i,n),s=Ai(o(),[])),Ms({changedNodes:s,changedEdges:a,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:i,getNodes:o}=t(),a=n||o(),s=r||i,u=a.map(f=>(f.selected=!1,Tr(f.id,!1))),c=s.map(f=>Tr(f.id,!1));Ms({changedNodes:u,changedEdges:c,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:i}=t();r==null||r.scaleExtent([n,i]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:i}=t();r==null||r.scaleExtent([i,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;(r=t().d3Zoom)==null||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),o=r().filter(s=>s.selected).map(s=>Tr(s.id,!1)),a=n.filter(s=>s.selected).map(s=>Tr(s.id,!1));Ms({changedNodes:o,changedEdges:a,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(i=>{i.positionAbsolute=Tc(i.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:i,height:o,d3Zoom:a,d3Selection:s,translateExtent:u}=t();if(!a||!s||!n.x&&!n.y)return;const c=sr.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),f=[[0,0],[i,o]],h=a==null?void 0:a.constrain()(c,f,u);a.transform(s,h)},cancelConnection:()=>e({connectionNodeId:Pi.connectionNodeId,connectionHandleId:Pi.connectionHandleId,connectionHandleType:Pi.connectionHandleType,connectionStatus:Pi.connectionStatus}),reset:()=>e({...Pi})})),Bb=({children:e})=>{const t=x.useRef(null);return t.current||(t.current=mj()),l(VB,{value:t.current,children:e})};Bb.displayName="ReactFlowProvider";const jb=({children:e})=>x.useContext(ws)?l(Oe,{children:e}):l(Bb,{children:e});jb.displayName="ReactFlowWrapper";function Gb(e,t){const n=x.useRef(null);return x.useMemo(()=>{if(process.env.NODE_ENV==="development"){const i=Object.keys(e);nn(n.current,i)&&kc("002",jn["002"]()),n.current=i}return t(e)},[e])}const yj={input:lb,default:Vc,output:cb,group:zc},bj={default:Es,straight:Pc,step:Ac,smoothstep:Cs,simplebezier:Dc},wj=[0,0],xj=[15,15],Sj={x:0,y:0,zoom:1},Cj={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Kb=x.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:o=yj,edgeTypes:a=bj,onNodeClick:s,onEdgeClick:u,onInit:c,onMove:f,onMoveStart:h,onMoveEnd:p,onConnect:g,onConnectStart:v,onConnectEnd:m,onClickConnectStart:w,onClickConnectEnd:b,onNodeMouseEnter:_,onNodeMouseMove:C,onNodeMouseLeave:S,onNodeContextMenu:E,onNodeDoubleClick:k,onNodeDragStart:A,onNodeDrag:L,onNodeDragStop:F,onNodesDelete:P,onEdgesDelete:O,onSelectionChange:N,onSelectionDragStart:z,onSelectionDrag:M,onSelectionDragStop:$,onSelectionContextMenu:I,onSelectionStart:R,onSelectionEnd:B,connectionMode:G=Gr.Strict,connectionLineType:K=Er.Bezier,connectionLineStyle:W,connectionLineComponent:ee,connectionLineContainerStyle:ne,deleteKeyCode:U="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:ce=!1,selectionMode:ue=Oo.Full,panActivationKeyCode:se="Space",multiSelectionKeyCode:ae="Meta",zoomActivationKeyCode:xe="Meta",snapToGrid:be=!1,snapGrid:Y=xj,onlyRenderVisibleElements:re=!1,selectNodesOnDrag:Se=!0,nodesDraggable:q,nodesConnectable:we,nodesFocusable:ve,nodeOrigin:_e=wj,edgesFocusable:ke,elementsSelectable:ge,defaultViewport:Ke=Sj,minZoom:Pe=.5,maxZoom:Xe=2,translateExtent:Ee=Uc,preventScrolling:Fe=!0,nodeExtent:Le,defaultMarkerColor:Ve="#b1b1b7",zoomOnScroll:ct=!0,zoomOnPinch:at=!0,panOnScroll:We=!1,panOnScrollSpeed:st=.5,panOnScrollMode:Ce=Ti.Free,zoomOnDoubleClick:Ie=!0,panOnDrag:et=!0,onPaneClick:Mt,onPaneMouseEnter:lt,onPaneMouseMove:kt,onPaneMouseLeave:dt,onPaneScroll:Gt,onPaneContextMenu:Ot,children:bt,onEdgeUpdate:_t,onEdgeContextMenu:Ht,onEdgeDoubleClick:vt,onEdgeMouseEnter:cn,onEdgeMouseMove:Vt,onEdgeMouseLeave:ie,onEdgeUpdateStart:pe,onEdgeUpdateEnd:me,edgeUpdaterRadius:Ae=10,onNodesChange:Qe,onEdgesChange:ft,noDragClassName:Wt="nodrag",noWheelClassName:qt="nowheel",noPanClassName:dn="nopan",fitView:xt=!1,fitViewOptions:V,connectOnClick:J=!0,attributionPosition:Q,proOptions:he,defaultEdgeOptions:ye,elevateNodesOnSelect:Te=!0,elevateEdgesOnSelect:Ne=!1,disableKeyboardA11y:De=!1,autoPanOnConnect:Ge=!0,autoPanOnNodeDrag:ze=!0,connectionRadius:qe=20,onError:Ct,style:rn,id:vn,...Dt},Gn)=>{const lr=Gb(o,M5),an=Gb(a,S5),sn=vn||"1";return l("div",{...Dt,style:{...rn,...Cj},ref:Gn,className:Zt(["react-flow",i]),"data-testid":"rf__wrapper",id:vn,children:y(jb,{children:[l(vj,{onInit:c,onMove:f,onMoveStart:h,onMoveEnd:p,onNodeClick:s,onEdgeClick:u,onNodeMouseEnter:_,onNodeMouseMove:C,onNodeMouseLeave:S,onNodeContextMenu:E,onNodeDoubleClick:k,nodeTypes:lr,edgeTypes:an,connectionLineType:K,connectionLineStyle:W,connectionLineComponent:ee,connectionLineContainerStyle:ne,selectionKeyCode:X,selectionOnDrag:ce,selectionMode:ue,deleteKeyCode:U,multiSelectionKeyCode:ae,panActivationKeyCode:se,zoomActivationKeyCode:xe,onlyRenderVisibleElements:re,selectNodesOnDrag:Se,defaultViewport:Ke,translateExtent:Ee,minZoom:Pe,maxZoom:Xe,preventScrolling:Fe,zoomOnScroll:ct,zoomOnPinch:at,zoomOnDoubleClick:Ie,panOnScroll:We,panOnScrollSpeed:st,panOnScrollMode:Ce,panOnDrag:et,onPaneClick:Mt,onPaneMouseEnter:lt,onPaneMouseMove:kt,onPaneMouseLeave:dt,onPaneScroll:Gt,onPaneContextMenu:Ot,onSelectionContextMenu:I,onSelectionStart:R,onSelectionEnd:B,onEdgeUpdate:_t,onEdgeContextMenu:Ht,onEdgeDoubleClick:vt,onEdgeMouseEnter:cn,onEdgeMouseMove:Vt,onEdgeMouseLeave:ie,onEdgeUpdateStart:pe,onEdgeUpdateEnd:me,edgeUpdaterRadius:Ae,defaultMarkerColor:Ve,noDragClassName:Wt,noWheelClassName:qt,noPanClassName:dn,elevateEdgesOnSelect:Ne,rfId:sn,disableKeyboardA11y:De,nodeOrigin:_e,nodeExtent:Le}),l(h5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:g,onConnectStart:v,onConnectEnd:m,onClickConnectStart:w,onClickConnectEnd:b,nodesDraggable:q,nodesConnectable:we,nodesFocusable:ve,edgesFocusable:ke,elementsSelectable:ge,elevateNodesOnSelect:Te,minZoom:Pe,maxZoom:Xe,nodeExtent:Le,onNodesChange:Qe,onEdgesChange:ft,snapToGrid:be,snapGrid:Y,connectionMode:G,translateExtent:Ee,connectOnClick:J,defaultEdgeOptions:ye,fitView:xt,fitViewOptions:V,onNodesDelete:P,onEdgesDelete:O,onNodeDragStart:A,onNodeDrag:L,onNodeDragStop:F,onSelectionDrag:M,onSelectionDragStart:z,onSelectionDragStop:$,noPanClassName:dn,nodeOrigin:_e,rfId:sn,autoPanOnConnect:Ge,autoPanOnNodeDrag:ze,onError:Ct,connectionRadius:qe}),l(f5,{onSelectionChange:N}),bt,l(FB,{proOptions:he,position:Q}),l(b5,{rfId:sn,disableKeyboardA11y:De})]})})});Kb.displayName="ReactFlow";const Hb=({id:e,x:t,y:n,width:r,height:i,style:o,color:a,strokeColor:s,strokeWidth:u,className:c,borderRadius:f,shapeRendering:h,onClick:p})=>{const{background:g,backgroundColor:v}=o||{},m=a||g||v;return l("rect",{className:Zt(["react-flow__minimap-node",c]),x:t,y:n,rx:f,ry:f,width:r,height:i,fill:m,stroke:s,strokeWidth:u,shapeRendering:h,onClick:p?w=>p(w,e):void 0})};Hb.displayName="MiniMapNode";var _j=x.memo(Hb);const Ej=200,Tj=150,Mj=e=>{const t=e.getNodes(),n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{nodes:t.filter(r=>!r.hidden&&r.width&&r.height),viewBB:n,boundingRect:t.length>0?GB($c(t,e.nodeOrigin),n):n,rfId:e.rfId,nodeOrigin:e.nodeOrigin}},Yc=e=>e instanceof Function?e:()=>e,kj="react-flow__minimap-desc";function Wb({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:i="",nodeBorderRadius:o=5,nodeStrokeWidth:a=2,maskColor:s="rgb(240, 240, 240, 0.6)",maskStrokeColor:u="none",maskStrokeWidth:c=1,position:f="bottom-right",onClick:h,onNodeClick:p,pannable:g=!1,zoomable:v=!1,ariaLabel:m="React Flow mini map"}){var ue,se;const w=Kt(),b=x.useRef(null),{boundingRect:_,viewBB:C,nodes:S,rfId:E,nodeOrigin:k}=Tt(Mj,nn),A=(ue=e==null?void 0:e.width)!=null?ue:Ej,L=(se=e==null?void 0:e.height)!=null?se:Tj,F=Yc(r),P=Yc(n),O=Yc(i),N=_.width/A,z=_.height/L,M=Math.max(N,z),$=M*A,I=M*L,R=5*M,B=_.x-($-_.width)/2-R,G=_.y-(I-_.height)/2-R,K=$+R*2,W=I+R*2,ee=typeof window>"u"||!!window.chrome?"crispEdges":"geometricPrecision",ne=`${kj}-${E}`,U=x.useRef(0);U.current=M,x.useEffect(()=>{if(b.current){const ae=Cn(b.current),xe=re=>{const{transform:Se,d3Selection:q,d3Zoom:we}=w.getState();if(re.sourceEvent.type!=="wheel"||!q||!we)return;const ve=-re.sourceEvent.deltaY*(re.sourceEvent.deltaMode===1?.05:re.sourceEvent.deltaMode?1:.002)*10,_e=Se[2]*Math.pow(2,ve);we.scaleTo(q,_e)},be=re=>{const{transform:Se,d3Selection:q,d3Zoom:we,translateExtent:ve,width:_e,height:ke}=w.getState();if(re.sourceEvent.type!=="mousemove"||!q||!we)return;const ge={x:Se[0]-re.sourceEvent.movementX*U.current*Math.max(1,Se[2]),y:Se[1]-re.sourceEvent.movementY*U.current*Math.max(1,Se[2])},Ke=[[0,0],[_e,ke]],Pe=sr.translate(ge.x,ge.y).scale(Se[2]),Xe=we.constrain()(Pe,Ke,ve);we.transform(q,Xe)},Y=Py().on("zoom",g?be:null).on("zoom.wheel",v?xe:null);return ae.call(Y),()=>{ae.on("zoom",null)}}},[g,v]);const X=h?ae=>{const xe=Dn(ae);h(ae,{x:xe[0],y:xe[1]})}:void 0,ce=p?(ae,xe)=>{const be=w.getState().nodeInternals.get(xe);p(ae,be)}:void 0;return l(_c,{position:f,style:e,className:Zt(["react-flow__minimap",t]),children:y("svg",{width:A,height:L,viewBox:`${B} ${G} ${K} ${W}`,role:"img","aria-labelledby":ne,ref:b,onClick:X,children:[m&&l("title",{id:ne,children:m}),S.map(ae=>{const{x:xe,y:be}=Kr(ae,k).positionAbsolute;return l(_j,{x:xe,y:be,width:ae.width,height:ae.height,style:ae.style,className:O(ae),color:F(ae),borderRadius:o,strokeColor:P(ae),strokeWidth:a,shapeRendering:ee,onClick:ce,id:ae.id},ae.id)}),l("path",{className:"react-flow__minimap-mask",d:`M${B-R},${G-R}h${K+R*2}v${W+R*2}h${-K-R*2}z
291
- M${C.x},${C.y}h${C.width}v${C.height}h${-C.width}z`,fill:s,fillRule:"evenodd",stroke:u,strokeWidth:c,pointerEvents:"none"})]})})}Wb.displayName="MiniMap";var Oj=x.memo(Wb);function Dj(){return l("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:l("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Rj(){return l("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:l("path",{d:"M0 0h32v4.2H0z"})})}function Aj(){return l("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:l("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function Pj(){return l("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Ij(){return l("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}const Po=({children:e,className:t,...n})=>l("button",{type:"button",className:Zt(["react-flow__controls-button",t]),...n,children:e});Po.displayName="ControlButton";const Nj=e=>e.nodesDraggable&&e.nodesConnectable&&e.elementsSelectable,qb=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:o,onZoomOut:a,onFitView:s,onInteractiveChange:u,className:c,children:f,position:h="bottom-left"})=>{const p=Kt(),[g,v]=x.useState(!1),m=Tt(Nj),{zoomIn:w,zoomOut:b,fitView:_}=Kc();if(x.useEffect(()=>{v(!0)},[]),!g)return null;const C=()=>{w(),o==null||o()},S=()=>{b(),a==null||a()},E=()=>{_(i),s==null||s()},k=()=>{p.setState({nodesDraggable:!m,nodesConnectable:!m,elementsSelectable:!m}),u==null||u(!m)};return y(_c,{className:Zt(["react-flow__controls",c]),position:h,style:e,children:[t&&y(Oe,{children:[l(Po,{onClick:C,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",children:l(Dj,{})}),l(Po,{onClick:S,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",children:l(Rj,{})})]}),n&&l(Po,{className:"react-flow__controls-fitview",onClick:E,title:"fit view","aria-label":"fit view",children:l(Aj,{})}),r&&l(Po,{className:"react-flow__controls-interactive",onClick:k,title:"toggle interactivity","aria-label":"toggle interactivity",children:m?l(Ij,{}):l(Pj,{})}),f]})};qb.displayName="Controls";var $j=x.memo(qb),Pn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Pn||(Pn={}));function Lj({color:e,dimensions:t,lineWidth:n}){return l("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function Vj({color:e,radius:t}){return l("circle",{cx:t,cy:t,r:t,fill:e})}const zj={[Pn.Dots]:"#91919a",[Pn.Lines]:"#eee",[Pn.Cross]:"#e2e2e2"},Fj={[Pn.Dots]:1,[Pn.Lines]:1,[Pn.Cross]:6},Bj=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Ub({variant:e=Pn.Dots,gap:t=20,size:n,lineWidth:r=1,color:i,style:o,className:a}){const s=x.useRef(null),{transform:u,patternId:c}=Tt(Bj,nn),f=i||zj[e],h=n||Fj[e],p=e===Pn.Dots,g=e===Pn.Cross,v=Array.isArray(t)?t:[t,t],m=[v[0]*u[2]||1,v[1]*u[2]||1],w=h*u[2],b=g?[w,w]:m,_=p?[w/2,w/2]:[b[0]/2,b[1]/2];return y("svg",{className:Zt(["react-flow__background",a]),style:{...o,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:s,children:[l("pattern",{id:c,x:u[0]%m[0],y:u[1]%m[1],width:m[0],height:m[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:p?l(Vj,{color:f,radius:w/2}):l(Lj,{dimensions:b,color:f,lineWidth:r})}),l("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${c})`})]})}Ub.displayName="Background";var jj=x.memo(Ub);const P6="";function Gj(e,t,n){const r=[],i=[];return e.current.forEach((o,a)=>{const s=o.panels.list.filter(u=>"__INTERACTIONS"in u.viz.conf);i.push(...s)}),i.forEach((o,a)=>{const s=t[o.id];s.data.interactions=fe.default.get(s,"data.interactions",[]);const{__INTERACTIONS:u,__OPERATIONS:c,__TRIGGERS:f}=o.viz.conf;Object.entries(c).forEach(([h,p])=>{const{schemaRef:g,data:v}=p,{config:m}=v;switch(g){case"builtin:op:open-link":let w=m.urlTemplate.substring(0,100);m.urlTemplate.length>=20&&(w+="..."),s.type="interaction",s.data.interactions.push({schemaRef:g,urlTemplate:m.urlTemplate,shortURLTemplate:w});return;case"builtin:op:open_view":r.push({id:`OPERATION--${h}`,source:o.id,target:m.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":s.type="interaction",s.data.interactions.push({schemaRef:g,filters:Object.keys(m.dictionary).map(b=>({key:b,label:n[b]}))});return;case"builtin:op:clear_filter_values":s.type="interaction",s.data.interactions.push({schemaRef:g,filters:m.filter_keys.map(b=>({key:b,label:n[b]}))});return;default:return}})}),r}function Kj(e,t){const n=e.filters.keyLabelMap;return{edges:Gj(e.views,t,n),edgeNodes:[]}}function Yb(e,t,n){return e*t+e*n}function Hj(e,t,n){return e*t+(e-1)*n}const Xc=25,Qc=40,Xb=25,Zc=350,Wj=150,qj=150,Qb=150,Uj=300,Jc=40,Zb=25,Yj=300;function Xj(e){const t=[];return e.current.forEach((n,r)=>{n.panels.list.forEach((i,o)=>{const a=Yb(o,Jc,Zb)+Qc,s=i.title.trim()?`${i.title}`:i.viz.type;t.push({id:i.id,_node_type:"panel",parentNode:n.id,data:{label:s},position:{x:Xc,y:a},sourcePosition:Me.Right,targetPosition:Me.Left,style:{width:Uj,height:Jc}})})}),t}const Qj={[rt.Division]:"Div",[rt.Modal]:"Modal",[rt.Tabs]:"Tabs"},Zj=tm;function Jj(e){return e.current.map((n,r)=>{const i=Hj(n.panels.list.length,Jc,Zb)+Qc+Xb;let o=[];return n.type===rt.Tabs&&(o=n.config.tabs.map(s=>s.view_id)),{id:n.id,_node_type:"view-root",_view_type:n.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:o,data:{label:`${Qj[n.type]}:${n.name}`},position:{x:0,y:0},sourcePosition:Me.Right,targetPosition:Me.Left,className:"light",style:{backgroundColor:Zj[n.type],width:Zc,height:i}}})}function eG(e){const t=fe.default.keyBy(e,n=>n.id);e.forEach(n=>{n._node_type!=="view-root"||n._view_type!==rt.Tabs||n._tab_view_ids.forEach(r=>{t[r].parentNode=n.id})})}function tG(e){const t=Jj(e.views);eG(t);const n=Xj(e.views);return[...t,...n]}function nG({nodeMap:e,nodes:t,edges:n}){t.forEach(r=>{r._node_type!=="view-root"||r._view_type!==rt.Tabs||(r.sourcePosition=Me.Bottom,r.style.width=Zc+Xc*2,r.style.height=Xb+r._tab_view_ids.reduce((i,o)=>{const a=e[o];a.position.y=i,a.position.x=Xc;const s=a.style.height;return i+s+20},Qc))})}function rG({nodeMap:e,nodes:t,edges:n}){n.filter(r=>r.label==="Open View").forEach(r=>{const i=e[r.source],o=e[r.target];if(!i||!o||!i.parentNode)return;const a=e[i.parentNode];a._node_type!=="view-root"||o._node_type!=="view-root"||(o._view_level+=1+a._view_level,a._sub_view_ids.push(o.id))}),t.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 iG({nodeMap:e,nodes:t,edges:n}){const r={};n.forEach(i=>{if(i.label!=="Open View")return;const o=e[i.source],a=e[i.target];if(o&&a&&o.parentNode){const s=e[o.parentNode],u=s.position.x,c=fe.default.get(a,"style.height",0),f=Number(s.style.width);a.position.x=u+f+Yj,s._view_level===0&&a._sub_view_ids.length===0&&(o.sourcePosition=Me.Left,a.targetPosition=Me.Right,a.position.x*=-1);const p=a.position.x,g=fe.default.get(r,p,0);a.position.y=g,r[p]=g+c+Qb}})}function oG({nodeMap:e,nodes:t,edges:n}){const r=new Set,i=new Set;n.forEach(a=>{r.add(a.source),i.add(a.target)}),t.filter(a=>a._node_type!=="view-root"||a.id==="Main"||a.parentNode?!1:!r.has(a.id)&&!i.has(a.id)).forEach((a,s)=>{a.position.x=Yb(s,Zc,qj),a.position.y=0-Wj-Qb})}function aG({nodeMap:e,nodes:t,edges:n}){const r={nodeMap:e,nodes:t,edges:n};return oG(r),rG(r),nG(r),iG(r),{nodes:t,edges:n}}function sG(e){const t=tG(e),n=fe.default.keyBy(t,u=>u.id),{edges:r,edgeNodes:i}=Kj(e,n),o=[...t,...i],a=fe.default.keyBy(o,u=>u.id),s={edges:fe.default.uniqBy(r,u=>u.id),nodes:o,nodeMap:a};return aG(s)}const I6="",ed={"builtin:op:open-link":l(d.ThemeIcon,{color:"blue",size:20,radius:"xl",children:l(QP,{size:14})}),"builtin:op:set_filter_values":l(d.ThemeIcon,{color:"orange",size:20,radius:"xl",children:l(JP,{size:14})}),"builtin:op:clear_filter_values":l(d.ThemeIcon,{color:"orange",size:20,radius:"xl",children:l(tI,{size:14})})};function lG(e){const t=[];return e.forEach(n=>{switch(n.schemaRef){case"builtin:op:open-link":t.push({key:n.urlTemplate,icon:ed[n.schemaRef],text:y(d.Group,{spacing:4,children:[l(d.Text,{children:"Open: "}),l(d.Text,{color:"dimmed",children:n.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":n.filters.forEach(({key:r,label:i})=>{t.push({key:n.schemaRef+r,icon:ed[n.schemaRef],text:l(d.Group,{spacing:4,children:y(d.Text,{children:["Set Filter: ",i]})})})});return;case"builtin:op:clear_filter_values":n.filters.forEach(({key:r,label:i})=>{t.push({key:n.schemaRef+r,icon:ed[n.schemaRef],text:l(d.Group,{spacing:4,children:y(d.Text,{children:["Clear Filter: ",i]})})})});return}}),t}const uG=x.memo(({data:e,isConnectable:t,sourcePosition:n=Me.Right,targetPosition:r=Me.Left,...i})=>{const o=x.useMemo(()=>lG(e.interactions),[e.interactions]);return y(Oe,{children:[l(Mi,{type:"target",position:r,isConnectable:t}),l(d.Box,{sx:{position:"absolute",top:0,right:0},children:l(le.ChevronsUpRight,{size:12})}),y(d.HoverCard,{shadow:"xl",withinPortal:!0,children:[l(d.HoverCard.Target,{children:l(d.Text,{children:e.label})}),l(d.HoverCard.Dropdown,{children:l(d.List,{spacing:"xs",size:"sm",center:!0,children:o.map(a=>l(d.List.Item,{icon:a.icon,children:a.text},a.key))})})]}),l(Mi,{type:"source",position:n,isConnectable:t})]})}),N6="",cG={interaction:uG},dG=te.observer(()=>{const e=$e(),{edges:t,nodes:n}=sG(e);return y(Kb,{nodes:n,edges:t,onNodesChange:fe.default.noop,onEdgesChange:fe.default.noop,onConnect:fe.default.noop,className:"interactions-viewer",fitView:!0,nodeTypes:cG,children:[l(Oj,{}),l($j,{}),l(jj,{})]})}),fG=te.observer(({opened:e,close:t})=>{const{freezeLayout:n}=Z.default.useContext(Dr);return Z.default.useEffect(()=>{n(e)},[e]),l(d.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:t,title:"Interactions",trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{body:{height:"90vh"},modal:{transform:"none !important"}},zIndex:300,children:l(dG,{})})});function pG({onClick:e,name:t,active:n,openSettings:r}){return y(d.Box,{sx:{position:"relative"},children:[l(d.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:l(d.Group,{sx:{width:"calc(100% - 28px)"},onClick:e,children:l(d.Text,{size:"sm",children:t})})}),n&&l(d.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:l(d.ActionIcon,{onClick:r,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:l($P,{size:16})})})]})}const hG=te.observer(()=>{const e=$e(),t=x.useCallback(r=>()=>e.views.setIDOfVIE(r),[e]),n=r=>{e.editor.open(["_VIEWS_",r])};return y(d.Box,{sx:{position:"relative"},children:[e.views.options.map(r=>l(pG,{active:e.views.idOfVIE===r.value,name:r.label,onClick:t(r.value),openSettings:()=>n(r.value)},r.value)),l(d.Divider,{variant:"dashed"}),l(d.Button,{variant:"subtle",rightIcon:l(bi,{size:14}),size:"sm",px:"xs",color:"blue",onClick:e.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:"Add a View"})]})}),gG=te.observer(()=>{const e=$e(),t=()=>{if(!e.queries.firstID){e.editor.open(["_QUERIES_",""]);return}e.editor.open(["_QUERIES_",e.queries.firstID])},n=()=>{if(!e.filters.firstID){e.editor.open(["_FILTERS_",""]);return}e.editor.open(["_FILTERS_",e.filters.firstID])},[r,i]=x.useState(!1),o=()=>i(!0),a=()=>i(!1);return y(d.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:[y(d.Navbar.Section,{children:[y(d.Group,{grow:!0,spacing:0,sx:{...Pm,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[l(d.Tooltip,{label:"Filters",withinPortal:!0,children:l(d.ActionIcon,{variant:"default",radius:0,size:"md",onClick:n,children:l(pv,{size:20})})}),l(d.Tooltip,{label:"Queries",withinPortal:!0,children:l(d.ActionIcon,{variant:"default",radius:0,size:"md",onClick:t,children:l(fv,{size:20})})}),l(d.Tooltip,{label:"Interactions Viewer",withinPortal:!0,children:l(d.ActionIcon,{variant:"default",radius:0,size:"md",onClick:o,children:l(hI,{size:20})})})]}),l(fG,{opened:r,close:a})]}),l(d.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:l(d.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Views"})}),l(d.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:l(hG,{})}),l(d.Navbar.Section,{children:l(d.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:l(d.Button,{size:"xs",leftIcon:l(xI,{size:20}),onClick:()=>e.editor.open([]),children:"Settings"})})})]})}),vG=te.observer(function({config:t}){return l(Oe,{children:l(d.Checkbox,{checked:t.default_value,onChange:n=>t.setDefaultValue(n.currentTarget.checked),label:"Default Checked"})})}),mG=[{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"}],yG=te.observer(function({config:t}){return y(Oe,{children:[y(d.Group,{children:[l(d.Checkbox,{checked:t.required,onChange:n=>t.setRequired(n.currentTarget.checked),label:"Required"}),l(d.Checkbox,{checked:t.clearable,onChange:n=>t.setClearable(n.currentTarget.checked),disabled:t.max_days>0,label:"Clearable"}),l(d.Checkbox,{checked:t.allowSingleDateInRange,onChange:n=>t.setAllowSingleDateInRange(n.currentTarget.checked),label:"Allow choosing 1 day"})]}),l(d.Select,{data:mG,label:"Display Format",value:t.inputFormat,onChange:t.setInputFormat}),l(yd,{label:"Default Value",config:t,value:t.default_value,onChange:t.setDefaultValue}),l(d.NumberInput,{label:"Max Days",description:y(d.Group,{position:"apart",children:[l(d.Text,{children:"Set 0 to disable."}),y(d.Group,{spacing:4,children:[l(d.Text,{children:"This feature requires"}),l(d.Text,{color:"blue",children:"Clearable"}),l(d.Text,{children:"to be checked"})]})]}),min:0,value:t.max_days,onChange:t.setMaxDays,hideControls:!0})]})}),td=te.observer(({value:e,onChange:t})=>{const n=$e(),r=Z.default.useMemo(()=>n.queries.options,[n.queries.current]),i=r.length===0;return l(d.Select,{label:"Pick a query",data:r,value:e,onChange:t,allowDeselect:!1,clearable:!0,sx:{flexGrow:1},disabled:i,error:i?"You need to add a query in Data Settings":void 0})}),bG=`
291
+ M${C.x},${C.y}h${C.width}v${C.height}h${-C.width}z`,fill:s,fillRule:"evenodd",stroke:u,strokeWidth:c,pointerEvents:"none"})]})})}Wb.displayName="MiniMap";var Oj=x.memo(Wb);function Dj(){return l("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:l("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Rj(){return l("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:l("path",{d:"M0 0h32v4.2H0z"})})}function Aj(){return l("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:l("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function Pj(){return l("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Ij(){return l("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:l("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}const Po=({children:e,className:t,...n})=>l("button",{type:"button",className:Zt(["react-flow__controls-button",t]),...n,children:e});Po.displayName="ControlButton";const Nj=e=>e.nodesDraggable&&e.nodesConnectable&&e.elementsSelectable,qb=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:o,onZoomOut:a,onFitView:s,onInteractiveChange:u,className:c,children:f,position:h="bottom-left"})=>{const p=Kt(),[g,v]=x.useState(!1),m=Tt(Nj),{zoomIn:w,zoomOut:b,fitView:_}=Kc();if(x.useEffect(()=>{v(!0)},[]),!g)return null;const C=()=>{w(),o==null||o()},S=()=>{b(),a==null||a()},E=()=>{_(i),s==null||s()},k=()=>{p.setState({nodesDraggable:!m,nodesConnectable:!m,elementsSelectable:!m}),u==null||u(!m)};return y(_c,{className:Zt(["react-flow__controls",c]),position:h,style:e,children:[t&&y(Oe,{children:[l(Po,{onClick:C,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",children:l(Dj,{})}),l(Po,{onClick:S,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",children:l(Rj,{})})]}),n&&l(Po,{className:"react-flow__controls-fitview",onClick:E,title:"fit view","aria-label":"fit view",children:l(Aj,{})}),r&&l(Po,{className:"react-flow__controls-interactive",onClick:k,title:"toggle interactivity","aria-label":"toggle interactivity",children:m?l(Ij,{}):l(Pj,{})}),f]})};qb.displayName="Controls";var $j=x.memo(qb),Pn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Pn||(Pn={}));function Lj({color:e,dimensions:t,lineWidth:n}){return l("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function Vj({color:e,radius:t}){return l("circle",{cx:t,cy:t,r:t,fill:e})}const zj={[Pn.Dots]:"#91919a",[Pn.Lines]:"#eee",[Pn.Cross]:"#e2e2e2"},Fj={[Pn.Dots]:1,[Pn.Lines]:1,[Pn.Cross]:6},Bj=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Ub({variant:e=Pn.Dots,gap:t=20,size:n,lineWidth:r=1,color:i,style:o,className:a}){const s=x.useRef(null),{transform:u,patternId:c}=Tt(Bj,nn),f=i||zj[e],h=n||Fj[e],p=e===Pn.Dots,g=e===Pn.Cross,v=Array.isArray(t)?t:[t,t],m=[v[0]*u[2]||1,v[1]*u[2]||1],w=h*u[2],b=g?[w,w]:m,_=p?[w/2,w/2]:[b[0]/2,b[1]/2];return y("svg",{className:Zt(["react-flow__background",a]),style:{...o,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:s,children:[l("pattern",{id:c,x:u[0]%m[0],y:u[1]%m[1],width:m[0],height:m[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:p?l(Vj,{color:f,radius:w/2}):l(Lj,{dimensions:b,color:f,lineWidth:r})}),l("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${c})`})]})}Ub.displayName="Background";var jj=x.memo(Ub);const I6="";function Gj(e,t,n){const r=[],i=[];return e.current.forEach((o,a)=>{const s=o.panels.list.filter(u=>"__INTERACTIONS"in u.viz.conf);i.push(...s)}),i.forEach((o,a)=>{const s=t[o.id];s.data.interactions=fe.default.get(s,"data.interactions",[]);const{__INTERACTIONS:u,__OPERATIONS:c,__TRIGGERS:f}=o.viz.conf;Object.entries(c).forEach(([h,p])=>{const{schemaRef:g,data:v}=p,{config:m}=v;switch(g){case"builtin:op:open-link":let w=m.urlTemplate.substring(0,100);m.urlTemplate.length>=20&&(w+="..."),s.type="interaction",s.data.interactions.push({schemaRef:g,urlTemplate:m.urlTemplate,shortURLTemplate:w});return;case"builtin:op:open_view":r.push({id:`OPERATION--${h}`,source:o.id,target:m.viewID,label:"Open View",style:{stroke:"rgba(0,0,0,0.8)"},type:"default"});return;case"builtin:op:set_filter_values":s.type="interaction",s.data.interactions.push({schemaRef:g,filters:Object.keys(m.dictionary).map(b=>({key:b,label:n[b]}))});return;case"builtin:op:clear_filter_values":s.type="interaction",s.data.interactions.push({schemaRef:g,filters:m.filter_keys.map(b=>({key:b,label:n[b]}))});return;default:return}})}),r}function Kj(e,t){const n=e.filters.keyLabelMap;return{edges:Gj(e.views,t,n),edgeNodes:[]}}function Yb(e,t,n){return e*t+e*n}function Hj(e,t,n){return e*t+(e-1)*n}const Xc=25,Qc=40,Xb=25,Zc=350,Wj=150,qj=150,Qb=150,Uj=300,Jc=40,Zb=25,Yj=300;function Xj(e){const t=[];return e.current.forEach((n,r)=>{n.panels.list.forEach((i,o)=>{const a=Yb(o,Jc,Zb)+Qc,s=i.title.trim()?`${i.title}`:i.viz.type;t.push({id:i.id,_node_type:"panel",parentNode:n.id,data:{label:s},position:{x:Xc,y:a},sourcePosition:Me.Right,targetPosition:Me.Left,style:{width:Uj,height:Jc}})})}),t}const Qj={[rt.Division]:"Div",[rt.Modal]:"Modal",[rt.Tabs]:"Tabs"},Zj=tm;function Jj(e){return e.current.map((n,r)=>{const i=Hj(n.panels.list.length,Jc,Zb)+Qc+Xb;let o=[];return n.type===rt.Tabs&&(o=n.config.tabs.map(s=>s.view_id)),{id:n.id,_node_type:"view-root",_view_type:n.type,_view_level:0,_sub_view_ids:[],_tab_view_ids:o,data:{label:`${Qj[n.type]}:${n.name}`},position:{x:0,y:0},sourcePosition:Me.Right,targetPosition:Me.Left,className:"light",style:{backgroundColor:Zj[n.type],width:Zc,height:i}}})}function eG(e){const t=fe.default.keyBy(e,n=>n.id);e.forEach(n=>{n._node_type!=="view-root"||n._view_type!==rt.Tabs||n._tab_view_ids.forEach(r=>{t[r].parentNode=n.id})})}function tG(e){const t=Jj(e.views);eG(t);const n=Xj(e.views);return[...t,...n]}function nG({nodeMap:e,nodes:t,edges:n}){t.forEach(r=>{r._node_type!=="view-root"||r._view_type!==rt.Tabs||(r.sourcePosition=Me.Bottom,r.style.width=Zc+Xc*2,r.style.height=Xb+r._tab_view_ids.reduce((i,o)=>{const a=e[o];a.position.y=i,a.position.x=Xc;const s=a.style.height;return i+s+20},Qc))})}function rG({nodeMap:e,nodes:t,edges:n}){n.filter(r=>r.label==="Open View").forEach(r=>{const i=e[r.source],o=e[r.target];if(!i||!o||!i.parentNode)return;const a=e[i.parentNode];a._node_type!=="view-root"||o._node_type!=="view-root"||(o._view_level+=1+a._view_level,a._sub_view_ids.push(o.id))}),t.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 iG({nodeMap:e,nodes:t,edges:n}){const r={};n.forEach(i=>{if(i.label!=="Open View")return;const o=e[i.source],a=e[i.target];if(o&&a&&o.parentNode){const s=e[o.parentNode],u=s.position.x,c=fe.default.get(a,"style.height",0),f=Number(s.style.width);a.position.x=u+f+Yj,s._view_level===0&&a._sub_view_ids.length===0&&(o.sourcePosition=Me.Left,a.targetPosition=Me.Right,a.position.x*=-1);const p=a.position.x,g=fe.default.get(r,p,0);a.position.y=g,r[p]=g+c+Qb}})}function oG({nodeMap:e,nodes:t,edges:n}){const r=new Set,i=new Set;n.forEach(a=>{r.add(a.source),i.add(a.target)}),t.filter(a=>a._node_type!=="view-root"||a.id==="Main"||a.parentNode?!1:!r.has(a.id)&&!i.has(a.id)).forEach((a,s)=>{a.position.x=Yb(s,Zc,qj),a.position.y=0-Wj-Qb})}function aG({nodeMap:e,nodes:t,edges:n}){const r={nodeMap:e,nodes:t,edges:n};return oG(r),rG(r),nG(r),iG(r),{nodes:t,edges:n}}function sG(e){const t=tG(e),n=fe.default.keyBy(t,u=>u.id),{edges:r,edgeNodes:i}=Kj(e,n),o=[...t,...i],a=fe.default.keyBy(o,u=>u.id),s={edges:fe.default.uniqBy(r,u=>u.id),nodes:o,nodeMap:a};return aG(s)}const N6="",ed={"builtin:op:open-link":l(d.ThemeIcon,{color:"blue",size:20,radius:"xl",children:l(QP,{size:14})}),"builtin:op:set_filter_values":l(d.ThemeIcon,{color:"orange",size:20,radius:"xl",children:l(JP,{size:14})}),"builtin:op:clear_filter_values":l(d.ThemeIcon,{color:"orange",size:20,radius:"xl",children:l(tI,{size:14})})};function lG(e){const t=[];return e.forEach(n=>{switch(n.schemaRef){case"builtin:op:open-link":t.push({key:n.urlTemplate,icon:ed[n.schemaRef],text:y(d.Group,{spacing:4,children:[l(d.Text,{children:"Open: "}),l(d.Text,{color:"dimmed",children:n.shortURLTemplate})]})});return;case"builtin:op:set_filter_values":n.filters.forEach(({key:r,label:i})=>{t.push({key:n.schemaRef+r,icon:ed[n.schemaRef],text:l(d.Group,{spacing:4,children:y(d.Text,{children:["Set Filter: ",i]})})})});return;case"builtin:op:clear_filter_values":n.filters.forEach(({key:r,label:i})=>{t.push({key:n.schemaRef+r,icon:ed[n.schemaRef],text:l(d.Group,{spacing:4,children:y(d.Text,{children:["Clear Filter: ",i]})})})});return}}),t}const uG=x.memo(({data:e,isConnectable:t,sourcePosition:n=Me.Right,targetPosition:r=Me.Left,...i})=>{const o=x.useMemo(()=>lG(e.interactions),[e.interactions]);return y(Oe,{children:[l(Mi,{type:"target",position:r,isConnectable:t}),l(d.Box,{sx:{position:"absolute",top:0,right:0},children:l(le.ChevronsUpRight,{size:12})}),y(d.HoverCard,{shadow:"xl",withinPortal:!0,children:[l(d.HoverCard.Target,{children:l(d.Text,{children:e.label})}),l(d.HoverCard.Dropdown,{children:l(d.List,{spacing:"xs",size:"sm",center:!0,children:o.map(a=>l(d.List.Item,{icon:a.icon,children:a.text},a.key))})})]}),l(Mi,{type:"source",position:n,isConnectable:t})]})}),$6="",cG={interaction:uG},dG=te.observer(()=>{const e=$e(),{edges:t,nodes:n}=sG(e);return y(Kb,{nodes:n,edges:t,onNodesChange:fe.default.noop,onEdgesChange:fe.default.noop,onConnect:fe.default.noop,className:"interactions-viewer",fitView:!0,nodeTypes:cG,children:[l(Oj,{}),l($j,{}),l(jj,{})]})}),fG=te.observer(({opened:e,close:t})=>{const{freezeLayout:n}=Z.default.useContext(Dr);return Z.default.useEffect(()=>{n(e)},[e]),l(d.Modal,{size:"96vw",overflow:"inside",opened:e,onClose:t,title:"Interactions",trapFocus:!0,onDragStart:r=>{r.stopPropagation()},styles:{body:{height:"90vh"},modal:{transform:"none !important"}},zIndex:300,children:l(dG,{})})});function pG({onClick:e,name:t,active:n,openSettings:r}){return y(d.Box,{sx:{position:"relative"},children:[l(d.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:l(d.Group,{sx:{width:"calc(100% - 28px)"},onClick:e,children:l(d.Text,{size:"sm",children:t})})}),n&&l(d.Tooltip,{label:"Edit",position:"right",withinPortal:!0,children:l(d.ActionIcon,{onClick:r,variant:"light",color:"blue",sx:{position:"absolute",top:0,bottom:0,height:"100%",right:0,zIndex:0,borderRadius:0},children:l($P,{size:16})})})]})}const hG=te.observer(()=>{const e=$e(),t=x.useCallback(r=>()=>e.views.setIDOfVIE(r),[e]),n=r=>{e.editor.open(["_VIEWS_",r])};return y(d.Box,{sx:{position:"relative"},children:[e.views.options.map(r=>l(pG,{active:e.views.idOfVIE===r.value,name:r.label,onClick:t(r.value),openSettings:()=>n(r.value)},r.value)),l(d.Divider,{variant:"dashed"}),l(d.Button,{variant:"subtle",rightIcon:l(bi,{size:14}),size:"sm",px:"xs",color:"blue",onClick:e.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"space-between"}},children:"Add a View"})]})}),gG=te.observer(()=>{const e=$e(),t=()=>{if(!e.queries.firstID){e.editor.open(["_QUERIES_",""]);return}e.editor.open(["_QUERIES_",e.queries.firstID])},n=()=>{if(!e.filters.firstID){e.editor.open(["_FILTERS_",""]);return}e.editor.open(["_FILTERS_",e.filters.firstID])},[r,i]=x.useState(!1),o=()=>i(!0),a=()=>i(!1);return y(d.Navbar,{p:0,width:{base:200,xs:200,sm:200,md:220,lg:240,xl:260},children:[y(d.Navbar.Section,{children:[y(d.Group,{grow:!0,spacing:0,sx:{...Pm,button:{borderWidth:0,borderBottomWidth:1,borderColor:"#e9ecef"}},children:[l(d.Tooltip,{label:"Filters",withinPortal:!0,children:l(d.ActionIcon,{variant:"default",radius:0,size:"md",onClick:n,children:l(pv,{size:20})})}),l(d.Tooltip,{label:"Queries",withinPortal:!0,children:l(d.ActionIcon,{variant:"default",radius:0,size:"md",onClick:t,children:l(fv,{size:20})})}),l(d.Tooltip,{label:"Interactions Viewer",withinPortal:!0,children:l(d.ActionIcon,{variant:"default",radius:0,size:"md",onClick:o,children:l(hI,{size:20})})})]}),l(fG,{opened:r,close:a})]}),l(d.Navbar.Section,{py:5,sx:{borderBottom:"1px solid #eee"},children:l(d.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Views"})}),l(d.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:l(hG,{})}),l(d.Navbar.Section,{children:l(d.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:l(d.Button,{size:"xs",leftIcon:l(xI,{size:20}),onClick:()=>e.editor.open([]),children:"Settings"})})})]})}),vG=te.observer(function({config:t}){return l(Oe,{children:l(d.Checkbox,{checked:t.default_value,onChange:n=>t.setDefaultValue(n.currentTarget.checked),label:"Default Checked"})})}),mG=[{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"}],yG=te.observer(function({config:t}){return y(Oe,{children:[y(d.Group,{children:[l(d.Checkbox,{checked:t.required,onChange:n=>t.setRequired(n.currentTarget.checked),label:"Required"}),l(d.Checkbox,{checked:t.clearable,onChange:n=>t.setClearable(n.currentTarget.checked),disabled:t.max_days>0,label:"Clearable"}),l(d.Checkbox,{checked:t.allowSingleDateInRange,onChange:n=>t.setAllowSingleDateInRange(n.currentTarget.checked),label:"Allow choosing 1 day"})]}),l(d.Select,{data:mG,label:"Display Format",value:t.inputFormat,onChange:t.setInputFormat}),l(yd,{label:"Default Value",config:t,value:t.default_value,onChange:t.setDefaultValue}),l(d.NumberInput,{label:"Max Days",description:y(d.Group,{position:"apart",children:[l(d.Text,{children:"Set 0 to disable."}),y(d.Group,{spacing:4,children:[l(d.Text,{children:"This feature requires"}),l(d.Text,{color:"blue",children:"Clearable"}),l(d.Text,{children:"to be checked"})]})]}),min:0,value:t.max_days,onChange:t.setMaxDays,hideControls:!0})]})}),td=te.observer(({value:e,onChange:t})=>{const n=$e(),r=Z.default.useMemo(()=>n.queries.options,[n.queries.current]),i=r.length===0;return l(d.Select,{label:"Pick a query",data:r,value:e,onChange:t,allowDeselect:!1,clearable:!0,sx:{flexGrow:1},disabled:i,error:i?"You need to add a query in Data Settings":void 0})}),bG=`
292
292
  // row
293
293
  {
294
294
  label: string;
@@ -303,7 +303,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
303
303
  parent_value: string;
304
304
  description?: string;
305
305
  }
306
- `,_G=()=>{const[e,t]=x.useState(!1);return y(Oe,{children:[l(d.Button,{variant:"subtle",compact:!0,onClick:()=>t(n=>!n),children:e?"Close":"Click to see expected data structure"}),l(d.Collapse,{in:e,children:l(Ur.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:CG})})]})},EG=te.observer(function({config:t}){return y(Oe,{children:[l(d.TextInput,{label:"Min-width",value:t.min_width,onChange:n=>t.setMinWidth(n.currentTarget.value),placeholder:"200px"}),l(d.Divider,{label:"Fetch options from database",labelPosition:"center"}),l(d.NumberInput,{value:t.default_selection_count,onChange:t.setDefaultSelectionCount,label:"Select first N options by default"}),l(td,{value:t.options_query_id,onChange:t.setOptionsQueryID}),l(_G,{})]})}),TG=te.observer(function({filter:t}){const[n,r]=Z.default.useState(t.plainDefaultValue);return Z.default.useEffect(()=>{r(t.plainDefaultValue)},[t]),y(d.Box,{sx:{maxWidth:"480px"},children:[l(d.Text,{pb:"md",color:"gray",children:"Preview"}),l(sg,{filter:t,value:n,onChange:r}),l(d.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),l(Ur.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),MG={select:xG,"multi-select":wG,"tree-select":EG,"text-input":SG,checkbox:vG,"date-range":yG},kG=[{label:"Select",value:"select"},{label:"Multi Select",value:"multi-select"},{label:"Tree Select",value:"tree-select"},{label:"Text Input",value:"text-input"},{label:"Checkbox",value:"checkbox"},{label:"Date Range",value:"date-range"}],OG=te.observer(function({filter:t}){const n=$e(),r=Z.default.useMemo(()=>MG[t.type],[t.type]);return y(d.Group,{grow:!0,spacing:20,align:"top",children:[y(d.Box,{sx:{maxWidth:"600px"},children:[l(d.Text,{pb:"md",color:"gray",children:"Edit"}),y(d.Stack,{children:[y(d.Group,{noWrap:!0,children:[l(d.NumberInput,{label:"Placement Order",required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&l(d.Checkbox,{label:"Submit automatically",checked:t.auto_submit,onChange:i=>t.setAutoSubmit(i.currentTarget.checked),mt:22})]}),l(d.MultiSelect,{label:"Visible in...",data:n.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),l(d.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:t.key,onChange:i=>{t.setKey(i.currentTarget.value)}}),l(d.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:t.label,onChange:i=>{t.setLabel(i.currentTarget.value)}}),l(d.Select,{label:"Widget",data:kG,required:!0,value:t.type,onChange:t.setType}),l(r,{config:t.config})]})]}),l(TG,{filter:t})]})}),DG=te.observer(({id:e})=>{const t=Kn.useModals(),n=$e();if(e==="")return null;const r=n.filters.findByID(e);if(!r)return y(d.Text,{size:14,children:["Filter by ID[",e,"] is not found"]});const i=()=>{t.openConfirmModal({title:"Delete this filter?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>n.filters.removeByID(e),zIndex:320})};return y(d.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[l(d.Group,{position:"right",pt:10,children:l(d.Button,{size:"xs",color:"red",leftIcon:l(le.Trash,{size:16}),onClick:i,children:"Delete this filter"})}),l(d.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:l(OG,{filter:r})})]})}),RG=te.observer(()=>{const e=$e(),[t,n]=x.useState(()=>JSON.stringify(e.mock_context.current,null,4)),r=()=>{try{e.mock_context.replace(JSON.parse(t))}catch(o){No.showNotification({title:"Failed",message:o.message,color:"red"})}},i=x.useMemo(()=>{try{return JSON.stringify(JSON.parse(t))!==JSON.stringify(e.mock_context.current)}catch{return!1}},[t,e.mock_context.current]);return y(d.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[l(d.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:l(d.Text,{weight:500,children:"Mock Context"})}),y(d.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[y(d.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[l(d.Text,{children:"A valid json string is required"}),l(d.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:t,onChange:n,sx:{flexGrow:1}})]}),l(d.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!i,onClick:r,children:l(le.DeviceFloppy,{size:20})})]})]})}),AG=te.observer(()=>{const{panel:e}=Yt();return l(hv,{label:"Description",value:e.description,onChange:e.setDescription,styles:{root:{flexGrow:1}}})}),PG=te.observer(()=>{const{panel:e}=Yt(),{style:t}=e;return l(Oe,{children:l(d.Switch,{label:"Border",checked:t.border.enabled,onChange:n=>t.border.setEnabled(n.currentTarget.checked)})})}),IG=te.observer(()=>{const{panel:e}=Yt(),{title:t,setTitle:n}=e,[r,i]=Ut.useInputState(t),o=t!==r,a=Z.default.useCallback(()=>{!o||n(r)},[o,r]);return x.useEffect(()=>{i(t)},[t]),l(d.TextInput,{value:r,onChange:i,label:y(d.Group,{children:[l(d.Text,{children:"Panel Title"}),l(d.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:a,children:l(le.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function NG(){return y(d.Stack,{sx:{height:"100%"},children:[l(d.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),l(PG,{}),l(d.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),l(IG,{}),l(AG,{})]})}const $G=te.observer(({height:e})=>{const t=$e(),{data:n,loading:r,error:i,panel:{viz:o,queryID:a}}=Yt(),s=t.queries.findByID(a);return l(Zv,{viz:o,data:n,loading:r,error:i,query:s,height:e})}),LG=te.observer(()=>{const{panel:{title:e,style:{border:t}}}=Yt();return l(Or,{children:l(d.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:y(d.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:t.enabled?"1px":"0px"},children:[y(d.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[l(d.Group,{children:l(yg,{})}),l(d.Group,{grow:!0,position:"center",children:l(d.Text,{lineClamp:1,weight:"bold",children:e})}),l(d.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),l(d.Group,{sx:{flexGrow:1},children:l($G,{height:"410px"})})]})})})}),VG=({queryID:e})=>{const t=$e(),{state:n,error:r}=t.getDataStuffByID(e),i=Z.default.useMemo(()=>t.queries.findByID(e),[t,e]);return n==="loading"?null:r?l(d.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:r}):i!=null&&i.stateMessage?l(d.Text,{color:"gray",align:"center",children:i.stateMessage}):null},zG={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function FG({data:e}){const t=x.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const r=Ov();return Object.keys(e[0]).map(i=>r.accessor(i,{cell:o=>o.getValue()}))},[e]),n=Rv({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:Dv()});return e.length===0?l(d.Box,{sx:{height:"5em"}}):y(d.Table,{sx:zG,children:[l("thead",{children:n.getHeaderGroups().map(r=>l("tr",{children:r.headers.map(i=>y("th",{style:{width:i.getSize()},children:[i.isPlaceholder?null:Ka(i.column.columnDef.header,i.getContext()),l(d.ActionIcon,{onMouseDown:i.getResizeHandler(),onTouchStart:i.getResizeHandler(),className:`resizer ${i.column.getIsResizing()?"isResizing":""}`,children:l(le.ArrowBarToRight,{})})]},i.id))},r.id))}),l("tbody",{children:n.getRowModel().rows.map(r=>l("tr",{children:r.getVisibleCells().map(i=>l("td",{children:Ka(i.column.columnDef.cell,i.getContext())},i.id))},r.id))})]})}const e0=te.observer(function({id:t}){const n=$e(),{data:r,state:i}=n.getDataStuffByID(t),o=i==="loading",a=()=>{n.queries.refetchDataByQueryID(t)},s=()=>{n.queries.downloadDataByQueryID(t)},u=x.useMemo(()=>Array.isArray(r)?r.slice(0,10):[],[r]),c=!Array.isArray(r)||r.length===0;return y(d.Stack,{sx:{border:"1px solid #eee"},children:[y(d.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[y(d.Group,{position:"left",children:[l(d.Text,{weight:500,children:"Preview Data"}),r.length>10&&y(d.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",r.length]})]}),y(d.Group,{pr:15,children:[l(d.ActionIcon,{variant:"subtle",color:"blue",disabled:o,onClick:a,children:l(le.Refresh,{size:15})}),l(d.ActionIcon,{variant:"subtle",color:"blue",disabled:o||c,onClick:s,children:l(le.Download,{size:15})})]})]}),y(d.Box,{sx:{position:"relative",overflow:"auto"},children:[l(d.LoadingOverlay,{visible:o}),l(VG,{queryID:t}),l(FG,{data:u})]})]})}),BG=te.observer(function(){const t=$e(),{panel:{queryID:n,setQueryID:r}}=Yt(),i=Z.default.useMemo(()=>t.queries.current.map(a=>({value:a.id,label:a.name})),[t.queries.current]),o=()=>{t.editor.setPath(["_QUERIES_",n])};return y(d.Stack,{children:[y(d.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[l(d.Text,{children:"Use query"}),l(d.Select,{data:i,value:n,onChange:r,allowDeselect:!1,clearable:!1,sx:{flexGrow:"1 !important"},maxDropdownHeight:300,rightSection:n&&l(d.Tooltip,{label:"Open this query",children:l(d.ActionIcon,{variant:"subtle",color:"blue",onClick:o,children:l(zP,{size:16})})})})]}),l(e0,{id:n})]})}),nd={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{}},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class jG{constructor(t){Re(this,"panel");Re(this,"selected");this.panel=t,Ft.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const t=this.panel.variables.filter(n=>n.name.startsWith(nd.name)).length;this.panel.addVariable(H.cloneDeep({...nd,name:`${nd.name}${t||""}`})),this.selected=H.last(this.panel.variables)}select(t){this.selected=t}remove(t){this.selected===t&&(this.selected=void 0);const n=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!H.isEmpty(this.panel.variables)){const r=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[r]}}}function GG(){const{panel:e}=Yt();return tt.useCreation(()=>new jG(e),[e])}const KG=Z.default.forwardRef(function({value:t,onChange:n,data:r,withStyle:i=!0},o){const a=(s,u)=>{const c=fe.default.cloneDeep(t);fe.default.set(c,s,u),n(c)};return y(d.Box,{px:"sm",py:"md",ref:o,children:[y(d.Group,{grow:!0,noWrap:!0,children:[l(d.TextInput,{label:"Name",required:!0,value:t.name,onChange:s=>a("name",s.currentTarget.value)}),l(mt,{label:"Data Field",required:!0,data:r,value:t.data_field,onChange:s=>a("data_field",s)})]}),l(Zl,{label:"Aggregation",value:t.aggregation,onChange:s=>a("aggregation",s)}),l(d.Divider,{my:"xs",label:"Format",labelPosition:"center"}),l($r,{value:t.formatter,onChange:s=>a("formatter",s)}),i&&l($g,{value:t,onChange:n})]})}),t0=d.createStyles(e=>({root:{height:"100%",overflow:"hidden",".var-list-container":{"& > *":{height:"100%"},width:250,height:"100%"},".var-list-actions":{height:"fit-content",flexShrink:0,width:"100%"},".var-list":{flex:"1 1 auto",overflow:"auto",minHeight:0,"& > *":{flex:"0 0 auto"}}},config:{height:"100%",overflow:"auto",paddingRight:10}})),HG=e=>{const{uiModel:t}=e;return l(d.Stack,{className:"var-list",children:t.variables.map(n=>l(d.Button,{variant:t.selected===n?"filled":"subtle",color:"gray",onClick:()=>t.select(n),children:n.name},n.name))})},WG=te.observer(HG),qG=({variable:e,data:t})=>l(d.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:l(d.Paper,{withBorder:!0,p:"md",children:rv(e,t)})}),UG=te.observer(qG),YG=e=>{const t=tt.useCreation(()=>Lz(e.variable),[e.variable]),{classes:n}=t0(),{data:r}=Yt();return y(d.Group,{style:{height:"100%"},align:"start",children:[y(d.Stack,{"data-testid":"variable-editor",align:"stretch",className:n.config,children:[y(d.Group,{position:"right",children:[l(d.ActionIcon,{variant:"filled",disabled:!t.changed,color:"primary",onClick:t.commit,children:l(bu,{size:18})}),l(d.ActionIcon,{color:"red",onClick:()=>e.uiModel.remove(e.variable),children:l(za,{size:18})})]}),l(KG,{value:D.getSnapshot(t.copy),onChange:t.update,data:r})]}),l(UG,{variable:D.getSnapshot(t.copy),data:r})]})},XG=te.observer(YG),QG=()=>{const e=GG(),{classes:t}=t0();return y(d.Group,{className:t.root,noWrap:!0,align:"start",children:[l(d.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:y(d.Stack,{justify:"space-between",children:[l(d.Box,{className:"var-list-actions",children:l(d.Button,{variant:"light",size:"sm",onClick:e.addNew,fullWidth:!0,children:"Add Variable"})}),l(WG,{uiModel:e})]})}),e.selected?l(Oe,{children:l(XG,{uiModel:e,variable:e.selected})}):l("span",{children:"Select or create a new variable on right side"})]})},ZG=te.observer(QG),rd=[];function JG(){const{vizManager:e}=x.useContext(zn);return x.useMemo(()=>e.availableVizList.map(t=>({value:t.name,label:t.displayName})).concat(rd),[e])}function eK(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function tK(){const{data:e,panel:{variables:t,viz:n,title:r,queryID:i,description:o,setDescription:a,setTitle:s,setQueryID:u,id:c}}=Yt(),{vizManager:f}=x.useContext(zn),h={title:r,description:o,viz:n,queryID:i,id:c},p={setDescription:a,setQueryID:u,setTitle:s},g=Yv(h);try{return f.resolveComponent(h.viz.type),l(Fo,{configure:g,children:l(MV,{variables:t,setVizConf:n.setConf,panel:h,panelInfoEditor:p,vizManager:f,data:e})})}catch(v){return console.info(H.get(v,"message")),null}}const nK=te.observer(()=>{const{data:e,panel:{viz:t}}=Yt(),[n,r]=Ut.useInputState(t.type),i=t.type!==n,{vizManager:o}=x.useContext(zn),a=Z.default.useCallback(()=>{if(!i)return;const g=eK(o,n);t.setType(n),t.setConf(g||{})},[t,i,n]),s=g=>{try{t.setConf(JSON.parse(g))}catch(v){console.error(v)}},u=Z.default.useMemo(()=>{var g;return(g=rd.find(v=>v.value===n))==null?void 0:g.Panel},[n,rd]),c=tK(),f=u?x.createElement(u,{data:e,conf:t.conf,setConf:t.setConf}):null,h=c||f,p=JG();return y(d.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[l(d.Select,{label:"Visualization",value:n,onChange:r,data:p,rightSection:l(d.ActionIcon,{disabled:!i,onClick:a,children:l(le.DeviceFloppy,{size:20})})}),l(d.Box,{pb:50,sx:{maxHeight:"calc(100% - 80px)",overflow:"auto"},children:h}),!h&&l(d.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:s})]})}),rK={root:{flexGrow:1,width:"100%",height:"100%"},panel:{width:"100%",height:"100%",padding:10}},n0=({children:e})=>y(d.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"calc(100% - 36px)"},children:[l(d.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),l(LG,{})]});function iK(e){return!["richText","button"].includes(e)}const oK=te.observer(({panel:e})=>{const t=Kn.useModals(),n=$e(),[r,i]=x.useState("Data"),{data:o,state:a,error:s}=n.getDataStuffByID(e.queryID),u=n.queries.findByID(e.queryID),f=iK(e.viz.type)&&a==="loading",h=f||s||!u||!!u.stateMessage;x.useEffect(()=>{i(v=>h&&v==="Visualization"?"Data":v)},[e.id,h]);const p=()=>{const v=n.editor.path;n.editor.setPath(["_VIEWS_",v[1]])},g=()=>t.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{e.removeSelf(),p()},confirmProps:{color:"red"},zIndex:320});return y($s,{value:{panel:e,data:o,loading:f,error:s},children:[y(d.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[y(d.Text,{pt:9,pb:8,children:[e.title?e.title:e.viz.type," "]}),l(d.Button,{size:"xs",variant:"subtle",color:"red",onClick:g,leftIcon:l(za,{size:14}),children:"Delete This Panel"})]}),y(d.Tabs,{value:r,onTabChange:i,keepMounted:!1,styles:rK,children:[y(d.Tabs.List,{children:[l(d.Tabs.Tab,{value:"Data",disabled:f,children:"Data"}),l(d.Tabs.Tab,{value:"Panel",children:"Panel"}),l(d.Tabs.Tab,{value:"Variables",disabled:h,children:l(d.Tooltip,{label:"Requires data",disabled:!h,withinPortal:!0,zIndex:310,children:l(d.Text,{children:"Variables"})})}),l(d.Tabs.Tab,{value:"Visualization",disabled:h,children:l(d.Tooltip,{label:"Requires data",disabled:!h,withinPortal:!0,zIndex:310,children:l(d.Text,{children:"Visualization"})})}),l(d.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),y(d.Tabs.Panel,{value:"Data",children:[l(d.LoadingOverlay,{visible:f,exitTransitionDuration:0}),l(BG,{})]}),l(d.Tabs.Panel,{value:"Panel",children:l(n0,{children:l(NG,{})})}),l(d.Tabs.Panel,{value:"Variables",children:l(ZG,{})}),l(d.Tabs.Panel,{value:"Visualization",children:l(Or,{children:l(n0,{children:l(nK,{})})})}),l(d.Tabs.Panel,{value:"Interactions",children:l(Or,{children:l(EV,{})})})]})]})}),aK=te.observer(({viewID:e,panelID:t})=>{const r=$e().views.findByID(e);if(!r)return y(d.Text,{size:14,children:["View by ID[",e,"] is not found"]});const i=r.panels.findByID(t);return i?l(oK,{panel:i}):y(d.Text,{size:14,children:["Panel by ID[",t,"] is not found"]})}),sK=x.forwardRef(({label:e,type:t,...n},r)=>y(d.Group,{position:"apart",ref:r,...n,children:[l(d.Text,{children:e}),l(d.Text,{children:t})]})),lK=te.observer(function({value:t,onChange:n}){const{data:r=[],loading:i}=tt.useRequest(Xu,{refreshDeps:[]},[]),o=x.useMemo(()=>r.map(s=>({label:s.key,value:s.key,type:s.type})),[r]),a=x.useMemo(()=>o.reduce((s,u)=>(s[u.value]=u.type,s),{}),[o]);return l(d.Select,{label:"Data Source",data:o,itemComponent:sK,sx:{flex:1},required:!0,disabled:i,value:t.key,onChange:s=>{s!==null&&n({key:s,type:a[s]})}})}),uK=e=>{const{queryModel:t}=e,n=$e(),i=n.findQueryUsage(t.id).length>0,o=Kn.useModals(),a=()=>{o.openConfirmModal({title:"Delete this query?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>n.queries.removeQuery(t.id),zIndex:320})};return i?l(d.Tooltip,{label:"Can't delete this query for it's being used, check out Usage tab for details",withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,children:l(d.Button,{color:"gray",size:"xs",leftIcon:l(za,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})}):l(d.Button,{color:"red",size:"xs",onClick:a,leftIcon:l(za,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})},cK=te.observer(uK),dK=te.observer(({queryModel:e})=>l(d.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:y(d.Stack,{spacing:10,sx:{width:"100%"},children:[l(d.Divider,{mb:-10,variant:"dashed",label:"Basics",labelPosition:"center"}),l(d.TextInput,{placeholder:"A unique name",label:"Name",required:!0,sx:{flex:1},value:e.name,onChange:t=>{e.setName(t.currentTarget.value)}}),l(lK,{value:{type:e.type,key:e.key},onChange:({type:t,key:n})=>{e.setKey(n),e.setType(t)}}),l(d.Divider,{mt:10,mb:-10,variant:"dashed",label:"Conditions",labelPosition:"center"}),l(d.MultiSelect,{label:"Run query when these are truthy",data:e.conditionOptions,value:[...e.run_by],onChange:e.setRunBy}),l(d.Divider,{mt:20,mb:10,variant:"dashed"}),l(cK,{queryModel:e})]})})),fK=({value:e,onChange:t})=>{const n=r=>{!r||t(r)};return l(d.Box,{sx:{position:"relative",flexGrow:1},children:l(Tn.default,{height:"100%",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},r0=x.forwardRef(({value:e,onChange:t,label:n,defaultValue:r},i)=>{const[o,a]=x.useState(e),s=()=>{t(o)},u=()=>{a(e)},c=()=>{a(r)};x.useEffect(()=>{a(e)},[e]);const f=o!==e;return y(d.Stack,{spacing:4,sx:{height:"100%"},children:[l(d.Text,{size:14,children:n}),l(fK,{value:o,onChange:a}),y(d.Group,{mt:10,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[l(d.Button,{onClick:c,size:"xs",color:"red",leftIcon:l(le.Recycle,{size:16}),children:"Reset to default"}),f&&y(d.Group,{position:"right",children:[l(d.Button,{onClick:u,variant:"subtle",size:"xs",children:"Cancel"}),l(d.Button,{size:"xs",onClick:s,children:"OK"})]})]})]})}),pK=`
306
+ `,_G=()=>{const[e,t]=x.useState(!1);return y(Oe,{children:[l(d.Button,{variant:"subtle",compact:!0,onClick:()=>t(n=>!n),children:e?"Close":"Click to see expected data structure"}),l(d.Collapse,{in:e,children:l(Ur.Prism,{language:"typescript",noCopy:!0,colorScheme:"dark",children:CG})})]})},EG=te.observer(function({config:t}){return y(Oe,{children:[l(d.TextInput,{label:"Min-width",value:t.min_width,onChange:n=>t.setMinWidth(n.currentTarget.value),placeholder:"200px"}),l(d.Divider,{label:"Fetch options from database",labelPosition:"center"}),l(d.NumberInput,{value:t.default_selection_count,onChange:t.setDefaultSelectionCount,label:"Select first N options by default"}),l(td,{value:t.options_query_id,onChange:t.setOptionsQueryID}),l(_G,{})]})}),TG=te.observer(function({filter:t}){const[n,r]=Z.default.useState(t.plainDefaultValue);return Z.default.useEffect(()=>{r(t.plainDefaultValue)},[t]),y(d.Box,{sx:{maxWidth:"480px"},children:[l(d.Text,{pb:"md",color:"gray",children:"Preview"}),l(sg,{filter:t,value:n,onChange:r}),l(d.Text,{pt:"lg",pb:"md",color:"gray",children:"Config"}),l(Ur.Prism,{language:"json",colorScheme:"dark",noCopy:!0,children:JSON.stringify(t,null,4)})]})}),MG={select:xG,"multi-select":wG,"tree-select":EG,"text-input":SG,checkbox:vG,"date-range":yG},kG=[{label:"Select",value:"select"},{label:"Multi Select",value:"multi-select"},{label:"Tree Select",value:"tree-select"},{label:"Text Input",value:"text-input"},{label:"Checkbox",value:"checkbox"},{label:"Date Range",value:"date-range"}],OG=te.observer(function({filter:t}){const n=$e(),r=Z.default.useMemo(()=>MG[t.type],[t.type]);return y(d.Group,{grow:!0,spacing:20,align:"top",children:[y(d.Box,{sx:{maxWidth:"600px"},children:[l(d.Text,{pb:"md",color:"gray",children:"Edit"}),y(d.Stack,{children:[y(d.Group,{noWrap:!0,children:[l(d.NumberInput,{label:"Placement Order",required:!0,value:t.order,onChange:t.setOrder,hideControls:!0,sx:{flexGrow:"1 !important"}}),t.auto_submit_supported&&l(d.Checkbox,{label:"Submit automatically",checked:t.auto_submit,onChange:i=>t.setAutoSubmit(i.currentTarget.checked),mt:22})]}),l(d.MultiSelect,{label:"Visible in...",data:n.views.options,value:[...t.visibleInViewsIDs],onChange:t.setVisibleInViewsIDs}),l(d.TextInput,{label:"Key",placeholder:"A unique key to refer",required:!0,value:t.key,onChange:i=>{t.setKey(i.currentTarget.value)}}),l(d.TextInput,{label:"Label",placeholder:"Label for this field",required:!0,value:t.label,onChange:i=>{t.setLabel(i.currentTarget.value)}}),l(d.Select,{label:"Widget",data:kG,required:!0,value:t.type,onChange:t.setType}),l(r,{config:t.config})]})]}),l(TG,{filter:t})]})}),DG=te.observer(({id:e})=>{const t=Kn.useModals(),n=$e();if(e==="")return null;const r=n.filters.findByID(e);if(!r)return y(d.Text,{size:14,children:["Filter by ID[",e,"] is not found"]});const i=()=>{t.openConfirmModal({title:"Delete this filter?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>n.filters.removeByID(e),zIndex:320})};return y(d.Stack,{sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",pb:30,children:[l(d.Group,{position:"right",pt:10,children:l(d.Button,{size:"xs",color:"red",leftIcon:l(le.Trash,{size:16}),onClick:i,children:"Delete this filter"})}),l(d.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:l(OG,{filter:r})})]})}),RG=te.observer(()=>{const e=$e(),[t,n]=x.useState(()=>JSON.stringify(e.mock_context.current,null,4)),r=()=>{try{e.mock_context.replace(JSON.parse(t))}catch(o){No.showNotification({title:"Failed",message:o.message,color:"red"})}},i=x.useMemo(()=>{try{return JSON.stringify(JSON.parse(t))!==JSON.stringify(e.mock_context.current)}catch{return!1}},[t,e.mock_context.current]);return y(d.Stack,{sx:{border:"1px solid #eee",borderLeft:"none",borderRight:"none",flexGrow:1,maxWidth:"unset"},children:[l(d.Group,{position:"left",pl:"md",py:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef",flexGrow:0},children:l(d.Text,{weight:500,children:"Mock Context"})}),y(d.Group,{grow:!0,px:"md",pb:"md",pt:0,sx:{flexGrow:1,position:"relative",alignItems:"flex-start"},children:[y(d.Stack,{spacing:10,sx:{maxWidth:"unset !important"},children:[l(d.Text,{children:"A valid json string is required"}),l(d.JsonInput,{validationError:"Invalid json",formatOnBlur:!0,autosize:!0,minRows:30,value:t,onChange:n,sx:{flexGrow:1}})]}),l(d.ActionIcon,{mr:5,variant:"filled",color:"blue",sx:{position:"absolute",right:12,top:0},disabled:!i,onClick:r,children:l(le.DeviceFloppy,{size:20})})]})]})}),AG=te.observer(()=>{const{panel:e}=Yt();return l(hv,{label:"Description",value:e.description,onChange:e.setDescription,styles:{root:{flexGrow:1}}})}),PG=te.observer(()=>{const{panel:e}=Yt(),{style:t}=e;return l(Oe,{children:l(d.Switch,{label:"Border",checked:t.border.enabled,onChange:n=>t.border.setEnabled(n.currentTarget.checked)})})}),IG=te.observer(()=>{const{panel:e}=Yt(),{title:t,setTitle:n}=e,[r,i]=Ut.useInputState(t),o=t!==r,a=Z.default.useCallback(()=>{!o||n(r)},[o,r]);return x.useEffect(()=>{i(t)},[t]),l(d.TextInput,{value:r,onChange:i,label:y(d.Group,{children:[l(d.Text,{children:"Panel Title"}),l(d.ActionIcon,{variant:"subtle",color:"blue",disabled:!o,onClick:a,children:l(le.DeviceFloppy,{size:20})})]}),styles:{label:{display:"block",paddingBottom:"4px"}}})});function NG(){return y(d.Stack,{sx:{height:"100%"},children:[l(d.Divider,{label:"Style",labelPosition:"center",variant:"dashed"}),l(PG,{}),l(d.Divider,{label:"Info",labelPosition:"center",variant:"dashed"}),l(IG,{}),l(AG,{})]})}const $G=te.observer(({height:e})=>{const t=$e(),{data:n,loading:r,error:i,panel:{viz:o,queryID:a}}=Yt(),s=t.queries.findByID(a);return l(Zv,{viz:o,data:n,loading:r,error:i,query:s,height:e})}),LG=te.observer(()=>{const{panel:{title:e,style:{border:t}}}=Yt();return l(Or,{children:l(d.Box,{sx:{height:"100%",flexGrow:0,flexShrink:0,width:"600px"},children:y(d.Stack,{mt:24,spacing:5,sx:{width:"600px",height:"450px",background:"transparent",borderRadius:"5px",border:"1px solid #e9ecef",borderWidth:t.enabled?"1px":"0px"},children:[y(d.Group,{position:"apart",noWrap:!0,sx:{flexGrow:0,flexShrink:0},children:[l(d.Group,{children:l(yg,{})}),l(d.Group,{grow:!0,position:"center",children:l(d.Text,{lineClamp:1,weight:"bold",children:e})}),l(d.Group,{position:"right",spacing:0,sx:{height:"28px"}})]}),l(d.Group,{sx:{flexGrow:1},children:l($G,{height:"410px"})})]})})})}),VG=({queryID:e})=>{const t=$e(),{state:n,error:r}=t.getDataStuffByID(e),i=Z.default.useMemo(()=>t.queries.findByID(e),[t,e]);return n==="loading"?null:r?l(d.Text,{color:"red",size:"md",align:"center",sx:{fontFamily:"monospace"},children:r}):i!=null&&i.stateMessage?l(d.Text,{color:"gray",align:"center",children:i.stateMessage}):null},zG={width:"fit-content",minWidth:"100%",tableLayout:"fixed",tr:{width:"fit-content"},th:{position:"relative"},".resizer":{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",cursor:"col-resize",userSelect:"none",touchAction:"none"},".resizer.isResizing":{color:"#228be6",opacity:"1"},"@media (hover: hover)":{".resizer":{opacity:"0"},"*:hover > .resizer":{color:"#228be6",opacity:"1"}}};function FG({data:e}){const t=x.useMemo(()=>{if(!Array.isArray(e)||e.length===0)return[];const r=Ov();return Object.keys(e[0]).map(i=>r.accessor(i,{cell:o=>o.getValue()}))},[e]),n=Rv({data:e,columns:t,columnResizeMode:"onChange",getCoreRowModel:Dv()});return e.length===0?l(d.Box,{sx:{height:"5em"}}):y(d.Table,{sx:zG,children:[l("thead",{children:n.getHeaderGroups().map(r=>l("tr",{children:r.headers.map(i=>y("th",{style:{width:i.getSize()},children:[i.isPlaceholder?null:Ka(i.column.columnDef.header,i.getContext()),l(d.ActionIcon,{onMouseDown:i.getResizeHandler(),onTouchStart:i.getResizeHandler(),className:`resizer ${i.column.getIsResizing()?"isResizing":""}`,children:l(le.ArrowBarToRight,{})})]},i.id))},r.id))}),l("tbody",{children:n.getRowModel().rows.map(r=>l("tr",{children:r.getVisibleCells().map(i=>l("td",{children:Ka(i.column.columnDef.cell,i.getContext())},i.id))},r.id))})]})}const e0=te.observer(function({id:t}){const n=$e(),{data:r,state:i}=n.getDataStuffByID(t),o=i==="loading",a=()=>{n.queries.refetchDataByQueryID(t)},s=()=>{n.queries.downloadDataByQueryID(t)},u=x.useMemo(()=>Array.isArray(r)?r.slice(0,10):[],[r]),c=!Array.isArray(r)||r.length===0;return y(d.Stack,{sx:{border:"1px solid #eee"},children:[y(d.Group,{position:"apart",py:"md",pl:"md",sx:{borderBottom:"1px solid #eee",background:"#efefef"},children:[y(d.Group,{position:"left",children:[l(d.Text,{weight:500,children:"Preview Data"}),r.length>10&&y(d.Text,{size:"sm",color:"gray",children:["Showing 10 rows of ",r.length]})]}),y(d.Group,{pr:15,children:[l(d.ActionIcon,{variant:"subtle",color:"blue",disabled:o,onClick:a,children:l(le.Refresh,{size:15})}),l(d.ActionIcon,{variant:"subtle",color:"blue",disabled:o||c,onClick:s,children:l(le.Download,{size:15})})]})]}),y(d.Box,{sx:{position:"relative",overflow:"auto"},children:[l(d.LoadingOverlay,{visible:o}),l(VG,{queryID:t}),l(FG,{data:u})]})]})}),BG=te.observer(function(){const t=$e(),{panel:{queryID:n,setQueryID:r}}=Yt(),i=Z.default.useMemo(()=>t.queries.current.map(a=>({value:a.id,label:a.name})),[t.queries.current]),o=()=>{t.editor.setPath(["_QUERIES_",n])};return y(d.Stack,{children:[y(d.Group,{position:"left",sx:{maxWidth:"600px",alignItems:"baseline"},children:[l(d.Text,{children:"Use query"}),l(d.Select,{data:i,value:n,onChange:r,allowDeselect:!1,clearable:!1,sx:{flexGrow:"1 !important"},maxDropdownHeight:300,rightSection:n&&l(d.Tooltip,{label:"Open this query",children:l(d.ActionIcon,{variant:"subtle",color:"blue",onClick:o,children:l(zP,{size:16})})})})]}),l(e0,{id:n})]})}),nd={name:"new_var",size:"1rem",weight:"initial",color:{type:"static",staticColor:"Red"},data_field:"",aggregation:{type:"sum",config:{}},formatter:{output:"number",mantissa:0,trimMantissa:!1,average:!1}};class jG{constructor(t){Re(this,"panel");Re(this,"selected");this.panel=t,Ft.makeAutoObservable(this,{},{deep:!1,autoBind:!0})}get variables(){return this.panel.variables}addNew(){const t=this.panel.variables.filter(n=>n.name.startsWith(nd.name)).length;this.panel.addVariable(H.cloneDeep({...nd,name:`${nd.name}${t||""}`})),this.selected=H.last(this.panel.variables)}select(t){this.selected=t}remove(t){this.selected===t&&(this.selected=void 0);const n=this.panel.variables.indexOf(t);if(this.panel.removeVariable(t),!this.selected&&!H.isEmpty(this.panel.variables)){const r=Math.min(this.panel.variables.length-1,n);this.selected=this.panel.variables[r]}}}function GG(){const{panel:e}=Yt();return tt.useCreation(()=>new jG(e),[e])}const KG=Z.default.forwardRef(function({value:t,onChange:n,data:r,withStyle:i=!0},o){const a=(s,u)=>{const c=fe.default.cloneDeep(t);fe.default.set(c,s,u),n(c)};return y(d.Box,{px:"sm",py:"md",ref:o,children:[y(d.Group,{grow:!0,noWrap:!0,children:[l(d.TextInput,{label:"Name",required:!0,value:t.name,onChange:s=>a("name",s.currentTarget.value)}),l(mt,{label:"Data Field",required:!0,data:r,value:t.data_field,onChange:s=>a("data_field",s)})]}),l(Zl,{label:"Aggregation",value:t.aggregation,onChange:s=>a("aggregation",s)}),l(d.Divider,{my:"xs",label:"Format",labelPosition:"center"}),l($r,{value:t.formatter,onChange:s=>a("formatter",s)}),i&&l($g,{value:t,onChange:n})]})}),t0=d.createStyles(e=>({root:{height:"100%",overflow:"hidden",".var-list-container":{"& > *":{height:"100%"},width:250,height:"100%"},".var-list-actions":{height:"fit-content",flexShrink:0,width:"100%"},".var-list":{flex:"1 1 auto",overflow:"auto",minHeight:0,"& > *":{flex:"0 0 auto"}}},config:{height:"100%",overflow:"auto",paddingRight:10}})),HG=e=>{const{uiModel:t}=e;return l(d.Stack,{className:"var-list",children:t.variables.map(n=>l(d.Button,{variant:t.selected===n?"filled":"subtle",color:"gray",onClick:()=>t.select(n),children:n.name},n.name))})},WG=te.observer(HG),qG=({variable:e,data:t})=>l(d.Group,{style:{minHeight:0,height:"calc(100% - 68px)"},children:l(d.Paper,{withBorder:!0,p:"md",children:rv(e,t)})}),UG=te.observer(qG),YG=e=>{const t=tt.useCreation(()=>Lz(e.variable),[e.variable]),{classes:n}=t0(),{data:r}=Yt();return y(d.Group,{style:{height:"100%"},align:"start",children:[y(d.Stack,{"data-testid":"variable-editor",align:"stretch",className:n.config,children:[y(d.Group,{position:"right",children:[l(d.ActionIcon,{variant:"filled",disabled:!t.changed,color:"primary",onClick:t.commit,children:l(bu,{size:18})}),l(d.ActionIcon,{color:"red",onClick:()=>e.uiModel.remove(e.variable),children:l(za,{size:18})})]}),l(KG,{value:D.getSnapshot(t.copy),onChange:t.update,data:r})]}),l(UG,{variable:D.getSnapshot(t.copy),data:r})]})},XG=te.observer(YG),QG=()=>{const e=GG(),{classes:t}=t0();return y(d.Group,{className:t.root,noWrap:!0,align:"start",children:[l(d.Paper,{withBorder:!0,p:"md",className:"var-list-container",children:y(d.Stack,{justify:"space-between",children:[l(d.Box,{className:"var-list-actions",children:l(d.Button,{variant:"light",size:"sm",onClick:e.addNew,fullWidth:!0,children:"Add Variable"})}),l(WG,{uiModel:e})]})}),e.selected?l(Oe,{children:l(XG,{uiModel:e,variable:e.selected})}):l("span",{children:"Select or create a new variable on right side"})]})},ZG=te.observer(QG),rd=[];function JG(){const{vizManager:e}=x.useContext(zn);return x.useMemo(()=>e.availableVizList.map(t=>({value:t.name,label:t.displayName})).concat(rd),[e])}function eK(e,t){try{return e.resolveComponent(t).createConfig()}catch{return null}}function tK(){const{data:e,panel:{variables:t,viz:n,title:r,queryID:i,description:o,setDescription:a,setTitle:s,setQueryID:u,id:c}}=Yt(),{vizManager:f}=x.useContext(zn),h={title:r,description:o,viz:n,queryID:i,id:c},p={setDescription:a,setQueryID:u,setTitle:s},g=Yv(h);try{return f.resolveComponent(h.viz.type),l(Fo,{configure:g,children:l(MV,{variables:t,setVizConf:n.setConf,panel:h,panelInfoEditor:p,vizManager:f,data:e})})}catch(v){return console.info(H.get(v,"message")),null}}const nK=te.observer(()=>{const{data:e,panel:{viz:t}}=Yt(),[n,r]=Ut.useInputState(t.type),i=t.type!==n,{vizManager:o}=x.useContext(zn),a=Z.default.useCallback(()=>{if(!i)return;const g=eK(o,n);t.setType(n),t.setConf(g||{})},[t,i,n]),s=g=>{try{t.setConf(JSON.parse(g))}catch(v){console.error(v)}},u=Z.default.useMemo(()=>{var g;return(g=rd.find(v=>v.value===n))==null?void 0:g.Panel},[n,rd]),c=tK(),f=u?x.createElement(u,{data:e,conf:t.conf,setConf:t.setConf}):null,h=c||f,p=JG();return y(d.Stack,{align:"stretch",sx:{height:"100%",overflow:"hidden"},children:[l(d.Select,{label:"Visualization",value:n,onChange:r,data:p,rightSection:l(d.ActionIcon,{disabled:!i,onClick:a,children:l(le.DeviceFloppy,{size:20})})}),l(d.Box,{pb:50,sx:{maxHeight:"calc(100% - 80px)",overflow:"auto"},children:h}),!h&&l(d.JsonInput,{minRows:20,label:"Config",value:JSON.stringify(t.conf,null,2),onChange:s})]})}),rK={root:{flexGrow:1,width:"100%",height:"100%"},panel:{width:"100%",height:"100%",padding:10}},n0=({children:e})=>y(d.Group,{noWrap:!0,grow:!0,position:"left",spacing:20,sx:{width:"100%",height:"calc(100% - 36px)"},children:[l(d.Box,{sx:{maxWidth:"calc(100% - 610px - 10px)",height:"100%",overflow:"auto"},children:e}),l(LG,{})]});function iK(e){return!["richText","button"].includes(e)}const oK=te.observer(({panel:e})=>{const t=Kn.useModals(),n=$e(),[r,i]=x.useState("Data"),{data:o,state:a,error:s}=n.getDataStuffByID(e.queryID),u=n.queries.findByID(e.queryID),f=iK(e.viz.type)&&a==="loading",h=f||s||!u||!!u.stateMessage;x.useEffect(()=>{i(v=>h&&v==="Visualization"?"Data":v)},[e.id,h]);const p=()=>{const v=n.editor.path;n.editor.setPath(["_VIEWS_",v[1]])},g=()=>t.openConfirmModal({title:"Delete this panel?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{e.removeSelf(),p()},confirmProps:{color:"red"},zIndex:320});return y($s,{value:{panel:e,data:o,loading:f,error:s},children:[y(d.Group,{px:16,position:"apart",sx:{borderBottom:"1px solid #eee"},children:[y(d.Text,{pt:9,pb:8,children:[e.title?e.title:e.viz.type," "]}),l(d.Button,{size:"xs",variant:"subtle",color:"red",onClick:g,leftIcon:l(za,{size:14}),children:"Delete This Panel"})]}),y(d.Tabs,{value:r,onTabChange:i,keepMounted:!1,styles:rK,children:[y(d.Tabs.List,{children:[l(d.Tabs.Tab,{value:"Data",disabled:f,children:"Data"}),l(d.Tabs.Tab,{value:"Panel",children:"Panel"}),l(d.Tabs.Tab,{value:"Variables",disabled:h,children:l(d.Tooltip,{label:"Requires data",disabled:!h,withinPortal:!0,zIndex:310,children:l(d.Text,{children:"Variables"})})}),l(d.Tabs.Tab,{value:"Visualization",disabled:h,children:l(d.Tooltip,{label:"Requires data",disabled:!h,withinPortal:!0,zIndex:310,children:l(d.Text,{children:"Visualization"})})}),l(d.Tabs.Tab,{value:"Interactions",children:"Interactions"})]}),y(d.Tabs.Panel,{value:"Data",children:[l(d.LoadingOverlay,{visible:f,exitTransitionDuration:0}),l(BG,{})]}),l(d.Tabs.Panel,{value:"Panel",children:l(n0,{children:l(NG,{})})}),l(d.Tabs.Panel,{value:"Variables",children:l(ZG,{})}),l(d.Tabs.Panel,{value:"Visualization",children:l(Or,{children:l(n0,{children:l(nK,{})})})}),l(d.Tabs.Panel,{value:"Interactions",children:l(Or,{children:l(EV,{})})})]})]})}),aK=te.observer(({viewID:e,panelID:t})=>{const r=$e().views.findByID(e);if(!r)return y(d.Text,{size:14,children:["View by ID[",e,"] is not found"]});const i=r.panels.findByID(t);return i?l(oK,{panel:i}):y(d.Text,{size:14,children:["Panel by ID[",t,"] is not found"]})}),sK=x.forwardRef(({label:e,type:t,...n},r)=>y(d.Group,{position:"apart",ref:r,...n,children:[l(d.Text,{children:e}),l(d.Text,{children:t})]})),lK=te.observer(function({value:t,onChange:n}){const{data:r=[],loading:i}=tt.useRequest(Xu,{refreshDeps:[]},[]),o=x.useMemo(()=>r.map(s=>({label:s.key,value:s.key,type:s.type})),[r]),a=x.useMemo(()=>o.reduce((s,u)=>(s[u.value]=u.type,s),{}),[o]);return l(d.Select,{label:"Data Source",data:o,itemComponent:sK,sx:{flex:1},required:!0,disabled:i,value:t.key,onChange:s=>{s!==null&&n({key:s,type:a[s]})}})}),uK=e=>{const{queryModel:t}=e,n=$e(),i=n.findQueryUsage(t.id).length>0,o=Kn.useModals(),a=()=>{o.openConfirmModal({title:"Delete this query?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>{n.queries.removeQuery(t.id),n.editor.setPath(["_QUERIES_",""])},zIndex:320})};return i?l(d.Tooltip,{label:"Can't delete this query for it's being used, check out Usage tab for details",withArrow:!0,events:{hover:!0,focus:!1,touch:!1},withinPortal:!0,children:l(d.Button,{color:"gray",size:"xs",leftIcon:l(za,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})}):l(d.Button,{color:"red",size:"xs",onClick:a,leftIcon:l(za,{size:16}),sx:{alignSelf:"flex-end"},children:"Delete this Query"})},cK=te.observer(uK),dK=te.observer(({queryModel:e})=>l(d.Center,{ml:20,mt:20,sx:{maxWidth:"600px"},children:y(d.Stack,{spacing:10,sx:{width:"100%"},children:[l(d.Divider,{mb:-10,variant:"dashed",label:"Basics",labelPosition:"center"}),l(d.TextInput,{placeholder:"A unique name",label:"Name",required:!0,sx:{flex:1},value:e.name,onChange:t=>{e.setName(t.currentTarget.value)}}),l(lK,{value:{type:e.type,key:e.key},onChange:({type:t,key:n})=>{e.setKey(n),e.setType(t)}}),l(d.Divider,{mt:10,mb:-10,variant:"dashed",label:"Conditions",labelPosition:"center"}),l(d.MultiSelect,{label:"Run query when these are truthy",data:e.conditionOptions,value:[...e.run_by],onChange:e.setRunBy}),l(d.Divider,{mt:20,mb:10,variant:"dashed"}),l(cK,{queryModel:e})]})})),fK=({value:e,onChange:t})=>{const n=r=>{!r||t(r)};return l(d.Box,{sx:{position:"relative",flexGrow:1},children:l(Tn.default,{height:"100%",defaultLanguage:"javascript",value:e,onChange:n,theme:"vs-dark",options:{minimap:{enabled:!1}}})})},r0=x.forwardRef(({value:e,onChange:t,label:n,defaultValue:r},i)=>{const[o,a]=x.useState(e),s=()=>{t(o)},u=()=>{a(e)},c=()=>{a(r)};x.useEffect(()=>{a(e)},[e]);const f=o!==e;return y(d.Stack,{spacing:4,sx:{height:"100%"},children:[l(d.Text,{size:14,children:n}),l(fK,{value:o,onChange:a}),y(d.Group,{mt:10,position:"apart",sx:{flexShrink:0,flexGrow:0},children:[l(d.Button,{onClick:c,size:"xs",color:"red",leftIcon:l(le.Recycle,{size:16}),children:"Reset to default"}),f&&y(d.Group,{position:"right",children:[l(d.Button,{onClick:u,variant:"subtle",size:"xs",children:"Cancel"}),l(d.Button,{size:"xs",onClick:s,children:"OK"})]})]})]})}),pK=`
307
307
  -- You may reference global variables in SQL or VizConfig.
308
308
  SELECT *
309
309
  FROM commit
@@ -317,4 +317,4 @@ WHERE
317
317
  \${sql_snippets.order_by_clause}
318
318
  `,i0=te.observer(function({showSQLSnippets:t=!0,sx:n={}}){const r=$e(),i=r.context.current,o=(()=>{const a={context:{...r.mock_context.current,...i},filters:r.filters.previewValues};return t&&(a.sql_snippets=r.sqlSnippets.record),JSON.stringify(a,null,2)})();return l(d.Stack,{sx:{overflow:"hidden",...n},children:y(d.Stack,{sx:{width:"100%"},children:[l(d.Text,{weight:500,sx:{flexGrow:0},children:"Guide"}),l(Ur.Prism,{language:"sql",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:pK}),l(d.Text,{weight:500,sx:{flexGrow:0},children:"Current Values"}),l(Ur.Prism,{language:"json",sx:{width:"100%"},noCopy:!0,colorScheme:"dark",children:o})]})})}),id=te.observer(()=>{const[e,t]=x.useState(!1);return y(Oe,{children:[l(d.Modal,{opened:e,onClose:()=>t(!1),title:"Global Variables",zIndex:320,size:"800px",children:l(i0,{})}),l(d.Button,{variant:"subtle",onClick:()=>t(!0),children:"See Global Variables"})]})}),o0={pre:["function build_request({ context, filters }, utils) {"," // build the quest"," return { method, url, params, headers, data }","}"].join(`
319
319
  `),post:["function process_result(res, utils) {"," // your code goes here"," return data","}"].join(`
320
- `)},hK=te.observer(({queryModel:e})=>e.typedAsHTTP?y(d.Tabs,{defaultValue:"pre_process",orientation:"vertical",sx:{flexGrow:1},children:[y(d.Tabs.List,{children:[l(d.Tabs.Tab,{value:"pre_process",children:"Build Request"}),l(d.Tabs.Tab,{value:"post_process",children:"Process Result"}),l(id,{})]}),l(d.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:l(r0,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:o0.pre})}),l(d.Tabs.Panel,{value:"post_process",p:"sm",children:l(r0,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:o0.post})})]}):null),od=({value:e,onChange:t,height:n="200px",defaultLanguage:r="sql"})=>{const i=a=>{console.log("changing"),t==null||t(a!=null?a:"")},o=!t;return l(Tn.default,{className:"minimal-monaco-editor",height:n,defaultLanguage:r,value:e,onChange:o?void 0:i,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:o||!t}})},gK=({value:e,height:t="200px",defaultLanguage:n="sql"})=>l(Tn.default,{className:"preview-sql-in-monaco-editor",height:t,defaultLanguage:n,value:e,onChange:void 0,theme:"vs-light",options:{lineNumbers:"on",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:!0}}),vK=te.observer(({value:e})=>{const t=$e(),n=t.context.current,r=Z.default.useMemo(()=>vm(e,n,t.mock_context.current,t.sqlSnippets.current,t.filters.values),[e,n,t.mock_context.current,t.sqlSnippets.current,t.filters.values]);return l(gK,{height:"100%",value:r})}),mK=te.observer(({queryModel:e})=>{const[t,n]=Z.default.useState(e.sql);Z.default.useEffect(()=>{n(o=>o!==e.sql?e.sql:o)},[e.sql]);const r=t!==e.sql,i=()=>{e.setSQL(t)};return e.typedAsSQL?y(d.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%"}},keepMounted:!1,children:[y(d.Tabs.List,{children:[l(d.Tabs.Tab,{value:"Edit",children:y(d.Group,{spacing:14,position:"apart",children:["Edit",l(d.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!r,onClick:i,children:l(le.DeviceFloppy,{size:20})})]})}),l(d.Tabs.Tab,{value:"Preview",children:"Preview"}),l(id,{})]}),l(d.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:l(od,{height:"100%",value:t,onChange:n})}),l(d.Tabs.Panel,{value:"Preview",p:0,pl:4,children:l(vK,{value:e.sql})})]}):null}),yK=te.observer(({queryID:e,usage:t})=>{const n=$e().editor,r=i=>{if(i.type==="filter"){n.setPath(["_FILTERS_",i.id]);return}if(i.type==="panel"){n.setPath(["_VIEWS_",i.viewID,"_PANELS_",i.id]);return}};return l(d.Stack,{py:"sm",px:"md",children:y(d.Table,{highlightOnHover:!0,children:[l("thead",{children:y("tr",{children:[l("th",{children:"Type"}),l("th",{children:"Name / Label"}),l("th",{children:"Action"})]})}),l("tbody",{children:t.map(i=>y("tr",{children:[l("td",{children:fe.default.capitalize(i.type)}),l("td",{children:i.label}),l("td",{children:l(d.Button,{compact:!0,variant:"subtle",onClick:()=>r(i),children:"Open"})})]},i.id))})]})})}),ks={height:"calc(100% - 44px)",padding:0},bK=te.observer(({queryModel:e})=>{const t=$e(),n=x.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),r=t.findQueryUsage(e.id),i=r.length===0;return l(d.Stack,{sx:{flexGrow:1},my:0,p:0,children:y(d.Tabs,{defaultValue:n,orientation:"horizontal",keepMounted:!1,sx:{flexGrow:1},children:[y(d.Tabs.List,{grow:!0,children:[l(d.Tabs.Tab,{value:"Configurations",children:"Configurations"}),e.typedAsSQL&&l(d.Tabs.Tab,{value:"SQL",children:"SQL"}),e.typedAsHTTP&&l(d.Tabs.Tab,{value:"HTTP",children:"Request"}),l(d.Tabs.Tab,{value:"Data",disabled:!e.datasource,children:l(d.Tooltip,{label:"Need to pick a Data Source first",disabled:e.datasource,withinPortal:!0,children:l(d.Text,{children:"Data"})})}),l(d.Tabs.Tab,{value:"Usage",disabled:i,children:l(d.Tooltip,{label:"This query is not used for any filter or panel",disabled:!i,withinPortal:!0,children:l(d.Text,{children:"Usage"})})})]}),l(d.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:l(dK,{queryModel:e})}),e.typedAsSQL&&l(d.Tabs.Panel,{value:"SQL",sx:ks,children:l(d.Stack,{sx:{height:"100%"},children:l(mK,{queryModel:e})})}),e.typedAsHTTP&&l(d.Tabs.Panel,{value:"HTTP",sx:ks,children:l(d.Stack,{sx:{height:"100%"},children:l(hK,{queryModel:e})})}),l(d.Tabs.Panel,{value:"Data",sx:{...ks,overflow:"hidden"},children:l(e0,{id:e.id})}),l(d.Tabs.Panel,{value:"Usage",sx:{...ks,overflow:"hidden"},children:l(yK,{queryID:e.id,usage:r})})]})})}),wK=te.observer(({id:e})=>{const t=$e(),n=x.useMemo(()=>t.queries.findByID(e),[t.queries,e]);return e===""?null:n?l(d.Stack,{sx:{height:"100%"},spacing:"sm",children:l(bK,{queryModel:n})}):l(d.Text,{size:14,color:"red",children:"Invalid Query ID"})}),xK=te.observer(({value:e})=>{const t=$e(),n=t.context.current,r=wz(e,n,t.mock_context.current,t.filters.values);return l(od,{height:"100%",value:r})}),SK=te.observer(({item:e,remove:t,onKeyChanged:n})=>{const[r,i]=x.useState("SQL"),[o,a]=x.useState(e.key),s=()=>{e.setKey(o),n(o)},u=o!==e.key,c=e.isADuplicatedKey(o),[f,h]=x.useState(e.value),p=()=>{e.setValue(f)};x.useEffect(()=>{a(e.key),h(e.value)},[e]);const g=f!==e.value,v=Kn.useModals(),m=()=>{v.openConfirmModal({title:"Delete this SQL snippet?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:t,zIndex:320})};return y(d.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[y(d.Group,{sx:{alignItems:"end"},spacing:40,children:[l(d.TextInput,{label:c?"This key is occupied by another snippet":"Key",value:o,onChange:w=>{a(w.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:l(d.ActionIcon,{color:"blue",variant:"subtle",onClick:s,disabled:!u||c,children:l(le.DeviceFloppy,{size:16})}),error:c}),l(d.Button,{leftIcon:l(le.Trash,{size:16}),color:"red",variant:"light",onClick:m,children:"Delete this SQL Snippet"})]}),y(d.Tabs,{value:r,onTabChange:i,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[y(d.Tabs.List,{sx:{position:"relative"},children:[l(d.Tabs.Tab,{value:"SQL",children:"SQL"}),l(d.Tabs.Tab,{value:"Preview",children:"Preview"}),l(id,{}),l(d.ActionIcon,{color:"blue",variant:"filled",onClick:p,disabled:!g,sx:{position:"absolute",top:0,right:10},children:l(le.DeviceFloppy,{size:18})})]}),l(d.Tabs.Panel,{value:"SQL",pt:"sm",children:l(od,{height:"100%",value:f,onChange:h})}),l(d.Tabs.Panel,{value:"Preview",pt:"sm",children:l(xK,{value:f})})]})]})}),CK=te.observer(({id:e})=>{const t=$e(),n=x.useMemo(()=>t.sqlSnippets.findByKey(e),[e]);return n?l(SK,{item:n,remove:()=>t.sqlSnippets.removeByKey(e),onKeyChanged:o=>{t.editor.setPath(["_SQL_SNIPPETS_",o])}}):y(d.Text,{size:14,children:["SQL Snippet by key[",e,"] is not found"]})}),_K=te.observer(({view:e})=>!e||e.type!==rt.Division?null:y(d.Stack,{children:[l(d.Divider,{mt:8,mb:0,label:"Division settings",labelPosition:"center"}),l(d.Text,{align:"center",size:"xs",color:"dimmed",children:"Under construction"})]})),EK=[{value:"default",label:"Default"},{value:"outline",label:"Outline"},{value:"pills",label:"Pills"}],TK=[{value:"horizontal",label:"Horizontal"},{value:"vertical",label:"Vertical"}],MK=te.observer(({view:e})=>{if(!e||e.type!==rt.Tabs)return null;const t=e.config;return y(d.Stack,{children:[l(d.Divider,{mt:8,mb:0,label:"Tabs settings",labelPosition:"center"}),l(d.Select,{label:"Variant",value:t.variant,onChange:t.setVariant,data:EK}),l(d.Select,{label:"Orientation",value:t.orientation,onChange:t.setOrientation,data:TK}),l(d.Switch,{label:"Grow Tabs",checked:t.grow,onChange:n=>t.setGrow(n.currentTarget.checked)})]})}),kK=({disabled:e,value:t,onChange:n})=>{const r=i=>{!i||n(i)};return y(d.Box,{sx:{position:"relative"},children:[e&&l(d.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),l(Tn.default,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},OK=({value:e,onChange:t})=>{const[n,{setTrue:r,setFalse:i}]=tt.useBoolean(),[o,a]=x.useState(e!=null?e:Qu),s=p=>{a({...o,enabled:p})},u=()=>{i();const{enabled:p,func_content:g}=o,v={enabled:p,func_content:g};a(v),t(v)},c=()=>{i(),a(e)},f=p=>{a(g=>({...g,func_content:p}))},h=()=>{f(Qu.func_content)};return y(Oe,{children:[l(d.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:r,sx:{flexGrow:0},children:l(le.Settings,{size:14})}),l(d.Modal,{size:800,title:"Customize modal title",opened:n,onClose:i,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:n&&y(d.Stack,{children:[l(d.Checkbox,{mt:10,label:"Enabled",checked:o.enabled,onChange:p=>s(p.currentTarget.checked)}),l(kK,{value:o.func_content,onChange:f,disabled:!o.enabled}),y(d.Group,{position:"apart",children:[l(d.Button,{onClick:h,color:"red",leftIcon:l(le.Recycle,{size:20}),children:"Rest"}),y(d.Group,{position:"right",children:[l(d.Button,{onClick:c,variant:"subtle",children:"Cancel"}),l(d.Button,{onClick:u,children:"OK"})]})]})]})})]})},DK=te.observer(({view:e})=>{if(!e||e.type!==rt.Modal)return null;const t=e.config,n=t.custom_modal_title.value;return y(d.Stack,{children:[l(d.Divider,{mt:8,label:"Modal settings",labelPosition:"center"}),y(d.Flex,{gap:10,children:[l(d.TextInput,{label:"Modal Title",value:n,onChange:fe.default.noop,disabled:!0,sx:{flexGrow:1}}),l(OK,{value:t.custom_modal_title,onChange:t.custom_modal_title.replace})]}),y(d.Group,{grow:!0,children:[l(d.TextInput,{label:"Width",value:t.width,onChange:r=>t.setWidth(r.currentTarget.value),placeholder:"600px / 50vw"}),l(d.TextInput,{label:"Height",value:t.height,onChange:r=>t.setHeight(r.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),RK=te.observer(({view:e})=>y(Oe,{children:[l(_K,{view:e}),l(DK,{view:e}),l(MK,{view:e})]})),AK=[{label:"Division",value:rt.Division},{label:"Modal",value:rt.Modal},{label:"Tabs",value:rt.Tabs}],PK=te.observer(({view:e})=>e?y(d.Stack,{sx:{position:"relative"},children:[l(d.TextInput,{label:"Name",value:e.name,onChange:t=>{e.setName(t.currentTarget.value)}}),l(d.Select,{label:"Type",withinPortal:!0,value:e.type,onChange:e.setType,data:AK}),l(RK,{view:e})]}):null),IK=te.observer(({id:e})=>{const t=Kn.useModals(),n=$e(),r=n.views.findByID(e);if(!r)return y(d.Text,{size:14,children:["View by ID[",e,"] is not found"]});const i=()=>{t.openConfirmModal({title:"Delete this view?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>n.views.removeByID(e),zIndex:320})};return y(d.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[l(d.Group,{position:"right",pt:10,children:l(d.Button,{size:"xs",color:"red",leftIcon:l(le.Trash,{size:16}),onClick:i,children:"Delete this view"})}),l(d.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:l(PK,{view:r})})]})});function NK(e){return e.length===1&&e[0]==="_GLOBAL_VARS_"}function $K(e){return e.length===1&&e[0]==="_MOCK_CONTEXT_"}function LK(e){return e.length===2&&e[0]==="_FILTERS_"}function VK(e){return e.length===2&&e[0]==="_SQL_SNIPPETS_"}function zK(e){return e.length===2&&e[0]==="_QUERIES_"}function FK(e){return e.length===2&&e[0]==="_VIEWS_"}function BK(e){return e.length===4&&e[0]==="_VIEWS_"&&e[2]==="_PANELS_"}const jK=te.observer(()=>l(d.Stack,{sx:{height:"100%"},p:"sm",children:l(i0,{})})),GK=te.observer(()=>{const e=$e().editor,t=e.path;return NK(t)?l(jK,{}):$K(t)?l(RG,{}):LK(t)?l(d.Box,{p:"xs",pl:20,children:l(DG,{id:t[1]})}):VK(t)?l(CK,{id:t[1]}):zK(t)?l(wK,{id:t[1]}):FK(t)?l(d.Box,{p:"xs",pl:20,children:l(IK,{id:t[1]})}):BK(t)?l(aK,{viewID:t[1],panelID:t[3]}):l(d.Box,{children:e.path})}),KK=te.observer(()=>($e().editor,l(GK,{}))),HK=te.observer(()=>{const e=$e(),t=()=>{const n=new Date().getTime().toString(),r={id:n,key:n,label:n,order:e.filters.current.length+1,type:Hu.TextInput,config:cm(),visibleInViewsIDs:["Main"],auto_submit:!1};e.filters.append(r)};return l(d.Button,{variant:"subtle",leftIcon:l(bi,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Filter"})}),WK=te.observer(({parentID:e})=>{const t=$e();if(!e)return null;const n=t.views.findByID(e);return n?l(d.Button,{variant:"subtle",leftIcon:l(bi,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n.panels.addANewPanel,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Panel"}):null}),qK=te.observer(()=>{const e=$e(),t=()=>{const n=new Date().getTime().toString(),r={id:n,name:n,type:Sn.Postgresql,key:"",sql:""};e.queries.append(r)};return l(d.Button,{variant:"subtle",leftIcon:l(bi,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Query"})}),UK=te.observer(()=>{const e=$e(),t=()=>{const r={key:new Date().getTime().toString(),value:""};e.sqlSnippets.append(r)};return l(d.Button,{variant:"subtle",leftIcon:l(bi,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a SQL Snippet"})}),YK=te.observer(()=>{const e=$e();return l(d.Button,{variant:"subtle",leftIcon:l(bi,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:e.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a View"})}),XK=te.observer(({action_type:e,parentID:t})=>($e(),e==="_Add_A_Filter_"?l(HK,{}):e==="_Add_A_SQL_SNIPPET_"?l(UK,{}):e==="_Add_A_QUERY_"?l(qK,{}):e==="_Add_A_VIEW_"?l(YK,{}):e==="_Add_A_PANEL_"?l(WK,{parentID:t}):null)),a0=te.observer(({option:e})=>{var a;const t=$e().editor,n=t.isOptionActive,r=n(t.path,e),i=t.isOptionOpened,o=t.navigate;return l(d.NavLink,{active:r,defaultOpened:i(e),label:e.label,onClick:()=>o(e),icon:e.Icon?l(e.Icon,{size:18}):null,children:(a=e.children)==null?void 0:a.map(s=>s._type==="ACTION"?l(XK,{action_type:s._action_type,parentID:s.parentID},`_ADD_${s.value}_`):l(a0,{option:s},s.value))},e.label)}),QK=te.observer(()=>{const e=$e();return l(d.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>l(a0,{option:t},t.value))})}),ZK=te.observer(()=>{const e=$e();return y(d.Navbar,{p:0,width:{base:200,xs:200,sm:220,md:240,lg:280,xl:300},sx:{height:"100vh - 60px - 60px"},children:[l(d.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:l(d.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Settings"})}),l(d.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:l(QK,{})}),l(d.Navbar.Section,{children:l(d.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:l(d.Button,{size:"xs",color:"red",leftIcon:l(TI,{size:18}),onClick:()=>e.editor.close(),children:"Close"})})})]})}),JK={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},e6=te.observer(()=>{const e=$e().editor;return l(d.Modal,{onClose:()=>e.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:e.settings_open,fullScreen:!0,title:null,transitionDuration:0,withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{modal:{padding:"0 !important"}},children:l(d.AppShell,{padding:0,navbar:l(ZK,{}),styles:JK,children:l(KK,{})})})});self.MonacoEnvironment={getWorker:function(e,t){const n=(r,i)=>new Worker(self.MonacoEnvironment.getWorker(r),{name:i,type:"module"});switch(t){case"typescript":case"javascript":return n("/monaco-editor/min/vs/language/typescript/ts.worker?worker",t);default:return n("/monaco-editor/min/vs/editor/editor.worker?worker",t)}}};function t6(){Lo.loader.__getMonacoInstance()||(console.log("loading monaco"),Lo.loader.config({paths:{vs:"/assets/monaco-editor/min/vs"}}),Lo.loader.init().then(t=>console.log("here is the monaco instance:",t)))}t6();const n6={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60,height:"100vh"}},r6=te.observer(function({context:t,dashboard:n,update:r,className:i="dashboard",config:o}){rm(o);const{data:a=[]}=tt.useRequest(Xu),[s,u]=Z.default.useState(!1),c=Z.default.useMemo(()=>Zu(n,a,t),[n]);pd(c,!0),Z.default.useEffect(()=>{c.context.replace(t)},[t]),Z.default.useEffect(()=>{c.datasources.replace(a)},[a]);const f=async()=>{const g=[...c.queries.json],v=[...c.sqlSnippets.json],m=[...c.views.json],w={...c.mock_context.current},b={...n,filters:[...c.filters.current],views:m,definition:{queries:g,sqlSnippets:v,mock_context:w}};await r(b)},h=tt.useCreation(Gu,[]),p=Ju(h);return l(Kn.ModalsProvider,{children:l(Ns,{value:c,children:l(Dr.Provider,{value:{layoutFrozen:s,freezeLayout:u,inEditMode:!0},children:l(zn.Provider,{value:h,children:y(Fo,{configure:p,children:[l(d.AppShell,{padding:0,header:l(Zz,{saveDashboardChanges:f}),navbar:l(gG,{}),styles:n6,children:l(d.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:c.views.visibleViews.map(g=>l(nm,{view:g},g.id))})}),l(e6,{})]})})})})})}),$6="",i6=te.observer(({context:e,dashboard:t,className:n="dashboard",config:r,fullScreenPanelID:i,setFullScreenPanelID:o})=>{rm(r);const{data:a=[]}=tt.useRequest(Xu),s=Z.default.useMemo(()=>Zu(t,a,e),[t]);pd(s,!1),Z.default.useEffect(()=>{s.context.replace(e)},[e]),Z.default.useEffect(()=>{s.datasources.replace(a)},[a]);const u=tt.useCreation(Gu,[]),c=Ju(u);return l(Kn.ModalsProvider,{children:l(Ns,{value:s,children:l(Ls.Provider,{value:{fullScreenPanelID:i,setFullScreenPanelID:o},children:l(Dr.Provider,{value:{layoutFrozen:!0,freezeLayout:fe.default.noop,inEditMode:!1},children:l(d.Box,{className:`${n} dashboard-root`,children:l(zn.Provider,{value:u,children:l(Fo,{configure:c,children:s.views.visibleViews.map(f=>l(Ya,{view:f},f.id))})})})})})})})});var s0={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(hn,function(){var n={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(i,o,a){var s,u=function(p,g,v){v===void 0&&(v={});var m=new Date(p),w=function(b,_){_===void 0&&(_={});var C=_.timeZoneName||"short",S=b+"|"+C,E=r[S];return E||(E=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:b,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:C}),r[S]=E),E}(g,v);return w.formatToParts(m)},c=function(p,g){for(var v=u(p,g),m=[],w=0;w<v.length;w+=1){var b=v[w],_=b.type,C=b.value,S=n[_];S>=0&&(m[S]=parseInt(C,10))}var E=m[3],k=E===24?0:E,A=m[0]+"-"+m[1]+"-"+m[2]+" "+k+":"+m[4]+":"+m[5]+":000",L=+p;return(a.utc(A).valueOf()-(L-=L%1e3))/6e4},f=o.prototype;f.tz=function(p,g){p===void 0&&(p=s);var v=this.utcOffset(),m=this.toDate(),w=m.toLocaleString("en-US",{timeZone:p}),b=Math.round((m-new Date(w))/1e3/60),_=a(w).$set("millisecond",this.$ms).utcOffset(15*-Math.round(m.getTimezoneOffset()/15)-b,!0);if(g){var C=_.utcOffset();_=_.add(v-C,"minute")}return _.$x.$timezone=p,_},f.offsetName=function(p){var g=this.$x.$timezone||a.tz.guess(),v=u(this.valueOf(),g,{timeZoneName:p}).find(function(m){return m.type.toLowerCase()==="timezonename"});return v&&v.value};var h=f.startOf;f.startOf=function(p,g){if(!this.$x||!this.$x.$timezone)return h.call(this,p,g);var v=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return h.call(v,p,g).tz(this.$x.$timezone,!0)},a.tz=function(p,g,v){var m=v&&g,w=v||g||s,b=c(+a(),w);if(typeof p!="string")return a(p).tz(w);var _=function(k,A,L){var F=k-60*A*1e3,P=c(F,L);if(A===P)return[F,A];var O=c(F-=60*(P-A)*1e3,L);return P===O?[F,P]:[k-60*Math.min(P,O)*1e3,Math.max(P,O)]}(a.utc(p,m).valueOf(),b,w),C=_[0],S=_[1],E=a(C).utcOffset(S);return E.$x.$timezone=w,E},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(p){s=p}}})})(s0);const o6=s0.exports;var l0={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(hn,function(){var n="minute",r=/[+-]\d\d(?::?\d\d)?/g,i=/([+-]|\d\d)/g;return function(o,a,s){var u=a.prototype;s.utc=function(m){var w={date:m,utc:!0,args:arguments};return new a(w)},u.utc=function(m){var w=s(this.toDate(),{locale:this.$L,utc:!0});return m?w.add(this.utcOffset(),n):w},u.local=function(){return s(this.toDate(),{locale:this.$L,utc:!1})};var c=u.parse;u.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),c.call(this,m)};var f=u.init;u.init=function(){if(this.$u){var m=this.$d;this.$y=m.getUTCFullYear(),this.$M=m.getUTCMonth(),this.$D=m.getUTCDate(),this.$W=m.getUTCDay(),this.$H=m.getUTCHours(),this.$m=m.getUTCMinutes(),this.$s=m.getUTCSeconds(),this.$ms=m.getUTCMilliseconds()}else f.call(this)};var h=u.utcOffset;u.utcOffset=function(m,w){var b=this.$utils().u;if(b(m))return this.$u?0:b(this.$offset)?h.call(this):this.$offset;if(typeof m=="string"&&(m=function(E){E===void 0&&(E="");var k=E.match(r);if(!k)return null;var A=(""+k[0]).match(i)||["-",0,0],L=A[0],F=60*+A[1]+ +A[2];return F===0?0:L==="+"?F:-F}(m),m===null))return this;var _=Math.abs(m)<=16?60*m:m,C=this;if(w)return C.$offset=_,C.$u=m===0,C;if(m!==0){var S=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(C=this.local().add(_+S,n)).$offset=_,C.$x.$localOffset=S}else C=this.utc();return C};var p=u.format;u.format=function(m){var w=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return p.call(this,w)},u.valueOf=function(){var m=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*m},u.isUTC=function(){return!!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var g=u.toDate;u.toDate=function(m){return m==="s"&&this.$offset?s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():g.call(this)};var v=u.diff;u.diff=function(m,w,b){if(m&&this.$u===m.$u)return v.call(this,m,w,b);var _=this.local(),C=s(m).local();return v.call(_,C,w,b)}}})})(l0);const a6=l0.exports,s6=()=>Promise.resolve().then(()=>VD).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));En.default.extend(a6),En.default.extend(o6),En.default.tz.setDefault("UTC"),de.ContextModel=xm,de.Dashboard=r6,de.DashboardFilterType=Hu,de.DashboardMode=em,de.DashboardModel=Ja,de.DashboardViewEditor=nm,de.DashboardViewRender=Ya,de.EViewComponentType=rt,de.FilterModel=qu,de.FiltersModel=pm,de.FullScreenPanelContext=Ls,de.LayoutStateContext=Dr,de.ModelContextProvider=Ns,de.Panel=Ua,de.PanelContextProvider=$s,de.QueriesModel=ym,de.QueryModel=mm,de.ReadOnlyDashboard=i6,de.SQLSnippetModel=bm,de.SQLSnippetsModel=wm,de.ViewComponentTypeBackground=tm,de.ViewComponentTypeColor=BV,de.ViewComponentTypeName=FV,de.ViewModel=Em,de.ViewsModel=Tm,de.createDashboardModel=Zu,de.createDashboardViewsModel=Mm,de.getInitialFiltersPayload=hm,de.getVersion=s6,de.useFullScreenPanelContext=wd,de.useModelContext=$e,de.usePanelContext=Yt,de.useTopLevelServices=Ju,Object.defineProperties(de,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
320
+ `)},hK=te.observer(({queryModel:e})=>e.typedAsHTTP?y(d.Tabs,{defaultValue:"pre_process",orientation:"vertical",sx:{flexGrow:1},children:[y(d.Tabs.List,{children:[l(d.Tabs.Tab,{value:"pre_process",children:"Build Request"}),l(d.Tabs.Tab,{value:"post_process",children:"Process Result"}),l(id,{})]}),l(d.Tabs.Panel,{value:"pre_process",sx:{position:"relative"},p:"sm",children:l(r0,{label:"",value:e.pre_process,onChange:e.setPreProcess,defaultValue:o0.pre})}),l(d.Tabs.Panel,{value:"post_process",p:"sm",children:l(r0,{label:"",value:e.post_process,onChange:e.setPostProcess,defaultValue:o0.post})})]}):null),od=({value:e,onChange:t,height:n="200px",defaultLanguage:r="sql"})=>{const i=a=>{console.log("changing"),t==null||t(a!=null?a:"")},o=!t;return l(Tn.default,{className:"minimal-monaco-editor",height:n,defaultLanguage:r,value:e,onChange:o?void 0:i,theme:"vs-dark",options:{lineNumbers:"off",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:o||!t}})},gK=({value:e,height:t="200px",defaultLanguage:n="sql"})=>l(Tn.default,{className:"preview-sql-in-monaco-editor",height:t,defaultLanguage:n,value:e,onChange:void 0,theme:"vs-light",options:{lineNumbers:"on",folding:!1,lineDecorationsWidth:20,lineNumbersMinChars:0,wordWrap:"on",minimap:{enabled:!1},readOnly:!0}}),vK=te.observer(({value:e})=>{const t=$e(),n=t.context.current,r=Z.default.useMemo(()=>vm(e,n,t.mock_context.current,t.sqlSnippets.current,t.filters.values),[e,n,t.mock_context.current,t.sqlSnippets.current,t.filters.values]);return l(gK,{height:"100%",value:r})}),mK=te.observer(({queryModel:e})=>{const[t,n]=Z.default.useState(e.sql);Z.default.useEffect(()=>{n(o=>o!==e.sql?e.sql:o)},[e.sql]);const r=t!==e.sql,i=()=>{e.setSQL(t)};return e.typedAsSQL?y(d.Tabs,{defaultValue:"Edit",orientation:"vertical",sx:{flexGrow:1},styles:{tabLabel:{width:"100%"}},keepMounted:!1,children:[y(d.Tabs.List,{children:[l(d.Tabs.Tab,{value:"Edit",children:y(d.Group,{spacing:14,position:"apart",children:["Edit",l(d.ActionIcon,{mr:5,variant:"filled",color:"blue",disabled:!r,onClick:i,children:l(le.DeviceFloppy,{size:20})})]})}),l(d.Tabs.Tab,{value:"Preview",children:"Preview"}),l(id,{})]}),l(d.Tabs.Panel,{value:"Edit",sx:{position:"relative"},p:"sm",children:l(od,{height:"100%",value:t,onChange:n})}),l(d.Tabs.Panel,{value:"Preview",p:0,pl:4,children:l(vK,{value:e.sql})})]}):null}),yK=te.observer(({queryID:e,usage:t})=>{const n=$e().editor,r=i=>{if(i.type==="filter"){n.setPath(["_FILTERS_",i.id]);return}if(i.type==="panel"){n.setPath(["_VIEWS_",i.viewID,"_PANELS_",i.id]);return}};return l(d.Stack,{py:"sm",px:"md",children:y(d.Table,{highlightOnHover:!0,children:[l("thead",{children:y("tr",{children:[l("th",{children:"Type"}),l("th",{children:"Name / Label"}),l("th",{children:"Action"})]})}),l("tbody",{children:t.map(i=>y("tr",{children:[l("td",{children:fe.default.capitalize(i.type)}),l("td",{children:i.label}),l("td",{children:l(d.Button,{compact:!0,variant:"subtle",onClick:()=>r(i),children:"Open"})})]},i.id))})]})})}),ks={height:"calc(100% - 44px)",padding:0},bK=te.observer(({queryModel:e})=>{const t=$e(),n=x.useMemo(()=>e.datasource?e.typedAsHTTP?"HTTP":"SQL":"Configurations",[e.datasource,e.typedAsHTTP]),r=t.findQueryUsage(e.id),i=r.length===0;return l(d.Stack,{sx:{flexGrow:1},my:0,p:0,children:y(d.Tabs,{defaultValue:n,orientation:"horizontal",keepMounted:!1,sx:{flexGrow:1},children:[y(d.Tabs.List,{grow:!0,children:[l(d.Tabs.Tab,{value:"Configurations",children:"Configurations"}),e.typedAsSQL&&l(d.Tabs.Tab,{value:"SQL",children:"SQL"}),e.typedAsHTTP&&l(d.Tabs.Tab,{value:"HTTP",children:"Request"}),l(d.Tabs.Tab,{value:"Data",disabled:!e.datasource,children:l(d.Tooltip,{label:"Need to pick a Data Source first",disabled:e.datasource,withinPortal:!0,children:l(d.Text,{children:"Data"})})}),l(d.Tabs.Tab,{value:"Usage",disabled:i,children:l(d.Tooltip,{label:"This query is not used for any filter or panel",disabled:!i,withinPortal:!0,children:l(d.Text,{children:"Usage"})})})]}),l(d.Tabs.Panel,{value:"Configurations",pt:0,p:0,children:l(dK,{queryModel:e})}),e.typedAsSQL&&l(d.Tabs.Panel,{value:"SQL",sx:ks,children:l(d.Stack,{sx:{height:"100%"},children:l(mK,{queryModel:e})})}),e.typedAsHTTP&&l(d.Tabs.Panel,{value:"HTTP",sx:ks,children:l(d.Stack,{sx:{height:"100%"},children:l(hK,{queryModel:e})})}),l(d.Tabs.Panel,{value:"Data",sx:{...ks,overflow:"hidden"},children:l(e0,{id:e.id})}),l(d.Tabs.Panel,{value:"Usage",sx:{...ks,overflow:"hidden"},children:l(yK,{queryID:e.id,usage:r})})]})})}),wK=te.observer(({id:e})=>{const t=$e(),n=x.useMemo(()=>t.queries.findByID(e),[t.queries,e]);return e===""?null:n?l(d.Stack,{sx:{height:"100%"},spacing:"sm",children:l(bK,{queryModel:n})}):l(d.Text,{size:14,color:"red",children:"Invalid Query ID"})}),xK=te.observer(({value:e})=>{const t=$e(),n=t.context.current,r=wz(e,n,t.mock_context.current,t.filters.values);return l(od,{height:"100%",value:r})}),SK=te.observer(({item:e,remove:t,onKeyChanged:n})=>{const[r,i]=x.useState("SQL"),[o,a]=x.useState(e.key),s=()=>{e.setKey(o),n(o)},u=o!==e.key,c=e.isADuplicatedKey(o),[f,h]=x.useState(e.value),p=()=>{e.setValue(f)};x.useEffect(()=>{a(e.key),h(e.value)},[e]);const g=f!==e.value,v=Kn.useModals(),m=()=>{v.openConfirmModal({title:"Delete this SQL snippet?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:t,zIndex:320})};return y(d.Stack,{p:20,sx:{maxWidth:"1100px",height:"100vh"},spacing:"sm",children:[y(d.Group,{sx:{alignItems:"end"},spacing:40,children:[l(d.TextInput,{label:c?"This key is occupied by another snippet":"Key",value:o,onChange:w=>{a(w.currentTarget.value)},sx:{flexGrow:"1 !important"},rightSection:l(d.ActionIcon,{color:"blue",variant:"subtle",onClick:s,disabled:!u||c,children:l(le.DeviceFloppy,{size:16})}),error:c}),l(d.Button,{leftIcon:l(le.Trash,{size:16}),color:"red",variant:"light",onClick:m,children:"Delete this SQL Snippet"})]}),y(d.Tabs,{value:r,onTabChange:i,sx:{flexGrow:1},styles:{panel:{height:"calc(100% - 50px)"}},children:[y(d.Tabs.List,{sx:{position:"relative"},children:[l(d.Tabs.Tab,{value:"SQL",children:"SQL"}),l(d.Tabs.Tab,{value:"Preview",children:"Preview"}),l(id,{}),l(d.ActionIcon,{color:"blue",variant:"filled",onClick:p,disabled:!g,sx:{position:"absolute",top:0,right:10},children:l(le.DeviceFloppy,{size:18})})]}),l(d.Tabs.Panel,{value:"SQL",pt:"sm",children:l(od,{height:"100%",value:f,onChange:h})}),l(d.Tabs.Panel,{value:"Preview",pt:"sm",children:l(xK,{value:f})})]})]})}),CK=te.observer(({id:e})=>{const t=$e(),n=x.useMemo(()=>t.sqlSnippets.findByKey(e),[e]);return n?l(SK,{item:n,remove:()=>t.sqlSnippets.removeByKey(e),onKeyChanged:o=>{t.editor.setPath(["_SQL_SNIPPETS_",o])}}):y(d.Text,{size:14,children:["SQL Snippet by key[",e,"] is not found"]})}),_K=te.observer(({view:e})=>!e||e.type!==rt.Division?null:y(d.Stack,{children:[l(d.Divider,{mt:8,mb:0,label:"Division settings",labelPosition:"center"}),l(d.Text,{align:"center",size:"xs",color:"dimmed",children:"Under construction"})]})),EK=[{value:"default",label:"Default"},{value:"outline",label:"Outline"},{value:"pills",label:"Pills"}],TK=[{value:"horizontal",label:"Horizontal"},{value:"vertical",label:"Vertical"}],MK=te.observer(({view:e})=>{if(!e||e.type!==rt.Tabs)return null;const t=e.config;return y(d.Stack,{children:[l(d.Divider,{mt:8,mb:0,label:"Tabs settings",labelPosition:"center"}),l(d.Select,{label:"Variant",value:t.variant,onChange:t.setVariant,data:EK}),l(d.Select,{label:"Orientation",value:t.orientation,onChange:t.setOrientation,data:TK}),l(d.Switch,{label:"Grow Tabs",checked:t.grow,onChange:n=>t.setGrow(n.currentTarget.checked)})]})}),kK=({disabled:e,value:t,onChange:n})=>{const r=i=>{!i||n(i)};return y(d.Box,{sx:{position:"relative"},children:[e&&l(d.Overlay,{opacity:.6,color:"#fff",zIndex:5,blur:2}),l(Tn.default,{height:"500px",defaultLanguage:"javascript",value:t,onChange:r,theme:"vs-dark",options:{minimap:{enabled:!1},readOnly:e}})]})},OK=({value:e,onChange:t})=>{const[n,{setTrue:r,setFalse:i}]=tt.useBoolean(),[o,a]=x.useState(e!=null?e:Qu),s=p=>{a({...o,enabled:p})},u=()=>{i();const{enabled:p,func_content:g}=o,v={enabled:p,func_content:g};a(v),t(v)},c=()=>{i(),a(e)},f=p=>{a(g=>({...g,func_content:p}))},h=()=>{f(Qu.func_content)};return y(Oe,{children:[l(d.ActionIcon,{size:"lg",color:"blue",variant:"filled",mt:26,onClick:r,sx:{flexGrow:0},children:l(le.Settings,{size:14})}),l(d.Modal,{size:800,title:"Customize modal title",opened:n,onClose:i,closeOnClickOutside:!1,withCloseButton:!1,zIndex:320,children:n&&y(d.Stack,{children:[l(d.Checkbox,{mt:10,label:"Enabled",checked:o.enabled,onChange:p=>s(p.currentTarget.checked)}),l(kK,{value:o.func_content,onChange:f,disabled:!o.enabled}),y(d.Group,{position:"apart",children:[l(d.Button,{onClick:h,color:"red",leftIcon:l(le.Recycle,{size:20}),children:"Rest"}),y(d.Group,{position:"right",children:[l(d.Button,{onClick:c,variant:"subtle",children:"Cancel"}),l(d.Button,{onClick:u,children:"OK"})]})]})]})})]})},DK=te.observer(({view:e})=>{if(!e||e.type!==rt.Modal)return null;const t=e.config,n=t.custom_modal_title.value;return y(d.Stack,{children:[l(d.Divider,{mt:8,label:"Modal settings",labelPosition:"center"}),y(d.Flex,{gap:10,children:[l(d.TextInput,{label:"Modal Title",value:n,onChange:fe.default.noop,disabled:!0,sx:{flexGrow:1}}),l(OK,{value:t.custom_modal_title,onChange:t.custom_modal_title.replace})]}),y(d.Group,{grow:!0,children:[l(d.TextInput,{label:"Width",value:t.width,onChange:r=>t.setWidth(r.currentTarget.value),placeholder:"600px / 50vw"}),l(d.TextInput,{label:"Height",value:t.height,onChange:r=>t.setHeight(r.currentTarget.value),placeholder:"600px / 50vw"})]})]})}),RK=te.observer(({view:e})=>y(Oe,{children:[l(_K,{view:e}),l(DK,{view:e}),l(MK,{view:e})]})),AK=[{label:"Division",value:rt.Division},{label:"Modal",value:rt.Modal},{label:"Tabs",value:rt.Tabs}],PK=te.observer(({view:e})=>e?y(d.Stack,{sx:{position:"relative"},children:[l(d.TextInput,{label:"Name",value:e.name,onChange:t=>{e.setName(t.currentTarget.value)}}),l(d.Select,{label:"Type",withinPortal:!0,value:e.type,onChange:e.setType,data:AK}),l(RK,{view:e})]}):null),IK=te.observer(({id:e})=>{const t=Kn.useModals(),n=$e(),r=n.views.findByID(e);if(!r)return y(d.Text,{size:14,children:["View by ID[",e,"] is not found"]});const i=()=>{t.openConfirmModal({title:"Delete this view?",labels:{confirm:"Confirm",cancel:"Cancel"},onCancel:()=>console.log("Cancel"),onConfirm:()=>n.views.removeByID(e),zIndex:320})};return y(d.Stack,{sx:{maxWidth:"600px",height:"100%"},spacing:"sm",children:[l(d.Group,{position:"right",pt:10,children:l(d.Button,{size:"xs",color:"red",leftIcon:l(le.Trash,{size:16}),onClick:i,children:"Delete this view"})}),l(d.Box,{sx:{flexGrow:1,maxHeight:"calc(100% - 52px)",overflow:"auto"},children:l(PK,{view:r})})]})});function NK(e){return e.length===1&&e[0]==="_GLOBAL_VARS_"}function $K(e){return e.length===1&&e[0]==="_MOCK_CONTEXT_"}function LK(e){return e.length===2&&e[0]==="_FILTERS_"}function VK(e){return e.length===2&&e[0]==="_SQL_SNIPPETS_"}function zK(e){return e.length===2&&e[0]==="_QUERIES_"}function FK(e){return e.length===2&&e[0]==="_VIEWS_"}function BK(e){return e.length===4&&e[0]==="_VIEWS_"&&e[2]==="_PANELS_"}const jK=te.observer(()=>l(d.Stack,{sx:{height:"100%"},p:"sm",children:l(i0,{})})),GK=te.observer(()=>{const e=$e().editor,t=e.path;return NK(t)?l(jK,{}):$K(t)?l(RG,{}):LK(t)?l(d.Box,{p:"xs",pl:20,children:l(DG,{id:t[1]})}):VK(t)?l(CK,{id:t[1]}):zK(t)?l(wK,{id:t[1]}):FK(t)?l(d.Box,{p:"xs",pl:20,children:l(IK,{id:t[1]})}):BK(t)?l(aK,{viewID:t[1],panelID:t[3]}):l(d.Box,{children:e.path})}),KK=te.observer(()=>($e().editor,l(GK,{}))),HK=te.observer(()=>{const e=$e(),t=()=>{const n=new Date().getTime().toString(),r={id:n,key:n,label:n,order:e.filters.current.length+1,type:Hu.TextInput,config:cm(),visibleInViewsIDs:["Main"],auto_submit:!1};e.filters.append(r)};return l(d.Button,{variant:"subtle",leftIcon:l(bi,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Filter"})}),WK=te.observer(({parentID:e})=>{const t=$e();if(!e)return null;const n=t.views.findByID(e);return n?l(d.Button,{variant:"subtle",leftIcon:l(bi,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:n.panels.addANewPanel,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Panel"}):null}),qK=te.observer(()=>{const e=$e(),t=()=>{const n=new Date().getTime().toString(),r={id:n,name:n,type:Sn.Postgresql,key:"",sql:""};e.queries.append(r)};return l(d.Button,{variant:"subtle",leftIcon:l(bi,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a Query"})}),UK=te.observer(()=>{const e=$e(),t=()=>{const r={key:new Date().getTime().toString(),value:""};e.sqlSnippets.append(r)};return l(d.Button,{variant:"subtle",leftIcon:l(bi,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:t,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a SQL Snippet"})}),YK=te.observer(()=>{const e=$e();return l(d.Button,{variant:"subtle",leftIcon:l(bi,{size:14}),size:"sm",px:"xs",mb:10,color:"blue",onClick:e.views.addARandomNewView,sx:{width:"100%",borderRadius:0},styles:{inner:{justifyContent:"flex-start"}},children:"Add a View"})}),XK=te.observer(({action_type:e,parentID:t})=>($e(),e==="_Add_A_Filter_"?l(HK,{}):e==="_Add_A_SQL_SNIPPET_"?l(UK,{}):e==="_Add_A_QUERY_"?l(qK,{}):e==="_Add_A_VIEW_"?l(YK,{}):e==="_Add_A_PANEL_"?l(WK,{parentID:t}):null)),a0=te.observer(({option:e})=>{var a;const t=$e().editor,n=t.isOptionActive,r=n(t.path,e),i=t.isOptionOpened,o=t.navigate;return l(d.NavLink,{active:r,defaultOpened:i(e),label:e.label,onClick:()=>o(e),icon:e.Icon?l(e.Icon,{size:18}):null,children:(a=e.children)==null?void 0:a.map(s=>s._type==="ACTION"?l(XK,{action_type:s._action_type,parentID:s.parentID},`_ADD_${s.value}_`):l(a0,{option:s},s.value))},e.label)}),QK=te.observer(()=>{const e=$e();return l(d.Box,{sx:{position:"relative"},children:e.editor.navOptions.map(t=>l(a0,{option:t},t.value))})}),ZK=te.observer(()=>{const e=$e();return y(d.Navbar,{p:0,width:{base:200,xs:200,sm:220,md:240,lg:280,xl:300},sx:{height:"100vh - 60px - 60px"},children:[l(d.Navbar.Section,{pt:9,pb:8,sx:{borderBottom:"1px solid #eee"},children:l(d.Text,{align:"center",sx:{userSelect:"none",cursor:"default"},children:"Settings"})}),l(d.Navbar.Section,{grow:!0,sx:{overflow:"auto"},children:l(QK,{})}),l(d.Navbar.Section,{children:l(d.Group,{grow:!0,p:"md",pt:"sm",sx:{borderTop:"1px solid #eee"},children:l(d.Button,{size:"xs",color:"red",leftIcon:l(TI,{size:18}),onClick:()=>e.editor.close(),children:"Close"})})})]})}),JK={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1,nav:{top:0,height:"100vh"}},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:0,height:"100vh"}},e6=te.observer(()=>{const e=$e().editor;return l(d.Modal,{onClose:()=>e.setSettingsOpen(!1),closeOnEscape:!1,closeOnClickOutside:!1,opened:e.settings_open,fullScreen:!0,title:null,transitionDuration:0,withCloseButton:!1,withinPortal:!0,zIndex:300,styles:{modal:{padding:"0 !important"}},children:l(d.AppShell,{padding:0,navbar:l(ZK,{}),styles:JK,children:l(KK,{})})})}),t6=e=>e.replace(/([^:])(\/\/+)/g,"$1/");function n6(e){x.useEffect(()=>{if(Lo.loader.__getMonacoInstance())return;console.log("loading monaco for @devtable/dashboard");const n=t6(e+"/assets/monaco-editor/min/vs");Lo.loader.config({paths:{vs:n}}),Lo.loader.init().then(r=>console.log("monaco instance:",r))},[])}const r6={root:{height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"},body:{flexGrow:1},main:{flexGrow:1,display:"flex",flexDirection:"column",paddingTop:60,height:"100vh"}},i6=te.observer(function({context:t,dashboard:n,update:r,className:i="dashboard",config:o}){n6(o.basename),rm(o);const{data:a=[]}=tt.useRequest(Xu),[s,u]=Z.default.useState(!1),c=Z.default.useMemo(()=>Zu(n,a,t),[n]);pd(c,!0),Z.default.useEffect(()=>{c.context.replace(t)},[t]),Z.default.useEffect(()=>{c.datasources.replace(a)},[a]);const f=async()=>{const g=[...c.queries.json],v=[...c.sqlSnippets.json],m=[...c.views.json],w={...c.mock_context.current},b={...n,filters:[...c.filters.current],views:m,definition:{queries:g,sqlSnippets:v,mock_context:w}};await r(b)},h=tt.useCreation(Gu,[]),p=Ju(h);return l(Kn.ModalsProvider,{children:l(Ns,{value:c,children:l(Dr.Provider,{value:{layoutFrozen:s,freezeLayout:u,inEditMode:!0},children:l(zn.Provider,{value:h,children:y(Fo,{configure:p,children:[l(d.AppShell,{padding:0,header:l(Zz,{saveDashboardChanges:f}),navbar:l(gG,{}),styles:r6,children:l(d.Box,{className:`${i} dashboard-root`,sx:{position:"relative"},children:c.views.visibleViews.map(g=>l(nm,{view:g},g.id))})}),l(e6,{})]})})})})})}),L6="",o6=te.observer(({context:e,dashboard:t,className:n="dashboard",config:r,fullScreenPanelID:i,setFullScreenPanelID:o})=>{rm(r);const{data:a=[]}=tt.useRequest(Xu),s=Z.default.useMemo(()=>Zu(t,a,e),[t]);pd(s,!1),Z.default.useEffect(()=>{s.context.replace(e)},[e]),Z.default.useEffect(()=>{s.datasources.replace(a)},[a]);const u=tt.useCreation(Gu,[]),c=Ju(u);return l(Kn.ModalsProvider,{children:l(Ns,{value:s,children:l(Ls.Provider,{value:{fullScreenPanelID:i,setFullScreenPanelID:o},children:l(Dr.Provider,{value:{layoutFrozen:!0,freezeLayout:fe.default.noop,inEditMode:!1},children:l(d.Box,{className:`${n} dashboard-root`,children:l(zn.Provider,{value:u,children:l(Fo,{configure:c,children:s.views.visibleViews.map(f=>l(Ya,{view:f},f.id))})})})})})})})});var s0={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(hn,function(){var n={year:0,month:1,day:2,hour:3,minute:4,second:5},r={};return function(i,o,a){var s,u=function(p,g,v){v===void 0&&(v={});var m=new Date(p),w=function(b,_){_===void 0&&(_={});var C=_.timeZoneName||"short",S=b+"|"+C,E=r[S];return E||(E=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:b,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",timeZoneName:C}),r[S]=E),E}(g,v);return w.formatToParts(m)},c=function(p,g){for(var v=u(p,g),m=[],w=0;w<v.length;w+=1){var b=v[w],_=b.type,C=b.value,S=n[_];S>=0&&(m[S]=parseInt(C,10))}var E=m[3],k=E===24?0:E,A=m[0]+"-"+m[1]+"-"+m[2]+" "+k+":"+m[4]+":"+m[5]+":000",L=+p;return(a.utc(A).valueOf()-(L-=L%1e3))/6e4},f=o.prototype;f.tz=function(p,g){p===void 0&&(p=s);var v=this.utcOffset(),m=this.toDate(),w=m.toLocaleString("en-US",{timeZone:p}),b=Math.round((m-new Date(w))/1e3/60),_=a(w).$set("millisecond",this.$ms).utcOffset(15*-Math.round(m.getTimezoneOffset()/15)-b,!0);if(g){var C=_.utcOffset();_=_.add(v-C,"minute")}return _.$x.$timezone=p,_},f.offsetName=function(p){var g=this.$x.$timezone||a.tz.guess(),v=u(this.valueOf(),g,{timeZoneName:p}).find(function(m){return m.type.toLowerCase()==="timezonename"});return v&&v.value};var h=f.startOf;f.startOf=function(p,g){if(!this.$x||!this.$x.$timezone)return h.call(this,p,g);var v=a(this.format("YYYY-MM-DD HH:mm:ss:SSS"));return h.call(v,p,g).tz(this.$x.$timezone,!0)},a.tz=function(p,g,v){var m=v&&g,w=v||g||s,b=c(+a(),w);if(typeof p!="string")return a(p).tz(w);var _=function(k,A,L){var F=k-60*A*1e3,P=c(F,L);if(A===P)return[F,A];var O=c(F-=60*(P-A)*1e3,L);return P===O?[F,P]:[k-60*Math.min(P,O)*1e3,Math.max(P,O)]}(a.utc(p,m).valueOf(),b,w),C=_[0],S=_[1],E=a(C).utcOffset(S);return E.$x.$timezone=w,E},a.tz.guess=function(){return Intl.DateTimeFormat().resolvedOptions().timeZone},a.tz.setDefault=function(p){s=p}}})})(s0);const a6=s0.exports;var l0={exports:{}};(function(e,t){(function(n,r){e.exports=r()})(hn,function(){var n="minute",r=/[+-]\d\d(?::?\d\d)?/g,i=/([+-]|\d\d)/g;return function(o,a,s){var u=a.prototype;s.utc=function(m){var w={date:m,utc:!0,args:arguments};return new a(w)},u.utc=function(m){var w=s(this.toDate(),{locale:this.$L,utc:!0});return m?w.add(this.utcOffset(),n):w},u.local=function(){return s(this.toDate(),{locale:this.$L,utc:!1})};var c=u.parse;u.parse=function(m){m.utc&&(this.$u=!0),this.$utils().u(m.$offset)||(this.$offset=m.$offset),c.call(this,m)};var f=u.init;u.init=function(){if(this.$u){var m=this.$d;this.$y=m.getUTCFullYear(),this.$M=m.getUTCMonth(),this.$D=m.getUTCDate(),this.$W=m.getUTCDay(),this.$H=m.getUTCHours(),this.$m=m.getUTCMinutes(),this.$s=m.getUTCSeconds(),this.$ms=m.getUTCMilliseconds()}else f.call(this)};var h=u.utcOffset;u.utcOffset=function(m,w){var b=this.$utils().u;if(b(m))return this.$u?0:b(this.$offset)?h.call(this):this.$offset;if(typeof m=="string"&&(m=function(E){E===void 0&&(E="");var k=E.match(r);if(!k)return null;var A=(""+k[0]).match(i)||["-",0,0],L=A[0],F=60*+A[1]+ +A[2];return F===0?0:L==="+"?F:-F}(m),m===null))return this;var _=Math.abs(m)<=16?60*m:m,C=this;if(w)return C.$offset=_,C.$u=m===0,C;if(m!==0){var S=this.$u?this.toDate().getTimezoneOffset():-1*this.utcOffset();(C=this.local().add(_+S,n)).$offset=_,C.$x.$localOffset=S}else C=this.utc();return C};var p=u.format;u.format=function(m){var w=m||(this.$u?"YYYY-MM-DDTHH:mm:ss[Z]":"");return p.call(this,w)},u.valueOf=function(){var m=this.$utils().u(this.$offset)?0:this.$offset+(this.$x.$localOffset||this.$d.getTimezoneOffset());return this.$d.valueOf()-6e4*m},u.isUTC=function(){return!!this.$u},u.toISOString=function(){return this.toDate().toISOString()},u.toString=function(){return this.toDate().toUTCString()};var g=u.toDate;u.toDate=function(m){return m==="s"&&this.$offset?s(this.format("YYYY-MM-DD HH:mm:ss:SSS")).toDate():g.call(this)};var v=u.diff;u.diff=function(m,w,b){if(m&&this.$u===m.$u)return v.call(this,m,w,b);var _=this.local(),C=s(m).local();return v.call(_,C,w,b)}}})})(l0);const s6=l0.exports,l6=()=>Promise.resolve().then(()=>VD).then(({version:e})=>(console.log(`[@devtable/dashboard] version: ${e}`),e));En.default.extend(s6),En.default.extend(a6),En.default.tz.setDefault("UTC"),de.ContextModel=xm,de.Dashboard=i6,de.DashboardFilterType=Hu,de.DashboardMode=em,de.DashboardModel=Ja,de.DashboardViewEditor=nm,de.DashboardViewRender=Ya,de.EViewComponentType=rt,de.FilterModel=qu,de.FiltersModel=pm,de.FullScreenPanelContext=Ls,de.LayoutStateContext=Dr,de.ModelContextProvider=Ns,de.Panel=Ua,de.PanelContextProvider=$s,de.QueriesModel=ym,de.QueryModel=mm,de.ReadOnlyDashboard=o6,de.SQLSnippetModel=bm,de.SQLSnippetsModel=wm,de.ViewComponentTypeBackground=tm,de.ViewComponentTypeColor=BV,de.ViewComponentTypeName=FV,de.ViewModel=Em,de.ViewsModel=Tm,de.createDashboardModel=Zu,de.createDashboardViewsModel=Mm,de.getInitialFiltersPayload=hm,de.getVersion=l6,de.useFullScreenPanelContext=wd,de.useModelContext=$e,de.usePanelContext=Yt,de.useTopLevelServices=Ju,Object.defineProperties(de,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});