@finos/legend-application-repl-deployment 13.83.0 → 13.85.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -41,5 +41,5 @@
41
41
  .${ip.BLUR}:hover {
42
42
  filter: none;
43
43
  }
44
- `})})),Gp=(0,vt.PA)((e=>{const{view:t}=e,n=t.grid.scrollHintText,o=document.querySelector(".data-cube-grid .ag-side-bar"),r=document.querySelector(".data-cube-grid .ag-body-vertical-scroll");return(0,E.jsxs)("div",{className:"absolute -top-10 flex items-center rounded-sm border border-neutral-300 bg-neutral-100 p-1 pr-2 text-neutral-500 shadow-sm",style:{right:(null!==o?o.getBoundingClientRect().width+6:10)+(null!==r?r.getBoundingClientRect().width:0)},children:[(0,E.jsx)(pr.TableScroll,{className:"text-lg"}),(0,E.jsx)("div",{className:"ml-1 font-mono text-sm",children:n??""})]})})),Hp=(0,vt.PA)((e=>{const{view:t}=e,n=bu(),o=t.grid;return(0,E.jsxs)("div",{className:"relative flex h-5 w-full select-none justify-between border-b border-neutral-200 bg-neutral-100",children:[Boolean(o.scrollHintText)&&(0,E.jsx)(Gp,{view:t}),(0,E.jsx)("div",{}),(0,E.jsxs)("div",{className:"flex h-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full items-center px-2 font-mono text-sm text-neutral-500",children:o.clientDataSource.rowCount?`Rows: ${o.clientDataSource.rowCount}`:""}),void 0!==o.rowLimit&&o.configuration.showWarningForTruncatedResult&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsxs)("div",{className:"flex h-full items-center px-2 text-orange-500",children:[(0,E.jsx)(pr.Warning,{className:"stroke-[3px]"}),(0,E.jsx)("div",{className:"ml-1 text-sm font-semibold",children:`Results truncated to fit within row limit (${o.rowLimit})`})]})]}),(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsxs)("button",{className:"flex h-full items-center p-2",onClick:()=>{o.setPaginationEnabled(!o.isPaginationEnabled)},children:[(0,E.jsx)(kr.A,{checked:o.isPaginationEnabled,classes:{root:"p-0 w-6 h-5 flex items-center",input:"w-2",checked:"!translate-x-2 ease-in-out duration-100 transition",thumb:Mn("w-2 h-2",{"bg-sky-600":o.isPaginationEnabled,"bg-neutral-500":!o.isPaginationEnabled}),switchBase:"p-0.5 mt-1 translate-x-0 ease-in-out duration-100 transition",track:Mn("h-3 w-5 border",{"!bg-sky-100 border-sky-600":o.isPaginationEnabled,"!bg-neutral-100 border-neutral-500":!o.isPaginationEnabled})},disableRipple:!0,disableFocusRipple:!0}),(0,E.jsx)("div",{className:Mn("text-sm",{"text-sky-600":o.isPaginationEnabled,"text-neutral-500":!o.isPaginationEnabled}),children:"Pagination"})]}),t.dataCube.options?.enableCache&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsxs)("button",{className:"flex h-full items-center p-2",onClick:()=>{o.setCachingEnabled(!o.isCachingEnabled).catch((e=>n.alertService.alertUnhandledError(e)))},children:[(0,E.jsx)(kr.A,{checked:o.isCachingEnabled,classes:{root:"p-0 w-6 h-5 flex items-center",input:"w-2",checked:"!translate-x-2 ease-in-out duration-100 transition",thumb:Mn("w-2 h-2",{"bg-sky-600":o.isCachingEnabled,"bg-neutral-500":!o.isCachingEnabled}),switchBase:"p-0.5 mt-1 translate-x-0 ease-in-out duration-100 transition",track:Mn("h-3 w-5 border",{"!bg-sky-100 border-sky-600":o.isCachingEnabled,"!bg-neutral-100 border-neutral-500":!o.isCachingEnabled})},disableRipple:!0,disableFocusRipple:!0,disabled:t.processCacheState.isInProgress,title:t.processCacheState.isInProgress?"Processing cache...":""}),(0,E.jsxs)("div",{className:Mn("flex items-center text-sm",{"text-sky-600":o.isCachingEnabled,"text-neutral-500":!o.isCachingEnabled}),children:["Cache ",(0,E.jsx)(vu,{})]})]})]})]})]})})),Vp=(0,vt.PA)((e=>{const{view:t}=e,n=t.grid;return(0,E.jsx)("div",{className:"relative h-[calc(100%_-_20px)] w-full",children:(0,E.jsx)(Ir.W6,{theme:"legacy",className:"data-cube-grid ag-theme-quartz",rowModelType:"serverSide",serverSideDatasource:n.clientDataSource,context:{view:t},onGridReady:e=>{n.configureClient(e.api).catch((e=>t.alertService.alertUnhandledError(e)))},modules:[yr.JKr,xr.fKx],...Qd(t)})})})),Wp=(0,vt.PA)((e=>{const{view:t}=e,n=t.grid.configuration;return(0,E.jsxs)("div",{className:"h-[calc(100%_-_48px)] w-full",children:[(0,E.jsx)(Up,{configuration:n}),(0,E.jsx)(Vp,{view:t}),(0,E.jsx)(Hp,{view:t})]})})),zp=(0,vt.PA)((e=>{const{view:t}=e;switch(t.info.configuration.gridMode){case Ti.MULTIDIMENSIONAL:return(0,E.jsx)(Bp,{view:t});case Ti.STANDARD:return(0,E.jsx)(Wp,{view:t});default:return(0,E.jsx)("div",{className:"border-t-1 border-b-1 h-[calc(100%_-_48px)] w-full border border-neutral-200 bg-neutral-50"})}}));var $p=n(16481);const Yp=(0,vt.PA)((e=>{const{view:t,taskManager:n}=e,o=t?.taskService.tasks??n?.tasks;return(0,E.jsxs)("div",{className:"flex h-5 w-full justify-between bg-neutral-100",children:[(0,E.jsxs)("div",{className:"flex",children:[(0,E.jsxs)("button",{className:"flex items-center px-2 text-sky-600 hover:text-sky-700 disabled:text-neutral-400",onClick:()=>{t?.editor.display.open(),t?.dataCube.telemetryService.sendTelemetry(Ud.OPEN_EDITOR_PROPERTIES,{...t.engine.getDataFromSource(t.getInitialSource()),openedFrom:Ai.STATUS_BAR})},disabled:!t,children:[(0,E.jsx)(pr.Settings,{className:"text-xl"}),(0,E.jsx)("div",{className:"pl-0.5 underline",children:"Properties"})]}),(0,E.jsx)("div",{className:"flex",children:(0,E.jsxs)("button",{className:"flex items-center text-sky-600 hover:text-sky-700 disabled:text-neutral-400",onClick:()=>{t?.filter.display.open(),t?.dataCube.telemetryService.sendTelemetry(Ud.OPEN_EDITOR_FILTER,{...t.engine.getDataFromSource(t.getInitialSource()),openedFrom:Ai.STATUS_BAR})},disabled:!t||ea(t.info.configuration.gridMode),children:[(0,E.jsx)(pr.TableFilter,{className:"text-lg"}),(0,E.jsx)("div",{className:"pl-0.5 underline",children:"Filter"})]})})]}),(0,E.jsx)("div",{className:"flex items-center px-2",children:(0,E.jsx)("div",{className:"flex h-3.5 w-48 border-[0.5px] border-neutral-300",title:void 0!==o&&o.length>0?o.length>1?o.map(((e,t)=>`Task ${t+1}/${o.length}: ${e.description}`)).join("\n"):N(o,0).description:void 0,children:void 0!==o&&o.length>0&&(0,E.jsx)($p.A,{classes:{root:"h-3.5 w-full bg-transparent",bar1Indeterminate:"bg-green-500",bar2Indeterminate:"bg-green-500"},variant:"indeterminate"})})})]})}));var Xp;!function(e){e.SEPARATOR="separator"}(Xp||(Xp={}));const Kp=(0,vt.PA)((e=>{const{children:t,title:n,menuItems:o,getMenuItems:r}=e,[i,a,s]=pu(),[l,c]=(0,Ft.useState)([...o??[]]);return(0,E.jsxs)("div",{className:"flex h-7 w-full bg-neutral-100",children:[(0,E.jsxs)("div",{className:"flex w-fit max-w-80 items-center pl-1 pr-2 text-lg font-medium",children:[(0,E.jsx)(pr.Cube,{className:"mr-1 h-4 w-4 flex-shrink-0"}),(0,E.jsx)("div",{className:"truncate",children:n})]}),(0,E.jsxs)("div",{className:"flex w-full flex-auto",children:[t,(0,E.jsx)("button",{className:"flex aspect-square h-full flex-shrink-0 items-center justify-center text-lg disabled:text-neutral-400",onClick:e=>{const t=r?.()??[];t.length&&t.unshift(Xp.SEPARATOR),c([...o??[],...t]),i(e)},disabled:!o?.length,children:(0,E.jsx)(pr.Menu,{})}),(0,E.jsx)(mu,{...s,menuProps:{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},classes:{paper:"rounded-none mt-[1px]",list:"w-40 p-0 rounded-none border border-neutral-400 bg-white overflow-y-auto py-0.5"}},children:l.map(((e,t)=>V(e)?(0,E.jsx)(gu,{className:"flex h-[22px] w-full items-center px-2.5 text-base hover:bg-neutral-100 focus:bg-neutral-100",onClick:()=>{e.action(),a()},disabled:Boolean(e.disabled),children:e.label},t):e===Xp.SEPARATOR?(0,E.jsx)("div",{className:"my-1 h-[1px] w-full bg-neutral-200"},t):null))})]})]})}));var qp;!function(e){e.PLACEHOLDER="legend-data-cube__placeholder"}(qp||(qp={}));const Jp=e=>{const{message:t,prompt:n}=e;return(0,E.jsxs)("div",{className:"flex h-full w-full overflow-auto p-5",children:[(0,E.jsx)("div",{className:"mr-3",children:(0,E.jsx)(pr.AlertError,{className:"flex-shrink-0 stroke-[0.5px] text-[40px] text-red-500"})}),(0,E.jsxs)("div",{children:[(0,E.jsx)("div",{className:"whitespace-break-spaces text-lg",children:t}),(0,E.jsx)("div",{className:"mt-1 whitespace-break-spaces text-neutral-500",children:n})]})]})},Qp=(0,vt.PA)((e=>{const{children:t,taskManager:n}=e;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"h-[calc(100%_-_48px)] w-full border border-x-0 border-neutral-200 bg-neutral-50",children:t??null}),(0,E.jsx)(Yp,{taskManager:n})]})})),Zp=(0,vt.PA)((e=>{const{children:t,title:n,menuItems:o,headerContent:r,layoutManager:i,taskManager:a}=e;return(0,E.jsxs)("div",{className:"data-cube relative flex h-full w-full flex-col bg-white","data-testid":qp.PLACEHOLDER,children:[(0,E.jsx)(Kp,{title:n,menuItems:o,children:r??null}),(0,E.jsx)(Qp,{taskManager:a,children:t}),i?(0,E.jsx)(Tr,{layout:i}):null,(0,E.jsx)(Ar,{})]})})),em=(0,vt.PA)((e=>{const{view:t}=e;return(0,Ft.useEffect)((()=>()=>t.dispose()),[t]),t.initializeState.hasFailed?(0,E.jsx)(Qp,{children:(0,E.jsx)(Jp,{message:"Initialization Failure",prompt:"Resolve the issue and reload."})}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(zp,{view:t}),(0,E.jsx)(Yp,{view:t})]})}));class tm{_startTime=Date.now();_time=this._startTime;_records=new Map;record(e){const t=Date.now(),n=t-this._time;this._time=t,e&&this._records.set(e,n)}getRecord(e){return D(this._records.get(e),`Can't find record for event '${e}'`)}get startTime(){return this._startTime}get elapsed(){return Date.now()-this._startTime}get records(){return new Map(this._records)}}var nm=n(61005);class om{_engine;_settingService;_snapshotService;_latestSnapshot;constructor(e,t,n){this._engine=e,this._settingService=t,this._snapshotService=n}getLatestSnapshot(){return this._latestSnapshot}async receiveSnapshot(e){const t=this._latestSnapshot;this._latestSnapshot=e,await this.applySnapshot(e.INTERNAL__fullClone(),t)}publishSnapshot(e){const t=this._latestSnapshot;this._latestSnapshot=e,this._settingService.getBooleanValue(Uu.DEBUGGER__ENABLE_DEBUG_MODE)&&this._engine.debugProcess("New Snapshot",["Publisher",this.getSnapshotSubscriberName()],["Snapshot",e.serialize()],["Previous Snapshot",t?.serialize()],["Diff",(0,nm.A)(t??{},e)]),this._snapshotService.broadcastSnapshot(e)}}class rm{_logService;_settingService;_subscribers=[];_snapshots=[];_pointer=-1;_historySize;constructor(e,t){(0,Ie.Gn)(this,{_snapshots:Ie.sH.struct,_pointer:Ie.sH,canUndo:Ie.EW,canRedo:Ie.EW,undo:Ie.XI,redo:Ie.XI,adjustHistorySize:Ie.XI,broadcastSnapshot:Ie.XI}),this._logService=e,this._settingService=t,this._historySize=Math.max(this._settingService.getNumericValue(Uu.EDITOR__MAX_HISTORY_STACK_SIZE),10)}registerSubscriber(e){if(this._subscribers.find((t=>t.getSnapshotSubscriberName()===e.getSnapshotSubscriberName())))throw new x(`Subscriber with name '${e.getSnapshotSubscriberName()}' already exists`);this._subscribers.push(e)}propagateSnapshot(e){this._subscribers.forEach((t=>{const n=t.getLatestSnapshot();n?.uuid!==e.uuid&&t.receiveSnapshot(e).catch((e=>{w(e),this._logService.logIllegalStateError("Error occured while subscribers receiving and applying new snapshot should be handled gracefully",e)}))}))}getCurrentSnapshot(){return N(this._snapshots,this._pointer)}getHistory(e){return e?.full?[...this._snapshots]:this._snapshots.slice(0,this._pointer+1)}get canUndo(){return this._pointer>0}get canRedo(){return this._pointer<this._snapshots.length-1}undo(){this._pointer=Math.max(this._pointer-1,0),this.propagateSnapshot(this.getCurrentSnapshot())}redo(){this._pointer=Math.min(this._pointer+1,this._snapshots.length-1),this.propagateSnapshot(this.getCurrentSnapshot())}adjustHistorySize(e){let t=e;e<=10&&(this._logService.logIllegalStateError(`Can't adjust history size to ${e}: value must be greator than 10`),t=Math.max(e,10));const n=this.getHistory();n.length>t?(this._snapshots=n.slice(-t),this._pointer=Math.min(Math.max(this._pointer-(n.length-t),0),n.length-1)):(this._snapshots=n,this._pointer=n.length-1),this._historySize=t}broadcastSnapshot(e){e.isFinalized()?(this._snapshots=[...this._snapshots.slice(0,this._pointer+1),e],this._pointer+=1,this.adjustHistorySize(this._historySize),this.propagateSnapshot(e)):this._logService.logIllegalStateError("Snapshot must be finalized before broadcasting")}}var im=n(43322);class am{uuid=(0,i.A)();parent;not=!1;constructor(e,t){(0,Ie.Gn)(this,{parent:Ie.sH,setParent:Ie.XI,not:Ie.sH,setNot:Ie.XI}),this.parent=e,this.not=Boolean(t)}setNot(e){this.not=e}setParent(e){this.parent=e}}class sm extends am{column;operation;value;constructor(e,t,n,o,r){super(e,r),(0,Ie.Gn)(this,{column:Ie.sH,setColumn:Ie.XI,operation:Ie.sH,setOperation:Ie.XI,value:Ie.sH.ref,setValue:Ie.XI,updateValue:Ie.XI}),this.column=t,this.operation=n,this.setValue(o)}setColumn(e){this.column=e}setOperation(e){this.operation=e}setValue(e){this.value=(0,Ie.AT)(e)?e:(0,Ie.Gn)(e,{value:Ie.sH})}updateValue(e){this.value.value=e}}class lm extends am{children=[];operation=Ci.AND;constructor(e,t,n){super(e,n),(0,Ie.Gn)(this,{children:Ie.sH,removeChild:Ie.XI,addChild:Ie.XI,operation:Ie.sH,setOperation:Ie.XI}),this.operation=t}setOperation(e){this.operation=e}removeChild(e){S(this.children,e)&&e.setParent(void 0)}addChild(e,t){this.children.includes(e)||(void 0!==t?(t=Math.max(0,Math.min(t,this.children.length)),this.children.splice(t,0,e)):this.children.push(e),e.setParent(this))}}function cm(e){return{groupOperator:e.operation,not:e.not,conditions:e.children.map((e=>{if(e instanceof sm)return{name:e.column.name,type:e.column.type,operator:e.operation.operator,value:(0,im.A)(e.value),not:e.not};if(e instanceof lm)return cm(e);throw new x("Unknown filter node")}))}}function um(e,t,n,o){const r=new lm(t,e.groupOperator===Ci.AND?Ci.AND:Ci.OR,e.not);return e.conditions.forEach((e=>{let t;t="groupOperator"in e?um(e,r,n,o):new sm(r,{name:e.name,type:e.type},o(e.operator),e.value,e.not),r.addChild(t),n.set(t.uuid,t)})),n.set(r.uuid,r),r}class dm{name;type;constructor(e,t){this.name=e,this.type=t}}class pm{_editor;selectedColumns=[];availableColumnsSearchText="";selectedColumnsSearchText="";onChange;constructor(e,t){(0,Ie.Gn)(this,{availableColumns:Ie.EW,availableColumnsForDisplay:Ie.EW,selectedColumnsForDisplay:Ie.EW,selectedColumns:Ie.sH,setSelectedColumns:Ie.XI,availableColumnsSearchText:Ie.sH,setAvailableColumnsSearchText:Ie.XI,selectedColumnsSearchText:Ie.sH,setSelectedColumnsSearchText:Ie.XI}),this._editor=e,this.onChange=t?.onChange}get availableColumnsForDisplay(){return this.availableColumns.filter((e=>!ra(this.selectedColumns,e.name))).sort(aa)}get selectedColumnsForDisplay(){return this.selectedColumns}setSelectedColumns(e){this.selectedColumns=e.map((e=>this.cloneColumn(e))),this.onChange?.(this)}setAvailableColumnsSearchText(e){this.availableColumnsSearchText=e}setSelectedColumnsSearchText(e){this.selectedColumnsSearchText=e}getColumn(e){return D(ra(this.availableColumns,e),`Can't find column '${e}'`)}}class mm extends dm{onChange;direction;constructor(e,t,n,o){super(e,t),(0,Ie.Gn)(this,{direction:Ie.sH,setDirection:Ie.XI}),this.direction=n,this.onChange=o}setDirection(e){this.direction=e,this.onChange?.()}}class gm extends pm{cloneColumn(e){return new mm(e.name,e.type,e.direction)}get availableColumns(){return(0,nt.A)([...this._editor.horizontalPivots.selector.selectedColumns.length?[...this._editor.horizontalPivots.pivotResultColumns,...[...this._editor.columns.selector.selectedColumns,...this._editor.verticalPivots.selector.selectedColumns].filter((e=>this._editor.columnProperties.getColumnConfiguration(e.name).kind===mi.DIMENSION&&!ra(this._editor.horizontalPivots.selector.selectedColumns,e.name)))]:[...this._editor.columns.selector.selectedColumns,...this._editor.verticalPivots.selector.selectedColumns],...this._editor.groupExtendColumns],(e=>e.name)).map((e=>new mm(e.name,e.type,bi.ASCENDING)))}}class hm{selector;constructor(e){this.selector=new gm(e)}adaptPropagatedChanges(){this.selector.setSelectedColumns(this.selector.selectedColumns.filter((e=>ra(this.selector.availableColumns,e.name))))}applySnaphot(e,t){this.selector.setSelectedColumns(e.data.sortColumns.map((e=>{const t=this.selector.getColumn(e.name);return new mm(t.name,t.type,e.direction)})))}buildSnapshot(e,t){e.data.sortColumns=this.selector.selectedColumns.map((e=>({...ia(e),direction:e.direction})))}}class fm extends sa{dataType;aggregateOperation;static create(e,t,n){const o=Object.assign(new fm("",""),sa.serialization.fromJson(e));return o.dataType=Qi(o.type),o.aggregateOperation=Ji(o.aggregateOperator,n),(0,Ie.Gn)(o,{kind:Ie.sH,setKind:Ie.XI,displayName:Ie.sH,setDisplayName:Ie.XI,decimals:Ie.sH,setDecimals:Ie.XI,displayCommas:Ie.sH,setDisplayCommas:Ie.XI,negativeNumberInParens:Ie.sH,setNegativeNumberInParens:Ie.XI,numberScale:Ie.sH,setNumberScale:Ie.XI,missingValueDisplayText:Ie.sH,setMissingValueDisplayText:Ie.XI,unit:Ie.sH,setUnit:Ie.XI,fontFamily:Ie.sH,setFontFamily:Ie.XI,fontSize:Ie.sH,setFontSize:Ie.XI,fontBold:Ie.sH,setFontBold:Ie.XI,fontItalic:Ie.sH,setFontItalic:Ie.XI,fontUnderline:Ie.sH,setFontUnderline:Ie.XI,fontStrikethrough:Ie.sH,setFontStrikethrough:Ie.XI,fontCase:Ie.sH,setFontCase:Ie.XI,textAlign:Ie.sH,setTextAlign:Ie.XI,normalForegroundColor:Ie.sH,setNormalForegroundColor:Ie.XI,negativeForegroundColor:Ie.sH,setNegativeForegroundColor:Ie.XI,zeroForegroundColor:Ie.sH,setZeroForegroundColor:Ie.XI,errorForegroundColor:Ie.sH,setErrorForegroundColor:Ie.XI,normalBackgroundColor:Ie.sH,setNormalBackgroundColor:Ie.XI,negativeBackgroundColor:Ie.sH,setNegativeBackgroundColor:Ie.XI,zeroBackgroundColor:Ie.sH,setZeroBackgroundColor:Ie.XI,errorBackgroundColor:Ie.sH,setErrorBackgroundColor:Ie.XI,isSelected:Ie.sH,setIsSelected:Ie.XI,hideFromView:Ie.sH,setHideFromView:Ie.XI,blur:Ie.sH,setBlur:Ie.XI,fixedWidth:Ie.sH,setFixedWidth:Ie.XI,minWidth:Ie.sH,setMinWidth:Ie.XI,maxWidth:Ie.sH,setMaxWidth:Ie.XI,pinned:Ie.sH,setPinned:Ie.XI,displayAsLink:Ie.sH,setDisplayAsLink:Ie.XI,linkLabelParameter:Ie.sH,setLinkLabelParameter:Ie.XI,isUsingDefaultStyling:Ie.EW,useDefaultStyling:Ie.XI,aggregateOperator:Ie.sH,aggregateOperation:Ie.sH,setAggregateOperation:Ie.XI,aggregationParameters:Ie.sH,setAggregationParameters:Ie.XI,excludedFromPivot:Ie.sH,setExcludedFromPivot:Ie.XI,pivotSortDirection:Ie.sH,setPivotSortDirection:Ie.XI,pivotStatisticColumnFunction:Ie.sH,setPivotStatisticColumnFunction:Ie.XI}),o}get isUsingDefaultStyling(){return void 0===this.fontFamily&&void 0===this.fontSize&&void 0===this.fontBold&&void 0===this.fontItalic&&void 0===this.fontUnderline&&void 0===this.fontStrikethrough&&void 0===this.textAlign&&void 0===this.normalForegroundColor&&void 0===this.negativeForegroundColor&&void 0===this.zeroForegroundColor&&void 0===this.errorForegroundColor&&void 0===this.normalBackgroundColor&&void 0===this.negativeBackgroundColor&&void 0===this.zeroBackgroundColor&&void 0===this.errorBackgroundColor}useDefaultStyling(){this.fontFamily=void 0,this.fontSize=void 0,this.fontBold=void 0,this.fontItalic=void 0,this.fontUnderline=void 0,this.fontStrikethrough=void 0,this.textAlign=void 0,this.normalForegroundColor=void 0,this.negativeForegroundColor=void 0,this.zeroForegroundColor=void 0,this.errorForegroundColor=void 0,this.normalBackgroundColor=void 0,this.negativeBackgroundColor=void 0,this.zeroBackgroundColor=void 0,this.errorBackgroundColor=void 0}setKind(e){this.kind=e}setDisplayName(e){this.displayName=e}setDecimals(e){this.decimals=e}setDisplayCommas(e){this.displayCommas=e}setNegativeNumberInParens(e){this.negativeNumberInParens=e}setNumberScale(e){this.numberScale=e}setMissingValueDisplayText(e){this.missingValueDisplayText=e}setUnit(e){this.unit=e}setFontFamily(e){this.fontFamily=e}setFontSize(e){this.fontSize=e}setFontBold(e){this.fontBold=e}setFontItalic(e){this.fontItalic=e}setFontUnderline(e){this.fontUnderline=e}setFontStrikethrough(e){this.fontStrikethrough=e}setFontCase(e){this.fontCase=e}setTextAlign(e){this.textAlign=e}setNormalForegroundColor(e){this.normalForegroundColor=e}setNegativeForegroundColor(e){this.negativeForegroundColor=e}setZeroForegroundColor(e){this.zeroForegroundColor=e}setErrorForegroundColor(e){this.errorForegroundColor=e}setNormalBackgroundColor(e){this.normalBackgroundColor=e}setNegativeBackgroundColor(e){this.negativeBackgroundColor=e}setZeroBackgroundColor(e){this.zeroBackgroundColor=e}setErrorBackgroundColor(e){this.errorBackgroundColor=e}setIsSelected(e){this.isSelected=e}setHideFromView(e){this.hideFromView=e}setBlur(e){this.blur=e}setFixedWidth(e){this.fixedWidth=e}setMinWidth(e){this.minWidth=e}setMaxWidth(e){this.maxWidth=e}setPinned(e){this.pinned=e}setDisplayAsLink(e){this.displayAsLink=e}setLinkLabelParameter(e){this.linkLabelParameter=e}setAggregateOperation(e){this.aggregateOperation=e,this.aggregateOperator=e.operator}setAggregationParameters(e){this.aggregationParameters=e}setExcludedFromPivot(e){this.excludedFromPivot=e}setPivotSortDirection(e){this.pivotSortDirection=e}setPivotStatisticColumnFunction(e){this.pivotStatisticColumnFunction=e}}class Em extends la{static create(e){const t=Object.assign(new Em,la.serialization.fromJson(e));return(0,Ie.Gn)(t,{expandedPaths:Ie.sH,setExpandedPaths:Ie.XI}),t}setExpandedPaths(e){this.expandedPaths=e}}class Cm extends da{static create(e){const t=Object.assign(new Cm,da.serialization.fromJson(e));return t.columns=[],(0,Ie.Gn)(t,{name:Ie.sH,setName:Ie.XI,description:Ie.sH,setDescription:Ie.XI,showHorizontalGridLines:Ie.sH,setShowHorizontalGridLines:Ie.XI,showVerticalGridLines:Ie.sH,setShowVerticalGridLines:Ie.XI,gridLineColor:Ie.sH,setGridLineColor:Ie.XI,gridMode:Ie.sH,setGridMode:Ie.XI,fontFamily:Ie.sH,setFontFamily:Ie.XI,fontSize:Ie.sH,setFontSize:Ie.XI,fontBold:Ie.sH,setFontBold:Ie.XI,fontItalic:Ie.sH,setFontItalic:Ie.XI,fontUnderline:Ie.sH,setFontUnderline:Ie.XI,fontStrikethrough:Ie.sH,setFontStrikethrough:Ie.XI,fontCase:Ie.sH,setFontCase:Ie.XI,textAlign:Ie.sH,setTextAlign:Ie.XI,normalForegroundColor:Ie.sH,setNormalForegroundColor:Ie.XI,negativeForegroundColor:Ie.sH,setNegativeForegroundColor:Ie.XI,zeroForegroundColor:Ie.sH,setZeroForegroundColor:Ie.XI,errorForegroundColor:Ie.sH,setErrorForegroundColor:Ie.XI,normalBackgroundColor:Ie.sH,setNormalBackgroundColor:Ie.XI,negativeBackgroundColor:Ie.sH,setNegativeBackgroundColor:Ie.XI,zeroBackgroundColor:Ie.sH,setZeroBackgroundColor:Ie.XI,errorBackgroundColor:Ie.sH,setErrorBackgroundColor:Ie.XI,alternateRows:Ie.sH,setAlternateRows:Ie.XI,alternateRowsColor:Ie.sH,setAlternateRowsColor:Ie.XI,alternateRowsCount:Ie.sH,setAlternateRowsCount:Ie.XI,alternateRowsStandardMode:Ie.sH,setAlternateRowsStandardMode:Ie.XI,showSelectionStats:Ie.sH,setShowSelectionStats:Ie.XI,showWarningForTruncatedResult:Ie.sH,setShowWarningForTruncatedResult:Ie.XI,initialExpandLevel:Ie.sH,setInitialExpandLevel:Ie.XI,showRootAggregation:Ie.sH,setShowRootAggregation:Ie.XI,showLeafCount:Ie.sH,setShowLeafCount:Ie.XI,treeColumnSortDirection:Ie.sH,setTreeColumnSortDirection:Ie.XI,pivotStatisticColumnName:Ie.sH,setPivotStatisticColumnName:Ie.XI,pivotStatisticColumnPlacement:Ie.sH,setPivotStatisticColumnPlacement:Ie.XI,isUsingDefaultStyling:Ie.EW,useDefaultStyling:Ie.XI}),t}get isUsingDefaultStyling(){return this.fontFamily===Bi&&11===this.fontSize&&this.fontBold===ji&&this.fontItalic===Mi&&this.fontUnderline===Ui&&this.fontStrikethrough===Gi&&this.textAlign===Hi&&this.normalForegroundColor===Vi&&this.negativeForegroundColor===$i&&this.zeroForegroundColor===Yi&&this.errorForegroundColor===Xi&&this.normalBackgroundColor===Wi&&this.negativeBackgroundColor===Wi&&this.zeroBackgroundColor===Wi&&this.errorBackgroundColor===Wi}useDefaultStyling(){this.fontFamily=Bi,this.fontSize=11,this.fontBold=ji,this.fontItalic=Mi,this.fontUnderline=Ui,this.fontStrikethrough=Gi,this.textAlign=Hi,this.normalForegroundColor=Vi,this.negativeForegroundColor=$i,this.zeroForegroundColor=Yi,this.errorForegroundColor=Xi,this.normalBackgroundColor=Wi,this.negativeBackgroundColor=Wi,this.zeroBackgroundColor=Wi,this.errorBackgroundColor=Wi}setName(e){this.name=e}setDescription(e){this.description=e}setShowHorizontalGridLines(e){this.showHorizontalGridLines=e}setShowVerticalGridLines(e){this.showVerticalGridLines=e}setGridLineColor(e){this.gridLineColor=e}setGridMode(e){this.gridMode=e}setFontFamily(e){this.fontFamily=e}setFontSize(e){this.fontSize=e}setFontBold(e){this.fontBold=e}setFontItalic(e){this.fontItalic=e}setFontUnderline(e){this.fontUnderline=e}setFontStrikethrough(e){this.fontStrikethrough=e}setFontCase(e){this.fontCase=e}setTextAlign(e){this.textAlign=e}setNormalForegroundColor(e){this.normalForegroundColor=e}setNegativeForegroundColor(e){this.negativeForegroundColor=e}setZeroForegroundColor(e){this.zeroForegroundColor=e}setErrorForegroundColor(e){this.errorForegroundColor=e}setNormalBackgroundColor(e){this.normalBackgroundColor=e}setNegativeBackgroundColor(e){this.negativeBackgroundColor=e}setZeroBackgroundColor(e){this.zeroBackgroundColor=e}setErrorBackgroundColor(e){this.errorBackgroundColor=e}setAlternateRows(e){this.alternateRows=e}setAlternateRowsColor(e){this.alternateRowsColor=e}setAlternateRowsCount(e){this.alternateRowsCount=e}setAlternateRowsStandardMode(e){this.alternateRowsStandardMode=e}setShowSelectionStats(e){this.showSelectionStats=e}setShowWarningForTruncatedResult(e){this.showWarningForTruncatedResult=e}setInitialExpandLevel(e){this.initialExpandLevel=e}setShowRootAggregation(e){this.showRootAggregation=e}setShowLeafCount(e){this.showLeafCount=e}setTreeColumnSortDirection(e){this.treeColumnSortDirection=e}setPivotStatisticColumnPlacement(e){this.pivotStatisticColumnPlacement=e}setPivotStatisticColumnName(e){this.pivotStatisticColumnName=e}setExpandedPaths(e){this.pivotLayout.expandedPaths=e}}class bm{limit=void 0;configuration=new Cm;constructor(e){(0,Ie.Gn)(this,{configuration:Ie.sH,limit:Ie.sH,setLimit:Ie.XI,applySnaphot:Ie.XI})}setLimit(e){this.limit=e}applySnaphot(e,t){this.setLimit(void 0!==e.data.limit&&e.data.limit>=0?e.data.limit:void 0),this.configuration=Cm.create(e.data.configuration)}buildSnapshot(e,t){const n=e.data;n.limit=void 0===this.limit||this.limit<0?void 0:this.limit,n.configuration=this.configuration.serialize()}}class vm{_view;columns=[];selectedColumnName;showAdvancedSettings=!1;constructor(e){(0,Ie.Gn)(this,{columns:Ie.sH,setColumns:Ie.XI,selectedColumnName:Ie.sH,setSelectedColumnName:Ie.XI,selectedColumn:Ie.EW,showAdvancedSettings:Ie.sH,setShowAdvancedSettings:Ie.XI,applySnaphot:Ie.XI}),this._view=e.view}getColumnConfiguration(e){return D(ra(this.columns,e),`Can't find configuration for column '${e}'`)}setColumns(e){this.columns=e}setSelectedColumnName(e){this.selectedColumnName=e}get selectedColumn(){return ra(this.columns,this.selectedColumnName)}setShowAdvancedSettings(e){this.showAdvancedSettings=e}applySnaphot(e,t){this.setColumns(e.data.configuration.columns.map((t=>fm.create(t,e,this._view.engine.aggregateOperations)))),!this.selectedColumn&&this.columns.length&&this.setSelectedColumnName(N(this.columns,0).name)}buildSnapshot(e,t){e.data.configuration={...e.data.configuration,columns:this.columns.map((e=>e.serialize()))}}}class _m extends pm{showHiddenColumns=!1;constructor(e,t){super(e,t),(0,Ie.Gn)(this,{availableColumnsForDisplay:Ie.$Z,selectedColumnsForDisplay:Ie.$Z,showHiddenColumns:Ie.sH,setShowHiddenColumns:Ie.XI})}cloneColumn(e){return new dm(e.name,e.type)}get availableColumns(){return[...this._editor.sourceColumns,...this._editor.leafExtendColumns,...this._editor.groupExtendColumns].map((e=>new dm(e.name,e.type)))}get availableColumnsForDisplay(){return super.availableColumnsForDisplay.filter((e=>this.showHiddenColumns||!this._editor.columnProperties.getColumnConfiguration(e.name).hideFromView))}get selectedColumnsForDisplay(){return super.selectedColumnsForDisplay.filter((e=>this.showHiddenColumns||!this._editor.columnProperties.getColumnConfiguration(e.name).hideFromView))}setShowHiddenColumns(e){this.showHiddenColumns=e}}class Tm{_editor;selector;constructor(e){(0,Ie.Gn)(this,{applySnaphot:Ie.XI}),this._editor=e,this.selector=new _m(e,{onChange:e=>{const t=e.selectedColumns.map((e=>this._editor.columnProperties.getColumnConfiguration(e.name))),n=this._editor.columnProperties.columns.filter((e=>!t.includes(e)));t.forEach((e=>e.setIsSelected(!0))),n.forEach((e=>e.setIsSelected(!1))),this._editor.columnProperties.setColumns([...t,...n])}})}propagateChanges(){this._editor.sorts.adaptPropagatedChanges()}applySnaphot(e,t){this.selector.setSelectedColumns(this._editor.columnProperties.columns.filter((e=>e.isSelected)).map((e=>{const t=this.selector.getColumn(e.name);return new dm(t.name,t.type)})))}buildSnapshot(e,t){this.propagateChanges(),e.data.selectColumns=this.selector.selectedColumns.filter((e=>!ra(this._editor.groupExtendColumns,e.name))).map(ia)}}class Nm extends pm{cloneColumn(e){return new dm(e.name,e.type)}get availableColumns(){return this._editor.columnProperties.columns.filter((e=>e.kind===mi.DIMENSION&&!ra(this._editor.groupExtendColumns,e.name)&&!ra(this._editor.horizontalPivots.selector.selectedColumns,e.name))).map((e=>new dm(e.name,e.type)))}}class Sm{selector;constructor(e){this.selector=new Nm(e)}adaptPropagatedChanges(){this.selector.setSelectedColumns(this.selector.selectedColumns.filter((e=>ra(this.selector.availableColumns,e.name))))}applySnaphot(e,t){this.selector.setSelectedColumns((e.data.groupBy?.columns??[]).map((e=>new dm(e.name,e.type))))}buildSnapshot(e,t){e.data.groupBy=this.selector.selectedColumns.length?{columns:this.selector.selectedColumns.map(ia)}:void 0,e.data.selectColumns=(0,nt.A)([...e.data.selectColumns,...this.selector.selectedColumns],(e=>e.name)).map(ia)}}function Am(){return{modules:[yr.JKr],theme:"legacy",className:"ag-theme-quartz",animateRows:!1,getRowId:e=>e.data.name,editType:"fullRow",rowDragMultiRow:!0,rowDragEntireRow:!0,rowSelection:{mode:"multiRow",checkboxes:!0,headerCheckbox:!0,enableClickSelection:!0},selectionColumnDef:{width:40,headerClass:"pl-6",cellClass:"pl-1.5",rowDrag:!0,rowDragText:(e,t)=>t>1?`${t} columns`:(e.rowNode?.data).name,sortable:!1,resizable:!1,suppressHeaderMenuButton:!0},suppressMoveWhenRowDragging:!0,rowHeight:20,headerHeight:20,suppressRowHoverHighlight:!1,noRowsOverlayComponent:e=>e.api.getQuickFilter()?(0,E.jsxs)("div",{className:"flex items-center border-[1.5px] border-neutral-300 p-2 font-semibold text-neutral-400",children:[(0,E.jsx)("div",{children:(0,E.jsx)(pr.WarningCircle,{className:"mr-1 text-lg"})}),"No match found"]}):e.noColumnsSelectedRenderer?e.noColumnsSelectedRenderer():(0,E.jsx)("div",{}),onModelUpdated:e=>{0===e.api.getDisplayedRowCount()?e.api.showNoRowsOverlay():e.api.hideOverlay()}}}const ym=(0,vt.PA)((function(e){const{selector:t,gridApi:n,scope:o}=e;return(0,E.jsxs)("div",{className:"flex items-center justify-center rounded-lg bg-neutral-500 px-1 py-0.5 font-mono text-xs font-bold text-white",children:[`${kp(n).length}/${"available"===o?t.availableColumnsForDisplay.length:t.selectedColumnsForDisplay.length}`,(0,E.jsx)("span",{className:"hidden",children:"available"===o?t.availableColumnsSearchText:t.selectedColumnsSearchText})]})})),xm=(0,vt.PA)((function(e){const{selector:t,columnLabelRenderer:n,columnActionRenderer:o,noColumnsSelectedRenderer:r}=e,[i,a]=(0,Ft.useState)([]),[s,l]=(0,Ft.useState)([]),[c,u]=(0,Ft.useState)(null),[d,p]=(0,Ft.useState)(null),m=(0,Ft.useRef)(null),g=(0,Ft.useRef)(null),h=(0,Ft.useCallback)((e=>{const n=e.nodes.map((e=>e.data)).filter(L);t.setSelectedColumns(t.selectedColumns.filter((e=>!ra(n,e.name))))}),[t]),f=(0,Ft.useCallback)((e=>{t.setSelectedColumns(wp(e.api))}),[t]),C=(0,Ft.useCallback)((e=>{-1!==e.overIndex&&t.setSelectedColumns(wp(e.api))}),[t]);return(0,Ft.useEffect)((()=>{if(!c||!d)return;const e=d.isDestroyed()?void 0:d.getRowDropZoneParams({onDragStop:e=>{f(e),c.clearFocusedCell()}});e&&!c.isDestroyed()&&c.addRowDropZone(e);const t=c.isDestroyed()?void 0:c.getRowDropZoneParams({onDragStop:e=>{h(e),d.clearFocusedCell()}});t&&!d.isDestroyed()&&d.addRowDropZone(t)}),[c,d,f,h]),(0,E.jsxs)("div",{className:"data-cube-column-selector flex h-full w-full",children:[(0,E.jsxs)("div",{className:"h-full w-[calc(50%_-_20px)]",children:[(0,E.jsx)("div",{className:"flex h-5 items-center text-sm",children:"Available columns:"}),(0,E.jsxs)("div",{className:"h-[calc(100%_-_20px)] rounded-sm border border-neutral-200",children:[(0,E.jsxs)("div",{className:"relative h-6 border-b border-neutral-200",children:[(0,E.jsx)("input",{className:"h-full w-full pl-10 pr-6 placeholder-neutral-400",ref:m,placeholder:"Search columns...",value:t.availableColumnsSearchText,onChange:e=>t.setAvailableColumnsSearchText(e.target.value),onKeyDown:e=>{"Escape"===e.code&&(e.stopPropagation(),m.current?.select(),t.setAvailableColumnsSearchText(""))}}),(0,E.jsx)("div",{className:"absolute left-0 top-0 flex h-6 w-10 items-center justify-center",children:(0,E.jsx)(pr.Search,{className:"stroke-[3px] text-lg text-neutral-500"})}),(0,E.jsx)("button",{className:"absolute right-0 top-0 flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",disabled:!t.availableColumnsSearchText,title:"Clear search [Esc]",onClick:()=>{t.setAvailableColumnsSearchText(""),m.current?.focus()},children:(0,E.jsx)(pr.X,{className:"text-lg"})})]}),(0,E.jsx)("div",{className:"h-[calc(100%_-_24px)]",children:(0,E.jsx)(Ir.W6,{...Am(),rowDragManaged:!1,onGridReady:e=>u(e.api),onSelectionChanged:e=>{a(e.api.getSelectedNodes().map((e=>e.data)).filter(L))},quickFilterText:t.availableColumnsSearchText,rowData:t.availableColumnsForDisplay,columnDefs:[{field:"name",colId:"name",flex:1,minWidth:100,filter:!0,sortable:!1,resizable:!1,suppressHeaderMenuButton:!0,getQuickFilterText:e=>e.value,headerComponent:e=>(0,E.jsxs)("button",{title:"Double-click to add all columns",className:"flex h-full w-full items-center justify-between pl-0.5",onDoubleClick:()=>{const n=kp(e.api);t.setSelectedColumns([...t.selectedColumns,...n]),e.api.clearFocusedCell()},children:[(0,E.jsx)("div",{children:"[All Columns]"}),(0,E.jsx)(ym,{selector:t,gridApi:e.api,scope:"available"})]}),cellRenderer:e=>{const r=e.data;return r?(0,E.jsxs)("div",{className:"flex h-full w-full cursor-pointer items-center",title:`[${r.name}]\nDouble-click to add column`,onDoubleClick:()=>{t.setSelectedColumns([...t.selectedColumns,r]),e.api.clearFocusedCell()},children:[n?.({selector:t,column:r})??(0,E.jsx)("div",{className:"h-full flex-1 items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-2",children:r.name}),(0,E.jsx)("div",{className:"flex h-full",children:o?.({selector:t,column:r})??null})]}):null}}]})})]})]}),(0,E.jsx)("div",{className:"flex h-full w-10 items-center justify-center",children:(0,E.jsxs)("div",{className:"flex flex-col",children:[(0,E.jsx)("button",{className:"flex items-center justify-center rounded-sm border border-neutral-300 bg-neutral-100 text-neutral-500 hover:bg-neutral-200 disabled:bg-neutral-200 disabled:text-neutral-400",title:"Add selected column(s)",onClick:()=>{if(!c||0===i.length)return;const e=kp(c),n=i.filter((t=>ra(e,t.name)));t.setSelectedColumns([...t.selectedColumns,...n]),c.clearFocusedCell()},disabled:!c||0===i.length,children:(0,E.jsx)(pr.ChevronRight,{className:"text-2xl"})}),(0,E.jsx)("button",{className:"mt-2 flex items-center justify-center rounded-sm border border-neutral-300 bg-neutral-100 text-neutral-500 hover:bg-neutral-200 disabled:bg-neutral-200 disabled:text-neutral-400",title:"Remove selected column(s)",onClick:()=>{if(!d||0===s.length)return;const e=kp(d),n=s.filter((t=>ra(e,t.name)));t.setSelectedColumns(t.selectedColumns.filter((e=>!ra(n,e.name)))),d.clearFocusedCell()},disabled:!d||0===s.length,children:(0,E.jsx)(pr.ChevronLeft,{className:"text-2xl"})})]})}),(0,E.jsxs)("div",{className:"h-full w-[calc(50%_-_20px)]",children:[(0,E.jsx)("div",{className:"flex h-5 items-center text-sm",children:"Selected columns:"}),(0,E.jsxs)("div",{className:"h-[calc(100%_-_20px)] rounded-sm border border-neutral-200",children:[(0,E.jsxs)("div",{className:"relative h-6 border-b border-neutral-200",children:[(0,E.jsx)("input",{className:"h-full w-full pl-10 placeholder-neutral-400",ref:g,placeholder:"Search columns...",value:t.selectedColumnsSearchText,onChange:e=>t.setSelectedColumnsSearchText(e.target.value),onKeyDown:e=>{"Escape"===e.code&&(e.stopPropagation(),t.setSelectedColumnsSearchText(""))}}),(0,E.jsx)("div",{className:"absolute left-0 top-0 flex h-6 w-10 items-center justify-center",children:(0,E.jsx)(pr.Search,{className:"stroke-[3px] text-lg text-neutral-500"})}),(0,E.jsx)("button",{className:"absolute right-0 top-0 flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",disabled:!t.selectedColumnsSearchText,title:"Clear search [Esc]",onClick:()=>{t.setSelectedColumnsSearchText(""),g.current?.focus()},children:(0,E.jsx)(pr.X,{className:"text-lg"})})]}),(0,E.jsx)("div",{className:"h-[calc(100%_-_24px)]",children:(0,E.jsx)(Ir.W6,{...Am(),rowDragManaged:!0,onRowDragEnd:C,onGridReady:e=>p(e.api),onSelectionChanged:e=>{l(e.api.getSelectedNodes().map((e=>e.data)).filter(L))},quickFilterText:t.selectedColumnsSearchText,noRowsOverlayComponentParams:{noColumnsSelectedRenderer:r},rowData:t.selectedColumnsForDisplay,columnDefs:[{field:"name",colId:"name",flex:1,minWidth:100,filter:!0,sortable:!1,resizable:!1,suppressHeaderMenuButton:!0,getQuickFilterText:e=>e.value,headerComponent:e=>(0,E.jsxs)("button",{title:"Double-click to remove all columns",className:"flex h-full w-full items-center justify-between pl-0.5",onDoubleClick:()=>{const n=kp(e.api);t.setSelectedColumns(t.selectedColumns.filter((e=>!ra(n,e.name)))),e.api.clearFocusedCell()},children:[(0,E.jsx)("div",{children:"[All Columns]"}),(0,E.jsx)(ym,{selector:t,gridApi:e.api,scope:"selected"})]}),cellRenderer:e=>{const r=e.data;return r?(0,E.jsxs)("div",{className:"flex h-full w-full cursor-pointer items-center",title:`[${r.name}]\nDouble-click to remove column`,onDoubleClick:()=>{t.setSelectedColumns(t.selectedColumns.filter((e=>e!==r))),e.api.clearFocusedCell()},children:[n?.({selector:t,column:r})??(0,E.jsx)("div",{className:"h-full flex-1 items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-2",children:r.name}),(0,E.jsx)("div",{className:"flex h-full",children:o?.({selector:t,column:r})??null})]}):null}}]})})]})]})]})})),Im=(0,vt.PA)((e=>{const{column:t}=e,[n,o,r,i]=pu();return(0,E.jsxs)("div",{className:"group relative flex h-full items-center",children:[!i&&(0,E.jsx)("div",{className:"flex h-[18px] w-32 items-center border border-transparent px-2 text-sm text-neutral-400 group-hover:invisible",children:t.direction}),i&&(0,E.jsxs)("div",{className:"flex h-[18px] w-32 items-center justify-between border border-sky-600 bg-sky-50 pl-2 pr-0.5 text-sm",children:[(0,E.jsx)("div",{children:t.direction}),(0,E.jsx)("div",{children:(0,E.jsx)(pr.CaretDown,{})})]}),(0,E.jsxs)("button",{className:"invisible absolute right-0 z-10 flex h-[18px] w-32 items-center justify-between border border-neutral-400 pl-2 pr-0.5 text-sm text-neutral-700 group-hover:visible",onClickCapture:e=>{e.stopPropagation(),n(e)},onClick:e=>e.stopPropagation(),children:[(0,E.jsx)("div",{children:t.direction}),(0,E.jsx)("div",{children:(0,E.jsx)(pr.CaretDown,{})})]}),(0,E.jsx)(xu,{className:"w-32",...r,children:[bi.ASCENDING,bi.DESCENDING].map((e=>(0,E.jsx)(Iu,{onClick:()=>{t.setDirection(e),o()},autoFocus:t.direction===e,children:e},e)))})]})})),wm=(0,vt.PA)((e=>{const{column:t}=e;return(0,E.jsx)("div",{className:"h-full flex-1 items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-2",children:t.name.split(yi).join(" / ")})})),km=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor.sorts;return(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-6 items-center text-xl font-medium",children:(0,E.jsx)(pr.TableSort,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:"Sorts"})]}),(0,E.jsx)("div",{className:"flex h-[calc(100%_-_24px)] w-full",children:(0,E.jsx)(xm,{selector:n.selector,columnLabelRenderer:e=>(0,E.jsx)(wm,{...e}),columnActionRenderer:e=>(0,E.jsx)(Im,{...e})})})]})}));var Rm;!function(e){e.EXTENDED_COLUMN_LEVELS="data-cube.extended-column.levels",e.GRID_CONFIGURATION_ROW_LIMIT="data-cube.grid-configuration.row-limit",e.COLUMN_CONFIGURATION_KIND="data-cube.column-configuration.kind",e.COLUMN_CONFIGURATION_UNIT="data-cube.column-configuration.unit",e.COLUMN_CONFIGURATION_DISPLAY_AS_LINK="data-cube.column-configuration.display-value-as-link",e.COLUMN_CONFIGURATION_MISSING_VALUE_FORMAT="data-cube.column-configuration.missing-value-format"}(Rm||(Rm={}));const Om=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor.generalProperties,o=n.configuration,[r,i,a,s]=pu(),[l,c,u,d]=pu(),[p,m,g,h]=pu(),[f,C,b,v]=pu(),[_,T,N]=pu(),[S,A,y]=pu();return(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-6 items-center text-xl font-medium",children:(0,E.jsx)(pr.TableOptions,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:"General Properties"})]}),(0,E.jsx)("div",{className:"flex h-[calc(100%_-_24px)] w-full",children:(0,E.jsxs)("div",{className:"h-full w-full py-2",children:[(0,E.jsxs)("div",{className:"flex h-6 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Report Title:"}),(0,E.jsx)(Su,{className:"h-6 w-96 text-lg font-semibold",value:o.name,onChange:e=>{o.setName(e.target.value)}})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Tree Column:"}),(0,E.jsx)(Au,{label:"Show root aggregation",checked:o.showRootAggregation,onChange:()=>o.setShowRootAggregation(!o.showRootAggregation)}),(0,E.jsx)(Au,{className:"ml-3",label:"Show leaf count",checked:o.showLeafCount,onChange:()=>o.setShowLeafCount(!o.showLeafCount)})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm"}),(0,E.jsx)("div",{className:"mr-1 flex h-full flex-shrink-0 items-center text-sm",children:"Sort:"}),(0,E.jsx)(yu,{className:"w-20",onClick:r,open:s,children:o.treeColumnSortDirection}),(0,E.jsx)(xu,{className:"w-20",...a,children:[bi.ASCENDING,bi.DESCENDING].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setTreeColumnSortDirection(e),i()},autoFocus:e===o.treeColumnSortDirection,children:e},e)))}),(0,E.jsx)("div",{className:"ml-3 mr-1 flex h-full flex-shrink-0 items-center text-sm",children:"Initially expand to level:"}),(0,E.jsx)(yu,{className:"w-16",onClick:l,open:d,showAsPlaceholder:void 0===o.initialExpandLevel,children:o.initialExpandLevel??Ki}),(0,E.jsx)(xu,{className:"w-16",...u,children:[void 0,1,2,3,4,5,6,7,8].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setInitialExpandLevel(e),c()},autoFocus:e===o.initialExpandLevel,children:e??Ki},e??"")))})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsxs)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:["Row Limit:",(0,E.jsx)(Ou,{className:"ml-1",documentationKey:Rm.GRID_CONFIGURATION_ROW_LIMIT})]}),(0,E.jsx)(Nu,{className:"w-16 text-sm",value:n.limit,min:0,step:1,defaultValue:void 0,placeholder:Ki,setValue:e=>n.setLimit(e)})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm"}),(0,E.jsx)(Au,{label:"Display warning when truncated",checked:o.showWarningForTruncatedResult,onChange:()=>o.setShowWarningForTruncatedResult(!o.showWarningForTruncatedResult)})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Show Selection Stats?"}),(0,E.jsx)(Au,{checked:o.showSelectionStats,onChange:()=>o.setShowSelectionStats(!o.showSelectionStats),disabled:!0}),(0,E.jsx)(vu,{})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Show Lines?"}),(0,E.jsx)(Au,{label:"Horizontal",checked:o.showHorizontalGridLines,onChange:()=>o.setShowHorizontalGridLines(!o.showHorizontalGridLines)}),(0,E.jsx)(Au,{className:"ml-3",label:"Vertical",checked:o.showVerticalGridLines,onChange:()=>o.setShowVerticalGridLines(!o.showVerticalGridLines)}),(0,E.jsx)("div",{className:"ml-3 mr-1 flex h-full flex-shrink-0 items-center text-sm",children:"Color:"}),(0,E.jsx)(Ru,{color:o.gridLineColor,defaultColor:Li,onChange:e=>o.setGridLineColor(e)})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Hightlight Rows:"}),(0,E.jsx)(Au,{label:"Standard mode",checked:o.alternateRowsStandardMode,onChange:()=>{o.alternateRowsStandardMode?o.setAlternateRowsStandardMode(!1):(o.setAlternateRowsStandardMode(!0),o.setAlternateRows(!1))}}),(0,E.jsx)(Au,{className:"ml-3",checked:o.alternateRows,onChange:()=>{o.alternateRows?o.setAlternateRows(!1):(o.setAlternateRows(!0),o.setAlternateRowsStandardMode(!1))}}),(0,E.jsx)("div",{className:"ml-1 mr-1 flex h-full flex-shrink-0 items-center text-sm",children:"Custom: Alternate color:"}),(0,E.jsx)(Ru,{disabled:!o.alternateRows,color:o.alternateRowsColor,defaultColor:Fi,onChange:e=>o.setAlternateRowsColor(e)}),(0,E.jsx)("div",{className:"ml-1 flex h-full flex-shrink-0 items-center text-sm",children:"every:"}),(0,E.jsx)(Nu,{className:"ml-1 w-16 text-sm",disabled:!o.alternateRows,min:1,step:1,defaultValue:1,isValid:e=>void 0!==e&&e>0,value:o.alternateRowsCount,setValue:e=>o.setAlternateRowsCount(e??1)}),(0,E.jsx)("div",{className:"ml-1 flex-shrink-0 text-sm",children:"rows"})]}),(0,E.jsx)("div",{className:"my-2 h-[1px] w-full bg-neutral-200"}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Default Font:"}),(0,E.jsx)(yu,{className:"w-28",onClick:p,open:h,children:o.fontFamily}),(0,E.jsxs)(xu,{className:"w-28",...g,children:[[ci.ARIAL,ci.ROBOTO,ci.ROBOTO_CONDENSED].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setFontFamily(e),m()},autoFocus:e===o.fontFamily,children:e},e))),(0,E.jsx)(wu,{}),[ci.GEORGIA,ci.ROBOTO_SERIF,ci.TIMES_NEW_ROMAN].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setFontFamily(e),m()},autoFocus:e===o.fontFamily,children:e},e))),(0,E.jsx)(wu,{}),[ci.JERBRAINS_MONO,ci.ROBOTO_MONO,ci.UBUNTU_MONO].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setFontFamily(e),m()},autoFocus:e===o.fontFamily,children:e},e)))]}),(0,E.jsx)(yu,{className:"ml-1 w-10",onClick:f,open:v,children:o.fontSize}),(0,E.jsx)(xu,{className:"w-10",...b,children:[4,5,6,7,8,9,10,11,12,14,16,18,20,22,24,26,28,32,36,48,72].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setFontSize(e),C()},autoFocus:e===o.fontSize,children:e},e)))}),(0,E.jsxs)("div",{className:"relative ml-2 flex h-5",children:[(0,E.jsx)("button",{title:"Bold",className:Mn("relative flex h-5 w-5 items-center justify-center rounded-bl-sm rounded-tl-sm border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":o.fontBold}),onClick:()=>o.setFontBold(!o.fontBold),children:(0,E.jsx)(pr.FontBold,{})}),(0,E.jsx)("button",{title:"Italic",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":o.fontItalic}),onClick:()=>o.setFontItalic(!o.fontItalic),children:(0,E.jsx)(pr.FontItalic,{})}),(0,E.jsx)("button",{title:"Underline"+(o.fontUnderline?` (${o.fontUnderline})`:""),className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-r-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":void 0!==o.fontUnderline}),onClick:()=>{void 0===o.fontUnderline?(o.setFontUnderline(pi.SOLID),o.setFontStrikethrough(!1)):o.setFontUnderline(void 0)},children:(0,E.jsx)(pr.FontUnderline,{})}),(0,E.jsxs)("button",{className:"text-2xs relative -ml-[1px] flex h-5 w-2.5 items-center justify-center border border-l-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-600 focus:z-[1]",onClick:_,children:[(0,E.jsx)("div",{className:Mn("h-4 w-[0.5px] bg-neutral-200",{"opacity-0":void 0!==o.fontUnderline})}),(0,E.jsx)(pr.CaretDown,{})]}),(0,E.jsx)(xu,{className:"w-14",...N,children:[pi.SOLID,pi.DASHED,pi.DOTTED,pi.DOUBLE,pi.WAVY].map((e=>(0,E.jsx)(Iu,{className:"relative",onClick:()=>{o.setFontUnderline(e),o.setFontStrikethrough(!1),T()},autoFocus:e===o.fontUnderline,children:(0,E.jsx)("div",{className:Mn("!hover:underline absolute top-0 !underline",{"!hover:decoration-solid !decoration-solid":e===pi.SOLID,"!hover:decoration-dashed !decoration-dashed":e===pi.DASHED,"!hover:decoration-dotted !decoration-dotted":e===pi.DOTTED,"!hover:decoration-double !decoration-double":e===pi.DOUBLE,"!hover:decoration-wavy !decoration-wavy":e===pi.WAVY}),children:"                "})},e)))}),(0,E.jsx)("button",{title:"Strikethrough",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":o.fontStrikethrough}),onClick:()=>{o.fontStrikethrough?o.setFontStrikethrough(!1):(o.setFontStrikethrough(!0),o.setFontUnderline(void 0))},children:(0,E.jsx)(pr.FontStrikethrough,{})}),(0,E.jsx)("button",{title:"Case"+(o.fontCase?` (${o.fontCase})`:""),className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-r-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":void 0!==o.fontCase}),onClick:()=>{o.setFontCase(void 0===o.fontCase?di.UPPERCASE:void 0)},children:(0,E.jsx)(pr.FontCase,{className:"stroke-[0.5px]"})}),(0,E.jsxs)("button",{className:"text-2xs relative -ml-[1px] flex h-5 w-2.5 items-center justify-center rounded-br-sm rounded-tr-sm border border-l-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-600 focus:z-[1]",onClick:S,children:[(0,E.jsx)("div",{className:Mn("h-4 w-[0.5px] bg-neutral-200",{"opacity-0":void 0!==o.fontCase})}),(0,E.jsx)(pr.CaretDown,{})]}),(0,E.jsx)(xu,{className:"w-20",...y,children:[di.LOWERCASE,di.UPPERCASE,di.CAPITALIZE].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setFontCase(e),A()},autoFocus:e===o.fontCase,children:(0,E.jsx)("div",{className:Mn({lowercase:e===di.LOWERCASE,uppercase:e===di.UPPERCASE,capitalize:e===di.CAPITALIZE}),children:e})},e)))})]}),(0,E.jsxs)("div",{className:"relative ml-2 flex h-5",children:[(0,E.jsx)("button",{title:"Align Left",className:Mn("relative flex h-5 w-5 items-center justify-center rounded-bl-sm rounded-tl-sm border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":o.textAlign===ui.LEFT}),onClick:()=>o.setTextAlign(ui.LEFT),children:(0,E.jsx)(pr.TextAlignLeft,{})}),(0,E.jsx)("button",{title:"Align Center",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":o.textAlign===ui.CENTER}),onClick:()=>o.setTextAlign(ui.CENTER),children:(0,E.jsx)(pr.TextAlignCenter,{})}),(0,E.jsx)("button",{title:"Align Right",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center rounded-br-sm rounded-tr-sm border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":o.textAlign===ui.RIGHT}),onClick:()=>o.setTextAlign(ui.RIGHT),children:(0,E.jsx)(pr.TextAlignRight,{})})]})]}),(0,E.jsxs)("div",{className:"mt-2 flex w-full",children:[(0,E.jsx)("div",{className:"flex h-6 w-32 flex-shrink-0 items-center text-sm",children:"Default Colors:"}),(0,E.jsxs)("div",{className:"h-18",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"w-16 flex-shrink-0"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Normal"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Negative"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Zero"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Error"})]}),(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-full w-16 flex-shrink-0 items-center text-sm",children:"Foreground:"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.normalForegroundColor,defaultColor:Vi,onChange:e=>o.setNormalForegroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.negativeForegroundColor,defaultColor:$i,onChange:e=>o.setNegativeForegroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.zeroForegroundColor,defaultColor:Yi,onChange:e=>o.setZeroForegroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.errorForegroundColor,defaultColor:Xi,onChange:e=>o.setErrorForegroundColor(e)})})]}),(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-full w-16 flex-shrink-0 items-center text-sm",children:"Background:"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.normalBackgroundColor,defaultColor:Wi,onChange:e=>o.setNormalBackgroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.negativeBackgroundColor,defaultColor:Wi,onChange:e=>o.setNegativeBackgroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.zeroBackgroundColor,defaultColor:Wi,onChange:e=>o.setZeroBackgroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.errorBackgroundColor,defaultColor:Wi,onChange:e=>o.setErrorBackgroundColor(e)})})]})]})]}),(0,E.jsxs)("div",{className:"mt-2 flex w-full",children:[(0,E.jsx)("div",{className:"flex h-6 w-32 flex-shrink-0 items-center text-sm"}),(0,E.jsxs)("div",{className:"w-80",children:[(0,E.jsx)("div",{className:"mb-2 h-[1px] w-full bg-neutral-200"}),(0,E.jsx)(Tu,{compact:!0,disabled:o.isUsingDefaultStyling,onClick:()=>o.useDefaultStyling(),children:"Use Default Styling"})]})]})]})})]})})),Lm=(0,vt.PA)((e=>{const{column:t,editor:n}=e,o=n.columnProperties.getColumnConfiguration(t.name).hideFromView;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:Mn("items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-2",{"text-neutral-400":o}),children:t.name}),Boolean(ra(n.leafExtendColumns,t.name))&&(0,E.jsx)("div",{className:"ml-1.5 mr-0.5 flex h-3.5 flex-shrink-0 items-center rounded-sm border border-neutral-300 bg-neutral-100 px-1 text-xs font-medium uppercase text-neutral-600",children:"Extended (Leaf Level)"}),Boolean(ra(n.groupExtendColumns,t.name))&&(0,E.jsx)("div",{className:"ml-1.5 mr-0.5 flex h-3.5 flex-shrink-0 items-center rounded-sm border border-neutral-300 bg-neutral-100 px-1 text-xs font-medium uppercase text-neutral-600",children:"Extended (Group Level)"})]})})),Fm=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor,o=n.columns;return(0,Ft.useEffect)((()=>()=>o.propagateChanges()),[o]),(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6 justify-between",children:[(0,E.jsxs)("div",{className:"flex h-full",children:[(0,E.jsx)("div",{className:"flex h-6 items-center text-xl font-medium",children:(0,E.jsx)(pr.TableColumns,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:"Columns"})]}),(0,E.jsx)("div",{className:"flex h-full items-center pr-2",children:(0,E.jsx)(Au,{label:"Show hidden columns?",checked:o.selector.showHiddenColumns,onChange:()=>o.selector.setShowHiddenColumns(!o.selector.showHiddenColumns)})})]}),(0,E.jsx)("div",{className:"flex h-[calc(100%_-_24px)] w-full",children:(0,E.jsx)(xm,{selector:o.selector,noColumnsSelectedRenderer:()=>(0,E.jsxs)("div",{className:"flex items-center border-[1.5px] border-neutral-200 p-2 font-semibold text-neutral-400",children:[(0,E.jsx)("div",{children:(0,E.jsx)(pr.Warning,{className:"mr-1 text-lg"})}),"No columns selected"]}),columnLabelRenderer:e=>(0,E.jsx)(Lm,{...e,editor:n})})})]})})),Dm=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor.verticalPivots;return(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-6 items-center text-xl font-medium",children:(0,E.jsx)(pr.TableGroupBy,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:"Vertical Pivots"})]}),(0,E.jsx)("div",{className:"flex h-[calc(100%_-_24px)] w-full",children:(0,E.jsx)(xm,{selector:n.selector})})]})})),Pm=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor.horizontalPivots;return(0,Ft.useEffect)((()=>()=>n.propagateChanges()),[n]),(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-6 items-center text-xl font-medium",children:(0,E.jsx)(pr.TablePivot,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:"Horizontal Pivots"})]}),(0,E.jsx)("div",{className:"flex h-[calc(100%_-_24px)] w-full",children:(0,E.jsx)(xm,{selector:n.selector,columnActionRenderer:e=>(0,E.jsx)(Im,{...e})})})]})})),Bm=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor,o=n.columnProperties,r=t.editor.generalProperties.configuration,i=o.selectedColumn,[a,s,l,c]=pu(),[u,d,p,m]=pu(),[g,h,f,C]=pu(),[b,v,_,T]=pu(),[N,S,A,y]=pu(),[x,I,w,k]=pu(),[R,O,L,F]=pu(),[D,P,B]=pu(),[j,M,U]=pu();return(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6 justify-between",children:[(0,E.jsxs)("div",{className:"flex h-full",children:[(0,E.jsxs)("div",{className:"relative flex h-6 items-center text-xl font-medium",children:[(0,E.jsx)(pr.TableColumn,{}),(0,E.jsx)(pr.TableColumnOptions__Settings,{className:"absolute bottom-1 right-0 bg-white text-xs"})]}),(0,E.jsx)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:"Column Properties"})]}),(0,E.jsxs)("div",{className:"flex h-full items-center pr-2",children:[(0,E.jsx)(Au,{label:"Show advanced settings?",checked:o.showAdvancedSettings,onChange:()=>o.setShowAdvancedSettings(!o.showAdvancedSettings)}),(0,E.jsx)(_u,{})]})]}),(0,E.jsx)("div",{className:"flex h-[calc(100%_-_24px)] w-full",children:(0,E.jsxs)("div",{className:"h-full w-full py-2",children:[(0,E.jsxs)("div",{className:"flex h-6 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Choose Column:"}),(0,E.jsx)(yu,{className:"w-80",onClick:a,open:c,children:(0,E.jsxs)("div",{className:"flex h-full w-full items-center",children:[(0,E.jsx)("div",{className:"overflow-hidden overflow-ellipsis whitespace-nowrap",children:i?.name??Ki}),i&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"ml-1.5 mr-0.5 flex h-3.5 w-12 flex-shrink-0 items-center justify-center rounded-sm border border-neutral-300 bg-neutral-100 text-xs font-medium uppercase text-neutral-600",children:i.dataType}),Boolean(ra(n.leafExtendColumns,i.name))&&(0,E.jsx)("div",{className:"mr-0.5 flex h-3.5 flex-shrink-0 items-center rounded-sm border border-neutral-300 bg-neutral-100 px-1 text-xs font-medium uppercase text-neutral-600",children:"Extended (Leaf Level)"}),Boolean(ra(n.groupExtendColumns,i.name))&&(0,E.jsx)("div",{className:"mr-0.5 flex h-3.5 flex-shrink-0 items-center rounded-sm border border-neutral-300 bg-neutral-100 px-1 text-xs font-medium uppercase text-neutral-600",children:"Extended (Group Level)"})]})]})}),(0,E.jsx)(xu,{className:"w-80",...l,children:o.columns.toSorted(aa).map((e=>(0,E.jsxs)(Iu,{onClick:()=>{o.setSelectedColumnName(e.name),s()},autoFocus:e.name===i?.name,children:[(0,E.jsx)("div",{className:"overflow-hidden overflow-ellipsis whitespace-nowrap",children:e.name}),(0,E.jsx)("div",{className:"ml-1.5 mr-0.5 flex h-3.5 w-12 flex-shrink-0 items-center justify-center rounded-sm border border-neutral-300 bg-neutral-100 text-xs font-medium uppercase text-neutral-600",children:e.dataType}),Boolean(ra(n.leafExtendColumns,e.name))&&(0,E.jsx)("div",{className:"mr-0.5 flex h-3.5 flex-shrink-0 items-center rounded-sm border border-neutral-300 bg-neutral-100 px-1 text-xs font-medium uppercase text-neutral-600",children:"Extended (Leaf Level)"}),Boolean(ra(n.groupExtendColumns,e.name))&&(0,E.jsx)("div",{className:"mr-0.5 flex h-3.5 flex-shrink-0 items-center rounded-sm border border-neutral-300 bg-neutral-100 px-1 text-xs font-medium uppercase text-neutral-600",children:"Extended (Group Level)"})]},e.name)))}),o.showAdvancedSettings&&i&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"mx-2 h-[1px] w-4 flex-shrink-0 bg-neutral-400"}),(0,E.jsxs)("div",{className:"flex h-6 items-center",children:[(0,E.jsxs)("div",{className:"flex h-full flex-shrink-0 items-center text-sm",children:["Column Kind:",(0,E.jsx)(Ou,{className:"ml-1",documentationKey:Rm.COLUMN_CONFIGURATION_KIND})]}),(0,E.jsx)(yu,{className:"ml-1.5 w-20",onClick:u,open:m,disabled:Boolean(ra(n.verticalPivots.selector.selectedColumns,i.name)??ra(n.horizontalPivots.selector.selectedColumns,i.name)),title:Boolean(ra(n.verticalPivots.selector.selectedColumns,i.name)??ra(n.horizontalPivots.selector.selectedColumns,i.name))?"Column kind cannot be changed while the column is used in pivot":void 0,children:i.kind}),(0,E.jsx)(xu,{className:"w-20",...p,children:[mi.DIMENSION,mi.MEASURE].map((e=>(0,E.jsx)(Iu,{onClick:()=>{e!==i.kind&&(i.setKind(e),i.setExcludedFromPivot(e===mi.DIMENSION),i.setPivotStatisticColumnFunction(e===mi.DIMENSION?void 0:fi.SUM)),d()},autoFocus:e===i.kind,children:e},e)))}),(0,E.jsx)(_u,{})]})]})]}),(0,E.jsx)("div",{className:"mb-2 ml-2 mt-3 h-[1px] w-[calc(100%_-_16px)] bg-neutral-200"}),i&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Display Name:"}),(0,E.jsx)(Su,{className:"w-80",value:i.displayName??"",onChange:e=>{const t=e.target.value;i.setDisplayName(""!==t?t:void 0)}})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Aggregation:"}),(0,E.jsx)(yu,{className:"w-32",onClick:g,disabled:i.kind===mi.DIMENSION,open:C,children:i.aggregateOperation.operator}),(0,E.jsx)(xu,{className:"w-32",...f,children:t.engine.aggregateOperations.filter((e=>e.isCompatibleWithColumn(i))).map((e=>(0,E.jsx)(Iu,{onClick:()=>{e!==i.aggregateOperation&&(i.setAggregateOperation(e),i.setAggregationParameters(e.generateDefaultParameterValues(i))),h()},autoFocus:e===i.aggregateOperation,children:e.label},e.operator)))}),(0,E.jsx)(Au,{className:"ml-3",label:"Exclude from horizontal pivot",checked:i.excludedFromPivot,onChange:()=>i.setExcludedFromPivot(!i.excludedFromPivot),disabled:i.kind===mi.DIMENSION})]}),i.dataType===_i.NUMBER&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Number Format:"}),(0,E.jsx)(Nu,{className:"w-16 text-sm",min:0,step:1,value:i.decimals??0,setValue:e=>{i.setDecimals(e)}}),(0,E.jsx)("div",{className:"ml-1 flex-shrink-0 text-sm",children:"decimal places"}),(0,E.jsx)(Au,{className:"ml-3",label:"Display commas",checked:i.displayCommas,onChange:()=>i.setDisplayCommas(!i.displayCommas)}),(0,E.jsx)(Au,{className:"ml-3",label:"Negative number in parens",checked:i.negativeNumberInParens,onChange:()=>i.setNegativeNumberInParens(!i.negativeNumberInParens)})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm"}),(0,E.jsx)("div",{className:"mr-1 flex h-full flex-shrink-0 items-center text-sm",children:"Scale:"}),(0,E.jsx)(yu,{className:"w-32",onClick:b,open:T,showAsPlaceholder:void 0===i.numberScale,children:i.numberScale??Ki}),(0,E.jsx)(xu,{className:"w-32",..._,children:[void 0,li.PERCENT,li.BASIS_POINT,li.THOUSANDS,li.MILLIONS,li.BILLIONS,li.TRILLIONS,li.AUTO].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setNumberScale(e),v()},autoFocus:e===i.numberScale,children:e??Ki},e??"")))}),(0,E.jsxs)("div",{className:"ml-3 mr-1 flex h-full flex-shrink-0 items-center text-sm",children:["Unit:",(0,E.jsx)(Ou,{className:"ml-1",documentationKey:Rm.COLUMN_CONFIGURATION_UNIT})]}),(0,E.jsx)(Su,{className:"w-16",value:i.unit??"",onChange:e=>{const t=e.target.value.trim();i.setUnit(""!==t.trim()?t:void 0)},placeholder:Ki})]})]}),i.dataType===_i.TEXT&&(0,E.jsx)(E.Fragment,{children:(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsxs)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:["Dislay as Link?",(0,E.jsx)(Ou,{className:"ml-1",documentationKey:Rm.COLUMN_CONFIGURATION_DISPLAY_AS_LINK})]}),(0,E.jsx)(Au,{checked:i.displayAsLink,onChange:()=>i.setDisplayAsLink(!i.displayAsLink)}),(0,E.jsx)("div",{className:"ml-1 h-[1px] w-2 flex-shrink-0 bg-neutral-400"}),(0,E.jsx)("div",{className:"ml-2 mr-1.5 flex h-full flex-shrink-0 items-center text-sm",children:"Use parameter in link as label:"}),(0,E.jsx)(Su,{className:"w-48",placeholder:Oi,value:i.linkLabelParameter??"",onChange:e=>{const t=e.target.value.trim();i.setLinkLabelParameter(""!==t?t:void 0)}})]})}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsxs)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:["Missing Value Format:",(0,E.jsx)(Ou,{className:"ml-1",documentationKey:Rm.COLUMN_CONFIGURATION_MISSING_VALUE_FORMAT})]}),(0,E.jsx)(Su,{className:"w-16",value:i.missingValueDisplayText??"",onChange:e=>{const t=e.target.value;i.setMissingValueDisplayText(""!==t?t:void 0)},placeholder:Ki})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Visibility:"}),(0,E.jsx)(Au,{label:"Blur content",checked:i.blur,onChange:()=>i.setBlur(!i.blur),disabled:i.hideFromView}),(0,E.jsx)(Au,{className:"ml-3",label:"Hide from view",checked:i.hideFromView,onChange:()=>i.setHideFromView(!i.hideFromView)})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Pin:"}),(0,E.jsx)(yu,{className:"w-16",onClick:N,open:y,showAsPlaceholder:void 0===i.pinned,children:i.pinned??Ki}),(0,E.jsx)(xu,{className:"w-16",...A,children:[void 0,vi.LEFT,vi.RIGHT].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setPinned(e),S()},autoFocus:e===i.pinned,children:e??Ki},e??"")))})]}),(0,E.jsxs)("div",{className:"mt-1.5 flex h-6 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Width:"}),(0,E.jsx)(Au,{label:"(Any)",checked:void 0===i.fixedWidth&&void 0===i.minWidth&&void 0===i.maxWidth,onChange:()=>{void 0===i.fixedWidth&&void 0===i.minWidth&&void 0===i.maxWidth?(i.setFixedWidth(300),i.setMinWidth(void 0),i.setMaxWidth(void 0)):(i.setFixedWidth(void 0),i.setMinWidth(void 0),i.setMaxWidth(void 0))}}),(0,E.jsx)(Au,{className:"ml-3",label:"Fixed",checked:void 0!==i.fixedWidth,onChange:()=>{i.setFixedWidth(void 0!==i.fixedWidth?void 0:300),i.setMinWidth(void 0),i.setMaxWidth(void 0)}}),(0,E.jsx)("div",{className:"ml-1 h-[1px] w-2 flex-shrink-0 bg-neutral-400"}),(0,E.jsx)(Nu,{className:"ml-1 w-16 text-sm",min:0,step:50,defaultValue:void 0,isValid:e=>void 0!==e&&e>0,value:i.fixedWidth,setValue:e=>{i.setFixedWidth(e)},disabled:void 0!==i.minWidth||void 0!==i.maxWidth}),(0,E.jsx)(Au,{className:"ml-3",label:"In range",checked:void 0!==i.minWidth||void 0!==i.maxWidth,onChange:()=>{void 0===i.minWidth&&void 0===i.maxWidth?(i.setMinWidth(Di),i.setMaxWidth(void 0),i.setFixedWidth(void 0)):(i.setMinWidth(void 0),i.setMaxWidth(void 0),i.setFixedWidth(void 0))}}),(0,E.jsx)("div",{className:"ml-1 h-[1px] w-2 flex-shrink-0 bg-neutral-400"}),(0,E.jsx)(Nu,{className:"ml-1 w-16 text-sm",min:0,step:50,defaultValue:void 0,isValid:e=>void 0!==e&&e>0,value:i.minWidth,setValue:e=>{i.setMinWidth(e)},disabled:void 0!==i.fixedWidth}),(0,E.jsx)("div",{className:"ml-1 h-[1px] w-1 flex-shrink-0 bg-neutral-400"}),(0,E.jsx)(Nu,{className:"ml-1 w-16 text-sm",min:i.minWidth??0,step:50,defaultValue:void 0,isValid:e=>void 0!==e&&e>=(i.minWidth??0),value:i.maxWidth,setValue:e=>{i.setMaxWidth(e)},disabled:void 0!==i.fixedWidth})]}),(0,E.jsx)("div",{className:"my-2 h-[1px] w-full bg-neutral-200"}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Font:"}),(0,E.jsx)(yu,{className:"w-28",onClick:x,open:k,children:i.fontFamily??r.fontFamily}),(0,E.jsxs)(xu,{className:"w-28",...w,children:[[ci.ARIAL,ci.ROBOTO,ci.ROBOTO_CONDENSED].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setFontFamily(e),I()},autoFocus:e===(i.fontFamily??r.fontFamily),children:e},e))),(0,E.jsx)(wu,{}),[ci.GEORGIA,ci.ROBOTO_SERIF,ci.TIMES_NEW_ROMAN].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setFontFamily(e),I()},autoFocus:e===(i.fontFamily??r.fontFamily),children:e},e))),(0,E.jsx)(wu,{}),[ci.JERBRAINS_MONO,ci.ROBOTO_MONO,ci.UBUNTU_MONO].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setFontFamily(e),I()},autoFocus:e===(i.fontFamily??r.fontFamily),children:e},e)))]}),(0,E.jsx)(yu,{className:"ml-1 w-10",onClick:R,open:F,children:i.fontSize??r.fontSize}),(0,E.jsx)(xu,{className:"w-10",...L,children:[4,5,6,7,8,9,10,11,12,14,16,18,20,22,24,26,28,32,36,48,72].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setFontSize(e),O()},autoFocus:e===(i.fontSize??r.fontSize),children:e},e)))}),(0,E.jsxs)("div",{className:"relative ml-2 flex h-5",children:[(0,E.jsx)("button",{title:"Bold",className:Mn("relative flex h-5 w-5 items-center justify-center rounded-bl-sm rounded-tl-sm border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":i.fontBold??r.fontBold}),onClick:()=>i.setFontBold(!(i.fontBold??r.fontBold)),children:(0,E.jsx)(pr.FontBold,{})}),(0,E.jsx)("button",{title:"Italic",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":i.fontItalic??r.fontItalic}),onClick:()=>i.setFontItalic(!(i.fontItalic??r.fontItalic)),children:(0,E.jsx)(pr.FontItalic,{})}),(0,E.jsx)("button",{title:"Underline"+(i.fontUnderline??r.fontUnderline?` (${i.fontUnderline??r.fontUnderline})`:""),className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-r-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":void 0!==(i.fontUnderline??r.fontUnderline)}),onClick:()=>{void 0===(i.fontUnderline??r.fontUnderline)?(i.setFontUnderline(pi.SOLID),i.setFontStrikethrough(!1)):i.setFontUnderline(void 0)},children:(0,E.jsx)(pr.FontUnderline,{})}),(0,E.jsxs)("button",{className:"text-2xs relative -ml-[1px] flex h-5 w-2.5 items-center justify-center border border-l-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-600 focus:z-[1]",onClick:D,children:[(0,E.jsx)("div",{className:Mn("h-4 w-[0.5px] bg-neutral-200",{"opacity-0":void 0!==(i.fontUnderline??r.fontUnderline)})}),(0,E.jsx)(pr.CaretDown,{})]}),(0,E.jsx)(xu,{className:"w-14",...B,children:[pi.SOLID,pi.DASHED,pi.DOTTED,pi.DOUBLE,pi.WAVY].map((e=>(0,E.jsx)(Iu,{className:"relative",onClick:()=>{i.setFontUnderline(e),i.setFontStrikethrough(!1),P()},autoFocus:e===(i.fontUnderline??r.fontUnderline),children:(0,E.jsx)("div",{className:Mn("!hover:underline absolute top-0 !underline",{"!hover:decoration-solid !decoration-solid":e===pi.SOLID,"!hover:decoration-dashed !decoration-dashed":e===pi.DASHED,"!hover:decoration-dotted !decoration-dotted":e===pi.DOTTED,"!hover:decoration-double !decoration-double":e===pi.DOUBLE,"!hover:decoration-wavy !decoration-wavy":e===pi.WAVY}),children:"                "})},e)))}),(0,E.jsx)("button",{title:"Strikethrough",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":i.fontStrikethrough??r.fontStrikethrough}),onClick:()=>{i.fontStrikethrough??r.fontStrikethrough?i.setFontStrikethrough(!1):(i.setFontStrikethrough(!0),i.setFontUnderline(void 0))},children:(0,E.jsx)(pr.FontStrikethrough,{})}),(0,E.jsx)("button",{title:"Case"+(i.fontCase??r.fontCase?` (${i.fontCase??r.fontCase})`:""),className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-r-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":void 0!==(i.fontCase??r.fontCase)}),onClick:()=>{void 0===(i.fontCase??r.fontCase)?i.setFontCase(di.UPPERCASE):i.setFontCase(void 0)},children:(0,E.jsx)(pr.FontCase,{className:"stroke-[0.5px]"})}),(0,E.jsxs)("button",{className:"text-2xs relative -ml-[1px] flex h-5 w-2.5 items-center justify-center rounded-br-sm rounded-tr-sm border border-l-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-600 focus:z-[1]",onClick:j,children:[(0,E.jsx)("div",{className:Mn("h-4 w-[0.5px] bg-neutral-200",{"opacity-0":void 0!==(i.fontCase??r.fontCase)})}),(0,E.jsx)(pr.CaretDown,{})]}),(0,E.jsx)(xu,{className:"w-20",...U,children:[di.LOWERCASE,di.UPPERCASE,di.CAPITALIZE].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setFontCase(e),M()},autoFocus:e===(i.fontCase??r.fontCase),children:(0,E.jsx)("div",{className:Mn({lowercase:e===di.LOWERCASE,uppercase:e===di.UPPERCASE,capitalize:e===di.CAPITALIZE}),children:e})},e)))})]}),(0,E.jsxs)("div",{className:"relative ml-2 flex h-5",children:[(0,E.jsx)("button",{title:"Align Left",className:Mn("relative flex h-5 w-5 items-center justify-center rounded-bl-sm rounded-tl-sm border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":(i.textAlign??r.textAlign)===ui.LEFT}),onClick:()=>i.setTextAlign(ui.LEFT),children:(0,E.jsx)(pr.TextAlignLeft,{})}),(0,E.jsx)("button",{title:"Align Center",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":(i.textAlign??r.textAlign)===ui.CENTER}),onClick:()=>i.setTextAlign(ui.CENTER),children:(0,E.jsx)(pr.TextAlignCenter,{})}),(0,E.jsx)("button",{title:"Align Right",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center rounded-br-sm rounded-tr-sm border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":(i.textAlign??r.textAlign)===ui.RIGHT}),onClick:()=>i.setTextAlign(ui.RIGHT),children:(0,E.jsx)(pr.TextAlignRight,{})})]})]}),(0,E.jsxs)("div",{className:"mt-2 flex w-full",children:[(0,E.jsx)("div",{className:"flex h-6 w-32 flex-shrink-0 items-center text-sm",children:"Colors:"}),(0,E.jsxs)("div",{className:"h-18",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"w-16 flex-shrink-0"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Normal"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Negative"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Zero"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Error"})]}),(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-full w-16 flex-shrink-0 items-center text-sm",children:"Foreground:"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.normalForegroundColor??r.normalForegroundColor,defaultColor:r.normalForegroundColor,onChange:e=>i.setNormalForegroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.negativeForegroundColor??r.negativeForegroundColor,defaultColor:r.negativeForegroundColor,onChange:e=>i.setNegativeForegroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.zeroForegroundColor??r.zeroForegroundColor,defaultColor:r.zeroForegroundColor,onChange:e=>i.setZeroForegroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.errorForegroundColor??r.errorForegroundColor,defaultColor:r.errorForegroundColor,onChange:e=>i.setErrorForegroundColor(e)})})]}),(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-full w-16 flex-shrink-0 items-center text-sm",children:"Background:"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.normalBackgroundColor??r.normalBackgroundColor,defaultColor:r.normalBackgroundColor,onChange:e=>i.setNormalBackgroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.negativeBackgroundColor??r.negativeBackgroundColor,defaultColor:r.negativeBackgroundColor,onChange:e=>i.setNegativeBackgroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.zeroBackgroundColor??r.zeroBackgroundColor,defaultColor:r.zeroBackgroundColor,onChange:e=>i.setZeroBackgroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.errorBackgroundColor??r.errorBackgroundColor,defaultColor:r.errorBackgroundColor,onChange:e=>i.setErrorBackgroundColor(e)})})]})]})]}),(0,E.jsxs)("div",{className:"mt-2 flex w-full",children:[(0,E.jsx)("div",{className:"flex h-6 w-32 flex-shrink-0 items-center text-sm"}),(0,E.jsxs)("div",{className:"w-80",children:[(0,E.jsx)("div",{className:"mb-2 h-[1px] w-full bg-neutral-200"}),(0,E.jsx)(Tu,{compact:!0,disabled:i.isUsingDefaultStyling,onClick:()=>i.useDefaultStyling(),children:"Use Default Styling"})]})]})]})]})})]})}));class jm{name;isRenaming=!1;columns=[];constructor(e){(0,Ie.Gn)(this,{name:Ie.sH,setName:Ie.XI,isRenaming:Ie.sH,setIsRenaming:Ie.XI,columns:Ie.sH,setColumns:Ie.XI}),this.name=e}setName(e){this.name=e}setIsRenaming(e){this.isRenaming=e}setColumns(e){this.columns=e}}class Mm{_editor;availableColumnsSearchText="";dimensions=[];dimensionsTreeData={nodes:[]};dimensionsTreeSearchText="";constructor(e){(0,Ie.Gn)(this,{availableColumns:Ie.EW,availableColumnsForDisplay:Ie.EW,availableColumnsSearchText:Ie.sH,setAvailableColumnsSearchText:Ie.XI,selectedColumns:Ie.EW,deselectColumns:Ie.XI,dimensions:Ie.sH,setDimensions:Ie.XI,newDimension:Ie.XI,dimensionsTreeData:Ie.sH.ref,refreshDimensionsTreeData:Ie.XI,dimensionsTreeSearchText:Ie.sH,setDimensionsTreeSearchText:Ie.XI}),this._editor=e}get availableColumns(){return this._editor.columnProperties.columns.filter((e=>e.kind===mi.DIMENSION&&!ra(this._editor.groupExtendColumns,e.name)&&!ra(this._editor.horizontalPivots.selector.selectedColumns,e.name))).map((e=>new dm(e.name,e.type)))}get availableColumnsForDisplay(){return this.availableColumns.filter((e=>!ra(this.selectedColumns,e.name))).sort(aa)}setAvailableColumnsSearchText(e){this.availableColumnsSearchText=e}get selectedColumns(){return this.dimensions.flatMap((e=>e.columns))}deselectColumns(e){this.dimensions.forEach((t=>{t.setColumns(t.columns.filter((t=>!ra(e,t.name))))}))}setDimensions(e){this.dimensions=e}newDimension(){const e=new jm(((e,t,n="underscore")=>{if(!t.match(/^[\w_-]+$/))throw new Error("Token must only contain digits, letters, or special characters _ and -");const o="whitespace"===n?" ":"_",r=e.map((e=>{const n=e.match(new RegExp(`^${t}${o}(?<count>\\d+)$`));return n?.groups?.count?parseInt(n.groups.count,10):0})).reduce(((e,t)=>Math.max(e,t)),0);return`${t}${o}${r+1}`})(this.dimensions.map((e=>e.name)),"Dimension","whitespace"));return this.dimensions.push(e),e}refreshDimensionsTreeData(){this.dimensionsTreeData={nodes:this.dimensions.map((e=>({name:e.name,data:e,children:e.columns.map((e=>({name:e.name,data:e})))})))}}setDimensionsTreeSearchText(e){this.dimensionsTreeSearchText=e}adaptPropagatedChanges(){this.deselectColumns(this.selectedColumns.filter((e=>!ra(this.availableColumns,e.name)))),this.refreshDimensionsTreeData()}applySnaphot(e,t){this.setDimensions(t.dimensions.dimensions.map((e=>{const n=new jm(e.name);return n.setColumns(e.columns.map((e=>{const n=D(ra(t.columns,e));return new dm(n.name,n.type)}))),n}))),this.refreshDimensionsTreeData()}buildSnapshot(e,t){const n=new ua;this._editor.generalProperties.configuration.gridMode===Ti.MULTIDIMENSIONAL?(n.dimensions=this.dimensions.map((e=>({name:e.name,columns:e.columns.map((e=>e.name))}))),e.data.configuration={...e.data.configuration,dimensions:ua.serialization.toJson(n)}):e=t}}console.error;const Um=(0,vt.PA)((e=>{const{panel:t,gridApi:n}=e;return(0,E.jsxs)("div",{className:"flex items-center justify-center rounded-lg bg-neutral-500 px-1 py-0.5 font-mono text-xs font-bold text-white",children:[`${kp(n).length}/${t.availableColumnsForDisplay.length}`,(0,E.jsx)("span",{className:"hidden",children:t.availableColumnsSearchText})]})})),Gm=(0,vt.PA)((e=>{const{panel:t,gridApi:n}=e;return(0,E.jsxs)("div",{className:"flex items-center justify-center rounded-lg bg-neutral-500 px-1 py-0.5 font-mono text-xs font-bold text-white",children:[`${kp(n).map((e=>e.data)).filter((e=>e instanceof jm)).length}/${t.dimensions.length}`,(0,E.jsx)("span",{className:"hidden",children:t.dimensionsTreeSearchText})]})})),Hm=(0,vt.PA)((e=>{const{panel:t,dimension:n,gridApi:o}=e,r=(0,Ft.useRef)(null),[i,a]=(0,Ft.useState)(n.name),s=!(""===i.trim()||(Boolean(t.dimensions.filter((e=>e.name!==n.name)).find((e=>e.name===i)))||void 0)),l=()=>{s&&(n.setName(i),n.setIsRenaming(!1),o.clearFocusedCell())};return(0,Ft.useEffect)((()=>{a(n.name)}),[n.name]),(0,Ft.useEffect)((()=>{n.isRenaming&&r.current?.focus()}),[n.isRenaming]),(0,E.jsxs)("div",{className:"flex h-full w-full items-center pl-1",title:`[Dimension: ${n.name}]\nDouble-click to remove all columns`,children:[(0,E.jsx)("div",{className:"text-2xs flex h-3 flex-shrink-0 items-center justify-center rounded-sm bg-neutral-500 px-1 font-bold text-white",children:"DIM"}),!n.isRenaming&&(0,E.jsx)("div",{className:"h-full flex-1 cursor-pointer items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-1",title:"Double-click to remove dimension",onDoubleClickCapture:e=>{e.stopPropagation(),n.setIsRenaming(!0),o.clearFocusedCell()},children:n.name}),n.isRenaming&&(0,E.jsxs)("div",{className:"relative flex items-center",onDoubleClickCapture:e=>{e.stopPropagation(),o.clearFocusedCell()},children:[(0,E.jsx)("input",{ref:r,className:Mn("ml-0.5 h-4 border border-neutral-300 pl-[1px] pr-6 focus:border-sky-600 focus:!outline-none",{"border-red-600 focus:border-red-600":!s}),value:i,onChange:e=>{a(e.target.value)},onKeyDown:e=>{"Escape"===e.code&&(r.current?.focus(),r.current?.select())},onKeyDownCapture:e=>{"Enter"===e.code&&(e.stopPropagation(),l())},onBlur:()=>{n.setIsRenaming(!1),a(n.name)}}),s&&(0,E.jsx)("button",{className:"text-2xs absolute right-0.5 flex h-3 w-5 items-center justify-center rounded-sm bg-sky-600 text-white",onClick:e=>{e.stopPropagation(),l()},children:"Save"})]})]})}));function Vm(e,t){e.alertService.alert({message:"No target dimensions to add columns to",text:"Columns need to be added to a dimension, but no dimension has been specified.\nDo you want to proceed with creating a new dimension and add the columns to it?",type:Mu.WARNING,actions:[{label:"Proceed",handler:t},{label:"Cancel",handler:()=>{}}],windowConfig:{...Er,width:550,height:180}})}function Wm(e){let t=-1===e.overIndex?void 0:e.overIndex;return void 0!==t&&e.y%20<10&&(t-=1),{overIndex:t,overNode:void 0!==t?Ip(e.api).at(-1===t?0:t):void 0}}const zm=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor,o=n.dimensions,r=(0,Ft.useRef)(null),i=(0,Ft.useRef)(null),[a,s]=(0,Ft.useState)([]),[l,c]=(0,Ft.useState)([]),[u,d]=(0,Ft.useState)([]),[p,m]=(0,Ft.useState)(null),[g,h]=(0,Ft.useState)(null),f=(0,Ft.useCallback)((e=>{const t=e.nodes.map((e=>e.data?.data)).filter((n=dm,e=>((e,t)=>e instanceof t)(e,n)));var n;o.deselectColumns(t),o.refreshDimensionsTreeData()}),[o]),C=(0,Ft.useCallback)((e=>{const{overNode:n}=Wm(e),r=e.nodes.map((e=>e.data)).filter(L),i=(n?.data?n.data.data instanceof jm?n.data.data:n.parent?.data?.data instanceof jm?n.parent.data.data:void 0:void 0)??o.dimensions.at(-1);if(i){const e=n?.data?.data instanceof dm?i.columns.indexOf(n.data.data):n?.data?.data instanceof jm?-1:void 0;i.setColumns(void 0!==e?[...i.columns.slice(0,e+1),...r,...i.columns.slice(e+1)]:[...i.columns,...r]),o.refreshDimensionsTreeData()}else Vm(t,(()=>{o.newDimension().setColumns([...r]),o.refreshDimensionsTreeData()}))}),[o,t]);(0,Ft.useEffect)((()=>{if(!p||!g)return;const e=g.isDestroyed()?void 0:g.getRowDropZoneParams({onDragStop:e=>{C(e),p.clearFocusedCell()}});e&&!p.isDestroyed()&&p.addRowDropZone(e);const t=p.isDestroyed()?void 0:p.getRowDropZoneParams({onDragStop:e=>{f(e),g.clearFocusedCell()}});t&&!g.isDestroyed()&&g.addRowDropZone(t)}),[p,g,C,f]);const[b,v]=(0,Ft.useState)(void 0),_=0===u.length||0===l.length,T=(0,Ft.useCallback)((e=>{const{overIndex:t,overNode:n}=Wm(e);v(void 0);const r=e.nodes.map((e=>e.data)).filter((e=>!(e instanceof jm)));if(0===r.length)return;const i=[],a=[];if(r.forEach((e=>{e.data instanceof jm?a.push(e.data):e.data instanceof dm&&i.push(e.data)})),!(i.length>0&&a.length>0)){if(a.length>0){let e;if(-1===t)e=-1;else if(void 0!==n){const t=n.data?n.data.data instanceof jm?n.data.data:n.parent?.data?.data instanceof jm?n.parent.data.data:void 0:void 0;if(t){const n=o.dimensions.indexOf(t);e=-1===n?-1:n-o.dimensions.slice(0,n+1).filter((e=>a.find((t=>e.name===t.name)))).length}}const r=o.dimensions.filter((e=>!a.find((t=>e.name===t.name))));return o.setDimensions(void 0!==e?[...r.slice(0,e+1),...a,...r.slice(e+1)]:[...r,...a]),void o.refreshDimensionsTreeData()}if(i.length>0){const e=(n?.data?n.data.data instanceof jm?n.data.data:n.parent?.data?.data instanceof jm?n.parent.data.data:void 0:void 0)??o.dimensions.at(-1);if(e){let t;if(n?.data?.data instanceof jm)t=-1;else if(n?.data?.data instanceof dm){const o=e.columns.indexOf(n.data.data);t=-1===o?-1:o-e.columns.slice(0,o+1).filter((e=>ra(i,e.name))).length}o.deselectColumns(i),e.setColumns(void 0!==t?[...e.columns.slice(0,t+1),...i,...e.columns.slice(t+1)]:[...e.columns,...i]),o.refreshDimensionsTreeData()}}}}),[o]),N=(0,Ft.useCallback)((e=>{const{overIndex:t,overNode:n}=Wm(e);v(t),e.api.refreshCells({rowNodes:n?[n]:[],force:!0})}),[]),S=(0,Ft.useCallback)((e=>{v(void 0)}),[]),A=(0,Ft.useCallback)((e=>{v(void 0)}),[]);return(0,Ft.useEffect)((()=>{o.dimensions.forEach((e=>e.setIsRenaming(!1))),v(void 0)}),[o]),(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-6 items-center text-xl font-medium",children:(0,E.jsx)(pr.TableDimension,{})}),(0,E.jsxs)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:["Dimensions",(0,E.jsx)(vu,{})]})]}),(0,E.jsxs)("div",{className:"h-[calc(100%_-_24px)] w-full",children:[(0,E.jsx)("div",{className:"h-10 py-2",children:(0,E.jsx)("div",{className:"flex h-6 w-full items-center",children:(0,E.jsx)(Au,{label:"Enable multidimensional grid mode",checked:n.generalProperties.configuration.gridMode===Ti.MULTIDIMENSIONAL,onChange:()=>{n.generalProperties.configuration.gridMode===Ti.MULTIDIMENSIONAL?n.generalProperties.configuration.setGridMode(Ti.STANDARD):0!==n.verticalPivots.selector.selectedColumns.length&&0===o.dimensions.length?t.alertService.alert({message:"Specified vertical pivots will be ignored in multidimensional grid mode.",text:"Multidimensional grid mode will ignore any specified vertical pivots, essentially, vertical pivot columns can be considered as one dimension.\nFor convenience, these vertical pivots can be converted into a dimension, do you want this conversion to happen?",type:Mu.WARNING,actions:[{label:"Yes",handler:()=>{const e=n.verticalPivots.selector.selectedColumns;o.newDimension().setColumns(o.availableColumns.filter((t=>ra(e,t.name)))),n.verticalPivots.selector.setSelectedColumns([]),o.refreshDimensionsTreeData(),n.generalProperties.configuration.setGridMode(Ti.MULTIDIMENSIONAL)}},{label:"No",handler:()=>{n.generalProperties.configuration.setGridMode(Ti.MULTIDIMENSIONAL)}}],windowConfig:{...Er,width:550,height:220}}):n.generalProperties.configuration.setGridMode(Ti.MULTIDIMENSIONAL)}})})}),n.generalProperties.configuration.gridMode!==Ti.MULTIDIMENSIONAL&&(0,E.jsx)(Fu,{message:"Multidimensional grid mode is experimental",type:Mu.WARNING,text:'This is an alternative grid view for DataCube with a different mode of interaction: dimensions (ordered list of columns to group by) are defined and will be used to explore data "top-down". Initially, the grid will show the root aggregation, then user can drill down into each dimension. This grid mode comes with the following limitations:\n- Specified vertical pivots will be ignored: essentially, vertical pivot can be considered as one dimension in this mode\n- No support for pagination\n- Initial view can take longer to materialize if drilldown is deep'}),n.generalProperties.configuration.gridMode===Ti.MULTIDIMENSIONAL&&(0,E.jsx)("div",{className:"flex h-[calc(100%_-_40px)] w-full",children:(0,E.jsxs)("div",{className:"data-cube-column-selector flex h-full w-full",children:[(0,E.jsxs)("div",{className:"h-full w-[calc(50%_-_20px)]",children:[(0,E.jsx)("div",{className:"flex h-5 items-center text-sm",children:"Available columns:"}),(0,E.jsxs)("div",{className:"h-[calc(100%_-_20px)] rounded-sm border border-neutral-200",children:[(0,E.jsxs)("div",{className:"relative h-6 border-b border-neutral-200",children:[(0,E.jsx)("input",{className:"h-full w-full pl-10 pr-6 placeholder-neutral-400",ref:r,placeholder:"Search columns...",value:o.availableColumnsSearchText,onChange:e=>o.setAvailableColumnsSearchText(e.target.value),onKeyDown:e=>{"Escape"===e.code&&(e.stopPropagation(),r.current?.select(),o.setAvailableColumnsSearchText(""))}}),(0,E.jsx)("div",{className:"absolute left-0 top-0 flex h-6 w-10 items-center justify-center",children:(0,E.jsx)(pr.Search,{className:"stroke-[3px] text-lg text-neutral-500"})}),(0,E.jsx)("button",{className:"absolute right-0 top-0 flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",disabled:!o.availableColumnsSearchText,title:"Clear search [Esc]",onClick:()=>{o.setAvailableColumnsSearchText(""),r.current?.focus()},children:(0,E.jsx)(pr.X,{className:"text-lg"})})]}),(0,E.jsx)("div",{className:"h-[calc(100%_-_24px)]",children:(0,E.jsx)(Ir.W6,{...Am(),rowDragManaged:!1,onGridReady:e=>m(e.api),onSelectionChanged:e=>{s(e.api.getSelectedNodes().map((e=>e.data)).filter(L))},quickFilterText:o.availableColumnsSearchText,rowData:o.availableColumnsForDisplay,rowClass:"border-t border-b border-1 border-transparent",columnDefs:[{field:"name",colId:"name",flex:1,minWidth:100,filter:!0,sortable:!1,resizable:!1,suppressHeaderMenuButton:!0,getQuickFilterText:e=>e.value,headerComponent:e=>(0,E.jsxs)("button",{title:"Double-click to add all columns",className:"flex h-full w-full items-center justify-between pl-0.5",onDoubleClick:()=>{const n=kp(e.api),r=o.dimensions.at(-1);r?(r.setColumns([...r.columns,...n]),o.refreshDimensionsTreeData()):Vm(t,(()=>{o.newDimension().setColumns([...n]),o.refreshDimensionsTreeData()})),e.api.clearFocusedCell()},children:[(0,E.jsx)("div",{children:"[All Columns]"}),(0,E.jsx)(Um,{panel:o,gridApi:e.api})]}),cellRenderer:e=>{const n=e.data;return n?(0,E.jsx)("div",{className:"flex h-full w-full cursor-pointer items-center",title:`[${n.name}]\nDouble-click to add column`,onDoubleClick:()=>{const r=o.dimensions.at(-1);r?(r.setColumns([...r.columns,n]),o.refreshDimensionsTreeData()):Vm(t,(()=>{o.newDimension().setColumns([n]),o.refreshDimensionsTreeData()})),e.api.clearFocusedCell()},children:(0,E.jsx)("div",{className:"h-full flex-1 items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-2",children:n.name})}):null}}]})})]})]}),(0,E.jsx)("div",{className:"flex h-full w-10 items-center justify-center",children:(0,E.jsxs)("div",{className:"flex flex-col",children:[(0,E.jsx)("button",{className:"flex items-center justify-center rounded-sm border border-neutral-300 bg-neutral-100 text-neutral-500 hover:bg-neutral-200 disabled:bg-neutral-200 disabled:text-neutral-400",title:"Add selected column(s)",onClick:()=>{if(!p||0===a.length)return;const e=kp(p),n=a.filter((t=>ra(e,t.name))),r=o.dimensions.at(-1);r?(r.setColumns([...r.columns,...n]),o.refreshDimensionsTreeData()):Vm(t,(()=>{o.newDimension().setColumns([...n]),o.refreshDimensionsTreeData()})),p.clearFocusedCell()},disabled:!p||0===a.length,children:(0,E.jsx)(pr.ChevronRight,{className:"text-2xl"})}),(0,E.jsx)("button",{className:"mt-2 flex items-center justify-center rounded-sm border border-neutral-300 bg-neutral-100 text-neutral-500 hover:bg-neutral-200 disabled:bg-neutral-200 disabled:text-neutral-400",title:"Remove selected column(s)",onClick:()=>{if(!g||0===l.length)return;const e=kp(g),t=l.filter((t=>ra(e,t.name)));o.deselectColumns(t),o.refreshDimensionsTreeData(),g.clearFocusedCell()},disabled:!g||0===l.length,children:(0,E.jsx)(pr.ChevronLeft,{className:"text-2xl"})})]})}),(0,E.jsxs)("div",{className:"data-cube-tree-selector h-full w-[calc(50%_-_20px)]",children:[(0,E.jsx)("div",{className:"flex h-5 items-center text-sm",children:"Dimensions:"}),(0,E.jsxs)("div",{className:"h-[calc(100%_-_20px)] rounded-sm border border-neutral-200",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsxs)("div",{className:"relative h-6 w-[calc(100%_-_124px)] border-b border-r border-neutral-200",children:[(0,E.jsx)("input",{className:"h-full w-full pl-10 pr-6 placeholder-neutral-400",ref:i,placeholder:"Search...",value:o.dimensionsTreeSearchText,onChange:e=>o.setDimensionsTreeSearchText(e.target.value),onKeyDown:e=>{"Escape"===e.code&&(e.stopPropagation(),i.current?.select(),o.setDimensionsTreeSearchText(""))}}),(0,E.jsx)("div",{className:"absolute left-0 top-0 flex h-6 w-10 items-center justify-center",children:(0,E.jsx)(pr.Search,{className:"stroke-[3px] text-lg text-neutral-500"})}),(0,E.jsx)("button",{className:"absolute right-0 top-0 flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",disabled:!o.dimensionsTreeSearchText,title:"Clear search [Esc]",onClick:()=>{o.setDimensionsTreeSearchText(""),i.current?.focus()},children:(0,E.jsx)(pr.X,{className:"text-lg"})})]}),(0,E.jsxs)("div",{className:"flex h-6 items-center border-b border-neutral-200",children:[(0,E.jsx)("button",{className:"flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",title:"Add new dimension",onClick:()=>{o.newDimension(),o.refreshDimensionsTreeData()},children:(0,E.jsx)(pr.Plus,{className:"text-lg"})}),(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsx)("button",{className:"flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",title:"Move dimension(s) up",disabled:0===u.length,onClick:()=>{if(0===u.length)return;const e=Math.min(...u.map((e=>o.dimensions.indexOf(e)))),t=[...o.dimensions.slice(0,Math.max(e-1,0)),...o.dimensions.map((e=>u.find((t=>t.name===e.name)))).filter(L)];o.setDimensions([...t,...o.dimensions.filter((e=>!t.find((t=>t.name===e.name))))]),o.refreshDimensionsTreeData()},children:(0,E.jsx)(pr.ChevronUp,{className:"text-lg"})}),(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsx)("button",{className:"flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",title:"Move dimension(s) down",disabled:0===u.length,onClick:()=>{if(0===u.length)return;const e=Math.max(...u.map((e=>o.dimensions.indexOf(e)))),t=[...o.dimensions.map((e=>u.find((t=>t.name===e.name)))).filter(L),...o.dimensions.slice(Math.min(e+1,o.dimensions.length)+1)];o.setDimensions([...o.dimensions.filter((e=>!t.find((t=>t.name===e.name)))),...t]),o.refreshDimensionsTreeData()},children:(0,E.jsx)(pr.ChevronDown,{className:"text-lg"})}),(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsx)("button",{className:"flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",title:"Remove dimension(s)",disabled:0===u.length,onClick:()=>{0!==u.length&&u.at(0)?.setIsRenaming(!0)},children:(0,E.jsx)(pr.Pencil,{className:"text-lg"})}),(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsx)("button",{className:"flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",title:"Rename dimension",disabled:0===u.length,onClick:()=>{0!==u.length&&(o.setDimensions(o.dimensions.filter((e=>!u.find((t=>t.name===e.name))))),o.refreshDimensionsTreeData())},children:(0,E.jsx)(pr.Delete,{className:"text-lg"})})]})]}),(0,E.jsx)("div",{className:"h-[calc(100%_-_24px)]",children:(0,E.jsx)(Ir.W6,{...Am(),modules:[yr.JKr,xr.vl5],className:"ag-theme-quartz",treeData:!0,treeDataChildrenField:"children",groupDefaultExpanded:-1,onGridReady:e=>{h(e.api)},onSelectionChanged:e=>{const t=e.api.getSelectedNodes().map((e=>e.data)).filter(L),n=[],o=[];t.forEach((e=>{e.data instanceof jm?o.push(e.data):e.data instanceof dm&&n.push(e.data)})),d(o),c(n)},rowSelection:{mode:"multiRow",groupSelects:"self"},columnDefs:[],quickFilterText:o.dimensionsTreeSearchText,rowData:o.dimensionsTreeData.nodes,rowClassRules:{"border-t border-b border-1 border-transparent":()=>!0,"border-b-sky-600":e=>void 0!==b&&e.rowIndex===b,"border-t-sky-600":e=>-1===b&&0===e.rowIndex},autoGroupColumnDef:{headerName:"Name",field:"name",colId:"name",flex:1,minWidth:100,filter:!0,sortable:!1,resizable:!1,suppressHeaderMenuButton:!0,suppressKeyboardEvent:e=>!!o.dimensions.some((e=>e.isRenaming))&&"Tab"!==e.event.code,getQuickFilterText:e=>e.value,headerComponent:e=>(0,E.jsxs)("button",{title:"Double-click to remove all columns",className:"flex h-full w-full items-center justify-between pl-0.5",onDoubleClick:()=>{const t=kp(e.api);o.deselectColumns(o.selectedColumns.filter((e=>ra(t,e.name)))),o.refreshDimensionsTreeData(),e.api.clearFocusedCell()},children:[(0,E.jsx)("div",{children:"[All Dimensions]"}),(0,E.jsx)(Gm,{panel:o,gridApi:e.api})]}),onCellDoubleClicked:e=>{e.data?.data instanceof jm&&(e.data.data.setColumns([]),o.refreshDimensionsTreeData(),e.api.clearFocusedCell())},cellRendererParams:{innerRenderer:e=>{const t=e.data;return t?t.data instanceof jm?(0,E.jsx)(Hm,{panel:o,dimension:t.data,gridApi:e.api}):(0,E.jsx)("div",{className:"flex h-full w-full cursor-pointer items-center",title:`[${t.name}]\nDouble-click to remove column`,onDoubleClick:()=>{t.data instanceof dm&&(o.deselectColumns([t.data]),o.refreshDimensionsTreeData()),e.api.clearFocusedCell()},children:(0,E.jsx)("div",{className:"h-full flex-1 items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-1",children:t.name})}):null}}},noRowsOverlayComponent:e=>e.api.getQuickFilter()?(0,E.jsxs)("div",{className:"flex items-center border-[1.5px] border-neutral-300 p-2 font-semibold text-neutral-400",children:[(0,E.jsx)("div",{children:(0,E.jsx)(pr.WarningCircle,{className:"mr-1 text-lg"})}),"No match found"]}):(0,E.jsxs)("div",{className:"flex items-center border-[1.5px] border-neutral-200 p-2 font-semibold text-neutral-400",children:[(0,E.jsx)("div",{children:(0,E.jsx)(pr.Warning,{className:"mr-1 text-lg"})}),"No dimensions specified"]}),suppressRowDrag:!_,rowDragEntireRow:_,onRowDragEnd:T,onRowDragMove:N,onRowDragCancel:S,onRowDragLeave:A})})]})]})]})})]})]})})),$m=(0,vt.PA)((e=>{const t=bu().alertService,{view:n}=e,o=n.editor,r=o.currentTab,i=[Jm.COLUMNS,Jm.HORIZONTAL_PIVOTS,Jm.VERTICAL_PIVOTS,Jm.DIMENSIONS,Jm.SORTS,Jm.GENERAL_PROPERTIES,Jm.COLUMN_PROPERTIES],a=[Jm.DIMENSIONS],s=()=>{n.dataCube.telemetryService.sendTelemetry(Ud.APPLY_CHANGES_PROPERTIES,n.engine.getDataFromSource(n.getInitialSource()))};return(0,Ft.useEffect)((()=>{ea(n.info.configuration.gridMode)&&o.setCurrentTab(Jm.DIMENSIONS)}),[n,o]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)("div",{className:"relative h-[calc(100%_-_40px)] w-full px-2 pt-8",children:[(0,E.jsx)("div",{className:"absolute top-0 flex h-9 w-[calc(100%_-_16px)] overflow-y-hidden pt-2",children:i.map((e=>(0,E.jsx)("button",{onClick:()=>o.setCurrentTab(e),disabled:ea(n.info.configuration.gridMode)&&!a.includes(e),className:Mn("relative flex h-6 items-center justify-center whitespace-nowrap border border-b-0 border-l-0 border-neutral-300 px-2 first:border-l focus:z-10 disabled:text-neutral-400",{"-top-0.5 h-[27px] border-b-0 bg-white":e===r}),children:e},e)))}),(0,E.jsxs)("div",{className:"h-full w-full overflow-auto border border-neutral-300 bg-white",children:[r===Jm.COLUMNS&&(0,E.jsx)(Fm,{view:n}),r===Jm.HORIZONTAL_PIVOTS&&(0,E.jsx)(Pm,{view:n}),r===Jm.VERTICAL_PIVOTS&&(0,E.jsx)(Dm,{view:n}),r===Jm.DIMENSIONS&&(0,E.jsx)(zm,{view:n}),r===Jm.SORTS&&(0,E.jsx)(km,{view:n}),r===Jm.GENERAL_PROPERTIES&&(0,E.jsx)(Om,{view:n}),r===Jm.COLUMN_PROPERTIES&&(0,E.jsx)(Bm,{view:n})]})]}),(0,E.jsxs)("div",{className:"flex h-10 items-center justify-end px-2",children:[(0,E.jsx)(Tu,{onClick:()=>o.display.close(),children:"Cancel"}),(0,E.jsx)(Tu,{className:"ml-2",disabled:o.finalizationState.isInProgress,onClick:()=>{s(),o.applyChanges().catch((e=>t.alertUnhandledError(e)))},children:"Apply"}),(0,E.jsx)(Tu,{className:"ml-2",disabled:o.finalizationState.isInProgress,onClick:()=>{s(),o.applyChanges({closeAfterApply:!0}).catch((e=>t.alertUnhandledError(e)))},children:"OK"})]})]})}));class Ym extends pm{cloneColumn(e){return new mm(e.name,e.type,e.direction,e.onChange)}get availableColumns(){return this._editor.columnProperties.columns.filter((e=>e.kind===mi.DIMENSION&&!ra(this._editor.groupExtendColumns,e.name))).map((e=>new mm(e.name,e.type,bi.ASCENDING,(()=>this.onChange?.(this)))))}}class Xm{_editor;selector;castColumns=[];constructor(e){(0,Ie.Gn)(this,{castColumns:Ie.sH.ref,pivotResultColumns:Ie.EW,setCastColumns:Ie.XI,applySnaphot:Ie.XI}),this._editor=e,this.selector=new Ym(e,{onChange:e=>{this._editor.columnProperties.columns.forEach((t=>t.setPivotSortDirection(ra(e.selectedColumns,t.name)?.direction)))}})}get pivotResultColumns(){return this.castColumns.filter((e=>na(e.name))).map(ia)}setCastColumns(e){this.castColumns=e}propagateChanges(){this._editor.verticalPivots.adaptPropagatedChanges(),this._editor.dimensions.adaptPropagatedChanges(),this._editor.sorts.adaptPropagatedChanges()}applySnaphot(e,t){this.selector.setSelectedColumns((e.data.pivot?.columns??[]).map((e=>new mm(e.name,e.type,ra(t.columns,e.name)?.pivotSortDirection??bi.ASCENDING,(()=>this.selector.onChange?.(this.selector)))))),this.setCastColumns(e.data.pivot?.castColumns??[])}buildSnapshot(e,t){e.data.pivot=this.selector.selectedColumns.length?{columns:this.selector.selectedColumns.map(ia),castColumns:this.castColumns.map(ia)}:void 0,e.data.selectColumns=(0,nt.A)([...e.data.selectColumns,...this.selector.selectedColumns],(e=>e.name)).map(ia)}}class Km{_editor;pivotLayout=new Em;constructor(e){(0,Ie.Gn)(this,{pivotLayout:Ie.sH,applySnaphot:Ie.XI}),this._editor=e}applySnaphot(e,t){this.pivotLayout=Em.create(e.data.configuration.pivotLayout)}buildSnapshot(e,t){this.pivotLayout.setExpandedPaths(xc(t.data.groupBy?.columns??[],this._editor.verticalPivots.selector.selectedColumns,this.pivotLayout.expandedPaths)),e.data.configuration={...e.data.configuration,pivotLayout:this.pivotLayout.serialize()}}}class qm extends A{sourceInformation}var Jm;!function(e){e.GENERAL_PROPERTIES="General Properties",e.COLUMN_PROPERTIES="Column Properties",e.COLUMNS="Columns",e.VERTICAL_PIVOTS="Vertical Pivots",e.DIMENSIONS="Dimensions",e.HORIZONTAL_PIVOTS="Horizontal Pivots",e.SORTS="Sorts"}(Jm||(Jm={}));class Qm extends om{view;display;finalizationState=we.create();generalProperties;pivotLayout;columnProperties;columns;horizontalPivots;verticalPivots;dimensions;sorts;currentTab=Jm.GENERAL_PROPERTIES;sourceColumns=[];leafExtendColumns=[];groupExtendColumns=[];constructor(e){super(e.engine,e.settingService,e.snapshotService),(0,Ie.Gn)(this,{currentTab:Ie.sH,setCurrentTab:Ie.XI,sourceColumns:Ie.sH.ref,leafExtendColumns:Ie.sH.ref,groupExtendColumns:Ie.sH.ref,applySnapshot:Ie.XI,applyChanges:Ie.XI}),this.view=e,this.display=this.view.dataCube.layoutService.newDisplay("Properties",(()=>(0,E.jsx)($m,{view:this.view}))),this.generalProperties=new bm(this),this.pivotLayout=new Km(this),this.columnProperties=new vm(this),this.dimensions=new Mm(this),this.columns=new Tm(this),this.horizontalPivots=new Xm(this),this.verticalPivots=new Sm(this),this.sorts=new hm(this)}setCurrentTab(e){this.currentTab=e}async applySnapshot(e,t){this.sourceColumns=e.data.sourceColumns,this.leafExtendColumns=e.data.leafExtendedColumns,this.groupExtendColumns=e.data.groupExtendedColumns;const n=da.serialization.fromJson(e.data.configuration);this.generalProperties.applySnaphot(e,n),this.pivotLayout.applySnaphot(e,n),this.columnProperties.applySnaphot(e,n),this.dimensions.applySnaphot(e,n),this.columns.applySnaphot(e,n),this.horizontalPivots.applySnaphot(e,n),this.verticalPivots.applySnaphot(e,n),this.sorts.applySnaphot(e,n)}getSnapshotSubscriberName(){return"editor"}async applyChanges(e){this.finalizationState.inProgress();const t=D(this.getLatestSnapshot()),n=t.clone();if(this.generalProperties.buildSnapshot(n,t),this.pivotLayout.buildSnapshot(n,t),this.columnProperties.buildSnapshot(n,t),this.dimensions.buildSnapshot(n,t),this.columns.buildSnapshot(n,t),this.horizontalPivots.buildSnapshot(n,t),this.verticalPivots.buildSnapshot(n,t),this.sorts.buildSnapshot(n,t),n.finalize(),n.hashCode!==t.hashCode){const e=this.view.taskService.newTask("Validating query..."),t=n.clone();t.data.pivot&&(t.data.pivot.castColumns=this.sorts.selector.availableColumns.filter((e=>!ra(t.data.groupExtendedColumns,e.name))).map(ia));const o="->",r=await this.view.engine.getPartialQueryCode(t,!0);try{await this.view.engine.getQueryCodeRelationReturnType(o+r,kl([],[this.view.source.query]),this.view.source)}catch(e){return w(e),void(e instanceof qm?this.view.dataCube.alertService.alertCodeCheckError(e,r,o,{message:"Query Validation Failure: Can't safely apply changes. Check the query code below for more details.",text:`Error: ${e.message}`}):this.view.dataCube.alertService.alertError(e,{message:"Query Validation Failure: Can't safely apply changes.",text:`Error: ${e.message}`}))}finally{this.view.taskService.endTask(e),this.finalizationState.complete()}this.publishSnapshot(n)}else this.finalizationState.complete();e?.closeAfterApply&&this.display.close()}}function Zm({name:e,subMenu:t,checked:n}){return(0,Ir.sd)({configureDefaults:()=>!0}),(0,E.jsxs)("div",{children:[(0,E.jsx)("span",{className:"ag-menu-option-part ag-menu-option-icon"}),(0,E.jsxs)("span",{className:"ag-menu-option-part ag-menu-option-text !inline-flex items-center",children:[(0,E.jsx)("span",{className:"opacity-50",children:e}),(0,E.jsx)(vu,{})]}),(0,E.jsx)("span",{className:"ag-menu-option-part ag-menu-option-shortcut"}),(0,E.jsx)("span",{className:"ag-menu-option-part ag-menu-option-popup-pointer select-none",children:t&&(0,E.jsx)("span",{className:"ag-icon ag-icon-small-right"})})]})}function eg(e,t,n,o){const r=o.view.engine.getFilterOperation(t);return{name:`Add Filter: ${e.name} ${r.textLabel}${n.label?` ${n.label}`:""}`,action:()=>{o.addNewFilterCondition(new sm(o.filterTree.root,{name:e.name,type:e.type},r,n.value,void 0))}}}class tg extends om{view;constructor(e){super(e.engine,e.settingService,e.snapshotService),this.view=e}configuration=new da;menuBuilder;getColumnConfiguration(e){return ra(this.configuration.columns,e)}filterTree={nodes:new Map};addNewFilterCondition(e){if(this.filterTree.root)if(this.filterTree.root.operation===Ci.AND)this.filterTree.root.addChild(e),this.filterTree.nodes.set(e.uuid,e);else{const t=this.filterTree.root;if(1===t.children.length)t.operation=Ci.AND,t.addChild(e),this.filterTree.nodes.set(e.uuid,e);else{const n=new lm(void 0,Ci.AND,void 0);this.filterTree.nodes.set(n.uuid,n),this.filterTree.root=n,n.addChild(t),n.addChild(e),this.filterTree.nodes.set(e.uuid,e)}}else{const t=new lm(void 0,Ci.AND,void 0);this.filterTree.nodes.set(t.uuid,t),this.filterTree.root=t,t.addChild(e),this.filterTree.nodes.set(e.uuid,e)}this.applyChanges()}clearFilters(){this.filterTree.root=void 0,this.filterTree.nodes=new Map,this.applyChanges()}selectColumns=[];leafExtendedColumns=[];groupExtendedColumns=[];pinColumn(e,t){const n=this.getColumnConfiguration(e);n&&(n.pinned=t,this.applyChanges())}rearrangeColumns(e){const t=e.map((e=>this.getColumnConfiguration(e))).filter(L);this.configuration.columns=[...t,...this.configuration.columns.filter((e=>!t.includes(e)))];const n=e.map((e=>ra(this.selectColumns,e))).filter(L);this.selectColumns=[...n,...n.filter((e=>!n.includes(e)))],this.applyChanges()}removeAllPins(){this.configuration.columns.forEach((e=>e.pinned=void 0)),this.applyChanges()}showColumn(e,t){const n=this.getColumnConfiguration(e);n&&(n.hideFromView=!t,this.applyChanges())}horizontalPivotColumns=[];horizontalPivotCastColumns=[];get horizontalPivotResultColumns(){return this.horizontalPivotCastColumns.filter((e=>na(e.name))).map(ia)}getHorizontalPivotableColumn(e){return ra(this.configuration.columns.filter((e=>e.kind===mi.DIMENSION&&!ra(this.groupExtendedColumns,e.name))),e)}setHorizontalPivotOnColumn(e){const t=this.getHorizontalPivotableColumn(e);t&&(this.horizontalPivotColumns=[t],this.applyChanges())}addHorizontalPivotOnColumn(e){const t=this.getHorizontalPivotableColumn(e);t&&(this.horizontalPivotColumns=[...this.horizontalPivotColumns,t],this.applyChanges())}clearAllHorizontalPivots(){this.horizontalPivotColumns=[],this.horizontalPivotCastColumns=[],this.applyChanges()}excludeColumnFromHorizontalPivot(e){if(na(e)){const t=oa(e),n=this.getColumnConfiguration(t);n&&!n.excludedFromPivot&&(n.excludedFromPivot=!0,this.applyChanges())}}includeColumnInHorizontalPivot(e){const t=this.getColumnConfiguration(e);t?.excludedFromPivot&&(t.excludedFromPivot=!1,this.applyChanges())}verticalPivotColumns=[];getVerticalPivotableColumn(e){return ra(this.configuration.columns.filter((e=>e.kind===mi.DIMENSION&&!ra(this.groupExtendedColumns,e.name)&&!ra(this.horizontalPivotColumns,e.name))),e)}setVerticalPivotOnColumn(e){const t=this.getVerticalPivotableColumn(e);t&&(this.verticalPivotColumns=[t],this.applyChanges())}addVerticalPivotOnColumn(e){const t=this.getVerticalPivotableColumn(e);t&&(this.verticalPivotColumns=[...this.verticalPivotColumns,t],this.applyChanges())}removeVerticalPivotOnColumn(e){this.verticalPivotColumns=this.verticalPivotColumns.filter((t=>t.name!==e)),this.applyChanges()}clearAllVerticalPivots(){this.verticalPivotColumns=[],this.applyChanges()}collapseAllPaths(){this.view.grid.client.collapseAll(),this.configuration.pivotLayout.expandedPaths=[],this.applyChanges()}expandPath(e){this.configuration.pivotLayout.expandedPaths=(0,Ne.A)([...this.configuration.pivotLayout.expandedPaths,e]).sort(),this.applyChanges()}collapsePath(e){this.configuration.pivotLayout.expandedPaths=this.configuration.pivotLayout.expandedPaths.filter((t=>t!==e)),this.applyChanges()}sortColumns=[];getSortableColumn(e){if(e)return ra([...this.horizontalPivotCastColumns.length?this.horizontalPivotCastColumns:this.selectColumns,...this.groupExtendedColumns],e)}setSortByColumn(e,t){const n=this.getSortableColumn(e);n&&(this.sortColumns=[{...n,direction:t}],this.applyChanges())}addSortByColumn(e,t){const n=this.getSortableColumn(e);n&&(this.sortColumns=[...this.sortColumns,{...n,direction:t}],this.applyChanges())}clearSortByColumn(e){this.sortColumns=this.sortColumns.filter((t=>t.name!==e)),this.applyChanges()}clearAllSorts(){this.sortColumns=[],this.applyChanges()}getSnapshotSubscriberName(){return"grid-controller"}async applySnapshot(e,t){this.configuration=da.serialization.fromJson(e.data.configuration),this.filterTree.nodes=new Map,this.filterTree.root=e.data.filter?um(e.data.filter,void 0,this.filterTree.nodes,(e=>this.view.engine.getFilterOperation(e))):void 0,this.selectColumns=e.data.selectColumns,this.leafExtendedColumns=e.data.leafExtendedColumns,this.groupExtendedColumns=e.data.groupExtendedColumns,this.horizontalPivotColumns=e.data.pivot?.columns??[],this.horizontalPivotCastColumns=e.data.pivot?.castColumns??[],this.verticalPivotColumns=e.data.groupBy?.columns??[],this.sortColumns=e.data.sortColumns,this.menuBuilder=ea(this.view.info.configuration.gridMode)?function(e){const t=e.view,n=t.dataCube;return(o,r)=>{const i=o.column??void 0,a=i?.getColId(),s=e.getColumnConfiguration(a);return[{name:"Zoom Out",action:e=>{const r=e.node?.data.metadata;t.grid.retrieveDrilloutData(r,D(o.column?.getColId())).catch((e=>n.alertService.alertUnhandledError(e)))}},{name:"Export",subMenu:[{name:"HTML",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"PDF",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Excel",action:()=>t.grid.exportEngine.exportFile(rp.EXCEL)},{name:"CSV",action:()=>t.grid.exportEngine.exportFile(rp.CSV)},"separator",{name:"DataCube Specification",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0}]},{name:"Email",subMenu:[{name:"HTML",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},"separator",{name:"HTML Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Plain Text Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"PDF Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Excel Attachment",action:()=>{t.grid.exportEngine.exportEmail(rp.EXCEL).catch((e=>n.alertService.alertUnhandledError(e)))}},{name:"CSV Attachment",action:()=>{t.grid.exportEngine.exportEmail(rp.CSV).catch((e=>n.alertService.alertUnhandledError(e)))}},{name:"DataCube Specification Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0}]},"separator",{name:"Resize",subMenu:[{name:"Auto-size to Fit Content",disabled:!i||!s||void 0!==s.fixedWidth,action:()=>o.api.autoSizeColumns([i?.getColId()].filter(L))},{name:"Minimize Column",disabled:!i||!s||void 0!==s.fixedWidth,action:()=>{i&&s&&o.api.setColumnWidths([{key:s.name,newWidth:s.minWidth??Di}])}},"separator",{name:"Auto-size All Columns",action:()=>o.api.autoSizeColumns([...e.configuration.columns.filter((e=>void 0===e.fixedWidth&&e.isSelected&&!e.hideFromView)).map((e=>e.name)),...e.horizontalPivotCastColumns.map((t=>{if(na(t.name)){const n=ra(e.configuration.columns,oa(t.name));if(n&&void 0===n.fixedWidth&&n.isSelected&&!n.hideFromView)return t.name}})).filter(L)])},{name:"Minimize All Columns",action:()=>{o.api.setColumnWidths([...e.configuration.columns.filter((e=>void 0===e.fixedWidth)).map((e=>({key:e.name,newWidth:s?.minWidth??Di}))),...e.horizontalPivotCastColumns.map((t=>{if(na(t.name)){const n=ra(e.configuration.columns,oa(t.name));if(n&&void 0===n.fixedWidth&&n.isSelected&&!n.hideFromView)return{key:t.name,newWidth:n.minWidth??Di}}})).filter(L)])}},{name:"Size Grid to Fit Screen",action:()=>o.api.sizeColumnsToFit()}]}]}}(this):function(e){const t=e.view,n=t.dataCube,o=t.filter,r=t.editor,i=t.extend,a=e=>{t.dataCube.telemetryService.sendTelemetry(Ud.EMAIL_DATACUBE,{...t.engine.getDataFromSource(t.getInitialSource()),emailFormat:e})},s=e=>{t.dataCube.telemetryService.sendTelemetry(Ud.EXPORT_DATACUBE,{...t.engine.getDataFromSource(t.getInitialSource()),exportFormat:e})},l=(e,n)=>{const o=void 0===n?{menuName:e}:{menuName:e,subMenuName:n};t.dataCube.telemetryService.sendTelemetry(Ud.SELECT_ITEM_GRIDMENU,{...t.engine.getDataFromSource(t.getInitialSource()),...o})};return(c,u)=>{const d=c.column??void 0,p=d?.getColId(),m=e.getColumnConfiguration(p),g=p&&na(p)?e.getColumnConfiguration(oa(p)):void 0,h=p&&ra([...e.leafExtendedColumns,...e.groupExtendedColumns],p),f="value"in c?c.value:void 0,E=[{name:"Sort",subMenu:[...d&&p&&e.getSortableColumn(p)?[{name:"Ascending",action:()=>{e.setSortByColumn(p,bi.ASCENDING),l("Sort","Ascending")}},{name:"Descending",action:()=>{e.setSortByColumn(p,bi.DESCENDING),l("Sort","Descending")}},{name:"Clear Sort",disabled:!ra(e.sortColumns,p),action:()=>{e.clearSortByColumn(p),l("Sort","Clear Sort")}},"separator",{name:"Add Ascending",disabled:Boolean(e.sortColumns.find((e=>e.name===p&&e.direction===bi.ASCENDING))),action:()=>{e.addSortByColumn(p,bi.ASCENDING),l("Sort","Add Ascending")}},{name:"Add Descending",disabled:Boolean(e.sortColumns.find((e=>e.name===p&&e.direction===bi.DESCENDING))),action:()=>{e.addSortByColumn(p,bi.DESCENDING),l("Sort","Add Descending")}},"separator"]:[],{name:"Clear All Sorts",disabled:0===e.sortColumns.length,action:()=>{e.clearAllSorts(),l("Clear All Sorts")}}]}];let C=[];if(d&&void 0!==f){let t=m;if(d.getColId()===Tp&&e.verticalPivotColumns.length&&"node"in c&&c.node){const n=e.verticalPivotColumns[c.node.level];t=e.getColumnConfiguration(n?.name)}if(t)if(f!==_p){const n=function(e,t){const n=`${t.type===Wr.STRING?`'${e}'`:e}`;let o;switch(t.type){case Wr.STRING:o=e;break;case Wr.NUMBER:case Wr.DECIMAL:case Wr.FLOAT:case Wr.INTEGER:o=z(Number(e));break;case Wr.DATE:case Wr.STRICTDATE:case Wr.DATETIME:o=e;break;default:throw new I(`Can't filter on column with unsupported type '${t.type}'`)}return{label:n,value:{type:t.type,value:o}}}(f,t),o=function(e){switch(e.type){case Wr.STRING:return[Ei.EQUAL,Ei.NOT_EQUAL,Ei.LESS_THAN,Ei.LESS_THAN_OR_EQUAL,Ei.GREATER_THAN,Ei.GREATER_THAN_OR_EQUAL,Ei.CONTAIN,Ei.NOT_CONTAIN,Ei.START_WITH,Ei.NOT_START_WITH,Ei.END_WITH,Ei.NOT_END_WITH];case Wr.NUMBER:case Wr.DECIMAL:case Wr.FLOAT:case Wr.INTEGER:case Wr.DATE:case Wr.STRICTDATE:case Wr.DATETIME:return[Ei.EQUAL,Ei.NOT_EQUAL,Ei.LESS_THAN,Ei.LESS_THAN_OR_EQUAL,Ei.GREATER_THAN,Ei.GREATER_THAN_OR_EQUAL];default:return[]}}(t);if(o.length&&o.includes(Ei.EQUAL)){const r=o.filter((e=>e!==Ei.EQUAL));C=[eg(t,Ei.EQUAL,n,e),r.length?{name:`More Filters on ${p}...`,subMenu:r.map((o=>eg(t,o,n,e)))}:void 0].filter(L)}}else C=[eg(t,Ei.IS_NULL,{value:{type:gi.VOID}},e),eg(t,Ei.IS_NOT_NULL,{value:{type:gi.VOID}},e)]}return[{name:"Export",subMenu:[{name:"HTML",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"PDF",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Excel",action:()=>{t.grid.exportEngine.exportFile(rp.EXCEL),s(rp.EXCEL)}},{name:"CSV",action:()=>{t.grid.exportEngine.exportFile(rp.CSV),s(rp.CSV)}},"separator",{name:"DataCube Specification",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0}]},{name:"Email",subMenu:[{name:"HTML",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},"separator",{name:"HTML Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Plain Text Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"PDF Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Excel Attachment",action:()=>{t.grid.exportEngine.exportEmail(rp.EXCEL).catch((e=>n.alertService.alertUnhandledError(e))),a(rp.EXCEL)}},{name:"CSV Attachment",action:()=>{t.grid.exportEngine.exportEmail(rp.CSV).catch((e=>n.alertService.alertUnhandledError(e))),a(rp.CSV)}},{name:"DataCube Specification Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0}]},{name:"Copy",menuItem:Zm,cssClasses:["!opacity-100"],subMenu:[{name:"Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Selected Rows as Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Selected Column as Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0}]},"separator",...E,{name:"Filter",subMenu:[...C,C.length?"separator":void 0,{name:"Filters...",action:()=>{o.display.open(),t.dataCube.telemetryService.sendTelemetry(Ud.OPEN_EDITOR_FILTER,{...t.engine.getDataFromSource(t.getInitialSource()),openedFrom:Ai.GRID_MENU})}},{name:"Clear All Filters",action:()=>{e.clearFilters(),l("Filter","Clear All Filters")}}].filter(L)},{name:"Pivot",subMenu:[...d&&p&&m?.kind===mi.DIMENSION&&e.getVerticalPivotableColumn(p)?[{name:`Vertical Pivot on ${p}`,action:()=>{e.setVerticalPivotOnColumn(p),l("Pivot","Vertical Pivot")}},{name:`Add Vertical Pivot on ${p}`,disabled:Boolean(ra(e.verticalPivotColumns,p)),action:()=>{e.addVerticalPivotOnColumn(p),l("Pivot","Add Vertical Pivot")}},{name:`Remove Vertical Pivot on ${p}`,disabled:!ra(e.verticalPivotColumns,p),action:()=>{e.removeVerticalPivotOnColumn(p),l("Pivot","Remove Vertical Pivot")}},"separator"]:[],...d&&p&&m?.kind===mi.DIMENSION&&e.getHorizontalPivotableColumn(p)?[{name:`Horizontal Pivot on ${p}`,action:()=>{e.setHorizontalPivotOnColumn(p),l("Pivot","Horizontal Pivot")}},{name:`Add Horizontal Pivot on ${p}`,disabled:Boolean(ra(e.horizontalPivotColumns,p)),action:()=>{e.addHorizontalPivotOnColumn(p),l("Pivot","Add Horizontal Pivot")}},"separator"]:[],...d&&p&&g?.kind===mi.MEASURE&&!g.excludedFromPivot&&0!==e.horizontalPivotColumns.length?[{name:`Exclude Column ${g.name} from Horizontal Pivot`,action:()=>{e.excludeColumnFromHorizontalPivot(p),l("Pivot","Exclude Column From Horizontal Pivot")}},"separator"]:[],...d&&p&&m?.kind===mi.MEASURE&&m.excludedFromPivot&&0!==e.horizontalPivotColumns.length?[{name:`Include Column ${p} in Horizontal Pivot`,action:()=>{e.includeColumnInHorizontalPivot(p),l("Pivot","Include Column in Horizontal Pivot")}},"separator"]:[],{name:"Clear All Vertical Pivots",disabled:0===e.verticalPivotColumns.length,action:()=>{e.clearAllVerticalPivots(),l("Pivot","Clear All Vertical Pivots")}},{name:"Clear All Horizontal Pivots",disabled:0===e.horizontalPivotColumns.length,action:()=>{e.clearAllHorizontalPivots(),l("Pivot","Clear All Horizontal Pivots")}}]},{name:"Extended Columns",subMenu:[{name:"Add New Column...",action:()=>{i.openNewColumnEditor().catch((e=>n.alertService.alertUnhandledError(e))),l("Extended Columns","Add New Column...")}},...m&&p?[{name:`Extend Column ${p}...`,action:()=>{i.openNewColumnEditor(m).catch((e=>n.alertService.alertUnhandledError(e))),l("Extended Columns","Extend Column")}}]:[],...h?["separator",{name:`Edit Column ${p}...`,action:()=>{i.openExistingColumnEditor(p).catch((e=>n.alertService.alertUnhandledError(e))),l("Extended Columns","Edit Column")}},{name:`Delete Column ${p}`,action:()=>{i.deleteColumn(p).catch((e=>n.alertService.alertUnhandledError(e))),l("Extended Columns","Delete Column")}}]:[]]},"separator",{name:"Resize",subMenu:[{name:"Auto-size to Fit Content",disabled:!d||!m||void 0!==m.fixedWidth,action:()=>{c.api.autoSizeColumns([d?.getColId()].filter(L)),l("Resize","Auto-size to Fit Content")}},{name:"Minimize Column",disabled:!d||!m||void 0!==m.fixedWidth,action:()=>{d&&m&&c.api.setColumnWidths([{key:m.name,newWidth:m.minWidth??Di}]),l("Resize","Minimize Column")}},"separator",{name:"Auto-size All Columns",action:()=>{c.api.autoSizeColumns([...e.configuration.columns.filter((e=>void 0===e.fixedWidth&&e.isSelected&&!e.hideFromView)).map((e=>e.name)),...e.horizontalPivotCastColumns.map((t=>{if(na(t.name)){const n=ra(e.configuration.columns,oa(t.name));if(n&&void 0===n.fixedWidth&&n.isSelected&&!n.hideFromView)return t.name}})).filter(L)]),l("Resize","Auto-size All Columns")}},{name:"Minimize All Columns",action:()=>{c.api.setColumnWidths([...e.configuration.columns.filter((e=>void 0===e.fixedWidth)).map((e=>({key:e.name,newWidth:m?.minWidth??Di}))),...e.horizontalPivotCastColumns.map((t=>{if(na(t.name)){const n=ra(e.configuration.columns,oa(t.name));if(n&&void 0===n.fixedWidth&&n.isSelected&&!n.hideFromView)return{key:t.name,newWidth:n.minWidth??Di}}})).filter(L)]),l("Resize","Minimize All Columns")}},{name:"Size Grid to Fit Screen",action:()=>{c.api.sizeColumnsToFit(),l("Resize","Size Grid to Fit Screen")}}]},{name:"Pin",subMenu:[...m?[{name:"Pin Left",disabled:!d||d.isPinnedLeft(),checked:Boolean(d?.isPinnedLeft()),action:()=>{e.pinColumn(p,vi.LEFT),l("Pin","Pin Left")}},{name:"Pin Right",disabled:!d||d.isPinnedRight(),checked:Boolean(d?.isPinnedRight()),action:()=>{e.pinColumn(p,vi.RIGHT),l("Pin","Pin Right")}},{name:"Unpin",disabled:!d?.isPinned(),action:()=>{e.pinColumn(p,void 0),l("Pin","Unpin")}},"separator"]:[],{name:"Remove All Pinnings",disabled:e.configuration.columns.every((e=>void 0===e.pinned)),action:()=>{e.removeAllPins(),l("Pin","Remove All Pinnings")}}]},{name:"Hide",disabled:!m,action:()=>{e.showColumn(p,!1),l("Hide")}},...p===Tp?["separator",{name:"Collapse All",action:()=>{e.collapseAllPaths()}}]:[],"separator",{name:"Heatmap",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!d,subMenu:d?[{name:`Add to ${d.getColId()}`,menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:`Remove from ${d.getColId()}`,menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0}]:[]},{name:"Show Plot...",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Show TreeMap...",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},"separator",{name:"Properties...",disabled:r.display.isOpen,action:()=>{d&&u&&(r.setCurrentTab(Jm.COLUMN_PROPERTIES),r.columnProperties.setSelectedColumnName(g?.name??m?.name??p)),r.display.open(),t.dataCube.telemetryService.sendTelemetry(Ud.OPEN_EDITOR_PROPERTIES,{...t.engine.getDataFromSource(t.getInitialSource()),openedFrom:Ai.GRID_MENU})}}]}}(this)}propagateChanges(e){this.verticalPivotColumns=this.verticalPivotColumns.filter((e=>!ra(this.horizontalPivotColumns,e.name))),this.configuration.pivotLayout.expandedPaths=xc(e.data.groupBy?.columns??[],this.verticalPivotColumns,this.configuration.pivotLayout.expandedPaths),this.configuration.columns.forEach((e=>{e.pivotSortDirection=ra(this.horizontalPivotColumns,e.name)?e.pivotSortDirection??bi.ASCENDING:void 0})),this.selectColumns=(0,nt.A)([...this.configuration.columns.filter((e=>e.isSelected&&!ra(this.groupExtendedColumns,e.name))),...this.horizontalPivotColumns,...this.verticalPivotColumns],(e=>e.name)).map(ia);const t=(0,nt.A)([...this.horizontalPivotColumns.length?[...this.horizontalPivotResultColumns,...[...this.configuration.columns.filter((e=>e.isSelected)),...this.verticalPivotColumns].filter((e=>this.getColumnConfiguration(e.name)?.kind===mi.DIMENSION&&!ra(this.horizontalPivotColumns,e.name)))]:[...this.configuration.columns.filter((e=>e.isSelected)),...this.verticalPivotColumns],...this.groupExtendedColumns],(e=>e.name));this.sortColumns=this.sortColumns.filter((e=>ra(t,e.name)))}applyChanges(){const e=D(this.getLatestSnapshot()),t=e.clone();this.propagateChanges(e),t.data.configuration=this.configuration.serialize(),t.data.filter=this.filterTree.root?cm(this.filterTree.root):void 0,t.data.selectColumns=this.selectColumns,t.data.pivot=this.horizontalPivotColumns.length?{columns:this.horizontalPivotColumns,castColumns:this.horizontalPivotCastColumns}:void 0,t.data.groupBy=this.verticalPivotColumns.length?{columns:this.verticalPivotColumns}:void 0,t.data.sortColumns=this.sortColumns,t.finalize(),t.hashCode!==e.hashCode&&this.publishSnapshot(t)}}function ng(e){return new Promise(((t,n)=>{const o=new FileReader;o.onloadend=()=>{const e=o.result;if(U(e)){const n=e.split(",")[1];if(n)return void t(n)}n(new Error("Can't base64 encode blob data"))},o.onerror=e=>n(e),o.readAsDataURL(e)}))}const og="mixed_boundary",rg="alternative_boundary",ig=`\nFrom:\nTo:\nSubject:\nX-Unsent: 1\nContent-Type: multipart/mixed; boundary="${og}"\n\n--${og}\nContent-Type: multipart/alternative; boundary="${rg}"\n\n--${rg}\nContent-Type: text/plain; charset="UTF-8"\nContent-Transfer-Encoding: 7bit\n\n\n\n--${rg}\nContent-Type: text/html; charset="UTF-8"\nContent-Transfer-Encoding: 7bit\n\n<html><body><p></p><body></html>\n\n--${rg}--\n\n`;class ag{_grid;constructor(e){this._grid=e}generateFileName(){return`${this._grid.configuration.name} - ${(0,Kn.GP)(new Date,"EEE MMM dd yyyy HH_mm_ss")}`}exportFile(e){const t=this.generateFileName();switch(e){case rp.CSV:return void this._grid.client.exportDataAsCsv({fileName:`${t}.csv`});case rp.EXCEL:return void this._grid.client.exportDataAsExcel({fileName:`${t}.xlsx`})}}async exportEmail(e){const t=this.generateFileName();let n,o,r=t;switch(e){case rp.CSV:r=`${t}.csv`,o=ee.TEXT_CSV,n=await ng(new Blob([this._grid.client.getDataAsCsv()??""],{type:ee.TEXT_CSV}));break;case rp.EXCEL:{r+=`${t}.xlsx`,o=ee.APPLICATION_XLSX;const e=this._grid.client.getDataAsExcel();let i;if(e instanceof Blob)i=e;else{if("string"!=typeof e)throw new x("Can't export Excel content");i=new Blob([e],{type:ee.APPLICATION_XLSX})}n=await ng(i);break}default:throw new I(`Can't export email in format '${e}'`)}le(`${t}.eml`,`${ig.trimStart()}--${og}\nContent-Type: ${o}; name="${r}"\nContent-Transfer-Encoding: base64\nContent-Disposition: attachment; filename="${r}"\n\n${n}\n\n--${og}--`,ee.MESSAGE_RFC822)}}class sg extends om{_view;controller;exportEngine;_client;clientDataSource;configuration=new da;rowLimit;isPaginationEnabled=!0;isCachingEnabled=!1;scrollHintText;debouncedAutoResizeColumns;constructor(e){super(e.engine,e.settingService,e.snapshotService),(0,Ie.Gn)(this,{clientDataSource:Ie.sH,configuration:Ie.sH,rowLimit:Ie.sH,isPaginationEnabled:Ie.sH,setPaginationEnabled:Ie.XI,isCachingEnabled:Ie.sH,setCachingEnabled:Ie.XI,scrollHintText:Ie.sH,setScrollHintText:Ie.XI,applySnapshot:Ie.XI}),this._view=e,this.controller=new tg(this._view),this.exportEngine=new ag(this),this.clientDataSource=new Dp(this,this._view)}setPaginationEnabled(e){this.isPaginationEnabled=e,this.clientDataSource=new Dp(this,this._view),this.client.updateGridOptions({cacheBlockSize:e?500:mp}),this._engine.sendTelemetry(e?Ud.PAGINATION_ENABLE__SUCCESS:Ud.PAGINATION_DISABLE__SUCCESS,this._engine.getDataFromSource(this._view.getInitialSource()))}async setCachingEnabled(e,t){if(e===this.isCachingEnabled)return;if(!1===e){const t=new tm;return await this._view.disposeCache(),(0,Ie.h5)((()=>{this.isCachingEnabled=e,this.clientDataSource=new Dp(this,this._view)})),void this._engine.sendTelemetry(Ud.CACHING_DISABLE__SUCCESS,{...this._engine.getDataFromSource(this._view.getInitialSource()),timings:this._engine.finalizeTimingRecord(t)})}const n=async()=>{const t=new tm;await this._view.initializeCache(),this._view.processCacheState.hasSucceeded&&(0,Ie.h5)((()=>{this.isCachingEnabled=e,this.clientDataSource=new Dp(this,this._view)})),this._engine.sendTelemetry(Ud.CACHING_ENABLE__SUCCESS,{...this._engine.getDataFromSource(this._view.getInitialSource()),timings:this._engine.finalizeTimingRecord(t)})};this._settingService.getBooleanValue(Uu.GRID_CLIENT__SHOW_CACHE_PERFORMANCE_WARNING)&&!t?.suppressWarning?this._view.alertService.alert({message:"Confirm you want to proceed with caching",text:"When enabled, the source dataset will be cached locally in order to boost query performance. But depending on computational resource available to your environment, sometimes, caching can negatively impact the overall performance, and can even lead to crashes.\n\nOverall, caching is still an experimental feature where we only support queries with simple execution plans, certain queries might not work, in which case, you can abort by turning off caching.\n\nDo you still want to proceed?",type:Mu.WARNING,actions:[{label:"Abort",handler:()=>{}},{label:"Proceed",handler:()=>{n().catch((e=>this._view.alertService.alertUnhandledError(e)))}},{label:"Dismiss Warning and Proceed",handler:()=>{this._view.settingService.updateValue(this._view.dataCube.api,Uu.GRID_CLIENT__SHOW_CACHE_PERFORMANCE_WARNING,!1),n().catch((e=>this._view.alertService.alertUnhandledError(e)))}}],windowConfig:{...Er,width:600,height:300,minWidth:300,minHeight:150}}):await n()}setScrollHintText(e){this.scrollHintText=e}get isClientConfigured(){return Boolean(this._client)}get client(){return D(this._client,"Grid client is not configured")}async configureClient(e){this._client=e,this.debouncedAutoResizeColumns=(0,Bn.A)((()=>e?.autoSizeAllColumns()),100);const t=this.getLatestSnapshot();t&&await this.applySnapshot(t,void 0)}async configureDimensionGridClient(e){this._client=e,this.debouncedAutoResizeColumns=(0,Bn.A)((()=>e?.autoSizeAllColumns()),100);const t=this.getLatestSnapshot();t&&(t.data.dimensionalTree||(t.data.dimensionalTree=cc(da.serialization.fromJson(t.data.configuration))),await this._applyDimensionalSnapshot(t))}async retrieveDrilloutData(e,t){const n=D(this.getLatestSnapshot()),o=ac(D(n.data.dimensionalTree));!function(e,t,n,o){for(const r of e.rootNodes){if(r.dimension!==t)continue;const e=uc(r,n,o,null);if(!e)continue;const{parent:i,index:a}=e;return i&&i.childNodes.splice(a,1),!0}}(D(n.data.dimensionalTree),t,D(e.get(t)?.column),D(e.get(t)?.groupByNodes)),await this._applyDimensionalSnapshot(n,o)}async retrieveDrilldownData(e){const t=D(this.getLatestSnapshot()),n=ac(D(t.data.dimensionalTree));t.data.dimensionalTree=cc(da.serialization.fromJson(t.data.configuration),e,t.data.dimensionalTree),await this._applyDimensionalSnapshot(t,n)}async _applyDimensionalSnapshot(e,t){this._client?.hideOverlay(),this._client?.setGridOption(Ni.LOADING,!0);const n=await async function(e,t,n){const o=t.taskService.newTask("Fetching data...");let r=[];const i=da.serialization.fromJson(e.data.configuration);let a=lc(D(e.data.dimensionalTree));if(n){const e=lc(n);e.length<=a.length&&(r=t.grid.client.getGridOption(Ni.ROW_DATA),a=function(e,t){const n=new Set(e.map(pc));return t.filter((e=>!n.has(pc(e))))}(e,a))}for(const n of a){const a=Vu(e,t.source,t.engine,n);let s;try{s=await t.engine.executeQuery(kl([],[a]),t.source,{debug:t.settingService.getBooleanValue(Uu.DEBUGGER__ENABLE_DEBUG_MODE),clientVersion:t.settingService.getBooleanValue(Uu.DEBUGGER__USE_DEV_CLIENT_PROTOCOL_VERSION)?gc.VX_X_X:void 0}),r=Op(s.result.result,0,n,r,i.dimensions.dimensions)}catch(e){return w(e),e instanceof jd?t.alertService.alertExecutionError(e,{message:"Data Fetch Failure: Can't execute query.",text:`Error: ${e.message}`}):t.alertService.alertError(e,{message:`Data Fetch Failure: ${e.message}`}),t.taskService.endTask(o),{rowData:[],columnDefs:[]}}t.settingService.getBooleanValue(Uu.DEBUGGER__ENABLE_DEBUG_MODE)&&t.engine.debugProcess("Execution",["Query",s.executedQuery],["Stats",`${r.length} rows, ${s.result.result.columns.length} columns`],["SQL",s.executedSQL??"-- Error: failed to extract executed SQL"],["SQL Execution Time",s.executionTime])}return t.taskService.endTask(o),{rowData:r,columnDefs:op(e,i)}}(e,this._view,t);this._client?.setGridOption(Ni.ROW_DATA,n.rowData),this._client?.setGridOption(Ni.COLUMN_DEFS,n.columnDefs),0===n.rowData.length&&this._client?.showNoRowsOverlay(),this._client?.setGridOption(Ni.LOADING,!1),this.publishSnapshot(e)}getSnapshotSubscriberName(){return"grid"}async applySnapshot(e,t){const n=da.serialization.fromJson(e.data.configuration);if(this.configuration=n,n.gridMode!==Ti.STANDARD||!this._client||this._client.isDestroyed())return;const o=function(e,t,n){return{isServerSideGroupOpenByDefault:e=>{if(void 0!==t.initialExpandLevel&&t.initialExpandLevel>0&&e.rowNode.level<=(t.showRootAggregation?t.initialExpandLevel+1:t.initialExpandLevel)-1)return!0;const n=e.rowNode.getRoute()??[];if(!n.length)return!1;if(t.showRootAggregation&&1===n.length&&n[0]===Ri)return!0;t.showRootAggregation&&n.shift();const o=n.join(xi);return!!t.pivotLayout.expandedPaths.includes(o)},rowClassRules:t.alternateRows?{[ip.HIGHLIGHT_ROW]:e=>e.rowIndex%(2*t.alternateRowsCount)>=t.alternateRowsCount}:{},onColumnPinned:e=>{if("api"!==e.source&&e.column){const t=e.column,o=t.getPinned();n.grid.controller.pinColumn(t.getColId(),null===o?void 0:o===yp.LEFT?vi.LEFT:vi.RIGHT)}},onColumnMoved:e=>{"api"!==e.source&&e.column&&e.finished&&n.grid.controller.rearrangeColumns((e.api.getColumnDefs()??[]).filter((e=>!("children"in e))).map((e=>e.colId??"")))},onColumnVisible:e=>{if("api"!==e.source&&e.column){const t=e.column,o=t.isVisible();n.grid.controller.showColumn(t.getColId(),o)}},onRowGroupOpened:e=>{if(e.event){const o=e.node.getRoute()??[];o.length&&t.showRootAggregation&&o.shift();const r=o.join(xi);if(!r)return;e.expanded?n.grid.controller.expandPath(r):n.grid.controller.collapsePath(r)}},onVirtualColumnsChanged:()=>{n.grid.debouncedAutoResizeColumns?.cancel(),n.grid.debouncedAutoResizeColumns?.()},columnDefs:np(e,t),autoGroupColumnDef:{colId:Tp,headerName:"",cellRendererParams:{suppressCount:!t.showLeafCount},...Xd(e,t),minWidth:200,sortable:!0,showRowGroup:!0,suppressSpanHeaderHeight:!0}}}(e,n,this._view);this._settingService.getBooleanValue(Uu.DEBUGGER__ENABLE_DEBUG_MODE)&&this._engine.debugProcess("New Grid Options",["Grid Options",o]),this.client.updateGridOptions({...o,rowBuffer:this._settingService.getNumericValue(Uu.GRID_CLIENT__ROW_BUFFER),purgeClosedRowNodes:this._settingService.getBooleanValue(Uu.GRID_CLIENT__PURGE_CLOSED_ROW_NODES),cacheBlockSize:this.isPaginationEnabled?500:mp}),this.client.setFilterModel({[Sp]:{type:"equals",filter:Rp(e,n)}})}}class lg extends om{_view;configuration=new da;name="";constructor(e){super(e.engine,e.settingService,e.snapshotService),(0,Ie.Gn)(this,{configuration:Ie.sH,name:Ie.sH,applySnapshot:Ie.XI}),this._view=e}getSnapshotSubscriberName(){return"info"}async applySnapshot(e,t){const n=e.data,o=da.serialization.fromJson(n.configuration);this.configuration=o,o.name!==this.name&&(this.name=o.name,this._view.dataCube.options?.onNameChanged?.({api:this._view.dataCube.api,name:this.name,source:this._view.source}))}}const cg=[{func:si.EXTEND,parameters:1,stopCondition:e=>ga(e.function,si.EXTEND)&&e.parameters[0]instanceof ha&&ga(e.parameters[0].function,si.OVER)},{func:si.FILTER,parameters:1},{func:si.SELECT,parameters:1},{func:si.GROUP_BY,parameters:2},{func:si.PIVOT,parameters:2},{func:si.CAST,parameters:1},{func:si.SORT,parameters:1},{func:si.LIMIT,parameters:1}];var ug;!function(e){e.LEAF_EXTEND="leaf_extend",e.FILTER="filter",e.SELECT="select",e.PIVOT__GROUP="pivot__group",e.PIVOT_SORT="pivot_sort",e.PIVOT="pivot",e.PIVOT_CAST="pivot_cast",e.GROUP_BY__GROUP="group_by__group",e.GROUP_BY="group_by",e.GROUP_BY_SORT="group_by_sort",e.GROUP_EXTEND="group_extend",e.SORT="sort",e.LIMIT="limit"}(ug||(ug={}));const dg=[{name:ug.LEAF_EXTEND,func:si.EXTEND,repeat:!0},{name:ug.FILTER,func:si.FILTER},{name:ug.SELECT,func:si.SELECT},{name:ug.PIVOT__GROUP,funcs:[{name:ug.PIVOT_SORT,func:si.SORT,required:!0},{name:ug.PIVOT,func:si.PIVOT,required:!0},{name:ug.PIVOT_CAST,func:si.CAST,required:!0}]},{name:ug.GROUP_BY__GROUP,funcs:[{name:ug.GROUP_BY,func:si.GROUP_BY,required:!0},{name:ug.GROUP_BY_SORT,func:si.SORT,required:!0}]},{name:ug.GROUP_EXTEND,func:si.EXTEND,repeat:!0},{name:ug.SORT,func:si.SORT},{name:ug.LIMIT,func:si.LIMIT}],pg=new RegExp(`^${dg.map((e=>"funcs"in e?`(${e.funcs.map((e=>`(?<${e.name}>${e.repeat?`(?:<${ma(e.func)}>____\\d+)*`:`<${ma(e.func)}>____\\d+`})${e.repeat||e.required?"":"?"}`)).join("")})${e.repeat?"*":e.required?"":"?"}`:`(?<${e.name}>${e.repeat?`(?:<${ma(e.func)}>____\\d+)*`:`<${ma(e.func)}>____\\d+`})${e.repeat||e.required?"":"?"}`)).join("")}$`);async function mg(e,t,n,o){const r=function(e){if(!(e instanceof ha))throw new Error("Can't process expression: expected a function expression");const t=[];let n=e;for(;n instanceof ha;){const e=cg.find((e=>ga(n.function,e.func)));if(!e)throw new Error(`Can't process expression: found unsupported function ${n.function}()`);if(!(n.parameters.length>e.parameters)){t.unshift(n);break}{if(e.stopCondition?.(n)){t.unshift(n);break}M(n.parameters.length===e.parameters+1,`Can't process ${ma(n.function)}() expression: expected at most ${e.parameters+1} parameters provided, got ${n.parameters.length}`);const o=vc(n,0,ha,"Can't process expression: expected a sequence of function calls (e.g. x()->y()->z())");n.parameters=n.parameters.slice(1),t.unshift(n),n=o}}const o=t.map(((e,t)=>`<${ma(e.function)}>____${t}`)).join("").match(pg);if(!o)throw new Error(`Can't process expression: unsupported function composition ${t.map((e=>`${ma(e.function)}()`)).join("->")} (supported composition: ${dg.map((e=>"funcs"in e?`[${e.funcs.map((e=>`${ma(e.func)}()`)).join("->")}]`:`${ma(e.func)}()`)).join("->")})`);const r=e=>{const n=o.groups?.[e];if(!n)return;const r=n.match(/\<.*?\>____\d+/g);return r?.length?r.map((e=>{const n=Number(e.split("____")[1]);if(!(isNaN(n)||n>=t.length))return N(t,n)})).filter(L):void 0};return{leafExtend:r(ug.LEAF_EXTEND),select:r(ug.SELECT)?.[0],filter:r(ug.FILTER)?.[0],pivotSort:r(ug.PIVOT_SORT)?.[0],pivot:r(ug.PIVOT)?.[0],pivotCast:r(ug.PIVOT_CAST)?.[0],groupBy:r(ug.GROUP_BY)?.[0],groupBySort:r(ug.GROUP_BY_SORT)?.[0],groupExtend:r(ug.GROUP_EXTEND),sort:r(ug.SORT)?.[0],limit:r(ug.LIMIT)?.[0]}}(o.deserializeValueSpecification(o.serializeValueSpecification(e))),i=Ld.create({}),a=i.data,s=new Map,l=(e,t)=>{if(s.has(e.name))throw new Error(t);s.set(e.name,e)},c=new Map,u=e=>ia(D(c.get(e),`Can't find column '${e}'`)),d=e=>c.set(e.name,e);if(a.sourceColumns=t.columns,yc(a.sourceColumns,(e=>`Can't process source: found duplicate source columns '${e}'`)),a.sourceColumns.forEach((e=>l(e,`Can't process source: another column with name '${e.name}' is already registered`))),a.sourceColumns.forEach((e=>d(e))),r.leafExtend?.length&&(a.leafExtendedColumns=await Ic(r.leafExtend,Array.from(c.values()),o,t),yc(a.leafExtendedColumns,(e=>`Can't process extend() expression: found duplicate extended columns '${e}'`)),a.leafExtendedColumns.forEach((e=>l(e,`Can't process extend() expression: another column with name '${e.name}' is already registered`))),a.leafExtendedColumns.forEach((e=>d(e)))),r.filter){const e=vc(r.filter,0,Gr,"Can't process filter() expression: expected parameter at index 0 to be a lambda expression");a.filter=wc(Nc(e,"Can't process filter() expression"),u,o.filterOperations)}r.select?(a.selectColumns=Tc(r.select,0).colSpecs.map((e=>u(e.name))),yc(a.selectColumns,(e=>`Can't process select() expression: found duplicate select columns '${e}'`)),c.clear(),a.selectColumns.forEach((e=>d(e)))):c.clear();let p=[],m=[];if(r.pivot&&r.pivotCast&&r.pivotSort){const e=Tc(r.pivot,0).colSpecs.map((e=>u(e.name))),t=(g=(h=r.pivotCast,vc(h,0,ds,`Can't process ${ma(h.function)}: expected parameter at index 0 to be a generic type instance`)).genericType,B(g.typeArguments[0]?.rawType,hs,"Can't process generic type: failed to extract relation type")).columns.map((e=>({name:e.name,type:Sc(e.genericType).fullPath})));a.pivot={columns:e,castColumns:t},p=Tc(r.pivot,1).colSpecs.map((e=>Fc(e,u,o.aggregateOperations))),m=function(e,t,n){const o=Pc(e,n),r=new Set(t.map((e=>e.name))),i=new Set(t.map((e=>e.name)));if(o.forEach((e=>{if(!r.has(e.name))throw new Error(`Can't process pivot() expression: sort column '${e.name}' must be a pivot column`);i.delete(e.name)})),0!==i.size)throw new Error(`Can't process pivot() expression: found unsorted pivot column(s) (${Array.from(i.values()).sort().map((e=>`'${e}'`)).join(", ")})`);return yc(o,(e=>`Can't process pivot() expression: found duplicate sort columns '${e}'`)),o}(r.pivotSort,e,u),function(e,t,n){const o=e.columns,r=e.castColumns;yc(o,(e=>`Can't process pivot() expression: found duplicate pivot columns '${e}'`)),yc(t,(e=>`Can't process pivot() expression: found duplicate aggregate columns '${e}'`)),yc(r,(e=>`Can't process pivot() expression: found duplicate cast columns '${e}'`)),t.forEach((e=>{if(ra(o,e.name))throw new Error(`Can't process pivot() expression: pivot column '${e.name}' must not be aggregated on`)})),n.filter((e=>!(ra(o,e.name)??ra(t,e.name)))).forEach((e=>{if(!ra(r,e.name))throw new Error(`Can't process pivot() expression: expected pivot group column '${e.name}' in cast columns`)})),o.forEach((e=>{if(ra(r,e.name))throw new Error(`Can't process pivot() expression: expected pivot column '${e.name}' to not present in cast columns`)})),t.forEach((e=>{if(ra(r,e.name))throw new Error(`Can't process pivot() expression: expected pivot aggregate column '${e.name}' to not present in cast columns`)})),r.filter((e=>na(e.name))).forEach((e=>{const n=oa(e.name);if(!ra(t,n))throw new Error(`Can't process pivot() expression: fail to match cast column '${e.name}' to a specified aggregate column`)}))}(a.pivot,p,Array.from(c.values())),c.clear(),t.forEach((e=>d(e)))}var g,h;let f=[],E=[];if(r.groupBy&&r.groupBySort){const e=Tc(r.groupBy,0).colSpecs.map((e=>u(e.name)));a.groupBy={columns:e},f=Tc(r.groupBy,1).colSpecs.map((e=>Fc(e,u,o.aggregateOperations))),E=function(e,t,n){const o=Pc(e,n),r=new Set(t.map((e=>e.name))),i=new Set(t.map((e=>e.name)));let a;if(o.forEach((e=>{if(!r.has(e.name))throw new Error(`Can't process groupBy() expression: sort column '${e.name}' must be a group column`);if(i.delete(e.name),a){if(e.direction!==a)throw new Error("Can't process groupBy() expression: all group columns must be sorted in the same direction")}else a=e.direction})),0!==i.size)throw new Error(`Can't process groupBy() expression: found unsorted group column(s) (${Array.from(i.values()).sort().map((e=>`'${e}'`)).join(", ")})`);return yc(o,(e=>`Can't process groupBy() expression: found duplicate sort columns '${e}'`)),o}(r.groupBySort,e,u),function(e,t,n,o,r){const i=e.columns;if(yc(i,(e=>`Can't process groupBy() expression: found duplicate group columns '${e}'`)),yc(t,(e=>`Can't process groupBy() expression: found duplicate aggregate columns '${e}'`)),t.forEach((e=>{if(ra(i,e.name))throw new Error(`Can't process groupBy() expression: group column '${e.name}' must not be aggregated on`)})),r.forEach((e=>{if(!(ra(i,e.name)??ra(t,e.name)))throw new Error(`Can't process groupBy() expression: column '${e.name}' is neither grouped nor aggregated on`)})),n){const e=new Map;t.filter((e=>na(e.name))).forEach((t=>{const n=oa(t.name),o={...t,name:n},r=e.get(n);if(r){if(!(0,Oo.A)({...r,type:void 0},{...o,type:void 0}))throw new Error(`Can't process groupBy() expression: found conflicting aggregation specification for column '${n}'`)}else e.set(n,o)})),o.forEach((t=>{const n=e.get(t.name);if(!n)throw new Error(`Can't process groupBy() expression: column '${t.name}' is aggregated in pivot() expression but not in groupBy() expression`);if(!(0,Oo.A)({...n,type:void 0},{...t,type:void 0}))throw new Error(`Can't process groupBy() expression: found conflicting aggregation specification for column '${t.name}'`)}))}}(a.groupBy,f,a.pivot,p,Array.from(c.values()))}if(r.groupExtend?.length&&(a.groupExtendedColumns=await Ic(r.groupExtend,Array.from(c.values()),o,t),yc(a.groupExtendedColumns,(e=>`Can't process extend() expression: found duplicate extended columns '${e}'`)),a.groupExtendedColumns.forEach((e=>l(e,`Can't process extend() expression: another column with name '${e.name}' is already registered`))),a.groupExtendedColumns.forEach((e=>d(e)))),r.sort&&(a.sortColumns=Pc(r.sort,u),yc(a.sortColumns,(e=>`Can't process sort() expression: found duplicate sort columns '${e}'`))),r.limit){const e=vc(r.limit,0,ba,"Can't process limit() expression: expected limit to be a non-negative integer value");a.limit=e.value}const C=function(e,t,n){const o=e.snapshot.data,r=t.configuration,i=Bd(e);if(!r)return i;o.groupBy&&M(r.treeColumnSortDirection===i.treeColumnSortDirection,`Can't process configuration: tree column sort direction mismatch (expected: '${i.treeColumnSortDirection.toLowerCase()}', found: '${r.treeColumnSortDirection.toLowerCase()}')`);const a=r.columns,s=i.columns,l=new Set;a.forEach((e=>{if(l.has(e.name))throw new Error(`Can't process configuration: found duplicate columns '${e.name}'`);l.add(e.name)})),a.forEach((e=>{if(!ra(s,e.name))throw new Error(`Can't process configuration: found extra column '${e.name}'`)})),s.forEach((e=>{if(!ra(a,e.name))throw new Error(`Can't process configuration: missing column '${e.name}'`)}));const c=[...o.selectColumns,...o.groupExtendedColumns,...[...o.sourceColumns,...o.leafExtendedColumns].filter((e=>!ra(o.selectColumns,e.name)))];return c.forEach(((e,t)=>{const n=N(a,t);M(e.name===n.name,`Can't process configuration: column ordering mismatch at index ${t} (expected: '${e.name}', found: '${n.name})', expected ordering: ${c.map((e=>e.name)).join(", ")}`)})),a.forEach((e=>{const t=D(ra(s,e.name));if(M(e.type===t.type,`Can't process configuration: type mismatch for column '${e.name}' (expected: '${t.type}', found: '${e.type}')`),M(e.isSelected===t.isSelected,`Can't process configuration: selection mismatch for column '${e.name}' (expected: '${t.isSelected}', found: '${e.isSelected}')`),(ra(o.pivot?.columns??[],e.name)??ra(o.groupBy?.columns??[],e.name))&&M(e.kind===t.kind,`Can't process configuration: kind mismatch for column '${e.name}' (expected: '${t.kind.toLowerCase()}', found: '${e.kind.toLowerCase()}')`),(o.pivot??o.groupBy)&&(M(e.aggregateOperator===t.aggregateOperator,`Can't process configuration: aggregation operator mismatch for column '${e.name}' (expected: '${t.aggregateOperator}', found: '${e.aggregateOperator}')`),M(n.getAggregateOperation(e.aggregateOperator).isCompatibleWithParameterValues(e.aggregationParameters),`Can't process configuration: incompatible aggregation parameter values for column '${e.name}' (operator: '${e.aggregateOperator}')`)),o.pivot&&(M(e.excludedFromPivot===t.excludedFromPivot,`Can't process configuration: pivot exclusion mismatch for column '${e.name}' (expected: '${t.excludedFromPivot}', found: '${e.excludedFromPivot}')`),M(e.pivotSortDirection===t.pivotSortDirection,`Can't process configuration: pivot sort direction mismatch for column '${e.name}' (expected: '${t.pivotSortDirection?.toLowerCase()??"none"}', found: '${e.pivotSortDirection?.toLowerCase()??"none"}')`)),e.kind===mi.DIMENSION&&!e.excludedFromPivot)throw new Error(`Can't process configuration: column '${e.name}' is a dimension but not excluded from pivot`)})),r}({snapshot:i,groupByAggColumns:f,groupBySortColumns:E,pivotAggColumns:p,pivotSortColumns:m},n,o);return a.configuration=C.serialize(),a.dimensionalTree=n.dimensionalTree,i.finalize()}var gg=n(60720),hg=n(78058),fg=n(36868);const Eg=(0,Ft.forwardRef)((function(e,t){return(0,E.jsx)(gg.x,{ref:t,...e})})),Cg=(0,Ft.forwardRef)((function(e,t){return(0,E.jsx)(hg.l,{ref:t,...e})})),bg=(0,Ft.forwardRef)((function(e,t){const{inputRef:n,className:o,disabled:r,InputProps:{ref:i,endAdornment:a}={},ownerState:s,enableAccessibleFieldDOMStructure:l,clearable:c,onClear:u,error:d,focused:p,...m}=e,g=(0,cu.A)(i,t);return(0,E.jsxs)("div",{style:{display:"flex",alignItems:"center",position:"relative"},ref:g,children:[(0,E.jsx)("input",{className:o,disabled:r,ref:n,...m}),a]})})),vg=(0,Ft.forwardRef)((function(e,t){const{slots:n,slotProps:o,onClear:r,...i}=e,a=(0,fg.c)({...i});return(0,E.jsx)(bg,{...a,ref:t})}));var _g=n(15179),Tg=n(15891);const Ng=(0,vt.PA)((0,Ft.forwardRef)((function(e,t){const{value:n,updateValue:o}=e,r=(0,Ft.useRef)(null),i=(0,cu.A)(r,t);return(0,E.jsx)("input",{ref:i,className:"h-5 w-full flex-shrink-0 border border-neutral-400 px-1 text-sm disabled:border-neutral-300 disabled:bg-neutral-50 disabled:text-neutral-300",value:n,onKeyDown:e=>{"Escape"===e.code&&r.current?.select()},onChange:e=>{o(e.target.value)}})}))),Sg="#ERR",Ag=(0,vt.PA)((0,Ft.forwardRef)((function(e,t){const{value:n,updateValue:o,defaultValue:r=0,step:i=1}=e,[a,s]=(0,Ft.useState)(n.toString()),l=(0,Ft.useRef)(null),c=(0,cu.A)(l,t),u=()=>{const e=Number(a);if(""===a)s(r.toString()),o(r);else if(isNaN(e)){if(a===Sg)return void s(n.toString());try{const e=z((0,Tg._3)(a));s(e.toString()),o(e)}catch{s(Sg),o(r)}}};return(0,Ft.useEffect)((()=>{s(n.toString())}),[n]),(0,E.jsxs)("div",{className:"relative h-5 w-full flex-shrink-0",children:[(0,E.jsx)("input",{ref:c,inputMode:"numeric",spellCheck:!1,type:"text",className:"h-full w-full border border-neutral-400 px-1 pr-5 text-sm disabled:border-neutral-300 disabled:bg-neutral-50 disabled:text-neutral-300",value:a,onKeyDown:e=>{if("Enter"===e.code)u(),l.current?.focus();else if("Escape"===e.code)l.current?.select();else if("ArrowUp"===e.code){e.preventDefault();const t=n+i;s(t.toString()),o(t)}else if("ArrowDown"===e.code){e.preventDefault();const t=n-i;s(t.toString()),o(t)}},onChange:e=>{const t=e.target.value;s(t);const n=Number(t);!isNaN(n)&&t&&o(n)},onBlur:()=>u()}),(0,E.jsx)("div",{className:"absolute right-0 top-0 flex h-5 w-5 items-center justify-center",children:(0,E.jsx)("button",{className:"text-lg text-neutral-500 hover:text-neutral-600",title:"Evaluate Expression (Enter)",onClick:u,tabIndex:-1,children:(0,E.jsx)(pr.Calculate,{})})})]})}))),yg=(0,Ft.forwardRef)((function(e,t){return(0,E.jsx)(vg,{...e,ref:t,className:"h-5 w-full flex-shrink-0 border border-neutral-400 px-1 pr-5 text-sm disabled:border-neutral-300 disabled:bg-neutral-50 disabled:text-neutral-300"})})),xg=(0,vt.PA)((e=>{const{value:t,updateValue:n}=e,[o,r]=(0,Ft.useState)(null);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("button",{className:"absolute right-0 top-0 flex h-5 w-5 items-center justify-center",title:"Open Date Picker...",onClick:e=>{r(e.currentTarget)},tabIndex:-1,children:(0,E.jsx)(pr.Calendar,{className:"text-lg text-neutral-500 hover:text-neutral-600"})}),(0,E.jsx)(Yn,{open:Boolean(o),anchorEl:o,anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},onClose:()=>r(null),classes:{root:"data-cube-editor-date-calendar mt-0.5",paper:"shadow-md rounded-none border border-neutral-300"},children:(0,E.jsx)(Eg,{autoFocus:!0,value:(0,_g.H)(t),onChange:e=>{n((0,Kn.GP)(e,Zr)),r(null)}})})]})})),Ig=(0,vt.PA)((0,Ft.forwardRef)((function(e,t){const{value:n,updateValue:o}=e;return(0,E.jsx)(Cg,{ref:t,value:(0,_g.H)(n),format:Zr,slots:{field:yg,openPickerButton:()=>(0,E.jsx)(xg,{value:n,updateValue:o})},onChange:e=>{e&&o((0,Kn.GP)(e,Zr))}})}))),wg=(0,vt.PA)((0,Ft.forwardRef)((function(e,t){const{value:n,updateValue:o,view:r}=e,i=r.filter,a=ra(i.columns,n),[s,l,c,u]=pu();return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(yu,{ref:t,className:"relative mr-1 w-32",onClick:s,open:u,children:n}),(0,E.jsx)(xu,{className:"w-32",...c,children:i.columns.filter((e=>a&&Qi(a.type)===Qi(e.type))).map((e=>(0,E.jsx)(Iu,{onClick:()=>{o(e.name),l()},autoFocus:n===e.name,children:e.name},e.name)))})]})}))),kg=(0,vt.PA)((0,Ft.forwardRef)((function(e,t){const{value:n,updateValue:o,view:r}=e;switch(n.type){case Wr.STRING:return(0,E.jsx)(Ng,{ref:t,value:n.value,updateValue:e=>o(e)});case Wr.NUMBER:case Wr.DECIMAL:case Wr.FLOAT:case Wr.INTEGER:return(0,E.jsx)(Ag,{ref:t,value:n.value,updateValue:e=>o(e)});case Wr.DATE:case Wr.STRICTDATE:case Wr.DATETIME:return(0,E.jsx)(Ig,{ref:t,value:n.value,updateValue:e=>o(e)});case gi.COLUMN:return(0,E.jsx)(wg,{ref:t,value:n.value,updateValue:e=>o(e),view:r});default:return null}})));function Rg(){return(0,E.jsxs)("div",{className:"relative flex pl-2.5",children:[(0,E.jsx)("div",{className:"pointer-events-none absolute -left-2 h-0 w-0 border-[9px] border-neutral-600 border-b-transparent border-l-transparent border-t-transparent"}),(0,E.jsx)("div",{className:"mr-1 flex h-[18px] w-10 flex-shrink-0 items-center bg-neutral-600 pl-2 text-sm font-medium text-white",title:"Filter is inverted: select all but what matches.",children:"NOT"})]})}const Og=(0,vt.PA)((e=>{const{className:t,node:n,view:o}=e,r=o.filter;return(0,E.jsxs)("div",{className:Mn("flex h-3.5 w-14 flex-shrink-0 bg-neutral-100",t),children:[(0,E.jsx)("button",{className:"flex h-3.5 w-3.5 items-center justify-center rounded-bl-sm rounded-tl-sm border border-neutral-400 hover:bg-neutral-200",onClick:()=>r.addFilterNode(n),title:"Insert a new column filter, just after this filter.",children:(0,E.jsx)(pr.FilterAddOperator,{className:"stroke-[2.5] text-sm"})}),(0,E.jsx)("button",{className:"flex h-3.5 w-3.5 items-center justify-center border border-l-0 border-neutral-400 hover:bg-neutral-200",onClick:()=>r.removeFilterNode(n),title:"Remove this filter",children:(0,E.jsx)(pr.FilterRemoveOperator,{className:"stroke-[2.5] text-sm"})}),(0,E.jsx)("button",{className:"flex h-3.5 w-3.5 items-center justify-center border border-l-0 border-neutral-400 hover:bg-neutral-200",onClick:()=>r.layerFilterNode(n),title:"Put this filter in its own sub-group (and combine it with other filters).",children:(0,E.jsx)(pr.FilterGroupOperator,{className:"stroke-[2.5] text-sm"})}),(0,E.jsx)("button",{className:Mn("flex h-3.5 w-3.5 items-center justify-center rounded-br-sm rounded-tr-sm border border-l-0 border-neutral-400 hover:bg-neutral-200",{"bg-neutral-600":n.not,"border-neutral-600":n.not,"text-white":n.not,"hover:bg-neutral-600":n.not}),onClick:()=>n.setNot(!n.not),title:n.not?"Turn off the NOT operator on this filter to select only what matches.":"Turn on the NOT operator on this filter to select all but what matches.",children:(0,E.jsx)(pr.FilterNotOperator,{className:"stroke-[3] text-xs"})})]})})),Lg=(0,vt.PA)((e=>{const{node:t,level:n,view:o}=e,r=bu(),i=o.filter,a=t.parent,s=a?a.children.indexOf(t):void 0,l=(0,Ft.useRef)(null),[c,u,d,p]=pu(),[m,g,h,f]=pu(),C=(0,Ft.useCallback)((()=>l.current?.focus()),[]);return(0,E.jsxs)("div",{className:"group flex h-6 items-center",children:[(0,E.jsx)("div",{className:Mn("z-1 absolute h-6 w-full bg-opacity-50 group-hover:bg-sky-100 group-hover:bg-opacity-50",{"bg-sky-50":t===i.selectedNode,"border-[0.5px] border-l-2 border-sky-200 border-l-sky-600":t===i.selectedNode}),onClick:()=>i.setSelectedNode(t)}),(0,E.jsx)("div",{style:{paddingLeft:36*n+10+60*(n-1)+"px"},className:"relative h-6 flex-shrink-0",onClick:()=>i.setSelectedNode(t),children:a&&(0,E.jsxs)("div",{className:"absolute top-0 flex h-6 items-center justify-end",style:{width:"22px",right:"8px"},children:[(0,E.jsx)("div",{className:Mn("h-[1px] w-full flex-1 bg-neutral-200",{"bg-sky-600":a===i.selectedGroupNode})}),void 0!==s&&s>0&&(0,E.jsx)("div",{className:Mn("flex h-6 items-center justify-center pl-1 text-xs text-neutral-600",{"text-sky-600":a===i.selectedGroupNode}),children:a.operation===Ci.AND?"and":"or"})]})}),(0,E.jsx)(Og,{className:"relative mr-1",node:t,view:o}),t.not&&(0,E.jsx)(Rg,{}),(0,E.jsx)(yu,{className:"relative mr-1 w-32",onClick:c,open:p,children:t.column.name}),(0,E.jsx)(xu,{className:"w-32",...d,onClosed:C,children:i.columns.map((e=>(0,E.jsx)(Iu,{onClick:()=>{if(e!==t.column){const n=t.operation.isCompatibleWithColumn(e)?t.operation:r.engine.filterOperations.filter((t=>t.isCompatibleWithColumn(e)))[0];n&&(t.setColumn(e),t.setOperation(n),t.setValue(n.generateDefaultValue(e)))}u()},autoFocus:t.column.name===e.name,children:e.name},e.name)))}),(0,E.jsx)(yu,{className:"relative mr-1 w-24",onClick:m,open:f,children:t.operation.label}),(0,E.jsx)(xu,{className:"w-24",...h,onClosed:C,children:r.engine.filterOperations.filter((e=>e.isCompatibleWithColumn(t.column))).map((e=>(0,E.jsx)(Iu,{onClick:()=>{e!==t.operation&&e.isCompatibleWithColumn(t.column)&&(t.setOperation(e),t.setValue(e.generateDefaultValue(t.column))),g()},autoFocus:t.operation.operator===e.operator,children:e.label},e.operator)))}),(0,E.jsx)("div",{className:"relative w-32 flex-shrink-0",children:(0,E.jsx)(kg,{ref:l,value:t.value,updateValue:e=>t.updateValue(e),view:o})})]})})),Fg=(0,vt.PA)((e=>{const{node:t,level:n,view:o}=e,r=o.filter,i=t.parent,a=i?i.children.indexOf(t):void 0,[s,l,c,u]=pu();return(0,E.jsxs)("div",{className:"group flex h-6 items-center",children:[(0,E.jsx)("div",{className:Mn("z-1 absolute h-6 w-full bg-opacity-50 group-hover:bg-sky-100 group-hover:bg-opacity-50",{"bg-sky-50":t===r.selectedNode,"border-[0.5px] border-l-2 border-sky-200 border-l-sky-600":t===r.selectedNode}),onClick:()=>r.setSelectedNode(t)}),(0,E.jsx)("div",{style:{paddingLeft:36*n+10+(0!==n?60*(n-1):0)+"px"},className:"relative h-6 flex-shrink-0",onClick:()=>r.setSelectedNode(t),children:0!==n&&i&&(0,E.jsxs)("div",{className:"absolute top-0 flex h-6 items-center justify-end",style:{width:"22px",right:"8px"},children:[(0,E.jsx)("div",{className:Mn("h-[1px] w-full flex-1 bg-neutral-200",{"bg-sky-600":i===r.selectedGroupNode})}),void 0!==a&&a>0&&(0,E.jsx)("div",{className:Mn("flex h-6 items-center justify-center pl-1 text-xs text-neutral-600",{"text-sky-600":i===r.selectedGroupNode}),children:i.operation===Ci.AND?"and":"or"})]})}),0!==n&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(Og,{className:"relative mr-1",node:t,view:o}),t.not&&(0,E.jsx)(Rg,{})]}),(0,E.jsx)(yu,{className:"relative w-14",onClick:s,open:u,children:t.operation===Ci.AND?"All of":"Any of"}),(0,E.jsxs)(xu,{className:"w-14",...c,children:[(0,E.jsx)(Iu,{onClick:()=>{t.setOperation(Ci.AND),l()},autoFocus:t.operation===Ci.AND,children:"All of"}),(0,E.jsx)(Iu,{onClick:()=>{t.setOperation(Ci.OR),l()},autoFocus:t.operation===Ci.OR,children:"Any of"})]})]})})),Dg=(0,vt.PA)((e=>{const{node:t,level:n,view:o}=e,r=o.filter;return(0,E.jsxs)("div",{className:"relative w-full",children:[(0,E.jsx)("div",{className:Mn("pointer-events-none absolute h-full",{"border-[0.5px] border-sky-200 bg-sky-50":t===r.selectedGroupNode}),style:{marginLeft:36*n+10+60*n-2+"px",width:`calc(100% - ${36*n+10+60*n-4}px)`}}),(0,E.jsx)(Fg,{node:t,level:n,view:o}),(0,E.jsxs)("div",{className:"relative",children:[(0,E.jsx)("div",{className:Mn("pointer-events-none absolute z-10 h-[calc(100%_-_12px)] w-0 border-l border-neutral-200",{"border-sky-600":t===r.selectedGroupNode}),style:{marginLeft:36*n+10+6+60*n+"px"}}),t.children.map((e=>e instanceof sm?(0,E.jsx)(Lg,{level:n+1,node:e,view:o},e.uuid):e instanceof lm?(0,E.jsx)(Dg,{level:n+1,node:e,view:o},e.uuid):null))]})]})})),Pg=(0,vt.PA)((e=>{const{view:t}=e,n=t.filter,o=()=>{t.dataCube.telemetryService.sendTelemetry(Ud.APPLY_CHANGES_FILTER,t.engine.getDataFromSource(t.getInitialSource()))};return(0,Ft.useEffect)((()=>{n.setSelectedNode(void 0)}),[n]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"relative h-[calc(100%_-_40px)] w-full px-2 pt-2",children:(0,E.jsx)("div",{className:"h-full w-full overflow-auto border border-neutral-300 bg-white",children:(0,E.jsx)("div",{className:"h-full w-full select-none p-2",children:(0,E.jsx)("div",{className:"flex h-full w-full",children:(0,E.jsxs)("div",{className:"relative flex h-full w-full overflow-auto rounded-sm border border-neutral-200",onClick:()=>n.setSelectedNode(void 0),children:[!n.tree.root&&(0,E.jsxs)("div",{className:"h-full w-full p-3",children:[(0,E.jsx)("div",{children:"No filter is specified. Click the button below to start."}),(0,E.jsx)(Tu,{onClick:()=>{n.initializeTree()},children:"Create New Filter"})]}),n.tree.root&&(0,E.jsxs)("div",{className:"flex flex-col py-1",onClick:e=>e.stopPropagation(),children:[(0,E.jsx)(Dg,{node:n.tree.root,level:0,view:t}),(0,E.jsx)("div",{className:"min-h-6 w-full flex-1",onClick:()=>n.setSelectedNode(void 0)})]})]})})})})}),(0,E.jsxs)("div",{className:"flex h-10 items-center justify-end px-2",children:[(0,E.jsx)(Tu,{onClick:()=>n.display.close(),children:"Cancel"}),(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>{n.applyChanges(),o()},children:"Apply"}),(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>{n.applyChanges(),n.display.close(),o()},children:"OK"})]})]})}));class Bg extends om{_view;display;tree;selectedNode;columns=[];constructor(e){super(e.engine,e.settingService,e.snapshotService),(0,Ie.Gn)(this,{tree:Ie.sH.ref,initializeTree:Ie.XI,refreshTree:Ie.XI,columns:Ie.sH.struct,applySnapshot:Ie.XI,selectedNode:Ie.sH,selectedGroupNode:Ie.EW,setSelectedNode:Ie.XI,addFilterNode:Ie.XI,removeFilterNode:Ie.XI,layerFilterNode:Ie.XI}),this._view=e,this.display=this._view.dataCube.layoutService.newDisplay("Filter",(()=>(0,E.jsx)(Pg,{view:this._view})),{x:-50,y:50,width:600,height:400,minWidth:300,minHeight:200,center:!1}),this.tree={nodes:new Map}}initializeTree(){if(void 0===this.tree.root&&0===this.tree.nodes.size){const e=new lm(void 0,Ci.AND,void 0);this.tree.nodes.set(e.uuid,e),this.tree.root=e;const t=this.generateNewFilterNode(e);t&&(e.addChild(t),this.tree.nodes.set(t.uuid,t)),this.refreshTree()}}refreshTree(){this.tree={...this.tree}}get selectedGroupNode(){return this.selectedNode instanceof lm?this.selectedNode:this.selectedNode?.parent}setSelectedNode(e){this.selectedNode=e}generateNewFilterNode(e){if(e instanceof sm)return new sm(void 0,e.column,e.operation,(0,im.A)(e.value),e.not);if(e instanceof lm&&0!==this.columns.length){const e=N(this.columns,0),t={name:e.name,type:e.type},n=this._engine.getFilterOperation(Ei.EQUAL);return new sm(void 0,t,n,n.generateDefaultValue(t),void 0)}}addFilterNode(e){if(this.tree.root){const t=this.generateNewFilterNode(e),n=e.parent;n&&t&&(n.addChild(t,e instanceof sm?n.children.indexOf(e)+1:void 0),this.tree.nodes.set(t.uuid,t),this.refreshTree())}}removeFilterNode(e){if(this.tree.root){const t=e.parent;if(e!==this.tree.root&&t){let n=[e];for(;n.length;)n.forEach((e=>{e instanceof lm&&e.children.forEach((e=>{e.setParent(void 0)})),this.tree.nodes.delete(e.uuid)})),n=Array.from(this.tree.nodes.values()).filter((e=>e!==this.tree.root&&!e.parent));if(t.removeChild(e),this.tree.nodes.delete(e.uuid),1===t.children.length){if(t!==this.tree.root){const e=N(t.children,0),n=D(t.parent);t.removeChild(e);const o=n.children.indexOf(t);n.removeChild(t),this.tree.nodes.delete(t.uuid),n.addChild(e,o)}}else 0===t.children.length&&t===this.tree.root&&(this.tree.root=void 0,this.tree.nodes.delete(t.uuid));this.refreshTree(),this.selectedNode===e&&this.setSelectedNode(void 0)}}}layerFilterNode(e){if(this.tree.root){const t=this.generateNewFilterNode(e),n=e.parent;if(n&&t){const o=n.children.indexOf(e);n.removeChild(e);const r=new lm(void 0,Ci.OR,void 0);r.addChild(e),r.addChild(t),n.addChild(r,o),this.tree.nodes.set(r.uuid,r),this.tree.nodes.set(t.uuid,t),this.refreshTree(),this.selectedNode===e&&this.setSelectedNode(r)}}}getSnapshotSubscriberName(){return"filter-editor"}async applySnapshot(e,t){const n=da.serialization.fromJson(e.data.configuration);this.columns=n.columns.filter((t=>!ra(e.data.groupExtendedColumns,t.name))),this.tree.nodes=new Map,this.tree.root=e.data.filter?um(e.data.filter,void 0,this.tree.nodes,(e=>this._engine.getFilterOperation(e))):void 0,this.setSelectedNode(void 0),this.refreshTree()}applyChanges(){const e=D(this.getLatestSnapshot()),t=e.clone();t.data.filter=this.tree.root?cm(this.tree.root):void 0,t.finalize(),t.hashCode!==e.hashCode&&this.publishSnapshot(t)}}const jg=(0,vt.PA)((e=>{const{state:t}=e,n=(0,Ft.useRef)(null),[o,r]=(0,Ft.useState)(),i=(0,Ft.useRef)(void 0),a=(0,Ft.useMemo)((()=>(0,Bn.A)((()=>{t.getReturnType().catch((e=>{t.alertHandler(e)}))}),500)),[t]);return(0,Ft.useEffect)((()=>{if(!o&&n.current){const e=n.current,o=document.getElementById(Sr),s=Nr.editor.create(e,{contextmenu:!1,copyWithSyntaxHighlighting:!1,fontSize:14,fontFamily:"Roboto Mono",fontLigatures:!0,fixedOverflowWidgets:!0,detectIndentation:!1,tabSize:2,"bracketPairColorization.enabled":!1,automaticLayout:!0,fontSize:12,language:lu.PURE,theme:Xc.GITHUB_LIGHT,wordSeparators:Pu,fixedOverflowWidgets:!0,...L(o)?{overflowWidgetsDomNode:o}:{}});i.current?.dispose(),i.current=Nr.languages.registerCompletionItemProvider(lu.PURE,{triggerCharacters:[...Pu,"$"],provideCompletionItems:async(e,n,o)=>{let r=[];return e.uri===t.editorModelUri&&(r=r.concat(await async function(e,t,n,o,r,i){const a=t.getValueInRange({startLineNumber:1,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column}),s=t.getWordAtPosition(e);let l=[];try{l=await o.getQueryTypeahead((n??"")+a,i(),r)}catch{}return l.map((t=>({label:t.display,kind:Nr.languages.CompletionItemKind.Text,filterText:t.display,insertTextRules:Nr.languages.CompletionItemInsertTextRule.InsertAsSnippet,insertText:t.completion,range:{startLineNumber:e.lineNumber,startColumn:s?.startColumn??e.column,endLineNumber:e.lineNumber,endColumn:s?.endColumn??e.column}})))}(n,e,t.codePrefix,t.engine,D(t.model),t.queryLambda))),{suggestions:r}}}),s.setModel(t.editorModel),s.onDidChangeModelContent((()=>{t.currentlyEditing=!0;const e=s.getValue();e!==t.code&&((0,Ie.h5)((()=>{t.code=e})),t.clearError(),t.setReturnType(void 0),a.cancel(),a())})),s.focus(),s.setPosition({lineNumber:1,column:t.code.length+1}),t.setEditor(s),r(s)}}),[t,o,a]),(0,Ft.useEffect)((()=>()=>{o&&(o.dispose(),i.current?.dispose())}),[o]),(0,Ft.useEffect)((()=>{t.editor?.updateOptions({readOnly:t.finalizationState.isInProgress})}),[t,t.finalizationState.isInProgress]),(0,E.jsxs)("div",{className:Mn("relative h-full w-full border border-neutral-200",{"border-red-500":t.hasErrors}),children:[(0,E.jsx)("div",{className:"absolute left-0 top-0 h-full w-full overflow-hidden"}),(0,E.jsx)("div",{ref:n,style:{height:"100%",width:"100%"}})]})}));var Mg;!function(e){e.LEAF_LEVEL_MEASURE="Leaf Level Measure",e.LEAF_LEVEL_DIMENSION="Leaf Level Dimension",e.GROUP_LEVEL="Group Level"}(Mg||(Mg={}));const Ug=(0,vt.PA)((e=>{const{state:t}=e,n=bu(),o=t.view,r=o.extend,i=(0,Ft.useRef)(null),a=t.isGroupLevel?Mg.GROUP_LEVEL:t.columnKind===mi.MEASURE?Mg.LEAF_LEVEL_MEASURE:Mg.LEAF_LEVEL_DIMENSION,[s,l,c,u]=pu(),[d,p,m,g]=pu(),h=(0,Ft.useMemo)((()=>(0,Bn.A)((()=>{t.getReturnType().catch((e=>n.alertService.alertUnhandledError(e)))}),500)),[t,n]);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"h-[calc(100%_-_40px)] w-full px-2 pt-2",children:(0,E.jsx)("div",{className:"h-full w-full overflow-auto border border-neutral-300 bg-white",children:(0,E.jsxs)("div",{className:"h-full w-full select-none p-0",children:[(0,E.jsxs)("div",{className:"h-24 w-full p-2",children:[(0,E.jsxs)("div",{className:"mt-1 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-24 flex-shrink-0 items-center text-sm",children:"Column Name:"}),(0,E.jsx)(Su,{className:"w-32",ref:i,disabled:t.finalizationState.isInProgress,value:t.name,onChange:e=>{t.setName(e.target.value)}}),(0,E.jsx)("div",{className:"ml-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center text-lg",children:t.isNameValid?(0,E.jsx)(pr.CircleChecked,{className:"text-green-500"}):(0,E.jsx)(pr.CircledFailed,{className:"text-red-500"})})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsxs)("div",{className:"flex h-full w-24 flex-shrink-0 items-center text-sm",children:["Column Kind:",(0,E.jsx)(Ou,{className:"ml-1",documentationKey:Rm.EXTENDED_COLUMN_LEVELS})]}),(0,E.jsx)(yu,{className:"w-32",onClick:s,open:u,disabled:t.finalizationState.isInProgress,children:a}),(0,E.jsx)(xu,{className:"w-32",...c,children:[Mg.LEAF_LEVEL_MEASURE,Mg.LEAF_LEVEL_DIMENSION,Mg.GROUP_LEVEL].map((e=>(0,E.jsx)(Iu,{onClick:()=>{switch(e){case Mg.LEAF_LEVEL_MEASURE:t.setColumnKind(!1,mi.MEASURE);break;case Mg.LEAF_LEVEL_DIMENSION:t.setColumnKind(!1,mi.DIMENSION);break;case Mg.GROUP_LEVEL:t.setColumnKind(!0,void 0);break;default:return}t.clearError(),t.setReturnType(void 0),h.cancel(),h(),l()},autoFocus:e===a,children:e},e)))})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-24 flex-shrink-0 items-center text-sm",children:"Value Type:"}),(0,E.jsx)(yu,{className:"w-32",onClick:d,open:g,disabled:t.finalizationState.isInProgress,children:t.expectedType}),(0,E.jsx)("div",{className:"ml-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center text-lg",children:t.validationState.isInProgress?(0,E.jsx)(pr.Loader,{className:"animate-spin stroke-2 text-neutral-400"}):t.returnType?t.isTypeValid?(0,E.jsx)(pr.CircleChecked,{className:"text-green-500"}):(0,E.jsx)(pr.CircledFailed,{className:"text-red-500"}):null}),(0,E.jsx)(xu,{className:"w-32",...m,children:[_i.TEXT,_i.NUMBER,_i.DATE].map((e=>(0,E.jsx)(Iu,{onClick:()=>{t.setExpectedType(e),p()},autoFocus:e===t.expectedType,children:e},e)))})]})]}),(0,E.jsx)("div",{className:"h-[calc(100%_-_96px)] w-full p-2 pt-1",children:(0,E.jsx)(jg,{state:t})})]})})}),(0,E.jsxs)("div",{className:"flex h-10 items-center justify-end px-2",children:[(0,E.jsx)(Tu,{onClick:()=>t.close(),children:"Cancel"}),t instanceof Wg&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>{r.deleteColumn(t.initialData.name).catch((e=>n.alertService.alertUnhandledError(e)))},children:"Delete"}),(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>{t.reset().catch((e=>n.alertService.alertUnhandledError(e)))},children:"Reset"})]}),(0,E.jsx)(Tu,{className:"ml-2",disabled:!t.isNameValid||!t.isTypeValid||t.validationState.isInProgress||t.finalizationState.isInProgress,onClick:()=>{t.applyChanges().catch((e=>n.alertService.alertUnhandledError(e))),o.dataCube.telemetryService.sendTelemetry(Ud.ADD_NEW_COLUMN,o.engine.getDataFromSource(o.getInitialSource()))},children:"OK"})]})]})}));class Gg{uuid=(0,i.A)();editorModel;editor;editorModelUri;code="";codePrefix;returnType;finalizationState=we.create();codeError;model;engine;currentlyEditing;constructor(e){this.engine=e,this.codePrefix="",this.editorModelUri=Nr.Uri.file(`/${this.uuid}.pure`),this.editorModel=Nr.editor.createModel("",lu.PURE,this.editorModelUri)}get hasErrors(){return Boolean(this.codeError)}clearError(){this.codeError=void 0,su(this.uuid)}setReturnType(e){this.returnType=e}setEditor(e){this.editor=e}}class Hg extends Gg{uuid=(0,i.A)();_manager;view;_name=`col_${this.uuid.replaceAll("-","_")}`;display;validationState=we.create();name;expectedType;isGroupLevel;columnKind;codeSuffix;model;queryLambda;constructor(e,t,n,o,r){super(e.view.engine),(0,Ie.Gn)(this,{name:Ie.sH,setName:Ie.XI,isNameValid:Ie.EW,expectedType:Ie.sH,setExpectedType:Ie.XI,isTypeValid:Ie.EW,isGroupLevel:Ie.sH,columnKind:Ie.sH,setColumnKind:Ie.XI,editor:Ie.sH.ref,setEditor:Ie.XI,codeError:Ie.sH.ref,showError:Ie.XI,clearError:Ie.XI,returnType:Ie.sH,setReturnType:Ie.XI}),this._manager=e,this.view=e.view,this.model=e.view.source,this.engine=this.view.engine,this.display=this.newDisplay(this),this.name=t,this.expectedType=n,this.isGroupLevel=o,this.columnKind=r,this.codePrefix=`->extend(~${this._name}:`,this.codeSuffix=")",this.editorModelUri=Nr.Uri.file(`/${this.uuid}.pure`),this.editorModel=Nr.editor.createModel("",lu.PURE,this.editorModelUri),this.queryLambda=this.buildExtendBaseQuery}alertHandler=e=>{this.view.dataCube.alertService.alertUnhandledError(e)};async initialize(){this.code=await this.getInitialCode(),this.editorModel.setValue(this.code)}setName(e){this.name=e}get isNameValid(){return!this._manager.allColumnNames.includes(this.name)}setExpectedType(e){this.expectedType=e}get isTypeValid(){return void 0!==this.returnType&&this.expectedType===Qi(this.returnType)}setColumnKind(e,t){this.isGroupLevel=e,this.columnKind=t}showError(e){this.codeError=e,e.sourceInformation&&au(this.editorModel,[{message:e.message,startLineNumber:e.sourceInformation.startLine,startColumn:e.sourceInformation.startColumn,endLineNumber:e.sourceInformation.endLine,endColumn:e.sourceInformation.endColumn}],this.uuid)}buildExtendBaseQuery=()=>{const e=D(this._manager.getLatestSnapshot()).clone();return this.isGroupLevel||(e.data.leafExtendedColumns=[],e.data.selectColumns=[],e.data.filter=void 0,e.data.groupBy=void 0,e.data.pivot=void 0),e.data.groupExtendedColumns=[],e.data.sortColumns=[],e.data.limit=void 0,kl([],[mc(e,this.view.source,this.view.engine,{skipExecutionContext:!0})])};async getReturnType(){this.validationState.inProgress(),this.clearError(),this.setReturnType(void 0);try{const e=await this.view.engine.getQueryCodeRelationReturnType(this.codePrefix+this.code+this.codeSuffix,this.buildExtendBaseQuery(),this.view.source);let t=ra(e.columns,this._name)?.type;return t=t&&ta(t)?t:void 0,this.setReturnType(t),t}catch(e){if(w(e),e instanceof qm){if(this.validationState.fail(),e.sourceInformation){e.sourceInformation.startColumn-=1===e.sourceInformation.startLine?this.codePrefix.length:0,e.sourceInformation.endColumn-=1===e.sourceInformation.endLine?this.codePrefix.length:0;const t=this.editorModel.getFullModelRange();(e.sourceInformation.startLine<1||1===e.sourceInformation.startLine&&e.sourceInformation.startColumn<1||e.sourceInformation.endLine>t.endLineNumber||e.sourceInformation.endLine===t.endLineNumber&&e.sourceInformation.endColumn>t.endColumn)&&(e.sourceInformation.startColumn=t.startColumn,e.sourceInformation.startLine=t.startLineNumber,e.sourceInformation.endColumn=t.endColumn,e.sourceInformation.endLine=t.endLineNumber)}return void this.showError(e)}this.view.dataCube.alertService.alertError(e,{message:`Expression Validation Failure: ${e.message}`})}finally{this.validationState.complete()}}close(){this.editorModel.dispose(),this.editor?.dispose(),this.display.close()}}class Vg extends Hg{initialCode;constructor(e,t){super(e,`col_${e.allColumnNames.length+1}`,t?Qi(t.type):_i.NUMBER,!1,t?t.kind:mi.MEASURE),this.initialCode=t?`${Ii}|$${Ii}.${t.name}`:`${Ii}|`}async getInitialCode(){return this.initialCode}newDisplay(e){return this.view.dataCube.layoutService.newDisplay("Add New Column",(()=>(0,E.jsx)(Ug,{state:this})),{x:50,y:50,width:500,height:300,minWidth:300,minHeight:200,center:!1})}async applyChanges(){if(!this.validationState.hasCompleted||!this.isNameValid||!this.isTypeValid)return;let e,t;this.finalizationState.inProgress();try{[e,t]=await Promise.all([this.view.engine.parseValueSpecification(this.code,!1),this.getReturnType()])}catch(e){return w(e),void this.view.dataCube.alertService.alertError(e,{message:`Expression Validation Failure: ${e.message}`})}finally{this.finalizationState.complete()}e instanceof Gr?t?(this._manager.addNewColumn({name:this.name,type:t,mapFn:this.view.engine.serializeValueSpecification(e)},this.isGroupLevel,this.columnKind,this),this.close()):this.view.dataCube.alertService.alertError(new Error,{message:"Expression Validation Failure: Can't compute expression return type."}):this.view.dataCube.alertService.alertError(new Error,{message:"Expression Validation Failure: Expression must be a lambda."})}}class Wg extends Hg{initialData;constructor(e,t,n,o){super(e,t.name,Qi(t.type),o,n),(0,Ie.Gn)(this,{initialData:Ie.sH.ref,isNameValid:Ie.$Z}),this.initialData={name:t.name,type:t.type,kind:n,isGroupLevel:o,mapFn:t.mapFn}}get isNameValid(){return!this._manager.allColumnNames.filter((e=>e!==this.initialData.name)).includes(this.name)}async getInitialCode(){return this.view.engine.getValueSpecificationCode(this.view.engine.deserializeValueSpecification(this.initialData.mapFn),!0)}newDisplay(e){return this.view.dataCube.layoutService.newDisplay("Edit Column",(()=>(0,E.jsx)(Ug,{state:this})),{x:50,y:50,width:500,height:300,minWidth:300,minHeight:200,center:!1})}async reset(){this.setName(this.initialData.name),this.setExpectedType(Qi(this.initialData.type)),this.setColumnKind(this.initialData.isGroupLevel,this.initialData.kind),await this.initialize(),await this.getReturnType()}async applyChanges(){if(!this.validationState.hasCompleted||!this.isNameValid||!this.isTypeValid)return;let e,t;this.finalizationState.inProgress();try{[e,t]=await Promise.all([this.view.engine.parseValueSpecification(this.code,!1),this.getReturnType()])}catch(e){return w(e),void this.view.dataCube.alertService.alertError(e,{message:`Expression Validation Failure: ${e.message}`})}finally{this.finalizationState.complete()}e instanceof Gr?t?await this._manager.updateColumn(this.initialData.name,{name:this.name,type:t,mapFn:this.view.engine.serializeValueSpecification(e)},this.isGroupLevel,this.columnKind):this.view.dataCube.alertService.alertError(new Error,{message:"Expression Validation Failure: Can't compute expression return type."}):this.view.dataCube.alertService.alertError(new Error,{message:"Expression Validation Failure: Expression must be a lambda."})}}class zg{name;type;data;constructor(e){this.name=e.name,this.type=e.type,this.data=e}}class $g extends om{view;columnConfigurations=[];selectColumns=[];sourceColumns=[];horizontalPivotCastColumns=[];leafExtendedColumns=[];groupExtendedColumns=[];newColumnEditors=[];existingColumnEditors=[];constructor(e){super(e.engine,e.settingService,e.snapshotService),(0,Ie.Gn)(this,{sourceColumns:Ie.sH.ref,horizontalPivotCastColumns:Ie.sH.ref,leafExtendedColumns:Ie.sH,setLeafExtendedColumns:Ie.XI,groupExtendedColumns:Ie.sH,setGroupExtendedColumns:Ie.XI,allColumnNames:Ie.EW,addNewColumn:Ie.XI,updateColumn:Ie.XI,deleteColumn:Ie.XI,applySnapshot:Ie.XI}),this.view=e}setLeafExtendedColumns(e){this.leafExtendedColumns=e}setGroupExtendedColumns(e){this.groupExtendedColumns=e}get allColumnNames(){return(0,nt.A)([...this.sourceColumns,...this.leafExtendedColumns,...this.groupExtendedColumns,...this.horizontalPivotCastColumns],(e=>e.name)).map((e=>e.name))}async openNewColumnEditor(e){const t=new Vg(this,e);await t.initialize(),this.newColumnEditors.push(t),t.display.open()}async openExistingColumnEditor(e){const t=this.existingColumnEditors.find((t=>t.initialData.name===e));if(t)return void t.display.open();if(!ra(this.leafExtendedColumns,e)&&!ra(this.groupExtendedColumns,e))return;const n=new Wg(this,D(ra(this.leafExtendedColumns,e)??ra(this.groupExtendedColumns,e)).data,D(ra(this.columnConfigurations,e)).kind,Boolean(ra(this.groupExtendedColumns,e)));await n.initialize(),this.existingColumnEditors.push(n),n.display.open()}addNewColumn(e,t,n,o){const r=Pd(e);n&&(r.kind=n,r.excludedFromPivot=n===mi.DIMENSION),this.columnConfigurations.push(r),S(this.newColumnEditors,o),t?this.groupExtendedColumns.push(new zg(e)):(this.leafExtendedColumns.push(new zg(e)),this.selectColumns.push(ia(e))),this.applyChanges()}async updateColumn(e,t,n,o){if(!ra(this.leafExtendedColumns,e)&&!ra(this.groupExtendedColumns,e))return;const r=D(ra(this.columnConfigurations,e)),i=this.view.taskService.newTask("Checking column update..."),a=D(this.getLatestSnapshot()).clone();a.data.leafExtendedColumns=a.data.leafExtendedColumns.filter((t=>t.name!==e)),a.data.groupExtendedColumns=a.data.groupExtendedColumns.filter((t=>t.name!==e)),a.data.selectColumns=a.data.selectColumns.filter((t=>t.name!==e)),n?a.data.groupExtendedColumns.push(t):(a.data.leafExtendedColumns.push(t),r.isSelected&&a.data.selectColumns.push(ia(t))),a.data.configuration={...a.data.configuration,columns:this.columnConfigurations.map((n=>n.name===e?{...n.serialize(),...ia(t),kind:o}:n.serialize()))};const s=await this._engine.getPartialQueryCode(a,!0);try{await this._engine.getQueryCodeRelationReturnType("->"+s,kl([],[this.view.source.query]),this.view.source)}catch(t){return w(t),void(t instanceof qm?this.view.dataCube.alertService.alertCodeCheckError(t,s,"->",{message:`Column Update Check Failure: Can't safely update column '${e}'. Check the query code below for more details.`,text:`Error: ${t.message}`}):this.view.dataCube.alertService.alertError(t,{message:`Column Update Check Failure: Can't safely update column '${e}'.`,text:`Error: ${t.message}`}))}finally{this.view.taskService.endTask(i)}this.setLeafExtendedColumns(this.leafExtendedColumns.filter((t=>t.name!==e))),this.setGroupExtendedColumns(this.groupExtendedColumns.filter((t=>t.name!==e))),this.selectColumns=this.selectColumns.filter((t=>t.name!==e)),n?this.setGroupExtendedColumns([...this.groupExtendedColumns,new zg(t)]):(this.setLeafExtendedColumns([...this.leafExtendedColumns,new zg(t)]),r.isSelected&&this.selectColumns.push(ia(t))),this.columnConfigurations=this.columnConfigurations.map((n=>(n.name===e&&(n.kind=o??Qi(t.type)===_i.NUMBER?mi.MEASURE:mi.DIMENSION,n.name=t.name,n.type=t.type,n.excludedFromPivot=n.kind===mi.DIMENSION),n))),this.existingColumnEditors.filter((t=>t.initialData.name===e)).forEach((e=>e.display.close())),this.existingColumnEditors=this.existingColumnEditors.filter((t=>t.initialData.name!==e)),this.applyChanges()}async deleteColumn(e){if(!ra(this.leafExtendedColumns,e)&&!ra(this.groupExtendedColumns,e))return;const t=this.view.taskService.newTask("Checking column deletion..."),n=D(this.getLatestSnapshot()).clone();n.data.leafExtendedColumns=n.data.leafExtendedColumns.filter((t=>t.name!==e)),n.data.groupExtendedColumns=n.data.groupExtendedColumns.filter((t=>t.name!==e)),n.data.selectColumns=n.data.selectColumns.filter((t=>t.name!==e)),n.data.configuration={...n.data.configuration,columns:this.columnConfigurations.filter((t=>t.name!==e)).map((e=>e.serialize()))};const o=await this._engine.getPartialQueryCode(n,!0);try{await this._engine.getQueryCodeRelationReturnType("->"+o,kl([],[this.view.source.query]),this.view.source)}catch(t){return w(t),void(t instanceof qm?this.view.dataCube.alertService.alertCodeCheckError(t,o,"->",{message:`Column Delete Check Failure: Can't safely delete column '${e}'. Check the query code below for more details.`,text:`Error: ${t.message}`}):this.view.dataCube.alertService.alertError(t,{message:`Column Delete Check Failure: Can't safely delete column '${e}'.`,text:`Error: ${t.message}`}))}finally{this.view.taskService.endTask(t)}this.setLeafExtendedColumns(this.leafExtendedColumns.filter((t=>t.name!==e))),this.setGroupExtendedColumns(this.groupExtendedColumns.filter((t=>t.name!==e))),this.columnConfigurations=this.columnConfigurations.filter((t=>t.name!==e)),this.selectColumns=this.selectColumns.filter((t=>t.name!==e)),this.existingColumnEditors.filter((t=>t.initialData.name===e)).forEach((e=>e.display.close())),this.existingColumnEditors=this.existingColumnEditors.filter((t=>t.initialData.name!==e)),this.applyChanges()}getSnapshotSubscriberName(){return"extend-manager"}async applySnapshot(e,t){const n=da.serialization.fromJson(e.data.configuration);this.columnConfigurations=n.columns,this.sourceColumns=e.data.sourceColumns,this.leafExtendedColumns=e.data.leafExtendedColumns.map((e=>new zg(e))),this.groupExtendedColumns=e.data.groupExtendedColumns.map((e=>new zg(e))),this.horizontalPivotCastColumns=e.data.pivot?.castColumns??[],this.selectColumns=e.data.selectColumns.map(ia),[...this.newColumnEditors,...this.existingColumnEditors].forEach((e=>{e.getReturnType().catch((()=>{}))}))}applyChanges(){const e=D(this.getLatestSnapshot()),t=e.clone();t.data.configuration={...e.data.configuration,columns:this.columnConfigurations.map((e=>e.serialize()))},t.data.leafExtendedColumns=this.leafExtendedColumns.map((e=>e.data)),t.data.groupExtendedColumns=this.groupExtendedColumns.map((e=>e.data)),t.data.selectColumns=[...this.selectColumns],t.finalize(),t.hashCode!==e.hashCode&&this.publishSnapshot(t)}}class Yg{uuid=(0,i.A)();description;startTime=Date.now();ownerId;endTime;constructor(e,t){this.description=e,this.ownerId=t}end(){this.endTime=Date.now()}}class Xg{tasks=[];constructor(){(0,Ie.Gn)(this,{tasks:Ie.sH,newTask:Ie.XI,endTask:Ie.XI,endTasks:Ie.XI})}newTask(e,t){const n=new Yg(e,t);return this.tasks.push(n),n}endTask(e){return this.tasks.find((t=>t.uuid===e.uuid))&&(this.tasks=this.tasks.filter((t=>t.uuid!==e.uuid)),e.end()),e}endTasks(e){this.tasks=this.tasks.filter((t=>!e.find((e=>e.uuid===t.uuid)))),e.forEach((e=>e.end()))}}class Kg{uuid=(0,i.A)();manager;constructor(e){(0,Ie.Gn)(this,{tasks:Ie.EW}),this.manager=e??new Xg}get tasks(){return this.manager.tasks.filter((e=>e.ownerId===this.uuid))}newTask(e){return this.manager.newTask(e,this.uuid)}endTask(e){return this.manager.endTask(e)}dispose(){this.manager.endTasks(this.tasks)}}class qg extends fc{model;runtime;db;schema;table;count}class Jg{dataCube;engine;logService;taskService;layoutService;alertService;settingService;snapshotService;info;editor;grid;filter;extend;initializeState=we.create();processCacheState=we.create();_source;_initialSource;_initialSpecification;constructor(e){this.dataCube=e,this.engine=e.engine,this.logService=e.logService,this.taskService=new Kg(e.taskService.manager),this.layoutService=e.layoutService,this.alertService=e.alertService,this.settingService=e.settingService,this.snapshotService=new rm(this.logService,this.settingService),this.info=new lg(this),this.editor=new Qm(this),this.grid=new sg(this),this.filter=new Bg(this),this.extend=new $g(this)}getInitialSource(){return this._initialSource}async generateSpecification(){const e=this.snapshotService.getCurrentSnapshot(),t=new Dd;return t.source=this.dataCube.specification.source,t.configuration=da.serialization.fromJson(e.data.configuration),t.query=await this.engine.getPartialQueryCode(e),t.dimensionalTree=e.data.dimensionalTree,t}get source(){if(!this._source)throw new x("Source is not initialized");return this._source}updateName(e){const t=this.snapshotService.getCurrentSnapshot(),n=t.clone(),o=da.serialization.fromJson(t.data.configuration);o.name!==e&&(o.name=e,n.data.configuration=o.serialize(),n.finalize(),n.hashCode!==t.hashCode&&this.snapshotService.broadcastSnapshot(n))}async applySpecification(e){const t=this.taskService.newTask("Applying specification...");try{if(!this._initialSource||!this._initialSpecification)throw new Error("DataCube is not initialized");if(!(0,Oo.A)(e.source,this._initialSpecification.source))throw new Error("Can't apply specification with different source");const t=await this.engine.parseValueSpecification(e.query),n=await mg(t,this._initialSource,e,this.engine);n.finalize(),n.hashCode!==this.snapshotService.getCurrentSnapshot().hashCode&&this.snapshotService.broadcastSnapshot(n)}catch(e){w(e),this.alertService.alertError(e,{message:`Specification Application Failure: ${e.message}`}),this.initializeState.fail()}finally{this.taskService.endTask(t)}}async initializeCache(){this.processCacheState.inProgress();const e=this.taskService.newTask("Initializing cache...");try{const e=await this.engine.initializeCache(this.source,{debug:this.settingService.getBooleanValue(Uu.DEBUGGER__ENABLE_DEBUG_MODE),clientVersion:this.settingService.getBooleanValue(Uu.DEBUGGER__USE_DEV_CLIENT_PROTOCOL_VERSION)?gc.VX_X_X:void 0});e&&(this._source=e),this.processCacheState.pass()}catch(e){w(e),this.alertService.alertError(e,{message:`Cache Processing Failure: ${e.message}`}),this._source=this._initialSource,this.processCacheState.fail()}finally{this.taskService.endTask(e)}}async disposeCache(){if(!(this._source instanceof qg))return;const e=this._source;this._source=this._initialSource,this.processCacheState.inProgress();const t=this.taskService.newTask("Disposing cache...");try{await this.engine.disposeCache(e)}catch(e){w(e),this.alertService.alertError(e,{message:`Cache Processing Failure: ${e.message}`})}finally{this.processCacheState.complete(),this.taskService.endTask(t)}}async initialize(e){this.initializeState.inProgress();const t=this.taskService.newTask("Initializing...");try{await Promise.all([this.info,this.editor,this.grid,this.grid.controller,this.filter,this.extend].map((async e=>{this.snapshotService.registerSubscriber(e)})));const t=await this.engine.processSource(e.source);this._source=t,this._initialSource=t,this._initialSpecification=e;const n=await this.engine.parseValueSpecification(e.query),o=await mg(n,t,e,this.engine),r=e=>{this.dataCube.telemetryService.sendTelemetry(Ud.SELECT_ACTION_CACHE_LOAD_ALERT,{...this.engine.getDataFromSource(this._initialSource),keepCachingEnabled:e})};e.options?.autoEnableCache&&(await this.grid.setCachingEnabled(!0,{suppressWarning:!0}),this.grid.isCachingEnabled&&this.settingService.getBooleanValue(Uu.GRID_CLIENT__SHOW_AUTO_ENABLE_CACHE_PERFORMANCE_WARNING)&&this.alertService.alert({message:"Caching is auto-enabled for this DataCube",text:"When enabled, the source dataset will be cached locally in order to boost query performance. But depending on computational resource available to your environment, sometimes, caching can negatively impact the overall performance, and can even lead to crashes.\n\nOverall, caching is still an experimental feature where we only support queries with simple execution plans, certain queries might not work.\n\nYou can disable caching if needed, otherwise, please proceed with caution.",type:Mu.WARNING,actions:[{label:"OK",handler:()=>{r(!0)}},{label:"Disable Caching",handler:()=>{r(!1),this.grid.setCachingEnabled(!1,{suppressWarning:!0}).catch((e=>this.alertService.alertUnhandledError(e)))}},{label:"Dismiss Warning",handler:()=>{r(!0),this.settingService.updateValue(this.dataCube.api,Uu.GRID_CLIENT__SHOW_AUTO_ENABLE_CACHE_PERFORMANCE_WARNING,!1)}}],windowConfig:{...Er,width:600,height:300,minWidth:300,minHeight:150}})),this.snapshotService.broadcastSnapshot(o),this.dataCube.options?.onViewInitialized?.({api:this.dataCube.api,source:t}),this.initializeState.pass()}catch(e){w(e),this.alertService.alertError(e,{message:`Initialization Failure: ${e.message}`,text:"Resolve the issue and reload the engine."}),this.initializeState.fail()}finally{this.taskService.endTask(t)}}dispose(){this.taskService.dispose()}}const Qg=(0,vt.PA)((e=>{const{configuration:t}=e,n=bu(),o=n.settingService;switch(t.type){case th.BOOLEAN:{const e=$(o.currentValues.get(t.key));return(0,E.jsxs)("div",{className:"my-2",children:[(0,E.jsx)("div",{className:"font-medium",children:t.title}),(0,E.jsx)("div",{className:"flex pr-2",children:(0,E.jsx)(Au,{label:t.description,checked:e,onChange:()=>{(0,Ie.h5)((()=>{o.currentValues.set(t.key,!e)}))}})})]})}case th.NUMERIC:{const e=z(o.currentValues.get(t.key)),n=t.defaultValue;return(0,E.jsxs)("div",{className:"my-2",children:[(0,E.jsx)("div",{className:"font-medium",children:t.title}),(0,E.jsx)("div",{className:"mb-1.5 text-sm text-neutral-700",children:t.description}),(0,E.jsx)(Nu,{className:"w-20 text-sm",min:t.numericValueMin,step:t.numericValueStep,max:t.numericValueMax,defaultValue:n,value:e,setValue:e=>{(0,Ie.h5)((()=>{o.currentValues.set(t.key,e??n)}))}})]})}case th.STRING:{const e=W(o.currentValues.get(t.key));return(0,E.jsxs)("div",{className:"my-2",children:[(0,E.jsx)("div",{className:"font-medium",children:t.title}),(0,E.jsx)("div",{className:"mb-1.5 text-sm text-neutral-700",children:t.description}),(0,E.jsx)(Su,{className:"w-80 text-sm",value:e,onChange:e=>{(0,Ie.h5)((()=>{o.currentValues.set(t.key,e.target.value)}))}})]})}case th.ACTION:return(0,E.jsxs)("div",{className:"my-2",children:[(0,E.jsx)("div",{className:"font-medium",children:t.title}),(0,E.jsx)("div",{className:"mb-1.5 text-sm text-neutral-700",children:t.description}),(0,E.jsx)("div",{className:"flex pr-2",children:(0,E.jsx)(Tu,{compact:!0,onClick:()=>t.action?.(n.api,void 0),children:"Run Action"})})]});default:return null}})),Zg=(0,vt.PA)((()=>{const e=bu(),t=e.settingService,n=Array.from(t.configurations.values()).toSorted(((e,t)=>e.title.localeCompare(t.title)));return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"h-[calc(100%_-_40px)] w-full p-2 pb-0",children:(0,E.jsxs)("div",{className:"h-full w-full select-none overflow-auto border border-neutral-300 bg-white p-2",children:[(0,E.jsx)("div",{className:"mt-1 flex h-5",children:(0,E.jsxs)("div",{className:"flex h-full",children:[(0,E.jsx)("div",{className:"flex h-5 items-center text-xl font-medium",children:(0,E.jsx)(pr.Table,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-5 items-center text-xl font-medium",children:"Grid"})]})}),n.filter((e=>e.group===eh.GRID)).map((e=>(0,E.jsx)(Qg,{configuration:e},e.key))),(0,E.jsx)("div",{className:"my-2 h-[1px] w-full bg-neutral-200"}),(0,E.jsx)("div",{className:"mt-1 flex h-5",children:(0,E.jsxs)("div",{className:"flex h-full",children:[(0,E.jsx)("div",{className:"flex h-5 items-center text-xl font-medium",children:(0,E.jsx)(pr.Debug,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-5 items-center text-xl font-medium",children:"Debug"})]})}),n.filter((e=>e.group===eh.DEBUG)).map((e=>(0,E.jsx)(Qg,{configuration:e},e.key)))]})}),(0,E.jsxs)("div",{className:"flex h-10 items-center justify-end px-2",children:[(0,E.jsx)(Tu,{onClick:()=>t.restoreDefaultValues(),disabled:!t.allowRestoreDefaultValues,children:"Restore Default Settings"}),(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>{t.display.close()},children:"Cancel"}),(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>t.save(e.api),children:"Apply"}),(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>{t.save(e.api),t.display.close()},children:"OK"})]})]})}));var eh,th,nh,oh,rh,ih;!function(e){e.DEBUG="Debug",e.EDITOR="Editor",e.GRID="Grid"}(eh||(eh={})),function(e){e.BOOLEAN="boolean",e.NUMERIC="numeric",e.STRING="string",e.ACTION="action"}(th||(th={}));class ah{_engine;_logService;_layoutService;_options;display;configurations=new Map;defaultValues=new Map;_defaultValuesHashCode;values=new Map;currentValues=new Map;constructor(e,t,n,o){(0,Ie.Gn)(this,{values:Ie.sH,save:Ie.XI,valuesHashCode:Ie.EW,currentValues:Ie.sH,restoreDefaultValues:Ie.XI,currentValuesHashCode:Ie.EW,allowRestoreDefaultValues:Ie.EW}),this._engine=e,this._logService=t,this._layoutService=n,this._options=o,this.display=this._layoutService.newDisplay("Settings",(()=>(0,E.jsx)(Zg,{})),{x:-50,y:50,width:600,height:400,minWidth:300,minHeight:200,center:!1});const r=[{key:Uu.DEBUGGER__ENABLE_DEBUG_MODE,title:"Debug Mode: Enabled",description:"Enables debug logging when running data queries, updating snapshots, etc.",group:eh.DEBUG,type:th.BOOLEAN,defaultValue:!1},{key:Uu.DEBUGGER__USE_DEV_CLIENT_PROTOCOL_VERSION,title:"Use development client protocol version: Enabled",description:"Specifies if development client protocol version (vX_X_X) should be used for execution",group:eh.DEBUG,type:th.BOOLEAN,defaultValue:!1},{key:Uu.DEBUGGER__ACTION__RELOAD,title:"Reload",description:"Manually reload DataCube (keeping all states). This is needed when making changes to settings that require reloading to take effect.",group:eh.DEBUG,type:th.ACTION,action:e=>e.reload(),defaultValue:void 0},{key:Uu.GRID_CLIENT__SHOW_CACHE_PERFORMANCE_WARNING,title:"Caching Performance Warning: Enabled",description:"Alerts user of potential performance and resource-related issues that caching can cause when enabled.",group:eh.GRID,type:th.BOOLEAN,defaultValue:!0},{key:Uu.GRID_CLIENT__SHOW_AUTO_ENABLE_CACHE_PERFORMANCE_WARNING,title:"Caching (Auto-Enabled) Performance Warning: Enabled",description:"Alerts user that caching is auto-enabled for the DataCube and of potential performance and resource-related issues that caching can cause when enabled.",group:eh.GRID,type:th.BOOLEAN,defaultValue:!0},{key:Uu.EDITOR__MAX_HISTORY_STACK_SIZE,title:"Max History Stack Size",description:"Sets the number of maximum snapshots to store in edit history.",group:eh.EDITOR,type:th.NUMERIC,defaultValue:100,numericValueMin:10,numericValueStep:10,action:(e,t)=>e._runTaskForEachView((e=>{e.snapshotService.adjustHistorySize(t)}))},{key:Uu.GRID_CLIENT__SUPPRESS_LARGE_DATASET_WARNING,title:"Large Dataset Warning: Disabled",description:"Suggests user to enable pagination when handling large datasets to improve performance.",group:eh.GRID,type:th.BOOLEAN,defaultValue:!1},{key:Uu.GRID_CLIENT__ROW_BUFFER,title:"Row Buffer",description:"Sets the number of rows the grid renders outside of the viewable area. e.g. if the buffer is 10 and your grid is showing 50 rows (as that's all that fits on your screen without scrolling), then the grid will actually render 70 in total (10 extra above and 10 extra below). Then when you scroll, the grid will already have 10 rows ready and waiting to show, no redraw is needed. A low small buffer will make initial draws of the grid faster; whereas a big one will reduce the redraw visible vertically scrolling.",group:eh.GRID,type:th.NUMERIC,defaultValue:50,numericValueMin:10,numericValueStep:10,action:(e,t)=>e._runTaskForEachView((e=>{e.grid.isClientConfigured&&e.grid.client.updateGridOptions({rowBuffer:t})}))},{key:Uu.GRID_CLIENT__PURGE_CLOSED_ROW_NODES,title:"Refresh Group Node Data: Enabled",description:"Forces refresh data when group node is opened.",group:eh.GRID,type:th.BOOLEAN,defaultValue:!1,action:(e,t)=>e._runTaskForEachView((e=>{e.grid.isClientConfigured&&e.grid.client.updateGridOptions({purgeClosedRowNodes:t})}))},{key:Uu.GRID_CLIENT__ACTION__RETRY_FAILED_DATA_FETCHES,title:"Retry Failed Data Fetches: Action",description:"Manually re-runs all failed data fetches in the grid.",group:eh.GRID,type:th.ACTION,action:e=>e.retryFailedDataFetches(),defaultValue:void 0}],{configurations:i,values:a}=o?.settingsData??{};[...r,...i??[]].forEach((e=>{this.configurations.set(e.key,e),this.setValue(e.key,e.defaultValue,[this.defaultValues,this.values,this.currentValues])}));const s=a??{};Object.keys(s).forEach((e=>{const t=s[e];this.configurations.get(e)&&this.setValue(e,t,[this.values,this.currentValues])})),this._defaultValuesHashCode=this.computeValuesHashCode(this.defaultValues)}setValue(e,t,n){const o=this.configurations.get(e);if(!o)return this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__FOUND_UNREGISTERED_SETTING),`Can't set value for unregistered setting '${e}'`),!1;switch(o.type){case th.BOOLEAN:if(!(H(t)||void 0===t&&o.valueOptional))return this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__FOUND_UNREGISTERED_SETTING),`Can't set value for setting '${e}': boolean value expected`),!1;break;case th.NUMERIC:if(!(G(t)||void 0===t&&o.valueOptional))return this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__FOUND_UNREGISTERED_SETTING),`Can't set value for setting '${e}': numeric value expected`),!1;break;case th.STRING:if(!(U(t)||void 0===t&&o.valueOptional))return this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__FOUND_UNREGISTERED_SETTING),`Can't set value for setting '${e}': string value expected`),!1;break;case th.ACTION:return!1;default:throw new I(`Can't set value for unsupported setting type '${o.type}'`)}return n.forEach((n=>{(0,Ie.h5)((()=>n.set(e,t)))})),!0}getConfiguration(e){const t=this.configurations.get(e);if(!t)throw this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__FOUND_UNREGISTERED_SETTING),`Can't retrieve value for unregistered setting '${e}'`),new x(`Can't retrieve value for unregistered setting '${e}'`);return t}getBooleanValue(e){const t=this.values.get(e);if(this.getConfiguration(e).type!==th.BOOLEAN||!H(t))throw this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__RETRIEVE_INCOMPATIBLE_VALUE),`Can't retrieve boolean value for setting '${e}'`),new x(`Can't retrieve boolean value for setting '${e}'`);return t}getNumericValue(e){const t=this.values.get(e);if(this.getConfiguration(e).type!==th.NUMERIC||!G(t))throw this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__RETRIEVE_INCOMPATIBLE_VALUE),`Can't retrieve numeric value for setting '${e}'`),new x(`Can't retrieve numeric value for setting '${e}'`);return t}getStringValue(e){const t=this.values.get(e);if(this.getConfiguration(e).type!==th.STRING||!U(t))throw this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__RETRIEVE_INCOMPATIBLE_VALUE),`Can't retrieve string value for setting '${e}'`),new x(`Can't retrieve string value for setting '${e}'`);return t}computeValuesHashCode(e){return Fr(Array.from(e.entries()).toSorted(((e,t)=>e[0].localeCompare(t[0]))).map((([e,t])=>`${e}:${t}`)))}get valuesHashCode(){return this.computeValuesHashCode(this.values)}get currentValuesHashCode(){return this.computeValuesHashCode(this.currentValues)}get allowRestoreDefaultValues(){return this._defaultValuesHashCode!==this.currentValuesHashCode}restoreDefaultValues(){this.currentValues.clear(),this.defaultValues.forEach(((e,t)=>this.currentValues.set(t,e)))}getCurrentSettingValues(){const e={};return this.values.forEach(((t,n)=>{const o=this.configurations.get(n);o&&t!==o.defaultValue&&(e[n]=t)})),e}updateValue(e,t,n){const o=this.configurations.get(t);o?this.setValue(t,n,[this.values,this.currentValues])&&(this._options?.onSettingsChanged?.({api:e,values:this.getCurrentSettingValues()}),o.action?.(e,n)):this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__FOUND_UNREGISTERED_SETTING),`Can't set value for unregistered setting '${t}'`)}save(e){const t=new Set;this.values.forEach(((e,n)=>{e!==this.currentValues.get(n)&&t.add(n)})),this.values.clear(),this.currentValues.forEach(((e,t)=>this.values.set(t,e))),this._options?.onSettingsChanged?.({api:e,values:this.getCurrentSettingValues()});let n=!1;for(const o of t){const t=this.configurations.get(o);t?.requiresReload&&(n=!0),t?.action&&t.action(e,this.values.get(o))}n&&e.reload()}}class sh{_dataCube;constructor(e){this._dataCube=e}_runTaskForEachView(e){e(this._dataCube.view)}getProcessedSource(){return this._dataCube.view.getInitialSource()}generateSpecification(){return this._dataCube.view.generateSpecification()}updateName(e){this._dataCube.view.updateName(e)}async applySpecification(e){await this._dataCube.view.applySpecification(e)}retryFailedDataFetches(){this._runTaskForEachView((e=>{e.grid.isClientConfigured&&e.grid.client.retryServerSideLoads()}))}reload(){this._dataCube.reload()}isCachingEnabled(){return this._dataCube.view.grid.isCachingEnabled}}!function(e){e.PROFILE="Profile",e.CLASS="Class",e.ENUMERATION="Enum",e.MEASURE="Measure",e.ASSOCIATION="Association",e.FUNCTION="function",e.MAPPING="Mapping",e.FLAT_DATA="FlatData",e.DATABASE="Database",e.SERVICE="Service",e.RUNTIME="Runtime",e.CONNECTION="Connection",e.FILE_GENERATION="FileGeneration",e.GENERATION_SPECIFICATION="GenerationSpecification",e.DATA_ELEMENT="Data",e.EXECUTION_ENVIRONMENT="ExecutionEnvironment"}(nh||(nh={})),function(e){e.JSON_MODEL_CONNECTION="JsonModelConnection",e.XML_MODEL_CONNECTION="XmlModelConnection",e.MODEL_CHAIN_CONNECTION="ModelChainConnection",e.RELATIONAL_DATABASE_CONNECTION="RelationalDatabaseConnection",e.FLAT_DATA_CONNECTION="FlatDataConnection"}(oh||(oh={})),(ih=rh||(rh={})).PURE="Pure",ih.CONNECTION="Connection",ih.RUNTIME="Runtime",ih.MAPPING="Mapping",ih.SERVICE="Service",ih.FLATDATA="FlatData",ih.RELATIONAL="Relational",ih.GENERATION_SPECIFICATION="GenerationSpecification",ih.FILE_GENERATION_SPECIFICATION="FileGeneration",ih.DATA="Data";const lh={wordPattern:/(-?\d*\.\d\w*)|([^`~!@#%^$&*()\-=+[{\]}\\|;:'",.<>/?\s][^`~!@#%^&*()\-=+[{\]}\\|;:'",.<>/?\s]*)/,comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"},{open:"<",close:">"},{open:"<<",close:">>"}],folding:{markers:{start:new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))"),end:new RegExp("^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))")}}};const ch=(0,vt.PA)((()=>{const e=bu().documentationService.currentEntry;if(!e)return null;const t=e.markdownText??e.text;return(0,E.jsxs)("div",{className:"h-full w-full overflow-auto bg-white p-4",children:[(0,E.jsx)("div",{className:"mb-3 text-2xl font-bold",children:e.title}),t&&(U(t)?(0,E.jsx)("div",{children:t}):(0,E.jsx)(Ln,{value:t}))]})}));class uh{_engine;_layoutService;display;currentEntry;constructor(e,t){(0,Ie.Gn)(this,{currentEntry:Ie.sH,setCurrentEntry:Ie.XI}),this._engine=e,this._layoutService=t,this.display=this._layoutService.newDisplay("Documentation",(()=>(0,E.jsx)(ch,{})),{x:-50,y:-50,width:400,height:400,minWidth:300,minHeight:200,center:!1})}getEntry(e){return this._engine.getDocumentationEntry(e)}setCurrentEntry(e){this.currentEntry=e}shouldDisplayDocumentationEntry(e){return Boolean(e.title&&(e.text??e.markdownText))}}class dh{_engine;constructor(e){this._engine=e}sendTelemetry(e,t){this._engine.sendTelemetry(e,t)}}class ph{_engine;constructor(e){this._engine=e}openLink(e){this._engine.openLink(e)}}class mh{_engine;constructor(e){this._engine=e}logDebug(e,...t){this._engine.logDebug(e,...t)}debugProcess(e,...t){this._engine.debugProcess(e,...t)}logInfo(e,...t){this._engine.logInfo(e,...t)}logWarning(e,...t){this._engine.logWarning(e,...t)}logError(e,...t){this._engine.logError(e,...t)}logUnhandledError(e){this._engine.logUnhandledError(e)}logIllegalStateError(e,t){this._engine.logIllegalStateError(e,t)}}class gh{engine;logService;taskService;layoutService;settingService;documentationService;alertService;navigationService;telemetryService;specification;options;initializeState=we.create();api;uuid=(0,i.A)();view;constructor(e,t,n){(0,Ie.Gn)(this,{uuid:Ie.sH,reload:Ie.XI}),this.engine=t,this.logService=new mh(this.engine),this.taskService=new Kg(n?.taskManager),this.layoutService=new vr(n?.layoutManager),this.settingService=new ah(this.engine,this.logService,this.layoutService,n),this.documentationService=new uh(this.engine,this.layoutService),this.alertService=new Gu(this.logService,this.layoutService),this.navigationService=new ph(this.engine),this.telemetryService=new dh(this.engine),this.api=new sh(this),this.specification=e,this.options=n,this.view=new Jg(this)}async initialize(){if(this.initializeState.isInInitialState){this.initializeState.inProgress();try{this.options?.gridClientLicense&&xr.hFV.setLicenseKey(this.options.gridClientLicense),await(async(e,t)=>{Nr.editor.defineTheme(Xc.DEFAULT_DARK,Kc),Nr.editor.defineTheme(Xc.SOLARIZED_DARK,qc),Nr.editor.defineTheme(Xc.GITHUB_DARK,Jc),Nr.editor.defineTheme(Xc.GITHUB_DARK_DIMMED,Zc),Nr.editor.defineTheme(Xc.GITHUB_LIGHT,Qc),Nr.editor.defineTheme(Xc.MATERIAL_DEFAULT,eu),Nr.editor.defineTheme(Xc.MATERIAL_DARKER,tu),Nr.editor.defineTheme(Xc.ONE_DARK_PRO,nu),Nr.editor.defineTheme(Xc.ONE_DARK_PRO_DARKER,ou);const n=`Monospaced font '${e}' has not been loaded properly, code editor might not display properly`;await Promise.all([400,700].map((t=>document.fonts.load(`${t} 1em ${e}`)))).then((()=>{document.fonts.check(`1em ${e}`)?Nr.editor.remeasureFonts():t(new Error(n))})).catch((()=>t(new Error(n))))})(ci.ROBOTO_MONO,(e=>{throw e})),e={},Nr.languages.register({id:lu.PURE}),Nr.languages.setLanguageConfiguration(lu.PURE,lh),Nr.languages.setMonarchTokensProvider(lu.PURE,(t=e?.extraKeywords??[],{defaultToken:"invalid",tokenPostfix:".pure",keywords:[...t,"Schema","Table","Join","View","primaryKey","groupBy","mainTable","let","extends","true","false","projects",nh.CLASS,nh.ASSOCIATION,nh.ENUMERATION,nh.MEASURE,nh.PROFILE,nh.FUNCTION,nh.MAPPING,nh.RUNTIME,nh.CONNECTION,nh.FILE_GENERATION,nh.GENERATION_SPECIFICATION,nh.DATA_ELEMENT,oh.JSON_MODEL_CONNECTION,oh.MODEL_CHAIN_CONNECTION,oh.XML_MODEL_CONNECTION,"include","EnumerationMapping","Pure","AssociationMapping","XStore","AggregationAware",nh.SERVICE,nh.FLAT_DATA,nh.DATABASE,oh.FLAT_DATA_CONNECTION,oh.RELATIONAL_DATABASE_CONNECTION,"Relational"],operators:["=",">","<","!","~","?",":","==","<=",">=","&&","||","++","--","+","-","*","/","&","|","^","%","->","#{","}#","@","<<",">>"],languageStructs:["import","native"],identifier:/[a-zA-Z_$][\w$]*/,symbols:/[=><!~?:&|+\-*/^%#@]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,digits:/\d+(_+\d+)*/,octaldigits:/[0-7]+(_+[0-7]+)*/,binarydigits:/[0-1]+(_+[0-1]+)*/,hexdigits:/[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,multiplicity:/\[(?:[a-zA-Z0-9]+(?:\.\.(?:[a-zA-Z0-9]+|\*|))?|\*)\]/,package:/(?:[\w_]+::)+/,generics:/(?:(?:<\w+>)|(?:<[^:.@^()]+[^-]>))/,date:/%-?\d+(?:-\d+(?:-\d+(?:T(?:\d+(?::\d+(?::\d+(?:.\d+)?)?)?)(?:[+-][0-9]{4})?)))/,time:/%\d+(?::\d+(?::\d+(?:.\d+)?)?)?/,tokenizer:{root:[{include:"@pure"},{include:"@date"},{include:"@color"},[/^\s*###[\w]+/,hc.PARSER],[/(@identifier)/,{cases:{"@languageStructs":hc.LANGUAGE_STRUCT,"@keywords":`${hc.KEYWORD}.$0`,"([a-zA-Z_$][\\w$]*)_((\\w+_(([a-zA-Z0-9]+)|(\\$[a-zA-Z0-9]+_[a-zA-Z0-9]+\\$)))__)*(\\w+_(([a-zA-Z0-9]+)|(\\$[a-zA-Z0-9]+_[a-zA-Z0-9]+\\$)))_":hc.TYPE,"@default":hc.IDENTIFIER}}],{include:"@whitespace"},[/[{}()[\]]/,"@brackets"],[/[<>](?!@symbols)/,"@brackets"],[/@symbols/,{cases:{"@operators":hc.OPERATOR,"@default":hc.IDENTIFIER}}],{include:"@number"},[/[;,.]/,hc.DELIMITER],[/'([^'\\]|\\.)*$/,`${hc.STRING}.invalid`],[/'/,hc.STRING,"@string"],{include:"@characters"}],pure:[[/(@package\*)/,[hc.PACKAGE]],[/(@package?)(@identifier)(@generics?)(\s*)(@multiplicity)/,[hc.PACKAGE,hc.TYPE,hc.GENERICS,hc.WHITESPACE,hc.MULTIPLICITY]],[/(@package)(@identifier)(@generics?)/,[hc.PACKAGE,hc.TYPE,hc.GENERICS]],[/([@^])(\s*)(@package?)(@identifier)(@generics?)(@multiplicity?)/,[`${hc.TYPE}.operator`,hc.WHITESPACE,hc.PACKAGE,hc.TYPE,hc.GENERICS,hc.MULTIPLICITY]],[/(\.\s*)(@identifier)/,[hc.DELIMITER,hc.PROPERTY]],[/(@identifier)(\s*=)/,[hc.PROPERTY,hc.OPERATOR]],[/(@identifier)(\.)(@identifier)/,[hc.TYPE,hc.OPERATOR,hc.PROPERTY]],[/(@identifier)(\s*:)/,[hc.PARAMETER,hc.OPERATOR]],[/(let)(\s+)(@identifier)(\s*=)/,[hc.KEYWORD,hc.WHITESPACE,hc.VARIABLE,hc.OPERATOR]],[/(\$@identifier)/,[`${hc.VARIABLE}.reference`]]],date:[[/(%latest)/,[`${hc.DATE}.latest`]],[/(@date)/,[hc.DATE]],[/(@time)/,[`${hc.DATE}.time`]]],color:[[/(#[0-9a-fA-F]{6})/,[hc.COLOR]]],number:[[/(@digits)[eE]([-+]?(@digits))?[fFdD]?/,`${hc.NUMBER}.float`],[/(@digits)\.(@digits)([eE][-+]?(@digits))?[fFdD]?/,`${hc.NUMBER}.float`],[/0[xX](@hexdigits)[Ll]?/,`${hc.NUMBER}.hex`],[/0(@octaldigits)[Ll]?/,`${hc.NUMBER}.octal`],[/0[bB](@binarydigits)[Ll]?/,`${hc.NUMBER}.binary`],[/(@digits)[fFdD]/,`${hc.NUMBER}.float`],[/(@digits)[lL]?/,hc.NUMBER]],whitespace:[[/[ \t\r\n]+/,hc.WHITESPACE],[/\/\*\*(?!\/)/,`${hc.COMMENT}.doc`,"@doc"],[/\/\*/,hc.COMMENT,"@comment"],[/\/\/.*$/,hc.COMMENT]],comment:[[/[^/*]+/,hc.COMMENT],[/\*\//,hc.COMMENT,"@pop"],[/[/*]/,hc.COMMENT]],doc:[[/[^/*]+/,`${hc.COMMENT}.doc`],[/\/\*/,`${hc.COMMENT}.doc.invalid`],[/\*\//,`${hc.COMMENT}.doc`,"@pop"],[/[/*]/,`${hc.COMMENT}.doc`]],string:[[/[^\\']+/,hc.STRING],[/@escapes/,`${hc.STRING}.escape`],[/\\./,`${hc.STRING}.escape.invalid`],[/'/,hc.STRING,"@pop"]],characters:[[/'[^\\']'/,hc.STRING],[/(')(@escapes)(')/,[hc.STRING,`${hc.STRING}.escape`,hc.STRING]],[/'/,`${hc.STRING}.invalid`]]}})),this.options?.onInitialized?.(this),this.initializeState.pass()}catch(e){w(e),this.alertService.alertError(e,{message:`Initialization Failure: ${e.message}`,text:"Resolve the issue and reload the engine."}),this.initializeState.fail()}}else this.logService.logDebug("DataCube state is re-initialized");var e,t}dispose(){this.view.dispose(),this.layoutService.dispose(),this.taskService.dispose()}reload(){this.view=new Jg(this),this.uuid=(0,i.A)()}}const hh=(0,vt.PA)((()=>{const e=bu(),t=e.view,n=e=>{t.dataCube.telemetryService.sendTelemetry(Ud.SELECT_ITEM_TITLE_BAR,{...t.engine.getDataFromSource(t.getInitialSource()),menuName:e})};return(0,Ft.useEffect)((()=>{e.view.initialize(e.specification).catch((t=>e.logService.logUnhandledError(t)))}),[e]),(0,E.jsxs)("div",{className:"data-cube relative flex h-full w-full flex-col bg-white",children:[(0,E.jsx)(Kp,{title:t.info.name,menuItems:[{label:Si.UNDO,action:()=>{e.view.snapshotService.undo(),n(Si.UNDO)},disabled:!e.view.snapshotService.canUndo},{label:Si.REDO,action:()=>{e.view.snapshotService.redo(),n(Si.REDO)},disabled:!e.view.snapshotService.canRedo},{label:Si.SETTINGS,action:()=>{e.settingService.display.open(),n(Si.SETTINGS)}}],getMenuItems:e.options?.getHeaderMenuItems,children:e.options?.innerHeaderRenderer?.({api:e.api})??null}),(0,E.jsx)(em,{view:t}),(0,E.jsx)(Tr,{layout:e.layoutService.manager}),(0,E.jsx)(Ar,{})]})})),fh=(0,vt.PA)((e=>{const{specification:t,engine:n,options:o}=e,r=(0,vt.iz)((()=>new gh(t,n,o)));return(0,Ft.useEffect)((()=>(r.initialize().catch((e=>r.logService.logUnhandledError(e))),()=>r.dispose())),[r]),r.initializeState.hasSucceeded?(0,E.jsx)(Cu,{value:r,children:(0,E.jsx)(hh,{},r.uuid)}):(0,E.jsx)(Zp,{title:wi,headerContent:r.options?.innerHeaderRenderer?.({api:r.api})??null,layoutManager:r.layoutService.manager,taskManager:r.taskService.manager,children:r.initializeState.hasFailed&&(0,E.jsx)(Jp,{message:"Initialization Failure",prompt:"Resolve the issue and reload."})})}));class Eh extends fc{runtime;mapping;timestamp;model;isLocal;isPersistenceSupported}const Ch="repl";class bh{query;runtime;model;mapping;timestamp;isLocal;isPersistenceSupported;columns=[];static serialization=new me((0,pe.PL)(bh,{_type:he(Ch),columns:(0,pe.p_)((0,pe.lS)()),isLocal:(0,pe.MY)(),isPersistenceSupported:(0,pe.MY)(),mapping:(0,pe.lq)((0,pe.MY)()),model:(0,pe.lq)((0,pe.lS)()),query:(0,pe.MY)(),runtime:(0,pe.MY)(),timestamp:(0,pe.MY)()}))}class vh{networkClient;constructor(e){this.networkClient=e}get baseUrl(){return D(this.networkClient.baseUrl,"REPL server client has not been configured properly")}get dataCube(){return`${this.baseUrl}/api/dataCube`}async getInfrastructureInfo(){return this.networkClient.get(`${this.dataCube}/infrastructureInfo`)}async getQueryTypeahead(e){return this.networkClient.post(`${this.dataCube}/typeahead`,e)}async parseValueSpecification(e){return this.networkClient.post(`${this.dataCube}/parseValueSpecification`,e)}async getValueSpecificationCode(e){return this.networkClient.post(`${this.dataCube}/getValueSpecificationCode`,e,{},{[Z.ACCEPT]:ee.TEXT_PLAIN})}async getBaseSpecification(){return this.networkClient.get(`${this.dataCube}/getBaseQuery`)}async getQueryRelationReturnType(e){return this.networkClient.post(`${this.dataCube}/getRelationReturnType`,e)}async getQueryCodeRelationReturnType(e){return this.networkClient.post(`${this.dataCube}/getRelationReturnType/code`,e)}async executeQuery(e){return this.networkClient.post(`${this.dataCube}/executeQuery`,e)}async publishQuery(e,t){return this.networkClient.post(`${t}`,e)}}class _h{query;runtime;mapping;model;static serialization=new me((0,pe.PL)(_h,{_type:he("freeformTDSExpression"),model:(0,pe.lS)(),query:(0,pe.MY)(),runtime:(0,pe.MY)(),mapping:(0,pe.lq)((0,pe.MY)())}))}class Th{runtime;model;functionPath;static serialization=new me((0,pe.PL)(Th,{_type:he("userDefinedFunction"),model:(0,pe.lS)(),runtime:(0,pe.lq)((0,pe.MY)()),functionPath:(0,pe.MY)()}))}class Nh{id;name;description;content;owner;lastUpdatedAt;createdAt;lastOpenAt;static serialization=new me((0,pe.PL)(Nh,{id:(0,pe.MY)(),lastUpdatedAt:(0,pe.lq)((0,pe.MY)()),createdAt:(0,pe.lq)((0,pe.MY)()),lastOpenAt:(0,pe.lq)((0,pe.MY)()),name:(0,pe.MY)(),description:(0,pe.lq)((0,pe.MY)()),content:(0,pe.lS)(),owner:(0,pe.lq)((0,pe.MY)())}));clone(){return Nh.serialization.fromJson(Nh.serialization.toJson(this))}}class Sh{id;name;description;owner;lastUpdatedAt;createdAt;lastOpenAt;static serialization=new me((0,pe.PL)(Sh,{id:(0,pe.MY)(),lastUpdatedAt:(0,pe.lq)((0,pe.MY)()),createdAt:(0,pe.lq)((0,pe.MY)()),lastOpenAt:(0,pe.lq)((0,pe.MY)()),name:(0,pe.MY)(),description:(0,pe.lq)((0,pe.MY)()),owner:(0,pe.lq)((0,pe.MY)())}))}const Ah=e=>{const{persistentDataCube:t}=e,n=Cf(),o=n.hostedApplicationBaseUrl?`${n.hostedApplicationBaseUrl}/${t.id}`:void 0;return(0,E.jsxs)("div",{className:"h-full w-full p-6",children:[(0,E.jsxs)("div",{className:"flex w-full overflow-auto",children:[(0,E.jsx)("div",{className:"mr-3",children:(0,E.jsx)(pr.AlertSuccess,{className:"flex-shrink-0 stroke-[0.5px] text-[40px] text-green-500"})}),(0,E.jsxs)("div",{children:[(0,E.jsx)("div",{className:"whitespace-break-spaces text-lg",children:"Published DataCube successfully!"}),o&&(0,E.jsx)("div",{className:"mt-1 whitespace-break-spaces text-neutral-500",children:"To view or share the published DataCube, use the link below."}),!o&&(0,E.jsx)("div",{className:"mt-1 whitespace-break-spaces text-neutral-500",children:"See the published DataCube ID below."})]})]}),o&&(0,E.jsxs)("div",{className:"mt-3 flex h-6 w-full",children:[(0,E.jsx)("div",{className:"flex h-full w-[calc(100%_-_20px)] items-center border border-r-0 border-neutral-400 px-1.5 font-bold text-sky-500 underline",children:(0,E.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"overflow-hidden overflow-ellipsis whitespace-nowrap",children:o})}),(0,E.jsx)("button",{className:"flex aspect-square h-full w-6 items-center justify-center border border-neutral-400 bg-neutral-300 hover:brightness-95",onClick:()=>{n.application.clipboardService.copyTextToClipboard(o).catch(n.application.alertUnhandledError)},title:"Copy Link",children:(0,E.jsx)(pr.Clipboard,{})})]}),!o&&(0,E.jsxs)("div",{className:"mt-3 flex h-6 w-full",children:[(0,E.jsx)("div",{className:"flex h-full w-[calc(100%_-_20px)] items-center border border-r-0 border-neutral-400 bg-neutral-200 px-1.5",children:(0,E.jsx)("div",{className:"overflow-hidden overflow-ellipsis whitespace-nowrap",children:t.id})}),(0,E.jsx)("button",{className:"flex aspect-square h-full w-6 items-center justify-center border border-neutral-400 bg-neutral-300 hover:brightness-95",onClick:()=>{n.application.clipboardService.copyTextToClipboard(t.id).catch(n.application.alertUnhandledError)},title:"Copy ID",children:(0,E.jsx)(pr.Clipboard,{})})]})]})};class yh{sourceId;startLine;startColumn;endLine;endColumn;constructor(e,t,n,o,r){this.sourceId=e,this.startLine=t,this.startColumn=n,this.endLine=o,this.endColumn=r}}var xh,Ih,wh,kh;!function(e){e.COMPILATION="COMPILATION",e.PARSER="PARSER"}(xh||(xh={}));class Rh{message="";errorType;sourceInformation;static serialization=new me((0,pe.PL)(Rh,{errorType:(0,pe.lq)((0,pe.MY)()),message:(0,pe.MY)(),sourceInformation:ge(Ka.schema)}))}!function(e){e.CLASS_BUILDER="classBuilder",e.TDS_BUILDER="tdsBuilder",e.JSON_BUILDER="json"}(Ih||(Ih={})),function(e){e.RELATIONAL="relational",e.RELATIONAL_EXECUTION_ACTIVITY="RelationalExecutionActivity",e.AGGREGATION_AWARE_ACTIVITY="aggregationAware"}(wh||(wh={})),function(e){e.CSV="CSV"}(kh||(kh={}));class Oh{_type;constructor(e){this._type=e}}class Lh{}class Fh extends Lh{sql;comment;constructor(e){super(),this.sql=e}}class Dh extends Lh{rewrittenQuery}class Ph extends Lh{values;constructor(e){super(),this.values=e}}class Bh{builder;activities}class jh extends Bh{values}class Mh extends Bh{value;constructor(e){super(),this.value=e}}class Uh{name;type;relationalType;doc}class Gh extends Oh{columns=[];constructor(){super(Ih.TDS_BUILDER)}}class Hh{values=[]}class Vh{columns=[];rows=[]}class Wh extends Bh{_UUID=(0,i.A)();builder=new Gh;result=new Vh}class zh extends Oh{_type=Ih.CLASS_BUILDER}class $h extends Bh{builder=new zh(Ih.CLASS_BUILDER);objects}class Yh{static builderSerialization=new me((0,pe.PL)(Yh,{_type:(0,pe.MY)()}))}class Xh{}class Kh extends Xh{sql;comment;static serialization=new me((0,pe.PL)(Kh,{sql:(0,pe.MY)(),comment:(0,pe.lq)((0,pe.MY)())}))}class qh extends Xh{rewrittenQuery;static serialization=new me((0,pe.PL)(qh,{rewrittenQuery:(0,pe.MY)()}))}class Jh{builder;activities}class Qh extends Xh{content;constructor(e){super(),this.content=e}}class Zh extends Jh{values;static serialization=new me((0,pe.PL)(Zh,{_type:(0,pe.MY)(),builder:ge(Yh.builderSerialization.schema),values:(0,pe.lS)()}))}class ef{name;doc;type;relationalType;static serialization=new me((0,pe.PL)(ef,{name:(0,pe.MY)(),doc:(0,pe.lq)((0,pe.MY)()),type:(0,pe.lq)((0,pe.MY)()),relationalType:(0,pe.lq)((0,pe.MY)())}))}class tf extends Yh{columns=[];static serialization=new me((0,pe.PL)(tf,{_type:(0,pe.MY)(),columns:(0,pe.p_)(ge(ef.serialization.schema))}))}function nf(e){switch(e._type){case wh.RELATIONAL:case wh.RELATIONAL_EXECUTION_ACTIVITY:return Kh.serialization.fromJson(e);case wh.AGGREGATION_AWARE_ACTIVITY:return qh.serialization.fromJson(e);default:return new Qh(e)}}class of extends Jh{result;static serialization=new me((0,pe.PL)(of,{builder:ge(tf.serialization.schema),activities:(0,pe.p_)((0,pe.Ie)((()=>pe._Z),nf)),result:(0,pe.lS)()}))}class rf extends Jh{objects;static serialization=new me((0,pe.PL)(rf,{builder:ge(Yh.builderSerialization.schema),activities:(0,pe.p_)((0,pe.Ie)((()=>pe._Z),nf)),objects:(0,pe.lS)()}))}class af extends Jh{value;constructor(e){super(),this.value=e}}class sf extends Jh{content}class lf extends Bh{content}const cf=e=>{if(e instanceof Kh){const t=new Fh(e.sql);return t.comment=e.comment,t}if(e instanceof qh){const t=new Dh;return t.rewrittenQuery=D(e.rewrittenQuery,"Aggregation aware execution activities 'rewritenQuery' field is missing"),t}if(e instanceof Qh)return new Ph(e);throw new I("Can't build execution activities",e)},uf=e=>{const t=new Uh;return t.name=D(e.name,"TDS column 'name' field is missing"),t.type=e.type,t.doc=e.doc,t.relationalType=e.relationalType,t},df=e=>{if(e instanceof sf){const t=new lf;return t.content=e.content,t}if(e instanceof rf)return(e=>{const t=new $h;return t.objects=D(e.objects,"Class execution result 'objects' field is missing"),t.activities=e.activities?.map(cf),t})(e);if(e instanceof of)return(e=>{const t=new Wh;return t.builder=(e=>{const t=new Gh;return t.columns=e.columns.map(uf),t})(D(e.builder,"TDS execution result 'builder' field is missing")),t.activities=e.activities?.map(cf),t.result.columns=e.result.columns,t.result.rows=e.result.rows.map((e=>{const t=new Hh;return t.values=e.values,t})),t})(e);if(e instanceof Zh)return(e=>{const t=new jh;return t.values=D(e.values,"JSON execution result 'values' field is missing"),t})(e);if(e instanceof af)return new Mh(e.value);throw new I("Can't build execution result",e)},pf=e=>{if(null===e||U(e)||G(e)||H(e))return new af(e);switch(e.builder?._type){case Ih.CLASS_BUILDER:return rf.serialization.fromJson(e);case Ih.TDS_BUILDER:return of.serialization.fromJson(e);case Ih.JSON_BUILDER:return Zh.serialization.fromJson(e);default:{const t=new sf;return t.content=e,t}}};class mf extends Md{_application;_client;constructor(e,t){super(),this._application=e,this._client=t}async processSource(e){if(e._type===Ch){const t=bh.serialization.fromJson(e),n=new Eh;n.query=await this.parseValueSpecification(t.query,!1);try{n.columns=(await this._getQueryRelationType(kl([],[n.query]))).columns}catch(e){throw w(e),new Error(`Can't get query result columns. Make sure the source query return a relation (i.e. typed TDS). Error: ${e.message}`)}return n.runtime=t.runtime,n.mapping=t.mapping,n.timestamp=t.timestamp,n.model=t.model,n.isLocal=t.isLocal,n.isPersistenceSupported=t.isPersistenceSupported,n}throw new I(`Can't process query source of type '${e._type}'.`)}getDataFromSource(e){return{}}finalizeTimingRecord(e,t){}async parseValueSpecification(e,t){return this.deserializeValueSpecification(await this._client.parseValueSpecification({code:e,returnSourceInformation:t}))}async getValueSpecificationCode(e,t){return this._client.getValueSpecificationCode({value:this.serializeValueSpecification(e),pretty:t})}async getQueryTypeahead(e,t,n){return this._client.getQueryTypeahead({code:e,baseQuery:this.serializeValueSpecification(t)})}async getQueryRelationReturnType(e,t){return this._getQueryRelationType(e)}async getQueryCodeRelationReturnType(e,t,n){try{return{columns:(0,pe.iu)(As,await this._client.getQueryCodeRelationReturnType({code:e,baseQuery:this.serializeValueSpecification(t)})).columns.map((e=>({name:e.name,type:fs(e.genericType)})))}}catch(e){if(w(e),e instanceof re&&e.response.status===J.BAD_REQUEST)throw(e=>{const t=new qm(e.message);return t.sourceInformation=e.sourceInformation?(n=e.sourceInformation,new yh(D(n.sourceId,"Source information 'sourceId' field is missing"),D(n.startLine,"Source information 'startLine' field is missing"),D(n.startColumn,"Source information 'startColumn' field is missing"),D(n.endLine,"Source information 'endLine' field is missing"),D(n.endColumn,"Source information 'endColumn' field is missing"))):void 0,t;var n})(Rh.serialization.fromJson(e.payload));throw e}}async executeQuery(e,t,n){const o=performance.now(),r=await this._client.executeQuery({query:this.serializeValueSpecification(e),debug:n?.debug}),i=performance.now();return{result:B(df(pf(JSON.parse(r.result))),Wh),executedQuery:r.executedQuery,executedSQL:r.executedSQL,executionTime:i-o}}buildExecutionContext(e){if(e instanceof Eh)return Ll(si.FROM,[e.mapping?Pl(e.mapping):void 0,Pl(e.runtime)].filter(L))}async _getQueryRelationType(e){return{columns:(0,pe.iu)(As,await this._client.getQueryRelationReturnType({query:this.serializeValueSpecification(e)})).columns.map((e=>({name:e.name,type:fs(e.genericType)})))}}logDebug(e,...t){this._application.logService.debug(c.create(de.DEBUG),e,...t)}debugProcess(e,...t){this._application.logService.debug(c.create(de.DEBUG),`\n------ START DEBUG PROCESS: ${e} ------`,...t.flatMap((([e,t])=>[`\n[${e.toUpperCase()}]:`,t])),`\n------- END DEBUG PROCESS: ${e} -------\n\n`)}logInfo(e,...t){this._application.logService.info(e,...t)}logWarning(e,...t){this._application.logService.warn(e,...t)}logError(e,...t){this._application.logService.error(e,...t)}logUnhandledError(e){this._application.logUnhandledError(e)}logIllegalStateError(e,t){this.logError(c.create(de.ILLEGAL_APPLICATION_STATE_OCCURRED),e,t)}getDocumentationEntry(e){return this._application.documentationService.getDocEntry(e)}openLink(e){this._application.navigationService.navigator.visitAddress(e)}sendTelemetry(e,t){}}class gf{_client;application;engine;taskService;layoutService;alertService;initializeState=we.create();publishState=we.create();source;gridClientLicense;queryServerBaseUrl;hostedApplicationBaseUrl;specification;constructor(e){(0,Ie.Gn)(this,{specification:Ie.sH,setSpecification:Ie.XI,source:Ie.sH,setSource:Ie.XI}),this.application=e,this._client=new vh(new se({baseUrl:e.config.useDynamicREPLServer?window.location.origin+D(e.config.baseAddress).replace("/repl/",""):e.config.replUrl})),this.engine=new mf(this.application,this._client),this.taskService=new Kg,this.layoutService=new vr,this.alertService=new Gu(new mh(this.engine),this.layoutService)}setSpecification(e){this.specification=e}setSource(e){this.source=e}async initialize(){const e=this.taskService.newTask("Initializing REPL...");this.initializeState.inProgress();try{const e=await this._client.getInfrastructureInfo();e.currentUser&&this.application.identityService.setCurrentUser(e.currentUser),this.application.telemetryService.setup(),this.queryServerBaseUrl=e.queryServerBaseUrl,this.hostedApplicationBaseUrl=e.hostedApplicationBaseUrl,this.gridClientLicense=e.gridClientLicense,this.setSpecification(Dd.serialization.fromJson(await this._client.getBaseSpecification())),this.initializeState.pass()}catch(e){w(e),this.application.logService.error(c.create(de.APPLICATION_LOAD__FAILURE),"Can't initialize REPL",e),this.alertService.alertError(e,{message:`Initialization Failure: ${e.message}`,text:"Resolve the issue and reload the engine."}),this.initializeState.fail()}finally{this.taskService.endTask(e)}}async publishDataCube(e){if(!this.queryServerBaseUrl||!(this.source instanceof Eh)||!this.source.isPersistenceSupported||!this.source.model||this.source.isLocal)return;this.publishState.inProgress();const t=this.taskService.newTask("Publishing DataCube...");try{const t=await e.generateSpecification(),n=new _h;n.query=bh.serialization.fromJson(t.source).query,n.runtime=this.source.runtime,n.model=this.source.model,t.source=_h.serialization.toJson(n);const o=new Nh;o.id=(0,i.A)(),o.name=t.configuration?.name??wi,o.content=Dd.serialization.toJson(t),o.owner=this.application.identityService.currentUser;const r=Nh.serialization.fromJson(await this._client.publishQuery(Nh.serialization.toJson(o),this.queryServerBaseUrl)),a=new gr(new mr("Publish Query",(()=>(0,E.jsx)(Ah,{persistentDataCube:r}))));a.configuration.window={width:420,height:150,minWidth:300,minHeight:100,center:!0},this.layoutService.newWindow(a)}catch(e){w(e),this.alertService.alertError(e,{message:"Persistence Failure: Can't publish query.",text:`Error: ${e.message}`})}finally{this.taskService.endTask(t),this.publishState.complete()}}}const hf=(0,vt.PA)((e=>{const{children:t,simple:n,enableTransitions:o}=e,r=D((0,Ft.useContext)(rr),"Can't find application platform in context"),i=Pt();return(0,Ft.useEffect)((()=>{i.initialize(r).catch(i.alertUnhandledError)}),[i,r]),i.initState.hasSucceeded?n?(0,E.jsx)(ao,{enableTransitions:o,children:t}):(0,E.jsx)(io,{enableTransitions:o,children:t}):(0,E.jsx)(E.Fragment,{})})),ff=(0,Ft.createContext)(void 0),Ef=({children:e})=>{const t=Pt(),n=(0,vt.iz)((()=>new gf(t)));return(0,E.jsx)(ff.Provider,{value:n,children:e})},Cf=()=>D((0,Ft.useContext)(ff),"Can't find Legend REPL base store in context"),bf=({children:e})=>(0,E.jsx)(hf,{simple:!0,children:(0,E.jsx)(Ef,{children:e})}),vf=(0,vt.PA)((e=>{const{api:t}=e,n=Cf();if(!n.source||!n.queryServerBaseUrl)return null;const o=n.source instanceof Eh&&n.source.isPersistenceSupported&&!n.source.isLocal;return(0,E.jsx)("div",{className:"flex h-full items-center",children:(0,E.jsx)(Tu,{compact:!0,disabled:!o||n.publishState.isInProgress,onClick:()=>{n.publishDataCube(t).catch((e=>n.alertService.alertUnhandledError(e)))},children:"Publish"})})}));var _f;!function(e){e.DATA_CUBE="data-cube"}(_f||(_f={}));const Tf=(0,vt.PA)((e=>{const{specification:t}=e,n=Cf(),o=n.application;return(0,Ft.useEffect)((()=>(o.navigationService.navigator.blockNavigation([()=>!0],void 0,(()=>{o.logService.warn(c.create(de.NAVIGATION_BLOCKED),"Navigation from the application is blocked")})),()=>{o.navigationService.navigator.unblockNavigation()})),[o]),(0,E.jsx)(fh,{specification:t,engine:n.engine,options:{gridClientLicense:n.gridClientLicense,layoutManager:n.layoutService.manager,taskManager:n.taskService.manager,onNameChanged(e){const t=e.source instanceof Eh?e.source.timestamp:void 0;o.layoutService.setWindowTitle(`⊞ ${name}${t?` - ${(0,Kn.GP)(new Date(t),"HH:mm:ss EEE MMM dd yyyy")}`:""}`)},onViewInitialized(e){n.setSource(e.source)},innerHeaderRenderer:e=>(0,E.jsx)(vf,{api:e.api}),getHeaderMenuItems:()=>[{label:"See Documentation",action:()=>{o.documentationService.url&&o.navigationService.navigator.visitAddress(o.documentationService.url)},disabled:!o.documentationService.url}],settingsData:{values:o.settingService.getObjectValue(_f.DATA_CUBE)},onSettingsChanged(e){o.settingService.persistValue(_f.DATA_CUBE,e.values)}}})})),Nf=Object.freeze({DATA_CUBE:"/dataCube"}),Sf=(0,vt.PA)((()=>{const e=Cf();return(0,Ft.useEffect)((()=>{e.initialize().catch((t=>e.application.alertUnhandledError(t)))}),[e]),e.initializeState.hasSucceeded?(0,E.jsx)("div",{className:"h-full",children:e.specification&&(0,E.jsx)(Zo.BV,{children:(0,E.jsx)(Zo.qh,{path:Nf.DATA_CUBE,element:(0,E.jsx)(Tf,{specification:e.specification})})})}):(0,E.jsxs)(Zp,{title:wi,layoutManager:e.layoutService.manager,taskManager:e.taskService.manager,children:[e.initializeState.isInProgress&&(0,E.jsx)("div",{className:"h-full w-full p-2",children:(0,E.jsx)("div",{children:"Initializing..."})}),e.initializeState.hasFailed&&(0,E.jsx)(Jp,{message:"Initialization Failure",prompt:"Resolve the issue and reload."})]})})),Af=e=>{const{baseUrl:t}=e;return(0,E.jsx)(ar,{baseUrl:t,children:(0,E.jsx)(bf,{children:(0,E.jsx)(Sf,{})})})};class yf extends Wo{static create(){const e=new yf(new $o);return e.withBasePlugins([new Ko]),e}async configureApplication(e){return new Jo(e)}async loadApplication(e){(0,C.createRoot)((()=>{let e=document.getElementsByTagName(zo).length?document.getElementsByTagName(zo)[0]:void 0;return e||(e=document.createElement(zo),document.body.appendChild(e)),e.setAttribute("style","height: 100%; width: 100%; display: block"),e})()).render((0,E.jsx)(Bt,{store:e,children:(0,E.jsx)(Af,{baseUrl:this.baseAddress})}))}}class xf{static getPresetCollection(){return[]}static getPluginCollection(){return[new f]}static run(e){yf.create().setup({baseAddress:e}).withPresets(xf.getPresetCollection()).withPlugins(xf.getPluginCollection()).start().catch((e=>{throw e}))}}const If=new URL("./",window.location.href).pathname;xf.run(If)},98933:(e,t,n)=>{var o={"./simpleWorker":99246,"./simpleWorker.js":99246};function r(e){return Promise.resolve().then((()=>{if(!n.o(o,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return n(o[e])}))}r.keys=()=>Object.keys(o),r.id=98933,e.exports=r}},a={};function s(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={id:e,loaded:!1,exports:{}};return i[e].call(n.exports,n,n.exports,s),n.loaded=!0,n.exports}s.m=i,s.amdD=function(){throw new Error("define cannot be used indirect")},s.amdO={},e=[],s.O=(t,n,o,r)=>{if(!n){var i=1/0;for(u=0;u<e.length;u++){for(var[n,o,r]=e[u],a=!0,l=0;l<n.length;l++)(!1&r||i>=r)&&Object.keys(s.O).every((e=>s.O[e](n[l])))?n.splice(l--,1):(a=!1,r<i&&(i=r));if(a){e.splice(u--,1);var c=o();void 0!==c&&(t=c)}}return t}r=r||0;for(var u=e.length;u>0&&e[u-1][2]>r;u--)e[u]=e[u-1];e[u]=[n,o,r]},s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(e,o){if(1&o&&(e=this(e)),8&o)return e;if("object"==typeof e&&e){if(4&o&&e.__esModule)return e;if(16&o&&"function"==typeof e.then)return e}var r=Object.create(null);s.r(r);var i={};t=t||[null,n({}),n([]),n(n)];for(var a=2&o&&e;"object"==typeof a&&!~t.indexOf(a);a=n(a))Object.getOwnPropertyNames(a).forEach((t=>i[t]=()=>e[t]));return i.default=()=>e,s.d(r,i),r},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((t,n)=>(s.f[n](e,t),t)),[])),s.u=e=>"static/"+e+".a0ce728d.js",s.miniCssF=e=>{},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o={},r="@finos/legend-application-repl-deployment:",s.l=(e,t,n,i)=>{if(o[e])o[e].push(t);else{var a,l;if(void 0!==n)for(var c=document.getElementsByTagName("script"),u=0;u<c.length;u++){var d=c[u];if(d.getAttribute("src")==e||d.getAttribute("data-webpack")==r+n){a=d;break}}a||(l=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",r+n),a.src=e),o[e]=[t];var p=(t,n)=>{a.onerror=a.onload=null,clearTimeout(m);var r=o[e];if(delete o[e],a.parentNode&&a.parentNode.removeChild(a),r&&r.forEach((e=>e(n))),t)return t(n)},m=setTimeout(p.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=p.bind(null,a.onerror),a.onload=p.bind(null,a.onload),l&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),s.p="./",(()=>{var e={57:0};s.f.j=(t,n)=>{var o=s.o(e,t)?e[t]:void 0;if(0!==o)if(o)n.push(o[2]);else{var r=new Promise(((n,r)=>o=e[t]=[n,r]));n.push(o[2]=r);var i=s.p+s.u(t),a=new Error;s.l(i,(n=>{if(s.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var r=n&&("load"===n.type?"missing":n.type),i=n&&n.target&&n.target.src;a.message="Loading chunk "+t+" failed.\n("+r+": "+i+")",a.name="ChunkLoadError",a.type=r,a.request=i,o[1](a)}}),"chunk-"+t,t)}},s.O.j=t=>0===e[t];var t=(t,n)=>{var o,r,[i,a,l]=n,c=0;if(i.some((t=>0!==e[t]))){for(o in a)s.o(a,o)&&(s.m[o]=a[o]);if(l)var u=l(s)}for(t&&t(n);c<i.length;c++)r=i[c],s.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return s.O(u)},n=globalThis.webpackChunk_finos_legend_application_repl_deployment=globalThis.webpackChunk_finos_legend_application_repl_deployment||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})(),s.nc=void 0;var l=s.O(void 0,[121],(()=>s(86098)));l=s.O(l)})();
45
- //# sourceMappingURL=index.97e084e0.js.map
44
+ `})})),Gp=(0,vt.PA)((e=>{const{view:t}=e,n=t.grid.scrollHintText,o=document.querySelector(".data-cube-grid .ag-side-bar"),r=document.querySelector(".data-cube-grid .ag-body-vertical-scroll");return(0,E.jsxs)("div",{className:"absolute -top-10 flex items-center rounded-sm border border-neutral-300 bg-neutral-100 p-1 pr-2 text-neutral-500 shadow-sm",style:{right:(null!==o?o.getBoundingClientRect().width+6:10)+(null!==r?r.getBoundingClientRect().width:0)},children:[(0,E.jsx)(pr.TableScroll,{className:"text-lg"}),(0,E.jsx)("div",{className:"ml-1 font-mono text-sm",children:n??""})]})})),Hp=(0,vt.PA)((e=>{const{view:t}=e,n=bu(),o=t.grid;return(0,E.jsxs)("div",{className:"relative flex h-5 w-full select-none justify-between border-b border-neutral-200 bg-neutral-100",children:[Boolean(o.scrollHintText)&&(0,E.jsx)(Gp,{view:t}),(0,E.jsx)("div",{}),(0,E.jsxs)("div",{className:"flex h-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full items-center px-2 font-mono text-sm text-neutral-500",children:o.clientDataSource.rowCount?`Rows: ${o.clientDataSource.rowCount}`:""}),void 0!==o.rowLimit&&o.configuration.showWarningForTruncatedResult&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsxs)("div",{className:"flex h-full items-center px-2 text-orange-500",children:[(0,E.jsx)(pr.Warning,{className:"stroke-[3px]"}),(0,E.jsx)("div",{className:"ml-1 text-sm font-semibold",children:`Results truncated to fit within row limit (${o.rowLimit})`})]})]}),(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsxs)("button",{className:"flex h-full items-center p-2",onClick:()=>{o.setPaginationEnabled(!o.isPaginationEnabled)},children:[(0,E.jsx)(kr.A,{checked:o.isPaginationEnabled,classes:{root:"p-0 w-6 h-5 flex items-center",input:"w-2",checked:"!translate-x-2 ease-in-out duration-100 transition",thumb:Mn("w-2 h-2",{"bg-sky-600":o.isPaginationEnabled,"bg-neutral-500":!o.isPaginationEnabled}),switchBase:"p-0.5 mt-1 translate-x-0 ease-in-out duration-100 transition",track:Mn("h-3 w-5 border",{"!bg-sky-100 border-sky-600":o.isPaginationEnabled,"!bg-neutral-100 border-neutral-500":!o.isPaginationEnabled})},disableRipple:!0,disableFocusRipple:!0}),(0,E.jsx)("div",{className:Mn("text-sm",{"text-sky-600":o.isPaginationEnabled,"text-neutral-500":!o.isPaginationEnabled}),children:"Pagination"})]}),t.dataCube.options?.enableCache&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsxs)("button",{className:"flex h-full items-center p-2",onClick:()=>{o.setCachingEnabled(!o.isCachingEnabled).catch((e=>n.alertService.alertUnhandledError(e)))},children:[(0,E.jsx)(kr.A,{checked:o.isCachingEnabled,classes:{root:"p-0 w-6 h-5 flex items-center",input:"w-2",checked:"!translate-x-2 ease-in-out duration-100 transition",thumb:Mn("w-2 h-2",{"bg-sky-600":o.isCachingEnabled,"bg-neutral-500":!o.isCachingEnabled}),switchBase:"p-0.5 mt-1 translate-x-0 ease-in-out duration-100 transition",track:Mn("h-3 w-5 border",{"!bg-sky-100 border-sky-600":o.isCachingEnabled,"!bg-neutral-100 border-neutral-500":!o.isCachingEnabled})},disableRipple:!0,disableFocusRipple:!0,disabled:t.processCacheState.isInProgress,title:t.processCacheState.isInProgress?"Processing cache...":""}),(0,E.jsxs)("div",{className:Mn("flex items-center text-sm",{"text-sky-600":o.isCachingEnabled,"text-neutral-500":!o.isCachingEnabled}),children:["Cache ",(0,E.jsx)(vu,{})]})]})]})]})]})})),Vp=(0,vt.PA)((e=>{const{view:t}=e,n=t.grid;return(0,E.jsx)("div",{className:"relative h-[calc(100%_-_20px)] w-full",children:(0,E.jsx)(Ir.W6,{theme:"legacy",className:"data-cube-grid ag-theme-quartz",rowModelType:"serverSide",serverSideDatasource:n.clientDataSource,context:{view:t},onGridReady:e=>{n.configureClient(e.api).catch((e=>t.alertService.alertUnhandledError(e)))},modules:[yr.JKr,xr.fKx],...Qd(t)})})})),Wp=(0,vt.PA)((e=>{const{view:t}=e,n=t.grid.configuration;return(0,E.jsxs)("div",{className:"h-[calc(100%_-_48px)] w-full",children:[(0,E.jsx)(Up,{configuration:n}),(0,E.jsx)(Vp,{view:t}),(0,E.jsx)(Hp,{view:t})]})})),zp=(0,vt.PA)((e=>{const{view:t}=e;switch(t.info.configuration.gridMode){case Ti.MULTIDIMENSIONAL:return(0,E.jsx)(Bp,{view:t});case Ti.STANDARD:return(0,E.jsx)(Wp,{view:t});default:return(0,E.jsx)("div",{className:"border-t-1 border-b-1 h-[calc(100%_-_48px)] w-full border border-neutral-200 bg-neutral-50"})}}));var $p=n(16481);const Yp=(0,vt.PA)((e=>{const{view:t,taskManager:n}=e,o=t?.taskService.tasks??n?.tasks;return(0,E.jsxs)("div",{className:"flex h-5 w-full justify-between bg-neutral-100",children:[(0,E.jsxs)("div",{className:"flex",children:[(0,E.jsxs)("button",{className:"flex items-center px-2 text-sky-600 hover:text-sky-700 disabled:text-neutral-400",onClick:()=>{t?.editor.display.open(),t?.dataCube.telemetryService.sendTelemetry(Ud.OPEN_EDITOR_PROPERTIES,{...t.engine.getDataFromSource(t.getInitialSource()),openedFrom:Ai.STATUS_BAR})},disabled:!t,children:[(0,E.jsx)(pr.Settings,{className:"text-xl"}),(0,E.jsx)("div",{className:"pl-0.5 underline",children:"Properties"})]}),(0,E.jsx)("div",{className:"flex",children:(0,E.jsxs)("button",{className:"flex items-center text-sky-600 hover:text-sky-700 disabled:text-neutral-400",onClick:()=>{t?.filter.display.open(),t?.dataCube.telemetryService.sendTelemetry(Ud.OPEN_EDITOR_FILTER,{...t.engine.getDataFromSource(t.getInitialSource()),openedFrom:Ai.STATUS_BAR})},disabled:!t||ea(t.info.configuration.gridMode),children:[(0,E.jsx)(pr.TableFilter,{className:"text-lg"}),(0,E.jsx)("div",{className:"pl-0.5 underline",children:"Filter"})]})})]}),(0,E.jsx)("div",{className:"flex items-center px-2",children:(0,E.jsx)("div",{className:"flex h-3.5 w-48 border-[0.5px] border-neutral-300",title:void 0!==o&&o.length>0?o.length>1?o.map(((e,t)=>`Task ${t+1}/${o.length}: ${e.description}`)).join("\n"):N(o,0).description:void 0,children:void 0!==o&&o.length>0&&(0,E.jsx)($p.A,{classes:{root:"h-3.5 w-full bg-transparent",bar1Indeterminate:"bg-green-500",bar2Indeterminate:"bg-green-500"},variant:"indeterminate"})})})]})}));var Xp;!function(e){e.SEPARATOR="separator"}(Xp||(Xp={}));const Kp=(0,vt.PA)((e=>{const{children:t,title:n,menuItems:o,getMenuItems:r}=e,[i,a,s]=pu(),[l,c]=(0,Ft.useState)([...o??[]]);return(0,E.jsxs)("div",{className:"flex h-7 w-full bg-neutral-100",children:[(0,E.jsxs)("div",{className:"flex w-fit max-w-80 items-center pl-1 pr-2 text-lg font-medium",children:[(0,E.jsx)(pr.Cube,{className:"mr-1 h-4 w-4 flex-shrink-0"}),(0,E.jsx)("div",{className:"truncate",children:n})]}),(0,E.jsxs)("div",{className:"flex w-full flex-auto",children:[t,(0,E.jsx)("button",{className:"flex aspect-square h-full flex-shrink-0 items-center justify-center text-lg disabled:text-neutral-400",onClick:e=>{const t=r?.()??[];t.length&&t.unshift(Xp.SEPARATOR),c([...o??[],...t]),i(e)},disabled:!o?.length,children:(0,E.jsx)(pr.Menu,{})}),(0,E.jsx)(mu,{...s,menuProps:{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},classes:{paper:"rounded-none mt-[1px]",list:"w-40 p-0 rounded-none border border-neutral-400 bg-white overflow-y-auto py-0.5"}},children:l.map(((e,t)=>V(e)?(0,E.jsx)(gu,{className:"flex h-[22px] w-full items-center px-2.5 text-base hover:bg-neutral-100 focus:bg-neutral-100",onClick:()=>{e.action(),a()},disabled:Boolean(e.disabled),children:e.label},t):e===Xp.SEPARATOR?(0,E.jsx)("div",{className:"my-1 h-[1px] w-full bg-neutral-200"},t):null))})]})]})}));var qp;!function(e){e.PLACEHOLDER="legend-data-cube__placeholder"}(qp||(qp={}));const Jp=e=>{const{message:t,prompt:n}=e;return(0,E.jsxs)("div",{className:"flex h-full w-full overflow-auto p-5",children:[(0,E.jsx)("div",{className:"mr-3",children:(0,E.jsx)(pr.AlertError,{className:"flex-shrink-0 stroke-[0.5px] text-[40px] text-red-500"})}),(0,E.jsxs)("div",{children:[(0,E.jsx)("div",{className:"whitespace-break-spaces text-lg",children:t}),(0,E.jsx)("div",{className:"mt-1 whitespace-break-spaces text-neutral-500",children:n})]})]})},Qp=(0,vt.PA)((e=>{const{children:t,taskManager:n}=e;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"h-[calc(100%_-_48px)] w-full border border-x-0 border-neutral-200 bg-neutral-50",children:t??null}),(0,E.jsx)(Yp,{taskManager:n})]})})),Zp=(0,vt.PA)((e=>{const{children:t,title:n,menuItems:o,headerContent:r,layoutManager:i,taskManager:a}=e;return(0,E.jsxs)("div",{className:"data-cube relative flex h-full w-full flex-col bg-white","data-testid":qp.PLACEHOLDER,children:[(0,E.jsx)(Kp,{title:n,menuItems:o,children:r??null}),(0,E.jsx)(Qp,{taskManager:a,children:t}),i?(0,E.jsx)(Tr,{layout:i}):null,(0,E.jsx)(Ar,{})]})})),em=(0,vt.PA)((e=>{const{view:t}=e;return(0,Ft.useEffect)((()=>()=>t.dispose()),[t]),t.initializeState.hasFailed?(0,E.jsx)(Qp,{children:(0,E.jsx)(Jp,{message:"Initialization Failure",prompt:"Resolve the issue and reload."})}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(zp,{view:t}),(0,E.jsx)(Yp,{view:t})]})}));class tm{_startTime=Date.now();_time=this._startTime;_records=new Map;record(e){const t=Date.now(),n=t-this._time;this._time=t,e&&this._records.set(e,n)}getRecord(e){return D(this._records.get(e),`Can't find record for event '${e}'`)}get startTime(){return this._startTime}get elapsed(){return Date.now()-this._startTime}get records(){return new Map(this._records)}}var nm=n(61005);class om{_engine;_settingService;_snapshotService;_latestSnapshot;constructor(e,t,n){this._engine=e,this._settingService=t,this._snapshotService=n}getLatestSnapshot(){return this._latestSnapshot}async receiveSnapshot(e){const t=this._latestSnapshot;this._latestSnapshot=e,await this.applySnapshot(e.INTERNAL__fullClone(),t)}publishSnapshot(e){const t=this._latestSnapshot;this._latestSnapshot=e,this._settingService.getBooleanValue(Uu.DEBUGGER__ENABLE_DEBUG_MODE)&&this._engine.debugProcess("New Snapshot",["Publisher",this.getSnapshotSubscriberName()],["Snapshot",e.serialize()],["Previous Snapshot",t?.serialize()],["Diff",(0,nm.A)(t??{},e)]),this._snapshotService.broadcastSnapshot(e)}}class rm{_logService;_settingService;_subscribers=[];_snapshots=[];_pointer=-1;_historySize;constructor(e,t){(0,Ie.Gn)(this,{_snapshots:Ie.sH.struct,_pointer:Ie.sH,canUndo:Ie.EW,canRedo:Ie.EW,undo:Ie.XI,redo:Ie.XI,adjustHistorySize:Ie.XI,broadcastSnapshot:Ie.XI}),this._logService=e,this._settingService=t,this._historySize=Math.max(this._settingService.getNumericValue(Uu.EDITOR__MAX_HISTORY_STACK_SIZE),10)}registerSubscriber(e){if(this._subscribers.find((t=>t.getSnapshotSubscriberName()===e.getSnapshotSubscriberName())))throw new x(`Subscriber with name '${e.getSnapshotSubscriberName()}' already exists`);this._subscribers.push(e)}propagateSnapshot(e){this._subscribers.forEach((t=>{const n=t.getLatestSnapshot();n?.uuid!==e.uuid&&t.receiveSnapshot(e).catch((e=>{w(e),this._logService.logIllegalStateError("Error occured while subscribers receiving and applying new snapshot should be handled gracefully",e)}))}))}getCurrentSnapshot(){return N(this._snapshots,this._pointer)}getHistory(e){return e?.full?[...this._snapshots]:this._snapshots.slice(0,this._pointer+1)}get canUndo(){return this._pointer>0}get canRedo(){return this._pointer<this._snapshots.length-1}undo(){this._pointer=Math.max(this._pointer-1,0),this.propagateSnapshot(this.getCurrentSnapshot())}redo(){this._pointer=Math.min(this._pointer+1,this._snapshots.length-1),this.propagateSnapshot(this.getCurrentSnapshot())}adjustHistorySize(e){let t=e;e<=10&&(this._logService.logIllegalStateError(`Can't adjust history size to ${e}: value must be greator than 10`),t=Math.max(e,10));const n=this.getHistory();n.length>t?(this._snapshots=n.slice(-t),this._pointer=Math.min(Math.max(this._pointer-(n.length-t),0),n.length-1)):(this._snapshots=n,this._pointer=n.length-1),this._historySize=t}broadcastSnapshot(e){e.isFinalized()?(this._snapshots=[...this._snapshots.slice(0,this._pointer+1),e],this._pointer+=1,this.adjustHistorySize(this._historySize),this.propagateSnapshot(e)):this._logService.logIllegalStateError("Snapshot must be finalized before broadcasting")}}var im=n(43322);class am{uuid=(0,i.A)();parent;not=!1;constructor(e,t){(0,Ie.Gn)(this,{parent:Ie.sH,setParent:Ie.XI,not:Ie.sH,setNot:Ie.XI}),this.parent=e,this.not=Boolean(t)}setNot(e){this.not=e}setParent(e){this.parent=e}}class sm extends am{column;operation;value;constructor(e,t,n,o,r){super(e,r),(0,Ie.Gn)(this,{column:Ie.sH,setColumn:Ie.XI,operation:Ie.sH,setOperation:Ie.XI,value:Ie.sH.ref,setValue:Ie.XI,updateValue:Ie.XI}),this.column=t,this.operation=n,this.setValue(o)}setColumn(e){this.column=e}setOperation(e){this.operation=e}setValue(e){this.value=(0,Ie.AT)(e)?e:(0,Ie.Gn)(e,{value:Ie.sH})}updateValue(e){this.value.value=e}}class lm extends am{children=[];operation=Ci.AND;constructor(e,t,n){super(e,n),(0,Ie.Gn)(this,{children:Ie.sH,removeChild:Ie.XI,addChild:Ie.XI,operation:Ie.sH,setOperation:Ie.XI}),this.operation=t}setOperation(e){this.operation=e}removeChild(e){S(this.children,e)&&e.setParent(void 0)}addChild(e,t){this.children.includes(e)||(void 0!==t?(t=Math.max(0,Math.min(t,this.children.length)),this.children.splice(t,0,e)):this.children.push(e),e.setParent(this))}}function cm(e){return{groupOperator:e.operation,not:e.not,conditions:e.children.map((e=>{if(e instanceof sm)return{name:e.column.name,type:e.column.type,operator:e.operation.operator,value:(0,im.A)(e.value),not:e.not};if(e instanceof lm)return cm(e);throw new x("Unknown filter node")}))}}function um(e,t,n,o){const r=new lm(t,e.groupOperator===Ci.AND?Ci.AND:Ci.OR,e.not);return e.conditions.forEach((e=>{let t;t="groupOperator"in e?um(e,r,n,o):new sm(r,{name:e.name,type:e.type},o(e.operator),e.value,e.not),r.addChild(t),n.set(t.uuid,t)})),n.set(r.uuid,r),r}class dm{name;type;constructor(e,t){this.name=e,this.type=t}}class pm{_editor;selectedColumns=[];availableColumnsSearchText="";selectedColumnsSearchText="";onChange;constructor(e,t){(0,Ie.Gn)(this,{availableColumns:Ie.EW,availableColumnsForDisplay:Ie.EW,selectedColumnsForDisplay:Ie.EW,selectedColumns:Ie.sH,setSelectedColumns:Ie.XI,availableColumnsSearchText:Ie.sH,setAvailableColumnsSearchText:Ie.XI,selectedColumnsSearchText:Ie.sH,setSelectedColumnsSearchText:Ie.XI}),this._editor=e,this.onChange=t?.onChange}get availableColumnsForDisplay(){return this.availableColumns.filter((e=>!ra(this.selectedColumns,e.name))).sort(aa)}get selectedColumnsForDisplay(){return this.selectedColumns}setSelectedColumns(e){this.selectedColumns=e.map((e=>this.cloneColumn(e))),this.onChange?.(this)}setAvailableColumnsSearchText(e){this.availableColumnsSearchText=e}setSelectedColumnsSearchText(e){this.selectedColumnsSearchText=e}getColumn(e){return D(ra(this.availableColumns,e),`Can't find column '${e}'`)}}class mm extends dm{onChange;direction;constructor(e,t,n,o){super(e,t),(0,Ie.Gn)(this,{direction:Ie.sH,setDirection:Ie.XI}),this.direction=n,this.onChange=o}setDirection(e){this.direction=e,this.onChange?.()}}class gm extends pm{cloneColumn(e){return new mm(e.name,e.type,e.direction)}get availableColumns(){return(0,nt.A)([...this._editor.horizontalPivots.selector.selectedColumns.length?[...this._editor.horizontalPivots.pivotResultColumns,...[...this._editor.columns.selector.selectedColumns,...this._editor.verticalPivots.selector.selectedColumns].filter((e=>this._editor.columnProperties.getColumnConfiguration(e.name).kind===mi.DIMENSION&&!ra(this._editor.horizontalPivots.selector.selectedColumns,e.name)))]:[...this._editor.columns.selector.selectedColumns,...this._editor.verticalPivots.selector.selectedColumns],...this._editor.groupExtendColumns],(e=>e.name)).map((e=>new mm(e.name,e.type,bi.ASCENDING)))}}class hm{selector;constructor(e){this.selector=new gm(e)}adaptPropagatedChanges(){this.selector.setSelectedColumns(this.selector.selectedColumns.filter((e=>ra(this.selector.availableColumns,e.name))))}applySnaphot(e,t){this.selector.setSelectedColumns(e.data.sortColumns.map((e=>{const t=this.selector.getColumn(e.name);return new mm(t.name,t.type,e.direction)})))}buildSnapshot(e,t){e.data.sortColumns=this.selector.selectedColumns.map((e=>({...ia(e),direction:e.direction})))}}class fm extends sa{dataType;aggregateOperation;static create(e,t,n){const o=Object.assign(new fm("",""),sa.serialization.fromJson(e));return o.dataType=Qi(o.type),o.aggregateOperation=Ji(o.aggregateOperator,n),(0,Ie.Gn)(o,{kind:Ie.sH,setKind:Ie.XI,displayName:Ie.sH,setDisplayName:Ie.XI,decimals:Ie.sH,setDecimals:Ie.XI,displayCommas:Ie.sH,setDisplayCommas:Ie.XI,negativeNumberInParens:Ie.sH,setNegativeNumberInParens:Ie.XI,numberScale:Ie.sH,setNumberScale:Ie.XI,missingValueDisplayText:Ie.sH,setMissingValueDisplayText:Ie.XI,unit:Ie.sH,setUnit:Ie.XI,fontFamily:Ie.sH,setFontFamily:Ie.XI,fontSize:Ie.sH,setFontSize:Ie.XI,fontBold:Ie.sH,setFontBold:Ie.XI,fontItalic:Ie.sH,setFontItalic:Ie.XI,fontUnderline:Ie.sH,setFontUnderline:Ie.XI,fontStrikethrough:Ie.sH,setFontStrikethrough:Ie.XI,fontCase:Ie.sH,setFontCase:Ie.XI,textAlign:Ie.sH,setTextAlign:Ie.XI,normalForegroundColor:Ie.sH,setNormalForegroundColor:Ie.XI,negativeForegroundColor:Ie.sH,setNegativeForegroundColor:Ie.XI,zeroForegroundColor:Ie.sH,setZeroForegroundColor:Ie.XI,errorForegroundColor:Ie.sH,setErrorForegroundColor:Ie.XI,normalBackgroundColor:Ie.sH,setNormalBackgroundColor:Ie.XI,negativeBackgroundColor:Ie.sH,setNegativeBackgroundColor:Ie.XI,zeroBackgroundColor:Ie.sH,setZeroBackgroundColor:Ie.XI,errorBackgroundColor:Ie.sH,setErrorBackgroundColor:Ie.XI,isSelected:Ie.sH,setIsSelected:Ie.XI,hideFromView:Ie.sH,setHideFromView:Ie.XI,blur:Ie.sH,setBlur:Ie.XI,fixedWidth:Ie.sH,setFixedWidth:Ie.XI,minWidth:Ie.sH,setMinWidth:Ie.XI,maxWidth:Ie.sH,setMaxWidth:Ie.XI,pinned:Ie.sH,setPinned:Ie.XI,displayAsLink:Ie.sH,setDisplayAsLink:Ie.XI,linkLabelParameter:Ie.sH,setLinkLabelParameter:Ie.XI,isUsingDefaultStyling:Ie.EW,useDefaultStyling:Ie.XI,aggregateOperator:Ie.sH,aggregateOperation:Ie.sH,setAggregateOperation:Ie.XI,aggregationParameters:Ie.sH,setAggregationParameters:Ie.XI,excludedFromPivot:Ie.sH,setExcludedFromPivot:Ie.XI,pivotSortDirection:Ie.sH,setPivotSortDirection:Ie.XI,pivotStatisticColumnFunction:Ie.sH,setPivotStatisticColumnFunction:Ie.XI}),o}get isUsingDefaultStyling(){return void 0===this.fontFamily&&void 0===this.fontSize&&void 0===this.fontBold&&void 0===this.fontItalic&&void 0===this.fontUnderline&&void 0===this.fontStrikethrough&&void 0===this.textAlign&&void 0===this.normalForegroundColor&&void 0===this.negativeForegroundColor&&void 0===this.zeroForegroundColor&&void 0===this.errorForegroundColor&&void 0===this.normalBackgroundColor&&void 0===this.negativeBackgroundColor&&void 0===this.zeroBackgroundColor&&void 0===this.errorBackgroundColor}useDefaultStyling(){this.fontFamily=void 0,this.fontSize=void 0,this.fontBold=void 0,this.fontItalic=void 0,this.fontUnderline=void 0,this.fontStrikethrough=void 0,this.textAlign=void 0,this.normalForegroundColor=void 0,this.negativeForegroundColor=void 0,this.zeroForegroundColor=void 0,this.errorForegroundColor=void 0,this.normalBackgroundColor=void 0,this.negativeBackgroundColor=void 0,this.zeroBackgroundColor=void 0,this.errorBackgroundColor=void 0}setKind(e){this.kind=e}setDisplayName(e){this.displayName=e}setDecimals(e){this.decimals=e}setDisplayCommas(e){this.displayCommas=e}setNegativeNumberInParens(e){this.negativeNumberInParens=e}setNumberScale(e){this.numberScale=e}setMissingValueDisplayText(e){this.missingValueDisplayText=e}setUnit(e){this.unit=e}setFontFamily(e){this.fontFamily=e}setFontSize(e){this.fontSize=e}setFontBold(e){this.fontBold=e}setFontItalic(e){this.fontItalic=e}setFontUnderline(e){this.fontUnderline=e}setFontStrikethrough(e){this.fontStrikethrough=e}setFontCase(e){this.fontCase=e}setTextAlign(e){this.textAlign=e}setNormalForegroundColor(e){this.normalForegroundColor=e}setNegativeForegroundColor(e){this.negativeForegroundColor=e}setZeroForegroundColor(e){this.zeroForegroundColor=e}setErrorForegroundColor(e){this.errorForegroundColor=e}setNormalBackgroundColor(e){this.normalBackgroundColor=e}setNegativeBackgroundColor(e){this.negativeBackgroundColor=e}setZeroBackgroundColor(e){this.zeroBackgroundColor=e}setErrorBackgroundColor(e){this.errorBackgroundColor=e}setIsSelected(e){this.isSelected=e}setHideFromView(e){this.hideFromView=e}setBlur(e){this.blur=e}setFixedWidth(e){this.fixedWidth=e}setMinWidth(e){this.minWidth=e}setMaxWidth(e){this.maxWidth=e}setPinned(e){this.pinned=e}setDisplayAsLink(e){this.displayAsLink=e}setLinkLabelParameter(e){this.linkLabelParameter=e}setAggregateOperation(e){this.aggregateOperation=e,this.aggregateOperator=e.operator}setAggregationParameters(e){this.aggregationParameters=e}setExcludedFromPivot(e){this.excludedFromPivot=e}setPivotSortDirection(e){this.pivotSortDirection=e}setPivotStatisticColumnFunction(e){this.pivotStatisticColumnFunction=e}}class Em extends la{static create(e){const t=Object.assign(new Em,la.serialization.fromJson(e));return(0,Ie.Gn)(t,{expandedPaths:Ie.sH,setExpandedPaths:Ie.XI}),t}setExpandedPaths(e){this.expandedPaths=e}}class Cm extends da{static create(e){const t=Object.assign(new Cm,da.serialization.fromJson(e));return t.columns=[],(0,Ie.Gn)(t,{name:Ie.sH,setName:Ie.XI,description:Ie.sH,setDescription:Ie.XI,showHorizontalGridLines:Ie.sH,setShowHorizontalGridLines:Ie.XI,showVerticalGridLines:Ie.sH,setShowVerticalGridLines:Ie.XI,gridLineColor:Ie.sH,setGridLineColor:Ie.XI,gridMode:Ie.sH,setGridMode:Ie.XI,fontFamily:Ie.sH,setFontFamily:Ie.XI,fontSize:Ie.sH,setFontSize:Ie.XI,fontBold:Ie.sH,setFontBold:Ie.XI,fontItalic:Ie.sH,setFontItalic:Ie.XI,fontUnderline:Ie.sH,setFontUnderline:Ie.XI,fontStrikethrough:Ie.sH,setFontStrikethrough:Ie.XI,fontCase:Ie.sH,setFontCase:Ie.XI,textAlign:Ie.sH,setTextAlign:Ie.XI,normalForegroundColor:Ie.sH,setNormalForegroundColor:Ie.XI,negativeForegroundColor:Ie.sH,setNegativeForegroundColor:Ie.XI,zeroForegroundColor:Ie.sH,setZeroForegroundColor:Ie.XI,errorForegroundColor:Ie.sH,setErrorForegroundColor:Ie.XI,normalBackgroundColor:Ie.sH,setNormalBackgroundColor:Ie.XI,negativeBackgroundColor:Ie.sH,setNegativeBackgroundColor:Ie.XI,zeroBackgroundColor:Ie.sH,setZeroBackgroundColor:Ie.XI,errorBackgroundColor:Ie.sH,setErrorBackgroundColor:Ie.XI,alternateRows:Ie.sH,setAlternateRows:Ie.XI,alternateRowsColor:Ie.sH,setAlternateRowsColor:Ie.XI,alternateRowsCount:Ie.sH,setAlternateRowsCount:Ie.XI,alternateRowsStandardMode:Ie.sH,setAlternateRowsStandardMode:Ie.XI,showSelectionStats:Ie.sH,setShowSelectionStats:Ie.XI,showWarningForTruncatedResult:Ie.sH,setShowWarningForTruncatedResult:Ie.XI,initialExpandLevel:Ie.sH,setInitialExpandLevel:Ie.XI,showRootAggregation:Ie.sH,setShowRootAggregation:Ie.XI,showLeafCount:Ie.sH,setShowLeafCount:Ie.XI,treeColumnSortDirection:Ie.sH,setTreeColumnSortDirection:Ie.XI,pivotStatisticColumnName:Ie.sH,setPivotStatisticColumnName:Ie.XI,pivotStatisticColumnPlacement:Ie.sH,setPivotStatisticColumnPlacement:Ie.XI,isUsingDefaultStyling:Ie.EW,useDefaultStyling:Ie.XI}),t}get isUsingDefaultStyling(){return this.fontFamily===Bi&&11===this.fontSize&&this.fontBold===ji&&this.fontItalic===Mi&&this.fontUnderline===Ui&&this.fontStrikethrough===Gi&&this.textAlign===Hi&&this.normalForegroundColor===Vi&&this.negativeForegroundColor===$i&&this.zeroForegroundColor===Yi&&this.errorForegroundColor===Xi&&this.normalBackgroundColor===Wi&&this.negativeBackgroundColor===Wi&&this.zeroBackgroundColor===Wi&&this.errorBackgroundColor===Wi}useDefaultStyling(){this.fontFamily=Bi,this.fontSize=11,this.fontBold=ji,this.fontItalic=Mi,this.fontUnderline=Ui,this.fontStrikethrough=Gi,this.textAlign=Hi,this.normalForegroundColor=Vi,this.negativeForegroundColor=$i,this.zeroForegroundColor=Yi,this.errorForegroundColor=Xi,this.normalBackgroundColor=Wi,this.negativeBackgroundColor=Wi,this.zeroBackgroundColor=Wi,this.errorBackgroundColor=Wi}setName(e){this.name=e}setDescription(e){this.description=e}setShowHorizontalGridLines(e){this.showHorizontalGridLines=e}setShowVerticalGridLines(e){this.showVerticalGridLines=e}setGridLineColor(e){this.gridLineColor=e}setGridMode(e){this.gridMode=e}setFontFamily(e){this.fontFamily=e}setFontSize(e){this.fontSize=e}setFontBold(e){this.fontBold=e}setFontItalic(e){this.fontItalic=e}setFontUnderline(e){this.fontUnderline=e}setFontStrikethrough(e){this.fontStrikethrough=e}setFontCase(e){this.fontCase=e}setTextAlign(e){this.textAlign=e}setNormalForegroundColor(e){this.normalForegroundColor=e}setNegativeForegroundColor(e){this.negativeForegroundColor=e}setZeroForegroundColor(e){this.zeroForegroundColor=e}setErrorForegroundColor(e){this.errorForegroundColor=e}setNormalBackgroundColor(e){this.normalBackgroundColor=e}setNegativeBackgroundColor(e){this.negativeBackgroundColor=e}setZeroBackgroundColor(e){this.zeroBackgroundColor=e}setErrorBackgroundColor(e){this.errorBackgroundColor=e}setAlternateRows(e){this.alternateRows=e}setAlternateRowsColor(e){this.alternateRowsColor=e}setAlternateRowsCount(e){this.alternateRowsCount=e}setAlternateRowsStandardMode(e){this.alternateRowsStandardMode=e}setShowSelectionStats(e){this.showSelectionStats=e}setShowWarningForTruncatedResult(e){this.showWarningForTruncatedResult=e}setInitialExpandLevel(e){this.initialExpandLevel=e}setShowRootAggregation(e){this.showRootAggregation=e}setShowLeafCount(e){this.showLeafCount=e}setTreeColumnSortDirection(e){this.treeColumnSortDirection=e}setPivotStatisticColumnPlacement(e){this.pivotStatisticColumnPlacement=e}setPivotStatisticColumnName(e){this.pivotStatisticColumnName=e}setExpandedPaths(e){this.pivotLayout.expandedPaths=e}}class bm{limit=void 0;configuration=new Cm;constructor(e){(0,Ie.Gn)(this,{configuration:Ie.sH,limit:Ie.sH,setLimit:Ie.XI,applySnaphot:Ie.XI})}setLimit(e){this.limit=e}applySnaphot(e,t){this.setLimit(void 0!==e.data.limit&&e.data.limit>=0?e.data.limit:void 0),this.configuration=Cm.create(e.data.configuration)}buildSnapshot(e,t){const n=e.data;n.limit=void 0===this.limit||this.limit<0?void 0:this.limit,n.configuration=this.configuration.serialize()}}class vm{_view;columns=[];selectedColumnName;showAdvancedSettings=!1;constructor(e){(0,Ie.Gn)(this,{columns:Ie.sH,setColumns:Ie.XI,selectedColumnName:Ie.sH,setSelectedColumnName:Ie.XI,selectedColumn:Ie.EW,showAdvancedSettings:Ie.sH,setShowAdvancedSettings:Ie.XI,applySnaphot:Ie.XI}),this._view=e.view}getColumnConfiguration(e){return D(ra(this.columns,e),`Can't find configuration for column '${e}'`)}setColumns(e){this.columns=e}setSelectedColumnName(e){this.selectedColumnName=e}get selectedColumn(){return ra(this.columns,this.selectedColumnName)}setShowAdvancedSettings(e){this.showAdvancedSettings=e}applySnaphot(e,t){this.setColumns(e.data.configuration.columns.map((t=>fm.create(t,e,this._view.engine.aggregateOperations)))),!this.selectedColumn&&this.columns.length&&this.setSelectedColumnName(N(this.columns,0).name)}buildSnapshot(e,t){e.data.configuration={...e.data.configuration,columns:this.columns.map((e=>e.serialize()))}}}class _m extends pm{showHiddenColumns=!1;constructor(e,t){super(e,t),(0,Ie.Gn)(this,{availableColumnsForDisplay:Ie.$Z,selectedColumnsForDisplay:Ie.$Z,showHiddenColumns:Ie.sH,setShowHiddenColumns:Ie.XI})}cloneColumn(e){return new dm(e.name,e.type)}get availableColumns(){return[...this._editor.sourceColumns,...this._editor.leafExtendColumns,...this._editor.groupExtendColumns].map((e=>new dm(e.name,e.type)))}get availableColumnsForDisplay(){return super.availableColumnsForDisplay.filter((e=>this.showHiddenColumns||!this._editor.columnProperties.getColumnConfiguration(e.name).hideFromView))}get selectedColumnsForDisplay(){return super.selectedColumnsForDisplay.filter((e=>this.showHiddenColumns||!this._editor.columnProperties.getColumnConfiguration(e.name).hideFromView))}setShowHiddenColumns(e){this.showHiddenColumns=e}}class Tm{_editor;selector;constructor(e){(0,Ie.Gn)(this,{applySnaphot:Ie.XI}),this._editor=e,this.selector=new _m(e,{onChange:e=>{const t=e.selectedColumns.map((e=>this._editor.columnProperties.getColumnConfiguration(e.name))),n=this._editor.columnProperties.columns.filter((e=>!t.includes(e)));t.forEach((e=>e.setIsSelected(!0))),n.forEach((e=>e.setIsSelected(!1))),this._editor.columnProperties.setColumns([...t,...n])}})}propagateChanges(){this._editor.sorts.adaptPropagatedChanges()}applySnaphot(e,t){this.selector.setSelectedColumns(this._editor.columnProperties.columns.filter((e=>e.isSelected)).map((e=>{const t=this.selector.getColumn(e.name);return new dm(t.name,t.type)})))}buildSnapshot(e,t){this.propagateChanges(),e.data.selectColumns=this.selector.selectedColumns.filter((e=>!ra(this._editor.groupExtendColumns,e.name))).map(ia)}}class Nm extends pm{cloneColumn(e){return new dm(e.name,e.type)}get availableColumns(){return this._editor.columnProperties.columns.filter((e=>e.kind===mi.DIMENSION&&!ra(this._editor.groupExtendColumns,e.name)&&!ra(this._editor.horizontalPivots.selector.selectedColumns,e.name))).map((e=>new dm(e.name,e.type)))}}class Sm{selector;constructor(e){this.selector=new Nm(e)}adaptPropagatedChanges(){this.selector.setSelectedColumns(this.selector.selectedColumns.filter((e=>ra(this.selector.availableColumns,e.name))))}applySnaphot(e,t){this.selector.setSelectedColumns((e.data.groupBy?.columns??[]).map((e=>new dm(e.name,e.type))))}buildSnapshot(e,t){e.data.groupBy=this.selector.selectedColumns.length?{columns:this.selector.selectedColumns.map(ia)}:void 0,e.data.selectColumns=(0,nt.A)([...e.data.selectColumns,...this.selector.selectedColumns],(e=>e.name)).map(ia)}}function Am(){return{modules:[yr.JKr],theme:"legacy",className:"ag-theme-quartz",animateRows:!1,getRowId:e=>e.data.name,editType:"fullRow",rowDragMultiRow:!0,rowDragEntireRow:!0,rowSelection:{mode:"multiRow",checkboxes:!0,headerCheckbox:!0,enableClickSelection:!0},selectionColumnDef:{width:40,headerClass:"pl-6",cellClass:"pl-1.5",rowDrag:!0,rowDragText:(e,t)=>t>1?`${t} columns`:(e.rowNode?.data).name,sortable:!1,resizable:!1,suppressHeaderMenuButton:!0},suppressMoveWhenRowDragging:!0,rowHeight:20,headerHeight:20,suppressRowHoverHighlight:!1,noRowsOverlayComponent:e=>e.api.getQuickFilter()?(0,E.jsxs)("div",{className:"flex items-center border-[1.5px] border-neutral-300 p-2 font-semibold text-neutral-400",children:[(0,E.jsx)("div",{children:(0,E.jsx)(pr.WarningCircle,{className:"mr-1 text-lg"})}),"No match found"]}):e.noColumnsSelectedRenderer?e.noColumnsSelectedRenderer():(0,E.jsx)("div",{}),onModelUpdated:e=>{0===e.api.getDisplayedRowCount()?e.api.showNoRowsOverlay():e.api.hideOverlay()}}}const ym=(0,vt.PA)((function(e){const{selector:t,gridApi:n,scope:o}=e;return(0,E.jsxs)("div",{className:"flex items-center justify-center rounded-lg bg-neutral-500 px-1 py-0.5 font-mono text-xs font-bold text-white",children:[`${kp(n).length}/${"available"===o?t.availableColumnsForDisplay.length:t.selectedColumnsForDisplay.length}`,(0,E.jsx)("span",{className:"hidden",children:"available"===o?t.availableColumnsSearchText:t.selectedColumnsSearchText})]})})),xm=(0,vt.PA)((function(e){const{selector:t,columnLabelRenderer:n,columnActionRenderer:o,noColumnsSelectedRenderer:r}=e,[i,a]=(0,Ft.useState)([]),[s,l]=(0,Ft.useState)([]),[c,u]=(0,Ft.useState)(null),[d,p]=(0,Ft.useState)(null),m=(0,Ft.useRef)(null),g=(0,Ft.useRef)(null),h=(0,Ft.useCallback)((e=>{const n=e.nodes.map((e=>e.data)).filter(L);t.setSelectedColumns(t.selectedColumns.filter((e=>!ra(n,e.name))))}),[t]),f=(0,Ft.useCallback)((e=>{t.setSelectedColumns(wp(e.api))}),[t]),C=(0,Ft.useCallback)((e=>{-1!==e.overIndex&&t.setSelectedColumns(wp(e.api))}),[t]);return(0,Ft.useEffect)((()=>{if(!c||!d)return;const e=d.isDestroyed()?void 0:d.getRowDropZoneParams({onDragStop:e=>{f(e),c.clearFocusedCell()}});e&&!c.isDestroyed()&&c.addRowDropZone(e);const t=c.isDestroyed()?void 0:c.getRowDropZoneParams({onDragStop:e=>{h(e),d.clearFocusedCell()}});t&&!d.isDestroyed()&&d.addRowDropZone(t)}),[c,d,f,h]),(0,E.jsxs)("div",{className:"data-cube-column-selector flex h-full w-full",children:[(0,E.jsxs)("div",{className:"h-full w-[calc(50%_-_20px)]",children:[(0,E.jsx)("div",{className:"flex h-5 items-center text-sm",children:"Available columns:"}),(0,E.jsxs)("div",{className:"h-[calc(100%_-_20px)] rounded-sm border border-neutral-200",children:[(0,E.jsxs)("div",{className:"relative h-6 border-b border-neutral-200",children:[(0,E.jsx)("input",{className:"h-full w-full pl-10 pr-6 placeholder-neutral-400",ref:m,placeholder:"Search columns...",value:t.availableColumnsSearchText,onChange:e=>t.setAvailableColumnsSearchText(e.target.value),onKeyDown:e=>{"Escape"===e.code&&(e.stopPropagation(),m.current?.select(),t.setAvailableColumnsSearchText(""))}}),(0,E.jsx)("div",{className:"absolute left-0 top-0 flex h-6 w-10 items-center justify-center",children:(0,E.jsx)(pr.Search,{className:"stroke-[3px] text-lg text-neutral-500"})}),(0,E.jsx)("button",{className:"absolute right-0 top-0 flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",disabled:!t.availableColumnsSearchText,title:"Clear search [Esc]",onClick:()=>{t.setAvailableColumnsSearchText(""),m.current?.focus()},children:(0,E.jsx)(pr.X,{className:"text-lg"})})]}),(0,E.jsx)("div",{className:"h-[calc(100%_-_24px)]",children:(0,E.jsx)(Ir.W6,{...Am(),rowDragManaged:!1,onGridReady:e=>u(e.api),onSelectionChanged:e=>{a(e.api.getSelectedNodes().map((e=>e.data)).filter(L))},quickFilterText:t.availableColumnsSearchText,rowData:t.availableColumnsForDisplay,columnDefs:[{field:"name",colId:"name",flex:1,minWidth:100,filter:!0,sortable:!1,resizable:!1,suppressHeaderMenuButton:!0,getQuickFilterText:e=>e.value,headerComponent:e=>(0,E.jsxs)("button",{title:"Double-click to add all columns",className:"flex h-full w-full items-center justify-between pl-0.5",onDoubleClick:()=>{const n=kp(e.api);t.setSelectedColumns([...t.selectedColumns,...n]),e.api.clearFocusedCell()},children:[(0,E.jsx)("div",{children:"[All Columns]"}),(0,E.jsx)(ym,{selector:t,gridApi:e.api,scope:"available"})]}),cellRenderer:e=>{const r=e.data;return r?(0,E.jsxs)("div",{className:"flex h-full w-full cursor-pointer items-center",title:`[${r.name}]\nDouble-click to add column`,onDoubleClick:()=>{t.setSelectedColumns([...t.selectedColumns,r]),e.api.clearFocusedCell()},children:[n?.({selector:t,column:r})??(0,E.jsx)("div",{className:"h-full flex-1 items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-2",children:r.name}),(0,E.jsx)("div",{className:"flex h-full",children:o?.({selector:t,column:r})??null})]}):null}}]})})]})]}),(0,E.jsx)("div",{className:"flex h-full w-10 items-center justify-center",children:(0,E.jsxs)("div",{className:"flex flex-col",children:[(0,E.jsx)("button",{className:"flex items-center justify-center rounded-sm border border-neutral-300 bg-neutral-100 text-neutral-500 hover:bg-neutral-200 disabled:bg-neutral-200 disabled:text-neutral-400",title:"Add selected column(s)",onClick:()=>{if(!c||0===i.length)return;const e=kp(c),n=i.filter((t=>ra(e,t.name)));t.setSelectedColumns([...t.selectedColumns,...n]),c.clearFocusedCell()},disabled:!c||0===i.length,children:(0,E.jsx)(pr.ChevronRight,{className:"text-2xl"})}),(0,E.jsx)("button",{className:"mt-2 flex items-center justify-center rounded-sm border border-neutral-300 bg-neutral-100 text-neutral-500 hover:bg-neutral-200 disabled:bg-neutral-200 disabled:text-neutral-400",title:"Remove selected column(s)",onClick:()=>{if(!d||0===s.length)return;const e=kp(d),n=s.filter((t=>ra(e,t.name)));t.setSelectedColumns(t.selectedColumns.filter((e=>!ra(n,e.name)))),d.clearFocusedCell()},disabled:!d||0===s.length,children:(0,E.jsx)(pr.ChevronLeft,{className:"text-2xl"})})]})}),(0,E.jsxs)("div",{className:"h-full w-[calc(50%_-_20px)]",children:[(0,E.jsx)("div",{className:"flex h-5 items-center text-sm",children:"Selected columns:"}),(0,E.jsxs)("div",{className:"h-[calc(100%_-_20px)] rounded-sm border border-neutral-200",children:[(0,E.jsxs)("div",{className:"relative h-6 border-b border-neutral-200",children:[(0,E.jsx)("input",{className:"h-full w-full pl-10 placeholder-neutral-400",ref:g,placeholder:"Search columns...",value:t.selectedColumnsSearchText,onChange:e=>t.setSelectedColumnsSearchText(e.target.value),onKeyDown:e=>{"Escape"===e.code&&(e.stopPropagation(),t.setSelectedColumnsSearchText(""))}}),(0,E.jsx)("div",{className:"absolute left-0 top-0 flex h-6 w-10 items-center justify-center",children:(0,E.jsx)(pr.Search,{className:"stroke-[3px] text-lg text-neutral-500"})}),(0,E.jsx)("button",{className:"absolute right-0 top-0 flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",disabled:!t.selectedColumnsSearchText,title:"Clear search [Esc]",onClick:()=>{t.setSelectedColumnsSearchText(""),g.current?.focus()},children:(0,E.jsx)(pr.X,{className:"text-lg"})})]}),(0,E.jsx)("div",{className:"h-[calc(100%_-_24px)]",children:(0,E.jsx)(Ir.W6,{...Am(),rowDragManaged:!0,onRowDragEnd:C,onGridReady:e=>p(e.api),onSelectionChanged:e=>{l(e.api.getSelectedNodes().map((e=>e.data)).filter(L))},quickFilterText:t.selectedColumnsSearchText,noRowsOverlayComponentParams:{noColumnsSelectedRenderer:r},rowData:t.selectedColumnsForDisplay,columnDefs:[{field:"name",colId:"name",flex:1,minWidth:100,filter:!0,sortable:!1,resizable:!1,suppressHeaderMenuButton:!0,getQuickFilterText:e=>e.value,headerComponent:e=>(0,E.jsxs)("button",{title:"Double-click to remove all columns",className:"flex h-full w-full items-center justify-between pl-0.5",onDoubleClick:()=>{const n=kp(e.api);t.setSelectedColumns(t.selectedColumns.filter((e=>!ra(n,e.name)))),e.api.clearFocusedCell()},children:[(0,E.jsx)("div",{children:"[All Columns]"}),(0,E.jsx)(ym,{selector:t,gridApi:e.api,scope:"selected"})]}),cellRenderer:e=>{const r=e.data;return r?(0,E.jsxs)("div",{className:"flex h-full w-full cursor-pointer items-center",title:`[${r.name}]\nDouble-click to remove column`,onDoubleClick:()=>{t.setSelectedColumns(t.selectedColumns.filter((e=>e!==r))),e.api.clearFocusedCell()},children:[n?.({selector:t,column:r})??(0,E.jsx)("div",{className:"h-full flex-1 items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-2",children:r.name}),(0,E.jsx)("div",{className:"flex h-full",children:o?.({selector:t,column:r})??null})]}):null}}]})})]})]})]})})),Im=(0,vt.PA)((e=>{const{column:t}=e,[n,o,r,i]=pu();return(0,E.jsxs)("div",{className:"group relative flex h-full items-center",children:[!i&&(0,E.jsx)("div",{className:"flex h-[18px] w-32 items-center border border-transparent px-2 text-sm text-neutral-400 group-hover:invisible",children:t.direction}),i&&(0,E.jsxs)("div",{className:"flex h-[18px] w-32 items-center justify-between border border-sky-600 bg-sky-50 pl-2 pr-0.5 text-sm",children:[(0,E.jsx)("div",{children:t.direction}),(0,E.jsx)("div",{children:(0,E.jsx)(pr.CaretDown,{})})]}),(0,E.jsxs)("button",{className:"invisible absolute right-0 z-10 flex h-[18px] w-32 items-center justify-between border border-neutral-400 pl-2 pr-0.5 text-sm text-neutral-700 group-hover:visible",onClickCapture:e=>{e.stopPropagation(),n(e)},onClick:e=>e.stopPropagation(),children:[(0,E.jsx)("div",{children:t.direction}),(0,E.jsx)("div",{children:(0,E.jsx)(pr.CaretDown,{})})]}),(0,E.jsx)(xu,{className:"w-32",...r,children:[bi.ASCENDING,bi.DESCENDING].map((e=>(0,E.jsx)(Iu,{onClick:()=>{t.setDirection(e),o()},autoFocus:t.direction===e,children:e},e)))})]})})),wm=(0,vt.PA)((e=>{const{column:t}=e;return(0,E.jsx)("div",{className:"h-full flex-1 items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-2",children:t.name.split(yi).join(" / ")})})),km=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor.sorts;return(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-6 items-center text-xl font-medium",children:(0,E.jsx)(pr.TableSort,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:"Sorts"})]}),(0,E.jsx)("div",{className:"flex h-[calc(100%_-_24px)] w-full",children:(0,E.jsx)(xm,{selector:n.selector,columnLabelRenderer:e=>(0,E.jsx)(wm,{...e}),columnActionRenderer:e=>(0,E.jsx)(Im,{...e})})})]})}));var Rm;!function(e){e.EXTENDED_COLUMN_LEVELS="data-cube.extended-column.levels",e.GRID_CONFIGURATION_ROW_LIMIT="data-cube.grid-configuration.row-limit",e.COLUMN_CONFIGURATION_KIND="data-cube.column-configuration.kind",e.COLUMN_CONFIGURATION_UNIT="data-cube.column-configuration.unit",e.COLUMN_CONFIGURATION_DISPLAY_AS_LINK="data-cube.column-configuration.display-value-as-link",e.COLUMN_CONFIGURATION_MISSING_VALUE_FORMAT="data-cube.column-configuration.missing-value-format"}(Rm||(Rm={}));const Om=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor.generalProperties,o=n.configuration,[r,i,a,s]=pu(),[l,c,u,d]=pu(),[p,m,g,h]=pu(),[f,C,b,v]=pu(),[_,T,N]=pu(),[S,A,y]=pu();return(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-6 items-center text-xl font-medium",children:(0,E.jsx)(pr.TableOptions,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:"General Properties"})]}),(0,E.jsx)("div",{className:"flex h-[calc(100%_-_24px)] w-full",children:(0,E.jsxs)("div",{className:"h-full w-full py-2",children:[(0,E.jsxs)("div",{className:"flex h-6 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Report Title:"}),(0,E.jsx)(Su,{className:"h-6 w-96 text-lg font-semibold",value:o.name,onChange:e=>{o.setName(e.target.value)}})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Tree Column:"}),(0,E.jsx)(Au,{label:"Show root aggregation",checked:o.showRootAggregation,onChange:()=>o.setShowRootAggregation(!o.showRootAggregation)}),(0,E.jsx)(Au,{className:"ml-3",label:"Show leaf count",checked:o.showLeafCount,onChange:()=>o.setShowLeafCount(!o.showLeafCount)})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm"}),(0,E.jsx)("div",{className:"mr-1 flex h-full flex-shrink-0 items-center text-sm",children:"Sort:"}),(0,E.jsx)(yu,{className:"w-20",onClick:r,open:s,children:o.treeColumnSortDirection}),(0,E.jsx)(xu,{className:"w-20",...a,children:[bi.ASCENDING,bi.DESCENDING].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setTreeColumnSortDirection(e),i()},autoFocus:e===o.treeColumnSortDirection,children:e},e)))}),(0,E.jsx)("div",{className:"ml-3 mr-1 flex h-full flex-shrink-0 items-center text-sm",children:"Initially expand to level:"}),(0,E.jsx)(yu,{className:"w-16",onClick:l,open:d,showAsPlaceholder:void 0===o.initialExpandLevel,children:o.initialExpandLevel??Ki}),(0,E.jsx)(xu,{className:"w-16",...u,children:[void 0,1,2,3,4,5,6,7,8].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setInitialExpandLevel(e),c()},autoFocus:e===o.initialExpandLevel,children:e??Ki},e??"")))})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsxs)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:["Row Limit:",(0,E.jsx)(Ou,{className:"ml-1",documentationKey:Rm.GRID_CONFIGURATION_ROW_LIMIT})]}),(0,E.jsx)(Nu,{className:"w-16 text-sm",value:n.limit,min:0,step:1,defaultValue:void 0,placeholder:Ki,setValue:e=>n.setLimit(e)})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm"}),(0,E.jsx)(Au,{label:"Display warning when truncated",checked:o.showWarningForTruncatedResult,onChange:()=>o.setShowWarningForTruncatedResult(!o.showWarningForTruncatedResult)})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Show Selection Stats?"}),(0,E.jsx)(Au,{checked:o.showSelectionStats,onChange:()=>o.setShowSelectionStats(!o.showSelectionStats),disabled:!0}),(0,E.jsx)(vu,{})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Show Lines?"}),(0,E.jsx)(Au,{label:"Horizontal",checked:o.showHorizontalGridLines,onChange:()=>o.setShowHorizontalGridLines(!o.showHorizontalGridLines)}),(0,E.jsx)(Au,{className:"ml-3",label:"Vertical",checked:o.showVerticalGridLines,onChange:()=>o.setShowVerticalGridLines(!o.showVerticalGridLines)}),(0,E.jsx)("div",{className:"ml-3 mr-1 flex h-full flex-shrink-0 items-center text-sm",children:"Color:"}),(0,E.jsx)(Ru,{color:o.gridLineColor,defaultColor:Li,onChange:e=>o.setGridLineColor(e)})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Hightlight Rows:"}),(0,E.jsx)(Au,{label:"Standard mode",checked:o.alternateRowsStandardMode,onChange:()=>{o.alternateRowsStandardMode?o.setAlternateRowsStandardMode(!1):(o.setAlternateRowsStandardMode(!0),o.setAlternateRows(!1))}}),(0,E.jsx)(Au,{className:"ml-3",checked:o.alternateRows,onChange:()=>{o.alternateRows?o.setAlternateRows(!1):(o.setAlternateRows(!0),o.setAlternateRowsStandardMode(!1))}}),(0,E.jsx)("div",{className:"ml-1 mr-1 flex h-full flex-shrink-0 items-center text-sm",children:"Custom: Alternate color:"}),(0,E.jsx)(Ru,{disabled:!o.alternateRows,color:o.alternateRowsColor,defaultColor:Fi,onChange:e=>o.setAlternateRowsColor(e)}),(0,E.jsx)("div",{className:"ml-1 flex h-full flex-shrink-0 items-center text-sm",children:"every:"}),(0,E.jsx)(Nu,{className:"ml-1 w-16 text-sm",disabled:!o.alternateRows,min:1,step:1,defaultValue:1,isValid:e=>void 0!==e&&e>0,value:o.alternateRowsCount,setValue:e=>o.setAlternateRowsCount(e??1)}),(0,E.jsx)("div",{className:"ml-1 flex-shrink-0 text-sm",children:"rows"})]}),(0,E.jsx)("div",{className:"my-2 h-[1px] w-full bg-neutral-200"}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Default Font:"}),(0,E.jsx)(yu,{className:"w-28",onClick:p,open:h,children:o.fontFamily}),(0,E.jsxs)(xu,{className:"w-28",...g,children:[[ci.ARIAL,ci.ROBOTO,ci.ROBOTO_CONDENSED].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setFontFamily(e),m()},autoFocus:e===o.fontFamily,children:e},e))),(0,E.jsx)(wu,{}),[ci.GEORGIA,ci.ROBOTO_SERIF,ci.TIMES_NEW_ROMAN].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setFontFamily(e),m()},autoFocus:e===o.fontFamily,children:e},e))),(0,E.jsx)(wu,{}),[ci.JERBRAINS_MONO,ci.ROBOTO_MONO,ci.UBUNTU_MONO].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setFontFamily(e),m()},autoFocus:e===o.fontFamily,children:e},e)))]}),(0,E.jsx)(yu,{className:"ml-1 w-10",onClick:f,open:v,children:o.fontSize}),(0,E.jsx)(xu,{className:"w-10",...b,children:[4,5,6,7,8,9,10,11,12,14,16,18,20,22,24,26,28,32,36,48,72].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setFontSize(e),C()},autoFocus:e===o.fontSize,children:e},e)))}),(0,E.jsxs)("div",{className:"relative ml-2 flex h-5",children:[(0,E.jsx)("button",{title:"Bold",className:Mn("relative flex h-5 w-5 items-center justify-center rounded-bl-sm rounded-tl-sm border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":o.fontBold}),onClick:()=>o.setFontBold(!o.fontBold),children:(0,E.jsx)(pr.FontBold,{})}),(0,E.jsx)("button",{title:"Italic",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":o.fontItalic}),onClick:()=>o.setFontItalic(!o.fontItalic),children:(0,E.jsx)(pr.FontItalic,{})}),(0,E.jsx)("button",{title:"Underline"+(o.fontUnderline?` (${o.fontUnderline})`:""),className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-r-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":void 0!==o.fontUnderline}),onClick:()=>{void 0===o.fontUnderline?(o.setFontUnderline(pi.SOLID),o.setFontStrikethrough(!1)):o.setFontUnderline(void 0)},children:(0,E.jsx)(pr.FontUnderline,{})}),(0,E.jsxs)("button",{className:"text-2xs relative -ml-[1px] flex h-5 w-2.5 items-center justify-center border border-l-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-600 focus:z-[1]",onClick:_,children:[(0,E.jsx)("div",{className:Mn("h-4 w-[0.5px] bg-neutral-200",{"opacity-0":void 0!==o.fontUnderline})}),(0,E.jsx)(pr.CaretDown,{})]}),(0,E.jsx)(xu,{className:"w-14",...N,children:[pi.SOLID,pi.DASHED,pi.DOTTED,pi.DOUBLE,pi.WAVY].map((e=>(0,E.jsx)(Iu,{className:"relative",onClick:()=>{o.setFontUnderline(e),o.setFontStrikethrough(!1),T()},autoFocus:e===o.fontUnderline,children:(0,E.jsx)("div",{className:Mn("!hover:underline absolute top-0 !underline",{"!hover:decoration-solid !decoration-solid":e===pi.SOLID,"!hover:decoration-dashed !decoration-dashed":e===pi.DASHED,"!hover:decoration-dotted !decoration-dotted":e===pi.DOTTED,"!hover:decoration-double !decoration-double":e===pi.DOUBLE,"!hover:decoration-wavy !decoration-wavy":e===pi.WAVY}),children:"                "})},e)))}),(0,E.jsx)("button",{title:"Strikethrough",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":o.fontStrikethrough}),onClick:()=>{o.fontStrikethrough?o.setFontStrikethrough(!1):(o.setFontStrikethrough(!0),o.setFontUnderline(void 0))},children:(0,E.jsx)(pr.FontStrikethrough,{})}),(0,E.jsx)("button",{title:"Case"+(o.fontCase?` (${o.fontCase})`:""),className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-r-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":void 0!==o.fontCase}),onClick:()=>{o.setFontCase(void 0===o.fontCase?di.UPPERCASE:void 0)},children:(0,E.jsx)(pr.FontCase,{className:"stroke-[0.5px]"})}),(0,E.jsxs)("button",{className:"text-2xs relative -ml-[1px] flex h-5 w-2.5 items-center justify-center rounded-br-sm rounded-tr-sm border border-l-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-600 focus:z-[1]",onClick:S,children:[(0,E.jsx)("div",{className:Mn("h-4 w-[0.5px] bg-neutral-200",{"opacity-0":void 0!==o.fontCase})}),(0,E.jsx)(pr.CaretDown,{})]}),(0,E.jsx)(xu,{className:"w-20",...y,children:[di.LOWERCASE,di.UPPERCASE,di.CAPITALIZE].map((e=>(0,E.jsx)(Iu,{onClick:()=>{o.setFontCase(e),A()},autoFocus:e===o.fontCase,children:(0,E.jsx)("div",{className:Mn({lowercase:e===di.LOWERCASE,uppercase:e===di.UPPERCASE,capitalize:e===di.CAPITALIZE}),children:e})},e)))})]}),(0,E.jsxs)("div",{className:"relative ml-2 flex h-5",children:[(0,E.jsx)("button",{title:"Align Left",className:Mn("relative flex h-5 w-5 items-center justify-center rounded-bl-sm rounded-tl-sm border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":o.textAlign===ui.LEFT}),onClick:()=>o.setTextAlign(ui.LEFT),children:(0,E.jsx)(pr.TextAlignLeft,{})}),(0,E.jsx)("button",{title:"Align Center",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":o.textAlign===ui.CENTER}),onClick:()=>o.setTextAlign(ui.CENTER),children:(0,E.jsx)(pr.TextAlignCenter,{})}),(0,E.jsx)("button",{title:"Align Right",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center rounded-br-sm rounded-tr-sm border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":o.textAlign===ui.RIGHT}),onClick:()=>o.setTextAlign(ui.RIGHT),children:(0,E.jsx)(pr.TextAlignRight,{})})]})]}),(0,E.jsxs)("div",{className:"mt-2 flex w-full",children:[(0,E.jsx)("div",{className:"flex h-6 w-32 flex-shrink-0 items-center text-sm",children:"Default Colors:"}),(0,E.jsxs)("div",{className:"h-18",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"w-16 flex-shrink-0"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Normal"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Negative"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Zero"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Error"})]}),(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-full w-16 flex-shrink-0 items-center text-sm",children:"Foreground:"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.normalForegroundColor,defaultColor:Vi,onChange:e=>o.setNormalForegroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.negativeForegroundColor,defaultColor:$i,onChange:e=>o.setNegativeForegroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.zeroForegroundColor,defaultColor:Yi,onChange:e=>o.setZeroForegroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.errorForegroundColor,defaultColor:Xi,onChange:e=>o.setErrorForegroundColor(e)})})]}),(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-full w-16 flex-shrink-0 items-center text-sm",children:"Background:"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.normalBackgroundColor,defaultColor:Wi,onChange:e=>o.setNormalBackgroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.negativeBackgroundColor,defaultColor:Wi,onChange:e=>o.setNegativeBackgroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.zeroBackgroundColor,defaultColor:Wi,onChange:e=>o.setZeroBackgroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:o.errorBackgroundColor,defaultColor:Wi,onChange:e=>o.setErrorBackgroundColor(e)})})]})]})]}),(0,E.jsxs)("div",{className:"mt-2 flex w-full",children:[(0,E.jsx)("div",{className:"flex h-6 w-32 flex-shrink-0 items-center text-sm"}),(0,E.jsxs)("div",{className:"w-80",children:[(0,E.jsx)("div",{className:"mb-2 h-[1px] w-full bg-neutral-200"}),(0,E.jsx)(Tu,{compact:!0,disabled:o.isUsingDefaultStyling,onClick:()=>o.useDefaultStyling(),children:"Use Default Styling"})]})]})]})})]})})),Lm=(0,vt.PA)((e=>{const{column:t,editor:n}=e,o=n.columnProperties.getColumnConfiguration(t.name).hideFromView;return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:Mn("items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-2",{"text-neutral-400":o}),children:t.name}),Boolean(ra(n.leafExtendColumns,t.name))&&(0,E.jsx)("div",{className:"ml-1.5 mr-0.5 flex h-3.5 flex-shrink-0 items-center rounded-sm border border-neutral-300 bg-neutral-100 px-1 text-xs font-medium uppercase text-neutral-600",children:"Extended (Leaf Level)"}),Boolean(ra(n.groupExtendColumns,t.name))&&(0,E.jsx)("div",{className:"ml-1.5 mr-0.5 flex h-3.5 flex-shrink-0 items-center rounded-sm border border-neutral-300 bg-neutral-100 px-1 text-xs font-medium uppercase text-neutral-600",children:"Extended (Group Level)"})]})})),Fm=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor,o=n.columns;return(0,Ft.useEffect)((()=>()=>o.propagateChanges()),[o]),(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6 justify-between",children:[(0,E.jsxs)("div",{className:"flex h-full",children:[(0,E.jsx)("div",{className:"flex h-6 items-center text-xl font-medium",children:(0,E.jsx)(pr.TableColumns,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:"Columns"})]}),(0,E.jsx)("div",{className:"flex h-full items-center pr-2",children:(0,E.jsx)(Au,{label:"Show hidden columns?",checked:o.selector.showHiddenColumns,onChange:()=>o.selector.setShowHiddenColumns(!o.selector.showHiddenColumns)})})]}),(0,E.jsx)("div",{className:"flex h-[calc(100%_-_24px)] w-full",children:(0,E.jsx)(xm,{selector:o.selector,noColumnsSelectedRenderer:()=>(0,E.jsxs)("div",{className:"flex items-center border-[1.5px] border-neutral-200 p-2 font-semibold text-neutral-400",children:[(0,E.jsx)("div",{children:(0,E.jsx)(pr.Warning,{className:"mr-1 text-lg"})}),"No columns selected"]}),columnLabelRenderer:e=>(0,E.jsx)(Lm,{...e,editor:n})})})]})})),Dm=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor.verticalPivots;return(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-6 items-center text-xl font-medium",children:(0,E.jsx)(pr.TableGroupBy,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:"Vertical Pivots"})]}),(0,E.jsx)("div",{className:"flex h-[calc(100%_-_24px)] w-full",children:(0,E.jsx)(xm,{selector:n.selector})})]})})),Pm=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor.horizontalPivots;return(0,Ft.useEffect)((()=>()=>n.propagateChanges()),[n]),(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-6 items-center text-xl font-medium",children:(0,E.jsx)(pr.TablePivot,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:"Horizontal Pivots"})]}),(0,E.jsx)("div",{className:"flex h-[calc(100%_-_24px)] w-full",children:(0,E.jsx)(xm,{selector:n.selector,columnActionRenderer:e=>(0,E.jsx)(Im,{...e})})})]})})),Bm=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor,o=n.columnProperties,r=t.editor.generalProperties.configuration,i=o.selectedColumn,[a,s,l,c]=pu(),[u,d,p,m]=pu(),[g,h,f,C]=pu(),[b,v,_,T]=pu(),[N,S,A,y]=pu(),[x,I,w,k]=pu(),[R,O,L,F]=pu(),[D,P,B]=pu(),[j,M,U]=pu();return(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6 justify-between",children:[(0,E.jsxs)("div",{className:"flex h-full",children:[(0,E.jsxs)("div",{className:"relative flex h-6 items-center text-xl font-medium",children:[(0,E.jsx)(pr.TableColumn,{}),(0,E.jsx)(pr.TableColumnOptions__Settings,{className:"absolute bottom-1 right-0 bg-white text-xs"})]}),(0,E.jsx)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:"Column Properties"})]}),(0,E.jsxs)("div",{className:"flex h-full items-center pr-2",children:[(0,E.jsx)(Au,{label:"Show advanced settings?",checked:o.showAdvancedSettings,onChange:()=>o.setShowAdvancedSettings(!o.showAdvancedSettings)}),(0,E.jsx)(_u,{})]})]}),(0,E.jsx)("div",{className:"flex h-[calc(100%_-_24px)] w-full",children:(0,E.jsxs)("div",{className:"h-full w-full py-2",children:[(0,E.jsxs)("div",{className:"flex h-6 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Choose Column:"}),(0,E.jsx)(yu,{className:"w-80",onClick:a,open:c,children:(0,E.jsxs)("div",{className:"flex h-full w-full items-center",children:[(0,E.jsx)("div",{className:"overflow-hidden overflow-ellipsis whitespace-nowrap",children:i?.name??Ki}),i&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"ml-1.5 mr-0.5 flex h-3.5 w-12 flex-shrink-0 items-center justify-center rounded-sm border border-neutral-300 bg-neutral-100 text-xs font-medium uppercase text-neutral-600",children:i.dataType}),Boolean(ra(n.leafExtendColumns,i.name))&&(0,E.jsx)("div",{className:"mr-0.5 flex h-3.5 flex-shrink-0 items-center rounded-sm border border-neutral-300 bg-neutral-100 px-1 text-xs font-medium uppercase text-neutral-600",children:"Extended (Leaf Level)"}),Boolean(ra(n.groupExtendColumns,i.name))&&(0,E.jsx)("div",{className:"mr-0.5 flex h-3.5 flex-shrink-0 items-center rounded-sm border border-neutral-300 bg-neutral-100 px-1 text-xs font-medium uppercase text-neutral-600",children:"Extended (Group Level)"})]})]})}),(0,E.jsx)(xu,{className:"w-80",...l,children:o.columns.toSorted(aa).map((e=>(0,E.jsxs)(Iu,{onClick:()=>{o.setSelectedColumnName(e.name),s()},autoFocus:e.name===i?.name,children:[(0,E.jsx)("div",{className:"overflow-hidden overflow-ellipsis whitespace-nowrap",children:e.name}),(0,E.jsx)("div",{className:"ml-1.5 mr-0.5 flex h-3.5 w-12 flex-shrink-0 items-center justify-center rounded-sm border border-neutral-300 bg-neutral-100 text-xs font-medium uppercase text-neutral-600",children:e.dataType}),Boolean(ra(n.leafExtendColumns,e.name))&&(0,E.jsx)("div",{className:"mr-0.5 flex h-3.5 flex-shrink-0 items-center rounded-sm border border-neutral-300 bg-neutral-100 px-1 text-xs font-medium uppercase text-neutral-600",children:"Extended (Leaf Level)"}),Boolean(ra(n.groupExtendColumns,e.name))&&(0,E.jsx)("div",{className:"mr-0.5 flex h-3.5 flex-shrink-0 items-center rounded-sm border border-neutral-300 bg-neutral-100 px-1 text-xs font-medium uppercase text-neutral-600",children:"Extended (Group Level)"})]},e.name)))}),o.showAdvancedSettings&&i&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"mx-2 h-[1px] w-4 flex-shrink-0 bg-neutral-400"}),(0,E.jsxs)("div",{className:"flex h-6 items-center",children:[(0,E.jsxs)("div",{className:"flex h-full flex-shrink-0 items-center text-sm",children:["Column Kind:",(0,E.jsx)(Ou,{className:"ml-1",documentationKey:Rm.COLUMN_CONFIGURATION_KIND})]}),(0,E.jsx)(yu,{className:"ml-1.5 w-20",onClick:u,open:m,disabled:Boolean(ra(n.verticalPivots.selector.selectedColumns,i.name)??ra(n.horizontalPivots.selector.selectedColumns,i.name)),title:Boolean(ra(n.verticalPivots.selector.selectedColumns,i.name)??ra(n.horizontalPivots.selector.selectedColumns,i.name))?"Column kind cannot be changed while the column is used in pivot":void 0,children:i.kind}),(0,E.jsx)(xu,{className:"w-20",...p,children:[mi.DIMENSION,mi.MEASURE].map((e=>(0,E.jsx)(Iu,{onClick:()=>{e!==i.kind&&(i.setKind(e),i.setExcludedFromPivot(e===mi.DIMENSION),i.setPivotStatisticColumnFunction(e===mi.DIMENSION?void 0:fi.SUM)),d()},autoFocus:e===i.kind,children:e},e)))}),(0,E.jsx)(_u,{})]})]})]}),(0,E.jsx)("div",{className:"mb-2 ml-2 mt-3 h-[1px] w-[calc(100%_-_16px)] bg-neutral-200"}),i&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Display Name:"}),(0,E.jsx)(Su,{className:"w-80",value:i.displayName??"",onChange:e=>{const t=e.target.value;i.setDisplayName(""!==t?t:void 0)}})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Aggregation:"}),(0,E.jsx)(yu,{className:"w-32",onClick:g,disabled:i.kind===mi.DIMENSION,open:C,children:i.aggregateOperation.operator}),(0,E.jsx)(xu,{className:"w-32",...f,children:t.engine.aggregateOperations.filter((e=>e.isCompatibleWithColumn(i))).map((e=>(0,E.jsx)(Iu,{onClick:()=>{e!==i.aggregateOperation&&(i.setAggregateOperation(e),i.setAggregationParameters(e.generateDefaultParameterValues(i))),h()},autoFocus:e===i.aggregateOperation,children:e.label},e.operator)))}),(0,E.jsx)(Au,{className:"ml-3",label:"Exclude from horizontal pivot",checked:i.excludedFromPivot,onChange:()=>i.setExcludedFromPivot(!i.excludedFromPivot),disabled:i.kind===mi.DIMENSION})]}),i.dataType===_i.NUMBER&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Number Format:"}),(0,E.jsx)(Nu,{className:"w-16 text-sm",min:0,step:1,value:i.decimals??0,setValue:e=>{i.setDecimals(e)}}),(0,E.jsx)("div",{className:"ml-1 flex-shrink-0 text-sm",children:"decimal places"}),(0,E.jsx)(Au,{className:"ml-3",label:"Display commas",checked:i.displayCommas,onChange:()=>i.setDisplayCommas(!i.displayCommas)}),(0,E.jsx)(Au,{className:"ml-3",label:"Negative number in parens",checked:i.negativeNumberInParens,onChange:()=>i.setNegativeNumberInParens(!i.negativeNumberInParens)})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm"}),(0,E.jsx)("div",{className:"mr-1 flex h-full flex-shrink-0 items-center text-sm",children:"Scale:"}),(0,E.jsx)(yu,{className:"w-32",onClick:b,open:T,showAsPlaceholder:void 0===i.numberScale,children:i.numberScale??Ki}),(0,E.jsx)(xu,{className:"w-32",..._,children:[void 0,li.PERCENT,li.BASIS_POINT,li.THOUSANDS,li.MILLIONS,li.BILLIONS,li.TRILLIONS,li.AUTO].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setNumberScale(e),v()},autoFocus:e===i.numberScale,children:e??Ki},e??"")))}),(0,E.jsxs)("div",{className:"ml-3 mr-1 flex h-full flex-shrink-0 items-center text-sm",children:["Unit:",(0,E.jsx)(Ou,{className:"ml-1",documentationKey:Rm.COLUMN_CONFIGURATION_UNIT})]}),(0,E.jsx)(Su,{className:"w-16",value:i.unit??"",onChange:e=>{const t=e.target.value.trim();i.setUnit(""!==t.trim()?t:void 0)},placeholder:Ki})]})]}),i.dataType===_i.TEXT&&(0,E.jsx)(E.Fragment,{children:(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsxs)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:["Dislay as Link?",(0,E.jsx)(Ou,{className:"ml-1",documentationKey:Rm.COLUMN_CONFIGURATION_DISPLAY_AS_LINK})]}),(0,E.jsx)(Au,{checked:i.displayAsLink,onChange:()=>i.setDisplayAsLink(!i.displayAsLink)}),(0,E.jsx)("div",{className:"ml-1 h-[1px] w-2 flex-shrink-0 bg-neutral-400"}),(0,E.jsx)("div",{className:"ml-2 mr-1.5 flex h-full flex-shrink-0 items-center text-sm",children:"Use parameter in link as label:"}),(0,E.jsx)(Su,{className:"w-48",placeholder:Oi,value:i.linkLabelParameter??"",onChange:e=>{const t=e.target.value.trim();i.setLinkLabelParameter(""!==t?t:void 0)}})]})}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsxs)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:["Missing Value Format:",(0,E.jsx)(Ou,{className:"ml-1",documentationKey:Rm.COLUMN_CONFIGURATION_MISSING_VALUE_FORMAT})]}),(0,E.jsx)(Su,{className:"w-16",value:i.missingValueDisplayText??"",onChange:e=>{const t=e.target.value;i.setMissingValueDisplayText(""!==t?t:void 0)},placeholder:Ki})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Visibility:"}),(0,E.jsx)(Au,{label:"Blur content",checked:i.blur,onChange:()=>i.setBlur(!i.blur),disabled:i.hideFromView}),(0,E.jsx)(Au,{className:"ml-3",label:"Hide from view",checked:i.hideFromView,onChange:()=>i.setHideFromView(!i.hideFromView)})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Pin:"}),(0,E.jsx)(yu,{className:"w-16",onClick:N,open:y,showAsPlaceholder:void 0===i.pinned,children:i.pinned??Ki}),(0,E.jsx)(xu,{className:"w-16",...A,children:[void 0,vi.LEFT,vi.RIGHT].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setPinned(e),S()},autoFocus:e===i.pinned,children:e??Ki},e??"")))})]}),(0,E.jsxs)("div",{className:"mt-1.5 flex h-6 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Width:"}),(0,E.jsx)(Au,{label:"(Any)",checked:void 0===i.fixedWidth&&void 0===i.minWidth&&void 0===i.maxWidth,onChange:()=>{void 0===i.fixedWidth&&void 0===i.minWidth&&void 0===i.maxWidth?(i.setFixedWidth(300),i.setMinWidth(void 0),i.setMaxWidth(void 0)):(i.setFixedWidth(void 0),i.setMinWidth(void 0),i.setMaxWidth(void 0))}}),(0,E.jsx)(Au,{className:"ml-3",label:"Fixed",checked:void 0!==i.fixedWidth,onChange:()=>{i.setFixedWidth(void 0!==i.fixedWidth?void 0:300),i.setMinWidth(void 0),i.setMaxWidth(void 0)}}),(0,E.jsx)("div",{className:"ml-1 h-[1px] w-2 flex-shrink-0 bg-neutral-400"}),(0,E.jsx)(Nu,{className:"ml-1 w-16 text-sm",min:0,step:50,defaultValue:void 0,isValid:e=>void 0!==e&&e>0,value:i.fixedWidth,setValue:e=>{i.setFixedWidth(e)},disabled:void 0!==i.minWidth||void 0!==i.maxWidth}),(0,E.jsx)(Au,{className:"ml-3",label:"In range",checked:void 0!==i.minWidth||void 0!==i.maxWidth,onChange:()=>{void 0===i.minWidth&&void 0===i.maxWidth?(i.setMinWidth(Di),i.setMaxWidth(void 0),i.setFixedWidth(void 0)):(i.setMinWidth(void 0),i.setMaxWidth(void 0),i.setFixedWidth(void 0))}}),(0,E.jsx)("div",{className:"ml-1 h-[1px] w-2 flex-shrink-0 bg-neutral-400"}),(0,E.jsx)(Nu,{className:"ml-1 w-16 text-sm",min:0,step:50,defaultValue:void 0,isValid:e=>void 0!==e&&e>0,value:i.minWidth,setValue:e=>{i.setMinWidth(e)},disabled:void 0!==i.fixedWidth}),(0,E.jsx)("div",{className:"ml-1 h-[1px] w-1 flex-shrink-0 bg-neutral-400"}),(0,E.jsx)(Nu,{className:"ml-1 w-16 text-sm",min:i.minWidth??0,step:50,defaultValue:void 0,isValid:e=>void 0!==e&&e>=(i.minWidth??0),value:i.maxWidth,setValue:e=>{i.setMaxWidth(e)},disabled:void 0!==i.fixedWidth})]}),(0,E.jsx)("div",{className:"my-2 h-[1px] w-full bg-neutral-200"}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-32 flex-shrink-0 items-center text-sm",children:"Font:"}),(0,E.jsx)(yu,{className:"w-28",onClick:x,open:k,children:i.fontFamily??r.fontFamily}),(0,E.jsxs)(xu,{className:"w-28",...w,children:[[ci.ARIAL,ci.ROBOTO,ci.ROBOTO_CONDENSED].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setFontFamily(e),I()},autoFocus:e===(i.fontFamily??r.fontFamily),children:e},e))),(0,E.jsx)(wu,{}),[ci.GEORGIA,ci.ROBOTO_SERIF,ci.TIMES_NEW_ROMAN].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setFontFamily(e),I()},autoFocus:e===(i.fontFamily??r.fontFamily),children:e},e))),(0,E.jsx)(wu,{}),[ci.JERBRAINS_MONO,ci.ROBOTO_MONO,ci.UBUNTU_MONO].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setFontFamily(e),I()},autoFocus:e===(i.fontFamily??r.fontFamily),children:e},e)))]}),(0,E.jsx)(yu,{className:"ml-1 w-10",onClick:R,open:F,children:i.fontSize??r.fontSize}),(0,E.jsx)(xu,{className:"w-10",...L,children:[4,5,6,7,8,9,10,11,12,14,16,18,20,22,24,26,28,32,36,48,72].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setFontSize(e),O()},autoFocus:e===(i.fontSize??r.fontSize),children:e},e)))}),(0,E.jsxs)("div",{className:"relative ml-2 flex h-5",children:[(0,E.jsx)("button",{title:"Bold",className:Mn("relative flex h-5 w-5 items-center justify-center rounded-bl-sm rounded-tl-sm border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":i.fontBold??r.fontBold}),onClick:()=>i.setFontBold(!(i.fontBold??r.fontBold)),children:(0,E.jsx)(pr.FontBold,{})}),(0,E.jsx)("button",{title:"Italic",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":i.fontItalic??r.fontItalic}),onClick:()=>i.setFontItalic(!(i.fontItalic??r.fontItalic)),children:(0,E.jsx)(pr.FontItalic,{})}),(0,E.jsx)("button",{title:"Underline"+(i.fontUnderline??r.fontUnderline?` (${i.fontUnderline??r.fontUnderline})`:""),className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-r-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":void 0!==(i.fontUnderline??r.fontUnderline)}),onClick:()=>{void 0===(i.fontUnderline??r.fontUnderline)?(i.setFontUnderline(pi.SOLID),i.setFontStrikethrough(!1)):i.setFontUnderline(void 0)},children:(0,E.jsx)(pr.FontUnderline,{})}),(0,E.jsxs)("button",{className:"text-2xs relative -ml-[1px] flex h-5 w-2.5 items-center justify-center border border-l-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-600 focus:z-[1]",onClick:D,children:[(0,E.jsx)("div",{className:Mn("h-4 w-[0.5px] bg-neutral-200",{"opacity-0":void 0!==(i.fontUnderline??r.fontUnderline)})}),(0,E.jsx)(pr.CaretDown,{})]}),(0,E.jsx)(xu,{className:"w-14",...B,children:[pi.SOLID,pi.DASHED,pi.DOTTED,pi.DOUBLE,pi.WAVY].map((e=>(0,E.jsx)(Iu,{className:"relative",onClick:()=>{i.setFontUnderline(e),i.setFontStrikethrough(!1),P()},autoFocus:e===(i.fontUnderline??r.fontUnderline),children:(0,E.jsx)("div",{className:Mn("!hover:underline absolute top-0 !underline",{"!hover:decoration-solid !decoration-solid":e===pi.SOLID,"!hover:decoration-dashed !decoration-dashed":e===pi.DASHED,"!hover:decoration-dotted !decoration-dotted":e===pi.DOTTED,"!hover:decoration-double !decoration-double":e===pi.DOUBLE,"!hover:decoration-wavy !decoration-wavy":e===pi.WAVY}),children:"                "})},e)))}),(0,E.jsx)("button",{title:"Strikethrough",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":i.fontStrikethrough??r.fontStrikethrough}),onClick:()=>{i.fontStrikethrough??r.fontStrikethrough?i.setFontStrikethrough(!1):(i.setFontStrikethrough(!0),i.setFontUnderline(void 0))},children:(0,E.jsx)(pr.FontStrikethrough,{})}),(0,E.jsx)("button",{title:"Case"+(i.fontCase??r.fontCase?` (${i.fontCase??r.fontCase})`:""),className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-r-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":void 0!==(i.fontCase??r.fontCase)}),onClick:()=>{void 0===(i.fontCase??r.fontCase)?i.setFontCase(di.UPPERCASE):i.setFontCase(void 0)},children:(0,E.jsx)(pr.FontCase,{className:"stroke-[0.5px]"})}),(0,E.jsxs)("button",{className:"text-2xs relative -ml-[1px] flex h-5 w-2.5 items-center justify-center rounded-br-sm rounded-tr-sm border border-l-0 border-neutral-400 bg-neutral-50 p-0 text-neutral-600 focus:z-[1]",onClick:j,children:[(0,E.jsx)("div",{className:Mn("h-4 w-[0.5px] bg-neutral-200",{"opacity-0":void 0!==(i.fontCase??r.fontCase)})}),(0,E.jsx)(pr.CaretDown,{})]}),(0,E.jsx)(xu,{className:"w-20",...U,children:[di.LOWERCASE,di.UPPERCASE,di.CAPITALIZE].map((e=>(0,E.jsx)(Iu,{onClick:()=>{i.setFontCase(e),M()},autoFocus:e===(i.fontCase??r.fontCase),children:(0,E.jsx)("div",{className:Mn({lowercase:e===di.LOWERCASE,uppercase:e===di.UPPERCASE,capitalize:e===di.CAPITALIZE}),children:e})},e)))})]}),(0,E.jsxs)("div",{className:"relative ml-2 flex h-5",children:[(0,E.jsx)("button",{title:"Align Left",className:Mn("relative flex h-5 w-5 items-center justify-center rounded-bl-sm rounded-tl-sm border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":(i.textAlign??r.textAlign)===ui.LEFT}),onClick:()=>i.setTextAlign(ui.LEFT),children:(0,E.jsx)(pr.TextAlignLeft,{})}),(0,E.jsx)("button",{title:"Align Center",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":(i.textAlign??r.textAlign)===ui.CENTER}),onClick:()=>i.setTextAlign(ui.CENTER),children:(0,E.jsx)(pr.TextAlignCenter,{})}),(0,E.jsx)("button",{title:"Align Right",className:Mn("relative -ml-[1px] flex h-5 w-5 items-center justify-center rounded-br-sm rounded-tr-sm border border-neutral-400 bg-neutral-50 p-0 text-neutral-700 focus:z-[1]",{"bg-neutral-200":(i.textAlign??r.textAlign)===ui.RIGHT}),onClick:()=>i.setTextAlign(ui.RIGHT),children:(0,E.jsx)(pr.TextAlignRight,{})})]})]}),(0,E.jsxs)("div",{className:"mt-2 flex w-full",children:[(0,E.jsx)("div",{className:"flex h-6 w-32 flex-shrink-0 items-center text-sm",children:"Colors:"}),(0,E.jsxs)("div",{className:"h-18",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"w-16 flex-shrink-0"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Normal"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Negative"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Zero"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center text-sm",children:"Error"})]}),(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-full w-16 flex-shrink-0 items-center text-sm",children:"Foreground:"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.normalForegroundColor??r.normalForegroundColor,defaultColor:r.normalForegroundColor,onChange:e=>i.setNormalForegroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.negativeForegroundColor??r.negativeForegroundColor,defaultColor:r.negativeForegroundColor,onChange:e=>i.setNegativeForegroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.zeroForegroundColor??r.zeroForegroundColor,defaultColor:r.zeroForegroundColor,onChange:e=>i.setZeroForegroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.errorForegroundColor??r.errorForegroundColor,defaultColor:r.errorForegroundColor,onChange:e=>i.setErrorForegroundColor(e)})})]}),(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-full w-16 flex-shrink-0 items-center text-sm",children:"Background:"}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.normalBackgroundColor??r.normalBackgroundColor,defaultColor:r.normalBackgroundColor,onChange:e=>i.setNormalBackgroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.negativeBackgroundColor??r.negativeBackgroundColor,defaultColor:r.negativeBackgroundColor,onChange:e=>i.setNegativeBackgroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.zeroBackgroundColor??r.zeroBackgroundColor,defaultColor:r.zeroBackgroundColor,onChange:e=>i.setZeroBackgroundColor(e)})}),(0,E.jsx)("div",{className:"flex h-full w-12 flex-shrink-0 items-center justify-center",children:(0,E.jsx)(Ru,{color:i.errorBackgroundColor??r.errorBackgroundColor,defaultColor:r.errorBackgroundColor,onChange:e=>i.setErrorBackgroundColor(e)})})]})]})]}),(0,E.jsxs)("div",{className:"mt-2 flex w-full",children:[(0,E.jsx)("div",{className:"flex h-6 w-32 flex-shrink-0 items-center text-sm"}),(0,E.jsxs)("div",{className:"w-80",children:[(0,E.jsx)("div",{className:"mb-2 h-[1px] w-full bg-neutral-200"}),(0,E.jsx)(Tu,{compact:!0,disabled:i.isUsingDefaultStyling,onClick:()=>i.useDefaultStyling(),children:"Use Default Styling"})]})]})]})]})})]})}));class jm{name;isRenaming=!1;columns=[];constructor(e){(0,Ie.Gn)(this,{name:Ie.sH,setName:Ie.XI,isRenaming:Ie.sH,setIsRenaming:Ie.XI,columns:Ie.sH,setColumns:Ie.XI}),this.name=e}setName(e){this.name=e}setIsRenaming(e){this.isRenaming=e}setColumns(e){this.columns=e}}class Mm{_editor;availableColumnsSearchText="";dimensions=[];dimensionsTreeData={nodes:[]};dimensionsTreeSearchText="";constructor(e){(0,Ie.Gn)(this,{availableColumns:Ie.EW,availableColumnsForDisplay:Ie.EW,availableColumnsSearchText:Ie.sH,setAvailableColumnsSearchText:Ie.XI,selectedColumns:Ie.EW,deselectColumns:Ie.XI,dimensions:Ie.sH,setDimensions:Ie.XI,newDimension:Ie.XI,dimensionsTreeData:Ie.sH.ref,refreshDimensionsTreeData:Ie.XI,dimensionsTreeSearchText:Ie.sH,setDimensionsTreeSearchText:Ie.XI}),this._editor=e}get availableColumns(){return this._editor.columnProperties.columns.filter((e=>e.kind===mi.DIMENSION&&!ra(this._editor.groupExtendColumns,e.name)&&!ra(this._editor.horizontalPivots.selector.selectedColumns,e.name))).map((e=>new dm(e.name,e.type)))}get availableColumnsForDisplay(){return this.availableColumns.filter((e=>!ra(this.selectedColumns,e.name))).sort(aa)}setAvailableColumnsSearchText(e){this.availableColumnsSearchText=e}get selectedColumns(){return this.dimensions.flatMap((e=>e.columns))}deselectColumns(e){this.dimensions.forEach((t=>{t.setColumns(t.columns.filter((t=>!ra(e,t.name))))}))}setDimensions(e){this.dimensions=e}newDimension(){const e=new jm(((e,t,n="underscore")=>{if(!t.match(/^[\w_-]+$/))throw new Error("Token must only contain digits, letters, or special characters _ and -");const o="whitespace"===n?" ":"_",r=e.map((e=>{const n=e.match(new RegExp(`^${t}${o}(?<count>\\d+)$`));return n?.groups?.count?parseInt(n.groups.count,10):0})).reduce(((e,t)=>Math.max(e,t)),0);return`${t}${o}${r+1}`})(this.dimensions.map((e=>e.name)),"Dimension","whitespace"));return this.dimensions.push(e),e}refreshDimensionsTreeData(){this.dimensionsTreeData={nodes:this.dimensions.map((e=>({name:e.name,data:e,children:e.columns.map((e=>({name:e.name,data:e})))})))}}setDimensionsTreeSearchText(e){this.dimensionsTreeSearchText=e}adaptPropagatedChanges(){this.deselectColumns(this.selectedColumns.filter((e=>!ra(this.availableColumns,e.name)))),this.refreshDimensionsTreeData()}applySnaphot(e,t){this.setDimensions(t.dimensions.dimensions.map((e=>{const n=new jm(e.name);return n.setColumns(e.columns.map((e=>{const n=D(ra(t.columns,e));return new dm(n.name,n.type)}))),n}))),this.refreshDimensionsTreeData()}buildSnapshot(e,t){const n=new ua;this._editor.generalProperties.configuration.gridMode===Ti.MULTIDIMENSIONAL?(n.dimensions=this.dimensions.map((e=>({name:e.name,columns:e.columns.map((e=>e.name))}))),e.data.configuration={...e.data.configuration,dimensions:ua.serialization.toJson(n)}):e=t}}console.error;const Um=(0,vt.PA)((e=>{const{panel:t,gridApi:n}=e;return(0,E.jsxs)("div",{className:"flex items-center justify-center rounded-lg bg-neutral-500 px-1 py-0.5 font-mono text-xs font-bold text-white",children:[`${kp(n).length}/${t.availableColumnsForDisplay.length}`,(0,E.jsx)("span",{className:"hidden",children:t.availableColumnsSearchText})]})})),Gm=(0,vt.PA)((e=>{const{panel:t,gridApi:n}=e;return(0,E.jsxs)("div",{className:"flex items-center justify-center rounded-lg bg-neutral-500 px-1 py-0.5 font-mono text-xs font-bold text-white",children:[`${kp(n).map((e=>e.data)).filter((e=>e instanceof jm)).length}/${t.dimensions.length}`,(0,E.jsx)("span",{className:"hidden",children:t.dimensionsTreeSearchText})]})})),Hm=(0,vt.PA)((e=>{const{panel:t,dimension:n,gridApi:o}=e,r=(0,Ft.useRef)(null),[i,a]=(0,Ft.useState)(n.name),s=!(""===i.trim()||(Boolean(t.dimensions.filter((e=>e.name!==n.name)).find((e=>e.name===i)))||void 0)),l=()=>{s&&(n.setName(i),n.setIsRenaming(!1),o.clearFocusedCell())};return(0,Ft.useEffect)((()=>{a(n.name)}),[n.name]),(0,Ft.useEffect)((()=>{n.isRenaming&&r.current?.focus()}),[n.isRenaming]),(0,E.jsxs)("div",{className:"flex h-full w-full items-center pl-1",title:`[Dimension: ${n.name}]\nDouble-click to remove all columns`,children:[(0,E.jsx)("div",{className:"text-2xs flex h-3 flex-shrink-0 items-center justify-center rounded-sm bg-neutral-500 px-1 font-bold text-white",children:"DIM"}),!n.isRenaming&&(0,E.jsx)("div",{className:"h-full flex-1 cursor-pointer items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-1",title:"Double-click to remove dimension",onDoubleClickCapture:e=>{e.stopPropagation(),n.setIsRenaming(!0),o.clearFocusedCell()},children:n.name}),n.isRenaming&&(0,E.jsxs)("div",{className:"relative flex items-center",onDoubleClickCapture:e=>{e.stopPropagation(),o.clearFocusedCell()},children:[(0,E.jsx)("input",{ref:r,className:Mn("ml-0.5 h-4 border border-neutral-300 pl-[1px] pr-6 focus:border-sky-600 focus:!outline-none",{"border-red-600 focus:border-red-600":!s}),value:i,onChange:e=>{a(e.target.value)},onKeyDown:e=>{"Escape"===e.code&&(r.current?.focus(),r.current?.select())},onKeyDownCapture:e=>{"Enter"===e.code&&(e.stopPropagation(),l())},onBlur:()=>{n.setIsRenaming(!1),a(n.name)}}),s&&(0,E.jsx)("button",{className:"text-2xs absolute right-0.5 flex h-3 w-5 items-center justify-center rounded-sm bg-sky-600 text-white",onClick:e=>{e.stopPropagation(),l()},children:"Save"})]})]})}));function Vm(e,t){e.alertService.alert({message:"No target dimensions to add columns to",text:"Columns need to be added to a dimension, but no dimension has been specified.\nDo you want to proceed with creating a new dimension and add the columns to it?",type:Mu.WARNING,actions:[{label:"Proceed",handler:t},{label:"Cancel",handler:()=>{}}],windowConfig:{...Er,width:550,height:180}})}function Wm(e){let t=-1===e.overIndex?void 0:e.overIndex;return void 0!==t&&e.y%20<10&&(t-=1),{overIndex:t,overNode:void 0!==t?Ip(e.api).at(-1===t?0:t):void 0}}const zm=(0,vt.PA)((e=>{const{view:t}=e,n=t.editor,o=n.dimensions,r=(0,Ft.useRef)(null),i=(0,Ft.useRef)(null),[a,s]=(0,Ft.useState)([]),[l,c]=(0,Ft.useState)([]),[u,d]=(0,Ft.useState)([]),[p,m]=(0,Ft.useState)(null),[g,h]=(0,Ft.useState)(null),f=(0,Ft.useCallback)((e=>{const t=e.nodes.map((e=>e.data?.data)).filter((n=dm,e=>((e,t)=>e instanceof t)(e,n)));var n;o.deselectColumns(t),o.refreshDimensionsTreeData()}),[o]),C=(0,Ft.useCallback)((e=>{const{overNode:n}=Wm(e),r=e.nodes.map((e=>e.data)).filter(L),i=(n?.data?n.data.data instanceof jm?n.data.data:n.parent?.data?.data instanceof jm?n.parent.data.data:void 0:void 0)??o.dimensions.at(-1);if(i){const e=n?.data?.data instanceof dm?i.columns.indexOf(n.data.data):n?.data?.data instanceof jm?-1:void 0;i.setColumns(void 0!==e?[...i.columns.slice(0,e+1),...r,...i.columns.slice(e+1)]:[...i.columns,...r]),o.refreshDimensionsTreeData()}else Vm(t,(()=>{o.newDimension().setColumns([...r]),o.refreshDimensionsTreeData()}))}),[o,t]);(0,Ft.useEffect)((()=>{if(!p||!g)return;const e=g.isDestroyed()?void 0:g.getRowDropZoneParams({onDragStop:e=>{C(e),p.clearFocusedCell()}});e&&!p.isDestroyed()&&p.addRowDropZone(e);const t=p.isDestroyed()?void 0:p.getRowDropZoneParams({onDragStop:e=>{f(e),g.clearFocusedCell()}});t&&!g.isDestroyed()&&g.addRowDropZone(t)}),[p,g,C,f]);const[b,v]=(0,Ft.useState)(void 0),_=0===u.length||0===l.length,T=(0,Ft.useCallback)((e=>{const{overIndex:t,overNode:n}=Wm(e);v(void 0);const r=e.nodes.map((e=>e.data)).filter((e=>!(e instanceof jm)));if(0===r.length)return;const i=[],a=[];if(r.forEach((e=>{e.data instanceof jm?a.push(e.data):e.data instanceof dm&&i.push(e.data)})),!(i.length>0&&a.length>0)){if(a.length>0){let e;if(-1===t)e=-1;else if(void 0!==n){const t=n.data?n.data.data instanceof jm?n.data.data:n.parent?.data?.data instanceof jm?n.parent.data.data:void 0:void 0;if(t){const n=o.dimensions.indexOf(t);e=-1===n?-1:n-o.dimensions.slice(0,n+1).filter((e=>a.find((t=>e.name===t.name)))).length}}const r=o.dimensions.filter((e=>!a.find((t=>e.name===t.name))));return o.setDimensions(void 0!==e?[...r.slice(0,e+1),...a,...r.slice(e+1)]:[...r,...a]),void o.refreshDimensionsTreeData()}if(i.length>0){const e=(n?.data?n.data.data instanceof jm?n.data.data:n.parent?.data?.data instanceof jm?n.parent.data.data:void 0:void 0)??o.dimensions.at(-1);if(e){let t;if(n?.data?.data instanceof jm)t=-1;else if(n?.data?.data instanceof dm){const o=e.columns.indexOf(n.data.data);t=-1===o?-1:o-e.columns.slice(0,o+1).filter((e=>ra(i,e.name))).length}o.deselectColumns(i),e.setColumns(void 0!==t?[...e.columns.slice(0,t+1),...i,...e.columns.slice(t+1)]:[...e.columns,...i]),o.refreshDimensionsTreeData()}}}}),[o]),N=(0,Ft.useCallback)((e=>{const{overIndex:t,overNode:n}=Wm(e);v(t),e.api.refreshCells({rowNodes:n?[n]:[],force:!0})}),[]),S=(0,Ft.useCallback)((e=>{v(void 0)}),[]),A=(0,Ft.useCallback)((e=>{v(void 0)}),[]);return(0,Ft.useEffect)((()=>{o.dimensions.forEach((e=>e.setIsRenaming(!1))),v(void 0)}),[o]),(0,E.jsxs)("div",{className:"h-full w-full select-none p-2",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsx)("div",{className:"flex h-6 items-center text-xl font-medium",children:(0,E.jsx)(pr.TableDimension,{})}),(0,E.jsxs)("div",{className:"ml-1 flex h-6 items-center text-xl font-medium",children:["Dimensions",(0,E.jsx)(vu,{})]})]}),(0,E.jsxs)("div",{className:"h-[calc(100%_-_24px)] w-full",children:[(0,E.jsx)("div",{className:"h-10 py-2",children:(0,E.jsx)("div",{className:"flex h-6 w-full items-center",children:(0,E.jsx)(Au,{label:"Enable multidimensional grid mode",checked:n.generalProperties.configuration.gridMode===Ti.MULTIDIMENSIONAL,onChange:()=>{n.generalProperties.configuration.gridMode===Ti.MULTIDIMENSIONAL?n.generalProperties.configuration.setGridMode(Ti.STANDARD):0!==n.verticalPivots.selector.selectedColumns.length&&0===o.dimensions.length?t.alertService.alert({message:"Specified vertical pivots will be ignored in multidimensional grid mode.",text:"Multidimensional grid mode will ignore any specified vertical pivots, essentially, vertical pivot columns can be considered as one dimension.\nFor convenience, these vertical pivots can be converted into a dimension, do you want this conversion to happen?",type:Mu.WARNING,actions:[{label:"Yes",handler:()=>{const e=n.verticalPivots.selector.selectedColumns;o.newDimension().setColumns(o.availableColumns.filter((t=>ra(e,t.name)))),n.verticalPivots.selector.setSelectedColumns([]),o.refreshDimensionsTreeData(),n.generalProperties.configuration.setGridMode(Ti.MULTIDIMENSIONAL)}},{label:"No",handler:()=>{n.generalProperties.configuration.setGridMode(Ti.MULTIDIMENSIONAL)}}],windowConfig:{...Er,width:550,height:220}}):n.generalProperties.configuration.setGridMode(Ti.MULTIDIMENSIONAL)}})})}),n.generalProperties.configuration.gridMode!==Ti.MULTIDIMENSIONAL&&(0,E.jsx)(Fu,{message:"Multidimensional grid mode is experimental",type:Mu.WARNING,text:'This is an alternative grid view for DataCube with a different mode of interaction: dimensions (ordered list of columns to group by) are defined and will be used to explore data "top-down". Initially, the grid will show the root aggregation, then user can drill down into each dimension. This grid mode comes with the following limitations:\n- Specified vertical pivots will be ignored: essentially, vertical pivot can be considered as one dimension in this mode\n- No support for pagination\n- Initial view can take longer to materialize if drilldown is deep'}),n.generalProperties.configuration.gridMode===Ti.MULTIDIMENSIONAL&&(0,E.jsx)("div",{className:"flex h-[calc(100%_-_40px)] w-full",children:(0,E.jsxs)("div",{className:"data-cube-column-selector flex h-full w-full",children:[(0,E.jsxs)("div",{className:"h-full w-[calc(50%_-_20px)]",children:[(0,E.jsx)("div",{className:"flex h-5 items-center text-sm",children:"Available columns:"}),(0,E.jsxs)("div",{className:"h-[calc(100%_-_20px)] rounded-sm border border-neutral-200",children:[(0,E.jsxs)("div",{className:"relative h-6 border-b border-neutral-200",children:[(0,E.jsx)("input",{className:"h-full w-full pl-10 pr-6 placeholder-neutral-400",ref:r,placeholder:"Search columns...",value:o.availableColumnsSearchText,onChange:e=>o.setAvailableColumnsSearchText(e.target.value),onKeyDown:e=>{"Escape"===e.code&&(e.stopPropagation(),r.current?.select(),o.setAvailableColumnsSearchText(""))}}),(0,E.jsx)("div",{className:"absolute left-0 top-0 flex h-6 w-10 items-center justify-center",children:(0,E.jsx)(pr.Search,{className:"stroke-[3px] text-lg text-neutral-500"})}),(0,E.jsx)("button",{className:"absolute right-0 top-0 flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",disabled:!o.availableColumnsSearchText,title:"Clear search [Esc]",onClick:()=>{o.setAvailableColumnsSearchText(""),r.current?.focus()},children:(0,E.jsx)(pr.X,{className:"text-lg"})})]}),(0,E.jsx)("div",{className:"h-[calc(100%_-_24px)]",children:(0,E.jsx)(Ir.W6,{...Am(),rowDragManaged:!1,onGridReady:e=>m(e.api),onSelectionChanged:e=>{s(e.api.getSelectedNodes().map((e=>e.data)).filter(L))},quickFilterText:o.availableColumnsSearchText,rowData:o.availableColumnsForDisplay,rowClass:"border-t border-b border-1 border-transparent",columnDefs:[{field:"name",colId:"name",flex:1,minWidth:100,filter:!0,sortable:!1,resizable:!1,suppressHeaderMenuButton:!0,getQuickFilterText:e=>e.value,headerComponent:e=>(0,E.jsxs)("button",{title:"Double-click to add all columns",className:"flex h-full w-full items-center justify-between pl-0.5",onDoubleClick:()=>{const n=kp(e.api),r=o.dimensions.at(-1);r?(r.setColumns([...r.columns,...n]),o.refreshDimensionsTreeData()):Vm(t,(()=>{o.newDimension().setColumns([...n]),o.refreshDimensionsTreeData()})),e.api.clearFocusedCell()},children:[(0,E.jsx)("div",{children:"[All Columns]"}),(0,E.jsx)(Um,{panel:o,gridApi:e.api})]}),cellRenderer:e=>{const n=e.data;return n?(0,E.jsx)("div",{className:"flex h-full w-full cursor-pointer items-center",title:`[${n.name}]\nDouble-click to add column`,onDoubleClick:()=>{const r=o.dimensions.at(-1);r?(r.setColumns([...r.columns,n]),o.refreshDimensionsTreeData()):Vm(t,(()=>{o.newDimension().setColumns([n]),o.refreshDimensionsTreeData()})),e.api.clearFocusedCell()},children:(0,E.jsx)("div",{className:"h-full flex-1 items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-2",children:n.name})}):null}}]})})]})]}),(0,E.jsx)("div",{className:"flex h-full w-10 items-center justify-center",children:(0,E.jsxs)("div",{className:"flex flex-col",children:[(0,E.jsx)("button",{className:"flex items-center justify-center rounded-sm border border-neutral-300 bg-neutral-100 text-neutral-500 hover:bg-neutral-200 disabled:bg-neutral-200 disabled:text-neutral-400",title:"Add selected column(s)",onClick:()=>{if(!p||0===a.length)return;const e=kp(p),n=a.filter((t=>ra(e,t.name))),r=o.dimensions.at(-1);r?(r.setColumns([...r.columns,...n]),o.refreshDimensionsTreeData()):Vm(t,(()=>{o.newDimension().setColumns([...n]),o.refreshDimensionsTreeData()})),p.clearFocusedCell()},disabled:!p||0===a.length,children:(0,E.jsx)(pr.ChevronRight,{className:"text-2xl"})}),(0,E.jsx)("button",{className:"mt-2 flex items-center justify-center rounded-sm border border-neutral-300 bg-neutral-100 text-neutral-500 hover:bg-neutral-200 disabled:bg-neutral-200 disabled:text-neutral-400",title:"Remove selected column(s)",onClick:()=>{if(!g||0===l.length)return;const e=kp(g),t=l.filter((t=>ra(e,t.name)));o.deselectColumns(t),o.refreshDimensionsTreeData(),g.clearFocusedCell()},disabled:!g||0===l.length,children:(0,E.jsx)(pr.ChevronLeft,{className:"text-2xl"})})]})}),(0,E.jsxs)("div",{className:"data-cube-tree-selector h-full w-[calc(50%_-_20px)]",children:[(0,E.jsx)("div",{className:"flex h-5 items-center text-sm",children:"Dimensions:"}),(0,E.jsxs)("div",{className:"h-[calc(100%_-_20px)] rounded-sm border border-neutral-200",children:[(0,E.jsxs)("div",{className:"flex h-6",children:[(0,E.jsxs)("div",{className:"relative h-6 w-[calc(100%_-_124px)] border-b border-r border-neutral-200",children:[(0,E.jsx)("input",{className:"h-full w-full pl-10 pr-6 placeholder-neutral-400",ref:i,placeholder:"Search...",value:o.dimensionsTreeSearchText,onChange:e=>o.setDimensionsTreeSearchText(e.target.value),onKeyDown:e=>{"Escape"===e.code&&(e.stopPropagation(),i.current?.select(),o.setDimensionsTreeSearchText(""))}}),(0,E.jsx)("div",{className:"absolute left-0 top-0 flex h-6 w-10 items-center justify-center",children:(0,E.jsx)(pr.Search,{className:"stroke-[3px] text-lg text-neutral-500"})}),(0,E.jsx)("button",{className:"absolute right-0 top-0 flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",disabled:!o.dimensionsTreeSearchText,title:"Clear search [Esc]",onClick:()=>{o.setDimensionsTreeSearchText(""),i.current?.focus()},children:(0,E.jsx)(pr.X,{className:"text-lg"})})]}),(0,E.jsxs)("div",{className:"flex h-6 items-center border-b border-neutral-200",children:[(0,E.jsx)("button",{className:"flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",title:"Add new dimension",onClick:()=>{o.newDimension(),o.refreshDimensionsTreeData()},children:(0,E.jsx)(pr.Plus,{className:"text-lg"})}),(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsx)("button",{className:"flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",title:"Move dimension(s) up",disabled:0===u.length,onClick:()=>{if(0===u.length)return;const e=Math.min(...u.map((e=>o.dimensions.indexOf(e)))),t=[...o.dimensions.slice(0,Math.max(e-1,0)),...o.dimensions.map((e=>u.find((t=>t.name===e.name)))).filter(L)];o.setDimensions([...t,...o.dimensions.filter((e=>!t.find((t=>t.name===e.name))))]),o.refreshDimensionsTreeData()},children:(0,E.jsx)(pr.ChevronUp,{className:"text-lg"})}),(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsx)("button",{className:"flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",title:"Move dimension(s) down",disabled:0===u.length,onClick:()=>{if(0===u.length)return;const e=Math.max(...u.map((e=>o.dimensions.indexOf(e)))),t=[...o.dimensions.map((e=>u.find((t=>t.name===e.name)))).filter(L),...o.dimensions.slice(Math.min(e+1,o.dimensions.length)+1)];o.setDimensions([...o.dimensions.filter((e=>!t.find((t=>t.name===e.name)))),...t]),o.refreshDimensionsTreeData()},children:(0,E.jsx)(pr.ChevronDown,{className:"text-lg"})}),(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsx)("button",{className:"flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",title:"Remove dimension(s)",disabled:0===u.length,onClick:()=>{0!==u.length&&u.at(0)?.setIsRenaming(!0)},children:(0,E.jsx)(pr.Pencil,{className:"text-lg"})}),(0,E.jsx)("div",{className:"h-3 w-[1px] bg-neutral-200"}),(0,E.jsx)("button",{className:"flex h-6 w-6 items-center justify-center text-neutral-500 disabled:text-neutral-300",title:"Rename dimension",disabled:0===u.length,onClick:()=>{0!==u.length&&(o.setDimensions(o.dimensions.filter((e=>!u.find((t=>t.name===e.name))))),o.refreshDimensionsTreeData())},children:(0,E.jsx)(pr.Delete,{className:"text-lg"})})]})]}),(0,E.jsx)("div",{className:"h-[calc(100%_-_24px)]",children:(0,E.jsx)(Ir.W6,{...Am(),modules:[yr.JKr,xr.vl5],className:"ag-theme-quartz",treeData:!0,treeDataChildrenField:"children",groupDefaultExpanded:-1,onGridReady:e=>{h(e.api)},onSelectionChanged:e=>{const t=e.api.getSelectedNodes().map((e=>e.data)).filter(L),n=[],o=[];t.forEach((e=>{e.data instanceof jm?o.push(e.data):e.data instanceof dm&&n.push(e.data)})),d(o),c(n)},rowSelection:{mode:"multiRow",groupSelects:"self"},columnDefs:[],quickFilterText:o.dimensionsTreeSearchText,rowData:o.dimensionsTreeData.nodes,rowClassRules:{"border-t border-b border-1 border-transparent":()=>!0,"border-b-sky-600":e=>void 0!==b&&e.rowIndex===b,"border-t-sky-600":e=>-1===b&&0===e.rowIndex},autoGroupColumnDef:{headerName:"Name",field:"name",colId:"name",flex:1,minWidth:100,filter:!0,sortable:!1,resizable:!1,suppressHeaderMenuButton:!0,suppressKeyboardEvent:e=>!!o.dimensions.some((e=>e.isRenaming))&&"Tab"!==e.event.code,getQuickFilterText:e=>e.value,headerComponent:e=>(0,E.jsxs)("button",{title:"Double-click to remove all columns",className:"flex h-full w-full items-center justify-between pl-0.5",onDoubleClick:()=>{const t=kp(e.api);o.deselectColumns(o.selectedColumns.filter((e=>ra(t,e.name)))),o.refreshDimensionsTreeData(),e.api.clearFocusedCell()},children:[(0,E.jsx)("div",{children:"[All Dimensions]"}),(0,E.jsx)(Gm,{panel:o,gridApi:e.api})]}),onCellDoubleClicked:e=>{e.data?.data instanceof jm&&(e.data.data.setColumns([]),o.refreshDimensionsTreeData(),e.api.clearFocusedCell())},cellRendererParams:{innerRenderer:e=>{const t=e.data;return t?t.data instanceof jm?(0,E.jsx)(Hm,{panel:o,dimension:t.data,gridApi:e.api}):(0,E.jsx)("div",{className:"flex h-full w-full cursor-pointer items-center",title:`[${t.name}]\nDouble-click to remove column`,onDoubleClick:()=>{t.data instanceof dm&&(o.deselectColumns([t.data]),o.refreshDimensionsTreeData()),e.api.clearFocusedCell()},children:(0,E.jsx)("div",{className:"h-full flex-1 items-center overflow-hidden overflow-ellipsis whitespace-nowrap pl-1",children:t.name})}):null}}},noRowsOverlayComponent:e=>e.api.getQuickFilter()?(0,E.jsxs)("div",{className:"flex items-center border-[1.5px] border-neutral-300 p-2 font-semibold text-neutral-400",children:[(0,E.jsx)("div",{children:(0,E.jsx)(pr.WarningCircle,{className:"mr-1 text-lg"})}),"No match found"]}):(0,E.jsxs)("div",{className:"flex items-center border-[1.5px] border-neutral-200 p-2 font-semibold text-neutral-400",children:[(0,E.jsx)("div",{children:(0,E.jsx)(pr.Warning,{className:"mr-1 text-lg"})}),"No dimensions specified"]}),suppressRowDrag:!_,rowDragEntireRow:_,onRowDragEnd:T,onRowDragMove:N,onRowDragCancel:S,onRowDragLeave:A})})]})]})]})})]})]})})),$m=(0,vt.PA)((e=>{const t=bu().alertService,{view:n}=e,o=n.editor,r=o.currentTab,i=[Jm.COLUMNS,Jm.HORIZONTAL_PIVOTS,Jm.VERTICAL_PIVOTS,Jm.DIMENSIONS,Jm.SORTS,Jm.GENERAL_PROPERTIES,Jm.COLUMN_PROPERTIES],a=[Jm.DIMENSIONS],s=()=>{n.dataCube.telemetryService.sendTelemetry(Ud.APPLY_CHANGES_PROPERTIES,n.engine.getDataFromSource(n.getInitialSource()))};return(0,Ft.useEffect)((()=>{ea(n.info.configuration.gridMode)&&o.setCurrentTab(Jm.DIMENSIONS)}),[n,o]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)("div",{className:"relative h-[calc(100%_-_40px)] w-full px-2 pt-8",children:[(0,E.jsx)("div",{className:"absolute top-0 flex h-9 w-[calc(100%_-_16px)] overflow-y-hidden pt-2",children:i.map((e=>(0,E.jsx)("button",{onClick:()=>o.setCurrentTab(e),disabled:ea(n.info.configuration.gridMode)&&!a.includes(e),className:Mn("relative flex h-6 items-center justify-center whitespace-nowrap border border-b-0 border-l-0 border-neutral-300 px-2 first:border-l focus:z-10 disabled:text-neutral-400",{"-top-0.5 h-[27px] border-b-0 bg-white":e===r}),children:e},e)))}),(0,E.jsxs)("div",{className:"h-full w-full overflow-auto border border-neutral-300 bg-white",children:[r===Jm.COLUMNS&&(0,E.jsx)(Fm,{view:n}),r===Jm.HORIZONTAL_PIVOTS&&(0,E.jsx)(Pm,{view:n}),r===Jm.VERTICAL_PIVOTS&&(0,E.jsx)(Dm,{view:n}),r===Jm.DIMENSIONS&&(0,E.jsx)(zm,{view:n}),r===Jm.SORTS&&(0,E.jsx)(km,{view:n}),r===Jm.GENERAL_PROPERTIES&&(0,E.jsx)(Om,{view:n}),r===Jm.COLUMN_PROPERTIES&&(0,E.jsx)(Bm,{view:n})]})]}),(0,E.jsxs)("div",{className:"flex h-10 items-center justify-end px-2",children:[(0,E.jsx)(Tu,{onClick:()=>o.display.close(),children:"Cancel"}),(0,E.jsx)(Tu,{className:"ml-2",disabled:o.finalizationState.isInProgress,onClick:()=>{s(),o.applyChanges().catch((e=>t.alertUnhandledError(e)))},children:"Apply"}),(0,E.jsx)(Tu,{className:"ml-2",disabled:o.finalizationState.isInProgress,onClick:()=>{s(),o.applyChanges({closeAfterApply:!0}).catch((e=>t.alertUnhandledError(e)))},children:"OK"})]})]})}));class Ym extends pm{cloneColumn(e){return new mm(e.name,e.type,e.direction,e.onChange)}get availableColumns(){return this._editor.columnProperties.columns.filter((e=>e.kind===mi.DIMENSION&&!ra(this._editor.groupExtendColumns,e.name))).map((e=>new mm(e.name,e.type,bi.ASCENDING,(()=>this.onChange?.(this)))))}}class Xm{_editor;selector;castColumns=[];constructor(e){(0,Ie.Gn)(this,{castColumns:Ie.sH.ref,pivotResultColumns:Ie.EW,setCastColumns:Ie.XI,applySnaphot:Ie.XI}),this._editor=e,this.selector=new Ym(e,{onChange:e=>{this._editor.columnProperties.columns.forEach((t=>t.setPivotSortDirection(ra(e.selectedColumns,t.name)?.direction)))}})}get pivotResultColumns(){return this.castColumns.filter((e=>na(e.name))).map(ia)}setCastColumns(e){this.castColumns=e}propagateChanges(){this._editor.verticalPivots.adaptPropagatedChanges(),this._editor.dimensions.adaptPropagatedChanges(),this._editor.sorts.adaptPropagatedChanges()}applySnaphot(e,t){this.selector.setSelectedColumns((e.data.pivot?.columns??[]).map((e=>new mm(e.name,e.type,ra(t.columns,e.name)?.pivotSortDirection??bi.ASCENDING,(()=>this.selector.onChange?.(this.selector)))))),this.setCastColumns(e.data.pivot?.castColumns??[])}buildSnapshot(e,t){e.data.pivot=this.selector.selectedColumns.length?{columns:this.selector.selectedColumns.map(ia),castColumns:this.castColumns.map(ia)}:void 0,e.data.selectColumns=(0,nt.A)([...e.data.selectColumns,...this.selector.selectedColumns],(e=>e.name)).map(ia)}}class Km{_editor;pivotLayout=new Em;constructor(e){(0,Ie.Gn)(this,{pivotLayout:Ie.sH,applySnaphot:Ie.XI}),this._editor=e}applySnaphot(e,t){this.pivotLayout=Em.create(e.data.configuration.pivotLayout)}buildSnapshot(e,t){this.pivotLayout.setExpandedPaths(xc(t.data.groupBy?.columns??[],this._editor.verticalPivots.selector.selectedColumns,this.pivotLayout.expandedPaths)),e.data.configuration={...e.data.configuration,pivotLayout:this.pivotLayout.serialize()}}}class qm extends A{sourceInformation}var Jm;!function(e){e.GENERAL_PROPERTIES="General Properties",e.COLUMN_PROPERTIES="Column Properties",e.COLUMNS="Columns",e.VERTICAL_PIVOTS="Vertical Pivots",e.DIMENSIONS="Dimensions",e.HORIZONTAL_PIVOTS="Horizontal Pivots",e.SORTS="Sorts"}(Jm||(Jm={}));class Qm extends om{view;display;finalizationState=we.create();generalProperties;pivotLayout;columnProperties;columns;horizontalPivots;verticalPivots;dimensions;sorts;currentTab=Jm.GENERAL_PROPERTIES;sourceColumns=[];leafExtendColumns=[];groupExtendColumns=[];constructor(e){super(e.engine,e.settingService,e.snapshotService),(0,Ie.Gn)(this,{currentTab:Ie.sH,setCurrentTab:Ie.XI,sourceColumns:Ie.sH.ref,leafExtendColumns:Ie.sH.ref,groupExtendColumns:Ie.sH.ref,applySnapshot:Ie.XI,applyChanges:Ie.XI}),this.view=e,this.display=this.view.dataCube.layoutService.newDisplay("Properties",(()=>(0,E.jsx)($m,{view:this.view}))),this.generalProperties=new bm(this),this.pivotLayout=new Km(this),this.columnProperties=new vm(this),this.dimensions=new Mm(this),this.columns=new Tm(this),this.horizontalPivots=new Xm(this),this.verticalPivots=new Sm(this),this.sorts=new hm(this)}setCurrentTab(e){this.currentTab=e}async applySnapshot(e,t){this.sourceColumns=e.data.sourceColumns,this.leafExtendColumns=e.data.leafExtendedColumns,this.groupExtendColumns=e.data.groupExtendedColumns;const n=da.serialization.fromJson(e.data.configuration);this.generalProperties.applySnaphot(e,n),this.pivotLayout.applySnaphot(e,n),this.columnProperties.applySnaphot(e,n),this.dimensions.applySnaphot(e,n),this.columns.applySnaphot(e,n),this.horizontalPivots.applySnaphot(e,n),this.verticalPivots.applySnaphot(e,n),this.sorts.applySnaphot(e,n)}getSnapshotSubscriberName(){return"editor"}async applyChanges(e){this.finalizationState.inProgress();const t=D(this.getLatestSnapshot()),n=t.clone();if(this.generalProperties.buildSnapshot(n,t),this.pivotLayout.buildSnapshot(n,t),this.columnProperties.buildSnapshot(n,t),this.dimensions.buildSnapshot(n,t),this.columns.buildSnapshot(n,t),this.horizontalPivots.buildSnapshot(n,t),this.verticalPivots.buildSnapshot(n,t),this.sorts.buildSnapshot(n,t),n.finalize(),n.hashCode!==t.hashCode){const e=this.view.taskService.newTask("Validating query..."),t=n.clone();t.data.pivot&&(t.data.pivot.castColumns=this.sorts.selector.availableColumns.filter((e=>!ra(t.data.groupExtendedColumns,e.name))).map(ia));const o="->",r=await this.view.engine.getPartialQueryCode(t,!0);try{await this.view.engine.getQueryCodeRelationReturnType(o+r,kl([],[this.view.source.query]),this.view.source)}catch(e){return w(e),void(e instanceof qm?this.view.dataCube.alertService.alertCodeCheckError(e,r,o,{message:"Query Validation Failure: Can't safely apply changes. Check the query code below for more details.",text:`Error: ${e.message}`}):this.view.dataCube.alertService.alertError(e,{message:"Query Validation Failure: Can't safely apply changes.",text:`Error: ${e.message}`}))}finally{this.view.taskService.endTask(e),this.finalizationState.complete()}this.publishSnapshot(n)}else this.finalizationState.complete();e?.closeAfterApply&&this.display.close()}}function Zm({name:e,subMenu:t,checked:n}){return(0,Ir.sd)({configureDefaults:()=>!0}),(0,E.jsxs)("div",{children:[(0,E.jsx)("span",{className:"ag-menu-option-part ag-menu-option-icon"}),(0,E.jsxs)("span",{className:"ag-menu-option-part ag-menu-option-text !inline-flex items-center",children:[(0,E.jsx)("span",{className:"opacity-50",children:e}),(0,E.jsx)(vu,{})]}),(0,E.jsx)("span",{className:"ag-menu-option-part ag-menu-option-shortcut"}),(0,E.jsx)("span",{className:"ag-menu-option-part ag-menu-option-popup-pointer select-none",children:t&&(0,E.jsx)("span",{className:"ag-icon ag-icon-small-right"})})]})}function eg(e,t,n,o){const r=o.view.engine.getFilterOperation(t);return{name:`Add Filter: ${e.name} ${r.textLabel}${n.label?` ${n.label}`:""}`,action:()=>{o.addNewFilterCondition(new sm(o.filterTree.root,{name:e.name,type:e.type},r,n.value,void 0))}}}class tg extends om{view;constructor(e){super(e.engine,e.settingService,e.snapshotService),this.view=e}configuration=new da;menuBuilder;getColumnConfiguration(e){return ra(this.configuration.columns,e)}filterTree={nodes:new Map};addNewFilterCondition(e){if(this.filterTree.root)if(this.filterTree.root.operation===Ci.AND)this.filterTree.root.addChild(e),this.filterTree.nodes.set(e.uuid,e);else{const t=this.filterTree.root;if(1===t.children.length)t.operation=Ci.AND,t.addChild(e),this.filterTree.nodes.set(e.uuid,e);else{const n=new lm(void 0,Ci.AND,void 0);this.filterTree.nodes.set(n.uuid,n),this.filterTree.root=n,n.addChild(t),n.addChild(e),this.filterTree.nodes.set(e.uuid,e)}}else{const t=new lm(void 0,Ci.AND,void 0);this.filterTree.nodes.set(t.uuid,t),this.filterTree.root=t,t.addChild(e),this.filterTree.nodes.set(e.uuid,e)}this.applyChanges()}clearFilters(){this.filterTree.root=void 0,this.filterTree.nodes=new Map,this.applyChanges()}selectColumns=[];leafExtendedColumns=[];groupExtendedColumns=[];pinColumn(e,t){const n=this.getColumnConfiguration(e);n&&(n.pinned=t,this.applyChanges())}rearrangeColumns(e){const t=e.map((e=>this.getColumnConfiguration(e))).filter(L);this.configuration.columns=[...t,...this.configuration.columns.filter((e=>!t.includes(e)))];const n=e.map((e=>ra(this.selectColumns,e))).filter(L);this.selectColumns=[...n,...n.filter((e=>!n.includes(e)))],this.applyChanges()}removeAllPins(){this.configuration.columns.forEach((e=>e.pinned=void 0)),this.applyChanges()}showColumn(e,t){const n=this.getColumnConfiguration(e);n&&(n.hideFromView=!t,this.applyChanges())}horizontalPivotColumns=[];horizontalPivotCastColumns=[];get horizontalPivotResultColumns(){return this.horizontalPivotCastColumns.filter((e=>na(e.name))).map(ia)}getHorizontalPivotableColumn(e){return ra(this.configuration.columns.filter((e=>e.kind===mi.DIMENSION&&!ra(this.groupExtendedColumns,e.name))),e)}setHorizontalPivotOnColumn(e){const t=this.getHorizontalPivotableColumn(e);t&&(this.horizontalPivotColumns=[t],this.applyChanges())}addHorizontalPivotOnColumn(e){const t=this.getHorizontalPivotableColumn(e);t&&(this.horizontalPivotColumns=[...this.horizontalPivotColumns,t],this.applyChanges())}clearAllHorizontalPivots(){this.horizontalPivotColumns=[],this.horizontalPivotCastColumns=[],this.applyChanges()}excludeColumnFromHorizontalPivot(e){if(na(e)){const t=oa(e),n=this.getColumnConfiguration(t);n&&!n.excludedFromPivot&&(n.excludedFromPivot=!0,this.applyChanges())}}includeColumnInHorizontalPivot(e){const t=this.getColumnConfiguration(e);t?.excludedFromPivot&&(t.excludedFromPivot=!1,this.applyChanges())}verticalPivotColumns=[];getVerticalPivotableColumn(e){return ra(this.configuration.columns.filter((e=>e.kind===mi.DIMENSION&&!ra(this.groupExtendedColumns,e.name)&&!ra(this.horizontalPivotColumns,e.name))),e)}setVerticalPivotOnColumn(e){const t=this.getVerticalPivotableColumn(e);t&&(this.verticalPivotColumns=[t],this.applyChanges())}addVerticalPivotOnColumn(e){const t=this.getVerticalPivotableColumn(e);t&&(this.verticalPivotColumns=[...this.verticalPivotColumns,t],this.applyChanges())}removeVerticalPivotOnColumn(e){this.verticalPivotColumns=this.verticalPivotColumns.filter((t=>t.name!==e)),this.applyChanges()}clearAllVerticalPivots(){this.verticalPivotColumns=[],this.applyChanges()}collapseAllPaths(){this.view.grid.client.collapseAll(),this.configuration.pivotLayout.expandedPaths=[],this.applyChanges()}expandPath(e){this.configuration.pivotLayout.expandedPaths=(0,Ne.A)([...this.configuration.pivotLayout.expandedPaths,e]).sort(),this.applyChanges()}collapsePath(e){this.configuration.pivotLayout.expandedPaths=this.configuration.pivotLayout.expandedPaths.filter((t=>t!==e)),this.applyChanges()}sortColumns=[];getSortableColumn(e){if(e)return ra([...this.horizontalPivotCastColumns.length?this.horizontalPivotCastColumns:this.selectColumns,...this.groupExtendedColumns],e)}setSortByColumn(e,t){const n=this.getSortableColumn(e);n&&(this.sortColumns=[{...n,direction:t}],this.applyChanges())}addSortByColumn(e,t){const n=this.getSortableColumn(e);n&&(this.sortColumns=[...this.sortColumns,{...n,direction:t}],this.applyChanges())}clearSortByColumn(e){this.sortColumns=this.sortColumns.filter((t=>t.name!==e)),this.applyChanges()}clearAllSorts(){this.sortColumns=[],this.applyChanges()}getSnapshotSubscriberName(){return"grid-controller"}async applySnapshot(e,t){this.configuration=da.serialization.fromJson(e.data.configuration),this.filterTree.nodes=new Map,this.filterTree.root=e.data.filter?um(e.data.filter,void 0,this.filterTree.nodes,(e=>this.view.engine.getFilterOperation(e))):void 0,this.selectColumns=e.data.selectColumns,this.leafExtendedColumns=e.data.leafExtendedColumns,this.groupExtendedColumns=e.data.groupExtendedColumns,this.horizontalPivotColumns=e.data.pivot?.columns??[],this.horizontalPivotCastColumns=e.data.pivot?.castColumns??[],this.verticalPivotColumns=e.data.groupBy?.columns??[],this.sortColumns=e.data.sortColumns,this.menuBuilder=ea(this.view.info.configuration.gridMode)?function(e){const t=e.view,n=t.dataCube;return(o,r)=>{const i=o.column??void 0,a=i?.getColId(),s=e.getColumnConfiguration(a);return[{name:"Zoom Out",action:e=>{const r=e.node?.data.metadata;t.grid.retrieveDrilloutData(r,D(o.column?.getColId())).catch((e=>n.alertService.alertUnhandledError(e)))}},{name:"Export",subMenu:[{name:"HTML",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"PDF",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Excel",action:()=>t.grid.exportEngine.exportFile(rp.EXCEL)},{name:"CSV",action:()=>t.grid.exportEngine.exportFile(rp.CSV)},"separator",{name:"DataCube Specification",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0}]},{name:"Email",subMenu:[{name:"HTML",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},"separator",{name:"HTML Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Plain Text Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"PDF Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Excel Attachment",action:()=>{t.grid.exportEngine.exportEmail(rp.EXCEL).catch((e=>n.alertService.alertUnhandledError(e)))}},{name:"CSV Attachment",action:()=>{t.grid.exportEngine.exportEmail(rp.CSV).catch((e=>n.alertService.alertUnhandledError(e)))}},{name:"DataCube Specification Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0}]},"separator",{name:"Resize",subMenu:[{name:"Auto-size to Fit Content",disabled:!i||!s||void 0!==s.fixedWidth,action:()=>o.api.autoSizeColumns([i?.getColId()].filter(L))},{name:"Minimize Column",disabled:!i||!s||void 0!==s.fixedWidth,action:()=>{i&&s&&o.api.setColumnWidths([{key:s.name,newWidth:s.minWidth??Di}])}},"separator",{name:"Auto-size All Columns",action:()=>o.api.autoSizeColumns([...e.configuration.columns.filter((e=>void 0===e.fixedWidth&&e.isSelected&&!e.hideFromView)).map((e=>e.name)),...e.horizontalPivotCastColumns.map((t=>{if(na(t.name)){const n=ra(e.configuration.columns,oa(t.name));if(n&&void 0===n.fixedWidth&&n.isSelected&&!n.hideFromView)return t.name}})).filter(L)])},{name:"Minimize All Columns",action:()=>{o.api.setColumnWidths([...e.configuration.columns.filter((e=>void 0===e.fixedWidth)).map((e=>({key:e.name,newWidth:s?.minWidth??Di}))),...e.horizontalPivotCastColumns.map((t=>{if(na(t.name)){const n=ra(e.configuration.columns,oa(t.name));if(n&&void 0===n.fixedWidth&&n.isSelected&&!n.hideFromView)return{key:t.name,newWidth:n.minWidth??Di}}})).filter(L)])}},{name:"Size Grid to Fit Screen",action:()=>o.api.sizeColumnsToFit()}]}]}}(this):function(e){const t=e.view,n=t.dataCube,o=t.filter,r=t.editor,i=t.extend,a=e=>{t.dataCube.telemetryService.sendTelemetry(Ud.EMAIL_DATACUBE,{...t.engine.getDataFromSource(t.getInitialSource()),emailFormat:e})},s=e=>{t.dataCube.telemetryService.sendTelemetry(Ud.EXPORT_DATACUBE,{...t.engine.getDataFromSource(t.getInitialSource()),exportFormat:e})},l=(e,n)=>{const o=void 0===n?{menuName:e}:{menuName:e,subMenuName:n};t.dataCube.telemetryService.sendTelemetry(Ud.SELECT_ITEM_GRIDMENU,{...t.engine.getDataFromSource(t.getInitialSource()),...o})};return(c,u)=>{const d=c.column??void 0,p=d?.getColId(),m=e.getColumnConfiguration(p),g=p&&na(p)?e.getColumnConfiguration(oa(p)):void 0,h=p&&ra([...e.leafExtendedColumns,...e.groupExtendedColumns],p),f="value"in c?c.value:void 0,E=[{name:"Sort",subMenu:[...d&&p&&e.getSortableColumn(p)?[{name:"Ascending",action:()=>{e.setSortByColumn(p,bi.ASCENDING),l("Sort","Ascending")}},{name:"Descending",action:()=>{e.setSortByColumn(p,bi.DESCENDING),l("Sort","Descending")}},{name:"Clear Sort",disabled:!ra(e.sortColumns,p),action:()=>{e.clearSortByColumn(p),l("Sort","Clear Sort")}},"separator",{name:"Add Ascending",disabled:Boolean(e.sortColumns.find((e=>e.name===p&&e.direction===bi.ASCENDING))),action:()=>{e.addSortByColumn(p,bi.ASCENDING),l("Sort","Add Ascending")}},{name:"Add Descending",disabled:Boolean(e.sortColumns.find((e=>e.name===p&&e.direction===bi.DESCENDING))),action:()=>{e.addSortByColumn(p,bi.DESCENDING),l("Sort","Add Descending")}},"separator"]:[],{name:"Clear All Sorts",disabled:0===e.sortColumns.length,action:()=>{e.clearAllSorts(),l("Clear All Sorts")}}]}];let C=[];if(d&&void 0!==f){let t=m;if(d.getColId()===Tp&&e.verticalPivotColumns.length&&"node"in c&&c.node){const n=e.verticalPivotColumns[c.node.level];t=e.getColumnConfiguration(n?.name)}if(t)if(f!==_p){const n=function(e,t){const n=`${t.type===Wr.STRING?`'${e}'`:e}`;let o;switch(t.type){case Wr.STRING:o=e;break;case Wr.NUMBER:case Wr.DECIMAL:case Wr.FLOAT:case Wr.INTEGER:o=z(Number(e));break;case Wr.DATE:case Wr.STRICTDATE:case Wr.DATETIME:o=e;break;default:throw new I(`Can't filter on column with unsupported type '${t.type}'`)}return{label:n,value:{type:t.type,value:o}}}(f,t),o=function(e){switch(e.type){case Wr.STRING:return[Ei.EQUAL,Ei.NOT_EQUAL,Ei.LESS_THAN,Ei.LESS_THAN_OR_EQUAL,Ei.GREATER_THAN,Ei.GREATER_THAN_OR_EQUAL,Ei.CONTAIN,Ei.NOT_CONTAIN,Ei.START_WITH,Ei.NOT_START_WITH,Ei.END_WITH,Ei.NOT_END_WITH];case Wr.NUMBER:case Wr.DECIMAL:case Wr.FLOAT:case Wr.INTEGER:case Wr.DATE:case Wr.STRICTDATE:case Wr.DATETIME:return[Ei.EQUAL,Ei.NOT_EQUAL,Ei.LESS_THAN,Ei.LESS_THAN_OR_EQUAL,Ei.GREATER_THAN,Ei.GREATER_THAN_OR_EQUAL];default:return[]}}(t);if(o.length&&o.includes(Ei.EQUAL)){const r=o.filter((e=>e!==Ei.EQUAL));C=[eg(t,Ei.EQUAL,n,e),r.length?{name:`More Filters on ${p}...`,subMenu:r.map((o=>eg(t,o,n,e)))}:void 0].filter(L)}}else C=[eg(t,Ei.IS_NULL,{value:{type:gi.VOID}},e),eg(t,Ei.IS_NOT_NULL,{value:{type:gi.VOID}},e)]}return[{name:"Export",subMenu:[{name:"HTML",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"PDF",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Excel",action:()=>{t.grid.exportEngine.exportFile(rp.EXCEL),s(rp.EXCEL)}},{name:"CSV",action:()=>{t.grid.exportEngine.exportFile(rp.CSV),s(rp.CSV)}},"separator",{name:"DataCube Specification",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0}]},{name:"Email",subMenu:[{name:"HTML",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},"separator",{name:"HTML Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Plain Text Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"PDF Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Excel Attachment",action:()=>{t.grid.exportEngine.exportEmail(rp.EXCEL).catch((e=>n.alertService.alertUnhandledError(e))),a(rp.EXCEL)}},{name:"CSV Attachment",action:()=>{t.grid.exportEngine.exportEmail(rp.CSV).catch((e=>n.alertService.alertUnhandledError(e))),a(rp.CSV)}},{name:"DataCube Specification Attachment",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0}]},{name:"Copy",menuItem:Zm,cssClasses:["!opacity-100"],subMenu:[{name:"Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Selected Rows as Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Selected Column as Plain Text",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0}]},"separator",...E,{name:"Filter",subMenu:[...C,C.length?"separator":void 0,{name:"Filters...",action:()=>{o.display.open(),t.dataCube.telemetryService.sendTelemetry(Ud.OPEN_EDITOR_FILTER,{...t.engine.getDataFromSource(t.getInitialSource()),openedFrom:Ai.GRID_MENU})}},{name:"Clear All Filters",action:()=>{e.clearFilters(),l("Filter","Clear All Filters")}}].filter(L)},{name:"Pivot",subMenu:[...d&&p&&m?.kind===mi.DIMENSION&&e.getVerticalPivotableColumn(p)?[{name:`Vertical Pivot on ${p}`,action:()=>{e.setVerticalPivotOnColumn(p),l("Pivot","Vertical Pivot")}},{name:`Add Vertical Pivot on ${p}`,disabled:Boolean(ra(e.verticalPivotColumns,p)),action:()=>{e.addVerticalPivotOnColumn(p),l("Pivot","Add Vertical Pivot")}},{name:`Remove Vertical Pivot on ${p}`,disabled:!ra(e.verticalPivotColumns,p),action:()=>{e.removeVerticalPivotOnColumn(p),l("Pivot","Remove Vertical Pivot")}},"separator"]:[],...d&&p&&m?.kind===mi.DIMENSION&&e.getHorizontalPivotableColumn(p)?[{name:`Horizontal Pivot on ${p}`,action:()=>{e.setHorizontalPivotOnColumn(p),l("Pivot","Horizontal Pivot")}},{name:`Add Horizontal Pivot on ${p}`,disabled:Boolean(ra(e.horizontalPivotColumns,p)),action:()=>{e.addHorizontalPivotOnColumn(p),l("Pivot","Add Horizontal Pivot")}},"separator"]:[],...d&&p&&g?.kind===mi.MEASURE&&!g.excludedFromPivot&&0!==e.horizontalPivotColumns.length?[{name:`Exclude Column ${g.name} from Horizontal Pivot`,action:()=>{e.excludeColumnFromHorizontalPivot(p),l("Pivot","Exclude Column From Horizontal Pivot")}},"separator"]:[],...d&&p&&m?.kind===mi.MEASURE&&m.excludedFromPivot&&0!==e.horizontalPivotColumns.length?[{name:`Include Column ${p} in Horizontal Pivot`,action:()=>{e.includeColumnInHorizontalPivot(p),l("Pivot","Include Column in Horizontal Pivot")}},"separator"]:[],{name:"Clear All Vertical Pivots",disabled:0===e.verticalPivotColumns.length,action:()=>{e.clearAllVerticalPivots(),l("Pivot","Clear All Vertical Pivots")}},{name:"Clear All Horizontal Pivots",disabled:0===e.horizontalPivotColumns.length,action:()=>{e.clearAllHorizontalPivots(),l("Pivot","Clear All Horizontal Pivots")}}]},{name:"Extended Columns",subMenu:[{name:"Add New Column...",action:()=>{i.openNewColumnEditor().catch((e=>n.alertService.alertUnhandledError(e))),l("Extended Columns","Add New Column...")}},...m&&p?[{name:`Extend Column ${p}...`,action:()=>{i.openNewColumnEditor(m).catch((e=>n.alertService.alertUnhandledError(e))),l("Extended Columns","Extend Column")}}]:[],...h?["separator",{name:`Edit Column ${p}...`,action:()=>{i.openExistingColumnEditor(p).catch((e=>n.alertService.alertUnhandledError(e))),l("Extended Columns","Edit Column")}},{name:`Delete Column ${p}`,action:()=>{i.deleteColumn(p).catch((e=>n.alertService.alertUnhandledError(e))),l("Extended Columns","Delete Column")}}]:[]]},"separator",{name:"Resize",subMenu:[{name:"Auto-size to Fit Content",disabled:!d||!m||void 0!==m.fixedWidth,action:()=>{c.api.autoSizeColumns([d?.getColId()].filter(L)),l("Resize","Auto-size to Fit Content")}},{name:"Minimize Column",disabled:!d||!m||void 0!==m.fixedWidth,action:()=>{d&&m&&c.api.setColumnWidths([{key:m.name,newWidth:m.minWidth??Di}]),l("Resize","Minimize Column")}},"separator",{name:"Auto-size All Columns",action:()=>{c.api.autoSizeColumns([...e.configuration.columns.filter((e=>void 0===e.fixedWidth&&e.isSelected&&!e.hideFromView)).map((e=>e.name)),...e.horizontalPivotCastColumns.map((t=>{if(na(t.name)){const n=ra(e.configuration.columns,oa(t.name));if(n&&void 0===n.fixedWidth&&n.isSelected&&!n.hideFromView)return t.name}})).filter(L)]),l("Resize","Auto-size All Columns")}},{name:"Minimize All Columns",action:()=>{c.api.setColumnWidths([...e.configuration.columns.filter((e=>void 0===e.fixedWidth)).map((e=>({key:e.name,newWidth:m?.minWidth??Di}))),...e.horizontalPivotCastColumns.map((t=>{if(na(t.name)){const n=ra(e.configuration.columns,oa(t.name));if(n&&void 0===n.fixedWidth&&n.isSelected&&!n.hideFromView)return{key:t.name,newWidth:n.minWidth??Di}}})).filter(L)]),l("Resize","Minimize All Columns")}},{name:"Size Grid to Fit Screen",action:()=>{c.api.sizeColumnsToFit(),l("Resize","Size Grid to Fit Screen")}}]},{name:"Pin",subMenu:[...m?[{name:"Pin Left",disabled:!d||d.isPinnedLeft(),checked:Boolean(d?.isPinnedLeft()),action:()=>{e.pinColumn(p,vi.LEFT),l("Pin","Pin Left")}},{name:"Pin Right",disabled:!d||d.isPinnedRight(),checked:Boolean(d?.isPinnedRight()),action:()=>{e.pinColumn(p,vi.RIGHT),l("Pin","Pin Right")}},{name:"Unpin",disabled:!d?.isPinned(),action:()=>{e.pinColumn(p,void 0),l("Pin","Unpin")}},"separator"]:[],{name:"Remove All Pinnings",disabled:e.configuration.columns.every((e=>void 0===e.pinned)),action:()=>{e.removeAllPins(),l("Pin","Remove All Pinnings")}}]},{name:"Hide",disabled:!m,action:()=>{e.showColumn(p,!1),l("Hide")}},...p===Tp?["separator",{name:"Collapse All",action:()=>{e.collapseAllPaths()}}]:[],"separator",{name:"Heatmap",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!d,subMenu:d?[{name:`Add to ${d.getColId()}`,menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:`Remove from ${d.getColId()}`,menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0}]:[]},{name:"Show Plot...",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},{name:"Show TreeMap...",menuItem:Zm,cssClasses:["!opacity-100"],disabled:!0},"separator",{name:"Properties...",disabled:r.display.isOpen,action:()=>{d&&u&&(r.setCurrentTab(Jm.COLUMN_PROPERTIES),r.columnProperties.setSelectedColumnName(g?.name??m?.name??p)),r.display.open(),t.dataCube.telemetryService.sendTelemetry(Ud.OPEN_EDITOR_PROPERTIES,{...t.engine.getDataFromSource(t.getInitialSource()),openedFrom:Ai.GRID_MENU})}}]}}(this)}propagateChanges(e){this.verticalPivotColumns=this.verticalPivotColumns.filter((e=>!ra(this.horizontalPivotColumns,e.name))),this.configuration.pivotLayout.expandedPaths=xc(e.data.groupBy?.columns??[],this.verticalPivotColumns,this.configuration.pivotLayout.expandedPaths),this.configuration.columns.forEach((e=>{e.pivotSortDirection=ra(this.horizontalPivotColumns,e.name)?e.pivotSortDirection??bi.ASCENDING:void 0})),this.selectColumns=(0,nt.A)([...this.configuration.columns.filter((e=>e.isSelected&&!ra(this.groupExtendedColumns,e.name))),...this.horizontalPivotColumns,...this.verticalPivotColumns],(e=>e.name)).map(ia);const t=(0,nt.A)([...this.horizontalPivotColumns.length?[...this.horizontalPivotResultColumns,...[...this.configuration.columns.filter((e=>e.isSelected)),...this.verticalPivotColumns].filter((e=>this.getColumnConfiguration(e.name)?.kind===mi.DIMENSION&&!ra(this.horizontalPivotColumns,e.name)))]:[...this.configuration.columns.filter((e=>e.isSelected)),...this.verticalPivotColumns],...this.groupExtendedColumns],(e=>e.name));this.sortColumns=this.sortColumns.filter((e=>ra(t,e.name)))}applyChanges(){const e=D(this.getLatestSnapshot()),t=e.clone();this.propagateChanges(e),t.data.configuration=this.configuration.serialize(),t.data.filter=this.filterTree.root?cm(this.filterTree.root):void 0,t.data.selectColumns=this.selectColumns,t.data.pivot=this.horizontalPivotColumns.length?{columns:this.horizontalPivotColumns,castColumns:this.horizontalPivotCastColumns}:void 0,t.data.groupBy=this.verticalPivotColumns.length?{columns:this.verticalPivotColumns}:void 0,t.data.sortColumns=this.sortColumns,t.finalize(),t.hashCode!==e.hashCode&&this.publishSnapshot(t)}}function ng(e){return new Promise(((t,n)=>{const o=new FileReader;o.onloadend=()=>{const e=o.result;if(U(e)){const n=e.split(",")[1];if(n)return void t(n)}n(new Error("Can't base64 encode blob data"))},o.onerror=e=>n(e),o.readAsDataURL(e)}))}const og="mixed_boundary",rg="alternative_boundary",ig=`\nFrom:\nTo:\nSubject:\nX-Unsent: 1\nContent-Type: multipart/mixed; boundary="${og}"\n\n--${og}\nContent-Type: multipart/alternative; boundary="${rg}"\n\n--${rg}\nContent-Type: text/plain; charset="UTF-8"\nContent-Transfer-Encoding: 7bit\n\n\n\n--${rg}\nContent-Type: text/html; charset="UTF-8"\nContent-Transfer-Encoding: 7bit\n\n<html><body><p></p><body></html>\n\n--${rg}--\n\n`;class ag{_grid;constructor(e){this._grid=e}generateFileName(){return`${this._grid.configuration.name} - ${(0,Kn.GP)(new Date,"EEE MMM dd yyyy HH_mm_ss")}`}exportFile(e){const t=this.generateFileName();switch(e){case rp.CSV:return void this._grid.client.exportDataAsCsv({fileName:`${t}.csv`});case rp.EXCEL:return void this._grid.client.exportDataAsExcel({fileName:`${t}.xlsx`})}}async exportEmail(e){const t=this.generateFileName();let n,o,r=t;switch(e){case rp.CSV:r=`${t}.csv`,o=ee.TEXT_CSV,n=await ng(new Blob([this._grid.client.getDataAsCsv()??""],{type:ee.TEXT_CSV}));break;case rp.EXCEL:{r+=`${t}.xlsx`,o=ee.APPLICATION_XLSX;const e=this._grid.client.getDataAsExcel();let i;if(e instanceof Blob)i=e;else{if("string"!=typeof e)throw new x("Can't export Excel content");i=new Blob([e],{type:ee.APPLICATION_XLSX})}n=await ng(i);break}default:throw new I(`Can't export email in format '${e}'`)}le(`${t}.eml`,`${ig.trimStart()}--${og}\nContent-Type: ${o}; name="${r}"\nContent-Transfer-Encoding: base64\nContent-Disposition: attachment; filename="${r}"\n\n${n}\n\n--${og}--`,ee.MESSAGE_RFC822)}}class sg extends om{_view;controller;exportEngine;_client;clientDataSource;configuration=new da;rowLimit;isPaginationEnabled=!0;isCachingEnabled=!1;scrollHintText;debouncedAutoResizeColumns;constructor(e){super(e.engine,e.settingService,e.snapshotService),(0,Ie.Gn)(this,{clientDataSource:Ie.sH,configuration:Ie.sH,rowLimit:Ie.sH,isPaginationEnabled:Ie.sH,setPaginationEnabled:Ie.XI,isCachingEnabled:Ie.sH,setCachingEnabled:Ie.XI,scrollHintText:Ie.sH,setScrollHintText:Ie.XI,applySnapshot:Ie.XI}),this._view=e,this.controller=new tg(this._view),this.exportEngine=new ag(this),this.clientDataSource=new Dp(this,this._view)}setPaginationEnabled(e){this.isPaginationEnabled=e,this.clientDataSource=new Dp(this,this._view),this.client.updateGridOptions({cacheBlockSize:e?500:mp}),this._engine.sendTelemetry(e?Ud.PAGINATION_ENABLE__SUCCESS:Ud.PAGINATION_DISABLE__SUCCESS,this._engine.getDataFromSource(this._view.getInitialSource()))}async setCachingEnabled(e,t){if(e===this.isCachingEnabled)return;if(!1===e){const t=new tm;return await this._view.disposeCache(),(0,Ie.h5)((()=>{this.isCachingEnabled=e,this.clientDataSource=new Dp(this,this._view)})),void this._engine.sendTelemetry(Ud.CACHING_DISABLE__SUCCESS,{...this._engine.getDataFromSource(this._view.getInitialSource()),timings:this._engine.finalizeTimingRecord(t)})}const n=async()=>{const t=new tm;await this._view.initializeCache(),this._view.processCacheState.hasSucceeded&&(0,Ie.h5)((()=>{this.isCachingEnabled=e,this.clientDataSource=new Dp(this,this._view)})),this._engine.sendTelemetry(Ud.CACHING_ENABLE__SUCCESS,{...this._engine.getDataFromSource(this._view.getInitialSource()),timings:this._engine.finalizeTimingRecord(t)})};this._settingService.getBooleanValue(Uu.GRID_CLIENT__SHOW_CACHE_PERFORMANCE_WARNING)&&!t?.suppressWarning?this._view.alertService.alert({message:"Confirm you want to proceed with caching",text:"When enabled, the source dataset will be cached locally in order to boost query performance. But depending on computational resource available to your environment, sometimes, caching can negatively impact the overall performance, and can even lead to crashes.\n\nOverall, caching is still an experimental feature where we only support queries with simple execution plans, certain queries might not work, in which case, you can abort by turning off caching.\n\nDo you still want to proceed?",type:Mu.WARNING,actions:[{label:"Abort",handler:()=>{}},{label:"Proceed",handler:()=>{n().catch((e=>this._view.alertService.alertUnhandledError(e)))}},{label:"Dismiss Warning and Proceed",handler:()=>{this._view.settingService.updateValue(this._view.dataCube.api,Uu.GRID_CLIENT__SHOW_CACHE_PERFORMANCE_WARNING,!1),n().catch((e=>this._view.alertService.alertUnhandledError(e)))}}],windowConfig:{...Er,width:600,height:300,minWidth:300,minHeight:150}}):await n()}setScrollHintText(e){this.scrollHintText=e}get isClientConfigured(){return Boolean(this._client)}get client(){return D(this._client,"Grid client is not configured")}async configureClient(e){this._client=e,this.debouncedAutoResizeColumns=(0,Bn.A)((()=>e?.autoSizeAllColumns()),100);const t=this.getLatestSnapshot();t&&await this.applySnapshot(t,void 0)}async configureDimensionGridClient(e){this._client=e,this.debouncedAutoResizeColumns=(0,Bn.A)((()=>e?.autoSizeAllColumns()),100);const t=this.getLatestSnapshot();t&&(t.data.dimensionalTree||(t.data.dimensionalTree=cc(da.serialization.fromJson(t.data.configuration))),await this._applyDimensionalSnapshot(t))}async retrieveDrilloutData(e,t){const n=D(this.getLatestSnapshot()),o=ac(D(n.data.dimensionalTree));!function(e,t,n,o){for(const r of e.rootNodes){if(r.dimension!==t)continue;const e=uc(r,n,o,null);if(!e)continue;const{parent:i,index:a}=e;return i&&i.childNodes.splice(a,1),!0}}(D(n.data.dimensionalTree),t,D(e.get(t)?.column),D(e.get(t)?.groupByNodes)),await this._applyDimensionalSnapshot(n,o)}async retrieveDrilldownData(e){const t=D(this.getLatestSnapshot()),n=ac(D(t.data.dimensionalTree));t.data.dimensionalTree=cc(da.serialization.fromJson(t.data.configuration),e,t.data.dimensionalTree),await this._applyDimensionalSnapshot(t,n)}async _applyDimensionalSnapshot(e,t){this._client?.hideOverlay(),this._client?.setGridOption(Ni.LOADING,!0);const n=await async function(e,t,n){const o=t.taskService.newTask("Fetching data...");let r=[];const i=da.serialization.fromJson(e.data.configuration);let a=lc(D(e.data.dimensionalTree));if(n){const e=lc(n);e.length<=a.length&&(r=t.grid.client.getGridOption(Ni.ROW_DATA),a=function(e,t){const n=new Set(e.map(pc));return t.filter((e=>!n.has(pc(e))))}(e,a))}for(const n of a){const a=Vu(e,t.source,t.engine,n);let s;try{s=await t.engine.executeQuery(kl([],[a]),t.source,{debug:t.settingService.getBooleanValue(Uu.DEBUGGER__ENABLE_DEBUG_MODE),clientVersion:t.settingService.getBooleanValue(Uu.DEBUGGER__USE_DEV_CLIENT_PROTOCOL_VERSION)?gc.VX_X_X:void 0}),r=Op(s.result.result,0,n,r,i.dimensions.dimensions)}catch(e){return w(e),e instanceof jd?t.alertService.alertExecutionError(e,{message:"Data Fetch Failure: Can't execute query.",text:`Error: ${e.message}`}):t.alertService.alertError(e,{message:`Data Fetch Failure: ${e.message}`}),t.taskService.endTask(o),{rowData:[],columnDefs:[]}}t.settingService.getBooleanValue(Uu.DEBUGGER__ENABLE_DEBUG_MODE)&&t.engine.debugProcess("Execution",["Query",s.executedQuery],["Stats",`${r.length} rows, ${s.result.result.columns.length} columns`],["SQL",s.executedSQL??"-- Error: failed to extract executed SQL"],["SQL Execution Time",s.executionTime])}return t.taskService.endTask(o),{rowData:r,columnDefs:op(e,i)}}(e,this._view,t);this._client?.setGridOption(Ni.ROW_DATA,n.rowData),this._client?.setGridOption(Ni.COLUMN_DEFS,n.columnDefs),0===n.rowData.length&&this._client?.showNoRowsOverlay(),this._client?.setGridOption(Ni.LOADING,!1),this.publishSnapshot(e)}getSnapshotSubscriberName(){return"grid"}async applySnapshot(e,t){const n=da.serialization.fromJson(e.data.configuration);if(this.configuration=n,n.gridMode!==Ti.STANDARD||!this._client||this._client.isDestroyed())return;const o=function(e,t,n){return{isServerSideGroupOpenByDefault:e=>{if(void 0!==t.initialExpandLevel&&t.initialExpandLevel>0&&e.rowNode.level<=(t.showRootAggregation?t.initialExpandLevel+1:t.initialExpandLevel)-1)return!0;const n=e.rowNode.getRoute()??[];if(!n.length)return!1;if(t.showRootAggregation&&1===n.length&&n[0]===Ri)return!0;t.showRootAggregation&&n.shift();const o=n.join(xi);return!!t.pivotLayout.expandedPaths.includes(o)},rowClassRules:t.alternateRows?{[ip.HIGHLIGHT_ROW]:e=>e.rowIndex%(2*t.alternateRowsCount)>=t.alternateRowsCount}:{},onColumnPinned:e=>{if("api"!==e.source&&e.column){const t=e.column,o=t.getPinned();n.grid.controller.pinColumn(t.getColId(),null===o?void 0:o===yp.LEFT?vi.LEFT:vi.RIGHT)}},onColumnMoved:e=>{"api"!==e.source&&e.column&&e.finished&&n.grid.controller.rearrangeColumns((e.api.getColumnDefs()??[]).filter((e=>!("children"in e))).map((e=>e.colId??"")))},onColumnVisible:e=>{if("api"!==e.source&&e.column){const t=e.column,o=t.isVisible();n.grid.controller.showColumn(t.getColId(),o)}},onRowGroupOpened:e=>{if(e.event){const o=e.node.getRoute()??[];o.length&&t.showRootAggregation&&o.shift();const r=o.join(xi);if(!r)return;e.expanded?n.grid.controller.expandPath(r):n.grid.controller.collapsePath(r)}},onVirtualColumnsChanged:()=>{n.grid.debouncedAutoResizeColumns?.cancel(),n.grid.debouncedAutoResizeColumns?.()},columnDefs:np(e,t),autoGroupColumnDef:{colId:Tp,headerName:"",cellRendererParams:{suppressCount:!t.showLeafCount},...Xd(e,t),minWidth:200,sortable:!0,showRowGroup:!0,suppressSpanHeaderHeight:!0}}}(e,n,this._view);this._settingService.getBooleanValue(Uu.DEBUGGER__ENABLE_DEBUG_MODE)&&this._engine.debugProcess("New Grid Options",["Grid Options",o]),this.client.updateGridOptions({...o,rowBuffer:this._settingService.getNumericValue(Uu.GRID_CLIENT__ROW_BUFFER),purgeClosedRowNodes:this._settingService.getBooleanValue(Uu.GRID_CLIENT__PURGE_CLOSED_ROW_NODES),cacheBlockSize:this.isPaginationEnabled?500:mp}),this.client.setFilterModel({[Sp]:{type:"equals",filter:Rp(e,n)}})}}class lg extends om{_view;configuration=new da;name="";constructor(e){super(e.engine,e.settingService,e.snapshotService),(0,Ie.Gn)(this,{configuration:Ie.sH,name:Ie.sH,applySnapshot:Ie.XI}),this._view=e}getSnapshotSubscriberName(){return"info"}async applySnapshot(e,t){const n=e.data,o=da.serialization.fromJson(n.configuration);this.configuration=o,o.name!==this.name&&(this.name=o.name,this._view.dataCube.options?.onNameChanged?.({api:this._view.dataCube.api,name:this.name,source:this._view.source}))}}const cg=[{func:si.EXTEND,parameters:1,stopCondition:e=>ga(e.function,si.EXTEND)&&e.parameters[0]instanceof ha&&ga(e.parameters[0].function,si.OVER)},{func:si.FILTER,parameters:1},{func:si.SELECT,parameters:1},{func:si.GROUP_BY,parameters:2},{func:si.PIVOT,parameters:2},{func:si.CAST,parameters:1},{func:si.SORT,parameters:1},{func:si.LIMIT,parameters:1}];var ug;!function(e){e.LEAF_EXTEND="leaf_extend",e.FILTER="filter",e.SELECT="select",e.PIVOT__GROUP="pivot__group",e.PIVOT_SORT="pivot_sort",e.PIVOT="pivot",e.PIVOT_CAST="pivot_cast",e.GROUP_BY__GROUP="group_by__group",e.GROUP_BY="group_by",e.GROUP_BY_SORT="group_by_sort",e.GROUP_EXTEND="group_extend",e.SORT="sort",e.LIMIT="limit"}(ug||(ug={}));const dg=[{name:ug.LEAF_EXTEND,func:si.EXTEND,repeat:!0},{name:ug.FILTER,func:si.FILTER},{name:ug.SELECT,func:si.SELECT},{name:ug.PIVOT__GROUP,funcs:[{name:ug.PIVOT_SORT,func:si.SORT,required:!0},{name:ug.PIVOT,func:si.PIVOT,required:!0},{name:ug.PIVOT_CAST,func:si.CAST,required:!0}]},{name:ug.GROUP_BY__GROUP,funcs:[{name:ug.GROUP_BY,func:si.GROUP_BY,required:!0},{name:ug.GROUP_BY_SORT,func:si.SORT,required:!0}]},{name:ug.GROUP_EXTEND,func:si.EXTEND,repeat:!0},{name:ug.SORT,func:si.SORT},{name:ug.LIMIT,func:si.LIMIT}],pg=new RegExp(`^${dg.map((e=>"funcs"in e?`(${e.funcs.map((e=>`(?<${e.name}>${e.repeat?`(?:<${ma(e.func)}>____\\d+)*`:`<${ma(e.func)}>____\\d+`})${e.repeat||e.required?"":"?"}`)).join("")})${e.repeat?"*":e.required?"":"?"}`:`(?<${e.name}>${e.repeat?`(?:<${ma(e.func)}>____\\d+)*`:`<${ma(e.func)}>____\\d+`})${e.repeat||e.required?"":"?"}`)).join("")}$`);async function mg(e,t,n,o){const r=function(e){if(!(e instanceof ha))throw new Error("Can't process expression: expected a function expression");const t=[];let n=e;for(;n instanceof ha;){const e=cg.find((e=>ga(n.function,e.func)));if(!e)throw new Error(`Can't process expression: found unsupported function ${n.function}()`);if(!(n.parameters.length>e.parameters)){t.unshift(n);break}{if(e.stopCondition?.(n)){t.unshift(n);break}M(n.parameters.length===e.parameters+1,`Can't process ${ma(n.function)}() expression: expected at most ${e.parameters+1} parameters provided, got ${n.parameters.length}`);const o=vc(n,0,ha,"Can't process expression: expected a sequence of function calls (e.g. x()->y()->z())");n.parameters=n.parameters.slice(1),t.unshift(n),n=o}}const o=t.map(((e,t)=>`<${ma(e.function)}>____${t}`)).join("").match(pg);if(!o)throw new Error(`Can't process expression: unsupported function composition ${t.map((e=>`${ma(e.function)}()`)).join("->")} (supported composition: ${dg.map((e=>"funcs"in e?`[${e.funcs.map((e=>`${ma(e.func)}()`)).join("->")}]`:`${ma(e.func)}()`)).join("->")})`);const r=e=>{const n=o.groups?.[e];if(!n)return;const r=n.match(/\<.*?\>____\d+/g);return r?.length?r.map((e=>{const n=Number(e.split("____")[1]);if(!(isNaN(n)||n>=t.length))return N(t,n)})).filter(L):void 0};return{leafExtend:r(ug.LEAF_EXTEND),select:r(ug.SELECT)?.[0],filter:r(ug.FILTER)?.[0],pivotSort:r(ug.PIVOT_SORT)?.[0],pivot:r(ug.PIVOT)?.[0],pivotCast:r(ug.PIVOT_CAST)?.[0],groupBy:r(ug.GROUP_BY)?.[0],groupBySort:r(ug.GROUP_BY_SORT)?.[0],groupExtend:r(ug.GROUP_EXTEND),sort:r(ug.SORT)?.[0],limit:r(ug.LIMIT)?.[0]}}(o.deserializeValueSpecification(o.serializeValueSpecification(e))),i=Ld.create({}),a=i.data,s=new Map,l=(e,t)=>{if(s.has(e.name))throw new Error(t);s.set(e.name,e)},c=new Map,u=e=>ia(D(c.get(e),`Can't find column '${e}'`)),d=e=>c.set(e.name,e);if(a.sourceColumns=t.columns,yc(a.sourceColumns,(e=>`Can't process source: found duplicate source columns '${e}'`)),a.sourceColumns.forEach((e=>l(e,`Can't process source: another column with name '${e.name}' is already registered`))),a.sourceColumns.forEach((e=>d(e))),r.leafExtend?.length&&(a.leafExtendedColumns=await Ic(r.leafExtend,Array.from(c.values()),o,t),yc(a.leafExtendedColumns,(e=>`Can't process extend() expression: found duplicate extended columns '${e}'`)),a.leafExtendedColumns.forEach((e=>l(e,`Can't process extend() expression: another column with name '${e.name}' is already registered`))),a.leafExtendedColumns.forEach((e=>d(e)))),r.filter){const e=vc(r.filter,0,Gr,"Can't process filter() expression: expected parameter at index 0 to be a lambda expression");a.filter=wc(Nc(e,"Can't process filter() expression"),u,o.filterOperations)}r.select?(a.selectColumns=Tc(r.select,0).colSpecs.map((e=>u(e.name))),yc(a.selectColumns,(e=>`Can't process select() expression: found duplicate select columns '${e}'`)),c.clear(),a.selectColumns.forEach((e=>d(e)))):c.clear();let p=[],m=[];if(r.pivot&&r.pivotCast&&r.pivotSort){const e=Tc(r.pivot,0).colSpecs.map((e=>u(e.name))),t=(g=(h=r.pivotCast,vc(h,0,ds,`Can't process ${ma(h.function)}: expected parameter at index 0 to be a generic type instance`)).genericType,B(g.typeArguments[0]?.rawType,hs,"Can't process generic type: failed to extract relation type")).columns.map((e=>({name:e.name,type:Sc(e.genericType).fullPath})));a.pivot={columns:e,castColumns:t},p=Tc(r.pivot,1).colSpecs.map((e=>Fc(e,u,o.aggregateOperations))),m=function(e,t,n){const o=Pc(e,n),r=new Set(t.map((e=>e.name))),i=new Set(t.map((e=>e.name)));if(o.forEach((e=>{if(!r.has(e.name))throw new Error(`Can't process pivot() expression: sort column '${e.name}' must be a pivot column`);i.delete(e.name)})),0!==i.size)throw new Error(`Can't process pivot() expression: found unsorted pivot column(s) (${Array.from(i.values()).sort().map((e=>`'${e}'`)).join(", ")})`);return yc(o,(e=>`Can't process pivot() expression: found duplicate sort columns '${e}'`)),o}(r.pivotSort,e,u),function(e,t,n){const o=e.columns,r=e.castColumns;yc(o,(e=>`Can't process pivot() expression: found duplicate pivot columns '${e}'`)),yc(t,(e=>`Can't process pivot() expression: found duplicate aggregate columns '${e}'`)),yc(r,(e=>`Can't process pivot() expression: found duplicate cast columns '${e}'`)),t.forEach((e=>{if(ra(o,e.name))throw new Error(`Can't process pivot() expression: pivot column '${e.name}' must not be aggregated on`)})),n.filter((e=>!(ra(o,e.name)??ra(t,e.name)))).forEach((e=>{if(!ra(r,e.name))throw new Error(`Can't process pivot() expression: expected pivot group column '${e.name}' in cast columns`)})),o.forEach((e=>{if(ra(r,e.name))throw new Error(`Can't process pivot() expression: expected pivot column '${e.name}' to not present in cast columns`)})),t.forEach((e=>{if(ra(r,e.name))throw new Error(`Can't process pivot() expression: expected pivot aggregate column '${e.name}' to not present in cast columns`)})),r.filter((e=>na(e.name))).forEach((e=>{const n=oa(e.name);if(!ra(t,n))throw new Error(`Can't process pivot() expression: fail to match cast column '${e.name}' to a specified aggregate column`)}))}(a.pivot,p,Array.from(c.values())),c.clear(),t.forEach((e=>d(e)))}var g,h;let f=[],E=[];if(r.groupBy&&r.groupBySort){const e=Tc(r.groupBy,0).colSpecs.map((e=>u(e.name)));a.groupBy={columns:e},f=Tc(r.groupBy,1).colSpecs.map((e=>Fc(e,u,o.aggregateOperations))),E=function(e,t,n){const o=Pc(e,n),r=new Set(t.map((e=>e.name))),i=new Set(t.map((e=>e.name)));let a;if(o.forEach((e=>{if(!r.has(e.name))throw new Error(`Can't process groupBy() expression: sort column '${e.name}' must be a group column`);if(i.delete(e.name),a){if(e.direction!==a)throw new Error("Can't process groupBy() expression: all group columns must be sorted in the same direction")}else a=e.direction})),0!==i.size)throw new Error(`Can't process groupBy() expression: found unsorted group column(s) (${Array.from(i.values()).sort().map((e=>`'${e}'`)).join(", ")})`);return yc(o,(e=>`Can't process groupBy() expression: found duplicate sort columns '${e}'`)),o}(r.groupBySort,e,u),function(e,t,n,o,r){const i=e.columns;if(yc(i,(e=>`Can't process groupBy() expression: found duplicate group columns '${e}'`)),yc(t,(e=>`Can't process groupBy() expression: found duplicate aggregate columns '${e}'`)),t.forEach((e=>{if(ra(i,e.name))throw new Error(`Can't process groupBy() expression: group column '${e.name}' must not be aggregated on`)})),r.forEach((e=>{if(!(ra(i,e.name)??ra(t,e.name)))throw new Error(`Can't process groupBy() expression: column '${e.name}' is neither grouped nor aggregated on`)})),n){const e=new Map;t.filter((e=>na(e.name))).forEach((t=>{const n=oa(t.name),o={...t,name:n},r=e.get(n);if(r){if(!(0,Oo.A)({...r,type:void 0},{...o,type:void 0}))throw new Error(`Can't process groupBy() expression: found conflicting aggregation specification for column '${n}'`)}else e.set(n,o)})),o.forEach((t=>{const n=e.get(t.name);if(!n)throw new Error(`Can't process groupBy() expression: column '${t.name}' is aggregated in pivot() expression but not in groupBy() expression`);if(!(0,Oo.A)({...n,type:void 0},{...t,type:void 0}))throw new Error(`Can't process groupBy() expression: found conflicting aggregation specification for column '${t.name}'`)}))}}(a.groupBy,f,a.pivot,p,Array.from(c.values()))}if(r.groupExtend?.length&&(a.groupExtendedColumns=await Ic(r.groupExtend,Array.from(c.values()),o,t),yc(a.groupExtendedColumns,(e=>`Can't process extend() expression: found duplicate extended columns '${e}'`)),a.groupExtendedColumns.forEach((e=>l(e,`Can't process extend() expression: another column with name '${e.name}' is already registered`))),a.groupExtendedColumns.forEach((e=>d(e)))),r.sort&&(a.sortColumns=Pc(r.sort,u),yc(a.sortColumns,(e=>`Can't process sort() expression: found duplicate sort columns '${e}'`))),r.limit){const e=vc(r.limit,0,ba,"Can't process limit() expression: expected limit to be a non-negative integer value");a.limit=e.value}const C=function(e,t,n){const o=e.snapshot.data,r=t.configuration,i=Bd(e);if(!r)return i;o.groupBy&&M(r.treeColumnSortDirection===i.treeColumnSortDirection,`Can't process configuration: tree column sort direction mismatch (expected: '${i.treeColumnSortDirection.toLowerCase()}', found: '${r.treeColumnSortDirection.toLowerCase()}')`);const a=r.columns,s=i.columns,l=new Set;a.forEach((e=>{if(l.has(e.name))throw new Error(`Can't process configuration: found duplicate columns '${e.name}'`);l.add(e.name)})),a.forEach((e=>{if(!ra(s,e.name))throw new Error(`Can't process configuration: found extra column '${e.name}'`)})),s.forEach((e=>{if(!ra(a,e.name))throw new Error(`Can't process configuration: missing column '${e.name}'`)}));const c=[...o.selectColumns,...o.groupExtendedColumns,...[...o.sourceColumns,...o.leafExtendedColumns].filter((e=>!ra(o.selectColumns,e.name)))];return c.forEach(((e,t)=>{const n=N(a,t);M(e.name===n.name,`Can't process configuration: column ordering mismatch at index ${t} (expected: '${e.name}', found: '${n.name})', expected ordering: ${c.map((e=>e.name)).join(", ")}`)})),a.forEach((e=>{const t=D(ra(s,e.name));if(M(e.type===t.type,`Can't process configuration: type mismatch for column '${e.name}' (expected: '${t.type}', found: '${e.type}')`),M(e.isSelected===t.isSelected,`Can't process configuration: selection mismatch for column '${e.name}' (expected: '${t.isSelected}', found: '${e.isSelected}')`),(ra(o.pivot?.columns??[],e.name)??ra(o.groupBy?.columns??[],e.name))&&M(e.kind===t.kind,`Can't process configuration: kind mismatch for column '${e.name}' (expected: '${t.kind.toLowerCase()}', found: '${e.kind.toLowerCase()}')`),(o.pivot??o.groupBy)&&(M(e.aggregateOperator===t.aggregateOperator,`Can't process configuration: aggregation operator mismatch for column '${e.name}' (expected: '${t.aggregateOperator}', found: '${e.aggregateOperator}')`),M(n.getAggregateOperation(e.aggregateOperator).isCompatibleWithParameterValues(e.aggregationParameters),`Can't process configuration: incompatible aggregation parameter values for column '${e.name}' (operator: '${e.aggregateOperator}')`)),o.pivot&&(M(e.excludedFromPivot===t.excludedFromPivot,`Can't process configuration: pivot exclusion mismatch for column '${e.name}' (expected: '${t.excludedFromPivot}', found: '${e.excludedFromPivot}')`),M(e.pivotSortDirection===t.pivotSortDirection,`Can't process configuration: pivot sort direction mismatch for column '${e.name}' (expected: '${t.pivotSortDirection?.toLowerCase()??"none"}', found: '${e.pivotSortDirection?.toLowerCase()??"none"}')`)),e.kind===mi.DIMENSION&&!e.excludedFromPivot)throw new Error(`Can't process configuration: column '${e.name}' is a dimension but not excluded from pivot`)})),r}({snapshot:i,groupByAggColumns:f,groupBySortColumns:E,pivotAggColumns:p,pivotSortColumns:m},n,o);return a.configuration=C.serialize(),a.dimensionalTree=n.dimensionalTree,i.finalize()}var gg=n(60720),hg=n(78058),fg=n(36868);const Eg=(0,Ft.forwardRef)((function(e,t){return(0,E.jsx)(gg.x,{ref:t,...e})})),Cg=(0,Ft.forwardRef)((function(e,t){return(0,E.jsx)(hg.l,{ref:t,...e})})),bg=(0,Ft.forwardRef)((function(e,t){const{inputRef:n,className:o,disabled:r,InputProps:{ref:i,endAdornment:a}={},ownerState:s,enableAccessibleFieldDOMStructure:l,clearable:c,onClear:u,error:d,focused:p,...m}=e,g=(0,cu.A)(i,t);return(0,E.jsxs)("div",{style:{display:"flex",alignItems:"center",position:"relative"},ref:g,children:[(0,E.jsx)("input",{className:o,disabled:r,ref:n,...m}),a]})})),vg=(0,Ft.forwardRef)((function(e,t){const{slots:n,slotProps:o,onClear:r,...i}=e,a=(0,fg.c)({...i});return(0,E.jsx)(bg,{...a,ref:t})}));var _g=n(15179),Tg=n(15891);const Ng=(0,vt.PA)((0,Ft.forwardRef)((function(e,t){const{value:n,updateValue:o}=e,r=(0,Ft.useRef)(null),i=(0,cu.A)(r,t);return(0,E.jsx)("input",{ref:i,className:"h-5 w-full flex-shrink-0 border border-neutral-400 px-1 text-sm disabled:border-neutral-300 disabled:bg-neutral-50 disabled:text-neutral-300",value:n,onKeyDown:e=>{"Escape"===e.code&&r.current?.select()},onChange:e=>{o(e.target.value)}})}))),Sg="#ERR",Ag=(0,vt.PA)((0,Ft.forwardRef)((function(e,t){const{value:n,updateValue:o,defaultValue:r=0,step:i=1}=e,[a,s]=(0,Ft.useState)(n.toString()),l=(0,Ft.useRef)(null),c=(0,cu.A)(l,t),u=()=>{const e=Number(a);if(""===a)s(r.toString()),o(r);else if(isNaN(e)){if(a===Sg)return void s(n.toString());try{const e=z((0,Tg._3)(a));s(e.toString()),o(e)}catch{s(Sg),o(r)}}};return(0,Ft.useEffect)((()=>{s(n.toString())}),[n]),(0,E.jsxs)("div",{className:"relative h-5 w-full flex-shrink-0",children:[(0,E.jsx)("input",{ref:c,inputMode:"numeric",spellCheck:!1,type:"text",className:"h-full w-full border border-neutral-400 px-1 pr-5 text-sm disabled:border-neutral-300 disabled:bg-neutral-50 disabled:text-neutral-300",value:a,onKeyDown:e=>{if("Enter"===e.code)u(),l.current?.focus();else if("Escape"===e.code)l.current?.select();else if("ArrowUp"===e.code){e.preventDefault();const t=n+i;s(t.toString()),o(t)}else if("ArrowDown"===e.code){e.preventDefault();const t=n-i;s(t.toString()),o(t)}},onChange:e=>{const t=e.target.value;s(t);const n=Number(t);!isNaN(n)&&t&&o(n)},onBlur:()=>u()}),(0,E.jsx)("div",{className:"absolute right-0 top-0 flex h-5 w-5 items-center justify-center",children:(0,E.jsx)("button",{className:"text-lg text-neutral-500 hover:text-neutral-600",title:"Evaluate Expression (Enter)",onClick:u,tabIndex:-1,children:(0,E.jsx)(pr.Calculate,{})})})]})}))),yg=(0,Ft.forwardRef)((function(e,t){return(0,E.jsx)(vg,{...e,ref:t,className:"h-5 w-full flex-shrink-0 border border-neutral-400 px-1 pr-5 text-sm disabled:border-neutral-300 disabled:bg-neutral-50 disabled:text-neutral-300"})})),xg=(0,vt.PA)((e=>{const{value:t,updateValue:n}=e,[o,r]=(0,Ft.useState)(null);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("button",{className:"absolute right-0 top-0 flex h-5 w-5 items-center justify-center",title:"Open Date Picker...",onClick:e=>{r(e.currentTarget)},tabIndex:-1,children:(0,E.jsx)(pr.Calendar,{className:"text-lg text-neutral-500 hover:text-neutral-600"})}),(0,E.jsx)(Yn,{open:Boolean(o),anchorEl:o,anchorOrigin:{vertical:"bottom",horizontal:"center"},transformOrigin:{vertical:"top",horizontal:"center"},onClose:()=>r(null),classes:{root:"data-cube-editor-date-calendar mt-0.5",paper:"shadow-md rounded-none border border-neutral-300"},children:(0,E.jsx)(Eg,{autoFocus:!0,value:(0,_g.H)(t),onChange:e=>{n((0,Kn.GP)(e,Zr)),r(null)}})})]})})),Ig=(0,vt.PA)((0,Ft.forwardRef)((function(e,t){const{value:n,updateValue:o}=e;return(0,E.jsx)(Cg,{ref:t,value:(0,_g.H)(n),format:Zr,slots:{field:yg,openPickerButton:()=>(0,E.jsx)(xg,{value:n,updateValue:o})},onChange:e=>{e&&o((0,Kn.GP)(e,Zr))}})}))),wg=(0,vt.PA)((0,Ft.forwardRef)((function(e,t){const{value:n,updateValue:o,view:r}=e,i=r.filter,a=ra(i.columns,n),[s,l,c,u]=pu();return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(yu,{ref:t,className:"relative mr-1 w-32",onClick:s,open:u,children:n}),(0,E.jsx)(xu,{className:"w-32",...c,children:i.columns.filter((e=>a&&Qi(a.type)===Qi(e.type))).map((e=>(0,E.jsx)(Iu,{onClick:()=>{o(e.name),l()},autoFocus:n===e.name,children:e.name},e.name)))})]})}))),kg=(0,vt.PA)((0,Ft.forwardRef)((function(e,t){const{value:n,updateValue:o,view:r}=e;switch(n.type){case Wr.STRING:return(0,E.jsx)(Ng,{ref:t,value:n.value,updateValue:e=>o(e)});case Wr.NUMBER:case Wr.DECIMAL:case Wr.FLOAT:case Wr.INTEGER:return(0,E.jsx)(Ag,{ref:t,value:n.value,updateValue:e=>o(e)});case Wr.DATE:case Wr.STRICTDATE:case Wr.DATETIME:return(0,E.jsx)(Ig,{ref:t,value:n.value,updateValue:e=>o(e)});case gi.COLUMN:return(0,E.jsx)(wg,{ref:t,value:n.value,updateValue:e=>o(e),view:r});default:return null}})));function Rg(){return(0,E.jsxs)("div",{className:"relative flex pl-2.5",children:[(0,E.jsx)("div",{className:"pointer-events-none absolute -left-2 h-0 w-0 border-[9px] border-neutral-600 border-b-transparent border-l-transparent border-t-transparent"}),(0,E.jsx)("div",{className:"mr-1 flex h-[18px] w-10 flex-shrink-0 items-center bg-neutral-600 pl-2 text-sm font-medium text-white",title:"Filter is inverted: select all but what matches.",children:"NOT"})]})}const Og=(0,vt.PA)((e=>{const{className:t,node:n,view:o}=e,r=o.filter;return(0,E.jsxs)("div",{className:Mn("flex h-3.5 w-14 flex-shrink-0 bg-neutral-100",t),children:[(0,E.jsx)("button",{className:"flex h-3.5 w-3.5 items-center justify-center rounded-bl-sm rounded-tl-sm border border-neutral-400 hover:bg-neutral-200",onClick:()=>r.addFilterNode(n),title:"Insert a new column filter, just after this filter.",children:(0,E.jsx)(pr.FilterAddOperator,{className:"stroke-[2.5] text-sm"})}),(0,E.jsx)("button",{className:"flex h-3.5 w-3.5 items-center justify-center border border-l-0 border-neutral-400 hover:bg-neutral-200",onClick:()=>r.removeFilterNode(n),title:"Remove this filter",children:(0,E.jsx)(pr.FilterRemoveOperator,{className:"stroke-[2.5] text-sm"})}),(0,E.jsx)("button",{className:"flex h-3.5 w-3.5 items-center justify-center border border-l-0 border-neutral-400 hover:bg-neutral-200",onClick:()=>r.layerFilterNode(n),title:"Put this filter in its own sub-group (and combine it with other filters).",children:(0,E.jsx)(pr.FilterGroupOperator,{className:"stroke-[2.5] text-sm"})}),(0,E.jsx)("button",{className:Mn("flex h-3.5 w-3.5 items-center justify-center rounded-br-sm rounded-tr-sm border border-l-0 border-neutral-400 hover:bg-neutral-200",{"bg-neutral-600":n.not,"border-neutral-600":n.not,"text-white":n.not,"hover:bg-neutral-600":n.not}),onClick:()=>n.setNot(!n.not),title:n.not?"Turn off the NOT operator on this filter to select only what matches.":"Turn on the NOT operator on this filter to select all but what matches.",children:(0,E.jsx)(pr.FilterNotOperator,{className:"stroke-[3] text-xs"})})]})})),Lg=(0,vt.PA)((e=>{const{node:t,level:n,view:o}=e,r=bu(),i=o.filter,a=t.parent,s=a?a.children.indexOf(t):void 0,l=(0,Ft.useRef)(null),[c,u,d,p]=pu(),[m,g,h,f]=pu(),C=(0,Ft.useCallback)((()=>l.current?.focus()),[]);return(0,E.jsxs)("div",{className:"group flex h-6 items-center",children:[(0,E.jsx)("div",{className:Mn("z-1 absolute h-6 w-full bg-opacity-50 group-hover:bg-sky-100 group-hover:bg-opacity-50",{"bg-sky-50":t===i.selectedNode,"border-[0.5px] border-l-2 border-sky-200 border-l-sky-600":t===i.selectedNode}),onClick:()=>i.setSelectedNode(t)}),(0,E.jsx)("div",{style:{paddingLeft:36*n+10+60*(n-1)+"px"},className:"relative h-6 flex-shrink-0",onClick:()=>i.setSelectedNode(t),children:a&&(0,E.jsxs)("div",{className:"absolute top-0 flex h-6 items-center justify-end",style:{width:"22px",right:"8px"},children:[(0,E.jsx)("div",{className:Mn("h-[1px] w-full flex-1 bg-neutral-200",{"bg-sky-600":a===i.selectedGroupNode})}),void 0!==s&&s>0&&(0,E.jsx)("div",{className:Mn("flex h-6 items-center justify-center pl-1 text-xs text-neutral-600",{"text-sky-600":a===i.selectedGroupNode}),children:a.operation===Ci.AND?"and":"or"})]})}),(0,E.jsx)(Og,{className:"relative mr-1",node:t,view:o}),t.not&&(0,E.jsx)(Rg,{}),(0,E.jsx)(yu,{className:"relative mr-1 w-32",onClick:c,open:p,children:t.column.name}),(0,E.jsx)(xu,{className:"w-32",...d,onClosed:C,children:i.columns.map((e=>(0,E.jsx)(Iu,{onClick:()=>{if(e!==t.column){const n=t.operation.isCompatibleWithColumn(e)?t.operation:r.engine.filterOperations.filter((t=>t.isCompatibleWithColumn(e)))[0];n&&(t.setColumn(e),t.setOperation(n),t.setValue(n.generateDefaultValue(e)))}u()},autoFocus:t.column.name===e.name,children:e.name},e.name)))}),(0,E.jsx)(yu,{className:"relative mr-1 w-24",onClick:m,open:f,children:t.operation.label}),(0,E.jsx)(xu,{className:"w-24",...h,onClosed:C,children:r.engine.filterOperations.filter((e=>e.isCompatibleWithColumn(t.column))).map((e=>(0,E.jsx)(Iu,{onClick:()=>{e!==t.operation&&e.isCompatibleWithColumn(t.column)&&(t.setOperation(e),t.setValue(e.generateDefaultValue(t.column))),g()},autoFocus:t.operation.operator===e.operator,children:e.label},e.operator)))}),(0,E.jsx)("div",{className:"relative w-32 flex-shrink-0",children:(0,E.jsx)(kg,{ref:l,value:t.value,updateValue:e=>t.updateValue(e),view:o})})]})})),Fg=(0,vt.PA)((e=>{const{node:t,level:n,view:o}=e,r=o.filter,i=t.parent,a=i?i.children.indexOf(t):void 0,[s,l,c,u]=pu();return(0,E.jsxs)("div",{className:"group flex h-6 items-center",children:[(0,E.jsx)("div",{className:Mn("z-1 absolute h-6 w-full bg-opacity-50 group-hover:bg-sky-100 group-hover:bg-opacity-50",{"bg-sky-50":t===r.selectedNode,"border-[0.5px] border-l-2 border-sky-200 border-l-sky-600":t===r.selectedNode}),onClick:()=>r.setSelectedNode(t)}),(0,E.jsx)("div",{style:{paddingLeft:36*n+10+(0!==n?60*(n-1):0)+"px"},className:"relative h-6 flex-shrink-0",onClick:()=>r.setSelectedNode(t),children:0!==n&&i&&(0,E.jsxs)("div",{className:"absolute top-0 flex h-6 items-center justify-end",style:{width:"22px",right:"8px"},children:[(0,E.jsx)("div",{className:Mn("h-[1px] w-full flex-1 bg-neutral-200",{"bg-sky-600":i===r.selectedGroupNode})}),void 0!==a&&a>0&&(0,E.jsx)("div",{className:Mn("flex h-6 items-center justify-center pl-1 text-xs text-neutral-600",{"text-sky-600":i===r.selectedGroupNode}),children:i.operation===Ci.AND?"and":"or"})]})}),0!==n&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(Og,{className:"relative mr-1",node:t,view:o}),t.not&&(0,E.jsx)(Rg,{})]}),(0,E.jsx)(yu,{className:"relative w-14",onClick:s,open:u,children:t.operation===Ci.AND?"All of":"Any of"}),(0,E.jsxs)(xu,{className:"w-14",...c,children:[(0,E.jsx)(Iu,{onClick:()=>{t.setOperation(Ci.AND),l()},autoFocus:t.operation===Ci.AND,children:"All of"}),(0,E.jsx)(Iu,{onClick:()=>{t.setOperation(Ci.OR),l()},autoFocus:t.operation===Ci.OR,children:"Any of"})]})]})})),Dg=(0,vt.PA)((e=>{const{node:t,level:n,view:o}=e,r=o.filter;return(0,E.jsxs)("div",{className:"relative w-full",children:[(0,E.jsx)("div",{className:Mn("pointer-events-none absolute h-full",{"border-[0.5px] border-sky-200 bg-sky-50":t===r.selectedGroupNode}),style:{marginLeft:36*n+10+60*n-2+"px",width:`calc(100% - ${36*n+10+60*n-4}px)`}}),(0,E.jsx)(Fg,{node:t,level:n,view:o}),(0,E.jsxs)("div",{className:"relative",children:[(0,E.jsx)("div",{className:Mn("pointer-events-none absolute z-10 h-[calc(100%_-_12px)] w-0 border-l border-neutral-200",{"border-sky-600":t===r.selectedGroupNode}),style:{marginLeft:36*n+10+6+60*n+"px"}}),t.children.map((e=>e instanceof sm?(0,E.jsx)(Lg,{level:n+1,node:e,view:o},e.uuid):e instanceof lm?(0,E.jsx)(Dg,{level:n+1,node:e,view:o},e.uuid):null))]})]})})),Pg=(0,vt.PA)((e=>{const{view:t}=e,n=t.filter,o=()=>{t.dataCube.telemetryService.sendTelemetry(Ud.APPLY_CHANGES_FILTER,t.engine.getDataFromSource(t.getInitialSource()))};return(0,Ft.useEffect)((()=>{n.setSelectedNode(void 0)}),[n]),(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"relative h-[calc(100%_-_40px)] w-full px-2 pt-2",children:(0,E.jsx)("div",{className:"h-full w-full overflow-auto border border-neutral-300 bg-white",children:(0,E.jsx)("div",{className:"h-full w-full select-none p-2",children:(0,E.jsx)("div",{className:"flex h-full w-full",children:(0,E.jsxs)("div",{className:"relative flex h-full w-full overflow-auto rounded-sm border border-neutral-200",onClick:()=>n.setSelectedNode(void 0),children:[!n.tree.root&&(0,E.jsxs)("div",{className:"h-full w-full p-3",children:[(0,E.jsx)("div",{children:"No filter is specified. Click the button below to start."}),(0,E.jsx)(Tu,{onClick:()=>{n.initializeTree()},children:"Create New Filter"})]}),n.tree.root&&(0,E.jsxs)("div",{className:"flex flex-col py-1",onClick:e=>e.stopPropagation(),children:[(0,E.jsx)(Dg,{node:n.tree.root,level:0,view:t}),(0,E.jsx)("div",{className:"min-h-6 w-full flex-1",onClick:()=>n.setSelectedNode(void 0)})]})]})})})})}),(0,E.jsxs)("div",{className:"flex h-10 items-center justify-end px-2",children:[(0,E.jsx)(Tu,{onClick:()=>n.display.close(),children:"Cancel"}),(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>{n.applyChanges(),o()},children:"Apply"}),(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>{n.applyChanges(),n.display.close(),o()},children:"OK"})]})]})}));class Bg extends om{_view;display;tree;selectedNode;columns=[];constructor(e){super(e.engine,e.settingService,e.snapshotService),(0,Ie.Gn)(this,{tree:Ie.sH.ref,initializeTree:Ie.XI,refreshTree:Ie.XI,columns:Ie.sH.struct,applySnapshot:Ie.XI,selectedNode:Ie.sH,selectedGroupNode:Ie.EW,setSelectedNode:Ie.XI,addFilterNode:Ie.XI,removeFilterNode:Ie.XI,layerFilterNode:Ie.XI}),this._view=e,this.display=this._view.dataCube.layoutService.newDisplay("Filter",(()=>(0,E.jsx)(Pg,{view:this._view})),{x:-50,y:50,width:600,height:400,minWidth:300,minHeight:200,center:!1}),this.tree={nodes:new Map}}initializeTree(){if(void 0===this.tree.root&&0===this.tree.nodes.size){const e=new lm(void 0,Ci.AND,void 0);this.tree.nodes.set(e.uuid,e),this.tree.root=e;const t=this.generateNewFilterNode(e);t&&(e.addChild(t),this.tree.nodes.set(t.uuid,t)),this.refreshTree()}}refreshTree(){this.tree={...this.tree}}get selectedGroupNode(){return this.selectedNode instanceof lm?this.selectedNode:this.selectedNode?.parent}setSelectedNode(e){this.selectedNode=e}generateNewFilterNode(e){if(e instanceof sm)return new sm(void 0,e.column,e.operation,(0,im.A)(e.value),e.not);if(e instanceof lm&&0!==this.columns.length){const e=N(this.columns,0),t={name:e.name,type:e.type},n=this._engine.getFilterOperation(Ei.EQUAL);return new sm(void 0,t,n,n.generateDefaultValue(t),void 0)}}addFilterNode(e){if(this.tree.root){const t=this.generateNewFilterNode(e),n=e.parent;n&&t&&(n.addChild(t,e instanceof sm?n.children.indexOf(e)+1:void 0),this.tree.nodes.set(t.uuid,t),this.refreshTree())}}removeFilterNode(e){if(this.tree.root){const t=e.parent;if(e!==this.tree.root&&t){let n=[e];for(;n.length;)n.forEach((e=>{e instanceof lm&&e.children.forEach((e=>{e.setParent(void 0)})),this.tree.nodes.delete(e.uuid)})),n=Array.from(this.tree.nodes.values()).filter((e=>e!==this.tree.root&&!e.parent));if(t.removeChild(e),this.tree.nodes.delete(e.uuid),1===t.children.length){if(t!==this.tree.root){const e=N(t.children,0),n=D(t.parent);t.removeChild(e);const o=n.children.indexOf(t);n.removeChild(t),this.tree.nodes.delete(t.uuid),n.addChild(e,o)}}else 0===t.children.length&&t===this.tree.root&&(this.tree.root=void 0,this.tree.nodes.delete(t.uuid));this.refreshTree(),this.selectedNode===e&&this.setSelectedNode(void 0)}}}layerFilterNode(e){if(this.tree.root){const t=this.generateNewFilterNode(e),n=e.parent;if(n&&t){const o=n.children.indexOf(e);n.removeChild(e);const r=new lm(void 0,Ci.OR,void 0);r.addChild(e),r.addChild(t),n.addChild(r,o),this.tree.nodes.set(r.uuid,r),this.tree.nodes.set(t.uuid,t),this.refreshTree(),this.selectedNode===e&&this.setSelectedNode(r)}}}getSnapshotSubscriberName(){return"filter-editor"}async applySnapshot(e,t){const n=da.serialization.fromJson(e.data.configuration);this.columns=n.columns.filter((t=>!ra(e.data.groupExtendedColumns,t.name))),this.tree.nodes=new Map,this.tree.root=e.data.filter?um(e.data.filter,void 0,this.tree.nodes,(e=>this._engine.getFilterOperation(e))):void 0,this.setSelectedNode(void 0),this.refreshTree()}applyChanges(){const e=D(this.getLatestSnapshot()),t=e.clone();t.data.filter=this.tree.root?cm(this.tree.root):void 0,t.finalize(),t.hashCode!==e.hashCode&&this.publishSnapshot(t)}}const jg=(0,vt.PA)((e=>{const{state:t}=e,n=(0,Ft.useRef)(null),[o,r]=(0,Ft.useState)(),i=(0,Ft.useRef)(void 0),a=(0,Ft.useMemo)((()=>(0,Bn.A)((()=>{t.getReturnType().catch((e=>{t.alertHandler(e)}))}),500)),[t]);return(0,Ft.useEffect)((()=>{if(!o&&n.current){const e=n.current,o=document.getElementById(Sr),s=Nr.editor.create(e,{contextmenu:!1,copyWithSyntaxHighlighting:!1,fontSize:14,fontFamily:"Roboto Mono",fontLigatures:!0,fixedOverflowWidgets:!0,detectIndentation:!1,tabSize:2,"bracketPairColorization.enabled":!1,automaticLayout:!0,fontSize:12,language:lu.PURE,theme:Xc.GITHUB_LIGHT,wordSeparators:Pu,fixedOverflowWidgets:!0,...L(o)?{overflowWidgetsDomNode:o}:{}});i.current?.dispose(),i.current=Nr.languages.registerCompletionItemProvider(lu.PURE,{triggerCharacters:[...Pu,"$"],provideCompletionItems:async(e,n,o)=>{let r=[];return e.uri===t.editorModelUri&&(r=r.concat(await async function(e,t,n,o,r,i){const a=t.getValueInRange({startLineNumber:1,startColumn:1,endLineNumber:e.lineNumber,endColumn:e.column}),s=t.getWordAtPosition(e);let l=[];try{l=await o.getQueryTypeahead((n??"")+a,i(),r)}catch{}return l.map((t=>({label:t.display,kind:Nr.languages.CompletionItemKind.Text,filterText:t.display,insertTextRules:Nr.languages.CompletionItemInsertTextRule.InsertAsSnippet,insertText:t.completion,range:{startLineNumber:e.lineNumber,startColumn:s?.startColumn??e.column,endLineNumber:e.lineNumber,endColumn:s?.endColumn??e.column}})))}(n,e,t.codePrefix,t.engine,D(t.model),t.queryLambda))),{suggestions:r}}}),s.setModel(t.editorModel),s.onDidChangeModelContent((()=>{t.currentlyEditing=!0;const e=s.getValue();e!==t.code&&((0,Ie.h5)((()=>{t.code=e})),t.clearError(),t.setReturnType(void 0),a.cancel(),a())})),s.focus(),s.setPosition({lineNumber:1,column:t.code.length+1}),t.setEditor(s),r(s)}}),[t,o,a]),(0,Ft.useEffect)((()=>()=>{o&&(o.dispose(),i.current?.dispose())}),[o]),(0,Ft.useEffect)((()=>{t.editor?.updateOptions({readOnly:t.finalizationState.isInProgress})}),[t,t.finalizationState.isInProgress]),(0,E.jsxs)("div",{className:Mn("relative h-full w-full border border-neutral-200",{"border-red-500":t.hasErrors}),children:[(0,E.jsx)("div",{className:"absolute left-0 top-0 h-full w-full overflow-hidden"}),(0,E.jsx)("div",{ref:n,style:{height:"100%",width:"100%"}})]})}));var Mg;!function(e){e.LEAF_LEVEL_MEASURE="Leaf Level Measure",e.LEAF_LEVEL_DIMENSION="Leaf Level Dimension",e.GROUP_LEVEL="Group Level"}(Mg||(Mg={}));const Ug=(0,vt.PA)((e=>{const{state:t}=e,n=bu(),o=t.view,r=o.extend,i=(0,Ft.useRef)(null),a=t.isGroupLevel?Mg.GROUP_LEVEL:t.columnKind===mi.MEASURE?Mg.LEAF_LEVEL_MEASURE:Mg.LEAF_LEVEL_DIMENSION,[s,l,c,u]=pu(),[d,p,m,g]=pu(),h=(0,Ft.useMemo)((()=>(0,Bn.A)((()=>{t.getReturnType().catch((e=>n.alertService.alertUnhandledError(e)))}),500)),[t,n]);return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"h-[calc(100%_-_40px)] w-full px-2 pt-2",children:(0,E.jsx)("div",{className:"h-full w-full overflow-auto border border-neutral-300 bg-white",children:(0,E.jsxs)("div",{className:"h-full w-full select-none p-0",children:[(0,E.jsxs)("div",{className:"h-24 w-full p-2",children:[(0,E.jsxs)("div",{className:"mt-1 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-24 flex-shrink-0 items-center text-sm",children:"Column Name:"}),(0,E.jsx)(Su,{className:"w-32",ref:i,disabled:t.finalizationState.isInProgress,value:t.name,onChange:e=>{t.setName(e.target.value)}}),(0,E.jsx)("div",{className:"ml-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center text-lg",children:t.isNameValid?(0,E.jsx)(pr.CircleChecked,{className:"text-green-500"}):(0,E.jsx)(pr.CircledFailed,{className:"text-red-500"})})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsxs)("div",{className:"flex h-full w-24 flex-shrink-0 items-center text-sm",children:["Column Kind:",(0,E.jsx)(Ou,{className:"ml-1",documentationKey:Rm.EXTENDED_COLUMN_LEVELS})]}),(0,E.jsx)(yu,{className:"w-32",onClick:s,open:u,disabled:t.finalizationState.isInProgress,children:a}),(0,E.jsx)(xu,{className:"w-32",...c,children:[Mg.LEAF_LEVEL_MEASURE,Mg.LEAF_LEVEL_DIMENSION,Mg.GROUP_LEVEL].map((e=>(0,E.jsx)(Iu,{onClick:()=>{switch(e){case Mg.LEAF_LEVEL_MEASURE:t.setColumnKind(!1,mi.MEASURE);break;case Mg.LEAF_LEVEL_DIMENSION:t.setColumnKind(!1,mi.DIMENSION);break;case Mg.GROUP_LEVEL:t.setColumnKind(!0,void 0);break;default:return}t.clearError(),t.setReturnType(void 0),h.cancel(),h(),l()},autoFocus:e===a,children:e},e)))})]}),(0,E.jsxs)("div",{className:"mt-2 flex h-5 w-full items-center",children:[(0,E.jsx)("div",{className:"flex h-full w-24 flex-shrink-0 items-center text-sm",children:"Value Type:"}),(0,E.jsx)(yu,{className:"w-32",onClick:d,open:g,disabled:t.finalizationState.isInProgress,children:t.expectedType}),(0,E.jsx)("div",{className:"ml-0.5 flex h-5 w-5 flex-shrink-0 items-center justify-center text-lg",children:t.validationState.isInProgress?(0,E.jsx)(pr.Loader,{className:"animate-spin stroke-2 text-neutral-400"}):t.returnType?t.isTypeValid?(0,E.jsx)(pr.CircleChecked,{className:"text-green-500"}):(0,E.jsx)(pr.CircledFailed,{className:"text-red-500"}):null}),(0,E.jsx)(xu,{className:"w-32",...m,children:[_i.TEXT,_i.NUMBER,_i.DATE].map((e=>(0,E.jsx)(Iu,{onClick:()=>{t.setExpectedType(e),p()},autoFocus:e===t.expectedType,children:e},e)))})]})]}),(0,E.jsx)("div",{className:"h-[calc(100%_-_96px)] w-full p-2 pt-1",children:(0,E.jsx)(jg,{state:t})})]})})}),(0,E.jsxs)("div",{className:"flex h-10 items-center justify-end px-2",children:[(0,E.jsx)(Tu,{onClick:()=>t.close(),children:"Cancel"}),t instanceof Wg&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>{r.deleteColumn(t.initialData.name).catch((e=>n.alertService.alertUnhandledError(e)))},children:"Delete"}),(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>{t.reset().catch((e=>n.alertService.alertUnhandledError(e)))},children:"Reset"})]}),(0,E.jsx)(Tu,{className:"ml-2",disabled:!t.isNameValid||!t.isTypeValid||t.validationState.isInProgress||t.finalizationState.isInProgress,onClick:()=>{t.applyChanges().catch((e=>n.alertService.alertUnhandledError(e))),o.dataCube.telemetryService.sendTelemetry(Ud.ADD_NEW_COLUMN,o.engine.getDataFromSource(o.getInitialSource()))},children:"OK"})]})]})}));class Gg{uuid=(0,i.A)();editorModel;editor;editorModelUri;code="";codePrefix;returnType;finalizationState=we.create();codeError;model;engine;currentlyEditing;constructor(e){this.engine=e,this.codePrefix="",this.editorModelUri=Nr.Uri.file(`/${this.uuid}.pure`),this.editorModel=Nr.editor.createModel("",lu.PURE,this.editorModelUri)}get hasErrors(){return Boolean(this.codeError)}clearError(){this.codeError=void 0,su(this.uuid)}setReturnType(e){this.returnType=e}setEditor(e){this.editor=e}}class Hg extends Gg{uuid=(0,i.A)();_manager;view;_name=`col_${this.uuid.replaceAll("-","_")}`;display;validationState=we.create();name;expectedType;isGroupLevel;columnKind;codeSuffix;model;queryLambda;constructor(e,t,n,o,r){super(e.view.engine),(0,Ie.Gn)(this,{name:Ie.sH,setName:Ie.XI,isNameValid:Ie.EW,expectedType:Ie.sH,setExpectedType:Ie.XI,isTypeValid:Ie.EW,isGroupLevel:Ie.sH,columnKind:Ie.sH,setColumnKind:Ie.XI,editor:Ie.sH.ref,setEditor:Ie.XI,codeError:Ie.sH.ref,showError:Ie.XI,clearError:Ie.XI,returnType:Ie.sH,setReturnType:Ie.XI}),this._manager=e,this.view=e.view,this.model=e.view.source,this.engine=this.view.engine,this.display=this.newDisplay(this),this.name=t,this.expectedType=n,this.isGroupLevel=o,this.columnKind=r,this.codePrefix=`->extend(~${this._name}:`,this.codeSuffix=")",this.editorModelUri=Nr.Uri.file(`/${this.uuid}.pure`),this.editorModel=Nr.editor.createModel("",lu.PURE,this.editorModelUri),this.queryLambda=this.buildExtendBaseQuery}alertHandler=e=>{this.view.dataCube.alertService.alertUnhandledError(e)};async initialize(){this.code=await this.getInitialCode(),this.editorModel.setValue(this.code)}setName(e){this.name=e}get isNameValid(){return!this._manager.allColumnNames.includes(this.name)}setExpectedType(e){this.expectedType=e}get isTypeValid(){return void 0!==this.returnType&&this.expectedType===Qi(this.returnType)}setColumnKind(e,t){this.isGroupLevel=e,this.columnKind=t}showError(e){this.codeError=e,e.sourceInformation&&au(this.editorModel,[{message:e.message,startLineNumber:e.sourceInformation.startLine,startColumn:e.sourceInformation.startColumn,endLineNumber:e.sourceInformation.endLine,endColumn:e.sourceInformation.endColumn}],this.uuid)}buildExtendBaseQuery=()=>{const e=D(this._manager.getLatestSnapshot()).clone();return this.isGroupLevel||(e.data.leafExtendedColumns=[],e.data.selectColumns=[],e.data.filter=void 0,e.data.groupBy=void 0,e.data.pivot=void 0),e.data.groupExtendedColumns=[],e.data.sortColumns=[],e.data.limit=void 0,kl([],[mc(e,this.view.source,this.view.engine,{skipExecutionContext:!0})])};async getReturnType(){this.validationState.inProgress(),this.clearError(),this.setReturnType(void 0);try{const e=await this.view.engine.getQueryCodeRelationReturnType(this.codePrefix+this.code+this.codeSuffix,this.buildExtendBaseQuery(),this.view.source);let t=ra(e.columns,this._name)?.type;return t=t&&ta(t)?t:void 0,this.setReturnType(t),t}catch(e){if(w(e),e instanceof qm){if(this.validationState.fail(),e.sourceInformation){e.sourceInformation.startColumn-=1===e.sourceInformation.startLine?this.codePrefix.length:0,e.sourceInformation.endColumn-=1===e.sourceInformation.endLine?this.codePrefix.length:0;const t=this.editorModel.getFullModelRange();(e.sourceInformation.startLine<1||1===e.sourceInformation.startLine&&e.sourceInformation.startColumn<1||e.sourceInformation.endLine>t.endLineNumber||e.sourceInformation.endLine===t.endLineNumber&&e.sourceInformation.endColumn>t.endColumn)&&(e.sourceInformation.startColumn=t.startColumn,e.sourceInformation.startLine=t.startLineNumber,e.sourceInformation.endColumn=t.endColumn,e.sourceInformation.endLine=t.endLineNumber)}return void this.showError(e)}this.view.dataCube.alertService.alertError(e,{message:`Expression Validation Failure: ${e.message}`})}finally{this.validationState.complete()}}close(){this.editorModel.dispose(),this.editor?.dispose(),this.display.close()}}class Vg extends Hg{initialCode;constructor(e,t){var n;super(e,`col_${e.allColumnNames.length+1}`,t?Qi(t.type):_i.NUMBER,!1,t?t.kind:mi.MEASURE),this.initialCode=t?(n=t.name,Boolean(n.match(/\s/))?`${Ii}|$${Ii}.'${t.name}'`:`${Ii}|$${Ii}.${t.name}`):`${Ii}|`}async getInitialCode(){return this.initialCode}newDisplay(e){return this.view.dataCube.layoutService.newDisplay("Add New Column",(()=>(0,E.jsx)(Ug,{state:this})),{x:50,y:50,width:500,height:300,minWidth:300,minHeight:200,center:!1})}async applyChanges(){if(!this.validationState.hasCompleted||!this.isNameValid||!this.isTypeValid)return;let e,t;this.finalizationState.inProgress();try{[e,t]=await Promise.all([this.view.engine.parseValueSpecification(this.code,!1),this.getReturnType()])}catch(e){return w(e),void this.view.dataCube.alertService.alertError(e,{message:`Expression Validation Failure: ${e.message}`})}finally{this.finalizationState.complete()}e instanceof Gr?t?(this._manager.addNewColumn({name:this.name,type:t,mapFn:this.view.engine.serializeValueSpecification(e)},this.isGroupLevel,this.columnKind,this),this.close()):this.view.dataCube.alertService.alertError(new Error,{message:"Expression Validation Failure: Can't compute expression return type."}):this.view.dataCube.alertService.alertError(new Error,{message:"Expression Validation Failure: Expression must be a lambda."})}}class Wg extends Hg{initialData;constructor(e,t,n,o){super(e,t.name,Qi(t.type),o,n),(0,Ie.Gn)(this,{initialData:Ie.sH.ref,isNameValid:Ie.$Z}),this.initialData={name:t.name,type:t.type,kind:n,isGroupLevel:o,mapFn:t.mapFn}}get isNameValid(){return!this._manager.allColumnNames.filter((e=>e!==this.initialData.name)).includes(this.name)}async getInitialCode(){return this.view.engine.getValueSpecificationCode(this.view.engine.deserializeValueSpecification(this.initialData.mapFn),!0)}newDisplay(e){return this.view.dataCube.layoutService.newDisplay("Edit Column",(()=>(0,E.jsx)(Ug,{state:this})),{x:50,y:50,width:500,height:300,minWidth:300,minHeight:200,center:!1})}async reset(){this.setName(this.initialData.name),this.setExpectedType(Qi(this.initialData.type)),this.setColumnKind(this.initialData.isGroupLevel,this.initialData.kind),await this.initialize(),await this.getReturnType()}async applyChanges(){if(!this.validationState.hasCompleted||!this.isNameValid||!this.isTypeValid)return;let e,t;this.finalizationState.inProgress();try{[e,t]=await Promise.all([this.view.engine.parseValueSpecification(this.code,!1),this.getReturnType()])}catch(e){return w(e),void this.view.dataCube.alertService.alertError(e,{message:`Expression Validation Failure: ${e.message}`})}finally{this.finalizationState.complete()}e instanceof Gr?t?await this._manager.updateColumn(this.initialData.name,{name:this.name,type:t,mapFn:this.view.engine.serializeValueSpecification(e)},this.isGroupLevel,this.columnKind):this.view.dataCube.alertService.alertError(new Error,{message:"Expression Validation Failure: Can't compute expression return type."}):this.view.dataCube.alertService.alertError(new Error,{message:"Expression Validation Failure: Expression must be a lambda."})}}class zg{name;type;data;constructor(e){this.name=e.name,this.type=e.type,this.data=e}}class $g extends om{view;columnConfigurations=[];selectColumns=[];sourceColumns=[];horizontalPivotCastColumns=[];leafExtendedColumns=[];groupExtendedColumns=[];newColumnEditors=[];existingColumnEditors=[];constructor(e){super(e.engine,e.settingService,e.snapshotService),(0,Ie.Gn)(this,{sourceColumns:Ie.sH.ref,horizontalPivotCastColumns:Ie.sH.ref,leafExtendedColumns:Ie.sH,setLeafExtendedColumns:Ie.XI,groupExtendedColumns:Ie.sH,setGroupExtendedColumns:Ie.XI,allColumnNames:Ie.EW,addNewColumn:Ie.XI,updateColumn:Ie.XI,deleteColumn:Ie.XI,applySnapshot:Ie.XI}),this.view=e}setLeafExtendedColumns(e){this.leafExtendedColumns=e}setGroupExtendedColumns(e){this.groupExtendedColumns=e}get allColumnNames(){return(0,nt.A)([...this.sourceColumns,...this.leafExtendedColumns,...this.groupExtendedColumns,...this.horizontalPivotCastColumns],(e=>e.name)).map((e=>e.name))}async openNewColumnEditor(e){const t=new Vg(this,e);await t.initialize(),this.newColumnEditors.push(t),t.display.open()}async openExistingColumnEditor(e){const t=this.existingColumnEditors.find((t=>t.initialData.name===e));if(t)return void t.display.open();if(!ra(this.leafExtendedColumns,e)&&!ra(this.groupExtendedColumns,e))return;const n=new Wg(this,D(ra(this.leafExtendedColumns,e)??ra(this.groupExtendedColumns,e)).data,D(ra(this.columnConfigurations,e)).kind,Boolean(ra(this.groupExtendedColumns,e)));await n.initialize(),this.existingColumnEditors.push(n),n.display.open()}addNewColumn(e,t,n,o){const r=Pd(e);n&&(r.kind=n,r.excludedFromPivot=n===mi.DIMENSION),this.columnConfigurations.push(r),S(this.newColumnEditors,o),t?this.groupExtendedColumns.push(new zg(e)):(this.leafExtendedColumns.push(new zg(e)),this.selectColumns.push(ia(e))),this.applyChanges()}async updateColumn(e,t,n,o){if(!ra(this.leafExtendedColumns,e)&&!ra(this.groupExtendedColumns,e))return;const r=D(ra(this.columnConfigurations,e)),i=this.view.taskService.newTask("Checking column update..."),a=D(this.getLatestSnapshot()).clone();a.data.leafExtendedColumns=a.data.leafExtendedColumns.filter((t=>t.name!==e)),a.data.groupExtendedColumns=a.data.groupExtendedColumns.filter((t=>t.name!==e)),a.data.selectColumns=a.data.selectColumns.filter((t=>t.name!==e)),n?a.data.groupExtendedColumns.push(t):(a.data.leafExtendedColumns.push(t),r.isSelected&&a.data.selectColumns.push(ia(t))),a.data.configuration={...a.data.configuration,columns:this.columnConfigurations.map((n=>n.name===e?{...n.serialize(),...ia(t),kind:o}:n.serialize()))};const s=await this._engine.getPartialQueryCode(a,!0);try{await this._engine.getQueryCodeRelationReturnType("->"+s,kl([],[this.view.source.query]),this.view.source)}catch(t){return w(t),void(t instanceof qm?this.view.dataCube.alertService.alertCodeCheckError(t,s,"->",{message:`Column Update Check Failure: Can't safely update column '${e}'. Check the query code below for more details.`,text:`Error: ${t.message}`}):this.view.dataCube.alertService.alertError(t,{message:`Column Update Check Failure: Can't safely update column '${e}'.`,text:`Error: ${t.message}`}))}finally{this.view.taskService.endTask(i)}this.setLeafExtendedColumns(this.leafExtendedColumns.filter((t=>t.name!==e))),this.setGroupExtendedColumns(this.groupExtendedColumns.filter((t=>t.name!==e))),this.selectColumns=this.selectColumns.filter((t=>t.name!==e)),n?this.setGroupExtendedColumns([...this.groupExtendedColumns,new zg(t)]):(this.setLeafExtendedColumns([...this.leafExtendedColumns,new zg(t)]),r.isSelected&&this.selectColumns.push(ia(t))),this.columnConfigurations=this.columnConfigurations.map((n=>(n.name===e&&(n.kind=o??Qi(t.type)===_i.NUMBER?mi.MEASURE:mi.DIMENSION,n.name=t.name,n.type=t.type,n.excludedFromPivot=n.kind===mi.DIMENSION),n))),this.existingColumnEditors.filter((t=>t.initialData.name===e)).forEach((e=>e.display.close())),this.existingColumnEditors=this.existingColumnEditors.filter((t=>t.initialData.name!==e)),this.applyChanges()}async deleteColumn(e){if(!ra(this.leafExtendedColumns,e)&&!ra(this.groupExtendedColumns,e))return;const t=this.view.taskService.newTask("Checking column deletion..."),n=D(this.getLatestSnapshot()).clone();n.data.leafExtendedColumns=n.data.leafExtendedColumns.filter((t=>t.name!==e)),n.data.groupExtendedColumns=n.data.groupExtendedColumns.filter((t=>t.name!==e)),n.data.selectColumns=n.data.selectColumns.filter((t=>t.name!==e)),n.data.configuration={...n.data.configuration,columns:this.columnConfigurations.filter((t=>t.name!==e)).map((e=>e.serialize()))};const o=await this._engine.getPartialQueryCode(n,!0);try{await this._engine.getQueryCodeRelationReturnType("->"+o,kl([],[this.view.source.query]),this.view.source)}catch(t){return w(t),void(t instanceof qm?this.view.dataCube.alertService.alertCodeCheckError(t,o,"->",{message:`Column Delete Check Failure: Can't safely delete column '${e}'. Check the query code below for more details.`,text:`Error: ${t.message}`}):this.view.dataCube.alertService.alertError(t,{message:`Column Delete Check Failure: Can't safely delete column '${e}'.`,text:`Error: ${t.message}`}))}finally{this.view.taskService.endTask(t)}this.setLeafExtendedColumns(this.leafExtendedColumns.filter((t=>t.name!==e))),this.setGroupExtendedColumns(this.groupExtendedColumns.filter((t=>t.name!==e))),this.columnConfigurations=this.columnConfigurations.filter((t=>t.name!==e)),this.selectColumns=this.selectColumns.filter((t=>t.name!==e)),this.existingColumnEditors.filter((t=>t.initialData.name===e)).forEach((e=>e.display.close())),this.existingColumnEditors=this.existingColumnEditors.filter((t=>t.initialData.name!==e)),this.applyChanges()}getSnapshotSubscriberName(){return"extend-manager"}async applySnapshot(e,t){const n=da.serialization.fromJson(e.data.configuration);this.columnConfigurations=n.columns,this.sourceColumns=e.data.sourceColumns,this.leafExtendedColumns=e.data.leafExtendedColumns.map((e=>new zg(e))),this.groupExtendedColumns=e.data.groupExtendedColumns.map((e=>new zg(e))),this.horizontalPivotCastColumns=e.data.pivot?.castColumns??[],this.selectColumns=e.data.selectColumns.map(ia),[...this.newColumnEditors,...this.existingColumnEditors].forEach((e=>{e.getReturnType().catch((()=>{}))}))}applyChanges(){const e=D(this.getLatestSnapshot()),t=e.clone();t.data.configuration={...e.data.configuration,columns:this.columnConfigurations.map((e=>e.serialize()))},t.data.leafExtendedColumns=this.leafExtendedColumns.map((e=>e.data)),t.data.groupExtendedColumns=this.groupExtendedColumns.map((e=>e.data)),t.data.selectColumns=[...this.selectColumns],t.finalize(),t.hashCode!==e.hashCode&&this.publishSnapshot(t)}}class Yg{uuid=(0,i.A)();description;startTime=Date.now();ownerId;endTime;constructor(e,t){this.description=e,this.ownerId=t}end(){this.endTime=Date.now()}}class Xg{tasks=[];constructor(){(0,Ie.Gn)(this,{tasks:Ie.sH,newTask:Ie.XI,endTask:Ie.XI,endTasks:Ie.XI})}newTask(e,t){const n=new Yg(e,t);return this.tasks.push(n),n}endTask(e){return this.tasks.find((t=>t.uuid===e.uuid))&&(this.tasks=this.tasks.filter((t=>t.uuid!==e.uuid)),e.end()),e}endTasks(e){this.tasks=this.tasks.filter((t=>!e.find((e=>e.uuid===t.uuid)))),e.forEach((e=>e.end()))}}class Kg{uuid=(0,i.A)();manager;constructor(e){(0,Ie.Gn)(this,{tasks:Ie.EW}),this.manager=e??new Xg}get tasks(){return this.manager.tasks.filter((e=>e.ownerId===this.uuid))}newTask(e){return this.manager.newTask(e,this.uuid)}endTask(e){return this.manager.endTask(e)}dispose(){this.manager.endTasks(this.tasks)}}class qg extends fc{model;runtime;db;schema;table;count}class Jg{dataCube;engine;logService;taskService;layoutService;alertService;settingService;snapshotService;info;editor;grid;filter;extend;initializeState=we.create();processCacheState=we.create();_source;_initialSource;_initialSpecification;constructor(e){this.dataCube=e,this.engine=e.engine,this.logService=e.logService,this.taskService=new Kg(e.taskService.manager),this.layoutService=e.layoutService,this.alertService=e.alertService,this.settingService=e.settingService,this.snapshotService=new rm(this.logService,this.settingService),this.info=new lg(this),this.editor=new Qm(this),this.grid=new sg(this),this.filter=new Bg(this),this.extend=new $g(this)}getInitialSource(){return this._initialSource}async generateSpecification(){const e=this.snapshotService.getCurrentSnapshot(),t=new Dd;return t.source=this.dataCube.specification.source,t.configuration=da.serialization.fromJson(e.data.configuration),t.query=await this.engine.getPartialQueryCode(e),t.dimensionalTree=e.data.dimensionalTree,t}get source(){if(!this._source)throw new x("Source is not initialized");return this._source}updateName(e){const t=this.snapshotService.getCurrentSnapshot(),n=t.clone(),o=da.serialization.fromJson(t.data.configuration);o.name!==e&&(o.name=e,n.data.configuration=o.serialize(),n.finalize(),n.hashCode!==t.hashCode&&this.snapshotService.broadcastSnapshot(n))}async applySpecification(e){const t=this.taskService.newTask("Applying specification...");try{if(!this._initialSource||!this._initialSpecification)throw new Error("DataCube is not initialized");if(!(0,Oo.A)(e.source,this._initialSpecification.source))throw new Error("Can't apply specification with different source");const t=await this.engine.parseValueSpecification(e.query),n=await mg(t,this._initialSource,e,this.engine);n.finalize(),n.hashCode!==this.snapshotService.getCurrentSnapshot().hashCode&&this.snapshotService.broadcastSnapshot(n)}catch(e){w(e),this.alertService.alertError(e,{message:`Specification Application Failure: ${e.message}`}),this.initializeState.fail()}finally{this.taskService.endTask(t)}}async initializeCache(){this.processCacheState.inProgress();const e=this.taskService.newTask("Initializing cache...");try{const e=await this.engine.initializeCache(this.source,{debug:this.settingService.getBooleanValue(Uu.DEBUGGER__ENABLE_DEBUG_MODE),clientVersion:this.settingService.getBooleanValue(Uu.DEBUGGER__USE_DEV_CLIENT_PROTOCOL_VERSION)?gc.VX_X_X:void 0});e&&(this._source=e),this.processCacheState.pass()}catch(e){w(e),this.alertService.alertError(e,{message:`Cache Processing Failure: ${e.message}`}),this._source=this._initialSource,this.processCacheState.fail()}finally{this.taskService.endTask(e)}}async disposeCache(){if(!(this._source instanceof qg))return;const e=this._source;this._source=this._initialSource,this.processCacheState.inProgress();const t=this.taskService.newTask("Disposing cache...");try{await this.engine.disposeCache(e)}catch(e){w(e),this.alertService.alertError(e,{message:`Cache Processing Failure: ${e.message}`})}finally{this.processCacheState.complete(),this.taskService.endTask(t)}}async initialize(e){this.initializeState.inProgress();const t=this.taskService.newTask("Initializing...");try{await Promise.all([this.info,this.editor,this.grid,this.grid.controller,this.filter,this.extend].map((async e=>{this.snapshotService.registerSubscriber(e)})));const t=await this.engine.processSource(e.source);this._source=t,this._initialSource=t,this._initialSpecification=e;const n=await this.engine.parseValueSpecification(e.query),o=await mg(n,t,e,this.engine),r=e=>{this.dataCube.telemetryService.sendTelemetry(Ud.SELECT_ACTION_CACHE_LOAD_ALERT,{...this.engine.getDataFromSource(this._initialSource),keepCachingEnabled:e})};e.options?.autoEnableCache&&(await this.grid.setCachingEnabled(!0,{suppressWarning:!0}),this.grid.isCachingEnabled&&this.settingService.getBooleanValue(Uu.GRID_CLIENT__SHOW_AUTO_ENABLE_CACHE_PERFORMANCE_WARNING)&&this.alertService.alert({message:"Caching is auto-enabled for this DataCube",text:"When enabled, the source dataset will be cached locally in order to boost query performance. But depending on computational resource available to your environment, sometimes, caching can negatively impact the overall performance, and can even lead to crashes.\n\nOverall, caching is still an experimental feature where we only support queries with simple execution plans, certain queries might not work.\n\nYou can disable caching if needed, otherwise, please proceed with caution.",type:Mu.WARNING,actions:[{label:"OK",handler:()=>{r(!0)}},{label:"Disable Caching",handler:()=>{r(!1),this.grid.setCachingEnabled(!1,{suppressWarning:!0}).catch((e=>this.alertService.alertUnhandledError(e)))}},{label:"Dismiss Warning",handler:()=>{r(!0),this.settingService.updateValue(this.dataCube.api,Uu.GRID_CLIENT__SHOW_AUTO_ENABLE_CACHE_PERFORMANCE_WARNING,!1)}}],windowConfig:{...Er,width:600,height:300,minWidth:300,minHeight:150}})),this.snapshotService.broadcastSnapshot(o),this.dataCube.options?.onViewInitialized?.({api:this.dataCube.api,source:t}),this.initializeState.pass()}catch(e){w(e),this.alertService.alertError(e,{message:`Initialization Failure: ${e.message}`,text:"Resolve the issue and reload the engine."}),this.initializeState.fail()}finally{this.taskService.endTask(t)}}dispose(){this.taskService.dispose()}}const Qg=(0,vt.PA)((e=>{const{configuration:t}=e,n=bu(),o=n.settingService;switch(t.type){case th.BOOLEAN:{const e=$(o.currentValues.get(t.key));return(0,E.jsxs)("div",{className:"my-2",children:[(0,E.jsx)("div",{className:"font-medium",children:t.title}),(0,E.jsx)("div",{className:"flex pr-2",children:(0,E.jsx)(Au,{label:t.description,checked:e,onChange:()=>{(0,Ie.h5)((()=>{o.currentValues.set(t.key,!e)}))}})})]})}case th.NUMERIC:{const e=z(o.currentValues.get(t.key)),n=t.defaultValue;return(0,E.jsxs)("div",{className:"my-2",children:[(0,E.jsx)("div",{className:"font-medium",children:t.title}),(0,E.jsx)("div",{className:"mb-1.5 text-sm text-neutral-700",children:t.description}),(0,E.jsx)(Nu,{className:"w-20 text-sm",min:t.numericValueMin,step:t.numericValueStep,max:t.numericValueMax,defaultValue:n,value:e,setValue:e=>{(0,Ie.h5)((()=>{o.currentValues.set(t.key,e??n)}))}})]})}case th.STRING:{const e=W(o.currentValues.get(t.key));return(0,E.jsxs)("div",{className:"my-2",children:[(0,E.jsx)("div",{className:"font-medium",children:t.title}),(0,E.jsx)("div",{className:"mb-1.5 text-sm text-neutral-700",children:t.description}),(0,E.jsx)(Su,{className:"w-80 text-sm",value:e,onChange:e=>{(0,Ie.h5)((()=>{o.currentValues.set(t.key,e.target.value)}))}})]})}case th.ACTION:return(0,E.jsxs)("div",{className:"my-2",children:[(0,E.jsx)("div",{className:"font-medium",children:t.title}),(0,E.jsx)("div",{className:"mb-1.5 text-sm text-neutral-700",children:t.description}),(0,E.jsx)("div",{className:"flex pr-2",children:(0,E.jsx)(Tu,{compact:!0,onClick:()=>t.action?.(n.api,void 0),children:"Run Action"})})]});default:return null}})),Zg=(0,vt.PA)((()=>{const e=bu(),t=e.settingService,n=Array.from(t.configurations.values()).toSorted(((e,t)=>e.title.localeCompare(t.title)));return(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)("div",{className:"h-[calc(100%_-_40px)] w-full p-2 pb-0",children:(0,E.jsxs)("div",{className:"h-full w-full select-none overflow-auto border border-neutral-300 bg-white p-2",children:[(0,E.jsx)("div",{className:"mt-1 flex h-5",children:(0,E.jsxs)("div",{className:"flex h-full",children:[(0,E.jsx)("div",{className:"flex h-5 items-center text-xl font-medium",children:(0,E.jsx)(pr.Table,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-5 items-center text-xl font-medium",children:"Grid"})]})}),n.filter((e=>e.group===eh.GRID)).map((e=>(0,E.jsx)(Qg,{configuration:e},e.key))),(0,E.jsx)("div",{className:"my-2 h-[1px] w-full bg-neutral-200"}),(0,E.jsx)("div",{className:"mt-1 flex h-5",children:(0,E.jsxs)("div",{className:"flex h-full",children:[(0,E.jsx)("div",{className:"flex h-5 items-center text-xl font-medium",children:(0,E.jsx)(pr.Debug,{})}),(0,E.jsx)("div",{className:"ml-1 flex h-5 items-center text-xl font-medium",children:"Debug"})]})}),n.filter((e=>e.group===eh.DEBUG)).map((e=>(0,E.jsx)(Qg,{configuration:e},e.key)))]})}),(0,E.jsxs)("div",{className:"flex h-10 items-center justify-end px-2",children:[(0,E.jsx)(Tu,{onClick:()=>t.restoreDefaultValues(),disabled:!t.allowRestoreDefaultValues,children:"Restore Default Settings"}),(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>{t.display.close()},children:"Cancel"}),(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>t.save(e.api),children:"Apply"}),(0,E.jsx)(Tu,{className:"ml-2",onClick:()=>{t.save(e.api),t.display.close()},children:"OK"})]})]})}));var eh,th,nh,oh,rh,ih;!function(e){e.DEBUG="Debug",e.EDITOR="Editor",e.GRID="Grid"}(eh||(eh={})),function(e){e.BOOLEAN="boolean",e.NUMERIC="numeric",e.STRING="string",e.ACTION="action"}(th||(th={}));class ah{_engine;_logService;_layoutService;_options;display;configurations=new Map;defaultValues=new Map;_defaultValuesHashCode;values=new Map;currentValues=new Map;constructor(e,t,n,o){(0,Ie.Gn)(this,{values:Ie.sH,save:Ie.XI,valuesHashCode:Ie.EW,currentValues:Ie.sH,restoreDefaultValues:Ie.XI,currentValuesHashCode:Ie.EW,allowRestoreDefaultValues:Ie.EW}),this._engine=e,this._logService=t,this._layoutService=n,this._options=o,this.display=this._layoutService.newDisplay("Settings",(()=>(0,E.jsx)(Zg,{})),{x:-50,y:50,width:600,height:400,minWidth:300,minHeight:200,center:!1});const r=[{key:Uu.DEBUGGER__ENABLE_DEBUG_MODE,title:"Debug Mode: Enabled",description:"Enables debug logging when running data queries, updating snapshots, etc.",group:eh.DEBUG,type:th.BOOLEAN,defaultValue:!1},{key:Uu.DEBUGGER__USE_DEV_CLIENT_PROTOCOL_VERSION,title:"Use development client protocol version: Enabled",description:"Specifies if development client protocol version (vX_X_X) should be used for execution",group:eh.DEBUG,type:th.BOOLEAN,defaultValue:!1},{key:Uu.DEBUGGER__ACTION__RELOAD,title:"Reload",description:"Manually reload DataCube (keeping all states). This is needed when making changes to settings that require reloading to take effect.",group:eh.DEBUG,type:th.ACTION,action:e=>e.reload(),defaultValue:void 0},{key:Uu.GRID_CLIENT__SHOW_CACHE_PERFORMANCE_WARNING,title:"Caching Performance Warning: Enabled",description:"Alerts user of potential performance and resource-related issues that caching can cause when enabled.",group:eh.GRID,type:th.BOOLEAN,defaultValue:!0},{key:Uu.GRID_CLIENT__SHOW_AUTO_ENABLE_CACHE_PERFORMANCE_WARNING,title:"Caching (Auto-Enabled) Performance Warning: Enabled",description:"Alerts user that caching is auto-enabled for the DataCube and of potential performance and resource-related issues that caching can cause when enabled.",group:eh.GRID,type:th.BOOLEAN,defaultValue:!0},{key:Uu.EDITOR__MAX_HISTORY_STACK_SIZE,title:"Max History Stack Size",description:"Sets the number of maximum snapshots to store in edit history.",group:eh.EDITOR,type:th.NUMERIC,defaultValue:100,numericValueMin:10,numericValueStep:10,action:(e,t)=>e._runTaskForEachView((e=>{e.snapshotService.adjustHistorySize(t)}))},{key:Uu.GRID_CLIENT__SUPPRESS_LARGE_DATASET_WARNING,title:"Large Dataset Warning: Disabled",description:"Suggests user to enable pagination when handling large datasets to improve performance.",group:eh.GRID,type:th.BOOLEAN,defaultValue:!1},{key:Uu.GRID_CLIENT__ROW_BUFFER,title:"Row Buffer",description:"Sets the number of rows the grid renders outside of the viewable area. e.g. if the buffer is 10 and your grid is showing 50 rows (as that's all that fits on your screen without scrolling), then the grid will actually render 70 in total (10 extra above and 10 extra below). Then when you scroll, the grid will already have 10 rows ready and waiting to show, no redraw is needed. A low small buffer will make initial draws of the grid faster; whereas a big one will reduce the redraw visible vertically scrolling.",group:eh.GRID,type:th.NUMERIC,defaultValue:50,numericValueMin:10,numericValueStep:10,action:(e,t)=>e._runTaskForEachView((e=>{e.grid.isClientConfigured&&e.grid.client.updateGridOptions({rowBuffer:t})}))},{key:Uu.GRID_CLIENT__PURGE_CLOSED_ROW_NODES,title:"Refresh Group Node Data: Enabled",description:"Forces refresh data when group node is opened.",group:eh.GRID,type:th.BOOLEAN,defaultValue:!1,action:(e,t)=>e._runTaskForEachView((e=>{e.grid.isClientConfigured&&e.grid.client.updateGridOptions({purgeClosedRowNodes:t})}))},{key:Uu.GRID_CLIENT__ACTION__RETRY_FAILED_DATA_FETCHES,title:"Retry Failed Data Fetches: Action",description:"Manually re-runs all failed data fetches in the grid.",group:eh.GRID,type:th.ACTION,action:e=>e.retryFailedDataFetches(),defaultValue:void 0}],{configurations:i,values:a}=o?.settingsData??{};[...r,...i??[]].forEach((e=>{this.configurations.set(e.key,e),this.setValue(e.key,e.defaultValue,[this.defaultValues,this.values,this.currentValues])}));const s=a??{};Object.keys(s).forEach((e=>{const t=s[e];this.configurations.get(e)&&this.setValue(e,t,[this.values,this.currentValues])})),this._defaultValuesHashCode=this.computeValuesHashCode(this.defaultValues)}setValue(e,t,n){const o=this.configurations.get(e);if(!o)return this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__FOUND_UNREGISTERED_SETTING),`Can't set value for unregistered setting '${e}'`),!1;switch(o.type){case th.BOOLEAN:if(!(H(t)||void 0===t&&o.valueOptional))return this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__FOUND_UNREGISTERED_SETTING),`Can't set value for setting '${e}': boolean value expected`),!1;break;case th.NUMERIC:if(!(G(t)||void 0===t&&o.valueOptional))return this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__FOUND_UNREGISTERED_SETTING),`Can't set value for setting '${e}': numeric value expected`),!1;break;case th.STRING:if(!(U(t)||void 0===t&&o.valueOptional))return this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__FOUND_UNREGISTERED_SETTING),`Can't set value for setting '${e}': string value expected`),!1;break;case th.ACTION:return!1;default:throw new I(`Can't set value for unsupported setting type '${o.type}'`)}return n.forEach((n=>{(0,Ie.h5)((()=>n.set(e,t)))})),!0}getConfiguration(e){const t=this.configurations.get(e);if(!t)throw this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__FOUND_UNREGISTERED_SETTING),`Can't retrieve value for unregistered setting '${e}'`),new x(`Can't retrieve value for unregistered setting '${e}'`);return t}getBooleanValue(e){const t=this.values.get(e);if(this.getConfiguration(e).type!==th.BOOLEAN||!H(t))throw this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__RETRIEVE_INCOMPATIBLE_VALUE),`Can't retrieve boolean value for setting '${e}'`),new x(`Can't retrieve boolean value for setting '${e}'`);return t}getNumericValue(e){const t=this.values.get(e);if(this.getConfiguration(e).type!==th.NUMERIC||!G(t))throw this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__RETRIEVE_INCOMPATIBLE_VALUE),`Can't retrieve numeric value for setting '${e}'`),new x(`Can't retrieve numeric value for setting '${e}'`);return t}getStringValue(e){const t=this.values.get(e);if(this.getConfiguration(e).type!==th.STRING||!U(t))throw this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__RETRIEVE_INCOMPATIBLE_VALUE),`Can't retrieve string value for setting '${e}'`),new x(`Can't retrieve string value for setting '${e}'`);return t}computeValuesHashCode(e){return Fr(Array.from(e.entries()).toSorted(((e,t)=>e[0].localeCompare(t[0]))).map((([e,t])=>`${e}:${t}`)))}get valuesHashCode(){return this.computeValuesHashCode(this.values)}get currentValuesHashCode(){return this.computeValuesHashCode(this.currentValues)}get allowRestoreDefaultValues(){return this._defaultValuesHashCode!==this.currentValuesHashCode}restoreDefaultValues(){this.currentValues.clear(),this.defaultValues.forEach(((e,t)=>this.currentValues.set(t,e)))}getCurrentSettingValues(){const e={};return this.values.forEach(((t,n)=>{const o=this.configurations.get(n);o&&t!==o.defaultValue&&(e[n]=t)})),e}updateValue(e,t,n){const o=this.configurations.get(t);o?this.setValue(t,n,[this.values,this.currentValues])&&(this._options?.onSettingsChanged?.({api:e,values:this.getCurrentSettingValues()}),o.action?.(e,n)):this._logService.logWarning(c.create(Ud.SETTINGS__FAILURE__FOUND_UNREGISTERED_SETTING),`Can't set value for unregistered setting '${t}'`)}save(e){const t=new Set;this.values.forEach(((e,n)=>{e!==this.currentValues.get(n)&&t.add(n)})),this.values.clear(),this.currentValues.forEach(((e,t)=>this.values.set(t,e))),this._options?.onSettingsChanged?.({api:e,values:this.getCurrentSettingValues()});let n=!1;for(const o of t){const t=this.configurations.get(o);t?.requiresReload&&(n=!0),t?.action&&t.action(e,this.values.get(o))}n&&e.reload()}}class sh{_dataCube;constructor(e){this._dataCube=e}_runTaskForEachView(e){e(this._dataCube.view)}getProcessedSource(){return this._dataCube.view.getInitialSource()}generateSpecification(){return this._dataCube.view.generateSpecification()}updateName(e){this._dataCube.view.updateName(e)}async applySpecification(e){await this._dataCube.view.applySpecification(e)}retryFailedDataFetches(){this._runTaskForEachView((e=>{e.grid.isClientConfigured&&e.grid.client.retryServerSideLoads()}))}reload(){this._dataCube.reload()}isCachingEnabled(){return this._dataCube.view.grid.isCachingEnabled}}!function(e){e.PROFILE="Profile",e.CLASS="Class",e.ENUMERATION="Enum",e.MEASURE="Measure",e.ASSOCIATION="Association",e.FUNCTION="function",e.MAPPING="Mapping",e.FLAT_DATA="FlatData",e.DATABASE="Database",e.SERVICE="Service",e.RUNTIME="Runtime",e.CONNECTION="Connection",e.FILE_GENERATION="FileGeneration",e.GENERATION_SPECIFICATION="GenerationSpecification",e.DATA_ELEMENT="Data",e.EXECUTION_ENVIRONMENT="ExecutionEnvironment"}(nh||(nh={})),function(e){e.JSON_MODEL_CONNECTION="JsonModelConnection",e.XML_MODEL_CONNECTION="XmlModelConnection",e.MODEL_CHAIN_CONNECTION="ModelChainConnection",e.RELATIONAL_DATABASE_CONNECTION="RelationalDatabaseConnection",e.FLAT_DATA_CONNECTION="FlatDataConnection"}(oh||(oh={})),(ih=rh||(rh={})).PURE="Pure",ih.CONNECTION="Connection",ih.RUNTIME="Runtime",ih.MAPPING="Mapping",ih.SERVICE="Service",ih.FLATDATA="FlatData",ih.RELATIONAL="Relational",ih.GENERATION_SPECIFICATION="GenerationSpecification",ih.FILE_GENERATION_SPECIFICATION="FileGeneration",ih.DATA="Data";const lh={wordPattern:/(-?\d*\.\d\w*)|([^`~!@#%^$&*()\-=+[{\]}\\|;:'",.<>/?\s][^`~!@#%^&*()\-=+[{\]}\\|;:'",.<>/?\s]*)/,comments:{lineComment:"//",blockComment:["/*","*/"]},brackets:[["{","}"],["[","]"],["(",")"]],autoClosingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"}],surroundingPairs:[{open:"{",close:"}"},{open:"[",close:"]"},{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"},{open:"<",close:">"},{open:"<<",close:">>"}],folding:{markers:{start:new RegExp("^\\s*//\\s*(?:(?:#?region\\b)|(?:<editor-fold\\b))"),end:new RegExp("^\\s*//\\s*(?:(?:#?endregion\\b)|(?:</editor-fold>))")}}};const ch=(0,vt.PA)((()=>{const e=bu().documentationService.currentEntry;if(!e)return null;const t=e.markdownText??e.text;return(0,E.jsxs)("div",{className:"h-full w-full overflow-auto bg-white p-4",children:[(0,E.jsx)("div",{className:"mb-3 text-2xl font-bold",children:e.title}),t&&(U(t)?(0,E.jsx)("div",{children:t}):(0,E.jsx)(Ln,{value:t}))]})}));class uh{_engine;_layoutService;display;currentEntry;constructor(e,t){(0,Ie.Gn)(this,{currentEntry:Ie.sH,setCurrentEntry:Ie.XI}),this._engine=e,this._layoutService=t,this.display=this._layoutService.newDisplay("Documentation",(()=>(0,E.jsx)(ch,{})),{x:-50,y:-50,width:400,height:400,minWidth:300,minHeight:200,center:!1})}getEntry(e){return this._engine.getDocumentationEntry(e)}setCurrentEntry(e){this.currentEntry=e}shouldDisplayDocumentationEntry(e){return Boolean(e.title&&(e.text??e.markdownText))}}class dh{_engine;constructor(e){this._engine=e}sendTelemetry(e,t){this._engine.sendTelemetry(e,t)}}class ph{_engine;constructor(e){this._engine=e}openLink(e){this._engine.openLink(e)}}class mh{_engine;constructor(e){this._engine=e}logDebug(e,...t){this._engine.logDebug(e,...t)}debugProcess(e,...t){this._engine.debugProcess(e,...t)}logInfo(e,...t){this._engine.logInfo(e,...t)}logWarning(e,...t){this._engine.logWarning(e,...t)}logError(e,...t){this._engine.logError(e,...t)}logUnhandledError(e){this._engine.logUnhandledError(e)}logIllegalStateError(e,t){this._engine.logIllegalStateError(e,t)}}class gh{engine;logService;taskService;layoutService;settingService;documentationService;alertService;navigationService;telemetryService;specification;options;initializeState=we.create();api;uuid=(0,i.A)();view;constructor(e,t,n){(0,Ie.Gn)(this,{uuid:Ie.sH,reload:Ie.XI}),this.engine=t,this.logService=new mh(this.engine),this.taskService=new Kg(n?.taskManager),this.layoutService=new vr(n?.layoutManager),this.settingService=new ah(this.engine,this.logService,this.layoutService,n),this.documentationService=new uh(this.engine,this.layoutService),this.alertService=new Gu(this.logService,this.layoutService),this.navigationService=new ph(this.engine),this.telemetryService=new dh(this.engine),this.api=new sh(this),this.specification=e,this.options=n,this.view=new Jg(this)}async initialize(){if(this.initializeState.isInInitialState){this.initializeState.inProgress();try{this.options?.gridClientLicense&&xr.hFV.setLicenseKey(this.options.gridClientLicense),await(async(e,t)=>{Nr.editor.defineTheme(Xc.DEFAULT_DARK,Kc),Nr.editor.defineTheme(Xc.SOLARIZED_DARK,qc),Nr.editor.defineTheme(Xc.GITHUB_DARK,Jc),Nr.editor.defineTheme(Xc.GITHUB_DARK_DIMMED,Zc),Nr.editor.defineTheme(Xc.GITHUB_LIGHT,Qc),Nr.editor.defineTheme(Xc.MATERIAL_DEFAULT,eu),Nr.editor.defineTheme(Xc.MATERIAL_DARKER,tu),Nr.editor.defineTheme(Xc.ONE_DARK_PRO,nu),Nr.editor.defineTheme(Xc.ONE_DARK_PRO_DARKER,ou);const n=`Monospaced font '${e}' has not been loaded properly, code editor might not display properly`;await Promise.all([400,700].map((t=>document.fonts.load(`${t} 1em ${e}`)))).then((()=>{document.fonts.check(`1em ${e}`)?Nr.editor.remeasureFonts():t(new Error(n))})).catch((()=>t(new Error(n))))})(ci.ROBOTO_MONO,(e=>{throw e})),e={},Nr.languages.register({id:lu.PURE}),Nr.languages.setLanguageConfiguration(lu.PURE,lh),Nr.languages.setMonarchTokensProvider(lu.PURE,(t=e?.extraKeywords??[],{defaultToken:"invalid",tokenPostfix:".pure",keywords:[...t,"Schema","Table","Join","View","primaryKey","groupBy","mainTable","let","extends","true","false","projects",nh.CLASS,nh.ASSOCIATION,nh.ENUMERATION,nh.MEASURE,nh.PROFILE,nh.FUNCTION,nh.MAPPING,nh.RUNTIME,nh.CONNECTION,nh.FILE_GENERATION,nh.GENERATION_SPECIFICATION,nh.DATA_ELEMENT,oh.JSON_MODEL_CONNECTION,oh.MODEL_CHAIN_CONNECTION,oh.XML_MODEL_CONNECTION,"include","EnumerationMapping","Pure","AssociationMapping","XStore","AggregationAware",nh.SERVICE,nh.FLAT_DATA,nh.DATABASE,oh.FLAT_DATA_CONNECTION,oh.RELATIONAL_DATABASE_CONNECTION,"Relational"],operators:["=",">","<","!","~","?",":","==","<=",">=","&&","||","++","--","+","-","*","/","&","|","^","%","->","#{","}#","@","<<",">>"],languageStructs:["import","native"],identifier:/[a-zA-Z_$][\w$]*/,symbols:/[=><!~?:&|+\-*/^%#@]+/,escapes:/\\(?:[abfnrtv\\"']|x[0-9A-Fa-f]{1,4}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})/,digits:/\d+(_+\d+)*/,octaldigits:/[0-7]+(_+[0-7]+)*/,binarydigits:/[0-1]+(_+[0-1]+)*/,hexdigits:/[[0-9a-fA-F]+(_+[0-9a-fA-F]+)*/,multiplicity:/\[(?:[a-zA-Z0-9]+(?:\.\.(?:[a-zA-Z0-9]+|\*|))?|\*)\]/,package:/(?:[\w_]+::)+/,generics:/(?:(?:<\w+>)|(?:<[^:.@^()]+[^-]>))/,date:/%-?\d+(?:-\d+(?:-\d+(?:T(?:\d+(?::\d+(?::\d+(?:.\d+)?)?)?)(?:[+-][0-9]{4})?)))/,time:/%\d+(?::\d+(?::\d+(?:.\d+)?)?)?/,tokenizer:{root:[{include:"@pure"},{include:"@date"},{include:"@color"},[/^\s*###[\w]+/,hc.PARSER],[/(@identifier)/,{cases:{"@languageStructs":hc.LANGUAGE_STRUCT,"@keywords":`${hc.KEYWORD}.$0`,"([a-zA-Z_$][\\w$]*)_((\\w+_(([a-zA-Z0-9]+)|(\\$[a-zA-Z0-9]+_[a-zA-Z0-9]+\\$)))__)*(\\w+_(([a-zA-Z0-9]+)|(\\$[a-zA-Z0-9]+_[a-zA-Z0-9]+\\$)))_":hc.TYPE,"@default":hc.IDENTIFIER}}],{include:"@whitespace"},[/[{}()[\]]/,"@brackets"],[/[<>](?!@symbols)/,"@brackets"],[/@symbols/,{cases:{"@operators":hc.OPERATOR,"@default":hc.IDENTIFIER}}],{include:"@number"},[/[;,.]/,hc.DELIMITER],[/'([^'\\]|\\.)*$/,`${hc.STRING}.invalid`],[/'/,hc.STRING,"@string"],{include:"@characters"}],pure:[[/(@package\*)/,[hc.PACKAGE]],[/(@package?)(@identifier)(@generics?)(\s*)(@multiplicity)/,[hc.PACKAGE,hc.TYPE,hc.GENERICS,hc.WHITESPACE,hc.MULTIPLICITY]],[/(@package)(@identifier)(@generics?)/,[hc.PACKAGE,hc.TYPE,hc.GENERICS]],[/([@^])(\s*)(@package?)(@identifier)(@generics?)(@multiplicity?)/,[`${hc.TYPE}.operator`,hc.WHITESPACE,hc.PACKAGE,hc.TYPE,hc.GENERICS,hc.MULTIPLICITY]],[/(\.\s*)(@identifier)/,[hc.DELIMITER,hc.PROPERTY]],[/(@identifier)(\s*=)/,[hc.PROPERTY,hc.OPERATOR]],[/(@identifier)(\.)(@identifier)/,[hc.TYPE,hc.OPERATOR,hc.PROPERTY]],[/(@identifier)(\s*:)/,[hc.PARAMETER,hc.OPERATOR]],[/(let)(\s+)(@identifier)(\s*=)/,[hc.KEYWORD,hc.WHITESPACE,hc.VARIABLE,hc.OPERATOR]],[/(\$@identifier)/,[`${hc.VARIABLE}.reference`]]],date:[[/(%latest)/,[`${hc.DATE}.latest`]],[/(@date)/,[hc.DATE]],[/(@time)/,[`${hc.DATE}.time`]]],color:[[/(#[0-9a-fA-F]{6})/,[hc.COLOR]]],number:[[/(@digits)[eE]([-+]?(@digits))?[fFdD]?/,`${hc.NUMBER}.float`],[/(@digits)\.(@digits)([eE][-+]?(@digits))?[fFdD]?/,`${hc.NUMBER}.float`],[/0[xX](@hexdigits)[Ll]?/,`${hc.NUMBER}.hex`],[/0(@octaldigits)[Ll]?/,`${hc.NUMBER}.octal`],[/0[bB](@binarydigits)[Ll]?/,`${hc.NUMBER}.binary`],[/(@digits)[fFdD]/,`${hc.NUMBER}.float`],[/(@digits)[lL]?/,hc.NUMBER]],whitespace:[[/[ \t\r\n]+/,hc.WHITESPACE],[/\/\*\*(?!\/)/,`${hc.COMMENT}.doc`,"@doc"],[/\/\*/,hc.COMMENT,"@comment"],[/\/\/.*$/,hc.COMMENT]],comment:[[/[^/*]+/,hc.COMMENT],[/\*\//,hc.COMMENT,"@pop"],[/[/*]/,hc.COMMENT]],doc:[[/[^/*]+/,`${hc.COMMENT}.doc`],[/\/\*/,`${hc.COMMENT}.doc.invalid`],[/\*\//,`${hc.COMMENT}.doc`,"@pop"],[/[/*]/,`${hc.COMMENT}.doc`]],string:[[/[^\\']+/,hc.STRING],[/@escapes/,`${hc.STRING}.escape`],[/\\./,`${hc.STRING}.escape.invalid`],[/'/,hc.STRING,"@pop"]],characters:[[/'[^\\']'/,hc.STRING],[/(')(@escapes)(')/,[hc.STRING,`${hc.STRING}.escape`,hc.STRING]],[/'/,`${hc.STRING}.invalid`]]}})),this.options?.onInitialized?.(this),this.initializeState.pass()}catch(e){w(e),this.alertService.alertError(e,{message:`Initialization Failure: ${e.message}`,text:"Resolve the issue and reload the engine."}),this.initializeState.fail()}}else this.logService.logDebug("DataCube state is re-initialized");var e,t}dispose(){this.view.dispose(),this.layoutService.dispose(),this.taskService.dispose()}reload(){this.view=new Jg(this),this.uuid=(0,i.A)()}}const hh=(0,vt.PA)((()=>{const e=bu(),t=e.view,n=e=>{t.dataCube.telemetryService.sendTelemetry(Ud.SELECT_ITEM_TITLE_BAR,{...t.engine.getDataFromSource(t.getInitialSource()),menuName:e})};return(0,Ft.useEffect)((()=>{e.view.initialize(e.specification).catch((t=>e.logService.logUnhandledError(t)))}),[e]),(0,E.jsxs)("div",{className:"data-cube relative flex h-full w-full flex-col bg-white",children:[(0,E.jsx)(Kp,{title:t.info.name,menuItems:[{label:Si.UNDO,action:()=>{e.view.snapshotService.undo(),n(Si.UNDO)},disabled:!e.view.snapshotService.canUndo},{label:Si.REDO,action:()=>{e.view.snapshotService.redo(),n(Si.REDO)},disabled:!e.view.snapshotService.canRedo},{label:Si.SETTINGS,action:()=>{e.settingService.display.open(),n(Si.SETTINGS)}}],getMenuItems:e.options?.getHeaderMenuItems,children:e.options?.innerHeaderRenderer?.({api:e.api})??null}),(0,E.jsx)(em,{view:t}),(0,E.jsx)(Tr,{layout:e.layoutService.manager}),(0,E.jsx)(Ar,{})]})})),fh=(0,vt.PA)((e=>{const{specification:t,engine:n,options:o}=e,r=(0,vt.iz)((()=>new gh(t,n,o)));return(0,Ft.useEffect)((()=>(r.initialize().catch((e=>r.logService.logUnhandledError(e))),()=>r.dispose())),[r]),r.initializeState.hasSucceeded?(0,E.jsx)(Cu,{value:r,children:(0,E.jsx)(hh,{},r.uuid)}):(0,E.jsx)(Zp,{title:wi,headerContent:r.options?.innerHeaderRenderer?.({api:r.api})??null,layoutManager:r.layoutService.manager,taskManager:r.taskService.manager,children:r.initializeState.hasFailed&&(0,E.jsx)(Jp,{message:"Initialization Failure",prompt:"Resolve the issue and reload."})})}));class Eh extends fc{runtime;mapping;timestamp;model;isLocal;isPersistenceSupported}const Ch="repl";class bh{query;runtime;model;mapping;timestamp;isLocal;isPersistenceSupported;columns=[];static serialization=new me((0,pe.PL)(bh,{_type:he(Ch),columns:(0,pe.p_)((0,pe.lS)()),isLocal:(0,pe.MY)(),isPersistenceSupported:(0,pe.MY)(),mapping:(0,pe.lq)((0,pe.MY)()),model:(0,pe.lq)((0,pe.lS)()),query:(0,pe.MY)(),runtime:(0,pe.MY)(),timestamp:(0,pe.MY)()}))}class vh{networkClient;constructor(e){this.networkClient=e}get baseUrl(){return D(this.networkClient.baseUrl,"REPL server client has not been configured properly")}get dataCube(){return`${this.baseUrl}/api/dataCube`}async getInfrastructureInfo(){return this.networkClient.get(`${this.dataCube}/infrastructureInfo`)}async getQueryTypeahead(e){return this.networkClient.post(`${this.dataCube}/typeahead`,e)}async parseValueSpecification(e){return this.networkClient.post(`${this.dataCube}/parseValueSpecification`,e)}async getValueSpecificationCode(e){return this.networkClient.post(`${this.dataCube}/getValueSpecificationCode`,e,{},{[Z.ACCEPT]:ee.TEXT_PLAIN})}async getBaseSpecification(){return this.networkClient.get(`${this.dataCube}/getBaseQuery`)}async getQueryRelationReturnType(e){return this.networkClient.post(`${this.dataCube}/getRelationReturnType`,e)}async getQueryCodeRelationReturnType(e){return this.networkClient.post(`${this.dataCube}/getRelationReturnType/code`,e)}async executeQuery(e){return this.networkClient.post(`${this.dataCube}/executeQuery`,e)}async publishQuery(e,t){return this.networkClient.post(`${t}`,e)}}class _h{query;runtime;mapping;model;static serialization=new me((0,pe.PL)(_h,{_type:he("freeformTDSExpression"),model:(0,pe.lS)(),query:(0,pe.MY)(),runtime:(0,pe.MY)(),mapping:(0,pe.lq)((0,pe.MY)())}))}class Th{runtime;model;functionPath;static serialization=new me((0,pe.PL)(Th,{_type:he("userDefinedFunction"),model:(0,pe.lS)(),runtime:(0,pe.lq)((0,pe.MY)()),functionPath:(0,pe.MY)()}))}class Nh{id;name;description;content;owner;lastUpdatedAt;createdAt;lastOpenAt;static serialization=new me((0,pe.PL)(Nh,{id:(0,pe.MY)(),lastUpdatedAt:(0,pe.lq)((0,pe.MY)()),createdAt:(0,pe.lq)((0,pe.MY)()),lastOpenAt:(0,pe.lq)((0,pe.MY)()),name:(0,pe.MY)(),description:(0,pe.lq)((0,pe.MY)()),content:(0,pe.lS)(),owner:(0,pe.lq)((0,pe.MY)())}));clone(){return Nh.serialization.fromJson(Nh.serialization.toJson(this))}}class Sh{id;name;description;owner;lastUpdatedAt;createdAt;lastOpenAt;static serialization=new me((0,pe.PL)(Sh,{id:(0,pe.MY)(),lastUpdatedAt:(0,pe.lq)((0,pe.MY)()),createdAt:(0,pe.lq)((0,pe.MY)()),lastOpenAt:(0,pe.lq)((0,pe.MY)()),name:(0,pe.MY)(),description:(0,pe.lq)((0,pe.MY)()),owner:(0,pe.lq)((0,pe.MY)())}))}const Ah=e=>{const{persistentDataCube:t}=e,n=Cf(),o=n.hostedApplicationBaseUrl?`${n.hostedApplicationBaseUrl}/${t.id}`:void 0;return(0,E.jsxs)("div",{className:"h-full w-full p-6",children:[(0,E.jsxs)("div",{className:"flex w-full overflow-auto",children:[(0,E.jsx)("div",{className:"mr-3",children:(0,E.jsx)(pr.AlertSuccess,{className:"flex-shrink-0 stroke-[0.5px] text-[40px] text-green-500"})}),(0,E.jsxs)("div",{children:[(0,E.jsx)("div",{className:"whitespace-break-spaces text-lg",children:"Published DataCube successfully!"}),o&&(0,E.jsx)("div",{className:"mt-1 whitespace-break-spaces text-neutral-500",children:"To view or share the published DataCube, use the link below."}),!o&&(0,E.jsx)("div",{className:"mt-1 whitespace-break-spaces text-neutral-500",children:"See the published DataCube ID below."})]})]}),o&&(0,E.jsxs)("div",{className:"mt-3 flex h-6 w-full",children:[(0,E.jsx)("div",{className:"flex h-full w-[calc(100%_-_20px)] items-center border border-r-0 border-neutral-400 px-1.5 font-bold text-sky-500 underline",children:(0,E.jsx)("a",{href:o,target:"_blank",rel:"noopener noreferrer",className:"overflow-hidden overflow-ellipsis whitespace-nowrap",children:o})}),(0,E.jsx)("button",{className:"flex aspect-square h-full w-6 items-center justify-center border border-neutral-400 bg-neutral-300 hover:brightness-95",onClick:()=>{n.application.clipboardService.copyTextToClipboard(o).catch(n.application.alertUnhandledError)},title:"Copy Link",children:(0,E.jsx)(pr.Clipboard,{})})]}),!o&&(0,E.jsxs)("div",{className:"mt-3 flex h-6 w-full",children:[(0,E.jsx)("div",{className:"flex h-full w-[calc(100%_-_20px)] items-center border border-r-0 border-neutral-400 bg-neutral-200 px-1.5",children:(0,E.jsx)("div",{className:"overflow-hidden overflow-ellipsis whitespace-nowrap",children:t.id})}),(0,E.jsx)("button",{className:"flex aspect-square h-full w-6 items-center justify-center border border-neutral-400 bg-neutral-300 hover:brightness-95",onClick:()=>{n.application.clipboardService.copyTextToClipboard(t.id).catch(n.application.alertUnhandledError)},title:"Copy ID",children:(0,E.jsx)(pr.Clipboard,{})})]})]})};class yh{sourceId;startLine;startColumn;endLine;endColumn;constructor(e,t,n,o,r){this.sourceId=e,this.startLine=t,this.startColumn=n,this.endLine=o,this.endColumn=r}}var xh,Ih,wh,kh;!function(e){e.COMPILATION="COMPILATION",e.PARSER="PARSER"}(xh||(xh={}));class Rh{message="";errorType;sourceInformation;static serialization=new me((0,pe.PL)(Rh,{errorType:(0,pe.lq)((0,pe.MY)()),message:(0,pe.MY)(),sourceInformation:ge(Ka.schema)}))}!function(e){e.CLASS_BUILDER="classBuilder",e.TDS_BUILDER="tdsBuilder",e.JSON_BUILDER="json"}(Ih||(Ih={})),function(e){e.RELATIONAL="relational",e.RELATIONAL_EXECUTION_ACTIVITY="RelationalExecutionActivity",e.AGGREGATION_AWARE_ACTIVITY="aggregationAware"}(wh||(wh={})),function(e){e.CSV="CSV"}(kh||(kh={}));class Oh{_type;constructor(e){this._type=e}}class Lh{}class Fh extends Lh{sql;comment;constructor(e){super(),this.sql=e}}class Dh extends Lh{rewrittenQuery}class Ph extends Lh{values;constructor(e){super(),this.values=e}}class Bh{builder;activities}class jh extends Bh{values}class Mh extends Bh{value;constructor(e){super(),this.value=e}}class Uh{name;type;relationalType;doc}class Gh extends Oh{columns=[];constructor(){super(Ih.TDS_BUILDER)}}class Hh{values=[]}class Vh{columns=[];rows=[]}class Wh extends Bh{_UUID=(0,i.A)();builder=new Gh;result=new Vh}class zh extends Oh{_type=Ih.CLASS_BUILDER}class $h extends Bh{builder=new zh(Ih.CLASS_BUILDER);objects}class Yh{static builderSerialization=new me((0,pe.PL)(Yh,{_type:(0,pe.MY)()}))}class Xh{}class Kh extends Xh{sql;comment;static serialization=new me((0,pe.PL)(Kh,{sql:(0,pe.MY)(),comment:(0,pe.lq)((0,pe.MY)())}))}class qh extends Xh{rewrittenQuery;static serialization=new me((0,pe.PL)(qh,{rewrittenQuery:(0,pe.MY)()}))}class Jh{builder;activities}class Qh extends Xh{content;constructor(e){super(),this.content=e}}class Zh extends Jh{values;static serialization=new me((0,pe.PL)(Zh,{_type:(0,pe.MY)(),builder:ge(Yh.builderSerialization.schema),values:(0,pe.lS)()}))}class ef{name;doc;type;relationalType;static serialization=new me((0,pe.PL)(ef,{name:(0,pe.MY)(),doc:(0,pe.lq)((0,pe.MY)()),type:(0,pe.lq)((0,pe.MY)()),relationalType:(0,pe.lq)((0,pe.MY)())}))}class tf extends Yh{columns=[];static serialization=new me((0,pe.PL)(tf,{_type:(0,pe.MY)(),columns:(0,pe.p_)(ge(ef.serialization.schema))}))}function nf(e){switch(e._type){case wh.RELATIONAL:case wh.RELATIONAL_EXECUTION_ACTIVITY:return Kh.serialization.fromJson(e);case wh.AGGREGATION_AWARE_ACTIVITY:return qh.serialization.fromJson(e);default:return new Qh(e)}}class of extends Jh{result;static serialization=new me((0,pe.PL)(of,{builder:ge(tf.serialization.schema),activities:(0,pe.p_)((0,pe.Ie)((()=>pe._Z),nf)),result:(0,pe.lS)()}))}class rf extends Jh{objects;static serialization=new me((0,pe.PL)(rf,{builder:ge(Yh.builderSerialization.schema),activities:(0,pe.p_)((0,pe.Ie)((()=>pe._Z),nf)),objects:(0,pe.lS)()}))}class af extends Jh{value;constructor(e){super(),this.value=e}}class sf extends Jh{content}class lf extends Bh{content}const cf=e=>{if(e instanceof Kh){const t=new Fh(e.sql);return t.comment=e.comment,t}if(e instanceof qh){const t=new Dh;return t.rewrittenQuery=D(e.rewrittenQuery,"Aggregation aware execution activities 'rewritenQuery' field is missing"),t}if(e instanceof Qh)return new Ph(e);throw new I("Can't build execution activities",e)},uf=e=>{const t=new Uh;return t.name=D(e.name,"TDS column 'name' field is missing"),t.type=e.type,t.doc=e.doc,t.relationalType=e.relationalType,t},df=e=>{if(e instanceof sf){const t=new lf;return t.content=e.content,t}if(e instanceof rf)return(e=>{const t=new $h;return t.objects=D(e.objects,"Class execution result 'objects' field is missing"),t.activities=e.activities?.map(cf),t})(e);if(e instanceof of)return(e=>{const t=new Wh;return t.builder=(e=>{const t=new Gh;return t.columns=e.columns.map(uf),t})(D(e.builder,"TDS execution result 'builder' field is missing")),t.activities=e.activities?.map(cf),t.result.columns=e.result.columns,t.result.rows=e.result.rows.map((e=>{const t=new Hh;return t.values=e.values,t})),t})(e);if(e instanceof Zh)return(e=>{const t=new jh;return t.values=D(e.values,"JSON execution result 'values' field is missing"),t})(e);if(e instanceof af)return new Mh(e.value);throw new I("Can't build execution result",e)},pf=e=>{if(null===e||U(e)||G(e)||H(e))return new af(e);switch(e.builder?._type){case Ih.CLASS_BUILDER:return rf.serialization.fromJson(e);case Ih.TDS_BUILDER:return of.serialization.fromJson(e);case Ih.JSON_BUILDER:return Zh.serialization.fromJson(e);default:{const t=new sf;return t.content=e,t}}};class mf extends Md{_application;_client;constructor(e,t){super(),this._application=e,this._client=t}async processSource(e){if(e._type===Ch){const t=bh.serialization.fromJson(e),n=new Eh;n.query=await this.parseValueSpecification(t.query,!1);try{n.columns=(await this._getQueryRelationType(kl([],[n.query]))).columns}catch(e){throw w(e),new Error(`Can't get query result columns. Make sure the source query return a relation (i.e. typed TDS). Error: ${e.message}`)}return n.runtime=t.runtime,n.mapping=t.mapping,n.timestamp=t.timestamp,n.model=t.model,n.isLocal=t.isLocal,n.isPersistenceSupported=t.isPersistenceSupported,n}throw new I(`Can't process query source of type '${e._type}'.`)}getDataFromSource(e){return{}}finalizeTimingRecord(e,t){}async parseValueSpecification(e,t){return this.deserializeValueSpecification(await this._client.parseValueSpecification({code:e,returnSourceInformation:t}))}async getValueSpecificationCode(e,t){return this._client.getValueSpecificationCode({value:this.serializeValueSpecification(e),pretty:t})}async getQueryTypeahead(e,t,n){return this._client.getQueryTypeahead({code:e,baseQuery:this.serializeValueSpecification(t)})}async getQueryRelationReturnType(e,t){return this._getQueryRelationType(e)}async getQueryCodeRelationReturnType(e,t,n){try{return{columns:(0,pe.iu)(As,await this._client.getQueryCodeRelationReturnType({code:e,baseQuery:this.serializeValueSpecification(t)})).columns.map((e=>({name:e.name,type:fs(e.genericType)})))}}catch(e){if(w(e),e instanceof re&&e.response.status===J.BAD_REQUEST)throw(e=>{const t=new qm(e.message);return t.sourceInformation=e.sourceInformation?(n=e.sourceInformation,new yh(D(n.sourceId,"Source information 'sourceId' field is missing"),D(n.startLine,"Source information 'startLine' field is missing"),D(n.startColumn,"Source information 'startColumn' field is missing"),D(n.endLine,"Source information 'endLine' field is missing"),D(n.endColumn,"Source information 'endColumn' field is missing"))):void 0,t;var n})(Rh.serialization.fromJson(e.payload));throw e}}async executeQuery(e,t,n){const o=performance.now(),r=await this._client.executeQuery({query:this.serializeValueSpecification(e),debug:n?.debug}),i=performance.now();return{result:B(df(pf(JSON.parse(r.result))),Wh),executedQuery:r.executedQuery,executedSQL:r.executedSQL,executionTime:i-o}}buildExecutionContext(e){if(e instanceof Eh)return Ll(si.FROM,[e.mapping?Pl(e.mapping):void 0,Pl(e.runtime)].filter(L))}async _getQueryRelationType(e){return{columns:(0,pe.iu)(As,await this._client.getQueryRelationReturnType({query:this.serializeValueSpecification(e)})).columns.map((e=>({name:e.name,type:fs(e.genericType)})))}}logDebug(e,...t){this._application.logService.debug(c.create(de.DEBUG),e,...t)}debugProcess(e,...t){this._application.logService.debug(c.create(de.DEBUG),`\n------ START DEBUG PROCESS: ${e} ------`,...t.flatMap((([e,t])=>[`\n[${e.toUpperCase()}]:`,t])),`\n------- END DEBUG PROCESS: ${e} -------\n\n`)}logInfo(e,...t){this._application.logService.info(e,...t)}logWarning(e,...t){this._application.logService.warn(e,...t)}logError(e,...t){this._application.logService.error(e,...t)}logUnhandledError(e){this._application.logUnhandledError(e)}logIllegalStateError(e,t){this.logError(c.create(de.ILLEGAL_APPLICATION_STATE_OCCURRED),e,t)}getDocumentationEntry(e){return this._application.documentationService.getDocEntry(e)}openLink(e){this._application.navigationService.navigator.visitAddress(e)}sendTelemetry(e,t){}}class gf{_client;application;engine;taskService;layoutService;alertService;initializeState=we.create();publishState=we.create();source;gridClientLicense;queryServerBaseUrl;hostedApplicationBaseUrl;specification;constructor(e){(0,Ie.Gn)(this,{specification:Ie.sH,setSpecification:Ie.XI,source:Ie.sH,setSource:Ie.XI}),this.application=e,this._client=new vh(new se({baseUrl:e.config.useDynamicREPLServer?window.location.origin+D(e.config.baseAddress).replace("/repl/",""):e.config.replUrl})),this.engine=new mf(this.application,this._client),this.taskService=new Kg,this.layoutService=new vr,this.alertService=new Gu(new mh(this.engine),this.layoutService)}setSpecification(e){this.specification=e}setSource(e){this.source=e}async initialize(){const e=this.taskService.newTask("Initializing REPL...");this.initializeState.inProgress();try{const e=await this._client.getInfrastructureInfo();e.currentUser&&this.application.identityService.setCurrentUser(e.currentUser),this.application.telemetryService.setup(),this.queryServerBaseUrl=e.queryServerBaseUrl,this.hostedApplicationBaseUrl=e.hostedApplicationBaseUrl,this.gridClientLicense=e.gridClientLicense,this.setSpecification(Dd.serialization.fromJson(await this._client.getBaseSpecification())),this.initializeState.pass()}catch(e){w(e),this.application.logService.error(c.create(de.APPLICATION_LOAD__FAILURE),"Can't initialize REPL",e),this.alertService.alertError(e,{message:`Initialization Failure: ${e.message}`,text:"Resolve the issue and reload the engine."}),this.initializeState.fail()}finally{this.taskService.endTask(e)}}async publishDataCube(e){if(!this.queryServerBaseUrl||!(this.source instanceof Eh)||!this.source.isPersistenceSupported||!this.source.model||this.source.isLocal)return;this.publishState.inProgress();const t=this.taskService.newTask("Publishing DataCube...");try{const t=await e.generateSpecification(),n=new _h;n.query=bh.serialization.fromJson(t.source).query,n.runtime=this.source.runtime,n.model=this.source.model,t.source=_h.serialization.toJson(n);const o=new Nh;o.id=(0,i.A)(),o.name=t.configuration?.name??wi,o.content=Dd.serialization.toJson(t),o.owner=this.application.identityService.currentUser;const r=Nh.serialization.fromJson(await this._client.publishQuery(Nh.serialization.toJson(o),this.queryServerBaseUrl)),a=new gr(new mr("Publish Query",(()=>(0,E.jsx)(Ah,{persistentDataCube:r}))));a.configuration.window={width:420,height:150,minWidth:300,minHeight:100,center:!0},this.layoutService.newWindow(a)}catch(e){w(e),this.alertService.alertError(e,{message:"Persistence Failure: Can't publish query.",text:`Error: ${e.message}`})}finally{this.taskService.endTask(t),this.publishState.complete()}}}const hf=(0,vt.PA)((e=>{const{children:t,simple:n,enableTransitions:o}=e,r=D((0,Ft.useContext)(rr),"Can't find application platform in context"),i=Pt();return(0,Ft.useEffect)((()=>{i.initialize(r).catch(i.alertUnhandledError)}),[i,r]),i.initState.hasSucceeded?n?(0,E.jsx)(ao,{enableTransitions:o,children:t}):(0,E.jsx)(io,{enableTransitions:o,children:t}):(0,E.jsx)(E.Fragment,{})})),ff=(0,Ft.createContext)(void 0),Ef=({children:e})=>{const t=Pt(),n=(0,vt.iz)((()=>new gf(t)));return(0,E.jsx)(ff.Provider,{value:n,children:e})},Cf=()=>D((0,Ft.useContext)(ff),"Can't find Legend REPL base store in context"),bf=({children:e})=>(0,E.jsx)(hf,{simple:!0,children:(0,E.jsx)(Ef,{children:e})}),vf=(0,vt.PA)((e=>{const{api:t}=e,n=Cf();if(!n.source||!n.queryServerBaseUrl)return null;const o=n.source instanceof Eh&&n.source.isPersistenceSupported&&!n.source.isLocal;return(0,E.jsx)("div",{className:"flex h-full items-center",children:(0,E.jsx)(Tu,{compact:!0,disabled:!o||n.publishState.isInProgress,onClick:()=>{n.publishDataCube(t).catch((e=>n.alertService.alertUnhandledError(e)))},children:"Publish"})})}));var _f;!function(e){e.DATA_CUBE="data-cube"}(_f||(_f={}));const Tf=(0,vt.PA)((e=>{const{specification:t}=e,n=Cf(),o=n.application;return(0,Ft.useEffect)((()=>(o.navigationService.navigator.blockNavigation([()=>!0],void 0,(()=>{o.logService.warn(c.create(de.NAVIGATION_BLOCKED),"Navigation from the application is blocked")})),()=>{o.navigationService.navigator.unblockNavigation()})),[o]),(0,E.jsx)(fh,{specification:t,engine:n.engine,options:{gridClientLicense:n.gridClientLicense,layoutManager:n.layoutService.manager,taskManager:n.taskService.manager,onNameChanged(e){const t=e.source instanceof Eh?e.source.timestamp:void 0;o.layoutService.setWindowTitle(`⊞ ${name}${t?` - ${(0,Kn.GP)(new Date(t),"HH:mm:ss EEE MMM dd yyyy")}`:""}`)},onViewInitialized(e){n.setSource(e.source)},innerHeaderRenderer:e=>(0,E.jsx)(vf,{api:e.api}),getHeaderMenuItems:()=>[{label:"See Documentation",action:()=>{o.documentationService.url&&o.navigationService.navigator.visitAddress(o.documentationService.url)},disabled:!o.documentationService.url}],settingsData:{values:o.settingService.getObjectValue(_f.DATA_CUBE)},onSettingsChanged(e){o.settingService.persistValue(_f.DATA_CUBE,e.values)}}})})),Nf=Object.freeze({DATA_CUBE:"/dataCube"}),Sf=(0,vt.PA)((()=>{const e=Cf();return(0,Ft.useEffect)((()=>{e.initialize().catch((t=>e.application.alertUnhandledError(t)))}),[e]),e.initializeState.hasSucceeded?(0,E.jsx)("div",{className:"h-full",children:e.specification&&(0,E.jsx)(Zo.BV,{children:(0,E.jsx)(Zo.qh,{path:Nf.DATA_CUBE,element:(0,E.jsx)(Tf,{specification:e.specification})})})}):(0,E.jsxs)(Zp,{title:wi,layoutManager:e.layoutService.manager,taskManager:e.taskService.manager,children:[e.initializeState.isInProgress&&(0,E.jsx)("div",{className:"h-full w-full p-2",children:(0,E.jsx)("div",{children:"Initializing..."})}),e.initializeState.hasFailed&&(0,E.jsx)(Jp,{message:"Initialization Failure",prompt:"Resolve the issue and reload."})]})})),Af=e=>{const{baseUrl:t}=e;return(0,E.jsx)(ar,{baseUrl:t,children:(0,E.jsx)(bf,{children:(0,E.jsx)(Sf,{})})})};class yf extends Wo{static create(){const e=new yf(new $o);return e.withBasePlugins([new Ko]),e}async configureApplication(e){return new Jo(e)}async loadApplication(e){(0,C.createRoot)((()=>{let e=document.getElementsByTagName(zo).length?document.getElementsByTagName(zo)[0]:void 0;return e||(e=document.createElement(zo),document.body.appendChild(e)),e.setAttribute("style","height: 100%; width: 100%; display: block"),e})()).render((0,E.jsx)(Bt,{store:e,children:(0,E.jsx)(Af,{baseUrl:this.baseAddress})}))}}class xf{static getPresetCollection(){return[]}static getPluginCollection(){return[new f]}static run(e){yf.create().setup({baseAddress:e}).withPresets(xf.getPresetCollection()).withPlugins(xf.getPluginCollection()).start().catch((e=>{throw e}))}}const If=new URL("./",window.location.href).pathname;xf.run(If)},98933:(e,t,n)=>{var o={"./simpleWorker":99246,"./simpleWorker.js":99246};function r(e){return Promise.resolve().then((()=>{if(!n.o(o,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return n(o[e])}))}r.keys=()=>Object.keys(o),r.id=98933,e.exports=r}},a={};function s(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={id:e,loaded:!1,exports:{}};return i[e].call(n.exports,n,n.exports,s),n.loaded=!0,n.exports}s.m=i,s.amdD=function(){throw new Error("define cannot be used indirect")},s.amdO={},e=[],s.O=(t,n,o,r)=>{if(!n){var i=1/0;for(u=0;u<e.length;u++){for(var[n,o,r]=e[u],a=!0,l=0;l<n.length;l++)(!1&r||i>=r)&&Object.keys(s.O).every((e=>s.O[e](n[l])))?n.splice(l--,1):(a=!1,r<i&&(i=r));if(a){e.splice(u--,1);var c=o();void 0!==c&&(t=c)}}return t}r=r||0;for(var u=e.length;u>0&&e[u-1][2]>r;u--)e[u]=e[u-1];e[u]=[n,o,r]},s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},n=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,s.t=function(e,o){if(1&o&&(e=this(e)),8&o)return e;if("object"==typeof e&&e){if(4&o&&e.__esModule)return e;if(16&o&&"function"==typeof e.then)return e}var r=Object.create(null);s.r(r);var i={};t=t||[null,n({}),n([]),n(n)];for(var a=2&o&&e;"object"==typeof a&&!~t.indexOf(a);a=n(a))Object.getOwnPropertyNames(a).forEach((t=>i[t]=()=>e[t]));return i.default=()=>e,s.d(r,i),r},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.f={},s.e=e=>Promise.all(Object.keys(s.f).reduce(((t,n)=>(s.f[n](e,t),t)),[])),s.u=e=>"static/"+e+".a0ce728d.js",s.miniCssF=e=>{},s.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o={},r="@finos/legend-application-repl-deployment:",s.l=(e,t,n,i)=>{if(o[e])o[e].push(t);else{var a,l;if(void 0!==n)for(var c=document.getElementsByTagName("script"),u=0;u<c.length;u++){var d=c[u];if(d.getAttribute("src")==e||d.getAttribute("data-webpack")==r+n){a=d;break}}a||(l=!0,(a=document.createElement("script")).charset="utf-8",a.timeout=120,s.nc&&a.setAttribute("nonce",s.nc),a.setAttribute("data-webpack",r+n),a.src=e),o[e]=[t];var p=(t,n)=>{a.onerror=a.onload=null,clearTimeout(m);var r=o[e];if(delete o[e],a.parentNode&&a.parentNode.removeChild(a),r&&r.forEach((e=>e(n))),t)return t(n)},m=setTimeout(p.bind(null,void 0,{type:"timeout",target:a}),12e4);a.onerror=p.bind(null,a.onerror),a.onload=p.bind(null,a.onload),l&&document.head.appendChild(a)}},s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),s.p="./",(()=>{var e={57:0};s.f.j=(t,n)=>{var o=s.o(e,t)?e[t]:void 0;if(0!==o)if(o)n.push(o[2]);else{var r=new Promise(((n,r)=>o=e[t]=[n,r]));n.push(o[2]=r);var i=s.p+s.u(t),a=new Error;s.l(i,(n=>{if(s.o(e,t)&&(0!==(o=e[t])&&(e[t]=void 0),o)){var r=n&&("load"===n.type?"missing":n.type),i=n&&n.target&&n.target.src;a.message="Loading chunk "+t+" failed.\n("+r+": "+i+")",a.name="ChunkLoadError",a.type=r,a.request=i,o[1](a)}}),"chunk-"+t,t)}},s.O.j=t=>0===e[t];var t=(t,n)=>{var o,r,[i,a,l]=n,c=0;if(i.some((t=>0!==e[t]))){for(o in a)s.o(a,o)&&(s.m[o]=a[o]);if(l)var u=l(s)}for(t&&t(n);c<i.length;c++)r=i[c],s.o(e,r)&&e[r]&&e[r][0](),e[r]=0;return s.O(u)},n=globalThis.webpackChunk_finos_legend_application_repl_deployment=globalThis.webpackChunk_finos_legend_application_repl_deployment||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})(),s.nc=void 0;var l=s.O(void 0,[121],(()=>s(86098)));l=s.O(l)})();
45
+ //# sourceMappingURL=index.94af29ae.js.map