@datalayer/agent-runtimes 1.5.23 → 1.5.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist-embed/chunks/{CellSidebarExtension-CDnzN9Cb.js → CellSidebarExtension-B-73cmcQ.js} +1 -1
  2. package/dist-embed/chunks/{ChatView-BjZ993Ch.js → ChatView-CUWE6I5M.js} +3 -3
  3. package/dist-embed/chunks/{DeckComponent-Cb4_dZpN.js → DeckComponent-ymp4My5d.js} +1 -1
  4. package/dist-embed/chunks/{DocumentView-Caxb2xz-.js → DocumentView-i99p_Qzt.js} +1 -1
  5. package/dist-embed/chunks/{EphemeralDocument-DIHjR5l8.js → EphemeralDocument--pV47gPl.js} +1 -1
  6. package/dist-embed/chunks/{EphemeralNotebook-1Rwa3anx.js → EphemeralNotebook-BqccUXGd.js} +1 -1
  7. package/dist-embed/chunks/{ExcalidrawComponent-vJQwgcUt.js → ExcalidrawComponent-DgSMy796.js} +1 -1
  8. package/dist-embed/chunks/{ExcalidrawModal-BDgjdSz2.js → ExcalidrawModal-DFJW9pQh.js} +1 -1
  9. package/dist-embed/chunks/{JupyterLexicalExtension-_7FM5Om8.js → JupyterLexicalExtension-CqDatsgf.js} +5 -5
  10. package/dist-embed/chunks/{KernelVariables-CKIqy599.js → KernelVariables-CS6h5HyK.js} +1 -1
  11. package/dist-embed/chunks/{NotebookToolSurfaces-YAM1bvZS.js → NotebookToolSurfaces-CTLbTvsS.js} +1 -1
  12. package/dist-embed/chunks/{NotebookView-C8RCvsR1.js → NotebookView-BJpTApeL.js} +1 -1
  13. package/dist-embed/chunks/{Output-BWClePP-.js → Output-no9rnFJ7.js} +1 -1
  14. package/dist-embed/chunks/{SandboxDetailsDialog-CDSxIC0-.js → SandboxDetailsDialog-BAv6RMed.js} +1 -1
  15. package/dist-embed/chunks/{SchemaForm-CO_2yGg2.js → SchemaForm-CE5NfpBU.js} +1 -1
  16. package/dist-embed/chunks/{WidgetVariableView--osoOLv8.js → WidgetVariableView-V4DsgfIK.js} +1 -1
  17. package/dist-embed/chunks/{YouTubePlugin-BB7Z7INn.js → YouTubePlugin-CpgyVTwG.js} +1 -1
  18. package/dist-embed/chunks/{ar-SA-G6X2FPQ2-D6Ko4I2x.js → ar-SA-G6X2FPQ2-DwUjDWHp.js} +1 -1
  19. package/dist-embed/chunks/{az-AZ-76LH7QW2-B3UhxnSz.js → az-AZ-76LH7QW2-DROX4pJc.js} +1 -1
  20. package/dist-embed/chunks/{bg-BG-XCXSNQG7-BS-QRZjB.js → bg-BG-XCXSNQG7-DPLzP9Bm.js} +1 -1
  21. package/dist-embed/chunks/{bn-BD-2XOGV67Q-DNg0uIV0.js → bn-BD-2XOGV67Q-CCOU2J2j.js} +1 -1
  22. package/dist-embed/chunks/{ca-ES-6MX7JW3Y-Bn4yHfTY.js → ca-ES-6MX7JW3Y-3RgFapBd.js} +1 -1
  23. package/dist-embed/chunks/{cs-CZ-2BRQDIVT-DUGnyonZ.js → cs-CZ-2BRQDIVT-BJS7ofhJ.js} +1 -1
  24. package/dist-embed/chunks/{da-DK-5WZEPLOC-Is8nybqO.js → da-DK-5WZEPLOC-BHDT0zzh.js} +1 -1
  25. package/dist-embed/chunks/{de-DE-XR44H4JA-D54sMa4L.js → de-DE-XR44H4JA-CWVJKc9t.js} +1 -1
  26. package/dist-embed/chunks/{el-GR-BZB4AONW-CvM3SWat.js → el-GR-BZB4AONW-2z8DB9lI.js} +1 -1
  27. package/dist-embed/chunks/{es-ES-U4NZUMDT-BZDRRuRf.js → es-ES-U4NZUMDT-DzXGWPd4.js} +1 -1
  28. package/dist-embed/chunks/{eu-ES-A7QVB2H4-DAmknI9y.js → eu-ES-A7QVB2H4-CslHE4iE.js} +1 -1
  29. package/dist-embed/chunks/{fa-IR-HGAKTJCU-CQhKri4O.js → fa-IR-HGAKTJCU-CBWUHs2r.js} +1 -1
  30. package/dist-embed/chunks/{fi-FI-Z5N7JZ37-DzEDoP64.js → fi-FI-Z5N7JZ37-MAr8kZMI.js} +1 -1
  31. package/dist-embed/chunks/{fr-FR-RHASNOE6-DiSkyvEB.js → fr-FR-RHASNOE6-BUz3aHQJ.js} +1 -1
  32. package/dist-embed/chunks/{gl-ES-HMX3MZ6V-3AJMzY-I.js → gl-ES-HMX3MZ6V-DvzQmDYv.js} +1 -1
  33. package/dist-embed/chunks/{he-IL-6SHJWFNN-Cuh5an4X.js → he-IL-6SHJWFNN-DKR3cKyQ.js} +1 -1
  34. package/dist-embed/chunks/{hi-IN-IWLTKZ5I-BbeuFB83.js → hi-IN-IWLTKZ5I-C4tyBNwa.js} +1 -1
  35. package/dist-embed/chunks/{hu-HU-A5ZG7DT2-C1OMfhob.js → hu-HU-A5ZG7DT2-C8BnBgH5.js} +1 -1
  36. package/dist-embed/chunks/{id-ID-SAP4L64H-BzKILJTZ.js → id-ID-SAP4L64H-Bn1hY5OS.js} +1 -1
  37. package/dist-embed/chunks/{index-CPpm1tqJ.js → index-5N0EOEHV.js} +1 -1
  38. package/dist-embed/chunks/{index-f418CYn7.js → index-BKB97UwL.js} +1 -1
  39. package/dist-embed/chunks/{index-CyQgE_Es.js → index-BN8Bbau-.js} +2 -2
  40. package/dist-embed/chunks/{index-CKFrz1es.js → index-BTdq_niO.js} +1 -1
  41. package/dist-embed/chunks/{index-D4QM3qbA.js → index-Bhzj1Pnv.js} +1 -1
  42. package/dist-embed/chunks/{index-BMandbJB.js → index-BzMt3uYX.js} +1 -1
  43. package/dist-embed/chunks/{index-DLimRfHQ.js → index-CCRwowMu.js} +1 -1
  44. package/dist-embed/chunks/{index-BFdE0KFI.js → index-CEbnhuIo.js} +1 -1
  45. package/dist-embed/chunks/{index-CAd5YQQl.js → index-CZB8DyUw.js} +1 -1
  46. package/dist-embed/chunks/{index-BO6VQLH6.js → index-Cd5CgKFr.js} +1 -1
  47. package/dist-embed/chunks/{index-D64QvG43.js → index-CkQ6IAoY.js} +1 -1
  48. package/dist-embed/chunks/{index-BktUM85c.js → index-Coj9opLJ.js} +1 -1
  49. package/dist-embed/chunks/{index-dYwQAVs_.js → index-D9_026K2.js} +1 -1
  50. package/dist-embed/chunks/{index-SbFvdBPQ.js → index-DVaPKQyL.js} +1 -1
  51. package/dist-embed/chunks/{index-f9WZsG2n.js → index-DWfzdTZo.js} +1 -1
  52. package/dist-embed/chunks/{index-DY8mjz1l.js → index-DdBQBN76.js} +1 -1
  53. package/dist-embed/chunks/{index-DEjLPUAD.js → index-Di3aBGLV.js} +1 -1
  54. package/dist-embed/chunks/{index-Cu0bp_EI.js → index-Gngo0bXi.js} +1 -1
  55. package/dist-embed/chunks/{index-DyVR0igi.js → index-S4sn4R3i.js} +1 -1
  56. package/dist-embed/chunks/{index-noRoZrq5.js → index-Z2pxzg3H.js} +1 -1
  57. package/dist-embed/chunks/{index-PqsSImlj.js → index-_H5U6gal.js} +1 -1
  58. package/dist-embed/chunks/{index-x45cMPwN.js → index-_nsBY26B.js} +1 -1
  59. package/dist-embed/chunks/{index-CM7xo08K.js → index-b6e3y1R-.js} +1 -1
  60. package/dist-embed/chunks/{index-wk9vl2uW.js → index-szXn1pzS.js} +1 -1
  61. package/dist-embed/chunks/{index.esm-p0OnSU9h.js → index.esm-nZym6gpK.js} +1 -1
  62. package/dist-embed/chunks/isEqual-g-jK7vY0.js +1 -0
  63. package/dist-embed/chunks/{it-IT-JPQ66NNP-DuG05fUR.js → it-IT-JPQ66NNP-DEiaanA7.js} +1 -1
  64. package/dist-embed/chunks/{ja-JP-DBVTYXUO-DeDfL3Bk.js → ja-JP-DBVTYXUO-Bb0GBZrQ.js} +1 -1
  65. package/dist-embed/chunks/{kaa-6HZHGXH3-BRKFVG6s.js → kaa-6HZHGXH3-DxqTv9uN.js} +1 -1
  66. package/dist-embed/chunks/{kab-KAB-ZGHBKWFO-Uqakmhz5.js → kab-KAB-ZGHBKWFO-D0V0yQgV.js} +1 -1
  67. package/dist-embed/chunks/{kk-KZ-P5N5QNE5-DWMXMIAK.js → kk-KZ-P5N5QNE5-CYyEyHXW.js} +1 -1
  68. package/dist-embed/chunks/{km-KH-HSX4SM5Z-BXNl9QnV.js → km-KH-HSX4SM5Z-CCTEGikY.js} +1 -1
  69. package/dist-embed/chunks/{ko-KR-MTYHY66A-BZgIqTuN.js → ko-KR-MTYHY66A-C-QDut19.js} +1 -1
  70. package/dist-embed/chunks/{ku-TR-6OUDTVRD-CQNa5i5U.js → ku-TR-6OUDTVRD-CIqn8p2Y.js} +1 -1
  71. package/dist-embed/chunks/{lt-LT-XHIRWOB4-BQW2k7iv.js → lt-LT-XHIRWOB4-BDLUWFPH.js} +1 -1
  72. package/dist-embed/chunks/{lv-LV-5QDEKY6T-B0HRRCC4.js → lv-LV-5QDEKY6T-BItabIJP.js} +1 -1
  73. package/dist-embed/chunks/{mr-IN-CRQNXWMA-DXR6sWSH.js → mr-IN-CRQNXWMA-DXXb8N2w.js} +1 -1
  74. package/dist-embed/chunks/{my-MM-5M5IBNSE-BZ5_9oCm.js → my-MM-5M5IBNSE-TidIfjqS.js} +1 -1
  75. package/dist-embed/chunks/{nb-NO-T6EIAALU-CBtv36wZ.js → nb-NO-T6EIAALU-DEINynK7.js} +1 -1
  76. package/dist-embed/chunks/{nl-NL-IS3SIHDZ-CcqE3cY8.js → nl-NL-IS3SIHDZ-D04rJzNe.js} +1 -1
  77. package/dist-embed/chunks/{nn-NO-6E72VCQL-Cl9wPgpU.js → nn-NO-6E72VCQL-oWFzCtpf.js} +1 -1
  78. package/dist-embed/chunks/{oc-FR-POXYY2M6-CQEkV2p1.js → oc-FR-POXYY2M6-BmFfP6hk.js} +1 -1
  79. package/dist-embed/chunks/{pa-IN-N4M65BXN-CaE6yG0U.js → pa-IN-N4M65BXN-RkXrgKXw.js} +1 -1
  80. package/dist-embed/chunks/{percentages-BXMCSKIN-Bk5xifLL.js → percentages-BXMCSKIN-BL_DuU3S.js} +3 -3
  81. package/dist-embed/chunks/{pl-PL-T2D74RX3-M1pQcF2j.js → pl-PL-T2D74RX3-DqxkHzTj.js} +1 -1
  82. package/dist-embed/chunks/{pt-BR-5N22H2LF-BFDHu72z.js → pt-BR-5N22H2LF-DFA-wWC5.js} +1 -1
  83. package/dist-embed/chunks/{pt-PT-UZXXM6DQ-DFcZY1Gz.js → pt-PT-UZXXM6DQ-Z5jw_7aw.js} +1 -1
  84. package/dist-embed/chunks/{renderer-Dy4lZ1KZ.js → renderer-DKKfWkWv.js} +1 -1
  85. package/dist-embed/chunks/{ro-RO-JPDTUUEW-BGm_Xwik.js → ro-RO-JPDTUUEW-DjC09bHq.js} +1 -1
  86. package/dist-embed/chunks/{ru-RU-B4JR7IUQ-BsrZ_x8p.js → ru-RU-B4JR7IUQ-CqwD7Yik.js} +1 -1
  87. package/dist-embed/chunks/{si-LK-N5RQ5JYF-BfaYS44g.js → si-LK-N5RQ5JYF-OVf4k6G3.js} +1 -1
  88. package/dist-embed/chunks/{sk-SK-C5VTKIMK-D-K9yMTN.js → sk-SK-C5VTKIMK-BG__kjLT.js} +1 -1
  89. package/dist-embed/chunks/{sl-SI-NN7IZMDC-B48XvZUw.js → sl-SI-NN7IZMDC-CIgxidVH.js} +1 -1
  90. package/dist-embed/chunks/{subset-shared.chunk-DzA7mJjZ.js → subset-shared.chunk-BR0LJHtQ.js} +1 -1
  91. package/dist-embed/chunks/{subset-worker.chunk-CsTEdHAt.js → subset-worker.chunk-52aAcjvz.js} +1 -1
  92. package/dist-embed/chunks/{sv-SE-XGPEYMSR-DfhLO_Vt.js → sv-SE-XGPEYMSR-CYHz3xCa.js} +1 -1
  93. package/dist-embed/chunks/{ta-IN-2NMHFXQM-EZA_oxSt.js → ta-IN-2NMHFXQM-BphRr9QY.js} +1 -1
  94. package/dist-embed/chunks/{th-TH-HPSO5L25-G9vy_zQH.js → th-TH-HPSO5L25-Ba2-2Bo0.js} +1 -1
  95. package/dist-embed/chunks/{tr-TR-DEFEU3FU-DBj_G5CD.js → tr-TR-DEFEU3FU-CRKE7Roy.js} +1 -1
  96. package/dist-embed/chunks/{uk-UA-QMV73CPH-DN7lMu5H.js → uk-UA-QMV73CPH-DlNE5CAT.js} +1 -1
  97. package/dist-embed/chunks/{vi-VN-M7AON7JQ-LoT02qgd.js → vi-VN-M7AON7JQ-Cp44PRXY.js} +1 -1
  98. package/dist-embed/chunks/{zh-CN-LNUGB5OW-CjexwOqT.js → zh-CN-LNUGB5OW-JHqqwp0j.js} +1 -1
  99. package/dist-embed/chunks/{zh-HK-E62DVLB3-B0ys_HV6.js → zh-HK-E62DVLB3-YEs97mA8.js} +1 -1
  100. package/dist-embed/chunks/{zh-TW-RAJ6MFWO-tQJWLJuU.js → zh-TW-RAJ6MFWO-CgmeTbuy.js} +1 -1
  101. package/dist-embed/datalayer-app-main.js +65 -65
  102. package/lib/apps/plugins/pap-sign-in/signIn.d.ts +3 -89
  103. package/lib/apps/plugins/pap-sign-in/signIn.js +5 -142
  104. package/lib/chat/messages/ChatMessageList.js +3 -1
  105. package/lib/chat/presence/Presence.d.ts +4 -4
  106. package/lib/chat/presence/Presence.js +3 -2
  107. package/lib/chat/presence/presenceStatus.d.ts +3 -34
  108. package/lib/chat/presence/presenceStatus.js +4 -46
  109. package/lib/portable/conversation.d.ts +3 -0
  110. package/lib/portable/conversation.js +15 -1
  111. package/lib/portable/direct.d.ts +100 -0
  112. package/lib/portable/direct.js +172 -0
  113. package/lib/portable/displays.d.ts +109 -0
  114. package/lib/portable/displays.js +261 -0
  115. package/lib/portable/fixtures.d.ts +11 -0
  116. package/lib/portable/fixtures.js +72 -0
  117. package/lib/portable/index.d.ts +6 -0
  118. package/lib/portable/index.js +10 -0
  119. package/lib/portable/presence.d.ts +47 -0
  120. package/lib/portable/presence.js +71 -0
  121. package/lib/portable/signIn.d.ts +96 -0
  122. package/lib/portable/signIn.js +148 -0
  123. package/lib/portable/views.d.ts +147 -0
  124. package/lib/portable/views.js +52 -0
  125. package/lib/runtimes/__tests__/fixtures/accounting-agent-card.json +1 -1
  126. package/package.json +1 -1
  127. package/dist-embed/chunks/isEqual-Cwjr2skl.js +0 -1
@@ -1,4 +1,4 @@
1
- import{r as _,v as Ue,j as u,iN as Pt,I as q,e4 as Ge,cm as pe,b7 as ge,c as J,ez as Tt,et as qe,eK as Dt,iO as jt,iP as At,iQ as Je,iR as Ye,c1 as W,iS as It,iT as Nt,iU as Lt,bx as De,iV as ct,iW as ht,iX as Rt,iY as fe,ar as Ot,by as ut,iZ as ft,i_ as Ft,i$ as Xe,J as A,j0 as Ze,j1 as me,j2 as Bt,j3 as Wt,j4 as Vt,ak as _e,j5 as Ie,j6 as Qe,ci as ke,ch as ee,aW as $t,dK as Gt,b_ as z,iJ as Ht,ae as zt,c6 as Kt,ag as Z,cy as Ut,cZ as qt,hr as Fe,hp as mt,j7 as xe,j8 as de,j9 as Jt,am as Yt,ah as Xt,iH as Zt,ja as pt,hc as H,jb as Qt,jc as R,jd as en,cS as tn,je as gt,jf as nn,jg as sn,jh as on,o as ne,B as ue,cG as rn,dv as et,_ as an,aa as ln,dz as tt,dA as ce,dB as dn,cb as cn,l as hn,ji as un,jj as _t,eT as fn,jk as ae,b6 as D,C as le,co as nt,bi as vt,d6 as mn,ct as pn,bf as Se,i as gn,P as _n,an as vn,au as yn}from"../datalayer-app-main.js";import{b as Cn,c as bn,f as he,P as Ne,d as wn,W as kn,r as xn,g as Sn,h as Mn,i as En,C as Pn,a as Tn}from"./index-DSN70XMH.js";import{c as Dn,N as Be}from"./NotebookSkeleton-CI7ovjNW.js";import{H as jn}from"./hoverbox-CStlKQWE.js";import{R as yt,L as An}from"./index-DyVR0igi.js";import{a as In,W as st}from"./renderer-Dy4lZ1KZ.js";import{C as Me,S as Ee}from"./SquareIcon-e3ygcjpv.js";function Nn(...r){return _.useCallback(e=>{for(const t of r)typeof t=="function"?t(e):t&&(t.current=e)},r)}var Q={Banner:"prc-Banner-Banner-IR8eJ",BannerContainer:"prc-Banner-BannerContainer-lbx3d",BannerContent:"prc-Banner-BannerContent-zTITK",BannerActions:"prc-Banner-BannerActions-XCfHL",BannerTitle:"prc-Banner-BannerTitle-TcuJl",BannerIcon:"prc-Banner-BannerIcon-WuOyf",BannerDismiss:"prc-Banner-BannerDismiss-uBZVm",BannerActionsContainer:"prc-Banner-BannerActionsContainer-ukGMH"};const Ln={critical:u.jsx(jt,{}),info:u.jsx(qe,{}),success:u.jsx(Dt,{}),upsell:u.jsx(qe,{}),warning:u.jsx(Tt,{})},Rn={critical:"Critical",info:"Information",success:"Success",upsell:"Recommendation",warning:"Warning"},On=Ue.forwardRef(function({"aria-label":e,children:t,className:n,description:s,hideTitle:o,icon:i,onDismiss:a,primaryAction:l,secondaryAction:d,title:c,variant:h="info",...f},m){const C=!!a,x=l||d,I=Ue.useRef(null),L=Nn(m,I),g=h==="info"||h==="upsell";return u.jsxs("section",{...f,"aria-label":e??Rn[h],className:pe(n,Q.Banner),"data-dismissible":a?"":void 0,"data-title-hidden":o?"":void 0,"data-variant":h,tabIndex:-1,ref:L,children:[u.jsx("div",{className:Q.BannerIcon,children:i&&g?i:Ln[h]}),u.jsxs("div",{className:Q.BannerContainer,children:[u.jsxs("div",{className:Q.BannerContent,children:[c?o?u.jsx(Pt,{children:u.jsx(We,{children:c})}):u.jsx(We,{children:c}):null,s?u.jsx(Ct,{children:s}):null,t]}),x?u.jsx(Fn,{primaryAction:l,secondaryAction:d}):null]}),C?u.jsx(q,{"aria-label":"Dismiss banner",onClick:a,className:Q.BannerDismiss,icon:Ge,variant:"invisible"}):null]})});function We(r){const e=ge.c(12);let t,n,s,o;e[0]!==r?({as:o,className:n,children:t,...s}=r,e[0]=r,e[1]=t,e[2]=n,e[3]=s,e[4]=o):(t=e[1],n=e[2],s=e[3],o=e[4]);const i=o===void 0?"h2":o;let a;e[5]!==n?(a=pe(n,Q.BannerTitle),e[5]=n,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==t||e[9]!==s||e[10]!==a?(l=u.jsx(i,{...s,className:a,"data-banner-title":"",children:t}),e[7]=i,e[8]=t,e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function Ct(r){const e=ge.c(10);let t,n,s;e[0]!==r?({children:t,className:n,...s}=r,e[0]=r,e[1]=t,e[2]=n,e[3]=s):(t=e[1],n=e[2],s=e[3]);let o;e[4]!==n?(o=pe("BannerDescription",n),e[4]=n,e[5]=o):o=e[5];let i;return e[6]!==t||e[7]!==s||e[8]!==o?(i=u.jsx("div",{...s,className:o,children:t}),e[6]=t,e[7]=s,e[8]=o,e[9]=i):i=e[9],i}function Fn(r){const e=ge.c(9),{primaryAction:t,secondaryAction:n}=r,s=n??null,o=t??null;let i;e[0]!==s||e[1]!==o?(i=u.jsxs("div",{className:Q.BannerActionsContainer,"data-primary-action":"trailing",children:[s,o]}),e[0]=s,e[1]=o,e[2]=i):i=e[2];const a=t??null,l=n??null;let d;e[3]!==a||e[4]!==l?(d=u.jsxs("div",{className:Q.BannerActionsContainer,"data-primary-action":"leading",children:[a,l]}),e[3]=a,e[4]=l,e[5]=d):d=e[5];let c;return e[6]!==i||e[7]!==d?(c=u.jsxs("div",{className:Q.BannerActions,children:[i,d]}),e[6]=i,e[7]=d,e[8]=c):c=e[8],c}const bt=_.forwardRef((r,e)=>{const t=ge.c(11);let n,s,o;t[0]!==r?({children:n,className:s,...o}=r,t[0]=r,t[1]=n,t[2]=s,t[3]=o):(n=t[1],s=t[2],o=t[3]);let i;t[4]!==s?(i=pe("BannerPrimaryAction",s),t[4]=s,t[5]=i):i=t[5];let a;return t[6]!==n||t[7]!==e||t[8]!==o||t[9]!==i?(a=u.jsx(J,{ref:e,className:i,variant:"default",...o,children:n}),t[6]=n,t[7]=e,t[8]=o,t[9]=i,t[10]=a):a=t[10],a});bt.displayName="BannerPrimaryAction";const wt=_.forwardRef((r,e)=>{const t=ge.c(11);let n,s,o;t[0]!==r?({children:n,className:s,...o}=r,t[0]=r,t[1]=n,t[2]=s,t[3]=o):(n=t[1],s=t[2],o=t[3]);let i;t[4]!==s?(i=pe("BannerPrimaryAction",s),t[4]=s,t[5]=i):i=t[5];let a;return t[6]!==n||t[7]!==e||t[8]!==o||t[9]!==i?(a=u.jsx(J,{ref:e,className:i,variant:"link",...o,children:n}),t[6]=n,t[7]=e,t[8]=o,t[9]=i,t[10]=a):a=t[10],a});wt.displayName="BannerSecondaryAction";const Bn=Object.assign(On,{Title:We,Description:Ct,PrimaryAction:bt,SecondaryAction:wt}),ve=Nt.define({combine(r){return r[r.length-1]}}),Wn=De.baseTheme({".jp-remote-cursor":{borderLeft:"1px solid black",marginLeft:"-1px"},".jp-remote-cursor.jp-mod-primary":{borderLeftWidth:"2px"},".jp-remote-selection":{opacity:.5},".cm-tooltip":{border:"none"},".cm-tooltip.jp-remote-userInfo":{color:"var(--fgColor-onEmphasis, #ffffff)",padding:"0px 2px"}});function He(r,e){const t=r?.username||r?.display_name||r?.name||String(e),{theme:n,colorMode:s}=Ot.getState(),o=s==="auto"?typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light":s;return Dn(t,n,o)}const je=Lt.define();class kt{style;marker;constructor(e,t){this.style=e,this.marker=t}draw(){const e=this.marker.draw();for(const[t,n]of Object.entries(this.style))e.style[t]=n;return e}eq(e){return this.marker.eq(e.marker)&&W.deepEqual(this.style,e.style)}update(e,t){for(const[n,s]of Object.entries(this.style))e.style[n]=s;return this.marker.update(e,t.marker)}}const Vn=ct({above:!0,markers(r){const{awareness:e,ytext:t}=r.state.facet(ve),n=t.doc,s=[];return e.getStates().forEach((o,i)=>{if(i===e.doc.clientID)return;const a=o.cursors;for(const l of a??[]){if(!l?.anchor||!l?.head)return;const d=fe(l.anchor,n),c=fe(l.head,n);if(d?.type!==t||c?.type!==t)return;const h=l.primary??!0?"jp-remote-cursor jp-mod-primary":"jp-remote-cursor",f=ut.cursor(c.index,c.index>d.index?-1:1);for(const m of ft.forRange(r,h,f))s.push(new kt({borderLeftColor:He(o.user,i)},m))}}),s},update(r,e){return!!r.transactions.find(t=>t.annotation(je))},class:"jp-remote-cursors"});function ot(r){const e=new Array,{awareness:t,ytext:n}=r.facet(ve),s=n.doc;for(const[o,i]of t.getStates())if(o!==t.doc.clientID)for(const a of i.cursors??[]){if(!a?.head)continue;const l=fe(a.head,s);l?.type===n&&e.push({pos:l.index,above:!0,create:()=>{const d=document.createElement("div");return d.classList.add("jp-remote-userInfo"),d.style.backgroundColor=He(i.user,o),d.textContent=i.user?.display_name??"Anonymous",{dom:d}}})}return e}const $n=ht.define({create:ot,update(r,e){return e.annotation(je)?ot(e.state):r},provide(r){return Rt.computeN([r],e=>e.field(r))}}),Gn=ct({above:!1,markers(r){const{awareness:e,ytext:t}=r.state.facet(ve),n=t.doc,s=[];return e.getStates().forEach((o,i)=>{if(i===e.doc.clientID)return;const a=o.cursors;for(const l of a??[]){if((l.empty??!0)||!l?.anchor||!l?.head)return;const d=fe(l.anchor,n),c=fe(l.head,n);if(d?.type!==t||c?.type!==t)return;const h="jp-remote-selection";for(const f of ft.forRange(r,h,ut.range(d.index,c.index)))s.push(new kt({backgroundColor:He(o.user,i)},f))}}),s},update(r,e){return!!r.transactions.find(t=>t.annotation(je))},class:"jp-remote-selections"}),Hn=At.fromClass(class{editorAwareness;_listener;constructor(r){this.editorAwareness=r.state.facet(ve),this._listener=({added:e,updated:t,removed:n})=>{e.concat(t).concat(n).findIndex(o=>o!==this.editorAwareness.awareness.doc.clientID)>=0&&r.dispatch({annotations:[je.of([])]})},this.editorAwareness.awareness.on("change",this._listener)}destroy(){this.editorAwareness.awareness.off("change",this._listener)}update(r){if(!r.docChanged&&!r.selectionSet)return;const{awareness:e,ytext:t}=this.editorAwareness,n=e.getLocalState();if(n){const s=r.view.hasFocus&&r.view.dom.ownerDocument.hasFocus(),o=r.state.selection,i=new Array;if(s&&o){for(const a of o.ranges){const l=a===o.main,d=Je(t,a.anchor),c=Je(t,a.head);i.push({anchor:d,head:c,primary:l,empty:a.empty})}if(!n.cursors||i.length>0){const a=n.cursors?.map(l=>({...l,anchor:l?.anchor?Ye(l.anchor):null,head:l?.head?Ye(l.head):null}));W.deepEqual(i,a)||e.setLocalStateField("cursors",i)}}}}},{provide:()=>[Wn,Vn,Gn,$n,It({position:"absolute",parent:document.body})]});function zn(r){return[ve.of(r),Hn]}class Ae extends Ft{constructor(e={}){var t;super(),this.version="2.0.0",this.ymeta=this.ydoc.getMap("meta"),this._onMetaChanged=n=>{const s=n.find(i=>i.target===this.ymeta.get("metadata"));if(s){const i=s.changes.keys,a=this.ymeta.get("metadata");s.changes.keys.forEach((l,d)=>{switch(l.action){case"add":this._metadataChanged.emit({key:d,type:"add",newValue:a.get(d)});break;case"delete":this._metadataChanged.emit({key:d,type:"remove",oldValue:l.oldValue});break;case"update":{const c=a.get(d),h=l.oldValue;let f=!0;typeof h=="object"&&typeof c=="object"?f=W.deepEqual(h,c):f=h===c,f||this._metadataChanged.emit({key:d,type:"change",oldValue:h,newValue:c})}break}}),this._changed.emit({metadataChange:i})}const o=n.find(i=>i.target===this.ymeta);if(o){if(o.keysChanged.has("metadata")){const i=o.changes.keys.get("metadata");if(i?.action==="add"&&!i.oldValue){const a=new Map;for(const l of Object.keys(this.metadata))a.set(l,{action:"add",oldValue:void 0}),this._metadataChanged.emit({key:l,type:"add",newValue:this.getMetadata(l)});this._changed.emit({metadataChange:a})}}if(o.keysChanged.has("nbformat")){const i=o.changes.keys.get("nbformat"),a={key:"nbformat",oldValue:i?.oldValue?i.oldValue:void 0,newValue:this.nbformat};this._changed.emit({nbformatChanged:a})}if(o.keysChanged.has("nbformat_minor")){const i=o.changes.keys.get("nbformat_minor"),a={key:"nbformat_minor",oldValue:i?.oldValue?i.oldValue:void 0,newValue:this.nbformat_minor};this._changed.emit({nbformatChanged:a})}}},this._onYCellsChanged=n=>{n.changes.added.forEach(i=>{const a=i.content.type;if(!this._ycellMapping.has(a)){const l=Xe(a,{notebook:this});this._ycellMapping.set(a,l)}}),n.changes.deleted.forEach(i=>{const a=i.content.type,l=this._ycellMapping.get(a);l&&(l.dispose(),this._ycellMapping.delete(a))});let s=0;const o=[];n.changes.delta.forEach(i=>{if(i.insert!=null){const a=i.insert.map(l=>this._ycellMapping.get(l));o.push({insert:a}),this.cells.splice(s,0,...a),s+=i.insert.length}else i.delete!=null?(o.push(i),this.cells.splice(s,i.delete)):i.retain!=null&&(o.push(i),s+=i.retain)}),this._changed.emit({cellsChange:o})},this._metadataChanged=new A(this),this._ycells=this.ydoc.getArray("cells"),this._ycellMapping=new WeakMap,this._disableDocumentWideUndoRedo=(t=e.disableDocumentWideUndoRedo)!==null&&t!==void 0?t:!1,this.cells=this._ycells.toArray().map(n=>(this._ycellMapping.has(n)||this._ycellMapping.set(n,Xe(n,{notebook:this})),this._ycellMapping.get(n))),this.undoManager.addToScope(this._ycells),this._ycells.observe(this._onYCellsChanged),this.ymeta.observeDeep(this._onMetaChanged)}static create(e={}){var t,n,s,o,i,a,l,d,c;const h=new Ae({disableDocumentWideUndoRedo:(t=e.disableDocumentWideUndoRedo)!==null&&t!==void 0?t:!1}),f={cells:(s=(n=e.data)===null||n===void 0?void 0:n.cells)!==null&&s!==void 0?s:[],nbformat:(i=(o=e.data)===null||o===void 0?void 0:o.nbformat)!==null&&i!==void 0?i:4,nbformat_minor:(l=(a=e.data)===null||a===void 0?void 0:a.nbformat_minor)!==null&&l!==void 0?l:5,metadata:(c=(d=e.data)===null||d===void 0?void 0:d.metadata)!==null&&c!==void 0?c:{}};return h.setSource(f),h}get disableDocumentWideUndoRedo(){return this._disableDocumentWideUndoRedo}get metadata(){return this.getMetadata()}set metadata(e){this.setMetadata(e)}get metadataChanged(){return this._metadataChanged}get nbformat(){return this.ymeta.get("nbformat")}set nbformat(e){this.transact(()=>{this.ymeta.set("nbformat",e)},!1)}get nbformat_minor(){return this.ymeta.get("nbformat_minor")}set nbformat_minor(e){this.transact(()=>{this.ymeta.set("nbformat_minor",e)},!1)}dispose(){this.isDisposed||(this._ycells.unobserve(this._onYCellsChanged),this.ymeta.unobserveDeep(this._onMetaChanged),super.dispose())}getCell(e){return this.cells[e]}addCell(e){return this.insertCell(this._ycells.length,e)}insertCell(e,t){return this.insertCells(e,[t])[0]}insertCells(e,t){const n=t.map(s=>{const o=Ze(s,this);return this._ycellMapping.set(o.ymodel,o),o});return this.transact(()=>{this._ycells.insert(e,n.map(s=>s.ymodel))}),this.dirty=!0,n}moveCell(e,t){this.moveCells(e,t)}moveCells(e,t,n=1){const s=new Array(n).fill(!0).map((o,i)=>this.getCell(e+i).toJSON());this.transact(()=>{this._ycells.delete(e,n),this._ycells.insert(e>t?t:t-n+1,s.map(o=>Ze(o,this).ymodel))}),this.dirty=!0}deleteCell(e){this.deleteCellRange(e,e+1)}deleteCellRange(e,t){this.transact(()=>{this._ycells.delete(e,t-e)}),this.dirty=!0}deleteMetadata(e){if(typeof this.getMetadata(e)>"u")return;const t=this.metadata;delete t[e],this.setMetadata(t)}getMetadata(e){const t=this.ymeta.get("metadata");if(t!==void 0)if(typeof e=="string"){const n=t.get(e);return typeof n>"u"?void 0:W.deepCopy(n)}else return W.deepCopy(t.toJSON())}setMetadata(e,t){var n;if(typeof e=="string"){if(typeof t>"u")throw new TypeError(`Metadata value for ${e} cannot be 'undefined'; use deleteMetadata.`);if(W.deepEqual((n=this.getMetadata(e))!==null&&n!==void 0?n:null,t))return;const s={};s[e]=t,this.updateMetadata(s)}else if(!this.metadata||!W.deepEqual(this.metadata,e)){const s=W.deepCopy(e),o=this.ymeta.get("metadata");if(o===void 0)return;this.transact(()=>{o.clear();for(const[i,a]of Object.entries(s))o.set(i,a)}),this.dirty=!0}}updateMetadata(e){const t=W.deepCopy(e),n=this.ymeta.get("metadata");n!==void 0&&(this.transact(()=>{for(const[s,o]of Object.entries(t))n.set(s,o)}),this.dirty=!0)}getSource(){return this.toJSON()}setSource(e){this.fromJSON(e),this.dirty=!1}fromJSON(e){this.transact(()=>{this.nbformat=e.nbformat,this.nbformat_minor=e.nbformat_minor;const t=e.metadata;if(t.orig_nbformat!==void 0&&delete t.orig_nbformat,this.metadata)this.metadata=t;else{const o=new me;for(const[i,a]of Object.entries(t))o.set(i,a);this.ymeta.set("metadata",o)}const n=e.nbformat===4&&e.nbformat_minor>=5,s=e.cells.map(o=>(n||delete o.id,o));this.insertCells(this.cells.length,s),this.deleteCellRange(0,this.cells.length)})}toJSON(){const e=this.nbformat===4&&this.nbformat_minor<=4;return{metadata:this.metadata,nbformat_minor:this.nbformat_minor,nbformat:this.nbformat,cells:this.cells.map(t=>{const n=t.toJSON();return e&&delete n.id,n})}}}class Kn{constructor(e){this.model=e,this._cellMap=new WeakMap,this._changed=new A(this),this._isDisposed=!1,this._insertCells(0,this.model.cells),this.model.changed.connect(this._onSharedModelChanged,this)}get changed(){return this._changed}get isDisposed(){return this._isDisposed}get length(){return this.model.cells.length}*[Symbol.iterator](){for(const e of this.model.cells)yield this._cellMap.get(e)}dispose(){var e;if(!this._isDisposed){this._isDisposed=!0;for(const t of this.model.cells)(e=this._cellMap.get(t))===null||e===void 0||e.dispose();A.clearData(this)}}get(e){return this._cellMap.get(this.model.cells[e])}_insertCells(e,t){return t.forEach(n=>{let s;switch(n.cell_type){case"code":{s=new Vt({sharedModel:n});break}case"markdown":{s=new Wt({sharedModel:n});break}default:s=new Bt({sharedModel:n})}this._cellMap.set(n,s),n.disposed.connect(()=>{s.dispose(),this._cellMap.delete(n)})}),this.length}_onSharedModelChanged(e,t){var n;let s=0;const o=new Array;(n=t.cellsChange)===null||n===void 0||n.forEach(i=>{i.insert!=null?(this._insertCells(s,i.insert),o.push({type:"add",newIndex:s,newValues:i.insert.map(a=>this._cellMap.get(a)),oldIndex:-2,oldValues:[]}),s+=i.insert.length):i.delete!=null?o.push({type:"remove",newIndex:-1,newValues:[],oldIndex:s,oldValues:new Array(i.delete).fill(void 0)}):i.retain!=null&&(s+=i.retain)}),o.forEach(i=>this._changed.emit(i))}}class Un{constructor(e){this._requestBatchSize=10,this._cursor=0,this._hasSession=!1,this._history=[],this._placeholder="",this._kernelSession="",this._setByHistory=!1,this._isDisposed=!1,this._editor=null,this._filtered=[],this._kernel=null,this._sessionContext=e.sessionContext,this._trans=(e.translator||_e).load("jupyterlab"),this._handleKernel().then(()=>{this._sessionContext.kernelChanged.connect(this._handleKernel,this)}),this._toRequest=this._requestBatchSize}get editor(){return this._editor}set editor(e){if(this._editor===e)return;const t=this._editor;t&&t.model.sharedModel.changed.disconnect(this.onTextChange,this),this._editor=e,e&&e.model.sharedModel.changed.connect(this.onTextChange,this)}get placeholder(){return this._placeholder}get kernelSession(){return this._kernelSession}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed=!0,this._history.length=0,A.clearData(this)}async checkSession(e){var t;this._hasSession||(await this._retrieveHistory(),this._hasSession=!0,this.editor=e.editor,this._placeholder=((t=this._editor)===null||t===void 0?void 0:t.model.sharedModel.getSource())||"",this.setFilter(this._placeholder),this._cursor=this._filtered.length-1)}async back(e){return await this.checkSession(e),--this._cursor,this._cursor<0&&await this.fetchBatch(),this._cursor=Math.max(0,this._cursor),this._filtered[this._cursor]}async forward(e){return await this.checkSession(e),++this._cursor,this._cursor=Math.min(this._filtered.length-1,this._cursor),this._filtered[this._cursor]}updateEditor(e,t){var n,s;if(e){const o=(n=e.editor)===null||n===void 0?void 0:n.model,i=o?.sharedModel.getSource();if(this.isDisposed||!t||i===t)return;this._setByHistory=!0,o?.sharedModel.setSource(t);let a=0;a=t.indexOf(`
1
+ import{r as _,v as Ue,j as u,iN as Pt,I as q,e4 as Ge,cm as pe,b7 as ge,c as J,ez as Tt,et as qe,eK as Dt,iO as jt,iP as At,iQ as Je,iR as Ye,c1 as W,iS as It,iT as Nt,iU as Lt,bx as De,iV as ct,iW as ht,iX as Rt,iY as fe,ar as Ot,by as ut,iZ as ft,i_ as Ft,i$ as Xe,J as A,j0 as Ze,j1 as me,j2 as Bt,j3 as Wt,j4 as Vt,ak as _e,j5 as Ie,j6 as Qe,ci as ke,ch as ee,aW as $t,dK as Gt,b_ as z,iJ as Ht,ae as zt,c6 as Kt,ag as Z,cy as Ut,cZ as qt,hr as Fe,hp as mt,j7 as xe,j8 as de,j9 as Jt,am as Yt,ah as Xt,iH as Zt,ja as pt,hc as H,jb as Qt,jc as R,jd as en,cS as tn,je as gt,jf as nn,jg as sn,jh as on,o as ne,B as ue,cG as rn,dv as et,_ as an,aa as ln,dz as tt,dA as ce,dB as dn,cb as cn,l as hn,ji as un,jj as _t,f5 as fn,jk as ae,b6 as D,C as le,co as nt,bi as vt,d6 as mn,ct as pn,bf as Se,i as gn,P as _n,an as vn,au as yn}from"../datalayer-app-main.js";import{b as Cn,c as bn,f as he,P as Ne,d as wn,W as kn,r as xn,g as Sn,h as Mn,i as En,C as Pn,a as Tn}from"./index-DSN70XMH.js";import{c as Dn,N as Be}from"./NotebookSkeleton-CI7ovjNW.js";import{H as jn}from"./hoverbox-CStlKQWE.js";import{R as yt,L as An}from"./index-S4sn4R3i.js";import{a as In,W as st}from"./renderer-DKKfWkWv.js";import{C as Me,S as Ee}from"./SquareIcon-e3ygcjpv.js";function Nn(...r){return _.useCallback(e=>{for(const t of r)typeof t=="function"?t(e):t&&(t.current=e)},r)}var Q={Banner:"prc-Banner-Banner-IR8eJ",BannerContainer:"prc-Banner-BannerContainer-lbx3d",BannerContent:"prc-Banner-BannerContent-zTITK",BannerActions:"prc-Banner-BannerActions-XCfHL",BannerTitle:"prc-Banner-BannerTitle-TcuJl",BannerIcon:"prc-Banner-BannerIcon-WuOyf",BannerDismiss:"prc-Banner-BannerDismiss-uBZVm",BannerActionsContainer:"prc-Banner-BannerActionsContainer-ukGMH"};const Ln={critical:u.jsx(jt,{}),info:u.jsx(qe,{}),success:u.jsx(Dt,{}),upsell:u.jsx(qe,{}),warning:u.jsx(Tt,{})},Rn={critical:"Critical",info:"Information",success:"Success",upsell:"Recommendation",warning:"Warning"},On=Ue.forwardRef(function({"aria-label":e,children:t,className:n,description:s,hideTitle:o,icon:i,onDismiss:a,primaryAction:l,secondaryAction:d,title:c,variant:h="info",...f},m){const C=!!a,x=l||d,I=Ue.useRef(null),L=Nn(m,I),g=h==="info"||h==="upsell";return u.jsxs("section",{...f,"aria-label":e??Rn[h],className:pe(n,Q.Banner),"data-dismissible":a?"":void 0,"data-title-hidden":o?"":void 0,"data-variant":h,tabIndex:-1,ref:L,children:[u.jsx("div",{className:Q.BannerIcon,children:i&&g?i:Ln[h]}),u.jsxs("div",{className:Q.BannerContainer,children:[u.jsxs("div",{className:Q.BannerContent,children:[c?o?u.jsx(Pt,{children:u.jsx(We,{children:c})}):u.jsx(We,{children:c}):null,s?u.jsx(Ct,{children:s}):null,t]}),x?u.jsx(Fn,{primaryAction:l,secondaryAction:d}):null]}),C?u.jsx(q,{"aria-label":"Dismiss banner",onClick:a,className:Q.BannerDismiss,icon:Ge,variant:"invisible"}):null]})});function We(r){const e=ge.c(12);let t,n,s,o;e[0]!==r?({as:o,className:n,children:t,...s}=r,e[0]=r,e[1]=t,e[2]=n,e[3]=s,e[4]=o):(t=e[1],n=e[2],s=e[3],o=e[4]);const i=o===void 0?"h2":o;let a;e[5]!==n?(a=pe(n,Q.BannerTitle),e[5]=n,e[6]=a):a=e[6];let l;return e[7]!==i||e[8]!==t||e[9]!==s||e[10]!==a?(l=u.jsx(i,{...s,className:a,"data-banner-title":"",children:t}),e[7]=i,e[8]=t,e[9]=s,e[10]=a,e[11]=l):l=e[11],l}function Ct(r){const e=ge.c(10);let t,n,s;e[0]!==r?({children:t,className:n,...s}=r,e[0]=r,e[1]=t,e[2]=n,e[3]=s):(t=e[1],n=e[2],s=e[3]);let o;e[4]!==n?(o=pe("BannerDescription",n),e[4]=n,e[5]=o):o=e[5];let i;return e[6]!==t||e[7]!==s||e[8]!==o?(i=u.jsx("div",{...s,className:o,children:t}),e[6]=t,e[7]=s,e[8]=o,e[9]=i):i=e[9],i}function Fn(r){const e=ge.c(9),{primaryAction:t,secondaryAction:n}=r,s=n??null,o=t??null;let i;e[0]!==s||e[1]!==o?(i=u.jsxs("div",{className:Q.BannerActionsContainer,"data-primary-action":"trailing",children:[s,o]}),e[0]=s,e[1]=o,e[2]=i):i=e[2];const a=t??null,l=n??null;let d;e[3]!==a||e[4]!==l?(d=u.jsxs("div",{className:Q.BannerActionsContainer,"data-primary-action":"leading",children:[a,l]}),e[3]=a,e[4]=l,e[5]=d):d=e[5];let c;return e[6]!==i||e[7]!==d?(c=u.jsxs("div",{className:Q.BannerActions,children:[i,d]}),e[6]=i,e[7]=d,e[8]=c):c=e[8],c}const bt=_.forwardRef((r,e)=>{const t=ge.c(11);let n,s,o;t[0]!==r?({children:n,className:s,...o}=r,t[0]=r,t[1]=n,t[2]=s,t[3]=o):(n=t[1],s=t[2],o=t[3]);let i;t[4]!==s?(i=pe("BannerPrimaryAction",s),t[4]=s,t[5]=i):i=t[5];let a;return t[6]!==n||t[7]!==e||t[8]!==o||t[9]!==i?(a=u.jsx(J,{ref:e,className:i,variant:"default",...o,children:n}),t[6]=n,t[7]=e,t[8]=o,t[9]=i,t[10]=a):a=t[10],a});bt.displayName="BannerPrimaryAction";const wt=_.forwardRef((r,e)=>{const t=ge.c(11);let n,s,o;t[0]!==r?({children:n,className:s,...o}=r,t[0]=r,t[1]=n,t[2]=s,t[3]=o):(n=t[1],s=t[2],o=t[3]);let i;t[4]!==s?(i=pe("BannerPrimaryAction",s),t[4]=s,t[5]=i):i=t[5];let a;return t[6]!==n||t[7]!==e||t[8]!==o||t[9]!==i?(a=u.jsx(J,{ref:e,className:i,variant:"link",...o,children:n}),t[6]=n,t[7]=e,t[8]=o,t[9]=i,t[10]=a):a=t[10],a});wt.displayName="BannerSecondaryAction";const Bn=Object.assign(On,{Title:We,Description:Ct,PrimaryAction:bt,SecondaryAction:wt}),ve=Nt.define({combine(r){return r[r.length-1]}}),Wn=De.baseTheme({".jp-remote-cursor":{borderLeft:"1px solid black",marginLeft:"-1px"},".jp-remote-cursor.jp-mod-primary":{borderLeftWidth:"2px"},".jp-remote-selection":{opacity:.5},".cm-tooltip":{border:"none"},".cm-tooltip.jp-remote-userInfo":{color:"var(--fgColor-onEmphasis, #ffffff)",padding:"0px 2px"}});function He(r,e){const t=r?.username||r?.display_name||r?.name||String(e),{theme:n,colorMode:s}=Ot.getState(),o=s==="auto"?typeof window<"u"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light":s;return Dn(t,n,o)}const je=Lt.define();class kt{style;marker;constructor(e,t){this.style=e,this.marker=t}draw(){const e=this.marker.draw();for(const[t,n]of Object.entries(this.style))e.style[t]=n;return e}eq(e){return this.marker.eq(e.marker)&&W.deepEqual(this.style,e.style)}update(e,t){for(const[n,s]of Object.entries(this.style))e.style[n]=s;return this.marker.update(e,t.marker)}}const Vn=ct({above:!0,markers(r){const{awareness:e,ytext:t}=r.state.facet(ve),n=t.doc,s=[];return e.getStates().forEach((o,i)=>{if(i===e.doc.clientID)return;const a=o.cursors;for(const l of a??[]){if(!l?.anchor||!l?.head)return;const d=fe(l.anchor,n),c=fe(l.head,n);if(d?.type!==t||c?.type!==t)return;const h=l.primary??!0?"jp-remote-cursor jp-mod-primary":"jp-remote-cursor",f=ut.cursor(c.index,c.index>d.index?-1:1);for(const m of ft.forRange(r,h,f))s.push(new kt({borderLeftColor:He(o.user,i)},m))}}),s},update(r,e){return!!r.transactions.find(t=>t.annotation(je))},class:"jp-remote-cursors"});function ot(r){const e=new Array,{awareness:t,ytext:n}=r.facet(ve),s=n.doc;for(const[o,i]of t.getStates())if(o!==t.doc.clientID)for(const a of i.cursors??[]){if(!a?.head)continue;const l=fe(a.head,s);l?.type===n&&e.push({pos:l.index,above:!0,create:()=>{const d=document.createElement("div");return d.classList.add("jp-remote-userInfo"),d.style.backgroundColor=He(i.user,o),d.textContent=i.user?.display_name??"Anonymous",{dom:d}}})}return e}const $n=ht.define({create:ot,update(r,e){return e.annotation(je)?ot(e.state):r},provide(r){return Rt.computeN([r],e=>e.field(r))}}),Gn=ct({above:!1,markers(r){const{awareness:e,ytext:t}=r.state.facet(ve),n=t.doc,s=[];return e.getStates().forEach((o,i)=>{if(i===e.doc.clientID)return;const a=o.cursors;for(const l of a??[]){if((l.empty??!0)||!l?.anchor||!l?.head)return;const d=fe(l.anchor,n),c=fe(l.head,n);if(d?.type!==t||c?.type!==t)return;const h="jp-remote-selection";for(const f of ft.forRange(r,h,ut.range(d.index,c.index)))s.push(new kt({backgroundColor:He(o.user,i)},f))}}),s},update(r,e){return!!r.transactions.find(t=>t.annotation(je))},class:"jp-remote-selections"}),Hn=At.fromClass(class{editorAwareness;_listener;constructor(r){this.editorAwareness=r.state.facet(ve),this._listener=({added:e,updated:t,removed:n})=>{e.concat(t).concat(n).findIndex(o=>o!==this.editorAwareness.awareness.doc.clientID)>=0&&r.dispatch({annotations:[je.of([])]})},this.editorAwareness.awareness.on("change",this._listener)}destroy(){this.editorAwareness.awareness.off("change",this._listener)}update(r){if(!r.docChanged&&!r.selectionSet)return;const{awareness:e,ytext:t}=this.editorAwareness,n=e.getLocalState();if(n){const s=r.view.hasFocus&&r.view.dom.ownerDocument.hasFocus(),o=r.state.selection,i=new Array;if(s&&o){for(const a of o.ranges){const l=a===o.main,d=Je(t,a.anchor),c=Je(t,a.head);i.push({anchor:d,head:c,primary:l,empty:a.empty})}if(!n.cursors||i.length>0){const a=n.cursors?.map(l=>({...l,anchor:l?.anchor?Ye(l.anchor):null,head:l?.head?Ye(l.head):null}));W.deepEqual(i,a)||e.setLocalStateField("cursors",i)}}}}},{provide:()=>[Wn,Vn,Gn,$n,It({position:"absolute",parent:document.body})]});function zn(r){return[ve.of(r),Hn]}class Ae extends Ft{constructor(e={}){var t;super(),this.version="2.0.0",this.ymeta=this.ydoc.getMap("meta"),this._onMetaChanged=n=>{const s=n.find(i=>i.target===this.ymeta.get("metadata"));if(s){const i=s.changes.keys,a=this.ymeta.get("metadata");s.changes.keys.forEach((l,d)=>{switch(l.action){case"add":this._metadataChanged.emit({key:d,type:"add",newValue:a.get(d)});break;case"delete":this._metadataChanged.emit({key:d,type:"remove",oldValue:l.oldValue});break;case"update":{const c=a.get(d),h=l.oldValue;let f=!0;typeof h=="object"&&typeof c=="object"?f=W.deepEqual(h,c):f=h===c,f||this._metadataChanged.emit({key:d,type:"change",oldValue:h,newValue:c})}break}}),this._changed.emit({metadataChange:i})}const o=n.find(i=>i.target===this.ymeta);if(o){if(o.keysChanged.has("metadata")){const i=o.changes.keys.get("metadata");if(i?.action==="add"&&!i.oldValue){const a=new Map;for(const l of Object.keys(this.metadata))a.set(l,{action:"add",oldValue:void 0}),this._metadataChanged.emit({key:l,type:"add",newValue:this.getMetadata(l)});this._changed.emit({metadataChange:a})}}if(o.keysChanged.has("nbformat")){const i=o.changes.keys.get("nbformat"),a={key:"nbformat",oldValue:i?.oldValue?i.oldValue:void 0,newValue:this.nbformat};this._changed.emit({nbformatChanged:a})}if(o.keysChanged.has("nbformat_minor")){const i=o.changes.keys.get("nbformat_minor"),a={key:"nbformat_minor",oldValue:i?.oldValue?i.oldValue:void 0,newValue:this.nbformat_minor};this._changed.emit({nbformatChanged:a})}}},this._onYCellsChanged=n=>{n.changes.added.forEach(i=>{const a=i.content.type;if(!this._ycellMapping.has(a)){const l=Xe(a,{notebook:this});this._ycellMapping.set(a,l)}}),n.changes.deleted.forEach(i=>{const a=i.content.type,l=this._ycellMapping.get(a);l&&(l.dispose(),this._ycellMapping.delete(a))});let s=0;const o=[];n.changes.delta.forEach(i=>{if(i.insert!=null){const a=i.insert.map(l=>this._ycellMapping.get(l));o.push({insert:a}),this.cells.splice(s,0,...a),s+=i.insert.length}else i.delete!=null?(o.push(i),this.cells.splice(s,i.delete)):i.retain!=null&&(o.push(i),s+=i.retain)}),this._changed.emit({cellsChange:o})},this._metadataChanged=new A(this),this._ycells=this.ydoc.getArray("cells"),this._ycellMapping=new WeakMap,this._disableDocumentWideUndoRedo=(t=e.disableDocumentWideUndoRedo)!==null&&t!==void 0?t:!1,this.cells=this._ycells.toArray().map(n=>(this._ycellMapping.has(n)||this._ycellMapping.set(n,Xe(n,{notebook:this})),this._ycellMapping.get(n))),this.undoManager.addToScope(this._ycells),this._ycells.observe(this._onYCellsChanged),this.ymeta.observeDeep(this._onMetaChanged)}static create(e={}){var t,n,s,o,i,a,l,d,c;const h=new Ae({disableDocumentWideUndoRedo:(t=e.disableDocumentWideUndoRedo)!==null&&t!==void 0?t:!1}),f={cells:(s=(n=e.data)===null||n===void 0?void 0:n.cells)!==null&&s!==void 0?s:[],nbformat:(i=(o=e.data)===null||o===void 0?void 0:o.nbformat)!==null&&i!==void 0?i:4,nbformat_minor:(l=(a=e.data)===null||a===void 0?void 0:a.nbformat_minor)!==null&&l!==void 0?l:5,metadata:(c=(d=e.data)===null||d===void 0?void 0:d.metadata)!==null&&c!==void 0?c:{}};return h.setSource(f),h}get disableDocumentWideUndoRedo(){return this._disableDocumentWideUndoRedo}get metadata(){return this.getMetadata()}set metadata(e){this.setMetadata(e)}get metadataChanged(){return this._metadataChanged}get nbformat(){return this.ymeta.get("nbformat")}set nbformat(e){this.transact(()=>{this.ymeta.set("nbformat",e)},!1)}get nbformat_minor(){return this.ymeta.get("nbformat_minor")}set nbformat_minor(e){this.transact(()=>{this.ymeta.set("nbformat_minor",e)},!1)}dispose(){this.isDisposed||(this._ycells.unobserve(this._onYCellsChanged),this.ymeta.unobserveDeep(this._onMetaChanged),super.dispose())}getCell(e){return this.cells[e]}addCell(e){return this.insertCell(this._ycells.length,e)}insertCell(e,t){return this.insertCells(e,[t])[0]}insertCells(e,t){const n=t.map(s=>{const o=Ze(s,this);return this._ycellMapping.set(o.ymodel,o),o});return this.transact(()=>{this._ycells.insert(e,n.map(s=>s.ymodel))}),this.dirty=!0,n}moveCell(e,t){this.moveCells(e,t)}moveCells(e,t,n=1){const s=new Array(n).fill(!0).map((o,i)=>this.getCell(e+i).toJSON());this.transact(()=>{this._ycells.delete(e,n),this._ycells.insert(e>t?t:t-n+1,s.map(o=>Ze(o,this).ymodel))}),this.dirty=!0}deleteCell(e){this.deleteCellRange(e,e+1)}deleteCellRange(e,t){this.transact(()=>{this._ycells.delete(e,t-e)}),this.dirty=!0}deleteMetadata(e){if(typeof this.getMetadata(e)>"u")return;const t=this.metadata;delete t[e],this.setMetadata(t)}getMetadata(e){const t=this.ymeta.get("metadata");if(t!==void 0)if(typeof e=="string"){const n=t.get(e);return typeof n>"u"?void 0:W.deepCopy(n)}else return W.deepCopy(t.toJSON())}setMetadata(e,t){var n;if(typeof e=="string"){if(typeof t>"u")throw new TypeError(`Metadata value for ${e} cannot be 'undefined'; use deleteMetadata.`);if(W.deepEqual((n=this.getMetadata(e))!==null&&n!==void 0?n:null,t))return;const s={};s[e]=t,this.updateMetadata(s)}else if(!this.metadata||!W.deepEqual(this.metadata,e)){const s=W.deepCopy(e),o=this.ymeta.get("metadata");if(o===void 0)return;this.transact(()=>{o.clear();for(const[i,a]of Object.entries(s))o.set(i,a)}),this.dirty=!0}}updateMetadata(e){const t=W.deepCopy(e),n=this.ymeta.get("metadata");n!==void 0&&(this.transact(()=>{for(const[s,o]of Object.entries(t))n.set(s,o)}),this.dirty=!0)}getSource(){return this.toJSON()}setSource(e){this.fromJSON(e),this.dirty=!1}fromJSON(e){this.transact(()=>{this.nbformat=e.nbformat,this.nbformat_minor=e.nbformat_minor;const t=e.metadata;if(t.orig_nbformat!==void 0&&delete t.orig_nbformat,this.metadata)this.metadata=t;else{const o=new me;for(const[i,a]of Object.entries(t))o.set(i,a);this.ymeta.set("metadata",o)}const n=e.nbformat===4&&e.nbformat_minor>=5,s=e.cells.map(o=>(n||delete o.id,o));this.insertCells(this.cells.length,s),this.deleteCellRange(0,this.cells.length)})}toJSON(){const e=this.nbformat===4&&this.nbformat_minor<=4;return{metadata:this.metadata,nbformat_minor:this.nbformat_minor,nbformat:this.nbformat,cells:this.cells.map(t=>{const n=t.toJSON();return e&&delete n.id,n})}}}class Kn{constructor(e){this.model=e,this._cellMap=new WeakMap,this._changed=new A(this),this._isDisposed=!1,this._insertCells(0,this.model.cells),this.model.changed.connect(this._onSharedModelChanged,this)}get changed(){return this._changed}get isDisposed(){return this._isDisposed}get length(){return this.model.cells.length}*[Symbol.iterator](){for(const e of this.model.cells)yield this._cellMap.get(e)}dispose(){var e;if(!this._isDisposed){this._isDisposed=!0;for(const t of this.model.cells)(e=this._cellMap.get(t))===null||e===void 0||e.dispose();A.clearData(this)}}get(e){return this._cellMap.get(this.model.cells[e])}_insertCells(e,t){return t.forEach(n=>{let s;switch(n.cell_type){case"code":{s=new Vt({sharedModel:n});break}case"markdown":{s=new Wt({sharedModel:n});break}default:s=new Bt({sharedModel:n})}this._cellMap.set(n,s),n.disposed.connect(()=>{s.dispose(),this._cellMap.delete(n)})}),this.length}_onSharedModelChanged(e,t){var n;let s=0;const o=new Array;(n=t.cellsChange)===null||n===void 0||n.forEach(i=>{i.insert!=null?(this._insertCells(s,i.insert),o.push({type:"add",newIndex:s,newValues:i.insert.map(a=>this._cellMap.get(a)),oldIndex:-2,oldValues:[]}),s+=i.insert.length):i.delete!=null?o.push({type:"remove",newIndex:-1,newValues:[],oldIndex:s,oldValues:new Array(i.delete).fill(void 0)}):i.retain!=null&&(s+=i.retain)}),o.forEach(i=>this._changed.emit(i))}}class Un{constructor(e){this._requestBatchSize=10,this._cursor=0,this._hasSession=!1,this._history=[],this._placeholder="",this._kernelSession="",this._setByHistory=!1,this._isDisposed=!1,this._editor=null,this._filtered=[],this._kernel=null,this._sessionContext=e.sessionContext,this._trans=(e.translator||_e).load("jupyterlab"),this._handleKernel().then(()=>{this._sessionContext.kernelChanged.connect(this._handleKernel,this)}),this._toRequest=this._requestBatchSize}get editor(){return this._editor}set editor(e){if(this._editor===e)return;const t=this._editor;t&&t.model.sharedModel.changed.disconnect(this.onTextChange,this),this._editor=e,e&&e.model.sharedModel.changed.connect(this.onTextChange,this)}get placeholder(){return this._placeholder}get kernelSession(){return this._kernelSession}get isDisposed(){return this._isDisposed}dispose(){this._isDisposed=!0,this._history.length=0,A.clearData(this)}async checkSession(e){var t;this._hasSession||(await this._retrieveHistory(),this._hasSession=!0,this.editor=e.editor,this._placeholder=((t=this._editor)===null||t===void 0?void 0:t.model.sharedModel.getSource())||"",this.setFilter(this._placeholder),this._cursor=this._filtered.length-1)}async back(e){return await this.checkSession(e),--this._cursor,this._cursor<0&&await this.fetchBatch(),this._cursor=Math.max(0,this._cursor),this._filtered[this._cursor]}async forward(e){return await this.checkSession(e),++this._cursor,this._cursor=Math.min(this._filtered.length-1,this._cursor),this._filtered[this._cursor]}updateEditor(e,t){var n,s;if(e){const o=(n=e.editor)===null||n===void 0?void 0:n.model,i=o?.sharedModel.getSource();if(this.isDisposed||!t||i===t)return;this._setByHistory=!0,o?.sharedModel.setSource(t);let a=0;a=t.indexOf(`
2
2
  `),a<0&&(a=t.length),(s=e.editor)===null||s===void 0||s.setCursorPosition({line:0,column:a})}}reset(){this._hasSession=!1,this._placeholder="",this._toRequest=this._requestBatchSize}async fetchBatch(){this._toRequest+=this._requestBatchSize;let e=this._filtered.slice().reverse(),t=this._history.slice();await this._retrieveHistory().then(()=>{this.setFilter(this._placeholder);let n=0,s=this._filtered.slice().reverse();for(let o=0;o<e.length;o++){let i=e[o];for(let a=o+n;a<s.length&&i!==s[a];a++)n+=1}this._cursor=this._filtered.length-(e.length+1)-n}),this._cursor<0&&this._history.length>t.length&&await this.fetchBatch()}onHistory(e,t){this._history.length=0;let n=["","",""],s=["","",""],o="";if(e.content.status==="ok"){for(let i=0;i<e.content.history.length;i++)s=e.content.history[i],s!==n&&(o=e.content.history[i][0],this._history.push(n=s));this.kernelSession||s[2]==t?.model.sharedModel.getSource()&&(this._kernelSession=o)}}onTextChange(){if(this._setByHistory){this._setByHistory=!1;return}this.reset()}async _handleKernel(){var e;if(this._kernel=(e=this._sessionContext.session)===null||e===void 0?void 0:e.kernel,!this._kernel){this._history.length=0;return}await this._retrieveHistory().catch()}async _retrieveHistory(e){var t;return await((t=this._kernel)===null||t===void 0?void 0:t.requestHistory(qn(this._toRequest)).then(n=>{this.onHistory(n,e)}).catch(()=>{console.warn(this._trans.__("History was unable to be retrieved"))}))}setFilter(e=""){this._filtered.length=0;let t="",n="";for(let s=0;s<this._history.length;s++)n=this._history[s][2],n!==t&&e!==n&&this._filtered.push(t=n);this._filtered.push(e)}}function qn(r){return{output:!1,raw:!0,hist_access_type:"tail",n:r}}class Ve{constructor(e={}){var t,n;this.standaloneModel=!1,this._readOnly=!1,this._contentChanged=new A(this),this._stateChanged=new A(this),this._isDisposed=!1,this._metadataChanged=new A(this),this.standaloneModel=typeof e.sharedModel>"u",e.sharedModel?this.sharedModel=e.sharedModel:this.sharedModel=Ae.create({disableDocumentWideUndoRedo:(t=e.disableDocumentWideUndoRedo)!==null&&t!==void 0?t:!0,data:{nbformat:Qe,nbformat_minor:Ie,metadata:{kernelspec:{name:"",display_name:""},language_info:{name:(n=e.languagePreference)!==null&&n!==void 0?n:""}}}}),this._cells=new Kn(this.sharedModel),this._trans=(e.translator||_e).load("jupyterlab"),this._deletedCells=[],this._collaborationEnabled=!!e?.collaborationEnabled,this._cells.changed.connect(this._onCellsChanged,this),this.sharedModel.changed.connect(this._onStateChanged,this),this.sharedModel.metadataChanged.connect(this._onMetadataChanged,this)}get contentChanged(){return this._contentChanged}get metadataChanged(){return this._metadataChanged}get stateChanged(){return this._stateChanged}get cells(){return this._cells}get dirty(){return this.sharedModel.dirty}set dirty(e){const t=this.dirty;e!==t&&(this.sharedModel.dirty=e)}get readOnly(){return this._readOnly}set readOnly(e){if(e===this._readOnly)return;const t=this._readOnly;this._readOnly=e,this.triggerStateChange({name:"readOnly",oldValue:t,newValue:e})}get metadata(){return this.sharedModel.metadata}get nbformat(){return this.sharedModel.nbformat}get nbformatMinor(){return this.sharedModel.nbformat_minor}get defaultKernelName(){var e;const t=this.getMetadata("kernelspec");return(e=t?.name)!==null&&e!==void 0?e:""}get deletedCells(){return this._deletedCells}get defaultKernelLanguage(){var e;const t=this.getMetadata("language_info");return(e=t?.name)!==null&&e!==void 0?e:""}get collaborative(){return this._collaborationEnabled}dispose(){if(this.isDisposed)return;this._isDisposed=!0;const e=this.cells;this._cells=null,e.dispose(),this.standaloneModel&&this.sharedModel.dispose(),A.clearData(this)}deleteMetadata(e){return this.sharedModel.deleteMetadata(e)}getMetadata(e){return this.sharedModel.getMetadata(e)}setMetadata(e,t){typeof t>"u"?this.sharedModel.deleteMetadata(e):this.sharedModel.setMetadata(e,t)}toString(){return JSON.stringify(this.toJSON())}fromString(e){this.fromJSON(JSON.parse(e))}toJSON(){return this._ensureMetadata(),this.sharedModel.toJSON()}fromJSON(e){var t,n;const s=W.deepCopy(e),o=e.metadata.orig_nbformat;if(s.nbformat=Math.max(e.nbformat,Qe),(s.nbformat!==e.nbformat||s.nbformat_minor<Ie)&&(s.nbformat_minor=Ie),o!==void 0&&s.nbformat!==o){const i=s.nbformat>o;let a;i?a=this._trans.__(`This notebook has been converted from an older notebook format (v%1)
3
3
  to the current notebook format (v%2).
4
4
  The next time you save this notebook, the current notebook format (v%2) will be used.
@@ -1,4 +1,4 @@
1
- import{E as N,eN as xo,r as o,j as t,eO as vo,eP as So,b_ as Rn,B as p,H as bt,T as H,c as Y,cu as zt,eu as Dt,eQ as ce,co as xt,e as yo,eR as Co,eS as wo,e3 as ko,eT as jo,aH as Io,dX as zn,dV as Eo,dY as Gt,eU as To,eV as Ro,eW as Ao,eX as Mo,eY as Po,eZ as Uo,e_ as $o,d3 as Oo,a_ as Fo,e$ as Lo,f0 as _o,f1 as zo,f2 as No,f3 as Bo,f4 as Vo,x as Nt,f5 as Ho,f6 as Wo,f7 as Do,f8 as Go,f9 as Ko,fa as Yo,fb as qo,fc as Jo,fd as Qo,fe as Xo,ff as Zo,fg as es,fh as ts,fi as ns,fj as os,fk as ss,fl as as,fm as is,fn as rs,fo as ls,fp as tt,fq as cs,fr as ds,fs as us,ft as fs,fu as An,fv as ps,fw as Fe,fx as ms,fy as gs,a$ as vt,fz as hs,fA as bs,fB as Mn,fC as xs,fD as vs,fE as Ss,fF as ys,eC as Cs,fG as Bt,fH as Ce,fI as ws,fJ as ks,fK as js,fL as Pn,fM as Is,fN as Un,fO as Es,fP as Ts,fQ as Rs,fR as As,fS as Ms,fT as Ps,fU as Us,fV as $s,fW as Os,fX as Fs,fY as St,fZ as Ls,f_ as _s,f$ as zs,I as Ns,g0 as Bs,g1 as Vs,g2 as $n,g3 as Hs,g4 as Ws,g5 as Ds,g6 as Kt,g7 as Gs,g8 as Ks,ek as Vt,g9 as Ys,ga as qs}from"../datalayer-app-main.js";import{S as Js,E as Qs,a as Xs}from"./SignInIcon-4HkE48mS.js";import{F as Zs,a as ea,b as ta}from"./LinkedInGreyIcon-BoWXE-HS.js";function Nn(){const n=N(xo);return o.useMemo(()=>n.map(a=>a.value),[n])}const Ht={github:{name:"github",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/github/callback"},google:{name:"google",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/google/callback"},linkedin:{name:"linkedin",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/linkedin/callback"}},On=()=>{if(typeof document>"u")return"";const n=document.getElementById("datalayer-config-data");if(!n?.textContent)return"";try{const a=JSON.parse(n.textContent);return String(a?.iamUrl||"").replace(/\/$/,"")}catch{return""}},na=(n,a="Unable to start social sign-in.")=>{if(n instanceof Error&&n.message)return n.message;if(typeof n=="string"&&n.trim())return n;if(n&&typeof n=="object"&&"message"in n){const l=n.message;if(typeof l=="string"&&l.trim())return l}return a},oa=jo`
1
+ import{E as N,e$ as xo,r as o,j as t,f0 as vo,f1 as So,b_ as Rn,B as p,H as bt,T as H,c as Y,cu as zt,eu as Dt,f2 as ce,co as xt,e as yo,f3 as Co,f4 as wo,e3 as ko,f5 as jo,aH as Io,dX as zn,dV as Eo,dY as Gt,f6 as To,f7 as Ro,f8 as Ao,f9 as Mo,fa as Po,fb as Uo,fc as $o,d3 as Fo,a_ as Lo,fd as Oo,fe as _o,ff as zo,fg as No,fh as Bo,fi as Vo,x as Nt,fj as Ho,fk as Wo,fl as Do,fm as Go,fn as Ko,fo as Yo,fp as qo,fq as Jo,fr as Qo,fs as Xo,ft as Zo,fu as es,fv as ts,fw as ns,fx as os,fy as ss,fz as as,fA as is,fB as rs,fC as ls,fD as tt,fE as cs,fF as ds,fG as us,fH as fs,fI as An,fJ as ps,fK as Le,fL as ms,fM as gs,a$ as vt,fN as hs,fO as bs,fP as Mn,fQ as xs,fR as vs,fS as Ss,fT as ys,eC as Cs,fU as Bt,fV as Ce,fW as ws,fX as ks,fY as js,fZ as Pn,f_ as Is,f$ as Un,g0 as Es,g1 as Ts,g2 as Rs,g3 as As,g4 as Ms,g5 as Ps,g6 as Us,g7 as $s,g8 as Fs,g9 as Ls,ga as St,gb as Os,gc as _s,gd as zs,I as Ns,ge as Bs,gf as Vs,gg as $n,gh as Hs,gi as Ws,gj as Ds,gk as Kt,gl as Gs,gm as Ks,ek as Vt,gn as Ys,go as qs}from"../datalayer-app-main.js";import{S as Js,E as Qs,a as Xs}from"./SignInIcon-4HkE48mS.js";import{F as Zs,a as ea,b as ta}from"./LinkedInGreyIcon-BoWXE-HS.js";function Nn(){const n=N(xo);return o.useMemo(()=>n.map(a=>a.value),[n])}const Ht={github:{name:"github",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/github/callback"},google:{name:"google",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/google/callback"},linkedin:{name:"linkedin",oauth2CallbackServerRoute:"jupyter_iam/oauth2/callback",oauth2CallbackUIRoute:"/iam/oauth2/linkedin/callback"}},Fn=()=>{if(typeof document>"u")return"";const n=document.getElementById("datalayer-config-data");if(!n?.textContent)return"";try{const a=JSON.parse(n.textContent);return String(a?.iamUrl||"").replace(/\/$/,"")}catch{return""}},na=(n,a="Unable to start social sign-in.")=>{if(n instanceof Error&&n.message)return n.message;if(typeof n=="string"&&n.trim())return n;if(n&&typeof n=="object"&&"message"in n){const l=n.message;if(typeof l=="string"&&l.trim())return l}return a},oa=jo`
2
2
  .signin-input-theme-scope input:-webkit-autofill,
3
3
  .signin-input-theme-scope input:-webkit-autofill:hover,
4
4
  .signin-input-theme-scope input:-webkit-autofill:focus,
@@ -25,8 +25,8 @@ import{E as N,eN as xo,r as o,j as t,eO as vo,eP as So,b_ as Rn,B as p,H as bt,T
25
25
  background-color: var(--bgColor-default) !important;
26
26
  opacity: 1 !important;
27
27
  }
28
- `,sa=({onSignIn:n,onApiKeySignIn:a,loginUrl:l,name:r,title:f="Datalayer OTEL",description:x="Sign in to access the observability dashboard.",icon:y,leadingIcon:I=t.jsx(ko,{size:24}),github:d=!1,google:we=!1,linkedin:q=!1,apiKey:nt=!1,signUp:O=!0,socialSignInNavigationTarget:ee,asDoc:v=!1,fillHeight:E=!0,hideHero:te=!1,calloutTitle:Le,calloutDescription:ot,passwordToggleLabel:de="Sign in with a password",signUpTitle:Yt="Don't have an account?",signUpDescription:J="Create a free Datalayer account with your email address.",signUpLabel:yt="Sign up with email",signUpHref:_e="https://datalayer.ai/signup",onSignUp:B,forgotPasswordHref:Q="/password",forgotPasswordLabel:ze="Forgot password?",showForgotPassword:Ct=!0,socialButtonMarginTop:h=3,actionButtonMaxWidth:X=320})=>{const ne=v&&!te,st=r??(v&&f==="Datalayer OTEL"?"Datalayer Sign In":f),wt=y??(v?t.jsx(Js,{size:24}):I),F=o.useMemo(()=>{if(l)return l;const c=On();return c?`${c}/api/iam/v1/login`:"/api/iam/v1/login"},[l]),[W,ke]=o.useState(""),[ue,kt]=o.useState(""),[at,jt]=o.useState(!1),[je,fe]=o.useState(!1),[w,pe]=o.useState(!1),[oe,it]=o.useState(!1),[Ne,Ie]=o.useState(null),[L,It]=o.useState(null),[me,Ee]=o.useState(""),[Te,rt]=o.useState(null),[Re,$]=o.useState(null),{enqueueToast:ge}=vo(),[Ae,se]=o.useState(!1),[ae,he]=o.useState(""),j=o.useRef(null),Me=o.useCallback(c=>So()?Rn.URLExt.join(Rn.PageConfig.getBaseUrl(),c.oauth2CallbackServerRoute):`${window.location.protocol}//${window.location.hostname}${window.location.port?`:${window.location.port}`:""}${c.oauth2CallbackUIRoute}`,[]),D=o.useMemo(()=>{if(typeof window>"u")return"/";const c=`${window.location.pathname}${window.location.search}${window.location.hash}`;return c.startsWith("/")?c:"/"},[]),V=o.useCallback(async c=>{if(!oe){$(null),Ie(c.name),it(!0);try{const k=On(),P=new URLSearchParams({provider:c.name,callback_uri:Me(c)}),g=ee===void 0?void 0:String(ee||"").trim(),R=g===void 0?D&&D!=="/"?D:void 0:g&&g.startsWith("/")&&!g.startsWith("//")?g:void 0;R&&P.set("post_auth_redirect",R);const re=`${k||""}/api/iam/v1/oauth2/authz/url?${P.toString()}`,S=await fetch(re),De=await S.json(),Pe=De?.autorization_url;if(!S.ok||!Pe)throw new Error(De?.message||"Unable to start social sign-in.");window.location.assign(Pe)}catch(k){const P=na(k);$(P),ge(P,{variant:"error"}),Ie(null),it(!1)}}},[Me,D,ge,oe,ee]);o.useEffect(()=>{Ae&&j.current?.focus()},[Ae]);const ie=o.useCallback(()=>{se(!1),he("")},[]),lt=o.useCallback(()=>{!ae.trim()||!a||(a(ae.trim()),ie())},[ae,a,ie]),ct=o.useCallback(()=>{if(B){B();return}window.location.assign(_e)},[B,_e]),G=o.useCallback(()=>{if(Q){if(Q.startsWith("http://")||Q.startsWith("https://")){window.open(Q,"_blank","noopener,noreferrer");return}window.location.assign(Q)}},[Q]),Be=o.useCallback(async()=>{if(!(v||!W||!ue||w)){pe(!0),$(null);try{const c=await fetch(F,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({handle:W,password:ue})});if(!c.ok)throw new Error(`HTTP ${c.status}`);const k=await c.json();if(k.success&&k.token){const P=String(k?.user?.id||k?.user?.uid||"").trim();if(!!k?.user?.mfaUrl&&P){It(P),rt(k.token),$(null);return}n&&n(k.token,W)}else $(k.message||"Invalid username or password.")}catch(c){$(c instanceof Error?c.message:String(c))}finally{pe(!1)}}},[v,W,ue,w,F,n]),Ve=o.useCallback(async()=>{if(!(v||w||!L||!me.trim()||!Te)){pe(!0),$(null);try{const c=new URL(F,window.location.origin),k=c.pathname.endsWith("/api/iam/v1/login")?c.href.replace(/\/api\/iam\/v1\/login$/,""):`${c.origin}`,P=await fetch(`${k}/api/iam/v1/users/${L}/mfa/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userUid:L,code:me.trim()})}),g=await P.json();if(!P.ok||!g?.success)throw new Error(g?.message||"Failed to validate your MFA code.");n&&n(Te,W)}catch(c){const k=c instanceof Error?c.message:String(c);$(k),ge(k,{variant:"error"})}finally{pe(!1)}}},[v,ge,W,w,F,me,Te,L,n]),He=o.useCallback(c=>{c.key==="Enter"&&(L?Ve():Be())},[L,Be,Ve]),We=oe||w||v;return t.jsxs(p,{className:"signin-input-theme-scope",display:"flex",alignItems:te||ne||!E?"flex-start":"center",justifyContent:"center",minHeight:te||ne||!E?"auto":"100vh",bg:te?"transparent":"canvas.default",color:"fg.default",py:te?0:ne?2:4,children:[t.jsx(oa,{}),t.jsxs(p,{width:"100%",maxWidth:440,p:0,children:[!te&&t.jsxs(t.Fragment,{children:[t.jsxs(p,{display:"flex",alignItems:"center",gap:2,mb:ne?2:3,justifyContent:"center",children:[wt,t.jsx(bt,{sx:{fontSize:3},children:st})]}),t.jsx(H,{as:"p",sx:{fontSize:1,color:"fg.muted",mb:ne?2:3,textAlign:"center"},children:x})]}),(Le||ot)&&t.jsxs(p,{mb:3,textAlign:"center",children:[Le&&t.jsx(bt,{as:"h3",sx:{fontSize:2,mb:1},children:Le}),ot&&t.jsx(H,{sx:{color:"fg.muted",fontSize:1},children:ot})]}),!L&&(d||we||q)&&t.jsxs(t.Fragment,{children:[d&&t.jsx(Y,{block:!0,size:"large",leadingVisual:Ne==="github"?()=>t.jsx(zt,{size:"small"}):Zs,disabled:We,onClick:()=>V(Ht.github),sx:{mt:h,maxWidth:X,mx:"auto"},children:"Sign in with GitHub"}),we&&t.jsx(Y,{block:!0,size:"large",leadingVisual:Ne==="google"?()=>t.jsx(zt,{size:"small"}):ea,disabled:We,onClick:()=>V(Ht.google),sx:{mt:h,maxWidth:X,mx:"auto"},children:"Sign in with Google"}),q&&t.jsx(Y,{block:!0,size:"large",leadingVisual:Ne==="linkedin"?()=>t.jsx(zt,{size:"small"}):ta,disabled:We,onClick:()=>V(Ht.linkedin),sx:{mt:h,maxWidth:X,mx:"auto"},children:"Sign in with LinkedIn"})]}),!L&&!at&&t.jsx(p,{mt:3,display:"flex",justifyContent:"center",children:t.jsx(Y,{leadingVisual:Dt,size:"large",block:!0,disabled:v||w||oe,onClick:()=>jt(!0),sx:{maxWidth:X,mx:"auto"},children:de})}),!L&&at&&t.jsxs(p,{mt:4,children:[t.jsxs(ce,{required:!0,sx:{mb:3},children:[t.jsx(ce.Label,{children:"Username"}),t.jsx(xt,{autoFocus:!0,block:!0,placeholder:"Your username",value:W,disabled:w||v,onChange:c=>ke(c.target.value),onKeyDown:He})]}),t.jsxs(ce,{required:!0,sx:{mb:3},children:[t.jsx(ce.Label,{children:"Password"}),t.jsx(xt,{block:!0,placeholder:"Your password",type:je?"text":"password",value:ue,disabled:w||v,onChange:c=>kt(c.target.value),onKeyDown:He,trailingAction:t.jsx(xt.Action,{onClick:()=>fe(!je),disabled:w||v,icon:je?Qs:Xs,"aria-label":je?"Hide password":"Show password",sx:{color:"var(--fgColor-muted)"}})})]}),t.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"space-between",mt:3,children:[t.jsx(Y,{variant:"primary",disabled:w||v||!W||!ue,onClick:Be,children:w?"Signing in…":"Sign In"}),Ct&&t.jsx(yo,{as:"button",sx:{fontSize:1,cursor:v?"not-allowed":"pointer",background:"none",border:"none",opacity:v?.6:1},onClick:()=>{v||w||G()},children:ze})]})]}),L&&t.jsxs(t.Fragment,{children:[t.jsxs(ce,{required:!0,sx:{mb:3,mt:2},children:[t.jsx(ce.Label,{children:"MFA Code"}),t.jsx(xt,{autoFocus:!0,block:!0,placeholder:"Your MFA code",value:me,disabled:w||v,onChange:c=>Ee(c.target.value),onKeyDown:He})]}),t.jsx(Y,{variant:"primary",block:!0,disabled:w||v||!me.trim(),onClick:Ve,sx:{maxWidth:X,mx:"auto"},children:w?"Validating…":"Validate MFA Code"})]}),Re&&t.jsx(H,{sx:{color:"danger.fg",fontSize:1,mt:3,display:"block"},children:Re}),O&&t.jsxs(p,{mt:4,pt:4,textAlign:"center",borderTop:"1px solid",borderColor:"border.muted",children:[t.jsx(bt,{as:"h3",sx:{fontSize:2,mb:2},children:Yt}),t.jsx(H,{as:"p",sx:{color:"fg.muted",fontSize:1,mb:3},children:J}),t.jsx(p,{display:"flex",justifyContent:"center",children:t.jsx(Y,{variant:"primary",size:"large",leadingVisual:Co,disabled:v||w,onClick:ct,children:yt})})]}),nt&&a&&t.jsxs(t.Fragment,{children:[t.jsxs(p,{display:"flex",alignItems:"center",gap:2,my:3,children:[t.jsx(p,{flex:1,height:"1px",bg:"border.default"}),t.jsx(H,{sx:{fontSize:0,color:"fg.muted"},children:"or"}),t.jsx(p,{flex:1,height:"1px",bg:"border.default"})]}),t.jsx(Y,{block:!0,leadingVisual:Dt,disabled:v||w||oe,onClick:()=>se(!0),sx:{maxWidth:X,mx:"auto"},children:"Sign in with an API Key"}),Ae&&t.jsx(p,{role:"dialog","aria-modal":"true","aria-labelledby":"signin-api-key-title",onKeyDown:c=>{c.key==="Escape"&&ie()},onClick:ie,position:"fixed",inset:0,zIndex:200,p:3,bg:"canvas.backdrop",display:"flex",alignItems:"center",justifyContent:"center",children:t.jsxs(p,{as:"form",onClick:c=>c.stopPropagation(),onSubmit:c=>{c.preventDefault(),lt()},width:"min(560px, 100%)",p:3,borderRadius:2,border:"1px solid",borderColor:"border.default",bg:"canvas.overlay",color:"fg.default",boxShadow:"shadow.large",children:[t.jsx(bt,{id:"signin-api-key-title",sx:{fontSize:2,mb:2},children:"Enter your API Key"}),t.jsxs(ce,{required:!0,children:[t.jsx(ce.Label,{children:"API Key"}),t.jsx(wo,{block:!0,required:!0,autoFocus:!0,placeholder:"Paste your API key here",value:ae,onInput:c=>he(c.currentTarget.value),ref:j})]}),t.jsxs(p,{mt:3,display:"flex",justifyContent:"flex-end",gap:2,children:[t.jsx(Y,{type:"button",onClick:ie,children:"Cancel"}),t.jsx(Y,{type:"submit",variant:"primary",disabled:!ae.trim(),children:"Authenticate"})]})]})})]})]})]})};function aa(n){const{agentId:a,instructions:l,model:r,frontendTools:f,inference:x,subagents:y,sharing:I,onSubagentEvent:d,modeEffect:we}=n;return{type:"browser-vercel-ai",endpoint:"",agentId:a,enableConfigQuery:!1,options:{instructions:l,model:r,frontendTools:f,inference:x,subagents:y,sharing:I,onSubagentEvent:d,modeEffect:we}}}const Fn=Io((n,a)=>({pending:void 0,suggest:(l,r)=>{const f=l.trim();f&&n({pending:{text:f,submit:r?.submit??!1,nonce:(a().pending?.nonce??0)+1}})},consume:()=>n({pending:void 0})}));function ia({agentName:n,sandboxStillRuns:a=!1,temporary:l=!0,onSignedIn:r,onSignUp:f}){const{configuration:x}=zn(),y=o.useCallback(I=>{Eo.getState().checkIAMToken(I),r?.()},[r]);return t.jsx(p,{height:"100%",minHeight:0,overflowY:"auto",bg:"canvas.default",px:4,py:4,children:t.jsxs(p,{maxWidth:440,mx:"auto",children:[t.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"center",gap:2,color:"attention.fg",mb:2,children:[t.jsx(Dt,{size:20}),t.jsx(H,{sx:{fontSize:2,fontWeight:"semibold",color:"fg.default"},children:l?"This demo runs on a shared key":"Your key has expired"})]}),t.jsxs(H,{as:"p",sx:{fontSize:1,color:"fg.muted",textAlign:"center",mb:3},children:[l?`${n??"The agent"} has used the time this key allows. Sign in to point your own agent at it, use your own data, and drop the time limit.`:`${n??"The agent"} stopped because your session ran out.`,a?" Your notebook is still running in this page.":""]}),t.jsx(sa,{hideHero:!0,fillHeight:!1,calloutTitle:"Sign in to keep going",github:!0,google:!0,linkedin:!0,socialSignInNavigationTarget:typeof window>"u"?void 0:`${window.location.pathname}${window.location.search}`,loginUrl:x?.iamUrl?`${x.iamUrl}/api/iam/v1/login`:void 0,onSignIn:y,onSignUp:f})]})})}const ra="https://r1.datalayer.run";function la(n=!0){const{configuration:a}=zn(),l=Gt(I=>I.token),r=a?.aiInferenceUrl||ra,f=To(r,n&&!l),x=l||f.token,y=o.useMemo(()=>({inferenceUrl:r,token:x||void 0}),[r,x]);return{inference:y,needsSignIn:Ro(y),anonymous:f,inferenceUrl:r}}const ca={name:"general-purpose",description:"A capable generalist for a task none of the specialists covers: research, reasoning, drafting, checking.",instructions:"You are a capable general-purpose assistant. Carry out the task you are given completely and report the result plainly, saying what you could not do."};function Ln(n){const a=n?.subagents;if(!a)return[];const l=(a.subagents??[]).map(r=>{const f=r.ref?Ao(r.ref):void 0;return{name:r.name,description:r.description||f?.description||r.name,instructions:r.instructions??f?.systemPrompt,model:r.model??f?.model??a.defaultModel,icon:f?.icon}});return a.includeGeneralPurpose?[...l,ca]:l}function da(n){return n.replace(/^datalayer_/,"").replace(/_lexical$/,"")}function ua(n){const a=da(n);return/^executeCodeIn(Notebook|Document)$/.test(a)||/^(read|list)[A-Z]/.test(a)}function fa(n,a){return n.filter(l=>a?.has(l.name)||ua(l.name))}function pa(n,a){const l=r=>a&&r.value.id===`${a}-tools`?0:r.value.id==="notebook-tools"?1:2;return n.map((r,f)=>({entry:r,index:f,rank:l(r)})).sort((r,f)=>r.rank-f.rank||r.index-f.index).map(r=>r.entry)}function ma(n,a,l){if(!l||!n.endsWith("-tools"))return!1;const r=n.slice(0,-6);return a.has(r)&&r!==l}const ga={type:"object",properties:{}};function ha(n,a){const l=new Set(n.toolset);return n.commands.filter(r=>l.has(r.name)).map(r=>({name:r.name,description:r.description,parameters:r.parameters??ga,location:"frontend",handler:async f=>{if(!a)throw new Error(`${r.name}: the ${n.plugin??n.id} plugin is not mounted on this page.`);const x=Object.keys(f??{}).length>0?f:void 0,y=await a.executeCommand(r.command,x);return y===void 0?{ok:!0,command:r.command,argument:x}:y}}))}function Bn(n,a){return n.flatMap(l=>ha(l,a))}function ba(){const n=Mo(),a=Nn();return o.useMemo(()=>Bn(a,n),[a,n])}function xa(n){const a=n?.app_instance;if(!a||typeof a!="object")return"";const l=a.deployment_uid;return typeof l=="string"?l.trim():""}function va(n,a,l){return n||!a?n:{id:l,messages:[]}}const Sa="var(--theme-accent)";function Vn({face:n,size:a}){return typeof n=="string"?t.jsx(Po,{emoji:n,size:a,label:""}):t.jsx(t.Fragment,{children:n})}function ya({face:n,size:a,state:l}){const r=l==="thinking"||l==="working",f=l==="paused";return t.jsxs(p,{as:"span","aria-hidden":!0,"data-presence":l,position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:a+8,height:a+8,flexShrink:0,fontSize:a,lineHeight:1,children:[t.jsx(p,{as:"span",position:"absolute",inset:0,borderRadius:"50%",boxShadow:f?"none":`0 0 0 2px ${Sa}`,border:f?"2px dashed":"none",borderColor:"border.default",opacity:r||l==="waiting"||f?.9:0,transition:"opacity var(--theme-motion-status, 0ms) var(--theme-motion-easing, ease)",animation:r?"loopPresenceBreath 1.8s ease-in-out infinite":"none",reducedMotion:{animation:"none"},sx:{"@keyframes loopPresenceBreath":{"0%, 100%":{transform:"scale(0.92)",opacity:.35},"50%":{transform:"scale(1.06)",opacity:.9}}}}),t.jsx(p,{as:"span",display:"inline-flex",opacity:f?.55:1,filter:f?"grayscale(0.6)":"none",transition:"opacity var(--theme-motion-status, 0ms) var(--theme-motion-easing, ease)",children:t.jsx(Vn,{face:n,size:a})})]})}function Ca({state:n}){return t.jsx(H,{role:"status","aria-live":"polite","data-presence-line":n,sx:{fontSize:0,color:n==="waiting"?"fg.default":"fg.muted",fontWeight:n==="waiting"?"semibold":"normal",whiteSpace:"nowrap",flexShrink:0},children:Uo[n]})}const wa=Kt(void 0),ka=Kt(""),ja=Kt({}),Z="",Ia=1400,_n=parseInt(Ys["--loop-face-large"],10);function Ma({workspace:n}){const a=$o(),l=Oo(),r=o.useRef(null),{setViewControls:f}=n,[x,y]=o.useState(null),I=Fo(),d=I.getConfig(Lo),we=d?.placeholder||a.placeholder,q=d?.defaultSurface??"notebook",nt=I.getConfig(_o),[O,ee]=o.useState(Z),v=o.useRef(!1),E=N(zo),te=N(No),Le=N(Bo),de=N(Vo)[0]?.value,J=Nt(de?.promptStance??wa)??de?.prompt,yt=N(Ho),_e=Wo(yt[0]?.value),B=o.useRef(_e);B.current=_e;const Q=o.useRef(""),ze=N(Do),Ct=o.useMemo(()=>Go(()=>ze.reduce((e,i)=>({...e,...i.value.extras.value}),{})),[ze]),h=Nt(ze.length>0?Ct:ja),X=o.useRef(new Set),ne=Ko(Gs,n),st=!ne.allowed,wt=st?ne.reason??"Chat is unavailable for this sandbox":void 0,[F,W]=o.useState(!1),[ke,ue]=o.useState(!1),[kt,at]=o.useState(!1),[jt,je]=o.useState({open:!1,pendingApproval:!1}),fe=Yo(F,jt,d?.presence?.paused===!0),w=d?.presence?.onPresence;o.useEffect(()=>{w?.(fe),B.current?.setPresence(fe)},[w,fe]);const pe=o.useRef(d?.presence?.onSaying);pe.current=d?.presence?.onSaying;const oe=o.useRef({answering:!1}),it=o.useCallback(e=>{r.current=e,ue(!!e)},[]),Ne=o.useCallback(e=>{const{open:i,pendingApproval:s}=qo(e);je(ye=>ye.open===i&&ye.pendingApproval===s?ye:{open:i,pendingApproval:s});const m={saying:Qo(e),answering:Jo(e)},u=oe.current;(u.saying?.id!==m.saying?.id||u.saying?.text!==m.saying?.text||u.answering!==m.answering)&&(oe.current=m,pe.current?.(m));const z=B.current;if(!z)return;z.items(e);const M=new Set(["complete","completed","done","error","failed","cancelled","canceled","rejected","denied","stopped"]),K={insertcell:"adding a cell",updatecell:"editing a cell",runcell:"running a cell",deletecells:"removing cells",readallcells:"reading the notebook",readcell:"reading a cell",executecode:"running code",insertblock:"adding a block",updateblock:"editing a block",runblock:"running a block",readdocument:"reading the document"};let b;for(let ye=e.length-1;ye>=0;ye-=1){const ht=e[ye];if(typeof ht.toolName=="string"&&ht.toolCallId){M.has(String(ht.status).toLowerCase())||(b=ht);break}}if(!b){z.activity(void 0);return}const Se=b.toolName.toLowerCase().replace(/^datalayer_/,"").replace(/_lexical$/,"").replace(/[^a-z]/g,""),bo=K[Se]??`using ${b.toolName}`;z.activity(`${Q.current||"The agent"} is ${bo}…`)},[]),Ie=o.useRef(h);Ie.current=h;const L=o.useCallback(e=>{eo(e),B.current?.usage(e),Ie.current.onUsage?.(e)},[]),It=o.useCallback(e=>{W(e),e||B.current?.end("done")},[]),me=o.useCallback(e=>{const i=B.current;if(!i)return;let s=-1;for(let u=e.length-1;u>=0;u-=1)if(e[u].role==="user"){s=u;break}const m=e.slice(s+1).filter(u=>u.role==="assistant").map(Xo).filter(u=>u.trim().length>0).join(`
28
+ `,sa=({onSignIn:n,onApiKeySignIn:a,loginUrl:l,name:r,title:f="Datalayer OTEL",description:x="Sign in to access the observability dashboard.",icon:y,leadingIcon:I=t.jsx(ko,{size:24}),github:d=!1,google:we=!1,linkedin:q=!1,apiKey:nt=!1,signUp:F=!0,socialSignInNavigationTarget:ee,asDoc:v=!1,fillHeight:E=!0,hideHero:te=!1,calloutTitle:Oe,calloutDescription:ot,passwordToggleLabel:de="Sign in with a password",signUpTitle:Yt="Don't have an account?",signUpDescription:J="Create a free Datalayer account with your email address.",signUpLabel:yt="Sign up with email",signUpHref:_e="https://datalayer.ai/signup",onSignUp:B,forgotPasswordHref:Q="/password",forgotPasswordLabel:ze="Forgot password?",showForgotPassword:Ct=!0,socialButtonMarginTop:h=3,actionButtonMaxWidth:X=320})=>{const ne=v&&!te,st=r??(v&&f==="Datalayer OTEL"?"Datalayer Sign In":f),wt=y??(v?t.jsx(Js,{size:24}):I),L=o.useMemo(()=>{if(l)return l;const c=Fn();return c?`${c}/api/iam/v1/login`:"/api/iam/v1/login"},[l]),[W,ke]=o.useState(""),[ue,kt]=o.useState(""),[at,jt]=o.useState(!1),[je,fe]=o.useState(!1),[w,pe]=o.useState(!1),[oe,it]=o.useState(!1),[Ne,Ie]=o.useState(null),[O,It]=o.useState(null),[me,Ee]=o.useState(""),[Te,rt]=o.useState(null),[Re,$]=o.useState(null),{enqueueToast:ge}=vo(),[Ae,se]=o.useState(!1),[ae,he]=o.useState(""),j=o.useRef(null),Me=o.useCallback(c=>So()?Rn.URLExt.join(Rn.PageConfig.getBaseUrl(),c.oauth2CallbackServerRoute):`${window.location.protocol}//${window.location.hostname}${window.location.port?`:${window.location.port}`:""}${c.oauth2CallbackUIRoute}`,[]),D=o.useMemo(()=>{if(typeof window>"u")return"/";const c=`${window.location.pathname}${window.location.search}${window.location.hash}`;return c.startsWith("/")?c:"/"},[]),V=o.useCallback(async c=>{if(!oe){$(null),Ie(c.name),it(!0);try{const k=Fn(),P=new URLSearchParams({provider:c.name,callback_uri:Me(c)}),g=ee===void 0?void 0:String(ee||"").trim(),R=g===void 0?D&&D!=="/"?D:void 0:g&&g.startsWith("/")&&!g.startsWith("//")?g:void 0;R&&P.set("post_auth_redirect",R);const re=`${k||""}/api/iam/v1/oauth2/authz/url?${P.toString()}`,S=await fetch(re),De=await S.json(),Pe=De?.autorization_url;if(!S.ok||!Pe)throw new Error(De?.message||"Unable to start social sign-in.");window.location.assign(Pe)}catch(k){const P=na(k);$(P),ge(P,{variant:"error"}),Ie(null),it(!1)}}},[Me,D,ge,oe,ee]);o.useEffect(()=>{Ae&&j.current?.focus()},[Ae]);const ie=o.useCallback(()=>{se(!1),he("")},[]),lt=o.useCallback(()=>{!ae.trim()||!a||(a(ae.trim()),ie())},[ae,a,ie]),ct=o.useCallback(()=>{if(B){B();return}window.location.assign(_e)},[B,_e]),G=o.useCallback(()=>{if(Q){if(Q.startsWith("http://")||Q.startsWith("https://")){window.open(Q,"_blank","noopener,noreferrer");return}window.location.assign(Q)}},[Q]),Be=o.useCallback(async()=>{if(!(v||!W||!ue||w)){pe(!0),$(null);try{const c=await fetch(L,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({handle:W,password:ue})});if(!c.ok)throw new Error(`HTTP ${c.status}`);const k=await c.json();if(k.success&&k.token){const P=String(k?.user?.id||k?.user?.uid||"").trim();if(!!k?.user?.mfaUrl&&P){It(P),rt(k.token),$(null);return}n&&n(k.token,W)}else $(k.message||"Invalid username or password.")}catch(c){$(c instanceof Error?c.message:String(c))}finally{pe(!1)}}},[v,W,ue,w,L,n]),Ve=o.useCallback(async()=>{if(!(v||w||!O||!me.trim()||!Te)){pe(!0),$(null);try{const c=new URL(L,window.location.origin),k=c.pathname.endsWith("/api/iam/v1/login")?c.href.replace(/\/api\/iam\/v1\/login$/,""):`${c.origin}`,P=await fetch(`${k}/api/iam/v1/users/${O}/mfa/validate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({userUid:O,code:me.trim()})}),g=await P.json();if(!P.ok||!g?.success)throw new Error(g?.message||"Failed to validate your MFA code.");n&&n(Te,W)}catch(c){const k=c instanceof Error?c.message:String(c);$(k),ge(k,{variant:"error"})}finally{pe(!1)}}},[v,ge,W,w,L,me,Te,O,n]),He=o.useCallback(c=>{c.key==="Enter"&&(O?Ve():Be())},[O,Be,Ve]),We=oe||w||v;return t.jsxs(p,{className:"signin-input-theme-scope",display:"flex",alignItems:te||ne||!E?"flex-start":"center",justifyContent:"center",minHeight:te||ne||!E?"auto":"100vh",bg:te?"transparent":"canvas.default",color:"fg.default",py:te?0:ne?2:4,children:[t.jsx(oa,{}),t.jsxs(p,{width:"100%",maxWidth:440,p:0,children:[!te&&t.jsxs(t.Fragment,{children:[t.jsxs(p,{display:"flex",alignItems:"center",gap:2,mb:ne?2:3,justifyContent:"center",children:[wt,t.jsx(bt,{sx:{fontSize:3},children:st})]}),t.jsx(H,{as:"p",sx:{fontSize:1,color:"fg.muted",mb:ne?2:3,textAlign:"center"},children:x})]}),(Oe||ot)&&t.jsxs(p,{mb:3,textAlign:"center",children:[Oe&&t.jsx(bt,{as:"h3",sx:{fontSize:2,mb:1},children:Oe}),ot&&t.jsx(H,{sx:{color:"fg.muted",fontSize:1},children:ot})]}),!O&&(d||we||q)&&t.jsxs(t.Fragment,{children:[d&&t.jsx(Y,{block:!0,size:"large",leadingVisual:Ne==="github"?()=>t.jsx(zt,{size:"small"}):Zs,disabled:We,onClick:()=>V(Ht.github),sx:{mt:h,maxWidth:X,mx:"auto"},children:"Sign in with GitHub"}),we&&t.jsx(Y,{block:!0,size:"large",leadingVisual:Ne==="google"?()=>t.jsx(zt,{size:"small"}):ea,disabled:We,onClick:()=>V(Ht.google),sx:{mt:h,maxWidth:X,mx:"auto"},children:"Sign in with Google"}),q&&t.jsx(Y,{block:!0,size:"large",leadingVisual:Ne==="linkedin"?()=>t.jsx(zt,{size:"small"}):ta,disabled:We,onClick:()=>V(Ht.linkedin),sx:{mt:h,maxWidth:X,mx:"auto"},children:"Sign in with LinkedIn"})]}),!O&&!at&&t.jsx(p,{mt:3,display:"flex",justifyContent:"center",children:t.jsx(Y,{leadingVisual:Dt,size:"large",block:!0,disabled:v||w||oe,onClick:()=>jt(!0),sx:{maxWidth:X,mx:"auto"},children:de})}),!O&&at&&t.jsxs(p,{mt:4,children:[t.jsxs(ce,{required:!0,sx:{mb:3},children:[t.jsx(ce.Label,{children:"Username"}),t.jsx(xt,{autoFocus:!0,block:!0,placeholder:"Your username",value:W,disabled:w||v,onChange:c=>ke(c.target.value),onKeyDown:He})]}),t.jsxs(ce,{required:!0,sx:{mb:3},children:[t.jsx(ce.Label,{children:"Password"}),t.jsx(xt,{block:!0,placeholder:"Your password",type:je?"text":"password",value:ue,disabled:w||v,onChange:c=>kt(c.target.value),onKeyDown:He,trailingAction:t.jsx(xt.Action,{onClick:()=>fe(!je),disabled:w||v,icon:je?Qs:Xs,"aria-label":je?"Hide password":"Show password",sx:{color:"var(--fgColor-muted)"}})})]}),t.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"space-between",mt:3,children:[t.jsx(Y,{variant:"primary",disabled:w||v||!W||!ue,onClick:Be,children:w?"Signing in…":"Sign In"}),Ct&&t.jsx(yo,{as:"button",sx:{fontSize:1,cursor:v?"not-allowed":"pointer",background:"none",border:"none",opacity:v?.6:1},onClick:()=>{v||w||G()},children:ze})]})]}),O&&t.jsxs(t.Fragment,{children:[t.jsxs(ce,{required:!0,sx:{mb:3,mt:2},children:[t.jsx(ce.Label,{children:"MFA Code"}),t.jsx(xt,{autoFocus:!0,block:!0,placeholder:"Your MFA code",value:me,disabled:w||v,onChange:c=>Ee(c.target.value),onKeyDown:He})]}),t.jsx(Y,{variant:"primary",block:!0,disabled:w||v||!me.trim(),onClick:Ve,sx:{maxWidth:X,mx:"auto"},children:w?"Validating…":"Validate MFA Code"})]}),Re&&t.jsx(H,{sx:{color:"danger.fg",fontSize:1,mt:3,display:"block"},children:Re}),F&&t.jsxs(p,{mt:4,pt:4,textAlign:"center",borderTop:"1px solid",borderColor:"border.muted",children:[t.jsx(bt,{as:"h3",sx:{fontSize:2,mb:2},children:Yt}),t.jsx(H,{as:"p",sx:{color:"fg.muted",fontSize:1,mb:3},children:J}),t.jsx(p,{display:"flex",justifyContent:"center",children:t.jsx(Y,{variant:"primary",size:"large",leadingVisual:Co,disabled:v||w,onClick:ct,children:yt})})]}),nt&&a&&t.jsxs(t.Fragment,{children:[t.jsxs(p,{display:"flex",alignItems:"center",gap:2,my:3,children:[t.jsx(p,{flex:1,height:"1px",bg:"border.default"}),t.jsx(H,{sx:{fontSize:0,color:"fg.muted"},children:"or"}),t.jsx(p,{flex:1,height:"1px",bg:"border.default"})]}),t.jsx(Y,{block:!0,leadingVisual:Dt,disabled:v||w||oe,onClick:()=>se(!0),sx:{maxWidth:X,mx:"auto"},children:"Sign in with an API Key"}),Ae&&t.jsx(p,{role:"dialog","aria-modal":"true","aria-labelledby":"signin-api-key-title",onKeyDown:c=>{c.key==="Escape"&&ie()},onClick:ie,position:"fixed",inset:0,zIndex:200,p:3,bg:"canvas.backdrop",display:"flex",alignItems:"center",justifyContent:"center",children:t.jsxs(p,{as:"form",onClick:c=>c.stopPropagation(),onSubmit:c=>{c.preventDefault(),lt()},width:"min(560px, 100%)",p:3,borderRadius:2,border:"1px solid",borderColor:"border.default",bg:"canvas.overlay",color:"fg.default",boxShadow:"shadow.large",children:[t.jsx(bt,{id:"signin-api-key-title",sx:{fontSize:2,mb:2},children:"Enter your API Key"}),t.jsxs(ce,{required:!0,children:[t.jsx(ce.Label,{children:"API Key"}),t.jsx(wo,{block:!0,required:!0,autoFocus:!0,placeholder:"Paste your API key here",value:ae,onInput:c=>he(c.currentTarget.value),ref:j})]}),t.jsxs(p,{mt:3,display:"flex",justifyContent:"flex-end",gap:2,children:[t.jsx(Y,{type:"button",onClick:ie,children:"Cancel"}),t.jsx(Y,{type:"submit",variant:"primary",disabled:!ae.trim(),children:"Authenticate"})]})]})})]})]})]})};function aa(n){const{agentId:a,instructions:l,model:r,frontendTools:f,inference:x,subagents:y,sharing:I,onSubagentEvent:d,modeEffect:we}=n;return{type:"browser-vercel-ai",endpoint:"",agentId:a,enableConfigQuery:!1,options:{instructions:l,model:r,frontendTools:f,inference:x,subagents:y,sharing:I,onSubagentEvent:d,modeEffect:we}}}const Ln=Io((n,a)=>({pending:void 0,suggest:(l,r)=>{const f=l.trim();f&&n({pending:{text:f,submit:r?.submit??!1,nonce:(a().pending?.nonce??0)+1}})},consume:()=>n({pending:void 0})}));function ia({agentName:n,sandboxStillRuns:a=!1,temporary:l=!0,onSignedIn:r,onSignUp:f}){const{configuration:x}=zn(),y=o.useCallback(I=>{Eo.getState().checkIAMToken(I),r?.()},[r]);return t.jsx(p,{height:"100%",minHeight:0,overflowY:"auto",bg:"canvas.default",px:4,py:4,children:t.jsxs(p,{maxWidth:440,mx:"auto",children:[t.jsxs(p,{display:"flex",alignItems:"center",justifyContent:"center",gap:2,color:"attention.fg",mb:2,children:[t.jsx(Dt,{size:20}),t.jsx(H,{sx:{fontSize:2,fontWeight:"semibold",color:"fg.default"},children:l?"This demo runs on a shared key":"Your key has expired"})]}),t.jsxs(H,{as:"p",sx:{fontSize:1,color:"fg.muted",textAlign:"center",mb:3},children:[l?`${n??"The agent"} has used the time this key allows. Sign in to point your own agent at it, use your own data, and drop the time limit.`:`${n??"The agent"} stopped because your session ran out.`,a?" Your notebook is still running in this page.":""]}),t.jsx(sa,{hideHero:!0,fillHeight:!1,calloutTitle:"Sign in to keep going",github:!0,google:!0,linkedin:!0,socialSignInNavigationTarget:typeof window>"u"?void 0:`${window.location.pathname}${window.location.search}`,loginUrl:x?.iamUrl?`${x.iamUrl}/api/iam/v1/login`:void 0,onSignIn:y,onSignUp:f})]})})}const ra="https://r1.datalayer.run";function la(n=!0){const{configuration:a}=zn(),l=Gt(I=>I.token),r=a?.aiInferenceUrl||ra,f=To(r,n&&!l),x=l||f.token,y=o.useMemo(()=>({inferenceUrl:r,token:x||void 0}),[r,x]);return{inference:y,needsSignIn:Ro(y),anonymous:f,inferenceUrl:r}}const ca={name:"general-purpose",description:"A capable generalist for a task none of the specialists covers: research, reasoning, drafting, checking.",instructions:"You are a capable general-purpose assistant. Carry out the task you are given completely and report the result plainly, saying what you could not do."};function On(n){const a=n?.subagents;if(!a)return[];const l=(a.subagents??[]).map(r=>{const f=r.ref?Ao(r.ref):void 0;return{name:r.name,description:r.description||f?.description||r.name,instructions:r.instructions??f?.systemPrompt,model:r.model??f?.model??a.defaultModel,icon:f?.icon}});return a.includeGeneralPurpose?[...l,ca]:l}function da(n){return n.replace(/^datalayer_/,"").replace(/_lexical$/,"")}function ua(n){const a=da(n);return/^executeCodeIn(Notebook|Document)$/.test(a)||/^(read|list)[A-Z]/.test(a)}function fa(n,a){return n.filter(l=>a?.has(l.name)||ua(l.name))}function pa(n,a){const l=r=>a&&r.value.id===`${a}-tools`?0:r.value.id==="notebook-tools"?1:2;return n.map((r,f)=>({entry:r,index:f,rank:l(r)})).sort((r,f)=>r.rank-f.rank||r.index-f.index).map(r=>r.entry)}function ma(n,a,l){if(!l||!n.endsWith("-tools"))return!1;const r=n.slice(0,-6);return a.has(r)&&r!==l}const ga={type:"object",properties:{}};function ha(n,a){const l=new Set(n.toolset);return n.commands.filter(r=>l.has(r.name)).map(r=>({name:r.name,description:r.description,parameters:r.parameters??ga,location:"frontend",handler:async f=>{if(!a)throw new Error(`${r.name}: the ${n.plugin??n.id} plugin is not mounted on this page.`);const x=Object.keys(f??{}).length>0?f:void 0,y=await a.executeCommand(r.command,x);return y===void 0?{ok:!0,command:r.command,argument:x}:y}}))}function Bn(n,a){return n.flatMap(l=>ha(l,a))}function ba(){const n=Mo(),a=Nn();return o.useMemo(()=>Bn(a,n),[a,n])}function xa(n){const a=n?.app_instance;if(!a||typeof a!="object")return"";const l=a.deployment_uid;return typeof l=="string"?l.trim():""}function va(n,a,l){return n||!a?n:{id:l,messages:[]}}const Sa=({state:n})=>Po[n],ya="var(--theme-accent)";function Vn({face:n,size:a}){return typeof n=="string"?t.jsx(Uo,{emoji:n,size:a,label:""}):t.jsx(t.Fragment,{children:n})}function Ca({face:n,size:a,state:l}){const r=l==="thinking"||l==="working",f=l==="paused";return t.jsxs(p,{as:"span","aria-hidden":!0,"data-presence":l,position:"relative",display:"inline-flex",alignItems:"center",justifyContent:"center",width:a+8,height:a+8,flexShrink:0,fontSize:a,lineHeight:1,children:[t.jsx(p,{as:"span",position:"absolute",inset:0,borderRadius:"50%",boxShadow:f?"none":`0 0 0 2px ${ya}`,border:f?"2px dashed":"none",borderColor:"border.default",opacity:r||l==="waiting"||f?.9:0,transition:"opacity var(--theme-motion-status, 0ms) var(--theme-motion-easing, ease)",animation:r?"loopPresenceBreath 1.8s ease-in-out infinite":"none",reducedMotion:{animation:"none"},sx:{"@keyframes loopPresenceBreath":{"0%, 100%":{transform:"scale(0.92)",opacity:.35},"50%":{transform:"scale(1.06)",opacity:.9}}}}),t.jsx(p,{as:"span",display:"inline-flex",opacity:f?.55:1,filter:f?"grayscale(0.6)":"none",transition:"opacity var(--theme-motion-status, 0ms) var(--theme-motion-easing, ease)",children:t.jsx(Vn,{face:n,size:a})})]})}function wa({state:n}){return t.jsx(H,{role:"status","aria-live":"polite","data-presence-line":n,sx:{fontSize:0,color:n==="waiting"?"fg.default":"fg.muted",fontWeight:n==="waiting"?"semibold":"normal",whiteSpace:"nowrap",flexShrink:0},children:Sa({state:n})})}const ka=Kt(void 0),ja=Kt(""),Ia=Kt({}),Z="",Ea=1400,_n=parseInt(Ys["--loop-face-large"],10);function Pa({workspace:n}){const a=$o(),l=Fo(),r=o.useRef(null),{setViewControls:f}=n,[x,y]=o.useState(null),I=Lo(),d=I.getConfig(Oo),we=d?.placeholder||a.placeholder,q=d?.defaultSurface??"notebook",nt=I.getConfig(_o),[F,ee]=o.useState(Z),v=o.useRef(!1),E=N(zo),te=N(No),Oe=N(Bo),de=N(Vo)[0]?.value,J=Nt(de?.promptStance??ka)??de?.prompt,yt=N(Ho),_e=Wo(yt[0]?.value),B=o.useRef(_e);B.current=_e;const Q=o.useRef(""),ze=N(Do),Ct=o.useMemo(()=>Go(()=>ze.reduce((e,i)=>({...e,...i.value.extras.value}),{})),[ze]),h=Nt(ze.length>0?Ct:Ia),X=o.useRef(new Set),ne=Ko(Gs,n),st=!ne.allowed,wt=st?ne.reason??"Chat is unavailable for this sandbox":void 0,[L,W]=o.useState(!1),[ke,ue]=o.useState(!1),[kt,at]=o.useState(!1),[jt,je]=o.useState({open:!1,pendingApproval:!1}),fe=Yo(L,jt,d?.presence?.paused===!0),w=d?.presence?.onPresence;o.useEffect(()=>{w?.(fe),B.current?.setPresence(fe)},[w,fe]);const pe=o.useRef(d?.presence?.onSaying);pe.current=d?.presence?.onSaying;const oe=o.useRef({answering:!1}),it=o.useCallback(e=>{r.current=e,ue(!!e)},[]),Ne=o.useCallback(e=>{const{open:i,pendingApproval:s}=qo(e);je(ye=>ye.open===i&&ye.pendingApproval===s?ye:{open:i,pendingApproval:s});const m={saying:Qo(e),answering:Jo(e)},u=oe.current;(u.saying?.id!==m.saying?.id||u.saying?.text!==m.saying?.text||u.answering!==m.answering)&&(oe.current=m,pe.current?.(m));const z=B.current;if(!z)return;z.items(e);const M=new Set(["complete","completed","done","error","failed","cancelled","canceled","rejected","denied","stopped"]),K={insertcell:"adding a cell",updatecell:"editing a cell",runcell:"running a cell",deletecells:"removing cells",readallcells:"reading the notebook",readcell:"reading a cell",executecode:"running code",insertblock:"adding a block",updateblock:"editing a block",runblock:"running a block",readdocument:"reading the document"};let b;for(let ye=e.length-1;ye>=0;ye-=1){const ht=e[ye];if(typeof ht.toolName=="string"&&ht.toolCallId){M.has(String(ht.status).toLowerCase())||(b=ht);break}}if(!b){z.activity(void 0);return}const Se=b.toolName.toLowerCase().replace(/^datalayer_/,"").replace(/_lexical$/,"").replace(/[^a-z]/g,""),bo=K[Se]??`using ${b.toolName}`;z.activity(`${Q.current||"The agent"} is ${bo}…`)},[]),Ie=o.useRef(h);Ie.current=h;const O=o.useCallback(e=>{eo(e),B.current?.usage(e),Ie.current.onUsage?.(e)},[]),It=o.useCallback(e=>{W(e),e||B.current?.end("done")},[]),me=o.useCallback(e=>{const i=B.current;if(!i)return;let s=-1;for(let u=e.length-1;u>=0;u-=1)if(e[u].role==="user"){s=u;break}const m=e.slice(s+1).filter(u=>u.role==="assistant").map(Xo).filter(u=>u.trim().length>0).join(`
29
29
 
30
30
  `);i.assistant(m)},[]),Ee=o.useRef([]),Te=o.useRef(!1),rt=o.useRef(void 0),Re=o.useRef(void 0),$=o.useRef(void 0),ge=N(Zo),Ae=o.useRef(ge);Ae.current=ge;const se=o.useCallback((e,i)=>{if(Re.current)return Re.current;const s=$.current;$.current=void 0;const m=es(Ae.current.map(M=>M.value),s?{...i??{},voice:s}:i),u=m?.loop;if(Te.current&&u?.files&&u.files.length>0){const M=rt.current;if(!M)return"A file is given to an application running on a runtime: run it on Datalayer or on your machine to give it one.";let K;try{K=u.files.map(b=>({file:ns(String(b.name??"")),base64:ts(String(b.data_url??""))}))}catch(b){return b instanceof Error?b.message:String(b)}M.execute(os(K)).then(b=>{if(!b.success){y(`The files could not be put in the sandbox: ${b.error??"it failed"}.`);return}se(`${e}
31
31
 
32
- ${ss(K.map(Se=>Se.file))}`,{...m,loop:Object.fromEntries(Object.entries(u).filter(([Se])=>Se!=="files"))})});return}B.current?.begin(e,r.current?.thread());const z=r.current?.send;if(!z){Ee.current.push([e,m]);return}z(e,m)},[]);o.useEffect(()=>{f(ke?{busy:F,stop:r.current?.stop,newChat:r.current?.newChat,send:se}:null)},[F,ke,f,se]),o.useEffect(()=>()=>f(null),[f]),o.useEffect(()=>n.prompts.subscribe(se),[n.prompts,se]),o.useEffect(()=>{if(!ke||Ee.current.length===0)return;const e=Ee.current.splice(0,Ee.current.length);for(const[i,s]of e)r.current?.send(i,s)},[ke]);const ae=o.useRef(!1),he=o.useCallback(async e=>{y(null);const i=await as(Ie.current,e);if(i){i.sent?Je(""):y(i.refused);return}ae.current||(ae.current=!0,nt?.firstPromptHook?.());const s=await n.submit(e);if(!s.handled){y(s.reason??null);return}Je(""),s.result?.content&&y(s.result.content)},[n,nt?.firstPromptHook]),j=o.useMemo(()=>E.find(e=>e.value.surfaceId===O)?.value,[E,O]),Me=o.useCallback(e=>{v.current=!0,ee(e)},[]);o.useEffect(()=>is(Me),[Me]),o.useEffect(()=>{rs(E.map(e=>e.value.surfaceId))},[E]),o.useEffect(()=>{ls(O&&O!==Z?O:qs)},[O]);const D=o.useMemo(()=>q===Z||q==="none"?void 0:E.find(e=>e.value.surfaceId===q),[E,q]);o.useEffect(()=>{v.current||!D||tt(D.value,n)&&ee(q)},[D,n,q]);const[V,ie]=o.useState(null),lt=o.useRef(null),ct=d?.fullScreenTopOffset??0,{fullScreen:G,usingApi:Be,toggle:Ve,topOffsetPx:He}=cs(lt,{forceOverlay:!!ct,topOffset:ct}),[We,c]=o.useState(!1),k=o.useRef(!1);o.useEffect(()=>{!F||k.current||G||(k.current=!0,c(!0))},[F,G]),o.useEffect(()=>{G&&c(!1)},[G]),o.useEffect(()=>{j&&!tt(j,n)&&(ie(j.surfaceId),ee(Z))},[j,n]);const P=o.useMemo(()=>{if(V)return E.find(e=>e.value.surfaceId===V)?.value;if(!v.current&&O===Z)return D?.value},[E,V,O,D]);o.useEffect(()=>{if(!V||O!==Z)return;const e=E.find(i=>i.value.surfaceId===V);e&&tt(e.value,n)&&(ie(null),ee(V))},[E,O,V,n]);const g=n.agentId?.trim()||"default",R=ds(n.sandbox.target??"local");Te.current=R;const C=us(),re=Nt(C?.selected??ka),S=C?.members.find(e=>e.id===re),De=N(fs)[0]?.value,Pe=De?.specId,A=An(S?.specId??g)??(Pe?An(Pe):void 0),Ge=S?void 0:De,qt=R&&!S?Ds(Pe,A):void 0;Q.current=S?.name??A?.name??g;const Jt=N(ps),Qt=h.hiddenOpeners,Xt=h.hideOpeners,Et=h.openers,Tt=o.useMemo(()=>{if(Xt)return[];const e=new Set(Qt??[]),i=b=>e.size===0?b:b.filter(Se=>!e.has(Se.text));if(Et)return i(Et);const s=Jt.flatMap(b=>b.value.suggestions);if(s.length>0)return i(s);const m=i(A?.suggestions??[]),u=i(C?.team.suggestions??[]);if(u.length===0)return m;const z=new Set(u.map(b=>b.text)),M=C?.team.name??"Team",K=S?.name??A?.name??g;return[...u.map(b=>({...b,group:M})),...m.filter(b=>!z.has(b.text)).map(b=>({...b,group:K}))]},[Jt,C,A,S,g,Qt,Xt,Et]),dt=o.useMemo(()=>Tt.map(e=>({title:e.summary??e.text,message:e.message??e.text,group:e.group})),[Tt]),Rt=Fe(A?.icon),_=d?.presence,Hn=Fe(C?.team.icon),Zt=N(ms),ut=o.useMemo(()=>{const e=[],i=new Map,s=new Set,m=new Set(E.map(u=>u.value.surfaceId));for(const u of pa(Zt,j?.surfaceId)){if(ma(u.value.id,m,j?.surfaceId))continue;let z;try{z=u.value.tools(n)}catch(M){console.warn(`[loop] frontend tools from '${u.plugin}' failed:`,M);continue}for(const M of z){const K=i.get(M.name);if(K){console.warn(`[loop] frontend tool '${M.name}' from '${u.plugin}' is shadowed by the one from '${K}'.`);continue}i.set(M.name,u.plugin),e.push(M),u.value.chatView&&s.add(M.name)}}for(const u of h.frontendTools??[])i.has(u.name)||(i.set(u.name,"chat-extras"),e.push(u),s.add(u.name));return j?e:fa(e,s)},[Zt,n.surfaceId,n.agentId,h.frontendTools,j?.surfaceId,E]),At=ba(),Ke=o.useMemo(()=>{if(At.length===0)return ut;const e=new Set(ut.map(i=>i.name));return[...ut,...At.filter(i=>!e.has(i.name))]},[ut,At]),en=Nn(),Mt=h.agentToolBundles,Wn=o.useMemo(()=>{const e=h.frontendTools??[];if(!Mt?.length)return h.frontendTools;const i=Bn(en.filter(m=>Mt.includes(m.id)),I),s=new Set(e.map(m=>m.name));return[...e,...i.filter(m=>!s.has(m.name))]},[h.frontendTools,Mt,en,I]);rt.current=R&&Ke.some(e=>e.name===gs)?I.getOutput(vt)?.sandbox:void 0;const T=hs(n.sandbox,n.serverUrl),tn=N(bs),Dn=o.useMemo(()=>tn.filter(e=>e.value.composer).map(e=>({name:e.value.name,description:e.value.description})),[tn]),Gn=o.useMemo(()=>{if(!C||!S)return Ln(A).map(s=>({name:s.name,description:s.description,icon:Fe(s.icon)}));const e=C.members.map(s=>({name:s.name,description:s.description,emoji:s.emoji,icon:Fe(s.icon),disabled:s.id===S.id,disabledReason:s.id===S.id?`You are already talking to ${s.name}`:void 0})),i=Mn(C.team,S.id).filter(s=>!C.members.some(m=>m.name===s.name)).map(s=>({name:s.name,description:s.description,icon:Fe(s.icon)}));return[...e,...i]},[C,S,A]),{inference:nn,anonymous:Kn}=la(R),Yn=Gt(e=>e.user),Pt=R&&Kn.status==="expired",on=!Yn,Ye=xs();Re.current=Ye.disabled?Ye.disableReason||"This conversation is closed here.":void 0;const Ut=T===void 0?vs(n.sandbox,a):void 0,qe=st||Pt||!!qt||!!Ut||Ye.disabled,sn=Pt?on?a.demoKeyExpired:a.keyExpired:qt??Ut??wt??(Ye.disabled?Ye.disableReason:void 0),[$t,Je]=o.useState(""),[an]=Ss(),Qe=o.useMemo(()=>d?.voice?ys(d.voice,an):void 0,[d?.voice,an]),[qn,Jn]=o.useState(!1),[Qn,rn]=o.useState(),ft=Qn??Ge?.model??A?.model??n.model??"",Ue=Cs(),ln=o.useRef(Ue),cn=o.useRef(re),dn=o.useRef(Ue);dn.current=Ue,o.useEffect(()=>{cn.current!==re&&(cn.current=re,ln.current=dn.current,rn(void 0))},[re]);const Xn=Ue&&Ue!==ln.current?Ue:null,[Zn,eo]=o.useState(),to=Xn??Zn??null,no=Bt(Ce.inpromptMenu),un=Bt(Ce.promptAction),fn=Bt(Ce.chatHeader),oo=o.useMemo(()=>C?.members.map(e=>({id:e.id,name:e.name,description:e.description,icon:Fe(e.icon)}))??[],[C]),be=Fn(e=>e.pending),[pn,so]=o.useState(0);o.useEffect(()=>ws(()=>so(e=>e+1)),[]),o.useEffect(()=>{be&&(Je(be.text),Fn.getState().consume(),be.submit&&he(be.text))},[be]);const mn=I.getConfig(vt)?.datalayerCreatePayload,xe=!!(Ge?.createPayload?.app_spec||mn?.app_spec),Xe=xa(mn),ao=Gt(e=>e.token),Ot=I.getConfig(vt)?.datalayerVisitors,io=ks(Ot),ro=I.getConfig(vt)?.embedToken,ve=Ot?io.token:ro||ao,lo=o.useMemo(()=>js(d?.voice,ve||void 0,Xe),[d?.voice,ve,Xe]),le=!!(Xe||Ot);if(le&&!xe)throw new Error("A deployment’s page runs its application: its host gave no app_spec.");const[gn]=o.useState(Pn),U=o.useMemo(()=>va(d?.thread,Xe,gn),[d?.thread,Xe,gn]),[$e,hn]=o.useState(null),co=!!(U?.fromRuntime&&$e?.given!==U.id);o.useEffect(()=>{if(!U?.fromRuntime||!xe||!T)return;let e=!0;return(async()=>{let i="";for(let s=0;s<4&&e;s+=1)try{const m=await Is({agentBaseUrl:T,agentId:g,uid:U.id,token:ve});e&&hn({given:U.id,thread:{...U,fromRuntime:!1,messages:m}});return}catch(m){i=m instanceof Error?m.message:String(m),await new Promise(u=>setTimeout(u,1500))}e&&hn({given:U.id,thread:{id:Pn(),messages:[],onStarted:U.onStarted},said:Un.notOpened(i)})})(),()=>{e=!1}},[U?.id,U?.fromRuntime,xe,T,g,ve]);const bn=U?.fromRuntime?$e?.given===U.id?$e.thread:void 0:U,Ft=o.useMemo(()=>R?aa({agentId:S?.specId??g,instructions:Es(A,Ge?.instructions),model:ft||void 0,inference:nn,frontendTools:Ke,subagents:C&&S?Mn(C.team,S.id):Ln(A),sharing:C?.sharing,onSubagentEvent:e=>Ks.getState().appendSubagentEvent(e),modeEffect:Ge?.modeEffect}):T!==void 0?{type:"ag-ui",endpoint:xe?`${T}/api/v1/apps/agents/${encodeURIComponent(g)}/ag-ui/`:`${T}/api/v1/ag-ui/${g}/`,...xe&&ve?{authToken:ve}:{},...xe?{uiSocket:`${T.replace(/^http/,"ws")}/api/v1/apps/ui`,uiFiles:`${T}/api/v1/apps/agents/${encodeURIComponent(g)}/files`,appSessions:`${T}/api/v1/apps/sessions`,...le?{ownRoutesOnly:!0}:{}}:{},agentId:g,configEndpoint:`${T}/api/v1/configure`,enableConfigQuery:!0}:void 0,[g,R,nn,S,Ke,C,A,Ge,ft,T,xe,ve,le]),pt=Ts(!R,Ft?.type==="ag-ui"?Ft.configEndpoint:void 0,void 0,g),Ze=Rs(),mt=As(g),[xn,Lt]=o.useState(void 0),[uo,fo]=o.useState(void 0);o.useEffect(()=>{if(R||T===void 0)return;const e=Ms(T,g,le);if(!e){Lt([]);return}let i=!1;return fetch(e).then(s=>s.ok?s.json():null).then(s=>{i||(Lt(s?Ps(s):[]),fo(s?Us(s):void 0))}).catch(()=>{i||Lt([])}),()=>{i=!0}},[T,g,R,le]);const po=o.useMemo(()=>$s(xn,()=>Object.values(Os).filter(e=>e.available&&Fs(e)).map(e=>({id:e.id,name:e.name,provider:e.provider}))),[xn]),vn=o.useMemo(()=>{const e=pt.data?.builtinTools??[],i=new Set(e.map(s=>s.name));return{runtime:e,frontend:Ke.filter(s=>!i.has(s.name)).map(s=>({id:s.name,name:s.name}))}},[pt.data?.builtinTools,Ke]),Sn=o.useMemo(()=>new Set((Ze.data?.skills??[]).filter(e=>e.status==="enabled"||e.status==="loaded").map(e=>e.id)),[Ze.data]),mo=o.useCallback(async e=>{if(le)throw new Error("A deployment’s chat does not switch its runtime’s model.");rn(e),!(R||T===void 0)&&await fetch(`${T}/api/v1/configure/inference/provider`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({model:e})}).catch(()=>{})},[T,R,le]),yn=d?.promptPlacement==="bottom-chat",go=d?.promptPlacement==="floating",Oe=d?.promptPlacement==="top",et=d?.hidePrompt===!0||h.hidePrompt===!0,ho={onSend:()=>{he($t)},input:$t,setInput:Je,focusTrigger:be||pn?(be?.nonce??0)+pn:void 0,placement:go||J==="floating"||J==="floating-top"||J==="floating-bottom"?"floating":"docked",floatingAnchor:J==="floating-top"?"top":"bottom",isLoading:F,onStop:()=>n.viewControls.stop?.(),placeholder:sn??h.sendInstead?.says??we,typingSuggestions:Tt.map(e=>e.text),suggestions:dt,disableInputPrompt:qe,connectionConfirmed:!qe,interim:qn,padding:Oe||J==="floating-top"||J==="floating-bottom"||J==="docked-top"?2:3,promptVariant:"lexical",autoFocus:d?.autoFocusPrompt??!0,mentionableAgents:Gn,promptCommands:Dn,headerContent:no.length>0?t.jsx(St,{slot:Ce.inpromptMenu,props:{workspace:n}}):void 0,footerExtras:un.length>0||Qe&&Qe.input!=="off"?t.jsxs(t.Fragment,{children:[un.length>0?t.jsx(St,{slot:Ce.promptAction,props:{workspace:n}}):null,Qe&&Qe.input!=="off"?t.jsx(Ls,{voice:Qe,input:$t,setInput:Je,disabled:qe,speaking:kt,onStopSpeaking:()=>r.current?.stopSpeaking?.(),onInterimChange:Jn,answers:!!(d?.voice?.output&&d.voice.output!=="off"&&d.voice.speechUrl),onSpoken:e=>{$.current=e},send:(e,i)=>{$.current=i,he(e)}}):null]}):void 0,showAgentsMenu:!_,showInlineAgentsMenu:!1,agents:oo,selectedAgentId:re,onSelectAgent:e=>C?.select(e),showTokenUsage:h.showTokenUsage??d?.showTokenUsage??!0,showContextRing:!0,agentUsage:to??void 0,showModelSelector:!_&&!le,models:po,decisions:uo,selectedModel:ft,onModelSelect:e=>{mo(e)},showToolsMenu:!_,availableTools:vn.runtime,availableFrontendTools:vn.frontend,mcpServers:pt.data?.mcpServers??[],mcpStatusData:h.mcpStatusData??void 0,showSkillsMenu:!_,skills:Ze.data?.skills??[],skillsLoading:Ze.isLoading,enabledSkills:Sn,onToggleSkill:e=>Sn.has(e)?mt.disableSkill(e):mt.enableSkill(e),onToggleAllSkills:(e,i)=>e.forEach(s=>i?mt.enableSkill(s):mt.disableSkill(s)),codemodeEnabled:h.codemodeEnabled??!1,onToggleCodemode:h.onToggleCodemode,isA2AProtocol:!1,hasConfigData:!!pt.data,hasSkillsData:!!Ze.data},Cn=te[0]?.value.Component,_t=Le[0]?.value.Component,wn=!d?.hideHeader&&!!_t,gt=Cn?t.jsx(Cn,{workspace:n,composer:ho}):null,kn=E.length>0&&d?.showSurfaceSelector!==!1?t.jsx(Ea,{surfaces:E.map(e=>e.value),active:j?.surfaceId??P?.surfaceId??Z,onChange:Me,workspace:n}):null,jn=t.jsxs(t.Fragment,{children:[E.map(e=>{const i=e.value,s=j?.surfaceId===i.surfaceId;return s||X.current.has(i.surfaceId)||tt(i,n)?(X.current.add(i.surfaceId),t.jsx(p,{sx:s?{flex:"1 1 0",minWidth:0,minHeight:0}:{position:"absolute",inset:0,visibility:"hidden",pointerEvents:"none",zIndex:-1},children:t.jsx(_s,{load:i.load,props:{surfaceId:i.surfaceId,workspace:n},fallback:t.jsxs(Wt,{children:["Loading ",i.title,"…"]}),errorFallback:u=>t.jsxs(Wt,{children:[i.title," failed to load: ",u.message]})})},i.surfaceId)):null}),!j&&P?t.jsx(p,{flex:"1 1 0",minWidth:0,minHeight:0,children:t.jsxs(Wt,{children:["Starting ",P.title,"…"]})}):null]}),In=t.jsx(t.Fragment,{children:t.jsxs(p,{flex:Oe&&j?"0 0 34%":"1 1 0",maxWidth:Oe&&j?460:void 0,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",borderLeft:j?"1px solid":void 0,borderColor:"border.default",position:"relative",children:[h.errorBanner?t.jsx(p,{flexShrink:0,px:3,py:2,fontSize:1,borderBottom:"1px solid",bg:h.errorBanner.variant==="warning"?"attention.subtle":"danger.subtle",color:h.errorBanner.variant==="warning"?"attention.fg":"danger.fg",borderColor:h.errorBanner.variant==="warning"?"attention.muted":"danger.muted",children:h.errorBanner.message}):null,$e?.said&&$e.given===U?.id?t.jsx(H,{as:"p",role:"status",sx:{m:0,px:3,py:2,fontSize:1,color:"fg.muted"},children:$e.said}):null,t.jsx(p,{flex:"1 1 auto",minHeight:0,display:"flex",children:co?t.jsx(H,{as:"p",role:"status",sx:{m:0,p:3,fontSize:1,color:"fg.muted"},children:Un.opening}):t.jsx(zs,{themeVariant:d?.themeVariant,themeOverrides:d?.themeOverrides,colorMode:d?.colorMode,thread:bn,voice:lo,disabled:qe,disableReason:sn,protocol:Ft,frontendTools:R?void 0:Wn,initialModel:ft||void 0,title:_?.name??S?.name??A?.name??g,description:_?.welcome??A?.description,brandIcon:_?.face?t.jsx(ya,{face:_.face,size:20,state:fe}):t.jsx(Rt,{size:20}),headerContent:_&&!Ut?t.jsx(Ca,{state:fe}):void 0,emptyState:{icon:_?.face?t.jsx("span",{"aria-hidden":!0,style:{fontSize:_n,lineHeight:1},children:t.jsx(Vn,{face:_.face,size:_n})}):t.jsx(Rt,{size:48}),title:_?.name??S?.name??A?.name??g,...C&&S?{sections:[{group:C.team.name,icon:t.jsx(Hn,{size:48}),title:C.team.name,subtitle:C.team.description},{group:S.name,icon:t.jsx(Rt,{size:32}),title:S.name,subtitle:A?.description}]}:null},suggestions:Oe||de||d?.suggestionLabels===!1?[]:dt,showHeader:wn,headerButtons:{showNewChat:d?.headerButtons?.newChat??!1,showClear:d?.headerButtons?.clear??!1},renderHeader:_t?e=>t.jsx(_t,{workspace:n,header:n.chatViewModes?{...e,chatViewMode:n.chatViewModes.value,onChatViewModeChange:n.chatViewModes.onChange,offeredViewModes:n.chatViewModes.offered}:e}):void 0,showInformation:!0,headerActions:t.jsxs(p,{display:"inline-flex",alignItems:"center",gap:2,children:[n.chatHeaderActions,fn.length>0?t.jsx(St,{slot:Ce.chatHeader,props:{workspace:n}}):null,t.jsx(Ns,{icon:G?Bs:Vs,"aria-label":G?"Exit full screen":"Enter full screen",variant:"invisible",size:"small",onClick:()=>{c(!1),Ve()},sx:We?{"@keyframes dla-fullscreen-hint":{"0%, 100%":{opacity:1},"50%":{opacity:.4}},"&&":{bg:`color-mix(in srgb, ${l.primary} 16%, transparent)`,boxShadow:`inset 0 0 0 1.5px ${l.primary}`,animation:`dla-fullscreen-hint ${Ia}ms ease-in-out infinite`},"@media (prefers-reduced-motion: reduce)":{"&&":{animation:"none"}}}:void 0})]}),showInput:!1,onSendReady:it,notebookToolSurfacesId:j?void 0:n.surfaceId,showTurnFooter:h.showTokenUsage??d?.showTokenUsage??!0,onContextSnapshot:L,onLoadingChange:It,onSpeakingChange:at,onItemsChange:me,onDisplayItemsChange:Ne,enableStreaming:!0},bn?.id)}),!wn&&fn.length>0?t.jsx(p,{hidden:!0,children:t.jsx(St,{slot:Ce.chatHeader,props:{workspace:n}})}):null,yn&&!et?gt:null]})}),En=d?.suggestionLabels!==!1&&dt.length>0?t.jsx(p,{"aria-label":a.suggestedPrompts,display:"flex",flexWrap:"wrap",gap:2,px:2,pb:"6px",children:dt.map(e=>t.jsx(p,{as:"button",type:"button",title:e.message,disabled:F||qe,onClick:()=>{he(e.message)},appearance:"none",font:"inherit",fontSize:0,fontWeight:"semibold",lineHeight:1.25,px:"10px",py:"5px",width:$n,flex:`0 0 ${$n}px`,borderRadius:"999px",border:"1px solid",bg:"canvas.subtle",whiteSpace:"nowrap",sx:{borderColor:"border.default",color:"fg.default",cursor:"pointer","&:hover:not(:disabled)":{borderColor:"accent.fg",color:"accent.fg"},"&:disabled":{opacity:.5,cursor:"default"}},children:t.jsx(Hs,{title:e.title,maxWidth:"100%",sx:{minWidth:0},children:e.title})},e.title))}):null,Tn=x?t.jsx(p,{flex:"0 0 auto",px:3,py:2,borderTop:"1px solid",borderColor:"border.default",bg:"canvas.subtle",fontSize:1,maxHeight:"40%",overflowY:"auto",children:x}):null;return t.jsxs(p,{ref:lt,sx:{height:"100%",minHeight:0,display:"flex",flexDirection:"column",position:"relative",...G?{bg:"canvas.default"}:null,...G&&!Be.current?{position:"fixed",top:He,right:0,bottom:0,left:0,height:"auto",zIndex:1e3}:null},children:[de?t.jsx(de.Component,{workspace:n,editors:jn,hasEditor:!!j,transcript:In,prompt:et?null:gt,chips:et?null:En,picker:kn,transient:Tn}):t.jsxs(t.Fragment,{children:[Oe&&!et?t.jsxs(p,{flex:"0 0 auto",borderBottom:"1px solid",borderColor:"border.default",children:[gt,En]}):null,kn,t.jsxs(p,{flex:"1 1 auto",minHeight:0,display:"flex",position:"relative",children:[jn,In]}),Tn,yn||et||Oe?null:gt]}),Pt?t.jsx(p,{position:"absolute",inset:0,zIndex:5,bg:"canvas.default",display:"flex",flexDirection:"column",minHeight:0,children:t.jsx(ia,{agentName:S?.name??A?.name,sandboxStillRuns:R,temporary:on,onSignedIn:()=>Ws.getState().clear()})}):null]})}function Ea({surfaces:n,active:a,onChange:l,workspace:r}){const f=[...n].sort((x,y)=>(x.order??100)-(y.order??100));return t.jsxs(p,{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2,px:3,py:2,borderBottom:"1px solid",borderColor:"border.default",children:[t.jsx(H,{sx:{fontSize:0,color:"fg.muted"},children:"Beside the chat"}),t.jsxs(Vt,{"aria-label":"Editor beside the chat",size:"small",children:[t.jsx(Vt.Button,{selected:a===Z,onClick:()=>l(Z),children:"Chat"}),f.map(x=>{const y=tt(x,r),I=y?void 0:x.unavailableReason?.(r)??"Not available right now";return t.jsx(Vt.Button,{selected:a===x.surfaceId,"aria-disabled":!y,title:I??x.title,leadingIcon:x.icon,onClick:()=>{y&&l(x.surfaceId)},children:x.title},x.surfaceId)})]})]})}function Wt({children:n}){return t.jsx(p,{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"fg.muted",fontSize:1,px:3,textAlign:"center",children:n})}export{Ma as default};
32
+ ${ss(K.map(Se=>Se.file))}`,{...m,loop:Object.fromEntries(Object.entries(u).filter(([Se])=>Se!=="files"))})});return}B.current?.begin(e,r.current?.thread());const z=r.current?.send;if(!z){Ee.current.push([e,m]);return}z(e,m)},[]);o.useEffect(()=>{f(ke?{busy:L,stop:r.current?.stop,newChat:r.current?.newChat,send:se}:null)},[L,ke,f,se]),o.useEffect(()=>()=>f(null),[f]),o.useEffect(()=>n.prompts.subscribe(se),[n.prompts,se]),o.useEffect(()=>{if(!ke||Ee.current.length===0)return;const e=Ee.current.splice(0,Ee.current.length);for(const[i,s]of e)r.current?.send(i,s)},[ke]);const ae=o.useRef(!1),he=o.useCallback(async e=>{y(null);const i=await as(Ie.current,e);if(i){i.sent?Je(""):y(i.refused);return}ae.current||(ae.current=!0,nt?.firstPromptHook?.());const s=await n.submit(e);if(!s.handled){y(s.reason??null);return}Je(""),s.result?.content&&y(s.result.content)},[n,nt?.firstPromptHook]),j=o.useMemo(()=>E.find(e=>e.value.surfaceId===F)?.value,[E,F]),Me=o.useCallback(e=>{v.current=!0,ee(e)},[]);o.useEffect(()=>is(Me),[Me]),o.useEffect(()=>{rs(E.map(e=>e.value.surfaceId))},[E]),o.useEffect(()=>{ls(F&&F!==Z?F:qs)},[F]);const D=o.useMemo(()=>q===Z||q==="none"?void 0:E.find(e=>e.value.surfaceId===q),[E,q]);o.useEffect(()=>{v.current||!D||tt(D.value,n)&&ee(q)},[D,n,q]);const[V,ie]=o.useState(null),lt=o.useRef(null),ct=d?.fullScreenTopOffset??0,{fullScreen:G,usingApi:Be,toggle:Ve,topOffsetPx:He}=cs(lt,{forceOverlay:!!ct,topOffset:ct}),[We,c]=o.useState(!1),k=o.useRef(!1);o.useEffect(()=>{!L||k.current||G||(k.current=!0,c(!0))},[L,G]),o.useEffect(()=>{G&&c(!1)},[G]),o.useEffect(()=>{j&&!tt(j,n)&&(ie(j.surfaceId),ee(Z))},[j,n]);const P=o.useMemo(()=>{if(V)return E.find(e=>e.value.surfaceId===V)?.value;if(!v.current&&F===Z)return D?.value},[E,V,F,D]);o.useEffect(()=>{if(!V||F!==Z)return;const e=E.find(i=>i.value.surfaceId===V);e&&tt(e.value,n)&&(ie(null),ee(V))},[E,F,V,n]);const g=n.agentId?.trim()||"default",R=ds(n.sandbox.target??"local");Te.current=R;const C=us(),re=Nt(C?.selected??ja),S=C?.members.find(e=>e.id===re),De=N(fs)[0]?.value,Pe=De?.specId,A=An(S?.specId??g)??(Pe?An(Pe):void 0),Ge=S?void 0:De,qt=R&&!S?Ds(Pe,A):void 0;Q.current=S?.name??A?.name??g;const Jt=N(ps),Qt=h.hiddenOpeners,Xt=h.hideOpeners,Et=h.openers,Tt=o.useMemo(()=>{if(Xt)return[];const e=new Set(Qt??[]),i=b=>e.size===0?b:b.filter(Se=>!e.has(Se.text));if(Et)return i(Et);const s=Jt.flatMap(b=>b.value.suggestions);if(s.length>0)return i(s);const m=i(A?.suggestions??[]),u=i(C?.team.suggestions??[]);if(u.length===0)return m;const z=new Set(u.map(b=>b.text)),M=C?.team.name??"Team",K=S?.name??A?.name??g;return[...u.map(b=>({...b,group:M})),...m.filter(b=>!z.has(b.text)).map(b=>({...b,group:K}))]},[Jt,C,A,S,g,Qt,Xt,Et]),dt=o.useMemo(()=>Tt.map(e=>({title:e.summary??e.text,message:e.message??e.text,group:e.group})),[Tt]),Rt=Le(A?.icon),_=d?.presence,Hn=Le(C?.team.icon),Zt=N(ms),ut=o.useMemo(()=>{const e=[],i=new Map,s=new Set,m=new Set(E.map(u=>u.value.surfaceId));for(const u of pa(Zt,j?.surfaceId)){if(ma(u.value.id,m,j?.surfaceId))continue;let z;try{z=u.value.tools(n)}catch(M){console.warn(`[loop] frontend tools from '${u.plugin}' failed:`,M);continue}for(const M of z){const K=i.get(M.name);if(K){console.warn(`[loop] frontend tool '${M.name}' from '${u.plugin}' is shadowed by the one from '${K}'.`);continue}i.set(M.name,u.plugin),e.push(M),u.value.chatView&&s.add(M.name)}}for(const u of h.frontendTools??[])i.has(u.name)||(i.set(u.name,"chat-extras"),e.push(u),s.add(u.name));return j?e:fa(e,s)},[Zt,n.surfaceId,n.agentId,h.frontendTools,j?.surfaceId,E]),At=ba(),Ke=o.useMemo(()=>{if(At.length===0)return ut;const e=new Set(ut.map(i=>i.name));return[...ut,...At.filter(i=>!e.has(i.name))]},[ut,At]),en=Nn(),Mt=h.agentToolBundles,Wn=o.useMemo(()=>{const e=h.frontendTools??[];if(!Mt?.length)return h.frontendTools;const i=Bn(en.filter(m=>Mt.includes(m.id)),I),s=new Set(e.map(m=>m.name));return[...e,...i.filter(m=>!s.has(m.name))]},[h.frontendTools,Mt,en,I]);rt.current=R&&Ke.some(e=>e.name===gs)?I.getOutput(vt)?.sandbox:void 0;const T=hs(n.sandbox,n.serverUrl),tn=N(bs),Dn=o.useMemo(()=>tn.filter(e=>e.value.composer).map(e=>({name:e.value.name,description:e.value.description})),[tn]),Gn=o.useMemo(()=>{if(!C||!S)return On(A).map(s=>({name:s.name,description:s.description,icon:Le(s.icon)}));const e=C.members.map(s=>({name:s.name,description:s.description,emoji:s.emoji,icon:Le(s.icon),disabled:s.id===S.id,disabledReason:s.id===S.id?`You are already talking to ${s.name}`:void 0})),i=Mn(C.team,S.id).filter(s=>!C.members.some(m=>m.name===s.name)).map(s=>({name:s.name,description:s.description,icon:Le(s.icon)}));return[...e,...i]},[C,S,A]),{inference:nn,anonymous:Kn}=la(R),Yn=Gt(e=>e.user),Pt=R&&Kn.status==="expired",on=!Yn,Ye=xs();Re.current=Ye.disabled?Ye.disableReason||"This conversation is closed here.":void 0;const Ut=T===void 0?vs(n.sandbox,a):void 0,qe=st||Pt||!!qt||!!Ut||Ye.disabled,sn=Pt?on?a.demoKeyExpired:a.keyExpired:qt??Ut??wt??(Ye.disabled?Ye.disableReason:void 0),[$t,Je]=o.useState(""),[an]=Ss(),Qe=o.useMemo(()=>d?.voice?ys(d.voice,an):void 0,[d?.voice,an]),[qn,Jn]=o.useState(!1),[Qn,rn]=o.useState(),ft=Qn??Ge?.model??A?.model??n.model??"",Ue=Cs(),ln=o.useRef(Ue),cn=o.useRef(re),dn=o.useRef(Ue);dn.current=Ue,o.useEffect(()=>{cn.current!==re&&(cn.current=re,ln.current=dn.current,rn(void 0))},[re]);const Xn=Ue&&Ue!==ln.current?Ue:null,[Zn,eo]=o.useState(),to=Xn??Zn??null,no=Bt(Ce.inpromptMenu),un=Bt(Ce.promptAction),fn=Bt(Ce.chatHeader),oo=o.useMemo(()=>C?.members.map(e=>({id:e.id,name:e.name,description:e.description,icon:Le(e.icon)}))??[],[C]),be=Ln(e=>e.pending),[pn,so]=o.useState(0);o.useEffect(()=>ws(()=>so(e=>e+1)),[]),o.useEffect(()=>{be&&(Je(be.text),Ln.getState().consume(),be.submit&&he(be.text))},[be]);const mn=I.getConfig(vt)?.datalayerCreatePayload,xe=!!(Ge?.createPayload?.app_spec||mn?.app_spec),Xe=xa(mn),ao=Gt(e=>e.token),Ft=I.getConfig(vt)?.datalayerVisitors,io=ks(Ft),ro=I.getConfig(vt)?.embedToken,ve=Ft?io.token:ro||ao,lo=o.useMemo(()=>js(d?.voice,ve||void 0,Xe),[d?.voice,ve,Xe]),le=!!(Xe||Ft);if(le&&!xe)throw new Error("A deployment’s page runs its application: its host gave no app_spec.");const[gn]=o.useState(Pn),U=o.useMemo(()=>va(d?.thread,Xe,gn),[d?.thread,Xe,gn]),[$e,hn]=o.useState(null),co=!!(U?.fromRuntime&&$e?.given!==U.id);o.useEffect(()=>{if(!U?.fromRuntime||!xe||!T)return;let e=!0;return(async()=>{let i="";for(let s=0;s<4&&e;s+=1)try{const m=await Is({agentBaseUrl:T,agentId:g,uid:U.id,token:ve});e&&hn({given:U.id,thread:{...U,fromRuntime:!1,messages:m}});return}catch(m){i=m instanceof Error?m.message:String(m),await new Promise(u=>setTimeout(u,1500))}e&&hn({given:U.id,thread:{id:Pn(),messages:[],onStarted:U.onStarted},said:Un.notOpened(i)})})(),()=>{e=!1}},[U?.id,U?.fromRuntime,xe,T,g,ve]);const bn=U?.fromRuntime?$e?.given===U.id?$e.thread:void 0:U,Lt=o.useMemo(()=>R?aa({agentId:S?.specId??g,instructions:Es(A,Ge?.instructions),model:ft||void 0,inference:nn,frontendTools:Ke,subagents:C&&S?Mn(C.team,S.id):On(A),sharing:C?.sharing,onSubagentEvent:e=>Ks.getState().appendSubagentEvent(e),modeEffect:Ge?.modeEffect}):T!==void 0?{type:"ag-ui",endpoint:xe?`${T}/api/v1/apps/agents/${encodeURIComponent(g)}/ag-ui/`:`${T}/api/v1/ag-ui/${g}/`,...xe&&ve?{authToken:ve}:{},...xe?{uiSocket:`${T.replace(/^http/,"ws")}/api/v1/apps/ui`,uiFiles:`${T}/api/v1/apps/agents/${encodeURIComponent(g)}/files`,appSessions:`${T}/api/v1/apps/sessions`,...le?{ownRoutesOnly:!0}:{}}:{},agentId:g,configEndpoint:`${T}/api/v1/configure`,enableConfigQuery:!0}:void 0,[g,R,nn,S,Ke,C,A,Ge,ft,T,xe,ve,le]),pt=Ts(!R,Lt?.type==="ag-ui"?Lt.configEndpoint:void 0,void 0,g),Ze=Rs(),mt=As(g),[xn,Ot]=o.useState(void 0),[uo,fo]=o.useState(void 0);o.useEffect(()=>{if(R||T===void 0)return;const e=Ms(T,g,le);if(!e){Ot([]);return}let i=!1;return fetch(e).then(s=>s.ok?s.json():null).then(s=>{i||(Ot(s?Ps(s):[]),fo(s?Us(s):void 0))}).catch(()=>{i||Ot([])}),()=>{i=!0}},[T,g,R,le]);const po=o.useMemo(()=>$s(xn,()=>Object.values(Fs).filter(e=>e.available&&Ls(e)).map(e=>({id:e.id,name:e.name,provider:e.provider}))),[xn]),vn=o.useMemo(()=>{const e=pt.data?.builtinTools??[],i=new Set(e.map(s=>s.name));return{runtime:e,frontend:Ke.filter(s=>!i.has(s.name)).map(s=>({id:s.name,name:s.name}))}},[pt.data?.builtinTools,Ke]),Sn=o.useMemo(()=>new Set((Ze.data?.skills??[]).filter(e=>e.status==="enabled"||e.status==="loaded").map(e=>e.id)),[Ze.data]),mo=o.useCallback(async e=>{if(le)throw new Error("A deployment’s chat does not switch its runtime’s model.");rn(e),!(R||T===void 0)&&await fetch(`${T}/api/v1/configure/inference/provider`,{method:"PUT",headers:{"content-type":"application/json"},body:JSON.stringify({model:e})}).catch(()=>{})},[T,R,le]),yn=d?.promptPlacement==="bottom-chat",go=d?.promptPlacement==="floating",Fe=d?.promptPlacement==="top",et=d?.hidePrompt===!0||h.hidePrompt===!0,ho={onSend:()=>{he($t)},input:$t,setInput:Je,focusTrigger:be||pn?(be?.nonce??0)+pn:void 0,placement:go||J==="floating"||J==="floating-top"||J==="floating-bottom"?"floating":"docked",floatingAnchor:J==="floating-top"?"top":"bottom",isLoading:L,onStop:()=>n.viewControls.stop?.(),placeholder:sn??h.sendInstead?.says??we,typingSuggestions:Tt.map(e=>e.text),suggestions:dt,disableInputPrompt:qe,connectionConfirmed:!qe,interim:qn,padding:Fe||J==="floating-top"||J==="floating-bottom"||J==="docked-top"?2:3,promptVariant:"lexical",autoFocus:d?.autoFocusPrompt??!0,mentionableAgents:Gn,promptCommands:Dn,headerContent:no.length>0?t.jsx(St,{slot:Ce.inpromptMenu,props:{workspace:n}}):void 0,footerExtras:un.length>0||Qe&&Qe.input!=="off"?t.jsxs(t.Fragment,{children:[un.length>0?t.jsx(St,{slot:Ce.promptAction,props:{workspace:n}}):null,Qe&&Qe.input!=="off"?t.jsx(Os,{voice:Qe,input:$t,setInput:Je,disabled:qe,speaking:kt,onStopSpeaking:()=>r.current?.stopSpeaking?.(),onInterimChange:Jn,answers:!!(d?.voice?.output&&d.voice.output!=="off"&&d.voice.speechUrl),onSpoken:e=>{$.current=e},send:(e,i)=>{$.current=i,he(e)}}):null]}):void 0,showAgentsMenu:!_,showInlineAgentsMenu:!1,agents:oo,selectedAgentId:re,onSelectAgent:e=>C?.select(e),showTokenUsage:h.showTokenUsage??d?.showTokenUsage??!0,showContextRing:!0,agentUsage:to??void 0,showModelSelector:!_&&!le,models:po,decisions:uo,selectedModel:ft,onModelSelect:e=>{mo(e)},showToolsMenu:!_,availableTools:vn.runtime,availableFrontendTools:vn.frontend,mcpServers:pt.data?.mcpServers??[],mcpStatusData:h.mcpStatusData??void 0,showSkillsMenu:!_,skills:Ze.data?.skills??[],skillsLoading:Ze.isLoading,enabledSkills:Sn,onToggleSkill:e=>Sn.has(e)?mt.disableSkill(e):mt.enableSkill(e),onToggleAllSkills:(e,i)=>e.forEach(s=>i?mt.enableSkill(s):mt.disableSkill(s)),codemodeEnabled:h.codemodeEnabled??!1,onToggleCodemode:h.onToggleCodemode,isA2AProtocol:!1,hasConfigData:!!pt.data,hasSkillsData:!!Ze.data},Cn=te[0]?.value.Component,_t=Oe[0]?.value.Component,wn=!d?.hideHeader&&!!_t,gt=Cn?t.jsx(Cn,{workspace:n,composer:ho}):null,kn=E.length>0&&d?.showSurfaceSelector!==!1?t.jsx(Ta,{surfaces:E.map(e=>e.value),active:j?.surfaceId??P?.surfaceId??Z,onChange:Me,workspace:n}):null,jn=t.jsxs(t.Fragment,{children:[E.map(e=>{const i=e.value,s=j?.surfaceId===i.surfaceId;return s||X.current.has(i.surfaceId)||tt(i,n)?(X.current.add(i.surfaceId),t.jsx(p,{sx:s?{flex:"1 1 0",minWidth:0,minHeight:0}:{position:"absolute",inset:0,visibility:"hidden",pointerEvents:"none",zIndex:-1},children:t.jsx(_s,{load:i.load,props:{surfaceId:i.surfaceId,workspace:n},fallback:t.jsxs(Wt,{children:["Loading ",i.title,"…"]}),errorFallback:u=>t.jsxs(Wt,{children:[i.title," failed to load: ",u.message]})})},i.surfaceId)):null}),!j&&P?t.jsx(p,{flex:"1 1 0",minWidth:0,minHeight:0,children:t.jsxs(Wt,{children:["Starting ",P.title,"…"]})}):null]}),In=t.jsx(t.Fragment,{children:t.jsxs(p,{flex:Fe&&j?"0 0 34%":"1 1 0",maxWidth:Fe&&j?460:void 0,minWidth:0,minHeight:0,display:"flex",flexDirection:"column",borderLeft:j?"1px solid":void 0,borderColor:"border.default",position:"relative",children:[h.errorBanner?t.jsx(p,{flexShrink:0,px:3,py:2,fontSize:1,borderBottom:"1px solid",bg:h.errorBanner.variant==="warning"?"attention.subtle":"danger.subtle",color:h.errorBanner.variant==="warning"?"attention.fg":"danger.fg",borderColor:h.errorBanner.variant==="warning"?"attention.muted":"danger.muted",children:h.errorBanner.message}):null,$e?.said&&$e.given===U?.id?t.jsx(H,{as:"p",role:"status",sx:{m:0,px:3,py:2,fontSize:1,color:"fg.muted"},children:$e.said}):null,t.jsx(p,{flex:"1 1 auto",minHeight:0,display:"flex",children:co?t.jsx(H,{as:"p",role:"status",sx:{m:0,p:3,fontSize:1,color:"fg.muted"},children:Un.opening}):t.jsx(zs,{themeVariant:d?.themeVariant,themeOverrides:d?.themeOverrides,colorMode:d?.colorMode,thread:bn,voice:lo,disabled:qe,disableReason:sn,protocol:Lt,frontendTools:R?void 0:Wn,initialModel:ft||void 0,title:_?.name??S?.name??A?.name??g,description:_?.welcome??A?.description,brandIcon:_?.face?t.jsx(Ca,{face:_.face,size:20,state:fe}):t.jsx(Rt,{size:20}),headerContent:_&&!Ut?t.jsx(wa,{state:fe}):void 0,emptyState:{icon:_?.face?t.jsx("span",{"aria-hidden":!0,style:{fontSize:_n,lineHeight:1},children:t.jsx(Vn,{face:_.face,size:_n})}):t.jsx(Rt,{size:48}),title:_?.name??S?.name??A?.name??g,...C&&S?{sections:[{group:C.team.name,icon:t.jsx(Hn,{size:48}),title:C.team.name,subtitle:C.team.description},{group:S.name,icon:t.jsx(Rt,{size:32}),title:S.name,subtitle:A?.description}]}:null},suggestions:Fe||de||d?.suggestionLabels===!1?[]:dt,showHeader:wn,headerButtons:{showNewChat:d?.headerButtons?.newChat??!1,showClear:d?.headerButtons?.clear??!1},renderHeader:_t?e=>t.jsx(_t,{workspace:n,header:n.chatViewModes?{...e,chatViewMode:n.chatViewModes.value,onChatViewModeChange:n.chatViewModes.onChange,offeredViewModes:n.chatViewModes.offered}:e}):void 0,showInformation:!0,headerActions:t.jsxs(p,{display:"inline-flex",alignItems:"center",gap:2,children:[n.chatHeaderActions,fn.length>0?t.jsx(St,{slot:Ce.chatHeader,props:{workspace:n}}):null,t.jsx(Ns,{icon:G?Bs:Vs,"aria-label":G?"Exit full screen":"Enter full screen",variant:"invisible",size:"small",onClick:()=>{c(!1),Ve()},sx:We?{"@keyframes dla-fullscreen-hint":{"0%, 100%":{opacity:1},"50%":{opacity:.4}},"&&":{bg:`color-mix(in srgb, ${l.primary} 16%, transparent)`,boxShadow:`inset 0 0 0 1.5px ${l.primary}`,animation:`dla-fullscreen-hint ${Ea}ms ease-in-out infinite`},"@media (prefers-reduced-motion: reduce)":{"&&":{animation:"none"}}}:void 0})]}),showInput:!1,onSendReady:it,notebookToolSurfacesId:j?void 0:n.surfaceId,showTurnFooter:h.showTokenUsage??d?.showTokenUsage??!0,onContextSnapshot:O,onLoadingChange:It,onSpeakingChange:at,onItemsChange:me,onDisplayItemsChange:Ne,enableStreaming:!0},bn?.id)}),!wn&&fn.length>0?t.jsx(p,{hidden:!0,children:t.jsx(St,{slot:Ce.chatHeader,props:{workspace:n}})}):null,yn&&!et?gt:null]})}),En=d?.suggestionLabels!==!1&&dt.length>0?t.jsx(p,{"aria-label":a.suggestedPrompts,display:"flex",flexWrap:"wrap",gap:2,px:2,pb:"6px",children:dt.map(e=>t.jsx(p,{as:"button",type:"button",title:e.message,disabled:L||qe,onClick:()=>{he(e.message)},appearance:"none",font:"inherit",fontSize:0,fontWeight:"semibold",lineHeight:1.25,px:"10px",py:"5px",width:$n,flex:`0 0 ${$n}px`,borderRadius:"999px",border:"1px solid",bg:"canvas.subtle",whiteSpace:"nowrap",sx:{borderColor:"border.default",color:"fg.default",cursor:"pointer","&:hover:not(:disabled)":{borderColor:"accent.fg",color:"accent.fg"},"&:disabled":{opacity:.5,cursor:"default"}},children:t.jsx(Hs,{title:e.title,maxWidth:"100%",sx:{minWidth:0},children:e.title})},e.title))}):null,Tn=x?t.jsx(p,{flex:"0 0 auto",px:3,py:2,borderTop:"1px solid",borderColor:"border.default",bg:"canvas.subtle",fontSize:1,maxHeight:"40%",overflowY:"auto",children:x}):null;return t.jsxs(p,{ref:lt,sx:{height:"100%",minHeight:0,display:"flex",flexDirection:"column",position:"relative",...G?{bg:"canvas.default"}:null,...G&&!Be.current?{position:"fixed",top:He,right:0,bottom:0,left:0,height:"auto",zIndex:1e3}:null},children:[de?t.jsx(de.Component,{workspace:n,editors:jn,hasEditor:!!j,transcript:In,prompt:et?null:gt,chips:et?null:En,picker:kn,transient:Tn}):t.jsxs(t.Fragment,{children:[Fe&&!et?t.jsxs(p,{flex:"0 0 auto",borderBottom:"1px solid",borderColor:"border.default",children:[gt,En]}):null,kn,t.jsxs(p,{flex:"1 1 auto",minHeight:0,display:"flex",position:"relative",children:[jn,In]}),Tn,yn||et||Fe?null:gt]}),Pt?t.jsx(p,{position:"absolute",inset:0,zIndex:5,bg:"canvas.default",display:"flex",flexDirection:"column",minHeight:0,children:t.jsx(ia,{agentName:S?.name??A?.name,sandboxStillRuns:R,temporary:on,onSignedIn:()=>Ws.getState().clear()})}):null]})}function Ta({surfaces:n,active:a,onChange:l,workspace:r}){const f=[...n].sort((x,y)=>(x.order??100)-(y.order??100));return t.jsxs(p,{flex:"0 0 auto",display:"flex",alignItems:"center",gap:2,px:3,py:2,borderBottom:"1px solid",borderColor:"border.default",children:[t.jsx(H,{sx:{fontSize:0,color:"fg.muted"},children:"Beside the chat"}),t.jsxs(Vt,{"aria-label":"Editor beside the chat",size:"small",children:[t.jsx(Vt.Button,{selected:a===Z,onClick:()=>l(Z),children:"Chat"}),f.map(x=>{const y=tt(x,r),I=y?void 0:x.unavailableReason?.(r)??"Not available right now";return t.jsx(Vt.Button,{selected:a===x.surfaceId,"aria-disabled":!y,title:I??x.title,leadingIcon:x.icon,onClick:()=>{y&&l(x.surfaceId)},children:x.title},x.surfaceId)})]})]})}function Wt({children:n}){return t.jsx(p,{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"fg.muted",fontSize:1,px:3,textAlign:"center",children:n})}export{Pa as default};
@@ -1,4 +1,4 @@
1
- import{jm as je,jn as We,jo as Qe,jp as Ke,jq as Xe,jr as Ze,js as Je,jt as et,ju as xe,r as Q,j as S,ar as br,_ as fr,jv as Tr,K as vr,bW as Cr,I as yr,bX as Rr,D as Nr,eS as Or,bi as da,T as Ar}from"../datalayer-app-main.js";import{x as Ir,B as xr,N as Dr}from"./JupyterLexicalExtension-_7FM5Om8.js";import"./NotebookSkeleton-CI7ovjNW.js";import"./Avatar-9MpXENSs.js";import"./url-DuKx0yk0.js";import"./isSymbol-BLtK9CV6.js";import"./toNumber-B1wj8-wx.js";import"./VideoIcon-BjP_LDa4.js";import"./LinkIcon-DUI0jw25.js";import"./Toolbar-CGQDY041.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./ArrowUpIcon-BUCpIXDR.js";import"./SortDescIcon-CS4EzHeS.js";import"./PaintbrushIcon-CLU8RilX.js";import"./PrismCss-CcU1ChRk.js";import"./Output-BWClePP-.js";import"./index-CFP9psRB.js";import"./hoverbox-CStlKQWE.js";import"./index-DSN70XMH.js";import"./index-DyVR0igi.js";import"./color-CG7_7V2-.js";import"./isEqual-Cwjr2skl.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./index-BJhxZF_K.js";import"./RestartIcon-Ca6_HoK0.js";import"./LexicalToolRegistry-8wJyLumb.js";const _a={datalayer:{light:{primary:xe.greenAccent,secondary:xe.greenText,textColor:xe.gray,primaryGradient:[xe.greenAccent,xe.greenBrand],secondaryGradient:[xe.greenHover,xe.greenBrand]},dark:{primary:xe.greenBright,secondary:xe.greenAccent,textColor:xe.gray,primaryGradient:[xe.greenAccent,xe.greenBrand],secondaryGradient:[xe.greenHover,xe.greenText]}},spatial:{light:{primary:et.indigoBrand,secondary:et.indigoText,textColor:et.gray,primaryGradient:[et.indigoBright,et.indigoBrand],secondaryGradient:[et.indigoHover,et.indigoAccent]},dark:{primary:et.indigoBright,secondary:et.indigoAccent,textColor:et.gray,primaryGradient:[et.indigoBright,et.indigoBrand],secondaryGradient:[et.indigoHover,et.indigoAccent]}},lovely:{light:{primary:Je.roseBrand,secondary:Je.roseText,textColor:Je.gray,primaryGradient:[Je.roseBright,Je.roseBrand],secondaryGradient:[Je.roseHover,Je.roseAccent]},dark:{primary:Je.roseBright,secondary:Je.roseAccent,textColor:Je.gray,primaryGradient:[Je.roseBright,Je.roseBrand],secondaryGradient:[Je.roseHover,Je.roseAccent]}},matrix:{light:{primary:Ze.greenBrand,secondary:Ze.greenText,textColor:Ze.gray,primaryGradient:[Ze.greenGlow,Ze.greenBrand],secondaryGradient:[Ze.greenHover,Ze.greenAccent]},dark:{primary:Ze.greenGlow,secondary:Ze.greenPhosphor,textColor:Ze.gray,primaryGradient:[Ze.greenGlow,Ze.greenBrand],secondaryGradient:[Ze.greenHover,Ze.greenAccent]}},earth:{light:{primary:Xe.oceanBrand,secondary:Xe.oceanText,textColor:Xe.gray,primaryGradient:[Xe.oceanAccent,Xe.oceanBrand],secondaryGradient:[Xe.oceanHover,Xe.oceanText]},dark:{primary:Xe.oceanBright,secondary:Xe.oceanAccent,textColor:Xe.gray,primaryGradient:[Xe.oceanBright,Xe.oceanBrand],secondaryGradient:[Xe.oceanHover,Xe.oceanAccent]}},sand:{light:{primary:Ke.sandBrand,secondary:Ke.sandText,textColor:Ke.gray,primaryGradient:[Ke.sandAccent,Ke.sandBrand],secondaryGradient:[Ke.sandHover,Ke.sandText]},dark:{primary:Ke.sandBright,secondary:Ke.sandAccent,textColor:Ke.gray,primaryGradient:[Ke.sandBright,Ke.sandBrand],secondaryGradient:[Ke.sandHover,Ke.sandAccent]}},ivory:{light:{primary:Qe.ivoryBrand,secondary:Qe.ivoryText,textColor:Qe.gray,primaryGradient:[Qe.ivoryAccent,Qe.ivoryBrand],secondaryGradient:[Qe.ivoryHover,Qe.ivoryText]},dark:{primary:Qe.ivoryBright,secondary:Qe.ivoryAccent,textColor:Qe.gray,primaryGradient:[Qe.ivoryBright,Qe.ivoryBrand],secondaryGradient:[Qe.ivoryHover,Qe.ivoryAccent]}},sun:{light:{primary:We.sunBrand,secondary:We.sunText,textColor:We.gray,primaryGradient:[We.sunAccent,We.sunBrand],secondaryGradient:[We.sunHover,We.sunText]},dark:{primary:We.sunBright,secondary:We.sunAccent,textColor:We.gray,primaryGradient:[We.sunBright,We.sunBrand],secondaryGradient:[We.sunHover,We.sunAccent]}},loop:{light:{primary:je.loopAccent,secondary:je.ink,textColor:je.gray,primaryGradient:[je.loopAccent,je.loopAccent],secondaryGradient:[je.ink,je.ink]},dark:{primary:je.loopBrand,secondary:je.inkDark,textColor:je.grayDark,primaryGradient:[je.loopBrand,je.loopBrand],secondaryGradient:[je.inkDark,je.inkDark]}}};function Ya(i="datalayer",t="light"){const n=t==="auto"?"light":t;return _a[i]?.[n]??_a.datalayer.light}const ua=25,wr=[{y:0,secondaryWidth:30,primaryWidth:70},{y:37.5,secondaryWidth:50,primaryWidth:50},{y:75,secondaryWidth:70,primaryWidth:30}];Q.forwardRef(function({size:t=16,variant:n="datalayer",colorMode:e="light",primaryColor:a,secondaryColor:r,primaryGradient:s,secondaryGradient:o,gradient:l=!0,...c},d){const _=Ya(n,e),u=a??_.primary,m=r??_.secondary,p=Q.useId().replace(/:/g,""),[g,b]=s??_.primaryGradient,[C,y]=o??_.secondaryGradient;return S.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100",width:t,height:t,"aria-hidden":"true",ref:d,...c,children:[l&&S.jsxs("defs",{children:[S.jsxs("linearGradient",{id:`${p}-p`,x1:"0",y1:"0",x2:"1",y2:"0",children:[S.jsx("stop",{offset:"0",stopColor:g}),S.jsx("stop",{offset:"1",stopColor:b})]}),S.jsxs("linearGradient",{id:`${p}-s`,x1:"0",y1:"0",x2:"1",y2:"0",children:[S.jsx("stop",{offset:"0",stopColor:C}),S.jsx("stop",{offset:"1",stopColor:y})]})]}),wr.map(({y:N,secondaryWidth:O,primaryWidth:v})=>S.jsxs("g",{children:[S.jsx("rect",{x:0,y:N,width:O,height:ua,fill:l?`url(#${p}-p)`:u}),S.jsx("rect",{x:O,y:N,width:v,height:ua,fill:l?`url(#${p}-s)`:m})]},N))]})});const Ha=new Map,On=i=>Ha.get(i),an=i=>Ha.has(i),kr=/(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\)|==[^=]+==)/g,ie=i=>i.split(kr).map((t,n)=>{const e=`${n}-${t}`;if(t.startsWith("**")&&t.endsWith("**"))return S.jsx("strong",{children:ie(t.slice(2,-2))},e);if(t.startsWith("`")&&t.endsWith("`"))return S.jsx("code",{children:t.slice(1,-1)},e);if(t.startsWith("==")&&t.endsWith("=="))return S.jsx("mark",{className:"dla-alert",children:t.slice(2,-2)},e);const a=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(t);return a?S.jsx("a",{href:a[2],target:"_blank",rel:"noopener noreferrer",children:a[1]},e):t}),Mr=i=>i.trim().split(/\n\s*\n/).map((t,n)=>S.jsx("p",{children:ie(t.trim())},`${n}-${t.slice(0,24)}`)),Lr=()=>{const{theme:i,colorMode:t}=br();return{theme:i,colorMode:t}},Pr={useTheme:Lr},Fr=Q.createContext(Pr),Va=()=>Q.useContext(Fr),za=()=>{const{useTheme:i}=Va();return i()},An=({footer:i,theme:t,index:n,total:e})=>{const{colorMode:a,theme:r}=za(),{Logo:s}=Va(),o=a==="auto"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a,l=Ya(r,o),c=new Date().getFullYear(),d=i.since&&i.since<c?`${i.since}–${c}`:`${c}`;return S.jsxs("div",{className:"dla-slide-footer",children:[i.logo&&S.jsx("a",{className:"dla-slide-footer-logo",href:i.href,target:"_blank",rel:"noopener noreferrer","aria-label":`${i.holder} — ${i.href}`,children:s?S.jsx(s,{height:26,variant:r,colorMode:a,inverse:t.logo.inverse,colored:t.logo.colored,primaryColor:t.logo.primaryColor??l.primary,secondaryColor:t.logo.secondaryColor??l.secondary,textColor:t.logo.textColor??l.textColor}):S.jsx("span",{className:"dla-slide-footer-holder",children:i.holder})}),i.note&&S.jsx("div",{className:"dla-slide-footer-note",children:i.note}),S.jsxs("div",{className:"dla-slide-footer-legal",children:[S.jsx("a",{href:i.href,target:"_blank",rel:"noopener noreferrer",children:i.href.replace(/^https?:\/\//,"")}),S.jsxs("span",{children:["© ",d," ",i.holder]}),i.slideNumbers&&S.jsxs("span",{className:"dla-slide-footer-number",children:[n," / ",e]})]})]})},In=({name:i})=>{if(!i)return null;const t=On(i);return t?S.jsx("div",{className:"dla-slide-backdrop","aria-hidden":!0,children:S.jsx(t,{})}):null},Le=({theme:i,footer:t,index:n,total:e,eyebrow:a,title:r,subtitle:s,layout:o,variant:l,backdrop:c,children:d})=>{const _=["dla-slide"];return l&&_.push(`dla-slide--${l}`),(o==="centered"||o==="full-bleed")&&_.push(`dla-slide--${o}`),S.jsxs("div",{className:_.join(" "),children:[S.jsx(In,{name:c}),S.jsxs("div",{className:"dla-slide-head",children:[a&&S.jsx("div",{className:"dla-slide-eyebrow",children:a}),r&&S.jsx("h2",{className:"dla-slide-title",children:ie(r)}),s&&S.jsx("p",{className:"dla-slide-subtitle",children:ie(s)})]}),S.jsx("div",{className:"dla-slide-body",children:d}),t&&S.jsx(An,{footer:t,theme:i,index:n,total:e})]})};var jt=(i,t)=>{for(let n in t)i[n]=t[n];return i},j=(i,t)=>Array.from(i.querySelectorAll(t)),Mn=(i,t,n)=>{n?i.classList.add(t):i.classList.remove(t)},$t=i=>{if(typeof i=="string"){if(i==="null")return null;if(i==="true")return!0;if(i==="false")return!1;if(i.match(/^-?[\d\.]+$/))return parseFloat(i)}return i},Rt=(i,t)=>{i.style.transform=t},Cn=(i,t)=>{let n=i.matches||i.matchesSelector||i.msMatchesSelector;return!!(n&&n.call(i,t))},De=(i,t)=>{if(i&&typeof i.closest=="function")return i.closest(t);for(;i;){if(Cn(i,t))return i;i=i.parentElement}return null},qa=i=>{i=i||document.documentElement;let t=i.requestFullscreen||i.webkitRequestFullscreen||i.webkitRequestFullScreen||i.mozRequestFullScreen||i.msRequestFullscreen;t&&t.apply(i)},Ur=(i,t,n,e="")=>{let a=i.querySelectorAll("."+n);for(let s=0;s<a.length;s++){let o=a[s];if(o.parentNode===i)return o}let r=document.createElement(t);return r.className=n,r.innerHTML=e,i.appendChild(r),r},Hn=i=>{let t=document.createElement("style");return i&&i.length>0&&t.appendChild(document.createTextNode(i)),document.head.appendChild(t),t},pa=()=>{let i={};location.search.replace(/[A-Z0-9]+?=([\w\.%-]*)/gi,t=>{let n=t.split("=").shift(),e=t.split("=").pop();return n&&e!==void 0&&(i[n]=e),t});for(let t in i){let n=i[t];i[t]=$t(unescape(n))}return i.dependencies!==void 0&&delete i.dependencies,i},Br=(i,t=0)=>{if(i){var n;let e,a=i.style.height;return i.style.height="0px",i.parentElement&&(i.parentElement.style.height="auto"),e=t-(((n=i.parentElement)==null?void 0:n.offsetHeight)||0),i.style.height=a+"px",i.parentElement&&i.parentElement.style.removeProperty("height"),e}return t},Gr={mp4:"video/mp4",m4a:"video/mp4",ogv:"video/ogg",mpeg:"video/mpeg",webm:"video/webm"},Yr=(i="")=>{let t=i.split(".").pop();return t?Gr[t]:void 0},Hr=(i="")=>encodeURI(i).replace(/%5B/g,"[").replace(/%5D/g,"]").replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`),$a=navigator.userAgent,Lt=/(iphone|ipod|ipad|android)/gi.test($a)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,ja=/android/gi.test($a),Vr=(function(i){if(i){var t=function(R){return[].slice.call(R)},n=0,e=1,a=2,r=3,s=[],o=null,l="requestAnimationFrame"in i?function(){var R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{sync:!1};i.cancelAnimationFrame(o);var U=function(){return d(s.filter((function(z){return z.dirty&&z.active})))};if(R.sync)return U();o=i.requestAnimationFrame(U)}:function(){},c=function(R){return function(U){s.forEach((function(z){return z.dirty=R})),l(U)}},d=function(R){R.filter((function(z){return!z.styleComputed})).forEach((function(z){z.styleComputed=p(z)})),R.filter(g).forEach(b);var U=R.filter(m);U.forEach(u),U.forEach((function(z){b(z),_(z)})),U.forEach(C)},_=function(R){return R.dirty=n},u=function(R){R.availableWidth=R.element.parentNode.clientWidth,R.currentWidth=R.element.scrollWidth,R.previousFontSize=R.currentFontSize,R.currentFontSize=Math.min(Math.max(R.minSize,R.availableWidth/R.currentWidth*R.previousFontSize),R.maxSize),R.whiteSpace=R.multiLine&&R.currentFontSize===R.minSize?"normal":"nowrap"},m=function(R){return R.dirty!==a||R.dirty===a&&R.element.parentNode.clientWidth!==R.availableWidth},p=function(R){var U=i.getComputedStyle(R.element,null);return R.currentFontSize=parseFloat(U.getPropertyValue("font-size")),R.display=U.getPropertyValue("display"),R.whiteSpace=U.getPropertyValue("white-space"),!0},g=function(R){var U=!1;return!R.preStyleTestCompleted&&(/inline-/.test(R.display)||(U=!0,R.display="inline-block"),R.whiteSpace!=="nowrap"&&(U=!0,R.whiteSpace="nowrap"),R.preStyleTestCompleted=!0,U)},b=function(R){R.element.style.whiteSpace=R.whiteSpace,R.element.style.display=R.display,R.element.style.fontSize=R.currentFontSize+"px"},C=function(R){R.element.dispatchEvent(new CustomEvent("fit",{detail:{oldValue:R.previousFontSize,newValue:R.currentFontSize,scaleFactor:R.currentFontSize/R.previousFontSize}}))},y=function(R,U){return function(z){R.dirty=U,R.active&&l(z)}},N=function(R){return function(){s=s.filter((function(U){return U.element!==R.element})),R.observeMutations&&R.observer.disconnect(),R.element.style.whiteSpace=R.originalStyle.whiteSpace,R.element.style.display=R.originalStyle.display,R.element.style.fontSize=R.originalStyle.fontSize}},O=function(R){return function(){R.active||(R.active=!0,l())}},v=function(R){return function(){return R.active=!1}},A=function(R){R.observeMutations&&(R.observer=new MutationObserver(y(R,e)),R.observer.observe(R.element,R.observeMutations))},M={minSize:16,maxSize:512,multiLine:!0,observeMutations:"MutationObserver"in i&&{subtree:!0,childList:!0,characterData:!0}},F=null,Y=function(){i.clearTimeout(F),F=i.setTimeout(c(a),B.observeWindowDelay)},x=["resize","orientationchange"];return Object.defineProperty(B,"observeWindow",{set:function(R){var U=`${R?"add":"remove"}EventListener`;x.forEach((function(z){i[U](z,Y)}))}}),B.observeWindow=!0,B.observeWindowDelay=100,B.fitAll=c(r),B}function K(R,U){var z=Object.assign({},M,U),Z=R.map((function(te){var se=Object.assign({},z,{element:te,active:!0});return(function(ae){ae.originalStyle={whiteSpace:ae.element.style.whiteSpace,display:ae.element.style.display,fontSize:ae.element.style.fontSize},A(ae),ae.newbie=!0,ae.dirty=!0,s.push(ae)})(se),{element:te,fit:y(se,r),unfreeze:O(se),freeze:v(se),unsubscribe:N(se)}}));return l(),Z}function B(R){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return typeof R=="string"?K(t(document.querySelectorAll(R)),U):K([R],U)[0]}})(typeof window>"u"?null:window);function ln(i){"@babel/helpers - typeof";return ln=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ln(i)}function zr(i,t){if(ln(i)!="object"||!i)return i;var n=i[Symbol.toPrimitive];if(n!==void 0){var e=n.call(i,t);if(ln(e)!="object")return e;throw TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function qr(i){var t=zr(i,"string");return ln(t)=="symbol"?t:t+""}function Kn(i,t,n){return(t=qr(t))in i?Object.defineProperty(i,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):i[t]=n,i}var $r=class{constructor(t){Kn(this,"allowedToPlayAudio",null),this.Reveal=t,this.startEmbeddedMedia=this.startEmbeddedMedia.bind(this),this.startEmbeddedIframe=this.startEmbeddedIframe.bind(this),this.preventIframeAutoFocus=this.preventIframeAutoFocus.bind(this),this.ensureMobileMediaPlaying=this.ensureMobileMediaPlaying.bind(this),this.failedAudioPlaybackTargets=new Set,this.failedVideoPlaybackTargets=new Set,this.failedMutedVideoPlaybackTargets=new Set,this.renderMediaPlayButton()}renderMediaPlayButton(){this.mediaPlayButton=document.createElement("button"),this.mediaPlayButton.className="r-overlay-button r-media-play-button",this.mediaPlayButton.addEventListener("click",()=>{this.resetTemporarilyMutedMedia(),new Set([...this.failedAudioPlaybackTargets,...this.failedVideoPlaybackTargets,...this.failedMutedVideoPlaybackTargets]).forEach(t=>{this.startEmbeddedMedia({target:t})}),this.clearMediaPlaybackErrors()})}shouldPreload(t){if(this.Reveal.isScrollView())return!0;let n=this.Reveal.getConfig().preloadIframes;return typeof n!="boolean"&&(n=t.hasAttribute("data-preload")),n}load(t,n={}){let e=this.Reveal.getConfig().display;if(e.includes("!important")){let r=e.replace(/\s*!important\s*$/,"").trim();t.style.setProperty("display",r,"important")}else t.style.display=e;j(t,"img[data-src], video[data-src], audio[data-src], iframe[data-src]").forEach(r=>{let s=r.tagName==="IFRAME";(!s||this.shouldPreload(r))&&(r.setAttribute("src",r.getAttribute("data-src")),r.setAttribute("data-lazy-loaded",""),r.removeAttribute("data-src"),s&&r.addEventListener("load",this.preventIframeAutoFocus))}),j(t,"video, audio").forEach(r=>{let s=0;j(r,"source[data-src]").forEach(o=>{o.setAttribute("src",o.getAttribute("data-src")),o.removeAttribute("data-src"),o.setAttribute("data-lazy-loaded",""),s+=1}),Lt&&r.tagName==="VIDEO"&&r.setAttribute("playsinline",""),s>0&&r.load()});let a=t.slideBackgroundElement;if(a){a.style.display="block";let r=t.slideBackgroundContentElement,s=t.getAttribute("data-background-iframe");if(a.hasAttribute("data-loaded")===!1){a.setAttribute("data-loaded","true");let l=t.getAttribute("data-background-image"),c=t.getAttribute("data-background-video"),d=t.hasAttribute("data-background-video-loop"),_=t.hasAttribute("data-background-video-muted");if(l)/^data:/.test(l.trim())?r.style.backgroundImage=`url(${l.trim()})`:r.style.backgroundImage=l.split(",").map(u=>`url(${Hr(decodeURI(u.trim()))})`).join(",");else if(c){let u=document.createElement("video");d&&u.setAttribute("loop",""),(_||this.Reveal.isSpeakerNotes())&&(u.muted=!0),Lt&&u.setAttribute("playsinline",""),c.split(",").forEach(m=>{let p=document.createElement("source");p.setAttribute("src",m);let g=Yr(m);g&&p.setAttribute("type",g),u.appendChild(p)}),r.appendChild(u)}else if(s&&n.excludeIframes!==!0){let u=document.createElement("iframe");u.setAttribute("allowfullscreen",""),u.setAttribute("mozallowfullscreen",""),u.setAttribute("webkitallowfullscreen",""),u.setAttribute("allow","autoplay"),u.setAttribute("data-src",s),u.style.width="100%",u.style.height="100%",u.style.maxHeight="100%",u.style.maxWidth="100%",r.appendChild(u)}}let o=r.querySelector("iframe[data-src]");o&&this.shouldPreload(a)&&!/autoplay=(1|true|yes)/gi.test(s)&&o.getAttribute("src")!==s&&o.setAttribute("src",s)}this.layout(t)}layout(t){Array.from(t.querySelectorAll(".r-fit-text")).forEach(n=>{Vr(n,{minSize:24,maxSize:this.Reveal.getConfig().height*.8,observeMutations:!1,observeWindow:!1})})}unload(t){t.style.display="none";let n=this.Reveal.getSlideBackground(t);n&&(n.style.display="none",j(n,"iframe[src]").forEach(e=>{e.removeAttribute("src")})),j(t,"video[data-lazy-loaded][src], audio[data-lazy-loaded][src], iframe[data-lazy-loaded][src]").forEach(e=>{e.setAttribute("data-src",e.getAttribute("src")),e.removeAttribute("src")}),j(t,"video[data-lazy-loaded] source[src], audio source[src]").forEach(e=>{e.setAttribute("data-src",e.getAttribute("src")),e.removeAttribute("src")})}formatEmbeddedContent(){let t=(n,e,a)=>{j(this.Reveal.getSlidesElement(),"iframe["+n+'*="'+e+'"]').forEach(r=>{let s=r.getAttribute(n);s&&s.indexOf(a)===-1&&r.setAttribute(n,s+(/\?/.test(s)?"&":"?")+a)})};t("src","youtube.com/embed/","enablejsapi=1"),t("data-src","youtube.com/embed/","enablejsapi=1"),t("src","player.vimeo.com/","api=1"),t("data-src","player.vimeo.com/","api=1")}startEmbeddedContent(t){if(t){let n=this.Reveal.isSpeakerNotes();j(t,'img[src$=".gif"]').forEach(e=>{e.setAttribute("src",e.getAttribute("src"))}),j(t,"video, audio").forEach(e=>{if(De(e,".fragment")&&!De(e,".fragment.visible"))return;let a=this.Reveal.getConfig().autoPlayMedia;if(typeof a!="boolean"&&(a=e.hasAttribute("data-autoplay")||!!De(e,".slide-background")),a&&typeof e.play=="function"){if(n&&!e.muted)return;e.readyState>1?this.startEmbeddedMedia({target:e}):Lt?(e.addEventListener("canplay",this.ensureMobileMediaPlaying),this.playMediaElement(e)):(e.removeEventListener("loadeddata",this.startEmbeddedMedia),e.addEventListener("loadeddata",this.startEmbeddedMedia))}}),n||(j(t,"iframe[src]").forEach(e=>{De(e,".fragment")&&!De(e,".fragment.visible")||this.startEmbeddedIframe({target:e})}),j(t,"iframe[data-src]").forEach(e=>{De(e,".fragment")&&!De(e,".fragment.visible")||e.getAttribute("src")!==e.getAttribute("data-src")&&(e.removeEventListener("load",this.startEmbeddedIframe),e.addEventListener("load",this.startEmbeddedIframe),e.setAttribute("src",e.getAttribute("data-src")))}))}}ensureMobileMediaPlaying(t){let n=t.target;typeof n.getVideoPlaybackQuality=="function"&&setTimeout(()=>{let e=n.paused===!1,a=n.getVideoPlaybackQuality().totalVideoFrames;e&&a===0&&(n.load(),n.play())},1e3)}startEmbeddedMedia(t){let n=!!De(t.target,"html"),e=!!De(t.target,".present");n&&e&&(t.target.paused||t.target.ended)&&(t.target.currentTime=0,this.playMediaElement(t.target)),t.target.removeEventListener("loadeddata",this.startEmbeddedMedia)}playMediaElement(t){let n=t.play();n&&typeof n.catch=="function"&&n.then(()=>{t.muted||(this.allowedToPlayAudio=!0)}).catch(e=>{if(e.name==="NotAllowedError")if(this.allowedToPlayAudio=!1,t.tagName==="VIDEO"){this.onVideoPlaybackNotAllowed(t);let a=!!De(t,"html"),r=!!De(t,".present"),s=t.muted;a&&r&&!s&&(t.setAttribute("data-muted-by-reveal","true"),t.muted=!0,t.play().catch(()=>{this.onMutedVideoPlaybackNotAllowed(t)}))}else t.tagName==="AUDIO"&&this.onAudioPlaybackNotAllowed(t)})}startEmbeddedIframe(t){let n=t.target;if(this.preventIframeAutoFocus(t),n&&n.contentWindow){let e=!!De(t.target,"html"),a=!!De(t.target,".present");if(e&&a){let r=this.Reveal.getConfig().autoPlayMedia;typeof r!="boolean"&&(r=n.hasAttribute("data-autoplay")||!!De(n,".slide-background")),/youtube\.com\/embed\//.test(n.getAttribute("src"))&&r?n.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}',"*"):/player\.vimeo\.com\//.test(n.getAttribute("src"))&&r?n.contentWindow.postMessage('{"method":"play"}',"*"):n.contentWindow.postMessage("slide:start","*")}}}stopEmbeddedContent(t,n={}){n=jt({unloadIframes:!0},n),t&&t.parentNode&&(j(t,"video, audio").forEach(e=>{!e.hasAttribute("data-ignore")&&typeof e.pause=="function"&&(e.setAttribute("data-paused-by-reveal",""),e.pause(),Lt&&e.removeEventListener("canplay",this.ensureMobileMediaPlaying))}),j(t,"iframe").forEach(e=>{e.contentWindow&&e.contentWindow.postMessage("slide:stop","*"),e.removeEventListener("load",this.preventIframeAutoFocus),e.removeEventListener("load",this.startEmbeddedIframe)}),j(t,'iframe[src*="youtube.com/embed/"]').forEach(e=>{!e.hasAttribute("data-ignore")&&e.contentWindow&&typeof e.contentWindow.postMessage=="function"&&e.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}',"*")}),j(t,'iframe[src*="player.vimeo.com/"]').forEach(e=>{!e.hasAttribute("data-ignore")&&e.contentWindow&&typeof e.contentWindow.postMessage=="function"&&e.contentWindow.postMessage('{"method":"pause"}',"*")}),n.unloadIframes===!0&&j(t,"iframe[data-src]").forEach(e=>{e.setAttribute("src","about:blank"),e.removeAttribute("src")}))}isAllowedToPlayAudio(){return this.allowedToPlayAudio}showPlayOrUnmuteButton(){let t=this.failedAudioPlaybackTargets.size,n=this.failedVideoPlaybackTargets.size,e=this.failedMutedVideoPlaybackTargets.size,a="Play media";e>0?a="Play video":n>0?a="Unmute video":t>0&&(a="Play audio"),this.mediaPlayButton.textContent=a,this.Reveal.getRevealElement().appendChild(this.mediaPlayButton)}onAudioPlaybackNotAllowed(t){this.failedAudioPlaybackTargets.add(t),this.showPlayOrUnmuteButton(t)}onVideoPlaybackNotAllowed(t){this.failedVideoPlaybackTargets.add(t),this.showPlayOrUnmuteButton()}onMutedVideoPlaybackNotAllowed(t){this.failedMutedVideoPlaybackTargets.add(t),this.showPlayOrUnmuteButton()}resetTemporarilyMutedMedia(){new Set([...this.failedAudioPlaybackTargets,...this.failedVideoPlaybackTargets,...this.failedMutedVideoPlaybackTargets]).forEach(t=>{t.hasAttribute("data-muted-by-reveal")&&(t.muted=!1,t.removeAttribute("data-muted-by-reveal"))})}clearMediaPlaybackErrors(){this.resetTemporarilyMutedMedia(),this.failedAudioPlaybackTargets.clear(),this.failedVideoPlaybackTargets.clear(),this.failedMutedVideoPlaybackTargets.clear(),this.mediaPlayButton&&this.mediaPlayButton.parentNode&&this.mediaPlayButton.remove()}preventIframeAutoFocus(t){let n=t.target;if(n&&this.Reveal.getConfig().preventIframeAutoFocus){let e=0,a=()=>{document.activeElement===n?document.activeElement.blur():e<1e3&&(e+=100,setTimeout(a,100))};setTimeout(a,100)}}afterSlideChanged(){this.clearMediaPlaybackErrors()}},Nt=".slides section",ht=".slides>section",Ln=".slides>section.present>section",jr=".backgrounds>.slide-background",Wr=/registerPlugin|registerKeyboardShortcut|addKeyBinding|addEventListener|showPreview|previewIframe/,Qr=class{constructor(t){this.Reveal=t}render(){this.element=document.createElement("div"),this.element.className="slide-number",this.Reveal.getRevealElement().appendChild(this.element)}configure(t,n){let e="none";t.slideNumber&&!this.Reveal.isPrintView()&&(t.showSlideNumber==="all"||t.showSlideNumber==="speaker"&&this.Reveal.isSpeakerNotes())&&(e="block"),this.element.style.display=e}update(){this.Reveal.getConfig().slideNumber&&this.element&&(this.element.innerHTML=this.getSlideNumber())}getSlideNumber(t=this.Reveal.getCurrentSlide()){let n=this.Reveal.getConfig(),e,a="h.v";if(typeof n.slideNumber=="function")e=n.slideNumber(t);else{typeof n.slideNumber=="string"&&(a=n.slideNumber),!/c/.test(a)&&this.Reveal.getHorizontalSlides().length===1&&(a="c");let s=t&&t.dataset.visibility==="uncounted"?0:1;switch(e=[],a){case"c":e.push(this.Reveal.getSlidePastCount(t)+s);break;case"c/t":e.push(this.Reveal.getSlidePastCount(t)+s,"/",this.Reveal.getTotalSlides());break;default:let o=this.Reveal.getIndices(t);e.push(o.h+s);let l=a==="h/v"?"/":".";this.Reveal.isVerticalSlide(t)&&e.push(l,o.v+1)}}let r="#"+this.Reveal.location.getHash(t);return this.formatNumber(e[0],e[1],e[2],r)}formatNumber(t,n,e,a="#"+this.Reveal.location.getHash()){return typeof e=="number"&&!isNaN(e)?`<a href="${a}">
1
+ import{jm as je,jn as We,jo as Qe,jp as Ke,jq as Xe,jr as Ze,js as Je,jt as et,ju as xe,r as Q,j as S,ar as br,_ as fr,jv as Tr,K as vr,bW as Cr,I as yr,bX as Rr,D as Nr,f4 as Or,bi as da,T as Ar}from"../datalayer-app-main.js";import{x as Ir,B as xr,N as Dr}from"./JupyterLexicalExtension-CqDatsgf.js";import"./NotebookSkeleton-CI7ovjNW.js";import"./Avatar-9MpXENSs.js";import"./url-DuKx0yk0.js";import"./isSymbol-BLtK9CV6.js";import"./toNumber-B1wj8-wx.js";import"./VideoIcon-BjP_LDa4.js";import"./LinkIcon-DUI0jw25.js";import"./Toolbar-CGQDY041.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./ArrowUpIcon-BUCpIXDR.js";import"./SortDescIcon-CS4EzHeS.js";import"./PaintbrushIcon-CLU8RilX.js";import"./PrismCss-CcU1ChRk.js";import"./Output-no9rnFJ7.js";import"./index-CFP9psRB.js";import"./hoverbox-CStlKQWE.js";import"./index-DSN70XMH.js";import"./index-S4sn4R3i.js";import"./color-CG7_7V2-.js";import"./isEqual-g-jK7vY0.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./index-BJhxZF_K.js";import"./RestartIcon-Ca6_HoK0.js";import"./LexicalToolRegistry-8wJyLumb.js";const _a={datalayer:{light:{primary:xe.greenAccent,secondary:xe.greenText,textColor:xe.gray,primaryGradient:[xe.greenAccent,xe.greenBrand],secondaryGradient:[xe.greenHover,xe.greenBrand]},dark:{primary:xe.greenBright,secondary:xe.greenAccent,textColor:xe.gray,primaryGradient:[xe.greenAccent,xe.greenBrand],secondaryGradient:[xe.greenHover,xe.greenText]}},spatial:{light:{primary:et.indigoBrand,secondary:et.indigoText,textColor:et.gray,primaryGradient:[et.indigoBright,et.indigoBrand],secondaryGradient:[et.indigoHover,et.indigoAccent]},dark:{primary:et.indigoBright,secondary:et.indigoAccent,textColor:et.gray,primaryGradient:[et.indigoBright,et.indigoBrand],secondaryGradient:[et.indigoHover,et.indigoAccent]}},lovely:{light:{primary:Je.roseBrand,secondary:Je.roseText,textColor:Je.gray,primaryGradient:[Je.roseBright,Je.roseBrand],secondaryGradient:[Je.roseHover,Je.roseAccent]},dark:{primary:Je.roseBright,secondary:Je.roseAccent,textColor:Je.gray,primaryGradient:[Je.roseBright,Je.roseBrand],secondaryGradient:[Je.roseHover,Je.roseAccent]}},matrix:{light:{primary:Ze.greenBrand,secondary:Ze.greenText,textColor:Ze.gray,primaryGradient:[Ze.greenGlow,Ze.greenBrand],secondaryGradient:[Ze.greenHover,Ze.greenAccent]},dark:{primary:Ze.greenGlow,secondary:Ze.greenPhosphor,textColor:Ze.gray,primaryGradient:[Ze.greenGlow,Ze.greenBrand],secondaryGradient:[Ze.greenHover,Ze.greenAccent]}},earth:{light:{primary:Xe.oceanBrand,secondary:Xe.oceanText,textColor:Xe.gray,primaryGradient:[Xe.oceanAccent,Xe.oceanBrand],secondaryGradient:[Xe.oceanHover,Xe.oceanText]},dark:{primary:Xe.oceanBright,secondary:Xe.oceanAccent,textColor:Xe.gray,primaryGradient:[Xe.oceanBright,Xe.oceanBrand],secondaryGradient:[Xe.oceanHover,Xe.oceanAccent]}},sand:{light:{primary:Ke.sandBrand,secondary:Ke.sandText,textColor:Ke.gray,primaryGradient:[Ke.sandAccent,Ke.sandBrand],secondaryGradient:[Ke.sandHover,Ke.sandText]},dark:{primary:Ke.sandBright,secondary:Ke.sandAccent,textColor:Ke.gray,primaryGradient:[Ke.sandBright,Ke.sandBrand],secondaryGradient:[Ke.sandHover,Ke.sandAccent]}},ivory:{light:{primary:Qe.ivoryBrand,secondary:Qe.ivoryText,textColor:Qe.gray,primaryGradient:[Qe.ivoryAccent,Qe.ivoryBrand],secondaryGradient:[Qe.ivoryHover,Qe.ivoryText]},dark:{primary:Qe.ivoryBright,secondary:Qe.ivoryAccent,textColor:Qe.gray,primaryGradient:[Qe.ivoryBright,Qe.ivoryBrand],secondaryGradient:[Qe.ivoryHover,Qe.ivoryAccent]}},sun:{light:{primary:We.sunBrand,secondary:We.sunText,textColor:We.gray,primaryGradient:[We.sunAccent,We.sunBrand],secondaryGradient:[We.sunHover,We.sunText]},dark:{primary:We.sunBright,secondary:We.sunAccent,textColor:We.gray,primaryGradient:[We.sunBright,We.sunBrand],secondaryGradient:[We.sunHover,We.sunAccent]}},loop:{light:{primary:je.loopAccent,secondary:je.ink,textColor:je.gray,primaryGradient:[je.loopAccent,je.loopAccent],secondaryGradient:[je.ink,je.ink]},dark:{primary:je.loopBrand,secondary:je.inkDark,textColor:je.grayDark,primaryGradient:[je.loopBrand,je.loopBrand],secondaryGradient:[je.inkDark,je.inkDark]}}};function Ya(i="datalayer",t="light"){const n=t==="auto"?"light":t;return _a[i]?.[n]??_a.datalayer.light}const ua=25,wr=[{y:0,secondaryWidth:30,primaryWidth:70},{y:37.5,secondaryWidth:50,primaryWidth:50},{y:75,secondaryWidth:70,primaryWidth:30}];Q.forwardRef(function({size:t=16,variant:n="datalayer",colorMode:e="light",primaryColor:a,secondaryColor:r,primaryGradient:s,secondaryGradient:o,gradient:l=!0,...c},d){const _=Ya(n,e),u=a??_.primary,m=r??_.secondary,p=Q.useId().replace(/:/g,""),[g,b]=s??_.primaryGradient,[C,y]=o??_.secondaryGradient;return S.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 100 100",width:t,height:t,"aria-hidden":"true",ref:d,...c,children:[l&&S.jsxs("defs",{children:[S.jsxs("linearGradient",{id:`${p}-p`,x1:"0",y1:"0",x2:"1",y2:"0",children:[S.jsx("stop",{offset:"0",stopColor:g}),S.jsx("stop",{offset:"1",stopColor:b})]}),S.jsxs("linearGradient",{id:`${p}-s`,x1:"0",y1:"0",x2:"1",y2:"0",children:[S.jsx("stop",{offset:"0",stopColor:C}),S.jsx("stop",{offset:"1",stopColor:y})]})]}),wr.map(({y:N,secondaryWidth:O,primaryWidth:v})=>S.jsxs("g",{children:[S.jsx("rect",{x:0,y:N,width:O,height:ua,fill:l?`url(#${p}-p)`:u}),S.jsx("rect",{x:O,y:N,width:v,height:ua,fill:l?`url(#${p}-s)`:m})]},N))]})});const Ha=new Map,On=i=>Ha.get(i),an=i=>Ha.has(i),kr=/(\*\*[^*]+\*\*|`[^`]+`|\[[^\]]+\]\([^)]+\)|==[^=]+==)/g,ie=i=>i.split(kr).map((t,n)=>{const e=`${n}-${t}`;if(t.startsWith("**")&&t.endsWith("**"))return S.jsx("strong",{children:ie(t.slice(2,-2))},e);if(t.startsWith("`")&&t.endsWith("`"))return S.jsx("code",{children:t.slice(1,-1)},e);if(t.startsWith("==")&&t.endsWith("=="))return S.jsx("mark",{className:"dla-alert",children:t.slice(2,-2)},e);const a=/^\[([^\]]+)\]\(([^)]+)\)$/.exec(t);return a?S.jsx("a",{href:a[2],target:"_blank",rel:"noopener noreferrer",children:a[1]},e):t}),Mr=i=>i.trim().split(/\n\s*\n/).map((t,n)=>S.jsx("p",{children:ie(t.trim())},`${n}-${t.slice(0,24)}`)),Lr=()=>{const{theme:i,colorMode:t}=br();return{theme:i,colorMode:t}},Pr={useTheme:Lr},Fr=Q.createContext(Pr),Va=()=>Q.useContext(Fr),za=()=>{const{useTheme:i}=Va();return i()},An=({footer:i,theme:t,index:n,total:e})=>{const{colorMode:a,theme:r}=za(),{Logo:s}=Va(),o=a==="auto"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":a,l=Ya(r,o),c=new Date().getFullYear(),d=i.since&&i.since<c?`${i.since}–${c}`:`${c}`;return S.jsxs("div",{className:"dla-slide-footer",children:[i.logo&&S.jsx("a",{className:"dla-slide-footer-logo",href:i.href,target:"_blank",rel:"noopener noreferrer","aria-label":`${i.holder} — ${i.href}`,children:s?S.jsx(s,{height:26,variant:r,colorMode:a,inverse:t.logo.inverse,colored:t.logo.colored,primaryColor:t.logo.primaryColor??l.primary,secondaryColor:t.logo.secondaryColor??l.secondary,textColor:t.logo.textColor??l.textColor}):S.jsx("span",{className:"dla-slide-footer-holder",children:i.holder})}),i.note&&S.jsx("div",{className:"dla-slide-footer-note",children:i.note}),S.jsxs("div",{className:"dla-slide-footer-legal",children:[S.jsx("a",{href:i.href,target:"_blank",rel:"noopener noreferrer",children:i.href.replace(/^https?:\/\//,"")}),S.jsxs("span",{children:["© ",d," ",i.holder]}),i.slideNumbers&&S.jsxs("span",{className:"dla-slide-footer-number",children:[n," / ",e]})]})]})},In=({name:i})=>{if(!i)return null;const t=On(i);return t?S.jsx("div",{className:"dla-slide-backdrop","aria-hidden":!0,children:S.jsx(t,{})}):null},Le=({theme:i,footer:t,index:n,total:e,eyebrow:a,title:r,subtitle:s,layout:o,variant:l,backdrop:c,children:d})=>{const _=["dla-slide"];return l&&_.push(`dla-slide--${l}`),(o==="centered"||o==="full-bleed")&&_.push(`dla-slide--${o}`),S.jsxs("div",{className:_.join(" "),children:[S.jsx(In,{name:c}),S.jsxs("div",{className:"dla-slide-head",children:[a&&S.jsx("div",{className:"dla-slide-eyebrow",children:a}),r&&S.jsx("h2",{className:"dla-slide-title",children:ie(r)}),s&&S.jsx("p",{className:"dla-slide-subtitle",children:ie(s)})]}),S.jsx("div",{className:"dla-slide-body",children:d}),t&&S.jsx(An,{footer:t,theme:i,index:n,total:e})]})};var jt=(i,t)=>{for(let n in t)i[n]=t[n];return i},j=(i,t)=>Array.from(i.querySelectorAll(t)),Mn=(i,t,n)=>{n?i.classList.add(t):i.classList.remove(t)},$t=i=>{if(typeof i=="string"){if(i==="null")return null;if(i==="true")return!0;if(i==="false")return!1;if(i.match(/^-?[\d\.]+$/))return parseFloat(i)}return i},Rt=(i,t)=>{i.style.transform=t},Cn=(i,t)=>{let n=i.matches||i.matchesSelector||i.msMatchesSelector;return!!(n&&n.call(i,t))},De=(i,t)=>{if(i&&typeof i.closest=="function")return i.closest(t);for(;i;){if(Cn(i,t))return i;i=i.parentElement}return null},qa=i=>{i=i||document.documentElement;let t=i.requestFullscreen||i.webkitRequestFullscreen||i.webkitRequestFullScreen||i.mozRequestFullScreen||i.msRequestFullscreen;t&&t.apply(i)},Ur=(i,t,n,e="")=>{let a=i.querySelectorAll("."+n);for(let s=0;s<a.length;s++){let o=a[s];if(o.parentNode===i)return o}let r=document.createElement(t);return r.className=n,r.innerHTML=e,i.appendChild(r),r},Hn=i=>{let t=document.createElement("style");return i&&i.length>0&&t.appendChild(document.createTextNode(i)),document.head.appendChild(t),t},pa=()=>{let i={};location.search.replace(/[A-Z0-9]+?=([\w\.%-]*)/gi,t=>{let n=t.split("=").shift(),e=t.split("=").pop();return n&&e!==void 0&&(i[n]=e),t});for(let t in i){let n=i[t];i[t]=$t(unescape(n))}return i.dependencies!==void 0&&delete i.dependencies,i},Br=(i,t=0)=>{if(i){var n;let e,a=i.style.height;return i.style.height="0px",i.parentElement&&(i.parentElement.style.height="auto"),e=t-(((n=i.parentElement)==null?void 0:n.offsetHeight)||0),i.style.height=a+"px",i.parentElement&&i.parentElement.style.removeProperty("height"),e}return t},Gr={mp4:"video/mp4",m4a:"video/mp4",ogv:"video/ogg",mpeg:"video/mpeg",webm:"video/webm"},Yr=(i="")=>{let t=i.split(".").pop();return t?Gr[t]:void 0},Hr=(i="")=>encodeURI(i).replace(/%5B/g,"[").replace(/%5D/g,"]").replace(/[!'()*]/g,t=>`%${t.charCodeAt(0).toString(16).toUpperCase()}`),$a=navigator.userAgent,Lt=/(iphone|ipod|ipad|android)/gi.test($a)||navigator.platform==="MacIntel"&&navigator.maxTouchPoints>1,ja=/android/gi.test($a),Vr=(function(i){if(i){var t=function(R){return[].slice.call(R)},n=0,e=1,a=2,r=3,s=[],o=null,l="requestAnimationFrame"in i?function(){var R=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{sync:!1};i.cancelAnimationFrame(o);var U=function(){return d(s.filter((function(z){return z.dirty&&z.active})))};if(R.sync)return U();o=i.requestAnimationFrame(U)}:function(){},c=function(R){return function(U){s.forEach((function(z){return z.dirty=R})),l(U)}},d=function(R){R.filter((function(z){return!z.styleComputed})).forEach((function(z){z.styleComputed=p(z)})),R.filter(g).forEach(b);var U=R.filter(m);U.forEach(u),U.forEach((function(z){b(z),_(z)})),U.forEach(C)},_=function(R){return R.dirty=n},u=function(R){R.availableWidth=R.element.parentNode.clientWidth,R.currentWidth=R.element.scrollWidth,R.previousFontSize=R.currentFontSize,R.currentFontSize=Math.min(Math.max(R.minSize,R.availableWidth/R.currentWidth*R.previousFontSize),R.maxSize),R.whiteSpace=R.multiLine&&R.currentFontSize===R.minSize?"normal":"nowrap"},m=function(R){return R.dirty!==a||R.dirty===a&&R.element.parentNode.clientWidth!==R.availableWidth},p=function(R){var U=i.getComputedStyle(R.element,null);return R.currentFontSize=parseFloat(U.getPropertyValue("font-size")),R.display=U.getPropertyValue("display"),R.whiteSpace=U.getPropertyValue("white-space"),!0},g=function(R){var U=!1;return!R.preStyleTestCompleted&&(/inline-/.test(R.display)||(U=!0,R.display="inline-block"),R.whiteSpace!=="nowrap"&&(U=!0,R.whiteSpace="nowrap"),R.preStyleTestCompleted=!0,U)},b=function(R){R.element.style.whiteSpace=R.whiteSpace,R.element.style.display=R.display,R.element.style.fontSize=R.currentFontSize+"px"},C=function(R){R.element.dispatchEvent(new CustomEvent("fit",{detail:{oldValue:R.previousFontSize,newValue:R.currentFontSize,scaleFactor:R.currentFontSize/R.previousFontSize}}))},y=function(R,U){return function(z){R.dirty=U,R.active&&l(z)}},N=function(R){return function(){s=s.filter((function(U){return U.element!==R.element})),R.observeMutations&&R.observer.disconnect(),R.element.style.whiteSpace=R.originalStyle.whiteSpace,R.element.style.display=R.originalStyle.display,R.element.style.fontSize=R.originalStyle.fontSize}},O=function(R){return function(){R.active||(R.active=!0,l())}},v=function(R){return function(){return R.active=!1}},A=function(R){R.observeMutations&&(R.observer=new MutationObserver(y(R,e)),R.observer.observe(R.element,R.observeMutations))},M={minSize:16,maxSize:512,multiLine:!0,observeMutations:"MutationObserver"in i&&{subtree:!0,childList:!0,characterData:!0}},F=null,Y=function(){i.clearTimeout(F),F=i.setTimeout(c(a),B.observeWindowDelay)},x=["resize","orientationchange"];return Object.defineProperty(B,"observeWindow",{set:function(R){var U=`${R?"add":"remove"}EventListener`;x.forEach((function(z){i[U](z,Y)}))}}),B.observeWindow=!0,B.observeWindowDelay=100,B.fitAll=c(r),B}function K(R,U){var z=Object.assign({},M,U),Z=R.map((function(te){var se=Object.assign({},z,{element:te,active:!0});return(function(ae){ae.originalStyle={whiteSpace:ae.element.style.whiteSpace,display:ae.element.style.display,fontSize:ae.element.style.fontSize},A(ae),ae.newbie=!0,ae.dirty=!0,s.push(ae)})(se),{element:te,fit:y(se,r),unfreeze:O(se),freeze:v(se),unsubscribe:N(se)}}));return l(),Z}function B(R){var U=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return typeof R=="string"?K(t(document.querySelectorAll(R)),U):K([R],U)[0]}})(typeof window>"u"?null:window);function ln(i){"@babel/helpers - typeof";return ln=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ln(i)}function zr(i,t){if(ln(i)!="object"||!i)return i;var n=i[Symbol.toPrimitive];if(n!==void 0){var e=n.call(i,t);if(ln(e)!="object")return e;throw TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(i)}function qr(i){var t=zr(i,"string");return ln(t)=="symbol"?t:t+""}function Kn(i,t,n){return(t=qr(t))in i?Object.defineProperty(i,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):i[t]=n,i}var $r=class{constructor(t){Kn(this,"allowedToPlayAudio",null),this.Reveal=t,this.startEmbeddedMedia=this.startEmbeddedMedia.bind(this),this.startEmbeddedIframe=this.startEmbeddedIframe.bind(this),this.preventIframeAutoFocus=this.preventIframeAutoFocus.bind(this),this.ensureMobileMediaPlaying=this.ensureMobileMediaPlaying.bind(this),this.failedAudioPlaybackTargets=new Set,this.failedVideoPlaybackTargets=new Set,this.failedMutedVideoPlaybackTargets=new Set,this.renderMediaPlayButton()}renderMediaPlayButton(){this.mediaPlayButton=document.createElement("button"),this.mediaPlayButton.className="r-overlay-button r-media-play-button",this.mediaPlayButton.addEventListener("click",()=>{this.resetTemporarilyMutedMedia(),new Set([...this.failedAudioPlaybackTargets,...this.failedVideoPlaybackTargets,...this.failedMutedVideoPlaybackTargets]).forEach(t=>{this.startEmbeddedMedia({target:t})}),this.clearMediaPlaybackErrors()})}shouldPreload(t){if(this.Reveal.isScrollView())return!0;let n=this.Reveal.getConfig().preloadIframes;return typeof n!="boolean"&&(n=t.hasAttribute("data-preload")),n}load(t,n={}){let e=this.Reveal.getConfig().display;if(e.includes("!important")){let r=e.replace(/\s*!important\s*$/,"").trim();t.style.setProperty("display",r,"important")}else t.style.display=e;j(t,"img[data-src], video[data-src], audio[data-src], iframe[data-src]").forEach(r=>{let s=r.tagName==="IFRAME";(!s||this.shouldPreload(r))&&(r.setAttribute("src",r.getAttribute("data-src")),r.setAttribute("data-lazy-loaded",""),r.removeAttribute("data-src"),s&&r.addEventListener("load",this.preventIframeAutoFocus))}),j(t,"video, audio").forEach(r=>{let s=0;j(r,"source[data-src]").forEach(o=>{o.setAttribute("src",o.getAttribute("data-src")),o.removeAttribute("data-src"),o.setAttribute("data-lazy-loaded",""),s+=1}),Lt&&r.tagName==="VIDEO"&&r.setAttribute("playsinline",""),s>0&&r.load()});let a=t.slideBackgroundElement;if(a){a.style.display="block";let r=t.slideBackgroundContentElement,s=t.getAttribute("data-background-iframe");if(a.hasAttribute("data-loaded")===!1){a.setAttribute("data-loaded","true");let l=t.getAttribute("data-background-image"),c=t.getAttribute("data-background-video"),d=t.hasAttribute("data-background-video-loop"),_=t.hasAttribute("data-background-video-muted");if(l)/^data:/.test(l.trim())?r.style.backgroundImage=`url(${l.trim()})`:r.style.backgroundImage=l.split(",").map(u=>`url(${Hr(decodeURI(u.trim()))})`).join(",");else if(c){let u=document.createElement("video");d&&u.setAttribute("loop",""),(_||this.Reveal.isSpeakerNotes())&&(u.muted=!0),Lt&&u.setAttribute("playsinline",""),c.split(",").forEach(m=>{let p=document.createElement("source");p.setAttribute("src",m);let g=Yr(m);g&&p.setAttribute("type",g),u.appendChild(p)}),r.appendChild(u)}else if(s&&n.excludeIframes!==!0){let u=document.createElement("iframe");u.setAttribute("allowfullscreen",""),u.setAttribute("mozallowfullscreen",""),u.setAttribute("webkitallowfullscreen",""),u.setAttribute("allow","autoplay"),u.setAttribute("data-src",s),u.style.width="100%",u.style.height="100%",u.style.maxHeight="100%",u.style.maxWidth="100%",r.appendChild(u)}}let o=r.querySelector("iframe[data-src]");o&&this.shouldPreload(a)&&!/autoplay=(1|true|yes)/gi.test(s)&&o.getAttribute("src")!==s&&o.setAttribute("src",s)}this.layout(t)}layout(t){Array.from(t.querySelectorAll(".r-fit-text")).forEach(n=>{Vr(n,{minSize:24,maxSize:this.Reveal.getConfig().height*.8,observeMutations:!1,observeWindow:!1})})}unload(t){t.style.display="none";let n=this.Reveal.getSlideBackground(t);n&&(n.style.display="none",j(n,"iframe[src]").forEach(e=>{e.removeAttribute("src")})),j(t,"video[data-lazy-loaded][src], audio[data-lazy-loaded][src], iframe[data-lazy-loaded][src]").forEach(e=>{e.setAttribute("data-src",e.getAttribute("src")),e.removeAttribute("src")}),j(t,"video[data-lazy-loaded] source[src], audio source[src]").forEach(e=>{e.setAttribute("data-src",e.getAttribute("src")),e.removeAttribute("src")})}formatEmbeddedContent(){let t=(n,e,a)=>{j(this.Reveal.getSlidesElement(),"iframe["+n+'*="'+e+'"]').forEach(r=>{let s=r.getAttribute(n);s&&s.indexOf(a)===-1&&r.setAttribute(n,s+(/\?/.test(s)?"&":"?")+a)})};t("src","youtube.com/embed/","enablejsapi=1"),t("data-src","youtube.com/embed/","enablejsapi=1"),t("src","player.vimeo.com/","api=1"),t("data-src","player.vimeo.com/","api=1")}startEmbeddedContent(t){if(t){let n=this.Reveal.isSpeakerNotes();j(t,'img[src$=".gif"]').forEach(e=>{e.setAttribute("src",e.getAttribute("src"))}),j(t,"video, audio").forEach(e=>{if(De(e,".fragment")&&!De(e,".fragment.visible"))return;let a=this.Reveal.getConfig().autoPlayMedia;if(typeof a!="boolean"&&(a=e.hasAttribute("data-autoplay")||!!De(e,".slide-background")),a&&typeof e.play=="function"){if(n&&!e.muted)return;e.readyState>1?this.startEmbeddedMedia({target:e}):Lt?(e.addEventListener("canplay",this.ensureMobileMediaPlaying),this.playMediaElement(e)):(e.removeEventListener("loadeddata",this.startEmbeddedMedia),e.addEventListener("loadeddata",this.startEmbeddedMedia))}}),n||(j(t,"iframe[src]").forEach(e=>{De(e,".fragment")&&!De(e,".fragment.visible")||this.startEmbeddedIframe({target:e})}),j(t,"iframe[data-src]").forEach(e=>{De(e,".fragment")&&!De(e,".fragment.visible")||e.getAttribute("src")!==e.getAttribute("data-src")&&(e.removeEventListener("load",this.startEmbeddedIframe),e.addEventListener("load",this.startEmbeddedIframe),e.setAttribute("src",e.getAttribute("data-src")))}))}}ensureMobileMediaPlaying(t){let n=t.target;typeof n.getVideoPlaybackQuality=="function"&&setTimeout(()=>{let e=n.paused===!1,a=n.getVideoPlaybackQuality().totalVideoFrames;e&&a===0&&(n.load(),n.play())},1e3)}startEmbeddedMedia(t){let n=!!De(t.target,"html"),e=!!De(t.target,".present");n&&e&&(t.target.paused||t.target.ended)&&(t.target.currentTime=0,this.playMediaElement(t.target)),t.target.removeEventListener("loadeddata",this.startEmbeddedMedia)}playMediaElement(t){let n=t.play();n&&typeof n.catch=="function"&&n.then(()=>{t.muted||(this.allowedToPlayAudio=!0)}).catch(e=>{if(e.name==="NotAllowedError")if(this.allowedToPlayAudio=!1,t.tagName==="VIDEO"){this.onVideoPlaybackNotAllowed(t);let a=!!De(t,"html"),r=!!De(t,".present"),s=t.muted;a&&r&&!s&&(t.setAttribute("data-muted-by-reveal","true"),t.muted=!0,t.play().catch(()=>{this.onMutedVideoPlaybackNotAllowed(t)}))}else t.tagName==="AUDIO"&&this.onAudioPlaybackNotAllowed(t)})}startEmbeddedIframe(t){let n=t.target;if(this.preventIframeAutoFocus(t),n&&n.contentWindow){let e=!!De(t.target,"html"),a=!!De(t.target,".present");if(e&&a){let r=this.Reveal.getConfig().autoPlayMedia;typeof r!="boolean"&&(r=n.hasAttribute("data-autoplay")||!!De(n,".slide-background")),/youtube\.com\/embed\//.test(n.getAttribute("src"))&&r?n.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}',"*"):/player\.vimeo\.com\//.test(n.getAttribute("src"))&&r?n.contentWindow.postMessage('{"method":"play"}',"*"):n.contentWindow.postMessage("slide:start","*")}}}stopEmbeddedContent(t,n={}){n=jt({unloadIframes:!0},n),t&&t.parentNode&&(j(t,"video, audio").forEach(e=>{!e.hasAttribute("data-ignore")&&typeof e.pause=="function"&&(e.setAttribute("data-paused-by-reveal",""),e.pause(),Lt&&e.removeEventListener("canplay",this.ensureMobileMediaPlaying))}),j(t,"iframe").forEach(e=>{e.contentWindow&&e.contentWindow.postMessage("slide:stop","*"),e.removeEventListener("load",this.preventIframeAutoFocus),e.removeEventListener("load",this.startEmbeddedIframe)}),j(t,'iframe[src*="youtube.com/embed/"]').forEach(e=>{!e.hasAttribute("data-ignore")&&e.contentWindow&&typeof e.contentWindow.postMessage=="function"&&e.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}',"*")}),j(t,'iframe[src*="player.vimeo.com/"]').forEach(e=>{!e.hasAttribute("data-ignore")&&e.contentWindow&&typeof e.contentWindow.postMessage=="function"&&e.contentWindow.postMessage('{"method":"pause"}',"*")}),n.unloadIframes===!0&&j(t,"iframe[data-src]").forEach(e=>{e.setAttribute("src","about:blank"),e.removeAttribute("src")}))}isAllowedToPlayAudio(){return this.allowedToPlayAudio}showPlayOrUnmuteButton(){let t=this.failedAudioPlaybackTargets.size,n=this.failedVideoPlaybackTargets.size,e=this.failedMutedVideoPlaybackTargets.size,a="Play media";e>0?a="Play video":n>0?a="Unmute video":t>0&&(a="Play audio"),this.mediaPlayButton.textContent=a,this.Reveal.getRevealElement().appendChild(this.mediaPlayButton)}onAudioPlaybackNotAllowed(t){this.failedAudioPlaybackTargets.add(t),this.showPlayOrUnmuteButton(t)}onVideoPlaybackNotAllowed(t){this.failedVideoPlaybackTargets.add(t),this.showPlayOrUnmuteButton()}onMutedVideoPlaybackNotAllowed(t){this.failedMutedVideoPlaybackTargets.add(t),this.showPlayOrUnmuteButton()}resetTemporarilyMutedMedia(){new Set([...this.failedAudioPlaybackTargets,...this.failedVideoPlaybackTargets,...this.failedMutedVideoPlaybackTargets]).forEach(t=>{t.hasAttribute("data-muted-by-reveal")&&(t.muted=!1,t.removeAttribute("data-muted-by-reveal"))})}clearMediaPlaybackErrors(){this.resetTemporarilyMutedMedia(),this.failedAudioPlaybackTargets.clear(),this.failedVideoPlaybackTargets.clear(),this.failedMutedVideoPlaybackTargets.clear(),this.mediaPlayButton&&this.mediaPlayButton.parentNode&&this.mediaPlayButton.remove()}preventIframeAutoFocus(t){let n=t.target;if(n&&this.Reveal.getConfig().preventIframeAutoFocus){let e=0,a=()=>{document.activeElement===n?document.activeElement.blur():e<1e3&&(e+=100,setTimeout(a,100))};setTimeout(a,100)}}afterSlideChanged(){this.clearMediaPlaybackErrors()}},Nt=".slides section",ht=".slides>section",Ln=".slides>section.present>section",jr=".backgrounds>.slide-background",Wr=/registerPlugin|registerKeyboardShortcut|addKeyBinding|addEventListener|showPreview|previewIframe/,Qr=class{constructor(t){this.Reveal=t}render(){this.element=document.createElement("div"),this.element.className="slide-number",this.Reveal.getRevealElement().appendChild(this.element)}configure(t,n){let e="none";t.slideNumber&&!this.Reveal.isPrintView()&&(t.showSlideNumber==="all"||t.showSlideNumber==="speaker"&&this.Reveal.isSpeakerNotes())&&(e="block"),this.element.style.display=e}update(){this.Reveal.getConfig().slideNumber&&this.element&&(this.element.innerHTML=this.getSlideNumber())}getSlideNumber(t=this.Reveal.getCurrentSlide()){let n=this.Reveal.getConfig(),e,a="h.v";if(typeof n.slideNumber=="function")e=n.slideNumber(t);else{typeof n.slideNumber=="string"&&(a=n.slideNumber),!/c/.test(a)&&this.Reveal.getHorizontalSlides().length===1&&(a="c");let s=t&&t.dataset.visibility==="uncounted"?0:1;switch(e=[],a){case"c":e.push(this.Reveal.getSlidePastCount(t)+s);break;case"c/t":e.push(this.Reveal.getSlidePastCount(t)+s,"/",this.Reveal.getTotalSlides());break;default:let o=this.Reveal.getIndices(t);e.push(o.h+s);let l=a==="h/v"?"/":".";this.Reveal.isVerticalSlide(t)&&e.push(l,o.v+1)}}let r="#"+this.Reveal.location.getHash(t);return this.formatNumber(e[0],e[1],e[2],r)}formatNumber(t,n,e,a="#"+this.Reveal.location.getHash()){return typeof e=="number"&&!isNaN(e)?`<a href="${a}">
2
2
  <span class="slide-number-a">${t}</span>
3
3
  <span class="slide-number-delimiter">${n}</span>
4
4
  <span class="slide-number-b">${e}</span>
@@ -1,3 +1,3 @@
1
- import{w as b,x as E,E as v,r as I,j as i,B as c,T as N,bk as j,bl as T,bm as U}from"../datalayer-app-main.js";import{EphemeralDocument as O}from"./EphemeralDocument-DIHjR5l8.js";import{O as _,b as P,u as w}from"./openingNotebook-CjjarT8V.js";import{P as d}from"./PrismCss-CcU1ChRk.js";import"./lexicalHooks-Pqoe8h_O.js";import"./LexicalToolRegistry-8wJyLumb.js";import"./useProgressTask-UPro-gwc.js";import"./JupyterLexicalExtension-_7FM5Om8.js";import"./NotebookSkeleton-CI7ovjNW.js";import"./Avatar-9MpXENSs.js";import"./url-DuKx0yk0.js";import"./isSymbol-BLtK9CV6.js";import"./toNumber-B1wj8-wx.js";import"./VideoIcon-BjP_LDa4.js";import"./LinkIcon-DUI0jw25.js";import"./Toolbar-CGQDY041.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./ArrowUpIcon-BUCpIXDR.js";import"./SortDescIcon-CS4EzHeS.js";import"./PaintbrushIcon-CLU8RilX.js";import"./Output-BWClePP-.js";import"./index-CFP9psRB.js";import"./hoverbox-CStlKQWE.js";import"./index-DSN70XMH.js";import"./index-DyVR0igi.js";import"./color-CG7_7V2-.js";import"./isEqual-Cwjr2skl.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./index-BJhxZF_K.js";import"./RestartIcon-Ca6_HoK0.js";const D="Quarterly revenue by region",M="Six rows of revenue, two quarters, three regions. The cell below loads them and shows the frame; run it, change it, or ask an agent to take it further — the code and its output live in this document, beside the words about them.",l="opening-document-input",S="opening-document-output",g=e=>({detail:0,format:0,mode:"normal",style:"",text:e,type:"text",version:1}),u=(e,o,t={})=>({children:o,direction:"ltr",format:"",indent:0,type:e,version:1,...t}),h={type:"linebreak",version:1},s=(e,o)=>({detail:0,format:0,mode:"normal",style:"",text:e,type:"jupyter-input-highlight",version:1,highlightType:o}),f=e=>e.flatMap(o=>{if(typeof o=="string")return o.split(`
1
+ import{w as b,x as E,E as v,r as I,j as i,B as c,T as N,bk as j,bl as T,bm as U}from"../datalayer-app-main.js";import{EphemeralDocument as O}from"./EphemeralDocument--pV47gPl.js";import{O as _,b as P,u as w}from"./openingNotebook-CjjarT8V.js";import{P as d}from"./PrismCss-CcU1ChRk.js";import"./lexicalHooks-Pqoe8h_O.js";import"./LexicalToolRegistry-8wJyLumb.js";import"./useProgressTask-UPro-gwc.js";import"./JupyterLexicalExtension-CqDatsgf.js";import"./NotebookSkeleton-CI7ovjNW.js";import"./Avatar-9MpXENSs.js";import"./url-DuKx0yk0.js";import"./isSymbol-BLtK9CV6.js";import"./toNumber-B1wj8-wx.js";import"./VideoIcon-BjP_LDa4.js";import"./LinkIcon-DUI0jw25.js";import"./Toolbar-CGQDY041.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./ArrowUpIcon-BUCpIXDR.js";import"./SortDescIcon-CS4EzHeS.js";import"./PaintbrushIcon-CLU8RilX.js";import"./Output-no9rnFJ7.js";import"./index-CFP9psRB.js";import"./hoverbox-CStlKQWE.js";import"./index-DSN70XMH.js";import"./index-S4sn4R3i.js";import"./color-CG7_7V2-.js";import"./isEqual-g-jK7vY0.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./index-BJhxZF_K.js";import"./RestartIcon-Ca6_HoK0.js";const D="Quarterly revenue by region",M="Six rows of revenue, two quarters, three regions. The cell below loads them and shows the frame; run it, change it, or ask an agent to take it further — the code and its output live in this document, beside the words about them.",l="opening-document-input",S="opening-document-output",g=e=>({detail:0,format:0,mode:"normal",style:"",text:e,type:"text",version:1}),u=(e,o,t={})=>({children:o,direction:"ltr",format:"",indent:0,type:e,version:1,...t}),h={type:"linebreak",version:1},s=(e,o)=>({detail:0,format:0,mode:"normal",style:"",text:e,type:"jupyter-input-highlight",version:1,highlightType:o}),f=e=>e.flatMap(o=>{if(typeof o=="string")return o.split(`
2
2
  `).flatMap((n,m)=>[...m>0?[h]:[],...n.length>0?[s(n)]:[]]);const{content:t,type:r}=o;return typeof t=="string"?[s(t,r)]:Array.isArray(t)?t.length===1&&typeof t[0]=="string"?[s(t[0],r)]:f(t):[]}),k=e=>{const o=d.languages.python;return o?f(d.tokenize(e,o)):e.split(`
3
3
  `).flatMap((t,r)=>[...r>0?[h]:[],...t.length>0?[s(t)]:[]])};function A(){const e=_.join("");return{root:{children:[u("heading",[g(D)],{tag:"h1"}),u("paragraph",[g(M)],{textFormat:0,textStyle:""}),u("jupyter-input",k(e),{language:"python",jupyterInputNodeUuid:l}),{type:"jupyter-output",version:1,format:"",source:e,outputs:[{output_type:"execute_result",execution_count:1,data:{"text/plain":P},metadata:{}}],jupyterInputNodeUuid:l,jupyterOutputNodeUuid:S}],direction:"ltr",format:"",indent:0,type:"root",version:1}}}function lt({workspace:e}){const o=b(),t=E(o.snapshot),r=e.surfaceId,n=w(T,j,{workspace:e,editorId:r}),a=v(U)[0]?.value,y=I.useMemo(()=>JSON.stringify((a?.document??A)()),[a]),x=a?.autoFocus??!0;if(t.state!=="running")return i.jsx(c,{height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"fg.muted",fontSize:1,px:4,textAlign:"center",children:i.jsx(N,{children:"The document needs a running sandbox for its code blocks. Open the Sandbox view to see what it is doing."})});const p=o.getServiceManager()??void 0;return i.jsx(c,{height:"100%",minHeight:0,children:i.jsx(O,{inheritTheme:!0,documentId:r,content:y,autoFocus:x,serviceManager:p,showToolbar:n.present,toolbarExtraItems:n.items,kernelId:p?t.kernelId:void 0,runtimeOverride:!p&&t.jupyterUrl?{baseUrl:t.jupyterUrl,token:t.jupyterToken}:void 0})})}export{lt as default};
@@ -1 +1 @@
1
- import{r,ap as ke,aq as Se,ar as je,as as we,at as ve,j as e,B as M,au as Ce,av as Ee,aw as be,ax as Re,ay as V,l as q,az as Me,aA as Te,aB as Pe,K as T,aC as De,aD as K,aE as $,aF as Ne,aG as Ue}from"../datalayer-app-main.js";import{useLexicalTools as Be}from"./lexicalHooks-Pqoe8h_O.js";import{u as He}from"./useProgressTask-UPro-gwc.js";import{L as Ae,j as Ie,T as Le,k as We,l as Fe,m as _e,D as G,n as ze,o as Je,p as Ve,q as qe,J as Ke,s as $e,F as Ge,t as Ye,u as Qe,v as Xe,w as Ze}from"./JupyterLexicalExtension-_7FM5Om8.js";import"./LexicalToolRegistry-8wJyLumb.js";import"./NotebookSkeleton-CI7ovjNW.js";import"./Avatar-9MpXENSs.js";import"./url-DuKx0yk0.js";import"./isSymbol-BLtK9CV6.js";import"./toNumber-B1wj8-wx.js";import"./VideoIcon-BjP_LDa4.js";import"./LinkIcon-DUI0jw25.js";import"./Toolbar-CGQDY041.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./ArrowUpIcon-BUCpIXDR.js";import"./SortDescIcon-CS4EzHeS.js";import"./PaintbrushIcon-CLU8RilX.js";import"./PrismCss-CcU1ChRk.js";import"./Output-BWClePP-.js";import"./index-CFP9psRB.js";import"./hoverbox-CStlKQWE.js";import"./index-DSN70XMH.js";import"./index-DyVR0igi.js";import"./color-CG7_7V2-.js";import"./isEqual-Cwjr2skl.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./index-BJhxZF_K.js";import"./RestartIcon-Ca6_HoK0.js";function Oe({content:o}){const[s]=T(),l=r.useRef(!0);return r.useEffect(()=>{if(l.current){if(l.current=!1,!o){s.update(()=>{const t=K();t.getChildrenSize()===0&&t.append($())},{tag:"history-merge"});return}try{const t=JSON.parse(o);if(t&&typeof t=="object"&&t.root){const d=s.parseEditorState(o);s.setEditorState(d,{tag:"history-merge"})}else throw new Error("Invalid Lexical editor state format")}catch{s.update(()=>{const t=K();t.clear(),t.append($())},{tag:"history-merge"})}}},[o,s]),null}function et({disabled:o}){const[s]=T();return r.useEffect(()=>{De(s,Ne).output.disabled.value=o},[s,o]),null}function tt({setIsLinkEditMode:o,extraItems:s}){const[l]=T(),[t,d]=r.useState(l);return e.jsx(Ze,{editor:l,activeEditor:t,setActiveEditor:d,setIsLinkEditMode:o,extraItems:s})}function Y({inherit:o,colorMode:s,themeConfig:l,children:t}){return o?e.jsx(e.Fragment,{children:t}):e.jsx(Te,{colorMode:s,theme:l.primerTheme,themeStyles:l.themeStyles,children:t})}function Ut({documentId:o,runtimeName:s,runtimeOverride:l,serviceManager:t,kernelId:d,themeVariant:Q,colorMode:X,content:P,onContentChange:w,onToolsReady:D,onKernelChange:v,collaboration:n,toolbarExtraItems:Z,showToolbar:O=!0,inheritTheme:N=!1,autoFocus:U=!0}){const h=!!(n?.websocketUrl&&n?.roomId),ee=n?.identity?.displayName||n?.identity?.handle||n?.identity?.userId,te=n?.identity?.color,ne=r.useMemo(()=>({user:{id:n?.identity?.userId,username:n?.identity?.userId||n?.identity?.handle||n?.identity?.displayName,name:n?.identity?.handle||n?.identity?.displayName,display_name:n?.identity?.displayName||n?.identity?.handle,initials:n?.identity?.initials,color:n?.identity?.color,avatar_url:n?.identity?.avatarUrl,handle:n?.identity?.handle}}),[n?.identity]),B=r.useRef(P),H=r.useRef(o);H.current!==o&&(H.current=o,B.current=P);const A=B.current,I=r.useRef(A??""),L=Be(o);r.useEffect(()=>{D?.(L)},[L,D]);const{runtimes:W,refetchRuntimes:C}=ke(),m=r.useMemo(()=>{const i=String(l?.baseUrl||"").trim();if(i)return{url:i,wsUrl:String(l?.wsUrl||"").trim()||void 0,token:String(l?.token||"").trim(),runtime_name:String(l?.runtimeName||"").trim()||"agent-node-proxy"};const a=String(s||"").trim();if(a)return W.find(j=>String(j?.runtime_name||"")===a)},[l,s,W]),F=!!(!l?.baseUrl&&String(s||"").trim()&&!m);r.useEffect(()=>{if(!F)return;C();const i=window.setInterval(()=>{C()},1e3);return()=>{window.clearInterval(i)}},[F,C]);const[re,g]=r.useState(null),[p,f]=r.useState(void 0);r.useEffect(()=>{let i=!1,a=null,j=null;return(async()=>{if(t){try{await t.ready;const u=d?t.kernels.connectTo({model:{id:d,name:"python"}}):await t.kernels.startNew();i||(g(t),f(new V({kernelName:u.model.name,kernelSpecName:u.model.name,kernelModel:u.model,kernelManager:t.kernels,kernelspecsManager:t.kernelspecs,sessionManager:t.sessions})))}catch(u){console.error("[agent-runtimes] The document could not reach the kernel of the sandbox it was given.",u),i||(g(null),f(void 0))}return}const b=String(m?.url||"").trim();if(!b){i||(g(null),f(void 0));return}try{const u=String(m?.token||"").trim(),pe=String(m?.wsUrl||"").trim()||b.replace(/^http/,"ws"),xe=q.ServerConnection.makeSettings({baseUrl:b,wsUrl:pe,token:u,appendToken:!0});a=new q.ServiceManager({serverSettings:xe}),j=Me(String(m?.runtime_name||""),a),await a.ready;const R=await a.kernels.startNew();if(!i){const ye=new V({kernelName:R.model.name,kernelSpecName:R.model.name,kernelModel:R.model,kernelManager:a.kernels,kernelspecsManager:a.kernelspecs,sessionManager:a.sessions});g(a),f(ye)}}catch{i||(g(null),f(void 0))}})(),()=>{i=!0,j?.(),a&&Ue(a)}},[t,d,m?.runtime_name,m?.url,m?.token]),r.useEffect(()=>(v?.(p?.connection??null),()=>{v?.(null)}),[p,v]);const E=re,_=!!((String(s||"").trim()||String(l?.baseUrl||"").trim()||t)&&!E);He(`ephemeral-document-start-${o}`,_);const oe=r.useMemo(()=>Se({name:"@datalayer/agent-runtimes/EphemeralDocument",namespace:`ephemeral-document-${o}`,theme:Xe,dependencies:[Qe,...U?[Pe]:[]],onError(i){console.error("[EphemeralDocument]",i)}}),[o,U]),ie=r.useCallback(i=>{if(!w)return;const a=JSON.stringify(i.toJSON());a!==I.current&&(I.current=a,w(a))},[w]),[x,se]=r.useState(null),[,z]=r.useState(!1),y=h?n?.roomId:void 0,[ae,le]=r.useState(),ce=y===void 0||ae===y,me=r.useCallback(i=>le(i?y:void 0),[y]),de=i=>{i!==null&&se(i)},{colorMode:ue,theme:he}=je(),k=X??ue,ge=Q??he,fe=we(),S=ve(ge),J=k==="auto"?fe:k,c=(J==="dark"?S.themeStyles.dark:S.themeStyles.light).backgroundColor??"";return e.jsx(M,{flex:1,minHeight:0,height:"100%",position:"relative",overflow:"hidden",bg:"canvas.default",children:E?e.jsx(Y,{inherit:N,colorMode:k,themeConfig:S,children:e.jsx(Ce,{colormode:J,backgroundColor:c,children:e.jsx(M,{sx:{position:"absolute",inset:0,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden",overscrollBehaviorY:"contain",padding:2,backgroundColor:c,"--bgColor-default":c,"& .editor-shell":{backgroundColor:c,borderRadius:2,display:"flex",flexDirection:"column",minHeight:0,flex:1,maxWidth:"none",width:"100%",margin:0},"& .editor-container":{backgroundColor:c,display:"flex",flexDirection:"column",minHeight:0,flex:1,width:"100%",maxWidth:"none",margin:0},"& .editor-inner":{backgroundColor:c,display:"flex",flexDirection:"column",minHeight:0,flex:1,width:"100%",maxWidth:"none"},"& .editor-scroller":{minHeight:0,flex:1,overflow:"auto",width:"100%",maxWidth:"none"},"& .editor":{minHeight:"100%",width:"100%",maxWidth:"none",margin:0},"& .editor-input":{backgroundColor:c,width:"100%",maxWidth:"none",margin:0},"& .ContentEditable__root":{width:"100%",maxWidth:"none",margin:0},'& [role="toolbar"][aria-label="Editor toolbar"]':{backgroundColor:c}},children:e.jsx(Ae,{lexicalId:o,serviceManager:E,children:e.jsx(Ee,{extension:oe,contentEditable:null,children:e.jsx(Ie,{children:e.jsx(Le,{children:e.jsxs("div",{className:"editor-shell",children:[O?e.jsx(tt,{setIsLinkEditMode:z,extraItems:Z}):null,e.jsx("div",{className:"editor-container",children:e.jsxs("div",{className:"editor-inner",children:[h&&n?e.jsx(We,{id:n.roomId,providerFactory:Fe,websocketUrl:n.websocketUrl,shouldBootstrap:!0,showCollaborators:!0,username:ee,cursorColor:te,awarenessData:ne,onInitialization:me}):null,e.jsx(_e,{}),ce?e.jsx("div",{className:"editor-scroller",children:e.jsx("div",{className:"editor",ref:de,children:e.jsx(be,{className:"editor-input","aria-label":"Ephemeral document editor"})})}):e.jsx(G,{maxWidth:"100%"}),!h&&e.jsx(Re,{onChange:ie}),e.jsx(et,{disabled:h}),!h&&e.jsx(Oe,{content:A}),e.jsx(ze,{}),e.jsx(Je,{}),e.jsx(Ve,{}),e.jsx(qe,{kernel:p}),e.jsx(Ke,{kernel:p}),x&&e.jsxs(e.Fragment,{children:[e.jsx($e,{anchorElem:x}),e.jsx(Ge,{anchorElem:x,setIsLinkEditMode:z}),e.jsx(Ye,{anchorElem:x})]})]})})]})})})})})})})}):_?e.jsx(Y,{inherit:N,colorMode:k,themeConfig:S,children:e.jsx(M,{position:"absolute",inset:0,display:"flex",flexDirection:"column",padding:2,backgroundColor:c,children:e.jsx(G,{label:"Starting the document",maxWidth:"100%"})})}):null})}export{Ut as EphemeralDocument,Ut as default};
1
+ import{r,ap as ke,aq as Se,ar as je,as as we,at as ve,j as e,B as M,au as Ce,av as Ee,aw as be,ax as Re,ay as V,l as q,az as Me,aA as Te,aB as Pe,K as T,aC as De,aD as K,aE as $,aF as Ne,aG as Ue}from"../datalayer-app-main.js";import{useLexicalTools as Be}from"./lexicalHooks-Pqoe8h_O.js";import{u as He}from"./useProgressTask-UPro-gwc.js";import{L as Ae,j as Ie,T as Le,k as We,l as Fe,m as _e,D as G,n as ze,o as Je,p as Ve,q as qe,J as Ke,s as $e,F as Ge,t as Ye,u as Qe,v as Xe,w as Ze}from"./JupyterLexicalExtension-CqDatsgf.js";import"./LexicalToolRegistry-8wJyLumb.js";import"./NotebookSkeleton-CI7ovjNW.js";import"./Avatar-9MpXENSs.js";import"./url-DuKx0yk0.js";import"./isSymbol-BLtK9CV6.js";import"./toNumber-B1wj8-wx.js";import"./VideoIcon-BjP_LDa4.js";import"./LinkIcon-DUI0jw25.js";import"./Toolbar-CGQDY041.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./ArrowUpIcon-BUCpIXDR.js";import"./SortDescIcon-CS4EzHeS.js";import"./PaintbrushIcon-CLU8RilX.js";import"./PrismCss-CcU1ChRk.js";import"./Output-no9rnFJ7.js";import"./index-CFP9psRB.js";import"./hoverbox-CStlKQWE.js";import"./index-DSN70XMH.js";import"./index-S4sn4R3i.js";import"./color-CG7_7V2-.js";import"./isEqual-g-jK7vY0.js";import"./defaultLocale-5voVPcsN.js";import"./index-DbMBnR4l.js";import"./index-BJhxZF_K.js";import"./RestartIcon-Ca6_HoK0.js";function Oe({content:o}){const[s]=T(),l=r.useRef(!0);return r.useEffect(()=>{if(l.current){if(l.current=!1,!o){s.update(()=>{const t=K();t.getChildrenSize()===0&&t.append($())},{tag:"history-merge"});return}try{const t=JSON.parse(o);if(t&&typeof t=="object"&&t.root){const d=s.parseEditorState(o);s.setEditorState(d,{tag:"history-merge"})}else throw new Error("Invalid Lexical editor state format")}catch{s.update(()=>{const t=K();t.clear(),t.append($())},{tag:"history-merge"})}}},[o,s]),null}function et({disabled:o}){const[s]=T();return r.useEffect(()=>{De(s,Ne).output.disabled.value=o},[s,o]),null}function tt({setIsLinkEditMode:o,extraItems:s}){const[l]=T(),[t,d]=r.useState(l);return e.jsx(Ze,{editor:l,activeEditor:t,setActiveEditor:d,setIsLinkEditMode:o,extraItems:s})}function Y({inherit:o,colorMode:s,themeConfig:l,children:t}){return o?e.jsx(e.Fragment,{children:t}):e.jsx(Te,{colorMode:s,theme:l.primerTheme,themeStyles:l.themeStyles,children:t})}function Ut({documentId:o,runtimeName:s,runtimeOverride:l,serviceManager:t,kernelId:d,themeVariant:Q,colorMode:X,content:P,onContentChange:w,onToolsReady:D,onKernelChange:v,collaboration:n,toolbarExtraItems:Z,showToolbar:O=!0,inheritTheme:N=!1,autoFocus:U=!0}){const h=!!(n?.websocketUrl&&n?.roomId),ee=n?.identity?.displayName||n?.identity?.handle||n?.identity?.userId,te=n?.identity?.color,ne=r.useMemo(()=>({user:{id:n?.identity?.userId,username:n?.identity?.userId||n?.identity?.handle||n?.identity?.displayName,name:n?.identity?.handle||n?.identity?.displayName,display_name:n?.identity?.displayName||n?.identity?.handle,initials:n?.identity?.initials,color:n?.identity?.color,avatar_url:n?.identity?.avatarUrl,handle:n?.identity?.handle}}),[n?.identity]),B=r.useRef(P),H=r.useRef(o);H.current!==o&&(H.current=o,B.current=P);const A=B.current,I=r.useRef(A??""),L=Be(o);r.useEffect(()=>{D?.(L)},[L,D]);const{runtimes:W,refetchRuntimes:C}=ke(),m=r.useMemo(()=>{const i=String(l?.baseUrl||"").trim();if(i)return{url:i,wsUrl:String(l?.wsUrl||"").trim()||void 0,token:String(l?.token||"").trim(),runtime_name:String(l?.runtimeName||"").trim()||"agent-node-proxy"};const a=String(s||"").trim();if(a)return W.find(j=>String(j?.runtime_name||"")===a)},[l,s,W]),F=!!(!l?.baseUrl&&String(s||"").trim()&&!m);r.useEffect(()=>{if(!F)return;C();const i=window.setInterval(()=>{C()},1e3);return()=>{window.clearInterval(i)}},[F,C]);const[re,g]=r.useState(null),[p,f]=r.useState(void 0);r.useEffect(()=>{let i=!1,a=null,j=null;return(async()=>{if(t){try{await t.ready;const u=d?t.kernels.connectTo({model:{id:d,name:"python"}}):await t.kernels.startNew();i||(g(t),f(new V({kernelName:u.model.name,kernelSpecName:u.model.name,kernelModel:u.model,kernelManager:t.kernels,kernelspecsManager:t.kernelspecs,sessionManager:t.sessions})))}catch(u){console.error("[agent-runtimes] The document could not reach the kernel of the sandbox it was given.",u),i||(g(null),f(void 0))}return}const b=String(m?.url||"").trim();if(!b){i||(g(null),f(void 0));return}try{const u=String(m?.token||"").trim(),pe=String(m?.wsUrl||"").trim()||b.replace(/^http/,"ws"),xe=q.ServerConnection.makeSettings({baseUrl:b,wsUrl:pe,token:u,appendToken:!0});a=new q.ServiceManager({serverSettings:xe}),j=Me(String(m?.runtime_name||""),a),await a.ready;const R=await a.kernels.startNew();if(!i){const ye=new V({kernelName:R.model.name,kernelSpecName:R.model.name,kernelModel:R.model,kernelManager:a.kernels,kernelspecsManager:a.kernelspecs,sessionManager:a.sessions});g(a),f(ye)}}catch{i||(g(null),f(void 0))}})(),()=>{i=!0,j?.(),a&&Ue(a)}},[t,d,m?.runtime_name,m?.url,m?.token]),r.useEffect(()=>(v?.(p?.connection??null),()=>{v?.(null)}),[p,v]);const E=re,_=!!((String(s||"").trim()||String(l?.baseUrl||"").trim()||t)&&!E);He(`ephemeral-document-start-${o}`,_);const oe=r.useMemo(()=>Se({name:"@datalayer/agent-runtimes/EphemeralDocument",namespace:`ephemeral-document-${o}`,theme:Xe,dependencies:[Qe,...U?[Pe]:[]],onError(i){console.error("[EphemeralDocument]",i)}}),[o,U]),ie=r.useCallback(i=>{if(!w)return;const a=JSON.stringify(i.toJSON());a!==I.current&&(I.current=a,w(a))},[w]),[x,se]=r.useState(null),[,z]=r.useState(!1),y=h?n?.roomId:void 0,[ae,le]=r.useState(),ce=y===void 0||ae===y,me=r.useCallback(i=>le(i?y:void 0),[y]),de=i=>{i!==null&&se(i)},{colorMode:ue,theme:he}=je(),k=X??ue,ge=Q??he,fe=we(),S=ve(ge),J=k==="auto"?fe:k,c=(J==="dark"?S.themeStyles.dark:S.themeStyles.light).backgroundColor??"";return e.jsx(M,{flex:1,minHeight:0,height:"100%",position:"relative",overflow:"hidden",bg:"canvas.default",children:E?e.jsx(Y,{inherit:N,colorMode:k,themeConfig:S,children:e.jsx(Ce,{colormode:J,backgroundColor:c,children:e.jsx(M,{sx:{position:"absolute",inset:0,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden",overscrollBehaviorY:"contain",padding:2,backgroundColor:c,"--bgColor-default":c,"& .editor-shell":{backgroundColor:c,borderRadius:2,display:"flex",flexDirection:"column",minHeight:0,flex:1,maxWidth:"none",width:"100%",margin:0},"& .editor-container":{backgroundColor:c,display:"flex",flexDirection:"column",minHeight:0,flex:1,width:"100%",maxWidth:"none",margin:0},"& .editor-inner":{backgroundColor:c,display:"flex",flexDirection:"column",minHeight:0,flex:1,width:"100%",maxWidth:"none"},"& .editor-scroller":{minHeight:0,flex:1,overflow:"auto",width:"100%",maxWidth:"none"},"& .editor":{minHeight:"100%",width:"100%",maxWidth:"none",margin:0},"& .editor-input":{backgroundColor:c,width:"100%",maxWidth:"none",margin:0},"& .ContentEditable__root":{width:"100%",maxWidth:"none",margin:0},'& [role="toolbar"][aria-label="Editor toolbar"]':{backgroundColor:c}},children:e.jsx(Ae,{lexicalId:o,serviceManager:E,children:e.jsx(Ee,{extension:oe,contentEditable:null,children:e.jsx(Ie,{children:e.jsx(Le,{children:e.jsxs("div",{className:"editor-shell",children:[O?e.jsx(tt,{setIsLinkEditMode:z,extraItems:Z}):null,e.jsx("div",{className:"editor-container",children:e.jsxs("div",{className:"editor-inner",children:[h&&n?e.jsx(We,{id:n.roomId,providerFactory:Fe,websocketUrl:n.websocketUrl,shouldBootstrap:!0,showCollaborators:!0,username:ee,cursorColor:te,awarenessData:ne,onInitialization:me}):null,e.jsx(_e,{}),ce?e.jsx("div",{className:"editor-scroller",children:e.jsx("div",{className:"editor",ref:de,children:e.jsx(be,{className:"editor-input","aria-label":"Ephemeral document editor"})})}):e.jsx(G,{maxWidth:"100%"}),!h&&e.jsx(Re,{onChange:ie}),e.jsx(et,{disabled:h}),!h&&e.jsx(Oe,{content:A}),e.jsx(ze,{}),e.jsx(Je,{}),e.jsx(Ve,{}),e.jsx(qe,{kernel:p}),e.jsx(Ke,{kernel:p}),x&&e.jsxs(e.Fragment,{children:[e.jsx($e,{anchorElem:x}),e.jsx(Ge,{anchorElem:x,setIsLinkEditMode:z}),e.jsx(Ye,{anchorElem:x})]})]})})]})})})})})})})}):_?e.jsx(Y,{inherit:N,colorMode:k,themeConfig:S,children:e.jsx(M,{position:"absolute",inset:0,display:"flex",flexDirection:"column",padding:2,backgroundColor:c,children:e.jsx(G,{label:"Starting the document",maxWidth:"100%"})})}):null})}export{Ut as EphemeralDocument,Ut as default};
@@ -1,2 +1,2 @@
1
- import{c1 as O,aW as Ee,l as x,b_ as I,aV as be,d$ as _e,e0 as Re,e1 as Ce,r as f,o as ne,ap as Me,e2 as Ue,j as v,ar as je,as as qe,at as Te,B as Q,au as Ae,az as Ne,aA as Ie,aG as Oe}from"../datalayer-app-main.js";import{u as Le}from"./useProgressTask-UPro-gwc.js";import{a as De}from"./NotebookToolbar-rtMQZWHQ.js";import{C as Je,a as $e,N as Be}from"./CellSidebarExtension-CDnzN9Cb.js";import"./RepoPushIcon-Cm8g9NuL.js";import"./Toolbar-CGQDY041.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./index-DSN70XMH.js";import"./hoverbox-CStlKQWE.js";import"./NotebookSkeleton-CI7ovjNW.js";import"./Avatar-9MpXENSs.js";import"./index-DyVR0igi.js";import"./color-CG7_7V2-.js";import"./isEqual-Cwjr2skl.js";import"./defaultLocale-5voVPcsN.js";import"./renderer-Dy4lZ1KZ.js";import"./SquareIcon-e3ygcjpv.js";const H="jupyter_server_nbmodel",Pe=new WeakSet;function We(e){return Pe.has(e)}function re(e){const n=e.model.getMetadata(H);return n?.kernelId&&n.requestId&&n.requestUrl?n:void 0}function oe(e,n){e.model.setMetadata(H,n)}function Z(e){e.model.deleteMetadata(H)}function se(e){return(typeof e=="string"?JSON.parse(e):e).reduce((r,t)=>{const o=r[r.length-1];if(t.output_type==="stream"&&o?.output_type==="stream"&&o.name===t.name){const s=Array.isArray(o.text)?o.text.join(""):o.text??"",a=Array.isArray(t.text)?t.text.join(""):t.text??"";o.text=s+a}else r.push(t);return r},[])}function j(e){return Array.isArray(e.text)?e.text.join(""):e.text??""}function Ke(e,n){return e?.output_type==="stream"&&n?.output_type==="stream"&&e.name===n.name&&j(n).startsWith(j(e))}function He(e,n){return e.length>n.length?!1:e.every((r,t)=>O.deepEqual(r,n[t])||t===e.length-1&&Ke(r,n[t]))}function Fe(e,n){const r=Math.min(e.length,n.length);for(let t=0;t<r;t+=1){const o=e[t],s=n[t];if(O.deepEqual(o,s))continue;if(!(o?.output_type==="stream"&&s?.output_type==="stream"&&o.name===s.name))return-1;const i=j(o),u=j(s);if(!u.startsWith(i)&&!i.startsWith(u)||t<r-1)return-1}return r}function Ge(e,n,r){let t=n.length;if(n.length>0&&r.length>=n.length){const o=n.length-1,s=n[o],a=r[o];if(!O.deepEqual(s,a)){const i=j(a).slice(j(s).length);i&&e.outputArea.model.add({...a,text:i})}}for(;t<r.length;)e.outputArea.model.add(r[t]),t+=1}function ae(e,n,r){const t=e.model.sharedModel,o=t.getOutputs();if(O.deepEqual(o,n))return;if(n.length===0){r?.length&&o.length&&e.outputArea.model.clear();return}if(He(n,o))return;console.debug("[jupyter-server-nbmodel] Applying pending output snapshot",{cellId:t.getId(),outputCount:n.length});const s=Fe(o,n);s>=0?Ge(e,o.slice(0,s),n):t.setOutputs(n)}const Ve=1e3;async function ze(e,n,r){let t;try{t=await n.json()}catch{return}if(t.request_id&&t.kernel_id){const a=n.headers.get("Location")??t.request_url;a&&(r.requestUrl=a),a&&r.recoverOutputs&&oe(e,{kernelId:t.kernel_id,requestId:t.request_id,requestUrl:a}),r.accepted||(r.accepted=!0,r.onAccepted?.())}if(t.outputs===void 0||!r.recoverOutputs)return;const o=se(t.outputs),s=r.serverOutputs;r.serverOutputs=o,ae(e,o,s)}async function K(e,n,r,t,o,s=100,a={}){const i=new Ee;return x.ServerConnection.makeRequest(n,r,t).then(async u=>{if(u.ok)if(u.status===202){await ze(e,u,a);let c=u.headers.get("Location")||a.requestUrl||n;c.startsWith(t.baseUrl)||(c=I.URLExt.join(t.baseUrl,c)),setTimeout(async(_,w,m,M,k,U,p)=>{try{const h=await K(_,w,m,M,k,U,p);i.resolve(h)}catch(h){i.reject(h)}},s,e,c,{method:"GET"},t,o,Math.min(Ve,s*2),a)}else i.resolve(u);else if(u.status===300){let c=u.headers.get("Location")||"";if(!c){const p=n.match(/^(.*\/api\/kernels\/[^/?]+)/);c=p?`${p[1]}/input`:""}if(!c){i.reject(new Error(`The kernel asked for an input, and where to send it could not be determined: no Location header, and the polled URL names no kernel (${n}).`));return}c.startsWith(t.baseUrl)||(c=I.URLExt.join(t.baseUrl,c));const{parent_header:_,input_request:w}=await u.json(),m=new be;m.addClass("jp-OutputArea-child"),m.addClass("jp-OutputArea-stdin-item");const M=new _e;M.addClass("jp-OutputArea-prompt"),m.addWidget(M);const k=new Re({future:Object.freeze({sendInputReply:(p,h)=>{x.ServerConnection.makeRequest(c,{method:"POST",body:JSON.stringify({input:p.value})},t).catch(E=>{console.error(`Failed to set input to ${JSON.stringify(p)}.`,E)})}}),parent_header:_,password:w.password,prompt:w.prompt,translator:o});k.addClass("jp-OutputArea-output"),m.addWidget(k);const U=k.node.getElementsByTagName("input")[0];k.value.then(p=>{m.addClass("jp-OutputArea-stdin-hiding"),e.outputArea.model.add({output_type:"stream",name:"stdin",text:p+`
1
+ import{c1 as O,aW as Ee,l as x,b_ as I,aV as be,d$ as _e,e0 as Re,e1 as Ce,r as f,o as ne,ap as Me,e2 as Ue,j as v,ar as je,as as qe,at as Te,B as Q,au as Ae,az as Ne,aA as Ie,aG as Oe}from"../datalayer-app-main.js";import{u as Le}from"./useProgressTask-UPro-gwc.js";import{a as De}from"./NotebookToolbar-rtMQZWHQ.js";import{C as Je,a as $e,N as Be}from"./CellSidebarExtension-B-73cmcQ.js";import"./RepoPushIcon-Cm8g9NuL.js";import"./Toolbar-CGQDY041.js";import"./KebabHorizontalIcon-CXDXtkuL.js";import"./index-DSN70XMH.js";import"./hoverbox-CStlKQWE.js";import"./NotebookSkeleton-CI7ovjNW.js";import"./Avatar-9MpXENSs.js";import"./index-S4sn4R3i.js";import"./color-CG7_7V2-.js";import"./isEqual-g-jK7vY0.js";import"./defaultLocale-5voVPcsN.js";import"./renderer-DKKfWkWv.js";import"./SquareIcon-e3ygcjpv.js";const H="jupyter_server_nbmodel",Pe=new WeakSet;function We(e){return Pe.has(e)}function re(e){const n=e.model.getMetadata(H);return n?.kernelId&&n.requestId&&n.requestUrl?n:void 0}function oe(e,n){e.model.setMetadata(H,n)}function Z(e){e.model.deleteMetadata(H)}function se(e){return(typeof e=="string"?JSON.parse(e):e).reduce((r,t)=>{const o=r[r.length-1];if(t.output_type==="stream"&&o?.output_type==="stream"&&o.name===t.name){const s=Array.isArray(o.text)?o.text.join(""):o.text??"",a=Array.isArray(t.text)?t.text.join(""):t.text??"";o.text=s+a}else r.push(t);return r},[])}function j(e){return Array.isArray(e.text)?e.text.join(""):e.text??""}function Ke(e,n){return e?.output_type==="stream"&&n?.output_type==="stream"&&e.name===n.name&&j(n).startsWith(j(e))}function He(e,n){return e.length>n.length?!1:e.every((r,t)=>O.deepEqual(r,n[t])||t===e.length-1&&Ke(r,n[t]))}function Fe(e,n){const r=Math.min(e.length,n.length);for(let t=0;t<r;t+=1){const o=e[t],s=n[t];if(O.deepEqual(o,s))continue;if(!(o?.output_type==="stream"&&s?.output_type==="stream"&&o.name===s.name))return-1;const i=j(o),u=j(s);if(!u.startsWith(i)&&!i.startsWith(u)||t<r-1)return-1}return r}function Ge(e,n,r){let t=n.length;if(n.length>0&&r.length>=n.length){const o=n.length-1,s=n[o],a=r[o];if(!O.deepEqual(s,a)){const i=j(a).slice(j(s).length);i&&e.outputArea.model.add({...a,text:i})}}for(;t<r.length;)e.outputArea.model.add(r[t]),t+=1}function ae(e,n,r){const t=e.model.sharedModel,o=t.getOutputs();if(O.deepEqual(o,n))return;if(n.length===0){r?.length&&o.length&&e.outputArea.model.clear();return}if(He(n,o))return;console.debug("[jupyter-server-nbmodel] Applying pending output snapshot",{cellId:t.getId(),outputCount:n.length});const s=Fe(o,n);s>=0?Ge(e,o.slice(0,s),n):t.setOutputs(n)}const Ve=1e3;async function ze(e,n,r){let t;try{t=await n.json()}catch{return}if(t.request_id&&t.kernel_id){const a=n.headers.get("Location")??t.request_url;a&&(r.requestUrl=a),a&&r.recoverOutputs&&oe(e,{kernelId:t.kernel_id,requestId:t.request_id,requestUrl:a}),r.accepted||(r.accepted=!0,r.onAccepted?.())}if(t.outputs===void 0||!r.recoverOutputs)return;const o=se(t.outputs),s=r.serverOutputs;r.serverOutputs=o,ae(e,o,s)}async function K(e,n,r,t,o,s=100,a={}){const i=new Ee;return x.ServerConnection.makeRequest(n,r,t).then(async u=>{if(u.ok)if(u.status===202){await ze(e,u,a);let c=u.headers.get("Location")||a.requestUrl||n;c.startsWith(t.baseUrl)||(c=I.URLExt.join(t.baseUrl,c)),setTimeout(async(_,w,m,M,k,U,p)=>{try{const h=await K(_,w,m,M,k,U,p);i.resolve(h)}catch(h){i.reject(h)}},s,e,c,{method:"GET"},t,o,Math.min(Ve,s*2),a)}else i.resolve(u);else if(u.status===300){let c=u.headers.get("Location")||"";if(!c){const p=n.match(/^(.*\/api\/kernels\/[^/?]+)/);c=p?`${p[1]}/input`:""}if(!c){i.reject(new Error(`The kernel asked for an input, and where to send it could not be determined: no Location header, and the polled URL names no kernel (${n}).`));return}c.startsWith(t.baseUrl)||(c=I.URLExt.join(t.baseUrl,c));const{parent_header:_,input_request:w}=await u.json(),m=new be;m.addClass("jp-OutputArea-child"),m.addClass("jp-OutputArea-stdin-item");const M=new _e;M.addClass("jp-OutputArea-prompt"),m.addWidget(M);const k=new Re({future:Object.freeze({sendInputReply:(p,h)=>{x.ServerConnection.makeRequest(c,{method:"POST",body:JSON.stringify({input:p.value})},t).catch(E=>{console.error(`Failed to set input to ${JSON.stringify(p)}.`,E)})}}),parent_header:_,password:w.password,prompt:w.prompt,translator:o});k.addClass("jp-OutputArea-output"),m.addWidget(k);const U=k.node.getElementsByTagName("input")[0];k.value.then(p=>{m.addClass("jp-OutputArea-stdin-hiding"),e.outputArea.model.add({output_type:"stream",name:"stdin",text:p+`
2
2
  `}),U.focus(),window.setTimeout(async()=>{const h=document.activeElement;m.dispose(),h&&h instanceof HTMLElement&&h.focus();try{const E=await K(e,n,r,t,o,100,a);i.resolve(E)}catch(E){i.reject(E)}},500)}),e.outputArea.layout.addWidget(m)}else i.reject(await x.ServerConnection.ResponseError.create(u))}).catch(u=>{i.reject(new x.ServerConnection.NetworkError(u))}),i.promise}async function Ye(e,n,r,t,o,s=100,a,i=!1){return K(e,n,r,t,o,s,{onAccepted:a,recoverOutputs:i})}async function Xe(e,n,r){const t=e.model.sharedModel;t.executionState="running";try{const s=await(await Ye(e,n,{method:"GET"},r,void 0,100,void 0,!0)).json(),a=se(s.outputs??"[]");return ae(e,a),t.execution_count=s.execution_count??null,t.executionState="idle",Z(e),s.status==="ok"}catch(o){if(o instanceof x.ServerConnection.ResponseError&&o.response.status===404)return Z(e),t.executionState="idle",!1;throw o}}const N=new Set;function Qe(e,n){if(e.startsWith(n.baseUrl))return e;const r=e.startsWith("http")?new URL(e).pathname:e;return I.URLExt.join(n.baseUrl,r)}function Ze(e,n){if(We(e))return!1;const r=re(e);if(!r||N.has(r.requestId)||e.isDisposed||!e.model)return!1;N.add(r.requestId);const t=Qe(r.requestUrl,n);return console.info("[agent-runtimes] Resuming a server execution",{cellId:e.model.sharedModel.getId(),requestId:r.requestId,requestUrl:t}),Xe(e,t,n).catch(o=>{if(e.isDisposed){N.delete(r.requestId);return}console.warn(`[agent-runtimes] Failed to resume the execution ${r.requestId}.`,o)}),!0}const W=new Set;async function et(e,n,r){const t=`${r.baseUrl}#${n.id}`;if(W.has(t))return 0;const o=await x.ServerConnection.makeRequest(I.URLExt.join(r.baseUrl,`api/kernels/${n.id}/execute`),{method:"GET"},r);if(o.status===404)return W.add(t),0;if(!o.ok)throw await x.ServerConnection.ResponseError.create(o).catch(()=>new Error(`Invalid response: ${o.status} ${o.statusText}`.trim()));W.add(t);const s=await o.json();let a=0;for(const i of s.requests??[]){if(!i.cell_id||N.has(i.request_id))continue;const u=e.find(c=>c.model?.sharedModel.getId()===i.cell_id);!u||u.isDisposed||re(u)||(oe(u,{kernelId:i.kernel_id,requestId:i.request_id,requestUrl:i.request_url}),a+=1)}return a}async function tt(e){if(e.isDisposed)return 0;const n=e.sessionContext?.session?.kernel,r=n?.serverSettings;if(!n||!r)return 0;const t=e.content.widgets.filter(s=>s instanceof Ce);if(t.length===0)return 0;try{await et(t,n,r)}catch(s){console.warn("[agent-runtimes] Failed to discover the active executions of the kernel.",s)}let o=0;for(const s of t)Ze(s,r)&&(o+=1);return o}const ee=1e3,nt=3e4;function rt(e,n){f.useEffect(()=>{if(!e||!n)return;let r=0;const t=()=>{const a=ne.getState().selectNotebook(e)?.adapter?.panel;!a||a.isDisposed||tt(a)};t();const o=window.setInterval(()=>{if(r+=ee,r>=nt){window.clearInterval(o);return}t()},ee);return()=>{window.clearInterval(o)}},[e,n])}const te={cells:[{cell_type:"code",source:[""],metadata:{},outputs:[],execution_count:null}],metadata:{kernelspec:{display_name:"Python 3",language:"python",name:"python3"},language_info:{name:"python"}},nbformat:4,nbformat_minor:5};function ot({inherit:e,colorMode:n,themeConfig:r,children:t}){return e?v.jsx(v.Fragment,{children:t}):v.jsx(Ie,{colorMode:n,theme:r.primerTheme,themeStyles:r.themeStyles,children:t})}function Et({notebookId:e,runtimeName:n,runtimeOverride:r,serviceManager:t,inheritTheme:o=!1,kernelId:s,cellSidebarMargin:a=120,nbformat:i,onNbformatChange:u,toolbarComponent:c,toolbarExtraItems:_,showToolbar:w=!0,showSaveItem:m=!1,themeVariant:M,colorMode:k,collaborationProvider:U}){const p=f.useRef(i??te),h=f.useRef(e);h.current!==e&&(h.current=e,p.current=i??te);const E=p.current,F=f.useRef(JSON.stringify(E)),{runtimes:G,refetchRuntimes:L}=Me(void 0,{enabled:!!String(n||"").trim()&&!t&&!String(r?.baseUrl||"").trim()}),V=f.useMemo(()=>{const l=String(n||"").trim();if(l)return G.find(d=>String(d?.runtime_name||"")===l)},[n,G]),S=f.useMemo(()=>{const l=String(r?.baseUrl||"").trim();return l?{url:l,wsUrl:String(r?.wsUrl||"").trim()||void 0,token:String(r?.token||"").trim(),runtime_name:String(r?.runtimeName||"").trim()||"agent-node-proxy"}:V},[r,V]),z=!!(!r?.baseUrl&&String(n||"").trim()&&!S);f.useEffect(()=>{if(!z)return;L();const l=window.setInterval(()=>{L()},1e3);return()=>{window.clearInterval(l)}},[z,L]);const[ie,D]=f.useState(null),[ue,J]=f.useState(void 0),[le,$]=f.useState(!1);f.useEffect(()=>{let l=!1,d=null,b=null;const y=async()=>{const R=String(S?.url||"").trim();if(!R){l||(D(null),J(void 0),$(!1));return}try{const A=String(S?.token||"").trim(),we=String(S?.wsUrl||"").trim()||R.replace(/^http/,"ws"),ke=x.ServerConnection.makeSettings({baseUrl:R,wsUrl:we,token:A,appendToken:!0}),C=new x.ServiceManager({serverSettings:ke});if(d=C,b=Ne(String(S?.runtime_name||""),d),l){g(C);return}await C.ready,await C.kernels.refreshRunning();const X=[...C.kernels.running()][0];if(l){g(C);return}D(C),J(X?.id),$(!X)}catch(A){d&&(g(d),d=null),l||(console.warn(`[agent-runtimes] Could not reach the sandbox at ${R}.`,A),D(null),J(void 0),$(!1))}},g=R=>{b?.(),b=null,Oe(R)};return y(),()=>{l=!0,d?(g(d),d=null):(b?.(),b=null)}},[S?.runtime_name,S?.url,S?.token,S?.wsUrl]);const q=t??ie,ce=Ue(),de=s??ue,fe=t?!s:le,me=f.useMemo(()=>{if(!w)return;const l=c||De,d=m?void 0:["notebook-save","notebook-divider-file"];return!_?.length&&!d?l:function(y){return v.jsx(l,{...y,extraItems:_,hiddenItems:d})}},[w,m,c,_]),pe=!!((String(n||"").trim()||String(r?.baseUrl||"").trim())&&!q);Le(`ephemeral-notebook-start-${e}`,pe),rt(e,q??void 0),f.useEffect(()=>{if(U)return;const l=()=>{const g=ne.getState().selectNotebook(e)?.adapter;return(g?.notebook?.model??g?.panel?.content?.model??null)?.toJSON?.()??null},d=()=>{const y=l();if(!y||!Array.isArray(y.cells))return;const g=JSON.stringify(y);g!==F.current&&(F.current=g,u?.(y))},b=window.setInterval(d,500);return()=>{window.clearInterval(b),d()}},[q,e,u]);const{colorMode:he,theme:ge}=je(),B=k??he,Se=M??ge,ye=qe(),P=Te(Se),Y=B==="auto"?ye:B,T=(Y==="dark"?P.themeStyles.dark:P.themeStyles.light).backgroundColor??"",ve=f.useMemo(()=>[new Je({factory:$e})],[]),xe=f.useMemo(()=>`.datalayer/${e}.ipynb`,[e]);return v.jsx(Q,{flex:1,minHeight:0,height:"100%",position:"relative",overflow:"hidden",bg:"canvas.default",children:q&&ce?v.jsx(ot,{inherit:o,colorMode:B,themeConfig:P,children:v.jsx(Ae,{colormode:Y,backgroundColor:T,children:v.jsx(Q,{sx:{position:"absolute",inset:0,display:"flex",flexDirection:"column",overflow:"hidden",overscrollBehaviorY:"contain",overflowAnchor:"none",padding:2,backgroundColor:T,"& #dla-Jupyter-Notebook":{display:"flex",flexDirection:"column"},...w?{"& #dla-Jupyter-Notebook > :first-of-type":{position:"sticky",top:0,zIndex:2,flex:"0 0 auto",backgroundColor:T}}:{"& .datalayer-NotebookPanel-header":{display:"none",minHeight:0}},"& #dla-Jupyter-Notebook > .dla-Box-Notebook":{flex:"1 1 auto",minHeight:0},'& [role="toolbar"][aria-label="Notebook toolbar"]':{backgroundColor:T}},children:v.jsx(Be,{nbformat:E,id:e,path:xe,serviceManager:q,startDefaultKernel:fe,kernelId:de,height:"100%",cellSidebarMargin:a,extensions:ve,Toolbar:me,collaborationProvider:U})})})}):null})}export{Et as EphemeralNotebook,Et as default};