@deephaven/code-studio 0.20.1-beta.2 → 0.20.1-beta.5
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.
|
@@ -14,7 +14,7 @@ ${o}`);for(let r=0;r<t;r+=1){const l=this.type.shouldTrim?e[i][r].trim():e[i][r]
|
|
|
14
14
|
${e}`):s.setValue(`${e}`);const o=s.getLineCount(),r=s.getLineLength(o)+1;this.editor.setPosition({lineNumber:o,column:r}),n&&this.editor.focus()}updateDimensions(){mn.debug("updateDimensions"),this.editor&&this.editor.layout()}focus(){mn.debug("focus"),this.editor&&this.editor.focus()}toggleFind(){this.editorComponent.current&&this.editorComponent.current.toggleFind()}setLanguage(e){this.editorComponent.current&&e!==void 0&&this.editorComponent.current.setLanguage(e)}render(){const{error:e,isLoaded:n,isLoading:s,session:i,sessionLanguage:o,settings:r}=this.props,{model:l}=this.state,a=e?`Unable to open document. ${e}`:null,d=r?r.language:null,c=l&&i&&d===o;return v(he,{children:[(e||s)&&h("div",{className:"h-100 w-100 position-relative",children:h(ml,{errorMessage:a,isLoading:s,isLoaded:n})}),n&&h("div",{className:"h-100 w-100 script-editor",children:r&&v(he,{children:[h(bl,{ref:this.editorComponent,settings:r,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy}),c!=null&&c&&h(Vu,{model:l,language:d,session:i})]})})]})}}Ku.defaultProps={error:null,isLoading:!1,isLoaded:!1,focusOnMount:!0,onChange:()=>{},session:null,sessionLanguage:null,settings:null};const yb={groovy:"Groovy",python:"Python",scala:"Scala"};class zc{static normalizeScriptLanguage(e){return yb[e]||null}static getDisabledRunTooltip(e,n,s,i){return e?n?null:`${s} doesn't match the session language \u2013 ${i} disabled`:`Console session not connected \u2013 ${i} disabled`}}const Ib=250,Rb=2500,qu=class extends S.exports.Component{constructor(t){super(t),this.loadData=Xe(()=>{const{commandHistoryStorage:e,item:n,language:s}=this.props,{id:i}=n;this.cleanup=e.listenItem(s,i,this.handleUpdate,this.handleError)},Ib),this.getPreviewText=Te(e=>e.split(`
|
|
15
15
|
`,Rb).join(`
|
|
16
16
|
`),{max:1}),this.handleUpdate=this.handleUpdate.bind(this),this.handleError=this.handleError.bind(this),this.handleTimeout=this.handleTimeout.bind(this),this.state={currentTime:Date.now()}}static getTimeString(t,e){if(t==null||e===""||e===0)return null;const n=Math.round((new Date(e).valueOf()-new Date(t).valueOf())/1e3);return n<1?"<1s":In.formatElapsedTime(n)}componentDidMount(){this.loadData()}componentDidUpdate(t,e){var s;const{data:n}=this.state;this.timer==null&&!(n!=null&&n.result)&&Boolean(n==null?void 0:n.startTime)&&!(n==null||n.endTime===void 0)?this.startTimer():((n==null?void 0:n.result)&&!((s=e.data)!=null&&s.result)||Boolean(n==null?void 0:n.endTime)&&!(e.data==null||e.data.endTime===void 0))&&this.stopTimer()}componentWillUnmount(){this.loadData.cancel(),this.cleanup!=null&&this.cleanup(),this.stopTimer()}startTimer(){this.stopTimer(),this.timer=setInterval(this.handleTimeout,1e3)}stopTimer(){this.timer&&(clearInterval(this.timer),this.timer=void 0)}updateTime(){this.setState({currentTime:Date.now()})}handleError(t){this.setState({error:`${t}`})}handleUpdate(t){const{data:e}=t!=null?t:{};this.setState({data:e});const{onUpdate:n}=this.props;n==null||n(e)}handleTimeout(){this.updateTime()}render(){var m;const{item:{name:t},language:e}=this.props,{currentTime:n,data:s,error:i}=this.state,{result:o,startTime:r,endTime:l}=s!=null?s:{},a=(m=o==null?void 0:o.error)!=null?m:i,d=qu.getTimeString(r,l!=null?l:n),c=this.getPreviewText(t),u=Boolean(d);return v("div",{className:"command-history-item-tooltip",children:[v("div",{className:"scroll-container",children:[h(Cl,{language:e,children:c}),c.length<t.length&&h("p",{children:"Preview Truncated..."})]}),v("div",{className:"result-info",children:[v("div",{className:"d-flex justify-content-between",children:[Boolean(a)&&v("div",{className:"text-danger mr-1",children:[h(q,{icon:cs})," Executed with errors"]}),v("div",{className:"time-wrapper",children:["Elapsed time:"," ",u?h("span",{className:"time-string",children:d}):h(_n,{})]})]}),Boolean(a)&&h("div",{className:"error-message",children:a})]})]})}};let Yu=qu;Yu.defaultProps={onUpdate:()=>{}};const Db=512,Xu=t=>{const{item:e,language:n,isSelected:s,commandHistoryStorage:i}=t,o=e.name.substring(0,Db),r=S.exports.useRef(null),l=S.exports.useCallback(()=>{var a;(a=r.current)==null||a.update()},[r]);return v("div",{className:z("command-history-item",{selected:s}),children:[o,h(Ie,{ref:r,interactive:!0,options:{placement:"left",modifiers:{preventOverflow:{enabled:!0,boundariesElement:"viewport",order:825}}},popperClassName:"command-history-item-popper",children:h(Yu,{item:e,language:n,onUpdate:l,commandHistoryStorage:i})})]})};Xu.defaultProps={isSelected:!1};class Kr extends S.exports.Component{static itemKey(e,n){return`${n.title}`}static renderContent(e){return e.selectionRequired!==void 0&&e.selectionRequired?v("div",{className:"fa-md fa-layers",children:[h(q,{icon:Fo,mask:e.icon,transform:"right-5 down-5 shrink-4"}),h(q,{icon:Zg,transform:"shrink-3 right-7 down-6"})]}):h(q,{icon:e.icon})}render(){const{actions:e,hasSelection:n}=this.props;return h("div",{className:"command-history-actions",children:e.map((s,i)=>h(Q,{kind:"inline",className:z(s.className),onClick:s.action,tooltip:s.description,disabled:s.selectionRequired!==void 0&&s.selectionRequired&&!n,icon:Kr.renderContent(s)},Kr.itemKey(i,s)))})}}const Mb=150,Wc=3,Gc=X.module("CommandHistoryViewportUpdater");function Nb({table:t,columns:e,top:n=0,bottom:s=0,search:i,isReversed:o=!1,onUpdate:r}){const l=S.exports.useMemo(()=>ui(a=>{const d=a.bottom-a.top,c=Math.max(0,a.top-d*Wc),u=a.bottom+d*Wc;t.setViewport({top:c,bottom:u,columns:a.columns})},Mb),[t]);return S.exports.useEffect(function(){const d=t.onUpdate(c=>{var u,m;r({items:(u=c.items)!=null?u:[],offset:(m=c.offset)!=null?m:0})});return()=>{Gc.debug("onUpdate cleanup"),d()}},[t,r]),S.exports.useEffect(function(){t.setSearch(i!=null?i:"")},[t,i]),S.exports.useEffect(function(){l({top:n,bottom:s,columns:e})},[l,n,s,e,i,o]),S.exports.useEffect(()=>()=>{Gc.debug2("Cancel throttledUpdateViewport"),l.cancel()},[l]),null}const bs=X.module("CommandHistory"),ss=class extends S.exports.Component{constructor(t){super(t),this.copySelectedCommands=this.copySelectedCommands.bind(this),this.createNotebook=this.createNotebook.bind(this),this.sendToConsole=this.sendToConsole.bind(this),this.renderItem=this.renderItem.bind(this),this.runInConsole=this.runInConsole.bind(this),this.sendToNotebook=this.sendToNotebook.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleSelectionChange=this.handleSelectionChange.bind(this),this.handleSearchChange=this.handleSearchChange.bind(this),this.handleViewportChange=this.handleViewportChange.bind(this),this.handleViewportUpdate=this.handleViewportUpdate.bind(this),this.itemActions=[{title:"Copy Selection",description:"Copy selected commands to clipboard",icon:df,shortcut:ks.COPY,action:this.copySelectedCommands,group:ie.groups.edit},{title:"Send to Console",description:"Open selected commands in the console",icon:wc,shortcut:Nn.COMMAND_HISTORY.SEND_TO_CONSOLE,action:this.sendToConsole,group:ss.menuGroups.send,order:10},{title:"Run in Console",description:"Run selected commands in the console",icon:Br,shortcut:Nn.COMMAND_HISTORY.RUN,action:this.runInConsole,group:ss.menuGroups.send,order:10},{title:"Send to Active Notebook",description:"Open selected commands in a notebook",icon:Sc,shortcut:Nn.COMMAND_HISTORY.SEND_TO_NOTEBOOK,action:this.sendToNotebook,group:ss.menuGroups.send,order:20},{title:"Send to New Notebook",description:"Open selected commands in a new notebook",icon:iu,action:this.createNotebook,group:ss.menuGroups.send,order:30}],this.historyActions=[{title:"Send to Console",icon:wc,selectionRequired:!0,description:"Open selected commands in the console",action:this.sendToConsole},{title:"Send to Notebook",icon:Sc,selectionRequired:!0,description:"Open selected commands in a notebook",action:this.sendToNotebook}],this.pending=new ps,this.searchInputRef=Y.createRef();const{table:e}=t;this.state={actions:[],historyActions:this.historyActions,top:0,bottom:0,itemCount:e.size,items:[],offset:0,selectedRanges:[],searchText:""}}static getCommandsFromViewport(t,e,n){const s=[];for(let i=0;i<n.length;i+=1){const o=n[i];for(let r=o[0];r<=o[1];r+=1)if(r>=e&&r<e+t.length){const{name:l}=t[r-e];s.push(l)}}return s}static async getCommandsFromSnapshot(t,e){return[...(await t.getSnapshot(e)).values()].map(s=>s.name)}componentWillUnmount(){this.pending.cancel()}async getSelectedCommands(){const{items:t,offset:e,selectedRanges:n}=this.state,s=n.slice().sort((o,r)=>o[0]-r[0]);if(s.length===0)return[];if(s[0][0]>=e&&s[s.length-1][1]<e+t.length)return ss.getCommandsFromViewport(t,e,s);const{table:i}=this.props;return this.pending.add(ss.getCommandsFromSnapshot(i,s))}getSelectedCommandText(){return this.getSelectedCommands().then(t=>t.join(`
|
|
17
|
-
`))}updateActions(){this.setState(t=>{const{selectedRanges:e}=t,n=e.reduce((s,i)=>s+i[1]-i[0]+1,0);return n>0&&n<ss.MAX_SELECTION_COUNT?(bs.debug("Updating actions",this.itemActions),{actions:this.itemActions}):(bs.debug("Disabling actions",n),{actions:[]})})}copySelectedCommands(){this.getSelectedCommandText().then(Ne.copyToClipboard).catch(bs.error)}createNotebook(){this.getSelectedCommandText().then(t=>{const{language:e,sendToNotebook:n}=this.props;n({value:t,language:e},!0)}).catch(bs.error)}sendToNotebook(){this.getSelectedCommandText().then(t=>{const{language:e,sendToNotebook:n}=this.props;n({value:t,language:e})}).catch(bs.error)}sendToConsole(){const{sendToConsole:t}=this.props;this.getSelectedCommandText().then(t).catch(bs.error)}runInConsole(){this.getSelectedCommandText().then(t=>{const{sendToConsole:e}=this.props;e(t,!0,!0)}).catch(bs.error)}handleSelect(t){const{sendToConsole:e}=this.props,{items:n,offset:s}=this.state;if(t<s||t>=s+n.length){bs.error("Invalid index!",t);return}const{name:i}=n[t-s];e(i)}handleSelectionChange(t){this.setState({selectedRanges:t}),this.updateActions()}handleViewportChange(t,e){this.setState({top:t,bottom:e})}handleSearchChange(t){this.setState({searchText:t.target.value,selectedRanges:[]})}handleViewportUpdate({items:t,offset:e}){const{table:n}=this.props,s=n.size;this.setState({items:t,itemCount:s,offset:e})}renderItem({item:t,itemIndex:e,isSelected:n}){const{language:s,commandHistoryStorage:i}=this.props;return h(Xu,{isSelected:n,item:t,language:s,commandHistoryStorage:i})}focus(){this.searchInputRef.current&&this.searchInputRef.current.focus()}render(){var m;const{language:t,table:e}=this.props,{actions:n,historyActions:s,searchText:i,top:o,bottom:r,items:l,itemCount:a,offset:d,selectedRanges:c}=this.state,u=(m=ku.LANGUAGE_MAP.get(t))!=null?m:"";return v("div",{className:"command-history",children:[v("div",{className:"command-history-search-bar",children:[h(gs,{ref:this.searchInputRef,value:i,placeholder:`${u} Command History`,onChange:this.handleSearchChange}),h(Kr,{actions:s,hasSelection:c.length>0})]}),v("div",{className:"command-history-list",children:[h(bn,{itemCount:a,items:l,offset:d,selectedRanges:c,onSelect:this.handleSelect,onSelectionChange:this.handleSelectionChange,onViewportChange:this.handleViewportChange,renderItem:this.renderItem,rowHeight:ss.ITEM_HEIGHT,isDoubleClickSelect:!0,isMultiSelect:!0,isStickyBottom:!0}),h(Nb,{table:e,top:o,bottom:r,search:i,onUpdate:this.handleViewportUpdate}),h(ie,{actions:n})]})]})}};let Sl=ss;Sl.ITEM_HEIGHT=29;Sl.MAX_SELECTION_COUNT=1e4;Sl.menuGroups={send:ie.groups.medium+100};class Fb extends S.exports.PureComponent{constructor(e){super(e),this.handleSwitchClick=this.handleSwitchClick.bind(this)}handleSwitchClick(){const{logLevel:e,onClick:n}=this.props;n(e)}render(){const{logLevel:e,on:n}=this.props;return v("div",{className:z("log-level-menu-item",e),children:[h(Du,{on:n,onClick:this.handleSwitchClick}),e]})}}const Lt=class extends S.exports.PureComponent{constructor(t){super(t),this.handleClearClick=this.handleClearClick.bind(this),this.handleFlushTimeout=this.handleFlushTimeout.bind(this),this.handleLogMessage=this.handleLogMessage.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleResetClick=this.handleResetClick.bind(this),this.handleResize=this.handleResize.bind(this),this.handleToggleAllClick=this.handleToggleAllClick.bind(this),this.logLevelMenuItems={},this.editorContainer=null,this.bufferedMessages=[],this.messages=[],this.state={shownLogLevels:{}}}static getLogText(t){const e=new Date(t.micros/1e3);return`${Ui.formatTimestamp(e)} ${t.logLevel} ${t.message}`}componentDidMount(){this.resetLogLevels(),this.initMonaco(),this.startListening(),window.addEventListener("resize",this.handleResize)}componentDidUpdate(t,e){this.updateDimensions();const{shownLogLevels:n}=this.state;e.shownLogLevels!==n&&this.refreshLogText();const{session:s}=this.props;t.session!==s&&(this.stopListening(),this.startListening(),this.clearLogs())}componentWillUnmount(){this.stopFlushTimer(),this.stopListening(),this.destroyMonaco(),window.removeEventListener("resize",this.handleResize)}getMenuActions(t){const e=[];e.push({menuElement:h("div",{className:"log-level-menu-title",children:"Display Log Levels"}),group:1,order:10});for(let n=0;n<Lt.AllLogLevels.length;n+=1){const s=Lt.AllLogLevels[n],i=t[s]!=null?t[s]:!1;e.push({title:s,group:1,order:n+100,menuElement:h(Fb,{logLevel:s,on:i,onClick:this.handleMenuItemClick,ref:o=>{o!=null&&(this.logLevelMenuItems[s]=o)}})})}return e.push({group:1,order:1e3,menuElement:v("div",{className:"log-level-menu-controls",children:[h(Q,{kind:"ghost",className:"log-level-toggle-all",onClick:this.handleToggleAllClick,children:"Toggle All"}),h(Q,{kind:"ghost",onClick:this.handleResetClick,children:"Reset"})]})}),e}resetLogLevels(){const t={};for(let e=0;e<Lt.AllLogLevels.length;e+=1){const n=Lt.AllLogLevels[e],s=Lt.DefaultLogLevels.indexOf(n)>=0;t[n]=s}this.setState({shownLogLevels:t})}startListening(){const{session:t}=this.props;this.cancelListener=t.onLogMessage(this.handleLogMessage)}stopListening(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}initMonaco(){A(this.editorContainer),this.editor=ds.create(this.editorContainer,{copyWithSyntaxHighlighting:!1,fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"log",lineDecorationsWidth:0,lineNumbersMinChars:0,minimap:{enabled:!1},readOnly:!0,renderLineHighlight:"none",scrollBeyondLastLine:!1,value:"",wordWrap:"on"}),this.editor.addCommand(Bn.Escape,()=>{}),this.editor.addCommand(gn.Shift|Bn.Escape,()=>{}),this.editor.addCommand(Bn.Escape,()=>{var e,n;const t=(e=this.editor)==null?void 0:e.getPosition();A(t),(n=this.editor)==null||n.setPosition(t)},"findWidgetVisible && editorTextFocus"),this.editor.addCommand(gn.Shift|Bn.Escape,()=>{var e,n;const t=(e=this.editor)==null?void 0:e.getPosition();A(t),(n=this.editor)==null||n.setPosition(t)},"findWidgetVisible && editorTextFocus")}destroyMonaco(){this.editor&&(this.editor.dispose(),this.editor=void 0)}triggerFindWidget(){var t,e;(t=this.editor)==null||t.focus(),(e=this.editor)==null||e.trigger("keyboard","actions.find",void 0)}toggleAll(){const{shownLogLevels:t}=this.state;let e=!0;for(let n=0;n<Lt.AllLogLevels.length;n+=1){const s=Lt.AllLogLevels[n];if(!t[s]){e=!1;break}}if(e)this.setState({shownLogLevels:{}});else{const n={};for(let s=0;s<Lt.AllLogLevels.length;s+=1){const i=Lt.AllLogLevels[s];n[i]=!0}this.setState({shownLogLevels:n})}}toggleLogLevel(t){const{shownLogLevels:e}=this.state,n=e[t],s={};s[t]=!n,this.updateLogLevels(s)}updateLogLevels(t){let{shownLogLevels:e}=this.state;e={...e,...t},this.setState({shownLogLevels:e})}appendLogText(t){if(!this.editor)return;const e=this.editor.getModel();let n=e==null?void 0:e.getLineCount();A(n);let s=e==null?void 0:e.getLineLength(n);A(s);const i=this.isBottomVisible(),o=[];if(s>0&&(o.push({range:{startLineNumber:n,startColumn:s+1,endLineNumber:n,endColumn:s+1},text:`
|
|
17
|
+
`))}updateActions(){this.setState(t=>{const{selectedRanges:e}=t,n=e.reduce((s,i)=>s+i[1]-i[0]+1,0);return n>0&&n<ss.MAX_SELECTION_COUNT?(bs.debug("Updating actions",this.itemActions),{actions:this.itemActions}):(bs.debug("Disabling actions",n),{actions:[]})})}copySelectedCommands(){this.getSelectedCommandText().then(Ne.copyToClipboard).catch(bs.error)}createNotebook(){this.getSelectedCommandText().then(t=>{const{language:e,sendToNotebook:n}=this.props;n({value:t,language:e},!0)}).catch(bs.error)}sendToNotebook(){this.getSelectedCommandText().then(t=>{const{language:e,sendToNotebook:n}=this.props;n({value:t,language:e})}).catch(bs.error)}sendToConsole(){const{sendToConsole:t}=this.props;this.getSelectedCommandText().then(t).catch(bs.error)}runInConsole(){this.getSelectedCommandText().then(t=>{const{sendToConsole:e}=this.props;e(t,!0,!0)}).catch(bs.error)}handleSelect(t){const{sendToConsole:e}=this.props,{items:n,offset:s}=this.state;if(t<s||t>=s+n.length){bs.error("Invalid index!",t);return}const{name:i}=n[t-s];e(i)}handleSelectionChange(t){this.setState({selectedRanges:t}),this.updateActions()}handleViewportChange(t,e){this.setState({top:t,bottom:e})}handleSearchChange(t){this.setState({searchText:t.target.value,selectedRanges:[]})}handleViewportUpdate({items:t,offset:e}){const{table:n}=this.props,s=n.size;this.setState({items:t,itemCount:s,offset:e})}renderItem({item:t,itemIndex:e,isSelected:n}){const{language:s,commandHistoryStorage:i}=this.props;return h(Xu,{isSelected:n,item:t,language:s,commandHistoryStorage:i})}focus(){this.searchInputRef.current&&this.searchInputRef.current.focus()}render(){var m;const{language:t,table:e}=this.props,{actions:n,historyActions:s,searchText:i,top:o,bottom:r,items:l,itemCount:a,offset:d,selectedRanges:c}=this.state,u=(m=ku.LANGUAGE_MAP.get(t))!=null?m:"";return v("div",{className:"command-history",children:[v("div",{className:"command-history-search-bar",children:[h(gs,{ref:this.searchInputRef,value:i,placeholder:`${u} Command History`,onChange:this.handleSearchChange}),h(Kr,{actions:s,hasSelection:c.length>0})]}),v("div",{className:"command-history-list",children:[h(bn,{itemCount:a,items:l,offset:d,selectedRanges:c,onSelect:this.handleSelect,onSelectionChange:this.handleSelectionChange,onViewportChange:this.handleViewportChange,renderItem:this.renderItem,rowHeight:ss.ITEM_HEIGHT,isDoubleClickSelect:!0,isMultiSelect:!0,isStickyBottom:!0}),h(Nb,{table:e,top:o,bottom:r,search:i,onUpdate:this.handleViewportUpdate}),h(ie,{actions:n})]})]})}};let Sl=ss;Sl.ITEM_HEIGHT=29;Sl.MAX_SELECTION_COUNT=1e4;Sl.menuGroups={send:ie.groups.medium+100};class Fb extends S.exports.PureComponent{constructor(e){super(e),this.handleSwitchClick=this.handleSwitchClick.bind(this)}handleSwitchClick(){const{logLevel:e,onClick:n}=this.props;n(e)}render(){const{logLevel:e,on:n}=this.props;return v("div",{className:z("log-level-menu-item",e),children:[h(Du,{on:n,onClick:this.handleSwitchClick}),e]})}}const Lt=class extends S.exports.PureComponent{constructor(t){super(t),this.handleClearClick=this.handleClearClick.bind(this),this.handleFlushTimeout=this.handleFlushTimeout.bind(this),this.handleLogMessage=this.handleLogMessage.bind(this),this.handleMenuItemClick=this.handleMenuItemClick.bind(this),this.handleResetClick=this.handleResetClick.bind(this),this.handleResize=this.handleResize.bind(this),this.handleToggleAllClick=this.handleToggleAllClick.bind(this),this.logLevelMenuItems={},this.editorContainer=null,this.bufferedMessages=[],this.messages=[],this.state={shownLogLevels:{}}}static getLogText(t){const e=new Date(t.micros/1e3);return`${Ui.formatTimestamp(e)} ${t.logLevel} ${t.message}`}componentDidMount(){this.resetLogLevels(),this.initMonaco(),this.startListening(),window.addEventListener("resize",this.handleResize)}componentDidUpdate(t,e){this.updateDimensions();const{shownLogLevels:n}=this.state;e.shownLogLevels!==n&&this.refreshLogText();const{session:s}=this.props;t.session!==s&&(this.stopListening(),this.startListening(),this.clearLogs())}componentWillUnmount(){this.stopFlushTimer(),this.stopListening(),this.destroyMonaco(),window.removeEventListener("resize",this.handleResize)}getMenuActions(t){const e=[];e.push({menuElement:h("div",{className:"log-level-menu-title",children:"Display Log Levels"}),group:1,order:10});for(let n=0;n<Lt.AllLogLevels.length;n+=1){const s=Lt.AllLogLevels[n],i=t[s]!=null?t[s]:!1;e.push({title:s,group:1,order:n+100,menuElement:h(Fb,{logLevel:s,on:i,onClick:this.handleMenuItemClick,ref:o=>{o!=null&&(this.logLevelMenuItems[s]=o)}})})}return e.push({group:1,order:1e3,menuElement:v("div",{className:"log-level-menu-controls",children:[h(Q,{kind:"ghost",className:"log-level-toggle-all",onClick:this.handleToggleAllClick,children:"Toggle All"}),h(Q,{kind:"ghost",onClick:this.handleResetClick,children:"Reset"})]})}),e}resetLogLevels(){const t={};for(let e=0;e<Lt.AllLogLevels.length;e+=1){const n=Lt.AllLogLevels[e],s=Lt.DefaultLogLevels.indexOf(n)>=0;t[n]=s}this.setState({shownLogLevels:t})}startListening(){const{session:t}=this.props;this.cancelListener=t.onLogMessage(this.handleLogMessage)}stopListening(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}initMonaco(){A(this.editorContainer),this.editor=ds.create(this.editorContainer,{copyWithSyntaxHighlighting:!1,fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:"log",lineDecorationsWidth:0,lineNumbers:"off",lineNumbersMinChars:0,minimap:{enabled:!1},readOnly:!0,renderLineHighlight:"none",scrollBeyondLastLine:!1,value:"",wordWrap:"on"}),this.editor.addCommand(Bn.Escape,()=>{}),this.editor.addCommand(gn.Shift|Bn.Escape,()=>{}),this.editor.addCommand(Bn.Escape,()=>{var e,n;const t=(e=this.editor)==null?void 0:e.getPosition();A(t),(n=this.editor)==null||n.setPosition(t)},"findWidgetVisible && editorTextFocus"),this.editor.addCommand(gn.Shift|Bn.Escape,()=>{var e,n;const t=(e=this.editor)==null?void 0:e.getPosition();A(t),(n=this.editor)==null||n.setPosition(t)},"findWidgetVisible && editorTextFocus")}destroyMonaco(){this.editor&&(this.editor.dispose(),this.editor=void 0)}triggerFindWidget(){var t,e;(t=this.editor)==null||t.focus(),(e=this.editor)==null||e.trigger("keyboard","actions.find",void 0)}toggleAll(){const{shownLogLevels:t}=this.state;let e=!0;for(let n=0;n<Lt.AllLogLevels.length;n+=1){const s=Lt.AllLogLevels[n];if(!t[s]){e=!1;break}}if(e)this.setState({shownLogLevels:{}});else{const n={};for(let s=0;s<Lt.AllLogLevels.length;s+=1){const i=Lt.AllLogLevels[s];n[i]=!0}this.setState({shownLogLevels:n})}}toggleLogLevel(t){const{shownLogLevels:e}=this.state,n=e[t],s={};s[t]=!n,this.updateLogLevels(s)}updateLogLevels(t){let{shownLogLevels:e}=this.state;e={...e,...t},this.setState({shownLogLevels:e})}appendLogText(t){if(!this.editor)return;const e=this.editor.getModel();let n=e==null?void 0:e.getLineCount();A(n);let s=e==null?void 0:e.getLineLength(n);A(s);const i=this.isBottomVisible(),o=[];if(s>0&&(o.push({range:{startLineNumber:n,startColumn:s+1,endLineNumber:n,endColumn:s+1},text:`
|
|
18
18
|
`,forceMoveMarkers:!0}),n+=1,s=0),o.push({range:{startLineNumber:n,startColumn:s,endLineNumber:n,endColumn:s},text:t,forceMoveMarkers:!0}),e==null||e.applyEdits(o),i){const r=e==null?void 0:e.getLineCount();A(r),this.editor.revealLine(r,1)}}refreshLogText(){var s;if(!this.editor)return;this.truncateLogIfNecessary();const{shownLogLevels:t}=this.state,e=this.isBottomVisible();let n="";for(let i=0;i<this.messages.length;i+=1){const o=this.messages[i];if(t[o.logLevel]){const r=Lt.getLogText(o);r.length>0&&(n+=r,r.charAt(r.length-1)!==`
|
|
19
19
|
`&&(n+=`
|
|
20
20
|
`))}}if(n=n.trimRight(),this.editor.setValue(n),e){const i=(s=this.editor.getModel())==null?void 0:s.getLineCount();A(i),this.editor.revealLine(i,1)}this.stopFlushTimer(),this.bufferedMessages=[]}truncateLogIfNecessary(){this.messages.length>Lt.maxLogSize&&(this.messages=this.messages.splice(this.messages.length-Lt.truncateSize))}scrollToBottom(){var e,n,s;if(!this.editor)return;const t=(s=(n=(e=this.editor)==null?void 0:e.getModel)==null?void 0:n.call(e))==null?void 0:s.getLineCount();A(t),this.editor.revealLine(t,1)}isBottomVisible(){if(!this.editor)return!0;const t=this.editor.getModel(),e=t==null?void 0:t.getLineCount();return A(e),this.isLineVisible(e)}isLineVisible(t){var n;const e=(n=this.editor)==null?void 0:n.getVisibleRanges();if(e==null||e.length===0)return!1;for(let s=0;s<e.length;s+=1){const i=e[s];if(i.startLineNumber<=t&&t<=i.endLineNumber)return!0}return!1}isLogItemVisible(t){const{shownLogLevels:e}=this.state;return e[t.logLevel]}flush(){let t="";for(let e=0;e<this.bufferedMessages.length;e+=1){const n=this.bufferedMessages[e],s=Lt.getLogText(n);t+=s,s.charAt(s.length-1)!==`
|
|
@@ -35,10 +35,10 @@ ${e}`):s.setValue(`${e}`);const o=s.getLineCount(),r=s.getLineLength(o)+1;this.e
|
|
|
35
35
|
`)}async valuesTable(t){let e=null;try{return e=await this.table.copy(),e.applyFilter([]),e.applySort([]),e.selectDistinct([t])}finally{e!=null&&e.close()}}isColumnMovable(t,e){if(t<0||t>=this.columnCount)return!1;if(e>0)return!0;const n=this.columns[t].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)||!n?!1:!this.isKeyColumn(t)}isKeyColumn(t){var e,n;return t<((n=(e=this.inputTable)==null?void 0:e.keyColumns.length)!=null?n:0)}isRowMovable(){return!1}isEditableRange(t){return this.inputTable!=null&&oe.isBounded(t)&&(this.isPendingRow(t.startRow)&&this.isPendingRow(t.endRow)||t.startColumn>=this.inputTable.keyColumns.length&&t.endColumn>=this.inputTable.keyColumns.length)&&t.startRow>=this.floatingTopRowCount&&t.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&t.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isDeletableRange(t){return this.inputTable!=null&&t.startRow!=null&&t.endRow!=null&&t.startRow>=this.floatingTopRowCount&&t.startRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount&&t.endRow<this.floatingTopRowCount+this.table.size+this.pendingRowCount}isEditableRanges(t){return t.every(e=>this.isEditableRange(e))}isDeletableRanges(t){return t.every(e=>this.isDeletableRange(e))}getTableAreaRange(){return new oe(null,this.floatingTopRowCount,null,this.floatingTopRowCount+this.table.size-1)}getPendingAreaRange(){return new oe(null,this.floatingTopRowCount+this.table.size,null,this.floatingTopRowCount+this.table.size+this.pendingNewRowCount-1)}async setValueForCell(t,e,n){return this.setValueForRanges([new oe(t,e,t,e)],n)}async setValueForRanges(t,e){var n;if(!this.isEditableRanges(t))throw new Error(`Uneditable ranges ${t}`);try{const s=new Set,i=[];oe.forEachCell(t,(d,c)=>{const u=this.columns[d];if(s.add(u),i[d]===void 0){const m=P.makeValue(u.type,e,this.formatter.timeZone);i[d]=m!=null?this.displayString(m,u.type,u.name):null}this.cachePendingValue(d,c,i[d])});const o=this.getPendingAreaRange(),r=t.map(d=>oe.intersection(o,d)).filter(d=>d!=null).map(d=>(A(d),oe.offset(d,0,-(this.floatingTopRowCount+this.table.size))));if(r.length>0){const d=new Map(this.pendingNewDataMap);oe.forEachCell(r,(c,u)=>{d.has(u)||d.set(u,{data:new Map});const m=this.columns[c],p=d.get(u);A(p);const{data:g}=p,f=new Map(g),b=P.makeValue(m.type,e,this.formatter.timeZone);b!=null?f.set(c,{value:b}):f.delete(c),f.size>0?d.set(u,{...p,data:f}):d.delete(u)}),this.pendingDataMap=d}this.dispatchEvent(new Ge(be.EVENT.UPDATED));const l=this.getTableAreaRange(),a=t.map(d=>oe.intersection(l,d)).filter(d=>d!=null);if(a.length>0){const c=(await this.snapshot(a.map(m=>{var p,g;return new oe(null,(p=m==null?void 0:m.startRow)!=null?p:null,null,(g=m==null?void 0:m.endRow)!=null?g:null)}))).map(m=>{const p={};for(let g=0;g<this.columns.length;g+=1)p[this.columns[g].name]=m[g];return s.forEach(g=>{p[g.name]=P.makeValue(g.type,e,this.formatter.timeZone)}),p}),u=await((n=this.inputTable)==null?void 0:n.addRows(c));et.debug("setValueForRanges(",t,",",e,") set tableRanges",a,"result",u)}oe.forEachCell(t,(d,c)=>{const u=i[d];A(u),this.cacheFormattedValue(d,c,u)})}catch(s){et.error("Unable to set ranges",t,e,s)}finally{oe.forEachCell(t,(s,i)=>{this.clearPendingValue(s,i)})}}async setValues(t=[]){var e;if(et.debug("setValues(",t,")"),!t.every(n=>{var s,i;return this.isEditableRange(oe.makeCell((s=n.column)!=null?s:n.x,(i=n.row)!=null?i:n.y))}))throw new Error(`Uneditable ranges ${t}`);try{const n=new Map(this.pendingNewDataMap);t.forEach(l=>{var f,b;const{text:a}=l,d=(f=l.column)!=null?f:l.x,c=(b=l.row)!=null?b:l.y,u=this.columns[d],m=P.makeValue(u.type,a,this.formatter.timeZone),p=m!=null?this.displayString(m,u.type,u.name):null;this.cachePendingValue(d,c,p);const g=this.pendingRow(c);if(g!=null){n.has(g)||n.set(g,{data:new Map});const C=n.get(g);A(C);const{data:w}=C,T=new Map(w);m!=null?T.set(d,{value:m}):T.delete(d),T.size>0?n.set(g,{...C,data:T}):n.delete(g)}}),this.pendingDataMap=n,this.dispatchEvent(new Ge(be.EVENT.UPDATED));const s=t.reduce((l,a)=>{var c,u;const d=(c=a.row)!=null?c:a.y;return l.has(d)||l.set(d,[]),(u=l.get(d))==null||u.push(a),l},new Map),i=oe.consolidate(t.map(l=>{var a,d;return oe.makeCell((a=l.column)!=null?a:l.x,(d=l.row)!=null?d:l.y)})),o=this.getTableAreaRange(),r=i.map(l=>oe.intersection(o,l)).filter(l=>l!=null);if(r.length>0){const a=(await this.snapshot(r.map(c=>(A(c),new oe(null,c.startRow,null,c.endRow))))).map((c,u)=>{let m=null,p=u;for(let b=0;b<r.length;b+=1){const C=r[b];A(C);const w=oe.rowCount([C]);if(p<w){A(C.startRow),m=C.startRow+p;break}p-=w}const g={};for(let b=0;b<this.columns.length;b+=1)g[this.columns[b].name]=c[b];A(m);const f=s.get(m);return f!=null&&f.forEach(b=>{var w;const C=this.columns[(w=b.column)!=null?w:b.x];g[C.name]=P.makeValue(C.type,b.text,this.formatter.timeZone)}),g});et.info("setValues setting tableRanges",r);const d=await((e=this.inputTable)==null?void 0:e.addRows(a));et.info("setValues set tableRanges",r,"SUCCESS",d)}t.forEach(l=>{var g,f;const{text:a}=l,d=(g=l.column)!=null?g:l.x,c=(f=l.row)!=null?f:l.y,u=this.columns[d],m=P.makeValue(u.type,a,this.formatter.timeZone),p=m!=null?this.displayString(m,u.type,u.name):null;this.cacheFormattedValue(d,c,p)})}finally{t.forEach(n=>{this.clearPendingValue(n.column,n.row)})}}async commitPending(){var t,e,n;if(this.pendingNewDataMap.size<=0)throw new Error("No pending changes to commit");try{this.isSaveInProgress=!0;const s=[];this.pendingNewDataMap.forEach(o=>{const r={};o.data.forEach(({value:l},a)=>{const d=this.columns[a];r[d.name]=l}),s.push(r)});const i=await((t=this.inputTable)==null?void 0:t.addRows(s));et.debug("commitPending()",this.pendingNewDataMap,"result",i),this.pendingNewDataMap=new Map,this.pendingNewDataErrors=new Map,this.pendingNewRowCount=Math.max(0,((n=(e=this.viewport)==null?void 0:e.bottom)!=null?n:0)-this.table.size),this.formattedStringData=[],this.dispatchEvent(new Ge(be.EVENT.PENDING_DATA_UPDATED))}finally{this.isSaveInProgress=!1}}editValueForCell(t,e){return this.textValueForCell(t,e)}async delete(t){if(!this.isDeletableRanges(t))throw new Error(`Undeletable ranges ${t}`);A(this.inputTable);const{keyColumns:e}=this.inputTable;if(e.length===0)throw new Error("No key columns to allow deletion");const n=this.getPendingAreaRange(),s=t.map(c=>oe.intersection(n,c)).filter(c=>c!=null).map(c=>(A(c),oe.offset(c,0,-(this.floatingTopRowCount+this.table.size))));if(s.length>0){const c=new Map(this.pendingNewDataMap);for(let u=0;u<s.length;u+=1){const m=s[u];A(m.startRow),A(m.endRow);for(let p=m.startRow;p<=m.endRow;p+=1)c.delete(p)}this.pendingNewDataMap=c,this.formattedStringData=[],this.dispatchEvent(new Ge(be.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ge(be.EVENT.UPDATED))}const i=this.getTableAreaRange(),o=t.map(c=>oe.intersection(i,c)).filter(c=>c!=null);if(o.length<=0)return;const[r,l]=await Promise.all([this.snapshot(o.map(c=>(A(c),new oe(0,c.startRow,e.length-1,c.endRow)))),this.table.copy()]),d=r.map(c=>{const u=[];for(let m=0;m<e.length;m+=1){const p=e[m],g=c[m],f=P.makeFilterRawValue(p.type,g),b=p.filter().eq(f);u.push(b)}return u.reduce((m,p)=>{var g;return(g=m==null?void 0:m.and(p))!=null?g:p})}).reduce((c,u)=>{var m;return(m=c==null?void 0:c.or(u))!=null?m:u});l.applyFilter([d]),l.close()}isValidForCell(t,e,n){try{const s=this.columns[t];return P.makeValue(s.type,n,this.formatter.timeZone),!0}catch{return!1}}};let Hd=Aa;Hd.ROW_BUFFER_PAGES=1;const Is=X.module("IrisGridTableModel"),ha=Object.freeze([]);class ap extends Hd{constructor(e,n=new hn,s=null){super(e,n,s),this.getMemoizedFrontColumns=ge(i=>i!=null?i:ha),this.getMemoizedBackColumns=ge(i=>i!=null?i:ha),this.getMemoizedFrozenColumns=ge((i,o)=>{var r;return(r=o!=null?o:i)!=null?r:ha}),this.getCachedFilterableColumnSet=ge(i=>new Set(i.map((o,r)=>r))),this.customColumnList=[],this.formatColumnList=[]}get isExportAvailable(){return this.table.freeze!=null}get isColumnStatisticsAvailable(){return this.table.getColumnStatistics!=null}get isValuesTableAvailable(){return this.table.selectDistinct!=null&&this.table.copy!=null}get isRollupAvailable(){return this.table.rollup!=null}get isSelectDistinctAvailable(){return this.table.selectDistinct!=null}get isCustomColumnsAvailable(){return this.table.applyCustomColumns!=null}get isFormatColumnsAvailable(){return this.table.applyCustomColumns!=null}get frontColumns(){var e;return this.getMemoizedFrontColumns((e=this.layoutHints)==null?void 0:e.frontColumns)}get backColumns(){var e;return this.getMemoizedBackColumns((e=this.layoutHints)==null?void 0:e.backColumns)}get frozenColumns(){var e;return this.getMemoizedFrozenColumns((e=this.layoutHints)==null?void 0:e.frozenColumns,this.userFrozenColumns)}get layoutHints(){return this.table.layoutHints}get floatingLeftColumnCount(){return this.frozenColumns.length}get description(){return this.table.description}get customColumns(){return this.customColumnList}set customColumns(e){if(Is.debug2("set customColumns",e,this.customColumnList,e===this.customColumnList),this.customColumnList.length===0&&e.length===0){Is.debug("Ignore empty initial customColumns"),this.customColumnList=e;return}if(this.customColumnList===e){Is.debug("Ignore same customColumns");return}this.closeSubscription(),this.customColumnList=e,this.table.applyCustomColumns([...e,...this.formatColumns]),this.applyViewport()}get formatColumns(){return this.formatColumnList}set formatColumns(e){if(Is.debug2("set formatColumns",e,this.formatColumnList,e===this.formatColumnList),this.formatColumnList.length===0&&e.length===0){Is.debug("Ignore empty initial formatColumns"),this.formatColumnList=e;return}if(this.formatColumnList===e){Is.debug("Ignore same formatColumns");return}this.closeSubscription(),this.formatColumnList=e,this.table.applyCustomColumns([...this.customColumns,...e]),this.applyViewport()}updateFrozenColumns(e){this.userFrozenColumns=e,this.dispatchEvent(new Ge(be.EVENT.TABLE_CHANGED,{detail:this.table}))}set totalsConfig(e){if(Is.debug("set totalsConfig",e),e!==this.totals){if(this.totals=e,this.formattedStringData=[],this.totalsTablePromise!=null&&this.totalsTablePromise.cancel(),this.setTotalsTable(null),e==null){this.dispatchEvent(new Ge(be.EVENT.UPDATED));return}this.totalsTablePromise=Ee.makeCancelable(this.table.getTotalsTable(e),n=>n.close()),this.totalsTablePromise.then(n=>{this.totalsTablePromise=null,this.setTotalsTable(n)}).catch(n=>{Ee.isCanceled(n)||(Is.error("Unable to set next totalsTable",n),this.totalsTablePromise=null,this.dispatchEvent(new Ge(be.EVENT.REQUEST_FAILED,{detail:n})))})}}get isFilterRequired(){return this.table.isUncoalesced}isFilterable(e){return this.getCachedFilterableColumnSet(this.columns).has(e)}async export(){return this.table.freeze()}columnStatistics(e){return this.table.getColumnStatistics(e)}isColumnMovable(e){const n=this.columns[e].name;return this.frontColumns.includes(n)||this.backColumns.includes(n)||this.frozenColumns.includes(n)?!1:!this.isKeyColumn(e)}isColumnFrozen(e){return this.frozenColumns.includes(this.columns[e].name)}async delete(e){var u;if(!this.isDeletableRanges(e))throw new Error(`Undeletable ranges ${e}`);A(this.inputTable);const{keyColumns:n}=this.inputTable;if(n.length===0)throw new Error("No key columns to allow deletion");const s=this.getPendingAreaRange(),i=e.map(m=>oe.intersection(s,m)).filter(m=>m!=null).map(m=>(A(m),oe.offset(m,0,-(this.floatingTopRowCount+this.table.size))));if(i.length>0){const m=new Map(super.pendingDataMap);for(let p=0;p<i.length;p+=1){const g=i[p];A(g.startRow),A(g.endRow);for(let f=g.startRow;f<=g.endRow;f+=1)m.delete(f)}super.pendingDataMap=m,this.formattedStringData=[],this.dispatchEvent(new Ge(be.EVENT.PENDING_DATA_UPDATED)),this.dispatchEvent(new Ge(be.EVENT.UPDATED))}const o=this.getTableAreaRange(),r=e.map(m=>oe.intersection(o,m)).filter(m=>m!=null);if(r.length<=0)return;const[l,a]=await Promise.all([this.snapshot(r.map(m=>(A(m),new oe(0,m.startRow,n.length-1,m.endRow)))),this.table.copy()]),c=l.map(m=>{const p=[];for(let g=0;g<n.length;g+=1){const f=n[g],b=m[g],C=P.makeFilterRawValue(f.type,b),w=f.filter().eq(C);p.push(w)}return p.reduce((g,f)=>{var b;return(b=g==null?void 0:g.and(f))!=null?b:f})}).reduce((m,p)=>{var g;return(g=m==null?void 0:m.or(p))!=null?g:p});a.applyFilter([c]),await((u=this.inputTable)==null?void 0:u.deleteTable(a)),a.close()}}class VT extends Hd{constructor(){super(...arguments),this.getCachedFilterableColumnSet=ge((e,n)=>new Set(((n==null?void 0:n.length)>0?n:e).map(s=>e.findIndex(i=>s.name===i.name))))}applyBufferedViewport(e,n,s){this.table.setViewport(e,n,s)}textForCell(e,n){const s=this.columns[e],i=this.row(n);if(i!=null&&s!=null&&!i.hasChildren&&s.constituentType!=null){const o=this.valueForCell(e,n);return this.displayString(o,s.constituentType,s.name)}return super.textForCell(e,n)}extractViewportRow(e,n){const{isExpanded:s,hasChildren:i,depth:o}=e;return{...super.extractViewportRow(e,n),isExpanded:s,hasChildren:i,depth:o}}async snapshot(e,n,s){var l,a,d,c;A(this.viewport),A(this.viewportData);const{columns:i}=this.viewport,o=[];n!=null&&n&&o.push(i.map(u=>u.name));const r=new oe(0,(l=this.viewportData)==null?void 0:l.offset,i.length,((a=this.viewportData)==null?void 0:a.offset)+((d=this.viewportData)==null?void 0:d.rows.length));for(let u=0;u<e.length;u+=1){const m=oe.intersection(r,e[u]);A(m),A(m.startRow),A(m.endRow);for(let p=m.startRow;p<=m.endRow;p+=1){const g=[],f=this.viewportData.rows[p-this.viewportData.offset];A(m.startColumn),A(m.endColumn);for(let b=m.startColumn;b<=m.endColumn;b+=1)A(s),g.push(s((c=f.data.get(b))==null?void 0:c.value,this.columns[b]));o.push(g)}}return o}get groupedColumns(){return[]}get hasExpandableRows(){return!0}get isChartBuilderAvailable(){return!1}get isSelectDistinctAvailable(){return!1}get isReversible(){return!1}isFilterable(e){return this.getCachedFilterableColumnSet(this.columns,this.groupedColumns).has(e)}isColumnMovable(e){return e>=this.groupedColumns.length}isRowExpandable(e){var s;const n=this.row(e);return(s=n==null?void 0:n.hasChildren)!=null?s:!1}isRowExpanded(e){var s;const n=this.row(e);return(s=n==null?void 0:n.isExpanded)!=null?s:!1}setRowExpanded(e,n){this.table.setExpanded(e,n)}depthForRow(e){var s;const n=this.row(e);return((s=n==null?void 0:n.depth)!=null?s:1)-1}}const Rs=X.module("IrisGridProxyModel");function ua(t,e,n){return P.isTreeTable(t)?new VT(t,e):new ap(t,e,n)}class UT extends be{constructor(e,n=new hn,s=null){super(),this.textForCell=(...o)=>this.model.textForCell(...o),this.truncationCharForCell=(...o)=>this.model.truncationCharForCell(...o),this.textAlignForCell=(...o)=>this.model.textAlignForCell(...o),this.colorForCell=(...o)=>this.model.colorForCell(...o),this.backgroundColorForCell=(...o)=>this.model.backgroundColorForCell(...o),this.textForColumnHeader=(...o)=>this.model.textForColumnHeader(...o),this.colorForColumnHeader=(...o)=>this.model.colorForColumnHeader(...o),this.textForRowHeader=(...o)=>this.model.textForRowHeader(...o),this.textForRowFooter=(...o)=>this.model.textForRowFooter(...o),this.isRowMovable=(...o)=>this.model.isRowMovable(...o),this.isColumnMovable=(...o)=>this.model.isColumnMovable(...o),this.isRowExpandable=(...o)=>gt(this.model)?this.model.isRowExpandable(...o):!1,this.isRowExpanded=(...o)=>gt(this.model)?this.model.isRowExpanded(...o):!1,this.setRowExpanded=(...o)=>{if(gt(this.model))return this.model.setRowExpanded(...o);throw Error("Function setRowExpanded does not exist on IrisGridTableModel")},this.depthForRow=(...o)=>gt(this.model)?this.model.depthForRow(...o):0,this.getColumnHeaderGroup=(...o)=>this.model.getColumnHeaderGroup(...o),this.getColumnHeaderParentGroup=(...o)=>this.model.getColumnHeaderParentGroup(...o),this.formatForCell=(...o)=>this.model.formatForCell(...o),this.valueForCell=(...o)=>this.model.valueForCell(...o),this.displayString=(...o)=>this.model.displayString(...o),this.isEditableRange=(...o)=>Ze(this.model)?this.model.isEditableRange(...o):!1,this.isFilterable=(...o)=>this.model.isFilterable(...o),this.setViewport=(o,r,l)=>this.model.setViewport(o,r,l),this.snapshot=(...o)=>this.model.snapshot(...o),this.textSnapshot=(...o)=>this.model.textSnapshot(...o),this.valuesTable=(...o)=>this.model.valuesTable(...o),this.editValueForCell=(...o)=>(Ze(this.model)&&this.model.editValueForCell(...o),""),this.setValueForCell=(...o)=>Ze(this.model)?this.model.setValueForCell(...o):Promise.reject(new Error("Model is not editable")),this.setValueForRanges=(...o)=>Ze(this.model)?this.model.setValueForRanges(...o):Promise.reject(new Error("Model is not editable")),this.setValues=(...o)=>Ze(this.model)?this.model.setValues(...o):Promise.resolve(),this.isValidForCell=(...o)=>Ze(this.model)?this.model.isValidForCell(...o):!1,this.delete=(...o)=>this.model.delete(...o),this.commitPending=(...o)=>this.model.commitPending(...o),this.handleModelEvent=this.handleModelEvent.bind(this);const i=ua(e,n,s);this.originalModel=i,this.model=i,this.modelPromise=null,this.rollup=null,this.selectDistinct=[]}close(){this.originalModel.close(),this.model!==this.originalModel&&this.model.close(),this.modelPromise!=null&&this.modelPromise.cancel()}handleModelEvent(e){Rs.debug2("handleModelEvent",e);const{detail:n,type:s}=e;this.dispatchEvent(new Ge(s,{detail:n}))}setModel(e){Rs.debug("setModel",e);const n=this.model;n!==this.originalModel&&n.close(),this.model=e,this.listenerCount>0&&this.addListeners(e),this.dispatchEvent(new Ge(be.EVENT.COLUMNS_CHANGED,{detail:e.columns})),oi(e)&&this.dispatchEvent(new Ge(be.EVENT.TABLE_CHANGED,{detail:e.table}))}setNextModel(e){Rs.debug2("setNextModel"),this.modelPromise&&this.modelPromise.cancel(),this.listenerCount>0&&this.removeListeners(this.model),this.modelPromise=Ee.makeCancelable(e,n=>n.close()),this.modelPromise.then(n=>{this.modelPromise=null,this.setModel(n)}).catch(n=>{if(Ee.isCanceled(n)){Rs.debug2("setNextModel cancelled");return}Rs.error("Unable to set next model",n),this.modelPromise=null,this.dispatchEvent(new Ge(be.EVENT.REQUEST_FAILED,{detail:n}))})}startListening(){super.startListening(),this.addListeners(this.model)}stopListening(){super.stopListening(),this.removeListeners(this.model)}addListeners(e){const n=Object.keys(be.EVENT);for(let s=0;s<n.length;s+=1)e.addEventListener(n[s],this.handleModelEvent)}removeListeners(e){const n=Object.keys(be.EVENT);for(let s=0;s<n.length;s+=1)e.removeEventListener(n[s],this.handleModelEvent)}get rowCount(){return this.model.rowCount}get columnCount(){return this.model.columnCount}get floatingTopRowCount(){return this.model.floatingTopRowCount}get floatingBottomRowCount(){return this.model.floatingBottomRowCount}get floatingLeftColumnCount(){return this.model.floatingLeftColumnCount}get floatingRightColumnCount(){return this.model.floatingRightColumnCount}isColumnFrozen(e){return this.model.isColumnFrozen(e)}get hasExpandableRows(){return gt(this.model)?this.model.hasExpandableRows:!1}get isExportAvailable(){return this.model.isExportAvailable}get isColumnStatisticsAvailable(){return this.model.isColumnStatisticsAvailable}get isValuesTableAvailable(){return this.model.isValuesTableAvailable}get isCustomColumnsAvailable(){return this.model.isCustomColumnsAvailable&&!(this.isSelectDistinctAvailable&&this.selectDistinctColumns.length>0)}get isFormatColumnsAvailable(){return this.model.isFormatColumnsAvailable}get isChartBuilderAvailable(){return this.model.isChartBuilderAvailable}get isRollupAvailable(){return(this.originalModel.isRollupAvailable||this.rollup!=null)&&this.selectDistinct.length===0}get isSelectDistinctAvailable(){return(this.originalModel.isSelectDistinctAvailable||this.selectDistinct.length>0)&&this.rollup==null}get isTotalsAvailable(){return this.model.isTotalsAvailable}get isReversible(){return this.model.isReversible}get columns(){return this.model.columns}get movedColumns(){return this.model.movedColumns}get movedRows(){return this.model.movedRows}get layoutHints(){return this.model.layoutHints}get frontColumns(){return this.model.frontColumns}get backColumns(){return this.model.backColumns}get frozenColumns(){return this.model.frozenColumns}get columnHeaderMaxDepth(){return this.model.columnHeaderMaxDepth}updateFrozenColumns(e){return this.model.updateFrozenColumns(e)}get originalColumns(){return this.originalModel.columns}get groupedColumns(){return this.model.groupedColumns}get description(){return this.model.description}get filter(){return this.model.filter}set filter(e){this.model.filter=e}get formatter(){return this.model.formatter}set formatter(e){this.model.formatter=e}get sort(){return this.model.sort}set sort(e){this.model.sort=e}get customColumns(){return this.model.customColumns}set customColumns(e){this.model.customColumns=e}get formatColumns(){return this.model.formatColumns}set formatColumns(e){this.model.formatColumns=e}get rollupConfig(){return this.rollup}set rollupConfig(e){if(Rs.debug("set rollupConfig",e),!this.isRollupAvailable)throw new Error("Rollup Rows are not available");if(ct(e,this.rollup))return;this.rollup=e;let n=Promise.resolve(this.originalModel);oi(this.originalModel)&&e!=null&&(n=this.originalModel.table.rollup(e).then(s=>ua(s,this.formatter))),this.setNextModel(n)}get selectDistinctColumns(){return this.selectDistinct}set selectDistinctColumns(e){if(Rs.debug("set selectDistinctColumns",e),!this.isSelectDistinctAvailable)throw new Error("Select distinct is not available");if(e===this.selectDistinctColumns||e.length===0&&this.selectDistinctColumns.length===0){Rs.debug("Ignore same selectDistinctColumns",e);return}this.selectDistinct=e;const n=e.map(i=>this.originalColumns.find(o=>o.name===i)).filter(i=>i!=null);let s=Promise.resolve(this.originalModel);oi(this.originalModel)&&n.length>0&&(s=this.originalModel.table.selectDistinct(n).then(i=>ua(i,this.formatter))),this.setNextModel(s)}get table(){if(oi(this.model))return this.model.table}get totalsConfig(){return this.model.totalsConfig}set totalsConfig(e){this.model.totalsConfig=e}get isFilterRequired(){return this.model.isFilterRequired}get isEditable(){return Ze(this.model)&&this.model.isEditable}export(){if(P.isTreeTable(this.model))throw new Error("TreeTable has no 'export' property");return this.model.export()}columnStatistics(e){if(P.isTreeTable(this.model))throw new Error("TreeTable has no 'columnStatistics' function");return this.model.columnStatistics(e)}get pendingDataMap(){return this.model.pendingDataMap}set pendingDataMap(e){this.model.pendingDataMap=e}get pendingRowCount(){return this.model.pendingRowCount}set pendingRowCount(e){this.model.pendingRowCount=e}get pendingDataErrors(){return this.model.pendingDataErrors}getColumnIndexByName(e){return this.model.getColumnIndexByName(e)}}class Vd{static async makeModel(e,n=new hn){let s=null;return!P.isTreeTable(e)&&e.hasInputTable&&(s=await e.inputTable()),new UT(e,n,s)}}class zi{}zi.OPEN="ChartEvent.OPEN";zi.CLOSE="ChartEvent.CLOSE";zi.COLUMN_SELECTED="ChartEvent.COLUMN_SELECTED";class ft{}ft.SESSION_OPENED="ConsoleEvent.SESSION_OPENED";ft.SESSION_CLOSED="ConsoleEvent.SESSION_CLOSED";ft.FOCUS_HISTORY="ConsoleEvent.FOCUS_HISTORY";ft.SEND_COMMAND="ConsoleEvent.SEND_COMMAND";ft.SETTINGS_CHANGED="ConsoleEvent.SETTINGS_CHANGED";class Pe{}Pe.TABLE_CHANGED="InputFilterEvent.TABLE_CHANGED";Pe.COLUMNS_CHANGED="InputFilterEvent.COLUMNS_CHANGED";Pe.FILTERS_CHANGED="InputFilterEvent.FILTERS_CHANGED";Pe.CLEAR_ALL_FILTERS="InputFilterEvent.CLEAR_ALL_FILTERS";Pe.COLUMN_SELECTED="InputFilterEvent.COLUMN_SELECTED";Pe.OPEN_DROPDOWN="InputFilterEvent.OPEN_DROPDOWN";Pe.OPEN_INPUT="InputFilterEvent.OPEN_INPUT";Pe.OPEN_FILTER_SET_MANAGER="InputFilterEvent.OPEN_FILTER_SET_MANAGER";class wt{}wt.OPEN_GRID="IrisGridEvent.OPEN_GRID";wt.CLOSE_GRID="IrisGridEvent.CLOSE_GRID";wt.DATA_SELECTED="IrisGridEvent.DATA_SELECTED";wt.COLUMN_SELECTED="IrisGridEvent.COLUMN_SELECTED";wt.STATE_CHANGED="IrisGridEvent.STATE_CHANGED";wt.CREATE_CHART="IrisGridevent.CREATE_CHART";const dp=Object.freeze({OPEN:"MarkdownEvent.OPEN"});class He{}He.CREATE_NOTEBOOK="NotebookEvent.createNotebook";He.SELECT_NOTEBOOK="NotebookEvent.selectNotebook";He.CLOSE_FILE="NotebookEvent.closeFile";He.RENAME="NotebookEvent.rename";He.RENAME_FILE="NotebookEvent.renameFile";He.REGISTER_FILE="NotebookEvent.registerFile";He.SEND_TO_NOTEBOOK="NotebookEvent.sendToNotebook";He.UNREGISTER_FILE="NotebookEvent.unregisterFile";class $n{}$n.focus="TabEvent.focus";$n.blur="TabEvent.blur";$n.openPQObject="TabEvent.openPQObject";$n.openControl="TabEvent.openControl";$n.reload="TabEvent.reload";$n.clearAllFilters="TabEvent.clearAllFilters";class cp extends S.exports.PureComponent{constructor(e){super(e),this.handleCloseTab=this.handleCloseTab.bind(this),this.handleCloseTabsRight=this.handleCloseTabsRight.bind(this),this.handleCloseTabsAll=this.handleCloseTabsAll.bind(this)}getAllTabs(){var n,s,i;const{glContainer:e}=this.props;return[...(i=(s=(n=e==null?void 0:e.tab)==null?void 0:n.header)==null?void 0:s.tabs)!=null?i:[]]}handleCloseTab(){const{glContainer:e}=this.props;e.close()}handleCloseTabsAll(){this.getAllTabs().forEach(n=>{var s;return(s=(n==null?void 0:n.contentItem).container)==null?void 0:s.close()})}handleCloseTabsRight(){var s,i,o,r,l,a,d;const{glContainer:e}=this.props,n=this.getAllTabs();for(let c=n.length-1;c>0&&((i=(s=n[c].contentItem)==null?void 0:s.config)==null?void 0:i.id)!==((l=(r=(o=e.tab)==null?void 0:o.contentItem)==null?void 0:r.config)==null?void 0:l.id);c-=1)(d=((a=n[c])==null?void 0:a.contentItem).container)==null||d.close()}canCloseTabsRight(){var i,o,r,l,a,d,c,u;const{glContainer:e}=this.props,n=this.getAllTabs();let s=!0;for(let m=n.length-1;m>0&&((o=(i=n[m].contentItem)==null?void 0:i.config)==null?void 0:o.id)!==((a=(l=(r=e.tab)==null?void 0:r.contentItem)==null?void 0:l.config)==null?void 0:a.id);m-=1)if(Boolean((u=(c=(d=n[m])==null?void 0:d.contentItem)==null?void 0:c.config)==null?void 0:u.isClosable)){s=!1;break}return s}canCloseAny(){var s,i,o;const e=this.getAllTabs();let n=!0;for(let r=e.length-1;r>0;r-=1)if(Boolean((o=(i=(s=e[r])==null?void 0:s.contentItem)==null?void 0:i.config)==null?void 0:o.isClosable)){n=!1;break}return n}render(){var o,r,l;const{additionalActions:e,glContainer:n}=this.props,s=[...e],i=(l=(r=(o=n.tab)==null?void 0:o.contentItem)==null?void 0:r.config)==null?void 0:l.isClosable;return s.push({title:"Close",order:10,group:ie.groups.low,action:this.handleCloseTab,disabled:i===void 0||!i}),s.push(()=>({title:"Close Tabs to Right",order:20,group:ie.groups.low,action:this.handleCloseTabsRight,disabled:this.canCloseTabsRight()})),s.push(()=>({title:"Close All",order:30,group:ie.groups.low,action:this.handleCloseTabsAll,disabled:this.canCloseAny()})),h(ie,{actions:s})}}cp.defaultProps={additionalActions:[]};class hp extends S.exports.PureComponent{constructor(e){super(e),this.handleRenameDialogOpened=this.handleRenameDialogOpened.bind(this),this.handleRenameInputChange=this.handleRenameInputChange.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.renameInputRef=Y.createRef();const{value:n}=e;this.state={value:n,valueWasValidated:!1}}componentDidUpdate(e){const{isShown:n}=e,{isShown:s}=this.props;s&&!n&&this.resetState()}resetState(){const{value:e}=this.props;this.setState({value:e,valueWasValidated:!1})}handleRenameDialogOpened(){var e,n;(n=(e=this.renameInputRef)==null?void 0:e.current)==null||n.focus()}handleRenameInputChange(e){this.setState({value:e.target.value})}handleRenameCancel(){const{onCancel:e}=this.props;e()}handleRenameSubmit(e){e.stopPropagation(),e.preventDefault();const{value:n}=this.state,s=n==null?void 0:n.trim();if(s!==void 0&&s!==""){const{onSubmit:i}=this.props;i(s)}else this.setState({value:s,valueWasValidated:!0})}renderRenameDialog(){const{isShared:e,isOwner:n,itemType:s}=this.props,{value:i,valueWasValidated:o}=this.state;return v("form",{className:z("p-3",{"was-validated":o}),onSubmit:this.handleRenameSubmit,noValidate:!0,role:"presentation",onMouseDown:r=>{r.stopPropagation()},onMouseUp:r=>{r.stopPropagation()},children:[v("div",{className:"form-group",children:[v("label",{htmlFor:`rename-dialog-${s}-input`,children:["Rename ",s]}),h("input",{type:"text",className:"form-control",id:`rename-dialog-${s}-input`,value:i!=null?i:void 0,ref:this.renameInputRef,onChange:this.handleRenameInputChange,required:!0}),v("div",{className:"invalid-feedback",children:[s," name cannot be empty"]}),(e||!n)&&v("div",{className:"pt-2",children:["Renaming this ",s," will rename for all users."]})]}),v("div",{className:"text-right",children:[h(Q,{kind:"secondary",className:"mr-2",onClick:this.handleRenameCancel,children:"Cancel"}),h(Q,{kind:"primary",type:"submit",children:"Rename"})]})]})}render(){const{isShown:e,onCancel:n}=this.props;return h(Fn,{isShown:e,onEntered:this.handleRenameDialogOpened,onExited:n,options:{placement:"bottom",modifiers:{preventOverflow:{boundariesElement:"viewport"}}},interactive:!0,closeOnBlur:!0,children:this.renderRenameDialog()})}}hp.defaultProps={isShared:!1,isOwner:!0,itemType:"Item",value:""};const BT=X.module("Panel");class Yn extends S.exports.PureComponent{constructor(e){super(e),this.getAdditionActions=ge((s,i,o)=>{const r=[];return i&&r.push(this.getCloneAction()),o&&r.push(this.getRenameAction()),[...r,...s]}),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.handleCopyPanel=this.handleCopyPanel.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleBlur=this.handleBlur.bind(this),this.handleHide=this.handleHide.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleBeforeShow=this.handleBeforeShow.bind(this),this.handleShow=this.handleShow.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRenameSubmit=this.handleRenameSubmit.bind(this),this.handleShowRenameDialog=this.handleShowRenameDialog.bind(this),this.handleTabClicked=this.handleTabClicked.bind(this),this.handleTab=this.handleTab.bind(this);const{glContainer:n}=this.props;this.state={title:te.getTitleFromContainer(n),showRenameDialog:!1}}componentDidMount(){const{componentPanel:e,glContainer:n,glEventHub:s}=this.props;n.on("resize",this.handleResize),n.on("show",this.handleBeforeShow),n.on("shown",this.handleShow),n.on("hide",this.handleHide),n.on("tab",this.handleTab),n.on("tabClicked",this.handleTabClicked),s.on(ft.SESSION_CLOSED,this.handleSessionClosed),s.on(ft.SESSION_OPENED,this.handleSessionOpened),s.on($n.focus,this.handleTabFocus),s.on($n.blur,this.handleTabBlur),s.on(Pe.CLEAR_ALL_FILTERS,this.handleClearAllFilters),s.emit(Me.MOUNT,e)}componentWillUnmount(){const{componentPanel:e,glContainer:n,glEventHub:s}=this.props;n.off("resize",this.handleResize),n.off("show",this.handleBeforeShow),n.off("shown",this.handleShow),n.off("hide",this.handleHide),n.off("tab",this.handleTab),n.off("tabClicked",this.handleTabClicked),s.off(ft.SESSION_CLOSED,this.handleSessionClosed),s.off(ft.SESSION_OPENED,this.handleSessionOpened),s.off($n.focus,this.handleTabFocus),s.off($n.blur,this.handleTabBlur),s.off(Pe.CLEAR_ALL_FILTERS,this.handleClearAllFilters),s.emit(Me.UNMOUNT,e)}handleTab(e){e!=null&&this.setState({title:te.getTitleFromTab(e)}),this.forceUpdate();const{onTab:n}=this.props;n(e)}handleTabClicked(...e){const{onTabClicked:n}=this.props;n(...e)}handleClearAllFilters(...e){const{onClearAllFilters:n}=this.props;n(...e)}handleFocus(e){const{componentPanel:n,glEventHub:s}=this.props;s.emit(Me.FOCUS,n);const{onFocus:i}=this.props;i(e)}handleBlur(e){const{onBlur:n}=this.props;n(e)}handleHide(...e){const{onHide:n}=this.props;n(...e)}handleResize(...e){const{onResize:n}=this.props;n(...e)}handleSessionClosed(e){const{onSessionClose:n}=this.props;n(e)}handleSessionOpened(e,n){const{onSessionOpen:s}=this.props;s(e,n)}handleBeforeShow(...e){const{onBeforeShow:n}=this.props;n(...e)}handleShow(...e){const{onShow:n}=this.props;n(...e)}handleTabBlur(...e){const{onTabBlur:n}=this.props;n(...e)}handleTabFocus(...e){const{onTabFocus:n}=this.props;n(...e)}handleRenameCancel(){this.setState({showRenameDialog:!1})}handleShowRenameDialog(){this.setState({showRenameDialog:!0})}handleRenameSubmit(e){const{glContainer:n}=this.props;this.setState({showRenameDialog:!1,title:e});const s=te.getRootFromContainer(n),i=te.getComponentConfigFromContainer(n);A(i),te.renameComponent(s,i,e)}handleCopyPanel(){const{glContainer:e,glEventHub:n}=this.props,s=te.getRootFromContainer(e),i=te.getComponentConfigFromContainer(e);if(i==null){BT.error("Could not get component config from container",e);return}const o=te.cloneComponent(s,i);o!==null&&n.emit(Me.CLONED,this,o)}getCloneAction(){return{title:"Copy Panel",order:10,group:ie.groups.high,action:this.handleCopyPanel}}getRenameAction(){return{title:"Rename",order:10,group:ie.groups.medium,action:this.handleShowRenameDialog}}render(){const{children:e,className:n,renderTabTooltip:s,glContainer:i,additionalActions:o,errorMessage:r,isLoaded:l,isLoading:a,isClonable:d,isRenamable:c}=this.props,{tab:u}=i,{showRenameDialog:m,title:p}=this.state;return v("div",{className:z("h-100 w-100 iris-panel",n),onFocusCapture:this.handleFocus,onBlurCapture:this.handleBlur,children:[e,h(ml,{errorMessage:r,isLoaded:l,isLoading:a}),u!=null&&hi.createPortal(v(he,{children:[h(cp,{glContainer:i,additionalActions:this.getAdditionActions(o,d,c)}),c&&h(hp,{isShown:m,value:p,itemType:"Panel",onCancel:this.handleRenameCancel,onSubmit:this.handleRenameSubmit}),s!=null&&h(Ie,{interactive:!0,options:{placement:"bottom"},popperClassName:"panel-tab-popper",children:s()})]}),u.element[0])]})}}Yn.defaultProps={className:"",onTab:()=>{},onTabClicked:()=>{},onClearAllFilters:()=>{},onFocus:()=>{},onBlur:()=>{},onHide:()=>{},onResize:()=>{},onSessionClose:()=>{},onSessionOpen:()=>{},onBeforeShow:()=>{},onShow:()=>{},onTabBlur:()=>{},onTabFocus:()=>{},renderTabTooltip:null,additionalActions:[],errorMessage:null,isLoading:!1,isLoaded:!0,isClonable:!1,isRenamable:!1};const $T=X.module("WidgetPanelTooltip"),_l=t=>{const{widgetType:e,widgetName:n,glContainer:s,description:i,children:o}=t,r=te.getTitleFromContainer(s),[l,a]=S.exports.useState(!1);return v("div",{className:"tab-tooltip-container",children:[v("div",{className:"row flex-nowrap align-items-start",children:[h("span",{className:"tab-tooltip-title",children:v("b",{children:[e," Name "]})}),h("span",{className:"tab-tooltip-name",children:n}),h(Q,{kind:"ghost",className:"tab-tooltip-copy",icon:l?nd:ed,onClick:()=>{Ne.copyToClipboard(n).then(()=>a(!0)).catch(d=>$T.error("Unable to column name",d))},tooltip:l?"Copied text":"Copy name"})]}),n!==r&&v("div",{className:"row",children:[h("span",{className:"tab-tooltip-title",children:h("b",{children:"Display Name"})}),h("span",{className:"tab-tooltip-name",children:r})]}),i&&h("div",{className:"row",children:h("span",{className:"tab-tooltip-description",children:i})}),o]})};_l.propTypes={glContainer:km.Container.isRequired,widgetType:R.exports.string,widgetName:R.exports.string,description:R.exports.string,children:R.exports.node};_l.defaultProps={widgetType:"",widgetName:"",description:null,children:null};class kl extends S.exports.PureComponent{constructor(e){super(e),this.getCachedRenderTabTooltip=ge((n,s,i,o,r)=>n?()=>h(_l,{glContainer:s,widgetType:i,widgetName:o,description:r}):null),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleCopyName=this.handleCopyName.bind(this),this.state={isClientDisconnected:!1,isPanelDisconnected:!1,isWidgetDisconnected:!1,isWaitingForReconnect:!1,isPanelInactive:!1}}handleCopyName(){const{widgetName:e}=this.props;Ne.copyToClipboard(e)}getErrorMessage(){const{errorMessage:e}=this.props,{isClientDisconnected:n,isPanelDisconnected:s,isWidgetDisconnected:i,isWaitingForReconnect:o}=this.state;if(e)return`${e}`;if(n&&s&&o)return`Disconnected from server.
|
|
36
36
|
Check your internet connection.`;if(n&&s)return"Disconnected from server.";if(s){const{widgetName:r,widgetType:l}=this.props;return`Variable "${r}" not set.
|
|
37
37
|
${l} does not exist yet.`}if(i){const{widgetName:r}=this.props;return`${r} is unavailable.`}}handleSessionClosed(...e){const{onSessionClose:n}=this.props;this.setState({isPanelDisconnected:!0,isWaitingForReconnect:!1}),n(...e)}handleSessionOpened(...e){const{onSessionOpen:n}=this.props;n(...e)}render(){const{children:e,className:n,componentPanel:s,isLoaded:i,isLoading:o,glContainer:r,glEventHub:l,isDisconnected:a,isClonable:d,isRenamable:c,showTabTooltip:u,renderTabTooltip:m,widgetType:p,widgetName:g,description:f,onClearAllFilters:b,onHide:C,onFocus:w,onBlur:T,onResize:E,onShow:y,onTabBlur:I,onTabFocus:D,onTabClicked:N}=this.props,{isPanelDisconnected:x,isWidgetDisconnected:U,isPanelInactive:$}=this.state,L=this.getErrorMessage(),H=m!=null?m:this.getCachedRenderTabTooltip(u,r,p,g,f),O=[{title:`Copy ${p} Name`,group:ie.groups.medium,order:20,action:this.handleCopyName}];return v(Yn,{className:z(n,{disconnected:x||U||a,inactive:$}),componentPanel:s,glContainer:r,glEventHub:l,onClearAllFilters:b,onHide:C,onFocus:w,onBlur:T,onResize:E,onShow:y,onSessionClose:this.handleSessionClosed,onSessionOpen:this.handleSessionOpened,onTabBlur:I,onTabFocus:D,onTabClicked:N,renderTabTooltip:H,errorMessage:L,isLoaded:i,isLoading:o,isClonable:d,isRenamable:c,additionalActions:O,children:[e,$&&h("div",{className:"fill-parent-absolute"})]})}}kl.defaultProps={className:"",errorMessage:null,isClonable:!0,isDisconnected:!1,isLoading:!1,isLoaded:!0,isRenamable:!0,showTabTooltip:!0,widgetName:"Widget",widgetType:"Widget",renderTabTooltip:null,description:"",onFocus:()=>{},onBlur:()=>{},onHide:()=>{},onClearAllFilters:()=>{},onResize:()=>{},onSessionClose:()=>{},onSessionOpen:()=>{},onShow:()=>{},onTabBlur:()=>{},onTabFocus:()=>{},onTabClicked:()=>{}};const cn=Object.freeze({DEFAULT:"DEFAULT",LINKER:"LINKER"}),zT="SET_SESSION_WRAPPER",WT=fi(zT,null),GT={sessionWrapper:WT},KT=new Map,Ll=Object.freeze([]),up=(t,e)=>{var n;return(n=qt(t,e).columns)!=null?n:Ll},qT=(t,e)=>{var n;return(n=qt(t,e).filterSets)!=null?n:Ll},Ud=(t,e)=>{var n;return(n=qt(t,e).filters)!=null?n:Ll},Bd=(t,e)=>{var n;return(n=qt(t,e).tableMap)!=null?n:KT},$d=(t,e)=>qt(t,e).isolatedLinkerPanelId,eo=(t,e)=>{var n;return(n=qt(t,e).links)!=null?n:Ll},zd=(t,e)=>qt(t,e).columnSelectionValidator,YT=(t,e)=>qt(t,e).connection,gi=(t,e)=>qt(t,e).sessionWrapper,XT=(t,e)=>n=>n(qn(t,{connection:e})),jT=(t,e)=>n=>n(qn(t,{sessionWrapper:e})),Wd=(t,e)=>n=>n(qn(t,{links:e})),QT=(t,e)=>(n,s)=>{const i=eo(s(),t),o=e.filter(r=>i.findIndex(l=>ct(l.start,r.start)&&ct(l.end,r.end))<0);return n(Wd(t,i.concat(o)))},ZT=(t,e)=>(n,s)=>{const o=eo(s(),t).filter(r=>!e.includes(r.id));return n(Wd(t,o))},mp=(t,e)=>n=>n(qn(t,{isolatedLinkerPanelId:e})),JT=(t,e)=>n=>n(qn(t,{columnSelectionValidator:e})),eE=(t,e)=>n=>n(qn(t,{consoleSettings:e})),tE=(t,e)=>n=>n(qn(t,{filterSets:e}));Object.entries(GT).map(([t,e])=>Xi.register(t,e));const pp=({columnMap:t,inputFilterMap:e,linkedColumnMap:n,onAdd:s,onOpenLinker:i,waitingFilterMap:o,waitingInputMap:r})=>{const l=S.exports.useMemo(()=>{const p=Array.from(r.keys()),g=p.find(C=>e.get(C)!=null),f=p.find(C=>n.get(C)!=null),b=tn.join(p.map(C=>`"${C}"`));return g!=null&&g&&f!=null&&f?`Use a filter control or linked table to set a value for ${b}`:g!=null&&g?`Set a filter control value for ${b}`:`Double click a row in a linked table to set a value for ${b}`},[e,n,r]),a=S.exports.useMemo(()=>Array.from(t.values()),[t]),d=S.exports.useCallback(p=>{p.stopPropagation(),p.preventDefault(),s(Array.from(o.values()))},[s,o]),c=S.exports.useCallback(p=>{p.stopPropagation(),p.preventDefault(),i()},[i]),u=o.size>0,m=!u&&r.size>0;return h("div",{className:"chart-panel-overlay chart-filter-overlay",children:v("div",{className:z("chart-panel-overlay-content chart-filter-overlay-content",{"chart-filter-waiting-filter":u},{"chart-filter-waiting-input":m}),children:[u&&v(he,{children:[h("div",{className:"info-message",children:"This plot requires a filter control to be added to the layout or a table link to be created on the following columns:"}),h("div",{className:"waiting-filter-list",children:a.map(p=>{const g=o.has(p.name),f=g?cs:sd;return v("div",{className:z("waiting-filter-item",{"is-invalid":g}),children:[h(q,{icon:f}),p.name]},p.name)})}),v("div",{children:[h(Vi,{onClick:d,className:"btn-primary",children:"Add Input Filters"}),h(Vi,{onClick:c,className:"btn-primary",children:"Open Linker Tool"})]})]}),m&&v(he,{children:[h("div",{className:"info-message",children:"Waiting for User Input"}),h("div",{className:"",children:l})]})]})})};pp.propTypes={columnMap:R.exports.instanceOf(Map).isRequired,inputFilterMap:R.exports.instanceOf(Map).isRequired,linkedColumnMap:R.exports.instanceOf(Map).isRequired,onAdd:R.exports.func.isRequired,onOpenLinker:R.exports.func.isRequired,waitingFilterMap:R.exports.instanceOf(Map).isRequired,waitingInputMap:R.exports.instanceOf(Map).isRequired};const _o=({columns:t,onColumnSelected:e,onMouseEnter:n,onMouseLeave:s})=>h("div",{className:"chart-panel-overlay chart-column-selector-overlay",children:h("div",{className:z("chart-panel-overlay-content"),children:v(he,{children:[h("div",{className:"info-message",children:"This plot requires a filter control to be added to the layout or a table link to be created on the following columns:"}),h("div",{className:"waiting-column-select-list",children:t.map(i=>h(gl,{className:z("btn-chart-column-selector",_o.makeButtonClassName(i.name)),onClick:()=>e(i.name),onMouseEnter:()=>{n&&n(i)},onMouseLeave:s,disabled:!i.isValid,isLinked:i.isActive,children:i.name},i.name))})]})})});_o.makeButtonClassName=t=>`btn-chart-column-selector-${t}`;_o.defaultProps={onMouseEnter:()=>{},onMouseLeave:()=>{}};const Jt=X.module("ChartPanel"),nE=150;function kr(t){return t.settings!==void 0}function sE(t){return t.inputFilters!=null}function iE(t){return t.panelState!=null}class Ol extends S.exports.Component{constructor(e){super(e),this.getWaitingInputMap=ge((r,l,a)=>{if(!r)return new Map;const d=new Map(l);return a.forEach((c,u)=>{d.delete(u)}),d}),this.getWaitingFilterMap=ge((r,l,a,d,c)=>{if(!r)return new Map;const u=new Map(l);return a.forEach((m,p)=>{u.delete(p)}),c.forEach((m,p)=>{u.delete(p)}),d.forEach((m,p)=>{u.delete(p)}),u}),this.getInputFilterColumnMap=ge((r,l)=>{const a=new Map;for(let d=0;d<l.length;d+=1){const c=l[d],{name:u,type:m}=c,p=r.get(u);p!=null&&p.type===m&&a.set(u,c)}return a}),this.getLinkedColumnMap=ge((r,l)=>{const a=new Map,d=te.getIdFromPanel(this);for(let c=0;c<l.length;c+=1){const u=l[c];let m=null;if(u.start!=null&&u.start.panelId===d&&r.has(u.start.columnName)?m=u.start.columnName:u.end&&u.end.panelId===d&&r.has(u.end.columnName)&&(m=u.end.columnName),m!=null&&r.has(m)){const p=r.get(m);A(p),a.set(m,p)}}return a}),this.getSelectorColumns=ge((r,l,a)=>Array.from(r.values()).map(d=>({name:d.name,type:d.type,isValid:a?a(this,d):!1,isActive:l.has(d.name)}))),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleColumnMouseEnter=this.handleColumnMouseEnter.bind(this),this.handleColumnMouseLeave=this.handleColumnMouseLeave.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleFilterAdd=this.handleFilterAdd.bind(this),this.handleHide=this.handleHide.bind(this),this.handleError=this.handleError.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSettingsChanged=this.handleSettingsChanged.bind(this),this.handleOpenLinker=this.handleOpenLinker.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSourceColumnChange=this.handleSourceColumnChange.bind(this),this.handleSourceFilterChange=this.handleSourceFilterChange.bind(this),this.handleSourceSortChange=this.handleSourceSortChange.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleUpdate=this.handleUpdate.bind(this),this.updateModelFromSource=Xe(this.updateModelFromSource.bind(this),nE),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.panelContainer=Y.createRef(),this.chart=Y.createRef(),this.pending=new ps;const{metadata:n,panelState:s}=e,{filterValueMap:i=[],settings:o={}}=s!=null?s:{};this.state={settings:o,error:void 0,isActive:!1,isDisconnected:!1,isLoading:!1,isLoaded:!1,isLinked:n!=null&&kr(n)&&n.settings&&n.settings.isLinked,filterMap:new Map(i),filterValueMap:new Map(i),model:void 0,columnMap:new Map,panelState:s}}componentDidMount(){this.isHidden()||(this.setState({isActive:!0}),this.initModel())}componentDidUpdate(e,n){const{inputFilters:s,source:i}=this.props,{columnMap:o,model:r,filterMap:l,filterValueMap:a,isLinked:d,settings:c}=this.state;!r||(o!==n.columnMap&&this.pruneFilterMaps(),s!==e.inputFilters&&this.updateChangedInputFilters(s,e.inputFilters),l!==n.filterMap?this.updateFilters():a!==n.filterValueMap&&this.updatePanelState(),c!==n.settings&&Xc(r)&&(r.updateSettings(c),this.updatePanelState()),d!==n.isLinked?i&&(d?(this.startListeningToSource(i),this.updateModelFromSource()):this.stopListeningToSource(i)):d&&i!==e.source&&(e.source&&this.stopListeningToSource(e.source),i&&(this.startListeningToSource(i),this.updateModelFromSource())))}componentWillUnmount(){this.pending.cancel();const{source:e}=this.props;e&&this.stopListeningToSource(e)}initModel(){this.setState({isLoading:!0,isLoaded:!1,error:void 0});const{makeModel:e}=this.props;this.pending.add(e(),n=>{n.close()}).then(this.handleLoadSuccess,this.handleLoadError)}startListeningToSource(e){Jt.debug("startListeningToSource",e),e.addEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.addEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.addEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}stopListeningToSource(e){Jt.debug("stopListeningToSource",e),e.removeEventListener(M.Table.EVENT_CUSTOMCOLUMNSCHANGED,this.handleSourceColumnChange),e.removeEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),e.removeEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange)}loadModelIfNecessary(){const{isActive:e,isLoaded:n,isLoading:s}=this.state;e&&!n&&!s&&this.initModel()}isHidden(){const{glContainer:e}=this.props,{isHidden:n}=e;return n}handleColumnSelected(e){const{glEventHub:n}=this.props,{columnMap:s}=this.state;n.emit(zi.COLUMN_SELECTED,this,s.get(e))}handleColumnMouseEnter({type:e,name:n}){const{columnSelectionValidator:s}=this.props;Jt.debug("handleColumnMouseEnter",s,e,n),s&&s(this,{type:e,name:n})}handleColumnMouseLeave(){const{columnSelectionValidator:e}=this.props;Jt.debug("handleColumnMouseLeave",e),e&&e(this,void 0)}handleDisconnect(){this.setState({error:new Error("Figure disconnected"),isDisconnected:!0})}handleFilterAdd(e){for(let n=0;n<e.length;n+=1)this.openInputFilter(e[n])}handleOpenLinker(){const{localDashboardId:e,setActiveTool:n,setDashboardIsolatedLinkerPanelId:s}=this.props;s(e,void 0),n(cn.LINKER)}handleReconnect(){this.setState({isDisconnected:!1,error:void 0}),this.sendColumnChange(),this.updateColumnFilters()}handleLoadSuccess(e){Jt.debug("handleLoadSuccess");const{model:n}=this.state;this.setState({model:e,isLoaded:!0},()=>{const{inputFilters:s,source:i}=this.props,{filterMap:o,isLinked:r}=this.state;e!==n&&(this.sendColumnChange(),this.updateColumnFilters(),this.updateInputFilters(s,o.size>0||e.isFilterRequired()),i&&r&&(this.startListeningToSource(i),this.updateModelFromSource()))})}handleLoadError(e){Ee.isCanceled(e)||(Jt.error("handleLoadError",e),this.setState({error:e,isLoading:!1}))}handleSourceColumnChange(){this.updateModelFromSource()}handleSourceFilterChange(){this.updateModelFromSource()}handleSourceSortChange(){this.updateModelFromSource()}updateModelFromSource(){const{metadata:e,source:n}=this.props,{isLinked:s,model:i}=this.state;if(!s||!i||!n){Jt.debug2("updateModelFromSource ignoring",s,i,n);return}if(this.pending.cancel(),kr(e)){const{settings:o}=e;this.pending.add(M.plot.Figure.create(Le.makeFigureSettings(o,n))).then(r=>{Xc(i)&&i.setFigure(r)}).catch(this.handleLoadError)}this.updatePanelState()}updatePanelState(){const{sourcePanel:e}=this.props,{panelState:n,filterValueMap:s,settings:i}=this.state;let{tableSettings:o}=n!=null?n:{};if(e&&sE(e.props)&&iE(e.state)){const{inputFilters:r}=e.props,{panelState:l}=e.state;l!=null&&(o=se.extractTableSettings(l,r))}this.setState({panelState:{settings:i,tableSettings:o,filterValueMap:Array.from(s)}})}handleError(){this.setState({isLoading:!1})}handleResize(){this.updateChart()}handleSettingsChanged(e){this.setState(({settings:n})=>{const s={...n,...e};return Jt.debug("Updated settings",s),{settings:s}})}handleHide(){this.setActive(!1)}handleShow(){this.setActive(!0)}handleTabBlur(){this.setActive(!1)}handleTabFocus(){const e=this.isHidden();this.setActive(!e)}handleUpdate(){this.setState({isLoading:!1})}handleClearAllFilters(){this.setState({filterValueMap:new Map,filterMap:new Map}),this.updatePanelState()}openInputFilter(e){const{glEventHub:n}=this.props,{name:s,type:i}=e;n.emit(Pe.OPEN_INPUT,{title:`${s} Filter`,panelState:{name:s,type:i,isValueShown:!0},createNewStack:!0,focusElement:"input"})}setActive(e){this.setState({isActive:e},()=>{e&&(this.loadModelIfNecessary(),this.updateChart())})}sendColumnChange(){const{model:e}=this.state;if(!e)return;const{glEventHub:n}=this.props;n.emit(Pe.COLUMNS_CHANGED,this,Array.from(e.getFilterColumnMap().values()))}getCoordinateForColumn(e){var l;const n=_o.makeButtonClassName(e);if(!this.panelContainer.current)return null;const s=this.panelContainer.current.querySelector(`.${n}`),i=(l=s==null?void 0:s.getBoundingClientRect())!=null?l:null;if(i==null||i.width<=0||i.height<=0)return null;const o=i.left+i.width/2,r=i.bottom;return[o,r]}setFilterMap(e){Jt.debug("setFilterMap",e),this.setState(n=>{const{columnMap:s,filterMap:i}=n;let o=null;const r=new Map(n.filterValueMap);return e.forEach(({columnType:l,value:a},d)=>{const c=s.get(d);c==null||c.type!==l||(r.set(d,a),i.get(d)!==a&&(o===null&&(o=new Map(i)),o.set(d,a)))}),{filterValueMap:r,filterMap:o!=null?o:i}})}unsetFilterValue(e){this.setState(n=>{var a;const{inputFilters:s}=this.props,{columnMap:i}=n;let{filterMap:o,filterValueMap:r}=n;if(!r.has(e))return null;r=new Map(n.filterValueMap),r.delete(e);const l=this.getInputFilterColumnMap(i,s);if(l.has(e)){const d=o.get(e),c=(a=l.get(e))==null?void 0:a.value;c!=null&&d!==c&&(o=new Map(n.filterMap),c.length>0?o.set(e,c):o.delete(e))}else o=new Map(n.filterMap),o.delete(e);return{filterMap:o,filterValueMap:r}})}updateChangedInputFilters(e,n){const s=n.filter(o=>e.find(r=>r.name===o.name&&r.type===o.type)===void 0);s.length>0&&this.deleteInputFilters(s);const i=e.filter(o=>!n.includes(o));i.length>0&&this.updateInputFilters(i)}updateInputFilters(e,n=!1){this.setState(s=>{const{columnMap:i}=s,o=new Map(s.filterValueMap),r=new Map(s.filterMap),l=n?{filterMap:r,filterValueMap:o}:{};for(let a=0;a<e.length;a+=1){const{name:d,type:c,value:u}=e[a],m=i.get(d);m!=null&&m.type===c&&(u!=null&&r.get(d)!==u&&(u===""?r.delete(d):r.set(d,u),l.filterMap=r),o.has(d)&&(o.delete(d),l.filterValueMap=o))}return Jt.debug("updateInputFilters",l),l})}deleteInputFilters(e,n=!1){this.setState(s=>{const{columnMap:i,filterValueMap:o}=s,r=new Map(s.filterMap);let l=n;for(let a=0;a<e.length;a+=1){const{name:d,type:c}=e[a],u=i.get(d);if(u!=null&&u.type===c&&r.has(d)){const m=r.get(d);if(o.has(d)){const p=o.get(d);p!==m&&p!=null&&(l=!0,r.set(d,p))}else l=!0,r.delete(d)}}return Jt.debug("deleteInputFilters",l),l?{filterMap:r}:null})}updateColumnFilters(){this.setState(({model:e})=>e?{columnMap:e.getFilterColumnMap()}:null)}updateFilters(){const{columnMap:e,filterMap:n,model:s}=this.state;A(s);const i=this.getWaitingInputMap(s.isFilterRequired(),e,n);if(s.setFilter(n),n.size>0&&i.size===0){const o=s.getDefaultTitle(),r=tn.join(Array.from(n.entries()).map(([l,a])=>`${l}: ${a}`));o?s.setTitle(`${o}<br><span style="font-size: smaller">${r}</span>`):s.setTitle(r),Jt.debug2("updateFilters filters set",n),this.setState({isLoading:!0})}else Jt.debug2("updateFilters waiting on inputs",i),s.setTitle(s.getDefaultTitle()),this.setState({isLoading:!1});this.updatePanelState()}pruneFilterMaps(){this.setState(e=>{const{columnMap:n}=e,s=new Map(e.filterMap),i=new Map(e.filterValueMap),o={};return e.filterValueMap.forEach((r,l)=>{n.has(l)||(i.delete(l),o.filterValueMap=i)}),e.filterMap.forEach((r,l)=>{n.has(l)||(s.delete(l),o.filterMap=s)}),o})}updateChart(){this.chart.current&&this.chart.current.updateDimensions()}render(){const{columnSelectionValidator:e,glContainer:n,glEventHub:s,inputFilters:i,isLinkerActive:o,links:r,metadata:l,settings:a}=this.props,{columnMap:d,filterMap:c,error:u,model:m,isActive:p,isDisconnected:g,isLoaded:f,isLoading:b}=this.state;let C;kr(l)?C=l.table:C=l.figure;const w=this.getInputFilterColumnMap(d,i),T=this.getLinkedColumnMap(d,r),E=m!=null?this.getWaitingInputMap(m.isFilterRequired(),d,c):new Map,y=m!=null?this.getWaitingFilterMap(m.isFilterRequired(),d,c,T,w):new Map,I=u!=null?`Unable to open chart. ${u}`:void 0,D=E.size>0,N=d.size>0&&o;return h(kl,{className:z("iris-chart-panel",{"input-required":D}),componentPanel:this,glContainer:n,glEventHub:s,onHide:this.handleHide,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabBlur:this.handleTabBlur,onTabFocus:this.handleTabFocus,errorMessage:I,isDisconnected:g,isLoading:b,isLoaded:f,widgetName:C,widgetType:"Chart",children:v("div",{ref:this.panelContainer,className:"chart-panel-container h-100 w-100",children:[h("div",{className:"chart-container h-100 w-100",children:f&&m&&h(Qu,{isActive:p,model:m,settings:a,ref:this.chart,onDisconnect:this.handleDisconnect,onReconnect:this.handleReconnect,onUpdate:this.handleUpdate,onError:this.handleError,onSettingsChanged:this.handleSettingsChanged})}),h(ht,{in:D&&!N&&!b,timeout:Tt.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(pp,{inputFilterMap:w,linkedColumnMap:T,onAdd:this.handleFilterAdd,onOpenLinker:this.handleOpenLinker,columnMap:d,waitingFilterMap:y,waitingInputMap:E})}),h(ht,{in:N,timeout:Tt.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,children:h(_o,{columns:this.getSelectorColumns(d,T,e),onColumnSelected:this.handleColumnSelected,onMouseEnter:this.handleColumnMouseEnter,onMouseLeave:this.handleColumnMouseLeave})})]})})}}Ol.defaultProps={columnSelectionValidator:null,isLinkerActive:!1,source:null,sourcePanel:null,panelState:null,settings:{}};Ol.displayName="ChartPanel";Ol.COMPONENT="ChartPanel";const oE=(t,e)=>{const{localDashboardId:n,metadata:s}=e;let i;s!=null&&(i=s.sourcePanelId);const o=Bd(t,n),r=Om(t,n),l=Tl(t),a=$d(t,n),d=l===cn.LINKER&&a===void 0;return{columnSelectionValidator:zd(t,n),isLinkerActive:d,inputFilters:Ud(t,n),links:eo(t,n),source:i!=null?o.get(i):void 0,sourcePanel:i!=null?r.get(i):void 0,settings:Kt(t)}},Pi=Mt(oE,{setActiveTool:El,setDashboardIsolatedLinkerPanelId:mp},null,{forwardRef:!0})(Ol);const Er=X.module("CommandHistoryPanel"),gp=class extends S.exports.Component{constructor(t){super(t),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleSendToConsole=this.handleSendToConsole.bind(this),this.handleSendToNotebook=this.handleSendToNotebook.bind(this),this.container=Y.createRef(),this.pending=new ps;const{session:e,sessionId:n,language:s}=t;this.state={panelState:{},session:e,sessionId:n,language:s,contextActions:[{action:this.handleFocusHistory,shortcut:Nn.COMMAND_HISTORY.FOCUS_HISTORY}]}}static handleError(t){Er.error(t)}componentDidMount(){const{glEventHub:t,session:e}=this.props;t.on(ft.FOCUS_HISTORY,this.handleFocusHistory),e!=null&&this.loadTable()}componentWillUnmount(){const{glEventHub:t}=this.props;t.off(ft.FOCUS_HISTORY,this.handleFocusHistory),this.pending.cancel()}handleFocusHistory(){this.container.current&&this.container.current.focus()}handleSessionOpened(t,{language:e,sessionId:n}){this.setState({session:t,sessionId:n,language:e},()=>{this.loadTable()})}handleSessionClosed(){this.pending.cancel(),this.setState({session:void 0,language:void 0,table:void 0})}handleSendToNotebook(t,e=!1){const{session:n,language:s}=this.state;if(Er.debug("handleSendToNotebook",n,t),!n){Er.error("Session is not connected.");return}const{glEventHub:i}=this.props;i.emit(e?He.CREATE_NOTEBOOK:He.SEND_TO_NOTEBOOK,n,s,t)}handleSendToConsole(t,e=!0,n=!1){Er.debug("handleSendToConsole",t);const{glEventHub:s}=this.props;s.emit(ft.SEND_COMMAND,t,e,n)}loadTable(){const{commandHistoryStorage:t}=this.props,{language:e,sessionId:n}=this.state;A(e),A(n),this.pending.add(t.getTable(e,n,Date.now()),s=>s.close()).then(s=>{this.setState({table:s})}).catch(gp.handleError)}render(){const{glContainer:t,glEventHub:e,commandHistoryStorage:n}=this.props,{language:s,contextActions:i,table:o}=this.state;return v(Yn,{className:"command-history-pane",componentPanel:this,glContainer:t,glEventHub:e,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,children:[!o&&h("div",{className:"command-history-disconnected-message",children:"Waiting for console connection"}),o&&s&&v(he,{children:[h(Sl,{ref:this.container,language:s,sendToNotebook:this.handleSendToNotebook,sendToConsole:this.handleSendToConsole,table:o,commandHistoryStorage:n}),h(ie,{actions:i})]})]})}};let Gd=gp;Gd.COMPONENT="CommandHistoryPanel";Gd.TITLE="Command History";const rE=(t,e)=>{const n=tm(t),s=gi(t,e.localDashboardId),{session:i,config:o}=s!=null?s:{},{type:r,id:l}=o!=null?o:{};return{commandHistoryStorage:n,language:r,session:i,sessionId:l}},Zr=Mt(rE,null,null,{forwardRef:!0})(Gd);const yr=X.module("ConsolePanel"),lE=500,aE=Object.freeze({consoleSettings:{},itemIds:[]});class Kd extends S.exports.PureComponent{constructor(e){super(e),this.savePanelState=Xe(()=>{const{consoleSettings:r,itemIds:l}=this.state,a={consoleSettings:r,itemIds:[...l]};yr.debug("Saving panel state",a),this.setState({panelState:a})},lE),this.handleFocusCommandHistory=this.handleFocusCommandHistory.bind(this),this.handleOpenObject=this.handleOpenObject.bind(this),this.handleCloseObject=this.handleCloseObject.bind(this),this.handleResize=this.handleResize.bind(this),this.handleSettingsChange=this.handleSettingsChange.bind(this),this.handleShow=this.handleShow.bind(this),this.handlePanelMount=this.handlePanelMount.bind(this),this.consoleRef=Y.createRef();const{panelState:n}=e,s={...aE,...n||{}},{consoleSettings:i,itemIds:o}=s;this.state={consoleSettings:i,itemIds:new Map(o),objectMap:new Map,error:void 0,panelState:s}}componentDidMount(){const{glEventHub:e}=this.props;this.closeDisconnectedPanels(),e.on(Me.MOUNT,this.handlePanelMount),this.subscribeToFieldUpdates()}componentDidUpdate(e,n){const{consoleSettings:s,itemIds:i}=this.state;(n.consoleSettings!==s||n.itemIds!==i)&&this.savePanelState()}componentWillUnmount(){var n;const{glEventHub:e}=this.props;this.savePanelState.flush(),e.off(Me.MOUNT,this.handlePanelMount),(n=this.objectSubscriptionCleanup)==null||n.call(this)}subscribeToFieldUpdates(){const{sessionWrapper:e}=this.props,{session:n}=e;this.objectSubscriptionCleanup=n.subscribeToFieldUpdates(s=>{yr.debug("Got updates",s),this.setState(({objectMap:i})=>{const{updated:o,created:r,removed:l}=s,a=[...o,...l],d=new Map(i);return a.forEach(u=>{const{title:m}=u;m!==void 0&&d.delete(m)}),[...o,...r].forEach(u=>{u.title!==void 0&&d.set(u.title,u)}),{objectMap:d}})})}setItemId(e,n){this.setState(({itemIds:s})=>{const i=new Map(s);return i.set(e,n),{itemIds:i}})}getItemId(e,n=!0){const{itemIds:s}=this.state;let i=s.get(e);return i==null&&n&&(i=We.generate(),this.setItemId(e,i)),i}handleTabFocus(){var e;(e=this.consoleRef.current)==null||e.focus()}handlePanelMount(e){var o,r,l;const{itemIds:n}=this.state,s=(o=e==null?void 0:e.props)==null?void 0:o.id,i=(l=(r=e==null?void 0:e.props)==null?void 0:r.metadata)==null?void 0:l.sourcePanelId;s&&i&&new Set(n.values()).has(i)&&this.setItemId(s,s)}handleFocusCommandHistory(){const{glEventHub:e}=this.props;e.emit(ft.FOCUS_HISTORY)}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions()}handleOpenObject(e){const{sessionWrapper:n}=this.props,{session:s}=n;this.openWidget(e,s)}handleCloseObject(e){const{title:n}=e;if(n!==void 0){const s=this.getItemId(n,!1),{glEventHub:i}=this.props;i.emit(Me.CLOSE,s)}}handleSettingsChange(e){const{glEventHub:n}=this.props;yr.debug("handleSettingsChange",e),this.setState({consoleSettings:e}),n.emit(ft.SETTINGS_CHANGED,e)}openWidget(e,n){const{glEventHub:s}=this.props,{title:i}=e;A(i);const o=this.getItemId(i),r={fetch:()=>n.getObject(e),panelId:o,widget:e};yr.debug("openWidget",r),s.emit(Me.OPEN,r)}addCommand(e,n=!0,s=!1){var i;(i=this.consoleRef.current)==null||i.addCommand(e,n,s)}closeDisconnectedPanels(e=!1){const{consoleSettings:n,itemIds:s}=this.state,{isClosePanelsOnDisconnectEnabled:i=!0}=n;if(!i&&!e)return;const o=[...s.values()],{glEventHub:r}=this.props;o.forEach(l=>{r.emit(Me.CLOSE,l)}),this.setState({itemIds:new Map})}updateDimensions(){var e;(e=this.consoleRef.current)==null||e.updateDimensions()}render(){const{commandHistoryStorage:e,glContainer:n,glEventHub:s,sessionWrapper:i,timeZone:o,unzip:r}=this.props,{consoleSettings:l,error:a,objectMap:d}=this.state,{config:c,session:u,connection:m}=i,{id:p,type:g}=c;return h(Yn,{componentPanel:this,glContainer:n,glEventHub:s,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,errorMessage:a!=null?`${a}`:void 0,children:h(he,{children:u!=null&&h(pd,{ref:this.consoleRef,settings:l,session:u,focusCommandHistory:this.handleFocusCommandHistory,openObject:this.handleOpenObject,closeObject:this.handleCloseObject,commandHistoryStorage:e,onSettingsChange:this.handleSettingsChange,language:g,statusBarChildren:v(he,{children:[h("div",{children:"\xA0"}),h("div",{children:ku.LANGUAGE_MAP.get(g)}),h("div",{children:"\xA0"}),h("div",{children:h(nS,{connection:m,defaultUpdateInterval:10*1e3,hoverUpdateInterval:3*1e3,monitorDuration:10*60*1e3})}),h("div",{children:"\xA0"})]}),scope:p,timeZone:o,objectMap:d,unzip:r})})})}}Kd.COMPONENT="ConsolePanel";Kd.TITLE="Console";const dE=(t,e)=>({commandHistoryStorage:tm(t),sessionWrapper:gi(t,e.localDashboardId),timeZone:vl(t)}),_i=Mt(dE,null,null,{forwardRef:!0})(Kd);const mo=X.module("DropdownFilter"),cE=150,Lr=class extends S.exports.Component{constructor(t){super(t),this.getCompatibleColumns=ge((i,o)=>i!=null?o.filter(({type:r})=>r!==void 0&&P.isCompatibleType(r,i.columnType)):[]),this.getColumnOptions=ge((i,o)=>{let r=-1;const l=[];return l.push(h("option",{value:"-1",children:"Select a column"},"placeholder")),i.forEach((a,d)=>{l.push(h("option",{value:d,children:this.getItemLabel(i,d)},`${a.name}/${a.type}`)),o!==null&&a.name===o.name&&a.type===o.type&&(r=d)}),[l,r]}),this.getSelectedOptionIndex=ge((i,o)=>i.indexOf(o)),this.getValueOptions=ge(i=>[h("option",{value:"-1",children:Lr.PLACEHOLDER},"-1"),...i.map((o,r)=>h("option",{value:r,children:o},`${r}/${o}`))]),this.getItemLabel=Te((i,o)=>{const{name:r,type:l}=i[o];if(o>0&&i[o-1].name===r||o<i.length-1&&i[o+1].name===r){const a=l.substring(l.lastIndexOf(".")+1);return`${r} (${a})`}return r}),this.sendUpdate=Xe(()=>{const{onChange:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i({column:o,isValueShown:l,value:r!=null?r:void 0})},cE),this.handleColumnChange=this.handleColumnChange.bind(this),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleDropdownKeyPress=this.handleDropdownKeyPress.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.dropdownRef=Y.createRef();const{column:e,isValueShown:n,value:s}=t;this.state={column:e,selectedColumn:e,disableCancel:!n,isValueShown:n,value:s}}componentDidUpdate(t,e){const{source:n,values:s,isLoaded:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i&&(n!==t.source&&this.sourceUpdated(),s!==t.values&&r!==""&&!s.includes(r)&&this.resetValue(),l!==e.isValueShown&&l&&this.focusInput(),(o!==e.column||r!==e.value||l!==e.isValueShown)&&this.sendUpdate())}componentWillUnmount(){this.sendUpdate.flush()}handleColumnChange(t){const{value:e}=t.target;if(mo.debug2("handleColumnChange",e),e!=null&&parseInt(e,10)<0){this.setState({selectedColumn:null});return}const{columns:n,source:s}=this.props,i=this.getCompatibleColumns(s,n);this.setState({selectedColumn:i[parseInt(e,10)]})}handleDropdownKeyPress(t){t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),mo.debug2("handleDropdownKeyPress"),this.sendUpdate(),this.sendUpdate.flush())}handleValueChange(t){const{value:e}=t.target,n=parseInt(e,10);let s="";const{values:i}=this.props;if(n===-1)mo.debug2("Selected default item");else if(n>=0&&n<i.length)s=i[n];else{mo.error("Invalid index",n,i);return}mo.debug2("handleValueChange",s),this.setState({value:s})}handleSettingsCancel(){this.setState(({column:t})=>({selectedColumn:t,isValueShown:!0}))}handleSettingsSave(){this.setState(({column:t,selectedColumn:e,value:n})=>({column:e,value:t===e?n:"",isValueShown:!0,disableCancel:!1}))}handleSettingsClick(t){t.stopPropagation(),this.showSettings()}handleBackgroundClick(t){t.target!==this.dropdownRef.current&&this.focusInput()}handleMouseEnter(){const{onSourceMouseEnter:t}=this.props;t()}handleMouseLeave(){const{onSourceMouseLeave:t}=this.props;t()}sourceUpdated(){this.setState({column:null,selectedColumn:null,isValueShown:!1,disableCancel:!0,value:""})}showSettings(){const{column:t}=this.state;this.setState({selectedColumn:t,isValueShown:!1})}focusInput(){this.dropdownRef.current!==null&&this.dropdownRef.current.focus()}resetValue(){this.setState({value:""})}clearFilter(){this.resetValue()}setFilterState({name:t,type:e,value:n,isValueShown:s}){const i=t!=null&&e!=null?{name:t,type:e}:null;this.setState({column:i,value:n,isValueShown:s})}render(){var U;const{columns:t,disableLinking:e,isLinkerActive:n,isLoaded:s,source:i,onColumnSelected:o,onSourceMouseEnter:r,onSourceMouseLeave:l,values:a,settingsError:d}=this.props,{column:c,disableCancel:u,isValueShown:m,selectedColumn:p,value:g}=this.state,f=i===null,b=this.getCompatibleColumns(i,t),C=i!=null,w=(U=i==null?void 0:i.columnName)!=null?U:Lr.SOURCE_BUTTON_PLACEHOLDER,T=c!=null?`${c.name} Filter`:null,[E,y]=this.getColumnOptions(b,p),I=this.getValueOptions(a),D=this.getSelectedOptionIndex(a,g),N=!C||p==null;return v(Ja,{className:"dropdown-filter fill-parent-absolute",isFlipped:m&&!n,children:[h("div",{className:"dropdown-filter-settings-card",children:v("div",{className:"dropdown-filter-card-content",children:[v("div",{className:"dropdown-filter-settings-grid",children:[h("label",{children:"Source Column"}),h(gl,{isLinked:C,onClick:o,onMouseEnter:r,onMouseLeave:l,className:Lr.SOURCE_BUTTON_CLASS_NAME,disabled:e,children:w}),h("div",{className:"text-muted small",children:"Select a source column for the list by linking to a table."}),h("label",{children:"Filter Column"}),h("select",{value:y,className:"custom-select",onChange:this.handleColumnChange,disabled:f,children:E}),h("div",{className:"text-muted small",children:"Dropdown filter control will apply its filter to all columns matching this name in this dashboard."})]}),d&&h("div",{className:"error-message text-center",children:d}),C&&v("div",{className:"dropdown-filter-settings-buttons",children:[h(Q,{kind:"secondary",type:"button",onClick:this.handleSettingsCancel,disabled:u||m||n,tooltip:n?"Cancel disabled while linker open":void 0,children:"Cancel"}),h(Q,{kind:"primary",type:"button",className:"ml-2",onClick:this.handleSettingsSave,disabled:N||m||n,tooltip:n?"Save disabled while linker open":void 0,children:"Save"})]})]})}),h("div",{className:"dropdown-filter-value-card",onClick:this.handleBackgroundClick,children:s&&v(he,{children:[h("div",{className:"dropdown-filter-column",children:h("div",{className:"dropdown-filter-column-title",children:T})}),v("div",{className:"dropdown-filter-card-content",children:[h("div",{className:"dropdown-filter-value-input d-flex flex-column justify-content-center",children:h("select",{className:"custom-select",value:D,ref:this.dropdownRef,onChange:this.handleValueChange,onKeyPress:this.handleDropdownKeyPress,children:I})}),d&&h("div",{className:"error-message mt-3 text-center",children:d})]}),h("div",{className:"dropdown-filter-menu",children:h(Q,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:h(q,{icon:Vo,transform:"grow-4"}),tooltip:"Dropdown Filter Settings"})})]})})]})}};let Wi=Lr;Wi.defaultProps={column:null,disableLinking:!1,isLinkerActive:!1,isLoaded:!1,isValueShown:!1,settingsError:null,source:null,value:"",values:[],onColumnSelected:()=>{},onSourceMouseEnter:()=>{},onSourceMouseLeave:()=>{}};Wi.PLACEHOLDER="Select a value...";Wi.SOURCE_BUTTON_CLASS_NAME="btn-dropdown-filter-selector";Wi.SOURCE_BUTTON_PLACEHOLDER="Select a column";const tt=X.module("DropdownFilterPanel"),hE=250,ei=class extends S.exports.Component{constructor(t){super(t),this.getCachedValues=ge((d,{type:c,name:u},m)=>c!==void 0&&P.isDateType(c)?d.map(p=>ei.DATETIME_FORMATTER.format(p)):d.map(p=>p!=null&&c!=null?m.getFormattedString(p,c,u):null)),this.getCachedPanelLinks=ge((d,c)=>{const u=te.getIdFromPanel(c);return tt.debug("getCachedPanelLinks",d,u),d.filter(m=>{var p;return((p=m.end)==null?void 0:p.panelId)===u})}),this.getCachedSource=ge(d=>{tt.debug("getCachedSource",d);let c=null;if(d.length>0){const[u]=d;c=u.start,d.length>1&&tt.error("Filter has more that one link",d)}return c}),this.getCachedSourceTable=ge((d,c)=>{var m;if(tt.debug("getCachedSourceTable",d,c),c==null)return null;const{panelId:u}=c;return(m=d.get(u))!=null?m:null}),this.getCachedSourceColumn=ge((d,c)=>{var u;return tt.debug("getCachedSourceColumn",d,c),d==null||c==null?null:(u=d.columns.find(({name:m,type:p})=>m===c.columnName&&p===c.columnType))!=null?u:null}),this.handleChange=Xe(this.handleChange.bind(this),hE),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleSourceFilterChange=this.handleSourceFilterChange.bind(this),this.handleSourceSortChange=this.handleSourceSortChange.bind(this),this.handleSourceSizeChange=this.handleSourceSizeChange.bind(this),this.handleSourceMouseEnter=this.handleSourceMouseEnter.bind(this),this.handleSourceMouseLeave=this.handleSourceMouseLeave.bind(this),this.handleValuesTableUpdate=this.handleValuesTableUpdate.bind(this),this.dropdownFilterRef=Y.createRef(),this.panelContainer=Y.createRef(),this.pending=new ps;const{panelState:e,settings:n}=t;this.columnFormats=hs.getColumnFormats(n);const{value:s="",isValueShown:i=!1,name:o,type:r,timestamp:l}=e!=null?e:{},a=o!=null&&r!=null?{name:o,type:r}:void 0;this.state={column:a,formatter:new hn(this.columnFormats),valuesTable:void 0,valuesColumn:void 0,sourceSize:0,value:s,timestamp:l,values:[],isValueShown:i,wasFlipped:!1,skipUpdate:!1,panelState:e,isDisconnected:!1,isLoading:!1,isLoaded:!1,error:null}}componentDidMount(){this.updateValuesTable();const{column:t,value:e,timestamp:n}=this.state,s=this.getSourceTable();if(s!==null&&this.startListeningToSource(s),t!=null){const{name:i,type:o}=t;this.sendUpdate(i,o,e,n)}}componentDidUpdate(t,e){const{valuesTable:n}=this.state,{settings:s}=this.props,i=this.getSource(),o=this.getSourceTable(),r=this.getSource(t),l=this.getSourceTable(t);s!==t.settings&&s!==void 0&&this.updateFormatterSettings(s),n!==e.valuesTable&&e.valuesTable!=null&&(tt.debug("Table in state modified, closing the old table."),e.valuesTable.close()),(o!==l||i!==r)&&this.updateValuesTable(),o!==l&&(l!==null&&this.stopListeningToSource(l),o!==null&&this.startListeningToSource(o))}componentWillUnmount(){const{valuesTable:t}=this.state,e=this.getSourceTable();this.pending.cancel(),e!==null&&this.stopListeningToSource(e),this.cleanup&&this.cleanup(),t!=null&&t.close()}getCoordinateForColumn(){var i;if(this.panelContainer.current==null)return null;const t=this.panelContainer.current.querySelector(`.${Wi.SOURCE_BUTTON_CLASS_NAME}`),e=(i=t==null?void 0:t.getBoundingClientRect())!=null?i:null;if(e==null||e.width<=0||e.height<=0)return null;const n=e.left+e.width/2,s=e.bottom;return[n,s]}getSettingsErrorMessage(){const{sourceSize:t}=this.state;if(t>ei.MAX_TABLE_SIZE)return`Table too large, must have fewer than ${ei.MAX_TABLE_SIZE} options.`}getPanelErrorMessage(){const{error:t}=this.state;return t!=null?`${t}`:void 0}getSource(t=this.props){const{dashboardLinks:e}=t,n=this.getCachedPanelLinks(e,this);return this.getCachedSource(n)}getSourceTable(t=this.props){const{panelTableMap:e}=t,n=this.getSource(t);return this.getCachedSourceTable(e,n)}getValuesColumn(t){const e=this.getSource();return this.getCachedSourceColumn(t,e)}startListeningToSource(t){tt.debug("startListeningToSource"),t.addEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),t.addEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),t.addEventListener(M.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),t.addEventListener(M.Table.EVENT_DISCONNECT,this.handleDisconnect),t.addEventListener(M.Table.EVENT_RECONNECT,this.handleReconnect)}stopListeningToSource(t){tt.debug("stopListeningToSource"),t.removeEventListener(M.Table.EVENT_FILTERCHANGED,this.handleSourceFilterChange),t.removeEventListener(M.Table.EVENT_SORTCHANGED,this.handleSourceSortChange),t.removeEventListener(M.Table.EVENT_SIZECHANGED,this.handleSourceSizeChange),t.removeEventListener(M.Table.EVENT_DISCONNECT,this.handleDisconnect),t.removeEventListener(M.Table.EVENT_RECONNECT,this.handleReconnect)}handleChange({column:t,isValueShown:e,value:n}){const{name:s=void 0,type:i=void 0}=t!=null?t:{};let o=!0,r=Date.now();this.setState(({panelState:l,timestamp:a,wasFlipped:d,skipUpdate:c})=>{var m;const u=l!=null&&e!==l.isValueShown&&s===l.name&&i===l.type&&n===l.value;return o=(m=!c&&e&&(!u||!d))!=null?m:!1,o||(r=a),{panelState:{isValueShown:e,name:s,type:i,value:n,timestamp:r!=null?r:void 0},timestamp:r,wasFlipped:u,skipUpdate:!1}},()=>{o&&this.sendUpdate(s!=null?s:null,i,n,r)})}handleDisconnect(){this.setState({error:new Error("Table disconnected"),isDisconnected:!0,isLoading:!1})}handleReconnect(){this.setState({isDisconnected:!1,error:null})}handleSourceFilterChange(){this.applySourceFilters()}handleSourceSortChange(){this.applySourceSorts()}handleSourceSizeChange({detail:t}){this.setState({sourceSize:t})}handleColumnSelected(){tt.debug("handleColumnSelected");const{glEventHub:t}=this.props;t.emit(Pe.COLUMN_SELECTED,this,ei.SOURCE_COLUMN)}handleClearAllFilters(){var t,e;(e=(t=this.dropdownFilterRef)==null?void 0:t.current)==null||e.clearFilter()}setPanelState(t,e=!1){var n,s;if(this.getSource()==null){tt.debug("Ignore state update for unlinked filter",t);return}this.setState({skipUpdate:!e}),(s=(n=this.dropdownFilterRef)==null?void 0:n.current)==null||s.setFilterState(t)}sendUpdate(t,e,n,s){var l;const{glEventHub:i}=this.props,o=(l=this.getSource())==null?void 0:l.panelId,r=o===null?[]:[o];tt.debug("sendUpdate",{name:t,type:e,value:n,timestamp:s,excludePanelIds:r}),i.emit(Pe.FILTERS_CHANGED,this,{name:t,type:e,value:n!=null?n:"=null",timestamp:s,excludePanelIds:r})}updateValuesTable(){const t=this.getSource(),e=this.getSourceTable();if(tt.debug("updateValuesTable",t,e),this.setState({values:[],valuesTable:void 0,error:null}),t==null){tt.debug("Filter unlinked."),this.setState({isLoading:!1,isLoaded:!0,isValueShown:!1,sourceSize:0});return}this.setState({isLoading:!0}),e!=null&&(this.setState({isLoaded:!1,sourceSize:e.size}),this.pending.add(e.copy(),n=>n.close()).then(n=>{this.updateViewportListener(n),this.setState({valuesTable:n})}).catch(n=>{Ee.isCanceled(n)||(tt.error(n),this.setState({isLoading:!1,error:n}))}))}applySourceSorts(){const{valuesTable:t}=this.state,e=this.getSourceTable();if(tt.debug("applySourceSorts",e.sort),t==null){tt.debug("Table not initialized");return}const n=[...e.sort];t.applySort(n),this.setViewport(t)}applySourceFilters(){const{valuesTable:t}=this.state,e=this.getSourceTable();if(tt.debug("applySourceFilters",e.filter),t==null){tt.debug("Table not initialized");return}const n=[...e.filter];t.applyFilter(n),this.setViewport(t)}updateViewportListener(t){if(tt.debug("updateViewportListener",t==null?void 0:t.size),this.cleanup&&this.cleanup(),t==null){this.cleanup=void 0;return}this.cleanup=t.addEventListener(M.Table.EVENT_UPDATED,this.handleValuesTableUpdate),this.setViewport(t)}setViewport(t){const e=this.getValuesColumn(t);if(!e){tt.error("values column is null");return}t.setViewport(0,ei.MAX_TABLE_SIZE-1,[e])}updateFormatterSettings(t){const e=hs.getColumnFormats(t);ct(this.columnFormats,e)||(this.columnFormats=e,this.setState({formatter:new hn(e)}))}handleValuesTableUpdate({detail:t}){const{rows:e}=t,{valuesTable:n}=this.state;if(!n){tt.error("valuesTable is null");return}const s=this.getValuesColumn(n);if(!s){tt.error("Values column not found");return}const i=e.map(o=>o.get(s));this.setState({values:i,isLoading:!1,isLoaded:!0,valuesColumn:s})}handleSourceMouseEnter(){const{columnSelectionValidator:t}=this.props;!t||t(this,ei.SOURCE_COLUMN)}handleSourceMouseLeave(){const{columnSelectionValidator:t}=this.props;!t||t(this,void 0)}render(){const{columns:t,disableLinking:e,glContainer:n,glEventHub:s,isLinkerActive:i}=this.props,{column:o,formatter:r,isDisconnected:l,isValueShown:a,value:d,values:c,valuesColumn:u,isLoading:m,isLoaded:p}=this.state,g=this.getSource(),f=this.getSettingsErrorMessage(),b=this.getPanelErrorMessage(),C=p&&u!=null?this.getCachedValues(c,u,r):[];return h(kl,{errorMessage:b,isLoading:m,isLoaded:p,isDisconnected:l,className:"iris-dropdown-filter-panel",componentPanel:this,glContainer:n,glEventHub:s,onClearAllFilters:this.handleClearAllFilters,widgetName:"Dropdown Filter",widgetType:"DropdownFilter",children:h("div",{ref:this.panelContainer,className:"dropdown-filter-container h-100 w-100 container",children:h(Wi,{ref:this.dropdownFilterRef,column:o,columns:t,isValueShown:a,isLinkerActive:i,disableLinking:e,isLoaded:p,settingsError:f,source:g,value:d,values:C,onChange:this.handleChange,onColumnSelected:this.handleColumnSelected,onSourceMouseEnter:this.handleSourceMouseEnter,onSourceMouseLeave:this.handleSourceMouseLeave})})})}};let to=ei;to.displayName="DropdownFilterPanel";to.COMPONENT="DropdownFilterPanel";to.MAX_TABLE_SIZE=256;to.DATETIME_FORMATTER=new lt({showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:"yyyy-MM-dd HH:mm:ss.SSSSSSSSS"});to.SOURCE_COLUMN=Object.freeze({name:"FilterSource",type:null});const uE=(t,e)=>{const{localDashboardId:n}=e,s=te.getIdFromPanel({props:e}),i=Bd(t,n),o=eo(t,n),r=Tl(t),l=$d(t,n),a=r===cn.LINKER&&(l===void 0||l===s),d=r===cn.LINKER&&l!==void 0&&l!==s;return{columns:up(t,n),columnSelectionValidator:zd(t,n),isLinkerActive:a,disableLinking:d,settings:Kt(t),panelTableMap:i,dashboardLinks:o}},di=Mt(uE,null,null,{forwardRef:!0})(to);function Gn(t){return t.type==="directory"}var fp=(t=>(t.GROOVY="text/x-groovy",t.PLAIN_TEXT="text/plain",t.PYTHON="text/x-python",t.PYTHON_COMPILED="application/x-python-code",t.SCALA="text/x-scala",t.UNKNOWN="",t))(fp||{});class de{static fileExtensionToString(e=""){return e.length===0?"":`.${e}`}static getDepth(e){var s;if(!de.hasPath(e))throw new Error(`Invalid path provided: ${e}`);return((s=e.match(/\//g))!=null?s:[]).length-1}static getExtension(e){var s;const n=this.getBaseName(e).split(".");return n.length>1&&(s=n.pop())!=null?s:""}static getBaseName(e){var n;return(n=e.split("/").pop())!=null?n:""}static getCopyFileName(e){const n=e.lastIndexOf(".");let s=null,i=null;n<0?i=e:(i=e.substring(0,n),s=e.substring(n+1));const o=i?`${i}-copy`:"Copy";return s!==null?`${o}.${s}`:o}static getMimeType(e){switch(this.getExtension(e).toLowerCase()){case"groovy":return"text/x-groovy";case"py":return"text/x-python";case"pyc":return"application/x-python-code";case"scala":return"text/x-scala";case"txt":return"text/plain";default:return""}}static getParent(e){if(!de.hasPath(e))throw new Error(`Invalid name provided: ${e}`);const n=e.split("/");for(;n.pop()==="";);if(n.length===0)throw new Error(`No parent for path provided: ${e}`);return`${n.join("/")}/`}static getPath(e){if(!de.hasPath(e))throw new Error(`Invalid filename provided: ${e}`);const n=e.split("/");return n.pop(),`${n.join("/")}/`}static hasPath(e){return e.startsWith("/")}static isPath(e){return e.startsWith("/")&&e.endsWith("/")}static makePath(e){return e.endsWith("/")?e:`${e}/`}static replaceExtension(e,n=""){const s=e.lastIndexOf("."),i=s>-1?e.substring(0,s):e,o=de.fileExtensionToString(n);return`${i}${o}`}static validateName(e){var o;const n=[".",".."],s=/[\\/\0]/g,i=new Map([["\0","null"]]);if(!e)throw new Oi("Name cannot be empty");if(n.includes(e))throw new Oi(`"${e}" is a reserved name`);if(s.test(e))throw new Oi(`Invalid characters in name: "${((o=e.match(s))!=null?o:[]).reduce((r,l)=>r.includes(l)?r:[...r,l],[]).map(r=>i.has(r)?i.get(r):r).join('", "')}"`)}static reducePaths(e){const n=e.filter(s=>de.isPath(s));return e.filter(s=>!n.some(i=>s!==i&&s.startsWith(i)))}static removeRoot(e,n){if(e.length===0)return n;if(!n.startsWith(e))throw new Error(`Filename ${n} does not start with expected root ${e}`);return n.substring(e.length)}static addRoot(e,n){return`${e}${n}`}}const xt=X.module("FileList"),Pa=t=>Gn(t)?de.makePath(t.filename):de.getPath(t.filename),qd=26,mE=500,wh="item-list-scroll-pane",Ha=t=>{var I;const{children:e,draggedItems:n,isDragInProgress:s,isDropTargetValid:i,isSelected:o,item:r,itemIndex:l,dropTargetItem:a,onDragStart:d,onDragOver:c,onDragEnd:u,onDrop:m}=t,p=(I=n==null?void 0:n.some(D=>D.id===r.id))!=null?I:!1,g=Pa(r),f=s&&a?Pa(a):null,b=s&&i&&Gn(r)&&f===g,C=s&&i&&f===g,w=s&&!i&&f===g,T=pE(r),E=de.getDepth(r.filename),y=Array(E).fill(null).map((D,N)=>h("span",{className:"file-list-depth-line"},N));return v("div",{className:z("d-flex w-100 align-items-center","file-list-item",{"is-dragged":p,"is-exact-drop-target":b,"is-in-drop-target":C,"is-invalid-drop-target":w,"is-selected":o}),onDragStart:D=>d(l,D),onDragOver:D=>c(l,D),onDragEnd:D=>u(l,D),onDrop:D=>m(l,D),draggable:!0,role:"presentation","aria-label":r.basename,children:[y," ",h(q,{icon:T,className:"item-icon",fixedWidth:!0})," ",v("span",{className:"truncation-wrapper",children:[e!=null?e:r.basename,h(Ie,{options:{modifiers:{preventOverflow:{boundariesElement:"window"}},placement:"left"},children:e!=null?e:r.basename})]})]})};function pE(t){if(Gn(t))return t.isExpanded?cf:hf;switch(de.getMimeType(t.basename)){case fp.PYTHON:return zf;default:return lf}}function vh(t,e){if(t.length===0||e==null)throw new Error("No items to move");const n=Pa(e);if(t.some(({filename:s})=>de.getPath(s)===n))throw new Error("File already in the destination folder");if(t.some(s=>Gn(s)&&n.startsWith(de.makePath(s.filename))))throw new Error("Destination folder cannot be a child of a dragged folder");return{files:t,targetPath:n}}const gE=t=>{const{isMultiSelect:e=!1,table:n,onFocusChange:s=()=>{},onMove:i,onSelect:o,onSelectionChange:r=()=>{},renderItem:l=Ha,rowHeight:a=qd,overscanCount:d=bn.DEFAULT_OVERSCAN}=t,[c,u]=S.exports.useState(()=>({items:[],offset:0,itemCount:0})),[m,p]=S.exports.useState({top:0,bottom:0}),[g,f]=S.exports.useState(),[b,C]=S.exports.useState(),[w,T]=S.exports.useState(),[E,y]=S.exports.useState([]),I=S.exports.useRef(null),D=S.exports.useRef(null),N=S.exports.useCallback(J=>{if(J.length===0||c==null)return[];const me=[];for(let fe=0;fe<J.length;fe+=1){const xe=J[fe];for(let _e=xe[0];_e<=xe[1];_e+=1)_e>=c.offset&&_e<c.offset+c.items.length&&me.push(c.items[_e-c.offset])}return me},[c]),x=S.exports.useCallback(J=>{const me=N([[J,J]]);if(me.length>0)return me[0]},[N]),U=S.exports.useCallback(()=>{const J=fn.count(E);if(J===0)return null;if(J===1){const me=E[0][0],fe=x(me);if(fe!=null)return fe.filename}return`${J} items`},[x,E]),$=S.exports.useCallback(J=>{var me;if(!(!b||!g)){xt.debug("dropItems",b,"to",J);try{const{files:fe,targetPath:xe}=vh(b,g);i(fe,xe),J!=null&&(y([[J,J]]),(me=I.current)==null||me.focusItem(J))}catch(fe){xt.error("Unable to complete move",fe)}}},[b,g,i]),L=S.exports.useCallback((J,me)=>{const fe=c.items[J-c.offset];fe!==void 0&&(xt.debug("handleItemClick",fe),o(fe,me),Gn(fe)&&(n==null||n.setExpanded(fe.filename,!fe.isExpanded)))},[c,o,n]),H=S.exports.useCallback((J,me)=>{var _e;xt.debug2("handleItemDragStart",J,E);let fe=E;fn.isSelected(E,J)||(fe=[[J,J]],y(fe)),C(N(fe)),(_e=I.current)==null||_e.resetMouseState();const xe=document.createElement("div");xe.innerHTML=`<div class="dnd-placeholder-content">${U()}</div>`,xe.className="file-list-dnd-placeholder",document.body.appendChild(xe),me.dataTransfer.setDragImage(xe,0,0),me.dataTransfer.effectAllowed="move",T(xe)},[U,N,E]),O=S.exports.useCallback((J,me)=>{me.preventDefault(),xt.debug2("handleItemDragOver",me),f(x(J))},[x]),F=S.exports.useCallback((J,me)=>{xt.debug("handleItemDragEnd",J),w==null||w.remove(),C(void 0),f(void 0),T(void 0)},[w]),_=S.exports.useCallback((J,me)=>{$(J)},[$]),k=S.exports.useCallback(()=>{xt.debug2("handleItemDragExit"),f(void 0)},[]),V=S.exports.useCallback(J=>{J.target instanceof Element&&J.target.classList.contains(wh)&&(J.preventDefault(),xt.debug2("handleListDragOver",J),f({type:"directory",filename:"/",basename:"/",id:"/"}))},[]),W=S.exports.useCallback(J=>{J.target instanceof Element&&J.target.classList.contains(wh)&&(xt.debug("handleListDrop"),$())},[$]),j=S.exports.useCallback(J=>{if(xt.debug2("handleSelectionChange",J),J!==E){y(J);const me=N(J);r(me)}},[N,r,E]),ee=S.exports.useCallback(J=>{if(xt.debug2("handleFocusChange",J),J!=null){const[me]=N([[J,J]]);s(me)}else s()},[N,s]),ve=S.exports.useCallback((J,me)=>{xt.debug("handleViewportChange",J,me),(J!==m.top||me!==m.bottom)&&p({top:J,bottom:me})},[m]),le=S.exports.useMemo(()=>{if(!b||!g)return!1;try{return vh(b,g),xt.debug("handleValidateDropTarget true"),!0}catch{return xt.debug("handleValidateDropTarget false"),!1}},[b,g]),{focusedPath:Se}=t;S.exports.useEffect(()=>{Se!==void 0&&(Se==="/"?n.collapseAll():(n.setExpanded(Se,!1),n.setExpanded(Se,!0)))},[n,Se]),S.exports.useEffect(function(){xt.debug("updating table viewport",m),n==null||n.setViewport({top:Math.max(0,m.top-d),bottom:m.bottom+d})},[d,n,m]),S.exports.useEffect(function(){const me=n.onUpdate(fe=>{u({items:fe.items.map(xe=>({...xe,itemName:xe.basename})),offset:fe.offset,itemCount:n.size})});return()=>{me()}},[n]),S.exports.useEffect(function(){if(g!=null&&Gn(g)&&g.filename!=="/"){const me=setTimeout(()=>{g.isExpanded||n==null||n.setExpanded(g.filename,!0)},mE);return()=>clearTimeout(me)}},[g,n]);const Oe=S.exports.useCallback(J=>l({...J,isDragInProgress:b!=null,dropTargetItem:g,draggedItems:b,isDropTargetValid:le,onDragStart:H,onDragEnd:F,onDragOver:O,onDragExit:k,onDrop:_}),[F,k,O,H,_,b,g,le,l]);return h("div",{ref:D,className:z("file-list",{"is-dragging":b!=null}),onDragOver:V,onDrop:W,children:h(bn,{ref:I,items:c.items,itemCount:c.itemCount,offset:c.offset,onFocusChange:ee,onSelect:L,onSelectionChange:j,onViewportChange:ve,selectedRanges:E,renderItem:Oe,rowHeight:a,isMultiSelect:e,isDragSelect:!1,isDeselectOnClick:!1})})};const fE={name:"File Explorer",DELETE:Be.createAndAdd({id:"FILE_EXPLORER.DELETE",name:"Delete",shortcut:[pe.DELETE],macShortcut:[ue.CMD,pe.BACKSPACE]}),RENAME:Be.createAndAdd({id:"FILE_EXPLORER.RENAME",name:"Rename",shortcut:[pe.ENTER],macShortcut:[pe.ENTER]})},Th={FILE_EXPLORER:fE};const Eh=X.module("FileListItemEditor"),CE=({item:t,onCancel:e,onSubmit:n,validate:s=()=>Promise.resolve()})=>{const i=S.exports.useRef(null),[o,r]=S.exports.useState(t.basename),[l,a]=S.exports.useState(),[d,c]=S.exports.useState(Promise.resolve()),u=S.exports.useCallback(()=>{var C;(C=i.current)==null||C.focus()},[i]),m=S.exports.useCallback(C=>C.stopPropagation(),[]),p=S.exports.useCallback(()=>{d.then(()=>{n(o)}).catch(C=>Eh.info("Unable to validate name",C))},[n,o,d]);S.exports.useEffect(function(){const w=Ee.makeCancelable(s(o));return w.then(()=>a(void 0)).catch(T=>{Ee.isCanceled(T)||a(T)}),c(w),()=>w.cancel()},[s,o]),S.exports.useEffect(function(){u()},[u]);const g=S.exports.useCallback(()=>{Eh.debug2("handleBlur"),p()},[p]),f=S.exports.useCallback(C=>{const{value:w}=C.target;r(w)},[]),b=S.exports.useCallback(C=>{C.stopPropagation();const{key:w}=C;switch(w){case"Enter":{p();break}case"Escape":{e();break}}},[e,p]);return v("div",{className:"file-list-item-editor",children:[h("input",{type:"text",className:z("form-control file-list-item-editor-input",{"is-invalid":l}),value:o,ref:i,onBlur:g,onKeyDown:b,onChange:f,onClick:m,onDoubleClick:m,onMouseDown:m}),l&&h("div",{className:"invalid-feedback",children:`${l}`})]})},Cp=t=>{const{isMultiSelect:e=!1,focusedPath:n,showContextMenu:s=!1,onCreateFile:i,onCreateFolder:o,onCopy:r,onDelete:l,onMove:a=()=>{},onRename:d,onSelect:c,onSelectionChange:u,table:m,rowHeight:p=qd,validateRename:g=()=>Promise.resolve()}=t,[f,b]=S.exports.useState(),[C,w]=S.exports.useState([]),[T,E]=S.exports.useState(),y=S.exports.useCallback(k=>{w(k),u==null||u(k)},[u]),I=S.exports.useCallback(k=>{E(k)},[]),D=S.exports.useCallback(()=>{T&&(r==null||r(T))},[T,r]),N=S.exports.useCallback(()=>{C.length>0&&(l==null||l(C))},[l,C]),x=S.exports.useCallback(()=>{i==null||i()},[i]),U=S.exports.useCallback(()=>{T&&(o==null||o(de.getPath(T.filename)))},[T,o]),$=S.exports.useCallback(()=>{T&&b(T)},[T]),L=S.exports.useCallback(()=>{b(void 0)},[]),H=S.exports.useCallback(k=>{f&&(d==null||d(f,k),b(void 0))},[d,f]),O=S.exports.useMemo(()=>{if(f)return[];const k=[];return i&&k.push({title:"New File",description:"Create new file",action:x,group:ie.groups.medium}),o&&k.push({title:"New Folder",description:"Create new folder",action:U,group:ie.groups.medium}),r&&k.push({title:"Copy",description:"Copy",action:D,group:ie.groups.low,disabled:T==null||Gn(T)}),l&&C.length>0&&k.push({title:"Delete",description:"Delete",shortcut:Th.FILE_EXPLORER.DELETE,action:N,group:ie.groups.low}),d&&k.push({title:"Rename",description:"Rename",shortcut:Th.FILE_EXPLORER.RENAME,action:$,group:ie.groups.low,disabled:T==null}),k},[D,N,x,U,$,T,r,i,o,l,d,C,f]),F=S.exports.useCallback(k=>f?g(f,k):Promise.reject(new Error("No rename item")),[f,g]),_=S.exports.useCallback(k=>{const{item:V}=k;return f&&f.filename===V.filename?Ha({...k,children:h(CE,{item:V,validate:F,onSubmit:H,onCancel:L})}):Ha(k)},[L,H,f,F]);return v("div",{className:"file-list-container",children:[m!=null&&h(gE,{onMove:a,onSelect:c,onSelectionChange:y,onFocusChange:I,renderItem:_,rowHeight:p,table:m,isMultiSelect:e,focusedPath:n}),s&&h(ie,{actions:O})]})};Cp.displayName="FileListContainer";class Or extends Oi{constructor(e){super("Name already exists"),this.isExistingFile=!0,this.info=e}}class Yd extends Error{constructor(){super("No file exists at the path specified"),this.isFileNotFound=!0}}const Ws=X.module("FileExplorer"),Xd=t=>{const{storage:e,isMultiSelect:n=!1,focusedPath:s,onDelete:i=()=>{},onRename:o=()=>{},onSelect:r,onSelectionChange:l,rowHeight:a=qd}=t,[d,c]=S.exports.useState([]),[u,m]=S.exports.useState();S.exports.useEffect(function(){let D;async function N(){Ws.debug("initTable"),D=Ee.makeCancelable(e.getTable(),x=>x.close());try{m(await D)}catch(x){Ee.isCanceled(x)||Ws.error("Unable to initialize table",x)}}return N(),()=>{D.cancel()}},[e]);const p=S.exports.useCallback(I=>{Ee.isCanceled(I)||Ws.error(I)},[]),g=S.exports.useCallback(I=>{Ws.debug("handleDelete, pending confirmation",I),c(I)},[]),f=S.exports.useCallback(()=>{Ws.debug("handleDeleteConfirm",d),d.forEach(I=>e.deleteFile(Gn(I)?de.makePath(I.filename):I.filename)),i(d),c([])},[d,i,e]),b=S.exports.useCallback(()=>{Ws.debug("handleDeleteCancel"),c([])},[]),C=S.exports.useCallback((I,D)=>{de.reducePaths(I.map(x=>Gn(x)?de.makePath(x.filename):x.filename)).forEach(x=>{const U=de.isPath(x)?`${D}${de.getBaseName(x.substring(0,x.length-1))}/`:`${D}${de.getBaseName(x)}`;e.moveFile(x,U).then(()=>{o(x,U)}).catch(p)})},[p,o,e]),w=S.exports.useCallback((I,D)=>{let N=I.filename;const x=Gn(I);x&&!N.endsWith("/")&&(N=`${N}/`);let U=`${de.getParent(N)}${D}`;x&&!U.endsWith("/")&&(U=`${U}/`),Ws.debug2("handleRename",N,U),e.moveFile(N,U).catch(p),o(N,U)},[p,o,e]),T=S.exports.useCallback(async(I,D)=>{if(D===I.basename)return;de.validateName(D);const N=`${de.getPath(I.filename)}${D}`;try{const x=await e.info(N);throw new Or(x)}catch(x){if(!(x instanceof Yd))throw x}},[e]),E=d.length>0,y=S.exports.useMemo(()=>d.length===1?`Are you sure you want to delete "${d[0].filename}"?`:"Are you sure you want to delete the selected files?",[d]);return v("div",{className:"file-explorer",children:[u&&h(Cp,{isMultiSelect:n,focusedPath:s,showContextMenu:!0,onMove:C,onDelete:g,onRename:w,onSelect:r,onSelectionChange:l,rowHeight:a,table:u,validateRename:T}),h(Hi,{isOpen:E,headerText:y,bodyText:"You cannot undo this action.",onCancel:b,onConfirm:f,confirmButtonText:"Delete"})]})};Xd.displayName="FileExplorer";const Gs=X.module("NewItemModal"),Ar=class extends S.exports.PureComponent{constructor(t){super(t),this.inputRef=Y.createRef(),this.pending=new ps,this.pathMap=new Map,this.isInitialLoad=!0,this.handleModalSubmit=this.handleModalSubmit.bind(this),this.handleModalOpened=this.handleModalOpened.bind(this),this.handleSelect=this.handleSelect.bind(this),this.handleChange=this.handleChange.bind(this),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleValidationError=this.handleValidationError.bind(this),this.handleOverwriteCancel=this.handleOverwriteCancel.bind(this),this.handleOverwriteConfirm=this.handleOverwriteConfirm.bind(this),this.handleExtensionChangeCancel=this.handleExtensionChangeCancel.bind(this),this.handleExtensionChangeConfirm=this.handleExtensionChangeConfirm.bind(this),this.handleBreadcrumbSelect=this.handleBreadcrumbSelect.bind(this);const{defaultValue:e}=t,n=de.hasPath(e)?de.getPath(e):"/";this.state={isSubmitting:!1,path:n,prevExtension:de.getExtension(e),showExtensionChangeModal:!1,showOverwriteModal:!1,value:de.getBaseName(e)}}static getValidationMessage(t){return t instanceof Or&&t.info.type==="directory"?"Error: Cannot overwrite existing directory":`${t}`}static handleError(t){Ee.isCanceled(t)||Gs.error(t)}componentDidUpdate(t,e){const{isOpen:n}=this.props,{isOpen:s}=t,{value:i,path:o}=this.state;!s&&n&&(this.resetValue(),this.isInitialLoad=!0),s&&n&&(!this.isInitialLoad&&(o!==e.path||i!==e.value)&&this.updateValidationStatus(o,i),this.isInitialLoad=!1)}componentWillUnmount(){this.pending.cancel(),this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableExistingItemPromise&&this.cancelableExistingItemPromise.cancel()}resetValue(){const{defaultValue:t}=this.props,e=de.hasPath(t)?de.getPath(t):"/";this.setState({path:e,value:de.getBaseName(t),validationError:void 0,prevExtension:de.getExtension(t),isSubmitting:!1})}getValidationPromise(t,e,n=!1){return this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableValidatePromise=Ee.makeCancelable(this.validateName(t,e,n)),this.cancelableValidatePromise}async validateName(t,e,n){de.validateName(e);const{defaultValue:s,storage:i}=this.props;if(n){const o=`${t}${e}`;if(o!==s)try{const r=await i.info(o);throw new Or(r)}catch(r){if(!(r instanceof Yd))throw r}}return e}updateValidationStatus(t,e){this.getValidationPromise(t,e).then(()=>{this.setState({validationError:void 0})}).catch(this.handleValidationError).catch(Ar.handleError)}handleModalOpened(){this.focusRenameInput()}handleModalSubmit(){this.submitModal()}handleChange(t){const{value:e}=t.target;this.setState({value:e})}handleSelect(t){if(Gs.debug("handleSelect",t),t.type==="directory")this.setState({path:de.makePath(t.filename)});else{const e=t.basename,n=de.getPath(t.filename);this.setState({value:e,path:n},()=>{this.focusRenameInput()})}}handleKeyDown(t){const{key:e}=t;switch(t.stopPropagation(),e){case"Enter":{t.preventDefault(),this.submitModal();break}case"Escape":{t.preventDefault();const{onCancel:n}=this.props;n();break}}}handleValidationError(t){if(!(t instanceof Oi))throw t;Gs.debug("Validation error",t),this.setState({validationError:t})}handleOverwriteCancel(){this.setState({showOverwriteModal:!1,isSubmitting:!1})}handleOverwriteConfirm(){this.setState({showOverwriteModal:!1});const{onSubmit:t}=this.props,{path:e,value:n}=this.state;Gs.debug("handleOverwriteConfirm",e,n),t(`${e}${n}`)}handleExtensionChangeCancel(){Gs.debug("handleExtensionChangeCancel"),this.setState(({value:t,prevExtension:e})=>{const n=de.replaceExtension(t,e);return{showExtensionChangeModal:!1,value:n}}),this.submitModal(!0)}handleExtensionChangeConfirm(){Gs.debug("handleExtensionChangeConfirm"),this.setState({showExtensionChangeModal:!1}),this.submitModal(!0)}focusRenameInput(){const t=this.inputRef.current;if(t){const{type:e}=this.props,{value:n}=t,s=e==="directory"?n.length:n.lastIndexOf(".");t.focus(),t.setSelectionRange(0,s>0?s:n.length)}}submitModal(t=!1){this.setState(({prevExtension:e,value:n,path:s})=>{const{notifyOnExtensionChange:i,type:o}=this.props;Gs.debug("submitModal",e,n);const r=de.getExtension(n);return i&&!t&&e!==null&&e!==r?{isSubmitting:!1,showExtensionChangeModal:!0,newExtension:r}:(this.getValidationPromise(s,n,!0).then(l=>{const{onSubmit:a}=this.props;a(`${s}${n}`)}).catch(l=>{if(l instanceof Or&&o!=="directory"&&l.info.type!=="directory"){this.setState({showOverwriteModal:!0});return}throw l}).catch(l=>{throw Ee.isCanceled(l)&&this.setState({isSubmitting:!1}),l}).catch(this.handleValidationError).catch(Ar.handleError),{isSubmitting:!0,showExtensionChangeModal:!1,newExtension:void 0})})}handleBreadcrumbSelect(t){this.setState({path:t})}renderPathButtons(t){const e=t.split("/");return e.pop(),e.map((n,s)=>{let i="";for(let o=0;o<s;o+=1)i+=`${e[o]}/`;return i+=`${n}/`,v(Y.Fragment,{children:[h(Q,{kind:"ghost",className:"directory-breadcrumbs",onClick:()=>this.handleBreadcrumbSelect(i),"aria-label":s===0?"Home":void 0,icon:s===0?h(q,{icon:uf,transform:"right-1.6"}):void 0,tooltip:s===0?"Home":void 0,children:n}),"/"]},i)})}render(){const{storage:t,isOpen:e,onCancel:n,placeholder:s,title:i,type:o}=this.props,{isSubmitting:r,path:l,showExtensionChangeModal:a,showOverwriteModal:d,validationError:c,value:u,prevExtension:m,newExtension:p}=this.state,g=o==="directory",f=de.fileExtensionToString(m),b=de.fileExtensionToString(p),C=g?"Create":"Save",w=g?"New folder name":"Save file as";return v(he,{children:[v(Oo,{isOpen:e,toggle:n,onOpened:this.handleModalOpened,className:"modal-dialog-centered new-file-modal theme-bg-dark",children:[h(Po,{toggle:n,children:i}),h(Ao,{children:h("form",{children:v("div",{className:"d-flex flex-column new-file-modal-content",children:[v("div",{className:"flex-grow-0 mb-4",children:[h("label",{htmlFor:"file-name-input",children:w}),h("input",{id:"file-name-input",type:"text",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:"false",className:z("form-control",{"is-invalid":c}),value:u,placeholder:s,ref:this.inputRef,onKeyDown:this.handleKeyDown,onChange:this.handleChange}),c&&h("div",{className:"invalid-feedback",children:Ar.getValidationMessage(c)})]}),v("div",{className:"flex-grow-0",children:[h("label",{children:"Directory: /"}),this.renderPathButtons(l)]}),h("div",{className:"flex-grow-1 file-explorer-container",children:h(Xd,{onSelect:this.handleSelect,storage:t,focusedPath:l})})]})})}),v(Za,{children:[h(Q,{kind:"secondary",onClick:n,children:"Cancel"}),h(Q,{kind:"primary",disabled:r,onClick:this.handleModalSubmit,children:C})]})]}),h(Hi,{isOpen:d,headerText:"Confirm overwrite",bodyText:"File with this name already exists, are you sure you want to overwrite it?",onCancel:this.handleOverwriteCancel,onConfirm:this.handleOverwriteConfirm,cancelButtonText:"Cancel",confirmButtonText:"Overwrite"}),h(Hi,{isOpen:a,headerText:"Confirm extension change",bodyText:`Are you sure you want to change extension from "${f}" to "${b}"?`,onCancel:this.handleExtensionChangeCancel,onConfirm:this.handleExtensionChangeConfirm,cancelButtonText:`Keep "${f}"`,confirmButtonText:`Use "${b}"`})]})}};let Al=Ar;Al.propTypes={isOpen:R.exports.bool,title:R.exports.string.isRequired,defaultValue:R.exports.string,type:R.exports.oneOf(["file","directory"]).isRequired,onSubmit:R.exports.func,onCancel:R.exports.func,placeholder:R.exports.string,storage:R.exports.shape({}).isRequired,notifyOnExtensionChange:R.exports.bool};Al.defaultProps={isOpen:!1,defaultValue:"/",notifyOnExtensionChange:!1,placeholder:"",onSubmit:t=>{},onCancel:()=>{}};const bE=({createFile:t,createFolder:e,onSearchChange:n,defaultSearchText:s=""})=>v("div",{className:"file-explorer-toolbar",children:[v("div",{className:"file-explorer-toolbar-buttons",children:[h(Q,{kind:"ghost",icon:iu,tooltip:"New notebook",onClick:t,"aria-label":"New notebook"}),h(Q,{kind:"ghost",icon:wf,tooltip:"New folder",onClick:e,"aria-label":"New folder"})]}),n&&h("div",{className:"file-explorer-toolbar-search",children:h(yu,{value:s,onChange:n,placeholder:"Search by name"})})]});const Ii=X.module("FileExplorerPanel"),SE=(t,e)=>{const n=nm(t),s=gi(t,e.localDashboardId),{session:i,config:o}=s!=null?s:{},r=o==null?void 0:o.type;return{fileStorage:n,language:r,session:i}},wE=Mt(SE,null,null,{forwardRef:!0});function vE(t){const e=t;return e!=null&&typeof e.button=="number"}const Va=class extends Y.Component{static handleError(t){Ii.error(t)}static isFocusEvent(t){return vE(t)?t.detail>=2:!0}constructor(t){super(t),this.handleFileSelect=this.handleFileSelect.bind(this),this.handleCreateFile=this.handleCreateFile.bind(this),this.handleCreateDirectory=this.handleCreateDirectory.bind(this),this.handleCreateDirectoryCancel=this.handleCreateDirectoryCancel.bind(this),this.handleCreateDirectorySubmit=this.handleCreateDirectorySubmit.bind(this),this.handleDelete=this.handleDelete.bind(this),this.handleRename=this.handleRename.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSelectionChange=this.handleSelectionChange.bind(this);const{session:e,language:n}=t;this.state={isShown:!1,language:n,session:e,showCreateFolder:!1,focusedFilePath:"/"}}componentDidMount(){this.isHidden()||this.setState({isShown:!0})}handleCreateFile(){const{glEventHub:t}=this.props,{session:e,language:n}=this.state,s={language:n,value:""};Ii.debug("handleCreateFile",e,n,s),t.emit(He.CREATE_NOTEBOOK,e,n,s)}handleCreateDirectory(t){this.setState({showCreateFolder:!0})}handleCreateDirectoryCancel(){Ii.debug("handleCreateDirectoryCancel"),this.setState({showCreateFolder:!1})}handleCreateDirectorySubmit(t){Ii.debug("handleCreateDirectorySubmit",t),this.setState({showCreateFolder:!1});const{fileStorage:e}=this.props;e.createDirectory(t).catch(Va.handleError)}handleDelete(t){const{glEventHub:e}=this.props;t.forEach(n=>{e.emit(He.CLOSE_FILE,{id:n.filename,itemName:n.filename})})}handleSelectionChange(t){let e="/";t.length===1&&(t[0].type==="directory"?e=de.makePath(t[0].filename):e=de.getPath(t[0].filename)),this.setState({focusedFilePath:e})}handleFileSelect(t,e){if(Ii.debug("fileSelect",t),t.type==="directory")return;const n=Va.isFocusEvent(e),s={id:t.filename,itemName:t.filename},{glEventHub:i}=this.props,{session:o,language:r}=this.state,l={value:null,language:r};i.emit(He.SELECT_NOTEBOOK,o,r,l,s,n)}handleRename(t,e){const{glEventHub:n}=this.props;Ii.debug("handleRename",t,e),n.emit(He.RENAME_FILE,t,e)}handleSessionOpened(t,{language:e}){this.setState({session:t,language:e})}handleSessionClosed(){this.setState({session:void 0,language:void 0})}handleShow(){this.setState({isShown:!0})}isHidden(){const{glContainer:t}=this.props,{isHidden:e}=t;return e}render(){const{fileStorage:t,glContainer:e,glEventHub:n}=this.props,{isShown:s,showCreateFolder:i,focusedFilePath:o}=this.state;return v(Yn,{className:"file-explorer-panel",componentPanel:this,glContainer:e,glEventHub:n,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[h(bE,{createFile:this.handleCreateFile,createFolder:this.handleCreateDirectory}),s&&h(Xd,{isMultiSelect:!0,storage:t,onDelete:this.handleDelete,onRename:this.handleRename,onSelect:this.handleFileSelect,onSelectionChange:this.handleSelectionChange}),h(Al,{isOpen:i,type:"directory",title:"Create New Folder",storage:t,onSubmit:this.handleCreateDirectorySubmit,onCancel:this.handleCreateDirectoryCancel,defaultValue:o})]})}};let jd=Va;jd.COMPONENT="FileExplorerPanel";jd.TITLE="File Explorer";const Jr=wE(jd);const it=X.module("FilterSetManager"),TE="Enter name...",yh="No Available Filter Sets";class el extends S.exports.Component{constructor(e){super(e),this.renameInputRef=Y.createRef(),this.dropdownRef=Y.createRef(),this.editDropdownRef=Y.createRef(),this.isRenamingExistingSet=ge((n,s)=>s!==void 0&&n.some(({id:i})=>i===s.id)),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.handleEditDropdownChange=this.handleEditDropdownChange.bind(this),this.handleFilterChange=this.handleFilterChange.bind(this),this.handleFilterApply=this.handleFilterApply.bind(this),this.handleCaptureNewSet=this.handleCaptureNewSet.bind(this),this.handleNameInputChange=this.handleNameInputChange.bind(this),this.handleNameInputKeyPress=this.handleNameInputKeyPress.bind(this),this.handleRenameConfirm=this.handleRenameConfirm.bind(this),this.handleRenameCancel=this.handleRenameCancel.bind(this),this.handleRestoreFullStateChange=this.handleRestoreFullStateChange.bind(this),this.handleSetDelete=this.handleSetDelete.bind(this),this.handleSetEdit=this.handleSetEdit.bind(this),this.handleSetUpdate=this.handleSetUpdate.bind(this),this.state={editId:void 0,renameSet:void 0,nameInputValue:"",nameInputError:void 0,modifiedFilterSets:[],restoreFullState:!1}}static animateScreenFlash(){var n;const e=document.createElement("div");e.classList.add("screen-flash-overlay"),e.addEventListener("animationend",()=>{e.remove()}),(n=document.querySelector("body"))==null||n.appendChild(e)}componentDidMount(){const{isValueShown:e}=this.props;e?this.updateSelectedId():this.initSettingsScreen()}componentDidUpdate(e,n){const{isValueShown:s,filterSets:i}=this.props,{modifiedFilterSets:o}=this.state;if(e.isValueShown&&!s&&this.initSettingsScreen(),this.isNameInputScreen()&&!this.isNameInputScreen(n)&&this.focusRenameInput(),i!==e.filterSets)if(!s&&i.length>0&&e.filterSets.length===0&&o.length===0){const{onChange:r}=this.props;r({isValueShown:!0,selectedId:i[0].id})}else this.updateSelectedId()}initSettingsScreen(){const{filterSets:e,selectedId:n}=this.props;it.debug("initSettingsScreen",e,n),this.setState({modifiedFilterSets:[...e],editId:n})}updateSelectedId(){const{isValueShown:e,filterSets:n,selectedId:s,onChange:i}=this.props;if(it.debug("updateSelectedId",n,s),!!e&&!n.some(({id:o})=>o===s)){const o=n.length===0;i({isValueShown:!o,selectedId:o?void 0:n[0].id})}}handleEditDropdownChange(e){const{value:n}=e.target;this.setState({editId:n})}handleFilterChange(e){const{value:n}=e.target,{isValueShown:s,onChange:i}=this.props;this.applyFilterSet(n),i({isValueShown:s,selectedId:n})}handleFilterApply(){const{selectedId:e}=this.props;this.applyFilterSet(e)}handleSettingsCancel(){const{onChange:e,selectedId:n,filterSets:s}=this.props;this.setState({modifiedFilterSets:[]}),s.length>0&&e({isValueShown:!0,selectedId:n})}handleSettingsSave(){const{onChange:e,onUpdateSets:n}=this.props,{modifiedFilterSets:s,editId:i}=this.state;this.setState({modifiedFilterSets:[]}),it.debug("Update sets",s,i),n(s),s.length>0&&e({isValueShown:!0,selectedId:i})}handleCaptureNewSet(){const{getFilterState:e}=this.props;el.animateScreenFlash();const n=We(),s=e(),i={id:n,title:"",panels:s};it.debug("handleSetCreate",i),this.setState({nameInputValue:"",nameInputError:void 0,renameSet:i})}handleRenameCancel(){this.setState({renameSet:void 0})}handleRestoreFullStateChange(e){this.setState({restoreFullState:e.target.value==="true"})}getNameError(e){var o;const{renameSet:n,modifiedFilterSets:s}=this.state,i=(o=e==null?void 0:e.trim())!=null?o:"";if(i.length===0)return it.debug("Name cannot be empty",i),"Name cannot be empty";if(n!==void 0&&s.some(({title:r,id:l})=>r===i&&l!==n.id))return it.debug("Set with this name already exists",i),"Set with this name already exists"}handleRenameConfirm(){var c;const{nameInputValue:e,renameSet:n,modifiedFilterSets:s,restoreFullState:i}=this.state;if(n===void 0){it.error("Renamed set undefined.");return}const o=this.getNameError(e);if(it.debug("handleRenameConfirm",e,o),o!==void 0){this.setState({nameInputError:o});return}const r=(c=e==null?void 0:e.trim())!=null?c:"",l={...n,title:r,restoreFullState:i},a=s.findIndex(({id:u})=>u===n.id),d=[...s];a>=0?(d[a]=l,it.debug("Renamed existing set",d)):(d.push(l),it.debug("Added new set to modified sets",d)),this.setState({editId:l.id,modifiedFilterSets:d,renameSet:void 0})}handleSetDelete(){this.setState(e=>{const{editId:n,modifiedFilterSets:s}=e,i=s.findIndex(({id:a})=>a===n);if(i<0)return it.error("Unable to find selected filterSet index",s,n),null;const o=s.filter(({id:a})=>a!==n),r=Math.max(0,Math.min(o.length-1,i-1)),l=o.length>0?o[r].id:void 0;return it.debug("Deleted selected set",n,s,o),it.debug("New selection",r,l),{modifiedFilterSets:o,editId:l}})}handleSetUpdate(){const{getFilterState:e}=this.props;el.animateScreenFlash();const n=e();this.setState(({modifiedFilterSets:s,editId:i})=>{if(i===void 0)return it.error("Filter for update not selected."),null;const o=[...s],r=o.findIndex(({id:l})=>l===i);return r<0?(it.error("Selected set for update not found."),null):(o[r]={...o[r],panels:n},it.debug("Update set",o,n),{modifiedFilterSets:o})})}handleSetEdit(){this.setState(({editId:e,modifiedFilterSets:n})=>{const s=n.find(({id:r})=>r===e);if(s===void 0)return it.error("Could not find selected set",e,n),null;const{title:i,restoreFullState:o=!1}=s;return{nameInputValue:i,nameInputError:void 0,renameSet:s,restoreFullState:o}})}handleSettingsClick(e){e.stopPropagation();const{onChange:n,selectedId:s}=this.props;n({isValueShown:!1,selectedId:s})}handleBackgroundClick(e){it.debug("handleBackgroundClick"),e.target!==this.dropdownRef.current&&this.focusInput()}handleNameInputChange(e){const{value:n}=e.target,s=this.getNameError(n);this.setState({nameInputValue:n,nameInputError:s})}handleNameInputKeyPress(e){const{key:n}=e;n==="Enter"&&(e.preventDefault(),this.handleRenameConfirm())}isNameInputScreen(e=this.state){const{renameSet:n}=e;return n!==void 0}applyFilterSet(e){const{onApply:n,filterSets:s}=this.props;if(e===void 0){it.debug("No filter selected");return}const i=s.find(({id:o})=>o===e);if(i===void 0){it.debug("Selected id not found in filterSets",e,s);return}it.debug("Apply filterSet",i),n(i)}focusInput(){var e;(e=this.dropdownRef.current)==null||e.focus()}focusRenameInput(){var e;(e=this.renameInputRef.current)==null||e.focus()}render(){const{nameInputValue:e,nameInputError:n,editId:s,renameSet:i,modifiedFilterSets:o,restoreFullState:r}=this.state,{isValueShown:l,filterSets:a,selectedId:d}=this.props,c=this.isNameInputScreen(),u=this.isRenamingExistingSet(o,i),m=o.length===0,p=!c&&m&&a.length===0,g=!c&&!p,f=v("div",{className:"fa-layers mr-3",children:[h(q,{icon:Fo,mask:wa,transform:"shrink-1 down-5 right-7"}),h(q,{icon:Ls,className:"text-primary",transform:"shrink-6 down-5 right-7"})]}),b=v("div",{className:"fa-layers",children:[h(q,{icon:Fo,mask:wa,transform:"shrink-1 down-5 right-7"}),h(q,{icon:Sa,transform:"shrink-1 down-5 right-7"})]});return h("div",{className:"filter-set-manager fill-parent-absolute",children:v(Ja,{className:"w-100 h-100",isFlipped:l,children:[h("div",{className:"filter-set-manager-settings-card fill-parent-absolute",children:v("div",{className:"filter-set-manager-card-content",children:[p&&v("div",{children:[h(Q,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:f,children:"Capture filter set"}),h("div",{className:"py-3 text-muted small",children:"Takes a snapshot of the currently applied filters on all panels, allowing you to restore saved filter sets later."})]}),c&&v("div",{className:"d-flex flex-column justify-content-center","data-testid":"edit-filter-set-container",children:[v("div",{className:"form-group",children:[h("label",{children:u?"Edit set":"Name captured set"}),v("div",{className:"name-input-container",children:[h("input",{type:"text",className:"input-set-name form-control",placeholder:TE,value:e,ref:this.renameInputRef,onChange:this.handleNameInputChange,onKeyPress:this.handleNameInputKeyPress,spellCheck:"false"}),h(Q,{"data-testid":"rename-confirm-button",kind:"ghost",className:"btn btn-link no-underline pt-2 pb-2",onClick:this.handleRenameConfirm,tooltip:"Save","test-id":"button-save",icon:ou}),h(Q,{"data-testid":"rename-cancel-button",kind:"ghost",className:"btn btn-link no-underline pt-2 pb-2",onClick:this.handleRenameCancel,tooltip:"Cancel",icon:of})]}),n!==void 0&&h("div",{className:"error-message",children:n})]}),h("div",{className:"form-group",children:v(pl,{onChange:this.handleRestoreFullStateChange,value:`${r}`,children:[h(Mn,{value:"false",children:"Restore only filters"}),h(Mn,{value:"true",children:"Restore full table state"})]})})]}),g&&v("div",{className:"filter-set-manager-settings-grid-1",children:[v("div",{className:"form-group",children:[h("label",{children:"Edit filter sets"}),v("div",{className:"filter-select-container",children:[v("select",{"data-testid":"settings-card-filter-select",ref:this.editDropdownRef,value:s!=null?s:"-1",className:"custom-select filter-value-select",onChange:this.handleEditDropdownChange,disabled:m,children:[m&&h("option",{value:"-1",disabled:!0,children:yh}),o.map(({id:C,title:w})=>h("option",{value:C,children:w},C))]}),h(Q,{kind:"ghost",onClick:this.handleSetUpdate,disabled:m,icon:b,tooltip:"Update"}),h(Q,{kind:"ghost",onClick:this.handleSetEdit,disabled:m,icon:ll,tooltip:"Edit"}),h(Q,{kind:"ghost",onClick:this.handleSetDelete,disabled:m,icon:xn,tooltip:"Delete"})]})]}),h("div",{children:h(Q,{kind:"ghost",className:"btn btn-link no-underline",onClick:this.handleCaptureNewSet,icon:f,children:"Capture new filter set"})}),v("div",{className:"py-3 text-right",children:[h(Q,{kind:"secondary",onClick:this.handleSettingsCancel,children:"Cancel"}),"\xA0",h(Q,{kind:"primary",onClick:this.handleSettingsSave,children:"Save"})]})]})]})},"front"),h("div",{className:"filter-set-manager-value-card fill-parent-absolute",onClick:this.handleBackgroundClick,children:v(he,{children:[h("div",{className:"filter-set-manager-column",children:h("div",{className:"filter-set-manager-column-title",children:"Filter sets"})}),h("div",{className:"filter-set-manager-card-content",children:h("div",{className:"filter-set-manager-value-input",children:v("div",{className:"filter-select-container",children:[v("select",{"data-testid":"value-card-filter-select",ref:this.dropdownRef,value:d,className:"custom-select filter-value-select",onChange:this.handleFilterChange,children:[a.length===0&&h("option",{value:"-1",disabled:!0,children:yh}),a.map(({id:C,title:w})=>h("option",{value:C,children:w},C))]}),h(Q,{"data-testid":"filter-apply-button",kind:"ghost",onClick:this.handleFilterApply,icon:od,tooltip:"Apply Filter Set"})]})})}),h("div",{className:"filter-set-manager-menu",children:h(Q,{kind:"ghost",className:"btn btn-link btn-link-icon m-2 px-2",onClick:this.handleSettingsClick,tooltip:"Settings",icon:h(q,{icon:Vo,transform:"grow-4"})})})]})},"back")]})})}}const Hn=X.module("IrisGridPanel"),EE=500,yE={IrisGrid:Ji,IrisGridTableModel:ap,ContextMenuRoot:pu};class Gi extends S.exports.PureComponent{constructor(e){super(e),this.getGridInputFilters=ge((s,i)=>se.getInputFiltersForColumns(s,i.filter(({value:o,excludePanelIds:r})=>{const l=te.getIdFromPanel(this);return o!=null&&(r==null||l!=null&&!r.includes(l))}))),this.getAlwaysFetchColumns=ge((s,i)=>{const o=te.getIdFromPanel(this),r=new Set(i);for(let l=0;l<s.length;l+=1){const{start:a}=s[l];a!=null&&a.panelId===o&&r.add(a.columnName)}return[...r]}),this.getPluginContent=ge((s,i,o,r,l)=>!i||!oi(i)||s==null||i.table==null?null:h("div",{className:"iris-grid-plugin",children:h(s,{ref:this.pluginRef,filter:this.handlePluginFilter,onFilter:this.handlePluginFilter,fetchColumns:this.handlePluginFetchColumns,onFetchColumns:this.handlePluginFetchColumns,table:i.table,user:o,panel:this,workspace:r,components:yE,onStateChange:this.handlePluginStateChange,pluginState:l})})),this.getDehydratedIrisGridPanelState=ge((s,i,o,r)=>se.dehydrateIrisGridPanelState(s,{isSelectingPartition:i,partition:o,partitionColumn:r})),this.getDehydratedIrisGridState=ge((s,i,o,r,l,a,d,c,u,m,p,g,f,b,C,w,T,E,y,I)=>se.dehydrateIrisGridState(s,{advancedFilters:o,aggregationSettings:T,customColumnFormatMap:r,isFilterBarShown:l,metrics:{userColumnWidths:C,userRowHeights:w},quickFilters:a,customColumns:d,reverseType:c,rollupConfig:u,showSearchBar:m,searchValue:p,selectDistinctColumns:g,selectedSearchColumns:f,sorts:i,invertSearchColumns:b,pendingDataMap:E,frozenColumns:y,conditionalFormats:I})),this.getDehydratedGridState=ge((s,i,o,r,l)=>se.dehydrateGridState(s,{isStuckToBottom:r,isStuckToRight:l,movedColumns:i,movedRows:o})),this.getCachedPanelState=ge((s,i,o,r)=>({irisGridPanelState:s,irisGridState:i,gridState:o,pluginState:r})),this.savePanelState=Xe(()=>{const{irisGridState:s,gridState:i,pluginState:o}=this;A(s);const{onPanelStateUpdate:r}=this.props,{model:l,panelState:a,isSelectingPartition:d,partition:c,partitionColumn:u}=this.state,{advancedFilters:m,aggregationSettings:p,customColumnFormatMap:g,isFilterBarShown:f,quickFilters:b,customColumns:C,reverseType:w,rollupConfig:T,showSearchBar:E,searchValue:y,selectDistinctColumns:I,selectedSearchColumns:D,sorts:N,invertSearchColumns:x,metrics:U,pendingDataMap:$,frozenColumns:L,conditionalFormats:H}=s;A(U);const{userColumnWidths:O,userRowHeights:F}=U;A(i);const{isStuckToBottom:_,isStuckToRight:k,movedColumns:V,movedRows:W}=i,j=this.getCachedPanelState(this.getDehydratedIrisGridPanelState(l,d,c,u),this.getDehydratedIrisGridState(l,N,m,g,f,b,C,w,T,E,y,I,D,x,O,F,p,$,L,H),this.getDehydratedGridState(l,V,W,_,k),o);j!==a&&(Hn.debug("Saving panel state",this,j),this.setState({panelState:j}),r==null||r(j))},EE),this.handleAdvancedSettingsChange=this.handleAdvancedSettingsChange.bind(this),this.handleColumnsChanged=this.handleColumnsChanged.bind(this),this.handleTableChanged=this.handleTableChanged.bind(this),this.handleColumnSelected=this.handleColumnSelected.bind(this),this.handleDataSelected=this.handleDataSelected.bind(this),this.handleError=this.handleError.bind(this),this.handleGridStateChange=this.handleGridStateChange.bind(this),this.handlePluginStateChange=this.handlePluginStateChange.bind(this),this.handlePartitionAppend=this.handlePartitionAppend.bind(this),this.handleCreateChart=this.handleCreateChart.bind(this),this.handleResize=this.handleResize.bind(this),this.handleShow=this.handleShow.bind(this),this.handleTabClicked=this.handleTabClicked.bind(this),this.handleDisconnect=this.handleDisconnect.bind(this),this.handleReconnect=this.handleReconnect.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.isColumnSelectionValid=this.isColumnSelectionValid.bind(this),this.handleContextMenu=this.handleContextMenu.bind(this),this.handlePluginFilter=this.handlePluginFilter.bind(this),this.handlePluginFetchColumns=this.handlePluginFetchColumns.bind(this),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.irisGrid=Y.createRef(),this.pluginRef=Y.createRef();const{panelState:n}=e;this.pluginState=null,this.state={error:null,isDisconnected:!1,isLoaded:!1,isLoading:!0,isModelReady:!1,model:void 0,advancedFilters:new Map,aggregationSettings:{aggregations:[],showOnTop:!1},advancedSettings:new Map(cw.DEFAULTS),customColumns:[],customColumnFormatMap:new Map,isFilterBarShown:!1,quickFilters:new Map,sorts:[],userColumnWidths:new Map,userRowHeights:new Map,reverseType:P.REVERSE_TYPE.NONE,movedColumns:[],movedRows:[],isSelectingPartition:!1,partition:void 0,partitionColumn:void 0,rollupConfig:void 0,showSearchBar:!1,searchValue:"",selectedSearchColumns:void 0,invertSearchColumns:!0,Plugin:void 0,pluginFilters:[],pluginFetchColumns:[],modelQueue:[],pendingDataMap:new Map,frozenColumns:void 0,panelState:n,irisGridStateOverrides:{},gridStateOverrides:{},isStuckToBottom:!1,isStuckToRight:!1,conditionalFormats:[],selectDistinctColumns:[]}}componentDidMount(){this.initModel()}componentDidUpdate(e,n){const{model:s}=this.state;s!==n.model&&(n.model!=null&&(this.stopModelListening(n.model),n.model.close()),s!=null&&this.startModelListening(s))}componentWillUnmount(){this.savePanelState.cancel(),this.modelPromise!=null&&(this.modelPromise.cancel(),this.modelPromise=void 0);const{model:e}=this.state;e&&(this.stopModelListening(e),e.close())}getTableName(){const{metadata:e}=this.props;return e.table}initModel(){this.setState({isModelReady:!1,isLoading:!0,error:null});const{makeModel:e}=this.props;this.modelPromise!=null&&this.modelPromise.cancel(),this.modelPromise=Ee.makeCancelable(e(),n=>n.close()),this.modelPromise.then(this.handleLoadSuccess).catch(this.handleLoadError)}handleLoadSuccess(e){const n=e,{panelState:s,irisGridStateOverrides:i}=this.state,o=[];if(s!=null){const{irisGridState:r}=s,{aggregationSettings:l,customColumns:a,selectDistinctColumns:d=[],rollupConfig:c}={...r,...i};a.length>0&&o.push(u=>{u.customColumns=a}),c!=null&&c.columns.length>0&&o.push(u=>{u.rollupConfig=se.getModelRollupConfig(u.originalColumns,c,l)}),d.length>0&&o.push(u=>{u.selectDistinctColumns=d})}this.setState({model:n,modelQueue:o}),this.initModelQueue(n,o)}initModelQueue(e,n){const s=e;if(n.length===0){this.modelInitialized(s);return}const i=n.shift();Hn.debug("initModelQueue",i),i&&i(s),this.setState({modelQueue:n})}handleAdvancedSettingsChange(e,n){Hn.debug("handleAdvancedSettingsChange",e,n),this.setState(({advancedSettings:s})=>s.get(e)===n?null:{advancedSettings:new Map(s).set(e,n)})}handlePluginFilter(e){const{model:n}=this.state;A(n);const{columns:s,formatter:i}=n,o=se.getFiltersFromInputFilters(s,e,i.timeZone);this.setState({pluginFilters:o})}handlePluginFetchColumns(e){this.setState({pluginFetchColumns:e})}handleContextMenu(e){var n,s,i;return(i=(s=(n=this.pluginRef.current)==null?void 0:n.getMenu)==null?void 0:s.call(n,e))!=null?i:[]}isColumnSelectionValid(e){const{columnSelectionValidator:n}=this.props;return n&&e?n(this,e):!1}handleGridStateChange(e,n){this.irisGridState=e,this.gridState=n,this.setState({isLoaded:!0,isLoading:!1}),this.savePanelState();const{glEventHub:s,onStateChange:i}=this.props;s.emit(wt.STATE_CHANGED,this),i==null||i(e,n)}handlePluginStateChange(e){const{irisGridState:n,gridState:s}=this;this.pluginState=e,n!==null&&s!==null&&this.savePanelState()}handleColumnsChanged(e){const{isModelReady:n,model:s,modelQueue:i}=this.state;n?this.sendColumnsChange(e.detail):(A(s),this.initModelQueue(s,i))}handleTableChanged(e){Hn.debug("handleTableChanged",e);const{glEventHub:n}=this.props,{detail:s}=e;n.emit(Pe.TABLE_CHANGED,this,s)}handlePartitionAppend(e,n){const{glEventHub:s}=this.props,{name:i}=e,o=this.getTableName(),r=`${o} = ${o}.where("${i}=\`${n}\`")`;s.emit(ft.SEND_COMMAND,r,!1,!0)}handleCreateChart(e,n){this.savePanelState.flush(),this.setState(()=>null,()=>{const{glEventHub:s,inputFilters:i,metadata:o}=this.props,{table:r}=o,{panelState:l}=this.state,a=te.getIdFromPanel(this);let d;l&&(d=se.extractTableSettings(l,i)),s.emit(wt.CREATE_CHART,{metadata:{settings:e,sourcePanelId:a,table:r,tableSettings:d},table:oi(n)?n.table:void 0})})}handleColumnSelected(e){const{glEventHub:n}=this.props;n.emit(wt.COLUMN_SELECTED,this,e)}handleDataSelected(e,n){const{glEventHub:s}=this.props;s.emit(wt.DATA_SELECTED,this,n)}handleResize(){this.updateGrid()}handleShow(){this.updateGrid()}handleTabClicked(){this.irisGrid.current&&this.irisGrid.current.focus()}handleError(e){Hn.error(e),this.setState({error:e,isLoading:!1})}handleDisconnect(){this.setState({error:new Error("Table disconnected"),isDisconnected:!0,isLoading:!1})}handleReconnect(){this.setState({isDisconnected:!1,error:null})}handleLoadError(e){Ee.isCanceled(e)||this.handleError(e)}modelInitialized(e){const{glEventHub:n,loadPlugin:s}=this.props;if(this.modelPromise=void 0,this.loadPanelState(e),this.setState({isModelReady:!0}),oi(e)){const{table:i}=e,{pluginName:o}=i;if(o!==""&&s!=null&&o!=null){const r=s(o);this.setState({Plugin:r})}n.emit(Pe.TABLE_CHANGED,this,i)}this.sendColumnsChange(e.columns)}handleClearAllFilters(){const e=this.irisGrid.current,{isDisconnected:n}=this.state;e!=null&&!n&&e.clearAllFilters()}sendColumnsChange(e){Hn.debug2("sendColumnsChange",e);const{glEventHub:n}=this.props;n.emit(Pe.COLUMNS_CHANGED,this,e)}startModelListening(e){e.addEventListener(be.EVENT.DISCONNECT,this.handleDisconnect),e.addEventListener(be.EVENT.RECONNECT,this.handleReconnect),e.addEventListener(be.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.addEventListener(be.EVENT.TABLE_CHANGED,this.handleTableChanged)}stopModelListening(e){e.removeEventListener(be.EVENT.DISCONNECT,this.handleDisconnect),e.removeEventListener(be.EVENT.RECONNECT,this.handleReconnect),e.removeEventListener(be.EVENT.COLUMNS_CHANGED,this.handleColumnsChanged),e.removeEventListener(be.EVENT.TABLE_CHANGED,this.handleTableChanged)}getCoordinateForColumn(e){var w,T,E;const{model:n}=this.state;if(!n)return null;const s=this.irisGrid.current,{gridWrapper:i}=s||{},o=(w=i==null?void 0:i.getBoundingClientRect())!=null?w:null;if(o==null||o.width<=0||o.height<=0)return null;A(s);const{metrics:r}=s.state;A(r);const{columnHeaderHeight:l,visibleColumnXs:a,visibleColumnWidths:d,right:c,columnHeaderMaxDepth:u}=r,m=n.getColumnIndexByName(e);A(m);const p=s.getVisibleColumn(m),g=(T=a.get(p))!=null?T:0,f=(E=d.get(p))!=null?E:0,b=Math.max(o.left,Math.min(p>c?o.right:o.left+g+f*.5,o.right)),C=o.top+l*u;return[b,C]}setFilterMap(e){const n=this.irisGrid.current;n!=null&&n.setFilterMap(e)}setAdvancedFilterMap(e){const n=this.irisGrid.current;n!=null&&n.setAdvancedFilterMap(e)}setFilters({quickFilters:e,advancedFilters:n}){Hn.debug("setFilters",e,n);const{model:s,isDisconnected:i}=this.state,o=this.irisGrid.current;if(o==null||i){Hn.debug("Ignore setFilters, model disconnected");return}A(s);const{columns:r,formatter:l}=s,a=se.changeFilterColumnNamesToIndexes(s.columns,e).filter(([c])=>s.isFilterable(c)),d=se.changeFilterColumnNamesToIndexes(s.columns,n).filter(([c])=>s.isFilterable(c));o.clearAllFilters(),o.setFilters({quickFilters:se.hydrateQuickFilters(r,a,l.timeZone),advancedFilters:se.hydrateAdvancedFilters(r,d,l.timeZone)})}setStateOverrides(e){Hn.debug("setStateOverrides",e);const{irisGridState:n,gridState:s}=e;this.setState({irisGridStateOverrides:n,gridStateOverrides:s},()=>{this.initModel()})}unsetFilterValue(){}loadPanelState(e){const{panelState:n,irisGridStateOverrides:s,gridStateOverrides:i}=this.state;if(n!=null)try{const{gridState:o,irisGridState:r,irisGridPanelState:l}=n,a={...s},{quickFilters:d,advancedFilters:c}=a;d&&(a.quickFilters=se.changeFilterColumnNamesToIndexes(e.columns,d)),c&&(a.advancedFilters=se.changeFilterColumnNamesToIndexes(e.columns,c));const{isSelectingPartition:u,partition:m,partitionColumn:p}=se.hydrateIrisGridPanelState(e,l),{advancedFilters:g,customColumns:f,customColumnFormatMap:b,isFilterBarShown:C,quickFilters:w,reverseType:T,rollupConfig:E,aggregationSettings:y,sorts:I,userColumnWidths:D,userRowHeights:N,showSearchBar:x,searchValue:U,selectDistinctColumns:$,selectedSearchColumns:L,invertSearchColumns:H,pendingDataMap:O,frozenColumns:F,conditionalFormats:_}=se.hydrateIrisGridState(e,{...r,...a}),{isStuckToBottom:k,isStuckToRight:V,movedColumns:W,movedRows:j}=se.hydrateGridState(e,{...o,...i},r.customColumns);this.setState({advancedFilters:g,conditionalFormats:_,customColumns:f,customColumnFormatMap:b,isFilterBarShown:C,isSelectingPartition:u,movedColumns:W,movedRows:j,partition:m,partitionColumn:p,quickFilters:w,reverseType:T,rollupConfig:E,aggregationSettings:y,sorts:I,userColumnWidths:D,userRowHeights:N,showSearchBar:x,searchValue:U,selectDistinctColumns:$,selectedSearchColumns:L,invertSearchColumns:H,pendingDataMap:O,frozenColumns:F,isStuckToBottom:k,isStuckToRight:V})}catch(o){Hn.error("loadPanelState failed to load panelState",n,o)}}updateGrid(){var n,s;const e=(s=(n=this.irisGrid.current)==null?void 0:n.grid)!=null?s:null;!e||e.handleResize()}render(){var Ht,Vt,kn;const{children:e,glContainer:n,glEventHub:s,columnSelectionValidator:i,getDownloadWorker:o,inputFilters:r,links:l,metadata:a,panelState:d,user:c,workspace:u,settings:m,theme:p}=this.props,{advancedFilters:g,aggregationSettings:f,advancedSettings:b,conditionalFormats:C,customColumns:w,customColumnFormatMap:T,error:E,isDisconnected:y,isFilterBarShown:I,isSelectingPartition:D,isStuckToBottom:N,isStuckToRight:x,isLoaded:U,isLoading:$,isModelReady:L,model:H,movedColumns:O,movedRows:F,partition:_,partitionColumn:k,quickFilters:V,reverseType:W,rollupConfig:j,sorts:ee,userColumnWidths:ve,userRowHeights:le,showSearchBar:Se,searchValue:Oe,selectDistinctColumns:J,selectedSearchColumns:me,invertSearchColumns:fe,Plugin:xe,pluginFilters:_e,pluginFetchColumns:un,pendingDataMap:Xn,frozenColumns:wn}=this.state,Ct=E!=null?`Unable to open table. ${E}`:void 0,{table:Re}=a,nt=(Ht=H==null?void 0:H.description)!=null?Ht:void 0,st=(Vt=d==null?void 0:d.pluginState)!=null?Vt:null,Nt=e!=null?e:this.getPluginContent(xe,H,c,u,st),{permissions:Yt}=c,{canCopy:Xt,canDownloadCsv:Ft}=Yt,jn=H==null?void 0:H.displayString((kn=H==null?void 0:H.rowCount)!=null?kn:0,"long");return v(kl,{errorMessage:Ct,isDisconnected:y,isLoading:$,isLoaded:U,className:"iris-grid-panel",glContainer:n,glEventHub:s,onClearAllFilters:this.handleClearAllFilters,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleShow,onTabClicked:this.handleTabClicked,widgetName:Re,widgetType:"Table",description:nt,componentPanel:this,renderTabTooltip:()=>h(_l,{widgetType:"Table",widgetName:Re,glContainer:n,description:nt,children:v("div",{className:"column-statistics-grid",children:[h("span",{className:"column-statistic-operation",children:"Number of Rows"}),h("span",{className:"column-statistic-value",children:jn})]})}),children:[L&&H&&h(Ji,{advancedFilters:g,aggregationSettings:f,advancedSettings:b,alwaysFetchColumns:this.getAlwaysFetchColumns(l,un),columnAllowedCursor:"linker",columnNotAllowedCursor:"not-allowed",customColumns:w,customColumnFormatMap:T,columnSelectionValidator:this.isColumnSelectionValid,conditionalFormats:C,inputFilters:this.getGridInputFilters(H.columns,r),applyInputFiltersOnInit:d==null,isFilterBarShown:I,isSelectingColumn:i!=null,isSelectingPartition:D,isStuckToBottom:N,isStuckToRight:x,movedColumns:O,movedRows:F,partition:_,partitionColumn:k,quickFilters:V,reverseType:W,rollupConfig:j,settings:m,sorts:ee,userColumnWidths:ve,userRowHeights:le,model:H,showSearchBar:Se,searchValue:Oe,selectedSearchColumns:me,selectDistinctColumns:J,invertSearchColumns:fe,onColumnSelected:this.handleColumnSelected,onCreateChart:this.handleCreateChart,onDataSelected:this.handleDataSelected,onError:this.handleError,onPartitionAppend:this.handlePartitionAppend,onStateChange:this.handleGridStateChange,onContextMenu:this.handleContextMenu,onAdvancedSettingsChange:this.handleAdvancedSettingsChange,customFilters:_e,pendingDataMap:Xn,canCopy:Xt,canDownloadCsv:Ft,ref:this.irisGrid,getDownloadWorker:o,frozenColumns:wn,theme:p,children:Nt}),!L&&h(he,{})]})}}Gi.defaultProps={onStateChange:()=>{},onPanelStateUpdate:()=>{}};Gi.displayName="IrisGridPanel";Gi.COMPONENT="IrisGridPanel";const IE=(t,{localDashboardId:e=Rn})=>({inputFilters:Ud(t,e),links:eo(t,e),columnSelectionValidator:zd(t,e),user:em(t),workspace:wl(t),settings:Kt(t)}),ci=Mt(IE,null,null,{forwardRef:!0})(Gi);const Ih=X.module("InputFilter"),RE=150,Ua=class extends S.exports.Component{constructor(t){super(t),this.getItemLabel=Te((i,o)=>{const{name:r,type:l}=i[o];if(o>0&&i[o-1].name===r||o<i.length-1&&i[o+1].name===r){const a=l.substring(l.lastIndexOf(".")+1);return`${r} (${a})`}return r}),this.sendUpdate=Xe(()=>{const{onChange:i}=this.props,{column:o,value:r,isValueShown:l}=this.state;i({column:o,isValueShown:l,value:r})},RE),this.handleColumnChange=this.handleColumnChange.bind(this),this.handleInputKeyPress=this.handleInputKeyPress.bind(this),this.handleValueChange=this.handleValueChange.bind(this),this.handleSettingsCancel=this.handleSettingsCancel.bind(this),this.handleSettingsClick=this.handleSettingsClick.bind(this),this.handleSettingsSave=this.handleSettingsSave.bind(this),this.handleBackgroundClick=this.handleBackgroundClick.bind(this),this.inputRef=Y.createRef();const{column:e,isValueShown:n,value:s}=t;this.state={column:e,selectedColumn:e,value:s,isValueShown:n}}componentDidUpdate(t,e){const{column:n}=this.props,{column:s,value:i,isValueShown:o}=this.state;n!==t.column&&this.setState({column:n,selectedColumn:n}),o!==void 0&&o&&o!==e.isValueShown&&this.focusInput(),(s!==e.column||i!==e.value||o!==e.isValueShown)&&this.sendUpdate()}componentWillUnmount(){this.sendUpdate.flush()}handleColumnChange(t){const{columns:e}=this.props,{value:n}=t.target,s=e[parseInt(n,10)];Ih.debug2("handleColumnChange",s),this.setState({selectedColumn:s,value:void 0})}handleInputKeyPress(t){t.key==="Enter"&&(t.preventDefault(),t.stopPropagation(),this.setState(({value:e})=>e==null?{value:""}:null,()=>{this.sendUpdate(),this.sendUpdate.flush()}))}handleValueChange(t){const{value:e}=t.target;Ih.debug2("handleValueChange",e),this.setState({value:e})}handleSettingsCancel(){const{column:t}=this.state;this.setState({selectedColumn:t,isValueShown:!0})}handleSettingsSave(){const{selectedColumn:t}=this.state;this.setState({column:t,isValueShown:!0})}handleSettingsClick(t){const{column:e}=this.state;this.setState({selectedColumn:e,isValueShown:!1}),t.stopPropagation()}handleBackgroundClick(t){t.target!==this.inputRef.current&&this.focusInput()}focusInput(){this.inputRef.current!==null&&(this.inputRef.current.select(),this.inputRef.current.focus())}clearFilter(){this.setState({value:""})}setFilterState({name:t,type:e,value:n,isValueShown:s}){const i=t!=null&&e!=null?{name:t,type:e}:void 0,o=s===void 0?{column:i,value:n}:{column:i,value:n,isValueShown:s};this.setState(o)}render(){const{columns:t}=this.props,{column:e,isValueShown:n,selectedColumn:s,value:i}=this.state,o=i==null||i.length===0?Ua.PLACEHOLDER.length:i.length;let r=null;if(e!=null){const l=t.findIndex(a=>a.name===e.name&&a.type===e.type);r=l>=0?this.getItemLabel(t,l):e.name}return v(Ja,{className:"input-filter fill-parent-absolute",isFlipped:n!=null?n:!1,children:[h("div",{className:"input-filter-settings-card",children:v("div",{className:"input-filter-settings-content",children:[v("div",{className:"input-filter-settings-grid",children:[h("label",{children:"Filter Column"}),v("select",{value:t.findIndex(l=>l.name===(s==null?void 0:s.name)&&l.type===(s==null?void 0:s.type)),className:"custom-select",onChange:this.handleColumnChange,children:[t.map((l,a)=>h("option",{value:a,children:this.getItemLabel(t,a)},`${l.name}/${l.type}`)),t.length===0&&h("option",{value:"-1",disabled:!0,children:"No Available Columns"})]}),h("div",{className:"text-muted small",children:"Input filter control will apply its filter to all columns matching this name in this dashboard."})]}),v("div",{className:"input-filter-settings-buttons",children:[h(Q,{kind:"secondary",onClick:this.handleSettingsCancel,disabled:e==null,children:"Cancel"}),h(Q,{kind:"primary",className:"ml-2",onClick:this.handleSettingsSave,disabled:s==null,children:"Save"})]})]})}),v("div",{className:"input-filter-value-card",onClick:this.handleBackgroundClick,children:[h("div",{className:"input-filter-column",children:v("div",{className:"input-filter-column-title",children:[r," Filter"]})}),h("div",{className:"d-flex justify-content-center align-items-center h-100 w-100",children:h("div",{className:"input-filter-value-input d-flex flex-column justify-content-center",children:h("input",{type:"text",ref:this.inputRef,placeholder:Ua.PLACEHOLDER,value:i!=null?i:"",onChange:this.handleValueChange,onKeyPress:this.handleInputKeyPress,style:{width:`${o+3}ch`},spellCheck:"false"})})}),h("div",{className:"input-filter-menu",children:h(Q,{kind:"ghost",className:"m-2 px-2",onClick:this.handleSettingsClick,icon:h(q,{icon:Vo,transform:"grow-4"}),tooltip:"Input Filter Settings"})})]})]})}};let Qd=Ua;Qd.PLACEHOLDER="Enter value...";Qd.defaultProps={column:null,isValueShown:!1,value:null};const DE=250;class Pl extends S.exports.Component{constructor(e){super(e),this.handleChange=Xe(this.handleChange.bind(this),DE),this.handleClearAllFilters=this.handleClearAllFilters.bind(this),this.inputFilterRef=Y.createRef();const{panelState:n}=e,{value:s,isValueShown:i=!1,name:o,type:r,timestamp:l}=n!=null?n:{};this.state={columns:[],column:o!=null&&r!=null?{name:o,type:r}:void 0,value:s,timestamp:l,isValueShown:i,wasFlipped:!1,skipUpdate:!1,panelState:n}}componentDidMount(){this.updateColumns();const{column:e,value:n,timestamp:s}=this.state;if(e!=null){const{name:i,type:o}=e;this.sendUpdate(i,o,n,s)}}componentDidUpdate(e){const{columns:n}=this.props;n!==e.columns&&this.updateColumns()}handleChange({column:e,isValueShown:n,value:s}){let i,o;e!=null&&({name:i,type:o}=e);let r=!0,l=Date.now();this.setState(({panelState:a,timestamp:d,wasFlipped:c,skipUpdate:u})=>{var p;const m=a!=null&&n!==a.isValueShown&&i===a.name&&o===a.type&&s===a.value;return r=(p=!u&&n&&(!m||!c))!=null?p:!1,r||(l=d),{panelState:{isValueShown:n,name:i,type:o,value:s,timestamp:l},timestamp:l,wasFlipped:m,skipUpdate:!1}},()=>{r&&this.sendUpdate(i,o,s,l)})}handleClearAllFilters(){var e;(e=this.inputFilterRef.current)==null||e.clearFilter()}sendUpdate(e,n,s,i){const{glEventHub:o}=this.props;o.emit(Pe.FILTERS_CHANGED,this,{name:e,type:n,value:s,timestamp:i})}setPanelState(e,n=!1){var s;this.setState({skipUpdate:!n}),(s=this.inputFilterRef.current)==null||s.setFilterState(e)}updateColumns(){const{columns:e}=this.props;e!=null&&this.setState(n=>{const{column:s}=n;return s==null&&e.length>0?{columns:[...e],column:e[0]}:s!=null&&!e.find(({name:i,type:o})=>s.name===i&&s.type===o)?{columns:[...e,s]}:{columns:[...e]}})}render(){const{glContainer:e,glEventHub:n}=this.props,{column:s,columns:i,isValueShown:o,value:r}=this.state;return h(Yn,{className:"iris-input-filter-panel",componentPanel:this,glContainer:e,glEventHub:n,onClearAllFilters:this.handleClearAllFilters,isClonable:!0,isRenamable:!0,children:h(Qd,{ref:this.inputFilterRef,column:s,columns:i,onChange:this.handleChange,isValueShown:o,value:r})})}}Pl.defaultProps={panelState:null};Pl.COMPONENT="InputFilterPanel";Pl.displayName="InputFilterPanel";const ME=(t,e)=>{const{localDashboardId:n}=e;return{columns:up(t,n)}},Ro=Mt(ME,null,null,{forwardRef:!0})(Pl);const Rt=X.module("FilterSetManagerPanel");function NE(t){return t.setPanelState!=null}const Ba=class extends S.exports.Component{static changeFilterIndexesToColumnNames(t,e){return e.map(([n,s])=>{if(n>=t.columns.length)return null;const{name:i}=t.columns[n];return{name:i,filter:s}}).filter(n=>n!=null)}constructor(t){super(t),this.handleChange=this.handleChange.bind(this),this.handleFilterApply=this.handleFilterApply.bind(this),this.handleSetsUpdate=this.handleSetsUpdate.bind(this),this.handleGetFilterState=this.handleGetFilterState.bind(this);const{panelState:e,filterSets:n}=t,{selectedId:s=n.length>0?n[0].id:void 0,isValueShown:i=!1}=e!=null?e:{};this.state={selectedId:s,isValueShown:i,panelState:e}}getFilterState(){const{dashboardOpenedPanelMap:t}=this.props,e=[];return[...t.keys()].forEach(n=>{const s=t.get(n);if(s===void 0){Rt.error("Could not get panel",s);return}const i=te.getComponentNameFromPanel(s),o=te.getIdFromPanel(s);Rt.debug("Panel:",s,i);const{glContainer:r=null}=s.props;if(r==null){Rt.error("Could not get panel container",s);return}const l=te.getComponentConfigFromContainer(r);if(l==null){Rt.error("Could not get component config from container",r);return}const a=te.getPanelComponentState(l);if(a==null){Rt.debug(`Panel state is null ${o}`);return}switch(i){case te.getComponentName(Gi):{let d;o!=null&&(d=this.getIrisGridPanelFilters(o,a)),d!=null&&e.push({panelId:o,type:i,state:d});break}case te.getComponentName(Ro):case te.getComponentName(di):{const{isValueShown:d,name:c,type:u,value:m}=a;e.push({panelId:o,type:i,state:{isValueShown:d,name:c,type:u,value:m}});break}}}),e}getIrisGridPanelFilters(t,e){const{panelTableMap:n}=this.props,s=n.get(t);if(s==null)return Rt.error(`Unable to get table for panel ${t}.`),null;const{irisGridState:i={advancedFilters:void 0,quickFilters:void 0},gridState:o={}}=e,{advancedFilters:r,quickFilters:l}=i;let a;r&&(a=Ba.changeFilterIndexesToColumnNames(s,r));let d;return l&&(d=Ba.changeFilterIndexesToColumnNames(s,l)),{irisGridState:{...i,advancedFilters:a,quickFilters:d},gridState:{...o}}}handleGetFilterState(){return this.getFilterState()}handleChange({isValueShown:t,selectedId:e}){Rt.debug("handleChange",t,e),this.setState({isValueShown:t,selectedId:e}),this.updatePanelState()}handleFilterApply(t){const{dashboardOpenedPanelMap:e}=this.props,{panels:n,restoreFullState:s=!1}=t;Rt.debug("Apply filters from filter set",t),n.forEach(({panelId:i,type:o,state:r})=>{if(i==null){Rt.debug("panel is null",i);return}if(!e.has(i)){Rt.debug("Ignore closed panel",i);return}Rt.debug("Apply panel filters",i,o,r);const l=e.get(i);switch(o){case te.getComponentName(Gi):this.restoreIrisGridFilters(l,r,s);break;case te.getComponentName(Ro):case te.getComponentName(di):this.restoreInputFilterState(l,r);break}})}handleSetsUpdate(t){const{setDashboardFilterSets:e,localDashboardId:n}=this.props;Rt.debug("Saving updated sets",t),e(n,[...t])}updatePanelState(){this.setState(({selectedId:t,isValueShown:e})=>({panelState:{selectedId:t,isValueShown:e}}))}restoreIrisGridFilters(t,e,n){const{irisGridState:s={},advancedFilters:i=[],quickFilters:o=[]}=e,{advancedFilters:r=i,quickFilters:l=o}=s,{panelTableMap:a}=this.props,d=te.getIdFromPanel(t);if(d==null){Rt.error("Panel Id is null.");return}if(a.get(d)==null){Rt.error(`Unable to get table for panel ${d}.`);return}Rt.debug("restoreIrisGridFilters",d,e,n),n?t.setStateOverrides(e):t.setFilters({quickFilters:l,advancedFilters:r})}restoreInputFilterState(t,e){const n={...e};delete n.isValueShown,Rt.debug("restoreInputFilterState",t,n),t&&NE(t)&&t.setPanelState(n)}render(){const{glContainer:t,glEventHub:e,filterSets:n}=this.props,{isValueShown:s,selectedId:i}=this.state;return h(Yn,{className:"filter-set-manager-panel",componentPanel:this,glContainer:t,glEventHub:e,isClonable:!0,isRenamable:!0,children:h("div",{className:"input-filter-container h-100 w-100 container",children:h(el,{onChange:this.handleChange,onApply:this.handleFilterApply,onUpdateSets:this.handleSetsUpdate,isValueShown:s,filterSets:n,selectedId:i,getFilterState:this.handleGetFilterState})})})}};let Zd=Ba;Zd.defaultProps={panelState:null};Zd.COMPONENT="FilterSetManagerPanel";const FE=(t,e)=>{const{localDashboardId:n}=e;return{filterSets:qT(t,n),dashboardOpenedPanelMap:Om(t,n),dashboardInputFilters:Ud(t,n),panelTableMap:Bd(t,n)}},ma=Mt(FE,{setDashboardFilterSets:tE},null,{forwardRef:!0})(Zd);const Rh=X.module("LogPanel");class Hl extends S.exports.PureComponent{constructor(e){super(e),this.handleResize=this.handleResize.bind(this),this.handleShow=this.handleShow.bind(this),this.handleHide=this.handleHide.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.isBottomVisible=!0,this.logView=null;const{session:n}=this.props;this.state={session:n}}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions(),this.logView&&(this.logView.triggerFindWidget(),this.isBottomVisible&&this.logView.scrollToBottom())}handleHide(){this.logView&&(this.isBottomVisible=this.logView.isBottomVisible())}handleSessionOpened(e){Rh.debug("Session opened",[e]),this.setState({session:e})}handleSessionClosed(e){Rh.debug("Session closed",e)}updateDimensions(){this.logView&&this.logView.updateDimensions()}render(){const{glContainer:e,glEventHub:n}=this.props,{session:s}=this.state;return v(Yn,{componentPanel:this,glContainer:e,glEventHub:n,onResize:this.handleResize,onHide:this.handleHide,onShow:this.handleShow,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,children:[s==null&&h("div",{className:"log-panel-disconnected-message",children:"Waiting for session connection"}),s!=null&&h(Yi,{session:s,ref:i=>{this.logView=i}})]})}}Hl.defaultProps={session:null};Hl.COMPONENT="LogPanel";Hl.TITLE="Log";const xE=(t,e)=>{var n;return{session:(n=gi(t,e.localDashboardId))==null?void 0:n.session}},tl=Mt(xE,null,null,{forwardRef:!0})(Hl);class bp extends S.exports.PureComponent{render(){const{isEditing:e,children:n,onDoubleClick:s}=this.props;return v("div",{className:"markdown-editor-container h-100 w-100",onDoubleClick:s,children:[h("div",{className:z("text-muted","edit-hint",{viewing:e===void 0||!e}),children:v("span",{children:["double-click to edit ",h(q,{icon:ll})]})}),n]})}}bp.defaultProps={isEditing:!1};const _E=X.module("MarkdownStartPage");class Sp extends S.exports.PureComponent{constructor(e){super(e),this.handleDeleteButtonClick=this.handleDeleteButtonClick.bind(this),this.handleDeleteModalClose=this.handleDeleteModalClose.bind(this),this.state={isDeleteModalShown:!1}}handleDeleteButtonClick(e){this.setState({isDeleteModalShown:!0,toBeDeleted:e})}handleDeleteModalClose(){this.setState({isDeleteModalShown:!1,toBeDeleted:void 0})}handleDeleteMarkdown(e){if(_E.debug("delete markdown: ",e),e!==void 0){const{onDelete:n}=this.props;n(e)}this.setState({isDeleteModalShown:!1,toBeDeleted:void 0})}render(){const{closedMarkdowns:e,onOpen:n,onCreate:s}=this.props,{isDeleteModalShown:i,toBeDeleted:o}=this.state;return h("div",{className:"markdown-panel-start-page h-100 w-100",children:v("div",{className:"markdown-panel-start-page-container",children:[v("div",{className:"markdown-panel-start-list",children:[h("h3",{className:"list-title",children:"Start"}),h("div",{className:"list-item",children:h(Q,{kind:"ghost",className:"title",onClick:s,children:"New Markdown Note"})})]}),v("div",{className:"markdown-panel-start-list",children:[h("h3",{className:"list-title",children:"Recently Closed from Dashboard"}),e.map(r=>v("div",{className:"list-item",children:[h(Q,{kind:"ghost",className:"title",onClick:()=>n(r),children:r.title}),h("button",{className:"btn-link icon",type:"button",onClick:()=>{this.handleDeleteButtonClick(r)},children:h(q,{icon:xn})})]},r.id)),v(Oo,{isOpen:i,toggle:this.handleDeleteModalClose,className:"modal-dialog-centered markdown-delete-modal theme-bg-light",children:[h(Po,{children:"Are you sure you want to permanently delete this note?"}),h(Ao,{children:"You can't undo this action."}),v(Za,{children:[h(Q,{kind:"secondary",onClick:this.handleDeleteModalClose,children:"Cancel"}),h(Q,{kind:"danger",onClick:()=>{this.handleDeleteMarkdown(o)},children:"Delete"})]})]})]})]})})}}Sp.defaultProps={closedMarkdowns:[],onOpen:()=>{},onCreate:()=>{},onDelete:()=>{}};class wp extends S.exports.PureComponent{constructor(e){super(e),this.renderMarkdown=n=>{const{children:s,className:i}=n,o=i!==void 0&&(i==null?void 0:i.startsWith("language-"))?i.substring(9):"plaintext";return h("pre",{children:h("code",{children:h(Cl,{language:o,children:Y.Children.map(s,r=>typeof r=="string"?r.trim():r)})})})},this.container=null}render(){const{isEditing:e,content:n,onEditorInitialized:s}=this.props;return h("div",{className:"markdown-editor-container",ref:i=>{this.container=i},children:e?h(bl,{settings:{language:"markdown",value:n,lineNumbers:"off"},onEditorInitialized:s}):h(Kh,{components:{code:this.renderMarkdown},children:n})})}}wp.defaultProps={isEditing:!1,content:""};const Ir=X.module("MarkdownPanel");class Jd extends S.exports.Component{constructor(e){super(e),this.getClosedMarkdowns=ge(i=>i.filter(o=>o.component==="MarkdownPanel").reverse()),this.handleContainerDoubleClick=this.handleContainerDoubleClick.bind(this),this.handleCreateMarkdown=this.handleCreateMarkdown.bind(this),this.handleDeleteMarkdown=this.handleDeleteMarkdown.bind(this),this.handleOpenMarkdown=this.handleOpenMarkdown.bind(this),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorBlur=this.handleEditorBlur.bind(this),this.handleEditorResize=this.handleEditorResize.bind(this);const{panelState:n}=e;let s=null;n!=null&&n.content!=null&&({content:s}=n),this.state={isStartPageShown:s==null,isEditing:!1,content:s,panelState:n},this.markdownEditor=null}setEditorPosition(e){var s,i;A(this.markdownEditor);const{container:n}=this.markdownEditor;if(this.editor&&n){const o=n.getBoundingClientRect().top,r=n.scrollTop,l=n.scrollHeight,a=(i=(s=this.editor.getModel())==null?void 0:s.getLineCount())!=null?i:0;let d=Math.round((r+e-o)/l*a);d>a&&(d=a),this.editor.revealLine(d),this.editor.setPosition({lineNumber:d,column:1}),this.editor.focus()}}handleContainerDoubleClick(e){const{isEditing:n}=this.state,s=e.clientY;n||this.setState({isEditing:!0},()=>{this.setEditorPosition(s)})}handleEditorInitialized(e){Ir.debug("Markdown Editor Initialized..."),this.editor=e}handleCreateMarkdown(){Ir.debug("create markdown..."),this.setState({isStartPageShown:!1,content:"",isEditing:!0,panelState:{content:""}},()=>{this.editor!=null&&this.editor.focus!=null&&this.editor.focus()})}handleOpenMarkdown(e){Ir.debug("open markdown...",e);const{glContainer:n,glEventHub:s}=this.props,i=te.getComponentConfigFromContainer(n);s.emit(Me.REOPEN,e,i)}handleDeleteMarkdown(e){const{glEventHub:n}=this.props;n.emit(Me.DELETE,e)}handleEditorBlur(e){var i;Ir.debug("markdown content changed, saving...");const{isEditing:n}=this.state;if(!n||this.markdownEditor!=null&&this.markdownEditor.container!=null&&this.markdownEditor.container.contains(e.relatedTarget))return;const s=(i=this.editor)==null?void 0:i.getValue();this.setState({content:s,isEditing:!1,panelState:{content:s}})}handleEditorResize(){const{isEditing:e}=this.state;e&&this.editor&&this.editor.layout()}render(){const{glContainer:e,glEventHub:n,closedPanels:s}=this.props,{isEditing:i,isStartPageShown:o,content:r}=this.state,l=this.getClosedMarkdowns(s);return h(Yn,{glContainer:e,glEventHub:n,className:"markdown-panel",componentPanel:this,onResize:this.handleEditorResize,onBlur:this.handleEditorBlur,isClonable:!0,isRenamable:!0,children:o?h(Sp,{closedMarkdowns:l,onCreate:this.handleCreateMarkdown,onOpen:this.handleOpenMarkdown,onDelete:this.handleDeleteMarkdown}):h(bp,{isEditing:i,onDoubleClick:this.handleContainerDoubleClick,children:h(wp,{ref:a=>{this.markdownEditor=a},isEditing:i,content:r!=null?r:void 0,onEditorInitialized:this.handleEditorInitialized})})})}}Jd.defaultProps={panelState:null};Jd.COMPONENT="MarkdownPanel";const kE=(t,e)=>{const{localDashboardId:n}=e;return{closedPanels:sw(t,n)}},po=Mt(kE,null,null,{forwardRef:!0})(Jd);class vp extends S.exports.PureComponent{constructor(e){super(e),this.handleRunSelected=this.handleRunSelected.bind(this),this.renderCodeBlock=this.renderCodeBlock.bind(this),this.renderLink=this.renderLink.bind(this),this.commands=new Map,this.codeElements=new Map,this.editorScrollView=Y.createRef(),this.state={hasCode:!1,hasRunCode:!1,nextStartLine:null}}componentDidMount(){this.updateHasCode()}componentDidUpdate(){this.updateHasCode()}updateHasCode(){const{hasCode:e}=this.state;this.commands.size===0&&e?this.setState({hasCode:!1}):this.commands.size>0&&!e&&this.setState({hasCode:!0})}getNextStartLine(e){const n=[...this.commands.keys()],s=n.findIndex(i=>i===e)+1;return s>=n.length?null:n[s]}handleRunSelected(e){var c,u,m;e.preventDefault(),e.stopPropagation();const{nextStartLine:n}=this.state,s=[...this.commands.keys()],i=s.findIndex(p=>p===n||n==null);if(i<0)return;const o=s[i],r=this.commands.get(o),l=this.getNextStartLine(o),a=(c=this.codeElements.get(o))==null?void 0:c.current,d=(u=a==null?void 0:a.parentElement)==null?void 0:u.nextElementSibling;if(d!=null){const{offsetTop:p}=d,g=p;(m=this.editorScrollView.current)==null||m.scroll({top:g,left:0})}this.runCode(r),this.setState({nextStartLine:l})}runCode(e){const{onRunCode:n}=this.props;n(e),this.setState({hasRunCode:!0})}renderCodeBlock(e){const{children:n,className:s,inline:i,node:o}=e,{hasRunCode:r,nextStartLine:l}=this.state,{children:a,position:d}=o;A(d);const{start:c}=d,{line:u}=c,m=a[0].value,p=Y.createRef(),g=this.commands.size===0,f=l===u||g&&l==null&&!r,b=s!==void 0&&s.startsWith("language-")?s.substring(9):"plaintext";return i!=null&&i?h("code",{className:s,children:n}):(this.commands.set(u,m),this.codeElements.set(u,p),v("div",{className:z("markdown-notebook-code-block",{"is-selected":f}),ref:p,onClick:()=>{this.setState({nextStartLine:u})},role:"presentation",children:[h(Q,{kind:"ghost",icon:Br,className:"btn-play-block",onClick:C=>{C.stopPropagation(),C.preventDefault(),this.runCode(m),this.setState({nextStartLine:u})},tooltip:"Run code"}),h("code",{children:h(Cl,{language:b,children:Y.Children.map(n,C=>typeof C=="string"?C.trim():C)})})]}))}renderLink(e){const{onLinkClick:n}=this.props,{href:s,children:i,target:o}=e;return h("a",{href:s,onClick:n,target:o,children:i})}render(){const{content:e,transformImageUri:n,transformLinkUri:s}=this.props,{hasCode:i,hasRunCode:o,nextStartLine:r}=this.state;return v("div",{className:"markdown-notebook",children:[h("div",{className:"markdown-notebook-toolbar",children:h(Q,{className:z("btn-play-selected-cell",{flashing:i&&!o}),kind:"ghost",icon:Br,onClick:this.handleRunSelected,tooltip:"Run code and select next",disabled:o&&r==null||!i,children:"Run Selected Code"})}),h("div",{className:"markdown-notebook-content",ref:this.editorScrollView,children:h(Kh,{components:{code:this.renderCodeBlock,a:this.renderLink},linkTarget:"_blank",remarkPlugins:[Zp],transformLinkUri:s,transformImageUri:n,includeElementIndex:!0,children:e})})]})}}vp.defaultProps={onRunCode:()=>{}};const $e=X.module("NotebookPanel"),Dh=400,Ni=class extends S.exports.Component{constructor(t){super(t),this.getOverflowActions=ge(()=>[{title:"Find",icon:Lf,action:this.handleFind,group:ie.groups.high,shortcut:Nn.NOTEBOOK.FIND,order:10}]),this.handleBlur=this.handleBlur.bind(this),this.handleCloseCancel=this.handleCloseCancel.bind(this),this.handleCloseDiscard=this.handleCloseDiscard.bind(this),this.handleCloseSave=this.handleCloseSave.bind(this),this.handleCopy=this.handleCopy.bind(this),this.handleEditorChange=this.handleEditorChange.bind(this),this.handleFind=this.handleFind.bind(this),this.handleFocus=this.handleFocus.bind(this),this.handleLinkClick=this.handleLinkClick.bind(this),this.handleLoadSuccess=this.handleLoadSuccess.bind(this),this.handleLoadError=this.handleLoadError.bind(this),this.handlePanelTabClick=this.handlePanelTabClick.bind(this),this.handleRenameFile=this.handleRenameFile.bind(this),this.handleResize=this.handleResize.bind(this),this.handleRunCommand=this.handleRunCommand.bind(this),this.handleRunAll=this.handleRunAll.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.handleSave=this.handleSave.bind(this),this.handleSaveAsCancel=this.handleSaveAsCancel.bind(this),this.handleSaveAsSubmit=this.handleSaveAsSubmit.bind(this),this.handleSaveError=this.handleSaveError.bind(this),this.handleSaveSuccess=this.handleSaveSuccess.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleShowRename=this.handleShowRename.bind(this),this.handleTab=this.handleTab.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleTabBlur=this.handleTabBlur.bind(this),this.handleTransformLinkUri=this.handleTransformLinkUri.bind(this),this.pending=new ps,this.debouncedSavePanelState=Xe(this.savePanelState.bind(this),Dh),this.debouncedLoad=Xe(this.load.bind(this),Dh),this.notebook=null,this.tabTitleElement=null,this.tabInitOnce=!1,this.shouldPromptClose=!0;const{isDashboardActive:e,session:n,sessionLanguage:s,panelState:i}=t;let o={value:"",language:""},r=null,{isPreview:l}=t;i!=null&&({fileMetadata:r=r,isPreview:l=l,settings:o=o}=i);const a=r!=null&&de.hasPath(r.itemName),c=a===!0&&o.value!=null||!a&&o.value!=null&&o.value.length>0?1:0;this.state={error:void 0,isDashboardActive:e,isFocused:!1,isLoading:!0,isLoaded:!1,isPreview:l,savedChangeCount:0,changeCount:c,fileMetadata:r,settings:o,session:n,sessionLanguage:s,panelState:{fileMetadata:r,settings:o},showCloseModal:!1,showSaveAsModal:!1,scriptCode:""},$e.debug("constructor",t,this.state)}static handleError(t){Ee.isCanceled(t)||$e.error(t)}static languageFromFileName(t){switch(de.getExtension(t).toLowerCase()){case"py":case"python":return"python";case"groovy":return"groovy";case"scala":return"scala";default:return null}}componentDidMount(){const{glContainer:t,glEventHub:e}=this.props,{tab:n}=t;n!=null&&this.initTab(n),this.initNotebookContent(),e.on(He.RENAME_FILE,this.handleRenameFile),t.on("tabClicked",this.handlePanelTabClick)}componentDidUpdate(t,e){const{isPreview:n}=this.state;n!==e.isPreview&&this.setPreviewStatus()}componentWillUnmount(){this.debouncedSavePanelState.flush(),this.pending.cancel();const{glContainer:t,glEventHub:e}=this.props,{fileMetadata:n,isPreview:s}=this.state;e.off(He.RENAME_FILE,this.handleRenameFile),t.off("tabClicked",this.handlePanelTabClick),e.emit(He.UNREGISTER_FILE,n,s)}initTab(t){this.tabInitOnce||(this.tabInitOnce=!0,this.initTabCloseOverride()),this.initTabClasses(t)}initTabCloseOverride(){const{glContainer:t}=this.props,e=t.close.bind(t);t.close=()=>{const{changeCount:n,savedChangeCount:s}=this.state;return n!==s&&this.shouldPromptClose?this.setState({showCloseModal:!0}):e(),!0}}initTabClasses(t){const e=t.element.get(0);A(e);const n=e.querySelector(".lm_title");this.tabTitleElement=n,n==null||n.classList.add("notebook-title"),this.setPreviewStatus()}getNotebookValue(){const{changeCount:t,savedChangeCount:e,settings:n}=this.state,{value:s}=n;if(t!==e&&this.notebook){const i=this.notebook.getValue();return i!=null?i:s}return s}initNotebookContent(){const{fileMetadata:t,settings:e,isPreview:n}=this.state;if(t&&t.id){$e.debug("Init content from file"),this.registerFileMetadata(t,n),this.load();return}if(e.value!=null){$e.debug("Use content passed in the settings prop"),this.handleLoadSuccess();return}this.handleLoadError(new Error("Missing file metadata"))}closeFileTabById(t){const{glEventHub:e}=this.props;e.emit(He.CLOSE_FILE,{id:t})}registerFileMetadata(t,e){const{glEventHub:n,metadata:s}=this.props,{id:i}=s;n.emit(He.REGISTER_FILE,i,t,e)}renameTab(t,e){const{glEventHub:n}=this.props;n.emit(He.RENAME,t,e)}load(){const{fileMetadata:t,settings:e}=this.state;A(t);const{id:n}=t,{fileStorage:s}=this.props;this.pending.add(s.loadFile(n)).then(i=>{var a;$e.debug("Loaded file",i);const{filename:o}=i,{itemName:r}=this.state;if(o!==r){const{metadata:d}=this.props,{id:c}=d;this.renameTab(c,de.getBaseName(o))}const l={...e,language:(a=Ni.languageFromFileName(o))!=null?a:""};e.value==null&&(l.value=i.content),this.setState({fileMetadata:{id:o,itemName:o},settings:l}),this.debouncedSavePanelState()}).then(this.handleLoadSuccess).catch(this.handleLoadError)}save(){const{fileMetadata:t}=this.state;if(t&&de.hasPath(t.itemName)){const e=this.getNotebookValue();return e!=null?(this.saveContent(t.itemName,e),!0):!1}return this.setState({showSaveAsModal:!0}),!1}saveContent(t,e){$e.debug("saveContent",t,e),this.updateSavedChangeCount();const{fileStorage:n}=this.props;this.pending.add(n.saveFile({filename:t,content:e,basename:t})).then(this.handleSaveSuccess).catch(this.handleSaveError)}updateSavedChangeCount(){this.setState(({changeCount:t})=>({savedChangeCount:t}))}setPreviewStatus(){if(!this.tabTitleElement)return;const{isPreview:t}=this.state;$e.debug("setPreviewStatus",this.tabTitleElement,t),t?this.tabTitleElement.classList.add("is-preview"):this.tabTitleElement.classList.remove("is-preview")}savePanelState(){this.setState(t=>{const{changeCount:e,savedChangeCount:n,fileMetadata:s,isPreview:i,settings:o}=t,r=this.getNotebookValue(),l=e!==n?r:null,a={...o,value:r},c={settings:{...o,value:l},fileMetadata:s,isPreview:i};return $e.debug("Saving panel state",c),{settings:a,panelState:c}})}handleCloseDiscard(){this.shouldPromptClose=!1,this.setState({showCloseModal:!1});const{glContainer:t}=this.props;t.close()}handleCloseSave(){if(this.shouldPromptClose=!1,this.setState({showCloseModal:!1}),this.save()){const{glContainer:t}=this.props;t.close()}}handleCloseCancel(){this.shouldPromptClose=!0,this.setState({showCloseModal:!1})}handleCopy(){const{fileMetadata:t,settings:e}=this.state;A(t);const n=this.getNotebookValue(),{language:s}=e,{itemName:i}=t,o=de.getCopyFileName(i);$e.debug("handleCopy",t,i,o),this.createNotebook(o,s,n!=null?n:void 0)}handleEditorChange(t){$e.debug2("handleEditorChanged",t),this.removePreviewStatus(),this.setState(e=>{const{changeCount:n,savedChangeCount:s}=e,{isUndoing:i,isRedoing:o}=t;return i?{changeCount:n-1,savedChangeCount:s}:!o&&n<s?{changeCount:n+1,savedChangeCount:0}:{changeCount:n+1,savedChangeCount:s}}),this.debouncedSavePanelState()}handleFind(){this.notebook&&this.notebook.toggleFind()}handleBlur(){$e.debug("handleBlur"),this.setState({isFocused:!1})}handleFocus(){$e.debug("handleFocus"),this.setState({isFocused:!0})}handleLinkClick(t){const{notebooksUrl:e,session:n,sessionLanguage:s}=this.props,{href:i}=t.currentTarget;if(!i||!i.startsWith(e))return;t.stopPropagation(),t.preventDefault();const o=`/${i.substring(e.length)}`.replace(/%20/g," ");if(o==="/"){$e.debug("Ignoring invalid notebook link",o);return}$e.debug("Notebook link clicked, opening",o);const{glEventHub:r}=this.props,l={value:null,language:s},a={id:o,itemName:o};r.emit(He.SELECT_NOTEBOOK,n,s,l,a)}handleLoadSuccess(){this.setState({error:void 0,isLoaded:!0,isLoading:!1})}handleLoadError(t){let e=t;Ee.isCanceled(e)||(Ee.isTimedOut(e)&&(e=new Error("File not found.")),$e.error(e),this.setState({error:e,isLoading:!1}))}handleSave(){$e.debug("handleSave"),this.save()}handleSaveSuccess(t){var i;const{fileStorage:e}=this.props,n={id:t.filename,itemName:t.filename},s=(i=Ni.languageFromFileName(t.filename))!=null?i:"";this.setState(o=>{const{fileMetadata:r}=o,l={...o.settings,language:s};return $e.debug("handleSaveSuccess",n,r,l),r&&de.hasPath(r.itemName)&&r.itemName!==n.itemName&&($e.debug("handleSaveSuccess deleting old file",r.itemName),e.deleteFile(r.itemName).catch(Ni.handleError)),{fileMetadata:n,settings:l,isPreview:!1}}),this.debouncedSavePanelState(),this.registerFileMetadata(n,!1)}handleSaveError(t){Ee.isCanceled(t)||(this.setState({savedChangeCount:0}),$e.error(t))}handleSaveAsCancel(){this.setState({showSaveAsModal:!1})}handleSaveAsSubmit(t){var i;$e.debug("handleSaveAsSubmit",t);const{fileMetadata:e}=this.state;if(!e)return;const{itemName:n}=e,s=(i=this.getNotebookValue())!=null?i:"";if(this.setState({showSaveAsModal:!1}),de.getBaseName(n)!==de.getBaseName(t)){const{metadata:o}=this.props,{id:r}=o;this.renameTab(r,de.getBaseName(t))}this.saveContent(t,s)}handleRenameFile(t,e){const{fileMetadata:n}=this.state;n&&n.id===t&&(this.setState({fileMetadata:{id:e,itemName:e}}),this.debouncedSavePanelState())}handleResize(){var t;(t=this.notebook)==null||t.updateDimensions()}handleRunCommand(t){this.runCommand(t)}handleRunAll(){var t;if(!this.notebook){$e.error("Editor is not initialized.");return}this.runCommand((t=this.notebook.getValue())!=null?t:void 0)}handleRunSelected(){if(!this.notebook){$e.error("Editor is not initialized.");return}this.runCommand(this.notebook.getSelectedCommand())}handleSessionOpened(t,{language:e}){this.setState({session:t,sessionLanguage:e})}handleSessionClosed(){this.setState({session:void 0,sessionLanguage:void 0})}handleShow(){var t;$e.debug("handleShow"),(t=this.notebook)==null||t.updateDimensions()}handleShowRename(){this.setState({showSaveAsModal:!0})}handleTab(t){$e.debug("NotebookPanel tab event",t),this.initTab(t)}handleTabFocus(...t){$e.debug("handleTabFocus",...t);const{glContainer:e}=this.props;this.setState({isDashboardActive:!0}),this.notebook&&!e.isHidden&&this.notebook.updateDimensions()}handleTabBlur(){$e.debug("handleTabBlur"),this.setState({isDashboardActive:!1})}handlePanelTabClick(){$e.debug("handlePanelTabClick"),this.focus()}handleTransformLinkUri(t){const{notebooksUrl:e}=this.props,{fileMetadata:n}=this.state;if(t.endsWith("/"))return t;if(t.startsWith("/"))return`${e}${t.substring(1)}`;let s=n==null?void 0:n.itemName;if(s===void 0)return t;s.charAt(0)==="/"&&(s=s.substring(1));const i=new URL(s,e);return new URL(t,i).href}focus(){requestAnimationFrame(()=>{this.notebook&&this.notebook.focus()})}createNotebook(t,e,n=""){const{glEventHub:s}=this.props,{session:i,sessionLanguage:o,settings:r}=this.state,l={...r,language:e,value:n},a={id:null,itemName:t};$e.debug("handleCreateNotebook",i,o,l,a),s.emit(He.CREATE_NOTEBOOK,i,o,l,a)}runCommand(t){if(t===void 0){$e.debug("Ignoring empty command.");return}this.removePreviewStatus();const{glEventHub:e}=this.props;e.emit(ft.SEND_COMMAND,t,!1,!0)}removePreviewStatus(){this.setState(({isPreview:t})=>{if(t){const{fileMetadata:e}=this.state;return e&&this.registerFileMetadata(e,!1),{isPreview:!1}}return null})}render(){var _,k;const{fileStorage:t,glContainer:e,glContainer:{tab:n},glEventHub:s}=this.props,{changeCount:i,savedChangeCount:o,error:r,isDashboardActive:l,isLoaded:a,isLoading:d,isPreview:c,fileMetadata:u,session:m,sessionLanguage:p,settings:g,showCloseModal:f,showSaveAsModal:b}=this.state,C=l&&!e.isHidden&&!c,w=(_=u==null?void 0:u.itemName)!=null?_:Ni.DEFAULT_NAME,T=w.endsWith(".md"),E=(u==null?void 0:u.id)!=null,y=this.getOverflowActions(),I={...g},D=m!=null,N=p===I.language,x=!a||!D||!N,U=!a,$=[{action:this.handleSave,shortcut:ks.SAVE}],L=zc.getDisabledRunTooltip(D,N,"Notebook extension","Run"),H=zc.getDisabledRunTooltip(D,N,"Notebook extension","Run Selected"),O=[{title:E?"Rename":"Save As\u2026",order:10,group:ie.groups.high,action:this.handleShowRename},{title:"Copy File",action:this.handleCopy,group:ie.groups.high,order:20}],F=n==null?void 0:n.element.find(".lm_title_before").get(0);return v(he,{children:[F&&hi.createPortal(h("span",{className:z("editor-unsaved-indicator",{"is-unsaved":i!==o})}),F),v(Yn,{className:"notebook-container",componentPanel:this,glContainer:e,glEventHub:s,onTab:this.handleTab,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,onTabBlur:this.handleTabBlur,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onFocus:this.handleFocus,onBlur:this.handleBlur,additionalActions:O,renderTabTooltip:()=>w,children:[!T&&v(he,{children:[v("div",{className:"notebook-toolbar",children:[v("span",{children:[h(Q,{kind:"ghost",className:"btn-play",onClick:this.handleRunAll,disabled:x,icon:h(q,{icon:Br,transform:"grow-4"}),tooltip:`Run ${Nn.NOTEBOOK.RUN.getDisplayText()}`}),L!=null&&h(Ie,{children:L})]}),v("span",{children:[h(Q,{kind:"ghost",className:"btn-play",onClick:this.handleRunSelected,disabled:x,icon:h(q,{icon:Gf,transform:"grow-4"}),tooltip:`Run Selected
|
|
38
|
-
${Nn.NOTEBOOK.RUN_SELECTED.getDisplayText()}`}),H!=null&&h(Ie,{children:H})]}),h(Q,{kind:"ghost",className:"mr-auto",disabled:U,onClick:this.handleSave,icon:ou,tooltip:"Save"}),h(Q,{kind:"ghost",className:"btn-overflow btn-link-icon",disabled:U,icon:nu,tooltip:"More Actions...",children:h(zn,{actions:y,popperOptions:Ni.POPPER_OPTIONS})})]}),h(Ku,{isLoaded:a,isLoading:d,error:r,onChange:this.handleEditorChange,onRunCommand:this.handleRunCommand,session:m,sessionLanguage:p,settings:I,focusOnMount:C,ref:V=>{this.notebook=V}})]}),T&&h(vp,{content:(k=I.value)!=null?k:"",onLinkClick:this.handleLinkClick,onRunCode:this.handleRunCommand,transformImageUri:this.handleTransformLinkUri,transformLinkUri:this.handleTransformLinkUri}),h(Al,{isOpen:b,type:"file",defaultValue:w,title:E?"Rename":"Save file as",onSubmit:this.handleSaveAsSubmit,onCancel:this.handleSaveAsCancel,notifyOnExtensionChange:!0,storage:t}),h(Hi,{isOpen:f,headerText:`Do you want to save the changes you made to ${w}?`,bodyText:"Your changes will be lost if you don't save them.",onCancel:this.handleCloseCancel,onDiscard:this.handleCloseDiscard,onConfirm:this.handleCloseSave,discardButtonText:"Discard Changes",confirmButtonText:"Save"}),h(ie,{actions:$})]})]})}};let Ko=Ni;Ko.COMPONENT="NotebookPanel";Ko.POPPER_OPTIONS={placement:"bottom-end"};Ko.DEFAULT_NAME="Untitled";Ko.defaultProps={isDashboardActive:!0,isPreview:!1,session:null,sessionLanguage:null};const LE=(t,e)=>{const n=nm(t),s=gi(t,e.localDashboardId),{session:i,config:o}=s!=null?s:{},{type:r}=o!=null?o:{};return{fileStorage:n,session:i,sessionLanguage:r}},Ks=Mt(LE,null,null,{forwardRef:!0})(Ko);class Do extends S.exports.Component{constructor(e){super(e),this.irisGridRef=Y.createRef(),this.buttonRef=Y.createRef(),this.handleReload=this.handleReload.bind(this),this.handleGridStateChange=this.handleGridStateChange.bind(this),this.handlePanelStateUpdate=this.handlePanelStateUpdate.bind(this);const{panelState:n}=e;this.state={shouldFocusGrid:!1,panelState:n}}handleReload(){var e,n;(e=this.irisGridRef.current)==null||e.initModel(),(n=this.buttonRef.current)==null||n.blur(),this.setState({shouldFocusGrid:!0})}handleGridStateChange(){var n,s,i;const{shouldFocusGrid:e}=this.state;e&&((i=(s=(n=this.irisGridRef.current)==null?void 0:n.irisGrid)==null?void 0:s.current)==null?void 0:i.grid)&&(this.irisGridRef.current.irisGrid.current.grid.focus(),this.setState({shouldFocusGrid:!1}))}handlePanelStateUpdate(e){this.setState({panelState:e})}render(){const{...e}=this.props;return h(ci,{ref:this.irisGridRef,onStateChange:this.handleGridStateChange,onPanelStateUpdate:this.handlePanelStateUpdate,...e,children:v(Q,{ref:this.buttonRef,kind:"primary",className:"btn-pandas",onClick:this.handleReload,tooltip:"Click to refresh pandas dataframe, updates do not occur automatically.",children:["pandas dataframe",v("span",{children:[h(q,{icon:od,transform:"shrink-1",className:"mr-1"}),"Reload"]})]})})}}Do.defaultProps={panelState:null};Do.COMPONENT="PandasPanel";const OE=t=>{Os(t);const{id:e,layout:n,registerComponent:s,hydrate:i}=t,o=S.exports.useCallback(({dragEvent:r,fetch:l,panelId:a=We.generate(),widget:d})=>{const{name:c,type:u}=d;if(u!==dh.VariableType.FIGURE)return;const m={name:c,figure:c},p=()=>l().then(b=>Bi.makeModel(void 0,b)),g={type:"react-component",component:Pi.COMPONENT,props:{localDashboardId:e,id:a,metadata:m,makeModel:p},title:c,id:a},{root:f}=n;te.openComponent({root:f,config:g,dragEvent:r})},[e,n]);return S.exports.useEffect(function(){const l=[s(Pi.COMPONENT,Pi,i)];return()=>{l.forEach(a=>a())}},[i,s]),Ke(n.eventHub,Me.OPEN,o),h(he,{})},AE=t=>{Os(t);const{id:e,layout:n}=t,s=S.exports.useCallback(({metadata:i,panelId:o=We.generate(),table:r})=>{const{settings:l}=i,a=()=>Bi.makeModelFromSettings(l,r),d=Le.titleFromSettings(l),c={type:"react-component",component:Pi.COMPONENT,props:{localDashboardId:e,id:o,metadata:i,makeModel:a},title:d,id:o},{root:u}=n;te.openComponent({root:u,config:c})},[e,n]);return Ke(n.eventHub,wt.CREATE_CHART,s),h(he,{})},at=X.module("ConsolePlugin");function Mh(t){return t.notebook!==void 0}function PE(t){Os(t)}const HE=t=>{PE(t);const{id:e,hydrateConsole:n,layout:s,panelManager:i,registerComponent:o,notebooksUrl:r}=t,l=S.exports.useRef(0),[a]=S.exports.useState(new Map),[d]=S.exports.useState(new Map),c=Xa(),u=S.exports.useCallback(()=>i.getLastUsedPanelOfType(_i),[i]),m=S.exports.useCallback((F,_=!0,k=!0)=>{if(!(F&&F.trim()))at.info("Ignoring empty code");else{const W=u();if(!W||!(W instanceof _i.WrappedComponent)){at.error("Console panel not found");return}at.debug("Send command: ",F,_,k),W.addCommand(F,_,k)}},[u]),p=S.exports.useCallback(F=>{c(eE(e,F))},[c,e]),g=S.exports.useCallback(({language:F})=>{const _=F==="python"?"py":F;let k=null;return _==null?(at.debug("No extension for language",F),k=`Untitled-${l.current}`):k=`Untitled-${l.current}.${_}`,l.current+=1,k},[]),f=S.exports.useCallback((F,_=!0)=>{const{id:k}=F;return k!=null&&a.has(k)?a.get(k):k!=null&&d.has(k)?d.get(k):_?We.generate():null},[a,d]),b=S.exports.useCallback((F,_)=>{te.renameComponent(s.root,{id:F},_)},[s.root]),C=S.exports.useCallback((F,_)=>{at.debug("Rename file panel",F,_);let k;if(a.has(F)&&(k=a.get(F),a.delete(F),k!=null&&a.set(_,k)),d.has(F)&&(k=d.get(F),d.delete(F),k!=null&&d.set(_,k)),k===void 0){at.debug2(`File ${F} isn't open, no need to rename the tab`);return}b(k,de.getBaseName(_))},[a,d,b]),w=S.exports.useCallback(F=>{const _=f(F,!1);if(_==null){at.error("Could not find panel id for file metadata",F);return}te.activateTab(s.root,{id:_})},[f,s.root]),T=S.exports.useCallback((F,_,k)=>{if(at.debug("registerFilePanel",F,_,k),_==null||_.id==null){at.debug("Ignore empty file id",_);return}const{id:V}=_;if(k){d.set(V,F);return}if(a.has(V)){const W=a.get(V);if(F===W){at.debug(`Update tab title for file ${V}`);const{itemName:j}=_;C(V,de.getBaseName(j))}else at.error(`File ${V} already associated with a different tab ${W}`);return}a.set(V,F),d.has(V)&&d.delete(V)},[a,d,C]),E=S.exports.useCallback((F,_)=>{if(at.debug("unregisterFileTab",F,_),F==null||F.id==null){at.debug("Ignore empty file id",F);return}const{id:k}=F;if(_){d.delete(k);return}a.delete(k)},[a,d]),y=S.exports.useCallback(F=>{at.debug("closeFilePanel",F);const{id:_}=F;let k=null,V=!1;if(a.has(_))k=a.get(_);else if(d.has(_))k=d.get(_),V=!0;else{at.debug(`File ${_} isn't open, ignore close event`);return}E(F,V),te.closeComponent(s.root,{id:k})},[s.root,a,d,E]),I=S.exports.useCallback(F=>{const{itemName:_}=F;return de.getBaseName(_)},[]),D=S.exports.useCallback(F=>{const{id:_}=F;return at.debug("fileIsOpen",F,_,a),_!=null&&a.has(_)},[a]),N=S.exports.useCallback(F=>{const{id:_}=F;return at.debug("fileIsOpenAsPreview",F,_,d),_!=null&&d.has(_)},[d]),x=S.exports.useCallback(F=>{if(F==null)return;const _=i.getOpenedPanelById(F);_&&Mh(_)&&_.focus()},[i]),U=S.exports.useCallback(({id:F,settings:_,fileMetadata:k,session:V,sessionLanguage:W,isPreview:j=!1})=>{const ee={settings:_,fileMetadata:k},ve=I(k);return{type:"react-component",component:Ks.COMPONENT,isFocusOnShow:!1,props:{localDashboardId:e,metadata:{id:F},session:V,sessionLanguage:W,panelState:ee,isPreview:j,notebooksUrl:r},title:ve,id:F}},[I,e,r]),$=S.exports.useCallback((F,_,k,V={id:null,itemName:g(k)})=>{const W=f(V);if(D(V)&&W!=null){at.debug("File is already open, focus panel"),w(V),x(W);return}const j=te.getStackForComponentTypes(s.root,[Ks.COMPONENT]),ee=U({id:W,settings:k,fileMetadata:V,session:F,sessionLanguage:_});at.debug("createNotebook",ee,a),te.openComponentInStack(j,ee)},[D,x,g,f,s.root,U,a,w]),L=S.exports.useCallback((F,_,k,V,W=!1)=>{at.debug("selectNotebook",V,W);const j=D(V),ee=N(V);if(j){if(w(V),W){const J=f(V);x(J)}return}if(ee&&!W){w(V);return}const[ve]=Array.from(d.values());let le=null,Se=null;ve!=null&&(le=ve,Se=te.getStackForConfig(s.root,{component:Ks.COMPONENT,id:le})),Se==null&&(le=f(V),Se=te.getStackForComponentTypes(s.root,[Ks.COMPONENT]));const Oe=U({id:le,settings:k,fileMetadata:V,session:F,sessionLanguage:_,isPreview:!W});te.openComponentInStack(Se,Oe),W&&x(le)},[w,D,N,x,f,s.root,U,d]),H=S.exports.useCallback((F,_,k={},V=!0)=>{const W=i.getLastUsedPanelOfType(Ks);W&&Mh(W)?k!=null&&k.value!=null&&W.notebook!=null&&W.notebook.append(k.value):V&&$(F,_,k)},[$,i]),O=S.exports.useCallback((F,_)=>_a.hydrate({...F,notebooksUrl:r},_),[r]);return S.exports.useEffect(function(){const _=[o(_i.COMPONENT,_i,n),o(Zr.COMPONENT,Zr),o(Jr.COMPONENT,Jr),o(tl.COMPONENT,tl),o(Ks.COMPONENT,Ks,O)];return()=>{_.forEach(k=>k())}},[o,n,O]),Ke(s.eventHub,ft.SEND_COMMAND,m),Ke(s.eventHub,ft.SETTINGS_CHANGED,p),Ke(s.eventHub,He.CLOSE_FILE,y),Ke(s.eventHub,He.CREATE_NOTEBOOK,$),Ke(s.eventHub,He.SELECT_NOTEBOOK,L),Ke(s.eventHub,He.RENAME,b),Ke(s.eventHub,He.RENAME_FILE,C),Ke(s.eventHub,He.SEND_TO_NOTEBOOK,H),Ke(s.eventHub,He.REGISTER_FILE,T),Ke(s.eventHub,He.UNREGISTER_FILE,E),h(he,{})},go=X.module("FilterPlugin");function Nh(t,e){return t.concat(e)}const VE=t=>{Os(t);const{id:e,layout:n,registerComponent:s}=t,i=Xa(),[o]=S.exports.useState(()=>new Map),[r]=S.exports.useState(()=>new Map),[l]=S.exports.useState(()=>new Map),a=S.exports.useCallback(()=>{const b=Array.from(o.values()).reduce(Nh,[]).sort((T,E)=>{const y=tn.toLower(T.name),I=tn.toLower(E.name);if(y!==I)return y>I?1:-1;const D=tn.toLower(T.type),N=tn.toLower(E.type);return D!==N?D>N?1:-1:0}).reduce((T,E)=>((T.length===0||tn.toLower(T[T.length-1].name)!==tn.toLower(E.name)||tn.toLower(T[T.length-1].type)!==tn.toLower(E.type))&&T.push(E),T),[]),C=Array.from(r.values()).reduce(Nh,[]).sort((T,E)=>T.timestamp-E.timestamp),w=new Map(l);go.debug("sendUpdate",{columns:b,filters:C,tableMap:w}),i(qn(e,{columns:b,filters:C,tableMap:w}))},[i,e,o,r,l]),d=S.exports.useCallback((b,C)=>{go.debug2("handleColumnsChanged",b,C),o.set(b,[].concat(C)),a()},[o,a]),c=S.exports.useCallback((b,C)=>{go.debug2("handleFiltersChanged",b,C),r.set(b,[].concat(C)),a()},[r,a]),u=S.exports.useCallback((b,C)=>{go.debug2("handleTableChanged",b,C),l.set(te.getIdFromPanel(b),C),a()},[l,a]),m=S.exports.useCallback(b=>{go.debug2("handlePanelUnmount",b),o.delete(b),r.delete(b),l.delete(te.getIdFromPanel(b)),a()},[o,r,l,a]),p=S.exports.useCallback(({title:b="DropdownFilter",metadata:C={},panelState:w=null,id:T=We.generate(),focusElement:E=te.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:I=null})=>{const D={type:"react-component",component:di.COMPONENT,props:{id:T,metadata:C,panelState:w,localDashboardId:e},title:b,id:T},{root:N}=n;te.openComponent({root:N,config:D,focusElement:E,createNewStack:y,dragEvent:I})},[n,e]),g=S.exports.useCallback(({title:b="InputFilter",metadata:C={},panelState:w=null,id:T=We.generate(),focusElement:E=te.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:I=null})=>{const D={type:"react-component",component:Ro.COMPONENT,props:{id:T,metadata:C,panelState:w,localDashboardId:e},title:b,id:T},{root:N}=n;te.openComponent({root:N,config:D,focusElement:E,createNewStack:y,dragEvent:I})},[n,e]),f=S.exports.useCallback(({title:b="FilterSets",metadata:C={},panelState:w=null,id:T=We.generate(),focusElement:E=te.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:I=null})=>{const D={type:"react-component",component:ma.COMPONENT,props:{id:T,metadata:C,panelState:w,localDashboardId:e},title:b,id:T},{root:N}=n;te.openComponent({root:N,config:D,focusElement:E,createNewStack:y,dragEvent:I})},[n,e]);return S.exports.useEffect(function(){const C=[s(di.COMPONENT,di),s(Ro.COMPONENT,Ro),s(ma.COMPONENT,ma)];return()=>{C.forEach(w=>w())}},[s]),Ke(n.eventHub,Pe.COLUMNS_CHANGED,d),Ke(n.eventHub,Pe.FILTERS_CHANGED,c),Ke(n.eventHub,Pe.TABLE_CHANGED,u),Ke(n.eventHub,Pe.OPEN_DROPDOWN,p),Ke(n.eventHub,Pe.OPEN_INPUT,g),Ke(n.eventHub,Pe.OPEN_FILTER_SET_MANAGER,f),Ke(n.eventHub,Me.UNMOUNT,m),h(he,{})},UE=[dh.VariableType.TABLE,dh.VariableType.TREETABLE],BE=t=>{Os(t);const{getDownloadWorker:e,loadPlugin:n,id:s,layout:i,registerComponent:o,hydrate:r,theme:l}=t,a=S.exports.useCallback(({dragEvent:d,fetch:c,panelId:u=We.generate(),widget:m})=>{const{name:p,type:g}=m;if(!UE.includes(g))return;const f={name:p,table:p},b=()=>c().then(T=>Vd.makeModel(T)),C={type:"react-component",component:ci.COMPONENT,props:{getDownloadWorker:e,loadPlugin:n,localDashboardId:s,id:u,metadata:f,makeModel:b,theme:l},title:p,id:u},{root:w}=i;te.openComponent({root:w,config:C,dragEvent:d})},[e,s,i,n,l]);return S.exports.useEffect(function(){const c=[o(ci.COMPONENT,ci,r)];return()=>{c.forEach(u=>u())}},[r,o]),Ke(i.eventHub,Me.OPEN,a),h(he,{})};function Tp(t){return typeof t.getCoordinateForColumn=="function"}function Fh(t){const e=t;return Tp(t)&&typeof e.setFilterMap=="function"&&typeof e.unsetFilterValue=="function"}const fo=X.module("LinkerUtils"),Ep=class{static getLinkType(t,e,n){var l;if((t==null?void 0:t.panelId)==null||(e==null?void 0:e.panelId)==null||t.panelId===e.panelId||n!=null&&n!==t.panelId&&n!==e.panelId)return fo.debug2("Incompatible panel ids",t,e,n),"invalid";if(t.panelComponent==null||e.panelComponent==null)return fo.error("PanelComponent should not be null",t,e),"invalid";const s=(l=Ep.ALLOWED_LINKS.get(t.panelComponent))==null?void 0:l.includes(e.panelComponent);if(s===void 0||!s)return fo.debug2("Incompatible panel components",t,e),"invalid";const{columnType:i}=t,{columnType:o}=e;if(!(o===null||P.isCompatibleType(i,o)))return fo.debug2("Incompatible type",i,o),"invalid";switch(e.panelComponent){case te.getComponentName(Pi):case te.getComponentName(ci):return"tableLink";case te.getComponentName(di):return"filterSource"}return fo.debug2("Incompatible target panel component",e.panelComponent),"invalid"}static findColumn(t,{columnName:e,columnType:n}){return t.find(({name:s,type:i})=>s===e&&i===n)}static cloneLinksForPanel(t,e,n){const s=[];return t.forEach(i=>{var o;i.start.panelId===e&&i.type!=="filterSource"?s.push({...i,id:We.generate(),start:{...i.start,panelId:n}}):((o=i.end)==null?void 0:o.panelId)===e&&s.push({...i,id:We.generate(),end:{...i.end,panelId:n}})}),s}};let ti=Ep;ti.ALLOWED_LINKS=new Map([[te.getComponentName(ci),[te.getComponentName(ci),te.getComponentName(Pi),te.getComponentName(di)]]]);const xh=.015,_h=1.5,yp=12,Ip=12,kh=2,Rr=Math.sqrt((Ip*.5)**2+yp**2),Lh=Math.asin(Ip*.5/yp),Oh=15,$a=class extends S.exports.PureComponent{static makeCirclePath(t,e,n){return`M ${t} ${e} m -${n},0 a ${n},${n} 0 1,0 ${n*2},0 a ${n},${n} 0 1,0 -${n*2},0 z`}constructor(t){super(t),this.handleClick=this.handleClick.bind(this)}handleClick(t){t.stopPropagation(),t.preventDefault();const{id:e,onClick:n}=this.props;n(e)}render(){const{className:t,x1:e,y1:n,x2:s,y2:i,id:o}=this.props,r=Math.sqrt((e-s)**2+(n-i)**2),l=Math.atan2(i-n,s-e),a=Math.sin(l),d=Math.cos(l)+2,c=window.innerWidth,u=window.innerHeight,m=0,p=0,g=Math.max(m,Math.min(e+(s-e)/2+a*(r*xh)**_h,c)),f=Math.max(p,Math.min(n+(i-n)/2+d*(r*xh)**_h,u)),b=`M ${e} ${n} Q ${g} ${f} ${s} ${i}`,C=`M ${m} ${p} L ${m} ${u} L ${c} ${u} L ${c} ${p} z
|
|
38
|
+
${Nn.NOTEBOOK.RUN_SELECTED.getDisplayText()}`}),H!=null&&h(Ie,{children:H})]}),h(Q,{kind:"ghost",className:"mr-auto",disabled:U,onClick:this.handleSave,icon:ou,tooltip:"Save"}),h(Q,{kind:"ghost",className:"btn-overflow btn-link-icon",disabled:U,icon:nu,tooltip:"More Actions...",onClick:()=>{},children:h(zn,{actions:y,popperOptions:Ni.POPPER_OPTIONS})})]}),h(Ku,{isLoaded:a,isLoading:d,error:r,onChange:this.handleEditorChange,onRunCommand:this.handleRunCommand,session:m,sessionLanguage:p,settings:I,focusOnMount:C,ref:V=>{this.notebook=V}})]}),T&&h(vp,{content:(k=I.value)!=null?k:"",onLinkClick:this.handleLinkClick,onRunCode:this.handleRunCommand,transformImageUri:this.handleTransformLinkUri,transformLinkUri:this.handleTransformLinkUri}),h(Al,{isOpen:b,type:"file",defaultValue:w,title:E?"Rename":"Save file as",onSubmit:this.handleSaveAsSubmit,onCancel:this.handleSaveAsCancel,notifyOnExtensionChange:!0,storage:t}),h(Hi,{isOpen:f,headerText:`Do you want to save the changes you made to ${w}?`,bodyText:"Your changes will be lost if you don't save them.",onCancel:this.handleCloseCancel,onDiscard:this.handleCloseDiscard,onConfirm:this.handleCloseSave,discardButtonText:"Discard Changes",confirmButtonText:"Save"}),h(ie,{actions:$})]})]})}};let Ko=Ni;Ko.COMPONENT="NotebookPanel";Ko.POPPER_OPTIONS={placement:"bottom-end"};Ko.DEFAULT_NAME="Untitled";Ko.defaultProps={isDashboardActive:!0,isPreview:!1,session:null,sessionLanguage:null};const LE=(t,e)=>{const n=nm(t),s=gi(t,e.localDashboardId),{session:i,config:o}=s!=null?s:{},{type:r}=o!=null?o:{};return{fileStorage:n,session:i,sessionLanguage:r}},Ks=Mt(LE,null,null,{forwardRef:!0})(Ko);class Do extends S.exports.Component{constructor(e){super(e),this.irisGridRef=Y.createRef(),this.buttonRef=Y.createRef(),this.handleReload=this.handleReload.bind(this),this.handleGridStateChange=this.handleGridStateChange.bind(this),this.handlePanelStateUpdate=this.handlePanelStateUpdate.bind(this);const{panelState:n}=e;this.state={shouldFocusGrid:!1,panelState:n}}handleReload(){var e,n;(e=this.irisGridRef.current)==null||e.initModel(),(n=this.buttonRef.current)==null||n.blur(),this.setState({shouldFocusGrid:!0})}handleGridStateChange(){var n,s,i;const{shouldFocusGrid:e}=this.state;e&&((i=(s=(n=this.irisGridRef.current)==null?void 0:n.irisGrid)==null?void 0:s.current)==null?void 0:i.grid)&&(this.irisGridRef.current.irisGrid.current.grid.focus(),this.setState({shouldFocusGrid:!1}))}handlePanelStateUpdate(e){this.setState({panelState:e})}render(){const{...e}=this.props;return h(ci,{ref:this.irisGridRef,onStateChange:this.handleGridStateChange,onPanelStateUpdate:this.handlePanelStateUpdate,...e,children:v(Q,{ref:this.buttonRef,kind:"primary",className:"btn-pandas",onClick:this.handleReload,tooltip:"Click to refresh pandas dataframe, updates do not occur automatically.",children:["pandas dataframe",v("span",{children:[h(q,{icon:od,transform:"shrink-1",className:"mr-1"}),"Reload"]})]})})}}Do.defaultProps={panelState:null};Do.COMPONENT="PandasPanel";const OE=t=>{Os(t);const{id:e,layout:n,registerComponent:s,hydrate:i}=t,o=S.exports.useCallback(({dragEvent:r,fetch:l,panelId:a=We.generate(),widget:d})=>{const{name:c,type:u}=d;if(u!==dh.VariableType.FIGURE)return;const m={name:c,figure:c},p=()=>l().then(b=>Bi.makeModel(void 0,b)),g={type:"react-component",component:Pi.COMPONENT,props:{localDashboardId:e,id:a,metadata:m,makeModel:p},title:c,id:a},{root:f}=n;te.openComponent({root:f,config:g,dragEvent:r})},[e,n]);return S.exports.useEffect(function(){const l=[s(Pi.COMPONENT,Pi,i)];return()=>{l.forEach(a=>a())}},[i,s]),Ke(n.eventHub,Me.OPEN,o),h(he,{})},AE=t=>{Os(t);const{id:e,layout:n}=t,s=S.exports.useCallback(({metadata:i,panelId:o=We.generate(),table:r})=>{const{settings:l}=i,a=()=>Bi.makeModelFromSettings(l,r),d=Le.titleFromSettings(l),c={type:"react-component",component:Pi.COMPONENT,props:{localDashboardId:e,id:o,metadata:i,makeModel:a},title:d,id:o},{root:u}=n;te.openComponent({root:u,config:c})},[e,n]);return Ke(n.eventHub,wt.CREATE_CHART,s),h(he,{})},at=X.module("ConsolePlugin");function Mh(t){return t.notebook!==void 0}function PE(t){Os(t)}const HE=t=>{PE(t);const{id:e,hydrateConsole:n,layout:s,panelManager:i,registerComponent:o,notebooksUrl:r}=t,l=S.exports.useRef(0),[a]=S.exports.useState(new Map),[d]=S.exports.useState(new Map),c=Xa(),u=S.exports.useCallback(()=>i.getLastUsedPanelOfType(_i),[i]),m=S.exports.useCallback((F,_=!0,k=!0)=>{if(!(F&&F.trim()))at.info("Ignoring empty code");else{const W=u();if(!W||!(W instanceof _i.WrappedComponent)){at.error("Console panel not found");return}at.debug("Send command: ",F,_,k),W.addCommand(F,_,k)}},[u]),p=S.exports.useCallback(F=>{c(eE(e,F))},[c,e]),g=S.exports.useCallback(({language:F})=>{const _=F==="python"?"py":F;let k=null;return _==null?(at.debug("No extension for language",F),k=`Untitled-${l.current}`):k=`Untitled-${l.current}.${_}`,l.current+=1,k},[]),f=S.exports.useCallback((F,_=!0)=>{const{id:k}=F;return k!=null&&a.has(k)?a.get(k):k!=null&&d.has(k)?d.get(k):_?We.generate():null},[a,d]),b=S.exports.useCallback((F,_)=>{te.renameComponent(s.root,{id:F},_)},[s.root]),C=S.exports.useCallback((F,_)=>{at.debug("Rename file panel",F,_);let k;if(a.has(F)&&(k=a.get(F),a.delete(F),k!=null&&a.set(_,k)),d.has(F)&&(k=d.get(F),d.delete(F),k!=null&&d.set(_,k)),k===void 0){at.debug2(`File ${F} isn't open, no need to rename the tab`);return}b(k,de.getBaseName(_))},[a,d,b]),w=S.exports.useCallback(F=>{const _=f(F,!1);if(_==null){at.error("Could not find panel id for file metadata",F);return}te.activateTab(s.root,{id:_})},[f,s.root]),T=S.exports.useCallback((F,_,k)=>{if(at.debug("registerFilePanel",F,_,k),_==null||_.id==null){at.debug("Ignore empty file id",_);return}const{id:V}=_;if(k){d.set(V,F);return}if(a.has(V)){const W=a.get(V);if(F===W){at.debug(`Update tab title for file ${V}`);const{itemName:j}=_;C(V,de.getBaseName(j))}else at.error(`File ${V} already associated with a different tab ${W}`);return}a.set(V,F),d.has(V)&&d.delete(V)},[a,d,C]),E=S.exports.useCallback((F,_)=>{if(at.debug("unregisterFileTab",F,_),F==null||F.id==null){at.debug("Ignore empty file id",F);return}const{id:k}=F;if(_){d.delete(k);return}a.delete(k)},[a,d]),y=S.exports.useCallback(F=>{at.debug("closeFilePanel",F);const{id:_}=F;let k=null,V=!1;if(a.has(_))k=a.get(_);else if(d.has(_))k=d.get(_),V=!0;else{at.debug(`File ${_} isn't open, ignore close event`);return}E(F,V),te.closeComponent(s.root,{id:k})},[s.root,a,d,E]),I=S.exports.useCallback(F=>{const{itemName:_}=F;return de.getBaseName(_)},[]),D=S.exports.useCallback(F=>{const{id:_}=F;return at.debug("fileIsOpen",F,_,a),_!=null&&a.has(_)},[a]),N=S.exports.useCallback(F=>{const{id:_}=F;return at.debug("fileIsOpenAsPreview",F,_,d),_!=null&&d.has(_)},[d]),x=S.exports.useCallback(F=>{if(F==null)return;const _=i.getOpenedPanelById(F);_&&Mh(_)&&_.focus()},[i]),U=S.exports.useCallback(({id:F,settings:_,fileMetadata:k,session:V,sessionLanguage:W,isPreview:j=!1})=>{const ee={settings:_,fileMetadata:k},ve=I(k);return{type:"react-component",component:Ks.COMPONENT,isFocusOnShow:!1,props:{localDashboardId:e,metadata:{id:F},session:V,sessionLanguage:W,panelState:ee,isPreview:j,notebooksUrl:r},title:ve,id:F}},[I,e,r]),$=S.exports.useCallback((F,_,k,V={id:null,itemName:g(k)})=>{const W=f(V);if(D(V)&&W!=null){at.debug("File is already open, focus panel"),w(V),x(W);return}const j=te.getStackForComponentTypes(s.root,[Ks.COMPONENT]),ee=U({id:W,settings:k,fileMetadata:V,session:F,sessionLanguage:_});at.debug("createNotebook",ee,a),te.openComponentInStack(j,ee)},[D,x,g,f,s.root,U,a,w]),L=S.exports.useCallback((F,_,k,V,W=!1)=>{at.debug("selectNotebook",V,W);const j=D(V),ee=N(V);if(j){if(w(V),W){const J=f(V);x(J)}return}if(ee&&!W){w(V);return}const[ve]=Array.from(d.values());let le=null,Se=null;ve!=null&&(le=ve,Se=te.getStackForConfig(s.root,{component:Ks.COMPONENT,id:le})),Se==null&&(le=f(V),Se=te.getStackForComponentTypes(s.root,[Ks.COMPONENT]));const Oe=U({id:le,settings:k,fileMetadata:V,session:F,sessionLanguage:_,isPreview:!W});te.openComponentInStack(Se,Oe),W&&x(le)},[w,D,N,x,f,s.root,U,d]),H=S.exports.useCallback((F,_,k={},V=!0)=>{const W=i.getLastUsedPanelOfType(Ks);W&&Mh(W)?k!=null&&k.value!=null&&W.notebook!=null&&W.notebook.append(k.value):V&&$(F,_,k)},[$,i]),O=S.exports.useCallback((F,_)=>_a.hydrate({...F,notebooksUrl:r},_),[r]);return S.exports.useEffect(function(){const _=[o(_i.COMPONENT,_i,n),o(Zr.COMPONENT,Zr),o(Jr.COMPONENT,Jr),o(tl.COMPONENT,tl),o(Ks.COMPONENT,Ks,O)];return()=>{_.forEach(k=>k())}},[o,n,O]),Ke(s.eventHub,ft.SEND_COMMAND,m),Ke(s.eventHub,ft.SETTINGS_CHANGED,p),Ke(s.eventHub,He.CLOSE_FILE,y),Ke(s.eventHub,He.CREATE_NOTEBOOK,$),Ke(s.eventHub,He.SELECT_NOTEBOOK,L),Ke(s.eventHub,He.RENAME,b),Ke(s.eventHub,He.RENAME_FILE,C),Ke(s.eventHub,He.SEND_TO_NOTEBOOK,H),Ke(s.eventHub,He.REGISTER_FILE,T),Ke(s.eventHub,He.UNREGISTER_FILE,E),h(he,{})},go=X.module("FilterPlugin");function Nh(t,e){return t.concat(e)}const VE=t=>{Os(t);const{id:e,layout:n,registerComponent:s}=t,i=Xa(),[o]=S.exports.useState(()=>new Map),[r]=S.exports.useState(()=>new Map),[l]=S.exports.useState(()=>new Map),a=S.exports.useCallback(()=>{const b=Array.from(o.values()).reduce(Nh,[]).sort((T,E)=>{const y=tn.toLower(T.name),I=tn.toLower(E.name);if(y!==I)return y>I?1:-1;const D=tn.toLower(T.type),N=tn.toLower(E.type);return D!==N?D>N?1:-1:0}).reduce((T,E)=>((T.length===0||tn.toLower(T[T.length-1].name)!==tn.toLower(E.name)||tn.toLower(T[T.length-1].type)!==tn.toLower(E.type))&&T.push(E),T),[]),C=Array.from(r.values()).reduce(Nh,[]).sort((T,E)=>T.timestamp-E.timestamp),w=new Map(l);go.debug("sendUpdate",{columns:b,filters:C,tableMap:w}),i(qn(e,{columns:b,filters:C,tableMap:w}))},[i,e,o,r,l]),d=S.exports.useCallback((b,C)=>{go.debug2("handleColumnsChanged",b,C),o.set(b,[].concat(C)),a()},[o,a]),c=S.exports.useCallback((b,C)=>{go.debug2("handleFiltersChanged",b,C),r.set(b,[].concat(C)),a()},[r,a]),u=S.exports.useCallback((b,C)=>{go.debug2("handleTableChanged",b,C),l.set(te.getIdFromPanel(b),C),a()},[l,a]),m=S.exports.useCallback(b=>{go.debug2("handlePanelUnmount",b),o.delete(b),r.delete(b),l.delete(te.getIdFromPanel(b)),a()},[o,r,l,a]),p=S.exports.useCallback(({title:b="DropdownFilter",metadata:C={},panelState:w=null,id:T=We.generate(),focusElement:E=te.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:I=null})=>{const D={type:"react-component",component:di.COMPONENT,props:{id:T,metadata:C,panelState:w,localDashboardId:e},title:b,id:T},{root:N}=n;te.openComponent({root:N,config:D,focusElement:E,createNewStack:y,dragEvent:I})},[n,e]),g=S.exports.useCallback(({title:b="InputFilter",metadata:C={},panelState:w=null,id:T=We.generate(),focusElement:E=te.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:I=null})=>{const D={type:"react-component",component:Ro.COMPONENT,props:{id:T,metadata:C,panelState:w,localDashboardId:e},title:b,id:T},{root:N}=n;te.openComponent({root:N,config:D,focusElement:E,createNewStack:y,dragEvent:I})},[n,e]),f=S.exports.useCallback(({title:b="FilterSets",metadata:C={},panelState:w=null,id:T=We.generate(),focusElement:E=te.DEFAULT_FOCUS_SELECTOR,createNewStack:y=!1,dragEvent:I=null})=>{const D={type:"react-component",component:ma.COMPONENT,props:{id:T,metadata:C,panelState:w,localDashboardId:e},title:b,id:T},{root:N}=n;te.openComponent({root:N,config:D,focusElement:E,createNewStack:y,dragEvent:I})},[n,e]);return S.exports.useEffect(function(){const C=[s(di.COMPONENT,di),s(Ro.COMPONENT,Ro),s(ma.COMPONENT,ma)];return()=>{C.forEach(w=>w())}},[s]),Ke(n.eventHub,Pe.COLUMNS_CHANGED,d),Ke(n.eventHub,Pe.FILTERS_CHANGED,c),Ke(n.eventHub,Pe.TABLE_CHANGED,u),Ke(n.eventHub,Pe.OPEN_DROPDOWN,p),Ke(n.eventHub,Pe.OPEN_INPUT,g),Ke(n.eventHub,Pe.OPEN_FILTER_SET_MANAGER,f),Ke(n.eventHub,Me.UNMOUNT,m),h(he,{})},UE=[dh.VariableType.TABLE,dh.VariableType.TREETABLE],BE=t=>{Os(t);const{getDownloadWorker:e,loadPlugin:n,id:s,layout:i,registerComponent:o,hydrate:r,theme:l}=t,a=S.exports.useCallback(({dragEvent:d,fetch:c,panelId:u=We.generate(),widget:m})=>{const{name:p,type:g}=m;if(!UE.includes(g))return;const f={name:p,table:p},b=()=>c().then(T=>Vd.makeModel(T)),C={type:"react-component",component:ci.COMPONENT,props:{getDownloadWorker:e,loadPlugin:n,localDashboardId:s,id:u,metadata:f,makeModel:b,theme:l},title:p,id:u},{root:w}=i;te.openComponent({root:w,config:C,dragEvent:d})},[e,s,i,n,l]);return S.exports.useEffect(function(){const c=[o(ci.COMPONENT,ci,r)];return()=>{c.forEach(u=>u())}},[r,o]),Ke(i.eventHub,Me.OPEN,a),h(he,{})};function Tp(t){return typeof t.getCoordinateForColumn=="function"}function Fh(t){const e=t;return Tp(t)&&typeof e.setFilterMap=="function"&&typeof e.unsetFilterValue=="function"}const fo=X.module("LinkerUtils"),Ep=class{static getLinkType(t,e,n){var l;if((t==null?void 0:t.panelId)==null||(e==null?void 0:e.panelId)==null||t.panelId===e.panelId||n!=null&&n!==t.panelId&&n!==e.panelId)return fo.debug2("Incompatible panel ids",t,e,n),"invalid";if(t.panelComponent==null||e.panelComponent==null)return fo.error("PanelComponent should not be null",t,e),"invalid";const s=(l=Ep.ALLOWED_LINKS.get(t.panelComponent))==null?void 0:l.includes(e.panelComponent);if(s===void 0||!s)return fo.debug2("Incompatible panel components",t,e),"invalid";const{columnType:i}=t,{columnType:o}=e;if(!(o===null||P.isCompatibleType(i,o)))return fo.debug2("Incompatible type",i,o),"invalid";switch(e.panelComponent){case te.getComponentName(Pi):case te.getComponentName(ci):return"tableLink";case te.getComponentName(di):return"filterSource"}return fo.debug2("Incompatible target panel component",e.panelComponent),"invalid"}static findColumn(t,{columnName:e,columnType:n}){return t.find(({name:s,type:i})=>s===e&&i===n)}static cloneLinksForPanel(t,e,n){const s=[];return t.forEach(i=>{var o;i.start.panelId===e&&i.type!=="filterSource"?s.push({...i,id:We.generate(),start:{...i.start,panelId:n}}):((o=i.end)==null?void 0:o.panelId)===e&&s.push({...i,id:We.generate(),end:{...i.end,panelId:n}})}),s}};let ti=Ep;ti.ALLOWED_LINKS=new Map([[te.getComponentName(ci),[te.getComponentName(ci),te.getComponentName(Pi),te.getComponentName(di)]]]);const xh=.015,_h=1.5,yp=12,Ip=12,kh=2,Rr=Math.sqrt((Ip*.5)**2+yp**2),Lh=Math.asin(Ip*.5/yp),Oh=15,$a=class extends S.exports.PureComponent{static makeCirclePath(t,e,n){return`M ${t} ${e} m -${n},0 a ${n},${n} 0 1,0 ${n*2},0 a ${n},${n} 0 1,0 -${n*2},0 z`}constructor(t){super(t),this.handleClick=this.handleClick.bind(this)}handleClick(t){t.stopPropagation(),t.preventDefault();const{id:e,onClick:n}=this.props;n(e)}render(){const{className:t,x1:e,y1:n,x2:s,y2:i,id:o}=this.props,r=Math.sqrt((e-s)**2+(n-i)**2),l=Math.atan2(i-n,s-e),a=Math.sin(l),d=Math.cos(l)+2,c=window.innerWidth,u=window.innerHeight,m=0,p=0,g=Math.max(m,Math.min(e+(s-e)/2+a*(r*xh)**_h,c)),f=Math.max(p,Math.min(n+(i-n)/2+d*(r*xh)**_h,u)),b=`M ${e} ${n} Q ${g} ${f} ${s} ${i}`,C=`M ${m} ${p} L ${m} ${u} L ${c} ${u} L ${c} ${p} z
|
|
39
39
|
${$a.makeCirclePath(e,n,Oh)}
|
|
40
40
|
${$a.makeCirclePath(s,i,Oh)}`,w=`link-select-clip-${o}`,T=Math.atan2(i-f,s-g),E=T-Lh+Math.PI,y=T+Lh+Math.PI,I=s+Math.cos(T)*kh,D=i+Math.sin(T)*kh,N=I+Math.cos(E)*Rr,x=D+Math.sin(E)*Rr,U=I+Math.cos(y)*Rr,$=D+Math.sin(y)*Rr,L=`${I},${D} ${N},${x} ${U},${$}`;return v("svg",{className:t,children:[h("clipPath",{id:w,children:h("path",{d:C,clipRule:"evenodd"})}),h("path",{className:"link-select",d:b,onClick:this.handleClick,clipPath:`url(#${w})`}),h("path",{className:"link-background",d:b}),h("path",{className:"link-foreground",d:b}),h("circle",{className:"link-dot",cx:e,cy:n,r:"5"}),h("polygon",{className:"link-triangle",points:L})]})}};let Rp=$a;Rp.defaultProps={className:"",onClick(){}};const pa=X.module("LinkerOverlayContent");class Dp 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){pa.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(!Tp(o))throw new Error(`Panel does not have getCoordinateForColumn method: ${s}`);try{const l=o.getCoordinateForColumn(i);if(l!=null)return l}catch{pa.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 te.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:l,mouseY:a}=this.state,d=n.map(c=>{try{const{id:u,type:m,isReversed:p,start:g,end:f}=c;let[b,C]=this.getPointFromLinkPoint(g),w=l!=null?l:b,T=a!=null?a:C;if(f!=null&&([w,T]=this.getPointFromLinkPoint(f)),p!=null&&p){const[y,I]=[b,C];[b,C]=[w,T],[w,T]=[y,I]}const E=z("linker-link",{disabled:e},{"link-filter-source":m==="filterSource"},{"link-invalid":m==="invalid"},{interactive:c.end==null});return{x1:b,y1:C,x2:w,y2:T,id:u,className:E}}catch(u){return pa.error("Unable to get point for link",c,u),null}}).filter(c=>c!=null);return v("div",{className:"linker-overlay",children:[h("svg",{children:d.map(({x1:c,y1:u,x2:m,y2:p,id:g,className:f})=>h(Rp,{className:f,id:g,x1:c,y1:u,x2:m,y2:p,onClick:i},g))}),v("div",{className:"linker-toast-dialog",children:[h("div",{className:"toast-body",children:s}),v("div",{className:"toast-footer",children:[h(Q,{kind:"secondary",onClick:o,children:"Clear All"}),h(Q,{kind:"primary",onClick:r,children:"Done"})]})]}),h(ie,{actions:[{action:this.handleEscapePressed,shortcut:ks.LINKER_CLOSE,isGlobal:!0}]})]})}}Dp.defaultProps={disabled:"false"};const Bt=X.module("Linker"),$E=(t,e)=>({activeTool:Tl(t),isolatedLinkerPanelId:$d(t,e.localDashboardId),links:eo(t,e.localDashboardId),timeZone:vl(t)}),zE=Mt($E,{setActiveTool:El,setDashboardLinks:Wd,addDashboardLinks:QT,deleteDashboardLinks:ZT,setDashboardIsolatedLinkerPanelId:mp,setDashboardColumnSelectionValidator:JT});class WE extends S.exports.Component{constructor(e){super(e),this.getCachedLinks=ge((n,s,i)=>{const o=[...n];return s!=null&&s.start!=null&&o.push(s),i!==void 0?o.filter(r=>{var l,a;return((l=r==null?void 0:r.start)==null?void 0:l.panelId)===i||((a=r==null?void 0:r.end)==null?void 0:a.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){Bt.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(wt.COLUMN_SELECTED,this.handleGridColumnSelect),n.on(wt.DATA_SELECTED,this.handleUpdateValues),n.on(wt.STATE_CHANGED,this.handleStateChange),n.on(zi.COLUMN_SELECTED,this.handleChartColumnSelect),n.on(Me.CLONED,this.handlePanelCloned),n.on(Pe.COLUMN_SELECTED,this.handleFilterColumnSelect),n.on(Pe.COLUMNS_CHANGED,this.handleColumnsChanged),n.on(Me.CLOSED,this.handlePanelClosed)}stopListening(e){e.off("stateChanged",this.handleLayoutStateChanged);const{eventHub:n}=e;n.off(wt.COLUMN_SELECTED,this.handleGridColumnSelect),n.off(wt.DATA_SELECTED,this.handleUpdateValues),n.off(wt.STATE_CHANGED,this.handleStateChange),n.off(zi.COLUMN_SELECTED,this.handleChartColumnSelect),n.off(Me.CLONED,this.handlePanelCloned),n.off(Pe.COLUMN_SELECTED,this.handleFilterColumnSelect),n.off(Pe.COLUMNS_CHANGED,this.handleColumnsChanged),n.off(Me.CLOSED,this.handlePanelClosed)}handleCancel(){const{linkInProgress:e}=this.state;if(e==null){const{setActiveTool:n}=this.props;n(cn.DEFAULT)}this.setState({linkInProgress:void 0})}handleDone(){const{setActiveTool:e}=this.props;e(cn.DEFAULT),this.setState({linkInProgress:void 0})}handleChartColumnSelect(e,n){this.columnSelected(e,n,!0)}handleFilterColumnSelect(e,n){Bt.debug("handleFilterColumnSelect",this.isOverlayShown());const{links:s,localDashboardId:i,setActiveTool:o,setDashboardIsolatedLinkerPanelId:r}=this.props,l=te.getIdFromPanel(e),a=s.filter(d=>{var c,u;return((c=d.start)==null?void 0:c.panelId)===l||((u=d.end)==null?void 0:u.panelId)===l});if(!this.isOverlayShown()&&l!=null){o(cn.LINKER),r(i,l),a.length===0&&this.columnSelected(e,n,!0,l);return}this.columnSelected(e,n,!0)}handleColumnsChanged(e,n){Bt.debug("handleColumnsChanged",e,n);const{links:s}=this.props,i=te.getIdFromPanel(e);if(i==null){Bt.error("Invalid panelId",e);return}const o=s.filter(({start:r,end:l})=>r.panelId===i&&ti.findColumn(n,r)==null||l!=null&&l.panelId===i&&ti.findColumn(n,l)==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,l=te.getIdFromPanel(e);if(l==null)return;const a=te.getComponentNameFromPanel(e),{name:d,type:c}=n;if(r==null||r.start==null){const u={id:We.generate(),start:{panelId:l,panelComponent:a,columnName:d,columnType:c},type:"invalid",isReversed:s};Bt.debug("starting link",u),this.setState({linkInProgress:u})}else{const{start:u,id:m,isReversed:p}=r,g={panelId:l,panelComponent:a,columnName:d,columnType:c},f=ti.getLinkType(p!==void 0&&p?g:u,p!==void 0&&p?u:g,i!=null?i:o);switch(f){case"invalid":Bt.debug("Ignore invalid link connection",r,g);return;case"filterSource":{const{links:C}=this.props,w=p!==void 0&&p?u.panelId:g.panelId,T=C.filter(({end:E})=>(E==null?void 0:E.panelId)===w);this.deleteLinks(T);break}}const b={start:p!==void 0&&p?g:u,end:p!==void 0&&p?u:g,id:m,type:f};Bt.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,l=n.getOpenedPanelById(i);l?Fh(l)?l.unsetFilterValue(o,r):Bt.debug("endPanel.unsetFilterValue not implemented",l):Bt.debug("endPanel no longer exists, ignoring unsetFilterValue",i)}}setPanelFilterMap(e,n){Bt.debug("Set filter data for panel:",e,n);const{panelManager:s}=this.props,i=s.getOpenedPanelById(e);i?Fh(i)?i.setFilterMap(n):Bt.debug("panel.setFilterMap not implemented",e,i):Bt.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]):Bt.error("Unable to find link to delete",e)}handleUpdateValues(e,n){const s=te.getIdFromPanel(e),{links:i,timeZone:o}=this.props,r=new Map;for(let l=0;l<i.length;l+=1){const{start:a,end:d}=i[l];if(a.panelId===s&&d!=null){const{panelId:c,columnName:u,columnType:m}=d,p=r.has(c)?r.get(c):new Map,{value:g}=n[a.columnName];let f=`${g}`;m!=null&&P.isDateType(m)&&(f=new lt({timeZone:o,showTimeZone:!1,showTSeparator:!0,defaultDateTimeFormatString:us.FULL_DATE_FORMAT}).format(g)),p.set(u,{columnType:m,text:f,value:g}),r.set(c,p)}}r.forEach((l,a)=>{this.setPanelFilterMap(a,l)})}handlePanelCloned(e,n){const{links:s}=this.props,i=te.getIdFromPanel(e),o=n.id;if(i!=null){const r=ti.cloneLinksForPanel(s,i,o);this.addLinks(r)}}handlePanelClosed(e){Bt.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:l}=i;(o.panelId===e||(r==null?void 0:r.panelId)===e)&&this.handleLinkDeleted(l)}}isOverlayShown(){const{activeTool:e}=this.props;return e===cn.LINKER}updateSelectionValidators(){const{activeTool:e,setDashboardColumnSelectionValidator:n,localDashboardId:s}=this.props;switch(e){case cn.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,l=te.getIdFromPanel(e);if(l==null)return!1;const a={panelId:l,panelComponent:te.getComponentNameFromPanel(e),columnName:n.name,columnType:n.type},d=o!==void 0&&o?ti.getLinkType(a,r,i):ti.getLinkType(r,a,i);return this.updateLinkInProgressType(s,d),d!=="invalid"}render(){const{links:e,isolatedLinkerPanelId:n,panelManager:s}=this.props,{linkInProgress:i}=this.state,o=this.isOverlayShown(),r=i!=null&&i.start!=null,l=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 h(he,{children:h(ht,{in:o,timeout:Tt.transitionMs,classNames:"fade",mountOnEnter:!0,unmountOnExit:!0,onExited:this.handleExited,children:h(Dp,{disabled:r,panelManager:s,links:this.getCachedLinks(e,i,n),messageText:l,onLinkDeleted:this.handleLinkDeleted,onAllLinksDeleted:this.handleAllLinksDeleted,onDone:this.handleDone,onCancel:this.handleCancel})})})}}const GE=zE(WE),KE=t=>{Os(t);const{id:e,layout:n,panelManager:s}=t;return h(GE,{layout:n,localDashboardId:e,panelManager:s})},za=class{static getNewMarkdownTitle(t){let e=`${za.DEFAULT_TITLE}`,n=0;for(;t.indexOf(e)>=0;)n+=1,e=`${za.DEFAULT_TITLE}-${n}`;return e}};let Mo=za;Mo.DEFAULT_TITLE="Note";Mo.DEFAULT_CONTENT=`# Markdown Note
|
|
41
41
|
|
|
42
42
|
This note can be edited using **markdown** for styling.`;const qE=t=>{Os(t);const{id:e,layout:n,panelManager:s,registerComponent:i}=t,o=S.exports.useCallback(l=>{const{title:a,componentState:d,props:c}=l;let{panelState:u=null}=c;return d!=null&&({panelState:u=null}=d),a==null||u==null||u.content==null||u.content.length===0||u.content===Mo.DEFAULT_CONTENT?null:yd(l)},[]),r=S.exports.useCallback(({title:l="",metadata:a={},id:d=We.generate(),focusElement:c=te.DEFAULT_FOCUS_SELECTOR,createNewStack:u=!1,dragEvent:m=null}={})=>{const p=s.getOpenedPanelConfigsOfType(po.COMPONENT),g=s.getClosedPanelConfigsOfType(po.COMPONENT),f=p.map(E=>{var y;return(y=E.title)!=null?y:""}),b=l!=null&&l!==""?l:Mo.getNewMarkdownTitle(f),C=g.length>0?null:Mo.DEFAULT_CONTENT,w={type:"react-component",component:po.COMPONENT,props:{id:d,metadata:a,panelState:{content:C},localDashboardId:e},title:b,id:d},{root:T}=n;te.openComponent({root:T,config:w,focusElement:c,createNewStack:u,dragEvent:m})},[e,n,s]);return S.exports.useEffect(function(){const a=[i(po.COMPONENT,po,Id,o)];return()=>{a.forEach(d=>d())}},[o,i]),Ke(n.eventHub,dp.OPEN,r),h(he,{})},YE=t=>{Os(t);const{hydrate:e,id:n,layout:s,registerComponent:i}=t,o=S.exports.useCallback(({dragEvent:r,fetch:l,panelId:a=We.generate(),widget:d})=>{const{name:c,type:u}=d;if(u!==dh.VariableType.PANDAS)return;const m={name:c,table:c},p=()=>l().then(b=>Vd.makeModel(b)),g={type:"react-component",component:Do.COMPONENT,props:{localDashboardId:n,id:a,metadata:m,makeModel:p},title:c,id:a},{root:f}=s;te.openComponent({root:f,config:g,dragEvent:r})},[n,s]);return S.exports.useEffect(function(){const l=[i(Do.COMPONENT,Do,e)];return()=>{l.forEach(a=>a())}},[e,i]),Ke(s.eventHub,Me.OPEN,o),h(he,{})};class Cn{}Cn.DROPDOWN_FILTER="ControlType.DROPDOWN_FILTER";Cn.INPUT_FILTER="ControlType.INPUT_FILTER";Cn.MARKDOWN="ControlType.MARKDOWN";Cn.FILTER_SET_MANAGER="ControlType.FILTER_SET_MANAGER";const XE=R.exports.shape({state:R.exports.shape({panelState:R.exports.shape({})})}),jE=R.exports.shape({panelId:R.exports.string.isRequired,columnName:R.exports.string.isRequired,columnType:R.exports.string.isRequired}),Ah=R.exports.shape({panelId:R.exports.string.isRequired,columnName:R.exports.string.isRequired}),Mp=R.exports.shape({start:Ah,end:Ah,id:R.exports.string,isReversed:R.exports.bool}),QE=R.exports.arrayOf(Mp),ZE=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:jE,Link:Mp,Links:QE,Panel:XE,User:ZE});const JE=(t,e)=>t[e]===null?null:R.exports.bool,e1=(t,e)=>t[e]===null?null:R.exports.string;Object.freeze({nullableBoolean:JE,nullableString:e1});X.module("StorageTableViewportUpdater");class Ph{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(Wt.and)}),{filterItems:n,filterOperators:s}}static combineFilterConfigs(e,n,s=Wt.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 ga=X.module("PouchStorageTable"),t1="Deephaven.";qh.plugin(Jp);function n1(t,e){switch(t){case K.in:case K.contains:return{$regex:new RegExp(`${e}`)};case K.inIgnoreCase:return{$regex:new RegExp(`${e}`,"i")};case K.eq:return{$eq:e};case K.notEq:return{$neq:e};case K.greaterThan:return{$gt:e};case K.greaterThanOrEqualTo:return{$gte:e};case K.lessThan:return{$lt:e};case K.lessThanOrEqualTo:return{$lte:e};case K.startsWith:return{$regex:new RegExp(`^(?${e}).*`)};default:throw new Error(`Unsupported type: ${t}`)}}function s1(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:l,value:a}=o,d={[r]:n1(l,a)};if(i===0)s=d;else if(s!==null&&i-1<n.length){const c=n[i-1];if(c===Wt.and)s={$and:[s,d]};else if(c===Wt.or)s={$or:[s,d]};else throw new Error(`Unexpected filter operator ${c}, ${d}`)}}if(s==null)throw new Error(`Invalid filter config ${t}`);return s}function fa(t=[]){return{$and:[...t.map(e=>s1(e)),{name:{$gt:null}},{id:{$gt:null}}]}}function i1(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 o1{constructor(e){this.listeners=[],this.itemListeners=new Map,this.currentSize=0,this.currentReverse=!1,this.currentFilter=null,this.currentSort=null,this.db=new qh(`${t1}${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){ga.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=Ee.makeCancelable(this.db.find({selector:fa((n=this.currentFilter)!=null?n:[]),fields:[]}));const s=await this.infoUpdatePromise;this.currentSize=s.docs.length,this.sendUpdate()}catch(s){if(!Ee.isCanceled(s))throw ga.error("Unable to refreshInfo",s),s}}async refreshData(){var e,n;if(!!this.currentViewport)try{const{currentViewport:s}=this,i=i1(this.currentSort,this.currentReverse);(e=this.viewportUpdatePromise)==null||e.cancel(),this.viewportUpdatePromise=Ee.makeCancelable(this.db.find({selector:fa((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(!Ee.isCanceled(s))throw ga.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 l;const r=o-i+1;return this.db.find({selector:fa((l=this.currentFilter)!=null?l:[]),skip:i,limit:r,sort:s,fields:["id","name"]}).then(a=>{for(let d=0;d<r;d+=1){const c=i+d;n.set(c,a.docs[d])}})})),n}}class Hh extends o1{constructor(e){super(`CommandHistoryStorage.${e}`)}setSearch(e){this.setFilters(e?[Ph.makeFilterConfig([Ph.makeFilterItem("name",K.contains,e)])]:[])}}const Vh=X.module("PouchCommandHistoryStorage");class r1{constructor(){this.updateTableMap=new Map}getUpdateTable(e){return this.updateTableMap.has(e)||this.updateTableMap.set(e,new Hh(e)),this.updateTableMap.get(e)}async getTable(e){return new Hh(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 Vh.debug("Updating item",o),await s.put(o),Vh.debug("Update saved"),n}listenItem(e,n,s){return this.getUpdateTable(e).onItemUpdate(n,s)}}const Np="SET_LAYOUT_STORAGE",l1=t=>({type:Np,payload:t}),Fp="/ide/assets/community-wordmark-app.d2c5c1eb.svg";const Ds=X.module("FormattingSectionContent");function a1(t){return t.formatString!=null}const ot=class extends S.exports.PureComponent{constructor(t){super(t),this.getCachedColumnTypeOptions=Te(()=>ot.renderColumnTypeOptions()),this.getCachedDateTimeFormatOptions=Te((c,u,m,p=!1,g=null)=>{const{timestampAtMenuOpen:f}=this.state;return ot.renderDateTimeOptions(f,c,u,m,p,g)}),this.debouncedCommitChanges=Xe(this.commitChanges.bind(this),ot.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:l,truncateNumbersWithPound:a}=t,d=e.map((c,u)=>({...c,id:u}));this.containerRef=Y.createRef(),this.addFormatRuleButtonRef=Y.createRef(),this.lastFormatRuleIndex=d.length,this.state={formatSettings:d,formatRulesChanged:!1,showTimeZone:o,showTSeparator:r,timeZone:l,defaultDateTimeFormat:n,defaultDecimalFormatOptions:s,defaultIntegerFormatOptions:i,truncateNumbersWithPound:a,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 ot.isSameOptions(t,e)}static isSameIntegerOptions(t,e){return ot.isSameOptions(t,e)}static isValidColumnName(t){return t!==""&&ms.isValidColumnName(t)}static isValidFormat(t,e){if(!t||e.formatString==null||!a1(e))return!1;switch(t){case"datetime":return lt.isValid(e);case"decimal":return Ue.isValid(e);case"int":return dt.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 ot.isValidColumnName(t.columnName)&&ot.isValidFormat(t.columnType,t.format)}static renderTimeZoneOptions(){return In.TIME_ZONES.map(e=>{const{label:n,value:s}=e;return h("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=>h("option",{value:n.value,children:n.label},`key-columnType-${n.value}`));return v(he,{children:[h("option",{disabled:!0,value:"",children:"Select Type"},"key-columnType-placeholder"),e]})}static renderDateTimeOptions(t,e,n,s,i,o){const r=new hn([],{timeZone:e,showTimeZone:n,showTSeparator:s}),l=i?lt.getGlobalFormats(n,s):lt.getFormats(n,s);return o&&!l.includes(o)&&l.unshift(o),l.map(a=>{const d=lt.makeFormat("",a,lt.TYPE_GLOBAL);return h("option",{value:a,children:r.getFormattedString(t,P.dataType.DATETIME,"",d)},a)})}componentDidMount(){ot.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;A(i);const o=[...i];let r={};e==="columnType"&&(r={format:""});const l={...o[t],...r,[e]:n};return o[t]=l,{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(),ot.focusFirstInputInContainer(t)}commitChanges(){var m;const{formatSettings:t,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,defaultDecimalFormatOptions:o,defaultIntegerFormatOptions:r,truncateNumbersWithPound:l}=this.state,a=(m=t.filter(ot.isFormatRuleValidForSave).map(ot.removeFormatRuleExtraProps))!=null?m:[],{settings:d,saveSettings:c}=this.props,u={...d,formatter:a,defaultDateTimeFormat:e,showTimeZone:n,showTSeparator:s,timeZone:i,truncateNumbersWithPound:l};ot.isValidFormat(P.dataType.DECIMAL,Ue.makeCustomFormat(o.defaultFormatString))&&(u.defaultDecimalFormatOptions=o),ot.isValidFormat(P.dataType.INT,dt.makeCustomFormat(r.defaultFormatString))&&(u.defaultIntegerFormatOptions=r),c(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!==void 0&&t.isNewRule||(this.isDuplicateRule(t)&&(e.hasColumnNameError=!0,n.push("Duplicate column name/type combo.")),ot.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!=null?(e.hasFormatError=!0,n.push("Empty formatting rule.")):ot.isValidFormat(t.columnType,t.format)||(e.hasFormatError=!0,n.push("Invalid formatting rule.")),e.message=n.join(`
|
|
43
43
|
`)),e}renderFormatRule(t,e){const n=`input-${t}-columnName`,s=`input-${t}-columnType`,i=`input-${t}-format`,o=this.getCachedColumnTypeOptions(),r=c=>this.handleFormatRuleChange(t,"columnName",c.target.value),l=()=>this.handleFormatRuleChange(t,"isNewRule",!1),a=c=>this.handleFormatRuleChange(t,"columnType",c.target.value),d=this.getRuleError(e);return v("fieldset",{className:"container-fluid format-rule-container",children:[v("div",{className:"form-row",children:[v("div",{className:"form-group col-7 mb-2",children:[h("label",{htmlFor:n,children:"Column Name"}),h("input",{id:n,className:z("form-control",{"is-invalid":d.hasColumnNameError}),"data-lpignore":!0,type:"text",value:e.columnName,onChange:r,onBlur:l})]}),v("div",{className:"form-group col mb-2",children:[h(Q,{kind:"ghost",className:"btn-delete-format-rule float-right",tabIndex:-1,onClick:()=>this.handleFormatRuleDelete(t),icon:xn,tooltip:"Delete"}),h("label",{htmlFor:s,children:"Column Type"}),h("select",{id:s,className:"custom-select",value:e.columnType,onChange:a,children:o})]})]}),h("div",{className:"form-row",children:v("div",{className:"form-group col-12 d-flex mb-2",children:[h("label",{className:"flex-shrink-0 col-form-label mr-3",htmlFor:i,children:"Formatting Rule"}),this.renderFormatRuleInput(t,e.columnType,i,e.format,d.hasFormatError)]})}),h("div",{className:"form-row",children:h("div",{className:"form-group col-12 d-flex mb-2",children:d.message&&h("p",{className:"text-danger",children:d.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,l=n!=null&&n.formatString||"";return v("select",{className:z("custom-select",{"is-invalid":s}),value:l,id:e,onChange:a=>{const d=lt.makeFormat("",a.target.value,lt.TYPE_GLOBAL);this.handleFormatRuleChange(t,"format",d)},children:[h("option",{value:"",disabled:!0,children:"Select format"},"default"),this.getCachedDateTimeFormatOptions(r,i,o)]})}renderIntegerFormatRuleInput(t,e,n,s){const i=n!=null&&n.formatString||"";return h("input",{className:z("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:dt.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=dt.makeFormat("",o.target.value,dt.TYPE_GLOBAL,void 0);this.handleFormatRuleChange(t,"format",r)}})}renderDecimalFormatRuleInput(t,e,n,s){const i=n!=null&&n.formatString||"";return h("input",{className:z("form-control","flex-grow-1",{"is-invalid":s}),"data-lpignore":!0,id:e,placeholder:Ue.DEFAULT_FORMAT_STRING,type:"text",value:i,onChange:o=>{const r=Ue.makeFormat("",o.target.value,Ue.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:l,showTSeparator:a,truncateNumbersWithPound:d}=this.state,{defaultFormatString:c=Ue.DEFAULT_FORMAT_STRING}=i!=null?i:{},{defaultFormatString:u=dt.DEFAULT_FORMAT_STRING}=o!=null?o:{},m=n.map((w,T)=>h(ht,{classNames:"fade",timeout:Tt.transitionMs,onEnter:this.handleFormatRuleEntered,children:this.renderFormatRule(T,w)},w.id)),p=h(Q,{kind:"ghost",className:"mb-3",onClick:this.handleFormatRuleCreate,ref:this.addFormatRuleButtonRef,icon:Ls,children:"Add New Rule"}),g=r===t.timeZone,f=a===t.showTSeparator&&l===t.showTimeZone&&s===t.defaultDateTimeFormat,b=ot.isSameDecimalOptions(i,t.defaultDecimalFormatOptions),C=ot.isSameIntegerOptions(o,t.defaultIntegerFormatOptions);return v("div",{className:"app-settings-formatting-section",ref:this.containerRef,children:[v("div",{className:"container-fluid p-0",children:[h("div",{children:"Default formatting for column types"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns of a set type."}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-reset-timezone",children:"Time zone"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:r,onChange:this.handleTimeZoneChange,id:"select-reset-timezone",children:ot.renderTimeZoneOptions()})}),h("div",{className:"col-1 btn-col",children:h(Q,{kind:"ghost",icon:Fi,onClick:this.handleResetTimeZone,tooltip:"Reset Time Zone",className:z("btn-reset","btn-reset-time-zone",{hidden:g})})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"select-default-time-format",children:"DateTime"}),h("div",{className:"col pr-0",children:h("select",{className:"custom-select",value:s,onChange:this.handleDefaultDateTimeFormatChange,id:"select-default-time-format",children:this.getCachedDateTimeFormatOptions(r,l,a,!0,s)})}),h("div",{className:"col-1 btn-col",children:h(Q,{kind:"ghost",icon:Fi,onClick:this.handleResetDateTimeFormat,tooltip:"Reset DateTime Options",className:z("btn-reset","btn-reset-date-time",{hidden:f})})})]}),h("div",{className:"form-row",children:h("div",{className:"offset-3 col-9",children:h(Pt,{checked:l!=null?l:null,onChange:this.handleShowTimeZoneChange,children:"Show time zone in dates"})})}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(Pt,{checked:a!=null?a:null,onChange:this.handleShowTSeparatorChange,children:"Show 'T' separator"})})}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-decimal-format-input",children:"Decimal"}),h("div",{className:"col pr-0",children:h("input",{className:z("form-control","flex-grow-1","default-decimal-format-input",{"is-invalid":!ot.isValidFormat(P.dataType.DECIMAL,Ue.makeCustomFormat(c))}),"data-lpignore":!0,placeholder:Ue.DEFAULT_FORMAT_STRING,type:"text",id:"default-decimal-format-input",value:c,onChange:this.handleDefaultDecimalFormatChange})}),h("div",{className:"col-1 btn-col",children:h(Q,{kind:"ghost",icon:Fi,onClick:this.handleResetDecimalFormat,tooltip:"Reset Decimal Formatting",className:z("btn-reset","btn-reset-decimal",{hidden:b}),"data-testid":"btn-reset-decimal"})})]}),v("div",{className:"form-row mb-2",children:[h("label",{className:"col-form-label col-3",htmlFor:"default-integer-format-input",children:"Integer"}),h("div",{className:"col pr-0",children:h("input",{className:z("form-control","flex-grow-1","default-integer-format-input",{"is-invalid":!ot.isValidFormat(P.dataType.INT,dt.makeCustomFormat(u))}),"data-lpignore":!0,placeholder:dt.DEFAULT_FORMAT_STRING,type:"text",id:"default-integer-format-input",value:u,onChange:this.handleDefaultIntegerFormatChange})}),h("div",{className:"col-1 btn-col",children:h(Q,{kind:"ghost",icon:Fi,onClick:this.handleResetIntegerFormat,tooltip:"Reset Integer Formatting",className:z("btn-reset","btn-reset-integer",{hidden:C}),"data-testid":"btn-reset-integer"})})]}),h("div",{className:"form-row mb-3",children:h("div",{className:"offset-3 col-9",children:h(Pt,{checked:d!=null?d:null,onChange:this.handleTruncateNumbersWithPoundChange,children:"Truncate numbers with #"})})})]}),h("div",{children:"Default formatting for matched column names"}),h("div",{className:"app-settings-menu-description mb-3",children:"Applies a formatting rule to all columns that match a specified name and type."}),h(eg,{appear:e,enter:e,exit:e,children:m}),p]})}};let ec=ot;ec.defaultProps={scrollTo:()=>{},defaults:{defaultDateTimeFormat:lt.DEFAULT_DATETIME_FORMAT_STRING,defaultDecimalFormatOptions:{defaultFormatString:Ue.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:dt.DEFAULT_FORMAT_STRING},showTimeZone:!1,showTSeparator:!0,timeZone:lt.DEFAULT_TIME_ZONE_ID}};ec.inputDebounceTime=250;const d1=t=>({formatter:aS(t),defaultDateTimeFormat:oS(t),defaultDecimalFormatOptions:rS(t),defaultIntegerFormatOptions:lS(t),showTimeZone:dS(t),showTSeparator:cS(t),truncateNumbersWithPound:hS(t),timeZone:vl(t),settings:Kt(t)}),c1=Mt(d1,{saveSettings:um})(ec),h1=()=>{const[t,e]=S.exports.useState(!1),n=()=>{e(!t)};return v(Q,{kind:"ghost",onClick:n,icon:pf,children:["Legal Notices",v(Oo,{isOpen:t,toggle:n,className:"theme-bg-light",children:[h(Po,{toggle:n,children:"Legal Notice"}),v(Ao,{children:[h("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."}),v("p",{children:["\xA9 2016-",new Date().getFullYear()," Deephaven Data Labs LLC. Patent Pending."]})]})]})]})},nl=t=>{const{children:e,isExpanded:n,sectionKey:s,title:i,onToggle:o}=t;return v(he,{children:[h("div",{children:v(Q,{kind:"ghost",className:"btn-collapse-trigger",onClick:()=>o(s),children:[h("div",{className:"flex-grow-1",children:i}),h("div",{className:"flex-shrink-0",children:h(q,{transform:n?"flip-v":"",icon:as})})]})}),h(cd,{in:n,autoFocusOnShow:!0,children:e})]})};nl.propTypes={children:R.exports.node,isExpanded:R.exports.bool.isRequired,sectionKey:R.exports.string.isRequired,title:R.exports.node.isRequired,onToggle:R.exports.func};nl.defaultProps={children:null,onToggle:()=>{}};function u1({shortcut:t,displayText:e,categoryName:n,onChange:s}){const[i,o]=S.exports.useState(e),[r,l]=S.exports.useState(t.getKeyState()),[a,d]=S.exports.useState(!1),[c,u]=S.exports.useState("");S.exports.useEffect(function(){o(e),l(t.getKeyState())},[e,t]),S.exports.useEffect(function(){o(zt.getDisplayText(r)),t.matchesKeyState(r)&&d(!1)},[r,t]),S.exports.useEffect(function(){if(a){if(!zt.isValidKeyState(r)){zt.isAllowedKey(r.keyValue)?u("Must contain a modifier key"):u("Must contain an allowed action key");return}const E=Be.getConflictingShortcuts(r).filter(y=>y.id.startsWith(n)&&y!==t).map(y=>y.name);if(E.length){u(`Conflicts with ${E.join(", ")}`);return}u("")}else u("")},[a,r,n,t]);function m(T){if(T.stopPropagation(),T.preventDefault(),t.isEditable&&!T.repeat){const E=zt.getKeyStateFromEvent(T),y=zt.createKeyState([pe.BACKSPACE]);zt.doKeyStatesMatch(E,y)?l(zt.NULL_KEY_STATE):l(E)}}function p(T){T.stopPropagation(),T.preventDefault(),t.matchesKeyState(r)||d(!0)}function g(){Ne.disableAllActions()}function f(){Ne.enableAllActions()}function b(){t.setKeyState(r),d(!1),s(t)}function C(){const T=t.getKeyState();l(T),d(!1)}function w(){d(!0),l(t.getDefaultKeyState())}return v(he,{children:[v("div",{className:"shortcut-item-container",children:[v("label",{className:"shortcut-item-name",children:[t.name,t.tooltip!==void 0&&h(Ie,{children:t.tooltip})]}),v("div",{className:"shortcut-item-input-container",children:[h("input",{className:z("form-control",{"is-invalid":c}),onKeyDown:m,onKeyUp:p,onFocus:g,onBlur:f,disabled:!t.isEditable,value:i,readOnly:!0}),!zt.doKeyStatesMatch(r,t.getDefaultKeyState())&&!c&&h(Q,{className:"reset-to-default-button",kind:"ghost",icon:h(q,{icon:Fi,transform:{rotate:90,flipX:!0}}),tooltip:"Reset to default",onClick:w})]})]}),a&&v("div",{className:z("shortcut-item-message-container",{"is-invalid":c}),children:[h("div",{className:"shortcut-item-message",children:c}),v("div",{className:"shortcut-item-message-buttons",children:[zt.isValidKeyState(r)&&h(Q,{kind:"ghost",onClick:b,children:"Confirm"}),h(Q,{kind:"ghost",onClick:C,children:"Undo"})]})]})]})}function m1({shortcutOverrides:t={},settings:e,saveSettings:n}){const s=S.exports.useCallback(l=>{const a=zt.isMacPlatform,d={mac:{...t.mac},windows:{...t.windows}},c=a?d.mac:d.windows;l.forEach(u=>{u.isDefault()?delete c[u.id]:c[u.id]=u.getKeyState()}),n({...e,shortcutOverrides:d})},[e,n,t]);let i=Array.from(Be.shortcutsByCategory.entries()).map(([l,a])=>({name:l,shortcuts:a}));const o=i.findIndex(l=>l.name.toUpperCase()==="GLOBAL"),r=i.splice(o,1);return i=i.concat(r),v(he,{children:[h("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(l=>h(p1,{name:l.name,shortcuts:l.shortcuts,saveShortcutOverrides:s},l.name))]})}function p1({name:t,shortcuts:e,saveShortcutOverrides:n}){function s(a){return a.split("_").map(d=>`${d[0].toUpperCase()}${d.slice(1).toLowerCase()}`).join(" ")}const[i,o]=S.exports.useState(e);function r(a){const d=i.filter(u=>u!==a&&!u.isNull()&&u.matchesKeyState(a.getKeyState()));d.forEach(u=>u.setToNull());const c=[a,...d];n(c),o(u=>[...u])}const l=S.exports.useMemo(()=>i.map(a=>a.getDisplayText()),[i]);return v("div",{className:"mt-3",children:[h("div",{className:"font-weight-bold",children:s(t)}),i.map((a,d)=>h(u1,{shortcut:a,displayText:l[d],categoryName:t,onChange:r},a.id))]})}const g1=t=>({settings:Kt(t),shortcutOverrides:uS(t)}),f1={saveSettings:um},C1=Mt(g1,f1)(m1),Wa=new zg,Ga=new Vr(Wa);function b1(){X.setLogLevel(parseInt("2",10)),Wa.enable(),Ga.enable(),window!=null&&(window.DHLog=X,window.DHLogProxy=Wa,window.DHLogHistory=Ga)}const S1="yyyy-MM-dd-HHmmss";function xp(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 l=o;if(typeof o=="bigint")s[i]=o.toString();else if(n.has(l))s[i]=`Circular ref to ${n.get(l)}`;else{const a=`${e}.${i}`;n.set(l,a),s[i]=xp(o,a,n)}}}),s}function w1(){const t=yl.getState();return JSON.stringify(xp(t),null,2)}function v1(){const t={uiVersion:"0.20.0",userAgent:navigator.userAgent};return JSON.stringify(t,null,2)}async function T1(t=`${M.i18n.DateTimeFormat.format(S1,new Date)}_support_logs`){const e=new Yh,n=e.folder(t);n.file("console.txt",Ga.getFormattedHistory()),n.file("redux.json",w1()),n.file("metadata.json",v1());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(){T1()}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.20.0",e="https://github.com/deephaven/web-client-ui/",n="https://deephaven.io/core/docs/";return v("div",{className:"app-settings-menu",children:[v("header",{className:"app-settings-menu-header",children:[h("div",{className:"flex-spacer"}),h(Q,{kind:"ghost",className:"btn-close-settings-menu",onClick:this.handleClose,icon:h(q,{icon:Ho,transform:"grow-4"}),tooltip:"Close"})]}),v("div",{className:"app-settings-menu-content",ref:this.menuContentRef,children:[h("h5",{children:"Settings"}),h("hr",{className:"my-0"}),h(nl,{sectionKey:Fs.FORMATTING_SECTION_KEY,isExpanded:this.isSectionExpanded(Fs.FORMATTING_SECTION_KEY),title:v(he,{children:[h(q,{icon:Df,transform:"grow-4",className:"mr-2"}),"Formatting & Time zone"]}),onToggle:this.handleSectionToggle,children:h(c1,{scrollTo:this.handleScrollTo})}),h(nl,{sectionKey:Fs.SHORTCUT_SECTION_KEY,isExpanded:this.isSectionExpanded(Fs.SHORTCUT_SECTION_KEY),title:v(he,{children:[h(q,{icon:vf,transform:"grow-2"})," ","Keyboard Shortcuts"]}),onToggle:this.handleSectionToggle,children:h(C1,{})}),v("div",{className:"app-settings-footer",children:[v("div",{className:"app-settings-footer-section",children:[v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Support"}),v("div",{children:["GitHub:\xA0",h("a",{href:e,className:"custom-link",target:"_blank",rel:"noopener noreferrer",children:e})]}),h(Q,{kind:"tertiary",className:"mt-2 py-2",onClick:Fs.handleExportSupportLogs,children:"Export Logs"})]}),v("div",{className:"app-settings-footer-item",children:[h("div",{className:"font-weight-bold",children:"Documentation"}),h("a",{target:"_blank",rel:"noreferrer noopener",href:n,className:"custom-link",children:n})]}),h("div",{className:"app-settings-footer-item",children:v("div",{className:"text-muted",children:["Version ",t]})}),h("div",{className:"app-settings-footer-item",children:h(h1,{})})]}),h("div",{className:"app-settings-footer-section",children:h("div",{className:"logo",children:h("a",{target:"_blank",rel:"noreferrer noopener",href:"https://deephaven.io",className:"d-inline-block custom-link p-1",children:h("img",{src:Fp,alt:"Deephaven Data Labs",width:"230px"})})})})]})]})]})}};let qo=Fs;qo.defaultProps={onDone:()=>{}};qo.FORMATTING_SECTION_KEY="SettingsMenu.formatting";qo.APPLICATION_SECTION_KEY="ApplicationMenu.settings";qo.SHORTCUT_SECTION_KEY="SettingsMenu.shortcuts";const Uh=10,ki=t=>{const{forwardedProps:{menuItem:{action:e,title:n,disabled:s},iconElement:i,displayShortcut:o,isMouseSelected:r,isKeyboardSelected:l,closeMenu:a}}=t,d=S.exports.useRef(),c=S.exports.useRef(),u=S.exports.useRef(null),[m,p]=S.exports.useState(!1),g=S.exports.useCallback(C=>{d.current!=null&&c.current!=null&&u.current&&(Math.abs(d.current-C.clientX)>=Uh||Math.abs(c.current-C.clientY)>=Uh)&&(p(!0),window.removeEventListener("mousemove",g),a(),e(C),u.current=null)},[e,a]);function f(C){d.current=C.clientX,c.current=C.clientY,u.current=C.target,window.addEventListener("mousemove",g)}function b(C){u.current===C.target&&(p(!0),a(),e(),window.removeEventListener("mousemove",g)),u.current=null}return S.exports.useEffect(function(){return function(){return window.removeEventListener("mousemove",g)}},[g]),v("button",{type:"button",className:z("btn-context-menu",{disabled:s},{active:r&&!s},{"keyboard-active":l&&!s}),onMouseDown:f,onMouseUp:b,disabled:m,children:[h("span",{className:z("icon"),children:i}),h("span",{className:"title",children:n}),h("span",{className:"shortcut",children:o})]})},tc=t=>{const{handleControlSelect:e,handleToolSelect:n,onClearFilter:s}=t,i=S.exports.useMemo(()=>[{title:"Input Filter",icon:Uf,menuElement:h(ki,{}),action:o=>{e(Cn.INPUT_FILTER,o)},order:10},{title:"Dropdown Filter",icon:au,menuElement:h(ki,{}),action:o=>{e(Cn.DROPDOWN_FILTER,o)},order:15},{title:"Markdown Widget",icon:bf,menuElement:h(ki,{}),action:o=>{e(Cn.MARKDOWN,o)},order:20},{title:"Filter Sets",icon:wa,menuElement:h(ki,{}),action:o=>{e(Cn.FILTER_SET_MANAGER,o)},order:25},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Tools"}),order:30},{title:"Linker",icon:td,action:()=>{n(cn.LINKER)},order:40,shortcut:ks.LINKER},{disabled:!0,menuElement:h("div",{className:"context-menu-group-header",children:"Actions"}),order:50},{title:"Clear All Filters",icon:Af,action:()=>{s()},order:60,shortcut:an.TABLE.CLEAR_ALL_FILTERS}],[e,n,s]);return h(zn,{popperClassName:"controls-menu-popper",actions:i})};tc.propTypes={handleControlSelect:R.exports.func,handleToolSelect:R.exports.func,onClearFilter:R.exports.func};tc.defaultProps={handleControlSelect:()=>{},handleToolSelect:()=>{},onClearFilter:()=>{}};ki.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})};ki.defaultProps={forwardedProps:null};const E1=fi(Np,null),y1={layoutStorage:E1},I1=t=>t.layoutStorage;Object.entries(y1).map(([t,e])=>Xi.register(t,e));const Bh=10,R1=t=>{const{onExportLayout:e,onImportLayout:n,onResetLayout:s,onSelect:i,widgets:o=[]}=t,[r,l]=S.exports.useState(!1),[a,d]=S.exports.useState(""),c=S.exports.useRef(null),u=S.exports.useRef(),m=S.exports.useCallback((E,y)=>{E!=null&&i(E,y)},[i]),p=S.exports.useCallback(E=>{d(E.target.value)},[]),g=S.exports.useCallback(E=>{u.current!=null&&(Math.abs(u.current.x-E.clientX)>=Bh||Math.abs(u.current.y-E.clientY)>=Bh)&&(l(!0),window.removeEventListener("mousemove",g),m(u.current.widget,E),u.current=void 0)},[u,m]),f=S.exports.useCallback((E,y)=>{u.current={x:E.clientX,y:E.clientY,widget:y},window.addEventListener("mousemove",g)},[g]),b=S.exports.useCallback((E,y)=>{var I;window.removeEventListener("mousemove",g),((I=u.current)==null?void 0:I.widget)===y&&(l(!0),m(y)),u.current=void 0},[g,u,m]),C=S.exports.useMemo(()=>o.filter(E=>{var y;return a?(y=E.name)==null?void 0:y.toLowerCase().includes(a.toLowerCase()):!0}),[a,o]).sort((E,y)=>{var I,D,N;return(N=(D=E.name)==null?void 0:D.localeCompare((I=y.name)!=null?I:""))!=null?N:0}),w=S.exports.useMemo(()=>C.map(E=>{var y,I;return h("li",{children:v(Q,{kind:"ghost","data-testid":`panel-list-item-${(y=E.name)!=null?y:""}-button`,onMouseDown:D=>{f(D,E)},onMouseUp:D=>{b(D,E)},onKeyDown:D=>{(D.key==="Enter"||D.key===" ")&&m(E)},disabled:r,onClick:()=>{},children:[h(_u,{type:E.type})," ",(I=E.name)!=null?I:""]})},E.name)}),[C,r,f,b,m]),T=S.exports.useMemo(()=>w.length===0?h("span",{children:"No bound variables found."}):null,[w]);return v("div",{className:"widget-list-container d-flex flex-column",children:[h("div",{className:"widget-list-header",children:h(gs,{value:a,placeholder:"Find Table, Plot or Widget",onChange:p,ref:c})}),v("ul",{className:"widget-list flex-grow-1",children:[T&&h("li",{className:"widget-list-message",children:T}),!T&&w]}),h("div",{children:h("hr",{})}),v("div",{className:"widget-list-footer",children:[v(Q,{kind:"ghost",onClick:e,children:[v("div",{className:"fa-md fa-layers",children:[h(q,{mask:va,icon:Cc,transform:"right-5 down-5"}),h(q,{icon:Cc,transform:"right-8 down-6"})]}),"Export Layout"]}),v(Q,{kind:"ghost",onClick:n,children:[v("div",{className:"fa-md fa-layers",children:[h(q,{mask:va,icon:Sa,transform:"right-5 down-5"}),h(q,{icon:Sa,transform:"right-8 down-6"})]}),"Import Layout"]}),h(Q,{kind:"ghost",icon:Fi,onClick:s,tooltip:"Reset Layout"})]})]})},D1=async(t,e,n)=>{let s,i,o,r;if(kr(e)?(s=e.settings,i=e.table,o=void 0,r=e.tableSettings):(s={},i="",o=e.figure,r={}),n!==void 0&&(n.tableSettings!=null&&(r=n.tableSettings),n.table!=null&&(i=n.table),n.figure!=null&&(o=n.figure),n.settings!=null&&(s={...s,...n.settings})),o!==void 0){const d={title:o,name:o,type:M.VariableType.FIGURE},c=await t.getObject(d);return Bi.makeModel(s,c)}const l={title:o,name:i,type:M.VariableType.TABLE},a=await t.getObject(l);return se.applyTableSettings(a,r,vl(yl.getState())),Bi.makeModelFromSettings(s,a)},M1=async(t,e,n=M.VariableType.TABLE)=>{const{table:s}=e,i={title:s,name:s,type:n},o=await t.getObject(i);return Vd.makeModel(o)};const N1=({onAutoFillClick:t=()=>{}})=>v("div",{className:"empty-dashboard-container",children:[v("div",{className:"hint-container",children:[h(q,{icon:Jg})," ",h("br",{}),"Use the panel list to add objects from a query."]}),v("div",{className:"empty-dashboard",children:[h("div",{className:"add-panels-hint",children:"Drag Panels Here"}),h(Q,{kind:"tertiary",onClick:t,children:"Auto fill objects"})]})]});function F1(t){return t.version===2}function x1(t){return Array.isArray(t)}const Dr=X.module("UserLayoutUtils"),_1={layoutConfig:[{type:"column",content:[{type:"row",content:[{type:"stack",content:[{type:"react-component",component:_i.COMPONENT,title:_i.TITLE,isClosable:!1},{type:"react-component",component:tl.COMPONENT,title:tl.TITLE,isClosable:!1}]},{type:"stack",width:25,content:[{type:"react-component",component:Zr.COMPONENT,title:Zr.TITLE,isClosable:!1},{type:"react-component",component:Jr.COMPONENT,title:Jr.TITLE,isClosable:!1}]}]},{type:"row",content:[{type:"stack",title:"Notebooks",content:[]}]}]}],links:[],filterSets:[],version:2},k1={layoutConfig:[],links:[],filterSets:[],version:2};function _p(t){if(F1(t))return t;if(x1(t))return{layoutConfig:t,links:[],filterSets:[],version:2};throw new Error(`Unexpected layout import format: ${t}`)}async function L1(t,e=!0){try{const n=await t.getLayouts();if(n.length>0)try{const s=await t.getLayout(n[0]);return _p(s)}catch(s){Dr.error("Unable to load layout",n[0],":",s),Dr.warn("No valid layouts found, falling back to default layout")}}catch(n){Dr.error("Unable to fetch layout list",n),Dr.warn("Falling back to default layout")}return e?_1:k1}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:L1,normalizeLayout:_p},Mr=X.module("DownloadServiceWorkerUtils"),kp=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(kp.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 sl=kp;sl.DOWNLOAD_PATH="/download/";const Lp={react:Y},A1=tg(Lp),P1=ng({requires:A1}),H1=sg.createRequires(Lp),V1=ig({requires:H1}),U1=X.module("PluginUtils");class Ka{static loadComponentPlugin(e){if("".split(",").includes(e)){const o=Y.lazy(()=>cg(()=>import(`./internal/${e}`),[])),r=Y.forwardRef((l,a)=>h(S.exports.Suspense,{fallback:h("div",{children:"Loading Plugin..."}),children:h(o,{ref:a,...l})}));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)=>h(P1,{url:s,render:({err:l,Component:a})=>{if(l!=null&&l!==""){const d=`Error loading plugin ${e} from ${s} due to ${l}`;return U1.error(d),h("div",{className:"error-message",children:`${d}`})}return h(a,{ref:r,...o})}}));return i.pluginName=e,i.displayName="Plugin",i}static async loadModulePlugin(e){return await V1(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 _t=X.module("AppMainContainer");class No extends S.exports.Component{constructor(e){super(e),this.getDashboardPlugins=ge(n=>[...n.entries()].filter(([,{DashboardPlugin:s}])=>s).map(([s,{DashboardPlugin:i}])=>h(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(cn.LINKER)},shortcut:ks.LINKER,isGlobal:!0},{action:()=>{this.sendClearFilter()},shortcut:an.TABLE.CLEAR_ALL_FILTERS,isGlobal:!0},{action:()=>{_t.debug("Consume unhandled save shortcut")},shortcut:ks.SAVE,isGlobal:!0}],isPanelsMenuShown:!1,isSettingsMenuShown:!1,widgets:[]}}static handleWindowBeforeUnload(e){e.preventDefault(),e.returnValue=""}static hydrateConsole(e,n){return _a.hydrate({...e,unzip:s=>Yh.loadAsync(s).then(i=>Object.values(i.files))},n)}componentDidMount(){this.initWidgets(),window.addEventListener("beforeunload",No.handleWindowBeforeUnload)}componentDidUpdate(e){const{dashboardData:n}=this.props;e.dashboardData!==n&&this.handleDataChange(n)}componentWillUnmount(){this.deinitWidgets(),window.removeEventListener("beforeunload",No.handleWindowBeforeUnload)}initWidgets(){const{connection:e}=this.props;if(e.subscribeToFieldUpdates==null){_t.warn("subscribeToFieldUpdates not supported, not initializing widgets");return}this.widgetListenerRemover=e.subscribeToFieldUpdates(n=>{_t.debug("Got updates",n),this.setState(({widgets:s})=>{const{updated:i,created:o,removed:r}=n,l=[...i,...r],a=s.filter(c=>!l.some(u=>u.name===c.name));return[...i,...o].forEach(c=>{c.name!=null&&c.name!==""&&a.push(c)}),{widgets:a}})})}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==null||i==null){_t.error("No session available to open notebook URL",n);return}const o={id:`/${n}`,itemName:`/${n}`},r=i.type,l={value:null,language:r};this.emitLayoutEvent(He.SELECT_NOTEBOOK,s,r,l,o,!0)}}sendClearFilter(){this.emitLayoutEvent(Pe.CLEAR_ALL_FILTERS)}emitLayoutEvent(e,...n){var s;(s=this.goldenLayout)==null||s.eventHub.emit(e,...n)}handleError(e){Ee.isCanceled(e)||_t.error(e)}handleSettingsMenuHide(){this.setState({isSettingsMenuShown:!1})}handleSettingsMenuShow(){this.setState({isSettingsMenuShown:!0})}handleControlSelect(e,n=null){switch(_t.debug("handleControlSelect",e),e){case Cn.DROPDOWN_FILTER:this.emitLayoutEvent(Pe.OPEN_DROPDOWN,{title:"DropdownFilter",type:e,createNewStack:!0,dragEvent:n});break;case Cn.INPUT_FILTER:this.emitLayoutEvent(Pe.OPEN_INPUT,{title:"InputFilter",type:e,createNewStack:!0,dragEvent:n});break;case Cn.MARKDOWN:this.emitLayoutEvent(dp.OPEN,{title:"Markdown",type:e,dragEvent:n});break;case Cn.FILTER_SET_MANAGER:this.emitLayoutEvent(Pe.OPEN_FILTER_SET_MANAGER,{title:"FilterSets",type:e,dragEvent:n});break;default:throw new Error(`Unrecognized control type ${e}`)}}handleToolSelect(e){_t.debug("handleToolSelect",e);const{activeTool:n,setActiveTool:s}=this.props;s(n===e?cn.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}),_t.debug("handleWidgetSelect",e,n),this.openWidget(e,n)}handleWidgetsMenuClose(){this.setState({isPanelsMenuShown:!1})}handleAutoFillClick(){const{widgets:e}=this.state;_t.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(){_t.info("handleExportLayoutClick"),this.setState({isPanelsMenuShown:!1});try{const{workspace:e}=this.props,{data:n}=e,s=Pr.exportLayout(n);_t.info("handleExportLayoutClick exportedConfig",s);const i=new Blob([JSON.stringify(s)],{type:"application/json"}),o=M.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){_t.error("Unable to export layout",e)}}handleImportLayoutClick(){_t.info("handleImportLayoutClick"),this.setState({isPanelsMenuShown:!1}),this.importElement.current!=null&&(this.importElement.current.value="",this.importElement.current.click())}handleResetLayoutClick(){_t.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:l,links:a}=Pr.normalizeLayout(o);s({layoutConfig:l}),n(Rn,{filterSets:r,links:a})}catch(n){_t.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:l}=this.props;l({layoutConfig:i}),r(Rn,{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!=null?s.TablePlugin:Ka.loadComponentPlugin(e)}hydrateDefault(e,n){const{connection:s}=this.props,{metadata:i}=e;if((i==null?void 0:i.type)!=null&&((i==null?void 0:i.id)!=null||(i==null?void 0:i.name)!=null)){const o=i.id!=null?{type:i.type,id:i.id}:{type:i.type,name:i.name,title:i.name};return{fetch:()=>s.getObject(o),localDashboardId:n,...e}}return _a.hydrate(e,n)}hydrateGrid(e,n){return this.hydrateTable(e,n,M.VariableType.TABLE)}hydratePandas(e,n){return this.hydrateTable(e,n,M.VariableType.PANDAS)}hydrateTable(e,n,s=M.VariableType.TABLE){const{connection:i}=this.props;return{...e,getDownloadWorker:sl.getServiceWorker,loadPlugin:this.handleLoadTablePlugin,localDashboardId:n,makeModel:()=>M1(i,e.metadata,s)}}hydrateChart(e,n){const{connection:s}=this.props;return{...e,localDashboardId:n,makeModel:()=>{const{metadata:i,panelState:o}=e;return D1(s,i,o)}}}openWidget(e,n){const{connection:s}=this.props;this.emitLayoutEvent(Me.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:l}=s,{canUsePanels:a}=l,{contextActions:d,isPanelsMenuShown:c,isSettingsMenuShown:u,widgets:m}=this.state,p=this.getDashboardPlugins(n);return v("div",{className:z("app-main-tabs","w-100","h-100","d-flex","flex-column",e?`active-tool-${e.toLowerCase()}`:""),onPaste:this.handlePaste,tabIndex:-1,children:[h("nav",{className:"nav-container",children:v("div",{className:"app-main-top-nav-menus",children:[h("img",{src:Fp,alt:"Deephaven Data Labs",width:"115px",className:"ml-1"}),v("div",{children:[v(Q,{kind:"ghost",className:"btn-panels-menu",icon:Kf,onClick:()=>{},children:["Controls",h(tc,{handleControlSelect:this.handleControlSelect,handleToolSelect:this.handleToolSelect,onClearFilter:this.handleClearFilter})]}),a&&v(Q,{kind:"ghost",className:"btn-panels-menu btn-show-panels","data-testid":"app-main-panels-button",onClick:this.handleWidgetMenuClick,icon:$f,children:["Panels",h(Fn,{isShown:c,className:"panels-menu-popper",onExited:this.handleWidgetsMenuClose,closeOnBlur:!0,interactive:!0,children:h(R1,{widgets:m,onExportLayout:this.handleExportLayoutClick,onImportLayout:this.handleImportLayoutClick,onResetLayout:this.handleResetLayoutClick,onSelect:this.handleWidgetSelect})})]}),h(Q,{kind:"ghost",className:z("btn-settings-menu",{"text-warning":s.operateAs!==s.name}),onClick:this.handleSettingsMenuShow,icon:h(q,{icon:Vo,transform:"grow-3 right-1 down-1"}),tooltip:"User Settings"})]})]})}),v(aw,{emptyDashboard:h(N1,{onAutoFillClick:this.handleAutoFillClick}),id:Rn,layoutConfig:r,onGoldenLayoutChange:this.handleGoldenLayoutChange,onLayoutConfigChange:this.handleLayoutConfigChange,onLayoutInitialized:this.openNotebookFromURL,hydrate:this.hydrateDefault,children:[h(BE,{hydrate:this.hydrateGrid,getDownloadWorker:sl.getServiceWorker,loadPlugin:this.handleLoadTablePlugin}),h(OE,{hydrate:this.hydrateChart}),h(AE,{}),h(HE,{hydrateConsole:No.hydrateConsole,notebooksUrl:new URL("/notebooks/",`${window.location}`).href}),h(VE,{}),h(YE,{hydrate:this.hydratePandas}),h(qE,{}),h(KE,{}),p]}),h(ht,{in:u,timeout:Tt.transitionMidMs,classNames:"slide-left",mountOnEnter:!0,unmountOnExit:!0,children:h(qo,{onDone:this.handleSettingsMenuHide})}),h(ie,{actions:d}),h("input",{ref:this.importElement,type:"file",accept:".json",style:{display:"none"},onChange:this.handleImportLayoutFiles})]})}}const B1=t=>{var e,n;return{activeTool:Tl(t),dashboardData:qt(t,Rn),layoutStorage:I1(t),plugins:mS(t),connection:YT(t,Rn),session:(e=gi(t,Rn))==null?void 0:e.session,sessionConfig:(n=gi(t,Rn))==null?void 0:n.config,user:em(t),workspace:wl(t)}},$1=Mt(B1,{setActiveTool:El,updateDashboardData:qn,updateWorkspaceData:hm})(og(No)),z1=()=>v("div",{className:"app",children:[h($1,{}),h(pu,{})]}),W1=X.module("LocalWorkspaceStorage"),Eo=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:lt.DEFAULT_DATETIME_FORMAT_STRING,formatter:[],timeZone:lt.DEFAULT_TIME_ZONE_ID,showTimeZone:!1,showTSeparator:!0,disableMoveConfirmation:!1,defaultDecimalFormatOptions:{defaultFormatString:Ue.DEFAULT_FORMAT_STRING},defaultIntegerFormatOptions:{defaultFormatString:dt.DEFAULT_FORMAT_STRING},truncateNumbersWithPound:!1},layoutConfig:i,closed:[{}],links:s,filterSets:n}}static async makeDefaultWorkspace(t,e){return{data:await Eo.makeDefaultWorkspaceData(t,e)}}constructor(t){this.layoutStorage=t}async load(t){var e;try{return JSON.parse((e=localStorage.getItem(Eo.STORAGE_KEY))!=null?e:"")}catch{return W1.info("Unable to load workspace data, initializing to default data"),Eo.makeDefaultWorkspace(this.layoutStorage,t)}}async save(t){return localStorage.setItem(Eo.STORAGE_KEY,JSON.stringify(t)),t}};let Op=Eo;Op.STORAGE_KEY="deephaven.WorkspaceStorage";class G1 extends Error{constructor(){super(...arguments),this.isNoConsolesError=!0}}function K1(t){return t.isNoConsolesError}const Li=X.module("SessionUtils");function q1(){return new URL("/jsapi",`${window.location}`)}function Ap(){const t=q1();return`${t.protocol}//${t.host}`}function Y1(){const t=Ap();return Li.info(`Starting connection to '${t}'...`),new M.IdeConnection(t)}async function X1(t){Li.info("Getting console types...");const e=await t.getConsoleTypes();if(Li.info("Available types:",e),e.length===0)throw new G1("No console types available");const n=e[0];Li.info("Starting session with type",n);const s=await t.startSession(n),i={type:n,id:We.generate()};return Li.info("Console session established",i),{session:s,config:i,connection:t}}function j1(){const t=Ap();return Li.info("createCoreClient",t),new M.CoreClient(t)}class Q1{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 Co=X.module("GrpcFileStorageTable"),qa=class{constructor(t,e="",n=e){this.currentSize=0,this.listeners=[],this.childTables=new Map,this.storageService=t,this.baseRoot=e,this.root=n,n===e&&(this.doRefresh=Xe(this.doRefresh.bind(this),qa.REFRESH_DEBOUNCE))}removeBaseRoot(t){return de.removeRoot(this.baseRoot,t)}getViewportData(){var t;return this.viewportUpdatePromise||this.refreshInternal(),(t=this.viewportUpdatePromise)!=null?t:Promise.resolve({items:[],offset:0})}getSnapshot(t){throw new Error("Method not implemented.")}get size(){return this.currentSize}setExpanded(t,e){const n=t.split("/");let s=n.shift();if((s===void 0||s==="")&&(s=n.shift()),s===void 0||s==="")throw new Error(`Invalid path: ${t}`);const i=n.join("/");if(e){if(!this.childTables.has(s)){const o=new qa(this.storageService,this.baseRoot,`${this.root}/${s}`);this.childTables.set(s,o)}if(i){const o=this.childTables.get(s);o==null||o.setExpanded(i,e)}}else if(this.childTables.has(s))if(i){const o=this.childTables.get(s);o==null||o.setExpanded(i,e)}else this.childTables.delete(s);this.currentViewport&&this.refreshInternal()}collapseAll(){this.childTables.clear(),this.currentViewport&&this.refreshInternal()}setSearch(t){throw new Error("Method not implemented.")}setViewport(t){this.currentViewport=t,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(t){return this.listeners=[...this.listeners,t],()=>{this.listeners=this.listeners.filter(e=>e!==t)}}doRefresh(t){Co.debug2("doRefresh",this.root),t(this.fetchData())}refresh(){var n;Co.debug2("refresh",this.root),(n=this.viewportUpdatePromise)==null||n.cancel();const t=new Promise(s=>{this.doRefresh(s)}),e=Ee.makeCancelable(t.then(s=>{if(this.viewportUpdatePromise!==e)throw new ai;return this.currentViewportData=s,this.sendUpdate(),s}));e.catch(s=>{Ee.isCanceled(s)||Co.error("Error updating viewport",s)}),this.viewportUpdatePromise=e}refreshInternal(){try{this.refresh()}catch(t){Ee.isCanceled(t)||Co.error("Unable to refresh data",t)}}async fetchData(){const{currentViewport:t}=this;if(!t)throw new Error("No viewport set");let n=(await this.storageService.listItems(this.root)).map(s=>({type:s.type,filename:this.removeBaseRoot(s.filename),basename:s.basename,id:this.removeBaseRoot(s.filename),isExpanded:s.type==="directory"?this.childTables.has(s.basename):void 0})).sort((s,i)=>s.type!==i.type?s.type==="directory"?-1:1:s.basename.localeCompare(i.basename));for(let s=0;s<n.length;s+=1){const i=n[s],{basename:o,filename:r}=i;if(r===this.removeBaseRoot(`${this.root}/${o}`)&&i.type==="directory"){const l=this.childTables.get(o);if(l!=null){l.setViewport({top:0,bottom:t.bottom-s});const a=await l.getViewportData();n.splice(s+1,0,...a.items)}}}return this.currentSize=n.length,Co.debug2(this.root,"items",n,t),n=n.slice(t.top,t.bottom),{items:n,offset:t.top}}sendUpdate(){var n;const{listeners:t}=this,e=(n=this.currentViewportData)!=null?n:{items:[],offset:0};for(let s=0;s<t.length;s+=1)t[s](e)}};let Pp=qa;Pp.REFRESH_DEBOUNCE=50;const Z1=X.module("GrpcFileStorage"),Hp=class{constructor(t,e=""){this.tables=[],this.refreshTables=ui(()=>{this.tables.forEach(n=>n.refresh())},Hp.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 Pp(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 Yd;if(e.length>1)throw Z1.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 Vp=Hp;Vp.REFRESH_THROTTLE=150;const ri=X.module("AppInit");async function J1(){ri.debug("Loading plugins...");try{const t=await Ka.loadJson("/js-plugins/manifest.json");ri.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],l=`/js-plugins/${o}/${r}`;e.push(Ka.loadModulePlugin(l))}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 ri.info("Plugins loaded:",s),s}catch(t){return ri.error("Unable to load plugins:",t),new Map}}async function e2(t){let e;try{e=await X1(t)}catch(n){if(!K1(n))throw n}return e}const nc=t=>{const{workspace:e,setActiveTool:n,setCommandHistoryStorage:s,setDashboardData:i,setFileStorage:o,setLayoutStorage:r,setDashboardConnection:l,setDashboardSessionWrapper:a,setPlugins:d,setUser:c,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{ri.info("Initializing Web UI","0.20.0",navigator.userAgent);const N=await J1(),x=Y1(),U=await e2(x);x.addEventListener(M.IdeConnection.HACK_CONNECTION_FAILURE,J=>{var fe;const{detail:me}=J;ri.error("Connection failure",me),g(`Unable to connect: ${(fe=me.details)!=null?fe:"Unknown Error"}`)});const $="user",L={name:$,operateAs:$,groups:[],permissions:{isSuperUser:!1,isQueryViewOnly:!1,isNonInteractive:!1,canUsePanels:!0,canCreateDashboard:!0,canCreateCodeStudio:!0,canCreateQueryMonitor:!0,canCopy:!0,canDownloadCsv:!0}},H=j1();await H.login({type:M.CoreClient.LOGIN_TYPE_ANONYMOUS});const O=H.getStorageService(),F=new Q1(O,"/layouts"),_=new Vp(O,"/notebooks"),k=new Op(F),V=new r1,W=await k.load({isConsoleAvailable:U!==void 0}),{data:j}=W,{settings:ee}=j;ee.defaultDecimalFormatOptions===void 0&&(ee.defaultDecimalFormatOptions={defaultFormatString:Ue.DEFAULT_FORMAT_STRING}),ee.defaultIntegerFormatOptions===void 0&&(ee.defaultIntegerFormatOptions={defaultFormatString:dt.DEFAULT_FORMAT_STRING}),ee.truncateNumbersWithPound===void 0&&(ee.truncateNumbersWithPound=!1);const{shortcutOverrides:ve={}}=ee,Se=zt.isMacPlatform?(I=ve.mac)!=null?I:{}:(D=ve.windows)!=null?D:{};Object.entries(Se).forEach(([J,me])=>{var fe;(fe=Be.get(J))==null||fe.setKeyState(me)});const Oe={filterSets:j.filterSets,links:j.links};n(cn.DEFAULT),s(V),i(Rn,Oe),o(_),r(F),l(Rn,x),U!==void 0&&a(Rn,U),d(N),c(L),m(k),u(W)}catch(N){ri.error(N),g(N)}},[n,s,i,o,r,l,a,d,c,u,m]),w=S.exports.useCallback(()=>{document.fonts!=null?document.fonts.ready.then(()=>{b(!1)}):b(!1)},[]);S.exports.useEffect(function(){C(),w()},[C,w]);const T=e==null&&p==null||f,E=!T&&p==null,y=p!=null?`${p}`:null;return v(he,{children:[E&&h(z1,{}),h(ml,{isLoading:T,isLoaded:E,errorMessage:y}),v("div",{id:"preload-fonts",style:{visibility:"hidden",position:"absolute",top:-1e4},children:[h("p",{className:"fira-sans-regular",children:"preload"}),h("p",{className:"fira-sans-semibold",children:"preload"}),h("p",{className:"fira-mono",children:"preload"})]})]})};nc.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};nc.defaultProps={workspace:null,workspaceStorage:null};const t2=t=>({workspace:wl(t),workspaceStorage:iS(t)}),$h=Mt(t2,{setActiveTool:El,setCommandHistoryStorage:fS,setDashboardData:Am,setFileStorage:CS,setLayoutStorage:l1,setDashboardConnection:XT,setDashboardSessionWrapper:jT,setPlugins:SS,setUser:pS,setWorkspace:cm,setWorkspaceStorage:gS})(nc),n2=()=>h(rg,{basename:"/ide/",children:v(lg,{children:[h(mc,{exact:!0,path:"/",component:$h}),h(mc,{path:"/notebook/:notebookPath+",component:$h}),h(ag,{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 s2(){"serviceWorker"in navigator&&navigator.serviceWorker.getRegistrations().then(t=>{t.forEach(e=>{e.scope.endsWith("/download/")||e.unregister()})})}b1();hi.render(h(Gh,{store:yl,children:h(n2,{})}),document.getElementById("root"));s2();sl.registerOnLoaded();rt.init();window["__react-beautiful-dnd-disable-dev-warnings"]=!0;
|
|
44
|
-
//# sourceMappingURL=index.
|
|
44
|
+
//# sourceMappingURL=index.013e2a93.js.map
|