@vellumai/web 0.10.11-dev.202607222129.31c06e5 → 0.10.11-dev.202607222325.35fc367

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 (103) hide show
  1. package/dist/assets/{account-page-CzZuoekz.js → account-page-GZyBTNUh.js} +1 -1
  2. package/dist/assets/{acp-run-detail-panel-DssICbn8.js → acp-run-detail-panel-rUaOd-hf.js} +1 -1
  3. package/dist/assets/{activity-steps-panel-CeLVlAeY.js → activity-steps-panel-5VIG5OqK.js} +1 -1
  4. package/dist/assets/{add-credits-modal-BFTdUmH6.js → add-credits-modal-CzzFGQWP.js} +1 -1
  5. package/dist/assets/{ai-page-ukSnDSJr.js → ai-page-CM4iIEf6.js} +1 -1
  6. package/dist/assets/api-Cg02JjXP.js +1 -0
  7. package/dist/assets/{api-CxAtNZ-r.js → api-Jhp24FhR.js} +1 -1
  8. package/dist/assets/{api-key-screen-DD_TJKco.js → api-key-screen-XB0o3VGu.js} +1 -1
  9. package/dist/assets/{assistant-status-panel-gpwr0glD.js → assistant-status-panel-3QLq7XTz.js} +1 -1
  10. package/dist/assets/{auth-store-Lzg3kiaw.js → auth-store-quPkF_4z.js} +1 -1
  11. package/dist/assets/{background-task-detail-panel-BCXH3MXV.js → background-task-detail-panel-CtnQ4o8Y.js} +1 -1
  12. package/dist/assets/{billing-page-BZwgqWS1.js → billing-page-BuH7Flj1.js} +1 -1
  13. package/dist/assets/{bookmarks-page-B-PbfvFN.js → bookmarks-page-BPYxHwvq.js} +1 -1
  14. package/dist/assets/{build-state-Bo2Ut5Js.js → build-state-rDsVeVLA.js} +1 -1
  15. package/dist/assets/{channels-page-route-DEwl411M.js → channels-page-route-CPi_Fp88.js} +1 -1
  16. package/dist/assets/chat-AyO7_TjY.js +1 -0
  17. package/dist/assets/{command-palette-DNujIsf0.js → command-palette-DSjWseMw.js} +1 -1
  18. package/dist/assets/{command-palette-window-page-mWNMMe4I.js → command-palette-window-page-Dj8qEe_8.js} +1 -1
  19. package/dist/assets/{community-page-DEcDCjsQ.js → community-page-C5z-9PeA.js} +1 -1
  20. package/dist/assets/{connect-page-DuBhY8KD.js → connect-page-CovLqmQK.js} +1 -1
  21. package/dist/assets/{contacts-page-route-BS2duMoh.js → contacts-page-route-C0blpiOy.js} +1 -1
  22. package/dist/assets/{credentials-page-DDgYexAA.js → credentials-page-BYLMj-Vi.js} +1 -1
  23. package/dist/assets/{debug-page-B_us491I.js → debug-page-BXDNUKAc.js} +1 -1
  24. package/dist/assets/{deploy-dialogs-CB5PSyxZ.js → deploy-dialogs-SI8FNwW3.js} +1 -1
  25. package/dist/assets/{detail-panel-stop-button-26G26Tqs.js → detail-panel-stop-button-DYV4AyIE.js} +1 -1
  26. package/dist/assets/{developer-page-Dqug_k0U.js → developer-page-4qC6bfMI.js} +1 -1
  27. package/dist/assets/{dictation-overlay-page-Rz3bqW3f.js → dictation-overlay-page-w-7_v7vX.js} +1 -1
  28. package/dist/assets/{document-viewer-page-DmHPShuz.js → document-viewer-page-D5v9jurM.js} +1 -1
  29. package/dist/assets/{emails-page-s9TxP6jP.js → emails-page-CrxG8ZDa.js} +1 -1
  30. package/dist/assets/{general-page-DsrG3cM2.js → general-page-ZuhMFVx3.js} +1 -1
  31. package/dist/assets/{hatching-screen-CuzULcU_.js → hatching-screen-CeQF1pRn.js} +1 -1
  32. package/dist/assets/{home-page-route-Cc3ksf3X.js → home-page-route-BSswnfjb.js} +1 -1
  33. package/dist/assets/{hosting-screen-DufVMlwF.js → hosting-screen-CoPWPYM0.js} +1 -1
  34. package/dist/assets/{identity-page-route-CUrEsO_0.js → identity-page-route-5CTzy7R7.js} +1 -1
  35. package/dist/assets/{index-C7ix_asE.js → index-Ck1SrvnM.js} +15 -15
  36. package/dist/assets/index-Co1WDHMj.css +2 -0
  37. package/dist/assets/{inspect-page-BUAbv6xj.js → inspect-page-CbL5eNZP.js} +1 -1
  38. package/dist/assets/{integrations-page-9JcrAORp.js → integrations-page-hX8eENSt.js} +1 -1
  39. package/dist/assets/{intelligence-layout-DJjUScCy.js → intelligence-layout-Che-CPPC.js} +1 -1
  40. package/dist/assets/{library-detail-page-BCAZmbR6.js → library-detail-page-CHLvGvqm.js} +1 -1
  41. package/dist/assets/{library-page-CiTHHvZ5.js → library-page-CyX22JKU.js} +1 -1
  42. package/dist/assets/{login-flow-DYrO-od6.js → login-flow-DbD8dpQO.js} +1 -1
  43. package/dist/assets/{login-page-DAFzFbRp.js → login-page-Bk7ZkXmL.js} +1 -1
  44. package/dist/assets/{logout-page-CsPkQ-4I.js → logout-page-b5UKcm6I.js} +1 -1
  45. package/dist/assets/{logs-layout-DBJaWlOK.js → logs-layout-DqmiOqxX.js} +1 -1
  46. package/dist/assets/{memory-page-route-CpPfBU9j.js → memory-page-route-z1B9mzGX.js} +1 -1
  47. package/dist/assets/{memory-router-playground-page-DfGhXcZW.js → memory-router-playground-page-BkNOYakH.js} +1 -1
  48. package/dist/assets/{mobile-sidebar-drawer-CVT3O8os.js → mobile-sidebar-drawer-CZXirrGr.js} +1 -1
  49. package/dist/assets/{notifications-page-DcHyVoSk.js → notifications-page-ChodICPa.js} +1 -1
  50. package/dist/assets/{oauth-complete-page-DjKBNbdN.js → oauth-complete-page-DAbVLddu.js} +1 -1
  51. package/dist/assets/{oauth-popup-complete-page-2KKVC5zM.js → oauth-popup-complete-page-DgH2GYyB.js} +1 -1
  52. package/dist/assets/{pairing-page-7NMcVDJj.js → pairing-page-B7TF3mjM.js} +1 -1
  53. package/dist/assets/{personality-page-CwaMBzXV.js → personality-page-BfD3xcZs.js} +1 -1
  54. package/dist/assets/{plans-page-Cre3Gpys.js → plans-page-BkxM9GzA.js} +1 -1
  55. package/dist/assets/{platform-loopback-page-CIcVs3UP.js → platform-loopback-page-CdL_j5rg.js} +1 -1
  56. package/dist/assets/{plugin-detail-page-R7HOcOd1.js → plugin-detail-page-DD3KG_Ob.js} +1 -1
  57. package/dist/assets/{privacy-page-CTQpOjs-.js → privacy-page-BOhDW3Tr.js} +1 -1
  58. package/dist/assets/{privacy-screen-DgHmBdN-.js → privacy-screen-DsKCxStT.js} +1 -1
  59. package/dist/assets/{provider-callback-page-kcYxB4WF.js → provider-callback-page-Dy-XHz3J.js} +1 -1
  60. package/dist/assets/{provider-signup-page-D9aI4WFt.js → provider-signup-page-Cw_EuUcw.js} +1 -1
  61. package/dist/assets/{quick-input-page-D2Bqa3St.js → quick-input-page-DgKCQboP.js} +1 -1
  62. package/dist/assets/{research-mock-page-C6zrZtBI.js → research-mock-page-DuWAP5WQ.js} +1 -1
  63. package/dist/assets/{research-onboarding-route-AYDHEowO.js → research-onboarding-route-DqSzV4R1.js} +1 -1
  64. package/dist/assets/{review-terms-screen-BSa9jNvG.js → review-terms-screen-C4VOK9eY.js} +1 -1
  65. package/dist/assets/{risk-C-ZyBTAb.js → risk-BbqTlLoT.js} +1 -1
  66. package/dist/assets/{schedules-page-gqD1Tbf8.js → schedules-page-CKnLdKQE.js} +1 -1
  67. package/dist/assets/{select-assistant-screen-CFvCmydl.js → select-assistant-screen-CKk_y6Wj.js} +1 -1
  68. package/dist/assets/{settings-layout-XYxLMpW0.js → settings-layout-Cntp7oUe.js} +1 -1
  69. package/dist/assets/{share-feedback-modal-Bjh3dK-n.js → share-feedback-modal-vBcYayA4.js} +1 -1
  70. package/dist/assets/{sidebar-tree-CDqUGPSK.js → sidebar-tree-X01ptIng.js} +1 -1
  71. package/dist/assets/{signup-page-DgYRwrxX.js → signup-page-CkcipBzC.js} +1 -1
  72. package/dist/assets/{site-favicon-DHBOONR1.js → site-favicon-qbssi9h0.js} +1 -1
  73. package/dist/assets/{skill-detail-page-Dnh8ep5N.js → skill-detail-page-sf-eYZtq.js} +1 -1
  74. package/dist/assets/{skill-detail-panel-DIn7RLCC.js → skill-detail-panel-bqurW7AD.js} +1 -1
  75. package/dist/assets/{start-screen-CJb-0lgs.js → start-screen-BGwp_xBH.js} +1 -1
  76. package/dist/assets/{subagent-detail-panel-V44LtNl6.js → subagent-detail-panel-BzMMipi4.js} +1 -1
  77. package/dist/assets/{subagent-store-CPEG25fH.js → subagent-store-ZCAfa32m.js} +1 -1
  78. package/dist/assets/{superpowers-page-X0kSM_TF.js → superpowers-page-D3EekoAk.js} +1 -1
  79. package/dist/assets/{system-events-page-Duos2ubJ.js → system-events-page-tOTktdXx.js} +1 -1
  80. package/dist/assets/{theme-stage-page-BU-Gj4c2.js → theme-stage-page-CkPg3HLk.js} +1 -1
  81. package/dist/assets/{tier-upgrade-resize-modal-CbRtJhAf.js → tier-upgrade-resize-modal-BWDhujpc.js} +1 -1
  82. package/dist/assets/{tiptap-document-editor-D1aVS6nK.js → tiptap-document-editor-4dcMTA_h.js} +1 -1
  83. package/dist/assets/{tool-detail-panel-C-O4opDs.js → tool-detail-panel-hH1I4AMa.js} +1 -1
  84. package/dist/assets/{upgrade-cancel-page-UaVSwAVr.js → upgrade-cancel-page-B_bh0PIP.js} +1 -1
  85. package/dist/assets/{upgrade-success-page-CBs03tVb.js → upgrade-success-page-DmQqjklp.js} +1 -1
  86. package/dist/assets/{use-assistant-identity-details-CKel0e_r.js → use-assistant-identity-details-DRCMhHXZ.js} +1 -1
  87. package/dist/assets/{use-edge-swipe-back-Dv1ShCT7.js → use-edge-swipe-back-2Yjfb81V.js} +1 -1
  88. package/dist/assets/{use-invite-link-dialog-BfVPh6F5.js → use-invite-link-dialog-DNAxfIHK.js} +1 -1
  89. package/dist/assets/use-is-org-ready-DP2_SBJo.js +1 -0
  90. package/dist/assets/{use-onboarding-login-DMLLDHRX.js → use-onboarding-login-6LWa5XdQ.js} +1 -1
  91. package/dist/assets/{use-skill-actions-DPXX5qWL.js → use-skill-actions-FLVJkX9f.js} +1 -1
  92. package/dist/assets/{use-skill-detail-files-CuoCiyOy.js → use-skill-detail-files-DHBiaT9K.js} +1 -1
  93. package/dist/assets/{voice-page-DdjI8A76.js → voice-page-Cex0WiYJ.js} +1 -1
  94. package/dist/assets/{weather-forecast-display-0GtxW555.js → weather-forecast-display-BoH2wKfc.js} +1 -1
  95. package/dist/assets/{welcome-screen-DZhajJW3.js → welcome-screen-BE8PhNfU.js} +1 -1
  96. package/dist/assets/{workflow-detail-panel-Cw0kRLTK.js → workflow-detail-panel-CO0C-Lqo.js} +1 -1
  97. package/dist/assets/{workspace-page-7j1DZUlp.js → workspace-page-eR-YtX-j.js} +1 -1
  98. package/dist/index.html +13 -13
  99. package/package.json +1 -1
  100. package/dist/assets/api-DqHVnn1b.js +0 -1
  101. package/dist/assets/chat-CNlH625o.js +0 -1
  102. package/dist/assets/index-BRSW3eiH.css +0 -2
  103. package/dist/assets/use-is-org-ready-Ba5vxuqM.js +0 -1
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import"./button-CW7wKp2r.js";import{n,u as r}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{u as a}from"./routes-D4ff4ONd.js";import"./conversation-store-CnRrUeSu.js";import"./index-C7ix_asE.js";var o=e(t(),1),s=i(),c=[{claim:`Software engineer based in Austin, TX`,confidence:`confident`,sources:[`https://github.com/example-dev`]},{claim:`Product engineer at an early-stage AI startup`,confidence:`confident`,sources:[`https://example.com/team`]},{claim:`Maintains an open-source CLI tool for local LLM evaluation and tooling`,confidence:`confident`,sources:[`https://github.com/example-dev`,`https://example.com/project`]},{claim:`Primarily writes TypeScript and Go`,confidence:`confident`,sources:[`https://github.com/example-dev`]},{claim:`Came up through a coding bootcamp rather than a CS degree`,confidence:`maybe`,sources:[]}];function l(){r();let[e,t]=(0,o.useState)(`results`),[i,l]=(0,o.useState)(()=>new Map);return c.map((e,t)=>({fact:e,index:t})),(0,s.jsx)(n,{to:a.assistant,replace:!0})}export{l as ResearchMockPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import"./button-CW7wKp2r.js";import{n,u as r}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as i}from"./jsx-runtime-CVSDxk6A.js";import{u as a}from"./routes-D4ff4ONd.js";import"./conversation-store-CnRrUeSu.js";import"./index-Ck1SrvnM.js";var o=e(t(),1),s=i(),c=[{claim:`Software engineer based in Austin, TX`,confidence:`confident`,sources:[`https://github.com/example-dev`]},{claim:`Product engineer at an early-stage AI startup`,confidence:`confident`,sources:[`https://example.com/team`]},{claim:`Maintains an open-source CLI tool for local LLM evaluation and tooling`,confidence:`confident`,sources:[`https://github.com/example-dev`,`https://example.com/project`]},{claim:`Primarily writes TypeScript and Go`,confidence:`confident`,sources:[`https://github.com/example-dev`]},{claim:`Came up through a coding bootcamp rather than a CS degree`,confidence:`maybe`,sources:[]}];function l(){r();let[e,t]=(0,o.useState)(`results`),[i,l]=(0,o.useState)(()=>new Map);return c.map((e,t)=>({fact:e,index:t})),(0,s.jsx)(n,{to:a.assistant,replace:!0})}export{l as ResearchMockPage};
@@ -1,4 +1,4 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-anSemq95.js";import{t as n}from"./react-DJZBPgpf.js";import{P as r,t as i}from"./button-CW7wKp2r.js";import{m as a,u as o}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./useQuery-B45lW1Kk.js";import{t as l}from"./jsx-runtime-CVSDxk6A.js";import{t as u}from"./arrow-left-C2re-gYj.js";import{t as d}from"./loader-circle-Ck8fq3yv.js";import{t as f}from"./pencil-CsnkG5VN.js";import{t as p}from"./plus-DZZypDUF.js";import{t as m}from"./x-CswtfvgS.js";import{t as h}from"./tag-CJyI1Y2J.js";import{t as g}from"./input-D3MhHg0d.js";import{i as _,r as v,t as y}from"./dist-kYT5dDAe.js";import{n as b}from"./toast-zHo1wvF9.js";import{n as x,t as S}from"./create-selectors-8NePGNlX.js";import{ct as C,f as w,o as T,y as E}from"./local-mode-Dydd46cS.js";import{Gn as D,Or as O,Tr as k,V as A,Wn as j,bn as M,tt as N,xn as P}from"./sdk.gen-BR-xXIZm.js";import{r as ee}from"./api-errors-CoE1wFl2.js";import{A as F,B as te,L as I,R as ne,n as re,z as ie}from"./auth-store-Lzg3kiaw.js";import{a as L,o as ae,r as oe}from"./api-CxAtNZ-r.js";import{u as se}from"./routes-D4ff4ONd.js";import{n as ce}from"./platform-detection-BBQ3eUv5.js";import{a as le}from"./feature-flag-catalog-W5kYlNH2.js";import{o as ue,s as de}from"./prechat-mDxOfWth.js";import{t as fe}from"./browser-timezone-2SnmKDjM.js";import{c as pe}from"./conversation-list-fetchers-DKtnmlFF.js";import{i as me,n as he,r as ge,t as _e}from"./research-onboarding-persistence-C4LT0Ekr.js";import{t as R}from"./proxy-DoUA9mK6.js";import{t as ve}from"./AnimatePresence-C42g9zWi.js";import{t as z}from"./use-reduced-motion-DpK6cQN-.js";import{t as B}from"./animated-avatar-6bSYRHZr.js";import{An as ye,Br as be,Dn as xe,Fn as Se,Jn as V,Ks as H,Ln as Ce,Lo as we,Oa as Te,On as Ee,Os as De,Ra as Oe,Tn as U,Zo as ke,_n as W,_t as Ae,gn as je,hn as G,jn as Me,ka as Ne,kn as K,on as Pe,vn as Fe,vt as q,wn as J}from"./index-C7ix_asE.js";import{c as Ie,i as Le,l as Re,n as ze,r as Be,s as Ve,t as He}from"./latest-assistant-text-CQ8YGbvQ.js";import{n as Ue,t as We}from"./onboarding-step-layout-CEt9JOpN.js";import{n as Ge}from"./plugin-attribution-meUNq3wV.js";var Y=e(n(),1),Ke=`grounded`,qe=12;function Je(e,t){let n=e.slice(0,qe).map(e=>`- ${e.name} — ${e.description}`).join(`
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-anSemq95.js";import{t as n}from"./react-DJZBPgpf.js";import{P as r,t as i}from"./button-CW7wKp2r.js";import{m as a,u as o}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./useQuery-B45lW1Kk.js";import{t as l}from"./jsx-runtime-CVSDxk6A.js";import{t as u}from"./arrow-left-C2re-gYj.js";import{t as d}from"./loader-circle-Ck8fq3yv.js";import{t as f}from"./pencil-CsnkG5VN.js";import{t as p}from"./plus-DZZypDUF.js";import{t as m}from"./x-CswtfvgS.js";import{t as h}from"./tag-CJyI1Y2J.js";import{t as g}from"./input-D3MhHg0d.js";import{i as _,r as v,t as y}from"./dist-kYT5dDAe.js";import{n as b}from"./toast-zHo1wvF9.js";import{n as x,t as S}from"./create-selectors-8NePGNlX.js";import{ct as C,f as w,o as T,y as E}from"./local-mode-Dydd46cS.js";import{Gn as D,Or as O,Tr as k,V as A,Wn as j,bn as M,tt as N,xn as P}from"./sdk.gen-BR-xXIZm.js";import{r as ee}from"./api-errors-CoE1wFl2.js";import{A as F,B as te,L as I,R as ne,n as re,z as ie}from"./auth-store-quPkF_4z.js";import{a as L,o as ae,r as oe}from"./api-Jhp24FhR.js";import{u as se}from"./routes-D4ff4ONd.js";import{n as ce}from"./platform-detection-BBQ3eUv5.js";import{a as le}from"./feature-flag-catalog-W5kYlNH2.js";import{o as ue,s as de}from"./prechat-mDxOfWth.js";import{t as fe}from"./browser-timezone-2SnmKDjM.js";import{c as pe}from"./conversation-list-fetchers-DKtnmlFF.js";import{i as me,n as he,r as ge,t as _e}from"./research-onboarding-persistence-C4LT0Ekr.js";import{t as R}from"./proxy-DoUA9mK6.js";import{t as ve}from"./AnimatePresence-C42g9zWi.js";import{t as z}from"./use-reduced-motion-DpK6cQN-.js";import{t as B}from"./animated-avatar-6bSYRHZr.js";import{An as ye,Br as be,Dn as xe,Fn as Se,Jn as V,Ks as H,Ln as Ce,Lo as we,Oa as Te,On as Ee,Os as De,Ra as Oe,Tn as U,Zo as ke,_n as W,_t as Ae,gn as je,hn as G,jn as Me,ka as Ne,kn as K,on as Pe,vn as Fe,vt as q,wn as J}from"./index-Ck1SrvnM.js";import{c as Ie,i as Le,l as Re,n as ze,r as Be,s as Ve,t as He}from"./latest-assistant-text-CQ8YGbvQ.js";import{n as Ue,t as We}from"./onboarding-step-layout-CEt9JOpN.js";import{n as Ge}from"./plugin-attribution-meUNq3wV.js";var Y=e(n(),1),Ke=`grounded`,qe=12;function Je(e,t){let n=e.slice(0,qe).map(e=>`- ${e.name} — ${e.description}`).join(`
2
2
  `);return n?`
3
3
  Capabilities you can offer me — specialized skillsets you can invoke on my behalf, not generic chat:
4
4
  ${n}
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-CW7wKp2r.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./shield-check-C3mmA0Pk.js";import{t as s}from"./is-electron-y5bNUVyG.js";import{f as c,i as l,n as u}from"./auth-store-Lzg3kiaw.js";import{_ as d}from"./native-biometric-DG8Pfu_V.js";import{u as f}from"./routes-D4ff4ONd.js";import{c as p,d as m,f as h,l as g,p as _,u as v}from"./prefs-CzauL-hH.js";import{Ba as y,hn as b}from"./index-C7ix_asE.js";import{n as x,t as S}from"./consent-controls-HYKKj225.js";var C=e(t(),1),w={},T={"2026-06-22":[`Introduces Together AI as a new managed model provider`]};function E(e){return w[e]??[]}function D(e){return T[e]??[]}var O=a();function k(){let e=i(),[t]=r(),a=u.use.user()?.id??null,w=u.use.logout(),T=s(),k=l(),[A,j]=_(),[M,N]=v(),[P,F]=m(),[I,L]=h(),[R]=p(),[z]=g(),B=P??!0,V=I??!0,[H]=(0,C.useState)(()=>!A),[U]=(0,C.useState)(()=>!M),[W]=(0,C.useState)(()=>!R),[G]=(0,C.useState)(()=>!z),K=!H&&!U&&!W&&!G,q=H||K,J=U||K,Y=W||K,X=G||K,Z=!K&&!H&&!U,Q=K?`Terms & privacy`:Z?`Review your privacy preferences`:`Updated terms`,$=K?`Review your terms and privacy preferences anytime.`:Z?`Confirm your privacy preferences to continue.`:`We've updated our terms. Please review and accept to continue.`,ee=(0,C.useCallback)(()=>{c({userId:a,tos:A,privacy:M,shareAnalytics:Y?B:null,shareDiagnostics:X?V:null,hasPlatformSession:k}),e(d(t.get(`returnTo`),f.assistant),{replace:!0})},[M,k,e,t,B,V,Y,X,A,a]),te=(0,C.useCallback)(async()=>{await w(),y(f.account.login)},[w]),ne=q&&!A||J&&!M;return(0,O.jsx)(b,{showCreatureFooter:!1,children:(0,O.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${T?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`px-6 py-16`} text-[var(--content-default)]`,children:[(0,O.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full border border-[var(--border-subtle)] bg-[var(--surface-lift)]`,style:{animation:`fadeInUp 0.5s ease-out 0.05s both`},children:(0,O.jsx)(o,{className:`h-6 w-6 text-[var(--content-secondary)]`,strokeWidth:1.75})}),(0,O.jsx)(`h1`,{className:`mt-5 ${T?`text-title-large`:`text-3xl font-semibold tracking-tight`}`,style:{animation:`fadeInUp 0.5s ease-out 0.12s both`},children:Q}),(0,O.jsx)(`p`,{className:`text-center text-body-medium-lighter text-[var(--content-tertiary)] ${T?`mt-3`:`mt-3.5`}`,style:{animation:`fadeInUp 0.5s ease-out 0.2s both`},children:$}),(Y||X)&&(0,O.jsx)(x,{electron:T,showAnalytics:Y,showDiagnostics:X,shareAnalytics:B,shareDiagnostics:V,onShareAnalyticsChange:F,onShareDiagnosticsChange:L,className:`mt-9 w-full`,style:{animation:`fadeInUp 0.5s ease-out 0.28s both`}}),(J||q)&&(0,O.jsx)(S,{electron:T,showPrivacy:J,showTos:q,privacyConsent:M,tosAccepted:A,onPrivacyChange:N,onTosChange:j,privacyNotes:J?D(`2026-06-22`):[],tosNotes:q?E(`2026-06-08`):[],className:`mt-6 w-full`,style:{animation:`fadeInUp 0.5s ease-out 0.36s both`}}),(0,O.jsxs)(`div`,{className:`mt-9 flex w-full flex-col ${T?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.44s both`},children:[(0,O.jsx)(n,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:ne,onClick:ee,className:T?void 0:`h-11 text-base`,children:`Continue`}),(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,onClick:te,className:T?void 0:`h-11 text-base`,children:`Log out`})]})]})})}export{k as ReviewTermsScreen};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-CW7wKp2r.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./shield-check-C3mmA0Pk.js";import{t as s}from"./is-electron-y5bNUVyG.js";import{f as c,i as l,n as u}from"./auth-store-quPkF_4z.js";import{_ as d}from"./native-biometric-DG8Pfu_V.js";import{u as f}from"./routes-D4ff4ONd.js";import{c as p,d as m,f as h,l as g,p as _,u as v}from"./prefs-CzauL-hH.js";import{Ba as y,hn as b}from"./index-Ck1SrvnM.js";import{n as x,t as S}from"./consent-controls-HYKKj225.js";var C=e(t(),1),w={},T={"2026-06-22":[`Introduces Together AI as a new managed model provider`]};function E(e){return w[e]??[]}function D(e){return T[e]??[]}var O=a();function k(){let e=i(),[t]=r(),a=u.use.user()?.id??null,w=u.use.logout(),T=s(),k=l(),[A,j]=_(),[M,N]=v(),[P,F]=m(),[I,L]=h(),[R]=p(),[z]=g(),B=P??!0,V=I??!0,[H]=(0,C.useState)(()=>!A),[U]=(0,C.useState)(()=>!M),[W]=(0,C.useState)(()=>!R),[G]=(0,C.useState)(()=>!z),K=!H&&!U&&!W&&!G,q=H||K,J=U||K,Y=W||K,X=G||K,Z=!K&&!H&&!U,Q=K?`Terms & privacy`:Z?`Review your privacy preferences`:`Updated terms`,$=K?`Review your terms and privacy preferences anytime.`:Z?`Confirm your privacy preferences to continue.`:`We've updated our terms. Please review and accept to continue.`,ee=(0,C.useCallback)(()=>{c({userId:a,tos:A,privacy:M,shareAnalytics:Y?B:null,shareDiagnostics:X?V:null,hasPlatformSession:k}),e(d(t.get(`returnTo`),f.assistant),{replace:!0})},[M,k,e,t,B,V,Y,X,A,a]),te=(0,C.useCallback)(async()=>{await w(),y(f.account.login)},[w]),ne=q&&!A||J&&!M;return(0,O.jsx)(b,{showCreatureFooter:!1,children:(0,O.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${T?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`px-6 py-16`} text-[var(--content-default)]`,children:[(0,O.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full border border-[var(--border-subtle)] bg-[var(--surface-lift)]`,style:{animation:`fadeInUp 0.5s ease-out 0.05s both`},children:(0,O.jsx)(o,{className:`h-6 w-6 text-[var(--content-secondary)]`,strokeWidth:1.75})}),(0,O.jsx)(`h1`,{className:`mt-5 ${T?`text-title-large`:`text-3xl font-semibold tracking-tight`}`,style:{animation:`fadeInUp 0.5s ease-out 0.12s both`},children:Q}),(0,O.jsx)(`p`,{className:`text-center text-body-medium-lighter text-[var(--content-tertiary)] ${T?`mt-3`:`mt-3.5`}`,style:{animation:`fadeInUp 0.5s ease-out 0.2s both`},children:$}),(Y||X)&&(0,O.jsx)(x,{electron:T,showAnalytics:Y,showDiagnostics:X,shareAnalytics:B,shareDiagnostics:V,onShareAnalyticsChange:F,onShareDiagnosticsChange:L,className:`mt-9 w-full`,style:{animation:`fadeInUp 0.5s ease-out 0.28s both`}}),(J||q)&&(0,O.jsx)(S,{electron:T,showPrivacy:J,showTos:q,privacyConsent:M,tosAccepted:A,onPrivacyChange:N,onTosChange:j,privacyNotes:J?D(`2026-06-22`):[],tosNotes:q?E(`2026-06-08`):[],className:`mt-6 w-full`,style:{animation:`fadeInUp 0.5s ease-out 0.36s both`}}),(0,O.jsxs)(`div`,{className:`mt-9 flex w-full flex-col ${T?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.44s both`},children:[(0,O.jsx)(n,{variant:`primary`,size:`regular`,fullWidth:!0,disabled:ne,onClick:ee,className:T?void 0:`h-11 text-base`,children:`Continue`}),(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,onClick:te,className:T?void 0:`h-11 text-base`,children:`Log out`})]})]})})}export{k as ReviewTermsScreen};
@@ -1,3 +1,3 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{c as t,i as n}from"./local-settings-C-dW2vkq.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./createLucideIcon-Bjb-Kuq7.js";import{n as a,t as o}from"./create-selectors-8NePGNlX.js";import{n as s}from"./typed-storage-CiZjryGu.js";import{a as c}from"./diagnostics-DbnQqLDx.js";import{l}from"./chat-markdown-message-CjK8FRpm.js";import{t as u}from"./conversation-store-CnRrUeSu.js";import{s as ee,u as d}from"./messages-Bb68dDXK.js";import{C as f,D as p,n as te,t as ne,w as re,x as ie}from"./chat-CNlH625o.js";var ae=i(`bolt`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}],[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}]]),oe=i(`pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),se=i(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),ce=i(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),le=e(r(),1),m=1e3,ue=15,de=0,h=new Map,g=[];function fe(e){let t=`sse-${++de}`,n={id:t,abortSignal:e,initiatedAt:Date.now(),establishedAt:null,lastTrafficAt:null,lastDataAt:null,dataFrames:0,keepalives:0,endedAt:null,endReason:null};h.set(t,n),Se();let r=()=>{xe(t,`aborted`)};return e.aborted?r():e.addEventListener(`abort`,r,{once:!0}),t}function pe(e){let t=h.get(e);t&&t.establishedAt===null&&(t.establishedAt=Date.now())}function me(e,t){let n=h.get(e);if(!n)return;let r=Date.now();n.lastTrafficAt=r,t?(n.lastDataAt=r,n.dataFrames++):n.keepalives++}function he(e,t){g.push({clientId:e,receivedAt:new Date().toISOString(),...t}),g.length>m&&g.shift()}var ge=`events-tail`;function _e(e){if(e.length===0)return;let t=new Set;for(let e of g)typeof e.seq==`number`&&t.add(e.seq);for(let n of e)typeof n.seq==`number`&&t.has(n.seq)||g.push({clientId:ge,receivedAt:new Date().toISOString(),...n});for(;g.length>m;)g.shift()}function ve(){return Array.from(h.values())}function ye(e=m){let t=Math.max(0,g.length-e);return g.slice(t)}function be(e,t){if(t===null)return null;let n=1/0;for(let e of g)typeof e.seq==`number`&&(n=Math.min(n,e.seq));return n!==1/0&&n>t+1?null:g.filter(n=>n.conversationId===e&&typeof n.seq==`number`&&n.seq>t).sort((e,t)=>e.seq-t.seq)}function xe(e,t){let n=h.get(e);n&&(n.endedAt===null?(n.endedAt=Date.now(),n.endReason=t):n.endReason===`aborted`&&t!==`aborted`&&(n.endReason=t),Se())}function Se(){let e=0;for(let t of h.values())t.endedAt!==null&&e++;if(!(e<=ue))for(let[t,n]of h){if(e<=ue)break;n.endedAt!==null&&(h.delete(t),e--)}}var _={phase:`idle`,pendingQueuedCount:0,activeToolCallCount:0,activeTurnId:null,lastTerminalReason:null,statusText:null,liveWebActivity:{}};function v(e){return e===`queued`||e===`thinking`||e===`streaming`||e===`awaiting_user_input`}function Ce(e){return e===`thinking`}function y(e){return(e.phase===`idle`||e.phase===`errored`)&&!e.activeTurnId}var we=o(a()((e,t)=>({..._,requestSend:t=>e(e=>({phase:`thinking`,activeTurnId:t??e.activeTurnId,lastTerminalReason:null,activeToolCallCount:0,statusText:null})),acceptSend:t=>e(e=>({activeTurnId:t,...e.phase===`idle`||e.phase===`errored`?{phase:`thinking`,lastTerminalReason:null}:null})),onTextDelta:()=>{let n=t();if(n.phase===`idle`||n.phase===`errored`){if(!n.activeTurnId)return;e({phase:`streaming`});return}(n.phase===`thinking`||n.phase===`queued`)&&e({phase:`streaming`})},onToolUseStart:()=>{let n=t();y(n)||e({phase:n.phase===`idle`||n.phase===`errored`||n.phase===`queued`?`thinking`:n.phase,activeToolCallCount:n.activeToolCallCount+1})},onToolResult:()=>e(e=>({activeToolCallCount:Math.max(0,e.activeToolCallCount-1)})),onToolActivityMetadata:(n,r)=>{let i=t();y(i)||e({liveWebActivity:{...i.liveWebActivity,[n]:r}})},onActivityThinking:(n,r)=>{let i=t();if(y(i)){if(!r?.canStartFromIdle)return;e({phase:`thinking`,statusText:n??null,lastTerminalReason:null});return}i.phase!==`awaiting_user_input`&&e({phase:`thinking`,statusText:n??null})},recoverFromAwaitingUserInput:()=>{t().phase===`awaiting_user_input`&&e({phase:`thinking`})},showSurface:n=>{y(t())||n&&e({phase:`awaiting_user_input`})},updateSurface:()=>{},dismissSurface:()=>{let n=t();n.phase===`awaiting_user_input`&&n.activeToolCallCount===0&&e({phase:`thinking`})},completeSurface:()=>{let n=t();n.phase===`awaiting_user_input`&&n.activeToolCallCount===0&&e({phase:`thinking`})},onSecretRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},onConfirmationRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},onQuestionRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},onContactRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},completeTurn:()=>{e({phase:t().pendingQueuedCount>0?`queued`:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},handoffGeneration:()=>{y(t())||e({phase:`thinking`,activeToolCallCount:0,statusText:null})},cancelGeneration:()=>{e({phase:t().pendingQueuedCount>0?`queued`:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`cancelled`,statusText:null,liveWebActivity:{}})},onStreamError:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`error`,statusText:null,liveWebActivity:{}}),onSessionError:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`session_error`,statusText:null,liveWebActivity:{}}),onTurnTimeout:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`timeout`,statusText:null,liveWebActivity:{}}),onPollReconciled:n=>{let r=t();n&&n!==r.activeTurnId||v(r.phase)&&e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},resetTurn:()=>e({..._}),clearStaleTurn:()=>{let n=t();n.activeTurnId&&v(n.phase)||e({..._})},enqueueMessage:()=>e(e=>({pendingQueuedCount:e.pendingQueuedCount+1})),dequeueMessage:()=>{let n=t(),r=Math.max(0,n.pendingQueuedCount-1);if(y(n)){e({pendingQueuedCount:r});return}e({phase:`thinking`,pendingQueuedCount:r})},deleteQueuedMessage:()=>{let n=t(),r=Math.max(0,n.pendingQueuedCount-1);if(r===0&&n.phase===`queued`){e({phase:`idle`,pendingQueuedCount:0,activeTurnId:null,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}});return}e({pendingQueuedCount:r})}}))),Te=3670016,Ee=[.85,.75,.65,.5],De=2e7,Oe=new Set([`image/jpeg`,`image/jpg`,`image/png`,`image/webp`,`image/heic`,`image/heif`,`image/bmp`,`image/tiff`]),ke=new Set([`jpg`,`jpeg`,`png`,`webp`,`heic`,`heif`,`bmp`,`tif`,`tiff`]);function b(e){let t=e.type.trim().toLowerCase();if(Oe.has(t))return!0;let n=e.name.split(`.`).pop()?.trim().toLowerCase();return n?ke.has(n):!1}function Ae(e){return b(e)&&e.size>3670016}function je(e){let t=e.type.trim().toLowerCase();if(t===`image/heic`||t===`image/heif`)return!0;let n=e.name.split(`.`).pop()?.trim().toLowerCase();return n===`heic`||n===`heif`}function Me(e){return Ae(e)||je(e)}function Ne(e){if(/^image\/jpe?g$/i.test(e))return`jpg`;let t=e.slice(6).toLowerCase();return/^[a-z0-9]+$/.test(t)?t:`jpg`}function Pe(e,t=`image/jpeg`){let n=`attachment`,r=e.trim()||n,i=Ne(t),a=r.match(/\.([^./\\]+)$/)?.[1]?.toLowerCase();return a===i||i===`jpg`&&a===`jpeg`?r:`${r.replace(/\.[^./\\]+$/,``)||n}.${i}`}async function Fe(e){if(!Me(e)||await Le(e))return{status:`unchanged`,file:e};if(e.size>104857600)return{status:`failed`,error:`This image is too large to process safely. Please choose a smaller image.`};let t;try{t=await Ie(e)}catch{return{status:`failed`,error:`Couldn't resize this image for upload. Try a smaller image.`}}try{let n;try{n=await ze(t,e.size)}catch{n=null}if(!n||!je(e)&&n.size>=e.size)return{status:`failed`,error:`Couldn't resize this image for upload. Try a smaller image.`};let r=n.type.startsWith(`image/`)?n.type:`image/jpeg`;return{status:`resized`,file:new File([n],Pe(e.name,r),{type:r,lastModified:e.lastModified})}}finally{t.close()}}async function Ie(e){if(typeof createImageBitmap==`function`)try{let t=await createImageBitmap(e,{imageOrientation:`from-image`});return{source:t,width:t.width,height:t.height,close:()=>t.close()}}catch{}if(typeof Image>`u`)throw Error(`No browser image decoder is available.`);let t=URL.createObjectURL(e);return await new Promise((e,n)=>{let r=new Image;r.onload=()=>{e({source:r,width:r.naturalWidth||r.width,height:r.naturalHeight||r.height,close:()=>URL.revokeObjectURL(t)})},r.onerror=()=>{URL.revokeObjectURL(t),n(Error(`Image decode failed.`))},r.src=t})}async function Le(e){if(!Re(e))return!1;let t;try{t=new Uint8Array(await e.slice(0,Math.min(e.size,1024*1024)).arrayBuffer())}catch{return!0}if(!S(t,0,`RIFF`)||!S(t,8,`WEBP`))return!1;let n=x(t,`VP8X`);return n>=0&&(t[n+8]??0)&2?!0:x(t,`ANIM`)>=0||x(t,`ANMF`)>=0}function Re(e){return e.type.trim().toLowerCase()===`image/webp`||/\.webp$/i.test(e.name)}function x(e,t){for(let n=0;n<=e.length-t.length;n+=1)if(S(e,n,t))return n;return-1}function S(e,t,n){if(t+n.length>e.length)return!1;for(let r=0;r<n.length;r+=1)if(e[t+r]!==n.charCodeAt(r))return!1;return!0}async function ze(e,t){let n=e.width*e.height,r=null;if(n<=De)for(let t of Ee){let n=await w(e.source,e.width,e.height,t);if(r=C(r,n),n&&n.size<=3670016)return n}let i=r?.size??t,a=Math.min(Math.sqrt(Te/i*.9),.95);for(let t=0;t<4;t+=1){let t=Math.max(Math.floor(e.width*a),1),n=Math.max(Math.floor(e.height*a),1),o=null;for(let i of Ee){let a=await w(e.source,t,n,i);if(r=C(r,a),o=C(o,a),a&&a.size<=3670016)return a}i=o?.size??i,a*=Math.min(Math.sqrt(Te/i*.9),.9)}return null}function C(e,t){return t&&(!e||t.size<e.size)?t:e}async function w(e,t,n,r){if(typeof document>`u`)return null;let i=document.createElement(`canvas`);i.width=t,i.height=n;let a=i.getContext(`2d`);if(!a||typeof i.toBlob!=`function`)return null;a.fillStyle=`#fff`,a.fillRect(0,0,t,n),a.drawImage(e,0,0,t,n);try{return await new Promise(e=>{i.toBlob(t=>e(t),`image/jpeg`,r)})}finally{i.width=0,i.height=0}}var Be=`vellum:chatDrafts:`;function T(e){return`${Be}${e}`}function Ve(e){let t=n(T(e),``);if(!t)return new Map;try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?new Map:new Map(Object.entries(e).filter(e=>typeof e[1]==`string`))}catch{return new Map}}function E(e,n){t(T(e),JSON.stringify(Object.fromEntries(n)))}function He(){return`att-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Ue(e){return b(e)?`100 MB`:`50 MB`}function We(e){return e.size<=52428800?!0:b(e)&&e.size<=104857600}function Ge(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(n+1)}var D=new Map,O=null,k=new Map,A=new Set,Ke=a()((e,t)=>({input:``,restoredDraftConversationId:null,attachments:[],attachmentLastError:null,setInput:t=>{e(e=>({input:typeof t==`function`?t(e.input):t}))},saveDraft:(e,t)=>{t.trim()?D.set(e,t):D.delete(e),O&&E(O,D)},clearDraft:e=>{D.delete(e),O&&E(O,D)},handleConversationSwitch:({previousKey:n,nextKey:r})=>{if(!(n!==null&&n!==r)||!n)return;let i=t().input;i.trim()?D.set(n,i):D.delete(n);let a=(r&&D.get(r))??``;e({input:a,restoredDraftConversationId:a.length>0&&r?r:null}),O&&E(O,D)},loadAssistantDrafts:(n,r)=>{if(O&&O!==n){let n=t().input;r&&(n.trim()?D.set(r,n):D.delete(r)),E(O,D),e({input:``,restoredDraftConversationId:null})}D=Ve(n),O=n},clearRestoredDraftNotice:()=>{e({restoredDraftConversationId:null})},restoreDraftIfEmpty:n=>{let r=D.get(n);r&&r.trim()&&!t().input.trim()&&e({input:r,restoredDraftConversationId:n})},addFiles:(t,n)=>{let r=Array.from(t);if(r.length===0)return;if(!n){e({attachmentLastError:`No active assistant. Please try again.`});return}let i=[],a=[];for(let e of r)We(e)?a.push(e):i.push(e);let o=i[0];if(e(o?{attachmentLastError:i.length===1?`${o.name} is larger than ${Ue(o)} and can't be attached.`:`${i.length} files are too large and can't be attached.`}:{attachmentLastError:null}),a.length===0)return;let s=a.map(e=>({pending:{kind:`uploading`,localId:He(),filename:e.name||`attachment`,mimeType:e.type||`application/octet-stream`,sizeBytes:e.size},file:e}));e(e=>({attachments:[...e.attachments,...s.map(e=>e.pending)]}));for(let{pending:t,file:r}of s)(async()=>{try{let i=await Fe(r);if(A.has(t.localId)){A.delete(t.localId);return}if(i.status===`failed`&&r.size>52428800){j(e,t.localId,i.error);return}let a=i.status===`failed`?r:i.file;if(a.size>52428800){j(e,t.localId,`This attachment is still larger than 50 MB after resizing. Try a smaller image.`);return}i.status===`resized`&&e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId&&e.kind===`uploading`?{...e,filename:a.name||`attachment`,mimeType:a.type||`application/octet-stream`,sizeBytes:a.size}:e)}));let o=await ee(n,a);if(A.has(t.localId)){A.delete(t.localId);return}if(!o.ok){j(e,t.localId,o.error.detail??`Upload failed`);return}let s=a.type||`application/octet-stream`,c=o.filename??(a.name||`attachment`),u=o.mimeType??s,d=o.sizeBytes??a.size,f=a;if(u.startsWith(`image/`)&&u!==s){let e=await l(n,o.id);if(A.has(t.localId)){A.delete(t.localId);return}e&&(f=e)}let p=null;try{p=URL.createObjectURL(f),k.set(t.localId,p)}catch{p=null}e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId?{kind:`uploaded`,localId:t.localId,id:o.id,filename:c,mimeType:u,sizeBytes:d,previewUrl:p,thumbnailUrl:null}:e)}))}catch{if(A.has(t.localId)){A.delete(t.localId);return}j(e,t.localId,`Upload failed`)}})()},addPathReferences:t=>{let n=[];for(let e of t){let t=e.trim();t&&n.push({kind:`path-reference`,localId:He(),path:t,filename:Ge(t)||t})}n.length!==0&&e(e=>({attachments:[...e.attachments,...n],attachmentLastError:null}))},removeAttachment:t=>{e(e=>{let n=e.attachments.find(e=>e.localId===t);return n&&n.kind===`uploading`&&A.add(t),{attachments:e.attachments.filter(e=>e.localId!==t)}}),qe(t)},resetAttachments:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&A.add(t.localId);return{attachments:[],attachmentLastError:null}})},fullReset:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&A.add(t.localId);return{attachments:[],attachmentLastError:null}}),k.forEach(e=>URL.revokeObjectURL(e)),k.clear()},dismissAttachmentError:()=>{e({attachmentLastError:null})}}));function j(e,t,n){e(e=>({attachments:e.attachments.map(e=>e.localId!==t||e.kind!==`uploading`?e:{kind:`failed`,localId:t,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes,error:n})}))}function qe(e){let t=k.get(e);t&&(URL.revokeObjectURL(t),k.delete(e))}function Je(e){return e.reduce((e,t)=>t.kind===`uploading`?e+1:e,0)}function Ye(e){return e.filter(e=>e.kind===`uploaded`).map(e=>e.id)}function Xe(e){return e.filter(e=>e.kind===`path-reference`).map(e=>e.path)}var M=o(Ke);function Ze(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Qe(e){let t=JSON.parse(e);return Ze(t)?t:null}function N(e,t){let n=[...e??[]],r=n.findIndex(e=>e.type===`surface`&&e.surface.surfaceId===t.surfaceId);return r===-1?n.push({type:`surface`,surface:t}):n[r]={type:`surface`,surface:t},n}function $e(e,t){return e?.filter(e=>!(e.type===`surface`&&e.surface.surfaceId===t))}function et(e,t){if(!e.surfaces?.length)return e;let n=!1,r=e.contentBlocks,i=e.surfaces.map(e=>{let i=t(e);return i!==e&&(n=!0,r=N(r,i)),i});return n?{...e,surfaces:i,contentBlocks:r}:e}function tt(e,t){if(!e.surfaces?.length)return e;let n=e.surfaces.filter(t);if(n.length===e.surfaces.length)return e;let r=new Set(e.surfaces.filter(e=>!t(e)).map(e=>e.surfaceId));return{...e,surfaces:n,contentOrder:e.contentOrder?.filter(e=>!(e.type===`surface`&&r.has(e.id))),contentBlocks:e.contentBlocks?.filter(e=>!(e.type===`surface`&&r.has(e.surface.surfaceId)))}}var nt=500,rt=s({keyFn:e=>`vellum:dismissed-surfaces:${e}`,scope:`user`,parseValue:e=>Ze(e)?e:null,fallback:{},maxEntries:200});function it(e,t){let n=rt.get(e,t);return n?new Set(n):new Set}function at(e,t,n){let r=Array.from(n);r.length>nt&&(r=r.slice(r.length-nt)),rt.set(e,t,r)}var ot=[];function st(e,t){if(!e)return ot;if(t.size===0)return e;let n=!1,r=e.map(e=>{let r=tt(e,e=>!t.has(e.surfaceId));return r!==e&&(n=!0),r});return n?r:e}function ct(e){if(!e||typeof e!=`object`)return!1;let t=e;return!(typeof t.tokens!=`number`||!Number.isFinite(t.tokens)||t.maxTokens!==null&&(typeof t.maxTokens!=`number`||!Number.isFinite(t.maxTokens))||t.fillRatio!==null&&(typeof t.fillRatio!=`number`||!Number.isFinite(t.fillRatio)))}var lt=s({keyFn:e=>`vellum:ctxwindow:${e}`,scope:`user`,parseValue:e=>ct(e)?e:null,fallback:{},maxEntries:200});function ut(e){return new Map(Object.entries(lt.load(e)))}function dt(e,t,n){lt.set(e,t,n)}var ft=`PROVIDER_BILLING`,pt=`PROVIDER_NOT_CONFIGURED`,mt=`MANAGED_KEY_INVALID`,ht=`credits_exhausted`,gt=`provider_billing`,_t=`daily_limit_reached`;function vt(e){return e?.errorCategory?e.errorCategory.endsWith(ht):e?.code===ft}function yt(e){return e?.errorCategory?e.errorCategory.endsWith(gt):!1}function bt(e){return e?.errorCategory?e.errorCategory.endsWith(_t):!1}function xt(e){return bt(e)?`daily_limit`:vt(e)?`managed_credits`:yt(e)?`provider_billing`:null}function P(e){return xt(e)!==null||e?.code===pt||e?.displayAs===`modal`}function St(e){return!!e&&!P(e)}function Ct(e){return e?.code===mt}var wt={pendingSecret:null,isSubmittingSecret:!1,secretSaved:!1,pendingConfirmation:null,isSubmittingConfirmation:!1,pendingContactRequest:null,isSubmittingContactRequest:!1,contactRequestAccepted:!1,pendingQuestion:null,isSubmittingQuestion:!1,isQuestionCardDismissed:!1,inlineConfirmationToolCallId:null,pendingAcpConnect:null,dismissedAcpConnectToolUseIds:new Set,pendingAcpContinue:!1,unknownNudgeToolCallIds:new Set},F=o(a()((e,t)=>({...wt,showSecret:n=>{let{pendingSecret:r}=t();if(r&&r.requestId===n.requestId){let t={};for(let e of Object.keys(n))n[e]!==void 0&&(t[e]=n[e]);e({pendingSecret:{...r,...t}});return}e({pendingSecret:n,isSubmittingSecret:!1,secretSaved:!1})},submitSecretStart:()=>e({isSubmittingSecret:!0}),submitSecretEnd:t=>e({isSubmittingSecret:!1,secretSaved:t??!1}),dismissSecret:()=>e({pendingSecret:null,isSubmittingSecret:!1}),updateSecret:(n,r)=>{let{pendingSecret:i}=t();!i||i.requestId!==n||e({pendingSecret:{...i,...r}})},showConfirmation:t=>e({pendingConfirmation:t,isSubmittingConfirmation:!1}),submitConfirmationStart:()=>e({isSubmittingConfirmation:!0}),submitConfirmationEnd:()=>e({isSubmittingConfirmation:!1}),dismissConfirmation:()=>e({pendingConfirmation:null,isSubmittingConfirmation:!1}),dismissConfirmationIfMatches:n=>{let{pendingConfirmation:r}=t();!r||r.requestId!==n||e({pendingConfirmation:null,isSubmittingConfirmation:!1})},updateConfirmation:(n,r)=>{let{pendingConfirmation:i}=t();!i||i.requestId!==n||e({pendingConfirmation:{...i,...r}})},setInlineConfirmationToolCallId:t=>e({inlineConfirmationToolCallId:t}),showContactRequest:t=>e({pendingContactRequest:t,isSubmittingContactRequest:!1,contactRequestAccepted:!1}),submitContactRequestStart:()=>e({isSubmittingContactRequest:!0}),submitContactRequestEnd:()=>e({isSubmittingContactRequest:!1}),dismissContactRequest:()=>e({pendingContactRequest:null,isSubmittingContactRequest:!1}),acceptContactRequest:()=>e({contactRequestAccepted:!0}),showQuestion:t=>e({pendingQuestion:t,isSubmittingQuestion:!1,isQuestionCardDismissed:!1}),submitQuestionStart:()=>e({isSubmittingQuestion:!0}),submitQuestionEnd:()=>e({isSubmittingQuestion:!1}),dismissQuestion:()=>e({pendingQuestion:null,isSubmittingQuestion:!1,isQuestionCardDismissed:!1}),dismissQuestionCard:()=>e({isQuestionCardDismissed:!0}),resetSecretAndConfirmation:()=>e({pendingSecret:null,isSubmittingSecret:!1,secretSaved:!1,pendingConfirmation:null,isSubmittingConfirmation:!1,inlineConfirmationToolCallId:null}),showAcpConnect:t=>e(e=>e.dismissedAcpConnectToolUseIds.has(t.toolUseId)?{}:{pendingAcpConnect:t}),dismissAcpConnect:()=>e(e=>({pendingAcpConnect:null,dismissedAcpConnectToolUseIds:e.pendingAcpConnect?new Set(e.dismissedAcpConnectToolUseIds).add(e.pendingAcpConnect.toolUseId):e.dismissedAcpConnectToolUseIds})),requestAcpContinue:()=>e({pendingAcpContinue:!0}),clearAcpContinue:()=>e({pendingAcpContinue:!1}),addUnknownNudgeToolCallId:n=>{let r=t().unknownNudgeToolCallIds;r.has(n)||e({unknownNudgeToolCallIds:new Set([...r,n])})},removeUnknownNudgeToolCallId:n=>{let r=t().unknownNudgeToolCallIds;if(!r.has(n))return;let i=new Set(r);i.delete(n),e({unknownNudgeToolCallIds:i})},resetAll:()=>e(wt)})));function Tt(e){if(e.length===0)return``;let t=e[0]??``;for(let n=1;n<e.length;n++){let r=t[t.length-1],i=e[n][0];r&&i&&r!==` `&&r!==`
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{c as t,i as n}from"./local-settings-C-dW2vkq.js";import{t as r}from"./react-DJZBPgpf.js";import{t as i}from"./createLucideIcon-Bjb-Kuq7.js";import{n as a,t as o}from"./create-selectors-8NePGNlX.js";import{n as s}from"./typed-storage-CiZjryGu.js";import{a as c}from"./diagnostics-DbnQqLDx.js";import{l}from"./chat-markdown-message-CjK8FRpm.js";import{t as u}from"./conversation-store-CnRrUeSu.js";import{s as ee,u as d}from"./messages-Bb68dDXK.js";import{C as f,D as p,n as te,t as ne,w as re,x as ie}from"./chat-AyO7_TjY.js";var ae=i(`bolt`,[[`path`,{d:`M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z`,key:`yt0hxn`}],[`circle`,{cx:`12`,cy:`12`,r:`4`,key:`4exip2`}]]),oe=i(`pen`,[[`path`,{d:`M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z`,key:`1a8usu`}]]),se=i(`plug`,[[`path`,{d:`M12 22v-5`,key:`1ega77`}],[`path`,{d:`M15 8V2`,key:`18g5xt`}],[`path`,{d:`M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z`,key:`1xoxul`}],[`path`,{d:`M9 8V2`,key:`14iosj`}]]),ce=i(`square-terminal`,[[`path`,{d:`m7 11 2-2-2-2`,key:`1lz0vl`}],[`path`,{d:`M11 13h4`,key:`1p7l4v`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}]]),le=e(r(),1),m=1e3,ue=15,de=0,h=new Map,g=[];function fe(e){let t=`sse-${++de}`,n={id:t,abortSignal:e,initiatedAt:Date.now(),establishedAt:null,lastTrafficAt:null,lastDataAt:null,dataFrames:0,keepalives:0,endedAt:null,endReason:null};h.set(t,n),Se();let r=()=>{xe(t,`aborted`)};return e.aborted?r():e.addEventListener(`abort`,r,{once:!0}),t}function pe(e){let t=h.get(e);t&&t.establishedAt===null&&(t.establishedAt=Date.now())}function me(e,t){let n=h.get(e);if(!n)return;let r=Date.now();n.lastTrafficAt=r,t?(n.lastDataAt=r,n.dataFrames++):n.keepalives++}function he(e,t){g.push({clientId:e,receivedAt:new Date().toISOString(),...t}),g.length>m&&g.shift()}var ge=`events-tail`;function _e(e){if(e.length===0)return;let t=new Set;for(let e of g)typeof e.seq==`number`&&t.add(e.seq);for(let n of e)typeof n.seq==`number`&&t.has(n.seq)||g.push({clientId:ge,receivedAt:new Date().toISOString(),...n});for(;g.length>m;)g.shift()}function ve(){return Array.from(h.values())}function ye(e=m){let t=Math.max(0,g.length-e);return g.slice(t)}function be(e,t){if(t===null)return null;let n=1/0;for(let e of g)typeof e.seq==`number`&&(n=Math.min(n,e.seq));return n!==1/0&&n>t+1?null:g.filter(n=>n.conversationId===e&&typeof n.seq==`number`&&n.seq>t).sort((e,t)=>e.seq-t.seq)}function xe(e,t){let n=h.get(e);n&&(n.endedAt===null?(n.endedAt=Date.now(),n.endReason=t):n.endReason===`aborted`&&t!==`aborted`&&(n.endReason=t),Se())}function Se(){let e=0;for(let t of h.values())t.endedAt!==null&&e++;if(!(e<=ue))for(let[t,n]of h){if(e<=ue)break;n.endedAt!==null&&(h.delete(t),e--)}}var _={phase:`idle`,pendingQueuedCount:0,activeToolCallCount:0,activeTurnId:null,lastTerminalReason:null,statusText:null,liveWebActivity:{}};function v(e){return e===`queued`||e===`thinking`||e===`streaming`||e===`awaiting_user_input`}function Ce(e){return e===`thinking`}function y(e){return(e.phase===`idle`||e.phase===`errored`)&&!e.activeTurnId}var we=o(a()((e,t)=>({..._,requestSend:t=>e(e=>({phase:`thinking`,activeTurnId:t??e.activeTurnId,lastTerminalReason:null,activeToolCallCount:0,statusText:null})),acceptSend:t=>e(e=>({activeTurnId:t,...e.phase===`idle`||e.phase===`errored`?{phase:`thinking`,lastTerminalReason:null}:null})),onTextDelta:()=>{let n=t();if(n.phase===`idle`||n.phase===`errored`){if(!n.activeTurnId)return;e({phase:`streaming`});return}(n.phase===`thinking`||n.phase===`queued`)&&e({phase:`streaming`})},onToolUseStart:()=>{let n=t();y(n)||e({phase:n.phase===`idle`||n.phase===`errored`||n.phase===`queued`?`thinking`:n.phase,activeToolCallCount:n.activeToolCallCount+1})},onToolResult:()=>e(e=>({activeToolCallCount:Math.max(0,e.activeToolCallCount-1)})),onToolActivityMetadata:(n,r)=>{let i=t();y(i)||e({liveWebActivity:{...i.liveWebActivity,[n]:r}})},onActivityThinking:(n,r)=>{let i=t();if(y(i)){if(!r?.canStartFromIdle)return;e({phase:`thinking`,statusText:n??null,lastTerminalReason:null});return}i.phase!==`awaiting_user_input`&&e({phase:`thinking`,statusText:n??null})},recoverFromAwaitingUserInput:()=>{t().phase===`awaiting_user_input`&&e({phase:`thinking`})},showSurface:n=>{y(t())||n&&e({phase:`awaiting_user_input`})},updateSurface:()=>{},dismissSurface:()=>{let n=t();n.phase===`awaiting_user_input`&&n.activeToolCallCount===0&&e({phase:`thinking`})},completeSurface:()=>{let n=t();n.phase===`awaiting_user_input`&&n.activeToolCallCount===0&&e({phase:`thinking`})},onSecretRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},onConfirmationRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},onQuestionRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},onContactRequest:()=>{y(t())||e({phase:`awaiting_user_input`})},completeTurn:()=>{e({phase:t().pendingQueuedCount>0?`queued`:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},handoffGeneration:()=>{y(t())||e({phase:`thinking`,activeToolCallCount:0,statusText:null})},cancelGeneration:()=>{e({phase:t().pendingQueuedCount>0?`queued`:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`cancelled`,statusText:null,liveWebActivity:{}})},onStreamError:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`error`,statusText:null,liveWebActivity:{}}),onSessionError:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`session_error`,statusText:null,liveWebActivity:{}}),onTurnTimeout:()=>e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,pendingQueuedCount:0,lastTerminalReason:`timeout`,statusText:null,liveWebActivity:{}}),onPollReconciled:n=>{let r=t();n&&n!==r.activeTurnId||v(r.phase)&&e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},resetTurn:()=>e({..._}),clearStaleTurn:()=>{let n=t();n.activeTurnId&&v(n.phase)||e({..._})},enqueueMessage:()=>e(e=>({pendingQueuedCount:e.pendingQueuedCount+1})),dequeueMessage:()=>{let n=t(),r=Math.max(0,n.pendingQueuedCount-1);if(y(n)){e({pendingQueuedCount:r});return}e({phase:`thinking`,pendingQueuedCount:r})},deleteQueuedMessage:()=>{let n=t(),r=Math.max(0,n.pendingQueuedCount-1);if(r===0&&n.phase===`queued`){e({phase:`idle`,pendingQueuedCount:0,activeTurnId:null,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}});return}e({pendingQueuedCount:r})}}))),Te=3670016,Ee=[.85,.75,.65,.5],De=2e7,Oe=new Set([`image/jpeg`,`image/jpg`,`image/png`,`image/webp`,`image/heic`,`image/heif`,`image/bmp`,`image/tiff`]),ke=new Set([`jpg`,`jpeg`,`png`,`webp`,`heic`,`heif`,`bmp`,`tif`,`tiff`]);function b(e){let t=e.type.trim().toLowerCase();if(Oe.has(t))return!0;let n=e.name.split(`.`).pop()?.trim().toLowerCase();return n?ke.has(n):!1}function Ae(e){return b(e)&&e.size>3670016}function je(e){let t=e.type.trim().toLowerCase();if(t===`image/heic`||t===`image/heif`)return!0;let n=e.name.split(`.`).pop()?.trim().toLowerCase();return n===`heic`||n===`heif`}function Me(e){return Ae(e)||je(e)}function Ne(e){if(/^image\/jpe?g$/i.test(e))return`jpg`;let t=e.slice(6).toLowerCase();return/^[a-z0-9]+$/.test(t)?t:`jpg`}function Pe(e,t=`image/jpeg`){let n=`attachment`,r=e.trim()||n,i=Ne(t),a=r.match(/\.([^./\\]+)$/)?.[1]?.toLowerCase();return a===i||i===`jpg`&&a===`jpeg`?r:`${r.replace(/\.[^./\\]+$/,``)||n}.${i}`}async function Fe(e){if(!Me(e)||await Le(e))return{status:`unchanged`,file:e};if(e.size>104857600)return{status:`failed`,error:`This image is too large to process safely. Please choose a smaller image.`};let t;try{t=await Ie(e)}catch{return{status:`failed`,error:`Couldn't resize this image for upload. Try a smaller image.`}}try{let n;try{n=await ze(t,e.size)}catch{n=null}if(!n||!je(e)&&n.size>=e.size)return{status:`failed`,error:`Couldn't resize this image for upload. Try a smaller image.`};let r=n.type.startsWith(`image/`)?n.type:`image/jpeg`;return{status:`resized`,file:new File([n],Pe(e.name,r),{type:r,lastModified:e.lastModified})}}finally{t.close()}}async function Ie(e){if(typeof createImageBitmap==`function`)try{let t=await createImageBitmap(e,{imageOrientation:`from-image`});return{source:t,width:t.width,height:t.height,close:()=>t.close()}}catch{}if(typeof Image>`u`)throw Error(`No browser image decoder is available.`);let t=URL.createObjectURL(e);return await new Promise((e,n)=>{let r=new Image;r.onload=()=>{e({source:r,width:r.naturalWidth||r.width,height:r.naturalHeight||r.height,close:()=>URL.revokeObjectURL(t)})},r.onerror=()=>{URL.revokeObjectURL(t),n(Error(`Image decode failed.`))},r.src=t})}async function Le(e){if(!Re(e))return!1;let t;try{t=new Uint8Array(await e.slice(0,Math.min(e.size,1024*1024)).arrayBuffer())}catch{return!0}if(!S(t,0,`RIFF`)||!S(t,8,`WEBP`))return!1;let n=x(t,`VP8X`);return n>=0&&(t[n+8]??0)&2?!0:x(t,`ANIM`)>=0||x(t,`ANMF`)>=0}function Re(e){return e.type.trim().toLowerCase()===`image/webp`||/\.webp$/i.test(e.name)}function x(e,t){for(let n=0;n<=e.length-t.length;n+=1)if(S(e,n,t))return n;return-1}function S(e,t,n){if(t+n.length>e.length)return!1;for(let r=0;r<n.length;r+=1)if(e[t+r]!==n.charCodeAt(r))return!1;return!0}async function ze(e,t){let n=e.width*e.height,r=null;if(n<=De)for(let t of Ee){let n=await w(e.source,e.width,e.height,t);if(r=C(r,n),n&&n.size<=3670016)return n}let i=r?.size??t,a=Math.min(Math.sqrt(Te/i*.9),.95);for(let t=0;t<4;t+=1){let t=Math.max(Math.floor(e.width*a),1),n=Math.max(Math.floor(e.height*a),1),o=null;for(let i of Ee){let a=await w(e.source,t,n,i);if(r=C(r,a),o=C(o,a),a&&a.size<=3670016)return a}i=o?.size??i,a*=Math.min(Math.sqrt(Te/i*.9),.9)}return null}function C(e,t){return t&&(!e||t.size<e.size)?t:e}async function w(e,t,n,r){if(typeof document>`u`)return null;let i=document.createElement(`canvas`);i.width=t,i.height=n;let a=i.getContext(`2d`);if(!a||typeof i.toBlob!=`function`)return null;a.fillStyle=`#fff`,a.fillRect(0,0,t,n),a.drawImage(e,0,0,t,n);try{return await new Promise(e=>{i.toBlob(t=>e(t),`image/jpeg`,r)})}finally{i.width=0,i.height=0}}var Be=`vellum:chatDrafts:`;function T(e){return`${Be}${e}`}function Ve(e){let t=n(T(e),``);if(!t)return new Map;try{let e=JSON.parse(t);return typeof e!=`object`||!e||Array.isArray(e)?new Map:new Map(Object.entries(e).filter(e=>typeof e[1]==`string`))}catch{return new Map}}function E(e,n){t(T(e),JSON.stringify(Object.fromEntries(n)))}function He(){return`att-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Ue(e){return b(e)?`100 MB`:`50 MB`}function We(e){return e.size<=52428800?!0:b(e)&&e.size<=104857600}function Ge(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(n+1)}var D=new Map,O=null,k=new Map,A=new Set,Ke=a()((e,t)=>({input:``,restoredDraftConversationId:null,attachments:[],attachmentLastError:null,setInput:t=>{e(e=>({input:typeof t==`function`?t(e.input):t}))},saveDraft:(e,t)=>{t.trim()?D.set(e,t):D.delete(e),O&&E(O,D)},clearDraft:e=>{D.delete(e),O&&E(O,D)},handleConversationSwitch:({previousKey:n,nextKey:r})=>{if(!(n!==null&&n!==r)||!n)return;let i=t().input;i.trim()?D.set(n,i):D.delete(n);let a=(r&&D.get(r))??``;e({input:a,restoredDraftConversationId:a.length>0&&r?r:null}),O&&E(O,D)},loadAssistantDrafts:(n,r)=>{if(O&&O!==n){let n=t().input;r&&(n.trim()?D.set(r,n):D.delete(r)),E(O,D),e({input:``,restoredDraftConversationId:null})}D=Ve(n),O=n},clearRestoredDraftNotice:()=>{e({restoredDraftConversationId:null})},restoreDraftIfEmpty:n=>{let r=D.get(n);r&&r.trim()&&!t().input.trim()&&e({input:r,restoredDraftConversationId:n})},addFiles:(t,n)=>{let r=Array.from(t);if(r.length===0)return;if(!n){e({attachmentLastError:`No active assistant. Please try again.`});return}let i=[],a=[];for(let e of r)We(e)?a.push(e):i.push(e);let o=i[0];if(e(o?{attachmentLastError:i.length===1?`${o.name} is larger than ${Ue(o)} and can't be attached.`:`${i.length} files are too large and can't be attached.`}:{attachmentLastError:null}),a.length===0)return;let s=a.map(e=>({pending:{kind:`uploading`,localId:He(),filename:e.name||`attachment`,mimeType:e.type||`application/octet-stream`,sizeBytes:e.size},file:e}));e(e=>({attachments:[...e.attachments,...s.map(e=>e.pending)]}));for(let{pending:t,file:r}of s)(async()=>{try{let i=await Fe(r);if(A.has(t.localId)){A.delete(t.localId);return}if(i.status===`failed`&&r.size>52428800){j(e,t.localId,i.error);return}let a=i.status===`failed`?r:i.file;if(a.size>52428800){j(e,t.localId,`This attachment is still larger than 50 MB after resizing. Try a smaller image.`);return}i.status===`resized`&&e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId&&e.kind===`uploading`?{...e,filename:a.name||`attachment`,mimeType:a.type||`application/octet-stream`,sizeBytes:a.size}:e)}));let o=await ee(n,a);if(A.has(t.localId)){A.delete(t.localId);return}if(!o.ok){j(e,t.localId,o.error.detail??`Upload failed`);return}let s=a.type||`application/octet-stream`,c=o.filename??(a.name||`attachment`),u=o.mimeType??s,d=o.sizeBytes??a.size,f=a;if(u.startsWith(`image/`)&&u!==s){let e=await l(n,o.id);if(A.has(t.localId)){A.delete(t.localId);return}e&&(f=e)}let p=null;try{p=URL.createObjectURL(f),k.set(t.localId,p)}catch{p=null}e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId?{kind:`uploaded`,localId:t.localId,id:o.id,filename:c,mimeType:u,sizeBytes:d,previewUrl:p,thumbnailUrl:null}:e)}))}catch{if(A.has(t.localId)){A.delete(t.localId);return}j(e,t.localId,`Upload failed`)}})()},addPathReferences:t=>{let n=[];for(let e of t){let t=e.trim();t&&n.push({kind:`path-reference`,localId:He(),path:t,filename:Ge(t)||t})}n.length!==0&&e(e=>({attachments:[...e.attachments,...n],attachmentLastError:null}))},removeAttachment:t=>{e(e=>{let n=e.attachments.find(e=>e.localId===t);return n&&n.kind===`uploading`&&A.add(t),{attachments:e.attachments.filter(e=>e.localId!==t)}}),qe(t)},resetAttachments:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&A.add(t.localId);return{attachments:[],attachmentLastError:null}})},fullReset:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&A.add(t.localId);return{attachments:[],attachmentLastError:null}}),k.forEach(e=>URL.revokeObjectURL(e)),k.clear()},dismissAttachmentError:()=>{e({attachmentLastError:null})}}));function j(e,t,n){e(e=>({attachments:e.attachments.map(e=>e.localId!==t||e.kind!==`uploading`?e:{kind:`failed`,localId:t,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes,error:n})}))}function qe(e){let t=k.get(e);t&&(URL.revokeObjectURL(t),k.delete(e))}function Je(e){return e.reduce((e,t)=>t.kind===`uploading`?e+1:e,0)}function Ye(e){return e.filter(e=>e.kind===`uploaded`).map(e=>e.id)}function Xe(e){return e.filter(e=>e.kind===`path-reference`).map(e=>e.path)}var M=o(Ke);function Ze(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function Qe(e){let t=JSON.parse(e);return Ze(t)?t:null}function N(e,t){let n=[...e??[]],r=n.findIndex(e=>e.type===`surface`&&e.surface.surfaceId===t.surfaceId);return r===-1?n.push({type:`surface`,surface:t}):n[r]={type:`surface`,surface:t},n}function $e(e,t){return e?.filter(e=>!(e.type===`surface`&&e.surface.surfaceId===t))}function et(e,t){if(!e.surfaces?.length)return e;let n=!1,r=e.contentBlocks,i=e.surfaces.map(e=>{let i=t(e);return i!==e&&(n=!0,r=N(r,i)),i});return n?{...e,surfaces:i,contentBlocks:r}:e}function tt(e,t){if(!e.surfaces?.length)return e;let n=e.surfaces.filter(t);if(n.length===e.surfaces.length)return e;let r=new Set(e.surfaces.filter(e=>!t(e)).map(e=>e.surfaceId));return{...e,surfaces:n,contentOrder:e.contentOrder?.filter(e=>!(e.type===`surface`&&r.has(e.id))),contentBlocks:e.contentBlocks?.filter(e=>!(e.type===`surface`&&r.has(e.surface.surfaceId)))}}var nt=500,rt=s({keyFn:e=>`vellum:dismissed-surfaces:${e}`,scope:`user`,parseValue:e=>Ze(e)?e:null,fallback:{},maxEntries:200});function it(e,t){let n=rt.get(e,t);return n?new Set(n):new Set}function at(e,t,n){let r=Array.from(n);r.length>nt&&(r=r.slice(r.length-nt)),rt.set(e,t,r)}var ot=[];function st(e,t){if(!e)return ot;if(t.size===0)return e;let n=!1,r=e.map(e=>{let r=tt(e,e=>!t.has(e.surfaceId));return r!==e&&(n=!0),r});return n?r:e}function ct(e){if(!e||typeof e!=`object`)return!1;let t=e;return!(typeof t.tokens!=`number`||!Number.isFinite(t.tokens)||t.maxTokens!==null&&(typeof t.maxTokens!=`number`||!Number.isFinite(t.maxTokens))||t.fillRatio!==null&&(typeof t.fillRatio!=`number`||!Number.isFinite(t.fillRatio)))}var lt=s({keyFn:e=>`vellum:ctxwindow:${e}`,scope:`user`,parseValue:e=>ct(e)?e:null,fallback:{},maxEntries:200});function ut(e){return new Map(Object.entries(lt.load(e)))}function dt(e,t,n){lt.set(e,t,n)}var ft=`PROVIDER_BILLING`,pt=`PROVIDER_NOT_CONFIGURED`,mt=`MANAGED_KEY_INVALID`,ht=`credits_exhausted`,gt=`provider_billing`,_t=`daily_limit_reached`;function vt(e){return e?.errorCategory?e.errorCategory.endsWith(ht):e?.code===ft}function yt(e){return e?.errorCategory?e.errorCategory.endsWith(gt):!1}function bt(e){return e?.errorCategory?e.errorCategory.endsWith(_t):!1}function xt(e){return bt(e)?`daily_limit`:vt(e)?`managed_credits`:yt(e)?`provider_billing`:null}function P(e){return xt(e)!==null||e?.code===pt||e?.displayAs===`modal`}function St(e){return!!e&&!P(e)}function Ct(e){return e?.code===mt}var wt={pendingSecret:null,isSubmittingSecret:!1,secretSaved:!1,pendingConfirmation:null,isSubmittingConfirmation:!1,pendingContactRequest:null,isSubmittingContactRequest:!1,contactRequestAccepted:!1,pendingQuestion:null,isSubmittingQuestion:!1,isQuestionCardDismissed:!1,inlineConfirmationToolCallId:null,pendingAcpConnect:null,dismissedAcpConnectToolUseIds:new Set,pendingAcpContinue:!1,unknownNudgeToolCallIds:new Set},F=o(a()((e,t)=>({...wt,showSecret:n=>{let{pendingSecret:r}=t();if(r&&r.requestId===n.requestId){let t={};for(let e of Object.keys(n))n[e]!==void 0&&(t[e]=n[e]);e({pendingSecret:{...r,...t}});return}e({pendingSecret:n,isSubmittingSecret:!1,secretSaved:!1})},submitSecretStart:()=>e({isSubmittingSecret:!0}),submitSecretEnd:t=>e({isSubmittingSecret:!1,secretSaved:t??!1}),dismissSecret:()=>e({pendingSecret:null,isSubmittingSecret:!1}),updateSecret:(n,r)=>{let{pendingSecret:i}=t();!i||i.requestId!==n||e({pendingSecret:{...i,...r}})},showConfirmation:t=>e({pendingConfirmation:t,isSubmittingConfirmation:!1}),submitConfirmationStart:()=>e({isSubmittingConfirmation:!0}),submitConfirmationEnd:()=>e({isSubmittingConfirmation:!1}),dismissConfirmation:()=>e({pendingConfirmation:null,isSubmittingConfirmation:!1}),dismissConfirmationIfMatches:n=>{let{pendingConfirmation:r}=t();!r||r.requestId!==n||e({pendingConfirmation:null,isSubmittingConfirmation:!1})},updateConfirmation:(n,r)=>{let{pendingConfirmation:i}=t();!i||i.requestId!==n||e({pendingConfirmation:{...i,...r}})},setInlineConfirmationToolCallId:t=>e({inlineConfirmationToolCallId:t}),showContactRequest:t=>e({pendingContactRequest:t,isSubmittingContactRequest:!1,contactRequestAccepted:!1}),submitContactRequestStart:()=>e({isSubmittingContactRequest:!0}),submitContactRequestEnd:()=>e({isSubmittingContactRequest:!1}),dismissContactRequest:()=>e({pendingContactRequest:null,isSubmittingContactRequest:!1}),acceptContactRequest:()=>e({contactRequestAccepted:!0}),showQuestion:t=>e({pendingQuestion:t,isSubmittingQuestion:!1,isQuestionCardDismissed:!1}),submitQuestionStart:()=>e({isSubmittingQuestion:!0}),submitQuestionEnd:()=>e({isSubmittingQuestion:!1}),dismissQuestion:()=>e({pendingQuestion:null,isSubmittingQuestion:!1,isQuestionCardDismissed:!1}),dismissQuestionCard:()=>e({isQuestionCardDismissed:!0}),resetSecretAndConfirmation:()=>e({pendingSecret:null,isSubmittingSecret:!1,secretSaved:!1,pendingConfirmation:null,isSubmittingConfirmation:!1,inlineConfirmationToolCallId:null}),showAcpConnect:t=>e(e=>e.dismissedAcpConnectToolUseIds.has(t.toolUseId)?{}:{pendingAcpConnect:t}),dismissAcpConnect:()=>e(e=>({pendingAcpConnect:null,dismissedAcpConnectToolUseIds:e.pendingAcpConnect?new Set(e.dismissedAcpConnectToolUseIds).add(e.pendingAcpConnect.toolUseId):e.dismissedAcpConnectToolUseIds})),requestAcpContinue:()=>e({pendingAcpContinue:!0}),clearAcpContinue:()=>e({pendingAcpContinue:!1}),addUnknownNudgeToolCallId:n=>{let r=t().unknownNudgeToolCallIds;r.has(n)||e({unknownNudgeToolCallIds:new Set([...r,n])})},removeUnknownNudgeToolCallId:n=>{let r=t().unknownNudgeToolCallIds;if(!r.has(n))return;let i=new Set(r);i.delete(n),e({unknownNudgeToolCallIds:i})},resetAll:()=>e(wt)})));function Tt(e){if(e.length===0)return``;let t=e[0]??``;for(let n=1;n<e.length;n++){let r=t[t.length-1],i=e[n][0];r&&i&&r!==` `&&r!==`
2
2
  `&&r!==` `&&i!==` `&&i!==`
3
3
  `&&i!==` `&&(t+=` `),t+=e[n]}return t}function Et(e){let t=[];for(let n of e?.contentBlocks??[])n.type===`text`&&t.push(n.text);return Tt(t)}function Dt(e){if(!(!e||e.length===0))return e.map(e=>{let{previewUrl:t,thumbnailUrl:n}=d(e.mimeType,e.data,e.thumbnailData,e.id!=null);return{id:e.id??e.filename,filename:e.filename,mimeType:e.mimeType,sizeBytes:e.sizeBytes??(e.data?Math.floor(e.data.length*3/4):0),previewUrl:t,thumbnailUrl:n}})}function I(e){let t=e[e.length-1];return!!t&&t.role===`assistant`}function Ot(e,t){if(!t)return null;let n=e.length-1;for(;n>=0&&e[n].role===`user`&&e[n].queueStatus===`queued`;)n--;let r=e[n];return!r||r.role!==`assistant`?null:r.id}function L(e,t){return e.findIndex(e=>e.role===`assistant`&&(e.id===t||!!e.mergedMessageIds?.includes(t)))}function R(e,t){if(!t||e.id===t)return e;let n=e.mergedMessageIds??[];return n.includes(t)?e:{...e,mergedMessageIds:[...n,t]}}function z(e,t=Date.now()){if(!e.toolCalls?.some(e=>p(e)))return null;let n=t;return{toolCalls:e.toolCalls.map(e=>p(e)?{...e,completedAt:n}:e),contentBlocks:e.contentBlocks?.map(e=>e.type===`tool_use`&&p(e.toolCall)?{type:`tool_use`,toolCall:{...e.toolCall,completedAt:n}}:e)}}function kt(e,t,n){return e.map(e=>e.id===t?{...e,queuePosition:n}:e)}function At(e,t){return e.map(e=>e.id===t?{...e,queueStatus:void 0,queuePosition:void 0}:e)}function jt(e,t){return e.filter(e=>e.id!==t)}function Mt(e,t,n,r=Date.now()){return[...e,{id:n??crypto.randomUUID(),...n?{}:{isOptimistic:!0},role:`assistant`,textSegments:[t],contentOrder:[{type:`text`,id:`0`}],contentBlocks:[{type:`text`,text:t}],timestamp:r}]}function Nt(e,t,n){n&&e[e.length-1]?.type===t.type?e[e.length-1]=t:e.push(t)}function B(e,t,n,r){let i=R(e[t],r),a=[...i.textSegments??[]],o=[...i.contentOrder??[]],s=[...i.contentBlocks??[]],c=o[o.length-1]?.type===`text`&&a.length>0;c?a[a.length-1]=a[a.length-1]+n:(o.push({type:`text`,id:String(a.length)}),a.push(n)),Nt(s,{type:`text`,text:a[a.length-1]},c);let l=[...e];return l[t]={...i,textSegments:a,contentOrder:o,contentBlocks:s},l}function V(e,t,n,r){let i=R(e[t],r),a=[...i.thinkingSegments??[]],o=[...i.contentOrder??[]],s=[...i.contentBlocks??[]],c=o[o.length-1]?.type===`thinking`&&a.length>0;c?a[a.length-1]=a[a.length-1]+n:(o.push({type:`thinking`,id:String(a.length)}),a.push(n)),Nt(s,{type:`thinking`,thinking:a[a.length-1]},c);let l=[...e];return l[t]={...i,thinkingSegments:a,contentOrder:o,contentBlocks:s},l}function Pt(e,t,n,r,i=Date.now()){if(n){let a=L(e,n);if(a>=0)return B(e,a,t,n);if(I(e))return B(e,e.length-1,t,n);let o=r?.();return o?B([...e,o],e.length,t,n):Mt(e,t,n,i)}return I(e)?B(e,e.length-1,t,void 0):Mt(e,t,n,i)}function Ft(e,t,n,r=Date.now()){return[...e,{id:n??crypto.randomUUID(),...n?{}:{isOptimistic:!0},role:`assistant`,thinkingSegments:[t],contentOrder:[{type:`thinking`,id:`0`}],contentBlocks:[{type:`thinking`,thinking:t}],timestamp:r}]}function It(e,t,n,r,i=Date.now()){if(n){let a=L(e,n);if(a>=0)return V(e,a,t,n);if(I(e))return V(e,e.length-1,t,n);let o=r?.();return o?V([...e,o],e.length,t,n):Ft(e,t,n,i)}return I(e)?V(e,e.length-1,t,void 0):Ft(e,t,n,i)}function Lt(e,t=Date.now()){let n=!1,r=e.map(e=>{if(e.role!==`assistant`)return e;let r=z(e,t);return r?(n=!0,{...e,...r}):e});return n?r:e}function Rt(e,t,n=Date.now()){let r=e[e.length-1],i=Dt(t.attachments);if(r?.role!==`assistant`)return i?[...e,{id:t.messageId??crypto.randomUUID(),...t.messageId?{}:{isOptimistic:!0},role:`assistant`,timestamp:n,attachments:i}]:e;let a=z(r,n),o=r.isOptimistic===!0&&!!t.messageId;return[...e.slice(0,-1),{...r,...o?{id:t.messageId,isOptimistic:!1}:{},...i?{attachments:i}:{},...a??{}}]}function zt(e,t){if(t!==void 0)return e.findIndex(e=>e.role===`user`&&e.clientMessageId===t);for(let t=e.length-1;t>=0;t--){let n=e[t];if(n&&n.role===`user`&&n.isOptimistic===!0)return t}return-1}function Bt(e,t,n=Date.now()){let r=t.messageId;if(r!==void 0&&e.some(e=>e.role===`user`&&(e.id===r||e.mergedMessageIds?.includes(r))))return e;let i=zt(e,t.clientMessageId);if(i!==-1){if(r===void 0)return e;let t=[...e];return t[i]={...t[i],id:r,isOptimistic:!1,queueStatus:void 0,queuePosition:void 0},t}return[...e,{id:r??crypto.randomUUID(),...r===void 0?{isOptimistic:!0}:{},...t.clientMessageId?{clientMessageId:t.clientMessageId}:{},role:`user`,textSegments:[t.text],contentOrder:[{type:`text`,id:`0`}],contentBlocks:[{type:`text`,text:t.text}],timestamp:n}]}function Vt(e,t=Date.now()){let n=e.length-1,r=e[n];if(!r||r.role!==`assistant`)return e;let i=z(r,t);if(!(Et(r).trim().length>0||r.thinkingSegments!=null&&r.thinkingSegments.length>0||r.toolCalls!=null&&r.toolCalls.length>0||r.surfaces!=null&&r.surfaces.length>0))return e.slice(0,-1);let a=[...e];return a[n]={...r,...i??{}},a}function H(e,t){let n=[...e??[]],r=n.findIndex(e=>e.type===`tool_use`&&e.toolCall.id===t.id);return r===-1?n.push({type:`tool_use`,toolCall:t}):n[r]={type:`tool_use`,toolCall:t},n}function U(e,t,n,r){let i=R(e[t],r),a=i.toolCalls?.findIndex(e=>e.id===n.id)??-1,o=[...e];if(a!==-1){let e=[...i.toolCalls??[]],r={...e[a],...n};return e[a]=r,o[t]={...i,toolCalls:e,contentBlocks:H(i.contentBlocks,r)},o}return o[t]={...i,toolCalls:[...i.toolCalls??[],n],contentOrder:[...i.contentOrder??[],{type:`toolCall`,id:n.id}],contentBlocks:H(i.contentBlocks,n)},o}function Ht(e,t,n,r=Date.now()){if(n){let r=L(e,n);if(r>=0)return U(e,r,t,n);if(I(e))return U(e,e.length-1,t,n)}else if(I(e))return U(e,e.length-1,t);return[...e,{id:n??crypto.randomUUID(),...n?{}:{isOptimistic:!0},role:`assistant`,toolCalls:[t],contentOrder:[{type:`toolCall`,id:t.id}],contentBlocks:[{type:`tool_use`,toolCall:t}],timestamp:r}]}function Ut(e,t){let n=-1,r=-1;if(t.toolUseId)for(let i=e.length-1;i>=0;i--){let a=e[i];if(a?.role!==`assistant`||!a.toolCalls?.length)continue;let o=a.toolCalls.findIndex(e=>e.id===t.toolUseId);if(o!==-1){n=i,r=o;break}}if(n===-1){if(n=e.findLastIndex(e=>e.role===`assistant`&&e.toolCalls&&e.toolCalls.length>0),n===-1)return e;let t=e[n];if(!t?.toolCalls)return e;r=t.toolCalls.findLastIndex(e=>p(e))}if(r===-1)return e;let i=e[n],a=i.toolCalls[r];if(!a)return e;let o=t.imageDataList===void 0?t.imageData===void 0?void 0:[t.imageData]:t.imageDataList,s=t.imageData===void 0?o?.[0]:t.imageData,c=[...i.toolCalls],l={...a,result:t.result,isError:t.isError,riskLevel:t.riskLevel,riskReason:t.riskReason,matchedTrustRuleId:t.matchedTrustRuleId,approvalMode:t.approvalMode,approvalReason:t.approvalReason,riskThreshold:t.riskThreshold,riskAllowlistOptions:t.riskAllowlistOptions,riskScopeOptions:t.riskScopeOptions,riskDirectoryScopeOptions:t.riskDirectoryScopeOptions,...s===void 0?{}:{imageData:s},...o===void 0?{}:{imageDataList:o},...t.activityMetadata===void 0?{}:{activityMetadata:t.activityMetadata},...t.errorCode===void 0?{}:{errorCode:t.errorCode},completedAt:t.completedAt??Date.now(),streamedOutput:void 0};c[r]=l;let u=[...e];return u[n]={...i,toolCalls:c,contentBlocks:H(i.contentBlocks,l)},u}var Wt=16384;function Gt(e){return e.length<=16384?e:e.slice(e.length-Wt)}function Kt(e,t){if(!t.chunk)return e;let n=-1,r=-1;if(t.toolUseId){if(t.messageId){let i=L(e,t.messageId);if(i>=0){let a=e[i].toolCalls?.findIndex(e=>e.id===t.toolUseId)??-1;a!==-1&&(n=i,r=a)}}if(n===-1)for(let i=e.length-1;i>=0;i--){let a=e[i];if(a?.role!==`assistant`||!a.toolCalls?.length)continue;let o=a.toolCalls.findIndex(e=>e.id===t.toolUseId);if(o!==-1){n=i,r=o;break}}}else{if(n=e.findLastIndex(e=>e.role===`assistant`&&e.toolCalls&&e.toolCalls.length>0),n===-1)return e;let t=e[n];if(!t?.toolCalls)return e;r=t.toolCalls.findLastIndex(e=>p(e))}if(n===-1||r===-1)return e;let i=e[n],a=i.toolCalls[r];if(!a)return e;let o={...a,streamedOutput:Gt((a.streamedOutput??``)+t.chunk)},s=[...i.toolCalls];s[r]=o;let c=[...e];return c[n]={...i,toolCalls:s,contentBlocks:H(i.contentBlocks,o)},c}function qt(e,t,n,r=Date.now()){let i=-1;if(n&&(i=L(e,n)),i===-1){for(let t=e.length-1;t>=0;t--)if(e[t]?.role===`assistant`){i=t;break}}let a=[...e];if(i===-1)a.push({id:n??crypto.randomUUID(),...n?{}:{isOptimistic:!0},role:`assistant`,surfaces:[t],contentOrder:[{type:`surface`,id:t.surfaceId}],contentBlocks:[{type:`surface`,surface:t}],timestamp:r});else{let r=R(e[i],n);if(r.contentOrder?.some(e=>e.type===`surface`&&e.id===t.surfaceId)||r.surfaces?.some(e=>e.surfaceId===t.surfaceId))return e;a[i]={...r,surfaces:[...r.surfaces??[],t],contentOrder:[...r.contentOrder??[],{type:`surface`,id:t.surfaceId}],contentBlocks:N(r.contentBlocks,t)}}return a}function Jt(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r],a=i.surfaces?.findIndex(e=>e.surfaceId===t)??-1;if(a===-1)continue;let o=i.surfaces[a],s={...o.data,...n};o.data.templateData&&n.templateData&&typeof o.data.templateData==`object`&&typeof n.templateData==`object`&&(s.templateData={...o.data.templateData,...n.templateData});let c={...o,data:s},l=[...e],u=[...i.surfaces];return u[a]=c,l[r]={...i,surfaces:u,contentBlocks:N(i.contentBlocks,c)},l}return e}function Yt(e,t){for(let n=e.length-1;n>=0;n--){if(!e[n].surfaces?.some(e=>e.surfaceId===t))continue;let r=[...e];return r[n]={...e[n],surfaces:e[n].surfaces?.filter(e=>e.surfaceId!==t),contentOrder:e[n].contentOrder?.filter(e=>!(e.type===`surface`&&e.id===t)),contentBlocks:$e(e[n].contentBlocks,t)},r}return e}function Xt(e,t,n){for(let r=e.length-1;r>=0;r--){let i=e[r].surfaces?.find(e=>e.surfaceId===t);if(!i)continue;let a={...i,completed:!0,completionSummary:n},o=[...e];return o[r]={...e[r],surfaces:e[r].surfaces?.map(e=>e.surfaceId===t?a:e),contentBlocks:N(e[r].contentBlocks,a)},o}return e}var Zt=[`choice`,`oauth_connect`,`form`,`confirmation`,`file_upload`,`card`,`list`,`table`,`browser_view`,`task_preferences`];function Qt(e){return e==null||e.hasPendingConfirmation||e.hasUncompletedVisibleSurface}function $t(e,t){let n=!1,r=e.map(e=>{let r=ie(e,e=>e.pendingConfirmation?.requestId===t?{...e,pendingConfirmation:void 0}:e);return r!==e&&(n=!0),r});return n?r:e}function en(e){let t=!1,n=e.map(e=>{let n=ie(e,e=>e.pendingConfirmation?{...e,pendingConfirmation:void 0}:e);return n!==e&&(t=!0),n});return t?n:e}function tn(e,t){let n=new Set;for(let e of t)if(e.surfaces)for(let t of e.surfaces)re(t)&&n.add(t.surfaceId);return n.size===0?{updatedMessages:e,dismissedIds:n}:{updatedMessages:e.map(e=>tt(e,e=>!n.has(e.surfaceId))),dismissedIds:n}}function nn(e,t,n,r){for(let i=e.length-1;i>=0;i--){let a=e[i].surfaces?.find(e=>e.surfaceId===t);if(!a)continue;if(!Zt.includes(a.surfaceType))return e;let o=a.actions?.find(e=>e.id===n),s=n===`cancel`||n===`dismiss`||o?.style===`secondary`,c=[...e];return c[i]=et(e[i],e=>e.surfaceId===t?{...e,completed:!0,completionSummary:s?`Cancelled`:r??o?.label??void 0}:e),c}return e}function rn(e,t,n){return e&&ne[e]||t||n}function W(e){return typeof e==`string`?e:void 0}function an(e){return typeof e==`boolean`?e:void 0}function on(e){return Array.isArray(e)?e:void 0}function sn(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function G(e){return Array.isArray(e)?e:void 0}function cn(e){return{requestId:typeof e.requestId==`string`?e.requestId:``,label:W(e.label),service:W(e.service),field:W(e.field),description:W(e.description),placeholder:W(e.placeholder),allowOneTimeSend:an(e.allowOneTimeSend),allowedTools:on(e.allowedTools),allowedDomains:on(e.allowedDomains),purpose:W(e.purpose)}}function ln(e){let t={requestId:typeof e.requestId==`string`?e.requestId:``,title:W(e.title),description:W(e.description),toolName:W(e.toolName),riskLevel:W(e.riskLevel),riskReason:W(e.riskReason),allowlistOptions:G(e.allowlistOptions),scopeOptions:G(e.scopeOptions),directoryScopeOptions:G(e.directoryScopeOptions),persistentDecisionsAllowed:an(e.persistentDecisionsAllowed),input:sn(e.input),toolUseId:W(e.toolUseId)};return{confData:t,state:{...t,confirmLabel:W(e.confirmLabel),denyLabel:W(e.denyLabel)}}}function un(){return`turn-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function dn(e,t){let n=Date.parse(e);return Number.isFinite(n)?n:typeof t==`number`?t:0}function fn(e,t,n){switch(t.type){case`assistant_text_delta`:return Pt(e,t.text,t.messageId,void 0,n);case`assistant_thinking_delta`:return It(e,t.thinking,t.messageId,void 0,n);case`message_complete`:return Rt(e,t,n);case`user_message_echo`:return Bt(e,{text:t.text,messageId:t.messageId,clientMessageId:t.clientMessageId},n);case`assistant_activity_state`:return t.phase===`idle`?Lt(e,n):e;case`conversation_error`:return Vt(e,n);case`tool_use_preview_start`:return Ht(e,{id:t.toolUseId,name:t.toolName,input:{},previewStartedAt:typeof t.previewStartedAt==`number`?t.previewStartedAt:n},t.messageId,n);case`tool_use_start`:return Ht(e,{id:t.toolUseId??`tool-${n}`,name:t.toolName,input:t.input,startedAt:`startedAt`in t&&typeof t.startedAt==`number`?t.startedAt:n,...`previewStartedAt`in t&&typeof t.previewStartedAt==`number`?{previewStartedAt:t.previewStartedAt}:{}},t.messageId,n);case`tool_result`:return Ut(e,{toolUseId:t.toolUseId,result:t.result,isError:t.isError,riskLevel:t.riskLevel,riskReason:t.riskReason,matchedTrustRuleId:t.matchedTrustRuleId,approvalMode:t.approvalMode,approvalReason:t.approvalReason,riskThreshold:t.riskThreshold,riskAllowlistOptions:t.riskAllowlistOptions,riskScopeOptions:t.riskScopeOptions,riskDirectoryScopeOptions:t.riskDirectoryScopeOptions,imageData:t.imageData,imageDataList:t.imageDataList,activityMetadata:t.activityMetadata,errorCode:t.errorCode,completedAt:`completedAt`in t&&typeof t.completedAt==`number`?t.completedAt:n});case`tool_output_chunk`:return t.chunk?Kt(e,{chunk:t.chunk,toolUseId:t.toolUseId,messageId:t.messageId}):e;case`ui_surface_show`:{let r={surfaceId:t.surfaceId,surfaceType:t.surfaceType,title:t.title,data:t.data,actions:t.actions,display:t.display};return r.display=f(r),qt(e,r,t.messageId,n)}case`ui_surface_update`:return Jt(e,t.surfaceId,t.data);case`ui_surface_dismiss`:return Yt(e,t.surfaceId);case`ui_surface_complete`:return Xt(e,t.surfaceId,t.summary);case`confirmation_request`:return te(e,{requestId:t.requestId,toolName:t.toolName,riskLevel:t.riskLevel,riskReason:t.riskReason,allowlistOptions:t.allowlistOptions,scopeOptions:t.scopeOptions,directoryScopeOptions:t.directoryScopeOptions,persistentDecisionsAllowed:t.persistentDecisionsAllowed,input:t.input,toolUseId:t.toolUseId}).updatedMessages;case`interaction_resolved`:return t.kind===`confirmation`||t.kind===`acp_confirmation`?$t(e,t.requestId):e;default:return e}}function pn(e,t,n){if(e!==void 0){if(typeof n!=`number`)return e;switch(t.type){case`assistant_turn_start`:case`assistant_text_delta`:case`assistant_thinking_delta`:return!0;case`assistant_activity_state`:return t.phase!==`idle`;case`message_complete`:return!1;default:return e}}}function mn(e,t){let{seq:n}=t;if(typeof n==`number`&&typeof e.seq==`number`&&n<=e.seq)return e;let r=dn(t.emittedAt,n),i=fn(e.messages,t.message,r),a=typeof n==`number`?Math.max(e.seq??-1,n):e.seq??null,o=pn(e.processing,t.message,n);return{...e,messages:i,seq:a,processing:o}}function hn(e,t){return t.reduce(mn,e)}function gn(e,t){return t===null?e:hn(e,t)}function _n(e){return[...new Set([e.id,...e.mergedMessageIds??[]].filter(e=>typeof e==`string`&&e.length>0))]}function K(e){let t=_n(e);return e.clientMessageId&&!t.includes(e.clientMessageId)?[...t,e.clientMessageId]:t}var vn={hasMore:!1,oldestTimestamp:null,isLoadingOlder:!1};function yn(){return{snapshot:null,optimisticSends:[],error:null,notice:null,isLoadingHistory:!0,transcriptPagination:{...vn},contextWindowUsage:null,ephemeralMetaResults:[],compactionCircuitOpenUntil:null,dismissedSurfaceIds:new Set,streamingMessageIds:new Set,pendingQueuedMessageIds:[],requestIdToMessageId:new Map,pendingLocalDeletions:new Set,confirmationToolCallMap:new Map,expandedToolCallIds:new Set,expandedCardIds:new Map,contextWindowUsageByConversation:new Map,previousConversationId:null,previousAssistantId:null,draftConversationIdResolution:!1}}function q(e,t){return typeof t==`function`?t(e):t}function bn(e,t){if(e.length===0)return e;let n=new Map;for(let e of t)for(let t of K(e))n.has(t)||n.set(t,e);let r=e.filter(e=>{let t;for(let r of K(e))if(t=n.get(r),t)break;return t?!!e.attachments?.length&&!t.attachments?.length:!0});return r.length===e.length?e:r}var J=o(a()((e,t)=>({...yn(),seedSnapshot:(n,r)=>{let i=t().snapshot;if(r.seq==null&&i!==null&&typeof i.seq==`number`){c(`history_seed_skipped_anchorless`,{conversationId:n,liveSeq:i.seq});return}let a=be(n,r.seq??null);if(a===null&&i!==null&&typeof i.seq==`number`&&typeof r.seq==`number`&&r.seq<i.seq){c(`history_seed_skipped_stale_anchor`,{conversationId:n,liveSeq:i.seq,fetchedSeq:r.seq});return}let o=gn(r,a);e(e=>({snapshot:o,optimisticSends:bn(e.optimisticSends,o.messages)}))},applyEnvelopeToSnapshot:t=>e(e=>e.snapshot?{snapshot:mn(e.snapshot,t)}:{}),addOptimisticSend:t=>e(e=>({optimisticSends:[...e.optimisticSends,t]})),setOptimisticSends:t=>e(e=>({optimisticSends:q(e.optimisticSends,t)})),patchSnapshotMessages:t=>e(e=>e.snapshot?{snapshot:{...e.snapshot,messages:t(e.snapshot.messages)}}:{}),setError:t=>e(e=>({error:q(e.error,t)})),setNotice:t=>e(e=>({notice:q(e.notice,t)})),setIsLoadingHistory:t=>e({isLoadingHistory:t}),setTranscriptPagination:t=>e(e=>({transcriptPagination:q(e.transcriptPagination,t)})),setContextWindowUsage:t=>e(e=>({contextWindowUsage:q(e.contextWindowUsage,t)})),setCompactionCircuitOpenUntil:t=>e(e=>({compactionCircuitOpenUntil:q(e.compactionCircuitOpenUntil,t)})),switchToConversation:({assistantId:n,activeConversationId:r})=>{let i=t();if(i.draftConversationIdResolution){e({draftConversationIdResolution:!1});return}let a=i.previousConversationId;if(a&&a!==r&&a){let e=F.getState();(e.pendingSecret||e.pendingConfirmation)&&u.getState().addAttentionConversationId(a)}let o=i.previousAssistantId!==null&&i.previousAssistantId!==n,s=o||i.previousAssistantId===null;c(`conversation_switch_reset`,{assistantId:n,conversationId:r,outgoingConversationId:a??null}),M.getState().handleConversationSwitch({previousKey:a??null,nextKey:r}),we.getState().resetTurn(),F.getState().resetAll(),o?M.getState().fullReset():M.getState().resetAttachments();let l=s?ut(n):i.contextWindowUsageByConversation;e({snapshot:null,optimisticSends:[],ephemeralMetaResults:[],error:P(i.error)?i.error:null,notice:null,isLoadingHistory:!0,transcriptPagination:{...vn},contextWindowUsage:l.get(r)??null,compactionCircuitOpenUntil:null,dismissedSurfaceIds:it(n,r),streamingMessageIds:new Set,pendingQueuedMessageIds:[],requestIdToMessageId:new Map,pendingLocalDeletions:new Set,confirmationToolCallMap:new Map,expandedToolCallIds:new Set,expandedCardIds:new Map,contextWindowUsageByConversation:l,previousConversationId:r,previousAssistantId:n,draftConversationIdResolution:!1})},markDraftResolution:()=>e({draftConversationIdResolution:!0}),setConfirmationToolCall:(t,n)=>e(e=>{let r=new Map(e.confirmationToolCallMap);return r.set(t,n),{confirmationToolCallMap:r}}),deleteConfirmationToolCall:t=>e(e=>{let n=new Map(e.confirmationToolCallMap);return n.delete(t),{confirmationToolCallMap:n}}),clearConfirmationToolCallMap:()=>e({confirmationToolCallMap:new Map}),addDismissedSurfaceId:t=>e(e=>{let n=new Set(e.dismissedSurfaceIds);return n.add(t),{dismissedSurfaceIds:n}}),addDismissedSurfaceIds:t=>e(e=>{let n=new Set(e.dismissedSurfaceIds);for(let e of t)n.add(e);return{dismissedSurfaceIds:n}}),batchUpdateStreamingMessageIds:(t,n)=>e(e=>{let r=new Set(e.streamingMessageIds);for(let e of t)r.add(e);for(let e of n)r.delete(e);return{streamingMessageIds:r}}),pushPendingQueuedMessageId:t=>e(e=>({pendingQueuedMessageIds:[...e.pendingQueuedMessageIds,t]})),shiftPendingQueuedMessageId:()=>{let n=t().pendingQueuedMessageIds;if(n.length===0)return;let[r,...i]=n;return e({pendingQueuedMessageIds:i}),r},setRequestIdMapping:(t,n)=>e(e=>{let r=new Map(e.requestIdToMessageId);return r.set(t,n),{requestIdToMessageId:r}}),popRequestIdMapping:n=>{let r=t().requestIdToMessageId,i=r.get(n);if(i!==void 0){let t=new Map(r);t.delete(n),e({requestIdToMessageId:t})}return i},addPendingLocalDeletion:t=>e(e=>{let n=new Set(e.pendingLocalDeletions);return n.add(t),{pendingLocalDeletions:n}}),consumePendingLocalDeletion:n=>{let r=t().pendingLocalDeletions;if(!r.has(n))return!1;let i=new Set(r);return i.delete(n),e({pendingLocalDeletions:i}),!0},setExpandedToolCallId:(t,n)=>e(e=>{let r=new Set(e.expandedToolCallIds);return n?r.add(t):r.delete(t),{expandedToolCallIds:r}}),setExpandedCardId:(t,n)=>e(e=>{let r=new Map(e.expandedCardIds);return r.set(t,n),{expandedCardIds:r}}),setContextWindowUsageForConversation:(t,n)=>e(e=>{let r=new Map(e.contextWindowUsageByConversation);return r.set(t,n),{contextWindowUsageByConversation:r}}),addEphemeralMetaResult:t=>e(e=>({ephemeralMetaResults:[...e.ephemeralMetaResults,t]})),clearEphemeralMetaResults:()=>e(e=>e.ephemeralMetaResults.length===0?e:{ephemeralMetaResults:[]})})));function xn(e,t){if(t.length===0)return e;let n=new Map;for(let e of t)for(let t of K(e))n.has(t)||n.set(t,e);let r=[],i=new Set;for(let t of e){let e;for(let r of K(t)){let t=n.get(r);if(t){e=t;break}}if(e){i.has(e)||(r.push(e),i.add(e));continue}r.push(t)}for(let e of t)i.has(e)||r.push(e);return r}function Sn(){let e=J.use.snapshot(),t=J.use.optimisticSends(),n=J.use.dismissedSurfaceIds();return(0,le.useMemo)(()=>xn(st(e?.messages,n),t),[e,t,n])}function Y(e,t,n=`…`){return e.length<=t?e:e.slice(0,t-n.length)+n}function Cn(e){if(!e)return null;let t=e.split(`/`),n=t[t.length-1];return!n||n===`.`?null:n}function X(e,t){return Y(e,t,`...`)}function wn(e){if(!e)return null;let t=e.replace(/\s+/g,` `).trim().match(/(?:^|&&\s*|\|\|\s*|;\s*)(?:\S*\/)?assistant\s+browser\s+([^\s;&|]+)/i);if(!t)return null;let n=t[1].toLowerCase();return new Set([`navigate`,`click`,`type`,`screenshot`,`snapshot`,`scroll`,`hover`,`select`,`drag`,`wait`,`back`,`forward`,`refresh`,`close`,`tab`,`press_key`,`wait_for`,`extract`,`fill_credential`]).has(n)?n:`unknown`}function Z(e,t){let n=e.toLowerCase();return n!==`bash`&&n!==`host_bash`?null:wn(t)}function Tn(e){switch(e){case`navigate`:return`Opened a page`;case`click`:return`Clicked on the page`;case`type`:return`Typed on the page`;case`screenshot`:return`Took a screenshot`;case`snapshot`:return`Captured page snapshot`;case`scroll`:return`Scrolled the page`;case`hover`:return`Hovered on the page`;case`select`:return`Selected on the page`;case`drag`:return`Dragged on the page`;case`wait`:return`Waited for the page`;case`back`:return`Went back`;case`forward`:return`Went forward`;case`refresh`:return`Refreshed the page`;case`close`:return`Closed the tab`;case`tab`:return`Switched tabs`;case`press_key`:return`Pressed a key`;case`wait_for`:return`Waited for a condition`;case`extract`:return`Extracted page content`;case`fill_credential`:return`Filled a credential`;case`unknown`:return`Used the browser`}}function En(e){switch(e){case`navigate`:return`Opening a page`;case`click`:return`Clicking on the page`;case`type`:return`Typing on the page`;case`screenshot`:return`Taking a screenshot`;case`snapshot`:return`Capturing page snapshot`;case`scroll`:return`Scrolling the page`;case`hover`:return`Hovering on the page`;case`select`:return`Selecting on the page`;case`drag`:return`Dragging on the page`;case`wait`:return`Waiting for the page`;case`back`:return`Going back`;case`forward`:return`Going forward`;case`refresh`:return`Refreshing the page`;case`close`:return`Closing the tab`;case`tab`:return`Switching tabs`;case`press_key`:return`Pressing a key`;case`wait_for`:return`Waiting for a condition`;case`extract`:return`Extracting page content`;case`fill_credential`:return`Filling a credential`;case`unknown`:return`Using the browser`}}function Dn(e){switch(e){case`navigate`:case`back`:case`forward`:case`tab`:return`compass`;case`click`:case`hover`:case`select`:case`drag`:case`scroll`:return`compass`;case`screenshot`:case`snapshot`:return`camera`;case`type`:case`press_key`:case`fill_credential`:return`compass`;case`wait`:case`wait_for`:case`refresh`:case`close`:return`compass`;case`extract`:return`compass`;case`unknown`:return`compass`}}function On(e,t){let n=e.toLowerCase();if(n===`bash`||n===`host_bash`){let e=t.command??t.cmd;if(typeof e==`string`)return e.replace(/\s+/g,` `).trim()}if(n===`file_read`||n===`host_file_read`||n===`file_write`||n===`host_file_write`||n===`file_edit`||n===`host_file_edit`){let e=t.file_path??t.path??t.filePath;if(typeof e==`string`)return e}if(n===`grep`||n===`glob`){let e=t.pattern??t.query;if(typeof e==`string`)return e}if(n===`web_search`){let e=t.query??t.search;if(typeof e==`string`)return e}return``}function kn(e,t=``){let n=e.toLowerCase(),r=t.replace(/\s+/g,` `).trim(),i=Cn(r),a=Z(e,r);if(a)return Tn(a);switch(n){case`bash`:case`host_bash`:return r?`Ran \`${X(r,30)}\``:`Ran a command`;case`file_read`:case`host_file_read`:return i?`Read ${i}`:`Read a file`;case`file_write`:case`host_file_write`:return i?`Wrote ${i}`:`Wrote a file`;case`file_edit`:case`host_file_edit`:return i?`Edited ${i}`:`Edited a file`;case`grep`:return r?`Searched for '${X(r,25)}'`:`Searched files`;case`glob`:return r?`Searched for ${X(r,25)}`:`Found files`;case`web_search`:return r?`Searched '${X(r,25)}'`:`Searched the web`;case`web_fetch`:return`Fetched a webpage`;default:return`Used ${e.replace(/_/g,` `)}`}}function An(e,t=``,n){let r=Z(e,t);if(r)return En(r);if(n){let t=e.toLowerCase();if(t===`app_create`||t===`app_refresh`||t===`app_update`)return n}switch(e.toLowerCase()){case`bash`:case`host_bash`:return`Running a command`;case`file_read`:case`host_file_read`:return`Reading a file`;case`file_write`:case`host_file_write`:return`Writing a file`;case`file_edit`:case`host_file_edit`:return`Editing a file`;case`grep`:return`Searching files`;case`glob`:return`Finding files`;case`web_search`:return`Searching the web`;case`web_fetch`:return`Fetching a webpage`;case`app_create`:return`Building your app`;case`app_refresh`:case`app_update`:return`Refreshing your app`;default:return`Running ${e.replace(/_/g,` `)}`}}function jn(e){return e.split(/[_-]+/).filter(e=>e.length>0).map(e=>e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()).join(` `)}function Mn(e,t=``){let n=Z(e,t);if(n)return Dn(n);switch(e.toLowerCase()){case`bash`:case`host_bash`:return`terminal`;case`file_read`:case`host_file_read`:return`file-text`;case`file_write`:case`host_file_write`:return`file-plus`;case`file_edit`:case`host_file_edit`:return`pencil`;case`grep`:case`glob`:case`web_search`:return`search`;case`web_fetch`:return`globe`;default:return`wrench`}}var Nn=80;function Q(e,...t){for(let n of t){let t=e[n];if(typeof t==`string`&&t.trim().length>0)return t}return``}function Pn(e){if(!e)return``;let t=e.replace(/\/+$/,``),n=t.lastIndexOf(`/`);return n===-1?t:t.slice(n+1)}function Fn(e){if(!e.startsWith(`mcp__`))return null;let t=e.slice(5),n=t.indexOf(`__`);if(n===-1)return null;let r=t.slice(0,n),i=t.slice(n+2);return!r||!i?null:{serverName:r,toolMethod:i}}function $(e,t){let n=t&&typeof t==`object`?t:{},r=e.toLowerCase(),i=Q(n,`activity`,`reason`),a=Fn(e);if(a)return{title:`Using ${a.serverName}`,info:a.toolMethod,activity:i,iconName:`plug`};switch(r){case`bash`:case`host_bash`:return{title:`Working`,info:Y(Q(n,`command`,`cmd`).replace(/\s+/g,` `).trim(),Nn),activity:i,iconName:`terminal`};case`str_replace_editor`:case`text_editor`:{let e=Q(n,`command`).toLowerCase(),t=Pn(Q(n,`path`,`file_path`,`filePath`));return e===`view`?{title:`Reading`,info:t,activity:i,iconName:`file`}:{title:`Editing`,info:t,activity:i,iconName:`pen`}}case`computer`:return{title:`Using computer`,info:Q(n,`action`),activity:i,iconName:`monitor`};case`skill_execute`:{let e=Q(n,`tool`);if(e){let t=n.input,r=$(e,t);return{...r,activity:i||r.activity}}return{title:`Using a skill`,info:Q(n,`skill`,`name`,`skillName`),activity:i,iconName:`sparkle`}}case`skill`:case`skill_invoke`:case`skill_load`:return{title:`Using a skill`,info:Q(n,`skill`,`name`,`skillName`),activity:i,iconName:`sparkle`};case`subagent_spawn`:return{title:`Spawning subagent`,info:Q(n,`label`,`objective`,`task`),activity:i,iconName:`user-plus`};default:return{title:e?`Running ${jn(e)}`:`Running tool`,info:``,activity:i,iconName:`bolt`}}}function In(e){return $(e.name,e.input)}var Ln=[{open:`<thinking>`,close:`</thinking>`},{open:`<think>`,close:`</think>`}];function Rn(e){return Ln.some(t=>e.includes(t.open))}function zn(e){if(!Rn(e))return null;let t=[],n=e=>{e.trim()&&t.push({type:`text`,text:e})},r=e=>{let n=e.trim();n&&t.push({type:`thinking`,thinking:n})},i=0;for(;;){let a=-1,o;for(let t of Ln){let n=e.indexOf(t.open,i);n!==-1&&(a===-1||n<a)&&(a=n,o=t)}if(!o)break;n(e.slice(i,a));let s=a+o.open.length,c=e.indexOf(o.close,s);if(c===-1)return r(e.slice(s)),t;r(e.slice(s,c)),i=c+o.close.length}return n(e.slice(i)),t}function Bn(e){return typeof e.id==`string`&&e.id.length>0}function Vn(e){return e.some(e=>e.type===`text`&&Rn(e.text))?e.flatMap(e=>{let t=e.type===`text`?zn(e.text):null;return t?t.map(e=>e.type===`thinking`?{type:`thinking`,thinking:e.thinking}:{type:`text`,text:e.text}):[e]}):e}function Hn(e,t){let n=t?.splitInlineThinking?Vn(e):e,r=[],i=null,a=()=>(i||(i={type:`activity`,items:[]},r.push(i)),i);for(let e of n)if(e.type===`thinking`){let t=a(),n=t.items[t.items.length-1];n?.type===`thinking`?(n.thinking=n.thinking?`${n.thinking}\n${e.thinking}`:e.thinking,e.startedAt!=null&&(n.startedAt=n.startedAt==null?e.startedAt:Math.min(n.startedAt,e.startedAt)),e.completedAt!=null&&(n.completedAt=n.completedAt==null?e.completedAt:Math.max(n.completedAt,e.completedAt))):t.items.push({type:`thinking`,thinking:e.thinking,startedAt:e.startedAt,completedAt:e.completedAt})}else if(e.type===`tool_use`){if(!Bn(e.toolCall))continue;a().items.push({type:`tool_use`,toolCall:e.toolCall})}else (e.type===`text`||e.type===`surface`)&&(i=null,r.push(e));return r}function Un(e){let t=[],n=[];for(let r of e){if(r.type===`thinking`){r.thinking&&t.push({kind:`thinking`,text:r.thinking,startedAt:r.startedAt,completedAt:r.completedAt});continue}let e=r.toolCall;Wn(e)||(n.push(e),t.push({kind:`toolCall`,toolCall:e}))}return{cardItems:t,toolCalls:n}}function Wn(e){return!e.pendingConfirmation&&(e.name===`ui_show`||e.name===`ui_update`||e.name===`ui_dismiss`)}function Gn(e){if(e.name===`subagent_spawn`)return!0;if(e.name!==`skill_execute`)return!1;let t=e.input;return typeof t!=`object`||!t?!1:t.tool===`subagent_spawn`}function Kn(e){if(e.name===`run_workflow`)return!0;if(e.name!==`skill_execute`)return!1;let t=e.input;return typeof t!=`object`||!t?!1:t.tool===`run_workflow`}function qn(e){if(e.name===`acp_spawn`)return!0;if(e.name!==`skill_execute`)return!1;let t=e.input;return typeof t!=`object`||!t?!1:t.tool===`acp_spawn`}function Jn(e){if(e.name!==`bash`&&e.name!==`host_bash`)return!1;let t=e.input;return typeof t!=`object`||!t?!1:t.background===!0}var Yn=new Set([`low`,`medium`,`high`]);function Xn(e){let t=e?.toLowerCase();return t&&Yn.has(t)?t:`medium`}function Zn(e){switch(e?.toLowerCase()){case`low`:return{bg:`bg-[var(--system-positive-strong)]`,text:`text-white`,label:`Low`};case`medium`:return{bg:`bg-[var(--system-mid-strong)]`,text:`text-black`,label:`Medium`};case`high`:return{bg:`bg-[var(--system-negative-strong)]`,text:`text-white`,label:`High`};case`workspace`:return{bg:`bg-[var(--surface-lift)]`,text:`text-[var(--content-secondary)]`,border:`border border-[var(--border-element)]`,label:`Workspace`};default:return{bg:`bg-[var(--content-secondary)]`,text:`text-white`,label:e??`Unknown`}}}function Qn(e){switch(e?.toLowerCase()){case`low`:return`Auto-approved at Conservative tolerance or higher`;case`medium`:return`Auto-approved at Relaxed tolerance or higher`;case`high`:return`Auto-approved only at Full Access tolerance`;default:return}}function $n(e){switch(e?.toLowerCase()){case`low`:return{bg:`bg-[var(--system-positive-weak)]`,text:`text-[var(--system-positive-strong)]`,label:`Low`};case`medium`:return{bg:`bg-[var(--system-mid-weak)]`,text:`text-[var(--system-mid-strong)]`,label:`Medium`};case`high`:return{bg:`bg-[var(--system-negative-weak)]`,text:`text-[var(--system-negative-strong)]`,label:`High`};case`workspace`:return{bg:`bg-[var(--surface-lift)]`,text:`text-[var(--content-secondary)]`,label:`Workspace`};default:return{bg:`bg-[var(--surface-lift)]`,text:`text-[var(--content-secondary)]`,label:e?e.charAt(0).toUpperCase()+e.slice(1):`Unknown`}}}var er={unknown:2,low:0,medium:1,high:2},tr={none:-1,low:0,medium:1,high:2};function nr(e,t,n){return e?.toLowerCase()!==`auto`||!n?!0:(er[(t??``).toLowerCase()]??-1)<=(tr[n.toLowerCase()]??-1)}function rr(e){switch(e){case`trust_rule_allowed`:return`· Auto-approved · Trust rule matched`;case`sandbox_auto_approve`:return null;case`platform_auto_approve`:return`· Auto-approved · Platform session`;default:return null}}function ir(e,t){return e===`sandbox_auto_approve`?{displayLevel:`workspace`,inherentRisk:t}:{displayLevel:t??`unknown`}}export{Je as $,tn as A,I as B,xn as C,$t as D,K as E,Qt as F,St as G,F as H,At as I,at as J,P as K,Ot as L,ln as M,cn as N,en as O,rn as P,Ye as Q,jt as R,Sn as S,_n as T,xt as U,Et as V,Ct as W,Qe as X,et as Y,Xe as Z,An as _,Qn as a,ve as at,jn as b,Un as c,pe as ct,Jn as d,fe as dt,M as et,Kn as f,ce as ft,On as g,$ as h,ae as ht,$n as i,xe as it,un as j,nn as k,Hn as l,he as lt,In as m,oe as mt,rr as n,Ce as nt,Xn as o,ye as ot,Gn as p,se as pt,dt as q,Zn as r,we as rt,nr as s,_e as st,ir as t,v as tt,qn as u,me as ut,Mn as v,J as w,Y as x,kn as y,kt as z};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-anSemq95.js";import{t as n}from"./react-DJZBPgpf.js";import{P as r,t as i}from"./button-CW7wKp2r.js";import{f as a,u as o}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./useQuery-B45lW1Kk.js";import{t as l}from"./jsx-runtime-CVSDxk6A.js";import{t as u}from"./typography-1kyF_Eu1.js";import{n as d,t as f}from"./settings-wSv59mkN.js";import{t as p}from"./chart-column-L6Nldm8M.js";import{t as m}from"./chevron-down-DpYf9Gwq.js";import{r as h,t as g}from"./panel-item-D1WbMkez.js";import{t as _}from"./clock-LiCGqvyn.js";import{t as v}from"./loader-circle-Ck8fq3yv.js";import{t as y}from"./repeat-BhXOPeQU.js";import{t as b}from"./x-CswtfvgS.js";import{t as x}from"./notice-CvJ7MBx5.js";import{i as S,j as C}from"./src-BT0gNVcT.js";import{t as w}from"./tag-CJyI1Y2J.js";import{n as T,t as E}from"./input-D3MhHg0d.js";import{t as D}from"./toggle-Ca1aoG-l.js";import{t as O}from"./modal-D_Y2RPD5.js";import{n as k}from"./toast-zHo1wvF9.js";import{t as A}from"./dropdown-DQozlhbb.js";import{F as j,M,N,P,Vt as F,Xt as ee,Yt as te,_ as ne,c as I,d as L,dt as re,ft as ie,g as R,j as ae,mt as oe,pt as se,ut as ce,v as le,y as ue}from"./react-query.gen-DfzfX_Jv.js";import{u as z}from"./routes-D4ff4ONd.js";import{t as de}from"./effective-timezone-Ct3PoWNH.js";import{t as B}from"./assistant-feature-flag-store-Bh-_qc7v.js";import{As as fe,Ha as pe,J as me,Ua as he,Vo as ge,Wa as _e,Wt as ve,Xs as ye,lr as V,ts as be}from"./index-C7ix_asE.js";import{t as xe}from"./detail-card-CAHT277C.js";import{a as Se,c as Ce,i as we,l as Te,n as Ee,o as De,r as Oe,s as ke,t as Ae,u as je}from"./page-empty-state-DhwyXbFT.js";import{r as Me,t as Ne}from"./profile-metadata-C6i7Ro9a.js";var H=e(n(),1),Pe={frequency:`daily`,minute:0,hour24:9,weekdays:[1],dayOfMonth:1},U=[{value:0,letter:`S`,short:`Sun`,full:`Sunday`},{value:1,letter:`M`,short:`Mon`,full:`Monday`},{value:2,letter:`T`,short:`Tue`,full:`Tuesday`},{value:3,letter:`W`,short:`Wed`,full:`Wednesday`},{value:4,letter:`T`,short:`Thu`,full:`Thursday`},{value:5,letter:`F`,short:`Fri`,full:`Friday`},{value:6,letter:`S`,short:`Sat`,full:`Saturday`}],Fe=[1,2,3,4,5];function W(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function Ie(e){let t=Array.from(new Set(e.map(e=>W(e,0,6)).filter(e=>Number.isInteger(e)))).sort((e,t)=>e-t);return t.length>0?t:[1]}function Le(e){let t=W(e.minute,0,59),n=W(e.hour24,0,23);switch(e.frequency){case`hourly`:return`${t} * * * *`;case`daily`:return`${t} ${n} * * *`;case`weekly`:return`${t} ${n} * * ${Ie(e.weekdays).join(`,`)}`;case`monthly`:return e.dayOfMonth===`last`?`${t} ${n} L * *`:`${t} ${n} ${W(e.dayOfMonth,1,28)} * *`}}function Re(e,t){let n=W(e,0,23),r=W(t,0,59),i=n<12?`AM`:`PM`;return`${n%12==0?12:n%12}:${String(r).padStart(2,`0`)} ${i}`}function ze(e){let t=[`th`,`st`,`nd`,`rd`],n=e%100;return`${e}${t[(n-20)%10]??t[n]??t[0]}`}function Be(e){let t=Ie(e),n=new Set(t);if(t.length===7)return`every day`;if(t.length===5&&Fe.every(e=>n.has(e)))return`every weekday`;if(t.length===2&&n.has(0)&&n.has(6))return`every weekend`;if(t.length===1)return`every ${U[t[0]]?.full??`day`}`;let r=t.map(e=>U[e]?.short??``),i=r.pop();return`every ${r.join(`, `)} & ${i}`}function Ve(e){let t=Re(e.hour24,e.minute);switch(e.frequency){case`hourly`:{let t=W(e.minute,0,59);return`Runs every hour at :${String(t).padStart(2,`0`)}`}case`daily`:return`Runs every day at ${t}`;case`weekly`:return`Runs ${Be(e.weekdays)} at ${t}`;case`monthly`:return e.dayOfMonth===`last`?`Runs on the last day of every month at ${t}`:`Runs on the ${ze(W(e.dayOfMonth,1,28))} of every month at ${t}`}}var G=l(),He=[{value:`hourly`,label:`Hourly`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}],Ue=Array.from({length:12},(e,t)=>{let n=t+1;return{value:String(n),label:String(n)}}),We=Array.from({length:12},(e,t)=>{let n=t*5,r=String(n).padStart(2,`0`);return{value:r,label:r}}),Ge=[...Array.from({length:28},(e,t)=>{let n=t+1;return{value:String(n),label:ze(n)}}),{value:`last`,label:`Last day`}],Ke=[{value:`AM`,label:`AM`},{value:`PM`,label:`PM`}];function qe(e,t){let n=e%12;return t===`PM`?n+12:n}function Je(e){try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value;return t&&t!==e?`${e} · ${t}`:e}catch{return e}}function Ye({isOpen:e,assistantId:t,onClose:n,onCreated:r}){return(0,G.jsx)(O.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,G.jsx)(Xe,{assistantId:t,onClose:n,onCreated:r}):null})}function Xe({assistantId:e,onClose:t,onCreated:n}){let r=V(),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(``),[d,f]=(0,H.useState)(`simple`),[p,m]=(0,H.useState)(Pe),[h,g]=(0,H.useState)(``),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(null),x=a.trim(),S=s.trim(),C=l.trim(),w=h.trim(),D=(0,H.useMemo)(()=>d===`simple`?Le(p):w,[d,p,w]),k=(0,H.useMemo)(()=>d===`simple`?Ve(p):w||`Enter a cron expression to continue.`,[d,p,w]),A=(0,H.useMemo)(()=>Je(r),[r]),j=x.length>0&&S.length>0&&C.length>0&&D.length>0&&!_;return(0,G.jsxs)(O.Content,{size:`md`,children:[(0,G.jsxs)(O.Header,{children:[(0,G.jsx)(O.Title,{children:`Create schedule`}),(0,G.jsx)(O.Description,{children:`Schedule a recurring instruction for your assistant. Runs in execute mode — the message is delivered to the assistant on each fire.`})]}),(0,G.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),j){v(!0),b(null);try{await Ee(e,{name:x,description:S,expression:D,message:C,timezone:r}),v(!1),n()}catch(e){b(e instanceof Error?e.message:`Failed to create schedule.`),v(!1)}}},children:[(0,G.jsx)(O.Body,{children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,G.jsx)(E,{label:`Name`,placeholder:`Morning briefing`,value:a,onChange:e=>o(e.target.value),required:!0,autoFocus:!0,fullWidth:!0}),(0,G.jsx)(T,{label:`Description`,placeholder:`What is this schedule for?`,value:s,onChange:e=>c(e.target.value),required:!0,fullWidth:!0,rows:2}),(0,G.jsx)(tt,{label:`Repeat`,children:d===`simple`?(0,G.jsx)(Ze,{cadence:p,onChange:m}):(0,G.jsx)(et,{value:h,onChange:g,onUseSimple:()=>f(`simple`)})}),(0,G.jsx)(nt,{summary:k,mono:d===`advanced`&&w.length>0,timezoneLabel:A}),d===`simple`?(0,G.jsx)(`button`,{type:`button`,onClick:()=>{g(e=>e||Le(p)),f(`advanced`)},className:`self-start text-body-small-default text-[var(--content-tertiary)] underline-offset-2 transition-colors hover:text-[var(--content-default)] hover:underline`,children:`Advanced — write a cron expression`}):null,(0,G.jsx)(T,{label:`Message`,placeholder:`What should the assistant do on each fire?`,value:l,onChange:e=>u(e.target.value),required:!0,fullWidth:!0,rows:4}),y?(0,G.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:y}):null]})}),(0,G.jsxs)(O.Footer,{children:[(0,G.jsx)(i,{variant:`outlined`,onClick:t,type:`button`,children:`Cancel`}),(0,G.jsx)(i,{variant:`primary`,type:`submit`,disabled:!j,children:_?`Creating…`:`Create schedule`})]})]})]})}function Ze({cadence:e,onChange:t}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(C,{items:He,value:e.frequency,onChange:n=>t({...e,frequency:n}),ariaLabel:`How often the schedule runs`}),e.frequency===`hourly`?(0,G.jsx)(K,{label:`At minute`,children:(0,G.jsx)(A,{options:We,value:String(e.minute).padStart(2,`0`),onChange:n=>t({...e,minute:Number(n)}),"aria-label":`Minute`,className:`w-24`})}):null,e.frequency===`weekly`?(0,G.jsx)(K,{label:`On these days`,children:(0,G.jsx)($e,{value:e.weekdays,onChange:n=>t({...e,weekdays:n})})}):null,e.frequency===`monthly`?(0,G.jsx)(K,{label:`On day`,children:(0,G.jsx)(A,{options:Ge,value:e.dayOfMonth===`last`?`last`:String(e.dayOfMonth),onChange:n=>t({...e,dayOfMonth:n===`last`?`last`:Number(n)}),"aria-label":`Day of month`,className:`w-32`})}):null,e.frequency===`hourly`?null:(0,G.jsx)(K,{label:`At time`,children:(0,G.jsx)(Qe,{hour24:e.hour24,minute:e.minute,onChange:(n,r)=>t({...e,hour24:n,minute:r})})})]})}function Qe({hour24:e,minute:t,onChange:n}){let r=e<12?`AM`:`PM`,i=e%12==0?12:e%12;return(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(A,{options:Ue,value:String(i),onChange:e=>n(qe(Number(e),r),t),"aria-label":`Hour`,className:`w-[72px]`}),(0,G.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`:`}),(0,G.jsx)(A,{options:We,value:String(t).padStart(2,`0`),onChange:t=>n(e,Number(t)),"aria-label":`Minute`,className:`w-[72px]`}),(0,G.jsx)(`div`,{className:`w-[112px]`,children:(0,G.jsx)(C,{items:Ke,value:r,onChange:e=>n(qe(i,e),t),ariaLabel:`AM or PM`})})]})}function $e({value:e,onChange:t}){let n=new Set(e),i=e=>{let r=new Set(n);r.has(e)?r.size>1&&r.delete(e):r.add(e),t([...r].sort((e,t)=>e-t))};return(0,G.jsx)(`div`,{className:`flex gap-1.5`,children:U.map(e=>{let t=n.has(e.value);return(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(e.value),"aria-pressed":t,"aria-label":e.full,title:e.full,className:r(`flex h-9 w-9 items-center justify-center rounded-md border text-body-medium-default transition-colors`,t?`border-[var(--border-active)] bg-[var(--surface-active)] text-[var(--content-emphasised)]`:`border-[var(--field-border)] text-[var(--content-tertiary)] hover:border-[var(--border-active)] hover:text-[var(--content-default)]`),children:e.letter},e.value)})})}function et({value:e,onChange:t,onUseSimple:n}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(E,{placeholder:`0 9 * * *`,value:e,onChange:e=>t(e.target.value),fullWidth:!0,className:`font-mono`,"aria-label":`Cron expression`,helperText:`Standard 5-field cron (minute hour day month weekday). RRULE expressions are also accepted.`}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`self-start text-body-small-default text-[var(--content-tertiary)] underline-offset-2 transition-colors hover:text-[var(--content-default)] hover:underline`,children:`← Back to the simple builder`})]})}function tt({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:e}),t]})}function K({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,G.jsx)(`span`,{className:`min-w-[88px] text-body-small-default text-[var(--content-tertiary)]`,children:e}),t]})}function nt({summary:e,mono:t,timezoneLabel:n}){return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-lift)] px-3.5 py-3`,children:[(0,G.jsx)(_,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:r(`text-body-medium-default text-[var(--content-default)]`,t&&`break-all font-mono`),children:e}),(0,G.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[`Times use your timezone — `,n,`.`]})]})]})}function rt(e=de(),t=Date.now()){return Me(`7d`,e,t)}function q(e){return e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0}):`—`}function it(e){return e==null?`—`:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}var at=new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:2});function J(e){return e==null||!Number.isFinite(e)?`—`:at.format(e)}function Y(e){return`${e.toLocaleString()} ${e===1?`run`:`runs`}`}function ot(e){let t=Math.round(e/6e4);return t>=60&&t%60==0?`Every ${t/60} hr`:`Every ${t} min`}function st(e){if(!e)return;let t=new Set,n=[];for(let r of e)for(let e of r.runs)t.has(e.id)||(t.add(e.id),n.push(e));return n}function ct(e){return!!e.conversationId&&e.conversationExists===!0&&e.conversationArchivedAt==null}function lt(e){return ct(e)?e.conversationId??null:null}function X(e){return typeof e==`string`&&e.length>0}var ut={heartbeat:`system-heartbeat`,consolidation:`system-consolidation`,retrospective:`system-memory-retrospective`};function dt(e){if(e.cronExpression)return e.timezone?`Cron: ${e.cronExpression} (${e.timezone})`:`Cron: ${e.cronExpression}`;let t=ot(e.intervalMs);return e.activeHoursStart!=null&&e.activeHoursEnd!=null&&(t+=` (${e.activeHoursStart}:00–${e.activeHoursEnd}:00)`),t}function ft(e){return ot(e.intervalMs)}var pt=`After conversation activity`;function mt(e,t){return e.status===`fired`||e.status===`cancelled`?!0:e.status===`firing`?!1:e.nextRunAt==null||!e.enabled&&e.nextRunAt<=t}function ht(e,t){let n=[],r=[],i=[];for(let a of e)a.isOneShot?mt(a,t)?i.push(a):r.push(a):n.push(a);return n.sort((e,t)=>e.enabled===t.enabled?(e.nextRunAt??1/0)-(t.nextRunAt??1/0):e.enabled?-1:1),r.sort((e,t)=>(e.nextRunAt??1/0)-(t.nextRunAt??1/0)),i.sort((e,t)=>{let n=e.lastRunAt??e.nextRunAt??0;return(t.lastRunAt??t.nextRunAt??0)-n}),{recurring:n,upcomingOneTime:r,pastOneTime:i}}function gt(e,t,n=!0){return{queryKey:[{_id:`schedulesUsagesummaryGet`,path:{assistant_id:e??``},_tz:t}],queryFn:()=>e?Se(e,rt(t)):Promise.resolve([]),enabled:n,staleTime:1e4}}function _t(e){return{scheduleId:e,runCount:0,totalEstimatedCostUsd:0,eventCount:0}}function vt(e,t,n){let r=(t??[]).filter(e=>{let t=e.startedAt??e.createdAt;return t>=n.from&&t<=n.to});return{scheduleId:e,runCount:r.length,totalEstimatedCostUsd:r.reduce((e,t)=>{let n=t.estimatedCostUsd;return typeof n==`number`&&Number.isFinite(n)?e+n:e},0),eventCount:0}}function yt({status:e}){return(0,G.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:e===`ok`||e===`completed`?`var(--system-positive-strong)`:e===`error`||e===`failed`?`var(--system-negative-strong)`:`var(--content-tertiary)`},"aria-label":e??`unknown`})}function bt({scheduleName:e,usage:t,onOpenUsage:n}){if(t.status===`loading`)return(0,G.jsxs)(`div`,{"aria-label":`Loading schedule usage`,className:`flex w-[156px] shrink-0 items-center justify-end gap-3`,children:[(0,G.jsx)(`span`,{className:`h-5 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,G.jsx)(`span`,{className:`h-5 w-16 animate-pulse rounded bg-[var(--surface-muted)]`})]});let r=t.status===`error`,i=r?`--`:J(t.summary.totalEstimatedCostUsd),a=r?`--`:Y(t.summary.runCount),o=t.status===`ready`&&!(t.summary.totalEstimatedCostUsd>0),s=t.status===`ready`&&t.summary.runCount===0,c=o?`text-[var(--content-tertiary)]`:`text-[var(--content-default)]`,l=s?`text-[var(--content-tertiary)]`:`text-[var(--content-default)]`;return(0,G.jsxs)(`div`,{className:`flex w-[156px] shrink-0 items-center justify-end gap-3 text-right text-body-small-default`,children:[n?(0,G.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`View usage for ${e}`,className:`min-w-[64px] cursor-pointer rounded px-1 py-0.5 text-right transition-colors hover:bg-[var(--surface-hover)] ${c}`,children:i}):(0,G.jsx)(`span`,{"aria-label":`Cost for ${e} in the last 7 days: ${i}`,className:`block min-w-[64px] px-1 py-0.5 ${c}`,children:i}),(0,G.jsx)(`span`,{"aria-label":`Runs for ${e} in the last 7 days: ${a}`,className:`block min-w-[64px] px-1 py-0.5 ${l}`,children:a})]})}function xt({name:e,subtitle:t,enabled:n,nextRunAt:r,lastRunAt:i,usage:a,helperText:o,statusLabel:s,statusTone:c=`neutral`,onClick:l}){return(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-md px-2 py-3 transition-colors hover:bg-[var(--surface-hover)] [&+&]:border-t [&+&]:border-[var(--border-base)]`,children:(0,G.jsxs)(`button`,{type:`button`,onClick:l,"aria-label":`Open ${e}`,className:`flex min-w-0 flex-1 cursor-pointer flex-wrap items-center gap-3 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e})}),(0,G.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:t}),o?(0,G.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-secondary)]`,children:o}):null,(0,G.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-body-small-default text-[var(--content-tertiary)]`,children:[r?(0,G.jsxs)(`span`,{children:[`Next: `,q(r)]}):null,i?(0,G.jsxs)(`span`,{children:[`Last: `,q(i)]}):null]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-3`,children:[(0,G.jsx)(bt,{scheduleName:e,usage:a}),s?(0,G.jsx)(w,{tone:c,children:s}):(0,G.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:n?`var(--system-positive-strong)`:`var(--content-disabled)`},"aria-label":n?`enabled`:`disabled`}),(0,G.jsx)(h,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]})})}function St({heartbeatConfig:e,consolidationConfig:t,retrospectiveConfig:n,heartbeatUsage:r,consolidationUsage:i,retrospectiveUsage:a,isLoading:o,hasError:s,onRetry:c,onSelectHeartbeat:l,onSelectConsolidation:u,onSelectRetrospective:d}){let f=e!=null,p=t?.available===!0,h=n?.available===!0,g=f||p||h;if(!o&&!s&&!g)return null;let _=[...f?[r]:[],...p?[i]:[],...h?[a]:[]].filter(e=>e.status===`ready`),y=_.reduce((e,t)=>e+(t.summary.totalEstimatedCostUsd??0),0),b=o?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(v,{className:`h-5 w-5 animate-spin text-stone-400`})}):s&&!g?(0,G.jsxs)(x,{tone:`error`,children:[`Failed to load system jobs.`,` `,(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]}):(0,G.jsxs)(`div`,{children:[f?(0,G.jsx)(xt,{name:`Heartbeat`,subtitle:dt(e),enabled:e.enabled,nextRunAt:e.nextRunAt,lastRunAt:e.lastRunAt,usage:r,onClick:l}):null,p?(0,G.jsx)(xt,{name:`Consolidation`,subtitle:ft(t),enabled:t.enabled,helperText:t.enabled?void 0:`Memory is off, so consolidation is paused.`,nextRunAt:t.nextRunAt,lastRunAt:t.lastRunAt,usage:i,statusLabel:t.enabled?void 0:`Paused`,statusTone:`warning`,onClick:u}):null,h?(0,G.jsx)(xt,{name:`Memory retrospective`,subtitle:pt,enabled:n.enabled,helperText:n.enabled?void 0:`Memory is off, so retrospectives are paused.`,nextRunAt:n.nextRunAt,lastRunAt:n.lastRunAt,usage:a,statusLabel:n.enabled?void 0:`Paused`,statusTone:`warning`,onClick:d}):null,s?(0,G.jsx)(`div`,{className:`pt-3 first:pt-0`,children:(0,G.jsxs)(x,{tone:`error`,children:[`Some system jobs failed to load.`,` `,(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]})}):null]});return(0,G.jsx)(xe,{children:(0,G.jsx)(S.Root,{type:`multiple`,children:(0,G.jsxs)(S.Item,{value:`system-jobs`,children:[(0,G.jsxs)(S.Trigger,{className:`group justify-between gap-3`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1 text-left`,children:[(0,G.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`System`}),(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Built-in jobs managed by the assistant runtime`})]}),(0,G.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[_.length>0?(0,G.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[J(y),` (7d)`]}):null,(0,G.jsx)(m,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]})]}),(0,G.jsx)(S.Content,{children:(0,G.jsx)(`div`,{className:`mt-3`,children:b})})]})})})}function Z(e,t){return{id:e.id,jobId:t,status:e.status,startedAt:e.startedAt??e.scheduledFor,finishedAt:e.finishedAt,durationMs:e.durationMs,output:`skipReason`in e&&e.skipReason?`Skipped: ${e.skipReason}`:null,error:e.error,conversationId:e.conversationId,conversationExists:e.conversationExists,conversationArchivedAt:e.conversationArchivedAt,estimatedCostUsd:e.estimatedCostUsd,createdAt:e.createdAt,...`title`in e?{title:e.title}:{}}}function Ct(e){return e.runs.map(e=>Z(e,`heartbeat`))}function wt(e){return e.runs.map(e=>Z(e,`consolidation`))}function Tt(e){return e.runs.map(e=>Z(e,`retrospective`))}var Q=1e4;function Et(e,t,n,r,i){return e?{status:`loading`}:t?{status:`error`}:{status:`ready`,summary:vt(n,r,i)}}function Dt(e,n){let r=s(),i={path:{assistant_id:e??``}},{data:a,isLoading:o,isError:l,refetch:u}=c({...ae(i),enabled:!!e,staleTime:Q}),{data:d,isLoading:f,isError:p,refetch:m}=c({...R(i),enabled:!!e,staleTime:Q}),{data:h,isLoading:g,isError:_,refetch:v}=c({...ce(i),enabled:!!e,staleTime:Q}),y={path:{assistant_id:e??``},query:{limit:100}},{data:b,isLoading:x,isError:S,refetch:C}=c({...j(y),select:Ct,enabled:!!e&&a!=null,staleTime:Q}),{data:w,isLoading:T,isError:E,refetch:D}=c({...ue(y),select:wt,enabled:!!e&&d?.available===!0,staleTime:Q}),{data:O,isLoading:A,isError:N,refetch:ne}=c({...se(y),select:Tt,enabled:!!e&&h?.available===!0,staleTime:Q}),I=(0,H.useMemo)(()=>rt(n),[n]),L=(0,H.useMemo)(()=>Et(x,S,ut.heartbeat,b,I),[b,S,x,I]),re=(0,H.useMemo)(()=>Et(T,E,ut.consolidation,w,I),[w,E,T,I]),oe=(0,H.useMemo)(()=>Et(A,N,ut.retrospective,O,I),[O,N,A,I]),z=t=>{if(!e)return;let n={heartbeat:{config:ae(i).queryKey,runs:j(y).queryKey,infinite:P(i)},consolidation:{config:R(i).queryKey,runs:ue(y).queryKey,infinite:le(i)},retrospective:{config:ce(i).queryKey,runs:se(y).queryKey,infinite:ie(i)}}[t];r.invalidateQueries({queryKey:n.config}),r.invalidateQueries({queryKey:n.runs}),r.invalidateQueries({queryKey:n.infinite})},de=ee({onSuccess:e=>{e.ran?k.success(`Heartbeat started.`):k.info(`Heartbeat skipped.`)},onError:e=>{t(e,{context:`heartbeat_run_now`}),k.error(`Failed to run heartbeat.`)},onSettled:()=>z(`heartbeat`)}),B=F({onSuccess:e=>{e.ran?k.success(`Consolidation queued.`):k.info(`Consolidation already queued or running.`)},onError:e=>{t(e,{context:`consolidation_run_now`}),k.error(`Failed to run consolidation.`)},onSettled:()=>z(`consolidation`)}),fe=te({onSuccess:e=>{M(r,i,e),k.success(e.enabled?`Heartbeat enabled.`:`Heartbeat disabled.`)},onError:e=>{t(e,{context:`heartbeat_toggle`}),k.error(`Failed to toggle heartbeat.`)}});return{heartbeatConfig:a,consolidationConfig:d,retrospectiveConfig:h,heartbeatUsage:L,consolidationUsage:re,retrospectiveUsage:oe,isLoading:o||f||g,hasError:l||p||_,isHeartbeatRunning:de.isPending,isConsolidationRunning:B.isPending,isHeartbeatLoading:o,isHeartbeatError:l,isConsolidationLoading:f,isConsolidationError:p,isRetrospectiveLoading:g,isRetrospectiveError:_,refetchHeartbeat:u,refetchConsolidation:m,refetchRetrospective:v,runHeartbeatNow:()=>{e&&de.mutate({path:{assistant_id:e}})},runConsolidationNow:()=>{e&&B.mutate({path:{assistant_id:e}})},toggleHeartbeat:t=>{e&&fe.mutate({body:{enabled:t},path:{assistant_id:e}})},refetchAll:()=>{u(),m(),v(),C(),D(),ne()}}}function Ot({children:e}){return(0,G.jsx)(u,{variant:`label-small-default`,as:`div`,className:`mb-2 uppercase tracking-wider text-[var(--content-tertiary)]`,children:e})}function $({label:e,value:t}){return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-1`,children:[(0,G.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:e}),(0,G.jsx)(`span`,{className:`min-w-0 text-right text-body-medium-lighter text-[var(--content-default)]`,children:t})]})}function kt({icon:e,value:t,label:n}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] p-3`,children:[(0,G.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--surface-sunken)] text-[var(--content-secondary)]`,children:e}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-body-large-default text-[var(--content-default)]`,children:t}),(0,G.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:n})]})]})}function At({usage:e}){return e.status===`loading`?(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-3 pt-2`,children:Array.from({length:2},(e,t)=>(0,G.jsx)(`div`,{className:`h-[60px] animate-pulse rounded-lg bg-[var(--surface-muted)]`},t))}):e.status===`error`?null:(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 pt-2`,children:[(0,G.jsx)(kt,{icon:(0,G.jsx)(fe,{className:`h-4 w-4`}),value:J(e.summary.totalEstimatedCostUsd),label:`7 Day Cost`}),(0,G.jsx)(kt,{icon:(0,G.jsx)(y,{className:`h-4 w-4`}),value:Y(e.summary.runCount),label:`7 Day Runs`})]})}function jt(e){return e.exists&&e.archivedAt==null}function Mt({run:e,index:t,isExpanded:n,disableDirectOpen:i,onOpenConversation:a,onToggleDetails:o}){let s=lt(e),c=e.conversations??(s?[{id:s,title:null,exists:!0,archivedAt:null}]:[]),l=X(e.output),u=X(e.error),d=!i&&c.length===1&&jt(c[0])?c[0].id:null,f=!d&&(c.length>0||l||u),p=`schedule-run-details-${t}`,m=!!d||f,g=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yt,{status:e.status}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:q(e.startedAt)}),(0,G.jsxs)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[it(e.durationMs),` ·`,` `,J(e.estimatedCostUsd)]}),e.status===`error`&&e.error?(0,G.jsxs)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--system-negative-strong)]`,children:[e.error.slice(0,120),e.error.length>120?`…`:``]}):null]}),m?(0,G.jsx)(h,{className:r(`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform`,f&&n?`rotate-90`:``)}):null]}),_=f&&n?(0,G.jsx)(`div`,{id:p,className:`px-2 pb-3`,children:(0,G.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[c.length>0?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Conversations`}),(0,G.jsx)(`div`,{className:`space-y-1`,children:c.map(e=>jt(e)?(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(e.id),className:`block w-full truncate text-left text-body-small-default text-[var(--content-default)] hover:underline`,children:X(e.title)?e.title:`Conversation`},e.id):(0,G.jsxs)(`span`,{className:`block truncate text-body-small-default text-[var(--content-tertiary)] italic`,children:[X(e.title)?e.title:`Conversation`,` `,e.exists?`(archived)`:`(unavailable)`]},e.id))})]}):null,l?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,u?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null;return d?(0,G.jsx)(`div`,{children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(d),"aria-label":`Open conversation for run at ${q(e.startedAt)}`,className:`flex w-full cursor-pointer items-center gap-3 px-2 py-3 text-left shadow-none transition-colors hover:bg-[var(--surface-hover)] focus:outline-none`,children:g})}):f?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(e.id),"aria-label":`Toggle details for run at ${q(e.startedAt)}`,"aria-expanded":n,"aria-controls":p,className:`flex w-full cursor-pointer items-center gap-3 px-2 py-3 text-left shadow-none transition-colors hover:bg-[var(--surface-hover)] focus:outline-none`,children:g}),_]}):(0,G.jsx)(`div`,{className:`flex items-center gap-3 px-2 py-3`,children:g})}function Nt({runs:e,isLoading:t,disableDirectOpen:n,onOpenConversation:r}){let[i,a]=(0,H.useState)(null);return t?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,G.jsx)(v,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,G.jsx)(`p`,{className:`py-2 text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:`No runs yet.`}):(0,G.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.map((e,t)=>(0,G.jsx)(Mt,{run:e,index:t,isExpanded:i===e.id,disableDirectOpen:n,onOpenConversation:r,onToggleDetails:e=>a(t=>t===e?null:e)},e.id))})}function Pt({schedule:e,assistantId:n,usage:a,isMobile:s,onClose:l,onDeleted:d}){let f=o(),{data:m,isLoading:h}=c({queryKey:oe({path:{assistant_id:n,id:e.id}}),queryFn:()=>we(n,e.id),staleTime:1e4}),[g,_]=(0,H.useState)(!1),[y,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(!1),w=async()=>{_(!0);try{await De(n,e.id)}catch(e){t(e,{context:`schedule_run_now`}),k.error(`Failed to run schedule.`)}finally{_(!1)}},T=async()=>{C(!0);try{await Oe(n,e.id),d()}catch(e){t(e,{context:`schedule_delete`}),k.error(`Failed to delete schedule.`),C(!1),x(!1)}};return(0,G.jsxs)(`div`,{className:r(`flex h-full flex-col bg-[var(--surface-overlay)]`,!s&&`rounded-[var(--radius-xl)] border border-[var(--border-base)]`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsx)(u,{variant:`title-small`,className:`truncate text-[var(--content-default)]`,children:e.name})}),(0,G.jsx)(i,{variant:`ghost`,iconOnly:(0,G.jsx)(b,{}),onClick:l,"aria-label":`Close schedule details`,tooltip:`Close`,className:`shrink-0`})]}),(0,G.jsxs)(`div`,{className:`flex-1 space-y-6 overflow-y-auto px-[var(--app-spacing-lg)] py-[var(--app-spacing-lg)]`,children:[e.description?(0,G.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:e.description}):null,(0,G.jsxs)(`section`,{children:[(0,G.jsx)(Ot,{children:`Details`}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] px-4 py-2`,children:[e.cadenceDescription?(0,G.jsx)($,{label:`Cadence`,value:e.cadenceDescription}):null,(0,G.jsx)($,{label:`Mode`,value:e.mode}),(0,G.jsx)($,{label:`Status`,value:e.enabled?`Enabled`:`Disabled`}),(0,G.jsx)($,{label:`Next run`,value:q(e.nextRunAt)}),e.lastRunAt?(0,G.jsx)($,{label:`Last run`,value:(0,G.jsxs)(`span`,{className:`flex items-center justify-end gap-2`,children:[(0,G.jsx)(yt,{status:e.lastStatus}),q(e.lastRunAt)]})}):null]})]}),(0,G.jsx)(At,{usage:a}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(Ot,{children:`Recent runs`}),(0,G.jsx)(Nt,{runs:m?.runs,isLoading:h,disableDirectOpen:e.mode===`script`,onOpenConversation:e=>he(f,e)})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[y?(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(i,{variant:`ghost`,onClick:()=>x(!1),disabled:S,children:`Cancel`}),(0,G.jsx)(i,{variant:`danger`,onClick:()=>void T(),disabled:S,children:S?`Deleting…`:`Yes, delete`})]}):(0,G.jsx)(i,{variant:`dangerOutline`,leftIcon:(0,G.jsx)(ge,{className:`h-3.5 w-3.5`}),onClick:()=>x(!0),children:`Delete`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(i,{variant:`outlined`,leftIcon:(0,G.jsx)(p,{className:`h-3.5 w-3.5`}),onClick:()=>f(z.settings.usageForSchedule(e.id)),children:`View usage`}),e.mode===`script`?(0,G.jsx)(i,{variant:`primary`,leftIcon:g?(0,G.jsx)(v,{className:`h-3.5 w-3.5 animate-spin`}):void 0,onClick:()=>void w(),disabled:g,children:g?`Running…`:`Run now`}):null]})]})]})}function Ft(e){if(e.status===`loading`)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`h-4 w-12 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,G.jsx)(`span`,{className:`h-4 w-10 animate-pulse rounded bg-[var(--surface-muted)]`})]});if(e.status===`error`)return(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`—`});let{summary:t}=e;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:J(t.totalEstimatedCostUsd)}),(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:Y(t.runCount)})]})}function It({name:e,metaParts:t,usage:n,enabled:r,selected:i,onClick:a,onToggle:o,toggleAriaLabel:s}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md px-2 py-3 transition-colors [&+&]:border-t [&+&]:border-[var(--border-base)] ${i?`bg-[var(--surface-active)]`:`hover:bg-[var(--surface-hover)]`}`,children:[o?(0,G.jsx)(D,{checked:r,onChange:o,"aria-label":s}):null,(0,G.jsxs)(`button`,{type:`button`,onClick:a,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-4 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e}),t.length>0?(0,G.jsx)(`span`,{className:`flex min-w-0 items-center gap-2 text-label-small-default text-[var(--content-tertiary)]`,children:t.map((e,t)=>(0,G.jsxs)(H.Fragment,{children:[t>0?(0,G.jsx)(`span`,{className:`h-[3px] w-[3px] shrink-0 rounded-full bg-[var(--content-tertiary)]`}):null,(0,G.jsx)(`span`,{className:`truncate`,children:e})]},t))}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4`,children:[Ft(n),(0,G.jsx)(h,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]})]})}function Lt({schedule:e,usage:t,selected:n,onClick:r,onToggle:i}){let a=e.isOneShot?``:e.cadenceDescription.trim(),o=e.lastRunAt??e.nextRunAt,s=[a,o?q(o):``].filter(Boolean);return(0,G.jsx)(It,{name:e.name,metaParts:s,usage:t,enabled:e.enabled,selected:n,onClick:r,onToggle:i,toggleAriaLabel:i?`Toggle ${e.name}`:void 0})}function Rt({recurring:e,oneTime:t,pastOneTime:n,usageForSchedule:r,isLoading:a,isError:o,refetch:s,onToggle:c,onSelectSchedule:l,selectedScheduleId:u,onStartNewChat:f,onCreateSchedule:p,pastOpen:m,onPastOpenChange:g,systemTasksSlot:_}){let v=e=>(0,G.jsx)(Lt,{schedule:e,usage:r(e.id),selected:e.id===u,onClick:()=>l(e.id),onToggle:t=>c(e.id,t)},e.id),y=e=>(0,G.jsx)(Lt,{schedule:e,usage:r(e.id),selected:e.id===u,onClick:()=>l(e.id)},e.id),b=n.length>0?(0,G.jsx)(S.Root,{type:`single`,collapsible:!0,className:`mt-3`,value:m?`past`:``,onValueChange:e=>g(e===`past`),children:(0,G.jsxs)(S.Item,{value:`past`,children:[(0,G.jsxs)(S.Trigger,{className:`group gap-[var(--app-spacing-xs)] px-2 text-label-small-default text-[var(--content-tertiary)]`,children:[(0,G.jsx)(h,{size:14,"aria-hidden":!0,className:`shrink-0 transition-transform group-data-[state=open]:rotate-90`}),(0,G.jsxs)(`span`,{children:[`Past (`,n.length,`)`]})]}),(0,G.jsx)(S.Content,{children:(0,G.jsx)(`div`,{className:`pt-1`,children:n.map(y)})})]})}):null;return(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[a?(0,G.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2},(e,t)=>(0,G.jsx)(`div`,{className:`h-12 animate-pulse rounded-md bg-[var(--surface-muted)]`},t))}):o&&e.length===0?(0,G.jsx)(x,{tone:`error`,actions:(0,G.jsx)(`button`,{type:`button`,onClick:s,className:`cursor-pointer underline hover:no-underline`,children:`Retry`}),children:`Failed to load schedules.`}):e.length===0&&t.length===0&&n.length===0?(0,G.jsx)(Ae,{icon:d,title:`No schedules yet`,description:`Ask your assistant to set one up, or create one yourself.`,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(i,{variant:`primary`,size:`regular`,onClick:f,children:`New Conversation`}),(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`or`}),(0,G.jsx)(i,{variant:`outlined`,size:`regular`,onClick:p,children:`Create schedule`})]})}):(0,G.jsxs)(`div`,{children:[e.map(v),t.length>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`mt-3 px-2 text-label-small-default text-[var(--content-tertiary)]`,children:`One-time`}),t.map(y)]}):null,b]}),_?(0,G.jsx)(`div`,{className:`mt-[var(--app-spacing-lg)]`,children:_}):null]})}var zt=`Default (assistant's main model)`,Bt=`Custom call-site model`;function Vt(e,t){return t?.[e]?.displayName??e}function Ht(e,t){if(e==null)return;if(e.provider!=null||e.model!=null)return Bt;let n=e.profile?.trim();return n?`Override (${Vt(n,t)})`:void 0}function Ut({assistantId:e,pinnedProfile:t,defaultCallSite:n=`mainAgent`,fallbackLabel:r=zt,respectCallSiteOverride:i=!1}){let a=t==null,{data:o}=c({...I({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4}),s=(0,H.useMemo)(()=>o?Ne(o):{},[o]),{data:l}=c({...L({path:{assistant_id:e}}),enabled:!!e&&a,staleTime:6e4}),u=a&&i?Ht(o?.llm?.callSites?.[n],s):void 0,d=a?l?.callSites.find(e=>e.id===n)?.defaultProfile:void 0,f=t==null?u??(d==null?r:`Default (${Vt(d,s)})`):Vt(t,s);return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Model profile`}),(0,G.jsx)(`span`,{className:`min-w-0 text-right`,children:f})]})}function Wt({runs:e,isLoading:t,emptyMessage:n=`No runs yet.`,hasMore:r=!1,isLoadingMore:a=!1,onLoadMore:s}){let c=o(),[l,u]=(0,H.useState)(null);return(0,G.jsx)(xe,{title:`Recent runs`,children:t?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(v,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,G.jsx)(`p`,{className:`py-4 text-center text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:n}):(0,G.jsxs)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:[e.map((e,t)=>{let n=lt(e),r=X(e.output),i=X(e.error),a=!n&&(r||i),o=l===e.id,s=`schedule-run-details-${t}`;return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(g,{label:(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,G.jsx)(yt,{status:e.status}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-body-medium-lighter text-[var(--content-default)]`,children:X(e.title)?e.title:q(e.startedAt)}),(0,G.jsxs)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[X(e.title)?`${q(e.startedAt)} · `:``,it(e.durationMs),` ·`,` `,J(e.estimatedCostUsd),e.status===`error`&&e.error&&(0,G.jsxs)(`span`,{className:`ml-2 text-[var(--system-negative-strong)]`,children:[e.error.slice(0,80),e.error.length>80?`…`:``]})]})]}),n||a?(0,G.jsx)(h,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform ${o?`rotate-90`:``}`}):null]}),onSelect:n?()=>he(c,n):a?()=>u(o?null:e.id):void 0,"aria-label":`Run at ${q(e.startedAt)}`,"aria-expanded":a?o:void 0,"aria-controls":a?s:void 0,className:`h-auto py-2.5 gap-3 -mx-2 px-2`}),a&&o?(0,G.jsx)(`div`,{id:s,className:`px-2 pb-3`,children:(0,G.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[r?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,i?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null]},e.id)}),r&&s?(0,G.jsx)(`div`,{className:`flex justify-center pt-3`,children:(0,G.jsx)(i,{variant:`outlined`,size:`compact`,onClick:s,disabled:a,leftIcon:a?(0,G.jsx)(v,{className:`h-3.5 w-3.5 animate-spin`}):void 0,children:a?`Loading…`:`Load more`})}):null]})})}var Gt={heartbeat:`heartbeatAgent`,consolidation:`memoryV2Consolidation`,retrospective:`memoryRetrospective`};function Kt({children:e}){return(0,G.jsx)(u,{variant:`label-small-default`,as:`div`,className:`mb-2 uppercase tracking-wider text-[var(--content-tertiary)]`,children:e})}function qt({kind:e,assistantId:t,systemTasks:n,canOpenMemorySettings:a,isMobile:s,onClose:c}){let l=o(),{heartbeatConfig:d,consolidationConfig:p,retrospectiveConfig:m}=n,h,g,_,y,S,C,w;e===`heartbeat`?(h=`Heartbeat`,g=d?dt(d):``,_=d?.enabled??!1,y=d?.nextRunAt??null,S=d?.lastRunAt??null,C=n.isHeartbeatRunning,w=n.runHeartbeatNow):e===`consolidation`?(h=`Consolidation`,g=p?ft(p):``,_=p?.enabled??!1,y=p?.nextRunAt??null,S=p?.lastRunAt??null,C=n.isConsolidationRunning,w=n.runConsolidationNow):(h=`Memory retrospective`,g=pt,_=m?.enabled??!1,y=m?.nextRunAt??null,S=m?.lastRunAt??null,C=!1,w=void 0);let T=e!==`heartbeat`,E=e===`retrospective`,O=T&&!_,k=C||O,A=T?_?`On · Managed by Memory`:`Paused`:_?`Enabled`:`Disabled`,j=E?`Memory is off, so retrospectives are paused. Turn Memory back on to resume them.`:`Memory is off, so consolidation is paused. Turn Memory back on to resume consolidation.`,M=T&&_&&a,P={path:{assistant_id:t},query:{limit:25}},F=e===`heartbeat`?N(P):e===`consolidation`?ne(P):re(P),{data:ee,isLoading:te,fetchNextPage:I,hasNextPage:L,isFetchingNextPage:ie}=ye({queryKey:F.queryKey,queryFn:F.queryFn,initialPageParam:{path:P.path,query:{}},getNextPageParam:e=>e.nextCursor??void 0,staleTime:1e4}),R=st(ee?.pages.map(t=>({runs:t.runs.map(t=>Z(t,e))})));return(0,G.jsxs)(`div`,{className:r(`flex h-full flex-col bg-[var(--surface-overlay)]`,!s&&`rounded-[var(--radius-xl)] border border-[var(--border-base)]`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(u,{variant:`title-small`,className:`truncate text-[var(--content-default)]`,children:h}),g?(0,G.jsx)(u,{variant:`body-small-default`,as:`p`,className:`truncate text-[var(--content-tertiary)]`,children:g}):null]}),(0,G.jsx)(i,{variant:`ghost`,iconOnly:(0,G.jsx)(b,{}),onClick:c,"aria-label":`Close schedule details`,tooltip:`Close`,className:`shrink-0`})]}),(0,G.jsxs)(`div`,{className:`flex-1 space-y-6 overflow-y-auto px-[var(--app-spacing-lg)] py-[var(--app-spacing-lg)]`,children:[(0,G.jsxs)(`section`,{children:[(0,G.jsx)(Kt,{children:`Details`}),(0,G.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] px-4 py-3 text-body-medium-lighter`,children:[(0,G.jsx)(Ut,{assistantId:t,defaultCallSite:Gt[e],fallbackLabel:`Default (system task model)`,respectCallSiteOverride:!0}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Status`}),(0,G.jsxs)(`span`,{className:`flex items-center gap-2 text-[var(--content-default)]`,children:[(0,G.jsx)(`span`,{children:A}),T?null:(0,G.jsx)(D,{checked:_,onChange:n.toggleHeartbeat,"aria-label":`Toggle ${h}`})]})]}),E?null:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Next run`}),(0,G.jsx)(`span`,{className:`text-[var(--content-default)]`,children:q(y)})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Last run`}),(0,G.jsx)(`span`,{className:`text-[var(--content-default)]`,children:q(S)})]})]}),O?(0,G.jsx)(x,{tone:`warning`,className:`mt-4`,actions:a?(0,G.jsx)(i,{variant:`outlined`,size:`compact`,onClick:()=>l(`${z.settings.developer}?tab=memory`),children:`Turn on Memory`}):void 0,children:j}):null]}),(0,G.jsx)(Wt,{runs:R,isLoading:te,hasMore:L,isLoadingMore:ie,onLoadMore:()=>void I()})]}),M||w?(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[M?(0,G.jsx)(i,{variant:`outlined`,leftIcon:(0,G.jsx)(f,{className:`h-3.5 w-3.5`}),onClick:()=>l(`${z.settings.developer}?tab=memory`),children:`Memory settings`}):null,w?(0,G.jsx)(i,{variant:`primary`,leftIcon:C?(0,G.jsx)(v,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(be,{className:`h-3.5 w-3.5`}),onClick:w,disabled:k,children:C?`Running…`:`Run now`}):null]}):null]})}function Jt(e){let n=V(),[r]=(0,H.useState)(()=>Date.now()),{data:i,isLoading:a,isError:o,refetch:s}=c(ke(e)),{data:l,isLoading:u,isError:d}=c(gt(e,n,!0)),{recurring:f,oneTime:p,pastOneTime:m}=(0,H.useMemo)(()=>{let e=ht(i??[],r);return{recurring:e.recurring,oneTime:e.upcomingOneTime,pastOneTime:e.pastOneTime}},[r,i]),h=(0,H.useMemo)(()=>new Map((l??[]).map(e=>[e.scheduleId,e])),[l]);return{recurring:f,oneTime:p,pastOneTime:m,usageForSchedule:(0,H.useCallback)(e=>u?{status:`loading`}:d?{status:`error`}:{status:`ready`,summary:h.get(e)??_t(e)},[d,u,h]),handleToggle:(0,H.useCallback)(async(n,r)=>{if(e)try{await Ce(e,n,r),s()}catch(e){t(e,{context:`schedule_toggle`}),k.error(`Failed to toggle schedule.`)}},[e,s]),isLoading:a,isError:o,refetch:(0,H.useCallback)(()=>{s()},[s])}}function Yt(){let e=o(),{scheduleId:t}=a(),n=me(),r=pe(),i=V(),s=Jt(n),c=Dt(n,i),l=ve(`memoryOptOut`),u=B.use.settingsDeveloperNav(),d=l&&u===!0,[f,p]=(0,H.useState)(!1),m=t??null,[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(!1),y=(0,H.useCallback)(t=>{e(t?z.schedules.detail(t):z.schedules.root)},[e]),b=m?s.recurring.find(e=>e.id===m)??s.oneTime.find(e=>e.id===m)??s.pastOneTime.find(e=>e.id===m)??null:null;(0,H.useEffect)(()=>{m&&!s.isLoading&&!s.isError&&!b&&y(null)},[m,b,s.isLoading,s.isError,y]);let x=h===`heartbeat`?c.heartbeatConfig!=null:h===`consolidation`?c.consolidationConfig?.available===!0:h===`retrospective`?c.retrospectiveConfig?.available===!0:!1;(0,H.useEffect)(()=>{h&&!c.isLoading&&!x&&g(null)},[h,x,c.isLoading]);let S=(0,H.useCallback)(e=>{g(null),y(e)},[y]),C=(0,H.useCallback)(e=>{m&&y(null),g(e)},[y,m]),w=(0,H.useCallback)(()=>{_e(e)},[e]),T=(b?(0,G.jsx)(Pt,{schedule:b,assistantId:n,usage:s.usageForSchedule(b.id),isMobile:r,onClose:()=>y(null),onDeleted:()=>{y(null),s.refetch()}}):null)??(h&&x?(0,G.jsx)(qt,{kind:h,assistantId:n,systemTasks:c,canOpenMemorySettings:d,isMobile:r,onClose:()=>g(null)}):null),E=(0,G.jsx)(Rt,{recurring:s.recurring,oneTime:s.oneTime,pastOneTime:s.pastOneTime,usageForSchedule:s.usageForSchedule,isLoading:s.isLoading,isError:s.isError,refetch:s.refetch,onToggle:s.handleToggle,onSelectSchedule:S,selectedScheduleId:m,onStartNewChat:w,onCreateSchedule:()=>p(!0),pastOpen:_,onPastOpenChange:v,systemTasksSlot:(0,G.jsx)(St,{heartbeatConfig:c.heartbeatConfig,consolidationConfig:c.consolidationConfig,retrospectiveConfig:c.retrospectiveConfig,heartbeatUsage:c.heartbeatUsage,consolidationUsage:c.consolidationUsage,retrospectiveUsage:c.retrospectiveUsage,isLoading:c.isLoading,hasError:c.hasError,onRetry:c.refetchAll,onSelectHeartbeat:()=>C(`heartbeat`),onSelectConsolidation:()=>C(`consolidation`),onSelectRetrospective:()=>C(`retrospective`)})});return T&&r?(0,G.jsx)(je,{children:T}):(0,G.jsxs)(G.Fragment,{children:[T&&!r?(0,G.jsx)(Te,{storageKey:`schedulesDetailDrawerWidth`,detailKey:m??h??void 0,section:E,detail:T}):E,(0,G.jsx)(Ye,{isOpen:f,assistantId:n,onClose:()=>p(!1),onCreated:()=>{p(!1),s.refetch()}})]})}export{Yt as SchedulesPage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./capture-error-anSemq95.js";import{t as n}from"./react-DJZBPgpf.js";import{P as r,t as i}from"./button-CW7wKp2r.js";import{f as a,u as o}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{n as s}from"./QueryClientProvider-DKhXIxGb.js";import{t as c}from"./useQuery-B45lW1Kk.js";import{t as l}from"./jsx-runtime-CVSDxk6A.js";import{t as u}from"./typography-1kyF_Eu1.js";import{n as d,t as f}from"./settings-wSv59mkN.js";import{t as p}from"./chart-column-L6Nldm8M.js";import{t as m}from"./chevron-down-DpYf9Gwq.js";import{r as h,t as g}from"./panel-item-D1WbMkez.js";import{t as _}from"./clock-LiCGqvyn.js";import{t as v}from"./loader-circle-Ck8fq3yv.js";import{t as y}from"./repeat-BhXOPeQU.js";import{t as b}from"./x-CswtfvgS.js";import{t as x}from"./notice-CvJ7MBx5.js";import{i as S,j as C}from"./src-BT0gNVcT.js";import{t as w}from"./tag-CJyI1Y2J.js";import{n as T,t as E}from"./input-D3MhHg0d.js";import{t as D}from"./toggle-Ca1aoG-l.js";import{t as O}from"./modal-D_Y2RPD5.js";import{n as k}from"./toast-zHo1wvF9.js";import{t as A}from"./dropdown-DQozlhbb.js";import{F as j,M,N,P,Vt as F,Xt as ee,Yt as te,_ as ne,c as I,d as L,dt as re,ft as ie,g as R,j as ae,mt as oe,pt as se,ut as ce,v as le,y as ue}from"./react-query.gen-DfzfX_Jv.js";import{u as z}from"./routes-D4ff4ONd.js";import{t as de}from"./effective-timezone-Ct3PoWNH.js";import{t as B}from"./assistant-feature-flag-store-Bh-_qc7v.js";import{As as fe,Ha as pe,J as me,Ua as he,Vo as ge,Wa as _e,Wt as ve,Xs as ye,lr as V,ts as be}from"./index-Ck1SrvnM.js";import{t as xe}from"./detail-card-CAHT277C.js";import{a as Se,c as Ce,i as we,l as Te,n as Ee,o as De,r as Oe,s as ke,t as Ae,u as je}from"./page-empty-state-DhwyXbFT.js";import{r as Me,t as Ne}from"./profile-metadata-C6i7Ro9a.js";var H=e(n(),1),Pe={frequency:`daily`,minute:0,hour24:9,weekdays:[1],dayOfMonth:1},U=[{value:0,letter:`S`,short:`Sun`,full:`Sunday`},{value:1,letter:`M`,short:`Mon`,full:`Monday`},{value:2,letter:`T`,short:`Tue`,full:`Tuesday`},{value:3,letter:`W`,short:`Wed`,full:`Wednesday`},{value:4,letter:`T`,short:`Thu`,full:`Thursday`},{value:5,letter:`F`,short:`Fri`,full:`Friday`},{value:6,letter:`S`,short:`Sat`,full:`Saturday`}],Fe=[1,2,3,4,5];function W(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,Math.round(e))):t}function Ie(e){let t=Array.from(new Set(e.map(e=>W(e,0,6)).filter(e=>Number.isInteger(e)))).sort((e,t)=>e-t);return t.length>0?t:[1]}function Le(e){let t=W(e.minute,0,59),n=W(e.hour24,0,23);switch(e.frequency){case`hourly`:return`${t} * * * *`;case`daily`:return`${t} ${n} * * *`;case`weekly`:return`${t} ${n} * * ${Ie(e.weekdays).join(`,`)}`;case`monthly`:return e.dayOfMonth===`last`?`${t} ${n} L * *`:`${t} ${n} ${W(e.dayOfMonth,1,28)} * *`}}function Re(e,t){let n=W(e,0,23),r=W(t,0,59),i=n<12?`AM`:`PM`;return`${n%12==0?12:n%12}:${String(r).padStart(2,`0`)} ${i}`}function ze(e){let t=[`th`,`st`,`nd`,`rd`],n=e%100;return`${e}${t[(n-20)%10]??t[n]??t[0]}`}function Be(e){let t=Ie(e),n=new Set(t);if(t.length===7)return`every day`;if(t.length===5&&Fe.every(e=>n.has(e)))return`every weekday`;if(t.length===2&&n.has(0)&&n.has(6))return`every weekend`;if(t.length===1)return`every ${U[t[0]]?.full??`day`}`;let r=t.map(e=>U[e]?.short??``),i=r.pop();return`every ${r.join(`, `)} & ${i}`}function Ve(e){let t=Re(e.hour24,e.minute);switch(e.frequency){case`hourly`:{let t=W(e.minute,0,59);return`Runs every hour at :${String(t).padStart(2,`0`)}`}case`daily`:return`Runs every day at ${t}`;case`weekly`:return`Runs ${Be(e.weekdays)} at ${t}`;case`monthly`:return e.dayOfMonth===`last`?`Runs on the last day of every month at ${t}`:`Runs on the ${ze(W(e.dayOfMonth,1,28))} of every month at ${t}`}}var G=l(),He=[{value:`hourly`,label:`Hourly`},{value:`daily`,label:`Daily`},{value:`weekly`,label:`Weekly`},{value:`monthly`,label:`Monthly`}],Ue=Array.from({length:12},(e,t)=>{let n=t+1;return{value:String(n),label:String(n)}}),We=Array.from({length:12},(e,t)=>{let n=t*5,r=String(n).padStart(2,`0`);return{value:r,label:r}}),Ge=[...Array.from({length:28},(e,t)=>{let n=t+1;return{value:String(n),label:ze(n)}}),{value:`last`,label:`Last day`}],Ke=[{value:`AM`,label:`AM`},{value:`PM`,label:`PM`}];function qe(e,t){let n=e%12;return t===`PM`?n+12:n}function Je(e){try{let t=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`short`}).formatToParts(new Date).find(e=>e.type===`timeZoneName`)?.value;return t&&t!==e?`${e} · ${t}`:e}catch{return e}}function Ye({isOpen:e,assistantId:t,onClose:n,onCreated:r}){return(0,G.jsx)(O.Root,{open:e,onOpenChange:e=>{e||n()},children:e?(0,G.jsx)(Xe,{assistantId:t,onClose:n,onCreated:r}):null})}function Xe({assistantId:e,onClose:t,onCreated:n}){let r=V(),[a,o]=(0,H.useState)(``),[s,c]=(0,H.useState)(``),[l,u]=(0,H.useState)(``),[d,f]=(0,H.useState)(`simple`),[p,m]=(0,H.useState)(Pe),[h,g]=(0,H.useState)(``),[_,v]=(0,H.useState)(!1),[y,b]=(0,H.useState)(null),x=a.trim(),S=s.trim(),C=l.trim(),w=h.trim(),D=(0,H.useMemo)(()=>d===`simple`?Le(p):w,[d,p,w]),k=(0,H.useMemo)(()=>d===`simple`?Ve(p):w||`Enter a cron expression to continue.`,[d,p,w]),A=(0,H.useMemo)(()=>Je(r),[r]),j=x.length>0&&S.length>0&&C.length>0&&D.length>0&&!_;return(0,G.jsxs)(O.Content,{size:`md`,children:[(0,G.jsxs)(O.Header,{children:[(0,G.jsx)(O.Title,{children:`Create schedule`}),(0,G.jsx)(O.Description,{children:`Schedule a recurring instruction for your assistant. Runs in execute mode — the message is delivered to the assistant on each fire.`})]}),(0,G.jsxs)(`form`,{onSubmit:async t=>{if(t.preventDefault(),j){v(!0),b(null);try{await Ee(e,{name:x,description:S,expression:D,message:C,timezone:r}),v(!1),n()}catch(e){b(e instanceof Error?e.message:`Failed to create schedule.`),v(!1)}}},children:[(0,G.jsx)(O.Body,{children:(0,G.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,G.jsx)(E,{label:`Name`,placeholder:`Morning briefing`,value:a,onChange:e=>o(e.target.value),required:!0,autoFocus:!0,fullWidth:!0}),(0,G.jsx)(T,{label:`Description`,placeholder:`What is this schedule for?`,value:s,onChange:e=>c(e.target.value),required:!0,fullWidth:!0,rows:2}),(0,G.jsx)(tt,{label:`Repeat`,children:d===`simple`?(0,G.jsx)(Ze,{cadence:p,onChange:m}):(0,G.jsx)(et,{value:h,onChange:g,onUseSimple:()=>f(`simple`)})}),(0,G.jsx)(nt,{summary:k,mono:d===`advanced`&&w.length>0,timezoneLabel:A}),d===`simple`?(0,G.jsx)(`button`,{type:`button`,onClick:()=>{g(e=>e||Le(p)),f(`advanced`)},className:`self-start text-body-small-default text-[var(--content-tertiary)] underline-offset-2 transition-colors hover:text-[var(--content-default)] hover:underline`,children:`Advanced — write a cron expression`}):null,(0,G.jsx)(T,{label:`Message`,placeholder:`What should the assistant do on each fire?`,value:l,onChange:e=>u(e.target.value),required:!0,fullWidth:!0,rows:4}),y?(0,G.jsx)(`p`,{className:`text-body-small-default text-[var(--system-negative-strong)]`,children:y}):null]})}),(0,G.jsxs)(O.Footer,{children:[(0,G.jsx)(i,{variant:`outlined`,onClick:t,type:`button`,children:`Cancel`}),(0,G.jsx)(i,{variant:`primary`,type:`submit`,disabled:!j,children:_?`Creating…`:`Create schedule`})]})]})]})}function Ze({cadence:e,onChange:t}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(C,{items:He,value:e.frequency,onChange:n=>t({...e,frequency:n}),ariaLabel:`How often the schedule runs`}),e.frequency===`hourly`?(0,G.jsx)(K,{label:`At minute`,children:(0,G.jsx)(A,{options:We,value:String(e.minute).padStart(2,`0`),onChange:n=>t({...e,minute:Number(n)}),"aria-label":`Minute`,className:`w-24`})}):null,e.frequency===`weekly`?(0,G.jsx)(K,{label:`On these days`,children:(0,G.jsx)($e,{value:e.weekdays,onChange:n=>t({...e,weekdays:n})})}):null,e.frequency===`monthly`?(0,G.jsx)(K,{label:`On day`,children:(0,G.jsx)(A,{options:Ge,value:e.dayOfMonth===`last`?`last`:String(e.dayOfMonth),onChange:n=>t({...e,dayOfMonth:n===`last`?`last`:Number(n)}),"aria-label":`Day of month`,className:`w-32`})}):null,e.frequency===`hourly`?null:(0,G.jsx)(K,{label:`At time`,children:(0,G.jsx)(Qe,{hour24:e.hour24,minute:e.minute,onChange:(n,r)=>t({...e,hour24:n,minute:r})})})]})}function Qe({hour24:e,minute:t,onChange:n}){let r=e<12?`AM`:`PM`,i=e%12==0?12:e%12;return(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(A,{options:Ue,value:String(i),onChange:e=>n(qe(Number(e),r),t),"aria-label":`Hour`,className:`w-[72px]`}),(0,G.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-tertiary)]`,children:`:`}),(0,G.jsx)(A,{options:We,value:String(t).padStart(2,`0`),onChange:t=>n(e,Number(t)),"aria-label":`Minute`,className:`w-[72px]`}),(0,G.jsx)(`div`,{className:`w-[112px]`,children:(0,G.jsx)(C,{items:Ke,value:r,onChange:e=>n(qe(i,e),t),ariaLabel:`AM or PM`})})]})}function $e({value:e,onChange:t}){let n=new Set(e),i=e=>{let r=new Set(n);r.has(e)?r.size>1&&r.delete(e):r.add(e),t([...r].sort((e,t)=>e-t))};return(0,G.jsx)(`div`,{className:`flex gap-1.5`,children:U.map(e=>{let t=n.has(e.value);return(0,G.jsx)(`button`,{type:`button`,onClick:()=>i(e.value),"aria-pressed":t,"aria-label":e.full,title:e.full,className:r(`flex h-9 w-9 items-center justify-center rounded-md border text-body-medium-default transition-colors`,t?`border-[var(--border-active)] bg-[var(--surface-active)] text-[var(--content-emphasised)]`:`border-[var(--field-border)] text-[var(--content-tertiary)] hover:border-[var(--border-active)] hover:text-[var(--content-default)]`),children:e.letter},e.value)})})}function et({value:e,onChange:t,onUseSimple:n}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsx)(E,{placeholder:`0 9 * * *`,value:e,onChange:e=>t(e.target.value),fullWidth:!0,className:`font-mono`,"aria-label":`Cron expression`,helperText:`Standard 5-field cron (minute hour day month weekday). RRULE expressions are also accepted.`}),(0,G.jsx)(`button`,{type:`button`,onClick:n,className:`self-start text-body-small-default text-[var(--content-tertiary)] underline-offset-2 transition-colors hover:text-[var(--content-default)] hover:underline`,children:`← Back to the simple builder`})]})}function tt({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:e}),t]})}function K({label:e,children:t}){return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1.5`,children:[(0,G.jsx)(`span`,{className:`min-w-[88px] text-body-small-default text-[var(--content-tertiary)]`,children:e}),t]})}function nt({summary:e,mono:t,timezoneLabel:n}){return(0,G.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-[var(--border-subtle)] bg-[var(--surface-lift)] px-3.5 py-3`,children:[(0,G.jsx)(_,{className:`mt-0.5 h-4 w-4 shrink-0 text-[var(--content-tertiary)]`,"aria-hidden":!0}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`p`,{className:r(`text-body-medium-default text-[var(--content-default)]`,t&&`break-all font-mono`),children:e}),(0,G.jsxs)(`p`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:[`Times use your timezone — `,n,`.`]})]})]})}function rt(e=de(),t=Date.now()){return Me(`7d`,e,t)}function q(e){return e?new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`,hour12:!0}):`—`}function it(e){return e==null?`—`:e<1e3?`${e}ms`:`${(e/1e3).toFixed(1)}s`}var at=new Intl.NumberFormat(void 0,{style:`currency`,currency:`USD`,minimumFractionDigits:2,maximumFractionDigits:2});function J(e){return e==null||!Number.isFinite(e)?`—`:at.format(e)}function Y(e){return`${e.toLocaleString()} ${e===1?`run`:`runs`}`}function ot(e){let t=Math.round(e/6e4);return t>=60&&t%60==0?`Every ${t/60} hr`:`Every ${t} min`}function st(e){if(!e)return;let t=new Set,n=[];for(let r of e)for(let e of r.runs)t.has(e.id)||(t.add(e.id),n.push(e));return n}function ct(e){return!!e.conversationId&&e.conversationExists===!0&&e.conversationArchivedAt==null}function lt(e){return ct(e)?e.conversationId??null:null}function X(e){return typeof e==`string`&&e.length>0}var ut={heartbeat:`system-heartbeat`,consolidation:`system-consolidation`,retrospective:`system-memory-retrospective`};function dt(e){if(e.cronExpression)return e.timezone?`Cron: ${e.cronExpression} (${e.timezone})`:`Cron: ${e.cronExpression}`;let t=ot(e.intervalMs);return e.activeHoursStart!=null&&e.activeHoursEnd!=null&&(t+=` (${e.activeHoursStart}:00–${e.activeHoursEnd}:00)`),t}function ft(e){return ot(e.intervalMs)}var pt=`After conversation activity`;function mt(e,t){return e.status===`fired`||e.status===`cancelled`?!0:e.status===`firing`?!1:e.nextRunAt==null||!e.enabled&&e.nextRunAt<=t}function ht(e,t){let n=[],r=[],i=[];for(let a of e)a.isOneShot?mt(a,t)?i.push(a):r.push(a):n.push(a);return n.sort((e,t)=>e.enabled===t.enabled?(e.nextRunAt??1/0)-(t.nextRunAt??1/0):e.enabled?-1:1),r.sort((e,t)=>(e.nextRunAt??1/0)-(t.nextRunAt??1/0)),i.sort((e,t)=>{let n=e.lastRunAt??e.nextRunAt??0;return(t.lastRunAt??t.nextRunAt??0)-n}),{recurring:n,upcomingOneTime:r,pastOneTime:i}}function gt(e,t,n=!0){return{queryKey:[{_id:`schedulesUsagesummaryGet`,path:{assistant_id:e??``},_tz:t}],queryFn:()=>e?Se(e,rt(t)):Promise.resolve([]),enabled:n,staleTime:1e4}}function _t(e){return{scheduleId:e,runCount:0,totalEstimatedCostUsd:0,eventCount:0}}function vt(e,t,n){let r=(t??[]).filter(e=>{let t=e.startedAt??e.createdAt;return t>=n.from&&t<=n.to});return{scheduleId:e,runCount:r.length,totalEstimatedCostUsd:r.reduce((e,t)=>{let n=t.estimatedCostUsd;return typeof n==`number`&&Number.isFinite(n)?e+n:e},0),eventCount:0}}function yt({status:e}){return(0,G.jsx)(`span`,{className:`inline-block h-2 w-2 rounded-full`,style:{backgroundColor:e===`ok`||e===`completed`?`var(--system-positive-strong)`:e===`error`||e===`failed`?`var(--system-negative-strong)`:`var(--content-tertiary)`},"aria-label":e??`unknown`})}function bt({scheduleName:e,usage:t,onOpenUsage:n}){if(t.status===`loading`)return(0,G.jsxs)(`div`,{"aria-label":`Loading schedule usage`,className:`flex w-[156px] shrink-0 items-center justify-end gap-3`,children:[(0,G.jsx)(`span`,{className:`h-5 w-16 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,G.jsx)(`span`,{className:`h-5 w-16 animate-pulse rounded bg-[var(--surface-muted)]`})]});let r=t.status===`error`,i=r?`--`:J(t.summary.totalEstimatedCostUsd),a=r?`--`:Y(t.summary.runCount),o=t.status===`ready`&&!(t.summary.totalEstimatedCostUsd>0),s=t.status===`ready`&&t.summary.runCount===0,c=o?`text-[var(--content-tertiary)]`:`text-[var(--content-default)]`,l=s?`text-[var(--content-tertiary)]`:`text-[var(--content-default)]`;return(0,G.jsxs)(`div`,{className:`flex w-[156px] shrink-0 items-center justify-end gap-3 text-right text-body-small-default`,children:[n?(0,G.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`View usage for ${e}`,className:`min-w-[64px] cursor-pointer rounded px-1 py-0.5 text-right transition-colors hover:bg-[var(--surface-hover)] ${c}`,children:i}):(0,G.jsx)(`span`,{"aria-label":`Cost for ${e} in the last 7 days: ${i}`,className:`block min-w-[64px] px-1 py-0.5 ${c}`,children:i}),(0,G.jsx)(`span`,{"aria-label":`Runs for ${e} in the last 7 days: ${a}`,className:`block min-w-[64px] px-1 py-0.5 ${l}`,children:a})]})}function xt({name:e,subtitle:t,enabled:n,nextRunAt:r,lastRunAt:i,usage:a,helperText:o,statusLabel:s,statusTone:c=`neutral`,onClick:l}){return(0,G.jsx)(`div`,{className:`flex flex-wrap items-center gap-3 rounded-md px-2 py-3 transition-colors hover:bg-[var(--surface-hover)] [&+&]:border-t [&+&]:border-[var(--border-base)]`,children:(0,G.jsxs)(`button`,{type:`button`,onClick:l,"aria-label":`Open ${e}`,className:`flex min-w-0 flex-1 cursor-pointer flex-wrap items-center gap-3 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,G.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e})}),(0,G.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:t}),o?(0,G.jsx)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--content-secondary)]`,children:o}):null,(0,G.jsxs)(`div`,{className:`mt-0.5 flex flex-wrap items-center gap-x-3 gap-y-1 text-body-small-default text-[var(--content-tertiary)]`,children:[r?(0,G.jsxs)(`span`,{children:[`Next: `,q(r)]}):null,i?(0,G.jsxs)(`span`,{children:[`Last: `,q(i)]}):null]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-end gap-3`,children:[(0,G.jsx)(bt,{scheduleName:e,usage:a}),s?(0,G.jsx)(w,{tone:c,children:s}):(0,G.jsx)(`span`,{className:`h-2 w-2 rounded-full`,style:{backgroundColor:n?`var(--system-positive-strong)`:`var(--content-disabled)`},"aria-label":n?`enabled`:`disabled`}),(0,G.jsx)(h,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]})})}function St({heartbeatConfig:e,consolidationConfig:t,retrospectiveConfig:n,heartbeatUsage:r,consolidationUsage:i,retrospectiveUsage:a,isLoading:o,hasError:s,onRetry:c,onSelectHeartbeat:l,onSelectConsolidation:u,onSelectRetrospective:d}){let f=e!=null,p=t?.available===!0,h=n?.available===!0,g=f||p||h;if(!o&&!s&&!g)return null;let _=[...f?[r]:[],...p?[i]:[],...h?[a]:[]].filter(e=>e.status===`ready`),y=_.reduce((e,t)=>e+(t.summary.totalEstimatedCostUsd??0),0),b=o?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(v,{className:`h-5 w-5 animate-spin text-stone-400`})}):s&&!g?(0,G.jsxs)(x,{tone:`error`,children:[`Failed to load system jobs.`,` `,(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]}):(0,G.jsxs)(`div`,{children:[f?(0,G.jsx)(xt,{name:`Heartbeat`,subtitle:dt(e),enabled:e.enabled,nextRunAt:e.nextRunAt,lastRunAt:e.lastRunAt,usage:r,onClick:l}):null,p?(0,G.jsx)(xt,{name:`Consolidation`,subtitle:ft(t),enabled:t.enabled,helperText:t.enabled?void 0:`Memory is off, so consolidation is paused.`,nextRunAt:t.nextRunAt,lastRunAt:t.lastRunAt,usage:i,statusLabel:t.enabled?void 0:`Paused`,statusTone:`warning`,onClick:u}):null,h?(0,G.jsx)(xt,{name:`Memory retrospective`,subtitle:pt,enabled:n.enabled,helperText:n.enabled?void 0:`Memory is off, so retrospectives are paused.`,nextRunAt:n.nextRunAt,lastRunAt:n.lastRunAt,usage:a,statusLabel:n.enabled?void 0:`Paused`,statusTone:`warning`,onClick:d}):null,s?(0,G.jsx)(`div`,{className:`pt-3 first:pt-0`,children:(0,G.jsxs)(x,{tone:`error`,children:[`Some system jobs failed to load.`,` `,(0,G.jsx)(`button`,{type:`button`,onClick:c,className:`cursor-pointer underline hover:no-underline`,children:`Retry`})]})}):null]});return(0,G.jsx)(xe,{children:(0,G.jsx)(S.Root,{type:`multiple`,children:(0,G.jsxs)(S.Item,{value:`system-jobs`,children:[(0,G.jsxs)(S.Trigger,{className:`group justify-between gap-3`,children:[(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-wrap items-baseline gap-x-2 gap-y-1 text-left`,children:[(0,G.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-secondary)]`,children:`System`}),(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`Built-in jobs managed by the assistant runtime`})]}),(0,G.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[_.length>0?(0,G.jsxs)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[J(y),` (7d)`]}):null,(0,G.jsx)(m,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform group-data-[state=open]:rotate-180`})]})]}),(0,G.jsx)(S.Content,{children:(0,G.jsx)(`div`,{className:`mt-3`,children:b})})]})})})}function Z(e,t){return{id:e.id,jobId:t,status:e.status,startedAt:e.startedAt??e.scheduledFor,finishedAt:e.finishedAt,durationMs:e.durationMs,output:`skipReason`in e&&e.skipReason?`Skipped: ${e.skipReason}`:null,error:e.error,conversationId:e.conversationId,conversationExists:e.conversationExists,conversationArchivedAt:e.conversationArchivedAt,estimatedCostUsd:e.estimatedCostUsd,createdAt:e.createdAt,...`title`in e?{title:e.title}:{}}}function Ct(e){return e.runs.map(e=>Z(e,`heartbeat`))}function wt(e){return e.runs.map(e=>Z(e,`consolidation`))}function Tt(e){return e.runs.map(e=>Z(e,`retrospective`))}var Q=1e4;function Et(e,t,n,r,i){return e?{status:`loading`}:t?{status:`error`}:{status:`ready`,summary:vt(n,r,i)}}function Dt(e,n){let r=s(),i={path:{assistant_id:e??``}},{data:a,isLoading:o,isError:l,refetch:u}=c({...ae(i),enabled:!!e,staleTime:Q}),{data:d,isLoading:f,isError:p,refetch:m}=c({...R(i),enabled:!!e,staleTime:Q}),{data:h,isLoading:g,isError:_,refetch:v}=c({...ce(i),enabled:!!e,staleTime:Q}),y={path:{assistant_id:e??``},query:{limit:100}},{data:b,isLoading:x,isError:S,refetch:C}=c({...j(y),select:Ct,enabled:!!e&&a!=null,staleTime:Q}),{data:w,isLoading:T,isError:E,refetch:D}=c({...ue(y),select:wt,enabled:!!e&&d?.available===!0,staleTime:Q}),{data:O,isLoading:A,isError:N,refetch:ne}=c({...se(y),select:Tt,enabled:!!e&&h?.available===!0,staleTime:Q}),I=(0,H.useMemo)(()=>rt(n),[n]),L=(0,H.useMemo)(()=>Et(x,S,ut.heartbeat,b,I),[b,S,x,I]),re=(0,H.useMemo)(()=>Et(T,E,ut.consolidation,w,I),[w,E,T,I]),oe=(0,H.useMemo)(()=>Et(A,N,ut.retrospective,O,I),[O,N,A,I]),z=t=>{if(!e)return;let n={heartbeat:{config:ae(i).queryKey,runs:j(y).queryKey,infinite:P(i)},consolidation:{config:R(i).queryKey,runs:ue(y).queryKey,infinite:le(i)},retrospective:{config:ce(i).queryKey,runs:se(y).queryKey,infinite:ie(i)}}[t];r.invalidateQueries({queryKey:n.config}),r.invalidateQueries({queryKey:n.runs}),r.invalidateQueries({queryKey:n.infinite})},de=ee({onSuccess:e=>{e.ran?k.success(`Heartbeat started.`):k.info(`Heartbeat skipped.`)},onError:e=>{t(e,{context:`heartbeat_run_now`}),k.error(`Failed to run heartbeat.`)},onSettled:()=>z(`heartbeat`)}),B=F({onSuccess:e=>{e.ran?k.success(`Consolidation queued.`):k.info(`Consolidation already queued or running.`)},onError:e=>{t(e,{context:`consolidation_run_now`}),k.error(`Failed to run consolidation.`)},onSettled:()=>z(`consolidation`)}),fe=te({onSuccess:e=>{M(r,i,e),k.success(e.enabled?`Heartbeat enabled.`:`Heartbeat disabled.`)},onError:e=>{t(e,{context:`heartbeat_toggle`}),k.error(`Failed to toggle heartbeat.`)}});return{heartbeatConfig:a,consolidationConfig:d,retrospectiveConfig:h,heartbeatUsage:L,consolidationUsage:re,retrospectiveUsage:oe,isLoading:o||f||g,hasError:l||p||_,isHeartbeatRunning:de.isPending,isConsolidationRunning:B.isPending,isHeartbeatLoading:o,isHeartbeatError:l,isConsolidationLoading:f,isConsolidationError:p,isRetrospectiveLoading:g,isRetrospectiveError:_,refetchHeartbeat:u,refetchConsolidation:m,refetchRetrospective:v,runHeartbeatNow:()=>{e&&de.mutate({path:{assistant_id:e}})},runConsolidationNow:()=>{e&&B.mutate({path:{assistant_id:e}})},toggleHeartbeat:t=>{e&&fe.mutate({body:{enabled:t},path:{assistant_id:e}})},refetchAll:()=>{u(),m(),v(),C(),D(),ne()}}}function Ot({children:e}){return(0,G.jsx)(u,{variant:`label-small-default`,as:`div`,className:`mb-2 uppercase tracking-wider text-[var(--content-tertiary)]`,children:e})}function $({label:e,value:t}){return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4 py-1`,children:[(0,G.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:e}),(0,G.jsx)(`span`,{className:`min-w-0 text-right text-body-medium-lighter text-[var(--content-default)]`,children:t})]})}function kt({icon:e,value:t,label:n}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] p-3`,children:[(0,G.jsx)(`span`,{className:`flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-[var(--surface-sunken)] text-[var(--content-secondary)]`,children:e}),(0,G.jsxs)(`div`,{className:`min-w-0`,children:[(0,G.jsx)(`div`,{className:`truncate text-body-large-default text-[var(--content-default)]`,children:t}),(0,G.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:n})]})]})}function At({usage:e}){return e.status===`loading`?(0,G.jsx)(`div`,{className:`grid grid-cols-2 gap-3 pt-2`,children:Array.from({length:2},(e,t)=>(0,G.jsx)(`div`,{className:`h-[60px] animate-pulse rounded-lg bg-[var(--surface-muted)]`},t))}):e.status===`error`?null:(0,G.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 pt-2`,children:[(0,G.jsx)(kt,{icon:(0,G.jsx)(fe,{className:`h-4 w-4`}),value:J(e.summary.totalEstimatedCostUsd),label:`7 Day Cost`}),(0,G.jsx)(kt,{icon:(0,G.jsx)(y,{className:`h-4 w-4`}),value:Y(e.summary.runCount),label:`7 Day Runs`})]})}function jt(e){return e.exists&&e.archivedAt==null}function Mt({run:e,index:t,isExpanded:n,disableDirectOpen:i,onOpenConversation:a,onToggleDetails:o}){let s=lt(e),c=e.conversations??(s?[{id:s,title:null,exists:!0,archivedAt:null}]:[]),l=X(e.output),u=X(e.error),d=!i&&c.length===1&&jt(c[0])?c[0].id:null,f=!d&&(c.length>0||l||u),p=`schedule-run-details-${t}`,m=!!d||f,g=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(yt,{status:e.status}),(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`div`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:q(e.startedAt)}),(0,G.jsxs)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[it(e.durationMs),` ·`,` `,J(e.estimatedCostUsd)]}),e.status===`error`&&e.error?(0,G.jsxs)(`div`,{className:`mt-0.5 text-body-small-default text-[var(--system-negative-strong)]`,children:[e.error.slice(0,120),e.error.length>120?`…`:``]}):null]}),m?(0,G.jsx)(h,{className:r(`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform`,f&&n?`rotate-90`:``)}):null]}),_=f&&n?(0,G.jsx)(`div`,{id:p,className:`px-2 pb-3`,children:(0,G.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[c.length>0?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Conversations`}),(0,G.jsx)(`div`,{className:`space-y-1`,children:c.map(e=>jt(e)?(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(e.id),className:`block w-full truncate text-left text-body-small-default text-[var(--content-default)] hover:underline`,children:X(e.title)?e.title:`Conversation`},e.id):(0,G.jsxs)(`span`,{className:`block truncate text-body-small-default text-[var(--content-tertiary)] italic`,children:[X(e.title)?e.title:`Conversation`,` `,e.exists?`(archived)`:`(unavailable)`]},e.id))})]}):null,l?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,u?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null;return d?(0,G.jsx)(`div`,{children:(0,G.jsx)(`button`,{type:`button`,onClick:()=>a(d),"aria-label":`Open conversation for run at ${q(e.startedAt)}`,className:`flex w-full cursor-pointer items-center gap-3 px-2 py-3 text-left shadow-none transition-colors hover:bg-[var(--surface-hover)] focus:outline-none`,children:g})}):f?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`button`,{type:`button`,onClick:()=>o(e.id),"aria-label":`Toggle details for run at ${q(e.startedAt)}`,"aria-expanded":n,"aria-controls":p,className:`flex w-full cursor-pointer items-center gap-3 px-2 py-3 text-left shadow-none transition-colors hover:bg-[var(--surface-hover)] focus:outline-none`,children:g}),_]}):(0,G.jsx)(`div`,{className:`flex items-center gap-3 px-2 py-3`,children:g})}function Nt({runs:e,isLoading:t,disableDirectOpen:n,onOpenConversation:r}){let[i,a]=(0,H.useState)(null);return t?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-6`,children:(0,G.jsx)(v,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,G.jsx)(`p`,{className:`py-2 text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:`No runs yet.`}):(0,G.jsx)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:e.map((e,t)=>(0,G.jsx)(Mt,{run:e,index:t,isExpanded:i===e.id,disableDirectOpen:n,onOpenConversation:r,onToggleDetails:e=>a(t=>t===e?null:e)},e.id))})}function Pt({schedule:e,assistantId:n,usage:a,isMobile:s,onClose:l,onDeleted:d}){let f=o(),{data:m,isLoading:h}=c({queryKey:oe({path:{assistant_id:n,id:e.id}}),queryFn:()=>we(n,e.id),staleTime:1e4}),[g,_]=(0,H.useState)(!1),[y,x]=(0,H.useState)(!1),[S,C]=(0,H.useState)(!1),w=async()=>{_(!0);try{await De(n,e.id)}catch(e){t(e,{context:`schedule_run_now`}),k.error(`Failed to run schedule.`)}finally{_(!1)}},T=async()=>{C(!0);try{await Oe(n,e.id),d()}catch(e){t(e,{context:`schedule_delete`}),k.error(`Failed to delete schedule.`),C(!1),x(!1)}};return(0,G.jsxs)(`div`,{className:r(`flex h-full flex-col bg-[var(--surface-overlay)]`,!s&&`rounded-[var(--radius-xl)] border border-[var(--border-base)]`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,G.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,G.jsx)(u,{variant:`title-small`,className:`truncate text-[var(--content-default)]`,children:e.name})}),(0,G.jsx)(i,{variant:`ghost`,iconOnly:(0,G.jsx)(b,{}),onClick:l,"aria-label":`Close schedule details`,tooltip:`Close`,className:`shrink-0`})]}),(0,G.jsxs)(`div`,{className:`flex-1 space-y-6 overflow-y-auto px-[var(--app-spacing-lg)] py-[var(--app-spacing-lg)]`,children:[e.description?(0,G.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-secondary)]`,children:e.description}):null,(0,G.jsxs)(`section`,{children:[(0,G.jsx)(Ot,{children:`Details`}),(0,G.jsxs)(`div`,{className:`rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] px-4 py-2`,children:[e.cadenceDescription?(0,G.jsx)($,{label:`Cadence`,value:e.cadenceDescription}):null,(0,G.jsx)($,{label:`Mode`,value:e.mode}),(0,G.jsx)($,{label:`Status`,value:e.enabled?`Enabled`:`Disabled`}),(0,G.jsx)($,{label:`Next run`,value:q(e.nextRunAt)}),e.lastRunAt?(0,G.jsx)($,{label:`Last run`,value:(0,G.jsxs)(`span`,{className:`flex items-center justify-end gap-2`,children:[(0,G.jsx)(yt,{status:e.lastStatus}),q(e.lastRunAt)]})}):null]})]}),(0,G.jsx)(At,{usage:a}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(Ot,{children:`Recent runs`}),(0,G.jsx)(Nt,{runs:m?.runs,isLoading:h,disableDirectOpen:e.mode===`script`,onOpenConversation:e=>he(f,e)})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between gap-2 border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[y?(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(i,{variant:`ghost`,onClick:()=>x(!1),disabled:S,children:`Cancel`}),(0,G.jsx)(i,{variant:`danger`,onClick:()=>void T(),disabled:S,children:S?`Deleting…`:`Yes, delete`})]}):(0,G.jsx)(i,{variant:`dangerOutline`,leftIcon:(0,G.jsx)(ge,{className:`h-3.5 w-3.5`}),onClick:()=>x(!0),children:`Delete`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(i,{variant:`outlined`,leftIcon:(0,G.jsx)(p,{className:`h-3.5 w-3.5`}),onClick:()=>f(z.settings.usageForSchedule(e.id)),children:`View usage`}),e.mode===`script`?(0,G.jsx)(i,{variant:`primary`,leftIcon:g?(0,G.jsx)(v,{className:`h-3.5 w-3.5 animate-spin`}):void 0,onClick:()=>void w(),disabled:g,children:g?`Running…`:`Run now`}):null]})]})]})}function Ft(e){if(e.status===`loading`)return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`h-4 w-12 animate-pulse rounded bg-[var(--surface-muted)]`}),(0,G.jsx)(`span`,{className:`h-4 w-10 animate-pulse rounded bg-[var(--surface-muted)]`})]});if(e.status===`error`)return(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`—`});let{summary:t}=e;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:J(t.totalEstimatedCostUsd)}),(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-secondary)]`,children:Y(t.runCount)})]})}function It({name:e,metaParts:t,usage:n,enabled:r,selected:i,onClick:a,onToggle:o,toggleAriaLabel:s}){return(0,G.jsxs)(`div`,{className:`flex items-center gap-3 rounded-md px-2 py-3 transition-colors [&+&]:border-t [&+&]:border-[var(--border-base)] ${i?`bg-[var(--surface-active)]`:`hover:bg-[var(--surface-hover)]`}`,children:[o?(0,G.jsx)(D,{checked:r,onChange:o,"aria-label":s}):null,(0,G.jsxs)(`button`,{type:`button`,onClick:a,className:`flex min-w-0 flex-1 cursor-pointer items-center gap-4 text-left focus:outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)]`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,G.jsx)(`span`,{className:`truncate text-body-medium-default text-[var(--content-default)]`,children:e}),t.length>0?(0,G.jsx)(`span`,{className:`flex min-w-0 items-center gap-2 text-label-small-default text-[var(--content-tertiary)]`,children:t.map((e,t)=>(0,G.jsxs)(H.Fragment,{children:[t>0?(0,G.jsx)(`span`,{className:`h-[3px] w-[3px] shrink-0 rounded-full bg-[var(--content-tertiary)]`}):null,(0,G.jsx)(`span`,{className:`truncate`,children:e})]},t))}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-4`,children:[Ft(n),(0,G.jsx)(h,{className:`h-4 w-4 text-[var(--content-tertiary)]`})]})]})]})}function Lt({schedule:e,usage:t,selected:n,onClick:r,onToggle:i}){let a=e.isOneShot?``:e.cadenceDescription.trim(),o=e.lastRunAt??e.nextRunAt,s=[a,o?q(o):``].filter(Boolean);return(0,G.jsx)(It,{name:e.name,metaParts:s,usage:t,enabled:e.enabled,selected:n,onClick:r,onToggle:i,toggleAriaLabel:i?`Toggle ${e.name}`:void 0})}function Rt({recurring:e,oneTime:t,pastOneTime:n,usageForSchedule:r,isLoading:a,isError:o,refetch:s,onToggle:c,onSelectSchedule:l,selectedScheduleId:u,onStartNewChat:f,onCreateSchedule:p,pastOpen:m,onPastOpenChange:g,systemTasksSlot:_}){let v=e=>(0,G.jsx)(Lt,{schedule:e,usage:r(e.id),selected:e.id===u,onClick:()=>l(e.id),onToggle:t=>c(e.id,t)},e.id),y=e=>(0,G.jsx)(Lt,{schedule:e,usage:r(e.id),selected:e.id===u,onClick:()=>l(e.id)},e.id),b=n.length>0?(0,G.jsx)(S.Root,{type:`single`,collapsible:!0,className:`mt-3`,value:m?`past`:``,onValueChange:e=>g(e===`past`),children:(0,G.jsxs)(S.Item,{value:`past`,children:[(0,G.jsxs)(S.Trigger,{className:`group gap-[var(--app-spacing-xs)] px-2 text-label-small-default text-[var(--content-tertiary)]`,children:[(0,G.jsx)(h,{size:14,"aria-hidden":!0,className:`shrink-0 transition-transform group-data-[state=open]:rotate-90`}),(0,G.jsxs)(`span`,{children:[`Past (`,n.length,`)`]})]}),(0,G.jsx)(S.Content,{children:(0,G.jsx)(`div`,{className:`pt-1`,children:n.map(y)})})]})}):null;return(0,G.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[a?(0,G.jsx)(`div`,{className:`space-y-3`,children:Array.from({length:2},(e,t)=>(0,G.jsx)(`div`,{className:`h-12 animate-pulse rounded-md bg-[var(--surface-muted)]`},t))}):o&&e.length===0?(0,G.jsx)(x,{tone:`error`,actions:(0,G.jsx)(`button`,{type:`button`,onClick:s,className:`cursor-pointer underline hover:no-underline`,children:`Retry`}),children:`Failed to load schedules.`}):e.length===0&&t.length===0&&n.length===0?(0,G.jsx)(Ae,{icon:d,title:`No schedules yet`,description:`Ask your assistant to set one up, or create one yourself.`,actions:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(i,{variant:`primary`,size:`regular`,onClick:f,children:`New Conversation`}),(0,G.jsx)(`span`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:`or`}),(0,G.jsx)(i,{variant:`outlined`,size:`regular`,onClick:p,children:`Create schedule`})]})}):(0,G.jsxs)(`div`,{children:[e.map(v),t.length>0?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:`mt-3 px-2 text-label-small-default text-[var(--content-tertiary)]`,children:`One-time`}),t.map(y)]}):null,b]}),_?(0,G.jsx)(`div`,{className:`mt-[var(--app-spacing-lg)]`,children:_}):null]})}var zt=`Default (assistant's main model)`,Bt=`Custom call-site model`;function Vt(e,t){return t?.[e]?.displayName??e}function Ht(e,t){if(e==null)return;if(e.provider!=null||e.model!=null)return Bt;let n=e.profile?.trim();return n?`Override (${Vt(n,t)})`:void 0}function Ut({assistantId:e,pinnedProfile:t,defaultCallSite:n=`mainAgent`,fallbackLabel:r=zt,respectCallSiteOverride:i=!1}){let a=t==null,{data:o}=c({...I({path:{assistant_id:e}}),enabled:!!e,staleTime:6e4}),s=(0,H.useMemo)(()=>o?Ne(o):{},[o]),{data:l}=c({...L({path:{assistant_id:e}}),enabled:!!e&&a,staleTime:6e4}),u=a&&i?Ht(o?.llm?.callSites?.[n],s):void 0,d=a?l?.callSites.find(e=>e.id===n)?.defaultProfile:void 0,f=t==null?u??(d==null?r:`Default (${Vt(d,s)})`):Vt(t,s);return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Model profile`}),(0,G.jsx)(`span`,{className:`min-w-0 text-right`,children:f})]})}function Wt({runs:e,isLoading:t,emptyMessage:n=`No runs yet.`,hasMore:r=!1,isLoadingMore:a=!1,onLoadMore:s}){let c=o(),[l,u]=(0,H.useState)(null);return(0,G.jsx)(xe,{title:`Recent runs`,children:t?(0,G.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,G.jsx)(v,{className:`h-5 w-5 animate-spin text-stone-400`})}):!e||e.length===0?(0,G.jsx)(`p`,{className:`py-4 text-center text-body-medium-lighter text-[var(--content-tertiary)] italic`,children:n}):(0,G.jsxs)(`div`,{className:`divide-y divide-[var(--border-base)]`,children:[e.map((e,t)=>{let n=lt(e),r=X(e.output),i=X(e.error),a=!n&&(r||i),o=l===e.id,s=`schedule-run-details-${t}`;return(0,G.jsxs)(`div`,{children:[(0,G.jsx)(g,{label:(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-1 items-center gap-3`,children:[(0,G.jsx)(yt,{status:e.status}),(0,G.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(`span`,{className:`block truncate text-body-medium-lighter text-[var(--content-default)]`,children:X(e.title)?e.title:q(e.startedAt)}),(0,G.jsxs)(`span`,{className:`block text-body-small-default text-[var(--content-tertiary)]`,children:[X(e.title)?`${q(e.startedAt)} · `:``,it(e.durationMs),` ·`,` `,J(e.estimatedCostUsd),e.status===`error`&&e.error&&(0,G.jsxs)(`span`,{className:`ml-2 text-[var(--system-negative-strong)]`,children:[e.error.slice(0,80),e.error.length>80?`…`:``]})]})]}),n||a?(0,G.jsx)(h,{className:`h-4 w-4 shrink-0 text-[var(--content-tertiary)] transition-transform ${o?`rotate-90`:``}`}):null]}),onSelect:n?()=>he(c,n):a?()=>u(o?null:e.id):void 0,"aria-label":`Run at ${q(e.startedAt)}`,"aria-expanded":a?o:void 0,"aria-controls":a?s:void 0,className:`h-auto py-2.5 gap-3 -mx-2 px-2`}),a&&o?(0,G.jsx)(`div`,{id:s,className:`px-2 pb-3`,children:(0,G.jsxs)(`div`,{className:`space-y-3 rounded-md border border-[var(--border-subtle)] bg-[var(--surface-sunken)] p-3`,children:[r?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Output`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--content-default)]`,children:e.output})]}):null,i?(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`div`,{className:`mb-1 text-body-small-default text-[var(--content-secondary)]`,children:`Error`}),(0,G.jsx)(`pre`,{className:`max-h-64 overflow-auto whitespace-pre-wrap break-words text-body-small-default font-mono text-[var(--system-negative-strong)]`,children:e.error})]}):null]})}):null]},e.id)}),r&&s?(0,G.jsx)(`div`,{className:`flex justify-center pt-3`,children:(0,G.jsx)(i,{variant:`outlined`,size:`compact`,onClick:s,disabled:a,leftIcon:a?(0,G.jsx)(v,{className:`h-3.5 w-3.5 animate-spin`}):void 0,children:a?`Loading…`:`Load more`})}):null]})})}var Gt={heartbeat:`heartbeatAgent`,consolidation:`memoryV2Consolidation`,retrospective:`memoryRetrospective`};function Kt({children:e}){return(0,G.jsx)(u,{variant:`label-small-default`,as:`div`,className:`mb-2 uppercase tracking-wider text-[var(--content-tertiary)]`,children:e})}function qt({kind:e,assistantId:t,systemTasks:n,canOpenMemorySettings:a,isMobile:s,onClose:c}){let l=o(),{heartbeatConfig:d,consolidationConfig:p,retrospectiveConfig:m}=n,h,g,_,y,S,C,w;e===`heartbeat`?(h=`Heartbeat`,g=d?dt(d):``,_=d?.enabled??!1,y=d?.nextRunAt??null,S=d?.lastRunAt??null,C=n.isHeartbeatRunning,w=n.runHeartbeatNow):e===`consolidation`?(h=`Consolidation`,g=p?ft(p):``,_=p?.enabled??!1,y=p?.nextRunAt??null,S=p?.lastRunAt??null,C=n.isConsolidationRunning,w=n.runConsolidationNow):(h=`Memory retrospective`,g=pt,_=m?.enabled??!1,y=m?.nextRunAt??null,S=m?.lastRunAt??null,C=!1,w=void 0);let T=e!==`heartbeat`,E=e===`retrospective`,O=T&&!_,k=C||O,A=T?_?`On · Managed by Memory`:`Paused`:_?`Enabled`:`Disabled`,j=E?`Memory is off, so retrospectives are paused. Turn Memory back on to resume them.`:`Memory is off, so consolidation is paused. Turn Memory back on to resume consolidation.`,M=T&&_&&a,P={path:{assistant_id:t},query:{limit:25}},F=e===`heartbeat`?N(P):e===`consolidation`?ne(P):re(P),{data:ee,isLoading:te,fetchNextPage:I,hasNextPage:L,isFetchingNextPage:ie}=ye({queryKey:F.queryKey,queryFn:F.queryFn,initialPageParam:{path:P.path,query:{}},getNextPageParam:e=>e.nextCursor??void 0,staleTime:1e4}),R=st(ee?.pages.map(t=>({runs:t.runs.map(t=>Z(t,e))})));return(0,G.jsxs)(`div`,{className:r(`flex h-full flex-col bg-[var(--surface-overlay)]`,!s&&`rounded-[var(--radius-xl)] border border-[var(--border-base)]`),children:[(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3 border-b border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[(0,G.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,G.jsx)(u,{variant:`title-small`,className:`truncate text-[var(--content-default)]`,children:h}),g?(0,G.jsx)(u,{variant:`body-small-default`,as:`p`,className:`truncate text-[var(--content-tertiary)]`,children:g}):null]}),(0,G.jsx)(i,{variant:`ghost`,iconOnly:(0,G.jsx)(b,{}),onClick:c,"aria-label":`Close schedule details`,tooltip:`Close`,className:`shrink-0`})]}),(0,G.jsxs)(`div`,{className:`flex-1 space-y-6 overflow-y-auto px-[var(--app-spacing-lg)] py-[var(--app-spacing-lg)]`,children:[(0,G.jsxs)(`section`,{children:[(0,G.jsx)(Kt,{children:`Details`}),(0,G.jsxs)(`div`,{className:`space-y-2 rounded-lg border border-[var(--border-base)] bg-[var(--surface-lift)] px-4 py-3 text-body-medium-lighter`,children:[(0,G.jsx)(Ut,{assistantId:t,defaultCallSite:Gt[e],fallbackLabel:`Default (system task model)`,respectCallSiteOverride:!0}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Status`}),(0,G.jsxs)(`span`,{className:`flex items-center gap-2 text-[var(--content-default)]`,children:[(0,G.jsx)(`span`,{children:A}),T?null:(0,G.jsx)(D,{checked:_,onChange:n.toggleHeartbeat,"aria-label":`Toggle ${h}`})]})]}),E?null:(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Next run`}),(0,G.jsx)(`span`,{className:`text-[var(--content-default)]`,children:q(y)})]}),(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-4`,children:[(0,G.jsx)(`span`,{className:`text-[var(--content-secondary)]`,children:`Last run`}),(0,G.jsx)(`span`,{className:`text-[var(--content-default)]`,children:q(S)})]})]}),O?(0,G.jsx)(x,{tone:`warning`,className:`mt-4`,actions:a?(0,G.jsx)(i,{variant:`outlined`,size:`compact`,onClick:()=>l(`${z.settings.developer}?tab=memory`),children:`Turn on Memory`}):void 0,children:j}):null]}),(0,G.jsx)(Wt,{runs:R,isLoading:te,hasMore:L,isLoadingMore:ie,onLoadMore:()=>void I()})]}),M||w?(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center justify-end gap-2 border-t border-[var(--border-base)] p-[var(--app-spacing-lg)]`,children:[M?(0,G.jsx)(i,{variant:`outlined`,leftIcon:(0,G.jsx)(f,{className:`h-3.5 w-3.5`}),onClick:()=>l(`${z.settings.developer}?tab=memory`),children:`Memory settings`}):null,w?(0,G.jsx)(i,{variant:`primary`,leftIcon:C?(0,G.jsx)(v,{className:`h-3.5 w-3.5 animate-spin`}):(0,G.jsx)(be,{className:`h-3.5 w-3.5`}),onClick:w,disabled:k,children:C?`Running…`:`Run now`}):null]}):null]})}function Jt(e){let n=V(),[r]=(0,H.useState)(()=>Date.now()),{data:i,isLoading:a,isError:o,refetch:s}=c(ke(e)),{data:l,isLoading:u,isError:d}=c(gt(e,n,!0)),{recurring:f,oneTime:p,pastOneTime:m}=(0,H.useMemo)(()=>{let e=ht(i??[],r);return{recurring:e.recurring,oneTime:e.upcomingOneTime,pastOneTime:e.pastOneTime}},[r,i]),h=(0,H.useMemo)(()=>new Map((l??[]).map(e=>[e.scheduleId,e])),[l]);return{recurring:f,oneTime:p,pastOneTime:m,usageForSchedule:(0,H.useCallback)(e=>u?{status:`loading`}:d?{status:`error`}:{status:`ready`,summary:h.get(e)??_t(e)},[d,u,h]),handleToggle:(0,H.useCallback)(async(n,r)=>{if(e)try{await Ce(e,n,r),s()}catch(e){t(e,{context:`schedule_toggle`}),k.error(`Failed to toggle schedule.`)}},[e,s]),isLoading:a,isError:o,refetch:(0,H.useCallback)(()=>{s()},[s])}}function Yt(){let e=o(),{scheduleId:t}=a(),n=me(),r=pe(),i=V(),s=Jt(n),c=Dt(n,i),l=ve(`memoryOptOut`),u=B.use.settingsDeveloperNav(),d=l&&u===!0,[f,p]=(0,H.useState)(!1),m=t??null,[h,g]=(0,H.useState)(null),[_,v]=(0,H.useState)(!1),y=(0,H.useCallback)(t=>{e(t?z.schedules.detail(t):z.schedules.root)},[e]),b=m?s.recurring.find(e=>e.id===m)??s.oneTime.find(e=>e.id===m)??s.pastOneTime.find(e=>e.id===m)??null:null;(0,H.useEffect)(()=>{m&&!s.isLoading&&!s.isError&&!b&&y(null)},[m,b,s.isLoading,s.isError,y]);let x=h===`heartbeat`?c.heartbeatConfig!=null:h===`consolidation`?c.consolidationConfig?.available===!0:h===`retrospective`?c.retrospectiveConfig?.available===!0:!1;(0,H.useEffect)(()=>{h&&!c.isLoading&&!x&&g(null)},[h,x,c.isLoading]);let S=(0,H.useCallback)(e=>{g(null),y(e)},[y]),C=(0,H.useCallback)(e=>{m&&y(null),g(e)},[y,m]),w=(0,H.useCallback)(()=>{_e(e)},[e]),T=(b?(0,G.jsx)(Pt,{schedule:b,assistantId:n,usage:s.usageForSchedule(b.id),isMobile:r,onClose:()=>y(null),onDeleted:()=>{y(null),s.refetch()}}):null)??(h&&x?(0,G.jsx)(qt,{kind:h,assistantId:n,systemTasks:c,canOpenMemorySettings:d,isMobile:r,onClose:()=>g(null)}):null),E=(0,G.jsx)(Rt,{recurring:s.recurring,oneTime:s.oneTime,pastOneTime:s.pastOneTime,usageForSchedule:s.usageForSchedule,isLoading:s.isLoading,isError:s.isError,refetch:s.refetch,onToggle:s.handleToggle,onSelectSchedule:S,selectedScheduleId:m,onStartNewChat:w,onCreateSchedule:()=>p(!0),pastOpen:_,onPastOpenChange:v,systemTasksSlot:(0,G.jsx)(St,{heartbeatConfig:c.heartbeatConfig,consolidationConfig:c.consolidationConfig,retrospectiveConfig:c.retrospectiveConfig,heartbeatUsage:c.heartbeatUsage,consolidationUsage:c.consolidationUsage,retrospectiveUsage:c.retrospectiveUsage,isLoading:c.isLoading,hasError:c.hasError,onRetry:c.refetchAll,onSelectHeartbeat:()=>C(`heartbeat`),onSelectConsolidation:()=>C(`consolidation`),onSelectRetrospective:()=>C(`retrospective`)})});return T&&r?(0,G.jsx)(je,{children:T}):(0,G.jsxs)(G.Fragment,{children:[T&&!r?(0,G.jsx)(Te,{storageKey:`schedulesDetailDrawerWidth`,detailKey:m??h??void 0,section:E,detail:T}):E,(0,G.jsx)(Ye,{isOpen:f,assistantId:n,onClose:()=>p(!1),onCreated:()=>{p(!1),s.refetch()}})]})}export{Yt as SchedulesPage};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-CW7wKp2r.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./check-wF3S-AV4.js";import{t as s}from"./modal-D_Y2RPD5.js";import{t as c}from"./confirm-dialog-DxBl6zcI.js";import{P as l,j as u,k as d,lt as f,rt as p,t as ee,u as te}from"./local-mode-Dydd46cS.js";import{t as m}from"./is-electron-y5bNUVyG.js";import{n as h}from"./resolved-assistants-store-DdHm-7v4.js";import{D as g,O as _,i as v,n as y}from"./auth-store-Lzg3kiaw.js";import{u as b}from"./routes-D4ff4ONd.js";import{t as x}from"./use-onboarding-login-DMLLDHRX.js";import{g as S,hn as C,js as w,or as T,sr as ne,vs as E}from"./index-C7ix_asE.js";var D=e(t(),1),O=a();function k({open:e,assistantName:t,isPending:r,errorMessage:i,onCancel:a,onRepair:o,onRetire:l}){let[u,d]=(0,D.useState)(`menu`);(0,D.useEffect)(()=>{e&&d(`menu`)},[e]);let f=i?(0,O.jsx)(`span`,{className:`mt-3 block text-body-small-default text-[var(--system-negative-strong)]`,children:i}):null;return u===`confirm-repair`?(0,O.jsx)(c,{open:e,title:`Repair Assistant?`,message:(0,O.jsxs)(O.Fragment,{children:[`Repairing re-provisions this assistant’s authentication token. Any other devices or browser sessions connected to it will be signed out and need to reconnect.`,f]}),confirmLabel:`Repair`,isPending:r,onConfirm:o,onCancel:()=>d(`menu`)}):u===`confirm-retire`?(0,O.jsx)(T,{open:e,isPending:r,extraMessage:f,onConfirm:l,onCancel:()=>d(`menu`)}):(0,O.jsx)(s.Root,{open:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,O.jsxs)(s.Content,{size:`sm`,hideCloseButton:!0,onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation(),r||a()},children:[(0,O.jsx)(s.Header,{children:(0,O.jsx)(s.Title,{children:`Can’t Authenticate Assistant`})}),(0,O.jsxs)(s.Body,{children:[(0,O.jsxs)(s.Description,{children:[`The authentication token for `,t,` is missing or can no longer be refreshed, so this assistant can’t be connected. You can repair it, retire it, or pick a different assistant.`]}),f,(0,O.jsxs)(`div`,{className:`mt-5 flex w-full flex-col gap-2`,children:[(0,O.jsx)(n,{variant:`primary`,fullWidth:!0,disabled:r,onClick:()=>d(`confirm-repair`),children:`Wake & Repair`}),(0,O.jsx)(n,{variant:`dangerOutline`,fullWidth:!0,disabled:r,onClick:()=>d(`confirm-retire`),children:`Retire Assistant`}),(0,O.jsx)(n,{variant:`outlined`,fullWidth:!0,disabled:r,onClick:a,children:`Cancel`})]})]})]})})}function A(e){return e.name?e.name:e.isLocal?`Local Assistant`:`Cloud Assistant`}function j(e){if(e.hatchedAt)return`Created ${S(e.hatchedAt)}`}function M(){let e=i(),[t]=r(),a=t.get(`fromLogin`)===`1`,o=t.get(`noAutoSkip`)===`1`,s=m(),c=v(),S=h.use.assistants(),w=g.use.currentOrganizationId(),{loading:T,error:E,login:j,cancel:M}=x(),P=e=>e.isLocal||c,F=S.filter(P),I=S.some(e=>e.isPlatformHosted)&&!c,[L,R]=(0,D.useState)(null),[z,B]=(0,D.useState)(!1),[V,H]=(0,D.useState)(!1),[U,W]=(0,D.useState)(null),[G,K]=(0,D.useState)(null),[q,J]=(0,D.useState)(!1),[Y,X]=(0,D.useState)(null);(0,D.useEffect)(()=>{if(L!=null||F.length===0)return;let e=_(w);R(F.find(t=>t.id===e)?.id??F[0].id)},[L,F,w]);let Z=async t=>{B(!0),W(null);try{t.isLocal?await y.getState().connectLocalAssistant(t.id):await y.getState().connectPlatformAssistant(t.id),e(b.assistant,{replace:!0})}catch(e){console.error(`selectAssistant.handleConnect failed`,e),t.isLocal&&d()&&(u(e)||f(e)||e instanceof ee)&&te(t.id)?K(t):W(`Failed to connect. Please try again.`),B(!1)}},Q=()=>{K(null),J(!1),X(null),H(!1)},re=async()=>{if(!(!G||q)){J(!0),X(null);try{let e=await l(G.id,{repairGuardian:!0});if(e.ok){p(),Q(),Z(G);return}X(e.error||`Repair failed. Please try again.`)}catch(e){console.error(`selectAssistant.recoveryRepair failed`,e),X(`Repair failed. Please try again.`)}J(!1)}},ie=async()=>{if(!(!G||q)){J(!0),X(null);try{let t=await ne(G.id);if(t.ok){Q(),e(t.nextRoute,{replace:!0});return}X(t.error)}catch(e){console.error(`selectAssistant.recoveryRetire failed`,e),X(`Failed to retire assistant. Please try again.`)}J(!1)}};(0,D.useEffect)(()=>{a||o||z||V||S.length!==0&&S.length===1&&F.length===1&&(H(!0),Z(F[0]))},[S.length,F.length]);let ae=()=>{let e=S.find(e=>e.id===L);e&&Z(e)},oe=()=>{e(b.welcome)},$=E??U;return V&&!$&&!G?(0,O.jsx)(C,{children:(0,O.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-xl flex-col items-center justify-center px-6 text-[var(--content-default)]`,children:(0,O.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Connecting to your assistant…`})})}):(0,O.jsxs)(C,{children:[(0,O.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${s?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`min-h-screen px-6 pb-40 pt-16`} text-[var(--content-default)]`,children:[(0,O.jsx)(`h1`,{className:s?`text-title-large`:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Choose an Assistant`}),(0,O.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${s?`mt-3.5`:`mt-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Select which assistant you’d like to use.`}),$&&(0,O.jsx)(`p`,{className:`mt-4 text-body-small-default text-[var(--system-negative-strong)]`,children:$}),(0,O.jsx)(`div`,{className:`flex w-full flex-col ${s?`mt-8 gap-2`:`mt-10 gap-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.4s both`},children:S.map(e=>{let t=P(e);return(0,O.jsx)(N,{assistant:e,selected:L===e.id,disabled:!t,badge:!t&&e.isPlatformHosted?`Requires Account`:void 0,onSelect:()=>{t&&R(e.id)}},e.id)})}),(0,O.jsxs)(`div`,{className:`mt-8 flex w-full flex-col ${s?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[F.length>0&&(0,O.jsx)(n,{variant:`primary`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:ae,disabled:!L||z,children:z?`Connecting…`:`Continue`}),(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:()=>void e(`${b.onboarding.hosting}?from=select-assistant`),disabled:z||T,children:`Create New Assistant`}),I&&(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:T?M:()=>void j(),disabled:z,children:T?`Cancel`:`Log In`}),(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:oe,disabled:z||T,children:`Back`})]})]}),(0,O.jsx)(k,{open:G!=null,assistantName:G?A(G):``,isPending:q,errorMessage:Y??void 0,onCancel:Q,onRepair:()=>void re(),onRetire:()=>void ie()})]})}function N({assistant:e,selected:t,disabled:n,badge:r,onSelect:i}){let a=j(e),s=m();return(0,O.jsxs)(`button`,{type:`button`,onClick:i,disabled:n,className:[`group flex w-full items-center border text-left`,s?`gap-3 rounded-lg p-3`:`gap-4 rounded-2xl px-5 py-4`,`transition-all duration-200 ease-out`,n?`cursor-not-allowed opacity-50`:`cursor-pointer hover:bg-[var(--surface-secondary)]`,t&&!n?`border-[var(--primary-base)] bg-[var(--primary-base)]/[0.08] shadow-[inset_0_0_0_1px_var(--primary-base)]`:`border-[var(--border-element)] bg-transparent`].join(` `),children:[(0,O.jsx)(`div`,{className:[`flex shrink-0 items-center justify-center transition-colors duration-200`,s?`h-8 w-8 rounded-lg`:`h-10 w-10 rounded-xl`,t&&!n?`bg-[var(--primary-base)]/15 text-[var(--primary-base)]`:`bg-[var(--surface-tertiary)] text-[var(--content-secondary)]`].join(` `),children:e.isLocal?(0,O.jsx)(E,{className:`h-5 w-5`}):(0,O.jsx)(w,{className:`h-5 w-5`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:A(e)}),r&&(0,O.jsx)(`span`,{className:`rounded-full bg-[var(--surface-tertiary)] px-2 py-0.5 text-[var(--content-tertiary)] ${s?`text-label-medium-default`:`text-body-small-default`}`,children:r})]}),a&&(0,O.jsx)(`span`,{className:`mt-0.5 block text-[var(--content-tertiary)] ${s?`text-label-medium-default`:`text-body-small-default`}`,children:a})]}),!n&&(0,O.jsx)(`div`,{className:[`flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 transition-all duration-200`,t?`border-[var(--primary-base)] bg-[var(--primary-base)]`:`border-[var(--border-element)] group-hover:border-[var(--content-tertiary)]`].join(` `),children:t&&(0,O.jsx)(o,{className:`h-3 w-3 text-[var(--surface-base)]`,strokeWidth:3})})]})}export{M as SelectAssistantScreen};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{t as n}from"./button-CW7wKp2r.js";import{m as r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./check-wF3S-AV4.js";import{t as s}from"./modal-D_Y2RPD5.js";import{t as c}from"./confirm-dialog-DxBl6zcI.js";import{P as l,j as u,k as d,lt as f,rt as p,t as ee,u as te}from"./local-mode-Dydd46cS.js";import{t as m}from"./is-electron-y5bNUVyG.js";import{n as h}from"./resolved-assistants-store-DdHm-7v4.js";import{D as g,O as _,i as v,n as y}from"./auth-store-quPkF_4z.js";import{u as b}from"./routes-D4ff4ONd.js";import{t as x}from"./use-onboarding-login-6LWa5XdQ.js";import{g as S,hn as C,js as w,or as T,sr as ne,vs as E}from"./index-Ck1SrvnM.js";var D=e(t(),1),O=a();function k({open:e,assistantName:t,isPending:r,errorMessage:i,onCancel:a,onRepair:o,onRetire:l}){let[u,d]=(0,D.useState)(`menu`);(0,D.useEffect)(()=>{e&&d(`menu`)},[e]);let f=i?(0,O.jsx)(`span`,{className:`mt-3 block text-body-small-default text-[var(--system-negative-strong)]`,children:i}):null;return u===`confirm-repair`?(0,O.jsx)(c,{open:e,title:`Repair Assistant?`,message:(0,O.jsxs)(O.Fragment,{children:[`Repairing re-provisions this assistant’s authentication token. Any other devices or browser sessions connected to it will be signed out and need to reconnect.`,f]}),confirmLabel:`Repair`,isPending:r,onConfirm:o,onCancel:()=>d(`menu`)}):u===`confirm-retire`?(0,O.jsx)(T,{open:e,isPending:r,extraMessage:f,onConfirm:l,onCancel:()=>d(`menu`)}):(0,O.jsx)(s.Root,{open:e,onOpenChange:e=>{!e&&!r&&a()},children:(0,O.jsxs)(s.Content,{size:`sm`,hideCloseButton:!0,onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation(),r||a()},children:[(0,O.jsx)(s.Header,{children:(0,O.jsx)(s.Title,{children:`Can’t Authenticate Assistant`})}),(0,O.jsxs)(s.Body,{children:[(0,O.jsxs)(s.Description,{children:[`The authentication token for `,t,` is missing or can no longer be refreshed, so this assistant can’t be connected. You can repair it, retire it, or pick a different assistant.`]}),f,(0,O.jsxs)(`div`,{className:`mt-5 flex w-full flex-col gap-2`,children:[(0,O.jsx)(n,{variant:`primary`,fullWidth:!0,disabled:r,onClick:()=>d(`confirm-repair`),children:`Wake & Repair`}),(0,O.jsx)(n,{variant:`dangerOutline`,fullWidth:!0,disabled:r,onClick:()=>d(`confirm-retire`),children:`Retire Assistant`}),(0,O.jsx)(n,{variant:`outlined`,fullWidth:!0,disabled:r,onClick:a,children:`Cancel`})]})]})]})})}function A(e){return e.name?e.name:e.isLocal?`Local Assistant`:`Cloud Assistant`}function j(e){if(e.hatchedAt)return`Created ${S(e.hatchedAt)}`}function M(){let e=i(),[t]=r(),a=t.get(`fromLogin`)===`1`,o=t.get(`noAutoSkip`)===`1`,s=m(),c=v(),S=h.use.assistants(),w=g.use.currentOrganizationId(),{loading:T,error:E,login:j,cancel:M}=x(),P=e=>e.isLocal||c,F=S.filter(P),I=S.some(e=>e.isPlatformHosted)&&!c,[L,R]=(0,D.useState)(null),[z,B]=(0,D.useState)(!1),[V,H]=(0,D.useState)(!1),[U,W]=(0,D.useState)(null),[G,K]=(0,D.useState)(null),[q,J]=(0,D.useState)(!1),[Y,X]=(0,D.useState)(null);(0,D.useEffect)(()=>{if(L!=null||F.length===0)return;let e=_(w);R(F.find(t=>t.id===e)?.id??F[0].id)},[L,F,w]);let Z=async t=>{B(!0),W(null);try{t.isLocal?await y.getState().connectLocalAssistant(t.id):await y.getState().connectPlatformAssistant(t.id),e(b.assistant,{replace:!0})}catch(e){console.error(`selectAssistant.handleConnect failed`,e),t.isLocal&&d()&&(u(e)||f(e)||e instanceof ee)&&te(t.id)?K(t):W(`Failed to connect. Please try again.`),B(!1)}},Q=()=>{K(null),J(!1),X(null),H(!1)},re=async()=>{if(!(!G||q)){J(!0),X(null);try{let e=await l(G.id,{repairGuardian:!0});if(e.ok){p(),Q(),Z(G);return}X(e.error||`Repair failed. Please try again.`)}catch(e){console.error(`selectAssistant.recoveryRepair failed`,e),X(`Repair failed. Please try again.`)}J(!1)}},ie=async()=>{if(!(!G||q)){J(!0),X(null);try{let t=await ne(G.id);if(t.ok){Q(),e(t.nextRoute,{replace:!0});return}X(t.error)}catch(e){console.error(`selectAssistant.recoveryRetire failed`,e),X(`Failed to retire assistant. Please try again.`)}J(!1)}};(0,D.useEffect)(()=>{a||o||z||V||S.length!==0&&S.length===1&&F.length===1&&(H(!0),Z(F[0]))},[S.length,F.length]);let ae=()=>{let e=S.find(e=>e.id===L);e&&Z(e)},oe=()=>{e(b.welcome)},$=E??U;return V&&!$&&!G?(0,O.jsx)(C,{children:(0,O.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-xl flex-col items-center justify-center px-6 text-[var(--content-default)]`,children:(0,O.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)]`,children:`Connecting to your assistant…`})})}):(0,O.jsxs)(C,{children:[(0,O.jsxs)(`div`,{className:`mx-auto flex w-full max-w-xl flex-col items-center ${s?`min-h-full px-8 pt-21 pb-4 electron-prechat-type`:`min-h-screen px-6 pb-40 pt-16`} text-[var(--content-default)]`,children:[(0,O.jsx)(`h1`,{className:s?`text-title-large`:`text-3xl font-semibold tracking-tight`,style:{animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Choose an Assistant`}),(0,O.jsx)(`p`,{className:`text-body-medium-lighter text-[var(--content-tertiary)] ${s?`mt-3.5`:`mt-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Select which assistant you’d like to use.`}),$&&(0,O.jsx)(`p`,{className:`mt-4 text-body-small-default text-[var(--system-negative-strong)]`,children:$}),(0,O.jsx)(`div`,{className:`flex w-full flex-col ${s?`mt-8 gap-2`:`mt-10 gap-3`}`,style:{animation:`fadeInUp 0.5s ease-out 0.4s both`},children:S.map(e=>{let t=P(e);return(0,O.jsx)(N,{assistant:e,selected:L===e.id,disabled:!t,badge:!t&&e.isPlatformHosted?`Requires Account`:void 0,onSelect:()=>{t&&R(e.id)}},e.id)})}),(0,O.jsxs)(`div`,{className:`mt-8 flex w-full flex-col ${s?`gap-2.5`:`gap-2`}`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[F.length>0&&(0,O.jsx)(n,{variant:`primary`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:ae,disabled:!L||z,children:z?`Connecting…`:`Continue`}),(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:()=>void e(`${b.onboarding.hosting}?from=select-assistant`),disabled:z||T,children:`Create New Assistant`}),I&&(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:T?M:()=>void j(),disabled:z,children:T?`Cancel`:`Log In`}),(0,O.jsx)(n,{variant:`outlined`,size:`regular`,fullWidth:!0,className:s?void 0:`h-11 text-base`,onClick:oe,disabled:z||T,children:`Back`})]})]}),(0,O.jsx)(k,{open:G!=null,assistantName:G?A(G):``,isPending:q,errorMessage:Y??void 0,onCancel:Q,onRepair:()=>void re(),onRetire:()=>void ie()})]})}function N({assistant:e,selected:t,disabled:n,badge:r,onSelect:i}){let a=j(e),s=m();return(0,O.jsxs)(`button`,{type:`button`,onClick:i,disabled:n,className:[`group flex w-full items-center border text-left`,s?`gap-3 rounded-lg p-3`:`gap-4 rounded-2xl px-5 py-4`,`transition-all duration-200 ease-out`,n?`cursor-not-allowed opacity-50`:`cursor-pointer hover:bg-[var(--surface-secondary)]`,t&&!n?`border-[var(--primary-base)] bg-[var(--primary-base)]/[0.08] shadow-[inset_0_0_0_1px_var(--primary-base)]`:`border-[var(--border-element)] bg-transparent`].join(` `),children:[(0,O.jsx)(`div`,{className:[`flex shrink-0 items-center justify-center transition-colors duration-200`,s?`h-8 w-8 rounded-lg`:`h-10 w-10 rounded-xl`,t&&!n?`bg-[var(--primary-base)]/15 text-[var(--primary-base)]`:`bg-[var(--surface-tertiary)] text-[var(--content-secondary)]`].join(` `),children:e.isLocal?(0,O.jsx)(E,{className:`h-5 w-5`}):(0,O.jsx)(w,{className:`h-5 w-5`})}),(0,O.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,O.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,O.jsx)(`span`,{className:`text-body-medium-default text-[var(--content-default)]`,children:A(e)}),r&&(0,O.jsx)(`span`,{className:`rounded-full bg-[var(--surface-tertiary)] px-2 py-0.5 text-[var(--content-tertiary)] ${s?`text-label-medium-default`:`text-body-small-default`}`,children:r})]}),a&&(0,O.jsx)(`span`,{className:`mt-0.5 block text-[var(--content-tertiary)] ${s?`text-label-medium-default`:`text-body-small-default`}`,children:a})]}),!n&&(0,O.jsx)(`div`,{className:[`flex h-5 w-5 shrink-0 items-center justify-center rounded-full border-2 transition-all duration-200`,t?`border-[var(--primary-base)] bg-[var(--primary-base)]`:`border-[var(--border-element)] group-hover:border-[var(--content-tertiary)]`].join(` `),children:t&&(0,O.jsx)(o,{className:`h-3 w-3 text-[var(--surface-base)]`,strokeWidth:3})})]})}export{M as SelectAssistantScreen};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{l as n,r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./log-in-khREn0DP.js";import{i as s}from"./auth-store-Lzg3kiaw.js";import{u as c}from"./routes-D4ff4ONd.js";import{t as l}from"./client-feature-flag-store-BOcAh56y.js";import{t as u}from"./use-onboarding-login-DMLLDHRX.js";import{t as d}from"./assistant-feature-flag-store-Bh-_qc7v.js";import{Vt as f,fo as p,fs as m,za as h}from"./index-C7ix_asE.js";import{n as g,t as _}from"./sidebar-tree-CDqUGPSK.js";var v=e(t(),1),y=a();function b(){let e=d.use.settingsDeveloperNav(),t=d.use.credentialsSettings(),a=l.use.platformNotifications(),b=p({platformHostedOnly:!0}),x=p()===`full`?`Billing & Usage`:`Usage`,{pathname:S}=n(),C=i(),w=s(),{login:T}=u(),E=(0,v.useMemo)(()=>f.filter(e=>!(e.id===`notifications`&&(!a||b===`gated`)||e.id===`credentials`&&!t||e.id===`developer`)).map(e=>e.id===`billing`?{...e,label:x}:e),[a,b,t,x]),D=(0,v.useMemo)(()=>{let t=[];return e&&t.push(...f.filter(e=>e.id===`developer`)),t.push(w?{id:`logout`,label:`Log Out`,icon:m,onSelect:()=>void h(C)}:{id:`login`,label:`Log In`,icon:o,onSelect:()=>void T()}),t},[e,w,C,T]),O=(0,v.useMemo)(()=>{if(S===c.settings.root)return`Settings`;let e=f.find(e=>S===e.href||S.startsWith(e.href+`/`));return e?e.id===`billing`?x:e.label:`Settings`},[S,x]);return(0,y.jsx)(g,{backHref:c.assistant,sidebar:(0,y.jsx)(_,{items:E,bottomItems:D,indexPath:c.settings.root}),title:O,children:(0,y.jsx)(r,{})})}export{b as SettingsLayout};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-DJZBPgpf.js";import{l as n,r,u as i}from"./chunk-5KNZJZUH-SU6Q_tDT.js";import{t as a}from"./jsx-runtime-CVSDxk6A.js";import{t as o}from"./log-in-khREn0DP.js";import{i as s}from"./auth-store-quPkF_4z.js";import{u as c}from"./routes-D4ff4ONd.js";import{t as l}from"./client-feature-flag-store-BOcAh56y.js";import{t as u}from"./use-onboarding-login-6LWa5XdQ.js";import{t as d}from"./assistant-feature-flag-store-Bh-_qc7v.js";import{Vt as f,fo as p,fs as m,za as h}from"./index-Ck1SrvnM.js";import{n as g,t as _}from"./sidebar-tree-X01ptIng.js";var v=e(t(),1),y=a();function b(){let e=d.use.settingsDeveloperNav(),t=d.use.credentialsSettings(),a=l.use.platformNotifications(),b=p({platformHostedOnly:!0}),x=p()===`full`?`Billing & Usage`:`Usage`,{pathname:S}=n(),C=i(),w=s(),{login:T}=u(),E=(0,v.useMemo)(()=>f.filter(e=>!(e.id===`notifications`&&(!a||b===`gated`)||e.id===`credentials`&&!t||e.id===`developer`)).map(e=>e.id===`billing`?{...e,label:x}:e),[a,b,t,x]),D=(0,v.useMemo)(()=>{let t=[];return e&&t.push(...f.filter(e=>e.id===`developer`)),t.push(w?{id:`logout`,label:`Log Out`,icon:m,onSelect:()=>void h(C)}:{id:`login`,label:`Log In`,icon:o,onSelect:()=>void T()}),t},[e,w,C,T]),O=(0,v.useMemo)(()=>{if(S===c.settings.root)return`Settings`;let e=f.find(e=>S===e.href||S.startsWith(e.href+`/`));return e?e.id===`billing`?x:e.label:`Settings`},[S,x]);return(0,y.jsx)(g,{backHref:c.assistant,sidebar:(0,y.jsx)(_,{items:E,bottomItems:D,indexPath:c.settings.root}),title:O,children:(0,y.jsx)(r,{})})}export{b as SettingsLayout};