@deephaven/code-studio 0.77.1-beta.2 → 0.77.1-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/build/assets/{AppRoot-280e670c.js → AppRoot-f69a0140.js} +3 -3
  2. package/build/assets/{AppRoot-280e670c.js.map → AppRoot-f69a0140.js.map} +1 -1
  3. package/build/assets/{Chart-ebd8c605.js → Chart-19846143.js} +2 -2
  4. package/build/assets/{Chart-ebd8c605.js.map → Chart-19846143.js.map} +1 -1
  5. package/build/assets/{ControlType-f1bb8293.js → ControlType-5e65a1f9.js} +3 -3
  6. package/build/assets/{ControlType-f1bb8293.js.map → ControlType-5e65a1f9.js.map} +1 -1
  7. package/build/assets/FontBootstrap-301270dd.css +1 -0
  8. package/build/assets/{FontBootstrap-753901ab.js → FontBootstrap-dafd12df.js} +2 -2
  9. package/build/assets/{FontBootstrap-753901ab.js.map → FontBootstrap-dafd12df.js.map} +1 -1
  10. package/build/assets/{FormatterUtils-29aa8e1a.js → FormatterUtils-84854bf0.js} +2 -2
  11. package/build/assets/{FormatterUtils-29aa8e1a.js.map → FormatterUtils-84854bf0.js.map} +1 -1
  12. package/build/assets/{Grid-e1236296.js → Grid-2da8c6ae.js} +2 -2
  13. package/build/assets/{Grid-e1236296.js.map → Grid-2da8c6ae.js.map} +1 -1
  14. package/build/assets/{GridRenderer-ed7dbad4.js → GridRenderer-bc76a490.js} +2 -2
  15. package/build/assets/{GridRenderer-ed7dbad4.js.map → GridRenderer-bc76a490.js.map} +1 -1
  16. package/build/assets/{IrisGrid-105d172d.js → IrisGrid-4566fcfe.js} +2 -2
  17. package/build/assets/{IrisGrid-105d172d.js.map → IrisGrid-4566fcfe.js.map} +1 -1
  18. package/build/assets/{IrisGridModel-61ddc43e.js → IrisGridModel-5eee50a2.js} +2 -2
  19. package/build/assets/{IrisGridModel-61ddc43e.js.map → IrisGridModel-5eee50a2.js.map} +1 -1
  20. package/build/assets/{IrisGridShortcuts-d4875242.js → IrisGridShortcuts-ce1afae5.js} +2 -2
  21. package/build/assets/{IrisGridShortcuts-d4875242.js.map → IrisGridShortcuts-ce1afae5.js.map} +1 -1
  22. package/build/assets/{IrisGridThemeProvider-47181f2a.css → IrisGridThemeProvider-3984e29a.css} +1 -1
  23. package/build/assets/{IrisGridThemeProvider-b7f4c598.js → IrisGridThemeProvider-3c6c8cb6.js} +2 -2
  24. package/build/assets/{IrisGridThemeProvider-b7f4c598.js.map → IrisGridThemeProvider-3c6c8cb6.js.map} +1 -1
  25. package/build/assets/{MarkdownEditor-f869507d.js → MarkdownEditor-c76b2153.js} +2 -2
  26. package/build/assets/{MarkdownEditor-f869507d.js.map → MarkdownEditor-c76b2153.js.map} +1 -1
  27. package/build/assets/{MarkdownNotebook-d2c01a48.js → MarkdownNotebook-4a4ccc33.js} +2 -2
  28. package/build/assets/{MarkdownNotebook-d2c01a48.js.map → MarkdownNotebook-4a4ccc33.js.map} +1 -1
  29. package/build/assets/{MissingPartitionError-bd4a06dd.js → MissingPartitionError-6c767865.js} +2 -2
  30. package/build/assets/{MissingPartitionError-bd4a06dd.js.map → MissingPartitionError-6c767865.js.map} +1 -1
  31. package/build/assets/{StyleGuideRoot-773a2aaf.js → StyleGuideRoot-27a8d861.js} +2 -2
  32. package/build/assets/{StyleGuideRoot-773a2aaf.js.map → StyleGuideRoot-27a8d861.js.map} +1 -1
  33. package/build/assets/{index-470b8a54.css → index-13e1b819.css} +1 -1
  34. package/build/assets/index-3a104f6a.css +1 -0
  35. package/build/assets/{index-d7716c14.js → index-49c2275d.js} +2 -2
  36. package/build/assets/{index-d7716c14.js.map → index-49c2275d.js.map} +1 -1
  37. package/build/assets/{index-3ad3aa8a.js → index-5f3db412.js} +2 -2
  38. package/build/assets/{index-3ad3aa8a.js.map → index-5f3db412.js.map} +1 -1
  39. package/build/assets/{index-f720412a.js → index-d634bf3b.js} +3 -3
  40. package/build/assets/{index-f720412a.js.map → index-d634bf3b.js.map} +1 -1
  41. package/build/assets/{useUser-01f40e41.js → useUser-f5667912.js} +2 -2
  42. package/build/assets/{useUser-01f40e41.js.map → useUser-f5667912.js.map} +1 -1
  43. package/build/index.html +2 -2
  44. package/package.json +30 -30
  45. package/build/assets/FontBootstrap-832a937c.css +0 -1
  46. package/build/assets/index-e500652d.css +0 -1
@@ -1,4 +1,4 @@
1
- import{r as C,I as o,K as $,L as W,bb as We,Z as we,ba as Ct,bc as Zr,_ as Qe,T as Qr,U as oe,M as Je,bP as St,bQ as re,bR as wt,bS as Ot,bT as yt,bU as xt,bV as _e,bW as It,bX as jt,bY as Dt,bZ as er,b_ as Pt,b$ as rr,c0 as Nt,c1 as Tt,c2 as Et,c3 as Rt,c4 as At,c5 as Mt,af as Le,$ as kt}from"./vendor-2ad5ff96.js";import{L as be,bb as Ft,am as Jr,f as ye,g as ze,T as K,bc as Ve,bd as Ke,aq as _t,ao as et,u as Lt,be as Ht,ar as rt,ai as Ee,aj as Gt,I as tt,e as k,aF as Ut,bf as $t,F as tr,n as Bt,bg as nt,bh as at,v as Wt,bi as zt,J as Vt,b4 as Kt,bj as qt,bk as Xt,bl as Yt,bm as Zt,bn as Qt,d as Jt,ay as en,bo as rn,aV as Z,a8 as tn,a2 as nn,aL as an}from"./index-d7716c14.js";import{S as on,b as nr,m as sn,I as it,C as ue}from"./MissingPartitionError-bd4a06dd.js";import{a as ne}from"./IrisGridShortcuts-d4875242.js";import{b as ee,O as ot,h as ln,T as dn,i as st,j as un,k as cn,G as hn}from"./GridRenderer-ed7dbad4.js";import{B as N,S as Oe,c as V,C as ce,x as vn,aQ as mn,a9 as gn,D as qe,Q as lt,s as He,d as fn,P as pn,ck as bn,u as Cn,ai as Sn,a_ as wn}from"./ControlType-f1bb8293.js";import{R as Xe,a as he,c as me,d as ge,G as M,m as dt}from"./IrisGridModel-61ddc43e.js";import{e as On}from"./monaco-b5248072.js";import{F as yn}from"./FormatterUtils-29aa8e1a.js";function ar(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function ir(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ar(Object(r),!0).forEach(function(n){xn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ar(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function xn(t,e,r){return e=In(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function In(t){var e=jn(t,"string");return typeof e=="symbol"?e:String(e)}function jn(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var or=be.module("Aggregations");function Qi(t){var{isRollup:e,settings:r,onChange:n,onEdit:a}=t,{aggregations:i,showOnTop:s}=r,l=C.useMemo(()=>on.filter(w=>!i.some(j=>j.operation===w)),[i]),[u,d]=C.useState(l[0]),[c,h]=C.useState([]),m=C.useCallback(w=>{n(ir(ir({},r),w))},[n,r]),v=C.useCallback(w=>{m({aggregations:w})},[m]),g=C.useCallback(w=>{m({showOnTop:w})},[m]),f=C.useCallback(()=>{or.debug("handleDragStart"),ne.startDragging()},[]),b=C.useCallback(w=>{var{destination:j,source:E}=w;if(or.debug("handleDragEnd",j,E),ne.stopDragging(),j!==null){var L=j.index;E.index<j.index&&(L+=1);var _=[...i],F=ne.reorder(_,c,_,L),U=ne.adjustDestinationIndex(L,c),G=[[U,U+F.length-1]];v(_),h(G)}},[v,i,c,h]),p=C.useCallback(w=>{d(w)},[d]),O=C.useCallback(()=>{v([...i,{operation:u,selected:[],invert:!0}])},[i,u,v]),S=C.useCallback(w=>{v(i.filter((j,E)=>E!==w))},[i,v]),D=C.useCallback(w=>{h(w)},[h]),y=C.useCallback(w=>{var j=i[w];nr.isRollupOperation(j.operation)||a(j)},[i,a]),I=C.useCallback(w=>{g(w.target.value==="true")},[g]);C.useEffect(function(){l.length>0&&!l.includes(u)&&d(l[0])},[l,u]);var T=C.useCallback(w=>{var{item:j,itemIndex:E,isClone:L=!1,selectedCount:_}=w,F=j.operation,U=L?"".concat(_):void 0,G=L?"item-list-item-clone":void 0,B=nr.isRollupOperation(j.operation),ae=!L&&!B;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:$("item-list-item-content","draggable-item-list-item-content",G),children:[o.jsxs("span",{className:"title",children:[F,!e&&B&&o.jsxs("span",{className:"small text-warning",children:[o.jsx(W,{icon:Ft})," Requires rollup"]})]}),ee.renderBadge({text:U}),ee.renderHandle()]}),!L&&o.jsxs(o.Fragment,{children:[o.jsx(N,{kind:"ghost",className:"btn-edit",icon:Jr,tooltip:"Edit Columns",onClick:()=>a(j),disabled:!ae}),o.jsx(N,{kind:"ghost",className:"btn-delete",icon:ye,tooltip:"Delete Aggregation",onClick:()=>S(E)})]})]})},[S,a,e]),A=l.length>0,x=i.length>0;return o.jsxs("div",{className:"aggregations",children:[A&&o.jsxs("div",{className:"form-inline",children:[o.jsx(Oe,{onChange:p,value:u,children:l.map(w=>o.jsx(ot,{value:w,children:w},w))}),o.jsxs("button",{type:"button",className:"btn btn-link btn-add",onClick:O,children:[o.jsx(W,{icon:ze}),"Add Aggregation"]})]}),A&&x&&o.jsx("hr",{}),x&&o.jsxs(o.Fragment,{children:[!e&&o.jsxs("div",{className:"form-inline",children:[o.jsx("label",{children:"Placement: "}),o.jsxs(Xe,{onChange:I,value:"".concat(s),children:[o.jsx(he,{value:"true",children:"Top"}),o.jsx(he,{value:"false",children:"Bottom"})]})]}),o.jsx(We,{onDragStart:f,onDragEnd:b,children:o.jsx(ee,{className:"selected-aggregations",itemCount:i.length,items:i,renderItem:T,offset:0,onSelectionChange:D,onSelect:y,selectedRanges:c,isMultiSelect:!0})})]})]})}function sr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function ie(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?sr(Object(r),!0).forEach(function(n){Dn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):sr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Dn(t,e,r){return e=Pn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Pn(t){var e=Nn(t,"string");return typeof e=="symbol"?e:String(e)}function Nn(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Q;(function(t){t[t.NONE=0]="NONE",t[t.ASCENDING=1]="ASCENDING",t[t.DESCENDING=2]="DESCENDING"})(Q||(Q={}));var Tn=30;function Ji(t){var{aggregation:e,columns:r,onChange:n}=t,[a,i]=C.useState(-1),[s,l]=C.useState(-1),[u,d]=C.useState(Q.NONE),{invert:c,selected:h}=e,m=C.useRef(null),v=C.useCallback(I=>h.includes(I)?!c:c,[c,h]),g=C.useMemo(()=>{var I=sn(r,e.operation);return u!==Q.NONE&&(I=V.sortColumns(I,u===Q.ASCENDING)),I},[r,e.operation,u]),f=C.useMemo(()=>a>=0?g.slice(a,s+1).map(I=>({value:I.name,displayValue:I.name,isSelected:v(I.name)})):[],[g,v,s,a]),b=C.useCallback(I=>{var{name:T}=g[I],A=h.indexOf(T),x=[...h],w=c;A>=0?x.splice(A,1):(x.push(T),x.length===g.length&&(x=[],w=!c)),n(ie(ie({},e),{},{selected:x,invert:w}))},[e,c,g,h,n]),p=C.useCallback(()=>{d(Q.NONE),n(ie(ie({},e),{},{selected:[],invert:!0}))},[e,n]),O=C.useCallback((I,T)=>{i(I),l(T)},[i,l]),S=C.useCallback(()=>{h.length===0?n(ie(ie({},e),{},{invert:!c})):n(ie(ie({},e),{},{selected:[],invert:!0}))},[e,c,n,h]),D=h.length===0?c:null,y=h.length!==0||!c||u!==Q.NONE;return o.jsxs("div",{role:"menu",className:"aggregation-edit",children:[o.jsx("div",{className:"top-menu",children:o.jsxs("div",{className:"form-inline",children:[o.jsx(ce,{checked:D,onChange:S,children:"Toggle All"}),o.jsx("div",{className:"spacer"}),o.jsx(vn,{in:y,timeout:K.transitionSlowMs,mountOnEnter:!0,unmountOnExit:!0,children:o.jsx(N,{kind:"ghost",className:"btn-reset",onClick:p,children:"Reset"})}),o.jsx(N,{kind:"ghost",className:$({active:u===Q.ASCENDING}),icon:Ve,tooltip:"Sort ascending",onClick:()=>d(Q.ASCENDING)}),o.jsx(N,{kind:"ghost",className:$({active:u===Q.DESCENDING}),icon:Ke,tooltip:"Sort descending",onClick:()=>d(Q.DESCENDING)})]})}),o.jsx("div",{className:"aggregation-edit-item-list",children:o.jsx(mn,{itemCount:g.length,items:f,offset:a,renderItem:I=>{var{item:T}=I;return o.jsx(ce,{checked:v(T.value),children:T.displayValue})},onSelect:b,onViewportChange:O,rowHeight:Tn,focusSelector:"input",ref:m})})]})}function lr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function dr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?lr(Object(r),!0).forEach(function(n){En(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):lr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function En(t,e,r){return e=Rn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Rn(t){var e=An(t,"string");return typeof e=="symbol"?e:String(e)}function An(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Mn(t){return o.jsx("svg",dr(dr({width:48,height:48,xmlns:"http://www.w3.org/2000/svg"},t),{},{children:o.jsxs("g",{fill:"none",fillRule:"evenodd",children:[o.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),o.jsx("path",{fill:"#7DA4FF",d:"M8 26h4v15H8zM15 17h4v24h-4zM22 21h4v20h-4zM29 17h4v24h-4zM36 11h4v30h-4z"})]})}))}function ur(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function cr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ur(Object(r),!0).forEach(function(n){kn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ur(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function kn(t,e,r){return e=Fn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Fn(t){var e=_n(t,"string");return typeof e=="symbol"?e:String(e)}function _n(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ln(t){return o.jsx("svg",cr(cr({width:48,height:48,xmlns:"http://www.w3.org/2000/svg"},t),{},{children:o.jsxs("g",{fill:"none",fillRule:"evenodd",children:[o.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),o.jsx("path",{fill:"#7DA4FF",d:"M7 34h4v8H7zM12 31h4v11h-4zM17 27h4v15h-4zM22 22h4v20h-4zM27 27h4v15h-4zM32 29h4v13h-4zM37 31h4v11h-4z"})]})}))}function hr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function vr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?hr(Object(r),!0).forEach(function(n){Hn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):hr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Hn(t,e,r){return e=Gn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Gn(t){var e=Un(t,"string");return typeof e=="symbol"?e:String(e)}function Un(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function $n(t){return o.jsx("svg",vr(vr({width:48,height:48,xmlns:"http://www.w3.org/2000/svg"},t),{},{children:o.jsxs("g",{fill:"none",fillRule:"evenodd",children:[o.jsx("path",{fill:"#C1C0C0",d:"M4 4h1v40H4zM44 43v1H5v-1z"}),o.jsx("path",{stroke:"#7DA4FF",d:"M7.984 32.44l7.982-11.378 5.273 3.739 9.952-10.838 2.826 1.894 7.45-5.802"}),o.jsx("path",{stroke:"#BECDEF",d:"M8.244 37.926L17 33.496l5 .87 10.637-10.35 10.615-1.381"})]})}))}function mr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function gr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?mr(Object(r),!0).forEach(function(n){Bn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):mr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Bn(t,e,r){return e=Wn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Wn(t){var e=zn(t,"string");return typeof e=="symbol"?e:String(e)}function zn(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Vn(t){return o.jsx("svg",gr(gr({width:48,height:48,xmlns:"http://www.w3.org/2000/svg"},t),{},{children:o.jsxs("g",{fill:"none",fillRule:"evenodd",children:[o.jsx("path",{d:"M24 10c7.732 0 14 6.268 14 14s-6.268 14-14 14-14-6.268-14-14h14V10z",fill:"#80A6FF"}),o.jsx("path",{d:"M10 24c0-7.732 6.268-14 14-14v14H10z",fill:"#C1C0C0"})]})}))}function fr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function pr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?fr(Object(r),!0).forEach(function(n){Kn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):fr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Kn(t,e,r){return e=qn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qn(t){var e=Xn(t,"string");return typeof e=="symbol"?e:String(e)}function Xn(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Yn(t){return o.jsx("svg",pr(pr({width:48,height:48,xmlns:"http://www.w3.org/2000/svg"},t),{},{children:o.jsxs("g",{fill:"none",fillRule:"evenodd",children:[o.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),o.jsx("path",{fill:"#939293",d:"M44 34v1H4v-1zM44 25v1H4v-1zM44 16v1H4v-1z"}),o.jsx("circle",{fill:"#7DA4FF",cx:9.5,cy:37.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:16.5,cy:30.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:22.5,cy:36.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:28.5,cy:30.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:15.5,cy:38.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:23.5,cy:25.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:19.5,cy:19.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:29.5,cy:19.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:32.5,cy:26.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:36.5,cy:13.5,r:1.5})]})}))}function br(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Cr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?br(Object(r),!0).forEach(function(n){Zn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):br(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Zn(t,e,r){return e=Qn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Qn(t){var e=Jn(t,"string");return typeof e=="symbol"?e:String(e)}function Jn(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function eo(t){return o.jsxs("svg",Cr(Cr({width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{},{children:[o.jsx("rect",{width:"48",height:"48",fill:"none"}),o.jsx("rect",{x:"26",y:"10",width:"15",height:"4",fill:"#9FDE70"}),o.jsx("rect",{x:"26",y:"22",width:"15",height:"4",fill:"#9FDE70"}),o.jsx("rect",{x:"26",y:"28",width:"15",height:"4",fill:"#FFD95C"}),o.jsx("rect",{x:"26",y:"34",width:"15",height:"4",fill:"#9FDE70"})]}))}function Sr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function wr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Sr(Object(r),!0).forEach(function(n){ea(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Sr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function ea(t,e,r){return e=ra(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ra(t){var e=ta(t,"string");return typeof e=="symbol"?e:String(e)}function ta(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ro(t){return o.jsxs("svg",wr(wr({width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{},{children:[o.jsx("rect",{width:"48",height:"48",fill:"none"}),o.jsx("rect",{x:"4",y:"16",width:"40",height:"4",fill:"#FFD95C"}),o.jsx("rect",{x:"4",y:"10",width:"40",height:"4",fill:"#78DCE8"}),o.jsx("rect",{x:"4",y:"34",width:"40",height:"4",fill:"#78DCE8"})]}))}var Or=be.module("ChartBuilder");class J extends C.PureComponent{static getMaxSeriesCount(e,r){switch(r){case e.plot.SeriesPlotStyle.PIE:return 1;case e.plot.SeriesPlotStyle.HISTOGRAM:return 0;default:return 100}}static makeSeriesItem(e){return{id:we.generate(),value:e}}static makeDefaultSeriesItems(e,r,n){var a=J.getMaxSeriesCount(e,r);if(a===0||n==null||n.length===0)return[];var i=n.length>1?n[1].name:n[0].name;return[J.makeSeriesItem(i)]}static getDefaultXAxis(e,r){return r!=null&&r.length>0?r[0].name:null}constructor(e){super(e),gn(this);var{model:r}=e,{columns:n,dh:a}=r,i=this.getTypes()[0],s=J.getDefaultXAxis(i,n),l=J.makeDefaultSeriesItems(a,i,n);this.state={type:i,seriesItems:l,xAxis:s,isLinked:!0}}getTypes(){var{model:e}=this.props,{dh:r}=e;return[r.plot.SeriesPlotStyle.LINE,r.plot.SeriesPlotStyle.BAR,r.plot.SeriesPlotStyle.SCATTER,r.plot.SeriesPlotStyle.PIE]}getTypeName(e){var{model:r}=this.props,{dh:n}=r;switch(e){case n.plot.SeriesPlotStyle.LINE:return"Line";case n.plot.SeriesPlotStyle.BAR:return"Bar";case n.plot.SeriesPlotStyle.SCATTER:return"Scatter";case n.plot.SeriesPlotStyle.PIE:return"Pie";case n.plot.SeriesPlotStyle.HISTOGRAM:return"Histogram";default:return e}}getTypeIcon(e){var{model:r}=this.props,{dh:n}=r;switch(e){case n.plot.SeriesPlotStyle.LINE:return o.jsx($n,{});case n.plot.SeriesPlotStyle.BAR:return o.jsx(Mn,{});case n.plot.SeriesPlotStyle.SCATTER:return o.jsx(Yn,{});case n.plot.SeriesPlotStyle.PIE:return o.jsx(Vn,{});case n.plot.SeriesPlotStyle.HISTOGRAM:return o.jsx(Ln,{});default:return null}}getXAxisLabel(e){var{model:r}=this.props,{dh:n}=r;switch(e){case n.plot.SeriesPlotStyle.PIE:return"Labels";case n.plot.SeriesPlotStyle.HISTOGRAM:return"Data";default:return"X-Axis"}}getSeriesLabel(e){var{model:r}=this.props,{dh:n}=r;switch(e){case n.plot.SeriesPlotStyle.PIE:return"Values";default:return"Series"}}handleAddSeries(){this.setState(e=>{var{seriesItems:r}=e,n=[...r],{model:a}=this.props,{columns:i}=a;return n.push({id:we.generate(),value:i[0].name}),{seriesItems:n}},this.sendChange)}handleLinkStateChange(e){this.setState({isLinked:e.target.value==="true"},this.sendChange)}handleReset(){var{model:e}=this.props,{columns:r,dh:n}=e,a=this.getTypes()[0],i=J.getDefaultXAxis(a,r),s=J.makeDefaultSeriesItems(n,a,r),l=!0;this.setState({type:a,seriesItems:s,xAxis:i,isLinked:l},this.sendChange)}handleSeriesChange(e,r){var n=e;this.setState(a=>{var{seriesItems:i}=a;return i=[...i],i[r].value=n,{seriesItems:i}},this.sendChange)}handleSeriesDeleteClick(e){this.setState(r=>{var{seriesItems:n}=r,a=[...n];return a.splice(e,1),{seriesItems:a}},this.sendChange)}handleSubmit(e){e.preventDefault();var{onSubmit:r}=this.props,{type:n,seriesItems:a,xAxis:i,isLinked:s}=this.state,l=a.map(u=>u.value);r({type:n,series:l,xAxis:i,isLinked:s})}handleTypeClick(e){var r=this.getTypes()[e];Or.debug2("handleTypeSelect",r),this.setState(n=>{var{model:a}=this.props,{dh:i}=a,s=J.getMaxSeriesCount(i,r),{seriesItems:l}=n;if(l=l.slice(0,s),l.length===0&&s>0){var{columns:u}=a;l=J.makeDefaultSeriesItems(i,r,u)}return{type:r,seriesItems:l}},this.sendChange)}handleXAxisChange(e){var r=e;Or.debug2("x-axis change",r),this.setState({xAxis:r},this.sendChange)}sendChange(){var{onChange:e}=this.props,{isLinked:r,type:n,seriesItems:a,xAxis:i}=this.state,s=a.map(l=>l.value);e({type:n,series:s,xAxis:i,isLinked:r})}render(){var{model:e}=this.props,{columns:r,dh:n}=e,{seriesItems:a,type:i,xAxis:s,isLinked:l}=this.state,u=J.getMaxSeriesCount(n,i),d=this.getXAxisLabel(i),c=this.getSeriesLabel(i),h=a.length>0,m=a.length<u;return o.jsx("div",{className:"chart-builder",children:o.jsxs("form",{onSubmit:this.handleSubmit,children:[o.jsxs("div",{className:"form-row",children:[o.jsx("label",{children:"Select Chart Type"}),o.jsx("div",{className:"form-row",children:this.getTypes().map((v,g)=>{var f=v;return o.jsx("div",{className:"col col-chart-type",children:o.jsxs("button",{type:"button",className:$("btn","btn-icon","btn-chart-type",{active:v===i}),onClick:()=>this.handleTypeClick(g),children:[this.getTypeIcon(v),this.getTypeName(v)]})},f)})})]}),o.jsx("hr",{}),o.jsxs("div",{className:"form-row form-inline",children:[o.jsx("label",{className:"col-2 label-left",children:d}),o.jsx(Oe,{className:"form-control select-x-axis col",value:s,onChange:this.handleXAxisChange,children:r.map(v=>o.jsx("option",{value:v.name,children:v.name},v.name))})]}),h&&o.jsx("hr",{}),a.map((v,g)=>o.jsxs("div",{className:"form-row form-inline form-series-item","data-testid":"form-series-item-".concat(g),children:[o.jsx("label",{className:"col-2 label-left",children:g===0?c:""}),o.jsx(Oe,{className:"form-control select-series col",value:v.value,onChange:f=>this.handleSeriesChange(f,g),"data-testid":"select-series-item-".concat(g),children:r.map(f=>o.jsx("option",{value:f.name,children:f.name},f.name))}),a.length>1&&o.jsx(N,{kind:"ghost",className:"btn-delete-series ml-2 px-2","data-testid":"delete-series-".concat(g),onClick:()=>{this.handleSeriesDeleteClick(g)},icon:ye,tooltip:"Delete"})]},v.id)),m&&o.jsxs("div",{className:"form-row",children:[o.jsx("div",{className:"col-2"}),o.jsx(N,{kind:"ghost",className:"btn-add-series mt-1",onClick:this.handleAddSeries,icon:ze,children:"Add Series"})]}),o.jsxs("div",{className:"form-row chart-builder-link",children:[o.jsx("label",{className:"col-2 label-right",children:o.jsxs("div",{className:"fa-md fa-layers",children:[o.jsx(W,{mask:_t,icon:et,transform:"right-5 down-5"}),o.jsx(W,{icon:l?Lt:Ht,transform:"grow-2 right-8 down-6"})]})}),o.jsxs(Xe,{onChange:this.handleLinkStateChange,value:"".concat(l),children:[o.jsx(he,{value:"true",children:"Sync State"}),o.jsx(he,{value:"false",children:"Freeze State"})]})]}),o.jsxs("div",{className:"form-row",children:[o.jsx("div",{className:"col-2 label-right"}),o.jsx("div",{className:"col chart-builder-link-info",children:l?"Charts with synced state will update to match any filters or user modifications applied to the parent table.":"Freeze State disconnects the chart state from the parent table. New filters or user modifications on the parent table will not be applied."})]}),o.jsxs("div",{className:$("form-row","justify-content-end","my-3"),children:[o.jsx(N,{kind:"secondary",className:"btn-reset",onClick:this.handleReset,children:"Reset"}),o.jsx(N,{kind:"primary",type:"submit",className:"btn-submit",children:"Create"})]})]})})}}const to=J;function yr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function na(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?yr(Object(r),!0).forEach(function(n){Re(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):yr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Re(t,e,r){return e=aa(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function aa(t){var e=ia(t,"string");return typeof e=="symbol"?e:String(e)}function ia(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class ut extends C.Component{constructor(e){super(e),Re(this,"editorContainer",void 0),Re(this,"editor",void 0),this.handleContentChanged=this.handleContentChanged.bind(this),this.handleEditorFocus=this.handleEditorFocus.bind(this),this.handleEditorBlur=this.handleEditorBlur.bind(this),this.handleContainerClick=this.handleContainerClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.state={isEditorFocused:!1,isEditorEmpty:!0},this.editorContainer=null}componentDidMount(){this.initEditor()}componentWillUnmount(){this.destroyEditor()}initEditor(){var e,{value:r,editorSettings:n}=this.props,a=na({copyWithSyntaxHighlighting:"false",fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"groovyDB",lineDecorationsWidth:8,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},scrollBeyondLastLine:!1,padding:{top:6,bottom:6},tabCompletion:"off",useTabStops:!0,value:r,wordWrap:"on",automaticLayout:!0,autoClosingBrackets:"beforeWhitespace"},n);if(!this.editorContainer)throw new Error("editorContainer is null");this.editor=On.create(this.editorContainer,a),this.editor.layout(),(e=this.editor.getModel())===null||e===void 0||e.updateOptions({tabSize:0}),this.editor.onKeyDown(this.handleKeyDown),this.editor.onDidChangeModelContent(this.handleContentChanged),this.editor.onDidFocusEditorText(this.handleEditorFocus),this.editor.onDidBlurEditorText(this.handleEditorBlur)}destroyEditor(){var e;(e=this.editor)===null||e===void 0||e.dispose(),this.editor=void 0}handleContentChanged(){var e,r,{onContentChanged:n}=this.props,a=(e=this.editor)===null||e===void 0||(r=e.getModel())===null||r===void 0?void 0:r.getValue();a!==void 0&&this.setState({isEditorEmpty:a.length===0}),n(a)}handleEditorFocus(){this.setState({isEditorFocused:!0})}handleEditorBlur(){var e,r,n,a=(e=(r=this.editor)===null||r===void 0||(n=r.getModel())===null||n===void 0?void 0:n.getValue())!==null&&e!==void 0?e:"";this.setState({isEditorEmpty:a.length===0,isEditorFocused:!1})}handleContainerClick(){var e,{isEditorFocused:r}=this.state;r||(e=this.editor)===null||e===void 0||e.focus()}handleKeyDown(e){var{onTab:r,editorIndex:n}=this.props;e.code==="Tab"&&(e.stopPropagation(),e.preventDefault(),r(n,e.shiftKey))}render(){var{className:e,invalid:r,placeholder:n="",value:a}=this.props,{isEditorFocused:i,isEditorEmpty:s}=this.state;return o.jsxs("div",{className:$("input-editor-wrapper",{focused:i,invalid:r},e),role:"presentation",onClick:this.handleContainerClick,children:[o.jsx("div",{className:"editor-container",ref:l=>{this.editorContainer=l},"data-testid":"custom-column-formula"}),s&&!a&&n.length>0&&o.jsx("div",{className:"editor-placeholder text-muted",children:n})]})}}Re(ut,"defaultProps",{value:"",onContentChanged:()=>{},editorSettings:{},editorIndex:0,onTab:()=>{},invalid:!1});function xr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function xe(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?xr(Object(r),!0).forEach(function(n){oa(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):xr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function oa(t,e,r){return e=sa(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function sa(t){var e=la(t,"string");return typeof e=="symbol"?e:String(e)}function la(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Ir=Object.freeze({NAME:"name",FORMULA:"formula"}),da=()=>{};function ua(t){var{eventKey:e,name:r,inputIndex:n,formula:a,onChange:i,onDeleteColumn:s,onTabInEditor:l,invalid:u,isDuplicate:d}=t,c=r===""||qe.isValidColumnName(r),h=C.useCallback(m=>{m!==void 0&&(m.replace(/(\r\n|\n|\r)/gm,""),i(e,Ir.FORMULA,m))},[i,e]);return o.jsx(Ct,{draggableId:e,index:n,disableInteractiveElementBlocking:!0,children:(m,v)=>o.jsxs("div",xe(xe({className:$("draggable-container",{dragging:v.isDragging}),ref:m.innerRef},m.draggableProps),{},{children:[o.jsxs("div",{className:"custom-column-input-container",children:[o.jsxs("div",{className:"pb-3",children:[o.jsxs("div",{className:"d-flex flex-row custom-column-name",children:[o.jsx("input",{className:$("form-control custom-column-input",{"is-invalid":u||!c||d}),placeholder:"Column Name",value:r,onChange:g=>{i(e,Ir.NAME,g.target.value)}}),o.jsx(N,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{s(e)},icon:ye,tooltip:"Delete custom column"}),o.jsx(N,xe(xe({kind:"ghost",className:"btn-drag-handle",onClick:da},m.dragHandleProps),{},{icon:rt,tooltip:"Drag column to re-order"}))]}),(!c||d)&&o.jsx("p",{className:"validate-label-error text-danger mb-0 mt-2 pl-1",children:c?"Duplicate name":"Invalid name"})]}),o.jsx(ut,{editorSettings:{language:"deephavenDb"},editorIndex:n,placeholder:"Column Formula",value:a,onContentChanged:h,onTab:l,invalid:u})]}),o.jsx("hr",{})]}))})}function jr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function ke(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?jr(Object(r),!0).forEach(function(n){pe(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):jr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function pe(t,e,r){return e=ca(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ca(t){var e=ha(t,"string");return typeof e=="symbol"?e:String(e)}function ha(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class le extends C.Component{static makeCustomColumnInputEventKey(){return we.generate()}static createCustomColumnInput(){return{eventKey:we.generate(),name:"",formula:""}}constructor(e){super(e),pe(this,"container",void 0),pe(this,"successButtonTimer",void 0),pe(this,"getInput",Qe((r,n)=>r.find(a=>a.eventKey===n))),pe(this,"getInputIndex",Qe((r,n)=>r.findIndex(a=>a.eventKey===n))),this.handleAddColumnClick=this.handleAddColumnClick.bind(this),this.handleSaveClick=this.handleSaveClick.bind(this),this.handleInputChange=this.handleInputChange.bind(this),this.handleDeleteColumn=this.handleDeleteColumn.bind(this),this.handleCustomColumnUpdated=this.handleCustomColumnUpdated.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.resetRequestFailed=this.resetRequestFailed.bind(this),this.handleEditorTabNavigation=this.handleEditorTabNavigation.bind(this),this.state={inputs:[],isCustomColumnApplying:!1,errorMessage:null,hasRequestFailed:!1,isSuccessShowing:!1},this.container=null,this.successButtonTimer=null}componentDidMount(){var{customColumns:e}=this.props;this.parseCustomColumns(e),this.startListening()}componentWillUnmount(){this.stopListening(),this.successButtonTimer&&clearTimeout(this.successButtonTimer)}resetErrorMessage(){this.setState({errorMessage:null})}startListening(){var{model:e}=this.props;e.addEventListener(me.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.addEventListener(me.EVENT.UPDATED,this.handleCustomColumnUpdated),e.addEventListener(me.EVENT.REQUEST_FAILED,this.handleRequestFailed)}stopListening(){var{model:e}=this.props;e.removeEventListener(me.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.removeEventListener(me.EVENT.UPDATED,this.handleCustomColumnUpdated),e.removeEventListener(me.EVENT.REQUEST_FAILED,this.handleRequestFailed)}parseCustomColumns(e){if(e.length>0){var r=e.map(n=>{var a=n.split(/=(.+)/,2);return{eventKey:le.makeCustomColumnInputEventKey(),name:a[0],formula:a[1]}});this.setState({inputs:r})}else this.setState({inputs:[le.createCustomColumnInput()]})}handleAddColumnClick(){var{inputs:e}=this.state,r=[...e];r.push(le.createCustomColumnInput()),this.setState({inputs:r})}handleDeleteColumn(e){var{inputs:r}=this.state,n=this.getInputIndex(r,e),a=[...r];a.splice(n,1),a.length===0&&a.push(le.createCustomColumnInput()),this.setState({inputs:a})}handleInputChange(e,r,n){var{inputs:a}=this.state,i=this.getInputIndex(a,e),s=this.getInput(a,e),l=ke({},s);l[r]=n;var u=[...a];u.splice(i,1,l),this.setState({inputs:u})}handleCustomColumnUpdated(){var{isCustomColumnApplying:e}=this.state;e&&this.setState({isCustomColumnApplying:!1,isSuccessShowing:!0},()=>{this.successButtonTimer=setTimeout(()=>this.setState({isSuccessShowing:!1}),le.SUCCESS_SHOW_DURATION)})}handleRequestFailed(e){var r=e,{isCustomColumnApplying:n}=this.state;n&&this.setState({isCustomColumnApplying:!1,errorMessage:o.jsxs(o.Fragment,{children:[o.jsxs("p",{children:[o.jsx(W,{icon:Ee})," Failed to apply custom columns."]}),o.jsxs("div",{className:"error-box",children:[r.detail.errorMessage,o.jsx("br",{}),"Table configuration:"," ",JSON.stringify(r.detail.configuration)]})]}),hasRequestFailed:!0})}handleDragEnd(e){if(ne.stopDragging(),!!e.destination){var{inputs:r}=this.state,n=e.source.index,a=e.destination.index,i=[...r],s=r[n];i.splice(n,1),i.splice(a,0,s),this.setState({inputs:i})}}handleEditorTabNavigation(e,r){var{inputs:n}=this.state;if(r){var a;((a=this.container)===null||a===void 0?void 0:a.querySelectorAll(".btn-drag-handle")[e]).focus();return}if(e===n.length-1){var i,s;(i=this.container)===null||i===void 0||(s=i.querySelector(".btn-add-column"))===null||s===void 0||s.focus()}else{var l,u=e+1;((l=this.container)===null||l===void 0?void 0:l.querySelectorAll(".custom-column-input")[u]).focus()}}handleSaveClick(){var{onSave:e,customColumns:r}=this.props,{inputs:n,isCustomColumnApplying:a}=this.state;if(!a){var i=[];n.forEach(s=>{var{name:l,formula:u}=s;l&&u&&i.push("".concat(l,"=").concat(u))}),this.resetErrorMessage(),this.setState({isCustomColumnApplying:i.length>0||r.length>0}),e(i)}}resetRequestFailed(){this.setState(e=>{var{hasRequestFailed:r}=e;return r?{hasRequestFailed:!1}:null})}renderInputs(){var{inputs:e,hasRequestFailed:r}=this.state,n=new Map;return e.forEach(a=>{var i,{name:s}=a;return n.set(s,((i=n.get(s))!==null&&i!==void 0?i:0)+1)}),e.map((a,i)=>{var s,{eventKey:l,name:u,formula:d}=a,c=((s=n.get(u))!==null&&s!==void 0?s:0)>1;return o.jsx(ua,{inputIndex:i,eventKey:l,name:u,formula:d,onChange:this.handleInputChange,onDeleteColumn:this.handleDeleteColumn,onTabInEditor:this.handleEditorTabNavigation,invalid:r,isDuplicate:c},l)})}renderSaveButton(){var{inputs:e,isCustomColumnApplying:r,isSuccessShowing:n}=this.state,a=e.length>1?"Save Columns":"Save Column",i=e.every(u=>{var{name:d}=u;return d===""||qe.isValidColumnName(d)}),s=e.filter(u=>{var{name:d}=u;return d!==""}).map(u=>{var{name:d}=u;return d}),l=new Set(s).size===s.length;return o.jsxs(N,{kind:n?"success":"primary",className:$("btn-apply",{"btn-spinner":r}),disabled:n||r||!i||!l,onClick:this.handleSaveClick,icon:n?Gt:void 0,children:[r&&o.jsxs("span",{children:[o.jsx(tt,{className:"mr-2 loading-spinner-vertical-align"}),o.jsx("span",{className:"btn-normal-content",children:"Applying"})]}),!n&&!r&&a,n&&"Success"]})}render(){var{onCancel:e}=this.props,{errorMessage:r}=this.state;return o.jsxs("div",{role:"presentation",className:"custom-column-builder-container",ref:n=>{this.container=n},onClick:this.resetRequestFailed,onFocus:this.resetRequestFailed,children:[o.jsx("hr",{}),o.jsx(We,{onDragStart:ne.startDragging,onDragEnd:this.handleDragEnd,children:o.jsx(Zr,{droppableId:"droppable-custom-columns",children:(n,a)=>o.jsxs("div",ke(ke({ref:n.innerRef},n.droppableProps),{},{className:$("droppable-container",{dragging:a.draggingFromThisWith}),children:[this.renderInputs(),n.placeholder]}))})}),o.jsx("div",{className:"pt-1 px-3",children:o.jsx(N,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,icon:ze,children:"Add Another Column"})}),o.jsxs("div",{className:"custom-column-builder-footer",children:[r&&o.jsx("div",{className:"error-message",children:r}),o.jsxs("div",{className:"d-flex justify-content-end",children:[o.jsx(N,{kind:"secondary",className:"mr-2",onClick:e,children:"Cancel"}),this.renderSaveButton()]})]})]})}}pe(le,"SUCCESS_SHOW_DURATION",750);const no=le;var Ge;(function(t){t.ADVANCED_SETTINGS="ADVANCED_SETTINGS",t.AGGREGATIONS="AGGREGATIONS",t.AGGREGATION_EDIT="AGGREGATIONS_EDIT",t.CHART_BUILDER="CHART_BUILDER",t.CUSTOM_COLUMN_BUILDER="CUSTOM_COLUMN_BUILDER",t.QUICK_FILTERS="QUICK_FILTERS",t.ROLLUP_ROWS="ROLLUP_ROWS",t.SEARCH_BAR="SEARCH_BAR",t.SELECT_DISTINCT="SELECT_DISTINCT",t.TABLE_EXPORTER="TABLE_EXPORTER",t.VISIBILITY_ORDERING_BUILDER="VISIBILITY_ORDERING_BUILDER",t.CONDITIONAL_FORMATTING="CONDITIONAL_FORMATTING",t.CONDITIONAL_FORMATTING_EDIT="CONDITIONAL_FORMATTING_EDIT",t.GOTO="GOTO"})(Ge||(Ge={}));const ao=Ge;function Dr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Pr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Dr(Object(r),!0).forEach(function(n){de(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Dr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function de(t,e,r){return e=va(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function va(t){var e=ma(t,"string");return typeof e=="symbol"?e:String(e)}function ma(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Ce=be.module("RollupRows"),ga=150,Ie="grouped-rollup-rows",je="ungrouped-rollup-rows";class z extends C.Component{static renderColumn(e){var{item:r,isClone:n,selectedCount:a}=e,i=r?.name,s=n!==void 0&&n?"".concat(a):void 0,l=n!==void 0&&n?"item-list-item-clone":"";return ee.renderTextItem({text:i,badgeText:s,className:l})}static addGroupings(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length;if(r==null||r.length===0)return e;var a=n,i=e.filter((s,l)=>r.includes(s)?(l<a&&(a-=1),!1):!0);return i.splice(a,0,...r),i}static isGroupable(e){return!V.isDecimalType(e.type)}constructor(e){super(e),de(this,"ungroupedList",void 0),de(this,"groupedList",void 0),de(this,"search",Qr(s=>{for(var l=this.getSortedUngroupedColumns(),u=[],d=null,c=0;c<l.length;c+=1){var h=l[c];h.name.toLowerCase().includes(s.toLowerCase())&&(d==null&&(d=c),u.push([c,c]))}k(d),this.setState({ungroupedSelectedRanges:u}),u.length>0&&this.ungroupedList.current&&this.ungroupedList.current.scrollToItem(d)},ga)),de(this,"getCachedUngroupedColumns",oe((s,l)=>s.filter(u=>z.isGroupable(u)&&l.find(d=>d===u.name)==null))),de(this,"getCachedSortedColumns",oe((s,l)=>l==null?[...s]:V.sortColumns(s,l===z.SORT.ASCENDING))),this.handleDeleteClicked=this.handleDeleteClicked.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleUngroupedSelect=this.handleUngroupedSelect.bind(this),this.handleUngroupedSelectionChange=this.handleUngroupedSelectionChange.bind(this),this.handleDragStart=this.handleDragStart.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleGroupedSelectionChange=this.handleGroupedSelectionChange.bind(this),this.handleShowConstituentsChange=this.handleShowConstituentsChange.bind(this),this.handleShowNonAggregatedColumnsChange=this.handleShowNonAggregatedColumnsChange.bind(this),this.handleSortAscending=this.handleSortAscending.bind(this),this.handleSortDescending=this.handleSortDescending.bind(this),this.renderGroupedItem=this.renderGroupedItem.bind(this),this.ungroupedList=Je.createRef(),this.groupedList=Je.createRef();var{config:r}=e,{columns:n=[],showConstituents:a=!0,showNonAggregatedColumns:i=!0}=r??{};this.state={ungroupedSelectedRanges:[],columns:n,groupedSelectedRanges:[],searchFilter:"",showConstituents:a,showNonAggregatedColumns:i,dragSource:null,sort:null}}componentDidUpdate(e,r){var{config:n}=this.props,{columns:a,showConstituents:i,showNonAggregatedColumns:s}=this.state;n!==e.config?this.updateFromConfig():(a!==r.columns||i!==r.showConstituents||s!==r.showNonAggregatedColumns)&&(n==null||a!==n.columns||i!==n.showConstituents||s!==n.showNonAggregatedColumns)&&this.sendChange()}componentWillUnmount(){this.search.cancel()}handleSearchChange(e){var r=e.target.value;if(this.setState({searchFilter:r}),!r){this.search.cancel(),this.resetSelection();return}this.search(r)}handleSortAscending(){this.setState(e=>{var{sort:r}=e;return{sort:r===z.SORT.ASCENDING?null:z.SORT.ASCENDING}})}handleSortDescending(){this.setState(e=>{var{sort:r}=e;return{sort:r===z.SORT.DESCENDING?null:z.SORT.DESCENDING}})}resetSelection(){this.setState({ungroupedSelectedRanges:[],groupedSelectedRanges:[]})}handleDragStart(e){Ce.debug("handleDragStart",e),document.documentElement.classList.add("drag-pointer-events-none"),this.setState({dragSource:e.source})}handleDragEnd(e){Ce.debug("handleDragEnd",e),document.documentElement.classList.remove("drag-pointer-events-none"),this.setState({dragSource:null});var{destination:r,source:n}=e;if(!(r==null||n==null)){if(r.droppableId===je){this.setState(s=>{var{groupedSelectedRanges:l,columns:u}=s,d=[...u];return ne.reorder(d,l,[],0),{columns:d,ungroupedSelectedRanges:[],groupedSelectedRanges:[]}});return}var a=n.droppableId===Ie,i=r.index;a&&n.index<r.index&&(i+=1),this.setState(s=>{var{columns:l,ungroupedSelectedRanges:u,groupedSelectedRanges:d}=s,c=[...l],h=a?c:this.getSortedUngroupedColumns().map(b=>b.name),m=a?d:u,v=ne.reorder(h,m,c,i),g=a?ne.adjustDestinationIndex(i,d):i,f=[[g,g+v.length-1]];return{columns:c,ungroupedSelectedRanges:[],groupedSelectedRanges:f}}),this.resetSelection()}}handleUngroupedSelect(e){Ce.debug("handleUngroupedSelect"),this.setState(r=>{var{columns:n}=r;return{columns:z.addGroupings(n,[this.getSortedUngroupedColumns()[e].name]),ungroupedSelectedRanges:[],groupedSelectedRanges:[]}})}handleUngroupedSelectionChange(e){Ce.debug2("handleUngroupedSelectionChange",e),this.setState(r=>{var{ungroupedSelectedRanges:n}=r;return e===n?null:{ungroupedSelectedRanges:e,groupedSelectedRanges:[]}})}handleGroupedSelectionChange(e){Ce.debug2("handleGroupedSelectedRanges",e),this.setState(r=>{var{groupedSelectedRanges:n}=r;return e===n?null:{groupedSelectedRanges:e,ungroupedSelectedRanges:[]}})}handleDeleteClicked(e){this.setState(r=>{var{columns:n}=r,a=n.slice();return a.splice(e,1),{columns:a}})}handleShowConstituentsChange(){this.setState(e=>{var{showConstituents:r}=e;return{showConstituents:!r}})}handleShowNonAggregatedColumnsChange(){this.setState(e=>{var{showNonAggregatedColumns:r}=e;return{showNonAggregatedColumns:!r}})}updateFromConfig(){var{config:e}=this.props,{columns:r=[],showConstituents:n=!0,showNonAggregatedColumns:a=!0}=e??{};this.setState({columns:r,showConstituents:n,showNonAggregatedColumns:a})}sendChange(){var{onChange:e}=this.props,{columns:r,showConstituents:n,showNonAggregatedColumns:a}=this.state;e({columns:r,showConstituents:n,showNonAggregatedColumns:a})}getUngroupedColumns(){var{model:e}=this.props,{columns:r}=this.state,{originalColumns:n}=e;return this.getCachedUngroupedColumns(n,r)}getSortedUngroupedColumns(){var{sort:e}=this.state,r=this.getUngroupedColumns();return this.getCachedSortedColumns(r,e)}renderGroupedItem(e){var{item:r,itemIndex:n,isClone:a,selectedCount:i}=e,s=a!==void 0&&a?"":"  ".repeat(n),l="".concat(s).concat(r),u=a!==void 0&&a?"".concat(i):void 0,d=a!==void 0&&a?"item-list-item-clone":"";return o.jsxs(o.Fragment,{children:[ee.renderTextItem({text:l,badgeText:u,className:d}),(a===void 0||!a)&&o.jsx(N,{kind:"ghost",className:"btn btn-link btn-link-icon btn-delete-grouping float-right",onClick:()=>this.handleDeleteClicked(n),children:o.jsx(W,{icon:ye})})]})}render(){var{columns:e,dragSource:r,searchFilter:n,groupedSelectedRanges:a,ungroupedSelectedRanges:i,showConstituents:s,showNonAggregatedColumns:l,sort:u}=this.state,d=this.getSortedUngroupedColumns(),c=e.length*ee.DEFAULT_ROW_HEIGHT;r?.droppableId===je&&(c+=ee.DEFAULT_ROW_HEIGHT);var h=d.length*ee.DEFAULT_ROW_HEIGHT+10,m=Math.min(3*ee.DEFAULT_ROW_HEIGHT,h);return o.jsx("div",{role:"menu",className:$("rollup-rows",{"is-dragging":r!=null}),tabIndex:0,children:o.jsxs(We,{onDragEnd:this.handleDragEnd,onDragStart:this.handleDragStart,children:[o.jsxs("div",{className:"rollup-rows-group-by",children:[o.jsx("div",{className:"section-title",children:"Group By"}),e.length===0&&o.jsx(Zr,{droppableId:"placeholder",children:(v,g)=>o.jsx("div",Pr(Pr({className:$("placeholder","text-muted",{"is-dragging-from-this":g.draggingFromThisWith,"is-dragging-over":g.isDraggingOver,"is-dropping":g.draggingOverWith}),ref:v.innerRef},v.droppableProps),{},{children:"To create a rollup, drag columns from the list below and drop them into this area."}))}),e.length>0&&o.jsx(ee,{draggingItemClassName:"rollup-rows-dragging-grouped-item",draggablePrefix:Ie,droppableId:Ie,itemCount:e.length,items:e,offset:0,onSelectionChange:this.handleGroupedSelectionChange,ref:this.groupedList,renderItem:this.renderGroupedItem,selectedRanges:a,style:{height:c},isMultiSelect:!0})]}),o.jsxs("div",{className:"rollup-rows-available-columns",children:[o.jsx("div",{className:"section-title",children:"Available Grouping Columns"}),o.jsxs("div",{className:"top-menu",children:[o.jsx(lt,{className:"w-100",value:n,matchCount:n?i.length:void 0,placeholder:"Find column...",onChange:this.handleSearchChange}),o.jsxs(N,{kind:"ghost",className:$("btn-link btn-link-icon",{active:u===z.SORT.ASCENDING}),onClick:this.handleSortAscending,children:[o.jsx(W,{icon:Ve}),o.jsx(He,{children:"Sort ascending"})]}),o.jsxs(N,{kind:"ghost",className:$("btn-link btn-link-icon",{active:u===z.SORT.DESCENDING}),onClick:this.handleSortDescending,children:[o.jsx(W,{icon:Ke}),o.jsx(He,{children:"Sort descending"})]})]}),o.jsx(ee,{className:"rollup-available-grouping-columns",draggablePrefix:je,droppableId:je,itemCount:d.length,items:d,renderItem:z.renderColumn,offset:0,onSelect:this.handleUngroupedSelect,onSelectionChange:this.handleUngroupedSelectionChange,ref:this.ungroupedList,selectedRanges:i,style:{maxHeight:h,minHeight:m},isDropDisabled:r?.droppableId!==Ie,isMultiSelect:!0}),o.jsxs("div",{className:"bottom-menu",children:[o.jsx("div",{className:"label",children:"Show:"}),o.jsx(ce,{checked:s,onChange:this.handleShowConstituentsChange,children:"Constituents"}),o.jsx(ce,{checked:l,onChange:this.handleShowNonAggregatedColumnsChange,children:"Non-Aggregated Columns"})]})]})]})})}}de(z,"SORT",Object.freeze({ASCENDING:"ASC",DESCENDING:"DESC"}));de(z,"defaultProps",{config:null,onChange:()=>{}});const io=z;function Nr(t,e,r,n,a,i,s){try{var l=t[i](s),u=l.value}catch(d){r(d);return}l.done?e(u):Promise.resolve(u).then(n,a)}function fa(t){return function(){var e=this,r=arguments;return new Promise(function(n,a){var i=t.apply(e,r);function s(u){Nr(i,n,a,s,l,"next",u)}function l(u){Nr(i,n,a,s,l,"throw",u)}s(void 0)})}}function Tr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Er(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Tr(Object(r),!0).forEach(function(n){ve(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Tr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function ve(t,e,r){return e=pa(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pa(t){var e=ba(t,"string");return typeof e=="symbol"?e:String(e)}function ba(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Ca=be.module("TableCsvExporter");class P extends C.Component{static getDateString(e){return e.i18n.DateTimeFormat.format(P.FILENAME_DATE_FORMAT,new Date)}constructor(e){super(e),this.handleDownloadClick=this.handleDownloadClick.bind(this),this.handleDownloadRowOptionChanged=this.handleDownloadRowOptionChanged.bind(this),this.handleCustomizedDownloadRowOptionChanged=this.handleCustomizedDownloadRowOptionChanged.bind(this),this.handleCustomizedDownloadRowsChanged=this.handleCustomizedDownloadRowsChanged.bind(this),this.handleIncludeColumnHeadersChanged=this.handleIncludeColumnHeadersChanged.bind(this),this.handleIncludeHiddenColumnsChanged=this.handleIncludeHiddenColumnsChanged.bind(this),this.handleUseUnformattedValuesChanged=this.handleUseUnformattedValuesChanged.bind(this);var{model:r,name:n}=e;this.state={fileName:"".concat(n,"-").concat(P.getDateString(r.dh),".csv"),downloadRowOption:P.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,customizedDownloadRowOption:P.CUSTOMIZED_ROWS_OPTIONS.FIRST,customizedDownloadRows:P.DEFAULT_DOWNLOAD_ROWS,includeColumnHeaders:!0,includeHiddenColumns:!1,useUnformattedValues:!1,errorMessage:null,id:we.generate()}}getSnapshotRanges(){var{model:e,selectedRanges:r}=this.props,{downloadRowOption:n,customizedDownloadRowOption:a,customizedDownloadRows:i}=this.state,{rowCount:s,columnCount:l}=e,u=[];switch(n){case P.DOWNLOAD_ROW_OPTIONS.ALL_ROWS:u.push(new ge(0,0,l-1,s-1));break;case P.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS:u=r.map(d=>Er(Er({},d),{},{startColumn:0,endColumn:l-1})).sort((d,c)=>d.startRow!=null&&c.startRow!=null?d.startRow-c.startRow:0);break;case P.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS:switch(a){case P.CUSTOMIZED_ROWS_OPTIONS.FIRST:u.push(new ge(0,0,l-1,Math.min(i-1,s-1)));break;case P.CUSTOMIZED_ROWS_OPTIONS.LAST:u.push(new ge(0,Math.max(0,s-i),l-1,s-1));break}break}return u}getModelRanges(e){var{userColumnWidths:r,movedColumns:n}=this.props,{includeHiddenColumns:a}=this.state,i=it.getHiddenColumns(r),s=M.getModelRanges(e,n);if(!a&&i.length>0){var l=i.map(ge.makeColumn);s=ge.subtractRangesFromRanges(s,l)}return s}resetDownloadState(){this.setState({errorMessage:null})}handleDownloadClick(){var e=this;return fa(function*(){var{model:r,isDownloading:n,onDownloadStart:a,onDownload:i,onCancel:s}=e.props,{fileName:l,includeColumnHeaders:u,useUnformattedValues:d}=e.state;if(n){s();return}e.resetDownloadState();var c=e.getSnapshotRanges(),h=e.getModelRanges(c);if(e.validateOptionInput()){a();try{var m=yield r.export(),v=m.setViewport(0,0);yield v.getViewportData(),i(l,m,v,c,h,u,d)}catch(g){Ca.error("CSV download failed",g),e.setState({errorMessage:o.jsxs("p",{children:[o.jsx(W,{icon:Ee})," ","".concat(g)]})}),s()}}})()}handleDownloadRowOptionChanged(e){this.setState({downloadRowOption:e.target.value})}handleCustomizedDownloadRowOptionChanged(e){this.setState({customizedDownloadRowOption:e})}handleCustomizedDownloadRowsChanged(e){this.setState({customizedDownloadRows:parseInt(e.target.value,10)})}handleIncludeColumnHeadersChanged(){this.setState(e=>{var{includeColumnHeaders:r}=e;return{includeColumnHeaders:!r}})}handleIncludeHiddenColumnsChanged(){this.setState(e=>{var{includeHiddenColumns:r}=e;return{includeHiddenColumns:!r}})}handleUseUnformattedValuesChanged(){this.setState(e=>{var{useUnformattedValues:r}=e;return{useUnformattedValues:!r}})}validateOptionInput(){var{selectedRanges:e}=this.props,{downloadRowOption:r,customizedDownloadRows:n}=this.state;return r===P.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS&&e.length===0?(this.setState({errorMessage:o.jsxs("p",{children:[o.jsx(W,{icon:Ee})," No rows selected. Please select some rows in the table."]})}),!1):r===P.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS&&n<=0?(this.setState({errorMessage:o.jsxs("p",{children:[o.jsx(W,{icon:Ee})," Number of rows to output must be greater than 0"]})}),!1):!0}render(){var{model:e,isDownloading:r,tableDownloadProgress:n,tableDownloadEstimatedTime:a,selectedRanges:i,tableDownloadStatus:s}=this.props,{fileName:l,downloadRowOption:u,customizedDownloadRowOption:d,customizedDownloadRows:c,includeColumnHeaders:h,includeHiddenColumns:m,useUnformattedValues:v,errorMessage:g,id:f}=this.state,{rowCount:b}=e;return o.jsxs("div",{className:"table-csv-exporter",children:[o.jsx("div",{className:"section-title",children:"Download Rows"}),o.jsx("div",{className:"form-group",children:o.jsxs(Xe,{onChange:this.handleDownloadRowOptionChanged,value:u,disabled:r,children:[o.jsxs(he,{value:P.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,"data-testid":"radio-csv-exporter-download-all",children:["All Rows",o.jsx("span",{className:"text-muted ml-2",children:"(".concat(b.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")," rows)")})]}),o.jsxs(he,{value:P.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS,"data-testid":"radio-csv-exporter-only-selected",children:["Only Selected Rows",o.jsx("span",{className:"text-muted ml-2",children:i.length>0?"(".concat(ge.rowCount(i).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")," rows)"):null})]}),o.jsx(he,{value:P.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS,"data-testid":"radio-csv-exporter-customized-rows",children:o.jsxs("div",{className:"radio-input-row",role:"presentation",onClick:()=>{this.setState({downloadRowOption:P.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS})},children:[o.jsxs(Oe,{value:d,"data-testid":"select-csv-exporter-customized-rows",className:"custom-select",disabled:r,onChange:this.handleCustomizedDownloadRowOptionChanged,children:[o.jsx("option",{value:"FIRST",children:"First"}),o.jsx("option",{value:"LAST",children:"Last"})]}),o.jsx("input",{type:"number",className:"form-control",id:"customizedRows-".concat(f),"data-testid":"input-csv-exporter-customized-rows",name:"customizedRows-".concat(f),placeholder:"100",value:c,disabled:r,onChange:this.handleCustomizedDownloadRowsChanged}),o.jsx("div",{children:"Rows"})]})})]})}),o.jsxs("div",{className:"form-group",children:[o.jsx("label",{htmlFor:"customizedRows-".concat(f),children:"File Name"}),o.jsx("input",{type:"text",className:"form-control",id:"filename-".concat(f),"data-testid":"input-csv-exporter-file-name",name:"filename-".concat(f),value:l,onChange:p=>{this.setState({fileName:p.target.value})},disabled:r})]}),o.jsxs("div",{className:"checkbox-options",children:[o.jsx(ce,{checked:h,onChange:this.handleIncludeColumnHeadersChanged,children:"Include column headers"}),o.jsx(ce,{checked:m,onChange:this.handleIncludeHiddenColumnsChanged,children:"Include hidden columns"}),o.jsx(ce,{checked:v,onChange:this.handleUseUnformattedValuesChanged,children:"Use unformatted values"})]}),o.jsxs("div",{className:"section-footer flex-column",children:[g!=null&&o.jsx("div",{className:"error-message",children:g}),s&&o.jsxs("div",{className:"download-status",children:[(s===P.DOWNLOAD_STATUS.DOWNLOADING||s===P.DOWNLOAD_STATUS.INITIATING)&&o.jsxs(o.Fragment,{children:[s===P.DOWNLOAD_STATUS.INITIATING&&o.jsx("div",{className:"text-muted",children:"Starting Download..."}),s===P.DOWNLOAD_STATUS.DOWNLOADING&&o.jsxs("div",{className:"text-muted d-flex justify-content-between",children:[o.jsx("span",{children:a||a===0?"Estimated time: ".concat(fn.formatElapsedTime(a)):null}),o.jsx("span",{children:"".concat(n,"%")})]})]}),s===P.DOWNLOAD_STATUS.FINISHED&&o.jsx("div",{className:"text-muted text-right",children:"Download Completed"}),s===P.DOWNLOAD_STATUS.CANCELED&&o.jsx("div",{className:"text-muted",children:"Download Canceled"}),(s===P.DOWNLOAD_STATUS.DOWNLOADING||s===P.DOWNLOAD_STATUS.INITIATING)&&o.jsx("div",{className:"progress",children:o.jsx("div",{className:"progress-bar progress-bar-striped progress-bar-animated",style:{width:"".concat(n,"%")}})}),s===P.DOWNLOAD_STATUS.FINISHED&&o.jsx("div",{className:"progress",children:o.jsx("div",{className:"progress-bar bg-success",style:{width:"".concat(n,"%")}})})]}),o.jsxs(N,{kind:"primary","data-testid":"btn-csv-exporter-download",className:$("btn-downloading",{"btn-spinner btn-cancelable":r}),onClick:this.handleDownloadClick,children:[r&&o.jsxs("span",{children:[o.jsx(tt,{className:"mr-2 loading-spinner-vertical-align"}),o.jsx("span",{className:"btn-normal-content",children:"Downloading"}),o.jsx("span",{className:"btn-hover-content",children:"Cancel"})]}),!r&&"Download"]})]})]})}}ve(P,"FILENAME_DATE_FORMAT","yyyy-MM-dd-HHmmss");ve(P,"DOWNLOAD_STATUS",{INITIATING:"INITIATING",DOWNLOADING:"DOWNLOADING",FINISHED:"FINISHED",CANCELED:"CANCELED"});ve(P,"DOWNLOAD_ROW_OPTIONS",{ALL_ROWS:"ALL_ROWS",SELECTED_ROWS:"SELECTED_ROWS",CUSTOMIZED_ROWS:"CUSTOMIZED_ROWS"});ve(P,"CUSTOMIZED_ROWS_OPTIONS",{FIRST:"FIRST",LAST:"LAST"});ve(P,"DEFAULT_DOWNLOAD_ROWS",100);ve(P,"defaultProps",{onDownloadStart:()=>{},isDownloading:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:null,selectedRanges:[]});const oo=P;function R(t,e,r){return e=Sa(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sa(t){var e=wa(t,"string");return typeof e=="symbol"?e:String(e)}function wa(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var te=be.module("TableSaver"),Oa="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function ya(t){return t.added!==void 0}function xa(t){if(!ya(t))throw new Error("event is not UpdateEventData")}class X extends C.PureComponent{static csvEscapeString(e){return'"'.concat(e.replace(/"/g,'""'),'"')}constructor(e){super(e),R(this,"sw",void 0),R(this,"port",void 0),R(this,"fileWriter",void 0),R(this,"table",void 0),R(this,"tableSubscription",void 0),R(this,"columns",void 0),R(this,"fileName",void 0),R(this,"includeColumnHeaders",void 0),R(this,"useUnformattedValues",void 0),R(this,"chunkRows",void 0),R(this,"gridRanges",void 0),R(this,"gridRangeCounter",void 0),R(this,"rangedSnapshotsTotal",void 0),R(this,"rangedSnapshotCounter",void 0),R(this,"snapshotsTotal",void 0),R(this,"snapshotCounter",void 0),R(this,"snapshotsBuffer",void 0),R(this,"currentSnapshotIndex",void 0),R(this,"snapshotPending",void 0),R(this,"cancelableSnapshots",void 0),R(this,"streamTimeout",void 0),R(this,"snapshotHandlerTimeout",void 0),R(this,"downloadStartTime",void 0),R(this,"iframe",void 0),R(this,"useBlobFallback",void 0),R(this,"getCachedCustomColumnFormatFlag",dt(yn.isCustomColumnFormatDefined,{max:1e4})),this.handlePortMessage=this.handlePortMessage.bind(this),this.handleSnapshotResolved=this.handleSnapshotResolved.bind(this),this.handleDownloadTimeout=this.handleDownloadTimeout.bind(this),this.state={},this.gridRanges=[],this.gridRangeCounter=0,this.rangedSnapshotsTotal=[],this.rangedSnapshotCounter=0,this.includeColumnHeaders=!0,this.useUnformattedValues=!1,this.snapshotsTotal=0,this.snapshotCounter=0,this.snapshotsBuffer=new Map,this.currentSnapshotIndex=0,this.snapshotPending=0,this.cancelableSnapshots=[],this.useBlobFallback=!1}componentDidMount(){var{getDownloadWorker:e}=this.props;e().then(r=>{te.info("found active service worker"),this.sw=r,this.sw.postMessage("ping")}).catch(r=>{te.warn("Download csv is not optimized.",r),this.useBlobFallback=!0})}componentWillUnmount(){this.removeIframe(),this.streamTimeout&&clearTimeout(this.streamTimeout),this.snapshotHandlerTimeout&&clearTimeout(this.snapshotHandlerTimeout)}createWriterStream(e){var r=this.useBlobFallback,n=[],a=null;r&&(a=TextEncoder.prototype.encode.bind(new TextEncoder));var{fileName:i}=this,s={};return r?(s.write=l=>{k(a),l.header!==void 0&&n.push(a(l.header)),l.rows!==void 0&&n.push(a(l.rows))},s.close=()=>{k(i);var l=new Blob(n,{type:"application/octet-stream; charset=utf-8"}),u=document.createElement("a");u.href=URL.createObjectURL(l),u.download=i,u.click()},s.abort=()=>{e.postMessage({cancel:!0}),e.close()}):(s.write=l=>{e.postMessage(l)},s.close=()=>{e.postMessage({end:!0}),e.close()},s.abort=()=>{e.postMessage({cancel:!0}),e.close()}),new WritableStream(s)}startDownload(e,r,n,a,i,s,l){var{isDownloading:u}=this.props;if(!u){this.downloadStartTime=Date.now(),te.info("start downloading ".concat(e)),this.table=r,this.columns=it.columnsFromRanges(i,r.columns),this.tableSubscription=n,this.gridRanges=a,this.includeColumnHeaders=s,this.useUnformattedValues=l;var d=encodeURIComponent(e.replace(/\//g,":")).replace(/['()]/g,escape).replace(/\*/g,"%2A"),c=new MessageChannel;if(this.port=c.port1,this.fileName=e,this.fileWriter=this.createWriterStream(this.port).getWriter(),this.useBlobFallback){this.writeCsvTable(s);return}this.sw&&this.sw.postMessage({encodedFileName:d},[c.port2]),this.port.onmessage=this.handlePortMessage}}finishDownload(){this.table&&this.table.close(),this.tableSubscription&&this.tableSubscription.close(),this.fileWriter&&this.fileWriter.close();var{onDownloadCompleted:e}=this.props;e(),this.resetTableSaver(),this.downloadStartTime!==void 0&&te.info("download finished, total elapsed time ".concat((Date.now()-this.downloadStartTime)/1e3," seconds"))}cancelDownload(){var e,r,n;(e=this.table)===null||e===void 0||e.close(),(r=this.tableSubscription)===null||r===void 0||r.close(),(n=this.fileWriter)===null||n===void 0||n.abort(),this.cancelableSnapshots.forEach(i=>{i&&(i.catch(()=>null),i.cancel())});var{onDownloadCanceled:a}=this.props;a(),this.resetTableSaver()}resetTableSaver(){this.table=void 0,this.tableSubscription=void 0,this.columns=void 0,this.chunkRows=void 0,this.removeIframe(),this.gridRanges=[],this.gridRangeCounter=0,this.rangedSnapshotsTotal=[],this.rangedSnapshotCounter=0,this.includeColumnHeaders=!0,this.useUnformattedValues=!1,this.snapshotsTotal=0,this.snapshotCounter=0,this.snapshotsBuffer=new Map,this.currentSnapshotIndex=0,this.snapshotPending=0,this.cancelableSnapshots=[],this.streamTimeout!=null&&clearTimeout(this.streamTimeout),this.snapshotHandlerTimeout!=null&&clearTimeout(this.snapshotHandlerTimeout),this.streamTimeout=void 0,this.snapshotHandlerTimeout=void 0}handleDownloadTimeout(){te.info("download canceled"),this.cancelDownload()}writeTableHeader(){var e,r="";if(this.columns)for(var n=0;n<this.columns.length;n+=1)r+=this.columns[n].name,r+=n===this.columns.length-1?`
1
+ import{r as C,I as o,K as $,L as W,bb as We,Z as we,ba as Ct,bc as Zr,_ as Qe,T as Qr,U as oe,M as Je,bP as St,bQ as re,bR as wt,bS as Ot,bT as yt,bU as xt,bV as _e,bW as It,bX as jt,bY as Dt,bZ as er,b_ as Pt,b$ as rr,c0 as Nt,c1 as Tt,c2 as Et,c3 as Rt,c4 as At,c5 as Mt,af as Le,$ as kt}from"./vendor-2ad5ff96.js";import{L as be,bb as Ft,am as Jr,f as ye,g as ze,T as K,bc as Ve,bd as Ke,aq as _t,ao as et,u as Lt,be as Ht,ar as rt,ai as Ee,aj as Gt,I as tt,e as k,aF as Ut,bf as $t,F as tr,n as Bt,bg as nt,bh as at,v as Wt,bi as zt,J as Vt,b4 as Kt,bj as qt,bk as Xt,bl as Yt,bm as Zt,bn as Qt,d as Jt,ay as en,bo as rn,aV as Z,a8 as tn,a2 as nn,aL as an}from"./index-49c2275d.js";import{S as on,b as nr,m as sn,I as it,C as ue}from"./MissingPartitionError-6c767865.js";import{a as ne}from"./IrisGridShortcuts-ce1afae5.js";import{b as ee,O as ot,h as ln,T as dn,i as st,j as un,k as cn,G as hn}from"./GridRenderer-bc76a490.js";import{B as N,S as Oe,c as V,C as ce,x as vn,aQ as mn,a9 as gn,D as qe,Q as lt,s as He,d as fn,P as pn,ck as bn,u as Cn,ai as Sn,a_ as wn}from"./ControlType-5e65a1f9.js";import{R as Xe,a as he,c as me,d as ge,G as M,m as dt}from"./IrisGridModel-5eee50a2.js";import{e as On}from"./monaco-b5248072.js";import{F as yn}from"./FormatterUtils-84854bf0.js";function ar(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function ir(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ar(Object(r),!0).forEach(function(n){xn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ar(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function xn(t,e,r){return e=In(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function In(t){var e=jn(t,"string");return typeof e=="symbol"?e:String(e)}function jn(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var or=be.module("Aggregations");function Qi(t){var{isRollup:e,settings:r,onChange:n,onEdit:a}=t,{aggregations:i,showOnTop:s}=r,l=C.useMemo(()=>on.filter(w=>!i.some(j=>j.operation===w)),[i]),[u,d]=C.useState(l[0]),[c,h]=C.useState([]),m=C.useCallback(w=>{n(ir(ir({},r),w))},[n,r]),v=C.useCallback(w=>{m({aggregations:w})},[m]),g=C.useCallback(w=>{m({showOnTop:w})},[m]),f=C.useCallback(()=>{or.debug("handleDragStart"),ne.startDragging()},[]),b=C.useCallback(w=>{var{destination:j,source:E}=w;if(or.debug("handleDragEnd",j,E),ne.stopDragging(),j!==null){var L=j.index;E.index<j.index&&(L+=1);var _=[...i],F=ne.reorder(_,c,_,L),U=ne.adjustDestinationIndex(L,c),G=[[U,U+F.length-1]];v(_),h(G)}},[v,i,c,h]),p=C.useCallback(w=>{d(w)},[d]),O=C.useCallback(()=>{v([...i,{operation:u,selected:[],invert:!0}])},[i,u,v]),S=C.useCallback(w=>{v(i.filter((j,E)=>E!==w))},[i,v]),D=C.useCallback(w=>{h(w)},[h]),y=C.useCallback(w=>{var j=i[w];nr.isRollupOperation(j.operation)||a(j)},[i,a]),I=C.useCallback(w=>{g(w.target.value==="true")},[g]);C.useEffect(function(){l.length>0&&!l.includes(u)&&d(l[0])},[l,u]);var T=C.useCallback(w=>{var{item:j,itemIndex:E,isClone:L=!1,selectedCount:_}=w,F=j.operation,U=L?"".concat(_):void 0,G=L?"item-list-item-clone":void 0,B=nr.isRollupOperation(j.operation),ae=!L&&!B;return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:$("item-list-item-content","draggable-item-list-item-content",G),children:[o.jsxs("span",{className:"title",children:[F,!e&&B&&o.jsxs("span",{className:"small text-warning",children:[o.jsx(W,{icon:Ft})," Requires rollup"]})]}),ee.renderBadge({text:U}),ee.renderHandle()]}),!L&&o.jsxs(o.Fragment,{children:[o.jsx(N,{kind:"ghost",className:"btn-edit",icon:Jr,tooltip:"Edit Columns",onClick:()=>a(j),disabled:!ae}),o.jsx(N,{kind:"ghost",className:"btn-delete",icon:ye,tooltip:"Delete Aggregation",onClick:()=>S(E)})]})]})},[S,a,e]),A=l.length>0,x=i.length>0;return o.jsxs("div",{className:"aggregations",children:[A&&o.jsxs("div",{className:"form-inline",children:[o.jsx(Oe,{onChange:p,value:u,children:l.map(w=>o.jsx(ot,{value:w,children:w},w))}),o.jsxs("button",{type:"button",className:"btn btn-link btn-add",onClick:O,children:[o.jsx(W,{icon:ze}),"Add Aggregation"]})]}),A&&x&&o.jsx("hr",{}),x&&o.jsxs(o.Fragment,{children:[!e&&o.jsxs("div",{className:"form-inline",children:[o.jsx("label",{children:"Placement: "}),o.jsxs(Xe,{onChange:I,value:"".concat(s),children:[o.jsx(he,{value:"true",children:"Top"}),o.jsx(he,{value:"false",children:"Bottom"})]})]}),o.jsx(We,{onDragStart:f,onDragEnd:b,children:o.jsx(ee,{className:"selected-aggregations",itemCount:i.length,items:i,renderItem:T,offset:0,onSelectionChange:D,onSelect:y,selectedRanges:c,isMultiSelect:!0})})]})]})}function sr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function ie(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?sr(Object(r),!0).forEach(function(n){Dn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):sr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Dn(t,e,r){return e=Pn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Pn(t){var e=Nn(t,"string");return typeof e=="symbol"?e:String(e)}function Nn(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Q;(function(t){t[t.NONE=0]="NONE",t[t.ASCENDING=1]="ASCENDING",t[t.DESCENDING=2]="DESCENDING"})(Q||(Q={}));var Tn=30;function Ji(t){var{aggregation:e,columns:r,onChange:n}=t,[a,i]=C.useState(-1),[s,l]=C.useState(-1),[u,d]=C.useState(Q.NONE),{invert:c,selected:h}=e,m=C.useRef(null),v=C.useCallback(I=>h.includes(I)?!c:c,[c,h]),g=C.useMemo(()=>{var I=sn(r,e.operation);return u!==Q.NONE&&(I=V.sortColumns(I,u===Q.ASCENDING)),I},[r,e.operation,u]),f=C.useMemo(()=>a>=0?g.slice(a,s+1).map(I=>({value:I.name,displayValue:I.name,isSelected:v(I.name)})):[],[g,v,s,a]),b=C.useCallback(I=>{var{name:T}=g[I],A=h.indexOf(T),x=[...h],w=c;A>=0?x.splice(A,1):(x.push(T),x.length===g.length&&(x=[],w=!c)),n(ie(ie({},e),{},{selected:x,invert:w}))},[e,c,g,h,n]),p=C.useCallback(()=>{d(Q.NONE),n(ie(ie({},e),{},{selected:[],invert:!0}))},[e,n]),O=C.useCallback((I,T)=>{i(I),l(T)},[i,l]),S=C.useCallback(()=>{h.length===0?n(ie(ie({},e),{},{invert:!c})):n(ie(ie({},e),{},{selected:[],invert:!0}))},[e,c,n,h]),D=h.length===0?c:null,y=h.length!==0||!c||u!==Q.NONE;return o.jsxs("div",{role:"menu",className:"aggregation-edit",children:[o.jsx("div",{className:"top-menu",children:o.jsxs("div",{className:"form-inline",children:[o.jsx(ce,{checked:D,onChange:S,children:"Toggle All"}),o.jsx("div",{className:"spacer"}),o.jsx(vn,{in:y,timeout:K.transitionSlowMs,mountOnEnter:!0,unmountOnExit:!0,children:o.jsx(N,{kind:"ghost",className:"btn-reset",onClick:p,children:"Reset"})}),o.jsx(N,{kind:"ghost",className:$({active:u===Q.ASCENDING}),icon:Ve,tooltip:"Sort ascending",onClick:()=>d(Q.ASCENDING)}),o.jsx(N,{kind:"ghost",className:$({active:u===Q.DESCENDING}),icon:Ke,tooltip:"Sort descending",onClick:()=>d(Q.DESCENDING)})]})}),o.jsx("div",{className:"aggregation-edit-item-list",children:o.jsx(mn,{itemCount:g.length,items:f,offset:a,renderItem:I=>{var{item:T}=I;return o.jsx(ce,{checked:v(T.value),children:T.displayValue})},onSelect:b,onViewportChange:O,rowHeight:Tn,focusSelector:"input",ref:m})})]})}function lr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function dr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?lr(Object(r),!0).forEach(function(n){En(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):lr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function En(t,e,r){return e=Rn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Rn(t){var e=An(t,"string");return typeof e=="symbol"?e:String(e)}function An(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Mn(t){return o.jsx("svg",dr(dr({width:48,height:48,xmlns:"http://www.w3.org/2000/svg"},t),{},{children:o.jsxs("g",{fill:"none",fillRule:"evenodd",children:[o.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),o.jsx("path",{fill:"#7DA4FF",d:"M8 26h4v15H8zM15 17h4v24h-4zM22 21h4v20h-4zM29 17h4v24h-4zM36 11h4v30h-4z"})]})}))}function ur(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function cr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?ur(Object(r),!0).forEach(function(n){kn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ur(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function kn(t,e,r){return e=Fn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Fn(t){var e=_n(t,"string");return typeof e=="symbol"?e:String(e)}function _n(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ln(t){return o.jsx("svg",cr(cr({width:48,height:48,xmlns:"http://www.w3.org/2000/svg"},t),{},{children:o.jsxs("g",{fill:"none",fillRule:"evenodd",children:[o.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),o.jsx("path",{fill:"#7DA4FF",d:"M7 34h4v8H7zM12 31h4v11h-4zM17 27h4v15h-4zM22 22h4v20h-4zM27 27h4v15h-4zM32 29h4v13h-4zM37 31h4v11h-4z"})]})}))}function hr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function vr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?hr(Object(r),!0).forEach(function(n){Hn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):hr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Hn(t,e,r){return e=Gn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Gn(t){var e=Un(t,"string");return typeof e=="symbol"?e:String(e)}function Un(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function $n(t){return o.jsx("svg",vr(vr({width:48,height:48,xmlns:"http://www.w3.org/2000/svg"},t),{},{children:o.jsxs("g",{fill:"none",fillRule:"evenodd",children:[o.jsx("path",{fill:"#C1C0C0",d:"M4 4h1v40H4zM44 43v1H5v-1z"}),o.jsx("path",{stroke:"#7DA4FF",d:"M7.984 32.44l7.982-11.378 5.273 3.739 9.952-10.838 2.826 1.894 7.45-5.802"}),o.jsx("path",{stroke:"#BECDEF",d:"M8.244 37.926L17 33.496l5 .87 10.637-10.35 10.615-1.381"})]})}))}function mr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function gr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?mr(Object(r),!0).forEach(function(n){Bn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):mr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Bn(t,e,r){return e=Wn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Wn(t){var e=zn(t,"string");return typeof e=="symbol"?e:String(e)}function zn(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Vn(t){return o.jsx("svg",gr(gr({width:48,height:48,xmlns:"http://www.w3.org/2000/svg"},t),{},{children:o.jsxs("g",{fill:"none",fillRule:"evenodd",children:[o.jsx("path",{d:"M24 10c7.732 0 14 6.268 14 14s-6.268 14-14 14-14-6.268-14-14h14V10z",fill:"#80A6FF"}),o.jsx("path",{d:"M10 24c0-7.732 6.268-14 14-14v14H10z",fill:"#C1C0C0"})]})}))}function fr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function pr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?fr(Object(r),!0).forEach(function(n){Kn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):fr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Kn(t,e,r){return e=qn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qn(t){var e=Xn(t,"string");return typeof e=="symbol"?e:String(e)}function Xn(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Yn(t){return o.jsx("svg",pr(pr({width:48,height:48,xmlns:"http://www.w3.org/2000/svg"},t),{},{children:o.jsxs("g",{fill:"none",fillRule:"evenodd",children:[o.jsx("path",{fill:"#C1C0C0",d:"M44 43v1H4v-1z"}),o.jsx("path",{fill:"#939293",d:"M44 34v1H4v-1zM44 25v1H4v-1zM44 16v1H4v-1z"}),o.jsx("circle",{fill:"#7DA4FF",cx:9.5,cy:37.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:16.5,cy:30.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:22.5,cy:36.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:28.5,cy:30.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:15.5,cy:38.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:23.5,cy:25.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:19.5,cy:19.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:29.5,cy:19.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:32.5,cy:26.5,r:1.5}),o.jsx("circle",{fill:"#7DA4FF",cx:36.5,cy:13.5,r:1.5})]})}))}function br(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Cr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?br(Object(r),!0).forEach(function(n){Zn(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):br(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Zn(t,e,r){return e=Qn(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Qn(t){var e=Jn(t,"string");return typeof e=="symbol"?e:String(e)}function Jn(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function eo(t){return o.jsxs("svg",Cr(Cr({width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{},{children:[o.jsx("rect",{width:"48",height:"48",fill:"none"}),o.jsx("rect",{x:"26",y:"10",width:"15",height:"4",fill:"#9FDE70"}),o.jsx("rect",{x:"26",y:"22",width:"15",height:"4",fill:"#9FDE70"}),o.jsx("rect",{x:"26",y:"28",width:"15",height:"4",fill:"#FFD95C"}),o.jsx("rect",{x:"26",y:"34",width:"15",height:"4",fill:"#9FDE70"})]}))}function Sr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function wr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Sr(Object(r),!0).forEach(function(n){ea(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Sr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function ea(t,e,r){return e=ra(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ra(t){var e=ta(t,"string");return typeof e=="symbol"?e:String(e)}function ta(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ro(t){return o.jsxs("svg",wr(wr({width:"48",height:"48",viewBox:"0 0 48 48",fill:"none",xmlns:"http://www.w3.org/2000/svg"},t),{},{children:[o.jsx("rect",{width:"48",height:"48",fill:"none"}),o.jsx("rect",{x:"4",y:"16",width:"40",height:"4",fill:"#FFD95C"}),o.jsx("rect",{x:"4",y:"10",width:"40",height:"4",fill:"#78DCE8"}),o.jsx("rect",{x:"4",y:"34",width:"40",height:"4",fill:"#78DCE8"})]}))}var Or=be.module("ChartBuilder");class J extends C.PureComponent{static getMaxSeriesCount(e,r){switch(r){case e.plot.SeriesPlotStyle.PIE:return 1;case e.plot.SeriesPlotStyle.HISTOGRAM:return 0;default:return 100}}static makeSeriesItem(e){return{id:we.generate(),value:e}}static makeDefaultSeriesItems(e,r,n){var a=J.getMaxSeriesCount(e,r);if(a===0||n==null||n.length===0)return[];var i=n.length>1?n[1].name:n[0].name;return[J.makeSeriesItem(i)]}static getDefaultXAxis(e,r){return r!=null&&r.length>0?r[0].name:null}constructor(e){super(e),gn(this);var{model:r}=e,{columns:n,dh:a}=r,i=this.getTypes()[0],s=J.getDefaultXAxis(i,n),l=J.makeDefaultSeriesItems(a,i,n);this.state={type:i,seriesItems:l,xAxis:s,isLinked:!0}}getTypes(){var{model:e}=this.props,{dh:r}=e;return[r.plot.SeriesPlotStyle.LINE,r.plot.SeriesPlotStyle.BAR,r.plot.SeriesPlotStyle.SCATTER,r.plot.SeriesPlotStyle.PIE]}getTypeName(e){var{model:r}=this.props,{dh:n}=r;switch(e){case n.plot.SeriesPlotStyle.LINE:return"Line";case n.plot.SeriesPlotStyle.BAR:return"Bar";case n.plot.SeriesPlotStyle.SCATTER:return"Scatter";case n.plot.SeriesPlotStyle.PIE:return"Pie";case n.plot.SeriesPlotStyle.HISTOGRAM:return"Histogram";default:return e}}getTypeIcon(e){var{model:r}=this.props,{dh:n}=r;switch(e){case n.plot.SeriesPlotStyle.LINE:return o.jsx($n,{});case n.plot.SeriesPlotStyle.BAR:return o.jsx(Mn,{});case n.plot.SeriesPlotStyle.SCATTER:return o.jsx(Yn,{});case n.plot.SeriesPlotStyle.PIE:return o.jsx(Vn,{});case n.plot.SeriesPlotStyle.HISTOGRAM:return o.jsx(Ln,{});default:return null}}getXAxisLabel(e){var{model:r}=this.props,{dh:n}=r;switch(e){case n.plot.SeriesPlotStyle.PIE:return"Labels";case n.plot.SeriesPlotStyle.HISTOGRAM:return"Data";default:return"X-Axis"}}getSeriesLabel(e){var{model:r}=this.props,{dh:n}=r;switch(e){case n.plot.SeriesPlotStyle.PIE:return"Values";default:return"Series"}}handleAddSeries(){this.setState(e=>{var{seriesItems:r}=e,n=[...r],{model:a}=this.props,{columns:i}=a;return n.push({id:we.generate(),value:i[0].name}),{seriesItems:n}},this.sendChange)}handleLinkStateChange(e){this.setState({isLinked:e.target.value==="true"},this.sendChange)}handleReset(){var{model:e}=this.props,{columns:r,dh:n}=e,a=this.getTypes()[0],i=J.getDefaultXAxis(a,r),s=J.makeDefaultSeriesItems(n,a,r),l=!0;this.setState({type:a,seriesItems:s,xAxis:i,isLinked:l},this.sendChange)}handleSeriesChange(e,r){var n=e;this.setState(a=>{var{seriesItems:i}=a;return i=[...i],i[r].value=n,{seriesItems:i}},this.sendChange)}handleSeriesDeleteClick(e){this.setState(r=>{var{seriesItems:n}=r,a=[...n];return a.splice(e,1),{seriesItems:a}},this.sendChange)}handleSubmit(e){e.preventDefault();var{onSubmit:r}=this.props,{type:n,seriesItems:a,xAxis:i,isLinked:s}=this.state,l=a.map(u=>u.value);r({type:n,series:l,xAxis:i,isLinked:s})}handleTypeClick(e){var r=this.getTypes()[e];Or.debug2("handleTypeSelect",r),this.setState(n=>{var{model:a}=this.props,{dh:i}=a,s=J.getMaxSeriesCount(i,r),{seriesItems:l}=n;if(l=l.slice(0,s),l.length===0&&s>0){var{columns:u}=a;l=J.makeDefaultSeriesItems(i,r,u)}return{type:r,seriesItems:l}},this.sendChange)}handleXAxisChange(e){var r=e;Or.debug2("x-axis change",r),this.setState({xAxis:r},this.sendChange)}sendChange(){var{onChange:e}=this.props,{isLinked:r,type:n,seriesItems:a,xAxis:i}=this.state,s=a.map(l=>l.value);e({type:n,series:s,xAxis:i,isLinked:r})}render(){var{model:e}=this.props,{columns:r,dh:n}=e,{seriesItems:a,type:i,xAxis:s,isLinked:l}=this.state,u=J.getMaxSeriesCount(n,i),d=this.getXAxisLabel(i),c=this.getSeriesLabel(i),h=a.length>0,m=a.length<u;return o.jsx("div",{className:"chart-builder",children:o.jsxs("form",{onSubmit:this.handleSubmit,children:[o.jsxs("div",{className:"form-row",children:[o.jsx("label",{children:"Select Chart Type"}),o.jsx("div",{className:"form-row",children:this.getTypes().map((v,g)=>{var f=v;return o.jsx("div",{className:"col col-chart-type",children:o.jsxs("button",{type:"button",className:$("btn","btn-icon","btn-chart-type",{active:v===i}),onClick:()=>this.handleTypeClick(g),children:[this.getTypeIcon(v),this.getTypeName(v)]})},f)})})]}),o.jsx("hr",{}),o.jsxs("div",{className:"form-row form-inline",children:[o.jsx("label",{className:"col-2 label-left",children:d}),o.jsx(Oe,{className:"form-control select-x-axis col",value:s,onChange:this.handleXAxisChange,children:r.map(v=>o.jsx("option",{value:v.name,children:v.name},v.name))})]}),h&&o.jsx("hr",{}),a.map((v,g)=>o.jsxs("div",{className:"form-row form-inline form-series-item","data-testid":"form-series-item-".concat(g),children:[o.jsx("label",{className:"col-2 label-left",children:g===0?c:""}),o.jsx(Oe,{className:"form-control select-series col",value:v.value,onChange:f=>this.handleSeriesChange(f,g),"data-testid":"select-series-item-".concat(g),children:r.map(f=>o.jsx("option",{value:f.name,children:f.name},f.name))}),a.length>1&&o.jsx(N,{kind:"ghost",className:"btn-delete-series ml-2 px-2","data-testid":"delete-series-".concat(g),onClick:()=>{this.handleSeriesDeleteClick(g)},icon:ye,tooltip:"Delete"})]},v.id)),m&&o.jsxs("div",{className:"form-row",children:[o.jsx("div",{className:"col-2"}),o.jsx(N,{kind:"ghost",className:"btn-add-series mt-1",onClick:this.handleAddSeries,icon:ze,children:"Add Series"})]}),o.jsxs("div",{className:"form-row chart-builder-link",children:[o.jsx("label",{className:"col-2 label-right",children:o.jsxs("div",{className:"fa-md fa-layers",children:[o.jsx(W,{mask:_t,icon:et,transform:"right-5 down-5"}),o.jsx(W,{icon:l?Lt:Ht,transform:"grow-2 right-8 down-6"})]})}),o.jsxs(Xe,{onChange:this.handleLinkStateChange,value:"".concat(l),children:[o.jsx(he,{value:"true",children:"Sync State"}),o.jsx(he,{value:"false",children:"Freeze State"})]})]}),o.jsxs("div",{className:"form-row",children:[o.jsx("div",{className:"col-2 label-right"}),o.jsx("div",{className:"col chart-builder-link-info",children:l?"Charts with synced state will update to match any filters or user modifications applied to the parent table.":"Freeze State disconnects the chart state from the parent table. New filters or user modifications on the parent table will not be applied."})]}),o.jsxs("div",{className:$("form-row","justify-content-end","my-3"),children:[o.jsx(N,{kind:"secondary",className:"btn-reset",onClick:this.handleReset,children:"Reset"}),o.jsx(N,{kind:"primary",type:"submit",className:"btn-submit",children:"Create"})]})]})})}}const to=J;function yr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function na(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?yr(Object(r),!0).forEach(function(n){Re(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):yr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Re(t,e,r){return e=aa(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function aa(t){var e=ia(t,"string");return typeof e=="symbol"?e:String(e)}function ia(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class ut extends C.Component{constructor(e){super(e),Re(this,"editorContainer",void 0),Re(this,"editor",void 0),this.handleContentChanged=this.handleContentChanged.bind(this),this.handleEditorFocus=this.handleEditorFocus.bind(this),this.handleEditorBlur=this.handleEditorBlur.bind(this),this.handleContainerClick=this.handleContainerClick.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.state={isEditorFocused:!1,isEditorEmpty:!0},this.editorContainer=null}componentDidMount(){this.initEditor()}componentWillUnmount(){this.destroyEditor()}initEditor(){var e,{value:r,editorSettings:n}=this.props,a=na({copyWithSyntaxHighlighting:"false",fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"groovyDB",lineDecorationsWidth:8,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},scrollBeyondLastLine:!1,padding:{top:6,bottom:6},tabCompletion:"off",useTabStops:!0,value:r,wordWrap:"on",automaticLayout:!0,autoClosingBrackets:"beforeWhitespace"},n);if(!this.editorContainer)throw new Error("editorContainer is null");this.editor=On.create(this.editorContainer,a),this.editor.layout(),(e=this.editor.getModel())===null||e===void 0||e.updateOptions({tabSize:0}),this.editor.onKeyDown(this.handleKeyDown),this.editor.onDidChangeModelContent(this.handleContentChanged),this.editor.onDidFocusEditorText(this.handleEditorFocus),this.editor.onDidBlurEditorText(this.handleEditorBlur)}destroyEditor(){var e;(e=this.editor)===null||e===void 0||e.dispose(),this.editor=void 0}handleContentChanged(){var e,r,{onContentChanged:n}=this.props,a=(e=this.editor)===null||e===void 0||(r=e.getModel())===null||r===void 0?void 0:r.getValue();a!==void 0&&this.setState({isEditorEmpty:a.length===0}),n(a)}handleEditorFocus(){this.setState({isEditorFocused:!0})}handleEditorBlur(){var e,r,n,a=(e=(r=this.editor)===null||r===void 0||(n=r.getModel())===null||n===void 0?void 0:n.getValue())!==null&&e!==void 0?e:"";this.setState({isEditorEmpty:a.length===0,isEditorFocused:!1})}handleContainerClick(){var e,{isEditorFocused:r}=this.state;r||(e=this.editor)===null||e===void 0||e.focus()}handleKeyDown(e){var{onTab:r,editorIndex:n}=this.props;e.code==="Tab"&&(e.stopPropagation(),e.preventDefault(),r(n,e.shiftKey))}render(){var{className:e,invalid:r,placeholder:n="",value:a}=this.props,{isEditorFocused:i,isEditorEmpty:s}=this.state;return o.jsxs("div",{className:$("input-editor-wrapper",{focused:i,invalid:r},e),role:"presentation",onClick:this.handleContainerClick,children:[o.jsx("div",{className:"editor-container",ref:l=>{this.editorContainer=l},"data-testid":"custom-column-formula"}),s&&!a&&n.length>0&&o.jsx("div",{className:"editor-placeholder text-muted",children:n})]})}}Re(ut,"defaultProps",{value:"",onContentChanged:()=>{},editorSettings:{},editorIndex:0,onTab:()=>{},invalid:!1});function xr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function xe(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?xr(Object(r),!0).forEach(function(n){oa(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):xr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function oa(t,e,r){return e=sa(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function sa(t){var e=la(t,"string");return typeof e=="symbol"?e:String(e)}function la(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Ir=Object.freeze({NAME:"name",FORMULA:"formula"}),da=()=>{};function ua(t){var{eventKey:e,name:r,inputIndex:n,formula:a,onChange:i,onDeleteColumn:s,onTabInEditor:l,invalid:u,isDuplicate:d}=t,c=r===""||qe.isValidColumnName(r),h=C.useCallback(m=>{m!==void 0&&(m.replace(/(\r\n|\n|\r)/gm,""),i(e,Ir.FORMULA,m))},[i,e]);return o.jsx(Ct,{draggableId:e,index:n,disableInteractiveElementBlocking:!0,children:(m,v)=>o.jsxs("div",xe(xe({className:$("draggable-container",{dragging:v.isDragging}),ref:m.innerRef},m.draggableProps),{},{children:[o.jsxs("div",{className:"custom-column-input-container",children:[o.jsxs("div",{className:"pb-3",children:[o.jsxs("div",{className:"d-flex flex-row custom-column-name",children:[o.jsx("input",{className:$("form-control custom-column-input",{"is-invalid":u||!c||d}),placeholder:"Column Name",value:r,onChange:g=>{i(e,Ir.NAME,g.target.value)}}),o.jsx(N,{kind:"ghost",className:"ml-1 px-2",onClick:()=>{s(e)},icon:ye,tooltip:"Delete custom column"}),o.jsx(N,xe(xe({kind:"ghost",className:"btn-drag-handle",onClick:da},m.dragHandleProps),{},{icon:rt,tooltip:"Drag column to re-order"}))]}),(!c||d)&&o.jsx("p",{className:"validate-label-error text-danger mb-0 mt-2 pl-1",children:c?"Duplicate name":"Invalid name"})]}),o.jsx(ut,{editorSettings:{language:"deephavenDb"},editorIndex:n,placeholder:"Column Formula",value:a,onContentChanged:h,onTab:l,invalid:u})]}),o.jsx("hr",{})]}))})}function jr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function ke(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?jr(Object(r),!0).forEach(function(n){pe(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):jr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function pe(t,e,r){return e=ca(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ca(t){var e=ha(t,"string");return typeof e=="symbol"?e:String(e)}function ha(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class le extends C.Component{static makeCustomColumnInputEventKey(){return we.generate()}static createCustomColumnInput(){return{eventKey:we.generate(),name:"",formula:""}}constructor(e){super(e),pe(this,"container",void 0),pe(this,"successButtonTimer",void 0),pe(this,"getInput",Qe((r,n)=>r.find(a=>a.eventKey===n))),pe(this,"getInputIndex",Qe((r,n)=>r.findIndex(a=>a.eventKey===n))),this.handleAddColumnClick=this.handleAddColumnClick.bind(this),this.handleSaveClick=this.handleSaveClick.bind(this),this.handleInputChange=this.handleInputChange.bind(this),this.handleDeleteColumn=this.handleDeleteColumn.bind(this),this.handleCustomColumnUpdated=this.handleCustomColumnUpdated.bind(this),this.handleRequestFailed=this.handleRequestFailed.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.resetRequestFailed=this.resetRequestFailed.bind(this),this.handleEditorTabNavigation=this.handleEditorTabNavigation.bind(this),this.state={inputs:[],isCustomColumnApplying:!1,errorMessage:null,hasRequestFailed:!1,isSuccessShowing:!1},this.container=null,this.successButtonTimer=null}componentDidMount(){var{customColumns:e}=this.props;this.parseCustomColumns(e),this.startListening()}componentWillUnmount(){this.stopListening(),this.successButtonTimer&&clearTimeout(this.successButtonTimer)}resetErrorMessage(){this.setState({errorMessage:null})}startListening(){var{model:e}=this.props;e.addEventListener(me.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.addEventListener(me.EVENT.UPDATED,this.handleCustomColumnUpdated),e.addEventListener(me.EVENT.REQUEST_FAILED,this.handleRequestFailed)}stopListening(){var{model:e}=this.props;e.removeEventListener(me.EVENT.COLUMNS_CHANGED,this.handleCustomColumnUpdated),e.removeEventListener(me.EVENT.UPDATED,this.handleCustomColumnUpdated),e.removeEventListener(me.EVENT.REQUEST_FAILED,this.handleRequestFailed)}parseCustomColumns(e){if(e.length>0){var r=e.map(n=>{var a=n.split(/=(.+)/,2);return{eventKey:le.makeCustomColumnInputEventKey(),name:a[0],formula:a[1]}});this.setState({inputs:r})}else this.setState({inputs:[le.createCustomColumnInput()]})}handleAddColumnClick(){var{inputs:e}=this.state,r=[...e];r.push(le.createCustomColumnInput()),this.setState({inputs:r})}handleDeleteColumn(e){var{inputs:r}=this.state,n=this.getInputIndex(r,e),a=[...r];a.splice(n,1),a.length===0&&a.push(le.createCustomColumnInput()),this.setState({inputs:a})}handleInputChange(e,r,n){var{inputs:a}=this.state,i=this.getInputIndex(a,e),s=this.getInput(a,e),l=ke({},s);l[r]=n;var u=[...a];u.splice(i,1,l),this.setState({inputs:u})}handleCustomColumnUpdated(){var{isCustomColumnApplying:e}=this.state;e&&this.setState({isCustomColumnApplying:!1,isSuccessShowing:!0},()=>{this.successButtonTimer=setTimeout(()=>this.setState({isSuccessShowing:!1}),le.SUCCESS_SHOW_DURATION)})}handleRequestFailed(e){var r=e,{isCustomColumnApplying:n}=this.state;n&&this.setState({isCustomColumnApplying:!1,errorMessage:o.jsxs(o.Fragment,{children:[o.jsxs("p",{children:[o.jsx(W,{icon:Ee})," Failed to apply custom columns."]}),o.jsxs("div",{className:"error-box",children:[r.detail.errorMessage,o.jsx("br",{}),"Table configuration:"," ",JSON.stringify(r.detail.configuration)]})]}),hasRequestFailed:!0})}handleDragEnd(e){if(ne.stopDragging(),!!e.destination){var{inputs:r}=this.state,n=e.source.index,a=e.destination.index,i=[...r],s=r[n];i.splice(n,1),i.splice(a,0,s),this.setState({inputs:i})}}handleEditorTabNavigation(e,r){var{inputs:n}=this.state;if(r){var a;((a=this.container)===null||a===void 0?void 0:a.querySelectorAll(".btn-drag-handle")[e]).focus();return}if(e===n.length-1){var i,s;(i=this.container)===null||i===void 0||(s=i.querySelector(".btn-add-column"))===null||s===void 0||s.focus()}else{var l,u=e+1;((l=this.container)===null||l===void 0?void 0:l.querySelectorAll(".custom-column-input")[u]).focus()}}handleSaveClick(){var{onSave:e,customColumns:r}=this.props,{inputs:n,isCustomColumnApplying:a}=this.state;if(!a){var i=[];n.forEach(s=>{var{name:l,formula:u}=s;l&&u&&i.push("".concat(l,"=").concat(u))}),this.resetErrorMessage(),this.setState({isCustomColumnApplying:i.length>0||r.length>0}),e(i)}}resetRequestFailed(){this.setState(e=>{var{hasRequestFailed:r}=e;return r?{hasRequestFailed:!1}:null})}renderInputs(){var{inputs:e,hasRequestFailed:r}=this.state,n=new Map;return e.forEach(a=>{var i,{name:s}=a;return n.set(s,((i=n.get(s))!==null&&i!==void 0?i:0)+1)}),e.map((a,i)=>{var s,{eventKey:l,name:u,formula:d}=a,c=((s=n.get(u))!==null&&s!==void 0?s:0)>1;return o.jsx(ua,{inputIndex:i,eventKey:l,name:u,formula:d,onChange:this.handleInputChange,onDeleteColumn:this.handleDeleteColumn,onTabInEditor:this.handleEditorTabNavigation,invalid:r,isDuplicate:c},l)})}renderSaveButton(){var{inputs:e,isCustomColumnApplying:r,isSuccessShowing:n}=this.state,a=e.length>1?"Save Columns":"Save Column",i=e.every(u=>{var{name:d}=u;return d===""||qe.isValidColumnName(d)}),s=e.filter(u=>{var{name:d}=u;return d!==""}).map(u=>{var{name:d}=u;return d}),l=new Set(s).size===s.length;return o.jsxs(N,{kind:n?"success":"primary",className:$("btn-apply",{"btn-spinner":r}),disabled:n||r||!i||!l,onClick:this.handleSaveClick,icon:n?Gt:void 0,children:[r&&o.jsxs("span",{children:[o.jsx(tt,{className:"mr-2 loading-spinner-vertical-align"}),o.jsx("span",{className:"btn-normal-content",children:"Applying"})]}),!n&&!r&&a,n&&"Success"]})}render(){var{onCancel:e}=this.props,{errorMessage:r}=this.state;return o.jsxs("div",{role:"presentation",className:"custom-column-builder-container",ref:n=>{this.container=n},onClick:this.resetRequestFailed,onFocus:this.resetRequestFailed,children:[o.jsx("hr",{}),o.jsx(We,{onDragStart:ne.startDragging,onDragEnd:this.handleDragEnd,children:o.jsx(Zr,{droppableId:"droppable-custom-columns",children:(n,a)=>o.jsxs("div",ke(ke({ref:n.innerRef},n.droppableProps),{},{className:$("droppable-container",{dragging:a.draggingFromThisWith}),children:[this.renderInputs(),n.placeholder]}))})}),o.jsx("div",{className:"pt-1 px-3",children:o.jsx(N,{kind:"ghost",className:"btn-add-column",onClick:this.handleAddColumnClick,icon:ze,children:"Add Another Column"})}),o.jsxs("div",{className:"custom-column-builder-footer",children:[r&&o.jsx("div",{className:"error-message",children:r}),o.jsxs("div",{className:"d-flex justify-content-end",children:[o.jsx(N,{kind:"secondary",className:"mr-2",onClick:e,children:"Cancel"}),this.renderSaveButton()]})]})]})}}pe(le,"SUCCESS_SHOW_DURATION",750);const no=le;var Ge;(function(t){t.ADVANCED_SETTINGS="ADVANCED_SETTINGS",t.AGGREGATIONS="AGGREGATIONS",t.AGGREGATION_EDIT="AGGREGATIONS_EDIT",t.CHART_BUILDER="CHART_BUILDER",t.CUSTOM_COLUMN_BUILDER="CUSTOM_COLUMN_BUILDER",t.QUICK_FILTERS="QUICK_FILTERS",t.ROLLUP_ROWS="ROLLUP_ROWS",t.SEARCH_BAR="SEARCH_BAR",t.SELECT_DISTINCT="SELECT_DISTINCT",t.TABLE_EXPORTER="TABLE_EXPORTER",t.VISIBILITY_ORDERING_BUILDER="VISIBILITY_ORDERING_BUILDER",t.CONDITIONAL_FORMATTING="CONDITIONAL_FORMATTING",t.CONDITIONAL_FORMATTING_EDIT="CONDITIONAL_FORMATTING_EDIT",t.GOTO="GOTO"})(Ge||(Ge={}));const ao=Ge;function Dr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Pr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Dr(Object(r),!0).forEach(function(n){de(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Dr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function de(t,e,r){return e=va(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function va(t){var e=ma(t,"string");return typeof e=="symbol"?e:String(e)}function ma(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Ce=be.module("RollupRows"),ga=150,Ie="grouped-rollup-rows",je="ungrouped-rollup-rows";class z extends C.Component{static renderColumn(e){var{item:r,isClone:n,selectedCount:a}=e,i=r?.name,s=n!==void 0&&n?"".concat(a):void 0,l=n!==void 0&&n?"item-list-item-clone":"";return ee.renderTextItem({text:i,badgeText:s,className:l})}static addGroupings(e,r){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:e.length;if(r==null||r.length===0)return e;var a=n,i=e.filter((s,l)=>r.includes(s)?(l<a&&(a-=1),!1):!0);return i.splice(a,0,...r),i}static isGroupable(e){return!V.isDecimalType(e.type)}constructor(e){super(e),de(this,"ungroupedList",void 0),de(this,"groupedList",void 0),de(this,"search",Qr(s=>{for(var l=this.getSortedUngroupedColumns(),u=[],d=null,c=0;c<l.length;c+=1){var h=l[c];h.name.toLowerCase().includes(s.toLowerCase())&&(d==null&&(d=c),u.push([c,c]))}k(d),this.setState({ungroupedSelectedRanges:u}),u.length>0&&this.ungroupedList.current&&this.ungroupedList.current.scrollToItem(d)},ga)),de(this,"getCachedUngroupedColumns",oe((s,l)=>s.filter(u=>z.isGroupable(u)&&l.find(d=>d===u.name)==null))),de(this,"getCachedSortedColumns",oe((s,l)=>l==null?[...s]:V.sortColumns(s,l===z.SORT.ASCENDING))),this.handleDeleteClicked=this.handleDeleteClicked.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleUngroupedSelect=this.handleUngroupedSelect.bind(this),this.handleUngroupedSelectionChange=this.handleUngroupedSelectionChange.bind(this),this.handleDragStart=this.handleDragStart.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleGroupedSelectionChange=this.handleGroupedSelectionChange.bind(this),this.handleShowConstituentsChange=this.handleShowConstituentsChange.bind(this),this.handleShowNonAggregatedColumnsChange=this.handleShowNonAggregatedColumnsChange.bind(this),this.handleSortAscending=this.handleSortAscending.bind(this),this.handleSortDescending=this.handleSortDescending.bind(this),this.renderGroupedItem=this.renderGroupedItem.bind(this),this.ungroupedList=Je.createRef(),this.groupedList=Je.createRef();var{config:r}=e,{columns:n=[],showConstituents:a=!0,showNonAggregatedColumns:i=!0}=r??{};this.state={ungroupedSelectedRanges:[],columns:n,groupedSelectedRanges:[],searchFilter:"",showConstituents:a,showNonAggregatedColumns:i,dragSource:null,sort:null}}componentDidUpdate(e,r){var{config:n}=this.props,{columns:a,showConstituents:i,showNonAggregatedColumns:s}=this.state;n!==e.config?this.updateFromConfig():(a!==r.columns||i!==r.showConstituents||s!==r.showNonAggregatedColumns)&&(n==null||a!==n.columns||i!==n.showConstituents||s!==n.showNonAggregatedColumns)&&this.sendChange()}componentWillUnmount(){this.search.cancel()}handleSearchChange(e){var r=e.target.value;if(this.setState({searchFilter:r}),!r){this.search.cancel(),this.resetSelection();return}this.search(r)}handleSortAscending(){this.setState(e=>{var{sort:r}=e;return{sort:r===z.SORT.ASCENDING?null:z.SORT.ASCENDING}})}handleSortDescending(){this.setState(e=>{var{sort:r}=e;return{sort:r===z.SORT.DESCENDING?null:z.SORT.DESCENDING}})}resetSelection(){this.setState({ungroupedSelectedRanges:[],groupedSelectedRanges:[]})}handleDragStart(e){Ce.debug("handleDragStart",e),document.documentElement.classList.add("drag-pointer-events-none"),this.setState({dragSource:e.source})}handleDragEnd(e){Ce.debug("handleDragEnd",e),document.documentElement.classList.remove("drag-pointer-events-none"),this.setState({dragSource:null});var{destination:r,source:n}=e;if(!(r==null||n==null)){if(r.droppableId===je){this.setState(s=>{var{groupedSelectedRanges:l,columns:u}=s,d=[...u];return ne.reorder(d,l,[],0),{columns:d,ungroupedSelectedRanges:[],groupedSelectedRanges:[]}});return}var a=n.droppableId===Ie,i=r.index;a&&n.index<r.index&&(i+=1),this.setState(s=>{var{columns:l,ungroupedSelectedRanges:u,groupedSelectedRanges:d}=s,c=[...l],h=a?c:this.getSortedUngroupedColumns().map(b=>b.name),m=a?d:u,v=ne.reorder(h,m,c,i),g=a?ne.adjustDestinationIndex(i,d):i,f=[[g,g+v.length-1]];return{columns:c,ungroupedSelectedRanges:[],groupedSelectedRanges:f}}),this.resetSelection()}}handleUngroupedSelect(e){Ce.debug("handleUngroupedSelect"),this.setState(r=>{var{columns:n}=r;return{columns:z.addGroupings(n,[this.getSortedUngroupedColumns()[e].name]),ungroupedSelectedRanges:[],groupedSelectedRanges:[]}})}handleUngroupedSelectionChange(e){Ce.debug2("handleUngroupedSelectionChange",e),this.setState(r=>{var{ungroupedSelectedRanges:n}=r;return e===n?null:{ungroupedSelectedRanges:e,groupedSelectedRanges:[]}})}handleGroupedSelectionChange(e){Ce.debug2("handleGroupedSelectedRanges",e),this.setState(r=>{var{groupedSelectedRanges:n}=r;return e===n?null:{groupedSelectedRanges:e,ungroupedSelectedRanges:[]}})}handleDeleteClicked(e){this.setState(r=>{var{columns:n}=r,a=n.slice();return a.splice(e,1),{columns:a}})}handleShowConstituentsChange(){this.setState(e=>{var{showConstituents:r}=e;return{showConstituents:!r}})}handleShowNonAggregatedColumnsChange(){this.setState(e=>{var{showNonAggregatedColumns:r}=e;return{showNonAggregatedColumns:!r}})}updateFromConfig(){var{config:e}=this.props,{columns:r=[],showConstituents:n=!0,showNonAggregatedColumns:a=!0}=e??{};this.setState({columns:r,showConstituents:n,showNonAggregatedColumns:a})}sendChange(){var{onChange:e}=this.props,{columns:r,showConstituents:n,showNonAggregatedColumns:a}=this.state;e({columns:r,showConstituents:n,showNonAggregatedColumns:a})}getUngroupedColumns(){var{model:e}=this.props,{columns:r}=this.state,{originalColumns:n}=e;return this.getCachedUngroupedColumns(n,r)}getSortedUngroupedColumns(){var{sort:e}=this.state,r=this.getUngroupedColumns();return this.getCachedSortedColumns(r,e)}renderGroupedItem(e){var{item:r,itemIndex:n,isClone:a,selectedCount:i}=e,s=a!==void 0&&a?"":"  ".repeat(n),l="".concat(s).concat(r),u=a!==void 0&&a?"".concat(i):void 0,d=a!==void 0&&a?"item-list-item-clone":"";return o.jsxs(o.Fragment,{children:[ee.renderTextItem({text:l,badgeText:u,className:d}),(a===void 0||!a)&&o.jsx(N,{kind:"ghost",className:"btn btn-link btn-link-icon btn-delete-grouping float-right",onClick:()=>this.handleDeleteClicked(n),children:o.jsx(W,{icon:ye})})]})}render(){var{columns:e,dragSource:r,searchFilter:n,groupedSelectedRanges:a,ungroupedSelectedRanges:i,showConstituents:s,showNonAggregatedColumns:l,sort:u}=this.state,d=this.getSortedUngroupedColumns(),c=e.length*ee.DEFAULT_ROW_HEIGHT;r?.droppableId===je&&(c+=ee.DEFAULT_ROW_HEIGHT);var h=d.length*ee.DEFAULT_ROW_HEIGHT+10,m=Math.min(3*ee.DEFAULT_ROW_HEIGHT,h);return o.jsx("div",{role:"menu",className:$("rollup-rows",{"is-dragging":r!=null}),tabIndex:0,children:o.jsxs(We,{onDragEnd:this.handleDragEnd,onDragStart:this.handleDragStart,children:[o.jsxs("div",{className:"rollup-rows-group-by",children:[o.jsx("div",{className:"section-title",children:"Group By"}),e.length===0&&o.jsx(Zr,{droppableId:"placeholder",children:(v,g)=>o.jsx("div",Pr(Pr({className:$("placeholder","text-muted",{"is-dragging-from-this":g.draggingFromThisWith,"is-dragging-over":g.isDraggingOver,"is-dropping":g.draggingOverWith}),ref:v.innerRef},v.droppableProps),{},{children:"To create a rollup, drag columns from the list below and drop them into this area."}))}),e.length>0&&o.jsx(ee,{draggingItemClassName:"rollup-rows-dragging-grouped-item",draggablePrefix:Ie,droppableId:Ie,itemCount:e.length,items:e,offset:0,onSelectionChange:this.handleGroupedSelectionChange,ref:this.groupedList,renderItem:this.renderGroupedItem,selectedRanges:a,style:{height:c},isMultiSelect:!0})]}),o.jsxs("div",{className:"rollup-rows-available-columns",children:[o.jsx("div",{className:"section-title",children:"Available Grouping Columns"}),o.jsxs("div",{className:"top-menu",children:[o.jsx(lt,{className:"w-100",value:n,matchCount:n?i.length:void 0,placeholder:"Find column...",onChange:this.handleSearchChange}),o.jsxs(N,{kind:"ghost",className:$("btn-link btn-link-icon",{active:u===z.SORT.ASCENDING}),onClick:this.handleSortAscending,children:[o.jsx(W,{icon:Ve}),o.jsx(He,{children:"Sort ascending"})]}),o.jsxs(N,{kind:"ghost",className:$("btn-link btn-link-icon",{active:u===z.SORT.DESCENDING}),onClick:this.handleSortDescending,children:[o.jsx(W,{icon:Ke}),o.jsx(He,{children:"Sort descending"})]})]}),o.jsx(ee,{className:"rollup-available-grouping-columns",draggablePrefix:je,droppableId:je,itemCount:d.length,items:d,renderItem:z.renderColumn,offset:0,onSelect:this.handleUngroupedSelect,onSelectionChange:this.handleUngroupedSelectionChange,ref:this.ungroupedList,selectedRanges:i,style:{maxHeight:h,minHeight:m},isDropDisabled:r?.droppableId!==Ie,isMultiSelect:!0}),o.jsxs("div",{className:"bottom-menu",children:[o.jsx("div",{className:"label",children:"Show:"}),o.jsx(ce,{checked:s,onChange:this.handleShowConstituentsChange,children:"Constituents"}),o.jsx(ce,{checked:l,onChange:this.handleShowNonAggregatedColumnsChange,children:"Non-Aggregated Columns"})]})]})]})})}}de(z,"SORT",Object.freeze({ASCENDING:"ASC",DESCENDING:"DESC"}));de(z,"defaultProps",{config:null,onChange:()=>{}});const io=z;function Nr(t,e,r,n,a,i,s){try{var l=t[i](s),u=l.value}catch(d){r(d);return}l.done?e(u):Promise.resolve(u).then(n,a)}function fa(t){return function(){var e=this,r=arguments;return new Promise(function(n,a){var i=t.apply(e,r);function s(u){Nr(i,n,a,s,l,"next",u)}function l(u){Nr(i,n,a,s,l,"throw",u)}s(void 0)})}}function Tr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Er(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Tr(Object(r),!0).forEach(function(n){ve(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Tr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function ve(t,e,r){return e=pa(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function pa(t){var e=ba(t,"string");return typeof e=="symbol"?e:String(e)}function ba(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Ca=be.module("TableCsvExporter");class P extends C.Component{static getDateString(e){return e.i18n.DateTimeFormat.format(P.FILENAME_DATE_FORMAT,new Date)}constructor(e){super(e),this.handleDownloadClick=this.handleDownloadClick.bind(this),this.handleDownloadRowOptionChanged=this.handleDownloadRowOptionChanged.bind(this),this.handleCustomizedDownloadRowOptionChanged=this.handleCustomizedDownloadRowOptionChanged.bind(this),this.handleCustomizedDownloadRowsChanged=this.handleCustomizedDownloadRowsChanged.bind(this),this.handleIncludeColumnHeadersChanged=this.handleIncludeColumnHeadersChanged.bind(this),this.handleIncludeHiddenColumnsChanged=this.handleIncludeHiddenColumnsChanged.bind(this),this.handleUseUnformattedValuesChanged=this.handleUseUnformattedValuesChanged.bind(this);var{model:r,name:n}=e;this.state={fileName:"".concat(n,"-").concat(P.getDateString(r.dh),".csv"),downloadRowOption:P.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,customizedDownloadRowOption:P.CUSTOMIZED_ROWS_OPTIONS.FIRST,customizedDownloadRows:P.DEFAULT_DOWNLOAD_ROWS,includeColumnHeaders:!0,includeHiddenColumns:!1,useUnformattedValues:!1,errorMessage:null,id:we.generate()}}getSnapshotRanges(){var{model:e,selectedRanges:r}=this.props,{downloadRowOption:n,customizedDownloadRowOption:a,customizedDownloadRows:i}=this.state,{rowCount:s,columnCount:l}=e,u=[];switch(n){case P.DOWNLOAD_ROW_OPTIONS.ALL_ROWS:u.push(new ge(0,0,l-1,s-1));break;case P.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS:u=r.map(d=>Er(Er({},d),{},{startColumn:0,endColumn:l-1})).sort((d,c)=>d.startRow!=null&&c.startRow!=null?d.startRow-c.startRow:0);break;case P.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS:switch(a){case P.CUSTOMIZED_ROWS_OPTIONS.FIRST:u.push(new ge(0,0,l-1,Math.min(i-1,s-1)));break;case P.CUSTOMIZED_ROWS_OPTIONS.LAST:u.push(new ge(0,Math.max(0,s-i),l-1,s-1));break}break}return u}getModelRanges(e){var{userColumnWidths:r,movedColumns:n}=this.props,{includeHiddenColumns:a}=this.state,i=it.getHiddenColumns(r),s=M.getModelRanges(e,n);if(!a&&i.length>0){var l=i.map(ge.makeColumn);s=ge.subtractRangesFromRanges(s,l)}return s}resetDownloadState(){this.setState({errorMessage:null})}handleDownloadClick(){var e=this;return fa(function*(){var{model:r,isDownloading:n,onDownloadStart:a,onDownload:i,onCancel:s}=e.props,{fileName:l,includeColumnHeaders:u,useUnformattedValues:d}=e.state;if(n){s();return}e.resetDownloadState();var c=e.getSnapshotRanges(),h=e.getModelRanges(c);if(e.validateOptionInput()){a();try{var m=yield r.export(),v=m.setViewport(0,0);yield v.getViewportData(),i(l,m,v,c,h,u,d)}catch(g){Ca.error("CSV download failed",g),e.setState({errorMessage:o.jsxs("p",{children:[o.jsx(W,{icon:Ee})," ","".concat(g)]})}),s()}}})()}handleDownloadRowOptionChanged(e){this.setState({downloadRowOption:e.target.value})}handleCustomizedDownloadRowOptionChanged(e){this.setState({customizedDownloadRowOption:e})}handleCustomizedDownloadRowsChanged(e){this.setState({customizedDownloadRows:parseInt(e.target.value,10)})}handleIncludeColumnHeadersChanged(){this.setState(e=>{var{includeColumnHeaders:r}=e;return{includeColumnHeaders:!r}})}handleIncludeHiddenColumnsChanged(){this.setState(e=>{var{includeHiddenColumns:r}=e;return{includeHiddenColumns:!r}})}handleUseUnformattedValuesChanged(){this.setState(e=>{var{useUnformattedValues:r}=e;return{useUnformattedValues:!r}})}validateOptionInput(){var{selectedRanges:e}=this.props,{downloadRowOption:r,customizedDownloadRows:n}=this.state;return r===P.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS&&e.length===0?(this.setState({errorMessage:o.jsxs("p",{children:[o.jsx(W,{icon:Ee})," No rows selected. Please select some rows in the table."]})}),!1):r===P.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS&&n<=0?(this.setState({errorMessage:o.jsxs("p",{children:[o.jsx(W,{icon:Ee})," Number of rows to output must be greater than 0"]})}),!1):!0}render(){var{model:e,isDownloading:r,tableDownloadProgress:n,tableDownloadEstimatedTime:a,selectedRanges:i,tableDownloadStatus:s}=this.props,{fileName:l,downloadRowOption:u,customizedDownloadRowOption:d,customizedDownloadRows:c,includeColumnHeaders:h,includeHiddenColumns:m,useUnformattedValues:v,errorMessage:g,id:f}=this.state,{rowCount:b}=e;return o.jsxs("div",{className:"table-csv-exporter",children:[o.jsx("div",{className:"section-title",children:"Download Rows"}),o.jsx("div",{className:"form-group",children:o.jsxs(Xe,{onChange:this.handleDownloadRowOptionChanged,value:u,disabled:r,children:[o.jsxs(he,{value:P.DOWNLOAD_ROW_OPTIONS.ALL_ROWS,"data-testid":"radio-csv-exporter-download-all",children:["All Rows",o.jsx("span",{className:"text-muted ml-2",children:"(".concat(b.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")," rows)")})]}),o.jsxs(he,{value:P.DOWNLOAD_ROW_OPTIONS.SELECTED_ROWS,"data-testid":"radio-csv-exporter-only-selected",children:["Only Selected Rows",o.jsx("span",{className:"text-muted ml-2",children:i.length>0?"(".concat(ge.rowCount(i).toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1,")," rows)"):null})]}),o.jsx(he,{value:P.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS,"data-testid":"radio-csv-exporter-customized-rows",children:o.jsxs("div",{className:"radio-input-row",role:"presentation",onClick:()=>{this.setState({downloadRowOption:P.DOWNLOAD_ROW_OPTIONS.CUSTOMIZED_ROWS})},children:[o.jsxs(Oe,{value:d,"data-testid":"select-csv-exporter-customized-rows",className:"custom-select",disabled:r,onChange:this.handleCustomizedDownloadRowOptionChanged,children:[o.jsx("option",{value:"FIRST",children:"First"}),o.jsx("option",{value:"LAST",children:"Last"})]}),o.jsx("input",{type:"number",className:"form-control",id:"customizedRows-".concat(f),"data-testid":"input-csv-exporter-customized-rows",name:"customizedRows-".concat(f),placeholder:"100",value:c,disabled:r,onChange:this.handleCustomizedDownloadRowsChanged}),o.jsx("div",{children:"Rows"})]})})]})}),o.jsxs("div",{className:"form-group",children:[o.jsx("label",{htmlFor:"customizedRows-".concat(f),children:"File Name"}),o.jsx("input",{type:"text",className:"form-control",id:"filename-".concat(f),"data-testid":"input-csv-exporter-file-name",name:"filename-".concat(f),value:l,onChange:p=>{this.setState({fileName:p.target.value})},disabled:r})]}),o.jsxs("div",{className:"checkbox-options",children:[o.jsx(ce,{checked:h,onChange:this.handleIncludeColumnHeadersChanged,children:"Include column headers"}),o.jsx(ce,{checked:m,onChange:this.handleIncludeHiddenColumnsChanged,children:"Include hidden columns"}),o.jsx(ce,{checked:v,onChange:this.handleUseUnformattedValuesChanged,children:"Use unformatted values"})]}),o.jsxs("div",{className:"section-footer flex-column",children:[g!=null&&o.jsx("div",{className:"error-message",children:g}),s&&o.jsxs("div",{className:"download-status",children:[(s===P.DOWNLOAD_STATUS.DOWNLOADING||s===P.DOWNLOAD_STATUS.INITIATING)&&o.jsxs(o.Fragment,{children:[s===P.DOWNLOAD_STATUS.INITIATING&&o.jsx("div",{className:"text-muted",children:"Starting Download..."}),s===P.DOWNLOAD_STATUS.DOWNLOADING&&o.jsxs("div",{className:"text-muted d-flex justify-content-between",children:[o.jsx("span",{children:a||a===0?"Estimated time: ".concat(fn.formatElapsedTime(a)):null}),o.jsx("span",{children:"".concat(n,"%")})]})]}),s===P.DOWNLOAD_STATUS.FINISHED&&o.jsx("div",{className:"text-muted text-right",children:"Download Completed"}),s===P.DOWNLOAD_STATUS.CANCELED&&o.jsx("div",{className:"text-muted",children:"Download Canceled"}),(s===P.DOWNLOAD_STATUS.DOWNLOADING||s===P.DOWNLOAD_STATUS.INITIATING)&&o.jsx("div",{className:"progress",children:o.jsx("div",{className:"progress-bar progress-bar-striped progress-bar-animated",style:{width:"".concat(n,"%")}})}),s===P.DOWNLOAD_STATUS.FINISHED&&o.jsx("div",{className:"progress",children:o.jsx("div",{className:"progress-bar bg-success",style:{width:"".concat(n,"%")}})})]}),o.jsxs(N,{kind:"primary","data-testid":"btn-csv-exporter-download",className:$("btn-downloading",{"btn-spinner btn-cancelable":r}),onClick:this.handleDownloadClick,children:[r&&o.jsxs("span",{children:[o.jsx(tt,{className:"mr-2 loading-spinner-vertical-align"}),o.jsx("span",{className:"btn-normal-content",children:"Downloading"}),o.jsx("span",{className:"btn-hover-content",children:"Cancel"})]}),!r&&"Download"]})]})]})}}ve(P,"FILENAME_DATE_FORMAT","yyyy-MM-dd-HHmmss");ve(P,"DOWNLOAD_STATUS",{INITIATING:"INITIATING",DOWNLOADING:"DOWNLOADING",FINISHED:"FINISHED",CANCELED:"CANCELED"});ve(P,"DOWNLOAD_ROW_OPTIONS",{ALL_ROWS:"ALL_ROWS",SELECTED_ROWS:"SELECTED_ROWS",CUSTOMIZED_ROWS:"CUSTOMIZED_ROWS"});ve(P,"CUSTOMIZED_ROWS_OPTIONS",{FIRST:"FIRST",LAST:"LAST"});ve(P,"DEFAULT_DOWNLOAD_ROWS",100);ve(P,"defaultProps",{onDownloadStart:()=>{},isDownloading:!1,tableDownloadStatus:"",tableDownloadProgress:0,tableDownloadEstimatedTime:null,selectedRanges:[]});const oo=P;function R(t,e,r){return e=Sa(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sa(t){var e=wa(t,"string");return typeof e=="symbol"?e:String(e)}function wa(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var te=be.module("TableSaver"),Oa="yyyy-MM-dd'T'HH:mm:ss.SSSSSSSSS z";function ya(t){return t.added!==void 0}function xa(t){if(!ya(t))throw new Error("event is not UpdateEventData")}class X extends C.PureComponent{static csvEscapeString(e){return'"'.concat(e.replace(/"/g,'""'),'"')}constructor(e){super(e),R(this,"sw",void 0),R(this,"port",void 0),R(this,"fileWriter",void 0),R(this,"table",void 0),R(this,"tableSubscription",void 0),R(this,"columns",void 0),R(this,"fileName",void 0),R(this,"includeColumnHeaders",void 0),R(this,"useUnformattedValues",void 0),R(this,"chunkRows",void 0),R(this,"gridRanges",void 0),R(this,"gridRangeCounter",void 0),R(this,"rangedSnapshotsTotal",void 0),R(this,"rangedSnapshotCounter",void 0),R(this,"snapshotsTotal",void 0),R(this,"snapshotCounter",void 0),R(this,"snapshotsBuffer",void 0),R(this,"currentSnapshotIndex",void 0),R(this,"snapshotPending",void 0),R(this,"cancelableSnapshots",void 0),R(this,"streamTimeout",void 0),R(this,"snapshotHandlerTimeout",void 0),R(this,"downloadStartTime",void 0),R(this,"iframe",void 0),R(this,"useBlobFallback",void 0),R(this,"getCachedCustomColumnFormatFlag",dt(yn.isCustomColumnFormatDefined,{max:1e4})),this.handlePortMessage=this.handlePortMessage.bind(this),this.handleSnapshotResolved=this.handleSnapshotResolved.bind(this),this.handleDownloadTimeout=this.handleDownloadTimeout.bind(this),this.state={},this.gridRanges=[],this.gridRangeCounter=0,this.rangedSnapshotsTotal=[],this.rangedSnapshotCounter=0,this.includeColumnHeaders=!0,this.useUnformattedValues=!1,this.snapshotsTotal=0,this.snapshotCounter=0,this.snapshotsBuffer=new Map,this.currentSnapshotIndex=0,this.snapshotPending=0,this.cancelableSnapshots=[],this.useBlobFallback=!1}componentDidMount(){var{getDownloadWorker:e}=this.props;e().then(r=>{te.info("found active service worker"),this.sw=r,this.sw.postMessage("ping")}).catch(r=>{te.warn("Download csv is not optimized.",r),this.useBlobFallback=!0})}componentWillUnmount(){this.removeIframe(),this.streamTimeout&&clearTimeout(this.streamTimeout),this.snapshotHandlerTimeout&&clearTimeout(this.snapshotHandlerTimeout)}createWriterStream(e){var r=this.useBlobFallback,n=[],a=null;r&&(a=TextEncoder.prototype.encode.bind(new TextEncoder));var{fileName:i}=this,s={};return r?(s.write=l=>{k(a),l.header!==void 0&&n.push(a(l.header)),l.rows!==void 0&&n.push(a(l.rows))},s.close=()=>{k(i);var l=new Blob(n,{type:"application/octet-stream; charset=utf-8"}),u=document.createElement("a");u.href=URL.createObjectURL(l),u.download=i,u.click()},s.abort=()=>{e.postMessage({cancel:!0}),e.close()}):(s.write=l=>{e.postMessage(l)},s.close=()=>{e.postMessage({end:!0}),e.close()},s.abort=()=>{e.postMessage({cancel:!0}),e.close()}),new WritableStream(s)}startDownload(e,r,n,a,i,s,l){var{isDownloading:u}=this.props;if(!u){this.downloadStartTime=Date.now(),te.info("start downloading ".concat(e)),this.table=r,this.columns=it.columnsFromRanges(i,r.columns),this.tableSubscription=n,this.gridRanges=a,this.includeColumnHeaders=s,this.useUnformattedValues=l;var d=encodeURIComponent(e.replace(/\//g,":")).replace(/['()]/g,escape).replace(/\*/g,"%2A"),c=new MessageChannel;if(this.port=c.port1,this.fileName=e,this.fileWriter=this.createWriterStream(this.port).getWriter(),this.useBlobFallback){this.writeCsvTable(s);return}this.sw&&this.sw.postMessage({encodedFileName:d},[c.port2]),this.port.onmessage=this.handlePortMessage}}finishDownload(){this.table&&this.table.close(),this.tableSubscription&&this.tableSubscription.close(),this.fileWriter&&this.fileWriter.close();var{onDownloadCompleted:e}=this.props;e(),this.resetTableSaver(),this.downloadStartTime!==void 0&&te.info("download finished, total elapsed time ".concat((Date.now()-this.downloadStartTime)/1e3," seconds"))}cancelDownload(){var e,r,n;(e=this.table)===null||e===void 0||e.close(),(r=this.tableSubscription)===null||r===void 0||r.close(),(n=this.fileWriter)===null||n===void 0||n.abort(),this.cancelableSnapshots.forEach(i=>{i&&(i.catch(()=>null),i.cancel())});var{onDownloadCanceled:a}=this.props;a(),this.resetTableSaver()}resetTableSaver(){this.table=void 0,this.tableSubscription=void 0,this.columns=void 0,this.chunkRows=void 0,this.removeIframe(),this.gridRanges=[],this.gridRangeCounter=0,this.rangedSnapshotsTotal=[],this.rangedSnapshotCounter=0,this.includeColumnHeaders=!0,this.useUnformattedValues=!1,this.snapshotsTotal=0,this.snapshotCounter=0,this.snapshotsBuffer=new Map,this.currentSnapshotIndex=0,this.snapshotPending=0,this.cancelableSnapshots=[],this.streamTimeout!=null&&clearTimeout(this.streamTimeout),this.snapshotHandlerTimeout!=null&&clearTimeout(this.snapshotHandlerTimeout),this.streamTimeout=void 0,this.snapshotHandlerTimeout=void 0}handleDownloadTimeout(){te.info("download canceled"),this.cancelDownload()}writeTableHeader(){var e,r="";if(this.columns)for(var n=0;n<this.columns.length;n+=1)r+=this.columns[n].name,r+=n===this.columns.length-1?`
2
2
  `:",";(e=this.fileWriter)===null||e===void 0||e.write({header:r}).then(()=>null)}startWriteTableBody(){this.columns&&this.gridRanges!=null&&(this.chunkRows=Math.floor(X.DOWNLOAD_CELL_CHUNK/this.columns.length),this.rangedSnapshotsTotal=this.gridRanges.map(e=>(k(e.endRow),k(e.startRow),k(this.chunkRows),Math.ceil((e.endRow-e.startRow+1)/this.chunkRows))),this.snapshotsTotal=this.rangedSnapshotsTotal.reduce((e,r)=>e+r),te.info("start writing table, total snapshots: ",this.snapshotsTotal),this.makeSnapshot(Math.min(X.SNAPSHOT_BUFFER_SIZE,this.snapshotsTotal)))}writeCsvTable(e){e&&this.writeTableHeader(),this.startWriteTableBody()}writeSnapshot(e,r,n){if(this.currentSnapshotIndex===e&&this.fileWriter){for(;this.snapshotsBuffer.has(this.currentSnapshotIndex);){var a=this.snapshotsBuffer.get(this.currentSnapshotIndex);k(a),this.fileWriter.write({rows:this.convertSnapshotIntoCsv(a)}),this.snapshotsBuffer.delete(this.currentSnapshotIndex),this.currentSnapshotIndex+=1,this.updateDownloadProgress(e)}if(this.snapshotsTotal&&this.currentSnapshotIndex>=this.snapshotsTotal){this.finishDownload();return}}this.snapshotCounter&&this.snapshotsTotal&&this.snapshotCounter<this.snapshotsTotal&&(te.debug2(`
3
3
  current range index: `.concat(this.gridRangeCounter,`,
4
4
  snapshotIndexCounter: `).concat(this.snapshotCounter,`,
@@ -8,4 +8,4 @@ import{r as C,I as o,K as $,L as W,bb as We,Z as we,ba as Ct,bc as Zr,_ as Qe,T
8
8
  making `).concat(Math.min(X.SNAPSHOT_BUFFER_SIZE-this.snapshotsBuffer.size-this.snapshotPending,this.snapshotsTotal-this.snapshotCounter),` more snapshots
9
9
  `)),this.makeSnapshot(Math.min(X.SNAPSHOT_BUFFER_SIZE-this.snapshotsBuffer.size-this.snapshotPending,this.snapshotsTotal-this.snapshotCounter)))}updateDownloadProgress(e){if(e!=null&&this.snapshotsTotal!=null&&this.downloadStartTime!=null){var{onDownloadProgressUpdate:r}=this.props,n=Math.floor(e*100/this.snapshotsTotal),a=e>1?Math.floor((Date.now()-this.downloadStartTime)*(this.snapshotsTotal-e)/e/1e3):null;r(n,a)}}convertSnapshotIntoCsv(e){for(var r="",n=e.added.iterator(),{dh:a,formatter:i}=this.props,s=[];n.hasNext();)s.push(n.next().value);k(this.columns);for(var{useUnformattedValues:l}=this,u=0;u<s.length;u+=1)for(var d=s[u],c=0;c<this.columns.length;c+=1){var{type:h,name:m}=this.columns[c],v=null;if(l){var g,f=(g=e.getData(d,this.columns[c]))!==null&&g!==void 0?g:"";f!==""&&V.isDateType(h)&&(f=a.i18n.DateTimeFormat.format(Oa,f,a.i18n.TimeZone.getTimeZone(i.timeZone))),v=f.toString()}else{var b=this.getCachedCustomColumnFormatFlag(i,m,h),p=null;if(!b){var O=e.getFormat(d,this.columns[c]);p=O?.formatString!=null?O:null}p?v=i.getFormattedString(e.getData(d,this.columns[c]),h,m,p):v=i.getFormattedString(e.getData(d,this.columns[c]),h,m)}r+=X.csvEscapeString(v),r+=c===this.columns.length-1?`
10
10
  `:","}return r}makeSnapshot(e){var r=this;if(!(e<=0)){var{dh:n}=this.props;k(this.gridRangeCounter);var a=0,i=this.gridRanges[this.gridRangeCounter];k(this.tableSubscription),k(this.columns);for(var s=function(){k(i),k(i.startRow),k(i.endRow),k(r.rangedSnapshotCounter),k(r.chunkRows);var u=i.startRow+r.rangedSnapshotCounter*r.chunkRows,d=Math.min(u+r.chunkRows-1,i.endRow),c=r.snapshotCounter;r.cancelableSnapshots.push(pn.makeCancelable(r.tableSubscription.snapshot(n.RangeSet.ofRange(u,d),r.columns).then(h=>(xa(h),r.handleSnapshotResolved(h,c,u,d),c)).catch(h=>{te.error(h)}),h=>{te.info("snapshot ".concat(h," has been canceled"))})),r.rangedSnapshotCounter+=1,r.snapshotCounter+=1,r.snapshotPending+=1,r.rangedSnapshotCounter>=r.rangedSnapshotsTotal[r.gridRangeCounter]&&(r.gridRangeCounter+=1,r.rangedSnapshotCounter=0,i=r.gridRanges[r.gridRangeCounter]),a+=1};a<e;)s()}}handlePortMessage(e){var{data:r}=e,{download:n,readableStreamPulling:a}=r;if(!this.useBlobFallback){if(n!=null){var{includeColumnHeaders:i}=this;this.makeIframe("".concat(n)),this.writeCsvTable(i)}a!=null&&(this.useBlobFallback||(this.streamTimeout!=null&&clearTimeout(this.streamTimeout),this.streamTimeout=setTimeout(this.handleDownloadTimeout,X.STREAM_TIMEOUT)))}}handleSnapshotResolved(e,r,n,a){this.snapshotHandlerTimeout=setTimeout(()=>{this.snapshotsBuffer.set(r,e),this.snapshotPending-=1,this.writeSnapshot(r,n,a),this.cancelableSnapshots[r]=null},X.SNAPSHOT_HANDLER_TIMEOUT)}makeIframe(e){var r=document.createElement("iframe");r.hidden=!0,r.src=e,r.name="iframe",document.body.appendChild(r),this.iframe=r}removeIframe(){var e;(e=this.iframe)===null||e===void 0||e.remove(),this.iframe=void 0}render(){return null}}R(X,"DOWNLOAD_CELL_CHUNK",6e3);R(X,"SNAPSHOT_BUFFER_SIZE",5);R(X,"STREAM_TIMEOUT",8e3);R(X,"SNAPSHOT_HANDLER_TIMEOUT",5);R(X,"defaultProps",{isDownloading:!1,onDownloadCompleted:()=>{},onDownloadCanceled:()=>{},onDownloadProgressUpdate:()=>{}});function Ia(t){var e,{group:r,onDelete:n,onColorChange:a,onNameChange:i,validateName:s}=t,{isNew:l}=r,u=C.useRef(r),d=C.useRef(null),c=C.useRef(null),[h,m]=C.useState(!1),[v,g]=C.useState(l?"":r.name),[f,b]=C.useState(l),[p,O]=C.useState(!1),S=v!==r.name?s(v):"",D=l&&!p||S==="",y=C.useCallback(()=>{m(!1)},[]);C.useEffect(function(){f&&d.current&&(d.current.focus(),d.current.select())},[f]),C.useEffect(function(){return()=>{u.current.isNew&&n(u.current)}},[n]),C.useEffect(function(){if(h){var w,j;(w=c.current)===null||w===void 0||w.click(),(j=c.current)===null||j===void 0||j.focus(),window.addEventListener("click",y,!0)}return()=>window.removeEventListener("click",y,!0)},[h,y]);var I=()=>{D&&(i(r,v),b(!1))},T=()=>{if(l){n(r);return}g(r.name),b(!1)},A=x=>{O(!0),x.key==="Enter"&&(x.stopPropagation(),I()),x.key===" "&&x.stopPropagation(),x.key==="Escape"&&T()};return f?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"editing-container",children:[o.jsx("input",{ref:d,className:$("form-control",{"is-invalid":!D}),value:v,placeholder:"Group Name",onChange:x=>g(x.target.value),onKeyDown:A,onBlur:()=>O(!0)}),o.jsx(N,{kind:"ghost",icon:Ut,tooltip:"Confirm",onClick:I}),o.jsx(N,{kind:"ghost",icon:$t,tooltip:"Cancel",onClick:T})]}),!D&&o.jsx("p",{className:"mb-0 validate-label-error text-danger",children:S})]}):o.jsxs("div",{className:"group-name-wrapper",children:[o.jsx("span",{className:"column-name",children:v}),o.jsx(N,{className:"p-1 mx-1",kind:"ghost",icon:Jr,tooltip:"Edit",onClick:()=>{b(!0)}}),o.jsxs("span",{className:"right-buttons",children:[o.jsx(N,{kind:"ghost",icon:ye,tooltip:"Delete group",onClick:()=>n(r)}),o.jsx(N,{kind:"ghost",className:"color-swatch mr-1",icon:r.color!==void 0?o.jsxs("span",{className:"fa-layers",children:[o.jsx(W,{className:"color-swatch",icon:tr,color:K.white,transform:"down-1"}),o.jsx(W,{className:"color-swatch",icon:tr,color:r.color,transform:"shrink-2 down-1"})]}):Bt,tooltip:"Set color",onClick:()=>m(x=>!x)}),h&&o.jsxs(o.Fragment,{children:[o.jsx("input",{"aria-label":"Color input",ref:c,type:"color",list:"presetColors",value:(e=r.color)!==null&&e!==void 0?e:K["content-bg"],style:{visibility:"hidden",width:0,height:0,padding:0,border:0},onChange:x=>{r.color=x.target.value,a(r,x.target.value)}}),o.jsxs("datalist",{id:"presetColors",children:[o.jsx("option",{children:K["content-bg"]}),o.jsx("option",{children:K.primary}),o.jsx("option",{children:K.foreground}),o.jsx("option",{children:K.green}),o.jsx("option",{children:K.yellow}),o.jsx("option",{children:K.orange}),o.jsx("option",{children:K.red}),o.jsx("option",{children:K.purple}),o.jsx("option",{children:K.blue}),o.jsx("option",{children:K["gray-400"]})]})]})]})]})}function Rr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Ar(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Rr(Object(r),!0).forEach(function(n){ja(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Rr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function ja(t,e,r){return e=Da(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Da(t){var e=Pa(t,"string");return typeof e=="symbol"?e:String(e)}function Pa(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Na(){}var Ta=C.forwardRef(function(e,r){var{value:n,clone:a,childCount:i,item:s,onVisibilityChange:l,onClick:u,onGroupDelete:d,onGroupColorChange:c,onGroupNameChange:h,validateGroupName:m,handleProps:v}=e,{group:g,modelIndex:f,isVisible:b}=s.data,p=C.useRef(null),O=C.useCallback(D=>{if(D.buttons===1){var y;l([f].flat(),!b),(y=p.current)===null||y===void 0||y.focus()}},[l,f,b]),S=C.useCallback(D=>{u(n,D)},[u,n]);return o.jsxs("div",Ar(Ar({ref:r,className:$("tree-item",{isSelected:s.selected,"two-dragged":i===2,"multiple-dragged":i>2}),onClick:S},v),{},{children:[o.jsx(N,{ref:p,kind:"ghost",className:"px-1",onClick:Na,onMouseDown:O,onMouseEnter:O,icon:b?nt:at,tooltip:"Toggle visibility"}),o.jsx("span",{className:$("column-name",g&&"column-group"),children:g&&!a?o.jsx(Ia,{group:g,onDelete:d,onColorChange:c,onNameChange:h,validateName:m}):n}),o.jsxs("div",{children:[a&&i>1&&o.jsx("span",{className:"item-count",children:i}),o.jsx(He,{children:"Drag to re-order"}),o.jsx(W,{icon:rt})]})]}))});const Ea=Ta;function Ra(t){return t.parentId!==void 0}function Mr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function kr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Mr(Object(r),!0).forEach(function(n){Aa(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Mr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Aa(t,e,r){return e=Ma(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ma(t){var e=ka(t,"string");return typeof e=="symbol"?e:String(e)}function ka(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Fa(t,e){return Math.round(t/e)}function ct(t,e,r,n,a,i){var s=t.findIndex(d=>d.name===n);if(s===-1){var l=r.get(n);if(l==null)throw new Error("Column or header group not found: ".concat(n));var u=l.childIndexes.flat();return{id:n,selected:i.has(n),children:l.children.map(d=>ct(t,e,r,d,a,i)).sort((d,c)=>{var h=Array.isArray(d.data.visibleIndex)?d.data.visibleIndex[0]:d.data.visibleIndex,m=Array.isArray(c.data.visibleIndex)?c.data.visibleIndex[0]:c.data.visibleIndex;return h-m}),data:{modelIndex:u,visibleIndex:l.getVisibleRange(e),group:l,isVisible:u.some(d=>!a.has(d))}}}return{id:n,children:[],selected:i.has(n),data:{modelIndex:s,visibleIndex:M.getVisibleIndex(s,e),isVisible:!a.has(s)}}}function _a(t,e,r,n,a){for(var i=[],s=new Set(a),l=new Map(r.map(h=>[h.name,h])),u=new Set(n),d=0,c=function(){for(var m=M.getModelIndex(d,e),v=t[m].name,g=r.find(b=>{var{children:p}=b;return p.includes(v)});g!==void 0&&g.parent!==void 0;)g=l.get(g.parent);var f=ct(t,e,l,g?g.name:v,u,s);i.push(f),Array.isArray(f.data.visibleIndex)?d+=f.data.visibleIndex[1]-f.data.visibleIndex[0]+1:d+=1};d<t.length;)c();return i}function Ae(t,e,r,n,a){var i=t.findIndex(p=>{var{id:O}=p;return O===r}),s=t.findIndex(p=>{var{id:O}=p;return O===e}),l=t[s],u=St(t,s,i),d=u[i-1],c=u[i+1],h=Fa(n,a),m=l.depth+h,v=La({previousItem:d,nextItem:c}),g=Ha({nextItem:c}),f=m;return m>=v?f=v:m<g&&(f=g),{depth:f,maxDepth:v,minDepth:g,parentId:b()};function b(){var p;if(f===0||!d)return null;if(f===d.depth)return d.parentId;if(f>d.depth)return d.id;var O=(p=u.slice(0,i).reverse().find(S=>S.depth===f))===null||p===void 0?void 0:p.parentId;return O??null}}function La(t){var e,r,{previousItem:n,nextItem:a}=t;return Math.max((e=n?.depth)!==null&&e!==void 0?e:0,(r=a?.depth)!==null&&r!==void 0?r:0)}function Ha(t){var{nextItem:e}=t;return e?e.depth:0}function ht(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:null,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:0;return t.reduce((n,a,i)=>[...n,kr(kr({},a),{},{parentId:e,depth:r,index:i}),...ht(a.children,a.id,r+1)],[])}function q(t){return t.every(Ra)?[...t]:ht(t)}function vt(t,e){for(var r=0;r<t.length;r+=1){var n=t[r],{id:a,children:i}=n;if(a===e)return n;if(i.length){var s=vt(i,e);if(s)return s}}}function mt(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return t.reduce((r,n)=>{var{children:a}=n;return a.length?mt(a,r+1):r+1},e)}function Ga(t,e){var r=vt(t,e);return r?mt(r.children):0}function Fr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function De(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Fr(Object(r),!0).forEach(function(n){Ua(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Fr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Ua(t,e,r){return e=$a(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function $a(t){var e=Ba(t,"string");return typeof e=="symbol"?e:String(e)}function Ba(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Wa=[re.Down,re.Right,re.Up,re.Left],za=[re.Left,re.Right];function Va(t,e,r){return(n,a)=>{var{currentCoordinates:i,context:{active:s,over:l,collisionRect:u,droppableRects:d,droppableContainers:c}}=a;if(Wa.includes(n.code)){if(!s||!u)return;n.preventDefault();var{current:{items:h,offset:m}}=t;if(za.includes(n.code)&&l?.id!=null){var{depth:v,maxDepth:g,minDepth:f}=Ae(h,s.id,l.id,m,r);switch(n.code){case re.Left:if(v>f)return De(De({},i),{},{x:i.x-r});break;case re.Right:if(v<g)return De(De({},i),{},{x:i.x+r});break}return}var b=[];c.forEach(F=>{if(!(F!=null&&F.disabled||F.id===l?.id)){var U=d.get(F.id);if(U)switch(n.code){case re.Down:u.top<U.top&&b.push(F);break;case re.Up:u.top>U.top&&b.push(F);break}}});var p=wt({active:s,collisionRect:u,pointerCoordinates:null,droppableRects:d,droppableContainers:b}),O=Ot(p,"id");if(O===l?.id&&p.length>1&&(O=p[1].id),O!=null&&l?.id!=null){var S=d.get(s.id),D=d.get(O),y=c.get(O);if(S&&D&&y){var I=h.findIndex(F=>{var{id:U}=F;return U===O}),T=h[I],A=h.findIndex(F=>{var{id:U}=F;return U===s.id}),x=h[A];if(T!=null&&x!=null){var{depth:w}=Ae(h,s.id,O,(T.depth-x.depth)*r,r),j=I>A,E=j?1:-1,L=e?(u.height-S.height)/2:0,_={x:D.left+w*r,y:D.top+E*L};return _}}}}}}function Ka(t,e,r){return e=qa(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qa(t){var e=Xa(t,"string");return typeof e=="symbol"?e:String(e)}function Xa(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}class gt extends yt{}Ka(gt,"activators",[{eventName:"onPointerDown",handler:t=>{var{nativeEvent:e}=t;return!(!e.isPrimary||e.button!==0||Za(e.target))}}]);var Ya=["button","input","textarea","select","option"];function Za(t){return!!(t?.tagName!=null&&Ya.includes(t.tagName.toLowerCase()))}function ft(t){var{clone:e=!1,depth:r,disableInteraction:n=!1,ghost:a=!1,handleProps:i,value:s,dragRef:l=null,wrapperRef:u=null,renderItem:d,item:c,childCount:h}=t,m=C.useMemo(()=>Array(r).fill(0).map((g,f)=>o.jsx("span",{className:"depth-line"},"depth-line-".concat(f))),[r]),v=C.useMemo(()=>({ref:l,clone:e,value:s,item:c,childCount:h,handleProps:i}),[l,e,s,c,h,i]);return o.jsxs("li",{className:$("item-wrapper",{clone:e,ghost:a,disableInteraction:n}),ref:u,children:[!e&&m,d(v)]},s)}ft.displayName="TreeItem";var Qa=["id","depth"];function _r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Pe(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?_r(Object(r),!0).forEach(function(n){Ja(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):_r(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Ja(t,e,r){return e=ei(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ei(t){var e=ri(t,"string");return typeof e=="symbol"?e:String(e)}function ri(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ti(t,e){if(t==null)return{};var r=ni(t,e),n,a;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(a=0;a<i.length;a++)n=i[a],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(t,n)&&(r[n]=t[n])}return r}function ni(t,e){if(t==null)return{};var r={},n=Object.keys(t),a,i;for(i=0;i<n.length;i++)a=n[i],!(e.indexOf(a)>=0)&&(r[a]=t[a]);return r}var ai=t=>{var{isSorting:e,wasDragging:r}=t;return!(e||r)};function Lr(t){var{id:e,depth:r}=t,n=ti(t,Qa),{attributes:a,isDragging:i,isSorting:s,listeners:l,setDraggableNodeRef:u,setDroppableNodeRef:d,transform:c,transition:h}=xt({id:e,animateLayoutChanges:ai}),m=_e.Translate.toString(c),v=C.useMemo(()=>({transform:m,transition:h}),[m,h]),g=C.useMemo(()=>Pe(Pe(Pe({},a),l),{},{style:v}),[a,l,v]);return o.jsx(ft,Pe({dragRef:u,wrapperRef:d,depth:r,ghost:i,disableInteraction:s,handleProps:g},n))}function Hr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Me(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Hr(Object(r),!0).forEach(function(n){ii(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Hr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function ii(t,e,r){return e=oi(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function oi(t){var e=si(t,"string");return typeof e=="symbol"?e:String(e)}function si(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var li={keyframes(t){var{transform:e}=t;return[{opacity:1,transform:_e.Transform.toString(e.initial)},{opacity:0,transform:_e.Transform.toString(Me(Me({},e.final),{},{x:e.final.x+5,y:e.final.y+5}))}]},easing:"ease-out",sideEffects(t){var{active:e}=t;e.node.animate([{opacity:0},{opacity:1}],{duration:er.duration,easing:er.easing})}},Ne=null;function di(t){var e;return Ne==null&&t.activeNodeRect&&t.activatorEvent instanceof PointerEvent&&(Ne=Math.floor((t.activatorEvent.clientY-t.activeNodeRect.top)/t.activeNodeRect.height)*t.activeNodeRect.height),t.activeNodeRect||(Ne=null),Me(Me({},t.transform),{},{y:t.transform.y+((e=Ne)!==null&&e!==void 0?e:0)})}function ui(t){var{items:e,renderItem:r,indentationWidth:n=30,indicator:a=!1,activeId:i,overId:s,offsetLeft:l}=t,u=It(),d=C.useRef(u);C.useEffect(function(){d.current=u},[u]),C.useEffect(function(){d.current.measureDroppableContainers(e.map(g=>{var{id:f}=g;return f}))},[e]);var c=i!=null&&s!=null?Ae(e,i,s,l,n):null,h=C.useRef({items:e,offset:l}),m=i!=null?e.find(v=>{var{id:g}=v;return g===i}):null;return C.useEffect(()=>{h.current={items:e,offset:l}},[e,l]),o.jsxs(o.Fragment,{children:[o.jsx("div",{className:$("tree-container",i!=null&&"marching-ants"),children:e.map(v=>{var{id:g,depth:f}=v;return o.jsx(Lr,{id:g,value:g,depth:g===i&&c?c.depth:f,item:v,renderItem:r},g)})}),jt.createPortal(o.jsx(Dt,{dropAnimation:li,modifiers:[di],className:"visibility-ordering-list",children:i!=null&&m?o.jsx(Lr,{id:i,depth:m.depth,clone:!0,childCount:Ga(e,i)+1,value:i.toString(),renderItem:r,item:m}):null}),document.body)]})}function Gr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Te(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Gr(Object(r),!0).forEach(function(n){ci(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Gr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function ci(t,e,r){return e=hi(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function hi(t){var e=vi(t,"string");return typeof e=="symbol"?e:String(e)}function vi(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var mi={droppable:{strategy:At.Always}},gi={activationConstraint:{distance:5}};function fi(t){var{items:e,indicator:r=!1,indentationWidth:n=30,onDragStart:a,onDragEnd:i,renderItem:s}=t,[l,u]=C.useState(null),[d,c]=C.useState(null),[h,m]=C.useState(0),v=C.useMemo(()=>{var x=q(e);return l!=null?x.filter(w=>{var{id:j,selected:E}=w;return j===l||!E}):x},[l,e]),g=l!=null&&d!=null?Ae(v,l,d,h,n):null,f=C.useRef({items:v,offset:h}),b=C.useMemo(()=>({coordinateGetter:Va(f,r,n)}),[n,r]),p=Pt(rr(gt,gi),rr(Mt,b)),O=C.useMemo(()=>v.map(x=>{var{id:w}=x;return w}),[v]);C.useEffect(()=>{f.current={items:v,offset:h}},[v,h]);var S=C.useCallback(x=>{var{active:{id:w}}=x;u(w),c(w),a?.(w),document.body.style.setProperty("cursor","grabbing")},[a]),D=C.useCallback(x=>{var{delta:w}=x;m(w.x)},[]),y=C.useCallback(x=>{var w,{over:j}=x;c((w=j?.id)!==null&&w!==void 0?w:null)},[]),I=C.useCallback(()=>{c(null),u(null),m(0),document.body.style.setProperty("cursor","")},[]),T=C.useCallback(x=>{var{active:w,over:j}=x;if(I(),g&&j){var{depth:E,parentId:L}=g,_=JSON.parse(JSON.stringify(q(e))),F=_.findIndex(B=>{var{id:ae}=B;return ae===j.id}),U=_.findIndex(B=>{var{id:ae}=B;return ae===w.id}),G=_[U];_[U]=Te(Te({},G),{},{depth:E,parentId:L}),i?.(G,Te(Te({},_[F]),{},{parentId:g.parentId}))}},[e,i,g,I]),A=C.useCallback(()=>{I()},[I]);return o.jsx(Nt,{sensors:p,collisionDetection:Tt,measuring:mi,onDragStart:S,onDragMove:D,onDragOver:y,onDragEnd:T,onDragCancel:A,children:o.jsx(Et,{items:O,strategy:Rt,children:o.jsx(ui,{items:v,renderItem:s,indicator:r,indentationWidth:n,activeId:l,overId:d,offsetLeft:h})})})}function Ur(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function $r(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Ur(Object(r),!0).forEach(function(n){pi(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Ur(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function pi(t,e,r){return e=bi(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function bi(t){var e=Ci(t,"string");return typeof e=="symbol"?e:String(e)}function Ci(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Si(t,e,r,n,a,i,s,l){var u=a.map((D,y)=>$r($r({},D),{},{index:y})),d=[],c=n,h=i[0].data.visibleIndex,m=u.findIndex(D=>{var{id:y}=D;return y===t.id}),v=u.findIndex(D=>{var{id:y}=D;return y===e.id}),g=Array.isArray(h)?h[1]+1:h+1;c=se(i[0],e.parentId,c);for(var f=1;f<i.length;f+=1){var{data:{visibleIndex:b}}=i[f];d=M.moveItemOrRange(b,g,d,!0),g+=Array.isArray(b)?b[1]-b[0]+1:1,c=se(i[f],e.parentId,c)}var p=[Array.isArray(h)?h[0]:h,g-1],O=Array.isArray(e.data.visibleIndex)?e.data.visibleIndex[0]:e.data.visibleIndex,S=M.getVisibleIndex(O,d);return m>v&&S>O&&(S-=1),e.children.length>0&&(Array.isArray(h)?h[0]:h)<S&&(S-=1),p[0]<S&&(S-=p[1]-p[0]),d=M.moveItemOrRange(p,Le(S,s,l),d),{groups:c,movedColumns:r.concat(d)}}function se(t,e,r){if(t.parentId===e)return[...r];var n=r.map(b=>new ue(b)),a=new Map(n.map(b=>[b.name,b])),i=n.find(b=>b.name===t.parentId),s=n.find(b=>b.name===e),l=n.find(b=>b.name===t.id);if(i!=null&&(i.children=i.children.filter(b=>b!==t.id),i.children.length===0)){var u,d=new Set([i.name]),{parent:c=""}=i,h=a.get(c);for((u=h)===null||u===void 0||u.removeChildren([i.name]);h&&h.children.length===0;){var m,v;d.add(h.name);var g=(m=(v=h)===null||v===void 0?void 0:v.parent)!==null&&m!==void 0?m:"",f=a.get(g);f?.removeChildren([h.name]),h=f}n=n.filter(b=>{var{name:p}=b;return!d.has(p)})}return s?.addChildren([t.id]),l?.setParent(e??void 0),n}function Br(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function fe(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Br(Object(r),!0).forEach(function(n){Y(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Br(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Y(t,e,r){return e=wi(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function wi(t){var e=Oi(t,"string");return typeof e=="symbol"?e:String(e)}function Oi(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var yi=150;class H extends C.PureComponent{static shouldRenderColumn(e){return e.isProxy!==!0}constructor(e){super(e),Y(this,"list",void 0),Y(this,"debouncedSearchColumns",Qr(this.searchColumns,yi)),Y(this,"handleGroupColorChange",kt((r,n)=>{var{columnHeaderGroups:a,onColumnHeaderGroupChanged:i}=this.props,s=[...a],l=new ue(fe(fe({},r),{},{color:n}));s.splice(s.findIndex(u=>{var{name:d}=u;return d===r.name}),1,l),i(s)},250)),Y(this,"renderItem",oe(r=>{var{value:n,clone:a,item:i,ref:s,handleProps:l}=r,{onColumnVisibilityChanged:u}=this.props,{selectedColumns:d}=this.state,c=n;if(a){var h=this.getSelectedParentItems().map(m=>{var{id:v}=m;return v});c=h.join(", ")}return o.jsx(Ea,{ref:s,value:c,clone:a,item:i,childCount:d.size,onVisibilityChange:u,onClick:this.handleItemClick,onGroupDelete:this.handleGroupDelete,onGroupColorChange:this.handleGroupColorChange,onGroupNameChange:this.handleGroupNameChange,validateGroupName:this.validateGroupName,handleProps:l})})),Y(this,"getMemoizedFirstMovableIndex",oe((r,n,a)=>{for(var i=0;i<n.length;i+=1){var s=M.getModelIndex(i,a);if(r.isColumnMovable(s))return i}return null})),Y(this,"getMemoizedLastMovableIndex",oe((r,n,a)=>{for(var i=n.length-1;i>=0;i-=1){var s=M.getModelIndex(i,a);if(r.isColumnMovable(s))return i}return null})),Y(this,"memoizedGetTreeItems",oe((r,n,a,i,s)=>_a(r,n,a,i,[...s.values()]))),Y(this,"makeVisibilityOrderingList",oe((r,n)=>{var{movedColumns:a}=this.props,i=[],s=this.getFirstMovableIndex(),l=this.getLastMovableIndex(),u=n.findIndex(D=>{var{data:y}=D;return Array.isArray(y.visibleIndex)?y.visibleIndex[0]===s:y.visibleIndex===s}),d=n.findIndex(D=>{var{data:y}=D;return Array.isArray(y.visibleIndex)?y.visibleIndex[1]===l:y.visibleIndex===l}),c=n.slice(u,d+1);if(s==null||l===null){for(var h=0;h<r.length;h+=1){var m=M.getModelIndex(h,a),v=r[m];H.shouldRenderColumn(v)&&i.push(this.renderImmovableItem(v.name))}return i}for(var g=0;g<s;g+=1){var f=M.getModelIndex(g,a),b=r[f];H.shouldRenderColumn(b)&&i.push(this.renderImmovableItem(b.name))}s!==null&&s>0&&i.push(o.jsx("hr",{},"top-horizontal-divider")),i.push(o.jsx(fi,{items:c,renderItem:this.renderItem,onDragStart:this.handleDragStart,onDragEnd:this.handleDragEnd},"movable-items")),l!=null&&l<r.length-1&&i.push(o.jsx("hr",{},"bottom-horizontal-divider"));for(var p=l+1;p<r.length;p+=1){var O=M.getModelIndex(p,a),S=r[O];H.shouldRenderColumn(S)&&i.push(this.renderImmovableItem(S.name))}return i})),Y(this,"renderImmovableItem",oe(r=>o.jsx("div",{className:"visibility-ordering-list-item immovable",children:o.jsx("div",{className:"column-item",children:o.jsx("span",{className:"column-name",children:r})})},r))),this.handleSearchInputChange=this.handleSearchInputChange.bind(this),this.searchColumns=this.searchColumns.bind(this),this.handleItemClick=this.handleItemClick.bind(this),this.handleDragEnd=this.handleDragEnd.bind(this),this.handleGroupDelete=this.handleGroupDelete.bind(this),this.handleGroupNameChange=this.handleGroupNameChange.bind(this),this.handleGroupCreate=this.handleGroupCreate.bind(this),this.validateGroupName=this.validateGroupName.bind(this),this.addColumnToSelected=this.addColumnToSelected.bind(this),this.handleDragStart=this.handleDragStart.bind(this),this.state={selectedColumns:new Set,queriedColumnIndex:void 0,queriedColumnRange:void 0,prevQueriedColumns:void 0,lastSelectedColumn:"",searchFilter:""},this.list=null}componentDidUpdate(e){var{movedColumns:r}=this.props;if(r!==e.movedColumns){var{searchFilter:n}=this.state;this.searchColumns(n,!1)}}componentWillUnmount(){this.debouncedSearchColumns.cancel()}resetVisibilityOrdering(){var{model:e,onReset:r,onMovedColumnsChanged:n,onColumnHeaderGroupChanged:a}=this.props;this.setState({selectedColumns:new Set,queriedColumnIndex:void 0,queriedColumnRange:void 0,prevQueriedColumns:void 0,lastSelectedColumn:"",searchFilter:""}),r(),a(e.initialColumnHeaderGroups),n(e.initialMovedColumns)}resetSelection(){this.setState({selectedColumns:new Set,lastSelectedColumn:""})}handleSearchInputChange(e){var r=e.target.value;if(this.setState({searchFilter:r}),!r){this.debouncedSearchColumns.cancel(),this.resetSelection();return}this.debouncedSearchColumns(r)}searchColumns(e){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=q(this.getTreeItems()),a=n.filter(c=>{var h,m,{id:v,data:g}=c;return!((h=(m=g.group)===null||m===void 0?void 0:m.isNew)!==null&&h!==void 0&&h)&&v.toLowerCase().includes(e.toLowerCase())}),i=a.reduce((c,h)=>{var{id:m}=h,v=n.findIndex(g=>g.id===m);return fe(fe({},c),{},{[v]:m})},{});if(!r){this.setState({prevQueriedColumns:i});return}var s=a.map(c=>{var{id:h}=c;return h});if(this.addColumnToSelected(s,!1),s.length>0){var l,u=n.findIndex(c=>{var{id:h}=c;return h.toLowerCase().includes(e.toLowerCase())}),d=(l=this.list)===null||l===void 0?void 0:l.querySelectorAll(".item-wrapper")[u];d?.scrollIntoView({block:"center"})}this.setState({prevQueriedColumns:i,queriedColumnIndex:void 0})}changeSelectedColumn(e){var r,{queriedColumnIndex:n,queriedColumnRange:a,prevQueriedColumns:i}=this.state,s=n;if(i!==void 0){var l=Object.keys(i).length;e==="forward"?a!==void 0?s=a.nextIndex:s===void 0||s>=l-1?s=0:s+=1:e==="back"&&(a!==void 0?s=a.prevIndex:s===void 0||s<=0?s=l-1:s-=1),this.addColumnToSelected([Object.values(i)[s]],!1);var u=parseInt(Object.keys(i)[s],10),d=(r=this.list)===null||r===void 0?void 0:r.querySelectorAll(".item-wrapper")[u];d?.scrollIntoView({block:"center"}),this.setState({queriedColumnIndex:s,queriedColumnRange:void 0})}}adjustQueriedIndex(e){var{prevQueriedColumns:r}=this.state;if(r!==void 0){if(e in Object.values(r)){var n=Object.values(r).indexOf(e);this.setState({queriedColumnIndex:n,queriedColumnRange:void 0});return}for(var a=q(this.getTreeItems()),i=a.findIndex(h=>h.id===e),s=Object.keys(r).map(h=>parseInt(h,10)),l=s.length-1,u=0,d=0;d<s.length;d+=1){var c=s[d];if(c<i)l=d;else if(c>i){u=d;break}}this.setState({queriedColumnRange:{prevIndex:l,nextIndex:u}})}}moveSelectedColumns(e){var{columnHeaderGroups:r}=this.props,{selectedColumns:n}=this.state,a=q(this.getTreeItems()),i=this.getFirstMovableIndex(),s=this.getLastMovableIndex();k(i),k(s);var l=this.getSelectedParentItems(),u=e===H.MOVE_OPTIONS.UP||e===H.MOVE_OPTIONS.TOP;u||l.reverse();for(var d=[],c=r,h=function(){var{id:g,parentId:f,depth:b,data:{visibleIndex:p}}=l[m];switch(e){case H.MOVE_OPTIONS.TOP:{d=M.moveItemOrRange(p,i,d,!0);var O=Array.isArray(p)?p[1]-p[0]+1:1;i+=O,c=se(l[m],null,c);break}case H.MOVE_OPTIONS.BOTTOM:{d=M.moveItemOrRange(p,s,d,!0);var S=Array.isArray(p)?p[1]-p[0]+1:1;s-=S,c=se(l[m],null,c);break}case H.MOVE_OPTIONS.UP:{var D=a.findIndex(G=>G.id===g),y=a.map((G,B)=>B<D&&!n.has(G.id)).lastIndexOf(!0),I=a[y];if(I!=null&&I.parentId!==f)if(Math.abs(I.depth-b)>1){var T=a.map((G,B)=>B<y&&G.depth===b).lastIndexOf(!0),A=a[T];c=se(l[m],A.id,c)}else c=se(l[m],I.parentId,c);else{var x=Le(Array.isArray(p)?p[0]-1:p-1,i,s);d=M.moveItemOrRange(p,x,d,!1);var w=Array.isArray(p)?p[1]-p[0]+1:1;i+=w}break}case H.MOVE_OPTIONS.DOWN:{var j=a.findIndex(G=>G.id===g),E=a.find((G,B)=>B>j&&!n.has(G.id));if(E?.parentId!==f){var L,_=a.find(G=>G.id===f);c=se(l[m],(L=_?.parentId)!==null&&L!==void 0?L:null,c);break}else if(E?.children.length>0){c=se(l[m],E.id,c);break}var F=Le(Array.isArray(p)?p[0]+1:p+1,i,s);d=M.moveItemOrRange(p,F,d,!1);var U=Array.isArray(p)?p[1]-p[0]+1:1;s-=U;break}}},m=0;m<l.length;m+=1)h();return{newMoves:d,groups:c}}handleMoveColumns(e){var{onMovedColumnsChanged:r,movedColumns:n,onColumnHeaderGroupChanged:a}=this.props,{newMoves:i,groups:s}=this.moveSelectedColumns(e),l;e===H.MOVE_OPTIONS.TOP&&(l=()=>{var u,d;(u=this.list)===null||u===void 0||(d=u.parentElement)===null||d===void 0||d.scroll({top:0})}),e===H.MOVE_OPTIONS.BOTTOM&&(l=()=>{var u,d;(u=this.list)===null||u===void 0||(d=u.parentElement)===null||d===void 0||d.scroll({top:this.list.parentElement.scrollHeight})}),a(s),i.length>0&&r(n.concat(i),l)}getSortMoves(e,r,n){var a=[...e],i=r===H.SORTING_OPTIONS.ASC;a.sort((m,v)=>{var g=m.id.toUpperCase(),f=v.id.toUpperCase();return bn.sort(g,f,i)});for(var s=[...n],l=Math.min(...a.flatMap(m=>{var{modelIndex:v}=m.data;return Array.isArray(v)?M.getVisibleIndexes(v,s):M.getVisibleIndex(v,s)})),u=0;u<a.length;u+=1){var d=a[u],{modelIndex:c}=d.data,h=Array.isArray(c)?M.getVisibleIndexes(c,s):M.getVisibleIndex(c,s);s=Array.isArray(h)?M.moveRange([Math.min(...h),Math.max(...h)],l,s,!0):M.moveItem(h,l,s),Array.isArray(h)&&(s=this.getSortMoves(d.children,r,s)),l+=Array.isArray(c)?c.length:1}return s}handleSortColumns(e){for(var r,n,{model:a,onMovedColumnsChanged:i}=this.props,s=this.getTreeItems(),l=(r=this.getFirstMovableIndex())!==null&&r!==void 0?r:0,u=(n=this.getLastMovableIndex())!==null&&n!==void 0?n:s.length-1,d=s.slice(l,u+1),c=[...a.initialMovedColumns],h=0;h<a.frozenColumns.length;h+=1){var m,v=a.frozenColumns[h],g=M.getVisibleIndex((m=a.getColumnIndexByName(v))!==null&&m!==void 0?m:0,c);g!==h&&c.push({from:g,to:h})}var f=this.getSortMoves(d,e,c);i(f)}handleItemClick(e,r){if(r.stopPropagation(),!(r.target instanceof HTMLElement&&(r.target.tagName==="BUTTON"||r.target.tagName==="INPUT"))){r.currentTarget.focus();var{selectedColumns:n,lastSelectedColumn:a}=this.state,i=M.isModifierKeyDown(r),s=r.shiftKey,l=n.has(e),u=[e];if(l&&i){this.removeColumnFromSelected(e);return}var d=q(this.getTreeItems());if(l&&!s&&a===e){var c=d.find(g=>{var{id:f}=g;return f===e});k(c);var h=q(c.children).length;if(h+1===n.size){this.resetSelection();return}}if(s){var m=d.findIndex(g=>g.id===e),v=d.findIndex(g=>g.id===a);u.push(...d.slice(Math.min(v,m),Math.max(v,m)+1).map(g=>g.id))}this.addColumnToSelected(u,i||s),this.adjustQueriedIndex(e),this.setState({lastSelectedColumn:e})}}addColumnToSelected(e,r){var{selectedColumns:n}=this.state,a=new Set(r?[...n.values()].concat(e):e),i=q(this.getTreeItems());i.forEach(s=>{var{id:l,children:u}=s;a.has(l)&&u.forEach(d=>a.add(d.id))}),this.setState({selectedColumns:a})}removeColumnFromSelected(e){var{selectedColumns:r}=this.state,n=q(this.getTreeItems()),a=n.find(l=>{var{id:u}=l;return u===e});k(a);var i=n.find(l=>{var{id:u}=l;return u===a.parentId});q(a?.children).forEach(l=>r.delete(l.id));for(var s=function(){r.delete(i.id);var u=i.parentId;i=n.find(d=>{var{id:c}=d;return c===u})};i!=null;)s();r.delete(e),this.setState({selectedColumns:new Set(r)})}handleDragStart(e){var{selectedColumns:r}=this.state;r.has(e)||this.addColumnToSelected([e],!1)}handleDragEnd(e,r){var{movedColumns:n,onMovedColumnsChanged:a,columnHeaderGroups:i,onColumnHeaderGroupChanged:s}=this.props,l=this.getSelectedParentItems(),u=q(this.getTreeItems()).map((v,g)=>fe(fe({},v),{},{index:g})),d=this.getFirstMovableIndex(),c=this.getLastMovableIndex();k(d),k(c);var{groups:h,movedColumns:m}=Si(e,r,n,i,u,l,d,c);s(h),a(m)}handleGroupNameChange(e,r){var{columnHeaderGroups:n,onColumnHeaderGroupChanged:a}=this.props,i=[...n],s=e.name,l=i.findIndex(m=>{var{name:v}=m;return v===s}),u=i[l];k(u);var d=new ue(u);d.name=r,i.splice(l,1,d);var c=i.findIndex(m=>{var{name:v}=m;return v===d.parent});if(c>=0){var h=new ue(i[c]);h.removeChildren([s]),h.addChildren([r]),i.splice(c,1,h)}a(i)}handleGroupDelete(e){var{columnHeaderGroups:r,onColumnHeaderGroupChanged:n}=this.props,a=r.filter(l=>l.name!==e.name),i=a.findIndex(l=>l.name===e.parent);if(i>=0){var s=new ue(a[i]);s.addChildren(e.children),s.removeChildren([e.name]),a.splice(i,1,s)}n(a)}handleGroupCreate(){var{movedColumns:e,onMovedColumnsChanged:r,onColumnHeaderGroupChanged:n}=this.props,{newMoves:a,groups:i}=this.moveSelectedColumns(H.MOVE_OPTIONS.TOP),s=i.filter(h=>!h.isNew),l=this.getSelectedParentItems(),u=l.map(h=>h.data.modelIndex).flat().filter(h=>h>=0),d="".concat(ue.NEW_GROUP_PREFIX,"-").concat(Date.now()),c=new ue({name:d,children:l.map(h=>{var{id:m}=h;return m}),depth:0,childIndexes:[...new Set(u)]});r(e.concat(a),()=>{var h,m;(h=this.list)===null||h===void 0||(m=h.parentElement)===null||m===void 0||m.scroll({top:0})}),n(s.concat([c])),this.resetSelection()}validateGroupName(e){var{model:r,columnHeaderGroups:n}=this.props,{columns:a}=r;return qe.isValidColumnName(e)?a.some(i=>{var{name:s}=i;return s===e})||n.some(i=>{var{name:s}=i;return s===e})?"Duplicate name":"":"Invalid name"}getFirstMovableIndex(){var{model:e,movedColumns:r}=this.props;return this.getMemoizedFirstMovableIndex(e,e.columns,r)}getLastMovableIndex(){var{model:e,movedColumns:r}=this.props;return this.getMemoizedLastMovableIndex(e,e.columns,r)}getTreeItems(){var{model:e,movedColumns:r,hiddenColumns:n,columnHeaderGroups:a}=this.props,{selectedColumns:i}=this.state;return this.memoizedGetTreeItems(e.columns,r,a,n,i)}getSelectedParentItems(){var{selectedColumns:e}=this.state,r=q(this.getTreeItems());return r.filter(n=>{var{id:a,parentId:i}=n;return e.has(a)&&!e.has(i??"")})}render(){var{model:e,hiddenColumns:r,onColumnVisibilityChanged:n}=this.props,{selectedColumns:a,searchFilter:i,prevQueriedColumns:s,queriedColumnIndex:l}=this.state,u=a.size>0,d=this.getTreeItems(),c=new Map(q(d).map(S=>[S.id,S.data.modelIndex])),h=new Set(r),m=[...new Set(u?[...a.values()].map(S=>c.get(S)).filter(S=>S!=null).flat():d.map(S=>S.data.modelIndex).flat())],v=m.some(S=>!h.has(S)),g=v?"Hide All":"Show All",f=v?"Hide Selected":"Show Selected",b=this.makeVisibilityOrderingList(e.columns,d),p={index:l,next:S=>this.changeSelectedColumn(S)},O=Object.keys(s??{}).length;return o.jsxs("div",{role:"menu",className:"visibility-ordering-builder",tabIndex:0,children:[o.jsxs("div",{className:"top-menu",children:[o.jsx(N,{kind:"ghost",className:"toggle-visibility-btn",onClick:()=>{n(m,!v)},icon:v?nt:at,tooltip:"Toggle column visibility",children:u?f:g}),o.jsx(lt,{className:"visibility-search",value:i,matchCount:i?O:void 0,onChange:this.handleSearchInputChange,cursor:p})]}),o.jsxs("div",{className:"top-menu",children:[o.jsx(N,{kind:"ghost",icon:Wt,className:"px-1",tooltip:"Reset to default",onClick:()=>{this.resetVisibilityOrdering()},children:"Reset"}),o.jsx("span",{className:"vertical-divider"}),o.jsx(N,{kind:"ghost",icon:Ve,className:"px-1",tooltip:"Sort ascending",onClick:()=>{this.handleSortColumns(H.SORTING_OPTIONS.ASC)}}),o.jsx(N,{kind:"ghost",icon:Ke,className:"px-1",tooltip:"Sort descending",onClick:()=>{this.handleSortColumns(H.SORTING_OPTIONS.DSC)}}),o.jsx("span",{className:"vertical-divider"}),o.jsxs(N,{kind:"ghost",className:"px-1",tooltip:"Create group from selection",disabled:!u,onClick:this.handleGroupCreate,children:[o.jsxs("span",{className:"fa-layers",children:[o.jsx(W,{mask:zt,icon:et,transform:"right-7 down-5 shrink-6"}),o.jsx(W,{icon:Vt,transform:"right-8 down-6 shrink-8"})]}),"Group"]}),o.jsx("span",{className:"vertical-divider"}),o.jsx(N,{kind:"ghost",icon:Kt,className:"px-1",tooltip:"Move selection up",onClick:()=>{this.handleMoveColumns(H.MOVE_OPTIONS.UP)},disabled:!u}),o.jsx(N,{kind:"ghost",icon:qt,className:"px-1",tooltip:"Move selection down",onClick:()=>{this.handleMoveColumns(H.MOVE_OPTIONS.DOWN)},disabled:!u}),o.jsx(N,{kind:"ghost",icon:Xt,className:"px-1",tooltip:"Move selection to top",onClick:()=>{this.handleMoveColumns(H.MOVE_OPTIONS.TOP)},disabled:!u}),o.jsx(N,{kind:"ghost",icon:Yt,className:"px-1",tooltip:"Move selection to bottom",onClick:()=>{this.handleMoveColumns(H.MOVE_OPTIONS.BOTTOM)},disabled:!u})]}),o.jsx("div",{role:"menu",className:$("visibility-ordering-list"),children:o.jsx("div",{className:"column-list",ref:S=>{this.list=S},children:b})})]})}}Y(H,"SORTING_OPTIONS",{DSC:"DSC",ASC:"ASC"});Y(H,"MOVE_OPTIONS",{TOP:"TOP",BOTTOM:"BOTTOM",UP:"UP",DOWN:"DOWN"});const so=H;class lo extends ln{getGridY(e){var r=super.getGridY(e),{isFilterBarShown:n,theme:a,advancedFilters:i,quickFilters:s,sorts:l,reverseType:u}=e;return n?r+=a.filterBarHeight:(s!=null&&s.size>0||i!=null&&i.size>0)&&(r+=a.filterBarCollapsedHeight),u!==V.REVERSE_TYPE.NONE&&l!=null&&l.length>0&&(r+=a.reverseHeaderBarHeight),r}getUserColumnWidths(){return this.userColumnWidths}}var Ue=16,xi=new Map([["sortUp",Zt],["sortDown",Qt],["caretDown",Jt],["caretRight",en],["cellOverflow",rn]]),Ii=dt(t=>{var e=xi.get(t);if(e===void 0)throw new Error("Icon is undefined");var r=Array.isArray(e.icon[4])?e.icon[4][0]:e.icon[4],n=new Path2D(r),a=new Path2D,i={a:Ue/e.icon[0],d:Ue/e.icon[1]};return a.addPath(n,i),a},{max:1e3});function Se(t){return Ii(t)}class ji{static drawTreeMarker(e,r,n,a,i,s,l){e.save();var{x1:u,y1:d}=i,c=Se(l?"caretDown":"caretRight"),h=n+u-2,m=a+d+2.5;e.fillStyle=s,e.textAlign="center",e.translate(h,m),e.fill(c),e.restore()}}const pt=ji;class Di extends dn{drawCellContent(e,r,n,a){var i,{metrics:s,model:l}=r,{modelColumns:u,modelRows:d}=s,c=Z(d,a),h=u.get(n);if(h!==void 0){var m=l.valueForCell(h,c);if(V.isTextType((i=l.columns[h])===null||i===void 0?void 0:i.type)&&(m===null||m==="")){var v=e.font;e.font="italic ".concat(v),super.drawCellContent(e,r,n,a),e.font=v;return}super.drawCellContent(e,r,n,a)}}getTextRenderMetrics(e,r,n){var a=M.getTextRenderMetrics(e,r,n),{mouseX:i,mouseY:s,metrics:l,theme:u}=e;if(i==null||s==null)return a;var{column:d,row:c}=M.getGridPointFromXY(i,s,l);if(r===d&&n===c){var{left:h}=this.getCellOverflowButtonPosition(i,s,l,u);this.shouldRenderOverflowButton(e)&&h!=null&&(a.width=h-l.gridX-a.x)}return a}getCellOverflowButtonPosition(e,r,n,a){var i={left:null,top:null,width:null,height:null};if(e==null||r==null||n==null)return i;var{rowHeight:s,columnWidth:l,left:u,top:d}=M.getCellInfoFromXY(e,r,n);if(u==null||l==null||d==null)return i;var{width:c,verticalBarWidth:h}=n,{cellHorizontalPadding:m}=a,v=Ue+2*m,g=s,f=Math.min(n.gridX+u+l,c-h),b=f-v,p=n.gridY+d;return{left:b,top:p,width:v,height:g}}shouldRenderOverflowButton(e){var r,n,{context:a,mouseX:i,mouseY:s,metrics:l,model:u,theme:d}=e;if(i==null||s==null)return!1;var{row:c,column:h,modelRow:m,modelColumn:v}=M.getCellInfoFromXY(i,s,l);if(c==null||h==null||m==null||v==null||!V.isStringType(u.columns[v].type))return!1;var g=(r=u.textForCell(v,m))!==null&&r!==void 0?r:"",{width:f}=M.getTextRenderMetrics(e,h,c),b=(n=l.fontWidths.get(d.font))!==null&&n!==void 0?n:st;a.save(),a.font=d.font;var p=this.getCachedTruncatedString(a,g,f,b,u.truncationCharForCell(v,m));return a.restore(),g!==""&&p!==g}drawTreeMarker(e,r,n,a,i,s,l){pt.drawTreeMarker(e,r,n,a,i,s,l)}}const Pi=Di;class Ni extends un{drawTreeMarker(e,r,n,a,i,s,l){pt.drawTreeMarker(e,r,n,a,i,s,l)}}const Ti=Ni;function Wr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function zr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?Wr(Object(r),!0).forEach(function(n){$e(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Wr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function $e(t,e,r){return e=Ei(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ei(t){var e=Ri(t,"string");return typeof e=="symbol"?e:String(e)}function Ri(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Fe=Object.freeze({SORT_UP:"sortUp",SORT_DOWN:"sortDown",CARET_DOWN:"caretDown",CARET_RIGHT:"caretRight",CELL_OVERFLOW:"cellOverflow"}),Vr=10;class Be extends cn{constructor(){super(...arguments),$e(this,"textCellRenderer",new Pi),$e(this,"dataBarCellRenderer",new Ti)}static isFilterValid(e,r){var n=e==null||e.filter!=null,a=r==null||r.filter!=null;return n&&a}getSortIcon(e){return e?e.direction===V.sortDirection.ascending?Se(Fe.SORT_UP):e.direction===V.sortDirection.descending?Se(Fe.SORT_DOWN):null:null}drawCanvas(e){super.drawCanvas(e),this.drawScrim(e)}drawGrid(e,r){super.drawGrid(e,r),this.drawCellOverflowButton(r)}drawGridLines(e,r){super.drawGridLines(e,r),this.drawGroupedColumnLine(e,r),this.drawPendingRowLine(e,r)}drawCellContent(e,r,n,a){var{metrics:i,model:s}=r,{modelColumns:l,modelRows:u}=i,d=l.get(n),c=Z(u,a);if(d!==void 0){var h=s.renderTypeForCell(d,c),m=this.getCellRenderer(h);m.drawCellContent(e,r,n,a)}}getCellOverflowButtonPosition(e){var{mouseX:r,mouseY:n,metrics:a,theme:i}=e;return this.textCellRenderer.getCellOverflowButtonPosition(r,n,a,i)}shouldRenderOverflowButton(e){return this.textCellRenderer.shouldRenderOverflowButton(e)}drawCellOverflowButton(e){var{context:r,mouseX:n,mouseY:a,theme:i}=e;if(!(n==null||a==null)&&this.shouldRenderOverflowButton(e)){var{left:s,top:l,width:u,height:d}=this.getCellOverflowButtonPosition(e),{cellHorizontalPadding:c,overflowButtonColor:h,overflowButtonHoverColor:m}=i;r.save(),m!=null&&s!=null&&u!=null&&l!=null&&d!=null&&n>=s&&n<=s+u&&a>=l&&a<=l+d?r.fillStyle=m:h!=null&&(r.fillStyle=h);var v=Se(Fe.CELL_OVERFLOW);s!=null&&l!=null&&r.translate(s+c,l+2),r.fill(v),r.restore()}}drawGroupedColumnLine(e,r){var{metrics:n,model:a,theme:i}=r,{groupedColumns:s}=a,{maxY:l,allColumnWidths:u,allColumnXs:d}=n;if(!(s.length===0||i.groupedColumnDividerColor==null)){var c=s.length-1,h=d.get(c),m=u.get(c);if(!(h==null||m==null)){var v=h+m+.5;e.strokeStyle=i.groupedColumnDividerColor,e.lineWidth=1,e.beginPath(),e.moveTo(v,0),e.lineTo(v,l),e.stroke()}}}drawPendingRowLine(e,r){var{metrics:n,model:a,theme:i}=r,{allRowYs:s,maxX:l}=n,{pendingRowCount:u}=a;if(!(u<=0)){var d=a.rowCount-a.pendingRowCount-a.floatingBottomRowCount,c=s.get(d);c!=null&&(c-=.5,e.save(),e.setLineDash([4,2]),e.strokeStyle=i.pendingTextColor,e.lineWidth=1,e.beginPath(),e.moveTo(0,c),e.lineTo(l,c),e.stroke(),e.restore())}}drawMouseColumnHover(e,r){var{theme:n,metrics:a,hoverSelectColumn:i}=r;if(!(i==null||n.linkerColumnHoverBackgroundColor==null)){var{allColumnWidths:s,allColumnXs:l,maxY:u}=a,d=Z(l,i),c=Z(s,i);e.fillStyle=n.linkerColumnHoverBackgroundColor,e.fillRect(d,0,c,u)}}drawMouseRowHover(e,r){var{isSelectingColumn:n}=r;n||super.drawMouseRowHover(e,r)}drawScrim(e){var{context:r,loadingScrimProgress:n,metrics:a,theme:i}=e;if(n!=null){var{width:s,height:l,gridY:u}=a,{scrimBlurSize:d,scrimColor:c}=i;r.save(),r.globalCompositeOperation="color",r.filter="blur(".concat(d,"px)"),c!=null&&(r.fillStyle=c),r.beginPath(),r.rect(0,u,s,l-u),r.clip(),r.fillRect(-d,-d+u,d*2+s,(d*2+(l-u))*n),r.globalCompositeOperation="source-over",r.filter="blur(".concat(d,"px) opacity(15%)"),r.fillRect(-d,-d+u,d*2+s,(d*2+(l-u))*n),r.restore()}}drawColumnHeaders(e,r){super.drawColumnHeaders(e,r);var{theme:n,metrics:a,model:i,reverseType:s}=r,{columnHeaderHeight:l}=a;if(this.drawFilterHeaders(e,r),!(l<=0)){var{sort:u}=i;if(u.length===1){var d=s!==V.REVERSE_TYPE.NONE,c;d?c=n.headerReverseBarColor:c=n.headerSortBarColor,this.drawHeaderBar(e,r,c,d?n.reverseHeaderBarHeight:n.sortHeaderBarHeight)}else u.length>1&&(s!==V.REVERSE_TYPE.NONE&&this.drawHeaderBar(e,r,n.headerReverseBarColor,n.reverseHeaderBarHeight,!1),this.drawHeaderBar(e,r,n.headerSortBarColor,n.sortHeaderBarHeight))}}drawHeaderBar(e,r,n,a){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,{theme:s,metrics:l,model:u}=r,{columnHeaderHeight:d,width:c}=l,h=0;i||(h=a),e.fillStyle=s.headerBarCasingColor,e.fillRect(0,u.columnHeaderMaxDepth*d-a-2+h,c,a+2),e.fillStyle=n,e.fillRect(0,u.columnHeaderMaxDepth*d-a-1+h,c,a)}drawColumnHeadersAtDepth(e,r,n,a,i){var{metrics:s,model:l,isMenuShown:u}=r,{columnHeaderMaxDepth:d}=l,{width:c}=s,h=zr(zr({},a),{},{maxX:i===d-1&&a.maxX===c?c-(u?0:30):a.maxX});super.drawColumnHeadersAtDepth(e,r,n,h,i)}drawColumnHeaderAtIndex(e,r,n,a){var i,s;super.drawColumnHeaderAtIndex(e,r,n,a);var{metrics:l,model:u,theme:d}=r,{modelColumns:c,allColumnWidths:h,allColumnXs:m,gridX:v,columnHeaderHeight:g,fontWidths:f}=l,{headerHorizontalPadding:b}=d,p=Z(h,n,0),O=Z(m,n)+v,S=c.get(n);if(S!=null){var D=(i=u.columns[S])===null||i===void 0?void 0:i.name;if(D!=null){var y=V.getSortForColumn(u.sort,D);if(y){var I=this.getSortIcon(y);if(I){var T=u.textForColumnHeader(S);if(T!==void 0){var A=(s=f.get(e.font))!==null&&s!==void 0?s:st;k(A);var x=T.length*A,w=v+O+x+b,{maxX:j}=a;j-=b;var E=v+O+p-b-1,L=w>j?w+1:Math.min(j,E),_=y.direction===V.sortDirection.ascending?-6:-12,F=g*.5+_;e.save(),e.beginPath(),e.rect(O,0,p,g),e.clip(),e.fillStyle=d.headerSortBarColor,e.translate(L,F),e.fill(I),e.restore()}}}}}}drawFilterHeaders(e,r){var{isFilterBarShown:n,quickFilters:a,advancedFilters:i}=r;n?this.drawExpandedFilterHeaders(e,r):(a!=null&&a.size>0||i!=null&&i.size>0)&&this.drawCollapsedFilterHeaders(e,r)}drawExpandedFilterHeaders(e,r){var{metrics:n,model:a,theme:i,quickFilters:s,advancedFilters:l}=r,{filterBarHeight:u}=i;if(!(u<=0)){var{gridX:d,gridY:c,maxX:h,modelColumns:m,visibleColumns:v,allColumnWidths:g,allColumnXs:f}=n,b=c-u;e.save(),e.font=i.font,e.textAlign="left",s!=null&&s.size>0||l!=null&&l.size>0?e.fillStyle=i.filterBarExpandedActiveBackgroundColor:e.fillStyle=i.filterBarExpandedBackgroundColor,e.fillRect(d,b,h,u-1),e.fillStyle=i.headerBarCasingColor,e.fillRect(d,b+u-1,h,1);var p=b;e.strokeStyle=i.filterBarSeparatorColor,e.beginPath();for(var O=0;O<v.length;O+=1){var S=v[O],D=Z(m,S),y=Z(f,S),I=Z(g,S);if(a.isFilterable(D)&&I>0){var T=d+(y??0);e.rect(T+.5,p+.5,I,u-2)}}e.stroke();for(var A=0;A<v.length;A+=1){var x=v[A],w=Z(g,x),j=Z(f,x),E=j+d;this.drawExpandedFilterHeader(e,r,x,E,w)}e.restore()}}drawExpandedFilterHeader(e,r,n,a,i){if(!(i<=0)){var{metrics:s,theme:l,quickFilters:u,advancedFilters:d}=r,{modelColumns:c,gridY:h}=s,{filterBarHeight:m,filterBarExpandedActiveCellBackgroundColor:v,filterBarErrorColor:g,filterBarHorizontalPadding:f,headerColor:b}=l,p=h-m,O=c.get(n);if(O!==void 0){var S=u.get(O),D=d.get(O);if(!(S==null&&D==null)){var y=null;if(S!=null){var{text:I}=S;if(y=I,y||(y=V.getFilterText(S.filter)),y!=null){var{fontWidths:T}=s,A=T.get(e.font);(A==null||A===0)&&(A=e.measureText("8").width,A||(A=10));var x=(i-f*2)/A;x<=0?y="":y.length>x&&(y="".concat(y.substring(0,x-1),"…"))}}e.save();var w=Be.isFilterValid(D,S);if(w&&v!=null)e.fillStyle=v,e.fillRect(a+1,p+1,i-1,m-3);else if(g!=null){e.fillStyle=g,e.lineWidth=2,e.strokeStyle=g;var j=a+2,E=p+2,L=i-3,_=m-5;e.strokeRect(j,E,L,_)}if(y!=null&&y!==""){var F=a+f,U=p+m*.5+1;e.fillStyle=b,e.fillText(y,F,U)}e.restore()}}}}drawCollapsedFilterHeaders(e,r){var{metrics:n,theme:a}=r,{headerSeparatorColor:i,filterBarCollapsedHeight:s}=a;if(!(s<=0)){var{gridX:l,gridY:u,maxX:d,visibleColumns:c,allColumnWidths:h,allColumnXs:m}=n,v=u-s;e.save(),e.fillStyle=i,e.fillRect(l,v,d,s);for(var g=0;g<c.length;g+=1){var f=c[g],b=h.get(f),p=m.get(f);if(p!=null&&b!=null){var O=p+l;this.drawCollapsedFilterHeader(e,r,f,O,b)}}e.restore()}}drawCollapsedFilterHeader(e,r,n,a,i){if(!(i<=0)){var{metrics:s,theme:l,quickFilters:u,advancedFilters:d}=r,{modelColumns:c,gridY:h}=s,m=c.get(n);if(m!==void 0){var v=u.get(m),g=d.get(m),{filterBarCollapsedHeight:f,filterBarActiveColor:b,filterBarActiveBackgroundColor:p,filterBarErrorColor:O}=l;e.save();var S=Be.isFilterValid(g,v);p!=null&&v==null&&g==null?e.fillStyle=p:b!=null&&S?e.fillStyle=b:O!=null&&(e.fillStyle=O);var D=a+1,y=h-f,I=i-1,T=f-1;e.fillRect(D,y,I,T),e.restore()}}}drawRowFooters(e,r){var{metrics:n,model:a,mouseX:i,mouseY:s,theme:l}=r,{gridY:u,gridX:d,maxX:c,modelRows:h,floatingTopHeight:m,floatingBottomHeight:v,floatingRows:g,rowFooterWidth:f,height:b,horizontalBarHeight:p,verticalBarWidth:O,allRowHeights:S,allRowYs:D,width:y}=n;if(!(f<=0||g.length===0)){var{cellHorizontalPadding:I,floatingGridRowColor:T,floatingRowBackgroundColors:A,headerColor:x,rowHoverBackgroundColor:w}=l;e.translate(d,u),e.beginPath();var j=Math.min(c,y-f-O-d);e.fillStyle=A,m>0&&e.rect(j,0,f,m),v>0&&e.rect(j,b-u-p-v,f,v),e.fill();var E=i!=null&&s!=null&&i>=d&&i<=c+f?M.getRowAtY(s,n):null;if(w!=null&&E!==null&&g.includes(E)){e.fillStyle=w;var L=D.get(E),_=S.get(E);k(L),k(_),e.fillRect(j,L,f,_)}if(e.beginPath(),T!=null&&(e.strokeStyle=T),m>0&&(e.moveTo(j+.5,.5),e.lineTo(j+.5,m-.5)),v>0){var F=b-u-p-v;e.moveTo(j-.5,F+.5),e.lineTo(j-.5,F+v-.5)}e.stroke(),e.fillStyle=x,e.textAlign="left";for(var U=j+I,G=0;G<g.length;G+=1){var B=g[G],ae=S.get(B),Ye=D.get(B),Ze=h.get(B);if(Ye!=null&&ae!=null&&Ze!=null){var bt=Ye+ae*.5;e.fillText(a.textForRowFooter(Ze),U,bt)}}e.translate(-d,-u)}}getExpandButtonPosition(e,r){var{mouseX:n,mouseY:a,metrics:i,theme:s}=e,l={left:null,top:null,width:null,height:null};if(n==null||a==null||r==null||!i)return l;var{rowHeight:u,left:d,top:c}=M.getCellInfoFromXY(n,a,i);k(d),k(u),k(c);var{cellHorizontalPadding:h}=s,m=Vr+2*h,v=Math.max(d+Vr*r,i.gridX),g=i.gridY+c;return{left:v,top:g,width:m,height:u}}}const Ai="12px Fira Sans, sans-serif",Mi="var(--dh-color-white)",ki="var(--dh-color-black)",Kr={"grid-bg":"var(--dh-color-grid-bg)",font:Ai,white:Mi,black:ki,"header-bg":"var(--dh-color-grid-header-bg)","header-color":"var(--dh-color-grid-header-text)","header-height":"30px","header-separator-color":"var(--dh-color-grid-header-separator)","header-separator-hover-color":"var(--dh-color-grid-header-separator-hover)","header-hidden-separator-hover-color":"var(--dh-color-grid-header-separator-hidden-hover)","header-sort-bar-color":"var(--dh-color-grid-header-sort-bar)","header-reverse-bar-color":"var(--dh-color-grid-header-reverse-bar)","header-bar-casing-color":"var(--dh-color-grid-header-bar-casing)","header-font":"600 12px Fira Sans, sans-serif","row-height":"19px","row-background-colors":"var(--dh-color-grid-row-0-bg) var(--dh-color-grid-row-1-bg)","active-cell-selection-border-width":"2px","selection-color":"var(--dh-color-grid-selection)","selection-outline-color":"var(--dh-color-grid-selection-outline)","selection-outline-casing-color":"var(--dh-color-grid-selection-outline-casing)","row-hover-bg":"var(--dh-color-grid-row-hover-bg)","row-shadow-alpha":"var(--dh-color-grid-row-shadow-alpha)","selected-row-hover-bg":"var(--dh-color-grid-row-hover-bg-selected)","scroll-bar-active-selection-tick-color":"var(--dh-color-grid-scroll-bar-active-selection-tick)","scroll-bar-bg":"var(--dh-color-grid-scroll-bar-bg)","scroll-bar-hover-bg":"var(--dh-color-grid-scroll-bar-hover-bg)","scroll-bar-casing-color":"var(--dh-color-grid-scroll-bar-casing)","scroll-bar-corner-color":"var(--dh-color-grid-scroll-bar-corner)","scroll-bar-color":"var(--dh-color-grid-scroll-bar)","scroll-bar-hover-color":"var(--dh-color-grid-scroll-bar-hover)","scroll-bar-active-color":"var(--dh-color-grid-scroll-bar-active)","text-color":"var(--dh-color-grid-text)","hyperlink-color":"var(--dh-color-grid-text-hyperlink)","positive-number-color":"var(--dh-color-grid-number-positive)","negative-number-color":"var(--dh-color-grid-number-negative)","zero-number-color":"var(--dh-color-grid-number-zero)","date-color":"var(--dh-color-grid-date)","pending-text-color":"var(--dh-color-grid-text-pending)","error-text-color":"var(--dh-color-grid-text-error)","null-string-color":"var(--dh-color-grid-string-null)","filter-bar-active-bg":"var(--dh-color-grid-filter-bar-active-bg)","filter-bar-active-color":"var(--dh-color-grid-filter-bar-active)","filter-bar-expanded-bg":"var(--dh-color-grid-filter-bar-expanded-bg)","filter-bar-expanded-active-bg":"var(--dh-color-grid-filter-bar-expanded-active-bg)","filter-bar-expanded-active-cell-bg":"var(--dh-color-grid-filter-bar-expanded-active-cell-bg)","filter-bar-separator-color":"var(--dh-color-grid-filter-bar-separator)","filter-bar-error-color":"var(--dh-color-grid-filter-bar-error)","filter-icon-color":"var(--dh-color-grid-filter-icon)","scrim-color":"var(--dh-color-grid-scrim)","context-menu-sort-icon-color":"var(--dh-color-grid-context-menu-sort-icon)","context-menu-reverse-icon-color":"var(--dh-color-grid-context-menu-reverse-icon)","linker-column-hover-bg":"var(--dh-color-grid-column-linker-hover-bg)","tree-line-color":"var(--dh-color-grid-tree-line)","tree-marker-color":"var(--dh-color-grid-tree-marker)","tree-marker-hover-color":"var(--dh-color-grid-tree-marker-hover)","grouped-column-divider-color":"var(--dh-color-grid-column-grouped-divider)","floating-grid-row-color":"var(--dh-color-grid-floating-row)","floating-row-background-colors":"var(--dh-color-grid-floating-row-bg)","floating-divider-inner-color":"var(--dh-color-grid-floating-divider-inner)","floating-divider-outer-color":"var(--dh-color-grid-floating-divider-outer)","overflow-button-color":"var(--dh-color-grid-overflow-button)","overflow-button-hover-color":"var(--dh-color-grid-overflow-button-hover)","zero-line-color":"var(--dh-color-grid-data-bar-zero-line)","positive-bar-color":"var(--dh-color-grid-data-bar-positive)","negative-bar-color":"var(--dh-color-grid-data-bar-negative)","marker-bar-color":"var(--dh-color-grid-data-bar-marker)"};function qr(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),r.push.apply(r,n)}return r}function Xr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e]!=null?arguments[e]:{};e%2?qr(Object(r),!0).forEach(function(n){Fi(t,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):qr(Object(r)).forEach(function(n){Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(r,n))})}return t}function Fi(t,e,r){return e=_i(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _i(t){var e=Li(t,"string");return typeof e=="symbol"?e:String(e)}function Li(t,e){if(typeof t!="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}var Yr=be.module("IrisGridTheme");function Hi(){var t,e=tn(Kr);return e["row-background-colors"]=nn((t=e["row-background-colors"])!==null&&t!==void 0?t:"").map(r=>{var[n,a]=r;return an.normalizeCssColor(e["row-background-colors"].substring(n,a+1))}).join(" "),Yr.debug2("Iris grid theme:",Kr),Yr.debug2("Iris grid theme derived:",e),Object.freeze(Xr(Xr({},hn),{},{backgroundColor:e["grid-bg"],white:e.white,black:e.black,font:e.font,headerBackgroundColor:e["header-bg"],headerColor:e["header-color"],headerSeparatorColor:e["header-separator-color"],headerSeparatorHoverColor:e["header-separator-hover-color"],headerHiddenSeparatorHoverColor:e["header-hidden-separator-hover-color"],headerSortBarColor:e["header-sort-bar-color"],headerReverseBarColor:e["header-reverse-bar-color"],headerBarCasingColor:e["header-bar-casing-color"],headerFont:e["header-font"],rowBackgroundColors:e["row-background-colors"],rowHoverBackgroundColor:e["row-hover-bg"],selectionColor:e["selection-color"],selectionOutlineColor:e["selection-outline-color"],selectionOutlineCasingColor:e["selection-outline-casing-color"],selectedRowHoverBackgroundColor:e["selected-row-hover-bg"],scrollBarBackgroundColor:e["scroll-bar-bg"],scrollBarHoverBackgroundColor:e["scroll-bar-hover-bg"],scrollBarCasingColor:e["scroll-bar-casing-color"],scrollBarCornerColor:e["scroll-bar-corner-color"],scrollBarColor:e["scroll-bar-color"],scrollBarHoverColor:e["scroll-bar-hover-color"],scrollBarActiveColor:e["scroll-bar-active-color"],scrollBarSelectionTickColor:e["selected-row-hover-bg"],scrollBarActiveSelectionTickColor:e["scroll-bar-active-selection-tick-color"],textColor:e["text-color"],hyperlinkColor:e["hyperlink-color"],positiveNumberColor:e["positive-number-color"],negativeNumberColor:e["negative-number-color"],zeroNumberColor:e["zero-number-color"],dateColor:e["date-color"],pendingTextColor:e["pending-text-color"],errorTextColor:e["error-text-color"],nullStringColor:e["null-string-color"],filterBarActiveBackgroundColor:e["filter-bar-active-bg"],filterBarExpandedBackgroundColor:e["filter-bar-expanded-bg"],filterBarExpandedActiveBackgroundColor:e["filter-bar-expanded-active-bg"],filterBarExpandedActiveCellBackgroundColor:e["filter-bar-expanded-active-cell-bg"],filterBarSeparatorColor:e["filter-bar-separator-color"],filterBarActiveColor:e["filter-bar-active-color"],filterBarErrorColor:e["filter-bar-error-color"],filterIconColor:e["filter-icon-color"],scrimColor:e["scrim-color"],contextMenuSortIconColor:e["context-menu-sort-icon-color"],contextMenuReverseIconColor:e["context-menu-reverse-icon-color"],allowRowResize:!1,autoSelectRow:!0,gridColumnColor:null,gridRowColor:null,groupedColumnDividerColor:e["grouped-column-divider-color"],columnHoverBackgroundColor:null,headerHorizontalPadding:12,scrollBarSize:13,scrollBarHoverSize:16,minScrollHandleSize:24,rowHeight:parseInt(e["row-height"],10)||19,columnWidth:100,rowHeaderWidth:0,rowFooterWidth:60,columnHeaderHeight:parseInt(e["header-height"],10)||30,filterBarHeight:30,filterBarCollapsedHeight:5,sortHeaderBarHeight:2,reverseHeaderBarHeight:4,filterBarHorizontalPadding:4,activeCellSelectionBorderWidth:parseInt(e["active-cell-selection-border-width"],10)||2,shadowAlpha:parseFloat(e["row-shadow-alpha"])||.15,scrimBlurSize:25,minScrimTransitionTime:150,maxScrimTransitionTime:350,scrollSnapToRow:!0,linkerColumnHoverBackgroundColor:e["linker-column-hover-bg"],treeLineColor:e["tree-line-color"],treeMarkerColor:e["tree-marker-color"],treeMarkerHoverColor:e["tree-marker-hover-color"],floatingGridColumnColor:null,floatingGridRowColor:e["floating-grid-row-color"],floatingRowBackgroundColors:e["floating-row-background-colors"],floatingDividerInnerColor:e["floating-divider-inner-color"],floatingDividerOuterColor:e["floating-divider-outer-color"],overflowButtonColor:e["overflow-button-color"],overflowButtonHoverColor:e["overflow-button-hover-color"],zeroLineColor:e["zero-line-color"],positiveBarColor:e["positive-bar-color"],negativeBarColor:e["negative-bar-color"],markerBarColor:e["marker-bar-color"]}))}function Gi(t){return typeof t=="object"&&t!=null&&"equals"in t&&typeof t.equals=="function"}function Ui(t){return"".concat(t)}function uo(t){var{column:e,table:r,filter:n=Sn,onChange:a,selectedValue:i,disabled:s,className:l,formatValue:u=Ui,maxSize:d=1e3}=t,c=Cn(),[h,m]=C.useState([]);C.useEffect(()=>{if(r==null){m([]);return}var b=e??r.columns[0];r.applyFilter(n);var p=r.setViewport(0,d,[b]);return p.addEventListener(c.Table.EVENT_UPDATED,O=>{var{detail:S}=O,D=S.rows.map(y=>{var I;return(I=y.get(b))!==null&&I!==void 0?I:null});m(D)}),()=>{p.close()}},[e,c,n,d,r]);var v=C.useMemo(()=>i===void 0?[void 0,...h]:h,[i,h]),g=C.useMemo(()=>v.findIndex(b=>b===i||Gi(b)&&b.equals(i)),[i,v]),f=C.useCallback(b=>{a(v[b])},[a,v]);return o.jsx(Oe,{className:l,value:g,onChange:f,disabled:s,children:v.map((b,p)=>o.jsx(ot,{value:p,children:u(b)},"".concat(p)))})}var $i=C.createContext(null);function co(t){var{children:e}=t,{activeThemes:r}=wn(),n=C.useMemo(Hi,[r]);return o.jsx($i.Provider,{value:n,children:e})}export{Ji as A,to as C,eo as F,ut as I,ao as O,io as R,Mn as S,uo as T,so as V,Qi as a,no as b,ro as c,Ln as d,lo as e,Be as f,$i as g,co as h,$n as i,Vn as j,Yn as k,oo as l,X as m,Hi as n};
11
- //# sourceMappingURL=IrisGridThemeProvider-b7f4c598.js.map
11
+ //# sourceMappingURL=IrisGridThemeProvider-3c6c8cb6.js.map