@deephaven/code-studio 0.60.0 → 0.60.1-alpha.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/build/assets/AppRoot-78d4d9e3.js +5 -0
  2. package/build/assets/AppRoot-78d4d9e3.js.map +1 -0
  3. package/build/assets/{ControlType-aed38d2a.js → ControlType-6564be64.js} +14 -14
  4. package/build/assets/ControlType-6564be64.js.map +1 -0
  5. package/build/assets/{FontBootstrap-03312de4.js → FontBootstrap-7c2011d9.js} +2 -2
  6. package/build/assets/{FontBootstrap-03312de4.js.map → FontBootstrap-7c2011d9.js.map} +1 -1
  7. package/build/assets/{IrisGrid-95f2b562.js → IrisGrid-9b7bdb62.js} +7 -7
  8. package/build/assets/{IrisGrid-95f2b562.js.map → IrisGrid-9b7bdb62.js.map} +1 -1
  9. package/build/assets/{IrisGridModelFactory-83f4e8e3.js → IrisGridModelFactory-13cf501d.js} +3 -3
  10. package/build/assets/{IrisGridModelFactory-83f4e8e3.js.map → IrisGridModelFactory-13cf501d.js.map} +1 -1
  11. package/build/assets/{StyleGuideRoot-f74fbaec.js → StyleGuideRoot-1e7a89ef.js} +2 -2
  12. package/build/assets/{StyleGuideRoot-f74fbaec.js.map → StyleGuideRoot-1e7a89ef.js.map} +1 -1
  13. package/build/assets/index-110a15f5.js +2 -0
  14. package/build/assets/index-110a15f5.js.map +1 -0
  15. package/build/assets/{index-8f18b8a1.js → index-4799bb94.js} +2 -2
  16. package/build/assets/{index-8f18b8a1.js.map → index-4799bb94.js.map} +1 -1
  17. package/build/assets/{index-aeb6c8aa.js → index-cdb214b1.js} +2 -2
  18. package/build/assets/{index-aeb6c8aa.js.map → index-cdb214b1.js.map} +1 -1
  19. package/build/assets/usePlugins-d26d6337.js +3 -0
  20. package/build/assets/usePlugins-d26d6337.js.map +1 -0
  21. package/build/assets/{useUser-2b2d3085.js → useUser-3f49dc07.js} +2 -2
  22. package/build/assets/{useUser-2b2d3085.js.map → useUser-3f49dc07.js.map} +1 -1
  23. package/build/index.html +1 -1
  24. package/package.json +31 -31
  25. package/build/assets/AppRoot-4e766647.js +0 -5
  26. package/build/assets/AppRoot-4e766647.js.map +0 -1
  27. package/build/assets/ControlType-aed38d2a.js.map +0 -1
  28. package/build/assets/index-e5c706d4.js +0 -2
  29. package/build/assets/index-e5c706d4.js.map +0 -1
  30. package/build/assets/usePlugins-ed18184b.js +0 -3
  31. package/build/assets/usePlugins-ed18184b.js.map +0 -1
@@ -1,21 +1,21 @@
1
- import{C as l,G as re,r as c,au as Nr,N as Me,F as ee,H as se,U as _e,av as Tt,V as _i,L as Dt,M as xr,aw as Pn,ax as Dr,ay as Lr,az as Rr,aA as Ir,R as ki,as as jn,K as It,S as Hi,at as Mr,aB as Fr,ag as Ar}from"./vendor-755ebba4.js";import{x as jr,at as _r,aq as Ui,ar as $i,I as Bi,j as kr,e as D,d as Ct,au as Hr,L as Q,av as _n,aw as Ur,ax as $r,ay as Br,az as Vr,f as Vi,aj as Wi,aA as Ki,aB as Pt,B as On,ap as Wr,aC as Kr,aD as zr,aE as kn,aF as Yt,aG as Hn,aH as zi,aI as Gr,F as Yr,aJ as qr,aK as Zr,aL as Xr,aM as Qr,C as Jr,M as es,b as ts,c as ns,aN as is,aO as rs,al as ss,aP as as,aQ as os,aR as ls}from"./index-8f18b8a1.js";import{u as ds,ap as hs,d as Gi,B as K,g as Ce,ak as q,K as Y,bs as us,a5 as Oe,P as ce,G as qt,M as k,bp as cs,D as Yi,S as vs,C as ms,m as Ot,n as qi,bq as pt,V as ps,h as ot,br as gs,E as fs,ae as fn,an as bs,aP as Cs,ab as Ss,a7 as Es,aN as ys,bt as Ts,bu as Ps,bv as Os,bw as ws,bx as Ns,by as xs,bz as Ds,bA as Ls,bB as Rs,bC as Is,r as wn,L as Ms,aT as ae,H as xe,z as ke,w as lt,bm as Un,be as Fs,aW as As,bD as wt,ad as $n,N as Lt,al as js,ah as _s,e as ks,bE as Hs,p as Us,aU as bt,aV as Le,b1 as $s}from"./usePlugins-ed18184b.js";import{e as Nn,l as Ht,K as Nt,a as Zi}from"./monaco-0fb6bb22.js";function Bs(i){var{type:e}=i,t=ds();switch(e){case t.VariableType.TABLE:case t.VariableType.TABLEMAP:case t.VariableType.TREETABLE:case t.VariableType.HIERARCHICALTABLE:case t.VariableType.PARTITIONEDTABLE:return l.jsx(re,{icon:$i});case t.VariableType.FIGURE:return l.jsx(re,{icon:Ui});case t.VariableType.PANDAS:return l.jsx(re,{icon:_r});default:return l.jsx(re,{icon:jr})}}function Bn(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function Vs(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){Bn(s,n,r,a,o,"next",d)}function o(d){Bn(s,n,r,a,o,"throw",d)}a(void 0)})}}function xn(i){var{children:e,language:t}=i,[n,r]=c.useState(null),{activeThemes:s}=hs();return c.useEffect(()=>{var a=!1;function o(){return d.apply(this,arguments)}function d(){return d=Vs(function*(){if(e!=null&&s!=null){var h=yield Nn.colorize(e.toString(),t,{});a||r(h)}}),d.apply(this,arguments)}return o(),()=>{a=!0}},[s,e,t]),l.jsx("div",{style:{pointerEvents:"none"},dangerouslySetInnerHTML:n!=null?{__html:n}:void 0})}class Ws{static get LANGUAGE_MAP(){return new Map([["python","Python"],["groovy","Groovy"],["scala","Scala"]])}}const Xi=Ws;class Zt{static hasComment(e){return e.comment!==void 0}static hasPattern(e){return e.pattern!==void 0}static hasOp(e){return e.op!==void 0}static parseArguments(e){return e==null||!(typeof e=="string"||e instanceof String)?[]:Nr.parse(e).filter(t=>!this.hasComment(t)).map(t=>this.hasPattern(t)?t.pattern:this.hasOp(t)?t.op:"".concat(t))}static formatTimestamp(e){if(e==null||!(e instanceof Date))return null;var t="".concat(e.getHours()).padStart(2,"0"),n="".concat(e.getMinutes()).padStart(2,"0"),r="".concat(e.getSeconds()).padStart(2,"0"),s="".concat(e.getMilliseconds()).padStart(3,"0");return"".concat(t,":").concat(n,":").concat(r,".").concat(s)}static isTableType(e,t){return t===e.VariableType.TABLE||t===e.VariableType.TREETABLE||t===e.VariableType.HIERARCHICALTABLE||t===e.VariableType.PARTITIONEDTABLE}static isWidgetType(e,t){return t===e.VariableType.FIGURE||t===e.VariableType.OTHERWIDGET||t===e.VariableType.PANDAS}static isOpenableType(e,t){return Zt.isTableType(e,t)||Zt.isWidgetType(e,t)}static isFigureType(e,t){return t===e.VariableType.FIGURE}static isPandas(e,t){return t===e.VariableType.PANDAS}}const bn=Zt;function Qi(i){var{children:e}=i;return l.jsxs("div",{className:"console-history-item-result",children:[l.jsx("div",{className:"console-history-gutter",children:"-"}),l.jsx("div",{className:"console-history-content",children:e})]})}Qi.propTypes={children:Me.node.isRequired};function Cn(i,e,t){return e=Ks(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ks(i){var e=zs(i,"string");return typeof e=="symbol"?e:String(e)}function zs(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Ji extends c.Component{constructor(e){super(e),Cn(this,"timer",void 0),Cn(this,"startTime",void 0),this.updateElapsed=this.updateElapsed.bind(this),this.startTime=Date.now(),this.state={elapsed:0}}componentDidMount(){this.timer=setInterval(this.updateElapsed,1e3)}componentWillUnmount(){this.timer&&clearInterval(this.timer),this.timer=void 0}updateElapsed(){this.setState({elapsed:Math.round((Date.now()-this.startTime)/1e3)})}render(){var{disabled:e,onCancelClick:t}=this.props,{elapsed:n}=this.state;return l.jsx("div",{className:ee("console-history-result-in-progress",{disabled:e}),children:l.jsxs("span",{className:"badge",children:[l.jsx(Bi,{className:"ml-2"}),"Running... ",Gi.formatElapsedTime(n)," ",l.jsx(K,{className:"console-history-result-in-progress-cancel",kind:"ghost",icon:kr,tooltip:"Cancel",onClick:t,disabled:e})]})})}}Cn(Ji,"defaultProps",{disabled:!1});const Gs=Ji;function xt(i,e,t){return e=Ys(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ys(i){var e=qs(i,"string");return typeof e=="symbol"?e:String(e)}function qs(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class ct extends c.PureComponent{constructor(e){super(e),xt(this,"mouseX",void 0),xt(this,"mouseY",void 0),xt(this,"isClicking",void 0),this.handleKeyPress=this.handleKeyPress.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleToggleError=this.handleToggleError.bind(this),this.handleMouseEnter=this.handleMouseEnter.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.mouseX=null,this.mouseY=null,this.isClicking=!1,this.state={isExpanded:!1,isTriggerHovered:!1}}handleKeyPress(e){switch(e.key){case"Enter":case" ":this.handleToggleError(),e.stopPropagation(),e.preventDefault();break}}handleMouseDown(e){this.mouseX=e.clientX,this.mouseY=e.clientY,this.isClicking=!0}handleMouseMove(e){this.mouseX!=null&&this.mouseY!=null?(Math.abs(e.clientX-this.mouseX)>=ct.mouseDragThreshold||Math.abs(e.clientY-this.mouseY)>=ct.mouseDragThreshold)&&(this.isClicking=!1):this.isClicking&&(this.isClicking=!1)}handleMouseUp(e){this.isClicking&&!e.shiftKey&&!e.metaKey&&!e.altKey&&this.handleToggleError(),this.mouseX=null,this.mouseY=null,this.isClicking=!1}handleToggleError(){this.setState(e=>({isExpanded:!e.isExpanded}))}handleMouseEnter(){this.setState({isTriggerHovered:!0})}handleMouseLeave(){this.setState({isTriggerHovered:!1})}render(){var{isExpanded:e,isTriggerHovered:t}=this.state,{message:n}=this.props;D(n);var r=n.indexOf(`
2
- `),s=r>-1,a=n;s&&(a=n.slice(0,r));var o=n.slice(r),d=t?"error-btn-link error-btn-link--active":"error-btn-link";return l.jsxs("div",{className:ee("error-message",{expanded:e}),children:[s&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"error-gutter",children:l.jsx("button",{type:"button",onClick:this.handleToggleError,className:d,tabIndex:-1,children:l.jsx(re,{icon:e?Ct:Hr,transform:"left-3"})})}),l.jsxs("div",{className:"error-content",children:[l.jsx("div",{className:"console-error-text-trigger",role:"button",tabIndex:0,onKeyPress:this.handleKeyPress,onMouseDown:this.handleMouseDown,onMouseMove:this.handleMouseMove,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,onMouseUp:this.handleMouseUp,children:a}),e?o:""]})]}),!s&&l.jsx("div",{className:"error-content",children:l.jsx("div",{className:"console-error-text",children:a})})]},"error")}}xt(ct,"defaultProps",{message:""});xt(ct,"mouseDragThreshold",5);const Zs=ct;function Xs(i,e,t){return e=Qs(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Qs(i){var e=Js(i,"string");return typeof e=="symbol"?e:String(e)}function Js(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Vn=Q.module("ConsoleHistoryItem");class er extends c.PureComponent{constructor(e){super(e),this.handleCancelClick=this.handleCancelClick.bind(this),this.handleObjectClick=this.handleObjectClick.bind(this)}handleObjectClick(e){Vn.debug("handleObjectClick",e);var{openObject:t}=this.props;t(e)}handleCancelClick(){var{item:e}=this.props;e!=null&&e.cancelResult&&(Vn.debug("Cancelling command: ".concat(e.command)),e.cancelResult())}render(){var{disabled:e,item:t,language:n,iconForType:r}=this.props,{disabledObjects:s,result:a}=t,o=t.command!=null&&t.command!=="",d=null;o&&(d=l.jsxs("div",{className:"console-history-item-command",children:[l.jsx("div",{className:"console-history-gutter",children:">"}),l.jsx("div",{className:"console-history-content",children:l.jsx(xn,{language:n,children:t.command})})]}));var h=[],u=!1;if(a){var{error:v,message:m,changes:p}=a;if(p){var{created:E,updated:S}=p;[...E,...S].forEach(Z=>{u=!0;var{title:A}=Z,G="".concat(A),z=e===void 0||e||(s??[]).indexOf(G)>=0,X=l.jsx(K,{kind:"primary",onClick:()=>this.handleObjectClick(Z),className:"btn-console-object",disabled:z,icon:r(Z.type),children:A},G);h.push(X)})}if(v!=null&&!o){var g,y="".concat((g=v.message)!==null&&g!==void 0?g:v);y||(y=v);var P=l.jsx(Zs,{message:y},"result-error");h.push(P)}if(m!==void 0&&m!==""){var O=l.jsx("div",{className:"log-message",children:m},"log-message");h.push(O)}}else{u=!0;var L=l.jsx(Gs,{onCancelClick:this.handleCancelClick,disabled:e},"in_progress");h.push(L)}var V=null;return h.length>0&&(V=l.jsx(Qi,{children:h})),l.jsxs("div",{className:ee("console-command-result",{"console-result-buttons":u}),children:[d,V]})}}Xs(er,"defaultProps",{disabled:!1});const ea=er;function ta(i,e){return"".concat(i,".").concat(e.command,".").concat(e.result&&e.result.message,".").concat(e.result&&e.result.error)}function na(i){for(var{disabled:e=!1,items:t,language:n,openObject:r,supportsType:s,iconForType:a}=i,o=[],d=0;d<t.length;d+=1){var h=t[d],u=l.jsx(ea,{disabled:e,item:h,openObject:r,language:n,supportsType:s,iconForType:a},ta(d,h));o.push(u)}return l.jsx("div",{className:"container-fluid console-history",children:o})}var ia={name:"Console",CLEAR:Ce.createAndAdd({id:"CONSOLE.CLEAR",name:"Clear",shortcut:[q.CTRL,Y.L],macShortcut:[q.CTRL,Y.C]}),FOCUS_HISTORY:Ce.createAndAdd({id:"CONSOLE.FOCUS_HISTORY",name:"Focus History",shortcut:[q.CTRL,Y.H],macShortcut:[q.CTRL,q.OPTION,Y.H]})},ra={name:"Command History",FOCUS_HISTORY:Ce.createAndAdd({id:"COMMAND_HISTORY.FOCUS_HISTORY",name:"Focus History Search",shortcut:[q.CTRL,Y.H],macShortcut:[q.CTRL,q.OPTION,Y.H]}),SEND_TO_CONSOLE:Ce.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_CONSOLE",name:"Send to Console",shortcut:[Y.ENTER],macShortcut:[Y.ENTER]}),SEND_TO_NOTEBOOK:Ce.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_NOTEBOOK",name:"Send to Notebook",shortcut:[q.CTRL,Y.ENTER],macShortcut:[q.CMD,Y.ENTER]}),RUN:Ce.createAndAdd({id:"COMMAND_HISTORY.RUN",name:"Run",shortcut:[q.ALT,Y.R],macShortcut:[q.OPTION,Y.R]})},sa={name:"Notebook",RUN:Ce.createAndAdd({id:"NOTEBOOK.RUN",name:"Run",shortcut:[q.ALT,Y.R],macShortcut:[q.OPTION,Y.R]}),RUN_SELECTED:Ce.createAndAdd({id:"NOTEBOOK.RUN_SELECTED",name:"Run Selected",shortcut:[q.ALT,q.SHIFT,Y.R],macShortcut:[q.OPTION,q.SHIFT,Y.R]}),FIND:Ce.createAndAdd({id:"NOTEBOOK.FIND",name:"Find",shortcut:[q.CTRL,Y.F],macShortcut:[q.CMD,Y.F],isEditable:!1}),MINIMAP:Ce.createAndAdd({id:"NOTEBOOK.MINIMAP",name:"Show Minimap",shortcut:[q.ALT,Y.M],macShortcut:[q.OPTION,Y.M]}),WORDWRAP:Ce.createAndAdd({id:"NOTEBOOK.WORDWRAP",name:"Word Wrap",shortcut:[q.ALT,Y.Z],macShortcut:[q.OPTION,Y.Z]})},aa={CONSOLE:ia,COMMAND_HISTORY:ra,NOTEBOOK:sa};const be=aa,de=Object.freeze({FATAL:"FATAL",STDERR:"STDERR",ERROR:"ERROR",WARN:"WARN",STDOUT:"STDOUT",INFO:"INFO",DEBUG:"DEBUG",TRACE:"TRACE"});function dn(i,e,t){return e=oa(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function oa(i){var e=la(i,"string");return typeof e=="symbol"?e:String(e)}function la(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Be=Q.module("MonacoCompletionProvider");class rt extends c.PureComponent{static lspToMonacoKind(e){var t=Ht.CompletionItemKind;switch(e){case 1:return t.Text;case 2:return t.Method;case 3:return t.Function;case 4:return t.Constructor;case 5:return t.Field;case 6:return t.Variable;case 7:return t.Class;case 8:return t.Interface;case 9:return t.Module;case 10:return t.Property;case 11:return t.Unit;case 12:return t.Value;case 13:return t.Enum;case 14:return t.Keyword;case 15:return t.Snippet;case 16:return t.Color;case 17:return t.File;case 18:return t.Reference;case 19:return t.Folder;case 20:return t.EnumMember;case 21:return t.Constant;case 22:return t.Struct;case 23:return t.Event;case 24:return t.Operator;case 25:return t.TypeParameter;default:return t.Variable}}static lspToMonacoRange(e){var{start:t,end:n}=e;return{startLineNumber:t.line+1,startColumn:t.character+1,endLineNumber:n.line+1,endColumn:n.character+1}}static monacoToLspPosition(e){return{line:e.lineNumber-1,character:e.column-1}}constructor(e){super(e),dn(this,"registeredCompletionProvider",void 0),dn(this,"registeredSignatureProvider",void 0),dn(this,"registeredHoverProvider",void 0),this.handleCompletionRequest=this.handleCompletionRequest.bind(this),this.handleSignatureRequest=this.handleSignatureRequest.bind(this),this.handleHoverRequest=this.handleHoverRequest.bind(this)}componentDidMount(){var{language:e,session:t}=this.props;this.registeredCompletionProvider=Ht.registerCompletionItemProvider(e,{provideCompletionItems:this.handleCompletionRequest,triggerCharacters:[".",'"',"'"]}),t.getSignatureHelp&&(this.registeredSignatureProvider=Ht.registerSignatureHelpProvider(e,{provideSignatureHelp:this.handleSignatureRequest,signatureHelpTriggerCharacters:["(",","]})),t.getHover&&(this.registeredHoverProvider=Ht.registerHoverProvider(e,{provideHover:this.handleHoverRequest}))}componentWillUnmount(){var e,t,n;(e=this.registeredCompletionProvider)===null||e===void 0||e.dispose(),(t=this.registeredSignatureProvider)===null||t===void 0||t.dispose(),(n=this.registeredHoverProvider)===null||n===void 0||n.dispose()}handleCompletionRequest(e,t,n){var{model:r,session:s}=this.props;if(e!==r)return null;var a={textDocument:{uri:"".concat(e.uri),version:e.getVersionId()},position:rt.monacoToLspPosition(t),context:n},o=s.getCompletionItems(a);Be.debug("Requested completion items",a);var d=o.then(h=>{Be.debug("Completion items received: ",a,h);var u=h.map(v=>{var{label:m,kind:p,detail:E,documentation:S,sortText:g,filterText:y,textEdit:P,insertTextFormat:O}=v;return{label:m,kind:rt.lspToMonacoKind(p),detail:E,documentation:S?.kind==="markdown"?S:S?.value,sortText:g,filterText:y,insertText:P.text,insertTextRules:O===2?4:O,range:rt.lspToMonacoRange(P.range)}});return{incomplete:!0,suggestions:u}}).catch(h=>(Be.error("There was an error retrieving completion items",h),{suggestions:[]}));return d}handleSignatureRequest(e,t,n,r){var s={value:{signatures:[],activeSignature:0,activeParameter:0},dispose:()=>{}},{model:a,session:o}=this.props;if(e!==a||!o.getSignatureHelp)return null;var d={textDocument:{uri:"".concat(e.uri),version:e.getVersionId()},position:rt.monacoToLspPosition(t),context:r},h=o.getSignatureHelp(d);Be.debug("Requested signature help",d);var u=h.then(v=>{Be.debug("Signatures received: ",d,h);var m=v.map(E=>{var{label:S,documentation:g,parameters:y}=E;return{documentation:g?.kind==="markdown"?g:g?.value,label:S,parameters:y??[]}});if(m.length===0)return s;var p=0;return{value:{signatures:m,activeSignature:p,activeParameter:v[p].activeParameter},dispose:()=>{}}}).catch(v=>(Be.error("There was an error retrieving completion items",v),s));return u}handleHoverRequest(e,t){var{model:n,session:r}=this.props;if(e!==n||!r.getHover)return null;var s={textDocument:{uri:"".concat(e.uri),version:e.getVersionId()},position:rt.monacoToLspPosition(t)},a=r.getHover(s);Be.debug("Requested hover",s);var o=a.then(d=>{Be.debug("Hover received: ",s,d);var{contents:h}=d;return{contents:h?[h]:[]}}).catch(d=>(Be.error("There was an error retrieving hover",d),{contents:[]}));return o}render(){return null}}const tr=rt;function Wn(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function da(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){Wn(s,n,r,a,o,"next",d)}function o(d){Wn(s,n,r,a,o,"throw",d)}a(void 0)})}}function Ee(i,e,t){return e=ha(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ha(i){var e=ua(i,"string");return typeof e=="symbol"?e:String(e)}function ua(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var hn=Q.module("ConsoleInput"),Xt=parseInt(us["line-height"],10),nr=6,ir=6,ca=Xt+nr+ir,un=100;class Mt extends c.PureComponent{constructor(e){super(e),Ee(this,"cancelListener",void 0),Ee(this,"resizeObserver",void 0),Ee(this,"commandContainer",void 0),Ee(this,"commandEditor",void 0),Ee(this,"commandHistoryIndex",void 0),Ee(this,"commandSuggestionContainer",void 0),Ee(this,"loadingPromise",void 0),Ee(this,"timestamp",void 0),Ee(this,"bufferIndex",void 0),Ee(this,"history",void 0),Ee(this,"modifiedCommands",void 0),this.handleResize=this.handleResize.bind(this),this.commandContainer=se.createRef(),this.commandHistoryIndex=null,this.timestamp=Date.now(),this.bufferIndex=0,this.history=[],this.modifiedCommands=new Map,this.resizeObserver=new window.ResizeObserver(this.handleResize),this.state={commandEditorHeight:Xt,isFocused:!1,model:null}}componentDidMount(){this.initCommandEditor(),this.loadMoreHistory()}componentDidUpdate(){this.layoutEditor()}componentWillUnmount(){this.resizeObserver.disconnect(),this.loadingPromise!=null&&this.loadingPromise.cancel(),this.destroyCommandEditor()}setConsoleText(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e){if(hn.debug("Command received: ",e),!n){var r;this.commandHistoryIndex=null,(r=this.commandEditor)===null||r===void 0||r.setValue(e)}t&&this.focusEnd(),this.updateDimensions(),n&&this.processCommand(e)}}initCommandEditor(){var{language:e,session:t}=this.props,n={copyWithSyntaxHighlighting:!1,cursorStyle:"block",fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:e,lineHeight:Xt,lineDecorationsWidth:3,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollBeyondLastLine:!1,scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},padding:{top:nr,bottom:ir},value:"",wordWrap:"on"},r=this.commandContainer.current;D(r),this.commandEditor=Nn.create(r,n),Oe.setEOL(this.commandEditor),Oe.openDocument(this.commandEditor,t),this.commandEditor.onDidChangeModelContent(()=>{var s,a=(s=this.commandEditor)===null||s===void 0?void 0:s.getValue();this.modifiedCommands.set(this.commandHistoryIndex,a??null),this.updateDimensions()}),this.commandEditor.onDidFocusEditorText(()=>{this.setState({isFocused:!0})}),this.commandEditor.onDidBlurEditorText(()=>{this.setState({isFocused:!1})}),this.commandEditor.onKeyDown(s=>{var{commandEditor:a,commandHistoryIndex:o}=this,d=a?.getPosition();D(d);var{lineNumber:h}=d,u=a?.getModel();if(s.code==="ArrowUp"&&!this.isSuggestionMenuPopulated()&&h===1){o!=null?this.loadCommand(o+1):this.loadCommand(0),this.focusStart(),s.stopPropagation(),s.preventDefault();return}if(s.code==="ArrowDown"&&!this.isSuggestionMenuPopulated()&&h===u?.getLineCount()){o!=null&&o>0?this.loadCommand(o-1):this.loadCommand(null),this.focusEnd(),s.stopPropagation(),s.preventDefault();return}if(!s.altKey&&!s.shiftKey&&!s.metaKey&&s.keyCode===Nt.Enter&&!this.isSuggestionMenuPopulated()){var v;s.stopPropagation(),s.preventDefault();var m=(v=this.commandEditor)===null||v===void 0?void 0:v.getValue().trim();if(m!==void 0){var p;this.processCommand(m),(p=this.commandEditor)===null||p===void 0||p.setValue("")}}}),Oe.disableKeyBindings(this.commandEditor,[Zi.CtrlCmd|Nt.KeyF]),Oe.registerPasteHandler(this.commandEditor),this.commandEditor.focus(),this.resizeObserver.observe(r),this.updateDimensions(),this.setState({model:this.commandEditor.getModel()})}destroyCommandEditor(){var{session:e}=this.props;this.commandEditor&&(Oe.closeDocument(this.commandEditor,e),this.commandEditor.dispose(),this.commandEditor=void 0)}handleResize(){this.updateDimensions()}isSuggestionMenuActive(){var e;if(!this.commandSuggestionContainer){var t,n;this.commandSuggestionContainer=(t=this.commandEditor)===null||t===void 0||(n=t.getDomNode())===null||n===void 0?void 0:n.querySelector(".suggest-widget")}return(e=this.commandSuggestionContainer&&this.commandSuggestionContainer.classList.contains("visible"))!==null&&e!==void 0?e:!1}isSuggestionMenuPopulated(){var e,t,n;return this.isSuggestionMenuActive()&&((e=(t=this.commandSuggestionContainer)===null||t===void 0||(n=t.querySelector(".monaco-list-rows"))===null||n===void 0?void 0:n.childElementCount)!==null&&e!==void 0?e:0)>0}focus(){var e;(e=this.commandEditor)===null||e===void 0||e.focus()}focusStart(){var e,t,n,r,s,a=(e=this.commandEditor)===null||e===void 0?void 0:e.getModel();D(a);var o=a.getLineLength(1)+1,d=(t=this.commandEditor)===null||t===void 0?void 0:t.getTopForPosition(1,o);D(d),(n=this.commandEditor)===null||n===void 0||n.setPosition({lineNumber:1,column:o}),(r=this.commandEditor)===null||r===void 0||r.setScrollTop(d),(s=this.commandEditor)===null||s===void 0||s.focus()}focusEnd(){var e,t,n,r,s,a=(e=this.commandEditor)===null||e===void 0?void 0:e.getModel();D(a);var o=a.getLineCount(),d=a.getLineLength(o)+1,h=(t=this.commandEditor)===null||t===void 0?void 0:t.getTopForPosition(o,d);D(h),(n=this.commandEditor)===null||n===void 0||n.setPosition({lineNumber:o,column:d}),(r=this.commandEditor)===null||r===void 0||r.setScrollTop(h),(s=this.commandEditor)===null||s===void 0||s.focus()}clear(){var e,t,n;(e=this.commandEditor)===null||e===void 0||e.focus(),(t=this.commandEditor)===null||t===void 0||(n=t.getModel())===null||n===void 0||n.setValue(""),this.commandHistoryIndex=null}layoutEditor(){this.commandEditor&&this.commandEditor.layout()}loadCommand(e){var t,n;if(!(e!==null&&e>=this.history.length)){var r=this.modifiedCommands.get(e),s=e===null?"":this.history[this.history.length-e-1];this.commandHistoryIndex=e,(t=this.commandEditor)===null||t===void 0||(n=t.getModel())===null||n===void 0||n.setValue(r??s),e!==null&&e>this.history.length-un&&this.loadMoreHistory()}}loadMoreHistory(){var e=this;return da(function*(){try{if(e.loadingPromise!=null||e.bufferIndex==null)return;var{commandHistoryStorage:t,language:n,scope:r}=e.props;e.loadingPromise=ce.makeCancelable(t.getTable(n,r??"",e.timestamp),o=>o.close());var s=yield e.loadingPromise;s.setReversed(!0),s.setViewport({top:e.bufferIndex,bottom:e.bufferIndex+un-1}),e.loadingPromise=ce.makeCancelable(s.getViewportData(),()=>s.close());var a=yield e.loadingPromise;e.bufferIndex+=un,e.bufferIndex>=s.size&&(e.bufferIndex=null),e.history=[...a.items.filter((o,d,h)=>{var{name:u}=o;return d===0||u!==h[d-1].name}).map(o=>{var{name:d}=o;return d}).reverse(),...e.history],e.loadingPromise=void 0,s.close()}catch(o){if(e.loadingPromise=void 0,ce.isCanceled(o)){hn.debug2("Promise canceled, not loading history");return}hn.error("Error fetching history",o)}})()}processCommand(e){this.commandHistoryIndex=null,this.modifiedCommands.clear(),D(e),e!==""&&(this.history.length===0||e!==this.history[this.history.length-1])&&this.history.push(e),this.updateDimensions();var{onSubmit:t}=this.props;t(e)}updateDimensions(){if(this.commandEditor){var{maxHeight:e}=this.props;D(e);var t=this.commandEditor.getContentHeight(),n=Math.max(Math.min(t,e),ca),r=t>n,s={overviewRulerLanes:r?void 0:0};this.setState({commandEditorHeight:n},()=>{var a,o;(a=this.commandEditor)===null||a===void 0||a.updateOptions(s),(o=this.commandEditor)===null||o===void 0||o.layout()})}}render(){var{disabled:e,language:t,session:n}=this.props,{commandEditorHeight:r,isFocused:s,model:a}=this.state;return l.jsx("div",{className:ee("console-input-wrapper",{disabled:e}),children:l.jsxs("div",{className:ee("console-input-inner-wrapper",{focus:s}),children:[l.jsx("div",{className:Mt.INPUT_CLASS_NAME,ref:this.commandContainer,style:{height:r}}),a&&l.jsx(tr,{model:a,language:t,session:n})]})})}}Ee(Mt,"defaultProps",{maxHeight:Xt*10,scope:null,disabled:!1});Ee(Mt,"INPUT_CLASS_NAME","console-input");const Kn=Mt;function Ze(i,e,t){return e=va(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function va(i){var e=ma(i,"string");return typeof e=="symbol"?e:String(e)}function ma(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var zn="pasted values",pa=[/^audio.*/,/^font.*/,/^image.*/,/^video.*/],cn=[".csv",".tsv",".tab",".psv",".dsv",".txt"],Gn=[".zip"];class je extends c.Component{static isValidDropItem(e){return e!=null&&e.kind==="file"&&!pa.find(t=>t.test(e.type))}static isValidExtension(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return cn.some(n=>e.endsWith(n))||t&&Gn.some(n=>e.endsWith(n))}static handleDragOver(e){e.preventDefault(),e.stopPropagation()}static getIcon(e){return e===zn?_n:e.endsWith(".csv")?Ur:e.endsWith(".zip")?$r:Br}constructor(e){super(e),Ze(this,"fileElem",void 0),Ze(this,"divElem",void 0),Ze(this,"getValidExtensions",_e(t=>t?[...cn,...Gn]:[...cn])),Ze(this,"getAcceptString",_e(t=>this.getValidExtensions(t).join(", "))),Ze(this,"getFileTypeErrorString",_e(t=>cs.join(this.getValidExtensions(t),"or"))),this.handleSelectFile=this.handleSelectFile.bind(this),this.handleFiles=this.handleFiles.bind(this),this.handleDrop=this.handleDrop.bind(this),this.unstageFile=this.unstageFile.bind(this),this.handleMenuPaste=this.handleMenuPaste.bind(this),this.handlePasteEvent=this.handlePasteEvent.bind(this),this.fileElem=se.createRef(),this.divElem=se.createRef(),this.state={selectedFileName:""}}componentDidMount(){var e,t;(e=this.divElem.current)===null||e===void 0||e.addEventListener("paste",this.handlePasteEvent),(t=this.divElem.current)===null||t===void 0||t.focus()}componentWillUnmount(){var e;(e=this.divElem.current)===null||e===void 0||e.removeEventListener("paste",this.handlePasteEvent)}handleSelectFile(){if(this.fileElem.current){var e;this.fileElem.current.value="",(e=this.fileElem.current)===null||e===void 0||e.click()}}handleFiles(e){e.stopPropagation(),e.preventDefault();var{files:t}=e.target;t!=null&&this.handleFile(t[0])}handleDrop(e){var{allowZip:t,clearDragError:n,dragError:r}=this.props;if(e.preventDefault(),e.stopPropagation(),r!=null){n();return}if(!(e.dataTransfer==null||e.dataTransfer.items==null||e.dataTransfer.items.length===0)){var s=e.dataTransfer.items[0].getAsFile();D(s),je.isValidExtension(s.name,t)?this.handleFile(s):this.setState({dropError:je.FILE_TYPE_ERROR})}}unstageFile(e){var{onCancel:t}=this.props;e.stopPropagation(),e.preventDefault(),t(),this.setState({selectedFileName:"",dropError:void 0})}handleFile(e){var{onFileOpened:t}=this.props;t(e),this.setState({selectedFileName:e.name,dropError:void 0})}handleMenuPaste(){var{onPaste:e,onError:t,uploadInProgress:n}=this.props;n||navigator.clipboard.readText().then(r=>{e(r),this.setState({selectedFileName:zn,dropError:void 0})}).catch(r=>t(r))}handlePasteEvent(e){e.stopPropagation(),e.preventDefault(),this.handleMenuPaste()}makeContextMenuItems(){var{uploadInProgress:e}=this.props;return[{title:"Paste",icon:_n,action:this.handleMenuPaste,shortcut:qt.PASTE,disabled:e}]}render(){var{allowZip:e,dragError:t,uploadInProgress:n}=this.props,{selectedFileName:r,dropError:s}=this.state,a=t??s,o=this.makeContextMenuItems();return l.jsxs("div",{ref:this.divElem,className:"csv-overlay fill-parent-absolute",onDragOver:je.handleDragOver,onDrop:this.handleDrop,tabIndex:-1,children:[l.jsx(k,{actions:o}),l.jsx("input",{ref:this.fileElem,type:"file",id:"fileElem",accept:this.getAcceptString(e),style:{display:"none"},onChange:this.handleFiles,"data-testid":"fileElem"}),!r&&(a===void 0||a==="")&&l.jsxs("div",{className:"message-content",children:[l.jsx("div",{className:"message-icon",children:l.jsx(re,{icon:Vr})}),l.jsx("label",{children:"Drop file (or paste values) here to import"}),l.jsx("div",{className:"message-small",children:l.jsx("label",{children:"or"})}),l.jsx(K,{kind:"primary",onClick:this.handleSelectFile,children:"Select File..."})]}),r&&(a===void 0||a==="")&&l.jsxs("div",{className:"selected-content",children:[l.jsx("div",{className:"selected-icon",children:l.jsx(re,{icon:je.getIcon(r)})}),l.jsxs("div",{className:"selected-text",children:[l.jsx("label",{children:"Selected File"}),l.jsxs("label",{className:"selected-name",children:[r,!n&&l.jsx(K,{kind:"ghost",className:"ml-2",onClick:this.unstageFile,icon:Vi,tooltip:"Remove"})]})]})]}),!!a&&l.jsxs("div",{className:"message-content",children:[l.jsx("div",{className:"message-icon",children:l.jsx(re,{icon:Wi})}),l.jsx("label",{children:a}),a===je.FILE_TYPE_ERROR&&l.jsx("div",{className:"message-small",children:l.jsx("label",{children:this.getFileTypeErrorString(e)})})]})]})}}Ze(je,"defaultProps",{allowZip:!1,dragError:null});Ze(je,"MULTIPLE_FILE_ERROR","Please select only one file");Ze(je,"FILE_TYPE_ERROR","Filetype not supported.");const ut=je;function dt(i,e,t){return e=ga(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ga(i){var e=fa(i,"string");return typeof e=="symbol"?e:String(e)}function fa(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Qe{}dt(Qe,"INTEGER","int");dt(Qe,"LONG","long");dt(Qe,"DOUBLE","double");dt(Qe,"BOOLEAN","bool");dt(Qe,"STRING","string");dt(Qe,"DATE_TIME","datetime");dt(Qe,"LOCAL_TIME","localtime");const U=Qe;function rr(i,e){var t=i.internalStream("string");return t.readable=!0,t.read=()=>!1,t.removeListener=()=>!1,t.on("data",(n,r)=>e(r)),t}function Yn(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function qn(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Yn(Object(t),!0).forEach(function(n){ge(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Yn(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function ge(i,e,t){return e=ba(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ba(i){var e=Ca(i,"string");return typeof e=="symbol"?e:String(e)}function Ca(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Zn="unknown",Sa=2147483647,Ea=-2147483648,Xn=/^[0-9]{4}-[0-1][0-9]-[0-3][0-9][ T][0-2][0-9]:[0-5][0-9]:[0-6][0-9](?:\.[0-9]{1,9})?(?: [a-zA-Z]+)?$/,Qn=/^([0-9]+T)?([0-9]+):([0-9]+)(:[0-9]+)?(?:\.[0-9]{1,9})?$/;class he{static determineType(e,t,n){if(!e||e===n)return t;switch(t){case U.STRING:return U.STRING;case U.INTEGER:return he.checkInteger(e);case U.LONG:return he.checkLong(e);case U.DOUBLE:return he.checkDouble(e);case U.BOOLEAN:return he.checkBoolean(e);case U.DATE_TIME:return he.checkDateTime(e);case U.LOCAL_TIME:return he.checkLocalTime(e);default:return he.getTypeFromUnknown(e)}}static isNotParsableNumber(e){return isNaN(e)||e==="Infinity"||e==="-Infinity"}static checkInteger(e){var t=e.replace(/,/g,"");return he.isNotParsableNumber(t)?U.STRING:he.getNumberType(t)}static checkLong(e){var t=e.replace(/,/g,"");return he.isNotParsableNumber(t)?U.STRING:t.includes(".")?U.DOUBLE:U.LONG}static checkDouble(e){var t=e.replace(/,/g,"");return he.isNotParsableNumber(t)?U.STRING:U.DOUBLE}static checkBoolean(e){var t=e.toLowerCase();return t==="true"||t==="false"?U.BOOLEAN:U.STRING}static checkDateTime(e){return Xn.test(e)?U.DATE_TIME:U.STRING}static checkLocalTime(e){return Qn.test(e)?U.LOCAL_TIME:U.STRING}static getTypeFromUnknown(e){var t=e.replace(/,/g,"");if(he.isNotParsableNumber(t)){var n=e.toLowerCase();return n==="true"||n==="false"?U.BOOLEAN:Xn.test(e)&&e.includes(":")?U.DATE_TIME:Qn.test(e)?U.LOCAL_TIME:U.STRING}return he.getNumberType(t)}static getNumberType(e){if(e.includes("."))return U.DOUBLE;var t=e.startsWith("-")?11:10;if(e.length>t)return U.LONG;var n=parseInt(e,10);return n>Sa||n<Ea?U.LONG:U.INTEGER}constructor(e,t,n,r,s,a,o,d,h,u){ge(this,"onFileCompleted",void 0),ge(this,"file",void 0),ge(this,"readHeaders",void 0),ge(this,"nullString",void 0),ge(this,"onProgress",void 0),ge(this,"onError",void 0),ge(this,"types",void 0),ge(this,"chunks",void 0),ge(this,"totalChunks",void 0),ge(this,"rowCount",void 0),ge(this,"isZip",void 0),ge(this,"shouldTrim",void 0),ge(this,"zipProgress",void 0),ge(this,"config",void 0),this.onFileCompleted=e,this.file=t,this.readHeaders=n,this.nullString=s,this.onProgress=a,this.onError=o,this.chunks=0,this.totalChunks=d,this.rowCount=0,this.isZip=h,this.shouldTrim=u,this.zipProgress=0,this.handleChunk=this.handleChunk.bind(this),this.handleComplete=this.handleComplete.bind(this),this.handleError=this.handleError.bind(this),this.handleNodeUpdate=this.handleNodeUpdate.bind(this),this.config=qn(qn({},r),{},{error:this.handleError,chunk:this.handleChunk,complete:this.handleComplete})}parse(){if(this.file instanceof File||this.file instanceof Blob)Tt.parse(this.file,this.config);else{var e=rr(this.file,this.handleNodeUpdate);Tt.parse(e,this.config),e.resume()}}handleChunk(e,t){var{data:n}=e;if(!this.types){if(n==null||n.length===0){t.abort(),this.onError("Error parsing CSV: no data in file.");return}this.types=new Array(n[0].length).fill(Zn),this.readHeaders&&(n=n.slice(1))}this.rowCount+=n.length,D(this.types);var r=[...this.types];n.forEach(o=>{if(o.length>=r.length){for(var d=0;d<r.length;d+=1)r[d]=he.determineType(this.shouldTrim?o[d].trim():o[d],r[d],this.nullString);this.types=r}else t.abort(),this.onError(`Error parsing CSV: Insufficient data in row.
1
+ import{C as l,G as re,r as c,au as Nr,N as Me,F as ee,H as se,U as _e,av as Tt,V as _i,L as Dt,M as xr,aw as On,ax as Dr,ay as Lr,az as Rr,aA as Ir,R as ki,as as _n,K as It,S as Hi,at as Mr,aB as Fr,ag as Ar}from"./vendor-755ebba4.js";import{x as jr,at as _r,aq as Ui,ar as $i,I as Bi,j as kr,e as N,d as Ct,au as Hr,L as Q,av as kn,aw as Ur,ax as $r,ay as Br,az as Vr,f as Vi,aj as Wi,aA as Ki,aB as Pt,B as wn,ap as Wr,aC as Kr,aD as Gr,aE as Hn,aF as qt,aG as Un,aH as Gi,aI as zr,F as Yr,aJ as qr,aK as Zr,aL as Xr,aM as Qr,C as Jr,M as es,b as ts,c as ns,aN as is,aO as rs,al as ss,aP as as,aQ as os,aR as ls}from"./index-4799bb94.js";import{u as ds,aq as hs,d as zi,B as K,g as Ce,al as q,K as Y,by as us,a6 as Oe,P as ce,G as Zt,N as k,bv as cs,D as Yi,S as vs,C as ms,m as Ot,n as qi,bw as pt,W as ps,h as ot,bx as gs,E as fs,af as bn,ao as bs,aV as Cs,ac as Ss,a8 as Es,aT as ys,bz as Ts,bA as Ps,bB as Os,bC as ws,bD as Ns,bE as xs,bF as Ds,bG as Ls,bH as Rs,bI as Is,r as Nn,M as Ms,aZ as ae,H as xe,z as ke,w as lt,J as Fs,bs as $n,bk as As,b0 as js,bJ as wt,ae as Bn,Q as Lt,am as _s,ai as ks,e as Hs,bK as Us,p as $s,a_ as bt,a$ as Le,b7 as Bs}from"./usePlugins-d26d6337.js";import{e as xn,l as Ht,K as Nt,a as Zi}from"./monaco-0fb6bb22.js";function Vs(i){var{type:e}=i,t=ds();switch(e){case t.VariableType.TABLE:case t.VariableType.TABLEMAP:case t.VariableType.TREETABLE:case t.VariableType.HIERARCHICALTABLE:case t.VariableType.PARTITIONEDTABLE:return l.jsx(re,{icon:$i});case t.VariableType.FIGURE:return l.jsx(re,{icon:Ui});case t.VariableType.PANDAS:return l.jsx(re,{icon:_r});default:return l.jsx(re,{icon:jr})}}function Vn(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function Ws(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){Vn(s,n,r,a,o,"next",d)}function o(d){Vn(s,n,r,a,o,"throw",d)}a(void 0)})}}function Dn(i){var{children:e,language:t}=i,[n,r]=c.useState(null),{activeThemes:s}=hs();return c.useEffect(()=>{var a=!1;function o(){return d.apply(this,arguments)}function d(){return d=Ws(function*(){if(e!=null&&s!=null){var h=yield xn.colorize(e.toString(),t,{});a||r(h)}}),d.apply(this,arguments)}return o(),()=>{a=!0}},[s,e,t]),l.jsx("div",{style:{pointerEvents:"none"},dangerouslySetInnerHTML:n!=null?{__html:n}:void 0})}class Ks{static get LANGUAGE_MAP(){return new Map([["python","Python"],["groovy","Groovy"],["scala","Scala"]])}}const Xi=Ks;class Xt{static hasComment(e){return e.comment!==void 0}static hasPattern(e){return e.pattern!==void 0}static hasOp(e){return e.op!==void 0}static parseArguments(e){return e==null||!(typeof e=="string"||e instanceof String)?[]:Nr.parse(e).filter(t=>!this.hasComment(t)).map(t=>this.hasPattern(t)?t.pattern:this.hasOp(t)?t.op:"".concat(t))}static formatTimestamp(e){if(e==null||!(e instanceof Date))return null;var t="".concat(e.getHours()).padStart(2,"0"),n="".concat(e.getMinutes()).padStart(2,"0"),r="".concat(e.getSeconds()).padStart(2,"0"),s="".concat(e.getMilliseconds()).padStart(3,"0");return"".concat(t,":").concat(n,":").concat(r,".").concat(s)}static isTableType(e,t){return t===e.VariableType.TABLE||t===e.VariableType.TREETABLE||t===e.VariableType.HIERARCHICALTABLE||t===e.VariableType.PARTITIONEDTABLE}static isWidgetType(e,t){return t===e.VariableType.FIGURE||t===e.VariableType.OTHERWIDGET||t===e.VariableType.PANDAS}static isOpenableType(e,t){return Xt.isTableType(e,t)||Xt.isWidgetType(e,t)}static isFigureType(e,t){return t===e.VariableType.FIGURE}static isPandas(e,t){return t===e.VariableType.PANDAS}}const Cn=Xt;function Qi(i){var{children:e}=i;return l.jsxs("div",{className:"console-history-item-result",children:[l.jsx("div",{className:"console-history-gutter",children:"-"}),l.jsx("div",{className:"console-history-content",children:e})]})}Qi.propTypes={children:Me.node.isRequired};function Sn(i,e,t){return e=Gs(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Gs(i){var e=zs(i,"string");return typeof e=="symbol"?e:String(e)}function zs(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Ji extends c.Component{constructor(e){super(e),Sn(this,"timer",void 0),Sn(this,"startTime",void 0),this.updateElapsed=this.updateElapsed.bind(this),this.startTime=Date.now(),this.state={elapsed:0}}componentDidMount(){this.timer=setInterval(this.updateElapsed,1e3)}componentWillUnmount(){this.timer&&clearInterval(this.timer),this.timer=void 0}updateElapsed(){this.setState({elapsed:Math.round((Date.now()-this.startTime)/1e3)})}render(){var{disabled:e,onCancelClick:t}=this.props,{elapsed:n}=this.state;return l.jsx("div",{className:ee("console-history-result-in-progress",{disabled:e}),children:l.jsxs("span",{className:"badge",children:[l.jsx(Bi,{className:"ml-2"}),"Running... ",zi.formatElapsedTime(n)," ",l.jsx(K,{className:"console-history-result-in-progress-cancel",kind:"ghost",icon:kr,tooltip:"Cancel",onClick:t,disabled:e})]})})}}Sn(Ji,"defaultProps",{disabled:!1});const Ys=Ji;function xt(i,e,t){return e=qs(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function qs(i){var e=Zs(i,"string");return typeof e=="symbol"?e:String(e)}function Zs(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class ct extends c.PureComponent{constructor(e){super(e),xt(this,"mouseX",void 0),xt(this,"mouseY",void 0),xt(this,"isClicking",void 0),this.handleKeyPress=this.handleKeyPress.bind(this),this.handleMouseDown=this.handleMouseDown.bind(this),this.handleMouseMove=this.handleMouseMove.bind(this),this.handleMouseUp=this.handleMouseUp.bind(this),this.handleToggleError=this.handleToggleError.bind(this),this.handleMouseEnter=this.handleMouseEnter.bind(this),this.handleMouseLeave=this.handleMouseLeave.bind(this),this.mouseX=null,this.mouseY=null,this.isClicking=!1,this.state={isExpanded:!1,isTriggerHovered:!1}}handleKeyPress(e){switch(e.key){case"Enter":case" ":this.handleToggleError(),e.stopPropagation(),e.preventDefault();break}}handleMouseDown(e){this.mouseX=e.clientX,this.mouseY=e.clientY,this.isClicking=!0}handleMouseMove(e){this.mouseX!=null&&this.mouseY!=null?(Math.abs(e.clientX-this.mouseX)>=ct.mouseDragThreshold||Math.abs(e.clientY-this.mouseY)>=ct.mouseDragThreshold)&&(this.isClicking=!1):this.isClicking&&(this.isClicking=!1)}handleMouseUp(e){this.isClicking&&!e.shiftKey&&!e.metaKey&&!e.altKey&&this.handleToggleError(),this.mouseX=null,this.mouseY=null,this.isClicking=!1}handleToggleError(){this.setState(e=>({isExpanded:!e.isExpanded}))}handleMouseEnter(){this.setState({isTriggerHovered:!0})}handleMouseLeave(){this.setState({isTriggerHovered:!1})}render(){var{isExpanded:e,isTriggerHovered:t}=this.state,{message:n}=this.props;N(n);var r=n.indexOf(`
2
+ `),s=r>-1,a=n;s&&(a=n.slice(0,r));var o=n.slice(r),d=t?"error-btn-link error-btn-link--active":"error-btn-link";return l.jsxs("div",{className:ee("error-message",{expanded:e}),children:[s&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"error-gutter",children:l.jsx("button",{type:"button",onClick:this.handleToggleError,className:d,tabIndex:-1,children:l.jsx(re,{icon:e?Ct:Hr,transform:"left-3"})})}),l.jsxs("div",{className:"error-content",children:[l.jsx("div",{className:"console-error-text-trigger",role:"button",tabIndex:0,onKeyPress:this.handleKeyPress,onMouseDown:this.handleMouseDown,onMouseMove:this.handleMouseMove,onMouseEnter:this.handleMouseEnter,onMouseLeave:this.handleMouseLeave,onMouseUp:this.handleMouseUp,children:a}),e?o:""]})]}),!s&&l.jsx("div",{className:"error-content",children:l.jsx("div",{className:"console-error-text",children:a})})]},"error")}}xt(ct,"defaultProps",{message:""});xt(ct,"mouseDragThreshold",5);const Xs=ct;function Qs(i,e,t){return e=Js(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Js(i){var e=ea(i,"string");return typeof e=="symbol"?e:String(e)}function ea(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Wn=Q.module("ConsoleHistoryItem");class er extends c.PureComponent{constructor(e){super(e),this.handleCancelClick=this.handleCancelClick.bind(this),this.handleObjectClick=this.handleObjectClick.bind(this)}handleObjectClick(e){Wn.debug("handleObjectClick",e);var{openObject:t}=this.props;t(e)}handleCancelClick(){var{item:e}=this.props;e!=null&&e.cancelResult&&(Wn.debug("Cancelling command: ".concat(e.command)),e.cancelResult())}render(){var{disabled:e,item:t,language:n,iconForType:r}=this.props,{disabledObjects:s,result:a}=t,o=t.command!=null&&t.command!=="",d=null;o&&(d=l.jsxs("div",{className:"console-history-item-command",children:[l.jsx("div",{className:"console-history-gutter",children:">"}),l.jsx("div",{className:"console-history-content",children:l.jsx(Dn,{language:n,children:t.command})})]}));var h=[],u=!1;if(a){var{error:v,message:m,changes:p}=a;if(p){var{created:E,updated:S}=p;[...E,...S].forEach(Z=>{u=!0;var{title:A}=Z,z="".concat(A),G=e===void 0||e||(s??[]).indexOf(z)>=0,X=l.jsx(K,{kind:"primary",onClick:()=>this.handleObjectClick(Z),className:"btn-console-object",disabled:G,icon:r(Z.type),children:A},z);h.push(X)})}if(v!=null&&!o){var g,y="".concat((g=v.message)!==null&&g!==void 0?g:v);y||(y=v);var P=l.jsx(Xs,{message:y},"result-error");h.push(P)}if(m!==void 0&&m!==""){var O=l.jsx("div",{className:"log-message",children:m},"log-message");h.push(O)}}else{u=!0;var L=l.jsx(Ys,{onCancelClick:this.handleCancelClick,disabled:e},"in_progress");h.push(L)}var V=null;return h.length>0&&(V=l.jsx(Qi,{children:h})),l.jsxs("div",{className:ee("console-command-result",{"console-result-buttons":u}),children:[d,V]})}}Qs(er,"defaultProps",{disabled:!1});const ta=er;function na(i,e){return"".concat(i,".").concat(e.command,".").concat(e.result&&e.result.message,".").concat(e.result&&e.result.error)}function ia(i){for(var{disabled:e=!1,items:t,language:n,openObject:r,supportsType:s,iconForType:a}=i,o=[],d=0;d<t.length;d+=1){var h=t[d],u=l.jsx(ta,{disabled:e,item:h,openObject:r,language:n,supportsType:s,iconForType:a},na(d,h));o.push(u)}return l.jsx("div",{className:"container-fluid console-history",children:o})}var ra={name:"Console",CLEAR:Ce.createAndAdd({id:"CONSOLE.CLEAR",name:"Clear",shortcut:[q.CTRL,Y.L],macShortcut:[q.CTRL,Y.C]}),FOCUS_HISTORY:Ce.createAndAdd({id:"CONSOLE.FOCUS_HISTORY",name:"Focus History",shortcut:[q.CTRL,Y.H],macShortcut:[q.CTRL,q.OPTION,Y.H]})},sa={name:"Command History",FOCUS_HISTORY:Ce.createAndAdd({id:"COMMAND_HISTORY.FOCUS_HISTORY",name:"Focus History Search",shortcut:[q.CTRL,Y.H],macShortcut:[q.CTRL,q.OPTION,Y.H]}),SEND_TO_CONSOLE:Ce.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_CONSOLE",name:"Send to Console",shortcut:[Y.ENTER],macShortcut:[Y.ENTER]}),SEND_TO_NOTEBOOK:Ce.createAndAdd({id:"COMMAND_HISTORY.SEND_TO_NOTEBOOK",name:"Send to Notebook",shortcut:[q.CTRL,Y.ENTER],macShortcut:[q.CMD,Y.ENTER]}),RUN:Ce.createAndAdd({id:"COMMAND_HISTORY.RUN",name:"Run",shortcut:[q.ALT,Y.R],macShortcut:[q.OPTION,Y.R]})},aa={name:"Notebook",RUN:Ce.createAndAdd({id:"NOTEBOOK.RUN",name:"Run",shortcut:[q.ALT,Y.R],macShortcut:[q.OPTION,Y.R]}),RUN_SELECTED:Ce.createAndAdd({id:"NOTEBOOK.RUN_SELECTED",name:"Run Selected",shortcut:[q.ALT,q.SHIFT,Y.R],macShortcut:[q.OPTION,q.SHIFT,Y.R]}),FIND:Ce.createAndAdd({id:"NOTEBOOK.FIND",name:"Find",shortcut:[q.CTRL,Y.F],macShortcut:[q.CMD,Y.F],isEditable:!1}),MINIMAP:Ce.createAndAdd({id:"NOTEBOOK.MINIMAP",name:"Show Minimap",shortcut:[q.ALT,Y.M],macShortcut:[q.OPTION,Y.M]}),WORDWRAP:Ce.createAndAdd({id:"NOTEBOOK.WORDWRAP",name:"Word Wrap",shortcut:[q.ALT,Y.Z],macShortcut:[q.OPTION,Y.Z]})},oa={CONSOLE:ra,COMMAND_HISTORY:sa,NOTEBOOK:aa};const be=oa,de=Object.freeze({FATAL:"FATAL",STDERR:"STDERR",ERROR:"ERROR",WARN:"WARN",STDOUT:"STDOUT",INFO:"INFO",DEBUG:"DEBUG",TRACE:"TRACE"});function hn(i,e,t){return e=la(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function la(i){var e=da(i,"string");return typeof e=="symbol"?e:String(e)}function da(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Be=Q.module("MonacoCompletionProvider");class rt extends c.PureComponent{static lspToMonacoKind(e){var t=Ht.CompletionItemKind;switch(e){case 1:return t.Text;case 2:return t.Method;case 3:return t.Function;case 4:return t.Constructor;case 5:return t.Field;case 6:return t.Variable;case 7:return t.Class;case 8:return t.Interface;case 9:return t.Module;case 10:return t.Property;case 11:return t.Unit;case 12:return t.Value;case 13:return t.Enum;case 14:return t.Keyword;case 15:return t.Snippet;case 16:return t.Color;case 17:return t.File;case 18:return t.Reference;case 19:return t.Folder;case 20:return t.EnumMember;case 21:return t.Constant;case 22:return t.Struct;case 23:return t.Event;case 24:return t.Operator;case 25:return t.TypeParameter;default:return t.Variable}}static lspToMonacoRange(e){var{start:t,end:n}=e;return{startLineNumber:t.line+1,startColumn:t.character+1,endLineNumber:n.line+1,endColumn:n.character+1}}static monacoToLspPosition(e){return{line:e.lineNumber-1,character:e.column-1}}constructor(e){super(e),hn(this,"registeredCompletionProvider",void 0),hn(this,"registeredSignatureProvider",void 0),hn(this,"registeredHoverProvider",void 0),this.handleCompletionRequest=this.handleCompletionRequest.bind(this),this.handleSignatureRequest=this.handleSignatureRequest.bind(this),this.handleHoverRequest=this.handleHoverRequest.bind(this)}componentDidMount(){var{language:e,session:t}=this.props;this.registeredCompletionProvider=Ht.registerCompletionItemProvider(e,{provideCompletionItems:this.handleCompletionRequest,triggerCharacters:[".",'"',"'"]}),t.getSignatureHelp&&(this.registeredSignatureProvider=Ht.registerSignatureHelpProvider(e,{provideSignatureHelp:this.handleSignatureRequest,signatureHelpTriggerCharacters:["(",","]})),t.getHover&&(this.registeredHoverProvider=Ht.registerHoverProvider(e,{provideHover:this.handleHoverRequest}))}componentWillUnmount(){var e,t,n;(e=this.registeredCompletionProvider)===null||e===void 0||e.dispose(),(t=this.registeredSignatureProvider)===null||t===void 0||t.dispose(),(n=this.registeredHoverProvider)===null||n===void 0||n.dispose()}handleCompletionRequest(e,t,n){var{model:r,session:s}=this.props;if(e!==r)return null;var a={textDocument:{uri:"".concat(e.uri),version:e.getVersionId()},position:rt.monacoToLspPosition(t),context:n},o=s.getCompletionItems(a);Be.debug("Requested completion items",a);var d=o.then(h=>{Be.debug("Completion items received: ",a,h);var u=h.map(v=>{var{label:m,kind:p,detail:E,documentation:S,sortText:g,filterText:y,textEdit:P,insertTextFormat:O}=v;return{label:m,kind:rt.lspToMonacoKind(p),detail:E,documentation:S?.kind==="markdown"?S:S?.value,sortText:g,filterText:y,insertText:P.text,insertTextRules:O===2?4:O,range:rt.lspToMonacoRange(P.range)}});return{incomplete:!0,suggestions:u}}).catch(h=>(Be.error("There was an error retrieving completion items",h),{suggestions:[]}));return d}handleSignatureRequest(e,t,n,r){var s={value:{signatures:[],activeSignature:0,activeParameter:0},dispose:()=>{}},{model:a,session:o}=this.props;if(e!==a||!o.getSignatureHelp)return null;var d={textDocument:{uri:"".concat(e.uri),version:e.getVersionId()},position:rt.monacoToLspPosition(t),context:r},h=o.getSignatureHelp(d);Be.debug("Requested signature help",d);var u=h.then(v=>{Be.debug("Signatures received: ",d,h);var m=v.map(E=>{var{label:S,documentation:g,parameters:y}=E;return{documentation:g?.kind==="markdown"?g:g?.value,label:S,parameters:y??[]}});if(m.length===0)return s;var p=0;return{value:{signatures:m,activeSignature:p,activeParameter:v[p].activeParameter},dispose:()=>{}}}).catch(v=>(Be.error("There was an error retrieving completion items",v),s));return u}handleHoverRequest(e,t){var{model:n,session:r}=this.props;if(e!==n||!r.getHover)return null;var s={textDocument:{uri:"".concat(e.uri),version:e.getVersionId()},position:rt.monacoToLspPosition(t)},a=r.getHover(s);Be.debug("Requested hover",s);var o=a.then(d=>{Be.debug("Hover received: ",s,d);var{contents:h}=d;return{contents:h?[h]:[]}}).catch(d=>(Be.error("There was an error retrieving hover",d),{contents:[]}));return o}render(){return null}}const tr=rt;function Kn(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function ha(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){Kn(s,n,r,a,o,"next",d)}function o(d){Kn(s,n,r,a,o,"throw",d)}a(void 0)})}}function Ee(i,e,t){return e=ua(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ua(i){var e=ca(i,"string");return typeof e=="symbol"?e:String(e)}function ca(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var un=Q.module("ConsoleInput"),Qt=parseInt(us["line-height"],10),nr=6,ir=6,va=Qt+nr+ir,cn=100;class Mt extends c.PureComponent{constructor(e){super(e),Ee(this,"cancelListener",void 0),Ee(this,"resizeObserver",void 0),Ee(this,"commandContainer",void 0),Ee(this,"commandEditor",void 0),Ee(this,"commandHistoryIndex",void 0),Ee(this,"commandSuggestionContainer",void 0),Ee(this,"loadingPromise",void 0),Ee(this,"timestamp",void 0),Ee(this,"bufferIndex",void 0),Ee(this,"history",void 0),Ee(this,"modifiedCommands",void 0),this.handleResize=this.handleResize.bind(this),this.commandContainer=se.createRef(),this.commandHistoryIndex=null,this.timestamp=Date.now(),this.bufferIndex=0,this.history=[],this.modifiedCommands=new Map,this.resizeObserver=new window.ResizeObserver(this.handleResize),this.state={commandEditorHeight:Qt,isFocused:!1,model:null}}componentDidMount(){this.initCommandEditor(),this.loadMoreHistory()}componentDidUpdate(){this.layoutEditor()}componentWillUnmount(){this.resizeObserver.disconnect(),this.loadingPromise!=null&&this.loadingPromise.cancel(),this.destroyCommandEditor()}setConsoleText(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(e){if(un.debug("Command received: ",e),!n){var r;this.commandHistoryIndex=null,(r=this.commandEditor)===null||r===void 0||r.setValue(e)}t&&this.focusEnd(),this.updateDimensions(),n&&this.processCommand(e)}}initCommandEditor(){var{language:e,session:t}=this.props,n={copyWithSyntaxHighlighting:!1,cursorStyle:"block",fixedOverflowWidgets:!0,folding:!1,fontFamily:"Fira Mono",glyphMargin:!1,language:e,lineHeight:Qt,lineDecorationsWidth:3,lineNumbers:"off",minimap:{enabled:!1},renderLineHighlight:"none",scrollBeyondLastLine:!1,scrollbar:{arrowSize:0,horizontal:"hidden",horizontalScrollbarSize:0},padding:{top:nr,bottom:ir},value:"",wordWrap:"on"},r=this.commandContainer.current;N(r),this.commandEditor=xn.create(r,n),Oe.setEOL(this.commandEditor),Oe.openDocument(this.commandEditor,t),this.commandEditor.onDidChangeModelContent(()=>{var s,a=(s=this.commandEditor)===null||s===void 0?void 0:s.getValue();this.modifiedCommands.set(this.commandHistoryIndex,a??null),this.updateDimensions()}),this.commandEditor.onDidFocusEditorText(()=>{this.setState({isFocused:!0})}),this.commandEditor.onDidBlurEditorText(()=>{this.setState({isFocused:!1})}),this.commandEditor.onKeyDown(s=>{var{commandEditor:a,commandHistoryIndex:o}=this,d=a?.getPosition();N(d);var{lineNumber:h}=d,u=a?.getModel();if(s.code==="ArrowUp"&&!this.isSuggestionMenuPopulated()&&h===1){o!=null?this.loadCommand(o+1):this.loadCommand(0),this.focusStart(),s.stopPropagation(),s.preventDefault();return}if(s.code==="ArrowDown"&&!this.isSuggestionMenuPopulated()&&h===u?.getLineCount()){o!=null&&o>0?this.loadCommand(o-1):this.loadCommand(null),this.focusEnd(),s.stopPropagation(),s.preventDefault();return}if(!s.altKey&&!s.shiftKey&&!s.metaKey&&s.keyCode===Nt.Enter&&!this.isSuggestionMenuPopulated()){var v;s.stopPropagation(),s.preventDefault();var m=(v=this.commandEditor)===null||v===void 0?void 0:v.getValue().trim();if(m!==void 0){var p;this.processCommand(m),(p=this.commandEditor)===null||p===void 0||p.setValue("")}}}),Oe.disableKeyBindings(this.commandEditor,[Zi.CtrlCmd|Nt.KeyF]),Oe.registerPasteHandler(this.commandEditor),this.commandEditor.focus(),this.resizeObserver.observe(r),this.updateDimensions(),this.setState({model:this.commandEditor.getModel()})}destroyCommandEditor(){var{session:e}=this.props;this.commandEditor&&(Oe.closeDocument(this.commandEditor,e),this.commandEditor.dispose(),this.commandEditor=void 0)}handleResize(){this.updateDimensions()}isSuggestionMenuActive(){var e;if(!this.commandSuggestionContainer){var t,n;this.commandSuggestionContainer=(t=this.commandEditor)===null||t===void 0||(n=t.getDomNode())===null||n===void 0?void 0:n.querySelector(".suggest-widget")}return(e=this.commandSuggestionContainer&&this.commandSuggestionContainer.classList.contains("visible"))!==null&&e!==void 0?e:!1}isSuggestionMenuPopulated(){var e,t,n;return this.isSuggestionMenuActive()&&((e=(t=this.commandSuggestionContainer)===null||t===void 0||(n=t.querySelector(".monaco-list-rows"))===null||n===void 0?void 0:n.childElementCount)!==null&&e!==void 0?e:0)>0}focus(){var e;(e=this.commandEditor)===null||e===void 0||e.focus()}focusStart(){var e,t,n,r,s,a=(e=this.commandEditor)===null||e===void 0?void 0:e.getModel();N(a);var o=a.getLineLength(1)+1,d=(t=this.commandEditor)===null||t===void 0?void 0:t.getTopForPosition(1,o);N(d),(n=this.commandEditor)===null||n===void 0||n.setPosition({lineNumber:1,column:o}),(r=this.commandEditor)===null||r===void 0||r.setScrollTop(d),(s=this.commandEditor)===null||s===void 0||s.focus()}focusEnd(){var e,t,n,r,s,a=(e=this.commandEditor)===null||e===void 0?void 0:e.getModel();N(a);var o=a.getLineCount(),d=a.getLineLength(o)+1,h=(t=this.commandEditor)===null||t===void 0?void 0:t.getTopForPosition(o,d);N(h),(n=this.commandEditor)===null||n===void 0||n.setPosition({lineNumber:o,column:d}),(r=this.commandEditor)===null||r===void 0||r.setScrollTop(h),(s=this.commandEditor)===null||s===void 0||s.focus()}clear(){var e,t,n;(e=this.commandEditor)===null||e===void 0||e.focus(),(t=this.commandEditor)===null||t===void 0||(n=t.getModel())===null||n===void 0||n.setValue(""),this.commandHistoryIndex=null}layoutEditor(){this.commandEditor&&this.commandEditor.layout()}loadCommand(e){var t,n;if(!(e!==null&&e>=this.history.length)){var r=this.modifiedCommands.get(e),s=e===null?"":this.history[this.history.length-e-1];this.commandHistoryIndex=e,(t=this.commandEditor)===null||t===void 0||(n=t.getModel())===null||n===void 0||n.setValue(r??s),e!==null&&e>this.history.length-cn&&this.loadMoreHistory()}}loadMoreHistory(){var e=this;return ha(function*(){try{if(e.loadingPromise!=null||e.bufferIndex==null)return;var{commandHistoryStorage:t,language:n,scope:r}=e.props;e.loadingPromise=ce.makeCancelable(t.getTable(n,r??"",e.timestamp),o=>o.close());var s=yield e.loadingPromise;s.setReversed(!0),s.setViewport({top:e.bufferIndex,bottom:e.bufferIndex+cn-1}),e.loadingPromise=ce.makeCancelable(s.getViewportData(),()=>s.close());var a=yield e.loadingPromise;e.bufferIndex+=cn,e.bufferIndex>=s.size&&(e.bufferIndex=null),e.history=[...a.items.filter((o,d,h)=>{var{name:u}=o;return d===0||u!==h[d-1].name}).map(o=>{var{name:d}=o;return d}).reverse(),...e.history],e.loadingPromise=void 0,s.close()}catch(o){if(e.loadingPromise=void 0,ce.isCanceled(o)){un.debug2("Promise canceled, not loading history");return}un.error("Error fetching history",o)}})()}processCommand(e){this.commandHistoryIndex=null,this.modifiedCommands.clear(),N(e),e!==""&&(this.history.length===0||e!==this.history[this.history.length-1])&&this.history.push(e),this.updateDimensions();var{onSubmit:t}=this.props;t(e)}updateDimensions(){if(this.commandEditor){var{maxHeight:e}=this.props;N(e);var t=this.commandEditor.getContentHeight(),n=Math.max(Math.min(t,e),va),r=t>n,s={overviewRulerLanes:r?void 0:0};this.setState({commandEditorHeight:n},()=>{var a,o;(a=this.commandEditor)===null||a===void 0||a.updateOptions(s),(o=this.commandEditor)===null||o===void 0||o.layout()})}}render(){var{disabled:e,language:t,session:n}=this.props,{commandEditorHeight:r,isFocused:s,model:a}=this.state;return l.jsx("div",{className:ee("console-input-wrapper",{disabled:e}),children:l.jsxs("div",{className:ee("console-input-inner-wrapper",{focus:s}),children:[l.jsx("div",{className:Mt.INPUT_CLASS_NAME,ref:this.commandContainer,style:{height:r}}),a&&l.jsx(tr,{model:a,language:t,session:n})]})})}}Ee(Mt,"defaultProps",{maxHeight:Qt*10,scope:null,disabled:!1});Ee(Mt,"INPUT_CLASS_NAME","console-input");const Gn=Mt;function Ze(i,e,t){return e=ma(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ma(i){var e=pa(i,"string");return typeof e=="symbol"?e:String(e)}function pa(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var zn="pasted values",ga=[/^audio.*/,/^font.*/,/^image.*/,/^video.*/],vn=[".csv",".tsv",".tab",".psv",".dsv",".txt"],Yn=[".zip"];class je extends c.Component{static isValidDropItem(e){return e!=null&&e.kind==="file"&&!ga.find(t=>t.test(e.type))}static isValidExtension(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;return vn.some(n=>e.endsWith(n))||t&&Yn.some(n=>e.endsWith(n))}static handleDragOver(e){e.preventDefault(),e.stopPropagation()}static getIcon(e){return e===zn?kn:e.endsWith(".csv")?Ur:e.endsWith(".zip")?$r:Br}constructor(e){super(e),Ze(this,"fileElem",void 0),Ze(this,"divElem",void 0),Ze(this,"getValidExtensions",_e(t=>t?[...vn,...Yn]:[...vn])),Ze(this,"getAcceptString",_e(t=>this.getValidExtensions(t).join(", "))),Ze(this,"getFileTypeErrorString",_e(t=>cs.join(this.getValidExtensions(t),"or"))),this.handleSelectFile=this.handleSelectFile.bind(this),this.handleFiles=this.handleFiles.bind(this),this.handleDrop=this.handleDrop.bind(this),this.unstageFile=this.unstageFile.bind(this),this.handleMenuPaste=this.handleMenuPaste.bind(this),this.handlePasteEvent=this.handlePasteEvent.bind(this),this.fileElem=se.createRef(),this.divElem=se.createRef(),this.state={selectedFileName:""}}componentDidMount(){var e,t;(e=this.divElem.current)===null||e===void 0||e.addEventListener("paste",this.handlePasteEvent),(t=this.divElem.current)===null||t===void 0||t.focus()}componentWillUnmount(){var e;(e=this.divElem.current)===null||e===void 0||e.removeEventListener("paste",this.handlePasteEvent)}handleSelectFile(){if(this.fileElem.current){var e;this.fileElem.current.value="",(e=this.fileElem.current)===null||e===void 0||e.click()}}handleFiles(e){e.stopPropagation(),e.preventDefault();var{files:t}=e.target;t!=null&&this.handleFile(t[0])}handleDrop(e){var{allowZip:t,clearDragError:n,dragError:r}=this.props;if(e.preventDefault(),e.stopPropagation(),r!=null){n();return}if(!(e.dataTransfer==null||e.dataTransfer.items==null||e.dataTransfer.items.length===0)){var s=e.dataTransfer.items[0].getAsFile();N(s),je.isValidExtension(s.name,t)?this.handleFile(s):this.setState({dropError:je.FILE_TYPE_ERROR})}}unstageFile(e){var{onCancel:t}=this.props;e.stopPropagation(),e.preventDefault(),t(),this.setState({selectedFileName:"",dropError:void 0})}handleFile(e){var{onFileOpened:t}=this.props;t(e),this.setState({selectedFileName:e.name,dropError:void 0})}handleMenuPaste(){var{onPaste:e,onError:t,uploadInProgress:n}=this.props;n||navigator.clipboard.readText().then(r=>{e(r),this.setState({selectedFileName:zn,dropError:void 0})}).catch(r=>t(r))}handlePasteEvent(e){e.stopPropagation(),e.preventDefault(),this.handleMenuPaste()}makeContextMenuItems(){var{uploadInProgress:e}=this.props;return[{title:"Paste",icon:kn,action:this.handleMenuPaste,shortcut:Zt.PASTE,disabled:e}]}render(){var{allowZip:e,dragError:t,uploadInProgress:n}=this.props,{selectedFileName:r,dropError:s}=this.state,a=t??s,o=this.makeContextMenuItems();return l.jsxs("div",{ref:this.divElem,className:"csv-overlay fill-parent-absolute",onDragOver:je.handleDragOver,onDrop:this.handleDrop,tabIndex:-1,children:[l.jsx(k,{actions:o}),l.jsx("input",{ref:this.fileElem,type:"file",id:"fileElem",accept:this.getAcceptString(e),style:{display:"none"},onChange:this.handleFiles,"data-testid":"fileElem"}),!r&&(a===void 0||a==="")&&l.jsxs("div",{className:"message-content",children:[l.jsx("div",{className:"message-icon",children:l.jsx(re,{icon:Vr})}),l.jsx("label",{children:"Drop file (or paste values) here to import"}),l.jsx("div",{className:"message-small",children:l.jsx("label",{children:"or"})}),l.jsx(K,{kind:"primary",onClick:this.handleSelectFile,children:"Select File..."})]}),r&&(a===void 0||a==="")&&l.jsxs("div",{className:"selected-content",children:[l.jsx("div",{className:"selected-icon",children:l.jsx(re,{icon:je.getIcon(r)})}),l.jsxs("div",{className:"selected-text",children:[l.jsx("label",{children:"Selected File"}),l.jsxs("label",{className:"selected-name",children:[r,!n&&l.jsx(K,{kind:"ghost",className:"ml-2",onClick:this.unstageFile,icon:Vi,tooltip:"Remove"})]})]})]}),!!a&&l.jsxs("div",{className:"message-content",children:[l.jsx("div",{className:"message-icon",children:l.jsx(re,{icon:Wi})}),l.jsx("label",{children:a}),a===je.FILE_TYPE_ERROR&&l.jsx("div",{className:"message-small",children:l.jsx("label",{children:this.getFileTypeErrorString(e)})})]})]})}}Ze(je,"defaultProps",{allowZip:!1,dragError:null});Ze(je,"MULTIPLE_FILE_ERROR","Please select only one file");Ze(je,"FILE_TYPE_ERROR","Filetype not supported.");const ut=je;function dt(i,e,t){return e=fa(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function fa(i){var e=ba(i,"string");return typeof e=="symbol"?e:String(e)}function ba(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Qe{}dt(Qe,"INTEGER","int");dt(Qe,"LONG","long");dt(Qe,"DOUBLE","double");dt(Qe,"BOOLEAN","bool");dt(Qe,"STRING","string");dt(Qe,"DATE_TIME","datetime");dt(Qe,"LOCAL_TIME","localtime");const U=Qe;function rr(i,e){var t=i.internalStream("string");return t.readable=!0,t.read=()=>!1,t.removeListener=()=>!1,t.on("data",(n,r)=>e(r)),t}function qn(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Zn(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?qn(Object(t),!0).forEach(function(n){ge(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):qn(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function ge(i,e,t){return e=Ca(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ca(i){var e=Sa(i,"string");return typeof e=="symbol"?e:String(e)}function Sa(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Xn="unknown",Ea=2147483647,ya=-2147483648,Qn=/^[0-9]{4}-[0-1][0-9]-[0-3][0-9][ T][0-2][0-9]:[0-5][0-9]:[0-6][0-9](?:\.[0-9]{1,9})?(?: [a-zA-Z]+)?$/,Jn=/^([0-9]+T)?([0-9]+):([0-9]+)(:[0-9]+)?(?:\.[0-9]{1,9})?$/;class he{static determineType(e,t,n){if(!e||e===n)return t;switch(t){case U.STRING:return U.STRING;case U.INTEGER:return he.checkInteger(e);case U.LONG:return he.checkLong(e);case U.DOUBLE:return he.checkDouble(e);case U.BOOLEAN:return he.checkBoolean(e);case U.DATE_TIME:return he.checkDateTime(e);case U.LOCAL_TIME:return he.checkLocalTime(e);default:return he.getTypeFromUnknown(e)}}static isNotParsableNumber(e){return isNaN(e)||e==="Infinity"||e==="-Infinity"}static checkInteger(e){var t=e.replace(/,/g,"");return he.isNotParsableNumber(t)?U.STRING:he.getNumberType(t)}static checkLong(e){var t=e.replace(/,/g,"");return he.isNotParsableNumber(t)?U.STRING:t.includes(".")?U.DOUBLE:U.LONG}static checkDouble(e){var t=e.replace(/,/g,"");return he.isNotParsableNumber(t)?U.STRING:U.DOUBLE}static checkBoolean(e){var t=e.toLowerCase();return t==="true"||t==="false"?U.BOOLEAN:U.STRING}static checkDateTime(e){return Qn.test(e)?U.DATE_TIME:U.STRING}static checkLocalTime(e){return Jn.test(e)?U.LOCAL_TIME:U.STRING}static getTypeFromUnknown(e){var t=e.replace(/,/g,"");if(he.isNotParsableNumber(t)){var n=e.toLowerCase();return n==="true"||n==="false"?U.BOOLEAN:Qn.test(e)&&e.includes(":")?U.DATE_TIME:Jn.test(e)?U.LOCAL_TIME:U.STRING}return he.getNumberType(t)}static getNumberType(e){if(e.includes("."))return U.DOUBLE;var t=e.startsWith("-")?11:10;if(e.length>t)return U.LONG;var n=parseInt(e,10);return n>Ea||n<ya?U.LONG:U.INTEGER}constructor(e,t,n,r,s,a,o,d,h,u){ge(this,"onFileCompleted",void 0),ge(this,"file",void 0),ge(this,"readHeaders",void 0),ge(this,"nullString",void 0),ge(this,"onProgress",void 0),ge(this,"onError",void 0),ge(this,"types",void 0),ge(this,"chunks",void 0),ge(this,"totalChunks",void 0),ge(this,"rowCount",void 0),ge(this,"isZip",void 0),ge(this,"shouldTrim",void 0),ge(this,"zipProgress",void 0),ge(this,"config",void 0),this.onFileCompleted=e,this.file=t,this.readHeaders=n,this.nullString=s,this.onProgress=a,this.onError=o,this.chunks=0,this.totalChunks=d,this.rowCount=0,this.isZip=h,this.shouldTrim=u,this.zipProgress=0,this.handleChunk=this.handleChunk.bind(this),this.handleComplete=this.handleComplete.bind(this),this.handleError=this.handleError.bind(this),this.handleNodeUpdate=this.handleNodeUpdate.bind(this),this.config=Zn(Zn({},r),{},{error:this.handleError,chunk:this.handleChunk,complete:this.handleComplete})}parse(){if(this.file instanceof File||this.file instanceof Blob)Tt.parse(this.file,this.config);else{var e=rr(this.file,this.handleNodeUpdate);Tt.parse(e,this.config),e.resume()}}handleChunk(e,t){var{data:n}=e;if(!this.types){if(n==null||n.length===0){t.abort(),this.onError("Error parsing CSV: no data in file.");return}this.types=new Array(n[0].length).fill(Xn),this.readHeaders&&(n=n.slice(1))}this.rowCount+=n.length,N(this.types);var r=[...this.types];n.forEach(o=>{if(o.length>=r.length){for(var d=0;d<r.length;d+=1)r[d]=he.determineType(this.shouldTrim?o[d].trim():o[d],r[d],this.nullString);this.types=r}else t.abort(),this.onError(`Error parsing CSV: Insufficient data in row.
3
3
  Expected length `.concat(r.length," but found ").concat(o.length,`.
4
- Row = `).concat(o))}),this.chunks+=1;var s=0;this.totalChunks>0?s=Math.round(this.chunks/this.totalChunks*50):s=Math.round(this.zipProgress/2);var a=this.onProgress(s);a&&t.abort()}handleComplete(e){var{types:t,onFileCompleted:n}=this;D(t),(e==null||!e.meta.aborted)&&n(t.map(r=>r===Zn||r===U.LOCAL_TIME?U.STRING:r),this.rowCount)}handleError(e){var{onError:t}=this;t(e)}handleNodeUpdate(e){this.zipProgress=e.percent}}const ya=he;function J(i,e,t){return e=Ta(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ta(i){var e=Pa(i,"string");return typeof e=="symbol"?e:String(e)}function Pa(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Ut=Q.module("CsvParser"),Oa=650;class vt{static generateHeaderRecursive(e){var t="",n=e;return e>=26&&(t=t.concat(vt.generateHeaderRecursive(Math.floor(e/26)-1)),n=e%26),t.concat(String.fromCharCode(65+n))}constructor(e){var{onFileCompleted:t,session:n,file:r,type:s,readHeaders:a=!0,onProgress:o,onError:d,timeZone:h,isZip:u}=e;J(this,"onFileCompleted",void 0),J(this,"session",void 0),J(this,"file",void 0),J(this,"isZip",void 0),J(this,"type",void 0),J(this,"readHeaders",void 0),J(this,"timeZone",void 0),J(this,"onProgress",void 0),J(this,"onError",void 0),J(this,"tables",void 0),J(this,"headers",void 0),J(this,"types",void 0),J(this,"rowCount",void 0),J(this,"rowsProcessed",void 0),J(this,"chunks",void 0),J(this,"totalChunks",void 0),J(this,"isComplete",void 0),J(this,"zipProgress",void 0),J(this,"consolidatedChunks",void 0),J(this,"numConsolidated",void 0),J(this,"isCancelled",void 0),J(this,"config",void 0),this.onFileCompleted=t,this.session=n,this.file=r,this.isZip=u,this.type=s,this.readHeaders=a,this.timeZone=h,this.onProgress=o,this.onError=d,this.tables=[],this.rowCount=0,this.rowsProcessed=0,this.chunks=0,this.totalChunks=u?0:Math.ceil(r.size/Tt.LocalChunkSize),this.isComplete=!1,this.zipProgress=0,this.numConsolidated=0,this.isCancelled=!1,this.handleChunk=this.handleChunk.bind(this),this.handleError=this.handleError.bind(this),this.handleComplete=this.handleComplete.bind(this),this.handleNodeUpdate=this.handleNodeUpdate.bind(this),this.handleCreateTable=this.handleCreateTable.bind(this),this.config={delimiter:s.delimiter,newline:s.newline,escapeChar:s.escapeChar,dynamicTyping:!1,error:this.handleError,skipEmptyLines:s.skipEmptyLines,chunk:this.handleChunk,complete:this.handleComplete,fastMode:!1}}cancel(){this.isCancelled=!0}transpose(e,t){for(var n=t.length,r=new Array(e).fill(null).map(()=>new Array(n)),s=0;s<n;s+=1){var a=t[s];if(a.length<e)throw new Error("Insufficient columns. Expected ".concat(e," but found ").concat(a.length,`
5
- `).concat(a));for(var o=0;o<e;o+=1){var d=this.type.shouldTrim?t[s][o].trim():t[s][o];r[o][s]=this.nullCheck(d)}}return r}nullCheck(e){return e===this.type.nullString?"":e}parse(){var e=(n,r)=>{if(this.types=n,this.rowCount=r,this.file instanceof File||this.file instanceof Blob)Tt.parse(this.file,this.config);else{var s=rr(this.file,this.handleNodeUpdate);Tt.parse(s,this.config),s.resume()}},t=new ya(e,this.file,this.readHeaders,this.config,this.type.nullString,this.onProgress,this.onError,this.totalChunks,this.isZip,this.type.shouldTrim);t.parse()}handleChunk(e,t){var{readHeaders:n,onError:r,handleCreateTable:s,isZip:a,tables:o}=this;if(this.isCancelled){Ut.debug2("CSV parser cancelled."),t.abort(),o.forEach(v=>v.close());return}var{data:d}=e;this.headers||(n?(this.headers=Yi.legalizeColumnNames(d[0]),d=d.slice(1)):this.headers=vt.generateHeaders(d[0].length));var h=[];try{if(h=this.transpose(this.headers.length,d),a)this.consolidateChunks(h,t);else{var u=this.chunks;this.chunks+=1,s(u,h,t)}}catch(v){r(v)}}consolidateChunks(e,t){if(!this.consolidatedChunks)this.consolidatedChunks=e.slice();else for(var n=0;n<e.length;n+=1)this.consolidatedChunks[n]=this.consolidatedChunks[n].concat(e[n]);this.numConsolidated+=1,(this.numConsolidated>=Oa||this.isComplete)&&this.uploadConsolidatedChunks(t)}uploadConsolidatedChunks(e){var t,{handleCreateTable:n}=this,r=this.chunks;this.chunks+=1;var s=(t=this.consolidatedChunks)===null||t===void 0?void 0:t.slice();this.consolidatedChunks=void 0,this.numConsolidated=0,D(s),n(r,s,e)}handleCreateTable(e,t,n){var{session:r,tables:s,onFileCompleted:a,totalChunks:o,types:d,onProgress:h,onError:u}=this;n&&n.pause(),D(this.headers),D(d),this.rowsProcessed+=t[0].length,r.newTable(this.headers,d,t,this.timeZone).then(v=>{if(this.isCancelled){Ut.debug2("CSV parser cancelled."),n&&n.abort(),s.forEach(p=>p.close());return}n&&n.resume(),s[e]=v;var m=0;o>0?m=Math.round(s.length/o*50)+50:m=Math.round(this.rowsProcessed/this.rowCount*50)+50,Ut.debug2("CSV parser progress ".concat(m)),h(m),this.isComplete&&s.length===this.chunks&&(Ut.debug2("CSV parser complete."),a(s))}).catch(v=>{!this.isComplete&&n&&n.abort(),u(v)})}handleComplete(e){(e==null||e.meta.aborted==null)&&(this.isComplete=!0,this.consolidatedChunks&&this.uploadConsolidatedChunks(null))}handleError(e){var{onError:t}=this;t(e)}handleNodeUpdate(e){this.zipProgress=e.percent}}J(vt,"generateHeaders",i=>{for(var e=[],t=0;t<i;t+=1)e.push(vt.generateHeaderRecursive(t));return e});const wa=vt;function Dn(i,e,t){return e=Na(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Na(i){var e=xa(i,"string");return typeof e=="symbol"?e:String(e)}function xa(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class tn{static fromExtension(e){return e.endsWith(".csv")?"DEFAULT_CSV":e.endsWith(".tsv")||e.endsWith(".tab")?"TSV":e.endsWith(".psv")?"PIPE_SV":"AUTODETECT"}}Dn(tn,"DEFAULT_TYPE","DEFAULT_CSV");Dn(tn,"AUTO","AUTODETECT");Dn(tn,"TYPES",Object.freeze({DEFAULT_CSV:{name:"Default csv (trimmed)",delimiter:",",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},TSV:{name:"Tab seperated (tsv)",delimiter:" ",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},APACHE_COMMON_CSV:{name:"Apache Common csv",delimiter:",",newline:`\r
4
+ Row = `).concat(o))}),this.chunks+=1;var s=0;this.totalChunks>0?s=Math.round(this.chunks/this.totalChunks*50):s=Math.round(this.zipProgress/2);var a=this.onProgress(s);a&&t.abort()}handleComplete(e){var{types:t,onFileCompleted:n}=this;N(t),(e==null||!e.meta.aborted)&&n(t.map(r=>r===Xn||r===U.LOCAL_TIME?U.STRING:r),this.rowCount)}handleError(e){var{onError:t}=this;t(e)}handleNodeUpdate(e){this.zipProgress=e.percent}}const Ta=he;function J(i,e,t){return e=Pa(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Pa(i){var e=Oa(i,"string");return typeof e=="symbol"?e:String(e)}function Oa(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Ut=Q.module("CsvParser"),wa=650;class vt{static generateHeaderRecursive(e){var t="",n=e;return e>=26&&(t=t.concat(vt.generateHeaderRecursive(Math.floor(e/26)-1)),n=e%26),t.concat(String.fromCharCode(65+n))}constructor(e){var{onFileCompleted:t,session:n,file:r,type:s,readHeaders:a=!0,onProgress:o,onError:d,timeZone:h,isZip:u}=e;J(this,"onFileCompleted",void 0),J(this,"session",void 0),J(this,"file",void 0),J(this,"isZip",void 0),J(this,"type",void 0),J(this,"readHeaders",void 0),J(this,"timeZone",void 0),J(this,"onProgress",void 0),J(this,"onError",void 0),J(this,"tables",void 0),J(this,"headers",void 0),J(this,"types",void 0),J(this,"rowCount",void 0),J(this,"rowsProcessed",void 0),J(this,"chunks",void 0),J(this,"totalChunks",void 0),J(this,"isComplete",void 0),J(this,"zipProgress",void 0),J(this,"consolidatedChunks",void 0),J(this,"numConsolidated",void 0),J(this,"isCancelled",void 0),J(this,"config",void 0),this.onFileCompleted=t,this.session=n,this.file=r,this.isZip=u,this.type=s,this.readHeaders=a,this.timeZone=h,this.onProgress=o,this.onError=d,this.tables=[],this.rowCount=0,this.rowsProcessed=0,this.chunks=0,this.totalChunks=u?0:Math.ceil(r.size/Tt.LocalChunkSize),this.isComplete=!1,this.zipProgress=0,this.numConsolidated=0,this.isCancelled=!1,this.handleChunk=this.handleChunk.bind(this),this.handleError=this.handleError.bind(this),this.handleComplete=this.handleComplete.bind(this),this.handleNodeUpdate=this.handleNodeUpdate.bind(this),this.handleCreateTable=this.handleCreateTable.bind(this),this.config={delimiter:s.delimiter,newline:s.newline,escapeChar:s.escapeChar,dynamicTyping:!1,error:this.handleError,skipEmptyLines:s.skipEmptyLines,chunk:this.handleChunk,complete:this.handleComplete,fastMode:!1}}cancel(){this.isCancelled=!0}transpose(e,t){for(var n=t.length,r=new Array(e).fill(null).map(()=>new Array(n)),s=0;s<n;s+=1){var a=t[s];if(a.length<e)throw new Error("Insufficient columns. Expected ".concat(e," but found ").concat(a.length,`
5
+ `).concat(a));for(var o=0;o<e;o+=1){var d=this.type.shouldTrim?t[s][o].trim():t[s][o];r[o][s]=this.nullCheck(d)}}return r}nullCheck(e){return e===this.type.nullString?"":e}parse(){var e=(n,r)=>{if(this.types=n,this.rowCount=r,this.file instanceof File||this.file instanceof Blob)Tt.parse(this.file,this.config);else{var s=rr(this.file,this.handleNodeUpdate);Tt.parse(s,this.config),s.resume()}},t=new Ta(e,this.file,this.readHeaders,this.config,this.type.nullString,this.onProgress,this.onError,this.totalChunks,this.isZip,this.type.shouldTrim);t.parse()}handleChunk(e,t){var{readHeaders:n,onError:r,handleCreateTable:s,isZip:a,tables:o}=this;if(this.isCancelled){Ut.debug2("CSV parser cancelled."),t.abort(),o.forEach(v=>v.close());return}var{data:d}=e;this.headers||(n?(this.headers=Yi.legalizeColumnNames(d[0]),d=d.slice(1)):this.headers=vt.generateHeaders(d[0].length));var h=[];try{if(h=this.transpose(this.headers.length,d),a)this.consolidateChunks(h,t);else{var u=this.chunks;this.chunks+=1,s(u,h,t)}}catch(v){r(v)}}consolidateChunks(e,t){if(!this.consolidatedChunks)this.consolidatedChunks=e.slice();else for(var n=0;n<e.length;n+=1)this.consolidatedChunks[n]=this.consolidatedChunks[n].concat(e[n]);this.numConsolidated+=1,(this.numConsolidated>=wa||this.isComplete)&&this.uploadConsolidatedChunks(t)}uploadConsolidatedChunks(e){var t,{handleCreateTable:n}=this,r=this.chunks;this.chunks+=1;var s=(t=this.consolidatedChunks)===null||t===void 0?void 0:t.slice();this.consolidatedChunks=void 0,this.numConsolidated=0,N(s),n(r,s,e)}handleCreateTable(e,t,n){var{session:r,tables:s,onFileCompleted:a,totalChunks:o,types:d,onProgress:h,onError:u}=this;n&&n.pause(),N(this.headers),N(d),this.rowsProcessed+=t[0].length,r.newTable(this.headers,d,t,this.timeZone).then(v=>{if(this.isCancelled){Ut.debug2("CSV parser cancelled."),n&&n.abort(),s.forEach(p=>p.close());return}n&&n.resume(),s[e]=v;var m=0;o>0?m=Math.round(s.length/o*50)+50:m=Math.round(this.rowsProcessed/this.rowCount*50)+50,Ut.debug2("CSV parser progress ".concat(m)),h(m),this.isComplete&&s.length===this.chunks&&(Ut.debug2("CSV parser complete."),a(s))}).catch(v=>{!this.isComplete&&n&&n.abort(),u(v)})}handleComplete(e){(e==null||e.meta.aborted==null)&&(this.isComplete=!0,this.consolidatedChunks&&this.uploadConsolidatedChunks(null))}handleError(e){var{onError:t}=this;t(e)}handleNodeUpdate(e){this.zipProgress=e.percent}}J(vt,"generateHeaders",i=>{for(var e=[],t=0;t<i;t+=1)e.push(vt.generateHeaderRecursive(t));return e});const Na=vt;function Ln(i,e,t){return e=xa(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function xa(i){var e=Da(i,"string");return typeof e=="symbol"?e:String(e)}function Da(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class nn{static fromExtension(e){return e.endsWith(".csv")?"DEFAULT_CSV":e.endsWith(".tsv")||e.endsWith(".tab")?"TSV":e.endsWith(".psv")?"PIPE_SV":"AUTODETECT"}}Ln(nn,"DEFAULT_TYPE","DEFAULT_CSV");Ln(nn,"AUTO","AUTODETECT");Ln(nn,"TYPES",Object.freeze({DEFAULT_CSV:{name:"Default csv (trimmed)",delimiter:",",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},TSV:{name:"Tab seperated (tsv)",delimiter:" ",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},APACHE_COMMON_CSV:{name:"Apache Common csv",delimiter:",",newline:`\r
6
6
  `,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:null},EXCEL_CSV:{name:"Excel csv (strict)",delimiter:",",newline:`\r
7
7
  `,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!1,nullString:null},MY_SQL_CSV:{name:"MySQL csv",delimiter:" ",newline:`
8
8
  `,escapeChar:"\\",shouldTrim:!0,skipEmptyLines:!1,nullString:"\\N"},RFC4180_CSV:{name:"RFC4180 csv",delimiter:",",newline:`\r
9
- `,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!1,nullString:null},COLON_SV:{name:": colon sv",delimiter:":",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},SEMI_COLON_SV:{name:"; semi-colon sv",delimiter:";",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},PIPE_SV:{name:"| pipe separated (psv)",delimiter:"|",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},SPACE_SV:{name:'" " space sv',delimiter:" ",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},AUTODETECT:{name:"autodetect",delimiter:void 0,newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"}}));const St=tn;function sr(i,e,t){return e=Da(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Da(i){var e=La(i,"string");return typeof e=="symbol"?e:String(e)}function La(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Jn=Q.module("CsvInputBar"),Ra=Object.entries(St.TYPES).map(i=>{var[e,t]=i;return l.jsx("option",{value:e,children:t.name},e)});class ar extends c.Component{constructor(e){super(e),sr(this,"inputRef",void 0),this.handleUpload=this.handleUpload.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleError=this.handleError.bind(this),this.handleTableName=this.handleTableName.bind(this),this.toggleFirstRowHeaders=this.toggleFirstRowHeaders.bind(this),this.handleProgress=this.handleProgress.bind(this),this.handleCancelInProgress=this.handleCancelInProgress.bind(this),this.handleQueryTypeChange=this.handleQueryTypeChange.bind(this),this.inputRef=se.createRef(),this.state={tableName:"",tableNameSet:!1,isFirstRowHeaders:!0,showProgress:!1,progressValue:0,type:St.DEFAULT_TYPE,parser:null}}componentDidUpdate(e){var{file:t,paste:n}=this.props,{tableName:r,tableNameSet:s}=this.state;if(!s&&t!=null&&!r){var a,o=t.name.lastIndexOf("."),d=Yi.legalizeTableName(t.name.substring(0,o));this.setState({tableName:d,tableNameSet:!0}),(a=this.inputRef.current)===null||a===void 0||a.focus()}else(t==null&&e.file!=null||n==null&&e.paste!=null)&&this.setState({tableName:"",tableNameSet:!1});n!=null&&n!==""&&!r&&this.inputRef.current&&this.inputRef.current.focus(),t!=null&&t!==e.file?this.setState({type:St.fromExtension(t.name)}):n!=null&&n!==""&&(e.paste===void 0||e.paste==="")&&this.setState({type:St.AUTO})}componentWillUnmount(){var{parser:e}=this.state;e&&e.cancel()}handleCancel(){var{onClose:e}=this.props;e()}handleError(e){var{onClose:t,onError:n}=this.props;Jn.error(e),n(e),t()}handleTableName(e){this.setState({tableName:e.target.value,tableNameSet:!0})}toggleFirstRowHeaders(){var{isFirstRowHeaders:e}=this.state;this.setState({isFirstRowHeaders:!e})}handleUpload(e){e.stopPropagation(),e.preventDefault();var{file:t,paste:n}=this.props;t!=null?t.name.endsWith(".zip")?this.handleZipFile(t):this.handleFile(t):n!==void 0&&n!==""&&this.handleFile(new Blob([n],{type:"text/plain"}))}handleFile(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;Jn.info("Starting CSV parser for ".concat(e instanceof File?e.name:"pasted values"," ").concat(t?"":e.size," bytes"));var{session:n,timeZone:r,onInProgress:s}=this.props,{tableName:a,isFirstRowHeaders:o,type:d}=this.state,h=v=>{v.length===1?n.bindTableToVariable(v[0],a).then(()=>this.openTable()).catch(m=>this.handleError(m)):n.mergeTables(v).then(m=>{n.bindTableToVariable(m,a).then(()=>this.openTable()).catch(p=>this.handleError(p)),v.forEach(p=>p.close())}).catch(m=>this.handleError(m))},u=new wa({onFileCompleted:h,session:n,file:e,type:St.TYPES[d],readHeaders:o,onProgress:this.handleProgress,onError:this.handleError,timeZone:r,isZip:t});u.parse(),this.setState({showProgress:!0,parser:u}),s(!0)}handleZipFile(e){var{onUpdate:t,unzip:n}=this.props;if(n==null){this.handleError(new Error("No support for zip files available."));return}n(e).then(r=>{for(var s=!1,a=0;a<r.length;a+=1){var o=r[a];if(ut.isValidExtension(o.name)){t("Loading ".concat(o.name," as csv from ").concat(e.name)),s=!0,this.handleFile(o,!0);break}}if(!s)throw new Error("No csv file found in ".concat(e.name))}).catch(r=>this.handleError(r))}handleProgress(e){var{showProgress:t}=this.state;return t&&this.setState({progressValue:e}),!t}handleCancelInProgress(){var{onInProgress:e}=this.props,{parser:t}=this.state;t&&t.cancel(),this.setState({showProgress:!1,progressValue:0}),e(!1)}openTable(){var{onOpenTable:e,onClose:t}=this.props,{tableName:n}=this.state;e(n),t()}handleQueryTypeChange(e){this.setState({type:e})}render(){var{file:e,paste:t}=this.props,{tableName:n,isFirstRowHeaders:r,showProgress:s,progressValue:a,type:o}=this.state,d=!!t&&!n;return l.jsxs("div",{className:"csv-input-bar",children:[!s&&l.jsxs("form",{onSubmit:this.handleUpload,className:"csv-input-bar-container form-inline",children:[l.jsxs("div",{className:"form-group",children:[l.jsx("label",{htmlFor:"tableNameInput",children:"Table name"}),l.jsx("input",{ref:this.inputRef,id:"tableNameInput",type:"text",className:ee("form-control",{"is-invalid":d}),value:n,onChange:this.handleTableName})]}),l.jsxs("div",{className:"form-group",children:[l.jsx("label",{htmlFor:"formatSelect",children:"File format"}),l.jsx(vs,{id:"formatSelect",className:"custom-select",value:o,onChange:this.handleQueryTypeChange,children:Ra})]}),l.jsx(ms,{className:"firstRowHeaders",checked:r,onChange:this.toggleFirstRowHeaders,children:"First row is column headers"}),l.jsxs("div",{className:"csv-input-buttons form-group",children:[l.jsx(K,{kind:"secondary",onClick:this.handleCancel,children:"Cancel"}),l.jsx(K,{kind:"primary",type:"submit",disabled:!(e!==null||t!==void 0&&t!=="")||!n,children:"Upload"})]})]}),s&&l.jsxs("div",{className:"csv-progress-container",children:[l.jsx("label",{children:"Uploading Table"}),l.jsx("div",{className:"progress",children:l.jsx("div",{className:"progress-bar bg-primary",style:{width:"".concat(a,"%")},"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100})}),l.jsxs("label",{children:[a,"%"]}),l.jsx(K,{kind:"primary",onClick:this.handleCancelInProgress,children:"Cancel"})]})]})}}sr(ar,"defaultProps",{file:null,paste:null,unzip:null});const Ia=ar;function $t(i,e,t){return e=Ma(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ma(i){var e=Fa(i,"string");return typeof e=="symbol"?e:String(e)}function Fa(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var ei=Q.module("ConsoleMenu");class Qt extends c.PureComponent{static makeItemActions(e,t,n,r,s){if(e.length===0)return[];var a={menuElement:l.jsx(qi,{value:t,onChange:r,className:"console-menu",ref:n})},o=e;t&&(o=o.filter(h=>{var{title:u}=h;return u!=null&&u.toLowerCase().indexOf(t.toLowerCase())>=0}));var d=o.map(h=>({title:h.title,action:()=>{s(h)}}));return[a,...d]}constructor(e){super(e),$t(this,"tableSearchField",void 0),$t(this,"widgetSearchField",void 0),$t(this,"makeTableActions",_e((t,n,r)=>{var{dh:s}=this.props,a=t.filter(o=>bn.isTableType(s,o.type));return Qt.makeItemActions(a,n,o=>{this.tableSearchField=o},this.handleTableFilterChange,r)})),$t(this,"makeWidgetActions",_e((t,n,r)=>{var{dh:s}=this.props,a=t.filter(o=>bn.isWidgetType(s,o.type));return Qt.makeItemActions(a,n,o=>{this.widgetSearchField=o},this.handleWidgetFilterChange,r)})),this.handleTableFilterChange=this.handleTableFilterChange.bind(this),this.handleTableMenuClosed=this.handleTableMenuClosed.bind(this),this.handleTableMenuOpened=this.handleTableMenuOpened.bind(this),this.handleWidgetFilterChange=this.handleWidgetFilterChange.bind(this),this.handleWidgetMenuClosed=this.handleWidgetMenuClosed.bind(this),this.handleWidgetMenuOpened=this.handleWidgetMenuOpened.bind(this),this.state={tableFilterText:"",widgetFilterText:""}}handleTableFilterChange(e){ei.debug("filtering tables..."),this.setState({tableFilterText:e.target.value})}handleTableMenuClosed(){this.setState({tableFilterText:""})}handleTableMenuOpened(){var e;(e=this.tableSearchField)===null||e===void 0||e.focus()}handleWidgetFilterChange(e){ei.debug("filtering widgets..."),this.setState({widgetFilterText:e.target.value})}handleWidgetMenuClosed(){this.setState({widgetFilterText:""})}handleWidgetMenuOpened(){var e;(e=this.widgetSearchField)===null||e===void 0||e.focus()}render(){var{overflowActions:e,objects:t,openObject:n}=this.props,{tableFilterText:r,widgetFilterText:s}=this.state,a=this.makeTableActions(t,r,n),o=this.makeWidgetActions(t,s,n),d={placement:"bottom-end"},h=a.length===0,u=o.length===0;return l.jsxs(l.Fragment,{children:[l.jsx(K,{kind:"ghost",disabled:h,onClick:()=>{},icon:l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(re,{mask:$i,icon:Ct,transform:"right-5 down-5"}),l.jsx(re,{icon:Ct,transform:"right-8 down-6"})]}),tooltip:h?"No tables available":"Tables",children:l.jsx(Ot,{actions:a,onMenuOpened:this.handleTableMenuOpened,onMenuClosed:this.handleTableMenuClosed,options:{initialKeyboardIndex:1},popperOptions:d},"table-actions ")}),l.jsx(K,{kind:"ghost",disabled:o.length===0,onClick:()=>{},icon:l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(re,{mask:Ui,icon:Ct,transform:"right-5 down-5"}),l.jsx(re,{icon:Ct,transform:"right-8 down-6"})]}),tooltip:u?"No widgets available":"Widgets",children:l.jsx(Ot,{actions:o,onMenuOpened:this.handleWidgetMenuOpened,onMenuClosed:this.handleWidgetMenuClosed,options:{initialKeyboardIndex:1},popperOptions:d},"table-actions")}),l.jsx(K,{kind:"ghost",icon:Ki,tooltip:"More Actions...","aria-label":"More Actions...",onClick:()=>{},children:l.jsx(Ot,{actions:e,popperOptions:d})})]})}}const Aa=Qt;function or(i,e,t){return e=ja(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ja(i){var e=_a(i,"string");return typeof e=="symbol"?e:String(e)}function _a(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class lr extends c.PureComponent{constructor(e){super(e),or(this,"pending",void 0),this.handleCommandStarted=this.handleCommandStarted.bind(this),this.handleCommandCompleted=this.handleCommandCompleted.bind(this),this.pending=new pt,this.state={isDisconnected:!1,isCommandRunning:!1}}componentDidMount(){this.startListening()}componentWillUnmount(){this.stopListening(),this.cancelPendingPromises()}startListening(){var{dh:e,session:t}=this.props;t.addEventListener(e.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}stopListening(){var{dh:e,session:t}=this.props;t.removeEventListener(e.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}cancelPendingPromises(){this.pending.cancel()}handleCommandStarted(e){var{result:t}=e.detail;this.pending.add(t).then(()=>this.handleCommandCompleted(null)).catch(n=>this.handleCommandCompleted(n)),this.setState({isCommandRunning:!0})}handleCommandCompleted(e){e instanceof ps||this.setState({isCommandRunning:this.pending.pending.length>0})}render(){var{children:e,dh:t,openObject:n,overflowActions:r,objects:s}=this.props,{isDisconnected:a,isCommandRunning:o}=this.state,d=null,h=null;return a?(d="console-status-icon-disconnected",h="Worker is disconnected"):o?(d="console-status-icon-pending",h="Worker is busy"):(d="console-status-icon-idle",h="Worker is idle"),l.jsxs("div",{className:"console-pane-status-bar",children:[l.jsxs("div",{children:[l.jsx("div",{className:ee("console-status-icon",d)}),l.jsx(ot,{children:h})]}),e,l.jsx(Aa,{dh:t,overflowActions:r,openObject:n,objects:s})]})}}or(lr,"defaultProps",{children:null});const ka=lr;function ti(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Ne(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ti(Object(t),!0).forEach(function(n){Pe(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ti(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Pe(i,e,t){return e=Ha(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ha(i){var e=Ua(i,"string");return typeof e=="symbol"?e:String(e)}function Ua(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Re=Q.module("Console"),ni={isAutoLaunchPanelsEnabled:!0,isPrintStdOutEnabled:!0,isClosePanelsOnDisconnectEnabled:!0};function $a(){return!0}function Ba(i){return l.jsx(l.Fragment,{})}class Xe extends c.PureComponent{static isErrorLevel(e){return e===de.STDERR||e===de.ERROR||e===de.FATAL}static isOutputLevel(e){return e===de.STDOUT||Xe.isErrorLevel(e)}constructor(e){super(e),Pe(this,"cancelListener",void 0),Pe(this,"consolePane",void 0),Pe(this,"consoleInput",void 0),Pe(this,"consoleHistoryScrollPane",void 0),Pe(this,"pending",void 0),Pe(this,"queuedLogMessages",void 0),Pe(this,"processLogMessageQueue",_i(()=>{this.scrollConsoleHistoryToBottom(),this.setState(r=>{Re.debug2("processLogMessageQueue",this.queuedLogMessages.length," items");var{consoleHistory:s}=r;return s=s.concat(this.queuedLogMessages),this.queuedLogMessages=[],{consoleHistory:s}})},Xe.LOG_THROTTLE)),Pe(this,"getObjects",_e(r=>[...r.values()])),Pe(this,"getContextActions",_e(r=>[...r,{action:this.handleClearShortcut,shortcut:be.CONSOLE.CLEAR},{action:this.handleFocusHistory,shortcut:be.CONSOLE.FOCUS_HISTORY}])),this.handleCommandResult=this.handleCommandResult.bind(this),this.handleCommandStarted=this.handleCommandStarted.bind(this),this.handleCommandSubmit=this.handleCommandSubmit.bind(this),this.handleClearShortcut=this.handleClearShortcut.bind(this),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleLogMessage=this.handleLogMessage.bind(this),this.handleOverflowActions=this.handleOverflowActions.bind(this),this.handleScrollPaneScroll=this.handleScrollPaneScroll.bind(this),this.handleToggleAutoLaunchPanels=this.handleToggleAutoLaunchPanels.bind(this),this.handleToggleClosePanelsOnDisconnect=this.handleToggleClosePanelsOnDisconnect.bind(this),this.handleTogglePrintStdout=this.handleTogglePrintStdout.bind(this),this.handleUploadCsv=this.handleUploadCsv.bind(this),this.handleHideCsv=this.handleHideCsv.bind(this),this.handleCsvFileCanceled=this.handleCsvFileCanceled.bind(this),this.handleCsvFileOpened=this.handleCsvFileOpened.bind(this),this.handleCsvPaste=this.handleCsvPaste.bind(this),this.handleDragEnter=this.handleDragEnter.bind(this),this.handleDragLeave=this.handleDragLeave.bind(this),this.handleClearDragError=this.handleClearDragError.bind(this),this.handleOpenCsvTable=this.handleOpenCsvTable.bind(this),this.handleCsvUpdate=this.handleCsvUpdate.bind(this),this.handleCsvError=this.handleCsvError.bind(this),this.handleCsvInProgress=this.handleCsvInProgress.bind(this),this.consolePane=se.createRef(),this.consoleInput=se.createRef(),this.consoleHistoryScrollPane=se.createRef(),this.pending=new pt,this.queuedLogMessages=[];var{objectMap:t,settings:n}=this.props;this.state=Ne(Ne({consoleHistory:[],consoleHeight:0,isScrollDecorationShown:!1,objectHistoryMap:new Map,objectMap:new Map(t),showCsvOverlay:!1,csvFile:null,csvPaste:null,dragError:null,csvUploadInProgress:!1},ni),n)}componentDidMount(){this.initConsoleLogging();var{dh:e,session:t}=this.props;t.addEventListener(e.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.updateDimensions()}componentDidUpdate(e,t){var{props:n,state:r}=this;this.sendSettingsChange(t,r),n.objectMap!==e.objectMap&&this.updateObjectMap()}componentWillUnmount(){var{dh:e,session:t}=this.props;t.removeEventListener(e.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.pending.cancel(),this.processLogMessageQueue.cancel(),this.deinitConsoleLogging()}initConsoleLogging(){var{session:e}=this.props;this.cancelListener=e.onLogMessage(this.handleLogMessage)}deinitConsoleLogging(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}handleClearShortcut(e){var t;e.preventDefault(),e.stopPropagation(),(t=this.consoleInput.current)===null||t===void 0||t.clear()}handleCommandStarted(e){var{code:t,result:n}=e.detail,r=this.pending.add(n),s={command:t,disabledObjects:[],startTime:Date.now(),cancelResult:()=>{n.cancel()},wrappedResult:r},{commandHistoryStorage:a,language:o,scope:d}=this.props,h=a.addItem(o,d,t,{command:t,startTime:new Date().toJSON()});h.catch(u=>{Re.debug("Error adding workspace item",u)}),this.setState(u=>({consoleHistory:u.consoleHistory.concat(s)}),()=>{this.scrollConsoleHistoryToBottom(!0)}),r.then(u=>{this.handleCommandResult(u,s,h)}).catch(u=>{this.handleCommandError(u,s,h)})}handleCommandResult(e,t,n){var r=Ne(Ne({},t),{},{wrappedResult:void 0,cancelResult:void 0,result:e??t.result});this.setState(s=>{var{consoleHistory:a}=s,o=a.lastIndexOf(t);if(o<0)return Re.error("historyItem not found in consoleHistory"),null;var d=a.concat();return d[o]=r,{consoleHistory:d}}),e&&(this.updateHistory(e,r),this.updateKnownObjects(r),this.updateWorkspaceHistoryItem({error:e.error},n),this.closeRemovedItems(e.changes),this.openUpdatedItems(e.changes))}handleCommandError(e,t,n){if(ce.isCanceled(e)){Re.debug("Called handleCommandError on a cancelled promise result");return}this.updateWorkspaceHistoryItem({error:"".concat(e)},n),this.setState(r=>{var s=r.consoleHistory.concat(),a=s.lastIndexOf(t),o=Ne({},t);return o.wrappedResult=void 0,o.cancelResult=void 0,o.endTime=Date.now(),o.result={error:e},s[a]=o,{consoleHistory:s}})}handleFocusHistory(e){e.preventDefault(),e.stopPropagation();var{focusCommandHistory:t}=this.props;t()}handleLogMessage(e){var{isPrintStdOutEnabled:t}=this.state;t&&Xe.isOutputLevel(e.logLevel)&&this.queueLogMessage(e.message,e.logLevel)}queueLogMessage(e,t){var n={};Xe.isErrorLevel(t)?n.error=e:n.message=e;var r={command:void 0,result:n};this.queuedLogMessages.push(r),this.processLogMessageQueue()}openUpdatedItems(e){Re.debug("openUpdatedItems",e);var{isAutoLaunchPanelsEnabled:t}=this.state;if(e!=null){var{openObject:n}=this.props;[...e.created,...e.updated].forEach(r=>n(r,t&&(r.title===void 0||!r.title.startsWith("_"))))}}closeRemovedItems(e){if(!(e==null||e.removed==null||e.removed.length===0)){var{closeObject:t}=this.props,{removed:n}=e;n.forEach(r=>t(r))}}updateHistory(e,t){var n=t;e==null||e.changes==null||n==null||(n.endTime=Date.now(),this.scrollConsoleHistoryToBottom(),this.setState(r=>{var s=r.consoleHistory.concat();return{consoleHistory:s}}))}updateKnownObjects(e){var t;if(e.result&&(t=e.result.changes),!t||(t.created==null||t.created.length===0)&&(t.updated==null||t.updated.length===0)&&(t.removed==null||t.removed.length===0)){Re.debug2("updateKnownObjects no changes");return}this.setState(n=>{var r,s,a,{consoleHistory:o}=n,d=o.lastIndexOf(e);if(d<0)return Re.error("historyItem not found in state.consoleHistory"),null;var h=new Map(n.objectHistoryMap),u=new Map(n.objectMap),v=function(p){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,{title:S}=p;D(S);var g=h.get(S);if(g!=null&&g>=0){var y;o===n.consoleHistory&&(o=o.concat());var P=Ne(Ne({},o[g]),{},{disabledObjects:[...(y=o[g].disabledObjects)!==null&&y!==void 0?y:[],S]});o[g]=P}h.set(S,d),E?u.delete(S):u.set(S,p)};return(r=t)===null||r===void 0||r.updated.forEach(m=>v(m)),(s=t)===null||s===void 0||s.removed.forEach(m=>v(m,!0)),(a=t)===null||a===void 0||a.created.forEach(m=>{var{title:p}=m;D(p),h.set(p,d),u.set(p,m)}),{objectHistoryMap:h,objectMap:u,consoleHistory:o}})}updateObjectMap(){var{objectMap:e}=this.props;this.setState({objectMap:e})}updateWorkspaceHistoryItem(e,t){var n=this.pending.add(t),r=new Date().toJSON();n.then(s=>{var a=Ne(Ne({},s),{},{data:Ne(Ne({},s.data),{},{endTime:r,result:e})}),{commandHistoryStorage:o,language:d}=this.props;o.updateItem(d,a).catch(h=>{Re.warn("Error updating command history storage",h)})}).catch(s=>{Re.debug("Error updating workspace history item",s)})}scrollConsoleHistoryToBottom(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=this.consoleHistoryScrollPane.current;D(t),!(!e&&Math.abs(t.scrollHeight-t.clientHeight-t.scrollTop)>=1)&&window.requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}handleScrollPaneScroll(){var e=this.consoleHistoryScrollPane.current;D(e),e.scrollTop>0&&e.scrollHeight>e.clientHeight?this.setState({isScrollDecorationShown:!0}):this.setState({isScrollDecorationShown:!1})}handleToggleAutoLaunchPanels(){this.setState(e=>({isAutoLaunchPanelsEnabled:!e.isAutoLaunchPanelsEnabled}))}handleToggleClosePanelsOnDisconnect(){this.setState(e=>({isClosePanelsOnDisconnectEnabled:!e.isClosePanelsOnDisconnectEnabled}))}handleTogglePrintStdout(){this.setState(e=>({isPrintStdOutEnabled:!e.isPrintStdOutEnabled}))}handleUploadCsv(){this.setState({showCsvOverlay:!0,dragError:null,csvUploadInProgress:!1})}handleHideCsv(){this.setState({showCsvOverlay:!1,csvFile:null,csvPaste:null,dragError:null,csvUploadInProgress:!1})}handleCsvFileCanceled(){this.setState({csvFile:null,csvPaste:null})}handleCsvFileOpened(e){this.setState({csvFile:e,csvPaste:null})}handleCsvPaste(e){this.setState({csvFile:null,csvPaste:e})}handleDragEnter(e){if(!(e.dataTransfer==null||e.dataTransfer.items==null||e.dataTransfer.items.length===0||e.dataTransfer.items[0].kind==="string")){e.preventDefault(),e.stopPropagation(),this.setState({showCsvOverlay:!0});var{items:t}=e.dataTransfer;if(t.length>1){this.setState({dragError:ut.MULTIPLE_FILE_ERROR});return}var n=t[0];ut.isValidDropItem(n)?this.setState({dragError:null}):this.setState({dragError:ut.FILE_TYPE_ERROR})}}handleDragLeave(e){e.currentTarget==null||e.currentTarget instanceof Element&&e.relatedTarget instanceof Element&&e.currentTarget.contains(e.relatedTarget)||(e.preventDefault(),e.stopPropagation(),this.setState({showCsvOverlay:!1,dragError:null}))}handleClearDragError(){this.setState({dragError:null})}handleOpenCsvTable(e){var{dh:t,openObject:n,commandHistoryStorage:r,language:s,scope:a}=this.props,{consoleHistory:o,objectMap:d}=this.state,h={name:e,title:e,type:t.VariableType.TABLE},u=d.has(e),v={startTime:Date.now(),endTime:Date.now(),disabledObjects:[],result:{changes:{created:[],updated:[],removed:[],[u?"updated":"created"]:[h]}}},m=o.concat(v);this.setState({consoleHistory:m}),this.scrollConsoleHistoryToBottom(!0),this.updateKnownObjects(v),n({name:e,title:e,type:t.VariableType.TABLE}),r.addItem(s,a,e,{command:e,startTime:new Date().toJSON(),endTime:new Date().toJSON()})}addConsoleHistoryMessage(e,t){var{consoleHistory:n}=this.state,r={startTime:Date.now(),endTime:Date.now(),result:{message:e,error:t}},s=n.concat(r);this.setState({consoleHistory:s})}handleCsvUpdate(e){this.addConsoleHistoryMessage(e)}handleCsvError(e){this.addConsoleHistoryMessage(void 0,e!=null?"".concat(e):void 0)}handleCsvInProgress(e){this.setState({csvUploadInProgress:e})}handleOverflowActions(){var{isAutoLaunchPanelsEnabled:e,isClosePanelsOnDisconnectEnabled:t,isPrintStdOutEnabled:n}=this.state,{actions:r}=this.props;return[...r,{title:"Print Stdout",action:this.handleTogglePrintStdout,group:k.groups.high,icon:n?Pt:void 0,order:10},{title:"Auto Launch Panels",action:this.handleToggleAutoLaunchPanels,group:k.groups.high,icon:e?Pt:void 0,order:20},{title:"Close Panels on Disconnect",action:this.handleToggleClosePanelsOnDisconnect,group:k.groups.high,icon:t?Pt:void 0,order:30},{title:"Upload Table from File",action:this.handleUploadCsv,group:k.groups.high+10,order:40}]}handleCommandSubmit(e){if(e==="clear"||e==="cls")this.clearConsoleHistory();else if(e.length>0){var{session:t}=this.props;t.runCode(e).catch(r=>{Re.error("There was an error initiating the command",r)})}else{var n={command:" ",result:{},startTime:Date.now(),endTime:Date.now()};this.scrollConsoleHistoryToBottom(!0),this.setState(r=>({consoleHistory:r.consoleHistory.concat(n)}))}}clearConsoleHistory(){this.pending.cancel(),this.setState(e=>{var t=new Map([...e.objectHistoryMap.keys()].map(n=>[n,-1]));return{consoleHistory:[],objectHistoryMap:t}})}addCommand(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;this.consoleInput.current&&(this.consoleInput.current.setConsoleText(e,t,n),t&&this.scrollConsoleHistoryToBottom(!0))}focus(){var e;(e=this.consoleInput.current)===null||e===void 0||e.focus()}sendSettingsChange(e,t){for(var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=Object.keys(ni),s={},a=!1,o=0;o<r.length;o+=1){var d=r[o],{[d]:h}=t,{[d]:u}=e;h!==u&&(a=!0),s[d]=h}if(!(n&&!a)){var{onSettingsChange:v}=this.props;v(s)}}updateDimensions(){this.consolePane.current&&this.setState({consoleHeight:this.consolePane.current.clientHeight}),this.consoleInput.current&&this.consoleInput.current.updateDimensions()}render(){var{actions:e,dh:t,historyChildren:n,language:r,statusBarChildren:s,openObject:a,session:o,scope:d,commandHistoryStorage:h,timeZone:u,disabled:v,unzip:m,supportsType:p,iconForType:E}=this.props,{consoleHeight:S,consoleHistory:g,isScrollDecorationShown:y,objectMap:P,showCsvOverlay:O,csvFile:L,csvPaste:V,dragError:Z,csvUploadInProgress:A}=this.state,G=this.getObjects(P),z=Math.round(S*.7),X=this.getContextActions(e);return l.jsxs("div",{role:"presentation",className:ee("iris-console","h-100","w-100",{disabled:v}),children:[l.jsxs("div",{className:"console-pane",ref:this.consolePane,children:[l.jsx(ka,{dh:t,session:o,overflowActions:this.handleOverflowActions,openObject:a,objects:G,children:s}),l.jsxs("div",{className:"console-csv-container",onDragOver:ut.handleDragOver,onDragEnter:this.handleDragEnter,onDragLeave:this.handleDragLeave,children:[O&&l.jsx(ut,{onCancel:this.handleCsvFileCanceled,onFileOpened:this.handleCsvFileOpened,onPaste:this.handleCsvPaste,clearDragError:this.handleClearDragError,dragError:Z,onError:this.handleCsvError,uploadInProgress:A,allowZip:m!=null}),l.jsxs("div",{role:"presentation",className:ee("scroll-pane no-scroll-x",{"scroll-decoration":y}),onScroll:this.handleScrollPaneScroll,ref:this.consoleHistoryScrollPane,children:[l.jsx(na,{items:g,openObject:a,language:r,disabled:v,supportsType:p,iconForType:E}),n]})]}),!O&&l.jsx(Kn,{ref:this.consoleInput,session:o,language:r,scope:d,onSubmit:this.handleCommandSubmit,maxHeight:z,commandHistoryStorage:h}),O&&l.jsx(Ia,{session:o,onOpenTable:this.handleOpenCsvTable,onClose:this.handleHideCsv,onUpdate:this.handleCsvUpdate,onError:this.handleCsvError,file:L??void 0,paste:V??void 0,onInProgress:this.handleCsvInProgress,timeZone:u,unzip:m})]}),l.jsx(k,{actions:X,ignoreClassNames:[Kn.INPUT_CLASS_NAME]})]})}}Pe(Xe,"defaultProps",{statusBarChildren:null,settings:{},onSettingsChange:()=>{},scope:null,actions:[],historyChildren:null,timeZone:"America/New_York",objectMap:new Map,disabled:!1,unzip:null,supportsType:$a,iconForType:Ba});Pe(Xe,"LOG_THROTTLE",500);const Va=Xe;var Wa={groovy:"Groovy",python:"Python",scala:"Scala"};class Ka{static normalizeScriptLanguage(e){return Wa[e]||null}static getDisabledRunTooltip(e,t,n,r){return e?t?null:"".concat(n," doesn't match the session language – ").concat(r," disabled"):"Console session not connected – ".concat(r," disabled")}static outdentCode(e){var t=e.split(`
9
+ `,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!1,nullString:null},COLON_SV:{name:": colon sv",delimiter:":",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},SEMI_COLON_SV:{name:"; semi-colon sv",delimiter:";",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},PIPE_SV:{name:"| pipe separated (psv)",delimiter:"|",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},SPACE_SV:{name:'" " space sv',delimiter:" ",newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"},AUTODETECT:{name:"autodetect",delimiter:void 0,newline:void 0,escapeChar:'"',shouldTrim:!0,skipEmptyLines:!0,nullString:"(null)"}}));const St=nn;function sr(i,e,t){return e=La(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function La(i){var e=Ra(i,"string");return typeof e=="symbol"?e:String(e)}function Ra(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var ei=Q.module("CsvInputBar"),Ia=Object.entries(St.TYPES).map(i=>{var[e,t]=i;return l.jsx("option",{value:e,children:t.name},e)});class ar extends c.Component{constructor(e){super(e),sr(this,"inputRef",void 0),this.handleUpload=this.handleUpload.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleError=this.handleError.bind(this),this.handleTableName=this.handleTableName.bind(this),this.toggleFirstRowHeaders=this.toggleFirstRowHeaders.bind(this),this.handleProgress=this.handleProgress.bind(this),this.handleCancelInProgress=this.handleCancelInProgress.bind(this),this.handleQueryTypeChange=this.handleQueryTypeChange.bind(this),this.inputRef=se.createRef(),this.state={tableName:"",tableNameSet:!1,isFirstRowHeaders:!0,showProgress:!1,progressValue:0,type:St.DEFAULT_TYPE,parser:null}}componentDidUpdate(e){var{file:t,paste:n}=this.props,{tableName:r,tableNameSet:s}=this.state;if(!s&&t!=null&&!r){var a,o=t.name.lastIndexOf("."),d=Yi.legalizeTableName(t.name.substring(0,o));this.setState({tableName:d,tableNameSet:!0}),(a=this.inputRef.current)===null||a===void 0||a.focus()}else(t==null&&e.file!=null||n==null&&e.paste!=null)&&this.setState({tableName:"",tableNameSet:!1});n!=null&&n!==""&&!r&&this.inputRef.current&&this.inputRef.current.focus(),t!=null&&t!==e.file?this.setState({type:St.fromExtension(t.name)}):n!=null&&n!==""&&(e.paste===void 0||e.paste==="")&&this.setState({type:St.AUTO})}componentWillUnmount(){var{parser:e}=this.state;e&&e.cancel()}handleCancel(){var{onClose:e}=this.props;e()}handleError(e){var{onClose:t,onError:n}=this.props;ei.error(e),n(e),t()}handleTableName(e){this.setState({tableName:e.target.value,tableNameSet:!0})}toggleFirstRowHeaders(){var{isFirstRowHeaders:e}=this.state;this.setState({isFirstRowHeaders:!e})}handleUpload(e){e.stopPropagation(),e.preventDefault();var{file:t,paste:n}=this.props;t!=null?t.name.endsWith(".zip")?this.handleZipFile(t):this.handleFile(t):n!==void 0&&n!==""&&this.handleFile(new Blob([n],{type:"text/plain"}))}handleFile(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;ei.info("Starting CSV parser for ".concat(e instanceof File?e.name:"pasted values"," ").concat(t?"":e.size," bytes"));var{session:n,timeZone:r,onInProgress:s}=this.props,{tableName:a,isFirstRowHeaders:o,type:d}=this.state,h=v=>{v.length===1?n.bindTableToVariable(v[0],a).then(()=>this.openTable()).catch(m=>this.handleError(m)):n.mergeTables(v).then(m=>{n.bindTableToVariable(m,a).then(()=>this.openTable()).catch(p=>this.handleError(p)),v.forEach(p=>p.close())}).catch(m=>this.handleError(m))},u=new Na({onFileCompleted:h,session:n,file:e,type:St.TYPES[d],readHeaders:o,onProgress:this.handleProgress,onError:this.handleError,timeZone:r,isZip:t});u.parse(),this.setState({showProgress:!0,parser:u}),s(!0)}handleZipFile(e){var{onUpdate:t,unzip:n}=this.props;if(n==null){this.handleError(new Error("No support for zip files available."));return}n(e).then(r=>{for(var s=!1,a=0;a<r.length;a+=1){var o=r[a];if(ut.isValidExtension(o.name)){t("Loading ".concat(o.name," as csv from ").concat(e.name)),s=!0,this.handleFile(o,!0);break}}if(!s)throw new Error("No csv file found in ".concat(e.name))}).catch(r=>this.handleError(r))}handleProgress(e){var{showProgress:t}=this.state;return t&&this.setState({progressValue:e}),!t}handleCancelInProgress(){var{onInProgress:e}=this.props,{parser:t}=this.state;t&&t.cancel(),this.setState({showProgress:!1,progressValue:0}),e(!1)}openTable(){var{onOpenTable:e,onClose:t}=this.props,{tableName:n}=this.state;e(n),t()}handleQueryTypeChange(e){this.setState({type:e})}render(){var{file:e,paste:t}=this.props,{tableName:n,isFirstRowHeaders:r,showProgress:s,progressValue:a,type:o}=this.state,d=!!t&&!n;return l.jsxs("div",{className:"csv-input-bar",children:[!s&&l.jsxs("form",{onSubmit:this.handleUpload,className:"csv-input-bar-container form-inline",children:[l.jsxs("div",{className:"form-group",children:[l.jsx("label",{htmlFor:"tableNameInput",children:"Table name"}),l.jsx("input",{ref:this.inputRef,id:"tableNameInput",type:"text",className:ee("form-control",{"is-invalid":d}),value:n,onChange:this.handleTableName})]}),l.jsxs("div",{className:"form-group",children:[l.jsx("label",{htmlFor:"formatSelect",children:"File format"}),l.jsx(vs,{id:"formatSelect",className:"custom-select",value:o,onChange:this.handleQueryTypeChange,children:Ia})]}),l.jsx(ms,{className:"firstRowHeaders",checked:r,onChange:this.toggleFirstRowHeaders,children:"First row is column headers"}),l.jsxs("div",{className:"csv-input-buttons form-group",children:[l.jsx(K,{kind:"secondary",onClick:this.handleCancel,children:"Cancel"}),l.jsx(K,{kind:"primary",type:"submit",disabled:!(e!==null||t!==void 0&&t!=="")||!n,children:"Upload"})]})]}),s&&l.jsxs("div",{className:"csv-progress-container",children:[l.jsx("label",{children:"Uploading Table"}),l.jsx("div",{className:"progress",children:l.jsx("div",{className:"progress-bar bg-primary",style:{width:"".concat(a,"%")},"aria-valuenow":a,"aria-valuemin":0,"aria-valuemax":100})}),l.jsxs("label",{children:[a,"%"]}),l.jsx(K,{kind:"primary",onClick:this.handleCancelInProgress,children:"Cancel"})]})]})}}sr(ar,"defaultProps",{file:null,paste:null,unzip:null});const Ma=ar;function $t(i,e,t){return e=Fa(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Fa(i){var e=Aa(i,"string");return typeof e=="symbol"?e:String(e)}function Aa(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var ti=Q.module("ConsoleMenu");class Jt extends c.PureComponent{static makeItemActions(e,t,n,r,s){if(e.length===0)return[];var a={menuElement:l.jsx(qi,{value:t,onChange:r,className:"console-menu",ref:n})},o=e;t&&(o=o.filter(h=>{var{title:u}=h;return u!=null&&u.toLowerCase().indexOf(t.toLowerCase())>=0}));var d=o.map(h=>({title:h.title,action:()=>{s(h)}}));return[a,...d]}constructor(e){super(e),$t(this,"tableSearchField",void 0),$t(this,"widgetSearchField",void 0),$t(this,"makeTableActions",_e((t,n,r)=>{var{dh:s}=this.props,a=t.filter(o=>Cn.isTableType(s,o.type));return Jt.makeItemActions(a,n,o=>{this.tableSearchField=o},this.handleTableFilterChange,r)})),$t(this,"makeWidgetActions",_e((t,n,r)=>{var{dh:s}=this.props,a=t.filter(o=>Cn.isWidgetType(s,o.type));return Jt.makeItemActions(a,n,o=>{this.widgetSearchField=o},this.handleWidgetFilterChange,r)})),this.handleTableFilterChange=this.handleTableFilterChange.bind(this),this.handleTableMenuClosed=this.handleTableMenuClosed.bind(this),this.handleTableMenuOpened=this.handleTableMenuOpened.bind(this),this.handleWidgetFilterChange=this.handleWidgetFilterChange.bind(this),this.handleWidgetMenuClosed=this.handleWidgetMenuClosed.bind(this),this.handleWidgetMenuOpened=this.handleWidgetMenuOpened.bind(this),this.state={tableFilterText:"",widgetFilterText:""}}handleTableFilterChange(e){ti.debug("filtering tables..."),this.setState({tableFilterText:e.target.value})}handleTableMenuClosed(){this.setState({tableFilterText:""})}handleTableMenuOpened(){var e;(e=this.tableSearchField)===null||e===void 0||e.focus()}handleWidgetFilterChange(e){ti.debug("filtering widgets..."),this.setState({widgetFilterText:e.target.value})}handleWidgetMenuClosed(){this.setState({widgetFilterText:""})}handleWidgetMenuOpened(){var e;(e=this.widgetSearchField)===null||e===void 0||e.focus()}render(){var{overflowActions:e,objects:t,openObject:n}=this.props,{tableFilterText:r,widgetFilterText:s}=this.state,a=this.makeTableActions(t,r,n),o=this.makeWidgetActions(t,s,n),d={placement:"bottom-end"},h=a.length===0,u=o.length===0;return l.jsxs(l.Fragment,{children:[l.jsx(K,{kind:"ghost",disabled:h,onClick:()=>{},icon:l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(re,{mask:$i,icon:Ct,transform:"right-5 down-5"}),l.jsx(re,{icon:Ct,transform:"right-8 down-6"})]}),tooltip:h?"No tables available":"Tables",children:l.jsx(Ot,{actions:a,onMenuOpened:this.handleTableMenuOpened,onMenuClosed:this.handleTableMenuClosed,options:{initialKeyboardIndex:1},popperOptions:d},"table-actions ")}),l.jsx(K,{kind:"ghost",disabled:o.length===0,onClick:()=>{},icon:l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(re,{mask:Ui,icon:Ct,transform:"right-5 down-5"}),l.jsx(re,{icon:Ct,transform:"right-8 down-6"})]}),tooltip:u?"No widgets available":"Widgets",children:l.jsx(Ot,{actions:o,onMenuOpened:this.handleWidgetMenuOpened,onMenuClosed:this.handleWidgetMenuClosed,options:{initialKeyboardIndex:1},popperOptions:d},"table-actions")}),l.jsx(K,{kind:"ghost",icon:Ki,tooltip:"More Actions...","aria-label":"More Actions...",onClick:()=>{},children:l.jsx(Ot,{actions:e,popperOptions:d})})]})}}const ja=Jt;function or(i,e,t){return e=_a(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function _a(i){var e=ka(i,"string");return typeof e=="symbol"?e:String(e)}function ka(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class lr extends c.PureComponent{constructor(e){super(e),or(this,"pending",void 0),this.handleCommandStarted=this.handleCommandStarted.bind(this),this.handleCommandCompleted=this.handleCommandCompleted.bind(this),this.pending=new pt,this.state={isDisconnected:!1,isCommandRunning:!1}}componentDidMount(){this.startListening()}componentWillUnmount(){this.stopListening(),this.cancelPendingPromises()}startListening(){var{dh:e,session:t}=this.props;t.addEventListener(e.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}stopListening(){var{dh:e,session:t}=this.props;t.removeEventListener(e.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted)}cancelPendingPromises(){this.pending.cancel()}handleCommandStarted(e){var{result:t}=e.detail;this.pending.add(t).then(()=>this.handleCommandCompleted(null)).catch(n=>this.handleCommandCompleted(n)),this.setState({isCommandRunning:!0})}handleCommandCompleted(e){e instanceof ps||this.setState({isCommandRunning:this.pending.pending.length>0})}render(){var{children:e,dh:t,openObject:n,overflowActions:r,objects:s}=this.props,{isDisconnected:a,isCommandRunning:o}=this.state,d=null,h=null;return a?(d="console-status-icon-disconnected",h="Worker is disconnected"):o?(d="console-status-icon-pending",h="Worker is busy"):(d="console-status-icon-idle",h="Worker is idle"),l.jsxs("div",{className:"console-pane-status-bar",children:[l.jsxs("div",{children:[l.jsx("div",{className:ee("console-status-icon",d)}),l.jsx(ot,{children:h})]}),e,l.jsx(ja,{dh:t,overflowActions:r,openObject:n,objects:s})]})}}or(lr,"defaultProps",{children:null});const Ha=lr;function ni(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Ne(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ni(Object(t),!0).forEach(function(n){Pe(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ni(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Pe(i,e,t){return e=Ua(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ua(i){var e=$a(i,"string");return typeof e=="symbol"?e:String(e)}function $a(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Re=Q.module("Console"),ii={isAutoLaunchPanelsEnabled:!0,isPrintStdOutEnabled:!0,isClosePanelsOnDisconnectEnabled:!0};function Ba(){return!0}function Va(i){return l.jsx(l.Fragment,{})}class Xe extends c.PureComponent{static isErrorLevel(e){return e===de.STDERR||e===de.ERROR||e===de.FATAL}static isOutputLevel(e){return e===de.STDOUT||Xe.isErrorLevel(e)}constructor(e){super(e),Pe(this,"cancelListener",void 0),Pe(this,"consolePane",void 0),Pe(this,"consoleInput",void 0),Pe(this,"consoleHistoryScrollPane",void 0),Pe(this,"pending",void 0),Pe(this,"queuedLogMessages",void 0),Pe(this,"processLogMessageQueue",_i(()=>{this.scrollConsoleHistoryToBottom(),this.setState(r=>{Re.debug2("processLogMessageQueue",this.queuedLogMessages.length," items");var{consoleHistory:s}=r;return s=s.concat(this.queuedLogMessages),this.queuedLogMessages=[],{consoleHistory:s}})},Xe.LOG_THROTTLE)),Pe(this,"getObjects",_e(r=>[...r.values()])),Pe(this,"getContextActions",_e(r=>[...r,{action:this.handleClearShortcut,shortcut:be.CONSOLE.CLEAR},{action:this.handleFocusHistory,shortcut:be.CONSOLE.FOCUS_HISTORY}])),this.handleCommandResult=this.handleCommandResult.bind(this),this.handleCommandStarted=this.handleCommandStarted.bind(this),this.handleCommandSubmit=this.handleCommandSubmit.bind(this),this.handleClearShortcut=this.handleClearShortcut.bind(this),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleLogMessage=this.handleLogMessage.bind(this),this.handleOverflowActions=this.handleOverflowActions.bind(this),this.handleScrollPaneScroll=this.handleScrollPaneScroll.bind(this),this.handleToggleAutoLaunchPanels=this.handleToggleAutoLaunchPanels.bind(this),this.handleToggleClosePanelsOnDisconnect=this.handleToggleClosePanelsOnDisconnect.bind(this),this.handleTogglePrintStdout=this.handleTogglePrintStdout.bind(this),this.handleUploadCsv=this.handleUploadCsv.bind(this),this.handleHideCsv=this.handleHideCsv.bind(this),this.handleCsvFileCanceled=this.handleCsvFileCanceled.bind(this),this.handleCsvFileOpened=this.handleCsvFileOpened.bind(this),this.handleCsvPaste=this.handleCsvPaste.bind(this),this.handleDragEnter=this.handleDragEnter.bind(this),this.handleDragLeave=this.handleDragLeave.bind(this),this.handleClearDragError=this.handleClearDragError.bind(this),this.handleOpenCsvTable=this.handleOpenCsvTable.bind(this),this.handleCsvUpdate=this.handleCsvUpdate.bind(this),this.handleCsvError=this.handleCsvError.bind(this),this.handleCsvInProgress=this.handleCsvInProgress.bind(this),this.consolePane=se.createRef(),this.consoleInput=se.createRef(),this.consoleHistoryScrollPane=se.createRef(),this.pending=new pt,this.queuedLogMessages=[];var{objectMap:t,settings:n}=this.props;this.state=Ne(Ne({consoleHistory:[],consoleHeight:0,isScrollDecorationShown:!1,objectHistoryMap:new Map,objectMap:new Map(t),showCsvOverlay:!1,csvFile:null,csvPaste:null,dragError:null,csvUploadInProgress:!1},ii),n)}componentDidMount(){this.initConsoleLogging();var{dh:e,session:t}=this.props;t.addEventListener(e.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.updateDimensions()}componentDidUpdate(e,t){var{props:n,state:r}=this;this.sendSettingsChange(t,r),n.objectMap!==e.objectMap&&this.updateObjectMap()}componentWillUnmount(){var{dh:e,session:t}=this.props;t.removeEventListener(e.IdeSession.EVENT_COMMANDSTARTED,this.handleCommandStarted),this.pending.cancel(),this.processLogMessageQueue.cancel(),this.deinitConsoleLogging()}initConsoleLogging(){var{session:e}=this.props;this.cancelListener=e.onLogMessage(this.handleLogMessage)}deinitConsoleLogging(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}handleClearShortcut(e){var t;e.preventDefault(),e.stopPropagation(),(t=this.consoleInput.current)===null||t===void 0||t.clear()}handleCommandStarted(e){var{code:t,result:n}=e.detail,r=this.pending.add(n),s={command:t,disabledObjects:[],startTime:Date.now(),cancelResult:()=>{n.cancel()},wrappedResult:r},{commandHistoryStorage:a,language:o,scope:d}=this.props,h=a.addItem(o,d,t,{command:t,startTime:new Date().toJSON()});h.catch(u=>{Re.debug("Error adding workspace item",u)}),this.setState(u=>({consoleHistory:u.consoleHistory.concat(s)}),()=>{this.scrollConsoleHistoryToBottom(!0)}),r.then(u=>{this.handleCommandResult(u,s,h)}).catch(u=>{this.handleCommandError(u,s,h)})}handleCommandResult(e,t,n){var r=Ne(Ne({},t),{},{wrappedResult:void 0,cancelResult:void 0,result:e??t.result});this.setState(s=>{var{consoleHistory:a}=s,o=a.lastIndexOf(t);if(o<0)return Re.error("historyItem not found in consoleHistory"),null;var d=a.concat();return d[o]=r,{consoleHistory:d}}),e&&(this.updateHistory(e,r),this.updateKnownObjects(r),this.updateWorkspaceHistoryItem({error:e.error},n),this.closeRemovedItems(e.changes),this.openUpdatedItems(e.changes))}handleCommandError(e,t,n){if(ce.isCanceled(e)){Re.debug("Called handleCommandError on a cancelled promise result");return}this.updateWorkspaceHistoryItem({error:"".concat(e)},n),this.setState(r=>{var s=r.consoleHistory.concat(),a=s.lastIndexOf(t),o=Ne({},t);return o.wrappedResult=void 0,o.cancelResult=void 0,o.endTime=Date.now(),o.result={error:e},s[a]=o,{consoleHistory:s}})}handleFocusHistory(e){e.preventDefault(),e.stopPropagation();var{focusCommandHistory:t}=this.props;t()}handleLogMessage(e){var{isPrintStdOutEnabled:t}=this.state;t&&Xe.isOutputLevel(e.logLevel)&&this.queueLogMessage(e.message,e.logLevel)}queueLogMessage(e,t){var n={};Xe.isErrorLevel(t)?n.error=e:n.message=e;var r={command:void 0,result:n};this.queuedLogMessages.push(r),this.processLogMessageQueue()}openUpdatedItems(e){Re.debug("openUpdatedItems",e);var{isAutoLaunchPanelsEnabled:t}=this.state;if(e!=null){var{openObject:n}=this.props;[...e.created,...e.updated].forEach(r=>n(r,t&&(r.title===void 0||!r.title.startsWith("_"))))}}closeRemovedItems(e){if(!(e==null||e.removed==null||e.removed.length===0)){var{closeObject:t}=this.props,{removed:n}=e;n.forEach(r=>t(r))}}updateHistory(e,t){var n=t;e==null||e.changes==null||n==null||(n.endTime=Date.now(),this.scrollConsoleHistoryToBottom(),this.setState(r=>{var s=r.consoleHistory.concat();return{consoleHistory:s}}))}updateKnownObjects(e){var t;if(e.result&&(t=e.result.changes),!t||(t.created==null||t.created.length===0)&&(t.updated==null||t.updated.length===0)&&(t.removed==null||t.removed.length===0)){Re.debug2("updateKnownObjects no changes");return}this.setState(n=>{var r,s,a,{consoleHistory:o}=n,d=o.lastIndexOf(e);if(d<0)return Re.error("historyItem not found in state.consoleHistory"),null;var h=new Map(n.objectHistoryMap),u=new Map(n.objectMap),v=function(p){var E=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,{title:S}=p;N(S);var g=h.get(S);if(g!=null&&g>=0){var y;o===n.consoleHistory&&(o=o.concat());var P=Ne(Ne({},o[g]),{},{disabledObjects:[...(y=o[g].disabledObjects)!==null&&y!==void 0?y:[],S]});o[g]=P}h.set(S,d),E?u.delete(S):u.set(S,p)};return(r=t)===null||r===void 0||r.updated.forEach(m=>v(m)),(s=t)===null||s===void 0||s.removed.forEach(m=>v(m,!0)),(a=t)===null||a===void 0||a.created.forEach(m=>{var{title:p}=m;N(p),h.set(p,d),u.set(p,m)}),{objectHistoryMap:h,objectMap:u,consoleHistory:o}})}updateObjectMap(){var{objectMap:e}=this.props;this.setState({objectMap:e})}updateWorkspaceHistoryItem(e,t){var n=this.pending.add(t),r=new Date().toJSON();n.then(s=>{var a=Ne(Ne({},s),{},{data:Ne(Ne({},s.data),{},{endTime:r,result:e})}),{commandHistoryStorage:o,language:d}=this.props;o.updateItem(d,a).catch(h=>{Re.warn("Error updating command history storage",h)})}).catch(s=>{Re.debug("Error updating workspace history item",s)})}scrollConsoleHistoryToBottom(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,t=this.consoleHistoryScrollPane.current;N(t),!(!e&&Math.abs(t.scrollHeight-t.clientHeight-t.scrollTop)>=1)&&window.requestAnimationFrame(()=>{t.scrollTop=t.scrollHeight})}handleScrollPaneScroll(){var e=this.consoleHistoryScrollPane.current;N(e),e.scrollTop>0&&e.scrollHeight>e.clientHeight?this.setState({isScrollDecorationShown:!0}):this.setState({isScrollDecorationShown:!1})}handleToggleAutoLaunchPanels(){this.setState(e=>({isAutoLaunchPanelsEnabled:!e.isAutoLaunchPanelsEnabled}))}handleToggleClosePanelsOnDisconnect(){this.setState(e=>({isClosePanelsOnDisconnectEnabled:!e.isClosePanelsOnDisconnectEnabled}))}handleTogglePrintStdout(){this.setState(e=>({isPrintStdOutEnabled:!e.isPrintStdOutEnabled}))}handleUploadCsv(){this.setState({showCsvOverlay:!0,dragError:null,csvUploadInProgress:!1})}handleHideCsv(){this.setState({showCsvOverlay:!1,csvFile:null,csvPaste:null,dragError:null,csvUploadInProgress:!1})}handleCsvFileCanceled(){this.setState({csvFile:null,csvPaste:null})}handleCsvFileOpened(e){this.setState({csvFile:e,csvPaste:null})}handleCsvPaste(e){this.setState({csvFile:null,csvPaste:e})}handleDragEnter(e){if(!(e.dataTransfer==null||e.dataTransfer.items==null||e.dataTransfer.items.length===0||e.dataTransfer.items[0].kind==="string")){e.preventDefault(),e.stopPropagation(),this.setState({showCsvOverlay:!0});var{items:t}=e.dataTransfer;if(t.length>1){this.setState({dragError:ut.MULTIPLE_FILE_ERROR});return}var n=t[0];ut.isValidDropItem(n)?this.setState({dragError:null}):this.setState({dragError:ut.FILE_TYPE_ERROR})}}handleDragLeave(e){e.currentTarget==null||e.currentTarget instanceof Element&&e.relatedTarget instanceof Element&&e.currentTarget.contains(e.relatedTarget)||(e.preventDefault(),e.stopPropagation(),this.setState({showCsvOverlay:!1,dragError:null}))}handleClearDragError(){this.setState({dragError:null})}handleOpenCsvTable(e){var{dh:t,openObject:n,commandHistoryStorage:r,language:s,scope:a}=this.props,{consoleHistory:o,objectMap:d}=this.state,h={name:e,title:e,type:t.VariableType.TABLE},u=d.has(e),v={startTime:Date.now(),endTime:Date.now(),disabledObjects:[],result:{changes:{created:[],updated:[],removed:[],[u?"updated":"created"]:[h]}}},m=o.concat(v);this.setState({consoleHistory:m}),this.scrollConsoleHistoryToBottom(!0),this.updateKnownObjects(v),n({name:e,title:e,type:t.VariableType.TABLE}),r.addItem(s,a,e,{command:e,startTime:new Date().toJSON(),endTime:new Date().toJSON()})}addConsoleHistoryMessage(e,t){var{consoleHistory:n}=this.state,r={startTime:Date.now(),endTime:Date.now(),result:{message:e,error:t}},s=n.concat(r);this.setState({consoleHistory:s})}handleCsvUpdate(e){this.addConsoleHistoryMessage(e)}handleCsvError(e){this.addConsoleHistoryMessage(void 0,e!=null?"".concat(e):void 0)}handleCsvInProgress(e){this.setState({csvUploadInProgress:e})}handleOverflowActions(){var{isAutoLaunchPanelsEnabled:e,isClosePanelsOnDisconnectEnabled:t,isPrintStdOutEnabled:n}=this.state,{actions:r}=this.props;return[...r,{title:"Print Stdout",action:this.handleTogglePrintStdout,group:k.groups.high,icon:n?Pt:void 0,order:10},{title:"Auto Launch Panels",action:this.handleToggleAutoLaunchPanels,group:k.groups.high,icon:e?Pt:void 0,order:20},{title:"Close Panels on Disconnect",action:this.handleToggleClosePanelsOnDisconnect,group:k.groups.high,icon:t?Pt:void 0,order:30},{title:"Upload Table from File",action:this.handleUploadCsv,group:k.groups.high+10,order:40}]}handleCommandSubmit(e){if(e==="clear"||e==="cls")this.clearConsoleHistory();else if(e.length>0){var{session:t}=this.props;t.runCode(e).catch(r=>{Re.error("There was an error initiating the command",r)})}else{var n={command:" ",result:{},startTime:Date.now(),endTime:Date.now()};this.scrollConsoleHistoryToBottom(!0),this.setState(r=>({consoleHistory:r.consoleHistory.concat(n)}))}}clearConsoleHistory(){this.pending.cancel(),this.setState(e=>{var t=new Map([...e.objectHistoryMap.keys()].map(n=>[n,-1]));return{consoleHistory:[],objectHistoryMap:t}})}addCommand(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;this.consoleInput.current&&(this.consoleInput.current.setConsoleText(e,t,n),t&&this.scrollConsoleHistoryToBottom(!0))}focus(){var e;(e=this.consoleInput.current)===null||e===void 0||e.focus()}sendSettingsChange(e,t){for(var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,r=Object.keys(ii),s={},a=!1,o=0;o<r.length;o+=1){var d=r[o],{[d]:h}=t,{[d]:u}=e;h!==u&&(a=!0),s[d]=h}if(!(n&&!a)){var{onSettingsChange:v}=this.props;v(s)}}updateDimensions(){this.consolePane.current&&this.setState({consoleHeight:this.consolePane.current.clientHeight}),this.consoleInput.current&&this.consoleInput.current.updateDimensions()}render(){var{actions:e,dh:t,historyChildren:n,language:r,statusBarChildren:s,openObject:a,session:o,scope:d,commandHistoryStorage:h,timeZone:u,disabled:v,unzip:m,supportsType:p,iconForType:E}=this.props,{consoleHeight:S,consoleHistory:g,isScrollDecorationShown:y,objectMap:P,showCsvOverlay:O,csvFile:L,csvPaste:V,dragError:Z,csvUploadInProgress:A}=this.state,z=this.getObjects(P),G=Math.round(S*.7),X=this.getContextActions(e);return l.jsxs("div",{role:"presentation",className:ee("iris-console","h-100","w-100",{disabled:v}),children:[l.jsxs("div",{className:"console-pane",ref:this.consolePane,children:[l.jsx(Ha,{dh:t,session:o,overflowActions:this.handleOverflowActions,openObject:a,objects:z,children:s}),l.jsxs("div",{className:"console-csv-container",onDragOver:ut.handleDragOver,onDragEnter:this.handleDragEnter,onDragLeave:this.handleDragLeave,children:[O&&l.jsx(ut,{onCancel:this.handleCsvFileCanceled,onFileOpened:this.handleCsvFileOpened,onPaste:this.handleCsvPaste,clearDragError:this.handleClearDragError,dragError:Z,onError:this.handleCsvError,uploadInProgress:A,allowZip:m!=null}),l.jsxs("div",{role:"presentation",className:ee("scroll-pane no-scroll-x",{"scroll-decoration":y}),onScroll:this.handleScrollPaneScroll,ref:this.consoleHistoryScrollPane,children:[l.jsx(ia,{items:g,openObject:a,language:r,disabled:v,supportsType:p,iconForType:E}),n]})]}),!O&&l.jsx(Gn,{ref:this.consoleInput,session:o,language:r,scope:d,onSubmit:this.handleCommandSubmit,maxHeight:G,commandHistoryStorage:h}),O&&l.jsx(Ma,{session:o,onOpenTable:this.handleOpenCsvTable,onClose:this.handleHideCsv,onUpdate:this.handleCsvUpdate,onError:this.handleCsvError,file:L??void 0,paste:V??void 0,onInProgress:this.handleCsvInProgress,timeZone:u,unzip:m})]}),l.jsx(k,{actions:X,ignoreClassNames:[Gn.INPUT_CLASS_NAME]})]})}}Pe(Xe,"defaultProps",{statusBarChildren:null,settings:{},onSettingsChange:()=>{},scope:null,actions:[],historyChildren:null,timeZone:"America/New_York",objectMap:new Map,disabled:!1,unzip:null,supportsType:Ba,iconForType:Va});Pe(Xe,"LOG_THROTTLE",500);const Wa=Xe;var Ka={groovy:"Groovy",python:"Python",scala:"Scala"};class Ga{static normalizeScriptLanguage(e){return Ka[e]||null}static getDisabledRunTooltip(e,t,n,r){return e?t?null:"".concat(n," doesn't match the session language – ").concat(r," disabled"):"Console session not connected – ".concat(r," disabled")}static outdentCode(e){var t=e.split(`
10
10
  `),n=t.reduce((r,s)=>{var a=s.length-s.trimStart().length;return a===s.length?r:a<r?a:r},Number.MAX_SAFE_INTEGER);return t.map(r=>r.slice(n)).join(`
11
- `)}}const Sn=Ka;function Et(i,e,t){return e=za(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function za(i){var e=Ga(i,"string");return typeof e=="symbol"?e:String(e)}function Ga(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Te=Q.module("ScriptEditor");class dr extends c.Component{constructor(e){super(e),Et(this,"contextActionCleanups",void 0),Et(this,"completionCleanup",void 0),Et(this,"editor",void 0),Et(this,"editorComponent",void 0),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorWillDestroy=this.handleEditorWillDestroy.bind(this),this.handleRun=this.handleRun.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.updateShortcuts=this.updateShortcuts.bind(this),this.contextActionCleanups=[],this.editorComponent=se.createRef(),this.state={model:null}}componentDidMount(){Ce.addEventListener("onUpdate",this.updateShortcuts)}componentDidUpdate(e){var t,n,{sessionLanguage:r,settings:s}=this.props,a=s?.language,o=a!==((t=e.settings)===null||t===void 0?void 0:t.language);o&&(Te.debug("Set language",a),this.setLanguage(a));var d=r==null&&e.sessionLanguage!=null,h=a===r,u=((n=e.settings)===null||n===void 0?void 0:n.language)===e.sessionLanguage;(d||r!==void 0&&u&&!h)&&(Te.debug("De-init completion and context actions"),this.deInitContextActions(),this.deInitCodeCompletion());var v=r!=null&&e.sessionLanguage==null;(v&&h||r!==void 0&&!u&&h)&&(Te.debug("Init completion and context actions"),this.initContextActions(),this.initCodeCompletion())}componentWillUnmount(){Ce.removeEventListener("onUpdate",this.updateShortcuts)}getValue(){return this.editor?this.editor.getValue():(Te.error("Editor not initialized"),null)}getSelectedCommand(){var e,t,n=(e=this.editor)===null||e===void 0?void 0:e.getSelection();D(n);var r=(t=this.editor)===null||t===void 0?void 0:t.getModel();D(r);var{startLineNumber:s,endColumn:a}=n,{endLineNumber:o}=n;a===1&&o>s&&(o-=1);var d=r.getLineMinColumn(s),h=r.getLineMaxColumn(o),u=n.setStartPosition(s,d).setEndPosition(o,h);return Sn.outdentCode(r.getValueInRange(u))}handleEditorInitialized(e){var{focusOnMount:t,onChange:n,onEditorInitialized:r,settings:s,session:a,sessionLanguage:o}=this.props;Te.debug("handleEditorInitialized",o,a,s),this.editor=e,this.setState({model:this.editor.getModel()}),Oe.setEOL(e),Oe.registerPasteHandler(e),a!=null&&s&&o===s.language&&(this.initContextActions(),this.initCodeCompletion()),e.onDidChangeModelContent(n),t!=null&&t&&e.focus(),r(this.editor)}handleEditorWillDestroy(e){Te.debug("handleEditorWillDestroy");var{onEditorWillDestroy:t}=this.props;t(e),this.deInitContextActions(),this.deInitCodeCompletion(),this.setState({model:null}),this.editor=void 0}handleRun(){var{onRunCommand:e}=this.props,t=this.getValue();t!=null&&e(t)}handleRunSelected(){var{onRunCommand:e}=this.props,t=this.getSelectedCommand();e(t)}initContextActions(){if(this.contextActionCleanups.length>0){Te.error("Context actions already initialized.");return}if(this.editor){var e=[];e.push(this.editor.addAction({id:"run-code",label:"Run",keybindings:[Oe.getMonacoKeyCodeFromShortcut(be.NOTEBOOK.RUN)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRun()}})),e.push(this.editor.addAction({id:"run-selected-code",label:"Run Selected",keybindings:[Oe.getMonacoKeyCodeFromShortcut(be.NOTEBOOK.RUN_SELECTED)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRunSelected()}})),this.contextActionCleanups=e}}deInitContextActions(){this.contextActionCleanups.length>0&&(this.contextActionCleanups.forEach(e=>e.dispose()),this.contextActionCleanups=[])}updateShortcuts(){this.deInitContextActions(),this.initContextActions()}initCodeCompletion(){if(this.completionCleanup!=null){Te.error("Code completion already initialized.");return}var{session:e}=this.props;Te.debug("initCodeCompletion",this.editor,e),this.editor&&e!=null&&(this.completionCleanup=Oe.openDocument(this.editor,e))}deInitCodeCompletion(){var{session:e}=this.props;Te.debug("deInitCodeCompletion",this.editor,e),this.completionCleanup&&(this.completionCleanup.dispose(),this.completionCleanup=void 0,this.editor&&e!=null&&Oe.closeDocument(this.editor,e))}append(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;D(this.editor);var n=this.editor.getModel();D(n);var r=n.getValue();r?n.setValue("".concat(r,`
12
- `).concat(e)):n.setValue("".concat(e));var s=n.getLineCount(),a=n.getLineLength(s)+1;this.editor.setPosition({lineNumber:s,column:a}),t&&this.editor.focus()}updateDimensions(){Te.debug("updateDimensions"),this.editor&&this.editor.layout()}focus(){Te.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(){var e,{error:t,isLoaded:n,isLoading:r,session:s,sessionLanguage:a,settings:o}=this.props,{model:d}=this.state,h=t?"Unable to open document. ".concat(t):null,u=o&&(e=o.language)!==null&&e!==void 0?e:null,v=d&&s&&u===a;return l.jsxs(l.Fragment,{children:[(t||r)&&l.jsx("div",{className:"h-100 w-100 position-relative",children:l.jsx(On,{errorMessage:h,isLoading:r,isLoaded:n})}),n&&l.jsx("div",{className:"h-100 w-100 script-editor",children:o&&l.jsxs(l.Fragment,{children:[l.jsx(gs,{ref:this.editorComponent,settings:o,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy}),v!=null&&v&&l.jsx(tr,{model:d,language:u,session:s})]})})]})}}Et(dr,"defaultProps",{error:null,isLoading:!1,isLoaded:!1,focusOnMount:!0,onChange:()=>{},onEditorInitialized:()=>{},onEditorWillDestroy:()=>{},session:null});const Ya=dr;function yt(i,e,t){return e=qa(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function qa(i){var e=Za(i,"string");return typeof e=="symbol"?e:String(e)}function Za(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Xa=250,Qa=2500;class nn extends c.Component{static getTimeString(e,t){if(e==null||t===""||t===0)return null;var n=Math.round((new Date(t).valueOf()-new Date(e).valueOf())/1e3);return n<1?"<1s":Gi.formatElapsedTime(n)}constructor(e){super(e),yt(this,"timer",void 0),yt(this,"cleanup",void 0),yt(this,"loadData",Dt(()=>{var{commandHistoryStorage:t,item:n,language:r}=this.props,{id:s}=n;this.cleanup=t.listenItem(r,s,this.handleUpdate,this.handleError)},Xa)),yt(this,"getPreviewText",xr(t=>t.split(`
13
- `,Qa).join(`
14
- `),{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()}}componentDidMount(){this.loadData()}componentDidUpdate(e,t){var n,{data:r}=this.state;this.timer==null&&!(r!=null&&r.result)&&r?.startTime&&!(r==null||r.endTime===void 0)?this.startTimer():(r!=null&&r.result&&!((n=t.data)!==null&&n!==void 0&&n.result)||r?.endTime&&!(t.data==null||t.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(e){this.setState({error:"".concat(e)})}handleUpdate(e){var{data:t}=e??{};this.setState({data:t});var{onUpdate:n}=this.props;n?.(t)}handleTimeout(){this.updateTime()}render(){var e,{item:{name:t},language:n}=this.props,{currentTime:r,data:s,error:a}=this.state,{result:o,startTime:d,endTime:h}=s??{},u=(e=o?.error)!==null&&e!==void 0?e:a,v=nn.getTimeString(d,h??r),m=this.getPreviewText(t),p=!!v;return l.jsxs("div",{className:"command-history-item-tooltip",children:[l.jsxs("div",{className:"scroll-container",children:[l.jsx(xn,{language:n,children:m}),m.length<t.length&&l.jsx("p",{children:"Preview Truncated..."})]}),l.jsxs("div",{className:"result-info",children:[l.jsxs("div",{className:"d-flex justify-content-between",children:[!!u&&l.jsxs("div",{className:"text-danger mr-1",children:[l.jsx(re,{icon:Wi})," Executed with errors"]}),l.jsxs("div",{className:"time-wrapper",children:["Elapsed time:"," ",p?l.jsx("span",{className:"time-string",children:v}):l.jsx(Bi,{className:"loading-spinner-vertical-align"})]})]}),!!u&&l.jsx("div",{className:"error-message",children:u})]})]})}}yt(nn,"defaultProps",{onUpdate:()=>{}});const Ja=nn;var eo=512;function hr(i){var{item:e,language:t,isSelected:n,commandHistoryStorage:r}=i,s=e.name.substring(0,eo),a=c.useRef(null),o=c.useCallback(()=>{var d;(d=a.current)===null||d===void 0||d.update()},[a]);return l.jsxs("div",{className:ee("command-history-item",{selected:n}),children:[s,l.jsx(ot,{ref:a,interactive:!0,options:{placement:"left",modifiers:{preventOverflow:{enabled:!0,boundariesElement:"viewport",order:825}}},popperClassName:"command-history-item-popper",children:l.jsx(Ja,{item:e,language:t,onUpdate:o,commandHistoryStorage:r})})]})}hr.defaultProps={isSelected:!1};class Jt extends c.Component{static itemKey(e,t){return"".concat(t.title)}static renderContent(e){return e.selectionRequired!==void 0&&e.selectionRequired?l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(re,{icon:Wr,mask:e.icon,transform:"right-5 down-5 shrink-4"}),l.jsx(re,{icon:Kr,transform:"shrink-3 right-7 down-6"})]}):l.jsx(re,{icon:e.icon})}render(){var{actions:e,hasSelection:t}=this.props;return l.jsx("div",{className:"command-history-actions",children:e.map((n,r)=>l.jsx(K,{kind:"inline",className:ee(n.className),onClick:n.action,tooltip:n.description,disabled:n.selectionRequired!==void 0&&n.selectionRequired&&!t,icon:Jt.renderContent(n)},Jt.itemKey(r,n)))})}}const to=Jt;var no=150,ii=3,ri=Q.module("CommandHistoryViewportUpdater");function io(i){var{table:e,columns:t,top:n=0,bottom:r=0,search:s,isReversed:a=!1,onUpdate:o}=i,d=c.useMemo(()=>_i(h=>{var u=h.bottom-h.top,v=Math.max(0,h.top-u*ii),m=h.bottom+u*ii;e.setViewport({top:v,bottom:m,columns:h.columns})},no),[e]);return c.useEffect(function(){var u=e.onUpdate(v=>{var m,p;o({items:(m=v.items)!==null&&m!==void 0?m:[],offset:(p=v.offset)!==null&&p!==void 0?p:0})});return()=>{ri.debug("onUpdate cleanup"),u()}},[e,o]),c.useEffect(function(){e.setSearch(s??"")},[e,s]),c.useEffect(function(){d({top:n,bottom:r,columns:t})},[d,n,r,t,s,a]),c.useEffect(()=>()=>{ri.debug2("Cancel throttledUpdateViewport"),d.cancel()},[d]),null}function si(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function ai(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){si(s,n,r,a,o,"next",d)}function o(d){si(s,n,r,a,o,"throw",d)}a(void 0)})}}function Ae(i,e,t){return e=ro(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ro(i){var e=so(i,"string");return typeof e=="symbol"?e:String(e)}function so(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Ye=Q.module("CommandHistory");class fe extends c.Component{static getCommandsFromViewport(e,t,n){for(var r=[],s=0;s<n.length;s+=1)for(var a=n[s],o=a[0];o<=a[1];o+=1)if(o>=t&&o<t+e.length){var{name:d}=e[o-t];r.push(d)}return r}static getCommandsFromSnapshot(e,t){return ai(function*(){var n=yield e.getSnapshot(t);return[...n.values()].map(r=>r.name)})()}constructor(e){super(e),Ae(this,"itemActions",void 0),Ae(this,"historyActions",void 0),Ae(this,"pending",void 0),Ae(this,"searchInputRef",void 0),Ae(this,"itemListRef",void 0),Ae(this,"debouncedSearchChange",Dt(()=>{this.setState(n=>{var{searchText:r}=n;return{debouncedSearchText:r,selectedRanges:[]}})},fe.SET_SEARCH_DEBOUNCE_MS)),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:zr,shortcut:qt.COPY,action:this.copySelectedCommands,group:k.groups.edit},{title:"Send to Console",description:"Open selected commands in the console",icon:kn,shortcut:be.COMMAND_HISTORY.SEND_TO_CONSOLE,action:this.sendToConsole,group:fe.menuGroups.send,order:10},{title:"Run in Console",description:"Run selected commands in the console",icon:Yt,shortcut:be.COMMAND_HISTORY.RUN,action:this.runInConsole,group:fe.menuGroups.send,order:10},{title:"Send to Active Notebook",description:"Open selected commands in a notebook",icon:Hn,shortcut:be.COMMAND_HISTORY.SEND_TO_NOTEBOOK,action:this.sendToNotebook,group:fe.menuGroups.send,order:20},{title:"Send to New Notebook",description:"Open selected commands in a new notebook",icon:zi,action:this.createNotebook,group:fe.menuGroups.send,order:30}],this.historyActions=[{title:"Send to Console",icon:kn,selectionRequired:!0,description:"Open selected commands in the console",action:this.sendToConsole},{title:"Send to Notebook",icon:Hn,selectionRequired:!0,description:"Open selected commands in a notebook",action:this.sendToNotebook}],this.pending=new pt,this.searchInputRef=se.createRef(),this.itemListRef=se.createRef();var{table:t}=e;this.state={actions:[],historyActions:this.historyActions,top:0,bottom:0,itemCount:t.size,items:[],offset:0,selectedRanges:[],searchText:"",debouncedSearchText:""}}componentWillUnmount(){this.debouncedSearchChange.cancel(),this.pending.cancel()}getSelectedCommands(){var e=this;return ai(function*(){var{items:t,offset:n,selectedRanges:r}=e.state,s=r.slice().sort((o,d)=>o[0]-d[0]);if(s.length===0)return[];if(s[0][0]>=n&&s[s.length-1][1]<n+t.length)return fe.getCommandsFromViewport(t,n,s);var{table:a}=e.props;return e.pending.add(fe.getCommandsFromSnapshot(a,s))})()}getSelectedCommandText(){return this.getSelectedCommands().then(e=>e.join(`
15
- `))}updateActions(){this.setState(e=>{var{selectedRanges:t}=e,n=t.reduce((r,s)=>r+s[1]-s[0]+1,0);return n>0&&n<fe.MAX_SELECTION_COUNT?(Ye.debug("Updating actions",this.itemActions),{actions:this.itemActions}):(Ye.debug("Disabling actions",n),{actions:[]})})}copySelectedCommands(){this.getSelectedCommandText().then(fs).catch(Ye.error)}createNotebook(){this.getSelectedCommandText().then(e=>{var{language:t,sendToNotebook:n}=this.props;n({value:e,language:t},!0)}).catch(Ye.error)}sendToNotebook(){this.getSelectedCommandText().then(e=>{var{language:t,sendToNotebook:n}=this.props;n({value:e,language:t})}).catch(Ye.error)}sendToConsole(){var{sendToConsole:e}=this.props;this.getSelectedCommandText().then(e).catch(Ye.error)}runInConsole(){this.getSelectedCommandText().then(e=>{var{sendToConsole:t}=this.props;t(e,!0,!0)}).catch(Ye.error)}handleSelect(e){var{sendToConsole:t}=this.props,{items:n,offset:r}=this.state;if(e<r||e>=r+n.length){Ye.error("Invalid index!",e);return}var{name:s}=n[e-r];t(s)}handleSelectionChange(e){this.setState({selectedRanges:e}),this.updateActions()}handleViewportChange(e,t){this.setState({top:e,bottom:t})}handleSearchChange(e){this.setState({searchText:e.target.value}),this.debouncedSearchChange()}handleViewportUpdate(e){var{items:t,offset:n}=e,{table:r}=this.props,s=r.size;this.setState({items:t,itemCount:s,offset:n})}renderItem(e){var{item:t,itemIndex:n,isSelected:r}=e,{language:s,commandHistoryStorage:a}=this.props;return l.jsx(hr,{isSelected:r,item:t,language:s,commandHistoryStorage:a})}focus(){this.searchInputRef.current&&this.searchInputRef.current.focus()}restoreScrollPosition(){var e;(e=this.itemListRef.current)===null||e===void 0||e.restoreScrollPosition()}render(){var e,{language:t,table:n}=this.props,{actions:r,historyActions:s,searchText:a,debouncedSearchText:o,top:d,bottom:h,items:u,itemCount:v,offset:m,selectedRanges:p}=this.state,E=(e=Xi.LANGUAGE_MAP.get(t))!==null&&e!==void 0?e:"";return l.jsxs("div",{className:"command-history",children:[l.jsxs("div",{className:"command-history-search-bar",children:[l.jsx(qi,{ref:this.searchInputRef,value:a,placeholder:"".concat(E," Command History"),onChange:this.handleSearchChange}),l.jsx(to,{actions:s,hasSelection:p.length>0})]}),l.jsxs("div",{className:"command-history-list",children:[l.jsx(fn,{ref:this.itemListRef,itemCount:v,items:u,offset:m,selectedRanges:p,onSelect:this.handleSelect,onSelectionChange:this.handleSelectionChange,onViewportChange:this.handleViewportChange,renderItem:this.renderItem,rowHeight:fe.ITEM_HEIGHT,isDoubleClickSelect:!0,isMultiSelect:!0,isStickyBottom:!0}),l.jsx(io,{table:n,top:d,bottom:h,search:o,onUpdate:this.handleViewportUpdate}),l.jsx(k,{actions:r})]})]})}}Ae(fe,"ITEM_HEIGHT",29);Ae(fe,"MAX_SELECTION_COUNT",1e4);Ae(fe,"SET_SEARCH_DEBOUNCE_MS",150);Ae(fe,"menuGroups",{send:k.groups.medium+100});const ao=fe;class oo extends c.PureComponent{constructor(e){super(e),this.handleSwitchClick=this.handleSwitchClick.bind(this)}handleSwitchClick(){var{logLevel:e,onClick:t}=this.props;t(e)}render(){var{logLevel:e,on:t}=this.props;return l.jsxs("div",{className:ee("log-level-menu-item",e),children:[l.jsx(bs,{on:t,onClick:this.handleSwitchClick}),e]})}}const lo=oo;function oi(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function li(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?oi(Object(t),!0).forEach(function(n){ye(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):oi(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function ye(i,e,t){return e=ho(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ho(i){var e=uo(i,"string");return typeof e=="symbol"?e:String(e)}function uo(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class ne extends c.PureComponent{static getLogText(e){var t=new Date(e.micros/1e3),n=bn.formatTimestamp(t);return"".concat(n," ").concat(e.logLevel," ").concat(e.message)}constructor(e){super(e),ye(this,"cancelListener",void 0),ye(this,"editor",void 0),ye(this,"editorContainer",void 0),ye(this,"logLevelMenuItems",void 0),ye(this,"flushTimer",void 0),ye(this,"bufferedMessages",void 0),ye(this,"messages",void 0),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:{}}}componentDidMount(){this.resetLogLevels(),this.initMonaco(),this.startListening(),window.addEventListener("resize",this.handleResize)}componentDidUpdate(e,t){this.updateDimensions();var{shownLogLevels:n}=this.state;t.shownLogLevels!==n&&this.refreshLogText();var{session:r}=this.props;e.session!==r&&(this.stopListening(),this.startListening(),this.clearLogs())}componentWillUnmount(){this.stopFlushTimer(),this.stopListening(),this.destroyMonaco(),window.removeEventListener("resize",this.handleResize)}getMenuActions(e){var t=this,n=[];n.push({menuElement:l.jsx("div",{className:"log-level-menu-title",children:"Display Log Levels"}),group:1,order:10});for(var r=function(){var o=ne.AllLogLevels[s],d=e[o]!=null?e[o]:!1;n.push({title:o,group:1,order:s+100,menuElement:l.jsx(lo,{logLevel:o,on:d,onClick:t.handleMenuItemClick,ref:h=>{h!=null&&(t.logLevelMenuItems[o]=h)}})})},s=0;s<ne.AllLogLevels.length;s+=1)r();return n.push({group:1,order:1e3,menuElement:l.jsxs("div",{className:"log-level-menu-controls",children:[l.jsx(K,{kind:"ghost",className:"log-level-toggle-all",onClick:this.handleToggleAllClick,children:"Toggle All"}),l.jsx(K,{kind:"ghost",onClick:this.handleResetClick,children:"Reset"})]})}),n}resetLogLevels(){for(var e={},t=function(){var s=ne.AllLogLevels[n],a=ne.DefaultLogLevels.some(o=>o===s);e[s]=a},n=0;n<ne.AllLogLevels.length;n+=1)t();this.setState({shownLogLevels:e})}startListening(){var{session:e}=this.props;this.cancelListener=e.onLogMessage(this.handleLogMessage)}stopListening(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}initMonaco(){D(this.editorContainer),this.editor=Nn.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"}),[[Nt.Escape],[Zi.Shift|Nt.Escape]].forEach(e=>{D(this.editor),Oe.disableKeyBindings(this.editor,e),this.editor.addAction({id:"clear-selection-on-escape",label:"",keybindings:[Nt.Escape],keybindingContext:"findWidgetVisible && editorTextFocus",run:()=>{var t,n,r=(t=this.editor)===null||t===void 0?void 0:t.getPosition();D(r),(n=this.editor)===null||n===void 0||n.setPosition(r)}})})}destroyMonaco(){this.editor&&(this.editor.dispose(),this.editor=void 0)}triggerFindWidget(){var e,t;(e=this.editor)===null||e===void 0||e.focus(),(t=this.editor)===null||t===void 0||t.trigger("keyboard","actions.find",void 0)}toggleAll(){for(var{shownLogLevels:e}=this.state,t=!0,n=0;n<ne.AllLogLevels.length;n+=1){var r=ne.AllLogLevels[n];if(!e[r]){t=!1;break}}if(t)this.setState({shownLogLevels:{}});else{for(var s={},a=0;a<ne.AllLogLevels.length;a+=1){var o=ne.AllLogLevels[a];s[o]=!0}this.setState({shownLogLevels:s})}}toggleLogLevel(e){var{shownLogLevels:t}=this.state,n=t[e],r={};r[e]=!n,this.updateLogLevels(r)}updateLogLevels(e){var{shownLogLevels:t}=this.state;t=li(li({},t),e),this.setState({shownLogLevels:t})}appendLogText(e){if(this.editor){var t=this.editor.getModel(),n=t?.getLineCount();D(n);var r=t?.getLineLength(n);D(r);var s=this.isBottomVisible(),a=[];if(r>0&&(a.push({range:{startLineNumber:n,startColumn:r+1,endLineNumber:n,endColumn:r+1},text:`
16
- `,forceMoveMarkers:!0}),n+=1,r=0),a.push({range:{startLineNumber:n,startColumn:r,endLineNumber:n,endColumn:r},text:e,forceMoveMarkers:!0}),t?.applyEdits(a),s){var o=t?.getLineCount();D(o),this.editor.revealLine(o,1)}}}refreshLogText(){if(this.editor){this.truncateLogIfNecessary();for(var{shownLogLevels:e}=this.state,t=this.isBottomVisible(),n="",r=0;r<this.messages.length;r+=1){var s=this.messages[r];if(e[s.logLevel]){var a=ne.getLogText(s);a.length>0&&(n+=a,a.charAt(a.length-1)!==`
11
+ `)}}const En=Ga;function Et(i,e,t){return e=za(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function za(i){var e=Ya(i,"string");return typeof e=="symbol"?e:String(e)}function Ya(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Te=Q.module("ScriptEditor");class dr extends c.Component{constructor(e){super(e),Et(this,"contextActionCleanups",void 0),Et(this,"completionCleanup",void 0),Et(this,"editor",void 0),Et(this,"editorComponent",void 0),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorWillDestroy=this.handleEditorWillDestroy.bind(this),this.handleRun=this.handleRun.bind(this),this.handleRunSelected=this.handleRunSelected.bind(this),this.updateShortcuts=this.updateShortcuts.bind(this),this.contextActionCleanups=[],this.editorComponent=se.createRef(),this.state={model:null}}componentDidMount(){Ce.addEventListener("onUpdate",this.updateShortcuts)}componentDidUpdate(e){var t,n,{sessionLanguage:r,settings:s}=this.props,a=s?.language,o=a!==((t=e.settings)===null||t===void 0?void 0:t.language);o&&(Te.debug("Set language",a),this.setLanguage(a));var d=r==null&&e.sessionLanguage!=null,h=a===r,u=((n=e.settings)===null||n===void 0?void 0:n.language)===e.sessionLanguage;(d||r!==void 0&&u&&!h)&&(Te.debug("De-init completion and context actions"),this.deInitContextActions(),this.deInitCodeCompletion());var v=r!=null&&e.sessionLanguage==null;(v&&h||r!==void 0&&!u&&h)&&(Te.debug("Init completion and context actions"),this.initContextActions(),this.initCodeCompletion())}componentWillUnmount(){Ce.removeEventListener("onUpdate",this.updateShortcuts)}getValue(){return this.editor?this.editor.getValue():(Te.error("Editor not initialized"),null)}getSelectedCommand(){var e,t,n=(e=this.editor)===null||e===void 0?void 0:e.getSelection();N(n);var r=(t=this.editor)===null||t===void 0?void 0:t.getModel();N(r);var{startLineNumber:s,endColumn:a}=n,{endLineNumber:o}=n;a===1&&o>s&&(o-=1);var d=r.getLineMinColumn(s),h=r.getLineMaxColumn(o),u=n.setStartPosition(s,d).setEndPosition(o,h);return En.outdentCode(r.getValueInRange(u))}handleEditorInitialized(e){var{focusOnMount:t,onChange:n,onEditorInitialized:r,settings:s,session:a,sessionLanguage:o}=this.props;Te.debug("handleEditorInitialized",o,a,s),this.editor=e,this.setState({model:this.editor.getModel()}),Oe.setEOL(e),Oe.registerPasteHandler(e),a!=null&&s&&o===s.language&&(this.initContextActions(),this.initCodeCompletion()),e.onDidChangeModelContent(n),t!=null&&t&&e.focus(),r(this.editor)}handleEditorWillDestroy(e){Te.debug("handleEditorWillDestroy");var{onEditorWillDestroy:t}=this.props;t(e),this.deInitContextActions(),this.deInitCodeCompletion(),this.setState({model:null}),this.editor=void 0}handleRun(){var{onRunCommand:e}=this.props,t=this.getValue();t!=null&&e(t)}handleRunSelected(){var{onRunCommand:e}=this.props,t=this.getSelectedCommand();e(t)}initContextActions(){if(this.contextActionCleanups.length>0){Te.error("Context actions already initialized.");return}if(this.editor){var e=[];e.push(this.editor.addAction({id:"run-code",label:"Run",keybindings:[Oe.getMonacoKeyCodeFromShortcut(be.NOTEBOOK.RUN)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRun()}})),e.push(this.editor.addAction({id:"run-selected-code",label:"Run Selected",keybindings:[Oe.getMonacoKeyCodeFromShortcut(be.NOTEBOOK.RUN_SELECTED)],contextMenuGroupId:"navigation",contextMenuOrder:1.5,run:()=>{this.handleRunSelected()}})),this.contextActionCleanups=e}}deInitContextActions(){this.contextActionCleanups.length>0&&(this.contextActionCleanups.forEach(e=>e.dispose()),this.contextActionCleanups=[])}updateShortcuts(){this.deInitContextActions(),this.initContextActions()}initCodeCompletion(){if(this.completionCleanup!=null){Te.error("Code completion already initialized.");return}var{session:e}=this.props;Te.debug("initCodeCompletion",this.editor,e),this.editor&&e!=null&&(this.completionCleanup=Oe.openDocument(this.editor,e))}deInitCodeCompletion(){var{session:e}=this.props;Te.debug("deInitCodeCompletion",this.editor,e),this.completionCleanup&&(this.completionCleanup.dispose(),this.completionCleanup=void 0,this.editor&&e!=null&&Oe.closeDocument(this.editor,e))}append(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;N(this.editor);var n=this.editor.getModel();N(n);var r=n.getValue();r?n.setValue("".concat(r,`
12
+ `).concat(e)):n.setValue("".concat(e));var s=n.getLineCount(),a=n.getLineLength(s)+1;this.editor.setPosition({lineNumber:s,column:a}),t&&this.editor.focus()}updateDimensions(){Te.debug("updateDimensions"),this.editor&&this.editor.layout()}focus(){Te.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(){var e,{error:t,isLoaded:n,isLoading:r,session:s,sessionLanguage:a,settings:o}=this.props,{model:d}=this.state,h=t?"Unable to open document. ".concat(t):null,u=o&&(e=o.language)!==null&&e!==void 0?e:null,v=d&&s&&u===a;return l.jsxs(l.Fragment,{children:[(t||r)&&l.jsx("div",{className:"h-100 w-100 position-relative",children:l.jsx(wn,{errorMessage:h,isLoading:r,isLoaded:n})}),n&&l.jsx("div",{className:"h-100 w-100 script-editor",children:o&&l.jsxs(l.Fragment,{children:[l.jsx(gs,{ref:this.editorComponent,settings:o,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy}),v!=null&&v&&l.jsx(tr,{model:d,language:u,session:s})]})})]})}}Et(dr,"defaultProps",{error:null,isLoading:!1,isLoaded:!1,focusOnMount:!0,onChange:()=>{},onEditorInitialized:()=>{},onEditorWillDestroy:()=>{},session:null});const qa=dr;function yt(i,e,t){return e=Za(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Za(i){var e=Xa(i,"string");return typeof e=="symbol"?e:String(e)}function Xa(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Qa=250,Ja=2500;class rn extends c.Component{static getTimeString(e,t){if(e==null||t===""||t===0)return null;var n=Math.round((new Date(t).valueOf()-new Date(e).valueOf())/1e3);return n<1?"<1s":zi.formatElapsedTime(n)}constructor(e){super(e),yt(this,"timer",void 0),yt(this,"cleanup",void 0),yt(this,"loadData",Dt(()=>{var{commandHistoryStorage:t,item:n,language:r}=this.props,{id:s}=n;this.cleanup=t.listenItem(r,s,this.handleUpdate,this.handleError)},Qa)),yt(this,"getPreviewText",xr(t=>t.split(`
13
+ `,Ja).join(`
14
+ `),{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()}}componentDidMount(){this.loadData()}componentDidUpdate(e,t){var n,{data:r}=this.state;this.timer==null&&!(r!=null&&r.result)&&r?.startTime&&!(r==null||r.endTime===void 0)?this.startTimer():(r!=null&&r.result&&!((n=t.data)!==null&&n!==void 0&&n.result)||r?.endTime&&!(t.data==null||t.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(e){this.setState({error:"".concat(e)})}handleUpdate(e){var{data:t}=e??{};this.setState({data:t});var{onUpdate:n}=this.props;n?.(t)}handleTimeout(){this.updateTime()}render(){var e,{item:{name:t},language:n}=this.props,{currentTime:r,data:s,error:a}=this.state,{result:o,startTime:d,endTime:h}=s??{},u=(e=o?.error)!==null&&e!==void 0?e:a,v=rn.getTimeString(d,h??r),m=this.getPreviewText(t),p=!!v;return l.jsxs("div",{className:"command-history-item-tooltip",children:[l.jsxs("div",{className:"scroll-container",children:[l.jsx(Dn,{language:n,children:m}),m.length<t.length&&l.jsx("p",{children:"Preview Truncated..."})]}),l.jsxs("div",{className:"result-info",children:[l.jsxs("div",{className:"d-flex justify-content-between",children:[!!u&&l.jsxs("div",{className:"text-danger mr-1",children:[l.jsx(re,{icon:Wi})," Executed with errors"]}),l.jsxs("div",{className:"time-wrapper",children:["Elapsed time:"," ",p?l.jsx("span",{className:"time-string",children:v}):l.jsx(Bi,{className:"loading-spinner-vertical-align"})]})]}),!!u&&l.jsx("div",{className:"error-message",children:u})]})]})}}yt(rn,"defaultProps",{onUpdate:()=>{}});const eo=rn;var to=512;function hr(i){var{item:e,language:t,isSelected:n,commandHistoryStorage:r}=i,s=e.name.substring(0,to),a=c.useRef(null),o=c.useCallback(()=>{var d;(d=a.current)===null||d===void 0||d.update()},[a]);return l.jsxs("div",{className:ee("command-history-item",{selected:n}),children:[s,l.jsx(ot,{ref:a,interactive:!0,options:{placement:"left",modifiers:{preventOverflow:{enabled:!0,boundariesElement:"viewport",order:825}}},popperClassName:"command-history-item-popper",children:l.jsx(eo,{item:e,language:t,onUpdate:o,commandHistoryStorage:r})})]})}hr.defaultProps={isSelected:!1};class en extends c.Component{static itemKey(e,t){return"".concat(t.title)}static renderContent(e){return e.selectionRequired!==void 0&&e.selectionRequired?l.jsxs("div",{className:"fa-md fa-layers",children:[l.jsx(re,{icon:Wr,mask:e.icon,transform:"right-5 down-5 shrink-4"}),l.jsx(re,{icon:Kr,transform:"shrink-3 right-7 down-6"})]}):l.jsx(re,{icon:e.icon})}render(){var{actions:e,hasSelection:t}=this.props;return l.jsx("div",{className:"command-history-actions",children:e.map((n,r)=>l.jsx(K,{kind:"inline",className:ee(n.className),onClick:n.action,tooltip:n.description,disabled:n.selectionRequired!==void 0&&n.selectionRequired&&!t,icon:en.renderContent(n)},en.itemKey(r,n)))})}}const no=en;var io=150,ri=3,si=Q.module("CommandHistoryViewportUpdater");function ro(i){var{table:e,columns:t,top:n=0,bottom:r=0,search:s,isReversed:a=!1,onUpdate:o}=i,d=c.useMemo(()=>_i(h=>{var u=h.bottom-h.top,v=Math.max(0,h.top-u*ri),m=h.bottom+u*ri;e.setViewport({top:v,bottom:m,columns:h.columns})},io),[e]);return c.useEffect(function(){var u=e.onUpdate(v=>{var m,p;o({items:(m=v.items)!==null&&m!==void 0?m:[],offset:(p=v.offset)!==null&&p!==void 0?p:0})});return()=>{si.debug("onUpdate cleanup"),u()}},[e,o]),c.useEffect(function(){e.setSearch(s??"")},[e,s]),c.useEffect(function(){d({top:n,bottom:r,columns:t})},[d,n,r,t,s,a]),c.useEffect(()=>()=>{si.debug2("Cancel throttledUpdateViewport"),d.cancel()},[d]),null}function ai(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function oi(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){ai(s,n,r,a,o,"next",d)}function o(d){ai(s,n,r,a,o,"throw",d)}a(void 0)})}}function Ae(i,e,t){return e=so(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function so(i){var e=ao(i,"string");return typeof e=="symbol"?e:String(e)}function ao(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Ye=Q.module("CommandHistory");class fe extends c.Component{static getCommandsFromViewport(e,t,n){for(var r=[],s=0;s<n.length;s+=1)for(var a=n[s],o=a[0];o<=a[1];o+=1)if(o>=t&&o<t+e.length){var{name:d}=e[o-t];r.push(d)}return r}static getCommandsFromSnapshot(e,t){return oi(function*(){var n=yield e.getSnapshot(t);return[...n.values()].map(r=>r.name)})()}constructor(e){super(e),Ae(this,"itemActions",void 0),Ae(this,"historyActions",void 0),Ae(this,"pending",void 0),Ae(this,"searchInputRef",void 0),Ae(this,"itemListRef",void 0),Ae(this,"debouncedSearchChange",Dt(()=>{this.setState(n=>{var{searchText:r}=n;return{debouncedSearchText:r,selectedRanges:[]}})},fe.SET_SEARCH_DEBOUNCE_MS)),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:Gr,shortcut:Zt.COPY,action:this.copySelectedCommands,group:k.groups.edit},{title:"Send to Console",description:"Open selected commands in the console",icon:Hn,shortcut:be.COMMAND_HISTORY.SEND_TO_CONSOLE,action:this.sendToConsole,group:fe.menuGroups.send,order:10},{title:"Run in Console",description:"Run selected commands in the console",icon:qt,shortcut:be.COMMAND_HISTORY.RUN,action:this.runInConsole,group:fe.menuGroups.send,order:10},{title:"Send to Active Notebook",description:"Open selected commands in a notebook",icon:Un,shortcut:be.COMMAND_HISTORY.SEND_TO_NOTEBOOK,action:this.sendToNotebook,group:fe.menuGroups.send,order:20},{title:"Send to New Notebook",description:"Open selected commands in a new notebook",icon:Gi,action:this.createNotebook,group:fe.menuGroups.send,order:30}],this.historyActions=[{title:"Send to Console",icon:Hn,selectionRequired:!0,description:"Open selected commands in the console",action:this.sendToConsole},{title:"Send to Notebook",icon:Un,selectionRequired:!0,description:"Open selected commands in a notebook",action:this.sendToNotebook}],this.pending=new pt,this.searchInputRef=se.createRef(),this.itemListRef=se.createRef();var{table:t}=e;this.state={actions:[],historyActions:this.historyActions,top:0,bottom:0,itemCount:t.size,items:[],offset:0,selectedRanges:[],searchText:"",debouncedSearchText:""}}componentWillUnmount(){this.debouncedSearchChange.cancel(),this.pending.cancel()}getSelectedCommands(){var e=this;return oi(function*(){var{items:t,offset:n,selectedRanges:r}=e.state,s=r.slice().sort((o,d)=>o[0]-d[0]);if(s.length===0)return[];if(s[0][0]>=n&&s[s.length-1][1]<n+t.length)return fe.getCommandsFromViewport(t,n,s);var{table:a}=e.props;return e.pending.add(fe.getCommandsFromSnapshot(a,s))})()}getSelectedCommandText(){return this.getSelectedCommands().then(e=>e.join(`
15
+ `))}updateActions(){this.setState(e=>{var{selectedRanges:t}=e,n=t.reduce((r,s)=>r+s[1]-s[0]+1,0);return n>0&&n<fe.MAX_SELECTION_COUNT?(Ye.debug("Updating actions",this.itemActions),{actions:this.itemActions}):(Ye.debug("Disabling actions",n),{actions:[]})})}copySelectedCommands(){this.getSelectedCommandText().then(fs).catch(Ye.error)}createNotebook(){this.getSelectedCommandText().then(e=>{var{language:t,sendToNotebook:n}=this.props;n({value:e,language:t},!0)}).catch(Ye.error)}sendToNotebook(){this.getSelectedCommandText().then(e=>{var{language:t,sendToNotebook:n}=this.props;n({value:e,language:t})}).catch(Ye.error)}sendToConsole(){var{sendToConsole:e}=this.props;this.getSelectedCommandText().then(e).catch(Ye.error)}runInConsole(){this.getSelectedCommandText().then(e=>{var{sendToConsole:t}=this.props;t(e,!0,!0)}).catch(Ye.error)}handleSelect(e){var{sendToConsole:t}=this.props,{items:n,offset:r}=this.state;if(e<r||e>=r+n.length){Ye.error("Invalid index!",e);return}var{name:s}=n[e-r];t(s)}handleSelectionChange(e){this.setState({selectedRanges:e}),this.updateActions()}handleViewportChange(e,t){this.setState({top:e,bottom:t})}handleSearchChange(e){this.setState({searchText:e.target.value}),this.debouncedSearchChange()}handleViewportUpdate(e){var{items:t,offset:n}=e,{table:r}=this.props,s=r.size;this.setState({items:t,itemCount:s,offset:n})}renderItem(e){var{item:t,itemIndex:n,isSelected:r}=e,{language:s,commandHistoryStorage:a}=this.props;return l.jsx(hr,{isSelected:r,item:t,language:s,commandHistoryStorage:a})}focus(){this.searchInputRef.current&&this.searchInputRef.current.focus()}restoreScrollPosition(){var e;(e=this.itemListRef.current)===null||e===void 0||e.restoreScrollPosition()}render(){var e,{language:t,table:n}=this.props,{actions:r,historyActions:s,searchText:a,debouncedSearchText:o,top:d,bottom:h,items:u,itemCount:v,offset:m,selectedRanges:p}=this.state,E=(e=Xi.LANGUAGE_MAP.get(t))!==null&&e!==void 0?e:"";return l.jsxs("div",{className:"command-history",children:[l.jsxs("div",{className:"command-history-search-bar",children:[l.jsx(qi,{ref:this.searchInputRef,value:a,placeholder:"".concat(E," Command History"),onChange:this.handleSearchChange}),l.jsx(no,{actions:s,hasSelection:p.length>0})]}),l.jsxs("div",{className:"command-history-list",children:[l.jsx(bn,{ref:this.itemListRef,itemCount:v,items:u,offset:m,selectedRanges:p,onSelect:this.handleSelect,onSelectionChange:this.handleSelectionChange,onViewportChange:this.handleViewportChange,renderItem:this.renderItem,rowHeight:fe.ITEM_HEIGHT,isDoubleClickSelect:!0,isMultiSelect:!0,isStickyBottom:!0}),l.jsx(ro,{table:n,top:d,bottom:h,search:o,onUpdate:this.handleViewportUpdate}),l.jsx(k,{actions:r})]})]})}}Ae(fe,"ITEM_HEIGHT",29);Ae(fe,"MAX_SELECTION_COUNT",1e4);Ae(fe,"SET_SEARCH_DEBOUNCE_MS",150);Ae(fe,"menuGroups",{send:k.groups.medium+100});const oo=fe;class lo extends c.PureComponent{constructor(e){super(e),this.handleSwitchClick=this.handleSwitchClick.bind(this)}handleSwitchClick(){var{logLevel:e,onClick:t}=this.props;t(e)}render(){var{logLevel:e,on:t}=this.props;return l.jsxs("div",{className:ee("log-level-menu-item",e),children:[l.jsx(bs,{on:t,onClick:this.handleSwitchClick}),e]})}}const ho=lo;function li(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function di(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?li(Object(t),!0).forEach(function(n){ye(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):li(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function ye(i,e,t){return e=uo(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function uo(i){var e=co(i,"string");return typeof e=="symbol"?e:String(e)}function co(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class ne extends c.PureComponent{static getLogText(e){var t=new Date(e.micros/1e3),n=Cn.formatTimestamp(t);return"".concat(n," ").concat(e.logLevel," ").concat(e.message)}constructor(e){super(e),ye(this,"cancelListener",void 0),ye(this,"editor",void 0),ye(this,"editorContainer",void 0),ye(this,"logLevelMenuItems",void 0),ye(this,"flushTimer",void 0),ye(this,"bufferedMessages",void 0),ye(this,"messages",void 0),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:{}}}componentDidMount(){this.resetLogLevels(),this.initMonaco(),this.startListening(),window.addEventListener("resize",this.handleResize)}componentDidUpdate(e,t){this.updateDimensions();var{shownLogLevels:n}=this.state;t.shownLogLevels!==n&&this.refreshLogText();var{session:r}=this.props;e.session!==r&&(this.stopListening(),this.startListening(),this.clearLogs())}componentWillUnmount(){this.stopFlushTimer(),this.stopListening(),this.destroyMonaco(),window.removeEventListener("resize",this.handleResize)}getMenuActions(e){var t=this,n=[];n.push({menuElement:l.jsx("div",{className:"log-level-menu-title",children:"Display Log Levels"}),group:1,order:10});for(var r=function(){var o=ne.AllLogLevels[s],d=e[o]!=null?e[o]:!1;n.push({title:o,group:1,order:s+100,menuElement:l.jsx(ho,{logLevel:o,on:d,onClick:t.handleMenuItemClick,ref:h=>{h!=null&&(t.logLevelMenuItems[o]=h)}})})},s=0;s<ne.AllLogLevels.length;s+=1)r();return n.push({group:1,order:1e3,menuElement:l.jsxs("div",{className:"log-level-menu-controls",children:[l.jsx(K,{kind:"ghost",className:"log-level-toggle-all",onClick:this.handleToggleAllClick,children:"Toggle All"}),l.jsx(K,{kind:"ghost",onClick:this.handleResetClick,children:"Reset"})]})}),n}resetLogLevels(){for(var e={},t=function(){var s=ne.AllLogLevels[n],a=ne.DefaultLogLevels.some(o=>o===s);e[s]=a},n=0;n<ne.AllLogLevels.length;n+=1)t();this.setState({shownLogLevels:e})}startListening(){var{session:e}=this.props;this.cancelListener=e.onLogMessage(this.handleLogMessage)}stopListening(){this.cancelListener!=null&&(this.cancelListener(),this.cancelListener=void 0)}initMonaco(){N(this.editorContainer),this.editor=xn.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"}),[[Nt.Escape],[Zi.Shift|Nt.Escape]].forEach(e=>{N(this.editor),Oe.disableKeyBindings(this.editor,e),this.editor.addAction({id:"clear-selection-on-escape",label:"",keybindings:[Nt.Escape],keybindingContext:"findWidgetVisible && editorTextFocus",run:()=>{var t,n,r=(t=this.editor)===null||t===void 0?void 0:t.getPosition();N(r),(n=this.editor)===null||n===void 0||n.setPosition(r)}})})}destroyMonaco(){this.editor&&(this.editor.dispose(),this.editor=void 0)}triggerFindWidget(){var e,t;(e=this.editor)===null||e===void 0||e.focus(),(t=this.editor)===null||t===void 0||t.trigger("keyboard","actions.find",void 0)}toggleAll(){for(var{shownLogLevels:e}=this.state,t=!0,n=0;n<ne.AllLogLevels.length;n+=1){var r=ne.AllLogLevels[n];if(!e[r]){t=!1;break}}if(t)this.setState({shownLogLevels:{}});else{for(var s={},a=0;a<ne.AllLogLevels.length;a+=1){var o=ne.AllLogLevels[a];s[o]=!0}this.setState({shownLogLevels:s})}}toggleLogLevel(e){var{shownLogLevels:t}=this.state,n=t[e],r={};r[e]=!n,this.updateLogLevels(r)}updateLogLevels(e){var{shownLogLevels:t}=this.state;t=di(di({},t),e),this.setState({shownLogLevels:t})}appendLogText(e){if(this.editor){var t=this.editor.getModel(),n=t?.getLineCount();N(n);var r=t?.getLineLength(n);N(r);var s=this.isBottomVisible(),a=[];if(r>0&&(a.push({range:{startLineNumber:n,startColumn:r+1,endLineNumber:n,endColumn:r+1},text:`
16
+ `,forceMoveMarkers:!0}),n+=1,r=0),a.push({range:{startLineNumber:n,startColumn:r,endLineNumber:n,endColumn:r},text:e,forceMoveMarkers:!0}),t?.applyEdits(a),s){var o=t?.getLineCount();N(o),this.editor.revealLine(o,1)}}}refreshLogText(){if(this.editor){this.truncateLogIfNecessary();for(var{shownLogLevels:e}=this.state,t=this.isBottomVisible(),n="",r=0;r<this.messages.length;r+=1){var s=this.messages[r];if(e[s.logLevel]){var a=ne.getLogText(s);a.length>0&&(n+=a,a.charAt(a.length-1)!==`
17
17
  `&&(n+=`
18
- `))}}if(n=n.trimRight(),this.editor.setValue(n),t){var o,d=(o=this.editor.getModel())===null||o===void 0?void 0:o.getLineCount();D(d),this.editor.revealLine(d,1)}this.stopFlushTimer(),this.bufferedMessages=[]}}truncateLogIfNecessary(){this.messages.length>ne.maxLogSize&&(this.messages=this.messages.splice(this.messages.length-ne.truncateSize))}scrollToBottom(){var e,t,n;if(this.editor){var r=(e=this.editor)===null||e===void 0||(t=e.getModel)===null||t===void 0||(n=t.call(e))===null||n===void 0?void 0:n.getLineCount();D(r),this.editor.revealLine(r,1)}}isBottomVisible(){if(!this.editor)return!0;var e=this.editor.getModel(),t=e?.getLineCount();return D(t),this.isLineVisible(t)}isLineVisible(e){var t,n=(t=this.editor)===null||t===void 0?void 0:t.getVisibleRanges();if(n==null||n.length===0)return!1;for(var r=0;r<n.length;r+=1){var s=n[r];if(s.startLineNumber<=e&&e<=s.endLineNumber)return!0}return!1}isLogItemVisible(e){var{shownLogLevels:t}=this.state;return t[e.logLevel]}flush(){for(var e="",t=0;t<this.bufferedMessages.length;t+=1){var n=this.bufferedMessages[t],r=ne.getLogText(n);e+=r,r.charAt(r.length-1)!==`
18
+ `))}}if(n=n.trimRight(),this.editor.setValue(n),t){var o,d=(o=this.editor.getModel())===null||o===void 0?void 0:o.getLineCount();N(d),this.editor.revealLine(d,1)}this.stopFlushTimer(),this.bufferedMessages=[]}}truncateLogIfNecessary(){this.messages.length>ne.maxLogSize&&(this.messages=this.messages.splice(this.messages.length-ne.truncateSize))}scrollToBottom(){var e,t,n;if(this.editor){var r=(e=this.editor)===null||e===void 0||(t=e.getModel)===null||t===void 0||(n=t.call(e))===null||n===void 0?void 0:n.getLineCount();N(r),this.editor.revealLine(r,1)}}isBottomVisible(){if(!this.editor)return!0;var e=this.editor.getModel(),t=e?.getLineCount();return N(t),this.isLineVisible(t)}isLineVisible(e){var t,n=(t=this.editor)===null||t===void 0?void 0:t.getVisibleRanges();if(n==null||n.length===0)return!1;for(var r=0;r<n.length;r+=1){var s=n[r];if(s.startLineNumber<=e&&e<=s.endLineNumber)return!0}return!1}isLogItemVisible(e){var{shownLogLevels:t}=this.state;return t[e.logLevel]}flush(){for(var e="",t=0;t<this.bufferedMessages.length;t+=1){var n=this.bufferedMessages[t],r=ne.getLogText(n);e+=r,r.charAt(r.length-1)!==`
19
19
  `&&(e+=`
20
- `)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,ne.bufferTimeout))}stopFlushTimer(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0)}updateDimensions(){this.editor&&this.editor.layout()}handleClearClick(){this.clearLogs()}clearLogs(){this.messages=[],this.refreshLogText()}handleFlushTimeout(){this.stopFlushTimer(),this.flush()}handleLogMessage(e){this.messages.push(e),this.editor&&this.isLogItemVisible(e)&&this.queue(e)}handleMenuItemClick(e){this.toggleLogLevel(e)}handleResetClick(){this.resetLogLevels()}handleResize(){this.updateDimensions()}handleToggleAllClick(){this.toggleAll()}render(){var e={placement:"bottom-end"},{shownLogLevels:t}=this.state,n=this.getMenuActions(t);return l.jsxs("div",{className:"log-pane h-100 w-100",children:[l.jsxs("div",{className:"log-pane-menu",children:[l.jsx(K,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:Gr,tooltip:"Clear log"}),l.jsx(K,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:Yr,tooltip:"Log Settings",onClick:()=>{},children:l.jsx(Ot,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:e})})]}),l.jsx("div",{className:"log-pane-editor h-100 w-100",ref:r=>{this.editorContainer=r}})]})}}ye(ne,"DefaultLogLevels",[de.STDOUT,de.ERROR,de.FATAL,de.STDERR,de.WARN]);ye(ne,"AllLogLevels",[de.INFO,de.STDOUT,de.ERROR,de.FATAL,de.STDERR,de.WARN,de.DEBUG,de.TRACE]);ye(ne,"bufferTimeout",16);ye(ne,"maxLogSize",131072);ye(ne,"truncateSize",65536);const co=ne;function di(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function vo(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){di(s,n,r,a,o,"next",d)}function o(d){di(s,n,r,a,o,"throw",d)}a(void 0)})}}var mo=Q.module("HeapUsage");function po(i){var e,{connection:t,defaultUpdateInterval:n,hoverUpdateInterval:r,bgMonitoring:s=!0,monitorDuration:a}=i,o=Cs(),[d,h]=c.useState({freeMemory:0,maximumHeapSize:999,totalHeapSize:0}),[u,v]=c.useState(!1),m=c.useRef({timestamps:[],usages:[]}),p=Ss(),E=c.useCallback(vo(function*(){try{var N=yield t.getWorkerHeapInfo();if(!p.current)return;if(h(N),s||u){for(var F=(N.totalHeapSize-N.freeMemory)/N.maximumHeapSize,I=Date.now(),{timestamps:oe,usages:ze}=m.current;oe.length!==0&&I-oe[0]>a*1.5;)oe.shift(),ze.shift();oe.push(I),ze.push(F)}else m.current={timestamps:[],usages:[]}}catch(Ge){mo.warn("Unable to get heap usage",Ge)}}),[t,p,s,u,a]);Es(E,u?r:n);var S=(N,F)=>Math.round(N*10**F)/10**F,g=2,y=1024**3,{freeMemory:P,totalHeapSize:O,maximumHeapSize:L}=d,V=S(P/y,g),Z=S(O/y,g),A=S(L/y,g),G=Z-V,z=function(F,I){var oe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return l.jsxs("div",{className:ee("heap-usage-info-row",{"heading-bottom-border":oe}),children:[l.jsx("div",{className:"font-weight-bold",children:F}),l.jsx("div",{children:I})]})},{timestamps:X,usages:ve}=m.current,R=(e=X[X.length-1])!==null&&e!==void 0?e:0,$=O/L,H=(O-P)/L;return l.jsxs("div",{className:"max-memory",children:[l.jsx("div",{className:"total-memory",style:{width:"calc(".concat($*100,"% - ").concat($*2,"px")}}),l.jsx("div",{className:ee("used-memory",{"heap-overflow":(O-P)/L>.95}),style:{width:"calc(".concat(H*100,"% - ").concat(H*2,"px")}}),l.jsxs("div",{className:"memory-text",children:[A.toFixed(1)," GB"]}),l.jsx(ot,{onEntered:()=>v(!0),onExited:()=>v(!1),interactive:!0,children:l.jsxs("div",{className:"heap-tooltip",children:[z("In use:","".concat(G.toFixed(g)," of ").concat(A.toFixed(g)," GB"),!0),z("Free:","".concat(V.toFixed(g)," GB")),z("Total:","".concat(Z.toFixed(g)," GB")),z("Max:","".concat(A.toFixed(g)," GB")),l.jsx("div",{className:"heap-plot",children:l.jsx(ys,{data:[{x:[...X],y:[...ve],type:"scatter",mode:"lines"}],config:{staticPlot:!0,responsive:!0},style:{width:"196px",height:"100px"},layout:{margin:{l:2,t:2,r:2,b:2},plot_bgcolor:"transparent",paper_bgcolor:"transparent",colorway:["#4878ea"],xaxis:{dtick:Math.round(a/6),gridcolor:o.linecolor,range:[R-a,R],linecolor:o.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:o.linecolor,range:[0,1],linecolor:o.linecolor,linewidth:2,mirror:!0}}})}),l.jsxs("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(a/1e3/60)," min."]})]})})]})}function hi(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function go(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?hi(Object(t),!0).forEach(function(n){fo(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):hi(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function fo(i,e,t){return e=bo(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function bo(i){var e=Co(i,"string");return typeof e=="symbol"?e:String(e)}function Co(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Ln=Object.freeze({}),So=new Map,Od=i=>i.api,wd=i=>i.user,Rn=i=>i.storage,ur=i=>Rn(i).commandHistoryStorage,cr=i=>Rn(i).fileStorage,Nd=i=>Rn(i).workspaceStorage,Eo=i=>i.defaultWorkspaceSettings,yo=i=>{var{workspace:e}=i;return e},He=i=>{for(var e=yo(i).data.settings,t=go({},Eo(i)),n=Object.keys(e),r=0;r<n.length;r+=1){var s=n[r];e[s]!==void 0&&(t[s]=e[s])}return t},xd=i=>i.defaultWorkspaceSettings,Dd=i=>He(i).defaultDateTimeFormat,Ld=i=>{var e;return(e=He(i).defaultDecimalFormatOptions)!==null&&e!==void 0?e:Ln},Rd=i=>{var e;return(e=He(i).defaultIntegerFormatOptions)!==null&&e!==void 0?e:Ln},Id=i=>{var e;return(e=He(i).formatter)!==null&&e!==void 0?e:[]},To=i=>He(i).timeZone,Md=i=>He(i).showTimeZone,Fd=i=>He(i).showTSeparator,Ad=i=>He(i).truncateNumbersWithPound,jd=i=>He(i).shortcutOverrides,Po=i=>{var e;return(e=He(i).defaultNotebookSettings)!==null&&e!==void 0?e:Ln},_d=i=>i.activeTool,Oo=i=>{var e;return(e=i.plugins)!==null&&e!==void 0?e:So};function ui(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function vn(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ui(Object(t),!0).forEach(function(n){wo(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ui(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function wo(i,e,t){return e=No(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function No(i){var e=xo(i,"string");return typeof e=="symbol"?e:String(e)}function xo(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function vr(i,e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:e,n=arguments.length>1?arguments[1]:void 0;switch(n.type){case i:{var r=n.payload;return r==null?null:t!=null?vn(vn({},t),r):vn({},r)}default:return t}}}function Je(i,e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:e,n=arguments.length>1?arguments[1]:void 0;switch(n.type){case i:return n.payload;default:return t}}}const Do=Je(Ts,null),Lo=Je(Ps,null),Ro=Je(Os,null),Io=Je(ws,null),Mo=Je(Ns,null),Fo=Je(xs,null),Ao=Pn({commandHistoryStorage:Io,fileStorage:Mo,workspaceStorage:Fo}),jo=vr(Ds,null),_o=vr(Ls,null),ko=Je(Rs,null),Ho=Je(Is,null);var Uo={activeTool:Lo,api:Do,plugins:Ro,storage:Ao,user:jo,workspace:_o,defaultWorkspaceSettings:ko,serverConfigValues:Ho};const $o=Uo;var ci=Q.module("redux-logger"),Bo=i=>e=>t=>{ci.debug("dispatching",t);var n=e(t);return ci.debug("next state",i.getState()),n};const Vo=Bo;var Wo=Q.module("redux-crashReporter"),Ko=i=>e=>t=>{try{return e(t)}catch(n){throw Wo.error("Error executing",t," with state ",i.getState(),":",n),n}};const zo=Ko,Go=[Vo,zo,Dr];var mn;Object.entries($o).map(i=>{var[e,t]=i;return wn.register(e,t)});var Yo=(mn=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)!==null&&mn!==void 0?mn:Ir,mr=Lr(Pn(wn.reducers),Yo(Rr(...Go)));wn.setListener(i=>{mr.replaceReducer(Pn(i))});const kd=mr;function Ft(i,e,t){return e=qo(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function qo(i){var e=Zo(i,"string");return typeof e=="symbol"?e:String(e)}function Zo(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class gt{}Ft(gt,"SESSION_OPENED","ConsoleEvent.SESSION_OPENED");Ft(gt,"SESSION_CLOSED","ConsoleEvent.SESSION_CLOSED");Ft(gt,"FOCUS_HISTORY","ConsoleEvent.FOCUS_HISTORY");Ft(gt,"SEND_COMMAND","ConsoleEvent.SEND_COMMAND");Ft(gt,"SETTINGS_CHANGED","ConsoleEvent.SETTINGS_CHANGED");const we=gt;function et(i,e,t){return e=Xo(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Xo(i){var e=Qo(i,"string");return typeof e=="symbol"?e:String(e)}function Qo(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class We{}et(We,"TABLE_CHANGED","InputFilterEvent.TABLE_CHANGED");et(We,"COLUMNS_CHANGED","InputFilterEvent.COLUMNS_CHANGED");et(We,"FILTERS_CHANGED","InputFilterEvent.FILTERS_CHANGED");et(We,"CLEAR_ALL_FILTERS","InputFilterEvent.CLEAR_ALL_FILTERS");et(We,"COLUMN_SELECTED","InputFilterEvent.COLUMN_SELECTED");et(We,"OPEN_DROPDOWN","InputFilterEvent.OPEN_DROPDOWN");et(We,"OPEN_INPUT","InputFilterEvent.OPEN_INPUT");et(We,"OPEN_FILTER_SET_MANAGER","InputFilterEvent.OPEN_FILTER_SET_MANAGER");const vi=We,Hd=Object.freeze({OPEN:"MarkdownEvent.OPEN"});function Ke(i,e,t){return e=Jo(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Jo(i){var e=el(i,"string");return typeof e=="symbol"?e:String(e)}function el(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Ue{}Ke(Ue,"CREATE_NOTEBOOK","NotebookEvent.createNotebook");Ke(Ue,"SELECT_NOTEBOOK","NotebookEvent.selectNotebook");Ke(Ue,"CLOSE_FILE","NotebookEvent.closeFile");Ke(Ue,"RENAME","NotebookEvent.rename");Ke(Ue,"RENAME_FILE","NotebookEvent.renameFile");Ke(Ue,"REGISTER_FILE","NotebookEvent.registerFile");Ke(Ue,"SEND_TO_NOTEBOOK","NotebookEvent.sendToNotebook");Ke(Ue,"UNREGISTER_FILE","NotebookEvent.unregisterFile");Ke(Ue,"PROMOTE_FROM_PREVIEW","NotebookEvent.promoteFromPreview");const W=Ue;function ft(i,e,t){return e=tl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function tl(i){var e=nl(i,"string");return typeof e=="symbol"?e:String(e)}function nl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class ht{}ft(ht,"focus","TabEvent.focus");ft(ht,"blur","TabEvent.blur");ft(ht,"openPQObject","TabEvent.openPQObject");ft(ht,"openControl","TabEvent.openControl");ft(ht,"reload","TabEvent.reload");ft(ht,"clearAllFilters","TabEvent.clearAllFilters");const Bt=ht;function il(i,e,t){return e=rl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function rl(i){var e=sl(i,"string");return typeof e=="symbol"?e:String(e)}function sl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class pr extends c.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 e,t,n,{glContainer:r}=this.props;return[...(e=r==null||(t=r.tab)===null||t===void 0||(n=t.header)===null||n===void 0?void 0:n.tabs)!==null&&e!==void 0?e:[]]}handleCloseTab(){var{glContainer:e}=this.props;e.close()}handleCloseTabsAll(){var e=this.getAllTabs();e.forEach(t=>{var n;return(n=(t?.contentItem).container)===null||n===void 0?void 0:n.close()})}handleCloseTabsRight(){for(var{glContainer:e}=this.props,t=this.getAllTabs(),n=t.length-1;n>0;n-=1){var r,s,a,o,d,h,u;if(((r=t[n].contentItem)===null||r===void 0||(s=r.config)===null||s===void 0?void 0:s.id)===((a=e.tab)===null||a===void 0||(o=a.contentItem)===null||o===void 0||(d=o.config)===null||d===void 0?void 0:d.id))break;(h=((u=t[n])===null||u===void 0?void 0:u.contentItem).container)===null||h===void 0||h.close()}}canCloseTabsRight(){for(var{glContainer:e}=this.props,t=this.getAllTabs(),n=!0,r=t.length-1;r>0;r-=1){var s,a,o,d,h,u,v,m;if(((s=t[r].contentItem)===null||s===void 0||(a=s.config)===null||a===void 0?void 0:a.id)===((o=e.tab)===null||o===void 0||(d=o.contentItem)===null||d===void 0||(h=d.config)===null||h===void 0?void 0:h.id))break;var p=!!(!((u=t[r])===null||u===void 0||(v=u.contentItem)===null||v===void 0||(m=v.config)===null||m===void 0)&&m.isClosable);if(p){n=!1;break}}return n}canCloseAny(){for(var e=this.getAllTabs(),t=!0,n=e.length-1;n>0;n-=1){var r,s,a,o=!!(!((r=e[n])===null||r===void 0||(s=r.contentItem)===null||s===void 0||(a=s.config)===null||a===void 0)&&a.isClosable);if(o){t=!1;break}}return t}render(){var e,t,n,{additionalActions:r,glContainer:s}=this.props,a=[...r],o=(e=s.tab)===null||e===void 0||(t=e.contentItem)===null||t===void 0||(n=t.config)===null||n===void 0?void 0:n.isClosable;return a.push({title:"Close",order:10,group:k.groups.low,action:this.handleCloseTab,disabled:o===void 0||!o}),a.push(()=>({title:"Close Tabs to Right",order:20,group:k.groups.low,action:this.handleCloseTabsRight,disabled:this.canCloseTabsRight()})),a.push(()=>({title:"Close All",order:30,group:k.groups.low,action:this.handleCloseTabsAll,disabled:this.canCloseAny()})),l.jsx(k,{actions:a})}}il(pr,"defaultProps",{additionalActions:[]});const al=pr;function gr(i,e,t){return e=ol(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ol(i){var e=ll(i,"string");return typeof e=="symbol"?e:String(e)}function ll(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class fr extends c.PureComponent{constructor(e){super(e),gr(this,"renameInputRef",void 0),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=se.createRef();var{value:t}=e;this.state={value:t,valueWasValidated:!1}}componentDidUpdate(e){var{isShown:t}=e,{isShown:n}=this.props;n&&!t&&this.resetState()}resetState(){var{value:e}=this.props;this.setState({value:e,valueWasValidated:!1})}handleRenameDialogOpened(){var e,t;(e=this.renameInputRef)===null||e===void 0||(t=e.current)===null||t===void 0||t.focus()}handleRenameInputChange(e){this.setState({value:e.target.value})}handleRenameCancel(){var{onCancel:e}=this.props;e()}handleRenameSubmit(e){e.stopPropagation(),e.preventDefault();var{value:t}=this.state,n=t?.trim();if(n!==void 0&&n!==""){var{onSubmit:r}=this.props;r(n)}else this.setState({value:n,valueWasValidated:!0})}renderRenameDialog(){var{isShared:e,isOwner:t,itemType:n}=this.props,{value:r,valueWasValidated:s}=this.state;return l.jsxs("form",{className:ee("p-3",{"was-validated":s}),onSubmit:this.handleRenameSubmit,noValidate:!0,role:"presentation",onMouseDown:a=>{a.stopPropagation()},onMouseUp:a=>{a.stopPropagation()},children:[l.jsxs("div",{className:"form-group",children:[l.jsxs("label",{htmlFor:"rename-dialog-".concat(n,"-input"),children:["Rename ",n]}),l.jsx("input",{type:"text",className:"form-control",id:"rename-dialog-".concat(n,"-input"),value:r??void 0,ref:this.renameInputRef,onChange:this.handleRenameInputChange,required:!0}),l.jsxs("div",{className:"invalid-feedback",children:[n," name cannot be empty"]}),(e||!t)&&l.jsxs("div",{className:"pt-2",children:["Renaming this ",n," will rename for all users."]})]}),l.jsxs("div",{className:"text-right",children:[l.jsx(K,{kind:"secondary",className:"mr-2",onClick:this.handleRenameCancel,children:"Cancel"}),l.jsx(K,{kind:"primary",type:"submit",children:"Rename"})]})]})}render(){var{isShown:e,onCancel:t}=this.props;return l.jsx(Ms,{isShown:e,onEntered:this.handleRenameDialogOpened,onExited:t,options:{placement:"bottom"},interactive:!0,closeOnBlur:!0,children:this.renderRenameDialog()})}}gr(fr,"defaultProps",{isShared:!1,isOwner:!0,itemType:"Item",value:""});function En(i,e,t){return e=dl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function dl(i){var e=hl(i,"string");return typeof e=="symbol"?e:String(e)}function hl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var ul=Q.module("Panel");class br extends c.PureComponent{constructor(e){super(e),En(this,"ref",void 0),En(this,"getAdditionActions",_e((n,r,s)=>{var a=[];return r&&a.push(this.getCloneAction()),s&&a.push(this.getRenameAction()),[...a,...n]})),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),this.ref=se.createRef();var{glContainer:t}=this.props;this.state={title:ae.getTitleFromContainer(t),showRenameDialog:!1,isWithinPanel:!0}}componentDidMount(){var e,t,{componentPanel:n,glContainer:r,glEventHub:s}=this.props;r.on("resize",this.handleResize),r.on("show",this.handleBeforeShow),r.on("shown",this.handleShow),r.on("hide",this.handleHide),r.on("tab",this.handleTab),r.on("tabClicked",this.handleTabClicked),s.on(we.SESSION_CLOSED,this.handleSessionClosed),s.on(we.SESSION_OPENED,this.handleSessionOpened),s.on(Bt.focus,this.handleTabFocus),s.on(Bt.blur,this.handleTabBlur),s.on(vi.CLEAR_ALL_FILTERS,this.handleClearAllFilters),s.emit(xe.MOUNT,n??this),this.setState({isWithinPanel:((e=this.ref.current)===null||e===void 0||(t=e.parentElement)===null||t===void 0?void 0:t.closest(".dh-panel"))!=null})}componentWillUnmount(){var{componentPanel:e,glContainer:t,glEventHub:n}=this.props;t.off("resize",this.handleResize),t.off("show",this.handleBeforeShow),t.off("shown",this.handleShow),t.off("hide",this.handleHide),t.off("tab",this.handleTab),t.off("tabClicked",this.handleTabClicked),n.off(we.SESSION_CLOSED,this.handleSessionClosed),n.off(we.SESSION_OPENED,this.handleSessionOpened),n.off(Bt.focus,this.handleTabFocus),n.off(Bt.blur,this.handleTabBlur),n.off(vi.CLEAR_ALL_FILTERS,this.handleClearAllFilters),n.emit(xe.UNMOUNT,e??this)}handleTab(e){e!=null&&this.setState({title:ae.getTitleFromTab(e)}),this.forceUpdate();var{onTab:t}=this.props;t(e)}handleTabClicked(e){var{onTabClicked:t}=this.props;t(e)}handleClearAllFilters(){var{onClearAllFilters:e}=this.props;e(...arguments)}handleFocus(e){var{componentPanel:t,glEventHub:n}=this.props;n.emit(xe.FOCUS,t??this);var{onFocus:r}=this.props;r(e)}handleBlur(e){var{onBlur:t}=this.props;t(e)}handleHide(){var{onHide:e}=this.props;e(...arguments)}handleResize(){var{onResize:e}=this.props;e(...arguments)}handleSessionClosed(e){var{onSessionClose:t}=this.props;t(e)}handleSessionOpened(e,t){var{onSessionOpen:n}=this.props;n(e,t)}handleBeforeShow(){var{onBeforeShow:e}=this.props;e(...arguments)}handleShow(){var{onShow:e}=this.props;e(...arguments)}handleTabBlur(){var{onTabBlur:e}=this.props;e(...arguments)}handleTabFocus(){var{onTabFocus:e}=this.props;e(...arguments)}handleRenameCancel(){this.setState({showRenameDialog:!1})}handleShowRenameDialog(){this.setState({showRenameDialog:!0})}handleRenameSubmit(e){var{glContainer:t}=this.props;this.setState({showRenameDialog:!1,title:e});var n=ae.getRootFromContainer(t),r=ae.getComponentConfigFromContainer(t);D(r),ae.renameComponent(n,r,e)}handleCopyPanel(){var{glContainer:e,glEventHub:t}=this.props,n=ae.getRootFromContainer(e),r=ae.getComponentConfigFromContainer(e);if(r==null){ul.error("Could not get component config from container",e);return}var s=ae.cloneComponent(n,r);s!==null&&t.emit(xe.CLONED,this,s)}getCloneAction(){return{title:"Copy Panel",order:10,group:k.groups.high,action:this.handleCopyPanel}}getRenameAction(){return{title:"Rename",order:10,group:k.groups.medium,action:this.handleShowRenameDialog}}render(){var{children:e,className:t,renderTabTooltip:n,glContainer:r,additionalActions:s,errorMessage:a,isLoaded:o,isLoading:d,isClonable:h,isRenamable:u}=this.props,{tab:v}=r,{showRenameDialog:m,title:p,isWithinPanel:E}=this.state;return l.jsxs("div",{className:ee("h-100 w-100 dh-panel",t),onFocusCapture:this.handleFocus,onBlurCapture:this.handleBlur,ref:this.ref,children:[e,l.jsx(On,{errorMessage:a,isLoaded:o,isLoading:d}),!E&&v!=null&&ki.createPortal(l.jsxs(l.Fragment,{children:[l.jsx(al,{glContainer:r,additionalActions:this.getAdditionActions(s,h,u)}),u&&l.jsx(fr,{isShown:m,value:p,itemType:"Panel",onCancel:this.handleRenameCancel,onSubmit:this.handleRenameSubmit}),n!=null&&l.jsx(ot,{interactive:!0,options:{placement:"bottom"},popperClassName:"panel-tab-popper",children:n()})]}),v.element[0])]})}}En(br,"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 At=br,Ud=Object.freeze({DEFAULT:"DEFAULT",LINKER:"LINKER"});var cl=Object.freeze({}),vl=new Map,rn=Object.freeze([]),$d=(i,e)=>{var t;return(t=ke(i,e).columns)!==null&&t!==void 0?t:rn},Bd=(i,e)=>{var t;return(t=ke(i,e).filterSets)!==null&&t!==void 0?t:rn},Vd=(i,e)=>{var t;return(t=ke(i,e).filters)!==null&&t!==void 0?t:rn},Wd=(i,e)=>{var t;return(t=ke(i,e).tableMap)!==null&&t!==void 0?t:vl},Kd=(i,e)=>ke(i,e).isolatedLinkerPanelId,Cr=(i,e)=>{var t;return(t=ke(i,e).links)!==null&&t!==void 0?t:rn},zd=(i,e)=>ke(i,e).columnSelectionValidator,Gd=(i,e)=>{var t;return(t=ke(i,e).consoleSettings)!==null&&t!==void 0?t:cl},Yd=(i,e)=>ke(i,e).connection,jt=(i,e)=>ke(i,e).sessionWrapper,qd=(i,e)=>t=>t(lt(i,{connection:e})),Zd=(i,e)=>t=>t(lt(i,{sessionWrapper:e})),Sr=(i,e)=>t=>t(lt(i,{links:e})),Xd=(i,e)=>(t,n)=>{var r=Cr(n(),i),s=e.filter(a=>r.findIndex(o=>jn(o.start,a.start)&&jn(o.end,a.end))<0);return t(Sr(i,r.concat(s)))},Qd=(i,e)=>(t,n)=>{var r=Cr(n(),i),s=r.filter(a=>!e.includes(a.id));return t(Sr(i,s))},Jd=(i,e)=>t=>t(lt(i,{isolatedLinkerPanelId:e})),eh=(i,e)=>t=>t(lt(i,{columnSelectionValidator:e})),ml=(i,e)=>t=>t(lt(i,{consoleSettings:e})),th=(i,e)=>t=>t(lt(i,{filterSets:e}));function en(i,e,t){return e=pl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function pl(i){var e=gl(i,"string");return typeof e=="symbol"?e:String(e)}function gl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Vt=Q.module("CommandHistoryPanel");class _t extends c.Component{static handleError(e){Vt.error(e)}constructor(e){super(e),en(this,"container",void 0),en(this,"pending",void 0),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSendToConsole=this.handleSendToConsole.bind(this),this.handleSendToNotebook=this.handleSendToNotebook.bind(this),this.container=se.createRef(),this.pending=new pt;var{session:t,sessionId:n,language:r}=e;this.state={panelState:{},session:t,sessionId:n,language:r,contextActions:[{action:this.handleFocusHistory,shortcut:be.COMMAND_HISTORY.FOCUS_HISTORY}]}}componentDidMount(){var{glEventHub:e,session:t}=this.props;e.on(we.FOCUS_HISTORY,this.handleFocusHistory),t!=null&&this.loadTable()}componentWillUnmount(){var{glEventHub:e}=this.props;e.off(we.FOCUS_HISTORY,this.handleFocusHistory),this.pending.cancel()}handleFocusHistory(){this.container.current&&this.container.current.focus()}handleShow(){var e;(e=this.container.current)===null||e===void 0||e.restoreScrollPosition()}handleSessionOpened(e,t){var{language:n,sessionId:r}=t;this.setState({session:e,sessionId:r,language:n},()=>{this.loadTable()})}handleSessionClosed(){this.pending.cancel(),this.setState({session:void 0,language:void 0,table:void 0})}handleSendToNotebook(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,{session:n,language:r}=this.state;if(Vt.debug("handleSendToNotebook",n,e),!n){Vt.error("Session is not connected.");return}var{glEventHub:s}=this.props;s.emit(t?W.CREATE_NOTEBOOK:W.SEND_TO_NOTEBOOK,n,r,e)}handleSendToConsole(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;Vt.debug("handleSendToConsole",e);var{glEventHub:r}=this.props;r.emit(we.SEND_COMMAND,e,t,n)}loadTable(){var{commandHistoryStorage:e}=this.props,{language:t,sessionId:n}=this.state;D(t),D(n),this.pending.add(e.getTable(t,n,Date.now()),r=>r.close()).then(r=>{this.setState({table:r})}).catch(_t.handleError)}render(){var{glContainer:e,glEventHub:t,commandHistoryStorage:n}=this.props,{language:r,contextActions:s,table:a}=this.state;return l.jsxs(At,{className:"command-history-pane",componentPanel:this,glContainer:e,glEventHub:t,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[!a&&l.jsx("div",{className:"command-history-disconnected-message",children:"Waiting for console connection"}),a&&r!=null&&l.jsxs(l.Fragment,{children:[l.jsx(ao,{ref:this.container,language:r,sendToNotebook:this.handleSendToNotebook,sendToConsole:this.handleSendToConsole,table:a,commandHistoryStorage:n}),l.jsx(k,{actions:s})]})]})}}en(_t,"COMPONENT","CommandHistoryPanel");en(_t,"TITLE","Command History");var fl=(i,e)=>{var t=ur(i),n=jt(i,e.localDashboardId),{session:r,config:s}=n??{},{type:a,id:o}=s??{};return{commandHistoryStorage:t,language:a,session:r,sessionId:o}},bl=It(fl,null,null,{forwardRef:!0})(_t);const Cl=bl;function mi(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function pi(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?mi(Object(t),!0).forEach(function(n){st(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):mi(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function st(i,e,t){return e=Sl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Sl(i){var e=El(i,"string");return typeof e=="symbol"?e:String(e)}function El(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Wt=Q.module("ConsolePanel"),yl=500,Tl=Object.freeze({consoleSettings:{},itemIds:[]});class sn extends c.PureComponent{constructor(e){super(e),st(this,"consoleRef",void 0),st(this,"objectSubscriptionCleanup",void 0),st(this,"savePanelState",Dt(()=>{var{consoleSettings:a,itemIds:o}=this.state,d={consoleSettings:a,itemIds:[...o]};Wt.debug("Saving panel state",d),this.setState({panelState:d})},yl)),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.supportsType=this.supportsType.bind(this),this.iconForType=this.iconForType.bind(this),this.consoleRef=se.createRef();var{panelState:t}=e,n=pi(pi({},Tl),t||{}),{consoleSettings:r,itemIds:s}=n;this.state={consoleSettings:r,itemIds:new Map(s),objectMap:new Map,error:void 0,panelState:n}}componentDidMount(){var{glEventHub:e}=this.props;this.closeDisconnectedPanels(),e.on(xe.MOUNT,this.handlePanelMount),this.subscribeToFieldUpdates()}componentDidUpdate(e,t){var{consoleSettings:n,itemIds:r}=this.state;(t.consoleSettings!==n||t.itemIds!==r)&&this.savePanelState()}componentWillUnmount(){var e,{glEventHub:t}=this.props;this.savePanelState.flush(),t.off(xe.MOUNT,this.handlePanelMount),(e=this.objectSubscriptionCleanup)===null||e===void 0||e.call(this)}subscribeToFieldUpdates(){var{sessionWrapper:e}=this.props;if(e!=null){var{session:t}=e;this.objectSubscriptionCleanup=t.subscribeToFieldUpdates(n=>{Wt.debug("Got updates",n),this.setState(r=>{var{objectMap:s}=r,{updated:a,created:o,removed:d}=n,h=[...a,...d],u=new Map(s);h.forEach(m=>{var{title:p}=m;p!==void 0&&u.delete(p)});var v=[...a,...o];return v.forEach(m=>{m.title!==void 0&&u.set(m.title,m)}),{objectMap:u}})})}}setItemId(e,t){this.setState(n=>{var{itemIds:r}=n,s=new Map(r);return s.set(e,t),{itemIds:s}})}getItemId(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,{itemIds:n}=this.state,r=n.get(e);return r==null&&t&&(r=Hi.generate(),this.setItemId(e,r)),r}handleTabFocus(){var e;(e=this.consoleRef.current)===null||e===void 0||e.focus()}handlePanelMount(e){var t,n,r,{itemIds:s}=this.state,a=e==null||(t=e.props)===null||t===void 0?void 0:t.id,o=e==null||(n=e.props)===null||n===void 0||(r=n.metadata)===null||r===void 0?void 0:r.sourcePanelId;if(a&&o){var d=new Set(s.values());d.has(o)&&this.setItemId(a,a)}}handleFocusCommandHistory(){var{glEventHub:e}=this.props;e.emit(we.FOCUS_HISTORY)}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions()}handleOpenObject(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,{sessionWrapper:n}=this.props;if(n!=null){var{session:r}=n,{root:s}=this.context,a=e.title!=null?this.getItemId(e.title,!1):null;(t||a!=null&&ae.getStackForRoot(s,{id:a},!1,!1,!1)!=null)&&this.openWidget(e,r)}}handleCloseObject(e){var{title:t}=e;if(t!==void 0){var n=this.getItemId(t,!1);if(n!=null){var{glEventHub:r}=this.props;r.emit(xe.CLOSE,n)}}}handleSettingsChange(e){var{glEventHub:t}=this.props;Wt.debug("handleSettingsChange",e),this.setState({consoleSettings:e}),t.emit(we.SETTINGS_CHANGED,e)}openWidget(e,t){var{glEventHub:n}=this.props,{title:r}=e;D(r);var s=this.getItemId(r),a={fetch:()=>t.getObject(e),panelId:s,widget:e};Wt.debug("openWidget",a),n.emit(xe.OPEN,a)}addCommand(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;(t=this.consoleRef.current)===null||t===void 0||t.addCommand(e,n,r)}closeDisconnectedPanels(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,{consoleSettings:t,itemIds:n}=this.state,{isClosePanelsOnDisconnectEnabled:r=!0}=t;if(!(!r&&!e)){var s=[...n.values()],{glEventHub:a}=this.props;s.forEach(o=>{a.emit(xe.CLOSE,o)}),this.setState({itemIds:new Map})}}updateDimensions(){var e;(e=this.consoleRef.current)===null||e===void 0||e.updateDimensions()}supportsType(e){var{plugins:t}=this.props;return[...t.values()].some(n=>Un(n,e))}iconForType(e){var{plugins:t}=this.props,n=[...t.values()].find(r=>Un(r,e));return n!=null?Fs(n):l.jsx(Bs,{type:e})}render(){var{commandHistoryStorage:e,glContainer:t,glEventHub:n,sessionWrapper:r,timeZone:s,unzip:a}=this.props;if(r==null)return l.jsx(On,{isLoading:!1,errorMessage:"Console is disabled."});var{consoleSettings:o,error:d,objectMap:h}=this.state,{config:u,session:v,connection:m,details:p={},dh:E}=r,{workerName:S,processInfoId:g}=p,{id:y,type:P}=u;return l.jsx(At,{className:"iris-panel-console",componentPanel:this,glContainer:t,glEventHub:n,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,errorMessage:d!=null?"".concat(d):void 0,children:v!=null&&l.jsx(Va,{dh:E,ref:this.consoleRef,settings:o,session:v,focusCommandHistory:this.handleFocusCommandHistory,openObject:this.handleOpenObject,closeObject:this.handleCloseObject,commandHistoryStorage:e,onSettingsChange:this.handleSettingsChange,language:P,statusBarChildren:l.jsxs(l.Fragment,{children:[l.jsx("div",{children:Xi.LANGUAGE_MAP.get(P)}),S!=null&&l.jsxs(l.Fragment,{children:[l.jsx("div",{children:"•"}),S]}),g!=null&&l.jsxs(l.Fragment,{children:[l.jsx("div",{children:"•"}),g,l.jsx("div",{children:"•"})]}),l.jsx(po,{connection:m,defaultUpdateInterval:10*1e3,hoverUpdateInterval:3*1e3,monitorDuration:10*60*1e3})]}),scope:y,timeZone:s,objectMap:h,unzip:a,supportsType:this.supportsType,iconForType:this.iconForType})})}}st(sn,"COMPONENT","ConsolePanel");st(sn,"TITLE","Console");st(sn,"contextType",As);var Pl=(i,e)=>({commandHistoryStorage:ur(i),sessionWrapper:jt(i,e.localDashboardId),timeZone:To(i),plugins:Oo(i)}),Ol=It(Pl,null,null,{forwardRef:!0})(sn);const pn=Ol;function De(i){return i.type==="directory"}function wl(i,e,t){return e=Nl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Nl(i){var e=xl(i,"string");return typeof e=="symbol"?e:String(e)}function xl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Dl extends Error{constructor(){super("No file exists at the path specified"),wl(this,"isFileNotFound",!0)}}const In=Dl;function gi(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function fi(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){gi(s,n,r,a,o,"next",d)}function o(d){gi(s,n,r,a,o,"throw",d)}a(void 0)})}}var Ve;(function(i){i.GROOVY="text/x-groovy",i.PLAIN_TEXT="text/plain",i.PYTHON="text/x-python",i.PYTHON_COMPILED="application/x-python-code",i.SCALA="text/x-scala",i.UNKNOWN=""})(Ve||(Ve={}));class Fe{static fileExists(e,t){return fi(function*(){try{return yield e.info(t),!0}catch(n){if(!(n instanceof In))throw n;return!1}})()}static fileExtensionToString(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";return e.length===0?"":".".concat(e)}static getDepth(e){var t;if(!Fe.hasPath(e))throw new Error("Invalid path provided: ".concat(e));var n=(t=e.match(/\//g))!==null&&t!==void 0?t:[];return n.length-1}static getExtension(e){var t=this.getBaseName(e).split(".");if(t.length>1){var n;return(n=t.pop())!==null&&n!==void 0?n:""}return""}static getBaseName(e){var t;return(t=e.split("/").pop())!==null&&t!==void 0?t:""}static getCopyFileName(e){var t=e.lastIndexOf("."),n=null,r=null;t<0?r=e:(r=e.substring(0,t),n=e.substring(t+1));var s=r?"".concat(r,"-copy"):"Copy";return n!==null?"".concat(s,".").concat(n):s}static getUniqueCopyFileName(e,t){return fi(function*(){for(var n=Fe.getCopyFileName(t);yield Fe.fileExists(e,n);)n=Fe.getCopyFileName(n);return n})()}static getMimeType(e){var t=this.getExtension(e).toLowerCase();switch(t){case"groovy":return Ve.GROOVY;case"py":return Ve.PYTHON;case"pyc":return Ve.PYTHON_COMPILED;case"scala":return Ve.SCALA;case"txt":return Ve.PLAIN_TEXT;default:return Ve.UNKNOWN}}static getParent(e){if(!Fe.hasPath(e))throw new Error("Invalid name provided: ".concat(e));for(var t=e.split("/");t.pop()==="";);if(t.length===0)throw new Error("No parent for path provided: ".concat(e));return"".concat(t.join("/"),"/")}static getPath(e){if(!Fe.hasPath(e))throw new Error("Invalid filename provided: ".concat(e));var t=e.split("/");return t.pop(),"".concat(t.join("/"),"/")}static hasPath(e){return e.startsWith("/")}static isPath(e){return e.startsWith("/")&&e.endsWith("/")}static makePath(e){return e.endsWith("/")?e:"".concat(e,"/")}static replaceExtension(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",n=e.lastIndexOf("."),r=n>-1?e.substring(0,n):e,s=Fe.fileExtensionToString(t);return"".concat(r).concat(s)}static validateName(e){var t=[".",".."],n=/[\\/\0]/g,r=new Map([["\0","null"]]);if(!e)throw new wt("Name cannot be empty");if(t.includes(e))throw new wt('"'.concat(e,'" is a reserved name'));if(n.test(e)){var s,a;throw new wt('Invalid characters in name: "'.concat((s=(a=e.match(n))===null||a===void 0?void 0:a.reduce((o,d)=>o.includes(d)?o:[...o,d],[]).map(o=>r.has(o)?r.get(o):o).join('", "'))!==null&&s!==void 0?s:"",'"'))}}static reducePaths(e){var t=e.filter(n=>Fe.isPath(n));return e.filter(n=>!t.some(r=>n!==r&&n.startsWith(r)))}static removeRoot(e,t){if(e.length===0)return t;if(!t.startsWith(e))throw new Error("Filename ".concat(t," does not start with expected root ").concat(e));return t.substring(e.length)}static addRoot(e,t){return"".concat(e).concat(t)}}const w=Fe;var Mn=26;function yn(i){return De(i)?w.makePath(i.filename):w.getPath(i.filename)}function bi(i,e){if(i.length===0||e==null)throw new Error("No items to move");var t=yn(e);if(i.some(n=>{var{filename:r}=n;return w.getPath(r)===t}))throw new Error("File already in the destination folder");if(i.some(n=>De(n)&&t.startsWith(w.makePath(n.filename))))throw new Error("Destination folder cannot be a child of a dragged folder");return{files:i,targetPath:t}}function Ll(i){if(De(i))return i.isExpanded?qr:Zr;var e=w.getMimeType(i.basename);switch(e){case Ve.PYTHON:return Qr;default:return Xr}}function Tn(i){var e,{children:t,draggedItems:n,isDragInProgress:r,isDropTargetValid:s,isSelected:a,item:o,itemIndex:d,dropTargetItem:h,onDragStart:u,onDragOver:v,onDragEnd:m,onDrop:p}=i,E=(e=n?.some(A=>A.id===o.id))!==null&&e!==void 0?e:!1,S=yn(o),g=r&&h?yn(h):null,y=r&&s&&De(o)&&g===S,P=r&&s&&g===S,O=r&&!s&&g===S,L=Ll(o),V=w.getDepth(o.filename),Z=Array(V).fill(null).map((A,G)=>l.jsx("span",{className:"file-list-depth-line"},G));return l.jsxs("div",{className:ee("d-flex w-100 align-items-center","file-list-item",{"is-dragged":E,"is-exact-drop-target":y,"is-in-drop-target":P,"is-invalid-drop-target":O,"is-selected":a}),onDragStart:A=>u(d,A),onDragOver:A=>v(d,A),onDragEnd:A=>m(d,A),onDrop:A=>p(d,A),draggable:!0,role:"presentation","aria-label":o.basename,children:[Z," ",l.jsx(re,{icon:L,className:"item-icon",fixedWidth:!0})," ",l.jsx("span",{className:"truncation-wrapper",children:t??l.jsxs(l.Fragment,{children:[o.basename,l.jsx(ot,{children:o.basename})]})})]})}function Ci(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Kt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ci(Object(t),!0).forEach(function(n){Rl(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Ci(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Rl(i,e,t){return e=Il(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Il(i){var e=Ml(i,"string");return typeof e=="symbol"?e:String(e)}function Ml(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var pe=Q.module("FileList"),Fl=500,Si="item-list-scroll-pane";function Al(i){var{isMultiSelect:e=!1,table:t,onFocusChange:n=()=>{},onMove:r,onSelect:s,onSelectionChange:a=()=>{},renderItem:o=Tn,rowHeight:d=Mn,overscanCount:h=fn.DEFAULT_OVERSCAN}=i,[u,v]=c.useState(()=>({items:[],offset:0,itemCount:0})),[m,p]=c.useState({top:0,bottom:0}),[E,S]=c.useState(),[g,y]=c.useState(),[P,O]=c.useState(),[L,V]=c.useState([]),Z=c.useRef(),A=c.useRef(null),G=c.useRef(null),z=c.useCallback(C=>{if(C.length===0||u==null)return[];for(var M=[],B=0;B<C.length;B+=1)for(var te=C[B],me=te[0];me<=te[1];me+=1)me>=u.offset&&me<u.offset+u.items.length&&M.push(u.items[me-u.offset]);return M},[u]),X=c.useCallback(C=>{var M=z([[C,C]]);if(M.length>0)return M[0]},[z]),ve=c.useCallback(()=>{var C=$n.count(L);if(C===0)return null;if(C===1){var M=L[0][0],B=X(M);if(B!=null)return B.filename}return"".concat(C," items")},[X,L]),R=c.useCallback(C=>{if(!(!g||!E)){pe.debug("dropItems",g,"to",C);try{var{files:M,targetPath:B}=bi(g,E);if(r?.(M,B),C!=null){var te;V([[C,C]]),(te=A.current)===null||te===void 0||te.focusItem(C)}}catch(me){pe.error("Unable to complete move",me)}}},[g,E,r]),$=c.useCallback((C,M)=>{var B=u.items[C-u.offset];B!==void 0&&(pe.debug("handleItemClick",B),s(B,M),De(B)&&t?.setExpanded(B.filename,!B.isExpanded))},[u,s,t]),H=c.useCallback((C,M)=>{var B;pe.debug2("handleItemDragStart",C,L);var te=L;$n.isSelected(L,C)||(te=[[C,C]],V(te)),y(z(te)),(B=A.current)===null||B===void 0||B.resetMouseState();var me=document.createElement("div");me.innerHTML='<div class="dnd-placeholder-content">'.concat(ve(),"</div>"),me.className="file-list-dnd-placeholder",document.body.appendChild(me),M.dataTransfer.setDragImage(me,0,0),M.dataTransfer.effectAllowed="move",O(me)},[ve,z,L]),N=c.useCallback((C,M)=>{M.preventDefault(),pe.debug2("handleItemDragOver",M),S(X(C))},[X]),F=c.useCallback((C,M)=>{pe.debug("handleItemDragEnd",C),P?.remove(),y(void 0),S(void 0),O(void 0)},[P]),I=c.useCallback((C,M)=>{R(C)},[R]),oe=c.useCallback(()=>{pe.debug2("handleItemDragExit"),S(void 0)},[]),ze=c.useCallback(C=>{C.target instanceof Element&&C.target.classList.contains(Si)&&(C.preventDefault(),pe.debug2("handleListDragOver",C),S({type:"directory",filename:"/",basename:"/",id:"/"}))},[]),Ge=c.useCallback(C=>{C.target instanceof Element&&C.target.classList.contains(Si)&&(pe.debug("handleListDrop"),R())},[R]),f=c.useCallback(function(C){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(pe.debug2("handleSelectionChange",C),M===!0||C!==L){V(C);var B=z(C);a(B)}},[z,a,L]),b=c.useCallback(C=>{if(pe.debug2("handleFocusChange",C),C!=null){var[M]=z([[C,C]]);n(M)}else n();Z.current=C},[z,n]),T=c.useCallback((C,M)=>{pe.debug("handleViewportChange",C,M),(C!==m.top||M!==m.bottom)&&p({top:C,bottom:M})},[m]),x=c.useMemo(()=>{if(!g||!E)return!1;try{return bi(g,E),pe.debug("handleValidateDropTarget true"),!0}catch{return pe.debug("handleValidateDropTarget false"),!1}},[g,E]),{focusedPath:j}=i;c.useEffect(()=>{j!==void 0&&(j==="/"?t.collapseAll():(t.setExpanded(j,!1),t.setExpanded(j,!0)))},[t,j]),c.useEffect(function(){pe.debug("updating table viewport",m),t?.setViewport({top:Math.max(0,m.top-h),bottom:m.bottom+h})},[h,t,m]),c.useEffect(function(){var M=t.onUpdate(B=>{v({items:B.items.map(te=>Kt(Kt({},te),{},{itemName:te.basename})),offset:B.offset,itemCount:t.size})});return()=>{M()}},[t]),c.useEffect(function(){Z.current!=null&&b(Z.current),L.length>0&&f(L,!0)},[u,b,f,L]),c.useEffect(function(){if(E!=null&&De(E)&&E.filename!=="/"){var M=setTimeout(()=>{E.isExpanded||t?.setExpanded(E.filename,!0)},Fl);return()=>clearTimeout(M)}},[E,t]);var $e=c.useCallback(C=>o(Kt(Kt({},C),{},{isDragInProgress:g!=null,dropTargetItem:E,draggedItems:g,isDropTargetValid:x,onDragStart:H,onDragEnd:F,onDragOver:N,onDragExit:oe,onDrop:I})),[F,oe,N,H,I,g,E,x,o]);return l.jsx("div",{ref:G,className:ee("file-list",{"is-dragging":g!=null}),onDragOver:ze,onDrop:Ge,children:l.jsx(fn,{ref:A,items:u.items,itemCount:u.itemCount,offset:u.offset,onFocusChange:b,onSelect:$,onSelectionChange:f,onViewportChange:T,selectedRanges:L,renderItem:$e,rowHeight:d,isMultiSelect:e,isDragSelect:!1,isDeselectOnClick:!1})})}var jl={name:"File Explorer",DELETE:Ce.createAndAdd({id:"FILE_EXPLORER.DELETE",name:"Delete",shortcut:[Y.DELETE],macShortcut:[q.CMD,Y.BACKSPACE]}),RENAME:Ce.createAndAdd({id:"FILE_EXPLORER.RENAME",name:"Rename",shortcut:[Y.ENTER],macShortcut:[Y.ENTER]})};const Ei={FILE_EXPLORER:jl};var yi=Q.module("FileListItemEditor"),_l=()=>Promise.resolve();function kl(i){var{item:e,onCancel:t,onSubmit:n,validate:r=_l}=i,s=c.useRef(null),[a,o]=c.useState(e.basename),[d,h]=c.useState(),[u,v]=c.useState(Promise.resolve()),m=c.useCallback(()=>{var P;(P=s.current)===null||P===void 0||P.focus()},[s]),p=c.useCallback(P=>P.stopPropagation(),[]),E=c.useCallback(()=>{u.then(()=>{n(a)}).catch(P=>yi.info("Unable to validate name",P))},[n,a,u]);c.useEffect(function(){var O=ce.makeCancelable(r(a));return O.then(()=>h(void 0)).catch(L=>{ce.isCanceled(L)||h(L)}),v(O),()=>O.cancel()},[r,a]),c.useEffect(function(){m()},[m]);var S=c.useCallback(()=>{yi.debug2("handleBlur"),E()},[E]),g=c.useCallback(P=>{var{value:O}=P.target;o(O)},[]),y=c.useCallback(P=>{P.stopPropagation();var{key:O}=P;switch(O){case"Enter":{E();break}case"Escape":{t();break}}},[t,E]);return l.jsxs("div",{className:"file-list-item-editor",children:[l.jsx("input",{type:"text",className:ee("form-control file-list-item-editor-input",{"is-invalid":d}),value:a,ref:s,onBlur:S,onKeyDown:y,onChange:g,onClick:p,onDoubleClick:p,onMouseDown:p}),d&&l.jsx("div",{className:"invalid-feedback",children:"".concat(d)})]})}function Ti(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function gn(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ti(Object(t),!0).forEach(function(n){Hl(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Ti(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Hl(i,e,t){return e=Ul(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ul(i){var e=$l(i,"string");return typeof e=="symbol"?e:String(e)}function $l(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function Er(i){var{isMultiSelect:e=!1,focusedPath:t,showContextMenu:n=!1,onCreateFile:r,onCreateFolder:s,onCopy:a,onDelete:o,onMove:d,onRename:h,onSelect:u,onSelectionChange:v,table:m,rowHeight:p=Mn,validateRename:E=()=>Promise.resolve()}=i,[S,g]=c.useState(),[y,P]=c.useState([]),[O,L]=c.useState(),V=c.useCallback(I=>{P(I),v?.(I)},[v]),Z=c.useCallback(I=>{L(I)},[]),A=c.useCallback(()=>{O&&a?.(O)},[O,a]),G=c.useCallback(()=>{y.length>0&&o?.(y)},[o,y]),z=c.useCallback(()=>{r?.()},[r]),X=c.useCallback(()=>{O&&s?.(w.getPath(O.filename))},[O,s]),ve=c.useCallback(()=>{O&&g(O)},[O]),R=c.useCallback(()=>{g(void 0)},[]),$=c.useCallback(I=>{S&&(h?.(S,I),g(void 0))},[h,S]),H=c.useMemo(()=>{if(S)return[];var I=[];return r&&I.push({title:"New File",description:"Create new file",action:z,group:k.groups.medium}),s&&I.push({title:"New Folder",description:"Create new folder",action:X,group:k.groups.medium}),a&&I.push({title:"Copy File",description:"Copy the selected file",action:A,group:k.groups.low,disabled:O==null||De(O)}),o&&y.length>0&&I.push({title:"Delete",description:"Delete",shortcut:Ei.FILE_EXPLORER.DELETE,action:G,group:k.groups.low}),h&&I.push({title:"Rename",description:"Rename",shortcut:Ei.FILE_EXPLORER.RENAME,action:ve,group:k.groups.low,disabled:O==null}),I},[A,G,z,X,ve,O,a,r,s,o,h,y,S]),N=c.useCallback(I=>(D(S),E(S,I)),[S,E]),F=c.useCallback(I=>{var{item:oe}=I;return S&&S.filename===oe.filename?l.jsx(Tn,gn(gn({},I),{},{children:l.jsx(kl,{item:oe,validate:N,onSubmit:$,onCancel:R})})):l.jsx(Tn,gn({},I))},[R,$,S,N]);return l.jsxs("div",{className:"file-list-container",children:[m!=null&&l.jsx(Al,{onMove:d,onSelect:u,onSelectionChange:V,onFocusChange:Z,renderItem:F,rowHeight:p,table:m,isMultiSelect:e,focusedPath:t}),n&&l.jsx(k,{actions:H})]})}Er.displayName="FileListContainer";function Pi(i,e,t){return e=Bl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Bl(i){var e=Vl(i,"string");return typeof e=="symbol"?e:String(e)}function Vl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Wl extends wt{constructor(e){super("Name already exists"),Pi(this,"isExistingFile",!0),Pi(this,"info",void 0),this.info=e}}const zt=Wl;function Oi(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function wi(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){Oi(s,n,r,a,o,"next",d)}function o(d){Oi(s,n,r,a,o,"throw",d)}a(void 0)})}}var Ie=Q.module("FileExplorer");function Fn(i){var{storage:e,isMultiSelect:t=!1,focusedPath:n,onCopy:r=()=>{},onDelete:s=()=>{},onRename:a=()=>{},onCreateFile:o=()=>{},onCreateFolder:d=()=>{},onSelect:h,onSelectionChange:u,rowHeight:v=Mn}=i,[m,p]=c.useState([]),[E,S]=c.useState();c.useEffect(function(){var $;function H(){return N.apply(this,arguments)}function N(){return N=wi(function*(){Ie.debug("initTable"),$=ce.makeCancelable(e.getTable(),F=>F.close());try{S(yield $)}catch(F){ce.isCanceled(F)||Ie.error("Unable to initialize table",F)}}),N.apply(this,arguments)}return H(),()=>{$.cancel()}},[e]);var g=c.useCallback(R=>{ce.isCanceled(R)||Ie.error(R)},[]),y=c.useCallback(()=>{Ie.debug("handleCreateFile"),o()},[o]),P=c.useCallback(()=>{Ie.debug("handleCreateFolder"),d()},[d]),O=c.useCallback(R=>{Ie.debug("handleCopyFile",R.filename),r(R)},[r]),L=c.useCallback(R=>{Ie.debug("handleDelete, pending confirmation",R),p(R)},[]),V=c.useCallback(()=>{Ie.debug("handleDeleteConfirm",m),m.forEach(R=>e.deleteFile(De(R)?w.makePath(R.filename):R.filename)),s(m),p([])},[m,s,e]),Z=c.useCallback(()=>{Ie.debug("handleDeleteCancel"),p([])},[]),A=c.useCallback((R,$)=>{var H=w.reducePaths(R.map(N=>De(N)?w.makePath(N.filename):N.filename));H.forEach(N=>{var F=w.isPath(N)?"".concat($).concat(w.getBaseName(N.substring(0,N.length-1)),"/"):"".concat($).concat(w.getBaseName(N));e.moveFile(N,F).then(()=>{a(N,F)}).catch(g)})},[g,a,e]),G=c.useCallback((R,$)=>{var H=R.filename,N=De(R);N&&!H.endsWith("/")&&(H="".concat(H,"/"));var F="".concat(w.getParent(H)).concat($);N&&!F.endsWith("/")&&(F="".concat(F,"/")),Ie.debug2("handleRename",H,F),e.moveFile(H,F).catch(g),a(H,F)},[g,a,e]),z=c.useCallback(function(){var R=wi(function*($,H){if(H!==$.basename){w.validateName(H);var N="".concat(w.getPath($.filename)).concat(H);try{var F=yield e.info(N);throw new zt(F)}catch(I){if(!(I instanceof In))throw I}}});return function($,H){return R.apply(this,arguments)}}(),[e]),X=m.length>0,ve=c.useMemo(()=>m.length===1?'Are you sure you want to delete "'.concat(m[0].filename,'"?'):"Are you sure you want to delete the selected files?",[m]);return l.jsxs("div",{className:"file-explorer",children:[E&&l.jsx(Er,{isMultiSelect:t,focusedPath:n,showContextMenu:!0,onCopy:O,onCreateFolder:P,onCreateFile:y,onMove:A,onDelete:L,onRename:G,onSelect:h,onSelectionChange:u,rowHeight:v,table:E,validateRename:z}),l.jsx(Lt,{isOpen:X,headerText:ve,bodyText:"You cannot undo this action.",onCancel:Z,onConfirm:V,confirmButtonText:"Delete"})]})}Fn.displayName="FileExplorer";function Ni(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function Kl(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){Ni(s,n,r,a,o,"next",d)}function o(d){Ni(s,n,r,a,o,"throw",d)}a(void 0)})}}function qe(i,e,t){return e=zl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function zl(i){var e=Gl(i,"string");return typeof e=="symbol"?e:String(e)}function Gl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var tt=Q.module("NewItemModal");class at extends c.PureComponent{static getValidationMessage(e){return e instanceof zt&&e.info.type==="directory"?"Error: Cannot overwrite existing directory":"".concat(e)}static handleError(e){ce.isCanceled(e)||tt.error(e)}constructor(e){super(e),qe(this,"inputRef",se.createRef()),qe(this,"cancelableValidatePromise",void 0),qe(this,"cancelableExistingItemPromise",void 0),qe(this,"pending",new pt),qe(this,"pathMap",new Map),qe(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);var{defaultValue:t}=e,n=w.hasPath(t)?w.getPath(t):"/";this.state={isSubmitting:!1,path:n,prevExtension:w.getExtension(t),showExtensionChangeModal:!1,showOverwriteModal:!1,value:w.getBaseName(t)}}componentDidUpdate(e,t){var{isOpen:n}=this.props,{isOpen:r}=e,{value:s,path:a}=this.state;!r&&n&&(this.resetValue(),this.isInitialLoad=!0),r&&n&&(!this.isInitialLoad&&(a!==t.path||s!==t.value)&&this.updateValidationStatus(a,s),this.isInitialLoad=!1)}componentWillUnmount(){this.pending.cancel(),this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableExistingItemPromise&&this.cancelableExistingItemPromise.cancel()}resetValue(){var{defaultValue:e}=this.props,t=w.hasPath(e)?w.getPath(e):"/";this.setState({path:t,value:w.getBaseName(e),validationError:void 0,prevExtension:w.getExtension(e),isSubmitting:!1})}getValidationPromise(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableValidatePromise=ce.makeCancelable(this.validateName(e,t,n)),this.cancelableValidatePromise}validateName(e,t,n){var r=this;return Kl(function*(){w.validateName(t);var{defaultValue:s,storage:a}=r.props;if(n){var o="".concat(e).concat(t);if(o!==s)try{var d=yield a.info(o);throw new zt(d)}catch(h){if(!(h instanceof In))throw h}}return t})()}updateValidationStatus(e,t){this.getValidationPromise(e,t).then(()=>{this.setState({validationError:void 0})}).catch(this.handleValidationError).catch(at.handleError)}handleModalOpened(){this.focusRenameInput()}handleModalSubmit(){this.submitModal()}handleChange(e){var{value:t}=e.target;this.setState({value:t})}handleSelect(e){if(tt.debug("handleSelect",e),e.type==="directory")this.setState({path:w.makePath(e.filename)});else{var t=e.basename,n=w.getPath(e.filename);this.setState({value:t,path:n},()=>{this.focusRenameInput()})}}handleKeyDown(e){var{key:t}=e;switch(e.stopPropagation(),t){case"Enter":{e.preventDefault(),this.submitModal();break}case"Escape":{e.preventDefault();var{onCancel:n}=this.props;n();break}}}handleValidationError(e){if(!(e instanceof wt))throw e;tt.debug("Validation error",e),this.setState({validationError:e})}handleOverwriteCancel(){this.setState({showOverwriteModal:!1,isSubmitting:!1})}handleOverwriteConfirm(){this.setState({showOverwriteModal:!1});var{onSubmit:e}=this.props,{path:t,value:n}=this.state;tt.debug("handleOverwriteConfirm",t,n),e("".concat(t).concat(n),!0)}handleExtensionChangeCancel(){tt.debug("handleExtensionChangeCancel"),this.setState(e=>{var{value:t,prevExtension:n}=e,r=w.replaceExtension(t,n);return{showExtensionChangeModal:!1,value:r}}),this.submitModal(!0)}handleExtensionChangeConfirm(){tt.debug("handleExtensionChangeConfirm"),this.setState({showExtensionChangeModal:!1}),this.submitModal(!0)}focusRenameInput(){var e=this.inputRef.current;if(e){var{type:t}=this.props,{value:n}=e,r=t==="directory"?n.length:n.lastIndexOf(".");e.focus(),e.setSelectionRange(0,r>0?r:n.length)}}submitModal(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.setState(t=>{var{prevExtension:n,value:r,path:s}=t,{notifyOnExtensionChange:a,type:o}=this.props;tt.debug("submitModal",n,r);var d=w.getExtension(r);return a&&!e&&n!==null&&n!==d?{isSubmitting:!1,showExtensionChangeModal:!0,newExtension:d}:(this.getValidationPromise(s,r,!0).then(h=>{var{onSubmit:u}=this.props;u("".concat(s).concat(r))}).catch(h=>{if(h instanceof zt&&o!=="directory"&&h.info.type!=="directory"){this.setState({showOverwriteModal:!0});return}throw h}).catch(h=>{throw ce.isCanceled(h)&&this.setState({isSubmitting:!1}),h}).catch(this.handleValidationError).catch(at.handleError),{isSubmitting:!0,showExtensionChangeModal:!1,newExtension:void 0})})}handleBreadcrumbSelect(e){this.setState({path:e})}renderPathButtons(e){var t=e.split("/");return t.pop(),t.map((n,r)=>{for(var s="",a=0;a<r;a+=1)s+="".concat(t[a],"/");return s+="".concat(n,"/"),l.jsxs(se.Fragment,{children:[l.jsx(K,{kind:"ghost",className:"directory-breadcrumbs",onClick:()=>this.handleBreadcrumbSelect(s),"aria-label":r===0?"Home":void 0,icon:r===0?l.jsx(re,{icon:Jr,transform:"right-1.6"}):void 0,tooltip:r===0?"Home":void 0,children:n}),"/"]},s)})}render(){var{storage:e,isOpen:t,onCancel:n,placeholder:r,title:s,type:a}=this.props,{isSubmitting:o,path:d,showExtensionChangeModal:h,showOverwriteModal:u,validationError:v,value:m,prevExtension:p,newExtension:E}=this.state,S=a==="directory",g=w.fileExtensionToString(p),y=w.fileExtensionToString(E),P=S?"Create":"Save",O=S?"New folder name":"Save file as";return l.jsxs(l.Fragment,{children:[l.jsxs(es,{isOpen:t,toggle:n,onOpened:this.handleModalOpened,className:"modal-dialog-centered new-file-modal",children:[l.jsx(ts,{toggle:n,children:s}),l.jsx(ns,{children:l.jsx("form",{children:l.jsxs("div",{className:"d-flex flex-column new-file-modal-content",children:[l.jsxs("div",{className:"flex-grow-0 mb-4",children:[l.jsx("label",{htmlFor:"file-name-input",children:O}),l.jsx("input",{id:"file-name-input",type:"text",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:"false",className:ee("form-control",{"is-invalid":v}),value:m,placeholder:r,ref:this.inputRef,onKeyDown:this.handleKeyDown,onChange:this.handleChange}),v&&l.jsx("div",{className:"invalid-feedback",children:at.getValidationMessage(v)})]}),l.jsxs("div",{className:"flex-grow-0",children:[l.jsx("label",{children:"Directory: /"}),this.renderPathButtons(d)]}),l.jsx("div",{className:"flex-grow-1 file-explorer-container",children:l.jsx(Fn,{onSelect:this.handleSelect,storage:e,focusedPath:d})})]})})}),l.jsxs(js,{children:[l.jsx(K,{kind:"secondary",onClick:n,children:"Cancel"}),l.jsx(K,{kind:"primary",disabled:o,onClick:this.handleModalSubmit,children:P})]})]}),l.jsx(Lt,{isOpen:u,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"}),l.jsx(Lt,{isOpen:h,headerText:"Confirm extension change",bodyText:'Are you sure you want to change extension from "'.concat(g,'" to "').concat(y,'"?'),onCancel:this.handleExtensionChangeCancel,onConfirm:this.handleExtensionChangeConfirm,cancelButtonText:'Keep "'.concat(g,'"'),confirmButtonText:'Use "'.concat(y,'"')})]})}}qe(at,"propTypes",{isOpen:Me.bool,title:Me.string.isRequired,defaultValue:Me.string,type:Me.oneOf(["file","directory"]).isRequired,onSubmit:Me.func,onCancel:Me.func,placeholder:Me.string,storage:Me.shape({}).isRequired,notifyOnExtensionChange:Me.bool});qe(at,"defaultProps",{isOpen:!1,defaultValue:"/",notifyOnExtensionChange:!1,placeholder:"",onSubmit:(i,e)=>{},onCancel:()=>{}});const yr=at;function Yl(i){var{createFile:e,createFolder:t,onSearchChange:n,defaultSearchText:r=""}=i;return l.jsxs("div",{className:"file-explorer-toolbar",children:[l.jsxs("div",{className:"file-explorer-toolbar-buttons",children:[l.jsx(K,{kind:"ghost",icon:zi,tooltip:"New notebook",onClick:e,"aria-label":"New notebook"}),l.jsx(K,{kind:"ghost",icon:is,tooltip:"New folder",onClick:t,"aria-label":"New folder"})]}),n&&l.jsx("div",{className:"file-explorer-toolbar-search",children:l.jsx(_s,{value:r,onChange:n,placeholder:"Search by name"})})]})}function xi(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function ql(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){xi(s,n,r,a,o,"next",d)}function o(d){xi(s,n,r,a,o,"throw",d)}a(void 0)})}}function Tr(i,e,t){return e=Zl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Zl(i){var e=Xl(i,"string");return typeof e=="symbol"?e:String(e)}function Xl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var nt=Q.module("FileExplorerPanel"),Ql=(i,e)=>{var t=cr(i),n=jt(i,e.localDashboardId),{session:r,config:s}=n??{},a=s?.type;return{fileStorage:t,language:a,session:r}},Jl=It(Ql,null,null,{forwardRef:!0});function ed(i){var e=i;return e!=null&&typeof e.button=="number"}class mt extends se.Component{static handleError(e){nt.error(e)}static isFocusEvent(e){return ed(e)?e.detail>=2:!0}constructor(e){super(e),this.handleFileSelect=this.handleFileSelect.bind(this),this.handleCopyFile=this.handleCopyFile.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);var{session:t,language:n}=e;this.state={isShown:!1,language:n,session:t,showCreateFolder:!1,focusedFilePath:"/"}}componentDidMount(){this.isHidden()||this.setState({isShown:!0})}handleCreateFile(){var{glEventHub:e}=this.props,{session:t,language:n}=this.state,r={language:n,value:""};nt.debug("handleCreateFile",t,n,r),e.emit(W.CREATE_NOTEBOOK,t,n,r)}handleCreateDirectory(){this.setState({showCreateFolder:!0})}handleCreateDirectoryCancel(){nt.debug("handleCreateDirectoryCancel"),this.setState({showCreateFolder:!1})}handleCreateDirectorySubmit(e){nt.debug("handleCreateDirectorySubmit",e),this.setState({showCreateFolder:!1});var{fileStorage:t}=this.props;t.createDirectory(e).catch(mt.handleError)}handleCopyFile(e){var t=this;return ql(function*(){var{fileStorage:n}=t.props;if(De(e)){nt.error("Invalid item in handleCopyItem",e);return}var r=yield w.getUniqueCopyFileName(n,e.filename);yield n.copyFile(e.filename,r)})()}handleDelete(e){var{glEventHub:t}=this.props;e.forEach(n=>{t.emit(W.CLOSE_FILE,{id:n.filename,itemName:n.filename})})}handleSelectionChange(e){var t="/";e.length===1&&(e[0].type==="directory"?t=w.makePath(e[0].filename):t=w.getPath(e[0].filename)),this.setState({focusedFilePath:t})}handleFileSelect(e,t){if(nt.debug("fileSelect",e),e.type!=="directory"){var n=mt.isFocusEvent(t),r={id:e.filename,itemName:e.filename},{glEventHub:s}=this.props,{session:a,language:o}=this.state,d={value:null,language:o};s.emit(W.SELECT_NOTEBOOK,a,o,d,r,n)}}handleRename(e,t){var{glEventHub:n}=this.props;nt.debug("handleRename",e,t),n.emit(W.RENAME_FILE,e,t)}handleSessionOpened(e,t){var{language:n}=t;this.setState({session:e,language:n})}handleSessionClosed(){this.setState({session:void 0,language:void 0})}handleShow(){this.setState({isShown:!0})}isHidden(){var{glContainer:e}=this.props,{isHidden:t}=e;return t}render(){var{fileStorage:e,glContainer:t,glEventHub:n}=this.props,{isShown:r,showCreateFolder:s,focusedFilePath:a}=this.state;return l.jsxs(At,{className:"file-explorer-panel",componentPanel:this,glContainer:t,glEventHub:n,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[l.jsx(Yl,{createFile:this.handleCreateFile,createFolder:this.handleCreateDirectory}),r&&l.jsx(Fn,{isMultiSelect:!0,storage:e,onCopy:this.handleCopyFile,onCreateFile:this.handleCreateFile,onCreateFolder:this.handleCreateDirectory,onDelete:this.handleDelete,onRename:this.handleRename,onSelect:this.handleFileSelect,onSelectionChange:this.handleSelectionChange}),l.jsx(yr,{isOpen:s,type:"directory",title:"Create New Folder",storage:e,onSubmit:this.handleCreateDirectorySubmit,onCancel:this.handleCreateDirectoryCancel,defaultValue:a})]})}}Tr(mt,"COMPONENT","FileExplorerPanel");Tr(mt,"TITLE","File Explorer");var td=Jl(mt);const nd=td;function Rt(i,e,t){return e=id(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function id(i){var e=rd(i,"string");return typeof e=="symbol"?e:String(e)}function rd(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Di=Q.module("LogPanel");class an extends c.PureComponent{constructor(e){super(e),Rt(this,"isBottomVisible",void 0),Rt(this,"logView",void 0),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;var{session:t}=this.props;this.state={session:t}}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){Di.debug("Session opened",[e]),this.setState({session:e})}handleSessionClosed(e){Di.debug("Session closed",e)}updateDimensions(){this.logView&&this.logView.updateDimensions()}render(){var{glContainer:e,glEventHub:t}=this.props,{session:n}=this.state;return l.jsxs(At,{componentPanel:this,glContainer:e,glEventHub:t,onResize:this.handleResize,onHide:this.handleHide,onShow:this.handleShow,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,children:[n==null&&l.jsx("div",{className:"log-panel-disconnected-message",children:"Waiting for session connection"}),n!=null&&l.jsx(co,{session:n,ref:r=>{this.logView=r}})]})}}Rt(an,"defaultProps",{session:null});Rt(an,"COMPONENT","LogPanel");Rt(an,"TITLE","Log");var sd=(i,e)=>{var t;return{session:(t=jt(i,e.localDashboardId))===null||t===void 0?void 0:t.session}},ad=It(sd,null,null,{forwardRef:!0})(an);const od=ad;function Gt(i,e,t){return e=ld(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ld(i){var e=dd(i,"string");return typeof e=="symbol"?e:String(e)}function dd(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Pr extends c.PureComponent{constructor(e){super(e),Gt(this,"commands",void 0),Gt(this,"codeElements",void 0),Gt(this,"editorScrollView",void 0),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=se.createRef(),this.state={hasCode:!1,hasRunCode:!1,nextStartLine:null}}componentDidMount(){this.updateHasCode()}componentDidUpdate(){this.updateHasCode()}updateHasCode(){var{hasCode:e}=this.state;this.commands.size===0&&e?this.setState({hasCode:!1}):this.commands.size>0&&!e&&this.setState({hasCode:!0})}getNextStartLine(e){var t=[...this.commands.keys()],n=t.findIndex(r=>r===e)+1;return n>=t.length?null:t[n]}handleRunSelected(e){var t,n;e.preventDefault(),e.stopPropagation();var{nextStartLine:r}=this.state,s=[...this.commands.keys()],a=s.findIndex(S=>S===r||r==null);if(!(a<0)){var o=s[a],d=this.commands.get(o),h=this.getNextStartLine(o),u=(t=this.codeElements.get(o))===null||t===void 0?void 0:t.current,v=u==null||(n=u.parentElement)===null||n===void 0?void 0:n.nextElementSibling;if(v!=null){var m,{offsetTop:p}=v,E=p;(m=this.editorScrollView.current)===null||m===void 0||m.scroll({top:E,left:0})}this.runCode(d),this.setState({nextStartLine:h})}}runCode(e){var{onRunCode:t}=this.props;t(e),this.setState({hasRunCode:!0})}renderCodeBlock(e){var{children:t,className:n,inline:r,node:s}=e,{hasRunCode:a,nextStartLine:o}=this.state,{children:d,position:h}=s;D(h);var{start:u}=h,{line:v}=u,m=d[0].value,p=se.createRef(),E=this.commands.size===0,S=o===v||E&&o==null&&!a,g=n!==void 0&&n.startsWith("language-")?n.substring(9):"plaintext";return r!=null&&r?l.jsx("code",{className:n,children:t}):(this.commands.set(v,m),this.codeElements.set(v,p),l.jsxs("div",{className:ee("markdown-notebook-code-block",{"is-selected":S}),ref:p,onClick:()=>{this.setState({nextStartLine:v})},role:"presentation",children:[l.jsx(K,{kind:"ghost",icon:Yt,className:"btn-play-block",onClick:y=>{y.stopPropagation(),y.preventDefault(),this.runCode(m),this.setState({nextStartLine:v})},tooltip:"Run code"}),l.jsx("code",{children:l.jsx(xn,{language:g,children:se.Children.map(t,y=>typeof y=="string"?y.trim():y)})})]}))}renderLink(e){var{onLinkClick:t}=this.props,{href:n,children:r,target:s}=e;return l.jsx("a",{href:n,onClick:t,target:s,children:r})}render(){var{content:e,transformImageUri:t,transformLinkUri:n}=this.props,{hasCode:r,hasRunCode:s,nextStartLine:a}=this.state;return l.jsxs("div",{className:"markdown-notebook",children:[l.jsx("div",{className:"markdown-notebook-toolbar",children:l.jsx(K,{className:ee("btn-play-selected-cell",{flashing:r&&!s}),kind:"ghost",icon:Yt,onClick:this.handleRunSelected,tooltip:"Run code and select next",disabled:s&&a==null||!r,children:"Run Selected Code"})}),l.jsx("div",{className:"markdown-notebook-content",ref:this.editorScrollView,children:l.jsx(Mr,{components:{code:this.renderCodeBlock,a:this.renderLink},linkTarget:"_blank",remarkPlugins:[Fr],transformLinkUri:n,transformImageUri:t,includeElementIndex:!0,children:e})})]})}}Gt(Pr,"defaultProps",{onRunCode:()=>{}});const hd=Pr;function Li(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function Ri(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){Li(s,n,r,a,o,"next",d)}function o(d){Li(s,n,r,a,o,"throw",d)}a(void 0)})}}function Ii(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Se(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ii(Object(t),!0).forEach(function(n){ue(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Ii(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function ue(i,e,t){return e=ud(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ud(i){var e=cd(i,"string");return typeof e=="symbol"?e:String(e)}function cd(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var _=Q.module("NotebookPanel"),Mi=400;class le extends c.Component{static handleError(e){ce.isCanceled(e)||_.error(e)}static unsavedNotebookCount(){return document.querySelectorAll(".".concat(le.UNSAVED_INDICATOR_CLASS_NAME,".").concat(le.UNSAVED_STATUS_CLASS_NAME)).length}static languageFromFileName(e){var t=w.getExtension(e).toLowerCase();switch(t){case"py":case"python":return"python";case"groovy":return"groovy";case"scala":return"scala";default:return null}}constructor(e){super(e),ue(this,"pending",void 0),ue(this,"debouncedSavePanelState",void 0),ue(this,"debouncedLoad",void 0),ue(this,"notebook",void 0),ue(this,"tabTitleElement",void 0),ue(this,"tabInitOnce",void 0),ue(this,"editor",void 0),ue(this,"getSettings",_e((m,p)=>Se(Se({},m),{},{minimap:{enabled:p}}))),ue(this,"getOverflowActions",_e((m,p)=>[{title:"Find",icon:as,action:this.handleFind,group:k.groups.high,shortcut:be.NOTEBOOK.FIND,order:10},{title:"Copy File",icon:os,action:this.handleCopy,group:k.groups.medium,order:20},{title:"Rename File",icon:ls,action:this.handleShowRename,group:k.groups.medium,order:30},{title:"Delete File",icon:Vi,action:this.handleDelete,group:k.groups.medium,order:40},{title:"Show Minimap",icon:m?Pt:void 0,action:this.handleMinimapChange,group:k.groups.low,shortcut:be.NOTEBOOK.MINIMAP,order:20},{title:"Word Wrap",icon:p?Pt:void 0,action:this.handleWordWrapChange,group:k.groups.low,shortcut:be.NOTEBOOK.WORDWRAP,order:30}])),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.handleDelete=this.handleDelete.bind(this),this.handleDeleteConfirm=this.handleDeleteConfirm.bind(this),this.handleDeleteCancel=this.handleDeleteCancel.bind(this),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorWillDestroy=this.handleEditorWillDestroy.bind(this),this.handleEditorChange=this.handleEditorChange.bind(this),this.handleFind=this.handleFind.bind(this),this.handleMinimapChange=this.handleMinimapChange.bind(this),this.handleWordWrapChange=this.handleWordWrapChange.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.handlePanelDropped=this.handlePanelDropped.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.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabClick=this.handleTabClick.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleTransformLinkUri=this.handleTransformLinkUri.bind(this),this.handleOverwrite=this.handleOverwrite.bind(this),this.handlePreviewPromotion=this.handlePreviewPromotion.bind(this),this.getDropdownOverflowActions=this.getDropdownOverflowActions.bind(this),this.pending=new pt,this.debouncedSavePanelState=Dt(this.savePanelState.bind(this),Mi),this.debouncedLoad=Dt(this.load.bind(this),Mi),this.notebook=null,this.tabTitleElement=null,this.tabInitOnce=!1;var{isDashboardActive:t,session:n,sessionLanguage:r,panelState:s}=e,a={value:"",language:"",wordWrap:"off"},o=null,{isPreview:d}=e;s!=null&&({fileMetadata:o=o,isPreview:d=d,settings:a=a}=s);var h=o!=null&&w.hasPath(o.itemName),u=h===!0&&a.value!=null||!h&&a.value!=null&&a.value.length>0,v=u?1:0;this.state={error:void 0,isDashboardActive:t,isFocused:!1,isLoading:!0,isLoaded:!1,isPreview:d,savedChangeCount:0,changeCount:v,fileMetadata:o,settings:a,session:n,sessionLanguage:r,panelState:{fileMetadata:o,settings:a},showCloseModal:!1,showDeleteModal:!1,showSaveAsModal:!1,scriptCode:""},_.debug("constructor",e,this.state)}componentDidMount(){var{glContainer:e,glEventHub:t}=this.props,{tab:n}=e;n!=null&&this.initTab(n),this.initNotebookContent(),t.on(W.RENAME_FILE,this.handleRenameFile),t.on(xe.DROPPED,this.handlePanelDropped),e.on(W.PROMOTE_FROM_PREVIEW,this.handlePreviewPromotion)}componentDidUpdate(e,t){var{isPreview:n,settings:r}=this.state,{wordWrap:s}=r,{defaultNotebookSettings:a}=this.props;n!==t.isPreview&&this.setPreviewStatus(),s!==t.settings.wordWrap&&(this.updateEditorWordWrap(),this.debouncedSavePanelState()),a.isMinimapEnabled!==e.defaultNotebookSettings.isMinimapEnabled&&this.updateEditorMinimap()}componentWillUnmount(){this.debouncedSavePanelState.flush(),this.pending.cancel();var{glEventHub:e,glContainer:t}=this.props,{fileMetadata:n,isPreview:r}=this.state;e.off(W.RENAME_FILE,this.handleRenameFile),e.off(xe.DROPPED,this.handlePanelDropped),t.off(W.PROMOTE_FROM_PREVIEW,this.handlePreviewPromotion),e.emit(W.UNREGISTER_FILE,n,r)}initTab(e){this.tabInitOnce||(this.tabInitOnce=!0,this.initTabCloseOverride()),this.initTabClasses(e)}initTabCloseOverride(){var{glContainer:e}=this.props;e.beforeClose(t=>{if(t?.force===!0)return!0;var{changeCount:n,savedChangeCount:r}=this.state;return n!==r?(this.setState({showCloseModal:!0}),!1):!0})}initTabClasses(e){var t=e.element.get(0);D(t);var n=t.querySelector(".lm_title");this.tabTitleElement=n,n?.classList.add("notebook-title"),this.setPreviewStatus()}getNotebookValue(){var{changeCount:e,savedChangeCount:t,settings:n}=this.state,{value:r}=n;if(e!==t&&this.notebook){var s=this.notebook.getValue();return s??r}return r}initNotebookContent(){var{fileMetadata:e,settings:t,isPreview:n}=this.state;if(e&&e.id){_.debug("Init content from file"),this.registerFileMetadata(e,n),this.load();return}if(t.value!=null){_.debug("Use content passed in the settings prop"),this.handleLoadSuccess();return}this.handleLoadError(new Error("Missing file metadata"))}closeFileTabById(e){var{glEventHub:t}=this.props;t.emit(W.CLOSE_FILE,{id:e})}registerFileMetadata(e,t){var{glEventHub:n,metadata:r}=this.props,{id:s}=r;n.emit(W.REGISTER_FILE,s,e,t)}renameTab(e,t){var{glEventHub:n}=this.props;n.emit(W.RENAME,e,t)}load(){var{fileMetadata:e,settings:t}=this.state;D(e);var{id:n}=e,{fileStorage:r}=this.props;this.pending.add(r.loadFile(n)).then(s=>{var a;_.debug("Loaded file",s);var{filename:o}=s,{itemName:d}=this.state;if(o!==d){var{metadata:h}=this.props,{id:u}=h;this.renameTab(u,w.getBaseName(o))}var v=Se(Se({},t),{},{language:(a=le.languageFromFileName(o))!==null&&a!==void 0?a:""});t.value==null&&(v.value=s.content),t.wordWrap===void 0&&(t.wordWrap="off"),this.setState({fileMetadata:{id:o,itemName:o},settings:v}),this.debouncedSavePanelState()}).then(this.handleLoadSuccess).catch(this.handleLoadError)}save(){var{fileMetadata:e}=this.state;if(e&&w.hasPath(e.itemName)){var t=this.getNotebookValue();return t!==void 0?(this.saveContent(e.itemName,t),!0):!1}return this.setState({showSaveAsModal:!0}),!1}saveContent(e,t){_.debug("saveContent",e,t),this.updateSavedChangeCount();var{fileStorage:n}=this.props;this.pending.add(n.saveFile({filename:e,content:t,basename:e})).then(this.handleSaveSuccess).catch(this.handleSaveError)}updateSavedChangeCount(){this.setState(e=>{var{changeCount:t}=e;return{savedChangeCount:t}})}setPreviewStatus(){if(this.tabTitleElement){var{isPreview:e}=this.state;_.debug("setPreviewStatus",this.tabTitleElement,e),e?this.tabTitleElement.classList.add("is-preview"):this.tabTitleElement.classList.remove("is-preview")}}handlePreviewPromotion(){this.removePreviewStatus()}savePanelState(){this.setState(e=>{var{changeCount:t,savedChangeCount:n,fileMetadata:r,isPreview:s,settings:a}=e,o=this.getNotebookValue(),d=t!==n?o:void 0,h=Se(Se({},a),{},{value:o}),u=Se(Se({},a),{},{value:d}),v={settings:u,fileMetadata:r,isPreview:s};return _.debug("Saving panel state",v),{settings:h,panelState:v}})}handleCloseDiscard(){this.setState({showCloseModal:!1});var{glContainer:e}=this.props;e.close({force:!0})}handleCloseSave(){if(this.setState({showCloseModal:!1}),this.save()){var{glContainer:e}=this.props;e.close({force:!0})}}handleCloseCancel(){this.setState({showCloseModal:!1})}handleOverwrite(e){var{glEventHub:t}=this.props;t.emit(W.CLOSE_FILE,{id:e,itemName:e},{force:!0}),this.focus()}handleCopy(){var e=this;return Ri(function*(){var{fileStorage:t,glEventHub:n,session:r}=e.props,{fileMetadata:s,settings:a}=e.state;D(s);var{language:o}=a,{itemName:d}=s,h=yield w.getUniqueCopyFileName(t,d);_.debug("handleCopy",s,d,h),yield t.copyFile(d,h);var u={id:h,itemName:h},v={value:null,language:o};n.emit(W.SELECT_NOTEBOOK,r,o,v,u,!0)})()}handleDelete(){_.debug("handleDelete, pending confirmation"),this.setState({showDeleteModal:!0})}handleDeleteConfirm(){var e=this;return Ri(function*(){var{fileStorage:t,glContainer:n,glEventHub:r}=e.props,{fileMetadata:s}=e.state;_.debug("handleDeleteConfirm",s?.itemName),e.setState({showDeleteModal:!1}),s&&(w.hasPath(s.itemName)&&(yield w.fileExists(t,s.itemName))?(r.emit(W.CLOSE_FILE,s,{force:!0}),t.deleteFile(s.itemName)):n.close({force:!0}))})()}handleDeleteCancel(){this.setState({showDeleteModal:!1})}handleEditorInitialized(e){this.editor=e}handleEditorWillDestroy(){this.editor=void 0}handleEditorChange(e){_.debug2("handleEditorChanged",e),this.removePreviewStatus(),this.setState(t=>{var{changeCount:n,savedChangeCount:r}=t,{isUndoing:s,isRedoing:a}=e;return s?{changeCount:n-1,savedChangeCount:r}:!a&&n<r?{changeCount:n+1,savedChangeCount:0}:{changeCount:n+1,savedChangeCount:r}}),this.debouncedSavePanelState()}handleFind(){this.notebook&&this.notebook.toggleFind()}updateEditorMinimap(){if(this.editor){var{defaultNotebookSettings:e}=this.props;this.editor.updateOptions({minimap:{enabled:e.isMinimapEnabled}})}}handleMinimapChange(){var e,{defaultNotebookSettings:t,updateSettings:n}=this.props,r={defaultNotebookSettings:{isMinimapEnabled:!((e=t.isMinimapEnabled)!==null&&e!==void 0&&e)}};n(r)}updateEditorWordWrap(){if(this.editor){var{settings:e}=this.state,{wordWrap:t}=e;this.editor.updateOptions({wordWrap:t})}}handleWordWrapChange(){this.editor&&this.setState(e=>{var{settings:t}=e,n=t.wordWrap==="on"?"off":"on";return{settings:Se(Se({},t),{},{wordWrap:n})}})}handleBlur(){_.debug("handleBlur"),this.setState({isFocused:!1})}handleFocus(){_.debug("handleFocus"),this.setState({isFocused:!0})}handleLinkClick(e){var{notebooksUrl:t,session:n,sessionLanguage:r}=this.props,{href:s}=e.currentTarget;if(!(!s||!s.startsWith(t))){e.stopPropagation(),e.preventDefault();var a="/".concat(s.substring(t.length)).replace(/%20/g," ");if(a==="/"){_.debug("Ignoring invalid notebook link",a);return}_.debug("Notebook link clicked, opening",a);var{glEventHub:o}=this.props,d={value:null,language:r},h={id:a,itemName:a};o.emit(W.SELECT_NOTEBOOK,n,r,d,h)}}handleLoadSuccess(){this.setState({error:void 0,isLoaded:!0,isLoading:!1})}handleLoadError(e){var t=e;ce.isCanceled(t)||(ce.isTimedOut(t)&&(t=new Error("File not found.")),_.error(t),this.setState({error:t,isLoading:!1}))}handleSave(){_.debug("handleSave"),this.save()}handleSaveSuccess(e){var t,{fileStorage:n}=this.props,r={id:e.filename,itemName:e.filename},s=(t=le.languageFromFileName(e.filename))!==null&&t!==void 0?t:"";this.setState(a=>{var{fileMetadata:o}=a,d=Se(Se({},a.settings),{},{language:s});return _.debug("handleSaveSuccess",r,o,d),o&&w.hasPath(o.itemName)&&o.itemName!==r.itemName&&(_.debug("handleSaveSuccess deleting old file",o.itemName),n.deleteFile(o.itemName).catch(le.handleError)),{fileMetadata:r,settings:d,isPreview:!1}}),this.debouncedSavePanelState(),this.registerFileMetadata(r,!1)}handleSaveError(e){ce.isCanceled(e)||(this.setState({savedChangeCount:0}),_.error(e))}handleSaveAsCancel(){this.setState({showSaveAsModal:!1})}handleSaveAsSubmit(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;n&&this.handleOverwrite(e),_.debug("handleSaveAsSubmit",e);var{fileMetadata:r}=this.state;if(r){var{itemName:s}=r,a=(t=this.getNotebookValue())!==null&&t!==void 0?t:"";if(this.setState({showSaveAsModal:!1}),w.getBaseName(s)!==w.getBaseName(e)){var{metadata:o}=this.props,{id:d}=o;this.renameTab(d,w.getBaseName(e))}this.saveContent(e,a)}}handleRenameFile(e,t,n){var{fileMetadata:r,panelState:s}=this.state,{glContainer:a}=this.props;if(r?.itemName==="/".concat(t)&&n&&JSON.stringify(s)!==JSON.stringify(n)){a.close();return}r&&r.id===e&&(this.setState({fileMetadata:{id:t,itemName:t}}),this.debouncedSavePanelState())}handleResize(){var e;(e=this.notebook)===null||e===void 0||e.updateDimensions()}handleRunCommand(e){this.runCommand(e)}handleRunAll(){var e;if(!this.notebook){_.error("Editor is not initialized.");return}this.runCommand((e=this.notebook.getValue())!==null&&e!==void 0?e:void 0)}handleRunSelected(){if(!this.notebook){_.error("Editor is not initialized.");return}this.runCommand(this.notebook.getSelectedCommand())}handleSessionOpened(e,t){var{language:n}=t;this.setState({session:e,sessionLanguage:n})}handleSessionClosed(){this.setState({session:void 0,sessionLanguage:void 0})}handleShow(){var e;_.debug("handleShow"),(e=this.notebook)===null||e===void 0||e.updateDimensions()}handlePanelDropped(e){var{metadata:{id:t}}=this.props;e===t&&this.forceUpdate()}handleShowRename(){this.setState({showSaveAsModal:!0})}handleTab(e){_.debug("NotebookPanel tab event",e),this.initTab(e)}handleTabFocus(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];_.debug("handleTabFocus",...t);var{glContainer:r}=this.props;this.setState({isDashboardActive:!0}),this.notebook&&!r.isHidden&&this.notebook.updateDimensions()}handleTabBlur(){_.debug("handleTabBlur"),this.setState({isDashboardActive:!1})}handleTabClick(e){_.debug("handle NotebookPanel tab click"),this.focus(),e.detail===2&&this.removePreviewStatus()}handleTransformLinkUri(e){var{notebooksUrl:t}=this.props,{fileMetadata:n}=this.state;if(e.endsWith("/"))return e;if(e.startsWith("/"))return"".concat(t).concat(e.substring(1));var r=n?.itemName;if(r===void 0)return e;r.charAt(0)==="/"&&(r=r.substring(1));var s=new URL(r,t);return new URL(e,s).href}focus(){requestAnimationFrame(()=>{this.notebook&&this.notebook.focus()})}createNotebook(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",{glEventHub:r}=this.props,{session:s,sessionLanguage:a,settings:o}=this.state,d=Se(Se({},o),{},{language:t,value:n}),h={id:null,itemName:e};_.debug("handleCreateNotebook",s,a,d,h),r.emit(W.CREATE_NOTEBOOK,s,a,d,h)}runCommand(e){if(e===void 0||e===""){_.debug("Ignoring empty command.");return}this.removePreviewStatus();var{glEventHub:t}=this.props;t.emit(we.SEND_COMMAND,e,!1,!0)}removePreviewStatus(){this.setState(e=>{var{isPreview:t}=e;if(t){var{fileMetadata:n}=this.state;return n&&this.registerFileMetadata(n,!1),{isPreview:!1}}return null})}getDropdownOverflowActions(){var e,t,{defaultNotebookSettings:n}=this.props,{settings:r}=this.state;return this.getOverflowActions((e=n.isMinimapEnabled)!==null&&e!==void 0?e:!1,this.getSettings(r,(t=n.isMinimapEnabled)!==null&&t!==void 0?t:!1).wordWrap==="on")}render(){var e,t,n,{fileStorage:r,glContainer:s,glContainer:{tab:a},glEventHub:o,defaultNotebookSettings:d}=this.props,{changeCount:h,savedChangeCount:u,error:v,isDashboardActive:m,isLoaded:p,isLoading:E,isPreview:S,fileMetadata:g,session:y,sessionLanguage:P,settings:O,showCloseModal:L,showDeleteModal:V,showSaveAsModal:Z}=this.state,A=m&&!s.isHidden&&!S,G=(e=g?.itemName)!==null&&e!==void 0?e:le.DEFAULT_NAME,z=G.endsWith(".md"),X=g?.id!=null,ve=this.getSettings(O,(t=d.isMinimapEnabled)!==null&&t!==void 0?t:!1),R=y!=null,$=P===ve.language,H=!p||!R||!$,N=!p,F=[{action:this.handleSave,shortcut:qt.SAVE},{action:this.handleMinimapChange,shortcut:be.NOTEBOOK.MINIMAP},{action:this.handleWordWrapChange,shortcut:be.NOTEBOOK.WORDWRAP}],I=Sn.getDisabledRunTooltip(R,$,"Notebook extension","Run"),oe=Sn.getDisabledRunTooltip(R,$,"Notebook extension","Run Selected"),ze=[{title:X?"Rename":"Save As…",order:10,group:k.groups.high,action:this.handleShowRename},{title:"Copy File",action:this.handleCopy,group:k.groups.high,order:20}],Ge=a?.element.find(".lm_title_before").get(0);return l.jsxs(l.Fragment,{children:[Ge!=null&&ki.createPortal(l.jsx("span",{className:ee(le.UNSAVED_INDICATOR_CLASS_NAME,{[le.UNSAVED_STATUS_CLASS_NAME]:h!==u})}),Ge),l.jsxs(At,{className:"notebook-container",componentPanel:this,glContainer:s,glEventHub:o,onTab:this.handleTab,onResize:this.handleResize,onShow:this.handleShow,onTabClicked:this.handleTabClick,onTabFocus:this.handleTabFocus,onTabBlur:this.handleTabBlur,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onFocus:this.handleFocus,onBlur:this.handleBlur,additionalActions:ze,renderTabTooltip:()=>G,children:[!z&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"notebook-toolbar",children:[l.jsxs("span",{children:[l.jsx(K,{kind:"ghost",className:"btn-play",onClick:this.handleRunAll,disabled:H,icon:l.jsx(re,{icon:Yt,transform:"grow-4"}),tooltip:"Run ".concat(be.NOTEBOOK.RUN.getDisplayText()),"aria-label":"Run"}),I!=null&&l.jsx(ot,{children:I})]}),l.jsxs("span",{children:[l.jsx(K,{kind:"ghost",className:"btn-play",onClick:this.handleRunSelected,disabled:H,icon:l.jsx(re,{icon:rs,transform:"grow-4"}),tooltip:"Run Selected ".concat(be.NOTEBOOK.RUN_SELECTED.getDisplayText()),"aria-label":"Run Selected"}),oe!=null&&l.jsx(ot,{children:oe})]}),l.jsx(K,{kind:"ghost",className:"mr-auto",disabled:N,onClick:this.handleSave,icon:ss,tooltip:"Save ".concat(qt.SAVE.getDisplayText()),"aria-label":"Save"}),l.jsx(K,{kind:"ghost",className:"btn-overflow",disabled:N,icon:Ki,tooltip:"More Actions...",onClick:()=>{},children:l.jsx(Ot,{actions:this.getDropdownOverflowActions,popperOptions:le.POPPER_OPTIONS})})]}),l.jsx(Ya,{isLoaded:p,isLoading:E,error:v,onChange:this.handleEditorChange,onRunCommand:this.handleRunCommand,session:y,sessionLanguage:P,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy,settings:ve,focusOnMount:A,ref:f=>{this.notebook=f}})]}),z&&l.jsx(hd,{content:(n=ve.value)!==null&&n!==void 0?n:"",onLinkClick:this.handleLinkClick,onRunCode:this.handleRunCommand,transformImageUri:this.handleTransformLinkUri,transformLinkUri:this.handleTransformLinkUri}),l.jsx(yr,{isOpen:Z,type:"file",defaultValue:G,title:X?"Rename":"Save file as",onSubmit:this.handleSaveAsSubmit,onCancel:this.handleSaveAsCancel,notifyOnExtensionChange:!0,storage:r}),l.jsx(Lt,{isOpen:V,headerText:'Are you sure you want to delete "'.concat(G,'"?'),bodyText:"You cannot undo this action.",onCancel:this.handleDeleteCancel,onConfirm:this.handleDeleteConfirm,confirmButtonText:"Delete"}),l.jsx(Lt,{isOpen:L,headerText:"Do you want to save the changes you made to ".concat(G,"?"),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"}),l.jsx(k,{actions:F})]})]})}}ue(le,"COMPONENT","NotebookPanel");ue(le,"POPPER_OPTIONS",{placement:"bottom-end"});ue(le,"DEFAULT_NAME","Untitled");ue(le,"UNSAVED_INDICATOR_CLASS_NAME","editor-unsaved-indicator");ue(le,"UNSAVED_STATUS_CLASS_NAME","is-unsaved");ue(le,"defaultProps",{isDashboardActive:!0,isPreview:!1,session:null,sessionLanguage:null,defaultNotebookSettings:{isMinimapEnabled:!0}});var vd=(i,e)=>{var t=cr(i),n=Po(i),r=jt(i,e.localDashboardId),{session:s,config:a}=r??{},{type:o}=a??{};return{fileStorage:t,defaultNotebookSettings:n,session:s,sessionLanguage:o}},md=It(vd,{updateSettings:ks},null,{forwardRef:!0})(le);const it=md;function Fi(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Ai(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Fi(Object(t),!0).forEach(function(n){pd(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Fi(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function pd(i,e,t){return e=gd(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function gd(i){var e=fd(i,"string");return typeof e=="symbol"?e:String(e)}function fd(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var ie=Q.module("ConsolePlugin");function ji(i){return i.notebook!==void 0}function bd(i){$s(i)}function nh(i){bd(i);var{id:e,hydrateConsole:t,layout:n,panelManager:r,registerComponent:s,notebooksUrl:a}=i,o=c.useRef(0),[d,h]=c.useState(new Map),[u,v]=c.useState(new Map),m=Ar(),p=c.useCallback(()=>r.getLastUsedPanelOfType(pn),[r]),E=c.useCallback((f,b)=>{h(T=>new Map(T.set(f,b)))},[h]),S=c.useCallback(f=>{h(b=>(b.delete(f),new Map(b)))},[h]),g=c.useCallback((f,b)=>{v(T=>new Map(T.set(f,b)))},[v]),y=c.useCallback(f=>{v(b=>(b.delete(f),new Map(b)))},[v]),P=c.useCallback(function(f){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,x=f&&f.trim();if(!x)ie.info("Ignoring empty code");else{var j=p();if(!j||!(j instanceof pn.WrappedComponent)){ie.error("Console panel not found");return}ie.debug("Send command: ",f,b,T),j.addCommand(f,b,T)}},[p]),O=c.useCallback(f=>{m(ml(e,f))},[m,e]),L=c.useCallback(f=>{var{language:b}=f,T=b==="python"?"py":b,x=null;return T==null?(ie.debug("No extension for language",b),x="Untitled-".concat(o.current)):x="Untitled-".concat(o.current,".").concat(T),o.current+=1,x},[]),V=c.useCallback(function(f){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,{id:T}=f;if(T!=null&&d.has(T))return d.get(T);if(T!=null&&u.has(T))return u.get(T);if(b)return Hi.generate()},[d,u]),Z=c.useCallback((f,b)=>{ae.renameComponent(n.root,{id:f},b)},[n.root]),A=c.useCallback((f,b)=>{ie.debug("Rename file panel",f,b);var T;if(d.has(f)&&(T=d.get(f),S(f),T!=null&&E(b,T)),u.has(f)&&(T=u.get(f),y(f),T!=null&&g(b,T)),T===void 0){ie.debug2("File ".concat(f," isn't open, no need to rename the tab"));return}Z(T,w.getBaseName(b))},[d,u,Z,E,g,S,y]),G=c.useCallback(f=>{var b=V(f,!1);if(b==null){ie.error("Could not find panel id for file metadata",f);return}ae.activateTab(n.root,{id:b})},[V,n.root]),z=c.useCallback((f,b,T)=>{if(ie.debug("registerFilePanel",f,b,T),b==null||b.id==null){ie.debug("Ignore empty file id",b);return}var{id:x}=b;if(T){g(x,f);return}if(d.has(x)){var j=d.get(x);if(f===j){ie.debug("Update tab title for file ".concat(x));var{itemName:$e}=b;A(x,$e)}else ie.error("File ".concat(x," already associated with a different tab ").concat(j));return}E(x,f),u.has(x)&&y(x)},[d,u,A,E,g,y]),X=c.useCallback((f,b)=>{if(ie.debug("unregisterFileTab",f,b),f==null||f.id==null){ie.debug("Ignore empty file id",f);return}var{id:T}=f;if(b){y(T);return}S(T)},[S,y]),ve=c.useCallback((f,b)=>{ie.debug("closeFilePanel",f);var{id:T}=f,x=null,j=!1;if(d.has(T))x=d.get(T);else if(u.has(T))x=u.get(T),j=!0;else{ie.debug("File ".concat(T," isn't open, ignore close event"));return}X(f,j),ae.closeComponent(n.root,{id:x},b)},[n.root,d,u,X]),R=c.useCallback(f=>{var{itemName:b}=f;return w.getBaseName(b)},[]),$=c.useCallback(f=>{var{id:b}=f;return ie.debug("fileIsOpen",f,b,d),b!=null&&d.has(b)},[d]),H=c.useCallback(f=>{var{id:b}=f;return ie.debug("fileIsOpenAsPreview",f,b,u),b!=null&&u.has(b)},[u]),N=c.useCallback(f=>{if(f!=null){var b=r.getOpenedPanelById(f);b&&ji(b)&&b.focus()}},[r]),F=c.useCallback(f=>{var{id:b,settings:T,fileMetadata:x,session:j,sessionLanguage:$e,isPreview:C=!1}=f,M={settings:T,fileMetadata:x},B=R(x);return{type:"react-component",component:it.COMPONENT,isFocusOnShow:!1,props:{localDashboardId:e,metadata:{id:b},session:j,sessionLanguage:$e,panelState:M,isPreview:C,notebooksUrl:a},title:B,id:b}},[R,e,a]),I=c.useCallback(function(f,b,T){var x=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{id:null,itemName:L(T)},j=V(x);if($(x)&&j!=null){ie.debug("File is already open, focus panel"),G(x),N(j);return}var $e=ae.getStackForComponentTypes(n.root,[it.COMPONENT]),C=F({id:j,settings:T,fileMetadata:x,session:f,sessionLanguage:b});ie.debug("createNotebook",C,d),ae.openComponentInStack($e,C)},[$,N,L,V,n.root,F,d,G]),oe=c.useCallback(function(f,b,T,x){var j=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;ie.debug("selectNotebook",x,j);var $e=$(x),C=H(x),[M]=[...u.values()],B=!j,te=B&&M?M:V(x);if(te==null||te==="")throw new Error("Unable to retrieve or create panelId for metadata",x);if($e||C)G(x);else{var me=ae.getStackForComponentTypes(n.root,[it.COMPONENT]),Or=F({id:te,settings:T,fileMetadata:x,session:f,sessionLanguage:b,isPreview:B});ae.openComponentInStack(me,Or)}if(C&&j){var An=x.id,wr=ae.getStackForConfig(n.root,{component:it.COMPONENT,id:te}),ln=ae.getContentItemInStack(wr,{component:it.COMPONENT,id:te});ln&&Hs(ln)&&(ln.container.emit(W.PROMOTE_FROM_PREVIEW),y(An),E(An,te))}j&&N(te)},[G,$,H,N,V,n.root,F,u,y,E]),ze=c.useCallback(function(f,b){var T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},x=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,j=r.getLastUsedPanelOfType(it);j&&ji(j)?T!=null&&T.value!=null&&j.notebook!=null&&j.notebook.append(T.value):x&&I(f,b,T)},[I,r]),Ge=c.useCallback((f,b)=>Us.hydrate(Ai(Ai({},f),{},{notebooksUrl:a}),b),[a]);return bt(s,pn,t),bt(s,Cl),bt(s,nd),bt(s,od),bt(s,it,Ge),Le(n.eventHub,we.SEND_COMMAND,P),Le(n.eventHub,we.SETTINGS_CHANGED,O),Le(n.eventHub,W.CLOSE_FILE,ve),Le(n.eventHub,W.CREATE_NOTEBOOK,I),Le(n.eventHub,W.SELECT_NOTEBOOK,oe),Le(n.eventHub,W.RENAME,Z),Le(n.eventHub,W.RENAME_FILE,A),Le(n.eventHub,W.SEND_TO_NOTEBOOK,ze),Le(n.eventHub,W.REGISTER_FILE,z),Le(n.eventHub,W.UNREGISTER_FILE,X),null}function on(i,e,t){return e=Cd(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Cd(i){var e=Sd(i,"string");return typeof e=="symbol"?e:String(e)}function Sd(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class kt{}on(kt,"DROPDOWN_FILTER","ControlType.DROPDOWN_FILTER");on(kt,"INPUT_FILTER","ControlType.INPUT_FILTER");on(kt,"MARKDOWN","ControlType.MARKDOWN");on(kt,"FILTER_SET_MANAGER","ControlType.FILTER_SET_MANAGER");const ih=kt;export{we as $,Zd as A,Nd as B,ih as C,Jd as D,Wd as E,nd as F,Kd as G,zd as H,vi as I,Vd as J,Cr as K,od as L,Hd as M,W as N,Bs as O,At as P,He as Q,$d as R,th as S,Ud as T,Bd as U,xn as V,De as W,Sr as X,Xd as Y,Qd as Z,eh as _,Ld as a,Bt as a0,ml as a1,Gd as a2,Rd as b,Od as c,Md as d,Fd as e,Ad as f,Dd as g,To as h,xd as i,jd as j,Id as k,pn as l,Cl as m,_d as n,Oo as o,Yd as p,jt as q,Je as r,kd as s,wd as t,yo as u,it as v,nh as w,w as x,In as y,qd as z};
21
- //# sourceMappingURL=ControlType-aed38d2a.js.map
20
+ `)}this.bufferedMessages=[],this.appendLogText(e)}queue(e){this.bufferedMessages.push(e),this.bufferedMessages.length===1&&(this.flushTimer=setTimeout(this.handleFlushTimeout,ne.bufferTimeout))}stopFlushTimer(){this.flushTimer&&(clearTimeout(this.flushTimer),this.flushTimer=void 0)}updateDimensions(){this.editor&&this.editor.layout()}handleClearClick(){this.clearLogs()}clearLogs(){this.messages=[],this.refreshLogText()}handleFlushTimeout(){this.stopFlushTimer(),this.flush()}handleLogMessage(e){this.messages.push(e),this.editor&&this.isLogItemVisible(e)&&this.queue(e)}handleMenuItemClick(e){this.toggleLogLevel(e)}handleResetClick(){this.resetLogLevels()}handleResize(){this.updateDimensions()}handleToggleAllClick(){this.toggleAll()}render(){var e={placement:"bottom-end"},{shownLogLevels:t}=this.state,n=this.getMenuActions(t);return l.jsxs("div",{className:"log-pane h-100 w-100",children:[l.jsxs("div",{className:"log-pane-menu",children:[l.jsx(K,{kind:"ghost",className:"btn-clear-logs",onClick:this.handleClearClick,icon:zr,tooltip:"Clear log"}),l.jsx(K,{kind:"ghost",className:"btn-link-icon btn-overflow",icon:Yr,tooltip:"Log Settings",onClick:()=>{},children:l.jsx(Ot,{actions:n,popperClassName:"log-level-menu-popper",popperOptions:e})})]}),l.jsx("div",{className:"log-pane-editor h-100 w-100",ref:r=>{this.editorContainer=r}})]})}}ye(ne,"DefaultLogLevels",[de.STDOUT,de.ERROR,de.FATAL,de.STDERR,de.WARN]);ye(ne,"AllLogLevels",[de.INFO,de.STDOUT,de.ERROR,de.FATAL,de.STDERR,de.WARN,de.DEBUG,de.TRACE]);ye(ne,"bufferTimeout",16);ye(ne,"maxLogSize",131072);ye(ne,"truncateSize",65536);const vo=ne;function hi(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function mo(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){hi(s,n,r,a,o,"next",d)}function o(d){hi(s,n,r,a,o,"throw",d)}a(void 0)})}}var po=Q.module("HeapUsage");function go(i){var e,{connection:t,defaultUpdateInterval:n,hoverUpdateInterval:r,bgMonitoring:s=!0,monitorDuration:a}=i,o=Cs(),[d,h]=c.useState({freeMemory:0,maximumHeapSize:999,totalHeapSize:0}),[u,v]=c.useState(!1),m=c.useRef({timestamps:[],usages:[]}),p=Ss(),E=c.useCallback(mo(function*(){try{var x=yield t.getWorkerHeapInfo();if(!p.current)return;if(h(x),s||u){for(var F=(x.totalHeapSize-x.freeMemory)/x.maximumHeapSize,I=Date.now(),{timestamps:oe,usages:Ge}=m.current;oe.length!==0&&I-oe[0]>a*1.5;)oe.shift(),Ge.shift();oe.push(I),Ge.push(F)}else m.current={timestamps:[],usages:[]}}catch(ze){po.warn("Unable to get heap usage",ze)}}),[t,p,s,u,a]);Es(E,u?r:n);var S=(x,F)=>Math.round(x*10**F)/10**F,g=2,y=1024**3,{freeMemory:P,totalHeapSize:O,maximumHeapSize:L}=d,V=S(P/y,g),Z=S(O/y,g),A=S(L/y,g),z=Z-V,G=function(F,I){var oe=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return l.jsxs("div",{className:ee("heap-usage-info-row",{"heading-bottom-border":oe}),children:[l.jsx("div",{className:"font-weight-bold",children:F}),l.jsx("div",{children:I})]})},{timestamps:X,usages:ve}=m.current,R=(e=X[X.length-1])!==null&&e!==void 0?e:0,$=O/L,H=(O-P)/L;return l.jsxs("div",{className:"max-memory",children:[l.jsx("div",{className:"total-memory",style:{width:"calc(".concat($*100,"% - ").concat($*2,"px")}}),l.jsx("div",{className:ee("used-memory",{"heap-overflow":(O-P)/L>.95}),style:{width:"calc(".concat(H*100,"% - ").concat(H*2,"px")}}),l.jsxs("div",{className:"memory-text",children:[A.toFixed(1)," GB"]}),l.jsx(ot,{onEntered:()=>v(!0),onExited:()=>v(!1),interactive:!0,children:l.jsxs("div",{className:"heap-tooltip",children:[G("In use:","".concat(z.toFixed(g)," of ").concat(A.toFixed(g)," GB"),!0),G("Free:","".concat(V.toFixed(g)," GB")),G("Total:","".concat(Z.toFixed(g)," GB")),G("Max:","".concat(A.toFixed(g)," GB")),l.jsx("div",{className:"heap-plot",children:l.jsx(ys,{data:[{x:[...X],y:[...ve],type:"scatter",mode:"lines"}],config:{staticPlot:!0,responsive:!0},style:{width:"196px",height:"100px"},layout:{margin:{l:2,t:2,r:2,b:2},plot_bgcolor:"transparent",paper_bgcolor:"transparent",colorway:["#4878ea"],xaxis:{dtick:Math.round(a/6),gridcolor:o.linecolor,range:[R-a,R],linecolor:o.linecolor,linewidth:2,mirror:!0},yaxis:{dtick:.2,gridcolor:o.linecolor,range:[0,1],linecolor:o.linecolor,linewidth:2,mirror:!0}}})}),l.jsxs("div",{className:"heap-utilisation-text",children:["% utilization over ",Math.round(a/1e3/60)," min."]})]})})]})}function ui(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function fo(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ui(Object(t),!0).forEach(function(n){bo(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ui(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function bo(i,e,t){return e=Co(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Co(i){var e=So(i,"string");return typeof e=="symbol"?e:String(e)}function So(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Rn=Object.freeze({}),Eo=new Map,wd=i=>i.api,Nd=i=>i.user,In=i=>i.storage,ur=i=>In(i).commandHistoryStorage,cr=i=>In(i).fileStorage,xd=i=>In(i).workspaceStorage,yo=i=>i.defaultWorkspaceSettings,To=i=>{var{workspace:e}=i;return e},He=i=>{for(var e=To(i).data.settings,t=fo({},yo(i)),n=Object.keys(e),r=0;r<n.length;r+=1){var s=n[r];e[s]!==void 0&&(t[s]=e[s])}return t},Dd=i=>i.defaultWorkspaceSettings,Ld=i=>He(i).defaultDateTimeFormat,Rd=i=>{var e;return(e=He(i).defaultDecimalFormatOptions)!==null&&e!==void 0?e:Rn},Id=i=>{var e;return(e=He(i).defaultIntegerFormatOptions)!==null&&e!==void 0?e:Rn},Md=i=>{var e;return(e=He(i).formatter)!==null&&e!==void 0?e:[]},Po=i=>He(i).timeZone,Fd=i=>He(i).showTimeZone,Ad=i=>He(i).showTSeparator,jd=i=>He(i).truncateNumbersWithPound,_d=i=>He(i).shortcutOverrides,Oo=i=>{var e;return(e=He(i).defaultNotebookSettings)!==null&&e!==void 0?e:Rn},kd=i=>i.activeTool,wo=i=>{var e;return(e=i.plugins)!==null&&e!==void 0?e:Eo};function ci(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function mn(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?ci(Object(t),!0).forEach(function(n){No(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):ci(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function No(i,e,t){return e=xo(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function xo(i){var e=Do(i,"string");return typeof e=="symbol"?e:String(e)}function Do(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function vr(i,e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:e,n=arguments.length>1?arguments[1]:void 0;switch(n.type){case i:{var r=n.payload;return r==null?null:t!=null?mn(mn({},t),r):mn({},r)}default:return t}}}function Je(i,e){return function(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:e,n=arguments.length>1?arguments[1]:void 0;switch(n.type){case i:return n.payload;default:return t}}}const Lo=Je(Ts,null),Ro=Je(Ps,null),Io=Je(Os,null),Mo=Je(ws,null),Fo=Je(Ns,null),Ao=Je(xs,null),jo=On({commandHistoryStorage:Mo,fileStorage:Fo,workspaceStorage:Ao}),_o=vr(Ds,null),ko=vr(Ls,null),Ho=Je(Rs,null),Uo=Je(Is,null);var $o={activeTool:Ro,api:Lo,plugins:Io,storage:jo,user:_o,workspace:ko,defaultWorkspaceSettings:Ho,serverConfigValues:Uo};const Bo=$o;var vi=Q.module("redux-logger"),Vo=i=>e=>t=>{vi.debug("dispatching",t);var n=e(t);return vi.debug("next state",i.getState()),n};const Wo=Vo;var Ko=Q.module("redux-crashReporter"),Go=i=>e=>t=>{try{return e(t)}catch(n){throw Ko.error("Error executing",t," with state ",i.getState(),":",n),n}};const zo=Go,Yo=[Wo,zo,Dr];var pn;Object.entries(Bo).map(i=>{var[e,t]=i;return Nn.register(e,t)});var qo=(pn=window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__)!==null&&pn!==void 0?pn:Ir,mr=Lr(On(Nn.reducers),qo(Rr(...Yo)));Nn.setListener(i=>{mr.replaceReducer(On(i))});const Hd=mr;function Ft(i,e,t){return e=Zo(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Zo(i){var e=Xo(i,"string");return typeof e=="symbol"?e:String(e)}function Xo(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class gt{}Ft(gt,"SESSION_OPENED","ConsoleEvent.SESSION_OPENED");Ft(gt,"SESSION_CLOSED","ConsoleEvent.SESSION_CLOSED");Ft(gt,"FOCUS_HISTORY","ConsoleEvent.FOCUS_HISTORY");Ft(gt,"SEND_COMMAND","ConsoleEvent.SEND_COMMAND");Ft(gt,"SETTINGS_CHANGED","ConsoleEvent.SETTINGS_CHANGED");const we=gt;function et(i,e,t){return e=Qo(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Qo(i){var e=Jo(i,"string");return typeof e=="symbol"?e:String(e)}function Jo(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class We{}et(We,"TABLE_CHANGED","InputFilterEvent.TABLE_CHANGED");et(We,"COLUMNS_CHANGED","InputFilterEvent.COLUMNS_CHANGED");et(We,"FILTERS_CHANGED","InputFilterEvent.FILTERS_CHANGED");et(We,"CLEAR_ALL_FILTERS","InputFilterEvent.CLEAR_ALL_FILTERS");et(We,"COLUMN_SELECTED","InputFilterEvent.COLUMN_SELECTED");et(We,"OPEN_DROPDOWN","InputFilterEvent.OPEN_DROPDOWN");et(We,"OPEN_INPUT","InputFilterEvent.OPEN_INPUT");et(We,"OPEN_FILTER_SET_MANAGER","InputFilterEvent.OPEN_FILTER_SET_MANAGER");const mi=We,Ud=Object.freeze({OPEN:"MarkdownEvent.OPEN"});function Ke(i,e,t){return e=el(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function el(i){var e=tl(i,"string");return typeof e=="symbol"?e:String(e)}function tl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Ue{}Ke(Ue,"CREATE_NOTEBOOK","NotebookEvent.createNotebook");Ke(Ue,"SELECT_NOTEBOOK","NotebookEvent.selectNotebook");Ke(Ue,"CLOSE_FILE","NotebookEvent.closeFile");Ke(Ue,"RENAME","NotebookEvent.rename");Ke(Ue,"RENAME_FILE","NotebookEvent.renameFile");Ke(Ue,"REGISTER_FILE","NotebookEvent.registerFile");Ke(Ue,"SEND_TO_NOTEBOOK","NotebookEvent.sendToNotebook");Ke(Ue,"UNREGISTER_FILE","NotebookEvent.unregisterFile");Ke(Ue,"PROMOTE_FROM_PREVIEW","NotebookEvent.promoteFromPreview");const W=Ue;function ft(i,e,t){return e=nl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function nl(i){var e=il(i,"string");return typeof e=="symbol"?e:String(e)}function il(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class ht{}ft(ht,"focus","TabEvent.focus");ft(ht,"blur","TabEvent.blur");ft(ht,"openPQObject","TabEvent.openPQObject");ft(ht,"openControl","TabEvent.openControl");ft(ht,"reload","TabEvent.reload");ft(ht,"clearAllFilters","TabEvent.clearAllFilters");const Bt=ht;function rl(i,e,t){return e=sl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function sl(i){var e=al(i,"string");return typeof e=="symbol"?e:String(e)}function al(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class pr extends c.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 e,t,n,{glContainer:r}=this.props;return[...(e=r==null||(t=r.tab)===null||t===void 0||(n=t.header)===null||n===void 0?void 0:n.tabs)!==null&&e!==void 0?e:[]]}handleCloseTab(){var{glContainer:e}=this.props;e.close()}handleCloseTabsAll(){var e=this.getAllTabs();e.forEach(t=>{var n;return(n=(t?.contentItem).container)===null||n===void 0?void 0:n.close()})}handleCloseTabsRight(){for(var{glContainer:e}=this.props,t=this.getAllTabs(),n=t.length-1;n>0;n-=1){var r,s,a,o,d,h,u;if(((r=t[n].contentItem)===null||r===void 0||(s=r.config)===null||s===void 0?void 0:s.id)===((a=e.tab)===null||a===void 0||(o=a.contentItem)===null||o===void 0||(d=o.config)===null||d===void 0?void 0:d.id))break;(h=((u=t[n])===null||u===void 0?void 0:u.contentItem).container)===null||h===void 0||h.close()}}canCloseTabsRight(){for(var{glContainer:e}=this.props,t=this.getAllTabs(),n=!0,r=t.length-1;r>0;r-=1){var s,a,o,d,h,u,v,m;if(((s=t[r].contentItem)===null||s===void 0||(a=s.config)===null||a===void 0?void 0:a.id)===((o=e.tab)===null||o===void 0||(d=o.contentItem)===null||d===void 0||(h=d.config)===null||h===void 0?void 0:h.id))break;var p=!!(!((u=t[r])===null||u===void 0||(v=u.contentItem)===null||v===void 0||(m=v.config)===null||m===void 0)&&m.isClosable);if(p){n=!1;break}}return n}canCloseAny(){for(var e=this.getAllTabs(),t=!0,n=e.length-1;n>0;n-=1){var r,s,a,o=!!(!((r=e[n])===null||r===void 0||(s=r.contentItem)===null||s===void 0||(a=s.config)===null||a===void 0)&&a.isClosable);if(o){t=!1;break}}return t}render(){var e,t,n,{additionalActions:r,glContainer:s}=this.props,a=[...r],o=(e=s.tab)===null||e===void 0||(t=e.contentItem)===null||t===void 0||(n=t.config)===null||n===void 0?void 0:n.isClosable;return a.push({title:"Close",order:10,group:k.groups.low,action:this.handleCloseTab,disabled:o===void 0||!o}),a.push(()=>({title:"Close Tabs to Right",order:20,group:k.groups.low,action:this.handleCloseTabsRight,disabled:this.canCloseTabsRight()})),a.push(()=>({title:"Close All",order:30,group:k.groups.low,action:this.handleCloseTabsAll,disabled:this.canCloseAny()})),l.jsx(k,{actions:a})}}rl(pr,"defaultProps",{additionalActions:[]});const ol=pr;function gr(i,e,t){return e=ll(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function ll(i){var e=dl(i,"string");return typeof e=="symbol"?e:String(e)}function dl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class fr extends c.PureComponent{constructor(e){super(e),gr(this,"renameInputRef",void 0),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=se.createRef();var{value:t}=e;this.state={value:t,valueWasValidated:!1}}componentDidUpdate(e){var{isShown:t}=e,{isShown:n}=this.props;n&&!t&&this.resetState()}resetState(){var{value:e}=this.props;this.setState({value:e,valueWasValidated:!1})}handleRenameDialogOpened(){var e,t;(e=this.renameInputRef)===null||e===void 0||(t=e.current)===null||t===void 0||t.focus()}handleRenameInputChange(e){this.setState({value:e.target.value})}handleRenameCancel(){var{onCancel:e}=this.props;e()}handleRenameSubmit(e){e.stopPropagation(),e.preventDefault();var{value:t}=this.state,n=t?.trim();if(n!==void 0&&n!==""){var{onSubmit:r}=this.props;r(n)}else this.setState({value:n,valueWasValidated:!0})}renderRenameDialog(){var{isShared:e,isOwner:t,itemType:n}=this.props,{value:r,valueWasValidated:s}=this.state;return l.jsxs("form",{className:ee("p-3",{"was-validated":s}),onSubmit:this.handleRenameSubmit,noValidate:!0,role:"presentation",onMouseDown:a=>{a.stopPropagation()},onMouseUp:a=>{a.stopPropagation()},children:[l.jsxs("div",{className:"form-group",children:[l.jsxs("label",{htmlFor:"rename-dialog-".concat(n,"-input"),children:["Rename ",n]}),l.jsx("input",{type:"text",className:"form-control",id:"rename-dialog-".concat(n,"-input"),value:r??void 0,ref:this.renameInputRef,onChange:this.handleRenameInputChange,required:!0}),l.jsxs("div",{className:"invalid-feedback",children:[n," name cannot be empty"]}),(e||!t)&&l.jsxs("div",{className:"pt-2",children:["Renaming this ",n," will rename for all users."]})]}),l.jsxs("div",{className:"text-right",children:[l.jsx(K,{kind:"secondary",className:"mr-2",onClick:this.handleRenameCancel,children:"Cancel"}),l.jsx(K,{kind:"primary",type:"submit",children:"Rename"})]})]})}render(){var{isShown:e,onCancel:t}=this.props;return l.jsx(Ms,{isShown:e,onEntered:this.handleRenameDialogOpened,onExited:t,options:{placement:"bottom"},interactive:!0,closeOnBlur:!0,children:this.renderRenameDialog()})}}gr(fr,"defaultProps",{isShared:!1,isOwner:!0,itemType:"Item",value:""});function yn(i,e,t){return e=hl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function hl(i){var e=ul(i,"string");return typeof e=="symbol"?e:String(e)}function ul(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var cl=Q.module("Panel");class br extends c.PureComponent{constructor(e){super(e),yn(this,"ref",void 0),yn(this,"getAdditionActions",_e((n,r,s)=>{var a=[];return r&&a.push(this.getCloneAction()),s&&a.push(this.getRenameAction()),[...a,...n]})),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),this.ref=se.createRef();var{glContainer:t}=this.props;this.state={title:ae.getTitleFromContainer(t),showRenameDialog:!1,isWithinPanel:!0}}componentDidMount(){var e,t,{componentPanel:n,glContainer:r,glEventHub:s}=this.props;r.on("resize",this.handleResize),r.on("show",this.handleBeforeShow),r.on("shown",this.handleShow),r.on("hide",this.handleHide),r.on("tab",this.handleTab),r.on("tabClicked",this.handleTabClicked),s.on(we.SESSION_CLOSED,this.handleSessionClosed),s.on(we.SESSION_OPENED,this.handleSessionOpened),s.on(Bt.focus,this.handleTabFocus),s.on(Bt.blur,this.handleTabBlur),s.on(mi.CLEAR_ALL_FILTERS,this.handleClearAllFilters),s.emit(xe.MOUNT,n??this),this.setState({isWithinPanel:((e=this.ref.current)===null||e===void 0||(t=e.parentElement)===null||t===void 0?void 0:t.closest(".dh-panel"))!=null})}componentWillUnmount(){var{componentPanel:e,glContainer:t,glEventHub:n}=this.props;t.off("resize",this.handleResize),t.off("show",this.handleBeforeShow),t.off("shown",this.handleShow),t.off("hide",this.handleHide),t.off("tab",this.handleTab),t.off("tabClicked",this.handleTabClicked),n.off(we.SESSION_CLOSED,this.handleSessionClosed),n.off(we.SESSION_OPENED,this.handleSessionOpened),n.off(Bt.focus,this.handleTabFocus),n.off(Bt.blur,this.handleTabBlur),n.off(mi.CLEAR_ALL_FILTERS,this.handleClearAllFilters),n.emit(xe.UNMOUNT,e??this)}handleTab(e){e!=null&&this.setState({title:ae.getTitleFromTab(e)}),this.forceUpdate();var{onTab:t}=this.props;t(e)}handleTabClicked(e){var{onTabClicked:t}=this.props;t(e)}handleClearAllFilters(){var{onClearAllFilters:e}=this.props;e(...arguments)}handleFocus(e){var{componentPanel:t,glEventHub:n}=this.props;n.emit(xe.FOCUS,t??this);var{onFocus:r}=this.props;r(e)}handleBlur(e){var{onBlur:t}=this.props;t(e)}handleHide(){var{onHide:e}=this.props;e(...arguments)}handleResize(){var{onResize:e}=this.props;e(...arguments)}handleSessionClosed(e){var{onSessionClose:t}=this.props;t(e)}handleSessionOpened(e,t){var{onSessionOpen:n}=this.props;n(e,t)}handleBeforeShow(){var{onBeforeShow:e}=this.props;e(...arguments)}handleShow(){var{onShow:e}=this.props;e(...arguments)}handleTabBlur(){var{onTabBlur:e}=this.props;e(...arguments)}handleTabFocus(){var{onTabFocus:e}=this.props;e(...arguments)}handleRenameCancel(){this.setState({showRenameDialog:!1})}handleShowRenameDialog(){this.setState({showRenameDialog:!0})}handleRenameSubmit(e){var{glContainer:t}=this.props;this.setState({showRenameDialog:!1,title:e});var n=ae.getRootFromContainer(t),r=ae.getComponentConfigFromContainer(t);N(r),ae.renameComponent(n,r,e)}handleCopyPanel(){var{glContainer:e,glEventHub:t}=this.props,n=ae.getRootFromContainer(e),r=ae.getComponentConfigFromContainer(e);if(r==null){cl.error("Could not get component config from container",e);return}var s=ae.cloneComponent(n,r);s!==null&&t.emit(xe.CLONED,this,s)}getCloneAction(){return{title:"Copy Panel",order:10,group:k.groups.high,action:this.handleCopyPanel}}getRenameAction(){return{title:"Rename",order:10,group:k.groups.medium,action:this.handleShowRenameDialog}}render(){var{children:e,className:t,renderTabTooltip:n,glContainer:r,additionalActions:s,errorMessage:a,isLoaded:o,isLoading:d,isClonable:h,isRenamable:u}=this.props,{tab:v}=r,{showRenameDialog:m,title:p,isWithinPanel:E}=this.state;return l.jsxs("div",{className:ee("h-100 w-100 dh-panel",t),onFocusCapture:this.handleFocus,onBlurCapture:this.handleBlur,ref:this.ref,children:[e,l.jsx(wn,{errorMessage:a,isLoaded:o,isLoading:d}),!E&&v!=null&&ki.createPortal(l.jsxs(l.Fragment,{children:[l.jsx(ol,{glContainer:r,additionalActions:this.getAdditionActions(s,h,u)}),u&&l.jsx(fr,{isShown:m,value:p,itemType:"Panel",onCancel:this.handleRenameCancel,onSubmit:this.handleRenameSubmit}),n!=null&&l.jsx(ot,{interactive:!0,options:{placement:"bottom"},popperClassName:"panel-tab-popper",children:n()})]}),v.element[0])]})}}yn(br,"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 At=br,$d=Object.freeze({DEFAULT:"DEFAULT",LINKER:"LINKER"});var vl=Object.freeze({}),ml=new Map,sn=Object.freeze([]),Bd=(i,e)=>{var t;return(t=ke(i,e).columns)!==null&&t!==void 0?t:sn},Vd=(i,e)=>{var t;return(t=ke(i,e).filterSets)!==null&&t!==void 0?t:sn},Wd=(i,e)=>{var t;return(t=ke(i,e).filters)!==null&&t!==void 0?t:sn},Kd=(i,e)=>{var t;return(t=ke(i,e).tableMap)!==null&&t!==void 0?t:ml},Gd=(i,e)=>ke(i,e).isolatedLinkerPanelId,Cr=(i,e)=>{var t;return(t=ke(i,e).links)!==null&&t!==void 0?t:sn},zd=(i,e)=>ke(i,e).columnSelectionValidator,Yd=(i,e)=>{var t;return(t=ke(i,e).consoleSettings)!==null&&t!==void 0?t:vl},qd=(i,e)=>ke(i,e).connection,jt=(i,e)=>ke(i,e).sessionWrapper,Zd=(i,e)=>t=>t(lt(i,{connection:e})),Xd=(i,e)=>t=>t(lt(i,{sessionWrapper:e})),Sr=(i,e)=>t=>t(lt(i,{links:e})),Qd=(i,e)=>(t,n)=>{var r=Cr(n(),i),s=e.filter(a=>r.findIndex(o=>_n(o.start,a.start)&&_n(o.end,a.end))<0);return t(Sr(i,r.concat(s)))},Jd=(i,e)=>(t,n)=>{var r=Cr(n(),i),s=r.filter(a=>!e.includes(a.id));return t(Sr(i,s))},eh=(i,e)=>t=>t(lt(i,{isolatedLinkerPanelId:e})),th=(i,e)=>t=>t(lt(i,{columnSelectionValidator:e})),pl=(i,e)=>t=>t(lt(i,{consoleSettings:e})),nh=(i,e)=>t=>t(lt(i,{filterSets:e}));function tn(i,e,t){return e=gl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function gl(i){var e=fl(i,"string");return typeof e=="symbol"?e:String(e)}function fl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Vt=Q.module("CommandHistoryPanel");class _t extends c.Component{static handleError(e){Vt.error(e)}constructor(e){super(e),tn(this,"container",void 0),tn(this,"pending",void 0),this.handleFocusHistory=this.handleFocusHistory.bind(this),this.handleSessionOpened=this.handleSessionOpened.bind(this),this.handleSessionClosed=this.handleSessionClosed.bind(this),this.handleShow=this.handleShow.bind(this),this.handleSendToConsole=this.handleSendToConsole.bind(this),this.handleSendToNotebook=this.handleSendToNotebook.bind(this),this.container=se.createRef(),this.pending=new pt;var{session:t,sessionId:n,language:r}=e;this.state={panelState:{},session:t,sessionId:n,language:r,contextActions:[{action:this.handleFocusHistory,shortcut:be.COMMAND_HISTORY.FOCUS_HISTORY}]}}componentDidMount(){var{glEventHub:e,session:t}=this.props;e.on(we.FOCUS_HISTORY,this.handleFocusHistory),t!=null&&this.loadTable()}componentWillUnmount(){var{glEventHub:e}=this.props;e.off(we.FOCUS_HISTORY,this.handleFocusHistory),this.pending.cancel()}handleFocusHistory(){this.container.current&&this.container.current.focus()}handleShow(){var e;(e=this.container.current)===null||e===void 0||e.restoreScrollPosition()}handleSessionOpened(e,t){var{language:n,sessionId:r}=t;this.setState({session:e,sessionId:r,language:n},()=>{this.loadTable()})}handleSessionClosed(){this.pending.cancel(),this.setState({session:void 0,language:void 0,table:void 0})}handleSendToNotebook(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,{session:n,language:r}=this.state;if(Vt.debug("handleSendToNotebook",n,e),!n){Vt.error("Session is not connected.");return}var{glEventHub:s}=this.props;s.emit(t?W.CREATE_NOTEBOOK:W.SEND_TO_NOTEBOOK,n,r,e)}handleSendToConsole(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;Vt.debug("handleSendToConsole",e);var{glEventHub:r}=this.props;r.emit(we.SEND_COMMAND,e,t,n)}loadTable(){var{commandHistoryStorage:e}=this.props,{language:t,sessionId:n}=this.state;N(t),N(n),this.pending.add(e.getTable(t,n,Date.now()),r=>r.close()).then(r=>{this.setState({table:r})}).catch(_t.handleError)}render(){var{glContainer:e,glEventHub:t,commandHistoryStorage:n}=this.props,{language:r,contextActions:s,table:a}=this.state;return l.jsxs(At,{className:"command-history-pane",componentPanel:this,glContainer:e,glEventHub:t,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[!a&&l.jsx("div",{className:"command-history-disconnected-message",children:"Waiting for console connection"}),a&&r!=null&&l.jsxs(l.Fragment,{children:[l.jsx(oo,{ref:this.container,language:r,sendToNotebook:this.handleSendToNotebook,sendToConsole:this.handleSendToConsole,table:a,commandHistoryStorage:n}),l.jsx(k,{actions:s})]})]})}}tn(_t,"COMPONENT","CommandHistoryPanel");tn(_t,"TITLE","Command History");var bl=(i,e)=>{var t=ur(i),n=jt(i,e.localDashboardId),{session:r,config:s}=n??{},{type:a,id:o}=s??{};return{commandHistoryStorage:t,language:a,session:r,sessionId:o}},Cl=It(bl,null,null,{forwardRef:!0})(_t);const Sl=Cl;function pi(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Wt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?pi(Object(t),!0).forEach(function(n){st(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):pi(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function st(i,e,t){return e=El(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function El(i){var e=yl(i,"string");return typeof e=="symbol"?e:String(e)}function yl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Kt=Q.module("ConsolePanel"),Tl=500,Pl=Object.freeze({consoleSettings:{},itemIds:[]});class an extends c.PureComponent{constructor(e){super(e),st(this,"consoleRef",void 0),st(this,"objectSubscriptionCleanup",void 0),st(this,"savePanelState",Dt(()=>{var{consoleSettings:a,itemIds:o}=this.state,d={consoleSettings:a,itemIds:[...o]};Kt.debug("Saving panel state",d),this.setState({panelState:d})},Tl)),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.supportsType=this.supportsType.bind(this),this.iconForType=this.iconForType.bind(this),this.consoleRef=se.createRef();var{panelState:t}=e,n=Wt(Wt({},Pl),t||{}),{consoleSettings:r,itemIds:s}=n;this.state={consoleSettings:r,itemIds:new Map(s),objectMap:new Map,error:void 0,panelState:n}}componentDidMount(){var{glEventHub:e}=this.props;this.closeDisconnectedPanels(),e.on(xe.MOUNT,this.handlePanelMount),this.subscribeToFieldUpdates()}componentDidUpdate(e,t){var{consoleSettings:n,itemIds:r}=this.state;(t.consoleSettings!==n||t.itemIds!==r)&&this.savePanelState()}componentWillUnmount(){var e,{glEventHub:t}=this.props;this.savePanelState.flush(),t.off(xe.MOUNT,this.handlePanelMount),(e=this.objectSubscriptionCleanup)===null||e===void 0||e.call(this)}subscribeToFieldUpdates(){var{sessionWrapper:e}=this.props;if(e!=null){var{session:t}=e;this.objectSubscriptionCleanup=t.subscribeToFieldUpdates(n=>{Kt.debug("Got updates",n),this.setState(r=>{var{objectMap:s}=r,{updated:a,created:o,removed:d}=n,h=[...a,...d],u=new Map(s);h.forEach(m=>{var{title:p}=m;p!==void 0&&u.delete(p)});var v=[...a,...o];return v.forEach(m=>{m.title!==void 0&&u.set(m.title,m)}),{objectMap:u}})})}}setItemId(e,t){this.setState(n=>{var{itemIds:r}=n,s=new Map(r);return s.set(e,t),{itemIds:s}})}getItemId(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,{itemIds:n}=this.state,r=n.get(e);return r==null&&t&&(r=Hi.generate(),this.setItemId(e,r)),r}handleTabFocus(){var e;(e=this.consoleRef.current)===null||e===void 0||e.focus()}handlePanelMount(e){var t,n,r,{itemIds:s}=this.state,a=e==null||(t=e.props)===null||t===void 0?void 0:t.id,o=e==null||(n=e.props)===null||n===void 0||(r=n.metadata)===null||r===void 0?void 0:r.sourcePanelId;if(a&&o){var d=new Set(s.values());d.has(o)&&this.setItemId(a,a)}}handleFocusCommandHistory(){var{glEventHub:e}=this.props;e.emit(we.FOCUS_HISTORY)}handleResize(){this.updateDimensions()}handleShow(){this.updateDimensions()}handleOpenObject(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,{root:n}=this.context,r=e.title!=null?this.getItemId(e.title,!1):null;(t||r!=null&&ae.getStackForRoot(n,{id:r},!1,!1,!1)!=null)&&this.openWidget(e)}handleCloseObject(e){var{title:t}=e;if(t!==void 0){var n=this.getItemId(t,!1);if(n!=null){var{glEventHub:r}=this.props;r.emit(xe.CLOSE,n)}}}handleSettingsChange(e){var{glEventHub:t}=this.props;Kt.debug("handleSettingsChange",e),this.setState({consoleSettings:e}),t.emit(we.SETTINGS_CHANGED,e)}openWidget(e){var{glEventHub:t,sessionWrapper:n}=this.props;N(n);var{config:r,session:s}=n,{title:a}=e;N(a);var o=this.getItemId(a),d=Wt(Wt({},Fs(e)),{},{sessionId:r.id}),h={fetch:()=>s.getObject(e),metadata:d,panelId:o,widget:e};Kt.debug("openWidget",h),t.emit(xe.OPEN,h)}addCommand(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;(t=this.consoleRef.current)===null||t===void 0||t.addCommand(e,n,r)}closeDisconnectedPanels(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,{consoleSettings:t,itemIds:n}=this.state,{isClosePanelsOnDisconnectEnabled:r=!0}=t;if(!(!r&&!e)){var s=[...n.values()],{glEventHub:a}=this.props;s.forEach(o=>{a.emit(xe.CLOSE,o)}),this.setState({itemIds:new Map})}}updateDimensions(){var e;(e=this.consoleRef.current)===null||e===void 0||e.updateDimensions()}supportsType(e){var{plugins:t}=this.props;return[...t.values()].some(n=>$n(n,e))}iconForType(e){var{plugins:t}=this.props,n=[...t.values()].find(r=>$n(r,e));return n!=null?As(n):l.jsx(Vs,{type:e})}render(){var{commandHistoryStorage:e,glContainer:t,glEventHub:n,sessionWrapper:r,timeZone:s,unzip:a}=this.props;if(r==null)return l.jsx(wn,{isLoading:!1,errorMessage:"Console is disabled."});var{consoleSettings:o,error:d,objectMap:h}=this.state,{config:u,session:v,connection:m,details:p={},dh:E}=r,{workerName:S,processInfoId:g}=p,{id:y,type:P}=u;return l.jsx(At,{className:"iris-panel-console",componentPanel:this,glContainer:t,glEventHub:n,onResize:this.handleResize,onShow:this.handleShow,onTabFocus:this.handleTabFocus,errorMessage:d!=null?"".concat(d):void 0,children:v!=null&&l.jsx(Wa,{dh:E,ref:this.consoleRef,settings:o,session:v,focusCommandHistory:this.handleFocusCommandHistory,openObject:this.handleOpenObject,closeObject:this.handleCloseObject,commandHistoryStorage:e,onSettingsChange:this.handleSettingsChange,language:P,statusBarChildren:l.jsxs(l.Fragment,{children:[l.jsx("div",{children:Xi.LANGUAGE_MAP.get(P)}),S!=null&&l.jsxs(l.Fragment,{children:[l.jsx("div",{children:"•"}),S]}),g!=null&&l.jsxs(l.Fragment,{children:[l.jsx("div",{children:"•"}),g,l.jsx("div",{children:"•"})]}),l.jsx(go,{connection:m,defaultUpdateInterval:10*1e3,hoverUpdateInterval:3*1e3,monitorDuration:10*60*1e3})]}),scope:y,timeZone:s,objectMap:h,unzip:a,supportsType:this.supportsType,iconForType:this.iconForType})})}}st(an,"COMPONENT","ConsolePanel");st(an,"TITLE","Console");st(an,"contextType",js);var Ol=(i,e)=>({commandHistoryStorage:ur(i),sessionWrapper:jt(i,e.localDashboardId),timeZone:Po(i),plugins:wo(i)}),wl=It(Ol,null,null,{forwardRef:!0})(an);const gn=wl;function De(i){return i.type==="directory"}function Nl(i,e,t){return e=xl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function xl(i){var e=Dl(i,"string");return typeof e=="symbol"?e:String(e)}function Dl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Ll extends Error{constructor(){super("No file exists at the path specified"),Nl(this,"isFileNotFound",!0)}}const Mn=Ll;function gi(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function fi(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){gi(s,n,r,a,o,"next",d)}function o(d){gi(s,n,r,a,o,"throw",d)}a(void 0)})}}var Ve;(function(i){i.GROOVY="text/x-groovy",i.PLAIN_TEXT="text/plain",i.PYTHON="text/x-python",i.PYTHON_COMPILED="application/x-python-code",i.SCALA="text/x-scala",i.UNKNOWN=""})(Ve||(Ve={}));class Fe{static fileExists(e,t){return fi(function*(){try{return yield e.info(t),!0}catch(n){if(!(n instanceof Mn))throw n;return!1}})()}static fileExtensionToString(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:"";return e.length===0?"":".".concat(e)}static getDepth(e){var t;if(!Fe.hasPath(e))throw new Error("Invalid path provided: ".concat(e));var n=(t=e.match(/\//g))!==null&&t!==void 0?t:[];return n.length-1}static getExtension(e){var t=this.getBaseName(e).split(".");if(t.length>1){var n;return(n=t.pop())!==null&&n!==void 0?n:""}return""}static getBaseName(e){var t;return(t=e.split("/").pop())!==null&&t!==void 0?t:""}static getCopyFileName(e){var t=e.lastIndexOf("."),n=null,r=null;t<0?r=e:(r=e.substring(0,t),n=e.substring(t+1));var s=r?"".concat(r,"-copy"):"Copy";return n!==null?"".concat(s,".").concat(n):s}static getUniqueCopyFileName(e,t){return fi(function*(){for(var n=Fe.getCopyFileName(t);yield Fe.fileExists(e,n);)n=Fe.getCopyFileName(n);return n})()}static getMimeType(e){var t=this.getExtension(e).toLowerCase();switch(t){case"groovy":return Ve.GROOVY;case"py":return Ve.PYTHON;case"pyc":return Ve.PYTHON_COMPILED;case"scala":return Ve.SCALA;case"txt":return Ve.PLAIN_TEXT;default:return Ve.UNKNOWN}}static getParent(e){if(!Fe.hasPath(e))throw new Error("Invalid name provided: ".concat(e));for(var t=e.split("/");t.pop()==="";);if(t.length===0)throw new Error("No parent for path provided: ".concat(e));return"".concat(t.join("/"),"/")}static getPath(e){if(!Fe.hasPath(e))throw new Error("Invalid filename provided: ".concat(e));var t=e.split("/");return t.pop(),"".concat(t.join("/"),"/")}static hasPath(e){return e.startsWith("/")}static isPath(e){return e.startsWith("/")&&e.endsWith("/")}static makePath(e){return e.endsWith("/")?e:"".concat(e,"/")}static replaceExtension(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"",n=e.lastIndexOf("."),r=n>-1?e.substring(0,n):e,s=Fe.fileExtensionToString(t);return"".concat(r).concat(s)}static validateName(e){var t=[".",".."],n=/[\\/\0]/g,r=new Map([["\0","null"]]);if(!e)throw new wt("Name cannot be empty");if(t.includes(e))throw new wt('"'.concat(e,'" is a reserved name'));if(n.test(e)){var s,a;throw new wt('Invalid characters in name: "'.concat((s=(a=e.match(n))===null||a===void 0?void 0:a.reduce((o,d)=>o.includes(d)?o:[...o,d],[]).map(o=>r.has(o)?r.get(o):o).join('", "'))!==null&&s!==void 0?s:"",'"'))}}static reducePaths(e){var t=e.filter(n=>Fe.isPath(n));return e.filter(n=>!t.some(r=>n!==r&&n.startsWith(r)))}static removeRoot(e,t){if(e.length===0)return t;if(!t.startsWith(e))throw new Error("Filename ".concat(t," does not start with expected root ").concat(e));return t.substring(e.length)}static addRoot(e,t){return"".concat(e).concat(t)}}const w=Fe;var Fn=26;function Tn(i){return De(i)?w.makePath(i.filename):w.getPath(i.filename)}function bi(i,e){if(i.length===0||e==null)throw new Error("No items to move");var t=Tn(e);if(i.some(n=>{var{filename:r}=n;return w.getPath(r)===t}))throw new Error("File already in the destination folder");if(i.some(n=>De(n)&&t.startsWith(w.makePath(n.filename))))throw new Error("Destination folder cannot be a child of a dragged folder");return{files:i,targetPath:t}}function Rl(i){if(De(i))return i.isExpanded?qr:Zr;var e=w.getMimeType(i.basename);switch(e){case Ve.PYTHON:return Qr;default:return Xr}}function Pn(i){var e,{children:t,draggedItems:n,isDragInProgress:r,isDropTargetValid:s,isSelected:a,item:o,itemIndex:d,dropTargetItem:h,onDragStart:u,onDragOver:v,onDragEnd:m,onDrop:p}=i,E=(e=n?.some(A=>A.id===o.id))!==null&&e!==void 0?e:!1,S=Tn(o),g=r&&h?Tn(h):null,y=r&&s&&De(o)&&g===S,P=r&&s&&g===S,O=r&&!s&&g===S,L=Rl(o),V=w.getDepth(o.filename),Z=Array(V).fill(null).map((A,z)=>l.jsx("span",{className:"file-list-depth-line"},z));return l.jsxs("div",{className:ee("d-flex w-100 align-items-center","file-list-item",{"is-dragged":E,"is-exact-drop-target":y,"is-in-drop-target":P,"is-invalid-drop-target":O,"is-selected":a}),onDragStart:A=>u(d,A),onDragOver:A=>v(d,A),onDragEnd:A=>m(d,A),onDrop:A=>p(d,A),draggable:!0,role:"presentation","aria-label":o.basename,children:[Z," ",l.jsx(re,{icon:L,className:"item-icon",fixedWidth:!0})," ",l.jsx("span",{className:"truncation-wrapper",children:t??l.jsxs(l.Fragment,{children:[o.basename,l.jsx(ot,{children:o.basename})]})})]})}function Ci(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Gt(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ci(Object(t),!0).forEach(function(n){Il(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Ci(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Il(i,e,t){return e=Ml(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Ml(i){var e=Fl(i,"string");return typeof e=="symbol"?e:String(e)}function Fl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var pe=Q.module("FileList"),Al=500,Si="item-list-scroll-pane";function jl(i){var{isMultiSelect:e=!1,table:t,onFocusChange:n=()=>{},onMove:r,onSelect:s,onSelectionChange:a=()=>{},renderItem:o=Pn,rowHeight:d=Fn,overscanCount:h=bn.DEFAULT_OVERSCAN}=i,[u,v]=c.useState(()=>({items:[],offset:0,itemCount:0})),[m,p]=c.useState({top:0,bottom:0}),[E,S]=c.useState(),[g,y]=c.useState(),[P,O]=c.useState(),[L,V]=c.useState([]),Z=c.useRef(),A=c.useRef(null),z=c.useRef(null),G=c.useCallback(C=>{if(C.length===0||u==null)return[];for(var M=[],B=0;B<C.length;B+=1)for(var te=C[B],me=te[0];me<=te[1];me+=1)me>=u.offset&&me<u.offset+u.items.length&&M.push(u.items[me-u.offset]);return M},[u]),X=c.useCallback(C=>{var M=G([[C,C]]);if(M.length>0)return M[0]},[G]),ve=c.useCallback(()=>{var C=Bn.count(L);if(C===0)return null;if(C===1){var M=L[0][0],B=X(M);if(B!=null)return B.filename}return"".concat(C," items")},[X,L]),R=c.useCallback(C=>{if(!(!g||!E)){pe.debug("dropItems",g,"to",C);try{var{files:M,targetPath:B}=bi(g,E);if(r?.(M,B),C!=null){var te;V([[C,C]]),(te=A.current)===null||te===void 0||te.focusItem(C)}}catch(me){pe.error("Unable to complete move",me)}}},[g,E,r]),$=c.useCallback((C,M)=>{var B=u.items[C-u.offset];B!==void 0&&(pe.debug("handleItemClick",B),s(B,M),De(B)&&t?.setExpanded(B.filename,!B.isExpanded))},[u,s,t]),H=c.useCallback((C,M)=>{var B;pe.debug2("handleItemDragStart",C,L);var te=L;Bn.isSelected(L,C)||(te=[[C,C]],V(te)),y(G(te)),(B=A.current)===null||B===void 0||B.resetMouseState();var me=document.createElement("div");me.innerHTML='<div class="dnd-placeholder-content">'.concat(ve(),"</div>"),me.className="file-list-dnd-placeholder",document.body.appendChild(me),M.dataTransfer.setDragImage(me,0,0),M.dataTransfer.effectAllowed="move",O(me)},[ve,G,L]),x=c.useCallback((C,M)=>{M.preventDefault(),pe.debug2("handleItemDragOver",M),S(X(C))},[X]),F=c.useCallback((C,M)=>{pe.debug("handleItemDragEnd",C),P?.remove(),y(void 0),S(void 0),O(void 0)},[P]),I=c.useCallback((C,M)=>{R(C)},[R]),oe=c.useCallback(()=>{pe.debug2("handleItemDragExit"),S(void 0)},[]),Ge=c.useCallback(C=>{C.target instanceof Element&&C.target.classList.contains(Si)&&(C.preventDefault(),pe.debug2("handleListDragOver",C),S({type:"directory",filename:"/",basename:"/",id:"/"}))},[]),ze=c.useCallback(C=>{C.target instanceof Element&&C.target.classList.contains(Si)&&(pe.debug("handleListDrop"),R())},[R]),f=c.useCallback(function(C){var M=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(pe.debug2("handleSelectionChange",C),M===!0||C!==L){V(C);var B=G(C);a(B)}},[G,a,L]),b=c.useCallback(C=>{if(pe.debug2("handleFocusChange",C),C!=null){var[M]=G([[C,C]]);n(M)}else n();Z.current=C},[G,n]),T=c.useCallback((C,M)=>{pe.debug("handleViewportChange",C,M),(C!==m.top||M!==m.bottom)&&p({top:C,bottom:M})},[m]),D=c.useMemo(()=>{if(!g||!E)return!1;try{return bi(g,E),pe.debug("handleValidateDropTarget true"),!0}catch{return pe.debug("handleValidateDropTarget false"),!1}},[g,E]),{focusedPath:j}=i;c.useEffect(()=>{j!==void 0&&(j==="/"?t.collapseAll():(t.setExpanded(j,!1),t.setExpanded(j,!0)))},[t,j]),c.useEffect(function(){pe.debug("updating table viewport",m),t?.setViewport({top:Math.max(0,m.top-h),bottom:m.bottom+h})},[h,t,m]),c.useEffect(function(){var M=t.onUpdate(B=>{v({items:B.items.map(te=>Gt(Gt({},te),{},{itemName:te.basename})),offset:B.offset,itemCount:t.size})});return()=>{M()}},[t]),c.useEffect(function(){Z.current!=null&&b(Z.current),L.length>0&&f(L,!0)},[u,b,f,L]),c.useEffect(function(){if(E!=null&&De(E)&&E.filename!=="/"){var M=setTimeout(()=>{E.isExpanded||t?.setExpanded(E.filename,!0)},Al);return()=>clearTimeout(M)}},[E,t]);var $e=c.useCallback(C=>o(Gt(Gt({},C),{},{isDragInProgress:g!=null,dropTargetItem:E,draggedItems:g,isDropTargetValid:D,onDragStart:H,onDragEnd:F,onDragOver:x,onDragExit:oe,onDrop:I})),[F,oe,x,H,I,g,E,D,o]);return l.jsx("div",{ref:z,className:ee("file-list",{"is-dragging":g!=null}),onDragOver:Ge,onDrop:ze,children:l.jsx(bn,{ref:A,items:u.items,itemCount:u.itemCount,offset:u.offset,onFocusChange:b,onSelect:$,onSelectionChange:f,onViewportChange:T,selectedRanges:L,renderItem:$e,rowHeight:d,isMultiSelect:e,isDragSelect:!1,isDeselectOnClick:!1})})}var _l={name:"File Explorer",DELETE:Ce.createAndAdd({id:"FILE_EXPLORER.DELETE",name:"Delete",shortcut:[Y.DELETE],macShortcut:[q.CMD,Y.BACKSPACE]}),RENAME:Ce.createAndAdd({id:"FILE_EXPLORER.RENAME",name:"Rename",shortcut:[Y.ENTER],macShortcut:[Y.ENTER]})};const Ei={FILE_EXPLORER:_l};var yi=Q.module("FileListItemEditor"),kl=()=>Promise.resolve();function Hl(i){var{item:e,onCancel:t,onSubmit:n,validate:r=kl}=i,s=c.useRef(null),[a,o]=c.useState(e.basename),[d,h]=c.useState(),[u,v]=c.useState(Promise.resolve()),m=c.useCallback(()=>{var P;(P=s.current)===null||P===void 0||P.focus()},[s]),p=c.useCallback(P=>P.stopPropagation(),[]),E=c.useCallback(()=>{u.then(()=>{n(a)}).catch(P=>yi.info("Unable to validate name",P))},[n,a,u]);c.useEffect(function(){var O=ce.makeCancelable(r(a));return O.then(()=>h(void 0)).catch(L=>{ce.isCanceled(L)||h(L)}),v(O),()=>O.cancel()},[r,a]),c.useEffect(function(){m()},[m]);var S=c.useCallback(()=>{yi.debug2("handleBlur"),E()},[E]),g=c.useCallback(P=>{var{value:O}=P.target;o(O)},[]),y=c.useCallback(P=>{P.stopPropagation();var{key:O}=P;switch(O){case"Enter":{E();break}case"Escape":{t();break}}},[t,E]);return l.jsxs("div",{className:"file-list-item-editor",children:[l.jsx("input",{type:"text",className:ee("form-control file-list-item-editor-input",{"is-invalid":d}),value:a,ref:s,onBlur:S,onKeyDown:y,onChange:g,onClick:p,onDoubleClick:p,onMouseDown:p}),d&&l.jsx("div",{className:"invalid-feedback",children:"".concat(d)})]})}function Ti(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function fn(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ti(Object(t),!0).forEach(function(n){Ul(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Ti(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function Ul(i,e,t){return e=$l(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function $l(i){var e=Bl(i,"string");return typeof e=="symbol"?e:String(e)}function Bl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}function Er(i){var{isMultiSelect:e=!1,focusedPath:t,showContextMenu:n=!1,onCreateFile:r,onCreateFolder:s,onCopy:a,onDelete:o,onMove:d,onRename:h,onSelect:u,onSelectionChange:v,table:m,rowHeight:p=Fn,validateRename:E=()=>Promise.resolve()}=i,[S,g]=c.useState(),[y,P]=c.useState([]),[O,L]=c.useState(),V=c.useCallback(I=>{P(I),v?.(I)},[v]),Z=c.useCallback(I=>{L(I)},[]),A=c.useCallback(()=>{O&&a?.(O)},[O,a]),z=c.useCallback(()=>{y.length>0&&o?.(y)},[o,y]),G=c.useCallback(()=>{r?.()},[r]),X=c.useCallback(()=>{O&&s?.(w.getPath(O.filename))},[O,s]),ve=c.useCallback(()=>{O&&g(O)},[O]),R=c.useCallback(()=>{g(void 0)},[]),$=c.useCallback(I=>{S&&(h?.(S,I),g(void 0))},[h,S]),H=c.useMemo(()=>{if(S)return[];var I=[];return r&&I.push({title:"New File",description:"Create new file",action:G,group:k.groups.medium}),s&&I.push({title:"New Folder",description:"Create new folder",action:X,group:k.groups.medium}),a&&I.push({title:"Copy File",description:"Copy the selected file",action:A,group:k.groups.low,disabled:O==null||De(O)}),o&&y.length>0&&I.push({title:"Delete",description:"Delete",shortcut:Ei.FILE_EXPLORER.DELETE,action:z,group:k.groups.low}),h&&I.push({title:"Rename",description:"Rename",shortcut:Ei.FILE_EXPLORER.RENAME,action:ve,group:k.groups.low,disabled:O==null}),I},[A,z,G,X,ve,O,a,r,s,o,h,y,S]),x=c.useCallback(I=>(N(S),E(S,I)),[S,E]),F=c.useCallback(I=>{var{item:oe}=I;return S&&S.filename===oe.filename?l.jsx(Pn,fn(fn({},I),{},{children:l.jsx(Hl,{item:oe,validate:x,onSubmit:$,onCancel:R})})):l.jsx(Pn,fn({},I))},[R,$,S,x]);return l.jsxs("div",{className:"file-list-container",children:[m!=null&&l.jsx(jl,{onMove:d,onSelect:u,onSelectionChange:V,onFocusChange:Z,renderItem:F,rowHeight:p,table:m,isMultiSelect:e,focusedPath:t}),n&&l.jsx(k,{actions:H})]})}Er.displayName="FileListContainer";function Pi(i,e,t){return e=Vl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Vl(i){var e=Wl(i,"string");return typeof e=="symbol"?e:String(e)}function Wl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Kl extends wt{constructor(e){super("Name already exists"),Pi(this,"isExistingFile",!0),Pi(this,"info",void 0),this.info=e}}const zt=Kl;function Oi(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function wi(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){Oi(s,n,r,a,o,"next",d)}function o(d){Oi(s,n,r,a,o,"throw",d)}a(void 0)})}}var Ie=Q.module("FileExplorer");function An(i){var{storage:e,isMultiSelect:t=!1,focusedPath:n,onCopy:r=()=>{},onDelete:s=()=>{},onRename:a=()=>{},onCreateFile:o=()=>{},onCreateFolder:d=()=>{},onSelect:h,onSelectionChange:u,rowHeight:v=Fn}=i,[m,p]=c.useState([]),[E,S]=c.useState();c.useEffect(function(){var $;function H(){return x.apply(this,arguments)}function x(){return x=wi(function*(){Ie.debug("initTable"),$=ce.makeCancelable(e.getTable(),F=>F.close());try{S(yield $)}catch(F){ce.isCanceled(F)||Ie.error("Unable to initialize table",F)}}),x.apply(this,arguments)}return H(),()=>{$.cancel()}},[e]);var g=c.useCallback(R=>{ce.isCanceled(R)||Ie.error(R)},[]),y=c.useCallback(()=>{Ie.debug("handleCreateFile"),o()},[o]),P=c.useCallback(()=>{Ie.debug("handleCreateFolder"),d()},[d]),O=c.useCallback(R=>{Ie.debug("handleCopyFile",R.filename),r(R)},[r]),L=c.useCallback(R=>{Ie.debug("handleDelete, pending confirmation",R),p(R)},[]),V=c.useCallback(()=>{Ie.debug("handleDeleteConfirm",m),m.forEach(R=>e.deleteFile(De(R)?w.makePath(R.filename):R.filename)),s(m),p([])},[m,s,e]),Z=c.useCallback(()=>{Ie.debug("handleDeleteCancel"),p([])},[]),A=c.useCallback((R,$)=>{var H=w.reducePaths(R.map(x=>De(x)?w.makePath(x.filename):x.filename));H.forEach(x=>{var F=w.isPath(x)?"".concat($).concat(w.getBaseName(x.substring(0,x.length-1)),"/"):"".concat($).concat(w.getBaseName(x));e.moveFile(x,F).then(()=>{a(x,F)}).catch(g)})},[g,a,e]),z=c.useCallback((R,$)=>{var H=R.filename,x=De(R);x&&!H.endsWith("/")&&(H="".concat(H,"/"));var F="".concat(w.getParent(H)).concat($);x&&!F.endsWith("/")&&(F="".concat(F,"/")),Ie.debug2("handleRename",H,F),e.moveFile(H,F).catch(g),a(H,F)},[g,a,e]),G=c.useCallback(function(){var R=wi(function*($,H){if(H!==$.basename){w.validateName(H);var x="".concat(w.getPath($.filename)).concat(H);try{var F=yield e.info(x);throw new zt(F)}catch(I){if(!(I instanceof Mn))throw I}}});return function($,H){return R.apply(this,arguments)}}(),[e]),X=m.length>0,ve=c.useMemo(()=>m.length===1?'Are you sure you want to delete "'.concat(m[0].filename,'"?'):"Are you sure you want to delete the selected files?",[m]);return l.jsxs("div",{className:"file-explorer",children:[E&&l.jsx(Er,{isMultiSelect:t,focusedPath:n,showContextMenu:!0,onCopy:O,onCreateFolder:P,onCreateFile:y,onMove:A,onDelete:L,onRename:z,onSelect:h,onSelectionChange:u,rowHeight:v,table:E,validateRename:G}),l.jsx(Lt,{isOpen:X,headerText:ve,bodyText:"You cannot undo this action.",onCancel:Z,onConfirm:V,confirmButtonText:"Delete"})]})}An.displayName="FileExplorer";function Ni(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function Gl(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){Ni(s,n,r,a,o,"next",d)}function o(d){Ni(s,n,r,a,o,"throw",d)}a(void 0)})}}function qe(i,e,t){return e=zl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function zl(i){var e=Yl(i,"string");return typeof e=="symbol"?e:String(e)}function Yl(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var tt=Q.module("NewItemModal");class at extends c.PureComponent{static getValidationMessage(e){return e instanceof zt&&e.info.type==="directory"?"Error: Cannot overwrite existing directory":"".concat(e)}static handleError(e){ce.isCanceled(e)||tt.error(e)}constructor(e){super(e),qe(this,"inputRef",se.createRef()),qe(this,"cancelableValidatePromise",void 0),qe(this,"cancelableExistingItemPromise",void 0),qe(this,"pending",new pt),qe(this,"pathMap",new Map),qe(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);var{defaultValue:t}=e,n=w.hasPath(t)?w.getPath(t):"/";this.state={isSubmitting:!1,path:n,prevExtension:w.getExtension(t),showExtensionChangeModal:!1,showOverwriteModal:!1,value:w.getBaseName(t)}}componentDidUpdate(e,t){var{isOpen:n}=this.props,{isOpen:r}=e,{value:s,path:a}=this.state;!r&&n&&(this.resetValue(),this.isInitialLoad=!0),r&&n&&(!this.isInitialLoad&&(a!==t.path||s!==t.value)&&this.updateValidationStatus(a,s),this.isInitialLoad=!1)}componentWillUnmount(){this.pending.cancel(),this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableExistingItemPromise&&this.cancelableExistingItemPromise.cancel()}resetValue(){var{defaultValue:e}=this.props,t=w.hasPath(e)?w.getPath(e):"/";this.setState({path:t,value:w.getBaseName(e),validationError:void 0,prevExtension:w.getExtension(e),isSubmitting:!1})}getValidationPromise(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;return this.cancelableValidatePromise&&this.cancelableValidatePromise.cancel(),this.cancelableValidatePromise=ce.makeCancelable(this.validateName(e,t,n)),this.cancelableValidatePromise}validateName(e,t,n){var r=this;return Gl(function*(){w.validateName(t);var{defaultValue:s,storage:a}=r.props;if(n){var o="".concat(e).concat(t);if(o!==s)try{var d=yield a.info(o);throw new zt(d)}catch(h){if(!(h instanceof Mn))throw h}}return t})()}updateValidationStatus(e,t){this.getValidationPromise(e,t).then(()=>{this.setState({validationError:void 0})}).catch(this.handleValidationError).catch(at.handleError)}handleModalOpened(){this.focusRenameInput()}handleModalSubmit(){this.submitModal()}handleChange(e){var{value:t}=e.target;this.setState({value:t})}handleSelect(e){if(tt.debug("handleSelect",e),e.type==="directory")this.setState({path:w.makePath(e.filename)});else{var t=e.basename,n=w.getPath(e.filename);this.setState({value:t,path:n},()=>{this.focusRenameInput()})}}handleKeyDown(e){var{key:t}=e;switch(e.stopPropagation(),t){case"Enter":{e.preventDefault(),this.submitModal();break}case"Escape":{e.preventDefault();var{onCancel:n}=this.props;n();break}}}handleValidationError(e){if(!(e instanceof wt))throw e;tt.debug("Validation error",e),this.setState({validationError:e})}handleOverwriteCancel(){this.setState({showOverwriteModal:!1,isSubmitting:!1})}handleOverwriteConfirm(){this.setState({showOverwriteModal:!1});var{onSubmit:e}=this.props,{path:t,value:n}=this.state;tt.debug("handleOverwriteConfirm",t,n),e("".concat(t).concat(n),!0)}handleExtensionChangeCancel(){tt.debug("handleExtensionChangeCancel"),this.setState(e=>{var{value:t,prevExtension:n}=e,r=w.replaceExtension(t,n);return{showExtensionChangeModal:!1,value:r}}),this.submitModal(!0)}handleExtensionChangeConfirm(){tt.debug("handleExtensionChangeConfirm"),this.setState({showExtensionChangeModal:!1}),this.submitModal(!0)}focusRenameInput(){var e=this.inputRef.current;if(e){var{type:t}=this.props,{value:n}=e,r=t==="directory"?n.length:n.lastIndexOf(".");e.focus(),e.setSelectionRange(0,r>0?r:n.length)}}submitModal(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.setState(t=>{var{prevExtension:n,value:r,path:s}=t,{notifyOnExtensionChange:a,type:o}=this.props;tt.debug("submitModal",n,r);var d=w.getExtension(r);return a&&!e&&n!==null&&n!==d?{isSubmitting:!1,showExtensionChangeModal:!0,newExtension:d}:(this.getValidationPromise(s,r,!0).then(h=>{var{onSubmit:u}=this.props;u("".concat(s).concat(r))}).catch(h=>{if(h instanceof zt&&o!=="directory"&&h.info.type!=="directory"){this.setState({showOverwriteModal:!0});return}throw h}).catch(h=>{throw ce.isCanceled(h)&&this.setState({isSubmitting:!1}),h}).catch(this.handleValidationError).catch(at.handleError),{isSubmitting:!0,showExtensionChangeModal:!1,newExtension:void 0})})}handleBreadcrumbSelect(e){this.setState({path:e})}renderPathButtons(e){var t=e.split("/");return t.pop(),t.map((n,r)=>{for(var s="",a=0;a<r;a+=1)s+="".concat(t[a],"/");return s+="".concat(n,"/"),l.jsxs(se.Fragment,{children:[l.jsx(K,{kind:"ghost",className:"directory-breadcrumbs",onClick:()=>this.handleBreadcrumbSelect(s),"aria-label":r===0?"Home":void 0,icon:r===0?l.jsx(re,{icon:Jr,transform:"right-1.6"}):void 0,tooltip:r===0?"Home":void 0,children:n}),"/"]},s)})}render(){var{storage:e,isOpen:t,onCancel:n,placeholder:r,title:s,type:a}=this.props,{isSubmitting:o,path:d,showExtensionChangeModal:h,showOverwriteModal:u,validationError:v,value:m,prevExtension:p,newExtension:E}=this.state,S=a==="directory",g=w.fileExtensionToString(p),y=w.fileExtensionToString(E),P=S?"Create":"Save",O=S?"New folder name":"Save file as";return l.jsxs(l.Fragment,{children:[l.jsxs(es,{isOpen:t,toggle:n,onOpened:this.handleModalOpened,className:"modal-dialog-centered new-file-modal",children:[l.jsx(ts,{toggle:n,children:s}),l.jsx(ns,{children:l.jsx("form",{children:l.jsxs("div",{className:"d-flex flex-column new-file-modal-content",children:[l.jsxs("div",{className:"flex-grow-0 mb-4",children:[l.jsx("label",{htmlFor:"file-name-input",children:O}),l.jsx("input",{id:"file-name-input",type:"text",autoComplete:"off",autoCapitalize:"none",autoCorrect:"off",spellCheck:"false",className:ee("form-control",{"is-invalid":v}),value:m,placeholder:r,ref:this.inputRef,onKeyDown:this.handleKeyDown,onChange:this.handleChange}),v&&l.jsx("div",{className:"invalid-feedback",children:at.getValidationMessage(v)})]}),l.jsxs("div",{className:"flex-grow-0",children:[l.jsx("label",{children:"Directory: /"}),this.renderPathButtons(d)]}),l.jsx("div",{className:"flex-grow-1 file-explorer-container",children:l.jsx(An,{onSelect:this.handleSelect,storage:e,focusedPath:d})})]})})}),l.jsxs(_s,{children:[l.jsx(K,{kind:"secondary",onClick:n,children:"Cancel"}),l.jsx(K,{kind:"primary",disabled:o,onClick:this.handleModalSubmit,children:P})]})]}),l.jsx(Lt,{isOpen:u,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"}),l.jsx(Lt,{isOpen:h,headerText:"Confirm extension change",bodyText:'Are you sure you want to change extension from "'.concat(g,'" to "').concat(y,'"?'),onCancel:this.handleExtensionChangeCancel,onConfirm:this.handleExtensionChangeConfirm,cancelButtonText:'Keep "'.concat(g,'"'),confirmButtonText:'Use "'.concat(y,'"')})]})}}qe(at,"propTypes",{isOpen:Me.bool,title:Me.string.isRequired,defaultValue:Me.string,type:Me.oneOf(["file","directory"]).isRequired,onSubmit:Me.func,onCancel:Me.func,placeholder:Me.string,storage:Me.shape({}).isRequired,notifyOnExtensionChange:Me.bool});qe(at,"defaultProps",{isOpen:!1,defaultValue:"/",notifyOnExtensionChange:!1,placeholder:"",onSubmit:(i,e)=>{},onCancel:()=>{}});const yr=at;function ql(i){var{createFile:e,createFolder:t,onSearchChange:n,defaultSearchText:r=""}=i;return l.jsxs("div",{className:"file-explorer-toolbar",children:[l.jsxs("div",{className:"file-explorer-toolbar-buttons",children:[l.jsx(K,{kind:"ghost",icon:Gi,tooltip:"New notebook",onClick:e,"aria-label":"New notebook"}),l.jsx(K,{kind:"ghost",icon:is,tooltip:"New folder",onClick:t,"aria-label":"New folder"})]}),n&&l.jsx("div",{className:"file-explorer-toolbar-search",children:l.jsx(ks,{value:r,onChange:n,placeholder:"Search by name"})})]})}function xi(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function Zl(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){xi(s,n,r,a,o,"next",d)}function o(d){xi(s,n,r,a,o,"throw",d)}a(void 0)})}}function Tr(i,e,t){return e=Xl(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Xl(i){var e=Ql(i,"string");return typeof e=="symbol"?e:String(e)}function Ql(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var nt=Q.module("FileExplorerPanel"),Jl=(i,e)=>{var t=cr(i),n=jt(i,e.localDashboardId),{session:r,config:s}=n??{},a=s?.type;return{fileStorage:t,language:a,session:r}},ed=It(Jl,null,null,{forwardRef:!0});function td(i){var e=i;return e!=null&&typeof e.button=="number"}class mt extends se.Component{static handleError(e){nt.error(e)}static isFocusEvent(e){return td(e)?e.detail>=2:!0}constructor(e){super(e),this.handleFileSelect=this.handleFileSelect.bind(this),this.handleCopyFile=this.handleCopyFile.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);var{session:t,language:n}=e;this.state={isShown:!1,language:n,session:t,showCreateFolder:!1,focusedFilePath:"/"}}componentDidMount(){this.isHidden()||this.setState({isShown:!0})}handleCreateFile(){var{glEventHub:e}=this.props,{session:t,language:n}=this.state,r={language:n,value:""};nt.debug("handleCreateFile",t,n,r),e.emit(W.CREATE_NOTEBOOK,t,n,r)}handleCreateDirectory(){this.setState({showCreateFolder:!0})}handleCreateDirectoryCancel(){nt.debug("handleCreateDirectoryCancel"),this.setState({showCreateFolder:!1})}handleCreateDirectorySubmit(e){nt.debug("handleCreateDirectorySubmit",e),this.setState({showCreateFolder:!1});var{fileStorage:t}=this.props;t.createDirectory(e).catch(mt.handleError)}handleCopyFile(e){var t=this;return Zl(function*(){var{fileStorage:n}=t.props;if(De(e)){nt.error("Invalid item in handleCopyItem",e);return}var r=yield w.getUniqueCopyFileName(n,e.filename);yield n.copyFile(e.filename,r)})()}handleDelete(e){var{glEventHub:t}=this.props;e.forEach(n=>{t.emit(W.CLOSE_FILE,{id:n.filename,itemName:n.filename})})}handleSelectionChange(e){var t="/";e.length===1&&(e[0].type==="directory"?t=w.makePath(e[0].filename):t=w.getPath(e[0].filename)),this.setState({focusedFilePath:t})}handleFileSelect(e,t){if(nt.debug("fileSelect",e),e.type!=="directory"){var n=mt.isFocusEvent(t),r={id:e.filename,itemName:e.filename},{glEventHub:s}=this.props,{session:a,language:o}=this.state,d={value:null,language:o};s.emit(W.SELECT_NOTEBOOK,a,o,d,r,n)}}handleRename(e,t){var{glEventHub:n}=this.props;nt.debug("handleRename",e,t),n.emit(W.RENAME_FILE,e,t)}handleSessionOpened(e,t){var{language:n}=t;this.setState({session:e,language:n})}handleSessionClosed(){this.setState({session:void 0,language:void 0})}handleShow(){this.setState({isShown:!0})}isHidden(){var{glContainer:e}=this.props,{isHidden:t}=e;return t}render(){var{fileStorage:e,glContainer:t,glEventHub:n}=this.props,{isShown:r,showCreateFolder:s,focusedFilePath:a}=this.state;return l.jsxs(At,{className:"file-explorer-panel",componentPanel:this,glContainer:t,glEventHub:n,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onShow:this.handleShow,children:[l.jsx(ql,{createFile:this.handleCreateFile,createFolder:this.handleCreateDirectory}),r&&l.jsx(An,{isMultiSelect:!0,storage:e,onCopy:this.handleCopyFile,onCreateFile:this.handleCreateFile,onCreateFolder:this.handleCreateDirectory,onDelete:this.handleDelete,onRename:this.handleRename,onSelect:this.handleFileSelect,onSelectionChange:this.handleSelectionChange}),l.jsx(yr,{isOpen:s,type:"directory",title:"Create New Folder",storage:e,onSubmit:this.handleCreateDirectorySubmit,onCancel:this.handleCreateDirectoryCancel,defaultValue:a})]})}}Tr(mt,"COMPONENT","FileExplorerPanel");Tr(mt,"TITLE","File Explorer");var nd=ed(mt);const id=nd;function Rt(i,e,t){return e=rd(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function rd(i){var e=sd(i,"string");return typeof e=="symbol"?e:String(e)}function sd(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var Di=Q.module("LogPanel");class on extends c.PureComponent{constructor(e){super(e),Rt(this,"isBottomVisible",void 0),Rt(this,"logView",void 0),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;var{session:t}=this.props;this.state={session:t}}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){Di.debug("Session opened",[e]),this.setState({session:e})}handleSessionClosed(e){Di.debug("Session closed",e)}updateDimensions(){this.logView&&this.logView.updateDimensions()}render(){var{glContainer:e,glEventHub:t}=this.props,{session:n}=this.state;return l.jsxs(At,{componentPanel:this,glContainer:e,glEventHub:t,onResize:this.handleResize,onHide:this.handleHide,onShow:this.handleShow,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,children:[n==null&&l.jsx("div",{className:"log-panel-disconnected-message",children:"Waiting for session connection"}),n!=null&&l.jsx(vo,{session:n,ref:r=>{this.logView=r}})]})}}Rt(on,"defaultProps",{session:null});Rt(on,"COMPONENT","LogPanel");Rt(on,"TITLE","Log");var ad=(i,e)=>{var t;return{session:(t=jt(i,e.localDashboardId))===null||t===void 0?void 0:t.session}},od=It(ad,null,null,{forwardRef:!0})(on);const ld=od;function Yt(i,e,t){return e=dd(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function dd(i){var e=hd(i,"string");return typeof e=="symbol"?e:String(e)}function hd(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class Pr extends c.PureComponent{constructor(e){super(e),Yt(this,"commands",void 0),Yt(this,"codeElements",void 0),Yt(this,"editorScrollView",void 0),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=se.createRef(),this.state={hasCode:!1,hasRunCode:!1,nextStartLine:null}}componentDidMount(){this.updateHasCode()}componentDidUpdate(){this.updateHasCode()}updateHasCode(){var{hasCode:e}=this.state;this.commands.size===0&&e?this.setState({hasCode:!1}):this.commands.size>0&&!e&&this.setState({hasCode:!0})}getNextStartLine(e){var t=[...this.commands.keys()],n=t.findIndex(r=>r===e)+1;return n>=t.length?null:t[n]}handleRunSelected(e){var t,n;e.preventDefault(),e.stopPropagation();var{nextStartLine:r}=this.state,s=[...this.commands.keys()],a=s.findIndex(S=>S===r||r==null);if(!(a<0)){var o=s[a],d=this.commands.get(o),h=this.getNextStartLine(o),u=(t=this.codeElements.get(o))===null||t===void 0?void 0:t.current,v=u==null||(n=u.parentElement)===null||n===void 0?void 0:n.nextElementSibling;if(v!=null){var m,{offsetTop:p}=v,E=p;(m=this.editorScrollView.current)===null||m===void 0||m.scroll({top:E,left:0})}this.runCode(d),this.setState({nextStartLine:h})}}runCode(e){var{onRunCode:t}=this.props;t(e),this.setState({hasRunCode:!0})}renderCodeBlock(e){var{children:t,className:n,inline:r,node:s}=e,{hasRunCode:a,nextStartLine:o}=this.state,{children:d,position:h}=s;N(h);var{start:u}=h,{line:v}=u,m=d[0].value,p=se.createRef(),E=this.commands.size===0,S=o===v||E&&o==null&&!a,g=n!==void 0&&n.startsWith("language-")?n.substring(9):"plaintext";return r!=null&&r?l.jsx("code",{className:n,children:t}):(this.commands.set(v,m),this.codeElements.set(v,p),l.jsxs("div",{className:ee("markdown-notebook-code-block",{"is-selected":S}),ref:p,onClick:()=>{this.setState({nextStartLine:v})},role:"presentation",children:[l.jsx(K,{kind:"ghost",icon:qt,className:"btn-play-block",onClick:y=>{y.stopPropagation(),y.preventDefault(),this.runCode(m),this.setState({nextStartLine:v})},tooltip:"Run code"}),l.jsx("code",{children:l.jsx(Dn,{language:g,children:se.Children.map(t,y=>typeof y=="string"?y.trim():y)})})]}))}renderLink(e){var{onLinkClick:t}=this.props,{href:n,children:r,target:s}=e;return l.jsx("a",{href:n,onClick:t,target:s,children:r})}render(){var{content:e,transformImageUri:t,transformLinkUri:n}=this.props,{hasCode:r,hasRunCode:s,nextStartLine:a}=this.state;return l.jsxs("div",{className:"markdown-notebook",children:[l.jsx("div",{className:"markdown-notebook-toolbar",children:l.jsx(K,{className:ee("btn-play-selected-cell",{flashing:r&&!s}),kind:"ghost",icon:qt,onClick:this.handleRunSelected,tooltip:"Run code and select next",disabled:s&&a==null||!r,children:"Run Selected Code"})}),l.jsx("div",{className:"markdown-notebook-content",ref:this.editorScrollView,children:l.jsx(Mr,{components:{code:this.renderCodeBlock,a:this.renderLink},linkTarget:"_blank",remarkPlugins:[Fr],transformLinkUri:n,transformImageUri:t,includeElementIndex:!0,children:e})})]})}}Yt(Pr,"defaultProps",{onRunCode:()=>{}});const ud=Pr;function Li(i,e,t,n,r,s,a){try{var o=i[s](a),d=o.value}catch(h){t(h);return}o.done?e(d):Promise.resolve(d).then(n,r)}function Ri(i){return function(){var e=this,t=arguments;return new Promise(function(n,r){var s=i.apply(e,t);function a(d){Li(s,n,r,a,o,"next",d)}function o(d){Li(s,n,r,a,o,"throw",d)}a(void 0)})}}function Ii(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Se(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Ii(Object(t),!0).forEach(function(n){ue(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Ii(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function ue(i,e,t){return e=cd(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function cd(i){var e=vd(i,"string");return typeof e=="symbol"?e:String(e)}function vd(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var _=Q.module("NotebookPanel"),Mi=400;class le extends c.Component{static handleError(e){ce.isCanceled(e)||_.error(e)}static unsavedNotebookCount(){return document.querySelectorAll(".".concat(le.UNSAVED_INDICATOR_CLASS_NAME,".").concat(le.UNSAVED_STATUS_CLASS_NAME)).length}static languageFromFileName(e){var t=w.getExtension(e).toLowerCase();switch(t){case"py":case"python":return"python";case"groovy":return"groovy";case"scala":return"scala";default:return null}}constructor(e){super(e),ue(this,"pending",void 0),ue(this,"debouncedSavePanelState",void 0),ue(this,"debouncedLoad",void 0),ue(this,"notebook",void 0),ue(this,"tabTitleElement",void 0),ue(this,"tabInitOnce",void 0),ue(this,"editor",void 0),ue(this,"getSettings",_e((m,p)=>Se(Se({},m),{},{minimap:{enabled:p}}))),ue(this,"getOverflowActions",_e((m,p)=>[{title:"Find",icon:as,action:this.handleFind,group:k.groups.high,shortcut:be.NOTEBOOK.FIND,order:10},{title:"Copy File",icon:os,action:this.handleCopy,group:k.groups.medium,order:20},{title:"Rename File",icon:ls,action:this.handleShowRename,group:k.groups.medium,order:30},{title:"Delete File",icon:Vi,action:this.handleDelete,group:k.groups.medium,order:40},{title:"Show Minimap",icon:m?Pt:void 0,action:this.handleMinimapChange,group:k.groups.low,shortcut:be.NOTEBOOK.MINIMAP,order:20},{title:"Word Wrap",icon:p?Pt:void 0,action:this.handleWordWrapChange,group:k.groups.low,shortcut:be.NOTEBOOK.WORDWRAP,order:30}])),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.handleDelete=this.handleDelete.bind(this),this.handleDeleteConfirm=this.handleDeleteConfirm.bind(this),this.handleDeleteCancel=this.handleDeleteCancel.bind(this),this.handleEditorInitialized=this.handleEditorInitialized.bind(this),this.handleEditorWillDestroy=this.handleEditorWillDestroy.bind(this),this.handleEditorChange=this.handleEditorChange.bind(this),this.handleFind=this.handleFind.bind(this),this.handleMinimapChange=this.handleMinimapChange.bind(this),this.handleWordWrapChange=this.handleWordWrapChange.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.handlePanelDropped=this.handlePanelDropped.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.handleTabBlur=this.handleTabBlur.bind(this),this.handleTabClick=this.handleTabClick.bind(this),this.handleTabFocus=this.handleTabFocus.bind(this),this.handleTransformLinkUri=this.handleTransformLinkUri.bind(this),this.handleOverwrite=this.handleOverwrite.bind(this),this.handlePreviewPromotion=this.handlePreviewPromotion.bind(this),this.getDropdownOverflowActions=this.getDropdownOverflowActions.bind(this),this.pending=new pt,this.debouncedSavePanelState=Dt(this.savePanelState.bind(this),Mi),this.debouncedLoad=Dt(this.load.bind(this),Mi),this.notebook=null,this.tabTitleElement=null,this.tabInitOnce=!1;var{isDashboardActive:t,session:n,sessionLanguage:r,panelState:s}=e,a={value:"",language:"",wordWrap:"off"},o=null,{isPreview:d}=e;s!=null&&({fileMetadata:o=o,isPreview:d=d,settings:a=a}=s);var h=o!=null&&w.hasPath(o.itemName),u=h===!0&&a.value!=null||!h&&a.value!=null&&a.value.length>0,v=u?1:0;this.state={error:void 0,isDashboardActive:t,isFocused:!1,isLoading:!0,isLoaded:!1,isPreview:d,savedChangeCount:0,changeCount:v,fileMetadata:o,settings:a,session:n,sessionLanguage:r,panelState:{fileMetadata:o,settings:a},showCloseModal:!1,showDeleteModal:!1,showSaveAsModal:!1,scriptCode:""},_.debug("constructor",e,this.state)}componentDidMount(){var{glContainer:e,glEventHub:t}=this.props,{tab:n}=e;n!=null&&this.initTab(n),this.initNotebookContent(),t.on(W.RENAME_FILE,this.handleRenameFile),t.on(xe.DROPPED,this.handlePanelDropped),e.on(W.PROMOTE_FROM_PREVIEW,this.handlePreviewPromotion)}componentDidUpdate(e,t){var{isPreview:n,settings:r}=this.state,{wordWrap:s}=r,{defaultNotebookSettings:a}=this.props;n!==t.isPreview&&this.setPreviewStatus(),s!==t.settings.wordWrap&&(this.updateEditorWordWrap(),this.debouncedSavePanelState()),a.isMinimapEnabled!==e.defaultNotebookSettings.isMinimapEnabled&&this.updateEditorMinimap()}componentWillUnmount(){this.debouncedSavePanelState.flush(),this.pending.cancel();var{glEventHub:e,glContainer:t}=this.props,{fileMetadata:n,isPreview:r}=this.state;e.off(W.RENAME_FILE,this.handleRenameFile),e.off(xe.DROPPED,this.handlePanelDropped),t.off(W.PROMOTE_FROM_PREVIEW,this.handlePreviewPromotion),e.emit(W.UNREGISTER_FILE,n,r)}initTab(e){this.tabInitOnce||(this.tabInitOnce=!0,this.initTabCloseOverride()),this.initTabClasses(e)}initTabCloseOverride(){var{glContainer:e}=this.props;e.beforeClose(t=>{if(t?.force===!0)return!0;var{changeCount:n,savedChangeCount:r}=this.state;return n!==r?(this.setState({showCloseModal:!0}),!1):!0})}initTabClasses(e){var t=e.element.get(0);N(t);var n=t.querySelector(".lm_title");this.tabTitleElement=n,n?.classList.add("notebook-title"),this.setPreviewStatus()}getNotebookValue(){var{changeCount:e,savedChangeCount:t,settings:n}=this.state,{value:r}=n;if(e!==t&&this.notebook){var s=this.notebook.getValue();return s??r}return r}initNotebookContent(){var{fileMetadata:e,settings:t,isPreview:n}=this.state;if(e&&e.id){_.debug("Init content from file"),this.registerFileMetadata(e,n),this.load();return}if(t.value!=null){_.debug("Use content passed in the settings prop"),this.handleLoadSuccess();return}this.handleLoadError(new Error("Missing file metadata"))}closeFileTabById(e){var{glEventHub:t}=this.props;t.emit(W.CLOSE_FILE,{id:e})}registerFileMetadata(e,t){var{glEventHub:n,metadata:r}=this.props,{id:s}=r;n.emit(W.REGISTER_FILE,s,e,t)}renameTab(e,t){var{glEventHub:n}=this.props;n.emit(W.RENAME,e,t)}load(){var{fileMetadata:e,settings:t}=this.state;N(e);var{id:n}=e,{fileStorage:r}=this.props;this.pending.add(r.loadFile(n)).then(s=>{var a;_.debug("Loaded file",s);var{filename:o}=s,{itemName:d}=this.state;if(o!==d){var{metadata:h}=this.props,{id:u}=h;this.renameTab(u,w.getBaseName(o))}var v=Se(Se({},t),{},{language:(a=le.languageFromFileName(o))!==null&&a!==void 0?a:""});t.value==null&&(v.value=s.content),t.wordWrap===void 0&&(t.wordWrap="off"),this.setState({fileMetadata:{id:o,itemName:o},settings:v}),this.debouncedSavePanelState()}).then(this.handleLoadSuccess).catch(this.handleLoadError)}save(){var{fileMetadata:e}=this.state;if(e&&w.hasPath(e.itemName)){var t=this.getNotebookValue();return t!==void 0?(this.saveContent(e.itemName,t),!0):!1}return this.setState({showSaveAsModal:!0}),!1}saveContent(e,t){_.debug("saveContent",e,t),this.updateSavedChangeCount();var{fileStorage:n}=this.props;this.pending.add(n.saveFile({filename:e,content:t,basename:e})).then(this.handleSaveSuccess).catch(this.handleSaveError)}updateSavedChangeCount(){this.setState(e=>{var{changeCount:t}=e;return{savedChangeCount:t}})}setPreviewStatus(){if(this.tabTitleElement){var{isPreview:e}=this.state;_.debug("setPreviewStatus",this.tabTitleElement,e),e?this.tabTitleElement.classList.add("is-preview"):this.tabTitleElement.classList.remove("is-preview")}}handlePreviewPromotion(){this.removePreviewStatus()}savePanelState(){this.setState(e=>{var{changeCount:t,savedChangeCount:n,fileMetadata:r,isPreview:s,settings:a}=e,o=this.getNotebookValue(),d=t!==n?o:void 0,h=Se(Se({},a),{},{value:o}),u=Se(Se({},a),{},{value:d}),v={settings:u,fileMetadata:r,isPreview:s};return _.debug("Saving panel state",v),{settings:h,panelState:v}})}handleCloseDiscard(){this.setState({showCloseModal:!1});var{glContainer:e}=this.props;e.close({force:!0})}handleCloseSave(){if(this.setState({showCloseModal:!1}),this.save()){var{glContainer:e}=this.props;e.close({force:!0})}}handleCloseCancel(){this.setState({showCloseModal:!1})}handleOverwrite(e){var{glEventHub:t}=this.props;t.emit(W.CLOSE_FILE,{id:e,itemName:e},{force:!0}),this.focus()}handleCopy(){var e=this;return Ri(function*(){var{fileStorage:t,glEventHub:n,session:r}=e.props,{fileMetadata:s,settings:a}=e.state;N(s);var{language:o}=a,{itemName:d}=s,h=yield w.getUniqueCopyFileName(t,d);_.debug("handleCopy",s,d,h),yield t.copyFile(d,h);var u={id:h,itemName:h},v={value:null,language:o};n.emit(W.SELECT_NOTEBOOK,r,o,v,u,!0)})()}handleDelete(){_.debug("handleDelete, pending confirmation"),this.setState({showDeleteModal:!0})}handleDeleteConfirm(){var e=this;return Ri(function*(){var{fileStorage:t,glContainer:n,glEventHub:r}=e.props,{fileMetadata:s}=e.state;_.debug("handleDeleteConfirm",s?.itemName),e.setState({showDeleteModal:!1}),s&&(w.hasPath(s.itemName)&&(yield w.fileExists(t,s.itemName))?(r.emit(W.CLOSE_FILE,s,{force:!0}),t.deleteFile(s.itemName)):n.close({force:!0}))})()}handleDeleteCancel(){this.setState({showDeleteModal:!1})}handleEditorInitialized(e){this.editor=e}handleEditorWillDestroy(){this.editor=void 0}handleEditorChange(e){_.debug2("handleEditorChanged",e),this.removePreviewStatus(),this.setState(t=>{var{changeCount:n,savedChangeCount:r}=t,{isUndoing:s,isRedoing:a}=e;return s?{changeCount:n-1,savedChangeCount:r}:!a&&n<r?{changeCount:n+1,savedChangeCount:0}:{changeCount:n+1,savedChangeCount:r}}),this.debouncedSavePanelState()}handleFind(){this.notebook&&this.notebook.toggleFind()}updateEditorMinimap(){if(this.editor){var{defaultNotebookSettings:e}=this.props;this.editor.updateOptions({minimap:{enabled:e.isMinimapEnabled}})}}handleMinimapChange(){var e,{defaultNotebookSettings:t,updateSettings:n}=this.props,r={defaultNotebookSettings:{isMinimapEnabled:!((e=t.isMinimapEnabled)!==null&&e!==void 0&&e)}};n(r)}updateEditorWordWrap(){if(this.editor){var{settings:e}=this.state,{wordWrap:t}=e;this.editor.updateOptions({wordWrap:t})}}handleWordWrapChange(){this.editor&&this.setState(e=>{var{settings:t}=e,n=t.wordWrap==="on"?"off":"on";return{settings:Se(Se({},t),{},{wordWrap:n})}})}handleBlur(){_.debug("handleBlur"),this.setState({isFocused:!1})}handleFocus(){_.debug("handleFocus"),this.setState({isFocused:!0})}handleLinkClick(e){var{notebooksUrl:t,session:n,sessionLanguage:r}=this.props,{href:s}=e.currentTarget;if(!(!s||!s.startsWith(t))){e.stopPropagation(),e.preventDefault();var a="/".concat(s.substring(t.length)).replace(/%20/g," ");if(a==="/"){_.debug("Ignoring invalid notebook link",a);return}_.debug("Notebook link clicked, opening",a);var{glEventHub:o}=this.props,d={value:null,language:r},h={id:a,itemName:a};o.emit(W.SELECT_NOTEBOOK,n,r,d,h)}}handleLoadSuccess(){this.setState({error:void 0,isLoaded:!0,isLoading:!1})}handleLoadError(e){var t=e;ce.isCanceled(t)||(ce.isTimedOut(t)&&(t=new Error("File not found.")),_.error(t),this.setState({error:t,isLoading:!1}))}handleSave(){_.debug("handleSave"),this.save()}handleSaveSuccess(e){var t,{fileStorage:n}=this.props,r={id:e.filename,itemName:e.filename},s=(t=le.languageFromFileName(e.filename))!==null&&t!==void 0?t:"";this.setState(a=>{var{fileMetadata:o}=a,d=Se(Se({},a.settings),{},{language:s});return _.debug("handleSaveSuccess",r,o,d),o&&w.hasPath(o.itemName)&&o.itemName!==r.itemName&&(_.debug("handleSaveSuccess deleting old file",o.itemName),n.deleteFile(o.itemName).catch(le.handleError)),{fileMetadata:r,settings:d,isPreview:!1}}),this.debouncedSavePanelState(),this.registerFileMetadata(r,!1)}handleSaveError(e){ce.isCanceled(e)||(this.setState({savedChangeCount:0}),_.error(e))}handleSaveAsCancel(){this.setState({showSaveAsModal:!1})}handleSaveAsSubmit(e){var t,n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;n&&this.handleOverwrite(e),_.debug("handleSaveAsSubmit",e);var{fileMetadata:r}=this.state;if(r){var{itemName:s}=r,a=(t=this.getNotebookValue())!==null&&t!==void 0?t:"";if(this.setState({showSaveAsModal:!1}),w.getBaseName(s)!==w.getBaseName(e)){var{metadata:o}=this.props,{id:d}=o;this.renameTab(d,w.getBaseName(e))}this.saveContent(e,a)}}handleRenameFile(e,t,n){var{fileMetadata:r,panelState:s}=this.state,{glContainer:a}=this.props;if(r?.itemName==="/".concat(t)&&n&&JSON.stringify(s)!==JSON.stringify(n)){a.close();return}r&&r.id===e&&(this.setState({fileMetadata:{id:t,itemName:t}}),this.debouncedSavePanelState())}handleResize(){var e;(e=this.notebook)===null||e===void 0||e.updateDimensions()}handleRunCommand(e){this.runCommand(e)}handleRunAll(){var e;if(!this.notebook){_.error("Editor is not initialized.");return}this.runCommand((e=this.notebook.getValue())!==null&&e!==void 0?e:void 0)}handleRunSelected(){if(!this.notebook){_.error("Editor is not initialized.");return}this.runCommand(this.notebook.getSelectedCommand())}handleSessionOpened(e,t){var{language:n}=t;this.setState({session:e,sessionLanguage:n})}handleSessionClosed(){this.setState({session:void 0,sessionLanguage:void 0})}handleShow(){var e;_.debug("handleShow"),(e=this.notebook)===null||e===void 0||e.updateDimensions()}handlePanelDropped(e){var{metadata:{id:t}}=this.props;e===t&&this.forceUpdate()}handleShowRename(){this.setState({showSaveAsModal:!0})}handleTab(e){_.debug("NotebookPanel tab event",e),this.initTab(e)}handleTabFocus(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];_.debug("handleTabFocus",...t);var{glContainer:r}=this.props;this.setState({isDashboardActive:!0}),this.notebook&&!r.isHidden&&this.notebook.updateDimensions()}handleTabBlur(){_.debug("handleTabBlur"),this.setState({isDashboardActive:!1})}handleTabClick(e){_.debug("handle NotebookPanel tab click"),this.focus(),e.detail===2&&this.removePreviewStatus()}handleTransformLinkUri(e){var{notebooksUrl:t}=this.props,{fileMetadata:n}=this.state;if(e.endsWith("/"))return e;if(e.startsWith("/"))return"".concat(t).concat(e.substring(1));var r=n?.itemName;if(r===void 0)return e;r.charAt(0)==="/"&&(r=r.substring(1));var s=new URL(r,t);return new URL(e,s).href}focus(){requestAnimationFrame(()=>{this.notebook&&this.notebook.focus()})}createNotebook(e,t){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"",{glEventHub:r}=this.props,{session:s,sessionLanguage:a,settings:o}=this.state,d=Se(Se({},o),{},{language:t,value:n}),h={id:null,itemName:e};_.debug("handleCreateNotebook",s,a,d,h),r.emit(W.CREATE_NOTEBOOK,s,a,d,h)}runCommand(e){if(e===void 0||e===""){_.debug("Ignoring empty command.");return}this.removePreviewStatus();var{glEventHub:t}=this.props;t.emit(we.SEND_COMMAND,e,!1,!0)}removePreviewStatus(){this.setState(e=>{var{isPreview:t}=e;if(t){var{fileMetadata:n}=this.state;return n&&this.registerFileMetadata(n,!1),{isPreview:!1}}return null})}getDropdownOverflowActions(){var e,t,{defaultNotebookSettings:n}=this.props,{settings:r}=this.state;return this.getOverflowActions((e=n.isMinimapEnabled)!==null&&e!==void 0?e:!1,this.getSettings(r,(t=n.isMinimapEnabled)!==null&&t!==void 0?t:!1).wordWrap==="on")}render(){var e,t,n,{fileStorage:r,glContainer:s,glContainer:{tab:a},glEventHub:o,defaultNotebookSettings:d}=this.props,{changeCount:h,savedChangeCount:u,error:v,isDashboardActive:m,isLoaded:p,isLoading:E,isPreview:S,fileMetadata:g,session:y,sessionLanguage:P,settings:O,showCloseModal:L,showDeleteModal:V,showSaveAsModal:Z}=this.state,A=m&&!s.isHidden&&!S,z=(e=g?.itemName)!==null&&e!==void 0?e:le.DEFAULT_NAME,G=z.endsWith(".md"),X=g?.id!=null,ve=this.getSettings(O,(t=d.isMinimapEnabled)!==null&&t!==void 0?t:!1),R=y!=null,$=P===ve.language,H=!p||!R||!$,x=!p,F=[{action:this.handleSave,shortcut:Zt.SAVE},{action:this.handleMinimapChange,shortcut:be.NOTEBOOK.MINIMAP},{action:this.handleWordWrapChange,shortcut:be.NOTEBOOK.WORDWRAP}],I=En.getDisabledRunTooltip(R,$,"Notebook extension","Run"),oe=En.getDisabledRunTooltip(R,$,"Notebook extension","Run Selected"),Ge=[{title:X?"Rename":"Save As…",order:10,group:k.groups.high,action:this.handleShowRename},{title:"Copy File",action:this.handleCopy,group:k.groups.high,order:20}],ze=a?.element.find(".lm_title_before").get(0);return l.jsxs(l.Fragment,{children:[ze!=null&&ki.createPortal(l.jsx("span",{className:ee(le.UNSAVED_INDICATOR_CLASS_NAME,{[le.UNSAVED_STATUS_CLASS_NAME]:h!==u})}),ze),l.jsxs(At,{className:"notebook-container",componentPanel:this,glContainer:s,glEventHub:o,onTab:this.handleTab,onResize:this.handleResize,onShow:this.handleShow,onTabClicked:this.handleTabClick,onTabFocus:this.handleTabFocus,onTabBlur:this.handleTabBlur,onSessionOpen:this.handleSessionOpened,onSessionClose:this.handleSessionClosed,onFocus:this.handleFocus,onBlur:this.handleBlur,additionalActions:Ge,renderTabTooltip:()=>z,children:[!G&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"notebook-toolbar",children:[l.jsxs("span",{children:[l.jsx(K,{kind:"ghost",className:"btn-play",onClick:this.handleRunAll,disabled:H,icon:l.jsx(re,{icon:qt,transform:"grow-4"}),tooltip:"Run ".concat(be.NOTEBOOK.RUN.getDisplayText()),"aria-label":"Run"}),I!=null&&l.jsx(ot,{children:I})]}),l.jsxs("span",{children:[l.jsx(K,{kind:"ghost",className:"btn-play",onClick:this.handleRunSelected,disabled:H,icon:l.jsx(re,{icon:rs,transform:"grow-4"}),tooltip:"Run Selected ".concat(be.NOTEBOOK.RUN_SELECTED.getDisplayText()),"aria-label":"Run Selected"}),oe!=null&&l.jsx(ot,{children:oe})]}),l.jsx(K,{kind:"ghost",className:"mr-auto",disabled:x,onClick:this.handleSave,icon:ss,tooltip:"Save ".concat(Zt.SAVE.getDisplayText()),"aria-label":"Save"}),l.jsx(K,{kind:"ghost",className:"btn-overflow",disabled:x,icon:Ki,tooltip:"More Actions...",onClick:()=>{},children:l.jsx(Ot,{actions:this.getDropdownOverflowActions,popperOptions:le.POPPER_OPTIONS})})]}),l.jsx(qa,{isLoaded:p,isLoading:E,error:v,onChange:this.handleEditorChange,onRunCommand:this.handleRunCommand,session:y,sessionLanguage:P,onEditorInitialized:this.handleEditorInitialized,onEditorWillDestroy:this.handleEditorWillDestroy,settings:ve,focusOnMount:A,ref:f=>{this.notebook=f}})]}),G&&l.jsx(ud,{content:(n=ve.value)!==null&&n!==void 0?n:"",onLinkClick:this.handleLinkClick,onRunCode:this.handleRunCommand,transformImageUri:this.handleTransformLinkUri,transformLinkUri:this.handleTransformLinkUri}),l.jsx(yr,{isOpen:Z,type:"file",defaultValue:z,title:X?"Rename":"Save file as",onSubmit:this.handleSaveAsSubmit,onCancel:this.handleSaveAsCancel,notifyOnExtensionChange:!0,storage:r}),l.jsx(Lt,{isOpen:V,headerText:'Are you sure you want to delete "'.concat(z,'"?'),bodyText:"You cannot undo this action.",onCancel:this.handleDeleteCancel,onConfirm:this.handleDeleteConfirm,confirmButtonText:"Delete"}),l.jsx(Lt,{isOpen:L,headerText:"Do you want to save the changes you made to ".concat(z,"?"),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"}),l.jsx(k,{actions:F})]})]})}}ue(le,"COMPONENT","NotebookPanel");ue(le,"POPPER_OPTIONS",{placement:"bottom-end"});ue(le,"DEFAULT_NAME","Untitled");ue(le,"UNSAVED_INDICATOR_CLASS_NAME","editor-unsaved-indicator");ue(le,"UNSAVED_STATUS_CLASS_NAME","is-unsaved");ue(le,"defaultProps",{isDashboardActive:!0,isPreview:!1,session:null,sessionLanguage:null,defaultNotebookSettings:{isMinimapEnabled:!0}});var md=(i,e)=>{var t=cr(i),n=Oo(i),r=jt(i,e.localDashboardId),{session:s,config:a}=r??{},{type:o}=a??{};return{fileStorage:t,defaultNotebookSettings:n,session:s,sessionLanguage:o}},pd=It(md,{updateSettings:Hs},null,{forwardRef:!0})(le);const it=pd;function Fi(i,e){var t=Object.keys(i);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(i);e&&(n=n.filter(function(r){return Object.getOwnPropertyDescriptor(i,r).enumerable})),t.push.apply(t,n)}return t}function Ai(i){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Fi(Object(t),!0).forEach(function(n){gd(i,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(i,Object.getOwnPropertyDescriptors(t)):Fi(Object(t)).forEach(function(n){Object.defineProperty(i,n,Object.getOwnPropertyDescriptor(t,n))})}return i}function gd(i,e,t){return e=fd(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function fd(i){var e=bd(i,"string");return typeof e=="symbol"?e:String(e)}function bd(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}var ie=Q.module("ConsolePlugin");function ji(i){return i.notebook!==void 0}function Cd(i){Bs(i)}function ih(i){Cd(i);var{id:e,hydrateConsole:t,layout:n,panelManager:r,registerComponent:s,notebooksUrl:a}=i,o=c.useRef(0),[d,h]=c.useState(new Map),[u,v]=c.useState(new Map),m=Ar(),p=c.useCallback(()=>r.getLastUsedPanelOfType(gn),[r]),E=c.useCallback((f,b)=>{h(T=>new Map(T.set(f,b)))},[h]),S=c.useCallback(f=>{h(b=>(b.delete(f),new Map(b)))},[h]),g=c.useCallback((f,b)=>{v(T=>new Map(T.set(f,b)))},[v]),y=c.useCallback(f=>{v(b=>(b.delete(f),new Map(b)))},[v]),P=c.useCallback(function(f){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!0,D=f&&f.trim();if(!D)ie.info("Ignoring empty code");else{var j=p();if(!j||!(j instanceof gn.WrappedComponent)){ie.error("Console panel not found");return}ie.debug("Send command: ",f,b,T),j.addCommand(f,b,T)}},[p]),O=c.useCallback(f=>{m(pl(e,f))},[m,e]),L=c.useCallback(f=>{var{language:b}=f,T=b==="python"?"py":b,D=null;return T==null?(ie.debug("No extension for language",b),D="Untitled-".concat(o.current)):D="Untitled-".concat(o.current,".").concat(T),o.current+=1,D},[]),V=c.useCallback(function(f){var b=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,{id:T}=f;if(T!=null&&d.has(T))return d.get(T);if(T!=null&&u.has(T))return u.get(T);if(b)return Hi.generate()},[d,u]),Z=c.useCallback((f,b)=>{ae.renameComponent(n.root,{id:f},b)},[n.root]),A=c.useCallback((f,b)=>{ie.debug("Rename file panel",f,b);var T;if(d.has(f)&&(T=d.get(f),S(f),T!=null&&E(b,T)),u.has(f)&&(T=u.get(f),y(f),T!=null&&g(b,T)),T===void 0){ie.debug2("File ".concat(f," isn't open, no need to rename the tab"));return}Z(T,w.getBaseName(b))},[d,u,Z,E,g,S,y]),z=c.useCallback(f=>{var b=V(f,!1);if(b==null){ie.error("Could not find panel id for file metadata",f);return}ae.activateTab(n.root,{id:b})},[V,n.root]),G=c.useCallback((f,b,T)=>{if(ie.debug("registerFilePanel",f,b,T),b==null||b.id==null){ie.debug("Ignore empty file id",b);return}var{id:D}=b;if(T){g(D,f);return}if(d.has(D)){var j=d.get(D);if(f===j){ie.debug("Update tab title for file ".concat(D));var{itemName:$e}=b;A(D,$e)}else ie.error("File ".concat(D," already associated with a different tab ").concat(j));return}E(D,f),u.has(D)&&y(D)},[d,u,A,E,g,y]),X=c.useCallback((f,b)=>{if(ie.debug("unregisterFileTab",f,b),f==null||f.id==null){ie.debug("Ignore empty file id",f);return}var{id:T}=f;if(b){y(T);return}S(T)},[S,y]),ve=c.useCallback((f,b)=>{ie.debug("closeFilePanel",f);var{id:T}=f,D=null,j=!1;if(d.has(T))D=d.get(T);else if(u.has(T))D=u.get(T),j=!0;else{ie.debug("File ".concat(T," isn't open, ignore close event"));return}X(f,j),ae.closeComponent(n.root,{id:D},b)},[n.root,d,u,X]),R=c.useCallback(f=>{var{itemName:b}=f;return w.getBaseName(b)},[]),$=c.useCallback(f=>{var{id:b}=f;return ie.debug("fileIsOpen",f,b,d),b!=null&&d.has(b)},[d]),H=c.useCallback(f=>{var{id:b}=f;return ie.debug("fileIsOpenAsPreview",f,b,u),b!=null&&u.has(b)},[u]),x=c.useCallback(f=>{if(f!=null){var b=r.getOpenedPanelById(f);b&&ji(b)&&b.focus()}},[r]),F=c.useCallback(f=>{var{id:b,settings:T,fileMetadata:D,session:j,sessionLanguage:$e,isPreview:C=!1}=f,M={settings:T,fileMetadata:D},B=R(D);return{type:"react-component",component:it.COMPONENT,isFocusOnShow:!1,props:{localDashboardId:e,metadata:{id:b},session:j,sessionLanguage:$e,panelState:M,isPreview:C,notebooksUrl:a},title:B,id:b}},[R,e,a]),I=c.useCallback(function(f,b,T){var D=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{id:null,itemName:L(T)},j=V(D);if($(D)&&j!=null){ie.debug("File is already open, focus panel"),z(D),x(j);return}var $e=ae.getStackForComponentTypes(n.root,[it.COMPONENT]),C=F({id:j,settings:T,fileMetadata:D,session:f,sessionLanguage:b});ie.debug("createNotebook",C,d),ae.openComponentInStack($e,C)},[$,x,L,V,n.root,F,d,z]),oe=c.useCallback(function(f,b,T,D){var j=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!1;ie.debug("selectNotebook",D,j);var $e=$(D),C=H(D),[M]=[...u.values()],B=!j,te=B&&M?M:V(D);if(te==null||te==="")throw new Error("Unable to retrieve or create panelId for metadata",D);if($e||C)z(D);else{var me=ae.getStackForComponentTypes(n.root,[it.COMPONENT]),Or=F({id:te,settings:T,fileMetadata:D,session:f,sessionLanguage:b,isPreview:B});ae.openComponentInStack(me,Or)}if(C&&j){var jn=D.id,wr=ae.getStackForConfig(n.root,{component:it.COMPONENT,id:te}),dn=ae.getContentItemInStack(wr,{component:it.COMPONENT,id:te});dn&&Us(dn)&&(dn.container.emit(W.PROMOTE_FROM_PREVIEW),y(jn),E(jn,te))}j&&x(te)},[z,$,H,x,V,n.root,F,u,y,E]),Ge=c.useCallback(function(f,b){var T=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},D=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!0,j=r.getLastUsedPanelOfType(it);j&&ji(j)?T!=null&&T.value!=null&&j.notebook!=null&&j.notebook.append(T.value):D&&I(f,b,T)},[I,r]),ze=c.useCallback((f,b)=>$s.hydrate(Ai(Ai({},f),{},{notebooksUrl:a}),b),[a]);return bt(s,gn,t),bt(s,Sl),bt(s,id),bt(s,ld),bt(s,it,ze),Le(n.eventHub,we.SEND_COMMAND,P),Le(n.eventHub,we.SETTINGS_CHANGED,O),Le(n.eventHub,W.CLOSE_FILE,ve),Le(n.eventHub,W.CREATE_NOTEBOOK,I),Le(n.eventHub,W.SELECT_NOTEBOOK,oe),Le(n.eventHub,W.RENAME,Z),Le(n.eventHub,W.RENAME_FILE,A),Le(n.eventHub,W.SEND_TO_NOTEBOOK,Ge),Le(n.eventHub,W.REGISTER_FILE,G),Le(n.eventHub,W.UNREGISTER_FILE,X),null}function ln(i,e,t){return e=Sd(e),e in i?Object.defineProperty(i,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):i[e]=t,i}function Sd(i){var e=Ed(i,"string");return typeof e=="symbol"?e:String(e)}function Ed(i,e){if(typeof i!="object"||i===null)return i;var t=i[Symbol.toPrimitive];if(t!==void 0){var n=t.call(i,e||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(i)}class kt{}ln(kt,"DROPDOWN_FILTER","ControlType.DROPDOWN_FILTER");ln(kt,"INPUT_FILTER","ControlType.INPUT_FILTER");ln(kt,"MARKDOWN","ControlType.MARKDOWN");ln(kt,"FILTER_SET_MANAGER","ControlType.FILTER_SET_MANAGER");const rh=kt;export{we as $,Xd as A,xd as B,rh as C,eh as D,Kd as E,id as F,Gd as G,zd as H,mi as I,Wd as J,Cr as K,ld as L,Ud as M,W as N,Vs as O,At as P,He as Q,Bd as R,nh as S,$d as T,Vd as U,Dn as V,De as W,Sr as X,Qd as Y,Jd as Z,th as _,Rd as a,Bt as a0,pl as a1,Yd as a2,Id as b,wd as c,Fd as d,Ad as e,jd as f,Ld as g,Po as h,Dd as i,_d as j,Md as k,gn as l,Sl as m,kd as n,wo as o,qd as p,jt as q,Je as r,Hd as s,Nd as t,To as u,it as v,ih as w,w as x,Mn as y,Zd as z};
21
+ //# sourceMappingURL=ControlType-6564be64.js.map