@datalayer/agent-runtimes 1.5.22 → 1.5.24
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/{AgentDetails-B6vekLFY.js → AgentDetails-Xvq2IvHg.js} +1 -1
- package/dist-embed/chunks/{AgentDetailsDialog-C-o8qFsS.js → AgentDetailsDialog-DmtKB_5z.js} +1 -1
- package/dist-embed/chunks/{CellSidebarExtension-BBXRIRgA.js → CellSidebarExtension-B-73cmcQ.js} +1 -1
- package/dist-embed/chunks/{ChatView-BjZ993Ch.js → ChatView-CUWE6I5M.js} +3 -3
- package/dist-embed/chunks/{ContextPie-Daf19Ivt.js → ContextPie-DdsXl5s7.js} +1 -1
- package/dist-embed/chunks/{DeckComponent-C76a8LYD.js → DeckComponent-ymp4My5d.js} +2 -2
- package/dist-embed/chunks/{DocumentView-BZhbQkbP.js → DocumentView-i99p_Qzt.js} +1 -1
- package/dist-embed/chunks/{EphemeralDocument-Bzv1mPpG.js → EphemeralDocument--pV47gPl.js} +1 -1
- package/dist-embed/chunks/{EphemeralNotebook-C4_wmSgk.js → EphemeralNotebook-BqccUXGd.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawComponent-DVOnRDkN.js → ExcalidrawComponent-DgSMy796.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawModal-B0h_-M3l.js → ExcalidrawModal-DFJW9pQh.js} +1 -1
- package/dist-embed/chunks/{JupyterLexicalExtension-B2PQrLXS.js → JupyterLexicalExtension-CqDatsgf.js} +8 -8
- package/dist-embed/chunks/{KernelVariables-trZsXNAi.js → KernelVariables-CS6h5HyK.js} +1 -1
- package/dist-embed/chunks/{NotebookToolSurfaces-BuKcXArX.js → NotebookToolSurfaces-CTLbTvsS.js} +1 -1
- package/dist-embed/chunks/{NotebookView-Em4y6Een.js → NotebookView-BJpTApeL.js} +1 -1
- package/dist-embed/chunks/{Output-DA8Udq91.js → Output-no9rnFJ7.js} +1 -1
- package/dist-embed/chunks/{SandboxDetailsDialog-o2z6YFyb.js → SandboxDetailsDialog-BAv6RMed.js} +1 -1
- package/dist-embed/chunks/{SchemaForm-DCt_mqR1.js → SchemaForm-CE5NfpBU.js} +1 -1
- package/dist-embed/chunks/{WidgetVariableView-CDEFi0p0.js → WidgetVariableView-V4DsgfIK.js} +1 -1
- package/dist-embed/chunks/{YouTubePlugin-DxRPFzvS.js → YouTubePlugin-CpgyVTwG.js} +1 -1
- package/dist-embed/chunks/{abnfDiagram-VCTEODGH-CsoEWluu.js → abnfDiagram-VCTEODGH-faK2fyHC.js} +1 -1
- package/dist-embed/chunks/{abnfDiagram-VCTEODGH-Cit223SC.js → abnfDiagram-VCTEODGH-wvUaPpVC.js} +1 -1
- package/dist-embed/chunks/{ar-SA-G6X2FPQ2-CjJtC55z.js → ar-SA-G6X2FPQ2-DwUjDWHp.js} +1 -1
- package/dist-embed/chunks/{architectureDiagram-5GKGNRK7-DyQuZM-c.js → architectureDiagram-5GKGNRK7-CwbfxDHw.js} +1 -1
- package/dist-embed/chunks/{architectureDiagram-5GKGNRK7-DfqpfKOB.js → architectureDiagram-5GKGNRK7-DBMLRsbO.js} +1 -1
- package/dist-embed/chunks/{az-AZ-76LH7QW2-B7KkL6wt.js → az-AZ-76LH7QW2-DROX4pJc.js} +1 -1
- package/dist-embed/chunks/{bg-BG-XCXSNQG7-D7UwtEhO.js → bg-BG-XCXSNQG7-DPLzP9Bm.js} +1 -1
- package/dist-embed/chunks/{blockDiagram-868be97b-jJKAH_Up.js → blockDiagram-868be97b-BXBoGds2.js} +1 -1
- package/dist-embed/chunks/{blockDiagram-I7D4REHJ-BcQwB7-r.js → blockDiagram-I7D4REHJ-BNkBA3Vb.js} +1 -1
- package/dist-embed/chunks/{blockDiagram-I7D4REHJ-z3xnLtdG.js → blockDiagram-I7D4REHJ-DUIcpkIN.js} +1 -1
- package/dist-embed/chunks/{bn-BD-2XOGV67Q-pDDWE9Mn.js → bn-BD-2XOGV67Q-CCOU2J2j.js} +1 -1
- package/dist-embed/chunks/{c4Diagram-3f4bdde3-DU_-LipO.js → c4Diagram-3f4bdde3-4OdTwU_t.js} +1 -1
- package/dist-embed/chunks/{c4Diagram-7LVT6UL2-BeMfCOG_.js → c4Diagram-7LVT6UL2-BGpBMrvl.js} +1 -1
- package/dist-embed/chunks/{c4Diagram-7LVT6UL2-DjfnLrWZ.js → c4Diagram-7LVT6UL2-f7UaZWVg.js} +1 -1
- package/dist-embed/chunks/{ca-ES-6MX7JW3Y-By1uEeFx.js → ca-ES-6MX7JW3Y-3RgFapBd.js} +1 -1
- package/dist-embed/chunks/{chunk-2Q5K7J3B-YWpfqKnX.js → chunk-2Q5K7J3B-BBPiCQqO.js} +1 -1
- package/dist-embed/chunks/{chunk-2Q5K7J3B-BGvvv_gg.js → chunk-2Q5K7J3B-P4f8Cifn.js} +1 -1
- package/dist-embed/chunks/{chunk-5VM5RSS4-t-8mwHFb.js → chunk-5VM5RSS4-BVaSZr_4.js} +1 -1
- package/dist-embed/chunks/{chunk-5VM5RSS4-4bCWL_eZ.js → chunk-5VM5RSS4-CcNPo9qP.js} +1 -1
- package/dist-embed/chunks/{chunk-F27PBJKO-De9ONU-g.js → chunk-F27PBJKO-C-90E7AT.js} +1 -1
- package/dist-embed/chunks/{chunk-F27PBJKO-3yGsHIDd.js → chunk-F27PBJKO-DTgjd0wN.js} +1 -1
- package/dist-embed/chunks/{chunk-IMKFNOWR-DA2KJGep.js → chunk-IMKFNOWR--OZX7QCt.js} +1 -1
- package/dist-embed/chunks/{chunk-IMKFNOWR-Bvbi7lre.js → chunk-IMKFNOWR-DuzpuE1w.js} +1 -1
- package/dist-embed/chunks/{chunk-JWPE2WC7-w_AaYpEU.js → chunk-JWPE2WC7-CAdvd3EQ.js} +1 -1
- package/dist-embed/chunks/{chunk-JWPE2WC7-CVkDZh_H.js → chunk-JWPE2WC7-OHowekj4.js} +1 -1
- package/dist-embed/chunks/{chunk-POPQ4Y6H-C1mg0obI.js → chunk-POPQ4Y6H-BgLsR3l7.js} +1 -1
- package/dist-embed/chunks/{chunk-POPQ4Y6H-DnstozKC.js → chunk-POPQ4Y6H-Dw1h_9lT.js} +1 -1
- package/dist-embed/chunks/{chunk-SVP7TREG-CVLd6GtA.js → chunk-SVP7TREG-VsO48dck.js} +1 -1
- package/dist-embed/chunks/{chunk-SVP7TREG-DmKkKduL.js → chunk-SVP7TREG-kM9Erqyf.js} +1 -1
- package/dist-embed/chunks/{chunk-TICWLB2K-xv7MPgmq.js → chunk-TICWLB2K-CU2oQRJ9.js} +1 -1
- package/dist-embed/chunks/{chunk-TICWLB2K-C-lEt3p0.js → chunk-TICWLB2K-pVdCft0o.js} +1 -1
- package/dist-embed/chunks/{chunk-XXDRQBXY-j7xuWjIK.js → chunk-XXDRQBXY-BSfKSQ7y.js} +1 -1
- package/dist-embed/chunks/{chunk-XXDRQBXY-Cq8wF2xQ.js → chunk-XXDRQBXY-CL1cUI4w.js} +1 -1
- package/dist-embed/chunks/{classDiagram-ZZMXUADV-DRPRMTvC.js → classDiagram-ZZMXUADV-Ctw7VU-m.js} +1 -1
- package/dist-embed/chunks/{classDiagram-ZZMXUADV-Dvh08RMu.js → classDiagram-ZZMXUADV-Dq0Eb9fh.js} +1 -1
- package/dist-embed/chunks/{classDiagram-f62afe4f-B8-b8b-t.js → classDiagram-f62afe4f-C8j4XsQw.js} +1 -1
- package/dist-embed/chunks/{classDiagram-v2-604399ef-CHogX84-.js → classDiagram-v2-604399ef-BVT78aGU.js} +1 -1
- package/dist-embed/chunks/{classDiagram-v2-VYDZK3BY-DRPRMTvC.js → classDiagram-v2-VYDZK3BY-Ctw7VU-m.js} +1 -1
- package/dist-embed/chunks/{classDiagram-v2-VYDZK3BY-Dvh08RMu.js → classDiagram-v2-VYDZK3BY-Dq0Eb9fh.js} +1 -1
- package/dist-embed/chunks/{cose-bilkent-JH36ORCC-BrisaBwh.js → cose-bilkent-JH36ORCC-DEGpy0W8.js} +1 -1
- package/dist-embed/chunks/{cose-bilkent-JH36ORCC-DGpwW9PH.js → cose-bilkent-JH36ORCC-DrOmRWVI.js} +1 -1
- package/dist-embed/chunks/{createText-aed3d8b3-C8C5hNtS.js → createText-aed3d8b3-BukHQ1P8.js} +1 -1
- package/dist-embed/chunks/{cs-CZ-2BRQDIVT-TB9QxoL2.js → cs-CZ-2BRQDIVT-BJS7ofhJ.js} +1 -1
- package/dist-embed/chunks/{cynefinDiagram-5FMLGOSQ-NXny6Mot.js → cynefinDiagram-5FMLGOSQ-CnZ3wqXe.js} +1 -1
- package/dist-embed/chunks/{cynefinDiagram-5FMLGOSQ-B37BRKcq.js → cynefinDiagram-5FMLGOSQ-qZ6StjuY.js} +1 -1
- package/dist-embed/chunks/{da-DK-5WZEPLOC-CLl8TZ2P.js → da-DK-5WZEPLOC-BHDT0zzh.js} +1 -1
- package/dist-embed/chunks/{dagre-GXQ25YYZ-mM6SsGs8.js → dagre-GXQ25YYZ-Bb0_WA3x.js} +1 -1
- package/dist-embed/chunks/{dagre-GXQ25YYZ-b03jeXc5.js → dagre-GXQ25YYZ-Dbp_O7kO.js} +1 -1
- package/dist-embed/chunks/{de-DE-XR44H4JA-6gY_Hl4H.js → de-DE-XR44H4JA-CWVJKc9t.js} +1 -1
- package/dist-embed/chunks/{diagram-S7CK7UJ4-fpaH_1xM.js → diagram-S7CK7UJ4-CwINt91M.js} +1 -1
- package/dist-embed/chunks/{diagram-S7CK7UJ4-C8TF_Y_V.js → diagram-S7CK7UJ4-DHPFd83P.js} +1 -1
- package/dist-embed/chunks/{diagram-UQ7AKVKN-CcqaQfbU.js → diagram-UQ7AKVKN-BqXFRP10.js} +1 -1
- package/dist-embed/chunks/{diagram-UQ7AKVKN-G8fspx37.js → diagram-UQ7AKVKN-CXRpfLBt.js} +1 -1
- package/dist-embed/chunks/{diagram-VSXAHHWV-DLhWEHn-.js → diagram-VSXAHHWV-Bg68Bv82.js} +1 -1
- package/dist-embed/chunks/{diagram-VSXAHHWV-B3Q41FOl.js → diagram-VSXAHHWV-DO0toZBQ.js} +1 -1
- package/dist-embed/chunks/{diagram-VX7I27RA-Dy-IHeZr.js → diagram-VX7I27RA-BEO0D7jE.js} +1 -1
- package/dist-embed/chunks/{diagram-VX7I27RA-Dnbm3teD.js → diagram-VX7I27RA-Diuc1eIf.js} +1 -1
- package/dist-embed/chunks/{diagram-Z3DM3KII-BkiB9_Ay.js → diagram-Z3DM3KII-BLJQK61P.js} +1 -1
- package/dist-embed/chunks/{diagram-Z3DM3KII-hE5FTtNp.js → diagram-Z3DM3KII-DtauJWd2.js} +1 -1
- package/dist-embed/chunks/{ebnfDiagram-PWID7BFC-DJhj6Mbd.js → ebnfDiagram-PWID7BFC-6H6OSebp.js} +1 -1
- package/dist-embed/chunks/{ebnfDiagram-PWID7BFC-DZiCEGSK.js → ebnfDiagram-PWID7BFC-SU3uN2_2.js} +1 -1
- package/dist-embed/chunks/{edges-b2856ca0-DuBY_rn3.js → edges-b2856ca0-DbD0XDJS.js} +1 -1
- package/dist-embed/chunks/{el-GR-BZB4AONW-CFGi_gqP.js → el-GR-BZB4AONW-2z8DB9lI.js} +1 -1
- package/dist-embed/chunks/{erDiagram-5d81789a-BYOejxuX.js → erDiagram-5d81789a-C-Tzt4MD.js} +1 -1
- package/dist-embed/chunks/{erDiagram-RLTQ6QDP-v1tF2vX5.js → erDiagram-RLTQ6QDP-C_c-qnRZ.js} +1 -1
- package/dist-embed/chunks/{erDiagram-RLTQ6QDP-Bg2UfSBM.js → erDiagram-RLTQ6QDP-DEAWMrMT.js} +1 -1
- package/dist-embed/chunks/{es-ES-U4NZUMDT-D_HQumEp.js → es-ES-U4NZUMDT-DzXGWPd4.js} +1 -1
- package/dist-embed/chunks/{eu-ES-A7QVB2H4-CvUID20p.js → eu-ES-A7QVB2H4-CslHE4iE.js} +1 -1
- package/dist-embed/chunks/{fa-IR-HGAKTJCU-C7_Vi5QP.js → fa-IR-HGAKTJCU-CBWUHs2r.js} +1 -1
- package/dist-embed/chunks/{fi-FI-Z5N7JZ37-SBYxKS7Q.js → fi-FI-Z5N7JZ37-MAr8kZMI.js} +1 -1
- package/dist-embed/chunks/{flowDb-185abca5-C_IywhMB.js → flowDb-185abca5-Di4aD0Mg.js} +1 -1
- package/dist-embed/chunks/{flowDiagram-1629c991-C8JQo90r.js → flowDiagram-1629c991-fImernS2.js} +1 -1
- package/dist-embed/chunks/{flowDiagram-HODETNUW-BigtRRvu.js → flowDiagram-HODETNUW-DzoskzA4.js} +1 -1
- package/dist-embed/chunks/{flowDiagram-HODETNUW-Cd1y1bVx.js → flowDiagram-HODETNUW-Hr-elwWq.js} +1 -1
- package/dist-embed/chunks/{flowDiagram-v2-1d953310-DTH8N-sj.js → flowDiagram-v2-1d953310-P1qDfDo-.js} +1 -1
- package/dist-embed/chunks/{flowchart-elk-definition-6df44142-W8s7oFgJ.js → flowchart-elk-definition-6df44142-CXebTCvX.js} +1 -1
- package/dist-embed/chunks/{fr-FR-RHASNOE6-fAErz4Nf.js → fr-FR-RHASNOE6-BUz3aHQJ.js} +1 -1
- package/dist-embed/chunks/{ganttDiagram-3b0b3873-D_XwfPDh.js → ganttDiagram-3b0b3873-Bupos8HO.js} +1 -1
- package/dist-embed/chunks/{ganttDiagram-EL5Y4UJY-BIsU1Bcw.js → ganttDiagram-EL5Y4UJY-3bErrKpg.js} +1 -1
- package/dist-embed/chunks/{ganttDiagram-EL5Y4UJY-VT_s02F9.js → ganttDiagram-EL5Y4UJY-e3WDalFj.js} +1 -1
- package/dist-embed/chunks/{gitGraphDiagram-WWUBYQGX-BvxzF9hn.js → gitGraphDiagram-WWUBYQGX-BiEolUQH.js} +1 -1
- package/dist-embed/chunks/{gitGraphDiagram-WWUBYQGX-BDdr_2gq.js → gitGraphDiagram-WWUBYQGX-Ck49f0H9.js} +1 -1
- package/dist-embed/chunks/{gitGraphDiagram-f01e8bc2-UBa5a0HV.js → gitGraphDiagram-f01e8bc2-DM8FMetI.js} +1 -1
- package/dist-embed/chunks/{gl-ES-HMX3MZ6V-DCciQOEM.js → gl-ES-HMX3MZ6V-DvzQmDYv.js} +1 -1
- package/dist-embed/chunks/{he-IL-6SHJWFNN-CuQhQVb2.js → he-IL-6SHJWFNN-DKR3cKyQ.js} +1 -1
- package/dist-embed/chunks/{hi-IN-IWLTKZ5I-BlH8AK2z.js → hi-IN-IWLTKZ5I-C4tyBNwa.js} +1 -1
- package/dist-embed/chunks/{hu-HU-A5ZG7DT2-BaBGhZVQ.js → hu-HU-A5ZG7DT2-C8BnBgH5.js} +1 -1
- package/dist-embed/chunks/{id-ID-SAP4L64H-Dkm1zS1g.js → id-ID-SAP4L64H-Bn1hY5OS.js} +1 -1
- package/dist-embed/chunks/{index-D5xVRNk8.js → index-5N0EOEHV.js} +1 -1
- package/dist-embed/chunks/{index-9bae90f3-CvHGNDGk.js → index-9bae90f3-l9tb84fw.js} +1 -1
- package/dist-embed/chunks/{index-DsMBsL3g.js → index-BKB97UwL.js} +1 -1
- package/dist-embed/chunks/{index-BQp4l7hT.js → index-BN8Bbau-.js} +2 -2
- package/dist-embed/chunks/{index-D2vkNPmG.js → index-BTdq_niO.js} +1 -1
- package/dist-embed/chunks/{index-BcdbHyzT.js → index-BTnG8qrO.js} +1 -1
- package/dist-embed/chunks/{index-CozDzMOf.js → index-Bhzj1Pnv.js} +1 -1
- package/dist-embed/chunks/{index-BDs-ntTo.js → index-BzMt3uYX.js} +1 -1
- package/dist-embed/chunks/{index-CUAnjzKL.js → index-CCRwowMu.js} +1 -1
- package/dist-embed/chunks/{index-Dp3JEvYy.js → index-CEbnhuIo.js} +1 -1
- package/dist-embed/chunks/{index-CrL-deXT.js → index-CRZ1qthh.js} +1 -1
- package/dist-embed/chunks/{index-CoxYszKx.js → index-CZB8DyUw.js} +1 -1
- package/dist-embed/chunks/{index-bC_5dTbf.js → index-Cd5CgKFr.js} +1 -1
- package/dist-embed/chunks/{index-DlYw1KQn.js → index-CkQ6IAoY.js} +1 -1
- package/dist-embed/chunks/{index-B9aqZrHy.js → index-Coj9opLJ.js} +1 -1
- package/dist-embed/chunks/{index-BqDJ3hYN.js → index-D9_026K2.js} +1 -1
- package/dist-embed/chunks/{index-SsFECYMb.js → index-DVaPKQyL.js} +1 -1
- package/dist-embed/chunks/{index-DdmqZZnv.js → index-DWfzdTZo.js} +1 -1
- package/dist-embed/chunks/{index-CecqH6mN.js → index-DdBQBN76.js} +1 -1
- package/dist-embed/chunks/{index-DPHM1WLM.js → index-Di3aBGLV.js} +1 -1
- package/dist-embed/chunks/{index-jJxXKHoT.js → index-DiBcWu6d.js} +1 -1
- package/dist-embed/chunks/{index-DE_JTiwB.js → index-Gngo0bXi.js} +1 -1
- package/dist-embed/chunks/index-S4sn4R3i.js +34 -0
- package/dist-embed/chunks/{index-DvyxBamA.js → index-TDpnbl90.js} +4 -4
- package/dist-embed/chunks/{index-DAZUOPnd.js → index-Z2pxzg3H.js} +1 -1
- package/dist-embed/chunks/{index-Dc5AqaeZ.js → index-_H5U6gal.js} +1 -1
- package/dist-embed/chunks/{index-YVrQYH-H.js → index-_nsBY26B.js} +1 -1
- package/dist-embed/chunks/{index-D8wHLHbt.js → index-b6e3y1R-.js} +1 -1
- package/dist-embed/chunks/{index-CtEseCtc.js → index-fQxrRXLD.js} +1 -1
- package/dist-embed/chunks/{index-DMll0Yzi.js → index-szXn1pzS.js} +1 -1
- package/dist-embed/chunks/{index.esm-p0OnSU9h.js → index.esm-nZym6gpK.js} +1 -1
- package/dist-embed/chunks/{index.esm-q_fIJH5v.js → index.esm-z-R1Ypx2.js} +1 -1
- package/dist-embed/chunks/{infoDiagram-27XIBGKW-DIeaDzEK.js → infoDiagram-27XIBGKW-8DlnjSdf.js} +1 -1
- package/dist-embed/chunks/{infoDiagram-27XIBGKW-DZ6Xhv3K.js → infoDiagram-27XIBGKW-BjyM865y.js} +1 -1
- package/dist-embed/chunks/{infoDiagram-a29d40f1-B9PMyz4X.js → infoDiagram-a29d40f1-DXYFLipl.js} +1 -1
- package/dist-embed/chunks/isEqual-g-jK7vY0.js +1 -0
- package/dist-embed/chunks/{ishikawaDiagram-5VMMS53U-CwrdITPn.js → ishikawaDiagram-5VMMS53U-Bb5g5HNe.js} +1 -1
- package/dist-embed/chunks/{ishikawaDiagram-5VMMS53U-BP4Q8nEu.js → ishikawaDiagram-5VMMS53U-ri4cvaWs.js} +1 -1
- package/dist-embed/chunks/{it-IT-JPQ66NNP-BrcctIsI.js → it-IT-JPQ66NNP-DEiaanA7.js} +1 -1
- package/dist-embed/chunks/{ja-JP-DBVTYXUO-CKuJ3Sod.js → ja-JP-DBVTYXUO-Bb0GBZrQ.js} +1 -1
- package/dist-embed/chunks/{journeyDiagram-3NMN7TZE-iJrCUeL0.js → journeyDiagram-3NMN7TZE-96VNFopN.js} +1 -1
- package/dist-embed/chunks/{journeyDiagram-3NMN7TZE-wI34jsXX.js → journeyDiagram-3NMN7TZE-BpYgEBLO.js} +1 -1
- package/dist-embed/chunks/{journeyDiagram-95396277-B6WhL2Fl.js → journeyDiagram-95396277-CQ_kN2gp.js} +1 -1
- package/dist-embed/chunks/{kaa-6HZHGXH3-ChFYZBwI.js → kaa-6HZHGXH3-DxqTv9uN.js} +1 -1
- package/dist-embed/chunks/{kab-KAB-ZGHBKWFO-C7C7EuVk.js → kab-KAB-ZGHBKWFO-D0V0yQgV.js} +1 -1
- package/dist-embed/chunks/{kanban-definition-UXKFOSKX-gqU76cK9.js → kanban-definition-UXKFOSKX-B5nUu45Q.js} +1 -1
- package/dist-embed/chunks/{kanban-definition-UXKFOSKX-B8AB0LN4.js → kanban-definition-UXKFOSKX-BPsXEKm4.js} +1 -1
- package/dist-embed/chunks/{kk-KZ-P5N5QNE5-Bff18CC1.js → kk-KZ-P5N5QNE5-CYyEyHXW.js} +1 -1
- package/dist-embed/chunks/{km-KH-HSX4SM5Z-DU2YQt8I.js → km-KH-HSX4SM5Z-CCTEGikY.js} +1 -1
- package/dist-embed/chunks/{ko-KR-MTYHY66A-CQruDlRn.js → ko-KR-MTYHY66A-C-QDut19.js} +1 -1
- package/dist-embed/chunks/{ku-TR-6OUDTVRD-DoySMeIi.js → ku-TR-6OUDTVRD-CIqn8p2Y.js} +1 -1
- package/dist-embed/chunks/{layout-DbdaqszO.js → layout-Bdtul_rg.js} +1 -1
- package/dist-embed/chunks/{layout-CJFemkl6.js → layout-Dq0J6INj.js} +1 -1
- package/dist-embed/chunks/{lt-LT-XHIRWOB4-72Vmr8iW.js → lt-LT-XHIRWOB4-BDLUWFPH.js} +1 -1
- package/dist-embed/chunks/{lv-LV-5QDEKY6T-CxtO97qO.js → lv-LV-5QDEKY6T-BItabIJP.js} +1 -1
- package/dist-embed/chunks/{mermaid.core-DaZxhAXO.js → mermaid.core-B9dEBs01.js} +4 -4
- package/dist-embed/chunks/{mermaid.core-CAzPWd8O.js → mermaid.core-pflA3DMC.js} +3 -3
- package/dist-embed/chunks/{mindmap-definition-YA3MSWOX-DPl-uWpT.js → mindmap-definition-YA3MSWOX-CEuIjXO2.js} +1 -1
- package/dist-embed/chunks/{mindmap-definition-YA3MSWOX-D8W0sJ7P.js → mindmap-definition-YA3MSWOX-DwLQYAqQ.js} +1 -1
- package/dist-embed/chunks/{mindmap-definition-e4c1d938-CGXwlH4A.js → mindmap-definition-e4c1d938-CDWIPlcb.js} +1 -1
- package/dist-embed/chunks/{mr-IN-CRQNXWMA-BNGEl_QE.js → mr-IN-CRQNXWMA-DXXb8N2w.js} +1 -1
- package/dist-embed/chunks/{my-MM-5M5IBNSE-4wIAMvGF.js → my-MM-5M5IBNSE-TidIfjqS.js} +1 -1
- package/dist-embed/chunks/{nb-NO-T6EIAALU-z-1s9yX9.js → nb-NO-T6EIAALU-DEINynK7.js} +1 -1
- package/dist-embed/chunks/{nl-NL-IS3SIHDZ-CYKGEVB8.js → nl-NL-IS3SIHDZ-D04rJzNe.js} +1 -1
- package/dist-embed/chunks/{nn-NO-6E72VCQL-DwQFIFpO.js → nn-NO-6E72VCQL-oWFzCtpf.js} +1 -1
- package/dist-embed/chunks/{oc-FR-POXYY2M6-mH2n3eM_.js → oc-FR-POXYY2M6-BmFfP6hk.js} +1 -1
- package/dist-embed/chunks/{pa-IN-N4M65BXN-DbixE6jQ.js → pa-IN-N4M65BXN-RkXrgKXw.js} +1 -1
- package/dist-embed/chunks/{pegDiagram-XKGWAZYB-D3qs3UBw.js → pegDiagram-XKGWAZYB-CqRRvKft.js} +1 -1
- package/dist-embed/chunks/{pegDiagram-XKGWAZYB-DJmZupPa.js → pegDiagram-XKGWAZYB-Cwo6HzRh.js} +1 -1
- package/dist-embed/chunks/{percentages-BXMCSKIN-5Q9KX_WU.js → percentages-BXMCSKIN-BL_DuU3S.js} +5 -5
- package/dist-embed/chunks/{pieDiagram-E7YTZNPT-CrZQ-dOy.js → pieDiagram-E7YTZNPT-BvBHesgq.js} +1 -1
- package/dist-embed/chunks/{pieDiagram-E7YTZNPT-C58cd6s7.js → pieDiagram-E7YTZNPT-CkHpKSua.js} +1 -1
- package/dist-embed/chunks/{pieDiagram-c941bede-Dn3GMx6q.js → pieDiagram-c941bede-Bsn1Bxk5.js} +1 -1
- package/dist-embed/chunks/{pl-PL-T2D74RX3-jOVonFYe.js → pl-PL-T2D74RX3-DqxkHzTj.js} +1 -1
- package/dist-embed/chunks/{pt-BR-5N22H2LF-Cx4MrqgK.js → pt-BR-5N22H2LF-DFA-wWC5.js} +1 -1
- package/dist-embed/chunks/{pt-PT-UZXXM6DQ-B2PzNwuF.js → pt-PT-UZXXM6DQ-Z5jw_7aw.js} +1 -1
- package/dist-embed/chunks/{quadrantDiagram-AXDQQJYC-haT-kxqE.js → quadrantDiagram-AXDQQJYC-AaQ_WgXa.js} +1 -1
- package/dist-embed/chunks/{quadrantDiagram-AXDQQJYC-CJn8hkR8.js → quadrantDiagram-AXDQQJYC-nOA8Q9nG.js} +1 -1
- package/dist-embed/chunks/{quadrantDiagram-cf8b8fe0-B3wudq14.js → quadrantDiagram-cf8b8fe0-BhaNj-gz.js} +1 -1
- package/dist-embed/chunks/{railroadDiagram-O6MQD6OU-T23yIHww.js → railroadDiagram-O6MQD6OU-BlWFu3pn.js} +1 -1
- package/dist-embed/chunks/{railroadDiagram-O6MQD6OU-Ty6XXjBy.js → railroadDiagram-O6MQD6OU-D-SNyKIn.js} +1 -1
- package/dist-embed/chunks/{renderer-Au1S-H5k.js → renderer-DKKfWkWv.js} +1 -1
- package/dist-embed/chunks/{requirementDiagram-53bda41b-B-eAYQ6c.js → requirementDiagram-53bda41b-C2WctYyl.js} +1 -1
- package/dist-embed/chunks/{requirementDiagram-BXWQKSXE-fpBmgh7Q.js → requirementDiagram-BXWQKSXE-1A97ivzl.js} +1 -1
- package/dist-embed/chunks/{requirementDiagram-BXWQKSXE-CgkHdmYF.js → requirementDiagram-BXWQKSXE-BpWNFdrw.js} +1 -1
- package/dist-embed/chunks/{ro-RO-JPDTUUEW-BCQxuLcc.js → ro-RO-JPDTUUEW-DjC09bHq.js} +1 -1
- package/dist-embed/chunks/{ru-RU-B4JR7IUQ-CqSiHvqj.js → ru-RU-B4JR7IUQ-CqwD7Yik.js} +1 -1
- package/dist-embed/chunks/{sankeyDiagram-P5KCCOFB-hDbZE81L.js → sankeyDiagram-P5KCCOFB-DnT5kYW5.js} +1 -1
- package/dist-embed/chunks/{sankeyDiagram-P5KCCOFB-DEGMK43Q.js → sankeyDiagram-P5KCCOFB-ktT6v9aY.js} +1 -1
- package/dist-embed/chunks/{sankeyDiagram-c3ef121a-O14jOeqO.js → sankeyDiagram-c3ef121a-3FD4GIJS.js} +1 -1
- package/dist-embed/chunks/{sequenceDiagram-82a5b84f-BFFzLElQ.js → sequenceDiagram-82a5b84f-CZQmoHAd.js} +1 -1
- package/dist-embed/chunks/{sequenceDiagram-WJ2MYXX4-MrC4K4SC.js → sequenceDiagram-WJ2MYXX4-0HHgJN0L.js} +1 -1
- package/dist-embed/chunks/{sequenceDiagram-WJ2MYXX4-wongMGVN.js → sequenceDiagram-WJ2MYXX4-DYY-dZgX.js} +1 -1
- package/dist-embed/chunks/{si-LK-N5RQ5JYF-Dbgk5YHt.js → si-LK-N5RQ5JYF-OVf4k6G3.js} +1 -1
- package/dist-embed/chunks/{sizeCapture-INFHLROL-CiOiAAo5.js → sizeCapture-INFHLROL-CIF2j9e_.js} +1 -1
- package/dist-embed/chunks/{sizeCapture-INFHLROL-j4-sCda0.js → sizeCapture-INFHLROL-DJOph387.js} +1 -1
- package/dist-embed/chunks/{sk-SK-C5VTKIMK-OBAaNvVw.js → sk-SK-C5VTKIMK-BG__kjLT.js} +1 -1
- package/dist-embed/chunks/{sl-SI-NN7IZMDC-DqLxi4IM.js → sl-SI-NN7IZMDC-CIgxidVH.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-43e79a5f-BZm5gFdu.js → stateDiagram-43e79a5f-CMlUXY1x.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-D77RDMKH-D7_xyy8n.js → stateDiagram-D77RDMKH-CkICPC-C.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-D77RDMKH-DXrbH1aM.js → stateDiagram-D77RDMKH-DVd0MOrg.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-v2-2041ed4f-DiXOgJsK.js → stateDiagram-v2-2041ed4f-BcO6vvJA.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-v2-MP3YSRHH-ngWpJn6k.js → stateDiagram-v2-MP3YSRHH-BFlXwfgz.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-v2-MP3YSRHH-DLsY6ysL.js → stateDiagram-v2-MP3YSRHH-CJD5_Eji.js} +1 -1
- package/dist-embed/chunks/{styles-455b33cd-CrHizSU7.js → styles-455b33cd-BfyZJvzN.js} +1 -1
- package/dist-embed/chunks/{styles-f932cba9-YuCN7fSa.js → styles-f932cba9-k2wfF-9Q.js} +1 -1
- package/dist-embed/chunks/{styles-fcc2142b-tjrOPOh4.js → styles-fcc2142b-z3csTkbW.js} +1 -1
- package/dist-embed/chunks/{subset-shared.chunk-Du2agLgk.js → subset-shared.chunk-BR0LJHtQ.js} +1 -1
- package/dist-embed/chunks/{subset-worker.chunk-BXR8pgHc.js → subset-worker.chunk-52aAcjvz.js} +1 -1
- package/dist-embed/chunks/{sv-SE-XGPEYMSR-BbgHKxhC.js → sv-SE-XGPEYMSR-CYHz3xCa.js} +1 -1
- package/dist-embed/chunks/{svgDrawCommon-148a3cd9-DTqtvo5_.js → svgDrawCommon-148a3cd9-NqUFgQ9x.js} +1 -1
- package/dist-embed/chunks/{swimlanes-42K2YHIH-B289Mbni.js → swimlanes-42K2YHIH-B6pxWv6a.js} +1 -1
- package/dist-embed/chunks/{swimlanes-42K2YHIH-B3H_wpMu.js → swimlanes-42K2YHIH-Cj4fdAYa.js} +1 -1
- package/dist-embed/chunks/{swimlanesDiagram-VR7AAH4N-D0ZHzw-_.js → swimlanesDiagram-VR7AAH4N-B2gk37ys.js} +1 -1
- package/dist-embed/chunks/{swimlanesDiagram-VR7AAH4N-qWg-2xN_.js → swimlanesDiagram-VR7AAH4N-B9ThT6OH.js} +1 -1
- package/dist-embed/chunks/{ta-IN-2NMHFXQM-0pH7gQyu.js → ta-IN-2NMHFXQM-BphRr9QY.js} +1 -1
- package/dist-embed/chunks/{th-TH-HPSO5L25-Dvbu09CU.js → th-TH-HPSO5L25-Ba2-2Bo0.js} +1 -1
- package/dist-embed/chunks/{timeline-definition-24CTP7MA-DpMq7g2g.js → timeline-definition-24CTP7MA-D5dMAy5U.js} +1 -1
- package/dist-embed/chunks/{timeline-definition-24CTP7MA-DUc18SdK.js → timeline-definition-24CTP7MA-DVcslyxd.js} +1 -1
- package/dist-embed/chunks/{timeline-definition-7545f45a--4ypi4BE.js → timeline-definition-7545f45a-IhzNtIcW.js} +1 -1
- package/dist-embed/chunks/{tr-TR-DEFEU3FU-B6YS3iEB.js → tr-TR-DEFEU3FU-CRKE7Roy.js} +1 -1
- package/dist-embed/chunks/{uk-UA-QMV73CPH-DMG9vIVp.js → uk-UA-QMV73CPH-DlNE5CAT.js} +1 -1
- package/dist-embed/chunks/{vennDiagram-4TSXK5OY-CvEXE1xX.js → vennDiagram-4TSXK5OY-BMg6wc5A.js} +1 -1
- package/dist-embed/chunks/{vennDiagram-4TSXK5OY-CS12EGJw.js → vennDiagram-4TSXK5OY-KKysbuVs.js} +1 -1
- package/dist-embed/chunks/{vi-VN-M7AON7JQ-DB3ZrpeP.js → vi-VN-M7AON7JQ-Cp44PRXY.js} +1 -1
- package/dist-embed/chunks/{wardleyDiagram-VM6X3IG4-8LfGni9_.js → wardleyDiagram-VM6X3IG4-C5wMQ_qe.js} +1 -1
- package/dist-embed/chunks/{wardleyDiagram-VM6X3IG4-Bj02LzjH.js → wardleyDiagram-VM6X3IG4-CTed9ps7.js} +1 -1
- package/dist-embed/chunks/{xychartDiagram-3f383b91-CE_OY5QR.js → xychartDiagram-3f383b91-CsxcWMT8.js} +1 -1
- package/dist-embed/chunks/{xychartDiagram-S5SC5T6Z-DXqC0l3r.js → xychartDiagram-S5SC5T6Z-DthHDnAV.js} +1 -1
- package/dist-embed/chunks/{xychartDiagram-S5SC5T6Z-BdZi5x4a.js → xychartDiagram-S5SC5T6Z-Kpqryflz.js} +1 -1
- package/dist-embed/chunks/{zh-CN-LNUGB5OW-VV-lg83H.js → zh-CN-LNUGB5OW-JHqqwp0j.js} +1 -1
- package/dist-embed/chunks/{zh-HK-E62DVLB3-DLoyC6Q9.js → zh-HK-E62DVLB3-YEs97mA8.js} +1 -1
- package/dist-embed/chunks/{zh-TW-RAJ6MFWO-DhFllgOW.js → zh-TW-RAJ6MFWO-CgmeTbuy.js} +1 -1
- package/dist-embed/datalayer-app-main.js +16 -16
- package/lib/chat/presence/Presence.d.ts +4 -4
- package/lib/chat/presence/Presence.js +3 -2
- package/lib/chat/presence/presenceStatus.d.ts +3 -34
- package/lib/chat/presence/presenceStatus.js +4 -46
- package/lib/portable/fixtures.d.ts +11 -0
- package/lib/portable/fixtures.js +70 -0
- package/lib/portable/index.d.ts +3 -0
- package/lib/portable/index.js +5 -0
- package/lib/portable/presence.d.ts +47 -0
- package/lib/portable/presence.js +71 -0
- package/lib/portable/views.d.ts +125 -0
- package/lib/portable/views.js +52 -0
- package/package.json +1 -1
- package/dist-embed/chunks/index-a9o1fYab.js +0 -34
- package/dist-embed/chunks/isEqual-Cwjr2skl.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{v as te,r as z,j as e,B as n,H as F,cu as ae,T as i,c as L,e7 as Re,ek as le,el as He,em as Ve,en as me,eo as De,ep as qe,eq as Be,er as Ge,es as Ke,et as Je,eu as H,n as ce,bf as Ye,ct as Xe,L as A,aH as Qe,ev as Ze,ew as et,ex as tt,ey as Pe,cs as nt,ez as st,d5 as ot,cq as it,I as Oe,e4 as rt,eA as lt,eB as at,eC as ct,eD as dt,eE as ut,eF as pt,eG as ft,eH as ht,eI as gt,eJ as xt,eK as ne,eL as se,cr as mt,eM as bt}from"../datalayer-app-main.js";import{A as yt}from"./ArrowLeftIcon-Y3PTljcl.js";import{A as jt,T as St,M as Me,U as We,F as wt}from"./UnlinkIcon-DuVqPyB-.js";import Ie from"./index-
|
|
1
|
+
import{v as te,r as z,j as e,B as n,H as F,cu as ae,T as i,c as L,e7 as Re,ek as le,el as He,em as Ve,en as me,eo as De,ep as qe,eq as Be,er as Ge,es as Ke,et as Je,eu as H,n as ce,bf as Ye,ct as Xe,L as A,aH as Qe,ev as Ze,ew as et,ex as tt,ey as Pe,cs as nt,ez as st,d5 as ot,cq as it,I as Oe,e4 as rt,eA as lt,eB as at,eC as ct,eD as dt,eE as ut,eF as pt,eG as ft,eH as ht,eI as gt,eJ as xt,eK as ne,eL as se,cr as mt,eM as bt}from"../datalayer-app-main.js";import{A as yt}from"./ArrowLeftIcon-Y3PTljcl.js";import{A as jt,T as St,M as Me,U as We,F as wt}from"./UnlinkIcon-DuVqPyB-.js";import Ie from"./index-BTnG8qrO.js";import{P as $e}from"./index-BJhxZF_K.js";import{L as de}from"./LinkIcon-DUI0jw25.js";import{A as kt}from"./Avatar-9MpXENSs.js";function vt(t,s){if(Object.is(t,s))return!0;if(typeof t!="object"||t===null||typeof s!="object"||s===null)return!1;if(t instanceof Map&&s instanceof Map){if(t.size!==s.size)return!1;for(const[l,o]of t)if(!Object.is(o,s.get(l)))return!1;return!0}if(t instanceof Set&&s instanceof Set){if(t.size!==s.size)return!1;for(const l of t)if(!s.has(l))return!1;return!0}const r=Object.keys(t);if(r.length!==Object.keys(s).length)return!1;for(const l of r)if(!Object.prototype.hasOwnProperty.call(s,l)||!Object.is(t[l],s[l]))return!1;return!0}const{useRef:zt}=te;function Ne(t){const s=zt();return r=>{const l=t(r);return vt(s.current,l)?s.current:s.current=l}}function D(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function Te(t){if(!Number.isFinite(t)||Number.isNaN(t)||t<0)return"0ms";if(t<1)return`${Math.max(0,Math.round(t*1e3))}ms`;if(t<60)return`${t.toFixed(1)}s`;const s=Math.floor(t/60),r=Math.round(t%60);return`${s}m ${r}s`}function Ct(t){const s=String(t??"");return/[",\n]/.test(s)?`"${s.replace(/"/g,'""')}"`:s}function It(t){const s=[];s.push(["Context Usage Snapshot for Agent",t.agentId]),s.push(["Generated At",new Date().toISOString()]),s.push([]),s.push(["Summary"]),s.push(["Total Tokens",t.totalTokens]),s.push(["Context Window",t.contextWindow]),s.push(["System Prompt Tokens",t.systemPromptTokens]),s.push(["Tool Tokens",t.toolTokens]),s.push(["History Tokens",t.historyTokens]),s.push(["Current Message Tokens",t.currentMessageTokens]),s.push(["User Message Tokens",t.userMessageTokens]),s.push(["Assistant Message Tokens",t.assistantMessageTokens]),s.push([]),t.sessionUsage&&(s.push(["Session Usage"]),s.push(["Input Tokens",t.sessionUsage.inputTokens]),s.push(["Output Tokens",t.sessionUsage.outputTokens]),s.push(["Requests",t.sessionUsage.requests]),s.push(["Tool Calls",t.sessionUsage.toolCalls]),s.push(["Turns",t.sessionUsage.turns]),s.push(["Duration Seconds",t.sessionUsage.durationSeconds]),s.push([])),t.turnUsage&&(s.push(["Last Turn Usage"]),s.push(["Input Tokens",t.turnUsage.inputTokens]),s.push(["Output Tokens",t.turnUsage.outputTokens]),s.push(["Requests",t.turnUsage.requests]),s.push(["Tool Calls",t.turnUsage.toolCalls]),s.push(["Duration Seconds",t.turnUsage.durationSeconds]),s.push([])),s.push(["Distribution"]),s.push(["Category","Tokens"]);for(const c of t.distribution?.children??[])s.push([c.name,c.value]);if(s.push([]),t.perRequestUsage.length>0){s.push(["Per Request Usage"]),s.push(["Request #","Input Tokens","Output Tokens","Duration Ms","Tool Names","Timestamp","Turn ID"]);for(const c of t.perRequestUsage)s.push([c.requestNum,c.inputTokens,c.outputTokens,c.durationMs,c.toolNames.join("; "),c.timestamp??"",c.turnId??""])}const r=s.map(c=>c.map(Ct).join(",")).join(`
|
|
2
2
|
`),l=new Blob([r],{type:"text/csv;charset=utf-8;"}),o=URL.createObjectURL(l),a=document.createElement("a");a.href=o;const d=new Date().toISOString().replace(/[:.]/g,"-");a.download=`context-usage-${t.agentId}-${d}.csv`,a.style.display="none",document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(o)}function Tt(t){switch(t.toLowerCase()){case"messages":case"history":return Ge;case"tools":case"tool definitions":return Be;case"system":case"system prompts":return qe;case"cache":return De;default:return me}}function At({agentId:t,apiBase:s,liveData:r,messageCount:l=0,defaultView:o="overview",chartHeight:a="200px"}){const[d,c]=z.useState(o),[h,p]=z.useState(!1),S=r!==void 0,u=r,b=!S,m=z.useMemo(()=>{if(!u?.perRequestUsage||u.perRequestUsage.length===0)return null;const g=u.perRequestUsage;let C=0,N=0;const B=[],M=[],w=[],X=[];return g.forEach(W=>{C+=W.inputTokens,N+=W.outputTokens,B.push(`#${W.requestNum}`),M.push(C),w.push(N),X.push(C+N)}),{tooltip:{trigger:"axis",formatter:W=>{let U=`<strong>${W[0]?.axisValue||""}</strong><br/>`;return W.forEach($=>{U+=`${$.marker} ${$.seriesName}: ${D($.value)}<br/>`}),U}},legend:{data:["Input","Output","Total"],bottom:0,textStyle:{fontSize:10}},grid:{left:45,right:15,top:10,bottom:35},xAxis:{type:"category",data:B,axisLabel:{fontSize:10}},yAxis:{type:"value",axisLabel:{fontSize:10,formatter:W=>D(W)}},series:[{name:"Input",type:"line",data:M,smooth:!0,lineStyle:{width:2},areaStyle:{opacity:.2},itemStyle:{color:"#3B82F6"}},{name:"Output",type:"line",data:w,smooth:!0,lineStyle:{width:2},areaStyle:{opacity:.2},itemStyle:{color:"#10B981"}},{name:"Total",type:"line",data:X,smooth:!0,lineStyle:{width:2,type:"dashed"},itemStyle:{color:"#8B5CF6"}}]}},[u?.perRequestUsage]),R=z.useMemo(()=>{if(!u?.distribution)return null;const{distribution:g}=u,C=g.children&&g.children.length>0;return{tooltip:{formatter:N=>`${N.name}: ${D(N.value)} tokens`},series:[{type:"treemap",data:C?g.children:[{name:"No data",value:1}],roam:!1,breadcrumb:{show:!1},label:{show:!0,formatter:"{b}",fontSize:11},itemStyle:{borderColor:"#fff",borderWidth:2},levels:[{itemStyle:{borderColor:"#777",borderWidth:0,gapWidth:1}},{itemStyle:{borderColor:"#555",borderWidth:5,gapWidth:1},colorSaturation:[.35,.5]},{colorSaturation:[.35,.5]}]}]}},[u?.distribution]);if(b)return e.jsxs(n,{children:[e.jsx(F,{as:"h4",sx:{fontSize:1,fontWeight:"semibold",mb:2,color:"fg.muted"},children:"Context Usage"}),e.jsxs(n,{p:3,bg:"canvas.subtle",borderRadius:2,border:"1px solid",borderColor:"border.default",display:"flex",alignItems:"center",gap:2,children:[e.jsx(ae,{size:"small"}),e.jsx(i,{sx:{fontSize:1,color:"fg.muted"},children:"Loading context details..."})]})]});if(!u)return e.jsxs(n,{children:[e.jsx(F,{as:"h4",sx:{fontSize:1,fontWeight:"semibold",mb:2,color:"fg.muted"},children:"Context Usage"}),e.jsx(n,{p:3,bg:"attention.subtle",borderRadius:2,border:"1px solid",borderColor:"attention.muted",children:e.jsx(i,{sx:{fontSize:1,color:"attention.fg"},children:"Waiting for context data from WebSocket stream..."})})]});const{totalTokens:P,contextWindow:y,sessionUsage:f,turnUsage:j,distribution:E}=u,I=l>0?l:Math.max(f?.turns??0,u.perRequestUsage?.length>0?1:0),O=E?.children&&E.children.length>0;return e.jsxs(n,{children:[e.jsxs(n,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[e.jsx(F,{as:"h4",sx:{fontSize:1,fontWeight:"semibold",color:"fg.muted"},children:"Context Usage"}),e.jsxs(n,{display:"flex",alignItems:"center",gap:2,children:[I>0&&e.jsxs(i,{sx:{fontSize:0,color:"fg.muted"},children:[I," ",I===1?"message sent":"messages sent"]}),e.jsx(L,{size:"small",variant:"invisible",leadingVisual:Re,onClick:()=>It(u),children:"Download"})]})]}),e.jsxs(n,{p:3,bg:"canvas.subtle",borderRadius:2,border:"1px solid",borderColor:"border.default",children:[e.jsx(n,{mb:3,children:e.jsxs(i,{sx:{fontSize:1,fontWeight:"semibold"},children:["Total usage: ",D(P)]})}),(f||j)&&e.jsxs(n,{display:"flex",gap:3,mb:3,flexWrap:"wrap",children:[f&&e.jsxs(n,{flex:1,minWidth:120,p:2,bg:"canvas.default",borderRadius:2,border:"1px solid",borderColor:"border.muted",children:[e.jsxs(i,{sx:{fontSize:0,color:"fg.muted",display:"block"},children:["Session (",f.turns," turns)"]}),e.jsx(i,{sx:{fontSize:1,fontWeight:"semibold"},children:D(f.inputTokens+f.outputTokens)}),e.jsxs(i,{sx:{fontSize:0,color:"fg.muted"},children:[" ","in ",Te(f.durationSeconds)]})]}),j&&e.jsxs(n,{flex:1,minWidth:120,p:2,bg:"canvas.default",borderRadius:2,border:"1px solid",borderColor:"border.muted",children:[e.jsxs(i,{sx:{fontSize:0,color:"fg.muted",display:"block"},children:["Last Turn (",j.requests," reqs)"]}),e.jsx(i,{sx:{fontSize:1,fontWeight:"semibold"},children:D(j.inputTokens+j.outputTokens)}),e.jsxs(i,{sx:{fontSize:0,color:"fg.muted"},children:[" ","in ",Te(j.durationSeconds)]})]})]}),e.jsxs(n,{display:"flex",justifyContent:"space-between",alignItems:"center",mb:2,children:[e.jsxs(le,{"aria-label":"View mode",size:"small",onChange:g=>{c(["overview","distribution","history"][g])},children:[e.jsx(le.IconButton,{"aria-label":"Overview",selected:d==="overview",icon:He}),e.jsx(le.IconButton,{"aria-label":"Distribution",selected:d==="distribution",icon:jt,disabled:!O}),e.jsx(le.IconButton,{"aria-label":"History",selected:d==="history",icon:Ve})]}),d==="overview"&&e.jsx(L,{size:"small",variant:"invisible",onClick:()=>p(!h),children:h?"Less":"More"})]}),d==="overview"&&e.jsxs(n,{children:[e.jsxs(n,{display:"flex",flexDirection:"column",gap:2,children:[O&&E.children.map(g=>{const C=Tt(g.name),N=g.value/y*100;return e.jsxs(n,{display:"flex",alignItems:"center",gap:2,children:[e.jsx(n,{color:"fg.muted",width:20,children:e.jsx(C,{size:16})}),e.jsx(i,{sx:{fontSize:1,flex:1},children:g.name}),e.jsx(i,{sx:{fontSize:0,color:"fg.muted",minWidth:60},children:D(g.value)}),e.jsx(n,{width:80,children:e.jsx($e,{progress:N,sx:{height:4}})})]},g.name)}),!O&&e.jsx(i,{sx:{color:"fg.muted",fontSize:1,textAlign:"center",py:2},children:"No context data yet. Start a conversation to see usage."})]}),h&&O&&e.jsxs(n,{mt:3,p:2,bg:"canvas.default",borderRadius:2,border:"1px solid",borderColor:"border.muted",fontSize:0,children:[u.systemPromptTokens>0&&e.jsxs(n,{mb:2,children:[e.jsxs(i,{sx:{fontWeight:"semibold"},children:["System Prompts:"," ",D(u.systemPromptTokens)," tokens"]}),u.systemPrompts.slice(0,2).map((g,C)=>e.jsxs(i,{sx:{display:"block",ml:2,mt:1,color:"fg.muted"},children:["•"," ",g.length>80?g.slice(0,80)+"...":g]},C))]}),u.toolTokens>0&&e.jsxs(n,{mb:2,children:[e.jsxs(i,{sx:{fontWeight:"semibold"},children:["Tools: ",D(u.toolTokens)," tokens (",u.tools.length," tools)"]}),e.jsxs(n,{ml:2,mt:1,children:[u.tools.slice(0,4).map((g,C)=>e.jsxs(i,{sx:{display:"block",color:"fg.muted"},children:["• ",g.name,": ",D(g.totalTokens)]},C)),u.tools.length>4&&e.jsxs(i,{sx:{color:"fg.muted",fontStyle:"italic"},children:["...and ",u.tools.length-4," more"]})]})]}),(u.userMessageTokens>0||u.assistantMessageTokens>0)&&e.jsxs(n,{mb:2,children:[e.jsxs(i,{sx:{fontWeight:"semibold"},children:["Messages:"," ",D(u.userMessageTokens+u.assistantMessageTokens)," ","tokens"]}),e.jsxs(n,{ml:2,mt:1,children:[e.jsxs(i,{sx:{display:"block",color:"fg.muted"},children:["• User: ",D(u.userMessageTokens)]}),e.jsxs(i,{sx:{display:"block",color:"fg.muted"},children:["• Assistant:"," ",D(u.assistantMessageTokens)]}),u.toolCallTokens>0&&e.jsxs(i,{sx:{display:"block",color:"fg.muted"},children:["• Tool calls:"," ",D(u.toolCallTokens)]})]})]})]})]}),d==="distribution"&&R&&e.jsx(Ie,{option:R,style:{height:a},opts:{renderer:"svg"}}),d==="history"&&m&&e.jsxs(n,{children:[e.jsx(Ie,{option:m,style:{height:a},opts:{renderer:"svg"}}),h&&u.perRequestUsage.length>0&&e.jsx(n,{mt:2,maxHeight:"150px",overflowY:"auto",fontSize:0,children:u.perRequestUsage.slice(-10).reverse().map((g,C)=>e.jsxs(n,{display:"flex",gap:2,py:1,borderBottom:C<9?"1px solid":"none",borderColor:"border.muted",children:[e.jsxs(i,{sx:{fontWeight:"semibold",minWidth:30},children:["#",g.requestNum]}),e.jsxs(i,{sx:{color:"#3B82F6"},children:["↓",D(g.inputTokens)]}),e.jsxs(i,{sx:{color:"#10B981"},children:["↑",D(g.outputTokens)]}),g.toolNames.length>0&&e.jsxs(i,{sx:{color:"fg.muted"},children:["🔧 ",g.toolNames.join(", ")]})]},g.requestNum))})]}),d==="history"&&!m&&e.jsx(n,{py:3,children:e.jsx(i,{sx:{color:"fg.muted",fontSize:1},children:"No history"})})]})]})}function q(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toString()}function ee({title:t,icon:s,count:r,tokens:l,defaultExpanded:o=!1,children:a}){const[d,c]=z.useState(o);return e.jsxs(n,{mb:2,children:[e.jsxs(n,{as:"button",onClick:()=>c(!d),display:"flex",alignItems:"center",gap:2,width:"100%",p:2,bg:"canvas.subtle",border:"1px solid",borderColor:"border.default",borderRadius:2,cursor:"pointer",hover:{bg:"canvas.inset"},children:[d?e.jsx(Ye,{size:16}):e.jsx(Xe,{size:16}),te.createElement(s,{size:16}),e.jsx(i,{sx:{fontWeight:"semibold",flex:1,textAlign:"left"},children:t}),r!==void 0&&e.jsx(A,{variant:"secondary",size:"small",children:r}),l!==void 0&&l>0&&e.jsxs(i,{sx:{fontSize:0,color:"fg.muted"},children:[q(l)," tokens"]})]}),d&&e.jsx(n,{border:"1px solid",borderColor:"border.default",borderTop:"none",borderRadius:"0 0 6px 6px",p:2,children:a})]})}function Et({tool:t}){const[s,r]=z.useState(!1),[l,o]=z.useState(!1);return e.jsxs(n,{p:2,mb:2,bg:"canvas.default",border:"1px solid",borderColor:"border.muted",borderRadius:2,children:[e.jsxs(n,{display:"flex",alignItems:"center",gap:2,mb:1,children:[e.jsx(i,{sx:{fontWeight:"bold",fontFamily:"mono",fontSize:1},children:t.name}),e.jsx(A,{size:"small",variant:"secondary",children:t.sourceType}),t.isAsync&&e.jsx(A,{size:"small",variant:"accent",children:"async"}),t.requiresApproval&&e.jsx(A,{size:"small",variant:"attention",children:"requires approval"}),e.jsxs(i,{sx:{fontSize:0,color:"fg.muted",ml:"auto"},children:[q(t.totalTokens)," tokens"]})]}),t.description&&e.jsx(i,{sx:{fontSize:1,color:"fg.muted",display:"block",mb:2},children:t.description}),e.jsxs(n,{display:"flex",gap:2,children:[e.jsxs(L,{size:"small",variant:"invisible",onClick:()=>r(!s),children:[s?"Hide":"Show"," Schema"]}),t.sourceCode&&e.jsxs(L,{size:"small",variant:"invisible",onClick:()=>o(!l),children:[l?"Hide":"Show"," Source"]})]}),s&&e.jsx(n,{as:"pre",mt:2,p:2,bg:"canvas.inset",borderRadius:2,fontSize:0,overflow:"auto",maxHeight:200,children:JSON.stringify(t.parametersSchema,null,2)}),l&&t.sourceCode&&e.jsx(n,{as:"pre",mt:2,p:2,bg:"canvas.inset",borderRadius:2,fontSize:0,overflow:"auto",maxHeight:300,children:t.sourceCode})]})}function Ut({agentId:t,apiBase:s,liveData:r}){const l=r!==void 0,o=r;if(!l)return e.jsx(n,{p:3,display:"flex",alignItems:"center",justifyContent:"center",children:e.jsx(i,{sx:{color:"fg.muted"},children:"Waiting for context data from WebSocket stream..."})});if(!o)return e.jsx(n,{p:3,bg:"attention.subtle",borderRadius:2,border:"1px solid",borderColor:"attention.muted",children:e.jsx(i,{sx:{color:"attention.fg"},children:"No context data available."})});if(o.error)return e.jsx(n,{p:3,bg:"attention.subtle",borderRadius:2,border:"1px solid",borderColor:"attention.muted",children:e.jsx(i,{sx:{color:"attention.fg"},children:o.error})});const{tokenSummary:a,modelConfiguration:d}=o;return e.jsxs(n,{children:[e.jsxs(n,{mb:3,children:[e.jsxs(i,{sx:{fontSize:1,fontWeight:"semibold"},children:["Total usage: ",q(a.total)," /"," ",q(a.contextWindow)," (",Math.round(a.usagePercent),"%)"]}),e.jsx($e,{progress:Math.min(a.usagePercent,100),sx:{mt:2,height:8},bg:a.usagePercent>90?"danger.emphasis":a.usagePercent>70?"attention.emphasis":"success.emphasis"}),e.jsxs(n,{display:"flex",gap:3,mt:2,flexWrap:"wrap",fontSize:0,color:"fg.muted",children:[e.jsxs(i,{children:["System: ",q(a.systemPrompts)]}),e.jsxs(i,{children:["Tools: ",q(a.tools)]}),a.memory>0&&e.jsxs(i,{children:["Memory: ",q(a.memory)]}),e.jsxs(i,{children:["History: ",q(a.history)]}),e.jsxs(i,{children:["Current: ",q(a.current)]})]})]}),e.jsx(ee,{title:"Model Configuration",icon:Ke,defaultExpanded:!1,children:e.jsxs(n,{display:"grid",gridTemplateColumns:"1fr 2fr",gap:2,children:[e.jsx(i,{sx:{fontWeight:"semibold",fontSize:1},children:"Model:"}),e.jsx(i,{sx:{fontSize:1,fontFamily:"mono"},children:d.modelName||"Not specified"}),e.jsx(i,{sx:{fontWeight:"semibold",fontSize:1},children:"Context Window:"}),e.jsxs(i,{sx:{fontSize:1},children:[q(d.contextWindow)," tokens"]}),Object.keys(d.settings).length>0&&e.jsxs(e.Fragment,{children:[e.jsx(i,{sx:{fontWeight:"semibold",fontSize:1},children:"Settings:"}),e.jsx(n,{as:"pre",fontSize:0,p:2,bg:"canvas.inset",borderRadius:2,overflow:"auto",children:JSON.stringify(d.settings,null,2)})]})]})}),e.jsx(ee,{title:"System Prompts",icon:Je,count:o.systemPrompts.length,tokens:o.systemPromptTokens,children:o.systemPrompts.length===0?e.jsx(i,{sx:{color:"fg.muted",fontSize:1},children:"No system prompts configured"}):o.systemPrompts.map((c,h)=>e.jsxs(n,{p:2,mb:2,bg:"canvas.inset",borderRadius:2,border:"1px solid",borderColor:"border.muted",children:[e.jsxs(n,{display:"flex",justifyContent:"space-between",mb:1,children:[e.jsxs(i,{sx:{fontWeight:"semibold",fontSize:0},children:["Prompt ",h+1]}),e.jsxs(i,{sx:{fontSize:0,color:"fg.muted"},children:[q(c.tokens)," tokens"]})]}),e.jsx(i,{as:"pre",sx:{fontSize:0,whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:200,overflow:"auto"},children:c.content})]},h))}),e.jsx(ee,{title:"Tool Definitions",icon:St,count:o.tools.length,tokens:o.toolTokens,children:o.tools.length===0?e.jsx(i,{sx:{color:"fg.muted",fontSize:1},children:"No tools configured"}):o.tools.map((c,h)=>e.jsx(Et,{tool:c},h))}),o.memoryBlocks.length>0&&e.jsx(ee,{title:"Memory Blocks",icon:De,count:o.memoryBlocks.length,tokens:o.memoryTokens,children:o.memoryBlocks.map((c,h)=>e.jsx(n,{as:"pre",p:2,mb:2,bg:"canvas.inset",borderRadius:2,fontSize:0,overflow:"auto",children:JSON.stringify(c,null,2)},h))}),Object.keys(o.toolEnvironment).length>0&&e.jsx(ee,{title:"Tool Environment",icon:H,count:Object.keys(o.toolEnvironment).length,children:e.jsx(n,{display:"grid",gridTemplateColumns:"1fr 2fr",gap:2,children:Object.entries(o.toolEnvironment).map(([c,h])=>e.jsxs(te.Fragment,{children:[e.jsx(i,{sx:{fontFamily:"mono",fontSize:1,fontWeight:"semibold"},children:c}),e.jsx(i,{sx:{fontFamily:"mono",fontSize:1,color:"fg.muted"},children:h})]},c))})}),o.toolRules.length>0&&e.jsx(ee,{title:"Tool Rules",icon:ce,count:o.toolRules.length,children:o.toolRules.map((c,h)=>e.jsx(n,{as:"pre",p:2,mb:2,bg:"canvas.inset",borderRadius:2,fontSize:0,overflow:"auto",children:JSON.stringify(c,null,2)},h))})]})}const ye={provider:"github",displayName:"GitHub",iconUrl:"https://github.githubassets.com/favicons/favicon.svg",authorizationUrl:"https://github.com/login/oauth/authorize",tokenUrl:"https://github.com/login/oauth/access_token",userInfoUrl:"https://api.github.com/user",revocationUrl:"https://api.github.com/applications/{client_id}/token",defaultScopes:["read:user","user:email"]},je={provider:"google",displayName:"Google",iconUrl:"https://www.google.com/favicon.ico",authorizationUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",userInfoUrl:"https://www.googleapis.com/oauth2/v2/userinfo",revocationUrl:"https://oauth2.googleapis.com/revoke",defaultScopes:["openid","email","profile"],additionalParams:{access_type:"offline",prompt:"consent"}},Se={provider:"kaggle",displayName:"Kaggle",iconUrl:"https://www.kaggle.com/static/images/favicon.ico",authorizationUrl:"https://www.kaggle.com/oauth/authorize",tokenUrl:"https://www.kaggle.com/oauth/token",userInfoUrl:"https://www.kaggle.com/api/v1/me",defaultScopes:["datasets:read","notebooks:read"]};function _t(t=64){const s=Math.max(43,Math.min(128,t)),r=new Uint8Array(s);return crypto.getRandomValues(r),we(r)}async function Rt(t){const r=new TextEncoder().encode(t),l=await crypto.subtle.digest("SHA-256",r);return we(new Uint8Array(l))}function Dt(){const t=new Uint8Array(32);return crypto.getRandomValues(t),we(t)}function we(t){let s="";const r=new Uint8Array(t);for(let l=0;l<r.length;l++)s+=String.fromCharCode(r[l]);return s=btoa(s),s.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}async function Pt(){const t=_t(),s=await Rt(t);return{codeVerifier:t,codeChallenge:s}}const Ot="datalayer-agent-identities",Ae="/api/v1/identity/oauth/token",Mt="/api/v1/identity/oauth/userinfo",Wt="/api/v1/identity/oauth/revoke",$t={identities:new Map,pendingAuthorization:null,providerConfigs:new Map,isLoading:!1,error:null};function Nt(t,s,r,l){const o=new URLSearchParams({client_id:t.clientId,redirect_uri:t.redirectUri,response_type:"code",scope:s.join(" "),state:r,code_challenge:l,code_challenge_method:"S256",...t.additionalParams});return`${t.authorizationUrl}?${o.toString()}`}const T=Qe()(Ze(et(tt((t,s)=>({...$t,configureProvider:r=>{t(l=>{const o=new Map(l.providerConfigs);return o.set(r.provider,r),{providerConfigs:o}})},startAuthorization:async(r,l,o)=>{const d=s().providerConfigs.get(r);if(!d)throw new Error(`Provider ${r} is not configured`);const{codeVerifier:c,codeChallenge:h}=await Pt(),p=Dt(),S=l||d.defaultScopes,u=Nt(d,S,p,h),b={requestId:`auth-${Date.now()}-${Math.random().toString(36).substr(2,9)}`,provider:r,authUrl:u,state:p,codeVerifier:c,scopes:S,requestedAt:Date.now(),onComplete:o?.onComplete,onError:o?.onError};return t({pendingAuthorization:b,error:null}),u},completeAuthorization:async r=>{const l=s(),o=l.pendingAuthorization;if(!o)throw new Error("No pending authorization request");if(r.state!==o.state){const a=new Error("State mismatch - possible CSRF attack");throw o.onError?.(a),t({pendingAuthorization:null,error:a}),a}if(r.error){const a=new Error(r.errorDescription||r.error);throw o.onError?.(a),t({pendingAuthorization:null,error:a}),a}t({isLoading:!0});try{const a=l.providerConfigs.get(o.provider);if(!a)throw new Error(`Provider ${o.provider} is not configured`);const d=a.redirectUri.split("/").slice(0,3).join("/"),c=await fetch(`${d}${Ae}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:o.provider,code:r.code,code_verifier:o.codeVerifier,redirect_uri:a.redirectUri})});if(!c.ok){const b=await c.json().catch(()=>({}));throw new Error(b.detail||`Token exchange failed: ${c.status}`)}const h=await c.json(),p={accessToken:h.access_token,tokenType:h.token_type||"Bearer",expiresAt:h.expires_in?Date.now()+h.expires_in*1e3:void 0,refreshToken:h.refresh_token,scopes:o.scopes};let S;if(a.userInfoUrl)try{const b=await fetch(`${d}${Mt}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:o.provider,access_token:p.accessToken})});if(b.ok){const m=await b.json();S={id:m.id?.toString()||m.sub,username:m.login||m.username,name:m.name,email:m.email,avatarUrl:m.avatar_url||m.picture,profileUrl:m.html_url||m.profile,raw:m}}}catch(b){console.warn("Failed to fetch user info:",b)}const u={provider:o.provider,displayName:a.displayName,iconUrl:a.iconUrl,scopes:o.scopes,isConnected:!0,connectedAt:Date.now(),userInfo:S,token:p};return t(b=>{const m=new Map(b.identities);return m.set(o.provider,u),{identities:m,pendingAuthorization:null,isLoading:!1,error:null}}),o.onComplete?.(u),u}catch(a){const d=a instanceof Error?a:new Error(String(a));throw o.onError?.(d),t({isLoading:!1,error:d,pendingAuthorization:null}),d}},cancelAuthorization:()=>{const r=s().pendingAuthorization;r?.onError&&r.onError(new Error("Authorization cancelled")),t({pendingAuthorization:null})},connectWithToken:async(r,l,o)=>{t({isLoading:!0,error:null});try{const a={accessToken:l,tokenType:"Bearer",scopes:[]},d={kaggle:{displayName:"Kaggle",iconUrl:"https://www.kaggle.com/static/images/favicon.ico"}}[r]||{displayName:r,iconUrl:void 0},c={provider:r,authType:"token",displayName:o?.displayName||d.displayName,iconUrl:o?.iconUrl||d.iconUrl,scopes:[],isConnected:!0,connectedAt:Date.now(),userInfo:o?.userInfo,token:a};return t(h=>{const p=new Map(h.identities);return p.set(r,c),{identities:p,isLoading:!1,error:null}}),c}catch(a){const d=a instanceof Error?a:new Error(String(a));throw t({isLoading:!1,error:d}),d}},disconnect:async r=>{const l=s(),o=l.identities.get(r),a=l.providerConfigs.get(r);if(!o||!o.token){t(d=>{const c=new Map(d.identities);return c.delete(r),{identities:c}});return}if(o.authType==="token"){t(d=>{const c=new Map(d.identities);return c.delete(r),{identities:c}});return}if(a?.revocationUrl)try{const d=a.redirectUri.split("/").slice(0,3).join("/");await fetch(`${d}${Wt}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,access_token:o.token.accessToken})})}catch(d){console.warn("Failed to revoke token:",d)}t(d=>{const c=new Map(d.identities);return c.delete(r),{identities:c}})},refreshToken:async r=>{const l=s(),o=l.identities.get(r),a=l.providerConfigs.get(r);if(!o||!o.token?.refreshToken)throw new Error(`No refresh token available for ${r}`);if(!a)throw new Error(`Provider ${r} is not configured`);const d=a.redirectUri.split("/").slice(0,3).join("/"),c=await fetch(`${d}${Ae}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({provider:r,grant_type:"refresh_token",refresh_token:o.token.refreshToken})});if(!c.ok)throw new Error(`Token refresh failed: ${c.status}`);const h=await c.json(),p={accessToken:h.access_token,tokenType:h.token_type||"Bearer",expiresAt:h.expires_in?Date.now()+h.expires_in*1e3:void 0,refreshToken:h.refresh_token||o.token.refreshToken,scopes:o.scopes};return t(S=>{const u=new Map(S.identities);return u.set(r,{...o,token:p}),{identities:u}}),p},getIdentity:r=>s().identities.get(r),isConnected:r=>s().identities.get(r)?.isConnected??!1,getToken:async r=>{const o=s().identities.get(r);if(!o||!o.token)return null;const a=o.token.expiresAt;if(a&&a-Date.now()<300*1e3){if(o.token.refreshToken)try{return await s().refreshToken(r)}catch(d){return console.warn("Token refresh failed:",d),null}return null}return o.token},clearAll:()=>{t({identities:new Map,pendingAuthorization:null,error:null})},setError:r=>{t({error:r})}}),{name:Ot,storage:{getItem:t=>{const s=localStorage.getItem(t);if(!s)return null;const r=JSON.parse(s),l=new URLSearchParams(window.location.search),o=l.has("code")&&l.has("state");return{state:{...r.state,identities:new Map(r.state.identities||[]),providerConfigs:new Map(r.state.providerConfigs||[]),pendingAuthorization:o&&r.state.pendingAuthorization||null,isLoading:!1,error:null}}},setItem:(t,s)=>{const r={state:{...s.state,identities:Array.from(s.state.identities.entries()),providerConfigs:Array.from(s.state.providerConfigs.entries()),pendingAuthorization:s.state.pendingAuthorization?{...s.state.pendingAuthorization,onComplete:void 0,onError:void 0}:null,isLoading:!1,error:null}};localStorage.setItem(t,JSON.stringify(r))},removeItem:t=>localStorage.removeItem(t)},partialize:t=>({identities:t.identities,providerConfigs:t.providerConfigs,pendingAuthorization:t.pendingAuthorization})})),{name:"IdentityStore"}));function Lt(){return T(Ne(t=>Array.from(t.identities.values()).filter(s=>s.isConnected)))}function Ft(){return T(Ne(t=>Array.from(t.identities.entries()).filter(([s,r])=>r.isConnected).map(([s])=>s)))}function Ht(){return T(t=>t.pendingAuthorization)}function Vt(){return T(t=>t.isLoading)}function qt(){return T(t=>t.error)}function fe(t){const s=T.getState();t.github&&s.configureProvider({...ye,clientId:t.github.clientId,redirectUri:t.github.redirectUri}),t.google&&s.configureProvider({...je,clientId:t.google.clientId,redirectUri:t.google.redirectUri}),t.kaggle&&s.configureProvider({...Se,clientId:t.kaggle.clientId,redirectUri:t.kaggle.redirectUri})}function ke(t={}){const{providers:s,baseUrl:r=typeof window<"u"?window.location.origin:"",callbackPath:l=typeof window<"u"?window.location.pathname:"/oauth/callback",autoHandleCallback:o=!0}=t,a=Lt(),d=Ft(),c=Ht(),h=Vt(),p=qt(),S=T(x=>x.startAuthorization),u=T(x=>x.completeAuthorization),b=T(x=>x.cancelAuthorization),m=T(x=>x.disconnect),R=T(x=>x.getIdentity),P=T(x=>x.isConnected),y=T(x=>x.getToken),f=T(x=>x.configureProvider);z.useEffect(()=>{if(!s)return;const x=`${r}${l}`;s.github&&fe({github:{clientId:s.github.clientId,redirectUri:s.github.redirectUri||x}}),s.google&&fe({google:{clientId:s.google.clientId,redirectUri:s.google.redirectUri||x}}),s.kaggle&&fe({kaggle:{clientId:s.kaggle.clientId,redirectUri:s.kaggle.redirectUri||x}}),s.custom&&s.custom.forEach(U=>{f(U)})},[s,r,l,f]),z.useEffect(()=>{if(!o||typeof window>"u")return;const x=new URLSearchParams(window.location.search),U=x.get("code"),$=x.get("state"),G=x.get("error"),V=x.get("error_description");(U&&$||G)&&u({code:U||"",state:$||"",error:G||void 0,errorDescription:V||void 0}).then(()=>{const K=window.location.pathname;window.history.replaceState({},"",K)}).catch(K=>{console.error("OAuth callback error:",K);const Q=window.location.pathname;window.history.replaceState({},"",Q)})},[o,u]);const j=z.useCallback(async(x,U)=>{const $=await S(x,U);window.location.href=$},[S]),E=z.useCallback(async(x,U)=>{const $=await S(x,U,{onComplete:()=>{},onError:()=>{}});return new Promise((G,V)=>{const K=T.getState();K.pendingAuthorization&&(K.pendingAuthorization.onComplete=G,K.pendingAuthorization.onError=V);const Q=600,k=700,ue=window.screenX+(window.outerWidth-Q)/2,v=window.screenY+(window.outerHeight-k)/2,_=window.open($,"oauth_popup",`width=${Q},height=${k},left=${ue},top=${v},toolbar=no,menubar=no`);if(!_){V(new Error("Failed to open popup window"));return}const J=Y=>{if(Y.origin===window.location.origin)if(Y.data?.type==="oauth-callback-success"){window.removeEventListener("message",J),clearInterval(oe),_.close();const ie=Y.data.provider,re=Y.data.identity;if(console.debug("[Identity] Received oauth-callback-success for provider:",ie),console.debug("[Identity] Identity from popup:",re),re){const ve=T.getState().identities,Z=new Map(ve);Z.set(ie,re),T.setState({identities:Z,pendingAuthorization:null}),console.debug("[Identity] Store updated with identity from popup, identities count:",Z.size),G(re);return}setTimeout(()=>{const Z=localStorage.getItem("agent-runtimes-identity");if(console.debug("[Identity] Fallback: reading from localStorage"),Z)try{const Le=JSON.parse(Z).state?.identities||[],pe=new Map(Le).get(ie);if(pe){const Fe=T.getState().identities,Ce=new Map(Fe);Ce.set(ie,pe),T.setState({identities:Ce,pendingAuthorization:null}),G(pe);return}}catch(ze){console.error("[Identity] Failed to parse identity from localStorage:",ze)}T.setState({pendingAuthorization:null}),V(new Error("Identity not found after OAuth success"))},100)}else Y.data?.type==="oauth-callback-error"?(window.removeEventListener("message",J),clearInterval(oe),_.close(),T.setState({pendingAuthorization:null}),V(new Error(Y.data.error||"OAuth authentication failed"))):Y.data?.type==="oauth_callback"&&(window.removeEventListener("message",J),clearInterval(oe),_.close(),u(Y.data.payload).then(G).catch(V))};window.addEventListener("message",J);const oe=setInterval(()=>{_.closed&&(clearInterval(oe),window.removeEventListener("message",J),T.getState().pendingAuthorization&&(b(),V(new Error("Popup closed by user"))))},500)})},[S,u,b]),I=T(x=>x.connectWithToken),O=z.useCallback(async(x,U,$)=>I(x,U,$),[I]),g=z.useCallback(async x=>{await m(x)},[m]),C=z.useCallback(async x=>u(x),[u]),N=z.useCallback(()=>{b()},[b]),B=z.useCallback(x=>P(x),[P]),M=z.useCallback(x=>R(x),[R]),w=z.useCallback(async x=>(await y(x))?.accessToken??null,[y]),X=z.useCallback(x=>{f(x)},[f]),W=c!==null;return z.useMemo(()=>({identities:a,connectedProviders:d,isAuthorizing:W,isLoading:h,error:p,pendingAuthorization:c,connect:j,connectWithPopup:E,connectWithToken:O,disconnect:g,completeAuthorization:C,cancelAuthorization:N,isConnected:B,getIdentity:M,getAccessToken:w,configureProvider:X}),[a,d,W,h,p,c,j,E,O,g,C,N,B,M,w,X])}const Ee={github:{name:"GitHub",icon:Me,color:"#24292f",description:"Access GitHub repositories and APIs"},google:{name:"Google",icon:H,color:"#4285f4",description:"Access Google services and APIs"},kaggle:{name:"Kaggle",icon:H,color:"#20beff",description:"Access Kaggle datasets and notebooks"},linkedin:{name:"LinkedIn",icon:H,color:"#0077b5",description:"Access LinkedIn profile and connections"},slack:{name:"Slack",icon:H,color:"#4a154b",description:"Access Slack workspaces and channels"},notion:{name:"Notion",icon:H,color:"#000000",description:"Access Notion pages and databases"},custom:{name:"Custom",icon:de,color:"#6f42c1",description:"Custom OAuth provider"}},Bt={github:["read:user","user:email"],google:["openid","profile","email"],kaggle:["read"],linkedin:["r_liteprofile","r_emailaddress"],slack:["users:read","channels:read"],notion:["read_content"],custom:[]},Gt=({provider:t,clientId:s,providerConfig:r,scopes:l,disabled:o=!1,size:a="medium",variant:d="full",onConnect:c,onDisconnect:h,onError:p})=>{const{identities:S,isAuthorizing:u,error:b,connectWithPopup:m,disconnect:R,configureProvider:P}=ke(),y=Ee[t]||Ee.custom,f=S.find(g=>g.provider===t),j=!!f,E=u;te.useEffect(()=>{if(s){const g=t==="github"?ye:t==="google"?je:t==="kaggle"?Se:void 0;if(g){const C=r?.redirectUri||(typeof window<"u"?`${window.location.origin}${window.location.pathname}`:"");P({...g,...r,provider:t,clientId:s,redirectUri:C})}}},[s,t,r,P]);const I=z.useCallback(async()=>{try{if(j)await R(t),h?.(t);else{const g=await m(t,l||Bt[t]);c?.(g)}}catch(g){const C=g instanceof Error?g.message:String(g);C!=="Popup closed by user"&&p?.(g instanceof Error?g:new Error(C))}},[j,t,l,m,R,c,h,p]);te.useEffect(()=>{b&&p?.(b instanceof Error?b:new Error(String(b)))},[b,p]);const O={onClick:I,disabled:o||E||!s&&!j,size:a==="large"?"large":a==="small"?"small":"medium"};return d==="icon"?e.jsx(L,{...O,variant:j?"primary":"default","aria-label":j?`Disconnect ${y.name}`:`Connect ${y.name}`,sx:{width:a==="small"?28:a==="large"?44:36,height:a==="small"?28:a==="large"?44:36,p:0},children:E?e.jsx(n,{as:"span",className:"anim-rotate",display:"inline-block",children:"⏳"}):e.jsx(y.icon,{size:a==="small"?14:18})}):d==="compact"?e.jsx(L,{...O,variant:j?"primary":"default",leadingVisual:y.icon,trailingVisual:j?Pe:void 0,children:E?"Connecting...":y.name}):e.jsxs(n,{display:"flex",flexDirection:"column",gap:2,p:2,border:"1px solid",borderColor:j?"success.muted":"border.default",borderRadius:2,backgroundColor:j?"success.subtle":"canvas.subtle",children:[e.jsxs(n,{display:"flex",alignItems:"center",gap:2,children:[e.jsx(n,{width:40,height:40,borderRadius:2,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:y.color,color:"white",children:e.jsx(y.icon,{size:20})}),e.jsxs(n,{flex:1,children:[e.jsx(i,{sx:{fontWeight:"bold",display:"block"},children:y.name}),e.jsx(i,{sx:{fontSize:0,color:"fg.muted",display:"block"},children:j&&f?.userInfo?`Connected as ${f.userInfo.name||f.userInfo.email}`:y.description})]}),!j&&e.jsx(L,{...O,variant:"primary",leadingVisual:de,children:E?"Working...":"Connect"})]}),j&&f&&e.jsxs(n,{display:"flex",flexDirection:"column",gap:2,children:[e.jsxs(n,{display:"flex",alignItems:"center",gap:2,pl:1,children:[f.userInfo?.avatarUrl&&e.jsx("a",{href:f.userInfo.profileUrl||`https://github.com/${f.userInfo.username}`,target:"_blank",rel:"noopener noreferrer",style:{display:"block",lineHeight:0},children:e.jsx("img",{src:f.userInfo.avatarUrl,alt:f.userInfo.name||"User avatar",style:{width:32,height:32,borderRadius:"50%",cursor:"pointer"}})}),e.jsxs(n,{flex:1,children:[f.userInfo?.username&&e.jsx("a",{href:f.userInfo.profileUrl||`https://github.com/${f.userInfo.username}`,target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsxs(i,{sx:{fontSize:1,color:"fg.muted",display:"block",":hover":{textDecoration:"underline"}},children:["@",f.userInfo.username]})}),e.jsx(i,{sx:{fontSize:0,color:"fg.muted",display:"block"},children:f.token?.expiresAt?`Expires ${new Date(f.token.expiresAt).toLocaleDateString()}`:"Token does not expire"})]})]}),f.scopes&&f.scopes.length>0&&e.jsx(n,{display:"flex",flexWrap:"wrap",gap:1,pl:1,children:f.scopes.map(g=>e.jsx(i,{sx:{fontSize:0,px:2,py:1,bg:"neutral.muted",borderRadius:2,color:"fg.muted"},children:g},g))}),e.jsxs(L,{...O,variant:"danger",leadingVisual:We,children:["Disconnect from ",y.name]})]})]})},Ue={github:{name:"GitHub",icon:Me,color:"#24292f",description:"Access GitHub repositories and APIs"},google:{name:"Google",icon:H,color:"#4285f4",description:"Access Google services and APIs"},kaggle:{name:"Kaggle",icon:H,color:"#20beff",description:"Access Kaggle datasets and notebooks"},linkedin:{name:"LinkedIn",icon:H,color:"#0077b5",description:"Access LinkedIn profile"},slack:{name:"Slack",icon:H,color:"#4a154b",description:"Access Slack workspaces"},notion:{name:"Notion",icon:H,color:"#000000",description:"Access Notion pages"},custom:{name:"Custom",icon:de,color:"#6f42c1",description:"Custom OAuth provider"}},Kt={github:["read:user","user:email","repo"],google:["openid","profile","email"],kaggle:["read"],linkedin:["r_liteprofile","r_emailaddress"],slack:["users:read","channels:read"],notion:["read_content"],custom:[]};function Jt(t){if(!t)return{isExpired:!1,isExpiringSoon:!1};const s=Date.now(),r=new Date(t),l=t-s,o=s-t,a=300*1e3;return{isExpired:l<0,isExpiringSoon:l>0&&l<a,expiresAt:r,timeUntilExpiry:l>0?l:void 0,timeSinceExpiry:l<0?o:void 0}}function he(t){const s=Math.floor(t/1e3),r=Math.floor(s/60),l=Math.floor(r/60),o=Math.floor(l/24);return o>0?o===1?"1 day":`${o} days`:l>0?l===1?"1 hour":`${l} hours`:r>0?r===1?"1 minute":`${r} minutes`:s===1?"1 second":`${s} seconds`}function Yt(t){return t.isExpired&&t.timeSinceExpiry?`Expired ${he(t.timeSinceExpiry)} ago`:t.timeUntilExpiry?t.isExpiringSoon?`Expires in ${he(t.timeUntilExpiry)}`:`Expires in ${he(t.timeUntilExpiry)}`:"Token does not expire"}function Xt({identity:t,providerConfig:s,showExpirationDetails:r=!0,allowReconnect:l=!0,onConnect:o,onDisconnect:a,onError:d}){const{connect:c,disconnect:h,configureProvider:p,isAuthorizing:S}=ke(),u=t.provider,b=Ue[u]||Ue.custom,m=z.useMemo(()=>Jt(t.token?.expiresAt),[t.token?.expiresAt]);te.useEffect(()=>{if(s?.clientId){const y=u==="github"?ye:u==="google"?je:u==="kaggle"?Se:void 0;if(y){const f=s.config?.redirectUri||(typeof window<"u"?`${window.location.origin}${window.location.pathname}`:"");p({...y,...s.config,provider:u,clientId:s.clientId,redirectUri:f})}}},[s,u,p]);const R=z.useCallback(async()=>{try{const y=s?.scopes||Kt[u];await c(u,y)}catch(y){d?.(y instanceof Error?y:new Error(String(y)))}},[u,s?.scopes,c,d]),P=z.useCallback(async()=>{try{await h(u),a?.(u)}catch(y){d?.(y instanceof Error?y:new Error(String(y)))}},[u,h,a,d]);return e.jsxs(n,{display:"flex",flexDirection:"column",gap:2,p:3,border:"1px solid",borderColor:m.isExpired?"danger.muted":m.isExpiringSoon?"attention.muted":"success.muted",borderRadius:2,backgroundColor:m.isExpired?"danger.subtle":m.isExpiringSoon?"attention.subtle":"success.subtle",children:[e.jsxs(n,{display:"flex",alignItems:"center",gap:2,children:[e.jsx(n,{width:32,height:32,borderRadius:2,display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:b.color,color:"white",children:e.jsx(b.icon,{size:16})}),e.jsxs(n,{flex:1,display:"flex",alignItems:"center",gap:2,children:[e.jsx(i,{sx:{fontWeight:"semibold",fontSize:1},children:b.name}),e.jsx(A,{size:"small",variant:"secondary",children:t.authType==="token"?"API Key":"OAuth"})]}),m.isExpired?e.jsx(A,{variant:"danger",size:"small",children:e.jsxs(n,{display:"inline-flex",alignItems:"center",gap:1,children:[e.jsx(st,{size:12})," Expired"]})}):m.isExpiringSoon?e.jsx(A,{variant:"attention",size:"small",children:e.jsxs(n,{display:"inline-flex",alignItems:"center",gap:1,children:[e.jsx(me,{size:12})," Expiring Soon"]})}):e.jsx(A,{variant:"success",size:"small",children:e.jsxs(n,{display:"inline-flex",alignItems:"center",gap:1,children:[e.jsx(Pe,{size:12})," Connected"]})})]}),e.jsxs(n,{display:"flex",alignItems:"center",gap:2,children:[t.userInfo?.avatarUrl&&e.jsx("a",{href:t.userInfo.profileUrl||(u==="github"?`https://github.com/${t.userInfo.username}`:void 0),target:"_blank",rel:"noopener noreferrer",style:{display:"block",lineHeight:0},children:e.jsx(kt,{src:t.userInfo.avatarUrl,size:32,alt:t.userInfo.name||t.userInfo.username||b.name,sx:{cursor:"pointer"}})}),e.jsxs(n,{flex:1,minWidth:0,children:[t.userInfo?.name&&e.jsx(i,{sx:{fontWeight:"semibold",fontSize:1,display:"block"},children:t.userInfo.name}),(t.userInfo?.username||t.userInfo?.email)&&e.jsx("a",{href:t.userInfo.profileUrl||(u==="github"?`https://github.com/${t.userInfo.username}`:void 0),target:"_blank",rel:"noopener noreferrer",style:{textDecoration:"none"},children:e.jsx(i,{sx:{fontSize:0,color:"fg.muted",display:"block",":hover":{textDecoration:"underline"}},children:t.userInfo.username?`@${t.userInfo.username}`:t.userInfo.email})})]})]}),r&&e.jsxs(n,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(me,{size:12}),e.jsx(i,{sx:{fontSize:0,color:m.isExpired?"danger.fg":m.isExpiringSoon?"attention.fg":"fg.muted"},children:Yt(m)})]}),t.scopes&&t.scopes.length>0&&e.jsx(n,{display:"flex",flexWrap:"wrap",gap:1,children:t.scopes.map(y=>e.jsx(A,{size:"small",variant:"secondary",children:y},y))}),e.jsxs(n,{display:"flex",gap:2,mt:1,children:[m.isExpired&&l&&s?.clientId&&e.jsx(ot,{text:"Reconnect to refresh token",children:e.jsx(L,{variant:"primary",size:"small",leadingVisual:it,onClick:R,disabled:S,children:S?"Connecting...":"Reconnect"})}),e.jsxs(L,{variant:m.isExpired?"invisible":"danger",size:"small",leadingVisual:We,onClick:P,disabled:S,children:["Disconnect from ",b.name]})]})]})}function Qt({providers:t,title:s="Connected Accounts",showHeader:r=!0,showDescription:l=!0,description:o="Connected identities for this agent. Agents can use these to access external services on your behalf.",showExpirationDetails:a=!0,allowReconnect:d=!0,onConnect:c,onDisconnect:h,onError:p}){const{identities:S,error:u}=ke(),b=z.useMemo(()=>{if(t){const f=Object.keys(t);return S.filter(j=>f.includes(j.provider)||j.authType==="token"&&j.isConnected)}return S},[S,t]),m=z.useMemo(()=>new Set(S.map(f=>f.provider)),[S]),R=z.useMemo(()=>{if(!t)return{};const f=Object.keys(t),j={};for(const E of f)m.has(E)||(j[E]=t[E]);return j},[t,m]),P=Object.keys(R).length>0,y=z.useCallback(f=>j=>{p?.(f,j)},[p]);return b.length===0&&!t?null:e.jsxs(n,{children:[r&&e.jsxs(n,{display:"flex",alignItems:"center",gap:2,mb:2,children:[e.jsx(H,{size:16}),e.jsx(i,{sx:{fontSize:1,fontWeight:"semibold",color:"fg.muted"},children:s})]}),e.jsxs(n,{p:3,bg:"canvas.subtle",borderRadius:2,border:"1px solid",borderColor:"border.default",children:[l&&e.jsx(i,{sx:{fontSize:0,color:"fg.muted",display:"block",mb:b.length>0?3:0},children:o}),u&&e.jsx(nt,{variant:"danger",sx:{mb:3},children:u instanceof Error?u.message:String(u)}),b.length>0?e.jsx(n,{display:"flex",flexDirection:"column",gap:2,children:b.map(f=>e.jsx(Xt,{identity:f,providerConfig:t?.[f.provider],showExpirationDetails:a,allowReconnect:d,onConnect:c,onDisconnect:h,onError:y(f.provider)},f.provider))}):P?null:e.jsxs(n,{display:"flex",alignItems:"center",gap:2,color:"fg.muted",children:[e.jsx(de,{size:16}),e.jsx(i,{sx:{fontSize:1},children:"No connected accounts"})]}),P&&e.jsxs(n,{mt:b.length>0?3:0,children:[b.length>0&&e.jsx(i,{sx:{fontSize:0,color:"fg.muted",display:"block",mb:2},children:"Connect additional accounts:"}),e.jsx(n,{display:"flex",flexDirection:"column",gap:2,children:Object.keys(R).map(f=>{const j=R[f];return e.jsx(Gt,{provider:f,clientId:j.clientId,scopes:j.scopes,providerConfig:j.config,size:"medium",variant:"full",onConnect:c,onDisconnect:h,onError:y(f)},f)})})]})]})]})}const ge=t=>typeof t=="object"&&t!==null&&!Array.isArray(t),xe=t=>{if(t==null)return"null";if(typeof t=="number"||typeof t=="boolean")return String(t);const s=String(t);return s===""?"''":/^[a-zA-Z0-9._/-]+$/.test(s)?s:JSON.stringify(s)},be=(t,s=0)=>{const r=" ".repeat(s);if(Array.isArray(t))return t.length===0?"[]":t.map(l=>ge(l)||Array.isArray(l)?`${r}-
|
|
3
3
|
${be(l,s+1)}`:`${r}- ${xe(l)}`).join(`
|
|
4
4
|
`);if(ge(t)){const l=Object.entries(t).filter(([,o])=>o!==void 0);return l.length===0?"{}":l.map(([o,a])=>ge(a)||Array.isArray(a)?`${r}${o}:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,Q as l,j as s,D as o,a as m}from"../datalayer-app-main.js";import{AgentDetails as p}from"./AgentDetails-
|
|
1
|
+
import{r as n,Q as l,j as s,D as o,a as m}from"../datalayer-app-main.js";import{AgentDetails as p}from"./AgentDetails-Xvq2IvHg.js";import"./ArrowLeftIcon-Y3PTljcl.js";import"./UnlinkIcon-DuVqPyB-.js";import"./index-BTnG8qrO.js";import"./index-BJhxZF_K.js";import"./LinkIcon-DUI0jw25.js";import"./Avatar-9MpXENSs.js";function B({about:e,name:r,onClose:t}){const a=n.useMemo(()=>new l,[]),i=!!(e.agentId&&e.apiBase);return s.jsx(o,{title:`${e.name??r} · Agent Details`,onClose:t,width:"xlarge",height:"large",children:s.jsx("div",{"data-assistant-agent-details":"",children:s.jsx(m,{client:a,children:s.jsx(p,{name:e.name??r,protocol:e.protocol??(i?"agent-runtimes":"browser"),url:e.url??"",messageCount:0,agentId:e.agentId,apiBase:e.apiBase,onBack:t,showBackHeader:!1,showUsage:i,padded:!1,runtime:i,summary:{spec:e.spec,model:e.model,where:e.where,description:e.description,skills:e.skills}})})})})}export{B as AgentDetailsDialog,B as default};
|
package/dist-embed/chunks/{CellSidebarExtension-BBXRIRgA.js → CellSidebarExtension-B-73cmcQ.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as _,v as Ue,j as u,iN as Pt,I as q,e4 as Ge,cm as pe,b7 as ge,c as J,ez as Tt,et as qe,eK as Dt,iO as jt,iP as At,iQ as Je,iR as Ye,c1 as W,iS as It,iT as Nt,iU as Lt,bx as De,iV as ct,iW as ht,iX as Rt,iY as fe,ar as Ot,by as ut,iZ as ft,i_ as Ft,i$ as Xe,J as A,j0 as Ze,j1 as me,j2 as Bt,j3 as Wt,j4 as Vt,ak as _e,j5 as Ie,j6 as Qe,ci as ke,ch as ee,aW as $t,dK as Gt,b_ as z,iJ as Ht,ae as zt,c6 as Kt,ag as Z,cy as Ut,cZ as qt,hr as Fe,hp as mt,j7 as xe,j8 as de,j9 as Jt,am as Yt,ah as Xt,iH as Zt,ja as pt,hc as H,jb as Qt,jc as R,jd as en,cS as tn,je as gt,jf as nn,jg as sn,jh as on,o as ne,B as ue,cG as rn,dv as et,_ as an,aa as ln,dz as tt,dA as ce,dB as dn,cb as cn,l as hn,ji as un,jj as _t,eT as fn,jk as ae,b6 as D,C as le,co as nt,bi as vt,d6 as mn,ct as pn,bf as Se,i as gn,P as _n,an as vn,au as yn}from"../datalayer-app-main.js";import{b as Cn,c as bn,f as he,P as Ne,d as wn,W as kn,r as xn,g as Sn,h as Mn,i as En,C as Pn,a as Tn}from"./index-DSN70XMH.js";import{c as Dn,N as Be}from"./NotebookSkeleton-CI7ovjNW.js";import{H as jn}from"./hoverbox-CStlKQWE.js";import{R as yt,L as An}from"./index-a9o1fYab.js";import{a as In,W as st}from"./renderer-Au1S-H5k.js";import{C as Me,S as Ee}from"./SquareIcon-e3ygcjpv.js";function Nn(...r){return _.useCallback(e=>{for(const t of r)typeof t=="function"?t(e):t&&(t.current=e)},r)}var Q={Banner:"prc-Banner-Banner-IR8eJ",BannerContainer:"prc-Banner-BannerContainer-lbx3d",BannerContent:"prc-Banner-BannerContent-zTITK",BannerActions:"prc-Banner-BannerActions-XCfHL",BannerTitle:"prc-Banner-BannerTitle-TcuJl",BannerIcon:"prc-Banner-BannerIcon-WuOyf",BannerDismiss:"prc-Banner-BannerDismiss-uBZVm",BannerActionsContainer:"prc-Banner-BannerActionsContainer-ukGMH"};const Ln={critical:u.jsx(jt,{}),info:u.jsx(qe,{}),success:u.jsx(Dt,{}),upsell:u.jsx(qe,{}),warning:u.jsx(Tt,{})},Rn={critical:"Critical",info:"Information",success:"Success",upsell:"Recommendation",warning:"Warning"},On=Ue.forwardRef(function({"aria-label":e,children:t,className:n,description:s,hideTitle:o,icon:i,onDismiss:a,primaryAction:l,secondaryAction:d,title:c,variant:h="info",...f},m){const C=!!a,x=l||d,I=Ue.useRef(null),L=Nn(m,I),g=h==="info"||h==="upsell";return u.jsxs("section",{...f,"aria-label":e??Rn[h],className:pe(n,Q.Banner),"data-dismissible":a?"":void 0,"data-title-hidden":o?"":void 0,"data-variant":h,tabIndex:-1,ref:L,children:[u.jsx("div",{className:Q.BannerIcon,children:i&&g?i:Ln[h]}),u.jsxs("div",{className:Q.BannerContainer,children:[u.jsxs("div",{className:Q.BannerContent,children:[c?o?u.jsx(Pt,{children:u.jsx(We,{children:c})}):u.jsx(We,{children:c}):null,s?u.jsx(Ct,{children:s}):null,t]}),x?u.jsx(Fn,{primaryAction:l,secondaryAction:d}):null]}),C?u.jsx(q,{"aria-label":"Dismiss banner",onClick:a,className:Q.BannerDismiss,icon:Ge,variant:"invisible"}):null]})});function We(r){const e=ge.c(12);let t,n,s,o;e[0]!==r?({as:o,className:n,children:t,...s}=r,e[0]=r,e[1]=t,e[2]=n,e[3]=s,e[4]=o):(t=e[1],n=e[2],s=e[3],o=e[4]);const i=o===void 0?"h2":o;let a;e[5]!==n?(a=pe(n,Q.BannerTitle),e[5]=n,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==t||e[9]!==s||e[10]!==a?(l=u.jsx(i,{...s,className:a,"data-banner-title":"",children:t}),e[7]=i,e[8]=t,e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function Ct(r){const e=ge.c(10);let t,n,s;e[0]!==r?({children:t,className:n,...s}=r,e[0]=r,e[1]=t,e[2]=n,e[3]=s):(t=e[1],n=e[2],s=e[3]);let o;e[4]!==n?(o=pe("BannerDescription",n),e[4]=n,e[5]=o):o=e[5];let i;return e[6]!==t||e[7]!==s||e[8]!==o?(i=u.jsx("div",{...s,className:o,children:t}),e[6]=t,e[7]=s,e[8]=o,e[9]=i):i=e[9],i}function Fn(r){const e=ge.c(9),{primaryAction:t,secondaryAction:n}=r,s=n??null,o=t??null;let i;e[0]!==s||e[1]!==o?(i=u.jsxs("div",{className:Q.BannerActionsContainer,"data-primary-action":"trailing",children:[s,o]}),e[0]=s,e[1]=o,e[2]=i):i=e[2];const a=t??null,l=n??null;let d;e[3]!==a||e[4]!==l?(d=u.jsxs("div",{className:Q.BannerActionsContainer,"data-primary-action":"leading",children:[a,l]}),e[3]=a,e[4]=l,e[5]=d):d=e[5];let c;return e[6]!==i||e[7]!==d?(c=u.jsxs("div",{className:Q.BannerActions,children:[i,d]}),e[6]=i,e[7]=d,e[8]=c):c=e[8],c}const bt=_.forwardRef((r,e)=>{const t=ge.c(11);let n,s,o;t[0]!==r?({children:n,className:s,...o}=r,t[0]=r,t[1]=n,t[2]=s,t[3]=o):(n=t[1],s=t[2],o=t[3]);let i;t[4]!==s?(i=pe("BannerPrimaryAction",s),t[4]=s,t[5]=i):i=t[5];let a;return t[6]!==n||t[7]!==e||t[8]!==o||t[9]!==i?(a=u.jsx(J,{ref:e,className:i,variant:"default",...o,children:n}),t[6]=n,t[7]=e,t[8]=o,t[9]=i,t[10]=a):a=t[10],a});bt.displayName="BannerPrimaryAction";const wt=_.forwardRef((r,e)=>{const t=ge.c(11);let n,s,o;t[0]!==r?({children:n,className:s,...o}=r,t[0]=r,t[1]=n,t[2]=s,t[3]=o):(n=t[1],s=t[2],o=t[3]);let i;t[4]!==s?(i=pe("BannerPrimaryAction",s),t[4]=s,t[5]=i):i=t[5];let a;return t[6]!==n||t[7]!==e||t[8]!==o||t[9]!==i?(a=u.jsx(J,{ref:e,className:i,variant:"link",...o,children:n}),t[6]=n,t[7]=e,t[8]=o,t[9]=i,t[10]=a):a=t[10],a});wt.displayName="BannerSecondaryAction";const Bn=Object.assign(On,{Title:We,Description:Ct,PrimaryAction:bt,SecondaryAction:wt}),ve=Nt.define({combine(r){return r[r.length-1]}}),Wn=De.baseTheme({".jp-remote-cursor":{borderLeft:"1px solid black",marginLeft:"-1px"},".jp-remote-cursor.jp-mod-primary":{borderLeftWidth:"2px"},".jp-remote-selection":{opacity:.5},".cm-tooltip":{border:"none"},".cm-tooltip.jp-remote-userInfo":{color:"var(--fgColor-onEmphasis, #ffffff)",padding:"0px 2px"}});function He(r,e){const t=r?.username||r?.display_name||r?.name||String(e),{theme:n,colorMode:s}=Ot.getState(),o=s==="auto"?typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light":s;return Dn(t,n,o)}const je=Lt.define();class kt{style;marker;constructor(e,t){this.style=e,this.marker=t}draw(){const e=this.marker.draw();for(const[t,n]of Object.entries(this.style))e.style[t]=n;return e}eq(e){return this.marker.eq(e.marker)&&W.deepEqual(this.style,e.style)}update(e,t){for(const[n,s]of Object.entries(this.style))e.style[n]=s;return this.marker.update(e,t.marker)}}const Vn=ct({above:!0,markers(r){const{awareness:e,ytext:t}=r.state.facet(ve),n=t.doc,s=[];return e.getStates().forEach((o,i)=>{if(i===e.doc.clientID)return;const a=o.cursors;for(const l of a??[]){if(!l?.anchor||!l?.head)return;const d=fe(l.anchor,n),c=fe(l.head,n);if(d?.type!==t||c?.type!==t)return;const h=l.primary??!0?"jp-remote-cursor jp-mod-primary":"jp-remote-cursor",f=ut.cursor(c.index,c.index>d.index?-1:1);for(const m of ft.forRange(r,h,f))s.push(new kt({borderLeftColor:He(o.user,i)},m))}}),s},update(r,e){return!!r.transactions.find(t=>t.annotation(je))},class:"jp-remote-cursors"});function ot(r){const e=new Array,{awareness:t,ytext:n}=r.facet(ve),s=n.doc;for(const[o,i]of t.getStates())if(o!==t.doc.clientID)for(const a of i.cursors??[]){if(!a?.head)continue;const l=fe(a.head,s);l?.type===n&&e.push({pos:l.index,above:!0,create:()=>{const d=document.createElement("div");return d.classList.add("jp-remote-userInfo"),d.style.backgroundColor=He(i.user,o),d.textContent=i.user?.display_name??"Anonymous",{dom:d}}})}return e}const $n=ht.define({create:ot,update(r,e){return e.annotation(je)?ot(e.state):r},provide(r){return Rt.computeN([r],e=>e.field(r))}}),Gn=ct({above:!1,markers(r){const{awareness:e,ytext:t}=r.state.facet(ve),n=t.doc,s=[];return e.getStates().forEach((o,i)=>{if(i===e.doc.clientID)return;const a=o.cursors;for(const l of a??[]){if((l.empty??!0)||!l?.anchor||!l?.head)return;const d=fe(l.anchor,n),c=fe(l.head,n);if(d?.type!==t||c?.type!==t)return;const h="jp-remote-selection";for(const f of ft.forRange(r,h,ut.range(d.index,c.index)))s.push(new kt({backgroundColor:He(o.user,i)},f))}}),s},update(r,e){return!!r.transactions.find(t=>t.annotation(je))},class:"jp-remote-selections"}),Hn=At.fromClass(class{editorAwareness;_listener;constructor(r){this.editorAwareness=r.state.facet(ve),this._listener=({added:e,updated:t,removed:n})=>{e.concat(t).concat(n).findIndex(o=>o!==this.editorAwareness.awareness.doc.clientID)>=0&&r.dispatch({annotations:[je.of([])]})},this.editorAwareness.awareness.on("change",this._listener)}destroy(){this.editorAwareness.awareness.off("change",this._listener)}update(r){if(!r.docChanged&&!r.selectionSet)return;const{awareness:e,ytext:t}=this.editorAwareness,n=e.getLocalState();if(n){const s=r.view.hasFocus&&r.view.dom.ownerDocument.hasFocus(),o=r.state.selection,i=new Array;if(s&&o){for(const a of o.ranges){const l=a===o.main,d=Je(t,a.anchor),c=Je(t,a.head);i.push({anchor:d,head:c,primary:l,empty:a.empty})}if(!n.cursors||i.length>0){const a=n.cursors?.map(l=>({...l,anchor:l?.anchor?Ye(l.anchor):null,head:l?.head?Ye(l.head):null}));W.deepEqual(i,a)||e.setLocalStateField("cursors",i)}}}}},{provide:()=>[Wn,Vn,Gn,$n,It({position:"absolute",parent:document.body})]});function zn(r){return[ve.of(r),Hn]}class Ae extends Ft{constructor(e={}){var t;super(),this.version="2.0.0",this.ymeta=this.ydoc.getMap("meta"),this._onMetaChanged=n=>{const s=n.find(i=>i.target===this.ymeta.get("metadata"));if(s){const i=s.changes.keys,a=this.ymeta.get("metadata");s.changes.keys.forEach((l,d)=>{switch(l.action){case"add":this._metadataChanged.emit({key:d,type:"add",newValue:a.get(d)});break;case"delete":this._metadataChanged.emit({key:d,type:"remove",oldValue:l.oldValue});break;case"update":{const c=a.get(d),h=l.oldValue;let f=!0;typeof h=="object"&&typeof c=="object"?f=W.deepEqual(h,c):f=h===c,f||this._metadataChanged.emit({key:d,type:"change",oldValue:h,newValue:c})}break}}),this._changed.emit({metadataChange:i})}const o=n.find(i=>i.target===this.ymeta);if(o){if(o.keysChanged.has("metadata")){const i=o.changes.keys.get("metadata");if(i?.action==="add"&&!i.oldValue){const a=new Map;for(const l of Object.keys(this.metadata))a.set(l,{action:"add",oldValue:void 0}),this._metadataChanged.emit({key:l,type:"add",newValue:this.getMetadata(l)});this._changed.emit({metadataChange:a})}}if(o.keysChanged.has("nbformat")){const i=o.changes.keys.get("nbformat"),a={key:"nbformat",oldValue:i?.oldValue?i.oldValue:void 0,newValue:this.nbformat};this._changed.emit({nbformatChanged:a})}if(o.keysChanged.has("nbformat_minor")){const i=o.changes.keys.get("nbformat_minor"),a={key:"nbformat_minor",oldValue:i?.oldValue?i.oldValue:void 0,newValue:this.nbformat_minor};this._changed.emit({nbformatChanged:a})}}},this._onYCellsChanged=n=>{n.changes.added.forEach(i=>{const a=i.content.type;if(!this._ycellMapping.has(a)){const l=Xe(a,{notebook:this});this._ycellMapping.set(a,l)}}),n.changes.deleted.forEach(i=>{const a=i.content.type,l=this._ycellMapping.get(a);l&&(l.dispose(),this._ycellMapping.delete(a))});let s=0;const o=[];n.changes.delta.forEach(i=>{if(i.insert!=null){const a=i.insert.map(l=>this._ycellMapping.get(l));o.push({insert:a}),this.cells.splice(s,0,...a),s+=i.insert.length}else i.delete!=null?(o.push(i),this.cells.splice(s,i.delete)):i.retain!=null&&(o.push(i),s+=i.retain)}),this._changed.emit({cellsChange:o})},this._metadataChanged=new A(this),this._ycells=this.ydoc.getArray("cells"),this._ycellMapping=new WeakMap,this._disableDocumentWideUndoRedo=(t=e.disableDocumentWideUndoRedo)!==null&&t!==void 0?t:!1,this.cells=this._ycells.toArray().map(n=>(this._ycellMapping.has(n)||this._ycellMapping.set(n,Xe(n,{notebook:this})),this._ycellMapping.get(n))),this.undoManager.addToScope(this._ycells),this._ycells.observe(this._onYCellsChanged),this.ymeta.observeDeep(this._onMetaChanged)}static create(e={}){var t,n,s,o,i,a,l,d,c;const h=new Ae({disableDocumentWideUndoRedo:(t=e.disableDocumentWideUndoRedo)!==null&&t!==void 0?t:!1}),f={cells:(s=(n=e.data)===null||n===void 0?void 0:n.cells)!==null&&s!==void 0?s:[],nbformat:(i=(o=e.data)===null||o===void 0?void 0:o.nbformat)!==null&&i!==void 0?i:4,nbformat_minor:(l=(a=e.data)===null||a===void 0?void 0:a.nbformat_minor)!==null&&l!==void 0?l:5,metadata:(c=(d=e.data)===null||d===void 0?void 0:d.metadata)!==null&&c!==void 0?c:{}};return h.setSource(f),h}get disableDocumentWideUndoRedo(){return this._disableDocumentWideUndoRedo}get metadata(){return this.getMetadata()}set metadata(e){this.setMetadata(e)}get metadataChanged(){return this._metadataChanged}get nbformat(){return this.ymeta.get("nbformat")}set nbformat(e){this.transact(()=>{this.ymeta.set("nbformat",e)},!1)}get nbformat_minor(){return this.ymeta.get("nbformat_minor")}set nbformat_minor(e){this.transact(()=>{this.ymeta.set("nbformat_minor",e)},!1)}dispose(){this.isDisposed||(this._ycells.unobserve(this._onYCellsChanged),this.ymeta.unobserveDeep(this._onMetaChanged),super.dispose())}getCell(e){return this.cells[e]}addCell(e){return this.insertCell(this._ycells.length,e)}insertCell(e,t){return this.insertCells(e,[t])[0]}insertCells(e,t){const n=t.map(s=>{const o=Ze(s,this);return this._ycellMapping.set(o.ymodel,o),o});return this.transact(()=>{this._ycells.insert(e,n.map(s=>s.ymodel))}),this.dirty=!0,n}moveCell(e,t){this.moveCells(e,t)}moveCells(e,t,n=1){const s=new Array(n).fill(!0).map((o,i)=>this.getCell(e+i).toJSON());this.transact(()=>{this._ycells.delete(e,n),this._ycells.insert(e>t?t:t-n+1,s.map(o=>Ze(o,this).ymodel))}),this.dirty=!0}deleteCell(e){this.deleteCellRange(e,e+1)}deleteCellRange(e,t){this.transact(()=>{this._ycells.delete(e,t-e)}),this.dirty=!0}deleteMetadata(e){if(typeof this.getMetadata(e)>"u")return;const t=this.metadata;delete t[e],this.setMetadata(t)}getMetadata(e){const t=this.ymeta.get("metadata");if(t!==void 0)if(typeof e=="string"){const n=t.get(e);return typeof n>"u"?void 0:W.deepCopy(n)}else return W.deepCopy(t.toJSON())}setMetadata(e,t){var n;if(typeof e=="string"){if(typeof t>"u")throw new TypeError(`Metadata value for ${e} cannot be 'undefined'; use deleteMetadata.`);if(W.deepEqual((n=this.getMetadata(e))!==null&&n!==void 0?n:null,t))return;const s={};s[e]=t,this.updateMetadata(s)}else if(!this.metadata||!W.deepEqual(this.metadata,e)){const s=W.deepCopy(e),o=this.ymeta.get("metadata");if(o===void 0)return;this.transact(()=>{o.clear();for(const[i,a]of Object.entries(s))o.set(i,a)}),this.dirty=!0}}updateMetadata(e){const t=W.deepCopy(e),n=this.ymeta.get("metadata");n!==void 0&&(this.transact(()=>{for(const[s,o]of Object.entries(t))n.set(s,o)}),this.dirty=!0)}getSource(){return this.toJSON()}setSource(e){this.fromJSON(e),this.dirty=!1}fromJSON(e){this.transact(()=>{this.nbformat=e.nbformat,this.nbformat_minor=e.nbformat_minor;const t=e.metadata;if(t.orig_nbformat!==void 0&&delete t.orig_nbformat,this.metadata)this.metadata=t;else{const o=new me;for(const[i,a]of Object.entries(t))o.set(i,a);this.ymeta.set("metadata",o)}const n=e.nbformat===4&&e.nbformat_minor>=5,s=e.cells.map(o=>(n||delete o.id,o));this.insertCells(this.cells.length,s),this.deleteCellRange(0,this.cells.length)})}toJSON(){const e=this.nbformat===4&&this.nbformat_minor<=4;return{metadata:this.metadata,nbformat_minor:this.nbformat_minor,nbformat:this.nbformat,cells:this.cells.map(t=>{const n=t.toJSON();return e&&delete n.id,n})}}}class Kn{constructor(e){this.model=e,this._cellMap=new WeakMap,this._changed=new A(this),this._isDisposed=!1,this._insertCells(0,this.model.cells),this.model.changed.connect(this._onSharedModelChanged,this)}get changed(){return this._changed}get isDisposed(){return this._isDisposed}get length(){return this.model.cells.length}*[Symbol.iterator](){for(const e of this.model.cells)yield this._cellMap.get(e)}dispose(){var e;if(!this._isDisposed){this._isDisposed=!0;for(const t of this.model.cells)(e=this._cellMap.get(t))===null||e===void 0||e.dispose();A.clearData(this)}}get(e){return this._cellMap.get(this.model.cells[e])}_insertCells(e,t){return t.forEach(n=>{let s;switch(n.cell_type){case"code":{s=new Vt({sharedModel:n});break}case"markdown":{s=new Wt({sharedModel:n});break}default:s=new Bt({sharedModel:n})}this._cellMap.set(n,s),n.disposed.connect(()=>{s.dispose(),this._cellMap.delete(n)})}),this.length}_onSharedModelChanged(e,t){var n;let s=0;const o=new Array;(n=t.cellsChange)===null||n===void 0||n.forEach(i=>{i.insert!=null?(this._insertCells(s,i.insert),o.push({type:"add",newIndex:s,newValues:i.insert.map(a=>this._cellMap.get(a)),oldIndex:-2,oldValues:[]}),s+=i.insert.length):i.delete!=null?o.push({type:"remove",newIndex:-1,newValues:[],oldIndex:s,oldValues:new Array(i.delete).fill(void 0)}):i.retain!=null&&(s+=i.retain)}),o.forEach(i=>this._changed.emit(i))}}class Un{constructor(e){this._requestBatchSize=10,this._cursor=0,this._hasSession=!1,this._history=[],this._placeholder="",this._kernelSession="",this._setByHistory=!1,this._isDisposed=!1,this._editor=null,this._filtered=[],this._kernel=null,this._sessionContext=e.sessionContext,this._trans=(e.translator||_e).load("jupyterlab"),this._handleKernel().then(()=>{this._sessionContext.kernelChanged.connect(this._handleKernel,this)}),this._toRequest=this._requestBatchSize}get editor(){return this._editor}set editor(e){if(this._editor===e)return;const t=this._editor;t&&t.model.sharedModel.changed.disconnect(this.onTextChange,this),this._editor=e,e&&e.model.sharedModel.changed.connect(this.onTextChange,this)}get placeholder(){return this._placeholder}get kernelSession(){return this._kernelSession}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed=!0,this._history.length=0,A.clearData(this)}async checkSession(e){var t;this._hasSession||(await this._retrieveHistory(),this._hasSession=!0,this.editor=e.editor,this._placeholder=((t=this._editor)===null||t===void 0?void 0:t.model.sharedModel.getSource())||"",this.setFilter(this._placeholder),this._cursor=this._filtered.length-1)}async back(e){return await this.checkSession(e),--this._cursor,this._cursor<0&&await this.fetchBatch(),this._cursor=Math.max(0,this._cursor),this._filtered[this._cursor]}async forward(e){return await this.checkSession(e),++this._cursor,this._cursor=Math.min(this._filtered.length-1,this._cursor),this._filtered[this._cursor]}updateEditor(e,t){var n,s;if(e){const o=(n=e.editor)===null||n===void 0?void 0:n.model,i=o?.sharedModel.getSource();if(this.isDisposed||!t||i===t)return;this._setByHistory=!0,o?.sharedModel.setSource(t);let a=0;a=t.indexOf(`
|
|
1
|
+
import{r as _,v as Ue,j as u,iN as Pt,I as q,e4 as Ge,cm as pe,b7 as ge,c as J,ez as Tt,et as qe,eK as Dt,iO as jt,iP as At,iQ as Je,iR as Ye,c1 as W,iS as It,iT as Nt,iU as Lt,bx as De,iV as ct,iW as ht,iX as Rt,iY as fe,ar as Ot,by as ut,iZ as ft,i_ as Ft,i$ as Xe,J as A,j0 as Ze,j1 as me,j2 as Bt,j3 as Wt,j4 as Vt,ak as _e,j5 as Ie,j6 as Qe,ci as ke,ch as ee,aW as $t,dK as Gt,b_ as z,iJ as Ht,ae as zt,c6 as Kt,ag as Z,cy as Ut,cZ as qt,hr as Fe,hp as mt,j7 as xe,j8 as de,j9 as Jt,am as Yt,ah as Xt,iH as Zt,ja as pt,hc as H,jb as Qt,jc as R,jd as en,cS as tn,je as gt,jf as nn,jg as sn,jh as on,o as ne,B as ue,cG as rn,dv as et,_ as an,aa as ln,dz as tt,dA as ce,dB as dn,cb as cn,l as hn,ji as un,jj as _t,f5 as fn,jk as ae,b6 as D,C as le,co as nt,bi as vt,d6 as mn,ct as pn,bf as Se,i as gn,P as _n,an as vn,au as yn}from"../datalayer-app-main.js";import{b as Cn,c as bn,f as he,P as Ne,d as wn,W as kn,r as xn,g as Sn,h as Mn,i as En,C as Pn,a as Tn}from"./index-DSN70XMH.js";import{c as Dn,N as Be}from"./NotebookSkeleton-CI7ovjNW.js";import{H as jn}from"./hoverbox-CStlKQWE.js";import{R as yt,L as An}from"./index-S4sn4R3i.js";import{a as In,W as st}from"./renderer-DKKfWkWv.js";import{C as Me,S as Ee}from"./SquareIcon-e3ygcjpv.js";function Nn(...r){return _.useCallback(e=>{for(const t of r)typeof t=="function"?t(e):t&&(t.current=e)},r)}var Q={Banner:"prc-Banner-Banner-IR8eJ",BannerContainer:"prc-Banner-BannerContainer-lbx3d",BannerContent:"prc-Banner-BannerContent-zTITK",BannerActions:"prc-Banner-BannerActions-XCfHL",BannerTitle:"prc-Banner-BannerTitle-TcuJl",BannerIcon:"prc-Banner-BannerIcon-WuOyf",BannerDismiss:"prc-Banner-BannerDismiss-uBZVm",BannerActionsContainer:"prc-Banner-BannerActionsContainer-ukGMH"};const Ln={critical:u.jsx(jt,{}),info:u.jsx(qe,{}),success:u.jsx(Dt,{}),upsell:u.jsx(qe,{}),warning:u.jsx(Tt,{})},Rn={critical:"Critical",info:"Information",success:"Success",upsell:"Recommendation",warning:"Warning"},On=Ue.forwardRef(function({"aria-label":e,children:t,className:n,description:s,hideTitle:o,icon:i,onDismiss:a,primaryAction:l,secondaryAction:d,title:c,variant:h="info",...f},m){const C=!!a,x=l||d,I=Ue.useRef(null),L=Nn(m,I),g=h==="info"||h==="upsell";return u.jsxs("section",{...f,"aria-label":e??Rn[h],className:pe(n,Q.Banner),"data-dismissible":a?"":void 0,"data-title-hidden":o?"":void 0,"data-variant":h,tabIndex:-1,ref:L,children:[u.jsx("div",{className:Q.BannerIcon,children:i&&g?i:Ln[h]}),u.jsxs("div",{className:Q.BannerContainer,children:[u.jsxs("div",{className:Q.BannerContent,children:[c?o?u.jsx(Pt,{children:u.jsx(We,{children:c})}):u.jsx(We,{children:c}):null,s?u.jsx(Ct,{children:s}):null,t]}),x?u.jsx(Fn,{primaryAction:l,secondaryAction:d}):null]}),C?u.jsx(q,{"aria-label":"Dismiss banner",onClick:a,className:Q.BannerDismiss,icon:Ge,variant:"invisible"}):null]})});function We(r){const e=ge.c(12);let t,n,s,o;e[0]!==r?({as:o,className:n,children:t,...s}=r,e[0]=r,e[1]=t,e[2]=n,e[3]=s,e[4]=o):(t=e[1],n=e[2],s=e[3],o=e[4]);const i=o===void 0?"h2":o;let a;e[5]!==n?(a=pe(n,Q.BannerTitle),e[5]=n,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==t||e[9]!==s||e[10]!==a?(l=u.jsx(i,{...s,className:a,"data-banner-title":"",children:t}),e[7]=i,e[8]=t,e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function Ct(r){const e=ge.c(10);let t,n,s;e[0]!==r?({children:t,className:n,...s}=r,e[0]=r,e[1]=t,e[2]=n,e[3]=s):(t=e[1],n=e[2],s=e[3]);let o;e[4]!==n?(o=pe("BannerDescription",n),e[4]=n,e[5]=o):o=e[5];let i;return e[6]!==t||e[7]!==s||e[8]!==o?(i=u.jsx("div",{...s,className:o,children:t}),e[6]=t,e[7]=s,e[8]=o,e[9]=i):i=e[9],i}function Fn(r){const e=ge.c(9),{primaryAction:t,secondaryAction:n}=r,s=n??null,o=t??null;let i;e[0]!==s||e[1]!==o?(i=u.jsxs("div",{className:Q.BannerActionsContainer,"data-primary-action":"trailing",children:[s,o]}),e[0]=s,e[1]=o,e[2]=i):i=e[2];const a=t??null,l=n??null;let d;e[3]!==a||e[4]!==l?(d=u.jsxs("div",{className:Q.BannerActionsContainer,"data-primary-action":"leading",children:[a,l]}),e[3]=a,e[4]=l,e[5]=d):d=e[5];let c;return e[6]!==i||e[7]!==d?(c=u.jsxs("div",{className:Q.BannerActions,children:[i,d]}),e[6]=i,e[7]=d,e[8]=c):c=e[8],c}const bt=_.forwardRef((r,e)=>{const t=ge.c(11);let n,s,o;t[0]!==r?({children:n,className:s,...o}=r,t[0]=r,t[1]=n,t[2]=s,t[3]=o):(n=t[1],s=t[2],o=t[3]);let i;t[4]!==s?(i=pe("BannerPrimaryAction",s),t[4]=s,t[5]=i):i=t[5];let a;return t[6]!==n||t[7]!==e||t[8]!==o||t[9]!==i?(a=u.jsx(J,{ref:e,className:i,variant:"default",...o,children:n}),t[6]=n,t[7]=e,t[8]=o,t[9]=i,t[10]=a):a=t[10],a});bt.displayName="BannerPrimaryAction";const wt=_.forwardRef((r,e)=>{const t=ge.c(11);let n,s,o;t[0]!==r?({children:n,className:s,...o}=r,t[0]=r,t[1]=n,t[2]=s,t[3]=o):(n=t[1],s=t[2],o=t[3]);let i;t[4]!==s?(i=pe("BannerPrimaryAction",s),t[4]=s,t[5]=i):i=t[5];let a;return t[6]!==n||t[7]!==e||t[8]!==o||t[9]!==i?(a=u.jsx(J,{ref:e,className:i,variant:"link",...o,children:n}),t[6]=n,t[7]=e,t[8]=o,t[9]=i,t[10]=a):a=t[10],a});wt.displayName="BannerSecondaryAction";const Bn=Object.assign(On,{Title:We,Description:Ct,PrimaryAction:bt,SecondaryAction:wt}),ve=Nt.define({combine(r){return r[r.length-1]}}),Wn=De.baseTheme({".jp-remote-cursor":{borderLeft:"1px solid black",marginLeft:"-1px"},".jp-remote-cursor.jp-mod-primary":{borderLeftWidth:"2px"},".jp-remote-selection":{opacity:.5},".cm-tooltip":{border:"none"},".cm-tooltip.jp-remote-userInfo":{color:"var(--fgColor-onEmphasis, #ffffff)",padding:"0px 2px"}});function He(r,e){const t=r?.username||r?.display_name||r?.name||String(e),{theme:n,colorMode:s}=Ot.getState(),o=s==="auto"?typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light":s;return Dn(t,n,o)}const je=Lt.define();class kt{style;marker;constructor(e,t){this.style=e,this.marker=t}draw(){const e=this.marker.draw();for(const[t,n]of Object.entries(this.style))e.style[t]=n;return e}eq(e){return this.marker.eq(e.marker)&&W.deepEqual(this.style,e.style)}update(e,t){for(const[n,s]of Object.entries(this.style))e.style[n]=s;return this.marker.update(e,t.marker)}}const Vn=ct({above:!0,markers(r){const{awareness:e,ytext:t}=r.state.facet(ve),n=t.doc,s=[];return e.getStates().forEach((o,i)=>{if(i===e.doc.clientID)return;const a=o.cursors;for(const l of a??[]){if(!l?.anchor||!l?.head)return;const d=fe(l.anchor,n),c=fe(l.head,n);if(d?.type!==t||c?.type!==t)return;const h=l.primary??!0?"jp-remote-cursor jp-mod-primary":"jp-remote-cursor",f=ut.cursor(c.index,c.index>d.index?-1:1);for(const m of ft.forRange(r,h,f))s.push(new kt({borderLeftColor:He(o.user,i)},m))}}),s},update(r,e){return!!r.transactions.find(t=>t.annotation(je))},class:"jp-remote-cursors"});function ot(r){const e=new Array,{awareness:t,ytext:n}=r.facet(ve),s=n.doc;for(const[o,i]of t.getStates())if(o!==t.doc.clientID)for(const a of i.cursors??[]){if(!a?.head)continue;const l=fe(a.head,s);l?.type===n&&e.push({pos:l.index,above:!0,create:()=>{const d=document.createElement("div");return d.classList.add("jp-remote-userInfo"),d.style.backgroundColor=He(i.user,o),d.textContent=i.user?.display_name??"Anonymous",{dom:d}}})}return e}const $n=ht.define({create:ot,update(r,e){return e.annotation(je)?ot(e.state):r},provide(r){return Rt.computeN([r],e=>e.field(r))}}),Gn=ct({above:!1,markers(r){const{awareness:e,ytext:t}=r.state.facet(ve),n=t.doc,s=[];return e.getStates().forEach((o,i)=>{if(i===e.doc.clientID)return;const a=o.cursors;for(const l of a??[]){if((l.empty??!0)||!l?.anchor||!l?.head)return;const d=fe(l.anchor,n),c=fe(l.head,n);if(d?.type!==t||c?.type!==t)return;const h="jp-remote-selection";for(const f of ft.forRange(r,h,ut.range(d.index,c.index)))s.push(new kt({backgroundColor:He(o.user,i)},f))}}),s},update(r,e){return!!r.transactions.find(t=>t.annotation(je))},class:"jp-remote-selections"}),Hn=At.fromClass(class{editorAwareness;_listener;constructor(r){this.editorAwareness=r.state.facet(ve),this._listener=({added:e,updated:t,removed:n})=>{e.concat(t).concat(n).findIndex(o=>o!==this.editorAwareness.awareness.doc.clientID)>=0&&r.dispatch({annotations:[je.of([])]})},this.editorAwareness.awareness.on("change",this._listener)}destroy(){this.editorAwareness.awareness.off("change",this._listener)}update(r){if(!r.docChanged&&!r.selectionSet)return;const{awareness:e,ytext:t}=this.editorAwareness,n=e.getLocalState();if(n){const s=r.view.hasFocus&&r.view.dom.ownerDocument.hasFocus(),o=r.state.selection,i=new Array;if(s&&o){for(const a of o.ranges){const l=a===o.main,d=Je(t,a.anchor),c=Je(t,a.head);i.push({anchor:d,head:c,primary:l,empty:a.empty})}if(!n.cursors||i.length>0){const a=n.cursors?.map(l=>({...l,anchor:l?.anchor?Ye(l.anchor):null,head:l?.head?Ye(l.head):null}));W.deepEqual(i,a)||e.setLocalStateField("cursors",i)}}}}},{provide:()=>[Wn,Vn,Gn,$n,It({position:"absolute",parent:document.body})]});function zn(r){return[ve.of(r),Hn]}class Ae extends Ft{constructor(e={}){var t;super(),this.version="2.0.0",this.ymeta=this.ydoc.getMap("meta"),this._onMetaChanged=n=>{const s=n.find(i=>i.target===this.ymeta.get("metadata"));if(s){const i=s.changes.keys,a=this.ymeta.get("metadata");s.changes.keys.forEach((l,d)=>{switch(l.action){case"add":this._metadataChanged.emit({key:d,type:"add",newValue:a.get(d)});break;case"delete":this._metadataChanged.emit({key:d,type:"remove",oldValue:l.oldValue});break;case"update":{const c=a.get(d),h=l.oldValue;let f=!0;typeof h=="object"&&typeof c=="object"?f=W.deepEqual(h,c):f=h===c,f||this._metadataChanged.emit({key:d,type:"change",oldValue:h,newValue:c})}break}}),this._changed.emit({metadataChange:i})}const o=n.find(i=>i.target===this.ymeta);if(o){if(o.keysChanged.has("metadata")){const i=o.changes.keys.get("metadata");if(i?.action==="add"&&!i.oldValue){const a=new Map;for(const l of Object.keys(this.metadata))a.set(l,{action:"add",oldValue:void 0}),this._metadataChanged.emit({key:l,type:"add",newValue:this.getMetadata(l)});this._changed.emit({metadataChange:a})}}if(o.keysChanged.has("nbformat")){const i=o.changes.keys.get("nbformat"),a={key:"nbformat",oldValue:i?.oldValue?i.oldValue:void 0,newValue:this.nbformat};this._changed.emit({nbformatChanged:a})}if(o.keysChanged.has("nbformat_minor")){const i=o.changes.keys.get("nbformat_minor"),a={key:"nbformat_minor",oldValue:i?.oldValue?i.oldValue:void 0,newValue:this.nbformat_minor};this._changed.emit({nbformatChanged:a})}}},this._onYCellsChanged=n=>{n.changes.added.forEach(i=>{const a=i.content.type;if(!this._ycellMapping.has(a)){const l=Xe(a,{notebook:this});this._ycellMapping.set(a,l)}}),n.changes.deleted.forEach(i=>{const a=i.content.type,l=this._ycellMapping.get(a);l&&(l.dispose(),this._ycellMapping.delete(a))});let s=0;const o=[];n.changes.delta.forEach(i=>{if(i.insert!=null){const a=i.insert.map(l=>this._ycellMapping.get(l));o.push({insert:a}),this.cells.splice(s,0,...a),s+=i.insert.length}else i.delete!=null?(o.push(i),this.cells.splice(s,i.delete)):i.retain!=null&&(o.push(i),s+=i.retain)}),this._changed.emit({cellsChange:o})},this._metadataChanged=new A(this),this._ycells=this.ydoc.getArray("cells"),this._ycellMapping=new WeakMap,this._disableDocumentWideUndoRedo=(t=e.disableDocumentWideUndoRedo)!==null&&t!==void 0?t:!1,this.cells=this._ycells.toArray().map(n=>(this._ycellMapping.has(n)||this._ycellMapping.set(n,Xe(n,{notebook:this})),this._ycellMapping.get(n))),this.undoManager.addToScope(this._ycells),this._ycells.observe(this._onYCellsChanged),this.ymeta.observeDeep(this._onMetaChanged)}static create(e={}){var t,n,s,o,i,a,l,d,c;const h=new Ae({disableDocumentWideUndoRedo:(t=e.disableDocumentWideUndoRedo)!==null&&t!==void 0?t:!1}),f={cells:(s=(n=e.data)===null||n===void 0?void 0:n.cells)!==null&&s!==void 0?s:[],nbformat:(i=(o=e.data)===null||o===void 0?void 0:o.nbformat)!==null&&i!==void 0?i:4,nbformat_minor:(l=(a=e.data)===null||a===void 0?void 0:a.nbformat_minor)!==null&&l!==void 0?l:5,metadata:(c=(d=e.data)===null||d===void 0?void 0:d.metadata)!==null&&c!==void 0?c:{}};return h.setSource(f),h}get disableDocumentWideUndoRedo(){return this._disableDocumentWideUndoRedo}get metadata(){return this.getMetadata()}set metadata(e){this.setMetadata(e)}get metadataChanged(){return this._metadataChanged}get nbformat(){return this.ymeta.get("nbformat")}set nbformat(e){this.transact(()=>{this.ymeta.set("nbformat",e)},!1)}get nbformat_minor(){return this.ymeta.get("nbformat_minor")}set nbformat_minor(e){this.transact(()=>{this.ymeta.set("nbformat_minor",e)},!1)}dispose(){this.isDisposed||(this._ycells.unobserve(this._onYCellsChanged),this.ymeta.unobserveDeep(this._onMetaChanged),super.dispose())}getCell(e){return this.cells[e]}addCell(e){return this.insertCell(this._ycells.length,e)}insertCell(e,t){return this.insertCells(e,[t])[0]}insertCells(e,t){const n=t.map(s=>{const o=Ze(s,this);return this._ycellMapping.set(o.ymodel,o),o});return this.transact(()=>{this._ycells.insert(e,n.map(s=>s.ymodel))}),this.dirty=!0,n}moveCell(e,t){this.moveCells(e,t)}moveCells(e,t,n=1){const s=new Array(n).fill(!0).map((o,i)=>this.getCell(e+i).toJSON());this.transact(()=>{this._ycells.delete(e,n),this._ycells.insert(e>t?t:t-n+1,s.map(o=>Ze(o,this).ymodel))}),this.dirty=!0}deleteCell(e){this.deleteCellRange(e,e+1)}deleteCellRange(e,t){this.transact(()=>{this._ycells.delete(e,t-e)}),this.dirty=!0}deleteMetadata(e){if(typeof this.getMetadata(e)>"u")return;const t=this.metadata;delete t[e],this.setMetadata(t)}getMetadata(e){const t=this.ymeta.get("metadata");if(t!==void 0)if(typeof e=="string"){const n=t.get(e);return typeof n>"u"?void 0:W.deepCopy(n)}else return W.deepCopy(t.toJSON())}setMetadata(e,t){var n;if(typeof e=="string"){if(typeof t>"u")throw new TypeError(`Metadata value for ${e} cannot be 'undefined'; use deleteMetadata.`);if(W.deepEqual((n=this.getMetadata(e))!==null&&n!==void 0?n:null,t))return;const s={};s[e]=t,this.updateMetadata(s)}else if(!this.metadata||!W.deepEqual(this.metadata,e)){const s=W.deepCopy(e),o=this.ymeta.get("metadata");if(o===void 0)return;this.transact(()=>{o.clear();for(const[i,a]of Object.entries(s))o.set(i,a)}),this.dirty=!0}}updateMetadata(e){const t=W.deepCopy(e),n=this.ymeta.get("metadata");n!==void 0&&(this.transact(()=>{for(const[s,o]of Object.entries(t))n.set(s,o)}),this.dirty=!0)}getSource(){return this.toJSON()}setSource(e){this.fromJSON(e),this.dirty=!1}fromJSON(e){this.transact(()=>{this.nbformat=e.nbformat,this.nbformat_minor=e.nbformat_minor;const t=e.metadata;if(t.orig_nbformat!==void 0&&delete t.orig_nbformat,this.metadata)this.metadata=t;else{const o=new me;for(const[i,a]of Object.entries(t))o.set(i,a);this.ymeta.set("metadata",o)}const n=e.nbformat===4&&e.nbformat_minor>=5,s=e.cells.map(o=>(n||delete o.id,o));this.insertCells(this.cells.length,s),this.deleteCellRange(0,this.cells.length)})}toJSON(){const e=this.nbformat===4&&this.nbformat_minor<=4;return{metadata:this.metadata,nbformat_minor:this.nbformat_minor,nbformat:this.nbformat,cells:this.cells.map(t=>{const n=t.toJSON();return e&&delete n.id,n})}}}class Kn{constructor(e){this.model=e,this._cellMap=new WeakMap,this._changed=new A(this),this._isDisposed=!1,this._insertCells(0,this.model.cells),this.model.changed.connect(this._onSharedModelChanged,this)}get changed(){return this._changed}get isDisposed(){return this._isDisposed}get length(){return this.model.cells.length}*[Symbol.iterator](){for(const e of this.model.cells)yield this._cellMap.get(e)}dispose(){var e;if(!this._isDisposed){this._isDisposed=!0;for(const t of this.model.cells)(e=this._cellMap.get(t))===null||e===void 0||e.dispose();A.clearData(this)}}get(e){return this._cellMap.get(this.model.cells[e])}_insertCells(e,t){return t.forEach(n=>{let s;switch(n.cell_type){case"code":{s=new Vt({sharedModel:n});break}case"markdown":{s=new Wt({sharedModel:n});break}default:s=new Bt({sharedModel:n})}this._cellMap.set(n,s),n.disposed.connect(()=>{s.dispose(),this._cellMap.delete(n)})}),this.length}_onSharedModelChanged(e,t){var n;let s=0;const o=new Array;(n=t.cellsChange)===null||n===void 0||n.forEach(i=>{i.insert!=null?(this._insertCells(s,i.insert),o.push({type:"add",newIndex:s,newValues:i.insert.map(a=>this._cellMap.get(a)),oldIndex:-2,oldValues:[]}),s+=i.insert.length):i.delete!=null?o.push({type:"remove",newIndex:-1,newValues:[],oldIndex:s,oldValues:new Array(i.delete).fill(void 0)}):i.retain!=null&&(s+=i.retain)}),o.forEach(i=>this._changed.emit(i))}}class Un{constructor(e){this._requestBatchSize=10,this._cursor=0,this._hasSession=!1,this._history=[],this._placeholder="",this._kernelSession="",this._setByHistory=!1,this._isDisposed=!1,this._editor=null,this._filtered=[],this._kernel=null,this._sessionContext=e.sessionContext,this._trans=(e.translator||_e).load("jupyterlab"),this._handleKernel().then(()=>{this._sessionContext.kernelChanged.connect(this._handleKernel,this)}),this._toRequest=this._requestBatchSize}get editor(){return this._editor}set editor(e){if(this._editor===e)return;const t=this._editor;t&&t.model.sharedModel.changed.disconnect(this.onTextChange,this),this._editor=e,e&&e.model.sharedModel.changed.connect(this.onTextChange,this)}get placeholder(){return this._placeholder}get kernelSession(){return this._kernelSession}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed=!0,this._history.length=0,A.clearData(this)}async checkSession(e){var t;this._hasSession||(await this._retrieveHistory(),this._hasSession=!0,this.editor=e.editor,this._placeholder=((t=this._editor)===null||t===void 0?void 0:t.model.sharedModel.getSource())||"",this.setFilter(this._placeholder),this._cursor=this._filtered.length-1)}async back(e){return await this.checkSession(e),--this._cursor,this._cursor<0&&await this.fetchBatch(),this._cursor=Math.max(0,this._cursor),this._filtered[this._cursor]}async forward(e){return await this.checkSession(e),++this._cursor,this._cursor=Math.min(this._filtered.length-1,this._cursor),this._filtered[this._cursor]}updateEditor(e,t){var n,s;if(e){const o=(n=e.editor)===null||n===void 0?void 0:n.model,i=o?.sharedModel.getSource();if(this.isDisposed||!t||i===t)return;this._setByHistory=!0,o?.sharedModel.setSource(t);let a=0;a=t.indexOf(`
|
|
2
2
|
`),a<0&&(a=t.length),(s=e.editor)===null||s===void 0||s.setCursorPosition({line:0,column:a})}}reset(){this._hasSession=!1,this._placeholder="",this._toRequest=this._requestBatchSize}async fetchBatch(){this._toRequest+=this._requestBatchSize;let e=this._filtered.slice().reverse(),t=this._history.slice();await this._retrieveHistory().then(()=>{this.setFilter(this._placeholder);let n=0,s=this._filtered.slice().reverse();for(let o=0;o<e.length;o++){let i=e[o];for(let a=o+n;a<s.length&&i!==s[a];a++)n+=1}this._cursor=this._filtered.length-(e.length+1)-n}),this._cursor<0&&this._history.length>t.length&&await this.fetchBatch()}onHistory(e,t){this._history.length=0;let n=["","",""],s=["","",""],o="";if(e.content.status==="ok"){for(let i=0;i<e.content.history.length;i++)s=e.content.history[i],s!==n&&(o=e.content.history[i][0],this._history.push(n=s));this.kernelSession||s[2]==t?.model.sharedModel.getSource()&&(this._kernelSession=o)}}onTextChange(){if(this._setByHistory){this._setByHistory=!1;return}this.reset()}async _handleKernel(){var e;if(this._kernel=(e=this._sessionContext.session)===null||e===void 0?void 0:e.kernel,!this._kernel){this._history.length=0;return}await this._retrieveHistory().catch()}async _retrieveHistory(e){var t;return await((t=this._kernel)===null||t===void 0?void 0:t.requestHistory(qn(this._toRequest)).then(n=>{this.onHistory(n,e)}).catch(()=>{console.warn(this._trans.__("History was unable to be retrieved"))}))}setFilter(e=""){this._filtered.length=0;let t="",n="";for(let s=0;s<this._history.length;s++)n=this._history[s][2],n!==t&&e!==n&&this._filtered.push(t=n);this._filtered.push(e)}}function qn(r){return{output:!1,raw:!0,hist_access_type:"tail",n:r}}class Ve{constructor(e={}){var t,n;this.standaloneModel=!1,this._readOnly=!1,this._contentChanged=new A(this),this._stateChanged=new A(this),this._isDisposed=!1,this._metadataChanged=new A(this),this.standaloneModel=typeof e.sharedModel>"u",e.sharedModel?this.sharedModel=e.sharedModel:this.sharedModel=Ae.create({disableDocumentWideUndoRedo:(t=e.disableDocumentWideUndoRedo)!==null&&t!==void 0?t:!0,data:{nbformat:Qe,nbformat_minor:Ie,metadata:{kernelspec:{name:"",display_name:""},language_info:{name:(n=e.languagePreference)!==null&&n!==void 0?n:""}}}}),this._cells=new Kn(this.sharedModel),this._trans=(e.translator||_e).load("jupyterlab"),this._deletedCells=[],this._collaborationEnabled=!!e?.collaborationEnabled,this._cells.changed.connect(this._onCellsChanged,this),this.sharedModel.changed.connect(this._onStateChanged,this),this.sharedModel.metadataChanged.connect(this._onMetadataChanged,this)}get contentChanged(){return this._contentChanged}get metadataChanged(){return this._metadataChanged}get stateChanged(){return this._stateChanged}get cells(){return this._cells}get dirty(){return this.sharedModel.dirty}set dirty(e){const t=this.dirty;e!==t&&(this.sharedModel.dirty=e)}get readOnly(){return this._readOnly}set readOnly(e){if(e===this._readOnly)return;const t=this._readOnly;this._readOnly=e,this.triggerStateChange({name:"readOnly",oldValue:t,newValue:e})}get metadata(){return this.sharedModel.metadata}get nbformat(){return this.sharedModel.nbformat}get nbformatMinor(){return this.sharedModel.nbformat_minor}get defaultKernelName(){var e;const t=this.getMetadata("kernelspec");return(e=t?.name)!==null&&e!==void 0?e:""}get deletedCells(){return this._deletedCells}get defaultKernelLanguage(){var e;const t=this.getMetadata("language_info");return(e=t?.name)!==null&&e!==void 0?e:""}get collaborative(){return this._collaborationEnabled}dispose(){if(this.isDisposed)return;this._isDisposed=!0;const e=this.cells;this._cells=null,e.dispose(),this.standaloneModel&&this.sharedModel.dispose(),A.clearData(this)}deleteMetadata(e){return this.sharedModel.deleteMetadata(e)}getMetadata(e){return this.sharedModel.getMetadata(e)}setMetadata(e,t){typeof t>"u"?this.sharedModel.deleteMetadata(e):this.sharedModel.setMetadata(e,t)}toString(){return JSON.stringify(this.toJSON())}fromString(e){this.fromJSON(JSON.parse(e))}toJSON(){return this._ensureMetadata(),this.sharedModel.toJSON()}fromJSON(e){var t,n;const s=W.deepCopy(e),o=e.metadata.orig_nbformat;if(s.nbformat=Math.max(e.nbformat,Qe),(s.nbformat!==e.nbformat||s.nbformat_minor<Ie)&&(s.nbformat_minor=Ie),o!==void 0&&s.nbformat!==o){const i=s.nbformat>o;let a;i?a=this._trans.__(`This notebook has been converted from an older notebook format (v%1)
|
|
3
3
|
to the current notebook format (v%2).
|
|
4
4
|
The next time you save this notebook, the current notebook format (v%2) will be used.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{E as N,
|
|
1
|
+
import{E as N,e$ as xo,r as o,j as t,f0 as vo,f1 as So,b_ as Rn,B as p,H as bt,T as H,c as Y,cu as zt,eu as Dt,f2 as ce,co as xt,e as yo,f3 as Co,f4 as wo,e3 as ko,f5 as jo,aH as Io,dX as zn,dV as Eo,dY as Gt,f6 as To,f7 as Ro,f8 as Ao,f9 as Mo,fa as Po,fb as Uo,fc as $o,d3 as Fo,a_ as Lo,fd as Oo,fe as _o,ff as zo,fg as No,fh as Bo,fi as Vo,x as Nt,fj as Ho,fk as Wo,fl as Do,fm as Go,fn as Ko,fo as Yo,fp as qo,fq as Jo,fr as Qo,fs as Xo,ft as Zo,fu as es,fv as ts,fw as ns,fx as os,fy as ss,fz as as,fA as is,fB as rs,fC as ls,fD as tt,fE as cs,fF as ds,fG as us,fH as fs,fI as An,fJ as ps,fK as Le,fL as ms,fM as gs,a$ as vt,fN as hs,fO as bs,fP as Mn,fQ as xs,fR as vs,fS as Ss,fT as ys,eC as Cs,fU as Bt,fV as Ce,fW as ws,fX as ks,fY as js,fZ as Pn,f_ as Is,f$ as Un,g0 as Es,g1 as Ts,g2 as Rs,g3 as As,g4 as Ms,g5 as Ps,g6 as Us,g7 as $s,g8 as Fs,g9 as Ls,ga as St,gb as Os,gc as _s,gd as zs,I as Ns,ge as Bs,gf as Vs,gg as $n,gh as Hs,gi as Ws,gj as Ds,gk as Kt,gl as Gs,gm as Ks,ek as Vt,gn as Ys,go as qs}from"../datalayer-app-main.js";import{S as Js,E as Qs,a as Xs}from"./SignInIcon-4HkE48mS.js";import{F as Zs,a as ea,b as ta}from"./LinkedInGreyIcon-BoWXE-HS.js";function Nn(){const n=N(xo);return o.useMemo(()=>n.map(a=>a.value),[n])}const Ht={github:{name:"github",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/github/callback"},google:{name:"google",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/google/callback"},linkedin:{name:"linkedin",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/linkedin/callback"}},Fn=()=>{if(typeof document>"u")return"";const n=document.getElementById("datalayer-config-data");if(!n?.textContent)return"";try{const a=JSON.parse(n.textContent);return String(a?.iamUrl||"").replace(/\/$/,"")}catch{return""}},na=(n,a="Unable to start social sign-in.")=>{if(n instanceof Error&&n.message)return n.message;if(typeof n=="string"&&n.trim())return n;if(n&&typeof n=="object"&&"message"in n){const l=n.message;if(typeof l=="string"&&l.trim())return l}return a},oa=jo`
|
|
2
2
|
.signin-input-theme-scope input:-webkit-autofill,
|
|
3
3
|
.signin-input-theme-scope input:-webkit-autofill:hover,
|
|
4
4
|
.signin-input-theme-scope input:-webkit-autofill:focus,
|
|
@@ -25,8 +25,8 @@ import{E as N,eN as xo,r as o,j as t,eO as vo,eP as So,b_ as Rn,B as p,H as bt,T
|
|
|
25
25
|
background-color: var(--bgColor-default) !important;
|
|
26
26
|
opacity: 1 !important;
|
|
27
27
|
}
|
|
28
|
-
`,sa=({onSignIn:n,onApiKeySignIn:a,loginUrl:l,name:r,title:f="Datalayer OTEL",description:x="Sign in to access the observability dashboard.",icon:y,leadingIcon:I=t.jsx(ko,{size:24}),github:d=!1,google:we=!1,linkedin:q=!1,apiKey:nt=!1,signUp:O=!0,socialSignInNavigationTarget:ee,asDoc:v=!1,fillHeight:E=!0,hideHero:te=!1,calloutTitle:Le,calloutDescription:ot,passwordToggleLabel:de="Sign in with a password",signUpTitle:Yt="Don't have an account?",signUpDescription:J="Create a free Datalayer account with your email address.",signUpLabel:yt="Sign up with email",signUpHref:_e="https://datalayer.ai/signup",onSignUp:B,forgotPasswordHref:Q="/password",forgotPasswordLabel:ze="Forgot password?",showForgotPassword:Ct=!0,socialButtonMarginTop:h=3,actionButtonMaxWidth:X=320})=>{const ne=v&&!te,st=r??(v&&f==="Datalayer OTEL"?"Datalayer Sign In":f),wt=y??(v?t.jsx(Js,{size:24}):I),F=o.useMemo(()=>{if(l)return l;const c=On();return c?`${c}/api/iam/v1/login`:"/api/iam/v1/login"},[l]),[W,ke]=o.useState(""),[ue,kt]=o.useState(""),[at,jt]=o.useState(!1),[je,fe]=o.useState(!1),[w,pe]=o.useState(!1),[oe,it]=o.useState(!1),[Ne,Ie]=o.useState(null),[L,It]=o.useState(null),[me,Ee]=o.useState(""),[Te,rt]=o.useState(null),[Re,$]=o.useState(null),{enqueueToast:ge}=vo(),[Ae,se]=o.useState(!1),[ae,he]=o.useState(""),j=o.useRef(null),Me=o.useCallback(c=>So()?Rn.URLExt.join(Rn.PageConfig.getBaseUrl(),c.oauth2CallbackServerRoute):`${window.location.protocol}//${window.location.hostname}${window.location.port?`:${window.location.port}`:""}${c.oauth2CallbackUIRoute}`,[]),D=o.useMemo(()=>{if(typeof window>"u")return"/";const c=`${window.location.pathname}${window.location.search}${window.location.hash}`;return c.startsWith("/")?c:"/"},[]),V=o.useCallback(async c=>{if(!oe){$(null),Ie(c.name),it(!0);try{const k=On(),P=new URLSearchParams({provider:c.name,callback_uri:Me(c)}),g=ee===void 0?void 0:String(ee||"").trim(),R=g===void 0?D&&D!=="/"?D:void 0:g&&g.startsWith("/")&&!g.startsWith("//")?g:void 0;R&&P.set("post_auth_redirect",R);const re=`${k||""}/api/iam/v1/oauth2/authz/url?${P.toString()}`,S=await fetch(re),De=await S.json(),Pe=De?.autorization_url;if(!S.ok||!Pe)throw new Error(De?.message||"Unable to start social sign-in.");window.location.assign(Pe)}catch(k){const P=na(k);$(P),ge(P,{variant:"error"}),Ie(null),it(!1)}}},[Me,D,ge,oe,ee]);o.useEffect(()=>{Ae&&j.current?.focus()},[Ae]);const ie=o.useCallback(()=>{se(!1),he("")},[]),lt=o.useCallback(()=>{!ae.trim()||!a||(a(ae.trim()),ie())},[ae,a,ie]),ct=o.useCallback(()=>{if(B){B();return}window.location.assign(_e)},[B,_e]),G=o.useCallback(()=>{if(Q){if(Q.startsWith("http://")||Q.startsWith("https://")){window.open(Q,"_blank","noopener,noreferrer");return}window.location.assign(Q)}},[Q]),Be=o.useCallback(async()=>{if(!(v||!W||!ue||w)){pe(!0),$(null);try{const c=await fetch(F,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({handle:W,password:ue})});if(!c.ok)throw new Error(`HTTP ${c.status}`);const k=await c.json();if(k.success&&k.token){const P=String(k?.user?.id||k?.user?.uid||"").trim();if(!!k?.user?.mfaUrl&&P){It(P),rt(k.token),$(null);return}n&&n(k.token,W)}else $(k.message||"Invalid username or password.")}catch(c){$(c instanceof Error?c.message:String(c))}finally{pe(!1)}}},[v,W,ue,w,F,n]),Ve=o.useCallback(async()=>{if(!(v||w||!L||!me.trim()||!Te)){pe(!0),$(null);try{const c=new URL(F,window.location.origin),k=c.pathname.endsWith("/api/iam/v1/login")?c.href.replace(/\/api\/iam\/v1\/login$/,""):`${c.origin}`,P=await fetch(`${k}/api/iam/v1/users/${L}/mfa/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userUid:L,code:me.trim()})}),g=await P.json();if(!P.ok||!g?.success)throw new Error(g?.message||"Failed to validate your MFA code.");n&&n(Te,W)}catch(c){const k=c instanceof Error?c.message:String(c);$(k),ge(k,{variant:"error"})}finally{pe(!1)}}},[v,ge,W,w,F,me,Te,L,n]),He=o.useCallback(c=>{c.key==="Enter"&&(L?Ve():Be())},[L,Be,Ve]),We=oe||w||v;return t.jsxs(p,{className:"signin-input-theme-scope",display:"flex",alignItems:te||ne||!E?"flex-start":"center",justifyContent:"center",minHeight:te||ne||!E?"auto":"100vh",bg:te?"transparent":"canvas.default",color:"fg.default",py:te?0:ne?2:4,children:[t.jsx(oa,{}),t.jsxs(p,{width:"100%",maxWidth:440,p:0,children:[!te&&t.jsxs(t.Fragment,{children:[t.jsxs(p,{display:"flex",alignItems:"center",gap:2,mb:ne?2:3,justifyContent:"center",children:[wt,t.jsx(bt,{sx:{fontSize:3},children:st})]}),t.jsx(H,{as:"p",sx:{fontSize:1,color:"fg.muted",mb:ne?2:3,textAlign:"center"},children:x})]}),(Le||ot)&&t.jsxs(p,{mb:3,textAlign:"center",children:[Le&&t.jsx(bt,{as:"h3",sx:{fontSize:2,mb:1},children:Le}),ot&&t.jsx(H,{sx:{color:"fg.muted",fontSize:1},children:ot})]}),!L&&(d||we||q)&&t.jsxs(t.Fragment,{children:[d&&t.jsx(Y,{block:!0,size:"large",leadingVisual:Ne==="github"?()=>t.jsx(zt,{size:"small"}):Zs,disabled:We,onClick:()=>V(Ht.github),sx:{mt:h,maxWidth:X,mx:"auto"},children:"Sign in with GitHub"}),we&&t.jsx(Y,{block:!0,size:"large",leadingVisual:Ne==="google"?()=>t.jsx(zt,{size:"small"}):ea,disabled:We,onClick:()=>V(Ht.google),sx:{mt:h,maxWidth:X,mx:"auto"},children:"Sign in with Google"}),q&&t.jsx(Y,{block:!0,size:"large",leadingVisual:Ne==="linkedin"?()=>t.jsx(zt,{size:"small"}):ta,disabled:We,onClick:()=>V(Ht.linkedin),sx:{mt:h,maxWidth:X,mx:"auto"},children:"Sign in with LinkedIn"})]}),!L&&!at&&t.jsx(p,{mt:3,display:"flex",justifyContent:"center",children:t.jsx(Y,{leadingVisual:Dt,size:"large",block:!0,disabled:v||w||oe,onClick:()=>jt(!0),sx:{maxWidth:X,mx:"auto"},children:de})}),!L&&at&&t.jsxs(p,{mt:4,children:[t.jsxs(ce,{required:!0,sx:{mb:3},children:[t.jsx(ce.Label,{children:"Username"}),t.jsx(xt,{autoFocus:!0,block:!0,placeholder:"Your username",value:W,disabled:w||v,onChange:c=>ke(c.target.value),onKeyDown:He})]}),t.jsxs(ce,{required:!0,sx:{mb:3},children:[t.jsx(ce.Label,{children:"Password"}),t.jsx(xt,{block:!0,placeholder:"Your password",type:je?"text":"password",value:ue,disabled:w||v,onChange:c=>kt(c.target.value),onKeyDown:He,trailingAction:t.jsx(xt.Action,{onClick:()=>fe(!je),disabled:w||v,icon:je?Qs:Xs,"aria-label":je?"Hide password":"Show password",sx:{color:"var(--fgColor-muted)"}})})]}),t.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"space-between",mt:3,children:[t.jsx(Y,{variant:"primary",disabled:w||v||!W||!ue,onClick:Be,children:w?"Signing in…":"Sign In"}),Ct&&t.jsx(yo,{as:"button",sx:{fontSize:1,cursor:v?"not-allowed":"pointer",background:"none",border:"none",opacity:v?.6:1},onClick:()=>{v||w||G()},children:ze})]})]}),L&&t.jsxs(t.Fragment,{children:[t.jsxs(ce,{required:!0,sx:{mb:3,mt:2},children:[t.jsx(ce.Label,{children:"MFA Code"}),t.jsx(xt,{autoFocus:!0,block:!0,placeholder:"Your MFA code",value:me,disabled:w||v,onChange:c=>Ee(c.target.value),onKeyDown:He})]}),t.jsx(Y,{variant:"primary",block:!0,disabled:w||v||!me.trim(),onClick:Ve,sx:{maxWidth:X,mx:"auto"},children:w?"Validating…":"Validate MFA Code"})]}),Re&&t.jsx(H,{sx:{color:"danger.fg",fontSize:1,mt:3,display:"block"},children:Re}),O&&t.jsxs(p,{mt:4,pt:4,textAlign:"center",borderTop:"1px solid",borderColor:"border.muted",children:[t.jsx(bt,{as:"h3",sx:{fontSize:2,mb:2},children:Yt}),t.jsx(H,{as:"p",sx:{color:"fg.muted",fontSize:1,mb:3},children:J}),t.jsx(p,{display:"flex",justifyContent:"center",children:t.jsx(Y,{variant:"primary",size:"large",leadingVisual:Co,disabled:v||w,onClick:ct,children:yt})})]}),nt&&a&&t.jsxs(t.Fragment,{children:[t.jsxs(p,{display:"flex",alignItems:"center",gap:2,my:3,children:[t.jsx(p,{flex:1,height:"1px",bg:"border.default"}),t.jsx(H,{sx:{fontSize:0,color:"fg.muted"},children:"or"}),t.jsx(p,{flex:1,height:"1px",bg:"border.default"})]}),t.jsx(Y,{block:!0,leadingVisual:Dt,disabled:v||w||oe,onClick:()=>se(!0),sx:{maxWidth:X,mx:"auto"},children:"Sign in with an API Key"}),Ae&&t.jsx(p,{role:"dialog","aria-modal":"true","aria-labelledby":"signin-api-key-title",onKeyDown:c=>{c.key==="Escape"&&ie()},onClick:ie,position:"fixed",inset:0,zIndex:200,p:3,bg:"canvas.backdrop",display:"flex",alignItems:"center",justifyContent:"center",children:t.jsxs(p,{as:"form",onClick:c=>c.stopPropagation(),onSubmit:c=>{c.preventDefault(),lt()},width:"min(560px, 100%)",p:3,borderRadius:2,border:"1px solid",borderColor:"border.default",bg:"canvas.overlay",color:"fg.default",boxShadow:"shadow.large",children:[t.jsx(bt,{id:"signin-api-key-title",sx:{fontSize:2,mb:2},children:"Enter your API Key"}),t.jsxs(ce,{required:!0,children:[t.jsx(ce.Label,{children:"API Key"}),t.jsx(wo,{block:!0,required:!0,autoFocus:!0,placeholder:"Paste your API key here",value:ae,onInput:c=>he(c.currentTarget.value),ref:j})]}),t.jsxs(p,{mt:3,display:"flex",justifyContent:"flex-end",gap:2,children:[t.jsx(Y,{type:"button",onClick:ie,children:"Cancel"}),t.jsx(Y,{type:"submit",variant:"primary",disabled:!ae.trim(),children:"Authenticate"})]})]})})]})]})]})};function aa(n){const{agentId:a,instructions:l,model:r,frontendTools:f,inference:x,subagents:y,sharing:I,onSubagentEvent:d,modeEffect:we}=n;return{type:"browser-vercel-ai",endpoint:"",agentId:a,enableConfigQuery:!1,options:{instructions:l,model:r,frontendTools:f,inference:x,subagents:y,sharing:I,onSubagentEvent:d,modeEffect:we}}}const Fn=Io((n,a)=>({pending:void 0,suggest:(l,r)=>{const f=l.trim();f&&n({pending:{text:f,submit:r?.submit??!1,nonce:(a().pending?.nonce??0)+1}})},consume:()=>n({pending:void 0})}));function ia({agentName:n,sandboxStillRuns:a=!1,temporary:l=!0,onSignedIn:r,onSignUp:f}){const{configuration:x}=zn(),y=o.useCallback(I=>{Eo.getState().checkIAMToken(I),r?.()},[r]);return t.jsx(p,{height:"100%",minHeight:0,overflowY:"auto",bg:"canvas.default",px:4,py:4,children:t.jsxs(p,{maxWidth:440,mx:"auto",children:[t.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"center",gap:2,color:"attention.fg",mb:2,children:[t.jsx(Dt,{size:20}),t.jsx(H,{sx:{fontSize:2,fontWeight:"semibold",color:"fg.default"},children:l?"This demo runs on a shared key":"Your key has expired"})]}),t.jsxs(H,{as:"p",sx:{fontSize:1,color:"fg.muted",textAlign:"center",mb:3},children:[l?`${n??"The agent"} has used the time this key allows. Sign in to point your own agent at it, use your own data, and drop the time limit.`:`${n??"The agent"} stopped because your session ran out.`,a?" Your notebook is still running in this page.":""]}),t.jsx(sa,{hideHero:!0,fillHeight:!1,calloutTitle:"Sign in to keep going",github:!0,google:!0,linkedin:!0,socialSignInNavigationTarget:typeof window>"u"?void 0:`${window.location.pathname}${window.location.search}`,loginUrl:x?.iamUrl?`${x.iamUrl}/api/iam/v1/login`:void 0,onSignIn:y,onSignUp:f})]})})}const ra="https://r1.datalayer.run";function la(n=!0){const{configuration:a}=zn(),l=Gt(I=>I.token),r=a?.aiInferenceUrl||ra,f=To(r,n&&!l),x=l||f.token,y=o.useMemo(()=>({inferenceUrl:r,token:x||void 0}),[r,x]);return{inference:y,needsSignIn:Ro(y),anonymous:f,inferenceUrl:r}}const ca={name:"general-purpose",description:"A capable generalist for a task none of the specialists covers: research, reasoning, drafting, checking.",instructions:"You are a capable general-purpose assistant. Carry out the task you are given completely and report the result plainly, saying what you could not do."};function Ln(n){const a=n?.subagents;if(!a)return[];const l=(a.subagents??[]).map(r=>{const f=r.ref?Ao(r.ref):void 0;return{name:r.name,description:r.description||f?.description||r.name,instructions:r.instructions??f?.systemPrompt,model:r.model??f?.model??a.defaultModel,icon:f?.icon}});return a.includeGeneralPurpose?[...l,ca]:l}function da(n){return n.replace(/^datalayer_/,"").replace(/_lexical$/,"")}function ua(n){const a=da(n);return/^executeCodeIn(Notebook|Document)$/.test(a)||/^(read|list)[A-Z]/.test(a)}function fa(n,a){return n.filter(l=>a?.has(l.name)||ua(l.name))}function pa(n,a){const l=r=>a&&r.value.id===`${a}-tools`?0:r.value.id==="notebook-tools"?1:2;return n.map((r,f)=>({entry:r,index:f,rank:l(r)})).sort((r,f)=>r.rank-f.rank||r.index-f.index).map(r=>r.entry)}function ma(n,a,l){if(!l||!n.endsWith("-tools"))return!1;const r=n.slice(0,-6);return a.has(r)&&r!==l}const ga={type:"object",properties:{}};function ha(n,a){const l=new Set(n.toolset);return n.commands.filter(r=>l.has(r.name)).map(r=>({name:r.name,description:r.description,parameters:r.parameters??ga,location:"frontend",handler:async f=>{if(!a)throw new Error(`${r.name}: the ${n.plugin??n.id} plugin is not mounted on this page.`);const x=Object.keys(f??{}).length>0?f:void 0,y=await a.executeCommand(r.command,x);return y===void 0?{ok:!0,command:r.command,argument:x}:y}}))}function Bn(n,a){return n.flatMap(l=>ha(l,a))}function ba(){const n=Mo(),a=Nn();return o.useMemo(()=>Bn(a,n),[a,n])}function xa(n){const a=n?.app_instance;if(!a||typeof a!="object")return"";const l=a.deployment_uid;return typeof l=="string"?l.trim():""}function va(n,a,l){return n||!a?n:{id:l,messages:[]}}const Sa="var(--theme-accent)";function Vn({face:n,size:a}){return typeof n=="string"?t.jsx(Po,{emoji:n,size:a,label:""}):t.jsx(t.Fragment,{children:n})}function ya({face:n,size:a,state:l}){const r=l==="thinking"||l==="working",f=l==="paused";return t.jsxs(p,{as:"span","aria-hidden":!0,"data-presence":l,position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:a+8,height:a+8,flexShrink:0,fontSize:a,lineHeight:1,children:[t.jsx(p,{as:"span",position:"absolute",inset:0,borderRadius:"50%",boxShadow:f?"none":`0 0 0 2px ${Sa}`,border:f?"2px dashed":"none",borderColor:"border.default",opacity:r||l==="waiting"||f?.9:0,transition:"opacity var(--theme-motion-status, 0ms) var(--theme-motion-easing, ease)",animation:r?"loopPresenceBreath 1.8s ease-in-out infinite":"none",reducedMotion:{animation:"none"},sx:{"@keyframes loopPresenceBreath":{"0%, 100%":{transform:"scale(0.92)",opacity:.35},"50%":{transform:"scale(1.06)",opacity:.9}}}}),t.jsx(p,{as:"span",display:"inline-flex",opacity:f?.55:1,filter:f?"grayscale(0.6)":"none",transition:"opacity var(--theme-motion-status, 0ms) var(--theme-motion-easing, ease)",children:t.jsx(Vn,{face:n,size:a})})]})}function Ca({state:n}){return t.jsx(H,{role:"status","aria-live":"polite","data-presence-line":n,sx:{fontSize:0,color:n==="waiting"?"fg.default":"fg.muted",fontWeight:n==="waiting"?"semibold":"normal",whiteSpace:"nowrap",flexShrink:0},children:Uo[n]})}const wa=Kt(void 0),ka=Kt(""),ja=Kt({}),Z="",Ia=1400,_n=parseInt(Ys["--loop-face-large"],10);function Ma({workspace:n}){const a=$o(),l=Oo(),r=o.useRef(null),{setViewControls:f}=n,[x,y]=o.useState(null),I=Fo(),d=I.getConfig(Lo),we=d?.placeholder||a.placeholder,q=d?.defaultSurface??"notebook",nt=I.getConfig(_o),[O,ee]=o.useState(Z),v=o.useRef(!1),E=N(zo),te=N(No),Le=N(Bo),de=N(Vo)[0]?.value,J=Nt(de?.promptStance??wa)??de?.prompt,yt=N(Ho),_e=Wo(yt[0]?.value),B=o.useRef(_e);B.current=_e;const Q=o.useRef(""),ze=N(Do),Ct=o.useMemo(()=>Go(()=>ze.reduce((e,i)=>({...e,...i.value.extras.value}),{})),[ze]),h=Nt(ze.length>0?Ct:ja),X=o.useRef(new Set),ne=Ko(Gs,n),st=!ne.allowed,wt=st?ne.reason??"Chat is unavailable for this sandbox":void 0,[F,W]=o.useState(!1),[ke,ue]=o.useState(!1),[kt,at]=o.useState(!1),[jt,je]=o.useState({open:!1,pendingApproval:!1}),fe=Yo(F,jt,d?.presence?.paused===!0),w=d?.presence?.onPresence;o.useEffect(()=>{w?.(fe),B.current?.setPresence(fe)},[w,fe]);const pe=o.useRef(d?.presence?.onSaying);pe.current=d?.presence?.onSaying;const oe=o.useRef({answering:!1}),it=o.useCallback(e=>{r.current=e,ue(!!e)},[]),Ne=o.useCallback(e=>{const{open:i,pendingApproval:s}=qo(e);je(ye=>ye.open===i&&ye.pendingApproval===s?ye:{open:i,pendingApproval:s});const m={saying:Qo(e),answering:Jo(e)},u=oe.current;(u.saying?.id!==m.saying?.id||u.saying?.text!==m.saying?.text||u.answering!==m.answering)&&(oe.current=m,pe.current?.(m));const z=B.current;if(!z)return;z.items(e);const M=new Set(["complete","completed","done","error","failed","cancelled","canceled","rejected","denied","stopped"]),K={insertcell:"adding a cell",updatecell:"editing a cell",runcell:"running a cell",deletecells:"removing cells",readallcells:"reading the notebook",readcell:"reading a cell",executecode:"running code",insertblock:"adding a block",updateblock:"editing a block",runblock:"running a block",readdocument:"reading the document"};let b;for(let ye=e.length-1;ye>=0;ye-=1){const ht=e[ye];if(typeof ht.toolName=="string"&&ht.toolCallId){M.has(String(ht.status).toLowerCase())||(b=ht);break}}if(!b){z.activity(void 0);return}const Se=b.toolName.toLowerCase().replace(/^datalayer_/,"").replace(/_lexical$/,"").replace(/[^a-z]/g,""),bo=K[Se]??`using ${b.toolName}`;z.activity(`${Q.current||"The agent"} is ${bo}…`)},[]),Ie=o.useRef(h);Ie.current=h;const L=o.useCallback(e=>{eo(e),B.current?.usage(e),Ie.current.onUsage?.(e)},[]),It=o.useCallback(e=>{W(e),e||B.current?.end("done")},[]),me=o.useCallback(e=>{const i=B.current;if(!i)return;let s=-1;for(let u=e.length-1;u>=0;u-=1)if(e[u].role==="user"){s=u;break}const m=e.slice(s+1).filter(u=>u.role==="assistant").map(Xo).filter(u=>u.trim().length>0).join(`
|
|
28
|
+
`,sa=({onSignIn:n,onApiKeySignIn:a,loginUrl:l,name:r,title:f="Datalayer OTEL",description:x="Sign in to access the observability dashboard.",icon:y,leadingIcon:I=t.jsx(ko,{size:24}),github:d=!1,google:we=!1,linkedin:q=!1,apiKey:nt=!1,signUp:F=!0,socialSignInNavigationTarget:ee,asDoc:v=!1,fillHeight:E=!0,hideHero:te=!1,calloutTitle:Oe,calloutDescription:ot,passwordToggleLabel:de="Sign in with a password",signUpTitle:Yt="Don't have an account?",signUpDescription:J="Create a free Datalayer account with your email address.",signUpLabel:yt="Sign up with email",signUpHref:_e="https://datalayer.ai/signup",onSignUp:B,forgotPasswordHref:Q="/password",forgotPasswordLabel:ze="Forgot password?",showForgotPassword:Ct=!0,socialButtonMarginTop:h=3,actionButtonMaxWidth:X=320})=>{const ne=v&&!te,st=r??(v&&f==="Datalayer OTEL"?"Datalayer Sign In":f),wt=y??(v?t.jsx(Js,{size:24}):I),L=o.useMemo(()=>{if(l)return l;const c=Fn();return c?`${c}/api/iam/v1/login`:"/api/iam/v1/login"},[l]),[W,ke]=o.useState(""),[ue,kt]=o.useState(""),[at,jt]=o.useState(!1),[je,fe]=o.useState(!1),[w,pe]=o.useState(!1),[oe,it]=o.useState(!1),[Ne,Ie]=o.useState(null),[O,It]=o.useState(null),[me,Ee]=o.useState(""),[Te,rt]=o.useState(null),[Re,$]=o.useState(null),{enqueueToast:ge}=vo(),[Ae,se]=o.useState(!1),[ae,he]=o.useState(""),j=o.useRef(null),Me=o.useCallback(c=>So()?Rn.URLExt.join(Rn.PageConfig.getBaseUrl(),c.oauth2CallbackServerRoute):`${window.location.protocol}//${window.location.hostname}${window.location.port?`:${window.location.port}`:""}${c.oauth2CallbackUIRoute}`,[]),D=o.useMemo(()=>{if(typeof window>"u")return"/";const c=`${window.location.pathname}${window.location.search}${window.location.hash}`;return c.startsWith("/")?c:"/"},[]),V=o.useCallback(async c=>{if(!oe){$(null),Ie(c.name),it(!0);try{const k=Fn(),P=new URLSearchParams({provider:c.name,callback_uri:Me(c)}),g=ee===void 0?void 0:String(ee||"").trim(),R=g===void 0?D&&D!=="/"?D:void 0:g&&g.startsWith("/")&&!g.startsWith("//")?g:void 0;R&&P.set("post_auth_redirect",R);const re=`${k||""}/api/iam/v1/oauth2/authz/url?${P.toString()}`,S=await fetch(re),De=await S.json(),Pe=De?.autorization_url;if(!S.ok||!Pe)throw new Error(De?.message||"Unable to start social sign-in.");window.location.assign(Pe)}catch(k){const P=na(k);$(P),ge(P,{variant:"error"}),Ie(null),it(!1)}}},[Me,D,ge,oe,ee]);o.useEffect(()=>{Ae&&j.current?.focus()},[Ae]);const ie=o.useCallback(()=>{se(!1),he("")},[]),lt=o.useCallback(()=>{!ae.trim()||!a||(a(ae.trim()),ie())},[ae,a,ie]),ct=o.useCallback(()=>{if(B){B();return}window.location.assign(_e)},[B,_e]),G=o.useCallback(()=>{if(Q){if(Q.startsWith("http://")||Q.startsWith("https://")){window.open(Q,"_blank","noopener,noreferrer");return}window.location.assign(Q)}},[Q]),Be=o.useCallback(async()=>{if(!(v||!W||!ue||w)){pe(!0),$(null);try{const c=await fetch(L,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({handle:W,password:ue})});if(!c.ok)throw new Error(`HTTP ${c.status}`);const k=await c.json();if(k.success&&k.token){const P=String(k?.user?.id||k?.user?.uid||"").trim();if(!!k?.user?.mfaUrl&&P){It(P),rt(k.token),$(null);return}n&&n(k.token,W)}else $(k.message||"Invalid username or password.")}catch(c){$(c instanceof Error?c.message:String(c))}finally{pe(!1)}}},[v,W,ue,w,L,n]),Ve=o.useCallback(async()=>{if(!(v||w||!O||!me.trim()||!Te)){pe(!0),$(null);try{const c=new URL(L,window.location.origin),k=c.pathname.endsWith("/api/iam/v1/login")?c.href.replace(/\/api\/iam\/v1\/login$/,""):`${c.origin}`,P=await fetch(`${k}/api/iam/v1/users/${O}/mfa/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userUid:O,code:me.trim()})}),g=await P.json();if(!P.ok||!g?.success)throw new Error(g?.message||"Failed to validate your MFA code.");n&&n(Te,W)}catch(c){const k=c instanceof Error?c.message:String(c);$(k),ge(k,{variant:"error"})}finally{pe(!1)}}},[v,ge,W,w,L,me,Te,O,n]),He=o.useCallback(c=>{c.key==="Enter"&&(O?Ve():Be())},[O,Be,Ve]),We=oe||w||v;return t.jsxs(p,{className:"signin-input-theme-scope",display:"flex",alignItems:te||ne||!E?"flex-start":"center",justifyContent:"center",minHeight:te||ne||!E?"auto":"100vh",bg:te?"transparent":"canvas.default",color:"fg.default",py:te?0:ne?2:4,children:[t.jsx(oa,{}),t.jsxs(p,{width:"100%",maxWidth:440,p:0,children:[!te&&t.jsxs(t.Fragment,{children:[t.jsxs(p,{display:"flex",alignItems:"center",gap:2,mb:ne?2:3,justifyContent:"center",children:[wt,t.jsx(bt,{sx:{fontSize:3},children:st})]}),t.jsx(H,{as:"p",sx:{fontSize:1,color:"fg.muted",mb:ne?2:3,textAlign:"center"},children:x})]}),(Oe||ot)&&t.jsxs(p,{mb:3,textAlign:"center",children:[Oe&&t.jsx(bt,{as:"h3",sx:{fontSize:2,mb:1},children:Oe}),ot&&t.jsx(H,{sx:{color:"fg.muted",fontSize:1},children:ot})]}),!O&&(d||we||q)&&t.jsxs(t.Fragment,{children:[d&&t.jsx(Y,{block:!0,size:"large",leadingVisual:Ne==="github"?()=>t.jsx(zt,{size:"small"}):Zs,disabled:We,onClick:()=>V(Ht.github),sx:{mt:h,maxWidth:X,mx:"auto"},children:"Sign in with GitHub"}),we&&t.jsx(Y,{block:!0,size:"large",leadingVisual:Ne==="google"?()=>t.jsx(zt,{size:"small"}):ea,disabled:We,onClick:()=>V(Ht.google),sx:{mt:h,maxWidth:X,mx:"auto"},children:"Sign in with Google"}),q&&t.jsx(Y,{block:!0,size:"large",leadingVisual:Ne==="linkedin"?()=>t.jsx(zt,{size:"small"}):ta,disabled:We,onClick:()=>V(Ht.linkedin),sx:{mt:h,maxWidth:X,mx:"auto"},children:"Sign in with LinkedIn"})]}),!O&&!at&&t.jsx(p,{mt:3,display:"flex",justifyContent:"center",children:t.jsx(Y,{leadingVisual:Dt,size:"large",block:!0,disabled:v||w||oe,onClick:()=>jt(!0),sx:{maxWidth:X,mx:"auto"},children:de})}),!O&&at&&t.jsxs(p,{mt:4,children:[t.jsxs(ce,{required:!0,sx:{mb:3},children:[t.jsx(ce.Label,{children:"Username"}),t.jsx(xt,{autoFocus:!0,block:!0,placeholder:"Your username",value:W,disabled:w||v,onChange:c=>ke(c.target.value),onKeyDown:He})]}),t.jsxs(ce,{required:!0,sx:{mb:3},children:[t.jsx(ce.Label,{children:"Password"}),t.jsx(xt,{block:!0,placeholder:"Your password",type:je?"text":"password",value:ue,disabled:w||v,onChange:c=>kt(c.target.value),onKeyDown:He,trailingAction:t.jsx(xt.Action,{onClick:()=>fe(!je),disabled:w||v,icon:je?Qs:Xs,"aria-label":je?"Hide password":"Show password",sx:{color:"var(--fgColor-muted)"}})})]}),t.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"space-between",mt:3,children:[t.jsx(Y,{variant:"primary",disabled:w||v||!W||!ue,onClick:Be,children:w?"Signing in…":"Sign In"}),Ct&&t.jsx(yo,{as:"button",sx:{fontSize:1,cursor:v?"not-allowed":"pointer",background:"none",border:"none",opacity:v?.6:1},onClick:()=>{v||w||G()},children:ze})]})]}),O&&t.jsxs(t.Fragment,{children:[t.jsxs(ce,{required:!0,sx:{mb:3,mt:2},children:[t.jsx(ce.Label,{children:"MFA Code"}),t.jsx(xt,{autoFocus:!0,block:!0,placeholder:"Your MFA code",value:me,disabled:w||v,onChange:c=>Ee(c.target.value),onKeyDown:He})]}),t.jsx(Y,{variant:"primary",block:!0,disabled:w||v||!me.trim(),onClick:Ve,sx:{maxWidth:X,mx:"auto"},children:w?"Validating…":"Validate MFA Code"})]}),Re&&t.jsx(H,{sx:{color:"danger.fg",fontSize:1,mt:3,display:"block"},children:Re}),F&&t.jsxs(p,{mt:4,pt:4,textAlign:"center",borderTop:"1px solid",borderColor:"border.muted",children:[t.jsx(bt,{as:"h3",sx:{fontSize:2,mb:2},children:Yt}),t.jsx(H,{as:"p",sx:{color:"fg.muted",fontSize:1,mb:3},children:J}),t.jsx(p,{display:"flex",justifyContent:"center",children:t.jsx(Y,{variant:"primary",size:"large",leadingVisual:Co,disabled:v||w,onClick:ct,children:yt})})]}),nt&&a&&t.jsxs(t.Fragment,{children:[t.jsxs(p,{display:"flex",alignItems:"center",gap:2,my:3,children:[t.jsx(p,{flex:1,height:"1px",bg:"border.default"}),t.jsx(H,{sx:{fontSize:0,color:"fg.muted"},children:"or"}),t.jsx(p,{flex:1,height:"1px",bg:"border.default"})]}),t.jsx(Y,{block:!0,leadingVisual:Dt,disabled:v||w||oe,onClick:()=>se(!0),sx:{maxWidth:X,mx:"auto"},children:"Sign in with an API Key"}),Ae&&t.jsx(p,{role:"dialog","aria-modal":"true","aria-labelledby":"signin-api-key-title",onKeyDown:c=>{c.key==="Escape"&&ie()},onClick:ie,position:"fixed",inset:0,zIndex:200,p:3,bg:"canvas.backdrop",display:"flex",alignItems:"center",justifyContent:"center",children:t.jsxs(p,{as:"form",onClick:c=>c.stopPropagation(),onSubmit:c=>{c.preventDefault(),lt()},width:"min(560px, 100%)",p:3,borderRadius:2,border:"1px solid",borderColor:"border.default",bg:"canvas.overlay",color:"fg.default",boxShadow:"shadow.large",children:[t.jsx(bt,{id:"signin-api-key-title",sx:{fontSize:2,mb:2},children:"Enter your API Key"}),t.jsxs(ce,{required:!0,children:[t.jsx(ce.Label,{children:"API Key"}),t.jsx(wo,{block:!0,required:!0,autoFocus:!0,placeholder:"Paste your API key here",value:ae,onInput:c=>he(c.currentTarget.value),ref:j})]}),t.jsxs(p,{mt:3,display:"flex",justifyContent:"flex-end",gap:2,children:[t.jsx(Y,{type:"button",onClick:ie,children:"Cancel"}),t.jsx(Y,{type:"submit",variant:"primary",disabled:!ae.trim(),children:"Authenticate"})]})]})})]})]})]})};function aa(n){const{agentId:a,instructions:l,model:r,frontendTools:f,inference:x,subagents:y,sharing:I,onSubagentEvent:d,modeEffect:we}=n;return{type:"browser-vercel-ai",endpoint:"",agentId:a,enableConfigQuery:!1,options:{instructions:l,model:r,frontendTools:f,inference:x,subagents:y,sharing:I,onSubagentEvent:d,modeEffect:we}}}const Ln=Io((n,a)=>({pending:void 0,suggest:(l,r)=>{const f=l.trim();f&&n({pending:{text:f,submit:r?.submit??!1,nonce:(a().pending?.nonce??0)+1}})},consume:()=>n({pending:void 0})}));function ia({agentName:n,sandboxStillRuns:a=!1,temporary:l=!0,onSignedIn:r,onSignUp:f}){const{configuration:x}=zn(),y=o.useCallback(I=>{Eo.getState().checkIAMToken(I),r?.()},[r]);return t.jsx(p,{height:"100%",minHeight:0,overflowY:"auto",bg:"canvas.default",px:4,py:4,children:t.jsxs(p,{maxWidth:440,mx:"auto",children:[t.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"center",gap:2,color:"attention.fg",mb:2,children:[t.jsx(Dt,{size:20}),t.jsx(H,{sx:{fontSize:2,fontWeight:"semibold",color:"fg.default"},children:l?"This demo runs on a shared key":"Your key has expired"})]}),t.jsxs(H,{as:"p",sx:{fontSize:1,color:"fg.muted",textAlign:"center",mb:3},children:[l?`${n??"The agent"} has used the time this key allows. Sign in to point your own agent at it, use your own data, and drop the time limit.`:`${n??"The agent"} stopped because your session ran out.`,a?" Your notebook is still running in this page.":""]}),t.jsx(sa,{hideHero:!0,fillHeight:!1,calloutTitle:"Sign in to keep going",github:!0,google:!0,linkedin:!0,socialSignInNavigationTarget:typeof window>"u"?void 0:`${window.location.pathname}${window.location.search}`,loginUrl:x?.iamUrl?`${x.iamUrl}/api/iam/v1/login`:void 0,onSignIn:y,onSignUp:f})]})})}const ra="https://r1.datalayer.run";function la(n=!0){const{configuration:a}=zn(),l=Gt(I=>I.token),r=a?.aiInferenceUrl||ra,f=To(r,n&&!l),x=l||f.token,y=o.useMemo(()=>({inferenceUrl:r,token:x||void 0}),[r,x]);return{inference:y,needsSignIn:Ro(y),anonymous:f,inferenceUrl:r}}const ca={name:"general-purpose",description:"A capable generalist for a task none of the specialists covers: research, reasoning, drafting, checking.",instructions:"You are a capable general-purpose assistant. Carry out the task you are given completely and report the result plainly, saying what you could not do."};function On(n){const a=n?.subagents;if(!a)return[];const l=(a.subagents??[]).map(r=>{const f=r.ref?Ao(r.ref):void 0;return{name:r.name,description:r.description||f?.description||r.name,instructions:r.instructions??f?.systemPrompt,model:r.model??f?.model??a.defaultModel,icon:f?.icon}});return a.includeGeneralPurpose?[...l,ca]:l}function da(n){return n.replace(/^datalayer_/,"").replace(/_lexical$/,"")}function ua(n){const a=da(n);return/^executeCodeIn(Notebook|Document)$/.test(a)||/^(read|list)[A-Z]/.test(a)}function fa(n,a){return n.filter(l=>a?.has(l.name)||ua(l.name))}function pa(n,a){const l=r=>a&&r.value.id===`${a}-tools`?0:r.value.id==="notebook-tools"?1:2;return n.map((r,f)=>({entry:r,index:f,rank:l(r)})).sort((r,f)=>r.rank-f.rank||r.index-f.index).map(r=>r.entry)}function ma(n,a,l){if(!l||!n.endsWith("-tools"))return!1;const r=n.slice(0,-6);return a.has(r)&&r!==l}const ga={type:"object",properties:{}};function ha(n,a){const l=new Set(n.toolset);return n.commands.filter(r=>l.has(r.name)).map(r=>({name:r.name,description:r.description,parameters:r.parameters??ga,location:"frontend",handler:async f=>{if(!a)throw new Error(`${r.name}: the ${n.plugin??n.id} plugin is not mounted on this page.`);const x=Object.keys(f??{}).length>0?f:void 0,y=await a.executeCommand(r.command,x);return y===void 0?{ok:!0,command:r.command,argument:x}:y}}))}function Bn(n,a){return n.flatMap(l=>ha(l,a))}function ba(){const n=Mo(),a=Nn();return o.useMemo(()=>Bn(a,n),[a,n])}function xa(n){const a=n?.app_instance;if(!a||typeof a!="object")return"";const l=a.deployment_uid;return typeof l=="string"?l.trim():""}function va(n,a,l){return n||!a?n:{id:l,messages:[]}}const Sa=({state:n})=>Po[n],ya="var(--theme-accent)";function Vn({face:n,size:a}){return typeof n=="string"?t.jsx(Uo,{emoji:n,size:a,label:""}):t.jsx(t.Fragment,{children:n})}function Ca({face:n,size:a,state:l}){const r=l==="thinking"||l==="working",f=l==="paused";return t.jsxs(p,{as:"span","aria-hidden":!0,"data-presence":l,position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:a+8,height:a+8,flexShrink:0,fontSize:a,lineHeight:1,children:[t.jsx(p,{as:"span",position:"absolute",inset:0,borderRadius:"50%",boxShadow:f?"none":`0 0 0 2px ${ya}`,border:f?"2px dashed":"none",borderColor:"border.default",opacity:r||l==="waiting"||f?.9:0,transition:"opacity var(--theme-motion-status, 0ms) var(--theme-motion-easing, ease)",animation:r?"loopPresenceBreath 1.8s ease-in-out infinite":"none",reducedMotion:{animation:"none"},sx:{"@keyframes loopPresenceBreath":{"0%, 100%":{transform:"scale(0.92)",opacity:.35},"50%":{transform:"scale(1.06)",opacity:.9}}}}),t.jsx(p,{as:"span",display:"inline-flex",opacity:f?.55:1,filter:f?"grayscale(0.6)":"none",transition:"opacity var(--theme-motion-status, 0ms) var(--theme-motion-easing, ease)",children:t.jsx(Vn,{face:n,size:a})})]})}function wa({state:n}){return t.jsx(H,{role:"status","aria-live":"polite","data-presence-line":n,sx:{fontSize:0,color:n==="waiting"?"fg.default":"fg.muted",fontWeight:n==="waiting"?"semibold":"normal",whiteSpace:"nowrap",flexShrink:0},children:Sa({state:n})})}const ka=Kt(void 0),ja=Kt(""),Ia=Kt({}),Z="",Ea=1400,_n=parseInt(Ys["--loop-face-large"],10);function Pa({workspace:n}){const a=$o(),l=Fo(),r=o.useRef(null),{setViewControls:f}=n,[x,y]=o.useState(null),I=Lo(),d=I.getConfig(Oo),we=d?.placeholder||a.placeholder,q=d?.defaultSurface??"notebook",nt=I.getConfig(_o),[F,ee]=o.useState(Z),v=o.useRef(!1),E=N(zo),te=N(No),Oe=N(Bo),de=N(Vo)[0]?.value,J=Nt(de?.promptStance??ka)??de?.prompt,yt=N(Ho),_e=Wo(yt[0]?.value),B=o.useRef(_e);B.current=_e;const Q=o.useRef(""),ze=N(Do),Ct=o.useMemo(()=>Go(()=>ze.reduce((e,i)=>({...e,...i.value.extras.value}),{})),[ze]),h=Nt(ze.length>0?Ct:Ia),X=o.useRef(new Set),ne=Ko(Gs,n),st=!ne.allowed,wt=st?ne.reason??"Chat is unavailable for this sandbox":void 0,[L,W]=o.useState(!1),[ke,ue]=o.useState(!1),[kt,at]=o.useState(!1),[jt,je]=o.useState({open:!1,pendingApproval:!1}),fe=Yo(L,jt,d?.presence?.paused===!0),w=d?.presence?.onPresence;o.useEffect(()=>{w?.(fe),B.current?.setPresence(fe)},[w,fe]);const pe=o.useRef(d?.presence?.onSaying);pe.current=d?.presence?.onSaying;const oe=o.useRef({answering:!1}),it=o.useCallback(e=>{r.current=e,ue(!!e)},[]),Ne=o.useCallback(e=>{const{open:i,pendingApproval:s}=qo(e);je(ye=>ye.open===i&&ye.pendingApproval===s?ye:{open:i,pendingApproval:s});const m={saying:Qo(e),answering:Jo(e)},u=oe.current;(u.saying?.id!==m.saying?.id||u.saying?.text!==m.saying?.text||u.answering!==m.answering)&&(oe.current=m,pe.current?.(m));const z=B.current;if(!z)return;z.items(e);const M=new Set(["complete","completed","done","error","failed","cancelled","canceled","rejected","denied","stopped"]),K={insertcell:"adding a cell",updatecell:"editing a cell",runcell:"running a cell",deletecells:"removing cells",readallcells:"reading the notebook",readcell:"reading a cell",executecode:"running code",insertblock:"adding a block",updateblock:"editing a block",runblock:"running a block",readdocument:"reading the document"};let b;for(let ye=e.length-1;ye>=0;ye-=1){const ht=e[ye];if(typeof ht.toolName=="string"&&ht.toolCallId){M.has(String(ht.status).toLowerCase())||(b=ht);break}}if(!b){z.activity(void 0);return}const Se=b.toolName.toLowerCase().replace(/^datalayer_/,"").replace(/_lexical$/,"").replace(/[^a-z]/g,""),bo=K[Se]??`using ${b.toolName}`;z.activity(`${Q.current||"The agent"} is ${bo}…`)},[]),Ie=o.useRef(h);Ie.current=h;const O=o.useCallback(e=>{eo(e),B.current?.usage(e),Ie.current.onUsage?.(e)},[]),It=o.useCallback(e=>{W(e),e||B.current?.end("done")},[]),me=o.useCallback(e=>{const i=B.current;if(!i)return;let s=-1;for(let u=e.length-1;u>=0;u-=1)if(e[u].role==="user"){s=u;break}const m=e.slice(s+1).filter(u=>u.role==="assistant").map(Xo).filter(u=>u.trim().length>0).join(`
|
|
29
29
|
|
|
30
30
|
`);i.assistant(m)},[]),Ee=o.useRef([]),Te=o.useRef(!1),rt=o.useRef(void 0),Re=o.useRef(void 0),$=o.useRef(void 0),ge=N(Zo),Ae=o.useRef(ge);Ae.current=ge;const se=o.useCallback((e,i)=>{if(Re.current)return Re.current;const s=$.current;$.current=void 0;const m=es(Ae.current.map(M=>M.value),s?{...i??{},voice:s}:i),u=m?.loop;if(Te.current&&u?.files&&u.files.length>0){const M=rt.current;if(!M)return"A file is given to an application running on a runtime: run it on Datalayer or on your machine to give it one.";let K;try{K=u.files.map(b=>({file:ns(String(b.name??"")),base64:ts(String(b.data_url??""))}))}catch(b){return b instanceof Error?b.message:String(b)}M.execute(os(K)).then(b=>{if(!b.success){y(`The files could not be put in the sandbox: ${b.error??"it failed"}.`);return}se(`${e}
|
|
31
31
|
|
|
32
|
-
${ss(K.map(Se=>Se.file))}`,{...m,loop:Object.fromEntries(Object.entries(u).filter(([Se])=>Se!=="files"))})});return}B.current?.begin(e,r.current?.thread());const z=r.current?.send;if(!z){Ee.current.push([e,m]);return}z(e,m)},[]);o.useEffect(()=>{f(ke?{busy:F,stop:r.current?.stop,newChat:r.current?.newChat,send:se}:null)},[F,ke,f,se]),o.useEffect(()=>()=>f(null),[f]),o.useEffect(()=>n.prompts.subscribe(se),[n.prompts,se]),o.useEffect(()=>{if(!ke||Ee.current.length===0)return;const e=Ee.current.splice(0,Ee.current.length);for(const[i,s]of e)r.current?.send(i,s)},[ke]);const ae=o.useRef(!1),he=o.useCallback(async e=>{y(null);const i=await as(Ie.current,e);if(i){i.sent?Je(""):y(i.refused);return}ae.current||(ae.current=!0,nt?.firstPromptHook?.());const s=await n.submit(e);if(!s.handled){y(s.reason??null);return}Je(""),s.result?.content&&y(s.result.content)},[n,nt?.firstPromptHook]),j=o.useMemo(()=>E.find(e=>e.value.surfaceId===O)?.value,[E,O]),Me=o.useCallback(e=>{v.current=!0,ee(e)},[]);o.useEffect(()=>is(Me),[Me]),o.useEffect(()=>{rs(E.map(e=>e.value.surfaceId))},[E]),o.useEffect(()=>{ls(O&&O!==Z?O:qs)},[O]);const D=o.useMemo(()=>q===Z||q==="none"?void 0:E.find(e=>e.value.surfaceId===q),[E,q]);o.useEffect(()=>{v.current||!D||tt(D.value,n)&&ee(q)},[D,n,q]);const[V,ie]=o.useState(null),lt=o.useRef(null),ct=d?.fullScreenTopOffset??0,{fullScreen:G,usingApi:Be,toggle:Ve,topOffsetPx:He}=cs(lt,{forceOverlay:!!ct,topOffset:ct}),[We,c]=o.useState(!1),k=o.useRef(!1);o.useEffect(()=>{!F||k.current||G||(k.current=!0,c(!0))},[F,G]),o.useEffect(()=>{G&&c(!1)},[G]),o.useEffect(()=>{j&&!tt(j,n)&&(ie(j.surfaceId),ee(Z))},[j,n]);const P=o.useMemo(()=>{if(V)return E.find(e=>e.value.surfaceId===V)?.value;if(!v.current&&O===Z)return D?.value},[E,V,O,D]);o.useEffect(()=>{if(!V||O!==Z)return;const e=E.find(i=>i.value.surfaceId===V);e&&tt(e.value,n)&&(ie(null),ee(V))},[E,O,V,n]);const g=n.agentId?.trim()||"default",R=ds(n.sandbox.target??"local");Te.current=R;const C=us(),re=Nt(C?.selected??ka),S=C?.members.find(e=>e.id===re),De=N(fs)[0]?.value,Pe=De?.specId,A=An(S?.specId??g)??(Pe?An(Pe):void 0),Ge=S?void 0:De,qt=R&&!S?Ds(Pe,A):void 0;Q.current=S?.name??A?.name??g;const Jt=N(ps),Qt=h.hiddenOpeners,Xt=h.hideOpeners,Et=h.openers,Tt=o.useMemo(()=>{if(Xt)return[];const e=new Set(Qt??[]),i=b=>e.size===0?b:b.filter(Se=>!e.has(Se.text));if(Et)return i(Et);const s=Jt.flatMap(b=>b.value.suggestions);if(s.length>0)return i(s);const m=i(A?.suggestions??[]),u=i(C?.team.suggestions??[]);if(u.length===0)return m;const z=new Set(u.map(b=>b.text)),M=C?.team.name??"Team",K=S?.name??A?.name??g;return[...u.map(b=>({...b,group:M})),...m.filter(b=>!z.has(b.text)).map(b=>({...b,group:K}))]},[Jt,C,A,S,g,Qt,Xt,Et]),dt=o.useMemo(()=>Tt.map(e=>({title:e.summary??e.text,message:e.message??e.text,group:e.group})),[Tt]),Rt=Fe(A?.icon),_=d?.presence,Hn=Fe(C?.team.icon),Zt=N(ms),ut=o.useMemo(()=>{const e=[],i=new Map,s=new Set,m=new Set(E.map(u=>u.value.surfaceId));for(const u of pa(Zt,j?.surfaceId)){if(ma(u.value.id,m,j?.surfaceId))continue;let z;try{z=u.value.tools(n)}catch(M){console.warn(`[loop] frontend tools from '${u.plugin}' failed:`,M);continue}for(const M of z){const K=i.get(M.name);if(K){console.warn(`[loop] frontend tool '${M.name}' from '${u.plugin}' is shadowed by the one from '${K}'.`);continue}i.set(M.name,u.plugin),e.push(M),u.value.chatView&&s.add(M.name)}}for(const u of h.frontendTools??[])i.has(u.name)||(i.set(u.name,"chat-extras"),e.push(u),s.add(u.name));return j?e:fa(e,s)},[Zt,n.surfaceId,n.agentId,h.frontendTools,j?.surfaceId,E]),At=ba(),Ke=o.useMemo(()=>{if(At.length===0)return ut;const e=new Set(ut.map(i=>i.name));return[...ut,...At.filter(i=>!e.has(i.name))]},[ut,At]),en=Nn(),Mt=h.agentToolBundles,Wn=o.useMemo(()=>{const e=h.frontendTools??[];if(!Mt?.length)return h.frontendTools;const i=Bn(en.filter(m=>Mt.includes(m.id)),I),s=new Set(e.map(m=>m.name));return[...e,...i.filter(m=>!s.has(m.name))]},[h.frontendTools,Mt,en,I]);rt.current=R&&Ke.some(e=>e.name===gs)?I.getOutput(vt)?.sandbox:void 0;const T=hs(n.sandbox,n.serverUrl),tn=N(bs),Dn=o.useMemo(()=>tn.filter(e=>e.value.composer).map(e=>({name:e.value.name,description:e.value.description})),[tn]),Gn=o.useMemo(()=>{if(!C||!S)return Ln(A).map(s=>({name:s.name,description:s.description,icon:Fe(s.icon)}));const e=C.members.map(s=>({name:s.name,description:s.description,emoji:s.emoji,icon:Fe(s.icon),disabled:s.id===S.id,disabledReason:s.id===S.id?`You are already talking to ${s.name}`:void 0})),i=Mn(C.team,S.id).filter(s=>!C.members.some(m=>m.name===s.name)).map(s=>({name:s.name,description:s.description,icon:Fe(s.icon)}));return[...e,...i]},[C,S,A]),{inference:nn,anonymous:Kn}=la(R),Yn=Gt(e=>e.user),Pt=R&&Kn.status==="expired",on=!Yn,Ye=xs();Re.current=Ye.disabled?Ye.disableReason||"This conversation is closed here.":void 0;const Ut=T===void 0?vs(n.sandbox,a):void 0,qe=st||Pt||!!qt||!!Ut||Ye.disabled,sn=Pt?on?a.demoKeyExpired:a.keyExpired:qt??Ut??wt??(Ye.disabled?Ye.disableReason:void 0),[$t,Je]=o.useState(""),[an]=Ss(),Qe=o.useMemo(()=>d?.voice?ys(d.voice,an):void 0,[d?.voice,an]),[qn,Jn]=o.useState(!1),[Qn,rn]=o.useState(),ft=Qn??Ge?.model??A?.model??n.model??"",Ue=Cs(),ln=o.useRef(Ue),cn=o.useRef(re),dn=o.useRef(Ue);dn.current=Ue,o.useEffect(()=>{cn.current!==re&&(cn.current=re,ln.current=dn.current,rn(void 0))},[re]);const Xn=Ue&&Ue!==ln.current?Ue:null,[Zn,eo]=o.useState(),to=Xn??Zn??null,no=Bt(Ce.inpromptMenu),un=Bt(Ce.promptAction),fn=Bt(Ce.chatHeader),oo=o.useMemo(()=>C?.members.map(e=>({id:e.id,name:e.name,description:e.description,icon:Fe(e.icon)}))??[],[C]),be=Fn(e=>e.pending),[pn,so]=o.useState(0);o.useEffect(()=>ws(()=>so(e=>e+1)),[]),o.useEffect(()=>{be&&(Je(be.text),Fn.getState().consume(),be.submit&&he(be.text))},[be]);const mn=I.getConfig(vt)?.datalayerCreatePayload,xe=!!(Ge?.createPayload?.app_spec||mn?.app_spec),Xe=xa(mn),ao=Gt(e=>e.token),Ot=I.getConfig(vt)?.datalayerVisitors,io=ks(Ot),ro=I.getConfig(vt)?.embedToken,ve=Ot?io.token:ro||ao,lo=o.useMemo(()=>js(d?.voice,ve||void 0,Xe),[d?.voice,ve,Xe]),le=!!(Xe||Ot);if(le&&!xe)throw new Error("A deployment’s page runs its application: its host gave no app_spec.");const[gn]=o.useState(Pn),U=o.useMemo(()=>va(d?.thread,Xe,gn),[d?.thread,Xe,gn]),[$e,hn]=o.useState(null),co=!!(U?.fromRuntime&&$e?.given!==U.id);o.useEffect(()=>{if(!U?.fromRuntime||!xe||!T)return;let e=!0;return(async()=>{let i="";for(let s=0;s<4&&e;s+=1)try{const m=await Is({agentBaseUrl:T,agentId:g,uid:U.id,token:ve});e&&hn({given:U.id,thread:{...U,fromRuntime:!1,messages:m}});return}catch(m){i=m instanceof Error?m.message:String(m),await new Promise(u=>setTimeout(u,1500))}e&&hn({given:U.id,thread:{id:Pn(),messages:[],onStarted:U.onStarted},said:Un.notOpened(i)})})(),()=>{e=!1}},[U?.id,U?.fromRuntime,xe,T,g,ve]);const bn=U?.fromRuntime?$e?.given===U.id?$e.thread:void 0:U,Ft=o.useMemo(()=>R?aa({agentId:S?.specId??g,instructions:Es(A,Ge?.instructions),model:ft||void 0,inference:nn,frontendTools:Ke,subagents:C&&S?Mn(C.team,S.id):Ln(A),sharing:C?.sharing,onSubagentEvent:e=>Ks.getState().appendSubagentEvent(e),modeEffect:Ge?.modeEffect}):T!==void 0?{type:"ag-ui",endpoint:xe?`${T}/api/v1/apps/agents/${encodeURIComponent(g)}/ag-ui/`:`${T}/api/v1/ag-ui/${g}/`,...xe&&ve?{authToken:ve}:{},...xe?{uiSocket:`${T.replace(/^http/,"ws")}/api/v1/apps/ui`,uiFiles:`${T}/api/v1/apps/agents/${encodeURIComponent(g)}/files`,appSessions:`${T}/api/v1/apps/sessions`,...le?{ownRoutesOnly:!0}:{}}:{},agentId:g,configEndpoint:`${T}/api/v1/configure`,enableConfigQuery:!0}:void 0,[g,R,nn,S,Ke,C,A,Ge,ft,T,xe,ve,le]),pt=Ts(!R,Ft?.type==="ag-ui"?Ft.configEndpoint:void 0,void 0,g),Ze=Rs(),mt=As(g),[xn,Lt]=o.useState(void 0),[uo,fo]=o.useState(void 0);o.useEffect(()=>{if(R||T===void 0)return;const e=Ms(T,g,le);if(!e){Lt([]);return}let i=!1;return fetch(e).then(s=>s.ok?s.json():null).then(s=>{i||(Lt(s?Ps(s):[]),fo(s?Us(s):void 0))}).catch(()=>{i||Lt([])}),()=>{i=!0}},[T,g,R,le]);const po=o.useMemo(()=>$s(xn,()=>Object.values(Os).filter(e=>e.available&&Fs(e)).map(e=>({id:e.id,name:e.name,provider:e.provider}))),[xn]),vn=o.useMemo(()=>{const e=pt.data?.builtinTools??[],i=new Set(e.map(s=>s.name));return{runtime:e,frontend:Ke.filter(s=>!i.has(s.name)).map(s=>({id:s.name,name:s.name}))}},[pt.data?.builtinTools,Ke]),Sn=o.useMemo(()=>new Set((Ze.data?.skills??[]).filter(e=>e.status==="enabled"||e.status==="loaded").map(e=>e.id)),[Ze.data]),mo=o.useCallback(async e=>{if(le)throw new Error("A deployment’s chat does not switch its runtime’s model.");rn(e),!(R||T===void 0)&&await fetch(`${T}/api/v1/configure/inference/provider`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({model:e})}).catch(()=>{})},[T,R,le]),yn=d?.promptPlacement==="bottom-chat",go=d?.promptPlacement==="floating",Oe=d?.promptPlacement==="top",et=d?.hidePrompt===!0||h.hidePrompt===!0,ho={onSend:()=>{he($t)},input:$t,setInput:Je,focusTrigger:be||pn?(be?.nonce??0)+pn:void 0,placement:go||J==="floating"||J==="floating-top"||J==="floating-bottom"?"floating":"docked",floatingAnchor:J==="floating-top"?"top":"bottom",isLoading:F,onStop:()=>n.viewControls.stop?.(),placeholder:sn??h.sendInstead?.says??we,typingSuggestions:Tt.map(e=>e.text),suggestions:dt,disableInputPrompt:qe,connectionConfirmed:!qe,interim:qn,padding:Oe||J==="floating-top"||J==="floating-bottom"||J==="docked-top"?2:3,promptVariant:"lexical",autoFocus:d?.autoFocusPrompt??!0,mentionableAgents:Gn,promptCommands:Dn,headerContent:no.length>0?t.jsx(St,{slot:Ce.inpromptMenu,props:{workspace:n}}):void 0,footerExtras:un.length>0||Qe&&Qe.input!=="off"?t.jsxs(t.Fragment,{children:[un.length>0?t.jsx(St,{slot:Ce.promptAction,props:{workspace:n}}):null,Qe&&Qe.input!=="off"?t.jsx(Ls,{voice:Qe,input:$t,setInput:Je,disabled:qe,speaking:kt,onStopSpeaking:()=>r.current?.stopSpeaking?.(),onInterimChange:Jn,answers:!!(d?.voice?.output&&d.voice.output!=="off"&&d.voice.speechUrl),onSpoken:e=>{$.current=e},send:(e,i)=>{$.current=i,he(e)}}):null]}):void 0,showAgentsMenu:!_,showInlineAgentsMenu:!1,agents:oo,selectedAgentId:re,onSelectAgent:e=>C?.select(e),showTokenUsage:h.showTokenUsage??d?.showTokenUsage??!0,showContextRing:!0,agentUsage:to??void 0,showModelSelector:!_&&!le,models:po,decisions:uo,selectedModel:ft,onModelSelect:e=>{mo(e)},showToolsMenu:!_,availableTools:vn.runtime,availableFrontendTools:vn.frontend,mcpServers:pt.data?.mcpServers??[],mcpStatusData:h.mcpStatusData??void 0,showSkillsMenu:!_,skills:Ze.data?.skills??[],skillsLoading:Ze.isLoading,enabledSkills:Sn,onToggleSkill:e=>Sn.has(e)?mt.disableSkill(e):mt.enableSkill(e),onToggleAllSkills:(e,i)=>e.forEach(s=>i?mt.enableSkill(s):mt.disableSkill(s)),codemodeEnabled:h.codemodeEnabled??!1,onToggleCodemode:h.onToggleCodemode,isA2AProtocol:!1,hasConfigData:!!pt.data,hasSkillsData:!!Ze.data},Cn=te[0]?.value.Component,_t=Le[0]?.value.Component,wn=!d?.hideHeader&&!!_t,gt=Cn?t.jsx(Cn,{workspace:n,composer:ho}):null,kn=E.length>0&&d?.showSurfaceSelector!==!1?t.jsx(Ea,{surfaces:E.map(e=>e.value),active:j?.surfaceId??P?.surfaceId??Z,onChange:Me,workspace:n}):null,jn=t.jsxs(t.Fragment,{children:[E.map(e=>{const i=e.value,s=j?.surfaceId===i.surfaceId;return s||X.current.has(i.surfaceId)||tt(i,n)?(X.current.add(i.surfaceId),t.jsx(p,{sx:s?{flex:"1 1 0",minWidth:0,minHeight:0}:{position:"absolute",inset:0,visibility:"hidden",pointerEvents:"none",zIndex:-1},children:t.jsx(_s,{load:i.load,props:{surfaceId:i.surfaceId,workspace:n},fallback:t.jsxs(Wt,{children:["Loading ",i.title,"…"]}),errorFallback:u=>t.jsxs(Wt,{children:[i.title," failed to load: ",u.message]})})},i.surfaceId)):null}),!j&&P?t.jsx(p,{flex:"1 1 0",minWidth:0,minHeight:0,children:t.jsxs(Wt,{children:["Starting ",P.title,"…"]})}):null]}),In=t.jsx(t.Fragment,{children:t.jsxs(p,{flex:Oe&&j?"0 0 34%":"1 1 0",maxWidth:Oe&&j?460:void 0,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",borderLeft:j?"1px solid":void 0,borderColor:"border.default",position:"relative",children:[h.errorBanner?t.jsx(p,{flexShrink:0,px:3,py:2,fontSize:1,borderBottom:"1px solid",bg:h.errorBanner.variant==="warning"?"attention.subtle":"danger.subtle",color:h.errorBanner.variant==="warning"?"attention.fg":"danger.fg",borderColor:h.errorBanner.variant==="warning"?"attention.muted":"danger.muted",children:h.errorBanner.message}):null,$e?.said&&$e.given===U?.id?t.jsx(H,{as:"p",role:"status",sx:{m:0,px:3,py:2,fontSize:1,color:"fg.muted"},children:$e.said}):null,t.jsx(p,{flex:"1 1 auto",minHeight:0,display:"flex",children:co?t.jsx(H,{as:"p",role:"status",sx:{m:0,p:3,fontSize:1,color:"fg.muted"},children:Un.opening}):t.jsx(zs,{themeVariant:d?.themeVariant,themeOverrides:d?.themeOverrides,colorMode:d?.colorMode,thread:bn,voice:lo,disabled:qe,disableReason:sn,protocol:Ft,frontendTools:R?void 0:Wn,initialModel:ft||void 0,title:_?.name??S?.name??A?.name??g,description:_?.welcome??A?.description,brandIcon:_?.face?t.jsx(ya,{face:_.face,size:20,state:fe}):t.jsx(Rt,{size:20}),headerContent:_&&!Ut?t.jsx(Ca,{state:fe}):void 0,emptyState:{icon:_?.face?t.jsx("span",{"aria-hidden":!0,style:{fontSize:_n,lineHeight:1},children:t.jsx(Vn,{face:_.face,size:_n})}):t.jsx(Rt,{size:48}),title:_?.name??S?.name??A?.name??g,...C&&S?{sections:[{group:C.team.name,icon:t.jsx(Hn,{size:48}),title:C.team.name,subtitle:C.team.description},{group:S.name,icon:t.jsx(Rt,{size:32}),title:S.name,subtitle:A?.description}]}:null},suggestions:Oe||de||d?.suggestionLabels===!1?[]:dt,showHeader:wn,headerButtons:{showNewChat:d?.headerButtons?.newChat??!1,showClear:d?.headerButtons?.clear??!1},renderHeader:_t?e=>t.jsx(_t,{workspace:n,header:n.chatViewModes?{...e,chatViewMode:n.chatViewModes.value,onChatViewModeChange:n.chatViewModes.onChange,offeredViewModes:n.chatViewModes.offered}:e}):void 0,showInformation:!0,headerActions:t.jsxs(p,{display:"inline-flex",alignItems:"center",gap:2,children:[n.chatHeaderActions,fn.length>0?t.jsx(St,{slot:Ce.chatHeader,props:{workspace:n}}):null,t.jsx(Ns,{icon:G?Bs:Vs,"aria-label":G?"Exit full screen":"Enter full screen",variant:"invisible",size:"small",onClick:()=>{c(!1),Ve()},sx:We?{"@keyframes dla-fullscreen-hint":{"0%, 100%":{opacity:1},"50%":{opacity:.4}},"&&":{bg:`color-mix(in srgb, ${l.primary} 16%, transparent)`,boxShadow:`inset 0 0 0 1.5px ${l.primary}`,animation:`dla-fullscreen-hint ${Ia}ms ease-in-out infinite`},"@media (prefers-reduced-motion: reduce)":{"&&":{animation:"none"}}}:void 0})]}),showInput:!1,onSendReady:it,notebookToolSurfacesId:j?void 0:n.surfaceId,showTurnFooter:h.showTokenUsage??d?.showTokenUsage??!0,onContextSnapshot:L,onLoadingChange:It,onSpeakingChange:at,onItemsChange:me,onDisplayItemsChange:Ne,enableStreaming:!0},bn?.id)}),!wn&&fn.length>0?t.jsx(p,{hidden:!0,children:t.jsx(St,{slot:Ce.chatHeader,props:{workspace:n}})}):null,yn&&!et?gt:null]})}),En=d?.suggestionLabels!==!1&&dt.length>0?t.jsx(p,{"aria-label":a.suggestedPrompts,display:"flex",flexWrap:"wrap",gap:2,px:2,pb:"6px",children:dt.map(e=>t.jsx(p,{as:"button",type:"button",title:e.message,disabled:F||qe,onClick:()=>{he(e.message)},appearance:"none",font:"inherit",fontSize:0,fontWeight:"semibold",lineHeight:1.25,px:"10px",py:"5px",width:$n,flex:`0 0 ${$n}px`,borderRadius:"999px",border:"1px solid",bg:"canvas.subtle",whiteSpace:"nowrap",sx:{borderColor:"border.default",color:"fg.default",cursor:"pointer","&:hover:not(:disabled)":{borderColor:"accent.fg",color:"accent.fg"},"&:disabled":{opacity:.5,cursor:"default"}},children:t.jsx(Hs,{title:e.title,maxWidth:"100%",sx:{minWidth:0},children:e.title})},e.title))}):null,Tn=x?t.jsx(p,{flex:"0 0 auto",px:3,py:2,borderTop:"1px solid",borderColor:"border.default",bg:"canvas.subtle",fontSize:1,maxHeight:"40%",overflowY:"auto",children:x}):null;return t.jsxs(p,{ref:lt,sx:{height:"100%",minHeight:0,display:"flex",flexDirection:"column",position:"relative",...G?{bg:"canvas.default"}:null,...G&&!Be.current?{position:"fixed",top:He,right:0,bottom:0,left:0,height:"auto",zIndex:1e3}:null},children:[de?t.jsx(de.Component,{workspace:n,editors:jn,hasEditor:!!j,transcript:In,prompt:et?null:gt,chips:et?null:En,picker:kn,transient:Tn}):t.jsxs(t.Fragment,{children:[Oe&&!et?t.jsxs(p,{flex:"0 0 auto",borderBottom:"1px solid",borderColor:"border.default",children:[gt,En]}):null,kn,t.jsxs(p,{flex:"1 1 auto",minHeight:0,display:"flex",position:"relative",children:[jn,In]}),Tn,yn||et||Oe?null:gt]}),Pt?t.jsx(p,{position:"absolute",inset:0,zIndex:5,bg:"canvas.default",display:"flex",flexDirection:"column",minHeight:0,children:t.jsx(ia,{agentName:S?.name??A?.name,sandboxStillRuns:R,temporary:on,onSignedIn:()=>Ws.getState().clear()})}):null]})}function Ea({surfaces:n,active:a,onChange:l,workspace:r}){const f=[...n].sort((x,y)=>(x.order??100)-(y.order??100));return t.jsxs(p,{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2,px:3,py:2,borderBottom:"1px solid",borderColor:"border.default",children:[t.jsx(H,{sx:{fontSize:0,color:"fg.muted"},children:"Beside the chat"}),t.jsxs(Vt,{"aria-label":"Editor beside the chat",size:"small",children:[t.jsx(Vt.Button,{selected:a===Z,onClick:()=>l(Z),children:"Chat"}),f.map(x=>{const y=tt(x,r),I=y?void 0:x.unavailableReason?.(r)??"Not available right now";return t.jsx(Vt.Button,{selected:a===x.surfaceId,"aria-disabled":!y,title:I??x.title,leadingIcon:x.icon,onClick:()=>{y&&l(x.surfaceId)},children:x.title},x.surfaceId)})]})]})}function Wt({children:n}){return t.jsx(p,{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"fg.muted",fontSize:1,px:3,textAlign:"center",children:n})}export{Ma as default};
|
|
32
|
+
${ss(K.map(Se=>Se.file))}`,{...m,loop:Object.fromEntries(Object.entries(u).filter(([Se])=>Se!=="files"))})});return}B.current?.begin(e,r.current?.thread());const z=r.current?.send;if(!z){Ee.current.push([e,m]);return}z(e,m)},[]);o.useEffect(()=>{f(ke?{busy:L,stop:r.current?.stop,newChat:r.current?.newChat,send:se}:null)},[L,ke,f,se]),o.useEffect(()=>()=>f(null),[f]),o.useEffect(()=>n.prompts.subscribe(se),[n.prompts,se]),o.useEffect(()=>{if(!ke||Ee.current.length===0)return;const e=Ee.current.splice(0,Ee.current.length);for(const[i,s]of e)r.current?.send(i,s)},[ke]);const ae=o.useRef(!1),he=o.useCallback(async e=>{y(null);const i=await as(Ie.current,e);if(i){i.sent?Je(""):y(i.refused);return}ae.current||(ae.current=!0,nt?.firstPromptHook?.());const s=await n.submit(e);if(!s.handled){y(s.reason??null);return}Je(""),s.result?.content&&y(s.result.content)},[n,nt?.firstPromptHook]),j=o.useMemo(()=>E.find(e=>e.value.surfaceId===F)?.value,[E,F]),Me=o.useCallback(e=>{v.current=!0,ee(e)},[]);o.useEffect(()=>is(Me),[Me]),o.useEffect(()=>{rs(E.map(e=>e.value.surfaceId))},[E]),o.useEffect(()=>{ls(F&&F!==Z?F:qs)},[F]);const D=o.useMemo(()=>q===Z||q==="none"?void 0:E.find(e=>e.value.surfaceId===q),[E,q]);o.useEffect(()=>{v.current||!D||tt(D.value,n)&&ee(q)},[D,n,q]);const[V,ie]=o.useState(null),lt=o.useRef(null),ct=d?.fullScreenTopOffset??0,{fullScreen:G,usingApi:Be,toggle:Ve,topOffsetPx:He}=cs(lt,{forceOverlay:!!ct,topOffset:ct}),[We,c]=o.useState(!1),k=o.useRef(!1);o.useEffect(()=>{!L||k.current||G||(k.current=!0,c(!0))},[L,G]),o.useEffect(()=>{G&&c(!1)},[G]),o.useEffect(()=>{j&&!tt(j,n)&&(ie(j.surfaceId),ee(Z))},[j,n]);const P=o.useMemo(()=>{if(V)return E.find(e=>e.value.surfaceId===V)?.value;if(!v.current&&F===Z)return D?.value},[E,V,F,D]);o.useEffect(()=>{if(!V||F!==Z)return;const e=E.find(i=>i.value.surfaceId===V);e&&tt(e.value,n)&&(ie(null),ee(V))},[E,F,V,n]);const g=n.agentId?.trim()||"default",R=ds(n.sandbox.target??"local");Te.current=R;const C=us(),re=Nt(C?.selected??ja),S=C?.members.find(e=>e.id===re),De=N(fs)[0]?.value,Pe=De?.specId,A=An(S?.specId??g)??(Pe?An(Pe):void 0),Ge=S?void 0:De,qt=R&&!S?Ds(Pe,A):void 0;Q.current=S?.name??A?.name??g;const Jt=N(ps),Qt=h.hiddenOpeners,Xt=h.hideOpeners,Et=h.openers,Tt=o.useMemo(()=>{if(Xt)return[];const e=new Set(Qt??[]),i=b=>e.size===0?b:b.filter(Se=>!e.has(Se.text));if(Et)return i(Et);const s=Jt.flatMap(b=>b.value.suggestions);if(s.length>0)return i(s);const m=i(A?.suggestions??[]),u=i(C?.team.suggestions??[]);if(u.length===0)return m;const z=new Set(u.map(b=>b.text)),M=C?.team.name??"Team",K=S?.name??A?.name??g;return[...u.map(b=>({...b,group:M})),...m.filter(b=>!z.has(b.text)).map(b=>({...b,group:K}))]},[Jt,C,A,S,g,Qt,Xt,Et]),dt=o.useMemo(()=>Tt.map(e=>({title:e.summary??e.text,message:e.message??e.text,group:e.group})),[Tt]),Rt=Le(A?.icon),_=d?.presence,Hn=Le(C?.team.icon),Zt=N(ms),ut=o.useMemo(()=>{const e=[],i=new Map,s=new Set,m=new Set(E.map(u=>u.value.surfaceId));for(const u of pa(Zt,j?.surfaceId)){if(ma(u.value.id,m,j?.surfaceId))continue;let z;try{z=u.value.tools(n)}catch(M){console.warn(`[loop] frontend tools from '${u.plugin}' failed:`,M);continue}for(const M of z){const K=i.get(M.name);if(K){console.warn(`[loop] frontend tool '${M.name}' from '${u.plugin}' is shadowed by the one from '${K}'.`);continue}i.set(M.name,u.plugin),e.push(M),u.value.chatView&&s.add(M.name)}}for(const u of h.frontendTools??[])i.has(u.name)||(i.set(u.name,"chat-extras"),e.push(u),s.add(u.name));return j?e:fa(e,s)},[Zt,n.surfaceId,n.agentId,h.frontendTools,j?.surfaceId,E]),At=ba(),Ke=o.useMemo(()=>{if(At.length===0)return ut;const e=new Set(ut.map(i=>i.name));return[...ut,...At.filter(i=>!e.has(i.name))]},[ut,At]),en=Nn(),Mt=h.agentToolBundles,Wn=o.useMemo(()=>{const e=h.frontendTools??[];if(!Mt?.length)return h.frontendTools;const i=Bn(en.filter(m=>Mt.includes(m.id)),I),s=new Set(e.map(m=>m.name));return[...e,...i.filter(m=>!s.has(m.name))]},[h.frontendTools,Mt,en,I]);rt.current=R&&Ke.some(e=>e.name===gs)?I.getOutput(vt)?.sandbox:void 0;const T=hs(n.sandbox,n.serverUrl),tn=N(bs),Dn=o.useMemo(()=>tn.filter(e=>e.value.composer).map(e=>({name:e.value.name,description:e.value.description})),[tn]),Gn=o.useMemo(()=>{if(!C||!S)return On(A).map(s=>({name:s.name,description:s.description,icon:Le(s.icon)}));const e=C.members.map(s=>({name:s.name,description:s.description,emoji:s.emoji,icon:Le(s.icon),disabled:s.id===S.id,disabledReason:s.id===S.id?`You are already talking to ${s.name}`:void 0})),i=Mn(C.team,S.id).filter(s=>!C.members.some(m=>m.name===s.name)).map(s=>({name:s.name,description:s.description,icon:Le(s.icon)}));return[...e,...i]},[C,S,A]),{inference:nn,anonymous:Kn}=la(R),Yn=Gt(e=>e.user),Pt=R&&Kn.status==="expired",on=!Yn,Ye=xs();Re.current=Ye.disabled?Ye.disableReason||"This conversation is closed here.":void 0;const Ut=T===void 0?vs(n.sandbox,a):void 0,qe=st||Pt||!!qt||!!Ut||Ye.disabled,sn=Pt?on?a.demoKeyExpired:a.keyExpired:qt??Ut??wt??(Ye.disabled?Ye.disableReason:void 0),[$t,Je]=o.useState(""),[an]=Ss(),Qe=o.useMemo(()=>d?.voice?ys(d.voice,an):void 0,[d?.voice,an]),[qn,Jn]=o.useState(!1),[Qn,rn]=o.useState(),ft=Qn??Ge?.model??A?.model??n.model??"",Ue=Cs(),ln=o.useRef(Ue),cn=o.useRef(re),dn=o.useRef(Ue);dn.current=Ue,o.useEffect(()=>{cn.current!==re&&(cn.current=re,ln.current=dn.current,rn(void 0))},[re]);const Xn=Ue&&Ue!==ln.current?Ue:null,[Zn,eo]=o.useState(),to=Xn??Zn??null,no=Bt(Ce.inpromptMenu),un=Bt(Ce.promptAction),fn=Bt(Ce.chatHeader),oo=o.useMemo(()=>C?.members.map(e=>({id:e.id,name:e.name,description:e.description,icon:Le(e.icon)}))??[],[C]),be=Ln(e=>e.pending),[pn,so]=o.useState(0);o.useEffect(()=>ws(()=>so(e=>e+1)),[]),o.useEffect(()=>{be&&(Je(be.text),Ln.getState().consume(),be.submit&&he(be.text))},[be]);const mn=I.getConfig(vt)?.datalayerCreatePayload,xe=!!(Ge?.createPayload?.app_spec||mn?.app_spec),Xe=xa(mn),ao=Gt(e=>e.token),Ft=I.getConfig(vt)?.datalayerVisitors,io=ks(Ft),ro=I.getConfig(vt)?.embedToken,ve=Ft?io.token:ro||ao,lo=o.useMemo(()=>js(d?.voice,ve||void 0,Xe),[d?.voice,ve,Xe]),le=!!(Xe||Ft);if(le&&!xe)throw new Error("A deployment’s page runs its application: its host gave no app_spec.");const[gn]=o.useState(Pn),U=o.useMemo(()=>va(d?.thread,Xe,gn),[d?.thread,Xe,gn]),[$e,hn]=o.useState(null),co=!!(U?.fromRuntime&&$e?.given!==U.id);o.useEffect(()=>{if(!U?.fromRuntime||!xe||!T)return;let e=!0;return(async()=>{let i="";for(let s=0;s<4&&e;s+=1)try{const m=await Is({agentBaseUrl:T,agentId:g,uid:U.id,token:ve});e&&hn({given:U.id,thread:{...U,fromRuntime:!1,messages:m}});return}catch(m){i=m instanceof Error?m.message:String(m),await new Promise(u=>setTimeout(u,1500))}e&&hn({given:U.id,thread:{id:Pn(),messages:[],onStarted:U.onStarted},said:Un.notOpened(i)})})(),()=>{e=!1}},[U?.id,U?.fromRuntime,xe,T,g,ve]);const bn=U?.fromRuntime?$e?.given===U.id?$e.thread:void 0:U,Lt=o.useMemo(()=>R?aa({agentId:S?.specId??g,instructions:Es(A,Ge?.instructions),model:ft||void 0,inference:nn,frontendTools:Ke,subagents:C&&S?Mn(C.team,S.id):On(A),sharing:C?.sharing,onSubagentEvent:e=>Ks.getState().appendSubagentEvent(e),modeEffect:Ge?.modeEffect}):T!==void 0?{type:"ag-ui",endpoint:xe?`${T}/api/v1/apps/agents/${encodeURIComponent(g)}/ag-ui/`:`${T}/api/v1/ag-ui/${g}/`,...xe&&ve?{authToken:ve}:{},...xe?{uiSocket:`${T.replace(/^http/,"ws")}/api/v1/apps/ui`,uiFiles:`${T}/api/v1/apps/agents/${encodeURIComponent(g)}/files`,appSessions:`${T}/api/v1/apps/sessions`,...le?{ownRoutesOnly:!0}:{}}:{},agentId:g,configEndpoint:`${T}/api/v1/configure`,enableConfigQuery:!0}:void 0,[g,R,nn,S,Ke,C,A,Ge,ft,T,xe,ve,le]),pt=Ts(!R,Lt?.type==="ag-ui"?Lt.configEndpoint:void 0,void 0,g),Ze=Rs(),mt=As(g),[xn,Ot]=o.useState(void 0),[uo,fo]=o.useState(void 0);o.useEffect(()=>{if(R||T===void 0)return;const e=Ms(T,g,le);if(!e){Ot([]);return}let i=!1;return fetch(e).then(s=>s.ok?s.json():null).then(s=>{i||(Ot(s?Ps(s):[]),fo(s?Us(s):void 0))}).catch(()=>{i||Ot([])}),()=>{i=!0}},[T,g,R,le]);const po=o.useMemo(()=>$s(xn,()=>Object.values(Fs).filter(e=>e.available&&Ls(e)).map(e=>({id:e.id,name:e.name,provider:e.provider}))),[xn]),vn=o.useMemo(()=>{const e=pt.data?.builtinTools??[],i=new Set(e.map(s=>s.name));return{runtime:e,frontend:Ke.filter(s=>!i.has(s.name)).map(s=>({id:s.name,name:s.name}))}},[pt.data?.builtinTools,Ke]),Sn=o.useMemo(()=>new Set((Ze.data?.skills??[]).filter(e=>e.status==="enabled"||e.status==="loaded").map(e=>e.id)),[Ze.data]),mo=o.useCallback(async e=>{if(le)throw new Error("A deployment’s chat does not switch its runtime’s model.");rn(e),!(R||T===void 0)&&await fetch(`${T}/api/v1/configure/inference/provider`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({model:e})}).catch(()=>{})},[T,R,le]),yn=d?.promptPlacement==="bottom-chat",go=d?.promptPlacement==="floating",Fe=d?.promptPlacement==="top",et=d?.hidePrompt===!0||h.hidePrompt===!0,ho={onSend:()=>{he($t)},input:$t,setInput:Je,focusTrigger:be||pn?(be?.nonce??0)+pn:void 0,placement:go||J==="floating"||J==="floating-top"||J==="floating-bottom"?"floating":"docked",floatingAnchor:J==="floating-top"?"top":"bottom",isLoading:L,onStop:()=>n.viewControls.stop?.(),placeholder:sn??h.sendInstead?.says??we,typingSuggestions:Tt.map(e=>e.text),suggestions:dt,disableInputPrompt:qe,connectionConfirmed:!qe,interim:qn,padding:Fe||J==="floating-top"||J==="floating-bottom"||J==="docked-top"?2:3,promptVariant:"lexical",autoFocus:d?.autoFocusPrompt??!0,mentionableAgents:Gn,promptCommands:Dn,headerContent:no.length>0?t.jsx(St,{slot:Ce.inpromptMenu,props:{workspace:n}}):void 0,footerExtras:un.length>0||Qe&&Qe.input!=="off"?t.jsxs(t.Fragment,{children:[un.length>0?t.jsx(St,{slot:Ce.promptAction,props:{workspace:n}}):null,Qe&&Qe.input!=="off"?t.jsx(Os,{voice:Qe,input:$t,setInput:Je,disabled:qe,speaking:kt,onStopSpeaking:()=>r.current?.stopSpeaking?.(),onInterimChange:Jn,answers:!!(d?.voice?.output&&d.voice.output!=="off"&&d.voice.speechUrl),onSpoken:e=>{$.current=e},send:(e,i)=>{$.current=i,he(e)}}):null]}):void 0,showAgentsMenu:!_,showInlineAgentsMenu:!1,agents:oo,selectedAgentId:re,onSelectAgent:e=>C?.select(e),showTokenUsage:h.showTokenUsage??d?.showTokenUsage??!0,showContextRing:!0,agentUsage:to??void 0,showModelSelector:!_&&!le,models:po,decisions:uo,selectedModel:ft,onModelSelect:e=>{mo(e)},showToolsMenu:!_,availableTools:vn.runtime,availableFrontendTools:vn.frontend,mcpServers:pt.data?.mcpServers??[],mcpStatusData:h.mcpStatusData??void 0,showSkillsMenu:!_,skills:Ze.data?.skills??[],skillsLoading:Ze.isLoading,enabledSkills:Sn,onToggleSkill:e=>Sn.has(e)?mt.disableSkill(e):mt.enableSkill(e),onToggleAllSkills:(e,i)=>e.forEach(s=>i?mt.enableSkill(s):mt.disableSkill(s)),codemodeEnabled:h.codemodeEnabled??!1,onToggleCodemode:h.onToggleCodemode,isA2AProtocol:!1,hasConfigData:!!pt.data,hasSkillsData:!!Ze.data},Cn=te[0]?.value.Component,_t=Oe[0]?.value.Component,wn=!d?.hideHeader&&!!_t,gt=Cn?t.jsx(Cn,{workspace:n,composer:ho}):null,kn=E.length>0&&d?.showSurfaceSelector!==!1?t.jsx(Ta,{surfaces:E.map(e=>e.value),active:j?.surfaceId??P?.surfaceId??Z,onChange:Me,workspace:n}):null,jn=t.jsxs(t.Fragment,{children:[E.map(e=>{const i=e.value,s=j?.surfaceId===i.surfaceId;return s||X.current.has(i.surfaceId)||tt(i,n)?(X.current.add(i.surfaceId),t.jsx(p,{sx:s?{flex:"1 1 0",minWidth:0,minHeight:0}:{position:"absolute",inset:0,visibility:"hidden",pointerEvents:"none",zIndex:-1},children:t.jsx(_s,{load:i.load,props:{surfaceId:i.surfaceId,workspace:n},fallback:t.jsxs(Wt,{children:["Loading ",i.title,"…"]}),errorFallback:u=>t.jsxs(Wt,{children:[i.title," failed to load: ",u.message]})})},i.surfaceId)):null}),!j&&P?t.jsx(p,{flex:"1 1 0",minWidth:0,minHeight:0,children:t.jsxs(Wt,{children:["Starting ",P.title,"…"]})}):null]}),In=t.jsx(t.Fragment,{children:t.jsxs(p,{flex:Fe&&j?"0 0 34%":"1 1 0",maxWidth:Fe&&j?460:void 0,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",borderLeft:j?"1px solid":void 0,borderColor:"border.default",position:"relative",children:[h.errorBanner?t.jsx(p,{flexShrink:0,px:3,py:2,fontSize:1,borderBottom:"1px solid",bg:h.errorBanner.variant==="warning"?"attention.subtle":"danger.subtle",color:h.errorBanner.variant==="warning"?"attention.fg":"danger.fg",borderColor:h.errorBanner.variant==="warning"?"attention.muted":"danger.muted",children:h.errorBanner.message}):null,$e?.said&&$e.given===U?.id?t.jsx(H,{as:"p",role:"status",sx:{m:0,px:3,py:2,fontSize:1,color:"fg.muted"},children:$e.said}):null,t.jsx(p,{flex:"1 1 auto",minHeight:0,display:"flex",children:co?t.jsx(H,{as:"p",role:"status",sx:{m:0,p:3,fontSize:1,color:"fg.muted"},children:Un.opening}):t.jsx(zs,{themeVariant:d?.themeVariant,themeOverrides:d?.themeOverrides,colorMode:d?.colorMode,thread:bn,voice:lo,disabled:qe,disableReason:sn,protocol:Lt,frontendTools:R?void 0:Wn,initialModel:ft||void 0,title:_?.name??S?.name??A?.name??g,description:_?.welcome??A?.description,brandIcon:_?.face?t.jsx(Ca,{face:_.face,size:20,state:fe}):t.jsx(Rt,{size:20}),headerContent:_&&!Ut?t.jsx(wa,{state:fe}):void 0,emptyState:{icon:_?.face?t.jsx("span",{"aria-hidden":!0,style:{fontSize:_n,lineHeight:1},children:t.jsx(Vn,{face:_.face,size:_n})}):t.jsx(Rt,{size:48}),title:_?.name??S?.name??A?.name??g,...C&&S?{sections:[{group:C.team.name,icon:t.jsx(Hn,{size:48}),title:C.team.name,subtitle:C.team.description},{group:S.name,icon:t.jsx(Rt,{size:32}),title:S.name,subtitle:A?.description}]}:null},suggestions:Fe||de||d?.suggestionLabels===!1?[]:dt,showHeader:wn,headerButtons:{showNewChat:d?.headerButtons?.newChat??!1,showClear:d?.headerButtons?.clear??!1},renderHeader:_t?e=>t.jsx(_t,{workspace:n,header:n.chatViewModes?{...e,chatViewMode:n.chatViewModes.value,onChatViewModeChange:n.chatViewModes.onChange,offeredViewModes:n.chatViewModes.offered}:e}):void 0,showInformation:!0,headerActions:t.jsxs(p,{display:"inline-flex",alignItems:"center",gap:2,children:[n.chatHeaderActions,fn.length>0?t.jsx(St,{slot:Ce.chatHeader,props:{workspace:n}}):null,t.jsx(Ns,{icon:G?Bs:Vs,"aria-label":G?"Exit full screen":"Enter full screen",variant:"invisible",size:"small",onClick:()=>{c(!1),Ve()},sx:We?{"@keyframes dla-fullscreen-hint":{"0%, 100%":{opacity:1},"50%":{opacity:.4}},"&&":{bg:`color-mix(in srgb, ${l.primary} 16%, transparent)`,boxShadow:`inset 0 0 0 1.5px ${l.primary}`,animation:`dla-fullscreen-hint ${Ea}ms ease-in-out infinite`},"@media (prefers-reduced-motion: reduce)":{"&&":{animation:"none"}}}:void 0})]}),showInput:!1,onSendReady:it,notebookToolSurfacesId:j?void 0:n.surfaceId,showTurnFooter:h.showTokenUsage??d?.showTokenUsage??!0,onContextSnapshot:O,onLoadingChange:It,onSpeakingChange:at,onItemsChange:me,onDisplayItemsChange:Ne,enableStreaming:!0},bn?.id)}),!wn&&fn.length>0?t.jsx(p,{hidden:!0,children:t.jsx(St,{slot:Ce.chatHeader,props:{workspace:n}})}):null,yn&&!et?gt:null]})}),En=d?.suggestionLabels!==!1&&dt.length>0?t.jsx(p,{"aria-label":a.suggestedPrompts,display:"flex",flexWrap:"wrap",gap:2,px:2,pb:"6px",children:dt.map(e=>t.jsx(p,{as:"button",type:"button",title:e.message,disabled:L||qe,onClick:()=>{he(e.message)},appearance:"none",font:"inherit",fontSize:0,fontWeight:"semibold",lineHeight:1.25,px:"10px",py:"5px",width:$n,flex:`0 0 ${$n}px`,borderRadius:"999px",border:"1px solid",bg:"canvas.subtle",whiteSpace:"nowrap",sx:{borderColor:"border.default",color:"fg.default",cursor:"pointer","&:hover:not(:disabled)":{borderColor:"accent.fg",color:"accent.fg"},"&:disabled":{opacity:.5,cursor:"default"}},children:t.jsx(Hs,{title:e.title,maxWidth:"100%",sx:{minWidth:0},children:e.title})},e.title))}):null,Tn=x?t.jsx(p,{flex:"0 0 auto",px:3,py:2,borderTop:"1px solid",borderColor:"border.default",bg:"canvas.subtle",fontSize:1,maxHeight:"40%",overflowY:"auto",children:x}):null;return t.jsxs(p,{ref:lt,sx:{height:"100%",minHeight:0,display:"flex",flexDirection:"column",position:"relative",...G?{bg:"canvas.default"}:null,...G&&!Be.current?{position:"fixed",top:He,right:0,bottom:0,left:0,height:"auto",zIndex:1e3}:null},children:[de?t.jsx(de.Component,{workspace:n,editors:jn,hasEditor:!!j,transcript:In,prompt:et?null:gt,chips:et?null:En,picker:kn,transient:Tn}):t.jsxs(t.Fragment,{children:[Fe&&!et?t.jsxs(p,{flex:"0 0 auto",borderBottom:"1px solid",borderColor:"border.default",children:[gt,En]}):null,kn,t.jsxs(p,{flex:"1 1 auto",minHeight:0,display:"flex",position:"relative",children:[jn,In]}),Tn,yn||et||Fe?null:gt]}),Pt?t.jsx(p,{position:"absolute",inset:0,zIndex:5,bg:"canvas.default",display:"flex",flexDirection:"column",minHeight:0,children:t.jsx(ia,{agentName:S?.name??A?.name,sandboxStillRuns:R,temporary:on,onSignedIn:()=>Ws.getState().clear()})}):null]})}function Ta({surfaces:n,active:a,onChange:l,workspace:r}){const f=[...n].sort((x,y)=>(x.order??100)-(y.order??100));return t.jsxs(p,{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2,px:3,py:2,borderBottom:"1px solid",borderColor:"border.default",children:[t.jsx(H,{sx:{fontSize:0,color:"fg.muted"},children:"Beside the chat"}),t.jsxs(Vt,{"aria-label":"Editor beside the chat",size:"small",children:[t.jsx(Vt.Button,{selected:a===Z,onClick:()=>l(Z),children:"Chat"}),f.map(x=>{const y=tt(x,r),I=y?void 0:x.unavailableReason?.(r)??"Not available right now";return t.jsx(Vt.Button,{selected:a===x.surfaceId,"aria-disabled":!y,title:I??x.title,leadingIcon:x.icon,onClick:()=>{y&&l(x.surfaceId)},children:x.title},x.surfaceId)})]})]})}function Wt({children:n}){return t.jsx(p,{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"fg.muted",fontSize:1,px:3,textAlign:"center",children:n})}export{Pa as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as x,j as e,B as n,T as s,q as i}from"../datalayer-app-main.js";import j from"./index-
|
|
1
|
+
import{r as x,j as e,B as n,T as s,q as i}from"../datalayer-app-main.js";import j from"./index-BTnG8qrO.js";function A({agentUsage:o,padding:y,showContextRing:T=!1}){const[k,h]=x.useState(!1),v=x.useRef(null),c=x.useRef(null),g=!!o.turnUsage,C=!!o.sessionUsage,w=!!o.costUsage&&(o.costUsage.cumulativeCostUsd>0||o.costUsage.lastTurnCostUsd>0),m=o.sessionUsage,p=o.turnUsage,b=o.costUsage,d=t=>t<.01?`$${t.toFixed(4)}`:t<1?`$${t.toFixed(3)}`:`$${t.toFixed(2)}`,f=o.totalTokens,u=o.contextWindow,S=Math.max(0,u-f),a=u>0?f/u*100:0,r=[];if(o.distribution?.children?.length){const t={"System Prompts":"#8250df","Tool Definitions":"#bf8700","User Messages":"#16A085","Assistant Messages":"#1a7f37","Tool Usage":"#cf222e"};for(const l of o.distribution.children)r.push({name:l.name,value:l.value,color:t[l.name]||"#6e7781"})}else{o.systemPromptTokens>0&&r.push({name:"System Prompts",value:o.systemPromptTokens,color:"#8250df"}),o.toolTokens>0&&r.push({name:"Tool Definitions",value:o.toolTokens,color:"#bf8700"});const t=(o.userMessageTokens||0)+(o.assistantMessageTokens||0);t>0&&r.push({name:"Messages",value:t,color:"#16A085"});const l=(o.toolCallTokens||0)+(o.toolReturnTokens||0);l>0&&r.push({name:"Tool Results",value:l,color:"#cf222e"})}const z=a>90?"#cf222e":a>70?"#bf8700":"#16A085",W="var(--bgColor-muted, #f6f8fa)",R="var(--borderColor-default, #d1d9e0)",M={animation:!1,series:[{type:"pie",radius:[0,"90%"],center:["50%","50%"],silent:!0,label:{show:!1},labelLine:{show:!1},data:[{value:f,itemStyle:{color:z}},{value:S,itemStyle:{color:W}}]}]},P={animation:!1,series:[{type:"pie",radius:["45%","80%"],center:["50%","50%"],silent:!0,label:{show:!1},labelLine:{show:!1},itemStyle:{borderColor:"var(--bgColor-default, #ffffff)",borderWidth:1},data:[...r.map(t=>({value:t.value,itemStyle:{color:t.color}})),{value:S,itemStyle:{color:R}}]}]};return e.jsxs(n,{display:"flex",alignItems:"center",justifyContent:"flex-start",gap:2,py:1,px:y,bg:"canvas.subtle",flexWrap:"nowrap",overflow:"visible",whiteSpace:"nowrap",minWidth:0,children:[T&&e.jsxs(n,{position:"relative",flexShrink:0,onMouseEnter:()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>h(!0),150)},onMouseLeave:()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>h(!1),250)},children:[e.jsx(n,{ref:v,cursor:"pointer",width:20,height:20,display:"flex",alignItems:"center",justifyContent:"center",border:"1px solid",borderColor:"border.default",borderRadius:"50%",children:e.jsx(j,{option:M,style:{width:18,height:18},opts:{renderer:"svg"}})}),k&&e.jsxs(n,{position:"absolute",bottom:"100%",left:0,mb:1,p:3,width:260,bg:"canvas.overlay",borderRadius:2,boxShadow:"shadow.large",border:"1px solid",borderColor:"border.default",zIndex:100,children:[e.jsx(s,{sx:{fontWeight:"bold",fontSize:1,color:"fg.default",display:"block",mb:2},children:"Context"}),e.jsxs(s,{sx:{fontSize:0,color:"fg.muted",display:"block",mb:1},children:[e.jsx(s,{as:"span",sx:{fontWeight:"semibold",color:"fg.default"},children:i(f)})," / ",i(u)," tokens"]}),o.costUsage&&e.jsxs(s,{sx:{fontSize:0,color:"fg.muted",display:"block",mb:2},children:["cost ",e.jsx(s,{as:"span",sx:{fontWeight:"semibold",color:"fg.default"},children:d(o.costUsage.lastTurnCostUsd)})," turn · ",e.jsx(s,{as:"span",sx:{fontWeight:"semibold",color:"fg.default"},children:d(o.costUsage.cumulativeCostUsd)})," total"]}),e.jsxs(s,{sx:{fontSize:0,color:a>90?"danger.fg":a>70?"attention.fg":"fg.muted",fontWeight:"semibold",display:"block",mb:2},children:["• ",a.toFixed(0),"%"]}),e.jsx(n,{display:"flex",justifyContent:"center",mb:2,children:e.jsx(j,{option:P,style:{width:80,height:80},opts:{renderer:"svg"}})}),e.jsx(n,{display:"flex",flexDirection:"column",gap:1,children:r.map(t=>{const l=f>0?t.value/f*100:0;return e.jsxs(n,{display:"flex",alignItems:"center",gap:2,children:[e.jsx(n,{width:8,height:8,borderRadius:"50%",bg:t.color,flexShrink:0}),e.jsx(s,{sx:{fontSize:0,color:"fg.muted",flex:1},children:t.name}),e.jsxs(s,{sx:{fontSize:0,color:"fg.default",fontWeight:"semibold"},children:[l.toFixed(1),"%"]})]},t.name)})}),a>70&&e.jsx(s,{sx:{fontSize:0,color:"attention.fg",display:"block",mt:2,fontStyle:"italic"},children:"Quality may decline as limit nears."})]})]}),e.jsxs(s,{sx:{fontSize:0,color:"fg.muted",flexShrink:0},children:[e.jsx(s,{as:"span",sx:{fontWeight:"semibold",color:"fg.default",fontSize:0},children:i(o.totalTokens)})," / ",i(o.contextWindow)," ctx"]}),w&&e.jsxs(s,{sx:{fontSize:0,color:"fg.muted",flexShrink:0},children:["· cost ",e.jsx(s,{as:"span",sx:{fontWeight:"semibold",color:"fg.default",fontSize:0},children:d(b?.lastTurnCostUsd??0)})," turn / ",e.jsx(s,{as:"span",sx:{fontWeight:"semibold",color:"fg.default",fontSize:0},children:d(b?.cumulativeCostUsd??0)})]}),C&&e.jsxs(s,{sx:{fontSize:0,color:"fg.muted",flexShrink:0},children:["· session ",i(m?.inputTokens??0),e.jsx(s,{as:"span",sx:{color:"success.fg",fontSize:0},children:"▲"})," ",i(m?.outputTokens??0),e.jsx(s,{as:"span",sx:{color:"attention.fg",fontSize:0},children:"▼"})]}),g&&e.jsxs(s,{sx:{fontSize:0,color:"fg.muted",flexShrink:0},children:["· turn ",i(p?.inputTokens??0),e.jsx(s,{as:"span",sx:{color:"success.fg",fontSize:0},children:"▲"})," ",i(p?.outputTokens??0),e.jsx(s,{as:"span",sx:{color:"attention.fg",fontSize:0},children:"▼"})]})]})}export{A as ContextPie};
|