@deephaven/code-studio 0.19.1-alpha-demo.1 → 0.19.1

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.
@@ -39,5 +39,5 @@ ${a} does not exist yet.`}if(i){const{widgetName:r}=this.props;return`${r} is un
39
39
  ${Al.makeCirclePath(s,i,Nh)}`,v=`link-select-clip-${o}`,T=Math.atan2(i-f,s-g),y=T-Dh+Math.PI,E=T+Dh+Math.PI,I=s+Math.cos(T)*Rh,D=i+Math.sin(T)*Rh,M=I+Math.cos(y)*Dr,x=D+Math.sin(y)*Dr,B=I+Math.cos(E)*Dr,$=D+Math.sin(E)*Dr,k=`${I},${D} ${M},${x} ${B},${$}`;return w("svg",{className:t,children:[d("clipPath",{id:v,children:d("path",{d:C,clipRule:"evenodd"})}),d("path",{className:"link-select",d:b,onClick:this.handleClick,clipPath:`url(#${v})`}),d("path",{className:"link-background",d:b}),d("path",{className:"link-foreground",d:b}),d("circle",{className:"link-dot",cx:e,cy:n,r:"5"}),d("polygon",{className:"link-triangle",points:k})]})}};let mp=Al;mp.defaultProps={className:"",onClick(){}};const ml=X.module("LinkerOverlayContent");class pp extends S.exports.Component{constructor(e){super(e),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleEscapePressed=this.handleEscapePressed.bind(this),this.state={mouseX:void 0,mouseY:void 0}}componentDidMount(){window.addEventListener("mousemove",this.handleMouseMove,!0)}componentDidCatch(e,n){ml.error("componentDidCatch",e,n)}componentWillUnmount(){window.removeEventListener("mousemove",this.handleMouseMove,!0)}getPointFromLinkPoint(e){const{panelManager:n}=this.props,{panelId:s,columnName:i}=e,o=n.getOpenedPanelById(s);if(o!=null){if(!cp(o))throw new Error(`Panel does not have getCoordinateForColumn method: ${s}`);try{const a=o.getCoordinateForColumn(i);if(a!=null)return a}catch{ml.error("Could not get coordinate for column",i,o)}}const r=n.getContainerByPanelId(s);if(r==null)throw new Error(`Unable to find panel container for id: ${s}`);return J.getTabPoint(r)}handleMouseMove(e){this.setState({mouseX:e.clientX,mouseY:e.clientY})}handleEscapePressed(){const{onCancel:e}=this.props;e()}render(){const{disabled:e,links:n,messageText:s,onLinkDeleted:i,onAllLinksDeleted:o,onDone:r}=this.props,{mouseX:a,mouseY:l}=this.state,c=n.map(h=>{try{const{id:u,type:m,isReversed:p,start:g,end:f}=h;let[b,C]=this.getPointFromLinkPoint(g),v=a!=null?a:b,T=l!=null?l:C;if(f!=null&&([v,T]=this.getPointFromLinkPoint(f)),p){const[E,I]=[b,C];[b,C]=[v,T],[v,T]=[E,I]}const y=W("linker-link",{disabled:e},{"link-filter-source":m==="filterSource"},{"link-invalid":m==="invalid"},{interactive:h.end==null});return{x1:b,y1:C,x2:v,y2:T,id:u,className:y}}catch(u){return ml.error("Unable to get point for link",h,u),null}}).filter(h=>h!=null);return w("div",{className:"linker-overlay",children:[d("svg",{children:c.map(({x1:h,y1:u,x2:m,y2:p,id:g,className:f})=>d(mp,{className:f,id:g,x1:h,y1:u,x2:m,y2:p,onClick:i},g))}),w("div",{className:"linker-toast-dialog",children:[d("div",{className:"toast-body",children:s}),w("div",{className:"toast-footer",children:[d("button",{className:"btn btn-outline-primary",onClick:o,type:"button",children:"Clear All"}),d("button",{className:"btn btn-primary",onClick:r,type:"button",children:"Done"})]})]}),d(ie,{actions:[{action:this.handleEscapePressed,shortcut:Os.LINKER_CLOSE,isGlobal:!0}]})]})}}pp.defaultProps={disabled:"false"};const zt=X.module("Linker"),bE=(t,e)=>({activeTool:wa(t),isolatedLinkerPanelId:kc(t,e.localDashboardId),links:ro(t,e.localDashboardId),timeZone:Sa(t)}),SE=xt(bE,{setActiveTool:va,setDashboardLinks:Ac,addDashboardLinks:DT,deleteDashboardLinks:NT,setDashboardIsolatedLinkerPanelId:ep,setDashboardColumnSelectionValidator:MT});class wE extends S.exports.Component{constructor(e){super(e),this.getCachedLinks=Ce((n,s,i)=>{const o=[...n];return s&&s.start&&o.push(s),i!==void 0?o.filter(r=>{var a,l;return((a=r==null?void 0:r.start)==null?void 0:a.panelId)===i||((l=r==null?void 0:r.end)==null?void 0:l.panelId)===i||(r==null?void 0:r.end)==null}):o}),this.handleCancel=this.handleCancel.bind(this),this.handleDone=this.handleDone.bind(this),this.handlePanelCloned=this.handlePanelCloned.bind(this),this.handleFilterColumnSelect=this.handleFilterColumnSelect.bind(this),this.handleColumnsChanged=this.handleColumnsChanged.bind(this),this.handlePanelClosed=this.handlePanelClosed.bind(this),this.handleLayoutStateChanged=this.handleLayoutStateChanged.bind(this),this.handleAllLinksDeleted=this.handleAllLinksDeleted.bind(this),this.handleLinkDeleted=this.handleLinkDeleted.bind(this),this.handleChartColumnSelect=this.handleChartColumnSelect.bind(this),this.handleGridColumnSelect=this.handleGridColumnSelect.bind(this),this.handleUpdateValues=this.handleUpdateValues.bind(this),this.handleStateChange=this.handleStateChange.bind(this),this.handleExited=this.handleExited.bind(this),this.isColumnSelectionValid=this.isColumnSelectionValid.bind(this),this.state={linkInProgress:void 0}}componentDidMount(){const{layout:e}=this.props;this.startListening(e),this.updateSelectionValidators()}componentDidUpdate(e){const{activeTool:n,layout:s}=this.props;s!==e.layout&&(this.stopListening(e.layout),this.startListening(s)),n!==e.activeTool&&this.updateSelectionValidators()}componentDidCatch(e,n){zt.error("componentDidCatch",e,n)}componentWillUnmount(){const{layout:e}=this.props;this.stopListening(e)}startListening(e){e.on("stateChanged",this.handleLayoutStateChanged);const{eventHub:n}=e;n.on(yt.COLUMN_SELECTED,this.handleGridColumnSelect),n.on(yt.DATA_SELECTED,this.handleUpdateValues),n.on(yt.STATE_CHANGED,this.handleStateChange),n.on(Yi.COLUMN_SELECTED,this.handleChartColumnSelect),n.on(Fe.CLONED,this.handlePanelCloned),n.on(Ue.COLUMN_SELECTED,this.handleFilterColumnSelect),n.on(Ue.COLUMNS_CHANGED,this.handleColumnsChanged),n.on(Fe.CLOSED,this.handlePanelClosed)}stopListening(e){e.off("stateChanged",this.handleLayoutStateChanged);const{eventHub:n}=e;n.off(yt.COLUMN_SELECTED,this.handleGridColumnSelect),n.off(yt.DATA_SELECTED,this.handleUpdateValues),n.off(yt.STATE_CHANGED,this.handleStateChange),n.off(Yi.COLUMN_SELECTED,this.handleChartColumnSelect),n.off(Fe.CLONED,this.handlePanelCloned),n.off(Ue.COLUMN_SELECTED,this.handleFilterColumnSelect),n.off(Ue.COLUMNS_CHANGED,this.handleColumnsChanged),n.off(Fe.CLOSED,this.handlePanelClosed)}handleCancel(){const{linkInProgress:e}=this.state;if(e==null){const{setActiveTool:n}=this.props;n(mn.DEFAULT)}this.setState({linkInProgress:void 0})}handleDone(){const{setActiveTool:e}=this.props;e(mn.DEFAULT),this.setState({linkInProgress:void 0})}handleChartColumnSelect(e,n){this.columnSelected(e,n,!0)}handleFilterColumnSelect(e,n){zt.debug("handleFilterColumnSelect",this.isOverlayShown());const{links:s,localDashboardId:i,setActiveTool:o,setDashboardIsolatedLinkerPanelId:r}=this.props,a=J.getIdFromPanel(e),l=s.filter(c=>{var h,u;return((h=c.start)==null?void 0:h.panelId)===a||((u=c.end)==null?void 0:u.panelId)===a});if(!this.isOverlayShown()&&a!=null){o(mn.LINKER),r(i,a),l.length===0&&this.columnSelected(e,n,!0,a);return}this.columnSelected(e,n,!0)}handleColumnsChanged(e,n){zt.debug("handleColumnsChanged",e,n);const{links:s}=this.props,i=J.getIdFromPanel(e);if(i==null){zt.error("Invalid panelId",e);return}const o=s.filter(({start:r,end:a})=>r.panelId===i&&si.findColumn(n,r)==null||a!=null&&a.panelId===i&&si.findColumn(n,a)==null);this.deleteLinks(o)}handleGridColumnSelect(e,n){this.columnSelected(e,n)}columnSelected(e,n,s=!1,i){if(i===void 0&&!this.isOverlayShown())return;const{isolatedLinkerPanelId:o}=this.props,{linkInProgress:r}=this.state,a=J.getIdFromPanel(e);if(a==null)return;const l=J.getComponentNameFromPanel(e),{name:c,type:h}=n;if(r==null||r.start==null){const u={id:qe.generate(),start:{panelId:a,panelComponent:l,columnName:c,columnType:h},type:"invalid",isReversed:s};zt.debug("starting link",u),this.setState({linkInProgress:u})}else{const{start:u,id:m,isReversed:p}=r,g={panelId:a,panelComponent:l,columnName:c,columnType:h},f=si.getLinkType(p?g:u,p?u:g,i!=null?i:o);switch(f){case"invalid":zt.debug("Ignore invalid link connection",r,g);return;case"filterSource":{const{links:C}=this.props,v=p?u.panelId:g.panelId,T=C.filter(({end:y})=>(y==null?void 0:y.panelId)===v);this.deleteLinks(T);break}}const b={start:p?g:u,end:p?u:g,id:m,type:f};zt.info("creating link",b),this.setState({linkInProgress:void 0},()=>{this.addLinks([b])})}}unsetFilterValueForLink(e){const{panelManager:n}=this.props;if(e.end){const{end:s}=e,{panelId:i,columnName:o,columnType:r}=s,a=n.getOpenedPanelById(i);a?Eh(a)?a.unsetFilterValue(o,r):zt.debug("endPanel.unsetFilterValue not implemented",a):zt.debug("endPanel no longer exists, ignoring unsetFilterValue",i)}}setPanelFilterMap(e,n){zt.debug("Set filter data for panel:",e,n);const{panelManager:s}=this.props,i=s.getOpenedPanelById(e);i?Eh(i)?i.setFilterMap(n):zt.debug("panel.setFilterMap not implemented",e,i):zt.debug("panel no longer exists, ignoring setFilterMap",e)}addLinks(e){const{addDashboardLinks:n,localDashboardId:s}=this.props;n(s,e)}deleteLinks(e,n=!1){const{localDashboardId:s}=this.props;if(e.forEach(i=>this.unsetFilterValueForLink(i)),n){const{setDashboardLinks:i}=this.props;i(s,[])}else if(e.length>0){const{deleteDashboardLinks:i}=this.props;i(s,e.map(({id:o})=>o))}}handleAllLinksDeleted(){const{links:e,isolatedLinkerPanelId:n}=this.props;if(n===void 0)this.deleteLinks(e,!0);else{const s=e.filter(i=>{var o,r;return((o=i==null?void 0:i.start)==null?void 0:o.panelId)===n||((r=i==null?void 0:i.end)==null?void 0:r.panelId)===n});this.deleteLinks(s)}this.setState({linkInProgress:void 0})}handleLinkDeleted(e){const{links:n}=this.props,s=n.find(i=>i.id===e);s?this.deleteLinks([s]):zt.error("Unable to find link to delete",e)}handleUpdateValues(e,n){const s=J.getIdFromPanel(e),{links:i,timeZone:o}=this.props,r=new Map;for(let a=0;a<i.length;a+=1){const{start:l,end:c}=i[a];if(l.panelId===s&&c!=null){const{panelId:h,columnName:u,columnType:m}=c,p=r.has(h)?r.get(h):new Map,{value:g}=n[l.columnName];let f=`${g}`;m!=null&&P.isDateType(m)&&(f=new ht({timeZone:o,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:us.FULL_DATE_FORMAT}).format(g)),p.set(u,{columnType:m,text:f,value:g}),r.set(h,p)}}r.forEach((a,l)=>{this.setPanelFilterMap(l,a)})}handlePanelCloned(e,n){const{links:s}=this.props,i=J.getIdFromPanel(e),o=n.id;if(i!=null){const r=si.cloneLinksForPanel(s,i,o);this.addLinks(r)}}handlePanelClosed(e){zt.debug(`Panel ${e} closed, deleting links.`),this.deleteLinksForPanelId(e)}handleLayoutStateChanged(){this.forceUpdate()}handleStateChange(){this.forceUpdate()}handleExited(){const{localDashboardId:e,setDashboardIsolatedLinkerPanelId:n}=this.props;n(e,void 0)}deleteLinksForPanelId(e){const{links:n}=this.props;for(let s=0;s<n.length;s+=1){const i=n[s],{start:o,end:r,id:a}=i;(o.panelId===e||(r==null?void 0:r.panelId)===e)&&this.handleLinkDeleted(a)}}isOverlayShown(){const{activeTool:e}=this.props;return e===mn.LINKER}updateSelectionValidators(){const{activeTool:e,setDashboardColumnSelectionValidator:n,localDashboardId:s}=this.props;switch(e){case mn.LINKER:n(s,this.isColumnSelectionValid);break;default:n(s,void 0);break}}updateLinkInProgressType(e,n="invalid"){this.setState({linkInProgress:{...e,type:n}})}isColumnSelectionValid(e,n){const{linkInProgress:s}=this.state,{isolatedLinkerPanelId:i}=this.props;if((s==null?void 0:s.start)==null)return!0;if(n==null)return this.updateLinkInProgressType(s),!1;const{isReversed:o,start:r}=s,a=J.getIdFromPanel(e);if(a==null)return!1;const l={panelId:a,panelComponent:J.getComponentNameFromPanel(e),columnName:n.name,columnType:n.type},c=o?si.getLinkType(l,r,i):si.getLinkType(r,l,i);return this.updateLinkInProgressType(s,c),c!=="invalid"}render(){const{links:e,isolatedLinkerPanelId:n,panelManager:s}=this.props,{linkInProgress:i}=this.state,o=this.isOverlayShown(),r=i!=null&&i.start!=null,a=n===void 0?"Click a column source, then click a column target to create a filter link. Remove a filter link by clicking again to erase. Click done when finished.":"Create a link between the source column button and a table column by clicking on one, then the other. Remove the link by clicking it directly. Click done when finished.";return d(ue,{children:d(gt,{in:o,timeout:It.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,onExited:this.handleExited,children:d(pp,{disabled:r,panelManager:s,links:this.getCachedLinks(e,i,n),messageText:a,onLinkDeleted:this.handleLinkDeleted,onAllLinksDeleted:this.handleAllLinksDeleted,onDone:this.handleDone,onCancel:this.handleCancel})})})}}const vE=SE(wE),TE=t=>{Ps(t);const{id:e,layout:n,panelManager:s}=t;return d(vE,{layout:n,localDashboardId:e,panelManager:s})},Pl=class{static getNewMarkdownTitle(t){let e=`${Pl.DEFAULT_TITLE}`,n=0;for(;t.indexOf(e)>=0;)n+=1,e=`${Pl.DEFAULT_TITLE}-${n}`;return e}};let _o=Pl;_o.DEFAULT_TITLE="Note";_o.DEFAULT_CONTENT=`# Markdown Note
40
40
 
41
41
  This note can be edited using **markdown** for styling.`;const EE=t=>{Ps(t);const{id:e,layout:n,panelManager:s,registerComponent:i}=t,o=S.exports.useCallback(a=>{const{title:l,componentState:c,props:h}=a;let{panelState:u=null}=h;return c&&({panelState:u=null}=c),!l||!u||!u.content||u.content.length===0||u.content===_o.DEFAULT_CONTENT?null:fc(a)},[]),r=S.exports.useCallback(({title:a="",metadata:l={},id:c=qe.generate(),focusElement:h=J.DEFAULT_FOCUS_SELECTOR,createNewStack:u=!1,dragEvent:m=null}={})=>{const p=s.getOpenedPanelConfigsOfType(wo.COMPONENT),g=s.getClosedPanelConfigsOfType(wo.COMPONENT),f=p.map(y=>{var E;return(E=y.title)!=null?E:""}),b=a||_o.getNewMarkdownTitle(f),C=g.length>0?null:_o.DEFAULT_CONTENT,v={type:"react-component",component:wo.COMPONENT,props:{id:c,metadata:l,panelState:{content:C},localDashboardId:e},title:b,id:c},{root:T}=n;J.openComponent({root:T,config:v,focusElement:h,createNewStack:u,dragEvent:m})},[e,n,s]);return S.exports.useEffect(function(){const l=[i(wo.COMPONENT,wo,Cc,o)];return()=>{l.forEach(c=>c())}},[o,i]),Xe(n.eventHub,jm.OPEN,r),d(ue,{})},yE=t=>{Ps(t);const{hydrate:e,id:n,layout:s,registerComponent:i}=t,o=S.exports.useCallback(({dragEvent:r,fetch:a,panelId:l=qe.generate(),widget:c})=>{const{name:h,type:u}=c;if(u!==dh.VariableType.PANDAS)return;const m={name:h,table:h},p=()=>a().then(b=>xc.makeModel(b)),g={type:"react-component",component:xo.COMPONENT,props:{localDashboardId:n,id:l,metadata:m,makeModel:p},title:h,id:l},{root:f}=s;J.openComponent({root:f,config:g,dragEvent:r})},[n,s]);return S.exports.useEffect(function(){const a=[i(xo.COMPONENT,xo,e)];return()=>{a.forEach(l=>l())}},[e,i]),Xe(s.eventHub,Fe.OPEN,o),d(ue,{})};class wn{}wn.DROPDOWN_FILTER="ControlType.DROPDOWN_FILTER";wn.INPUT_FILTER="ControlType.INPUT_FILTER";wn.MARKDOWN="ControlType.MARKDOWN";wn.FILTER_SET_MANAGER="ControlType.FILTER_SET_MANAGER";const IE=R.exports.shape({state:R.exports.shape({panelState:R.exports.shape({})})}),RE=R.exports.shape({panelId:R.exports.string.isRequired,columnName:R.exports.string.isRequired,columnType:R.exports.string.isRequired}),Mh=R.exports.shape({panelId:R.exports.string.isRequired,columnName:R.exports.string.isRequired}),gp=R.exports.shape({start:Mh,end:Mh,id:R.exports.string,isReversed:R.exports.bool}),DE=R.exports.arrayOf(gp),NE=R.exports.shape({name:R.exports.string.isRequired,operateAs:R.exports.string.isRequired,groups:R.exports.arrayOf(R.exports.string).isRequired,permissions:R.exports.shape({isSuperUser:R.exports.bool.isRequired,isQueryViewOnly:R.exports.bool.isRequired,isNonInteractive:R.exports.bool.isRequired,canUsePanels:R.exports.bool.isRequired,canCreateDashboard:R.exports.bool.isRequired,canCreateCodeStudio:R.exports.bool.isRequired,canCreateQueryMonitor:R.exports.bool.isRequired,canCopy:R.exports.bool.isRequired,canDownloadCsv:R.exports.bool.isRequired}).isRequired});Object.freeze({LinkPoint:RE,Link:gp,Links:DE,Panel:IE,User:NE});const ME=(t,e)=>t[e]===null?null:R.exports.bool,FE=(t,e)=>t[e]===null?null:R.exports.string;Object.freeze({nullableBoolean:ME,nullableString:FE});const fp="SET_LAYOUT_STORAGE",xE=t=>({type:fp,payload:t}),Cp="/ide/assets/community-wordmark-app.d2c5c1eb.svg";const Ds=X.module("FormattingSectionContent");function _E(t){return t.formatString!=null}const ct=class extends S.exports.PureComponent{constructor(t){super(t),this.getCachedColumnTypeOptions=Ie(()=>ct.renderColumnTypeOptions()),this.getCachedDateTimeFormatOptions=Ie((h,u,m,p=!1,g=null)=>{const{timestampAtMenuOpen:f}=this.state;return ct.renderDateTimeOptions(f,h,u,m,p,g)}),this.debouncedCommitChanges=st(this.commitChanges.bind(this),ct.inputDebounceTime),this.handleDefaultDateTimeFormatChange=this.handleDefaultDateTimeFormatChange.bind(this),this.handleDefaultDecimalFormatChange=this.handleDefaultDecimalFormatChange.bind(this),this.handleDefaultIntegerFormatChange=this.handleDefaultIntegerFormatChange.bind(this),this.handleFormatRuleEntered=this.handleFormatRuleEntered.bind(this),this.handleFormatRuleChange=this.handleFormatRuleChange.bind(this),this.handleFormatRuleCreate=this.handleFormatRuleCreate.bind(this),this.handleFormatRuleDelete=this.handleFormatRuleDelete.bind(this),this.handleShowTimeZoneChange=this.handleShowTimeZoneChange.bind(this),this.handleShowTSeparatorChange=this.handleShowTSeparatorChange.bind(this),this.handleTimeZoneChange=this.handleTimeZoneChange.bind(this),this.handleResetDateTimeFormat=this.handleResetDateTimeFormat.bind(this),this.handleResetDecimalFormat=this.handleResetDecimalFormat.bind(this),this.handleResetIntegerFormat=this.handleResetIntegerFormat.bind(this),this.handleResetTimeZone=this.handleResetTimeZone.bind(this),this.handleTruncateNumbersWithPoundChange=this.handleTruncateNumbersWithPoundChange.bind(this);const{formatter:e,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,showTimeZone:o,showTSeparator:r,timeZone:a,truncateNumbersWithPound:l}=t,c=e.map((h,u)=>({...h,id:u}));this.containerRef=Y.createRef(),this.addFormatRuleButtonRef=Y.createRef(),this.lastFormatRuleIndex=c.length,this.state={formatSettings:c,formatRulesChanged:!1,showTimeZone:o,showTSeparator:r,timeZone:a,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:l,timestampAtMenuOpen:new Date}}static focusFirstInputInContainer(t){const e=t==null?void 0:t.querySelector("input, select, textarea");e&&e.focus()}static isSameOptions(t,e){return t.defaultFormatString===e.defaultFormatString}static isSameDecimalOptions(t,e){return ct.isSameOptions(t,e)}static isSameIntegerOptions(t,e){return ct.isSameOptions(t,e)}static isValidColumnName(t){return t!==""&&ms.isValidColumnName(t)}static isValidFormat(t,e){if(!t||!e.formatString||!_E(e))return!1;switch(t){case"datetime":return ht.isValid(e);case"decimal":return We.isValid(e);case"int":return mt.isValid(e);default:return Ds.warn("Trying to validate format of unknown type"),!0}}static removeFormatRuleExtraProps(t){const{id:e,isNewRule:n,...s}=t;return s}static isFormatRuleValidForSave(t){return ct.isValidColumnName(t.columnName)&&ct.isValidFormat(t.columnType,t.format)}static renderTimeZoneOptions(){return Rn.TIME_ZONES.map(e=>{const{label:n,value:s}=e;return d("option",{value:s,children:n},s)})}static renderColumnTypeOptions(){const e=[{value:P.dataType.DATETIME,label:"DateTime"},{value:P.dataType.DECIMAL,label:"Decimal"},{value:P.dataType.INT,label:"Integer"}].map(n=>d("option",{value:n.value,children:n.label},`key-columnType-${n.value}`));return w(ue,{children:[d("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),e]})}static renderDateTimeOptions(t,e,n,s,i,o){const r=new pn([],{timeZone:e,showTimeZone:n,showTSeparator:s}),a=i?ht.getGlobalFormats(n,s):ht.getFormats(n,s);return o&&!a.includes(o)&&a.unshift(o),a.map(l=>{const c=ht.makeFormat("",l,ht.TYPE_GLOBAL);return d("option",{value:l,children:r.getFormattedString(t,P.dataType.DATETIME,"",c)},l)})}componentDidMount(){ct.focusFirstInputInContainer(this.containerRef.current)}componentWillUnmount(){this.debouncedCommitChanges.flush()}isDuplicateRule(t){var n;const{formatSettings:e}=this.state;return(n=e.some(s=>s.id!==t.id&&s.columnName===t.columnName&&s.columnType===t.columnType))!=null?n:!1}getAutoIncrementFormatRuleIndex(){const{lastFormatRuleIndex:t}=this;return this.lastFormatRuleIndex+=1,t}handleDefaultDateTimeFormatChange(t){Ds.debug("handleDefaultDateTimeFormatChange",t.target.value),this.setState({defaultDateTimeFormat:t.target.value},()=>{this.debouncedCommitChanges()})}handleDefaultDecimalFormatChange(t){Ds.debug("handleDefaultDecimalFormatChange",t.target.value),this.setState({defaultDecimalFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleDefaultIntegerFormatChange(t){Ds.debug("handleDefaultIntegerFormatChange",t.target.value),this.setState({defaultIntegerFormatOptions:{defaultFormatString:t.target.value}},()=>{this.debouncedCommitChanges()})}handleFormatRuleChange(t,e,n){this.setState(s=>{const{formatSettings:i}=s;O(i);const o=[...i];let r={};e==="columnType"&&(r={format:""});const a={...o[t],...r,[e]:n};return o[t]=a,{formatSettings:o}},()=>{this.debouncedCommitChanges()})}handleFormatRuleCreate(){this.setState(t=>{const{formatSettings:e}=t,n={columnType:P.dataType.DATETIME,columnName:"",format:{},id:this.getAutoIncrementFormatRuleIndex(),isNewRule:!0};return{formatSettings:e!=null?[...e,n]:[n],formatRulesChanged:!0}})}handleFormatRuleDelete(t){this.setState(e=>{const{formatSettings:n}=e;return{formatSettings:n.filter((i,o)=>o!==t),formatRulesChanged:!0}},()=>{this.debouncedCommitChanges()})}handleShowTimeZoneChange(){this.setState(t=>({showTimeZone:!t.showTimeZone}),()=>{this.debouncedCommitChanges()})}handleShowTSeparatorChange(){this.setState(t=>({showTSeparator:!t.showTSeparator}),()=>{this.debouncedCommitChanges()})}handleTimeZoneChange(t){this.setState({timeZone:t.target.value},()=>{this.debouncedCommitChanges()})}handleResetDateTimeFormat(){const{defaults:t}=this.props,{defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s}=t;Ds.debug("handleResetDateTimeFormat"),this.setState({defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s},()=>{this.debouncedCommitChanges()})}handleResetTimeZone(){const{defaults:t}=this.props,{timeZone:e}=t;Ds.debug("handleResetTimeZone"),this.setState({timeZone:e},()=>{this.debouncedCommitChanges()})}handleResetDecimalFormat(){const{defaults:t}=this.props,{defaultDecimalFormatOptions:e}=t;Ds.debug("handleResetDecimalFormat"),this.setState({defaultDecimalFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleResetIntegerFormat(){const{defaults:t}=this.props,{defaultIntegerFormatOptions:e}=t;Ds.debug("handleResetIntegerFormat"),this.setState({defaultIntegerFormatOptions:e},()=>{this.debouncedCommitChanges()})}handleTruncateNumbersWithPoundChange(){this.setState(t=>({truncateNumbersWithPound:!t.truncateNumbersWithPound}),()=>{this.debouncedCommitChanges()})}handleFormatRuleEntered(t){this.scrollToFormatBlockBottom(),ct.focusFirstInputInContainer(t)}commitChanges(){var m;const{formatSettings:t,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:r,truncateNumbersWithPound:a}=this.state,l=(m=t.filter(ct.isFormatRuleValidForSave).map(ct.removeFormatRuleExtraProps))!=null?m:[],{settings:c,saveSettings:h}=this.props,u={...c,formatter:l,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:a};ct.isValidFormat(P.dataType.DECIMAL,We.makeCustomFormat(o.defaultFormatString))&&(u.defaultDecimalFormatOptions=o),ct.isValidFormat(P.dataType.INT,mt.makeCustomFormat(r.defaultFormatString))&&(u.defaultIntegerFormatOptions=r),h(u)}scrollToFormatBlockBottom(){var e,n,s,i;const{scrollTo:t}=this.props;t(0,((n=(e=this.addFormatRuleButtonRef.current)==null?void 0:e.offsetHeight)!=null?n:0)+((i=(s=this.addFormatRuleButtonRef.current)==null?void 0:s.offsetTop)!=null?i:0))}getRuleError(t){const e={hasColumnNameError:!1,hasFormatError:!1,message:""},n=[];return t.isNewRule||(this.isDuplicateRule(t)&&(e.hasColumnNameError=!0,n.push("Duplicate column name/type combo.")),ct.isValidColumnName(t.columnName)||(e.hasColumnNameError=!0,n.push("Column names must start with a letter or underscore and contain only alphanumeric characters or underscores.")),t.format?ct.isValidFormat(t.columnType,t.format)||(e.hasFormatError=!0,n.push("Invalid formatting rule.")):(e.hasFormatError=!0,n.push("Empty formatting rule.")),e.message=n.join(`
42
- `)),e}renderFormatRule(t,e){const n=`input-${t}-columnName`,s=`input-${t}-columnType`,i=`input-${t}-format`,o=this.getCachedColumnTypeOptions(),r=h=>this.handleFormatRuleChange(t,"columnName",h.target.value),a=()=>this.handleFormatRuleChange(t,"isNewRule",!1),l=h=>this.handleFormatRuleChange(t,"columnType",h.target.value),c=this.getRuleError(e);return w("fieldset",{className:"container-fluid format-rule-container",children:[w("div",{className:"form-row",children:[w("div",{className:"form-group col-7 mb-2",children:[d("label",{htmlFor:n,children:"Column Name"}),d("input",{id:n,className:W("form-control",{"is-invalid":c.hasColumnNameError}),"data-lpignore":!0,type:"text",value:e.columnName,onChange:r,onBlur:a})]}),w("div",{className:"form-group col mb-2",children:[d("button",{type:"button",className:"btn btn-link btn-link-icon btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(t),children:d(z,{icon:_n})}),d("label",{htmlFor:s,children:"Column Type"}),d("select",{id:s,className:"custom-select",value:e.columnType,onChange:l,children:o})]})]}),d("div",{className:"form-row",children:w("div",{className:"form-group col-12 d-flex mb-2",children:[d("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:i,children:"Formatting Rule"}),this.renderFormatRuleInput(t,e.columnType,i,e.format,c.hasFormatError)]})}),d("div",{className:"form-row",children:d("div",{className:"form-group col-12 d-flex mb-2",children:c.message&&d("p",{className:"text-danger",children:c.message})})})]},t)}renderFormatRuleInput(t,e,n,s,i){switch(P.getNormalizedType(e)){case P.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(t,n,s,i);case P.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(t,n,s,i);case P.dataType.INT:return this.renderIntegerFormatRuleInput(t,n,s,i);default:return null}}renderDateTimeFormatRuleInput(t,e,n,s){const{showTimeZone:i,showTSeparator:o,timeZone:r}=this.state,a=n&&n.formatString||"";return w("select",{className:W("custom-select",{"is-invalid":s}),value:a,id:e,onChange:l=>{const c=ht.makeFormat("",l.target.value,ht.TYPE_GLOBAL);this.handleFormatRuleChange(t,"format",c)},children:[d("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(r,i,o)]})}renderIntegerFormatRuleInput(t,e,n,s){const i=n&&n.formatString||"";return d("input",{className:W("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:mt.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=mt.makeFormat("",o.target.value,mt.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}renderDecimalFormatRuleInput(t,e,n,s){const i=n&&n.formatString||"";return d("input",{className:W("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:We.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=We.makeFormat("",o.target.value,We.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}render(){const{defaults:t}=this.props,{formatRulesChanged:e,formatSettings:n,defaultDateTimeFormat:s,defaultDecimalFormatOptions:i,defaultIntegerFormatOptions:o,timeZone:r,showTimeZone:a,showTSeparator:l,truncateNumbersWithPound:c}=this.state,{defaultFormatString:h=We.DEFAULT_FORMAT_STRING}=i!=null?i:{},{defaultFormatString:u=mt.DEFAULT_FORMAT_STRING}=o!=null?o:{},m=n.map((v,T)=>d(gt,{classNames:"fade",timeout:It.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(T,v)},v.id)),p=w("button",{type:"button",className:"btn btn-link mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,children:[d(z,{icon:As}),"Add New Rule"]}),g=r===t.timeZone,f=l===t.showTSeparator&&a===t.showTimeZone&&s===t.defaultDateTimeFormat,b=ct.isSameDecimalOptions(i,t.defaultDecimalFormatOptions),C=ct.isSameIntegerOptions(o,t.defaultIntegerFormatOptions);return w("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[w("div",{className:"container-fluid p-0",children:[d("div",{children:"Default formatting for column types"}),d("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns of a set type."}),w("div",{className:"form-row mb-2",children:[d("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),d("div",{className:"col pr-0",children:d("select",{className:"custom-select",value:r,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:ct.renderTimeZoneOptions()})}),d("div",{className:"col-1 btn-col",children:d(he,{kind:"ghost",icon:_i,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:W("btn-reset","btn-reset-time-zone",{hidden:g})})})]}),w("div",{className:"form-row mb-2",children:[d("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),d("div",{className:"col pr-0",children:d("select",{className:"custom-select",value:s,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(r,a,l,!0,s)})}),d("div",{className:"col-1 btn-col",children:d(he,{kind:"ghost",icon:_i,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:W("btn-reset","btn-reset-date-time",{hidden:f})})})]}),d("div",{className:"form-row",children:d("div",{className:"offset-3 col-9",children:d(Ut,{checked:a!=null?a:null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),d("div",{className:"form-row mb-3",children:d("div",{className:"offset-3 col-9",children:d(Ut,{checked:l!=null?l:null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),w("div",{className:"form-row mb-2",children:[d("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),d("div",{className:"col pr-0",children:d("input",{className:W("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!ct.isValidFormat(P.dataType.DECIMAL,We.makeCustomFormat(h))}),"data-lpignore":!0,placeholder:We.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:h,onChange:this.handleDefaultDecimalFormatChange})}),d("div",{className:"col-1 btn-col",children:d(he,{kind:"ghost",icon:_i,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:W("btn-reset","btn-reset-decimal",{hidden:b}),"data-testid":"btn-reset-decimal"})})]}),w("div",{className:"form-row mb-2",children:[d("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),d("div",{className:"col pr-0",children:d("input",{className:W("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!ct.isValidFormat(P.dataType.INT,mt.makeCustomFormat(u))}),"data-lpignore":!0,placeholder:mt.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:u,onChange:this.handleDefaultIntegerFormatChange})}),d("div",{className:"col-1 btn-col",children:d(he,{kind:"ghost",icon:_i,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:W("btn-reset","btn-reset-integer",{hidden:C}),"data-testid":"btn-reset-integer"})})]}),d("div",{className:"form-row mb-3",children:d("div",{className:"offset-3 col-9",children:d(Ut,{checked:c!=null?c:null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Truncate numbers with #"})})})]}),d("div",{children:"Default formatting for matched column names"}),d("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns that match a specified name and type."}),d(Vp,{appear:e,enter:e,exit:e,children:m}),p]})}};let Kc=ct;Kc.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:ht.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:We.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:mt.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:ht.DEFAULT_TIME_ZONE_ID}};Kc.inputDebounceTime=250;const LE=t=>({formatter:Yb(t),defaultDateTimeFormat:Gb(t),defaultDecimalFormatOptions:Kb(t),defaultIntegerFormatOptions:qb(t),showTimeZone:Xb(t),showTSeparator:jb(t),truncateNumbersWithPound:Qb(t),timeZone:Sa(t),settings:Xt(t)}),kE=xt(LE,{saveSettings:im})(Kc),OE=()=>{const[t,e]=S.exports.useState(!1),n=()=>{e(!t)};return w("button",{type:"button",className:"btn btn-link",onClick:n,children:[d(z,{icon:Jg}),"Legal Notices",w(Ho,{isOpen:t,toggle:n,className:"theme-bg-light",children:[d(Uo,{toggle:n,children:"Legal Notice"}),w(Vo,{children:[d("p",{children:"Deephaven software is protected by U.S. Patent Nos. 9,612,959; 9,613,018; 9,613,109; 9,619,210; 9,633,060; 9,639,570; 9,672,238; 9,679,006; 9,690,821; 9,710,511; 9,760,591; 9,805,084; 9,836,495; 9,836,494; 9,886,469; 9,898,496; 9,934,266; 10,002,153; 10,002,154; 10,002,155; 10,003,673; 10,019,138; 10,069,943; 10,176,211; 10,198,465; 10,198,466; 10,198,469; 10,212,257; 10,241,960; 10,241,965; 10,242,040; 10,242,041; 10,353,893; 10,346,394; 10,452,649; 10,496,639; 10,540,351; 10,552,412; 10,565,194; 10,565,206; 10,572,474; 10,621,168; 10,642,829; 10,657,184; 10,678,787; 10,691,686; and 10,783,191. Other patents pending."}),w("p",{children:["\xA9 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})},ea=t=>{const{children:e,isExpanded:n,sectionKey:s,title:i,onToggle:o}=t;return w(ue,{children:[d("div",{children:w("button",{type:"button",className:"btn btn-link btn-collapse-trigger",onClick:()=>o(s),children:[d("div",{className:"flex-grow-1",children:i}),d("div",{className:"flex-shrink-0",children:d(z,{transform:n?"flip-v":"",icon:cs})})]})}),d(sc,{in:n,autoFocusOnShow:!0,children:e})]})};ea.propTypes={children:R.exports.node,isExpanded:R.exports.bool.isRequired,sectionKey:R.exports.string.isRequired,title:R.exports.node.isRequired,onToggle:R.exports.func};ea.defaultProps={children:null,onToggle:()=>{}};function AE({shortcut:t,displayText:e,categoryName:n,onChange:s}){const[i,o]=S.exports.useState(e),[r,a]=S.exports.useState(t.getKeyState()),[l,c]=S.exports.useState(!1),[h,u]=S.exports.useState("");S.exports.useEffect(function(){o(e),a(t.getKeyState())},[e,t]),S.exports.useEffect(function(){o(Kt.getDisplayText(r)),t.matchesKeyState(r)&&c(!1)},[r,t]),S.exports.useEffect(function(){if(l){if(!Kt.isValidKeyState(r)){Kt.isAllowedKey(r.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const y=ze.getConflictingShortcuts(r).filter(E=>E.id.startsWith(n)&&E!==t).map(E=>E.name);if(y.length){u(`Conflicts with ${y.join(", ")}`);return}u("")}else u("")},[l,r,n,t]);function m(T){if(T.stopPropagation(),T.preventDefault(),t.isEditable&&!T.repeat){const y=Kt.getKeyStateFromEvent(T),E=Kt.createKeyState([fe.BACKSPACE]);Kt.doKeyStatesMatch(y,E)?a(Kt.NULL_KEY_STATE):a(y)}}function p(T){T.stopPropagation(),T.preventDefault(),t.matchesKeyState(r)||c(!0)}function g(){xe.disableAllActions()}function f(){xe.enableAllActions()}function b(){t.setKeyState(r),c(!1),s(t)}function C(){const T=t.getKeyState();a(T),c(!1)}function v(){c(!0),a(t.getDefaultKeyState())}return w(ue,{children:[w("div",{className:"shortcut-item-container",children:[w("label",{className:"shortcut-item-name",children:[t.name,t.tooltip&&d(pe,{children:t.tooltip})]}),w("div",{className:"shortcut-item-input-container",children:[d("input",{className:W("form-control",{"is-invalid":h}),onKeyDown:m,onKeyUp:p,onFocus:g,onBlur:f,disabled:!t.isEditable,value:i,readOnly:!0}),!Kt.doKeyStatesMatch(r,t.getDefaultKeyState())&&!h&&d(he,{className:"reset-to-default-button",kind:"ghost",icon:d(z,{icon:_i,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:v})]})]}),l&&w("div",{className:W("shortcut-item-message-container",{"is-invalid":h}),children:[d("div",{className:"shortcut-item-message",children:h}),w("div",{className:"shortcut-item-message-buttons",children:[Kt.isValidKeyState(r)&&d(he,{kind:"ghost",onClick:b,children:"Confirm"}),d(he,{kind:"ghost",onClick:C,children:"Undo"})]})]})]})}function PE({shortcutOverrides:t={},settings:e,saveSettings:n}){const s=S.exports.useCallback(a=>{const l=Kt.isMacPlatform,c={mac:{...t.mac},windows:{...t.windows}},h=l?c.mac:c.windows;a.forEach(u=>{u.isDefault()?delete h[u.id]:h[u.id]=u.getKeyState()}),n({...e,shortcutOverrides:c})},[e,n,t]);let i=Array.from(ze.shortcutsByCategory.entries()).map(([a,l])=>({name:a,shortcuts:l}));const o=i.findIndex(a=>a.name.toUpperCase()==="GLOBAL"),r=i.splice(o,1);return i=i.concat(r),w(ue,{children:[d("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. Assigning shortcuts that conflict with the browser or IDE shortcuts may cause unintended behavior"}),i.map(a=>d(HE,{name:a.name,shortcuts:a.shortcuts,saveShortcutOverrides:s},a.name))]})}function HE({name:t,shortcuts:e,saveShortcutOverrides:n}){function s(l){return l.split("_").map(c=>`${c[0].toUpperCase()}${c.slice(1).toLowerCase()}`).join(" ")}const[i,o]=S.exports.useState(e);function r(l){const c=i.filter(u=>u!==l&&!u.isNull()&&u.matchesKeyState(l.getKeyState()));c.forEach(u=>u.setToNull());const h=[l,...c];n(h),o(u=>[...u])}const a=S.exports.useMemo(()=>i.map(l=>l.getDisplayText()),[i]);return w("div",{className:"mt-3",children:[d("div",{className:"font-weight-bold",children:s(t)}),i.map((l,c)=>d(AE,{shortcut:l,displayText:a[c],categoryName:t,onChange:r},l.id))]})}const VE=t=>({settings:Xt(t),shortcutOverrides:Zb(t)}),UE={saveSettings:im},BE=xt(VE,UE)(PE),Hl=new Mg,Vl=new Vr(Hl);function $E(){X.setLogLevel(parseInt("2",10)),Hl.enable(),Vl.enable(),window&&(window.DHLog=X,window.DHLogProxy=Hl,window.DHLogHistory=Vl)}const WE="yyyy-MM-dd-HHmmss";function bp(t,e="root",n=new Map([[t,""]])){const s={};return Object.entries(t).forEach(([i,o])=>{try{JSON.stringify(o),s[i]=o}catch{const a=o;if(typeof o=="bigint")s[i]=o.toString();else if(n.has(a))s[i]=`Circular ref to ${n.get(a)}`;else{const l=`${e}.${i}`;n.set(a,l),s[i]=bp(o,l,n)}}}),s}function zE(){const t=Ta.getState();return JSON.stringify(bp(t),null,2)}function GE(){const t={uiVersion:"0.19.0",userAgent:navigator.userAgent};return JSON.stringify(t,null,2)}async function KE(t=`${N.i18n.DateTimeFormat.format(WE,new Date)}_support_logs`){const e=new Vh,n=e.folder(t);n.file("console.txt",Vl.getFormattedHistory()),n.file("redux.json",zE()),n.file("metadata.json",GE());const s=await e.generateAsync({type:"blob"}),i=document.createElement("a");i.href=URL.createObjectURL(s),i.download=`${t}.zip`,i.click()}const Fs=class extends S.exports.Component{constructor(t){super(t),this.handleClose=this.handleClose.bind(this),this.handleScrollTo=this.handleScrollTo.bind(this),this.handleSectionToggle=this.handleSectionToggle.bind(this),this.menuContentRef=Y.createRef(),this.state={expandedSectionKey:Fs.FORMATTING_SECTION_KEY}}static focusFirstInputInContainer(t){const e=t==null?void 0:t.querySelector("input, select, textarea");e&&e.focus()}static handleExportSupportLogs(){KE()}componentDidMount(){Fs.focusFirstInputInContainer(this.menuContentRef.current)}isSectionExpanded(t){const{expandedSectionKey:e}=this.state;return e===t}handleScrollTo(t,e){var n;(n=this.menuContentRef.current)==null||n.scrollTo(t,e)}handleSectionToggle(t){this.setState(e=>({expandedSectionKey:e.expandedSectionKey===t?void 0:t}))}handleClose(){const{onDone:t}=this.props;t()}render(){const t="0.19.0",e="https://github.com/deephaven/web-client-ui/",n="https://deephaven.io/core/docs/";return w("div",{className:"app-settings-menu",children:[w("header",{className:"app-settings-menu-header",children:[d("div",{className:"flex-spacer"}),d("button",{type:"button",className:"btn btn-link btn-link-icon btn-close-settings-menu",onClick:this.handleClose,children:d(z,{icon:Bo,transform:"grow-4"})})]}),w("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[d("h5",{children:"Settings"}),d("hr",{className:"my-0"}),d(ea,{sectionKey:Fs.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(Fs.FORMATTING_SECTION_KEY),title:w(ue,{children:[d(z,{icon:mf,transform:"grow-4",className:"mr-2"}),"Formatting & Time zone"]}),onToggle:this.handleSectionToggle,children:d(kE,{scrollTo:this.handleScrollTo})}),d(ea,{sectionKey:Fs.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(Fs.SHORTCUT_SECTION_KEY),title:w(ue,{children:[d(z,{icon:af,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:d(BE,{})}),w("div",{className:"app-settings-footer",children:[w("div",{className:"app-settings-footer-section",children:[w("div",{className:"app-settings-footer-item",children:[d("div",{className:"font-weight-bold",children:"Support"}),w("div",{children:["GitHub:\xA0",d("a",{href:e,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:e})]}),d("button",{type:"button",className:"btn btn-secondary mt-2 py-2",onClick:Fs.handleExportSupportLogs,children:"Export Logs"})]}),w("div",{className:"app-settings-footer-item",children:[d("div",{className:"font-weight-bold",children:"Documentation"}),d("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),d("div",{className:"app-settings-footer-item",children:w("div",{className:"text-muted",children:["Version ",t]})}),d("div",{className:"app-settings-footer-item",children:d(OE,{})})]}),d("div",{className:"app-settings-footer-section",children:d("div",{className:"logo",children:d("a",{target:"_blank",rel:"noreferrer noopener",href:"https://deephaven.io",className:"d-inline-block custom-link p-1",children:d("img",{src:Cp,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}};let Yo=Fs;Yo.defaultProps={onDone:()=>{}};Yo.FORMATTING_SECTION_KEY="SettingsMenu.formatting";Yo.APPLICATION_SECTION_KEY="ApplicationMenu.settings";Yo.SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";const Fh=10,Ai=t=>{const{forwardedProps:{menuItem:{action:e,title:n,disabled:s},iconElement:i,displayShortcut:o,isMouseSelected:r,isKeyboardSelected:a,closeMenu:l}}=t,c=S.exports.useRef(),h=S.exports.useRef(),u=S.exports.useRef(null),[m,p]=S.exports.useState(!1),g=S.exports.useCallback(C=>{c.current&&h.current&&u.current&&(Math.abs(c.current-C.clientX)>=Fh||Math.abs(h.current-C.clientY)>=Fh)&&(p(!0),window.removeEventListener("mousemove",g),l(),e(C),u.current=null)},[e,l]);function f(C){c.current=C.clientX,h.current=C.clientY,u.current=C.target,window.addEventListener("mousemove",g)}function b(C){u.current===C.target&&(p(!0),l(),e(),window.removeEventListener("mousemove",g)),u.current=null}return S.exports.useEffect(function(){return function(){return window.removeEventListener("mousemove",g)}},[g]),w("button",{type:"button",className:W("btn-context-menu",{disabled:s},{active:r&&!s},{"keyboard-active":a&&!s}),onMouseDown:f,onMouseUp:b,disabled:m,children:[d("span",{className:W("icon"),children:i}),d("span",{className:"title",children:n}),d("span",{className:"shortcut",children:o})]})},qc=t=>{const{handleControlSelect:e,handleToolSelect:n,onClearFilter:s}=t,i=S.exports.useMemo(()=>[{title:"Input Filter",icon:Rf,menuElement:d(Ai,{}),action:o=>{e(wn.INPUT_FILTER,o)},order:10},{title:"Dropdown Filter",icon:eu,menuElement:d(Ai,{}),action:o=>{e(wn.DROPDOWN_FILTER,o)},order:15},{title:"Markdown Widget",icon:sf,menuElement:d(Ai,{}),action:o=>{e(wn.MARKDOWN,o)},order:20},{title:"Filter Sets",icon:wl,menuElement:d(Ai,{}),action:o=>{e(wn.FILTER_SET_MANAGER,o)},order:25},{disabled:!0,menuElement:d("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:Yl,action:()=>{n(mn.LINKER)},order:40,shortcut:Os.LINKER},{disabled:!0,menuElement:d("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:Tf,action:()=>{s()},order:60,shortcut:hn.TABLE.CLEAR_ALL_FILTERS}],[e,n,s]);return d(zn,{popperClassName:"controls-menu-popper",actions:i})};qc.propTypes={handleControlSelect:R.exports.func,handleToolSelect:R.exports.func,onClearFilter:R.exports.func};qc.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Ai.propTypes={forwardedProps:R.exports.shape({iconElement:R.exports.node,displayShortcut:R.exports.string,isMouseSelected:R.exports.bool.isRequired,isKeyboardSelected:R.exports.bool.isRequired,closeMenu:R.exports.func.isRequired,menuItem:R.exports.shape({action:R.exports.func,title:R.exports.string,disabled:R.exports.bool}).isRequired})};Ai.defaultProps={forwardedProps:null};const qE=fi(fp,null),YE={layoutStorage:qE},XE=t=>t.layoutStorage;Object.entries(YE).map(([t,e])=>eo.register(t,e));const xh=10,jE=t=>{const{onExportLayout:e,onImportLayout:n,onResetLayout:s,onSelect:i,widgets:o=[]}=t,[r,a]=S.exports.useState(!1),[l,c]=S.exports.useState(""),h=S.exports.useRef(null),u=S.exports.useRef(),m=S.exports.useCallback((y,E)=>{y&&i(y,E)},[i]),p=S.exports.useCallback(y=>{c(y.target.value)},[]),g=S.exports.useCallback(y=>{u.current!=null&&(Math.abs(u.current.x-y.clientX)>=xh||Math.abs(u.current.y-y.clientY)>=xh)&&(a(!0),window.removeEventListener("mousemove",g),m(u.current.widget,y),u.current=void 0)},[u,m]),f=S.exports.useCallback((y,E)=>{u.current={x:y.clientX,y:y.clientY,widget:E},window.addEventListener("mousemove",g)},[g]),b=S.exports.useCallback((y,E)=>{var I;window.removeEventListener("mousemove",g),((I=u.current)==null?void 0:I.widget)===E&&(a(!0),m(E)),u.current=void 0},[g,u,m]),C=S.exports.useMemo(()=>o.filter(y=>{var E;return l?(E=y.name)==null?void 0:E.toLowerCase().includes(l.toLowerCase()):!0}),[l,o]).sort((y,E)=>{var I,D,M;return(M=(D=y.name)==null?void 0:D.localeCompare((I=E.name)!=null?I:""))!=null?M:0}),v=S.exports.useMemo(()=>C.map(y=>{var E,I;return d("li",{children:w("button",{type:"button",className:"btn btn-link","data-testid":`panel-list-item-${(E=y.name)!=null?E:""}-button`,onMouseDown:D=>{f(D,y)},onMouseUp:D=>{b(D,y)},onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&m(y)},disabled:r,children:[d(yu,{type:y.type})," ",(I=y.name)!=null?I:""]})},y.name)}),[C,r,f,b,m]),T=S.exports.useMemo(()=>v.length===0?d("span",{children:"No bound variables found."}):null,[v]);return w("div",{className:"widget-list-container d-flex flex-column",children:[d("div",{className:"widget-list-header",children:d(gs,{value:l,placeholder:"Find Table, Plot or Widget",onChange:p,ref:h})}),w("ul",{className:"widget-list flex-grow-1",children:[T&&d("li",{className:"widget-list-message",children:T}),!T&&v]}),d("div",{children:d("hr",{})}),w("div",{className:"widget-list-footer",children:[w(he,{kind:"ghost",onClick:e,children:[w("div",{className:"fa-md fa-layers",children:[d(z,{mask:vl,icon:dd,transform:"right-5 down-5"}),d(z,{icon:dd,transform:"right-8 down-6"})]}),"Export Layout"]}),w(he,{kind:"ghost",onClick:n,children:[w("div",{className:"fa-md fa-layers",children:[d(z,{mask:vl,icon:Sl,transform:"right-5 down-5"}),d(z,{icon:Sl,transform:"right-8 down-6"})]}),"Import Layout"]}),d(he,{kind:"ghost",icon:_i,onClick:s,tooltip:"Reset Layout"})]})]})},QE=async(t,e,n)=>{let s,i,o,r;if(Lr(e)?(s=e.settings,i=e.table,o="",r=e.tableSettings):(s={},i="",o=e.figure,r={}),n&&(n.tableSettings&&(r=n.tableSettings),n.table&&(i=n.table),n.figure&&(o=n.figure),n.settings&&(s={...s,...n.settings})),o){const c={title:o,name:o,type:N.VariableType.FIGURE},h=await t.getObject(c);return Ki.makeModel(s,h)}const a={title:o,name:i,type:N.VariableType.TABLE},l=await t.getObject(a);return te.applyTableSettings(l,r,Sa(Ta.getState())),Ki.makeModelFromSettings(s,l)},ZE=async(t,e,n=N.VariableType.TABLE)=>{const{table:s}=e,i={title:s,name:s,type:n},o=await t.getObject(i);return xc.makeModel(o)};const JE=({onAutoFillClick:t=()=>{}})=>w("div",{className:"empty-dashboard-container",children:[w("div",{className:"hint-container",children:[d(z,{icon:Vg})," ",d("br",{}),"Use the panel list to add objects from a query."]}),w("div",{className:"empty-dashboard",children:[d("div",{className:"add-panels-hint",children:"Drag Panels Here"}),d(he,{kind:"tertiary",onClick:t,children:"Auto fill objects"})]})]});function e1(t){return t.version===2}function t1(t){return Array.isArray(t)}const Nr=X.module("UserLayoutUtils"),n1={layoutConfig:[{type:"column",content:[{type:"row",content:[{type:"stack",content:[{type:"react-component",component:Oi.COMPONENT,title:Oi.TITLE,isClosable:!1},{type:"react-component",component:Jr.COMPONENT,title:Jr.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:jr.COMPONENT,title:jr.TITLE,isClosable:!1},{type:"react-component",component:Qr.COMPONENT,title:Qr.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},s1={layoutConfig:[],links:[],filterSets:[],version:2};function Sp(t){if(e1(t))return t;if(t1(t))return{layoutConfig:t,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${t}`)}async function i1(t,e=!0){try{const n=await t.getLayouts();if(n.length>0)try{const s=await t.getLayout(n[0]);return Sp(s)}catch(s){Nr.error("Unable to load layout",n[0],":",s),Nr.warn("No valid layouts found, falling back to default layout")}}catch(n){Nr.error("Unable to fetch layout list",n),Nr.warn("Falling back to default layout")}return e?n1:s1}function o1(t){const{filterSets:e,layoutConfig:n,links:s}=t;return{filterSets:e,layoutConfig:n,links:s,version:2}}const Pr={exportLayout:o1,getDefaultLayout:i1,normalizeLayout:Sp},Mr=X.module("DownloadServiceWorkerUtils"),wp=class{static registerOnLoaded(){new URL("/ide/",window.location.href).origin===window.location.origin&&("serviceWorker"in navigator?window.addEventListener("load",()=>{const e=new URL("/ide/download/serviceWorker.js",window.location.href);navigator.serviceWorker.register(e).then(n=>{n.update(),Mr.info("Registering service worker on ",e,n)}).catch(n=>{Mr.error("Failed to register service worker",n)})}):Mr.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const e=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(wp.DOWNLOAD_PATH));if(e&&e.active)return Mr.info("Download service worker is active."),e.active;throw new Error("Can not find download service worker.")}throw new Error("Download service worker is not available.")}static unregisterSW(){}};let ta=wp;ta.DOWNLOAD_PATH="/download/";const vp={react:Y},r1=Up(vp),a1=Bp({requires:r1}),l1=$p.createRequires(vp),c1=Wp({requires:l1}),d1=X.module("PluginUtils");class Ul{static loadComponentPlugin(e){if("".split(",").includes(e)){const o=Y.lazy(()=>jp(()=>import(`./internal/${e}`),[])),r=Y.forwardRef((a,l)=>d(S.exports.Suspense,{fallback:d("div",{children:"Loading Plugin..."}),children:d(o,{ref:l,...a})}));return r.pluginName=e,r.displayName="Local Plugin",r}const n=new URL("/ide/plugins/",`${window.location}`),s=new URL(`${e}.js`,n),i=Y.forwardRef((o,r)=>d(a1,{url:s,render:({err:a,Component:l})=>{if(a){const c=`Error loading plugin ${e} from ${s} due to ${a}`;return d1.error(c),d("div",{className:"error-message",children:`${c}`})}return d(l,{ref:r,...o})}}));return i.pluginName=e,i.displayName="Plugin",i}static async loadModulePlugin(e){return await c1(e)}static async loadJson(e){return new Promise((n,s)=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{try{const o=JSON.parse(i.responseText);n(o)}catch(o){s(o)}}),i.addEventListener("error",o=>{s(o)}),i.open("GET",e),i.send()})}}const Ot=X.module("AppMainContainer");class Lo extends S.exports.Component{constructor(e){super(e),this.getDashboardPlugins=Ce(n=>[...n.entries()].filter(([,{DashboardPlugin:s}])=>s).map(([s,{DashboardPlugin:i}])=>d(i,{},s))),this.handleSettingsMenuHide=this.handleSettingsMenuHide.bind(this),this.handleSettingsMenuShow=this.handleSettingsMenuShow.bind(this),this.handleError=this.handleError.bind(this),this.handleControlSelect=this.handleControlSelect.bind(this),this.handleToolSelect=this.handleToolSelect.bind(this),this.handleClearFilter=this.handleClearFilter.bind(this),this.handleDataChange=this.handleDataChange.bind(this),this.handleAutoFillClick=this.handleAutoFillClick.bind(this),this.handleGoldenLayoutChange=this.handleGoldenLayoutChange.bind(this),this.handleLayoutConfigChange=this.handleLayoutConfigChange.bind(this),this.handleExportLayoutClick=this.handleExportLayoutClick.bind(this),this.handleImportLayoutClick=this.handleImportLayoutClick.bind(this),this.handleImportLayoutFiles=this.handleImportLayoutFiles.bind(this),this.handleLoadTablePlugin=this.handleLoadTablePlugin.bind(this),this.handleResetLayoutClick=this.handleResetLayoutClick.bind(this),this.handleWidgetMenuClick=this.handleWidgetMenuClick.bind(this),this.handleWidgetsMenuClose=this.handleWidgetsMenuClose.bind(this),this.handleWidgetSelect=this.handleWidgetSelect.bind(this),this.handlePaste=this.handlePaste.bind(this),this.hydrateChart=this.hydrateChart.bind(this),this.hydrateGrid=this.hydrateGrid.bind(this),this.hydratePandas=this.hydratePandas.bind(this),this.hydrateDefault=this.hydrateDefault.bind(this),this.openNotebookFromURL=this.openNotebookFromURL.bind(this),this.importElement=Y.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(mn.LINKER)},shortcut:Os.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:hn.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{Ot.debug("Consume unhandled save shortcut")},shortcut:Os.SAVE,isGlobal:!0}],isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,n){return Rl.hydrate({...e,unzip:s=>Vh.loadAsync(s).then(i=>Object.values(i.files))},n)}componentDidMount(){this.initWidgets(),window.addEventListener("beforeunload",Lo.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:n}=this.props;e.dashboardData!==n&&this.handleDataChange(n)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",Lo.handleWindowBeforeUnload)}initWidgets(){const{connection:e}=this.props;if(!e.subscribeToFieldUpdates){Ot.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(n=>{Ot.debug("Got updates",n),this.setState(({widgets:s})=>{const{updated:i,created:o,removed:r}=n,a=[...i,...r],l=s.filter(h=>!a.some(u=>u.name===h.name));return[...i,...o].forEach(h=>{h.name&&l.push(h)}),{widgets:l}})})}deinitWidgets(){var e;(e=this.widgetListenerRemover)==null||e.call(this)}openNotebookFromURL(){const{match:e}=this.props,{notebookPath:n}=e.params;if(n){const{session:s,sessionConfig:i}=this.props;if(!s||!i){Ot.error("No session available to open notebook URL",n);return}const o={id:`/${n}`,itemName:`/${n}`},r=i.type,a={value:null,language:r};this.emitLayoutEvent(Be.SELECT_NOTEBOOK,s,r,a,o,!0)}}sendClearFilter(){this.emitLayoutEvent(Ue.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...n){var s;(s=this.goldenLayout)==null||s.eventHub.emit(e,...n)}handleError(e){De.isCanceled(e)||Ot.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,n=null){switch(Ot.debug("handleControlSelect",e),e){case wn.DROPDOWN_FILTER:this.emitLayoutEvent(Ue.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:n});break;case wn.INPUT_FILTER:this.emitLayoutEvent(Ue.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:n});break;case wn.MARKDOWN:this.emitLayoutEvent(jm.OPEN,{title:"Markdown",type:e,dragEvent:n});break;case wn.FILTER_SET_MANAGER:this.emitLayoutEvent(Ue.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:n});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){Ot.debug("handleToolSelect",e);const{activeTool:n,setActiveTool:s}=this.props;s(n===e?mn.DEFAULT:e)}handleClearFilter(){this.sendClearFilter()}handleDataChange(e){const{updateWorkspaceData:n}=this.props,{closed:s,filterSets:i,links:o}=e;n({closed:s,filterSets:i,links:o})}handleGoldenLayoutChange(e){this.goldenLayout=e}handleLayoutConfigChange(e){const{updateWorkspaceData:n}=this.props;n({layoutConfig:e})}handleWidgetMenuClick(){this.setState(({isPanelsMenuShown:e})=>({isPanelsMenuShown:!e}))}handleWidgetSelect(e,n){this.setState({isPanelsMenuShown:!1}),Ot.debug("handleWidgetSelect",e,n),this.openWidget(e,n)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;Ot.debug("handleAutoFillClick",e);const n=e.sort((s,i)=>s.title!=null&&i.title!=null?s.title.localeCompare(i.title):0);for(let s=0;s<n.length;s+=1)this.openWidget(n[s])}handleExportLayoutClick(){Ot.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:n}=e,s=Pr.exportLayout(n);Ot.info("handleExportLayoutClick exportedConfig",s);const i=new Blob([JSON.stringify(s)],{type:"application/json"}),o=N.i18n.DateTimeFormat.format("yyyy-MM-dd-HHmmss",new Date),r=document.createElement("a");r.href=URL.createObjectURL(i),r.download=`deephaven-app-layout-${o}.json`,r.click()}catch(e){Ot.error("Unable to export layout",e)}}handleImportLayoutClick(){Ot.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){Ot.info("handleResetLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.resetLayout()}handleImportLayoutFiles(e){var n;e.stopPropagation(),e.preventDefault(),e.target.files!=null&&this.importLayoutFile((n=e.target.files)==null?void 0:n[0])}async importLayoutFile(e){try{const{updateDashboardData:n,updateWorkspaceData:s}=this.props,i=await e.text(),o=JSON.parse(i),{filterSets:r,layoutConfig:a,links:l}=Pr.normalizeLayout(o);s({layoutConfig:a}),n(Dn,{filterSets:r,links:l})}catch(n){Ot.error("Unable to import layout",n)}}async resetLayout(){const{layoutStorage:e,session:n}=this.props,{filterSets:s,layoutConfig:i,links:o}=await Pr.getDefaultLayout(e,n!==void 0),{updateDashboardData:r,updateWorkspaceData:a}=this.props;a({layoutConfig:i}),r(Dn,{filterSets:s,links:o})}handlePaste(e){let n=e.currentTarget.parentElement;for(;n!=null;){if(n.classList.contains("monaco-editor"))return;n=n.parentElement}const{clipboardData:s}=e,i=s.getData("Text"),o=/“|”/g;o.test(i)&&(e.preventDefault(),e.stopPropagation(),document.execCommand("insertText",!1,i.replace(o,'"')))}handleLoadTablePlugin(e){const{plugins:n}=this.props,s=n.get(e);return s!=null&&s.TablePlugin?s.TablePlugin:Ul.loadComponentPlugin(e)}hydrateDefault(e,n){const{connection:s}=this.props,{metadata:i}=e;if((i==null?void 0:i.type)&&((i==null?void 0:i.id)||(i==null?void 0:i.name))){const o=i.id?{type:i.type,id:i.id}:{type:i.type,name:i.name,title:i.name};return{fetch:()=>s.getObject(o),localDashboardId:n,...e}}return Rl.hydrate(e,n)}hydrateGrid(e,n){return this.hydrateTable(e,n,N.VariableType.TABLE)}hydratePandas(e,n){return this.hydrateTable(e,n,N.VariableType.PANDAS)}hydrateTable(e,n,s=N.VariableType.TABLE){const{connection:i}=this.props;return{...e,getDownloadWorker:ta.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:n,makeModel:()=>ZE(i,e.metadata,s)}}hydrateChart(e,n){const{connection:s}=this.props;return{...e,localDashboardId:n,makeModel:()=>{const{metadata:i,panelState:o}=e;return QE(s,i,o)}}}openWidget(e,n){const{connection:s}=this.props;this.emitLayoutEvent(Fe.OPEN,{dragEvent:n,fetch:()=>s.getObject(e),widget:e})}render(){const{activeTool:e,plugins:n,user:s,workspace:i}=this.props,{data:o}=i,{layoutConfig:r}=o,{permissions:a}=s,{canUsePanels:l}=a,{contextActions:c,isPanelsMenuShown:h,isSettingsMenuShown:u,widgets:m}=this.state,p=this.getDashboardPlugins(n);return w("div",{className:W("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[d("nav",{className:"nav-container",children:w("div",{className:"app-main-top-nav-menus",children:[d("img",{src:Cp,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),w("div",{children:[w("button",{type:"button",className:"btn btn-link btn-panels-menu",children:[d(z,{icon:_f}),"Controls",d(qc,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),l&&w("button",{type:"button",className:"btn btn-link btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,children:[d(z,{icon:Nf}),"Panels",d(xn,{isShown:h,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:d(jE,{widgets:m,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),w("button",{type:"button",className:W("btn btn-link btn-link-icon btn-settings-menu",{"text-warning":s.operateAs!==s.name}),onClick:this.handleSettingsMenuShow,children:[d(z,{icon:$o,transform:"grow-3 right-1 down-1"}),d(pe,{children:"User Settings"})]})]})]})}),w(Vw,{emptyDashboard:d(JE,{onAutoFillClick:this.handleAutoFillClick}),id:Dn,layoutConfig:r,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[d(CE,{hydrate:this.hydrateGrid,getDownloadWorker:ta.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),d(hE,{hydrate:this.hydrateChart}),d(uE,{}),d(pE,{hydrateConsole:Lo.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),d(gE,{}),d(yE,{hydrate:this.hydratePandas}),d(EE,{}),d(TE,{}),p]}),d(gt,{in:u,timeout:It.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:d(Yo,{onDone:this.handleSettingsMenuHide})}),d(ie,{actions:c}),d("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles})]})}}const h1=t=>{var e,n;return{activeTool:wa(t),dashboardData:jt(t,Dn),layoutStorage:XE(t),plugins:Jb(t),connection:yT(t,Dn),session:(e=gi(t,Dn))==null?void 0:e.session,sessionConfig:(n=gi(t,Dn))==null?void 0:n.config,user:Ku(t),workspace:ba(t)}},u1=xt(h1,{setActiveTool:va,updateDashboardData:Yn,updateWorkspaceData:sm})(zp(Lo)),m1=()=>w("div",{className:"app",children:[d(u1,{}),d(ru,{})]});X.module("StorageTableViewportUpdater");class _h{static makeSortConfig(e,n){return{column:e,direction:n}}static makeFilterConfig(e){const n=[],s=[];return e.forEach((i,o)=>{n.push(i),o>0&&s.push(qt.and)}),{filterItems:n,filterOperators:s}}static combineFilterConfigs(e,n,s=qt.and){return{filterItems:[...e.filterItems,...n.filterItems],filterOperators:[...e.filterOperators,s,...n.filterOperators]}}static makeFilterItem(e,n,s){return{columnName:e,type:n,value:s}}}const pl=X.module("PouchStorageTable"),p1="Deephaven.";Uh.plugin(Gp);function g1(t,e){switch(t){case q.in:case q.contains:return{$regex:new RegExp(`${e}`)};case q.inIgnoreCase:return{$regex:new RegExp(`${e}`,"i")};case q.eq:return{$eq:e};case q.notEq:return{$neq:e};case q.greaterThan:return{$gt:e};case q.greaterThanOrEqualTo:return{$gte:e};case q.lessThan:return{$lt:e};case q.lessThanOrEqualTo:return{$lte:e};case q.startsWith:return{$regex:new RegExp(`^(?${e}).*`)};default:throw new Error(`Unsupported type: ${t}`)}}function f1(t){const{filterItems:e,filterOperators:n}=t;let s=null;for(let i=0;i<e.length;i+=1){const o=e[i],{columnName:r,type:a,value:l}=o,c={[r]:g1(a,l)};if(i===0)s=c;else if(s!==null&&i-1<n.length){const h=n[i-1];if(h===qt.and)s={$and:[s,c]};else if(h===qt.or)s={$or:[s,c]};else throw new Error(`Unexpected filter operator ${h}, ${c}`)}}if(s==null)throw new Error(`Invalid filter config ${t}`);return s}function gl(t=[]){return{$and:[...t.map(e=>f1(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function C1(t,e=!1){var n;return[{id:e?"desc":"asc"},...(n=t==null?void 0:t.map(s=>({[s.column]:s.direction})))!=null?n:[]]}class b1{constructor(e){this.listeners=[],this.itemListeners=new Map,this.currentSize=0,this.currentReverse=!1,this.currentFilter=null,this.currentSort=null,this.db=new Uh(`${p1}${e}`),this.db._remote=!1,this.db.changes({live:!0,since:"now",include_docs:!0}).on("change",this.dbUpdate.bind(this)),this.db.createIndex({index:{fields:["id","name"]}}),this.refreshInfo()}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(n=>n!==e)}}onItemUpdate(e,n){return this.itemListeners.has(e)||this.itemListeners.set(e,[]),this.itemListeners.set(e,[...this.itemListeners.get(e),n]),this.refreshItem(e),()=>{this.itemListeners.set(e,this.itemListeners.get(e).filter(s=>s!==n))}}close(){this.listeners=[]}get size(){return this.currentSize}get viewport(){return this.currentViewport}setReversed(e){this.currentReverse=e,this.currentViewportData=void 0,this.refreshData()}setViewport(e){this.currentViewport=e,this.refreshInfo(),this.refreshData()}setSorts(e){this.currentSort=e,this.currentViewportData=void 0,this.refreshData()}setFilters(e){this.currentFilter=e,this.currentViewportData=void 0,this.refreshInfo(),this.refreshData()}get data(){return this.currentViewportData}async getViewportData(){var e;return this.viewportUpdatePromise||this.refreshData(),(e=this.viewportUpdatePromise)!=null?e:Promise.resolve({items:[],offset:0})}async put(e){const n={...e,_id:e.id};return await this.db.put(n),n}sendUpdate(){var s;const{listeners:e}=this,n=(s=this.currentViewportData)!=null?s:{items:[],offset:0};for(let i=0;i<e.length;i+=1)e[i](n)}sendItemUpdate(e){const n=this.itemListeners.get(e.id);if(n!==void 0)for(let s=0;s<n.length;s+=1)n[s](e)}dbUpdate(e){pl.debug("Update received",e),this.refreshInfo(),e.doc!==void 0&&this.sendItemUpdate(e.doc),this.refreshData()}async refreshInfo(){var e,n;try{(e=this.infoUpdatePromise)==null||e.cancel(),this.infoUpdatePromise=De.makeCancelable(this.db.find({selector:gl((n=this.currentFilter)!=null?n:[]),fields:[]}));const s=await this.infoUpdatePromise;this.currentSize=s.docs.length,this.sendUpdate()}catch(s){if(!De.isCanceled(s))throw pl.error("Unable to refreshInfo",s),s}}async refreshData(){var e,n;if(!!this.currentViewport)try{const{currentViewport:s}=this,i=C1(this.currentSort,this.currentReverse);(e=this.viewportUpdatePromise)==null||e.cancel(),this.viewportUpdatePromise=De.makeCancelable(this.db.find({selector:gl((n=this.currentFilter)!=null?n:[]),skip:s.top,limit:s.bottom-s.top+1,sort:i,fields:["id","name"]}).then(r=>({items:r.docs,offset:s.top})));const o=await this.viewportUpdatePromise;return this.currentViewportData=o,this.sendUpdate(),o}catch(s){if(!De.isCanceled(s))throw pl.error("Unable to refreshData",s),s}}async refreshItem(e){const s=(await this.db.find({selector:{id:e},limit:1})).docs[0];return s!==void 0&&this.sendItemUpdate(s),s}async getSnapshot(e){const n=new Map,s=[{id:this.currentReverse?"desc":"asc"}];return await Promise.all(e.map(async([i,o])=>{var a;const r=o-i+1;return this.db.find({selector:gl((a=this.currentFilter)!=null?a:[]),skip:i,limit:r,sort:s,fields:["id","name"]}).then(l=>{for(let c=0;c<r;c+=1){const h=i+c;n.set(h,l.docs[c])}})})),n}}class Lh extends b1{constructor(e){super(`CommandHistoryStorage.${e}`)}setSearch(e){this.setFilters(e?[_h.makeFilterConfig([_h.makeFilterItem("name",q.contains,e)])]:[])}}const kh=X.module("PouchCommandHistoryStorage");class S1{constructor(){this.updateTableMap=new Map}getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new Lh(e)),this.updateTableMap.get(e)}async getTable(e){return new Lh(e)}async addItem(e,n,s,i){return this.updateItem(e,{id:`${new Date().getTime()}`,name:s,data:i})}async updateItem(e,n){const s=this.getUpdateTable(e),i=await s.refreshItem(n.id),o={...i!=null?i:{},...n};return kh.debug("Updating item",o),await s.put(o),kh.debug("Update saved"),n}listenItem(e,n,s){return this.getUpdateTable(e).onItemUpdate(n,s)}}const w1=X.module("LocalWorkspaceStorage"),Do=class{static async makeDefaultWorkspaceData(t,e){const{filterSets:n,links:s,layoutConfig:i}=await Pr.getDefaultLayout(t,e==null?void 0:e.isConsoleAvailable);return{settings:{defaultDateTimeFormat:ht.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:ht.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:We.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:mt.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(t,e){return{data:await Do.makeDefaultWorkspaceData(t,e)}}constructor(t){this.layoutStorage=t}async load(t){var e;try{return JSON.parse((e=localStorage.getItem(Do.STORAGE_KEY))!=null?e:"")}catch{return w1.info("Unable to load workspace data, initializing to default data"),Do.makeDefaultWorkspace(this.layoutStorage,t)}}async save(t){return localStorage.setItem(Do.STORAGE_KEY,JSON.stringify(t)),t}};let Tp=Do;Tp.STORAGE_KEY="deephaven.WorkspaceStorage";class v1 extends Error{constructor(){super(...arguments),this.isNoConsolesError=!0}}function T1(t){return t.isNoConsolesError}const Pi=X.module("SessionUtils");function E1(){return new URL("/jsapi",`${window.location}`)}function Ep(){const t=E1();return`${t.protocol}//${t.host}`}function y1(){const t=Ep();return Pi.info(`Starting connection to '${t}'...`),new N.IdeConnection(t)}async function I1(t){Pi.info("Getting console types...");const e=await t.getConsoleTypes();if(Pi.info("Available types:",e),e.length===0)throw new v1("No console types available");const n=e[0];Pi.info("Starting session with type",n);const s=await t.startSession(n),i={type:n,id:qe.generate()};return Pi.info("Console session established",i),{session:s,config:i,connection:t}}function R1(){const t=Ep();return Pi.info("createCoreClient",t),new N.CoreClient(t)}class D1{constructor(e,n=""){this.storageService=e,this.root=n}async getLayouts(){return(await this.storageService.listItems(this.root,"*.json")).map(n=>n.basename)}async getLayout(e){const s=await(await this.storageService.loadFile(`${this.root}/${e}`)).text();return JSON.parse(s)}}const fl=X.module("GrpcFileStorageTable");class Yc{constructor(e,n="",s=n){this.currentSize=0,this.listeners=[],this.childTables=new Map,this.storageService=e,this.baseRoot=n,this.root=s}removeBaseRoot(e){return de.removeRoot(this.baseRoot,e)}getViewportData(){var e;return this.viewportUpdatePromise||this.refreshInternal(),(e=this.viewportUpdatePromise)!=null?e:Promise.resolve({items:[],offset:0})}getSnapshot(e){throw new Error("Method not implemented.")}get size(){return this.currentSize}async setExpanded(e,n){const s=e.split("/");let i=s.shift();if(i||(i=s.shift()),!i)throw new Error(`Invalid path: ${e}`);const o=s.join("/");if(n){if(!this.childTables.has(i)){const r=new Yc(this.storageService,this.baseRoot,`${this.root}/${i}`);this.childTables.set(i,r)}if(o){const r=this.childTables.get(i);r==null||r.setExpanded(o,n)}}else if(this.childTables.has(i))if(o){const r=this.childTables.get(i);r==null||r.setExpanded(o,n)}else this.childTables.delete(i);this.currentViewport&&await this.refreshInternal()}async collapseAll(){this.childTables.clear(),this.currentViewport&&await this.refreshInternal()}setSearch(e){throw new Error("Method not implemented.")}setViewport(e){this.currentViewport=e,this.refreshInternal()}setFilters(){throw new Error("Method not implemented.")}setSorts(){throw new Error("Method not implemented.")}setReversed(){throw new Error("Method not implemented.")}close(){this.listeners=[]}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(n=>n!==e)}}async refresh(){var n;fl.debug2(this.root,"refreshData"),(n=this.viewportUpdatePromise)==null||n.cancel(),this.viewportUpdatePromise=De.makeCancelable(this.fetchData());const e=await this.viewportUpdatePromise;return this.currentViewportData=e,this.sendUpdate(),e}async refreshInternal(){try{await this.refresh()}catch(e){De.isCanceled(e)||fl.error("Unable to refresh data",e)}}async fetchData(){const{currentViewport:e}=this;if(!e)throw new Error("No viewport set");let s=(await this.storageService.listItems(this.root)).map(i=>({type:i.type,filename:this.removeBaseRoot(i.filename),basename:i.basename,id:this.removeBaseRoot(i.filename),isExpanded:i.type==="directory"?this.childTables.has(i.basename):void 0})).sort((i,o)=>i.type!==o.type?i.type==="directory"?-1:1:i.basename.localeCompare(o.basename));for(let i=0;i<s.length;i+=1){const o=s[i],{basename:r,filename:a}=o;if(a===this.removeBaseRoot(`${this.root}/${r}`)&&o.type==="directory"){const l=this.childTables.get(r);if(l!=null){l.setViewport({top:0,bottom:e.bottom-i});const c=await l.getViewportData();s.splice(i+1,0,...c.items)}}}return this.currentSize=s.length,fl.debug2(this.root,"items",s,e),s=s.slice(e.top,e.bottom),{items:s,offset:e.top}}sendUpdate(){var s;const{listeners:e}=this,n=(s=this.currentViewportData)!=null?s:{items:[],offset:0};for(let i=0;i<e.length;i+=1)e[i](n)}}const N1=X.module("GrpcFileStorage"),yp=class{constructor(t,e=""){this.tables=[],this.refreshTables=hi(()=>{this.tables.every(n=>n.refresh().catch(()=>{}))},yp.REFRESH_THROTTLE),this.storageService=t,this.root=e}removeRoot(t){return de.removeRoot(this.root,t)}addRoot(t){return de.addRoot(this.root,t)}async createDirectory(t){return await this.storageService.createDirectory(this.addRoot(t)),this.refreshTables(),{type:"directory",id:t,filename:t,basename:de.getBaseName(t)}}async getTable(){const t=new Yc(this.storageService,this.root);return this.tables.push(t),t}async saveFile(t){const e=dh.storage.FileContents.text(t.content);return await this.storageService.saveFile(this.addRoot(t.filename),e,!0),this.refreshTables(),t}async loadFile(t){const n=await(await this.storageService.loadFile(this.addRoot(t))).text();return{filename:t,basename:de.getBaseName(t),content:n}}async deleteFile(t){await this.storageService.deleteItem(this.addRoot(t)),this.refreshTables()}async moveFile(t,e){await this.storageService.moveItem(this.addRoot(t),this.addRoot(e)),this.refreshTables()}async info(t){const e=await this.storageService.listItems(this.addRoot(de.getPath(t)),de.getBaseName(t));if(e.length===0)throw new Uc;if(e.length>1)throw N1.error("More than one matching file found, should never happen.",e),new Error("More than one matching file found");const n=e[0];return{filename:this.removeRoot(n.filename),basename:this.removeRoot(n.basename),id:this.removeRoot(n.filename),type:n.type}}};let Ip=yp;Ip.REFRESH_THROTTLE=150;const Hi=X.module("AppInit");async function M1(){Hi.debug("Loading plugins...");try{const t=await Ul.loadJson("/js-plugins/manifest.json");Hi.debug("Plugin manifest loaded:",t);const e=[];for(let i=0;i<t.plugins.length;i+=1){const{name:o,main:r}=t.plugins[i],a=`/js-plugins/${o}/${r}`;e.push(Ul.loadModulePlugin(a))}const n=await Promise.all(e),s=new Map;for(let i=0;i<n.length;i+=1){const{name:o}=t.plugins[i];s.set(o,n[i])}return Hi.info("Plugins loaded:",s),s}catch(t){return Hi.error("Unable to load plugins:",t),new Map}}async function F1(t){let e;try{e=await I1(t)}catch(n){if(!T1(n))throw n}return e}const Xc=t=>{const{workspace:e,setActiveTool:n,setCommandHistoryStorage:s,setDashboardData:i,setFileStorage:o,setLayoutStorage:r,setDashboardConnection:a,setDashboardSessionWrapper:l,setPlugins:c,setUser:h,setWorkspace:u,setWorkspaceStorage:m}=t,[p,g]=S.exports.useState(),[f,b]=S.exports.useState(!0),C=S.exports.useCallback(async()=>{var I,D;try{const M=await M1(),x=y1(),B=await F1(x);x.addEventListener(N.IdeConnection.HACK_CONNECTION_FAILURE,Z=>{var be;const{detail:ge}=Z;Hi.error("Connection failure",ge),g(`Unable to connect: ${(be=ge.details)!=null?be:"Unknown Error"}`)});const $="user",k={name:$,operateAs:$,groups:[],permissions:{isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:!0,canDownloadCsv:!0}},H=R1();await H.login({type:N.CoreClient.LOGIN_TYPE_ANONYMOUS});const A=H.getStorageService(),F=new D1(A,"/layouts"),_=new Ip(A,"/notebooks"),L=new Tp(F),V=new S1,G=await L.load({isConsoleAvailable:B!==void 0}),{data:j}=G,{settings:ne}=j;ne.defaultDecimalFormatOptions===void 0&&(ne.defaultDecimalFormatOptions={defaultFormatString:We.DEFAULT_FORMAT_STRING}),ne.defaultIntegerFormatOptions===void 0&&(ne.defaultIntegerFormatOptions={defaultFormatString:mt.DEFAULT_FORMAT_STRING}),ne.truncateNumbersWithPound===void 0&&(ne.truncateNumbersWithPound=!1);const{shortcutOverrides:ye={}}=ne,Te=Kt.isMacPlatform?(I=ye.mac)!=null?I:{}:(D=ye.windows)!=null?D:{};Object.entries(Te).forEach(([Z,ge])=>{var be;(be=ze.get(Z))==null||be.setKeyState(ge)});const He={filterSets:j.filterSets,links:j.links};n(mn.DEFAULT),s(V),i(Dn,He),o(_),r(F),a(Dn,x),B!==void 0&&l(Dn,B),c(M),h(k),m(L),u(G)}catch(M){Hi.error(M),g(M)}},[n,s,i,o,r,a,l,c,h,u,m]),v=S.exports.useCallback(()=>{document.fonts?document.fonts.ready.then(()=>{b(!1)}):b(!1)},[]);S.exports.useEffect(function(){C(),v()},[C,v]);const T=!e&&!p||f,y=!T&&!p,E=p?`${p}`:null;return w(ue,{children:[y&&d(m1,{}),d(ha,{isLoading:T,isLoaded:y,errorMessage:E}),w("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:[d("p",{className:"fira-sans-regular",children:"preload"}),d("p",{className:"fira-sans-semibold",children:"preload"}),d("p",{className:"fira-mono",children:"preload"})]})]})};Xc.propTypes={workspace:R.exports.shape({}),workspaceStorage:R.exports.shape({close:R.exports.func}),setActiveTool:R.exports.func.isRequired,setCommandHistoryStorage:R.exports.func.isRequired,setDashboardData:R.exports.func.isRequired,setFileStorage:R.exports.func.isRequired,setLayoutStorage:R.exports.func.isRequired,setDashboardConnection:R.exports.func.isRequired,setDashboardSessionWrapper:R.exports.func.isRequired,setPlugins:R.exports.func.isRequired,setUser:R.exports.func.isRequired,setWorkspace:R.exports.func.isRequired,setWorkspaceStorage:R.exports.func.isRequired};Xc.defaultProps={workspace:null,workspaceStorage:null};const x1=t=>({workspace:ba(t),workspaceStorage:zb(t)}),Oh=xt(x1,{setActiveTool:va,setCommandHistoryStorage:nS,setDashboardData:Em,setFileStorage:sS,setLayoutStorage:xE,setDashboardConnection:IT,setDashboardSessionWrapper:RT,setPlugins:oS,setUser:eS,setWorkspace:nm,setWorkspaceStorage:tS})(Xc),_1=()=>d(Kp,{basename:"/ide/",children:w(qp,{children:[d(rd,{exact:!0,path:"/",component:Oh}),d(rd,{path:"/notebook/:notebookPath+",component:Oh}),d(Yp,{from:"*",to:"/"})]})});Boolean(window.location.hostname==="localhost"||window.location.hostname==="[::1]"||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function L1(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}$E();di.render(d(Ph,{store:Ta,children:d(_1,{})}),document.getElementById("root"));L1();ta.registerOnLoaded();dt.init();window["__react-beautiful-dnd-disable-dev-warnings"]=!0;
43
- //# sourceMappingURL=index.2407ffa6.js.map
42
+ `)),e}renderFormatRule(t,e){const n=`input-${t}-columnName`,s=`input-${t}-columnType`,i=`input-${t}-format`,o=this.getCachedColumnTypeOptions(),r=h=>this.handleFormatRuleChange(t,"columnName",h.target.value),a=()=>this.handleFormatRuleChange(t,"isNewRule",!1),l=h=>this.handleFormatRuleChange(t,"columnType",h.target.value),c=this.getRuleError(e);return w("fieldset",{className:"container-fluid format-rule-container",children:[w("div",{className:"form-row",children:[w("div",{className:"form-group col-7 mb-2",children:[d("label",{htmlFor:n,children:"Column Name"}),d("input",{id:n,className:W("form-control",{"is-invalid":c.hasColumnNameError}),"data-lpignore":!0,type:"text",value:e.columnName,onChange:r,onBlur:a})]}),w("div",{className:"form-group col mb-2",children:[d("button",{type:"button",className:"btn btn-link btn-link-icon btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(t),children:d(z,{icon:_n})}),d("label",{htmlFor:s,children:"Column Type"}),d("select",{id:s,className:"custom-select",value:e.columnType,onChange:l,children:o})]})]}),d("div",{className:"form-row",children:w("div",{className:"form-group col-12 d-flex mb-2",children:[d("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:i,children:"Formatting Rule"}),this.renderFormatRuleInput(t,e.columnType,i,e.format,c.hasFormatError)]})}),d("div",{className:"form-row",children:d("div",{className:"form-group col-12 d-flex mb-2",children:c.message&&d("p",{className:"text-danger",children:c.message})})})]},t)}renderFormatRuleInput(t,e,n,s,i){switch(P.getNormalizedType(e)){case P.dataType.DATETIME:return this.renderDateTimeFormatRuleInput(t,n,s,i);case P.dataType.DECIMAL:return this.renderDecimalFormatRuleInput(t,n,s,i);case P.dataType.INT:return this.renderIntegerFormatRuleInput(t,n,s,i);default:return null}}renderDateTimeFormatRuleInput(t,e,n,s){const{showTimeZone:i,showTSeparator:o,timeZone:r}=this.state,a=n&&n.formatString||"";return w("select",{className:W("custom-select",{"is-invalid":s}),value:a,id:e,onChange:l=>{const c=ht.makeFormat("",l.target.value,ht.TYPE_GLOBAL);this.handleFormatRuleChange(t,"format",c)},children:[d("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(r,i,o)]})}renderIntegerFormatRuleInput(t,e,n,s){const i=n&&n.formatString||"";return d("input",{className:W("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:mt.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=mt.makeFormat("",o.target.value,mt.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}renderDecimalFormatRuleInput(t,e,n,s){const i=n&&n.formatString||"";return d("input",{className:W("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:We.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=We.makeFormat("",o.target.value,We.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}render(){const{defaults:t}=this.props,{formatRulesChanged:e,formatSettings:n,defaultDateTimeFormat:s,defaultDecimalFormatOptions:i,defaultIntegerFormatOptions:o,timeZone:r,showTimeZone:a,showTSeparator:l,truncateNumbersWithPound:c}=this.state,{defaultFormatString:h=We.DEFAULT_FORMAT_STRING}=i!=null?i:{},{defaultFormatString:u=mt.DEFAULT_FORMAT_STRING}=o!=null?o:{},m=n.map((v,T)=>d(gt,{classNames:"fade",timeout:It.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(T,v)},v.id)),p=w("button",{type:"button",className:"btn btn-link mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,children:[d(z,{icon:As}),"Add New Rule"]}),g=r===t.timeZone,f=l===t.showTSeparator&&a===t.showTimeZone&&s===t.defaultDateTimeFormat,b=ct.isSameDecimalOptions(i,t.defaultDecimalFormatOptions),C=ct.isSameIntegerOptions(o,t.defaultIntegerFormatOptions);return w("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[w("div",{className:"container-fluid p-0",children:[d("div",{children:"Default formatting for column types"}),d("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns of a set type."}),w("div",{className:"form-row mb-2",children:[d("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),d("div",{className:"col pr-0",children:d("select",{className:"custom-select",value:r,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:ct.renderTimeZoneOptions()})}),d("div",{className:"col-1 btn-col",children:d(he,{kind:"ghost",icon:_i,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:W("btn-reset","btn-reset-time-zone",{hidden:g})})})]}),w("div",{className:"form-row mb-2",children:[d("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),d("div",{className:"col pr-0",children:d("select",{className:"custom-select",value:s,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(r,a,l,!0,s)})}),d("div",{className:"col-1 btn-col",children:d(he,{kind:"ghost",icon:_i,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:W("btn-reset","btn-reset-date-time",{hidden:f})})})]}),d("div",{className:"form-row",children:d("div",{className:"offset-3 col-9",children:d(Ut,{checked:a!=null?a:null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),d("div",{className:"form-row mb-3",children:d("div",{className:"offset-3 col-9",children:d(Ut,{checked:l!=null?l:null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),w("div",{className:"form-row mb-2",children:[d("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),d("div",{className:"col pr-0",children:d("input",{className:W("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!ct.isValidFormat(P.dataType.DECIMAL,We.makeCustomFormat(h))}),"data-lpignore":!0,placeholder:We.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:h,onChange:this.handleDefaultDecimalFormatChange})}),d("div",{className:"col-1 btn-col",children:d(he,{kind:"ghost",icon:_i,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:W("btn-reset","btn-reset-decimal",{hidden:b}),"data-testid":"btn-reset-decimal"})})]}),w("div",{className:"form-row mb-2",children:[d("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),d("div",{className:"col pr-0",children:d("input",{className:W("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!ct.isValidFormat(P.dataType.INT,mt.makeCustomFormat(u))}),"data-lpignore":!0,placeholder:mt.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:u,onChange:this.handleDefaultIntegerFormatChange})}),d("div",{className:"col-1 btn-col",children:d(he,{kind:"ghost",icon:_i,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:W("btn-reset","btn-reset-integer",{hidden:C}),"data-testid":"btn-reset-integer"})})]}),d("div",{className:"form-row mb-3",children:d("div",{className:"offset-3 col-9",children:d(Ut,{checked:c!=null?c:null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Truncate numbers with #"})})})]}),d("div",{children:"Default formatting for matched column names"}),d("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns that match a specified name and type."}),d(Vp,{appear:e,enter:e,exit:e,children:m}),p]})}};let Kc=ct;Kc.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:ht.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:We.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:mt.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:ht.DEFAULT_TIME_ZONE_ID}};Kc.inputDebounceTime=250;const LE=t=>({formatter:Yb(t),defaultDateTimeFormat:Gb(t),defaultDecimalFormatOptions:Kb(t),defaultIntegerFormatOptions:qb(t),showTimeZone:Xb(t),showTSeparator:jb(t),truncateNumbersWithPound:Qb(t),timeZone:Sa(t),settings:Xt(t)}),kE=xt(LE,{saveSettings:im})(Kc),OE=()=>{const[t,e]=S.exports.useState(!1),n=()=>{e(!t)};return w("button",{type:"button",className:"btn btn-link",onClick:n,children:[d(z,{icon:Jg}),"Legal Notices",w(Ho,{isOpen:t,toggle:n,className:"theme-bg-light",children:[d(Uo,{toggle:n,children:"Legal Notice"}),w(Vo,{children:[d("p",{children:"Deephaven software is protected by U.S. Patent Nos. 9,612,959; 9,613,018; 9,613,109; 9,619,210; 9,633,060; 9,639,570; 9,672,238; 9,679,006; 9,690,821; 9,710,511; 9,760,591; 9,805,084; 9,836,495; 9,836,494; 9,886,469; 9,898,496; 9,934,266; 10,002,153; 10,002,154; 10,002,155; 10,003,673; 10,019,138; 10,069,943; 10,176,211; 10,198,465; 10,198,466; 10,198,469; 10,212,257; 10,241,960; 10,241,965; 10,242,040; 10,242,041; 10,353,893; 10,346,394; 10,452,649; 10,496,639; 10,540,351; 10,552,412; 10,565,194; 10,565,206; 10,572,474; 10,621,168; 10,642,829; 10,657,184; 10,678,787; 10,691,686; and 10,783,191. Other patents pending."}),w("p",{children:["\xA9 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})},ea=t=>{const{children:e,isExpanded:n,sectionKey:s,title:i,onToggle:o}=t;return w(ue,{children:[d("div",{children:w("button",{type:"button",className:"btn btn-link btn-collapse-trigger",onClick:()=>o(s),children:[d("div",{className:"flex-grow-1",children:i}),d("div",{className:"flex-shrink-0",children:d(z,{transform:n?"flip-v":"",icon:cs})})]})}),d(sc,{in:n,autoFocusOnShow:!0,children:e})]})};ea.propTypes={children:R.exports.node,isExpanded:R.exports.bool.isRequired,sectionKey:R.exports.string.isRequired,title:R.exports.node.isRequired,onToggle:R.exports.func};ea.defaultProps={children:null,onToggle:()=>{}};function AE({shortcut:t,displayText:e,categoryName:n,onChange:s}){const[i,o]=S.exports.useState(e),[r,a]=S.exports.useState(t.getKeyState()),[l,c]=S.exports.useState(!1),[h,u]=S.exports.useState("");S.exports.useEffect(function(){o(e),a(t.getKeyState())},[e,t]),S.exports.useEffect(function(){o(Kt.getDisplayText(r)),t.matchesKeyState(r)&&c(!1)},[r,t]),S.exports.useEffect(function(){if(l){if(!Kt.isValidKeyState(r)){Kt.isAllowedKey(r.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const y=ze.getConflictingShortcuts(r).filter(E=>E.id.startsWith(n)&&E!==t).map(E=>E.name);if(y.length){u(`Conflicts with ${y.join(", ")}`);return}u("")}else u("")},[l,r,n,t]);function m(T){if(T.stopPropagation(),T.preventDefault(),t.isEditable&&!T.repeat){const y=Kt.getKeyStateFromEvent(T),E=Kt.createKeyState([fe.BACKSPACE]);Kt.doKeyStatesMatch(y,E)?a(Kt.NULL_KEY_STATE):a(y)}}function p(T){T.stopPropagation(),T.preventDefault(),t.matchesKeyState(r)||c(!0)}function g(){xe.disableAllActions()}function f(){xe.enableAllActions()}function b(){t.setKeyState(r),c(!1),s(t)}function C(){const T=t.getKeyState();a(T),c(!1)}function v(){c(!0),a(t.getDefaultKeyState())}return w(ue,{children:[w("div",{className:"shortcut-item-container",children:[w("label",{className:"shortcut-item-name",children:[t.name,t.tooltip&&d(pe,{children:t.tooltip})]}),w("div",{className:"shortcut-item-input-container",children:[d("input",{className:W("form-control",{"is-invalid":h}),onKeyDown:m,onKeyUp:p,onFocus:g,onBlur:f,disabled:!t.isEditable,value:i,readOnly:!0}),!Kt.doKeyStatesMatch(r,t.getDefaultKeyState())&&!h&&d(he,{className:"reset-to-default-button",kind:"ghost",icon:d(z,{icon:_i,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:v})]})]}),l&&w("div",{className:W("shortcut-item-message-container",{"is-invalid":h}),children:[d("div",{className:"shortcut-item-message",children:h}),w("div",{className:"shortcut-item-message-buttons",children:[Kt.isValidKeyState(r)&&d(he,{kind:"ghost",onClick:b,children:"Confirm"}),d(he,{kind:"ghost",onClick:C,children:"Undo"})]})]})]})}function PE({shortcutOverrides:t={},settings:e,saveSettings:n}){const s=S.exports.useCallback(a=>{const l=Kt.isMacPlatform,c={mac:{...t.mac},windows:{...t.windows}},h=l?c.mac:c.windows;a.forEach(u=>{u.isDefault()?delete h[u.id]:h[u.id]=u.getKeyState()}),n({...e,shortcutOverrides:c})},[e,n,t]);let i=Array.from(ze.shortcutsByCategory.entries()).map(([a,l])=>({name:a,shortcuts:l}));const o=i.findIndex(a=>a.name.toUpperCase()==="GLOBAL"),r=i.splice(o,1);return i=i.concat(r),w(ue,{children:[d("div",{className:"app-settings-menu-description",children:"Customize shortcuts below. Assigning shortcuts that conflict with the browser or IDE shortcuts may cause unintended behavior"}),i.map(a=>d(HE,{name:a.name,shortcuts:a.shortcuts,saveShortcutOverrides:s},a.name))]})}function HE({name:t,shortcuts:e,saveShortcutOverrides:n}){function s(l){return l.split("_").map(c=>`${c[0].toUpperCase()}${c.slice(1).toLowerCase()}`).join(" ")}const[i,o]=S.exports.useState(e);function r(l){const c=i.filter(u=>u!==l&&!u.isNull()&&u.matchesKeyState(l.getKeyState()));c.forEach(u=>u.setToNull());const h=[l,...c];n(h),o(u=>[...u])}const a=S.exports.useMemo(()=>i.map(l=>l.getDisplayText()),[i]);return w("div",{className:"mt-3",children:[d("div",{className:"font-weight-bold",children:s(t)}),i.map((l,c)=>d(AE,{shortcut:l,displayText:a[c],categoryName:t,onChange:r},l.id))]})}const VE=t=>({settings:Xt(t),shortcutOverrides:Zb(t)}),UE={saveSettings:im},BE=xt(VE,UE)(PE),Hl=new Mg,Vl=new Vr(Hl);function $E(){X.setLogLevel(parseInt("2",10)),Hl.enable(),Vl.enable(),window&&(window.DHLog=X,window.DHLogProxy=Hl,window.DHLogHistory=Vl)}const WE="yyyy-MM-dd-HHmmss";function bp(t,e="root",n=new Map([[t,""]])){const s={};return Object.entries(t).forEach(([i,o])=>{try{JSON.stringify(o),s[i]=o}catch{const a=o;if(typeof o=="bigint")s[i]=o.toString();else if(n.has(a))s[i]=`Circular ref to ${n.get(a)}`;else{const l=`${e}.${i}`;n.set(a,l),s[i]=bp(o,l,n)}}}),s}function zE(){const t=Ta.getState();return JSON.stringify(bp(t),null,2)}function GE(){const t={uiVersion:"0.19.1",userAgent:navigator.userAgent};return JSON.stringify(t,null,2)}async function KE(t=`${N.i18n.DateTimeFormat.format(WE,new Date)}_support_logs`){const e=new Vh,n=e.folder(t);n.file("console.txt",Vl.getFormattedHistory()),n.file("redux.json",zE()),n.file("metadata.json",GE());const s=await e.generateAsync({type:"blob"}),i=document.createElement("a");i.href=URL.createObjectURL(s),i.download=`${t}.zip`,i.click()}const Fs=class extends S.exports.Component{constructor(t){super(t),this.handleClose=this.handleClose.bind(this),this.handleScrollTo=this.handleScrollTo.bind(this),this.handleSectionToggle=this.handleSectionToggle.bind(this),this.menuContentRef=Y.createRef(),this.state={expandedSectionKey:Fs.FORMATTING_SECTION_KEY}}static focusFirstInputInContainer(t){const e=t==null?void 0:t.querySelector("input, select, textarea");e&&e.focus()}static handleExportSupportLogs(){KE()}componentDidMount(){Fs.focusFirstInputInContainer(this.menuContentRef.current)}isSectionExpanded(t){const{expandedSectionKey:e}=this.state;return e===t}handleScrollTo(t,e){var n;(n=this.menuContentRef.current)==null||n.scrollTo(t,e)}handleSectionToggle(t){this.setState(e=>({expandedSectionKey:e.expandedSectionKey===t?void 0:t}))}handleClose(){const{onDone:t}=this.props;t()}render(){const t="0.19.1",e="https://github.com/deephaven/web-client-ui/",n="https://deephaven.io/core/docs/";return w("div",{className:"app-settings-menu",children:[w("header",{className:"app-settings-menu-header",children:[d("div",{className:"flex-spacer"}),d("button",{type:"button",className:"btn btn-link btn-link-icon btn-close-settings-menu",onClick:this.handleClose,children:d(z,{icon:Bo,transform:"grow-4"})})]}),w("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[d("h5",{children:"Settings"}),d("hr",{className:"my-0"}),d(ea,{sectionKey:Fs.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(Fs.FORMATTING_SECTION_KEY),title:w(ue,{children:[d(z,{icon:mf,transform:"grow-4",className:"mr-2"}),"Formatting & Time zone"]}),onToggle:this.handleSectionToggle,children:d(kE,{scrollTo:this.handleScrollTo})}),d(ea,{sectionKey:Fs.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(Fs.SHORTCUT_SECTION_KEY),title:w(ue,{children:[d(z,{icon:af,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:d(BE,{})}),w("div",{className:"app-settings-footer",children:[w("div",{className:"app-settings-footer-section",children:[w("div",{className:"app-settings-footer-item",children:[d("div",{className:"font-weight-bold",children:"Support"}),w("div",{children:["GitHub:\xA0",d("a",{href:e,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:e})]}),d("button",{type:"button",className:"btn btn-secondary mt-2 py-2",onClick:Fs.handleExportSupportLogs,children:"Export Logs"})]}),w("div",{className:"app-settings-footer-item",children:[d("div",{className:"font-weight-bold",children:"Documentation"}),d("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),d("div",{className:"app-settings-footer-item",children:w("div",{className:"text-muted",children:["Version ",t]})}),d("div",{className:"app-settings-footer-item",children:d(OE,{})})]}),d("div",{className:"app-settings-footer-section",children:d("div",{className:"logo",children:d("a",{target:"_blank",rel:"noreferrer noopener",href:"https://deephaven.io",className:"d-inline-block custom-link p-1",children:d("img",{src:Cp,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}};let Yo=Fs;Yo.defaultProps={onDone:()=>{}};Yo.FORMATTING_SECTION_KEY="SettingsMenu.formatting";Yo.APPLICATION_SECTION_KEY="ApplicationMenu.settings";Yo.SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";const Fh=10,Ai=t=>{const{forwardedProps:{menuItem:{action:e,title:n,disabled:s},iconElement:i,displayShortcut:o,isMouseSelected:r,isKeyboardSelected:a,closeMenu:l}}=t,c=S.exports.useRef(),h=S.exports.useRef(),u=S.exports.useRef(null),[m,p]=S.exports.useState(!1),g=S.exports.useCallback(C=>{c.current&&h.current&&u.current&&(Math.abs(c.current-C.clientX)>=Fh||Math.abs(h.current-C.clientY)>=Fh)&&(p(!0),window.removeEventListener("mousemove",g),l(),e(C),u.current=null)},[e,l]);function f(C){c.current=C.clientX,h.current=C.clientY,u.current=C.target,window.addEventListener("mousemove",g)}function b(C){u.current===C.target&&(p(!0),l(),e(),window.removeEventListener("mousemove",g)),u.current=null}return S.exports.useEffect(function(){return function(){return window.removeEventListener("mousemove",g)}},[g]),w("button",{type:"button",className:W("btn-context-menu",{disabled:s},{active:r&&!s},{"keyboard-active":a&&!s}),onMouseDown:f,onMouseUp:b,disabled:m,children:[d("span",{className:W("icon"),children:i}),d("span",{className:"title",children:n}),d("span",{className:"shortcut",children:o})]})},qc=t=>{const{handleControlSelect:e,handleToolSelect:n,onClearFilter:s}=t,i=S.exports.useMemo(()=>[{title:"Input Filter",icon:Rf,menuElement:d(Ai,{}),action:o=>{e(wn.INPUT_FILTER,o)},order:10},{title:"Dropdown Filter",icon:eu,menuElement:d(Ai,{}),action:o=>{e(wn.DROPDOWN_FILTER,o)},order:15},{title:"Markdown Widget",icon:sf,menuElement:d(Ai,{}),action:o=>{e(wn.MARKDOWN,o)},order:20},{title:"Filter Sets",icon:wl,menuElement:d(Ai,{}),action:o=>{e(wn.FILTER_SET_MANAGER,o)},order:25},{disabled:!0,menuElement:d("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:Yl,action:()=>{n(mn.LINKER)},order:40,shortcut:Os.LINKER},{disabled:!0,menuElement:d("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:Tf,action:()=>{s()},order:60,shortcut:hn.TABLE.CLEAR_ALL_FILTERS}],[e,n,s]);return d(zn,{popperClassName:"controls-menu-popper",actions:i})};qc.propTypes={handleControlSelect:R.exports.func,handleToolSelect:R.exports.func,onClearFilter:R.exports.func};qc.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};Ai.propTypes={forwardedProps:R.exports.shape({iconElement:R.exports.node,displayShortcut:R.exports.string,isMouseSelected:R.exports.bool.isRequired,isKeyboardSelected:R.exports.bool.isRequired,closeMenu:R.exports.func.isRequired,menuItem:R.exports.shape({action:R.exports.func,title:R.exports.string,disabled:R.exports.bool}).isRequired})};Ai.defaultProps={forwardedProps:null};const qE=fi(fp,null),YE={layoutStorage:qE},XE=t=>t.layoutStorage;Object.entries(YE).map(([t,e])=>eo.register(t,e));const xh=10,jE=t=>{const{onExportLayout:e,onImportLayout:n,onResetLayout:s,onSelect:i,widgets:o=[]}=t,[r,a]=S.exports.useState(!1),[l,c]=S.exports.useState(""),h=S.exports.useRef(null),u=S.exports.useRef(),m=S.exports.useCallback((y,E)=>{y&&i(y,E)},[i]),p=S.exports.useCallback(y=>{c(y.target.value)},[]),g=S.exports.useCallback(y=>{u.current!=null&&(Math.abs(u.current.x-y.clientX)>=xh||Math.abs(u.current.y-y.clientY)>=xh)&&(a(!0),window.removeEventListener("mousemove",g),m(u.current.widget,y),u.current=void 0)},[u,m]),f=S.exports.useCallback((y,E)=>{u.current={x:y.clientX,y:y.clientY,widget:E},window.addEventListener("mousemove",g)},[g]),b=S.exports.useCallback((y,E)=>{var I;window.removeEventListener("mousemove",g),((I=u.current)==null?void 0:I.widget)===E&&(a(!0),m(E)),u.current=void 0},[g,u,m]),C=S.exports.useMemo(()=>o.filter(y=>{var E;return l?(E=y.name)==null?void 0:E.toLowerCase().includes(l.toLowerCase()):!0}),[l,o]).sort((y,E)=>{var I,D,M;return(M=(D=y.name)==null?void 0:D.localeCompare((I=E.name)!=null?I:""))!=null?M:0}),v=S.exports.useMemo(()=>C.map(y=>{var E,I;return d("li",{children:w("button",{type:"button",className:"btn btn-link","data-testid":`panel-list-item-${(E=y.name)!=null?E:""}-button`,onMouseDown:D=>{f(D,y)},onMouseUp:D=>{b(D,y)},onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&m(y)},disabled:r,children:[d(yu,{type:y.type})," ",(I=y.name)!=null?I:""]})},y.name)}),[C,r,f,b,m]),T=S.exports.useMemo(()=>v.length===0?d("span",{children:"No bound variables found."}):null,[v]);return w("div",{className:"widget-list-container d-flex flex-column",children:[d("div",{className:"widget-list-header",children:d(gs,{value:l,placeholder:"Find Table, Plot or Widget",onChange:p,ref:h})}),w("ul",{className:"widget-list flex-grow-1",children:[T&&d("li",{className:"widget-list-message",children:T}),!T&&v]}),d("div",{children:d("hr",{})}),w("div",{className:"widget-list-footer",children:[w(he,{kind:"ghost",onClick:e,children:[w("div",{className:"fa-md fa-layers",children:[d(z,{mask:vl,icon:dd,transform:"right-5 down-5"}),d(z,{icon:dd,transform:"right-8 down-6"})]}),"Export Layout"]}),w(he,{kind:"ghost",onClick:n,children:[w("div",{className:"fa-md fa-layers",children:[d(z,{mask:vl,icon:Sl,transform:"right-5 down-5"}),d(z,{icon:Sl,transform:"right-8 down-6"})]}),"Import Layout"]}),d(he,{kind:"ghost",icon:_i,onClick:s,tooltip:"Reset Layout"})]})]})},QE=async(t,e,n)=>{let s,i,o,r;if(Lr(e)?(s=e.settings,i=e.table,o="",r=e.tableSettings):(s={},i="",o=e.figure,r={}),n&&(n.tableSettings&&(r=n.tableSettings),n.table&&(i=n.table),n.figure&&(o=n.figure),n.settings&&(s={...s,...n.settings})),o){const c={title:o,name:o,type:N.VariableType.FIGURE},h=await t.getObject(c);return Ki.makeModel(s,h)}const a={title:o,name:i,type:N.VariableType.TABLE},l=await t.getObject(a);return te.applyTableSettings(l,r,Sa(Ta.getState())),Ki.makeModelFromSettings(s,l)},ZE=async(t,e,n=N.VariableType.TABLE)=>{const{table:s}=e,i={title:s,name:s,type:n},o=await t.getObject(i);return xc.makeModel(o)};const JE=({onAutoFillClick:t=()=>{}})=>w("div",{className:"empty-dashboard-container",children:[w("div",{className:"hint-container",children:[d(z,{icon:Vg})," ",d("br",{}),"Use the panel list to add objects from a query."]}),w("div",{className:"empty-dashboard",children:[d("div",{className:"add-panels-hint",children:"Drag Panels Here"}),d(he,{kind:"tertiary",onClick:t,children:"Auto fill objects"})]})]});function e1(t){return t.version===2}function t1(t){return Array.isArray(t)}const Nr=X.module("UserLayoutUtils"),n1={layoutConfig:[{type:"column",content:[{type:"row",content:[{type:"stack",content:[{type:"react-component",component:Oi.COMPONENT,title:Oi.TITLE,isClosable:!1},{type:"react-component",component:Jr.COMPONENT,title:Jr.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:jr.COMPONENT,title:jr.TITLE,isClosable:!1},{type:"react-component",component:Qr.COMPONENT,title:Qr.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},s1={layoutConfig:[],links:[],filterSets:[],version:2};function Sp(t){if(e1(t))return t;if(t1(t))return{layoutConfig:t,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${t}`)}async function i1(t,e=!0){try{const n=await t.getLayouts();if(n.length>0)try{const s=await t.getLayout(n[0]);return Sp(s)}catch(s){Nr.error("Unable to load layout",n[0],":",s),Nr.warn("No valid layouts found, falling back to default layout")}}catch(n){Nr.error("Unable to fetch layout list",n),Nr.warn("Falling back to default layout")}return e?n1:s1}function o1(t){const{filterSets:e,layoutConfig:n,links:s}=t;return{filterSets:e,layoutConfig:n,links:s,version:2}}const Pr={exportLayout:o1,getDefaultLayout:i1,normalizeLayout:Sp},Mr=X.module("DownloadServiceWorkerUtils"),wp=class{static registerOnLoaded(){new URL("/ide/",window.location.href).origin===window.location.origin&&("serviceWorker"in navigator?window.addEventListener("load",()=>{const e=new URL("/ide/download/serviceWorker.js",window.location.href);navigator.serviceWorker.register(e).then(n=>{n.update(),Mr.info("Registering service worker on ",e,n)}).catch(n=>{Mr.error("Failed to register service worker",n)})}):Mr.info("Service worker is not supported."))}static async getServiceWorker(){if("serviceWorker"in navigator){const e=(await navigator.serviceWorker.getRegistrations()).find(n=>n.scope.endsWith(wp.DOWNLOAD_PATH));if(e&&e.active)return Mr.info("Download service worker is active."),e.active;throw new Error("Can not find download service worker.")}throw new Error("Download service worker is not available.")}static unregisterSW(){}};let ta=wp;ta.DOWNLOAD_PATH="/download/";const vp={react:Y},r1=Up(vp),a1=Bp({requires:r1}),l1=$p.createRequires(vp),c1=Wp({requires:l1}),d1=X.module("PluginUtils");class Ul{static loadComponentPlugin(e){if("".split(",").includes(e)){const o=Y.lazy(()=>jp(()=>import(`./internal/${e}`),[])),r=Y.forwardRef((a,l)=>d(S.exports.Suspense,{fallback:d("div",{children:"Loading Plugin..."}),children:d(o,{ref:l,...a})}));return r.pluginName=e,r.displayName="Local Plugin",r}const n=new URL("/ide/plugins/",`${window.location}`),s=new URL(`${e}.js`,n),i=Y.forwardRef((o,r)=>d(a1,{url:s,render:({err:a,Component:l})=>{if(a){const c=`Error loading plugin ${e} from ${s} due to ${a}`;return d1.error(c),d("div",{className:"error-message",children:`${c}`})}return d(l,{ref:r,...o})}}));return i.pluginName=e,i.displayName="Plugin",i}static async loadModulePlugin(e){return await c1(e)}static async loadJson(e){return new Promise((n,s)=>{const i=new XMLHttpRequest;i.addEventListener("load",()=>{try{const o=JSON.parse(i.responseText);n(o)}catch(o){s(o)}}),i.addEventListener("error",o=>{s(o)}),i.open("GET",e),i.send()})}}const Ot=X.module("AppMainContainer");class Lo extends S.exports.Component{constructor(e){super(e),this.getDashboardPlugins=Ce(n=>[...n.entries()].filter(([,{DashboardPlugin:s}])=>s).map(([s,{DashboardPlugin:i}])=>d(i,{},s))),this.handleSettingsMenuHide=this.handleSettingsMenuHide.bind(this),this.handleSettingsMenuShow=this.handleSettingsMenuShow.bind(this),this.handleError=this.handleError.bind(this),this.handleControlSelect=this.handleControlSelect.bind(this),this.handleToolSelect=this.handleToolSelect.bind(this),this.handleClearFilter=this.handleClearFilter.bind(this),this.handleDataChange=this.handleDataChange.bind(this),this.handleAutoFillClick=this.handleAutoFillClick.bind(this),this.handleGoldenLayoutChange=this.handleGoldenLayoutChange.bind(this),this.handleLayoutConfigChange=this.handleLayoutConfigChange.bind(this),this.handleExportLayoutClick=this.handleExportLayoutClick.bind(this),this.handleImportLayoutClick=this.handleImportLayoutClick.bind(this),this.handleImportLayoutFiles=this.handleImportLayoutFiles.bind(this),this.handleLoadTablePlugin=this.handleLoadTablePlugin.bind(this),this.handleResetLayoutClick=this.handleResetLayoutClick.bind(this),this.handleWidgetMenuClick=this.handleWidgetMenuClick.bind(this),this.handleWidgetsMenuClose=this.handleWidgetsMenuClose.bind(this),this.handleWidgetSelect=this.handleWidgetSelect.bind(this),this.handlePaste=this.handlePaste.bind(this),this.hydrateChart=this.hydrateChart.bind(this),this.hydrateGrid=this.hydrateGrid.bind(this),this.hydratePandas=this.hydratePandas.bind(this),this.hydrateDefault=this.hydrateDefault.bind(this),this.openNotebookFromURL=this.openNotebookFromURL.bind(this),this.importElement=Y.createRef(),this.state={contextActions:[{action:()=>{this.handleToolSelect(mn.LINKER)},shortcut:Os.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:hn.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{Ot.debug("Consume unhandled save shortcut")},shortcut:Os.SAVE,isGlobal:!0}],isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,n){return Rl.hydrate({...e,unzip:s=>Vh.loadAsync(s).then(i=>Object.values(i.files))},n)}componentDidMount(){this.initWidgets(),window.addEventListener("beforeunload",Lo.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:n}=this.props;e.dashboardData!==n&&this.handleDataChange(n)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",Lo.handleWindowBeforeUnload)}initWidgets(){const{connection:e}=this.props;if(!e.subscribeToFieldUpdates){Ot.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(n=>{Ot.debug("Got updates",n),this.setState(({widgets:s})=>{const{updated:i,created:o,removed:r}=n,a=[...i,...r],l=s.filter(h=>!a.some(u=>u.name===h.name));return[...i,...o].forEach(h=>{h.name&&l.push(h)}),{widgets:l}})})}deinitWidgets(){var e;(e=this.widgetListenerRemover)==null||e.call(this)}openNotebookFromURL(){const{match:e}=this.props,{notebookPath:n}=e.params;if(n){const{session:s,sessionConfig:i}=this.props;if(!s||!i){Ot.error("No session available to open notebook URL",n);return}const o={id:`/${n}`,itemName:`/${n}`},r=i.type,a={value:null,language:r};this.emitLayoutEvent(Be.SELECT_NOTEBOOK,s,r,a,o,!0)}}sendClearFilter(){this.emitLayoutEvent(Ue.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...n){var s;(s=this.goldenLayout)==null||s.eventHub.emit(e,...n)}handleError(e){De.isCanceled(e)||Ot.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,n=null){switch(Ot.debug("handleControlSelect",e),e){case wn.DROPDOWN_FILTER:this.emitLayoutEvent(Ue.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:n});break;case wn.INPUT_FILTER:this.emitLayoutEvent(Ue.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:n});break;case wn.MARKDOWN:this.emitLayoutEvent(jm.OPEN,{title:"Markdown",type:e,dragEvent:n});break;case wn.FILTER_SET_MANAGER:this.emitLayoutEvent(Ue.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:n});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){Ot.debug("handleToolSelect",e);const{activeTool:n,setActiveTool:s}=this.props;s(n===e?mn.DEFAULT:e)}handleClearFilter(){this.sendClearFilter()}handleDataChange(e){const{updateWorkspaceData:n}=this.props,{closed:s,filterSets:i,links:o}=e;n({closed:s,filterSets:i,links:o})}handleGoldenLayoutChange(e){this.goldenLayout=e}handleLayoutConfigChange(e){const{updateWorkspaceData:n}=this.props;n({layoutConfig:e})}handleWidgetMenuClick(){this.setState(({isPanelsMenuShown:e})=>({isPanelsMenuShown:!e}))}handleWidgetSelect(e,n){this.setState({isPanelsMenuShown:!1}),Ot.debug("handleWidgetSelect",e,n),this.openWidget(e,n)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;Ot.debug("handleAutoFillClick",e);const n=e.sort((s,i)=>s.title!=null&&i.title!=null?s.title.localeCompare(i.title):0);for(let s=0;s<n.length;s+=1)this.openWidget(n[s])}handleExportLayoutClick(){Ot.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:n}=e,s=Pr.exportLayout(n);Ot.info("handleExportLayoutClick exportedConfig",s);const i=new Blob([JSON.stringify(s)],{type:"application/json"}),o=N.i18n.DateTimeFormat.format("yyyy-MM-dd-HHmmss",new Date),r=document.createElement("a");r.href=URL.createObjectURL(i),r.download=`deephaven-app-layout-${o}.json`,r.click()}catch(e){Ot.error("Unable to export layout",e)}}handleImportLayoutClick(){Ot.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){Ot.info("handleResetLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.resetLayout()}handleImportLayoutFiles(e){var n;e.stopPropagation(),e.preventDefault(),e.target.files!=null&&this.importLayoutFile((n=e.target.files)==null?void 0:n[0])}async importLayoutFile(e){try{const{updateDashboardData:n,updateWorkspaceData:s}=this.props,i=await e.text(),o=JSON.parse(i),{filterSets:r,layoutConfig:a,links:l}=Pr.normalizeLayout(o);s({layoutConfig:a}),n(Dn,{filterSets:r,links:l})}catch(n){Ot.error("Unable to import layout",n)}}async resetLayout(){const{layoutStorage:e,session:n}=this.props,{filterSets:s,layoutConfig:i,links:o}=await Pr.getDefaultLayout(e,n!==void 0),{updateDashboardData:r,updateWorkspaceData:a}=this.props;a({layoutConfig:i}),r(Dn,{filterSets:s,links:o})}handlePaste(e){let n=e.currentTarget.parentElement;for(;n!=null;){if(n.classList.contains("monaco-editor"))return;n=n.parentElement}const{clipboardData:s}=e,i=s.getData("Text"),o=/“|”/g;o.test(i)&&(e.preventDefault(),e.stopPropagation(),document.execCommand("insertText",!1,i.replace(o,'"')))}handleLoadTablePlugin(e){const{plugins:n}=this.props,s=n.get(e);return s!=null&&s.TablePlugin?s.TablePlugin:Ul.loadComponentPlugin(e)}hydrateDefault(e,n){const{connection:s}=this.props,{metadata:i}=e;if((i==null?void 0:i.type)&&((i==null?void 0:i.id)||(i==null?void 0:i.name))){const o=i.id?{type:i.type,id:i.id}:{type:i.type,name:i.name,title:i.name};return{fetch:()=>s.getObject(o),localDashboardId:n,...e}}return Rl.hydrate(e,n)}hydrateGrid(e,n){return this.hydrateTable(e,n,N.VariableType.TABLE)}hydratePandas(e,n){return this.hydrateTable(e,n,N.VariableType.PANDAS)}hydrateTable(e,n,s=N.VariableType.TABLE){const{connection:i}=this.props;return{...e,getDownloadWorker:ta.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:n,makeModel:()=>ZE(i,e.metadata,s)}}hydrateChart(e,n){const{connection:s}=this.props;return{...e,localDashboardId:n,makeModel:()=>{const{metadata:i,panelState:o}=e;return QE(s,i,o)}}}openWidget(e,n){const{connection:s}=this.props;this.emitLayoutEvent(Fe.OPEN,{dragEvent:n,fetch:()=>s.getObject(e),widget:e})}render(){const{activeTool:e,plugins:n,user:s,workspace:i}=this.props,{data:o}=i,{layoutConfig:r}=o,{permissions:a}=s,{canUsePanels:l}=a,{contextActions:c,isPanelsMenuShown:h,isSettingsMenuShown:u,widgets:m}=this.state,p=this.getDashboardPlugins(n);return w("div",{className:W("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[d("nav",{className:"nav-container",children:w("div",{className:"app-main-top-nav-menus",children:[d("img",{src:Cp,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),w("div",{children:[w("button",{type:"button",className:"btn btn-link btn-panels-menu",children:[d(z,{icon:_f}),"Controls",d(qc,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),l&&w("button",{type:"button",className:"btn btn-link btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,children:[d(z,{icon:Nf}),"Panels",d(xn,{isShown:h,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:d(jE,{widgets:m,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),w("button",{type:"button",className:W("btn btn-link btn-link-icon btn-settings-menu",{"text-warning":s.operateAs!==s.name}),onClick:this.handleSettingsMenuShow,children:[d(z,{icon:$o,transform:"grow-3 right-1 down-1"}),d(pe,{children:"User Settings"})]})]})]})}),w(Vw,{emptyDashboard:d(JE,{onAutoFillClick:this.handleAutoFillClick}),id:Dn,layoutConfig:r,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[d(CE,{hydrate:this.hydrateGrid,getDownloadWorker:ta.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),d(hE,{hydrate:this.hydrateChart}),d(uE,{}),d(pE,{hydrateConsole:Lo.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),d(gE,{}),d(yE,{hydrate:this.hydratePandas}),d(EE,{}),d(TE,{}),p]}),d(gt,{in:u,timeout:It.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:d(Yo,{onDone:this.handleSettingsMenuHide})}),d(ie,{actions:c}),d("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles})]})}}const h1=t=>{var e,n;return{activeTool:wa(t),dashboardData:jt(t,Dn),layoutStorage:XE(t),plugins:Jb(t),connection:yT(t,Dn),session:(e=gi(t,Dn))==null?void 0:e.session,sessionConfig:(n=gi(t,Dn))==null?void 0:n.config,user:Ku(t),workspace:ba(t)}},u1=xt(h1,{setActiveTool:va,updateDashboardData:Yn,updateWorkspaceData:sm})(zp(Lo)),m1=()=>w("div",{className:"app",children:[d(u1,{}),d(ru,{})]});X.module("StorageTableViewportUpdater");class _h{static makeSortConfig(e,n){return{column:e,direction:n}}static makeFilterConfig(e){const n=[],s=[];return e.forEach((i,o)=>{n.push(i),o>0&&s.push(qt.and)}),{filterItems:n,filterOperators:s}}static combineFilterConfigs(e,n,s=qt.and){return{filterItems:[...e.filterItems,...n.filterItems],filterOperators:[...e.filterOperators,s,...n.filterOperators]}}static makeFilterItem(e,n,s){return{columnName:e,type:n,value:s}}}const pl=X.module("PouchStorageTable"),p1="Deephaven.";Uh.plugin(Gp);function g1(t,e){switch(t){case q.in:case q.contains:return{$regex:new RegExp(`${e}`)};case q.inIgnoreCase:return{$regex:new RegExp(`${e}`,"i")};case q.eq:return{$eq:e};case q.notEq:return{$neq:e};case q.greaterThan:return{$gt:e};case q.greaterThanOrEqualTo:return{$gte:e};case q.lessThan:return{$lt:e};case q.lessThanOrEqualTo:return{$lte:e};case q.startsWith:return{$regex:new RegExp(`^(?${e}).*`)};default:throw new Error(`Unsupported type: ${t}`)}}function f1(t){const{filterItems:e,filterOperators:n}=t;let s=null;for(let i=0;i<e.length;i+=1){const o=e[i],{columnName:r,type:a,value:l}=o,c={[r]:g1(a,l)};if(i===0)s=c;else if(s!==null&&i-1<n.length){const h=n[i-1];if(h===qt.and)s={$and:[s,c]};else if(h===qt.or)s={$or:[s,c]};else throw new Error(`Unexpected filter operator ${h}, ${c}`)}}if(s==null)throw new Error(`Invalid filter config ${t}`);return s}function gl(t=[]){return{$and:[...t.map(e=>f1(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function C1(t,e=!1){var n;return[{id:e?"desc":"asc"},...(n=t==null?void 0:t.map(s=>({[s.column]:s.direction})))!=null?n:[]]}class b1{constructor(e){this.listeners=[],this.itemListeners=new Map,this.currentSize=0,this.currentReverse=!1,this.currentFilter=null,this.currentSort=null,this.db=new Uh(`${p1}${e}`),this.db._remote=!1,this.db.changes({live:!0,since:"now",include_docs:!0}).on("change",this.dbUpdate.bind(this)),this.db.createIndex({index:{fields:["id","name"]}}),this.refreshInfo()}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(n=>n!==e)}}onItemUpdate(e,n){return this.itemListeners.has(e)||this.itemListeners.set(e,[]),this.itemListeners.set(e,[...this.itemListeners.get(e),n]),this.refreshItem(e),()=>{this.itemListeners.set(e,this.itemListeners.get(e).filter(s=>s!==n))}}close(){this.listeners=[]}get size(){return this.currentSize}get viewport(){return this.currentViewport}setReversed(e){this.currentReverse=e,this.currentViewportData=void 0,this.refreshData()}setViewport(e){this.currentViewport=e,this.refreshInfo(),this.refreshData()}setSorts(e){this.currentSort=e,this.currentViewportData=void 0,this.refreshData()}setFilters(e){this.currentFilter=e,this.currentViewportData=void 0,this.refreshInfo(),this.refreshData()}get data(){return this.currentViewportData}async getViewportData(){var e;return this.viewportUpdatePromise||this.refreshData(),(e=this.viewportUpdatePromise)!=null?e:Promise.resolve({items:[],offset:0})}async put(e){const n={...e,_id:e.id};return await this.db.put(n),n}sendUpdate(){var s;const{listeners:e}=this,n=(s=this.currentViewportData)!=null?s:{items:[],offset:0};for(let i=0;i<e.length;i+=1)e[i](n)}sendItemUpdate(e){const n=this.itemListeners.get(e.id);if(n!==void 0)for(let s=0;s<n.length;s+=1)n[s](e)}dbUpdate(e){pl.debug("Update received",e),this.refreshInfo(),e.doc!==void 0&&this.sendItemUpdate(e.doc),this.refreshData()}async refreshInfo(){var e,n;try{(e=this.infoUpdatePromise)==null||e.cancel(),this.infoUpdatePromise=De.makeCancelable(this.db.find({selector:gl((n=this.currentFilter)!=null?n:[]),fields:[]}));const s=await this.infoUpdatePromise;this.currentSize=s.docs.length,this.sendUpdate()}catch(s){if(!De.isCanceled(s))throw pl.error("Unable to refreshInfo",s),s}}async refreshData(){var e,n;if(!!this.currentViewport)try{const{currentViewport:s}=this,i=C1(this.currentSort,this.currentReverse);(e=this.viewportUpdatePromise)==null||e.cancel(),this.viewportUpdatePromise=De.makeCancelable(this.db.find({selector:gl((n=this.currentFilter)!=null?n:[]),skip:s.top,limit:s.bottom-s.top+1,sort:i,fields:["id","name"]}).then(r=>({items:r.docs,offset:s.top})));const o=await this.viewportUpdatePromise;return this.currentViewportData=o,this.sendUpdate(),o}catch(s){if(!De.isCanceled(s))throw pl.error("Unable to refreshData",s),s}}async refreshItem(e){const s=(await this.db.find({selector:{id:e},limit:1})).docs[0];return s!==void 0&&this.sendItemUpdate(s),s}async getSnapshot(e){const n=new Map,s=[{id:this.currentReverse?"desc":"asc"}];return await Promise.all(e.map(async([i,o])=>{var a;const r=o-i+1;return this.db.find({selector:gl((a=this.currentFilter)!=null?a:[]),skip:i,limit:r,sort:s,fields:["id","name"]}).then(l=>{for(let c=0;c<r;c+=1){const h=i+c;n.set(h,l.docs[c])}})})),n}}class Lh extends b1{constructor(e){super(`CommandHistoryStorage.${e}`)}setSearch(e){this.setFilters(e?[_h.makeFilterConfig([_h.makeFilterItem("name",q.contains,e)])]:[])}}const kh=X.module("PouchCommandHistoryStorage");class S1{constructor(){this.updateTableMap=new Map}getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new Lh(e)),this.updateTableMap.get(e)}async getTable(e){return new Lh(e)}async addItem(e,n,s,i){return this.updateItem(e,{id:`${new Date().getTime()}`,name:s,data:i})}async updateItem(e,n){const s=this.getUpdateTable(e),i=await s.refreshItem(n.id),o={...i!=null?i:{},...n};return kh.debug("Updating item",o),await s.put(o),kh.debug("Update saved"),n}listenItem(e,n,s){return this.getUpdateTable(e).onItemUpdate(n,s)}}const w1=X.module("LocalWorkspaceStorage"),Do=class{static async makeDefaultWorkspaceData(t,e){const{filterSets:n,links:s,layoutConfig:i}=await Pr.getDefaultLayout(t,e==null?void 0:e.isConsoleAvailable);return{settings:{defaultDateTimeFormat:ht.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:ht.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:We.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:mt.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(t,e){return{data:await Do.makeDefaultWorkspaceData(t,e)}}constructor(t){this.layoutStorage=t}async load(t){var e;try{return JSON.parse((e=localStorage.getItem(Do.STORAGE_KEY))!=null?e:"")}catch{return w1.info("Unable to load workspace data, initializing to default data"),Do.makeDefaultWorkspace(this.layoutStorage,t)}}async save(t){return localStorage.setItem(Do.STORAGE_KEY,JSON.stringify(t)),t}};let Tp=Do;Tp.STORAGE_KEY="deephaven.WorkspaceStorage";class v1 extends Error{constructor(){super(...arguments),this.isNoConsolesError=!0}}function T1(t){return t.isNoConsolesError}const Pi=X.module("SessionUtils");function E1(){return new URL("/jsapi",`${window.location}`)}function Ep(){const t=E1();return`${t.protocol}//${t.host}`}function y1(){const t=Ep();return Pi.info(`Starting connection to '${t}'...`),new N.IdeConnection(t)}async function I1(t){Pi.info("Getting console types...");const e=await t.getConsoleTypes();if(Pi.info("Available types:",e),e.length===0)throw new v1("No console types available");const n=e[0];Pi.info("Starting session with type",n);const s=await t.startSession(n),i={type:n,id:qe.generate()};return Pi.info("Console session established",i),{session:s,config:i,connection:t}}function R1(){const t=Ep();return Pi.info("createCoreClient",t),new N.CoreClient(t)}class D1{constructor(e,n=""){this.storageService=e,this.root=n}async getLayouts(){return(await this.storageService.listItems(this.root,"*.json")).map(n=>n.basename)}async getLayout(e){const s=await(await this.storageService.loadFile(`${this.root}/${e}`)).text();return JSON.parse(s)}}const fl=X.module("GrpcFileStorageTable");class Yc{constructor(e,n="",s=n){this.currentSize=0,this.listeners=[],this.childTables=new Map,this.storageService=e,this.baseRoot=n,this.root=s}removeBaseRoot(e){return de.removeRoot(this.baseRoot,e)}getViewportData(){var e;return this.viewportUpdatePromise||this.refreshInternal(),(e=this.viewportUpdatePromise)!=null?e:Promise.resolve({items:[],offset:0})}getSnapshot(e){throw new Error("Method not implemented.")}get size(){return this.currentSize}async setExpanded(e,n){const s=e.split("/");let i=s.shift();if(i||(i=s.shift()),!i)throw new Error(`Invalid path: ${e}`);const o=s.join("/");if(n){if(!this.childTables.has(i)){const r=new Yc(this.storageService,this.baseRoot,`${this.root}/${i}`);this.childTables.set(i,r)}if(o){const r=this.childTables.get(i);r==null||r.setExpanded(o,n)}}else if(this.childTables.has(i))if(o){const r=this.childTables.get(i);r==null||r.setExpanded(o,n)}else this.childTables.delete(i);this.currentViewport&&await this.refreshInternal()}async collapseAll(){this.childTables.clear(),this.currentViewport&&await this.refreshInternal()}setSearch(e){throw new Error("Method not implemented.")}setViewport(e){this.currentViewport=e,this.refreshInternal()}setFilters(){throw new Error("Method not implemented.")}setSorts(){throw new Error("Method not implemented.")}setReversed(){throw new Error("Method not implemented.")}close(){this.listeners=[]}onUpdate(e){return this.listeners=[...this.listeners,e],()=>{this.listeners=this.listeners.filter(n=>n!==e)}}async refresh(){var n;fl.debug2(this.root,"refreshData"),(n=this.viewportUpdatePromise)==null||n.cancel(),this.viewportUpdatePromise=De.makeCancelable(this.fetchData());const e=await this.viewportUpdatePromise;return this.currentViewportData=e,this.sendUpdate(),e}async refreshInternal(){try{await this.refresh()}catch(e){De.isCanceled(e)||fl.error("Unable to refresh data",e)}}async fetchData(){const{currentViewport:e}=this;if(!e)throw new Error("No viewport set");let s=(await this.storageService.listItems(this.root)).map(i=>({type:i.type,filename:this.removeBaseRoot(i.filename),basename:i.basename,id:this.removeBaseRoot(i.filename),isExpanded:i.type==="directory"?this.childTables.has(i.basename):void 0})).sort((i,o)=>i.type!==o.type?i.type==="directory"?-1:1:i.basename.localeCompare(o.basename));for(let i=0;i<s.length;i+=1){const o=s[i],{basename:r,filename:a}=o;if(a===this.removeBaseRoot(`${this.root}/${r}`)&&o.type==="directory"){const l=this.childTables.get(r);if(l!=null){l.setViewport({top:0,bottom:e.bottom-i});const c=await l.getViewportData();s.splice(i+1,0,...c.items)}}}return this.currentSize=s.length,fl.debug2(this.root,"items",s,e),s=s.slice(e.top,e.bottom),{items:s,offset:e.top}}sendUpdate(){var s;const{listeners:e}=this,n=(s=this.currentViewportData)!=null?s:{items:[],offset:0};for(let i=0;i<e.length;i+=1)e[i](n)}}const N1=X.module("GrpcFileStorage"),yp=class{constructor(t,e=""){this.tables=[],this.refreshTables=hi(()=>{this.tables.every(n=>n.refresh().catch(()=>{}))},yp.REFRESH_THROTTLE),this.storageService=t,this.root=e}removeRoot(t){return de.removeRoot(this.root,t)}addRoot(t){return de.addRoot(this.root,t)}async createDirectory(t){return await this.storageService.createDirectory(this.addRoot(t)),this.refreshTables(),{type:"directory",id:t,filename:t,basename:de.getBaseName(t)}}async getTable(){const t=new Yc(this.storageService,this.root);return this.tables.push(t),t}async saveFile(t){const e=dh.storage.FileContents.text(t.content);return await this.storageService.saveFile(this.addRoot(t.filename),e,!0),this.refreshTables(),t}async loadFile(t){const n=await(await this.storageService.loadFile(this.addRoot(t))).text();return{filename:t,basename:de.getBaseName(t),content:n}}async deleteFile(t){await this.storageService.deleteItem(this.addRoot(t)),this.refreshTables()}async moveFile(t,e){await this.storageService.moveItem(this.addRoot(t),this.addRoot(e)),this.refreshTables()}async info(t){const e=await this.storageService.listItems(this.addRoot(de.getPath(t)),de.getBaseName(t));if(e.length===0)throw new Uc;if(e.length>1)throw N1.error("More than one matching file found, should never happen.",e),new Error("More than one matching file found");const n=e[0];return{filename:this.removeRoot(n.filename),basename:this.removeRoot(n.basename),id:this.removeRoot(n.filename),type:n.type}}};let Ip=yp;Ip.REFRESH_THROTTLE=150;const Hi=X.module("AppInit");async function M1(){Hi.debug("Loading plugins...");try{const t=await Ul.loadJson("/js-plugins/manifest.json");Hi.debug("Plugin manifest loaded:",t);const e=[];for(let i=0;i<t.plugins.length;i+=1){const{name:o,main:r}=t.plugins[i],a=`/js-plugins/${o}/${r}`;e.push(Ul.loadModulePlugin(a))}const n=await Promise.all(e),s=new Map;for(let i=0;i<n.length;i+=1){const{name:o}=t.plugins[i];s.set(o,n[i])}return Hi.info("Plugins loaded:",s),s}catch(t){return Hi.error("Unable to load plugins:",t),new Map}}async function F1(t){let e;try{e=await I1(t)}catch(n){if(!T1(n))throw n}return e}const Xc=t=>{const{workspace:e,setActiveTool:n,setCommandHistoryStorage:s,setDashboardData:i,setFileStorage:o,setLayoutStorage:r,setDashboardConnection:a,setDashboardSessionWrapper:l,setPlugins:c,setUser:h,setWorkspace:u,setWorkspaceStorage:m}=t,[p,g]=S.exports.useState(),[f,b]=S.exports.useState(!0),C=S.exports.useCallback(async()=>{var I,D;try{const M=await M1(),x=y1(),B=await F1(x);x.addEventListener(N.IdeConnection.HACK_CONNECTION_FAILURE,Z=>{var be;const{detail:ge}=Z;Hi.error("Connection failure",ge),g(`Unable to connect: ${(be=ge.details)!=null?be:"Unknown Error"}`)});const $="user",k={name:$,operateAs:$,groups:[],permissions:{isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:!0,canDownloadCsv:!0}},H=R1();await H.login({type:N.CoreClient.LOGIN_TYPE_ANONYMOUS});const A=H.getStorageService(),F=new D1(A,"/layouts"),_=new Ip(A,"/notebooks"),L=new Tp(F),V=new S1,G=await L.load({isConsoleAvailable:B!==void 0}),{data:j}=G,{settings:ne}=j;ne.defaultDecimalFormatOptions===void 0&&(ne.defaultDecimalFormatOptions={defaultFormatString:We.DEFAULT_FORMAT_STRING}),ne.defaultIntegerFormatOptions===void 0&&(ne.defaultIntegerFormatOptions={defaultFormatString:mt.DEFAULT_FORMAT_STRING}),ne.truncateNumbersWithPound===void 0&&(ne.truncateNumbersWithPound=!1);const{shortcutOverrides:ye={}}=ne,Te=Kt.isMacPlatform?(I=ye.mac)!=null?I:{}:(D=ye.windows)!=null?D:{};Object.entries(Te).forEach(([Z,ge])=>{var be;(be=ze.get(Z))==null||be.setKeyState(ge)});const He={filterSets:j.filterSets,links:j.links};n(mn.DEFAULT),s(V),i(Dn,He),o(_),r(F),a(Dn,x),B!==void 0&&l(Dn,B),c(M),h(k),m(L),u(G)}catch(M){Hi.error(M),g(M)}},[n,s,i,o,r,a,l,c,h,u,m]),v=S.exports.useCallback(()=>{document.fonts?document.fonts.ready.then(()=>{b(!1)}):b(!1)},[]);S.exports.useEffect(function(){C(),v()},[C,v]);const T=!e&&!p||f,y=!T&&!p,E=p?`${p}`:null;return w(ue,{children:[y&&d(m1,{}),d(ha,{isLoading:T,isLoaded:y,errorMessage:E}),w("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:[d("p",{className:"fira-sans-regular",children:"preload"}),d("p",{className:"fira-sans-semibold",children:"preload"}),d("p",{className:"fira-mono",children:"preload"})]})]})};Xc.propTypes={workspace:R.exports.shape({}),workspaceStorage:R.exports.shape({close:R.exports.func}),setActiveTool:R.exports.func.isRequired,setCommandHistoryStorage:R.exports.func.isRequired,setDashboardData:R.exports.func.isRequired,setFileStorage:R.exports.func.isRequired,setLayoutStorage:R.exports.func.isRequired,setDashboardConnection:R.exports.func.isRequired,setDashboardSessionWrapper:R.exports.func.isRequired,setPlugins:R.exports.func.isRequired,setUser:R.exports.func.isRequired,setWorkspace:R.exports.func.isRequired,setWorkspaceStorage:R.exports.func.isRequired};Xc.defaultProps={workspace:null,workspaceStorage:null};const x1=t=>({workspace:ba(t),workspaceStorage:zb(t)}),Oh=xt(x1,{setActiveTool:va,setCommandHistoryStorage:nS,setDashboardData:Em,setFileStorage:sS,setLayoutStorage:xE,setDashboardConnection:IT,setDashboardSessionWrapper:RT,setPlugins:oS,setUser:eS,setWorkspace:nm,setWorkspaceStorage:tS})(Xc),_1=()=>d(Kp,{basename:"/ide/",children:w(qp,{children:[d(rd,{exact:!0,path:"/",component:Oh}),d(rd,{path:"/notebook/:notebookPath+",component:Oh}),d(Yp,{from:"*",to:"/"})]})});Boolean(window.location.hostname==="localhost"||window.location.hostname==="[::1]"||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/));function L1(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}$E();di.render(d(Ph,{store:Ta,children:d(_1,{})}),document.getElementById("root"));L1();ta.registerOnLoaded();dt.init();window["__react-beautiful-dnd-disable-dev-warnings"]=!0;
43
+ //# sourceMappingURL=index.9df8e28a.js.map