@datalayer/agent-runtimes 1.3.114 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-embed/chunks/ChatView-CaBuPTyG.js +32 -0
- package/dist-embed/chunks/{DeckComponent-CuRWiARr.js → DeckComponent-cRJJMGgt.js} +1 -1
- package/dist-embed/chunks/{DocumentView-BYU2HREd.js → DocumentView-CiqN9ze6.js} +1 -1
- package/dist-embed/chunks/{EphemeralDocument-BjFSuQKH.js → EphemeralDocument-BjJfn7J-.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawComponent-CFLnMPnf.js → ExcalidrawComponent-BtNXWUN8.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawModal-CB9d5Vpk.js → ExcalidrawModal-C6SEKFlD.js} +1 -1
- package/dist-embed/chunks/{JupyterLexicalExtension-CYnZrelh.js → JupyterLexicalExtension-BuRLImy5.js} +5 -5
- package/dist-embed/chunks/{NotebookToolSurfaces-D62q-lbb.js → NotebookToolSurfaces-ktcGRm7d.js} +1 -1
- package/dist-embed/chunks/{Output-2KxoKu5F.js → Output-BscOPLqE.js} +10 -10
- package/dist-embed/chunks/{YouTubePlugin-CjODyxZ2.js → YouTubePlugin-xBjNr2Iu.js} +1 -1
- package/dist-embed/chunks/{ar-SA-G6X2FPQ2-C-zAYgA-.js → ar-SA-G6X2FPQ2-BB82iKLz.js} +1 -1
- package/dist-embed/chunks/{az-AZ-76LH7QW2-BHq5js6U.js → az-AZ-76LH7QW2-DsMRKXlw.js} +1 -1
- package/dist-embed/chunks/{bg-BG-XCXSNQG7-BTcNNcTc.js → bg-BG-XCXSNQG7-43Y1kPxa.js} +1 -1
- package/dist-embed/chunks/{bn-BD-2XOGV67Q-DXRk27u1.js → bn-BD-2XOGV67Q-CLqPJBll.js} +1 -1
- package/dist-embed/chunks/{ca-ES-6MX7JW3Y-D-0J9rqp.js → ca-ES-6MX7JW3Y-CDFGSEh3.js} +1 -1
- package/dist-embed/chunks/{cs-CZ-2BRQDIVT-CgN3I-57.js → cs-CZ-2BRQDIVT-ByNB8eZd.js} +1 -1
- package/dist-embed/chunks/{da-DK-5WZEPLOC-CHQloSoX.js → da-DK-5WZEPLOC-B7MrVwy8.js} +1 -1
- package/dist-embed/chunks/{de-DE-XR44H4JA-C-Hq84pe.js → de-DE-XR44H4JA-CN1cdk94.js} +1 -1
- package/dist-embed/chunks/{el-GR-BZB4AONW-MTzGcSsP.js → el-GR-BZB4AONW-DnaGhWD1.js} +1 -1
- package/dist-embed/chunks/{es-ES-U4NZUMDT-Thj-4Rwn.js → es-ES-U4NZUMDT-DE1vZzDE.js} +1 -1
- package/dist-embed/chunks/{eu-ES-A7QVB2H4-BEEyNQo-.js → eu-ES-A7QVB2H4-DmHB0zpm.js} +1 -1
- package/dist-embed/chunks/{fa-IR-HGAKTJCU-CtUGmNBZ.js → fa-IR-HGAKTJCU-CNzE8tJj.js} +1 -1
- package/dist-embed/chunks/{fi-FI-Z5N7JZ37-6GMgpkSu.js → fi-FI-Z5N7JZ37-Ca2vTFQC.js} +1 -1
- package/dist-embed/chunks/{fr-FR-RHASNOE6-BakNCbxj.js → fr-FR-RHASNOE6-B0yWFX3_.js} +1 -1
- package/dist-embed/chunks/{gl-ES-HMX3MZ6V-Cwkb9OPk.js → gl-ES-HMX3MZ6V-2_3FMVJq.js} +1 -1
- package/dist-embed/chunks/{he-IL-6SHJWFNN-BaMmvCkr.js → he-IL-6SHJWFNN-BW1lby00.js} +1 -1
- package/dist-embed/chunks/{hi-IN-IWLTKZ5I-1aWewhep.js → hi-IN-IWLTKZ5I-DTixfSwB.js} +1 -1
- package/dist-embed/chunks/{hu-HU-A5ZG7DT2-BIHI23BQ.js → hu-HU-A5ZG7DT2-DOfYwLWP.js} +1 -1
- package/dist-embed/chunks/{id-ID-SAP4L64H-CYpgmx8X.js → id-ID-SAP4L64H-Cwtdtkvg.js} +1 -1
- package/dist-embed/chunks/{index-BhSMzuKq.js → index--qMT5k1q.js} +1 -1
- package/dist-embed/chunks/{index-b1yzCiTq.js → index-B-UP9DlM.js} +1 -1
- package/dist-embed/chunks/{index-DMKsCn-y.js → index-BAwsCLGT.js} +1 -1
- package/dist-embed/chunks/{index-BUhqZVtg.js → index-BITOMOWN.js} +1 -1
- package/dist-embed/chunks/{index-1wTrAXI1.js → index-B_9UD0bt.js} +2 -2
- package/dist-embed/chunks/{index-DtlUttQj.js → index-BgFbP5P0.js} +1 -1
- package/dist-embed/chunks/{index-CC-Ht79i.js → index-CMUTS_sA.js} +1 -1
- package/dist-embed/chunks/{index-B7nmHsEo.js → index-Cgf7tlW3.js} +1 -1
- package/dist-embed/chunks/{index-CsZ2HycN.js → index-CrNfUmIU.js} +1 -1
- package/dist-embed/chunks/{index-DIOcQUrz.js → index-CzuLxFBK.js} +1 -1
- package/dist-embed/chunks/{index-EmZm7_bH.js → index-DEn5R18M.js} +1 -1
- package/dist-embed/chunks/{index-DeVZ-nmF.js → index-DFEBhySA.js} +1 -1
- package/dist-embed/chunks/{index-CMYyiALV.js → index-DYkwi0aX.js} +1 -1
- package/dist-embed/chunks/{index-Fzz2KjFM.js → index-DvpdAlVH.js} +1 -1
- package/dist-embed/chunks/{index-W7TVoWP5.js → index-Dyh5xopp.js} +1 -1
- package/dist-embed/chunks/{index-en9Yf1Yz.js → index-Jt4bWLoz.js} +1 -1
- package/dist-embed/chunks/{index-BbucLMre.js → index-S-sjhoD3.js} +1 -1
- package/dist-embed/chunks/{index-D18sf241.js → index-TRLGqZaF.js} +1 -1
- package/dist-embed/chunks/{index-ZZnjmFwm.js → index-YcqCoWJl.js} +1 -1
- package/dist-embed/chunks/{index-BFLtEBuP.js → index-sQy5cmWo.js} +1 -1
- package/dist-embed/chunks/{it-IT-JPQ66NNP-CLcqplyX.js → it-IT-JPQ66NNP-C3xZ61-6.js} +1 -1
- package/dist-embed/chunks/{ja-JP-DBVTYXUO-u8Qe6tR7.js → ja-JP-DBVTYXUO-CeTmglEb.js} +1 -1
- package/dist-embed/chunks/{kaa-6HZHGXH3-BG2kx50I.js → kaa-6HZHGXH3-D6Jr6B6Y.js} +1 -1
- package/dist-embed/chunks/{kab-KAB-ZGHBKWFO-CSYUpRxd.js → kab-KAB-ZGHBKWFO-pEXBqeuG.js} +1 -1
- package/dist-embed/chunks/{kk-KZ-P5N5QNE5-CpBMgHAz.js → kk-KZ-P5N5QNE5-BRJunmHm.js} +1 -1
- package/dist-embed/chunks/{km-KH-HSX4SM5Z-CoMUUQMb.js → km-KH-HSX4SM5Z--GJgT9rN.js} +1 -1
- package/dist-embed/chunks/{ko-KR-MTYHY66A-DwxY8CGI.js → ko-KR-MTYHY66A-Bjnez4qR.js} +1 -1
- package/dist-embed/chunks/{ku-TR-6OUDTVRD-UoNYUfm0.js → ku-TR-6OUDTVRD-DgOdYJrS.js} +1 -1
- package/dist-embed/chunks/{lt-LT-XHIRWOB4-Dr4uXaEj.js → lt-LT-XHIRWOB4-BMwhrtjM.js} +1 -1
- package/dist-embed/chunks/{lv-LV-5QDEKY6T-CNC56J-_.js → lv-LV-5QDEKY6T-0pxW7YE0.js} +1 -1
- package/dist-embed/chunks/{mr-IN-CRQNXWMA-BKWa9nzZ.js → mr-IN-CRQNXWMA-tndp8BXC.js} +1 -1
- package/dist-embed/chunks/{my-MM-5M5IBNSE-bwAzOWhV.js → my-MM-5M5IBNSE-sispDhO4.js} +1 -1
- package/dist-embed/chunks/{nb-NO-T6EIAALU-CkpsChor.js → nb-NO-T6EIAALU-CjBurOuS.js} +1 -1
- package/dist-embed/chunks/{nl-NL-IS3SIHDZ-COVk4rlb.js → nl-NL-IS3SIHDZ-B58EVmr3.js} +1 -1
- package/dist-embed/chunks/{nn-NO-6E72VCQL-DlyFF-C1.js → nn-NO-6E72VCQL-D1p7LZSq.js} +1 -1
- package/dist-embed/chunks/{oc-FR-POXYY2M6-CFDosV2C.js → oc-FR-POXYY2M6-C1M8sddP.js} +1 -1
- package/dist-embed/chunks/{pa-IN-N4M65BXN-BKRB3O0U.js → pa-IN-N4M65BXN-D8ESzASl.js} +1 -1
- package/dist-embed/chunks/{percentages-BXMCSKIN-D7pnqUsZ.js → percentages-BXMCSKIN-BihMTsFR.js} +3 -3
- package/dist-embed/chunks/{pl-PL-T2D74RX3-C5r2Tds7.js → pl-PL-T2D74RX3-DQGe6LHC.js} +1 -1
- package/dist-embed/chunks/{pt-BR-5N22H2LF-CDnT98bW.js → pt-BR-5N22H2LF-CvXBgZQs.js} +1 -1
- package/dist-embed/chunks/{pt-PT-UZXXM6DQ-C6c4SPk1.js → pt-PT-UZXXM6DQ-BMnnlIUJ.js} +1 -1
- package/dist-embed/chunks/{ro-RO-JPDTUUEW-CW6pbzEZ.js → ro-RO-JPDTUUEW-DZ-9UUH7.js} +1 -1
- package/dist-embed/chunks/{ru-RU-B4JR7IUQ-CbaAJG0w.js → ru-RU-B4JR7IUQ-JlRBwjob.js} +1 -1
- package/dist-embed/chunks/{si-LK-N5RQ5JYF-BZkUjpXF.js → si-LK-N5RQ5JYF-Bx8kHnkd.js} +1 -1
- package/dist-embed/chunks/{sk-SK-C5VTKIMK-DsfWgpPU.js → sk-SK-C5VTKIMK-xsfEfbZb.js} +1 -1
- package/dist-embed/chunks/{sl-SI-NN7IZMDC-Kx0FqxKU.js → sl-SI-NN7IZMDC-SQYUECnr.js} +1 -1
- package/dist-embed/chunks/{subset-shared.chunk-DM3l9OuH.js → subset-shared.chunk-Ch6j8nKC.js} +1 -1
- package/dist-embed/chunks/{subset-worker.chunk-4w4yibm3.js → subset-worker.chunk-pJjck5pR.js} +1 -1
- package/dist-embed/chunks/{sv-SE-XGPEYMSR-DY0ryO-L.js → sv-SE-XGPEYMSR-BxcjSHE2.js} +1 -1
- package/dist-embed/chunks/{ta-IN-2NMHFXQM-CWpIs0i0.js → ta-IN-2NMHFXQM-rItSkDUS.js} +1 -1
- package/dist-embed/chunks/{th-TH-HPSO5L25-Cwkcfb3u.js → th-TH-HPSO5L25-B7UzESFj.js} +1 -1
- package/dist-embed/chunks/{tr-TR-DEFEU3FU-BqJZZl-Y.js → tr-TR-DEFEU3FU-Ci6oNfEX.js} +1 -1
- package/dist-embed/chunks/{uk-UA-QMV73CPH-Dg213mG4.js → uk-UA-QMV73CPH-C9csqvO6.js} +1 -1
- package/dist-embed/chunks/{vi-VN-M7AON7JQ-DY94NKxF.js → vi-VN-M7AON7JQ-DRAj2kZj.js} +1 -1
- package/dist-embed/chunks/{zh-CN-LNUGB5OW-B6I9A7sA.js → zh-CN-LNUGB5OW-DLOyW8hH.js} +1 -1
- package/dist-embed/chunks/{zh-HK-E62DVLB3-D3oqgDOt.js → zh-HK-E62DVLB3-DwC6_2Ws.js} +1 -1
- package/dist-embed/chunks/{zh-TW-RAJ6MFWO-CYwgY0Jo.js → zh-TW-RAJ6MFWO-DEMugIwa.js} +1 -1
- package/dist-embed/datalayer-app-main.js +156 -156
- package/lib/apps/apps/appspec.d.ts +13 -0
- package/lib/apps/apps/appspec.js +93 -0
- package/lib/apps/apps/checks.d.ts +1 -1
- package/lib/apps/apps/checks.js +2 -2
- package/lib/apps/apps/customComponents.js +1 -1
- package/lib/apps/core/canvasBlocks.d.ts +3 -3
- package/lib/apps/core/canvasParts.d.ts +6 -4
- package/lib/apps/core/index.d.ts +8 -0
- package/lib/apps/embed/AppEmbed.js +13 -20
- package/lib/apps/embed/embedSession.d.ts +8 -4
- package/lib/apps/embed/embedSession.js +16 -9
- package/lib/apps/embed/hostBridge.d.ts +47 -13
- package/lib/apps/embed/hostBridge.js +135 -18
- package/lib/apps/index.d.ts +1 -1
- package/lib/apps/index.js +1 -1
- package/lib/apps/plugins/a2ui-surface/AnswerShows.d.ts +21 -0
- package/lib/apps/plugins/a2ui-surface/AnswerShows.js +29 -0
- package/lib/apps/plugins/a2ui-surface/SurfaceToolResult.js +4 -7
- package/lib/apps/plugins/a2ui-surface/index.d.ts +2 -1
- package/lib/apps/plugins/a2ui-surface/index.js +10 -1
- package/lib/apps/plugins/a2ui-surface/toolResult.d.ts +20 -11
- package/lib/apps/plugins/a2ui-surface/toolResult.js +27 -11
- package/lib/apps/plugins/app-components/index.d.ts +1 -1
- package/lib/apps/plugins/app-components/index.js +2 -2
- package/lib/apps/plugins/app-elements/AppElements.d.ts +3 -3
- package/lib/apps/plugins/app-elements/AppElements.js +5 -20
- package/lib/apps/plugins/app-elements/QuestionView.d.ts +30 -0
- package/lib/apps/plugins/app-elements/QuestionView.js +70 -0
- package/lib/apps/plugins/app-elements/index.d.ts +7 -4
- package/lib/apps/plugins/app-elements/index.js +14 -5
- package/lib/apps/plugins/app-page/appPageModel.d.ts +6 -8
- package/lib/apps/plugins/app-page/appPageModel.js +0 -2
- package/lib/apps/plugins/app-page/pageRun.d.ts +2 -2
- package/lib/apps/plugins/app-page/pageRun.js +3 -3
- package/lib/apps/plugins/canvas-blocks/index.d.ts +13 -13
- package/lib/apps/plugins/canvas-blocks/index.js +24 -24
- package/lib/apps/plugins/canvas-parts/index.d.ts +7 -1
- package/lib/apps/plugins/canvas-parts/index.js +36 -0
- package/lib/apps/plugins/chat/ChatView.js +29 -3
- package/lib/chat/base/ChatBase.js +264 -43
- package/lib/chat/base/loopElement.d.ts +16 -17
- package/lib/chat/base/loopElement.js +11 -27
- package/lib/chat/base/loopStep.d.ts +15 -15
- package/lib/chat/base/loopStep.js +10 -13
- package/lib/chat/base/loopWindow.d.ts +15 -20
- package/lib/chat/base/loopWindow.js +26 -27
- package/lib/chat/base/uiFiles.d.ts +29 -0
- package/lib/chat/base/uiFiles.js +69 -0
- package/lib/chat/base/uiOps.d.ts +96 -0
- package/lib/chat/base/uiOps.js +251 -0
- package/lib/chat/messages/ChatMessageList.d.ts +13 -1
- package/lib/chat/messages/ChatMessageList.js +4 -4
- package/lib/components/a2ui/datalayer/Chart.d.ts +1 -1
- package/lib/components/a2ui/datalayer/schema.js +1 -1
- package/lib/components/teams/AnswerSurfaces.d.ts +3 -2
- package/lib/components/teams/AnswerSurfaces.js +7 -7
- package/lib/components/teams/useA2ATeam.d.ts +1 -1
- package/lib/config/AgentConfiguration.d.ts +1 -1
- package/lib/examples/ProtocolSignedRequestsExample.d.ts +10 -0
- package/lib/examples/ProtocolSignedRequestsExample.js +41 -0
- package/lib/examples/ProtocolUcpCheckoutExample.d.ts +10 -0
- package/lib/examples/ProtocolUcpCheckoutExample.js +59 -0
- package/lib/examples/example-selector.js +2 -0
- package/lib/examples/exampleGroups.d.ts +1 -1
- package/lib/examples/exampleGroups.js +4 -0
- package/lib/examples/index.d.ts +2 -0
- package/lib/examples/index.js +2 -0
- package/lib/examples/protocols/signedRequestsDemo.d.ts +27 -0
- package/lib/examples/protocols/signedRequestsDemo.js +59 -0
- package/lib/examples/protocols/ucpCheckoutDemo.d.ts +36 -0
- package/lib/examples/protocols/ucpCheckoutDemo.js +68 -0
- package/lib/protocols/AGUIAdapter.d.ts +7 -0
- package/lib/protocols/AGUIAdapter.js +43 -3
- package/lib/protocols/a2a/index.js +1 -0
- package/lib/protocols/agentic-commerce/index.js +1 -0
- package/lib/protocols/core.d.ts +6 -0
- package/lib/protocols/mcp/index.js +1 -0
- package/lib/protocols/pact/index.js +1 -0
- package/lib/protocols/ucp/index.js +1 -0
- package/lib/protocols/ucp/merchant.d.ts +15 -0
- package/lib/protocols/ucp/merchant.js +257 -0
- package/lib/protocols/web-bot-auth/index.js +1 -0
- package/lib/specs/agents/agents.js +338 -169
- package/lib/specs/apps.js +134 -6
- package/lib/specs/appspecSchema.js +59 -0
- package/lib/specs/cogs.js +6 -3
- package/lib/specs/index.d.ts +2 -1
- package/lib/specs/index.js +2 -1
- package/lib/specs/protocols.d.ts +24 -0
- package/lib/specs/protocols.js +197 -0
- package/lib/specs/ui.d.ts +21 -0
- package/lib/specs/{uiPlugins.js → ui.js} +14 -14
- package/lib/types/agentspecs.d.ts +69 -5
- package/lib/types/messages.d.ts +7 -0
- package/lib/types/protocol.d.ts +15 -0
- package/package.json +2 -2
- package/scripts/codegen/generate_agents.py +43 -8
- package/scripts/codegen/generate_protocols.py +207 -0
- package/scripts/codegen/generate_sandbox_agents.py +1 -1
- package/scripts/codegen/{generate_ui_plugins.py → generate_ui.py} +40 -40
- package/scripts/gen_workers.py +2 -2
- package/dist-embed/chunks/ChatView-D41Nx5rC.js +0 -32
- package/lib/chat/base/loopMessage.d.ts +0 -37
- package/lib/chat/base/loopMessage.js +0 -37
- package/lib/specs/uiPlugins.d.ts +0 -21
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{o as ue,t as rt,T as at,p as de,b as Ve,f as Ue,I as dt,j as ct,a as qe,d as ut,C as Ee,g as Ne}from"./index-BvvaLLhn.js";import{r as H,h2 as ht,c3 as pt,v as A,ag as Q,c0 as ne,ak as O,gF as gt,dG as bt,gw as mt,h3 as Ct,an as $e,dM as vt,gX as ft,dK as _t,cu as Z,c7 as yt,h4 as _,cH as De,cC as Je,cI as ze,g4 as Ge,g5 as Ye,dJ as xe,am as xt,ch as Xe,cg as ve,c1 as we,h5 as wt,h6 as kt,gZ as St,b_ as ke,l as Y,aW as At,gx as Mt,J as Tt,ah as pe,gK as G,h7 as he,af as ie,h8 as Ce,dD as Oe,h9 as Bt,ha as Et,cU as je,cS as Re,hb as le,cW as Ie,hc as Pe,cT as Nt,hd as Ot,he as jt,ac as Ze,hf as Rt,hg as It,dI as Pt,ai as F,dt as ge,hh as fe,cw as Lt,dB as Wt,c_ as Ht,hi as Ft,hj as se,hk as Qe,d6 as Kt,bZ as Vt,aj as Ut,cx as qt,c9 as $t,gI as Dt,hl as Jt,cM as zt,cP as Gt,hm as Yt,hn as Xt,ho as Zt,d9 as Qt,da as eo,cR as to,aV as oo,ed as no}from"../datalayer-app-main.js";import{b as io,I as et}from"./token-BRjncM66.js";import{ToolbarItems as lo}from"./index-CC-Ht79i.js";import{I as so}from"./index-Clp8quV1.js";import{I as Se}from"./tokens-BHMD_ju9.js";import{a as tt,I,b as ot,c as ro}from"./tokens-CydTkiyv.js";import{I as ao,a as nt}from"./tokens-BvmYCqiu.js";import{I as co}from"./tokens-CBD7cd6p.js";import{f as it,e as uo,c as ho,I as po,b as go}from"./index-1wTrAXI1.js";import{I as lt}from"./tokens-D1_9ZFxB.js";import{I as be}from"./tokens-BHLmeqjP.js";import{a as Ae}from"./tokens-_fLcuFXz.js";import{I as bo}from"./tokens-CENaHAHm.js";import{I as mo}from"./index-BYQwy0Zx.js";import{I as Co}from"./tokens-DXLxGbDM.js";import{W as vo,u as Le,V as fo,I as _o,a as yo,b as xo,c as wo}from"./document-BpXPH_dr.js";import{b as ko,c as So,d as Ao}from"./CellSidebarExtension-CQlXdanG.js";import{T as Mo,a as To}from"./model-BHONoBA6.js";import{C as We}from"./celltoolbartracker-D67W4XWx.js";import"./hoverbox-CStlKQWE.js";import"./Output-2KxoKu5F.js";import"./index-BJ7Yskx5.js";import"./color-CG7_7V2-.js";import"./isEqual-BybBNsZK.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./PaintbrushIcon-CLU8RilX.js";import"./index-B3WvcNQa.js";import"./RestartIcon-Ca6_HoK0.js";import"./NotebookSkeleton-HdM76lOj.js";import"./Avatar-DbU3YP4x.js";import"./renderer-lVFw9lw7.js";import"./SquareIcon-e3ygcjpv.js";import"./SortAscIcon-CVKVWIWQ.js";import"./url-DuKx0yk0.js";/* empty css */import"./index-Dro44tIm.js";/* empty css *//* empty css */import"./index-DsG9xhMj.js";/* empty css */import"./index-CNU-WVhQ.js";import"./index--OLIX362.js";import"./index-DYGslHkf.js";import"./index-BSRVX3UN.js";import"./index-BH2OX5l8.js";import"./index-C3vDfO5_.js";import"./index-Ko8lxXFd.js";import"./index-CB9u17_J.js";import"./index-BUVtc_FV.js";import"./ArrowLeftIcon-Y3PTljcl.js";import"./SkubbleIcon-tlg17jBG.js";import"./usePrimerThemeBridge-D_1NuGKb.js";import"./index-j-oeqTuo.js";import"./KernelVariables-KCUfxhF4.js";import"./index-BvgsWH_d.js";import"./SortDescIcon-CS4EzHeS.js";import"./NotebookToolbar-DMKCe3c2.js";import"./RepoPushIcon-Cm8g9NuL.js";import"./Toolbar-6Hdi_m3T.js";import"./sessions-3PQsLINe.js";import"./tokens-BfuLIPUq.js";import"./drivecontents-Bg9_6Kmo.js";import"./kernel-BI-BLP-K.js";const Bo="jp-DefaultStyle",Eo="jp-HTMLSelect";class No extends H.Component{render(){const{className:e,defaultStyle:i=!0,disabled:a,elementRef:s,iconProps:l,icon:p=ht,options:n=[],...c}=this.props,d=pt(Eo,{[Bo]:i},e),g=b=>{b.stopPropagation()},m=n.map(b=>{const f=typeof b=="object"?b:{value:b};return H.createElement("option",{...f,key:f.value},f.label||f.value)});return H.createElement("div",{className:d},H.createElement("select",{onFocus:g,disabled:a,ref:s,...c,multiple:!1},m,c.children),H.createElement(p.react,{tag:"span",stylesheet:"select",right:"4px",top:"4px",...l}))}}function Oo(r){const i=a=>{const s=Math.max(a*3.6,.1),l=s*Math.PI/180,p=Math.sin(l)*104,n=Math.cos(l)*-104;return"M 0 0 v -104 A 104 104 1 "+(s<180?1:0)+" 0 "+p.toFixed(4)+" "+n.toFixed(4)+" z"};return A.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},A.createElement("svg",{viewBox:"0 0 250 250"},A.createElement("circle",{cx:"125",cy:"125",r:"104",stroke:"var(--jp-inverse-layout-color3)",strokeWidth:"20",fill:"none"}),A.createElement("path",{className:"jp-Statusbar-ProgressCirclePath",transform:"translate(125,125) scale(.9)",d:i(r.progress),fill:"var(--jp-inverse-layout-color3)"})))}const jo="jp-JSONEditor",ce="jp-mod-error",Ro="jp-JSONEditor-host",Io="jp-JSONEditor-header";class Po extends Q{constructor(e){super(),this._dataDirty=!1,this._inputDirty=!1,this._source=null,this._originalValue=ne.emptyObject,this._changeGuard=!1,this.translator=e.translator||O,this._trans=this.translator.load("jupyterlab"),this.addClass(jo),this.headerNode=document.createElement("div"),this.headerNode.className=Io,this.revertButtonNode=gt.element({tag:"span",title:this._trans.__("Revert changes to data")}),this.commitButtonNode=bt.element({tag:"span",title:this._trans.__("Commit changes to data"),marginLeft:"8px"}),this.editorHostNode=document.createElement("div"),this.editorHostNode.className=Ro,this.headerNode.appendChild(this.revertButtonNode),this.headerNode.appendChild(this.commitButtonNode),this.node.appendChild(this.headerNode),this.node.appendChild(this.editorHostNode);const i=new mt.Model({mimeType:"application/json"});i.sharedModel.changed.connect(this._onModelChanged,this),this.model=i,this.editor=e.editorFactory({host:this.editorHostNode,model:i,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 i=this.editorHostNode;i.addEventListener("blur",this,!0),i.addEventListener("click",this,!0),this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.headerNode.addEventListener("click",this)}onBeforeDetach(e){const i=this.editorHostNode;i.removeEventListener("blur",this,!0),i.removeEventListener("click",this,!0),this.headerNode.removeEventListener("click",this)}_onSourceChanged(e,i){if(!this._changeGuard){if(this._inputDirty||this.editor.hasFocus()){this._dataDirty=!0;return}this._setValue()}}_onModelChanged(e,i){if(i.sourceChange){let a=!0;try{const s=JSON.parse(this.editor.model.sharedModel.getSource());this.removeClass(ce),this._inputDirty=!this._changeGuard&&!ne.deepEqual(s,this._originalValue)}catch{this.addClass(ce),this._inputDirty=!0,a=!1}this.revertButtonNode.hidden=!this._inputDirty,this.commitButtonNode.hidden=!a||!this._inputDirty}}_evtBlur(e){!this._inputDirty&&this._dataDirty&&this._setValue()}_evtClick(e){const i=e.target;this.revertButtonNode.contains(i)?this._setValue():this.commitButtonNode.contains(i)?!this.commitButtonNode.hidden&&!this.hasClass(ce)&&(this._changeGuard=!0,this._mergeContent(),this._changeGuard=!1,this._setValue()):this.editorHostNode.contains(i)&&this.editor.focus()}_mergeContent(){const e=this.editor.model,i=this._originalValue,a=JSON.parse(e.sharedModel.getSource()),s=this.source;if(s){for(const l in a)ne.deepEqual(a[l],i[l]||null)||s.set(l,a[l]);for(const l in i)l in a||s.delete(l)}}_setValue(){this._dataDirty=!1,this._inputDirty=!1,this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.removeClass(ce);const e=this.editor.model,i=this._source?this._source.toJSON():{};if(this._changeGuard=!0,i===void 0)e.sharedModel.setSource(this._trans.__("No data!")),this._originalValue=ne.emptyObject;else{const a=JSON.stringify(i,null,4);e.sharedModel.setSource(a),this._originalValue=i,a.length>1&&a[0]==="{"&&this.editor.setCursorPosition({line:0,column:1})}this._changeGuard=!1,this.commitButtonNode.hidden=!0,this.revertButtonNode.hidden=!0}}const Lo="jp-Notebook-toolbarCellType",Wo="jp-Notebook-toolbarCellTypeDropdown";var _e;(function(r){function e(g,m){const b=(m||O).load("jupyterlab");function f(){if(g.context.model.readOnly)return Xe({title:b.__("Cannot Save"),body:b.__("Document is read-only"),buttons:[ve.okButton()]});g.context.save().then(()=>{if(!g.isDisposed)return g.context.createCheckpoint()})}return Ct($e.create(H.createElement(vt,{signal:g.context.fileChanged},()=>H.createElement(ft,{icon:_t,onClick:f,tooltip:b.__("Save the notebook contents and create checkpoint"),enabled:!!(g&&g.context&&g.context.contentsModel&&g.context.contentsModel.writable)}))))}r.createSaveButton=e;function i(g,m){const b=(m||O).load("jupyterlab");return new Z({icon:yt,onClick:()=>{_.insertBelow(g.content)},tooltip:b.__("Insert a cell below")})}r.createInsertButton=i;function a(g,m,b){const f=(m||O).load("jupyterlab");return new Z({icon:De,onClick:async()=>{b?.get("useSystemClipboardForCells").composite?await _.cutToSystemClipboard(g.content):_.cut(g.content)},tooltip:f.__("Cut the selected cells")})}r.createCutButton=a;function s(g,m,b){const f=(m||O).load("jupyterlab");return new Z({icon:Je,onClick:async()=>{b?.get("useSystemClipboardForCells").composite?await _.copyToSystemClipboard(g.content):_.copy(g.content)},tooltip:f.__("Copy the selected cells")})}r.createCopyButton=s;function l(g,m,b){const f=(m||O).load("jupyterlab");return new Z({icon:ze,onClick:async()=>{b?.get("useSystemClipboardForCells").composite?await _.pasteFromSystemClipboard(g.content):_.paste(g.content)},tooltip:f.__("Paste cells from the clipboard")})}r.createPasteButton=l;function p(g,m,b){const f=(b??O).load("jupyterlab");return new Z({icon:Ge,onClick:()=>{_.runAndAdvance(g.content,g.sessionContext,m,b)},tooltip:f.__("Run the selected cells and advance")})}r.createRunButton=p;function n(g,m,b){const f=(b??O).load("jupyterlab");return new Z({icon:Ye,onClick:()=>{const x=m??new xe({translator:b});x.restart(g.sessionContext).then(o=>(o&&_.runAll(g.content,g.sessionContext,x,b),o))},tooltip:f.__("Restart the kernel, then re-run the whole notebook")})}r.createRestartRunAllButton=n;function c(g,m){return new Ho(g.content,m)}r.createCellTypeItem=c;function d(g,m,b,f){return[{name:"save",widget:e(g,b)},{name:"insert",widget:i(g,b)},{name:"cut",widget:a(g,b,f)},{name:"copy",widget:s(g,b,f)},{name:"paste",widget:l(g,b,f)},{name:"run",widget:p(g,m,b)},{name:"interrupt",widget:ue.createInterruptButton(g.sessionContext,b)},{name:"restart",widget:ue.createRestartButton(g.sessionContext,m,b)},{name:"restart-and-run",widget:n(g,m,b)},{name:"cellType",widget:c(g,b)},{name:"spacer",widget:xt.createSpacerItem()},{name:"kernelName",widget:ue.createKernelNameItem(g.sessionContext,m,b)}]}r.getDefaultItems=d})(_e||(_e={}));class Ho extends $e{constructor(e,i){super(),this.handleChange=a=>{a.target.value!=="-"&&(_.changeCellType(this._notebook,a.target.value),this._notebook.activate())},this.handleKeyDown=a=>{a.key==="Enter"&&this._notebook.activate()},this._trans=(i||O).load("jupyterlab"),this.addClass(Lo),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 i of this._notebook.widgets)if(this._notebook.isSelectedOrActive(i)&&i.model.type!==e){e="-";break}return H.createElement(No,{className:Wo,onChange:this.handleChange,onKeyDown:this.handleKeyDown,value:e,"aria-label":this._trans.__("Cell type"),title:this._trans.__("Select the cell type")},H.createElement("option",{value:"-"},"-"),H.createElement("option",{value:"code"},this._trans.__("Code")),H.createElement("option",{value:"markdown"},this._trans.__("Markdown")),H.createElement("option",{value:"raw"},this._trans.__("Raw")))}}function He(r){var e;const i=r.translator||O,a=rt(i),s=i.load("jupyterlab"),l=(e=r.displayOption.showJumpToCell)!==null&&e!==void 0?e:!1,p=r.state,n=r.displayOption.showOnToolBar,c=r.displayOption.showProgress,d=n?"down":"up",g=A.createElement("div",null),[m,b]=A.useState(!1);if(A.useEffect(()=>{if(m)return;const j=()=>{b(!0)};return _.executionScheduled.connect(j),()=>{_.executionScheduled.disconnect(j)}},[l,m]),!p)return g;const f=p.kernelStatus,x={alignSelf:"normal",height:"24px"},o=p.totalTime,t=p.scheduledCellNumber||0,u=p.scheduledCell.size||0,C=t-u;let w=100*C/t,B=c?"":"hidden";!c&&w<100&&(w=0);const M=j=>A.createElement(Oo,{progress:j,width:16,height:24,label:s.__("Kernel status")}),K=j=>s.__("Kernel status: %1",j),V=()=>{const j=r.notebook;_.selectLastRunCell(j),j.activeCell&&j.scrollToCell(j.activeCell)},R=(j,$,P)=>A.createElement("div",{className:"jp-Notebook-ExecutionIndicator",title:c?"":K(a[j]),"data-status":j},$,A.createElement("div",{className:`jp-Notebook-ExecutionIndicator-tooltip ${d} ${B}`},A.createElement("span",null," ",K(a[j])," "),P,l&&m&&A.createElement(St,{className:"jp-Notebook-ExecutionIndicator-jumpButton",onClick:V,title:s.__("Jump to current or last executed cell")},s.__("Jump to cell"))));if(p.kernelStatus==="connecting"||p.kernelStatus==="disconnected"||p.kernelStatus==="unknown")return R(f,A.createElement(wt.react,{...x}),[]);if(p.kernelStatus==="starting"||p.kernelStatus==="terminating"||p.kernelStatus==="restarting"||p.kernelStatus==="initializing")return R(f,A.createElement(kt.react,{...x}),[]);if(p.executionStatus==="busy")return R("busy",M(w),[A.createElement("span",{key:0},s.__("Executed %1/%2 cells",C,t)),A.createElement("span",{key:1},s._n("Elapsed time: %1 second","Elapsed time: %1 seconds",o))]);{const j=p.kernelStatus==="busy"?0:100,$=p.kernelStatus==="busy"||o===0?[]:[A.createElement("span",{key:0},s._n("Executed %1 cell","Executed %1 cells",t)),A.createElement("span",{key:1},s._n("Elapsed time: %1 second","Elapsed time: %1 seconds",o))];return R(p.kernelStatus,M(j),$)}}class X extends we{constructor(e,i=!0){super(new X.Model),this.translator=e||O,this.addClass("jp-mod-highlighted")}render(){if(this.model===null||!this.model.renderFlag)return A.createElement("div",null);{const e=this.model.currentNotebook;return e?A.createElement(He,{displayOption:this.model.displayOption,state:this.model.executionState(e),translator:this.translator,notebook:e}):A.createElement(He,{displayOption:this.model.displayOption,state:void 0,translator:this.translator,notebook:void 0})}}}(function(r){class e extends ke{constructor(){super(),this._notebookExecutionProgress=new WeakMap,this._displayOption={showOnToolBar:!0,showProgress:!0,showJumpToCell:!1},this._renderFlag=!0}attachNotebook(l){var p,n,c,d;if(l&&l.content&&l.context){const g=l.content,m=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 b=this._notebookExecutionProgress.get(g),f=u=>{b&&(b.kernelStatus=u.kernelDisplayStatus),this.stateChanged.emit(void 0)};m.statusChanged.connect(f,this);const x=u=>{b&&(b.kernelStatus=u.kernelDisplayStatus),this.stateChanged.emit(void 0)};m.connectionStatusChanged.connect(x,this),m.disposed.connect(u=>{u.connectionStatusChanged.disconnect(x,this),u.statusChanged.disconnect(f,this)});const o=(u,C)=>{const w=C.msg,B=w.header.msg_id;if(w.header.msg_type==="execute_request")this._cellScheduledCallback(g,B);else if(Y.KernelMessage.isStatusMsg(w)&&w.content.execution_state==="idle"){const M=w.parent_header.msg_id;this._cellExecutedCallback(g,M)}else Y.KernelMessage.isStatusMsg(w)&&w.content.execution_state==="restarting"?this._restartHandler(g):w.header.msg_type==="execute_input"&&this._startTimer(g)};(n=(p=m.session)===null||p===void 0?void 0:p.kernel)===null||n===void 0||n.anyMessage.connect(o),(d=(c=m.session)===null||c===void 0?void 0:c.kernel)===null||d===void 0||d.disposed.connect(u=>u.anyMessage.disconnect(o));const t=(u,C)=>{b&&(this._resetTime(b),this.stateChanged.emit(void 0),C.newValue&&C.newValue.anyMessage.connect(o))};m.kernelChanged.connect(t),m.disposed.connect(u=>u.kernelChanged.disconnect(t))}}}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 n=this._notebookExecutionProgress.get(l);n&&n.scheduledCell.has(p)&&(n.scheduledCell.delete(p),n.scheduledCell.size===0&&this._scheduleSwitchToIdle(n))}_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 n=this._notebookExecutionProgress.get(l);n&&!n.scheduledCell.has(p)&&(n.needReset&&this._resetTime(n),n.scheduledCell.add(p),n.scheduledCellNumber+=1)}_tick(l){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 i(s,l,p){const n=new r(l);return n.model.displayOption={showOnToolBar:!0,showProgress:!0,showJumpToCell:!1},n.model.attachNotebook({content:s.content,context:s.sessionContext}),p&&p.then(c=>{const d=g=>{const m=a(g);m.showJumpToCell&&(g.get("recordTiming").composite||g.set("recordTiming",!0).catch(f=>{console.error("Failed to auto-enable recordTiming:",f.message)})),n.model.updateRenderOption(m)};c.changed.connect(d),d(c),n.disposed.connect(()=>{c.changed.disconnect(d)})}).catch(c=>{console.error(c.message)}),n}r.createExecutionIndicatorItem=i;function a(s){let l=!0,p=!0,n=!1;const c=s.get("kernelStatus").composite;return c&&(l=!c.showOnStatusBar,p=c.showProgress,n=c.showJumpToRecentExecutionButton),{showOnToolBar:l,showProgress:p,showJumpToCell:n}}r.getSettingValue=a})(X||(X={}));function Fo(r){const e=(r.translator||O).load("jupyterlab");return H.createElement(at,{source:e.__("Mode: %1",r.modeNames[r.notebookMode])})}class re extends we{constructor(e){super(new re.Model),this.translator=e||O,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]),H.createElement(Fo,{notebookMode:this.model.notebookMode,translator:this.translator,modeNames:this._modeNames})):null}}(function(r){class e extends ke{constructor(){super(...arguments),this._onChanged=a=>{const s=this._notebookMode;this._notebook?this._notebookMode=a.mode:this._notebookMode="command",this._triggerChange(s,this._notebookMode)},this._notebookMode="command",this._notebook=null}get notebookMode(){return this._notebookMode}set notebook(a){const s=this._notebook;s!==null&&(s.stateChanged.disconnect(this._onChanged,this),s.activeCellChanged.disconnect(this._onChanged,this),s.modelContentChanged.disconnect(this._onChanged,this));const l=this._notebookMode;this._notebook=a,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(a,s){a!==s&&this.stateChanged.emit(void 0)}}r.Model=e})(re||(re={}));class Ko extends vo{constructor(e,i){super(e,i),this.editorWidget=e,this.options=i,this._type="code",this._readyDelegate=new At,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 i,a=this.language_info();return!a||!a.mimetype?i=this.widget.content.codeMimetype:i=a.mimetype,Array.isArray(i)?(e=i[0])!==null&&e!==void 0?e:Mt.defaultMimeType:i}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(i=>({ceEditor:this._getCellEditor(i),type:i.model.type,value:i.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 i=this._getCellAt(e);return this.widget.content.widgets.findIndex(s=>i===s)}getEditorIndex(e){let i=this._editorToCell.get(e);return this.editor.widgets.findIndex(a=>i===a)}getEditorWrapper(e){return this._editorToCell.get(e).node}async onKernelChanged(e,i){if(i.newValue)try{const a=this._languageInfo;await Le(this.isReady,-1),await this._updateLanguageInfo();const s=this._languageInfo;a?.name!=s.name||a?.mimetype!=s?.mimetype||a?.file_extension!=s?.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(a){console.warn(a),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(),Tt.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,i){let a=[],s=[];const l=this._type;if(i.type==="set"){let p=[],n=[];if(i.newValues.length===i.oldValues.length){for(let c=0;c<i.newValues.length;c++)i.oldValues[c].type===l&&i.newValues[c].type!==l?p.push(i.newValues[c]):i.oldValues[c].type!==l&&i.newValues[c].type===l&&n.push(i.newValues[c]);a=n,s=p}}else i.type=="add"&&(a=i.newValues.filter(p=>p.type===l));(s.length||a.length||i.type==="set"||i.type==="move"||i.type==="remove"||i.type==="clear")&&await this.updateDocuments();for(let p of a){let n=this.widget.content.widgets.find(c=>c.model.id===p.id);if(!n){console.warn(`Widget for added cell with ID: ${p.id} not found!`);continue}this._getCellEditor(n)}}createVirtualDocument(){return new fo({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 Le(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,i,a,s;const l=(s=await((a=(i=(e=this.widget.context.sessionContext)===null||e===void 0?void 0:e.session)===null||i===void 0?void 0:i.kernel)===null||a===void 0?void 0:a.info))===null||s===void 0?void 0:s.language_info;if(l)this._languageInfo=l;else throw new Error("Language info update failed (no session, kernel, or info available)")}_activeCellChanged(e,i){!i||i.model.type!==this._type||this._activeEditorChanged.emit({editor:this._getCellEditor(i)})}_getCellAt(e){let i=this.virtualDocument.getEditorAtVirtualLine(e);return this._editorToCell.get(i)}_getCellEditor(e){if(!this._cellToEditor.has(e)){const i=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,i),this._editorToCell.set(i,e),e.disposed.connect(()=>{this._cellToEditor.delete(e),this._editorToCell.delete(i),this._editorRemoved.emit({editor:i})}),this._editorAdded.emit({editor:i})}return this._cellToEditor.get(e)}}class Vo extends Q{constructor(){super(),this._items=[],this.layout=new pe,this.addClass("jp-RankedPanel")}addWidget(e,i){const a={widget:e,rank:i},s=ie.upperBound(this._items,a,ye.itemCmp);ie.insert(this._items,s,a),this.layout.insertWidget(s,e)}onChildRemoved(e){const i=ie.findFirstIndex(this._items,a=>a.widget===e.child);i!==-1&&ie.removeAt(this._items,i)}}class q extends Q{constructor(e){super(),this.addClass("jp-NotebookTools"),this.translator=e.translator||O,this._tools=[],this.layout=new pe,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 i=e.content;return i.widgets.filter(a=>i.isSelectedOrActive(a))}get activeNotebookPanel(){return this._tracker.currentWidget}addItem(e){var i;const a=e.tool,s=(i=e.rank)!==null&&i!==void 0?i:100;let l;const p=this._tools.find(n=>n.section===e.section);if(p)l=p.panel;else throw new Error(`The section ${e.section} does not exist`);a.addClass("jp-NotebookTools-tool"),l.addWidget(a,s),a.notebookTools=this,G.sendMessage(a,q.ActiveNotebookPanelMessage),G.sendMessage(a,q.ActiveCellMessage)}addSection(e){var i;const a=e.sectionName,s=e.label||e.sectionName,l=e.tool;let p=(i=e.rank)!==null&&i!==void 0?i:null;const n=new Vo;if(n.title.label=s,l&&n.addWidget(l,0),this._tools.push({section:a,panel:n,rank:p}),p!=null)this.layout.insertWidget(p,new de({widget:n}));else{let c=null;const d=this.layout;for(let g=0;g<d.widgets.length;g++){let m=d.widgets[g];if(m instanceof de&&m.widget.id==="advancedToolsSection"){c=g;break}}c!==null?this.layout.insertWidget(c,new de({widget:n})):this.layout.addWidget(new de({widget:n}))}}_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 i of this._toolChildren())G.sendMessage(i,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 i of this._toolChildren())G.sendMessage(i,q.ActiveCellMessage)}_onSelectionChanged(){for(const e of this._toolChildren())G.sendMessage(e,q.SelectionMessage)}_onActiveNotebookPanelMetadataChanged(e,i){const a=new he.ChangeMessage("activenotebookpanel-metadata-changed",{oldValue:void 0,newValue:void 0,...i});for(const s of this._toolChildren())G.sendMessage(s,a)}_onActiveCellMetadataChanged(e,i){const a=new he.ChangeMessage("activecell-metadata-changed",{newValue:void 0,oldValue:void 0,...i});for(const s of this._toolChildren())G.sendMessage(s,a)}*_toolChildren(){for(let e of this._tools)yield*e.panel.children()}}(function(r){r.ActiveNotebookPanelMessage=new Ce("activenotebookpanel-changed"),r.ActiveCellMessage=new Ce("activecell-changed"),r.SelectionMessage=new Ce("selection-changed");class e extends Q{dispose(){super.dispose(),this.notebookTools&&(this.notebookTools=null)}processMessage(s){switch(super.processMessage(s),s.type){case"activenotebookpanel-changed":this.onActiveNotebookPanelChanged(s);break;case"activecell-changed":this.onActiveCellChanged(s);break;case"selection-changed":this.onSelectionChanged(s);break;case"activecell-metadata-changed":this.onActiveCellMetadataChanged(s);break;case"activenotebookpanel-metadata-changed":this.onActiveNotebookPanelMetadataChanged(s);break}}onActiveNotebookPanelChanged(s){}onActiveCellChanged(s){}onSelectionChanged(s){}onActiveCellMetadataChanged(s){}onActiveNotebookPanelMetadataChanged(s){}}r.Tool=e;class i extends e{constructor(s){super();const{editorFactory:l}=s;this.addClass("jp-MetadataEditorTool");const p=this.layout=new pe;this._editorFactory=l,this._editorLabel=s.label||"Edit Metadata",this.createEditor();const n=new Q({node:document.createElement("label")});n.node.textContent=s.label||"Edit Metadata",p.addWidget(n),p.addWidget(this.editor)}get editor(){return this._editor}onActiveNotebookPanelChanged(s){this.editor.dispose(),this.notebookTools.activeNotebookPanel&&this.createEditor()}createEditor(){this._editor=new Po({editorFactory:this._editorFactory}),this.editor.title.label=this._editorLabel,this.layout.addWidget(this.editor)}}r.MetadataEditorTool=i})(q||(q={}));var ye;(function(r){function e(i,a){return i.rank-a.rank}r.itemCmp=e})(ye||(ye={}));const Uo=6;var W;(function(r){r[r.Idle=-1]="Idle",r[r.Error=-.5]="Error",r[r.Scheduled=0]="Scheduled",r[r.Running=1]="Running"})(W||(W={}));class qo extends To{constructor(e,i,a,s){super(e,s),this.parser=i,this.sanitizer=a,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),_.executionScheduled.connect(this.onExecutionScheduled,this),_.executed.connect(this.onExecuted,this),_.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 i=new Array;let a=this._cellToHeadingIndex.get(e);if(a!==void 0){const s=this.headings[a];for(i.push(s);this.headings[a-1]&&this.headings[a-1].cellRef===s.cellRef;)a--,i.unshift(this.headings[a])}return i}dispose(){var e,i,a;this.isDisposed||(this.headingsChanged.disconnect(this.onHeadingsChanged,this),(i=(e=this.widget.context)===null||e===void 0?void 0:e.model)===null||i===void 0||i.metadataChanged.disconnect(this.onMetadataChanged,this),(a=this.widget.content)===null||a===void 0||a.activeCellChanged.disconnect(this.onActiveCellChanged,this),_.executionScheduled.disconnect(this.onExecutionScheduled,this),_.executed.disconnect(this.onExecuted,this),_.outputCleared.disconnect(this.onOutputCleared,this),this._runningCells.length=0,this._errorCells.length=0,super.dispose())}setConfiguration(e){const i=this.loadConfigurationFromMetadata();super.setConfiguration({...this.configuration,...i,...e})}toggleCollapse(e){super.toggleCollapse(e),this.updateRunningStatus(this.headings)}async getHeadings(){const e=this.widget.content.widgets,i=new Set(e),a=[],s=new Array,l=new WeakMap;for(let p=0;p<e.length;p++){const n=e[p];switch(n.model.type){case"code":{!this.configuration.syncCollapseState&&this.configuration.includeOutput&&a.push(...Ie(await n.getHeadings(),this.configuration,s).map(d=>({...d,cellRef:n,collapsed:!1,isRunning:W.Idle})));break}case"markdown":{const d=Ie(await n.getHeadings(),this.configuration,s).map((g,m)=>({...g,cellRef:n,collapsed:!1,isRunning:W.Idle}));if(this.configuration.syncCollapseState&&n.headingCollapsed){const g=Math.min(...d.map(b=>b.level)),m=d.find(b=>b.level===g);m.collapsed=n.headingCollapsed}a.push(...d);break}}a.length>0&&l.set(n,a.length-1)}return this._cellToHeadingIndex=l,this._runningCells=this._runningCells.filter(p=>i.has(p)),this._errorCells=this._errorCells.filter(p=>i.has(p)),this.updateRunningStatus(a),Promise.resolve(a)}isHeadingEqual(e,i){return super.isHeadingEqual(e,i)&&e.cellRef===i.cellRef&&e.isRunning===i.isRunning}loadConfigurationFromMetadata(){const e=this.widget.content.model,i={};if(e)for(const a in this.configMetadataMap){const s=this.configMetadataMap[a];for(const l of s){let p=l;const n=p[0]==="!";n&&(p=p.slice(1));const c=p.split("/");let d=e.getMetadata(c[0]);for(let g=1;g<c.length;g++)d=(d??{})[c[g]];d!==void 0&&(typeof d=="boolean"&&n&&(d=!d),i[a]=d)}}return i}onActiveCellChanged(e,i){const a=this.getCellHeadings(i)[0];this.setActiveHeading(a??null,!1)}onHeadingsChanged(){this.widget.content.activeCell&&this.onActiveCellChanged(this.widget.content,this.widget.content.activeCell)}onExecuted(e,i){this._runningCells.forEach((a,s)=>{var l;if(a===i.cell){this._runningCells.splice(s,1);const p=this._cellToHeadingIndex.get(a);if(p!==void 0){const n=this.headings[p];if(i.success||((l=i.error)===null||l===void 0?void 0:l.errorName)===void 0){n.isRunning=W.Idle;return}n.isRunning=W.Error,this._errorCells.includes(a)||this._errorCells.push(a)}}}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onExecutionScheduled(e,i){this._runningCells.includes(i.cell)||this._runningCells.push(i.cell),this._errorCells.forEach((a,s)=>{a===i.cell&&this._errorCells.splice(s,1)}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onOutputCleared(e,i){this._errorCells.forEach((a,s)=>{if(a===i.cell){this._errorCells.splice(s,1);const l=this._cellToHeadingIndex.get(a);if(l!==void 0){const p=this.headings[l];p.isRunning=W.Idle}}}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onMetadataChanged(){this.setConfiguration({})}updateRunningStatus(e){e.forEach(s=>{s.isRunning=W.Idle}),this._runningCells.forEach((s,l)=>{const p=this._cellToHeadingIndex.get(s);if(p!==void 0){const n=e[p];n.isRunning!==W.Running&&(n.isRunning=l>0?W.Scheduled:W.Running)}}),this._errorCells.forEach((s,l)=>{const p=this._cellToHeadingIndex.get(s);if(p!==void 0){const n=e[p];n.isRunning===W.Idle&&(n.isRunning=W.Error)}});let i=0;for(;i<e.length;){const s=e[i];if(i++,s.collapsed){const l=Math.max(s.isRunning,a(e,s.level));s.dataset={...s.dataset,"data-running":l.toString()}}else s.dataset={...s.dataset,"data-running":s.isRunning.toString()}}function a(s,l){let p=W.Idle;for(;i<s.length;){const n=s[i];if(n.dataset={...n.dataset,"data-running":n.isRunning.toString()},n.level>l)i++,p=Math.max(n.isRunning,p),n.collapsed&&(p=Math.max(p,a(s,n.level)),n.dataset={...n.dataset,"data-running":p.toString()});else break}return p}}}class $o extends Mo{constructor(e,i,a,s){super(e),this.parser=i,this.sanitizer=a,this.commands=s,this._scrollToTop=!0}get scrollToTop(){return this._scrollToTop}set scrollToTop(e){this._scrollToTop=e}_createNew(e,i){const a=new qo(e,this.parser,this.sanitizer,i);let s=new WeakMap;const l=(m,b)=>{if(b){const f=async u=>{if(!u.inViewport)return;const C=s.get(b);if(C)if(this.scrollToTop)C.scrollIntoView({block:"start"}),e.content.outerNode.scrollTop-=Uo;else{const w=e.content.node.getBoundingClientRect(),B=C.getBoundingClientRect();(B.top>w.bottom||B.bottom<w.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)},x=b.cellRef,t=e.content.widgets.indexOf(x);x.model.type=="markdown"&&e.content.mode!="command"&&(e.content.mode="command"),e.content.activeCellIndex=t,x.inViewport?f(x).catch(u=>{console.error(`Fail to scroll to cell to display the required heading (${u}).`)}):e.content.scrollToItem(t,this.scrollToTop?"start":void 0).then(()=>p(x)).then(()=>f(x)).catch(u=>{console.error(`Fail to scroll to cell to display the required heading (${u}).`)})}},p=m=>Promise.all(a.getCellHeadings(m).map(async b=>{var f,x,o;const t=await Do(b,this.parser,this.sanitizer),u=(f=this.sanitizer.allowNamedProperties)!==null&&f!==void 0&&f?"id":"data-jupyter-id",C=t?`h${b.level}[${u}="${CSS.escape(t)}"]`:`h${b.level}`;b.outputIndex!==void 0?s.set(b,je(b.cellRef.outputArea.widgets[b.outputIndex].node,C,(x=b.prefix)!==null&&x!==void 0?x:"")):s.set(b,je(b.cellRef.node,C,(o=b.prefix)!==null&&o!==void 0?o:""))})).then(()=>{}),n=m=>{if(this.parser)return Re(e.content.node),s=new WeakMap,Promise.all(e.content.widgets.map(b=>p(b)))},c=(m,b)=>{var f,x,o,t;if(a.configuration.syncCollapseState)if(b!==null){const u=b.cellRef;u.headingCollapsed!==((f=b.collapsed)!==null&&f!==void 0?f:!1)&&(u.headingCollapsed=(x=b.collapsed)!==null&&x!==void 0?x:!1)}else{const u=(t=(o=a.headings[0])===null||o===void 0?void 0:o.collapsed)!==null&&t!==void 0?t:!1;e.content.widgets.forEach(C=>{C instanceof le&&C.headingInfo.level>=0&&(C.headingCollapsed=u)})}},d=(m,b)=>{if(a.configuration.syncCollapseState){const f=a.getCellHeadings(b)[0];f&&a.toggleCollapse({heading:f,collapsed:b.headingCollapsed})}},g=(m,b)=>{var f;b.inViewport?(f=p(b))===null||f===void 0||f.catch(console.warn):Re(b.node)};return e.context.ready.then(()=>{var m;(m=n())===null||m===void 0||m.catch(console.warn),a.activeHeadingChanged.connect(l),a.headingsChanged.connect(n),a.collapseChanged.connect(c),e.content.cellCollapsed.connect(d),e.content.cellInViewportChanged.connect(g),e.disposed.connect(()=>{a.activeHeadingChanged.disconnect(l),a.headingsChanged.disconnect(n),a.collapseChanged.disconnect(c),e.content.cellCollapsed.disconnect(d),e.content.cellInViewportChanged.disconnect(g)})}),a}getToolbarItems(e){return this.commands?[{name:"select-last-modified-back",widget:new Oe({commands:this.commands,id:"notebook:select-last-modified-cell",args:{toolbar:!0},icon:Bt,label:""})},{name:"select-last-modified-forward",widget:new Oe({commands:this.commands,id:"notebook:select-next-modified-cell",args:{toolbar:!0},icon:Et,label:""})}]:[]}}async function Do(r,e,i){let a=null;return r.type===Pe.HeadingType.Markdown?a=await Nt(e,r.raw,r.level,i):r.type===Pe.HeadingType.HTML&&(a=r.id),a}const Jo="jp-StatusItem-trust";function zo(r,e){e=e||O;const i=e.load("jupyterlab");return r.trustedCells===r.totalCells?i.__("Notebook trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells):r.activeCellTrusted?i.__("Active cell trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells):i.__("Notebook not trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells)}function Go(r){return r.allCellsTrusted?A.createElement(Ot.react,{top:"2px",stylesheet:"statusBar"}):A.createElement(jt.react,{top:"2px",stylesheet:"statusBar"})}class ae extends we{constructor(e){super(new ae.Model),this.translator=e||O,this.node.classList.add(Jo)}render(){if(!this.model)return null;const e=zo(this.model,this.translator);return e!==this.node.title&&(this.node.title=e),A.createElement(Go,{allCellsTrusted:this.model.trustedCells===this.model.totalCells,activeCellTrusted:this.model.activeCellTrusted,totalCells:this.model.totalCells,trustedCells:this.model.trustedCells})}}(function(r){class e extends ke{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(a){const s=this._notebook;s!==null&&(s.activeCellChanged.disconnect(this._onActiveCellChanged,this),s.modelContentChanged.disconnect(this._onModelChanged,this));const l=this._getAllState();if(this._notebook=a,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:n}=this._deriveCellTrustState(this._notebook.model);this._totalCells=p,this._trustedCells=n}this._triggerChange(l,this._getAllState())}_onModelChanged(a){const s=this._getAllState(),{total:l,trusted:p}=this._deriveCellTrustState(a.model);this._totalCells=l,this._trustedCells=p,this._triggerChange(s,this._getAllState())}_onActiveCellChanged(a,s){const l=this._getAllState();s?this._activeCellTrusted=s.model.trusted:this._activeCellTrusted=!1,this._triggerChange(l,this._getAllState())}_deriveCellTrustState(a){if(a===null)return{total:0,trusted:0};let s=0,l=0;for(const p of a.cells)p.type==="code"&&(s++,p.trusted&&l++);return{total:s,trusted:l}}_getAllState(){return[this._trustedCells,this._totalCells,this.activeCellTrusted]}_triggerChange(a,s){(a[0]!==s[0]||a[1]!==s[1]||a[2]!==s[2])&&this.stateChanged.emit(void 0)}}r.Model=e})(ae||(ae={}));const Yo=new Ze("@jupyterlab/metadataform:IMetadataFormProvider","A service to register new metadata editor widgets."),Xo={id:"@jupyterlab/notebook-extension:cell-executor",description:"Provides the notebook cell executor.",autoStart:!0,provides:tt,activate:()=>Object.freeze({runCell:Rt})},Zo=new Ze("@jupyterlab/logconsole:ILoggerRegistry","A service providing a logger infrastructure."),Qo={activate:en,id:"@jupyterlab/notebook-extension:log-output",description:"Adds cell outputs log to the application logger.",requires:[I],optional:[Zo],autoStart:!0};function en(r,e,i){if(!i)return;function a(s){function l(p,n,c){if(Y.KernelMessage.isDisplayDataMsg(p)||Y.KernelMessage.isStreamMsg(p)||Y.KernelMessage.isErrorMsg(p)||Y.KernelMessage.isExecuteResultMsg(p)){const d=i.getLogger(s.context.path);d.rendermime=s.content.rendermime;const g={...p.content,output_type:p.header.msg_type};let m=n;(Y.KernelMessage.isErrorMsg(p)||Y.KernelMessage.isStreamMsg(p)&&p.content.name==="stderr")&&(m=c),d.log({type:"output",data:g,level:m})}}s.context.sessionContext.iopubMessage.connect((p,n)=>l(n,"info","info")),s.context.sessionContext.unhandledMessage.connect((p,n)=>l(n,"warning","error"))}e.forEach(s=>a(s)),e.widgetAdded.connect((s,l)=>a(l))}const tn="jp-ActiveCellTool",on="jp-ActiveCellTool-Content",nn="jp-ActiveCellTool-CellContent";class ln extends q.Tool{constructor(e){super();const{languages:i}=e;this._tracker=e.tracker,this.addClass(tn),this.layout=new pe,this._inputPrompt=new It,this.layout.addWidget(this._inputPrompt);const a=document.createElement("div");a.classList.add(on);const s=a.appendChild(document.createElement("div")),l=s.appendChild(document.createElement("pre"));s.className=nn,this._editorEl=l,this.layout.addWidget(new Q({node:a}));const p=async()=>{var n,c;this._editorEl.innerHTML="",((n=this._cellModel)===null||n===void 0?void 0:n.type)==="code"?(this._inputPrompt.executionCount=`${(c=this._cellModel.executionCount)!==null&&c!==void 0?c:""}`,this._inputPrompt.show()):(this._inputPrompt.executionCount=null,this._inputPrompt.hide()),this._cellModel&&await i.highlight(this._cellModel.sharedModel.getSource().split(`
|
|
1
|
+
import{o as ue,t as rt,T as at,p as de,b as Ve,f as Ue,I as dt,j as ct,a as qe,d as ut,C as Ee,g as Ne}from"./index-BvvaLLhn.js";import{r as H,h2 as ht,c3 as pt,v as A,ag as Q,c0 as ne,ak as O,gF as gt,dG as bt,gw as mt,h3 as Ct,an as $e,dM as vt,gX as ft,dK as _t,cu as Z,c7 as yt,h4 as _,cH as De,cC as Je,cI as ze,g4 as Ge,g5 as Ye,dJ as xe,am as xt,ch as Xe,cg as ve,c1 as we,h5 as wt,h6 as kt,gZ as St,b_ as ke,l as Y,aW as At,gx as Mt,J as Tt,ah as pe,gK as G,h7 as he,af as ie,h8 as Ce,dD as Oe,h9 as Bt,ha as Et,cU as je,cS as Re,hb as le,cW as Ie,hc as Pe,cT as Nt,hd as Ot,he as jt,ac as Ze,hf as Rt,hg as It,dI as Pt,ai as F,dt as ge,hh as fe,cw as Lt,dB as Wt,c_ as Ht,hi as Ft,hj as se,hk as Qe,d6 as Kt,bZ as Vt,aj as Ut,cx as qt,c9 as $t,gI as Dt,hl as Jt,cM as zt,cP as Gt,hm as Yt,hn as Xt,ho as Zt,d9 as Qt,da as eo,cR as to,aV as oo,ed as no}from"../datalayer-app-main.js";import{b as io,I as et}from"./token-BRjncM66.js";import{ToolbarItems as lo}from"./index-CMUTS_sA.js";import{I as so}from"./index-Clp8quV1.js";import{I as Se}from"./tokens-BHMD_ju9.js";import{a as tt,I,b as ot,c as ro}from"./tokens-CydTkiyv.js";import{I as ao,a as nt}from"./tokens-BvmYCqiu.js";import{I as co}from"./tokens-CBD7cd6p.js";import{f as it,e as uo,c as ho,I as po,b as go}from"./index-B_9UD0bt.js";import{I as lt}from"./tokens-D1_9ZFxB.js";import{I as be}from"./tokens-BHLmeqjP.js";import{a as Ae}from"./tokens-_fLcuFXz.js";import{I as bo}from"./tokens-CENaHAHm.js";import{I as mo}from"./index-BYQwy0Zx.js";import{I as Co}from"./tokens-DXLxGbDM.js";import{W as vo,u as Le,V as fo,I as _o,a as yo,b as xo,c as wo}from"./document-BpXPH_dr.js";import{b as ko,c as So,d as Ao}from"./CellSidebarExtension-CQlXdanG.js";import{T as Mo,a as To}from"./model-BHONoBA6.js";import{C as We}from"./celltoolbartracker-D67W4XWx.js";import"./hoverbox-CStlKQWE.js";import"./Output-BscOPLqE.js";import"./index-BJ7Yskx5.js";import"./color-CG7_7V2-.js";import"./isEqual-BybBNsZK.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./PaintbrushIcon-CLU8RilX.js";import"./index-B3WvcNQa.js";import"./RestartIcon-Ca6_HoK0.js";import"./NotebookSkeleton-HdM76lOj.js";import"./Avatar-DbU3YP4x.js";import"./renderer-lVFw9lw7.js";import"./SquareIcon-e3ygcjpv.js";import"./SortAscIcon-CVKVWIWQ.js";import"./url-DuKx0yk0.js";/* empty css */import"./index-Dro44tIm.js";/* empty css *//* empty css */import"./index-DsG9xhMj.js";/* empty css */import"./index-CNU-WVhQ.js";import"./index--OLIX362.js";import"./index-DYGslHkf.js";import"./index-BSRVX3UN.js";import"./index-BH2OX5l8.js";import"./index-C3vDfO5_.js";import"./index-Ko8lxXFd.js";import"./index-CB9u17_J.js";import"./index-BUVtc_FV.js";import"./ArrowLeftIcon-Y3PTljcl.js";import"./SkubbleIcon-tlg17jBG.js";import"./usePrimerThemeBridge-D_1NuGKb.js";import"./index-j-oeqTuo.js";import"./KernelVariables-KCUfxhF4.js";import"./index-BvgsWH_d.js";import"./SortDescIcon-CS4EzHeS.js";import"./NotebookToolbar-DMKCe3c2.js";import"./RepoPushIcon-Cm8g9NuL.js";import"./Toolbar-6Hdi_m3T.js";import"./sessions-3PQsLINe.js";import"./tokens-BfuLIPUq.js";import"./drivecontents-Bg9_6Kmo.js";import"./kernel-BI-BLP-K.js";const Bo="jp-DefaultStyle",Eo="jp-HTMLSelect";class No extends H.Component{render(){const{className:e,defaultStyle:i=!0,disabled:a,elementRef:s,iconProps:l,icon:p=ht,options:n=[],...c}=this.props,d=pt(Eo,{[Bo]:i},e),g=b=>{b.stopPropagation()},m=n.map(b=>{const f=typeof b=="object"?b:{value:b};return H.createElement("option",{...f,key:f.value},f.label||f.value)});return H.createElement("div",{className:d},H.createElement("select",{onFocus:g,disabled:a,ref:s,...c,multiple:!1},m,c.children),H.createElement(p.react,{tag:"span",stylesheet:"select",right:"4px",top:"4px",...l}))}}function Oo(r){const i=a=>{const s=Math.max(a*3.6,.1),l=s*Math.PI/180,p=Math.sin(l)*104,n=Math.cos(l)*-104;return"M 0 0 v -104 A 104 104 1 "+(s<180?1:0)+" 0 "+p.toFixed(4)+" "+n.toFixed(4)+" z"};return A.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},A.createElement("svg",{viewBox:"0 0 250 250"},A.createElement("circle",{cx:"125",cy:"125",r:"104",stroke:"var(--jp-inverse-layout-color3)",strokeWidth:"20",fill:"none"}),A.createElement("path",{className:"jp-Statusbar-ProgressCirclePath",transform:"translate(125,125) scale(.9)",d:i(r.progress),fill:"var(--jp-inverse-layout-color3)"})))}const jo="jp-JSONEditor",ce="jp-mod-error",Ro="jp-JSONEditor-host",Io="jp-JSONEditor-header";class Po extends Q{constructor(e){super(),this._dataDirty=!1,this._inputDirty=!1,this._source=null,this._originalValue=ne.emptyObject,this._changeGuard=!1,this.translator=e.translator||O,this._trans=this.translator.load("jupyterlab"),this.addClass(jo),this.headerNode=document.createElement("div"),this.headerNode.className=Io,this.revertButtonNode=gt.element({tag:"span",title:this._trans.__("Revert changes to data")}),this.commitButtonNode=bt.element({tag:"span",title:this._trans.__("Commit changes to data"),marginLeft:"8px"}),this.editorHostNode=document.createElement("div"),this.editorHostNode.className=Ro,this.headerNode.appendChild(this.revertButtonNode),this.headerNode.appendChild(this.commitButtonNode),this.node.appendChild(this.headerNode),this.node.appendChild(this.editorHostNode);const i=new mt.Model({mimeType:"application/json"});i.sharedModel.changed.connect(this._onModelChanged,this),this.model=i,this.editor=e.editorFactory({host:this.editorHostNode,model:i,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 i=this.editorHostNode;i.addEventListener("blur",this,!0),i.addEventListener("click",this,!0),this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.headerNode.addEventListener("click",this)}onBeforeDetach(e){const i=this.editorHostNode;i.removeEventListener("blur",this,!0),i.removeEventListener("click",this,!0),this.headerNode.removeEventListener("click",this)}_onSourceChanged(e,i){if(!this._changeGuard){if(this._inputDirty||this.editor.hasFocus()){this._dataDirty=!0;return}this._setValue()}}_onModelChanged(e,i){if(i.sourceChange){let a=!0;try{const s=JSON.parse(this.editor.model.sharedModel.getSource());this.removeClass(ce),this._inputDirty=!this._changeGuard&&!ne.deepEqual(s,this._originalValue)}catch{this.addClass(ce),this._inputDirty=!0,a=!1}this.revertButtonNode.hidden=!this._inputDirty,this.commitButtonNode.hidden=!a||!this._inputDirty}}_evtBlur(e){!this._inputDirty&&this._dataDirty&&this._setValue()}_evtClick(e){const i=e.target;this.revertButtonNode.contains(i)?this._setValue():this.commitButtonNode.contains(i)?!this.commitButtonNode.hidden&&!this.hasClass(ce)&&(this._changeGuard=!0,this._mergeContent(),this._changeGuard=!1,this._setValue()):this.editorHostNode.contains(i)&&this.editor.focus()}_mergeContent(){const e=this.editor.model,i=this._originalValue,a=JSON.parse(e.sharedModel.getSource()),s=this.source;if(s){for(const l in a)ne.deepEqual(a[l],i[l]||null)||s.set(l,a[l]);for(const l in i)l in a||s.delete(l)}}_setValue(){this._dataDirty=!1,this._inputDirty=!1,this.revertButtonNode.hidden=!0,this.commitButtonNode.hidden=!0,this.removeClass(ce);const e=this.editor.model,i=this._source?this._source.toJSON():{};if(this._changeGuard=!0,i===void 0)e.sharedModel.setSource(this._trans.__("No data!")),this._originalValue=ne.emptyObject;else{const a=JSON.stringify(i,null,4);e.sharedModel.setSource(a),this._originalValue=i,a.length>1&&a[0]==="{"&&this.editor.setCursorPosition({line:0,column:1})}this._changeGuard=!1,this.commitButtonNode.hidden=!0,this.revertButtonNode.hidden=!0}}const Lo="jp-Notebook-toolbarCellType",Wo="jp-Notebook-toolbarCellTypeDropdown";var _e;(function(r){function e(g,m){const b=(m||O).load("jupyterlab");function f(){if(g.context.model.readOnly)return Xe({title:b.__("Cannot Save"),body:b.__("Document is read-only"),buttons:[ve.okButton()]});g.context.save().then(()=>{if(!g.isDisposed)return g.context.createCheckpoint()})}return Ct($e.create(H.createElement(vt,{signal:g.context.fileChanged},()=>H.createElement(ft,{icon:_t,onClick:f,tooltip:b.__("Save the notebook contents and create checkpoint"),enabled:!!(g&&g.context&&g.context.contentsModel&&g.context.contentsModel.writable)}))))}r.createSaveButton=e;function i(g,m){const b=(m||O).load("jupyterlab");return new Z({icon:yt,onClick:()=>{_.insertBelow(g.content)},tooltip:b.__("Insert a cell below")})}r.createInsertButton=i;function a(g,m,b){const f=(m||O).load("jupyterlab");return new Z({icon:De,onClick:async()=>{b?.get("useSystemClipboardForCells").composite?await _.cutToSystemClipboard(g.content):_.cut(g.content)},tooltip:f.__("Cut the selected cells")})}r.createCutButton=a;function s(g,m,b){const f=(m||O).load("jupyterlab");return new Z({icon:Je,onClick:async()=>{b?.get("useSystemClipboardForCells").composite?await _.copyToSystemClipboard(g.content):_.copy(g.content)},tooltip:f.__("Copy the selected cells")})}r.createCopyButton=s;function l(g,m,b){const f=(m||O).load("jupyterlab");return new Z({icon:ze,onClick:async()=>{b?.get("useSystemClipboardForCells").composite?await _.pasteFromSystemClipboard(g.content):_.paste(g.content)},tooltip:f.__("Paste cells from the clipboard")})}r.createPasteButton=l;function p(g,m,b){const f=(b??O).load("jupyterlab");return new Z({icon:Ge,onClick:()=>{_.runAndAdvance(g.content,g.sessionContext,m,b)},tooltip:f.__("Run the selected cells and advance")})}r.createRunButton=p;function n(g,m,b){const f=(b??O).load("jupyterlab");return new Z({icon:Ye,onClick:()=>{const x=m??new xe({translator:b});x.restart(g.sessionContext).then(o=>(o&&_.runAll(g.content,g.sessionContext,x,b),o))},tooltip:f.__("Restart the kernel, then re-run the whole notebook")})}r.createRestartRunAllButton=n;function c(g,m){return new Ho(g.content,m)}r.createCellTypeItem=c;function d(g,m,b,f){return[{name:"save",widget:e(g,b)},{name:"insert",widget:i(g,b)},{name:"cut",widget:a(g,b,f)},{name:"copy",widget:s(g,b,f)},{name:"paste",widget:l(g,b,f)},{name:"run",widget:p(g,m,b)},{name:"interrupt",widget:ue.createInterruptButton(g.sessionContext,b)},{name:"restart",widget:ue.createRestartButton(g.sessionContext,m,b)},{name:"restart-and-run",widget:n(g,m,b)},{name:"cellType",widget:c(g,b)},{name:"spacer",widget:xt.createSpacerItem()},{name:"kernelName",widget:ue.createKernelNameItem(g.sessionContext,m,b)}]}r.getDefaultItems=d})(_e||(_e={}));class Ho extends $e{constructor(e,i){super(),this.handleChange=a=>{a.target.value!=="-"&&(_.changeCellType(this._notebook,a.target.value),this._notebook.activate())},this.handleKeyDown=a=>{a.key==="Enter"&&this._notebook.activate()},this._trans=(i||O).load("jupyterlab"),this.addClass(Lo),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 i of this._notebook.widgets)if(this._notebook.isSelectedOrActive(i)&&i.model.type!==e){e="-";break}return H.createElement(No,{className:Wo,onChange:this.handleChange,onKeyDown:this.handleKeyDown,value:e,"aria-label":this._trans.__("Cell type"),title:this._trans.__("Select the cell type")},H.createElement("option",{value:"-"},"-"),H.createElement("option",{value:"code"},this._trans.__("Code")),H.createElement("option",{value:"markdown"},this._trans.__("Markdown")),H.createElement("option",{value:"raw"},this._trans.__("Raw")))}}function He(r){var e;const i=r.translator||O,a=rt(i),s=i.load("jupyterlab"),l=(e=r.displayOption.showJumpToCell)!==null&&e!==void 0?e:!1,p=r.state,n=r.displayOption.showOnToolBar,c=r.displayOption.showProgress,d=n?"down":"up",g=A.createElement("div",null),[m,b]=A.useState(!1);if(A.useEffect(()=>{if(m)return;const j=()=>{b(!0)};return _.executionScheduled.connect(j),()=>{_.executionScheduled.disconnect(j)}},[l,m]),!p)return g;const f=p.kernelStatus,x={alignSelf:"normal",height:"24px"},o=p.totalTime,t=p.scheduledCellNumber||0,u=p.scheduledCell.size||0,C=t-u;let w=100*C/t,B=c?"":"hidden";!c&&w<100&&(w=0);const M=j=>A.createElement(Oo,{progress:j,width:16,height:24,label:s.__("Kernel status")}),K=j=>s.__("Kernel status: %1",j),V=()=>{const j=r.notebook;_.selectLastRunCell(j),j.activeCell&&j.scrollToCell(j.activeCell)},R=(j,$,P)=>A.createElement("div",{className:"jp-Notebook-ExecutionIndicator",title:c?"":K(a[j]),"data-status":j},$,A.createElement("div",{className:`jp-Notebook-ExecutionIndicator-tooltip ${d} ${B}`},A.createElement("span",null," ",K(a[j])," "),P,l&&m&&A.createElement(St,{className:"jp-Notebook-ExecutionIndicator-jumpButton",onClick:V,title:s.__("Jump to current or last executed cell")},s.__("Jump to cell"))));if(p.kernelStatus==="connecting"||p.kernelStatus==="disconnected"||p.kernelStatus==="unknown")return R(f,A.createElement(wt.react,{...x}),[]);if(p.kernelStatus==="starting"||p.kernelStatus==="terminating"||p.kernelStatus==="restarting"||p.kernelStatus==="initializing")return R(f,A.createElement(kt.react,{...x}),[]);if(p.executionStatus==="busy")return R("busy",M(w),[A.createElement("span",{key:0},s.__("Executed %1/%2 cells",C,t)),A.createElement("span",{key:1},s._n("Elapsed time: %1 second","Elapsed time: %1 seconds",o))]);{const j=p.kernelStatus==="busy"?0:100,$=p.kernelStatus==="busy"||o===0?[]:[A.createElement("span",{key:0},s._n("Executed %1 cell","Executed %1 cells",t)),A.createElement("span",{key:1},s._n("Elapsed time: %1 second","Elapsed time: %1 seconds",o))];return R(p.kernelStatus,M(j),$)}}class X extends we{constructor(e,i=!0){super(new X.Model),this.translator=e||O,this.addClass("jp-mod-highlighted")}render(){if(this.model===null||!this.model.renderFlag)return A.createElement("div",null);{const e=this.model.currentNotebook;return e?A.createElement(He,{displayOption:this.model.displayOption,state:this.model.executionState(e),translator:this.translator,notebook:e}):A.createElement(He,{displayOption:this.model.displayOption,state:void 0,translator:this.translator,notebook:void 0})}}}(function(r){class e extends ke{constructor(){super(),this._notebookExecutionProgress=new WeakMap,this._displayOption={showOnToolBar:!0,showProgress:!0,showJumpToCell:!1},this._renderFlag=!0}attachNotebook(l){var p,n,c,d;if(l&&l.content&&l.context){const g=l.content,m=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 b=this._notebookExecutionProgress.get(g),f=u=>{b&&(b.kernelStatus=u.kernelDisplayStatus),this.stateChanged.emit(void 0)};m.statusChanged.connect(f,this);const x=u=>{b&&(b.kernelStatus=u.kernelDisplayStatus),this.stateChanged.emit(void 0)};m.connectionStatusChanged.connect(x,this),m.disposed.connect(u=>{u.connectionStatusChanged.disconnect(x,this),u.statusChanged.disconnect(f,this)});const o=(u,C)=>{const w=C.msg,B=w.header.msg_id;if(w.header.msg_type==="execute_request")this._cellScheduledCallback(g,B);else if(Y.KernelMessage.isStatusMsg(w)&&w.content.execution_state==="idle"){const M=w.parent_header.msg_id;this._cellExecutedCallback(g,M)}else Y.KernelMessage.isStatusMsg(w)&&w.content.execution_state==="restarting"?this._restartHandler(g):w.header.msg_type==="execute_input"&&this._startTimer(g)};(n=(p=m.session)===null||p===void 0?void 0:p.kernel)===null||n===void 0||n.anyMessage.connect(o),(d=(c=m.session)===null||c===void 0?void 0:c.kernel)===null||d===void 0||d.disposed.connect(u=>u.anyMessage.disconnect(o));const t=(u,C)=>{b&&(this._resetTime(b),this.stateChanged.emit(void 0),C.newValue&&C.newValue.anyMessage.connect(o))};m.kernelChanged.connect(t),m.disposed.connect(u=>u.kernelChanged.disconnect(t))}}}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 n=this._notebookExecutionProgress.get(l);n&&n.scheduledCell.has(p)&&(n.scheduledCell.delete(p),n.scheduledCell.size===0&&this._scheduleSwitchToIdle(n))}_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 n=this._notebookExecutionProgress.get(l);n&&!n.scheduledCell.has(p)&&(n.needReset&&this._resetTime(n),n.scheduledCell.add(p),n.scheduledCellNumber+=1)}_tick(l){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 i(s,l,p){const n=new r(l);return n.model.displayOption={showOnToolBar:!0,showProgress:!0,showJumpToCell:!1},n.model.attachNotebook({content:s.content,context:s.sessionContext}),p&&p.then(c=>{const d=g=>{const m=a(g);m.showJumpToCell&&(g.get("recordTiming").composite||g.set("recordTiming",!0).catch(f=>{console.error("Failed to auto-enable recordTiming:",f.message)})),n.model.updateRenderOption(m)};c.changed.connect(d),d(c),n.disposed.connect(()=>{c.changed.disconnect(d)})}).catch(c=>{console.error(c.message)}),n}r.createExecutionIndicatorItem=i;function a(s){let l=!0,p=!0,n=!1;const c=s.get("kernelStatus").composite;return c&&(l=!c.showOnStatusBar,p=c.showProgress,n=c.showJumpToRecentExecutionButton),{showOnToolBar:l,showProgress:p,showJumpToCell:n}}r.getSettingValue=a})(X||(X={}));function Fo(r){const e=(r.translator||O).load("jupyterlab");return H.createElement(at,{source:e.__("Mode: %1",r.modeNames[r.notebookMode])})}class re extends we{constructor(e){super(new re.Model),this.translator=e||O,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]),H.createElement(Fo,{notebookMode:this.model.notebookMode,translator:this.translator,modeNames:this._modeNames})):null}}(function(r){class e extends ke{constructor(){super(...arguments),this._onChanged=a=>{const s=this._notebookMode;this._notebook?this._notebookMode=a.mode:this._notebookMode="command",this._triggerChange(s,this._notebookMode)},this._notebookMode="command",this._notebook=null}get notebookMode(){return this._notebookMode}set notebook(a){const s=this._notebook;s!==null&&(s.stateChanged.disconnect(this._onChanged,this),s.activeCellChanged.disconnect(this._onChanged,this),s.modelContentChanged.disconnect(this._onChanged,this));const l=this._notebookMode;this._notebook=a,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(a,s){a!==s&&this.stateChanged.emit(void 0)}}r.Model=e})(re||(re={}));class Ko extends vo{constructor(e,i){super(e,i),this.editorWidget=e,this.options=i,this._type="code",this._readyDelegate=new At,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 i,a=this.language_info();return!a||!a.mimetype?i=this.widget.content.codeMimetype:i=a.mimetype,Array.isArray(i)?(e=i[0])!==null&&e!==void 0?e:Mt.defaultMimeType:i}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(i=>({ceEditor:this._getCellEditor(i),type:i.model.type,value:i.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 i=this._getCellAt(e);return this.widget.content.widgets.findIndex(s=>i===s)}getEditorIndex(e){let i=this._editorToCell.get(e);return this.editor.widgets.findIndex(a=>i===a)}getEditorWrapper(e){return this._editorToCell.get(e).node}async onKernelChanged(e,i){if(i.newValue)try{const a=this._languageInfo;await Le(this.isReady,-1),await this._updateLanguageInfo();const s=this._languageInfo;a?.name!=s.name||a?.mimetype!=s?.mimetype||a?.file_extension!=s?.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(a){console.warn(a),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(),Tt.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,i){let a=[],s=[];const l=this._type;if(i.type==="set"){let p=[],n=[];if(i.newValues.length===i.oldValues.length){for(let c=0;c<i.newValues.length;c++)i.oldValues[c].type===l&&i.newValues[c].type!==l?p.push(i.newValues[c]):i.oldValues[c].type!==l&&i.newValues[c].type===l&&n.push(i.newValues[c]);a=n,s=p}}else i.type=="add"&&(a=i.newValues.filter(p=>p.type===l));(s.length||a.length||i.type==="set"||i.type==="move"||i.type==="remove"||i.type==="clear")&&await this.updateDocuments();for(let p of a){let n=this.widget.content.widgets.find(c=>c.model.id===p.id);if(!n){console.warn(`Widget for added cell with ID: ${p.id} not found!`);continue}this._getCellEditor(n)}}createVirtualDocument(){return new fo({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 Le(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,i,a,s;const l=(s=await((a=(i=(e=this.widget.context.sessionContext)===null||e===void 0?void 0:e.session)===null||i===void 0?void 0:i.kernel)===null||a===void 0?void 0:a.info))===null||s===void 0?void 0:s.language_info;if(l)this._languageInfo=l;else throw new Error("Language info update failed (no session, kernel, or info available)")}_activeCellChanged(e,i){!i||i.model.type!==this._type||this._activeEditorChanged.emit({editor:this._getCellEditor(i)})}_getCellAt(e){let i=this.virtualDocument.getEditorAtVirtualLine(e);return this._editorToCell.get(i)}_getCellEditor(e){if(!this._cellToEditor.has(e)){const i=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,i),this._editorToCell.set(i,e),e.disposed.connect(()=>{this._cellToEditor.delete(e),this._editorToCell.delete(i),this._editorRemoved.emit({editor:i})}),this._editorAdded.emit({editor:i})}return this._cellToEditor.get(e)}}class Vo extends Q{constructor(){super(),this._items=[],this.layout=new pe,this.addClass("jp-RankedPanel")}addWidget(e,i){const a={widget:e,rank:i},s=ie.upperBound(this._items,a,ye.itemCmp);ie.insert(this._items,s,a),this.layout.insertWidget(s,e)}onChildRemoved(e){const i=ie.findFirstIndex(this._items,a=>a.widget===e.child);i!==-1&&ie.removeAt(this._items,i)}}class q extends Q{constructor(e){super(),this.addClass("jp-NotebookTools"),this.translator=e.translator||O,this._tools=[],this.layout=new pe,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 i=e.content;return i.widgets.filter(a=>i.isSelectedOrActive(a))}get activeNotebookPanel(){return this._tracker.currentWidget}addItem(e){var i;const a=e.tool,s=(i=e.rank)!==null&&i!==void 0?i:100;let l;const p=this._tools.find(n=>n.section===e.section);if(p)l=p.panel;else throw new Error(`The section ${e.section} does not exist`);a.addClass("jp-NotebookTools-tool"),l.addWidget(a,s),a.notebookTools=this,G.sendMessage(a,q.ActiveNotebookPanelMessage),G.sendMessage(a,q.ActiveCellMessage)}addSection(e){var i;const a=e.sectionName,s=e.label||e.sectionName,l=e.tool;let p=(i=e.rank)!==null&&i!==void 0?i:null;const n=new Vo;if(n.title.label=s,l&&n.addWidget(l,0),this._tools.push({section:a,panel:n,rank:p}),p!=null)this.layout.insertWidget(p,new de({widget:n}));else{let c=null;const d=this.layout;for(let g=0;g<d.widgets.length;g++){let m=d.widgets[g];if(m instanceof de&&m.widget.id==="advancedToolsSection"){c=g;break}}c!==null?this.layout.insertWidget(c,new de({widget:n})):this.layout.addWidget(new de({widget:n}))}}_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 i of this._toolChildren())G.sendMessage(i,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 i of this._toolChildren())G.sendMessage(i,q.ActiveCellMessage)}_onSelectionChanged(){for(const e of this._toolChildren())G.sendMessage(e,q.SelectionMessage)}_onActiveNotebookPanelMetadataChanged(e,i){const a=new he.ChangeMessage("activenotebookpanel-metadata-changed",{oldValue:void 0,newValue:void 0,...i});for(const s of this._toolChildren())G.sendMessage(s,a)}_onActiveCellMetadataChanged(e,i){const a=new he.ChangeMessage("activecell-metadata-changed",{newValue:void 0,oldValue:void 0,...i});for(const s of this._toolChildren())G.sendMessage(s,a)}*_toolChildren(){for(let e of this._tools)yield*e.panel.children()}}(function(r){r.ActiveNotebookPanelMessage=new Ce("activenotebookpanel-changed"),r.ActiveCellMessage=new Ce("activecell-changed"),r.SelectionMessage=new Ce("selection-changed");class e extends Q{dispose(){super.dispose(),this.notebookTools&&(this.notebookTools=null)}processMessage(s){switch(super.processMessage(s),s.type){case"activenotebookpanel-changed":this.onActiveNotebookPanelChanged(s);break;case"activecell-changed":this.onActiveCellChanged(s);break;case"selection-changed":this.onSelectionChanged(s);break;case"activecell-metadata-changed":this.onActiveCellMetadataChanged(s);break;case"activenotebookpanel-metadata-changed":this.onActiveNotebookPanelMetadataChanged(s);break}}onActiveNotebookPanelChanged(s){}onActiveCellChanged(s){}onSelectionChanged(s){}onActiveCellMetadataChanged(s){}onActiveNotebookPanelMetadataChanged(s){}}r.Tool=e;class i extends e{constructor(s){super();const{editorFactory:l}=s;this.addClass("jp-MetadataEditorTool");const p=this.layout=new pe;this._editorFactory=l,this._editorLabel=s.label||"Edit Metadata",this.createEditor();const n=new Q({node:document.createElement("label")});n.node.textContent=s.label||"Edit Metadata",p.addWidget(n),p.addWidget(this.editor)}get editor(){return this._editor}onActiveNotebookPanelChanged(s){this.editor.dispose(),this.notebookTools.activeNotebookPanel&&this.createEditor()}createEditor(){this._editor=new Po({editorFactory:this._editorFactory}),this.editor.title.label=this._editorLabel,this.layout.addWidget(this.editor)}}r.MetadataEditorTool=i})(q||(q={}));var ye;(function(r){function e(i,a){return i.rank-a.rank}r.itemCmp=e})(ye||(ye={}));const Uo=6;var W;(function(r){r[r.Idle=-1]="Idle",r[r.Error=-.5]="Error",r[r.Scheduled=0]="Scheduled",r[r.Running=1]="Running"})(W||(W={}));class qo extends To{constructor(e,i,a,s){super(e,s),this.parser=i,this.sanitizer=a,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),_.executionScheduled.connect(this.onExecutionScheduled,this),_.executed.connect(this.onExecuted,this),_.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 i=new Array;let a=this._cellToHeadingIndex.get(e);if(a!==void 0){const s=this.headings[a];for(i.push(s);this.headings[a-1]&&this.headings[a-1].cellRef===s.cellRef;)a--,i.unshift(this.headings[a])}return i}dispose(){var e,i,a;this.isDisposed||(this.headingsChanged.disconnect(this.onHeadingsChanged,this),(i=(e=this.widget.context)===null||e===void 0?void 0:e.model)===null||i===void 0||i.metadataChanged.disconnect(this.onMetadataChanged,this),(a=this.widget.content)===null||a===void 0||a.activeCellChanged.disconnect(this.onActiveCellChanged,this),_.executionScheduled.disconnect(this.onExecutionScheduled,this),_.executed.disconnect(this.onExecuted,this),_.outputCleared.disconnect(this.onOutputCleared,this),this._runningCells.length=0,this._errorCells.length=0,super.dispose())}setConfiguration(e){const i=this.loadConfigurationFromMetadata();super.setConfiguration({...this.configuration,...i,...e})}toggleCollapse(e){super.toggleCollapse(e),this.updateRunningStatus(this.headings)}async getHeadings(){const e=this.widget.content.widgets,i=new Set(e),a=[],s=new Array,l=new WeakMap;for(let p=0;p<e.length;p++){const n=e[p];switch(n.model.type){case"code":{!this.configuration.syncCollapseState&&this.configuration.includeOutput&&a.push(...Ie(await n.getHeadings(),this.configuration,s).map(d=>({...d,cellRef:n,collapsed:!1,isRunning:W.Idle})));break}case"markdown":{const d=Ie(await n.getHeadings(),this.configuration,s).map((g,m)=>({...g,cellRef:n,collapsed:!1,isRunning:W.Idle}));if(this.configuration.syncCollapseState&&n.headingCollapsed){const g=Math.min(...d.map(b=>b.level)),m=d.find(b=>b.level===g);m.collapsed=n.headingCollapsed}a.push(...d);break}}a.length>0&&l.set(n,a.length-1)}return this._cellToHeadingIndex=l,this._runningCells=this._runningCells.filter(p=>i.has(p)),this._errorCells=this._errorCells.filter(p=>i.has(p)),this.updateRunningStatus(a),Promise.resolve(a)}isHeadingEqual(e,i){return super.isHeadingEqual(e,i)&&e.cellRef===i.cellRef&&e.isRunning===i.isRunning}loadConfigurationFromMetadata(){const e=this.widget.content.model,i={};if(e)for(const a in this.configMetadataMap){const s=this.configMetadataMap[a];for(const l of s){let p=l;const n=p[0]==="!";n&&(p=p.slice(1));const c=p.split("/");let d=e.getMetadata(c[0]);for(let g=1;g<c.length;g++)d=(d??{})[c[g]];d!==void 0&&(typeof d=="boolean"&&n&&(d=!d),i[a]=d)}}return i}onActiveCellChanged(e,i){const a=this.getCellHeadings(i)[0];this.setActiveHeading(a??null,!1)}onHeadingsChanged(){this.widget.content.activeCell&&this.onActiveCellChanged(this.widget.content,this.widget.content.activeCell)}onExecuted(e,i){this._runningCells.forEach((a,s)=>{var l;if(a===i.cell){this._runningCells.splice(s,1);const p=this._cellToHeadingIndex.get(a);if(p!==void 0){const n=this.headings[p];if(i.success||((l=i.error)===null||l===void 0?void 0:l.errorName)===void 0){n.isRunning=W.Idle;return}n.isRunning=W.Error,this._errorCells.includes(a)||this._errorCells.push(a)}}}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onExecutionScheduled(e,i){this._runningCells.includes(i.cell)||this._runningCells.push(i.cell),this._errorCells.forEach((a,s)=>{a===i.cell&&this._errorCells.splice(s,1)}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onOutputCleared(e,i){this._errorCells.forEach((a,s)=>{if(a===i.cell){this._errorCells.splice(s,1);const l=this._cellToHeadingIndex.get(a);if(l!==void 0){const p=this.headings[l];p.isRunning=W.Idle}}}),this.updateRunningStatus(this.headings),this.stateChanged.emit()}onMetadataChanged(){this.setConfiguration({})}updateRunningStatus(e){e.forEach(s=>{s.isRunning=W.Idle}),this._runningCells.forEach((s,l)=>{const p=this._cellToHeadingIndex.get(s);if(p!==void 0){const n=e[p];n.isRunning!==W.Running&&(n.isRunning=l>0?W.Scheduled:W.Running)}}),this._errorCells.forEach((s,l)=>{const p=this._cellToHeadingIndex.get(s);if(p!==void 0){const n=e[p];n.isRunning===W.Idle&&(n.isRunning=W.Error)}});let i=0;for(;i<e.length;){const s=e[i];if(i++,s.collapsed){const l=Math.max(s.isRunning,a(e,s.level));s.dataset={...s.dataset,"data-running":l.toString()}}else s.dataset={...s.dataset,"data-running":s.isRunning.toString()}}function a(s,l){let p=W.Idle;for(;i<s.length;){const n=s[i];if(n.dataset={...n.dataset,"data-running":n.isRunning.toString()},n.level>l)i++,p=Math.max(n.isRunning,p),n.collapsed&&(p=Math.max(p,a(s,n.level)),n.dataset={...n.dataset,"data-running":p.toString()});else break}return p}}}class $o extends Mo{constructor(e,i,a,s){super(e),this.parser=i,this.sanitizer=a,this.commands=s,this._scrollToTop=!0}get scrollToTop(){return this._scrollToTop}set scrollToTop(e){this._scrollToTop=e}_createNew(e,i){const a=new qo(e,this.parser,this.sanitizer,i);let s=new WeakMap;const l=(m,b)=>{if(b){const f=async u=>{if(!u.inViewport)return;const C=s.get(b);if(C)if(this.scrollToTop)C.scrollIntoView({block:"start"}),e.content.outerNode.scrollTop-=Uo;else{const w=e.content.node.getBoundingClientRect(),B=C.getBoundingClientRect();(B.top>w.bottom||B.bottom<w.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)},x=b.cellRef,t=e.content.widgets.indexOf(x);x.model.type=="markdown"&&e.content.mode!="command"&&(e.content.mode="command"),e.content.activeCellIndex=t,x.inViewport?f(x).catch(u=>{console.error(`Fail to scroll to cell to display the required heading (${u}).`)}):e.content.scrollToItem(t,this.scrollToTop?"start":void 0).then(()=>p(x)).then(()=>f(x)).catch(u=>{console.error(`Fail to scroll to cell to display the required heading (${u}).`)})}},p=m=>Promise.all(a.getCellHeadings(m).map(async b=>{var f,x,o;const t=await Do(b,this.parser,this.sanitizer),u=(f=this.sanitizer.allowNamedProperties)!==null&&f!==void 0&&f?"id":"data-jupyter-id",C=t?`h${b.level}[${u}="${CSS.escape(t)}"]`:`h${b.level}`;b.outputIndex!==void 0?s.set(b,je(b.cellRef.outputArea.widgets[b.outputIndex].node,C,(x=b.prefix)!==null&&x!==void 0?x:"")):s.set(b,je(b.cellRef.node,C,(o=b.prefix)!==null&&o!==void 0?o:""))})).then(()=>{}),n=m=>{if(this.parser)return Re(e.content.node),s=new WeakMap,Promise.all(e.content.widgets.map(b=>p(b)))},c=(m,b)=>{var f,x,o,t;if(a.configuration.syncCollapseState)if(b!==null){const u=b.cellRef;u.headingCollapsed!==((f=b.collapsed)!==null&&f!==void 0?f:!1)&&(u.headingCollapsed=(x=b.collapsed)!==null&&x!==void 0?x:!1)}else{const u=(t=(o=a.headings[0])===null||o===void 0?void 0:o.collapsed)!==null&&t!==void 0?t:!1;e.content.widgets.forEach(C=>{C instanceof le&&C.headingInfo.level>=0&&(C.headingCollapsed=u)})}},d=(m,b)=>{if(a.configuration.syncCollapseState){const f=a.getCellHeadings(b)[0];f&&a.toggleCollapse({heading:f,collapsed:b.headingCollapsed})}},g=(m,b)=>{var f;b.inViewport?(f=p(b))===null||f===void 0||f.catch(console.warn):Re(b.node)};return e.context.ready.then(()=>{var m;(m=n())===null||m===void 0||m.catch(console.warn),a.activeHeadingChanged.connect(l),a.headingsChanged.connect(n),a.collapseChanged.connect(c),e.content.cellCollapsed.connect(d),e.content.cellInViewportChanged.connect(g),e.disposed.connect(()=>{a.activeHeadingChanged.disconnect(l),a.headingsChanged.disconnect(n),a.collapseChanged.disconnect(c),e.content.cellCollapsed.disconnect(d),e.content.cellInViewportChanged.disconnect(g)})}),a}getToolbarItems(e){return this.commands?[{name:"select-last-modified-back",widget:new Oe({commands:this.commands,id:"notebook:select-last-modified-cell",args:{toolbar:!0},icon:Bt,label:""})},{name:"select-last-modified-forward",widget:new Oe({commands:this.commands,id:"notebook:select-next-modified-cell",args:{toolbar:!0},icon:Et,label:""})}]:[]}}async function Do(r,e,i){let a=null;return r.type===Pe.HeadingType.Markdown?a=await Nt(e,r.raw,r.level,i):r.type===Pe.HeadingType.HTML&&(a=r.id),a}const Jo="jp-StatusItem-trust";function zo(r,e){e=e||O;const i=e.load("jupyterlab");return r.trustedCells===r.totalCells?i.__("Notebook trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells):r.activeCellTrusted?i.__("Active cell trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells):i.__("Notebook not trusted: %1 of %2 code cells trusted.",r.trustedCells,r.totalCells)}function Go(r){return r.allCellsTrusted?A.createElement(Ot.react,{top:"2px",stylesheet:"statusBar"}):A.createElement(jt.react,{top:"2px",stylesheet:"statusBar"})}class ae extends we{constructor(e){super(new ae.Model),this.translator=e||O,this.node.classList.add(Jo)}render(){if(!this.model)return null;const e=zo(this.model,this.translator);return e!==this.node.title&&(this.node.title=e),A.createElement(Go,{allCellsTrusted:this.model.trustedCells===this.model.totalCells,activeCellTrusted:this.model.activeCellTrusted,totalCells:this.model.totalCells,trustedCells:this.model.trustedCells})}}(function(r){class e extends ke{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(a){const s=this._notebook;s!==null&&(s.activeCellChanged.disconnect(this._onActiveCellChanged,this),s.modelContentChanged.disconnect(this._onModelChanged,this));const l=this._getAllState();if(this._notebook=a,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:n}=this._deriveCellTrustState(this._notebook.model);this._totalCells=p,this._trustedCells=n}this._triggerChange(l,this._getAllState())}_onModelChanged(a){const s=this._getAllState(),{total:l,trusted:p}=this._deriveCellTrustState(a.model);this._totalCells=l,this._trustedCells=p,this._triggerChange(s,this._getAllState())}_onActiveCellChanged(a,s){const l=this._getAllState();s?this._activeCellTrusted=s.model.trusted:this._activeCellTrusted=!1,this._triggerChange(l,this._getAllState())}_deriveCellTrustState(a){if(a===null)return{total:0,trusted:0};let s=0,l=0;for(const p of a.cells)p.type==="code"&&(s++,p.trusted&&l++);return{total:s,trusted:l}}_getAllState(){return[this._trustedCells,this._totalCells,this.activeCellTrusted]}_triggerChange(a,s){(a[0]!==s[0]||a[1]!==s[1]||a[2]!==s[2])&&this.stateChanged.emit(void 0)}}r.Model=e})(ae||(ae={}));const Yo=new Ze("@jupyterlab/metadataform:IMetadataFormProvider","A service to register new metadata editor widgets."),Xo={id:"@jupyterlab/notebook-extension:cell-executor",description:"Provides the notebook cell executor.",autoStart:!0,provides:tt,activate:()=>Object.freeze({runCell:Rt})},Zo=new Ze("@jupyterlab/logconsole:ILoggerRegistry","A service providing a logger infrastructure."),Qo={activate:en,id:"@jupyterlab/notebook-extension:log-output",description:"Adds cell outputs log to the application logger.",requires:[I],optional:[Zo],autoStart:!0};function en(r,e,i){if(!i)return;function a(s){function l(p,n,c){if(Y.KernelMessage.isDisplayDataMsg(p)||Y.KernelMessage.isStreamMsg(p)||Y.KernelMessage.isErrorMsg(p)||Y.KernelMessage.isExecuteResultMsg(p)){const d=i.getLogger(s.context.path);d.rendermime=s.content.rendermime;const g={...p.content,output_type:p.header.msg_type};let m=n;(Y.KernelMessage.isErrorMsg(p)||Y.KernelMessage.isStreamMsg(p)&&p.content.name==="stderr")&&(m=c),d.log({type:"output",data:g,level:m})}}s.context.sessionContext.iopubMessage.connect((p,n)=>l(n,"info","info")),s.context.sessionContext.unhandledMessage.connect((p,n)=>l(n,"warning","error"))}e.forEach(s=>a(s)),e.widgetAdded.connect((s,l)=>a(l))}const tn="jp-ActiveCellTool",on="jp-ActiveCellTool-Content",nn="jp-ActiveCellTool-CellContent";class ln extends q.Tool{constructor(e){super();const{languages:i}=e;this._tracker=e.tracker,this.addClass(tn),this.layout=new pe,this._inputPrompt=new It,this.layout.addWidget(this._inputPrompt);const a=document.createElement("div");a.classList.add(on);const s=a.appendChild(document.createElement("div")),l=s.appendChild(document.createElement("pre"));s.className=nn,this._editorEl=l,this.layout.addWidget(new Q({node:a}));const p=async()=>{var n,c;this._editorEl.innerHTML="",((n=this._cellModel)===null||n===void 0?void 0:n.type)==="code"?(this._inputPrompt.executionCount=`${(c=this._cellModel.executionCount)!==null&&c!==void 0?c:""}`,this._inputPrompt.show()):(this._inputPrompt.executionCount=null,this._inputPrompt.hide()),this._cellModel&&await i.highlight(this._cellModel.sharedModel.getSource().split(`
|
|
2
2
|
`)[0],i.findByMIME(this._cellModel.mimeType),this._editorEl)};this._refreshDebouncer=new Pt(p,150)}render(e){var i,a;const s=this._tracker.activeCell;return s&&(this._cellModel=s?.model||null),((i=this._cellModel)===null||i===void 0?void 0:i.sharedModel).changed.connect(this.refresh,this),(a=this._cellModel)===null||a===void 0||a.mimeTypeChanged.connect(this.refresh,this),this.refresh().then(()=>{}).catch(()=>{}),A.createElement("div",{ref:l=>l?.appendChild(this.node)})}async refresh(){await this._refreshDebouncer.invoke()}}const sn="jp-CellMetadataEditor",rn="jp-NotebookMetadataEditor";class an 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,i,a;const s=(e=this._tracker.activeCell)===null||e===void 0?void 0:e.model.sharedModel;if(s&&this.editor.source){const l=Object.keys((i=s.metadata)!==null&&i!==void 0?i:{}),p=(a=this.editor.source.toJSON())!==null&&a!==void 0?a:{};s.transact(()=>{l.forEach(n=>s.deleteMetadata(n)),s.setMetadata(p)})}}render(e){var i;const a=this._tracker.activeCell;return this.editor.source=a?new he({values:a.model.metadata}):null,(i=this.editor.source)===null||i===void 0||i.changed.connect(this._onSourceChanged,this),A.createElement("div",{className:sn},A.createElement("div",{ref:s=>s?.appendChild(this.node)}))}}class dn 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,i;this.editor.source&&((i=(e=this._tracker.currentWidget)===null||e===void 0?void 0:e.model)===null||i===void 0||i.sharedModel.setMetadata(this.editor.source.toJSON()))}render(e){var i,a;const s=this._tracker.currentWidget;return this.editor.source=s?new he({values:(i=s.model)===null||i===void 0?void 0:i.metadata}):null,(a=this.editor.source)===null||a===void 0||a.changed.connect(this._onSourceChanged,this),A.createElement("div",{className:rn},A.createElement("div",{ref:l=>l?.appendChild(this.node)}))}}var h;(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.selectLastRunCell="notebook:select-last-run-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"})(h||(h={}));const D="Notebook",cn=["notebook","python","custom"],un="@jupyterlab/notebook-extension:panel",Fe="jp-NotebookExtension-sideBySideMargins",ee={id:"@jupyterlab/notebook-extension:tracker",description:"Provides the notebook widget tracker.",provides:I,requires:[ot,io,tt],optional:[Ve,ao,co,it,lt,uo,be,Ue,F,Ae,nt],activate:Ln,autoStart:!0},hn={id:"@jupyterlab/notebook-extension:factory",description:"Provides the notebook cell factory.",provides:fe.IContentFactory,requires:[ge],autoStart:!0,activate:(r,e)=>{const i=e.factoryService.newInlineEditor;return new fe.ContentFactory({editorFactory:i})}},pn={activate:On,provides:ro,id:"@jupyterlab/notebook-extension:tools",description:"Provides the notebook tools.",autoStart:!0,requires:[I,ge,et,Lt.IStateDB,F],optional:[so]},gn={id:"@jupyterlab/notebook-extension:mode-status",description:"Adds a notebook mode status widget.",autoStart:!0,requires:[I,F],optional:[Se],activate:(r,e,i,a)=>{if(!a)return;const{shell:s}=r,l=new re(i);e.currentChanged.connect(()=>{const p=e.currentWidget;l.model.notebook=p&&p.content}),a.registerStatusItem("@jupyterlab/notebook-extension:mode-status",{priority:1,item:l,align:"right",rank:4,isActive:()=>!!s.currentWidget&&!!e.currentWidget&&s.currentWidget===e.currentWidget})}},bn={id:"@jupyterlab/notebook-extension:execution-indicator",description:"Adds a notebook execution status widget.",autoStart:!0,requires:[I,ho,F],optional:[Se,be],activate:(r,e,i,a,s,l)=>{let p,n,c;const d=g=>{var m,b;let{showOnToolBar:f,showProgress:x,showJumpToCell:o}=g;if(f)c&&(i.currentChanged.disconnect(n),c.dispose());else{if(!s)return;p?.model||(p=new X(a),n=(t,u)=>{const{newValue:C}=u;if(C&&e.has(C)){const w=C;p.model.attachNotebook({content:w.content,context:w.sessionContext})}},c=s.registerStatusItem("@jupyterlab/notebook-extension:execution-indicator",{item:p,align:"left",rank:3,isActive:()=>{const t=i.currentWidget;return!!t&&e.has(t)}}),p.model.attachNotebook({content:(m=e.currentWidget)===null||m===void 0?void 0:m.content,context:(b=e.currentWidget)===null||b===void 0?void 0:b.sessionContext}),i.currentChanged.connect(n),p.disposed.connect(()=>{i.currentChanged.disconnect(n)})),p.model.displayOption={showOnToolBar:f,showProgress:x,showJumpToCell:o}}};if(l){const g=l.load(ee.id);Promise.all([g,r.restored]).then(([m])=>{d(X.getSettingValue(m)),m.changed.connect(b=>d(X.getSettingValue(b)))}).catch(m=>{console.error(m.message)})}}},mn={id:"@jupyterlab/notebook-extension:export",description:"Adds the export notebook commands.",autoStart:!0,requires:[F,I],optional:[lt,Ve],activate:(r,e,i,a,s)=>{var l;const p=e.load("jupyterlab"),{commands:n,shell:c}=r,d=r.serviceManager,g=()=>L.isEnabled(c,i);n.addCommand(h.exportToFormat,{label:x=>{if(x.label===void 0)return p.__("Save and Export Notebook to the given `format`.");const o=x.label;return x.isPalette?p.__("Save and Export Notebook: %1",o):o},execute:async x=>{var o,t;const u=v(i,c,x);if(!u)return;const{context:C}=u,w={format:x.format,path:u.context.path,exporterOptions:{download:!0}};return C.model.dirty&&!C.model.readOnly&&await C.save(),(t=(o=d.nbconvert).exportAs)===null||t===void 0?void 0:t.call(o,w)},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 m;a&&(m=(l=a.fileMenu.items.find(x=>{var o;return x.type==="submenu"&&((o=x.submenu)===null||o===void 0?void 0:o.id)==="jp-mainmenu-file-notebookexport"}))===null||l===void 0?void 0:l.submenu);let b=!1;const f=async()=>{if(b)return;i.widgetAdded.disconnect(f),b=!0;const x=await d.nbconvert.getExportFormats(!1);if(!x)return;const o=L.getFormatLabels(e);Object.keys(x).forEach(function(u){const C=p.__(u[0].toUpperCase()+u.substr(1)),w=o[u]?o[u]:C;let B={format:u,label:w,isPalette:!1};if(cn.indexOf(u)===-1&&(m&&m.addItem({command:h.exportToFormat,args:B}),s)){B={format:u,label:w,isPalette:!0};const M=p.__("Notebook Operations");s.addItem({command:h.exportToFormat,category:M,args:B})}})};i.widgetAdded.connect(f)}},Cn={id:"@jupyterlab/notebook-extension:trust-status",description:"Adds the notebook trusted status widget.",autoStart:!0,requires:[I,F],optional:[Se],activate:(r,e,i,a)=>{if(!a)return;const{shell:s}=r,l=new ae(i);e.currentChanged.connect(()=>{const p=e.currentWidget;l.model.notebook=p&&p.content}),a.registerStatusItem("@jupyterlab/notebook-extension:trust-status",{item:l,align:"right",rank:3,isActive:()=>!!s.currentWidget&&!!e.currentWidget&&s.currentWidget===e.currentWidget})}},vn={id:"@jupyterlab/notebook-extension:widget-factory",description:"Provides the notebook widget factory.",provides:ot,requires:[fe.IContentFactory,ge,po,dt],optional:[be,Ue,F],activate:jn,autoStart:!0},fn={id:"@jupyterlab/notebook-extension:cloned-outputs",description:"Adds the clone output feature.",requires:[bo,I,F],optional:[it],activate:Rn,autoStart:!0},_n={id:"@jupyterlab/notebook-extension:code-console",description:"Adds the notebook code consoles features.",requires:[I,F],activate:In,autoStart:!0},yn={id:"@jupyterlab/notebook-extension:copy-output",description:"Adds the copy cell outputs feature.",activate:Pn,requires:[F,I],autoStart:!0},xn={id:"@jupyterlab/notebook-extension:kernel-status",description:"Adds the notebook kernel status.",activate:(r,e,i)=>{const a=s=>{let l=null;return s&&e.has(s)?s.sessionContext:l};i.addSessionProvider(a)},requires:[I,ct],autoStart:!0},wn={id:"@jupyterlab/notebook-extension:cursor-position",description:"Adds the notebook cursor position status.",activate:(r,e,i)=>{let a=null;const s=async l=>{let p=null;if(l!==a){if(a?.content.activeCellChanged.disconnect(i.update),a=null,l&&e.has(l)){l.content.activeCellChanged.connect(i.update);const n=l.content.activeCell;p=null,n&&(await n.ready,p=n.editor),a=l}}else if(l){const n=l.content.activeCell;p=null,n&&(await n.ready,p=n.editor)}return p};i.addEditorProvider(s)},requires:[I,Wt],autoStart:!0},kn={id:"@jupyterlab/notebook-extension:completer",description:"Adds the code completion capability to notebooks.",requires:[I],optional:[mo,F,qe],activate:Wn,autoStart:!0},Sn={id:"@jupyterlab/notebook-extension:search",description:"Adds search capability to notebooks.",requires:[Co],autoStart:!0,activate:(r,e)=>{e.add("jp-notebookSearchProvider",Jt)}},An={id:"@jupyterlab/notebook-extension:toc",description:"Adds table of content capability to the notebooks",requires:[I,Ht,qe],optional:[go,be],autoStart:!0,activate:(r,e,i,a,s,l)=>{const p=new $o(e,s,a);i.add(p),l&&Promise.all([r.restored,l.load(ee.id)]).then(([n,c])=>{const d=()=>{var g;p.scrollToTop=(g=c.composite.scrollHeadingToTop)!==null&&g!==void 0?g:!0};d(),c.changed.connect(d)}).catch(n=>{console.error("Failed to load notebook table of content settings.",n)})}},Mn={id:"@jupyterlab/notebook-extension:language-server",description:"Adds language server capability to the notebooks.",requires:[I,_o,yo,xo,wo],activate:Hn,autoStart:!0},Tn={id:"@jupyterlab/notebook-extension:update-raw-mimetype",description:"Adds metadata form editor for raw cell mimetype.",autoStart:!0,requires:[I,Yo,F],activate:(r,e,i,a)=>{const s=a.load("jupyterlab");let l=!1;async function p(){if(l||!i.get("commonToolsSection"))return;const n=i.get("commonToolsSection").getProperties("/raw_mimetype");if(!n)return;e.widgetAdded.disconnect(p),l=!0;const d=await r.serviceManager.nbconvert.getExportFormats(!1);if(!d)return;const g=Object.keys(d),m=L.getFormatLabels(a);g.forEach(function(b){var f;if(!(((f=n.oneOf)===null||f===void 0?void 0:f.filter(o=>o.const===b).length)>0)){const o=s.__(b[0].toUpperCase()+b.substr(1)),t=m[b]?m[b]:o,u=d[b].output_mimetype;n.oneOf.push({const:u,title:t})}}),i.get("commonToolsSection").setProperties("/raw_mimetype",n)}e.widgetAdded.connect(p)}},Bn={id:"@jupyterlab/notebook-extension:metadata-editor",description:"Adds metadata form for full metadata editor.",autoStart:!0,requires:[I,ge,Ae],optional:[F],activate:(r,e,i,a,s)=>{const l=c=>i.factoryService.newInlineEditor(c),p={fieldRenderer:c=>new an({editorFactory:l,tracker:e,label:"Cell metadata",translator:s}).render(c)};a.addRenderer("@jupyterlab/notebook-extension:metadata-editor.cell-metadata",p);const n={fieldRenderer:c=>new dn({editorFactory:l,tracker:e,label:"Notebook metadata",translator:s}).render(c)};a.addRenderer("@jupyterlab/notebook-extension:metadata-editor.notebook-metadata",n)}},En={id:"@jupyterlab/notebook-extension:active-cell-tool",description:"Adds active cell field in the metadata editor tab.",autoStart:!0,requires:[I,Ae,et],activate:(r,e,i,a)=>{const s={fieldRenderer:l=>new ln({tracker:e,languages:a}).render(l)};i.addRenderer("@jupyterlab/notebook-extension:active-cell-tool.renderer",s)}},Nn={id:"@jupyterlab/notebook-extension:open-with-no-kernel",description:'Adds the "Notebook (no kernel)" option to the Open With menu.',requires:[nt],optional:[F],autoStart:!0,activate:(r,e,i)=>{const{tracker:a}=e,s=(i??O).load("jupyterlab"),l=[];function p(n){var c,d;l.forEach(f=>f.dispose()),l.length=0;const g=(d=(c=n.menu.items.find(f=>{var x;return f.type==="submenu"&&((x=f.submenu)===null||x===void 0?void 0:x.id)==="jp-contextmenu-open-with"}))===null||c===void 0?void 0:c.submenu)!==null&&d!==void 0?d:null;if(!g)return;(a.currentWidget?Array.from(a.currentWidget.selectedItems()):[]).some(f=>f.type==="notebook")&&l.push(g.addItem({command:"filebrowser:open",args:{label:s.__("Notebook (no kernel)"),factory:D,kernelPreference:{shouldStart:!1}}}))}r.contextMenu.opened.connect(p)}},el=[Xo,hn,ee,bn,mn,pn,gn,Cn,vn,Qo,fn,_n,yn,xn,wn,kn,Sn,An,Mn,Tn,Bn,En,Nn];function On(r,e,i,a,s,l,p){const n=l.load("jupyterlab"),c="notebook-tools",d=new q({tracker:e,translator:l}),g=(m,b)=>{switch(b.type){case"activate-request":s.save(c,{open:!0});break;case"after-hide":case"close-request":s.remove(c);break}return!0};return d.title.icon=Kt,d.title.caption=n.__("Notebook Tools"),d.id=c,G.installMessageHook(d,g),p&&e.widgetAdded.connect((m,b)=>{p.register(b).render(d)}),d}function jn(r,e,i,a,s,l,p,n){const c=n??O,d=p??new xe({translator:c}),g=Vt.PageConfig.getOption("notebookStartsKernel"),m=g===""||g.toLowerCase()==="true",{commands:b}=r;let f;s.addFactory(D,"save",t=>lo.createSaveButton(b,t.context.fileChanged)),s.addFactory(D,"cellType",t=>_e.createCellTypeItem(t,c)),s.addFactory(D,"kernelName",t=>ue.createKernelNameItem(t.sessionContext,d,c)),s.addFactory(D,"executionProgress",t=>{const u=l?.load(ee.id),C=X.createExecutionIndicatorItem(t,c,u);return u?.then(w=>{t.disposed.connect(()=>{w.dispose()})}),C}),l&&(f=Ut(s,l,D,un,c));const x=c.load("jupyterlab"),o=new Ao({name:D,label:x.__("Notebook"),fileTypes:["notebook"],modelName:"notebook",defaultFor:["notebook"],preferKernel:m,canStartKernel:!0,rendermime:a,contentFactory:e,editorConfig:se.defaultEditorConfig,notebookConfig:se.defaultNotebookConfig,mimeTypeService:i.mimeTypeService,toolbarFactory:f,translator:c});return r.docRegistry.addWidgetFactory(o),o}function Rn(r,e,i,a,s){const l=a.load("jupyterlab"),p=new qt({namespace:"cloned-outputs"});s&&s.restore(p,{command:h.createOutputView,args:g=>({path:g.content.path,index:g.content.index}),name:g=>`${g.content.path}:${g.content.index}`,when:i.restored});const{commands:n,shell:c}=r,d=()=>L.isEnabledAndSingleSelected(c,i);n.addCommand(h.createOutputView,{label:l.__("Create New View for Cell Output"),execute:async g=>{var m;let b,f;const x=g.path;let o=g.index;if(x&&o!==void 0&&o!==null){if(f=e.findWidget(x,D),!f)return}else{if(f=i.currentWidget,!f)return;b=f.content.activeCell,o=f.content.activeCellIndex}const t=new L.ClonedOutputArea({notebook:f,cell:b,index:o,translator:a}),u=new $t({content:t});f.context.addSibling(u,{ref:f.id,mode:"split-bottom",type:"Cloned Output"});const C=()=>{p.save(u)};f.context.pathChanged.connect(C),(m=f.context.model)===null||m===void 0||m.cells.changed.connect(C),p.add(u),f.content.disposed.connect(()=>{var w;f.context.pathChanged.disconnect(C),(w=f.context.model)===null||w===void 0||w.cells.changed.disconnect(C),u.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 In(r,e,i){const a=i.load("jupyterlab"),{commands:s,shell:l}=r,p=()=>L.isEnabled(l,e);s.addCommand(h.createConsole,{label:a.__("New Console for Notebook"),execute:n=>{const c=e.currentWidget;if(c)return L.createConsole(s,c,n.activate)},isEnabled:p,describedBy:{args:{type:"object",properties:{activate:{type:"boolean",description:a.__("Whether to activate the console after creation")}}}}}),s.addCommand(h.createSubshellConsole,{label:a.__("New Subshell Console for Notebook"),execute:n=>{const c=e.currentWidget;if(c)return L.createConsole(s,c,n.activate,!0)},isEnabled:p,isVisible:()=>{var n,c,d;const g=(c=(n=e.currentWidget)===null||n===void 0?void 0:n.context.sessionContext.session)===null||c===void 0?void 0:c.kernel;return(d=g?.supportsSubshells)!==null&&d!==void 0?d:!1},describedBy:{args:{type:"object",properties:{activate:{type:"boolean",description:a.__("Whether to activate the console after creation")}}}}}),s.addCommand(h.runInConsole,{label:a.__("Run Selected Text or Current Line in Console"),execute:async n=>{var c,d;const g=e.currentWidget;if(!g)return;const{context:m,content:b}=g,f=b.activeCell,x=f?.model.metadata,o=m.path;if(!f||f.model.type!=="code")return;let t;const u=f.editor;if(!u)return;const C=u.getSelection(),{start:w,end:B}=C;if(w.column!==B.column||w.line!==B.line){const K=u.getOffsetAt(C.start),V=u.getOffsetAt(C.end);t=u.model.sharedModel.getSource().substring(K,V)}else{const K=u.getCursorPosition(),V=u.model.sharedModel.getSource().split(`
|
|
3
3
|
`);let R=C.start.line;for(;R<u.lineCount&&!V[R].replace(/\s/g,"").length;)R+=1;let j=R>0,$=0,P=$+1;for(;;){t=V.slice($,P).join(`
|
|
4
4
|
`);const te=await((d=(c=g.context.sessionContext.session)===null||c===void 0?void 0:c.kernel)===null||d===void 0?void 0:d.requestIsComplete({code:t+`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ai as b}from"../datalayer-app-main.js";import{b as f,S}from"./index-BvvaLLhn.js";import{I}from"./tokens-BHMD_ju9.js";import{c as h}from"./index-
|
|
1
|
+
import{ai as b}from"../datalayer-app-main.js";import{b as f,S}from"./index-BvvaLLhn.js";import{I}from"./tokens-BHMD_ju9.js";import{c as h}from"./index-B_9UD0bt.js";import{I as g}from"./tokens-BHLmeqjP.js";import"./hoverbox-CStlKQWE.js";import"./Output-BscOPLqE.js";import"./index-BYQwy0Zx.js";import"./index-BJ7Yskx5.js";import"./color-CG7_7V2-.js";import"./isEqual-BybBNsZK.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./PaintbrushIcon-CLU8RilX.js";import"./index-B3WvcNQa.js";import"./RestartIcon-Ca6_HoK0.js";import"./CellSidebarExtension-CQlXdanG.js";import"./NotebookSkeleton-HdM76lOj.js";import"./Avatar-DbU3YP4x.js";import"./renderer-lVFw9lw7.js";import"./SquareIcon-e3ygcjpv.js";import"./SortAscIcon-CVKVWIWQ.js";import"./url-DuKx0yk0.js";/* empty css */import"./index-Dro44tIm.js";/* empty css *//* empty css */import"./index-DsG9xhMj.js";/* empty css */import"./index-CNU-WVhQ.js";import"./index--OLIX362.js";import"./index-DYGslHkf.js";import"./index-BSRVX3UN.js";import"./index-BH2OX5l8.js";import"./index-C3vDfO5_.js";import"./index-Ko8lxXFd.js";import"./index-CB9u17_J.js";import"./index-BUVtc_FV.js";import"./ArrowLeftIcon-Y3PTljcl.js";import"./SkubbleIcon-tlg17jBG.js";import"./usePrimerThemeBridge-D_1NuGKb.js";import"./index-j-oeqTuo.js";import"./KernelVariables-KCUfxhF4.js";import"./index-BvgsWH_d.js";import"./SortDescIcon-CS4EzHeS.js";import"./NotebookToolbar-DMKCe3c2.js";import"./RepoPushIcon-Cm8g9NuL.js";import"./Toolbar-6Hdi_m3T.js";import"./sessions-3PQsLINe.js";import"./tokens-BfuLIPUq.js";import"./drivecontents-Bg9_6Kmo.js";import"./kernel-BI-BLP-K.js";const s="@jupyterlab/statusbar-extension:plugin",gt={id:s,description:"Provides the application status bar.",requires:[b],provides:I,autoStart:!0,activate:(i,l,p,r,n)=>{const c=l.load("jupyterlab"),t=new S;t.id="jp-main-statusbar",i.shell.add(t,"bottom"),p&&p.layoutModified.connect(()=>{t.update()});const u=c.__("Main Area"),e="statusbar:toggle";if(i.commands.addCommand(e,{label:c.__("Show Status Bar"),execute:()=>{t.setHidden(t.isVisible),r&&r.set(s,"visible",t.isVisible)},isToggled:()=>t.isVisible,describedBy:{args:{type:"object",properties:{}}}}),i.commands.commandExecuted.connect((d,m)=>{m.id==="application:reset-layout"&&!t.isVisible&&i.commands.execute(e).catch(o=>{console.error("Failed to show the status bar.",o)})}),n&&n.addItem({command:e,category:u}),r){const d=r.load(s),m=o=>{const a=o.get("visible").composite;t.setHidden(!a)};Promise.all([d,i.restored]).then(([o])=>{m(o),o.changed.connect(a=>{m(a)})}).catch(o=>{console.error(o.message)})}return t},optional:[h,g,f]};export{gt as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c0 as S,v as i,ak as E,d9 as Z,da as ee,db as J,dc as te,c7 as oe,c1 as ne,an as ie,dd as re,c3 as ae,de as le,b_ as se,ai as x,df as de,dg as ce,dh as me,di as ue,dj as pe,dk as I,dl as O,dm as B,dn as R,dp as fe,dq as he,dr as ge,ds as be,bw as ve,dt as ye,du as G,_ as N,dv as _e,dw as Ee,W as Ce,dx as je,dy as $,dz as A,dA as Fe,dB as Se}from"../datalayer-app-main.js";import{T as xe,b as ke}from"./index-BvvaLLhn.js";import{I as Ie}from"./tokens-BHMD_ju9.js";import{I as we}from"./tokens-CydTkiyv.js";import{C as Te,a as Ne}from"./index-BYQwy0Zx.js";import{I as z,a as H,b as M}from"./token-BRjncM66.js";import{F as Ae,c as Me,A as Le,g as W,v as Pe}from"./index-C17RrmNV.js";import{I as De}from"./tokens-BHLmeqjP.js";import{a as Oe}from"./tokens-_fLcuFXz.js";import{c as Be}from"./index-1wTrAXI1.js";import{s as Re}from"./hover-oeJgWZ71.js";import"./hoverbox-CStlKQWE.js";import"./_baseRest-BmxuuM4H.js";import"./isSymbol-BLtK9CV6.js";import"./forEach-hknrtmxV.js";import"./uniqueId-BVuTZY3F.js";import"./toNumber-B1wj8-wx.js";import"./_baseClone-ByJL1tkX.js";import"./merge-B_wcPK4Y.js";import"./isEqual-BybBNsZK.js";import"./Output-2KxoKu5F.js";import"./index-BJ7Yskx5.js";import"./color-CG7_7V2-.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./PaintbrushIcon-CLU8RilX.js";import"./index-B3WvcNQa.js";import"./RestartIcon-Ca6_HoK0.js";import"./CellSidebarExtension-CQlXdanG.js";import"./NotebookSkeleton-HdM76lOj.js";import"./Avatar-DbU3YP4x.js";import"./renderer-lVFw9lw7.js";import"./SquareIcon-e3ygcjpv.js";import"./SortAscIcon-CVKVWIWQ.js";import"./url-DuKx0yk0.js";/* empty css */import"./index-Dro44tIm.js";/* empty css *//* empty css */import"./index-DsG9xhMj.js";/* empty css */import"./index-CNU-WVhQ.js";import"./index--OLIX362.js";import"./index-DYGslHkf.js";import"./index-BSRVX3UN.js";import"./index-BH2OX5l8.js";import"./index-C3vDfO5_.js";import"./index-Ko8lxXFd.js";import"./index-CB9u17_J.js";import"./index-BUVtc_FV.js";import"./ArrowLeftIcon-Y3PTljcl.js";import"./SkubbleIcon-tlg17jBG.js";import"./usePrimerThemeBridge-D_1NuGKb.js";import"./index-j-oeqTuo.js";import"./KernelVariables-KCUfxhF4.js";import"./index-BvgsWH_d.js";import"./SortDescIcon-CS4EzHeS.js";import"./NotebookToolbar-DMKCe3c2.js";import"./RepoPushIcon-Cm8g9NuL.js";import"./Toolbar-6Hdi_m3T.js";import"./sessions-3PQsLINe.js";import"./tokens-BfuLIPUq.js";import"./drivecontents-Bg9_6Kmo.js";import"./kernel-BI-BLP-K.js";const Ge={submitButtonOptions:{norender:!0}},V=t=>{var e;const r=((e=t.translator)!==null&&e!==void 0?e:E).load("jupyterlab");let a;const l=()=>t.direction==="up"?!t.item.hasMoveUp:!t.item.hasMoveDown,u=t.direction==="up"?t.item.index-1:t.item.index+1;if(t.buttonStyle==="icons"){const d={tag:"span",elementPosition:"center"};return a=t.direction==="up"?i.createElement(Z.react,{...d}):i.createElement(ee.react,{...d}),i.createElement(J,{className:"jp-ArrayOperationsButton",onClick:t.item.onReorderClick(t.item.index,u),disabled:l(),appearance:"stealth",title:r.__("Move item %1",t.direction)},a)}else return i.createElement("button",{className:"jp-mod-styled jp-mod-reject jp-ArrayOperationsButton",onClick:t.item.onReorderClick(t.item.index,u),disabled:l()},t.direction==="up"?r.__("Move up"):r.__("Move down"))},$e=t=>{var e;const r=((e=t.translator)!==null&&e!==void 0?e:E).load("jupyterlab");let a;return t.buttonStyle==="icons"?(a=i.createElement(te.react,{tag:"span",elementPosition:"center"}),i.createElement(J,{className:"jp-mod-styled jp-mod-warn jp-ArrayOperationsButton",onClick:t.item.onDropIndexClick(t.item.index),appearance:"stealth",title:r.__("Remove item")},a)):i.createElement("button",{className:"jp-mod-styled jp-mod-warn jp-ArrayOperationsButton",onClick:t.item.onDropIndexClick(t.item.index)},r.__("Remove"))},K=t=>{var e;const r=((e=t.translator)!==null&&e!==void 0?e:E).load("jupyterlab");let a;return t.buttonStyle==="icons"?a=i.createElement(oe.react,{tag:"span",elementSize:"xlarge",elementPosition:"center"}):a=r.__("Add"),i.createElement("button",{className:"jp-mod-styled jp-mod-accept jp-ArrayOperationsButton",onClick:t.onAddClick,title:r.__("Add item")},a)};function L(t){const{component:e,name:r,buttonStyle:a,compact:l,showModifiedFromDefault:u,translator:d}=t,s=l??!1,m=a??(s?"icons":"text"),f=o=>e({...o,buttonStyle:m,compact:s,showModifiedFromDefault:u??!0,translator:d??E});return r&&(f.displayName=r),f}function Y(t,e){const r=W("TitleFieldTemplate",t,e),a=W("DescriptionFieldTemplate",t,e);return{TitleField:r,DescriptionField:a}}const We=t=>L({...t,name:"JupyterLabArrayTemplate",component:e=>{var r;const{schema:a,registry:l,uiSchema:u,required:d}=e,s={schema:a,registry:l,uiSchema:u,required:d},{TitleField:m,DescriptionField:f}=Y(l,u);return i.createElement("div",{className:e.className},e.compact?i.createElement("div",{className:"jp-FormGroup-compactTitle"},i.createElement("div",{className:"jp-FormGroup-fieldLabel jp-FormGroup-contentItem",id:`${e.idSchema.$id}__title`},e.title||""),i.createElement("div",{className:"jp-FormGroup-description",id:`${e.idSchema.$id}-description`},e.schema.description||"")):i.createElement(i.Fragment,null,e.title&&i.createElement(m,{...s,title:e.title,id:`${e.idSchema.$id}-title`}),i.createElement(f,{...s,id:`${e.idSchema.$id}-description`,description:(r=e.schema.description)!==null&&r!==void 0?r:""})),e.items.map(o=>i.createElement("div",{key:o.key,className:o.className},o.children,i.createElement("div",{className:"jp-ArrayOperations"},i.createElement(V,{buttonStyle:e.buttonStyle,translator:e.translator,item:o,direction:"up"}),i.createElement(V,{buttonStyle:e.buttonStyle,translator:e.translator,item:o,direction:"down"}),i.createElement($e,{buttonStyle:e.buttonStyle,translator:e.translator,item:o})))),e.canAdd&&i.createElement(K,{onAddClick:e.onAddClick,buttonStyle:e.buttonStyle,translator:e.translator}))}}),Ve=t=>L({...t,name:"JupyterLabObjectTemplate",component:e=>{var r;const{schema:a,registry:l,uiSchema:u,required:d}=e,s={schema:a,registry:l,uiSchema:u,required:d},{TitleField:m,DescriptionField:f}=Y(l,u);return i.createElement("fieldset",{id:e.idSchema.$id},e.compact?i.createElement("div",{className:"jp-FormGroup-compactTitle"},i.createElement("div",{className:"jp-FormGroup-fieldLabel jp-FormGroup-contentItem",id:`${e.idSchema.$id}__title`},e.title||""),i.createElement("div",{className:"jp-FormGroup-description",id:`${e.idSchema.$id}__description`},e.schema.description||"")):i.createElement(i.Fragment,null,(e.title||(e.uiSchema||S.emptyObject)["ui:title"])&&i.createElement(m,{...s,id:`${e.idSchema.$id}__title`,title:e.title||`${(e.uiSchema||S.emptyObject)["ui:title"]}`||""}),i.createElement(f,{...s,id:`${e.idSchema.$id}__description`,description:(r=e.schema.description)!==null&&r!==void 0?r:""})),e.properties.map(o=>o.content),Me(e.schema,e.uiSchema,e.formData)&&i.createElement(K,{onAddClick:e.onAddClick(e.schema),buttonStyle:e.buttonStyle,translator:e.translator}))}}),qe=t=>L({...t,name:"JupyterLabFieldTemplate",component:e=>{var r;const a=((r=e.translator)!==null&&r!==void 0?r:E).load("jupyterlab");let l=!1,u;const{formData:d,schema:s,label:m,displayLabel:f,id:o,formContext:n,errors:c,rawErrors:p,children:h,onKeyChange:b,onDropPropertyClick:v}=e,{defaultFormData:j}=n,_=o.split("_");_.shift();const C=_.join("."),y=C==="",F=C===(e.uiSchema||S.emptyObject)["ui:field"];e.showModifiedFromDefault&&(u=_.reduce((k,X)=>k?.[X],j),l=!y&&d!==void 0&&u!==void 0&&!s.properties&&s.type!=="array"&&!S.deepEqual(d,u));const P=!y&&s.type!="object"&&o!="jp-SettingsEditor-@jupyterlab/shortcuts-extension:shortcuts_shortcuts",T=s.hasOwnProperty(Le),D=!(s.type==="object"||s.type==="array");return i.createElement("div",{className:`form-group ${f||s.type==="boolean"?"small-field":""}`},!F&&(p?.length?i.createElement("div",{className:"jp-modifiedIndicator jp-errorIndicator"}):l&&i.createElement("div",{className:"jp-modifiedIndicator"})),i.createElement("div",{className:`jp-FormGroup-content ${e.compact?"jp-FormGroup-contentCompact":"jp-FormGroup-contentNormal"}`},D&&f&&!y&&m&&!T?e.compact?i.createElement("div",{className:"jp-FormGroup-compactTitle"},i.createElement("div",{className:"jp-FormGroup-fieldLabel jp-FormGroup-contentItem"},m),D&&s.description&&P&&i.createElement("div",{className:"jp-FormGroup-description"},s.description)):i.createElement("h3",{className:"jp-FormGroup-fieldLabel jp-FormGroup-contentItem"},m):i.createElement(i.Fragment,null),T&&i.createElement("input",{className:"jp-FormGroup-contentItem jp-mod-styled",type:"text",onBlur:k=>b(k.target.value),defaultValue:m}),i.createElement("div",{className:`${y?"jp-root":s.type==="object"?"jp-objectFieldWrapper":s.type==="array"?"jp-arrayFieldWrapper":"jp-inputFieldWrapper jp-FormGroup-contentItem"}`},h),T&&i.createElement("button",{className:"jp-FormGroup-contentItem jp-mod-styled jp-mod-warn jp-FormGroup-removeButton",onClick:v(m)},a.__("Remove")),!e.compact&&s.description&&P&&i.createElement("div",{className:"jp-FormGroup-description"},s.description),l&&u!==void 0&&s.type!=="object"&&i.createElement("div",{className:"jp-FormGroup-default"},a.__("Default: %1",u!==null?u.toLocaleString():"null")),i.createElement("div",{className:"validationErrors"},c)))}});function Ue(t){const{buttonStyle:e,compact:r,showModifiedFromDefault:a,translator:l,formContext:u,...d}=t,s={...d.uiSchema||S.emptyObject};s["ui:options"]={...Ge,...s["ui:options"]},d.uiSchema=s;const{FieldTemplate:m,ArrayFieldTemplate:f,ObjectFieldTemplate:o}=t.templates||S.emptyObject,n={buttonStyle:e,compact:r,showModifiedFromDefault:a,translator:l},c=i.useMemo(()=>m??qe(n),[m,e,r,a,l]),p=i.useMemo(()=>f??We(n),[f,e,r,a,l]),h=i.useMemo(()=>o??Ve(n),[o,e,r,a,l]),b={FieldTemplate:c,ArrayFieldTemplate:p,ObjectFieldTemplate:h};return i.createElement(Ae,{templates:b,formContext:u,...d})}class Je extends i.Component{constructor(e){super(e),this._handleChange=r=>{this.setState({value:r.currentTarget.value})},this._handleSubmit=r=>{r.preventDefault();const a=parseInt(this._textInput.value,10);return!isNaN(a)&&isFinite(a)&&1<=a&&a<=this.props.maxLine&&this.props.handleSubmit(a),!1},this._handleFocus=()=>{this.setState({hasFocus:!0})},this._handleBlur=()=>{this.setState({hasFocus:!1})},this._textInput=null,this.translator=e.translator||E,this._trans=this.translator.load("jupyterlab"),this.state={value:"",hasFocus:!1,textInputId:re.createDomID()+"-line-number-input"}}componentDidMount(){this._textInput.focus()}render(){return i.createElement("div",{className:"jp-lineFormSearch"},i.createElement("form",{name:"lineColumnForm",onSubmit:this._handleSubmit,noValidate:!0},i.createElement("div",{className:ae("jp-lineFormWrapper","lm-lineForm-wrapper",this.state.hasFocus?"jp-lineFormWrapperFocusWithin":void 0)},i.createElement("input",{type:"text",id:this.state.textInputId,className:"jp-lineFormInput",onChange:this._handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur,value:this.state.value,ref:e=>{this._textInput=e}}),i.createElement("div",{className:"jp-baseLineForm jp-lineFormButtonContainer"},i.createElement(le.react,{className:"jp-baseLineForm jp-lineFormButtonIcon",elementPosition:"center"}),i.createElement("input",{type:"submit",className:"jp-baseLineForm jp-lineFormButton",value:""}))),i.createElement("label",{className:"jp-lineFormCaption",htmlFor:this.state.textInputId},this._trans.__("Go to line number between 1 and %1",this.props.maxLine))))}}function ze(t){const r=(t.translator||E).load("jupyterlab"),a=l=>{if(l.key==="Enter"||l.key==="Spacebar"||l.key===" ")l.preventDefault(),l.stopPropagation(),t.handleClick();else return};return i.createElement(xe,{role:"button","aria-haspopup":!0,onClick:t.handleClick,source:r.__("Ln %1, Col %2",t.line,t.column),title:r.__("Go to line number…"),tabIndex:0,onKeyDown:a})}class w extends ne{constructor(e){super(new w.Model),this._popup=null,this.addClass("jp-mod-highlighted"),this.translator=e||E}render(){return this.model===null?null:i.createElement(ze,{line:this.model.line,column:this.model.column,translator:this.translator,handleClick:()=>this._handleClick()})}_handleClick(){this._popup&&this._popup.dispose();const e=ie.create(i.createElement(Je,{handleSubmit:r=>this._handleSubmit(r),currentLine:this.model.line,maxLine:this.model.editor.lineCount,translator:this.translator}));this._popup=Re({body:e,anchor:this,align:"right"})}_handleSubmit(e){this.model.editor.setCursorPosition({line:e-1,column:0}),this._popup.dispose(),this.model.editor.focus()}}(function(t){class e extends se{constructor(){super(...arguments),this._onSelectionChanged=()=>{const a=this._getAllState(),l=this.editor.getCursorPosition();this._line=l.line+1,this._column=l.column+1,this._triggerChange(a,this._getAllState())},this._line=1,this._column=1,this._editor=null}get editor(){return this._editor}set editor(a){var l;const u=this._editor;!((l=u?.model)===null||l===void 0)&&l.selections&&u.model.selections.changed.disconnect(this._onSelectionChanged);const d=this._getAllState();if(this._editor=a,!this._editor)this._column=1,this._line=1;else{this._editor.model.selections.changed.connect(this._onSelectionChanged);const s=this._editor.getCursorPosition();this._column=s.column+1,this._line=s.line+1}this._triggerChange(d,this._getAllState())}get line(){return this._line}get column(){return this._column}_getAllState(){return[this._line,this._column]}_triggerChange(a,l){(a[0]!==l[0]||a[1]!==l[1])&&this.stateChanged.emit(void 0)}}t.Model=e})(w||(w={}));var g;(function(t){t.deleteLine="codemirror:delete-line",t.toggleBlockComment="codemirror:toggle-block-comment",t.toggleComment="codemirror:toggle-comment",t.selectNextOccurrence="codemirror:select-next-occurrence",t.toggleTabFocusMode="codemirror:toggle-tab-focus-mode",t.foldCurrent="codemirror:fold-current",t.unfoldCurrent="codemirror:unfold-current",t.foldSubregions="codemirror:fold-subregions",t.unfoldSubregions="codemirror:unfold-subregions",t.foldAll="codemirror:fold-all",t.unfoldAll="codemirror:unfold-all"})(g||(g={}));const q=".cm-content",He={id:"@jupyterlab/codemirror-extension:commands",description:"Registers commands acting on selected/active CodeMirror editor.",autoStart:!0,requires:[we],optional:[x,ke],activate:(t,e,r,a)=>{r=r??E;const l=r.load("jupyterlab"),u=o=>o.classList.contains(q),d=()=>{var o,n;const c=(o=t.contextMenuHitTest(u))!==null&&o!==void 0?o:(n=document.activeElement)===null||n===void 0?void 0:n.closest(q);if(c)return ve.findFromDOM(c)},s=()=>!!d(),m=()=>{var o,n;const c=t.shell.currentWidget,p=(o=e.currentWidget)===null||o===void 0?void 0:o.content;if(e.currentWidget!==null&&e.currentWidget===c&&p&&p.activeCell)return{type:"notebook",widget:c,notebook:p,isEnabled:!0};const h=c;return h&&h.content&&typeof((n=h.content.editor)===null||n===void 0?void 0:n.focus)=="function"?{type:"fileEditor",widget:h,isEnabled:!0}:{type:"none",widget:null,isEnabled:!1}},f=()=>m().isEnabled;if(t.commands.addCommand(g.deleteLine,{label:l.__("Delete the current line"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const o=d();o&&de(o)},isEnabled:s}),t.commands.addCommand(g.toggleBlockComment,{label:l.__("Toggle Block Comment"),caption:l.__("Toggles block comments in languages which support it (e.g. C, JavaScript)"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const o=d();o&&ce(o)},isEnabled:s}),t.commands.addCommand(g.toggleComment,{label:l.__("Toggle Comment"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const o=d();o&&me(o)},isEnabled:s}),t.commands.addCommand(g.toggleTabFocusMode,{label:l.__("Toggle Tab Focus Mode"),caption:l.__("Toggles behavior of Tab key between inserting indentation and moving to next focusable element"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const o=d();o&&ue(o)},isEnabled:s}),t.commands.addCommand(g.selectNextOccurrence,{label:l.__("Select Next Occurrence"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const o=d();o&&pe(o)},isEnabled:s}),t.commands.addCommand(g.foldCurrent,{label:l.__("Fold Current Region"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{var o;const n=m();n.type==="notebook"?(n.notebook.mode="edit",n.notebook.activeCell&&((o=n.notebook.activeCell.editor)===null||o===void 0||o.focus())):n.type==="fileEditor"&&n.widget.content.editor.focus();const c=d();if(!c)return;const{state:p}=c,h=p.selection.main.head,b=p.doc.lineAt(h);I(p,b.from,b.to)&&O(c)},isEnabled:f}),t.commands.addCommand(g.unfoldCurrent,{label:l.__("Unfold Current Region"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{var o;const n=m();n.type==="notebook"?(n.notebook.mode="edit",n.notebook.activeCell&&((o=n.notebook.activeCell.editor)===null||o===void 0||o.focus())):n.type==="fileEditor"&&n.widget.content.editor.focus();const c=d();if(!c)return;const{state:p}=c,h=p.selection.main.head,b=p.doc.lineAt(h);I(p,b.from,b.to)&&B(c)},isEnabled:f}),t.commands.addCommand(g.foldSubregions,{label:l.__("Fold All Subregions"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{var o;const n=m();n.type==="notebook"?(n.notebook.mode="edit",n.notebook.activeCell&&((o=n.notebook.activeCell.editor)===null||o===void 0||o.focus())):n.type==="fileEditor"&&n.widget.content.editor.focus();const c=d();if(c)try{const{state:p}=c,h=p.selection.main.head,b=p.doc.lineAt(h),v=I(p,b.from,b.to);let j=!1;try{j=p.field(R,!1)!==void 0}catch{j=!1}if(j||(O(c),B(c)),!v)return;const _=[];let C=v.from+1;for(;C<v.to;){const y=p.doc.lineAt(C),F=I(p,y.from,y.to);F&&F.from>v.from&&F.to<=v.to?(_.push(fe.of(F)),C=F.to):C=y.to+1}_.length>0&&c.dispatch({effects:_})}catch{}},isEnabled:f}),t.commands.addCommand(g.unfoldSubregions,{label:l.__("Unfold All Subregions"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{var o;const n=m();n.type==="notebook"?(n.notebook.mode="edit",n.notebook.activeCell&&((o=n.notebook.activeCell.editor)===null||o===void 0||o.focus())):n.type==="fileEditor"&&n.widget.content.editor.focus();const c=d();if(c)try{const{state:p}=c,h=p.selection.main.head,b=p.doc.lineAt(h),v=I(p,b.from,b.to);if(!v)return;const j=p.field(R,!1);if(!j)return;const _=[];j.between(v.from+1,v.to,(C,y)=>{C>v.from&&y<=v.to&&_.push(he.of({from:C,to:y}))}),_.length>0&&c.dispatch({effects:_})}catch{}},isEnabled:f}),t.commands.addCommand(g.foldAll,{label:l.__("Fold All Regions"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{var o;const n=m();n.type==="notebook"?(n.notebook.mode="edit",n.notebook.activeCell&&((o=n.notebook.activeCell.editor)===null||o===void 0||o.focus())):n.type==="fileEditor"&&n.widget.content.editor.focus();const c=d();if(c)try{ge(c)}catch{}},isEnabled:f}),t.commands.addCommand(g.unfoldAll,{label:l.__("Unfold All Regions"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{var o;const n=m();n.type==="notebook"?(n.notebook.mode="edit",n.notebook.activeCell&&((o=n.notebook.activeCell.editor)===null||o===void 0||o.focus())):n.type==="fileEditor"&&n.widget.content.editor.focus();const c=d();if(c)try{be(c)}catch{}},isEnabled:f}),a){const o=l.__("File Operations");[g.foldCurrent,g.unfoldCurrent,g.foldSubregions,g.unfoldSubregions,g.foldAll,g.unfoldAll].forEach(n=>{a.addItem({command:n,category:o})})}}},U="@jupyterlab/codemirror-extension:plugin",Ke={id:"@jupyterlab/codemirror-extension:languages",description:"Provides the CodeMirror languages registry.",provides:z,optional:[x],activate:(t,e)=>{const r=new G;for(const a of G.getDefaultLanguages(e))r.addLanguage(a);return r.addLanguage({name:"ipythongfm",mime:"text/x-ipythongfm",load:async()=>{const[a,l,u]=await Promise.all([N(()=>import("./index-KgE-JGae.js"),[],import.meta.url),N(()=>import("./index-DbMBnR4l.js"),[],import.meta.url),N(()=>import("./stex-C3f8Ysf7.js"),[],import.meta.url)]),d=a.markdown({base:a.markdownLanguage,codeLanguages:s=>r.findBest(s),extensions:[_e(Ee.define(u.stexMath).parser)]});return new Ce(d.language,[d.support,je(l.pythonLanguage)])}}),r}},Ye={id:"@jupyterlab/codemirror-extension:themes",description:"Provides the CodeMirror theme registry",provides:H,optional:[x],activate:(t,e)=>{const r=new $;for(const a of $.getDefaultThemes(e))r.addTheme(a);return r}},Qe={id:"@jupyterlab/codemirror-extension:extensions",description:"Provides the CodeMirror extension factory registry.",provides:M,requires:[H],optional:[x,De,Oe],activate:(t,e,r,a,l)=>{const u=new A;for(const d of A.getDefaultExtensions({themes:e,translator:r}))u.addExtension(d);if(a){const d=s=>{var m;u.baseConfiguration=(m=s.get("defaultConfig").composite)!==null&&m!==void 0?m:{}};Promise.all([a.load(U),t.restored]).then(([s])=>{d(s),s.changed.connect(d)}),l?.addRenderer(`${U}.defaultConfig`,{fieldRenderer:s=>{let m;const f=i.useMemo(()=>u.settingsSchema,[]);s.name in s.formContext.defaultFormData?m=s.formContext.defaultFormData[s.name]:m={};for(const[o,n]of Object.entries(u.defaultConfiguration))typeof f[o]<"u"&&!(o in m)&&(m[o]=n);return i.createElement("div",{className:"jp-FormGroup-contentNormal"},i.createElement("h3",{className:"jp-FormGroup-fieldLabel jp-FormGroup-contentItem"},s.schema.title),s.schema.description&&i.createElement("div",{className:"jp-FormGroup-description"},s.schema.description),i.createElement(Ue,{schema:{title:s.schema.title,description:s.schema.description,type:"object",properties:f,additionalProperties:!1},validator:Pe,formData:{...m,...s.formData},formContext:{defaultFormData:m},liveValidate:!0,onChange:o=>{var n;const c={};for(const[p,h]of Object.entries((n=o.formData)!==null&&n!==void 0?n:{})){const b=m[p];(b===void 0||!S.deepEqual(h,b))&&(c[p]=h)}s.onChange(c)},tagName:"div",translator:r??E}))}})}return u}},Xe={id:"@jupyterlab/codemirror-extension:binding",description:"Register the CodeMirror extension factory binding the editor and the shared model.",autoStart:!0,requires:[M],activate:(t,e)=>{e.addExtension({name:"shared-model-binding",factory:r=>{var a;const l=r.model.sharedModel;return A.createImmutableExtension(Fe({ytext:l.ysource,undoManager:(a=l.undoManager)!==null&&a!==void 0?a:void 0}))}})}},Ze={id:"@jupyterlab/codemirror-extension:services",description:"Provides the service to instantiate CodeMirror editors.",provides:ye,requires:[z,M],optional:[x],activate:(t,e,r,a)=>({factoryService:new Te({extensions:r,languages:e,translator:a??E}),mimeTypeService:new Ne(e)})},Q={id:"@jupyterlab/codemirror-extension:line-col-status",description:"Provides the code editor cursor position model.",autoStart:!0,requires:[x],optional:[Be,Ie],provides:Se,activate:(t,e,r,a)=>{const l=new w(e),u=new Set;a&&a.registerStatusItem(Q.id,{priority:1,item:l,align:"right",rank:2,isActive:()=>!!l.model.editor});const d=f=>{u.add(f),t.shell.currentWidget&&m(t.shell,{newValue:t.shell.currentWidget})},s=()=>{m(t.shell,{oldValue:t.shell.currentWidget,newValue:t.shell.currentWidget})};function m(f,o){Promise.all([...u].map(n=>n(o.newValue))).then(n=>{var c;l.model.editor=(c=n.filter(p=>p!==null)[0])!==null&&c!==void 0?c:null}).catch(n=>{console.error("Get editors",n)})}return r&&r.currentChanged.connect(m),{addEditorProvider:d,update:s}}},uo=[He,Ke,Ye,Xe,Qe,Ze,Q];export{uo as default,Q as lineColItem};
|
|
1
|
+
import{c0 as S,v as i,ak as E,d9 as Z,da as ee,db as J,dc as te,c7 as oe,c1 as ne,an as ie,dd as re,c3 as ae,de as le,b_ as se,ai as x,df as de,dg as ce,dh as me,di as ue,dj as pe,dk as I,dl as O,dm as B,dn as R,dp as fe,dq as he,dr as ge,ds as be,bw as ve,dt as ye,du as G,_ as N,dv as _e,dw as Ee,W as Ce,dx as je,dy as $,dz as A,dA as Fe,dB as Se}from"../datalayer-app-main.js";import{T as xe,b as ke}from"./index-BvvaLLhn.js";import{I as Ie}from"./tokens-BHMD_ju9.js";import{I as we}from"./tokens-CydTkiyv.js";import{C as Te,a as Ne}from"./index-BYQwy0Zx.js";import{I as z,a as H,b as M}from"./token-BRjncM66.js";import{F as Ae,c as Me,A as Le,g as W,v as Pe}from"./index-C17RrmNV.js";import{I as De}from"./tokens-BHLmeqjP.js";import{a as Oe}from"./tokens-_fLcuFXz.js";import{c as Be}from"./index-B_9UD0bt.js";import{s as Re}from"./hover-oeJgWZ71.js";import"./hoverbox-CStlKQWE.js";import"./_baseRest-BmxuuM4H.js";import"./isSymbol-BLtK9CV6.js";import"./forEach-hknrtmxV.js";import"./uniqueId-BVuTZY3F.js";import"./toNumber-B1wj8-wx.js";import"./_baseClone-ByJL1tkX.js";import"./merge-B_wcPK4Y.js";import"./isEqual-BybBNsZK.js";import"./Output-BscOPLqE.js";import"./index-BJ7Yskx5.js";import"./color-CG7_7V2-.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./PaintbrushIcon-CLU8RilX.js";import"./index-B3WvcNQa.js";import"./RestartIcon-Ca6_HoK0.js";import"./CellSidebarExtension-CQlXdanG.js";import"./NotebookSkeleton-HdM76lOj.js";import"./Avatar-DbU3YP4x.js";import"./renderer-lVFw9lw7.js";import"./SquareIcon-e3ygcjpv.js";import"./SortAscIcon-CVKVWIWQ.js";import"./url-DuKx0yk0.js";/* empty css */import"./index-Dro44tIm.js";/* empty css *//* empty css */import"./index-DsG9xhMj.js";/* empty css */import"./index-CNU-WVhQ.js";import"./index--OLIX362.js";import"./index-DYGslHkf.js";import"./index-BSRVX3UN.js";import"./index-BH2OX5l8.js";import"./index-C3vDfO5_.js";import"./index-Ko8lxXFd.js";import"./index-CB9u17_J.js";import"./index-BUVtc_FV.js";import"./ArrowLeftIcon-Y3PTljcl.js";import"./SkubbleIcon-tlg17jBG.js";import"./usePrimerThemeBridge-D_1NuGKb.js";import"./index-j-oeqTuo.js";import"./KernelVariables-KCUfxhF4.js";import"./index-BvgsWH_d.js";import"./SortDescIcon-CS4EzHeS.js";import"./NotebookToolbar-DMKCe3c2.js";import"./RepoPushIcon-Cm8g9NuL.js";import"./Toolbar-6Hdi_m3T.js";import"./sessions-3PQsLINe.js";import"./tokens-BfuLIPUq.js";import"./drivecontents-Bg9_6Kmo.js";import"./kernel-BI-BLP-K.js";const Ge={submitButtonOptions:{norender:!0}},V=t=>{var e;const r=((e=t.translator)!==null&&e!==void 0?e:E).load("jupyterlab");let a;const l=()=>t.direction==="up"?!t.item.hasMoveUp:!t.item.hasMoveDown,u=t.direction==="up"?t.item.index-1:t.item.index+1;if(t.buttonStyle==="icons"){const d={tag:"span",elementPosition:"center"};return a=t.direction==="up"?i.createElement(Z.react,{...d}):i.createElement(ee.react,{...d}),i.createElement(J,{className:"jp-ArrayOperationsButton",onClick:t.item.onReorderClick(t.item.index,u),disabled:l(),appearance:"stealth",title:r.__("Move item %1",t.direction)},a)}else return i.createElement("button",{className:"jp-mod-styled jp-mod-reject jp-ArrayOperationsButton",onClick:t.item.onReorderClick(t.item.index,u),disabled:l()},t.direction==="up"?r.__("Move up"):r.__("Move down"))},$e=t=>{var e;const r=((e=t.translator)!==null&&e!==void 0?e:E).load("jupyterlab");let a;return t.buttonStyle==="icons"?(a=i.createElement(te.react,{tag:"span",elementPosition:"center"}),i.createElement(J,{className:"jp-mod-styled jp-mod-warn jp-ArrayOperationsButton",onClick:t.item.onDropIndexClick(t.item.index),appearance:"stealth",title:r.__("Remove item")},a)):i.createElement("button",{className:"jp-mod-styled jp-mod-warn jp-ArrayOperationsButton",onClick:t.item.onDropIndexClick(t.item.index)},r.__("Remove"))},K=t=>{var e;const r=((e=t.translator)!==null&&e!==void 0?e:E).load("jupyterlab");let a;return t.buttonStyle==="icons"?a=i.createElement(oe.react,{tag:"span",elementSize:"xlarge",elementPosition:"center"}):a=r.__("Add"),i.createElement("button",{className:"jp-mod-styled jp-mod-accept jp-ArrayOperationsButton",onClick:t.onAddClick,title:r.__("Add item")},a)};function L(t){const{component:e,name:r,buttonStyle:a,compact:l,showModifiedFromDefault:u,translator:d}=t,s=l??!1,m=a??(s?"icons":"text"),f=o=>e({...o,buttonStyle:m,compact:s,showModifiedFromDefault:u??!0,translator:d??E});return r&&(f.displayName=r),f}function Y(t,e){const r=W("TitleFieldTemplate",t,e),a=W("DescriptionFieldTemplate",t,e);return{TitleField:r,DescriptionField:a}}const We=t=>L({...t,name:"JupyterLabArrayTemplate",component:e=>{var r;const{schema:a,registry:l,uiSchema:u,required:d}=e,s={schema:a,registry:l,uiSchema:u,required:d},{TitleField:m,DescriptionField:f}=Y(l,u);return i.createElement("div",{className:e.className},e.compact?i.createElement("div",{className:"jp-FormGroup-compactTitle"},i.createElement("div",{className:"jp-FormGroup-fieldLabel jp-FormGroup-contentItem",id:`${e.idSchema.$id}__title`},e.title||""),i.createElement("div",{className:"jp-FormGroup-description",id:`${e.idSchema.$id}-description`},e.schema.description||"")):i.createElement(i.Fragment,null,e.title&&i.createElement(m,{...s,title:e.title,id:`${e.idSchema.$id}-title`}),i.createElement(f,{...s,id:`${e.idSchema.$id}-description`,description:(r=e.schema.description)!==null&&r!==void 0?r:""})),e.items.map(o=>i.createElement("div",{key:o.key,className:o.className},o.children,i.createElement("div",{className:"jp-ArrayOperations"},i.createElement(V,{buttonStyle:e.buttonStyle,translator:e.translator,item:o,direction:"up"}),i.createElement(V,{buttonStyle:e.buttonStyle,translator:e.translator,item:o,direction:"down"}),i.createElement($e,{buttonStyle:e.buttonStyle,translator:e.translator,item:o})))),e.canAdd&&i.createElement(K,{onAddClick:e.onAddClick,buttonStyle:e.buttonStyle,translator:e.translator}))}}),Ve=t=>L({...t,name:"JupyterLabObjectTemplate",component:e=>{var r;const{schema:a,registry:l,uiSchema:u,required:d}=e,s={schema:a,registry:l,uiSchema:u,required:d},{TitleField:m,DescriptionField:f}=Y(l,u);return i.createElement("fieldset",{id:e.idSchema.$id},e.compact?i.createElement("div",{className:"jp-FormGroup-compactTitle"},i.createElement("div",{className:"jp-FormGroup-fieldLabel jp-FormGroup-contentItem",id:`${e.idSchema.$id}__title`},e.title||""),i.createElement("div",{className:"jp-FormGroup-description",id:`${e.idSchema.$id}__description`},e.schema.description||"")):i.createElement(i.Fragment,null,(e.title||(e.uiSchema||S.emptyObject)["ui:title"])&&i.createElement(m,{...s,id:`${e.idSchema.$id}__title`,title:e.title||`${(e.uiSchema||S.emptyObject)["ui:title"]}`||""}),i.createElement(f,{...s,id:`${e.idSchema.$id}__description`,description:(r=e.schema.description)!==null&&r!==void 0?r:""})),e.properties.map(o=>o.content),Me(e.schema,e.uiSchema,e.formData)&&i.createElement(K,{onAddClick:e.onAddClick(e.schema),buttonStyle:e.buttonStyle,translator:e.translator}))}}),qe=t=>L({...t,name:"JupyterLabFieldTemplate",component:e=>{var r;const a=((r=e.translator)!==null&&r!==void 0?r:E).load("jupyterlab");let l=!1,u;const{formData:d,schema:s,label:m,displayLabel:f,id:o,formContext:n,errors:c,rawErrors:p,children:h,onKeyChange:b,onDropPropertyClick:v}=e,{defaultFormData:j}=n,_=o.split("_");_.shift();const C=_.join("."),y=C==="",F=C===(e.uiSchema||S.emptyObject)["ui:field"];e.showModifiedFromDefault&&(u=_.reduce((k,X)=>k?.[X],j),l=!y&&d!==void 0&&u!==void 0&&!s.properties&&s.type!=="array"&&!S.deepEqual(d,u));const P=!y&&s.type!="object"&&o!="jp-SettingsEditor-@jupyterlab/shortcuts-extension:shortcuts_shortcuts",T=s.hasOwnProperty(Le),D=!(s.type==="object"||s.type==="array");return i.createElement("div",{className:`form-group ${f||s.type==="boolean"?"small-field":""}`},!F&&(p?.length?i.createElement("div",{className:"jp-modifiedIndicator jp-errorIndicator"}):l&&i.createElement("div",{className:"jp-modifiedIndicator"})),i.createElement("div",{className:`jp-FormGroup-content ${e.compact?"jp-FormGroup-contentCompact":"jp-FormGroup-contentNormal"}`},D&&f&&!y&&m&&!T?e.compact?i.createElement("div",{className:"jp-FormGroup-compactTitle"},i.createElement("div",{className:"jp-FormGroup-fieldLabel jp-FormGroup-contentItem"},m),D&&s.description&&P&&i.createElement("div",{className:"jp-FormGroup-description"},s.description)):i.createElement("h3",{className:"jp-FormGroup-fieldLabel jp-FormGroup-contentItem"},m):i.createElement(i.Fragment,null),T&&i.createElement("input",{className:"jp-FormGroup-contentItem jp-mod-styled",type:"text",onBlur:k=>b(k.target.value),defaultValue:m}),i.createElement("div",{className:`${y?"jp-root":s.type==="object"?"jp-objectFieldWrapper":s.type==="array"?"jp-arrayFieldWrapper":"jp-inputFieldWrapper jp-FormGroup-contentItem"}`},h),T&&i.createElement("button",{className:"jp-FormGroup-contentItem jp-mod-styled jp-mod-warn jp-FormGroup-removeButton",onClick:v(m)},a.__("Remove")),!e.compact&&s.description&&P&&i.createElement("div",{className:"jp-FormGroup-description"},s.description),l&&u!==void 0&&s.type!=="object"&&i.createElement("div",{className:"jp-FormGroup-default"},a.__("Default: %1",u!==null?u.toLocaleString():"null")),i.createElement("div",{className:"validationErrors"},c)))}});function Ue(t){const{buttonStyle:e,compact:r,showModifiedFromDefault:a,translator:l,formContext:u,...d}=t,s={...d.uiSchema||S.emptyObject};s["ui:options"]={...Ge,...s["ui:options"]},d.uiSchema=s;const{FieldTemplate:m,ArrayFieldTemplate:f,ObjectFieldTemplate:o}=t.templates||S.emptyObject,n={buttonStyle:e,compact:r,showModifiedFromDefault:a,translator:l},c=i.useMemo(()=>m??qe(n),[m,e,r,a,l]),p=i.useMemo(()=>f??We(n),[f,e,r,a,l]),h=i.useMemo(()=>o??Ve(n),[o,e,r,a,l]),b={FieldTemplate:c,ArrayFieldTemplate:p,ObjectFieldTemplate:h};return i.createElement(Ae,{templates:b,formContext:u,...d})}class Je extends i.Component{constructor(e){super(e),this._handleChange=r=>{this.setState({value:r.currentTarget.value})},this._handleSubmit=r=>{r.preventDefault();const a=parseInt(this._textInput.value,10);return!isNaN(a)&&isFinite(a)&&1<=a&&a<=this.props.maxLine&&this.props.handleSubmit(a),!1},this._handleFocus=()=>{this.setState({hasFocus:!0})},this._handleBlur=()=>{this.setState({hasFocus:!1})},this._textInput=null,this.translator=e.translator||E,this._trans=this.translator.load("jupyterlab"),this.state={value:"",hasFocus:!1,textInputId:re.createDomID()+"-line-number-input"}}componentDidMount(){this._textInput.focus()}render(){return i.createElement("div",{className:"jp-lineFormSearch"},i.createElement("form",{name:"lineColumnForm",onSubmit:this._handleSubmit,noValidate:!0},i.createElement("div",{className:ae("jp-lineFormWrapper","lm-lineForm-wrapper",this.state.hasFocus?"jp-lineFormWrapperFocusWithin":void 0)},i.createElement("input",{type:"text",id:this.state.textInputId,className:"jp-lineFormInput",onChange:this._handleChange,onFocus:this._handleFocus,onBlur:this._handleBlur,value:this.state.value,ref:e=>{this._textInput=e}}),i.createElement("div",{className:"jp-baseLineForm jp-lineFormButtonContainer"},i.createElement(le.react,{className:"jp-baseLineForm jp-lineFormButtonIcon",elementPosition:"center"}),i.createElement("input",{type:"submit",className:"jp-baseLineForm jp-lineFormButton",value:""}))),i.createElement("label",{className:"jp-lineFormCaption",htmlFor:this.state.textInputId},this._trans.__("Go to line number between 1 and %1",this.props.maxLine))))}}function ze(t){const r=(t.translator||E).load("jupyterlab"),a=l=>{if(l.key==="Enter"||l.key==="Spacebar"||l.key===" ")l.preventDefault(),l.stopPropagation(),t.handleClick();else return};return i.createElement(xe,{role:"button","aria-haspopup":!0,onClick:t.handleClick,source:r.__("Ln %1, Col %2",t.line,t.column),title:r.__("Go to line number…"),tabIndex:0,onKeyDown:a})}class w extends ne{constructor(e){super(new w.Model),this._popup=null,this.addClass("jp-mod-highlighted"),this.translator=e||E}render(){return this.model===null?null:i.createElement(ze,{line:this.model.line,column:this.model.column,translator:this.translator,handleClick:()=>this._handleClick()})}_handleClick(){this._popup&&this._popup.dispose();const e=ie.create(i.createElement(Je,{handleSubmit:r=>this._handleSubmit(r),currentLine:this.model.line,maxLine:this.model.editor.lineCount,translator:this.translator}));this._popup=Re({body:e,anchor:this,align:"right"})}_handleSubmit(e){this.model.editor.setCursorPosition({line:e-1,column:0}),this._popup.dispose(),this.model.editor.focus()}}(function(t){class e extends se{constructor(){super(...arguments),this._onSelectionChanged=()=>{const a=this._getAllState(),l=this.editor.getCursorPosition();this._line=l.line+1,this._column=l.column+1,this._triggerChange(a,this._getAllState())},this._line=1,this._column=1,this._editor=null}get editor(){return this._editor}set editor(a){var l;const u=this._editor;!((l=u?.model)===null||l===void 0)&&l.selections&&u.model.selections.changed.disconnect(this._onSelectionChanged);const d=this._getAllState();if(this._editor=a,!this._editor)this._column=1,this._line=1;else{this._editor.model.selections.changed.connect(this._onSelectionChanged);const s=this._editor.getCursorPosition();this._column=s.column+1,this._line=s.line+1}this._triggerChange(d,this._getAllState())}get line(){return this._line}get column(){return this._column}_getAllState(){return[this._line,this._column]}_triggerChange(a,l){(a[0]!==l[0]||a[1]!==l[1])&&this.stateChanged.emit(void 0)}}t.Model=e})(w||(w={}));var g;(function(t){t.deleteLine="codemirror:delete-line",t.toggleBlockComment="codemirror:toggle-block-comment",t.toggleComment="codemirror:toggle-comment",t.selectNextOccurrence="codemirror:select-next-occurrence",t.toggleTabFocusMode="codemirror:toggle-tab-focus-mode",t.foldCurrent="codemirror:fold-current",t.unfoldCurrent="codemirror:unfold-current",t.foldSubregions="codemirror:fold-subregions",t.unfoldSubregions="codemirror:unfold-subregions",t.foldAll="codemirror:fold-all",t.unfoldAll="codemirror:unfold-all"})(g||(g={}));const q=".cm-content",He={id:"@jupyterlab/codemirror-extension:commands",description:"Registers commands acting on selected/active CodeMirror editor.",autoStart:!0,requires:[we],optional:[x,ke],activate:(t,e,r,a)=>{r=r??E;const l=r.load("jupyterlab"),u=o=>o.classList.contains(q),d=()=>{var o,n;const c=(o=t.contextMenuHitTest(u))!==null&&o!==void 0?o:(n=document.activeElement)===null||n===void 0?void 0:n.closest(q);if(c)return ve.findFromDOM(c)},s=()=>!!d(),m=()=>{var o,n;const c=t.shell.currentWidget,p=(o=e.currentWidget)===null||o===void 0?void 0:o.content;if(e.currentWidget!==null&&e.currentWidget===c&&p&&p.activeCell)return{type:"notebook",widget:c,notebook:p,isEnabled:!0};const h=c;return h&&h.content&&typeof((n=h.content.editor)===null||n===void 0?void 0:n.focus)=="function"?{type:"fileEditor",widget:h,isEnabled:!0}:{type:"none",widget:null,isEnabled:!1}},f=()=>m().isEnabled;if(t.commands.addCommand(g.deleteLine,{label:l.__("Delete the current line"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const o=d();o&&de(o)},isEnabled:s}),t.commands.addCommand(g.toggleBlockComment,{label:l.__("Toggle Block Comment"),caption:l.__("Toggles block comments in languages which support it (e.g. C, JavaScript)"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const o=d();o&&ce(o)},isEnabled:s}),t.commands.addCommand(g.toggleComment,{label:l.__("Toggle Comment"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const o=d();o&&me(o)},isEnabled:s}),t.commands.addCommand(g.toggleTabFocusMode,{label:l.__("Toggle Tab Focus Mode"),caption:l.__("Toggles behavior of Tab key between inserting indentation and moving to next focusable element"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const o=d();o&&ue(o)},isEnabled:s}),t.commands.addCommand(g.selectNextOccurrence,{label:l.__("Select Next Occurrence"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{const o=d();o&&pe(o)},isEnabled:s}),t.commands.addCommand(g.foldCurrent,{label:l.__("Fold Current Region"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{var o;const n=m();n.type==="notebook"?(n.notebook.mode="edit",n.notebook.activeCell&&((o=n.notebook.activeCell.editor)===null||o===void 0||o.focus())):n.type==="fileEditor"&&n.widget.content.editor.focus();const c=d();if(!c)return;const{state:p}=c,h=p.selection.main.head,b=p.doc.lineAt(h);I(p,b.from,b.to)&&O(c)},isEnabled:f}),t.commands.addCommand(g.unfoldCurrent,{label:l.__("Unfold Current Region"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{var o;const n=m();n.type==="notebook"?(n.notebook.mode="edit",n.notebook.activeCell&&((o=n.notebook.activeCell.editor)===null||o===void 0||o.focus())):n.type==="fileEditor"&&n.widget.content.editor.focus();const c=d();if(!c)return;const{state:p}=c,h=p.selection.main.head,b=p.doc.lineAt(h);I(p,b.from,b.to)&&B(c)},isEnabled:f}),t.commands.addCommand(g.foldSubregions,{label:l.__("Fold All Subregions"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{var o;const n=m();n.type==="notebook"?(n.notebook.mode="edit",n.notebook.activeCell&&((o=n.notebook.activeCell.editor)===null||o===void 0||o.focus())):n.type==="fileEditor"&&n.widget.content.editor.focus();const c=d();if(c)try{const{state:p}=c,h=p.selection.main.head,b=p.doc.lineAt(h),v=I(p,b.from,b.to);let j=!1;try{j=p.field(R,!1)!==void 0}catch{j=!1}if(j||(O(c),B(c)),!v)return;const _=[];let C=v.from+1;for(;C<v.to;){const y=p.doc.lineAt(C),F=I(p,y.from,y.to);F&&F.from>v.from&&F.to<=v.to?(_.push(fe.of(F)),C=F.to):C=y.to+1}_.length>0&&c.dispatch({effects:_})}catch{}},isEnabled:f}),t.commands.addCommand(g.unfoldSubregions,{label:l.__("Unfold All Subregions"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{var o;const n=m();n.type==="notebook"?(n.notebook.mode="edit",n.notebook.activeCell&&((o=n.notebook.activeCell.editor)===null||o===void 0||o.focus())):n.type==="fileEditor"&&n.widget.content.editor.focus();const c=d();if(c)try{const{state:p}=c,h=p.selection.main.head,b=p.doc.lineAt(h),v=I(p,b.from,b.to);if(!v)return;const j=p.field(R,!1);if(!j)return;const _=[];j.between(v.from+1,v.to,(C,y)=>{C>v.from&&y<=v.to&&_.push(he.of({from:C,to:y}))}),_.length>0&&c.dispatch({effects:_})}catch{}},isEnabled:f}),t.commands.addCommand(g.foldAll,{label:l.__("Fold All Regions"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{var o;const n=m();n.type==="notebook"?(n.notebook.mode="edit",n.notebook.activeCell&&((o=n.notebook.activeCell.editor)===null||o===void 0||o.focus())):n.type==="fileEditor"&&n.widget.content.editor.focus();const c=d();if(c)try{ge(c)}catch{}},isEnabled:f}),t.commands.addCommand(g.unfoldAll,{label:l.__("Unfold All Regions"),describedBy:{args:{type:"object",properties:{}}},execute:()=>{var o;const n=m();n.type==="notebook"?(n.notebook.mode="edit",n.notebook.activeCell&&((o=n.notebook.activeCell.editor)===null||o===void 0||o.focus())):n.type==="fileEditor"&&n.widget.content.editor.focus();const c=d();if(c)try{be(c)}catch{}},isEnabled:f}),a){const o=l.__("File Operations");[g.foldCurrent,g.unfoldCurrent,g.foldSubregions,g.unfoldSubregions,g.foldAll,g.unfoldAll].forEach(n=>{a.addItem({command:n,category:o})})}}},U="@jupyterlab/codemirror-extension:plugin",Ke={id:"@jupyterlab/codemirror-extension:languages",description:"Provides the CodeMirror languages registry.",provides:z,optional:[x],activate:(t,e)=>{const r=new G;for(const a of G.getDefaultLanguages(e))r.addLanguage(a);return r.addLanguage({name:"ipythongfm",mime:"text/x-ipythongfm",load:async()=>{const[a,l,u]=await Promise.all([N(()=>import("./index-KgE-JGae.js"),[],import.meta.url),N(()=>import("./index-DbMBnR4l.js"),[],import.meta.url),N(()=>import("./stex-C3f8Ysf7.js"),[],import.meta.url)]),d=a.markdown({base:a.markdownLanguage,codeLanguages:s=>r.findBest(s),extensions:[_e(Ee.define(u.stexMath).parser)]});return new Ce(d.language,[d.support,je(l.pythonLanguage)])}}),r}},Ye={id:"@jupyterlab/codemirror-extension:themes",description:"Provides the CodeMirror theme registry",provides:H,optional:[x],activate:(t,e)=>{const r=new $;for(const a of $.getDefaultThemes(e))r.addTheme(a);return r}},Qe={id:"@jupyterlab/codemirror-extension:extensions",description:"Provides the CodeMirror extension factory registry.",provides:M,requires:[H],optional:[x,De,Oe],activate:(t,e,r,a,l)=>{const u=new A;for(const d of A.getDefaultExtensions({themes:e,translator:r}))u.addExtension(d);if(a){const d=s=>{var m;u.baseConfiguration=(m=s.get("defaultConfig").composite)!==null&&m!==void 0?m:{}};Promise.all([a.load(U),t.restored]).then(([s])=>{d(s),s.changed.connect(d)}),l?.addRenderer(`${U}.defaultConfig`,{fieldRenderer:s=>{let m;const f=i.useMemo(()=>u.settingsSchema,[]);s.name in s.formContext.defaultFormData?m=s.formContext.defaultFormData[s.name]:m={};for(const[o,n]of Object.entries(u.defaultConfiguration))typeof f[o]<"u"&&!(o in m)&&(m[o]=n);return i.createElement("div",{className:"jp-FormGroup-contentNormal"},i.createElement("h3",{className:"jp-FormGroup-fieldLabel jp-FormGroup-contentItem"},s.schema.title),s.schema.description&&i.createElement("div",{className:"jp-FormGroup-description"},s.schema.description),i.createElement(Ue,{schema:{title:s.schema.title,description:s.schema.description,type:"object",properties:f,additionalProperties:!1},validator:Pe,formData:{...m,...s.formData},formContext:{defaultFormData:m},liveValidate:!0,onChange:o=>{var n;const c={};for(const[p,h]of Object.entries((n=o.formData)!==null&&n!==void 0?n:{})){const b=m[p];(b===void 0||!S.deepEqual(h,b))&&(c[p]=h)}s.onChange(c)},tagName:"div",translator:r??E}))}})}return u}},Xe={id:"@jupyterlab/codemirror-extension:binding",description:"Register the CodeMirror extension factory binding the editor and the shared model.",autoStart:!0,requires:[M],activate:(t,e)=>{e.addExtension({name:"shared-model-binding",factory:r=>{var a;const l=r.model.sharedModel;return A.createImmutableExtension(Fe({ytext:l.ysource,undoManager:(a=l.undoManager)!==null&&a!==void 0?a:void 0}))}})}},Ze={id:"@jupyterlab/codemirror-extension:services",description:"Provides the service to instantiate CodeMirror editors.",provides:ye,requires:[z,M],optional:[x],activate:(t,e,r,a)=>({factoryService:new Te({extensions:r,languages:e,translator:a??E}),mimeTypeService:new Ne(e)})},Q={id:"@jupyterlab/codemirror-extension:line-col-status",description:"Provides the code editor cursor position model.",autoStart:!0,requires:[x],optional:[Be,Ie],provides:Se,activate:(t,e,r,a)=>{const l=new w(e),u=new Set;a&&a.registerStatusItem(Q.id,{priority:1,item:l,align:"right",rank:2,isActive:()=>!!l.model.editor});const d=f=>{u.add(f),t.shell.currentWidget&&m(t.shell,{newValue:t.shell.currentWidget})},s=()=>{m(t.shell,{oldValue:t.shell.currentWidget,newValue:t.shell.currentWidget})};function m(f,o){Promise.all([...u].map(n=>n(o.newValue))).then(n=>{var c;l.model.editor=(c=n.filter(p=>p!==null)[0])!==null&&c!==void 0?c:null}).catch(n=>{console.error("Get editors",n)})}return r&&r.currentChanged.connect(m),{addEditorProvider:d,update:s}}},uo=[He,Ke,Ye,Xe,Qe,Ze,Q];export{uo as default,Q as lineColItem};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{ai as v,ak as k,aa as h}from"../datalayer-app-main.js";import{I as g,a as y,b as L}from"./index-
|
|
1
|
+
import{ai as v,ak as k,aa as h}from"../datalayer-app-main.js";import{I as g,a as y,b as L}from"./index-B_9UD0bt.js";import{I as b}from"./tokens-CENaHAHm.js";import{a as R}from"./index-BvvaLLhn.js";import{R as _}from"./index-BJ7Yskx5.js";import"./Output-BscOPLqE.js";import"./index-BYQwy0Zx.js";import"./hoverbox-CStlKQWE.js";import"./index-DbMBnR4l.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./PaintbrushIcon-CLU8RilX.js";import"./index-B3WvcNQa.js";import"./RestartIcon-Ca6_HoK0.js";import"./CellSidebarExtension-CQlXdanG.js";import"./NotebookSkeleton-HdM76lOj.js";import"./Avatar-DbU3YP4x.js";import"./renderer-lVFw9lw7.js";import"./SquareIcon-e3ygcjpv.js";import"./SortAscIcon-CVKVWIWQ.js";import"./url-DuKx0yk0.js";/* empty css */import"./index-Dro44tIm.js";/* empty css *//* empty css */import"./index-DsG9xhMj.js";/* empty css */import"./index-CNU-WVhQ.js";import"./index--OLIX362.js";import"./index-DYGslHkf.js";import"./index-BSRVX3UN.js";import"./index-BH2OX5l8.js";import"./index-C3vDfO5_.js";import"./index-Ko8lxXFd.js";import"./index-CB9u17_J.js";import"./index-BUVtc_FV.js";import"./ArrowLeftIcon-Y3PTljcl.js";import"./SkubbleIcon-tlg17jBG.js";import"./usePrimerThemeBridge-D_1NuGKb.js";import"./index-j-oeqTuo.js";import"./KernelVariables-KCUfxhF4.js";import"./index-BvgsWH_d.js";import"./SortDescIcon-CS4EzHeS.js";import"./NotebookToolbar-DMKCe3c2.js";import"./RepoPushIcon-Cm8g9NuL.js";import"./Toolbar-6Hdi_m3T.js";import"./sessions-3PQsLINe.js";import"./tokens-BfuLIPUq.js";import"./drivecontents-Bg9_6Kmo.js";import"./kernel-BI-BLP-K.js";import"./color-CG7_7V2-.js";import"./isEqual-BybBNsZK.js";import"./defaultLocale-5voVPcsN.js";var a;(function(t){t.handleLink="rendermime:handle-local-link"})(a||(a={}));const _e={id:"@jupyterlab/rendermime-extension:plugin",description:"Provides the render mime registry.",optional:[b,y,R,L,v],provides:g,activate:I,autoStart:!0},f="debugger:open-source";function I(t,n,p,s,l,r){const d=(r??k).load("jupyterlab");return n&&t.commands.addCommand(a.handleLink,{label:d.__("Handle Local Link"),execute:e=>{const i=e.path,o=e.id,m=e.scope||"server";if(i){if(m==="kernel"){if(!t.commands.hasCommand(f)){console.warn("Cannot open kernel file: debugger sources provider not available");return}return t.commands.execute(f,{path:i})}return n.services.contents.get(i,{content:!1}).then(()=>{const u=n.registry.defaultRenderedWidgetFactory(i),c=n.openOrReveal(i,u.name);c&&o&&c.setFragment(o)})}},describedBy:{args:{type:"object",properties:{path:{type:"string",description:d.__("The file path to open")},id:{type:"string",description:d.__("Fragment identifier to navigate to")},scope:{type:"string",enum:["kernel","server"],description:d.__("Scope of the file location")}},required:["path"]}}}),new _({initialFactories:h,trustHandler:{markTrusted:e=>{t.commandLinker.markTrusted(e)},unmarkTrusted:e=>{t.commandLinker.unmarkTrusted(e)}},linkHandler:n?{handleLink:(e,i,o)=>{e.tagName==="A"&&e.hasAttribute("download")||e.addEventListener("click",m=>{m.preventDefault(),t.commands.execute(a.handleLink,{path:i,id:o})})},handlePath:(e,i,o,m)=>{e.addEventListener("click",u=>{u.preventDefault(),t.commands.execute(a.handleLink,{path:i,id:m,scope:o})})}}:void 0,latexTypesetter:p??void 0,markdownParser:l??void 0,translator:r??void 0,sanitizer:s??void 0})}export{_e as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as V}from"./LexicalToolRegistry-CXLITkMD.js";import{D as Vl,a as Yl,b as Gl,e as Zl,c as Kl,g as Ql,i as ec,f as tc,l as nc,h as sc,j as oc,k as rc,m as ic,n as ac,r as lc,o as cc,p as uc,q as dc,s as pc,t as fc,v as mc,w as gc,x as hc,y as bc,z as yc,u as xc}from"./LexicalToolRegistry-CXLITkMD.js";import{_ as qt,E as Mn,G as Dn,H as Bn,K as me,M as Wt,O as ot,P as rt,Q as jn,R as Un,S as Xt,U as Fn,V as Jt,W as zn,X as Hn,Y as Vt,Z as Yt,a0 as qn,a1 as Wn,a2 as Xn,a3 as Jn,C as Gt,a4 as Vn,a5 as Zt,a6 as Yn,a7 as Gn,a8 as Ce,a9 as Q,aa as Kt,ab as it,ac as xe,ad as at,ae as Re,af as Zn,ag as Be,ah as Ve,ai as lt,aj as Kn,ak as Ye,al as Qn,am as es,an as ts,ao as Ge,ap as Qt,aq as en,ar as tn,as as Ie,at as ns,au as ss,av as nn,aw as os,ax as Pe,$ as rs,b as is,a as as,c as ls,ay as sn,az as Y,aA as cs,aB as us,aC as Ze,aD as ds,aE as ps,aF as fs,aG as ms,aH as ct,aI as gs,aJ as hs,aK as bs,aL as ys,aM as xs,aN as Es,aO as Oe,aP as Ke,aQ as bt,aR as yt,aS as Ts,aT as Cs,aU as vs,aV as ws,aW as Ss,aX as Ls,aY as ks,aZ as _s,a_ as As,x as on,a$ as Ns,b0 as $s,b1 as Rs,b2 as Is,b3 as Ps,b4 as Os,b5 as Fe,b6 as Ms,b7 as Ds,b8 as Bs,b9 as js,ba as Us,bb as rn,bc as an,bd as ln,be as cn,j as Fs,T as zs,L as Hs,w as qs,k as Ws,l as Xs,D as Js,m as Vs,n as Ys,o as Gs,p as Zs,t as Ks,bf as Qs,s as eo,F as to,u as no,v as so,bg as oo,bh as ro}from"./JupyterLexicalExtension-CYnZrelh.js";import{bi as Tc,bj as Cc,bk as vc,bl as wc,bm as Sc,bn as Lc,bo as kc,bp as _c,bq as Ac,br as Nc,bs as $c,bt as Rc,bu as Ic,bv as Pc,d as Oc,e as Mc,bw as Dc,bx as Bc,B as jc,by as Uc,A as Fc,bz as zc,bA as Hc,bB as qc,bC as Wc,bD as Xc,bE as Jc,bF as Vc,bG as Yc,bH as Gc,bI as Zc,bJ as Kc,bK as Qc,bL as eu,bM as tu,bN as nu,bO as su,bP as ou,f as ru,bQ as iu,g as au,bR as lu,bS as cu,bT as uu,bU as du,bV as pu,q as fu,bW as mu,bX as gu,bY as hu,bZ as bu,b_ as yu,b$ as xu,c0 as Eu,c1 as Tu,c2 as Cu,c3 as vu,c4 as wu,c5 as Su,c6 as Lu,c7 as ku,c8 as _u,c9 as Au,ca as Nu,cb as $u,cc as Ru,cd as Iu,ce as Pu,cf as Ou,cg as Mu,ch as Du,ci as Bu,cj as ju,I as Uu,ck as Fu,cl as zu,cm as Hu,cn as qu,co as Wu,cp as Xu,cq as Ju,cr as Vu,cs as Yu,ct as Gu,cu as Zu,cv as Ku,h as Qu,z as ed,cw as td,cx as nd,cy as sd,cz as od,cA as rd,cB as id,cC as ad,cD as ld,cE as cd,cF as ud,cG as dd,J as pd,cH as fd,cI as md,cJ as gd,cK as hd,cL as bd,cM as yd,cN as xd,cO as Ed,cP as Td,cQ as Cd,cR as vd,cS as wd,cT as Sd,cU as Ld,cV as kd,cW as _d,cX as Ad,cY as Nd,cZ as $d,c_ as Rd,c$ as Id,d0 as Pd,d1 as Od,d2 as Md,d3 as Dd,d4 as Bd,d5 as jd,d6 as Ud,d7 as Fd,d8 as zd,d9 as Hd,da as qd,db as Wd,dc as Xd,dd as Jd,de as Vd,df as Yd,dg as Gd,dh as Zd,di as Kd,dj as Qd,dk as ep,dl as tp,dm as np,dn as sp,dp as op,dq as rp,dr as ip,ds as ap,dt as lp,du as cp,dv as up,dw as dp,dx as pp,dy as fp,dz as mp,dA as gp,dB as hp,dC as bp,dD as yp,dE as xp,dF as Ep,dG as Tp,dH as Cp,dI as vp,dJ as wp,dK as Sp,dL as Lp,dM as kp,dN as _p,dO as Ap,dP as Np,dQ as $p,dR as Rp,dS as Ip,dT as Pp,dU as Op,dV as Mp,dW as Dp,dX as Bp,dY as jp,dZ as Up,d_ as Fp,d$ as zp,e0 as Hp,e1 as qp,e2 as Wp,e3 as Xp,e4 as Jp,e5 as Vp,e6 as Yp,e7 as Gp,e8 as Zp,e9 as Kp,ea as Qp,eb as ef,ec as tf,ed as nf,ee as sf,ef as of,eg as rf,eh as af,ei as lf,ej as cf,ek as uf,el as df,em as pf,en as ff,eo as mf,ep as gf,eq as hf,er as bf,es as yf,et as xf,eu as Ef,ev as Tf,ew as Cf,ex as vf,ey as wf,ez as Sf,eA as Lf,eB as kf,eC as _f,eD as Af,eE as Nf,eF as $f,eG as Rf,eH as If,eI as Pf,eJ as Of,eK as Mf,eL as Df,eM as Bf,eN as jf,eO as Uf,eP as Ff,eQ as zf,eR as Hf,eS as qf,eT as Wf,eU as Xf,eV as Jf,eW as Vf,eX as Yf,r as Gf,eY as Zf,eZ as Kf,e_ as Qf,e$ as em,i as tm,f0 as nm,f1 as sm,f2 as om,f3 as rm,f4 as im,f5 as am,f6 as lm,f7 as cm,f8 as um,f9 as dm,fa as pm,fb as fm,fc as mm,fd as gm,fe as hm,ff as bm,fg as ym,fh as xm,fi as Em,fj as Tm,fk as Cm,fl as vm,fm as wm,fn as Sm,fo as Lm,fp as km,fq as _m,fr as Am,fs as Nm,ft as $m,fu as Rm,fv as Im}from"./JupyterLexicalExtension-CYnZrelh.js";import{kz as io,r as m,j as h,aA as ao,au as lo,B as co,aE as ee,kA as U,kB as ae,kC as un,kD as fe,kE as z,kF as uo,kG as po,kH as fo,kI as mo,kJ as j,aD as ce,kK as Ee,kL as ut,kM as go,kN as ho,kO as bo,kP as yo,kQ as dn,kR as xo,kS as Eo,kT as To,kU as Co,kV as vo,kW as wo,aC as So,K as M,bR as ve,kX as Lo,kY as se,kZ as X,k_ as ye,k$ as ko,l0 as _o,l1 as Ao,bS as No,l2 as le,bU as pn,l3 as fn,l4 as mn,bc as gn,l5 as pe,l6 as $o,l7 as Ro,bh as ie,cn as Io,I as Le,e3 as hn,C as Po,e as Oo,bW as Mo,k as Do,l8 as Bo,l9 as jo,bV as ze,la as Uo,lb as xt,d4 as Fo,ek as zo,T as Ho,lc as Et,ld as qo,le as Wo,lf as Xo,lg as Tt,lh as Jo,li as Vo,av as Yo,aw as Go,aq as Zo,aB as Ko}from"../datalayer-app-main.js";import{CollapsiblePlugin as Om}from"./index-CsZ2HycN.js";import{u as Qo,N as Ct}from"./usePrimerThemeBridge-D_1NuGKb.js";import{u as er}from"./Output-2KxoKu5F.js";import{T as tr}from"./ThemeContext-D9ztCaU3.js";import{a as Dm,u as Bm}from"./ThemeContext-D9ztCaU3.js";import{YouTubePlugin as Um}from"./YouTubePlugin-CjODyxZ2.js";import"./NotebookSkeleton-HdM76lOj.js";import"./Avatar-DbU3YP4x.js";import"./url-DuKx0yk0.js";import"./isSymbol-BLtK9CV6.js";import"./toNumber-B1wj8-wx.js";import"./VideoIcon-BjP_LDa4.js";import"./LinkIcon-DUI0jw25.js";import"./Toolbar-6Hdi_m3T.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./ArrowUpIcon-BUCpIXDR.js";import"./SortDescIcon-CS4EzHeS.js";import"./PaintbrushIcon-CLU8RilX.js";import"./PrismCss-CcU1ChRk.js";import"./index-BvvaLLhn.js";import"./hoverbox-CStlKQWE.js";import"./index-BYQwy0Zx.js";import"./index-BJ7Yskx5.js";import"./color-CG7_7V2-.js";import"./isEqual-BybBNsZK.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./index-B3WvcNQa.js";import"./RestartIcon-Ca6_HoK0.js";class nr{registry;_debug;constructor(t,n=!1){this.registry=t,this._debug=n}calculateIndent(t){const n=this.registry.getConfigOrDefault(t.language),s=this.getLeadingWhitespaceCount(t.currentLine);let o=s,r=!1,i=!1,l;for(const a of n.indentTriggers)if(this.matchesIndentRule(t.currentLine,a)){o=s+a.indentAmount,r=!0,l=a.name;break}if(!r){for(const a of n.dedentTriggers)if(this.matchesDedentRule(t.currentLine,a)){i=!0,l=a.name;break}}if(n.customRules){for(const a of n.customRules)if(a.condition(t.currentLine,t)){o=a.apply(o,t);break}}return o=Math.max(0,o),{spaces:o,shouldIndent:r,shouldDedent:i,triggeredRule:l}}getTabString(t){const n=this.registry.getConfigOrDefault(t);return n.useTabs?" ":" ".repeat(n.tabSize)}getTabSize(t){return this.registry.getConfigOrDefault(t).tabSize}calculateOutdent(t,n){const s=this.registry.getConfigOrDefault(n),o=t-s.tabSize;return Math.max(0,o)}getLeadingWhitespaceCount(t){const n=t.match(/^[\t ]*/);if(!n)return 0;const s=n[0];let o=0;for(const r of s)r===" "?o+=4:o+=1;return o}getLeadingWhitespace(t){const n=t.match(/^[\t ]*/);return n?n[0]:""}matchesIndentRule(t,n){switch(n.context){case"line-end":return n.pattern.test(t);case"line-start":return n.pattern.test(t);case"anywhere":return n.pattern.test(t);default:return!1}}matchesDedentRule(t,n){switch(n.context){case"line-start":return n.pattern.test(t);case"anywhere":return n.pattern.test(t);default:return!1}}normalizeIndentation(t,n){const s=this.registry.getConfigOrDefault(n);if(s.useTabs){const o=this.getLeadingWhitespace(t),r=o.length,i=Math.floor(r/s.tabSize),l=r%s.tabSize;return" ".repeat(i)+" ".repeat(l)+t.substring(o.length)}else{const o=this.getLeadingWhitespace(t);return o.replace(/\t/g," ".repeat(s.tabSize)).concat(t.substring(o.length))}}}const sr={language:"python",tabSize:4,useTabs:!1,indentTriggers:[{name:"colon-indent",pattern:/:\s*(#.*)?$/,context:"line-end",indentAmount:4},{name:"continuation-backslash",pattern:/\\\s*(#.*)?$/,context:"line-end",indentAmount:4},{name:"open-bracket",pattern:/[[({]\s*$/,context:"line-end",indentAmount:4}],dedentTriggers:[{name:"flow-control-keywords",pattern:/^\s*(return|break|continue|pass)(\s|$)/,context:"line-start",dedentAmount:4},{name:"raise-keyword",pattern:/^\s*raise(\s|$)/,context:"line-start",dedentAmount:4}],customRules:[{name:"close-bracket-dedent",condition:e=>/^\s*[\])}]/.test(e),apply:e=>Math.max(0,e-4)}]},bn={language:"javascript",tabSize:2,useTabs:!1,indentTriggers:[{name:"open-brace",pattern:/\{\s*(\/\/.*)?$/,context:"line-end",indentAmount:2},{name:"open-bracket",pattern:/\[\s*(\/\/.*)?$/,context:"line-end",indentAmount:2},{name:"open-paren",pattern:/\(\s*(\/\/.*)?$/,context:"line-end",indentAmount:2},{name:"arrow-function",pattern:/=>\s*(\/\/.*)?$/,context:"line-end",indentAmount:2},{name:"ternary-operator",pattern:/\?\s*(\/\/.*)?$/,context:"line-end",indentAmount:2}],dedentTriggers:[{name:"return-statement",pattern:/^\s*return(\s|;)/,context:"line-start",dedentAmount:2},{name:"break-continue",pattern:/^\s*(break|continue)(\s|;)/,context:"line-start",dedentAmount:2},{name:"throw-statement",pattern:/^\s*throw(\s|;)/,context:"line-start",dedentAmount:2}],customRules:[{name:"close-brace-dedent",condition:e=>/^\s*}/.test(e),apply:e=>Math.max(0,e-2)},{name:"close-bracket-dedent",condition:e=>/^\s*\]/.test(e),apply:e=>Math.max(0,e-2)},{name:"close-paren-dedent",condition:e=>/^\s*\)/.test(e),apply:e=>Math.max(0,e-2)},{name:"case-label",condition:e=>/^\s*(case\s+.*:|default:)/.test(e),apply:(e,t)=>e}]},or={...bn,language:"typescript"};class rr{configs;options;constructor(t={}){this.configs=new Map,this.options={defaultLanguage:"python",fallbackTabSize:4,debug:!1,...t},this.registerDefaultLanguages(),t.customConfigs&&t.customConfigs.forEach(n=>this.registerLanguage(n))}registerDefaultLanguages(){this.registerLanguage(sr),this.registerLanguage(bn),this.registerLanguage(or),this.registerAlias("py","python"),this.registerAlias("js","javascript"),this.registerAlias("ts","typescript"),this.registerAlias("jsx","javascript"),this.registerAlias("tsx","typescript")}registerLanguage(t){if(this.configs.has(t.language)){this.options.debug&&console.warn(`[LanguageIndentRegistry] Language '${t.language}' already registered. Use updateConfig() to modify.`);return}this.configs.set(t.language,t)}registerAlias(t,n){const s=this.configs.get(n);s&&this.configs.set(t,s)}getConfig(t){if(!t)return this.getConfig(this.options.defaultLanguage);const n=t.toLowerCase().trim();return this.configs.get(n)}getConfigOrDefault(t){const n=this.getConfig(t);if(n)return n;const s=this.getConfig(this.options.defaultLanguage);return s?(this.options.debug&&console.warn(`[LanguageIndentRegistry] Language '${t}' not found, using default: ${this.options.defaultLanguage}`),s):(this.options.debug&&console.error(`[LanguageIndentRegistry] No config found for '${t}' and default '${this.options.defaultLanguage}' missing!`),this.createFallbackConfig(t||"unknown"))}createFallbackConfig(t){return{language:t,tabSize:this.options.fallbackTabSize||4,useTabs:this.options.preserveTabs||!1,indentTriggers:[],dedentTriggers:[]}}hasLanguage(t){if(!t)return!1;const n=t.toLowerCase().trim();return this.configs.has(n)}updateConfig(t,n){const s=t.toLowerCase().trim(),o=this.configs.get(s);if(!o)return this.options.debug&&console.warn(`[LanguageIndentRegistry] Cannot update '${t}' - not registered`),!1;const r={...o,...n,language:o.language};return this.configs.set(s,r),!0}getRegisteredLanguages(){return Array.from(this.configs.keys())}clear(){this.configs.clear()}reset(){this.clear(),this.registerDefaultLanguages()}}const ir="[Deleted Comment]",Qe=e=>e.uid===e.thread_uid,yn=e=>e.anchor?.mark_id??e.uid,ar=(e,t)=>e.created_at!==t.created_at?e.created_at<t.created_at?-1:1:e.uid<t.uid?-1:e.uid>t.uid?1:0,He=(e,t)=>e!==void 0&&e.updated_at>t.updated_at?e:t,vt=e=>{const{uid:t,handle:n,name:s,agent_uid:o}=e.author;return t?{kind:"user",uid:t,handle:n??null,name:s??null,...o?{agentUid:o}:{}}:Bn(s||n)},lr=e=>({type:"comment",id:e.uid,author:Dn(vt(e)),authorPrincipal:vt(e),content:e.deleted?ir:e.body,deleted:e.deleted,...e.mentions&&e.mentions.length>0?{mentions:e.mentions}:{},timeStamp:Date.parse(e.created_at)});function cr(e){const t=[...e].sort(ar),n=new Map;for(const s of t)Qe(s)||n.set(s.thread_uid,[...n.get(s.thread_uid)??[],s]);return t.filter(s=>Qe(s)&&!s.deleted&&s.status==="open").map(s=>({type:"thread",id:yn(s),quote:s.quote??"",assignee:s.assignee??null,comments:[s,...n.get(s.uid)??[]].map(lr)}))}const wt=e=>e&&e.length>0?{mentions:e}:{};class dl{searchPeople;assignThread;_editor;_backend;_options;_listeners=new Set;_heardDuringReads=new Set;_records=new Map;_comments=[];constructor(t,n,s={}){this._editor=t,this._backend=n,this._options=s;const{searchPeople:o,assign:r}=n;o&&(this.searchPeople=i=>o.call(n,i).catch(l=>{throw this._options.onError?.(l),l})),r&&(this.assignThread=(i,l)=>this._write(()=>r.call(n,this._threadRecord(i).uid,l?.uid??null)))}connect(){const t=this._backend.subscribe({comment:n=>this._heard(n),ready:()=>{this.refresh()}});return this.refresh(),t}async refresh(){const t=new Map;this._heardDuringReads.add(t);try{const n=await this._backend.list(),s=new Map(n.map(o=>[o.uid,o]));for(const[o,r]of t)s.set(o,He(s.get(o),r));this._records=s,this._changed()}catch(n){this._options.onError?.(n)}finally{this._heardDuringReads.delete(t)}}getComments(){return this._comments}addComment(t,n){if(t.type==="thread"){const s=t.id,o=t.comments[0];this._write(()=>this._backend.create({body:o?.content??"",anchor:{mark_id:s},quote:t.quote,...wt(o?.mentions)}),()=>this._unmark(s))}else n!==void 0?this._write(()=>this._backend.create({body:t.content,thread_uid:this._threadRecord(n).uid,...wt(t.mentions)})):this._options.onError?.(new Error("A comment is written in a thread."))}deleteComment(t){this._write(()=>this._backend.delete(t.id))}deleteThread(t){this._write(()=>this._backend.delete(this._threadRecord(t).uid))}resolveThread(t){this._write(()=>this._backend.resolve(this._threadRecord(t).uid))}registerOnChange(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}_write(t,n){Promise.resolve().then(t).then(s=>this._heard(s),s=>{n?.(),this._options.onError?.(s)})}_threadRecord(t){for(const n of this._records.values())if(Qe(n)&&yn(n)===t.id)return n;throw new Error(`The thread ${t.id} is not one the store read.`)}_heard(t){for(const n of this._heardDuringReads)n.set(t.uid,He(n.get(t.uid),t));this._records.set(t.uid,He(this._records.get(t.uid),t)),this._changed()}_changed(){this._comments=cr(this._records.values());for(const t of this._listeners)t()}_unmark(t){this._editor.update(()=>{for(const{node:n}of io())qt(n)&&n.getIDs().includes(t)&&(n.deleteID(t),n.getIDs().length===0&&Mn(n))})}}const dt=m.createContext(void 0);function ur(){const e=m.useContext(dt);if(!e)throw new Error("useContext must be inside a Provider with a value");return e}const dr=dt.Provider,pl=dt.Consumer,fl=({children:e})=>{const[t,n]=m.useState();return h.jsx(dr,{value:{editor:t,setEditor:n},children:e})};function ml(e){const{useStore:t,children:n}=e,{colorMode:s,resolvedMode:o,themeConfig:r,themeBackground:i,lexicalTheme:l}=Qo(t);return h.jsx(ao,{colorMode:s,theme:r.primerTheme,themeStyles:r.themeStyles,children:h.jsx(lo,{colormode:o,backgroundColor:i,useBaseStyles:!1,children:h.jsx(co,{sx:{"& .editor-shell":{backgroundColor:i,borderRadius:2},"& .editor-container":{backgroundColor:i},"& .editor-inner":{backgroundColor:i},"& .editor-input":{backgroundColor:i},'& [role="toolbar"][aria-label="Editor toolbar"]':{backgroundColor:i}},children:h.jsx(tr.Provider,{value:{theme:l},children:n})})})})}const pr={"\\":"\\textbackslash{}","{":"\\{","}":"\\}",$:"\\$","&":"\\&","#":"\\#","^":"\\^{}",_:"\\_","%":"\\%","~":"\\~{}"};function K(e){return e.replace(/[\\{}$&#^_%~]/g,t=>pr[t]??t)}function pt(e,t,n="{",s="}"){let o=0;for(let r=t;r<e.length;r++){const i=e[r];if(i==="\\"){r++;continue}if(i===n)o++;else if(i===s&&(o--,o===0))return r}return-1}function W(e,t){let n=t;for(;n<e.length&&(e[n]===" "||e[n]===`
|
|
1
|
+
import{d as V}from"./LexicalToolRegistry-CXLITkMD.js";import{D as Vl,a as Yl,b as Gl,e as Zl,c as Kl,g as Ql,i as ec,f as tc,l as nc,h as sc,j as oc,k as rc,m as ic,n as ac,r as lc,o as cc,p as uc,q as dc,s as pc,t as fc,v as mc,w as gc,x as hc,y as bc,z as yc,u as xc}from"./LexicalToolRegistry-CXLITkMD.js";import{_ as qt,E as Mn,G as Dn,H as Bn,K as me,M as Wt,O as ot,P as rt,Q as jn,R as Un,S as Xt,U as Fn,V as Jt,W as zn,X as Hn,Y as Vt,Z as Yt,a0 as qn,a1 as Wn,a2 as Xn,a3 as Jn,C as Gt,a4 as Vn,a5 as Zt,a6 as Yn,a7 as Gn,a8 as Ce,a9 as Q,aa as Kt,ab as it,ac as xe,ad as at,ae as Re,af as Zn,ag as Be,ah as Ve,ai as lt,aj as Kn,ak as Ye,al as Qn,am as es,an as ts,ao as Ge,ap as Qt,aq as en,ar as tn,as as Ie,at as ns,au as ss,av as nn,aw as os,ax as Pe,$ as rs,b as is,a as as,c as ls,ay as sn,az as Y,aA as cs,aB as us,aC as Ze,aD as ds,aE as ps,aF as fs,aG as ms,aH as ct,aI as gs,aJ as hs,aK as bs,aL as ys,aM as xs,aN as Es,aO as Oe,aP as Ke,aQ as bt,aR as yt,aS as Ts,aT as Cs,aU as vs,aV as ws,aW as Ss,aX as Ls,aY as ks,aZ as _s,a_ as As,x as on,a$ as Ns,b0 as $s,b1 as Rs,b2 as Is,b3 as Ps,b4 as Os,b5 as Fe,b6 as Ms,b7 as Ds,b8 as Bs,b9 as js,ba as Us,bb as rn,bc as an,bd as ln,be as cn,j as Fs,T as zs,L as Hs,w as qs,k as Ws,l as Xs,D as Js,m as Vs,n as Ys,o as Gs,p as Zs,t as Ks,bf as Qs,s as eo,F as to,u as no,v as so,bg as oo,bh as ro}from"./JupyterLexicalExtension-BuRLImy5.js";import{bi as Tc,bj as Cc,bk as vc,bl as wc,bm as Sc,bn as Lc,bo as kc,bp as _c,bq as Ac,br as Nc,bs as $c,bt as Rc,bu as Ic,bv as Pc,d as Oc,e as Mc,bw as Dc,bx as Bc,B as jc,by as Uc,A as Fc,bz as zc,bA as Hc,bB as qc,bC as Wc,bD as Xc,bE as Jc,bF as Vc,bG as Yc,bH as Gc,bI as Zc,bJ as Kc,bK as Qc,bL as eu,bM as tu,bN as nu,bO as su,bP as ou,f as ru,bQ as iu,g as au,bR as lu,bS as cu,bT as uu,bU as du,bV as pu,q as fu,bW as mu,bX as gu,bY as hu,bZ as bu,b_ as yu,b$ as xu,c0 as Eu,c1 as Tu,c2 as Cu,c3 as vu,c4 as wu,c5 as Su,c6 as Lu,c7 as ku,c8 as _u,c9 as Au,ca as Nu,cb as $u,cc as Ru,cd as Iu,ce as Pu,cf as Ou,cg as Mu,ch as Du,ci as Bu,cj as ju,I as Uu,ck as Fu,cl as zu,cm as Hu,cn as qu,co as Wu,cp as Xu,cq as Ju,cr as Vu,cs as Yu,ct as Gu,cu as Zu,cv as Ku,h as Qu,z as ed,cw as td,cx as nd,cy as sd,cz as od,cA as rd,cB as id,cC as ad,cD as ld,cE as cd,cF as ud,cG as dd,J as pd,cH as fd,cI as md,cJ as gd,cK as hd,cL as bd,cM as yd,cN as xd,cO as Ed,cP as Td,cQ as Cd,cR as vd,cS as wd,cT as Sd,cU as Ld,cV as kd,cW as _d,cX as Ad,cY as Nd,cZ as $d,c_ as Rd,c$ as Id,d0 as Pd,d1 as Od,d2 as Md,d3 as Dd,d4 as Bd,d5 as jd,d6 as Ud,d7 as Fd,d8 as zd,d9 as Hd,da as qd,db as Wd,dc as Xd,dd as Jd,de as Vd,df as Yd,dg as Gd,dh as Zd,di as Kd,dj as Qd,dk as ep,dl as tp,dm as np,dn as sp,dp as op,dq as rp,dr as ip,ds as ap,dt as lp,du as cp,dv as up,dw as dp,dx as pp,dy as fp,dz as mp,dA as gp,dB as hp,dC as bp,dD as yp,dE as xp,dF as Ep,dG as Tp,dH as Cp,dI as vp,dJ as wp,dK as Sp,dL as Lp,dM as kp,dN as _p,dO as Ap,dP as Np,dQ as $p,dR as Rp,dS as Ip,dT as Pp,dU as Op,dV as Mp,dW as Dp,dX as Bp,dY as jp,dZ as Up,d_ as Fp,d$ as zp,e0 as Hp,e1 as qp,e2 as Wp,e3 as Xp,e4 as Jp,e5 as Vp,e6 as Yp,e7 as Gp,e8 as Zp,e9 as Kp,ea as Qp,eb as ef,ec as tf,ed as nf,ee as sf,ef as of,eg as rf,eh as af,ei as lf,ej as cf,ek as uf,el as df,em as pf,en as ff,eo as mf,ep as gf,eq as hf,er as bf,es as yf,et as xf,eu as Ef,ev as Tf,ew as Cf,ex as vf,ey as wf,ez as Sf,eA as Lf,eB as kf,eC as _f,eD as Af,eE as Nf,eF as $f,eG as Rf,eH as If,eI as Pf,eJ as Of,eK as Mf,eL as Df,eM as Bf,eN as jf,eO as Uf,eP as Ff,eQ as zf,eR as Hf,eS as qf,eT as Wf,eU as Xf,eV as Jf,eW as Vf,eX as Yf,r as Gf,eY as Zf,eZ as Kf,e_ as Qf,e$ as em,i as tm,f0 as nm,f1 as sm,f2 as om,f3 as rm,f4 as im,f5 as am,f6 as lm,f7 as cm,f8 as um,f9 as dm,fa as pm,fb as fm,fc as mm,fd as gm,fe as hm,ff as bm,fg as ym,fh as xm,fi as Em,fj as Tm,fk as Cm,fl as vm,fm as wm,fn as Sm,fo as Lm,fp as km,fq as _m,fr as Am,fs as Nm,ft as $m,fu as Rm,fv as Im}from"./JupyterLexicalExtension-BuRLImy5.js";import{kz as io,r as m,j as h,aA as ao,au as lo,B as co,aE as ee,kA as U,kB as ae,kC as un,kD as fe,kE as z,kF as uo,kG as po,kH as fo,kI as mo,kJ as j,aD as ce,kK as Ee,kL as ut,kM as go,kN as ho,kO as bo,kP as yo,kQ as dn,kR as xo,kS as Eo,kT as To,kU as Co,kV as vo,kW as wo,aC as So,K as M,bR as ve,kX as Lo,kY as se,kZ as X,k_ as ye,k$ as ko,l0 as _o,l1 as Ao,bS as No,l2 as le,bU as pn,l3 as fn,l4 as mn,bc as gn,l5 as pe,l6 as $o,l7 as Ro,bh as ie,cn as Io,I as Le,e3 as hn,C as Po,e as Oo,bW as Mo,k as Do,l8 as Bo,l9 as jo,bV as ze,la as Uo,lb as xt,d4 as Fo,ek as zo,T as Ho,lc as Et,ld as qo,le as Wo,lf as Xo,lg as Tt,lh as Jo,li as Vo,av as Yo,aw as Go,aq as Zo,aB as Ko}from"../datalayer-app-main.js";import{CollapsiblePlugin as Om}from"./index-CrNfUmIU.js";import{u as Qo,N as Ct}from"./usePrimerThemeBridge-D_1NuGKb.js";import{u as er}from"./Output-BscOPLqE.js";import{T as tr}from"./ThemeContext-D9ztCaU3.js";import{a as Dm,u as Bm}from"./ThemeContext-D9ztCaU3.js";import{YouTubePlugin as Um}from"./YouTubePlugin-xBjNr2Iu.js";import"./NotebookSkeleton-HdM76lOj.js";import"./Avatar-DbU3YP4x.js";import"./url-DuKx0yk0.js";import"./isSymbol-BLtK9CV6.js";import"./toNumber-B1wj8-wx.js";import"./VideoIcon-BjP_LDa4.js";import"./LinkIcon-DUI0jw25.js";import"./Toolbar-6Hdi_m3T.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./ArrowUpIcon-BUCpIXDR.js";import"./SortDescIcon-CS4EzHeS.js";import"./PaintbrushIcon-CLU8RilX.js";import"./PrismCss-CcU1ChRk.js";import"./index-BvvaLLhn.js";import"./hoverbox-CStlKQWE.js";import"./index-BYQwy0Zx.js";import"./index-BJ7Yskx5.js";import"./color-CG7_7V2-.js";import"./isEqual-BybBNsZK.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./index-B3WvcNQa.js";import"./RestartIcon-Ca6_HoK0.js";class nr{registry;_debug;constructor(t,n=!1){this.registry=t,this._debug=n}calculateIndent(t){const n=this.registry.getConfigOrDefault(t.language),s=this.getLeadingWhitespaceCount(t.currentLine);let o=s,r=!1,i=!1,l;for(const a of n.indentTriggers)if(this.matchesIndentRule(t.currentLine,a)){o=s+a.indentAmount,r=!0,l=a.name;break}if(!r){for(const a of n.dedentTriggers)if(this.matchesDedentRule(t.currentLine,a)){i=!0,l=a.name;break}}if(n.customRules){for(const a of n.customRules)if(a.condition(t.currentLine,t)){o=a.apply(o,t);break}}return o=Math.max(0,o),{spaces:o,shouldIndent:r,shouldDedent:i,triggeredRule:l}}getTabString(t){const n=this.registry.getConfigOrDefault(t);return n.useTabs?" ":" ".repeat(n.tabSize)}getTabSize(t){return this.registry.getConfigOrDefault(t).tabSize}calculateOutdent(t,n){const s=this.registry.getConfigOrDefault(n),o=t-s.tabSize;return Math.max(0,o)}getLeadingWhitespaceCount(t){const n=t.match(/^[\t ]*/);if(!n)return 0;const s=n[0];let o=0;for(const r of s)r===" "?o+=4:o+=1;return o}getLeadingWhitespace(t){const n=t.match(/^[\t ]*/);return n?n[0]:""}matchesIndentRule(t,n){switch(n.context){case"line-end":return n.pattern.test(t);case"line-start":return n.pattern.test(t);case"anywhere":return n.pattern.test(t);default:return!1}}matchesDedentRule(t,n){switch(n.context){case"line-start":return n.pattern.test(t);case"anywhere":return n.pattern.test(t);default:return!1}}normalizeIndentation(t,n){const s=this.registry.getConfigOrDefault(n);if(s.useTabs){const o=this.getLeadingWhitespace(t),r=o.length,i=Math.floor(r/s.tabSize),l=r%s.tabSize;return" ".repeat(i)+" ".repeat(l)+t.substring(o.length)}else{const o=this.getLeadingWhitespace(t);return o.replace(/\t/g," ".repeat(s.tabSize)).concat(t.substring(o.length))}}}const sr={language:"python",tabSize:4,useTabs:!1,indentTriggers:[{name:"colon-indent",pattern:/:\s*(#.*)?$/,context:"line-end",indentAmount:4},{name:"continuation-backslash",pattern:/\\\s*(#.*)?$/,context:"line-end",indentAmount:4},{name:"open-bracket",pattern:/[[({]\s*$/,context:"line-end",indentAmount:4}],dedentTriggers:[{name:"flow-control-keywords",pattern:/^\s*(return|break|continue|pass)(\s|$)/,context:"line-start",dedentAmount:4},{name:"raise-keyword",pattern:/^\s*raise(\s|$)/,context:"line-start",dedentAmount:4}],customRules:[{name:"close-bracket-dedent",condition:e=>/^\s*[\])}]/.test(e),apply:e=>Math.max(0,e-4)}]},bn={language:"javascript",tabSize:2,useTabs:!1,indentTriggers:[{name:"open-brace",pattern:/\{\s*(\/\/.*)?$/,context:"line-end",indentAmount:2},{name:"open-bracket",pattern:/\[\s*(\/\/.*)?$/,context:"line-end",indentAmount:2},{name:"open-paren",pattern:/\(\s*(\/\/.*)?$/,context:"line-end",indentAmount:2},{name:"arrow-function",pattern:/=>\s*(\/\/.*)?$/,context:"line-end",indentAmount:2},{name:"ternary-operator",pattern:/\?\s*(\/\/.*)?$/,context:"line-end",indentAmount:2}],dedentTriggers:[{name:"return-statement",pattern:/^\s*return(\s|;)/,context:"line-start",dedentAmount:2},{name:"break-continue",pattern:/^\s*(break|continue)(\s|;)/,context:"line-start",dedentAmount:2},{name:"throw-statement",pattern:/^\s*throw(\s|;)/,context:"line-start",dedentAmount:2}],customRules:[{name:"close-brace-dedent",condition:e=>/^\s*}/.test(e),apply:e=>Math.max(0,e-2)},{name:"close-bracket-dedent",condition:e=>/^\s*\]/.test(e),apply:e=>Math.max(0,e-2)},{name:"close-paren-dedent",condition:e=>/^\s*\)/.test(e),apply:e=>Math.max(0,e-2)},{name:"case-label",condition:e=>/^\s*(case\s+.*:|default:)/.test(e),apply:(e,t)=>e}]},or={...bn,language:"typescript"};class rr{configs;options;constructor(t={}){this.configs=new Map,this.options={defaultLanguage:"python",fallbackTabSize:4,debug:!1,...t},this.registerDefaultLanguages(),t.customConfigs&&t.customConfigs.forEach(n=>this.registerLanguage(n))}registerDefaultLanguages(){this.registerLanguage(sr),this.registerLanguage(bn),this.registerLanguage(or),this.registerAlias("py","python"),this.registerAlias("js","javascript"),this.registerAlias("ts","typescript"),this.registerAlias("jsx","javascript"),this.registerAlias("tsx","typescript")}registerLanguage(t){if(this.configs.has(t.language)){this.options.debug&&console.warn(`[LanguageIndentRegistry] Language '${t.language}' already registered. Use updateConfig() to modify.`);return}this.configs.set(t.language,t)}registerAlias(t,n){const s=this.configs.get(n);s&&this.configs.set(t,s)}getConfig(t){if(!t)return this.getConfig(this.options.defaultLanguage);const n=t.toLowerCase().trim();return this.configs.get(n)}getConfigOrDefault(t){const n=this.getConfig(t);if(n)return n;const s=this.getConfig(this.options.defaultLanguage);return s?(this.options.debug&&console.warn(`[LanguageIndentRegistry] Language '${t}' not found, using default: ${this.options.defaultLanguage}`),s):(this.options.debug&&console.error(`[LanguageIndentRegistry] No config found for '${t}' and default '${this.options.defaultLanguage}' missing!`),this.createFallbackConfig(t||"unknown"))}createFallbackConfig(t){return{language:t,tabSize:this.options.fallbackTabSize||4,useTabs:this.options.preserveTabs||!1,indentTriggers:[],dedentTriggers:[]}}hasLanguage(t){if(!t)return!1;const n=t.toLowerCase().trim();return this.configs.has(n)}updateConfig(t,n){const s=t.toLowerCase().trim(),o=this.configs.get(s);if(!o)return this.options.debug&&console.warn(`[LanguageIndentRegistry] Cannot update '${t}' - not registered`),!1;const r={...o,...n,language:o.language};return this.configs.set(s,r),!0}getRegisteredLanguages(){return Array.from(this.configs.keys())}clear(){this.configs.clear()}reset(){this.clear(),this.registerDefaultLanguages()}}const ir="[Deleted Comment]",Qe=e=>e.uid===e.thread_uid,yn=e=>e.anchor?.mark_id??e.uid,ar=(e,t)=>e.created_at!==t.created_at?e.created_at<t.created_at?-1:1:e.uid<t.uid?-1:e.uid>t.uid?1:0,He=(e,t)=>e!==void 0&&e.updated_at>t.updated_at?e:t,vt=e=>{const{uid:t,handle:n,name:s,agent_uid:o}=e.author;return t?{kind:"user",uid:t,handle:n??null,name:s??null,...o?{agentUid:o}:{}}:Bn(s||n)},lr=e=>({type:"comment",id:e.uid,author:Dn(vt(e)),authorPrincipal:vt(e),content:e.deleted?ir:e.body,deleted:e.deleted,...e.mentions&&e.mentions.length>0?{mentions:e.mentions}:{},timeStamp:Date.parse(e.created_at)});function cr(e){const t=[...e].sort(ar),n=new Map;for(const s of t)Qe(s)||n.set(s.thread_uid,[...n.get(s.thread_uid)??[],s]);return t.filter(s=>Qe(s)&&!s.deleted&&s.status==="open").map(s=>({type:"thread",id:yn(s),quote:s.quote??"",assignee:s.assignee??null,comments:[s,...n.get(s.uid)??[]].map(lr)}))}const wt=e=>e&&e.length>0?{mentions:e}:{};class dl{searchPeople;assignThread;_editor;_backend;_options;_listeners=new Set;_heardDuringReads=new Set;_records=new Map;_comments=[];constructor(t,n,s={}){this._editor=t,this._backend=n,this._options=s;const{searchPeople:o,assign:r}=n;o&&(this.searchPeople=i=>o.call(n,i).catch(l=>{throw this._options.onError?.(l),l})),r&&(this.assignThread=(i,l)=>this._write(()=>r.call(n,this._threadRecord(i).uid,l?.uid??null)))}connect(){const t=this._backend.subscribe({comment:n=>this._heard(n),ready:()=>{this.refresh()}});return this.refresh(),t}async refresh(){const t=new Map;this._heardDuringReads.add(t);try{const n=await this._backend.list(),s=new Map(n.map(o=>[o.uid,o]));for(const[o,r]of t)s.set(o,He(s.get(o),r));this._records=s,this._changed()}catch(n){this._options.onError?.(n)}finally{this._heardDuringReads.delete(t)}}getComments(){return this._comments}addComment(t,n){if(t.type==="thread"){const s=t.id,o=t.comments[0];this._write(()=>this._backend.create({body:o?.content??"",anchor:{mark_id:s},quote:t.quote,...wt(o?.mentions)}),()=>this._unmark(s))}else n!==void 0?this._write(()=>this._backend.create({body:t.content,thread_uid:this._threadRecord(n).uid,...wt(t.mentions)})):this._options.onError?.(new Error("A comment is written in a thread."))}deleteComment(t){this._write(()=>this._backend.delete(t.id))}deleteThread(t){this._write(()=>this._backend.delete(this._threadRecord(t).uid))}resolveThread(t){this._write(()=>this._backend.resolve(this._threadRecord(t).uid))}registerOnChange(t){return this._listeners.add(t),()=>{this._listeners.delete(t)}}_write(t,n){Promise.resolve().then(t).then(s=>this._heard(s),s=>{n?.(),this._options.onError?.(s)})}_threadRecord(t){for(const n of this._records.values())if(Qe(n)&&yn(n)===t.id)return n;throw new Error(`The thread ${t.id} is not one the store read.`)}_heard(t){for(const n of this._heardDuringReads)n.set(t.uid,He(n.get(t.uid),t));this._records.set(t.uid,He(this._records.get(t.uid),t)),this._changed()}_changed(){this._comments=cr(this._records.values());for(const t of this._listeners)t()}_unmark(t){this._editor.update(()=>{for(const{node:n}of io())qt(n)&&n.getIDs().includes(t)&&(n.deleteID(t),n.getIDs().length===0&&Mn(n))})}}const dt=m.createContext(void 0);function ur(){const e=m.useContext(dt);if(!e)throw new Error("useContext must be inside a Provider with a value");return e}const dr=dt.Provider,pl=dt.Consumer,fl=({children:e})=>{const[t,n]=m.useState();return h.jsx(dr,{value:{editor:t,setEditor:n},children:e})};function ml(e){const{useStore:t,children:n}=e,{colorMode:s,resolvedMode:o,themeConfig:r,themeBackground:i,lexicalTheme:l}=Qo(t);return h.jsx(ao,{colorMode:s,theme:r.primerTheme,themeStyles:r.themeStyles,children:h.jsx(lo,{colormode:o,backgroundColor:i,useBaseStyles:!1,children:h.jsx(co,{sx:{"& .editor-shell":{backgroundColor:i,borderRadius:2},"& .editor-container":{backgroundColor:i},"& .editor-inner":{backgroundColor:i},"& .editor-input":{backgroundColor:i},'& [role="toolbar"][aria-label="Editor toolbar"]':{backgroundColor:i}},children:h.jsx(tr.Provider,{value:{theme:l},children:n})})})})}const pr={"\\":"\\textbackslash{}","{":"\\{","}":"\\}",$:"\\$","&":"\\&","#":"\\#","^":"\\^{}",_:"\\_","%":"\\%","~":"\\~{}"};function K(e){return e.replace(/[\\{}$&#^_%~]/g,t=>pr[t]??t)}function pt(e,t,n="{",s="}"){let o=0;for(let r=t;r<e.length;r++){const i=e[r];if(i==="\\"){r++;continue}if(i===n)o++;else if(i===s&&(o--,o===0))return r}return-1}function W(e,t){let n=t;for(;n<e.length&&(e[n]===" "||e[n]===`
|
|
2
2
|
`);)n++;if(e[n]!=="{")return null;const s=pt(e,n);return s===-1?null:{value:e.slice(n+1,s),end:s+1}}function ne(e,t){let n=t;for(;n<e.length&&e[n]===" ";)n++;if(e[n]!=="[")return null;const s=pt(e,n,"[","]");return s===-1?null:{value:e.slice(n+1,s),end:s+1}}function xn(e){return e.split(`
|
|
3
3
|
`).map(t=>{for(let n=0;n<t.length;n++){if(t[n]==="\\"){n++;continue}if(t[n]==="%")return t.slice(0,n)}return t}).join(`
|
|
4
4
|
`)}function En(e,t){if(!e)return null;const n=new RegExp(`(?:^|,)\\s*${t}\\s*=\\s*([^,]+)`).exec(e);return n?n[1].trim():null}function oe(e,t,n){const s=[];let o=t;for(let r=0;r<n;r++){const i=W(e,o);if(!i)break;s.push(i.value),o=i.end}return{values:s,end:o}}function fr(e){const t=e.indexOf("\\begin{document}");if(t===-1)return{body:e,preamble:""};const n=t+16,s=e.lastIndexOf("\\end{document}");return{body:s===-1?e.slice(n):e.slice(n,s),preamble:e.slice(0,t)}}function Tn(e){return e.charAt(0).toUpperCase()+e.slice(1)}const mr=new Set(["book","report","memoir","scrbook","scrreprt","amsbook","thesis","mitthesis","phdthesis","bookest"]);function Cn(e,t){return mr.has((e??"").toLowerCase())||t!==void 0&&/(?<!\\)\\chapter\b/.test(t)}const gr={h1:"section",h2:"subsection",h3:"subsubsection",h4:"paragraph",h5:"subparagraph",h6:"subparagraph"},hr={h1:"chapter",h2:"section",h3:"subsection",h4:"subsubsection",h5:"paragraph",h6:"subparagraph"},br={part:"h1",chapter:"h1",section:"h1",subsection:"h2",subsubsection:"h3",paragraph:"h4",subparagraph:"h5"},yr={part:"h1",chapter:"h1",section:"h2",subsection:"h3",subsubsection:"h4",paragraph:"h5",subparagraph:"h6"};function xr(e){return e?{js:"JavaScript",javascript:"JavaScript",ts:"TypeScript",typescript:"TypeScript",py:"Python",python:"Python",sh:"bash",bash:"bash",r:"R",sql:"SQL",c:"C",cpp:"C++",java:"Java",html:"HTML",xml:"XML",json:"JSON",markdown:"Markdown",md:"Markdown"}[e.toLowerCase()]??e:null}function ft(e){return e.replace(/^\n/,"").replace(/\n[ \t]*$/,"")}function Er(e){if(uo(e))return St(e.text);if(po(e)||fo(e)){const t=e.data["text/plain"];return t===void 0?null:St(t)}return mo(e)?e.traceback.join(`
|