@datalayer/agent-runtimes 1.6.26 → 1.6.27
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.
- package/dist-embed/chunks/{CellSidebarExtension-C6l8SYJ5.js → CellSidebarExtension-D7aXShZc.js} +1 -1
- package/dist-embed/chunks/{CollapsiblePlugin-Bn70jFpi.js → CollapsiblePlugin-Df_cvRKL.js} +1 -1
- package/dist-embed/chunks/{DeckComponent-DuxVpxzx.js → DeckComponent-sQU5JWCV.js} +1 -1
- package/dist-embed/chunks/{DocumentView-DKLkbwvh.js → DocumentView-BGthuEds.js} +1 -1
- package/dist-embed/chunks/{EphemeralDocument-CAXNOtEL.js → EphemeralDocument-CPSZcPKd.js} +1 -1
- package/dist-embed/chunks/{EphemeralNotebook-P_uxBveu.js → EphemeralNotebook-Dyx-25uN.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawComponent-mHitiMde.js → ExcalidrawComponent-F2NybZbz.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawModal-KB4MTQbk.js → ExcalidrawModal-CDiyt5M-.js} +1 -1
- package/dist-embed/chunks/{JupyterLexicalExtension-BtjDYMne.js → JupyterLexicalExtension-CEBuhvME.js} +7 -7
- package/dist-embed/chunks/{KernelVariables-CyPoY7Ap.js → KernelVariables-D3DSQaD3.js} +1 -1
- package/dist-embed/chunks/{NotebookToolSurfaces-SJd2MRQh.js → NotebookToolSurfaces-BDYXmM7k.js} +1 -1
- package/dist-embed/chunks/{NotebookView-CqS2dr1U.js → NotebookView-DRPnBAI2.js} +1 -1
- package/dist-embed/chunks/{Output-BfmeU6C2.js → Output-C6ZHZSBH.js} +1 -1
- package/dist-embed/chunks/{SandboxDetailsDialog-BQIrcZPM.js → SandboxDetailsDialog-qJBg2naH.js} +1 -1
- package/dist-embed/chunks/{WidgetVariableView-CxupIe6b.js → WidgetVariableView-B4faSdWW.js} +1 -1
- package/dist-embed/chunks/{YouTubePlugin-B6JmeO6g.js → YouTubePlugin-ChcBEMI-.js} +1 -1
- package/dist-embed/chunks/{ar-SA-G6X2FPQ2-BtDm_vBV.js → ar-SA-G6X2FPQ2-CnEVkWCp.js} +1 -1
- package/dist-embed/chunks/{az-AZ-76LH7QW2-CU9PzGa-.js → az-AZ-76LH7QW2-CSwFJ6du.js} +1 -1
- package/dist-embed/chunks/{bg-BG-XCXSNQG7-CcZG1sMf.js → bg-BG-XCXSNQG7-JG4F_3L3.js} +1 -1
- package/dist-embed/chunks/{bn-BD-2XOGV67Q-CsBxRWS8.js → bn-BD-2XOGV67Q-__W94Bx-.js} +1 -1
- package/dist-embed/chunks/{ca-ES-6MX7JW3Y-DiPlBY-L.js → ca-ES-6MX7JW3Y-CgTiQ3-C.js} +1 -1
- package/dist-embed/chunks/{cs-CZ-2BRQDIVT-B2LG8kaF.js → cs-CZ-2BRQDIVT-CuzIST9-.js} +1 -1
- package/dist-embed/chunks/{da-DK-5WZEPLOC-CjiEJ2dL.js → da-DK-5WZEPLOC-D4Z2Xglb.js} +1 -1
- package/dist-embed/chunks/{de-DE-XR44H4JA-D2hSEI1m.js → de-DE-XR44H4JA-E0rMdm2C.js} +1 -1
- package/dist-embed/chunks/{el-GR-BZB4AONW-C7ps3kie.js → el-GR-BZB4AONW-DHhs1347.js} +1 -1
- package/dist-embed/chunks/{es-ES-U4NZUMDT-BfNMUvfg.js → es-ES-U4NZUMDT-DI3jTuDV.js} +1 -1
- package/dist-embed/chunks/{esm-dClDAAXj.js → esm-DqlTXy-D.js} +1 -1
- package/dist-embed/chunks/{eu-ES-A7QVB2H4-CBQcRcNh.js → eu-ES-A7QVB2H4-ChXyoAj9.js} +1 -1
- package/dist-embed/chunks/{fa-IR-HGAKTJCU-CKTkkQUk.js → fa-IR-HGAKTJCU-D1qRoSi6.js} +1 -1
- package/dist-embed/chunks/{fi-FI-Z5N7JZ37-B2flJw4O.js → fi-FI-Z5N7JZ37-Cxzt5XFf.js} +1 -1
- package/dist-embed/chunks/{fr-FR-RHASNOE6-DCWxP6nh.js → fr-FR-RHASNOE6-DxKK7jD9.js} +1 -1
- package/dist-embed/chunks/{gl-ES-HMX3MZ6V-BGEA0PhL.js → gl-ES-HMX3MZ6V-CFdnAa4-.js} +1 -1
- package/dist-embed/chunks/{he-IL-6SHJWFNN-BaHixqAA.js → he-IL-6SHJWFNN-lBjIyRxj.js} +1 -1
- package/dist-embed/chunks/{hi-IN-IWLTKZ5I-CrHbvHN0.js → hi-IN-IWLTKZ5I-CtdCPck4.js} +1 -1
- package/dist-embed/chunks/{hu-HU-A5ZG7DT2-B9wQnRpK.js → hu-HU-A5ZG7DT2-D_CFF32t.js} +1 -1
- package/dist-embed/chunks/{id-ID-SAP4L64H-T0pQVB4m.js → id-ID-SAP4L64H-CwTXhwLK.js} +1 -1
- package/dist-embed/chunks/{index-BKAeSGYJ.js → index-9wJFadG-.js} +6 -6
- package/dist-embed/chunks/{index-Dd7kISed.js → index-C7UsrKrP.js} +1 -1
- package/dist-embed/chunks/{index-eH_desiS.js → index-DCpvl_OP.js} +2 -2
- package/dist-embed/chunks/{it-IT-JPQ66NNP-ECgWHvcY.js → it-IT-JPQ66NNP-BUEFwYid.js} +1 -1
- package/dist-embed/chunks/{ja-JP-DBVTYXUO-Cz96ctDW.js → ja-JP-DBVTYXUO-BAK_QQr1.js} +1 -1
- package/dist-embed/chunks/{kaa-6HZHGXH3-Cu7gLGxC.js → kaa-6HZHGXH3-C2yLyxLW.js} +1 -1
- package/dist-embed/chunks/{kab-KAB-ZGHBKWFO-CoJI939s.js → kab-KAB-ZGHBKWFO-CW0xgQ8n.js} +1 -1
- package/dist-embed/chunks/{kk-KZ-P5N5QNE5-DiEAZ9si.js → kk-KZ-P5N5QNE5-iG2uKF6i.js} +1 -1
- package/dist-embed/chunks/{km-KH-HSX4SM5Z-CNF1qzO2.js → km-KH-HSX4SM5Z-Bm_m99ak.js} +1 -1
- package/dist-embed/chunks/{ko-KR-MTYHY66A-BCvHfgyK.js → ko-KR-MTYHY66A-Clgfny6b.js} +1 -1
- package/dist-embed/chunks/{ku-TR-6OUDTVRD-BV9JoFXu.js → ku-TR-6OUDTVRD-Y8Y_vzzq.js} +1 -1
- package/dist-embed/chunks/{lib-Bx5jthWD.js → lib-7ge2Kma3.js} +1 -1
- package/dist-embed/chunks/{lib-yg0_lz05.js → lib-8ZUSfvoH.js} +1 -1
- package/dist-embed/chunks/{lib-CAo1qw8O.js → lib-B5Wbadbg.js} +1 -1
- package/dist-embed/chunks/{lib-DZN1MrxI.js → lib-B9ahcmxX.js} +1 -1
- package/dist-embed/chunks/{lib-BxusOAUc.js → lib-BFuQ3UQC.js} +1 -1
- package/dist-embed/chunks/{lib-0nJV2tTp.js → lib-BP80BmI2.js} +1 -1
- package/dist-embed/chunks/{lib-NqXc-p0V.js → lib-BepajD8I.js} +1 -1
- package/dist-embed/chunks/{lib-Dxhw9PEm.js → lib-COZbOw0Z.js} +1 -1
- package/dist-embed/chunks/{lib-DhqDod2q.js → lib-CbUWOQj9.js} +1 -1
- package/dist-embed/chunks/{lib-DJJHSa4o.js → lib-CpkMRAJY.js} +1 -1
- package/dist-embed/chunks/{lib-CIkHn_Ac.js → lib-D25l5ZAy.js} +1 -1
- package/dist-embed/chunks/{lib-CZz_1UlC.js → lib-DBCP5fWa.js} +1 -1
- package/dist-embed/chunks/{lib-BkW0DwuV.js → lib-DHHIihJW.js} +1 -1
- package/dist-embed/chunks/{lib-Cn6fuwbC.js → lib-DggdYYmh.js} +1 -1
- package/dist-embed/chunks/{lib-CJQ5jBOi.js → lib-DmPUUoao.js} +1 -1
- package/dist-embed/chunks/{lib-3EwLl_XC.js → lib-DwylwlRk.js} +1 -1
- package/dist-embed/chunks/{lib-aEdpLJmk.js → lib-NBgDVJov.js} +1 -1
- package/dist-embed/chunks/{lib-Bjb6erCc.js → lib-j6VKUVII.js} +1 -1
- package/dist-embed/chunks/{lib-DLAP9X-I.js → lib-obIZUupc.js} +1 -1
- package/dist-embed/chunks/{lt-LT-XHIRWOB4-BpoBiZvj.js → lt-LT-XHIRWOB4-D7Por38P.js} +1 -1
- package/dist-embed/chunks/{lv-LV-5QDEKY6T-DWPLOycm.js → lv-LV-5QDEKY6T-Bz5t6-LB.js} +1 -1
- package/dist-embed/chunks/{mr-IN-CRQNXWMA-C3XokKLN.js → mr-IN-CRQNXWMA-B1NTMzvS.js} +1 -1
- package/dist-embed/chunks/{my-MM-5M5IBNSE-bPDcBtIx.js → my-MM-5M5IBNSE-C1gGuOaf.js} +1 -1
- package/dist-embed/chunks/{nb-NO-T6EIAALU-zGQywuc4.js → nb-NO-T6EIAALU-o2E12ucR.js} +1 -1
- package/dist-embed/chunks/{nl-NL-IS3SIHDZ-D0N-QxdB.js → nl-NL-IS3SIHDZ-Bqxu5mbZ.js} +1 -1
- package/dist-embed/chunks/{nn-NO-6E72VCQL-BeiBipEM.js → nn-NO-6E72VCQL-DxUXxDPK.js} +1 -1
- package/dist-embed/chunks/{oc-FR-POXYY2M6-BSmiDtLw.js → oc-FR-POXYY2M6-CDttJVdz.js} +1 -1
- package/dist-embed/chunks/{pa-IN-N4M65BXN-YTioBliU.js → pa-IN-N4M65BXN-Dp8ANANJ.js} +1 -1
- package/dist-embed/chunks/{percentages-BXMCSKIN-B5BZ64UL.js → percentages-BXMCSKIN-B5xVDaSp.js} +3 -3
- package/dist-embed/chunks/{pl-PL-T2D74RX3-BmA-mIoA.js → pl-PL-T2D74RX3-N3d_R6le.js} +1 -1
- package/dist-embed/chunks/{pt-BR-5N22H2LF-DF1nGVg3.js → pt-BR-5N22H2LF-CpPiMZ-u.js} +1 -1
- package/dist-embed/chunks/{pt-PT-UZXXM6DQ-DhiSFYNH.js → pt-PT-UZXXM6DQ-EGdAVYif.js} +1 -1
- package/dist-embed/chunks/{renderer-D_wPFwb6.js → renderer-8__rsP1H.js} +1 -1
- package/dist-embed/chunks/{ro-RO-JPDTUUEW-DN5nT_8E.js → ro-RO-JPDTUUEW-Bkty7yik.js} +1 -1
- package/dist-embed/chunks/{ru-RU-B4JR7IUQ-DJAZColu.js → ru-RU-B4JR7IUQ-BRHTHx-M.js} +1 -1
- package/dist-embed/chunks/{si-LK-N5RQ5JYF-BcJdGNJf.js → si-LK-N5RQ5JYF-BnP3_yrO.js} +1 -1
- package/dist-embed/chunks/{sk-SK-C5VTKIMK-Bs43X2b-.js → sk-SK-C5VTKIMK-CcOBsX7R.js} +1 -1
- package/dist-embed/chunks/{sl-SI-NN7IZMDC-CVhBQ31i.js → sl-SI-NN7IZMDC-DjcpDjk-.js} +1 -1
- package/dist-embed/chunks/{standalone-BmUQQ5LE.js → standalone-BjQ9N7UL.js} +1 -1
- package/dist-embed/chunks/{subset-shared.chunk-BkTdi2-W.js → subset-shared.chunk-DuIbGrTT.js} +1 -1
- package/dist-embed/chunks/{subset-worker.chunk-SkNsdM6t.js → subset-worker.chunk-CNz8UZDr.js} +1 -1
- package/dist-embed/chunks/{sv-SE-XGPEYMSR-BR0XZMXJ.js → sv-SE-XGPEYMSR-DbihwJ2w.js} +1 -1
- package/dist-embed/chunks/{ta-IN-2NMHFXQM-4CfGQQ8v.js → ta-IN-2NMHFXQM--fKIkmrb.js} +1 -1
- package/dist-embed/chunks/{th-TH-HPSO5L25-CjO8TBa6.js → th-TH-HPSO5L25-CkS_jtXJ.js} +1 -1
- package/dist-embed/chunks/{tr-TR-DEFEU3FU-B3tO43YQ.js → tr-TR-DEFEU3FU-B7b1yuT5.js} +1 -1
- package/dist-embed/chunks/{uk-UA-QMV73CPH-DYk01HNs.js → uk-UA-QMV73CPH-DMXQPyW5.js} +1 -1
- package/dist-embed/chunks/{vi-VN-M7AON7JQ-Dyd2Hf1G.js → vi-VN-M7AON7JQ-DQGL1ixT.js} +1 -1
- package/dist-embed/chunks/{zh-CN-LNUGB5OW-Bs2W1BrY.js → zh-CN-LNUGB5OW-BzDVFX-Z.js} +1 -1
- package/dist-embed/chunks/{zh-HK-E62DVLB3-BwN2oc_m.js → zh-HK-E62DVLB3-DwTp6Tkq.js} +1 -1
- package/dist-embed/chunks/{zh-TW-RAJ6MFWO-qOevWsjt.js → zh-TW-RAJ6MFWO-VbTpKAX1.js} +1 -1
- package/dist-embed/datalayer-app-main.js +24 -24
- package/lib/specs/actions.js +3 -2
- package/lib/specs/agents/agents.d.ts +1 -1
- package/lib/specs/agents/agents.js +134 -134
- package/lib/specs/apps.d.ts +1 -1
- package/lib/specs/apps.js +394 -394
- package/lib/specs/backendTools.js +6 -6
- package/lib/specs/policies.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a9 as R,aF as I,aA as O,fO as M,r as n,dI as w,cn as b,fP as q,eG as F,fQ as H,fR as U,az as J,fS as k,ec as x,dQ as W,fT as z,fU as $,cv as Q,J as P,aC as V,et as G,aD as Y,dy as X,dv as Z}from"../datalayer-app-main.js";import{H as tt}from"./htmlselect-CqXICb9e.js";import{o as et}from"./index-eH_desiS.js";import{a as st}from"./tokens-BYcJtuKD.js";import{I as ot}from"./tokens-DY_UrMLq.js";import"./Output-BfmeU6C2.js";import"./index--S8WFITA.js";import"./hoverbox-CStlKQWE.js";import"./index-6zxBQeM_.js";import"./index-BKAeSGYJ.js";import"./dayjs.min-u3zuoSR8.js";import"./isEqual-BYxXubsX.js";import"./d3-color-Jd8hXty2.js";import"./dist-BrUAt6vF.js";import"./KebabHorizontalIcon-D6AY8pIS.js";import"./PaintbrushIcon-CFBHU-3l.js";import"./index-CqP3xLL5.js";import"./RestartIcon-DvpOf5Mf.js";import"./CellSidebarExtension-C6l8SYJ5.js";import"./NotebookSkeleton-BkzTMhIX.js";import"./Avatar-MNx1kN3F.js";import"./renderer-D_wPFwb6.js";import"./SquareIcon-Dy3l3VdH.js";import"./FileDirectoryOpenFillIcon-jGhuRcP3.js";import"./url-C6fJII94.js";/* empty css *//* empty css */import"./style-DdAxk_bj.js";/* empty css */import"./style-Cj1gzCjo.js";/* empty css */import"./style-rkw8dR9f.js";import"./style-GHJFdtIz.js";import"./style-ZSIOeMoX.js";import"./style-iVfD6mFL.js";import"./style-DA-Ya7rp.js";import"./style-D3tvWcFO.js";import"./style-BOqStzF9.js";import"./style-ADLQJ-E9.js";import"./style-DgglluaK.js";import"./ArrowLeftIcon-sX3iNMG1.js";import"./SkubbleIcon-CAaVh_BE.js";import"./usePrimerThemeBridge-DyX4EYyN.js";import"./index-BbcMy3Al.js";import"./KernelVariables-CyPoY7Ap.js";import"./index-C0d-d3s4.js";import"./SortAscIcon-CmH04s3F.js";import"./SortDescIcon-Qif6E10I.js";import"./NotebookToolbar-BMjQTGrr.js";import"./RepoPushIcon-BtXQRhLa.js";import"./Toolbar-BncUh2ly.js";import"./sessions-CgjtuOSm.js";import"./tokens-CBhRbpQP.js";import"./drivecontents-D1HzL7Fi.js";import"./kernel-BmfZmtIo.js";class it{constructor(e){this.reset=()=>{this._shortcut={id:"new shortcut",command:"",keybindings:[],selector:"body",category:"",args:{}},this._changed.emit()},this.addKeybinding=async(t,o)=>{this._shortcut.keybindings.push({keys:o,isDefault:!1}),this._changed.emit()},this.replaceKeybinding=async(t,o,s)=>{if(s=s.filter(i=>i!==""),!s.length)return this.deleteKeybinding(t,o);const r=this._shortcut.keybindings.findIndex(i=>i.keys===o.keys);r>-1?this._shortcut.keybindings[r]={keys:s,isDefault:!1}:this.addKeybinding(t,s),this._changed.emit()},this.deleteKeybinding=async(t,o)=>{const s=this._shortcut.keybindings.findIndex(r=>r.keys===o.keys);s>-1&&(this._shortcut.keybindings.splice(s,1),this._changed.emit())},this.resetKeybindings=async t=>{this._shortcut={...this._shortcut,keybindings:[]},this._changed.emit()},this.setCustomOptions=async(t,o)=>(this._shortcut={...this._shortcut,selector:o.selector,args:o.args},this._changed.emit(),!0),this.updateCommand=(t,o)=>{this._shortcut={...this._shortcut,command:t,category:o},this._changed.emit()},this._changed=new R(this),this._shortcut={id:"new shortcut",command:"",keybindings:[],selector:"body",category:"",args:{}},this.findConflictsFor=e.findConflictsFor,this.showSelectors=e.showSelectors,this.external=e.external}get shortcut(){return this._shortcut}get changed(){return this._changed}}class rt extends I{constructor(e){const{shortcut:t,translator:o,editorFactory:s}=e,r=o.load("jupyterlab"),i=new nt(t,o,s,()=>this._checkValidation(),e.readOnly),a=[];e.readOnly?a.push(I.cancelButton({label:r.__("OK")})):(a.push(I.cancelButton({label:r.__("Cancel")})),a.push(I.okButton({label:r.__("Apply")}))),super({title:e.readOnly?r.__("Shortcut Options"):r.__("Custom Shortcut Options"),body:i,buttons:a})}_evtKeydown(e){if(e.key==="Enter"){const t=this.node.querySelector(".jp-JSONEditor"),o=document.activeElement;if(t instanceof HTMLElement&&o instanceof HTMLElement&&t.contains(o)){e.stopPropagation();return}}super._evtKeydown(e)}}class nt extends O{constructor(e,t,o,s,r){var i,a;super();const c=t.load("jupyterlab");this.addClass("jp-Shortcuts-CustomOptionsDialogBody");const g=document.createElement("div");g.className="jp-Shortcuts-CustomOptionDialog-container";const p=document.createElement("label");p.textContent=c.__("Selector:"),p.className="jp-Dialog-label",this._selectorInput=document.createElement("input"),this._selectorInput.type="text",this._selectorInput.disabled=r??!1,this._selectorInput.value=e.selector,this._selectorInput.className="jp-mod-styled",g.appendChild(p),g.appendChild(this._selectorInput);const f=document.createElement("label");if(f.textContent=c.__("Arguments:"),f.className="jp-Dialog-label",g.appendChild(f),r){const d=document.createElement("pre");d.textContent=JSON.stringify((i=e.args)!==null&&i!==void 0?i:{},void 0,2),g.appendChild(d)}else this._editorWidget=new at((a=e.args)!==null&&a!==void 0?a:{},o,s),g.appendChild(this._editorWidget.node);this.node.appendChild(g)}getValue(){var e,t;const o=(t=(e=this._editorWidget)===null||e===void 0?void 0:e.getJSON())!==null&&t!==void 0?t:"{}";let s;try{s=JSON.parse(o)}catch(r){console.error(`Invalid JSON in arguments: ${r instanceof Error?r.message:String(r)}`),s={}}return{selector:this._selectorInput.value,args:s}}dispose(){var e;(e=this._editorWidget)===null||e===void 0||e.dispose(),super.dispose()}}class at extends O{constructor(e,t,o){super(),this._validateJSON=()=>{try{const a=this._editor.model.sharedModel.getSource();JSON.parse(a),this.node.classList.remove("jp-mod-error")}catch{this.node.classList.add("jp-mod-error")}this._checkValidation()},this.addClass("jp-JSONEditor"),this._checkValidation=o;const s=document.createElement("div");s.className="jp-JSONEditor-host";const r=new M.Model({mimeType:"application/json"}),i=JSON.stringify(e,null,2);r.sharedModel.setSource(i),this._editor=t({host:s,model:r,config:{readOnly:!1}}),this.node.appendChild(s),this._editor.model.sharedModel.changed.connect(this._validateJSON,this)}getJSON(){return this._editor.model.sharedModel.getSource()}dispose(){this._editor.model.sharedModel.changed.disconnect(this._validateJSON,this),this._editor.dispose(),super.dispose()}}const D="jp-Shortcuts-ConflictContainer";class A extends n.Component{constructor(e){super(e),this.handleSubmit=async()=>{this._isReplacingExistingKeybinding?this.state.selected?this.props.toggleInput():await this._updateShortcut():(await this._updateShortcut(),this.props.toggleInput())},this._updateShortcut=async()=>{const t=[...this.state.keys,this.state.currentChain];this.setState({keys:t}),this.props.keybinding?await this.props.replaceKeybinding(this.props.shortcut,this.props.keybinding,t):await this.props.addKeybinding(this.props.shortcut,t)},this._handleOverwrite=async(t,o)=>{const s=o.map(w.normalizeKeystroke);for(const r of t){const i=r.keybindings.filter(a=>b.deepEqual(a.keys,s)||s.some(c=>b.deepEqual(a.keys,[c])))[0];if(!i){console.error(`Conflicting binding could not be found for ${r} using keys ${o}`);continue}await this.props.deleteKeybinding(r,i)}await this._updateShortcut()},this.parseChaining=(t,o,s,r,i)=>{let a=q.keyForKeydownEvent(t.nativeEvent);const c=["Shift","Control","Alt","Meta","Ctrl","Accel"];if(t.key==="Backspace")s="",o="",r=[],i="",this.setState({value:o,userInput:s,keys:r,currentChain:i});else if(t.key!=="CapsLock"){const g=s.substr(s.lastIndexOf(" ")+1,s.length).trim();c.lastIndexOf(g)===-1&&g!=""?(s=s+",",r.push(i),i="",t.ctrlKey&&t.key!="Control"&&(s=(s+" Ctrl").trim(),i=(i+" Ctrl").trim()),t.metaKey&&t.key!="Meta"&&(s=(s+" Accel").trim(),i=(i+" Accel").trim()),t.altKey&&t.key!="Alt"&&(s=(s+" Alt").trim(),i=(i+" Alt").trim()),t.shiftKey&&t.key!="Shift"&&(s=(s+" Shift").trim(),i=(i+" Shift").trim()),c.lastIndexOf(t.key)===-1?(s=(s+" "+a).trim(),i=(i+" "+a).trim()):t.key==="Meta"?(s=(s+" Accel").trim(),i=(i+" Accel").trim()):t.key==="Control"?(s=(s+" Ctrl").trim(),i=(i+" Ctrl").trim()):t.key==="Shift"?(s=(s+" Shift").trim(),i=(i+" Shift").trim()):t.key==="Alt"?(s=(s+" Alt").trim(),i=(i+" Alt").trim()):(s=(s+" "+t.key).trim(),i=(i+" "+t.key).trim())):t.key==="Control"?(s=(s+" Ctrl").trim(),i=(i+" Ctrl").trim()):t.key==="Meta"?(s=(s+" Accel").trim(),i=(i+" Accel").trim()):t.key==="Shift"?(s=(s+" Shift").trim(),i=(i+" Shift").trim()):t.key==="Alt"?(s=(s+" Alt").trim(),i=(i+" Alt").trim()):(s=(s+" "+a).trim(),i=(i+" "+a).trim())}return this.setState({keys:r,currentChain:i}),[s,r,i]},this.checkNonFunctional=()=>{const t=["Ctrl","Alt","Accel","Shift"],o=this.state.currentChain.split(" "),s=o[o.length-1];return this.setState({isFunctional:t.indexOf(s)===-1}),t.indexOf(s)!==-1},this.checkShortcutAvailability=(t,o,s)=>{const r=this.props.findConflictsFor([...o,s],this.props.shortcut.selector),i=t===""||r.length===0;return!i&&r.length===1&&r[0].id===this.props.shortcut.id&&this._isReplacingExistingKeybinding?(this.setState({isAvailable:!0}),[]):(this.setState({isAvailable:i}),r)},this.handleInput=t=>{t.preventDefault(),this.setState({selected:!1});const o=this.parseChaining(t,this.state.value,this.state.userInput,this.state.keys,this.state.currentChain),s=o[0],r=o[1],i=o[2],a=this.props.toSymbols(s);let c=this.checkShortcutAvailability(s,r,i);this.setState({value:a,userInput:s,keys:r,currentChain:i},()=>{this.checkNonFunctional(),this._emitConflicts(c)})},this._handleBlur=t=>{var o,s;!((o=this._ref.current)===null||o===void 0)&&o.contains(t.relatedTarget)||!((s=t.relatedTarget)===null||s===void 0)&&s.closest(`.${D}`)||this.props.toggleInput()},this._ref=n.createRef(),this.state={value:this.props.placeholder,userInput:"",isAvailable:!0,isFunctional:this._isReplacingExistingKeybinding,keys:[],currentChain:"",selected:!0}}get _isReplacingExistingKeybinding(){return!!this.props.keybinding}_emitConflicts(e){const t=[...this.state.keys,this.state.currentChain];this.props.displayConflicts({conflictsWith:e,keys:this.state.keys,overwrite:async()=>{this.setState({isAvailable:!0}),await this._handleOverwrite(e,t),this.props.toggleInput()},cancel:()=>{this.props.toggleInput()}})}render(){const e=this.props.translator.load("jupyterlab");let t="jp-Shortcuts-Input";return this.state.isAvailable||(t+=" jp-mod-unavailable-Input"),n.createElement("div",{className:this.props.displayInput?this._isReplacingExistingKeybinding?"jp-Shortcuts-InputBox":"jp-Shortcuts-InputBox jp-Shortcuts-InputBoxNew":"jp-mod-hidden",ref:this._ref,onBlur:this._handleBlur},n.createElement("div",{tabIndex:0,className:t,onKeyDown:this.handleInput,ref:o=>o&&o.focus(),"data-lm-suppress-shortcuts":"true"},n.createElement("p",{className:this.state.selected&&this._isReplacingExistingKeybinding?"jp-Shortcuts-InputText jp-mod-selected-InputText":this.state.value===""?"jp-Shortcuts-InputText jp-mod-waiting-InputText":"jp-Shortcuts-InputText"},this.state.value===""?e.__("press keys"):this.state.value)),n.createElement("button",{className:this.state.isFunctional?this.state.isAvailable?"jp-Shortcuts-Submit":"jp-Shortcuts-Submit jp-mod-conflict-Submit":"jp-Shortcuts-Submit jp-mod-defunc-Submit",disabled:!this.state.isAvailable||!this.state.isFunctional,onClick:this.handleSubmit,tabIndex:0},this.state.isAvailable?n.createElement(F.react,null):n.createElement(H.react,null)))}}var C;(function(l){l.editBinding="shortcuts:edit-keybinding",l.addBinding="shortcuts:add-keybinding",l.deleteBinding="shortcuts:delete-keybinding",l.toggleSelectors="shortcuts:toggle-selectors",l.resetAll="shortcuts:reset-all"})(C||(C={}));var E;(function(l){l[l.Label=0]="Label",l[l.Category=1]="Category",l[l.Split=2]="Split",l[l.Default=3]="Default"})(E||(E={}));class j extends Map{constructor(e){var t,o,s,r;super();const{settings:i,commandRegistry:a,allCommands:c}=e;if(c)for(const g of a.listCommands()){const p={command:g,selector:"body"},f=this._computeTargetId(p),d=p.command.split(":"),m=(t=a.label(p.command,p.args))!==null&&t!==void 0?t:d.length>1?d[1]:void 0,u=d[0],y={...p,id:f,keybindings:[],category:u,label:m,args:{}};this.set(f,y)}else if(i){const g=(o=i.user.shortcuts)!==null&&o!==void 0?o:[],p=new Set(g.map(this._computeKeybindingId.bind(this))),f=(s=i.composite.shortcuts)!==null&&s!==void 0?s:[],d=i.default("shortcuts").map(m=>this._computeTargetId(m));for(const m of f){const u=this._computeTargetId(m),y=this._computeKeybindingId(m),h={keys:w.normalizeKeys(m),isDefault:!p.has(y),...m.preventDefault===void 0?{}:{preventDefault:m.preventDefault}},S=this.get(u);if(S)S.keybindings.push(h);else{const _=m.command.split(":"),K=(r=a.label(m.command,m.args))!==null&&r!==void 0?r:_.length>1?_[1]:void 0,B=_[0];this.set(u,{id:u,selector:m.selector,command:m.command,category:B,label:K,args:m.args,keybindings:[h],userDefined:!d.includes(u)})}}}}findConflictsFor(e,t){const o=new lt({registry:this}),s=e.map(w.normalizeKeystroke);let r=o.findConflicts(s,t);if(r.length!==0)return r;for(const i of s)if(r=o.findConflicts([i],t),r.length!==0)return r;return[]}_computeTargetId(e){var t;return e.command+"_"+e.selector+"_"+JSON.stringify((t=e.args)!==null&&t!==void 0?t:{})}_computeKeybindingId(e){var t;return[e.command,e.selector,JSON.stringify((t=e.args)!==null&&t!==void 0?t:{}),w.normalizeKeys(e).join(" ")].join("_")}}class lt{constructor(e){var t;const o=new Map;for(const s of e.registry.values())for(const r of s.keybindings){const i=this._keybindingHash(r.keys,s.selector),a=(t=o.get(i))!==null&&t!==void 0?t:[];a.push(s),o.set(i,a)}this._keybindingsMap=o}findConflicts(e,t){var o;const s=this._keybindingHash(e,t);return(o=this._keybindingsMap.get(s))!==null&&o!==void 0?o:[]}_keybindingHash(e,t){return e.join(" ")+"_"+t}}(function(l){function e(s){return s.replace(/\s+/g,"").toLowerCase()}function t(s,r){var i;const a=s.category.toLowerCase(),c=((i=s.label)!==null&&i!==void 0?i:"").toLowerCase(),g=`${a} ${c}`;let p=1/0,f=null;const d=/\b\w/g;for(;;){const S=d.exec(g);if(!S)break;const _=U.matchSumOfDeltas(g,r,S.index);if(!_)break;_&&_.score<=p&&(p=_.score,f=_.indices)}if(!f||p===1/0)return null;const m=a.length+1,u=J.lowerBound(f,m,(S,_)=>S-_),y=f.slice(0,u),h=f.slice(u);for(let S=0,_=h.length;S<_;++S)h[S]-=m;return y.length===0?{matchType:E.Label,categoryIndices:null,labelIndices:h,score:p,item:s}:h.length===0?{matchType:E.Category,categoryIndices:y,labelIndices:null,score:p,item:s}:{matchType:E.Split,categoryIndices:y,labelIndices:h,score:p,item:s}}function o(s,r){r=e(r);let i=[];for(const a of s.values()){if(!r){i.push({matchType:E.Default,categoryIndices:null,labelIndices:null,score:0,item:a});continue}let c=t(a,r);c&&i.push(c)}return i}l.matchItems=o})(j||(j={}));const ct={Ctrl:"⌃",Alt:"⌥",Shift:"⇧",Accel:"⌘",Cmd:"⌘"};class L extends n.Component{constructor(e){super(e),this.toggleInputNew=()=>{this.setState({displayNewInput:!this.state.displayNewInput,conflicts:new Map})},this.toSymbols=t=>k.IS_MAC?t.split(" ").map(o=>{var s;return(s=ct[o])!==null&&s!==void 0?s:o}).join(" "):t.split(" ").map(o=>o==="Accel"?"Ctrl":o).join(" "),this._trans=this.props.external.translator.load("jupyterlab"),this.state={displayNewInput:!1,displayReplaceInput:Object.freeze({}),conflicts:new Map}}componentDidMount(){this.props.external.actionRequested.connect(this._onActionRequested,this)}componentWillUnmount(){this.props.external.actionRequested.disconnect(this._onActionRequested,this)}async _onActionRequested(e,t){if(!("shortcutId"in t&&t.shortcutId!==this.props.shortcut.id)){if(t.request==="add-keybinding")return this.toggleInputNew();if(t.request==="edit-keybinding"&&this.toggleInputReplaceMethod(t.keybinding),t.request==="delete-keybinding"){const o=this.props.shortcut,s=o.keybindings[t.keybinding];this.props.deleteKeybinding(o,s).catch(console.error)}}}getCategoryCell(){return n.createElement("div",{className:"jp-Shortcuts-Cell"},this.props.shortcut.category)}getLabelCell(){var e;if(this.props.newShortcutUtils){const t=this._getFilteredCommands();return n.createElement("div",{className:"jp-Shortcuts-Cell"},n.createElement(tt,{value:this.props.shortcut.command,options:[{value:"",label:this._trans.__("Select a command")},...t.map(o=>({value:o.command,label:`${o.category}: ${o.label}`}))],onChange:o=>{var s,r,i;const a=t.find(c=>c.command===o.target.value);(s=this.props.newShortcutUtils)===null||s===void 0||s.updateCommand((r=a?.command)!==null&&r!==void 0?r:"",(i=a?.category)!==null&&i!==void 0?i:"")}}))}else return n.createElement("div",{className:"jp-Shortcuts-Cell"},n.createElement("div",{className:"jp-label"},(e=this.props.shortcut.label)!==null&&e!==void 0?e:this._trans.__("(Command label missing)")))}getResetShortCutLink(){return n.createElement("a",{className:"jp-Shortcuts-Reset",onClick:()=>this.props.resetKeybindings(this.props.shortcut)},this.props.shortcut.userDefined?this._trans.__("Delete"):this._trans.__("Reset"))}getSourceCell(){var e;const t=this.props.shortcut.keybindings.every(r=>r.isDefault),o=this.props.shortcut.userDefined||!!this.props.newShortcutUtils,s=o?this._trans.__("Custom options"):this._trans.__("Show options");return n.createElement("div",{className:"jp-Shortcuts-Cell"},!this.props.newShortcutUtils&&n.createElement("div",{className:"jp-Shortcuts-SourceCell"},t?this._trans.__("Default"):this._trans.__("Custom")),t?"":this.getResetShortCutLink(),this.props.external.editorFactory&&n.createElement(x,{className:"jp-mod-styled jp-mod-reject jp-Shortcuts-CustomOptions",onClick:async()=>{if(!this.props.external.editorFactory){console.error("Cannot build the custom options form");return}const i=await new rt({shortcut:this.props.shortcut,translator:this.props.external.translator,editorFactory:this.props.external.editorFactory,readOnly:!o}).launch();i.button.accept&&o&&i.value&&await this.props.setCustomOptions(this.props.shortcut,i.value)},title:s,"aria-label":s,appearance:"neutral"},o?n.createElement(W.react,{tag:null}):n.createElement(z.react,{tag:null})),!!this.props.newShortcutUtils&&n.createElement(n.Fragment,null,n.createElement(x,{className:"jp-mod-styled jp-mod-accept jp-Shortcuts-SaveNew",onClick:(e=this.props.newShortcutUtils)===null||e===void 0?void 0:e.saveShortcut,title:this._trans.__("Save shortcut"),"aria-label":this._trans.__("Save shortcut"),appearance:"neutral",disabled:!this.props.shortcut.command||!this.props.shortcut.keybindings.length||this.props.shortcut.keybindings.every(r=>!r.keys||r.keys.length===0)},n.createElement(F.react,{tag:null}))))}getOptionalSelectorCell(){return this.props.showSelectors?n.createElement("div",{className:"jp-Shortcuts-Cell"},n.createElement("div",{className:"jp-selector"},this.props.shortcut.selector)):null}getClassNameForShortCuts(e){const t=["jp-Shortcuts-ShortcutCell"];switch(e.length){case 1:t.push("jp-Shortcuts-SingleCell");break;case 0:t.push("jp-Shortcuts-EmptyCell");break}return t.join(" ")}toggleInputReplaceMethod(e){const t=this.state.displayReplaceInput[e];this.setState({displayReplaceInput:{...this.state.displayReplaceInput,[e]:!t},conflicts:new Map})}getDisplayReplaceInput(e){return this.state.displayReplaceInput[e]}getOrDisplayIfNeeded(e){const t=["jp-Shortcuts-Or"];return(e||this.state.displayNewInput)&&t.push("jp-Shortcuts-Or-Forced"),n.createElement("div",{className:t.join(" ")},this._trans.__("or"))}getShortCutAsInput(e,t){return n.createElement(A,{addKeybinding:this.props.addKeybinding,replaceKeybinding:this.props.replaceKeybinding,deleteKeybinding:this.props.deleteKeybinding,findConflictsFor:this.props.findConflictsFor,toggleInput:()=>this.toggleInputReplaceMethod(t),shortcut:this.props.shortcut,keybinding:e,displayConflicts:o=>{const s=new Map(this.state.conflicts);s.set(e,o),this.setState({conflicts:s})},toSymbols:this.toSymbols,displayInput:this.getDisplayReplaceInput(t),placeholder:this.toSymbols(e.keys.join(", ")),translator:this.props.external.translator})}getShortCutForDisplayOnly(e){return e.keys.map((t,o)=>n.createElement("div",{className:"jp-Shortcuts-ShortcutKeysContainer",key:o},n.createElement("div",{className:"jp-Shortcuts-ShortcutKeys"},this.toSymbols(t).split(" ").map((s,r,i)=>n.createElement(n.Fragment,{key:`${o}-${s}-${r}`},n.createElement("span",{className:"jp-ContextualShortcut-Key"},s),r+1<i.length?" + ":null))),o+1<e.keys.length?n.createElement("div",{className:"jp-Shortcuts-Comma"},","):null))}isLocationBeingEdited(e){return this.state.displayReplaceInput[e]}getDivForKey(e,t,o){return n.createElement("div",{className:"jp-Shortcuts-ShortcutContainer",key:this.props.shortcut.id+"_"+e,"data-keybinding":e,"data-shortcut":this.props.shortcut.id,onClick:()=>this.toggleInputReplaceMethod(e)},this.isLocationBeingEdited(e)?this.getShortCutAsInput(t,e):this.getShortCutForDisplayOnly(t),!(e===this._nonEmptyBindings.length-1&&Object.values(this.state.displayReplaceInput).some(Boolean))&&this.getOrDisplayIfNeeded(e<this._nonEmptyBindings.length-1))}getAddLink(){return n.createElement("a",{className:this.state.displayNewInput?"":"jp-Shortcuts-Plus",onClick:()=>{this.toggleInputNew()}},this._trans.__("Add"))}getInputBoxWhenToggled(){return this.state.displayNewInput?n.createElement(A,{addKeybinding:this.props.addKeybinding,replaceKeybinding:this.props.replaceKeybinding,deleteKeybinding:this.props.deleteKeybinding,findConflictsFor:this.props.findConflictsFor,toggleInput:this.toggleInputNew,shortcut:this.props.shortcut,displayConflicts:e=>{const t=new Map(this.state.conflicts);t.set(null,e),this.setState({conflicts:t})},toSymbols:this.toSymbols,displayInput:this.state.displayNewInput,placeholder:"",translator:this.props.external.translator}):n.createElement("div",null)}getShortCutsCell(e){return n.createElement("div",{className:"jp-Shortcuts-Cell"},n.createElement("div",{className:this.getClassNameForShortCuts(e)},e.map((t,o)=>this.getDivForKey(o,t,e)),e.length>=1&&!this.state.displayNewInput&&!Object.values(this.state.displayReplaceInput).some(Boolean)&&this.getAddLink(),e.length===0&&!this.state.displayNewInput&&this.getAddLink(),this.getInputBoxWhenToggled()))}getConflicts(){const e=[...this.state.conflicts.values()].filter(t=>t.conflictsWith.length!==0);return e.length===0?n.createElement(n.Fragment,null):n.createElement("div",{className:"jp-Shortcuts-Row jp-Shortcuts-RowWithConflict"},n.createElement("div",{className:D},e.map(t=>{const o=t.keys.join(" ")+"_"+t.conflictsWith.map(s=>s.id).join("");return n.createElement("div",{className:"jp-Shortcuts-Conflict",key:o},n.createElement("div",{className:"jp-Shortcuts-ErrorMessage"},this._trans.__("Shortcut already in use by %1. Overwrite it?",t.conflictsWith.map(s=>{var r;return(r=s.label)!==null&&r!==void 0?r:s.command}).join(", "))),n.createElement("div",{className:"jp-Shortcuts-ErrorButton"},n.createElement("button",{className:"jp-Button jp-mod-reject jp-mod-styled",onClick:()=>{this._clearConflict(t),t.cancel()}},this._trans.__("Cancel")),n.createElement("button",{className:"jp-Button jp-mod-warn jp-mod-styled",onClick:()=>{this._clearConflict(t),t.overwrite()}},this._trans.__("Overwrite"))))})))}_clearConflict(e){const t=new Map,o=this._conflictId(e);for(const[s,r]of this.state.conflicts.entries())this._conflictId(r)!==o&&t.set(s,r);this.setState({conflicts:t})}_conflictId(e){return e.keys.join(" ")+"_"+e.conflictsWith.map(t=>t.id).join("")}_getFilteredCommands(){var e,t;const o=new j({commandRegistry:this.props.external.commandRegistry,allCommands:!0}),s=j.matchItems(o,(t=(e=this.props.newShortcutUtils)===null||e===void 0?void 0:e.searchQuery)!==null&&t!==void 0?t:"").map(r=>r.item).filter(r=>!r.command.startsWith("__internal:"));return s.sort((r,i)=>{var a,c;const g=r.category,p=i.category,f=g.localeCompare(p);if(f)return f;{const d=(a=r.label)!==null&&a!==void 0?a:"",m=(c=i.label)!==null&&c!==void 0?c:"";return d.localeCompare(m)}}),s}get _nonEmptyBindings(){return this.props.shortcut.keybindings.filter(e=>e.keys.filter(t=>t!="").length!==0)}render(){return n.createElement(n.Fragment,null,n.createElement("div",{className:`jp-Shortcuts-Row${this.props.newShortcutUtils?" jp-Shortcuts-Row-newShortcut":""}`,"data-shortcut":this.props.shortcut.id},this.getCategoryCell(),this.getLabelCell(),this.getShortCutsCell(this._nonEmptyBindings),this.getSourceCell(),this.getOptionalSelectorCell()),this.getConflicts())}}const dt=115;class ht extends n.Component{render(){return n.createElement("div",{className:"jp-Shortcuts-ShortcutListContainer",style:{height:`${this.props.height-dt}px`},id:"shortcutListContainer"},n.createElement("div",{className:"jp-Shortcuts-ShortcutList"},this.props.shortcuts.map(e=>n.createElement(L,{key:e.id,addKeybinding:this.props.addKeybinding,replaceKeybinding:this.props.replaceKeybinding,deleteKeybinding:this.props.deleteKeybinding,resetKeybindings:this.props.resetKeybindings,findConflictsFor:this.props.findConflictsFor,setCustomOptions:this.props.setCustomOptions,shortcut:e,showSelectors:this.props.showSelectors,external:this.props.external}))))}}class ut extends n.Component{render(){return n.createElement("div",{className:this.props.title.toLowerCase()===this.props.active?"jp-Shortcuts-Header jp-Shortcuts-CurrentHeader":"jp-Shortcuts-Header",onClick:()=>this.props.updateSort(this.props.columnId)},this.props.title,n.createElement($.react,{className:"jp-Shortcuts-SortButton jp-ShortcutTitleItem-sortButton"}))}}function pt(l){const e=l.translator.load("jupyterlab");return n.createElement("div",{className:"jp-Shortcuts-AdvancedOptions"},n.createElement("a",{className:"jp-Shortcuts-AdvancedOptionsLink",onClick:()=>l.toggleSelectors()},l.showSelectors?e.__("Hide Selectors"):e.__("Show Selectors")),n.createElement("a",{className:"jp-Shortcuts-AdvancedOptionsLink",onClick:()=>l.resetShortcuts()},e.__("Reset All")),n.createElement(x,{className:"jp-mod-styled jp-mod-accept jp-Shortcuts-AdvancedOptionsButton",onClick:l.toggleAddCommandRow,title:e.__("Tool for adding shortcuts"),"aria-label":e.__("Tool for adding shortcuts")},n.createElement(Q.react,{tag:"span",elementSize:"xlarge",elementPosition:"center"})))}class mt extends n.Component{constructor(e){super(e)}getShortCutTitleItem(e,t){return n.createElement("div",{className:"jp-Shortcuts-Cell"},n.createElement(ut,{title:e,updateSort:this.props.updateSort,active:this.props.currentSort,columnId:t}))}render(){const e=this.props.translator.load("jupyterlab");return n.createElement("div",{className:"jp-Shortcuts-Top"},n.createElement("div",{className:"jp-Shortcuts-TopNav"},n.createElement(et,{"aria-label":e.__("Search shortcuts"),updateFilter:(t,o)=>this.props.updateSearchQuery(o??""),placeholder:e.__("Search…"),useFuzzyFilter:!1}),n.createElement(pt,{toggleSelectors:this.props.toggleSelectors,showSelectors:this.props.showSelectors,resetShortcuts:this.props.resetShortcuts,toggleAddCommandRow:this.props.toggleAddCommandRow,translator:this.props.translator})),n.createElement("div",{className:"jp-Shortcuts-HeaderRowContainer"},n.createElement("div",{className:"jp-Shortcuts-HeaderRow"},this.getShortCutTitleItem(e.__("Category"),"category"),this.getShortCutTitleItem(e.__("Command"),"command"),n.createElement("div",{className:"jp-Shortcuts-Cell"},n.createElement("div",{className:"title-div"},e.__("Shortcut"))),this.getShortCutTitleItem(e.__("Source"),"source"),this.props.showSelectors&&this.getShortCutTitleItem(e.__("Selectors"),"selector"))))}}class gt extends n.Component{constructor(e){super(e),this.updateSearchQuery=t=>{this.setState({searchQuery:t},()=>{const o=this.state.shortcutRegistry;this.setState({filteredShortcutList:this._searchFilterShortcuts(o)},()=>{this.sortShortcuts()})})},this.resetShortcuts=async()=>{await(await this.props.external.getSettings()).set("shortcuts",[]),await this._refreshShortcutList()},this.resetKeybindings=async t=>{await this._setKeybinding(t,[])},this.replaceKeybinding=async(t,o,s)=>this._setKeybinding(t,s,o),this.deleteKeybinding=async(t,o)=>{await this._setKeybinding(t,[],o)},this.addKeybinding=async(t,o)=>{await this._setKeybinding(t,o)},this.setCustomOptions=async(t,o)=>{var s;const r=await this.props.external.getSettings(),i=(s=r.user.shortcuts)!==null&&s!==void 0?s:[],a=i.filter(c=>{var g,p;return c.command===t.command&&c.selector===t.selector&&b.deepEqual((g=c.args)!==null&&g!==void 0?g:{},(p=t.args)!==null&&p!==void 0?p:{})});return a.length?(a.forEach(c=>{c.selector=o.selector,c.args=o.args}),await r.set("shortcuts",i),await this._refreshShortcutList(),!0):(console.error("Error writing the custom options: target not found"),!1)},this.toggleSelectors=()=>{this.setState({showSelectors:!this.state.showSelectors})},this.toggleAddCommandRow=async()=>{this.setState({showAddCommand:!this.state.showAddCommand})},this.updateSort=t=>{t!==this.state.currentSort&&this.setState({currentSort:t},this.sortShortcuts)},this.saveNewShortcut=async()=>{const t={...this.state.newShortcut,args:void 0};for(let s of t.keybindings)await this.addKeybinding(t,s.keys);await this.setCustomOptions(t,{selector:t.selector,args:this.state.newShortcut.args})&&(this._newShortcutItem.reset(),this.toggleAddCommandRow())},this._newShortcutItem=new it({showSelectors:!1,findConflictsFor:(t,o)=>this.state.shortcutRegistry?this.state.shortcutRegistry.findConflictsFor(t,o):(console.error("Cannot search for keybinding conflicts at this time: registry is not ready"),[]),external:this.props.external}),this.state={shortcutRegistry:null,filteredShortcutList:new Array,shortcutsFetched:!1,searchQuery:"",showSelectors:!1,currentSort:"category",showAddCommand:!1,newShortcut:this._newShortcutItem.shortcut},this._newShortcutItem.changed.connect(()=>{this.setState({newShortcut:{...this._newShortcutItem.shortcut}})})}componentDidMount(){this.props.external.actionRequested.connect(this._onActionRequested,this),this._refreshShortcutList()}componentWillUnmount(){this.props.external.actionRequested.disconnect(this._onActionRequested,this)}async _onActionRequested(e,t){if(t.request==="toggle-selectors")return this.toggleSelectors();t.request==="reset-all"&&await this.resetShortcuts()}async _refreshShortcutList(){const e=await this.props.external.getSettings(),t=new j({commandRegistry:this.props.external.commandRegistry,settings:e});this.setState({shortcutRegistry:t,filteredShortcutList:this._searchFilterShortcuts(t),shortcutsFetched:!0},()=>{this.sortShortcuts()})}_searchFilterShortcuts(e){return e?j.matchItems(e,this.state.searchQuery).map(o=>o.item):[]}async _setKeybinding(e,t,o){var s,r,i,a,c;t.length===1&&t[0]==""&&(t=[]);const g=t.map(w.normalizeKeystroke),p=await this.props.external.getSettings(),f=(s=p.user.shortcuts)!==null&&s!==void 0?s:[],d=[];let m=!1;for(let u of f)if(u.command===e.command&&u.selector===e.selector&&b.deepEqual((r=u.args)!==null&&r!==void 0?r:{},(i=e.args)!==null&&i!==void 0?i:{})&&o&&b.deepEqual(o.keys,w.normalizeKeys(u))){const y=o.isDefault&&b.deepEqual(o.keys,g);t.length!==0&&!y&&d.push(this._setShortcutKeys(u,t)),m=!0}else{if(u.command===e.command&&u.selector===e.selector&&b.deepEqual((a=u.args)!==null&&a!==void 0?a:{},(c=e.args)!==null&&c!==void 0?c:{})&&!o&&t.length===0)continue;d.push(u)}if(!m){const u=!o||!b.deepEqual(o.keys,g);o&&o.isDefault&&u&&d.push(this._shortcutFromTarget(e,o.keys,{disabled:!0,preventDefault:o.preventDefault})),t.length!==0&&u&&d.push(this._shortcutFromTarget(e,t,{preventDefault:o?.preventDefault}))}await p.set("shortcuts",d),await this._refreshShortcutList()}_setShortcutKeys(e,t){const o=this._platformKeys(e);return{...e,[o]:t}}_shortcutFromTarget(e,t,o={}){const s={command:e.command,selector:e.selector,keys:t};return e.args&&!b.deepEqual(e.args,{})&&(s.args=e.args),o.disabled&&(s.disabled=!0),o.preventDefault!==void 0&&(s.preventDefault=o.preventDefault),s}_platformKeys(e){return k.IS_WIN&&e.winKeys?"winKeys":k.IS_MAC&&e.macKeys?"macKeys":!k.IS_WIN&&!k.IS_MAC&&e.linuxKeys?"linuxKeys":"keys"}sortShortcuts(){const e=this.state.filteredShortcutList;let t=this.state.currentSort;t==="command"&&(t="label");const o=s=>{var r;return t==="source"?s.keybindings.every(i=>i.isDefault)?"default":"other":(r=s[t])!==null&&r!==void 0?r:""};e.sort((s,r)=>{var i,a;const c=o(s),g=o(r),p=c.localeCompare(g);if(p)return p;{const f=(i=s.label)!==null&&i!==void 0?i:"",d=(a=r.label)!==null&&a!==void 0?a:"";return f.localeCompare(d)}}),this.setState({filteredShortcutList:e})}render(){return this.state.shortcutsFetched?n.createElement("div",{className:"jp-Shortcuts-ShortcutUI",id:"jp-shortcutui"},n.createElement(mt,{updateSearchQuery:this.updateSearchQuery,resetShortcuts:this.resetShortcuts,toggleSelectors:this.toggleSelectors,showSelectors:this.state.showSelectors,updateSort:this.updateSort,currentSort:this.state.currentSort,toggleAddCommandRow:this.toggleAddCommandRow,width:this.props.width,translator:this.props.external.translator}),this.state.showAddCommand&&n.createElement(L,{...this._newShortcutItem,shortcut:this.state.newShortcut,newShortcutUtils:{searchQuery:this.state.searchQuery,updateCommand:this._newShortcutItem.updateCommand,saveShortcut:this.saveNewShortcut}}),n.createElement(ht,{shortcuts:this.state.filteredShortcutList,resetKeybindings:this.resetKeybindings,addKeybinding:this.addKeybinding,replaceKeybinding:this.replaceKeybinding,deleteKeybinding:this.deleteKeybinding,setCustomOptions:this.setCustomOptions,showSelectors:this.state.showSelectors,findConflictsFor:(e,t)=>this.state.shortcutRegistry?this.state.shortcutRegistry.findConflictsFor(e,t):(console.error("Cannot search for keybinding conflicts at this time: registry is not ready"),[]),height:this.props.height,external:this.props.external})):null}}const yt=l=>P.createElement(gt,{external:l.external,height:1e3,width:1e3}),T="@jupyterlab/shortcuts-extension:shortcuts";function ft(l,e,t,o,s){return{translator:t,getSettings:()=>l.load(T,!0),commandRegistry:e.commands,actionRequested:o,editorFactory:s}}const v={id:T,description:"Adds the keyboard shortcuts editor.",requires:[ot],optional:[V,st,G],activate:async(l,e,t,o,s)=>{const r=t??Y,i=r.load("jupyterlab"),{commands:a}=l;let c,g,p={};if(o){const d=new R({}),m=h=>h.dataset.shortcut!==void 0;l.commands.addCommand(C.editBinding,{label:i.__("Edit Keybinding"),caption:i.__("Edit existing keybinding"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const h=l.contextMenuHitTest(m),S=h?.dataset.keybinding,_=h?.dataset.shortcut;if(!_||!S)return console.log("Missing shortcut id/keybinding information");d.emit({request:"edit-keybinding",keybinding:parseInt(S,10),shortcutId:_})}}),l.commands.addCommand(C.deleteBinding,{label:i.__("Delete Keybinding"),caption:i.__("Delete chosen keybinding"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const h=l.contextMenuHitTest(m),S=h?.dataset.keybinding,_=h?.dataset.shortcut;if(!_||!S)return console.log("Missing shortcut id/keybinding information");d.emit({request:"delete-keybinding",keybinding:parseInt(S,10),shortcutId:_})}}),l.commands.addCommand(C.addBinding,{label:i.__("Add Keybinding"),caption:i.__("Add new keybinding for existing shortcut target"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const h=l.contextMenuHitTest(m),S=h?.dataset.shortcut;if(!S)return console.log("Missing shortcut id to add keybinding to");d.emit({request:"add-keybinding",shortcutId:S})}}),a.addCommand(C.toggleSelectors,{label:i.__("Toggle Selectors"),caption:i.__("Toggle command selectors"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{d.emit({request:"toggle-selectors"})}}),a.addCommand(C.resetAll,{label:i.__("Reset All"),caption:i.__("Reset all shortcuts"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{d.emit({request:"reset-all"})}});const u=s?h=>s.factoryService.newInlineEditor(h):void 0,y={fieldRenderer:h=>yt({external:ft(e,l,r,d,u),...h})};o.addRenderer(`${v.id}.shortcuts`,y)}function f(d){const m=l.commands.listCommands().join(`
|
|
1
|
+
import{a9 as R,aF as I,aA as O,fO as M,r as n,dI as w,cn as b,fP as q,eG as F,fQ as H,fR as U,az as J,fS as k,ec as x,dQ as W,fT as z,fU as $,cv as Q,J as P,aC as V,et as G,aD as Y,dy as X,dv as Z}from"../datalayer-app-main.js";import{H as tt}from"./htmlselect-CqXICb9e.js";import{o as et}from"./index-DCpvl_OP.js";import{a as st}from"./tokens-BYcJtuKD.js";import{I as ot}from"./tokens-DY_UrMLq.js";import"./Output-C6ZHZSBH.js";import"./index--S8WFITA.js";import"./hoverbox-CStlKQWE.js";import"./index-6zxBQeM_.js";import"./index-9wJFadG-.js";import"./dayjs.min-u3zuoSR8.js";import"./isEqual-BYxXubsX.js";import"./d3-color-Jd8hXty2.js";import"./dist-BrUAt6vF.js";import"./KebabHorizontalIcon-D6AY8pIS.js";import"./PaintbrushIcon-CFBHU-3l.js";import"./index-CqP3xLL5.js";import"./RestartIcon-DvpOf5Mf.js";import"./CellSidebarExtension-D7aXShZc.js";import"./NotebookSkeleton-BkzTMhIX.js";import"./Avatar-MNx1kN3F.js";import"./renderer-8__rsP1H.js";import"./SquareIcon-Dy3l3VdH.js";import"./FileDirectoryOpenFillIcon-jGhuRcP3.js";import"./url-C6fJII94.js";/* empty css *//* empty css */import"./style-DdAxk_bj.js";/* empty css */import"./style-Cj1gzCjo.js";/* empty css */import"./style-rkw8dR9f.js";import"./style-GHJFdtIz.js";import"./style-ZSIOeMoX.js";import"./style-iVfD6mFL.js";import"./style-DA-Ya7rp.js";import"./style-D3tvWcFO.js";import"./style-BOqStzF9.js";import"./style-ADLQJ-E9.js";import"./style-DgglluaK.js";import"./ArrowLeftIcon-sX3iNMG1.js";import"./SkubbleIcon-CAaVh_BE.js";import"./usePrimerThemeBridge-DyX4EYyN.js";import"./index-BbcMy3Al.js";import"./KernelVariables-D3DSQaD3.js";import"./index-C0d-d3s4.js";import"./SortAscIcon-CmH04s3F.js";import"./SortDescIcon-Qif6E10I.js";import"./NotebookToolbar-BMjQTGrr.js";import"./RepoPushIcon-BtXQRhLa.js";import"./Toolbar-BncUh2ly.js";import"./sessions-CgjtuOSm.js";import"./tokens-CBhRbpQP.js";import"./drivecontents-D1HzL7Fi.js";import"./kernel-BmfZmtIo.js";class it{constructor(e){this.reset=()=>{this._shortcut={id:"new shortcut",command:"",keybindings:[],selector:"body",category:"",args:{}},this._changed.emit()},this.addKeybinding=async(t,o)=>{this._shortcut.keybindings.push({keys:o,isDefault:!1}),this._changed.emit()},this.replaceKeybinding=async(t,o,s)=>{if(s=s.filter(i=>i!==""),!s.length)return this.deleteKeybinding(t,o);const r=this._shortcut.keybindings.findIndex(i=>i.keys===o.keys);r>-1?this._shortcut.keybindings[r]={keys:s,isDefault:!1}:this.addKeybinding(t,s),this._changed.emit()},this.deleteKeybinding=async(t,o)=>{const s=this._shortcut.keybindings.findIndex(r=>r.keys===o.keys);s>-1&&(this._shortcut.keybindings.splice(s,1),this._changed.emit())},this.resetKeybindings=async t=>{this._shortcut={...this._shortcut,keybindings:[]},this._changed.emit()},this.setCustomOptions=async(t,o)=>(this._shortcut={...this._shortcut,selector:o.selector,args:o.args},this._changed.emit(),!0),this.updateCommand=(t,o)=>{this._shortcut={...this._shortcut,command:t,category:o},this._changed.emit()},this._changed=new R(this),this._shortcut={id:"new shortcut",command:"",keybindings:[],selector:"body",category:"",args:{}},this.findConflictsFor=e.findConflictsFor,this.showSelectors=e.showSelectors,this.external=e.external}get shortcut(){return this._shortcut}get changed(){return this._changed}}class rt extends I{constructor(e){const{shortcut:t,translator:o,editorFactory:s}=e,r=o.load("jupyterlab"),i=new nt(t,o,s,()=>this._checkValidation(),e.readOnly),a=[];e.readOnly?a.push(I.cancelButton({label:r.__("OK")})):(a.push(I.cancelButton({label:r.__("Cancel")})),a.push(I.okButton({label:r.__("Apply")}))),super({title:e.readOnly?r.__("Shortcut Options"):r.__("Custom Shortcut Options"),body:i,buttons:a})}_evtKeydown(e){if(e.key==="Enter"){const t=this.node.querySelector(".jp-JSONEditor"),o=document.activeElement;if(t instanceof HTMLElement&&o instanceof HTMLElement&&t.contains(o)){e.stopPropagation();return}}super._evtKeydown(e)}}class nt extends O{constructor(e,t,o,s,r){var i,a;super();const c=t.load("jupyterlab");this.addClass("jp-Shortcuts-CustomOptionsDialogBody");const g=document.createElement("div");g.className="jp-Shortcuts-CustomOptionDialog-container";const p=document.createElement("label");p.textContent=c.__("Selector:"),p.className="jp-Dialog-label",this._selectorInput=document.createElement("input"),this._selectorInput.type="text",this._selectorInput.disabled=r??!1,this._selectorInput.value=e.selector,this._selectorInput.className="jp-mod-styled",g.appendChild(p),g.appendChild(this._selectorInput);const f=document.createElement("label");if(f.textContent=c.__("Arguments:"),f.className="jp-Dialog-label",g.appendChild(f),r){const d=document.createElement("pre");d.textContent=JSON.stringify((i=e.args)!==null&&i!==void 0?i:{},void 0,2),g.appendChild(d)}else this._editorWidget=new at((a=e.args)!==null&&a!==void 0?a:{},o,s),g.appendChild(this._editorWidget.node);this.node.appendChild(g)}getValue(){var e,t;const o=(t=(e=this._editorWidget)===null||e===void 0?void 0:e.getJSON())!==null&&t!==void 0?t:"{}";let s;try{s=JSON.parse(o)}catch(r){console.error(`Invalid JSON in arguments: ${r instanceof Error?r.message:String(r)}`),s={}}return{selector:this._selectorInput.value,args:s}}dispose(){var e;(e=this._editorWidget)===null||e===void 0||e.dispose(),super.dispose()}}class at extends O{constructor(e,t,o){super(),this._validateJSON=()=>{try{const a=this._editor.model.sharedModel.getSource();JSON.parse(a),this.node.classList.remove("jp-mod-error")}catch{this.node.classList.add("jp-mod-error")}this._checkValidation()},this.addClass("jp-JSONEditor"),this._checkValidation=o;const s=document.createElement("div");s.className="jp-JSONEditor-host";const r=new M.Model({mimeType:"application/json"}),i=JSON.stringify(e,null,2);r.sharedModel.setSource(i),this._editor=t({host:s,model:r,config:{readOnly:!1}}),this.node.appendChild(s),this._editor.model.sharedModel.changed.connect(this._validateJSON,this)}getJSON(){return this._editor.model.sharedModel.getSource()}dispose(){this._editor.model.sharedModel.changed.disconnect(this._validateJSON,this),this._editor.dispose(),super.dispose()}}const D="jp-Shortcuts-ConflictContainer";class A extends n.Component{constructor(e){super(e),this.handleSubmit=async()=>{this._isReplacingExistingKeybinding?this.state.selected?this.props.toggleInput():await this._updateShortcut():(await this._updateShortcut(),this.props.toggleInput())},this._updateShortcut=async()=>{const t=[...this.state.keys,this.state.currentChain];this.setState({keys:t}),this.props.keybinding?await this.props.replaceKeybinding(this.props.shortcut,this.props.keybinding,t):await this.props.addKeybinding(this.props.shortcut,t)},this._handleOverwrite=async(t,o)=>{const s=o.map(w.normalizeKeystroke);for(const r of t){const i=r.keybindings.filter(a=>b.deepEqual(a.keys,s)||s.some(c=>b.deepEqual(a.keys,[c])))[0];if(!i){console.error(`Conflicting binding could not be found for ${r} using keys ${o}`);continue}await this.props.deleteKeybinding(r,i)}await this._updateShortcut()},this.parseChaining=(t,o,s,r,i)=>{let a=q.keyForKeydownEvent(t.nativeEvent);const c=["Shift","Control","Alt","Meta","Ctrl","Accel"];if(t.key==="Backspace")s="",o="",r=[],i="",this.setState({value:o,userInput:s,keys:r,currentChain:i});else if(t.key!=="CapsLock"){const g=s.substr(s.lastIndexOf(" ")+1,s.length).trim();c.lastIndexOf(g)===-1&&g!=""?(s=s+",",r.push(i),i="",t.ctrlKey&&t.key!="Control"&&(s=(s+" Ctrl").trim(),i=(i+" Ctrl").trim()),t.metaKey&&t.key!="Meta"&&(s=(s+" Accel").trim(),i=(i+" Accel").trim()),t.altKey&&t.key!="Alt"&&(s=(s+" Alt").trim(),i=(i+" Alt").trim()),t.shiftKey&&t.key!="Shift"&&(s=(s+" Shift").trim(),i=(i+" Shift").trim()),c.lastIndexOf(t.key)===-1?(s=(s+" "+a).trim(),i=(i+" "+a).trim()):t.key==="Meta"?(s=(s+" Accel").trim(),i=(i+" Accel").trim()):t.key==="Control"?(s=(s+" Ctrl").trim(),i=(i+" Ctrl").trim()):t.key==="Shift"?(s=(s+" Shift").trim(),i=(i+" Shift").trim()):t.key==="Alt"?(s=(s+" Alt").trim(),i=(i+" Alt").trim()):(s=(s+" "+t.key).trim(),i=(i+" "+t.key).trim())):t.key==="Control"?(s=(s+" Ctrl").trim(),i=(i+" Ctrl").trim()):t.key==="Meta"?(s=(s+" Accel").trim(),i=(i+" Accel").trim()):t.key==="Shift"?(s=(s+" Shift").trim(),i=(i+" Shift").trim()):t.key==="Alt"?(s=(s+" Alt").trim(),i=(i+" Alt").trim()):(s=(s+" "+a).trim(),i=(i+" "+a).trim())}return this.setState({keys:r,currentChain:i}),[s,r,i]},this.checkNonFunctional=()=>{const t=["Ctrl","Alt","Accel","Shift"],o=this.state.currentChain.split(" "),s=o[o.length-1];return this.setState({isFunctional:t.indexOf(s)===-1}),t.indexOf(s)!==-1},this.checkShortcutAvailability=(t,o,s)=>{const r=this.props.findConflictsFor([...o,s],this.props.shortcut.selector),i=t===""||r.length===0;return!i&&r.length===1&&r[0].id===this.props.shortcut.id&&this._isReplacingExistingKeybinding?(this.setState({isAvailable:!0}),[]):(this.setState({isAvailable:i}),r)},this.handleInput=t=>{t.preventDefault(),this.setState({selected:!1});const o=this.parseChaining(t,this.state.value,this.state.userInput,this.state.keys,this.state.currentChain),s=o[0],r=o[1],i=o[2],a=this.props.toSymbols(s);let c=this.checkShortcutAvailability(s,r,i);this.setState({value:a,userInput:s,keys:r,currentChain:i},()=>{this.checkNonFunctional(),this._emitConflicts(c)})},this._handleBlur=t=>{var o,s;!((o=this._ref.current)===null||o===void 0)&&o.contains(t.relatedTarget)||!((s=t.relatedTarget)===null||s===void 0)&&s.closest(`.${D}`)||this.props.toggleInput()},this._ref=n.createRef(),this.state={value:this.props.placeholder,userInput:"",isAvailable:!0,isFunctional:this._isReplacingExistingKeybinding,keys:[],currentChain:"",selected:!0}}get _isReplacingExistingKeybinding(){return!!this.props.keybinding}_emitConflicts(e){const t=[...this.state.keys,this.state.currentChain];this.props.displayConflicts({conflictsWith:e,keys:this.state.keys,overwrite:async()=>{this.setState({isAvailable:!0}),await this._handleOverwrite(e,t),this.props.toggleInput()},cancel:()=>{this.props.toggleInput()}})}render(){const e=this.props.translator.load("jupyterlab");let t="jp-Shortcuts-Input";return this.state.isAvailable||(t+=" jp-mod-unavailable-Input"),n.createElement("div",{className:this.props.displayInput?this._isReplacingExistingKeybinding?"jp-Shortcuts-InputBox":"jp-Shortcuts-InputBox jp-Shortcuts-InputBoxNew":"jp-mod-hidden",ref:this._ref,onBlur:this._handleBlur},n.createElement("div",{tabIndex:0,className:t,onKeyDown:this.handleInput,ref:o=>o&&o.focus(),"data-lm-suppress-shortcuts":"true"},n.createElement("p",{className:this.state.selected&&this._isReplacingExistingKeybinding?"jp-Shortcuts-InputText jp-mod-selected-InputText":this.state.value===""?"jp-Shortcuts-InputText jp-mod-waiting-InputText":"jp-Shortcuts-InputText"},this.state.value===""?e.__("press keys"):this.state.value)),n.createElement("button",{className:this.state.isFunctional?this.state.isAvailable?"jp-Shortcuts-Submit":"jp-Shortcuts-Submit jp-mod-conflict-Submit":"jp-Shortcuts-Submit jp-mod-defunc-Submit",disabled:!this.state.isAvailable||!this.state.isFunctional,onClick:this.handleSubmit,tabIndex:0},this.state.isAvailable?n.createElement(F.react,null):n.createElement(H.react,null)))}}var C;(function(l){l.editBinding="shortcuts:edit-keybinding",l.addBinding="shortcuts:add-keybinding",l.deleteBinding="shortcuts:delete-keybinding",l.toggleSelectors="shortcuts:toggle-selectors",l.resetAll="shortcuts:reset-all"})(C||(C={}));var E;(function(l){l[l.Label=0]="Label",l[l.Category=1]="Category",l[l.Split=2]="Split",l[l.Default=3]="Default"})(E||(E={}));class j extends Map{constructor(e){var t,o,s,r;super();const{settings:i,commandRegistry:a,allCommands:c}=e;if(c)for(const g of a.listCommands()){const p={command:g,selector:"body"},f=this._computeTargetId(p),d=p.command.split(":"),m=(t=a.label(p.command,p.args))!==null&&t!==void 0?t:d.length>1?d[1]:void 0,u=d[0],y={...p,id:f,keybindings:[],category:u,label:m,args:{}};this.set(f,y)}else if(i){const g=(o=i.user.shortcuts)!==null&&o!==void 0?o:[],p=new Set(g.map(this._computeKeybindingId.bind(this))),f=(s=i.composite.shortcuts)!==null&&s!==void 0?s:[],d=i.default("shortcuts").map(m=>this._computeTargetId(m));for(const m of f){const u=this._computeTargetId(m),y=this._computeKeybindingId(m),h={keys:w.normalizeKeys(m),isDefault:!p.has(y),...m.preventDefault===void 0?{}:{preventDefault:m.preventDefault}},S=this.get(u);if(S)S.keybindings.push(h);else{const _=m.command.split(":"),K=(r=a.label(m.command,m.args))!==null&&r!==void 0?r:_.length>1?_[1]:void 0,B=_[0];this.set(u,{id:u,selector:m.selector,command:m.command,category:B,label:K,args:m.args,keybindings:[h],userDefined:!d.includes(u)})}}}}findConflictsFor(e,t){const o=new lt({registry:this}),s=e.map(w.normalizeKeystroke);let r=o.findConflicts(s,t);if(r.length!==0)return r;for(const i of s)if(r=o.findConflicts([i],t),r.length!==0)return r;return[]}_computeTargetId(e){var t;return e.command+"_"+e.selector+"_"+JSON.stringify((t=e.args)!==null&&t!==void 0?t:{})}_computeKeybindingId(e){var t;return[e.command,e.selector,JSON.stringify((t=e.args)!==null&&t!==void 0?t:{}),w.normalizeKeys(e).join(" ")].join("_")}}class lt{constructor(e){var t;const o=new Map;for(const s of e.registry.values())for(const r of s.keybindings){const i=this._keybindingHash(r.keys,s.selector),a=(t=o.get(i))!==null&&t!==void 0?t:[];a.push(s),o.set(i,a)}this._keybindingsMap=o}findConflicts(e,t){var o;const s=this._keybindingHash(e,t);return(o=this._keybindingsMap.get(s))!==null&&o!==void 0?o:[]}_keybindingHash(e,t){return e.join(" ")+"_"+t}}(function(l){function e(s){return s.replace(/\s+/g,"").toLowerCase()}function t(s,r){var i;const a=s.category.toLowerCase(),c=((i=s.label)!==null&&i!==void 0?i:"").toLowerCase(),g=`${a} ${c}`;let p=1/0,f=null;const d=/\b\w/g;for(;;){const S=d.exec(g);if(!S)break;const _=U.matchSumOfDeltas(g,r,S.index);if(!_)break;_&&_.score<=p&&(p=_.score,f=_.indices)}if(!f||p===1/0)return null;const m=a.length+1,u=J.lowerBound(f,m,(S,_)=>S-_),y=f.slice(0,u),h=f.slice(u);for(let S=0,_=h.length;S<_;++S)h[S]-=m;return y.length===0?{matchType:E.Label,categoryIndices:null,labelIndices:h,score:p,item:s}:h.length===0?{matchType:E.Category,categoryIndices:y,labelIndices:null,score:p,item:s}:{matchType:E.Split,categoryIndices:y,labelIndices:h,score:p,item:s}}function o(s,r){r=e(r);let i=[];for(const a of s.values()){if(!r){i.push({matchType:E.Default,categoryIndices:null,labelIndices:null,score:0,item:a});continue}let c=t(a,r);c&&i.push(c)}return i}l.matchItems=o})(j||(j={}));const ct={Ctrl:"⌃",Alt:"⌥",Shift:"⇧",Accel:"⌘",Cmd:"⌘"};class L extends n.Component{constructor(e){super(e),this.toggleInputNew=()=>{this.setState({displayNewInput:!this.state.displayNewInput,conflicts:new Map})},this.toSymbols=t=>k.IS_MAC?t.split(" ").map(o=>{var s;return(s=ct[o])!==null&&s!==void 0?s:o}).join(" "):t.split(" ").map(o=>o==="Accel"?"Ctrl":o).join(" "),this._trans=this.props.external.translator.load("jupyterlab"),this.state={displayNewInput:!1,displayReplaceInput:Object.freeze({}),conflicts:new Map}}componentDidMount(){this.props.external.actionRequested.connect(this._onActionRequested,this)}componentWillUnmount(){this.props.external.actionRequested.disconnect(this._onActionRequested,this)}async _onActionRequested(e,t){if(!("shortcutId"in t&&t.shortcutId!==this.props.shortcut.id)){if(t.request==="add-keybinding")return this.toggleInputNew();if(t.request==="edit-keybinding"&&this.toggleInputReplaceMethod(t.keybinding),t.request==="delete-keybinding"){const o=this.props.shortcut,s=o.keybindings[t.keybinding];this.props.deleteKeybinding(o,s).catch(console.error)}}}getCategoryCell(){return n.createElement("div",{className:"jp-Shortcuts-Cell"},this.props.shortcut.category)}getLabelCell(){var e;if(this.props.newShortcutUtils){const t=this._getFilteredCommands();return n.createElement("div",{className:"jp-Shortcuts-Cell"},n.createElement(tt,{value:this.props.shortcut.command,options:[{value:"",label:this._trans.__("Select a command")},...t.map(o=>({value:o.command,label:`${o.category}: ${o.label}`}))],onChange:o=>{var s,r,i;const a=t.find(c=>c.command===o.target.value);(s=this.props.newShortcutUtils)===null||s===void 0||s.updateCommand((r=a?.command)!==null&&r!==void 0?r:"",(i=a?.category)!==null&&i!==void 0?i:"")}}))}else return n.createElement("div",{className:"jp-Shortcuts-Cell"},n.createElement("div",{className:"jp-label"},(e=this.props.shortcut.label)!==null&&e!==void 0?e:this._trans.__("(Command label missing)")))}getResetShortCutLink(){return n.createElement("a",{className:"jp-Shortcuts-Reset",onClick:()=>this.props.resetKeybindings(this.props.shortcut)},this.props.shortcut.userDefined?this._trans.__("Delete"):this._trans.__("Reset"))}getSourceCell(){var e;const t=this.props.shortcut.keybindings.every(r=>r.isDefault),o=this.props.shortcut.userDefined||!!this.props.newShortcutUtils,s=o?this._trans.__("Custom options"):this._trans.__("Show options");return n.createElement("div",{className:"jp-Shortcuts-Cell"},!this.props.newShortcutUtils&&n.createElement("div",{className:"jp-Shortcuts-SourceCell"},t?this._trans.__("Default"):this._trans.__("Custom")),t?"":this.getResetShortCutLink(),this.props.external.editorFactory&&n.createElement(x,{className:"jp-mod-styled jp-mod-reject jp-Shortcuts-CustomOptions",onClick:async()=>{if(!this.props.external.editorFactory){console.error("Cannot build the custom options form");return}const i=await new rt({shortcut:this.props.shortcut,translator:this.props.external.translator,editorFactory:this.props.external.editorFactory,readOnly:!o}).launch();i.button.accept&&o&&i.value&&await this.props.setCustomOptions(this.props.shortcut,i.value)},title:s,"aria-label":s,appearance:"neutral"},o?n.createElement(W.react,{tag:null}):n.createElement(z.react,{tag:null})),!!this.props.newShortcutUtils&&n.createElement(n.Fragment,null,n.createElement(x,{className:"jp-mod-styled jp-mod-accept jp-Shortcuts-SaveNew",onClick:(e=this.props.newShortcutUtils)===null||e===void 0?void 0:e.saveShortcut,title:this._trans.__("Save shortcut"),"aria-label":this._trans.__("Save shortcut"),appearance:"neutral",disabled:!this.props.shortcut.command||!this.props.shortcut.keybindings.length||this.props.shortcut.keybindings.every(r=>!r.keys||r.keys.length===0)},n.createElement(F.react,{tag:null}))))}getOptionalSelectorCell(){return this.props.showSelectors?n.createElement("div",{className:"jp-Shortcuts-Cell"},n.createElement("div",{className:"jp-selector"},this.props.shortcut.selector)):null}getClassNameForShortCuts(e){const t=["jp-Shortcuts-ShortcutCell"];switch(e.length){case 1:t.push("jp-Shortcuts-SingleCell");break;case 0:t.push("jp-Shortcuts-EmptyCell");break}return t.join(" ")}toggleInputReplaceMethod(e){const t=this.state.displayReplaceInput[e];this.setState({displayReplaceInput:{...this.state.displayReplaceInput,[e]:!t},conflicts:new Map})}getDisplayReplaceInput(e){return this.state.displayReplaceInput[e]}getOrDisplayIfNeeded(e){const t=["jp-Shortcuts-Or"];return(e||this.state.displayNewInput)&&t.push("jp-Shortcuts-Or-Forced"),n.createElement("div",{className:t.join(" ")},this._trans.__("or"))}getShortCutAsInput(e,t){return n.createElement(A,{addKeybinding:this.props.addKeybinding,replaceKeybinding:this.props.replaceKeybinding,deleteKeybinding:this.props.deleteKeybinding,findConflictsFor:this.props.findConflictsFor,toggleInput:()=>this.toggleInputReplaceMethod(t),shortcut:this.props.shortcut,keybinding:e,displayConflicts:o=>{const s=new Map(this.state.conflicts);s.set(e,o),this.setState({conflicts:s})},toSymbols:this.toSymbols,displayInput:this.getDisplayReplaceInput(t),placeholder:this.toSymbols(e.keys.join(", ")),translator:this.props.external.translator})}getShortCutForDisplayOnly(e){return e.keys.map((t,o)=>n.createElement("div",{className:"jp-Shortcuts-ShortcutKeysContainer",key:o},n.createElement("div",{className:"jp-Shortcuts-ShortcutKeys"},this.toSymbols(t).split(" ").map((s,r,i)=>n.createElement(n.Fragment,{key:`${o}-${s}-${r}`},n.createElement("span",{className:"jp-ContextualShortcut-Key"},s),r+1<i.length?" + ":null))),o+1<e.keys.length?n.createElement("div",{className:"jp-Shortcuts-Comma"},","):null))}isLocationBeingEdited(e){return this.state.displayReplaceInput[e]}getDivForKey(e,t,o){return n.createElement("div",{className:"jp-Shortcuts-ShortcutContainer",key:this.props.shortcut.id+"_"+e,"data-keybinding":e,"data-shortcut":this.props.shortcut.id,onClick:()=>this.toggleInputReplaceMethod(e)},this.isLocationBeingEdited(e)?this.getShortCutAsInput(t,e):this.getShortCutForDisplayOnly(t),!(e===this._nonEmptyBindings.length-1&&Object.values(this.state.displayReplaceInput).some(Boolean))&&this.getOrDisplayIfNeeded(e<this._nonEmptyBindings.length-1))}getAddLink(){return n.createElement("a",{className:this.state.displayNewInput?"":"jp-Shortcuts-Plus",onClick:()=>{this.toggleInputNew()}},this._trans.__("Add"))}getInputBoxWhenToggled(){return this.state.displayNewInput?n.createElement(A,{addKeybinding:this.props.addKeybinding,replaceKeybinding:this.props.replaceKeybinding,deleteKeybinding:this.props.deleteKeybinding,findConflictsFor:this.props.findConflictsFor,toggleInput:this.toggleInputNew,shortcut:this.props.shortcut,displayConflicts:e=>{const t=new Map(this.state.conflicts);t.set(null,e),this.setState({conflicts:t})},toSymbols:this.toSymbols,displayInput:this.state.displayNewInput,placeholder:"",translator:this.props.external.translator}):n.createElement("div",null)}getShortCutsCell(e){return n.createElement("div",{className:"jp-Shortcuts-Cell"},n.createElement("div",{className:this.getClassNameForShortCuts(e)},e.map((t,o)=>this.getDivForKey(o,t,e)),e.length>=1&&!this.state.displayNewInput&&!Object.values(this.state.displayReplaceInput).some(Boolean)&&this.getAddLink(),e.length===0&&!this.state.displayNewInput&&this.getAddLink(),this.getInputBoxWhenToggled()))}getConflicts(){const e=[...this.state.conflicts.values()].filter(t=>t.conflictsWith.length!==0);return e.length===0?n.createElement(n.Fragment,null):n.createElement("div",{className:"jp-Shortcuts-Row jp-Shortcuts-RowWithConflict"},n.createElement("div",{className:D},e.map(t=>{const o=t.keys.join(" ")+"_"+t.conflictsWith.map(s=>s.id).join("");return n.createElement("div",{className:"jp-Shortcuts-Conflict",key:o},n.createElement("div",{className:"jp-Shortcuts-ErrorMessage"},this._trans.__("Shortcut already in use by %1. Overwrite it?",t.conflictsWith.map(s=>{var r;return(r=s.label)!==null&&r!==void 0?r:s.command}).join(", "))),n.createElement("div",{className:"jp-Shortcuts-ErrorButton"},n.createElement("button",{className:"jp-Button jp-mod-reject jp-mod-styled",onClick:()=>{this._clearConflict(t),t.cancel()}},this._trans.__("Cancel")),n.createElement("button",{className:"jp-Button jp-mod-warn jp-mod-styled",onClick:()=>{this._clearConflict(t),t.overwrite()}},this._trans.__("Overwrite"))))})))}_clearConflict(e){const t=new Map,o=this._conflictId(e);for(const[s,r]of this.state.conflicts.entries())this._conflictId(r)!==o&&t.set(s,r);this.setState({conflicts:t})}_conflictId(e){return e.keys.join(" ")+"_"+e.conflictsWith.map(t=>t.id).join("")}_getFilteredCommands(){var e,t;const o=new j({commandRegistry:this.props.external.commandRegistry,allCommands:!0}),s=j.matchItems(o,(t=(e=this.props.newShortcutUtils)===null||e===void 0?void 0:e.searchQuery)!==null&&t!==void 0?t:"").map(r=>r.item).filter(r=>!r.command.startsWith("__internal:"));return s.sort((r,i)=>{var a,c;const g=r.category,p=i.category,f=g.localeCompare(p);if(f)return f;{const d=(a=r.label)!==null&&a!==void 0?a:"",m=(c=i.label)!==null&&c!==void 0?c:"";return d.localeCompare(m)}}),s}get _nonEmptyBindings(){return this.props.shortcut.keybindings.filter(e=>e.keys.filter(t=>t!="").length!==0)}render(){return n.createElement(n.Fragment,null,n.createElement("div",{className:`jp-Shortcuts-Row${this.props.newShortcutUtils?" jp-Shortcuts-Row-newShortcut":""}`,"data-shortcut":this.props.shortcut.id},this.getCategoryCell(),this.getLabelCell(),this.getShortCutsCell(this._nonEmptyBindings),this.getSourceCell(),this.getOptionalSelectorCell()),this.getConflicts())}}const dt=115;class ht extends n.Component{render(){return n.createElement("div",{className:"jp-Shortcuts-ShortcutListContainer",style:{height:`${this.props.height-dt}px`},id:"shortcutListContainer"},n.createElement("div",{className:"jp-Shortcuts-ShortcutList"},this.props.shortcuts.map(e=>n.createElement(L,{key:e.id,addKeybinding:this.props.addKeybinding,replaceKeybinding:this.props.replaceKeybinding,deleteKeybinding:this.props.deleteKeybinding,resetKeybindings:this.props.resetKeybindings,findConflictsFor:this.props.findConflictsFor,setCustomOptions:this.props.setCustomOptions,shortcut:e,showSelectors:this.props.showSelectors,external:this.props.external}))))}}class ut extends n.Component{render(){return n.createElement("div",{className:this.props.title.toLowerCase()===this.props.active?"jp-Shortcuts-Header jp-Shortcuts-CurrentHeader":"jp-Shortcuts-Header",onClick:()=>this.props.updateSort(this.props.columnId)},this.props.title,n.createElement($.react,{className:"jp-Shortcuts-SortButton jp-ShortcutTitleItem-sortButton"}))}}function pt(l){const e=l.translator.load("jupyterlab");return n.createElement("div",{className:"jp-Shortcuts-AdvancedOptions"},n.createElement("a",{className:"jp-Shortcuts-AdvancedOptionsLink",onClick:()=>l.toggleSelectors()},l.showSelectors?e.__("Hide Selectors"):e.__("Show Selectors")),n.createElement("a",{className:"jp-Shortcuts-AdvancedOptionsLink",onClick:()=>l.resetShortcuts()},e.__("Reset All")),n.createElement(x,{className:"jp-mod-styled jp-mod-accept jp-Shortcuts-AdvancedOptionsButton",onClick:l.toggleAddCommandRow,title:e.__("Tool for adding shortcuts"),"aria-label":e.__("Tool for adding shortcuts")},n.createElement(Q.react,{tag:"span",elementSize:"xlarge",elementPosition:"center"})))}class mt extends n.Component{constructor(e){super(e)}getShortCutTitleItem(e,t){return n.createElement("div",{className:"jp-Shortcuts-Cell"},n.createElement(ut,{title:e,updateSort:this.props.updateSort,active:this.props.currentSort,columnId:t}))}render(){const e=this.props.translator.load("jupyterlab");return n.createElement("div",{className:"jp-Shortcuts-Top"},n.createElement("div",{className:"jp-Shortcuts-TopNav"},n.createElement(et,{"aria-label":e.__("Search shortcuts"),updateFilter:(t,o)=>this.props.updateSearchQuery(o??""),placeholder:e.__("Search…"),useFuzzyFilter:!1}),n.createElement(pt,{toggleSelectors:this.props.toggleSelectors,showSelectors:this.props.showSelectors,resetShortcuts:this.props.resetShortcuts,toggleAddCommandRow:this.props.toggleAddCommandRow,translator:this.props.translator})),n.createElement("div",{className:"jp-Shortcuts-HeaderRowContainer"},n.createElement("div",{className:"jp-Shortcuts-HeaderRow"},this.getShortCutTitleItem(e.__("Category"),"category"),this.getShortCutTitleItem(e.__("Command"),"command"),n.createElement("div",{className:"jp-Shortcuts-Cell"},n.createElement("div",{className:"title-div"},e.__("Shortcut"))),this.getShortCutTitleItem(e.__("Source"),"source"),this.props.showSelectors&&this.getShortCutTitleItem(e.__("Selectors"),"selector"))))}}class gt extends n.Component{constructor(e){super(e),this.updateSearchQuery=t=>{this.setState({searchQuery:t},()=>{const o=this.state.shortcutRegistry;this.setState({filteredShortcutList:this._searchFilterShortcuts(o)},()=>{this.sortShortcuts()})})},this.resetShortcuts=async()=>{await(await this.props.external.getSettings()).set("shortcuts",[]),await this._refreshShortcutList()},this.resetKeybindings=async t=>{await this._setKeybinding(t,[])},this.replaceKeybinding=async(t,o,s)=>this._setKeybinding(t,s,o),this.deleteKeybinding=async(t,o)=>{await this._setKeybinding(t,[],o)},this.addKeybinding=async(t,o)=>{await this._setKeybinding(t,o)},this.setCustomOptions=async(t,o)=>{var s;const r=await this.props.external.getSettings(),i=(s=r.user.shortcuts)!==null&&s!==void 0?s:[],a=i.filter(c=>{var g,p;return c.command===t.command&&c.selector===t.selector&&b.deepEqual((g=c.args)!==null&&g!==void 0?g:{},(p=t.args)!==null&&p!==void 0?p:{})});return a.length?(a.forEach(c=>{c.selector=o.selector,c.args=o.args}),await r.set("shortcuts",i),await this._refreshShortcutList(),!0):(console.error("Error writing the custom options: target not found"),!1)},this.toggleSelectors=()=>{this.setState({showSelectors:!this.state.showSelectors})},this.toggleAddCommandRow=async()=>{this.setState({showAddCommand:!this.state.showAddCommand})},this.updateSort=t=>{t!==this.state.currentSort&&this.setState({currentSort:t},this.sortShortcuts)},this.saveNewShortcut=async()=>{const t={...this.state.newShortcut,args:void 0};for(let s of t.keybindings)await this.addKeybinding(t,s.keys);await this.setCustomOptions(t,{selector:t.selector,args:this.state.newShortcut.args})&&(this._newShortcutItem.reset(),this.toggleAddCommandRow())},this._newShortcutItem=new it({showSelectors:!1,findConflictsFor:(t,o)=>this.state.shortcutRegistry?this.state.shortcutRegistry.findConflictsFor(t,o):(console.error("Cannot search for keybinding conflicts at this time: registry is not ready"),[]),external:this.props.external}),this.state={shortcutRegistry:null,filteredShortcutList:new Array,shortcutsFetched:!1,searchQuery:"",showSelectors:!1,currentSort:"category",showAddCommand:!1,newShortcut:this._newShortcutItem.shortcut},this._newShortcutItem.changed.connect(()=>{this.setState({newShortcut:{...this._newShortcutItem.shortcut}})})}componentDidMount(){this.props.external.actionRequested.connect(this._onActionRequested,this),this._refreshShortcutList()}componentWillUnmount(){this.props.external.actionRequested.disconnect(this._onActionRequested,this)}async _onActionRequested(e,t){if(t.request==="toggle-selectors")return this.toggleSelectors();t.request==="reset-all"&&await this.resetShortcuts()}async _refreshShortcutList(){const e=await this.props.external.getSettings(),t=new j({commandRegistry:this.props.external.commandRegistry,settings:e});this.setState({shortcutRegistry:t,filteredShortcutList:this._searchFilterShortcuts(t),shortcutsFetched:!0},()=>{this.sortShortcuts()})}_searchFilterShortcuts(e){return e?j.matchItems(e,this.state.searchQuery).map(o=>o.item):[]}async _setKeybinding(e,t,o){var s,r,i,a,c;t.length===1&&t[0]==""&&(t=[]);const g=t.map(w.normalizeKeystroke),p=await this.props.external.getSettings(),f=(s=p.user.shortcuts)!==null&&s!==void 0?s:[],d=[];let m=!1;for(let u of f)if(u.command===e.command&&u.selector===e.selector&&b.deepEqual((r=u.args)!==null&&r!==void 0?r:{},(i=e.args)!==null&&i!==void 0?i:{})&&o&&b.deepEqual(o.keys,w.normalizeKeys(u))){const y=o.isDefault&&b.deepEqual(o.keys,g);t.length!==0&&!y&&d.push(this._setShortcutKeys(u,t)),m=!0}else{if(u.command===e.command&&u.selector===e.selector&&b.deepEqual((a=u.args)!==null&&a!==void 0?a:{},(c=e.args)!==null&&c!==void 0?c:{})&&!o&&t.length===0)continue;d.push(u)}if(!m){const u=!o||!b.deepEqual(o.keys,g);o&&o.isDefault&&u&&d.push(this._shortcutFromTarget(e,o.keys,{disabled:!0,preventDefault:o.preventDefault})),t.length!==0&&u&&d.push(this._shortcutFromTarget(e,t,{preventDefault:o?.preventDefault}))}await p.set("shortcuts",d),await this._refreshShortcutList()}_setShortcutKeys(e,t){const o=this._platformKeys(e);return{...e,[o]:t}}_shortcutFromTarget(e,t,o={}){const s={command:e.command,selector:e.selector,keys:t};return e.args&&!b.deepEqual(e.args,{})&&(s.args=e.args),o.disabled&&(s.disabled=!0),o.preventDefault!==void 0&&(s.preventDefault=o.preventDefault),s}_platformKeys(e){return k.IS_WIN&&e.winKeys?"winKeys":k.IS_MAC&&e.macKeys?"macKeys":!k.IS_WIN&&!k.IS_MAC&&e.linuxKeys?"linuxKeys":"keys"}sortShortcuts(){const e=this.state.filteredShortcutList;let t=this.state.currentSort;t==="command"&&(t="label");const o=s=>{var r;return t==="source"?s.keybindings.every(i=>i.isDefault)?"default":"other":(r=s[t])!==null&&r!==void 0?r:""};e.sort((s,r)=>{var i,a;const c=o(s),g=o(r),p=c.localeCompare(g);if(p)return p;{const f=(i=s.label)!==null&&i!==void 0?i:"",d=(a=r.label)!==null&&a!==void 0?a:"";return f.localeCompare(d)}}),this.setState({filteredShortcutList:e})}render(){return this.state.shortcutsFetched?n.createElement("div",{className:"jp-Shortcuts-ShortcutUI",id:"jp-shortcutui"},n.createElement(mt,{updateSearchQuery:this.updateSearchQuery,resetShortcuts:this.resetShortcuts,toggleSelectors:this.toggleSelectors,showSelectors:this.state.showSelectors,updateSort:this.updateSort,currentSort:this.state.currentSort,toggleAddCommandRow:this.toggleAddCommandRow,width:this.props.width,translator:this.props.external.translator}),this.state.showAddCommand&&n.createElement(L,{...this._newShortcutItem,shortcut:this.state.newShortcut,newShortcutUtils:{searchQuery:this.state.searchQuery,updateCommand:this._newShortcutItem.updateCommand,saveShortcut:this.saveNewShortcut}}),n.createElement(ht,{shortcuts:this.state.filteredShortcutList,resetKeybindings:this.resetKeybindings,addKeybinding:this.addKeybinding,replaceKeybinding:this.replaceKeybinding,deleteKeybinding:this.deleteKeybinding,setCustomOptions:this.setCustomOptions,showSelectors:this.state.showSelectors,findConflictsFor:(e,t)=>this.state.shortcutRegistry?this.state.shortcutRegistry.findConflictsFor(e,t):(console.error("Cannot search for keybinding conflicts at this time: registry is not ready"),[]),height:this.props.height,external:this.props.external})):null}}const yt=l=>P.createElement(gt,{external:l.external,height:1e3,width:1e3}),T="@jupyterlab/shortcuts-extension:shortcuts";function ft(l,e,t,o,s){return{translator:t,getSettings:()=>l.load(T,!0),commandRegistry:e.commands,actionRequested:o,editorFactory:s}}const v={id:T,description:"Adds the keyboard shortcuts editor.",requires:[ot],optional:[V,st,G],activate:async(l,e,t,o,s)=>{const r=t??Y,i=r.load("jupyterlab"),{commands:a}=l;let c,g,p={};if(o){const d=new R({}),m=h=>h.dataset.shortcut!==void 0;l.commands.addCommand(C.editBinding,{label:i.__("Edit Keybinding"),caption:i.__("Edit existing keybinding"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const h=l.contextMenuHitTest(m),S=h?.dataset.keybinding,_=h?.dataset.shortcut;if(!_||!S)return console.log("Missing shortcut id/keybinding information");d.emit({request:"edit-keybinding",keybinding:parseInt(S,10),shortcutId:_})}}),l.commands.addCommand(C.deleteBinding,{label:i.__("Delete Keybinding"),caption:i.__("Delete chosen keybinding"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const h=l.contextMenuHitTest(m),S=h?.dataset.keybinding,_=h?.dataset.shortcut;if(!_||!S)return console.log("Missing shortcut id/keybinding information");d.emit({request:"delete-keybinding",keybinding:parseInt(S,10),shortcutId:_})}}),l.commands.addCommand(C.addBinding,{label:i.__("Add Keybinding"),caption:i.__("Add new keybinding for existing shortcut target"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const h=l.contextMenuHitTest(m),S=h?.dataset.shortcut;if(!S)return console.log("Missing shortcut id to add keybinding to");d.emit({request:"add-keybinding",shortcutId:S})}}),a.addCommand(C.toggleSelectors,{label:i.__("Toggle Selectors"),caption:i.__("Toggle command selectors"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{d.emit({request:"toggle-selectors"})}}),a.addCommand(C.resetAll,{label:i.__("Reset All"),caption:i.__("Reset all shortcuts"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{d.emit({request:"reset-all"})}});const u=s?h=>s.factoryService.newInlineEditor(h):void 0,y={fieldRenderer:h=>yt({external:ft(e,l,r,d,u),...h})};o.addRenderer(`${v.id}.shortcuts`,y)}function f(d){const m=l.commands.listCommands().join(`
|
|
2
2
|
`);g||(g=b.deepCopy(d.properties.shortcuts.default)),p={},d.properties.shortcuts.default=Object.keys(e.plugins).map(u=>{const y=e.plugins[u].schema["jupyter.lab.shortcuts"]||[];return p[u]=y,y}).concat([g]).reduce((u,y)=>k.IS_MAC?u.concat(y):u.concat(y.filter(h=>!h.keys.some(S=>{const{cmd:_}=w.parseKeystroke(S);return _}))),[]).sort((u,y)=>u.command.localeCompare(y.command)),d.properties.shortcuts.description=i.__(`Note: To disable a system default shortcut,
|
|
3
3
|
copy it to User Preferences and add the
|
|
4
4
|
"disabled" key, for example:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{T as De,q as he,t as ht,r as ce,b as $e,g as Je,I as pt,k as gt,a as ze,f as Ge,C as Re,h as Ie}from"./index--S8WFITA.js";import{J as M,aA as ee,cn as ie,aD as R,gr as mt,eG as Ct,fO as bt,cp as me,aJ as Te,ee as ft,cr as vt,ef as _t,cl as Ce,iq as yt,r as J,eM as xt,ii as wt,eK as kt,dz as Z,cv as St,ir as v,dK as Ye,dG as Xe,dL as Qe,fM as Ze,fN as et,eJ as Be,aI as At,aE as tt,aF as ke,is as Mt,it as Tt,ik as Bt,k as Y,bg as Et,gj as Nt,a9 as Ot,aB as be,gw as G,iu as ge,az as le,iv as xe,iw as Q,eD as Pe,ix as jt,iy as Rt,dU as we,dW as It,dY as Le,iz as We,dV as Pt,iA as Lt,iB as Wt,aw as ot,iC as Ht,iD as Ft,eI as Kt,iE as Vt,aC as F,et as fe,iF as Se,du as Ut,eB as qt,e0 as Dt,iG as $t,iH as se,iI as nt,ck as pe,dw as Jt,aG as zt,dB as Gt,cx as Yt,gu as Xt,iJ as Qt,dP as Zt,dS as eo,iK as to,dE as oo,iL as no,iM as io,ea as lo,eb as so,dv as ro,bf as ao,fh as co}from"../datalayer-app-main.js";import{b as uo,I as it}from"./token-d9po19EN.js";import{ToolbarItems as ho}from"./lib-aEdpLJmk.js";import{I as po}from"./index-CMhceBby.js";import{I as ve}from"./tokens-Dyd4wiX6.js";import{a as lt,I as L,b as st,c as go}from"./tokens-DiDi0Nkm.js";import{I as mo,a as rt}from"./tokens-DbNnxPrX.js";import{I as Co}from"./tokens-D1WVYIDT.js";import{f as at,e as bo,c as fo,I as vo,b as _o}from"./index-eH_desiS.js";import{I as dt}from"./tokens-B7nNzQEE.js";import{I as _e}from"./tokens-DY_UrMLq.js";import{a as Ee}from"./tokens-BYcJtuKD.js";import{I as yo}from"./tokens-Nkg3e_k9.js";import{I as xo}from"./index-6zxBQeM_.js";import{I as wo}from"./tokens-BcAeNU3z.js";import{W as ko,u as He,V as So,I as Ao,a as Mo,b as To,c as Bo}from"./document-CqNE0DPx.js";import{s as Eo}from"./hover-B3uFmZ-0.js";import{b as No,c as Oo,d as jo}from"./CellSidebarExtension-C6l8SYJ5.js";import{H as Ro}from"./htmlselect-CqXICb9e.js";import{T as Io,a as Po}from"./model-C2VRzh1c.js";import{C as Fe}from"./celltoolbartracker-BHSFiiuz.js";import"./hoverbox-CStlKQWE.js";import"./Output-BfmeU6C2.js";import"./index-BKAeSGYJ.js";import"./dayjs.min-u3zuoSR8.js";import"./isEqual-BYxXubsX.js";import"./d3-color-Jd8hXty2.js";import"./dist-BrUAt6vF.js";import"./KebabHorizontalIcon-D6AY8pIS.js";import"./PaintbrushIcon-CFBHU-3l.js";import"./index-CqP3xLL5.js";import"./RestartIcon-DvpOf5Mf.js";import"./NotebookSkeleton-BkzTMhIX.js";import"./Avatar-MNx1kN3F.js";import"./renderer-D_wPFwb6.js";import"./SquareIcon-Dy3l3VdH.js";import"./FileDirectoryOpenFillIcon-jGhuRcP3.js";import"./url-C6fJII94.js";/* empty css *//* empty css */import"./style-DdAxk_bj.js";/* empty css */import"./style-Cj1gzCjo.js";/* empty css */import"./style-rkw8dR9f.js";import"./style-GHJFdtIz.js";import"./style-ZSIOeMoX.js";import"./style-iVfD6mFL.js";import"./style-DA-Ya7rp.js";import"./style-D3tvWcFO.js";import"./style-BOqStzF9.js";import"./style-ADLQJ-E9.js";import"./style-DgglluaK.js";import"./ArrowLeftIcon-sX3iNMG1.js";import"./SkubbleIcon-CAaVh_BE.js";import"./usePrimerThemeBridge-DyX4EYyN.js";import"./index-BbcMy3Al.js";import"./KernelVariables-CyPoY7Ap.js";import"./index-C0d-d3s4.js";import"./SortAscIcon-CmH04s3F.js";import"./SortDescIcon-Qif6E10I.js";import"./NotebookToolbar-BMjQTGrr.js";import"./RepoPushIcon-BtXQRhLa.js";import"./Toolbar-BncUh2ly.js";import"./sessions-CgjtuOSm.js";import"./tokens-CBhRbpQP.js";import"./drivecontents-D1HzL7Fi.js";import"./kernel-BmfZmtIo.js";function Lo(r){const n=s=>{const a=Math.max(s*3.6,.1),l=a*Math.PI/180,p=Math.sin(l)*104,i=Math.cos(l)*-104;return"M 0 0 v -104 A 104 104 1 "+(a<180?1:0)+" 0 "+p.toFixed(4)+" "+i.toFixed(4)+" z"};return M.createElement("div",{className:"jp-Statusbar-ProgressCircle",role:"progressbar","aria-label":r.label||"Unlabelled progress circle","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r.progress,onClick:r.onClick},M.createElement("svg",{viewBox:"0 0 250 250"},M.createElement("circle",{cx:"125",cy:"125",r:"104",stroke:"var(--jp-inverse-layout-color3)",strokeWidth:"20",fill:"none"}),M.createElement("path",{className:"jp-Statusbar-ProgressCirclePath",transform:"translate(125,125) scale(.9)",d:n(r.progress),fill:"var(--jp-inverse-layout-color3)"})))}const Wo="jp-JSONEditor",ue="jp-mod-error",Ho="jp-JSONEditor-host",Fo="jp-JSONEditor-header";class Ko extends ee{constructor(e){super(),this._dataDirty=!1,this._inputDirty=!1,this._source=null,this._originalValue=ie.emptyObject,this._changeGuard=!1,this.translator=e.translator||R,this._trans=this.translator.load("jupyterlab"),this.addClass(Wo),this.headerNode=document.createElement("div"),this.headerNode.className=Fo,this.revertButtonNode=mt.element({tag:"span",title:this._trans.__("Revert changes to data")}),this.commitButtonNode=Ct.element({tag:"span",title:this._trans.__("Commit changes to data"),marginLeft:"8px"}),this.editorHostNode=document.createElement("div"),this.editorHostNode.className=Ho,this.headerNode.appendChild(this.revertButtonNode),this.headerNode.appendChild(this.commitButtonNode),this.node.appendChild(this.headerNode),this.node.appendChild(this.editorHostNode);const n=new bt.Model({mimeType:"application/json"});n.sharedModel.changed.connect(this._onModelChanged,this),this.model=n,this.editor=e.editorFactory({host:this.editorHostNode,model:n,config:{readOnly:!0}})}get source(){return this._source}set source(e){this._source!==e&&(this._source&&this._source.changed.disconnect(this._onSourceChanged,this),this._source=e,this.editor.setOption("readOnly",e===null),e&&e.changed.connect(this._onSourceChanged,this),this._setValue())}get isDirty(){return this._dataDirty||this._inputDirty}dispose(){var e;this.isDisposed||((e=this.source)===null||e===void 0||e.dispose(),this.model.dispose(),this.editor.dispose(),super.dispose())}handleEvent(e){switch(e.type){case"blur":this._evtBlur(e);break;case"click":this._evtClick(e);break}}onAfterAttach(e){const n=this.editorHostNode;n.addEventListener("blur",this,!0),n.addEventListener("click",this,!0),this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.headerNode.addEventListener("click",this)}onBeforeDetach(e){const n=this.editorHostNode;n.removeEventListener("blur",this,!0),n.removeEventListener("click",this,!0),this.headerNode.removeEventListener("click",this)}_onSourceChanged(e,n){if(!this._changeGuard){if(this._inputDirty||this.editor.hasFocus()){this._dataDirty=!0;return}this._setValue()}}_onModelChanged(e,n){if(n.sourceChange){let s=!0;try{const a=JSON.parse(this.editor.model.sharedModel.getSource());this.removeClass(ue),this._inputDirty=!this._changeGuard&&!ie.deepEqual(a,this._originalValue)}catch{this.addClass(ue),this._inputDirty=!0,s=!1}this.revertButtonNode.hidden=!this._inputDirty,this.commitButtonNode.hidden=!s||!this._inputDirty}}_evtBlur(e){!this._inputDirty&&this._dataDirty&&this._setValue()}_evtClick(e){const n=e.target;this.revertButtonNode.contains(n)?this._setValue():this.commitButtonNode.contains(n)?!this.commitButtonNode.hidden&&!this.hasClass(ue)&&(this._changeGuard=!0,this._mergeContent(),this._changeGuard=!1,this._setValue()):this.editorHostNode.contains(n)&&this.editor.focus()}_mergeContent(){const e=this.editor.model,n=this._originalValue,s=JSON.parse(e.sharedModel.getSource()),a=this.source;if(a){for(const l in s)ie.deepEqual(s[l],n[l]||null)||a.set(l,s[l]);for(const l in n)l in s||a.delete(l)}}_setValue(){this._dataDirty=!1,this._inputDirty=!1,this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.removeClass(ue);const e=this.editor.model,n=this._source?this._source.toJSON():{};if(this._changeGuard=!0,n===void 0)e.sharedModel.setSource(this._trans.__("No data!")),this._originalValue=ie.emptyObject;else{const s=JSON.stringify(n,null,4);e.sharedModel.setSource(s),this._originalValue=n,s.length>1&&s[0]==="{"&&this.editor.setCursorPosition({line:0,column:1})}this._changeGuard=!1,this.commitButtonNode.hidden=!0,this.revertButtonNode.hidden=!0}}class Vo extends M.Component{constructor(e){super(e),this._handleChange=s=>{this.setState({value:s.currentTarget.value})},this._handleSubmit=s=>{var a,l;s.preventDefault();const p=parseInt((l=(a=this._textInput)===null||a===void 0?void 0:a.value)!==null&&l!==void 0?l:"",10);return!isNaN(p)&&isFinite(p)&&1<=p&&p<=this.props.maxCell&&this.props.handleSubmit(p),!1},this._handleFocus=()=>{this.setState({hasFocus:!0})},this._handleBlur=()=>{this.setState({hasFocus:!1})},this._textInput=null;const n=e.translator||R;this._trans=n.load("jupyterlab"),this.state={value:"",hasFocus:!1,textInputId:ft.createDomID()+"-cell-number-input"}}componentDidMount(){var e;(e=this._textInput)===null||e===void 0||e.focus()}render(){return M.createElement("div",{className:"jp-lineFormSearch"},M.createElement("form",{name:"cellNumberForm",onSubmit:this._handleSubmit,noValidate:!0},M.createElement("div",{className:vt("jp-lineFormWrapper","lm-lineForm-wrapper",this.state.hasFocus?"jp-lineFormWrapperFocusWithin":void 0)},M.createElement("input",{type:"number",id:this.state.textInputId,className:"jp-lineFormInput",min:1,max:this.props.maxCell,onChange:this._handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur,value:this.state.value,ref:e=>{this._textInput=e}}),M.createElement("div",{className:"jp-baseLineForm jp-lineFormButtonContainer"},M.createElement(_t.react,{className:"jp-baseLineForm jp-lineFormButtonIcon",elementPosition:"center"}),M.createElement("input",{type:"submit",className:"jp-baseLineForm jp-lineFormButton",value:""}))),M.createElement("label",{className:"jp-lineFormCaption",htmlFor:this.state.textInputId},this._trans.__("Go to cell number between 1 and %1",this.props.maxCell))))}}function Uo(r){const n=(r.translator||R).load("jupyterlab"),s=r.selectionStart>0&&r.selectionStart!==r.selectionEnd?n.__("%1:%2/%3",r.selectionStart,r.selectionEnd,r.totalCells):n.__("Cell %1/%2",r.activeCell,r.totalCells),a=l=>{(l.key==="Enter"||l.key==="Spacebar"||l.key===" ")&&(l.preventDefault(),l.stopPropagation(),r.handleClick())};return M.createElement(De,{role:"button","aria-haspopup":!0,onClick:r.handleClick,source:s,title:n.__("Go to cell…"),tabIndex:0,onKeyDown:a})}class re extends me{constructor(e={}){super(new re.Model),this._popup=null,this.addClass("jp-mod-highlighted"),this._translator=e.translator||R}render(){return this.model===null?null:M.createElement(Uo,{activeCell:this.model.activeCell,selectionStart:this.model.selectionStart,selectionEnd:this.model.selectionEnd,totalCells:this.model.totalCells,translator:this._translator,handleClick:()=>this._handleClick()})}_handleClick(){if(this.model.totalCells<1)return;this._popup&&this._popup.dispose();const e=Te.create(M.createElement(Vo,{handleSubmit:n=>this._handleSubmit(n),maxCell:this.model.totalCells,translator:this._translator}));this._popup=Eo({body:e,anchor:this,align:"right"})}_handleSubmit(e){var n;const s=this.model.notebook;if(!s)return;const a=e-1;s.activeCellIndex=a,s.deselectAll(),s.scrollToItem(a).catch(l=>{console.error("Go to cell",l)}),(n=this._popup)===null||n===void 0||n.dispose(),s.activate()}}(function(r){class e extends Ce{constructor(){super(...arguments),this._activeCell=0,this._selectionStart=0,this._selectionEnd=0,this._totalCells=0,this._notebook=null}get notebook(){return this._notebook}set notebook(s){const a=this._notebook;a&&(a.activeCellChanged.disconnect(this._onChanged,this),a.modelContentChanged.disconnect(this._onChanged,this),a.selectionChanged.disconnect(this._onChanged,this));const l=this._getAllState();this._notebook=s,this._notebook?(this._notebook.activeCellChanged.connect(this._onChanged,this),this._notebook.modelContentChanged.connect(this._onChanged,this),this._notebook.selectionChanged.connect(this._onChanged,this),this._updateStateFromNotebook(this._notebook)):(this._activeCell=0,this._selectionStart=0,this._selectionEnd=0,this._totalCells=0),this._triggerChange(l,this._getAllState())}get activeCell(){return this._activeCell}get selectionStart(){return this._selectionStart}get selectionEnd(){return this._selectionEnd}get totalCells(){return this._totalCells}_onChanged(s){const a=this._getAllState();this._updateStateFromNotebook(s),this._triggerChange(a,this._getAllState())}_updateStateFromNotebook(s){const a=s.activeCellIndex;this._activeCell=a>=0?a+1:0,this._totalCells=s.widgets.length;let l=this._activeCell,p=this._activeCell,i=!1;s.widgets.forEach((u,d)=>{if(!s.isSelectedOrActive(u))return;const g=d+1;if(!i){l=g,p=g,i=!0;return}p=g}),this._selectionStart=i?l:0,this._selectionEnd=i?p:0}_getAllState(){return{activeCell:this._activeCell,selectionStart:this._selectionStart,selectionEnd:this._selectionEnd,totalCells:this._totalCells}}_triggerChange(s,a){(s.activeCell!==a.activeCell||s.selectionStart!==a.selectionStart||s.selectionEnd!==a.selectionEnd||s.totalCells!==a.totalCells)&&this.stateChanged.emit(void 0)}}r.Model=e})(re||(re={}));const qo="jp-Notebook-toolbarCellType",Do="jp-Notebook-toolbarCellTypeDropdown";var Ae;(function(r){function e(g,b){const f=(b||R).load("jupyterlab");function _(){if(g.context.model.readOnly)return tt({title:f.__("Cannot Save"),body:f.__("Document is read-only"),buttons:[ke.okButton()]});g.context.save().then(()=>{if(!g.isDisposed)return g.context.createCheckpoint()})}return yt(Te.create(J.createElement(xt,{signal:g.context.fileChanged},()=>J.createElement(wt,{icon:kt,onClick:_,tooltip:f.__("Save the notebook contents and create checkpoint"),enabled:!!(g&&g.context&&g.context.contentsModel&&g.context.contentsModel.writable)}))))}r.createSaveButton=e;function n(g,b){const f=(b||R).load("jupyterlab");return new Z({icon:St,onClick:()=>{v.insertBelow(g.content)},tooltip:f.__("Insert a cell below")})}r.createInsertButton=n;function s(g,b,f){const _=(b||R).load("jupyterlab");return new Z({icon:Ye,onClick:async()=>{f?.get("useSystemClipboardForCells").composite?await v.cutToSystemClipboard(g.content):v.cut(g.content)},tooltip:_.__("Cut the selected cells")})}r.createCutButton=s;function a(g,b,f){const _=(b||R).load("jupyterlab");return new Z({icon:Xe,onClick:async()=>{f?.get("useSystemClipboardForCells").composite?await v.copyToSystemClipboard(g.content):v.copy(g.content)},tooltip:_.__("Copy the selected cells")})}r.createCopyButton=a;function l(g,b,f){const _=(b||R).load("jupyterlab");return new Z({icon:Qe,onClick:async()=>{f?.get("useSystemClipboardForCells").composite?await v.pasteFromSystemClipboard(g.content):v.paste(g.content)},tooltip:_.__("Paste cells from the clipboard")})}r.createPasteButton=l;function p(g,b,f){const _=(f??R).load("jupyterlab");return new Z({icon:Ze,onClick:()=>{v.runAndAdvance(g.content,g.sessionContext,b,f)},tooltip:_.__("Run the selected cells and advance")})}r.createRunButton=p;function i(g,b,f){const _=(f??R).load("jupyterlab");return new Z({icon:et,onClick:()=>{const y=b??new Be({translator:f});y.restart(g.sessionContext).then(w=>(w&&v.runAll(g.content,g.sessionContext,y,f),w))},tooltip:_.__("Restart the kernel, then re-run the whole notebook")})}r.createRestartRunAllButton=i;function u(g,b){return new $o(g.content,b)}r.createCellTypeItem=u;function d(g,b,f,_){return[{name:"save",widget:e(g,f)},{name:"insert",widget:n(g,f)},{name:"cut",widget:s(g,f,_)},{name:"copy",widget:a(g,f,_)},{name:"paste",widget:l(g,f,_)},{name:"run",widget:p(g,b,f)},{name:"interrupt",widget:he.createInterruptButton(g.sessionContext,f)},{name:"restart",widget:he.createRestartButton(g.sessionContext,b,f)},{name:"restart-and-run",widget:i(g,b,f)},{name:"cellType",widget:u(g,f)},{name:"spacer",widget:At.createSpacerItem()},{name:"kernelName",widget:he.createKernelNameItem(g.sessionContext,b,f)}]}r.getDefaultItems=d})(Ae||(Ae={}));class $o extends Te{constructor(e,n){super(),this.handleChange=s=>{s.target.value!=="-"&&(v.changeCellType(this._notebook,s.target.value),this._notebook.activate())},this.handleKeyDown=s=>{s.key==="Enter"&&this._notebook.activate()},this._trans=(n||R).load("jupyterlab"),this.addClass(qo),this._notebook=e,e.model&&this.update(),e.activeCellChanged.connect(this.update,this),e.selectionChanged.connect(this.update,this)}render(){let e="-";this._notebook.activeCell&&(e=this._notebook.activeCell.model.type);for(const n of this._notebook.widgets)if(this._notebook.isSelectedOrActive(n)&&n.model.type!==e){e="-";break}return J.createElement(Ro,{className:Do,onChange:this.handleChange,onKeyDown:this.handleKeyDown,value:e,"aria-label":this._trans.__("Cell type"),title:this._trans.__("Select the cell type")},J.createElement("option",{value:"-"},"-"),J.createElement("option",{value:"code"},this._trans.__("Code")),J.createElement("option",{value:"markdown"},this._trans.__("Markdown")),J.createElement("option",{value:"raw"},this._trans.__("Raw")))}}function Ke(r){var e;const n=r.translator||R,s=ht(n),a=n.load("jupyterlab"),l=(e=r.displayOption.showJumpToCell)!==null&&e!==void 0?e:!1,p=r.state,i=r.displayOption.showOnToolBar,u=r.displayOption.showProgress,d=i?"down":"up",g=M.createElement("div",null),[b,f]=M.useState(!1);if(M.useEffect(()=>{if(b)return;const j=()=>{f(!0)};return v.executionScheduled.connect(j),()=>{v.executionScheduled.disconnect(j)}},[l,b]),!p)return g;const _=p.kernelStatus,y={alignSelf:"normal",height:"24px"},w=p.totalTime,S=p.scheduledCellNumber||0,o=p.scheduledCell.size||0,t=S-o;let h=100*t/S,C=u?"":"hidden";!u&&h<100&&(h=0);const k=j=>M.createElement(Lo,{progress:j,width:16,height:24,label:a.__("Kernel status")}),A=j=>a.__("Kernel status: %1",j),B=()=>{const j=r.notebook;v.selectLastRunCell(j),j.activeCell&&j.scrollToCell(j.activeCell)},E=(j,K,W)=>M.createElement("div",{className:"jp-Notebook-ExecutionIndicator",title:u?"":A(s[j]),"data-status":j},K,M.createElement("div",{className:`jp-Notebook-ExecutionIndicator-tooltip ${d} ${C}`},M.createElement("span",null," ",A(s[j])," "),W,l&&b&&M.createElement(Bt,{className:"jp-Notebook-ExecutionIndicator-jumpButton",onClick:B,title:a.__("Jump to current or last executed cell")},a.__("Jump to cell"))));if(p.kernelStatus==="connecting"||p.kernelStatus==="disconnected"||p.kernelStatus==="unknown")return E(_,M.createElement(Mt.react,{...y}),[]);if(p.kernelStatus==="starting"||p.kernelStatus==="terminating"||p.kernelStatus==="restarting"||p.kernelStatus==="initializing")return E(_,M.createElement(Tt.react,{...y}),[]);if(p.executionStatus==="busy")return E("busy",k(h),[M.createElement("span",{key:0},a.__("Executed %1/%2 cells",t,S)),M.createElement("span",{key:1},a._n("Elapsed time: %1 second","Elapsed time: %1 seconds",w))]);{const j=p.kernelStatus==="busy"?0:100,K=p.kernelStatus==="busy"||w===0?[]:[M.createElement("span",{key:0},a._n("Executed %1 cell","Executed %1 cells",S)),M.createElement("span",{key:1},a._n("Elapsed time: %1 second","Elapsed time: %1 seconds",w))];return E(p.kernelStatus,k(j),K)}}class X extends me{constructor(e,n=!0){super(new X.Model),this.translator=e||R,this.addClass("jp-mod-highlighted")}dispose(){var e;this.isDisposed||((e=this.model)===null||e===void 0||e.dispose(),super.dispose())}render(){if(this.model===null||!this.model.renderFlag)return M.createElement("div",null);{const e=this.model.currentNotebook;return e?M.createElement(Ke,{displayOption:this.model.displayOption,state:this.model.executionState(e),translator:this.translator,notebook:e}):M.createElement(Ke,{displayOption:this.model.displayOption,state:void 0,translator:this.translator,notebook:void 0})}}}(function(r){class e extends Ce{constructor(){super(),this._notebookExecutionProgress=new WeakMap,this._displayOption={showOnToolBar:!0,showProgress:!0,showJumpToCell:!1},this._renderFlag=!0}attachNotebook(l){var p,i,u,d;if(l&&l.content&&l.context){const g=l.content,b=l.context;if(this._currentNotebook=g,!this._notebookExecutionProgress.has(g)){this._notebookExecutionProgress.set(g,{executionStatus:"idle",kernelStatus:"idle",totalTime:0,interval:0,timeout:0,scheduledCell:new Set,scheduledCellNumber:0,needReset:!0});const f=this._notebookExecutionProgress.get(g),_=o=>{f&&(f.kernelStatus=o.kernelDisplayStatus),this.stateChanged.emit(void 0)};b.statusChanged.connect(_,this);const y=o=>{f&&(f.kernelStatus=o.kernelDisplayStatus),this.stateChanged.emit(void 0)};b.connectionStatusChanged.connect(y,this),b.disposed.connect(o=>{o.connectionStatusChanged.disconnect(y,this),o.statusChanged.disconnect(_,this)},this);const w=(o,t)=>{const h=t.msg,C=h.header.msg_id;if(h.header.msg_type==="execute_request")this._cellScheduledCallback(g,C);else if(Y.KernelMessage.isStatusMsg(h)&&h.content.execution_state==="idle"){const k=h.parent_header.msg_id;this._cellExecutedCallback(g,k)}else Y.KernelMessage.isStatusMsg(h)&&h.content.execution_state==="restarting"?this._restartHandler(g):h.header.msg_type==="execute_input"&&this._startTimer(g)};(i=(p=b.session)===null||p===void 0?void 0:p.kernel)===null||i===void 0||i.anyMessage.connect(w,this),(d=(u=b.session)===null||u===void 0?void 0:u.kernel)===null||d===void 0||d.disposed.connect(o=>o.anyMessage.disconnect(w,this),this);const S=(o,t)=>{f&&(this._resetTime(f),this.stateChanged.emit(void 0),t.newValue&&t.newValue.anyMessage.connect(w,this))};b.kernelChanged.connect(S,this),b.disposed.connect(o=>o.kernelChanged.disconnect(S,this),this)}}}get currentNotebook(){return this._currentNotebook}get displayOption(){return this._displayOption}set displayOption(l){this._displayOption=l}executionState(l){return this._notebookExecutionProgress.get(l)}_scheduleSwitchToIdle(l){window.setTimeout(()=>{l.executionStatus="idle",clearInterval(l.interval),this.stateChanged.emit(void 0)},150),l.timeout=window.setTimeout(()=>{l.needReset=!0},1e3)}_cellExecutedCallback(l,p){const i=this._notebookExecutionProgress.get(l);i&&i.scheduledCell.has(p)&&(i.scheduledCell.delete(p),i.scheduledCell.size===0&&this._scheduleSwitchToIdle(i))}_restartHandler(l){const p=this._notebookExecutionProgress.get(l);p&&(p.scheduledCell.clear(),this._scheduleSwitchToIdle(p))}_startTimer(l){const p=this._notebookExecutionProgress.get(l);p&&(p.scheduledCell.size>0?p.executionStatus!=="busy"&&(p.executionStatus="busy",clearTimeout(p.timeout),this.stateChanged.emit(void 0),p.interval=window.setInterval(()=>{this._tick(p)},1e3)):this._resetTime(p))}_cellScheduledCallback(l,p){const i=this._notebookExecutionProgress.get(l);i&&!i.scheduledCell.has(p)&&(i.needReset&&this._resetTime(i),i.scheduledCell.add(p),i.scheduledCellNumber+=1)}_tick(l){if(this.isDisposed){clearInterval(l.interval),clearTimeout(l.timeout);return}l.totalTime+=1,this.stateChanged.emit(void 0)}_resetTime(l){l.totalTime=0,l.scheduledCellNumber=0,l.executionStatus="idle",l.scheduledCell=new Set,clearTimeout(l.timeout),clearInterval(l.interval),l.needReset=!1}get renderFlag(){return this._renderFlag}updateRenderOption(l){this.displayOption.showOnToolBar&&(l.showOnToolBar?this._renderFlag=!0:this._renderFlag=!1),this.displayOption.showProgress=l.showProgress,this.displayOption.showJumpToCell=l.showJumpToCell,this.stateChanged.emit(void 0)}}r.Model=e;function n(a,l,p){const i=new r(l);return i.model.displayOption={showOnToolBar:!0,showProgress:!0,showJumpToCell:!1},i.model.attachNotebook({content:a.content,context:a.sessionContext}),p&&p.then(u=>{const d=g=>{const b=s(g);b.showJumpToCell&&(g.get("recordTiming").composite||g.set("recordTiming",!0).catch(_=>{console.error("Failed to auto-enable recordTiming:",_.message)})),i.model.updateRenderOption(b)};u.changed.connect(d),d(u),i.disposed.connect(()=>{u.changed.disconnect(d)})}).catch(u=>{console.error(u.message)}),i}r.createExecutionIndicatorItem=n;function s(a){let l=!0,p=!0,i=!1;const u=a.get("kernelStatus").composite;return u&&(l=!u.showOnStatusBar,p=u.showProgress,i=u.showJumpToRecentExecutionButton),{showOnToolBar:l,showProgress:p,showJumpToCell:i}}r.getSettingValue=s})(X||(X={}));function Jo(r){const e=(r.translator||R).load("jupyterlab");return J.createElement(De,{source:e.__("Mode: %1",r.modeNames[r.notebookMode])})}class ae extends me{constructor(e){super(new ae.Model),this.translator=e||R,this._trans=this.translator.load("jupyterlab"),this._modeNames={command:this._trans.__("Command"),edit:this._trans.__("Edit")}}render(){return this.model?(this.node.title=this._trans.__("Notebook is in %1 mode",this._modeNames[this.model.notebookMode]),J.createElement(Jo,{notebookMode:this.model.notebookMode,translator:this.translator,modeNames:this._modeNames})):null}}(function(r){class e extends Ce{constructor(){super(...arguments),this._onChanged=s=>{const a=this._notebookMode;this._notebook?this._notebookMode=s.mode:this._notebookMode="command",this._triggerChange(a,this._notebookMode)},this._notebookMode="command",this._notebook=null}get notebookMode(){return this._notebookMode}set notebook(s){const a=this._notebook;a!==null&&(a.stateChanged.disconnect(this._onChanged,this),a.activeCellChanged.disconnect(this._onChanged,this),a.modelContentChanged.disconnect(this._onChanged,this));const l=this._notebookMode;this._notebook=s,this._notebook===null?this._notebookMode="command":(this._notebookMode=this._notebook.mode,this._notebook.stateChanged.connect(this._onChanged,this),this._notebook.activeCellChanged.connect(this._onChanged,this),this._notebook.modelContentChanged.connect(this._onChanged,this)),this._triggerChange(l,this._notebookMode)}_triggerChange(s,a){s!==a&&this.stateChanged.emit(void 0)}}r.Model=e})(ae||(ae={}));class zo extends ko{constructor(e,n){super(e,n),this.editorWidget=e,this.options=n,this._type="code",this._readyDelegate=new Et,this._editorToCell=new Map,this.editor=e.content,this._cellToEditor=new WeakMap,this.isReady=this.isReady.bind(this),Promise.all([this.widget.context.sessionContext.ready,this.connectionManager.ready]).then(async()=>{await this.initOnceReady(),this._readyDelegate.resolve()}).catch(console.error)}get documentPath(){return this.widget.context.path}get mimeType(){var e;let n,s=this.language_info();return!s||!s.mimetype?n=this.widget.content.codeMimetype:n=s.mimetype,Array.isArray(n)?(e=n[0])!==null&&e!==void 0?e:Nt.defaultMimeType:n}get languageFileExtension(){let e=this.language_info();if(!(!e||!e.file_extension))return e.file_extension.replace(".","")}get wrapperElement(){return this.widget.node}get editors(){if(this.isDisposed)return[];let e=this.widget.content;return this._editorToCell.clear(),e.isDisposed?[]:e.widgets.map(n=>({ceEditor:this._getCellEditor(n),type:n.model.type,value:n.model.sharedModel.getSource()}))}get activeEditor(){return this.editor.activeCell?this._getCellEditor(this.editor.activeCell):void 0}get ready(){return this._readyDelegate.promise}getEditorIndexAt(e){let n=this._getCellAt(e);return this.widget.content.widgets.findIndex(a=>n===a)}getEditorIndex(e){let n=this._editorToCell.get(e);return this.editor.widgets.findIndex(s=>n===s)}getEditorWrapper(e){return this._editorToCell.get(e).node}async onKernelChanged(e,n){if(n.newValue)try{const s=this._languageInfo;await He(this.isReady,-1),await this._updateLanguageInfo();const a=this._languageInfo;s?.name!=a.name||s?.mimetype!=a?.mimetype||s?.file_extension!=a?.file_extension?(console.log(`Changed to ${this._languageInfo.name} kernel, reconnecting`),this.reloadConnection()):console.log("Keeping old LSP connection as the new kernel uses the same language")}catch(s){console.warn(s),this.reloadConnection()}}dispose(){this.isDisposed||(this.widget.context.sessionContext.kernelChanged.disconnect(this.onKernelChanged,this),this.widget.content.activeCellChanged.disconnect(this._activeCellChanged,this),super.dispose(),this._editorToCell.clear(),Ot.clearData(this))}isReady(){var e;return!this.widget.isDisposed&&this.widget.context.isReady&&this.widget.content.isVisible&&this.widget.content.widgets.length>0&&((e=this.widget.context.sessionContext.session)===null||e===void 0?void 0:e.kernel)!=null}async handleCellChange(e,n){let s=[],a=[];const l=this._type;if(n.type==="set"){let p=[],i=[];if(n.newValues.length===n.oldValues.length){for(let u=0;u<n.newValues.length;u++)n.oldValues[u].type===l&&n.newValues[u].type!==l?p.push(n.newValues[u]):n.oldValues[u].type!==l&&n.newValues[u].type===l&&i.push(n.newValues[u]);s=i,a=p}}else n.type=="add"&&(s=n.newValues.filter(p=>p.type===l));(a.length||s.length||n.type==="set"||n.type==="move"||n.type==="remove"||n.type==="clear")&&await this.updateDocuments();for(let p of s){let i=this.widget.content.widgets.find(u=>u.model.id===p.id);if(!i){console.warn(`Widget for added cell with ID: ${p.id} not found!`);continue}this._getCellEditor(i)}}createVirtualDocument(){return new So({language:this.language,foreignCodeExtractors:this.options.foreignCodeExtractorsManager,path:this.documentPath,fileExtension:this.languageFileExtension,standalone:!1,hasLspSupportedFile:!1})}language_info(){return this._languageInfo}async initOnceReady(){await He(this.isReady.bind(this),-1),await this._updateLanguageInfo(),this.initVirtual(),this.connectDocument(this.virtualDocument,!1).catch(console.warn),this.widget.context.sessionContext.kernelChanged.connect(this.onKernelChanged,this),this.widget.content.activeCellChanged.connect(this._activeCellChanged,this),this._connectModelSignals(this.widget),this.editor.modelChanged.connect(e=>{console.warn("Model changed, connecting cell change handler; this is not something we were expecting"),this._connectModelSignals(e)})}_connectModelSignals(e){e.model===null?console.warn(`Model is missing for notebook ${e}, cannot connect cell changed signal!`):e.model.cells.changed.connect(this.handleCellChange,this)}async _updateLanguageInfo(){var e,n,s,a;const l=(a=await((s=(n=(e=this.widget.context.sessionContext)===null||e===void 0?void 0:e.session)===null||n===void 0?void 0:n.kernel)===null||s===void 0?void 0:s.info))===null||a===void 0?void 0:a.language_info;if(l)this._languageInfo=l;else throw new Error("Language info update failed (no session, kernel, or info available)")}_activeCellChanged(e,n){!n||n.model.type!==this._type||this._activeEditorChanged.emit({editor:this._getCellEditor(n)})}_getCellAt(e){let n=this.virtualDocument.getEditorAtVirtualLine(e);return this._editorToCell.get(n)}_getCellEditor(e){if(!this._cellToEditor.has(e)){const n=Object.freeze({getEditor:()=>e.editor,ready:async()=>(await e.ready,e.editor),reveal:async()=>(await this.editor.scrollToCell(e),e.editor)});this._cellToEditor.set(e,n),this._editorToCell.set(n,e),e.disposed.connect(()=>{this._cellToEditor.delete(e),this._editorToCell.delete(n),this._editorRemoved.emit({editor:n})}),this._editorAdded.emit({editor:n})}return this._cellToEditor.get(e)}}class Go extends ee{constructor(){super(),this._items=[],this.layout=new be,this.addClass("jp-RankedPanel")}addWidget(e,n){const s={widget:e,rank:n},a=le.upperBound(this._items,s,Me.itemCmp);le.insert(this._items,a,s),this.layout.insertWidget(a,e)}onChildRemoved(e){const n=le.findFirstIndex(this._items,s=>s.widget===e.child);n!==-1&&le.removeAt(this._items,n)}}class q extends ee{constructor(e){super(),this.addClass("jp-NotebookTools"),this.translator=e.translator||R,this._tools=[],this.layout=new be,this._tracker=e.tracker,this._tracker.currentChanged.connect(this._onActiveNotebookPanelChanged,this),this._tracker.activeCellChanged.connect(this._onActiveCellChanged,this),this._tracker.selectionChanged.connect(this._onSelectionChanged,this),this._onActiveNotebookPanelChanged(),this._onActiveCellChanged(),this._onSelectionChanged()}get activeCell(){return this._tracker.activeCell}get selectedCells(){const e=this._tracker.currentWidget;if(!e)return[];const n=e.content;return n.widgets.filter(s=>n.isSelectedOrActive(s))}get activeNotebookPanel(){return this._tracker.currentWidget}addItem(e){var n;const s=e.tool,a=(n=e.rank)!==null&&n!==void 0?n:100;let l;const p=this._tools.find(i=>i.section===e.section);if(p)l=p.panel;else throw new Error(`The section ${e.section} does not exist`);s.addClass("jp-NotebookTools-tool"),l.addWidget(s,a),s.notebookTools=this,G.sendMessage(s,q.ActiveNotebookPanelMessage),G.sendMessage(s,q.ActiveCellMessage)}addSection(e){var n;const s=e.sectionName,a=e.label||e.sectionName,l=e.tool;let p=(n=e.rank)!==null&&n!==void 0?n:null;const i=new Go;if(i.title.label=a,l&&i.addWidget(l,0),this._tools.push({section:s,panel:i,rank:p}),p!=null)this.layout.insertWidget(p,new ce({widget:i}));else{let u=null;const d=this.layout;for(let g=0;g<d.widgets.length;g++){let b=d.widgets[g];if(b instanceof ce&&b.widget.id==="advancedToolsSection"){u=g;break}}u!==null?this.layout.insertWidget(u,new ce({widget:i})):this.layout.addWidget(new ce({widget:i}))}}_onActiveNotebookPanelChanged(){this._prevActiveNotebookModel&&!this._prevActiveNotebookModel.isDisposed&&this._prevActiveNotebookModel.metadataChanged.disconnect(this._onActiveNotebookPanelMetadataChanged,this);const e=this.activeNotebookPanel&&this.activeNotebookPanel.content?this.activeNotebookPanel.content.model:null;this._prevActiveNotebookModel=e,e&&e.metadataChanged.connect(this._onActiveNotebookPanelMetadataChanged,this);for(const n of this._toolChildren())G.sendMessage(n,q.ActiveNotebookPanelMessage)}_onActiveCellChanged(){this._prevActiveCell&&!this._prevActiveCell.isDisposed&&this._prevActiveCell.metadataChanged.disconnect(this._onActiveCellMetadataChanged,this);const e=this.activeCell?this.activeCell.model:null;this._prevActiveCell=e,e&&e.metadataChanged.connect(this._onActiveCellMetadataChanged,this);for(const n of this._toolChildren())G.sendMessage(n,q.ActiveCellMessage)}_onSelectionChanged(){for(const e of this._toolChildren())G.sendMessage(e,q.SelectionMessage)}_onActiveNotebookPanelMetadataChanged(e,n){const s=new ge.ChangeMessage("activenotebookpanel-metadata-changed",{oldValue:void 0,newValue:void 0,...n});for(const a of this._toolChildren())G.sendMessage(a,s)}_onActiveCellMetadataChanged(e,n){const s=new ge.ChangeMessage("activecell-metadata-changed",{newValue:void 0,oldValue:void 0,...n});for(const a of this._toolChildren())G.sendMessage(a,s)}*_toolChildren(){for(let e of this._tools)yield*e.panel.children()}}(function(r){r.ActiveNotebookPanelMessage=new xe("activenotebookpanel-changed"),r.ActiveCellMessage=new xe("activecell-changed"),r.SelectionMessage=new xe("selection-changed");class e extends ee{dispose(){super.dispose(),this.notebookTools&&(this.notebookTools=null)}processMessage(a){switch(super.processMessage(a),a.type){case"activenotebookpanel-changed":this.onActiveNotebookPanelChanged(a);break;case"activecell-changed":this.onActiveCellChanged(a);break;case"selection-changed":this.onSelectionChanged(a);break;case"activecell-metadata-changed":this.onActiveCellMetadataChanged(a);break;case"activenotebookpanel-metadata-changed":this.onActiveNotebookPanelMetadataChanged(a);break}}onActiveNotebookPanelChanged(a){}onActiveCellChanged(a){}onSelectionChanged(a){}onActiveCellMetadataChanged(a){}onActiveNotebookPanelMetadataChanged(a){}}r.Tool=e;class n extends e{constructor(a){super();const{editorFactory:l}=a;this.addClass("jp-MetadataEditorTool");const p=this.layout=new be;this._editorFactory=l,this._editorLabel=a.label||"Edit Metadata",this.createEditor();const i=new ee({node:document.createElement("label")});i.node.textContent=a.label||"Edit Metadata",p.addWidget(i),p.addWidget(this.editor)}get editor(){return this._editor}onActiveNotebookPanelChanged(a){this.editor.dispose(),this.notebookTools.activeNotebookPanel&&this.createEditor()}createEditor(){this._editor=new Ko({editorFactory:this._editorFactory}),this.editor.title.label=this._editorLabel,this.layout.addWidget(this.editor)}}r.MetadataEditorTool=n})(q||(q={}));var Me;(function(r){function e(n,s){return n.rank-s.rank}r.itemCmp=e})(Me||(Me={}));const Yo=6;var V;(function(r){r[r.Idle=-1]="Idle",r[r.Error=-.5]="Error",r[r.Scheduled=0]="Scheduled",r[r.Running=1]="Running"})(V||(V={}));class Xo extends Po{constructor(e,n,s,a){super(e,a),this.parser=n,this.sanitizer=s,this.configMetadataMap={numberHeaders:["toc-autonumbering","toc/number_sections"],numberingH1:["!toc/skip_h1_title"],baseNumbering:["toc/base_numbering"]},this._runningCells=new Array,this._errorCells=new Array,this._cellToHeadingIndex=new WeakMap,e.context.ready.then(()=>{this.setConfiguration({})}),this.widget.context.model.metadataChanged.connect(this.onMetadataChanged,this),this.widget.content.activeCellChanged.connect(this.onActiveCellChanged,this),v.executionScheduled.connect(this.onExecutionScheduled,this),v.executed.connect(this.onExecuted,this),v.outputCleared.connect(this.onOutputCleared,this),this.headingsChanged.connect(this.onHeadingsChanged,this)}get documentType(){return"notebook"}get isAlwaysActive(){return!0}get supportedOptions(){return["baseNumbering","maximalDepth","numberingH1","numberHeaders","includeOutput","syncCollapseState"]}getCellHeadings(e){const n=new Array;let s=this._cellToHeadingIndex.get(e);if(s!==void 0){const a=this.headings[s];for(n.push(a);this.headings[s-1]&&this.headings[s-1].cellRef===a.cellRef;)s--,n.unshift(this.headings[s])}return n}dispose(){var e,n,s;this.isDisposed||(this.headingsChanged.disconnect(this.onHeadingsChanged,this),(n=(e=this.widget.context)===null||e===void 0?void 0:e.model)===null||n===void 0||n.metadataChanged.disconnect(this.onMetadataChanged,this),(s=this.widget.content)===null||s===void 0||s.activeCellChanged.disconnect(this.onActiveCellChanged,this),v.executionScheduled.disconnect(this.onExecutionScheduled,this),v.executed.disconnect(this.onExecuted,this),v.outputCleared.disconnect(this.onOutputCleared,this),this._runningCells.length=0,this._errorCells.length=0,super.dispose())}setConfiguration(e){const n=this.loadConfigurationFromMetadata();super.setConfiguration({...this.configuration,...n,...e})}toggleCollapse(e){super.toggleCollapse(e),this.updateRunningStatus(this.headings)}async getHeadings(){const e=this.widget.content.widgets,n=new Set(e),s=[],a=new Array,l=new WeakMap;for(let p=0;p<e.length;p++){const i=e[p];switch(i.model.type){case"code":{!this.configuration.syncCollapseState&&this.configuration.includeOutput&&s.push(...Le(await i.getHeadings(),this.configuration,a).map(d=>({...d,cellRef:i,collapsed:!1,isRunning:V.Idle})));break}case"markdown":{const d=Le(await i.getHeadings(),this.configuration,a).map((g,b)=>({...g,cellRef:i,collapsed:!1,isRunning:V.Idle}));if(this.configuration.syncCollapseState&&i.headingCollapsed){const g=Math.min(...d.map(f=>f.level)),b=d.find(f=>f.level===g);b.collapsed=i.headingCollapsed}s.push(...d);break}}s.length>0&&l.set(i,s.length-1)}return this._cellToHeadingIndex=l,this._runningCells=this._runningCells.filter(p=>n.has(p)),this._errorCells=this._errorCells.filter(p=>n.has(p)),this.updateRunningStatus(s),Promise.resolve(s)}isHeadingEqual(e,n){return super.isHeadingEqual(e,n)&&e.cellRef===n.cellRef&&e.isRunning===n.isRunning}loadConfigurationFromMetadata(){const e=this.widget.content.model,n={};if(e)for(const s in this.configMetadataMap){const a=this.configMetadataMap[s];for(const l of a){let p=l;const i=p[0]==="!";i&&(p=p.slice(1));const u=p.split("/");let d=e.getMetadata(u[0]);for(let g=1;g<u.length;g++)d=(d??{})[u[g]];d!==void 0&&(typeof d=="boolean"&&i&&(d=!d),n[s]=d)}}return n}onActiveCellChanged(e,n){const s=this.getCellHeadings(n)[0];this.setActiveHeading(s??null,!1)}onHeadingsChanged(){this.widget.content.activeCell&&this.onActiveCellChanged(this.widget.content,this.widget.content.activeCell)}onExecuted(e,n){this._runningCells.forEach((s,a)=>{var l;if(s===n.cell){this._runningCells.splice(a,1);const p=this._cellToHeadingIndex.get(s);if(p!==void 0){const i=this.headings[p];if(n.success||((l=n.error)===null||l===void 0?void 0:l.errorName)===void 0){i.isRunning=V.Idle;return}i.isRunning=V.Error,this._errorCells.includes(s)||this._errorCells.push(s)}}}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onExecutionScheduled(e,n){this._runningCells.includes(n.cell)||this._runningCells.push(n.cell),this._errorCells.forEach((s,a)=>{s===n.cell&&this._errorCells.splice(a,1)}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onOutputCleared(e,n){this._errorCells.forEach((s,a)=>{if(s===n.cell){this._errorCells.splice(a,1);const l=this._cellToHeadingIndex.get(s);if(l!==void 0){const p=this.headings[l];p.isRunning=V.Idle}}}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onMetadataChanged(){this.setConfiguration({})}updateRunningStatus(e){e.forEach(a=>{a.isRunning=V.Idle}),this._runningCells.forEach((a,l)=>{const p=this._cellToHeadingIndex.get(a);if(p!==void 0){const i=e[p];i.isRunning!==V.Running&&(i.isRunning=l>0?V.Scheduled:V.Running)}}),this._errorCells.forEach((a,l)=>{const p=this._cellToHeadingIndex.get(a);if(p!==void 0){const i=e[p];i.isRunning===V.Idle&&(i.isRunning=V.Error)}});let n=0;for(;n<e.length;){const a=e[n];if(n++,a.collapsed){const l=Math.max(a.isRunning,s(e,a.level));a.dataset={...a.dataset,"data-running":l.toString()}}else a.dataset={...a.dataset,"data-running":a.isRunning.toString()}}function s(a,l){let p=V.Idle;for(;n<a.length;){const i=a[n];if(i.dataset={...i.dataset,"data-running":i.isRunning.toString()},i.level>l)n++,p=Math.max(i.isRunning,p),i.collapsed&&(p=Math.max(p,s(a,i.level)),i.dataset={...i.dataset,"data-running":p.toString()});else break}return p}}}class Qo extends Io{constructor(e,n,s,a){super(e),this.parser=n,this.sanitizer=s,this.commands=a,this._scrollToTop=!0}get scrollToTop(){return this._scrollToTop}set scrollToTop(e){this._scrollToTop=e}_createNew(e,n){const s=new Xo(e,this.parser,this.sanitizer,n);let a=new WeakMap;const l=(_,y)=>{if(y){const w=async h=>{if(!h.inViewport)return;let C=a.get(y);if((!C||!y.cellRef.node.contains(C))&&(await i(h),C=a.get(y)),C)if(this.scrollToTop)C.scrollIntoView({block:"start"}),e.content.outerNode.scrollTop-=Yo;else{const k=e.content.node.getBoundingClientRect(),A=C.getBoundingClientRect();(A.top>k.bottom||A.bottom<k.top)&&C.scrollIntoView({block:"center"})}else console.debug("scrolling to heading: using fallback strategy"),await e.content.scrollToItem(e.content.activeCellIndex,this.scrollToTop?"start":void 0,0)},S=y.cellRef,t=e.content.widgets.indexOf(S);S.model.type=="markdown"&&e.content.mode!="command"&&(e.content.mode="command"),e.content.activeCellIndex=t,S.inViewport?w(S).catch(h=>{console.error(`Fail to scroll to cell to display the required heading (${h}).`)}):e.content.scrollToItem(t,this.scrollToTop?"start":void 0).then(()=>i(S)).then(()=>w(S)).catch(h=>{console.error(`Fail to scroll to cell to display the required heading (${h}).`)})}},p=_=>s.getCellHeadings(_).filter(y=>y.cellRef===_),i=async _=>{var y;const w=p(_),S=(y=this.sanitizer.allowNamedProperties)!==null&&y!==void 0&&y?"id":"data-jupyter-id",o=await Promise.all(w.map(async h=>{const C=await Zo(h,this.parser,this.sanitizer);return C?`h${h.level}[${S}="${CSS.escape(C)}"]`:`h${h.level}`})),t=p(_);t.length!==w.length||t.some((h,C)=>h!==w[C])||(we(_.node),w.forEach((h,C)=>{var k,A;const B=h.outputIndex===void 0?h.cellRef.node:(k=h.cellRef.outputArea.widgets[h.outputIndex])===null||k===void 0?void 0:k.node;a.set(h,B?It(B,o[C],(A=h.prefix)!==null&&A!==void 0?A:""):null)}))},u=_=>{if(this.parser){we(e.content.node),a=new WeakMap;for(const y of e.content.widgets)y instanceof Q&&y.renderedChanged.connect(f);return Promise.all(e.content.widgets.map(y=>i(y)))}},d=(_,y)=>{var w,S,o,t;if(s.configuration.syncCollapseState)if(y!==null){const h=y.cellRef;h.headingCollapsed!==((w=y.collapsed)!==null&&w!==void 0?w:!1)&&(h.headingCollapsed=(S=y.collapsed)!==null&&S!==void 0?S:!1)}else{const h=(t=(o=s.headings[0])===null||o===void 0?void 0:o.collapsed)!==null&&t!==void 0?t:!1;e.content.widgets.forEach(C=>{C instanceof Q&&C.headingInfo.level>=0&&(C.headingCollapsed=h)})}},g=(_,y)=>{if(s.configuration.syncCollapseState){const w=s.getCellHeadings(y)[0];w&&s.toggleCollapse({heading:w,collapsed:y.headingCollapsed})}},b=(_,y)=>{var w;y.inViewport?(w=i(y))===null||w===void 0||w.catch(console.warn):we(y.node)},f=(_,y)=>{y&&i(_).catch(console.warn)};return e.context.ready.then(()=>{var _;(_=u())===null||_===void 0||_.catch(console.warn),s.activeHeadingChanged.connect(l),s.headingsChanged.connect(u),s.collapseChanged.connect(d),e.content.cellCollapsed.connect(g),e.content.cellInViewportChanged.connect(b),e.disposed.connect(()=>{s.activeHeadingChanged.disconnect(l),s.headingsChanged.disconnect(u),s.collapseChanged.disconnect(d),e.content.cellCollapsed.disconnect(g),e.content.cellInViewportChanged.disconnect(b);for(const y of e.content.widgets)y instanceof Q&&y.renderedChanged.disconnect(f)})}),s}getToolbarItems(e){return this.commands?[{name:"select-last-modified-back",widget:new Pe({commands:this.commands,id:"notebook:select-last-modified-cell",args:{toolbar:!0},icon:jt,label:""})},{name:"select-last-modified-forward",widget:new Pe({commands:this.commands,id:"notebook:select-next-modified-cell",args:{toolbar:!0},icon:Rt,label:""})}]:[]}}async function Zo(r,e,n){let s=null;return r.type===We.HeadingType.Markdown?s=await Pt(e,r.raw,r.level,n):r.type===We.HeadingType.HTML&&(s=r.id),s}const en="jp-StatusItem-trust";function tn(r,e){e=e||R;const n=e.load("jupyterlab");return r.trustedCells===r.totalCells?n.__("Notebook trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells):r.activeCellTrusted?n.__("Active cell trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells):n.__("Notebook not trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells)}function on(r){return r.allCellsTrusted?M.createElement(Lt.react,{top:"2px",stylesheet:"statusBar"}):M.createElement(Wt.react,{top:"2px",stylesheet:"statusBar"})}class de extends me{constructor(e){super(new de.Model),this.translator=e||R,this.node.classList.add(en)}render(){if(!this.model)return null;const e=tn(this.model,this.translator);return e!==this.node.title&&(this.node.title=e),M.createElement(on,{allCellsTrusted:this.model.trustedCells===this.model.totalCells,activeCellTrusted:this.model.activeCellTrusted,totalCells:this.model.totalCells,trustedCells:this.model.trustedCells})}}(function(r){class e extends Ce{constructor(){super(...arguments),this._trustedCells=0,this._totalCells=0,this._activeCellTrusted=!1,this._notebook=null}get trustedCells(){return this._trustedCells}get totalCells(){return this._totalCells}get activeCellTrusted(){return this._activeCellTrusted}get notebook(){return this._notebook}set notebook(s){const a=this._notebook;a!==null&&(a.activeCellChanged.disconnect(this._onActiveCellChanged,this),a.modelContentChanged.disconnect(this._onModelChanged,this));const l=this._getAllState();if(this._notebook=s,this._notebook===null)this._trustedCells=0,this._totalCells=0,this._activeCellTrusted=!1;else{this._notebook.activeCellChanged.connect(this._onActiveCellChanged,this),this._notebook.modelContentChanged.connect(this._onModelChanged,this),this._notebook.activeCell?this._activeCellTrusted=this._notebook.activeCell.model.trusted:this._activeCellTrusted=!1;const{total:p,trusted:i}=this._deriveCellTrustState(this._notebook.model);this._totalCells=p,this._trustedCells=i}this._triggerChange(l,this._getAllState())}_onModelChanged(s){const a=this._getAllState(),{total:l,trusted:p}=this._deriveCellTrustState(s.model);this._totalCells=l,this._trustedCells=p,this._triggerChange(a,this._getAllState())}_onActiveCellChanged(s,a){const l=this._getAllState();a?this._activeCellTrusted=a.model.trusted:this._activeCellTrusted=!1,this._triggerChange(l,this._getAllState())}_deriveCellTrustState(s){if(s===null)return{total:0,trusted:0};let a=0,l=0;for(const p of s.cells)p.type==="code"&&(a++,p.trusted&&l++);return{total:a,trusted:l}}_getAllState(){return[this._trustedCells,this._totalCells,this.activeCellTrusted]}_triggerChange(s,a){(s[0]!==a[0]||s[1]!==a[1]||s[2]!==a[2])&&this.stateChanged.emit(void 0)}}r.Model=e})(de||(de={}));const nn=new ot("@jupyterlab/metadataform:IMetadataFormProvider","A service to register new metadata editor widgets."),ln={id:"@jupyterlab/notebook-extension:cell-executor",description:"Provides the notebook cell executor.",autoStart:!0,provides:lt,activate:()=>Object.freeze({runCell:Ht})},sn=new ot("@jupyterlab/logconsole:ILoggerRegistry","A service providing a logger infrastructure."),rn={activate:an,id:"@jupyterlab/notebook-extension:log-output",description:"Adds cell outputs log to the application logger.",requires:[L],optional:[sn],autoStart:!0};function an(r,e,n){if(!n)return;function s(a){function l(p,i,u){if(Y.KernelMessage.isDisplayDataMsg(p)||Y.KernelMessage.isStreamMsg(p)||Y.KernelMessage.isErrorMsg(p)||Y.KernelMessage.isExecuteResultMsg(p)){const d=n.getLogger(a.context.path);d.rendermime=a.content.rendermime;const g={...p.content,output_type:p.header.msg_type};let b=i;(Y.KernelMessage.isErrorMsg(p)||Y.KernelMessage.isStreamMsg(p)&&p.content.name==="stderr")&&(b=u),d.log({type:"output",data:g,level:b})}}a.context.sessionContext.iopubMessage.connect((p,i)=>l(i,"info","info"),a),a.context.sessionContext.unhandledMessage.connect((p,i)=>l(i,"warning","error"),a)}e.forEach(a=>s(a)),e.widgetAdded.connect((a,l)=>s(l))}const dn="jp-ActiveCellTool",cn="jp-ActiveCellTool-Content",un="jp-ActiveCellTool-CellContent";class hn extends q.Tool{constructor(e){super(),this._cellModel=null,this._updateId=0,this._pendingUpdate=!1,this._promptOutdated=!1,this._tracker=e.tracker,this._languages=e.languages,this.addClass(dn),this.layout=new be,this._inputPrompt=new Ft,this.layout.addWidget(this._inputPrompt);const n=document.createElement("div");n.classList.add(cn);const s=n.appendChild(document.createElement("div")),a=s.appendChild(document.createElement("pre"));s.className=un,this._editorEl=a,this.layout.addWidget(new ee({node:n})),this._previewDebouncer=new Kt(()=>this._update(),150),this._tracker.activeCellChanged.connect(this._onActiveCellChanged,this),this._tracker.currentChanged.connect(this._onActiveCellChanged,this),this._onActiveCellChanged()}dispose(){this.isDisposed||(this._tracker.activeCellChanged.disconnect(this._onActiveCellChanged,this),this._tracker.currentChanged.disconnect(this._onActiveCellChanged,this),this._disconnectCellModel(),this._previewDebouncer.dispose(),super.dispose())}render(e){return M.createElement("div",{ref:n=>{!n||this.node.parentElement===n||(n.appendChild(this.node),this._pendingUpdate&&this._update().catch(console.warn))}})}_onActiveCellChanged(){var e,n;const s=(n=(e=this._tracker.activeCell)===null||e===void 0?void 0:e.model)!==null&&n!==void 0?n:null;s!==this._cellModel&&(this._disconnectCellModel(),this._cellModel=s,s&&(s.sharedModel.changed.connect(this._onCellContentChanged,this),s.mimeTypeChanged.connect(this._onCellContentChanged,this)),this._promptOutdated=!0,this._update().catch(console.warn))}_onCellContentChanged(){if(!this.node.isConnected){this._pendingUpdate=!0,this._promptOutdated=!0;return}this._promptOutdated||this._updatePrompt(),this._previewDebouncer.invoke().catch(console.warn)}_disconnectCellModel(){const e=this._cellModel;e&&(e.sharedModel.changed.disconnect(this._onCellContentChanged,this),e.mimeTypeChanged.disconnect(this._onCellContentChanged,this),this._cellModel=null)}_updatePrompt(){var e;const n=this._cellModel;n&&Vt(n)?(this._inputPrompt.executionCount=`${(e=n.executionCount)!==null&&e!==void 0?e:""}`,this._inputPrompt.show()):(this._inputPrompt.executionCount=null,this._inputPrompt.hide())}async _update(){if(!this.node.isConnected){this._pendingUpdate=!0;return}this._pendingUpdate=!1;const e=this._cellModel,n=++this._updateId;if(!e){this._promptOutdated=!1,this._updatePrompt(),this._editorEl.replaceChildren();return}const s=e.sharedModel.getSource(),a=s.indexOf(`
|
|
1
|
+
import{T as De,q as he,t as ht,r as ce,b as $e,g as Je,I as pt,k as gt,a as ze,f as Ge,C as Re,h as Ie}from"./index--S8WFITA.js";import{J as M,aA as ee,cn as ie,aD as R,gr as mt,eG as Ct,fO as bt,cp as me,aJ as Te,ee as ft,cr as vt,ef as _t,cl as Ce,iq as yt,r as J,eM as xt,ii as wt,eK as kt,dz as Z,cv as St,ir as v,dK as Ye,dG as Xe,dL as Qe,fM as Ze,fN as et,eJ as Be,aI as At,aE as tt,aF as ke,is as Mt,it as Tt,ik as Bt,k as Y,bg as Et,gj as Nt,a9 as Ot,aB as be,gw as G,iu as ge,az as le,iv as xe,iw as Q,eD as Pe,ix as jt,iy as Rt,dU as we,dW as It,dY as Le,iz as We,dV as Pt,iA as Lt,iB as Wt,aw as ot,iC as Ht,iD as Ft,eI as Kt,iE as Vt,aC as F,et as fe,iF as Se,du as Ut,eB as qt,e0 as Dt,iG as $t,iH as se,iI as nt,ck as pe,dw as Jt,aG as zt,dB as Gt,cx as Yt,gu as Xt,iJ as Qt,dP as Zt,dS as eo,iK as to,dE as oo,iL as no,iM as io,ea as lo,eb as so,dv as ro,bf as ao,fh as co}from"../datalayer-app-main.js";import{b as uo,I as it}from"./token-d9po19EN.js";import{ToolbarItems as ho}from"./lib-NBgDVJov.js";import{I as po}from"./index-CMhceBby.js";import{I as ve}from"./tokens-Dyd4wiX6.js";import{a as lt,I as L,b as st,c as go}from"./tokens-DiDi0Nkm.js";import{I as mo,a as rt}from"./tokens-DbNnxPrX.js";import{I as Co}from"./tokens-D1WVYIDT.js";import{f as at,e as bo,c as fo,I as vo,b as _o}from"./index-DCpvl_OP.js";import{I as dt}from"./tokens-B7nNzQEE.js";import{I as _e}from"./tokens-DY_UrMLq.js";import{a as Ee}from"./tokens-BYcJtuKD.js";import{I as yo}from"./tokens-Nkg3e_k9.js";import{I as xo}from"./index-6zxBQeM_.js";import{I as wo}from"./tokens-BcAeNU3z.js";import{W as ko,u as He,V as So,I as Ao,a as Mo,b as To,c as Bo}from"./document-CqNE0DPx.js";import{s as Eo}from"./hover-B3uFmZ-0.js";import{b as No,c as Oo,d as jo}from"./CellSidebarExtension-D7aXShZc.js";import{H as Ro}from"./htmlselect-CqXICb9e.js";import{T as Io,a as Po}from"./model-C2VRzh1c.js";import{C as Fe}from"./celltoolbartracker-BHSFiiuz.js";import"./hoverbox-CStlKQWE.js";import"./Output-C6ZHZSBH.js";import"./index-9wJFadG-.js";import"./dayjs.min-u3zuoSR8.js";import"./isEqual-BYxXubsX.js";import"./d3-color-Jd8hXty2.js";import"./dist-BrUAt6vF.js";import"./KebabHorizontalIcon-D6AY8pIS.js";import"./PaintbrushIcon-CFBHU-3l.js";import"./index-CqP3xLL5.js";import"./RestartIcon-DvpOf5Mf.js";import"./NotebookSkeleton-BkzTMhIX.js";import"./Avatar-MNx1kN3F.js";import"./renderer-8__rsP1H.js";import"./SquareIcon-Dy3l3VdH.js";import"./FileDirectoryOpenFillIcon-jGhuRcP3.js";import"./url-C6fJII94.js";/* empty css *//* empty css */import"./style-DdAxk_bj.js";/* empty css */import"./style-Cj1gzCjo.js";/* empty css */import"./style-rkw8dR9f.js";import"./style-GHJFdtIz.js";import"./style-ZSIOeMoX.js";import"./style-iVfD6mFL.js";import"./style-DA-Ya7rp.js";import"./style-D3tvWcFO.js";import"./style-BOqStzF9.js";import"./style-ADLQJ-E9.js";import"./style-DgglluaK.js";import"./ArrowLeftIcon-sX3iNMG1.js";import"./SkubbleIcon-CAaVh_BE.js";import"./usePrimerThemeBridge-DyX4EYyN.js";import"./index-BbcMy3Al.js";import"./KernelVariables-D3DSQaD3.js";import"./index-C0d-d3s4.js";import"./SortAscIcon-CmH04s3F.js";import"./SortDescIcon-Qif6E10I.js";import"./NotebookToolbar-BMjQTGrr.js";import"./RepoPushIcon-BtXQRhLa.js";import"./Toolbar-BncUh2ly.js";import"./sessions-CgjtuOSm.js";import"./tokens-CBhRbpQP.js";import"./drivecontents-D1HzL7Fi.js";import"./kernel-BmfZmtIo.js";function Lo(r){const n=s=>{const a=Math.max(s*3.6,.1),l=a*Math.PI/180,p=Math.sin(l)*104,i=Math.cos(l)*-104;return"M 0 0 v -104 A 104 104 1 "+(a<180?1:0)+" 0 "+p.toFixed(4)+" "+i.toFixed(4)+" z"};return M.createElement("div",{className:"jp-Statusbar-ProgressCircle",role:"progressbar","aria-label":r.label||"Unlabelled progress circle","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":r.progress,onClick:r.onClick},M.createElement("svg",{viewBox:"0 0 250 250"},M.createElement("circle",{cx:"125",cy:"125",r:"104",stroke:"var(--jp-inverse-layout-color3)",strokeWidth:"20",fill:"none"}),M.createElement("path",{className:"jp-Statusbar-ProgressCirclePath",transform:"translate(125,125) scale(.9)",d:n(r.progress),fill:"var(--jp-inverse-layout-color3)"})))}const Wo="jp-JSONEditor",ue="jp-mod-error",Ho="jp-JSONEditor-host",Fo="jp-JSONEditor-header";class Ko extends ee{constructor(e){super(),this._dataDirty=!1,this._inputDirty=!1,this._source=null,this._originalValue=ie.emptyObject,this._changeGuard=!1,this.translator=e.translator||R,this._trans=this.translator.load("jupyterlab"),this.addClass(Wo),this.headerNode=document.createElement("div"),this.headerNode.className=Fo,this.revertButtonNode=mt.element({tag:"span",title:this._trans.__("Revert changes to data")}),this.commitButtonNode=Ct.element({tag:"span",title:this._trans.__("Commit changes to data"),marginLeft:"8px"}),this.editorHostNode=document.createElement("div"),this.editorHostNode.className=Ho,this.headerNode.appendChild(this.revertButtonNode),this.headerNode.appendChild(this.commitButtonNode),this.node.appendChild(this.headerNode),this.node.appendChild(this.editorHostNode);const n=new bt.Model({mimeType:"application/json"});n.sharedModel.changed.connect(this._onModelChanged,this),this.model=n,this.editor=e.editorFactory({host:this.editorHostNode,model:n,config:{readOnly:!0}})}get source(){return this._source}set source(e){this._source!==e&&(this._source&&this._source.changed.disconnect(this._onSourceChanged,this),this._source=e,this.editor.setOption("readOnly",e===null),e&&e.changed.connect(this._onSourceChanged,this),this._setValue())}get isDirty(){return this._dataDirty||this._inputDirty}dispose(){var e;this.isDisposed||((e=this.source)===null||e===void 0||e.dispose(),this.model.dispose(),this.editor.dispose(),super.dispose())}handleEvent(e){switch(e.type){case"blur":this._evtBlur(e);break;case"click":this._evtClick(e);break}}onAfterAttach(e){const n=this.editorHostNode;n.addEventListener("blur",this,!0),n.addEventListener("click",this,!0),this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.headerNode.addEventListener("click",this)}onBeforeDetach(e){const n=this.editorHostNode;n.removeEventListener("blur",this,!0),n.removeEventListener("click",this,!0),this.headerNode.removeEventListener("click",this)}_onSourceChanged(e,n){if(!this._changeGuard){if(this._inputDirty||this.editor.hasFocus()){this._dataDirty=!0;return}this._setValue()}}_onModelChanged(e,n){if(n.sourceChange){let s=!0;try{const a=JSON.parse(this.editor.model.sharedModel.getSource());this.removeClass(ue),this._inputDirty=!this._changeGuard&&!ie.deepEqual(a,this._originalValue)}catch{this.addClass(ue),this._inputDirty=!0,s=!1}this.revertButtonNode.hidden=!this._inputDirty,this.commitButtonNode.hidden=!s||!this._inputDirty}}_evtBlur(e){!this._inputDirty&&this._dataDirty&&this._setValue()}_evtClick(e){const n=e.target;this.revertButtonNode.contains(n)?this._setValue():this.commitButtonNode.contains(n)?!this.commitButtonNode.hidden&&!this.hasClass(ue)&&(this._changeGuard=!0,this._mergeContent(),this._changeGuard=!1,this._setValue()):this.editorHostNode.contains(n)&&this.editor.focus()}_mergeContent(){const e=this.editor.model,n=this._originalValue,s=JSON.parse(e.sharedModel.getSource()),a=this.source;if(a){for(const l in s)ie.deepEqual(s[l],n[l]||null)||a.set(l,s[l]);for(const l in n)l in s||a.delete(l)}}_setValue(){this._dataDirty=!1,this._inputDirty=!1,this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.removeClass(ue);const e=this.editor.model,n=this._source?this._source.toJSON():{};if(this._changeGuard=!0,n===void 0)e.sharedModel.setSource(this._trans.__("No data!")),this._originalValue=ie.emptyObject;else{const s=JSON.stringify(n,null,4);e.sharedModel.setSource(s),this._originalValue=n,s.length>1&&s[0]==="{"&&this.editor.setCursorPosition({line:0,column:1})}this._changeGuard=!1,this.commitButtonNode.hidden=!0,this.revertButtonNode.hidden=!0}}class Vo extends M.Component{constructor(e){super(e),this._handleChange=s=>{this.setState({value:s.currentTarget.value})},this._handleSubmit=s=>{var a,l;s.preventDefault();const p=parseInt((l=(a=this._textInput)===null||a===void 0?void 0:a.value)!==null&&l!==void 0?l:"",10);return!isNaN(p)&&isFinite(p)&&1<=p&&p<=this.props.maxCell&&this.props.handleSubmit(p),!1},this._handleFocus=()=>{this.setState({hasFocus:!0})},this._handleBlur=()=>{this.setState({hasFocus:!1})},this._textInput=null;const n=e.translator||R;this._trans=n.load("jupyterlab"),this.state={value:"",hasFocus:!1,textInputId:ft.createDomID()+"-cell-number-input"}}componentDidMount(){var e;(e=this._textInput)===null||e===void 0||e.focus()}render(){return M.createElement("div",{className:"jp-lineFormSearch"},M.createElement("form",{name:"cellNumberForm",onSubmit:this._handleSubmit,noValidate:!0},M.createElement("div",{className:vt("jp-lineFormWrapper","lm-lineForm-wrapper",this.state.hasFocus?"jp-lineFormWrapperFocusWithin":void 0)},M.createElement("input",{type:"number",id:this.state.textInputId,className:"jp-lineFormInput",min:1,max:this.props.maxCell,onChange:this._handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur,value:this.state.value,ref:e=>{this._textInput=e}}),M.createElement("div",{className:"jp-baseLineForm jp-lineFormButtonContainer"},M.createElement(_t.react,{className:"jp-baseLineForm jp-lineFormButtonIcon",elementPosition:"center"}),M.createElement("input",{type:"submit",className:"jp-baseLineForm jp-lineFormButton",value:""}))),M.createElement("label",{className:"jp-lineFormCaption",htmlFor:this.state.textInputId},this._trans.__("Go to cell number between 1 and %1",this.props.maxCell))))}}function Uo(r){const n=(r.translator||R).load("jupyterlab"),s=r.selectionStart>0&&r.selectionStart!==r.selectionEnd?n.__("%1:%2/%3",r.selectionStart,r.selectionEnd,r.totalCells):n.__("Cell %1/%2",r.activeCell,r.totalCells),a=l=>{(l.key==="Enter"||l.key==="Spacebar"||l.key===" ")&&(l.preventDefault(),l.stopPropagation(),r.handleClick())};return M.createElement(De,{role:"button","aria-haspopup":!0,onClick:r.handleClick,source:s,title:n.__("Go to cell…"),tabIndex:0,onKeyDown:a})}class re extends me{constructor(e={}){super(new re.Model),this._popup=null,this.addClass("jp-mod-highlighted"),this._translator=e.translator||R}render(){return this.model===null?null:M.createElement(Uo,{activeCell:this.model.activeCell,selectionStart:this.model.selectionStart,selectionEnd:this.model.selectionEnd,totalCells:this.model.totalCells,translator:this._translator,handleClick:()=>this._handleClick()})}_handleClick(){if(this.model.totalCells<1)return;this._popup&&this._popup.dispose();const e=Te.create(M.createElement(Vo,{handleSubmit:n=>this._handleSubmit(n),maxCell:this.model.totalCells,translator:this._translator}));this._popup=Eo({body:e,anchor:this,align:"right"})}_handleSubmit(e){var n;const s=this.model.notebook;if(!s)return;const a=e-1;s.activeCellIndex=a,s.deselectAll(),s.scrollToItem(a).catch(l=>{console.error("Go to cell",l)}),(n=this._popup)===null||n===void 0||n.dispose(),s.activate()}}(function(r){class e extends Ce{constructor(){super(...arguments),this._activeCell=0,this._selectionStart=0,this._selectionEnd=0,this._totalCells=0,this._notebook=null}get notebook(){return this._notebook}set notebook(s){const a=this._notebook;a&&(a.activeCellChanged.disconnect(this._onChanged,this),a.modelContentChanged.disconnect(this._onChanged,this),a.selectionChanged.disconnect(this._onChanged,this));const l=this._getAllState();this._notebook=s,this._notebook?(this._notebook.activeCellChanged.connect(this._onChanged,this),this._notebook.modelContentChanged.connect(this._onChanged,this),this._notebook.selectionChanged.connect(this._onChanged,this),this._updateStateFromNotebook(this._notebook)):(this._activeCell=0,this._selectionStart=0,this._selectionEnd=0,this._totalCells=0),this._triggerChange(l,this._getAllState())}get activeCell(){return this._activeCell}get selectionStart(){return this._selectionStart}get selectionEnd(){return this._selectionEnd}get totalCells(){return this._totalCells}_onChanged(s){const a=this._getAllState();this._updateStateFromNotebook(s),this._triggerChange(a,this._getAllState())}_updateStateFromNotebook(s){const a=s.activeCellIndex;this._activeCell=a>=0?a+1:0,this._totalCells=s.widgets.length;let l=this._activeCell,p=this._activeCell,i=!1;s.widgets.forEach((u,d)=>{if(!s.isSelectedOrActive(u))return;const g=d+1;if(!i){l=g,p=g,i=!0;return}p=g}),this._selectionStart=i?l:0,this._selectionEnd=i?p:0}_getAllState(){return{activeCell:this._activeCell,selectionStart:this._selectionStart,selectionEnd:this._selectionEnd,totalCells:this._totalCells}}_triggerChange(s,a){(s.activeCell!==a.activeCell||s.selectionStart!==a.selectionStart||s.selectionEnd!==a.selectionEnd||s.totalCells!==a.totalCells)&&this.stateChanged.emit(void 0)}}r.Model=e})(re||(re={}));const qo="jp-Notebook-toolbarCellType",Do="jp-Notebook-toolbarCellTypeDropdown";var Ae;(function(r){function e(g,b){const f=(b||R).load("jupyterlab");function _(){if(g.context.model.readOnly)return tt({title:f.__("Cannot Save"),body:f.__("Document is read-only"),buttons:[ke.okButton()]});g.context.save().then(()=>{if(!g.isDisposed)return g.context.createCheckpoint()})}return yt(Te.create(J.createElement(xt,{signal:g.context.fileChanged},()=>J.createElement(wt,{icon:kt,onClick:_,tooltip:f.__("Save the notebook contents and create checkpoint"),enabled:!!(g&&g.context&&g.context.contentsModel&&g.context.contentsModel.writable)}))))}r.createSaveButton=e;function n(g,b){const f=(b||R).load("jupyterlab");return new Z({icon:St,onClick:()=>{v.insertBelow(g.content)},tooltip:f.__("Insert a cell below")})}r.createInsertButton=n;function s(g,b,f){const _=(b||R).load("jupyterlab");return new Z({icon:Ye,onClick:async()=>{f?.get("useSystemClipboardForCells").composite?await v.cutToSystemClipboard(g.content):v.cut(g.content)},tooltip:_.__("Cut the selected cells")})}r.createCutButton=s;function a(g,b,f){const _=(b||R).load("jupyterlab");return new Z({icon:Xe,onClick:async()=>{f?.get("useSystemClipboardForCells").composite?await v.copyToSystemClipboard(g.content):v.copy(g.content)},tooltip:_.__("Copy the selected cells")})}r.createCopyButton=a;function l(g,b,f){const _=(b||R).load("jupyterlab");return new Z({icon:Qe,onClick:async()=>{f?.get("useSystemClipboardForCells").composite?await v.pasteFromSystemClipboard(g.content):v.paste(g.content)},tooltip:_.__("Paste cells from the clipboard")})}r.createPasteButton=l;function p(g,b,f){const _=(f??R).load("jupyterlab");return new Z({icon:Ze,onClick:()=>{v.runAndAdvance(g.content,g.sessionContext,b,f)},tooltip:_.__("Run the selected cells and advance")})}r.createRunButton=p;function i(g,b,f){const _=(f??R).load("jupyterlab");return new Z({icon:et,onClick:()=>{const y=b??new Be({translator:f});y.restart(g.sessionContext).then(w=>(w&&v.runAll(g.content,g.sessionContext,y,f),w))},tooltip:_.__("Restart the kernel, then re-run the whole notebook")})}r.createRestartRunAllButton=i;function u(g,b){return new $o(g.content,b)}r.createCellTypeItem=u;function d(g,b,f,_){return[{name:"save",widget:e(g,f)},{name:"insert",widget:n(g,f)},{name:"cut",widget:s(g,f,_)},{name:"copy",widget:a(g,f,_)},{name:"paste",widget:l(g,f,_)},{name:"run",widget:p(g,b,f)},{name:"interrupt",widget:he.createInterruptButton(g.sessionContext,f)},{name:"restart",widget:he.createRestartButton(g.sessionContext,b,f)},{name:"restart-and-run",widget:i(g,b,f)},{name:"cellType",widget:u(g,f)},{name:"spacer",widget:At.createSpacerItem()},{name:"kernelName",widget:he.createKernelNameItem(g.sessionContext,b,f)}]}r.getDefaultItems=d})(Ae||(Ae={}));class $o extends Te{constructor(e,n){super(),this.handleChange=s=>{s.target.value!=="-"&&(v.changeCellType(this._notebook,s.target.value),this._notebook.activate())},this.handleKeyDown=s=>{s.key==="Enter"&&this._notebook.activate()},this._trans=(n||R).load("jupyterlab"),this.addClass(qo),this._notebook=e,e.model&&this.update(),e.activeCellChanged.connect(this.update,this),e.selectionChanged.connect(this.update,this)}render(){let e="-";this._notebook.activeCell&&(e=this._notebook.activeCell.model.type);for(const n of this._notebook.widgets)if(this._notebook.isSelectedOrActive(n)&&n.model.type!==e){e="-";break}return J.createElement(Ro,{className:Do,onChange:this.handleChange,onKeyDown:this.handleKeyDown,value:e,"aria-label":this._trans.__("Cell type"),title:this._trans.__("Select the cell type")},J.createElement("option",{value:"-"},"-"),J.createElement("option",{value:"code"},this._trans.__("Code")),J.createElement("option",{value:"markdown"},this._trans.__("Markdown")),J.createElement("option",{value:"raw"},this._trans.__("Raw")))}}function Ke(r){var e;const n=r.translator||R,s=ht(n),a=n.load("jupyterlab"),l=(e=r.displayOption.showJumpToCell)!==null&&e!==void 0?e:!1,p=r.state,i=r.displayOption.showOnToolBar,u=r.displayOption.showProgress,d=i?"down":"up",g=M.createElement("div",null),[b,f]=M.useState(!1);if(M.useEffect(()=>{if(b)return;const j=()=>{f(!0)};return v.executionScheduled.connect(j),()=>{v.executionScheduled.disconnect(j)}},[l,b]),!p)return g;const _=p.kernelStatus,y={alignSelf:"normal",height:"24px"},w=p.totalTime,S=p.scheduledCellNumber||0,o=p.scheduledCell.size||0,t=S-o;let h=100*t/S,C=u?"":"hidden";!u&&h<100&&(h=0);const k=j=>M.createElement(Lo,{progress:j,width:16,height:24,label:a.__("Kernel status")}),A=j=>a.__("Kernel status: %1",j),B=()=>{const j=r.notebook;v.selectLastRunCell(j),j.activeCell&&j.scrollToCell(j.activeCell)},E=(j,K,W)=>M.createElement("div",{className:"jp-Notebook-ExecutionIndicator",title:u?"":A(s[j]),"data-status":j},K,M.createElement("div",{className:`jp-Notebook-ExecutionIndicator-tooltip ${d} ${C}`},M.createElement("span",null," ",A(s[j])," "),W,l&&b&&M.createElement(Bt,{className:"jp-Notebook-ExecutionIndicator-jumpButton",onClick:B,title:a.__("Jump to current or last executed cell")},a.__("Jump to cell"))));if(p.kernelStatus==="connecting"||p.kernelStatus==="disconnected"||p.kernelStatus==="unknown")return E(_,M.createElement(Mt.react,{...y}),[]);if(p.kernelStatus==="starting"||p.kernelStatus==="terminating"||p.kernelStatus==="restarting"||p.kernelStatus==="initializing")return E(_,M.createElement(Tt.react,{...y}),[]);if(p.executionStatus==="busy")return E("busy",k(h),[M.createElement("span",{key:0},a.__("Executed %1/%2 cells",t,S)),M.createElement("span",{key:1},a._n("Elapsed time: %1 second","Elapsed time: %1 seconds",w))]);{const j=p.kernelStatus==="busy"?0:100,K=p.kernelStatus==="busy"||w===0?[]:[M.createElement("span",{key:0},a._n("Executed %1 cell","Executed %1 cells",S)),M.createElement("span",{key:1},a._n("Elapsed time: %1 second","Elapsed time: %1 seconds",w))];return E(p.kernelStatus,k(j),K)}}class X extends me{constructor(e,n=!0){super(new X.Model),this.translator=e||R,this.addClass("jp-mod-highlighted")}dispose(){var e;this.isDisposed||((e=this.model)===null||e===void 0||e.dispose(),super.dispose())}render(){if(this.model===null||!this.model.renderFlag)return M.createElement("div",null);{const e=this.model.currentNotebook;return e?M.createElement(Ke,{displayOption:this.model.displayOption,state:this.model.executionState(e),translator:this.translator,notebook:e}):M.createElement(Ke,{displayOption:this.model.displayOption,state:void 0,translator:this.translator,notebook:void 0})}}}(function(r){class e extends Ce{constructor(){super(),this._notebookExecutionProgress=new WeakMap,this._displayOption={showOnToolBar:!0,showProgress:!0,showJumpToCell:!1},this._renderFlag=!0}attachNotebook(l){var p,i,u,d;if(l&&l.content&&l.context){const g=l.content,b=l.context;if(this._currentNotebook=g,!this._notebookExecutionProgress.has(g)){this._notebookExecutionProgress.set(g,{executionStatus:"idle",kernelStatus:"idle",totalTime:0,interval:0,timeout:0,scheduledCell:new Set,scheduledCellNumber:0,needReset:!0});const f=this._notebookExecutionProgress.get(g),_=o=>{f&&(f.kernelStatus=o.kernelDisplayStatus),this.stateChanged.emit(void 0)};b.statusChanged.connect(_,this);const y=o=>{f&&(f.kernelStatus=o.kernelDisplayStatus),this.stateChanged.emit(void 0)};b.connectionStatusChanged.connect(y,this),b.disposed.connect(o=>{o.connectionStatusChanged.disconnect(y,this),o.statusChanged.disconnect(_,this)},this);const w=(o,t)=>{const h=t.msg,C=h.header.msg_id;if(h.header.msg_type==="execute_request")this._cellScheduledCallback(g,C);else if(Y.KernelMessage.isStatusMsg(h)&&h.content.execution_state==="idle"){const k=h.parent_header.msg_id;this._cellExecutedCallback(g,k)}else Y.KernelMessage.isStatusMsg(h)&&h.content.execution_state==="restarting"?this._restartHandler(g):h.header.msg_type==="execute_input"&&this._startTimer(g)};(i=(p=b.session)===null||p===void 0?void 0:p.kernel)===null||i===void 0||i.anyMessage.connect(w,this),(d=(u=b.session)===null||u===void 0?void 0:u.kernel)===null||d===void 0||d.disposed.connect(o=>o.anyMessage.disconnect(w,this),this);const S=(o,t)=>{f&&(this._resetTime(f),this.stateChanged.emit(void 0),t.newValue&&t.newValue.anyMessage.connect(w,this))};b.kernelChanged.connect(S,this),b.disposed.connect(o=>o.kernelChanged.disconnect(S,this),this)}}}get currentNotebook(){return this._currentNotebook}get displayOption(){return this._displayOption}set displayOption(l){this._displayOption=l}executionState(l){return this._notebookExecutionProgress.get(l)}_scheduleSwitchToIdle(l){window.setTimeout(()=>{l.executionStatus="idle",clearInterval(l.interval),this.stateChanged.emit(void 0)},150),l.timeout=window.setTimeout(()=>{l.needReset=!0},1e3)}_cellExecutedCallback(l,p){const i=this._notebookExecutionProgress.get(l);i&&i.scheduledCell.has(p)&&(i.scheduledCell.delete(p),i.scheduledCell.size===0&&this._scheduleSwitchToIdle(i))}_restartHandler(l){const p=this._notebookExecutionProgress.get(l);p&&(p.scheduledCell.clear(),this._scheduleSwitchToIdle(p))}_startTimer(l){const p=this._notebookExecutionProgress.get(l);p&&(p.scheduledCell.size>0?p.executionStatus!=="busy"&&(p.executionStatus="busy",clearTimeout(p.timeout),this.stateChanged.emit(void 0),p.interval=window.setInterval(()=>{this._tick(p)},1e3)):this._resetTime(p))}_cellScheduledCallback(l,p){const i=this._notebookExecutionProgress.get(l);i&&!i.scheduledCell.has(p)&&(i.needReset&&this._resetTime(i),i.scheduledCell.add(p),i.scheduledCellNumber+=1)}_tick(l){if(this.isDisposed){clearInterval(l.interval),clearTimeout(l.timeout);return}l.totalTime+=1,this.stateChanged.emit(void 0)}_resetTime(l){l.totalTime=0,l.scheduledCellNumber=0,l.executionStatus="idle",l.scheduledCell=new Set,clearTimeout(l.timeout),clearInterval(l.interval),l.needReset=!1}get renderFlag(){return this._renderFlag}updateRenderOption(l){this.displayOption.showOnToolBar&&(l.showOnToolBar?this._renderFlag=!0:this._renderFlag=!1),this.displayOption.showProgress=l.showProgress,this.displayOption.showJumpToCell=l.showJumpToCell,this.stateChanged.emit(void 0)}}r.Model=e;function n(a,l,p){const i=new r(l);return i.model.displayOption={showOnToolBar:!0,showProgress:!0,showJumpToCell:!1},i.model.attachNotebook({content:a.content,context:a.sessionContext}),p&&p.then(u=>{const d=g=>{const b=s(g);b.showJumpToCell&&(g.get("recordTiming").composite||g.set("recordTiming",!0).catch(_=>{console.error("Failed to auto-enable recordTiming:",_.message)})),i.model.updateRenderOption(b)};u.changed.connect(d),d(u),i.disposed.connect(()=>{u.changed.disconnect(d)})}).catch(u=>{console.error(u.message)}),i}r.createExecutionIndicatorItem=n;function s(a){let l=!0,p=!0,i=!1;const u=a.get("kernelStatus").composite;return u&&(l=!u.showOnStatusBar,p=u.showProgress,i=u.showJumpToRecentExecutionButton),{showOnToolBar:l,showProgress:p,showJumpToCell:i}}r.getSettingValue=s})(X||(X={}));function Jo(r){const e=(r.translator||R).load("jupyterlab");return J.createElement(De,{source:e.__("Mode: %1",r.modeNames[r.notebookMode])})}class ae extends me{constructor(e){super(new ae.Model),this.translator=e||R,this._trans=this.translator.load("jupyterlab"),this._modeNames={command:this._trans.__("Command"),edit:this._trans.__("Edit")}}render(){return this.model?(this.node.title=this._trans.__("Notebook is in %1 mode",this._modeNames[this.model.notebookMode]),J.createElement(Jo,{notebookMode:this.model.notebookMode,translator:this.translator,modeNames:this._modeNames})):null}}(function(r){class e extends Ce{constructor(){super(...arguments),this._onChanged=s=>{const a=this._notebookMode;this._notebook?this._notebookMode=s.mode:this._notebookMode="command",this._triggerChange(a,this._notebookMode)},this._notebookMode="command",this._notebook=null}get notebookMode(){return this._notebookMode}set notebook(s){const a=this._notebook;a!==null&&(a.stateChanged.disconnect(this._onChanged,this),a.activeCellChanged.disconnect(this._onChanged,this),a.modelContentChanged.disconnect(this._onChanged,this));const l=this._notebookMode;this._notebook=s,this._notebook===null?this._notebookMode="command":(this._notebookMode=this._notebook.mode,this._notebook.stateChanged.connect(this._onChanged,this),this._notebook.activeCellChanged.connect(this._onChanged,this),this._notebook.modelContentChanged.connect(this._onChanged,this)),this._triggerChange(l,this._notebookMode)}_triggerChange(s,a){s!==a&&this.stateChanged.emit(void 0)}}r.Model=e})(ae||(ae={}));class zo extends ko{constructor(e,n){super(e,n),this.editorWidget=e,this.options=n,this._type="code",this._readyDelegate=new Et,this._editorToCell=new Map,this.editor=e.content,this._cellToEditor=new WeakMap,this.isReady=this.isReady.bind(this),Promise.all([this.widget.context.sessionContext.ready,this.connectionManager.ready]).then(async()=>{await this.initOnceReady(),this._readyDelegate.resolve()}).catch(console.error)}get documentPath(){return this.widget.context.path}get mimeType(){var e;let n,s=this.language_info();return!s||!s.mimetype?n=this.widget.content.codeMimetype:n=s.mimetype,Array.isArray(n)?(e=n[0])!==null&&e!==void 0?e:Nt.defaultMimeType:n}get languageFileExtension(){let e=this.language_info();if(!(!e||!e.file_extension))return e.file_extension.replace(".","")}get wrapperElement(){return this.widget.node}get editors(){if(this.isDisposed)return[];let e=this.widget.content;return this._editorToCell.clear(),e.isDisposed?[]:e.widgets.map(n=>({ceEditor:this._getCellEditor(n),type:n.model.type,value:n.model.sharedModel.getSource()}))}get activeEditor(){return this.editor.activeCell?this._getCellEditor(this.editor.activeCell):void 0}get ready(){return this._readyDelegate.promise}getEditorIndexAt(e){let n=this._getCellAt(e);return this.widget.content.widgets.findIndex(a=>n===a)}getEditorIndex(e){let n=this._editorToCell.get(e);return this.editor.widgets.findIndex(s=>n===s)}getEditorWrapper(e){return this._editorToCell.get(e).node}async onKernelChanged(e,n){if(n.newValue)try{const s=this._languageInfo;await He(this.isReady,-1),await this._updateLanguageInfo();const a=this._languageInfo;s?.name!=a.name||s?.mimetype!=a?.mimetype||s?.file_extension!=a?.file_extension?(console.log(`Changed to ${this._languageInfo.name} kernel, reconnecting`),this.reloadConnection()):console.log("Keeping old LSP connection as the new kernel uses the same language")}catch(s){console.warn(s),this.reloadConnection()}}dispose(){this.isDisposed||(this.widget.context.sessionContext.kernelChanged.disconnect(this.onKernelChanged,this),this.widget.content.activeCellChanged.disconnect(this._activeCellChanged,this),super.dispose(),this._editorToCell.clear(),Ot.clearData(this))}isReady(){var e;return!this.widget.isDisposed&&this.widget.context.isReady&&this.widget.content.isVisible&&this.widget.content.widgets.length>0&&((e=this.widget.context.sessionContext.session)===null||e===void 0?void 0:e.kernel)!=null}async handleCellChange(e,n){let s=[],a=[];const l=this._type;if(n.type==="set"){let p=[],i=[];if(n.newValues.length===n.oldValues.length){for(let u=0;u<n.newValues.length;u++)n.oldValues[u].type===l&&n.newValues[u].type!==l?p.push(n.newValues[u]):n.oldValues[u].type!==l&&n.newValues[u].type===l&&i.push(n.newValues[u]);s=i,a=p}}else n.type=="add"&&(s=n.newValues.filter(p=>p.type===l));(a.length||s.length||n.type==="set"||n.type==="move"||n.type==="remove"||n.type==="clear")&&await this.updateDocuments();for(let p of s){let i=this.widget.content.widgets.find(u=>u.model.id===p.id);if(!i){console.warn(`Widget for added cell with ID: ${p.id} not found!`);continue}this._getCellEditor(i)}}createVirtualDocument(){return new So({language:this.language,foreignCodeExtractors:this.options.foreignCodeExtractorsManager,path:this.documentPath,fileExtension:this.languageFileExtension,standalone:!1,hasLspSupportedFile:!1})}language_info(){return this._languageInfo}async initOnceReady(){await He(this.isReady.bind(this),-1),await this._updateLanguageInfo(),this.initVirtual(),this.connectDocument(this.virtualDocument,!1).catch(console.warn),this.widget.context.sessionContext.kernelChanged.connect(this.onKernelChanged,this),this.widget.content.activeCellChanged.connect(this._activeCellChanged,this),this._connectModelSignals(this.widget),this.editor.modelChanged.connect(e=>{console.warn("Model changed, connecting cell change handler; this is not something we were expecting"),this._connectModelSignals(e)})}_connectModelSignals(e){e.model===null?console.warn(`Model is missing for notebook ${e}, cannot connect cell changed signal!`):e.model.cells.changed.connect(this.handleCellChange,this)}async _updateLanguageInfo(){var e,n,s,a;const l=(a=await((s=(n=(e=this.widget.context.sessionContext)===null||e===void 0?void 0:e.session)===null||n===void 0?void 0:n.kernel)===null||s===void 0?void 0:s.info))===null||a===void 0?void 0:a.language_info;if(l)this._languageInfo=l;else throw new Error("Language info update failed (no session, kernel, or info available)")}_activeCellChanged(e,n){!n||n.model.type!==this._type||this._activeEditorChanged.emit({editor:this._getCellEditor(n)})}_getCellAt(e){let n=this.virtualDocument.getEditorAtVirtualLine(e);return this._editorToCell.get(n)}_getCellEditor(e){if(!this._cellToEditor.has(e)){const n=Object.freeze({getEditor:()=>e.editor,ready:async()=>(await e.ready,e.editor),reveal:async()=>(await this.editor.scrollToCell(e),e.editor)});this._cellToEditor.set(e,n),this._editorToCell.set(n,e),e.disposed.connect(()=>{this._cellToEditor.delete(e),this._editorToCell.delete(n),this._editorRemoved.emit({editor:n})}),this._editorAdded.emit({editor:n})}return this._cellToEditor.get(e)}}class Go extends ee{constructor(){super(),this._items=[],this.layout=new be,this.addClass("jp-RankedPanel")}addWidget(e,n){const s={widget:e,rank:n},a=le.upperBound(this._items,s,Me.itemCmp);le.insert(this._items,a,s),this.layout.insertWidget(a,e)}onChildRemoved(e){const n=le.findFirstIndex(this._items,s=>s.widget===e.child);n!==-1&&le.removeAt(this._items,n)}}class q extends ee{constructor(e){super(),this.addClass("jp-NotebookTools"),this.translator=e.translator||R,this._tools=[],this.layout=new be,this._tracker=e.tracker,this._tracker.currentChanged.connect(this._onActiveNotebookPanelChanged,this),this._tracker.activeCellChanged.connect(this._onActiveCellChanged,this),this._tracker.selectionChanged.connect(this._onSelectionChanged,this),this._onActiveNotebookPanelChanged(),this._onActiveCellChanged(),this._onSelectionChanged()}get activeCell(){return this._tracker.activeCell}get selectedCells(){const e=this._tracker.currentWidget;if(!e)return[];const n=e.content;return n.widgets.filter(s=>n.isSelectedOrActive(s))}get activeNotebookPanel(){return this._tracker.currentWidget}addItem(e){var n;const s=e.tool,a=(n=e.rank)!==null&&n!==void 0?n:100;let l;const p=this._tools.find(i=>i.section===e.section);if(p)l=p.panel;else throw new Error(`The section ${e.section} does not exist`);s.addClass("jp-NotebookTools-tool"),l.addWidget(s,a),s.notebookTools=this,G.sendMessage(s,q.ActiveNotebookPanelMessage),G.sendMessage(s,q.ActiveCellMessage)}addSection(e){var n;const s=e.sectionName,a=e.label||e.sectionName,l=e.tool;let p=(n=e.rank)!==null&&n!==void 0?n:null;const i=new Go;if(i.title.label=a,l&&i.addWidget(l,0),this._tools.push({section:s,panel:i,rank:p}),p!=null)this.layout.insertWidget(p,new ce({widget:i}));else{let u=null;const d=this.layout;for(let g=0;g<d.widgets.length;g++){let b=d.widgets[g];if(b instanceof ce&&b.widget.id==="advancedToolsSection"){u=g;break}}u!==null?this.layout.insertWidget(u,new ce({widget:i})):this.layout.addWidget(new ce({widget:i}))}}_onActiveNotebookPanelChanged(){this._prevActiveNotebookModel&&!this._prevActiveNotebookModel.isDisposed&&this._prevActiveNotebookModel.metadataChanged.disconnect(this._onActiveNotebookPanelMetadataChanged,this);const e=this.activeNotebookPanel&&this.activeNotebookPanel.content?this.activeNotebookPanel.content.model:null;this._prevActiveNotebookModel=e,e&&e.metadataChanged.connect(this._onActiveNotebookPanelMetadataChanged,this);for(const n of this._toolChildren())G.sendMessage(n,q.ActiveNotebookPanelMessage)}_onActiveCellChanged(){this._prevActiveCell&&!this._prevActiveCell.isDisposed&&this._prevActiveCell.metadataChanged.disconnect(this._onActiveCellMetadataChanged,this);const e=this.activeCell?this.activeCell.model:null;this._prevActiveCell=e,e&&e.metadataChanged.connect(this._onActiveCellMetadataChanged,this);for(const n of this._toolChildren())G.sendMessage(n,q.ActiveCellMessage)}_onSelectionChanged(){for(const e of this._toolChildren())G.sendMessage(e,q.SelectionMessage)}_onActiveNotebookPanelMetadataChanged(e,n){const s=new ge.ChangeMessage("activenotebookpanel-metadata-changed",{oldValue:void 0,newValue:void 0,...n});for(const a of this._toolChildren())G.sendMessage(a,s)}_onActiveCellMetadataChanged(e,n){const s=new ge.ChangeMessage("activecell-metadata-changed",{newValue:void 0,oldValue:void 0,...n});for(const a of this._toolChildren())G.sendMessage(a,s)}*_toolChildren(){for(let e of this._tools)yield*e.panel.children()}}(function(r){r.ActiveNotebookPanelMessage=new xe("activenotebookpanel-changed"),r.ActiveCellMessage=new xe("activecell-changed"),r.SelectionMessage=new xe("selection-changed");class e extends ee{dispose(){super.dispose(),this.notebookTools&&(this.notebookTools=null)}processMessage(a){switch(super.processMessage(a),a.type){case"activenotebookpanel-changed":this.onActiveNotebookPanelChanged(a);break;case"activecell-changed":this.onActiveCellChanged(a);break;case"selection-changed":this.onSelectionChanged(a);break;case"activecell-metadata-changed":this.onActiveCellMetadataChanged(a);break;case"activenotebookpanel-metadata-changed":this.onActiveNotebookPanelMetadataChanged(a);break}}onActiveNotebookPanelChanged(a){}onActiveCellChanged(a){}onSelectionChanged(a){}onActiveCellMetadataChanged(a){}onActiveNotebookPanelMetadataChanged(a){}}r.Tool=e;class n extends e{constructor(a){super();const{editorFactory:l}=a;this.addClass("jp-MetadataEditorTool");const p=this.layout=new be;this._editorFactory=l,this._editorLabel=a.label||"Edit Metadata",this.createEditor();const i=new ee({node:document.createElement("label")});i.node.textContent=a.label||"Edit Metadata",p.addWidget(i),p.addWidget(this.editor)}get editor(){return this._editor}onActiveNotebookPanelChanged(a){this.editor.dispose(),this.notebookTools.activeNotebookPanel&&this.createEditor()}createEditor(){this._editor=new Ko({editorFactory:this._editorFactory}),this.editor.title.label=this._editorLabel,this.layout.addWidget(this.editor)}}r.MetadataEditorTool=n})(q||(q={}));var Me;(function(r){function e(n,s){return n.rank-s.rank}r.itemCmp=e})(Me||(Me={}));const Yo=6;var V;(function(r){r[r.Idle=-1]="Idle",r[r.Error=-.5]="Error",r[r.Scheduled=0]="Scheduled",r[r.Running=1]="Running"})(V||(V={}));class Xo extends Po{constructor(e,n,s,a){super(e,a),this.parser=n,this.sanitizer=s,this.configMetadataMap={numberHeaders:["toc-autonumbering","toc/number_sections"],numberingH1:["!toc/skip_h1_title"],baseNumbering:["toc/base_numbering"]},this._runningCells=new Array,this._errorCells=new Array,this._cellToHeadingIndex=new WeakMap,e.context.ready.then(()=>{this.setConfiguration({})}),this.widget.context.model.metadataChanged.connect(this.onMetadataChanged,this),this.widget.content.activeCellChanged.connect(this.onActiveCellChanged,this),v.executionScheduled.connect(this.onExecutionScheduled,this),v.executed.connect(this.onExecuted,this),v.outputCleared.connect(this.onOutputCleared,this),this.headingsChanged.connect(this.onHeadingsChanged,this)}get documentType(){return"notebook"}get isAlwaysActive(){return!0}get supportedOptions(){return["baseNumbering","maximalDepth","numberingH1","numberHeaders","includeOutput","syncCollapseState"]}getCellHeadings(e){const n=new Array;let s=this._cellToHeadingIndex.get(e);if(s!==void 0){const a=this.headings[s];for(n.push(a);this.headings[s-1]&&this.headings[s-1].cellRef===a.cellRef;)s--,n.unshift(this.headings[s])}return n}dispose(){var e,n,s;this.isDisposed||(this.headingsChanged.disconnect(this.onHeadingsChanged,this),(n=(e=this.widget.context)===null||e===void 0?void 0:e.model)===null||n===void 0||n.metadataChanged.disconnect(this.onMetadataChanged,this),(s=this.widget.content)===null||s===void 0||s.activeCellChanged.disconnect(this.onActiveCellChanged,this),v.executionScheduled.disconnect(this.onExecutionScheduled,this),v.executed.disconnect(this.onExecuted,this),v.outputCleared.disconnect(this.onOutputCleared,this),this._runningCells.length=0,this._errorCells.length=0,super.dispose())}setConfiguration(e){const n=this.loadConfigurationFromMetadata();super.setConfiguration({...this.configuration,...n,...e})}toggleCollapse(e){super.toggleCollapse(e),this.updateRunningStatus(this.headings)}async getHeadings(){const e=this.widget.content.widgets,n=new Set(e),s=[],a=new Array,l=new WeakMap;for(let p=0;p<e.length;p++){const i=e[p];switch(i.model.type){case"code":{!this.configuration.syncCollapseState&&this.configuration.includeOutput&&s.push(...Le(await i.getHeadings(),this.configuration,a).map(d=>({...d,cellRef:i,collapsed:!1,isRunning:V.Idle})));break}case"markdown":{const d=Le(await i.getHeadings(),this.configuration,a).map((g,b)=>({...g,cellRef:i,collapsed:!1,isRunning:V.Idle}));if(this.configuration.syncCollapseState&&i.headingCollapsed){const g=Math.min(...d.map(f=>f.level)),b=d.find(f=>f.level===g);b.collapsed=i.headingCollapsed}s.push(...d);break}}s.length>0&&l.set(i,s.length-1)}return this._cellToHeadingIndex=l,this._runningCells=this._runningCells.filter(p=>n.has(p)),this._errorCells=this._errorCells.filter(p=>n.has(p)),this.updateRunningStatus(s),Promise.resolve(s)}isHeadingEqual(e,n){return super.isHeadingEqual(e,n)&&e.cellRef===n.cellRef&&e.isRunning===n.isRunning}loadConfigurationFromMetadata(){const e=this.widget.content.model,n={};if(e)for(const s in this.configMetadataMap){const a=this.configMetadataMap[s];for(const l of a){let p=l;const i=p[0]==="!";i&&(p=p.slice(1));const u=p.split("/");let d=e.getMetadata(u[0]);for(let g=1;g<u.length;g++)d=(d??{})[u[g]];d!==void 0&&(typeof d=="boolean"&&i&&(d=!d),n[s]=d)}}return n}onActiveCellChanged(e,n){const s=this.getCellHeadings(n)[0];this.setActiveHeading(s??null,!1)}onHeadingsChanged(){this.widget.content.activeCell&&this.onActiveCellChanged(this.widget.content,this.widget.content.activeCell)}onExecuted(e,n){this._runningCells.forEach((s,a)=>{var l;if(s===n.cell){this._runningCells.splice(a,1);const p=this._cellToHeadingIndex.get(s);if(p!==void 0){const i=this.headings[p];if(n.success||((l=n.error)===null||l===void 0?void 0:l.errorName)===void 0){i.isRunning=V.Idle;return}i.isRunning=V.Error,this._errorCells.includes(s)||this._errorCells.push(s)}}}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onExecutionScheduled(e,n){this._runningCells.includes(n.cell)||this._runningCells.push(n.cell),this._errorCells.forEach((s,a)=>{s===n.cell&&this._errorCells.splice(a,1)}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onOutputCleared(e,n){this._errorCells.forEach((s,a)=>{if(s===n.cell){this._errorCells.splice(a,1);const l=this._cellToHeadingIndex.get(s);if(l!==void 0){const p=this.headings[l];p.isRunning=V.Idle}}}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onMetadataChanged(){this.setConfiguration({})}updateRunningStatus(e){e.forEach(a=>{a.isRunning=V.Idle}),this._runningCells.forEach((a,l)=>{const p=this._cellToHeadingIndex.get(a);if(p!==void 0){const i=e[p];i.isRunning!==V.Running&&(i.isRunning=l>0?V.Scheduled:V.Running)}}),this._errorCells.forEach((a,l)=>{const p=this._cellToHeadingIndex.get(a);if(p!==void 0){const i=e[p];i.isRunning===V.Idle&&(i.isRunning=V.Error)}});let n=0;for(;n<e.length;){const a=e[n];if(n++,a.collapsed){const l=Math.max(a.isRunning,s(e,a.level));a.dataset={...a.dataset,"data-running":l.toString()}}else a.dataset={...a.dataset,"data-running":a.isRunning.toString()}}function s(a,l){let p=V.Idle;for(;n<a.length;){const i=a[n];if(i.dataset={...i.dataset,"data-running":i.isRunning.toString()},i.level>l)n++,p=Math.max(i.isRunning,p),i.collapsed&&(p=Math.max(p,s(a,i.level)),i.dataset={...i.dataset,"data-running":p.toString()});else break}return p}}}class Qo extends Io{constructor(e,n,s,a){super(e),this.parser=n,this.sanitizer=s,this.commands=a,this._scrollToTop=!0}get scrollToTop(){return this._scrollToTop}set scrollToTop(e){this._scrollToTop=e}_createNew(e,n){const s=new Xo(e,this.parser,this.sanitizer,n);let a=new WeakMap;const l=(_,y)=>{if(y){const w=async h=>{if(!h.inViewport)return;let C=a.get(y);if((!C||!y.cellRef.node.contains(C))&&(await i(h),C=a.get(y)),C)if(this.scrollToTop)C.scrollIntoView({block:"start"}),e.content.outerNode.scrollTop-=Yo;else{const k=e.content.node.getBoundingClientRect(),A=C.getBoundingClientRect();(A.top>k.bottom||A.bottom<k.top)&&C.scrollIntoView({block:"center"})}else console.debug("scrolling to heading: using fallback strategy"),await e.content.scrollToItem(e.content.activeCellIndex,this.scrollToTop?"start":void 0,0)},S=y.cellRef,t=e.content.widgets.indexOf(S);S.model.type=="markdown"&&e.content.mode!="command"&&(e.content.mode="command"),e.content.activeCellIndex=t,S.inViewport?w(S).catch(h=>{console.error(`Fail to scroll to cell to display the required heading (${h}).`)}):e.content.scrollToItem(t,this.scrollToTop?"start":void 0).then(()=>i(S)).then(()=>w(S)).catch(h=>{console.error(`Fail to scroll to cell to display the required heading (${h}).`)})}},p=_=>s.getCellHeadings(_).filter(y=>y.cellRef===_),i=async _=>{var y;const w=p(_),S=(y=this.sanitizer.allowNamedProperties)!==null&&y!==void 0&&y?"id":"data-jupyter-id",o=await Promise.all(w.map(async h=>{const C=await Zo(h,this.parser,this.sanitizer);return C?`h${h.level}[${S}="${CSS.escape(C)}"]`:`h${h.level}`})),t=p(_);t.length!==w.length||t.some((h,C)=>h!==w[C])||(we(_.node),w.forEach((h,C)=>{var k,A;const B=h.outputIndex===void 0?h.cellRef.node:(k=h.cellRef.outputArea.widgets[h.outputIndex])===null||k===void 0?void 0:k.node;a.set(h,B?It(B,o[C],(A=h.prefix)!==null&&A!==void 0?A:""):null)}))},u=_=>{if(this.parser){we(e.content.node),a=new WeakMap;for(const y of e.content.widgets)y instanceof Q&&y.renderedChanged.connect(f);return Promise.all(e.content.widgets.map(y=>i(y)))}},d=(_,y)=>{var w,S,o,t;if(s.configuration.syncCollapseState)if(y!==null){const h=y.cellRef;h.headingCollapsed!==((w=y.collapsed)!==null&&w!==void 0?w:!1)&&(h.headingCollapsed=(S=y.collapsed)!==null&&S!==void 0?S:!1)}else{const h=(t=(o=s.headings[0])===null||o===void 0?void 0:o.collapsed)!==null&&t!==void 0?t:!1;e.content.widgets.forEach(C=>{C instanceof Q&&C.headingInfo.level>=0&&(C.headingCollapsed=h)})}},g=(_,y)=>{if(s.configuration.syncCollapseState){const w=s.getCellHeadings(y)[0];w&&s.toggleCollapse({heading:w,collapsed:y.headingCollapsed})}},b=(_,y)=>{var w;y.inViewport?(w=i(y))===null||w===void 0||w.catch(console.warn):we(y.node)},f=(_,y)=>{y&&i(_).catch(console.warn)};return e.context.ready.then(()=>{var _;(_=u())===null||_===void 0||_.catch(console.warn),s.activeHeadingChanged.connect(l),s.headingsChanged.connect(u),s.collapseChanged.connect(d),e.content.cellCollapsed.connect(g),e.content.cellInViewportChanged.connect(b),e.disposed.connect(()=>{s.activeHeadingChanged.disconnect(l),s.headingsChanged.disconnect(u),s.collapseChanged.disconnect(d),e.content.cellCollapsed.disconnect(g),e.content.cellInViewportChanged.disconnect(b);for(const y of e.content.widgets)y instanceof Q&&y.renderedChanged.disconnect(f)})}),s}getToolbarItems(e){return this.commands?[{name:"select-last-modified-back",widget:new Pe({commands:this.commands,id:"notebook:select-last-modified-cell",args:{toolbar:!0},icon:jt,label:""})},{name:"select-last-modified-forward",widget:new Pe({commands:this.commands,id:"notebook:select-next-modified-cell",args:{toolbar:!0},icon:Rt,label:""})}]:[]}}async function Zo(r,e,n){let s=null;return r.type===We.HeadingType.Markdown?s=await Pt(e,r.raw,r.level,n):r.type===We.HeadingType.HTML&&(s=r.id),s}const en="jp-StatusItem-trust";function tn(r,e){e=e||R;const n=e.load("jupyterlab");return r.trustedCells===r.totalCells?n.__("Notebook trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells):r.activeCellTrusted?n.__("Active cell trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells):n.__("Notebook not trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells)}function on(r){return r.allCellsTrusted?M.createElement(Lt.react,{top:"2px",stylesheet:"statusBar"}):M.createElement(Wt.react,{top:"2px",stylesheet:"statusBar"})}class de extends me{constructor(e){super(new de.Model),this.translator=e||R,this.node.classList.add(en)}render(){if(!this.model)return null;const e=tn(this.model,this.translator);return e!==this.node.title&&(this.node.title=e),M.createElement(on,{allCellsTrusted:this.model.trustedCells===this.model.totalCells,activeCellTrusted:this.model.activeCellTrusted,totalCells:this.model.totalCells,trustedCells:this.model.trustedCells})}}(function(r){class e extends Ce{constructor(){super(...arguments),this._trustedCells=0,this._totalCells=0,this._activeCellTrusted=!1,this._notebook=null}get trustedCells(){return this._trustedCells}get totalCells(){return this._totalCells}get activeCellTrusted(){return this._activeCellTrusted}get notebook(){return this._notebook}set notebook(s){const a=this._notebook;a!==null&&(a.activeCellChanged.disconnect(this._onActiveCellChanged,this),a.modelContentChanged.disconnect(this._onModelChanged,this));const l=this._getAllState();if(this._notebook=s,this._notebook===null)this._trustedCells=0,this._totalCells=0,this._activeCellTrusted=!1;else{this._notebook.activeCellChanged.connect(this._onActiveCellChanged,this),this._notebook.modelContentChanged.connect(this._onModelChanged,this),this._notebook.activeCell?this._activeCellTrusted=this._notebook.activeCell.model.trusted:this._activeCellTrusted=!1;const{total:p,trusted:i}=this._deriveCellTrustState(this._notebook.model);this._totalCells=p,this._trustedCells=i}this._triggerChange(l,this._getAllState())}_onModelChanged(s){const a=this._getAllState(),{total:l,trusted:p}=this._deriveCellTrustState(s.model);this._totalCells=l,this._trustedCells=p,this._triggerChange(a,this._getAllState())}_onActiveCellChanged(s,a){const l=this._getAllState();a?this._activeCellTrusted=a.model.trusted:this._activeCellTrusted=!1,this._triggerChange(l,this._getAllState())}_deriveCellTrustState(s){if(s===null)return{total:0,trusted:0};let a=0,l=0;for(const p of s.cells)p.type==="code"&&(a++,p.trusted&&l++);return{total:a,trusted:l}}_getAllState(){return[this._trustedCells,this._totalCells,this.activeCellTrusted]}_triggerChange(s,a){(s[0]!==a[0]||s[1]!==a[1]||s[2]!==a[2])&&this.stateChanged.emit(void 0)}}r.Model=e})(de||(de={}));const nn=new ot("@jupyterlab/metadataform:IMetadataFormProvider","A service to register new metadata editor widgets."),ln={id:"@jupyterlab/notebook-extension:cell-executor",description:"Provides the notebook cell executor.",autoStart:!0,provides:lt,activate:()=>Object.freeze({runCell:Ht})},sn=new ot("@jupyterlab/logconsole:ILoggerRegistry","A service providing a logger infrastructure."),rn={activate:an,id:"@jupyterlab/notebook-extension:log-output",description:"Adds cell outputs log to the application logger.",requires:[L],optional:[sn],autoStart:!0};function an(r,e,n){if(!n)return;function s(a){function l(p,i,u){if(Y.KernelMessage.isDisplayDataMsg(p)||Y.KernelMessage.isStreamMsg(p)||Y.KernelMessage.isErrorMsg(p)||Y.KernelMessage.isExecuteResultMsg(p)){const d=n.getLogger(a.context.path);d.rendermime=a.content.rendermime;const g={...p.content,output_type:p.header.msg_type};let b=i;(Y.KernelMessage.isErrorMsg(p)||Y.KernelMessage.isStreamMsg(p)&&p.content.name==="stderr")&&(b=u),d.log({type:"output",data:g,level:b})}}a.context.sessionContext.iopubMessage.connect((p,i)=>l(i,"info","info"),a),a.context.sessionContext.unhandledMessage.connect((p,i)=>l(i,"warning","error"),a)}e.forEach(a=>s(a)),e.widgetAdded.connect((a,l)=>s(l))}const dn="jp-ActiveCellTool",cn="jp-ActiveCellTool-Content",un="jp-ActiveCellTool-CellContent";class hn extends q.Tool{constructor(e){super(),this._cellModel=null,this._updateId=0,this._pendingUpdate=!1,this._promptOutdated=!1,this._tracker=e.tracker,this._languages=e.languages,this.addClass(dn),this.layout=new be,this._inputPrompt=new Ft,this.layout.addWidget(this._inputPrompt);const n=document.createElement("div");n.classList.add(cn);const s=n.appendChild(document.createElement("div")),a=s.appendChild(document.createElement("pre"));s.className=un,this._editorEl=a,this.layout.addWidget(new ee({node:n})),this._previewDebouncer=new Kt(()=>this._update(),150),this._tracker.activeCellChanged.connect(this._onActiveCellChanged,this),this._tracker.currentChanged.connect(this._onActiveCellChanged,this),this._onActiveCellChanged()}dispose(){this.isDisposed||(this._tracker.activeCellChanged.disconnect(this._onActiveCellChanged,this),this._tracker.currentChanged.disconnect(this._onActiveCellChanged,this),this._disconnectCellModel(),this._previewDebouncer.dispose(),super.dispose())}render(e){return M.createElement("div",{ref:n=>{!n||this.node.parentElement===n||(n.appendChild(this.node),this._pendingUpdate&&this._update().catch(console.warn))}})}_onActiveCellChanged(){var e,n;const s=(n=(e=this._tracker.activeCell)===null||e===void 0?void 0:e.model)!==null&&n!==void 0?n:null;s!==this._cellModel&&(this._disconnectCellModel(),this._cellModel=s,s&&(s.sharedModel.changed.connect(this._onCellContentChanged,this),s.mimeTypeChanged.connect(this._onCellContentChanged,this)),this._promptOutdated=!0,this._update().catch(console.warn))}_onCellContentChanged(){if(!this.node.isConnected){this._pendingUpdate=!0,this._promptOutdated=!0;return}this._promptOutdated||this._updatePrompt(),this._previewDebouncer.invoke().catch(console.warn)}_disconnectCellModel(){const e=this._cellModel;e&&(e.sharedModel.changed.disconnect(this._onCellContentChanged,this),e.mimeTypeChanged.disconnect(this._onCellContentChanged,this),this._cellModel=null)}_updatePrompt(){var e;const n=this._cellModel;n&&Vt(n)?(this._inputPrompt.executionCount=`${(e=n.executionCount)!==null&&e!==void 0?e:""}`,this._inputPrompt.show()):(this._inputPrompt.executionCount=null,this._inputPrompt.hide())}async _update(){if(!this.node.isConnected){this._pendingUpdate=!0;return}this._pendingUpdate=!1;const e=this._cellModel,n=++this._updateId;if(!e){this._promptOutdated=!1,this._updatePrompt(),this._editorEl.replaceChildren();return}const s=e.sharedModel.getSource(),a=s.indexOf(`
|
|
2
2
|
`),l=a===-1?s:s.slice(0,a),p=document.createElement("pre");try{await this._languages.highlight(l,this._languages.findByMIME(e.mimeType),p)}catch(u){console.warn(u),p.replaceChildren(document.createTextNode(l))}if(n!==this._updateId)return;this._promptOutdated&&(this._updatePrompt(),this._promptOutdated=!1);const i=document.createDocumentFragment();for(;p.firstChild;)i.appendChild(p.firstChild);this._editorEl.replaceChildren(i)}}const pn="jp-CellMetadataEditor",gn="jp-NotebookMetadataEditor";class mn extends q.MetadataEditorTool{constructor(e){super(e),this._tracker=e.tracker,this.editor.editorHostNode.addEventListener("blur",this.editor,!0),this.editor.editorHostNode.addEventListener("click",this.editor,!0),this.editor.headerNode.addEventListener("click",this.editor)}_onSourceChanged(){var e,n,s;const a=(e=this._tracker.activeCell)===null||e===void 0?void 0:e.model.sharedModel;if(a&&this.editor.source){const l=Object.keys((n=a.metadata)!==null&&n!==void 0?n:{}),p=(s=this.editor.source.toJSON())!==null&&s!==void 0?s:{};a.transact(()=>{l.forEach(i=>a.deleteMetadata(i)),a.setMetadata(p)})}}render(e){var n;const s=this._tracker.activeCell,a=this.editor.source;return this.editor.source=s?new ge({values:s.model.metadata}):null,a?.dispose(),(n=this.editor.source)===null||n===void 0||n.changed.connect(this._onSourceChanged,this),M.createElement("div",{className:pn},M.createElement("div",{ref:l=>l?.appendChild(this.node)}))}}class Cn extends q.MetadataEditorTool{constructor(e){super(e),this._tracker=e.tracker,this.editor.editorHostNode.addEventListener("blur",this.editor,!0),this.editor.editorHostNode.addEventListener("click",this.editor,!0),this.editor.headerNode.addEventListener("click",this.editor)}_onSourceChanged(){var e,n;this.editor.source&&((n=(e=this._tracker.currentWidget)===null||e===void 0?void 0:e.model)===null||n===void 0||n.sharedModel.setMetadata(this.editor.source.toJSON()))}render(e){var n,s;const a=this._tracker.currentWidget,l=this.editor.source;return this.editor.source=a?new ge({values:(n=a.model)===null||n===void 0?void 0:n.metadata}):null,l?.dispose(),(s=this.editor.source)===null||s===void 0||s.changed.connect(this._onSourceChanged,this),M.createElement("div",{className:gn},M.createElement("div",{ref:p=>p?.appendChild(this.node)}))}}var c;(function(r){r.createNew="notebook:create-new",r.interrupt="notebook:interrupt-kernel",r.restart="notebook:restart-kernel",r.restartClear="notebook:restart-clear-output",r.restartAndRunToSelected="notebook:restart-and-run-to-selected",r.restartRunAll="notebook:restart-run-all",r.reconnectToKernel="notebook:reconnect-to-kernel",r.changeKernel="notebook:change-kernel",r.getKernel="notebook:get-kernel",r.createConsole="notebook:create-console",r.createSubshellConsole="notebook:create-subshell-console",r.createOutputView="notebook:create-output-view",r.clearAllOutputs="notebook:clear-all-cell-outputs",r.shutdown="notebook:shutdown-kernel",r.closeAndShutdown="notebook:close-and-shutdown",r.trust="notebook:trust",r.exportToFormat="notebook:export-to-format",r.run="notebook:run-cell",r.runAndAdvance="notebook:run-cell-and-select-next",r.runAndInsert="notebook:run-cell-and-insert-below",r.runInConsole="notebook:run-in-console",r.runAll="notebook:run-all-cells",r.runAllAbove="notebook:run-all-above",r.runAllBelow="notebook:run-all-below",r.renderAllMarkdown="notebook:render-all-markdown",r.toCode="notebook:change-cell-to-code",r.toMarkdown="notebook:change-cell-to-markdown",r.toRaw="notebook:change-cell-to-raw",r.cut="notebook:cut-cell",r.copy="notebook:copy-cell",r.pasteAbove="notebook:paste-cell-above",r.pasteBelow="notebook:paste-cell-below",r.duplicateBelow="notebook:duplicate-below",r.pasteAndReplace="notebook:paste-and-replace-cell",r.moveUp="notebook:move-cell-up",r.moveDown="notebook:move-cell-down",r.clearOutputs="notebook:clear-cell-output",r.deleteCell="notebook:delete-cell",r.insertAbove="notebook:insert-cell-above",r.insertBelow="notebook:insert-cell-below",r.selectAbove="notebook:move-cursor-up",r.selectBelow="notebook:move-cursor-down",r.selectHeadingAboveOrCollapse="notebook:move-cursor-heading-above-or-collapse",r.selectHeadingBelowOrExpand="notebook:move-cursor-heading-below-or-expand",r.insertHeadingAbove="notebook:insert-heading-above",r.insertHeadingBelow="notebook:insert-heading-below",r.extendAbove="notebook:extend-marked-cells-above",r.extendTop="notebook:extend-marked-cells-top",r.extendBelow="notebook:extend-marked-cells-below",r.extendBottom="notebook:extend-marked-cells-bottom",r.selectAll="notebook:select-all",r.deselectAll="notebook:deselect-all",r.editMode="notebook:enter-edit-mode",r.merge="notebook:merge-cells",r.mergeAbove="notebook:merge-cell-above",r.mergeBelow="notebook:merge-cell-below",r.split="notebook:split-cell-at-cursor",r.commandMode="notebook:enter-command-mode",r.toggleAllLines="notebook:toggle-all-cell-line-numbers",r.undoCellAction="notebook:undo-cell-action",r.redoCellAction="notebook:redo-cell-action",r.redo="notebook:redo",r.undo="notebook:undo",r.markdown1="notebook:change-cell-to-heading-1",r.markdown2="notebook:change-cell-to-heading-2",r.markdown3="notebook:change-cell-to-heading-3",r.markdown4="notebook:change-cell-to-heading-4",r.markdown5="notebook:change-cell-to-heading-5",r.markdown6="notebook:change-cell-to-heading-6",r.hideCode="notebook:hide-cell-code",r.showCode="notebook:show-cell-code",r.hideAllCode="notebook:hide-all-cell-code",r.showAllCode="notebook:show-all-cell-code",r.hideOutput="notebook:hide-cell-outputs",r.showOutput="notebook:show-cell-outputs",r.toggleOutput="notebook:toggle-cell-outputs",r.hideAllOutputs="notebook:hide-all-cell-outputs",r.showAllOutputs="notebook:show-all-cell-outputs",r.toggleRenderSideBySideCurrentNotebook="notebook:toggle-render-side-by-side-current",r.setSideBySideRatio="notebook:set-side-by-side-ratio",r.enableOutputScrolling="notebook:enable-output-scrolling",r.disableOutputScrolling="notebook:disable-output-scrolling",r.toggleOutputScrolling="notebook:toggle-output-scrolling",r.selectLastRunCell="notebook:select-last-run-cell",r.selectLastModifiedCell="notebook:select-last-modified-cell",r.selectNextModifiedCell="notebook:select-next-modified-cell",r.replaceSelection="notebook:replace-selection",r.autoClosingBrackets="notebook:toggle-autoclosing-brackets",r.toggleCollapseCmd="notebook:toggle-heading-collapse",r.collapseAllCmd="notebook:collapse-all-headings",r.expandAllCmd="notebook:expand-all-headings",r.copyToClipboard="notebook:copy-to-clipboard",r.invokeCompleter="completer:invoke-notebook",r.selectCompleter="completer:select-notebook",r.tocRunCells="toc:run-cells",r.accessPreviousHistory="notebook:access-previous-history-entry",r.accessNextHistory="notebook:access-next-history-entry",r.virtualScrollbar="notebook:toggle-virtual-scrollbar",r.copySelectedtext="notebook:copy-selected-text",r.pasteText="notebook:paste-text",r.cutSelectedtext="notebook:cut-selected-text"})(c||(c={}));const D="Notebook",bn=["notebook","python","custom"],fn="@jupyterlab/notebook-extension:panel",Ve="jp-NotebookExtension-sideBySideMargins",te={id:"@jupyterlab/notebook-extension:tracker",description:"Provides the notebook widget tracker.",provides:L,requires:[st,uo,lt],optional:[$e,mo,Co,at,dt,bo,_e,Je,F,Ee,rt],activate:qn,autoStart:!0},vn={id:"@jupyterlab/notebook-extension:factory",description:"Provides the notebook and cell factory.",provides:Se.IContentFactory,requires:[fe],autoStart:!0,activate:(r,e)=>{const n=e.factoryService.newInlineEditor;return new Se.ContentFactory({editorFactory:n})}},_n={activate:Hn,provides:go,id:"@jupyterlab/notebook-extension:tools",description:"Provides the notebook tools.",autoStart:!0,requires:[L,fe,it,Ut.IStateDB,F],optional:[po]},yn={id:"@jupyterlab/notebook-extension:mode-status",description:"Adds a notebook mode status widget.",autoStart:!0,requires:[L,F],optional:[ve],activate:(r,e,n,s)=>{if(!s)return;const{shell:a}=r,l=new ae(n);e.currentChanged.connect(()=>{const p=e.currentWidget;l.model.notebook=p&&p.content}),s.registerStatusItem("@jupyterlab/notebook-extension:mode-status",{priority:1,item:l,align:"right",rank:4,isActive:()=>!!a.currentWidget&&!!e.currentWidget&&a.currentWidget===e.currentWidget})}},ct={id:"@jupyterlab/notebook-extension:cell-counter-status",description:"Adds a notebook cell counter status widget.",autoStart:!0,requires:[L,F],optional:[ve],activate:(r,e,n,s)=>{if(!s)return;const{shell:a}=r,l=new re({translator:n}),p=()=>{const i=e.currentWidget;l.model.notebook=i&&i.content};e.currentChanged.connect(p),p(),s.registerStatusItem(ct.id,{priority:1,item:l,align:"right",rank:2.5,isActive:()=>!!a.currentWidget&&!!e.currentWidget&&a.currentWidget===e.currentWidget})}},xn={id:"@jupyterlab/notebook-extension:execution-indicator",description:"Adds a notebook execution status widget.",autoStart:!0,requires:[L,fo,F],optional:[ve,_e],activate:(r,e,n,s,a,l)=>{let p,i,u;const d=g=>{var b,f;let{showOnToolBar:_,showProgress:y,showJumpToCell:w}=g;if(_)u&&(n.currentChanged.disconnect(i),u.dispose());else{if(!a)return;p?.model||(p=new X(s),i=(S,o)=>{const{newValue:t}=o;if(t&&e.has(t)){const h=t;p.model.attachNotebook({content:h.content,context:h.sessionContext})}},u=a.registerStatusItem("@jupyterlab/notebook-extension:execution-indicator",{item:p,align:"left",rank:3,isActive:()=>{const S=n.currentWidget;return!!S&&e.has(S)}}),p.model.attachNotebook({content:(b=e.currentWidget)===null||b===void 0?void 0:b.content,context:(f=e.currentWidget)===null||f===void 0?void 0:f.sessionContext}),n.currentChanged.connect(i),p.disposed.connect(()=>{n.currentChanged.disconnect(i)})),p.model.displayOption={showOnToolBar:_,showProgress:y,showJumpToCell:w}}};if(l){const g=l.load(te.id);Promise.all([g,r.restored]).then(([b])=>{d(X.getSettingValue(b)),b.changed.connect(f=>d(X.getSettingValue(f)))}).catch(b=>{console.error(b.message)})}}},wn={id:"@jupyterlab/notebook-extension:export",description:"Adds the export notebook commands.",autoStart:!0,requires:[F,L],optional:[dt,$e],activate:(r,e,n,s,a)=>{var l;const p=e.load("jupyterlab"),{commands:i,shell:u}=r,d=r.serviceManager,g=()=>H.isEnabled(u,n);i.addCommand(c.exportToFormat,{label:y=>{if(y.label===void 0)return p.__("Save and Export Notebook to the given `format`.");const w=y.label;return y.isPalette?p.__("Save and Export Notebook: %1",w):w},execute:async y=>{var w,S,o;const t=m(n,u,y);if(!t)return;const{context:h}=t,C=pe.PageConfig.getNotebookVersion(),k=pe.compareVersions(C,[4,0,0])<0&&pe.compareVersions(C,[2,18,0])>=0;let A=!1;if(y.format==="html"&&k){const E=await Ge.getBoolean({title:p.__("Export as HTML"),label:p.__("Sanitize HTML output"),value:!0});if(!E.button.accept)return;A=(w=E.value)!==null&&w!==void 0?w:!1}const B={format:y.format,path:t.context.path,exporterOptions:{download:!0,sanitizeHtml:A}};return h.model.dirty&&!h.model.readOnly&&await h.save(),(o=(S=d.nbconvert).exportAs)===null||o===void 0?void 0:o.call(S,B)},isEnabled:g,describedBy:{args:{type:"object",properties:{format:{type:"string",description:p.__("The export format (e.g., pdf, html, latex)")},label:{type:"string",description:p.__("The label to display for this format")},isPalette:{type:"boolean",description:p.__("Whether the command is called from the command palette")}},required:["format"]}}});let b;s&&(b=(l=s.fileMenu.items.find(y=>{var w;return y.type==="submenu"&&((w=y.submenu)===null||w===void 0?void 0:w.id)==="jp-mainmenu-file-notebookexport"}))===null||l===void 0?void 0:l.submenu);let f=!1;const _=async()=>{if(f)return;n.widgetAdded.disconnect(_),f=!0;const y=await d.nbconvert.getExportFormats(!1);if(!y)return;const w=H.getFormatLabels(e);Object.keys(y).forEach(function(o){const t=o[0].toLocaleUpperCase()+o.slice(1),h=p.__(t),C=w[o]?w[o]:h;let k={format:o,label:C,isPalette:!1};if(bn.indexOf(o)===-1&&(b&&b.addItem({command:c.exportToFormat,args:k}),a)){k={format:o,label:C,isPalette:!0};const A=p.__("Notebook Operations");a.addItem({command:c.exportToFormat,category:A,args:k})}})};n.widgetAdded.connect(_)}},kn={id:"@jupyterlab/notebook-extension:trust-status",description:"Adds the notebook trusted status widget.",autoStart:!0,requires:[L,F],optional:[ve],activate:(r,e,n,s)=>{if(!s)return;const{shell:a}=r,l=new de(n);e.currentChanged.connect(()=>{const p=e.currentWidget;l.model.notebook=p&&p.content}),s.registerStatusItem("@jupyterlab/notebook-extension:trust-status",{item:l,align:"right",rank:3,isActive:()=>!!a.currentWidget&&!!e.currentWidget&&a.currentWidget===e.currentWidget})}},Sn={id:"@jupyterlab/notebook-extension:widget-factory",description:"Provides the notebook widget factory.",provides:st,requires:[Se.IContentFactory,fe,vo,pt],optional:[_e,Je,F],activate:Fn,autoStart:!0},An={id:"@jupyterlab/notebook-extension:cloned-outputs",description:"Adds the clone output feature.",requires:[yo,L,F],optional:[at],activate:Kn,autoStart:!0},Mn={id:"@jupyterlab/notebook-extension:code-console",description:"Adds the notebook code consoles features.",requires:[L,F],activate:Vn,autoStart:!0},Tn={id:"@jupyterlab/notebook-extension:copy-output",description:"Adds the copy cell outputs feature.",activate:Un,requires:[F,L],autoStart:!0},Bn={id:"@jupyterlab/notebook-extension:kernel-status",description:"Adds the notebook kernel status.",activate:(r,e,n)=>{const s=a=>{let l=null;return a&&e.has(a)?a.sessionContext:l};n.addSessionProvider(s)},requires:[L,gt],autoStart:!0},En={id:"@jupyterlab/notebook-extension:cursor-position",description:"Adds the notebook cursor position status.",activate:(r,e,n)=>{let s=null;const a=async l=>{let p=null;if(l!==s){if(s?.content.activeCellChanged.disconnect(n.update),s=null,l&&e.has(l)){l.content.activeCellChanged.connect(n.update);const i=l.content.activeCell;p=null,i&&(await i.ready,p=i.editor),s=l}}else if(l){const i=l.content.activeCell;p=null,i&&(await i.ready,p=i.editor)}return p};n.addEditorProvider(a)},requires:[L,qt],autoStart:!0},Nn={id:"@jupyterlab/notebook-extension:completer",description:"Adds the code completion capability to notebooks.",requires:[L],optional:[xo,F,ze],activate:Dn,autoStart:!0},On={id:"@jupyterlab/notebook-extension:search",description:"Adds search capability to notebooks.",requires:[wo],autoStart:!0,activate:(r,e)=>{e.add("jp-notebookSearchProvider",Qt)}},jn={id:"@jupyterlab/notebook-extension:toc",description:"Adds table of content capability to the notebooks",requires:[L,Dt,ze],optional:[_o,_e],autoStart:!0,activate:(r,e,n,s,a,l)=>{const p=new Qo(e,a,s,r.commands);n.add(p),l&&Promise.all([r.restored,l.load(te.id)]).then(([i,u])=>{const d=()=>{var g;p.scrollToTop=(g=u.composite.scrollHeadingToTop)!==null&&g!==void 0?g:!0};d(),u.changed.connect(d)}).catch(i=>{console.error("Failed to load notebook table of content settings.",i)})}},Rn={id:"@jupyterlab/notebook-extension:language-server",description:"Adds language server capability to the notebooks.",requires:[L,Ao,Mo,To,Bo],activate:$n,autoStart:!0},In={id:"@jupyterlab/notebook-extension:update-raw-mimetype",description:"Adds metadata form editor for raw cell mimetype.",autoStart:!0,requires:[L,nn,F],activate:(r,e,n,s)=>{const a=s.load("jupyterlab");let l=!1;async function p(){if(l||!n.get("commonToolsSection"))return;const i=n.get("commonToolsSection").getProperties("/raw_mimetype");if(!i)return;e.widgetAdded.disconnect(p),l=!0;const d=await r.serviceManager.nbconvert.getExportFormats(!1);if(!d)return;const g=Object.keys(d),b=H.getFormatLabels(s);g.forEach(function(f){var _;if(!(((_=i.oneOf)===null||_===void 0?void 0:_.filter(w=>w.const===f).length)>0)){const w=f[0].toLocaleUpperCase()+f.slice(1),S=a.__(w),o=b[f]?b[f]:S,t=d[f].output_mimetype;i.oneOf.push({const:t,title:o})}}),n.get("commonToolsSection").setProperties("/raw_mimetype",i)}e.widgetAdded.connect(p)}},Pn={id:"@jupyterlab/notebook-extension:metadata-editor",description:"Adds metadata form for full metadata editor.",autoStart:!0,requires:[L,fe,Ee],optional:[F],activate:(r,e,n,s,a)=>{const l=g=>n.factoryService.newInlineEditor(g),p=new mn({editorFactory:l,tracker:e,label:"Cell metadata",translator:a}),i={fieldRenderer:g=>p.render(g)};s.addRenderer("@jupyterlab/notebook-extension:metadata-editor.cell-metadata",i);const u=new Cn({editorFactory:l,tracker:e,label:"Notebook metadata",translator:a}),d={fieldRenderer:g=>u.render(g)};s.addRenderer("@jupyterlab/notebook-extension:metadata-editor.notebook-metadata",d)}},Ln={id:"@jupyterlab/notebook-extension:active-cell-tool",description:"Adds active cell field in the metadata editor tab.",autoStart:!0,requires:[L,Ee,it],activate:(r,e,n,s)=>{const a=new hn({tracker:e,languages:s}),l={fieldRenderer:p=>a.render(p)};n.addRenderer("@jupyterlab/notebook-extension:active-cell-tool.renderer",l)}},Wn={id:"@jupyterlab/notebook-extension:open-with-no-kernel",description:'Adds the "Notebook (no kernel)" option to the Open With menu.',requires:[rt],optional:[F],autoStart:!0,activate:(r,e,n)=>{const{tracker:s}=e,a=(n??R).load("jupyterlab"),l=[];function p(i){var u,d;l.forEach(_=>_.dispose()),l.length=0;const g=(d=(u=i.menu.items.find(_=>{var y;return _.type==="submenu"&&((y=_.submenu)===null||y===void 0?void 0:y.id)==="jp-contextmenu-open-with"}))===null||u===void 0?void 0:u.submenu)!==null&&d!==void 0?d:null;if(!g)return;(s.currentWidget?Array.from(s.currentWidget.selectedItems()):[]).some(_=>_.type==="notebook")&&l.push(g.addItem({command:"filebrowser:open",args:{label:a.__("Notebook (no kernel)"),factory:D,kernelPreference:{shouldStart:!1,shouldReuse:!1}}}))}r.contextMenu.opened.connect(p)}},cl=[ln,vn,te,xn,wn,_n,ct,yn,kn,Sn,rn,An,Mn,Tn,Bn,En,Nn,On,jn,Rn,In,Pn,Ln,Wn];function Hn(r,e,n,s,a,l,p){const i=l.load("jupyterlab"),u="notebook-tools",d=new q({tracker:e,translator:l}),g=(b,f)=>{switch(f.type){case"activate-request":a.save(u,{open:!0});break;case"after-hide":case"close-request":a.remove(u);break}return!0};return d.title.icon=Jt,d.title.dataset={...d.title.dataset,jpTabLabel:i.__("Notebook Tools")},d.title.caption=i.__("Notebook Tools"),d.id=u,G.installMessageHook(d,g),p&&e.widgetAdded.connect((b,f)=>{p.register(f).render(d)}),d}function Fn(r,e,n,s,a,l,p,i){const u=i??R,d=p??new Be({translator:u}),g=pe.PageConfig.getOption("notebookStartsKernel"),b=g===""||g.toLowerCase()==="true",{commands:f}=r;let _;a.addFactory(D,"save",S=>ho.createSaveButton(f,S.context.fileChanged)),a.addFactory(D,"cellType",S=>Ae.createCellTypeItem(S,u)),a.addFactory(D,"kernelName",S=>he.createKernelNameItem(S.sessionContext,d,u)),a.addFactory(D,"executionProgress",S=>{const o=l?.load(te.id),t=X.createExecutionIndicatorItem(S,u,o);return o?.then(h=>{S.disposed.connect(()=>{h.dispose()})}),t}),l&&(_=zt(a,l,D,fn,u));const y=u.load("jupyterlab"),w=new jo({name:D,label:y.__("Notebook"),fileTypes:["notebook"],modelName:"notebook",defaultFor:["notebook"],preferKernel:b,canStartKernel:!0,rendermime:s,contentFactory:e,editorConfig:se.defaultEditorConfig,notebookConfig:se.defaultNotebookConfig,mimeTypeService:n.mimeTypeService,toolbarFactory:_,translator:u});return r.docRegistry.addWidgetFactory(w),w}function Kn(r,e,n,s,a){const l=s.load("jupyterlab"),p=new Gt({namespace:"cloned-outputs"});a&&a.restore(p,{command:c.createOutputView,args:g=>({path:g.content.path,index:g.content.index}),name:g=>`${g.content.path}:${g.content.index}`,when:n.restored});const{commands:i,shell:u}=r,d=()=>H.isEnabledAndSingleSelected(u,n);i.addCommand(c.createOutputView,{label:l.__("Create New View for Cell Output"),execute:async g=>{var b;let f,_;const y=g.path;let w=g.index;if(y&&w!==void 0&&w!==null){if(_=e.findWidget(y,D),!_)return}else{if(_=n.currentWidget,!_)return;f=_.content.activeCell,w=_.content.activeCellIndex}const S=new H.ClonedOutputArea({notebook:_,cell:f,index:w,translator:s}),o=new Yt({content:S});_.context.addSibling(o,{ref:_.id,mode:"split-bottom",type:"Cloned Output"});const t=()=>{p.save(o)};_.context.pathChanged.connect(t),(b=_.context.model)===null||b===void 0||b.cells.changed.connect(t),p.add(o),_.content.disposed.connect(()=>{var h;_.context.pathChanged.disconnect(t),(h=_.context.model)===null||h===void 0||h.cells.changed.disconnect(t),o.dispose()})},isEnabled:d,describedBy:{args:{type:"object",properties:{path:{type:"string",description:l.__("The path to the notebook containing the cell")},index:{type:"number",description:l.__("The index of the cell to create an output view for")}}}}})}function Vn(r,e,n){const s=n.load("jupyterlab"),{commands:a,shell:l}=r,p=()=>H.isEnabled(l,e);a.addCommand(c.createConsole,{label:s.__("New Console for Notebook"),execute:i=>{const u=e.currentWidget;if(u)return H.createConsole(a,u,i.activate)},isEnabled:p,describedBy:{args:{type:"object",properties:{activate:{type:"boolean",description:s.__("Whether to activate the console after creation")}}}}}),a.addCommand(c.createSubshellConsole,{label:s.__("New Subshell Console for Notebook"),execute:i=>{const u=e.currentWidget;if(u)return H.createConsole(a,u,i.activate,!0)},isEnabled:p,isVisible:()=>{var i,u,d;const g=(u=(i=e.currentWidget)===null||i===void 0?void 0:i.context.sessionContext.session)===null||u===void 0?void 0:u.kernel;return(d=g?.supportsSubshells)!==null&&d!==void 0?d:!1},describedBy:{args:{type:"object",properties:{activate:{type:"boolean",description:s.__("Whether to activate the console after creation")}}}}}),a.addCommand(c.runInConsole,{label:s.__("Run Selected Text or Current Line in Console"),execute:async i=>{var u,d;const g=e.currentWidget;if(!g)return;const{context:b,content:f}=g,_=f.activeCell,y=_?.model.metadata,w=b.path;if(!_||_.model.type!=="code")return;let S;const o=_.editor;if(!o)return;const t=o.getSelection(),{start:h,end:C}=t;if(h.column!==C.column||h.line!==C.line){const A=o.getOffsetAt(t.start),B=o.getOffsetAt(t.end);S=o.model.sharedModel.getSource().substring(A,B)}else{const A=o.getCursorPosition(),B=o.model.sharedModel.getSource().split(`
|
|
3
3
|
`);let E=t.start.line;for(;E<o.lineCount&&!B[E].replace(/\s/g,"").length;)E+=1;let j=E>0,K=0,W=K+1;for(;;){S=B.slice(K,W).join(`
|
|
4
4
|
`);const oe=await((d=(u=g.context.sessionContext.session)===null||u===void 0?void 0:u.kernel)===null||d===void 0?void 0:d.requestIsComplete({code:S+`
|