@vellumai/web 0.11.2-dev.202608050137.0c8f50a → 0.11.2-dev.202608050309.fa8263f

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 (138) hide show
  1. package/dist/assets/access-INPRM_aM.js +1 -0
  2. package/dist/assets/{account-page-oJluvmyu.js → account-page-DjVlZWVH.js} +1 -1
  3. package/dist/assets/{acp-run-detail-panel-SF3Cd2Y1.js → acp-run-detail-panel-CYIyDAYY.js} +1 -1
  4. package/dist/assets/{activity-steps-panel-Bf7vfY3x.js → activity-steps-panel-DI7oxT6n.js} +1 -1
  5. package/dist/assets/{add-credits-modal-Bf2YtuiY.js → add-credits-modal-BsOahXBH.js} +1 -1
  6. package/dist/assets/{ai-page-DzDrUG4B.js → ai-page-DOo45fbr.js} +1 -1
  7. package/dist/assets/{api-Du7TU0QH.js → api-BbdlW3Wt.js} +1 -1
  8. package/dist/assets/{api-DZ1FASA0.js → api-nvrU4YoP.js} +1 -1
  9. package/dist/assets/{app-card-D_hiQfXt.js → app-card-DRJg7paP.js} +1 -1
  10. package/dist/assets/{assistant-feature-flag-store-B38SPaJa.js → assistant-feature-flag-store-N5OiUTEL.js} +1 -1
  11. package/dist/assets/{assistant-status-panel-BWsrTfK7.js → assistant-status-panel-SNr_dm8a.js} +1 -1
  12. package/dist/assets/auth-store-BZjAJNpH.js +2 -0
  13. package/dist/assets/{avatar-random-YP7nnkKq.js → avatar-random-B2ASlInK.js} +1 -1
  14. package/dist/assets/{background-task-detail-panel-CVc1_RgU.js → background-task-detail-panel-qWFvJ3e4.js} +1 -1
  15. package/dist/assets/{billing-page-savrq3xn.js → billing-page-BRrzQ-GL.js} +1 -1
  16. package/dist/assets/{bookmarks-page-sxUYn21c.js → bookmarks-page-Av_hWQOR.js} +1 -1
  17. package/dist/assets/{browser-OiWKXQtn.js → browser-COAyWDHw.js} +1 -1
  18. package/dist/assets/{build-state-DQX02fuw.js → build-state-BOnYvQ5M.js} +1 -1
  19. package/dist/assets/{channels-page-route--BPWHssi.js → channels-page-route-BPJlOqGo.js} +1 -1
  20. package/dist/assets/{chat-markdown-message-DNvDe2IS.js → chat-markdown-message-DZrSbzma.js} +1 -1
  21. package/dist/assets/checkout-continuation-D8RJlny7.js +1 -0
  22. package/dist/assets/{checkout-page-DoEIUiiE.js → checkout-page-DrZpel2T.js} +1 -1
  23. package/dist/assets/{client-feature-flag-store-DXK8Z7NT.js → client-feature-flag-store-D52k_a_E.js} +1 -1
  24. package/dist/assets/{client-perf-BrZz3Mpl.js → client-perf-DjfIe5LZ.js} +1 -1
  25. package/dist/assets/{command-palette-BzCLrSWF.js → command-palette-BigjlvPf.js} +1 -1
  26. package/dist/assets/{command-palette-window-page-Bar4rPii.js → command-palette-window-page-Bj33Fonm.js} +1 -1
  27. package/dist/assets/{composer-settings-BAq8X7A3.js → composer-settings-C22o1zsH.js} +1 -1
  28. package/dist/assets/{contacts-page-route-CKzbasmB.js → contacts-page-route-CT-F9Uyv.js} +1 -1
  29. package/dist/assets/{conversation-cache-BfZuxKKb.js → conversation-cache-NwL8DG0h.js} +1 -1
  30. package/dist/assets/{conversation-list-fetchers-DeJjdZ02.js → conversation-list-fetchers-ZLqN0i2Q.js} +1 -1
  31. package/dist/assets/{conversation-navigation-Bvhw1EOw.js → conversation-navigation-7utFvr1F.js} +1 -1
  32. package/dist/assets/{conversation-queries-BKN00Bls.js → conversation-queries-NcoEa-m7.js} +1 -1
  33. package/dist/assets/{credential-entry-page-BmdIrT2Y.js → credential-entry-page-Bcp2UvSU.js} +1 -1
  34. package/dist/assets/{credentials-page-C8fLd-2y.js → credentials-page-Dw2YMFyU.js} +1 -1
  35. package/dist/assets/{debug-page-BJ24FQmL.js → debug-page-6wX9N5-9.js} +1 -1
  36. package/dist/assets/{developer-page-BxS6g7X8.js → developer-page-Cf2Hsxff.js} +1 -1
  37. package/dist/assets/{diagnostics-_ZD3ioXN.js → diagnostics-Bss-eL9u.js} +1 -1
  38. package/dist/assets/{doctor-handoff-store-ChvNtnd_.js → doctor-handoff-store-Dgsz1SEJ.js} +1 -1
  39. package/dist/assets/{document-viewer-page-DEPRfmWT.js → document-viewer-page-D1GxRw_5.js} +1 -1
  40. package/dist/assets/{emails-page-BnDY30p0.js → emails-page-Dw8E0XPa.js} +1 -1
  41. package/dist/assets/{first-run-scope-Df_gGGNm.js → first-run-scope-vVgdnaxO.js} +1 -1
  42. package/dist/assets/{funnel-events-BKW4C5Jf.js → funnel-events-tVQwgCuQ.js} +1 -1
  43. package/dist/assets/{general-page-BIb0cuR1.js → general-page-BmOj-tFZ.js} +1 -1
  44. package/dist/assets/{haptics-DhLyE78C.js → haptics-CWVeK4vK.js} +1 -1
  45. package/dist/assets/{hatching-screen-Pr6og78J.js → hatching-screen-DX0u6V13.js} +1 -1
  46. package/dist/assets/{home-page-route-DjjXxxpU.js → home-page-route-CeMb7_IF.js} +1 -1
  47. package/dist/assets/{hosting-screen-CAMZoYZo.js → hosting-screen-DVSH4SEC.js} +1 -1
  48. package/dist/assets/{identity-page-route-CwJWYmVY.js → identity-page-route-C0xhDqb2.js} +1 -1
  49. package/dist/assets/{index-DeRGsIP3.js → index-COilDRK7.js} +1 -1
  50. package/dist/assets/{ingest-BrVPryb7.js → ingest-DLPNupgb.js} +1 -1
  51. package/dist/assets/{inspect-page-BjO9-p7V.js → inspect-page-Fs-9_UT8.js} +1 -1
  52. package/dist/assets/{integrations-page-JKlyqr71.js → integrations-page-haNwPw96.js} +1 -1
  53. package/dist/assets/{latest-assistant-text-Cb-Ghdzy.js → latest-assistant-text-Di1iMJIt.js} +1 -1
  54. package/dist/assets/{library-detail-page-Y1duKURD.js → library-detail-page-BB2oncWf.js} +1 -1
  55. package/dist/assets/{library-page-CRKnpdDM.js → library-page-ekBrsMsl.js} +1 -1
  56. package/dist/assets/{local-runtime-upgrade-BT6QBEBd.js → local-runtime-upgrade-yBKK0VHQ.js} +1 -1
  57. package/dist/assets/{login-flow-CMvSPkyf.js → login-flow-Cv6fd0k7.js} +1 -1
  58. package/dist/assets/{login-page-CRPDaiVk.js → login-page-Bhg7nETo.js} +1 -1
  59. package/dist/assets/{logout-page-CWpu9g04.js → logout-page-B0WXwIfk.js} +1 -1
  60. package/dist/assets/{logs-layout-bwOKn4Pa.js → logs-layout-CuUiFCNM.js} +1 -1
  61. package/dist/assets/{memory-page-route-UOYcnMLZ.js → memory-page-route-C8DzIVRN.js} +1 -1
  62. package/dist/assets/{memory-router-playground-page-BGD7o886.js → memory-router-playground-page-CmALtUEX.js} +1 -1
  63. package/dist/assets/{message-files-panel-vxGafAAF.js → message-files-panel-39eP4laA.js} +1 -1
  64. package/dist/assets/{messages-BdRhAWrP.js → messages-uHyh-apY.js} +1 -1
  65. package/dist/assets/{mobile-sidebar-drawer-DhERtMv3.js → mobile-sidebar-drawer-Cl-CxiPz.js} +1 -1
  66. package/dist/assets/native-anchor-RFjMKDmu.js +1 -0
  67. package/dist/assets/{navigation-resolver-C8Qyk5eO.js → navigation-resolver-BICOcF3M.js} +1 -1
  68. package/dist/assets/{notifications-DT6MYNFs.js → notifications-CeLmbVpH.js} +1 -1
  69. package/dist/assets/{notifications-page-CW_cMCqc.js → notifications-page-o2vT9Bmw.js} +1 -1
  70. package/dist/assets/{open-workspace-file-1J9ToS-d.js → open-workspace-file-DxlQEPBv.js} +2 -2
  71. package/dist/assets/{pairing-page-BgztYa3j.js → pairing-page-CioXlSXf.js} +1 -1
  72. package/dist/assets/{personality-page-2RRxkXCV.js → personality-page-BwGgtwRz.js} +1 -1
  73. package/dist/assets/{plans-page-44i492TS.js → plans-page-wWqD3Ie9.js} +1 -1
  74. package/dist/assets/{platform-detection-HB9owK_1.js → platform-detection-ClZAYwCS.js} +1 -1
  75. package/dist/assets/{platform-login-notice-CnAT6TJZ.js → platform-login-notice-DrQazymT.js} +1 -1
  76. package/dist/assets/{platform-loopback-page-BguKV0pz.js → platform-loopback-page-BVuXQaib.js} +1 -1
  77. package/dist/assets/{privacy-page-D4Ft3SSy.js → privacy-page-CeoXjDjo.js} +1 -1
  78. package/dist/assets/{privacy-screen-CauLgurD.js → privacy-screen-C4qzL1Ul.js} +1 -1
  79. package/dist/assets/{provider-callback-page-Cea5TFlV.js → provider-callback-page-CTQ986md.js} +1 -1
  80. package/dist/assets/{provider-signup-page-B5_miKb-.js → provider-signup-page-C-w5SLvU.js} +1 -1
  81. package/dist/assets/{push-registration-DXLfEroH.js → push-registration-BGoSmgni.js} +1 -1
  82. package/dist/assets/{research-onboarding-route-Z29ryU4y.js → research-onboarding-route-B8XpYAVW.js} +1 -1
  83. package/dist/assets/{retire-confirm-dialog-B-dxIKuG.js → retire-confirm-dialog-pqyV2Phc.js} +1 -1
  84. package/dist/assets/{review-terms-screen-XYNkBr0N.js → review-terms-screen-9A0cBzHW.js} +1 -1
  85. package/dist/assets/{routes-72rOaVXx.js → routes-DQmLqZE4.js} +12 -12
  86. package/dist/assets/{runtime-upgrade-banner-DSBdNsGU.js → runtime-upgrade-banner-DLrDr2eV.js} +1 -1
  87. package/dist/assets/{schedules-page-cRU86Tk_.js → schedules-page-BE16OokW.js} +1 -1
  88. package/dist/assets/{select-assistant-screen-D-kNYuuJ.js → select-assistant-screen-Dp6ms36y.js} +1 -1
  89. package/dist/assets/{settings-layout-Dh8J0arK.js → settings-layout-BccfBcC9.js} +1 -1
  90. package/dist/assets/{settings-navigation-Bz99iCom.js → settings-navigation-4wNM9U6G.js} +1 -1
  91. package/dist/assets/{share-feedback-modal-C6RtPO1y.js → share-feedback-modal-D8jik8C_.js} +1 -1
  92. package/dist/assets/{sidebar-tree-92PU_1JK.js → sidebar-tree-D-eWxuiT.js} +1 -1
  93. package/dist/assets/{signup-page-sW5_KNjN.js → signup-page-BZfNDRR7.js} +1 -1
  94. package/dist/assets/{skill-detail-page-DxrSMloo.js → skill-detail-page-Dv2PDJqy.js} +1 -1
  95. package/dist/assets/{subagent-detail-panel-Db9YPzqQ.js → subagent-detail-panel-2CCPEQV9.js} +1 -1
  96. package/dist/assets/{subagent-store-BXOhShEO.js → subagent-store-bjcKwT3Z.js} +1 -1
  97. package/dist/assets/{system-events-page-CQJ_53SO.js → system-events-page-DLap6GYQ.js} +1 -1
  98. package/dist/assets/{theme-stage-page-DkYOEAhj.js → theme-stage-page-BkfUP6id.js} +1 -1
  99. package/dist/assets/{tool-detail-panel-Cf007F2i.js → tool-detail-panel-XRiIAX_W.js} +1 -1
  100. package/dist/assets/{transcript-message-body-shared-B8cE25F6.js → transcript-message-body-shared-NonvqK2W.js} +1 -1
  101. package/dist/assets/{upgrade-cancel-page-BVTXE0dB.js → upgrade-cancel-page-Bjhnk_UH.js} +1 -1
  102. package/dist/assets/{upgrade-success-page-DgbZEPpF.js → upgrade-success-page-CAf6RjeY.js} +1 -1
  103. package/dist/assets/{use-app-theme-FEeKltJv.js → use-app-theme-DCACPYkF.js} +1 -1
  104. package/dist/assets/{use-assistant-capability-De7J71CP.js → use-assistant-capability-BMfO1JSS.js} +1 -1
  105. package/dist/assets/{use-assistant-identity-details-Dk2Qehe0.js → use-assistant-identity-details-62Drj54o.js} +1 -1
  106. package/dist/assets/{use-attachment-preview-D0T316St.js → use-attachment-preview-BahM3Fpa.js} +1 -1
  107. package/dist/assets/{use-attachment-squares-frmKddbN.js → use-attachment-squares-D-EgqhGW.js} +1 -1
  108. package/dist/assets/{use-checkout-dismiss-refresh-CExvyXix.js → use-checkout-dismiss-refresh-CyeZ_3L2.js} +1 -1
  109. package/dist/assets/{use-command-palette-sections-CWOLQX1W.js → use-command-palette-sections-CQkC-d-4.js} +1 -1
  110. package/dist/assets/{use-edge-swipe-BeF8H02p.js → use-edge-swipe-Cy1q_g93.js} +1 -1
  111. package/dist/assets/{use-edge-swipe-back-3Bk1xDr0.js → use-edge-swipe-back-CMMid7We.js} +1 -1
  112. package/dist/assets/{use-edit-app-DxKkV6Hk.js → use-edit-app-s9REmFwp.js} +1 -1
  113. package/dist/assets/{use-is-org-ready-CfmZwxdN.js → use-is-org-ready-CNHq_yBF.js} +1 -1
  114. package/dist/assets/{use-onboarding-login-CJ7p0ITq.js → use-onboarding-login-D5l9Xmkv.js} +1 -1
  115. package/dist/assets/{use-platform-assistant-id-BBcUWy3-.js → use-platform-assistant-id-ziur35ah.js} +1 -1
  116. package/dist/assets/{use-platform-gate-CijNH8dw.js → use-platform-gate-Cx6EwFNs.js} +1 -1
  117. package/dist/assets/{use-return-to-short-circuit-C2YqlJVv.js → use-return-to-short-circuit-C7h8gHr0.js} +1 -1
  118. package/dist/assets/{use-sticky-profiles-DmcmSOsO.js → use-sticky-profiles-Bz0Gst-X.js} +1 -1
  119. package/dist/assets/{use-subagent-card-data-DGBTouhd.js → use-subagent-card-data-BB49eUCK.js} +1 -1
  120. package/dist/assets/use-transcript-message-by-id-DIG7klGi.js +1 -0
  121. package/dist/assets/{use-transcript-messages-DEs7Ih4P.js → use-transcript-messages-BL8C5d75.js} +1 -1
  122. package/dist/assets/{use-voice-sample-preview-CXWDRLHi.js → use-voice-sample-preview-CG9dYvdC.js} +1 -1
  123. package/dist/assets/{viewer-store-CGDw5Wtf.js → viewer-store-C-Uj2CzB.js} +1 -1
  124. package/dist/assets/{voice-list-Dn_1H-ZV.js → voice-list-Bza1jX_c.js} +1 -1
  125. package/dist/assets/{voice-page-CSzqo58x.js → voice-page-DuYLAxew.js} +1 -1
  126. package/dist/assets/{welcome-screen-WLx6gBF8.js → welcome-screen-D4wb-el5.js} +1 -1
  127. package/dist/assets/{workflow-store-Cotm4qOw.js → workflow-store-2S0CxvX3.js} +1 -1
  128. package/dist/assets/{workspace-page-C2UHPyt-.js → workspace-page-C1v1cUsu.js} +1 -1
  129. package/dist/index.html +59 -59
  130. package/package.json +1 -1
  131. package/dist/assets/access-DIC4wO8s.js +0 -1
  132. package/dist/assets/auth-store-AVhhOiz_.js +0 -2
  133. package/dist/assets/checkout-continuation-Cl65aymU.js +0 -1
  134. package/dist/assets/native-anchor-S15uxlUB.js +0 -1
  135. package/dist/assets/use-transcript-message-by-id-nvkX1iRu.js +0 -1
  136. /package/dist/assets/{feature-flag-catalog-K0ruEmRc.js → feature-flag-catalog-Ccklc1QS.js} +0 -0
  137. /package/dist/assets/{native-biometric-DSA3t7PV.js → native-biometric-Brq7EN1d.js} +0 -0
  138. /package/dist/assets/{remote-gateway-session-BKw7UXep.js → remote-gateway-session-C9Gb2ZfG.js} +0 -0
@@ -1,3 +1,3 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,l as n}from"./local-settings-Bx7FsNo5.js";import{t as r}from"./react-BFJW0bSv.js";import{i}from"./use-attachment-preview-D0T316St.js";import{n as a,t as o}from"./create-selectors-CEbfsat6.js";import{n as s}from"./event-bus-DYZhc6yM.js";import{r as c}from"./typed-storage-C92iOTRi.js";import{a as l}from"./diagnostics-_ZD3ioXN.js";import{t as u}from"./client-perf-BrZz3Mpl.js";import{t as ee}from"./conversation-store-DAowsv-z.js";import{s as te,u as d}from"./messages-BdRhAWrP.js";import{C as f,D as p,n as ne,t as re,w as ie,x as ae}from"./chat-Dy2BC2i1.js";var m=e(r(),1),oe=1e3,se=15,ce=0,h=new Map,g=[],_=new Map,le=20;function ue(e){let t=`sse-${++ce}`,n={id:t,abortSignal:e,initiatedAt:Date.now(),establishedAt:null,lastTrafficAt:null,lastDataAt:null,dataFrames:0,keepalives:0,firstFrameAt:null,interKeepaliveMs:null,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 de(e){let t=h.get(e);t&&t.establishedAt===null&&(t.establishedAt=Date.now())}function fe(e,t){let n=h.get(e);if(!n)return;let r=Date.now();n.lastTrafficAt=r,n.firstFrameAt===null&&(n.firstFrameAt=r),t?(n.lastDataAt=r,n.dataFrames++):(n.keepalives++,pe(n,r))}function pe(e,t){let n=_.get(e.id);if(!n){_.set(e.id,{lastKeepaliveAt:t,gaps:[]});return}n.gaps.push(t-n.lastKeepaliveAt),n.lastKeepaliveAt=t,n.gaps.length>le&&n.gaps.shift(),n.gaps.length>=2&&(e.interKeepaliveMs=Math.round(me(n.gaps)))}function me(e){let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==1?t[n]:(t[n-1]+t[n])/2}function he(e,t){g.push({clientId:e,receivedAt:new Date().toISOString(),...t}),g.length>oe&&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>oe;)g.shift()}function ve(){return Array.from(h.values())}function ye(e=oe){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),_.delete(e),Se())}function Se(){let e=0;for(let t of h.values())t.endedAt!==null&&e++;if(!(e<=se))for(let[t,n]of h){if(e<=se)break;n.endedAt!==null&&(h.delete(t),_.delete(t),e--)}}var Ce=15e3,v=null;function y(){v!==null&&(clearTimeout(v.timer),v=null)}function b(e){if(v===null)return;let t=performance.now()-v.at;y(),u(`client_switch.abandoned`,t,{reason:e})}function we(e){b(`superseded`),v={conversationId:e,at:performance.now(),timer:setTimeout(()=>{v=null,u(`client_switch.stalled`,Ce,{reason:`timeout`})},Ce)}}function Te(e,t){if(v===null||v.conversationId!==e)return;let n=performance.now()-v.at;y(),u(`client_switch.transcript_painted`,n,{had_history:t.hadHistory})}function Ee({conversationId:e,historyLoadFailed:t,transcriptPainted:n,hadHistory:r}){(0,m.useEffect)(()=>{if(e!==null){if(t){b(`history_error`);return}n&&Te(e,{hadHistory:r})}}),(0,m.useEffect)(()=>()=>{b(`unmount`)},[])}function De(){let e=s(`app.hidden`,()=>{b(`hidden`)});return()=>{e(),y()}}var x={phase:`idle`,pendingQueuedCount:0,activeToolCallCount:0,activeTurnId:null,lastTerminalReason:null,statusText:null,liveWebActivity:{}};function S(e){return e===`queued`||e===`thinking`||e===`streaming`||e===`awaiting_user_input`}function Oe(e){return e===`thinking`}function C(e){return(e.phase===`idle`||e.phase===`errored`)&&!e.activeTurnId}var ke=o(a()((e,t)=>({...x,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();C(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();C(i)||e({liveWebActivity:{...i.liveWebActivity,[n]:r}})},onActivityThinking:(n,r)=>{let i=t();if(C(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=>{C(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:()=>{C(t())||e({phase:`awaiting_user_input`})},onConfirmationRequest:()=>{C(t())||e({phase:`awaiting_user_input`})},onQuestionRequest:()=>{C(t())||e({phase:`awaiting_user_input`})},onContactRequest:()=>{C(t())||e({phase:`awaiting_user_input`})},completeTurn:()=>{e({phase:t().pendingQueuedCount>0?`queued`:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},handoffGeneration:()=>{C(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||S(r.phase)&&e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},resetTurn:()=>e({...x}),clearStaleTurn:()=>{let n=t();n.activeTurnId&&S(n.phase)||e({...x})},enqueueMessage:()=>e(e=>({pendingQueuedCount:e.pendingQueuedCount+1})),dequeueMessage:()=>{let n=t(),r=Math.max(0,n.pendingQueuedCount-1);if(C(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})}}))),Ae=3670016,je=[.85,.75,.65,.5],Me=2e7,Ne=new Set([`image/jpeg`,`image/jpg`,`image/png`,`image/webp`,`image/heic`,`image/heif`,`image/bmp`,`image/tiff`]),Pe=new Set([`jpg`,`jpeg`,`png`,`webp`,`heic`,`heif`,`bmp`,`tif`,`tiff`]);function w(e){let t=e.type.trim().toLowerCase();if(Ne.has(t))return!0;let n=e.name.split(`.`).pop()?.trim().toLowerCase();return n?Pe.has(n):!1}function Fe(e){return w(e)&&e.size>3670016}function Ie(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 Le(e){return Fe(e)||Ie(e)}function Re(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 ze(e,t=`image/jpeg`){let n=`attachment`,r=e.trim()||n,i=Re(t),a=r.match(/\.([^./\\]+)$/)?.[1]?.toLowerCase();return a===i||i===`jpg`&&a===`jpeg`?r:`${r.replace(/\.[^./\\]+$/,``)||n}.${i}`}async function Be(e){if(!Le(e)||await He(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 Ve(e)}catch{return{status:`failed`,error:`Couldn't resize this image for upload. Try a smaller image.`}}try{let n;try{n=await We(t,e.size)}catch{n=null}if(!n||!Ie(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],ze(e.name,r),{type:r,lastModified:e.lastModified})}}finally{t.close()}}async function Ve(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 He(e){if(!Ue(e))return!1;let t;try{t=new Uint8Array(await e.slice(0,Math.min(e.size,1024*1024)).arrayBuffer())}catch{return!0}if(!E(t,0,`RIFF`)||!E(t,8,`WEBP`))return!1;let n=T(t,`VP8X`);return n>=0&&(t[n+8]??0)&2?!0:T(t,`ANIM`)>=0||T(t,`ANMF`)>=0}function Ue(e){return e.type.trim().toLowerCase()===`image/webp`||/\.webp$/i.test(e.name)}function T(e,t){for(let n=0;n<=e.length-t.length;n+=1)if(E(e,n,t))return n;return-1}function E(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 We(e,t){let n=e.width*e.height,r=null;if(n<=Me)for(let t of je){let n=await Ge(e.source,e.width,e.height,t);if(r=D(r,n),n&&n.size<=3670016)return n}let i=r?.size??t,a=Math.min(Math.sqrt(Ae/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 je){let a=await Ge(e.source,t,n,i);if(r=D(r,a),o=D(o,a),a&&a.size<=3670016)return a}i=o?.size??i,a*=Math.min(Math.sqrt(Ae/i*.9),.9)}return null}function D(e,t){return t&&(!e||t.size<e.size)?t:e}async function Ge(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 Ke=`vellum:chatDrafts:`;function qe(e){return`${Ke}${e}`}function Je(e){let n=t(qe(e),``);if(!n)return new Map;try{let e=JSON.parse(n);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 O(e,t){n(qe(e),JSON.stringify(Object.fromEntries(t)))}function Ye(){return`att-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Xe(e){return w(e)?`100 MB`:`50 MB`}function Ze(e){return e.size<=52428800?!0:w(e)&&e.size<=104857600}function Qe(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(n+1)}var k=new Map,A=null,j=new Map,M=new Set,$e=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()?k.set(e,t):k.delete(e),A&&O(A,k)},clearDraft:e=>{k.delete(e),A&&O(A,k)},handleConversationSwitch:({previousKey:n,nextKey:r})=>{if(!(n!==null&&n!==r)||!n)return;let i=t().input;i.trim()?k.set(n,i):k.delete(n);let a=(r&&k.get(r))??``;e({input:a,restoredDraftConversationId:a.length>0&&r?r:null}),A&&O(A,k)},loadAssistantDrafts:(n,r)=>{if(A&&A!==n){let n=t().input;r&&(n.trim()?k.set(r,n):k.delete(r)),O(A,k),e({input:``,restoredDraftConversationId:null})}k=Je(n),A=n},clearRestoredDraftNotice:()=>{e({restoredDraftConversationId:null})},restoreDraftIfEmpty:n=>{let r=k.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 a=[],o=[];for(let e of r)Ze(e)?o.push(e):a.push(e);let s=a[0];if(e(s?{attachmentLastError:a.length===1?`${s.name} is larger than ${Xe(s)} and can't be attached.`:`${a.length} files are too large and can't be attached.`}:{attachmentLastError:null}),o.length===0)return;let c=o.map(e=>({pending:{kind:`uploading`,localId:Ye(),filename:e.name||`attachment`,mimeType:e.type||`application/octet-stream`,sizeBytes:e.size},file:e}));e(e=>({attachments:[...e.attachments,...c.map(e=>e.pending)]}));for(let{pending:t,file:r}of c)(async()=>{try{let a=await Be(r);if(M.has(t.localId)){M.delete(t.localId);return}if(a.status===`failed`&&r.size>52428800){N(e,t.localId,a.error);return}let o=a.status===`failed`?r:a.file;if(o.size>52428800){N(e,t.localId,`This attachment is still larger than 50 MB after resizing. Try a smaller image.`);return}a.status===`resized`&&e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId&&e.kind===`uploading`?{...e,filename:o.name||`attachment`,mimeType:o.type||`application/octet-stream`,sizeBytes:o.size}:e)}));let s=await te(n,o);if(M.has(t.localId)){M.delete(t.localId);return}if(!s.ok){N(e,t.localId,s.error.detail??`Upload failed`);return}let c=o.type||`application/octet-stream`,l=s.filename??(o.name||`attachment`),u=s.mimeType??c,ee=s.sizeBytes??o.size,d=o;if(u.startsWith(`image/`)&&u!==c){let e=await i(n,s.id);if(M.has(t.localId)){M.delete(t.localId);return}e&&(d=e)}let f=null;try{f=URL.createObjectURL(d),j.set(t.localId,f)}catch{f=null}e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId?{kind:`uploaded`,localId:t.localId,id:s.id,filename:l,mimeType:u,sizeBytes:ee,previewUrl:f,thumbnailUrl:null}:e)}))}catch{if(M.has(t.localId)){M.delete(t.localId);return}N(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:Ye(),path:t,filename:Qe(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`&&M.add(t),{attachments:e.attachments.filter(e=>e.localId!==t)}}),et(t)},resetAttachments:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&M.add(t.localId);return{attachments:[],attachmentLastError:null}})},fullReset:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&M.add(t.localId);return{attachments:[],attachmentLastError:null}}),j.forEach(e=>URL.revokeObjectURL(e)),j.clear()},dismissAttachmentError:()=>{e({attachmentLastError:null})}}));function N(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 et(e){let t=j.get(e);t&&(URL.revokeObjectURL(t),j.delete(e))}function tt(e){return e.reduce((e,t)=>t.kind===`uploading`?e+1:e,0)}function nt(e){return e.filter(e=>e.kind===`uploaded`).map(e=>e.id)}function rt(e){return e.filter(e=>e.kind===`path-reference`).map(e=>e.path)}var P=o($e);function it(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function at(e){let t=JSON.parse(e);return it(t)?t:null}function F(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 ot(e,t){return e?.filter(e=>!(e.type===`surface`&&e.surface.surfaceId===t))}function st(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=F(r,i)),i});return n?{...e,surfaces:i,contentBlocks:r}:e}function ct(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 lt=500,ut=c({keyFn:e=>`vellum:dismissed-surfaces:${e}`,scope:`user`,parseValue:e=>it(e)?e:null,fallback:{},maxEntries:200});function dt(e,t){let n=ut.get(e,t);return n?new Set(n):new Set}function ft(e,t,n){let r=Array.from(n);r.length>lt&&(r=r.slice(r.length-lt)),ut.set(e,t,r)}var pt=[];function mt(e,t){if(!e)return pt;if(t.size===0)return e;let n=!1,r=e.map(e=>{let r=ct(e,e=>!t.has(e.surfaceId));return r!==e&&(n=!0),r});return n?r:e}function ht(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 gt=c({keyFn:e=>`vellum:ctxwindow:${e}`,scope:`user`,parseValue:e=>ht(e)?e:null,fallback:{},maxEntries:200});function _t(e){return new Map(Object.entries(gt.load(e)))}function vt(e,t,n){gt.set(e,t,n)}var yt=`PROVIDER_BILLING`,bt=`PROVIDER_NOT_CONFIGURED`,xt=`MANAGED_KEY_INVALID`,St=`credits_exhausted`,Ct=`provider_billing`,wt=`daily_limit_reached`;function Tt(e){return e?e.category?e.category.endsWith(St):e.code===yt:!1}function Et(e){return e?Tt({code:e.code,category:e.errorCategory}):!1}function Dt(e){return e?.errorCategory?e.errorCategory.endsWith(Ct):!1}function Ot(e){return e?.errorCategory?e.errorCategory.endsWith(wt):!1}function kt(e){return Ot(e)?`daily_limit`:Et(e)?`managed_credits`:Dt(e)?`provider_billing`:null}function At(e){return e.billingBannerDecision===`daily_limit`?`daily_limit`:e.billingBannerDecision===`provider_billing`?`provider_billing`:e.billingBannerDecision===`managed_credits`?null:e.isLowBalance&&!e.dismissed?`low_balance`:null}function I(e){return kt(e)!==null||e?.code===bt||e?.displayAs===`modal`}function jt(e){return!!e&&!I(e)}function Mt(e){return e?.code===xt}var Nt={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},L=o(a()((e,t)=>({...Nt,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}),dismissQuestionIfMatches:n=>{let{pendingQuestion:r}=t();!r||r.requestId!==n||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(Nt)})));function Pt(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{i as t,l as n}from"./local-settings-Bx7FsNo5.js";import{t as r}from"./react-BFJW0bSv.js";import{i}from"./use-attachment-preview-BahM3Fpa.js";import{n as a,t as o}from"./create-selectors-CEbfsat6.js";import{n as s}from"./event-bus-DYZhc6yM.js";import{r as c}from"./typed-storage-C92iOTRi.js";import{a as l}from"./diagnostics-Bss-eL9u.js";import{t as u}from"./client-perf-DjfIe5LZ.js";import{t as ee}from"./conversation-store-DAowsv-z.js";import{s as te,u as d}from"./messages-uHyh-apY.js";import{C as f,D as p,n as ne,t as re,w as ie,x as ae}from"./chat-Dy2BC2i1.js";var m=e(r(),1),oe=1e3,se=15,ce=0,h=new Map,g=[],_=new Map,le=20;function ue(e){let t=`sse-${++ce}`,n={id:t,abortSignal:e,initiatedAt:Date.now(),establishedAt:null,lastTrafficAt:null,lastDataAt:null,dataFrames:0,keepalives:0,firstFrameAt:null,interKeepaliveMs:null,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 de(e){let t=h.get(e);t&&t.establishedAt===null&&(t.establishedAt=Date.now())}function fe(e,t){let n=h.get(e);if(!n)return;let r=Date.now();n.lastTrafficAt=r,n.firstFrameAt===null&&(n.firstFrameAt=r),t?(n.lastDataAt=r,n.dataFrames++):(n.keepalives++,pe(n,r))}function pe(e,t){let n=_.get(e.id);if(!n){_.set(e.id,{lastKeepaliveAt:t,gaps:[]});return}n.gaps.push(t-n.lastKeepaliveAt),n.lastKeepaliveAt=t,n.gaps.length>le&&n.gaps.shift(),n.gaps.length>=2&&(e.interKeepaliveMs=Math.round(me(n.gaps)))}function me(e){let t=[...e].sort((e,t)=>e-t),n=Math.floor(t.length/2);return t.length%2==1?t[n]:(t[n-1]+t[n])/2}function he(e,t){g.push({clientId:e,receivedAt:new Date().toISOString(),...t}),g.length>oe&&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>oe;)g.shift()}function ve(){return Array.from(h.values())}function ye(e=oe){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),_.delete(e),Se())}function Se(){let e=0;for(let t of h.values())t.endedAt!==null&&e++;if(!(e<=se))for(let[t,n]of h){if(e<=se)break;n.endedAt!==null&&(h.delete(t),_.delete(t),e--)}}var Ce=15e3,v=null;function y(){v!==null&&(clearTimeout(v.timer),v=null)}function b(e){if(v===null)return;let t=performance.now()-v.at;y(),u(`client_switch.abandoned`,t,{reason:e})}function we(e){b(`superseded`),v={conversationId:e,at:performance.now(),timer:setTimeout(()=>{v=null,u(`client_switch.stalled`,Ce,{reason:`timeout`})},Ce)}}function Te(e,t){if(v===null||v.conversationId!==e)return;let n=performance.now()-v.at;y(),u(`client_switch.transcript_painted`,n,{had_history:t.hadHistory})}function Ee({conversationId:e,historyLoadFailed:t,transcriptPainted:n,hadHistory:r}){(0,m.useEffect)(()=>{if(e!==null){if(t){b(`history_error`);return}n&&Te(e,{hadHistory:r})}}),(0,m.useEffect)(()=>()=>{b(`unmount`)},[])}function De(){let e=s(`app.hidden`,()=>{b(`hidden`)});return()=>{e(),y()}}var x={phase:`idle`,pendingQueuedCount:0,activeToolCallCount:0,activeTurnId:null,lastTerminalReason:null,statusText:null,liveWebActivity:{}};function S(e){return e===`queued`||e===`thinking`||e===`streaming`||e===`awaiting_user_input`}function Oe(e){return e===`thinking`}function C(e){return(e.phase===`idle`||e.phase===`errored`)&&!e.activeTurnId}var ke=o(a()((e,t)=>({...x,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();C(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();C(i)||e({liveWebActivity:{...i.liveWebActivity,[n]:r}})},onActivityThinking:(n,r)=>{let i=t();if(C(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=>{C(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:()=>{C(t())||e({phase:`awaiting_user_input`})},onConfirmationRequest:()=>{C(t())||e({phase:`awaiting_user_input`})},onQuestionRequest:()=>{C(t())||e({phase:`awaiting_user_input`})},onContactRequest:()=>{C(t())||e({phase:`awaiting_user_input`})},completeTurn:()=>{e({phase:t().pendingQueuedCount>0?`queued`:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},handoffGeneration:()=>{C(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||S(r.phase)&&e({phase:`idle`,activeTurnId:null,activeToolCallCount:0,lastTerminalReason:`complete`,statusText:null,liveWebActivity:{}})},resetTurn:()=>e({...x}),clearStaleTurn:()=>{let n=t();n.activeTurnId&&S(n.phase)||e({...x})},enqueueMessage:()=>e(e=>({pendingQueuedCount:e.pendingQueuedCount+1})),dequeueMessage:()=>{let n=t(),r=Math.max(0,n.pendingQueuedCount-1);if(C(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})}}))),Ae=3670016,je=[.85,.75,.65,.5],Me=2e7,Ne=new Set([`image/jpeg`,`image/jpg`,`image/png`,`image/webp`,`image/heic`,`image/heif`,`image/bmp`,`image/tiff`]),Pe=new Set([`jpg`,`jpeg`,`png`,`webp`,`heic`,`heif`,`bmp`,`tif`,`tiff`]);function w(e){let t=e.type.trim().toLowerCase();if(Ne.has(t))return!0;let n=e.name.split(`.`).pop()?.trim().toLowerCase();return n?Pe.has(n):!1}function Fe(e){return w(e)&&e.size>3670016}function Ie(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 Le(e){return Fe(e)||Ie(e)}function Re(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 ze(e,t=`image/jpeg`){let n=`attachment`,r=e.trim()||n,i=Re(t),a=r.match(/\.([^./\\]+)$/)?.[1]?.toLowerCase();return a===i||i===`jpg`&&a===`jpeg`?r:`${r.replace(/\.[^./\\]+$/,``)||n}.${i}`}async function Be(e){if(!Le(e)||await He(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 Ve(e)}catch{return{status:`failed`,error:`Couldn't resize this image for upload. Try a smaller image.`}}try{let n;try{n=await We(t,e.size)}catch{n=null}if(!n||!Ie(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],ze(e.name,r),{type:r,lastModified:e.lastModified})}}finally{t.close()}}async function Ve(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 He(e){if(!Ue(e))return!1;let t;try{t=new Uint8Array(await e.slice(0,Math.min(e.size,1024*1024)).arrayBuffer())}catch{return!0}if(!E(t,0,`RIFF`)||!E(t,8,`WEBP`))return!1;let n=T(t,`VP8X`);return n>=0&&(t[n+8]??0)&2?!0:T(t,`ANIM`)>=0||T(t,`ANMF`)>=0}function Ue(e){return e.type.trim().toLowerCase()===`image/webp`||/\.webp$/i.test(e.name)}function T(e,t){for(let n=0;n<=e.length-t.length;n+=1)if(E(e,n,t))return n;return-1}function E(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 We(e,t){let n=e.width*e.height,r=null;if(n<=Me)for(let t of je){let n=await Ge(e.source,e.width,e.height,t);if(r=D(r,n),n&&n.size<=3670016)return n}let i=r?.size??t,a=Math.min(Math.sqrt(Ae/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 je){let a=await Ge(e.source,t,n,i);if(r=D(r,a),o=D(o,a),a&&a.size<=3670016)return a}i=o?.size??i,a*=Math.min(Math.sqrt(Ae/i*.9),.9)}return null}function D(e,t){return t&&(!e||t.size<e.size)?t:e}async function Ge(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 Ke=`vellum:chatDrafts:`;function qe(e){return`${Ke}${e}`}function Je(e){let n=t(qe(e),``);if(!n)return new Map;try{let e=JSON.parse(n);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 O(e,t){n(qe(e),JSON.stringify(Object.fromEntries(t)))}function Ye(){return`att-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function Xe(e){return w(e)?`100 MB`:`50 MB`}function Ze(e){return e.size<=52428800?!0:w(e)&&e.size<=104857600}function Qe(e){let t=e.replace(/[/\\]+$/,``),n=Math.max(t.lastIndexOf(`/`),t.lastIndexOf(`\\`));return n===-1?t:t.slice(n+1)}var k=new Map,A=null,j=new Map,M=new Set,$e=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()?k.set(e,t):k.delete(e),A&&O(A,k)},clearDraft:e=>{k.delete(e),A&&O(A,k)},handleConversationSwitch:({previousKey:n,nextKey:r})=>{if(!(n!==null&&n!==r)||!n)return;let i=t().input;i.trim()?k.set(n,i):k.delete(n);let a=(r&&k.get(r))??``;e({input:a,restoredDraftConversationId:a.length>0&&r?r:null}),A&&O(A,k)},loadAssistantDrafts:(n,r)=>{if(A&&A!==n){let n=t().input;r&&(n.trim()?k.set(r,n):k.delete(r)),O(A,k),e({input:``,restoredDraftConversationId:null})}k=Je(n),A=n},clearRestoredDraftNotice:()=>{e({restoredDraftConversationId:null})},restoreDraftIfEmpty:n=>{let r=k.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 a=[],o=[];for(let e of r)Ze(e)?o.push(e):a.push(e);let s=a[0];if(e(s?{attachmentLastError:a.length===1?`${s.name} is larger than ${Xe(s)} and can't be attached.`:`${a.length} files are too large and can't be attached.`}:{attachmentLastError:null}),o.length===0)return;let c=o.map(e=>({pending:{kind:`uploading`,localId:Ye(),filename:e.name||`attachment`,mimeType:e.type||`application/octet-stream`,sizeBytes:e.size},file:e}));e(e=>({attachments:[...e.attachments,...c.map(e=>e.pending)]}));for(let{pending:t,file:r}of c)(async()=>{try{let a=await Be(r);if(M.has(t.localId)){M.delete(t.localId);return}if(a.status===`failed`&&r.size>52428800){N(e,t.localId,a.error);return}let o=a.status===`failed`?r:a.file;if(o.size>52428800){N(e,t.localId,`This attachment is still larger than 50 MB after resizing. Try a smaller image.`);return}a.status===`resized`&&e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId&&e.kind===`uploading`?{...e,filename:o.name||`attachment`,mimeType:o.type||`application/octet-stream`,sizeBytes:o.size}:e)}));let s=await te(n,o);if(M.has(t.localId)){M.delete(t.localId);return}if(!s.ok){N(e,t.localId,s.error.detail??`Upload failed`);return}let c=o.type||`application/octet-stream`,l=s.filename??(o.name||`attachment`),u=s.mimeType??c,ee=s.sizeBytes??o.size,d=o;if(u.startsWith(`image/`)&&u!==c){let e=await i(n,s.id);if(M.has(t.localId)){M.delete(t.localId);return}e&&(d=e)}let f=null;try{f=URL.createObjectURL(d),j.set(t.localId,f)}catch{f=null}e(e=>({attachments:e.attachments.map(e=>e.localId===t.localId?{kind:`uploaded`,localId:t.localId,id:s.id,filename:l,mimeType:u,sizeBytes:ee,previewUrl:f,thumbnailUrl:null}:e)}))}catch{if(M.has(t.localId)){M.delete(t.localId);return}N(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:Ye(),path:t,filename:Qe(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`&&M.add(t),{attachments:e.attachments.filter(e=>e.localId!==t)}}),et(t)},resetAttachments:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&M.add(t.localId);return{attachments:[],attachmentLastError:null}})},fullReset:()=>{e(e=>{for(let t of e.attachments)t.kind===`uploading`&&M.add(t.localId);return{attachments:[],attachmentLastError:null}}),j.forEach(e=>URL.revokeObjectURL(e)),j.clear()},dismissAttachmentError:()=>{e({attachmentLastError:null})}}));function N(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 et(e){let t=j.get(e);t&&(URL.revokeObjectURL(t),j.delete(e))}function tt(e){return e.reduce((e,t)=>t.kind===`uploading`?e+1:e,0)}function nt(e){return e.filter(e=>e.kind===`uploaded`).map(e=>e.id)}function rt(e){return e.filter(e=>e.kind===`path-reference`).map(e=>e.path)}var P=o($e);function it(e){return Array.isArray(e)&&e.every(e=>typeof e==`string`)}function at(e){let t=JSON.parse(e);return it(t)?t:null}function F(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 ot(e,t){return e?.filter(e=>!(e.type===`surface`&&e.surface.surfaceId===t))}function st(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=F(r,i)),i});return n?{...e,surfaces:i,contentBlocks:r}:e}function ct(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 lt=500,ut=c({keyFn:e=>`vellum:dismissed-surfaces:${e}`,scope:`user`,parseValue:e=>it(e)?e:null,fallback:{},maxEntries:200});function dt(e,t){let n=ut.get(e,t);return n?new Set(n):new Set}function ft(e,t,n){let r=Array.from(n);r.length>lt&&(r=r.slice(r.length-lt)),ut.set(e,t,r)}var pt=[];function mt(e,t){if(!e)return pt;if(t.size===0)return e;let n=!1,r=e.map(e=>{let r=ct(e,e=>!t.has(e.surfaceId));return r!==e&&(n=!0),r});return n?r:e}function ht(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 gt=c({keyFn:e=>`vellum:ctxwindow:${e}`,scope:`user`,parseValue:e=>ht(e)?e:null,fallback:{},maxEntries:200});function _t(e){return new Map(Object.entries(gt.load(e)))}function vt(e,t,n){gt.set(e,t,n)}var yt=`PROVIDER_BILLING`,bt=`PROVIDER_NOT_CONFIGURED`,xt=`MANAGED_KEY_INVALID`,St=`credits_exhausted`,Ct=`provider_billing`,wt=`daily_limit_reached`;function Tt(e){return e?e.category?e.category.endsWith(St):e.code===yt:!1}function Et(e){return e?Tt({code:e.code,category:e.errorCategory}):!1}function Dt(e){return e?.errorCategory?e.errorCategory.endsWith(Ct):!1}function Ot(e){return e?.errorCategory?e.errorCategory.endsWith(wt):!1}function kt(e){return Ot(e)?`daily_limit`:Et(e)?`managed_credits`:Dt(e)?`provider_billing`:null}function At(e){return e.billingBannerDecision===`daily_limit`?`daily_limit`:e.billingBannerDecision===`provider_billing`?`provider_billing`:e.billingBannerDecision===`managed_credits`?null:e.isLowBalance&&!e.dismissed?`low_balance`:null}function I(e){return kt(e)!==null||e?.code===bt||e?.displayAs===`modal`}function jt(e){return!!e&&!I(e)}function Mt(e){return e?.code===xt}var Nt={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},L=o(a()((e,t)=>({...Nt,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}),dismissQuestionIfMatches:n=>{let{pendingQuestion:r}=t();!r||r.requestId!==n||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(Nt)})));function Pt(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 Ft(e){let t=[];for(let n of e?.contentBlocks??[])n.type===`text`&&t.push(n.text);return Pt(t)}function It(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 Lt(e){return[...new Set([e.id,...e.mergedMessageIds??[]].filter(e=>typeof e==`string`&&e.length>0))]}function R(e){let t=Lt(e);return e.clientMessageId&&!t.includes(e.clientMessageId)?[...t,e.clientMessageId]:t}function z(e,t){return e.id===t||e.clientMessageId===t||(e.mergedMessageIds?.includes(t)??!1)}function B(e){let t=e[e.length-1];return!!t&&t.role===`assistant`}function Rt(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 V(e,t){return e.findIndex(e=>e.role===`assistant`&&(e.id===t||!!e.mergedMessageIds?.includes(t)))}function H(e,t){if(t){let n=V(e,t);if(n!==-1)return n}let n=e.findLastIndex(e=>e.role===`user`&&e.queueStatus!==`queued`)+1;for(let t=e.length-1;t>=n;t--)if(e[t]?.role===`assistant`)return t;return-1}function U(e,t){if(!t||e.id===t)return e;let n=e.mergedMessageIds??[];return n.includes(t)?e:{...e,mergedMessageIds:[...n,t]}}function W(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 zt(e,t,n){return e.map(e=>e.id===t?{...e,queuePosition:n}:e)}function Bt(e,t){return e.map(e=>z(e,t)?{...e,queueStatus:void 0,queuePosition:void 0}:e)}function Vt(e,t){return e.map(e=>z(e,t)?{...e,...e.clientMessageId?{}:{isOptimistic:!0},queueStatus:void 0,queuePosition:void 0}:e)}function Ht(e,t,n){return e.map(e=>z(e,t)?{...e,queueStatus:`queued`,queuePosition:n}:e)}function Ut(e,t){return e.filter(e=>!z(e,t))}function Wt(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 Gt(e,t,n){n&&e[e.length-1]?.type===t.type?e[e.length-1]=t:e.push(t)}function G(e,t,n,r){let i=U(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)),Gt(s,{type:`text`,text:a[a.length-1]},c);let l=[...e];return l[t]={...i,textSegments:a,contentOrder:o,contentBlocks:s},l}function K(e,t,n,r){let i=U(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)),Gt(s,{type:`thinking`,thinking:a[a.length-1]},c);let l=[...e];return l[t]={...i,thinkingSegments:a,contentOrder:o,contentBlocks:s},l}function Kt(e,t,n,r,i=Date.now()){if(n){let a=V(e,n);if(a>=0)return G(e,a,t,n);if(B(e))return G(e,e.length-1,t,n);let o=r?.();return o?G([...e,o],e.length,t,n):Wt(e,t,n,i)}return B(e)?G(e,e.length-1,t,void 0):Wt(e,t,n,i)}function qt(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 Jt(e,t,n,r,i=Date.now()){if(n){let a=V(e,n);if(a>=0)return K(e,a,t,n);if(B(e))return K(e,e.length-1,t,n);let o=r?.();return o?K([...e,o],e.length,t,n):qt(e,t,n,i)}return B(e)?K(e,e.length-1,t,void 0):qt(e,t,n,i)}function Yt(e,t=Date.now()){let n=!1,r=e.map(e=>{if(e.role!==`assistant`)return e;let r=W(e,t);return r?(n=!0,{...e,...r}):e});return n?r:e}function Xt(e,t,n=Date.now()){let r=e[e.length-1],i=It(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=W(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);let n=-1;for(let t=e.length-1;t>=0;t--){let r=e[t];if(r&&r.role===`user`&&r.isOptimistic===!0){if(!r.clientMessageId)return t;n===-1&&(n=t)}}return n}function Qt(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 $t(e,t=Date.now()){let n=e.length-1,r=e[n];if(!r||r.role!==`assistant`)return e;let i=W(r,t);if(!(Ft(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 q(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 J(e,t,n,r){let i=U(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:q(i.contentBlocks,r)},o}return o[t]={...i,toolCalls:[...i.toolCalls??[],n],contentOrder:[...i.contentOrder??[],{type:`toolCall`,id:n.id}],contentBlocks:q(i.contentBlocks,n)},o}function en(e,t,n,r=Date.now()){if(n){let r=V(e,n);if(r>=0)return J(e,r,t,n);if(B(e))return J(e,e.length-1,t,n)}else if(B(e))return J(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 tn(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.answeredQuestion===void 0?{}:{answeredQuestion:t.answeredQuestion},...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:q(i.contentBlocks,l)},u}var nn=16384;function rn(e){return e.length<=16384?e:e.slice(e.length-nn)}function an(e,t){if(!t.chunk)return e;let n=-1,r=-1;if(t.toolUseId){if(t.messageId){let i=V(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:rn((a.streamedOutput??``)+t.chunk)},s=[...i.toolCalls];s[r]=o;let c=[...e];return c[n]={...i,toolCalls:s,contentBlocks:q(i.contentBlocks,o)},c}function on(e,t,n,r=Date.now()){let i=H(e,n),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=U(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:F(r.contentBlocks,t)}}return a}function sn(e,t,n){let r=H(e,n);if(r===-1)return e;let i=e[r];if(i.pendingVisualToolUseIds?.includes(t))return e;let a=[...e];return a[r]={...U(i,n),pendingVisualToolUseIds:[...i.pendingVisualToolUseIds??[],t]},a}function Y(e,t={}){let n=t.toolUseId===void 0&&t.messageId!==void 0?H(e,t.messageId):void 0,r=!1,i=e.map((e,i)=>{let a=e.pendingVisualToolUseIds;if(!a||a.length===0||n!==void 0&&i!==n)return e;let o=t.toolUseId===void 0?[]:a.filter(e=>e!==t.toolUseId);if(o.length===a.length)return e;r=!0;let s={...e};return o.length===0?delete s.pendingVisualToolUseIds:s.pendingVisualToolUseIds=o,s});return r?i:e}function cn(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:F(i.contentBlocks,c)},l}return e}function ln(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:ot(e[n].contentBlocks,t)},r}return e}function un(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:F(e[r].contentBlocks,a)},o}return e}var dn=[`choice`,`oauth_connect`,`form`,`confirmation`,`file_upload`,`card`,`list`,`table`,`browser_view`,`task_preferences`];function fn(e){return e==null||e.hasPendingConfirmation||e.hasUncompletedVisibleSurface}function pn(e,t){let n=!1,r=e.map(e=>{let r=ae(e,e=>e.pendingConfirmation?.requestId===t?{...e,pendingConfirmation:void 0}:e);return r!==e&&(n=!0),r});return n?r:e}function mn(e){let t=!1,n=e.map(e=>{let n=ae(e,e=>e.pendingConfirmation?{...e,pendingConfirmation:void 0}:e);return n!==e&&(t=!0),n});return t?n:e}function hn(e,t){let n=new Set;for(let e of t)if(e.surfaces)for(let t of e.surfaces)ie(t)&&n.add(t.surfaceId);return n.size===0?{updatedMessages:e,dismissedIds:n}:{updatedMessages:e.map(e=>ct(e,e=>!n.has(e.surfaceId))),dismissedIds:n}}function gn(e,t,n,r,i){for(let a=e.length-1;a>=0;a--){let o=e[a].surfaces?.find(e=>e.surfaceId===t);if(!o)continue;if(!dn.includes(o.surfaceType)||o.completed)return e;let s=o.actions?.find(e=>e.id===n),c=n===`cancel`||n===`dismiss`,l=[...e];return l[a]=st(e[a],e=>e.surfaceId===t?{...e,completed:!0,completionSummary:c?`Cancelled`:r??s?.label??void 0,...i?.tone?{completionTone:i.tone}:{}}:e),l}return e}function _n(e,t,n){return e&&re[e]||t||n}function X(e){return typeof e==`string`?e:void 0}function vn(e){return typeof e==`boolean`?e:void 0}function yn(e){return Array.isArray(e)?e:void 0}function bn(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:void 0}function Z(e){return Array.isArray(e)?e:void 0}function xn(e){return{requestId:typeof e.requestId==`string`?e.requestId:``,label:X(e.label),service:X(e.service),field:X(e.field),description:X(e.description),placeholder:X(e.placeholder),allowOneTimeSend:vn(e.allowOneTimeSend),allowedTools:yn(e.allowedTools),allowedDomains:yn(e.allowedDomains),purpose:X(e.purpose)}}function Sn(e){let t={requestId:typeof e.requestId==`string`?e.requestId:``,title:X(e.title),description:X(e.description),toolName:X(e.toolName),riskLevel:X(e.riskLevel),riskReason:X(e.riskReason),allowlistOptions:Z(e.allowlistOptions),scopeOptions:Z(e.scopeOptions),directoryScopeOptions:Z(e.directoryScopeOptions),persistentDecisionsAllowed:vn(e.persistentDecisionsAllowed),input:bn(e.input),toolUseId:X(e.toolUseId)};return{confData:t,state:{...t,confirmLabel:X(e.confirmLabel),denyLabel:X(e.denyLabel)}}}function Cn(){return`turn-${Date.now()}-${Math.random().toString(36).slice(2,8)}`}function wn(e,t){let n=Date.parse(e);return Number.isFinite(n)?n:typeof t==`number`?t:0}function Tn(e,t,n){switch(t.type){case`assistant_text_delta`:return Kt(e,t.text,t.messageId,void 0,n);case`assistant_thinking_delta`:return Jt(e,t.thinking,t.messageId,void 0,n);case`message_complete`:return Y(Xt(e,t,n));case`user_message_echo`:return Qt(e,{text:t.text,messageId:t.messageId,clientMessageId:t.clientMessageId},n);case`message_dequeued`:return Vt(e,t.requestId);case`message_requeued`:return Ht(e,t.requestId,t.position);case`message_queued_deleted`:return Ut(e,t.requestId);case`assistant_activity_state`:return t.phase===`idle`?Y(Yt(e,n)):e;case`conversation_error`:return Y($t(e,n));case`tool_use_preview_start`:return en(e,{id:t.toolUseId,name:t.toolName,input:{},previewStartedAt:typeof t.previewStartedAt==`number`?t.previewStartedAt:n},t.messageId,n);case`tool_use_start`:return en(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 tn(Y(e,{toolUseId:t.toolUseId}),{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,answeredQuestion:t.answeredQuestion,errorCode:t.errorCode,completedAt:`completedAt`in t&&typeof t.completedAt==`number`?t.completedAt:n});case`tool_output_chunk`:return t.chunk?an(e,{chunk:t.chunk,toolUseId:t.toolUseId,messageId:t.messageId}):e;case`ui_surface_pending`:return sn(e,t.toolUseId,t.messageId);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),on(r.surfaceType===`visual`?Y(e,t.toolCallId?{toolUseId:t.toolCallId}:{messageId:t.messageId}):e,r,t.messageId,n)}case`ui_surface_update`:return cn(e,t.surfaceId,t.data);case`ui_surface_dismiss`:return ln(e,t.surfaceId);case`ui_surface_complete`:return un(e,t.surfaceId,t.summary);case`confirmation_request`:return ne(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`?pn(e,t.requestId):e;default:return e}}function En(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 Dn(e,t){let{seq:n}=t;if(typeof n==`number`&&typeof e.seq==`number`&&n<=e.seq)return e;let r=wn(t.emittedAt,n),i=Tn(e.messages,t.message,r),a=typeof n==`number`?Math.max(e.seq??-1,n):e.seq??null,o=En(e.processing,t.message,n);return{...e,messages:i,seq:a,processing:o}}function On(e,t){return t.reduce(Dn,e)}function kn(e,t){return t===null?e:On(e,t)}var An={hasMore:!1,oldestTimestamp:null,isLoadingOlder:!1};function jn(){return{snapshot:null,optimisticSends:[],error:null,notice:null,isLoadingHistory:!0,transcriptPagination:{...An},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 Mn(e,t){if(e.length===0)return e;let n=new Map;for(let e of t)for(let t of R(e))n.has(t)||n.set(t,e);let r=e.filter(e=>{let t;for(let r of R(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 $=o(a()((e,t)=>({...jn(),seedSnapshot:(n,r)=>{let i=t().snapshot;if(r.seq==null&&i!==null&&typeof i.seq==`number`){l(`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){l(`history_seed_skipped_stale_anchor`,{conversationId:n,liveSeq:i.seq,fetchedSeq:r.seq});return}let o=kn(r,a);e(e=>({snapshot:o,optimisticSends:Mn(e.optimisticSends,o.messages)}))},applyEnvelopeToSnapshot:t=>e(e=>e.snapshot?{snapshot:Dn(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){b(`draft_resolution`),e({draftConversationIdResolution:!1});return}let a=i.previousConversationId,o=!!(a&&a!==r);if(o&&a){let e=L.getState();(e.pendingSecret||e.pendingConfirmation)&&ee.getState().addAttentionConversationId(a)}let s=i.previousAssistantId!==null&&i.previousAssistantId!==n,c=s||i.previousAssistantId===null;l(`conversation_switch_reset`,{assistantId:n,conversationId:r,outgoingConversationId:a??null}),P.getState().handleConversationSwitch({previousKey:a??null,nextKey:r}),ke.getState().resetTurn(),L.getState().resetAll(),s?P.getState().fullReset():P.getState().resetAttachments();let u=c?_t(n):i.contextWindowUsageByConversation;o&&!s?we(r):b(`context_change`),e({snapshot:null,optimisticSends:[],ephemeralMetaResults:[],error:I(i.error)?i.error:null,notice:null,isLoadingHistory:!0,transcriptPagination:{...An},contextWindowUsage:u.get(r)??null,compactionCircuitOpenUntil:null,dismissedSurfaceIds:dt(n,r),streamingMessageIds:new Set,pendingQueuedMessageIds:[],requestIdToMessageId:new Map,pendingLocalDeletions:new Set,confirmationToolCallMap:new Map,expandedToolCallIds:new Set,expandedCardIds:new Map,contextWindowUsageByConversation:u,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},takePendingQueuedMessageId:n=>{let r=t().pendingQueuedMessageIds;if(r.includes(n))return e({pendingQueuedMessageIds:r.filter(e=>e!==n)}),n},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 Nn(e,t){if(t.length===0)return e;let n=new Map;for(let e of t)for(let t of R(e))n.has(t)||n.set(t,e);let r=[],i=new Set;for(let t of e){let e;for(let r of R(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 Pn(){let e=$.use.snapshot()?.messages,t=$.use.optimisticSends(),n=$.use.dismissedSurfaceIds();return(0,m.useMemo)(()=>Nn(mt(e,n),t),[e,t,n])}export{I as A,Oe as B,Ft as C,Mt as D,Tt as E,rt as F,ve as G,De as H,nt as I,de as J,ye as K,tt as L,ft as M,st as N,At as O,at as P,P as R,z as S,kt as T,Ee as U,ke as V,xe as W,fe as X,he as Y,ue as Z,Ut as _,mn as a,Lt as b,Cn as c,_n as d,fn as f,Ht as g,Rt as h,pn as i,vt as j,jt as k,Sn as l,Bt as m,Nn as n,gn as o,Vt as p,_e as q,$ as r,hn as s,Pn as t,xn as u,zt as v,L as w,R as x,B as y,S as z};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./useQuery-Bz-fbQ-m.js";import{n as r}from"./toast-DJj-rM9J.js";import{r as i}from"./use-is-org-ready-CfmZwxdN.js";import{Lt as a}from"./react-query.gen-BAqQbp0v.js";import{L as o}from"./react-query.gen-B0XpEMFg.js";function s(e,t){return{voices:e?.voices??[],defaultModel:e?.defaultModel??null,fetched:!!e,loading:t}}function c(e,t={}){let r=i(),{data:o,isLoading:c}=n({...a({path:{assistant_id:e??``}}),enabled:r&&!!e&&(t.enabled??!0),staleTime:6e4,retry:!1});return s(o,c)}function l(e={}){let t=i(),{data:r,isLoading:a}=n({...o(),enabled:t&&(e.enabled??!0),staleTime:6e4,retry:!1});return s(r,a)}var u=e(t(),1);function d(){let[e,t]=(0,u.useState)(null),n=(0,u.useRef)(null),i=(0,u.useRef)(0),a=()=>{i.current++,n.current?.pause(),n.current=null,t(null)};(0,u.useEffect)(()=>()=>{i.current++,n.current?.pause(),n.current=null},[]);function o(e){if(!e.sampleUrl)return;n.current?.pause();let a=++i.current,o=new Audio(e.sampleUrl);n.current=o,t(e.model);let s=()=>{i.current===a&&t(null)};o.onended=s,o.onerror=s,o.play().catch(()=>{i.current===a&&(r.error(`Could not play the voice sample.`),t(null))})}return{previewingModel:e,play:o,stop:a}}export{c as n,l as r,d as t};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./useQuery-Bz-fbQ-m.js";import{n as r}from"./toast-DJj-rM9J.js";import{r as i}from"./use-is-org-ready-CNHq_yBF.js";import{Lt as a}from"./react-query.gen-BAqQbp0v.js";import{L as o}from"./react-query.gen-B0XpEMFg.js";function s(e,t){return{voices:e?.voices??[],defaultModel:e?.defaultModel??null,fetched:!!e,loading:t}}function c(e,t={}){let r=i(),{data:o,isLoading:c}=n({...a({path:{assistant_id:e??``}}),enabled:r&&!!e&&(t.enabled??!0),staleTime:6e4,retry:!1});return s(o,c)}function l(e={}){let t=i(),{data:r,isLoading:a}=n({...o(),enabled:t&&(e.enabled??!0),staleTime:6e4,retry:!1});return s(r,a)}var u=e(t(),1);function d(){let[e,t]=(0,u.useState)(null),n=(0,u.useRef)(null),i=(0,u.useRef)(0),a=()=>{i.current++,n.current?.pause(),n.current=null,t(null)};(0,u.useEffect)(()=>()=>{i.current++,n.current?.pause(),n.current=null},[]);function o(e){if(!e.sampleUrl)return;n.current?.pause();let a=++i.current,o=new Audio(e.sampleUrl);n.current=o,t(e.model);let s=()=>{i.current===a&&t(null)};o.onended=s,o.onerror=s,o.play().catch(()=>{i.current===a&&(r.error(`Could not play the voice sample.`),t(null))})}return{previewingModel:e,play:o,stop:a}}export{c as n,l as r,d as t};
@@ -1 +1 @@
1
- import{t as e}from"./capture-error-DIcLdUu5.js";import"./src-ly8ixpHd.js";import{n as t}from"./toast-DJj-rM9J.js";import{n,t as r}from"./create-selectors-CEbfsat6.js";import{t as i}from"./api-errors-37rFaJd8.js";import{Ct as a,n as o,xt as s}from"./sdk.gen-qwmaWHuE.js";import{t as c}from"./open-workspace-file-1J9ToS-d.js";import{o as l}from"./workspace-path-links-vDBIljq_.js";var u=new Map;function d(e,t){return`${e}::${t}`}function f(e,t){let n=d(e,t),r=u.get(n);return r??(r=o({path:{assistant_id:e,id:t},throwOnError:!0}).then(e=>e.data.html).catch(e=>{throw u.delete(n),e}),u.set(n,r)),r}function p(e,t,n){u.set(d(e,t),Promise.resolve(n))}function m(e,t){u.delete(d(e,t))}function h(e){if(typeof e!=`object`||!e)return!1;let t=e.error;if(typeof t!=`object`||!t||t.code!==`NOT_FOUND`)return!1;let n=t.message;return typeof n==`string`&&n.startsWith(`App not found`)}function g(e){return e instanceof i&&e.status<500&&e.message?e.message:`Couldn't open this file`}var _=[`File not found`,`The file backing this document no longer exists`];function v(e){return!(e instanceof i)||e.status!==404?!1:!_.some(t=>e.message.startsWith(t))}function y(e,t){let n=e.mainView;return n===`document`||n===`subagent-detail`||n===`tool-detail`||n===`activity-steps`||n===`message-files`||n===`workflow-detail`||n===`acp-run-detail`||n===`background-task-detail`||n===`skill-detail`||n===`channel-setup`?e[t]:n}function b(e,t){return e===null||e.source!==t.source?!1:e.source===`document`&&t.source===`document`?e.surfaceId===t.surfaceId:e.source===`document`||t.source===`document`?!1:e.workspacePath===t.workspacePath}function x(e,t){return e.messageId!=null||t.messageId!=null?e.messageId===t.messageId&&e.groupIndex===t.groupIndex:e.toolCalls[0]?.id===t.toolCalls[0]?.id}function S(e,t){return e.messageId===t.messageId}function C(e,t){return t.messageId==null?e.thinkingText===t.thinkingText:e.messageId===t.messageId&&e.thinkingGroupIndex===t.thinkingGroupIndex&&e.thinkingItemIndex===t.thinkingItemIndex}var w={mainView:`chat`,activeAppId:null,openedAppState:null,activeDocumentTarget:null,openedDocumentState:null,isAppMinimized:!1,intelligenceTab:`identity`,assetsRefreshKey:0,viewBeforeDocument:`chat`,activeSubagentId:null,viewBeforeSubagentDetail:`chat`,activeToolDetail:null,viewBeforeToolDetail:`chat`,activeActivitySteps:null,viewBeforeActivitySteps:`chat`,activeMessageFiles:null,viewBeforeMessageFiles:`chat`,activeWorkflowRunId:null,viewBeforeWorkflowDetail:`chat`,activeAcpRunId:null,viewBeforeAcpRunDetail:`chat`,activeBackgroundTaskId:null,viewBeforeBackgroundTaskDetail:`chat`,activeSkillDetailId:null,viewBeforeSkillDetail:`chat`,activeChannelSetup:null,viewBeforeChannelSetup:`chat`,ruleEditorRequestSeq:0,ruleEditorRequestToolCallId:null},T=r(n()((n,r)=>({...w,setMainView:e=>{r().mainView!==e&&n({mainView:e})},setIntelligenceTab:e=>{r().intelligenceTab!==e&&n({intelligenceTab:e})},openApp:e=>{n({mainView:`app`,activeAppId:e,openedAppState:null,isAppMinimized:!1})},loadApp:async(t,i)=>{n({mainView:`app`,activeAppId:i,openedAppState:null,isAppMinimized:!1});try{let{data:e}=await o({path:{assistant_id:t,id:i},throwOnError:!0});if(r().activeAppId!==i)return;n({openedAppState:{appId:e.appId,dirName:e.dirName,name:e.name,html:e.html}}),p(t,e.appId,e.html)}catch(t){if(r().activeAppId!==i)return;h(t)||e(t,{context:`openApp`}),n({mainView:`chat`,activeAppId:null,openedAppState:null})}},setLoadedApp:e=>{n({openedAppState:e})},handleAppLoadFailed:()=>{n({mainView:`chat`,activeAppId:null,openedAppState:null})},closeApp:()=>{n({mainView:`chat`,activeAppId:null,openedAppState:null,isAppMinimized:!1})},toggleAppMinimized:()=>{n({isAppMinimized:!r().isAppMinimized})},minimizeApp:()=>{n({isAppMinimized:!0})},handleAppUnpinned:e=>{let t=r();return t.activeAppId!==e||t.mainView!==`app`&&t.mainView!==`app-editing`?!1:(r().closeApp(),!0)},enterAppEditing:()=>{n({mainView:`app-editing`})},exitAppEditing:()=>{n({mainView:`app`})},openSubagentDetail:e=>{n({mainView:`subagent-detail`,activeSubagentId:e,viewBeforeSubagentDetail:y(r(),`viewBeforeSubagentDetail`)})},closeSubagentDetail:()=>{n({mainView:r().viewBeforeSubagentDetail,activeSubagentId:null})},openWorkflowDetail:e=>{n({mainView:`workflow-detail`,activeWorkflowRunId:e,viewBeforeWorkflowDetail:y(r(),`viewBeforeWorkflowDetail`)})},closeWorkflowDetail:()=>{n({mainView:r().viewBeforeWorkflowDetail,activeWorkflowRunId:null})},openAcpRunDetail:e=>{n({mainView:`acp-run-detail`,activeAcpRunId:e,viewBeforeAcpRunDetail:y(r(),`viewBeforeAcpRunDetail`)})},closeAcpRunDetail:()=>{n({mainView:r().viewBeforeAcpRunDetail,activeAcpRunId:null})},openBackgroundTaskDetail:e=>{n({mainView:`background-task-detail`,activeBackgroundTaskId:e,viewBeforeBackgroundTaskDetail:y(r(),`viewBeforeBackgroundTaskDetail`)})},closeBackgroundTaskDetail:()=>{n({mainView:r().viewBeforeBackgroundTaskDetail,activeBackgroundTaskId:null})},openSkillDetail:e=>{n({mainView:`skill-detail`,activeSkillDetailId:e,viewBeforeSkillDetail:y(r(),`viewBeforeSkillDetail`)})},closeSkillDetail:()=>{n({mainView:r().viewBeforeSkillDetail,activeSkillDetailId:null})},openProcessDetail:({kind:e,id:t})=>{switch(e){case`subagent`:r().openSubagentDetail(t);return;case`workflow`:r().openWorkflowDetail(t);return;case`acp-run`:r().openAcpRunDetail(t);return;case`background-task`:r().openBackgroundTaskDetail(t);return;default:}},closeActiveOverlay:()=>{switch(r().mainView){case`document`:return r().closeDocument(),!0;case`subagent-detail`:return r().closeSubagentDetail(),!0;case`tool-detail`:return r().closeToolDetail(),!0;case`activity-steps`:return r().closeActivitySteps(),!0;case`message-files`:return r().closeMessageFiles(),!0;case`workflow-detail`:return r().closeWorkflowDetail(),!0;case`acp-run-detail`:return r().closeAcpRunDetail(),!0;case`background-task-detail`:return r().closeBackgroundTaskDetail(),!0;case`skill-detail`:return r().closeSkillDetail(),!0;case`channel-setup`:return r().closeChannelSetup(),!0;default:return!1}},openChannelSetup:e=>{n({mainView:`channel-setup`,activeChannelSetup:e,viewBeforeChannelSetup:y(r(),`viewBeforeChannelSetup`)})},closeChannelSetup:()=>{n({mainView:r().viewBeforeChannelSetup,activeChannelSetup:null})},openToolDetail:e=>{n({mainView:`tool-detail`,activeToolDetail:e,viewBeforeToolDetail:y(r(),`viewBeforeToolDetail`)})},toggleToolDetail:e=>{let t=r(),n=t.activeToolDetail;t.mainView===`tool-detail`&&n!=null&&(e.kind===`thinking`?n.kind===`thinking`&&C(n,e):n.kind!==`thinking`&&n.toolCallId===e.toolCallId)?r().closeToolDetail():r().openToolDetail(e)},closeToolDetail:()=>{n({mainView:r().viewBeforeToolDetail,activeToolDetail:null})},requestRuleEditor:e=>{e&&n(t=>({ruleEditorRequestSeq:t.ruleEditorRequestSeq+1,ruleEditorRequestToolCallId:e}))},openActivitySteps:e=>{n({mainView:`activity-steps`,activeActivitySteps:e,viewBeforeActivitySteps:y(r(),`viewBeforeActivitySteps`)})},toggleActivitySteps:e=>{let t=r(),n=t.activeActivitySteps;t.mainView===`activity-steps`&&n!=null&&x(n,e)?r().closeActivitySteps():r().openActivitySteps(e)},closeActivitySteps:()=>{n({mainView:r().viewBeforeActivitySteps,activeActivitySteps:null})},openMessageFiles:e=>{n({mainView:`message-files`,activeMessageFiles:e,viewBeforeMessageFiles:y(r(),`viewBeforeMessageFiles`)})},toggleMessageFiles:e=>{let t=r(),n=t.activeMessageFiles;t.mainView===`message-files`&&n!=null&&S(n,e)?r().closeMessageFiles():r().openMessageFiles(e)},closeMessageFiles:()=>{n({mainView:r().viewBeforeMessageFiles,activeMessageFiles:null})},clearTranscriptPanelPayloads:()=>{n({activeMessageFiles:null,activeActivitySteps:null,activeToolDetail:null})},openDocument:()=>{n({mainView:`document`,openedDocumentState:null,viewBeforeDocument:y(r(),`viewBeforeDocument`)})},loadDocument:async(e,t)=>{let i=y(r(),`viewBeforeDocument`),a={source:`document`,surfaceId:t};n({mainView:`document`,activeDocumentTarget:a,openedDocumentState:null,viewBeforeDocument:i});try{let{data:o}=await s({path:{assistant_id:e,id:t},throwOnError:!0});if(!b(r().activeDocumentTarget,a))return;if(!o){n({mainView:i,activeDocumentTarget:null,openedDocumentState:null});return}n({openedDocumentState:{source:`document`,surfaceId:o.surfaceId,conversationId:o.conversationId,documentName:o.title??`Untitled`,content:o.content??``,workspacePath:o.workspacePath}})}catch{if(!b(r().activeDocumentTarget,a))return;n({mainView:i,activeDocumentTarget:null,openedDocumentState:null})}},loadWorkspaceFileDocument:async(e,i,o)=>{let s=y(r(),`viewBeforeDocument`),l={source:`workspace-file`,workspacePath:i};n({mainView:`document`,activeDocumentTarget:l,openedDocumentState:null,viewBeforeDocument:s});let u=e=>{if(b(r().activeDocumentTarget,l)){if(n({mainView:s,activeDocumentTarget:null,openedDocumentState:null}),v(e)){c(i);return}t.error(g(e))}};try{let{data:t}=await a({path:{assistant_id:e},body:{path:i,conversationId:o},throwOnError:!0});if(!b(r().activeDocumentTarget,l))return;if(!t){u(null);return}n({activeDocumentTarget:{source:`document`,surfaceId:t.surfaceId},openedDocumentState:{source:`document`,surfaceId:t.surfaceId,conversationId:t.conversationId,documentName:t.title||`Untitled`,content:t.content??``,workspacePath:t.workspacePath}})}catch(e){u(e)}},openWorkspaceFilePreview:(e,t)=>{n({mainView:`document`,activeDocumentTarget:{source:`workspace-file-preview`,workspacePath:e},openedDocumentState:{source:`workspace-file-preview`,workspacePath:e,documentName:l(e),previewKind:t},viewBeforeDocument:y(r(),`viewBeforeDocument`)})},setLoadedDocument:e=>{n({openedDocumentState:e})},updateDocumentContent:(e,t,i)=>{let a=r().openedDocumentState;if(!a||a.source!==`document`||a.surfaceId!==e)return;let o=i===`append`?a.content+t:t;n({openedDocumentState:{...a,content:o}})},handleDocumentLoadFailed:()=>{n({mainView:r().viewBeforeDocument,activeDocumentTarget:null,openedDocumentState:null})},closeDocument:()=>{n({mainView:r().viewBeforeDocument,activeDocumentTarget:null,openedDocumentState:null})},refreshAssets:()=>{n({assetsRefreshKey:r().assetsRefreshKey+1})},reset:()=>n({...w})})));export{m as a,T as i,S as n,f as o,C as r,p as s,x as t};
1
+ import{t as e}from"./capture-error-DIcLdUu5.js";import"./src-ly8ixpHd.js";import{n as t}from"./toast-DJj-rM9J.js";import{n,t as r}from"./create-selectors-CEbfsat6.js";import{t as i}from"./api-errors-37rFaJd8.js";import{Ct as a,n as o,xt as s}from"./sdk.gen-qwmaWHuE.js";import{t as c}from"./open-workspace-file-DxlQEPBv.js";import{o as l}from"./workspace-path-links-vDBIljq_.js";var u=new Map;function d(e,t){return`${e}::${t}`}function f(e,t){let n=d(e,t),r=u.get(n);return r??(r=o({path:{assistant_id:e,id:t},throwOnError:!0}).then(e=>e.data.html).catch(e=>{throw u.delete(n),e}),u.set(n,r)),r}function p(e,t,n){u.set(d(e,t),Promise.resolve(n))}function m(e,t){u.delete(d(e,t))}function h(e){if(typeof e!=`object`||!e)return!1;let t=e.error;if(typeof t!=`object`||!t||t.code!==`NOT_FOUND`)return!1;let n=t.message;return typeof n==`string`&&n.startsWith(`App not found`)}function g(e){return e instanceof i&&e.status<500&&e.message?e.message:`Couldn't open this file`}var _=[`File not found`,`The file backing this document no longer exists`];function v(e){return!(e instanceof i)||e.status!==404?!1:!_.some(t=>e.message.startsWith(t))}function y(e,t){let n=e.mainView;return n===`document`||n===`subagent-detail`||n===`tool-detail`||n===`activity-steps`||n===`message-files`||n===`workflow-detail`||n===`acp-run-detail`||n===`background-task-detail`||n===`skill-detail`||n===`channel-setup`?e[t]:n}function b(e,t){return e===null||e.source!==t.source?!1:e.source===`document`&&t.source===`document`?e.surfaceId===t.surfaceId:e.source===`document`||t.source===`document`?!1:e.workspacePath===t.workspacePath}function x(e,t){return e.messageId!=null||t.messageId!=null?e.messageId===t.messageId&&e.groupIndex===t.groupIndex:e.toolCalls[0]?.id===t.toolCalls[0]?.id}function S(e,t){return e.messageId===t.messageId}function C(e,t){return t.messageId==null?e.thinkingText===t.thinkingText:e.messageId===t.messageId&&e.thinkingGroupIndex===t.thinkingGroupIndex&&e.thinkingItemIndex===t.thinkingItemIndex}var w={mainView:`chat`,activeAppId:null,openedAppState:null,activeDocumentTarget:null,openedDocumentState:null,isAppMinimized:!1,intelligenceTab:`identity`,assetsRefreshKey:0,viewBeforeDocument:`chat`,activeSubagentId:null,viewBeforeSubagentDetail:`chat`,activeToolDetail:null,viewBeforeToolDetail:`chat`,activeActivitySteps:null,viewBeforeActivitySteps:`chat`,activeMessageFiles:null,viewBeforeMessageFiles:`chat`,activeWorkflowRunId:null,viewBeforeWorkflowDetail:`chat`,activeAcpRunId:null,viewBeforeAcpRunDetail:`chat`,activeBackgroundTaskId:null,viewBeforeBackgroundTaskDetail:`chat`,activeSkillDetailId:null,viewBeforeSkillDetail:`chat`,activeChannelSetup:null,viewBeforeChannelSetup:`chat`,ruleEditorRequestSeq:0,ruleEditorRequestToolCallId:null},T=r(n()((n,r)=>({...w,setMainView:e=>{r().mainView!==e&&n({mainView:e})},setIntelligenceTab:e=>{r().intelligenceTab!==e&&n({intelligenceTab:e})},openApp:e=>{n({mainView:`app`,activeAppId:e,openedAppState:null,isAppMinimized:!1})},loadApp:async(t,i)=>{n({mainView:`app`,activeAppId:i,openedAppState:null,isAppMinimized:!1});try{let{data:e}=await o({path:{assistant_id:t,id:i},throwOnError:!0});if(r().activeAppId!==i)return;n({openedAppState:{appId:e.appId,dirName:e.dirName,name:e.name,html:e.html}}),p(t,e.appId,e.html)}catch(t){if(r().activeAppId!==i)return;h(t)||e(t,{context:`openApp`}),n({mainView:`chat`,activeAppId:null,openedAppState:null})}},setLoadedApp:e=>{n({openedAppState:e})},handleAppLoadFailed:()=>{n({mainView:`chat`,activeAppId:null,openedAppState:null})},closeApp:()=>{n({mainView:`chat`,activeAppId:null,openedAppState:null,isAppMinimized:!1})},toggleAppMinimized:()=>{n({isAppMinimized:!r().isAppMinimized})},minimizeApp:()=>{n({isAppMinimized:!0})},handleAppUnpinned:e=>{let t=r();return t.activeAppId!==e||t.mainView!==`app`&&t.mainView!==`app-editing`?!1:(r().closeApp(),!0)},enterAppEditing:()=>{n({mainView:`app-editing`})},exitAppEditing:()=>{n({mainView:`app`})},openSubagentDetail:e=>{n({mainView:`subagent-detail`,activeSubagentId:e,viewBeforeSubagentDetail:y(r(),`viewBeforeSubagentDetail`)})},closeSubagentDetail:()=>{n({mainView:r().viewBeforeSubagentDetail,activeSubagentId:null})},openWorkflowDetail:e=>{n({mainView:`workflow-detail`,activeWorkflowRunId:e,viewBeforeWorkflowDetail:y(r(),`viewBeforeWorkflowDetail`)})},closeWorkflowDetail:()=>{n({mainView:r().viewBeforeWorkflowDetail,activeWorkflowRunId:null})},openAcpRunDetail:e=>{n({mainView:`acp-run-detail`,activeAcpRunId:e,viewBeforeAcpRunDetail:y(r(),`viewBeforeAcpRunDetail`)})},closeAcpRunDetail:()=>{n({mainView:r().viewBeforeAcpRunDetail,activeAcpRunId:null})},openBackgroundTaskDetail:e=>{n({mainView:`background-task-detail`,activeBackgroundTaskId:e,viewBeforeBackgroundTaskDetail:y(r(),`viewBeforeBackgroundTaskDetail`)})},closeBackgroundTaskDetail:()=>{n({mainView:r().viewBeforeBackgroundTaskDetail,activeBackgroundTaskId:null})},openSkillDetail:e=>{n({mainView:`skill-detail`,activeSkillDetailId:e,viewBeforeSkillDetail:y(r(),`viewBeforeSkillDetail`)})},closeSkillDetail:()=>{n({mainView:r().viewBeforeSkillDetail,activeSkillDetailId:null})},openProcessDetail:({kind:e,id:t})=>{switch(e){case`subagent`:r().openSubagentDetail(t);return;case`workflow`:r().openWorkflowDetail(t);return;case`acp-run`:r().openAcpRunDetail(t);return;case`background-task`:r().openBackgroundTaskDetail(t);return;default:}},closeActiveOverlay:()=>{switch(r().mainView){case`document`:return r().closeDocument(),!0;case`subagent-detail`:return r().closeSubagentDetail(),!0;case`tool-detail`:return r().closeToolDetail(),!0;case`activity-steps`:return r().closeActivitySteps(),!0;case`message-files`:return r().closeMessageFiles(),!0;case`workflow-detail`:return r().closeWorkflowDetail(),!0;case`acp-run-detail`:return r().closeAcpRunDetail(),!0;case`background-task-detail`:return r().closeBackgroundTaskDetail(),!0;case`skill-detail`:return r().closeSkillDetail(),!0;case`channel-setup`:return r().closeChannelSetup(),!0;default:return!1}},openChannelSetup:e=>{n({mainView:`channel-setup`,activeChannelSetup:e,viewBeforeChannelSetup:y(r(),`viewBeforeChannelSetup`)})},closeChannelSetup:()=>{n({mainView:r().viewBeforeChannelSetup,activeChannelSetup:null})},openToolDetail:e=>{n({mainView:`tool-detail`,activeToolDetail:e,viewBeforeToolDetail:y(r(),`viewBeforeToolDetail`)})},toggleToolDetail:e=>{let t=r(),n=t.activeToolDetail;t.mainView===`tool-detail`&&n!=null&&(e.kind===`thinking`?n.kind===`thinking`&&C(n,e):n.kind!==`thinking`&&n.toolCallId===e.toolCallId)?r().closeToolDetail():r().openToolDetail(e)},closeToolDetail:()=>{n({mainView:r().viewBeforeToolDetail,activeToolDetail:null})},requestRuleEditor:e=>{e&&n(t=>({ruleEditorRequestSeq:t.ruleEditorRequestSeq+1,ruleEditorRequestToolCallId:e}))},openActivitySteps:e=>{n({mainView:`activity-steps`,activeActivitySteps:e,viewBeforeActivitySteps:y(r(),`viewBeforeActivitySteps`)})},toggleActivitySteps:e=>{let t=r(),n=t.activeActivitySteps;t.mainView===`activity-steps`&&n!=null&&x(n,e)?r().closeActivitySteps():r().openActivitySteps(e)},closeActivitySteps:()=>{n({mainView:r().viewBeforeActivitySteps,activeActivitySteps:null})},openMessageFiles:e=>{n({mainView:`message-files`,activeMessageFiles:e,viewBeforeMessageFiles:y(r(),`viewBeforeMessageFiles`)})},toggleMessageFiles:e=>{let t=r(),n=t.activeMessageFiles;t.mainView===`message-files`&&n!=null&&S(n,e)?r().closeMessageFiles():r().openMessageFiles(e)},closeMessageFiles:()=>{n({mainView:r().viewBeforeMessageFiles,activeMessageFiles:null})},clearTranscriptPanelPayloads:()=>{n({activeMessageFiles:null,activeActivitySteps:null,activeToolDetail:null})},openDocument:()=>{n({mainView:`document`,openedDocumentState:null,viewBeforeDocument:y(r(),`viewBeforeDocument`)})},loadDocument:async(e,t)=>{let i=y(r(),`viewBeforeDocument`),a={source:`document`,surfaceId:t};n({mainView:`document`,activeDocumentTarget:a,openedDocumentState:null,viewBeforeDocument:i});try{let{data:o}=await s({path:{assistant_id:e,id:t},throwOnError:!0});if(!b(r().activeDocumentTarget,a))return;if(!o){n({mainView:i,activeDocumentTarget:null,openedDocumentState:null});return}n({openedDocumentState:{source:`document`,surfaceId:o.surfaceId,conversationId:o.conversationId,documentName:o.title??`Untitled`,content:o.content??``,workspacePath:o.workspacePath}})}catch{if(!b(r().activeDocumentTarget,a))return;n({mainView:i,activeDocumentTarget:null,openedDocumentState:null})}},loadWorkspaceFileDocument:async(e,i,o)=>{let s=y(r(),`viewBeforeDocument`),l={source:`workspace-file`,workspacePath:i};n({mainView:`document`,activeDocumentTarget:l,openedDocumentState:null,viewBeforeDocument:s});let u=e=>{if(b(r().activeDocumentTarget,l)){if(n({mainView:s,activeDocumentTarget:null,openedDocumentState:null}),v(e)){c(i);return}t.error(g(e))}};try{let{data:t}=await a({path:{assistant_id:e},body:{path:i,conversationId:o},throwOnError:!0});if(!b(r().activeDocumentTarget,l))return;if(!t){u(null);return}n({activeDocumentTarget:{source:`document`,surfaceId:t.surfaceId},openedDocumentState:{source:`document`,surfaceId:t.surfaceId,conversationId:t.conversationId,documentName:t.title||`Untitled`,content:t.content??``,workspacePath:t.workspacePath}})}catch(e){u(e)}},openWorkspaceFilePreview:(e,t)=>{n({mainView:`document`,activeDocumentTarget:{source:`workspace-file-preview`,workspacePath:e},openedDocumentState:{source:`workspace-file-preview`,workspacePath:e,documentName:l(e),previewKind:t},viewBeforeDocument:y(r(),`viewBeforeDocument`)})},setLoadedDocument:e=>{n({openedDocumentState:e})},updateDocumentContent:(e,t,i)=>{let a=r().openedDocumentState;if(!a||a.source!==`document`||a.surfaceId!==e)return;let o=i===`append`?a.content+t:t;n({openedDocumentState:{...a,content:o}})},handleDocumentLoadFailed:()=>{n({mainView:r().viewBeforeDocument,activeDocumentTarget:null,openedDocumentState:null})},closeDocument:()=>{n({mainView:r().viewBeforeDocument,activeDocumentTarget:null,openedDocumentState:null})},refreshAssets:()=>{n({assetsRefreshKey:r().assetsRefreshKey+1})},reset:()=>n({...w})})));export{m as a,T as i,S as n,f as o,C as r,p as s,x as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-fyWSnR9X.js";import{n as r}from"./QueryClientProvider-CMu7CkQU.js";import{t as i}from"./useQuery-Bz-fbQ-m.js";import{t as a}from"./jsx-runtime-D3ZM-ToX.js";import{t as o}from"./cn-CJf7MmLX.js";import{t as s}from"./check-Dt2rQhdg.js";import"./src-ly8ixpHd.js";import{t as c}from"./square-DTFrgbZb.js";import{t as l}from"./volume-2-BXDl4IEg.js";import{n as u}from"./toast-DJj-rM9J.js";import{t as d}from"./dropdown-Dj83uU1o.js";import{j as f}from"./sdk.gen-qwmaWHuE.js";import{r as p}from"./use-is-org-ready-CfmZwxdN.js";import{Rt as m,c as h,l as g}from"./react-query.gen-BAqQbp0v.js";import{n as _,t as v}from"./use-voice-sample-preview-CXWDRLHi.js";var y=e(t(),1);function b({assistantId:e,configuredValue:t,buildPatchBody:n,failureMessage:i}){let a=r(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),d=c??t,p=(0,y.useRef)(Promise.resolve()),m=(0,y.useRef)(0);return{currentValue:d,selecting:o,select:(0,y.useCallback)(t=>{if(!e||t===d)return;let r=++m.current;l(t),s(!0),p.current=p.current.then(async()=>{try{let{response:r}=await f({path:{assistant_id:e},body:n(t),throwOnError:!1});if(!r?.ok){u.error(i);return}await a.invalidateQueries({queryKey:g({path:{assistant_id:e}})})}catch{u.error(i)}finally{r===m.current&&(l(null),s(!1))}})},[e,d,n,i,a])}}var x=e=>({services:{tts:{providers:{vellum:{model:e}}}}});function S(e){let t=p()&&!!e,{data:n}=i({...m({path:{assistant_id:e??``}}),enabled:t,staleTime:1/0,retry:!1}),{data:r}=i({...h({path:{assistant_id:e??``}}),enabled:t,staleTime:3e4}),a=r?.services?.tts,o=a?.mode===`managed`||a?.provider===`vellum`,s=n?.providers?.find(e=>e.id===`vellum`)?.supportsVoiceSelection===!0,{voices:c,defaultModel:l}=_(e,{enabled:t&&o}),u=t&&o&&s&&c.length>0,d=t&&!!r&&!o,{currentValue:f,selecting:g,select:v}=b({assistantId:e,configuredValue:a?.providers?.vellum?.model??l??c[0]?.model??``,buildPatchBody:x,failureMessage:`Couldn't change the voice just now. Try again.`});return{available:u,isByok:d,voices:c,currentModel:f,defaultModel:l??``,selectModel:v,selecting:g}}var C={deepgram:`Deepgram`,elevenlabs:`ElevenLabs`},w=`Uses Vellum credits, through providers like ElevenLabs and Deepgram.`;function T(e){let t=e.indexOf(` · `);return t===-1?{traits:e,accent:``}:{accent:e.slice(0,t),traits:e.slice(t+3)}}function E(e){let{traits:t}=T(e);return t.charAt(0).toUpperCase()+t.slice(1)}function D(e){let t=new Map;for(let n of e){let{accent:e}=T(n.description),r=e||`Other`,i=t.get(r);i?i.push(n):t.set(r,[n])}return[...t.entries()].sort((e,t)=>e[0].localeCompare(t[0])).map(([e,t])=>({accent:e,voices:[...t].sort((e,t)=>T(e.description).traits.localeCompare(T(t.description).traits))}))}var O=a();function k({description:e,className:t}){let{accent:n}=T(e);return(0,O.jsxs)(`span`,{className:o(`truncate`,t),children:[E(e),n&&(0,O.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:` · ${n}`})]})}function A({assistantId:e,heading:t,className:r,onSelect:i,value:a,onChange:u,showSource:f=!1,filterBySource:p=!1}){let{available:m,voices:h,currentModel:g,defaultModel:_,selectModel:b,selecting:x}=S(e),w=a!==void 0&&u!==void 0,T=w?a:g,k=e=>{w?u(e):b(e),i?.()},A=(0,y.useMemo)(()=>{let e=new Set,t=[];for(let n of h)e.has(n.source)||(e.add(n.source),t.push(n.source));return t.sort((e,t)=>(C[e]??e).localeCompare(C[t]??t))},[h]),[j,M]=(0,y.useState)(null),N=h.find(e=>e.model===T)?.source,P=p?j??N??A[0]??null:null,F=p&&A.length>1,I=(0,y.useMemo)(()=>D(P?h.filter(e=>e.source===P):h),[h,P]),{previewingModel:L,play:R,stop:z}=v(),B=(0,y.useRef)(null);(0,y.useEffect)(()=>{B.current?.scrollIntoView?.({block:`nearest`})},[]);let V=h.length>0;return(w?!V:!m)?null:(0,O.jsxs)(`div`,{className:o(`flex flex-col gap-2`,t&&`border-t border-[var(--border-subtle)] pt-3`,r),children:[t&&(0,O.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:t}),F&&(0,O.jsx)(`div`,{className:`px-1 pb-1`,children:(0,O.jsx)(d,{value:P??``,onChange:M,options:A.map(e=>({value:e,label:C[e]??e})),"aria-label":`Voice provider`})}),(0,O.jsx)(`div`,{role:`listbox`,"aria-label":`Assistant voice`,className:o(`flex flex-col overflow-y-auto`,p?`max-h-[60vh]`:`max-h-80`,x&&`pointer-events-none opacity-70`),children:I.map(e=>(0,O.jsxs)(`div`,{role:`group`,"aria-label":e.accent,children:[(0,O.jsx)(`div`,{className:`px-3 pb-1 pt-3 text-label-small-default text-[var(--content-tertiary)]`,children:e.accent}),e.voices.map(e=>{let t=e.model===T,r=L===e.model,i=e.model===_;return(0,O.jsxs)(`div`,{ref:t?B:void 0,role:`option`,"aria-selected":t,onClick:()=>k(e.model),className:o(`group flex cursor-pointer items-center gap-2 rounded-md px-3 py-2.5 transition-colors`,t?`bg-[var(--surface-active)]`:`hover:bg-[var(--surface-hover)]`),children:[(0,O.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-default text-[var(--content-default)]`,children:[E(e.description),i&&(0,O.jsxs)(`span`,{className:`text-[var(--content-tertiary)]`,children:[` `,`(default)`]})]}),f&&!p&&(0,O.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[var(--content-tertiary)]`,children:C[e.source]??e.source}),(0,O.jsxs)(`div`,{className:`relative flex size-7 shrink-0 items-center justify-center`,children:[e.sampleUrl!==``&&(0,O.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:r?(0,O.jsx)(c,{}):(0,O.jsx)(l,{}),"aria-label":r?`Stop preview`:`Preview ${e.description}`,className:o(`absolute inset-0 transition-opacity`,r?`opacity-100`:`opacity-0 group-hover:opacity-100 focus-visible:opacity-100 touch-mobile:opacity-100`),onClick:t=>{t.stopPropagation(),r?z():R(e)}}),t&&(0,O.jsx)(s,{"aria-hidden":!0,className:o(`pointer-events-none size-4 text-[var(--system-positive-strong)] transition-opacity`,r?`opacity-0`:e.sampleUrl===``?`opacity-100`:`opacity-100 group-hover:opacity-0 group-focus-within:opacity-0`)})]})]},e.model)})]},e.accent))})]})}export{S as a,E as i,A as n,b as o,w as r,k as t};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-fyWSnR9X.js";import{n as r}from"./QueryClientProvider-CMu7CkQU.js";import{t as i}from"./useQuery-Bz-fbQ-m.js";import{t as a}from"./jsx-runtime-D3ZM-ToX.js";import{t as o}from"./cn-CJf7MmLX.js";import{t as s}from"./check-Dt2rQhdg.js";import"./src-ly8ixpHd.js";import{t as c}from"./square-DTFrgbZb.js";import{t as l}from"./volume-2-BXDl4IEg.js";import{n as u}from"./toast-DJj-rM9J.js";import{t as d}from"./dropdown-Dj83uU1o.js";import{j as f}from"./sdk.gen-qwmaWHuE.js";import{r as p}from"./use-is-org-ready-CNHq_yBF.js";import{Rt as m,c as h,l as g}from"./react-query.gen-BAqQbp0v.js";import{n as _,t as v}from"./use-voice-sample-preview-CG9dYvdC.js";var y=e(t(),1);function b({assistantId:e,configuredValue:t,buildPatchBody:n,failureMessage:i}){let a=r(),[o,s]=(0,y.useState)(!1),[c,l]=(0,y.useState)(null),d=c??t,p=(0,y.useRef)(Promise.resolve()),m=(0,y.useRef)(0);return{currentValue:d,selecting:o,select:(0,y.useCallback)(t=>{if(!e||t===d)return;let r=++m.current;l(t),s(!0),p.current=p.current.then(async()=>{try{let{response:r}=await f({path:{assistant_id:e},body:n(t),throwOnError:!1});if(!r?.ok){u.error(i);return}await a.invalidateQueries({queryKey:g({path:{assistant_id:e}})})}catch{u.error(i)}finally{r===m.current&&(l(null),s(!1))}})},[e,d,n,i,a])}}var x=e=>({services:{tts:{providers:{vellum:{model:e}}}}});function S(e){let t=p()&&!!e,{data:n}=i({...m({path:{assistant_id:e??``}}),enabled:t,staleTime:1/0,retry:!1}),{data:r}=i({...h({path:{assistant_id:e??``}}),enabled:t,staleTime:3e4}),a=r?.services?.tts,o=a?.mode===`managed`||a?.provider===`vellum`,s=n?.providers?.find(e=>e.id===`vellum`)?.supportsVoiceSelection===!0,{voices:c,defaultModel:l}=_(e,{enabled:t&&o}),u=t&&o&&s&&c.length>0,d=t&&!!r&&!o,{currentValue:f,selecting:g,select:v}=b({assistantId:e,configuredValue:a?.providers?.vellum?.model??l??c[0]?.model??``,buildPatchBody:x,failureMessage:`Couldn't change the voice just now. Try again.`});return{available:u,isByok:d,voices:c,currentModel:f,defaultModel:l??``,selectModel:v,selecting:g}}var C={deepgram:`Deepgram`,elevenlabs:`ElevenLabs`},w=`Uses Vellum credits, through providers like ElevenLabs and Deepgram.`;function T(e){let t=e.indexOf(` · `);return t===-1?{traits:e,accent:``}:{accent:e.slice(0,t),traits:e.slice(t+3)}}function E(e){let{traits:t}=T(e);return t.charAt(0).toUpperCase()+t.slice(1)}function D(e){let t=new Map;for(let n of e){let{accent:e}=T(n.description),r=e||`Other`,i=t.get(r);i?i.push(n):t.set(r,[n])}return[...t.entries()].sort((e,t)=>e[0].localeCompare(t[0])).map(([e,t])=>({accent:e,voices:[...t].sort((e,t)=>T(e.description).traits.localeCompare(T(t.description).traits))}))}var O=a();function k({description:e,className:t}){let{accent:n}=T(e);return(0,O.jsxs)(`span`,{className:o(`truncate`,t),children:[E(e),n&&(0,O.jsx)(`span`,{className:`text-[var(--content-tertiary)]`,children:` · ${n}`})]})}function A({assistantId:e,heading:t,className:r,onSelect:i,value:a,onChange:u,showSource:f=!1,filterBySource:p=!1}){let{available:m,voices:h,currentModel:g,defaultModel:_,selectModel:b,selecting:x}=S(e),w=a!==void 0&&u!==void 0,T=w?a:g,k=e=>{w?u(e):b(e),i?.()},A=(0,y.useMemo)(()=>{let e=new Set,t=[];for(let n of h)e.has(n.source)||(e.add(n.source),t.push(n.source));return t.sort((e,t)=>(C[e]??e).localeCompare(C[t]??t))},[h]),[j,M]=(0,y.useState)(null),N=h.find(e=>e.model===T)?.source,P=p?j??N??A[0]??null:null,F=p&&A.length>1,I=(0,y.useMemo)(()=>D(P?h.filter(e=>e.source===P):h),[h,P]),{previewingModel:L,play:R,stop:z}=v(),B=(0,y.useRef)(null);(0,y.useEffect)(()=>{B.current?.scrollIntoView?.({block:`nearest`})},[]);let V=h.length>0;return(w?!V:!m)?null:(0,O.jsxs)(`div`,{className:o(`flex flex-col gap-2`,t&&`border-t border-[var(--border-subtle)] pt-3`,r),children:[t&&(0,O.jsx)(`span`,{className:`text-label-medium-default text-[var(--content-secondary)]`,children:t}),F&&(0,O.jsx)(`div`,{className:`px-1 pb-1`,children:(0,O.jsx)(d,{value:P??``,onChange:M,options:A.map(e=>({value:e,label:C[e]??e})),"aria-label":`Voice provider`})}),(0,O.jsx)(`div`,{role:`listbox`,"aria-label":`Assistant voice`,className:o(`flex flex-col overflow-y-auto`,p?`max-h-[60vh]`:`max-h-80`,x&&`pointer-events-none opacity-70`),children:I.map(e=>(0,O.jsxs)(`div`,{role:`group`,"aria-label":e.accent,children:[(0,O.jsx)(`div`,{className:`px-3 pb-1 pt-3 text-label-small-default text-[var(--content-tertiary)]`,children:e.accent}),e.voices.map(e=>{let t=e.model===T,r=L===e.model,i=e.model===_;return(0,O.jsxs)(`div`,{ref:t?B:void 0,role:`option`,"aria-selected":t,onClick:()=>k(e.model),className:o(`group flex cursor-pointer items-center gap-2 rounded-md px-3 py-2.5 transition-colors`,t?`bg-[var(--surface-active)]`:`hover:bg-[var(--surface-hover)]`),children:[(0,O.jsxs)(`span`,{className:`min-w-0 flex-1 truncate text-body-medium-default text-[var(--content-default)]`,children:[E(e.description),i&&(0,O.jsxs)(`span`,{className:`text-[var(--content-tertiary)]`,children:[` `,`(default)`]})]}),f&&!p&&(0,O.jsx)(`span`,{className:`shrink-0 text-body-small-default text-[var(--content-tertiary)]`,children:C[e.source]??e.source}),(0,O.jsxs)(`div`,{className:`relative flex size-7 shrink-0 items-center justify-center`,children:[e.sampleUrl!==``&&(0,O.jsx)(n,{variant:`ghost`,size:`compact`,iconOnly:r?(0,O.jsx)(c,{}):(0,O.jsx)(l,{}),"aria-label":r?`Stop preview`:`Preview ${e.description}`,className:o(`absolute inset-0 transition-opacity`,r?`opacity-100`:`opacity-0 group-hover:opacity-100 focus-visible:opacity-100 touch-mobile:opacity-100`),onClick:t=>{t.stopPropagation(),r?z():R(e)}}),t&&(0,O.jsx)(s,{"aria-hidden":!0,className:o(`pointer-events-none size-4 text-[var(--system-positive-strong)] transition-opacity`,r?`opacity-0`:e.sampleUrl===``?`opacity-100`:`opacity-100 group-hover:opacity-0 group-focus-within:opacity-0`)})]})]},e.model)})]},e.accent))})]})}export{S as a,E as i,A as n,b as o,w as r,k as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,l as n,o as r}from"./local-settings-Bx7FsNo5.js";import{t as i}from"./react-BFJW0bSv.js";import{t as a}from"./button-fyWSnR9X.js";import{m as o,n as s,t as c}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as l}from"./jsx-runtime-D3ZM-ToX.js";import{r as u}from"./middleware-Bxr-mmHu.js";import{L as d,z as f}from"./src-ly8ixpHd.js";import{t as p}from"./info-DkhVkzmK.js";import{t as m}from"./toggle-BEPV0rQM.js";import{t as h}from"./modal-D946-vqt.js";import{t as g}from"./dropdown-Dj83uU1o.js";import{t as _}from"./assistant-identity-store-CBR9g2br.js";import{d as v}from"./routes-CAe1h0Db.js";import{C as y,S as ee,b,d as x,f as S,h as C,i as w,m as te,o as T,p as E,s as D,t as O,w as k,x as A,y as j}from"./voice-providers-note-DWD_VjEF.js";import{a as M,n as ne,r as re,t as ie}from"./voice-list-Dn_1H-ZV.js";import{t as N}from"./use-active-assistant-id-CaI-sL1J.js";import{t as P}from"./detail-card-4afu5RY8.js";var F=e(i(),1),I=l();function L({assistantId:e,open:t,onOpenChange:n}){return(0,I.jsx)(h.Root,{open:t,onOpenChange:n,children:(0,I.jsx)(h.Content,{size:`md`,children:(0,I.jsx)(R,{assistantId:e,onDone:()=>n(!1)})})})}function R({assistantId:e,onDone:t}){let{available:n,currentModel:r,selectModel:i,selecting:o}=M(e);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(h.Header,{children:[(0,I.jsx)(h.Title,{children:`Voices`}),n&&(0,I.jsx)(h.Description,{children:`Uses Vellum credits, through providers like ElevenLabs and Deepgram.`})]}),(0,I.jsx)(h.Body,{children:(0,I.jsx)(ne,{assistantId:e,filterBySource:!0,value:r,onChange:i})}),(0,I.jsxs)(h.Footer,{className:`items-center justify-between gap-3`,children:[(0,I.jsx)(O,{}),(0,I.jsx)(a,{variant:`primary`,onClick:t,disabled:o,className:`shrink-0`,children:`Done`})]})]})}function z(){let e=N(),{available:t,voices:n,currentModel:r}=M(e),i=n.find(e=>e.model===r)??n[0],[o,s]=(0,F.useState)(!1),l=_.use.name(),u=l?`${l}’s Voice`:`Voice`;return t&&i?(0,I.jsxs)(P,{title:u,subtitle:re,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(ie,{description:i.description,className:`min-w-0 text-body-medium-lighter text-[var(--content-default)]`}),(0,I.jsx)(a,{variant:`outlined`,onClick:()=>s(!0),className:`shrink-0`,children:`Change`})]}),(0,I.jsx)(L,{assistantId:e,open:o,onOpenChange:s})]}):(0,I.jsx)(P,{title:u,children:(0,I.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Your assistant speaks through a provider you configured yourself. Set its voice on`,` `,(0,I.jsx)(c,{to:`${v.settings.ai}#text-to-speech`,className:`text-[var(--primary-base)] hover:underline`,children:`Models & Services`}),`.`]})})}var B=[{prefKey:`showUserTranscript`,label:`Show the words you say`,description:`Live transcription while you speak.`},{prefKey:`showAssistantTranscript`,label:`Show the words the assistant says`,description:`Text alongside the spoken response.`}],V=`We recommend keeping both off to start. It feels more like a real conversation.`;function H(){return(0,I.jsx)(`span`,{className:`shrink-0 rounded-full bg-[var(--surface-active)] px-2 py-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`Recommended off`})}function U({label:e,description:t,showBadge:n,checked:r,onChange:i}){return(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`truncate text-body-medium-lighter text-[var(--content-default)]`,children:e}),n?(0,I.jsx)(H,{}):null]}),t?(0,I.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:t}):null]}),(0,I.jsx)(m,{checked:r,onChange:i,"aria-label":e})]})}function W({showDescription:e=!1,showRecommendedBadge:t=!1}){let n=T.use.showUserTranscript(),r=T.use.showAssistantTranscript(),i=T.use.setShowUserTranscript(),a=T.use.setShowAssistantTranscript(),o={showUserTranscript:{checked:n,onChange:i},showAssistantTranscript:{checked:r,onChange:a}};return(0,I.jsx)(I.Fragment,{children:B.map(n=>{let r=o[n.prefKey];return(0,I.jsx)(U,{label:n.label,description:e?n.description:void 0,showBadge:t,checked:r.checked,onChange:r.onChange},n.prefKey)})})}var G=[{label:`Ctrl`,activator:{kind:`modifierOnly`,modifiers:[`control`]}},{label:`Alt`,activator:{kind:`modifierOnly`,modifiers:[`option`]}},{label:`Ctrl+Shift`,activator:{kind:`modifierOnly`,modifiers:[`control`,`shift`]}}],K={label:`Fn`,activator:S},q=`text-body-small-default text-[var(--content-tertiary)]`;function J(){let[e]=o(),t=e.get(`tab`);return t===`sounds`?(0,I.jsx)(s,{replace:!0,to:v.settings.sounds}):t===`services`?(0,I.jsx)(s,{replace:!0,to:v.settings.ai}):(0,I.jsx)(ae,{})}function ae(){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,I.jsxs)(Y,{heading:`Output`,description:`How your assistant sounds.`,children:[(0,I.jsx)(z,{}),(0,I.jsx)(oe,{})]}),(0,I.jsxs)(Y,{heading:`Input`,description:`How you talk to your assistant.`,children:[(0,I.jsx)(ce,{}),(0,I.jsx)(le,{}),(0,I.jsx)(Q,{})]}),(0,I.jsx)(Y,{heading:`Captions`,children:(0,I.jsx)(se,{})})]})}function oe(){let{available:e}=M(N());return e?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 px-1 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,I.jsx)(p,{className:`h-3.5 w-3.5 shrink-0 text-[var(--content-quiet)]`}),(0,I.jsx)(`span`,{children:`Want to use your own API key for STT or TTS, or set a custom voice?`}),(0,I.jsxs)(c,{to:`${v.settings.ai}#text-to-speech`,className:`inline-flex items-center gap-1 text-[var(--content-secondary)] underline decoration-[var(--border-element)] underline-offset-2 hover:text-[var(--content-default)]`,children:[`Set it up in Models & Services`,(0,I.jsx)(u,{className:`h-3 w-3`})]})]}):null}function Y({heading:e,description:t,children:n}){return(0,I.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsx)(`h2`,{className:`text-label-medium-default uppercase tracking-wide text-[var(--content-tertiary)]`,children:e}),t&&(0,I.jsx)(`p`,{className:`text-body-small-default text-[var(--content-quiet)]`,children:t})]}),n]})}function se(){return(0,I.jsx)(P,{title:`Captions`,subtitle:`Show live text of what you and the assistant say during a voice conversation.`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(W,{showDescription:!0}),(0,I.jsx)(`p`,{className:`${q} pt-1`,children:V})]})})}var X=``;function ce(){let[e,t]=(0,F.useState)([]),[i,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(()=>k()),l=(0,F.useCallback)(async()=>{if(navigator.mediaDevices?.enumerateDevices)try{let e=(await navigator.mediaDevices.enumerateDevices()).filter(e=>e.kind===`audioinput`);o(e.length>0&&e.every(e=>!e.label)),t(e.filter(e=>e.deviceId!==``&&e.deviceId!==`default`&&e.deviceId!==`communications`))}catch{t([]),o(!1)}},[]),u=(0,F.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop()}catch{}l()},[l]);(0,F.useEffect)(()=>{l();let e=navigator.mediaDevices;if(!e?.addEventListener)return;let t=()=>void l();return e.addEventListener(`devicechange`,t),()=>e.removeEventListener(`devicechange`,t)},[l]);let d=(0,F.useMemo)(()=>[{value:X,label:`System Default`},...e.map((e,t)=>({value:e.deviceId,label:e.label||`Microphone ${t+1}`}))],[e]),f=(0,F.useCallback)(e=>{c(e),e===X?r(y):n(y,e)},[]);return(0,I.jsx)(P,{title:`Microphone`,subtitle:`Which input device is used for dictation and voice conversations.`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,I.jsx)(`div`,{className:`max-w-xs`,children:(0,I.jsx)(g,{options:d,value:d.some(e=>e.value===s)?s:X,onChange:f,"aria-label":`Microphone`})}),i&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(a,{variant:`outlined`,onClick:u,children:`Allow Microphone Access`}),(0,I.jsx)(`span`,{className:q,children:`Grant microphone access to list your available input devices.`})]})]})})}function le(){let e=D(),[r,i]=(0,F.useState)(()=>{let n=t(E,``);return n?b(n,{preserveFunction:e}):e?K.activator:{kind:`off`}}),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)([]),l=(0,F.useRef)(null),u=(0,F.useRef)(!1),d=(0,F.useMemo)(()=>e?[K,...G]:G,[e]),f=r.kind!==`off`,h=f&&!e,g=(0,F.useCallback)(e=>{i(e),n(E,A(e)),o(!1),c([])},[]),_=(0,F.useCallback)(()=>{o(!0),c([]),u.current=!1,requestAnimationFrame(()=>{l.current?.focus()})},[]),v=(0,F.useCallback)(()=>{o(!1),c([]),u.current=!1},[]),y=(0,F.useCallback)(t=>{let n=[];return e&&t.getModifierState(`Fn`)&&n.push(`function`),t.ctrlKey&&n.push(`control`),t.altKey&&n.push(`option`),t.shiftKey&&n.push(`shift`),t.metaKey&&n.push(`command`),n},[e]),w=(0,F.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){v();return}let t=y(e),n=e.key;if(n===`Control`||n===`Alt`||n===`Shift`||n===`Meta`||n===`Fn`){c(t.includes(`function`)?S.modifiers:ee(t));return}if(t.includes(`function`)){g(S);return}u.current=!0,g({kind:`key`,label:n.length===1?n.toUpperCase():n,modifiers:t})},[v,y,g]),T=(0,F.useCallback)(e=>{if(!a)return;e.preventDefault(),e.stopPropagation();let t=e.key;if(t===`Control`||t===`Alt`||t===`Shift`||t===`Meta`||t===`Fn`){if(u.current){u.current=!1,c([]);return}y(e).length===0&&s.length>0&&g({kind:`modifierOnly`,modifiers:s})}},[y,a,s,g]);(0,F.useEffect)(()=>{if(!a)return;let e=e=>{l.current&&!l.current.contains(e.target)&&v()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[v,a]);let O=f&&!d.some(e=>C(e.activator,r));return(0,I.jsx)(P,{title:`Push to Talk`,subtitle:`Hold the activation key to dictate text or start a voice conversation.`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,I.jsx)(m,{checked:f,onChange:t=>{t?r.kind===`off`&&g(e?K.activator:x):g({kind:`off`})},label:`Enable Push to Talk`}),f&&(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`span`,{className:q,children:`Activation Key:`}),(0,I.jsxs)(`div`,{ref:l,tabIndex:a?0:-1,onKeyDown:a?w:void 0,onKeyUp:a?T:void 0,className:`flex flex-wrap items-center gap-2 focus:outline-none`,children:[d.map(e=>{let t=C(e.activator,r);return(0,I.jsx)(Z,{label:e.label,selected:t,onClick:()=>g(e.activator)},e.label)}),a?(0,I.jsx)(Z,{label:s.length>0?j(s):`Press any key…`,selected:!0,recording:!0,onClick:v}):(0,I.jsx)(Z,{label:O?te(r):`Custom`,selected:O,onClick:_})]}),h&&(0,I.jsxs)(`div`,{className:`flex items-start gap-1 pt-1 text-body-small-default text-[var(--content-quiet)]`,children:[(0,I.jsx)(p,{className:`mt-0.5 h-3 w-3 shrink-0`}),(0,I.jsx)(`span`,{children:`Push-to-Talk only works while this tab is focused, and browsers may intercept some shortcuts (e.g. Ctrl+T) before the page can see them. For always-on PTT, use the Vellum desktop app.`})]})]})]})})}function Z({label:e,selected:t,recording:n=!1,onClick:r}){return(0,I.jsxs)(`button`,{type:`button`,onClick:r,className:[`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 text-body-medium-lighter transition-colors`,`border-[var(--border-subtle)]`,t?`bg-[var(--surface-active)]`:`bg-[var(--surface-lift)] hover:bg-[var(--surface-hover)]`,n?`animate-pulse`:``].filter(Boolean).join(` `),children:[(0,I.jsx)(`span`,{className:[`inline-block h-2.5 w-2.5 rounded-full border`,t?`border-[var(--primary-base)] bg-[var(--primary-base)]`:`border-[var(--border-element)]`].join(` `)}),(0,I.jsx)(`span`,{className:`text-[var(--content-default)]`,children:e})]})}var ue=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`}];function Q(){let e=T.use.pauseBeforeReplyMs(),t=T.use.setPauseBeforeReplyMs(),n=T.use.interruptSensitivity(),r=T.use.setInterruptSensitivity(),i=e!==null||n!==null;return(0,I.jsx)(P,{title:`Turn taking`,subtitle:`Where your turn ends and the assistant's begins. Applies to hands-free conversations — under push to talk, the key decides.`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,I.jsx)($,{label:`Pause before reply`,description:`How long the assistant waits after you stop speaking before it replies. A longer pause lets you gather your thoughts mid-sentence without being cut off.`,isDefault:e===null,children:(0,I.jsx)(`div`,{className:`max-w-xs`,children:(0,I.jsx)(d,{value:(e??1200)/1e3,onValueChange:e=>{typeof e==`number`&&t(Math.round(e*1e3))},min:500/1e3,max:w/1e3,step:.1,showValue:!0,formatValue:e=>`${(typeof e==`number`?e:e[0]).toFixed(1)}s`,"aria-label":`Pause before reply`})})}),(0,I.jsx)($,{label:`Interrupt sensitivity`,description:`How easily talking over the assistant interrupts it. Lower it if the assistant cuts itself off on background noise or filler words; raise it to interrupt more quickly.`,isDefault:n===null,children:(0,I.jsx)(`div`,{className:`max-w-xs`,children:(0,I.jsx)(f,{items:ue,value:n??`medium`,onChange:r,ariaLabel:`Interrupt sensitivity`})})}),i&&(0,I.jsx)(`div`,{children:(0,I.jsx)(a,{variant:`outlined`,onClick:()=>{t(null),r(null)},children:`Reset to defaults`})})]})})}function $({label:e,description:t,isDefault:n,children:r}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:e}),n&&(0,I.jsx)(`span`,{className:`shrink-0 rounded-full bg-[var(--surface-active)] px-2 py-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`Default`})]}),(0,I.jsx)(`p`,{className:q,children:t}),r]})}export{J as VoicePage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{i as t,l as n,o as r}from"./local-settings-Bx7FsNo5.js";import{t as i}from"./react-BFJW0bSv.js";import{t as a}from"./button-fyWSnR9X.js";import{m as o,n as s,t as c}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as l}from"./jsx-runtime-D3ZM-ToX.js";import{r as u}from"./middleware-Bxr-mmHu.js";import{L as d,z as f}from"./src-ly8ixpHd.js";import{t as p}from"./info-DkhVkzmK.js";import{t as m}from"./toggle-BEPV0rQM.js";import{t as h}from"./modal-D946-vqt.js";import{t as g}from"./dropdown-Dj83uU1o.js";import{t as _}from"./assistant-identity-store-CBR9g2br.js";import{d as v}from"./routes-CAe1h0Db.js";import{C as y,S as ee,b,d as x,f as S,h as C,i as w,m as te,o as T,p as E,s as D,t as O,w as k,x as A,y as j}from"./voice-providers-note-DWD_VjEF.js";import{a as M,n as ne,r as re,t as ie}from"./voice-list-Bza1jX_c.js";import{t as N}from"./use-active-assistant-id-CaI-sL1J.js";import{t as P}from"./detail-card-4afu5RY8.js";var F=e(i(),1),I=l();function L({assistantId:e,open:t,onOpenChange:n}){return(0,I.jsx)(h.Root,{open:t,onOpenChange:n,children:(0,I.jsx)(h.Content,{size:`md`,children:(0,I.jsx)(R,{assistantId:e,onDone:()=>n(!1)})})})}function R({assistantId:e,onDone:t}){let{available:n,currentModel:r,selectModel:i,selecting:o}=M(e);return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(h.Header,{children:[(0,I.jsx)(h.Title,{children:`Voices`}),n&&(0,I.jsx)(h.Description,{children:`Uses Vellum credits, through providers like ElevenLabs and Deepgram.`})]}),(0,I.jsx)(h.Body,{children:(0,I.jsx)(ne,{assistantId:e,filterBySource:!0,value:r,onChange:i})}),(0,I.jsxs)(h.Footer,{className:`items-center justify-between gap-3`,children:[(0,I.jsx)(O,{}),(0,I.jsx)(a,{variant:`primary`,onClick:t,disabled:o,className:`shrink-0`,children:`Done`})]})]})}function z(){let e=N(),{available:t,voices:n,currentModel:r}=M(e),i=n.find(e=>e.model===r)??n[0],[o,s]=(0,F.useState)(!1),l=_.use.name(),u=l?`${l}’s Voice`:`Voice`;return t&&i?(0,I.jsxs)(P,{title:u,subtitle:re,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(ie,{description:i.description,className:`min-w-0 text-body-medium-lighter text-[var(--content-default)]`}),(0,I.jsx)(a,{variant:`outlined`,onClick:()=>s(!0),className:`shrink-0`,children:`Change`})]}),(0,I.jsx)(L,{assistantId:e,open:o,onOpenChange:s})]}):(0,I.jsx)(P,{title:u,children:(0,I.jsxs)(`p`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:[`Your assistant speaks through a provider you configured yourself. Set its voice on`,` `,(0,I.jsx)(c,{to:`${v.settings.ai}#text-to-speech`,className:`text-[var(--primary-base)] hover:underline`,children:`Models & Services`}),`.`]})})}var B=[{prefKey:`showUserTranscript`,label:`Show the words you say`,description:`Live transcription while you speak.`},{prefKey:`showAssistantTranscript`,label:`Show the words the assistant says`,description:`Text alongside the spoken response.`}],V=`We recommend keeping both off to start. It feels more like a real conversation.`;function H(){return(0,I.jsx)(`span`,{className:`shrink-0 rounded-full bg-[var(--surface-active)] px-2 py-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`Recommended off`})}function U({label:e,description:t,showBadge:n,checked:r,onChange:i}){return(0,I.jsxs)(`div`,{className:`flex items-center justify-between gap-3 py-1`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`truncate text-body-medium-lighter text-[var(--content-default)]`,children:e}),n?(0,I.jsx)(H,{}):null]}),t?(0,I.jsx)(`div`,{className:`text-body-small-default text-[var(--content-tertiary)]`,children:t}):null]}),(0,I.jsx)(m,{checked:r,onChange:i,"aria-label":e})]})}function W({showDescription:e=!1,showRecommendedBadge:t=!1}){let n=T.use.showUserTranscript(),r=T.use.showAssistantTranscript(),i=T.use.setShowUserTranscript(),a=T.use.setShowAssistantTranscript(),o={showUserTranscript:{checked:n,onChange:i},showAssistantTranscript:{checked:r,onChange:a}};return(0,I.jsx)(I.Fragment,{children:B.map(n=>{let r=o[n.prefKey];return(0,I.jsx)(U,{label:n.label,description:e?n.description:void 0,showBadge:t,checked:r.checked,onChange:r.onChange},n.prefKey)})})}var G=[{label:`Ctrl`,activator:{kind:`modifierOnly`,modifiers:[`control`]}},{label:`Alt`,activator:{kind:`modifierOnly`,modifiers:[`option`]}},{label:`Ctrl+Shift`,activator:{kind:`modifierOnly`,modifiers:[`control`,`shift`]}}],K={label:`Fn`,activator:S},q=`text-body-small-default text-[var(--content-tertiary)]`;function J(){let[e]=o(),t=e.get(`tab`);return t===`sounds`?(0,I.jsx)(s,{replace:!0,to:v.settings.sounds}):t===`services`?(0,I.jsx)(s,{replace:!0,to:v.settings.ai}):(0,I.jsx)(ae,{})}function ae(){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-8`,children:[(0,I.jsxs)(Y,{heading:`Output`,description:`How your assistant sounds.`,children:[(0,I.jsx)(z,{}),(0,I.jsx)(oe,{})]}),(0,I.jsxs)(Y,{heading:`Input`,description:`How you talk to your assistant.`,children:[(0,I.jsx)(ce,{}),(0,I.jsx)(le,{}),(0,I.jsx)(Q,{})]}),(0,I.jsx)(Y,{heading:`Captions`,children:(0,I.jsx)(se,{})})]})}function oe(){let{available:e}=M(N());return e?(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 px-1 text-body-small-default text-[var(--content-tertiary)]`,children:[(0,I.jsx)(p,{className:`h-3.5 w-3.5 shrink-0 text-[var(--content-quiet)]`}),(0,I.jsx)(`span`,{children:`Want to use your own API key for STT or TTS, or set a custom voice?`}),(0,I.jsxs)(c,{to:`${v.settings.ai}#text-to-speech`,className:`inline-flex items-center gap-1 text-[var(--content-secondary)] underline decoration-[var(--border-element)] underline-offset-2 hover:text-[var(--content-default)]`,children:[`Set it up in Models & Services`,(0,I.jsx)(u,{className:`h-3 w-3`})]})]}):null}function Y({heading:e,description:t,children:n}){return(0,I.jsxs)(`section`,{className:`flex flex-col gap-4`,children:[(0,I.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,I.jsx)(`h2`,{className:`text-label-medium-default uppercase tracking-wide text-[var(--content-tertiary)]`,children:e}),t&&(0,I.jsx)(`p`,{className:`text-body-small-default text-[var(--content-quiet)]`,children:t})]}),n]})}function se(){return(0,I.jsx)(P,{title:`Captions`,subtitle:`Show live text of what you and the assistant say during a voice conversation.`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(W,{showDescription:!0}),(0,I.jsx)(`p`,{className:`${q} pt-1`,children:V})]})})}var X=``;function ce(){let[e,t]=(0,F.useState)([]),[i,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)(()=>k()),l=(0,F.useCallback)(async()=>{if(navigator.mediaDevices?.enumerateDevices)try{let e=(await navigator.mediaDevices.enumerateDevices()).filter(e=>e.kind===`audioinput`);o(e.length>0&&e.every(e=>!e.label)),t(e.filter(e=>e.deviceId!==``&&e.deviceId!==`default`&&e.deviceId!==`communications`))}catch{t([]),o(!1)}},[]),u=(0,F.useCallback)(async()=>{try{let e=await navigator.mediaDevices.getUserMedia({audio:!0});for(let t of e.getTracks())t.stop()}catch{}l()},[l]);(0,F.useEffect)(()=>{l();let e=navigator.mediaDevices;if(!e?.addEventListener)return;let t=()=>void l();return e.addEventListener(`devicechange`,t),()=>e.removeEventListener(`devicechange`,t)},[l]);let d=(0,F.useMemo)(()=>[{value:X,label:`System Default`},...e.map((e,t)=>({value:e.deviceId,label:e.label||`Microphone ${t+1}`}))],[e]),f=(0,F.useCallback)(e=>{c(e),e===X?r(y):n(y,e)},[]);return(0,I.jsx)(P,{title:`Microphone`,subtitle:`Which input device is used for dictation and voice conversations.`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,I.jsx)(`div`,{className:`max-w-xs`,children:(0,I.jsx)(g,{options:d,value:d.some(e=>e.value===s)?s:X,onChange:f,"aria-label":`Microphone`})}),i&&(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,I.jsx)(a,{variant:`outlined`,onClick:u,children:`Allow Microphone Access`}),(0,I.jsx)(`span`,{className:q,children:`Grant microphone access to list your available input devices.`})]})]})})}function le(){let e=D(),[r,i]=(0,F.useState)(()=>{let n=t(E,``);return n?b(n,{preserveFunction:e}):e?K.activator:{kind:`off`}}),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)([]),l=(0,F.useRef)(null),u=(0,F.useRef)(!1),d=(0,F.useMemo)(()=>e?[K,...G]:G,[e]),f=r.kind!==`off`,h=f&&!e,g=(0,F.useCallback)(e=>{i(e),n(E,A(e)),o(!1),c([])},[]),_=(0,F.useCallback)(()=>{o(!0),c([]),u.current=!1,requestAnimationFrame(()=>{l.current?.focus()})},[]),v=(0,F.useCallback)(()=>{o(!1),c([]),u.current=!1},[]),y=(0,F.useCallback)(t=>{let n=[];return e&&t.getModifierState(`Fn`)&&n.push(`function`),t.ctrlKey&&n.push(`control`),t.altKey&&n.push(`option`),t.shiftKey&&n.push(`shift`),t.metaKey&&n.push(`command`),n},[e]),w=(0,F.useCallback)(e=>{if(e.preventDefault(),e.stopPropagation(),e.key===`Escape`){v();return}let t=y(e),n=e.key;if(n===`Control`||n===`Alt`||n===`Shift`||n===`Meta`||n===`Fn`){c(t.includes(`function`)?S.modifiers:ee(t));return}if(t.includes(`function`)){g(S);return}u.current=!0,g({kind:`key`,label:n.length===1?n.toUpperCase():n,modifiers:t})},[v,y,g]),T=(0,F.useCallback)(e=>{if(!a)return;e.preventDefault(),e.stopPropagation();let t=e.key;if(t===`Control`||t===`Alt`||t===`Shift`||t===`Meta`||t===`Fn`){if(u.current){u.current=!1,c([]);return}y(e).length===0&&s.length>0&&g({kind:`modifierOnly`,modifiers:s})}},[y,a,s,g]);(0,F.useEffect)(()=>{if(!a)return;let e=e=>{l.current&&!l.current.contains(e.target)&&v()};return window.addEventListener(`mousedown`,e),()=>window.removeEventListener(`mousedown`,e)},[v,a]);let O=f&&!d.some(e=>C(e.activator,r));return(0,I.jsx)(P,{title:`Push to Talk`,subtitle:`Hold the activation key to dictate text or start a voice conversation.`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,I.jsx)(m,{checked:f,onChange:t=>{t?r.kind===`off`&&g(e?K.activator:x):g({kind:`off`})},label:`Enable Push to Talk`}),f&&(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsx)(`span`,{className:q,children:`Activation Key:`}),(0,I.jsxs)(`div`,{ref:l,tabIndex:a?0:-1,onKeyDown:a?w:void 0,onKeyUp:a?T:void 0,className:`flex flex-wrap items-center gap-2 focus:outline-none`,children:[d.map(e=>{let t=C(e.activator,r);return(0,I.jsx)(Z,{label:e.label,selected:t,onClick:()=>g(e.activator)},e.label)}),a?(0,I.jsx)(Z,{label:s.length>0?j(s):`Press any key…`,selected:!0,recording:!0,onClick:v}):(0,I.jsx)(Z,{label:O?te(r):`Custom`,selected:O,onClick:_})]}),h&&(0,I.jsxs)(`div`,{className:`flex items-start gap-1 pt-1 text-body-small-default text-[var(--content-quiet)]`,children:[(0,I.jsx)(p,{className:`mt-0.5 h-3 w-3 shrink-0`}),(0,I.jsx)(`span`,{children:`Push-to-Talk only works while this tab is focused, and browsers may intercept some shortcuts (e.g. Ctrl+T) before the page can see them. For always-on PTT, use the Vellum desktop app.`})]})]})]})})}function Z({label:e,selected:t,recording:n=!1,onClick:r}){return(0,I.jsxs)(`button`,{type:`button`,onClick:r,className:[`inline-flex items-center gap-2 rounded-lg border px-3 py-1.5 text-body-medium-lighter transition-colors`,`border-[var(--border-subtle)]`,t?`bg-[var(--surface-active)]`:`bg-[var(--surface-lift)] hover:bg-[var(--surface-hover)]`,n?`animate-pulse`:``].filter(Boolean).join(` `),children:[(0,I.jsx)(`span`,{className:[`inline-block h-2.5 w-2.5 rounded-full border`,t?`border-[var(--primary-base)] bg-[var(--primary-base)]`:`border-[var(--border-element)]`].join(` `)}),(0,I.jsx)(`span`,{className:`text-[var(--content-default)]`,children:e})]})}var ue=[{value:`low`,label:`Low`},{value:`medium`,label:`Medium`},{value:`high`,label:`High`}];function Q(){let e=T.use.pauseBeforeReplyMs(),t=T.use.setPauseBeforeReplyMs(),n=T.use.interruptSensitivity(),r=T.use.setInterruptSensitivity(),i=e!==null||n!==null;return(0,I.jsx)(P,{title:`Turn taking`,subtitle:`Where your turn ends and the assistant's begins. Applies to hands-free conversations — under push to talk, the key decides.`,children:(0,I.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,I.jsx)($,{label:`Pause before reply`,description:`How long the assistant waits after you stop speaking before it replies. A longer pause lets you gather your thoughts mid-sentence without being cut off.`,isDefault:e===null,children:(0,I.jsx)(`div`,{className:`max-w-xs`,children:(0,I.jsx)(d,{value:(e??1200)/1e3,onValueChange:e=>{typeof e==`number`&&t(Math.round(e*1e3))},min:500/1e3,max:w/1e3,step:.1,showValue:!0,formatValue:e=>`${(typeof e==`number`?e:e[0]).toFixed(1)}s`,"aria-label":`Pause before reply`})})}),(0,I.jsx)($,{label:`Interrupt sensitivity`,description:`How easily talking over the assistant interrupts it. Lower it if the assistant cuts itself off on background noise or filler words; raise it to interrupt more quickly.`,isDefault:n===null,children:(0,I.jsx)(`div`,{className:`max-w-xs`,children:(0,I.jsx)(f,{items:ue,value:n??`medium`,onChange:r,ariaLabel:`Interrupt sensitivity`})})}),i&&(0,I.jsx)(`div`,{children:(0,I.jsx)(a,{variant:`outlined`,onClick:()=>{t(null),r(null)},children:`Reset to defaults`})})]})})}function $({label:e,description:t,isDefault:n,children:r}){return(0,I.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`text-body-medium-lighter text-[var(--content-default)]`,children:e}),n&&(0,I.jsx)(`span`,{className:`shrink-0 rounded-full bg-[var(--surface-active)] px-2 py-0.5 text-body-small-default text-[var(--content-tertiary)]`,children:`Default`})]}),(0,I.jsx)(`p`,{className:q,children:t}),r]})}export{J as VoicePage};
@@ -1 +1 @@
1
- import{t as e}from"./button-fyWSnR9X.js";import{u as t}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as n}from"./jsx-runtime-D3ZM-ToX.js";import{u as r}from"./local-mode-BR8wpdXp.js";import{d as i}from"./routes-CAe1h0Db.js";import{t as a}from"./use-onboarding-login-CJ7p0ITq.js";import{t as o}from"./onboarding-layout--37tB9YP.js";var s=n();function c(){let n=t(),{loading:c,error:l,login:u,cancel:d}=a();return(0,s.jsx)(o,{children:(0,s.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-xl flex-col items-center px-6 pb-40 text-[var(--content-default)]`,children:(0,s.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center`,children:[(0,s.jsx)(`h1`,{className:`text-5xl font-normal tracking-tight`,style:{fontFamily:`var(--font-serif)`,animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Welcome to Vellum`}),(0,s.jsx)(`p`,{className:`mt-3 text-body-medium-lighter text-[var(--content-tertiary)]`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Your own personal intelligence is just a step away.`}),l&&(0,s.jsx)(`p`,{className:`mt-4 text-body-small-default text-[var(--system-negative-strong)]`,children:l}),(0,s.jsxs)(`div`,{className:`mt-15 flex w-full max-w-sm flex-col gap-3`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[(0,s.jsx)(e,{variant:`primary`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:c?d:()=>void u(),children:c?`Cancel`:`Log In`}),(0,s.jsx)(e,{variant:`ghost`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:()=>{c&&d(),r()?n(i.selectAssistant):n(i.onboarding.hosting)},children:`Continue without account`})]})]})})})}export{c as WelcomeScreen};
1
+ import{t as e}from"./button-fyWSnR9X.js";import{u as t}from"./chunk-5KNZJZUH-Bsoom5--.js";import{t as n}from"./jsx-runtime-D3ZM-ToX.js";import{u as r}from"./local-mode-BR8wpdXp.js";import{d as i}from"./routes-CAe1h0Db.js";import{t as a}from"./use-onboarding-login-D5l9Xmkv.js";import{t as o}from"./onboarding-layout--37tB9YP.js";var s=n();function c(){let n=t(),{loading:c,error:l,login:u,cancel:d}=a();return(0,s.jsx)(o,{children:(0,s.jsx)(`div`,{className:`mx-auto flex min-h-screen w-full max-w-xl flex-col items-center px-6 pb-40 text-[var(--content-default)]`,children:(0,s.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center`,children:[(0,s.jsx)(`h1`,{className:`text-5xl font-normal tracking-tight`,style:{fontFamily:`var(--font-serif)`,animation:`fadeInUp 0.5s ease-out 0.1s both`},children:`Welcome to Vellum`}),(0,s.jsx)(`p`,{className:`mt-3 text-body-medium-lighter text-[var(--content-tertiary)]`,style:{animation:`fadeInUp 0.5s ease-out 0.3s both`},children:`Your own personal intelligence is just a step away.`}),l&&(0,s.jsx)(`p`,{className:`mt-4 text-body-small-default text-[var(--system-negative-strong)]`,children:l}),(0,s.jsxs)(`div`,{className:`mt-15 flex w-full max-w-sm flex-col gap-3`,style:{animation:`fadeInUp 0.5s ease-out 0.5s both`},children:[(0,s.jsx)(e,{variant:`primary`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:c?d:()=>void u(),children:c?`Cancel`:`Log In`}),(0,s.jsx)(e,{variant:`ghost`,size:`regular`,fullWidth:!0,className:`h-11 text-base`,onClick:()=>{c&&d(),r()?n(i.selectAssistant):n(i.onboarding.hosting)},children:`Continue without account`})]})]})})})}export{c as WelcomeScreen};
@@ -1 +1 @@
1
- import{t as e}from"./capture-error-DIcLdUu5.js";import{n as t,t as n}from"./create-selectors-CEbfsat6.js";import{p as r}from"./api-DZ1FASA0.js";import{n as i}from"./resolved-assistants-store-BymuLyDm.js";import{Lr as a,Rr as o,zr as s}from"./sdk.gen-qwmaWHuE.js";import{t as c}from"./by-tool-use-id-index-CUFuQqHz.js";import{t as l}from"./workflow-status-D0bBEpGp.js";async function u(t,n){try{let{data:i,response:a}=await s({path:{assistant_id:t,id:n},throwOnError:!1});if(!a||!a.ok||!i)return null;let o=r.safeParse(i);return o.success?o.data:(e(o.error,{context:`fetchWorkflowJournal`}),null)}catch(t){return e(t,{context:`fetchWorkflowJournal`}),null}}async function d(t,n){try{let{data:e,response:r}=await o({path:{assistant_id:t,id:n},throwOnError:!1});return r?.ok&&e?e:r?.status===404?`not_found`:null}catch(t){return e(t,{context:`fetchWorkflowRun`}),null}}var f={byId:{},orderedIds:[],byToolUseId:new Map,fetchedAt:new Map,hydratedRunIds:new Set,notFoundRunIds:new Set,hydrationFailedRunIds:new Set,generation:0};function p(e,t){return{runId:e,status:`running`,agentsSpawned:0,inputTokens:0,outputTokens:0,startedAt:t,leaves:new Map}}function m(e){let t=e;for(let[n,r]of e)r.status===`running`&&(t===e&&(t=new Map(e)),t.set(n,{...r,status:`cancelled`}));return t}function h(e,t){return`${t}:${l(e)?`live`:`final`}`}function g(e){return e===`failed`?`failed`:e===`running`?`running`:`completed`}function _(e){return e===`interrupted`?`running`:e}var v=n(t()((e,t)=>({...f,startRun:n=>{let{byId:r,orderedIds:i,byToolUseId:a}=t(),o=r[n.runId];if(o){let t=o.label??n.label,i=o.toolUseId??n.toolUseId,s=t!==o.label,l=i!==o.toolUseId;if(!s&&!l)return;let u={...o,label:t,toolUseId:i},d=l?c(a,n.toolUseId,n.runId):a;e({byId:{...r,[n.runId]:u},byToolUseId:d});return}let s={...p(n.runId,n.timestamp),label:n.label,toolUseId:n.toolUseId},l=c(a,n.toolUseId,n.runId);e({byId:{...r,[n.runId]:s},orderedIds:[...i,n.runId],byToolUseId:l})},applyProgress:n=>{let{byId:r,orderedIds:i}=t(),a=r[n.runId],o=a??p(n.runId,Date.now()),s={...o,status:_(o.status),phase:n.phase??o.phase,message:n.message??o.message,agentsSpawned:n.agentsSpawned??o.agentsSpawned,label:o.label??n.label};e({byId:{...r,[n.runId]:s},orderedIds:a?i:[...i,n.runId]})},leafStarted:n=>{let{byId:r,orderedIds:i}=t(),a=r[n.runId],o=a??p(n.runId,Date.now()),s=_(o.status),c=o.leaves.get(n.seq);if(c&&c.status!==`running`){s!==o.status&&e({byId:{...r,[n.runId]:{...o,status:s}}});return}let l={seq:n.seq,status:`running`,label:n.label??c?.label,promptSummary:n.promptSummary??c?.promptSummary},u=new Map(o.leaves).set(n.seq,l),d=Math.max(o.agentsSpawned,u.size);e({byId:{...r,[n.runId]:{...o,status:s,agentsSpawned:d,leaves:u}},orderedIds:a?i:[...i,n.runId]})},leafFinished:n=>{let{byId:r,orderedIds:i}=t(),a=r[n.runId],o=a??p(n.runId,Date.now()),s=o.leaves.get(n.seq),c={seq:n.seq,status:n.status,label:n.label??s?.label,promptSummary:s?.promptSummary,inputTokens:n.inputTokens??s?.inputTokens,outputTokens:n.outputTokens??s?.outputTokens,resultSummary:n.resultSummary??s?.resultSummary};if(s&&s.status===c.status&&s.label===c.label&&s.inputTokens===c.inputTokens&&s.outputTokens===c.outputTokens&&s.resultSummary===c.resultSummary)return;let l=new Map(o.leaves).set(n.seq,c),u=0,d=0;for(let e of l.values())u+=e.inputTokens??0,d+=e.outputTokens??0;e({byId:{...r,[n.runId]:{...o,inputTokens:Math.max(o.inputTokens,u),outputTokens:Math.max(o.outputTokens,d),leaves:l}},orderedIds:a?i:[...i,n.runId]})},completeRun:n=>{let{byId:r,orderedIds:i}=t(),a=r[n.runId],o=a??p(n.runId,Date.now()),s=l(n.status)?o.leaves:m(o.leaves),c={...o,status:n.status,agentsSpawned:n.agentsSpawned,inputTokens:n.inputTokens,outputTokens:n.outputTokens,summary:n.summary??o.summary,leaves:s};e({byId:{...r,[n.runId]:c},orderedIds:a?i:[...i,n.runId]})},backfillFromJournal:(n,r)=>{let{byId:i,orderedIds:a}=t(),o=i[n],s=o??p(n,Date.now()),c=!1,u=s.leaves;for(let e of r.leaves){let t=s.leaves.get(e.seq),n=g(e.status);if(!t){c||=(u=new Map(s.leaves),!0),u.set(e.seq,{seq:e.seq,status:n,label:e.label,promptSummary:e.promptSummary,resultSummary:e.resultSummary,inputTokens:e.inputTokens,outputTokens:e.outputTokens});continue}(t.status===`running`||t.status===`cancelled`)&&n!==`running`&&(c||=(u=new Map(s.leaves),!0),u.set(e.seq,{...t,status:n,label:t.label??e.label,promptSummary:t.promptSummary??e.promptSummary,resultSummary:t.resultSummary??e.resultSummary,inputTokens:t.inputTokens??e.inputTokens,outputTokens:t.outputTokens??e.outputTokens}))}let d=l(s.status)?r.status??s.status:s.status,f=l(s.status)&&!l(d)?m(u):u,h={...s,status:d,agentsSpawned:Math.max(s.agentsSpawned,r.agentsSpawned??s.agentsSpawned),inputTokens:Math.max(s.inputTokens,r.inputTokens??s.inputTokens),outputTokens:Math.max(s.outputTokens,r.outputTokens??s.outputTokens),phase:r.phase??s.phase,leaves:f};e({byId:{...i,[n]:h},orderedIds:o?a:[...a,n]})},fetchJournalIfNeeded:async(n,r)=>{let{byId:i,fetchedAt:a}=t(),o=i[r];if(!o)return;let s=h(o.status,r),c=a.get(s);if(c!==void 0&&c>=o.startedAt)return;let l=new Map(a);l.set(s,o.startedAt),e({fetchedAt:l});let d=t().generation,f=await u(n,r);if(!f){let n=new Map(t().fetchedAt);n.delete(s),e({fetchedAt:n});return}t().generation===d&&t().backfillFromJournal(r,f)},hydrateRunIfNeeded:async(n,r)=>{let{byId:i,hydratedRunIds:a}=t();if(i[r]||a.has(r))return;e({hydratedRunIds:new Set(a).add(r)});let o=t().generation,s=await d(n,r);if(t().generation===o){if(s===`not_found`){e({notFoundRunIds:new Set(t().notFoundRunIds).add(r)});return}if(s===null){let n=new Set(t().hydratedRunIds);n.delete(r),e({hydratedRunIds:n,hydrationFailedRunIds:new Set(t().hydrationFailedRunIds).add(r)});return}t().startRun({runId:r,label:s.name??void 0,timestamp:Date.now()}),l(s.status)?t().applyProgress({runId:r,agentsSpawned:s.agentsSpawned}):t().completeRun({runId:r,status:s.status,agentsSpawned:s.agentsSpawned,inputTokens:s.inputTokens,outputTokens:s.outputTokens}),await t().fetchJournalIfNeeded(n,r)}},abortRun:async e=>{let t=i.getState().activeAssistantId;if(t)try{await a({path:{assistant_id:t,id:e},throwOnError:!0})}catch{}},reset:()=>e({byId:{},orderedIds:[],byToolUseId:new Map,fetchedAt:new Map,hydratedRunIds:new Set,notFoundRunIds:new Set,hydrationFailedRunIds:new Set,generation:t().generation+1})})));export{v as t};
1
+ import{t as e}from"./capture-error-DIcLdUu5.js";import{n as t,t as n}from"./create-selectors-CEbfsat6.js";import{p as r}from"./api-nvrU4YoP.js";import{n as i}from"./resolved-assistants-store-BymuLyDm.js";import{Lr as a,Rr as o,zr as s}from"./sdk.gen-qwmaWHuE.js";import{t as c}from"./by-tool-use-id-index-CUFuQqHz.js";import{t as l}from"./workflow-status-D0bBEpGp.js";async function u(t,n){try{let{data:i,response:a}=await s({path:{assistant_id:t,id:n},throwOnError:!1});if(!a||!a.ok||!i)return null;let o=r.safeParse(i);return o.success?o.data:(e(o.error,{context:`fetchWorkflowJournal`}),null)}catch(t){return e(t,{context:`fetchWorkflowJournal`}),null}}async function d(t,n){try{let{data:e,response:r}=await o({path:{assistant_id:t,id:n},throwOnError:!1});return r?.ok&&e?e:r?.status===404?`not_found`:null}catch(t){return e(t,{context:`fetchWorkflowRun`}),null}}var f={byId:{},orderedIds:[],byToolUseId:new Map,fetchedAt:new Map,hydratedRunIds:new Set,notFoundRunIds:new Set,hydrationFailedRunIds:new Set,generation:0};function p(e,t){return{runId:e,status:`running`,agentsSpawned:0,inputTokens:0,outputTokens:0,startedAt:t,leaves:new Map}}function m(e){let t=e;for(let[n,r]of e)r.status===`running`&&(t===e&&(t=new Map(e)),t.set(n,{...r,status:`cancelled`}));return t}function h(e,t){return`${t}:${l(e)?`live`:`final`}`}function g(e){return e===`failed`?`failed`:e===`running`?`running`:`completed`}function _(e){return e===`interrupted`?`running`:e}var v=n(t()((e,t)=>({...f,startRun:n=>{let{byId:r,orderedIds:i,byToolUseId:a}=t(),o=r[n.runId];if(o){let t=o.label??n.label,i=o.toolUseId??n.toolUseId,s=t!==o.label,l=i!==o.toolUseId;if(!s&&!l)return;let u={...o,label:t,toolUseId:i},d=l?c(a,n.toolUseId,n.runId):a;e({byId:{...r,[n.runId]:u},byToolUseId:d});return}let s={...p(n.runId,n.timestamp),label:n.label,toolUseId:n.toolUseId},l=c(a,n.toolUseId,n.runId);e({byId:{...r,[n.runId]:s},orderedIds:[...i,n.runId],byToolUseId:l})},applyProgress:n=>{let{byId:r,orderedIds:i}=t(),a=r[n.runId],o=a??p(n.runId,Date.now()),s={...o,status:_(o.status),phase:n.phase??o.phase,message:n.message??o.message,agentsSpawned:n.agentsSpawned??o.agentsSpawned,label:o.label??n.label};e({byId:{...r,[n.runId]:s},orderedIds:a?i:[...i,n.runId]})},leafStarted:n=>{let{byId:r,orderedIds:i}=t(),a=r[n.runId],o=a??p(n.runId,Date.now()),s=_(o.status),c=o.leaves.get(n.seq);if(c&&c.status!==`running`){s!==o.status&&e({byId:{...r,[n.runId]:{...o,status:s}}});return}let l={seq:n.seq,status:`running`,label:n.label??c?.label,promptSummary:n.promptSummary??c?.promptSummary},u=new Map(o.leaves).set(n.seq,l),d=Math.max(o.agentsSpawned,u.size);e({byId:{...r,[n.runId]:{...o,status:s,agentsSpawned:d,leaves:u}},orderedIds:a?i:[...i,n.runId]})},leafFinished:n=>{let{byId:r,orderedIds:i}=t(),a=r[n.runId],o=a??p(n.runId,Date.now()),s=o.leaves.get(n.seq),c={seq:n.seq,status:n.status,label:n.label??s?.label,promptSummary:s?.promptSummary,inputTokens:n.inputTokens??s?.inputTokens,outputTokens:n.outputTokens??s?.outputTokens,resultSummary:n.resultSummary??s?.resultSummary};if(s&&s.status===c.status&&s.label===c.label&&s.inputTokens===c.inputTokens&&s.outputTokens===c.outputTokens&&s.resultSummary===c.resultSummary)return;let l=new Map(o.leaves).set(n.seq,c),u=0,d=0;for(let e of l.values())u+=e.inputTokens??0,d+=e.outputTokens??0;e({byId:{...r,[n.runId]:{...o,inputTokens:Math.max(o.inputTokens,u),outputTokens:Math.max(o.outputTokens,d),leaves:l}},orderedIds:a?i:[...i,n.runId]})},completeRun:n=>{let{byId:r,orderedIds:i}=t(),a=r[n.runId],o=a??p(n.runId,Date.now()),s=l(n.status)?o.leaves:m(o.leaves),c={...o,status:n.status,agentsSpawned:n.agentsSpawned,inputTokens:n.inputTokens,outputTokens:n.outputTokens,summary:n.summary??o.summary,leaves:s};e({byId:{...r,[n.runId]:c},orderedIds:a?i:[...i,n.runId]})},backfillFromJournal:(n,r)=>{let{byId:i,orderedIds:a}=t(),o=i[n],s=o??p(n,Date.now()),c=!1,u=s.leaves;for(let e of r.leaves){let t=s.leaves.get(e.seq),n=g(e.status);if(!t){c||=(u=new Map(s.leaves),!0),u.set(e.seq,{seq:e.seq,status:n,label:e.label,promptSummary:e.promptSummary,resultSummary:e.resultSummary,inputTokens:e.inputTokens,outputTokens:e.outputTokens});continue}(t.status===`running`||t.status===`cancelled`)&&n!==`running`&&(c||=(u=new Map(s.leaves),!0),u.set(e.seq,{...t,status:n,label:t.label??e.label,promptSummary:t.promptSummary??e.promptSummary,resultSummary:t.resultSummary??e.resultSummary,inputTokens:t.inputTokens??e.inputTokens,outputTokens:t.outputTokens??e.outputTokens}))}let d=l(s.status)?r.status??s.status:s.status,f=l(s.status)&&!l(d)?m(u):u,h={...s,status:d,agentsSpawned:Math.max(s.agentsSpawned,r.agentsSpawned??s.agentsSpawned),inputTokens:Math.max(s.inputTokens,r.inputTokens??s.inputTokens),outputTokens:Math.max(s.outputTokens,r.outputTokens??s.outputTokens),phase:r.phase??s.phase,leaves:f};e({byId:{...i,[n]:h},orderedIds:o?a:[...a,n]})},fetchJournalIfNeeded:async(n,r)=>{let{byId:i,fetchedAt:a}=t(),o=i[r];if(!o)return;let s=h(o.status,r),c=a.get(s);if(c!==void 0&&c>=o.startedAt)return;let l=new Map(a);l.set(s,o.startedAt),e({fetchedAt:l});let d=t().generation,f=await u(n,r);if(!f){let n=new Map(t().fetchedAt);n.delete(s),e({fetchedAt:n});return}t().generation===d&&t().backfillFromJournal(r,f)},hydrateRunIfNeeded:async(n,r)=>{let{byId:i,hydratedRunIds:a}=t();if(i[r]||a.has(r))return;e({hydratedRunIds:new Set(a).add(r)});let o=t().generation,s=await d(n,r);if(t().generation===o){if(s===`not_found`){e({notFoundRunIds:new Set(t().notFoundRunIds).add(r)});return}if(s===null){let n=new Set(t().hydratedRunIds);n.delete(r),e({hydratedRunIds:n,hydrationFailedRunIds:new Set(t().hydrationFailedRunIds).add(r)});return}t().startRun({runId:r,label:s.name??void 0,timestamp:Date.now()}),l(s.status)?t().applyProgress({runId:r,agentsSpawned:s.agentsSpawned}):t().completeRun({runId:r,status:s.status,agentsSpawned:s.agentsSpawned,inputTokens:s.inputTokens,outputTokens:s.outputTokens}),await t().fetchJournalIfNeeded(n,r)}},abortRun:async e=>{let t=i.getState().activeAssistantId;if(t)try{await a({path:{assistant_id:t,id:e},throwOnError:!0})}catch{}},reset:()=>e({byId:{},orderedIds:[],byToolUseId:new Map,fetchedAt:new Map,hydratedRunIds:new Set,notFoundRunIds:new Set,hydrationFailedRunIds:new Set,generation:t().generation+1})})));export{v as t};
@@ -1 +1 @@
1
- import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-fyWSnR9X.js";import{m as r}from"./chunk-5KNZJZUH-Bsoom5--.js";import{n as i}from"./QueryClientProvider-CMu7CkQU.js";import{t as a}from"./useQuery-Bz-fbQ-m.js";import{t as o}from"./useMutation-CXGTrp4W.js";import{t as s}from"./jsx-runtime-D3ZM-ToX.js";import{t as c}from"./queryOptions-CMSBCFOf.js";import{t as l}from"./createLucideIcon-CAM1RhH8.js";import{t as u}from"./chevron-down-BNidRDh1.js";import{t as d}from"./chevron-right-CANAtgGn.js";import{t as f}from"./menu-D7gzADvH.js";import{F as p,I as m,N as h}from"./src-ly8ixpHd.js";import{t as g}from"./download-Cnb8zZrK.js";import{t as _}from"./eye-off-DQ4xakzN.js";import{t as v}from"./eye-B_jBDDRn.js";import{t as y}from"./file-plus-DjC7wnGp.js";import{t as b}from"./file-text-CwGsMgaa.js";import{t as x}from"./file-DOePafLU.js";import{t as S}from"./folder-open-BTlvhHNO.js";import{n as C,r as w,t as T}from"./video-Dtwi0MD9.js";import{t as E}from"./folder-_l8GIyQp.js";import{t as D}from"./loader-circle-DWWXcfTQ.js";import{t as O}from"./pencil-Cm5DdeRM.js";import{t as k}from"./plus-EJu6s6xR.js";import{t as A}from"./search-DL-2uX3K.js";import{t as j}from"./trash-2-DfVRfykB.js";import{t as M}from"./x-D4O9yIS7.js";import{t as N}from"./input-B_e9sgY6.js";import{t as P}from"./modal-D946-vqt.js";import{t as ee}from"./confirm-dialog-Ro8nszbc.js";import{n as F,t as I}from"./file-markdown-DQoYQOq5.js";import{Br as te,Hr as L,Kr as R,Ur as ne,Vr as z,Wr as re,qr as B}from"./sdk.gen-qwmaWHuE.js";import{n as V}from"./use-is-mobile-MmHo-OM6.js";import{n as H,r as U,t as ie}from"./workspace-tree-query-CUw_yH2P.js";import{t as W}from"./use-active-assistant-id-CaI-sL1J.js";import{n as ae,t as oe}from"./mobile-sidebar-drawer-DhERtMv3.js";import{i as G,n as se,r as K,t as q}from"./file-editor-DIHQt7wk.js";import{t as J}from"./format-file-size-B5EMFtmw.js";var ce=l(`arrow-down-a-z`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M20 8h-5`,key:`1vsyxs`}],[`path`,{d:`M15 10V6.5a2.5 2.5 0 0 1 5 0V10`,key:`ag13bf`}],[`path`,{d:`M15 14h5l-5 6h5`,key:`ur5jdg`}]]),le=l(`arrow-down-wide-narrow`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M11 4h10`,key:`1w87gc`}],[`path`,{d:`M11 8h7`,key:`djye34`}],[`path`,{d:`M11 12h4`,key:`q8tih4`}]]),Y=e(t(),1);function ue(e){if(!e)return``;let t=e.indexOf(`;`);return(t===-1?e:e.slice(0,t)).trim()}function de(e,t){return ue(t)===`application/json`?!0:(e??``).toLowerCase().endsWith(`.json`)}function fe(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function X(e){return e.split(`/`).some(e=>e.startsWith(`.`))}var Z=s();function pe(e){let{assistantId:t,path:n,name:r,showHidden:i}=e,[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1);return{isDownloading:a,error:s,download:(0,Y.useCallback)(async()=>{c(!1),o(!0);try{await U({assistantId:t,path:n,filename:r,showHidden:i})}catch{c(!0)}finally{o(!1)}},[t,n,r,i])}}function me({assistantId:e,path:t,name:r,showHidden:i}){let{isDownloading:a,error:o,download:s}=pe({assistantId:e,path:t,name:r,showHidden:i});return(0,Z.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:a?(0,Z.jsx)(D,{className:`animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(g,{"aria-hidden":!0}),onClick:()=>void s(),disabled:a,"aria-label":`Download ${r}`,tooltip:o?`Download failed. Try again.`:`Download`})}function he(e){return c({queryFn:async()=>{let{data:t,error:n}=await L({path:e.path,query:{path:e.query.path,...e.query.showHidden?{showHidden:`true`}:{}}});if(n)throw n;return t},queryKey:[`assistantsWorkspaceFileRetrieve`,e]})}function ge({mimeType:e}){let t=e.indexOf(`;`),n=(t===-1?e:e.slice(0,t)).trim(),r=b;return n.startsWith(`image/`)?r=C:n.startsWith(`video/`)?r=T:!n.startsWith(`text/`)&&n!==`application/json`&&n!==`application/octet-stream`&&(r=x),(0,Z.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 10%, transparent)`},children:(0,Z.jsx)(r,{className:`h-3.5 w-3.5`,style:{color:`var(--content-default)`}})})}function _e({viewMode:e,onChange:t}){return(0,Z.jsx)(`div`,{className:`inline-flex rounded-md p-0.5`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 6%, transparent)`},children:[`preview`,`source`].map(r=>{let i=e===r;return(0,Z.jsx)(n,{variant:`ghost`,onClick:()=>t(r),className:`h-auto rounded border-0 px-2.5 py-1 text-body-small-default hover:bg-transparent`,style:{backgroundColor:i?`var(--surface-lift)`:`transparent`,color:i?`var(--content-default)`:`var(--content-tertiary)`,boxShadow:i?`0 1px 2px rgba(0,0,0,0.15)`:void 0},children:r===`preview`?`Preview`:`Source`},r)})})}function Q({name:e,mimeType:t,size:n,rightContent:r}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(ge,{mimeType:t}),(0,Z.jsx)(`span`,{className:`truncate text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),n!=null&&(0,Z.jsx)(`span`,{className:`shrink-0 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:J(n)})]}),r]})}function ve({assistantId:e,path:t,mimeType:n,showHidden:r}){let{data:i,isLoading:o}=a({queryFn:async()=>{let n=await z({path:{assistant_id:e},query:{path:t,...r?{showHidden:`true`}:{}},parseAs:`blob`});if(n.error)throw n.error;return n.data},queryKey:[`assistantsWorkspaceFileContentRetrieve`,{assistantId:e,path:t,showHidden:r}],enabled:!!t}),[s,c]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{if(!i)return;let e=URL.createObjectURL(i);return c(e),()=>{URL.revokeObjectURL(e),c(null)}},[i]),o?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Z.jsx)(D,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):s?n.startsWith(`image/`)?(0,Z.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,Z.jsx)(`img`,{src:s,alt:t.split(`/`).pop()??`image`,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n.startsWith(`video/`)?(0,Z.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,Z.jsx)(`video`,{src:s,controls:!0,className:`max-h-[70vh] max-w-full rounded`})}):null:null}function ye({assistantId:e,path:t,name:r,mimeType:i,size:a,modifiedAt:o,showHidden:s}){let{isDownloading:c,error:l,download:u}=pe({assistantId:e,path:t,name:r,showHidden:s});return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:r,mimeType:i,size:a}),(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,Z.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg border p-6 text-center`,style:{borderColor:`var(--border-base)`,backgroundColor:`var(--surface-lift)`},children:[(0,Z.jsx)(x,{className:`mx-auto h-10 w-10`,style:{color:`var(--content-tertiary)`}}),(0,Z.jsx)(`p`,{className:`mt-3 text-body-medium-default`,style:{color:`var(--content-default)`},children:r}),(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:i}),(0,Z.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:J(a,`Unknown size`)}),o&&(0,Z.jsxs)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:[`Modified: `,new Date(o).toLocaleString()]})]}),(0,Z.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:c?(0,Z.jsx)(D,{className:`animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(g,{"aria-hidden":!0}),onClick:u,disabled:c,"aria-label":`Download ${r}`,className:`mt-4`,children:c?`Downloading…`:`Download`}),l&&(0,Z.jsx)(`p`,{className:`mt-2 text-body-small-default`,style:{color:`var(--system-error)`},children:`Download failed. Try again.`})]})})]})}function be({assistantId:e,selectedPath:t,showHidden:r,viewMode:s,onChangeViewMode:c,onBrowse:l,pathRename:u,pathDelete:d}){let f=i(),{data:p,isLoading:m}=a({...he({path:{assistant_id:e},query:{path:t??``,showHidden:r}}),enabled:!!t}),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!u)return;let{from:e,to:t}=u,n=n=>n===e?t:n.startsWith(`${e}/`)?t+n.slice(e.length):n;g(e=>e==null?e:n(e)),v(e=>e==null?e:{...e,path:n(e.path)})},[u]),(0,Y.useEffect)(()=>{if(!d)return;let{path:e}=d,t=t=>t===e||t.startsWith(`${e}/`);g(e=>e!=null&&t(e)?null:e),v(e=>e!=null&&t(e.path)?null:e)},[d]);let y=h!=null&&h===t,b=p?.content??``,x=_?.path===t?_.content:b,C=()=>{g(null),v(null)},w=o({mutationFn:async({path:t,content:n})=>{let{error:r,response:i}=await B({path:{assistant_id:e},body:{path:t,content:n,encoding:`utf8`},throwOnError:!1});if(!i?.ok||r)throw Error(`Failed to save file`)},onSuccess:(e,t)=>{g(e=>e===t.path?null:e),v(e=>e?.path===t.path?null:e),f.invalidateQueries({queryKey:[`assistantsWorkspaceFileRetrieve`]})}}),T=x!==b,E=(0,Y.useCallback)(()=>{t&&T&&!w.isPending&&w.mutate({path:t,content:x})},[t,T,w,x]);if(!t)return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view`}),l&&(0,Z.jsx)(n,{type:`button`,onClick:l,leftIcon:(0,Z.jsx)(S,{"aria-hidden":!0}),className:`sm:hidden`,children:`Browse files`})]});if(m)return(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(D,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})});if(!p)return(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`File not found`})});let O=p.mimeType??`application/octet-stream`,k=p.name??t.split(`/`).pop()??t,A=F(k,O),j=de(k,O),M=p.content!=null&&!A&&!j,N=t?X(t):!0,P=y&&(0,Z.jsx)(se,{isDirty:T,isSaving:w.isPending,error:w.isError?`Save failed`:null,onSave:E,onDiscard:C});if(A&&p.content!=null){let e=y?x:p.content;return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:k,mimeType:O,rightContent:(0,Z.jsx)(_e,{viewMode:s,onChange:e=>{y&&C(),c(e)}})}),(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(q,{content:e,fileName:k,mimeType:O,showEdit:!N&&s===`source`,isEditing:y,onToggleEdit:()=>y?C():g(t)}),s===`preview`?(0,Z.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:(0,Z.jsx)(I,{content:e})}):y?(0,Z.jsx)(K,{value:x,onChange:e=>v({path:t,content:e}),onSave:E}):(0,Z.jsx)(G,{content:p.content,readOnly:N,onStartEdit:()=>g(t)})]}),P]})}if(j&&p.content!=null){let e=y?x:p.content,n=fe(e);return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:k,mimeType:O,rightContent:(0,Z.jsx)(_e,{viewMode:s,onChange:e=>{y&&C(),c(e)}})}),(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(q,{content:s===`preview`?n:e,downloadContent:e,fileName:k,mimeType:O,showEdit:!N&&s===`source`,isEditing:y,onToggleEdit:()=>y?C():g(t)}),s===`preview`?(0,Z.jsx)(G,{content:n,readOnly:!0,whiteSpace:`pre`}):y?(0,Z.jsx)(K,{value:x,onChange:e=>v({path:t,content:e}),onSave:E}):(0,Z.jsx)(G,{content:p.content,readOnly:N,onStartEdit:()=>g(t)})]}),P]})}return M?(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:k,mimeType:O,size:p.size}),(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(q,{content:y?x:p.content??``,fileName:k,mimeType:O,showEdit:!N,isEditing:y,onToggleEdit:()=>y?C():g(t)}),y?(0,Z.jsx)(K,{value:x,onChange:e=>v({path:t,content:e}),onSave:E}):(0,Z.jsx)(G,{content:p.content??``,readOnly:N,onStartEdit:()=>g(t)})]}),P]}):O.startsWith(`image/`)||O.startsWith(`video/`)?(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:k,mimeType:O,size:p.size,rightContent:(0,Z.jsx)(me,{assistantId:e,path:t,name:k,showHidden:r})}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Z.jsx)(ve,{assistantId:e,path:t,mimeType:O,showHidden:r})})]}):(0,Z.jsx)(ye,{assistantId:e,path:t,name:k,mimeType:O,size:p.size,modifiedAt:p.modifiedAt,showHidden:r})}function xe(e,t){if(t===`name`)return e;let n=e.slice();return n.sort((e,t)=>{let n=e.size??null,r=t.size??null;return n===null&&r===null?(e.name??``).localeCompare(t.name??``):n===null?1:r===null?-1:n===r?(e.name??``).localeCompare(t.name??``):r-n}),n}async function Se(e,t,n,r){let i=n.toLowerCase(),a=r?.toLowerCase(),{data:o}=await R({path:{assistant_id:e},query:t?{path:t}:{}});if(o?.entries?.some(e=>{let t=(e.name??``).toLowerCase();return t===i&&t!==a}))throw Error(`"${n}" already exists here.`)}function Ce({entry:e}){return e.type===`directory`?(0,Z.jsx)(E,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`image/`)?(0,Z.jsx)(C,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`video/`)?(0,Z.jsx)(T,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Z.jsx)(b,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}})}function we({entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:i,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,onRequestDelete:f,onRequestRename:m,onRequestCreate:h,depth:g}){let _=e.path??``,v=e.name??``,b=e.type===`directory`,x=n.has(_),S=r===_,C=v.startsWith(`.`),T=!X(_),E=b&&(x||s.length>0),{data:D}=a({...H({assistantId:t,path:_,showHidden:i,includeDirSizes:o===`size`}),enabled:b&&E}),k=(0,Y.useMemo)(()=>xe(D?.entries??[],o),[D?.entries,o]),A=s===``||v.toLowerCase().includes(s);if(s!==``&&!b&&!A)return null;let M=(0,Z.jsxs)(`button`,{onClick:()=>{b?c(_):l(_)},className:`flex w-full items-center gap-1.5 px-2 py-1 text-left text-body-medium-lighter transition-colors hover:bg-[var(--surface-hover)]`,style:{paddingLeft:`${g*14+8}px`,paddingRight:`8px`,color:S?`var(--content-default)`:C?`var(--content-tertiary)`:`var(--content-default)`,backgroundColor:S?`color-mix(in oklab, var(--primary-base) 12%, transparent)`:void 0,opacity:C&&!S?.7:1},children:[b?E?(0,Z.jsx)(u,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Z.jsx)(d,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Z.jsx)(`span`,{className:`h-3 w-3 shrink-0`}),(0,Z.jsx)(Ce,{entry:e}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:v}),e.size!=null&&(0,Z.jsx)(`span`,{className:`shrink-0 text-label-medium-default tabular-nums`,style:{color:`var(--content-tertiary)`},children:J(e.size)})]});return(0,Z.jsxs)(`div`,{children:[T?(0,Z.jsxs)(p.Root,{children:[(0,Z.jsx)(p.Trigger,{children:M}),(0,Z.jsxs)(p.Content,{children:[b&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(p.Item,{leftIcon:(0,Z.jsx)(y,{className:`h-3.5 w-3.5`}),onSelect:()=>h({kind:`file`,parentPath:_}),children:`New File`}),(0,Z.jsx)(p.Item,{leftIcon:(0,Z.jsx)(w,{className:`h-3.5 w-3.5`}),onSelect:()=>h({kind:`folder`,parentPath:_}),children:`New Folder`}),(0,Z.jsx)(p.Separator,{})]}),(0,Z.jsx)(p.Item,{leftIcon:(0,Z.jsx)(j,{className:`h-3.5 w-3.5`}),onSelect:()=>f({path:_,name:v,isDirectory:b}),children:`Delete`}),(0,Z.jsx)(p.Item,{leftIcon:(0,Z.jsx)(O,{className:`h-3.5 w-3.5`}),onSelect:()=>m({path:_,name:v,isDirectory:b}),children:`Rename`})]})]}):M,b&&E&&k.length>0&&(0,Z.jsx)(`div`,{children:k.map(e=>(0,Z.jsx)(we,{entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:i,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,onRequestDelete:f,onRequestRename:m,onRequestCreate:h,depth:g+1},e.path))})]})}function Te({title:e,placeholder:t,confirmLabel:r,pendingLabel:i,initialName:a,onCancel:o,onConfirm:s,pending:c,error:l}){let u=(0,Y.useRef)(null),[d,f]=(0,Y.useState)(a??``),p=d.trim(),m=p.length>0&&(/[/\\]/.test(p)||p===`.`||p===`..`),h=p.length>0&&!m&&!c;return(0,Z.jsx)(P.Root,{open:!0,onOpenChange:e=>{!e&&!c&&o()},children:(0,Z.jsx)(P.Content,{size:`sm`,hideCloseButton:!0,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault();let t=u.current;t&&(t.focus(),requestAnimationFrame(()=>{t.setSelectionRange(0,t.value.length)}))},onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation(),c||o()},children:(0,Z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h&&s(p)},children:[(0,Z.jsx)(P.Header,{children:(0,Z.jsx)(P.Title,{children:e})}),(0,Z.jsx)(P.Body,{children:(0,Z.jsx)(N,{ref:u,label:`Name`,value:d,onChange:e=>f(e.target.value),placeholder:t,errorText:l??(m?`Enter a single file or folder name without slashes.`:void 0),autoComplete:`off`,spellCheck:!1,fullWidth:!0})}),(0,Z.jsxs)(P.Footer,{children:[(0,Z.jsx)(n,{type:`button`,variant:`outlined`,onClick:o,disabled:c,children:`Cancel`}),(0,Z.jsx)(n,{type:`submit`,variant:`primary`,disabled:!h,children:c?i:r})]})]})})})}function Ee({assistantId:e,expandedPaths:t,selectedPath:r,showHidden:s,sortMode:c,onToggleExpand:l,onExpandPath:u,onSelectPath:d,onToggleShowHidden:f,onChangeSortMode:p,onPathDeleted:m,onPathRenamed:h}){let g=i(),[y,b]=(0,Y.useState)(``),x=y.trim().toLowerCase(),[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(null),O=(0,Y.useCallback)(()=>{T(null),D(null)},[]),{data:k,isLoading:j}=a(H({assistantId:e,showHidden:s,includeDirSizes:c===`size`})),P=(0,Y.useMemo)(()=>xe(k?.entries??[],c),[k?.entries,c]),F=(0,Y.useCallback)(()=>{for(let e of[ie,`assistantsWorkspaceFileRetrieve`,`assistantsWorkspaceFileContentRetrieve`])g.invalidateQueries({queryKey:[e]})},[g]),I=o({mutationFn:async t=>{let n=t.parentPath?`${t.parentPath}/${t.name}`:t.name;await Se(e,t.parentPath,t.name);let{error:r,response:i}=t.kind===`file`?await B({path:{assistant_id:e},body:{path:n,content:``,encoding:`utf8`},throwOnError:!1}):await ne({path:{assistant_id:e},body:{path:n},throwOnError:!1});if(r||!i?.ok)throw Error(typeof r==`string`?r:`Failed to create — check the name and try again.`);return{...t,path:n}},onSuccess:e=>{O(),F(),e.parentPath&&u(e.parentPath),e.kind===`file`?d(e.path):u(e.path)},onError:e=>{D(e instanceof Error?e.message:`Failed to create.`)}}),L=o({mutationFn:async t=>{let n=t.oldPath.lastIndexOf(`/`),r=n===-1?``:t.oldPath.slice(0,n),i=t.oldPath.slice(n+1),a=r?`${r}/${t.newName}`:t.newName;await Se(e,r,t.newName,i);let{error:o,response:s}=await re({path:{assistant_id:e},body:{oldPath:t.oldPath,newPath:a},throwOnError:!1});if(o||!s?.ok)throw Error(typeof o==`string`?o:`Failed to rename — check the name and try again.`);return{oldPath:t.oldPath,newPath:a}},onSuccess:({oldPath:e,newPath:t})=>{O(),F(),h(e,t)},onError:e=>{D(e instanceof Error?e.message:`Failed to rename.`)}}),R=(0,Y.useCallback)(e=>{D(null),T({type:`create`,...e})},[]),z=(0,Y.useCallback)(e=>{D(null),T({type:`rename`,path:e.path,name:e.name})},[]),[V,U]=(0,Y.useState)(null),W=o({mutationFn:async t=>{let{error:n,response:r}=await te({path:{assistant_id:e},body:{path:t.path},throwOnError:!1});if(n||!r?.ok)throw Error(typeof n==`string`?n:`Failed to delete — try again.`);return t},onSuccess:e=>{U(null),F(),m(e.path)}}),ae=(0,Y.useCallback)(e=>{W.reset(),U(e)},[W]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-secondary)`},children:`Files`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:c===`size`?(0,Z.jsx)(le,{"aria-hidden":!0}):(0,Z.jsx)(ce,{"aria-hidden":!0}),onClick:()=>p(c===`size`?`name`:`size`),"aria-label":c===`size`?`Sort by name`:`Sort by size`,title:c===`size`?`Sorted by size — switch to name`:`Sorted by name — switch to size`,tintColor:c===`size`?`var(--content-default)`:`var(--content-tertiary)`}),(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:s?(0,Z.jsx)(v,{"aria-hidden":!0}):(0,Z.jsx)(_,{"aria-hidden":!0}),onClick:f,"aria-label":s?`Hide hidden files`:`Show hidden files`,title:s?`Hide hidden files`:`Show hidden files`,tintColor:s?`var(--content-default)`:`var(--content-tertiary)`}),(0,Z.jsx)(De,{open:S,onOpenChange:C,onSelectKind:e=>{C(!1),R({kind:e,parentPath:``})}})]})]}),(0,Z.jsx)(`div`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(N,{type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`Search files`,leftIcon:(0,Z.jsx)(A,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0,spellCheck:!1,autoComplete:`off`}),y&&(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(M,{"aria-hidden":!0}),onClick:()=>b(``),"aria-label":`Clear search`,className:`absolute right-1.5 top-1/2 -translate-y-1/2`,tintColor:`var(--content-tertiary)`})]})}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:j?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`,style:{color:`var(--content-tertiary)`}})}):P.length?P.map(n=>(0,Z.jsx)(we,{entry:n,assistantId:e,expandedPaths:t,selectedPath:r,showHidden:s,sortMode:c,searchLower:x,onToggleExpand:l,onSelectPath:d,onRequestDelete:ae,onRequestRename:z,onRequestCreate:R,depth:0},n.path)):(0,Z.jsx)(`p`,{className:`px-3 py-4 text-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`No files found`})}),w?.type===`create`&&(0,Z.jsx)(Te,{title:w.kind===`file`?`New File`:`New Folder`,placeholder:w.kind===`file`?`filename.md`:`folder-name`,confirmLabel:`Create`,pendingLabel:`Creating…`,onCancel:O,onConfirm:e=>{D(null),I.mutate({kind:w.kind,parentPath:w.parentPath,name:e})},pending:I.isPending,error:E},`create-${w.kind}-${w.parentPath}`),w?.type===`rename`&&(0,Z.jsx)(Te,{title:`Rename`,placeholder:w.name,confirmLabel:`Rename`,pendingLabel:`Renaming…`,initialName:w.name,onCancel:O,onConfirm:e=>{if(e===w.name){O();return}D(null),L.mutate({oldPath:w.path,newName:e})},pending:L.isPending,error:E},`rename-${w.path}`),(0,Z.jsx)(ee,{open:V!==null,title:V?.isDirectory?`Delete Folder`:`Delete File`,message:(0,Z.jsxs)(Z.Fragment,{children:[`Are you sure you want to delete`,` `,(0,Z.jsx)(`span`,{style:{color:`var(--content-default)`},children:V?.name}),V?.isDirectory?` and all of its contents`:``,`? This cannot be undone.`,W.error&&(0,Z.jsx)(`span`,{className:`mt-2 block`,style:{color:`var(--system-negative-strong)`},children:W.error.message})]}),confirmLabel:W.isPending?`Deleting…`:`Delete`,destructive:!0,isPending:W.isPending,onConfirm:()=>{V&&W.mutate(V)},onCancel:()=>U(null)})]})}function De({open:e,onOpenChange:t,onSelectKind:r}){return V()?(0,Z.jsxs)(m.Root,{open:e,onOpenChange:t,children:[(0,Z.jsx)(m.Trigger,{asChild:!0,children:(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(k,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,Z.jsxs)(m.Content,{children:[(0,Z.jsx)(m.Header,{className:`sr-only`,children:(0,Z.jsx)(m.Title,{children:`Create new`})}),(0,Z.jsxs)(m.Body,{className:`pt-0`,children:[(0,Z.jsx)(h,{icon:y,label:`New File`,onSelect:()=>r(`file`)}),(0,Z.jsx)(h,{icon:w,label:`New Folder`,onSelect:()=>r(`folder`)})]})]})]}):(0,Z.jsxs)(f.Root,{open:e,onOpenChange:t,children:[(0,Z.jsx)(f.Trigger,{asChild:!0,children:(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(k,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,Z.jsxs)(f.Content,{align:`end`,sideOffset:4,children:[(0,Z.jsx)(f.Item,{leftIcon:(0,Z.jsx)(y,{className:`h-3.5 w-3.5`}),onSelect:()=>r(`file`),children:`New File`}),(0,Z.jsx)(f.Item,{leftIcon:(0,Z.jsx)(w,{className:`h-3.5 w-3.5`}),onSelect:()=>r(`folder`),children:`New Folder`})]})]})}function $(e){let t=e.split(`/`),n=new Set;for(let e=1;e<t.length;e++)n.add(t.slice(0,e).join(`/`));return n}function Oe({assistantId:e}){let[t,n]=r(),[i,a]=(0,Y.useState)(()=>{let e=t.get(`file`);return e?$(e):new Set}),[o,s]=(0,Y.useState)(()=>t.get(`file`)),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(()=>t.get(`sort`)===`size`?`size`:`name`),[f,p]=(0,Y.useState)(`preview`);(0,Y.useEffect)(()=>{let e=t.get(`file`);e&&(s(e),a(t=>{let n=new Set(t);for(let t of $(e))n.add(t);return n.size===t.size?t:n}),n(e=>{let t=new URLSearchParams(e);return t.delete(`file`),t},{replace:!0}))},[t,n]);let m=(0,Y.useCallback)(e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),h=(0,Y.useCallback)(e=>{a(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),[g,_]=(0,Y.useState)(!1),v=(0,Y.useCallback)(e=>{s(e),_(!1)},[]),[y,b]=(0,Y.useState)(null),x=(0,Y.useCallback)(e=>{let t=t=>t===e||t.startsWith(`${e}/`);s(e=>e!==null&&t(e)?null:e),a(e=>{let n=new Set([...e].filter(e=>!t(e)));return n.size===e.size?e:n}),b({path:e})},[]),[S,C]=(0,Y.useState)(null),w={assistantId:e,expandedPaths:i,selectedPath:o,showHidden:c,sortMode:u,onToggleExpand:m,onExpandPath:h,onSelectPath:v,onToggleShowHidden:()=>l(e=>!e),onChangeSortMode:d,onPathDeleted:x,onPathRenamed:(0,Y.useCallback)((e,t)=>{let n=n=>n===e?t:n.startsWith(`${e}/`)?t+n.slice(e.length):n;s(e=>e===null?e:n(e)),a(e=>{let t=!1,r=new Set;for(let i of e){let e=n(i);e!==i&&(t=!0),r.add(e)}return t?r:e}),C({from:e,to:t})},[])};return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-4`,children:[(0,Z.jsx)(`div`,{className:`flex items-center sm:hidden`,children:(0,Z.jsx)(ae,{onClick:()=>_(!0)})}),(0,Z.jsx)(oe,{open:g,onClose:()=>_(!1),title:`Files`,children:(0,Z.jsx)(Ee,{...w})}),(0,Z.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-4 sm:grid-cols-[320px_1fr]`,children:[(0,Z.jsx)(`div`,{className:`hidden min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border sm:flex`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,Z.jsx)(Ee,{...w})}),(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,Z.jsx)(be,{assistantId:e,selectedPath:o,showHidden:c,viewMode:f,onChangeViewMode:p,onBrowse:()=>_(!0),pathRename:S,pathDelete:y})})]})]})}function ke(){return(0,Z.jsx)(Oe,{assistantId:W()})}export{ke as WorkspacePage};
1
+ import{o as e}from"./chunk-jRWAZmH_.js";import{t}from"./react-BFJW0bSv.js";import{t as n}from"./button-fyWSnR9X.js";import{m as r}from"./chunk-5KNZJZUH-Bsoom5--.js";import{n as i}from"./QueryClientProvider-CMu7CkQU.js";import{t as a}from"./useQuery-Bz-fbQ-m.js";import{t as o}from"./useMutation-CXGTrp4W.js";import{t as s}from"./jsx-runtime-D3ZM-ToX.js";import{t as c}from"./queryOptions-CMSBCFOf.js";import{t as l}from"./createLucideIcon-CAM1RhH8.js";import{t as u}from"./chevron-down-BNidRDh1.js";import{t as d}from"./chevron-right-CANAtgGn.js";import{t as f}from"./menu-D7gzADvH.js";import{F as p,I as m,N as h}from"./src-ly8ixpHd.js";import{t as g}from"./download-Cnb8zZrK.js";import{t as _}from"./eye-off-DQ4xakzN.js";import{t as v}from"./eye-B_jBDDRn.js";import{t as y}from"./file-plus-DjC7wnGp.js";import{t as b}from"./file-text-CwGsMgaa.js";import{t as x}from"./file-DOePafLU.js";import{t as S}from"./folder-open-BTlvhHNO.js";import{n as C,r as w,t as T}from"./video-Dtwi0MD9.js";import{t as E}from"./folder-_l8GIyQp.js";import{t as D}from"./loader-circle-DWWXcfTQ.js";import{t as O}from"./pencil-Cm5DdeRM.js";import{t as k}from"./plus-EJu6s6xR.js";import{t as A}from"./search-DL-2uX3K.js";import{t as j}from"./trash-2-DfVRfykB.js";import{t as M}from"./x-D4O9yIS7.js";import{t as N}from"./input-B_e9sgY6.js";import{t as P}from"./modal-D946-vqt.js";import{t as ee}from"./confirm-dialog-Ro8nszbc.js";import{n as F,t as I}from"./file-markdown-DQoYQOq5.js";import{Br as te,Hr as L,Kr as R,Ur as ne,Vr as z,Wr as re,qr as B}from"./sdk.gen-qwmaWHuE.js";import{n as V}from"./use-is-mobile-MmHo-OM6.js";import{n as H,r as U,t as ie}from"./workspace-tree-query-CUw_yH2P.js";import{t as W}from"./use-active-assistant-id-CaI-sL1J.js";import{n as ae,t as oe}from"./mobile-sidebar-drawer-Cl-CxiPz.js";import{i as G,n as se,r as K,t as q}from"./file-editor-DIHQt7wk.js";import{t as J}from"./format-file-size-B5EMFtmw.js";var ce=l(`arrow-down-a-z`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M20 8h-5`,key:`1vsyxs`}],[`path`,{d:`M15 10V6.5a2.5 2.5 0 0 1 5 0V10`,key:`ag13bf`}],[`path`,{d:`M15 14h5l-5 6h5`,key:`ur5jdg`}]]),le=l(`arrow-down-wide-narrow`,[[`path`,{d:`m3 16 4 4 4-4`,key:`1co6wj`}],[`path`,{d:`M7 20V4`,key:`1yoxec`}],[`path`,{d:`M11 4h10`,key:`1w87gc`}],[`path`,{d:`M11 8h7`,key:`djye34`}],[`path`,{d:`M11 12h4`,key:`q8tih4`}]]),Y=e(t(),1);function ue(e){if(!e)return``;let t=e.indexOf(`;`);return(t===-1?e:e.slice(0,t)).trim()}function de(e,t){return ue(t)===`application/json`?!0:(e??``).toLowerCase().endsWith(`.json`)}function fe(e){try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}}function X(e){return e.split(`/`).some(e=>e.startsWith(`.`))}var Z=s();function pe(e){let{assistantId:t,path:n,name:r,showHidden:i}=e,[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1);return{isDownloading:a,error:s,download:(0,Y.useCallback)(async()=>{c(!1),o(!0);try{await U({assistantId:t,path:n,filename:r,showHidden:i})}catch{c(!0)}finally{o(!1)}},[t,n,r,i])}}function me({assistantId:e,path:t,name:r,showHidden:i}){let{isDownloading:a,error:o,download:s}=pe({assistantId:e,path:t,name:r,showHidden:i});return(0,Z.jsx)(n,{variant:`ghost`,size:`regular`,iconOnly:a?(0,Z.jsx)(D,{className:`animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(g,{"aria-hidden":!0}),onClick:()=>void s(),disabled:a,"aria-label":`Download ${r}`,tooltip:o?`Download failed. Try again.`:`Download`})}function he(e){return c({queryFn:async()=>{let{data:t,error:n}=await L({path:e.path,query:{path:e.query.path,...e.query.showHidden?{showHidden:`true`}:{}}});if(n)throw n;return t},queryKey:[`assistantsWorkspaceFileRetrieve`,e]})}function ge({mimeType:e}){let t=e.indexOf(`;`),n=(t===-1?e:e.slice(0,t)).trim(),r=b;return n.startsWith(`image/`)?r=C:n.startsWith(`video/`)?r=T:!n.startsWith(`text/`)&&n!==`application/json`&&n!==`application/octet-stream`&&(r=x),(0,Z.jsx)(`span`,{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 10%, transparent)`},children:(0,Z.jsx)(r,{className:`h-3.5 w-3.5`,style:{color:`var(--content-default)`}})})}function _e({viewMode:e,onChange:t}){return(0,Z.jsx)(`div`,{className:`inline-flex rounded-md p-0.5`,style:{backgroundColor:`color-mix(in oklab, var(--content-default) 6%, transparent)`},children:[`preview`,`source`].map(r=>{let i=e===r;return(0,Z.jsx)(n,{variant:`ghost`,onClick:()=>t(r),className:`h-auto rounded border-0 px-2.5 py-1 text-body-small-default hover:bg-transparent`,style:{backgroundColor:i?`var(--surface-lift)`:`transparent`,color:i?`var(--content-default)`:`var(--content-tertiary)`,boxShadow:i?`0 1px 2px rgba(0,0,0,0.15)`:void 0},children:r===`preview`?`Preview`:`Source`},r)})})}function Q({name:e,mimeType:t,size:n,rightContent:r}){return(0,Z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,Z.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,Z.jsx)(ge,{mimeType:t}),(0,Z.jsx)(`span`,{className:`truncate text-body-medium-default`,style:{color:`var(--content-default)`},children:e}),n!=null&&(0,Z.jsx)(`span`,{className:`shrink-0 text-body-small-default`,style:{color:`var(--content-tertiary)`},children:J(n)})]}),r]})}function ve({assistantId:e,path:t,mimeType:n,showHidden:r}){let{data:i,isLoading:o}=a({queryFn:async()=>{let n=await z({path:{assistant_id:e},query:{path:t,...r?{showHidden:`true`}:{}},parseAs:`blob`});if(n.error)throw n.error;return n.data},queryKey:[`assistantsWorkspaceFileContentRetrieve`,{assistantId:e,path:t,showHidden:r}],enabled:!!t}),[s,c]=(0,Y.useState)(null);return(0,Y.useEffect)(()=>{if(!i)return;let e=URL.createObjectURL(i);return c(e),()=>{URL.revokeObjectURL(e),c(null)}},[i]),o?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-12`,children:(0,Z.jsx)(D,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})}):s?n.startsWith(`image/`)?(0,Z.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,Z.jsx)(`img`,{src:s,alt:t.split(`/`).pop()??`image`,className:`max-h-[70vh] max-w-full rounded object-contain`})}):n.startsWith(`video/`)?(0,Z.jsx)(`div`,{className:`flex items-center justify-center p-4`,children:(0,Z.jsx)(`video`,{src:s,controls:!0,className:`max-h-[70vh] max-w-full rounded`})}):null:null}function ye({assistantId:e,path:t,name:r,mimeType:i,size:a,modifiedAt:o,showHidden:s}){let{isDownloading:c,error:l,download:u}=pe({assistantId:e,path:t,name:r,showHidden:s});return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:r,mimeType:i,size:a}),(0,Z.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-8`,children:(0,Z.jsxs)(`div`,{className:`w-full max-w-sm rounded-lg border p-6 text-center`,style:{borderColor:`var(--border-base)`,backgroundColor:`var(--surface-lift)`},children:[(0,Z.jsx)(x,{className:`mx-auto h-10 w-10`,style:{color:`var(--content-tertiary)`}}),(0,Z.jsx)(`p`,{className:`mt-3 text-body-medium-default`,style:{color:`var(--content-default)`},children:r}),(0,Z.jsxs)(`div`,{className:`mt-2 space-y-1`,children:[(0,Z.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:i}),(0,Z.jsx)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:J(a,`Unknown size`)}),o&&(0,Z.jsxs)(`p`,{className:`text-body-small-default`,style:{color:`var(--content-secondary, var(--content-tertiary))`},children:[`Modified: `,new Date(o).toLocaleString()]})]}),(0,Z.jsx)(n,{variant:`outlined`,size:`compact`,leftIcon:c?(0,Z.jsx)(D,{className:`animate-spin`,"aria-hidden":!0}):(0,Z.jsx)(g,{"aria-hidden":!0}),onClick:u,disabled:c,"aria-label":`Download ${r}`,className:`mt-4`,children:c?`Downloading…`:`Download`}),l&&(0,Z.jsx)(`p`,{className:`mt-2 text-body-small-default`,style:{color:`var(--system-error)`},children:`Download failed. Try again.`})]})})]})}function be({assistantId:e,selectedPath:t,showHidden:r,viewMode:s,onChangeViewMode:c,onBrowse:l,pathRename:u,pathDelete:d}){let f=i(),{data:p,isLoading:m}=a({...he({path:{assistant_id:e},query:{path:t??``,showHidden:r}}),enabled:!!t}),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{if(!u)return;let{from:e,to:t}=u,n=n=>n===e?t:n.startsWith(`${e}/`)?t+n.slice(e.length):n;g(e=>e==null?e:n(e)),v(e=>e==null?e:{...e,path:n(e.path)})},[u]),(0,Y.useEffect)(()=>{if(!d)return;let{path:e}=d,t=t=>t===e||t.startsWith(`${e}/`);g(e=>e!=null&&t(e)?null:e),v(e=>e!=null&&t(e.path)?null:e)},[d]);let y=h!=null&&h===t,b=p?.content??``,x=_?.path===t?_.content:b,C=()=>{g(null),v(null)},w=o({mutationFn:async({path:t,content:n})=>{let{error:r,response:i}=await B({path:{assistant_id:e},body:{path:t,content:n,encoding:`utf8`},throwOnError:!1});if(!i?.ok||r)throw Error(`Failed to save file`)},onSuccess:(e,t)=>{g(e=>e===t.path?null:e),v(e=>e?.path===t.path?null:e),f.invalidateQueries({queryKey:[`assistantsWorkspaceFileRetrieve`]})}}),T=x!==b,E=(0,Y.useCallback)(()=>{t&&T&&!w.isPending&&w.mutate({path:t,content:x})},[t,T,w,x]);if(!t)return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-3`,children:[(0,Z.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`Select a file to view`}),l&&(0,Z.jsx)(n,{type:`button`,onClick:l,leftIcon:(0,Z.jsx)(S,{"aria-hidden":!0}),className:`sm:hidden`,children:`Browse files`})]});if(m)return(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(D,{className:`h-6 w-6 animate-spin`,style:{color:`var(--content-tertiary)`}})});if(!p)return(0,Z.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,Z.jsx)(`p`,{className:`text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`File not found`})});let O=p.mimeType??`application/octet-stream`,k=p.name??t.split(`/`).pop()??t,A=F(k,O),j=de(k,O),M=p.content!=null&&!A&&!j,N=t?X(t):!0,P=y&&(0,Z.jsx)(se,{isDirty:T,isSaving:w.isPending,error:w.isError?`Save failed`:null,onSave:E,onDiscard:C});if(A&&p.content!=null){let e=y?x:p.content;return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:k,mimeType:O,rightContent:(0,Z.jsx)(_e,{viewMode:s,onChange:e=>{y&&C(),c(e)}})}),(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(q,{content:e,fileName:k,mimeType:O,showEdit:!N&&s===`source`,isEditing:y,onToggleEdit:()=>y?C():g(t)}),s===`preview`?(0,Z.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4`,style:{color:`var(--content-default)`},children:(0,Z.jsx)(I,{content:e})}):y?(0,Z.jsx)(K,{value:x,onChange:e=>v({path:t,content:e}),onSave:E}):(0,Z.jsx)(G,{content:p.content,readOnly:N,onStartEdit:()=>g(t)})]}),P]})}if(j&&p.content!=null){let e=y?x:p.content,n=fe(e);return(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:k,mimeType:O,rightContent:(0,Z.jsx)(_e,{viewMode:s,onChange:e=>{y&&C(),c(e)}})}),(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(q,{content:s===`preview`?n:e,downloadContent:e,fileName:k,mimeType:O,showEdit:!N&&s===`source`,isEditing:y,onToggleEdit:()=>y?C():g(t)}),s===`preview`?(0,Z.jsx)(G,{content:n,readOnly:!0,whiteSpace:`pre`}):y?(0,Z.jsx)(K,{value:x,onChange:e=>v({path:t,content:e}),onSave:E}):(0,Z.jsx)(G,{content:p.content,readOnly:N,onStartEdit:()=>g(t)})]}),P]})}return M?(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:k,mimeType:O,size:p.size}),(0,Z.jsxs)(`div`,{className:`relative flex-1 overflow-hidden`,children:[(0,Z.jsx)(q,{content:y?x:p.content??``,fileName:k,mimeType:O,showEdit:!N,isEditing:y,onToggleEdit:()=>y?C():g(t)}),y?(0,Z.jsx)(K,{value:x,onChange:e=>v({path:t,content:e}),onSave:E}):(0,Z.jsx)(G,{content:p.content??``,readOnly:N,onStartEdit:()=>g(t)})]}),P]}):O.startsWith(`image/`)||O.startsWith(`video/`)?(0,Z.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,Z.jsx)(Q,{name:k,mimeType:O,size:p.size,rightContent:(0,Z.jsx)(me,{assistantId:e,path:t,name:k,showHidden:r})}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-auto`,children:(0,Z.jsx)(ve,{assistantId:e,path:t,mimeType:O,showHidden:r})})]}):(0,Z.jsx)(ye,{assistantId:e,path:t,name:k,mimeType:O,size:p.size,modifiedAt:p.modifiedAt,showHidden:r})}function xe(e,t){if(t===`name`)return e;let n=e.slice();return n.sort((e,t)=>{let n=e.size??null,r=t.size??null;return n===null&&r===null?(e.name??``).localeCompare(t.name??``):n===null?1:r===null?-1:n===r?(e.name??``).localeCompare(t.name??``):r-n}),n}async function Se(e,t,n,r){let i=n.toLowerCase(),a=r?.toLowerCase(),{data:o}=await R({path:{assistant_id:e},query:t?{path:t}:{}});if(o?.entries?.some(e=>{let t=(e.name??``).toLowerCase();return t===i&&t!==a}))throw Error(`"${n}" already exists here.`)}function Ce({entry:e}){return e.type===`directory`?(0,Z.jsx)(E,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`image/`)?(0,Z.jsx)(C,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):e.mimeType?.startsWith(`video/`)?(0,Z.jsx)(T,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Z.jsx)(b,{className:`h-4 w-4 shrink-0`,style:{color:`var(--content-tertiary)`}})}function we({entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:i,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,onRequestDelete:f,onRequestRename:m,onRequestCreate:h,depth:g}){let _=e.path??``,v=e.name??``,b=e.type===`directory`,x=n.has(_),S=r===_,C=v.startsWith(`.`),T=!X(_),E=b&&(x||s.length>0),{data:D}=a({...H({assistantId:t,path:_,showHidden:i,includeDirSizes:o===`size`}),enabled:b&&E}),k=(0,Y.useMemo)(()=>xe(D?.entries??[],o),[D?.entries,o]),A=s===``||v.toLowerCase().includes(s);if(s!==``&&!b&&!A)return null;let M=(0,Z.jsxs)(`button`,{onClick:()=>{b?c(_):l(_)},className:`flex w-full items-center gap-1.5 px-2 py-1 text-left text-body-medium-lighter transition-colors hover:bg-[var(--surface-hover)]`,style:{paddingLeft:`${g*14+8}px`,paddingRight:`8px`,color:S?`var(--content-default)`:C?`var(--content-tertiary)`:`var(--content-default)`,backgroundColor:S?`color-mix(in oklab, var(--primary-base) 12%, transparent)`:void 0,opacity:C&&!S?.7:1},children:[b?E?(0,Z.jsx)(u,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Z.jsx)(d,{className:`h-3 w-3 shrink-0`,style:{color:`var(--content-tertiary)`}}):(0,Z.jsx)(`span`,{className:`h-3 w-3 shrink-0`}),(0,Z.jsx)(Ce,{entry:e}),(0,Z.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:v}),e.size!=null&&(0,Z.jsx)(`span`,{className:`shrink-0 text-label-medium-default tabular-nums`,style:{color:`var(--content-tertiary)`},children:J(e.size)})]});return(0,Z.jsxs)(`div`,{children:[T?(0,Z.jsxs)(p.Root,{children:[(0,Z.jsx)(p.Trigger,{children:M}),(0,Z.jsxs)(p.Content,{children:[b&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(p.Item,{leftIcon:(0,Z.jsx)(y,{className:`h-3.5 w-3.5`}),onSelect:()=>h({kind:`file`,parentPath:_}),children:`New File`}),(0,Z.jsx)(p.Item,{leftIcon:(0,Z.jsx)(w,{className:`h-3.5 w-3.5`}),onSelect:()=>h({kind:`folder`,parentPath:_}),children:`New Folder`}),(0,Z.jsx)(p.Separator,{})]}),(0,Z.jsx)(p.Item,{leftIcon:(0,Z.jsx)(j,{className:`h-3.5 w-3.5`}),onSelect:()=>f({path:_,name:v,isDirectory:b}),children:`Delete`}),(0,Z.jsx)(p.Item,{leftIcon:(0,Z.jsx)(O,{className:`h-3.5 w-3.5`}),onSelect:()=>m({path:_,name:v,isDirectory:b}),children:`Rename`})]})]}):M,b&&E&&k.length>0&&(0,Z.jsx)(`div`,{children:k.map(e=>(0,Z.jsx)(we,{entry:e,assistantId:t,expandedPaths:n,selectedPath:r,showHidden:i,sortMode:o,searchLower:s,onToggleExpand:c,onSelectPath:l,onRequestDelete:f,onRequestRename:m,onRequestCreate:h,depth:g+1},e.path))})]})}function Te({title:e,placeholder:t,confirmLabel:r,pendingLabel:i,initialName:a,onCancel:o,onConfirm:s,pending:c,error:l}){let u=(0,Y.useRef)(null),[d,f]=(0,Y.useState)(a??``),p=d.trim(),m=p.length>0&&(/[/\\]/.test(p)||p===`.`||p===`..`),h=p.length>0&&!m&&!c;return(0,Z.jsx)(P.Root,{open:!0,onOpenChange:e=>{!e&&!c&&o()},children:(0,Z.jsx)(P.Content,{size:`sm`,hideCloseButton:!0,"aria-describedby":void 0,onOpenAutoFocus:e=>{e.preventDefault();let t=u.current;t&&(t.focus(),requestAnimationFrame(()=>{t.setSelectionRange(0,t.value.length)}))},onEscapeKeyDown:e=>{e.preventDefault(),e.stopPropagation(),c||o()},children:(0,Z.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),h&&s(p)},children:[(0,Z.jsx)(P.Header,{children:(0,Z.jsx)(P.Title,{children:e})}),(0,Z.jsx)(P.Body,{children:(0,Z.jsx)(N,{ref:u,label:`Name`,value:d,onChange:e=>f(e.target.value),placeholder:t,errorText:l??(m?`Enter a single file or folder name without slashes.`:void 0),autoComplete:`off`,spellCheck:!1,fullWidth:!0})}),(0,Z.jsxs)(P.Footer,{children:[(0,Z.jsx)(n,{type:`button`,variant:`outlined`,onClick:o,disabled:c,children:`Cancel`}),(0,Z.jsx)(n,{type:`submit`,variant:`primary`,disabled:!h,children:c?i:r})]})]})})})}function Ee({assistantId:e,expandedPaths:t,selectedPath:r,showHidden:s,sortMode:c,onToggleExpand:l,onExpandPath:u,onSelectPath:d,onToggleShowHidden:f,onChangeSortMode:p,onPathDeleted:m,onPathRenamed:h}){let g=i(),[y,b]=(0,Y.useState)(``),x=y.trim().toLowerCase(),[S,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(null),O=(0,Y.useCallback)(()=>{T(null),D(null)},[]),{data:k,isLoading:j}=a(H({assistantId:e,showHidden:s,includeDirSizes:c===`size`})),P=(0,Y.useMemo)(()=>xe(k?.entries??[],c),[k?.entries,c]),F=(0,Y.useCallback)(()=>{for(let e of[ie,`assistantsWorkspaceFileRetrieve`,`assistantsWorkspaceFileContentRetrieve`])g.invalidateQueries({queryKey:[e]})},[g]),I=o({mutationFn:async t=>{let n=t.parentPath?`${t.parentPath}/${t.name}`:t.name;await Se(e,t.parentPath,t.name);let{error:r,response:i}=t.kind===`file`?await B({path:{assistant_id:e},body:{path:n,content:``,encoding:`utf8`},throwOnError:!1}):await ne({path:{assistant_id:e},body:{path:n},throwOnError:!1});if(r||!i?.ok)throw Error(typeof r==`string`?r:`Failed to create — check the name and try again.`);return{...t,path:n}},onSuccess:e=>{O(),F(),e.parentPath&&u(e.parentPath),e.kind===`file`?d(e.path):u(e.path)},onError:e=>{D(e instanceof Error?e.message:`Failed to create.`)}}),L=o({mutationFn:async t=>{let n=t.oldPath.lastIndexOf(`/`),r=n===-1?``:t.oldPath.slice(0,n),i=t.oldPath.slice(n+1),a=r?`${r}/${t.newName}`:t.newName;await Se(e,r,t.newName,i);let{error:o,response:s}=await re({path:{assistant_id:e},body:{oldPath:t.oldPath,newPath:a},throwOnError:!1});if(o||!s?.ok)throw Error(typeof o==`string`?o:`Failed to rename — check the name and try again.`);return{oldPath:t.oldPath,newPath:a}},onSuccess:({oldPath:e,newPath:t})=>{O(),F(),h(e,t)},onError:e=>{D(e instanceof Error?e.message:`Failed to rename.`)}}),R=(0,Y.useCallback)(e=>{D(null),T({type:`create`,...e})},[]),z=(0,Y.useCallback)(e=>{D(null),T({type:`rename`,path:e.path,name:e.name})},[]),[V,U]=(0,Y.useState)(null),W=o({mutationFn:async t=>{let{error:n,response:r}=await te({path:{assistant_id:e},body:{path:t.path},throwOnError:!1});if(n||!r?.ok)throw Error(typeof n==`string`?n:`Failed to delete — try again.`);return t},onSuccess:e=>{U(null),F(),m(e.path)}}),ae=(0,Y.useCallback)(e=>{W.reset(),U(e)},[W]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between border-b px-3 py-2.5`,style:{borderColor:`var(--border-element)`},children:[(0,Z.jsx)(`span`,{className:`text-body-medium-default`,style:{color:`var(--content-secondary)`},children:`Files`}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:c===`size`?(0,Z.jsx)(le,{"aria-hidden":!0}):(0,Z.jsx)(ce,{"aria-hidden":!0}),onClick:()=>p(c===`size`?`name`:`size`),"aria-label":c===`size`?`Sort by name`:`Sort by size`,title:c===`size`?`Sorted by size — switch to name`:`Sorted by name — switch to size`,tintColor:c===`size`?`var(--content-default)`:`var(--content-tertiary)`}),(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:s?(0,Z.jsx)(v,{"aria-hidden":!0}):(0,Z.jsx)(_,{"aria-hidden":!0}),onClick:f,"aria-label":s?`Hide hidden files`:`Show hidden files`,title:s?`Hide hidden files`:`Show hidden files`,tintColor:s?`var(--content-default)`:`var(--content-tertiary)`}),(0,Z.jsx)(De,{open:S,onOpenChange:C,onSelectKind:e=>{C(!1),R({kind:e,parentPath:``})}})]})]}),(0,Z.jsx)(`div`,{className:`px-3 py-2`,children:(0,Z.jsxs)(`div`,{className:`relative`,children:[(0,Z.jsx)(N,{type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:`Search files`,leftIcon:(0,Z.jsx)(A,{className:`h-3.5 w-3.5`,"aria-hidden":!0}),fullWidth:!0,spellCheck:!1,autoComplete:`off`}),y&&(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(M,{"aria-hidden":!0}),onClick:()=>b(``),"aria-label":`Clear search`,className:`absolute right-1.5 top-1/2 -translate-y-1/2`,tintColor:`var(--content-tertiary)`})]})}),(0,Z.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto py-1`,children:j?(0,Z.jsx)(`div`,{className:`flex items-center justify-center py-8`,children:(0,Z.jsx)(`div`,{className:`h-4 w-4 animate-spin rounded-full border-2 border-current border-t-transparent`,style:{color:`var(--content-tertiary)`}})}):P.length?P.map(n=>(0,Z.jsx)(we,{entry:n,assistantId:e,expandedPaths:t,selectedPath:r,showHidden:s,sortMode:c,searchLower:x,onToggleExpand:l,onSelectPath:d,onRequestDelete:ae,onRequestRename:z,onRequestCreate:R,depth:0},n.path)):(0,Z.jsx)(`p`,{className:`px-3 py-4 text-center text-body-medium-lighter`,style:{color:`var(--content-tertiary)`},children:`No files found`})}),w?.type===`create`&&(0,Z.jsx)(Te,{title:w.kind===`file`?`New File`:`New Folder`,placeholder:w.kind===`file`?`filename.md`:`folder-name`,confirmLabel:`Create`,pendingLabel:`Creating…`,onCancel:O,onConfirm:e=>{D(null),I.mutate({kind:w.kind,parentPath:w.parentPath,name:e})},pending:I.isPending,error:E},`create-${w.kind}-${w.parentPath}`),w?.type===`rename`&&(0,Z.jsx)(Te,{title:`Rename`,placeholder:w.name,confirmLabel:`Rename`,pendingLabel:`Renaming…`,initialName:w.name,onCancel:O,onConfirm:e=>{if(e===w.name){O();return}D(null),L.mutate({oldPath:w.path,newName:e})},pending:L.isPending,error:E},`rename-${w.path}`),(0,Z.jsx)(ee,{open:V!==null,title:V?.isDirectory?`Delete Folder`:`Delete File`,message:(0,Z.jsxs)(Z.Fragment,{children:[`Are you sure you want to delete`,` `,(0,Z.jsx)(`span`,{style:{color:`var(--content-default)`},children:V?.name}),V?.isDirectory?` and all of its contents`:``,`? This cannot be undone.`,W.error&&(0,Z.jsx)(`span`,{className:`mt-2 block`,style:{color:`var(--system-negative-strong)`},children:W.error.message})]}),confirmLabel:W.isPending?`Deleting…`:`Delete`,destructive:!0,isPending:W.isPending,onConfirm:()=>{V&&W.mutate(V)},onCancel:()=>U(null)})]})}function De({open:e,onOpenChange:t,onSelectKind:r}){return V()?(0,Z.jsxs)(m.Root,{open:e,onOpenChange:t,children:[(0,Z.jsx)(m.Trigger,{asChild:!0,children:(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(k,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,Z.jsxs)(m.Content,{children:[(0,Z.jsx)(m.Header,{className:`sr-only`,children:(0,Z.jsx)(m.Title,{children:`Create new`})}),(0,Z.jsxs)(m.Body,{className:`pt-0`,children:[(0,Z.jsx)(h,{icon:y,label:`New File`,onSelect:()=>r(`file`)}),(0,Z.jsx)(h,{icon:w,label:`New Folder`,onSelect:()=>r(`folder`)})]})]})]}):(0,Z.jsxs)(f.Root,{open:e,onOpenChange:t,children:[(0,Z.jsx)(f.Trigger,{asChild:!0,children:(0,Z.jsx)(n,{type:`button`,variant:`ghost`,size:`compact`,iconOnly:(0,Z.jsx)(k,{"aria-hidden":!0}),"aria-label":`Create new file or folder`,title:`New file or folder`,tintColor:`var(--content-tertiary)`})}),(0,Z.jsxs)(f.Content,{align:`end`,sideOffset:4,children:[(0,Z.jsx)(f.Item,{leftIcon:(0,Z.jsx)(y,{className:`h-3.5 w-3.5`}),onSelect:()=>r(`file`),children:`New File`}),(0,Z.jsx)(f.Item,{leftIcon:(0,Z.jsx)(w,{className:`h-3.5 w-3.5`}),onSelect:()=>r(`folder`),children:`New Folder`})]})]})}function $(e){let t=e.split(`/`),n=new Set;for(let e=1;e<t.length;e++)n.add(t.slice(0,e).join(`/`));return n}function Oe({assistantId:e}){let[t,n]=r(),[i,a]=(0,Y.useState)(()=>{let e=t.get(`file`);return e?$(e):new Set}),[o,s]=(0,Y.useState)(()=>t.get(`file`)),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(()=>t.get(`sort`)===`size`?`size`:`name`),[f,p]=(0,Y.useState)(`preview`);(0,Y.useEffect)(()=>{let e=t.get(`file`);e&&(s(e),a(t=>{let n=new Set(t);for(let t of $(e))n.add(t);return n.size===t.size?t:n}),n(e=>{let t=new URLSearchParams(e);return t.delete(`file`),t},{replace:!0}))},[t,n]);let m=(0,Y.useCallback)(e=>{a(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),h=(0,Y.useCallback)(e=>{a(t=>{if(t.has(e))return t;let n=new Set(t);return n.add(e),n})},[]),[g,_]=(0,Y.useState)(!1),v=(0,Y.useCallback)(e=>{s(e),_(!1)},[]),[y,b]=(0,Y.useState)(null),x=(0,Y.useCallback)(e=>{let t=t=>t===e||t.startsWith(`${e}/`);s(e=>e!==null&&t(e)?null:e),a(e=>{let n=new Set([...e].filter(e=>!t(e)));return n.size===e.size?e:n}),b({path:e})},[]),[S,C]=(0,Y.useState)(null),w={assistantId:e,expandedPaths:i,selectedPath:o,showHidden:c,sortMode:u,onToggleExpand:m,onExpandPath:h,onSelectPath:v,onToggleShowHidden:()=>l(e=>!e),onChangeSortMode:d,onPathDeleted:x,onPathRenamed:(0,Y.useCallback)((e,t)=>{let n=n=>n===e?t:n.startsWith(`${e}/`)?t+n.slice(e.length):n;s(e=>e===null?e:n(e)),a(e=>{let t=!1,r=new Set;for(let i of e){let e=n(i);e!==i&&(t=!0),r.add(e)}return t?r:e}),C({from:e,to:t})},[])};return(0,Z.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col gap-4`,children:[(0,Z.jsx)(`div`,{className:`flex items-center sm:hidden`,children:(0,Z.jsx)(ae,{onClick:()=>_(!0)})}),(0,Z.jsx)(oe,{open:g,onClose:()=>_(!1),title:`Files`,children:(0,Z.jsx)(Ee,{...w})}),(0,Z.jsxs)(`div`,{className:`grid min-h-0 flex-1 grid-cols-1 gap-4 sm:grid-cols-[320px_1fr]`,children:[(0,Z.jsx)(`div`,{className:`hidden min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border sm:flex`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,Z.jsx)(Ee,{...w})}),(0,Z.jsx)(`div`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden rounded-xl border`,style:{backgroundColor:`var(--surface-overlay)`,borderColor:`var(--border-base)`},children:(0,Z.jsx)(be,{assistantId:e,selectedPath:o,showHidden:c,viewMode:f,onChangeViewMode:p,onBrowse:()=>_(!0),pathRename:S,pathDelete:y})})]})]})}function ke(){return(0,Z.jsx)(Oe,{assistantId:W()})}export{ke as WorkspacePage};