@datalayer/agent-runtimes 1.5.34 → 1.5.35
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/{DeckComponent-ymp4My5d.js → DeckComponent-C7AztSPA.js} +2 -2
- package/dist-embed/chunks/{DocumentView-i99p_Qzt.js → DocumentView-DwpK2feQ.js} +1 -1
- package/dist-embed/chunks/{EphemeralDocument--pV47gPl.js → EphemeralDocument-rusBlgBp.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawComponent-DgSMy796.js → ExcalidrawComponent-Qv9LHutW.js} +1 -1
- package/dist-embed/chunks/{ExcalidrawModal-DFJW9pQh.js → ExcalidrawModal-D6Mb9nmf.js} +1 -1
- package/dist-embed/chunks/{JupyterLexicalExtension-CqDatsgf.js → JupyterLexicalExtension-r47Jyrrd.js} +4 -4
- package/dist-embed/chunks/{YouTubePlugin-CpgyVTwG.js → YouTubePlugin-4pUBJORX.js} +1 -1
- package/dist-embed/chunks/{abnfDiagram-VCTEODGH-faK2fyHC.js → abnfDiagram-VCTEODGH-BJ41CQF_.js} +1 -1
- package/dist-embed/chunks/{abnfDiagram-VCTEODGH-wvUaPpVC.js → abnfDiagram-VCTEODGH-DNYzHAbh.js} +1 -1
- package/dist-embed/chunks/{ar-SA-G6X2FPQ2-DwUjDWHp.js → ar-SA-G6X2FPQ2-CD4X_3wm.js} +1 -1
- package/dist-embed/chunks/{architectureDiagram-5GKGNRK7-DBMLRsbO.js → architectureDiagram-5GKGNRK7-CwaejFS3.js} +1 -1
- package/dist-embed/chunks/{architectureDiagram-5GKGNRK7-CwbfxDHw.js → architectureDiagram-5GKGNRK7-DbT9wERH.js} +1 -1
- package/dist-embed/chunks/{az-AZ-76LH7QW2-DROX4pJc.js → az-AZ-76LH7QW2-oMbKQcB-.js} +1 -1
- package/dist-embed/chunks/{bg-BG-XCXSNQG7-DPLzP9Bm.js → bg-BG-XCXSNQG7-lSIB5dDU.js} +1 -1
- package/dist-embed/chunks/{blockDiagram-868be97b-BXBoGds2.js → blockDiagram-868be97b-DMkn45RE.js} +1 -1
- package/dist-embed/chunks/{blockDiagram-I7D4REHJ-BNkBA3Vb.js → blockDiagram-I7D4REHJ-BECNvGDg.js} +1 -1
- package/dist-embed/chunks/{blockDiagram-I7D4REHJ-DUIcpkIN.js → blockDiagram-I7D4REHJ-CjQ3b06j.js} +1 -1
- package/dist-embed/chunks/{bn-BD-2XOGV67Q-CCOU2J2j.js → bn-BD-2XOGV67Q-B5PkHAFO.js} +1 -1
- package/dist-embed/chunks/{c4Diagram-3f4bdde3-4OdTwU_t.js → c4Diagram-3f4bdde3-Sln1RzFs.js} +1 -1
- package/dist-embed/chunks/{c4Diagram-7LVT6UL2-f7UaZWVg.js → c4Diagram-7LVT6UL2-CEN50eWF.js} +1 -1
- package/dist-embed/chunks/{c4Diagram-7LVT6UL2-BGpBMrvl.js → c4Diagram-7LVT6UL2-rLFGZdcX.js} +1 -1
- package/dist-embed/chunks/{ca-ES-6MX7JW3Y-3RgFapBd.js → ca-ES-6MX7JW3Y-BPeavtUl.js} +1 -1
- package/dist-embed/chunks/{chunk-2Q5K7J3B-BBPiCQqO.js → chunk-2Q5K7J3B-C7fGCGxg.js} +1 -1
- package/dist-embed/chunks/{chunk-2Q5K7J3B-P4f8Cifn.js → chunk-2Q5K7J3B-D1MNphVN.js} +1 -1
- package/dist-embed/chunks/{chunk-5VM5RSS4-BVaSZr_4.js → chunk-5VM5RSS4-BVhbsYB3.js} +1 -1
- package/dist-embed/chunks/{chunk-5VM5RSS4-CcNPo9qP.js → chunk-5VM5RSS4-Cj9Sj09E.js} +1 -1
- package/dist-embed/chunks/{chunk-F27PBJKO-DTgjd0wN.js → chunk-F27PBJKO-C6KAgeWn.js} +1 -1
- package/dist-embed/chunks/{chunk-F27PBJKO-C-90E7AT.js → chunk-F27PBJKO-DaHHRZRQ.js} +1 -1
- package/dist-embed/chunks/{chunk-IMKFNOWR-DuzpuE1w.js → chunk-IMKFNOWR-3wrc6d0Q.js} +1 -1
- package/dist-embed/chunks/{chunk-IMKFNOWR--OZX7QCt.js → chunk-IMKFNOWR-SYQLVKR9.js} +1 -1
- package/dist-embed/chunks/{chunk-JWPE2WC7-CAdvd3EQ.js → chunk-JWPE2WC7-BzDPwxUc.js} +1 -1
- package/dist-embed/chunks/{chunk-JWPE2WC7-OHowekj4.js → chunk-JWPE2WC7-hZ7wOnGa.js} +1 -1
- package/dist-embed/chunks/{chunk-POPQ4Y6H-BgLsR3l7.js → chunk-POPQ4Y6H-CjbywxMq.js} +1 -1
- package/dist-embed/chunks/{chunk-POPQ4Y6H-Dw1h_9lT.js → chunk-POPQ4Y6H-Z65qWIug.js} +1 -1
- package/dist-embed/chunks/{chunk-SVP7TREG-VsO48dck.js → chunk-SVP7TREG-Din3OYWe.js} +1 -1
- package/dist-embed/chunks/{chunk-SVP7TREG-kM9Erqyf.js → chunk-SVP7TREG-DleurvXy.js} +1 -1
- package/dist-embed/chunks/{chunk-TICWLB2K-pVdCft0o.js → chunk-TICWLB2K-Dx7w-18R.js} +1 -1
- package/dist-embed/chunks/{chunk-TICWLB2K-CU2oQRJ9.js → chunk-TICWLB2K-Z5NptHoD.js} +1 -1
- package/dist-embed/chunks/{chunk-XXDRQBXY-CL1cUI4w.js → chunk-XXDRQBXY-Ux5kMcSI.js} +1 -1
- package/dist-embed/chunks/{chunk-XXDRQBXY-BSfKSQ7y.js → chunk-XXDRQBXY-zWC-vTog.js} +1 -1
- package/dist-embed/chunks/{classDiagram-ZZMXUADV-Dq0Eb9fh.js → classDiagram-ZZMXUADV-D0QORYGn.js} +1 -1
- package/dist-embed/chunks/{classDiagram-ZZMXUADV-Ctw7VU-m.js → classDiagram-ZZMXUADV-DgHD5Kh0.js} +1 -1
- package/dist-embed/chunks/{classDiagram-f62afe4f-C8j4XsQw.js → classDiagram-f62afe4f-PiDp1Y3a.js} +1 -1
- package/dist-embed/chunks/{classDiagram-v2-604399ef-BVT78aGU.js → classDiagram-v2-604399ef-CW_LxcL4.js} +1 -1
- package/dist-embed/chunks/{classDiagram-v2-VYDZK3BY-Dq0Eb9fh.js → classDiagram-v2-VYDZK3BY-D0QORYGn.js} +1 -1
- package/dist-embed/chunks/{classDiagram-v2-VYDZK3BY-Ctw7VU-m.js → classDiagram-v2-VYDZK3BY-DgHD5Kh0.js} +1 -1
- package/dist-embed/chunks/{cose-bilkent-JH36ORCC-DEGpy0W8.js → cose-bilkent-JH36ORCC-CMAkTmJK.js} +1 -1
- package/dist-embed/chunks/{cose-bilkent-JH36ORCC-DrOmRWVI.js → cose-bilkent-JH36ORCC-iSI63fNY.js} +1 -1
- package/dist-embed/chunks/{createText-aed3d8b3-BukHQ1P8.js → createText-aed3d8b3-CsBZmLki.js} +1 -1
- package/dist-embed/chunks/{cs-CZ-2BRQDIVT-BJS7ofhJ.js → cs-CZ-2BRQDIVT-DrBOFpi4.js} +1 -1
- package/dist-embed/chunks/{cynefinDiagram-5FMLGOSQ-qZ6StjuY.js → cynefinDiagram-5FMLGOSQ-6nIBYQUF.js} +1 -1
- package/dist-embed/chunks/{cynefinDiagram-5FMLGOSQ-CnZ3wqXe.js → cynefinDiagram-5FMLGOSQ-BxwZiO0z.js} +1 -1
- package/dist-embed/chunks/cytoscape.esm-CkK8FqzY.js +321 -0
- package/dist-embed/chunks/{da-DK-5WZEPLOC-BHDT0zzh.js → da-DK-5WZEPLOC-G5bUTE3Z.js} +1 -1
- package/dist-embed/chunks/{dagre-GXQ25YYZ-Bb0_WA3x.js → dagre-GXQ25YYZ-DK_t5Dv9.js} +1 -1
- package/dist-embed/chunks/{dagre-GXQ25YYZ-Dbp_O7kO.js → dagre-GXQ25YYZ-lwpaVnIj.js} +1 -1
- package/dist-embed/chunks/{de-DE-XR44H4JA-CWVJKc9t.js → de-DE-XR44H4JA-Drpt3qDZ.js} +1 -1
- package/dist-embed/chunks/{diagram-S7CK7UJ4-CwINt91M.js → diagram-S7CK7UJ4-BKmPSO0V.js} +1 -1
- package/dist-embed/chunks/{diagram-S7CK7UJ4-DHPFd83P.js → diagram-S7CK7UJ4-pQiwoXZk.js} +1 -1
- package/dist-embed/chunks/{diagram-UQ7AKVKN-BqXFRP10.js → diagram-UQ7AKVKN-C6qjJbQl.js} +1 -1
- package/dist-embed/chunks/{diagram-UQ7AKVKN-CXRpfLBt.js → diagram-UQ7AKVKN-D5o3H3UE.js} +1 -1
- package/dist-embed/chunks/{diagram-VSXAHHWV-Bg68Bv82.js → diagram-VSXAHHWV-CEK3upG9.js} +1 -1
- package/dist-embed/chunks/{diagram-VSXAHHWV-DO0toZBQ.js → diagram-VSXAHHWV-DdWx8Pla.js} +1 -1
- package/dist-embed/chunks/{diagram-VX7I27RA-Diuc1eIf.js → diagram-VX7I27RA-CuAHZ13e.js} +1 -1
- package/dist-embed/chunks/{diagram-VX7I27RA-BEO0D7jE.js → diagram-VX7I27RA-HCEcXRxz.js} +1 -1
- package/dist-embed/chunks/{diagram-Z3DM3KII-BLJQK61P.js → diagram-Z3DM3KII-DIa0Aipv.js} +1 -1
- package/dist-embed/chunks/{diagram-Z3DM3KII-DtauJWd2.js → diagram-Z3DM3KII-H2dBkE-I.js} +1 -1
- package/dist-embed/chunks/{ebnfDiagram-PWID7BFC-SU3uN2_2.js → ebnfDiagram-PWID7BFC-Br2FcgwA.js} +1 -1
- package/dist-embed/chunks/{ebnfDiagram-PWID7BFC-6H6OSebp.js → ebnfDiagram-PWID7BFC-sUHCm_VG.js} +1 -1
- package/dist-embed/chunks/{edges-b2856ca0-DbD0XDJS.js → edges-b2856ca0-CZzjF187.js} +1 -1
- package/dist-embed/chunks/{el-GR-BZB4AONW-2z8DB9lI.js → el-GR-BZB4AONW-D4taPxaF.js} +1 -1
- package/dist-embed/chunks/{erDiagram-5d81789a-C-Tzt4MD.js → erDiagram-5d81789a-DUg4RLVT.js} +1 -1
- package/dist-embed/chunks/{erDiagram-RLTQ6QDP-DEAWMrMT.js → erDiagram-RLTQ6QDP-DCsulRKv.js} +1 -1
- package/dist-embed/chunks/{erDiagram-RLTQ6QDP-C_c-qnRZ.js → erDiagram-RLTQ6QDP-cQP1GN0_.js} +1 -1
- package/dist-embed/chunks/{es-ES-U4NZUMDT-DzXGWPd4.js → es-ES-U4NZUMDT-BvIGVphk.js} +1 -1
- package/dist-embed/chunks/{eu-ES-A7QVB2H4-CslHE4iE.js → eu-ES-A7QVB2H4-B8nvrNDk.js} +1 -1
- package/dist-embed/chunks/{fa-IR-HGAKTJCU-CBWUHs2r.js → fa-IR-HGAKTJCU-hwisHoU4.js} +1 -1
- package/dist-embed/chunks/{fi-FI-Z5N7JZ37-MAr8kZMI.js → fi-FI-Z5N7JZ37-DKrDvTXs.js} +1 -1
- package/dist-embed/chunks/{flowDb-185abca5-Di4aD0Mg.js → flowDb-185abca5-CEMVC-K6.js} +1 -1
- package/dist-embed/chunks/{flowDiagram-1629c991-fImernS2.js → flowDiagram-1629c991-AKV5j4oK.js} +1 -1
- package/dist-embed/chunks/{flowDiagram-HODETNUW-Hr-elwWq.js → flowDiagram-HODETNUW-BIHDtose.js} +1 -1
- package/dist-embed/chunks/{flowDiagram-HODETNUW-DzoskzA4.js → flowDiagram-HODETNUW-BfzQD7wt.js} +1 -1
- package/dist-embed/chunks/{flowDiagram-v2-1d953310-P1qDfDo-.js → flowDiagram-v2-1d953310-76wyGX0j.js} +1 -1
- package/dist-embed/chunks/{flowchart-elk-definition-6df44142-CXebTCvX.js → flowchart-elk-definition-6df44142-Cr_kl0fu.js} +1 -1
- package/dist-embed/chunks/{fr-FR-RHASNOE6-BUz3aHQJ.js → fr-FR-RHASNOE6-DPtlBK_j.js} +1 -1
- package/dist-embed/chunks/{ganttDiagram-3b0b3873-Bupos8HO.js → ganttDiagram-3b0b3873-DVqXF_B7.js} +1 -1
- package/dist-embed/chunks/{ganttDiagram-EL5Y4UJY-e3WDalFj.js → ganttDiagram-EL5Y4UJY-BM0LLRNH.js} +1 -1
- package/dist-embed/chunks/{ganttDiagram-EL5Y4UJY-3bErrKpg.js → ganttDiagram-EL5Y4UJY-DCVqUGh7.js} +1 -1
- package/dist-embed/chunks/{gitGraphDiagram-WWUBYQGX-Ck49f0H9.js → gitGraphDiagram-WWUBYQGX-DjJtEXHN.js} +1 -1
- package/dist-embed/chunks/{gitGraphDiagram-WWUBYQGX-BiEolUQH.js → gitGraphDiagram-WWUBYQGX-YSQk7-wR.js} +1 -1
- package/dist-embed/chunks/{gitGraphDiagram-f01e8bc2-DM8FMetI.js → gitGraphDiagram-f01e8bc2-BH1XJn2D.js} +1 -1
- package/dist-embed/chunks/{gl-ES-HMX3MZ6V-DvzQmDYv.js → gl-ES-HMX3MZ6V-B1ngwQkd.js} +1 -1
- package/dist-embed/chunks/{he-IL-6SHJWFNN-DKR3cKyQ.js → he-IL-6SHJWFNN-BaoAQZ3f.js} +1 -1
- package/dist-embed/chunks/{hi-IN-IWLTKZ5I-C4tyBNwa.js → hi-IN-IWLTKZ5I-DzPeRmLM.js} +1 -1
- package/dist-embed/chunks/{hu-HU-A5ZG7DT2-C8BnBgH5.js → hu-HU-A5ZG7DT2-BgLcm8oA.js} +1 -1
- package/dist-embed/chunks/{id-ID-SAP4L64H-Bn1hY5OS.js → id-ID-SAP4L64H-egIA8l8_.js} +1 -1
- package/dist-embed/chunks/{index-9bae90f3-l9tb84fw.js → index-9bae90f3-BseCAzrq.js} +1 -1
- package/dist-embed/chunks/{index-DdBQBN76.js → index-BKOQQ5Ku.js} +1 -1
- package/dist-embed/chunks/{index-_nsBY26B.js → index-cYM4KfdD.js} +1 -1
- package/dist-embed/chunks/{index-TDpnbl90.js → index-f-GkP02b.js} +3 -3
- package/dist-embed/chunks/{infoDiagram-27XIBGKW-BjyM865y.js → infoDiagram-27XIBGKW-BynJ6kmj.js} +1 -1
- package/dist-embed/chunks/{infoDiagram-27XIBGKW-8DlnjSdf.js → infoDiagram-27XIBGKW-qGpBVlZj.js} +1 -1
- package/dist-embed/chunks/{infoDiagram-a29d40f1-DXYFLipl.js → infoDiagram-a29d40f1-Owe2jwDJ.js} +1 -1
- package/dist-embed/chunks/{ishikawaDiagram-5VMMS53U-Bb5g5HNe.js → ishikawaDiagram-5VMMS53U-DNmI4uap.js} +1 -1
- package/dist-embed/chunks/{ishikawaDiagram-5VMMS53U-ri4cvaWs.js → ishikawaDiagram-5VMMS53U-mpS3ncPp.js} +1 -1
- package/dist-embed/chunks/{it-IT-JPQ66NNP-DEiaanA7.js → it-IT-JPQ66NNP-DDwc6pzw.js} +1 -1
- package/dist-embed/chunks/{ja-JP-DBVTYXUO-Bb0GBZrQ.js → ja-JP-DBVTYXUO-TrA2khDT.js} +1 -1
- package/dist-embed/chunks/{journeyDiagram-3NMN7TZE-96VNFopN.js → journeyDiagram-3NMN7TZE-DqBMQuJL.js} +1 -1
- package/dist-embed/chunks/{journeyDiagram-3NMN7TZE-BpYgEBLO.js → journeyDiagram-3NMN7TZE-DsfwhZ-B.js} +1 -1
- package/dist-embed/chunks/{journeyDiagram-95396277-CQ_kN2gp.js → journeyDiagram-95396277-B8XX3m66.js} +1 -1
- package/dist-embed/chunks/{kaa-6HZHGXH3-DxqTv9uN.js → kaa-6HZHGXH3-GwFnOAIz.js} +1 -1
- package/dist-embed/chunks/{kab-KAB-ZGHBKWFO-D0V0yQgV.js → kab-KAB-ZGHBKWFO-xYS1Kjfb.js} +1 -1
- package/dist-embed/chunks/{kanban-definition-UXKFOSKX-BPsXEKm4.js → kanban-definition-UXKFOSKX-CqtUdtwN.js} +1 -1
- package/dist-embed/chunks/{kanban-definition-UXKFOSKX-B5nUu45Q.js → kanban-definition-UXKFOSKX-DZ3oSdBN.js} +1 -1
- package/dist-embed/chunks/{kk-KZ-P5N5QNE5-CYyEyHXW.js → kk-KZ-P5N5QNE5-BwDJRk5I.js} +1 -1
- package/dist-embed/chunks/{km-KH-HSX4SM5Z-CCTEGikY.js → km-KH-HSX4SM5Z-Di9J-9zc.js} +1 -1
- package/dist-embed/chunks/{ko-KR-MTYHY66A-C-QDut19.js → ko-KR-MTYHY66A-BxF1Locw.js} +1 -1
- package/dist-embed/chunks/{ku-TR-6OUDTVRD-CIqn8p2Y.js → ku-TR-6OUDTVRD-mGflwIcv.js} +1 -1
- package/dist-embed/chunks/{layout-Dq0J6INj.js → layout-BnRN5gq_.js} +1 -1
- package/dist-embed/chunks/{layout-Bdtul_rg.js → layout-DC8Z4Z6o.js} +1 -1
- package/dist-embed/chunks/{lt-LT-XHIRWOB4-BDLUWFPH.js → lt-LT-XHIRWOB4-DWluphZ2.js} +1 -1
- package/dist-embed/chunks/{lv-LV-5QDEKY6T-BItabIJP.js → lv-LV-5QDEKY6T-D9EEzVQ9.js} +1 -1
- package/dist-embed/chunks/{mermaid.core-B9dEBs01.js → mermaid.core-ByLffeZ_.js} +3 -3
- package/dist-embed/chunks/{mermaid.core-pflA3DMC.js → mermaid.core-DuyFjpK0.js} +2 -2
- package/dist-embed/chunks/{mindmap-definition-YA3MSWOX-DwLQYAqQ.js → mindmap-definition-YA3MSWOX-C2mblKem.js} +1 -1
- package/dist-embed/chunks/{mindmap-definition-YA3MSWOX-CEuIjXO2.js → mindmap-definition-YA3MSWOX-D7nlPwYz.js} +1 -1
- package/dist-embed/chunks/{mindmap-definition-e4c1d938-CDWIPlcb.js → mindmap-definition-e4c1d938-awL4Gg2X.js} +1 -1
- package/dist-embed/chunks/{mr-IN-CRQNXWMA-DXXb8N2w.js → mr-IN-CRQNXWMA-DoMvP_Jp.js} +1 -1
- package/dist-embed/chunks/{my-MM-5M5IBNSE-TidIfjqS.js → my-MM-5M5IBNSE-CPPbx93K.js} +1 -1
- package/dist-embed/chunks/{nb-NO-T6EIAALU-DEINynK7.js → nb-NO-T6EIAALU-m2hgNNww.js} +1 -1
- package/dist-embed/chunks/{nl-NL-IS3SIHDZ-D04rJzNe.js → nl-NL-IS3SIHDZ-B809T0Iy.js} +1 -1
- package/dist-embed/chunks/{nn-NO-6E72VCQL-oWFzCtpf.js → nn-NO-6E72VCQL-DcMxKEVg.js} +1 -1
- package/dist-embed/chunks/{oc-FR-POXYY2M6-BmFfP6hk.js → oc-FR-POXYY2M6-BZTBaY64.js} +1 -1
- package/dist-embed/chunks/{pa-IN-N4M65BXN-RkXrgKXw.js → pa-IN-N4M65BXN-Cs4i3fnS.js} +1 -1
- package/dist-embed/chunks/{pegDiagram-XKGWAZYB-CqRRvKft.js → pegDiagram-XKGWAZYB-C0HQw4rE.js} +1 -1
- package/dist-embed/chunks/{pegDiagram-XKGWAZYB-Cwo6HzRh.js → pegDiagram-XKGWAZYB-C4-dNtcP.js} +1 -1
- package/dist-embed/chunks/{percentages-BXMCSKIN-BL_DuU3S.js → percentages-BXMCSKIN-D82iCuEy.js} +5 -5
- package/dist-embed/chunks/{pieDiagram-E7YTZNPT-CkHpKSua.js → pieDiagram-E7YTZNPT-CWACe1aa.js} +1 -1
- package/dist-embed/chunks/{pieDiagram-E7YTZNPT-BvBHesgq.js → pieDiagram-E7YTZNPT-x7B2jJsE.js} +1 -1
- package/dist-embed/chunks/{pieDiagram-c941bede-Bsn1Bxk5.js → pieDiagram-c941bede-BJhm1wRV.js} +1 -1
- package/dist-embed/chunks/{pl-PL-T2D74RX3-DqxkHzTj.js → pl-PL-T2D74RX3-B3jg7qOY.js} +1 -1
- package/dist-embed/chunks/{pt-BR-5N22H2LF-DFA-wWC5.js → pt-BR-5N22H2LF-aCJuloaY.js} +1 -1
- package/dist-embed/chunks/{pt-PT-UZXXM6DQ-Z5jw_7aw.js → pt-PT-UZXXM6DQ-8ZZdQp1P.js} +1 -1
- package/dist-embed/chunks/{quadrantDiagram-AXDQQJYC-nOA8Q9nG.js → quadrantDiagram-AXDQQJYC-B2ESxruT.js} +1 -1
- package/dist-embed/chunks/{quadrantDiagram-AXDQQJYC-AaQ_WgXa.js → quadrantDiagram-AXDQQJYC-BbhdvJg_.js} +1 -1
- package/dist-embed/chunks/{quadrantDiagram-cf8b8fe0-BhaNj-gz.js → quadrantDiagram-cf8b8fe0-DFqECCQX.js} +1 -1
- package/dist-embed/chunks/{railroadDiagram-O6MQD6OU-BlWFu3pn.js → railroadDiagram-O6MQD6OU-BTh6yg3I.js} +1 -1
- package/dist-embed/chunks/{railroadDiagram-O6MQD6OU-D-SNyKIn.js → railroadDiagram-O6MQD6OU-DoXeTqA2.js} +1 -1
- package/dist-embed/chunks/{requirementDiagram-53bda41b-C2WctYyl.js → requirementDiagram-53bda41b-233jV4qD.js} +1 -1
- package/dist-embed/chunks/{requirementDiagram-BXWQKSXE-BpWNFdrw.js → requirementDiagram-BXWQKSXE-D5XQ2Scv.js} +1 -1
- package/dist-embed/chunks/{requirementDiagram-BXWQKSXE-1A97ivzl.js → requirementDiagram-BXWQKSXE-vJkUGd2z.js} +1 -1
- package/dist-embed/chunks/{ro-RO-JPDTUUEW-DjC09bHq.js → ro-RO-JPDTUUEW-BmyO5zyl.js} +1 -1
- package/dist-embed/chunks/{ru-RU-B4JR7IUQ-CqwD7Yik.js → ru-RU-B4JR7IUQ-BneR_2Bm.js} +1 -1
- package/dist-embed/chunks/{sankeyDiagram-P5KCCOFB-DnT5kYW5.js → sankeyDiagram-P5KCCOFB-CgYfp9h2.js} +1 -1
- package/dist-embed/chunks/{sankeyDiagram-P5KCCOFB-ktT6v9aY.js → sankeyDiagram-P5KCCOFB-QAiE8XmR.js} +1 -1
- package/dist-embed/chunks/{sankeyDiagram-c3ef121a-3FD4GIJS.js → sankeyDiagram-c3ef121a-DhSOAdSF.js} +1 -1
- package/dist-embed/chunks/{sequenceDiagram-82a5b84f-CZQmoHAd.js → sequenceDiagram-82a5b84f-B0t7Tj-b.js} +1 -1
- package/dist-embed/chunks/{sequenceDiagram-WJ2MYXX4-DYY-dZgX.js → sequenceDiagram-WJ2MYXX4-BGKoZhUS.js} +1 -1
- package/dist-embed/chunks/{sequenceDiagram-WJ2MYXX4-0HHgJN0L.js → sequenceDiagram-WJ2MYXX4-DXK8x-A3.js} +1 -1
- package/dist-embed/chunks/{si-LK-N5RQ5JYF-OVf4k6G3.js → si-LK-N5RQ5JYF-CDB0IyVm.js} +1 -1
- package/dist-embed/chunks/{sizeCapture-INFHLROL-CIF2j9e_.js → sizeCapture-INFHLROL-3hkP3c7K.js} +1 -1
- package/dist-embed/chunks/{sizeCapture-INFHLROL-DJOph387.js → sizeCapture-INFHLROL-DXauv4Y7.js} +1 -1
- package/dist-embed/chunks/{sk-SK-C5VTKIMK-BG__kjLT.js → sk-SK-C5VTKIMK-ypZmPMe_.js} +1 -1
- package/dist-embed/chunks/{sl-SI-NN7IZMDC-CIgxidVH.js → sl-SI-NN7IZMDC-D9OrZXr7.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-43e79a5f-CMlUXY1x.js → stateDiagram-43e79a5f-3R5UYfNv.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-D77RDMKH-DVd0MOrg.js → stateDiagram-D77RDMKH-BoSlS4yd.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-D77RDMKH-CkICPC-C.js → stateDiagram-D77RDMKH-DsdKjDDe.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-v2-2041ed4f-BcO6vvJA.js → stateDiagram-v2-2041ed4f-CyKuuET1.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-v2-MP3YSRHH-BFlXwfgz.js → stateDiagram-v2-MP3YSRHH-C2VJiq4Z.js} +1 -1
- package/dist-embed/chunks/{stateDiagram-v2-MP3YSRHH-CJD5_Eji.js → stateDiagram-v2-MP3YSRHH-TtXiA-HS.js} +1 -1
- package/dist-embed/chunks/{styles-455b33cd-BfyZJvzN.js → styles-455b33cd-cllC-9In.js} +1 -1
- package/dist-embed/chunks/{styles-f932cba9-k2wfF-9Q.js → styles-f932cba9-2fKnoRJu.js} +1 -1
- package/dist-embed/chunks/{styles-fcc2142b-z3csTkbW.js → styles-fcc2142b-CXaxs3wc.js} +1 -1
- package/dist-embed/chunks/{subset-shared.chunk-BR0LJHtQ.js → subset-shared.chunk-cQajIUFT.js} +1 -1
- package/dist-embed/chunks/{subset-worker.chunk-52aAcjvz.js → subset-worker.chunk-DEC9qaDu.js} +1 -1
- package/dist-embed/chunks/{sv-SE-XGPEYMSR-CYHz3xCa.js → sv-SE-XGPEYMSR-CXBRqMMZ.js} +1 -1
- package/dist-embed/chunks/{svgDrawCommon-148a3cd9-NqUFgQ9x.js → svgDrawCommon-148a3cd9-C_mmNgT0.js} +1 -1
- package/dist-embed/chunks/{swimlanes-42K2YHIH-Cj4fdAYa.js → swimlanes-42K2YHIH-DBmDt5_R.js} +1 -1
- package/dist-embed/chunks/{swimlanes-42K2YHIH-B6pxWv6a.js → swimlanes-42K2YHIH-DPaziYXM.js} +1 -1
- package/dist-embed/chunks/{swimlanesDiagram-VR7AAH4N-B9ThT6OH.js → swimlanesDiagram-VR7AAH4N-9_IwhHVD.js} +1 -1
- package/dist-embed/chunks/{swimlanesDiagram-VR7AAH4N-B2gk37ys.js → swimlanesDiagram-VR7AAH4N-BdhVhC9l.js} +1 -1
- package/dist-embed/chunks/{ta-IN-2NMHFXQM-BphRr9QY.js → ta-IN-2NMHFXQM-BuB9HEjH.js} +1 -1
- package/dist-embed/chunks/{th-TH-HPSO5L25-Ba2-2Bo0.js → th-TH-HPSO5L25-Ci7wR5dZ.js} +1 -1
- package/dist-embed/chunks/{timeline-definition-24CTP7MA-DVcslyxd.js → timeline-definition-24CTP7MA-C4jDoC-u.js} +1 -1
- package/dist-embed/chunks/{timeline-definition-24CTP7MA-D5dMAy5U.js → timeline-definition-24CTP7MA-DnvUO3eu.js} +1 -1
- package/dist-embed/chunks/{timeline-definition-7545f45a-IhzNtIcW.js → timeline-definition-7545f45a-CG-isB_y.js} +1 -1
- package/dist-embed/chunks/{tr-TR-DEFEU3FU-CRKE7Roy.js → tr-TR-DEFEU3FU-CEJUT8zN.js} +1 -1
- package/dist-embed/chunks/{uk-UA-QMV73CPH-DlNE5CAT.js → uk-UA-QMV73CPH-Ceh5JIiD.js} +1 -1
- package/dist-embed/chunks/{vennDiagram-4TSXK5OY-KKysbuVs.js → vennDiagram-4TSXK5OY-Bgmm4KpJ.js} +1 -1
- package/dist-embed/chunks/{vennDiagram-4TSXK5OY-BMg6wc5A.js → vennDiagram-4TSXK5OY-WtB0-hBJ.js} +1 -1
- package/dist-embed/chunks/{vi-VN-M7AON7JQ-Cp44PRXY.js → vi-VN-M7AON7JQ-8-R9Ohxp.js} +1 -1
- package/dist-embed/chunks/{wardleyDiagram-VM6X3IG4-C5wMQ_qe.js → wardleyDiagram-VM6X3IG4-CbfSwLlj.js} +1 -1
- package/dist-embed/chunks/{wardleyDiagram-VM6X3IG4-CTed9ps7.js → wardleyDiagram-VM6X3IG4-Do_iO_Kw.js} +1 -1
- package/dist-embed/chunks/{xychartDiagram-3f383b91-CsxcWMT8.js → xychartDiagram-3f383b91-DisZWvLI.js} +1 -1
- package/dist-embed/chunks/{xychartDiagram-S5SC5T6Z-DthHDnAV.js → xychartDiagram-S5SC5T6Z-BImS3ikl.js} +1 -1
- package/dist-embed/chunks/{xychartDiagram-S5SC5T6Z-Kpqryflz.js → xychartDiagram-S5SC5T6Z-DaRNje_l.js} +1 -1
- package/dist-embed/chunks/{zh-CN-LNUGB5OW-JHqqwp0j.js → zh-CN-LNUGB5OW-D4q5wqKm.js} +1 -1
- package/dist-embed/chunks/{zh-HK-E62DVLB3-YEs97mA8.js → zh-HK-E62DVLB3-_UiIVKpk.js} +1 -1
- package/dist-embed/chunks/{zh-TW-RAJ6MFWO-CgmeTbuy.js → zh-TW-RAJ6MFWO-DyXZ-PXI.js} +1 -1
- package/dist-embed/datalayer-app-main.js +4 -4
- package/lib/specs/appspecSchema.js +2 -0
- package/package.json +1 -1
- package/dist-embed/chunks/cytoscape.esm-0l7yjBbd.js +0 -321
|
@@ -3629,7 +3629,7 @@ ${lo}</tr>
|
|
|
3629
3629
|
`}tablecell(lo){let $u=this.parser.parseInline(lo.tokens),Ru=lo.header?"th":"td";return(lo.align?`<${Ru} align="${lo.align}">`:`<${Ru}>`)+$u+`</${Ru}>
|
|
3630
3630
|
`}strong({tokens:lo}){return`<strong>${this.parser.parseInline(lo)}</strong>`}em({tokens:lo}){return`<em>${this.parser.parseInline(lo)}</em>`}codespan({text:lo}){return`<code>${w$2(lo,!0)}</code>`}br(lo){return"<br>"}del({tokens:lo}){return`<del>${this.parser.parseInline(lo)}</del>`}link({href:lo,title:$u,tokens:Ru}){let Iu=this.parser.parseInline(Ru),Pu=J$2(lo);if(Pu===null)return Iu;lo=Pu;let Ou='<a href="'+lo+'"';return $u&&(Ou+=' title="'+w$2($u)+'"'),Ou+=">"+Iu+"</a>",Ou}image({href:lo,title:$u,text:Ru,tokens:Iu}){Iu&&(Ru=this.parser.parseInline(Iu,this.parser.textRenderer));let Pu=J$2(lo);if(Pu===null)return w$2(Ru);lo=Pu;let Ou=`<img src="${lo}" alt="${Ru}"`;return $u&&(Ou+=` title="${w$2($u)}"`),Ou+=">",Ou}text(lo){return"tokens"in lo&&lo.tokens?this.parser.parseInline(lo.tokens):"escaped"in lo&&lo.escaped?lo.text:w$2(lo.text)}},$$1=class{strong({text:lo}){return lo}em({text:lo}){return lo}codespan({text:lo}){return lo}del({text:lo}){return lo}html({text:lo}){return lo}text({text:lo}){return lo}link({text:lo}){return""+lo}image({text:lo}){return""+lo}br(){return""}},b$5=class $_{options;renderer;textRenderer;constructor(lo){this.options=lo||T$1,this.options.renderer=this.options.renderer||new P$3,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new $$1}static parse(lo,$u){return new $_($u).parse(lo)}static parseInline(lo,$u){return new $_($u).parseInline(lo)}parse(lo,$u=!0){let Ru="";for(let Iu=0;Iu<lo.length;Iu++){let Pu=lo[Iu];if(this.options.extensions?.renderers?.[Pu.type]){let Mu=Pu,Du=this.options.extensions.renderers[Mu.type].call({parser:this},Mu);if(Du!==!1||!["space","hr","heading","code","table","blockquote","list","html","def","paragraph","text"].includes(Mu.type)){Ru+=Du||"";continue}}let Ou=Pu;switch(Ou.type){case"space":{Ru+=this.renderer.space(Ou);continue}case"hr":{Ru+=this.renderer.hr(Ou);continue}case"heading":{Ru+=this.renderer.heading(Ou);continue}case"code":{Ru+=this.renderer.code(Ou);continue}case"table":{Ru+=this.renderer.table(Ou);continue}case"blockquote":{Ru+=this.renderer.blockquote(Ou);continue}case"list":{Ru+=this.renderer.list(Ou);continue}case"html":{Ru+=this.renderer.html(Ou);continue}case"def":{Ru+=this.renderer.def(Ou);continue}case"paragraph":{Ru+=this.renderer.paragraph(Ou);continue}case"text":{let Mu=Ou,Du=this.renderer.text(Mu);for(;Iu+1<lo.length&&lo[Iu+1].type==="text";)Mu=lo[++Iu],Du+=`
|
|
3631
3631
|
`+this.renderer.text(Mu);$u?Ru+=this.renderer.paragraph({type:"paragraph",raw:Du,text:Du,tokens:[{type:"text",raw:Du,text:Du,escaped:!0}]}):Ru+=Du;continue}default:{let Mu='Token with "'+Ou.type+'" type was not found.';if(this.options.silent)return console.error(Mu),"";throw new Error(Mu)}}}return Ru}parseInline(lo,$u=this.renderer){let Ru="";for(let Iu=0;Iu<lo.length;Iu++){let Pu=lo[Iu];if(this.options.extensions?.renderers?.[Pu.type]){let Mu=this.options.extensions.renderers[Pu.type].call({parser:this},Pu);if(Mu!==!1||!["escape","html","link","image","strong","em","codespan","br","del","text"].includes(Pu.type)){Ru+=Mu||"";continue}}let Ou=Pu;switch(Ou.type){case"escape":{Ru+=$u.text(Ou);break}case"html":{Ru+=$u.html(Ou);break}case"link":{Ru+=$u.link(Ou);break}case"image":{Ru+=$u.image(Ou);break}case"strong":{Ru+=$u.strong(Ou);break}case"em":{Ru+=$u.em(Ou);break}case"codespan":{Ru+=$u.codespan(Ou);break}case"br":{Ru+=$u.br(Ou);break}case"del":{Ru+=$u.del(Ou);break}case"text":{Ru+=$u.text(Ou);break}default:{let Mu='Token with "'+Ou.type+'" type was not found.';if(this.options.silent)return console.error(Mu),"";throw new Error(Mu)}}}return Ru}},S$2=class{options;block;constructor(lo){this.options=lo||T$1}static passThroughHooks=new Set(["preprocess","postprocess","processAllTokens","emStrongMask"]);static passThroughHooksRespectAsync=new Set(["preprocess","postprocess","processAllTokens"]);preprocess(lo){return lo}postprocess(lo){return lo}processAllTokens(lo){return lo}emStrongMask(lo){return lo}provideLexer(){return this.block?x$7.lex:x$7.lexInline}provideParser(){return this.block?b$5.parse:b$5.parseInline}},B$2=class{defaults=L$2();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=b$5;Renderer=P$3;TextRenderer=$$1;Lexer=x$7;Tokenizer=y$4;Hooks=S$2;constructor(...lo){this.use(...lo)}walkTokens(lo,$u){let Ru=[];for(let Iu of lo)switch(Ru=Ru.concat($u.call(this,Iu)),Iu.type){case"table":{let Pu=Iu;for(let Ou of Pu.header)Ru=Ru.concat(this.walkTokens(Ou.tokens,$u));for(let Ou of Pu.rows)for(let Mu of Ou)Ru=Ru.concat(this.walkTokens(Mu.tokens,$u));break}case"list":{let Pu=Iu;Ru=Ru.concat(this.walkTokens(Pu.items,$u));break}default:{let Pu=Iu;this.defaults.extensions?.childTokens?.[Pu.type]?this.defaults.extensions.childTokens[Pu.type].forEach(Ou=>{let Mu=Pu[Ou].flat(1/0);Ru=Ru.concat(this.walkTokens(Mu,$u))}):Pu.tokens&&(Ru=Ru.concat(this.walkTokens(Pu.tokens,$u)))}}return Ru}use(...lo){let $u=this.defaults.extensions||{renderers:{},childTokens:{}};return lo.forEach(Ru=>{let Iu={...Ru};if(Iu.async=this.defaults.async||Iu.async||!1,Ru.extensions&&(Ru.extensions.forEach(Pu=>{if(!Pu.name)throw new Error("extension name required");if("renderer"in Pu){let Ou=$u.renderers[Pu.name];Ou?$u.renderers[Pu.name]=function(...Mu){let Du=Pu.renderer.apply(this,Mu);return Du===!1&&(Du=Ou.apply(this,Mu)),Du}:$u.renderers[Pu.name]=Pu.renderer}if("tokenizer"in Pu){if(!Pu.level||Pu.level!=="block"&&Pu.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let Ou=$u[Pu.level];Ou?Ou.unshift(Pu.tokenizer):$u[Pu.level]=[Pu.tokenizer],Pu.start&&(Pu.level==="block"?$u.startBlock?$u.startBlock.push(Pu.start):$u.startBlock=[Pu.start]:Pu.level==="inline"&&($u.startInline?$u.startInline.push(Pu.start):$u.startInline=[Pu.start]))}"childTokens"in Pu&&Pu.childTokens&&($u.childTokens[Pu.name]=Pu.childTokens)}),Iu.extensions=$u),Ru.renderer){let Pu=this.defaults.renderer||new P$3(this.defaults);for(let Ou in Ru.renderer){if(!(Ou in Pu))throw new Error(`renderer '${Ou}' does not exist`);if(["options","parser"].includes(Ou))continue;let Mu=Ou,Du=Ru.renderer[Mu],Lu=Pu[Mu];Pu[Mu]=(...Bu)=>{let ju=Du.apply(Pu,Bu);return ju===!1&&(ju=Lu.apply(Pu,Bu)),ju||""}}Iu.renderer=Pu}if(Ru.tokenizer){let Pu=this.defaults.tokenizer||new y$4(this.defaults);for(let Ou in Ru.tokenizer){if(!(Ou in Pu))throw new Error(`tokenizer '${Ou}' does not exist`);if(["options","rules","lexer"].includes(Ou))continue;let Mu=Ou,Du=Ru.tokenizer[Mu],Lu=Pu[Mu];Pu[Mu]=(...Bu)=>{let ju=Du.apply(Pu,Bu);return ju===!1&&(ju=Lu.apply(Pu,Bu)),ju}}Iu.tokenizer=Pu}if(Ru.hooks){let Pu=this.defaults.hooks||new S$2;for(let Ou in Ru.hooks){if(!(Ou in Pu))throw new Error(`hook '${Ou}' does not exist`);if(["options","block"].includes(Ou))continue;let Mu=Ou,Du=Ru.hooks[Mu],Lu=Pu[Mu];S$2.passThroughHooks.has(Ou)?Pu[Mu]=Bu=>{if(this.defaults.async&&S$2.passThroughHooksRespectAsync.has(Ou))return(async()=>{let Fu=await Du.call(Pu,Bu);return Lu.call(Pu,Fu)})();let ju=Du.call(Pu,Bu);return Lu.call(Pu,ju)}:Pu[Mu]=(...Bu)=>{if(this.defaults.async)return(async()=>{let Fu=await Du.apply(Pu,Bu);return Fu===!1&&(Fu=await Lu.apply(Pu,Bu)),Fu})();let ju=Du.apply(Pu,Bu);return ju===!1&&(ju=Lu.apply(Pu,Bu)),ju}}Iu.hooks=Pu}if(Ru.walkTokens){let Pu=this.defaults.walkTokens,Ou=Ru.walkTokens;Iu.walkTokens=function(Mu){let Du=[];return Du.push(Ou.call(this,Mu)),Pu&&(Du=Du.concat(Pu.call(this,Mu))),Du}}this.defaults={...this.defaults,...Iu}}),this}setOptions(lo){return this.defaults={...this.defaults,...lo},this}lexer(lo,$u){return x$7.lex(lo,$u??this.defaults)}parser(lo,$u){return b$5.parse(lo,$u??this.defaults)}parseMarkdown(lo){return($u,Ru)=>{let Iu={...Ru},Pu={...this.defaults,...Iu},Ou=this.onError(!!Pu.silent,!!Pu.async);if(this.defaults.async===!0&&Iu.async===!1)return Ou(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof $u>"u"||$u===null)return Ou(new Error("marked(): input parameter is undefined or null"));if(typeof $u!="string")return Ou(new Error("marked(): input parameter is of type "+Object.prototype.toString.call($u)+", string expected"));if(Pu.hooks&&(Pu.hooks.options=Pu,Pu.hooks.block=lo),Pu.async)return(async()=>{let Mu=Pu.hooks?await Pu.hooks.preprocess($u):$u,Du=await(Pu.hooks?await Pu.hooks.provideLexer():lo?x$7.lex:x$7.lexInline)(Mu,Pu),Lu=Pu.hooks?await Pu.hooks.processAllTokens(Du):Du;Pu.walkTokens&&await Promise.all(this.walkTokens(Lu,Pu.walkTokens));let Bu=await(Pu.hooks?await Pu.hooks.provideParser():lo?b$5.parse:b$5.parseInline)(Lu,Pu);return Pu.hooks?await Pu.hooks.postprocess(Bu):Bu})().catch(Ou);try{Pu.hooks&&($u=Pu.hooks.preprocess($u));let Mu=(Pu.hooks?Pu.hooks.provideLexer():lo?x$7.lex:x$7.lexInline)($u,Pu);Pu.hooks&&(Mu=Pu.hooks.processAllTokens(Mu)),Pu.walkTokens&&this.walkTokens(Mu,Pu.walkTokens);let Du=(Pu.hooks?Pu.hooks.provideParser():lo?b$5.parse:b$5.parseInline)(Mu,Pu);return Pu.hooks&&(Du=Pu.hooks.postprocess(Du)),Du}catch(Mu){return Ou(Mu)}}}onError(lo,$u){return Ru=>{if(Ru.message+=`
|
|
3632
|
-
Please report this to https://github.com/markedjs/marked.`,lo){let Iu="<p>An error occurred:</p><pre>"+w$2(Ru.message+"",!0)+"</pre>";return $u?Promise.resolve(Iu):Iu}if($u)return Promise.reject(Ru);throw Ru}}},_$4=new B$2;function k$2(Au,lo){return _$4.parse(Au,lo)}k$2.options=k$2.setOptions=function(Au){return _$4.setOptions(Au),k$2.defaults=_$4.defaults,G$1(k$2.defaults),k$2};k$2.getDefaults=L$2;k$2.defaults=T$1;k$2.use=function(...Au){return _$4.use(...Au),k$2.defaults=_$4.defaults,G$1(k$2.defaults),k$2};k$2.walkTokens=function(Au,lo){return _$4.walkTokens(Au,lo)};k$2.parseInline=_$4.parseInline;k$2.Parser=b$5;k$2.parser=b$5.parse;k$2.Renderer=P$3;k$2.TextRenderer=$$1;k$2.Lexer=x$7;k$2.lexer=x$7.lex;k$2.Tokenizer=y$4;k$2.Hooks=S$2;k$2.parse=k$2;k$2.options;k$2.setOptions;k$2.use;k$2.walkTokens;k$2.parseInline;b$5.parse;x$7.lex;var u$2=(...Au)=>twMerge(clsx(Au)),R$2=(Au,lo,$u)=>{let Ru=typeof lo=="string"?new Blob([lo],{type:$u}):lo,Iu=URL.createObjectURL(Ru),Pu=document.createElement("a");Pu.href=Iu,Pu.download=Au,document.body.appendChild(Pu),Pu.click(),document.body.removeChild(Pu),URL.revokeObjectURL(Iu)},Dt$4=reactExports.createContext({code:""}),U$2=()=>reactExports.useContext(Dt$4),ie$4=({onCopy:Au,onError:lo,timeout:$u=2e3,children:Ru,className:Iu,code:Pu,...Ou})=>{let[Mu,Du]=reactExports.useState(!1),Lu=reactExports.useRef(0),{code:Bu}=U$2(),{isAnimating:ju}=reactExports.useContext(C$1),Fu=Pu??Bu,zu=async()=>{var Hu;if(typeof window>"u"||!((Hu=navigator?.clipboard)!=null&&Hu.writeText)){lo?.(new Error("Clipboard API not available"));return}try{Mu||(await navigator.clipboard.writeText(Fu),Du(!0),Au?.(),Lu.current=window.setTimeout(()=>Du(!1),$u))}catch(Vu){lo?.(Vu)}};reactExports.useEffect(()=>()=>{window.clearTimeout(Lu.current)},[]);let Uu=Mu?Check:Copy;return jsxRuntimeExports.jsx("button",{className:u$2("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",Iu),"data-streamdown":"code-block-copy-button",disabled:ju,onClick:zu,title:"Copy Code",type:"button",...Ou,children:Ru??jsxRuntimeExports.jsx(Uu,{size:14})})},xe$2={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",文言:"wy"},Me$3=({onDownload:Au,onError:lo,language:$u,children:Ru,className:Iu,code:Pu,...Ou})=>{let{code:Mu}=U$2(),{isAnimating:Du}=reactExports.useContext(C$1),Lu=Pu??Mu,Bu=`file.${$u&&$u in xe$2?xe$2[$u]:"txt"}`,ju="text/plain",Fu=()=>{try{R$2(Bu,Lu,ju),Au?.()}catch(zu){lo?.(zu)}};return jsxRuntimeExports.jsx("button",{className:u$2("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",Iu),"data-streamdown":"code-block-download-button",disabled:Du,onClick:Fu,title:"Download file",type:"button",...Ou,children:Ru??jsxRuntimeExports.jsx(Download$1,{size:14})})},de$3=()=>jsxRuntimeExports.jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[jsxRuntimeExports.jsx("div",{className:"h-[46px] w-full bg-muted/80"}),jsxRuntimeExports.jsx("div",{className:"flex w-full items-center justify-center p-4",children:jsxRuntimeExports.jsx(LoaderCircle,{className:"size-4 animate-spin"})})]}),Jt$3=/\.[^/.]+$/,Pe$3=({node:Au,className:lo,src:$u,alt:Ru,...Iu})=>{let Pu=async()=>{if($u)try{let Ou=await(await fetch($u)).blob(),Mu=new URL($u,window.location.origin).pathname.split("/").pop()||"",Du=Mu.split(".").pop(),Lu=Mu.includes(".")&&Du!==void 0&&Du.length<=4,Bu="";if(Lu)Bu=Mu;else{let ju=Ou.type,Fu="png";ju.includes("jpeg")||ju.includes("jpg")?Fu="jpg":ju.includes("png")?Fu="png":ju.includes("svg")?Fu="svg":ju.includes("gif")?Fu="gif":ju.includes("webp")&&(Fu="webp"),Bu=`${(Ru||Mu||"image").replace(Jt$3,"")}.${Fu}`}R$2(Bu,Ou,Ou.type)}catch(Ou){console.error("Failed to download image:",Ou)}};return $u?jsxRuntimeExports.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsxRuntimeExports.jsx("img",{alt:Ru,className:u$2("max-w-full rounded-lg",lo),"data-streamdown":"image",src:$u,...Iu}),jsxRuntimeExports.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsxRuntimeExports.jsx("button",{className:u$2("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:Pu,title:"Download image",type:"button",children:jsxRuntimeExports.jsx(Download$1,{size:14})})]}):null},_$3=async Au=>{let lo={startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0,...Au},$u=(await __vitePreload(async()=>{const{default:Ru}=await import("./chunks/mermaid.core-B9dEBs01.js").then(Iu=>Iu.an);return{default:Ru}},[],import.meta.url)).default;return $u.initialize(lo),$u},Te$3=(Au,lo)=>{var $u;let Ru=($u=void 0)!=null?$u:5;return new Promise((Iu,Pu)=>{let Ou="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(Au))),Mu=new Image;Mu.crossOrigin="anonymous",Mu.onload=()=>{let Du=document.createElement("canvas"),Lu=Mu.width*Ru,Bu=Mu.height*Ru;Du.width=Lu,Du.height=Bu;let ju=Du.getContext("2d");if(!ju){Pu(new Error("Failed to create 2D canvas context for PNG export"));return}ju.drawImage(Mu,0,0,Lu,Bu),Du.toBlob(Fu=>{if(!Fu){Pu(new Error("Failed to create PNG blob"));return}Iu(Fu)},"image/png")},Mu.onerror=()=>Pu(new Error("Failed to load SVG image")),Mu.src=Ou})},Se$2=({chart:Au,children:lo,className:$u,onDownload:Ru,config:Iu,onError:Pu})=>{let[Ou,Mu]=reactExports.useState(!1),Du=reactExports.useRef(null),{isAnimating:Lu}=reactExports.useContext(C$1),Bu=async ju=>{try{if(ju==="mmd"){R$2("diagram.mmd",Au,"text/plain"),Mu(!1),Ru?.(ju);return}let Fu=await _$3(Iu),zu=Au.split("").reduce((Vu,Gu)=>(Vu<<5)-Vu+Gu.charCodeAt(0)|0,0),Uu=`mermaid-${Math.abs(zu)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:Hu}=await Fu.render(Uu,Au);if(!Hu){Pu?.(new Error("SVG not found. Please wait for the diagram to render."));return}if(ju==="svg"){R$2("diagram.svg",Hu,"image/svg+xml"),Mu(!1),Ru?.(ju);return}if(ju==="png"){let Vu=await Te$3(Hu);R$2("diagram.png",Vu,"image/png"),Ru?.(ju),Mu(!1);return}}catch(Fu){Pu?.(Fu)}};return reactExports.useEffect(()=>{let ju=Fu=>{Du.current&&!Du.current.contains(Fu.target)&&Mu(!1)};return document.addEventListener("mousedown",ju),()=>{document.removeEventListener("mousedown",ju)}},[]),jsxRuntimeExports.jsxs("div",{className:"relative",ref:Du,children:[jsxRuntimeExports.jsx("button",{className:u$2("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",$u),disabled:Lu,onClick:()=>Mu(!Ou),title:"Download diagram",type:"button",children:lo??jsxRuntimeExports.jsx(Download$1,{size:14})}),Ou&&jsxRuntimeExports.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntimeExports.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>Bu("svg"),title:"Download diagram as SVG",type:"button",children:"SVG"}),jsxRuntimeExports.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>Bu("png"),title:"Download diagram as PNG",type:"button",children:"PNG"}),jsxRuntimeExports.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>Bu("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]})]})},J$1=0,to$1=()=>{J$1+=1,J$1===1&&(document.body.style.overflow="hidden")},oo$1=()=>{J$1=Math.max(0,J$1-1),J$1===0&&(document.body.style.overflow="")},De$2=({chart:Au,config:lo,onFullscreen:$u,onExit:Ru,className:Iu,...Pu})=>{let[Ou,Mu]=reactExports.useState(!1),{isAnimating:Du,controls:Lu}=reactExports.useContext(C$1),Bu=(()=>{if(typeof Lu=="boolean")return Lu;let Fu=Lu.mermaid;return Fu===!1?!1:Fu===!0||Fu===void 0?!0:Fu.panZoom!==!1})(),ju=()=>{Mu(!Ou)};return reactExports.useEffect(()=>{if(Ou){to$1();let Fu=zu=>{zu.key==="Escape"&&Mu(!1)};return document.addEventListener("keydown",Fu),()=>{document.removeEventListener("keydown",Fu),oo$1()}}},[Ou]),reactExports.useEffect(()=>{Ou?$u?.():Ru&&Ru()},[Ou,$u,Ru]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("button",{className:u$2("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",Iu),disabled:Du,onClick:ju,title:"View fullscreen",type:"button",...Pu,children:jsxRuntimeExports.jsx(Maximize2,{size:14})}),Ou&&jsxRuntimeExports.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:ju,onKeyDown:Fu=>{Fu.key==="Escape"&&ju()},role:"button",tabIndex:0,children:[jsxRuntimeExports.jsx("button",{className:"absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:ju,title:"Exit fullscreen",type:"button",children:jsxRuntimeExports.jsx(X$3,{size:20})}),jsxRuntimeExports.jsx("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:Fu=>Fu.stopPropagation(),onKeyDown:Fu=>Fu.stopPropagation(),role:"presentation",children:jsxRuntimeExports.jsx(Ee$2,{chart:Au,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:lo,fullscreen:!0,showControls:Bu})})]})]})},Y$1=Au=>{var lo,$u;let Ru=[],Iu=[],Pu=Au.querySelectorAll("thead th");for(let Mu of Pu)Ru.push(((lo=Mu.textContent)==null?void 0:lo.trim())||"");let Ou=Au.querySelectorAll("tbody tr");for(let Mu of Ou){let Du=[],Lu=Mu.querySelectorAll("td");for(let Bu of Lu)Du.push((($u=Bu.textContent)==null?void 0:$u.trim())||"");Iu.push(Du)}return{headers:Ru,rows:Iu}},Q$1=Au=>{let{headers:lo,rows:$u}=Au,Ru=Mu=>{let Du=!1,Lu=!1;for(let Bu=0;Bu<Mu.length;Bu+=1){let ju=Mu[Bu];if(ju==='"'){Du=!0,Lu=!0;break}(ju===","||ju===`
|
|
3632
|
+
Please report this to https://github.com/markedjs/marked.`,lo){let Iu="<p>An error occurred:</p><pre>"+w$2(Ru.message+"",!0)+"</pre>";return $u?Promise.resolve(Iu):Iu}if($u)return Promise.reject(Ru);throw Ru}}},_$4=new B$2;function k$2(Au,lo){return _$4.parse(Au,lo)}k$2.options=k$2.setOptions=function(Au){return _$4.setOptions(Au),k$2.defaults=_$4.defaults,G$1(k$2.defaults),k$2};k$2.getDefaults=L$2;k$2.defaults=T$1;k$2.use=function(...Au){return _$4.use(...Au),k$2.defaults=_$4.defaults,G$1(k$2.defaults),k$2};k$2.walkTokens=function(Au,lo){return _$4.walkTokens(Au,lo)};k$2.parseInline=_$4.parseInline;k$2.Parser=b$5;k$2.parser=b$5.parse;k$2.Renderer=P$3;k$2.TextRenderer=$$1;k$2.Lexer=x$7;k$2.lexer=x$7.lex;k$2.Tokenizer=y$4;k$2.Hooks=S$2;k$2.parse=k$2;k$2.options;k$2.setOptions;k$2.use;k$2.walkTokens;k$2.parseInline;b$5.parse;x$7.lex;var u$2=(...Au)=>twMerge(clsx(Au)),R$2=(Au,lo,$u)=>{let Ru=typeof lo=="string"?new Blob([lo],{type:$u}):lo,Iu=URL.createObjectURL(Ru),Pu=document.createElement("a");Pu.href=Iu,Pu.download=Au,document.body.appendChild(Pu),Pu.click(),document.body.removeChild(Pu),URL.revokeObjectURL(Iu)},Dt$4=reactExports.createContext({code:""}),U$2=()=>reactExports.useContext(Dt$4),ie$4=({onCopy:Au,onError:lo,timeout:$u=2e3,children:Ru,className:Iu,code:Pu,...Ou})=>{let[Mu,Du]=reactExports.useState(!1),Lu=reactExports.useRef(0),{code:Bu}=U$2(),{isAnimating:ju}=reactExports.useContext(C$1),Fu=Pu??Bu,zu=async()=>{var Hu;if(typeof window>"u"||!((Hu=navigator?.clipboard)!=null&&Hu.writeText)){lo?.(new Error("Clipboard API not available"));return}try{Mu||(await navigator.clipboard.writeText(Fu),Du(!0),Au?.(),Lu.current=window.setTimeout(()=>Du(!1),$u))}catch(Vu){lo?.(Vu)}};reactExports.useEffect(()=>()=>{window.clearTimeout(Lu.current)},[]);let Uu=Mu?Check:Copy;return jsxRuntimeExports.jsx("button",{className:u$2("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",Iu),"data-streamdown":"code-block-copy-button",disabled:ju,onClick:zu,title:"Copy Code",type:"button",...Ou,children:Ru??jsxRuntimeExports.jsx(Uu,{size:14})})},xe$2={"1c":"1c","1c-query":"1cq",abap:"abap","actionscript-3":"as",ada:"ada",adoc:"adoc","angular-html":"html","angular-ts":"ts",apache:"conf",apex:"cls",apl:"apl",applescript:"applescript",ara:"ara",asciidoc:"adoc",asm:"asm",astro:"astro",awk:"awk",ballerina:"bal",bash:"sh",bat:"bat",batch:"bat",be:"be",beancount:"beancount",berry:"berry",bibtex:"bib",bicep:"bicep",blade:"blade.php",bsl:"bsl",c:"c","c#":"cs","c++":"cpp",cadence:"cdc",cairo:"cairo",cdc:"cdc",clarity:"clar",clj:"clj",clojure:"clj","closure-templates":"soy",cmake:"cmake",cmd:"cmd",cobol:"cob",codeowners:"CODEOWNERS",codeql:"ql",coffee:"coffee",coffeescript:"coffee","common-lisp":"lisp",console:"sh",coq:"v",cpp:"cpp",cql:"cql",crystal:"cr",cs:"cs",csharp:"cs",css:"css",csv:"csv",cue:"cue",cypher:"cql",d:"d",dart:"dart",dax:"dax",desktop:"desktop",diff:"diff",docker:"dockerfile",dockerfile:"dockerfile",dotenv:"env","dream-maker":"dm",edge:"edge",elisp:"el",elixir:"ex",elm:"elm","emacs-lisp":"el",erb:"erb",erl:"erl",erlang:"erl",f:"f","f#":"fs",f03:"f03",f08:"f08",f18:"f18",f77:"f77",f90:"f90",f95:"f95",fennel:"fnl",fish:"fish",fluent:"ftl",for:"for","fortran-fixed-form":"f","fortran-free-form":"f90",fs:"fs",fsharp:"fs",fsl:"fsl",ftl:"ftl",gdresource:"tres",gdscript:"gd",gdshader:"gdshader",genie:"gs",gherkin:"feature","git-commit":"gitcommit","git-rebase":"gitrebase",gjs:"js",gleam:"gleam","glimmer-js":"js","glimmer-ts":"ts",glsl:"glsl",gnuplot:"plt",go:"go",gql:"gql",graphql:"graphql",groovy:"groovy",gts:"gts",hack:"hack",haml:"haml",handlebars:"hbs",haskell:"hs",haxe:"hx",hbs:"hbs",hcl:"hcl",hjson:"hjson",hlsl:"hlsl",hs:"hs",html:"html","html-derivative":"html",http:"http",hxml:"hxml",hy:"hy",imba:"imba",ini:"ini",jade:"jade",java:"java",javascript:"js",jinja:"jinja",jison:"jison",jl:"jl",js:"js",json:"json",json5:"json5",jsonc:"jsonc",jsonl:"jsonl",jsonnet:"jsonnet",jssm:"jssm",jsx:"jsx",julia:"jl",kotlin:"kt",kql:"kql",kt:"kt",kts:"kts",kusto:"kql",latex:"tex",lean:"lean",lean4:"lean",less:"less",liquid:"liquid",lisp:"lisp",lit:"lit",llvm:"ll",log:"log",logo:"logo",lua:"lua",luau:"luau",make:"mak",makefile:"mak",markdown:"md",marko:"marko",matlab:"m",md:"md",mdc:"mdc",mdx:"mdx",mediawiki:"wiki",mermaid:"mmd",mips:"s",mipsasm:"s",mmd:"mmd",mojo:"mojo",move:"move",nar:"nar",narrat:"narrat",nextflow:"nf",nf:"nf",nginx:"conf",nim:"nim",nix:"nix",nu:"nu",nushell:"nu",objc:"m","objective-c":"m","objective-cpp":"mm",ocaml:"ml",pascal:"pas",perl:"pl",perl6:"p6",php:"php",plsql:"pls",po:"po",polar:"polar",postcss:"pcss",pot:"pot",potx:"potx",powerquery:"pq",powershell:"ps1",prisma:"prisma",prolog:"pl",properties:"properties",proto:"proto",protobuf:"proto",ps:"ps",ps1:"ps1",pug:"pug",puppet:"pp",purescript:"purs",py:"py",python:"py",ql:"ql",qml:"qml",qmldir:"qmldir",qss:"qss",r:"r",racket:"rkt",raku:"raku",razor:"cshtml",rb:"rb",reg:"reg",regex:"regex",regexp:"regexp",rel:"rel",riscv:"s",rs:"rs",rst:"rst",ruby:"rb",rust:"rs",sas:"sas",sass:"sass",scala:"scala",scheme:"scm",scss:"scss",sdbl:"sdbl",sh:"sh",shader:"shader",shaderlab:"shader",shell:"sh",shellscript:"sh",shellsession:"sh",smalltalk:"st",solidity:"sol",soy:"soy",sparql:"rq",spl:"spl",splunk:"spl",sql:"sql","ssh-config":"config",stata:"do",styl:"styl",stylus:"styl",svelte:"svelte",swift:"swift","system-verilog":"sv",systemd:"service",talon:"talon",talonscript:"talon",tasl:"tasl",tcl:"tcl",templ:"templ",terraform:"tf",tex:"tex",tf:"tf",tfvars:"tfvars",toml:"toml",ts:"ts","ts-tags":"ts",tsp:"tsp",tsv:"tsv",tsx:"tsx",turtle:"ttl",twig:"twig",typ:"typ",typescript:"ts",typespec:"tsp",typst:"typ",v:"v",vala:"vala",vb:"vb",verilog:"v",vhdl:"vhdl",vim:"vim",viml:"vim",vimscript:"vim",vue:"vue","vue-html":"html","vue-vine":"vine",vy:"vy",vyper:"vy",wasm:"wasm",wenyan:"wy",wgsl:"wgsl",wiki:"wiki",wikitext:"wiki",wit:"wit",wl:"wl",wolfram:"wl",xml:"xml",xsl:"xsl",yaml:"yaml",yml:"yml",zenscript:"zs",zig:"zig",zsh:"zsh",文言:"wy"},Me$3=({onDownload:Au,onError:lo,language:$u,children:Ru,className:Iu,code:Pu,...Ou})=>{let{code:Mu}=U$2(),{isAnimating:Du}=reactExports.useContext(C$1),Lu=Pu??Mu,Bu=`file.${$u&&$u in xe$2?xe$2[$u]:"txt"}`,ju="text/plain",Fu=()=>{try{R$2(Bu,Lu,ju),Au?.()}catch(zu){lo?.(zu)}};return jsxRuntimeExports.jsx("button",{className:u$2("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",Iu),"data-streamdown":"code-block-download-button",disabled:Du,onClick:Fu,title:"Download file",type:"button",...Ou,children:Ru??jsxRuntimeExports.jsx(Download$1,{size:14})})},de$3=()=>jsxRuntimeExports.jsxs("div",{className:"w-full divide-y divide-border overflow-hidden rounded-xl border border-border",children:[jsxRuntimeExports.jsx("div",{className:"h-[46px] w-full bg-muted/80"}),jsxRuntimeExports.jsx("div",{className:"flex w-full items-center justify-center p-4",children:jsxRuntimeExports.jsx(LoaderCircle,{className:"size-4 animate-spin"})})]}),Jt$3=/\.[^/.]+$/,Pe$3=({node:Au,className:lo,src:$u,alt:Ru,...Iu})=>{let Pu=async()=>{if($u)try{let Ou=await(await fetch($u)).blob(),Mu=new URL($u,window.location.origin).pathname.split("/").pop()||"",Du=Mu.split(".").pop(),Lu=Mu.includes(".")&&Du!==void 0&&Du.length<=4,Bu="";if(Lu)Bu=Mu;else{let ju=Ou.type,Fu="png";ju.includes("jpeg")||ju.includes("jpg")?Fu="jpg":ju.includes("png")?Fu="png":ju.includes("svg")?Fu="svg":ju.includes("gif")?Fu="gif":ju.includes("webp")&&(Fu="webp"),Bu=`${(Ru||Mu||"image").replace(Jt$3,"")}.${Fu}`}R$2(Bu,Ou,Ou.type)}catch(Ou){console.error("Failed to download image:",Ou)}};return $u?jsxRuntimeExports.jsxs("div",{className:"group relative my-4 inline-block","data-streamdown":"image-wrapper",children:[jsxRuntimeExports.jsx("img",{alt:Ru,className:u$2("max-w-full rounded-lg",lo),"data-streamdown":"image",src:$u,...Iu}),jsxRuntimeExports.jsx("div",{className:"pointer-events-none absolute inset-0 hidden rounded-lg bg-black/10 group-hover:block"}),jsxRuntimeExports.jsx("button",{className:u$2("absolute right-2 bottom-2 flex h-8 w-8 cursor-pointer items-center justify-center rounded-md border border-border bg-background/90 shadow-sm backdrop-blur-sm transition-all duration-200 hover:bg-background","opacity-0 group-hover:opacity-100"),onClick:Pu,title:"Download image",type:"button",children:jsxRuntimeExports.jsx(Download$1,{size:14})})]}):null},_$3=async Au=>{let lo={startOnLoad:!1,theme:"default",securityLevel:"strict",fontFamily:"monospace",suppressErrorRendering:!0,...Au},$u=(await __vitePreload(async()=>{const{default:Ru}=await import("./chunks/mermaid.core-ByLffeZ_.js").then(Iu=>Iu.an);return{default:Ru}},[],import.meta.url)).default;return $u.initialize(lo),$u},Te$3=(Au,lo)=>{var $u;let Ru=($u=void 0)!=null?$u:5;return new Promise((Iu,Pu)=>{let Ou="data:image/svg+xml;base64,"+btoa(unescape(encodeURIComponent(Au))),Mu=new Image;Mu.crossOrigin="anonymous",Mu.onload=()=>{let Du=document.createElement("canvas"),Lu=Mu.width*Ru,Bu=Mu.height*Ru;Du.width=Lu,Du.height=Bu;let ju=Du.getContext("2d");if(!ju){Pu(new Error("Failed to create 2D canvas context for PNG export"));return}ju.drawImage(Mu,0,0,Lu,Bu),Du.toBlob(Fu=>{if(!Fu){Pu(new Error("Failed to create PNG blob"));return}Iu(Fu)},"image/png")},Mu.onerror=()=>Pu(new Error("Failed to load SVG image")),Mu.src=Ou})},Se$2=({chart:Au,children:lo,className:$u,onDownload:Ru,config:Iu,onError:Pu})=>{let[Ou,Mu]=reactExports.useState(!1),Du=reactExports.useRef(null),{isAnimating:Lu}=reactExports.useContext(C$1),Bu=async ju=>{try{if(ju==="mmd"){R$2("diagram.mmd",Au,"text/plain"),Mu(!1),Ru?.(ju);return}let Fu=await _$3(Iu),zu=Au.split("").reduce((Vu,Gu)=>(Vu<<5)-Vu+Gu.charCodeAt(0)|0,0),Uu=`mermaid-${Math.abs(zu)}-${Date.now()}-${Math.random().toString(36).substring(2,9)}`,{svg:Hu}=await Fu.render(Uu,Au);if(!Hu){Pu?.(new Error("SVG not found. Please wait for the diagram to render."));return}if(ju==="svg"){R$2("diagram.svg",Hu,"image/svg+xml"),Mu(!1),Ru?.(ju);return}if(ju==="png"){let Vu=await Te$3(Hu);R$2("diagram.png",Vu,"image/png"),Ru?.(ju),Mu(!1);return}}catch(Fu){Pu?.(Fu)}};return reactExports.useEffect(()=>{let ju=Fu=>{Du.current&&!Du.current.contains(Fu.target)&&Mu(!1)};return document.addEventListener("mousedown",ju),()=>{document.removeEventListener("mousedown",ju)}},[]),jsxRuntimeExports.jsxs("div",{className:"relative",ref:Du,children:[jsxRuntimeExports.jsx("button",{className:u$2("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",$u),disabled:Lu,onClick:()=>Mu(!Ou),title:"Download diagram",type:"button",children:lo??jsxRuntimeExports.jsx(Download$1,{size:14})}),Ou&&jsxRuntimeExports.jsxs("div",{className:"absolute top-full right-0 z-10 mt-1 min-w-[120px] overflow-hidden rounded-md border border-border bg-background shadow-lg",children:[jsxRuntimeExports.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>Bu("svg"),title:"Download diagram as SVG",type:"button",children:"SVG"}),jsxRuntimeExports.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>Bu("png"),title:"Download diagram as PNG",type:"button",children:"PNG"}),jsxRuntimeExports.jsx("button",{className:"w-full px-3 py-2 text-left text-sm transition-colors hover:bg-muted/40",onClick:()=>Bu("mmd"),title:"Download diagram as MMD",type:"button",children:"MMD"})]})]})},J$1=0,to$1=()=>{J$1+=1,J$1===1&&(document.body.style.overflow="hidden")},oo$1=()=>{J$1=Math.max(0,J$1-1),J$1===0&&(document.body.style.overflow="")},De$2=({chart:Au,config:lo,onFullscreen:$u,onExit:Ru,className:Iu,...Pu})=>{let[Ou,Mu]=reactExports.useState(!1),{isAnimating:Du,controls:Lu}=reactExports.useContext(C$1),Bu=(()=>{if(typeof Lu=="boolean")return Lu;let Fu=Lu.mermaid;return Fu===!1?!1:Fu===!0||Fu===void 0?!0:Fu.panZoom!==!1})(),ju=()=>{Mu(!Ou)};return reactExports.useEffect(()=>{if(Ou){to$1();let Fu=zu=>{zu.key==="Escape"&&Mu(!1)};return document.addEventListener("keydown",Fu),()=>{document.removeEventListener("keydown",Fu),oo$1()}}},[Ou]),reactExports.useEffect(()=>{Ou?$u?.():Ru&&Ru()},[Ou,$u,Ru]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("button",{className:u$2("cursor-pointer p-1 text-muted-foreground transition-all hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",Iu),disabled:Du,onClick:ju,title:"View fullscreen",type:"button",...Pu,children:jsxRuntimeExports.jsx(Maximize2,{size:14})}),Ou&&jsxRuntimeExports.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-background/95 backdrop-blur-sm",onClick:ju,onKeyDown:Fu=>{Fu.key==="Escape"&&ju()},role:"button",tabIndex:0,children:[jsxRuntimeExports.jsx("button",{className:"absolute top-4 right-4 z-10 rounded-md p-2 text-muted-foreground transition-all hover:bg-muted hover:text-foreground",onClick:ju,title:"Exit fullscreen",type:"button",children:jsxRuntimeExports.jsx(X$3,{size:20})}),jsxRuntimeExports.jsx("div",{className:"flex h-full w-full items-center justify-center p-4",onClick:Fu=>Fu.stopPropagation(),onKeyDown:Fu=>Fu.stopPropagation(),role:"presentation",children:jsxRuntimeExports.jsx(Ee$2,{chart:Au,className:"h-full w-full [&>div]:h-full [&>div]:overflow-hidden [&_svg]:h-auto [&_svg]:w-auto",config:lo,fullscreen:!0,showControls:Bu})})]})]})},Y$1=Au=>{var lo,$u;let Ru=[],Iu=[],Pu=Au.querySelectorAll("thead th");for(let Mu of Pu)Ru.push(((lo=Mu.textContent)==null?void 0:lo.trim())||"");let Ou=Au.querySelectorAll("tbody tr");for(let Mu of Ou){let Du=[],Lu=Mu.querySelectorAll("td");for(let Bu of Lu)Du.push((($u=Bu.textContent)==null?void 0:$u.trim())||"");Iu.push(Du)}return{headers:Ru,rows:Iu}},Q$1=Au=>{let{headers:lo,rows:$u}=Au,Ru=Mu=>{let Du=!1,Lu=!1;for(let Bu=0;Bu<Mu.length;Bu+=1){let ju=Mu[Bu];if(ju==='"'){Du=!0,Lu=!0;break}(ju===","||ju===`
|
|
3633
3633
|
`)&&(Du=!0)}return Du?Lu?`"${Mu.replace(/"/g,'""')}"`:`"${Mu}"`:Mu},Iu=lo.length>0?$u.length+1:$u.length,Pu=new Array(Iu),Ou=0;lo.length>0&&(Pu[Ou]=lo.map(Ru).join(","),Ou+=1);for(let Mu of $u)Pu[Ou]=Mu.map(Ru).join(","),Ou+=1;return Pu.join(`
|
|
3634
3634
|
`)},Le$3=Au=>{let{headers:lo,rows:$u}=Au,Ru=Mu=>{let Du=!1;for(let Bu=0;Bu<Mu.length;Bu+=1){let ju=Mu[Bu];if(ju===" "||ju===`
|
|
3635
3635
|
`||ju==="\r"){Du=!0;break}}if(!Du)return Mu;let Lu=[];for(let Bu=0;Bu<Mu.length;Bu+=1){let ju=Mu[Bu];ju===" "?Lu.push("\\t"):ju===`
|
|
@@ -3683,7 +3683,7 @@ ${Pu}\`\`\``}),lo}function ChatMarkdown({text:Au,density:lo="comfortable"}){retu
|
|
|
3683
3683
|
`).replace(/^[ \t]*([-*_])([ \t]*\1){2,}[ \t]*$/gm,"").replace(/!\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/`([^`]*)`/g,"$1").replace(/^\s{0,3}#{1,6}\s+(.*)$/gm,"$1.").replace(/^\s*(?:[-*+]|\d+[.)])\s+/gm,"").replace(/^\s*>\s?/gm,"").replace(/[*_~]+/g,"").replace(/\.\s*\./g,".").replace(/\s+/g," ").trim()}const END=/[.!?…:;](?=["'»)\]]*(\s|$))/g,SHORTEST=12;class SentenceCutter{said=0;feed(lo){const $u=plainWords(lo),Ru=[];END.lastIndex=this.said;let Iu;for(;(Iu=END.exec($u))!==null;){const Pu=Iu.index+Iu[0].length;if(Pu>=$u.length)break;const Ou=$u.slice(this.said,Pu).trim();Ou.length>=SHORTEST&&(Ru.push(Ou),this.said=Pu)}return Ru}end(lo){const $u=plainWords(lo).slice(this.said).trim();return this.said=plainWords(lo).length,$u?[$u]:[]}}function readAloud(Au,lo){Au.unlock?.(),Au.stop();const $u=new SentenceCutter,Ru=[...$u.feed(lo),...$u.end(lo)];return Ru.forEach(Iu=>Au.say(Iu)),Ru}function readsAloud(Au,lo,$u){return Au.role==="assistant"&&!Au.live&&!Au.note&&Au.id!==$u&&lo.trim().length>0}function ReadAloud({onRead:Au}){return jsxRuntimeExports.jsx(Tooltip,{text:"Read aloud",direction:"n",children:jsxRuntimeExports.jsx(IconButton,{"data-read-aloud":"",icon:UnmuteIcon,"aria-label":"Read aloud",size:"small",variant:"invisible",onClick:Au})})}const DATALAYER_SPEECH_MODELS_URL="https://models-speech.datalayer.tech",DATALAYER_VOICE_ENGINES={transformers:()=>__vitePreload(()=>import("./chunks/transformers.web-CLaqP_Vm.js"),[],import.meta.url),vad:()=>__vitePreload(()=>import("./chunks/index-BSG9WA6E.js").then(Au=>Au.i),[],import.meta.url)};function chatVoiceOf(Au,lo){if(!Au?.enabled||Au.input==="off"&&Au.output==="off")return;if(Au.output!=="off"&&!lo.speechUrl)throw new Error("Its answers are said by Datalayer’s speech service, and its host gave no address for it.");const $u=Au.language||lo.language||"en-US";return{language:$u,input:Au.input,output:Au.input==="hands_free"?"always":Au.output,voice:Au.voice||voiceFor($u)?.id||"",modelsUrl:lo.modelsUrl||DATALAYER_SPEECH_MODELS_URL,engines:DATALAYER_VOICE_ENGINES,speechUrl:lo.speechUrl,token:lo.token,consentKey:lo.consentKey,where:Au.where??"auto"}}function voiceAskedAs(Au,lo){if(!Au)return;const $u=Au.token||lo;return $u?{...Au,token:$u}:{...Au}}const SILENCE_MS=1500;function settledVoice(Au,lo=heldVoiceSettings()){const $u=voiceForPerson(Au,lo),Ru=$u.output??"off";if(Ru!=="off"&&!$u.speechUrl)throw new Error(`A chat whose answers are heard (${Ru}) names the speech service: its speechUrl is missing.`);return{...$u,output:Ru,voice:$u.voice||voiceFor($u.language)?.id||"",modelsUrl:$u.modelsUrl||DATALAYER_SPEECH_MODELS_URL,engines:$u.engines??DATALAYER_VOICE_ENGINES,silenceMs:$u.silenceMs??SILENCE_MS}}const SYNTHESES_PATH="/api/ai-agents/v1/speech/syntheses",SENTENCES_AHEAD=2;class ServerSpeaker{constructor(lo){this.options=lo}options;context;analyser;gain;buffer;queue=[];playing;running=!1;generation=0;state={speaking:!1};update(lo){this.options={...this.options,...lo}}unlock(){this.audio(),this.context?.resume()}audio(){return this.context||(this.context=new AudioContext,this.analyser=this.context.createAnalyser(),this.analyser.fftSize=512,this.gain=this.context.createGain(),this.analyser.connect(this.gain),this.gain.connect(this.context.destination),this.buffer=new Float32Array(this.analyser.fftSize)),this.context}level(){if(!this.analyser||!this.buffer||!this.state.speaking)return 0;this.analyser.getFloatTimeDomainData(this.buffer);let lo=0;for(const $u of this.buffer)lo+=$u*$u;return Math.min(1,Math.sqrt(lo/this.buffer.length)*6)}speed(){const lo=this.options.rate;return typeof lo=="number"&&Number.isFinite(lo)?Math.min(2,Math.max(.5,lo)):1}loudness(){const lo=this.options.volume;return typeof lo=="number"&&Number.isFinite(lo)?Math.min(1,Math.max(0,lo)):1}set(lo){this.state={...this.state,...lo},this.options.onState?.(this.state)}say(lo){const $u=lo.trim();$u&&(this.queue.push({text:$u,asked:performance.now()}),this.askAhead(),this.running||this.run(this.generation))}askAhead(){for(const lo of this.queue.slice(0,SENTENCES_AHEAD))lo.audio||(lo.audio=this.fetch(lo.text))}async fetch(lo){const{speechUrl:$u,voice:Ru,language:Iu,token:Pu,fetcher:Ou=fetch}=this.options;try{const Mu=await Ou(`${$u.replace(/\/+$/,"")}${SYNTHESES_PATH}`,{method:"POST",headers:{"Content-Type":"application/json",...Pu?{Authorization:`Bearer ${Pu}`}:{}},body:JSON.stringify({text:lo,voice:Ru,language:Iu,format:"opus"})});if(!Mu.ok){const Du=await Mu.json().catch(()=>({}));return typeof Du?.detail=="string"?Du.detail:`The answer could not be spoken (${Mu.status}).`}return await Mu.arrayBuffer()}catch{return"Datalayer’s speech service could not be reached: the answer is still written here."}}async run(lo){this.running=!0;try{for(;this.queue.length&&lo===this.generation;){this.askAhead();const $u=this.queue[0],Ru=await $u.audio;if(lo!==this.generation)return;if(typeof Ru=="string"){this.queue=[],this.set({speaking:!1,sentence:void 0,refused:Ru});return}this.queue.shift(),this.askAhead();const Iu=this.audio(),Pu=await Iu.decodeAudioData(Ru);if(lo!==this.generation)return;await new Promise(Ou=>{const Mu=Iu.createBufferSource();Mu.buffer=Pu,Mu.playbackRate.value=this.speed(),this.gain&&(this.gain.gain.value=this.loudness()),Mu.connect(this.analyser),Mu.onended=()=>Ou(),this.playing=Mu,this.set({speaking:!0,sentence:$u.text,refused:void 0}),this.options.onFirstSound?.(Math.round(performance.now()-$u.asked)),Mu.start()}),this.playing=void 0}}finally{lo===this.generation&&(this.running=!1,this.state.speaking&&this.set({speaking:!1,sentence:void 0}))}}stop(){this.generation+=1,this.queue=[],this.running=!1;try{this.playing?.stop()}catch{}this.playing=void 0,this.set({speaking:!1,sentence:void 0})}close(){this.stop(),this.context?.close(),this.context=void 0}}function useVoiceSpeaker(Au,lo=!0){const[$u,Ru]=reactExports.useState({speaking:!1}),Iu=lo&&!!Au&&Au.output!=="off"&&!!Au.speechUrl,Pu=reactExports.useMemo(()=>Iu&&Au?.speechUrl?new ServerSpeaker({speechUrl:Au.speechUrl,voice:Au.voice,language:Au.language,token:Au.token,rate:Au.rate,volume:Au.volume,onState:Ru}):void 0,[Iu,Au?.speechUrl]);reactExports.useEffect(()=>{Pu?.update({voice:Au?.voice,language:Au?.language,token:Au?.token,rate:Au?.rate,volume:Au?.volume})},[Pu,Au?.voice,Au?.language,Au?.token,Au?.rate,Au?.volume]),reactExports.useEffect(()=>()=>Pu?.close(),[Pu]),reactExports.useEffect(()=>{if(!Pu)return;const Lu=()=>Pu.unlock();return window.addEventListener("pointerdown",Lu,{once:!0}),window.addEventListener("keydown",Lu,{once:!0}),()=>{window.removeEventListener("pointerdown",Lu),window.removeEventListener("keydown",Lu)}},[Pu]);const Ou=reactExports.useCallback(()=>Pu?.stop(),[Pu]),Mu=reactExports.useCallback(Lu=>{Pu&&readAloud(Pu,Lu)},[Pu]),Du=reactExports.useMemo(()=>Pu?()=>Pu.level():void 0,[Pu]);return{speaker:Pu,state:$u,stop:Ou,read:Mu,level:Du}}function answerText(Au){const lo=Au;if(!(!lo||lo.role!=="assistant"||typeof lo.toolName=="string")){if(typeof lo.content=="string")return lo.content;if(Array.isArray(lo.content))return lo.content.map($u=>$u&&typeof $u=="object"&&$u.type==="text"?String($u.text??""):"").join(" ")}}function useSpokenAnswers(Au,lo,$u,Ru){const Iu=reactExports.useRef(new Set),Pu=reactExports.useRef(void 0),Ou=reactExports.useRef(!1);reactExports.useEffect(()=>{if(!$u||!Ru){Ou.current=!1,Pu.current=void 0;return}const Mu=Au.map((Bu,ju)=>({id:String(Bu?.id??ju),text:answerText(Bu)})).filter(Bu=>Bu.text!==void 0);if(!Ou.current){Ou.current=!0,Mu.forEach(Bu=>Iu.current.add(Bu.id));return}const Du=Mu[Mu.length-1];if(!Du||Iu.current.has(Du.id)&&Pu.current?.id!==Du.id)return;Pu.current?.id!==Du.id&&(Iu.current.add(Du.id),Pu.current={id:Du.id,cutter:new SentenceCutter,ended:!1});const Lu=Pu.current;if(!Lu.ended){for(const Bu of Lu.cutter.feed(Du.text??""))Ru.say(Bu);if(!lo){for(const Bu of Lu.cutter.end(Du.text??""))Ru.say(Bu);Lu.ended=!0}}},[Au,lo,$u,Ru])}function ToolApprovalBanner({pendingApprovals:Au,onReview:lo,onApproveAll:$u,onDismiss:Ru,collapsible:Iu=!0}){const Pu=useChatWords(),[Ou,Mu]=reactExports.useState(!1);return Au.length===0?null:Ou?jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,px:3,py:2,bg:"attention.subtle",borderBottom:"1px solid",borderColor:"attention.muted",cursor:"pointer",onClick:()=>Mu(!1),children:[jsxRuntimeExports.jsx(ShieldCheckIcon,{size:16}),jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:1,fontWeight:"semibold"},children:Pu.toolApprovalsPending}),jsxRuntimeExports.jsx(CounterLabel,{children:Au.length})]}):jsxRuntimeExports.jsxs(Box,{borderBottom:"1px solid",borderColor:"attention.muted",bg:"attention.subtle",children:[jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",justifyContent:"space-between",px:3,py:2,children:[jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,children:[jsxRuntimeExports.jsx(AlertIcon,{size:16}),jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:1,fontWeight:"semibold"},children:Pu.approvalsPending(Au.length)})]}),jsxRuntimeExports.jsxs(Box,{display:"flex",gap:1,children:[$u&&Au.length>=1&&jsxRuntimeExports.jsx(ButtonComponent,{size:"small",variant:"primary",leadingVisual:CheckIcon,onClick:$u,children:Pu.approveAll}),Iu&&jsxRuntimeExports.jsx(ButtonComponent,{size:"small",variant:"invisible",onClick:()=>Mu(!0),children:Pu.collapse}),Ru&&jsxRuntimeExports.jsx(ButtonComponent,{size:"small",variant:"invisible",leadingVisual:XIcon,onClick:Ru,"aria-label":Pu.dismiss})]})]}),jsxRuntimeExports.jsx(Box,{px:3,pb:2,children:Au.map(Du=>jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",justifyContent:"space-between",py:1,px:2,mb:1,bg:"canvas.default",borderRadius:2,border:"1px solid",borderColor:"border.default",children:[jsxRuntimeExports.jsxs(Box,{children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontWeight:"semibold",fontSize:1},children:Du.toolName}),Du.toolDescription&&jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted",fontSize:0,ml:2},children:Du.toolDescription})]}),jsxRuntimeExports.jsx(ButtonComponent,{size:"small",variant:"default",onClick:()=>lo(Du),children:Pu.review})]},Du.id))})]})}function ToolApprovalDialog({isOpen:Au,toolName:lo,toolDescription:$u,args:Ru,onApprove:Iu,onDeny:Pu,onClose:Ou,showRememberChoice:Mu=!0}){const Du=useChatWords(),[Lu,Bu]=reactExports.useState(!1),ju=reactExports.useCallback(()=>{Iu(Lu)},[Iu,Lu]),Fu=reactExports.useCallback(()=>{Pu(Lu)},[Pu,Lu]);return Au?jsxRuntimeExports.jsxs(Dialog$1,{onClose:Ou,"aria-labelledby":"tool-approval-title",children:[jsxRuntimeExports.jsx(Dialog$1.Header,{children:jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,children:[jsxRuntimeExports.jsx(AlertIcon,{size:16}),Du.approvalTitle]})}),jsxRuntimeExports.jsxs(Box,{p:3,children:[jsxRuntimeExports.jsxs(Box,{mb:3,children:[jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,mb:2,children:[jsxRuntimeExports.jsx(ToolsIcon,{size:20}),jsxRuntimeExports.jsx(Heading$2,{as:"h4",sx:{fontSize:2},children:lo})]}),$u&&jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted",fontSize:1},children:$u})]}),jsxRuntimeExports.jsxs(Box,{mb:3,children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontWeight:"semibold",fontSize:1,mb:2,display:"block"},children:Du.arguments}),jsxRuntimeExports.jsx(Box,{as:"pre",p:3,bg:"canvas.subtle",borderRadius:2,border:"1px solid",borderColor:"border.default",overflow:"auto",maxHeight:200,fontSize:0,children:JSON.stringify(Ru,null,2)})]}),jsxRuntimeExports.jsx(Box,{p:3,bg:"attention.subtle",borderRadius:2,border:"1px solid",borderColor:"attention.muted",mb:3,children:jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:1},children:Du.approvalWarning})}),Mu&&jsxRuntimeExports.jsxs(FormControl$1,{sx:{mb:3},children:[jsxRuntimeExports.jsx(Checkbox,{checked:Lu,onChange:zu=>Bu(zu.target.checked)}),jsxRuntimeExports.jsx(FormControl$1.Label,{children:Du.rememberChoice})]}),jsxRuntimeExports.jsxs(Box,{display:"flex",justifyContent:"flex-end",gap:2,children:[jsxRuntimeExports.jsx(ButtonComponent,{variant:"danger",onClick:Fu,leadingVisual:XIcon,children:Du.deny}),jsxRuntimeExports.jsx(ButtonComponent,{variant:"primary",onClick:ju,leadingVisual:CheckIcon,children:Du.approve})]})]})]}):null}const isUsable=Au=>Au.isAvailable!==!1;function usableModels(Au){const lo=Au.filter(isUsable);return lo.length>0?lo:Au}function offeredModels(Au,lo){return usableModels(Au??lo())}const isOffered=(Au,lo)=>!!lo&&Au.some($u=>$u.id===lo&&isUsable($u));function initialModelId(Au,lo){return Au.some(Ru=>Ru.id===lo&&isUsable(Ru))?lo:(Au.find(isUsable)??Au[0])?.id}function readServerCatalogue(Au){return(Au?.models??[]).map(readServerModel)}function readServerDecisions(Au){return{models:Au.decision_models.map(readServerModel),note:Au.decisions_note}}function readServerModel(Au){const lo=Au.missing_env_vars??[],$u=Au.reason??(lo.length>0?`Set ${lo.join(", ")}`:void 0)??Au.warning??void 0;return{id:Au.id,name:Au.name??Au.id,isAvailable:Au.available!==!1,...$u&&Au.available===!1?{unavailableReason:$u}:{}}}const executionCache=new Map,CACHE_TTL_MS=2e3;function getOperationSignature(Au,lo){return`${Au}:${JSON.stringify(lo)}`}function isRecentDuplicate(Au,lo){const $u=getOperationSignature(Au,lo),Ru=executionCache.get($u);if(Ru&&Date.now()-Ru<CACHE_TTL_MS)return!0;for(const[Iu,Pu]of executionCache.entries())Date.now()-Pu>CACHE_TTL_MS*2&&executionCache.delete(Iu);return executionCache.set($u,Date.now()),!1}function processParameters(Au){if(!Au||typeof Au!="object"||Array.isArray(Au))return Au;const lo={};for(const[$u,Ru]of Object.entries(Au))if(typeof Ru=="string"&&(Ru.startsWith("{")||Ru.startsWith("[")))try{lo[$u]=JSON.parse(Ru)}catch{lo[$u]=Ru}else lo[$u]=Ru;return lo}function createAgentRuntimesTool(Au,lo,$u){const Ru=new OperationRunner;return{name:Au.toolReferenceName||Au.name,description:Au.description,parameters:Au.parameters,handler:async Iu=>{if(isRecentDuplicate(Au.name,Iu))return{success:!1,message:"Operation already executed recently (duplicate detected)"};try{const Pu=processParameters(Iu);return await Ru.execute(lo,Pu,{...$u,format:"toon"})}catch(Pu){return console.error("[agent-runtimes] ❌ ERROR in handler:",Pu),{success:!1,error:Pu instanceof Error?Pu.message:String(Pu)}}}}}function createAllAgentRuntimesTools(Au,lo,$u){const Ru=[];for(const Iu of Au){const Pu=lo[Iu.operation];if(!Pu){console.warn(`[agent-runtimes Tools] No operation found for ${Iu.name} (operation: ${Iu.operation})`);continue}const Ou=createAgentRuntimesTool(Iu,Pu,$u);Ru.push(Ou)}return Ru}const useNotebookStore=()=>notebookStore.getState();function createNotebookTools(Au,lo){const $u=new DefaultExecutor(Au,notebookStore.getState());return createAllAgentRuntimesTools(notebookToolDefinitions,notebookToolOperations,{documentId:Au,executor:$u,format:"toon",...lo})}function useNotebookTools(Au,lo){const $u=useNotebookStore(),Ru=reactExports.useMemo(()=>new DefaultExecutor(Au,$u),[Au]),Iu=reactExports.useMemo(()=>({documentId:Au,executor:Ru,format:"toon",...lo}),[Au,Ru,lo]);return reactExports.useMemo(()=>createAllAgentRuntimesTools(notebookToolDefinitions,notebookToolOperations,Iu),[Iu])}const notebookHooks=Object.freeze(Object.defineProperty({__proto__:null,createNotebookTools,useNotebookTools},Symbol.toStringTag,{value:"Module"})),AGENT_SPAN_ATTRIBUTES={operation:"gen_ai.operation.name",agentName:"gen_ai.agent.name",conversationId:"gen_ai.conversation.id",requestModel:"gen_ai.request.model",inputMessages:"gen_ai.input.messages",outputMessages:"gen_ai.output.messages",inputTokens:"gen_ai.usage.input_tokens",outputTokens:"gen_ai.usage.output_tokens",toolName:"gen_ai.tool.name",toolCallId:"gen_ai.tool.call.id",toolArguments:"gen_ai.tool.call.arguments",toolResult:"gen_ai.tool.call.result",toolType:"gen_ai.tool.type",toolKind:"datalayer.tool.kind",markIcon:"datalayer.mark.icon",markEmoji:"datalayer.mark.emoji",origin:"datalayer.span.origin",errorType:"error.type"},A=AGENT_SPAN_ATTRIBUTES;function jsonAttribute(Au){if(Au!==void 0)try{return JSON.stringify(Au)}catch{return String(Au)}}function shortLine(Au,lo=160){const $u=Au.replace(/\s+/g," ").trim();return $u.length>lo?`${$u.slice(0,lo-1)}…`:$u}function argumentsLine(Au,lo=100){if(!Au||typeof Au!="object")return Au===void 0?"":shortLine(String(Au),lo);const $u=Object.entries(Au).map(([Ru,Iu])=>`${Ru}=${typeof Iu=="string"?Iu:JSON.stringify(Iu)}`);return shortLine($u.join(", "),lo)}function messages(Au,lo){return JSON.stringify([{role:Au,parts:[{type:"text",content:lo}]}])}function startAgentTurn(Au,lo){return Au.startSpan(`invoke_agent ${lo.agent}`,{serviceName:lo.agent,parent:null,attributes:{[A.operation]:"invoke_agent",[A.agentName]:lo.agent,[A.requestModel]:lo.model||void 0,[A.conversationId]:lo.conversationId,[A.inputMessages]:messages("user",lo.prompt)}})}function endAgentTurn(Au,lo){const $u=lo.usage;Au.setAttributes({[A.outputMessages]:lo.text?messages("assistant",lo.text):void 0,[A.inputTokens]:$u?.inputTokens??$u?.promptTokens,[A.outputTokens]:$u?.outputTokens??$u?.completionTokens}),lo.error?(Au.setAttribute(A.errorType,"error"),Au.recordException(new Error(lo.error))):Au.setStatus("OK"),Au.end()}function toolType(Au){return Au==="mcp"?"extension":"function"}function startToolCall(Au,lo){return Au.startSpan(`execute_tool ${lo.name}`,{serviceName:lo.agent,...lo.parent?{parent:lo.parent}:{},attributes:{[A.operation]:"execute_tool",[A.agentName]:lo.agent,[A.toolName]:lo.name,[A.toolCallId]:lo.id,[A.toolArguments]:jsonAttribute(lo.args??{}),[A.toolType]:toolType(lo.tool.kind),[A.toolKind]:lo.tool.kind,[A.markIcon]:lo.tool.icon,[A.markEmoji]:lo.tool.emoji,[A.origin]:lo.origin}})}function endToolCall(Au,lo){Au.setAttribute(A.toolResult,jsonAttribute(lo.result)),lo.error?(Au.setAttribute(A.errorType,"tool_error"),Au.recordException(new Error(lo.error))):Au.setStatus("OK"),Au.end()}function sourceOfSpan(Au){const lo=Au.attributes??{};if(lo[A.toolKind])return String(lo[A.toolKind]);if(lo["rpc.service"]==="a2a"||Au.span_name.startsWith("a2a "))return"a2a";if(lo[A.operation]==="invoke_agent")return"model"}const SPAN_SOURCE_LABELS={a2a:"A2A",mcp:"MCP",frontend:"Frontend tool",skill:"Skill",codemode:"Codemode",runtime:"Runtime tool",model:"Model"};function messageText$1(Au){if(typeof Au!="string")return"";try{return(JSON.parse(Au)[0]?.parts??[]).map($u=>typeof $u.content=="string"?$u.content:"").join("")}catch{return""}}function describeAgentSpan(Au){const lo=Au.attributes??{},$u=lo[A.operation];if($u==="execute_tool"){let Mu;try{Mu=JSON.parse(String(lo[A.toolArguments]??"{}"))}catch{Mu=lo[A.toolArguments]}return argumentsLine(Mu)||void 0}if($u==="invoke_agent"){const Mu=messageText$1(lo[A.inputMessages]),Du=messageText$1(lo[A.outputMessages]),Lu=Number(lo[A.inputTokens]??0),Bu=Number(lo[A.outputTokens]??0),ju=Lu+Bu?` · ${Lu+Bu} tokens`:"";return shortLine(Du?`${shortLine(Mu,60)} → ${Du}`:Mu)+ju}const Ru=lo["a2a.message.text"],Iu=lo["a2a.task.state"],Pu=[typeof Iu=="string"?stateWord(Iu):"",typeof Ru=="string"?shortLine(Ru):""].filter(Boolean);if(Pu.length)return Pu.join(" · ");const Ou=lo["a2a.agent.skills"];return Array.isArray(Ou)?Ou.join(", "):void 0}function stateWord(Au){return typeof Au=="string"?Au.replace(/^TASK_STATE_/,"").toLowerCase().replace(/_/g," "):""}const AgentInspectorContext=reactExports.createContext(null);function useAgentInspectorTracer(){return reactExports.useContext(AgentInspectorContext)}const CODEMODE_TOOLS=new Set(["list_servers","list_tool_names","search_tools","get_tool_details","execute_code"]);function classifyToolCall(Au,lo,$u={}){const Ru=marksOfToolCall(Au,lo,$u.mcpServers);return{kind:$u.frontendTools?.includes(Au)?"frontend":Ru?.kind?Ru.kind:CODEMODE_TOOLS.has(Au)?"codemode":$u.fallback??"runtime",...Ru?.icon?{icon:Ru.icon}:{},...Ru?.emoji?{emoji:Ru.emoji}:{}}}function chatSpanRecorder(Au,lo,$u={}){let Ru;const Iu=new Map;return{turnStarted(Pu,Ou){Ru=startAgentTurn(Au,{agent:lo(),prompt:Pu,model:Ou})},turnEnded(Pu){Ru&&(endAgentTurn(Ru,Pu),Ru=void 0)},toolStarted({id:Pu,name:Ou,args:Mu}){const Du=Iu.get(Pu);if(Du){Du.setAttribute("gen_ai.tool.call.arguments",JSON.stringify(Mu??{}));return}Iu.set(Pu,startToolCall(Au,{agent:lo(),name:Ou,id:Pu,args:Mu,tool:classifyToolCall(Ou,Mu,{frontendTools:$u.frontendTools?.(),mcpServers:$u.mcpServers?.()}),...Ru?{parent:Ru.context}:{}}))},toolEnded(Pu,Ou){const Mu=Iu.get(Pu);Mu&&(Iu.delete(Pu),endToolCall(Mu,Ou))}}}const STEP_DISPLAY_TYPE="application/vnd.datalayer.loop.step+json",isStepDisplay=Au=>Au.type===STEP_DISPLAY_TYPE;function stepOfDisplay(Au){const lo=Au.data??{};if(!isStepDisplay(Au)||typeof lo.name!="string")throw new Error(`Display ${Au.id} is not a step`);return{id:Au.id,name:lo.name,kind:typeof lo.kind=="string"?lo.kind:"run",parentId:typeof lo.parent_id=="string"&&lo.parent_id?lo.parent_id:null,input:lo.input??null,output:lo.output??null,error:typeof lo.error=="string"?lo.error:"",ended:typeof lo.ended_at=="string"&&lo.ended_at!==""}}const stepCallId=Au=>`step-${Au}`;function stepItem(Au,lo){const $u=stepCallId(Au.id),Ru=`${Au.kind} step`;return{id:$u,type:"tool-call",toolCallId:$u,toolName:Au.name,args:{kind:Au.kind,...Au.input!==null?{input:Au.input}:{}},...!Au.error&&Au.output!==null?{result:Au.output}:{},status:Au.ended?Au.error?"error":"complete":"executing",...Au.error?{error:Au.error}:{},summary:lo?`${Ru}, inside ${lo}`:Ru}}function withLoopStep(Au,lo){const $u=lo.parentId?Au.find(Ou=>"toolCallId"in Ou&&Ou.toolCallId===stepCallId(lo.parentId)):void 0,Ru=stepItem(lo,$u&&"toolName"in $u?$u.toolName:void 0);let Iu=!1;const Pu=Au.map(Ou=>"toolCallId"in Ou&&Ou.toolCallId===Ru.toolCallId?(Iu=!0,Ru):Ou);return Iu?Pu:[...Au,Ru]}function elementOfDisplay(Au){const lo=Au.data?.where;if(lo!=="panel"&&lo!=="page")return null;const $u=Au.data?.title;return{id:Au.id,where:lo,title:typeof $u=="string"?$u:"",shows:Au}}function withLoopElement(Au,lo){if("closed"in lo)return Au.filter(Ru=>Ru.id!==lo.id);const $u=Au.findIndex(Ru=>Ru.id===lo.id);return $u<0?[...Au,lo]:Au.map((Ru,Iu)=>Iu===$u?lo:Ru)}let opened=[];const listeners$4=new Set,openLoopElements=()=>opened;function applyLoopElement(Au){opened=withLoopElement(opened,Au);for(const lo of[...listeners$4])lo(opened)}const closeLoopElement=Au=>applyLoopElement({id:Au,closed:!0});function clearLoopElements(){opened=[];for(const Au of[...listeners$4])Au(opened)}function onLoopElements(Au){return listeners$4.add(Au),()=>{listeners$4.delete(Au)}}const WINDOW_MESSAGE="message";function windowMessageOf(Au){if(Au.body.name!==WINDOW_MESSAGE)throw new Error(`A window op named ${Au.body.name} is not one this page acts on`);const lo=Au.body.args;if(!lo||!("data"in lo))throw new Error("A window message says no data");return lo.data}const listeners$3=new Set;function tellLoopWindow(Au){for(const lo of[...listeners$3])lo(Au)}function onLoopWindowMessage(Au){return listeners$3.add(Au),()=>{listeners$3.delete(Au)}}function windowTurnErrorOf(Au){let lo=null;for(const $u of Au.split(`
|
|
3684
3684
|
|
|
3685
3685
|
`)){const Ru=$u.split(`
|
|
3686
|
-
`).filter(Pu=>Pu.startsWith("data:")).map(Pu=>Pu.slice(5).trim()).join("");if(!Ru)continue;let Iu;try{Iu=JSON.parse(Ru)}catch{continue}if(Iu.type==="RUN_ERROR")lo=String(Iu.message??"The turn failed.");else if(Iu.type==="CUSTOM"&&Iu.name===AGUI_NAME)throw new Error("A reactor.ui op came on the run stream: it comes over the ui socket.")}return lo}function messageOfDisplay(Au){const lo=Au.data?.message_id;if(typeof lo!="string"||!lo)throw new Error(`Display ${Au.id} says no message it is under`);return lo}function speakerOf(Au){return{id:`author:${Au}`,name:Au}}function changed(Au,lo,$u){const Ru=Au.findIndex(Iu=>(Iu.displays??[]).some(Pu=>Pu.id===lo));if(Ru<0)throw new Error(`Display ${lo} is shown under no message here`);return Au.map((Iu,Pu)=>{if(Pu!==Ru)return Iu;const Ou=[];for(const Mu of Iu.displays??[]){if(Mu.id!==lo){Ou.push(Mu);continue}const Du=$u(Mu);Du&&Ou.push({...Du,id:lo})}return{...Iu,displays:Ou}})}function replaced(Au,lo){const $u=Au.findIndex(Ru=>Ru.id===lo.id);return $u<0?[...Au,lo]:Au.map((Ru,Iu)=>Iu===$u?lo:Ru)}function withUiOp(Au,lo){switch(lo.op){case"show":case"ask":{const $u=lo.body,Ru=messageOfDisplay($u);if(!Au.some(Iu=>Iu.id===Ru))throw new Error(`Display ${$u.id} is under message ${Ru}, which is not here`);return Au.map(Iu=>Iu.id===Ru?{...Iu,displays:replaced(Iu.displays??[],$u)}:Iu)}case"remove":{if(Au.some(Ru=>(Ru.displays??[]).some(Iu=>Iu.id===lo.id)))return changed(Au,lo.id,()=>{});if(!Au.some(Ru=>Ru.id===lo.id))throw new Error(`Nothing here is ${lo.id}: it cannot be removed`);return Au.filter(Ru=>Ru.id!==lo.id)}case"patch":{const $u=lo.body;return changed(Au,lo.id,Ru=>applyPatch$1(Ru,$u))}case"append":{const{path:$u,value:Ru}=lo.body;return changed(Au,lo.id,Iu=>applyPatch$1(Iu,[{op:"add",path:`${$u}/-`,value:Ru}]))}case"meta":{const $u=lo.body.author,Ru=Object.keys(lo.body);if(!lo.id||Ru.length!==1||typeof $u!="string"||!$u.trim())throw new Error(`A meta op says ${JSON.stringify(lo.body)}: only a message's author is read`);if(!Au.some(Iu=>Iu.id===lo.id))throw new Error(`Message ${lo.id} is not here: it has no author to say`);return Au.map(Iu=>Iu.id===lo.id?{...Iu,speaker:speakerOf($u.trim())}:Iu)}case"window":throw new Error("A window op is for the page, not the messages");default:return Au}}function routeUiOp(Au,lo,$u){switch(Au.op){case"window":return{routed:{to:"window",data:windowMessageOf(Au)},steps:lo};case"show":case"ask":{if(isStepDisplay(Au.body)){const Iu=applyUiOp(lo,Au);return{routed:{to:"step",step:stepOfDisplay(Au.body)},steps:Iu}}const Ru=elementOfDisplay(Au.body);return Ru?{routed:{to:"element",change:Ru},steps:lo}:{routed:{to:"messages",op:Au},steps:lo}}case"patch":case"append":{if(Au.id in lo.displays){const Ru=applyUiOp(lo,Au);return{routed:{to:"step",step:stepOfDisplay(Ru.displays[Au.id])},steps:Ru}}return{routed:{to:"messages",op:Au},steps:lo}}case"remove":{if(Au.id in lo.displays)throw new Error(`Step ${Au.id} is never removed: it ends`);return $u.has(Au.id)?{routed:{to:"element",change:{id:Au.id,closed:!0}},steps:lo}:{routed:{to:"messages",op:Au},steps:lo}}default:return{routed:{to:"messages",op:Au},steps:lo}}}function placeable(Au,lo){const $u=Iu=>!!Iu&&Au.some(Pu=>Pu.id===Iu),Ru=Iu=>!!Iu&&Au.some(Pu=>(Pu.displays??[]).some(Ou=>Ou.id===Iu));switch(lo.op){case"show":case"ask":{const Iu=lo.body.data?.message_id;return typeof Iu=="string"&&$u(Iu)}case"meta":return $u(lo.id);case"patch":case"append":return Ru(lo.id);case"remove":return Ru(lo.id)||$u(lo.id);default:return!0}}function displayPressOf(Au){const $u=Au?.loop?.action;if(!$u||typeof $u.display_id!="string")return null;if(typeof $u.name!="string"||typeof $u.token!="string")throw new Error("A press of a display says its action and its token");return{action:$u.name,display_id:$u.display_id,token:$u.token,payload:$u.payload??{}}}function withPress(Au,lo){const $u=lo?.press;if(typeof $u!="string"||!$u)throw new Error("The runtime checked the press but named none");const Ru={...Au.loop};return delete Ru.action,{...Au,loop:{...Ru,press:$u}}}function blobOfDataUrl(Au,lo,$u){const[Ru,Iu]=[Au.slice(0,Au.indexOf(",")),Au.slice(Au.indexOf(",")+1)];if(!Ru.startsWith("data:")||Au.indexOf(",")<0)throw new Error(`${lo} could not be read: it is not a data URL.`);const Pu=$u||Ru.slice(5).split(";")[0];let Ou;if(Ru.endsWith(";base64")){const Mu=atob(Iu);Ou=new Uint8Array(Mu.length);for(let Du=0;Du<Mu.length;Du+=1)Ou[Du]=Mu.charCodeAt(Du)}else Ou=new TextEncoder().encode(decodeURIComponent(Iu));return Object.assign(new Blob([Ou],{type:Pu}),{name:lo})}function namesFiles(Au){const lo=Au?.loop?.files;return Array.isArray(lo)&&lo.length>0}async function withUploadedFiles(Au,lo){const $u=Au.loop,Ru=$u.files,Iu=[];for(const Pu of Ru){if(isFileRef(Pu)){Iu.push(Pu);continue}const Ou=Pu;if(typeof Ou.name!="string"||typeof Ou.data_url!="string")throw new Error("A file given is neither the page’s nor a ref.");Iu.push(await lo(blobOfDataUrl(Ou.data_url,Ou.name,typeof Ou.type=="string"?Ou.type:void 0)))}return{...Au,loop:{...$u,files:Iu}}}const EphemeralDocument=vM.lazy(()=>__vitePreload(()=>import("./chunks/EphemeralDocument--pV47gPl.js"),[],import.meta.url).then(Au=>({default:Au.EphemeralDocument}))),loadAgentDetails=()=>__vitePreload(()=>import("./chunks/AgentDetails-Xvq2IvHg.js"),[],import.meta.url).then(Au=>({default:Au.AgentDetails})),loadEphemeralNotebook=()=>__vitePreload(()=>import("./chunks/EphemeralNotebook-BqccUXGd.js"),[],import.meta.url).then(Au=>({default:Au.EphemeralNotebook})),lazyViewRefused=Au=>lo=>jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{p:3,color:"danger.fg"},children:`The ${Au} could not be loaded: ${lo.message}`}),agentDetailsRefused=lazyViewRefused("agent details"),ephemeralNotebookRefused=lazyViewRefused("notebook"),sentPendingPromptKeys=new Set;function frontendToolExpectsArgs(Au){const lo=Au?.parameters;if(!lo)return!1;if(Array.isArray(lo))return lo.length>0;const $u=lo.properties;return $u&&typeof $u=="object"?Object.keys($u).length>0:Object.keys(lo).length>0}function CompanionSurfaceSkeleton({mode:Au}){return jsxRuntimeExports.jsx(Box,{"aria-label":Au==="notebook"?"Preparing notebook…":"Preparing document…",flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column",gap:3,p:4,children:Au==="notebook"?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:[0,1,2].map(lo=>jsxRuntimeExports.jsxs(Box,{p:3,border:"1px solid",borderColor:"border.muted",borderRadius:2,bg:"canvas.subtle",display:"flex",flexDirection:"column",gap:2,children:[jsxRuntimeExports.jsx(SkeletonText,{lines:1}),jsxRuntimeExports.jsx(SkeletonText,{lines:lo===0?2:3})]},lo))}):jsxRuntimeExports.jsxs(Box,{maxWidth:860,width:"100%",mx:"auto",display:"flex",flexDirection:"column",gap:3,children:[jsxRuntimeExports.jsx(SkeletonText,{lines:1}),jsxRuntimeExports.jsx(SkeletonText,{lines:4}),jsxRuntimeExports.jsx(SkeletonText,{lines:3}),jsxRuntimeExports.jsx(SkeletonText,{lines:5})]})})}const ThemedJupyterReactTheme=JupyterReactTheme$1;function ThemedChatBoundary({children:Au,themeVariant:lo,colorMode:$u,themeOverrides:Ru}){const Iu=useThemeStore(zu=>zu.colorMode),Pu=useThemeStore(zu=>zu.theme),Ou=$u??Iu,Mu=lo??Pu,Du=useSystemColorMode(),Lu=getThemeConfig(Mu),Bu=Ou==="auto"?Du:Ou,ju={...Bu==="dark"?Lu.themeStyles.dark:Lu.themeStyles.light,...Ru?.[Bu]},Fu=ju.backgroundColor??"";return jsxRuntimeExports.jsx(ThemedJupyterReactTheme,{colormode:Bu,theme:Lu.primerTheme,backgroundColor:Fu,loadJupyterLabCss:!1,style:{...ju,color:"var(--fgColor-default)",fontSize:"var(--text-body-size-medium)",display:"contents"},children:Au})}const AI_AGENTS_API_PREFIX="/api/ai-agents/v1",isDevTraceEnabled=()=>{try{return!1}catch{return!1}},logApprovalTrace=(Au,lo)=>{isDevTraceEnabled()&&console.debug(`[approval-trace] ${Au}`,lo)},normalizeAgentId=Au=>(Au??"").trim().toLowerCase(),normalizeToolName=Au=>Au.replace(/[-_]/g,"").toLowerCase(),normalizeSkillApprovalId=Au=>{const lo=Au.indexOf(":");return lo<=0?Au:Au.slice(0,lo)},stableStringify=Au=>Au===null||typeof Au!="object"?JSON.stringify(Au):Array.isArray(Au)?`[${Au.map($u=>stableStringify($u)).join(",")}]`:`{${Object.entries(Au).sort(([$u],[Ru])=>$u.localeCompare(Ru)).map(([$u,Ru])=>`${JSON.stringify($u)}:${stableStringify(Ru)}`).join(",")}}`,approvalSignature=(Au,lo)=>`${normalizeToolName(Au)}::${stableStringify(lo??{})}`,normalizeAiAgentsBaseUrl=Au=>{const lo=Au.replace(/\/$/,"");return lo.endsWith(AI_AGENTS_API_PREFIX)?lo.slice(0,-AI_AGENTS_API_PREFIX.length):lo},toWsUrl=(Au,lo,$u)=>{try{const Ru=new URL(Au);return Ru.protocol=Ru.protocol==="https:"?"wss:":"ws:",Ru.pathname=lo,$u?Ru.searchParams.set("token",$u):Ru.search="",Ru.toString()}catch{return null}},normalizeApprovalPayload=Au=>{const lo=typeof Au.id=="string"&&Au.id||typeof Au.approval_id=="string"&&Au.approval_id||typeof Au.approvalId=="string"&&Au.approvalId||"",$u=typeof Au.tool_name=="string"&&Au.tool_name||typeof Au.toolName=="string"&&Au.toolName||"";if(!lo||!$u)return null;const Ru=(Au.tool_args&&typeof Au.tool_args=="object"?Au.tool_args:Au.toolArgs&&typeof Au.toolArgs=="object"?Au.toolArgs:void 0)??{};return{id:lo,tool_name:$u,tool_args:Ru,tool_call_id:typeof Au.tool_call_id=="string"&&Au.tool_call_id||typeof Au.toolCallId=="string"&&Au.toolCallId||void 0,note:typeof Au.note=="string"&&Au.note||typeof Au.message=="string"&&Au.message||void 0,status:typeof Au.status=="string"&&Au.status||"pending",agent_id:typeof Au.agent_id=="string"&&Au.agent_id||typeof Au.agentId=="string"&&Au.agentId||void 0,created_at:typeof Au.created_at=="string"&&Au.created_at||typeof Au.createdAt=="string"&&Au.createdAt||void 0,updated_at:typeof Au.updated_at=="string"&&Au.updated_at||typeof Au.updatedAt=="string"&&Au.updatedAt||void 0}},statusFromApprovalEvent=Au=>{if(Au==="tool_approval_created")return"pending";if(Au==="tool_approval_approved")return"approved";if(Au==="tool_approval_rejected")return"rejected";if(Au==="tool_approval_deleted")return"deleted"},RESOLVED_TOOL_CALL_SUPPRESSION_MS=15e3,isApprovalForAgent=(Au,lo)=>{if(!lo)return!0;if(!Au.agent_id)return!1;if(Au.agent_id===lo)return!0;const $u=normalizeAgentId(Au.agent_id),Ru=normalizeAgentId(lo);return $u.includes(Ru)||Ru.includes($u)};function isToolCallOnlyPrompt(Au){const lo=Au.toLowerCase();return/tool\s*call\s*only/.test(lo)||/use\s+(?:a\s+)?tool\s+call\s+only/.test(lo)}function formatToolResultFallback(Au){if(typeof Au=="string")return Au;if(typeof Au=="number"||typeof Au=="boolean"||Au===null)return String(Au);try{const lo=JSON.stringify(Au,null,2);return lo.length>2e3?`${lo.slice(0,2e3)}
|
|
3686
|
+
`).filter(Pu=>Pu.startsWith("data:")).map(Pu=>Pu.slice(5).trim()).join("");if(!Ru)continue;let Iu;try{Iu=JSON.parse(Ru)}catch{continue}if(Iu.type==="RUN_ERROR")lo=String(Iu.message??"The turn failed.");else if(Iu.type==="CUSTOM"&&Iu.name===AGUI_NAME)throw new Error("A reactor.ui op came on the run stream: it comes over the ui socket.")}return lo}function messageOfDisplay(Au){const lo=Au.data?.message_id;if(typeof lo!="string"||!lo)throw new Error(`Display ${Au.id} says no message it is under`);return lo}function speakerOf(Au){return{id:`author:${Au}`,name:Au}}function changed(Au,lo,$u){const Ru=Au.findIndex(Iu=>(Iu.displays??[]).some(Pu=>Pu.id===lo));if(Ru<0)throw new Error(`Display ${lo} is shown under no message here`);return Au.map((Iu,Pu)=>{if(Pu!==Ru)return Iu;const Ou=[];for(const Mu of Iu.displays??[]){if(Mu.id!==lo){Ou.push(Mu);continue}const Du=$u(Mu);Du&&Ou.push({...Du,id:lo})}return{...Iu,displays:Ou}})}function replaced(Au,lo){const $u=Au.findIndex(Ru=>Ru.id===lo.id);return $u<0?[...Au,lo]:Au.map((Ru,Iu)=>Iu===$u?lo:Ru)}function withUiOp(Au,lo){switch(lo.op){case"show":case"ask":{const $u=lo.body,Ru=messageOfDisplay($u);if(!Au.some(Iu=>Iu.id===Ru))throw new Error(`Display ${$u.id} is under message ${Ru}, which is not here`);return Au.map(Iu=>Iu.id===Ru?{...Iu,displays:replaced(Iu.displays??[],$u)}:Iu)}case"remove":{if(Au.some(Ru=>(Ru.displays??[]).some(Iu=>Iu.id===lo.id)))return changed(Au,lo.id,()=>{});if(!Au.some(Ru=>Ru.id===lo.id))throw new Error(`Nothing here is ${lo.id}: it cannot be removed`);return Au.filter(Ru=>Ru.id!==lo.id)}case"patch":{const $u=lo.body;return changed(Au,lo.id,Ru=>applyPatch$1(Ru,$u))}case"append":{const{path:$u,value:Ru}=lo.body;return changed(Au,lo.id,Iu=>applyPatch$1(Iu,[{op:"add",path:`${$u}/-`,value:Ru}]))}case"meta":{const $u=lo.body.author,Ru=Object.keys(lo.body);if(!lo.id||Ru.length!==1||typeof $u!="string"||!$u.trim())throw new Error(`A meta op says ${JSON.stringify(lo.body)}: only a message's author is read`);if(!Au.some(Iu=>Iu.id===lo.id))throw new Error(`Message ${lo.id} is not here: it has no author to say`);return Au.map(Iu=>Iu.id===lo.id?{...Iu,speaker:speakerOf($u.trim())}:Iu)}case"window":throw new Error("A window op is for the page, not the messages");default:return Au}}function routeUiOp(Au,lo,$u){switch(Au.op){case"window":return{routed:{to:"window",data:windowMessageOf(Au)},steps:lo};case"show":case"ask":{if(isStepDisplay(Au.body)){const Iu=applyUiOp(lo,Au);return{routed:{to:"step",step:stepOfDisplay(Au.body)},steps:Iu}}const Ru=elementOfDisplay(Au.body);return Ru?{routed:{to:"element",change:Ru},steps:lo}:{routed:{to:"messages",op:Au},steps:lo}}case"patch":case"append":{if(Au.id in lo.displays){const Ru=applyUiOp(lo,Au);return{routed:{to:"step",step:stepOfDisplay(Ru.displays[Au.id])},steps:Ru}}return{routed:{to:"messages",op:Au},steps:lo}}case"remove":{if(Au.id in lo.displays)throw new Error(`Step ${Au.id} is never removed: it ends`);return $u.has(Au.id)?{routed:{to:"element",change:{id:Au.id,closed:!0}},steps:lo}:{routed:{to:"messages",op:Au},steps:lo}}default:return{routed:{to:"messages",op:Au},steps:lo}}}function placeable(Au,lo){const $u=Iu=>!!Iu&&Au.some(Pu=>Pu.id===Iu),Ru=Iu=>!!Iu&&Au.some(Pu=>(Pu.displays??[]).some(Ou=>Ou.id===Iu));switch(lo.op){case"show":case"ask":{const Iu=lo.body.data?.message_id;return typeof Iu=="string"&&$u(Iu)}case"meta":return $u(lo.id);case"patch":case"append":return Ru(lo.id);case"remove":return Ru(lo.id)||$u(lo.id);default:return!0}}function displayPressOf(Au){const $u=Au?.loop?.action;if(!$u||typeof $u.display_id!="string")return null;if(typeof $u.name!="string"||typeof $u.token!="string")throw new Error("A press of a display says its action and its token");return{action:$u.name,display_id:$u.display_id,token:$u.token,payload:$u.payload??{}}}function withPress(Au,lo){const $u=lo?.press;if(typeof $u!="string"||!$u)throw new Error("The runtime checked the press but named none");const Ru={...Au.loop};return delete Ru.action,{...Au,loop:{...Ru,press:$u}}}function blobOfDataUrl(Au,lo,$u){const[Ru,Iu]=[Au.slice(0,Au.indexOf(",")),Au.slice(Au.indexOf(",")+1)];if(!Ru.startsWith("data:")||Au.indexOf(",")<0)throw new Error(`${lo} could not be read: it is not a data URL.`);const Pu=$u||Ru.slice(5).split(";")[0];let Ou;if(Ru.endsWith(";base64")){const Mu=atob(Iu);Ou=new Uint8Array(Mu.length);for(let Du=0;Du<Mu.length;Du+=1)Ou[Du]=Mu.charCodeAt(Du)}else Ou=new TextEncoder().encode(decodeURIComponent(Iu));return Object.assign(new Blob([Ou],{type:Pu}),{name:lo})}function namesFiles(Au){const lo=Au?.loop?.files;return Array.isArray(lo)&&lo.length>0}async function withUploadedFiles(Au,lo){const $u=Au.loop,Ru=$u.files,Iu=[];for(const Pu of Ru){if(isFileRef(Pu)){Iu.push(Pu);continue}const Ou=Pu;if(typeof Ou.name!="string"||typeof Ou.data_url!="string")throw new Error("A file given is neither the page’s nor a ref.");Iu.push(await lo(blobOfDataUrl(Ou.data_url,Ou.name,typeof Ou.type=="string"?Ou.type:void 0)))}return{...Au,loop:{...$u,files:Iu}}}const EphemeralDocument=vM.lazy(()=>__vitePreload(()=>import("./chunks/EphemeralDocument-rusBlgBp.js"),[],import.meta.url).then(Au=>({default:Au.EphemeralDocument}))),loadAgentDetails=()=>__vitePreload(()=>import("./chunks/AgentDetails-Xvq2IvHg.js"),[],import.meta.url).then(Au=>({default:Au.AgentDetails})),loadEphemeralNotebook=()=>__vitePreload(()=>import("./chunks/EphemeralNotebook-BqccUXGd.js"),[],import.meta.url).then(Au=>({default:Au.EphemeralNotebook})),lazyViewRefused=Au=>lo=>jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{p:3,color:"danger.fg"},children:`The ${Au} could not be loaded: ${lo.message}`}),agentDetailsRefused=lazyViewRefused("agent details"),ephemeralNotebookRefused=lazyViewRefused("notebook"),sentPendingPromptKeys=new Set;function frontendToolExpectsArgs(Au){const lo=Au?.parameters;if(!lo)return!1;if(Array.isArray(lo))return lo.length>0;const $u=lo.properties;return $u&&typeof $u=="object"?Object.keys($u).length>0:Object.keys(lo).length>0}function CompanionSurfaceSkeleton({mode:Au}){return jsxRuntimeExports.jsx(Box,{"aria-label":Au==="notebook"?"Preparing notebook…":"Preparing document…",flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column",gap:3,p:4,children:Au==="notebook"?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:[0,1,2].map(lo=>jsxRuntimeExports.jsxs(Box,{p:3,border:"1px solid",borderColor:"border.muted",borderRadius:2,bg:"canvas.subtle",display:"flex",flexDirection:"column",gap:2,children:[jsxRuntimeExports.jsx(SkeletonText,{lines:1}),jsxRuntimeExports.jsx(SkeletonText,{lines:lo===0?2:3})]},lo))}):jsxRuntimeExports.jsxs(Box,{maxWidth:860,width:"100%",mx:"auto",display:"flex",flexDirection:"column",gap:3,children:[jsxRuntimeExports.jsx(SkeletonText,{lines:1}),jsxRuntimeExports.jsx(SkeletonText,{lines:4}),jsxRuntimeExports.jsx(SkeletonText,{lines:3}),jsxRuntimeExports.jsx(SkeletonText,{lines:5})]})})}const ThemedJupyterReactTheme=JupyterReactTheme$1;function ThemedChatBoundary({children:Au,themeVariant:lo,colorMode:$u,themeOverrides:Ru}){const Iu=useThemeStore(zu=>zu.colorMode),Pu=useThemeStore(zu=>zu.theme),Ou=$u??Iu,Mu=lo??Pu,Du=useSystemColorMode(),Lu=getThemeConfig(Mu),Bu=Ou==="auto"?Du:Ou,ju={...Bu==="dark"?Lu.themeStyles.dark:Lu.themeStyles.light,...Ru?.[Bu]},Fu=ju.backgroundColor??"";return jsxRuntimeExports.jsx(ThemedJupyterReactTheme,{colormode:Bu,theme:Lu.primerTheme,backgroundColor:Fu,loadJupyterLabCss:!1,style:{...ju,color:"var(--fgColor-default)",fontSize:"var(--text-body-size-medium)",display:"contents"},children:Au})}const AI_AGENTS_API_PREFIX="/api/ai-agents/v1",isDevTraceEnabled=()=>{try{return!1}catch{return!1}},logApprovalTrace=(Au,lo)=>{isDevTraceEnabled()&&console.debug(`[approval-trace] ${Au}`,lo)},normalizeAgentId=Au=>(Au??"").trim().toLowerCase(),normalizeToolName=Au=>Au.replace(/[-_]/g,"").toLowerCase(),normalizeSkillApprovalId=Au=>{const lo=Au.indexOf(":");return lo<=0?Au:Au.slice(0,lo)},stableStringify=Au=>Au===null||typeof Au!="object"?JSON.stringify(Au):Array.isArray(Au)?`[${Au.map($u=>stableStringify($u)).join(",")}]`:`{${Object.entries(Au).sort(([$u],[Ru])=>$u.localeCompare(Ru)).map(([$u,Ru])=>`${JSON.stringify($u)}:${stableStringify(Ru)}`).join(",")}}`,approvalSignature=(Au,lo)=>`${normalizeToolName(Au)}::${stableStringify(lo??{})}`,normalizeAiAgentsBaseUrl=Au=>{const lo=Au.replace(/\/$/,"");return lo.endsWith(AI_AGENTS_API_PREFIX)?lo.slice(0,-AI_AGENTS_API_PREFIX.length):lo},toWsUrl=(Au,lo,$u)=>{try{const Ru=new URL(Au);return Ru.protocol=Ru.protocol==="https:"?"wss:":"ws:",Ru.pathname=lo,$u?Ru.searchParams.set("token",$u):Ru.search="",Ru.toString()}catch{return null}},normalizeApprovalPayload=Au=>{const lo=typeof Au.id=="string"&&Au.id||typeof Au.approval_id=="string"&&Au.approval_id||typeof Au.approvalId=="string"&&Au.approvalId||"",$u=typeof Au.tool_name=="string"&&Au.tool_name||typeof Au.toolName=="string"&&Au.toolName||"";if(!lo||!$u)return null;const Ru=(Au.tool_args&&typeof Au.tool_args=="object"?Au.tool_args:Au.toolArgs&&typeof Au.toolArgs=="object"?Au.toolArgs:void 0)??{};return{id:lo,tool_name:$u,tool_args:Ru,tool_call_id:typeof Au.tool_call_id=="string"&&Au.tool_call_id||typeof Au.toolCallId=="string"&&Au.toolCallId||void 0,note:typeof Au.note=="string"&&Au.note||typeof Au.message=="string"&&Au.message||void 0,status:typeof Au.status=="string"&&Au.status||"pending",agent_id:typeof Au.agent_id=="string"&&Au.agent_id||typeof Au.agentId=="string"&&Au.agentId||void 0,created_at:typeof Au.created_at=="string"&&Au.created_at||typeof Au.createdAt=="string"&&Au.createdAt||void 0,updated_at:typeof Au.updated_at=="string"&&Au.updated_at||typeof Au.updatedAt=="string"&&Au.updatedAt||void 0}},statusFromApprovalEvent=Au=>{if(Au==="tool_approval_created")return"pending";if(Au==="tool_approval_approved")return"approved";if(Au==="tool_approval_rejected")return"rejected";if(Au==="tool_approval_deleted")return"deleted"},RESOLVED_TOOL_CALL_SUPPRESSION_MS=15e3,isApprovalForAgent=(Au,lo)=>{if(!lo)return!0;if(!Au.agent_id)return!1;if(Au.agent_id===lo)return!0;const $u=normalizeAgentId(Au.agent_id),Ru=normalizeAgentId(lo);return $u.includes(Ru)||Ru.includes($u)};function isToolCallOnlyPrompt(Au){const lo=Au.toLowerCase();return/tool\s*call\s*only/.test(lo)||/use\s+(?:a\s+)?tool\s+call\s+only/.test(lo)}function formatToolResultFallback(Au){if(typeof Au=="string")return Au;if(typeof Au=="number"||typeof Au=="boolean"||Au===null)return String(Au);try{const lo=JSON.stringify(Au,null,2);return lo.length>2e3?`${lo.slice(0,2e3)}
|
|
3687
3687
|
...`:lo}catch{return"Tool completed successfully."}}function parseEnabledMcpToolsByServer(Au){if(!Au||typeof Au!="object")return null;const lo=Au.enabled_tools_by_server;if(lo==null)return new Map;if(typeof lo!="object")return new Map;const $u=new Map;for(const[Ru,Iu]of Object.entries(lo)){if(!Array.isArray(Iu))continue;const Ou=Iu.filter(Mu=>typeof Mu=="string"&&Mu.length>0).map(Mu=>{const Du=Mu.indexOf("__");return Du>=0?Mu.slice(Du+2):Mu});$u.set(Ru,new Set(Ou))}return $u}function parseApprovedMcpToolsByServer(Au){if(!Au||typeof Au!="object")return null;const lo=Au.approved_tools_by_server;if(lo==null)return new Map;if(typeof lo!="object")return new Map;const $u=new Map;for(const[Ru,Iu]of Object.entries(lo)){if(!Array.isArray(Iu))continue;const Ou=Iu.filter(Mu=>typeof Mu=="string"&&Mu.length>0).map(Mu=>{const Du=Mu.indexOf("__");return Du>=0?Mu.slice(Du+2):Mu});$u.set(Ru,new Set(Ou))}return $u}const WELCOME_AT=new Date(0);function ChatBase(Au){const{agentRuntimeConfig:lo,protocol:$u,useStore:Ru=!0,disableInternalJupyterTheme:Iu=!1,themeVariant:Pu,colorMode:Ou,themeOverrides:Mu}=Au,Bu=lo?{type:(typeof $u=="string"?$u:void 0)||lo.protocol||"vercel-ai",endpoint:lo.url,authToken:lo.authToken,agentId:lo.agentId,enableConfigQuery:!0,configEndpoint:`${lo.url}/api/v1/config`}:typeof $u=="object"?$u:void 0,ju=lo?!1:Ru,Fu=reactExports.useContext(QueryClientContext),zu={...Au,protocol:Bu,useStore:ju},Uu=jsxRuntimeExports.jsx(ChatBaseInner,{...zu}),Hu=Iu?Uu:jsxRuntimeExports.jsx(ThemedChatBoundary,{themeVariant:Pu,colorMode:Ou,themeOverrides:Mu,children:Uu});return Fu?Hu:jsxRuntimeExports.jsx(QueryClientProvider,{client:internalQueryClient,children:Hu})}function ChatBaseInner({title:Au,subtitle:lo,showHeader:$u=!1,showTokenUsage:Ru=!0,showContextRing:Iu=!1,showLoadingIndicator:Pu=!0,showErrors:Ou=!0,showInput:Mu=!0,showModelSelector:Du=!0,showToolsMenu:Lu=!0,showSkillsMenu:Bu=!0,disableInputPrompt:ju=!1,promptVariant:Fu,mentionableAgents:zu,promptCommands:Uu,showAgentsMenu:Hu=!0,agents:Vu,selectedAgentId:Gu,onSelectAgent:Wu,disabled:Ku,disableReason:Ju,overlay:Yu,launching:Xu=!1,launchingMessage:ed,autoConnect:td=!0,codemodeEnabled:nd=!1,onToggleCodemode:od,initialModel:sd,availableModels:ad,mcpServers:pd,initialSkills:gd,className:_d,loadingState:yd,headerActions:bd,kernelIndicatorState:Sd,kernelIndicatorPlacement:Ed="left",kernel:cd,kernelEnvironmentName:dd,kernelCpu:md,kernelMemory:ld,kernelGpu:hd,themeVariant:vd,colorMode:wd,chatViewMode:kd,onChatViewModeChange:Rd,disabledViewModes:Od,useStore:jd=!0,protocol:Cd,onSendMessage:Ad,onSendReady:$d,onLoadingChange:qd,onSpeakingChange:Dd,onContextSnapshot:Ud,enableStreaming:rh=!1,brandIcon:Jd,avatarConfig:vh,headerButtons:sh,showPoweredBy:Eh=!1,poweredByProps:bh,emptyState:Qd,renderHeader:th,showTurnFooter:lh=!0,notebookToolSurfacesId:Dh,footerContent:Vd,welcome:Fd,trailingContent:Id,voice:Pd,voiceSpeaking:Wd=!1,onStopSpeaking:Nd,onReadAloud:Kd,showInformation:Xd=!1,onInformationClick:gh,headerContent:wh,children:Sh,borderRadius:Kh,backgroundColor:Md,border:xd,boxShadow:Hd,compact:Zd=!1,placeholder:mh,description:ah="Start a conversation with the AI agent.",onStateUpdate:yh,onNewChat:Th,onClear:Ih,onMessagesChange:zh,onItemsChange:qh,onDisplayItemsChange:Yh,autoFocus:Oh=!1,suggestions:np,submitOnSuggestionClick:ap=!0,hideMessagesAfterToolUI:dp=!1,focusTrigger:gp,frontendTools:Qh,enableEphemeralNotebook:bp=!1,initialEphemeralNotebookOpen:lp=!0,onEphemeralNotebookOpenChange:up,enableEphemeralDocument:Vh=!1,initialEphemeralSurfaceMode:Uh,onEphemeralSurfaceModeChange:Xh,collapsed:Df=!1,onExpandFromCollapsed:Ep,ephemeralNotebookToolbar:$h,ephemeralNotebookToolbarExtraItems:jh,ephemeralDocumentToolbarExtraItems:rf,ephemeralNotebookCollaborationProvider:Fp,ephemeralNotebookCollaborationDocumentId:nf,ephemeralDocumentCollaboration:Kp,ephemeralRuntimeOverride:tp,onToolCallStart:zp,onToolCallComplete:Sf,inspector:em,onAuthorizationRequired:Nf,connectedIdentities:Lf,runtimeId:Zp,thread:pp,historyEndpoint:Mp,historyAuthToken:_p,pendingPrompt:Pp,contextSnapshot:Af,mcpStatusData:Yp,sandboxStatusData:of,showToolApprovalBanner:vp=!0,pendingApprovals:Vf,onApproveApproval:df,onRejectApproval:cm}){const Ef=useChatWords();reactExports.useEffect(()=>{setupPrimerPortals()},[]);const Um=useChatAvailability(),sf=Ku??Um.disabled,Im=Ju??Um.disableReason,{theme:_m}=useThemeStore(),Bf=getColorPalette(_m,"dark").textLight,Lh=useAgentRuntimeStore(Ld=>Ld.approvals),zd=useAgentRuntimeStore(Ld=>Ld.historyVersion),uh=useAgentRuntimeStore(Ld=>Ld.mcpStatus),Mh=Yp??uh,Nh=typeof Cd=="object"?Cd:void 0,fp=useCoreStore(Ld=>Ld.configuration?.aiAgentsUrl),Ah=Nh?.agentId||Zp,ep=Zp||Ah,Dp=Nh?.authToken,gf=reactExports.useRef(`ephemeral-notebook-${Math.random().toString(36).slice(2,10)}`),kp=Zp||Nh?.agentId||Ah,Np=nf||(kp?`ephemeral-notebook-${kp}`:gf.current),Wp=useAgentRuntimeStore(Ld=>Ld.getEphemeralNotebookModel(Np)),tm=useAgentRuntimeStore(Ld=>Ld.setEphemeralNotebookModel),Jf=reactExports.useCallback(Ld=>{tm(Np,Ld)},[Np,tm]),hf=Kp?.roomId||(kp?`ephemeral-document-${kp}`:`ephemeral-document-${gf.current}`),Pm=useAgentRuntimeStore(Ld=>Ld.getEphemeralDocumentModel(hf)),Om=useAgentRuntimeStore(Ld=>Ld.setEphemeralDocumentModel),r0=reactExports.useCallback(Ld=>{Om(hf,Ld)},[hf,Om]),um=Uh??(bp&&lp?"notebook":"none"),[_f,nm]=reactExports.useState(um),$f=reactExports.useCallback(Ld=>{nm(Ld),Xh?.(Ld),up?.(Ld==="notebook")},[Xh,up]),qp=bp&&_f==="notebook",Cf=Vh&&_f==="document",yp=qp||Cf,Tf=yp&&Df,Rf=Tf?{key:"ephemeral-surface",type:"custom",order:900,render:()=>jsxRuntimeExports.jsx(EphemeralSurfaceControl,{mode:_f,onChange:$f,enableNotebook:bp,enableDocument:Vh,enableChatOnly:!1})}:null,Gh=Rf?[...jh??[],Rf]:jh,Lp=Rf?[...rf??[],Rf]:rf,[Jp,xf]=reactExports.useState(null);reactExports.useEffect(()=>{if(!qp){xf(null);return}const Ld=()=>notebookStore.getState().selectNotebook(Np)?.adapter?.kernel??null,Gd=()=>{const nh=Ld();xf(_h=>_h?.id===nh?.id?_h:nh)};Gd();const ih=window.setInterval(Gd,750),ph=notebookStore.subscribe(Gd);return()=>{window.clearInterval(ih),ph()}},[qp,Np]);const[If,om]=reactExports.useState(null),Gf=reactExports.useCallback(Ld=>{om(Gd=>Gd?.id===Ld?.id?Gd:Ld)},[]);reactExports.useEffect(()=>{Cf||om(null)},[Cf]);const wp=yp&&isFloatingChatViewMode(kd),jf=kd==="floating-small"||kd==="floating-draggable",xm=useNotebookTools(Np),[af,Zh]=reactExports.useState([]),Bp=reactExports.useCallback(Ld=>{Zh(Ld)},[]),kf=reactExports.useMemo(()=>qp?[...Qh||[],...xm]:Cf?[...Qh||[],...af]:Qh,[qp,Cf,Qh,xm,af]),Xp=reactExports.useMemo(()=>normalizeAiAgentsBaseUrl(fp||DEFAULT_SERVICE_URLS.AI_AGENTS),[fp]),lf=reactExports.useRef(null),w0=reactExports.useRef(new Map),Hm=reactExports.useCallback((Ld,Gd,ih)=>{const ph=lf.current;if(!ph||ph.readyState!==WebSocket.OPEN)return logApprovalTrace("send_decision_skipped_ws_not_ready",{approvalId:Ld,approved:Gd,wsReadyState:ph?.readyState}),!1;try{return logApprovalTrace("send_decision",{approvalId:Ld,approved:Gd,hasNote:!!ih}),ph.send(JSON.stringify({type:"tool_approval_decision",approvalId:Ld,approved:Gd,...ih?{note:ih}:{}})),!0}catch{return logApprovalTrace("send_decision_failed",{approvalId:Ld,approved:Gd}),!1}},[]),qm=reactExports.useCallback(()=>{const Ld=lf.current;if(!Ld||Ld.readyState!==WebSocket.OPEN)return!1;try{return Ld.send(JSON.stringify({type:"tool-approvals-history"})),logApprovalTrace("request_history",{}),!0}catch{return!1}},[]),im=reactExports.useCallback(Ld=>{Ld&&(w0.current.set(Ld,Date.now()+RESOLVED_TOOL_CALL_SUPPRESSION_MS),logApprovalTrace("suppress_pending_for_tool_call",{toolCallId:Ld,windowMs:RESOLVED_TOOL_CALL_SUPPRESSION_MS}))},[]),Og=reactExports.useCallback(Ld=>{if(!Ld)return!1;const Gd=w0.current.get(Ld);return Gd?Gd<Date.now()?(w0.current.delete(Ld),!1):!0:!1},[]),tg=reactExports.useCallback((Ld,Gd,ih)=>{window.setTimeout(()=>{if(!agentRuntimeStore.getState().approvals.some(_h=>_h.id===Ld&&_h.status==="pending"))return;const nh=Hm(Ld,Gd,ih);logApprovalTrace("retry_send_decision",{approvalId:Ld,approved:Gd,sent:nh}),nh&&qm()},500)},[qm,Hm]),l1=reactExports.useMemo(()=>Vf||Lh.filter(Ld=>Ld.status==="pending"&&isApprovalForAgent(Ld,Ah)).map(Ld=>({id:Ld.id,toolName:Ld.tool_name,toolDescription:Ld.note??void 0,args:Ld.tool_args??{},agentId:Ld.agent_id??"",requestedAt:Ld.created_at??new Date().toISOString()})),[Vf,Lh,Ah]),c1=reactExports.useCallback((Ld,Gd)=>{const ih=agentRuntimeStore.getState().approvals.find(Ph=>Ph.id===Ld),ph=ih?.tool_name;if(!ph)return;const _h=(()=>{if(ph.startsWith("skill:")){const cp=ph.slice(6);return cp?normalizeSkillApprovalId(cp):null}if(!new Set(["run_skill_script","load_skill","read_skill_resource"]).has(ph))return null;const Jh=ih?.tool_args??{},Hh=Jh.skill_name??Jh.skill??Jh.name;return typeof Hh!="string"||!Hh?null:normalizeSkillApprovalId(Hh)})();if(_h){v1(Jh=>{const Hh=new Map(Jh);return Hh.set(_h,Gd),Hh}),agentRuntimeStore.getState().sendRawMessage({type:Gd?"skill_approve":"skill_unapprove",skillId:_h},Ah)||console.warn("[ChatBase] skill_approve persistence dropped: websocket not ready");return}const Fh=ph.indexOf("__");if(Fh!==-1){const Ph=ph.slice(0,Fh),Jh=ph.slice(Fh+2);agentRuntimeStore.getState().sendRawMessage({type:"mcp_server_tool_approve",serverId:Ph,toolName:Jh,approved:Gd},Ah)||console.warn("[ChatBase] mcp_server_tool_approve persistence dropped: websocket not ready")}},[Ah]),rg=reactExports.useCallback(async(Ld,Gd,ih)=>{const nh=agentRuntimeStore.getState().approvals.find(Ph=>Ph.id===Ld)?.tool_call_id??ih;im(nh);const _h=Hm(Ld,!0,Gd);_h||console.warn("[ChatBase] ai-agents tool_approval_decision not sent: websocket not ready");const Fh=agentRuntimeStore.getState().sendDecision(Ld,!0,Gd,nh,Ah);Fh?c1(Ld,!0):console.warn("[ChatBase] tool_approval_decision dropped: websocket not ready"),(_h||Fh)&&agentRuntimeStore.getState().removeApproval(Ld),qm(),tg(Ld,!0,Gd),await df?.(Ld,Gd)},[Ah,im,df,c1,tg,qm,Hm]),u0=reactExports.useCallback(async(Ld,Gd,ih)=>{const nh=agentRuntimeStore.getState().approvals.find(Ph=>Ph.id===Ld)?.tool_call_id??ih;im(nh);const _h=Hm(Ld,!1,Gd);_h||console.warn("[ChatBase] ai-agents tool_approval_decision not sent: websocket not ready");const Fh=agentRuntimeStore.getState().sendDecision(Ld,!1,Gd,nh,Ah);Fh||console.warn("[ChatBase] tool_approval_decision dropped: websocket not ready"),(_h||Fh)&&agentRuntimeStore.getState().removeApproval(Ld),qm(),tg(Ld,!1,Gd),await cm?.(Ld,Gd)},[Ah,im,cm,tg,qm,Hm]),u1=reactExports.useRef(null),d1=reactExports.useCallback(Ld=>{const Gd=agentRuntimeStore.getState(),ih=new Set([Ld.id]),nh=!!Ld.tool_name?approvalSignature(Ld.tool_name,Ld.tool_args??{}):null;for(const _h of Gd.approvals){if(_h.status!=="pending"||!isApprovalForAgent(_h,Ah))continue;if(_h.id===Ld.id){ih.add(_h.id);continue}if(Ld.tool_call_id&&_h.tool_call_id&&_h.tool_call_id===Ld.tool_call_id){ih.add(_h.id);continue}if(!nh||!_h.tool_name)continue;approvalSignature(_h.tool_name,_h.tool_args??{})===nh&&ih.add(_h.id)}for(const _h of ih)Gd.removeApproval(_h)},[Ah]);reactExports.useEffect(()=>{if(!vp||Vf||!Dp)return;const Ld=toWsUrl(Xp,`${AI_AGENTS_API_PREFIX}/ws`,Dp);if(!Ld)return;let Gd=!1;const ih=new WebSocket(Ld);return lf.current=ih,ih.onopen=()=>{logApprovalTrace("ws_open_request_history",{activeAgentId:Ah}),ih.send(JSON.stringify({type:"tool-approvals-history"}))},ih.onmessage=ph=>{try{const nh=JSON.parse(String(ph.data)),_h=[],Fh=typeof nh.type=="string"?nh.type:void 0,Ph=typeof nh.event=="string"?nh.event:void 0;if(Fh==="tool-approvals-history"){const cp=(nh.data&&typeof nh.data=="object"?nh.data:{}).approvals;if(Array.isArray(cp))for(const Wh of cp)Wh&&typeof Wh=="object"&&_h.push(Wh)}else if(Ph?.startsWith("tool_approval_")){const Hh=nh.data&&typeof nh.data=="object"?nh.data:nh.payload&&typeof nh.payload=="object"?nh.payload:null;if(Hh){const cp=statusFromApprovalEvent(Ph);logApprovalTrace("recv_tool_approval_event",{event:Ph,approvalId:typeof Hh.id=="string"?Hh.id:typeof Hh.approval_id=="string"?Hh.approval_id:void 0,status:typeof Hh.status=="string"?Hh.status:cp}),_h.push(cp&&typeof Hh.status!="string"?{...Hh,status:cp}:Hh)}}if(_h.length===0)return;const Jh=agentRuntimeStore.getState();for(const Hh of _h){let cp=normalizeApprovalPayload(Hh);if(!cp){const Vp=typeof Hh.id=="string"&&Hh.id||typeof Hh.approval_id=="string"&&Hh.approval_id||typeof Hh.approvalId=="string"&&Hh.approvalId||"",jp=typeof Hh.status=="string"&&Hh.status||"";if(Vp&&jp&&jp!=="pending"){const Kf=Jh.approvals.find(Rm=>Rm.id===Vp);Kf&&(cp={...Kf,status:jp})}}if(!cp)continue;const Wh=cp.agent_id||!Ah?cp:{...cp,agent_id:Ah};if(isApprovalForAgent(Wh,Ah)){if(Wh.status==="pending"&&Og(Wh.tool_call_id)){logApprovalTrace("drop_transient_pending",{approvalId:Wh.id,toolCallId:Wh.tool_call_id,status:Wh.status});continue}logApprovalTrace("apply_tool_approval_update",{approvalId:Wh.id,status:Wh.status,agentId:Wh.agent_id,activeAgentId:Ah}),Wh.status==="pending"?Jh.upsertApproval(Wh):(d1(Wh),u1.current?.(Wh,Wh.status==="approved",Wh.note??void 0))}}}catch{}},ih.onclose=()=>{Gd||(lf.current=null)},ih.onerror=()=>{lf.current=null},()=>{Gd=!0,lf.current=null,ih.close()}},[vp,Vf,Xp,Dp,Ah,Og,d1]);const ip=typeof Cd=="object"?Cd:void 0,P1=ip?JSON.stringify(ip):"",Mg="agent-runtimes",dm=useChatStore(Ld=>Ld.clearMessages),L0=ip?.type==="a2a",[Dg,O1]=reactExports.useState(()=>emptyConversation(BROWSER_LIMITS)),Mm=reactExports.useRef(Dg),Xf=reactExports.useRef(!1),Ff=reactExports.useCallback(Ld=>{const Gd=Ld(Mm.current);Gd!==Mm.current&&(Mm.current=Gd,Xf.current=!0,O1(Gd))},[]),[B0,ng]=reactExports.useState(emptyChatLayer),d0=reactExports.useRef(B0),sm=reactExports.useCallback(Ld=>{const Gd=Ld(d0.current);Gd!==d0.current&&(d0.current=Gd,ng(Gd))},[]),n0=reactExports.useCallback(()=>{Ff(()=>emptyConversation(BROWSER_LIMITS)),sm(()=>emptyChatLayer())},[Ff,sm]),S0=reactExports.useCallback(Ld=>{let Gd;try{Gd=reduceConversation(emptyConversation(BROWSER_LIMITS),snapshotOfMessages(Ld))}catch(ph){console.error("[ChatBase] Conversation not read again:",ph),Cp(ph instanceof Error?ph:new Error(String(ph)));return}const ih=new Map;for(const ph of Ld){const{id:nh,role:_h,content:Fh,toolCalls:Ph,...Jh}=ph;ih.set(nh,Jh)}sm(()=>({...emptyChatLayer(),extras:ih})),Ff(()=>Gd)},[Ff,sm]),Wf=reactExports.useCallback(Ld=>Ff(Gd=>reduceConversation(Gd,Ld)),[Ff]),Vm=reactExports.useCallback(Ld=>{const Gd=Mm.current.items.find(ih=>ih.kind==="tool"&&ih.id===Ld);return Gd&&Gd.kind==="tool"?toolCallOf(Gd):void 0},[]),Ng=reactExports.useCallback(()=>Mm.current.items.flatMap(Ld=>Ld.kind==="tool"?[toolCallOf(Ld)]:[]),[]),wm=reactExports.useRef(Ef);wm.current=Ef;const M1=reactExports.useMemo(()=>conversationDrawer(Ld=>wm.current.error(Ld)),[]),pf=reactExports.useMemo(()=>M1(Dg,B0),[M1,Dg,B0]),zf=reactExports.useRef(pf);zf.current=pf;const[Uf,h0]=reactExports.useState(null),[og,E0]=reactExports.useState(!1),[Sm,Dm]=reactExports.useState(!1),[h1,Bh]=reactExports.useState(),[Op,mf]=reactExports.useState(!1),[hm,Cp]=reactExports.useState(null),[Nm,Lm]=reactExports.useState("");reactExports.useEffect(()=>{if(!cd){Bh(void 0);return}Bh(cd.status);const Ld=(Gd,ih)=>{Bh(ih)};return cd.statusChanged.connect(Ld),()=>{cd.statusChanged.disconnect(Ld)}},[cd]);const[pm,am]=reactExports.useState(!ep),[D1,Lg]=reactExports.useState(0),Pf=reactExports.useRef(new Map),o0=reactExports.useRef(emptyUiModel()),Bg=reactExports.useRef(new Set),[ig,p1]=reactExports.useState(!1),N1=reactExports.useRef(null),i0=Pp&&[Zp||Mp||ip?.endpoint||ip?.agentId,Pp].filter(Boolean).join("::"),[C0,sg]=reactExports.useState(""),[f1,T0]=reactExports.useState(new Map),[gv,L1]=reactExports.useState(new Map),[jg,Fg]=reactExports.useState([]),k0=useAgentRuntimeWsState(),m1=!!ip?.enableConfigQuery&&td,Sp=useConfig(m1,ip?.configEndpoint,ip?.authToken,ip?.agentId),p0=useSkills(m1&&Bu,ip?.configEndpoint,ip?.authToken),{enableSkill:ag,disableSkill:g1,approveSkill:rb,unapproveSkill:nb}=useSkillActions(Ah),[ob,v1]=reactExports.useState(new Map);reactExports.useEffect(()=>{v1(new Map)},[Ah]);const zg=reactExports.useMemo(()=>{const Ld=new Set;for(const Gd of p0.data?.skills??[])(Gd.status==="enabled"||Gd.status==="loaded")&&Ld.add(Gd.id);return Ld},[p0.data]);reactExports.useEffect(()=>{if(!Ah||m0.current.has(Ah))return;const Ld=p0.data?.skills??[];if(Ld.length===0)return;if(Ld.some(nh=>nh.status==="enabled"||nh.status==="loaded")){m0.current.add(Ah);return}const ih=Ld.filter(nh=>nh.status==="available").map(nh=>nh.id).filter(Boolean);if(ih.length===0){m0.current.add(Ah);return}ih.every(nh=>ag(nh))&&m0.current.add(Ah)},[Ah,p0.data,ag]);const b1=reactExports.useMemo(()=>{const Ld=new Set;for(const Gd of p0.data?.skills??[])Gd.approved===!0&&Ld.add(Gd.id);return ob.forEach((Gd,ih)=>{Gd?Ld.add(ih):Ld.delete(ih)}),Ld},[ob,p0.data]),Gm=reactExports.useMemo(()=>{const Ld=Sp.data?.builtinTools??[],Gd=ip?.options?.frontendTools??[],ih=new Set(Ld.map(nh=>nh.name)),ph=[...kf??[],...Gd].filter(nh=>ih.has(nh.name)?!1:(ih.add(nh.name),!0)).map(nh=>({id:nh.name,name:nh.name}));return{runtime:Ld,frontend:ph}},[Sp.data?.builtinTools,kf,ip?.options]),j0=reactExports.useMemo(()=>Vu??(Ah?[{id:Ah,name:Au||Ah,description:lo||ah}]:[]),[Vu,Ah,Au,lo,ah]),fm=typeof ip?.options?.model=="string"?(ip?.options).model:void 0,Wm=reactExports.useMemo(()=>{const Ld=ad||Sp.data?.models||(Sp.isError?[]:void 0);return offeredModels(Ld,()=>{const Gd=Object.values(AI_MODEL_CATALOGUE).filter(ih=>ih.available&&isChatModel(ih)).map(ih=>({id:ih.id,name:ih.name,provider:ih.provider}));return Gd.length>0?Gd:fm?[{id:fm,name:fm,provider:"inference"}]:[]})},[ad,Sp.data?.models,Sp.isError,fm]),vv=reactExports.useMemo(()=>zu??j0.map(Ld=>({name:Ld.name,description:Ld.description,icon:Ld.icon,disabled:Ld.id===(Gu??j0[0]?.id),disabledReason:`You are already talking to ${Ld.name}`})),[zu,j0,Gu]),B1=useContextSnapshot(m1&&Ru,ip?.configEndpoint,ip?.agentId,ip?.authToken),j1=reactExports.useMemo(()=>ip?.enableConfigQuery?void 0:{totalTokens:Uf?.totalTokens??0,contextWindow:2e5,sumResponseInputTokens:Uf?.sessionInput??0,sumResponseOutputTokens:Uf?.sessionOutput??0,systemPromptTokens:0,userMessageTokens:0,assistantMessageTokens:0,toolTokens:0,toolCallTokens:0,toolReturnTokens:0,historyToolCallTokens:0,historyToolReturnTokens:0,currentToolCallTokens:0,currentToolReturnTokens:0,turnUsage:{inputTokens:Uf?.turnInput??0,outputTokens:Uf?.turnOutput??0,requests:0,toolCalls:0,toolNames:[],durationSeconds:0},sessionUsage:{inputTokens:Uf?.sessionInput??0,outputTokens:Uf?.sessionOutput??0,requests:0,toolCalls:0,turns:0,durationSeconds:0}},[Uf,ip?.enableConfigQuery]),F1=reactExports.useRef(Ah),F0=reactExports.useRef(null),Ug=B1.data,y1=reactExports.useRef(Ug);y1.current=Ug,reactExports.useEffect(()=>{F1.current!==Ah&&(F1.current=Ah,h0(null),F0.current=y1.current??null)},[Ah]);const Hg=Ug&&Ug!==F0.current?Ug:void 0,z1=Af??Hg??j1;reactExports.useEffect(()=>{Ud?.(z1)},[z1,Ud]);const Em=useSandbox(m1&&$u&&!ip?.ownRoutesOnly,ip?.configEndpoint,ip?.authToken,ip?.agentId),mm=reactExports.useRef(null),f0=reactExports.useRef(null),Bm=reactExports.useRef(0),_1=reactExports.useRef(new Set),m0=reactExports.useRef(new Set),U1=reactExports.useRef(new Set),z0=reactExports.useRef(!1),x1=reactExports.useRef(dp);x1.current=dp;const U0=reactExports.useRef(pp?.id||generateMessageId()),jm=reactExports.useRef(pp),lg=reactExports.useRef(pp?.messages.length?pp.id:null),cg=reactExports.useCallback(()=>{const Ld=U0.current;lg.current!==Ld&&(lg.current=Ld,jm.current?.onStarted?.(Ld))},[]),H0=reactExports.useRef(null),A0=reactExports.useRef([]),Cm=reactExports.useRef(new Set),Tm=ip?.uiSocket,g0=reactExports.useRef(ip?.authToken);g0.current=ip?.authToken;const Km=ip?.uiFiles,Zm=reactExports.useCallback(Ld=>Km?uploadFile(Ld,{url:Km,scope:U0.current,token:g0.current}):Promise.reject(new Error("This conversation takes no file.")),[Km]),km=reactExports.useCallback(()=>{const Ld=d0.current;return Mm.current.items.flatMap(Gd=>Gd.kind==="message"||Gd.kind==="error"?[{id:Gd.id,displays:Ld.displays.get(Gd.id),speaker:Ld.speakers.get(Gd.id)}]:[])},[]),qg=reactExports.useCallback(Ld=>{const Gd=km();let ih;try{ih=withUiOp(Gd,Ld)}catch(_h){console.error("[ChatBase] reactor.ui op not applied:",_h);return}const ph=new Set(ih.map(_h=>_h.id)),nh=Gd.filter(_h=>!ph.has(_h.id)).map(_h=>_h.id);sm(_h=>{const Fh=new Map(_h.displays),Ph=new Map(_h.speakers);for(const Jh of ih)Jh.displays&&Fh.set(Jh.id,Jh.displays),Jh.speaker&&Ph.set(Jh.id,Jh.speaker);for(const Jh of nh)Fh.delete(Jh),Ph.delete(Jh);return{..._h,displays:Fh,speakers:Ph}}),nh.length>0&&Ff(_h=>withoutItems(_h,nh))},[km,sm,Ff]),H1=reactExports.useCallback((Ld,Gd)=>{if(Gd){if(Ld.op==="window")return;if((Ld.op==="show"||Ld.op==="ask")&&isStepDisplay(Ld.body)){Cm.current.add(Ld.body.id);return}if((Ld.op==="patch"||Ld.op==="append")&&Cm.current.has(Ld.id))return}let ih;try{ih=routeUiOp(Ld,o0.current,Bg.current)}catch(nh){console.error("[ChatBase] reactor.ui op not applied:",nh);return}o0.current=ih.steps;const ph=ih.routed;if(ph.to==="window")tellLoopWindow(ph.data);else if(ph.to==="step"){const nh=ph.step;sm(_h=>{const Fh=new Map(_h.steps.map(Hh=>[Hh.item.id,Hh.after])),Ph=Mm.current.items.at(-1)?.id??null,Jh=withLoopStep(_h.steps.map(Hh=>Hh.item),nh);return{..._h,steps:Jh.map(Hh=>({item:Hh,after:Fh.has(Hh.id)?Fh.get(Hh.id)??null:Ph}))}})}else if(ph.to==="element")Bg.current.add(ph.change.id),applyLoopElement(ph.change);else if(placeable(km(),ph.op))qg(ph.op);else{const nh=ph.op.op==="show"||ph.op.op==="ask"?ph.op.body.data?.message_id:void 0;Gd&&typeof nh=="string"?(Wf({type:"MESSAGE_SAID",messageId:nh,role:"assistant",text:"",streaming:!1}),qg(ph.op)):A0.current.push(ph.op)}},[qg,km,sm,Wf]),q1=reactExports.useRef(H1);q1.current=H1,reactExports.useEffect(()=>{if(A0.current.length===0)return;const Ld=A0.current.splice(0);for(const Gd of Ld){if(!placeable(km(),Gd)){A0.current.push(Gd);continue}qg(Gd)}},[Dg,qg,km]);const bv=reactExports.useCallback(()=>{if(!Tm)return null;const Ld=U0.current,Gd=H0.current;if(Gd&&Gd.scope===Ld)return Gd.socket;Gd?.socket.close(),o0.current=emptyUiModel(),Bg.current=new Set,A0.current=[],Cm.current=new Set;const ih=new UiSocket({url:Tm,scope:Ld,token:()=>g0.current??"",onOp:(ph,nh,_h)=>q1.current(ph,_h),onStatus:(ph,nh)=>{(ph==="refused"||ph==="gone")&&console.error(`[ChatBase] ui socket ${ph}: ${nh??""}`)}});return H0.current={socket:ih,scope:Ld},ih.connect(),ih},[Tm]),Hf=reactExports.useRef(bv);Hf.current=bv,reactExports.useEffect(()=>(pp?.messages.length&&Hf.current(),()=>{H0.current?.socket.close(),H0.current=null}),[]);const Qp=reactExports.useRef(null),Tp=reactExports.useRef(null),gm=reactExports.useRef(null),vm=reactExports.useRef(null),q0=reactExports.useRef(!1),$0=reactExports.useRef(Lf);$0.current=Lf;const V1=reactExports.useRef(kf);V1.current=kf;const yv=reactExports.useRef(zp);yv.current=zp;const ug=reactExports.useRef(Sf);ug.current=Sf;const dg=useAgentInspectorTracer(),hg=em??dg,Vg=reactExports.useRef("Agent");Vg.current=typeof Au=="string"&&Au||Ah||"Agent";const Ym=reactExports.useRef(null);hg&&Ym.current?.tracer!==hg?Ym.current={tracer:hg,recorder:chatSpanRecorder(hg,()=>Vg.current,{frontendTools:()=>(V1.current??[]).map(Ld=>Ld.name)})}:hg||(Ym.current=null);const v0=reactExports.useRef(""),s0=reactExports.useRef(null);reactExports.useEffect(()=>{let Ld=agentRuntimeStore.getState().toolDecisionRequest?.seq??0;return agentRuntimeStore.subscribe(Gd=>Gd.toolDecisionRequest,Gd=>{if(!Gd||Gd.seq===Ld)return;Ld=Gd.seq;const ih=s0.current;if(!ih)return;const ph=Fh=>(Fh??"").toLowerCase().replace(/[-_]/g,""),nh=Ng(),_h=nh.find(Fh=>Fh.result?.approvalId===Gd.approvalId)??nh.find(Fh=>ph(Fh.toolName)===ph(Gd.toolName)&&(Fh.status==="executing"||Fh.status==="inProgress"));_h&&ih(_h.toolCallId,{type:"tool-approval-decision",approved:Gd.approved,approvalId:Gd.approvalId,toolName:_h.toolName})})},[]);const b0=reactExports.useCallback((Ld,Gd,ih)=>{if(!Ld?.id||_1.current.has(Ld.id))return!1;let ph=Ld.tool_call_id;if(!ph)for(const _h of Ng()){if(_h.status!=="inProgress"&&_h.status!=="executing")continue;const Fh=approvalSignature(_h.toolName,_h.args??{}),Ph=approvalSignature(Ld.tool_name,Ld.tool_args??{});if(Fh===Ph){ph=_h.toolCallId;break}}if(!ph)return!1;const nh=Vm(ph);return!nh||nh.status!=="inProgress"&&nh.status!=="executing"?!1:(_1.current.add(Ld.id),s0.current?.(ph,{type:"tool-approval-decision",approved:Gd,approvalId:Ld.id,toolName:Ld.tool_name||nh.toolName,_fromServerEcho:!0,_alreadyDispatched:!0,...ih?{message:ih}:{}}),!0)},[Ah]);u1.current=b0;const R0=!!(ip?.endpoint&&/\/api\/runtimes\/v1\/agent-nodes\/[^/]+\/ag-ui\/?$/.test(ip.endpoint)),G1=ip?.configEndpoint?ip.configEndpoint.replace(/\/api\/v1\/(config|configure)\/?$/,""):ip?.endpoint?.replace(/\/api\/v1\/.*$/,"")??"";useAgentRuntimeWebSocket({enabled:!!ip&&!!G1&&!R0&&!ip.ownRoutesOnly,baseUrl:G1,authToken:ip?.authToken,agentId:ip?.agentId,onMessage:Ld=>{if(Ld.type!=="tool_approval_created"&&Ld.type!=="tool_approval_approved"&&Ld.type!=="tool_approval_rejected")return;const Gd=Ld.payload;if(Gd){if(Ld.type==="tool_approval_created"){isApprovalForAgent(Gd,Ah)&&agentRuntimeStore.getState().upsertApproval(Gd);return}d1(Gd),b0(Gd,Ld.type==="tool_approval_approved",Gd.note??void 0)}}});const V0=reactExports.useCallback(Ld=>{if(!pd)return!0;const Gd=Ld.isConfig===!1?"catalog":"config";return pd.some(ih=>ih.id===Ld.id&&ih.origin===Gd)},[pd]);reactExports.useEffect(()=>{if(Oh&&gm.current){const Ld=setTimeout(()=>gm.current?.focus(),100);return()=>clearTimeout(Ld)}},[Oh]),reactExports.useEffect(()=>{if(gp!==void 0&&gp>0&&gm.current){const Ld=setTimeout(()=>gm.current?.focus(),150);return()=>clearTimeout(Ld)}},[gp]);const pg=reactExports.useRef(!1);reactExports.useEffect(()=>{if(pg.current&&!Sm&&gm.current){const Ld=setTimeout(()=>gm.current?.focus(),50);return()=>clearTimeout(Ld)}pg.current=Sm},[Sm]);const fg=reactExports.useCallback(()=>{const Ld=gm.current;if(Ld){Ld.style.height="auto";const Gd=120,ph=Math.min(Math.max(Ld.scrollHeight,40),Gd);Ld.style.height=`${ph}px`,Ld.style.overflowY=Ld.scrollHeight>Gd?"auto":"hidden"}},[]);reactExports.useEffect(()=>{fg()},[Nm,fg]),reactExports.useEffect(()=>{const Ld=setTimeout(fg,0);return()=>clearTimeout(Ld)},[fg]),reactExports.useEffect(()=>{if(Wm.length===0||isOffered(Wm,C0))return;const Ld=initialModelId(Wm,sd||Sp.data?.defaultModel||DEFAULT_MODEL);Ld&&Ld!==C0&&sg(Ld)},[Wm,C0,sd,Sp.data?.defaultModel]);const G0=reactExports.useRef(!1);reactExports.useEffect(()=>{if(Wm.length>0&&!G0.current){G0.current=!0;const Ld=Sp.data?.builtinTools?.map(Gd=>Gd.id)||[];if(Fg(Ld),Sp.data?.mcpServers){const Gd=new Map;for(const ih of Sp.data.mcpServers)if(ih.isAvailable&&ih.enabled&&V0(ih)){const nh=new Set(ih.tools.map(_h=>_h.name).filter(_h=>!!_h));Gd.set(ih.id,nh)}T0(Gd)}}},[Sp.data,Wm,C0,sd,ad,pd,V0]),reactExports.useEffect(()=>{!Sp.data?.mcpServers||!pd||T0(Ld=>{const Gd=new Map;for(const ih of Sp.data?.mcpServers??[])if(V0(ih)&&Ld.has(ih.id)){const ph=Ld.get(ih.id);ph&&Gd.set(ih.id,ph)}else if(V0(ih)&&ih.isAvailable&&ih.enabled){const ph=new Set(ih.tools.map(nh=>nh.name).filter(nh=>!!nh));Gd.set(ih.id,ph)}return Gd})},[pd,Sp.data?.mcpServers,V0]);const vf=reactExports.useRef(pd);vf.current=pd,reactExports.useEffect(()=>{const Ld=parseEnabledMcpToolsByServer(Mh);if(!Ld)return;const Gd=Ah||"__global__",ih=!U1.current.has(Gd)&&k0==="connected";T0(ph=>{const nh=new Map(ph);if(Ld.forEach((_h,Fh)=>{(!vf.current||vf.current.some(Jh=>Jh.id===Fh))&&_h.size!==0&&nh.set(Fh,new Set(_h))}),ih){const _h=[];for(const Ph of Sp.data?.mcpServers??[]){if(!(!vf.current||vf.current.some(Wh=>Wh.id===Ph.id))||!Ph.isAvailable||!Ph.enabled)continue;const Hh=Ph.tools.map(Wh=>Wh.name).filter(Wh=>!!Wh);if(Hh.length===0)continue;const cp=nh.get(Ph.id);(!cp||cp.size===0)&&(nh.set(Ph.id,new Set(Hh)),_h.push({serverId:Ph.id,enabledToolNames:Hh}))}let Fh=!0;for(const Ph of _h)agentRuntimeStore.getState().sendRawMessage({type:"mcp_server_tools_set",serverId:Ph.serverId,enabledToolNames:Ph.enabledToolNames},Ah)||(Fh=!1,console.warn("[ChatBase] initial mcp_server_tools_set dropped: websocket not ready"));Fh&&U1.current.add(Gd)}return nh})},[Mh,Ah,Sp.data?.mcpServers,k0]),reactExports.useEffect(()=>{const Ld=parseApprovedMcpToolsByServer(Mh);Ld&&L1(()=>{const Gd=new Map;return Ld.forEach((ih,ph)=>{(!vf.current||vf.current.some(_h=>_h.id===ph))&&Gd.set(ph,new Set(ih))}),Gd})},[Mh]);const w1=reactExports.useRef("");reactExports.useEffect(()=>{const Ld=Mh?.servers;if(!Ld||Ld.length===0)return;const Gd=Ld.filter(_h=>_h.status==="started").map(_h=>_h.id).sort();if(Gd.length===0)return;const ih=Sp.data?.mcpServers||[],ph=Gd.some(_h=>{const Fh=ih.find(Ph=>Ph.id===_h);return!Fh||Fh.tools.length===0}),nh=Gd.join(",");ph&&nh!==w1.current&&Sp.refetch&&(w1.current=nh,Sp.refetch())},[Mh,Sp]);const ib=reactExports.useCallback((Ld,Gd)=>{T0(ih=>{const ph=new Map(ih),nh=new Set(ih.get(Ld)||[]);return nh.has(Gd)?nh.delete(Gd):nh.add(Gd),ph.set(Ld,nh),agentRuntimeStore.getState().sendRawMessage({type:"mcp_server_tools_set",serverId:Ld,enabledToolNames:Array.from(nh)},Ah)||console.warn("[ChatBase] mcp_server_tools_set dropped: websocket not ready"),ph})},[Ah]),ey=reactExports.useCallback((Ld,Gd,ih)=>{T0(ph=>{const nh=new Map(ph),_h=ih?new Set(Gd):new Set;return nh.set(Ld,_h),agentRuntimeStore.getState().sendRawMessage({type:"mcp_server_tools_set",serverId:Ld,enabledToolNames:Array.from(_h)},Ah)||console.warn("[ChatBase] mcp_server_tools_set dropped: websocket not ready"),nh})},[Ah]),ty=reactExports.useCallback(Ld=>{zg.has(Ld)?g1(Ld):ag(Ld)},[zg,ag,g1]),ry=reactExports.useCallback((Ld,Gd)=>{for(const ih of Ld)Gd?ag(ih):g1(ih)},[ag,g1]),Of=reactExports.useCallback((Ld,Gd)=>{L1(ih=>{const ph=new Map(ih),nh=new Set(ih.get(Ld)??[]),_h=nh.has(Gd);return _h?nh.delete(Gd):nh.add(Gd),ph.set(Ld,nh),agentRuntimeStore.getState().sendRawMessage({type:"mcp_server_tool_approve",serverId:Ld,toolName:Gd,approved:!_h},Ah)||console.warn("[ChatBase] mcp_server_tool_approve dropped: websocket not ready"),ph})},[Ah]),_v=reactExports.useCallback(Ld=>{b1.has(Ld)?(v1(Gd=>{const ih=new Map(Gd);return ih.set(Ld,!1),ih}),nb(Ld)):(v1(Gd=>{const ih=new Map(Gd);return ih.set(Ld,!0),ih}),rb(Ld))},[b1,rb,nb]),mg=reactExports.useCallback(()=>{const Ld=[];return f1.forEach((Gd,ih)=>{(!pd||pd.some(ph=>ph.id===ih))&&Gd.forEach(ph=>Ld.push(ph))}),Ld},[f1,pd]),Gg=reactExports.useCallback(()=>Array.from(zg),[zg]);reactExports.useEffect(()=>{if(jd&&!Zp){const Ld=useChatStore.getState().messages;Ld.length>0&&S0(Ld)}},[jd,Zp,S0]);const W1=reactExports.useRef(void 0),gg=reactExports.useRef(0),W0=reactExports.useRef(!1),sb=reactExports.useRef(null);reactExports.useEffect(()=>{if(ep!==W1.current&&(ep&&Pf.current.set(ep,0),W1.current=ep,n0(),!ep)||!ep)return;const Ld=jm.current;if(Ld){sb.current!==Ld.id&&(sb.current=Ld.id,useConversationStore.getState().setMessages(ep,Ld.messages),S0(Ld.messages),useConversationStore.getState().markFetched(ep),am(!0));return}zd!==gg.current&&(gg.current=zd,zd>0&&(useConversationStore.getState().clearMessages(ep),n0(),Pf.current.set(ep,0),W0.current=!0));const Gd=useConversationStore.getState(),ih=Gd.isFetching(ep),ph=Gd.getMessages(ep);if(ph.length>0&&(Mm.current.items.length===0&&S0(ph),am(!0)),ih)return;if(k0!=="connected"){ph.length===0&&am(!1);return}Gd.setFetching(ep,!0);const nh=()=>extractChatMessagesFromFullContext(agentRuntimeStore.getState().fullContext),_h=jp=>{Gd.setMessages(ep,jp),S0(jp),Pf.current.set(ep,0),Gd.markFetched(ep),am(!0)},Fh=W0.current?[]:nh();if(W0.current=!1,Fh.length>0){_h(Fh);return}const Ph=()=>{const jp=[Ah,Nh?.agentId,Zp,ep,"default",void 0],Kf=new Set;for(const Rm of jp){const A1=typeof Rm=="string"?Rm.trim():void 0,bf=A1||"__global__";if(Kf.has(bf))continue;if(Kf.add(bf),agentRuntimeStore.getState().requestRefresh(A1))return!0}return!1};if(!Ph()){Gd.setFetching(ep,!1),ph.length===0&&am(!1);return}let Hh=!1;const cp=window.setTimeout(()=>{Hh||Ph()},500),Wh=agentRuntimeStore.subscribe(jp=>jp.fullContext,jp=>{if(Hh||!jp)return;const Kf=extractChatMessagesFromFullContext(jp);Hh=!0,Wh(),_h(Kf)}),Vp=window.setTimeout(()=>{if(Hh)return;Hh=!0,Wh(),Gd.setFetching(ep,!1),am(ph.length>0);const jp=Pf.current.get(ep)??0;k0==="connected"&&jp<3?(Pf.current.set(ep,jp+1),Ph(),Lg(Rm=>Rm+1)):am(!0)},2e3);return()=>{window.clearTimeout(cp),window.clearTimeout(Vp),Wh()}},[ep,Mp,ip?.agentId,k0,Ah,D1,zd,n0,S0]),reactExports.useEffect(()=>{if(ep&&pf.length>0){const Ld=pf.filter(Gd=>!isToolCallMessage(Gd));Ld.length>0&&useConversationStore.getState().setMessages(ep,Ld)}},[ep,pf]),reactExports.useEffect(()=>{!jd||!Xf.current||useChatStore.getState().setMessages(pf.filter(Ld=>!isToolCallMessage(Ld)))},[jd,pf]);const S1=pf.filter(Ld=>!isToolCallMessage(Ld)),ab=reactExports.useRef(0);reactExports.useEffect(()=>{const Ld=S1.length;Ld!==ab.current&&(ab.current=Ld,zh?.(S1))},[pf,S1,zh]),reactExports.useEffect(()=>{qh?.(pf.filter(Ld=>!isToolCallMessage(Ld)))},[pf,qh]),reactExports.useEffect(()=>{Yh?.(pf)},[pf,Yh]);const E1=Zd?2:3,vg=reactExports.useMemo(()=>{if(ip?.configEndpoint)return{apiBaseUrl:getApiBaseFromConfig(ip.configEndpoint),authToken:ip.authToken}},[ip?.configEndpoint,ip?.authToken]),xv={userAvatar:jsxRuntimeExports.jsx(PersonIcon,{size:16}),assistantAvatar:jsxRuntimeExports.jsx(ForwardRef$2,{size:16,color:Bf}),showAvatars:!0,avatarSize:32,userAvatarBg:"neutral.muted",assistantAvatarBg:"accent.emphasis",...vh};reactExports.useEffect(()=>{if(!ip||!td||sf)return;const Ld=createProtocolAdapter(ip);if(Ld)return mm.current=Ld,p1(!0),f0.current=Ld.subscribe(Gd=>{if(Hf.current(),q0.current&&Gd.type!=="state-update"&&Gd.type!=="error"&&Gd.type!=="done")return;const ih=()=>{try{const nh=conversationEventsOf(Gd,Mm.current);Ff(_h=>nh.reduce((Fh,Ph)=>reduceConversation(Fh,Ph),_h))}catch(nh){console.error("[ChatBase] Protocol event not read:",nh),Cp(nh instanceof Error?nh:new Error(String(nh)))}},ph=()=>{const nh=Mm.current.items;if(nh.some(Ph=>Ph.kind==="message"&&Ph.role==="assistant"&&Ph.text.trim().length>0))return;const Fh=[...nh].reverse().find(Ph=>Ph.kind==="tool"&&Ph.status==="complete"&&Ph.value!==void 0);!Fh||Fh.kind!=="tool"||Wf({type:"MESSAGE_SAID",messageId:generateMessageId(),role:"assistant",text:formatToolResultFallback(Fh.value),streaming:!1})};switch(Gd.type){case"message":if(Gd.usage){const nh=Gd.timestamp instanceof Date?Gd.timestamp.getTime():Date.now(),_h=Math.max(0,Gd.usage.promptTokens??0),Fh=Math.max(0,Gd.usage.completionTokens??0),Ph=Math.max(_h+Fh,Gd.usage.totalTokens??0),Jh=agentRuntimeStore.getState();Jh.appendLocalTokenTurn({serviceName:Mg,agentId:ip?.agentId,timestampMs:nh,promptTokens:_h,completionTokens:Fh,totalTokens:Ph});const Hh=Jh.costUsage?.cumulativeCostUsd;typeof Hh=="number"&&Number.isFinite(Hh)&&Jh.upsertLocalCostPoint({serviceName:Mg,agentId:ip?.agentId,timestampMs:nh,cumulativeUsd:Math.max(0,Hh)})}if(z0.current)break;if(Gd.message){const nh=Gd.message.content;typeof nh=="string"&&nh&&(v0.current=sanitizeAssistantContent(nh)),ih()}break;case"tool-call":if(Gd.toolCall&&!q0.current){const nh=Gd.toolCall.toolCallId,_h=Gd.toolCall.toolName,Fh=Gd.toolCall.args||{},Ph=Gd.toolCall.argsComplete,Jh=Vm(nh);ih();const Hh=Vm(nh);if(!Hh)break;const cp=V1.current?.find(Vp=>Vp.name===_h),Wh=cp?.handler;Jh?Wh&&Jh.status==="executing"&&(Ph??Object.keys(Fh).length>0)&&(Bm.current++,C1(Wh,Hh,nh)):(yv.current?.({toolName:_h,toolCallId:nh,args:Fh}),Ym.current?.recorder.toolStarted({id:nh,name:_h,args:Fh}),Wh&&(Ph??(Object.keys(Fh).length>0||!frontendToolExpectsArgs(cp)))&&(Bm.current++,C1(Wh,Hh,nh)))}break;case"tool-result":if(Gd.toolResult){const nh=Gd.toolResult.toolCallId??"",_h=Vm(nh);ih();const Fh=Vm(nh);_h&&Fh&&(Ym.current?.recorder.toolEnded(nh,{result:Gd.toolResult.result,error:Gd.toolResult.error??(Fh.status==="error"?Fh.executionError??"failed":void 0)}),ug.current?.({toolName:_h.toolName,toolCallId:nh,args:_h.args,result:Gd.toolResult.result,status:Fh.status,error:Gd.toolResult.error}))}break;case"state-update":yh?.(Gd.data),ih();break;case"activity":ih();break;case"done":{Ym.current?.recorder.turnEnded({text:v0.current||void 0,usage:Gd.usage}),v0.current="";const nh=Gd.usage?.promptTokens??0,_h=Gd.usage?.completionTokens??0,Fh=Gd.usage?.totalTokens??nh+_h;Fh>0&&h0(Ph=>({turnInput:nh,turnOutput:_h,sessionInput:(Ph?.sessionInput??0)+nh,sessionOutput:(Ph?.sessionOutput??0)+_h,totalTokens:Fh}))}z0.current&&x1.current&&ph(),q0.current||ih(),z0.current=!1,Bm.current=0,Dm(!1),mf(!1),agentRuntimeStore.getState().requestRefresh(Ah);break;case"error":console.error("[ChatBase] Protocol error:",Gd.error),Ym.current?.recorder.turnEnded({error:Gd.error?.message??"error"}),Gd.error?.message&&/exceeded maximum retries/i.test(Gd.error.message)&&x1.current&&ph(),ih(),z0.current=!1,Cp(Gd.error||new Error("Unknown error")),Bm.current=0,Dm(!1),mf(!1),agentRuntimeStore.getState().requestRefresh(Ah);break;default:ih();break}}),Ld.connect().catch(console.error),()=>{f0.current?.(),mm.current?.disconnect()}},[P1,yh,jd,td]);function C1(Ld,Gd,ih){(async()=>{if(q0.current){Bm.current--,Bm.current<0&&(Bm.current=0);return}try{const ph=await Ld(Gd.args);mm.current&&await mm.current.sendToolResult(ih,{toolCallId:ih,success:!0,result:ph}),Ym.current?.recorder.toolEnded(ih,{result:ph}),Wf({type:"TOOL_CALL_DONE",toolCallId:ih,success:!0,result:ph})}catch(ph){console.error("[ChatBase] Frontend tool execution error:",ph),Ym.current?.recorder.toolEnded(ih,{error:ph.message}),Wf({type:"TOOL_CALL_DONE",toolCallId:ih,success:!1,error:ph.message})}finally{Bm.current--,Bm.current<0&&(Bm.current=0)}})()}reactExports.useEffect(()=>{const Ld=Qp.current;if(Ld){Ld.scrollTo({top:Ld.scrollHeight,behavior:"smooth"});return}Tp.current?.scrollIntoView({behavior:"smooth"})},[pf]);const K1=reactExports.useRef(void 0),[bg]=useVoiceSettings(),yg=reactExports.useMemo(()=>Pd?settledVoice(Pd,bg):void 0,[Pd,bg]),[Z1,Y1]=reactExports.useState(!1),J1=!!(Kd||Nd),I0=useVoiceSpeaker(yg,!J1);useSpokenAnswers(pf,Sm,!J1&&yg?.output==="always",I0.speaker);const P0=Wd||I0.state.speaking,[K0,lb]=reactExports.useState(()=>new Set),X1=Nd??(I0.speaker?I0.stop:void 0),Z0=Kd??(I0.speaker?I0.read:void 0),Am=reactExports.useCallback(async(Ld,Gd,ih)=>{const ph=(Ld??Nm).trim();if(!ph||Sm||!mm.current&&!Ad)return;if(Gd&&namesFiles(Gd))try{Gd=await withUploadedFiles(Gd,Zm)}catch(cp){Cp(cp instanceof Error?cp:new Error(String(cp)));return}const nh=displayPressOf(Gd);if(nh&&Gd){const cp=H0.current?.socket;if(!cp){Cp(new Error("This conversation’s ui channel is not open."));return}try{const Wh=await cp.act(nh);if(!Wh.ok){Cp(new Error(Wh.detail||`The press was refused (${Wh.status}).`));return}Gd=withPress(Gd,Wh.value)}catch(Wh){Cp(Wh instanceof Error?Wh:new Error(String(Wh)));return}}q0.current=!1,v0.current="",Ym.current?.recorder.turnStarted(ph,C0||void 0),z0.current=isToolCallOnlyPrompt(ph);const _h=ih??spokenOf(Gd?.voice)??(Ld===void 0?K1.current:void 0);K1.current=void 0;const Fh=_h?{...Gd??{},voice:_h}:Gd,Ph=createUserMessage(ph,_h?{..._h}:void 0),Hh=[...pf.filter(cp=>!isToolCallMessage(cp)),Ph];{const{id:cp,role:Wh,content:Vp,...jp}=Ph;sm(Kf=>({...Kf,extras:new Map(Kf.extras).set(cp,jp)}))}Ff(cp=>reduceConversation(withPrompt(cp,Ph.id,ph),{type:"RUN_STARTED"})),Lm(""),Dm(!0),mf(!0),Cp(null);try{if(Ad)if(rh){const cp=generateMessageId(),Wh=(Vp,jp)=>Wf({type:"MESSAGE_SAID",messageId:cp,role:"assistant",text:Vp,streaming:jp});Wh("",!0),jd&&useChatStore.getState().startStreaming(cp),vm.current=new AbortController,await Ad(ph,Hh,{onChunk:Vp=>{Wf({type:"TEXT_MESSAGE_CONTENT",messageId:cp,delta:Vp})},onComplete:Vp=>{Wh(Vp,!1),jd&&useChatStore.getState().stopStreaming()},onError:Vp=>{Wh(Ef.error(Vp.message),!1),jd&&useChatStore.getState().stopStreaming(),Cp(Vp)},signal:vm.current.signal})}else{const cp=await Ad(ph,Hh);cp&&Wf({type:"MESSAGE_SAID",messageId:generateMessageId(),role:"assistant",text:cp,streaming:!1})}else if(mm.current){const cp=(kf||[]).map(jp=>({name:jp.name,description:jp.description,parameters:jp.parameters||{type:"object",properties:{}}}));console.warn("[ChatBase] frontendTools count:",kf?.length??0,"toolsForRequest:",cp.map(jp=>jp.name));const Wh=mg(),Vp=Gg();cg(),await mm.current.sendMessage(Ph,{threadId:U0.current,messages:Hh,...C0&&{model:C0},tools:cp,builtinTools:Wh,skills:Vp,identities:$0.current,...Fh?{forwardedProps:Fh}:{}})}}catch(cp){cp.name!=="AbortError"&&(console.error("[ChatBase] Send error:",cp),Ff(Wh=>withError(Wh,cp.message)),Cp(cp))}finally{mm.current||(Mm.current.running&&Wf({type:"RUN_FINISHED"}),Dm(!1),mf(!1),agentRuntimeStore.getState().requestRefresh(Ah)),z0.current=!1,vm.current=null}},[Nm,Sm,pf,C0,kf,jd,Ad,Ah,rh,mg,Gg,cg,Ef,Zm,Ff,sm,Wf]);reactExports.useEffect(()=>{if(!Pp||i0&&N1.current===i0)return;if(i0&&sentPendingPromptKeys.has(i0)){N1.current=i0;return}!pm&&!(!ep||k0!=="connected")||!ig&&!Ad||(N1.current=i0??null,i0&&sentPendingPromptKeys.add(i0),queueMicrotask(()=>Am(Pp)))},[Pp,i0,pm,ep,k0,ig,Am,Ad,b0]);const _g=reactExports.useCallback(()=>{q0.current=!0,vm.current?.abort();const Ld=mm.current;Ld&&(typeof Ld.stopGeneration=="function"&&Ld.stopGeneration(),typeof Ld.terminateSession=="function"?Ld.terminateSession().catch(()=>{}):typeof Ld.terminateAgent=="function"?Ld.terminateAgent().catch(()=>{}):typeof Ld.terminateTask=="function"?Ld.terminateTask().catch(()=>{}):typeof Ld.terminateRequest=="function"&&Ld.terminateRequest().catch(()=>{})),Ff(Gd=>withTurnEnded(Gd,"stopped")),jd&&useChatStore.getState().stopStreaming(),Bm.current=0,Dm(!1),mf(!1),agentRuntimeStore.getState().requestRefresh(Ah),agentRuntimeStore.getState().stopSubagentActivity(),z0.current=!1,Em.interrupt(),cd&&cd.interrupt().catch(()=>{})},[cd,jd,Ah,ip?.configEndpoint,ip?.authToken,ip?.agentId]),T1=reactExports.useCallback(Ld=>async Gd=>{const ih=Ld.actions?.find(_h=>_h.name===Gd.action);if(!ih)throw new Error(`“${Gd.action}” was not offered here.`);const ph=Gd.payload?.value,nh=Gd.action===ANSWER_ACTION?typeof ph=="string"?ph:isFileRef(ph)?ph.name:"Answered.":Gd.action;await Am(nh,{loop:{action:{name:Gd.action,display_id:Ld.id,token:ih.token,payload:Gd.payload??{}}}})},[Am]),Wg=reactExports.useCallback(()=>{n0(),Bm.current=0,Lm(""),U0.current=generateMessageId(),jd&&dm(),ep&&useConversationStore.getState().clearMessages(ep),Th?.(),sh?.onNewChat?.()},[dm,Th,sh,jd,Zp,n0]);reactExports.useEffect(()=>{if($d){if(!ig&&!Ad){$d(null);return}return $d({send:(Ld,Gd)=>{Am(Ld,Gd)},stop:_g,newChat:Wg,thread:()=>U0.current,stopSpeaking:X1}),()=>{$d(null)}}},[$d,ig,Ad,Am,_g,Wg,X1]),reactExports.useEffect(()=>{qd?.(Sm)},[qd,Sm]),reactExports.useEffect(()=>{Dd?.(P0)},[Dd,P0]);const cb=reactExports.useCallback(()=>{window.confirm("Clear all messages?")&&(n0(),jd&&dm(),ep&&useConversationStore.getState().clearMessages(ep),Ih?.(),sh?.onClear?.())},[dm,Ih,sh,jd,Zp,n0]),xg=reactExports.useCallback(Ld=>{const Gd=new Set(Ld),ih=zf.current.filter(ph=>Gd.has(ph.id)).map(rowIdOf);Ff(ph=>withoutItems(ph,ih)),sm(ph=>ph.steps.some(nh=>Gd.has(nh.item.id))?{...ph,steps:ph.steps.filter(nh=>!Gd.has(nh.item.id))}:ph)},[Ff,sm]),wv=reactExports.useCallback(async(Ld,Gd)=>{const ih=Vm(Ld);if(ih&&(ih.status==="executing"||ih.status==="inProgress")){if(!!Gd&&typeof Gd=="object"&&Gd.type==="tool-approval-decision"&&typeof Gd.approved=="boolean"&&mm.current){const nh=Gd,_h=!!nh.approved,Fh=nh._fromServerEcho===!0,Ph=nh._alreadyDispatched===!0,Jh=ih.status==="inProgress",Hh=typeof nh.toolName=="string"?nh.toolName:ih.toolName,cp=Hh.includes("__");if(_h){const Wh=Hh.indexOf("__");if(Wh!==-1){const Vp=Hh.slice(0,Wh),jp=Hh.slice(Wh+2);L1(Kf=>{const Rm=new Map(Kf),A1=new Set(Kf.get(Vp)??[]);return A1.add(jp),Rm.set(Vp,A1),Rm})}}try{const Wh=typeof Gd=="object"&&Gd!==null&&typeof Gd.approvalId=="string"?Gd.approvalId:void 0;if(!Fh&&!Jh){Wh&&(_h?await rg?.(Wh,void 0,Ld):await u0?.(Wh,void 0,Ld));return}if(Wh&&!Ph&&(_h?await rg?.(Wh,void 0,Ld):await u0?.(Wh,void 0,Ld)),cp&&!Jh)return;Ff(Vp=>reduceConversation(reduceConversation(Vp,{type:"TOOL_CALL_DONE",toolCallId:Ld,success:_h,result:Gd,answered:!0,..._h?{}:{error:"Tool approval rejected by user"}}),{type:"RUN_STARTED"})),Dm(!0),mf(!0),await mm.current.sendToolResult(Ld,{toolCallId:Ld,success:_h,result:_h?{approved:!0,message:"Tool call approved by user.",...Wh?{approvalId:Wh}:{}}:{approved:!1,message:"Tool call rejected by user.",...Wh?{approvalId:Wh}:{}},..._h?{}:{error:"Tool approval rejected by user"}})}catch(Wh){console.error("[ChatBase] Approval continuation error:",Wh),Cp(Wh)}return}if(Wf({type:"TOOL_CALL_DONE",toolCallId:Ld,success:!0,result:Gd,answered:!0}),mm.current){let nh;if(typeof Gd=="string")nh=Gd;else if(Gd&&typeof Gd=="object"&&"accepted"in Gd){const Fh=Gd;if(Fh.accepted){const Ph=Fh.steps?.map(Jh=>Jh.description).join(", ")||"";nh=Ph?`I confirm and approve the following steps: ${Ph}`:"I confirm and approve the plan."}else nh="I reject this plan. Please suggest something else."}else nh=JSON.stringify(Gd,null,2);const _h={id:generateMessageId(),role:"user",content:nh,createdAt:new Date};Dm(!0),mf(!0),Wf({type:"RUN_STARTED"});try{const Fh=pf.filter(Ph=>!isToolCallMessage(Ph));await mm.current.sendMessage(_h,{threadId:U0.current,messages:[...Fh,_h]})}catch(Fh){console.error("[ChatBase] HITL respond error:",Fh)}}}},[pf,rg,u0,Vm,Ff,Wf]);s0.current=wv;const Y0=reactExports.useCallback(Ld=>{Am(Ld.message)},[Am]),Sv=reactExports.useCallback(Ld=>{Lm(Ld),setTimeout(()=>gm.current?.focus(),0)},[]),Ev=reactExports.useCallback(async(Ld,Gd)=>{await rg?.(Ld,Gd)},[rg]),J0=reactExports.useCallback(async(Ld,Gd)=>{await u0?.(Ld,Gd)},[u0]),y0=(Sp.data?.mcpServers||[]).filter(Ld=>!pd||V0(Ld)),Kg=reactExports.useMemo(()=>{const Ld=y0.map(ih=>{const ph=Mh?.servers?.find(nh=>nh.id===ih.id);if(ph&&ph.status==="started"){const nh={};if(ih.isAvailable||(nh.isAvailable=!0),ph.tools&&ph.tools.length>0&&(nh.tools=ph.tools.map(_h=>({name:_h.name,description:_h.description||"",enabled:_h.enabled??!0}))),Object.keys(nh).length>0)return{...ih,...nh}}return ih}),Gd=new Set(y0.map(ih=>ih.id));for(const ih of Mh?.servers??[])ih.status==="started"&&!Gd.has(ih.id)&&ih.tools&&ih.tools.length>0&&(!pd||pd.some(nh=>nh.id===ih.id))&&Ld.push({id:ih.id,name:ih.id,description:"",url:"",enabled:!0,tools:ih.tools.map(nh=>({name:nh.name,description:nh.description||"",enabled:nh.enabled??!0})),args:[],requiredEnvVars:[],isAvailable:!0,transport:"stdio",isConfig:!1,isRunning:!0});return Ld},[y0,Mh,pd]),Cv=ip?.configEndpoint?ip.configEndpoint.replace(/\/api\/v1\/(config|configure)\/?$/,""):void 0,Tv=!ip||!ip.enableConfigQuery||!!Sp.data||!!p0.data,k1=ah||Sp.data?.welcomeMessage||"",wg=Sp.data?.suggestions,kv=np&&np.length>0?np:Array.isArray(wg)&&wg.length>0?wg.map(Ld=>{if(typeof Ld=="string"){const ph=Ld.trim();return{title:ph,message:ph}}const Gd=(Ld?.text??"").trim();return{title:(Ld?.summary??"").trim()||Gd,message:Gd}}).filter(Ld=>Ld.message):void 0,Av=Fd?[{id:"__welcome__",role:"assistant",content:Fd,createdAt:WELCOME_AT},...pf]:pf,X0=Sm||Op?[...Av].reverse().find(Ld=>!isToolCallMessage(Ld)&&Ld.role==="assistant")?.id:void 0,Q1=Z0||K0.size?Ld=>{const Gd=getMessageText(Ld);return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[K0.has(Ld.id)?jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:0,color:"fg.muted",fontStyle:"italic"},"data-interrupted":"",children:"interrupted"}):null,Z0&&readsAloud(Ld,Gd,X0)?jsxRuntimeExports.jsx(ReadAloud,{onRead:()=>Z0(Gd)}):null]})}:void 0,$v=Sh||jsxRuntimeExports.jsxs(Box,{display:"flex",flexDirection:"column",minHeight:0,width:"100%",maxWidth:920,mx:"auto",bg:"canvas.default",children:[jsxRuntimeExports.jsx(ChatMessageList,{displayItems:Av,actOn:ip?.uiSocket?T1:void 0,upload:ip?.uiFiles?Zm:void 0,isLoading:Sm,isStreaming:Op,showLoadingIndicator:Pu,hideMessagesAfterToolUI:dp,avatarConfig:xv,padding:E1,notebookToolSurfacesId:Dh,approvalConfig:vg,messagesEndRef:Tp,onRespond:wv,showTurnFooters:lh,renderMessageFooter:Q1,agentUsage:z1,onRemoveItems:xg,mcpServers:Kg,emptyContent:Xu?null:jsxRuntimeExports.jsx(ChatEmptyState,{emptyState:Qd,brandIcon:Jd,description:k1,suggestions:kv,submitOnSuggestionClick:ap,onSuggestionSubmit:Y0,onSuggestionFill:Sv})}),Id]}),ev=yg&&yg.input!=="off"?jsxRuntimeExports.jsx(ComposerVoice,{voice:yg,input:Nm,setInput:Lm,disabled:sf||Xu,speaking:P0,onStopSpeaking:X1,running:Sm,onStopRun:_g,onInterrupted:()=>{X0&&lb(Ld=>new Set([...Ld,X0]))},onInterimChange:Y1,answers:!!(Pd?.output&&Pd.output!=="off"&&Pd.speechUrl),onSpoken:Ld=>{K1.current=Ld},send:(Ld,Gd)=>{Am(Ld,void 0,Gd)}}):void 0,tv=!J1&&I0.state.refused?jsxRuntimeExports.jsx(Text$3,{role:"alert",sx:{fontSize:0,color:"danger.fg",maxWidth:260},"data-voice-refused":"",children:I0.state.refused}):null,$m=Mu?jsxRuntimeExports.jsx(InputPrompt,{footerExtras:tv?jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[tv,ev]}):ev,interim:Z1,input:Nm,setInput:Lm,isLoading:Sm,kernelStatus:h1,connectionConfirmed:Tv,placeholder:mh,typingSuggestions:kv?.map(Ld=>Ld.message||Ld.title),autoFocus:Oh,focusTrigger:gp,padding:E1,onSend:()=>Am(),onStop:_g,disableInputPrompt:ju||sf||!!Yu||Xu,promptVariant:Fu,mentionableAgents:vv,promptCommands:Uu,promptHistory:Sp.data?.promptHistory?.map(askedOf),showTokenUsage:Ru,showContextRing:Iu,agentUsage:z1,showModelSelector:Du,showToolsMenu:Lu,showSkillsMenu:Bu,codemodeEnabled:nd,onToggleCodemode:od,isA2AProtocol:L0,showAgentsMenu:Hu,agents:j0,selectedAgentId:Gu??j0[0]?.id,onSelectAgent:Wu,hasConfigData:!!Sp.data,hasSkillsData:!!p0.data,configLoading:Sp.isLoading,models:Wm,decisions:Sp.data?{models:Sp.data.decisionModels,note:Sp.data.decisionsNote}:void 0,selectedModel:C0,onModelSelect:sg,availableTools:Gm.runtime,availableFrontendTools:Gm.frontend,mcpServers:Kg,enabledMcpTools:f1,enabledMcpToolCount:mg().length,onToggleMcpTool:ib,onToggleAllMcpServerTools:ey,approvedMcpTools:gv,onToggleMcpToolApproval:Of,skills:p0.data?.skills||[],skillsLoading:!1,enabledSkills:zg,onToggleSkill:ty,onToggleAllSkills:ry,approvedSkills:b1,onToggleSkillApproval:_v,apiBase:Cv,authToken:ip?.authToken,mcpStatusData:Mh}):null,Fm={title:Au,subtitle:lo,disableReason:sf?Im:void 0,brandIcon:Jd,headerContent:wh,headerActions:bd,showInformation:Xd,onInformationClick:gh??(()=>E0(!0)),padding:E1,kernelIndicatorState:Sd,kernelIndicatorPlacement:Ed,runtimeStatus:of??Em.data,kernel:qp?Jp??cd:Cf?If??cd:cd,kernelEnvironmentName:dd,kernelCpu:md,kernelMemory:ld,kernelGpu:hd,headerButtons:sh,messageCount:S1.length,onNewChat:Wg,onClear:cb,chatViewMode:kd,onChatViewModeChange:Rd,disabledViewModes:Od,showEphemeralSurfaceControl:bp||Vh,enableEphemeralNotebookOption:bp,enableEphemeralDocumentOption:Vh,ephemeralSurfaceMode:_f,onEphemeralSurfaceModeChange:$f},O0=$u?th?th(Fm):jsxRuntimeExports.jsx(ChatBaseHeader,{...Fm}):null;return jsxRuntimeExports.jsxs(Box,{className:_d,position:"relative",display:"flex",flexDirection:"column",height:"100%",maxHeight:"100%",minHeight:0,flex:"1 1 auto",width:"100%",minWidth:0,bg:Md||"canvas.default",borderRadius:Kh,border:xd,boxShadow:Hd,overflow:"hidden",children:[!yp&&O0,og&&jsxRuntimeExports.jsx(Box,{flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",children:jsxRuntimeExports.jsx(ReactorLazy,{load:loadAgentDetails,errorFallback:agentDetailsRefused,props:{name:Au||"AI Agent",icon:Jd,protocol:ip?.type??"unknown",url:ip?.endpoint||"",messageCount:pf.length,agentId:Ah,apiBase:ip?.configEndpoint,onBack:()=>E0(!1)}})}),vp&&l1&&l1.length>0&&jsxRuntimeExports.jsx(ToolApprovalBannerSection,{pendingApprovals:l1,onApprove:Ev,onReject:J0}),Ou&&hm&&jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,p:E1,bg:"danger.subtle",borderBottom:"1px solid",borderColor:"danger.muted",children:[jsxRuntimeExports.jsx(AlertIcon,{size:16}),jsxRuntimeExports.jsx(Text$3,{sx:{color:"danger.fg",fontSize:1},children:hm.message})]}),yp?jsxRuntimeExports.jsxs(Box,{flex:1,minHeight:0,display:"flex",overflow:"hidden",position:"relative",children:[jsxRuntimeExports.jsx(Box,{flex:1,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",sx:wp||Tf?null:{borderRight:"1px solid",borderColor:"border.default"},children:Xu||Yu?jsxRuntimeExports.jsx(CompanionSurfaceSkeleton,{mode:qp?"notebook":"document"}):qp?jsxRuntimeExports.jsx(ReactorLazy,{load:loadEphemeralNotebook,errorFallback:ephemeralNotebookRefused,fallback:jsxRuntimeExports.jsx(CompanionSurfaceSkeleton,{mode:"notebook"}),props:{notebookId:Np,runtimeName:Zp||Ah,runtimeOverride:tp,themeVariant:vd,colorMode:wd,nbformat:Wp??void 0,onNbformatChange:Jf,toolbarComponent:$h,toolbarExtraItems:Gh,collaborationProvider:Fp}}):jsxRuntimeExports.jsx(vM.Suspense,{fallback:null,children:jsxRuntimeExports.jsx(EphemeralDocument,{documentId:hf,runtimeName:Zp||Ah,runtimeOverride:tp,themeVariant:vd,colorMode:wd,content:Pm??void 0,onContentChange:r0,onToolsReady:Bp,onKernelChange:Gf,collaboration:Kp,toolbarExtraItems:Lp})})}),!Tf&&jsxRuntimeExports.jsxs(Box,{sx:wp?{position:"absolute",right:16,width:jf?360:440,maxWidth:"calc(100% - 32px)",...jf?{bottom:16,height:"62%"}:{top:16,bottom:16},display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden",bg:"canvas.default",border:"1px solid",borderColor:"border.default",borderRadius:2,boxShadow:"shadow.large",zIndex:5}:{flexShrink:0,width:440,minWidth:320,maxWidth:"48%",minHeight:0,display:"flex",flexDirection:"column",overflow:"hidden",bg:"canvas.default"},children:[O0,jsxRuntimeExports.jsx(Box,{ref:Qp,flex:1,minHeight:0,overflow:"auto",bg:"canvas.default",children:$v}),Vd,$m]}),Tf&&Ep&&(kd==="sidebar"?jsxRuntimeExports.jsx(Box,{position:"absolute",top:8,right:8,zIndex:6,children:jsxRuntimeExports.jsx(IconButton,{icon:SidebarExpandIcon,"aria-label":"Open chat",onClick:Ep,variant:"default",size:"small"})}):jsxRuntimeExports.jsx(FloatingBrandButton,{isOpen:!1,onToggle:Ep,position:"bottom-right",tooltip:"Open chat"}))]}):jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Box,{ref:Qp,"data-chat-history":"",flex:1,flexGrow:1,minHeight:0,overflow:"auto",bg:"canvas.default",children:$v}),Vd,$m]}),Eh&&jsxRuntimeExports.jsx(PoweredByTag,{...bh}),Yu&&jsxRuntimeExports.jsxs(Box,{position:"absolute",inset:0,zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",p:3,overflow:"auto",children:[jsxRuntimeExports.jsx(Box,{"aria-hidden":!0,position:"absolute",inset:0,bg:"canvas.default",opacity:.4,backdropFilter:"blur(1px)"}),jsxRuntimeExports.jsx(Box,{position:"relative",zIndex:1,maxWidth:"100%",children:Yu})]}),Xu&&!Yu&&jsxRuntimeExports.jsxs(Box,{position:"absolute",inset:0,zIndex:15,display:"flex",alignItems:"center",justifyContent:"center",p:3,children:[jsxRuntimeExports.jsx(Box,{"aria-hidden":!0,position:"absolute",inset:0,bg:"canvas.default",opacity:.35,backdropFilter:"blur(1px)"}),jsxRuntimeExports.jsxs(Box,{position:"relative",zIndex:1,display:"flex",flexDirection:"column",alignItems:"center",gap:3,children:[jsxRuntimeExports.jsx(StyledSpinner,{size:"large"}),jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted"},children:ed||"Launching your agent…"})]})]})]})}function ToolApprovalBannerSection({pendingApprovals:Au,onApprove:lo,onReject:$u}){const[Ru,Iu]=reactExports.useState(null);return reactExports.useEffect(()=>{Ru&&(Au.some(Pu=>Pu.id===Ru.id)||Iu(null))},[Au,Ru]),jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(ToolApprovalBanner,{pendingApprovals:Au,onReview:Pu=>Iu(Pu),onApproveAll:async()=>{if(lo)for(const Pu of Au)await lo(Pu.id)}}),jsxRuntimeExports.jsx(ToolApprovalDialog,{isOpen:!!Ru,toolName:Ru?.toolName??"",toolDescription:Ru?.toolDescription,args:Ru?.args??{},onApprove:async()=>{if(!Ru||!lo){Iu(null);return}await lo(Ru.id)!==!1&&Iu(null)},onDeny:async()=>{if(!Ru||!$u){Iu(null);return}await $u(Ru.id,"Rejected from tool approval dialog")!==!1&&Iu(null)},onClose:()=>Iu(null)})]})}const halo=Au=>({position:"absolute",inset:0,borderRadius:"50%",bg:Au||"accent.emphasis",zIndex:-1,pointerEvents:"none",willChange:"transform, opacity"});function ButtonGlow({color:Au}){return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx(Box,{"aria-hidden":!0,"data-button-glow":"breath",sx:{...halo(Au),filter:"blur(10px)",animation:"agentRuntimesGlowBreath 3.4s ease-in-out infinite","@keyframes agentRuntimesGlowBreath":{"0%, 100%":{transform:"scale(0.9)",opacity:.35},"50%":{transform:"scale(1.25)",opacity:.7}},"@media (prefers-reduced-motion: reduce)":{animation:"none",transform:"scale(1.1)",opacity:.4}}}),jsxRuntimeExports.jsx(Box,{"aria-hidden":!0,"data-button-glow":"aura",sx:{...halo(Au),filter:"blur(18px)",animation:"agentRuntimesGlowAura 5.3s ease-in-out infinite","@keyframes agentRuntimesGlowAura":{"0%, 100%":{transform:"scale(1)",opacity:.15},"40%":{transform:"scale(1.55)",opacity:.4},"70%":{transform:"scale(1.3)",opacity:.25}},"@media (prefers-reduced-motion: reduce)":{animation:"none",transform:"scale(1.3)",opacity:.2}}})]})}const MARGIN=24;function useViewportDrag(Au,{whole:lo=!1}={}){const[$u,Ru]=reactExports.useState(null),Iu=reactExports.useRef(null),Pu=reactExports.useCallback(Mu=>{const Du=Au.current;if(!Du)return;const Lu=Du.getBoundingClientRect();Iu.current={dx:Mu.clientX-Lu.left,dy:Mu.clientY-Lu.top};const Bu=Mu.currentTarget;Bu.setPointerCapture?.(Mu.pointerId);const ju=zu=>{if(!Iu.current)return;const Uu=Math.min(Math.max(zu.clientX-Iu.current.dx,lo?0:MARGIN-Lu.width),window.innerWidth-(lo?Lu.width:MARGIN)),Hu=Math.min(Math.max(zu.clientY-Iu.current.dy,0),window.innerHeight-(lo?Lu.height:MARGIN));Ru({left:Uu,top:Hu})},Fu=()=>{Iu.current=null,Bu.removeEventListener("pointermove",ju),Bu.removeEventListener("pointerup",Fu),Bu.removeEventListener("pointercancel",Fu)};Bu.addEventListener("pointermove",ju),Bu.addEventListener("pointerup",Fu),Bu.addEventListener("pointercancel",Fu),Mu.preventDefault()},[Au,lo]),Ou=reactExports.useCallback(()=>Ru(null),[]);return{position:$u,onHandlePointerDown:Pu,reset:Ou}}const INK=loopColors.ink,INK_DARK=loopColors.inkDark;function Eyes({cx:Au,cy:lo,gap:$u,r:Ru,colours:Iu}){const Pu=Au-$u/2,Ou=Au+$u/2;return jsxRuntimeExports.jsxs("g",{children:[jsxRuntimeExports.jsx("circle",{cx:Pu,cy:lo,r:Ru,fill:Iu.white,stroke:Iu.ring,strokeWidth:1.5}),jsxRuntimeExports.jsx("circle",{cx:Ou,cy:lo,r:Ru,fill:Iu.white,stroke:Iu.ring,strokeWidth:1.5}),jsxRuntimeExports.jsxs("g",{className:"assistant-pupils",children:[jsxRuntimeExports.jsx("circle",{cx:Pu+Ru*.15,cy:lo+Ru*.1,r:Ru*.45,fill:Iu.pupil}),jsxRuntimeExports.jsx("circle",{cx:Ou+Ru*.15,cy:lo+Ru*.1,r:Ru*.45,fill:Iu.pupil}),jsxRuntimeExports.jsx("circle",{cx:Pu+Ru*.3,cy:lo-Ru*.1,r:Ru*.14,fill:Iu.white}),jsxRuntimeExports.jsx("circle",{cx:Ou+Ru*.3,cy:lo-Ru*.1,r:Ru*.14,fill:Iu.white})]}),jsxRuntimeExports.jsxs("g",{className:"assistant-lids",children:[jsxRuntimeExports.jsx("ellipse",{cx:Pu,cy:lo,rx:Ru+.5,ry:Ru+.5,fill:Iu.lid}),jsxRuntimeExports.jsx("ellipse",{cx:Ou,cy:lo,rx:Ru+.5,ry:Ru+.5,fill:Iu.lid})]})]})}const PAPER_CLIP={light:{wire:"#7A808A",shine:"#E3E6EB",line:INK,eye:{white:loopColors.white,ring:INK,pupil:INK,lid:"#B8BDC6"}},dark:{wire:"#C9CED6",shine:"#8D93A0",line:INK_DARK,eye:{white:INK_DARK,ring:loopColors.grayDark,pupil:INK,lid:"#8D93A0"}}},WIZARD={light:{hat:"#6E5CD6",brim:"#4A3C9E",robe:"#5B4BB7",face:"#F2D3B3",beard:"#F4F4F6",beardEdge:"#7A808A",star:"#F8D469",eye:{white:loopColors.white,ring:INK,pupil:INK,lid:"#F2D3B3"}},dark:{hat:"#9C88F0",brim:"#7B67DB",robe:"#8F7CE8",face:"#E8C4A0",beard:"#E4E4EA",beardEdge:loopColors.grayDark,star:"#F8D469",eye:{white:INK_DARK,ring:INK,pupil:INK,lid:"#E8C4A0"}}},CAT={light:{fur:"#F4A261",edge:"#B4571A",tail:"#E08A45",ear:"#F6A5C1",nose:"#B83A6B",whiskers:INK,eye:{white:loopColors.white,ring:INK,pupil:INK,lid:"#F4A261"}},dark:{fur:"#F4A261",edge:"#F4A261",tail:"#E08A45",ear:"#F6A5C1",nose:"#B83A6B",whiskers:INK_DARK,eye:{white:INK_DARK,ring:INK,pupil:INK,lid:"#F4A261"}}},LOOP_EYES={light:{eye:{white:loopColors.white,ring:INK,pupil:INK,lid:"#E3E6EB"}},dark:{eye:{white:INK_DARK,ring:INK_DARK,pupil:loopColors.black,lid:loopColors.grayDark}}};function PaperClip({size:Au,mode:lo="light"}){const $u=PAPER_CLIP[lo],Ru="M40 86 L40 30 Q40 14 52 14 Q64 14 64 30 L64 74 Q64 82 56 82 Q48 82 48 74 L48 36";return jsxRuntimeExports.jsx("svg",{width:Au,height:Au,viewBox:"0 0 96 96",role:"img","aria-label":"Paper clip","data-assistant-mode":lo,children:jsxRuntimeExports.jsxs("g",{className:"assistant-body",children:[jsxRuntimeExports.jsx("path",{d:Ru,fill:"none",stroke:$u.wire,strokeWidth:6,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:Ru,fill:"none",stroke:$u.shine,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M36 22 Q42 18 47 21",stroke:$u.line,strokeWidth:2,fill:"none",strokeLinecap:"round"}),jsxRuntimeExports.jsx("path",{d:"M57 21 Q62 18 68 22",stroke:$u.line,strokeWidth:2,fill:"none",strokeLinecap:"round"}),jsxRuntimeExports.jsx(Eyes,{cx:52,cy:30,gap:16,r:6.5,colours:$u.eye}),jsxRuntimeExports.jsx("path",{className:"assistant-mouth",d:"M48 44 Q52 47 56 44",stroke:$u.line,strokeWidth:2,fill:"none",strokeLinecap:"round"})]})})}function Wizard({size:Au,mode:lo="light"}){const $u=WIZARD[lo];return jsxRuntimeExports.jsx("svg",{width:Au,height:Au,viewBox:"0 0 96 96",role:"img","aria-label":"Wizard","data-assistant-mode":lo,children:jsxRuntimeExports.jsxs("g",{className:"assistant-body",children:[jsxRuntimeExports.jsx("path",{d:"M34 58 Q48 52 62 58 Q70 74 76 92 Q48 98 20 92 Q26 74 34 58 Z",fill:$u.robe}),jsxRuntimeExports.jsx("path",{d:"M21 90 Q48 96 75 90 L76 92 Q48 98 20 92 Z",fill:$u.brim}),jsxRuntimeExports.jsx("circle",{cx:30,cy:82,r:1.6,fill:$u.star}),jsxRuntimeExports.jsx("circle",{cx:67,cy:78,r:1.3,fill:$u.star}),jsxRuntimeExports.jsx("ellipse",{cx:48,cy:46,rx:13,ry:12,fill:$u.face}),jsxRuntimeExports.jsx("path",{d:"M33 38 Q31 66 40 77 Q48 89 56 77 Q65 66 63 38 Q61 50 56 53 Q48 58 40 53 Q35 50 33 38 Z",fill:$u.beard,stroke:$u.beardEdge,strokeWidth:1,strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{className:"assistant-mouth",d:"M44 59 Q48 62 52 59",stroke:INK,strokeWidth:1.8,fill:"none",strokeLinecap:"round"}),jsxRuntimeExports.jsx("path",{d:"M39 55 Q44 51 48 54 Q52 51 57 55 Q52 57 48 56 Q44 57 39 55 Z",fill:$u.beard,stroke:$u.beardEdge,strokeWidth:.8}),jsxRuntimeExports.jsx("path",{d:"M25 36 Q35 26 39 14 Q43 2 58 3 Q50 8 53 18 Q58 30 71 36 Q48 30 25 36 Z",fill:$u.hat}),jsxRuntimeExports.jsx("path",{d:"M18 37 Q48 27 78 37 Q48 45 18 37 Z",fill:$u.brim}),jsxRuntimeExports.jsx("path",{d:"M47 17 l1.8 3.6 4 .6 -2.9 2.8 .7 4 -3.6 -1.9 -3.6 1.9 .7 -4 -2.9 -2.8 4 -.6 Z",fill:$u.star}),jsxRuntimeExports.jsx("circle",{cx:56,cy:28,r:1.4,fill:$u.star}),jsxRuntimeExports.jsx(Eyes,{cx:48,cy:46,gap:11,r:4,colours:$u.eye})]})})}function Cat({size:Au,mode:lo="light"}){const $u=CAT[lo],Ru="M70 84 Q90 78 84 58";return jsxRuntimeExports.jsx("svg",{width:Au,height:Au,viewBox:"0 0 96 96",role:"img","aria-label":"Cat","data-assistant-mode":lo,children:jsxRuntimeExports.jsxs("g",{className:"assistant-body",children:[jsxRuntimeExports.jsx("path",{d:Ru,stroke:$u.edge,strokeWidth:8,fill:"none",strokeLinecap:"round"}),jsxRuntimeExports.jsx("path",{d:Ru,stroke:$u.tail,strokeWidth:5,fill:"none",strokeLinecap:"round"}),jsxRuntimeExports.jsx("ellipse",{cx:48,cy:78,rx:24,ry:14,fill:$u.fur,stroke:$u.edge,strokeWidth:1.5}),jsxRuntimeExports.jsx("path",{d:"M24 30 L28 8 L42 22 Z",fill:$u.fur,stroke:$u.edge,strokeWidth:1.5,strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M72 30 L68 8 L54 22 Z",fill:$u.fur,stroke:$u.edge,strokeWidth:1.5,strokeLinejoin:"round"}),jsxRuntimeExports.jsx("path",{d:"M28 26 L30 14 L38 22 Z",fill:$u.ear}),jsxRuntimeExports.jsx("path",{d:"M68 26 L66 14 L58 22 Z",fill:$u.ear}),jsxRuntimeExports.jsx("circle",{cx:48,cy:42,r:24,fill:$u.fur,stroke:$u.edge,strokeWidth:1.5}),jsxRuntimeExports.jsx(Eyes,{cx:48,cy:38,gap:18,r:6.5,colours:$u.eye}),jsxRuntimeExports.jsx("path",{d:"M45 48 L51 48 L48 52 Z",fill:$u.nose}),jsxRuntimeExports.jsx("path",{className:"assistant-mouth",d:"M43 55 Q48 58 53 55",stroke:INK,strokeWidth:2,fill:"none",strokeLinecap:"round"}),jsxRuntimeExports.jsx("path",{d:"M30 48 L18 46 M30 52 L18 54 M66 48 L78 46 M66 52 L78 54",stroke:$u.whiskers,strokeWidth:1.2,strokeLinecap:"round"})]})})}function LoopEyes({size:Au,mode:lo="light"}){const $u=LOOP_EYES[lo];return jsxRuntimeExports.jsx("svg",{width:Au,height:Au,viewBox:"0 0 96 96",role:"img","aria-label":"L👀P eyes","data-assistant-mode":lo,children:jsxRuntimeExports.jsxs("g",{className:"assistant-body",children:[jsxRuntimeExports.jsx(Eyes,{cx:48,cy:50,gap:40,r:18,colours:$u.eye}),jsxRuntimeExports.jsx("path",{className:"assistant-mouth",d:"M42 80 Q48 84 54 80",stroke:lo==="dark"?INK_DARK:INK,strokeWidth:2.5,fill:"none",strokeLinecap:"round",opacity:0})]})})}const eyeOf=(Au,lo)=>({white:Au.white,ring:Au.ring,pupil:Au.pupil,on:lo}),ASSISTANT_CHARACTERS=[{id:"paperclip",name:"Paper clip",Drawing:PaperClip,keyColours:{light:{edges:[PAPER_CLIP.light.wire,PAPER_CLIP.light.line],eye:eyeOf(PAPER_CLIP.light.eye,"page")},dark:{edges:[PAPER_CLIP.dark.wire,PAPER_CLIP.dark.line],eye:eyeOf(PAPER_CLIP.dark.eye,"page")}}},{id:"wizard",name:"Wizard",Drawing:Wizard,keyColours:{light:{edges:[WIZARD.light.hat,WIZARD.light.brim,WIZARD.light.robe,WIZARD.light.beardEdge],eye:eyeOf(WIZARD.light.eye,WIZARD.light.face)},dark:{edges:[WIZARD.dark.hat,WIZARD.dark.brim,WIZARD.dark.robe,WIZARD.dark.beardEdge],eye:eyeOf(WIZARD.dark.eye,WIZARD.dark.face)}}},{id:"cat",name:"Cat",Drawing:Cat,keyColours:{light:{edges:[CAT.light.edge,CAT.light.whiskers],eye:eyeOf(CAT.light.eye,CAT.light.fur)},dark:{edges:[CAT.dark.edge,CAT.dark.whiskers],eye:eyeOf(CAT.dark.eye,CAT.dark.fur)}}},{id:"eyes",name:"L👀P eyes",Drawing:LoopEyes,keyColours:{light:{edges:[LOOP_EYES.light.eye.ring],eye:eyeOf(LOOP_EYES.light.eye,"page")},dark:{edges:[LOOP_EYES.dark.eye.white],eye:eyeOf(LOOP_EYES.dark.eye,"page")}}}],DEFAULT_ASSISTANT_CHARACTER="paperclip";function assistantCharacter(Au){const lo=ASSISTANT_CHARACTERS.find($u=>$u.id===Au);if(!lo)throw new Error(`There is no assistant character "${Au}"; the characters are ${ASSISTANT_CHARACTERS.map($u=>$u.id).join(", ")}.`);return lo}const DEFAULT_DECISION_NAME="Answer",DEFAULT_SCORE_RANGE={from:1,to:5},MAX_SCORE_STEPS=11;function scoreSteps(Au){const lo=[];for(let $u=Au.from;$u<=Au.to;$u+=1)lo.push(String($u));return lo}function decisionAskProblem(Au){if(!Au.situation.trim())return"Say the situation the question is about.";if(!Au.question.trim())return"Ask a question.";if(Au.type==="choice"){const lo=(Au.options??[]).filter($u=>$u.trim());if(lo.length<2)return"A choice needs at least two options.";if(new Set(lo.map($u=>$u.trim())).size!==lo.length)return"Two options are the same."}if(Au.type==="score"){const lo=Au.range??DEFAULT_SCORE_RANGE;if(!Number.isInteger(lo.from)||!Number.isInteger(lo.to))return"A score goes from a whole number to another.";if(lo.to<=lo.from)return"A score goes from a lower number to a higher one.";if(lo.to-lo.from+1>MAX_SCORE_STEPS)return`A score has at most ${MAX_SCORE_STEPS} steps.`}}function decisionRequest(Au){const lo=Au.type==="choice"?(Au.options??[]).map($u=>$u.trim()).filter(Boolean):Au.type==="score"?scoreSteps(Au.range??DEFAULT_SCORE_RANGE):[];return{state:Au.situation.trim(),questions:[{name:Au.name?.trim()||DEFAULT_DECISION_NAME,type:Au.type,instructions:Au.question.trim(),options:lo}]}}function confidenceWords(Au){return String(Number(Au.toFixed(2)))}function decisionAnswerWords(Au,lo,$u=[]){if(typeof lo.probability=="number"&&lo.choice===void 0){const Iu=lo.probability>=.5;return`${Au}: ${Iu?"yes":"no"} (${confidenceWords(Iu?lo.probability:1-lo.probability)})`}const Ru=typeof lo.confidence=="number"?` (${confidenceWords(lo.confidence)})`:"";if(typeof lo.score=="number"){const Iu=$u.length?$u:Object.keys(lo.legend??{}).sort((Du,Lu)=>Number(Du)-Number(Lu)).map(Du=>lo.legend?.[Du]??Du),Pu=lo.legend?.[String(lo.score)]??Iu[lo.score],Ou=Iu[Iu.length-1],Mu=Iu.length>0&&Iu.every(Du=>/^-?\d+$/.test(Du.trim()));return`${Au}: ${Pu??lo.score+1}${Mu&&Ou!==void 0?` of ${Ou}`:""}${Ru}`}return typeof lo.choice=="string"?`${Au}: ${lo.choice}${Ru}`:`${Au}: no answer`}function decisionResponseWords(Au,lo){if(lo.refusal)return lo.refusal;const[$u]=Au.questions,Ru=lo.answers?.[$u.name];return Ru?decisionAnswerWords($u.name,Ru,$u.options):"Nothing was decided: the answer did not come back."}function decisionsAskerAt(Au,lo){const $u=Au.replace(/\/+$/,"");return async Ru=>{let Iu;try{Iu=await fetch(`${$u}/api/v1/configure/inference/decisions`,{method:"POST",headers:{"Content-Type":"application/json",...lo?{Authorization:`Bearer ${lo}`}:{}},body:JSON.stringify(Ru)})}catch{return{refusal:"Nothing was decided: the runtime could not be reached."}}if(!Iu.ok){let Pu="";try{const Ou=await Iu.json();Pu=typeof Ou.detail=="string"?Ou.detail:""}catch{}return{refusal:`Nothing was decided: the runtime refused it (${Iu.status})${Pu?`: ${Pu}`:"."}`}}return await Iu.json()}}const DECISION_WORDS={ask:"Ask a decision",asking:"Asking…",submit:"Ask",cancel:"Cancel",again:"Ask another",types:{noul:"Yes or no",choice:"A choice",score:"A score"}},LINK_SX={mt:1,p:0,border:0,bg:"transparent",color:"accent.fg",textDecoration:"underline",cursor:"pointer",fontSize:1};function DecisionAsk({ask:Au,onActiveChange:lo}){const[$u,Ru]=reactExports.useState(!1),[Iu,Pu]=reactExports.useState(""),[Ou,Mu]=reactExports.useState(""),[Du,Lu]=reactExports.useState(""),[Bu,ju]=reactExports.useState("noul"),[Fu,zu]=reactExports.useState(""),[Uu,Hu]=reactExports.useState(String(DEFAULT_SCORE_RANGE.from)),[Vu,Gu]=reactExports.useState(String(DEFAULT_SCORE_RANGE.to)),[Wu,Ku]=reactExports.useState(),[Ju,Yu]=reactExports.useState(!1),[Xu,ed]=reactExports.useState(),td=reactExports.useRef(lo);td.current=lo,reactExports.useEffect(()=>()=>td.current?.(!1),[]);const nd=ad=>{Ru(ad),lo?.(ad)},od=()=>{ed(void 0),Ku(void 0),nd(!1)};if(!$u)return jsxRuntimeExports.jsx(Box,{as:"button",type:"button","data-balloon-ask-decision":"",onClick:()=>nd(!0),...LINK_SX,display:"block",children:DECISION_WORDS.ask});if(Xu!==void 0)return jsxRuntimeExports.jsxs(Box,{"data-balloon-decision":"answered",mt:2,children:[jsxRuntimeExports.jsx(Text$3,{as:"p","data-decision-answer":"",sx:{m:0,fontWeight:"semibold"},children:Xu}),jsxRuntimeExports.jsxs(Box,{display:"flex",gap:2,mt:2,children:[jsxRuntimeExports.jsx(ButtonComponent,{size:"small",onClick:()=>ed(void 0),children:DECISION_WORDS.again}),jsxRuntimeExports.jsx(ButtonComponent,{size:"small",variant:"invisible",onClick:od,children:DECISION_WORDS.cancel})]})]});const sd=async()=>{const ad={situation:Iu,question:Ou,type:Bu,name:Du,options:Fu.split(`
|
|
3688
3688
|
`),range:{from:Number(Uu),to:Number(Vu)}},pd=decisionAskProblem(ad);if(Ku(pd),pd)return;const gd=decisionRequest(ad);Yu(!0);try{ed(decisionResponseWords(gd,await Au(gd)))}catch(_d){ed(`Nothing was decided: ${_d instanceof Error?_d.message:String(_d)}`)}finally{Yu(!1)}};return jsxRuntimeExports.jsxs(Box,{as:"form","data-balloon-decision":"asking","aria-label":DECISION_WORDS.ask,onSubmit:ad=>{ad.preventDefault(),sd()},onKeyDown:ad=>{ad.key==="Escape"&&od()},mt:2,display:"flex",flexDirection:"column",gap:2,children:[jsxRuntimeExports.jsxs(FormControl$1,{children:[jsxRuntimeExports.jsx(FormControl$1.Label,{children:"Situation"}),jsxRuntimeExports.jsx(Textarea,{block:!0,rows:3,resize:"vertical",name:"situation",placeholder:"Help! My payouts have been failing for 3 days.",value:Iu,onChange:ad=>Pu(ad.target.value)})]}),jsxRuntimeExports.jsxs(FormControl$1,{children:[jsxRuntimeExports.jsx(FormControl$1.Label,{children:"Question"}),jsxRuntimeExports.jsx(TextInput$1,{block:!0,size:"small",name:"question",placeholder:"Is it urgent?",value:Ou,onChange:ad=>Mu(ad.target.value)})]}),jsxRuntimeExports.jsxs(Box,{display:"flex",gap:2,children:[jsxRuntimeExports.jsxs(FormControl$1,{sx:{flex:1},children:[jsxRuntimeExports.jsx(FormControl$1.Label,{children:"Type"}),jsxRuntimeExports.jsx(Select$1,{block:!0,size:"small",name:"type",value:Bu,onChange:ad=>ju(ad.target.value),children:Object.keys(DECISION_WORDS.types).map(ad=>jsxRuntimeExports.jsx(Select$1.Option,{value:ad,children:DECISION_WORDS.types[ad]},ad))})]}),jsxRuntimeExports.jsxs(FormControl$1,{sx:{flex:1},children:[jsxRuntimeExports.jsx(FormControl$1.Label,{children:"Name"}),jsxRuntimeExports.jsx(TextInput$1,{block:!0,size:"small",name:"name",placeholder:"Answer",value:Du,onChange:ad=>Lu(ad.target.value)})]})]}),Bu==="choice"&&jsxRuntimeExports.jsxs(FormControl$1,{children:[jsxRuntimeExports.jsx(FormControl$1.Label,{children:"Options, one per line"}),jsxRuntimeExports.jsx(Textarea,{block:!0,rows:3,resize:"vertical",name:"options",placeholder:`Billing
|
|
3689
3689
|
Tech
|
|
@@ -3852,7 +3852,7 @@ ${Mu}`:ju,inputs:Mu,clear:Ou?[]:[DRAFT.path],loop:Lu()}:{refused:"Nothing to sen
|
|
|
3852
3852
|
0%, 100% { opacity: 0.25; }
|
|
3853
3853
|
50% { opacity: 1; }
|
|
3854
3854
|
}`;function SubagentPulse(){const Au=useAgentRuntimeActiveSubagentToolCallId(),lo=useAgentRuntimeSubagentActivity(Au??void 0),$u=useOptionalReactorPlatform(),Ru=lo[0]?.subagentName??Au??"",Iu=$u?.getOutput(AGENTS_PLUGIN_NAME)?.team?.members.find(Du=>Du.name===Ru),Pu=agentIcon(Iu?.icon);if(!Au)return null;const Mu=lo.some(Du=>Du.transport==="a2a")?`${Ru} is working over A2A…`:`${Ru} is working…`;return jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("style",{children:KEYFRAMES}),jsxRuntimeExports.jsx(Tooltip,{text:Mu,direction:"n",children:jsxRuntimeExports.jsx(Box,{as:"button",type:"button","aria-label":Mu,"data-subagent-pulse":Ru,display:"inline-flex",alignItems:"center",justifyContent:"center",width:28,height:28,p:0,border:0,bg:"transparent",color:"accent.fg",cursor:"default",animation:`${PULSE_ANIMATION} 1.4s ease-in-out infinite`,children:jsxRuntimeExports.jsx(Pu,{size:16})})})]})}const SUBAGENT_ACTIVITY_PLUGIN_NAME="@datalayer/loop-plugin-subagent-activity",SubagentActivityPlugin={name:SUBAGENT_ACTIVITY_PLUGIN_NAME,displayName:"Subagent activity",description:"A delegated agent's icon, pulsing in the prompt's header while it works.",octicon:"people",emoji:"👥",dependencies:[InputPromptPlugin],build:()=>({components:[{id:"subagent-pulse",slot:LoopSlots.inpromptMenu,order:0,Component:SubagentPulse}]})},A2UI_PLUGIN_NAME="@datalayer/loop-plugin-a2ui",A2uiPlugin={name:A2UI_PLUGIN_NAME,displayName:"A2UI surfaces",description:"The last execution, rendered as a surface rather than dumped.",octicon:"browser",emoji:"🖼",dependencies:[AgentsPlugin],contributes:[contribution(LoopViewType,{viewType:"a2ui",title:"Surface",icon:BrowserIcon,order:30,canOpen:Au=>Au.sandbox.state==="running"&&Au.sandbox.variant!=="pyodide",unavailableReason:Au=>Au.sandbox.variant==="pyodide"?"Surfaces are rendered by the server; this sandbox runs in the browser":"Needs a running sandbox",load:()=>__vitePreload(()=>import("./chunks/A2uiView-EmeKVJZp.js"),[],import.meta.url)},{id:"a2ui",order:30}),contribution(LoopCommand,{name:"a2ui",aliases:["surface"],description:"Show the last execution as a rendered surface",group:"Open",keybinding:"Mod+Alt+U",run:async({workspace:Au})=>{Au.setActiveViewType("a2ui")}},{id:"a2ui"})]},NONE_VIEW="none";let state={viewId:NONE_VIEW,options:[],allowNone:!0},announcer=()=>!0;const listeners=new Set;function notify(){for(const Au of[...listeners])Au()}function getViewChoice(){return state}function subscribeViewChoice(Au){return listeners.add(Au),()=>{listeners.delete(Au)}}function setViewAnnouncer(Au){const lo=announcer;return announcer=Au,()=>{announcer=lo}}function setViewOptions(Au,lo=!0){if(lo===state.allowNone&&Au.length===state.options.length&&Au.every((Ru,Iu)=>Ru===state.options[Iu]))return;state={viewId:!lo&&!Au.includes(state.viewId)?Au[0]??NONE_VIEW:state.viewId,options:Au,allowNone:lo},notify()}function chooseView(Au){return state={...state,viewId:Au},notify(),announcer(Au)}function seedViewChoice(Au){state.viewId!==Au&&(state={...state,viewId:Au},notify())}function nextView(){const Au=state.allowNone?[NONE_VIEW,...state.options]:[...state.options];if(Au.length===0)return NONE_VIEW;const lo=Au.indexOf(state.viewId);return Au[(lo+1)%Au.length]}function ViewSelector({point:Au,describe:lo,context:$u,noneLabel:Ru,ariaLabel:Iu,allowNone:Pu=!0}){const Ou=useContributions(Au),Mu=reactExports.useSyncExternalStore(subscribeViewChoice,getViewChoice),[Du,Lu]=reactExports.useState(null),Bu=reactExports.useRef(null),ju=()=>{Bu.current!==null&&(window.clearTimeout(Bu.current),Bu.current=null)},Fu=Vu=>{ju(),Lu(Vu)},zu=()=>{ju(),Bu.current=window.setTimeout(()=>{Lu(null),Bu.current=null},250)};reactExports.useEffect(()=>ju,[]);const Uu=reactExports.useMemo(()=>Ou.map(Vu=>lo(Vu.value,$u)).sort((Vu,Gu)=>(Vu.order??100)-(Gu.order??100)),[Ou,lo,$u]);if(reactExports.useEffect(()=>{setViewOptions(Uu.map(Vu=>Vu.id),Pu)},[Uu,Pu]),Uu.length<(Pu?1:2))return null;const Hu=Uu.find(Vu=>Vu.id===Du&&Vu.details);return jsxRuntimeExports.jsxs(Box$1,{sx:{marginLeft:"auto",display:"flex",alignItems:"center",position:"relative"},children:[jsxRuntimeExports.jsxs(SegmentedControl,{"aria-label":Iu,size:"small",children:[Pu?jsxRuntimeExports.jsx(SegmentedControl.Button,{selected:Mu.viewId===NONE_VIEW,onClick:()=>chooseView(NONE_VIEW),children:Ru}):null,Uu.map(Vu=>jsxRuntimeExports.jsx(SegmentedControl.Button,{selected:Mu.viewId===Vu.id,"aria-disabled":Vu.disabled||void 0,title:Vu.disabled?Vu.disabledReason:Vu.title,leadingIcon:Vu.icon,onMouseEnter:Vu.details?()=>Fu(Vu.id):void 0,onMouseLeave:Vu.details?zu:void 0,onClick:()=>{Vu.disabled||chooseView(Vu.id)},children:Vu.badge?`${Vu.title} (${Vu.badge})`:Vu.title},Vu.id))]}),Hu?jsxRuntimeExports.jsx(Box$1,{onMouseEnter:ju,onMouseLeave:zu,sx:{position:"absolute",top:"calc(100% + 6px)",right:0,minWidth:260,maxWidth:380,maxHeight:320,overflowY:"auto",p:2,bg:"canvas.overlay",border:"1px solid",borderColor:"border.default",borderRadius:2,boxShadow:"shadow.large",zIndex:40,fontSize:0,color:"fg.default",textAlign:"left"},children:Hu.details}):null]})}const SHELL_PLUGIN_NAME$1="@datalayer/reactor-shell",ShellView=defineContributionPoint("reactor.shell.view"),describeAsIs=Au=>Au,ShellPlugin$1={name:SHELL_PLUGIN_NAME$1,displayName:"Shell",description:"A view point, its selector, and the choice as a command.",octicon:"columns",emoji:"📑",config:{point:ShellView,describe:describeAsIs,slot:"header",defaultView:NONE_VIEW,showSelector:!0,allowNone:!0,noneLabel:"None",ariaLabel:"View",announce:()=>!0,commandId:"shell.cycleView",commandName:"Switch the view",commandDescription:"Cycle through the contributed views, and none",keybinding:"Mod+Alt+E"},contributionPoints:[ShellView],register:({config:Au,registerCommand:lo})=>{const $u=setViewAnnouncer(Au.announce),Ru=lo({id:Au.commandId,name:Au.commandName,description:Au.commandDescription,emoji:"📑",category:"Workspace",keybinding:Au.keybinding||void 0,execute:()=>{chooseView(nextView())}});return()=>{$u(),Ru()}},build:({config:Au})=>(seedViewChoice(Au.defaultView||NONE_VIEW),{components:Au.showSelector?[{id:"view-selector",slot:Au.slot,Component:lo=>jsxRuntimeExports.jsx(ViewSelector,{point:Au.point,describe:Au.describe,context:lo,noneLabel:Au.noneLabel,allowNone:Au.allowNone,ariaLabel:Au.ariaLabel})}]:[]})};setViewAnnouncer(requestSurface);const NONE_EDITOR=NONE_VIEW;let mappedFor=null,mapped=null;function getEditorChoice(){const Au=getViewChoice();return(Au!==mappedFor||!mapped)&&(mappedFor=Au,mapped={editorId:Au.viewId,options:Au.options}),mapped}const subscribeEditorChoice=subscribeViewChoice,setEditorOptions=setViewOptions,chooseEditor=chooseView,seedEditorChoice=seedViewChoice,nextEditor=nextView;let jupyterReact=null;function loadJupyterReact(){return jupyterReact?Promise.resolve(jupyterReact):__vitePreload(()=>import("./chunks/index-BN8Bbau-.js").then(Au=>Au.r),[],import.meta.url).then(Au=>(jupyterReact=Au,Au))}const PREVIEW_LENGTH=56;function stripped(Au){const $u=(Au.split(`
|
|
3855
|
-
`).find(Ru=>Ru.trim())??"").trim();return $u.length>PREVIEW_LENGTH?`${$u.slice(0,PREVIEW_LENGTH-1)}…`:$u||"(empty)"}function PreviewList({title:Au,rows:lo}){return jsxRuntimeExports.jsxs(Box,{children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontWeight:"semibold",display:"block",mb:1},children:Au}),lo.length===0?jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted"},children:"Empty so far."}):lo.map(($u,Ru)=>jsxRuntimeExports.jsxs(Box,{display:"flex",gap:2,py:"2px",alignItems:"baseline",children:[jsxRuntimeExports.jsxs(Text$3,{sx:{color:"fg.muted",flexShrink:0,fontFamily:"mono"},children:[Ru," · ",$u.kind]}),jsxRuntimeExports.jsx(Text$3,{sx:{fontFamily:"mono",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$u.text})]},Ru))]})}function useOfferedEditors(){return reactExports.useSyncExternalStore(subscribeEditorChoice,()=>getEditorChoice().options)}function useNotebookRows(Au,lo){const[$u,Ru]=reactExports.useState(0);return reactExports.useEffect(()=>{if(!lo)return;let Iu=!1;const Pu=()=>Ru(Du=>Du+1),Ou=[],Mu=jupyterReact!==null;return loadJupyterReact().then(({notebookStore:Du})=>{if(!Iu)try{const Lu=Du.subscribe?.(Pu);Lu&&Ou.push(Lu);const Bu=Du.getState()?.notebooks?.get(Au)?.model;if(Bu){const ju=[Bu.contentChanged,Bu.cells?.changed];for(const Fu of ju)Fu?.connect&&(Fu.connect(Pu),Ou.push(()=>Fu.disconnect(Pu)))}Mu||Pu()}catch{}}),()=>{Iu=!0;for(const Du of Ou)try{Du()}catch{}}},[lo,Au,$u]),reactExports.useMemo(()=>{if(!lo)return null;const Iu=safeModel(Au);if(!Iu)return null;const Pu=[],Ou=Iu.cells;for(let Mu=0;Mu<Ou.length;Mu+=1){const Du=Ou.get(Mu);Pu.push({kind:Du.type,text:stripped(Du.sharedModel.getSource())})}return Pu},[lo,Au,$u])}function safeModel(Au){try{return jupyterReact?.notebookStore.getState()?.notebooks?.get(Au)?.model??null}catch{return null}}function useDocumentRows(Au,lo){const[$u,Ru]=reactExports.useState(null);return reactExports.useEffect(()=>{if(!lo){Ru(null);return}let Iu=!1,Pu,Ou=!1;return __vitePreload(()=>import("./chunks/PrismCss-CcU1ChRk.js").then(Mu=>Mu.a),[],import.meta.url).then(()=>__vitePreload(()=>import("./chunks/index-_nsBY26B.js"),[],import.meta.url)).then(({lexicalStore:Mu})=>{if(Iu)return;const Du=()=>{Ou||(Ou=!0,Mu.getState().readAllBlocks(Au,"brief").then(Lu=>{Ou=!1,!(Iu||!Array.isArray(Lu))&&Ru(Lu.map(Bu=>({kind:Bu.block_type??"block",text:stripped(Bu.preview??"")})))}).catch(()=>{Ou=!1,Iu||Ru(null)}))};Du(),Pu=Mu.subscribe(Du)}).catch(()=>{Iu||Ru(null)}),()=>{Iu=!0,Pu?.()}},[lo,Au]),$u}function useEditorPreviews(Au){const lo=useOfferedEditors(),$u=useNotebookRows(Au,lo.includes("notebook")),Ru=useDocumentRows(Au,lo.includes("document"));return reactExports.useMemo(()=>{const Iu={};return $u&&(Iu.notebook={badge:String($u.length),details:jsxRuntimeExports.jsx(PreviewList,{title:"Cells",rows:$u})}),Ru&&(Iu.document={badge:String(Ru.length),details:jsxRuntimeExports.jsx(PreviewList,{title:"Blocks",rows:Ru})}),Iu},[$u,Ru])}const SHELL_PLUGIN_NAME="@datalayer/loop-plugin-shell";function describeEditor(Au,lo){const $u=Au,Ru=lo?.workspace,Iu=Ru?canOpenView($u,Ru):!0;return{id:$u.surfaceId,title:$u.title,icon:$u.icon,order:$u.order,disabled:!Iu,disabledReason:Iu?void 0:Ru&&$u.unavailableReason?.(Ru)||"Not available right now"}}function EditorSelectorComponent(Au){const lo=Au.workspace,$u=useEditorPreviews(lo?.surfaceId??""),Ru=(Iu,Pu)=>{const Ou=describeEditor(Iu,Pu),Mu=$u[Ou.id];return Mu?{...Ou,badge:Mu.badge,details:Mu.details}:Ou};return jsxRuntimeExports.jsx(ViewSelector,{point:LoopEditorView,describe:Ru,context:Au,noneLabel:"Chat",ariaLabel:"Editor"})}const ShellPlugin={name:SHELL_PLUGIN_NAME,displayName:"Loop shell",description:"The Loop workspace’s extension points, and the editor choice.",octicon:"columns",emoji:"📑",config:{defaultEditor:NONE_EDITOR,showSelector:!0},dependencies:[configurePlugin(ShellPlugin$1,{point:LoopEditorView,describe:describeEditor,showSelector:!1,announce:Au=>requestSurface(Au),commandId:"loop.shell.cycleEditor",commandName:"Switch the editor",commandDescription:"Cycle through the editors beside the conversation, and none",keybinding:""})],contributionPoints:[LoopViewType,LoopEditorView],contributes:[contribution(LoopCommand,{name:"editor",aliases:["editors"],description:"Switch the editor beside the conversation",group:"Open",keybinding:"Mod+Alt+E",args:[{name:"editor",description:"Which editor: none, or a surface id. Omit to cycle.",required:!1,choices:()=>[NONE_EDITOR,...getEditorChoice().options]}],run:async({argv:Au})=>{const lo=Au.trim(),$u=lo===""?nextEditor():lo,Ru=[NONE_EDITOR,...getEditorChoice().options];if(!Ru.includes($u))throw new Error(`No editor called '${$u}'. There is: ${Ru.join(", ")}.`);if(!chooseEditor($u))throw new Error("No chat is on screen to host the editor.")}},{id:"editor"})],build:({config:Au})=>(seedEditorChoice(Au.defaultEditor||NONE_EDITOR),{components:Au.showSelector?[{id:"editor-selector",slot:LoopSlots.header,Component:EditorSelectorComponent}]:[]})};function NewChatAction({workspace:Au}){return Au?jsxRuntimeExports.jsx(IconButton,{icon:PlusIcon,"aria-label":"New conversation",title:"New conversation",variant:"invisible",size:"small",onClick:()=>{Au.submit("/new")}}):null}const PROMPT_PLUGIN_NAME="@datalayer/loop-plugin-prompt",PromptPlugin={name:PROMPT_PLUGIN_NAME,displayName:"Prompt",description:"Prompt commands: focus the composer, start over, and the +.",octicon:"paper-airplane",emoji:"🪶",contributes:[contribution(LoopCommand,{name:"prompt",description:"Focus the prompt",group:"Session",keybinding:"Mod+Alt+P",run:async()=>{if(!focusPrompt())throw new Error("No prompt is on screen to focus.")}},{id:"prompt"}),contribution(LoopCommand,{name:"new",aliases:["reset"],description:"Start the conversation over",group:"Session",keybinding:"Mod+Alt+R",run:async({workspace:Au})=>{const lo=Au.viewControls.newChat;if(!lo)throw new Error("No conversation is on screen to start over.");lo()}},{id:"new"})],build:()=>({components:[{id:"new-chat",slot:LoopSlots.promptAction,Component:NewChatAction}]})};function AgentspecPicker({workspace:Au}){const[lo,$u]=reactExports.useState([]),[Ru,Iu]=reactExports.useState(!1),[Pu,Ou]=reactExports.useState(Au.agentId),Mu=Au.sandbox.target,Du=Au.sandbox.state;reactExports.useEffect(()=>{let Fu=!1;return fetch(`${Au.serverUrl}/api/v1/agents`).then(zu=>zu.ok?zu.json():{agents:[]}).then(zu=>{Fu||$u(zu.agents??[])}).catch(()=>{}),()=>{Fu=!0}},[Au.serverUrl,Mu,Du]),reactExports.useEffect(()=>{Ou(Au.agentId)},[Au.agentId]);const Lu=reactExports.useCallback(async Fu=>{Iu(!0);try{(await fetch(`${Au.serverUrl}/api/v1/loop/sessions/${encodeURIComponent(Au.conversationId||Au.agentId||"session")}/agent`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({agent_id:Fu})})).ok&&(Ou(Fu),Au.setAgentId(Fu))}finally{Iu(!1)}},[Au.agentId,Au.conversationId,Au.serverUrl,Au.setAgentId]),Bu=lo.find(Fu=>Fu.id===Pu),ju=Bu?.name||getAgentspecs(Pu)?.name||Pu||"Agent";return lo.length===0?null:jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:1,children:[Ru?jsxRuntimeExports.jsx(StyledSpinner,{size:"small"}):null,jsxRuntimeExports.jsxs(ActionMenu,{children:[jsxRuntimeExports.jsxs(ActionMenu.Button,{variant:"invisible",size:"small",children:[Bu?.emoji?`${Bu.emoji} `:"",ju]}),jsxRuntimeExports.jsx(ActionMenu.Overlay,{width:"medium",children:jsxRuntimeExports.jsx(ActionList,{selectionVariant:"single",children:lo.map(Fu=>jsxRuntimeExports.jsxs(ActionList.Item,{selected:Fu.id===Pu,onSelect:()=>{Lu(Fu.id)},children:[Fu.emoji?`${Fu.emoji} `:"",Fu.name||Fu.id,Fu.description?jsxRuntimeExports.jsx(ActionList.Description,{variant:"block",children:Fu.description}):null]},Fu.id))})})]})]})}const AGENTSPECS_PLUGIN_NAME="@datalayer/loop-plugin-agentspecs",AgentspecsPlugin={name:AGENTSPECS_PLUGIN_NAME,displayName:"Agentspecs",description:"Pick the agentspec this session runs.",octicon:"people",emoji:"🤖",build(){return{components:[{slot:LoopSlots.header,id:"agent-picker",Component:AgentspecPicker}]}},contributes:[contribution(LoopCommand,{name:"agents",aliases:["agent"],description:"Switch the agent this session is using",group:"Agents",keybinding:"Mod+Alt+A",args:[{name:"agent-id",description:"Agent to switch to"}],run:async({workspace:Au,argv:lo})=>{const $u=lo.trim();if(!$u)return{content:"Pick an agent from the header, or /agents <id>."};const Ru=await fetch(`${Au.serverUrl}/api/v1/loop/sessions/${encodeURIComponent(Au.conversationId||Au.agentId||"session")}/agent`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({agent_id:$u})});if(!Ru.ok)return{content:`Unknown agent: ${$u}`};const Iu=await Ru.json();return{content:`Now using ${Iu.name??Iu.agent_id}.`}}},{id:"agents"})]},CHAT_HEADER_PLUGIN_NAME="@datalayer/loop-plugin-chat-header",LazyHeaderView=reactExports.lazy(()=>__vitePreload(()=>import("./chunks/HeaderView-DVGhaRai.js"),[],import.meta.url));function HeaderView(Au){return jsxRuntimeExports.jsx(reactExports.Suspense,{fallback:null,children:jsxRuntimeExports.jsx(LazyHeaderView,{...Au})})}const ChatHeaderPlugin={name:CHAT_HEADER_PLUGIN_NAME,displayName:"Chat Header",description:"The conversation’s title bar: agent, kernel, actions.",octicon:"rows",emoji:"🏷️",contributes:[contribution(LoopChatHeader,{id:"chat-header",Component:HeaderView},{id:"chat-header"})]};function readA2uiToolResult(Au,lo){if(!Au)return null;let $u=Au;if(typeof Au=="string")try{$u=JSON.parse(Au)}catch{return null}if(typeof $u!="object"||$u===null||!Array.isArray($u.messages))return null;const Ru=$u,Iu=(Ru.messages??[]).map(Pu=>{const Ou=Pu;return Ou.createSurface&&Ou.createSurface.catalogId!==lo?{...Ou,createSurface:{...Ou.createSurface,catalogId:lo}}:Pu});return{...Ru,messages:Iu}}function isEmptyA2uiValue(Au){return Au==null?!0:typeof Au=="string"?Au.trim()==="":Array.isArray(Au)?Au.length===0:typeof Au=="boolean"?Au===!1:!1}const EMAIL_PATTERN=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function validateA2uiField(Au,lo){if(isEmptyA2uiValue(lo))return Au.required?`${Au.label} is required.`:null;if(Au.format==="email"&&typeof lo=="string"&&!EMAIL_PATTERN.test(lo.trim()))return`${Au.label} must be a valid email address.`;if(Au.pattern&&typeof lo=="string"){let $u;try{$u=new RegExp(Au.pattern).test(lo.trim())}catch{$u=!0}if(!$u)return`${Au.label} is not in the expected format.`}if(Au.minLength!==void 0&&typeof lo=="string"&&lo.trim().length<Au.minLength)return`${Au.label} must be at least ${Au.minLength} characters.`;if(Au.type==="slider"&&typeof lo=="number"){if(Au.min!==void 0&&lo<Au.min)return`${Au.label} must be at least ${Au.min}.`;if(Au.max!==void 0&&lo>Au.max)return`${Au.label} must be at most ${Au.max}.`}return null}function validateA2uiSubmission(Au,lo){return Au.map($u=>validateA2uiField($u,lo[$u.id])).filter($u=>$u!==null)}const ANSWER_DISPLAY_TYPE="application/vnd.datalayer.loop.answer+json";function answerSurface(Au,lo){return Au.type!==ANSWER_DISPLAY_TYPE?null:readA2uiToolResult(Au.data?.surface,lo)}function answerPress(Au,lo){const $u=lo.name.trim(),Ru=(Au.actions??[]).find(Iu=>Iu.name===$u);return Ru?{message:$u,forwardedProps:{loop:{action:{name:$u,display_id:Au.id,token:Ru.token,payload:{...lo.context}}}}}:{refused:`“${$u||"This button"}” was not offered here.`}}function AnswerShowsView({display:Au,send:lo}){const $u=reactExports.useMemo(()=>answerSurface(Au,SURFACE_CATALOG_ID),[Au]),Ru=useOwnCatalog(),[Iu,Pu]=reactExports.useState(null);if(!$u?.messages||$u.messages.length===0)return jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted"},children:Au.text});const Ou=Mu=>{const Du=answerPress(Au,Mu);if("refused"in Du){Pu(Du.refused);return}Pu(lo(Du.message,Du.forwardedProps)?null:"The chat is not ready to take it yet.")};return jsxRuntimeExports.jsx(InlineSurface,{messages:$u.messages,onAction:Ou,validationError:Iu,catalog:Ru},JSON.stringify(Au))}function SurfaceToolResult({context:Au,send:lo,onRendered:$u,onSubmitted:Ru}){const Iu=reactExports.useMemo(()=>Au.status==="complete"?readA2uiToolResult(Au.result,SURFACE_CATALOG_ID):null,[Au.status,Au.result]),Pu=Iu?.title??"the form",[Ou,Mu]=reactExports.useState(null),Du=useOwnCatalog();reactExports.useEffect(()=>{Iu?.messages&&Iu.messages.length>0&&$u?.({toolCallId:Au.toolCallId,surfaceId:Iu.surfaceId,title:Pu,messages:Iu.messages,result:Iu})},[Iu,Au.toolCallId]);const Lu=reactExports.useCallback(Bu=>{if(Bu.name!=="submit_a2ui_form")return;const ju=Bu.context??{},Fu=validateA2uiSubmission(Iu?.fieldRules??[],ju);if(Fu.length>0){Mu(Fu.join(" "));return}Mu(null),Ru?.({surfaceId:Bu.surfaceId,title:Pu,values:ju}),lo(encodeFormSubmission({title:Pu,surfaceId:Bu.surfaceId,values:ju}))||Mu("The chat is not ready to take the submission yet.")},[Iu,Pu,lo,Ru]);return!Iu?.messages||Iu.messages.length===0?jsxRuntimeExports.jsxs(Box,{border:"1px solid",borderColor:"border.default",borderRadius:2,px:3,py:2,bg:"canvas.default",display:"flex",alignItems:"center",gap:2,children:[jsxRuntimeExports.jsx(StyledSpinner,{size:"small"}),jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:1,color:"fg.muted"},children:"Rendering A2UI surface..."})]}):jsxRuntimeExports.jsxs(Box,{display:"flex",flexDirection:"column",gap:2,children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontWeight:"bold"},children:Pu}),jsxRuntimeExports.jsx(InlineSurface,{messages:Iu.messages,onAction:Lu,validationError:Ou,catalog:Du})]})}const A2UI_SURFACE_PLUGIN_NAME="@datalayer/loop-plugin-a2ui-surface",A2UI_SURFACE_RENDERER="a2ui-surface",A2UI_SURFACE_TYPE="application/vnd.datalayer.a2ui.surface+json";function surfaceToolNames(){const Au=new Set;for(const lo of Object.values(AGENTSPECS))for(const $u of lo.frontendRenderTools??[])$u.renderer===A2UI_SURFACE_RENDERER&&Au.add($u.tool);return Au}let counter=0;function createA2uiSurfacePlugin(Au={}){const lo=`a2ui-surface-${counter+=1}`;let $u;const Ru=(Du,Lu)=>$u?!$u(Du,Lu):!1;function Iu({workspace:Du}){const Lu=Du?.viewControls.send;return reactExports.useEffect(()=>($u=Lu,()=>{$u===Lu&&($u=void 0)}),[Lu]),null}function Pu({context:Du}){return Du?Du.status==="error"?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:Du.defaultUI}):jsxRuntimeExports.jsx(SurfaceToolResult,{context:Du,send:Ru,onRendered:Au.onRendered,onSubmitted:Au.onSubmitted},Du.toolCallId):null}function Ou({display:Du}){return jsxRuntimeExports.jsx(AnswerShowsView,{display:Du,send:Ru})}return{name:counter===1?A2UI_SURFACE_PLUGIN_NAME:`${A2UI_SURFACE_PLUGIN_NAME}-${lo}`,displayName:"A2UI surfaces",description:"Generated surfaces drawn in the transcript, and submitted back to the agent.",octicon:"browser",emoji:"🪟",contributes:[contribution(Renderers,defineRenderer({type:A2UI_SURFACE_TYPE,component:Pu,rank:Au.onRendered||Au.onSubmitted?1:0}),{id:lo}),contribution(Renderers,defineRenderer({type:ANSWER_DISPLAY_TYPE,component:Ou}),{id:`${lo}:answer`}),...[...surfaceToolNames()].map(Du=>contribution(ToolBindings,{tool:Du,type:A2UI_SURFACE_TYPE},{id:`${lo}:${Du}`}))],build(){return{components:[{slot:LoopSlots.chatHeader,id:lo,Component:Iu}]}}}}const A2uiSurfacePlugin=createA2uiSurfacePlugin(),qrcode=function(Au,lo){let Iu=Au;const Pu=QRErrorCorrectionLevel[lo];let Ou=null,Mu=0,Du=null;const Lu=[],Bu={},ju=function(ed,td){Mu=Iu*4+17,Ou=(function(nd){const od=new Array(nd);for(let sd=0;sd<nd;sd+=1){od[sd]=new Array(nd);for(let ad=0;ad<nd;ad+=1)od[sd][ad]=null}return od})(Mu),Fu(0,0),Fu(Mu-7,0),Fu(0,Mu-7),Hu(),Uu(),Gu(ed,td),Iu>=7&&Vu(ed),Du==null&&(Du=Ju(Iu,Pu,Lu)),Wu(Du,td)},Fu=function(ed,td){for(let nd=-1;nd<=7;nd+=1)if(!(ed+nd<=-1||Mu<=ed+nd))for(let od=-1;od<=7;od+=1)td+od<=-1||Mu<=td+od||(0<=nd&&nd<=6&&(od==0||od==6)||0<=od&&od<=6&&(nd==0||nd==6)||2<=nd&&nd<=4&&2<=od&&od<=4?Ou[ed+nd][td+od]=!0:Ou[ed+nd][td+od]=!1)},zu=function(){let ed=0,td=0;for(let nd=0;nd<8;nd+=1){ju(!0,nd);const od=QRUtil.getLostPoint(Bu);(nd==0||ed>od)&&(ed=od,td=nd)}return td},Uu=function(){for(let ed=8;ed<Mu-8;ed+=1)Ou[ed][6]==null&&(Ou[ed][6]=ed%2==0);for(let ed=8;ed<Mu-8;ed+=1)Ou[6][ed]==null&&(Ou[6][ed]=ed%2==0)},Hu=function(){const ed=QRUtil.getPatternPosition(Iu);for(let td=0;td<ed.length;td+=1)for(let nd=0;nd<ed.length;nd+=1){const od=ed[td],sd=ed[nd];if(Ou[od][sd]==null)for(let ad=-2;ad<=2;ad+=1)for(let pd=-2;pd<=2;pd+=1)ad==-2||ad==2||pd==-2||pd==2||ad==0&&pd==0?Ou[od+ad][sd+pd]=!0:Ou[od+ad][sd+pd]=!1}},Vu=function(ed){const td=QRUtil.getBCHTypeNumber(Iu);for(let nd=0;nd<18;nd+=1){const od=!ed&&(td>>nd&1)==1;Ou[Math.floor(nd/3)][nd%3+Mu-8-3]=od}for(let nd=0;nd<18;nd+=1){const od=!ed&&(td>>nd&1)==1;Ou[nd%3+Mu-8-3][Math.floor(nd/3)]=od}},Gu=function(ed,td){const nd=Pu<<3|td,od=QRUtil.getBCHTypeInfo(nd);for(let sd=0;sd<15;sd+=1){const ad=!ed&&(od>>sd&1)==1;sd<6?Ou[sd][8]=ad:sd<8?Ou[sd+1][8]=ad:Ou[Mu-15+sd][8]=ad}for(let sd=0;sd<15;sd+=1){const ad=!ed&&(od>>sd&1)==1;sd<8?Ou[8][Mu-sd-1]=ad:sd<9?Ou[8][15-sd-1+1]=ad:Ou[8][15-sd-1]=ad}Ou[Mu-8][8]=!ed},Wu=function(ed,td){let nd=-1,od=Mu-1,sd=7,ad=0;const pd=QRUtil.getMaskFunction(td);for(let gd=Mu-1;gd>0;gd-=2)for(gd==6&&(gd-=1);;){for(let _d=0;_d<2;_d+=1)if(Ou[od][gd-_d]==null){let yd=!1;ad<ed.length&&(yd=(ed[ad]>>>sd&1)==1),pd(od,gd-_d)&&(yd=!yd),Ou[od][gd-_d]=yd,sd-=1,sd==-1&&(ad+=1,sd=7)}if(od+=nd,od<0||Mu<=od){od-=nd,nd=-nd;break}}},Ku=function(ed,td){let nd=0,od=0,sd=0;const ad=new Array(td.length),pd=new Array(td.length);for(let bd=0;bd<td.length;bd+=1){const Sd=td[bd].dataCount,Ed=td[bd].totalCount-Sd;od=Math.max(od,Sd),sd=Math.max(sd,Ed),ad[bd]=new Array(Sd);for(let ld=0;ld<ad[bd].length;ld+=1)ad[bd][ld]=255&ed.getBuffer()[ld+nd];nd+=Sd;const cd=QRUtil.getErrorCorrectPolynomial(Ed),md=qrPolynomial(ad[bd],cd.getLength()-1).mod(cd);pd[bd]=new Array(cd.getLength()-1);for(let ld=0;ld<pd[bd].length;ld+=1){const hd=ld+md.getLength()-pd[bd].length;pd[bd][ld]=hd>=0?md.getAt(hd):0}}let gd=0;for(let bd=0;bd<td.length;bd+=1)gd+=td[bd].totalCount;const _d=new Array(gd);let yd=0;for(let bd=0;bd<od;bd+=1)for(let Sd=0;Sd<td.length;Sd+=1)bd<ad[Sd].length&&(_d[yd]=ad[Sd][bd],yd+=1);for(let bd=0;bd<sd;bd+=1)for(let Sd=0;Sd<td.length;Sd+=1)bd<pd[Sd].length&&(_d[yd]=pd[Sd][bd],yd+=1);return _d},Ju=function(ed,td,nd){const od=QRRSBlock.getRSBlocks(ed,td),sd=qrBitBuffer();for(let pd=0;pd<nd.length;pd+=1){const gd=nd[pd];sd.put(gd.getMode(),4),sd.put(gd.getLength(),QRUtil.getLengthInBits(gd.getMode(),ed)),gd.write(sd)}let ad=0;for(let pd=0;pd<od.length;pd+=1)ad+=od[pd].dataCount;if(sd.getLengthInBits()>ad*8)throw"code length overflow. ("+sd.getLengthInBits()+">"+ad*8+")";for(sd.getLengthInBits()+4<=ad*8&&sd.put(0,4);sd.getLengthInBits()%8!=0;)sd.putBit(!1);for(;!(sd.getLengthInBits()>=ad*8||(sd.put(236,8),sd.getLengthInBits()>=ad*8));)sd.put(17,8);return Ku(sd,od)};Bu.addData=function(ed,td){td=td||"Byte";let nd=null;switch(td){case"Numeric":nd=qrNumber(ed);break;case"Alphanumeric":nd=qrAlphaNum(ed);break;case"Byte":nd=qr8BitByte(ed);break;case"Kanji":nd=qrKanji(ed);break;default:throw"mode:"+td}Lu.push(nd),Du=null},Bu.isDark=function(ed,td){if(ed<0||Mu<=ed||td<0||Mu<=td)throw ed+","+td;return Ou[ed][td]},Bu.getModuleCount=function(){return Mu},Bu.make=function(){if(Iu<1){let ed=1;for(;ed<40;ed++){const td=QRRSBlock.getRSBlocks(ed,Pu),nd=qrBitBuffer();for(let sd=0;sd<Lu.length;sd++){const ad=Lu[sd];nd.put(ad.getMode(),4),nd.put(ad.getLength(),QRUtil.getLengthInBits(ad.getMode(),ed)),ad.write(nd)}let od=0;for(let sd=0;sd<td.length;sd++)od+=td[sd].dataCount;if(nd.getLengthInBits()<=od*8)break}Iu=ed}ju(!1,zu())},Bu.createTableTag=function(ed,td){ed=ed||2,td=typeof td>"u"?ed*4:td;let nd="";nd+='<table style="',nd+=" border-width: 0px; border-style: none;",nd+=" border-collapse: collapse;",nd+=" padding: 0px; margin: "+td+"px;",nd+='">',nd+="<tbody>";for(let od=0;od<Bu.getModuleCount();od+=1){nd+="<tr>";for(let sd=0;sd<Bu.getModuleCount();sd+=1)nd+='<td style="',nd+=" border-width: 0px; border-style: none;",nd+=" border-collapse: collapse;",nd+=" padding: 0px; margin: 0px;",nd+=" width: "+ed+"px;",nd+=" height: "+ed+"px;",nd+=" background-color: ",nd+=Bu.isDark(od,sd)?"#000000":"#ffffff",nd+=";",nd+='"/>';nd+="</tr>"}return nd+="</tbody>",nd+="</table>",nd},Bu.createSvgTag=function(ed,td,nd,od){let sd={};typeof arguments[0]=="object"&&(sd=arguments[0],ed=sd.cellSize,td=sd.margin,nd=sd.alt,od=sd.title),ed=ed||2,td=typeof td>"u"?ed*4:td,nd=typeof nd=="string"?{text:nd}:nd||{},nd.text=nd.text||null,nd.id=nd.text?nd.id||"qrcode-description":null,od=typeof od=="string"?{text:od}:od||{},od.text=od.text||null,od.id=od.text?od.id||"qrcode-title":null;const ad=Bu.getModuleCount()*ed+td*2;let pd,gd,_d,yd,bd="",Sd;for(Sd="l"+ed+",0 0,"+ed+" -"+ed+",0 0,-"+ed+"z ",bd+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',bd+=sd.scalable?"":' width="'+ad+'px" height="'+ad+'px"',bd+=' viewBox="0 0 '+ad+" "+ad+'" ',bd+=' preserveAspectRatio="xMinYMin meet"',bd+=od.text||nd.text?' role="img" aria-labelledby="'+Yu([od.id,nd.id].join(" ").trim())+'"':"",bd+=">",bd+=od.text?'<title id="'+Yu(od.id)+'">'+Yu(od.text)+"</title>":"",bd+=nd.text?'<description id="'+Yu(nd.id)+'">'+Yu(nd.text)+"</description>":"",bd+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',bd+='<path d="',_d=0;_d<Bu.getModuleCount();_d+=1)for(yd=_d*ed+td,pd=0;pd<Bu.getModuleCount();pd+=1)Bu.isDark(_d,pd)&&(gd=pd*ed+td,bd+="M"+gd+","+yd+Sd);return bd+='" stroke="transparent" fill="black"/>',bd+="</svg>",bd},Bu.createDataURL=function(ed,td){ed=ed||2,td=typeof td>"u"?ed*4:td;const nd=Bu.getModuleCount()*ed+td*2,od=td,sd=nd-td;return createDataURL(nd,nd,function(ad,pd){if(od<=ad&&ad<sd&&od<=pd&&pd<sd){const gd=Math.floor((ad-od)/ed),_d=Math.floor((pd-od)/ed);return Bu.isDark(_d,gd)?0:1}else return 1})},Bu.createImgTag=function(ed,td,nd){ed=ed||2,td=typeof td>"u"?ed*4:td;const od=Bu.getModuleCount()*ed+td*2;let sd="";return sd+="<img",sd+=' src="',sd+=Bu.createDataURL(ed,td),sd+='"',sd+=' width="',sd+=od,sd+='"',sd+=' height="',sd+=od,sd+='"',nd&&(sd+=' alt="',sd+=Yu(nd),sd+='"'),sd+="/>",sd};const Yu=function(ed){let td="";for(let nd=0;nd<ed.length;nd+=1){const od=ed.charAt(nd);switch(od){case"<":td+="<";break;case">":td+=">";break;case"&":td+="&";break;case'"':td+=""";break;default:td+=od;break}}return td},Xu=function(ed){ed=typeof ed>"u"?2:ed;const nd=Bu.getModuleCount()*1+ed*2,od=ed,sd=nd-ed;let ad,pd,gd,_d,yd;const bd={"██":"█","█ ":"▀"," █":"▄"," ":" "},Sd={"██":"▀","█ ":"▀"," █":" "," ":" "};let Ed="";for(ad=0;ad<nd;ad+=2){for(gd=Math.floor((ad-od)/1),_d=Math.floor((ad+1-od)/1),pd=0;pd<nd;pd+=1)yd="█",od<=pd&&pd<sd&&od<=ad&&ad<sd&&Bu.isDark(gd,Math.floor((pd-od)/1))&&(yd=" "),od<=pd&&pd<sd&&od<=ad+1&&ad+1<sd&&Bu.isDark(_d,Math.floor((pd-od)/1))?yd+=" ":yd+="█",Ed+=ed<1&&ad+1>=sd?Sd[yd]:bd[yd];Ed+=`
|
|
3855
|
+
`).find(Ru=>Ru.trim())??"").trim();return $u.length>PREVIEW_LENGTH?`${$u.slice(0,PREVIEW_LENGTH-1)}…`:$u||"(empty)"}function PreviewList({title:Au,rows:lo}){return jsxRuntimeExports.jsxs(Box,{children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontWeight:"semibold",display:"block",mb:1},children:Au}),lo.length===0?jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted"},children:"Empty so far."}):lo.map(($u,Ru)=>jsxRuntimeExports.jsxs(Box,{display:"flex",gap:2,py:"2px",alignItems:"baseline",children:[jsxRuntimeExports.jsxs(Text$3,{sx:{color:"fg.muted",flexShrink:0,fontFamily:"mono"},children:[Ru," · ",$u.kind]}),jsxRuntimeExports.jsx(Text$3,{sx:{fontFamily:"mono",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$u.text})]},Ru))]})}function useOfferedEditors(){return reactExports.useSyncExternalStore(subscribeEditorChoice,()=>getEditorChoice().options)}function useNotebookRows(Au,lo){const[$u,Ru]=reactExports.useState(0);return reactExports.useEffect(()=>{if(!lo)return;let Iu=!1;const Pu=()=>Ru(Du=>Du+1),Ou=[],Mu=jupyterReact!==null;return loadJupyterReact().then(({notebookStore:Du})=>{if(!Iu)try{const Lu=Du.subscribe?.(Pu);Lu&&Ou.push(Lu);const Bu=Du.getState()?.notebooks?.get(Au)?.model;if(Bu){const ju=[Bu.contentChanged,Bu.cells?.changed];for(const Fu of ju)Fu?.connect&&(Fu.connect(Pu),Ou.push(()=>Fu.disconnect(Pu)))}Mu||Pu()}catch{}}),()=>{Iu=!0;for(const Du of Ou)try{Du()}catch{}}},[lo,Au,$u]),reactExports.useMemo(()=>{if(!lo)return null;const Iu=safeModel(Au);if(!Iu)return null;const Pu=[],Ou=Iu.cells;for(let Mu=0;Mu<Ou.length;Mu+=1){const Du=Ou.get(Mu);Pu.push({kind:Du.type,text:stripped(Du.sharedModel.getSource())})}return Pu},[lo,Au,$u])}function safeModel(Au){try{return jupyterReact?.notebookStore.getState()?.notebooks?.get(Au)?.model??null}catch{return null}}function useDocumentRows(Au,lo){const[$u,Ru]=reactExports.useState(null);return reactExports.useEffect(()=>{if(!lo){Ru(null);return}let Iu=!1,Pu,Ou=!1;return __vitePreload(()=>import("./chunks/PrismCss-CcU1ChRk.js").then(Mu=>Mu.a),[],import.meta.url).then(()=>__vitePreload(()=>import("./chunks/index-cYM4KfdD.js"),[],import.meta.url)).then(({lexicalStore:Mu})=>{if(Iu)return;const Du=()=>{Ou||(Ou=!0,Mu.getState().readAllBlocks(Au,"brief").then(Lu=>{Ou=!1,!(Iu||!Array.isArray(Lu))&&Ru(Lu.map(Bu=>({kind:Bu.block_type??"block",text:stripped(Bu.preview??"")})))}).catch(()=>{Ou=!1,Iu||Ru(null)}))};Du(),Pu=Mu.subscribe(Du)}).catch(()=>{Iu||Ru(null)}),()=>{Iu=!0,Pu?.()}},[lo,Au]),$u}function useEditorPreviews(Au){const lo=useOfferedEditors(),$u=useNotebookRows(Au,lo.includes("notebook")),Ru=useDocumentRows(Au,lo.includes("document"));return reactExports.useMemo(()=>{const Iu={};return $u&&(Iu.notebook={badge:String($u.length),details:jsxRuntimeExports.jsx(PreviewList,{title:"Cells",rows:$u})}),Ru&&(Iu.document={badge:String(Ru.length),details:jsxRuntimeExports.jsx(PreviewList,{title:"Blocks",rows:Ru})}),Iu},[$u,Ru])}const SHELL_PLUGIN_NAME="@datalayer/loop-plugin-shell";function describeEditor(Au,lo){const $u=Au,Ru=lo?.workspace,Iu=Ru?canOpenView($u,Ru):!0;return{id:$u.surfaceId,title:$u.title,icon:$u.icon,order:$u.order,disabled:!Iu,disabledReason:Iu?void 0:Ru&&$u.unavailableReason?.(Ru)||"Not available right now"}}function EditorSelectorComponent(Au){const lo=Au.workspace,$u=useEditorPreviews(lo?.surfaceId??""),Ru=(Iu,Pu)=>{const Ou=describeEditor(Iu,Pu),Mu=$u[Ou.id];return Mu?{...Ou,badge:Mu.badge,details:Mu.details}:Ou};return jsxRuntimeExports.jsx(ViewSelector,{point:LoopEditorView,describe:Ru,context:Au,noneLabel:"Chat",ariaLabel:"Editor"})}const ShellPlugin={name:SHELL_PLUGIN_NAME,displayName:"Loop shell",description:"The Loop workspace’s extension points, and the editor choice.",octicon:"columns",emoji:"📑",config:{defaultEditor:NONE_EDITOR,showSelector:!0},dependencies:[configurePlugin(ShellPlugin$1,{point:LoopEditorView,describe:describeEditor,showSelector:!1,announce:Au=>requestSurface(Au),commandId:"loop.shell.cycleEditor",commandName:"Switch the editor",commandDescription:"Cycle through the editors beside the conversation, and none",keybinding:""})],contributionPoints:[LoopViewType,LoopEditorView],contributes:[contribution(LoopCommand,{name:"editor",aliases:["editors"],description:"Switch the editor beside the conversation",group:"Open",keybinding:"Mod+Alt+E",args:[{name:"editor",description:"Which editor: none, or a surface id. Omit to cycle.",required:!1,choices:()=>[NONE_EDITOR,...getEditorChoice().options]}],run:async({argv:Au})=>{const lo=Au.trim(),$u=lo===""?nextEditor():lo,Ru=[NONE_EDITOR,...getEditorChoice().options];if(!Ru.includes($u))throw new Error(`No editor called '${$u}'. There is: ${Ru.join(", ")}.`);if(!chooseEditor($u))throw new Error("No chat is on screen to host the editor.")}},{id:"editor"})],build:({config:Au})=>(seedEditorChoice(Au.defaultEditor||NONE_EDITOR),{components:Au.showSelector?[{id:"editor-selector",slot:LoopSlots.header,Component:EditorSelectorComponent}]:[]})};function NewChatAction({workspace:Au}){return Au?jsxRuntimeExports.jsx(IconButton,{icon:PlusIcon,"aria-label":"New conversation",title:"New conversation",variant:"invisible",size:"small",onClick:()=>{Au.submit("/new")}}):null}const PROMPT_PLUGIN_NAME="@datalayer/loop-plugin-prompt",PromptPlugin={name:PROMPT_PLUGIN_NAME,displayName:"Prompt",description:"Prompt commands: focus the composer, start over, and the +.",octicon:"paper-airplane",emoji:"🪶",contributes:[contribution(LoopCommand,{name:"prompt",description:"Focus the prompt",group:"Session",keybinding:"Mod+Alt+P",run:async()=>{if(!focusPrompt())throw new Error("No prompt is on screen to focus.")}},{id:"prompt"}),contribution(LoopCommand,{name:"new",aliases:["reset"],description:"Start the conversation over",group:"Session",keybinding:"Mod+Alt+R",run:async({workspace:Au})=>{const lo=Au.viewControls.newChat;if(!lo)throw new Error("No conversation is on screen to start over.");lo()}},{id:"new"})],build:()=>({components:[{id:"new-chat",slot:LoopSlots.promptAction,Component:NewChatAction}]})};function AgentspecPicker({workspace:Au}){const[lo,$u]=reactExports.useState([]),[Ru,Iu]=reactExports.useState(!1),[Pu,Ou]=reactExports.useState(Au.agentId),Mu=Au.sandbox.target,Du=Au.sandbox.state;reactExports.useEffect(()=>{let Fu=!1;return fetch(`${Au.serverUrl}/api/v1/agents`).then(zu=>zu.ok?zu.json():{agents:[]}).then(zu=>{Fu||$u(zu.agents??[])}).catch(()=>{}),()=>{Fu=!0}},[Au.serverUrl,Mu,Du]),reactExports.useEffect(()=>{Ou(Au.agentId)},[Au.agentId]);const Lu=reactExports.useCallback(async Fu=>{Iu(!0);try{(await fetch(`${Au.serverUrl}/api/v1/loop/sessions/${encodeURIComponent(Au.conversationId||Au.agentId||"session")}/agent`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({agent_id:Fu})})).ok&&(Ou(Fu),Au.setAgentId(Fu))}finally{Iu(!1)}},[Au.agentId,Au.conversationId,Au.serverUrl,Au.setAgentId]),Bu=lo.find(Fu=>Fu.id===Pu),ju=Bu?.name||getAgentspecs(Pu)?.name||Pu||"Agent";return lo.length===0?null:jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:1,children:[Ru?jsxRuntimeExports.jsx(StyledSpinner,{size:"small"}):null,jsxRuntimeExports.jsxs(ActionMenu,{children:[jsxRuntimeExports.jsxs(ActionMenu.Button,{variant:"invisible",size:"small",children:[Bu?.emoji?`${Bu.emoji} `:"",ju]}),jsxRuntimeExports.jsx(ActionMenu.Overlay,{width:"medium",children:jsxRuntimeExports.jsx(ActionList,{selectionVariant:"single",children:lo.map(Fu=>jsxRuntimeExports.jsxs(ActionList.Item,{selected:Fu.id===Pu,onSelect:()=>{Lu(Fu.id)},children:[Fu.emoji?`${Fu.emoji} `:"",Fu.name||Fu.id,Fu.description?jsxRuntimeExports.jsx(ActionList.Description,{variant:"block",children:Fu.description}):null]},Fu.id))})})]})]})}const AGENTSPECS_PLUGIN_NAME="@datalayer/loop-plugin-agentspecs",AgentspecsPlugin={name:AGENTSPECS_PLUGIN_NAME,displayName:"Agentspecs",description:"Pick the agentspec this session runs.",octicon:"people",emoji:"🤖",build(){return{components:[{slot:LoopSlots.header,id:"agent-picker",Component:AgentspecPicker}]}},contributes:[contribution(LoopCommand,{name:"agents",aliases:["agent"],description:"Switch the agent this session is using",group:"Agents",keybinding:"Mod+Alt+A",args:[{name:"agent-id",description:"Agent to switch to"}],run:async({workspace:Au,argv:lo})=>{const $u=lo.trim();if(!$u)return{content:"Pick an agent from the header, or /agents <id>."};const Ru=await fetch(`${Au.serverUrl}/api/v1/loop/sessions/${encodeURIComponent(Au.conversationId||Au.agentId||"session")}/agent`,{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({agent_id:$u})});if(!Ru.ok)return{content:`Unknown agent: ${$u}`};const Iu=await Ru.json();return{content:`Now using ${Iu.name??Iu.agent_id}.`}}},{id:"agents"})]},CHAT_HEADER_PLUGIN_NAME="@datalayer/loop-plugin-chat-header",LazyHeaderView=reactExports.lazy(()=>__vitePreload(()=>import("./chunks/HeaderView-DVGhaRai.js"),[],import.meta.url));function HeaderView(Au){return jsxRuntimeExports.jsx(reactExports.Suspense,{fallback:null,children:jsxRuntimeExports.jsx(LazyHeaderView,{...Au})})}const ChatHeaderPlugin={name:CHAT_HEADER_PLUGIN_NAME,displayName:"Chat Header",description:"The conversation’s title bar: agent, kernel, actions.",octicon:"rows",emoji:"🏷️",contributes:[contribution(LoopChatHeader,{id:"chat-header",Component:HeaderView},{id:"chat-header"})]};function readA2uiToolResult(Au,lo){if(!Au)return null;let $u=Au;if(typeof Au=="string")try{$u=JSON.parse(Au)}catch{return null}if(typeof $u!="object"||$u===null||!Array.isArray($u.messages))return null;const Ru=$u,Iu=(Ru.messages??[]).map(Pu=>{const Ou=Pu;return Ou.createSurface&&Ou.createSurface.catalogId!==lo?{...Ou,createSurface:{...Ou.createSurface,catalogId:lo}}:Pu});return{...Ru,messages:Iu}}function isEmptyA2uiValue(Au){return Au==null?!0:typeof Au=="string"?Au.trim()==="":Array.isArray(Au)?Au.length===0:typeof Au=="boolean"?Au===!1:!1}const EMAIL_PATTERN=/^[^\s@]+@[^\s@]+\.[^\s@]+$/;function validateA2uiField(Au,lo){if(isEmptyA2uiValue(lo))return Au.required?`${Au.label} is required.`:null;if(Au.format==="email"&&typeof lo=="string"&&!EMAIL_PATTERN.test(lo.trim()))return`${Au.label} must be a valid email address.`;if(Au.pattern&&typeof lo=="string"){let $u;try{$u=new RegExp(Au.pattern).test(lo.trim())}catch{$u=!0}if(!$u)return`${Au.label} is not in the expected format.`}if(Au.minLength!==void 0&&typeof lo=="string"&&lo.trim().length<Au.minLength)return`${Au.label} must be at least ${Au.minLength} characters.`;if(Au.type==="slider"&&typeof lo=="number"){if(Au.min!==void 0&&lo<Au.min)return`${Au.label} must be at least ${Au.min}.`;if(Au.max!==void 0&&lo>Au.max)return`${Au.label} must be at most ${Au.max}.`}return null}function validateA2uiSubmission(Au,lo){return Au.map($u=>validateA2uiField($u,lo[$u.id])).filter($u=>$u!==null)}const ANSWER_DISPLAY_TYPE="application/vnd.datalayer.loop.answer+json";function answerSurface(Au,lo){return Au.type!==ANSWER_DISPLAY_TYPE?null:readA2uiToolResult(Au.data?.surface,lo)}function answerPress(Au,lo){const $u=lo.name.trim(),Ru=(Au.actions??[]).find(Iu=>Iu.name===$u);return Ru?{message:$u,forwardedProps:{loop:{action:{name:$u,display_id:Au.id,token:Ru.token,payload:{...lo.context}}}}}:{refused:`“${$u||"This button"}” was not offered here.`}}function AnswerShowsView({display:Au,send:lo}){const $u=reactExports.useMemo(()=>answerSurface(Au,SURFACE_CATALOG_ID),[Au]),Ru=useOwnCatalog(),[Iu,Pu]=reactExports.useState(null);if(!$u?.messages||$u.messages.length===0)return jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted"},children:Au.text});const Ou=Mu=>{const Du=answerPress(Au,Mu);if("refused"in Du){Pu(Du.refused);return}Pu(lo(Du.message,Du.forwardedProps)?null:"The chat is not ready to take it yet.")};return jsxRuntimeExports.jsx(InlineSurface,{messages:$u.messages,onAction:Ou,validationError:Iu,catalog:Ru},JSON.stringify(Au))}function SurfaceToolResult({context:Au,send:lo,onRendered:$u,onSubmitted:Ru}){const Iu=reactExports.useMemo(()=>Au.status==="complete"?readA2uiToolResult(Au.result,SURFACE_CATALOG_ID):null,[Au.status,Au.result]),Pu=Iu?.title??"the form",[Ou,Mu]=reactExports.useState(null),Du=useOwnCatalog();reactExports.useEffect(()=>{Iu?.messages&&Iu.messages.length>0&&$u?.({toolCallId:Au.toolCallId,surfaceId:Iu.surfaceId,title:Pu,messages:Iu.messages,result:Iu})},[Iu,Au.toolCallId]);const Lu=reactExports.useCallback(Bu=>{if(Bu.name!=="submit_a2ui_form")return;const ju=Bu.context??{},Fu=validateA2uiSubmission(Iu?.fieldRules??[],ju);if(Fu.length>0){Mu(Fu.join(" "));return}Mu(null),Ru?.({surfaceId:Bu.surfaceId,title:Pu,values:ju}),lo(encodeFormSubmission({title:Pu,surfaceId:Bu.surfaceId,values:ju}))||Mu("The chat is not ready to take the submission yet.")},[Iu,Pu,lo,Ru]);return!Iu?.messages||Iu.messages.length===0?jsxRuntimeExports.jsxs(Box,{border:"1px solid",borderColor:"border.default",borderRadius:2,px:3,py:2,bg:"canvas.default",display:"flex",alignItems:"center",gap:2,children:[jsxRuntimeExports.jsx(StyledSpinner,{size:"small"}),jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:1,color:"fg.muted"},children:"Rendering A2UI surface..."})]}):jsxRuntimeExports.jsxs(Box,{display:"flex",flexDirection:"column",gap:2,children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontWeight:"bold"},children:Pu}),jsxRuntimeExports.jsx(InlineSurface,{messages:Iu.messages,onAction:Lu,validationError:Ou,catalog:Du})]})}const A2UI_SURFACE_PLUGIN_NAME="@datalayer/loop-plugin-a2ui-surface",A2UI_SURFACE_RENDERER="a2ui-surface",A2UI_SURFACE_TYPE="application/vnd.datalayer.a2ui.surface+json";function surfaceToolNames(){const Au=new Set;for(const lo of Object.values(AGENTSPECS))for(const $u of lo.frontendRenderTools??[])$u.renderer===A2UI_SURFACE_RENDERER&&Au.add($u.tool);return Au}let counter=0;function createA2uiSurfacePlugin(Au={}){const lo=`a2ui-surface-${counter+=1}`;let $u;const Ru=(Du,Lu)=>$u?!$u(Du,Lu):!1;function Iu({workspace:Du}){const Lu=Du?.viewControls.send;return reactExports.useEffect(()=>($u=Lu,()=>{$u===Lu&&($u=void 0)}),[Lu]),null}function Pu({context:Du}){return Du?Du.status==="error"?jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:Du.defaultUI}):jsxRuntimeExports.jsx(SurfaceToolResult,{context:Du,send:Ru,onRendered:Au.onRendered,onSubmitted:Au.onSubmitted},Du.toolCallId):null}function Ou({display:Du}){return jsxRuntimeExports.jsx(AnswerShowsView,{display:Du,send:Ru})}return{name:counter===1?A2UI_SURFACE_PLUGIN_NAME:`${A2UI_SURFACE_PLUGIN_NAME}-${lo}`,displayName:"A2UI surfaces",description:"Generated surfaces drawn in the transcript, and submitted back to the agent.",octicon:"browser",emoji:"🪟",contributes:[contribution(Renderers,defineRenderer({type:A2UI_SURFACE_TYPE,component:Pu,rank:Au.onRendered||Au.onSubmitted?1:0}),{id:lo}),contribution(Renderers,defineRenderer({type:ANSWER_DISPLAY_TYPE,component:Ou}),{id:`${lo}:answer`}),...[...surfaceToolNames()].map(Du=>contribution(ToolBindings,{tool:Du,type:A2UI_SURFACE_TYPE},{id:`${lo}:${Du}`}))],build(){return{components:[{slot:LoopSlots.chatHeader,id:lo,Component:Iu}]}}}}const A2uiSurfacePlugin=createA2uiSurfacePlugin(),qrcode=function(Au,lo){let Iu=Au;const Pu=QRErrorCorrectionLevel[lo];let Ou=null,Mu=0,Du=null;const Lu=[],Bu={},ju=function(ed,td){Mu=Iu*4+17,Ou=(function(nd){const od=new Array(nd);for(let sd=0;sd<nd;sd+=1){od[sd]=new Array(nd);for(let ad=0;ad<nd;ad+=1)od[sd][ad]=null}return od})(Mu),Fu(0,0),Fu(Mu-7,0),Fu(0,Mu-7),Hu(),Uu(),Gu(ed,td),Iu>=7&&Vu(ed),Du==null&&(Du=Ju(Iu,Pu,Lu)),Wu(Du,td)},Fu=function(ed,td){for(let nd=-1;nd<=7;nd+=1)if(!(ed+nd<=-1||Mu<=ed+nd))for(let od=-1;od<=7;od+=1)td+od<=-1||Mu<=td+od||(0<=nd&&nd<=6&&(od==0||od==6)||0<=od&&od<=6&&(nd==0||nd==6)||2<=nd&&nd<=4&&2<=od&&od<=4?Ou[ed+nd][td+od]=!0:Ou[ed+nd][td+od]=!1)},zu=function(){let ed=0,td=0;for(let nd=0;nd<8;nd+=1){ju(!0,nd);const od=QRUtil.getLostPoint(Bu);(nd==0||ed>od)&&(ed=od,td=nd)}return td},Uu=function(){for(let ed=8;ed<Mu-8;ed+=1)Ou[ed][6]==null&&(Ou[ed][6]=ed%2==0);for(let ed=8;ed<Mu-8;ed+=1)Ou[6][ed]==null&&(Ou[6][ed]=ed%2==0)},Hu=function(){const ed=QRUtil.getPatternPosition(Iu);for(let td=0;td<ed.length;td+=1)for(let nd=0;nd<ed.length;nd+=1){const od=ed[td],sd=ed[nd];if(Ou[od][sd]==null)for(let ad=-2;ad<=2;ad+=1)for(let pd=-2;pd<=2;pd+=1)ad==-2||ad==2||pd==-2||pd==2||ad==0&&pd==0?Ou[od+ad][sd+pd]=!0:Ou[od+ad][sd+pd]=!1}},Vu=function(ed){const td=QRUtil.getBCHTypeNumber(Iu);for(let nd=0;nd<18;nd+=1){const od=!ed&&(td>>nd&1)==1;Ou[Math.floor(nd/3)][nd%3+Mu-8-3]=od}for(let nd=0;nd<18;nd+=1){const od=!ed&&(td>>nd&1)==1;Ou[nd%3+Mu-8-3][Math.floor(nd/3)]=od}},Gu=function(ed,td){const nd=Pu<<3|td,od=QRUtil.getBCHTypeInfo(nd);for(let sd=0;sd<15;sd+=1){const ad=!ed&&(od>>sd&1)==1;sd<6?Ou[sd][8]=ad:sd<8?Ou[sd+1][8]=ad:Ou[Mu-15+sd][8]=ad}for(let sd=0;sd<15;sd+=1){const ad=!ed&&(od>>sd&1)==1;sd<8?Ou[8][Mu-sd-1]=ad:sd<9?Ou[8][15-sd-1+1]=ad:Ou[8][15-sd-1]=ad}Ou[Mu-8][8]=!ed},Wu=function(ed,td){let nd=-1,od=Mu-1,sd=7,ad=0;const pd=QRUtil.getMaskFunction(td);for(let gd=Mu-1;gd>0;gd-=2)for(gd==6&&(gd-=1);;){for(let _d=0;_d<2;_d+=1)if(Ou[od][gd-_d]==null){let yd=!1;ad<ed.length&&(yd=(ed[ad]>>>sd&1)==1),pd(od,gd-_d)&&(yd=!yd),Ou[od][gd-_d]=yd,sd-=1,sd==-1&&(ad+=1,sd=7)}if(od+=nd,od<0||Mu<=od){od-=nd,nd=-nd;break}}},Ku=function(ed,td){let nd=0,od=0,sd=0;const ad=new Array(td.length),pd=new Array(td.length);for(let bd=0;bd<td.length;bd+=1){const Sd=td[bd].dataCount,Ed=td[bd].totalCount-Sd;od=Math.max(od,Sd),sd=Math.max(sd,Ed),ad[bd]=new Array(Sd);for(let ld=0;ld<ad[bd].length;ld+=1)ad[bd][ld]=255&ed.getBuffer()[ld+nd];nd+=Sd;const cd=QRUtil.getErrorCorrectPolynomial(Ed),md=qrPolynomial(ad[bd],cd.getLength()-1).mod(cd);pd[bd]=new Array(cd.getLength()-1);for(let ld=0;ld<pd[bd].length;ld+=1){const hd=ld+md.getLength()-pd[bd].length;pd[bd][ld]=hd>=0?md.getAt(hd):0}}let gd=0;for(let bd=0;bd<td.length;bd+=1)gd+=td[bd].totalCount;const _d=new Array(gd);let yd=0;for(let bd=0;bd<od;bd+=1)for(let Sd=0;Sd<td.length;Sd+=1)bd<ad[Sd].length&&(_d[yd]=ad[Sd][bd],yd+=1);for(let bd=0;bd<sd;bd+=1)for(let Sd=0;Sd<td.length;Sd+=1)bd<pd[Sd].length&&(_d[yd]=pd[Sd][bd],yd+=1);return _d},Ju=function(ed,td,nd){const od=QRRSBlock.getRSBlocks(ed,td),sd=qrBitBuffer();for(let pd=0;pd<nd.length;pd+=1){const gd=nd[pd];sd.put(gd.getMode(),4),sd.put(gd.getLength(),QRUtil.getLengthInBits(gd.getMode(),ed)),gd.write(sd)}let ad=0;for(let pd=0;pd<od.length;pd+=1)ad+=od[pd].dataCount;if(sd.getLengthInBits()>ad*8)throw"code length overflow. ("+sd.getLengthInBits()+">"+ad*8+")";for(sd.getLengthInBits()+4<=ad*8&&sd.put(0,4);sd.getLengthInBits()%8!=0;)sd.putBit(!1);for(;!(sd.getLengthInBits()>=ad*8||(sd.put(236,8),sd.getLengthInBits()>=ad*8));)sd.put(17,8);return Ku(sd,od)};Bu.addData=function(ed,td){td=td||"Byte";let nd=null;switch(td){case"Numeric":nd=qrNumber(ed);break;case"Alphanumeric":nd=qrAlphaNum(ed);break;case"Byte":nd=qr8BitByte(ed);break;case"Kanji":nd=qrKanji(ed);break;default:throw"mode:"+td}Lu.push(nd),Du=null},Bu.isDark=function(ed,td){if(ed<0||Mu<=ed||td<0||Mu<=td)throw ed+","+td;return Ou[ed][td]},Bu.getModuleCount=function(){return Mu},Bu.make=function(){if(Iu<1){let ed=1;for(;ed<40;ed++){const td=QRRSBlock.getRSBlocks(ed,Pu),nd=qrBitBuffer();for(let sd=0;sd<Lu.length;sd++){const ad=Lu[sd];nd.put(ad.getMode(),4),nd.put(ad.getLength(),QRUtil.getLengthInBits(ad.getMode(),ed)),ad.write(nd)}let od=0;for(let sd=0;sd<td.length;sd++)od+=td[sd].dataCount;if(nd.getLengthInBits()<=od*8)break}Iu=ed}ju(!1,zu())},Bu.createTableTag=function(ed,td){ed=ed||2,td=typeof td>"u"?ed*4:td;let nd="";nd+='<table style="',nd+=" border-width: 0px; border-style: none;",nd+=" border-collapse: collapse;",nd+=" padding: 0px; margin: "+td+"px;",nd+='">',nd+="<tbody>";for(let od=0;od<Bu.getModuleCount();od+=1){nd+="<tr>";for(let sd=0;sd<Bu.getModuleCount();sd+=1)nd+='<td style="',nd+=" border-width: 0px; border-style: none;",nd+=" border-collapse: collapse;",nd+=" padding: 0px; margin: 0px;",nd+=" width: "+ed+"px;",nd+=" height: "+ed+"px;",nd+=" background-color: ",nd+=Bu.isDark(od,sd)?"#000000":"#ffffff",nd+=";",nd+='"/>';nd+="</tr>"}return nd+="</tbody>",nd+="</table>",nd},Bu.createSvgTag=function(ed,td,nd,od){let sd={};typeof arguments[0]=="object"&&(sd=arguments[0],ed=sd.cellSize,td=sd.margin,nd=sd.alt,od=sd.title),ed=ed||2,td=typeof td>"u"?ed*4:td,nd=typeof nd=="string"?{text:nd}:nd||{},nd.text=nd.text||null,nd.id=nd.text?nd.id||"qrcode-description":null,od=typeof od=="string"?{text:od}:od||{},od.text=od.text||null,od.id=od.text?od.id||"qrcode-title":null;const ad=Bu.getModuleCount()*ed+td*2;let pd,gd,_d,yd,bd="",Sd;for(Sd="l"+ed+",0 0,"+ed+" -"+ed+",0 0,-"+ed+"z ",bd+='<svg version="1.1" xmlns="http://www.w3.org/2000/svg"',bd+=sd.scalable?"":' width="'+ad+'px" height="'+ad+'px"',bd+=' viewBox="0 0 '+ad+" "+ad+'" ',bd+=' preserveAspectRatio="xMinYMin meet"',bd+=od.text||nd.text?' role="img" aria-labelledby="'+Yu([od.id,nd.id].join(" ").trim())+'"':"",bd+=">",bd+=od.text?'<title id="'+Yu(od.id)+'">'+Yu(od.text)+"</title>":"",bd+=nd.text?'<description id="'+Yu(nd.id)+'">'+Yu(nd.text)+"</description>":"",bd+='<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>',bd+='<path d="',_d=0;_d<Bu.getModuleCount();_d+=1)for(yd=_d*ed+td,pd=0;pd<Bu.getModuleCount();pd+=1)Bu.isDark(_d,pd)&&(gd=pd*ed+td,bd+="M"+gd+","+yd+Sd);return bd+='" stroke="transparent" fill="black"/>',bd+="</svg>",bd},Bu.createDataURL=function(ed,td){ed=ed||2,td=typeof td>"u"?ed*4:td;const nd=Bu.getModuleCount()*ed+td*2,od=td,sd=nd-td;return createDataURL(nd,nd,function(ad,pd){if(od<=ad&&ad<sd&&od<=pd&&pd<sd){const gd=Math.floor((ad-od)/ed),_d=Math.floor((pd-od)/ed);return Bu.isDark(_d,gd)?0:1}else return 1})},Bu.createImgTag=function(ed,td,nd){ed=ed||2,td=typeof td>"u"?ed*4:td;const od=Bu.getModuleCount()*ed+td*2;let sd="";return sd+="<img",sd+=' src="',sd+=Bu.createDataURL(ed,td),sd+='"',sd+=' width="',sd+=od,sd+='"',sd+=' height="',sd+=od,sd+='"',nd&&(sd+=' alt="',sd+=Yu(nd),sd+='"'),sd+="/>",sd};const Yu=function(ed){let td="";for(let nd=0;nd<ed.length;nd+=1){const od=ed.charAt(nd);switch(od){case"<":td+="<";break;case">":td+=">";break;case"&":td+="&";break;case'"':td+=""";break;default:td+=od;break}}return td},Xu=function(ed){ed=typeof ed>"u"?2:ed;const nd=Bu.getModuleCount()*1+ed*2,od=ed,sd=nd-ed;let ad,pd,gd,_d,yd;const bd={"██":"█","█ ":"▀"," █":"▄"," ":" "},Sd={"██":"▀","█ ":"▀"," █":" "," ":" "};let Ed="";for(ad=0;ad<nd;ad+=2){for(gd=Math.floor((ad-od)/1),_d=Math.floor((ad+1-od)/1),pd=0;pd<nd;pd+=1)yd="█",od<=pd&&pd<sd&&od<=ad&&ad<sd&&Bu.isDark(gd,Math.floor((pd-od)/1))&&(yd=" "),od<=pd&&pd<sd&&od<=ad+1&&ad+1<sd&&Bu.isDark(_d,Math.floor((pd-od)/1))?yd+=" ":yd+="█",Ed+=ed<1&&ad+1>=sd?Sd[yd]:bd[yd];Ed+=`
|
|
3856
3856
|
`}return nd%2&&ed>0?Ed.substring(0,Ed.length-nd-1)+Array(nd+1).join("▀"):Ed.substring(0,Ed.length-1)};return Bu.createASCII=function(ed,td){if(ed=ed||1,ed<2)return Xu(td);ed-=1,td=typeof td>"u"?ed*2:td;const nd=Bu.getModuleCount()*ed+td*2,od=td,sd=nd-td;let ad,pd,gd,_d;const yd=Array(ed+1).join("██"),bd=Array(ed+1).join(" ");let Sd="",Ed="";for(ad=0;ad<nd;ad+=1){for(gd=Math.floor((ad-od)/ed),Ed="",pd=0;pd<nd;pd+=1)_d=1,od<=pd&&pd<sd&&od<=ad&&ad<sd&&Bu.isDark(gd,Math.floor((pd-od)/ed))&&(_d=0),Ed+=_d?yd:bd;for(gd=0;gd<ed;gd+=1)Sd+=Ed+`
|
|
3857
3857
|
`}return Sd.substring(0,Sd.length-1)},Bu.renderTo2dContext=function(ed,td){td=td||2;const nd=Bu.getModuleCount();for(let od=0;od<nd;od++)for(let sd=0;sd<nd;sd++)ed.fillStyle=Bu.isDark(od,sd)?"black":"white",ed.fillRect(sd*td,od*td,td,td)},Bu};qrcode.stringToBytes=function(Au){const lo=[];for(let $u=0;$u<Au.length;$u+=1){const Ru=Au.charCodeAt($u);lo.push(Ru&255)}return lo};qrcode.createStringToBytes=function(Au,lo){const $u=(function(){const Iu=base64DecodeInputStream(Au),Pu=function(){const Du=Iu.read();if(Du==-1)throw"eof";return Du};let Ou=0;const Mu={};for(;;){const Du=Iu.read();if(Du==-1)break;const Lu=Pu(),Bu=Pu(),ju=Pu(),Fu=String.fromCharCode(Du<<8|Lu),zu=Bu<<8|ju;Mu[Fu]=zu,Ou+=1}if(Ou!=lo)throw Ou+" != "+lo;return Mu})(),Ru=63;return function(Iu){const Pu=[];for(let Ou=0;Ou<Iu.length;Ou+=1){const Mu=Iu.charCodeAt(Ou);if(Mu<128)Pu.push(Mu);else{const Du=$u[Iu.charAt(Ou)];typeof Du=="number"?(Du&255)==Du?Pu.push(Du):(Pu.push(Du>>>8),Pu.push(Du&255)):Pu.push(Ru)}}return Pu}};const QRMode={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},QRErrorCorrectionLevel={L:1,M:0,Q:3,H:2},QRMaskPattern={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},QRUtil=(function(){const Au=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],lo=1335,$u=7973,Ru=21522,Iu={},Pu=function(Ou){let Mu=0;for(;Ou!=0;)Mu+=1,Ou>>>=1;return Mu};return Iu.getBCHTypeInfo=function(Ou){let Mu=Ou<<10;for(;Pu(Mu)-Pu(lo)>=0;)Mu^=lo<<Pu(Mu)-Pu(lo);return(Ou<<10|Mu)^Ru},Iu.getBCHTypeNumber=function(Ou){let Mu=Ou<<12;for(;Pu(Mu)-Pu($u)>=0;)Mu^=$u<<Pu(Mu)-Pu($u);return Ou<<12|Mu},Iu.getPatternPosition=function(Ou){return Au[Ou-1]},Iu.getMaskFunction=function(Ou){switch(Ou){case QRMaskPattern.PATTERN000:return function(Mu,Du){return(Mu+Du)%2==0};case QRMaskPattern.PATTERN001:return function(Mu,Du){return Mu%2==0};case QRMaskPattern.PATTERN010:return function(Mu,Du){return Du%3==0};case QRMaskPattern.PATTERN011:return function(Mu,Du){return(Mu+Du)%3==0};case QRMaskPattern.PATTERN100:return function(Mu,Du){return(Math.floor(Mu/2)+Math.floor(Du/3))%2==0};case QRMaskPattern.PATTERN101:return function(Mu,Du){return Mu*Du%2+Mu*Du%3==0};case QRMaskPattern.PATTERN110:return function(Mu,Du){return(Mu*Du%2+Mu*Du%3)%2==0};case QRMaskPattern.PATTERN111:return function(Mu,Du){return(Mu*Du%3+(Mu+Du)%2)%2==0};default:throw"bad maskPattern:"+Ou}},Iu.getErrorCorrectPolynomial=function(Ou){let Mu=qrPolynomial([1],0);for(let Du=0;Du<Ou;Du+=1)Mu=Mu.multiply(qrPolynomial([1,QRMath.gexp(Du)],0));return Mu},Iu.getLengthInBits=function(Ou,Mu){if(1<=Mu&&Mu<10)switch(Ou){case QRMode.MODE_NUMBER:return 10;case QRMode.MODE_ALPHA_NUM:return 9;case QRMode.MODE_8BIT_BYTE:return 8;case QRMode.MODE_KANJI:return 8;default:throw"mode:"+Ou}else if(Mu<27)switch(Ou){case QRMode.MODE_NUMBER:return 12;case QRMode.MODE_ALPHA_NUM:return 11;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 10;default:throw"mode:"+Ou}else if(Mu<41)switch(Ou){case QRMode.MODE_NUMBER:return 14;case QRMode.MODE_ALPHA_NUM:return 13;case QRMode.MODE_8BIT_BYTE:return 16;case QRMode.MODE_KANJI:return 12;default:throw"mode:"+Ou}else throw"type:"+Mu},Iu.getLostPoint=function(Ou){const Mu=Ou.getModuleCount();let Du=0;for(let ju=0;ju<Mu;ju+=1)for(let Fu=0;Fu<Mu;Fu+=1){let zu=0;const Uu=Ou.isDark(ju,Fu);for(let Hu=-1;Hu<=1;Hu+=1)if(!(ju+Hu<0||Mu<=ju+Hu))for(let Vu=-1;Vu<=1;Vu+=1)Fu+Vu<0||Mu<=Fu+Vu||Hu==0&&Vu==0||Uu==Ou.isDark(ju+Hu,Fu+Vu)&&(zu+=1);zu>5&&(Du+=3+zu-5)}for(let ju=0;ju<Mu-1;ju+=1)for(let Fu=0;Fu<Mu-1;Fu+=1){let zu=0;Ou.isDark(ju,Fu)&&(zu+=1),Ou.isDark(ju+1,Fu)&&(zu+=1),Ou.isDark(ju,Fu+1)&&(zu+=1),Ou.isDark(ju+1,Fu+1)&&(zu+=1),(zu==0||zu==4)&&(Du+=3)}for(let ju=0;ju<Mu;ju+=1)for(let Fu=0;Fu<Mu-6;Fu+=1)Ou.isDark(ju,Fu)&&!Ou.isDark(ju,Fu+1)&&Ou.isDark(ju,Fu+2)&&Ou.isDark(ju,Fu+3)&&Ou.isDark(ju,Fu+4)&&!Ou.isDark(ju,Fu+5)&&Ou.isDark(ju,Fu+6)&&(Du+=40);for(let ju=0;ju<Mu;ju+=1)for(let Fu=0;Fu<Mu-6;Fu+=1)Ou.isDark(Fu,ju)&&!Ou.isDark(Fu+1,ju)&&Ou.isDark(Fu+2,ju)&&Ou.isDark(Fu+3,ju)&&Ou.isDark(Fu+4,ju)&&!Ou.isDark(Fu+5,ju)&&Ou.isDark(Fu+6,ju)&&(Du+=40);let Lu=0;for(let ju=0;ju<Mu;ju+=1)for(let Fu=0;Fu<Mu;Fu+=1)Ou.isDark(Fu,ju)&&(Lu+=1);const Bu=Math.abs(100*Lu/Mu/Mu-50)/5;return Du+=Bu*10,Du},Iu})(),QRMath=(function(){const Au=new Array(256),lo=new Array(256);for(let Ru=0;Ru<8;Ru+=1)Au[Ru]=1<<Ru;for(let Ru=8;Ru<256;Ru+=1)Au[Ru]=Au[Ru-4]^Au[Ru-5]^Au[Ru-6]^Au[Ru-8];for(let Ru=0;Ru<255;Ru+=1)lo[Au[Ru]]=Ru;const $u={};return $u.glog=function(Ru){if(Ru<1)throw"glog("+Ru+")";return lo[Ru]},$u.gexp=function(Ru){for(;Ru<0;)Ru+=255;for(;Ru>=256;)Ru-=255;return Au[Ru]},$u})(),qrPolynomial=function(Au,lo){if(typeof Au.length>"u")throw Au.length+"/"+lo;const $u=(function(){let Iu=0;for(;Iu<Au.length&&Au[Iu]==0;)Iu+=1;const Pu=new Array(Au.length-Iu+lo);for(let Ou=0;Ou<Au.length-Iu;Ou+=1)Pu[Ou]=Au[Ou+Iu];return Pu})(),Ru={};return Ru.getAt=function(Iu){return $u[Iu]},Ru.getLength=function(){return $u.length},Ru.multiply=function(Iu){const Pu=new Array(Ru.getLength()+Iu.getLength()-1);for(let Ou=0;Ou<Ru.getLength();Ou+=1)for(let Mu=0;Mu<Iu.getLength();Mu+=1)Pu[Ou+Mu]^=QRMath.gexp(QRMath.glog(Ru.getAt(Ou))+QRMath.glog(Iu.getAt(Mu)));return qrPolynomial(Pu,0)},Ru.mod=function(Iu){if(Ru.getLength()-Iu.getLength()<0)return Ru;const Pu=QRMath.glog(Ru.getAt(0))-QRMath.glog(Iu.getAt(0)),Ou=new Array(Ru.getLength());for(let Mu=0;Mu<Ru.getLength();Mu+=1)Ou[Mu]=Ru.getAt(Mu);for(let Mu=0;Mu<Iu.getLength();Mu+=1)Ou[Mu]^=QRMath.gexp(QRMath.glog(Iu.getAt(Mu))+Pu);return qrPolynomial(Ou,0).mod(Iu)},Ru},QRRSBlock=(function(){const Au=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12,7,37,13],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]],lo=function(Iu,Pu){const Ou={};return Ou.totalCount=Iu,Ou.dataCount=Pu,Ou},$u={},Ru=function(Iu,Pu){switch(Pu){case QRErrorCorrectionLevel.L:return Au[(Iu-1)*4+0];case QRErrorCorrectionLevel.M:return Au[(Iu-1)*4+1];case QRErrorCorrectionLevel.Q:return Au[(Iu-1)*4+2];case QRErrorCorrectionLevel.H:return Au[(Iu-1)*4+3];default:return}};return $u.getRSBlocks=function(Iu,Pu){const Ou=Ru(Iu,Pu);if(typeof Ou>"u")throw"bad rs block @ typeNumber:"+Iu+"/errorCorrectionLevel:"+Pu;const Mu=Ou.length/3,Du=[];for(let Lu=0;Lu<Mu;Lu+=1){const Bu=Ou[Lu*3+0],ju=Ou[Lu*3+1],Fu=Ou[Lu*3+2];for(let zu=0;zu<Bu;zu+=1)Du.push(lo(ju,Fu))}return Du},$u})(),qrBitBuffer=function(){const Au=[];let lo=0;const $u={};return $u.getBuffer=function(){return Au},$u.getAt=function(Ru){const Iu=Math.floor(Ru/8);return(Au[Iu]>>>7-Ru%8&1)==1},$u.put=function(Ru,Iu){for(let Pu=0;Pu<Iu;Pu+=1)$u.putBit((Ru>>>Iu-Pu-1&1)==1)},$u.getLengthInBits=function(){return lo},$u.putBit=function(Ru){const Iu=Math.floor(lo/8);Au.length<=Iu&&Au.push(0),Ru&&(Au[Iu]|=128>>>lo%8),lo+=1},$u},qrNumber=function(Au){const lo=QRMode.MODE_NUMBER,$u=Au,Ru={};Ru.getMode=function(){return lo},Ru.getLength=function(Ou){return $u.length},Ru.write=function(Ou){const Mu=$u;let Du=0;for(;Du+2<Mu.length;)Ou.put(Iu(Mu.substring(Du,Du+3)),10),Du+=3;Du<Mu.length&&(Mu.length-Du==1?Ou.put(Iu(Mu.substring(Du,Du+1)),4):Mu.length-Du==2&&Ou.put(Iu(Mu.substring(Du,Du+2)),7))};const Iu=function(Ou){let Mu=0;for(let Du=0;Du<Ou.length;Du+=1)Mu=Mu*10+Pu(Ou.charAt(Du));return Mu},Pu=function(Ou){if("0"<=Ou&&Ou<="9")return Ou.charCodeAt(0)-48;throw"illegal char :"+Ou};return Ru},qrAlphaNum=function(Au){const lo=QRMode.MODE_ALPHA_NUM,$u=Au,Ru={};Ru.getMode=function(){return lo},Ru.getLength=function(Pu){return $u.length},Ru.write=function(Pu){const Ou=$u;let Mu=0;for(;Mu+1<Ou.length;)Pu.put(Iu(Ou.charAt(Mu))*45+Iu(Ou.charAt(Mu+1)),11),Mu+=2;Mu<Ou.length&&Pu.put(Iu(Ou.charAt(Mu)),6)};const Iu=function(Pu){if("0"<=Pu&&Pu<="9")return Pu.charCodeAt(0)-48;if("A"<=Pu&&Pu<="Z")return Pu.charCodeAt(0)-65+10;switch(Pu){case" ":return 36;case"$":return 37;case"%":return 38;case"*":return 39;case"+":return 40;case"-":return 41;case".":return 42;case"/":return 43;case":":return 44;default:throw"illegal char :"+Pu}};return Ru},qr8BitByte=function(Au){const lo=QRMode.MODE_8BIT_BYTE,$u=qrcode.stringToBytes(Au),Ru={};return Ru.getMode=function(){return lo},Ru.getLength=function(Iu){return $u.length},Ru.write=function(Iu){for(let Pu=0;Pu<$u.length;Pu+=1)Iu.put($u[Pu],8)},Ru},qrKanji=function(Au){const lo=QRMode.MODE_KANJI,$u=qrcode.stringToBytes;(function(Pu,Ou){const Mu=$u(Pu);if(Mu.length!=2||(Mu[0]<<8|Mu[1])!=Ou)throw"sjis not supported."})("友",38726);const Ru=$u(Au),Iu={};return Iu.getMode=function(){return lo},Iu.getLength=function(Pu){return~~(Ru.length/2)},Iu.write=function(Pu){const Ou=Ru;let Mu=0;for(;Mu+1<Ou.length;){let Du=(255&Ou[Mu])<<8|255&Ou[Mu+1];if(33088<=Du&&Du<=40956)Du-=33088;else if(57408<=Du&&Du<=60351)Du-=49472;else throw"illegal char at "+(Mu+1)+"/"+Du;Du=(Du>>>8&255)*192+(Du&255),Pu.put(Du,13),Mu+=2}if(Mu<Ou.length)throw"illegal char at "+(Mu+1)},Iu},byteArrayOutputStream=function(){const Au=[],lo={};return lo.writeByte=function($u){Au.push($u&255)},lo.writeShort=function($u){lo.writeByte($u),lo.writeByte($u>>>8)},lo.writeBytes=function($u,Ru,Iu){Ru=Ru||0,Iu=Iu||$u.length;for(let Pu=0;Pu<Iu;Pu+=1)lo.writeByte($u[Pu+Ru])},lo.writeString=function($u){for(let Ru=0;Ru<$u.length;Ru+=1)lo.writeByte($u.charCodeAt(Ru))},lo.toByteArray=function(){return Au},lo.toString=function(){let $u="";$u+="[";for(let Ru=0;Ru<Au.length;Ru+=1)Ru>0&&($u+=","),$u+=Au[Ru];return $u+="]",$u},lo},base64EncodeOutputStream=function(){let Au=0,lo=0,$u=0,Ru="";const Iu={},Pu=function(Mu){Ru+=String.fromCharCode(Ou(Mu&63))},Ou=function(Mu){if(Mu<0)throw"n:"+Mu;if(Mu<26)return 65+Mu;if(Mu<52)return 97+(Mu-26);if(Mu<62)return 48+(Mu-52);if(Mu==62)return 43;if(Mu==63)return 47;throw"n:"+Mu};return Iu.writeByte=function(Mu){for(Au=Au<<8|Mu&255,lo+=8,$u+=1;lo>=6;)Pu(Au>>>lo-6),lo-=6},Iu.flush=function(){if(lo>0&&(Pu(Au<<6-lo),Au=0,lo=0),$u%3!=0){const Mu=3-$u%3;for(let Du=0;Du<Mu;Du+=1)Ru+="="}},Iu.toString=function(){return Ru},Iu},base64DecodeInputStream=function(Au){const lo=Au;let $u=0,Ru=0,Iu=0;const Pu={};Pu.read=function(){for(;Iu<8;){if($u>=lo.length){if(Iu==0)return-1;throw"unexpected end of file./"+Iu}const Du=lo.charAt($u);if($u+=1,Du=="=")return Iu=0,-1;if(Du.match(/^\s$/))continue;Ru=Ru<<6|Ou(Du.charCodeAt(0)),Iu+=6}const Mu=Ru>>>Iu-8&255;return Iu-=8,Mu};const Ou=function(Mu){if(65<=Mu&&Mu<=90)return Mu-65;if(97<=Mu&&Mu<=122)return Mu-97+26;if(48<=Mu&&Mu<=57)return Mu-48+52;if(Mu==43)return 62;if(Mu==47)return 63;throw"c:"+Mu};return Pu},gifImage=function(Au,lo){const $u=Au,Ru=lo,Iu=new Array(Au*lo),Pu={};Pu.setPixel=function(Lu,Bu,ju){Iu[Bu*$u+Lu]=ju},Pu.write=function(Lu){Lu.writeString("GIF87a"),Lu.writeShort($u),Lu.writeShort(Ru),Lu.writeByte(128),Lu.writeByte(0),Lu.writeByte(0),Lu.writeByte(0),Lu.writeByte(0),Lu.writeByte(0),Lu.writeByte(255),Lu.writeByte(255),Lu.writeByte(255),Lu.writeString(","),Lu.writeShort(0),Lu.writeShort(0),Lu.writeShort($u),Lu.writeShort(Ru),Lu.writeByte(0);const Bu=2,ju=Mu(Bu);Lu.writeByte(Bu);let Fu=0;for(;ju.length-Fu>255;)Lu.writeByte(255),Lu.writeBytes(ju,Fu,255),Fu+=255;Lu.writeByte(ju.length-Fu),Lu.writeBytes(ju,Fu,ju.length-Fu),Lu.writeByte(0),Lu.writeString(";")};const Ou=function(Lu){const Bu=Lu;let ju=0,Fu=0;const zu={};return zu.write=function(Uu,Hu){if(Uu>>>Hu)throw"length over";for(;ju+Hu>=8;)Bu.writeByte(255&(Uu<<ju|Fu)),Hu-=8-ju,Uu>>>=8-ju,Fu=0,ju=0;Fu=Uu<<ju|Fu,ju=ju+Hu},zu.flush=function(){ju>0&&Bu.writeByte(Fu)},zu},Mu=function(Lu){const Bu=1<<Lu,ju=(1<<Lu)+1;let Fu=Lu+1;const zu=Du();for(let Wu=0;Wu<Bu;Wu+=1)zu.add(String.fromCharCode(Wu));zu.add(String.fromCharCode(Bu)),zu.add(String.fromCharCode(ju));const Uu=byteArrayOutputStream(),Hu=Ou(Uu);Hu.write(Bu,Fu);let Vu=0,Gu=String.fromCharCode(Iu[Vu]);for(Vu+=1;Vu<Iu.length;){const Wu=String.fromCharCode(Iu[Vu]);Vu+=1,zu.contains(Gu+Wu)?Gu=Gu+Wu:(Hu.write(zu.indexOf(Gu),Fu),zu.size()<4095&&(zu.size()==1<<Fu&&(Fu+=1),zu.add(Gu+Wu)),Gu=Wu)}return Hu.write(zu.indexOf(Gu),Fu),Hu.write(ju,Fu),Hu.flush(),Uu.toByteArray()},Du=function(){const Lu={};let Bu=0;const ju={};return ju.add=function(Fu){if(ju.contains(Fu))throw"dup key:"+Fu;Lu[Fu]=Bu,Bu+=1},ju.size=function(){return Bu},ju.indexOf=function(Fu){return Lu[Fu]},ju.contains=function(Fu){return typeof Lu[Fu]<"u"},ju};return Pu},createDataURL=function(Au,lo,$u){const Ru=gifImage(Au,lo);for(let Mu=0;Mu<lo;Mu+=1)for(let Du=0;Du<Au;Du+=1)Ru.setPixel(Du,Mu,$u(Du,Mu));const Iu=byteArrayOutputStream();Ru.write(Iu);const Pu=base64EncodeOutputStream(),Ou=Iu.toByteArray();for(let Mu=0;Mu<Ou.length;Mu+=1)Pu.writeByte(Ou[Mu]);return Pu.flush(),"data:image/gif;base64,"+Pu};qrcode.stringToBytes;function _extends(){return _extends=Object.assign?Object.assign.bind():function(Au){for(var lo=1;lo<arguments.length;lo++){var $u=arguments[lo];for(var Ru in $u)({}).hasOwnProperty.call($u,Ru)&&(Au[Ru]=$u[Ru])}return Au},_extends.apply(null,arguments)}function _objectWithoutProperties(Au,lo){if(Au==null)return{};var $u,Ru,Iu=_objectWithoutPropertiesLoose(Au,lo);if(Object.getOwnPropertySymbols){var Pu=Object.getOwnPropertySymbols(Au);for(Ru=0;Ru<Pu.length;Ru++)$u=Pu[Ru],lo.indexOf($u)===-1&&{}.propertyIsEnumerable.call(Au,$u)&&(Iu[$u]=Au[$u])}return Iu}function _objectWithoutPropertiesLoose(Au,lo){if(Au==null)return{};var $u={};for(var Ru in Au)if({}.hasOwnProperty.call(Au,Ru)){if(lo.indexOf(Ru)!==-1)continue;$u[Ru]=Au[Ru]}return $u}var _excluded$1=["bgColor","bgD","fgD","fgColor","size","title","viewBoxSize","xmlns"],propTypes$1={bgColor:s$5.oneOfType([s$5.object,s$5.string]).isRequired,bgD:s$5.string.isRequired,fgColor:s$5.oneOfType([s$5.object,s$5.string]).isRequired,fgD:s$5.string.isRequired,size:s$5.number.isRequired,title:s$5.string,viewBoxSize:s$5.number.isRequired,xmlns:s$5.string},QRCodeSvg=reactExports.forwardRef(function(Au,lo){var $u=Au.bgColor,Ru=Au.bgD,Iu=Au.fgD,Pu=Au.fgColor,Ou=Au.size,Mu=Au.title,Du=Au.viewBoxSize,Lu=Au.xmlns,Bu=Lu===void 0?"http://www.w3.org/2000/svg":Lu,ju=_objectWithoutProperties(Au,_excluded$1);return vM.createElement("svg",_extends({},ju,{height:Ou,ref:lo,viewBox:"0 0 ".concat(Du," ").concat(Du),width:Ou,xmlns:Bu}),Mu?vM.createElement("title",null,Mu):null,vM.createElement("path",{d:Ru,fill:$u}),vM.createElement("path",{d:Iu,fill:Pu}))});QRCodeSvg.displayName="QRCodeSvg";QRCodeSvg.propTypes=propTypes$1;var _excluded=["bgColor","fgColor","level","size","value"];qrcode.stringToBytes=function(Au){return Array.from(new TextEncoder().encode(Au))};var propTypes={bgColor:s$5.oneOfType([s$5.object,s$5.string]),fgColor:s$5.oneOfType([s$5.object,s$5.string]),level:s$5.string,size:s$5.number,value:s$5.string.isRequired},QRCode=reactExports.forwardRef(function(Au,lo){var $u=Au.bgColor,Ru=$u===void 0?"#FFFFFF":$u,Iu=Au.fgColor,Pu=Iu===void 0?"#000000":Iu,Ou=Au.level,Mu=Ou===void 0?"L":Ou,Du=Au.size,Lu=Du===void 0?256:Du,Bu=Au.value,ju=_objectWithoutProperties(Au,_excluded),Fu=qrcode(0,Mu);Fu.addData(Bu),Fu.make();var zu=Fu.getModuleCount(),Uu=Array.from({length:zu},function(Hu,Vu){return Array.from({length:zu},function(Gu,Wu){return Fu.isDark(Vu,Wu)})});return vM.createElement(QRCodeSvg,_extends({},ju,{bgColor:Ru,bgD:Uu.map(function(Hu,Vu){return Hu.map(function(Gu,Wu){return Gu?"":"M ".concat(Wu," ").concat(Vu," l 1 0 0 1 -1 0 Z")}).join(" ")}).join(" "),fgColor:Pu,fgD:Uu.map(function(Hu,Vu){return Hu.map(function(Gu,Wu){return Gu?"M ".concat(Wu," ").concat(Vu," l 1 0 0 1 -1 0 Z"):""}).join(" ")}).join(" "),ref:lo,size:Lu,viewBoxSize:zu}))});QRCode.displayName="QRCode";QRCode.propTypes=propTypes;function PapSignInCard({context:Au,send:lo}){const[$u,Ru]=reactExports.useState(!1),[Iu,Pu]=reactExports.useState(!1),[Ou,Mu]=reactExports.useState(null),Du=Au.status==="complete"?readPapSignIn(Au.result):null,Lu=Du&&!("refused"in Du)&&Du.mode==="direct"?Du.company??"":"";if(reactExports.useEffect(()=>{if(!Lu||typeof BroadcastChannel>"u")return;const zu=new BroadcastChannel(PAP_SIGN_IN_CHANNEL);return zu.onmessage=Uu=>{const Hu=signInReturnOf(Uu.data,Lu);Hu&&(Mu(Hu),zu.close())},()=>zu.close()},[Lu]),reactExports.useEffect(()=>{Ou==="signed_in"&&lo&&!Iu&&Pu(lo(PAP_SIGN_IN_WORDS.checkMessage(Lu)))},[Ou,lo,Iu,Lu]),!Du)return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:Au.defaultUI});if("refused"in Du)return jsxRuntimeExports.jsx(Flash,{variant:"danger",role:"alert",sx:{my:2},children:Du.refused});const Bu=async()=>{try{await navigator.clipboard.writeText(Du.code??""),Ru(!0)}catch{Ru(!1)}},ju=Du.company??Du.host,Fu=Du.mode==="mediated"?PAP_SIGN_IN_WORDS.mediatedTitle(Du.host):PAP_SIGN_IN_WORDS.title(ju);return jsxRuntimeExports.jsxs(Box,{as:"section","aria-label":Fu,my:2,p:3,border:"1px solid",borderColor:"border.default",borderRadius:2,bg:"canvas.subtle",maxWidth:480,children:[jsxRuntimeExports.jsx(Heading$2,{as:"h4",sx:{fontSize:2,mb:1},children:Fu}),jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{mt:0,mb:2,color:"fg.muted",fontSize:1},children:Du.mode==="device"?PAP_SIGN_IN_WORDS.device:Du.mode==="mediated"?PAP_SIGN_IN_WORDS.mediated:PAP_SIGN_IN_WORDS.direct}),Du.needs?jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{mt:0,mb:2,fontSize:1},children:PAP_SIGN_IN_WORDS.needs(Du.needs)}):null,Du.sentTo?jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{mt:0,mb:2,fontSize:1},children:PAP_SIGN_IN_WORDS.sentTo(Du.sentTo)}):null,Du.code?jsxRuntimeExports.jsxs(Box,{display:"flex",gap:3,alignItems:"center",flexWrap:"wrap",mb:2,children:[jsxRuntimeExports.jsxs(Box,{children:[jsxRuntimeExports.jsx(Text$3,{as:"div",sx:{fontSize:0,color:"fg.muted"},children:PAP_SIGN_IN_WORDS.code}),jsxRuntimeExports.jsx(Text$3,{as:"div","aria-live":"polite",sx:{fontFamily:"mono",fontSize:5,fontWeight:"bold",letterSpacing:"0.15em"},children:Du.code}),jsxRuntimeExports.jsx(ButtonComponent,{size:"small",leadingVisual:CopyIcon,onClick:()=>{Bu()},children:$u?PAP_SIGN_IN_WORDS.copied:PAP_SIGN_IN_WORDS.copy})]}),jsxRuntimeExports.jsx(Box,{bg:"#ffffff",p:2,borderRadius:2,lineHeight:0,children:jsxRuntimeExports.jsx(QRCode,{value:Du.open,size:112,title:PAP_SIGN_IN_WORDS.qr(Du.host)})})]}):null,jsxRuntimeExports.jsxs(Box,{display:"flex",gap:2,flexWrap:"wrap",alignItems:"center",children:[jsxRuntimeExports.jsx(ButtonComponent,{as:"a",href:Du.open,target:"_blank",rel:"noopener noreferrer",variant:"primary",trailingVisual:LinkExternalIcon,children:PAP_SIGN_IN_WORDS.open(ju)}),lo?jsxRuntimeExports.jsx(ButtonComponent,{disabled:Iu,onClick:()=>Pu(lo(PAP_SIGN_IN_WORDS.checkMessage(ju))),children:PAP_SIGN_IN_WORDS.checkAgain}):null]}),Ou?jsxRuntimeExports.jsx(Text$3,{as:"p",role:"status",sx:{mt:2,mb:0,fontSize:1},children:PAP_SIGN_IN_WORDS.returned[Ou](ju)}):null,Du.expiresAt?jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{mt:2,mb:0,fontSize:0,color:"fg.muted"},children:PAP_SIGN_IN_WORDS.until(Du.expiresAt)}):null,lo?null:jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{mt:1,mb:0,fontSize:1},children:PAP_SIGN_IN_WORDS.tellMe})]})}const PAP_SIGN_IN_PLUGIN_NAME="@datalayer/loop-plugin-pap-sign-in",PAP_SIGN_IN_TYPE="application/vnd.datalayer.pap.sign-in+json";function resultOf(Au,lo){const $u=Au.data??{};return"toolName"in $u?lo?.result:{status:"waiting_for_the_person",...$u}}function createPapSignInPlugin(){let Au;const lo=Pu=>Au?!Au(Pu):!1;function $u({workspace:Pu}){const Ou=Pu?.viewControls.send;return reactExports.useEffect(()=>(Au=Ou,()=>{Au===Ou&&(Au=void 0)}),[Ou]),null}function Ru({display:Pu,context:Ou}){const Mu=resultOf(Pu,Ou);return reactExports.createElement(PapSignInCard,{key:Pu.id,context:Ou?{...Ou,result:Mu}:{toolCallId:Pu.id,toolName:"pap_sign_in",name:"pap_sign_in",args:{},status:"complete",result:Mu},send:Au?lo:void 0})}return{name:PAP_SIGN_IN_PLUGIN_NAME,displayName:"Sign in at a company",description:"The company’s page, the code and until when, where the agent asks the person to sign in.",octicon:"sign-in",emoji:"🔑",contributes:[contribution(Renderers,defineRenderer({type:PAP_SIGN_IN_TYPE,component:Ru}),{id:"pap-sign-in"}),contribution(ToolBindings,{tool:PAP_SIGN_IN_TOOL,type:PAP_SIGN_IN_TYPE},{id:"pap-sign-in"})],build(){return{components:[{slot:LoopSlots.chatHeader,id:"pap-sign-in",Component:$u}]}}}}const PapSignInPlugin=createPapSignInPlugin(),COLOURS={context:{bg:"transparent",fg:"fg.muted",sign:" "},add:{bg:"success.subtle",fg:"success.fg",sign:"+"},remove:{bg:"danger.subtle",fg:"danger.fg",sign:"-"}};function DiffCard({display:Au}){const lo=unifiedDiffLines(Au.oldText,Au.newText);return jsxRuntimeExports.jsxs(Box,{"data-shield-display":"diff","data-language":Au.language,sx:{width:"100%",border:"1px solid",borderColor:"border.default",borderRadius:2,overflow:"hidden",fontSize:0},children:[jsxRuntimeExports.jsxs(Box,{sx:{px:2,py:1,bg:"canvas.subtle",borderBottom:"1px solid",borderColor:"border.default",display:"flex",justifyContent:"space-between"},children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontFamily:"mono",fontWeight:"bold"},children:Au.path}),jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted"},children:displayLine(Au)})]}),jsxRuntimeExports.jsx(Box,{as:"pre",className:`language-${Au.language}`,sx:{m:0,overflowX:"auto",fontFamily:"mono"},children:lo.map(($u,Ru)=>jsxRuntimeExports.jsxs(Box,{as:"span","data-diff-line":$u.kind,sx:{display:"block",px:2,bg:COLOURS[$u.kind].bg,color:COLOURS[$u.kind].fg,whiteSpace:"pre"},children:[COLOURS[$u.kind].sign,$u.text]},Ru))})]})}function TerminalCard({display:Au}){const lo=Au.exitCode!==null&&Au.exitCode!==0;return jsxRuntimeExports.jsxs(Box,{"data-shield-display":"terminal","data-exit-code":Au.exitCode===null?"running":Au.exitCode,sx:{width:"100%",border:"1px solid",borderColor:lo?"danger.muted":"border.default",borderRadius:2,overflow:"hidden",fontSize:0},children:[jsxRuntimeExports.jsxs(Box,{sx:{px:2,py:1,bg:"canvas.subtle",borderBottom:"1px solid",borderColor:"border.default",display:"flex",justifyContent:"space-between"},children:[jsxRuntimeExports.jsx(Text$3,{sx:{fontFamily:"mono",fontWeight:"bold"},children:Au.command?`$ ${Au.command}`:Au.terminalId}),jsxRuntimeExports.jsx(Text$3,{sx:{color:lo?"danger.fg":"fg.muted"},children:displayLine(Au)})]}),jsxRuntimeExports.jsx(Box,{as:"pre",sx:{m:0,px:2,py:1,overflowX:"auto",fontFamily:"mono",whiteSpace:"pre-wrap",bg:"canvas.default"},children:Au.output||(Au.exitCode===null?"…":"(no output)")})]})}const SHIELD_DISPLAYS_PLUGIN_NAME="@datalayer/loop-plugin-shield-displays";function Diff({display:Au,context:lo}){const $u=protocolDisplayOf(Au);return!$u||$u.kind!=="diff"?reactExports.createElement("span",null,lo?.defaultUI??Au.text):reactExports.createElement(DiffCard,{key:Au.id,display:$u})}function Terminal$1({display:Au,context:lo}){const $u=protocolDisplayOf(Au);return!$u||$u.kind!=="terminal"?reactExports.createElement("span",null,lo?.defaultUI??Au.text):reactExports.createElement(TerminalCard,{key:Au.id,display:$u})}function createShieldDisplaysPlugin(){return{name:SHIELD_DISPLAYS_PLUGIN_NAME,displayName:"Diffs and terminals",description:"What a coding agent changed, as a unified diff, and what it ran, with its output.",octicon:"diff",emoji:"🛡",contributes:[contribution(Renderers,defineRenderer({type:SHIELD_DIFF_TYPE,component:Diff}),{id:"shield-diff"}),contribution(Renderers,defineRenderer({type:SHIELD_TERMINAL_TYPE,component:Terminal$1}),{id:"shield-terminal"})]}}const ShieldDisplaysPlugin=createShieldDisplaysPlugin();function makeViewSwitchAction({viewId:Au,icon:lo,tooltip:$u}){return function(){const Iu=reactExports.useSyncExternalStore(subscribeEditorChoice,()=>getEditorChoice().editorId),Pu=useContributions(LoopEditorView);if(Au!==NONE_EDITOR&&!Pu.some(Mu=>Mu.value.surfaceId===Au))return null;const Ou=(Iu||NONE_EDITOR)===Au;return jsxRuntimeExports.jsx(IconButton,{icon:lo,"aria-label":$u,size:"small",variant:"invisible",onClick:()=>{chooseEditor(Au)||console.warn(`[loop] No chat is on screen to switch to '${Au}'.`)},sx:Ou?{color:"accent.fg"}:void 0})}}function defineViewPlugin(Au){const{key:lo,viewId:$u,displayName:Ru,description:Iu,icon:Pu,tooltip:Ou,order:Mu}=Au,Du=makeViewSwitchAction({viewId:$u,icon:Pu,tooltip:Ou});return{name:`@datalayer/loop-plugin-${lo}-view`,displayName:Ru,description:Iu,octicon:Au.octicon??"eye",emoji:Au.emoji,dependencies:[InputPromptPlugin],build:()=>({components:[{id:`${lo}-view-action`,slot:LoopSlots.promptAction,order:Mu,Component:Du}]})}}const ChatViewPlugin=defineViewPlugin({key:"chat",viewId:NONE_EDITOR,displayName:"Chat view",description:"The conversation on its own, from the composer footer.",icon:CommentDiscussionIcon,tooltip:"Show the chat",octicon:"comment-discussion",emoji:"💬",order:10}),DocumentViewPlugin=defineViewPlugin({key:"document",viewId:"document",displayName:"Document view",description:"The document beside the chat, from the composer footer.",icon:FileIcon,tooltip:"Show the document",octicon:"file",emoji:"📄",order:12}),NotebookViewPlugin=defineViewPlugin({key:"notebook",viewId:"notebook",displayName:"Notebook view",description:"The notebook beside the chat, from the composer footer.",icon:RowsIcon,tooltip:"Show the notebook",octicon:"rows",emoji:"📓",order:11}),STYLE_ELEMENT_ID="datalayer-reactor-commands-style",PALETTE_CSS=`
|
|
3858
3858
|
/*
|
|
@@ -4011,7 +4011,7 @@ ${Mu}`:ju,inputs:Mu,clear:Ou?[]:[DRAFT.path],loop:Lu()}:{refused:"Nothing to sen
|
|
|
4011
4011
|
opacity: 0.6;
|
|
4012
4012
|
border-top: 1px solid var(--cmdk-border);
|
|
4013
4013
|
}
|
|
4014
|
-
`;function usePaletteStyles(){reactExports.useEffect(()=>{if(typeof document>"u"||document.getElementById(STYLE_ELEMENT_ID))return;const Au=document.createElement("style");Au.id=STYLE_ELEMENT_ID,Au.textContent=PALETTE_CSS,document.head.appendChild(Au)},[])}function rank(Au,lo){if(!lo)return{command:Au,score:0};const $u=lo.toLowerCase(),Ru=[[Au.name.toLowerCase(),0],[Au.id.toLowerCase(),100],[(Au.category??"").toLowerCase(),200],[(Au.description??"").toLowerCase(),300]];for(const[Iu,Pu]of Ru){const Ou=Iu.indexOf($u);if(Ou>=0)return{command:Au,score:Pu+Ou}}return null}const PRIMER_PORTAL_ROOT_ID="__primerPortalRoot__";function paletteRoot(){return document.getElementById(PRIMER_PORTAL_ROOT_ID)??document.body}const LIST_ID="dla-cmdk-list",optionId=Au=>`dla-cmdk-option-${Au}`,PALETTE_KEYBINDING="Mod+K",PALETTE_CHORD=parseKeybinding(PALETTE_KEYBINDING);function CommandPalette(){const Au=useReactorPlatform(),lo=useCommands();usePaletteStyles();const[$u,Ru]=reactExports.useState(!1),[Iu,Pu]=reactExports.useState(""),[Ou,Mu]=reactExports.useState(0),[Du,Lu]=reactExports.useState(null),[Bu,ju]=reactExports.useState(null),Fu=reactExports.useRef(null),zu=reactExports.useMemo(()=>lo.map(Wu=>rank(Wu,Iu)).filter(Wu=>Wu!==null).sort((Wu,Ku)=>Wu.score-Ku.score).map(Wu=>Wu.command),[lo,Iu]),Uu=reactExports.useCallback(()=>{Ru(!1),Pu(""),Mu(0),ju(null)},[]),Hu=reactExports.useCallback(async Wu=>{Lu(Wu.id),ju(null);try{await Au.executeCommand(Wu.id),Uu()}catch(Ku){ju(Ku instanceof Error?Ku.message:String(Ku))}finally{Lu(null)}},[Uu,Au]);if(reactExports.useEffect(()=>{const Wu=lo.map(Yu=>{const Xu=Yu.keybinding?parseKeybinding(Yu.keybinding):null;return Xu?{chord:Xu,id:Yu.id}:null}).filter(Yu=>Yu!==null),Ku=isApplePlatform();function Ju(Yu){if(PALETTE_CHORD&&matchesKeybinding(Yu,PALETTE_CHORD,Ku)){Yu.preventDefault(),Yu.stopPropagation(),Ru(Xu=>!Xu);return}if(Yu.key==="Escape"){Ru(Xu=>Xu&&!1);return}if(!$u){for(const Xu of Wu)if(matchesKeybinding(Yu,Xu.chord,Ku)){Yu.preventDefault(),Yu.stopPropagation();const ed=Au.getCommand(Xu.id);ed&&ed.isEnabled?.()!==!1&&Au.executeCommand(Xu.id).catch(td=>{console.error(`Command ${Xu.id} failed`,td)});return}}}return document.addEventListener("keydown",Ju,{capture:!0}),()=>document.removeEventListener("keydown",Ju,{capture:!0})},[lo,$u,Au]),reactExports.useEffect(()=>{if(!$u)return;Pu(""),Mu(0),ju(null);const Wu=window.requestAnimationFrame(()=>Fu.current?.focus());return()=>window.cancelAnimationFrame(Wu)},[$u]),reactExports.useEffect(()=>{Mu(Wu=>Wu>=zu.length?0:Wu)},[zu.length]),!$u||typeof document>"u")return null;const Vu=Wu=>{if(Wu.key==="ArrowDown")Wu.preventDefault(),Mu(Ku=>zu.length===0?0:(Ku+1)%zu.length);else if(Wu.key==="ArrowUp")Wu.preventDefault(),Mu(Ku=>zu.length===0?0:(Ku-1+zu.length)%zu.length);else if(Wu.key==="Enter"){Wu.preventDefault();const Ku=zu[Ou];Ku&&Ku.isEnabled?.()!==!1&&Hu(Ku)}},Gu=jsxRuntimeExports.jsx("div",{className:"dla-cmdk-backdrop",onClick:Uu,children:jsxRuntimeExports.jsxs("div",{className:"dla-cmdk-panel",role:"dialog","aria-modal":"true","aria-label":"Command palette",onClick:Wu=>Wu.stopPropagation(),children:[jsxRuntimeExports.jsx("div",{className:"dla-cmdk-search",children:jsxRuntimeExports.jsx("input",{ref:Fu,className:"dla-cmdk-input",type:"text",placeholder:"Run a command…","aria-label":"Search commands",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,role:"combobox","aria-expanded":!0,"aria-controls":LIST_ID,"aria-autocomplete":"list","aria-activedescendant":zu.length>0?optionId(Ou):void 0,value:Iu,onChange:Wu=>Pu(Wu.target.value),onKeyDown:Vu})}),Bu!==null&&jsxRuntimeExports.jsx("div",{className:"dla-cmdk-error",children:Bu}),jsxRuntimeExports.jsx("ul",{className:"dla-cmdk-list",id:LIST_ID,role:"listbox",children:zu.length===0?jsxRuntimeExports.jsx("li",{className:"dla-cmdk-empty",children:lo.length===0?"No plugin has registered a command yet.":`Nothing matches “${Iu}”.`}):zu.map((Wu,Ku)=>{const Ju=Wu.isEnabled?.()!==!1;return jsxRuntimeExports.jsx("li",{children:jsxRuntimeExports.jsxs("button",{type:"button",className:"dla-cmdk-item",id:optionId(Ku),role:"option","aria-selected":Ku===Ou,"aria-disabled":!Ju,disabled:!Ju,onMouseEnter:()=>Mu(Ku),onClick:()=>{Hu(Wu)},children:[jsxRuntimeExports.jsx("span",{className:"dla-cmdk-mark","aria-hidden":"true",children:Wu.emoji??"·"}),jsxRuntimeExports.jsxs("span",{className:"dla-cmdk-text",children:[jsxRuntimeExports.jsx("span",{className:"dla-cmdk-name",children:Wu.name}),Wu.description&&jsxRuntimeExports.jsx("p",{className:"dla-cmdk-description",children:Wu.description})]}),Du===Wu.id&&jsxRuntimeExports.jsx("span",{className:"dla-cmdk-meta",children:"running…"}),Wu.keybinding&&jsxRuntimeExports.jsx("kbd",{className:"dla-cmdk-key",children:formatKeybinding(Wu.keybinding)}),Wu.category&&jsxRuntimeExports.jsx("span",{className:"dla-cmdk-meta",children:Wu.category})]})},Wu.id)})}),jsxRuntimeExports.jsxs("div",{className:"dla-cmdk-footer",children:[jsxRuntimeExports.jsxs("span",{children:["↑↓ to move · ↵ to run · esc to close ·"," ",jsxRuntimeExports.jsx("kbd",{className:"dla-cmdk-key",children:formatKeybinding(PALETTE_KEYBINDING)})," ","to reopen"]}),jsxRuntimeExports.jsxs("span",{children:[zu.length," of ",lo.length]})]})]})});return reactDomExports.createPortal(Gu,paletteRoot())}const CommandsPlugin={name:"@datalayer/reactor-commands",version:"1.0.0",displayName:"Commands",description:"A command palette: Ctrl-K opens a floating search over every command plugins have registered.",octicon:"command-palette",emoji:"⌘",build(){return{components:[{slot:"root",id:"command-palette",Component:CommandPalette}]}},commands:[{id:"commands.showPalette",name:"Show the command palette",description:"The same thing Ctrl-K does — listed so it is discoverable",emoji:"⌘",category:"Commands",keybinding:PALETTE_KEYBINDING,execute:()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",ctrlKey:!0,bubbles:!0}))}}]},COMMANDS_PLUGIN_NAME="@datalayer/loop-plugin-commands",DEFAULT_CATEGORY="Workspace",GROUP_EMOJI={Agents:"🤖",Open:"📂",Session:"🧭",Workspace:"🪟"};function LoopCommandBridge({workspace:Au,sync:lo}){const $u=useContributions(LoopCommand);return reactExports.useEffect(()=>{lo($u,Au)},[$u,Au,lo]),null}const LoopCommandsPlugin={name:COMMANDS_PLUGIN_NAME,displayName:"Command palette",description:"Puts the workspace commands in a Ctrl-K palette, beside every plugin that registers one.",octicon:"command-palette",emoji:"⌘",dependencies:[CommandsPlugin,ThemePlugin],build:Au=>{const lo=new Map;let $u="",Ru;const Iu=(Pu,Ou)=>{const Mu=Ou?Pu.map(Du=>`${Du.plugin}:${Du.value.name}`).join("|"):"";if(!(Mu===$u&&Ou===Ru)){$u=Mu,Ru=Ou;for(const Du of lo.values())Du();if(lo.clear(),!!Ou)for(const Du of Pu){const Lu=Du.value,Bu=Lu.group??DEFAULT_CATEGORY;lo.set(Lu.name,Au.registerCommand({id:`loop.${Lu.name}`,name:Lu.description,description:`/${Lu.name}`,emoji:GROUP_EMOJI[Bu]??"💠",category:Bu,keybinding:Lu.keybinding,execute:async()=>{await Lu.run({workspace:Ou,argv:""})}}))}}};return{components:[{id:"loop-command-bridge",slot:LoopSlots.status,Component:({workspace:Pu})=>jsxRuntimeExports.jsx(LoopCommandBridge,{workspace:Pu,sync:Iu})}]}}},MODELS_PLUGIN_NAME="@datalayer/loop-plugin-models",ModelsPlugin={name:MODELS_PLUGIN_NAME,displayName:"Models",description:"Which model answers, from the agentspecs catalog.",octicon:"cpu",emoji:"🧠",contributes:[contribution(LoopCommand,{name:"models",aliases:["model"],description:"Show the models available to this session",group:"Agents",keybinding:"Mod+Alt+M",run:async({workspace:Au})=>{const lo=await fetch(`${Au.serverUrl}/api/v1/configure/models`);if(!lo.ok)return{content:"The model catalogue is unavailable."};const $u=await lo.json();return{content:`${($u.models??[]).filter(Iu=>Iu.available!==!1).length} of ${($u.models??[]).length} models are ready. Pick one under the prompt.`}}},{id:"models"})]},WINDOW_CONTROLS_SLOT="loop.window.controls",WINDOW_ACTIONS_SLOT="loop.window.actions";function WindowFrame({children:Au,title:lo,height:$u,slotProps:Ru={}}){const Iu=useOptionalSlotComponents(WINDOW_ACTIONS_SLOT);return jsxRuntimeExports.jsxs(Box,{position:"relative",borderRadius:"14px",overflow:"hidden",border:"1px solid",borderColor:"border.default",bg:"canvas.default",boxShadow:"0 24px 60px -28px rgba(0, 0, 0, 0.55)",height:$u===void 0?"100%":void 0,display:$u===void 0?"flex":void 0,flexDirection:$u===void 0?"column":void 0,children:[jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,px:3,py:2,borderBottom:"1px solid",borderColor:"border.default",bg:"canvas.subtle",flexWrap:"wrap",rowGap:2,flex:"0 0 auto",children:[jsxRuntimeExports.jsx(Box,{display:"flex",alignItems:"center",gap:"6px",mr:1,flexShrink:0,children:jsxRuntimeExports.jsx(ReactorSlot,{slot:WINDOW_CONTROLS_SLOT,props:Ru})}),jsxRuntimeExports.jsx(Box,{minWidth:0,flex:"1 1 auto",children:lo}),Iu.length>0?jsxRuntimeExports.jsx(Box,{display:"flex",alignItems:"center",gap:2,flexShrink:0,ml:"auto",children:jsxRuntimeExports.jsx(ReactorSlot,{slot:WINDOW_ACTIONS_SLOT,props:Ru})}):null]}),jsxRuntimeExports.jsx(Box,{sx:$u===void 0?{flex:"1 1 auto",minHeight:0}:{height:$u,minHeight:0},children:Au})]})}const WINDOW_FRAME_PLUGIN_NAME="@datalayer/loop-plugin-window-frame";function WindowControls(){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:["danger.emphasis","attention.emphasis","success.emphasis"].map(Au=>jsxRuntimeExports.jsx(Box,{width:10,height:10,borderRadius:"50%",bg:Au},Au))})}const WindowFramePlugin={name:WINDOW_FRAME_PLUGIN_NAME,displayName:"Window frame",description:"Draws Loop as a window, and opens its title bar to controls and actions.",octicon:"browser",emoji:"🪟",build:()=>({components:[{id:"window-controls",slot:WINDOW_CONTROLS_SLOT,Component:WindowControls},{id:"full-screen",slot:LoopSlots.header,Component:WorkspaceFullScreenAction}]})},DOCUMENT_PLUGIN_NAME="@datalayer/loop-plugin-document",DocumentPlugin={name:DOCUMENT_PLUGIN_NAME,displayName:"Document editor",description:"A rich-text document beside the chat, driven by the agent.",octicon:"file",emoji:"📄",dependencies:[AgentsPlugin],contributionPoints:[LoopDocumentToolbar,LoopOpeningDocument],contributes:[contribution(LoopEditorView,{surfaceId:"document",title:"Document",icon:FileIcon,order:20,canOpen:Au=>Au.sandbox.state==="running",unavailableReason:()=>"Needs a running sandbox",load:()=>__vitePreload(()=>import("./chunks/DocumentView-i99p_Qzt.js"),[],import.meta.url)},{id:"document",order:20}),contribution(LoopCommand,{name:"document",description:"Open the document beside the chat",group:"Open",keybinding:"Mod+Alt+O",run:async({workspace:Au})=>{if(Au.setActiveViewType("chat"),!requestSurface("document"))throw new Error("No chat is on screen to open the document beside.")}},{id:"document"})],build:Au=>(__vitePreload(async()=>{const{createLexicalTools:lo}=await import("./chunks/lexicalHooks-Pqoe8h_O.js");return{createLexicalTools:lo}},[],import.meta.url).then(({createLexicalTools:lo})=>{Au.contribute(LoopFrontendTool,{id:"document-tools",tools:$u=>lo($u.surfaceId)},{id:"document-tools"})},lo=>{console.warn("The document tools could not be loaded",lo)}),{})},DOCUMENT_TOOLBAR_PLUGIN_NAME="@datalayer/loop-plugin-document-toolbar",DocumentToolbarPlugin=defineLazyPlugin({name:DOCUMENT_TOOLBAR_PLUGIN_NAME,displayName:"Document toolbar",description:"Shows what the document’s code blocks run on.",octicon:"circle",emoji:"🔵",activationEvents:[onContributionPoint(LoopDocumentToolbar)],contributionPoints:[LoopDocumentToolbarItem],load:()=>__vitePreload(()=>import("./chunks/plugin-Cf3g-jak.js"),[],import.meta.url)}),NOTEBOOK_PLUGIN_NAME="@datalayer/loop-plugin-notebook",NotebookPlugin={name:NOTEBOOK_PLUGIN_NAME,displayName:"Notebook editor",description:"A notebook beside the chat, on the session’s kernel.",octicon:"rows",emoji:"📓",dependencies:[AgentsPlugin],contributionPoints:[LoopNotebookToolbar,LoopOpeningNotebook],contributes:[contribution(LoopEditorView,{surfaceId:"notebook",title:"Notebook",icon:RowsIcon,order:10,canOpen:Au=>Au.sandbox.state==="running",unavailableReason:()=>"Needs a running sandbox",load:()=>__vitePreload(()=>import("./chunks/NotebookView-BJpTApeL.js"),[],import.meta.url)},{id:"notebook",order:10}),contribution(LoopCommand,{name:"notebook",description:"Open the notebook beside the chat",group:"Open",keybinding:"Mod+Alt+N",run:async({workspace:Au})=>{if(Au.setActiveViewType("chat"),!requestSurface("notebook"))throw new Error("No chat is on screen to open the notebook beside.")}},{id:"notebook"})],build:Au=>(__vitePreload(async()=>{const{createNotebookTools:lo}=await Promise.resolve().then(()=>notebookHooks);return{createNotebookTools:lo}},void 0,import.meta.url).then(({createNotebookTools:lo})=>{Au.contribute(LoopFrontendTool,{id:"notebook-tools",tools:$u=>lo($u.surfaceId)},{id:"notebook-tools"})},lo=>{console.warn("The notebook tools could not be loaded",lo)}),{})},NOTEBOOK_TOOLBAR_PLUGIN_NAME="@datalayer/loop-plugin-notebook-toolbar",NotebookToolbarPlugin=defineLazyPlugin({name:NOTEBOOK_TOOLBAR_PLUGIN_NAME,displayName:"Notebook toolbar",description:"Shows what the notebook is running on, on its toolbar.",octicon:"circle",emoji:"🟢",activationEvents:[onContributionPoint(LoopNotebookToolbar)],contributionPoints:[LoopNotebookToolbarItem],load:()=>__vitePreload(()=>import("./chunks/plugin-DA_NCYQX.js"),[],import.meta.url)}),NotebookExtension=defineExtension({name:"@datalayer/loop-extension-notebook",displayName:"Notebooks",description:"A notebook beside the chat, and the toolbar that reports on it.",octicon:"rows",emoji:"📓",plugins:[NotebookPlugin,NotebookToolbarPlugin]}),DocumentExtension=defineExtension({name:"@datalayer/loop-extension-document",displayName:"Documents",description:"A rich-text document beside the chat, and the toolbar that reports on it.",octicon:"file",emoji:"📄",plugins:[DocumentPlugin,DocumentToolbarPlugin]}),NO_TURN$5=signal$2({id:0,status:"idle"}),MAX_HEIGHT=168;function Thinking(){return jsxRuntimeExports.jsxs(Box,{as:"span","aria-label":"The agent is thinking",display:"inline-flex",gap:"4px",alignItems:"center",sx:{height:"1.5em","& > i":{width:5,height:5,borderRadius:"50%",bg:"fg.muted",animation:"loop-turn-dot 1.2s ease-in-out infinite"},"& > i:nth-of-type(2)":{animationDelay:"0.15s"},"& > i:nth-of-type(3)":{animationDelay:"0.3s"},"@keyframes loop-turn-dot":{"0%, 80%, 100%":{opacity:.25},"40%":{opacity:1}}},children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("i",{})]})}function TurnPanel({footer:Au="full"}){const lo=useContributions(LoopChatTurn),$u=useSignalValue$1(lo[0]?.value.turn??NO_TURN$5),Ru=useSignalValue$1(pageLayoutSheet),Iu=reactExports.useRef(null),[Pu,Ou]=reactExports.useState(null),[Mu,Du]=reactExports.useState(!1);reactExports.useEffect(()=>{const ju=Iu.current;ju&&(ju.scrollTop=ju.scrollHeight)},[$u.assistant]),reactExports.useEffect(()=>{if(!Mu)return;const ju=window.setTimeout(()=>Du(!1),1400);return()=>window.clearTimeout(ju)},[Mu]);const Lu=reactExports.useCallback(async()=>{const ju=[$u.user,$u.assistant].filter(Boolean).join(`
|
|
4014
|
+
`;function usePaletteStyles(){reactExports.useEffect(()=>{if(typeof document>"u"||document.getElementById(STYLE_ELEMENT_ID))return;const Au=document.createElement("style");Au.id=STYLE_ELEMENT_ID,Au.textContent=PALETTE_CSS,document.head.appendChild(Au)},[])}function rank(Au,lo){if(!lo)return{command:Au,score:0};const $u=lo.toLowerCase(),Ru=[[Au.name.toLowerCase(),0],[Au.id.toLowerCase(),100],[(Au.category??"").toLowerCase(),200],[(Au.description??"").toLowerCase(),300]];for(const[Iu,Pu]of Ru){const Ou=Iu.indexOf($u);if(Ou>=0)return{command:Au,score:Pu+Ou}}return null}const PRIMER_PORTAL_ROOT_ID="__primerPortalRoot__";function paletteRoot(){return document.getElementById(PRIMER_PORTAL_ROOT_ID)??document.body}const LIST_ID="dla-cmdk-list",optionId=Au=>`dla-cmdk-option-${Au}`,PALETTE_KEYBINDING="Mod+K",PALETTE_CHORD=parseKeybinding(PALETTE_KEYBINDING);function CommandPalette(){const Au=useReactorPlatform(),lo=useCommands();usePaletteStyles();const[$u,Ru]=reactExports.useState(!1),[Iu,Pu]=reactExports.useState(""),[Ou,Mu]=reactExports.useState(0),[Du,Lu]=reactExports.useState(null),[Bu,ju]=reactExports.useState(null),Fu=reactExports.useRef(null),zu=reactExports.useMemo(()=>lo.map(Wu=>rank(Wu,Iu)).filter(Wu=>Wu!==null).sort((Wu,Ku)=>Wu.score-Ku.score).map(Wu=>Wu.command),[lo,Iu]),Uu=reactExports.useCallback(()=>{Ru(!1),Pu(""),Mu(0),ju(null)},[]),Hu=reactExports.useCallback(async Wu=>{Lu(Wu.id),ju(null);try{await Au.executeCommand(Wu.id),Uu()}catch(Ku){ju(Ku instanceof Error?Ku.message:String(Ku))}finally{Lu(null)}},[Uu,Au]);if(reactExports.useEffect(()=>{const Wu=lo.map(Yu=>{const Xu=Yu.keybinding?parseKeybinding(Yu.keybinding):null;return Xu?{chord:Xu,id:Yu.id}:null}).filter(Yu=>Yu!==null),Ku=isApplePlatform();function Ju(Yu){if(PALETTE_CHORD&&matchesKeybinding(Yu,PALETTE_CHORD,Ku)){Yu.preventDefault(),Yu.stopPropagation(),Ru(Xu=>!Xu);return}if(Yu.key==="Escape"){Ru(Xu=>Xu&&!1);return}if(!$u){for(const Xu of Wu)if(matchesKeybinding(Yu,Xu.chord,Ku)){Yu.preventDefault(),Yu.stopPropagation();const ed=Au.getCommand(Xu.id);ed&&ed.isEnabled?.()!==!1&&Au.executeCommand(Xu.id).catch(td=>{console.error(`Command ${Xu.id} failed`,td)});return}}}return document.addEventListener("keydown",Ju,{capture:!0}),()=>document.removeEventListener("keydown",Ju,{capture:!0})},[lo,$u,Au]),reactExports.useEffect(()=>{if(!$u)return;Pu(""),Mu(0),ju(null);const Wu=window.requestAnimationFrame(()=>Fu.current?.focus());return()=>window.cancelAnimationFrame(Wu)},[$u]),reactExports.useEffect(()=>{Mu(Wu=>Wu>=zu.length?0:Wu)},[zu.length]),!$u||typeof document>"u")return null;const Vu=Wu=>{if(Wu.key==="ArrowDown")Wu.preventDefault(),Mu(Ku=>zu.length===0?0:(Ku+1)%zu.length);else if(Wu.key==="ArrowUp")Wu.preventDefault(),Mu(Ku=>zu.length===0?0:(Ku-1+zu.length)%zu.length);else if(Wu.key==="Enter"){Wu.preventDefault();const Ku=zu[Ou];Ku&&Ku.isEnabled?.()!==!1&&Hu(Ku)}},Gu=jsxRuntimeExports.jsx("div",{className:"dla-cmdk-backdrop",onClick:Uu,children:jsxRuntimeExports.jsxs("div",{className:"dla-cmdk-panel",role:"dialog","aria-modal":"true","aria-label":"Command palette",onClick:Wu=>Wu.stopPropagation(),children:[jsxRuntimeExports.jsx("div",{className:"dla-cmdk-search",children:jsxRuntimeExports.jsx("input",{ref:Fu,className:"dla-cmdk-input",type:"text",placeholder:"Run a command…","aria-label":"Search commands",autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1,role:"combobox","aria-expanded":!0,"aria-controls":LIST_ID,"aria-autocomplete":"list","aria-activedescendant":zu.length>0?optionId(Ou):void 0,value:Iu,onChange:Wu=>Pu(Wu.target.value),onKeyDown:Vu})}),Bu!==null&&jsxRuntimeExports.jsx("div",{className:"dla-cmdk-error",children:Bu}),jsxRuntimeExports.jsx("ul",{className:"dla-cmdk-list",id:LIST_ID,role:"listbox",children:zu.length===0?jsxRuntimeExports.jsx("li",{className:"dla-cmdk-empty",children:lo.length===0?"No plugin has registered a command yet.":`Nothing matches “${Iu}”.`}):zu.map((Wu,Ku)=>{const Ju=Wu.isEnabled?.()!==!1;return jsxRuntimeExports.jsx("li",{children:jsxRuntimeExports.jsxs("button",{type:"button",className:"dla-cmdk-item",id:optionId(Ku),role:"option","aria-selected":Ku===Ou,"aria-disabled":!Ju,disabled:!Ju,onMouseEnter:()=>Mu(Ku),onClick:()=>{Hu(Wu)},children:[jsxRuntimeExports.jsx("span",{className:"dla-cmdk-mark","aria-hidden":"true",children:Wu.emoji??"·"}),jsxRuntimeExports.jsxs("span",{className:"dla-cmdk-text",children:[jsxRuntimeExports.jsx("span",{className:"dla-cmdk-name",children:Wu.name}),Wu.description&&jsxRuntimeExports.jsx("p",{className:"dla-cmdk-description",children:Wu.description})]}),Du===Wu.id&&jsxRuntimeExports.jsx("span",{className:"dla-cmdk-meta",children:"running…"}),Wu.keybinding&&jsxRuntimeExports.jsx("kbd",{className:"dla-cmdk-key",children:formatKeybinding(Wu.keybinding)}),Wu.category&&jsxRuntimeExports.jsx("span",{className:"dla-cmdk-meta",children:Wu.category})]})},Wu.id)})}),jsxRuntimeExports.jsxs("div",{className:"dla-cmdk-footer",children:[jsxRuntimeExports.jsxs("span",{children:["↑↓ to move · ↵ to run · esc to close ·"," ",jsxRuntimeExports.jsx("kbd",{className:"dla-cmdk-key",children:formatKeybinding(PALETTE_KEYBINDING)})," ","to reopen"]}),jsxRuntimeExports.jsxs("span",{children:[zu.length," of ",lo.length]})]})]})});return reactDomExports.createPortal(Gu,paletteRoot())}const CommandsPlugin={name:"@datalayer/reactor-commands",version:"1.0.0",displayName:"Commands",description:"A command palette: Ctrl-K opens a floating search over every command plugins have registered.",octicon:"command-palette",emoji:"⌘",build(){return{components:[{slot:"root",id:"command-palette",Component:CommandPalette}]}},commands:[{id:"commands.showPalette",name:"Show the command palette",description:"The same thing Ctrl-K does — listed so it is discoverable",emoji:"⌘",category:"Commands",keybinding:PALETTE_KEYBINDING,execute:()=>{document.dispatchEvent(new KeyboardEvent("keydown",{key:"k",ctrlKey:!0,bubbles:!0}))}}]},COMMANDS_PLUGIN_NAME="@datalayer/loop-plugin-commands",DEFAULT_CATEGORY="Workspace",GROUP_EMOJI={Agents:"🤖",Open:"📂",Session:"🧭",Workspace:"🪟"};function LoopCommandBridge({workspace:Au,sync:lo}){const $u=useContributions(LoopCommand);return reactExports.useEffect(()=>{lo($u,Au)},[$u,Au,lo]),null}const LoopCommandsPlugin={name:COMMANDS_PLUGIN_NAME,displayName:"Command palette",description:"Puts the workspace commands in a Ctrl-K palette, beside every plugin that registers one.",octicon:"command-palette",emoji:"⌘",dependencies:[CommandsPlugin,ThemePlugin],build:Au=>{const lo=new Map;let $u="",Ru;const Iu=(Pu,Ou)=>{const Mu=Ou?Pu.map(Du=>`${Du.plugin}:${Du.value.name}`).join("|"):"";if(!(Mu===$u&&Ou===Ru)){$u=Mu,Ru=Ou;for(const Du of lo.values())Du();if(lo.clear(),!!Ou)for(const Du of Pu){const Lu=Du.value,Bu=Lu.group??DEFAULT_CATEGORY;lo.set(Lu.name,Au.registerCommand({id:`loop.${Lu.name}`,name:Lu.description,description:`/${Lu.name}`,emoji:GROUP_EMOJI[Bu]??"💠",category:Bu,keybinding:Lu.keybinding,execute:async()=>{await Lu.run({workspace:Ou,argv:""})}}))}}};return{components:[{id:"loop-command-bridge",slot:LoopSlots.status,Component:({workspace:Pu})=>jsxRuntimeExports.jsx(LoopCommandBridge,{workspace:Pu,sync:Iu})}]}}},MODELS_PLUGIN_NAME="@datalayer/loop-plugin-models",ModelsPlugin={name:MODELS_PLUGIN_NAME,displayName:"Models",description:"Which model answers, from the agentspecs catalog.",octicon:"cpu",emoji:"🧠",contributes:[contribution(LoopCommand,{name:"models",aliases:["model"],description:"Show the models available to this session",group:"Agents",keybinding:"Mod+Alt+M",run:async({workspace:Au})=>{const lo=await fetch(`${Au.serverUrl}/api/v1/configure/models`);if(!lo.ok)return{content:"The model catalogue is unavailable."};const $u=await lo.json();return{content:`${($u.models??[]).filter(Iu=>Iu.available!==!1).length} of ${($u.models??[]).length} models are ready. Pick one under the prompt.`}}},{id:"models"})]},WINDOW_CONTROLS_SLOT="loop.window.controls",WINDOW_ACTIONS_SLOT="loop.window.actions";function WindowFrame({children:Au,title:lo,height:$u,slotProps:Ru={}}){const Iu=useOptionalSlotComponents(WINDOW_ACTIONS_SLOT);return jsxRuntimeExports.jsxs(Box,{position:"relative",borderRadius:"14px",overflow:"hidden",border:"1px solid",borderColor:"border.default",bg:"canvas.default",boxShadow:"0 24px 60px -28px rgba(0, 0, 0, 0.55)",height:$u===void 0?"100%":void 0,display:$u===void 0?"flex":void 0,flexDirection:$u===void 0?"column":void 0,children:[jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",gap:2,px:3,py:2,borderBottom:"1px solid",borderColor:"border.default",bg:"canvas.subtle",flexWrap:"wrap",rowGap:2,flex:"0 0 auto",children:[jsxRuntimeExports.jsx(Box,{display:"flex",alignItems:"center",gap:"6px",mr:1,flexShrink:0,children:jsxRuntimeExports.jsx(ReactorSlot,{slot:WINDOW_CONTROLS_SLOT,props:Ru})}),jsxRuntimeExports.jsx(Box,{minWidth:0,flex:"1 1 auto",children:lo}),Iu.length>0?jsxRuntimeExports.jsx(Box,{display:"flex",alignItems:"center",gap:2,flexShrink:0,ml:"auto",children:jsxRuntimeExports.jsx(ReactorSlot,{slot:WINDOW_ACTIONS_SLOT,props:Ru})}):null]}),jsxRuntimeExports.jsx(Box,{sx:$u===void 0?{flex:"1 1 auto",minHeight:0}:{height:$u,minHeight:0},children:Au})]})}const WINDOW_FRAME_PLUGIN_NAME="@datalayer/loop-plugin-window-frame";function WindowControls(){return jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:["danger.emphasis","attention.emphasis","success.emphasis"].map(Au=>jsxRuntimeExports.jsx(Box,{width:10,height:10,borderRadius:"50%",bg:Au},Au))})}const WindowFramePlugin={name:WINDOW_FRAME_PLUGIN_NAME,displayName:"Window frame",description:"Draws Loop as a window, and opens its title bar to controls and actions.",octicon:"browser",emoji:"🪟",build:()=>({components:[{id:"window-controls",slot:WINDOW_CONTROLS_SLOT,Component:WindowControls},{id:"full-screen",slot:LoopSlots.header,Component:WorkspaceFullScreenAction}]})},DOCUMENT_PLUGIN_NAME="@datalayer/loop-plugin-document",DocumentPlugin={name:DOCUMENT_PLUGIN_NAME,displayName:"Document editor",description:"A rich-text document beside the chat, driven by the agent.",octicon:"file",emoji:"📄",dependencies:[AgentsPlugin],contributionPoints:[LoopDocumentToolbar,LoopOpeningDocument],contributes:[contribution(LoopEditorView,{surfaceId:"document",title:"Document",icon:FileIcon,order:20,canOpen:Au=>Au.sandbox.state==="running",unavailableReason:()=>"Needs a running sandbox",load:()=>__vitePreload(()=>import("./chunks/DocumentView-DwpK2feQ.js"),[],import.meta.url)},{id:"document",order:20}),contribution(LoopCommand,{name:"document",description:"Open the document beside the chat",group:"Open",keybinding:"Mod+Alt+O",run:async({workspace:Au})=>{if(Au.setActiveViewType("chat"),!requestSurface("document"))throw new Error("No chat is on screen to open the document beside.")}},{id:"document"})],build:Au=>(__vitePreload(async()=>{const{createLexicalTools:lo}=await import("./chunks/lexicalHooks-Pqoe8h_O.js");return{createLexicalTools:lo}},[],import.meta.url).then(({createLexicalTools:lo})=>{Au.contribute(LoopFrontendTool,{id:"document-tools",tools:$u=>lo($u.surfaceId)},{id:"document-tools"})},lo=>{console.warn("The document tools could not be loaded",lo)}),{})},DOCUMENT_TOOLBAR_PLUGIN_NAME="@datalayer/loop-plugin-document-toolbar",DocumentToolbarPlugin=defineLazyPlugin({name:DOCUMENT_TOOLBAR_PLUGIN_NAME,displayName:"Document toolbar",description:"Shows what the document’s code blocks run on.",octicon:"circle",emoji:"🔵",activationEvents:[onContributionPoint(LoopDocumentToolbar)],contributionPoints:[LoopDocumentToolbarItem],load:()=>__vitePreload(()=>import("./chunks/plugin-Cf3g-jak.js"),[],import.meta.url)}),NOTEBOOK_PLUGIN_NAME="@datalayer/loop-plugin-notebook",NotebookPlugin={name:NOTEBOOK_PLUGIN_NAME,displayName:"Notebook editor",description:"A notebook beside the chat, on the session’s kernel.",octicon:"rows",emoji:"📓",dependencies:[AgentsPlugin],contributionPoints:[LoopNotebookToolbar,LoopOpeningNotebook],contributes:[contribution(LoopEditorView,{surfaceId:"notebook",title:"Notebook",icon:RowsIcon,order:10,canOpen:Au=>Au.sandbox.state==="running",unavailableReason:()=>"Needs a running sandbox",load:()=>__vitePreload(()=>import("./chunks/NotebookView-BJpTApeL.js"),[],import.meta.url)},{id:"notebook",order:10}),contribution(LoopCommand,{name:"notebook",description:"Open the notebook beside the chat",group:"Open",keybinding:"Mod+Alt+N",run:async({workspace:Au})=>{if(Au.setActiveViewType("chat"),!requestSurface("notebook"))throw new Error("No chat is on screen to open the notebook beside.")}},{id:"notebook"})],build:Au=>(__vitePreload(async()=>{const{createNotebookTools:lo}=await Promise.resolve().then(()=>notebookHooks);return{createNotebookTools:lo}},void 0,import.meta.url).then(({createNotebookTools:lo})=>{Au.contribute(LoopFrontendTool,{id:"notebook-tools",tools:$u=>lo($u.surfaceId)},{id:"notebook-tools"})},lo=>{console.warn("The notebook tools could not be loaded",lo)}),{})},NOTEBOOK_TOOLBAR_PLUGIN_NAME="@datalayer/loop-plugin-notebook-toolbar",NotebookToolbarPlugin=defineLazyPlugin({name:NOTEBOOK_TOOLBAR_PLUGIN_NAME,displayName:"Notebook toolbar",description:"Shows what the notebook is running on, on its toolbar.",octicon:"circle",emoji:"🟢",activationEvents:[onContributionPoint(LoopNotebookToolbar)],contributionPoints:[LoopNotebookToolbarItem],load:()=>__vitePreload(()=>import("./chunks/plugin-DA_NCYQX.js"),[],import.meta.url)}),NotebookExtension=defineExtension({name:"@datalayer/loop-extension-notebook",displayName:"Notebooks",description:"A notebook beside the chat, and the toolbar that reports on it.",octicon:"rows",emoji:"📓",plugins:[NotebookPlugin,NotebookToolbarPlugin]}),DocumentExtension=defineExtension({name:"@datalayer/loop-extension-document",displayName:"Documents",description:"A rich-text document beside the chat, and the toolbar that reports on it.",octicon:"file",emoji:"📄",plugins:[DocumentPlugin,DocumentToolbarPlugin]}),NO_TURN$5=signal$2({id:0,status:"idle"}),MAX_HEIGHT=168;function Thinking(){return jsxRuntimeExports.jsxs(Box,{as:"span","aria-label":"The agent is thinking",display:"inline-flex",gap:"4px",alignItems:"center",sx:{height:"1.5em","& > i":{width:5,height:5,borderRadius:"50%",bg:"fg.muted",animation:"loop-turn-dot 1.2s ease-in-out infinite"},"& > i:nth-of-type(2)":{animationDelay:"0.15s"},"& > i:nth-of-type(3)":{animationDelay:"0.3s"},"@keyframes loop-turn-dot":{"0%, 80%, 100%":{opacity:.25},"40%":{opacity:1}}},children:[jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("i",{}),jsxRuntimeExports.jsx("i",{})]})}function TurnPanel({footer:Au="full"}){const lo=useContributions(LoopChatTurn),$u=useSignalValue$1(lo[0]?.value.turn??NO_TURN$5),Ru=useSignalValue$1(pageLayoutSheet),Iu=reactExports.useRef(null),[Pu,Ou]=reactExports.useState(null),[Mu,Du]=reactExports.useState(!1);reactExports.useEffect(()=>{const ju=Iu.current;ju&&(ju.scrollTop=ju.scrollHeight)},[$u.assistant]),reactExports.useEffect(()=>{if(!Mu)return;const ju=window.setTimeout(()=>Du(!1),1400);return()=>window.clearTimeout(ju)},[Mu]);const Lu=reactExports.useCallback(async()=>{const ju=[$u.user,$u.assistant].filter(Boolean).join(`
|
|
4015
4015
|
|
|
4016
4016
|
`);await navigator.clipboard?.writeText(ju),Du(!0)},[$u.user,$u.assistant]);if(Ru==="panel"||$u.status==="idle"||!$u.user||Pu===$u.id)return null;const Bu=$u.status==="thinking"||$u.status==="streaming";return jsxRuntimeExports.jsxs(Box,{"data-turn-panel":"",borderTop:"1px solid",borderColor:"border.muted",px:3,pt:2,pb:Au==="none"?2:1,display:"flex",flexDirection:"column",gap:2,bg:"canvas.default",children:[jsxRuntimeExports.jsx(Box,{display:"flex",justifyContent:"flex-end",children:jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:0,lineHeight:1.45,px:2,py:1,borderRadius:"10px",bg:"accent.subtle",color:"fg.default",maxWidth:"85%",overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:$u.user})}),jsxRuntimeExports.jsxs(Box,{display:"flex",gap:2,alignItems:"flex-start",children:[jsxRuntimeExports.jsx(Box,{ref:Iu,flex:"1 1 auto",minWidth:0,maxHeight:MAX_HEIGHT,overflowY:"auto",fontSize:0,lineHeight:1.5,color:$u.assistant?"fg.default":"fg.muted",whiteSpace:$u.assistant?"normal":"pre-wrap",overflowWrap:"anywhere",children:$u.assistant?jsxRuntimeExports.jsx(Box,{sx:{...streamdownMarkdownStyles,fontSize:0},children:jsxRuntimeExports.jsx(_o$1,{rehypePlugins:REHYPE_PLUGINS_WITHOUT_HTML,children:normalizeAssistantMarkdown($u.assistant)})}):$u.activity?jsxRuntimeExports.jsx(Text$3,{sx:{color:"fg.muted",fontStyle:"italic"},children:$u.activity}):Bu?jsxRuntimeExports.jsx(Thinking,{}):$u.status==="error"?"The agent could not answer.":"Done — the result is in the page."}),jsxRuntimeExports.jsx(IconButton,{icon:CommentDiscussionIcon,size:"small",variant:"invisible","aria-label":"Open the conversation",onClick:openPagePanel,sx:{color:"fg.muted",flexShrink:0}})]}),$u.assistant&&$u.activity?jsxRuntimeExports.jsx(Text$3,{sx:{fontSize:0,color:"fg.muted",fontStyle:"italic"},children:$u.activity}):null,Au==="full"?jsxRuntimeExports.jsx(TurnFooter,{usage:$u.usage,live:Bu,latest:!0,padding:0,onCopy:Lu,onRemove:()=>Ou($u.id)}):Au==="actions"?jsxRuntimeExports.jsxs(Box,{display:"flex",justifyContent:"flex-end",gap:1,mt:-1,children:[jsxRuntimeExports.jsx(IconButton,{icon:Mu?CheckIcon:CopyIcon,size:"small",variant:"invisible","aria-label":Mu?"Copied":"Copy this turn",onClick:()=>{Lu()},sx:{color:"fg.muted"}}),jsxRuntimeExports.jsx(IconButton,{icon:XIcon,size:"small",variant:"invisible","aria-label":"Dismiss until the next turn",onClick:()=>Ou($u.id),sx:{color:"fg.muted"}})]}):null]})}const SPLIT_DEFAULT_SHARE=.4,SPLIT_MIN_SHARE=.2,SPLIT_MAX_SHARE=.8,SPLIT_KEY_STEP=.05;function clampSplitShare(Au){return Number.isFinite(Au)?Math.min(SPLIT_MAX_SHARE,Math.max(SPLIT_MIN_SHARE,Au)):SPLIT_DEFAULT_SHARE}function splitShareForKey(Au,lo){switch(lo){case"ArrowLeft":return clampSplitShare(Au-SPLIT_KEY_STEP);case"ArrowRight":return clampSplitShare(Au+SPLIT_KEY_STEP);case"Home":return SPLIT_MIN_SHARE;case"End":return SPLIT_MAX_SHARE;default:return null}}function SplitLayout({editors:Au,hasEditor:lo,transcript:$u,prompt:Ru,chips:Iu,picker:Pu,transient:Ou}){const[Mu,Du]=reactExports.useState(SPLIT_DEFAULT_SHARE),Lu=reactExports.useRef(null),Bu=reactExports.useRef(!1),ju=reactExports.useCallback(Gu=>{const Wu=Lu.current?.getBoundingClientRect();return!Wu||Wu.width<=0?null:clampSplitShare((Gu-Wu.left)/Wu.width)},[]),Fu=Gu=>{Bu.current=!0,Gu.currentTarget.setPointerCapture?.(Gu.pointerId),Gu.preventDefault()},zu=Gu=>{if(!Bu.current)return;const Wu=ju(Gu.clientX);Wu!==null&&Du(Wu)},Uu=Gu=>{Bu.current=!1,Gu.currentTarget.releasePointerCapture?.(Gu.pointerId)},Hu=Gu=>{const Wu=splitShareForKey(Mu,Gu.key);Wu!==null&&(Gu.preventDefault(),Du(Wu))},Vu=Math.round(Mu*100);return jsxRuntimeExports.jsxs(Box,{"data-testid":"loop-split-layout",flex:"1 1 auto",minHeight:0,display:"flex",flexDirection:"column",children:[Pu,jsxRuntimeExports.jsxs(Box,{ref:Lu,flex:"1 1 auto",minHeight:0,display:"flex",position:"relative",overflow:"hidden",children:[jsxRuntimeExports.jsxs(Box,{"data-testid":"loop-split-conversation",flex:lo?`0 0 ${Vu}%`:"1 1 auto",minWidth:0,minHeight:0,display:"flex",flexDirection:"column",ml:lo?"-1px":0,children:[$u,Iu,Ru]}),lo?jsxRuntimeExports.jsx(Box,{role:"separator","aria-orientation":"vertical","aria-label":"Resize the conversation and the page","aria-valuemin":Math.round(SPLIT_MIN_SHARE*100),"aria-valuemax":Math.round(SPLIT_MAX_SHARE*100),"aria-valuenow":Vu,tabIndex:0,onPointerDown:Fu,onPointerMove:zu,onPointerUp:Uu,onPointerCancel:Uu,onKeyDown:Hu,flex:"0 0 7px",mx:"-3px",zIndex:1,cursor:"col-resize",display:"flex",justifyContent:"center",outline:"none",touchAction:"none",sx:{"&::before":{content:'""',width:"1px",height:"100%",bg:"border.default"},"&:hover::before, &:focus-visible::before":{width:"3px",bg:"accent.emphasis"}}}):null,jsxRuntimeExports.jsx(Box,{"data-testid":"loop-split-page",sx:lo?{flex:"1 1 0",minWidth:0,minHeight:0,display:"flex",...paneOpening("right")}:{position:"absolute",inset:0,visibility:"hidden",pointerEvents:"none",zIndex:-1},children:Au})]}),Ou]})}const LOOP_PAGE_LAYOUT_PLUGIN_NAME="@datalayer/loop-plugin-page-layout",NO_TURN$4=signal$2({id:0,status:"idle"}),pageLayoutChatMode=signal$2("floating-draggable"),promptStance=signal$2("floating-top");let floatingStance="floating-top";const PAGE_LAYOUT_DISABLED_MODES=["assistant"];function pageLayoutForChatMode(Au){switch(Au){case"sidebar":return{bandMode:"panel",panelMode:"docked"};case"floating":return{bandMode:"panel",panelMode:"overlay"};case"floating-small":return{bandMode:"panel",panelMode:"popup"};default:return{bandMode:"floating",panelMode:"docked"}}}function setPageLayoutChatMode(Au){pageLayoutChatMode.value=Au;const{bandMode:lo}=pageLayoutForChatMode(Au);promptStance.value=lo==="floating"?floatingStance:"docked-top",lo==="panel"&&openPagePanel()}function ChatModeAction(){const Au=useSignalValue$1(pageLayoutChatMode);return jsxRuntimeExports.jsx(ChatViewModeToggle,{value:Au,onChange:setPageLayoutChatMode,disabledModes:PAGE_LAYOUT_DISABLED_MODES})}function LoopPageLayout({parts:Au,promptMode:lo,pageSize:$u}){const Ru=useContributions(LoopChatTurn),Iu=useSignalValue$1(Ru[0]?.value.turn??NO_TURN$4),Pu=useSignalValue$1(pageLayoutChatMode),Ou=lo==="floating"?pageLayoutForChatMode(Pu):{bandMode:"docked",panelMode:"docked"};return jsxRuntimeExports.jsx(PageLayout,{page:Au.editors,hasPage:Au.hasEditor,panel:Au.transcript,band:Au.prompt,chips:Au.chips,picker:Au.picker,transient:Au.transient,activity:Iu.activity,bandMode:Ou.bandMode,panelMode:Ou.panelMode,pageSize:$u})}function ConversationToggle(){return jsxRuntimeExports.jsx(PagePanelToggle,{panelName:"conversation",icon:CommentDiscussionIcon,sx:{order:2}})}const LoopPageLayoutPlugin={name:LOOP_PAGE_LAYOUT_PLUGIN_NAME,config:{arrangement:"page",turnPanel:"below",turnPanelFooter:"full",prompt:"docked",promptAnchor:"top",pageSize:void 0},displayName:"Page layout",description:"The editor — or, in the chat view, the conversation — on a centred sheet, the prompt docked above it at the same width or floating over it as a draggable card, the current turn under the prompt, the conversation in a side panel; or, split, the conversation and the work side by side with a hairline to drag.",octicon:"file",emoji:"📄",build:({config:Au,...lo})=>{if(Au.arrangement==="split")return lo.contribute(LoopChatLayout,{id:"split-layout",prompt:"docked",Component:SplitLayout},{id:"split-layout"}),{components:[]};const $u=Au.prompt,Ru=Au.pageSize;floatingStance=Au.promptAnchor==="bottom"?"floating-bottom":"floating-top",$u==="floating"&&(promptStance.value=floatingStance);const Iu=Pu=>jsxRuntimeExports.jsx(LoopPageLayout,{parts:Pu,promptMode:$u,pageSize:Ru});if(lo.contribute(LoopChatLayout,{id:"page-layout",prompt:$u==="floating"?floatingStance:"docked-top",promptStance:$u==="floating"?promptStance:void 0,Component:Iu},{id:"page-layout"}),Au.turnPanel!=="none"){const Pu=Au.turnPanelFooter,Ou=()=>jsxRuntimeExports.jsx(TurnPanel,{footer:Pu});lo.contribute(LoopPromptPanel,{id:"page-layout-turn",placement:Au.turnPanel,order:0,Component:Ou},{id:"page-layout-turn"})}return{components:[{id:"page-layout-conversation-toggle",slot:LoopSlots.header,Component:ConversationToggle},...$u==="floating"?[{id:"page-layout-chat-mode",slot:LoopSlots.promptAction,Component:ChatModeAction}]:[]]}}};function loopPlugins(Au={}){const{serverUrl:lo,target:$u="browser",defaultEditor:Ru,showViewSelector:Iu=!0,hideChatHeader:Pu=!1,chatHeaderButtons:Ou=!1,promptPlacement:Mu,autoFocusPrompt:Du=!0,suggestionLabels:Lu=!0,fullScreenTopOffset:Bu=0,showAgentVariants:ju=!1,agentSummary:Fu=!0,teamId:zu,teamPicker:Uu=!0,pageLayout:Hu=!1,pageLayoutArrangement:Vu="page",pageLayoutTurnPanel:Gu="below",pageLayoutPrompt:Wu="docked",pageLayoutPromptAnchor:Ku="top",pageLayoutSize:Ju,pageLayoutTurnPanelFooter:Yu="full",localAgent:Xu,localAgentSpec:ed,datalayerAgentSpecId:td,datalayerCreatePayload:nd,datalayerVisitors:od,datalayerKept:sd,embedToken:ad,targetFixed:pd,themeVariant:gd,themeOverrides:_d,colorMode:yd,presence:bd,showTokenUsage:Sd,voice:Ed,thread:cd,floatingPrompt:dd=!1,editorSelector:md=!1,editors:ld=!0,conversation:hd=!0,commandPalette:vd=!1,pluginsPanel:wd=!1,windowFrame:kd=!1,firstPromptHook:Rd}=Au,Od=Ru??(ld?"notebook":"none");return hd?[configurePlugin(ChatPlugin,{defaultSurface:Od,showSurfaceSelector:ld&&Iu&&!md,hideHeader:Pu,headerButtons:{newChat:Ou,clear:Ou},promptPlacement:dd?"floating":Mu,autoFocusPrompt:Du,suggestionLabels:Lu,fullScreenTopOffset:Bu,themeVariant:gd,themeOverrides:_d,colorMode:yd,presence:bd,showTokenUsage:Sd,...Ed?{voice:Ed}:{},...cd?{thread:cd}:{}}),configurePlugin(InputPromptPlugin,{firstPromptHook:Rd}),ChatHeaderPlugin,A2uiSurfacePlugin,PapSignInPlugin,ShieldDisplaysPlugin,ChatViewPlugin,...ld?[NotebookViewPlugin,DocumentViewPlugin]:[],configurePlugin(AgentsPlugin,{serverUrl:lo,target:$u,datalayerAgentSpecId:td,datalayerCreatePayload:nd,datalayerVisitors:od,datalayerKept:sd,embedToken:ad,targetFixed:pd,showAgentVariants:ju,showAgentSummary:Fu,teamId:zu,showTeamPicker:Uu,localAgent:Xu??(ed?{createPayload:{description:`Local agent from the ${ed} spec`,agent_library:"pydantic-ai",agent_spec_id:ed,enable_codemode:!1}}:void 0)}),...ld?[NotebookExtension,DocumentExtension]:[],A2uiPlugin,AgentspecsPlugin,ModelsPlugin,ThemePlugin,SubagentActivityPlugin,configurePlugin(ShellPlugin,{defaultEditor:Od,showSelector:ld&&md}),...dd?[PromptPlugin]:[],...Hu?[configurePlugin(LoopPageLayoutPlugin,{arrangement:Vu,turnPanel:Gu,turnPanelFooter:Yu,prompt:Wu,promptAnchor:Ku,pageSize:Ju})]:[],...vd?[LoopCommandsPlugin]:[],...wd?[PluginsPanelPlugin]:[],...kd?[WindowFramePlugin]:[]]:[ThemePlugin,configurePlugin(ShellPlugin,{defaultEditor:"none",showSelector:!1}),...vd?[LoopCommandsPlugin]:[],...wd?[PluginsPanelPlugin]:[],...kd?[WindowFramePlugin]:[]]}function LoopEmbed({agentId:Au="",showHeader:lo=!1,chatHeaderActions:$u,headerActions:Ru,headerContainer:Iu,frameTitle:Pu,frameHeight:Ou,sidebarRail:Mu=!1,plugins:Du=[],...Lu}){const Bu=reactExports.useRef(Lu.firstPromptHook);Bu.current=Lu.firstPromptHook;const ju=reactExports.useMemo(()=>buildLoopReactor([...loopPlugins({...Lu,windowFrame:Lu.windowFrame||Pu!==void 0,firstPromptHook:()=>Bu.current?.()}),...Du]),[Lu.serverUrl,Lu.target,Lu.datalayerAgentSpecId,Lu.targetFixed,Lu.themeVariant,JSON.stringify(Lu.themeOverrides??null),Lu.colorMode,Lu.presence?.name,Lu.presence?.face,Lu.presence?.welcome,Lu.presence?.paused,Lu.showTokenUsage,JSON.stringify({...Lu.voice??{},engines:void 0,token:void 0}),Lu.thread?.id,JSON.stringify(Lu.datalayerCreatePayload??null),JSON.stringify(Lu.datalayerVisitors??null),Lu.datalayerKept?.url,Lu.embedToken,Lu.defaultEditor,Lu.showViewSelector,Lu.hideChatHeader,Lu.chatHeaderButtons,Lu.promptPlacement,Lu.autoFocusPrompt,Lu.suggestionLabels,Lu.fullScreenTopOffset,Lu.showAgentVariants,Lu.agentSummary,Lu.teamId,Lu.teamPicker,Lu.pageLayout,Lu.pageLayoutTurnPanel,Lu.pageLayoutTurnPanelFooter,Lu.pageLayoutPrompt,Lu.pageLayoutPromptAnchor,Lu.pageLayoutSize?.format,Lu.pageLayoutSize?.width,Lu.pageLayoutSize?.height,Lu.localAgentSpec,Lu.floatingPrompt,Lu.editorSelector,Lu.editors,Lu.conversation,Lu.commandPalette,Lu.pluginsPanel,Lu.windowFrame,Pu!==void 0,Du]);useReactor(ju);const Fu=jsxRuntimeExports.jsx(LoopWorkspace,{serverUrl:Lu.serverUrl??"",agentId:Au,reactor:ju,manageReactor:!1,showViewSelector:Lu.showViewSelector,showHeader:lo,chatHeaderActions:$u,headerActions:Ru,headerContainer:Iu,sidebarRail:Mu});return jsxRuntimeExports.jsx(QueryClientProvider,{client:internalQueryClient,children:Pu!==void 0?jsxRuntimeExports.jsx(WindowFrame,{title:Pu,height:Ou,children:Fu}):jsxRuntimeExports.jsx(Box,{height:"100%",minHeight:0,width:"100%",flex:"1 1 auto",minWidth:0,children:Fu})})}const RECORD_KIND_WORDS={session:"Session",tool_call:"Tool call",decision:"Rule",check:"Check",approval:"Approval",output:"Answer",feedback:"Feedback",turn:"Turn",run:"Working",notification:"Notification"};function entryOf(Au){return{uid:String(Au.uid??""),sessionUid:String(Au.session_uid??""),deploymentUid:String(Au.deployment_uid??""),version:Number(Au.version)||0,kind:String(Au.kind??"output"),summary:String(Au.summary??""),payload:Au.payload&&typeof Au.payload=="object"?Au.payload:{},createdAt:String(Au.created_at??"")}}function runEndOf(Au){const lo=Au.kind==="output"?Au.payload.status:void 0;return typeof lo=="string"&&lo in RUN_END_WORDS?lo:""}function entrySaid(Au){return Au.summary||RUN_END_WORDS[runEndOf(Au)]||""}function sessionSentence(Au){const lo=Au.filter(Ou=>Ou.kind==="tool_call").length,$u=Au.filter(Ou=>Ou.kind==="check"),Ru=Au.map(runEndOf).filter(Boolean),Iu=Ru.filter(Ou=>Ou==="answered").length,Pu=[lo===0?"No tool called":`${lo} tool call${lo===1?"":"s"}`];return $u.length&&Pu.push(`${$u.length} step${$u.length===1?"":"s"} a check did not let pass`),Ru[Ru.length-1]==="stopped"?Pu.push("stopped"):Iu&&Pu.push(`${Iu} answer${Iu===1?"":"s"}`),`${Pu.join(", ")}.`}async function read(Au,lo,$u){if(!Au.aiAgentsUrl)throw new Error("The record service is not configured.");const Ru=await fetch(`${Au.aiAgentsUrl.replace(/\/+$/,"")}/api/ai-agents/v1/apps${lo}`,{headers:Au.token?{Authorization:`Bearer ${Au.token}`}:{}}),Iu=await Ru.json().catch(()=>({}));if(!Ru.ok||Iu.success===!1)throw new Error(`${$u}: ${String(Iu.detail??Ru.status)}`);return Iu}async function listSessions(Au,lo,$u=20,Ru=!1){const Iu=await read(Au,`/sessions?app_uid=${encodeURIComponent(lo)}&limit=${$u}${Ru===null?"":`&tests=${Ru}`}`,"The sessions could not be read");return Array.isArray(Iu.sessions)?Iu.sessions.map(entryOf):[]}async function readSession(Au,lo){const $u=await read(Au,`/records?session_uid=${encodeURIComponent(lo)}&limit=500`,"The session could not be read");return Array.isArray($u.entries)?$u.entries.map(entryOf).filter(Ru=>Ru.kind!=="run"):[]}const APP_ACTIVITY_WORDS={title:"Activity",unsaved:"Recorded once it is saved on Datalayer: each session there — its address, or its Preview on Datalayer — is listed here.",signedOut:"Its activity is its owner’s: sign in to Datalayer to read it.",none:"Nothing yet: a session on Datalayer — its address, or the Preview on Datalayer — is recorded here."},NO_TURN$3=signal$2({id:0,status:"idle"});function useRead(Au,lo,$u=!0){const[Ru,Iu]=reactExports.useState({loading:$u});return reactExports.useEffect(()=>{if(!$u)return;let Pu=!1;return Iu(Ou=>({...Ou,loading:!0})),Au().then(Ou=>!Pu&&Iu({value:Ou,loading:!1}),Ou=>!Pu&&Iu({error:Ou instanceof Error?Ou.message:String(Ou),loading:!1})),()=>{Pu=!0}},[lo,$u]),Ru}function Session({context:Au,session:lo}){const[$u,Ru]=reactExports.useState(!1),Iu=useRead(()=>readSession(Au,lo.sessionUid),`${lo.sessionUid}:${Au.token}`,$u);return jsxRuntimeExports.jsxs(Box,{as:"details",onToggle:Pu=>Ru(Pu.currentTarget.open),borderTop:"1px solid",borderColor:"border.muted",py:2,children:[jsxRuntimeExports.jsxs(Box,{as:"summary",cursor:"pointer",fontSize:1,children:[lo.createdAt?jsxRuntimeExports.jsx(RelativeTime,{datetime:lo.createdAt}):"A session",lo.version?` · version ${lo.version}`:"",Iu.value?` · ${sessionSentence(Iu.value)}`:""]}),$u?Iu.loading?jsxRuntimeExports.jsx(StyledSpinner,{size:"small"}):Iu.error?jsxRuntimeExports.jsx(Text$3,{role:"alert",sx:{fontSize:1},children:Iu.error}):jsxRuntimeExports.jsx(Box,{as:"ol",pl:3,mt:2,mb:0,fontSize:1,children:(Iu.value??[]).map(Pu=>jsxRuntimeExports.jsxs(Box,{as:"li",mb:1,children:[jsxRuntimeExports.jsx(Label,{sx:{mr:2},children:RECORD_KIND_WORDS[Pu.kind]??Pu.kind}),entrySaid(Pu)]},Pu.uid))}):null]})}function AppActivity({appUid:Au}){const lo=useIAMStore(ju=>ju.token)??"",$u=useCoreStore(ju=>ju.configuration)?.aiAgentsUrl??"",Ru=useContributions(LoopChatTurn),Iu=useSignalValue$1(Ru[0]?.value.turn??NO_TURN$3),Pu=Iu.status!=="thinking"&&Iu.status!=="streaming",[Ou,Mu]=reactExports.useState(0);reactExports.useEffect(()=>{Pu&&Mu(Iu.id)},[Pu,Iu.id]);const Du={aiAgentsUrl:$u,token:lo},Lu=!!(Au&&lo),Bu=useRead(()=>listSessions(Du,Au??""),`${Au}:${lo}:${$u}:${Ou}`,Lu);return jsxRuntimeExports.jsxs(Box,{"data-testid":"app-activity",children:[jsxRuntimeExports.jsx(Heading$2,{as:"h3",sx:{fontSize:2,mb:2},children:APP_ACTIVITY_WORDS.title}),Au?lo?Bu.loading&&!Bu.value?jsxRuntimeExports.jsx(StyledSpinner,{size:"small"}):Bu.error?jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{fontSize:1,color:"fg.muted",m:0},children:Bu.error}):(Bu.value??[]).length===0?jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{fontSize:1,color:"fg.muted",m:0},children:APP_ACTIVITY_WORDS.none}):(Bu.value??[]).map(ju=>jsxRuntimeExports.jsx(Session,{context:Du,session:ju},ju.uid)):jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{fontSize:1,color:"fg.muted",m:0},children:APP_ACTIVITY_WORDS.signedOut}):jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{fontSize:1,color:"fg.muted",m:0},children:APP_ACTIVITY_WORDS.unsaved})]})}const APP_ACTIVITY_PLUGIN_NAME="@datalayer/loop-plugin-app-activity";function defineAppActivityPlugin(Au,lo){function $u(){return jsxRuntimeExports.jsx(AppActivity,{appUid:lo})}return{name:`${APP_ACTIVITY_PLUGIN_NAME}-${Au.id}`,displayName:`${Au.name}: activity`,description:`What ${Au.name} did, session by session, from its record.`,octicon:"pulse",build:()=>({components:[{id:"app-activity",slot:LoopSlots.sidebar,order:20,Component:$u,rail:{label:"Activity",icon:PulseIcon}}]})}}const APP_PANEL_WIDTH=380;function elementsByPlace(Au){const lo=Au.filter($u=>$u.where==="page");return{panels:Au.filter($u=>$u.where==="panel"),page:lo.length>0?lo[lo.length-1]:null}}function ElementBody({element:Au,send:lo}){return jsxRuntimeExports.jsx(AnswerShowsView,{display:Au.shows,send:($u,Ru)=>lo!==void 0&&!lo($u,Ru)})}function ElementHeader({element:Au}){return jsxRuntimeExports.jsxs(Box,{display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,mb:2,children:[jsxRuntimeExports.jsx(Text$3,{as:"h2",sx:{fontSize:2,fontWeight:"bold",m:0},children:Au.title}),jsxRuntimeExports.jsx(IconButton,{icon:XIcon,variant:"invisible",size:"small","aria-label":`Close ${Au.title}`,onClick:()=>closeLoopElement(Au.id)})]})}function AppElements({workspace:Au}){const lo=reactExports.useSyncExternalStore(onLoopElements,openLoopElements,openLoopElements),{panels:$u,page:Ru}=elementsByPlace(lo),Iu=Au?.viewControls.send;return $u.length===0&&Ru===null?null:jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[$u.length>0?jsxRuntimeExports.jsx(Box,{as:"aside","aria-label":"Side panel",position:"absolute",top:0,right:0,bottom:0,width:`min(${APP_PANEL_WIDTH}px, 100%)`,zIndex:1,overflowY:"auto",borderLeft:"1px solid",borderColor:"border.default",bg:"canvas.subtle",boxShadow:"shadow.medium",p:3,display:"flex",flexDirection:"column",gap:3,children:$u.map(Pu=>jsxRuntimeExports.jsxs(Box,{as:"section","aria-label":Pu.title,children:[jsxRuntimeExports.jsx(ElementHeader,{element:Pu}),jsxRuntimeExports.jsx(ElementBody,{element:Pu,send:Iu})]},Pu.id))}):null,Ru!==null?jsxRuntimeExports.jsxs(Box,{role:"dialog","aria-label":Ru.title,position:"absolute",inset:0,zIndex:2,overflowY:"auto",bg:"canvas.default",p:[3,4],children:[jsxRuntimeExports.jsx(ElementHeader,{element:Ru}),jsxRuntimeExports.jsx(ElementBody,{element:Ru,send:Iu})]}):null]})}const QUESTION_DISPLAY_TYPE="application/vnd.datalayer.loop.question+json",SchemaForm=reactExports.lazy(()=>__vitePreload(()=>import("./chunks/SchemaForm-CE5NfpBU.js"),[],import.meta.url));function questionOf(Au){const lo=Au.data??{},$u=lo.kind;if(Au.type!==QUESTION_DISPLAY_TYPE||$u!=="text"&&$u!=="choice"&&$u!=="file"&&$u!=="form"||typeof lo.prompt!="string")throw new Error(`Display ${Au.id} is not a question`);const Ru=Iu=>Array.isArray(Iu)?Iu.filter(Pu=>typeof Pu=="string"):[];return{kind:$u,prompt:lo.prompt,options:Ru(lo.options),accept:Ru(lo.accept),form:lo.form&&typeof lo.form=="object"?lo.form:{},answered:typeof lo.answered=="string"?lo.answered:null,answerable:(Au.actions??[]).some(Iu=>Iu.name===ANSWER_ACTION)}}function QuestionView({display:Au,act:lo,upload:$u}){const Ru=questionOf(Au),[Iu,Pu]=reactExports.useState(""),[Ou,Mu]=reactExports.useState(null),Du=Bu=>{if(!lo){Mu("The chat cannot take an answer here.");return}Mu(null),Promise.resolve(lo({action:ANSWER_ACTION,payload:{value:Bu}})).catch(ju=>Mu(ju instanceof Error?ju.message:String(ju)))};if(Ru.answered!==null)return jsxRuntimeExports.jsxs(Text$3,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:["Answered: ",Ru.answered]});const Lu=Ru.answerable&&!!lo;return jsxRuntimeExports.jsxs(Box$1,{display:"flex",flexDirection:"column",gap:2,"data-question-kind":Ru.kind,children:[Ru.kind==="choice"?jsxRuntimeExports.jsx(Box$1,{display:"flex",gap:2,flexWrap:"wrap",children:Ru.options.map(Bu=>jsxRuntimeExports.jsx(ButtonComponent,{size:"small",disabled:!Lu,onClick:()=>Du(Bu),children:Bu},Bu))}):null,Ru.kind==="text"?jsxRuntimeExports.jsxs(Box$1,{as:"form",display:"flex",gap:2,onSubmit:Bu=>{Bu.preventDefault(),Iu.trim()&&Du(Iu.trim())},children:[jsxRuntimeExports.jsx(TextInput$1,{"aria-label":Ru.prompt,value:Iu,disabled:!Lu,onChange:Bu=>Pu(Bu.target.value)}),jsxRuntimeExports.jsx(ButtonComponent,{type:"submit",size:"small",disabled:!Lu||!Iu.trim(),children:"Answer"})]}):null,Ru.kind==="form"?jsxRuntimeExports.jsx(reactExports.Suspense,{fallback:null,children:jsxRuntimeExports.jsx(SchemaForm,{schema:Ru.form,disabled:!Lu,onSubmit:({formData:Bu})=>Du(Bu??{})})}):null,Ru.kind==="file"?jsxRuntimeExports.jsx("input",{type:"file","aria-label":Ru.prompt,accept:Ru.accept.join(",")||void 0,disabled:!Lu||!$u,onChange:Bu=>{const ju=Bu.target.files?.[0];if(ju){if(!$u){Mu("The chat cannot take a file here.");return}Mu(null),$u(ju).then(Fu=>Du(Fu)).catch(Fu=>Mu(Fu instanceof Error?Fu.message:String(Fu)))}}}):null,Ou?jsxRuntimeExports.jsx(Text$3,{as:"p",sx:{color:"danger.fg",fontSize:1,m:0},children:Ou}):null]})}const APP_ELEMENTS_PLUGIN_NAME="@datalayer/loop-plugin-app-elements",AppElementsPlugin={name:APP_ELEMENTS_PLUGIN_NAME,displayName:"Side panel and pages",description:"What an application opens beside the conversation: a side panel, or a page of its own.",octicon:"sidebar-expand",contributes:[contribution(Renderers,defineRenderer({type:QUESTION_DISPLAY_TYPE,component:QuestionView}),{id:"app-elements:question"})],build:()=>({components:[{id:"app-elements",slot:LoopSlots.root,Component:AppElements}]}),register:()=>clearLoopElements},appComponentsPluginName=Au=>`@datalayer/loop-plugin-app-components-${Au}`,hasCustomComponents=Au=>(Au.interface.customComponents??[]).length>0;function defineAppComponentsPlugin(Au,lo){const $u=Au.interface.customComponents??[];if($u.length===0)throw new Error(`“${Au.name}” has no component of its own to contribute.`);return{name:appComponentsPluginName(Au.id),displayName:`${Au.name}'s components`,description:`The components ${Au.name}'s developer wrote: ${$u.map(Ru=>Ru.name).join(", ")}.`,octicon:"apps",contributes:$u.flatMap(Ru=>[contribution(LoopCanvasBlock,{id:Ru.name,ui:`app:${Au.id}`,component:customComponentEntry(Ru,Au.version)},{id:Ru.name}),contribution(LoopA2uiComponent,{id:Ru.name,app:Au.id,implementation:customImplementation(Ru,Au.version,lo,Au.id)},{id:Ru.name})])}}const COMPUTER_PARTS=["browse","files","shell"],COMPUTER_PART_TOOLS={browse:["open_page","read_page","page_screenshot","click_on_page","type_on_page"],files:["list_computer_files","read_computer_file","write_computer_file"],shell:["execute_code","run_skill_script"]},COMPUTER_WORDS={title:"Computer",part:{browse:"Browse",files:"Files",shell:"Shell"},on:"on",off:"off",none:"It has no computer: browse, files and shell are all off. Turn one on in its permissions to give it one.",offSaid:Au=>`Off, so its agent is given no tool for it: ${Au.join(", ")}.`,browser:"Browser",noBrowser:"No browser is installed on its computer.",noPage:"Its browser has opened no page yet.",pageAlt:Au=>`The page its browser shows: ${Au}`,clickToAct:"Click on the page to click there; with the page selected, what you type goes to it.",typeOnPage:"Text to type on the page",type:"Type",address:"An address to open",open:"Open",scrollUp:"Scroll up",scrollDown:"Scroll down",agentHas:"Its agent has the computer.",youHave:"You have the computer: its agent waits for it until you hand it back.",someoneHas:"Somebody else has taken this computer over.",takeOver:"Take over",handBack:"Hand back",run:"Run",yourCode:"Python to run on its computer",terminal:"What ran on it",nothingRan:"Nothing has run on it yet in this conversation.",files:"Files",notStarted:"Its computer starts when its agent first uses it: no file yet.",emptyDirectory:"Empty.",up:"Up",download:"Download",signedOut:"Its computer is shown once you are signed in to Datalayer."};function computerParts(Au){const lo=Au.permissions?.computer;return{browse:!!lo?.browse,files:!!lo?.files,shell:!!lo?.shell}}const hasComputer=Au=>COMPUTER_PARTS.some(lo=>Au[lo]),partsOff=Au=>COMPUTER_PARTS.filter(lo=>!Au[lo]).map(lo=>COMPUTER_WORDS.part[lo].toLowerCase());function partOf(Au){return COMPUTER_PARTS.find(lo=>COMPUTER_PART_TOOLS[lo].includes(Au))}const OUTPUT_LIMIT=4e3;function outputOf(Au){let lo=Au;if(typeof lo=="string")try{const Ru=JSON.parse(lo);Ru&&typeof Ru=="object"&&!Array.isArray(Ru)&&(lo=Ru)}catch{}let $u;if(lo&&typeof lo=="object"&&!Array.isArray(lo)){const Ru=lo,Iu=[typeof Ru.stdout=="string"?Ru.stdout:Ru.output,Ru.stderr,Ru.error??Ru.execution_error??Ru.code_error].filter(Pu=>typeof Pu=="string"&&Pu.trim()!=="");$u=Iu.length>0?Iu.join(`
|
|
4017
4017
|
`):"stdout"in Ru||"output"in Ru?"":JSON.stringify(lo,null,2)}else $u=typeof lo=="string"?lo:lo==null?"":JSON.stringify(lo,null,2);return $u.length>OUTPUT_LIMIT?`${$u.slice(0,OUTPUT_LIMIT)}
|