@qredence/fleet 0.7.1 → 0.7.2

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 (109) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/web/client/assets/{action-swap-roll-BfVrBOVd.js → action-swap-roll-Bek47h-E.js} +1 -1
  3. package/dist/web/client/assets/{alert-dialog-FCppNafx.js → alert-dialog-OoasP5iO.js} +1 -1
  4. package/dist/web/client/assets/{artifacts-panel-C69vz-oo.js → artifacts-panel-DVY0-7X0.js} +1 -1
  5. package/dist/web/client/assets/{badge-DOGhnsYk.js → badge-9wr3qUp1.js} +2 -2
  6. package/dist/web/client/assets/{button-BJyg7l5W.js → button-Bqms7ZKX.js} +1 -1
  7. package/dist/web/client/assets/{card-BScRdZNS.js → card-DPCbcrMK.js} +1 -1
  8. package/dist/web/client/assets/{chat-command-palette-wyZjTNa8.js → chat-command-palette-CXS5eTiy.js} +1 -1
  9. package/dist/web/client/assets/{citations-BhyqbxcZ.js → citations-C7USoVdz.js} +1 -1
  10. package/dist/web/client/assets/{command-Bo31U-UD.js → command-s2yLD3tA.js} +1 -1
  11. package/dist/web/client/assets/{create-project-dialog-SDyXTpl-.js → create-project-dialog-C99_Lyjg.js} +1 -1
  12. package/dist/web/client/assets/{dialog-DLIPvl1s.js → dialog-DuCD5hRq.js} +1 -1
  13. package/dist/web/client/assets/{ease-DKi-MOH5.js → ease-2gsl7ABx.js} +1 -1
  14. package/dist/web/client/assets/{fork-picker-dialog-BDleMADF.js → fork-picker-dialog--dV6TE-9.js} +1 -1
  15. package/dist/web/client/assets/globals-BXtzVIWE.css +2 -0
  16. package/dist/web/client/assets/{index-BARp0bjW.js → index-C2EkVtv5.js} +3 -3
  17. package/dist/web/client/assets/{input-Ce8yLnXY.js → input-DECT4vz2.js} +1 -1
  18. package/dist/web/client/assets/{input-group-BZLQiZOA.js → input-group-CZlz1ygA.js} +1 -1
  19. package/dist/web/client/assets/{ipython-tool-CuSGRhXl.js → ipython-tool-Bs6ESZe1.js} +1 -1
  20. package/dist/web/client/assets/{layout-constants-Bl6XCvhY.js → layout-constants-C4hoW3YP.js} +1 -1
  21. package/dist/web/client/assets/{markdown-yn-nhRzB.js → markdown-B2tpfUKu.js} +2 -2
  22. package/dist/web/client/assets/{markdown-code-DfJbKhL9.js → markdown-code-B5YUmtLX.js} +1 -1
  23. package/dist/web/client/assets/{message-queue-CiptKSb6.js → message-queue-BD2sIUTH.js} +1 -1
  24. package/dist/web/client/assets/{model-selector-list-BHQ-Q8b9.js → model-selector-list-zPZRE3JY.js} +1 -1
  25. package/dist/web/client/assets/{notify-BC0a76VJ.js → notify-mVA6z9Ly.js} +1 -1
  26. package/dist/web/client/assets/{openui-renderer-DrfHxs1t.js → openui-renderer-ByP8yQph.js} +1 -1
  27. package/dist/web/client/assets/{prompt-input-IwZOepG7.js → prompt-input-Bnl0HyL6.js} +1 -1
  28. package/dist/web/client/assets/{prompt-suggestions-BRFWFm5y.js → prompt-suggestions-DcgETXtw.js} +1 -1
  29. package/dist/web/client/assets/{provider-label-DNZOLldn.js → provider-label-COVNyoZo.js} +1 -1
  30. package/dist/web/client/assets/{repl-panel-UQN9UFG7.js → repl-panel-BoDNpJOe.js} +1 -1
  31. package/dist/web/client/assets/{resources-panel-kp_UjnpX.js → resources-panel-DD6iWOF3.js} +1 -1
  32. package/dist/web/client/assets/{right-panel-registry-CF7GLJrk.js → right-panel-registry-CIfLdAfS.js} +2 -2
  33. package/dist/web/client/assets/{routes-DCP1DP1g.js → routes-DO93P3Xm.js} +5 -5
  34. package/dist/web/client/assets/{select-COK0Kaq2.js → select-Dp15z1lf.js} +1 -1
  35. package/dist/web/client/assets/{session-reasoning-panel-DrTWp8d4.js → session-reasoning-panel-WMedZp__.js} +1 -1
  36. package/dist/web/client/assets/session-tool-renderer-BFC3-Md4.js +170 -0
  37. package/dist/web/client/assets/{session-tree-panel-deGRKAhX.js → session-tree-panel-CnHOsPzz.js} +1 -1
  38. package/dist/web/client/assets/{settings-dialog-BU1Tw0CQ.js → settings-dialog-BN138nzK.js} +1 -1
  39. package/dist/web/client/assets/{skeleton-D5Y9nBfp.js → skeleton-DNAr5ULI.js} +1 -1
  40. package/dist/web/client/assets/{skeleton-loaders-DOKGa7CW.js → skeleton-loaders-B28mF4tJ.js} +1 -1
  41. package/dist/web/client/assets/{spinner-C3sPnLdu.js → spinner-CSBXk3Lo.js} +1 -1
  42. package/dist/web/client/assets/{subagent-chat-panel-bVnkDkgs.js → subagent-chat-panel-DYKOKRPp.js} +1 -1
  43. package/dist/web/client/assets/subagent-transcript-BCUhqVvi.js +1 -0
  44. package/dist/web/client/assets/{subagent-utils-D7sXbLsS.js → subagent-utils-CM2qX9BG.js} +2 -2
  45. package/dist/web/client/assets/{subagents-panel-i5-12E1U.js → subagents-panel-CTvtU0Sh.js} +1 -1
  46. package/dist/web/client/assets/{surface-context-DWplCCcO.js → surface-context-VvasJf_6.js} +1 -1
  47. package/dist/web/client/assets/{surfaces-BULKVm-B.js → surfaces-m1vs5aMP.js} +1 -1
  48. package/dist/web/client/assets/{switch-DQETDDJT.js → switch-eqXIzePo.js} +1 -1
  49. package/dist/web/client/assets/{toast-BFeqSeaR.js → toast-DRDVljMF.js} +1 -1
  50. package/dist/web/client/assets/{tool-result-D7HtJ_yg.js → tool-result-DWUV8hEz.js} +1 -1
  51. package/dist/web/client/assets/{tool-timeline-B4ci1oJg.js → tool-timeline-4k2iSEky.js} +1 -1
  52. package/dist/web/client/assets/{use-reduced-motion-BgG7f9xw.js → use-reduced-motion-BzGFRmoG.js} +1 -1
  53. package/dist/web/client/assets/utils-CFDGLzf6.js +1 -0
  54. package/dist/web/client/assets/{workspace-panel-Clbmrdza.js → workspace-panel-BNeGABPi.js} +1 -1
  55. package/dist/web/client/assets/{workspace-path-nav-eVT0rYvv.js → workspace-path-nav-umvkE4ut.js} +2 -2
  56. package/dist/web/client/bundle-budget.json +5 -5
  57. package/dist/web/server/{_tanstack-start-manifest_v-CaT-3S-N-VAOGUHEJ.js → _tanstack-start-manifest_v-DTCFS0PG-ARV2V4FW.js} +26 -26
  58. package/dist/web/server/{artifacts-panel-BuAqeJzj-6DYYLKUW.js → artifacts-panel-Ct2R_4wM-DAPQMI57.js} +13 -13
  59. package/dist/web/server/{chat-command-palette-Ca8gXVi2-P6EOQ43G.js → chat-command-palette-ETZzg35Q-TAV74IAW.js} +8 -8
  60. package/dist/web/server/{chunk-5AYK2KDO.js → chunk-777VIBCH.js} +176 -176
  61. package/dist/web/server/{chunk-7VFULIHV.js → chunk-AAPVQJAD.js} +2 -2
  62. package/dist/web/server/{chunk-K4KN3QBT.js → chunk-BNB7T7P6.js} +2 -2
  63. package/dist/web/server/{chunk-E4YWFQX5.js → chunk-FFGFTGLQ.js} +415 -383
  64. package/dist/web/server/{chunk-GCDOYNXR.js → chunk-FL3FOWSC.js} +30 -30
  65. package/dist/web/server/{chunk-ITKXE2Q5.js → chunk-GS5F6X7H.js} +497 -234
  66. package/dist/web/server/{chunk-B7YWDA2F.js → chunk-INRE3X52.js} +2 -2
  67. package/dist/web/server/{chunk-35AFSKDX.js → chunk-JOCVZVZ3.js} +5 -5
  68. package/dist/web/server/{chunk-J4Y2Z3XM.js → chunk-JU7PCOE7.js} +4 -4
  69. package/dist/web/server/{chunk-UTV66W5H.js → chunk-KVW6XTN3.js} +14 -9
  70. package/dist/web/server/{chunk-NB3TVOGB.js → chunk-LECHJX4M.js} +483 -481
  71. package/dist/web/server/{chunk-JFAUSHBI.js → chunk-M6K66QBV.js} +6 -6
  72. package/dist/web/server/{chunk-COWE2EJ6.js → chunk-R7KUUFDW.js} +4 -4
  73. package/dist/web/server/chunk-SHNODG3C.js +18343 -0
  74. package/dist/web/server/{chunk-PXSOI3XF.js → chunk-SQXJ5TUB.js} +2 -2
  75. package/dist/web/server/{chunk-B5Y7XOIJ.js → chunk-TMQ3MT3D.js} +78 -17
  76. package/dist/web/server/{chunk-M7BTY55G.js → chunk-UWZYLMEH.js} +2 -2
  77. package/dist/web/server/{chunk-YIJ7D7G5.js → chunk-VTEYQNJE.js} +7 -7
  78. package/dist/web/server/{chunk-ABYOWAMD.js → chunk-X76RBZ37.js} +2 -2
  79. package/dist/web/server/{chunk-FPPKECLB.js → chunk-XMAAYUOT.js} +14 -14
  80. package/dist/web/server/{create-project-dialog-DCvdysey-IZUGGDAN.js → create-project-dialog-CqBmLTlA-X6HI6AYR.js} +9 -9
  81. package/dist/web/server/{dist-DVCLWOYT.js → dist-3UIQ7SZN.js} +2 -2
  82. package/dist/web/server/{dist-4A22NBTB.js → dist-ZPEDRNZ4.js} +2 -2
  83. package/dist/web/server/{fork-picker-dialog-QH00XmqX-6YLU5REF.js → fork-picker-dialog-PYNd9ozc-EA7BRLRR.js} +6 -6
  84. package/dist/web/server/{markdown-CShfYRVO-OKGCYPQK.js → markdown-CShfYRVO-22N5LNAN.js} +2 -2
  85. package/dist/web/server/{markdown-code-BDV_2b2T-VZGAECQB.js → markdown-code-BDV_2b2T-KUPHX52W.js} +2 -2
  86. package/dist/web/server/{message-queue-BzEFQR8k-2W53EW32.js → message-queue-DmSFAI5Y-XDZHJ2Z6.js} +6 -6
  87. package/dist/web/server/{model-selector-list-BjoXmw92-TEKBPB3E.js → model-selector-list-C-Y3p5UM-HTSWVVHP.js} +8 -8
  88. package/dist/web/server/{openui-renderer-CJ7Q2zZ_-FPXKZPSO.js → openui-renderer-C4B1EJxC-QDYQF5LD.js} +10 -10
  89. package/dist/web/server/{prompt-suggestions-EqAaAx6L-723M64XJ.js → prompt-suggestions-EqAaAx6L-B4KCWNZX.js} +1 -1
  90. package/dist/web/server/{repl-panel-DOyUyuQR-IMYO4FKX.js → repl-panel-DOyUyuQR-LRBDRMHW.js} +3 -3
  91. package/dist/web/server/{resources-panel-yVB4xF_K-OHFHXVU4.js → resources-panel-Bo-TmRON-O47AKGEQ.js} +7 -7
  92. package/dist/web/server/{router-UgU5vJxm-R33FGTXY.js → router-DtS2wXhd-I2SZV7YF.js} +5 -5
  93. package/dist/web/server/{routes-Cbbo-jh9-ZUPH4SJD.js → routes-DuSYlASY-U7C32ONE.js} +5 -5
  94. package/dist/web/server/server.js +3 -3
  95. package/dist/web/server/{session-reasoning-panel-C50VbaQ8-4YLMVVY6.js → session-reasoning-panel-BFcZs1pZ-KNHSU5GX.js} +7 -7
  96. package/dist/web/server/{session-tool-renderer-QcAkYD-V-6RXRKDH6.js → session-tool-renderer-TiFeeJEc-YUZPEEZ4.js} +9 -9
  97. package/dist/web/server/{session-tree-panel-CL49XSTK-4ZPK6AIV.js → session-tree-panel-CjsqVYLY-DGZBGY2E.js} +6 -6
  98. package/dist/web/server/{settings-dialog-DG9HEZeP-TWDRDGMN.js → settings-dialog-Bj5LrAE8-6BQRLUJT.js} +10 -10
  99. package/dist/web/server/{start-DEejK9Uj-FODAOTAO.js → start-cCC--AXu-BBMIT6OU.js} +1 -1
  100. package/dist/web/server/{subagent-chat-panel-Cg2CxshI-WWGFHTIF.js → subagent-chat-panel-DAS4Ne-1-TWIUXSQC.js} +12 -12
  101. package/dist/web/server/{subagents-panel-aC3Eo-MR-RNIPLCZQ.js → subagents-panel-C3CdUcqw-DFTJTPHA.js} +12 -12
  102. package/dist/web/server/{tool-timeline-C4dgQITK-CFWANSDL.js → tool-timeline-C4dgQITK-IWCLQLWG.js} +3 -3
  103. package/dist/web/server/{workspace-panel-DfdFkgHU-6HIOXRBX.js → workspace-panel-DNs0Ye2U-VFB6X5PK.js} +7 -7
  104. package/package.json +4 -4
  105. package/dist/web/client/assets/globals-DZbMyHfg.css +0 -2
  106. package/dist/web/client/assets/session-tool-renderer-Yu4G1165.js +0 -1389
  107. package/dist/web/client/assets/subagent-transcript-D_L-8PQi.js +0 -1
  108. package/dist/web/client/assets/utils-Dpy9ZFOr.js +0 -1
  109. package/dist/web/server/chunk-PHHC52CO.js +0 -38412
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-Cvdyeg_0.js";import{t as n}from"./jsx-runtime-NZYk81nU.js";import{t as r}from"./button-BJyg7l5W.js";import{t as i}from"./utils-Dpy9ZFOr.js";import{t as a}from"./git-branch-DZEh2mM2.js";import{a as o,i as s,o as c,r as l,s as u,t as d}from"./alert-dialog-FCppNafx.js";var f=e(t(),1),p=n();function m(e,t=0){let n=[];for(let r of e)n.push({node:r,depth:t}),n.push(...m(r.children,t+1));return n}function h({depth:e,isSelected:t,node:n,onSelect:a}){return(0,p.jsxs)(r,{type:`button`,variant:`ghost`,"data-testid":`session-tree-node-${n.id}`,onClick:a,className:i(`h-auto w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left font-normal`,t?`bg-foreground/10 ring-1 ring-foreground/15`:`hover:bg-foreground/6`,n.isOnActiveBranch?`text-foreground/90`:`text-foreground/55`),style:{marginLeft:`${e*12}px`,width:`calc(100% - ${e*12}px)`},children:[(0,p.jsxs)(`span`,{className:`flex items-center gap-1.5 text-label leading-5`,children:[n.isLeaf?(0,p.jsx)(`span`,{"aria-hidden":`true`,className:`font-semibold text-foreground`,children:`*`}):null,(0,p.jsx)(`span`,{className:`truncate font-medium`,children:n.preview})]}),(0,p.jsx)(`span`,{className:`truncate font-mono text-caption text-foreground/40`,children:n.id})]})}function g({sessionId:e,snapshot:t,loading:n,error:i,isStreaming:g,selectedEntryId:_,onSelectEntry:v,onRefresh:y,onRewind:b}){let[x,S]=(0,f.useState)(null),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(!1),[D,O]=(0,f.useState)(null),k=(0,f.useRef)(0),A=(0,f.useMemo)(()=>t?m(t.nodes):[],[t]),j=!!((0,f.useMemo)(()=>A.find(e=>e.node.id===_)?.node,[A,_])&&t&&_&&_!==t.leafId&&!g);(0,f.useEffect)(()=>{if(x===null||T||D===null)return;let e=t?.leafId??null;e!==C&&w(e)},[x,T,D,C,t?.leafId]);let M=(0,f.useCallback)(t=>{if(!(!e||t.messageIndex===void 0))return`${e}-m${t.messageIndex}`},[e]),N=(0,f.useCallback)(()=>{k.current+=1,S(null),w(null),O(null),E(!1)},[]);(0,f.useEffect)(()=>{N()},[e,N]);let P=(0,f.useCallback)(async()=>{let e=x,t=C;if(!e)return;let n=++k.current,r=()=>k.current===n;E(!0),O(null);try{await b(e,t),r()&&N()}catch(e){r()&&O(e instanceof Error?e.message:String(e))}finally{r()&&E(!1)}},[N,x,C,b]),F=(0,f.useCallback)(e=>{O(null),S(e),w(t?.leafId??null)},[t?.leafId]);return e?(0,p.jsxs)(`section`,{"aria-label":`Session tree`,className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2 text-label text-foreground/70`,children:[(0,p.jsx)(a,{className:`size-4`,"aria-hidden":`true`}),(0,p.jsx)(`span`,{children:`Branch history`})]}),(0,p.jsx)(r,{type:`button`,size:`compact`,variant:`outline`,onClick:y,disabled:n,children:`Refresh`})]}),i?(0,p.jsx)(`p`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-label text-destructive`,children:i}):null,g?(0,p.jsx)(`p`,{className:`rounded-md border border-border/60 bg-background px-3 py-2 text-label text-foreground/60`,children:`Finish or stop the current turn before rewinding.`}):null,(0,p.jsxs)(`div`,{"data-testid":`session-tree-list`,className:`flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto rounded-md border border-border/60 bg-background p-2`,children:[n&&A.length===0?(0,p.jsx)(`p`,{className:`px-2 py-3 text-label text-foreground/45`,children:`Loading session tree…`}):null,!n&&A.length===0?(0,p.jsx)(`p`,{className:`px-2 py-3 text-label text-foreground/45`,children:`No branch entries yet.`}):null,A.map(({node:e,depth:t})=>(0,p.jsx)(h,{depth:t,node:e,isSelected:e.id===_,onSelect:()=>v(e.id,M(e))},e.id))]}),(0,p.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,p.jsxs)(`p`,{className:`text-caption text-foreground/45`,children:[(0,p.jsx)(`span`,{"aria-hidden":`true`,children:`*`}),` marks the current leaf on the active branch.`]}),(0,p.jsx)(r,{type:`button`,size:`compact`,disabled:!j,onClick:()=>_&&F(_),children:`Rewind here`})]}),(0,p.jsx)(d,{open:x!==null,onOpenChange:e=>{!e&&!T&&N()},children:(0,p.jsxs)(s,{children:[(0,p.jsx)(u,{children:`Rewind session?`}),(0,p.jsx)(o,{children:`Later turns on the current branch leave the active session. Rewinding to a user turn follows Prime Agent edit-from-here semantics: the leaf moves to that message's parent so you can resend from there.`}),D?(0,p.jsx)(`p`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-label text-destructive`,children:D}):null,(0,p.jsxs)(c,{children:[(0,p.jsx)(l,{disabled:T,children:`Cancel`}),(0,p.jsx)(r,{type:`button`,variant:`destructive`,disabled:T,onClick:()=>void P(),children:T?`Rewinding…`:`Rewind`})]})]})})]}):(0,p.jsx)(`section`,{"aria-label":`Session tree`,className:`flex min-h-36 items-center rounded-md border border-dashed border-border/70 px-4 text-center text-label leading-5 text-foreground/45`,children:`Start or open a session to browse its branch history.`})}export{g as SessionTreePanel};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-Cvdyeg_0.js";import{t as n}from"./jsx-runtime-NZYk81nU.js";import{t as r}from"./button-Bqms7ZKX.js";import{t as i}from"./utils-CFDGLzf6.js";import{t as a}from"./git-branch-DZEh2mM2.js";import{a as o,i as s,o as c,r as l,s as u,t as d}from"./alert-dialog-OoasP5iO.js";var f=e(t(),1),p=n();function m(e,t=0){let n=[];for(let r of e)n.push({node:r,depth:t}),n.push(...m(r.children,t+1));return n}function h({depth:e,isSelected:t,node:n,onSelect:a}){return(0,p.jsxs)(r,{type:`button`,variant:`ghost`,"data-testid":`session-tree-node-${n.id}`,onClick:a,className:i(`h-auto w-full flex-col items-start gap-0.5 rounded-md px-2 py-1.5 text-left font-normal`,t?`bg-foreground/10 ring-1 ring-foreground/15`:`hover:bg-foreground/6`,n.isOnActiveBranch?`text-foreground/90`:`text-foreground/55`),style:{marginLeft:`${e*12}px`,width:`calc(100% - ${e*12}px)`},children:[(0,p.jsxs)(`span`,{className:`flex items-center gap-1.5 text-label leading-5`,children:[n.isLeaf?(0,p.jsx)(`span`,{"aria-hidden":`true`,className:`font-semibold text-foreground`,children:`*`}):null,(0,p.jsx)(`span`,{className:`truncate font-medium`,children:n.preview})]}),(0,p.jsx)(`span`,{className:`truncate font-mono text-caption text-foreground/40`,children:n.id})]})}function g({sessionId:e,snapshot:t,loading:n,error:i,isStreaming:g,selectedEntryId:_,onSelectEntry:v,onRefresh:y,onRewind:b}){let[x,S]=(0,f.useState)(null),[C,w]=(0,f.useState)(null),[T,E]=(0,f.useState)(!1),[D,O]=(0,f.useState)(null),k=(0,f.useRef)(0),A=(0,f.useMemo)(()=>t?m(t.nodes):[],[t]),j=!!((0,f.useMemo)(()=>A.find(e=>e.node.id===_)?.node,[A,_])&&t&&_&&_!==t.leafId&&!g);(0,f.useEffect)(()=>{if(x===null||T||D===null)return;let e=t?.leafId??null;e!==C&&w(e)},[x,T,D,C,t?.leafId]);let M=(0,f.useCallback)(t=>{if(!(!e||t.messageIndex===void 0))return`${e}-m${t.messageIndex}`},[e]),N=(0,f.useCallback)(()=>{k.current+=1,S(null),w(null),O(null),E(!1)},[]);(0,f.useEffect)(()=>{N()},[e,N]);let P=(0,f.useCallback)(async()=>{let e=x,t=C;if(!e)return;let n=++k.current,r=()=>k.current===n;E(!0),O(null);try{await b(e,t),r()&&N()}catch(e){r()&&O(e instanceof Error?e.message:String(e))}finally{r()&&E(!1)}},[N,x,C,b]),F=(0,f.useCallback)(e=>{O(null),S(e),w(t?.leafId??null)},[t?.leafId]);return e?(0,p.jsxs)(`section`,{"aria-label":`Session tree`,className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,p.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,p.jsxs)(`div`,{className:`flex items-center gap-2 text-label text-foreground/70`,children:[(0,p.jsx)(a,{className:`size-4`,"aria-hidden":`true`}),(0,p.jsx)(`span`,{children:`Branch history`})]}),(0,p.jsx)(r,{type:`button`,size:`compact`,variant:`outline`,onClick:y,disabled:n,children:`Refresh`})]}),i?(0,p.jsx)(`p`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-label text-destructive`,children:i}):null,g?(0,p.jsx)(`p`,{className:`rounded-md border border-border/60 bg-background px-3 py-2 text-label text-foreground/60`,children:`Finish or stop the current turn before rewinding.`}):null,(0,p.jsxs)(`div`,{"data-testid":`session-tree-list`,className:`flex min-h-0 flex-1 flex-col gap-1 overflow-y-auto rounded-md border border-border/60 bg-background p-2`,children:[n&&A.length===0?(0,p.jsx)(`p`,{className:`px-2 py-3 text-label text-foreground/45`,children:`Loading session tree…`}):null,!n&&A.length===0?(0,p.jsx)(`p`,{className:`px-2 py-3 text-label text-foreground/45`,children:`No branch entries yet.`}):null,A.map(({node:e,depth:t})=>(0,p.jsx)(h,{depth:t,node:e,isSelected:e.id===_,onSelect:()=>v(e.id,M(e))},e.id))]}),(0,p.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,p.jsxs)(`p`,{className:`text-caption text-foreground/45`,children:[(0,p.jsx)(`span`,{"aria-hidden":`true`,children:`*`}),` marks the current leaf on the active branch.`]}),(0,p.jsx)(r,{type:`button`,size:`compact`,disabled:!j,onClick:()=>_&&F(_),children:`Rewind here`})]}),(0,p.jsx)(d,{open:x!==null,onOpenChange:e=>{!e&&!T&&N()},children:(0,p.jsxs)(s,{children:[(0,p.jsx)(u,{children:`Rewind session?`}),(0,p.jsx)(o,{children:`Later turns on the current branch leave the active session. Rewinding to a user turn follows Prime Agent edit-from-here semantics: the leaf moves to that message's parent so you can resend from there.`}),D?(0,p.jsx)(`p`,{className:`rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-label text-destructive`,children:D}):null,(0,p.jsxs)(c,{children:[(0,p.jsx)(l,{disabled:T,children:`Cancel`}),(0,p.jsx)(r,{type:`button`,variant:`destructive`,disabled:T,onClick:()=>void P(),children:T?`Rewinding…`:`Rewind`})]})]})})]}):(0,p.jsx)(`section`,{"aria-label":`Session tree`,className:`flex min-h-36 items-center rounded-md border border-dashed border-border/70 px-4 text-center text-label leading-5 text-foreground/45`,children:`Start or open a session to browse its branch history.`})}export{g as SessionTreePanel};
@@ -1,2 +1,2 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-Cvdyeg_0.js";import{t as n}from"./jsx-runtime-NZYk81nU.js";import{J as r,X as i,et as a,n as o,q as s,t as c}from"./button-BJyg7l5W.js";import{t as l}from"./utils-Dpy9ZFOr.js";import{P as u,T as d,et as f,nt as p,rt as m}from"./createBaseUIEventDetails-DklXWq23.js";import{r as h}from"./toast-BFeqSeaR.js";import{N as g,S as _,_ as v,a as y,c as b,g as x,r as S,t as C,v as w}from"./select-COK0Kaq2.js";import{t as T}from"./useBaseUiId-BlzQUkVG.js";import{t as E}from"./createLucideIcon-CQY2ECfR.js";import{a as D,i as O,n as k,o as A,r as j,s as M,t as N}from"./provider-label-DNZOLldn.js";import{t as P}from"./check-BTwIaCtI.js";import{t as F}from"./chevron-right-BPCB1mOg.js";import{i as I,r as L,t as R}from"./sparkles-C4VQyMox.js";import{t as z}from"./eye-iNSvs0UA.js";import{t as B}from"./hard-drive-B3opVeEB.js";import{i as ee,n as V,r as H,t as U}from"./sun-C7zg8Oas.js";import{t as te}from"./loader-circle-BmKYM_C4.js";import{t as W}from"./pencil-Cbgq3ybX.js";import{t as ne}from"./plug-wCz-036u.js";import{a as G,n as re,r as ie}from"./right-panel-context-DHKWoetk.js";import{t as ae}from"./refresh-cw-CqPE3kNY.js";import{t as oe}from"./rotate-ccw-DLkfsmG9.js";import{t as K}from"./search-Cb6fFWew.js";import{a as se,n as ce,r as le}from"./ui-preferences-1YaENqef.js";import{a as q,c as ue,i as de,n as J,r as fe,s as pe,t as me}from"./switch-DQETDDJT.js";import{a as he,n as ge,o as _e,r as ve,t as ye}from"./dialog-DLIPvl1s.js";import{t as be}from"./input-Ce8yLnXY.js";import{a as xe,i as Se,n as Ce,r as we,t as Te}from"./input-group-BZLQiZOA.js";import{c as Ee,f as De,l as Oe,o as ke}from"./tokens-CtP2s1Y3.js";import{t as Y}from"./notify-BC0a76VJ.js";import{t as X}from"./spinner-C3sPnLdu.js";import{a as Ae,i as je,n as Me,o as Ne,r as Pe,s as Fe,t as Ie}from"./alert-dialog-FCppNafx.js";var Le={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};Le.node;var Re=E(Le),ze={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};ze.node;var Be=E(ze),Ve={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Ve.node;var He=E(Ve),Ue={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Ue.node;var We=E(Ue),Ge={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};Ge.node;var Ke=E(Ge),qe={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};qe.node;var Je=E(qe),Ye={name:`paintbrush`,size:24,node:[[`path`,{d:`m14.622 17.897-10.68-2.913`,key:`vj2p1u`}],[`path`,{d:`M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z`,key:`18tc5c`}],[`path`,{d:`M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15`,key:`ytzfxy`}]]};Ye.node;var Xe=E(Ye),Ze={name:`save`,size:24,node:[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]};Ze.node;var Qe=E(Ze),$e={name:`star`,size:24,node:[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]};$e.node;var et=E($e),tt={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};tt.node;var nt=E(tt),rt={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};rt.node;var it=E(rt),Z=e(t(),1),Q=n(),at=new Set([`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]),ot=new Map,st=500;function ct(e){let t=ot.get(e);if(t)return t;let n=RegExp(`^${e.split(``).map(e=>e===`*`?`.*`:e===`?`?`.`:pt(e)).join(``)}$`);return ot.size>=st&&ot.clear(),ot.set(e,n),n}function lt(e,t){return t===void 0||t.length!==0&&t.some(t=>ut(e,t))}function ut(e,t){let n=dt(t.trim()).toLowerCase(),r=[e.id,e.modelId,e.name,e.key,e.provider&&e.modelId?`${e.provider}/${e.modelId}`:void 0,e.provider&&e.id?`${e.provider}/${e.id}`:void 0].filter(e=>typeof e==`string`).map(e=>e.toLowerCase());if(!ft(n))return r.includes(n);let i=ct(n);return r.some(e=>i.test(e))}function dt(e){let t=e.lastIndexOf(`:`);if(t===-1)return e;let n=e.slice(t+1);return at.has(n)?e.slice(0,t):e}function ft(e){return e.includes(`*`)||e.includes(`?`)}function pt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function mt(e,t){return`${e}/${t}`}function ht(e,t,n=!0){return t&&n&&e.trim().length===0}function gt({attemptedSave:e,label:t,onChange:n,onToggleVisibility:r,placeholder:i,required:a=!0,showPassword:o,value:s}){let c=(0,Z.useId)(),u=ht(s,e,a);return(0,Q.jsxs)(J,{"data-invalid":u||void 0,children:[(0,Q.jsx)(q,{htmlFor:c,children:t}),(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ce,{align:`inline-start`,children:(0,Q.jsx)(Ke,{})}),(0,Q.jsx)(Se,{id:c,type:o?`text`:`password`,placeholder:i,value:s,onChange:e=>n(e.target.value),"aria-label":t,"aria-invalid":u||void 0}),(0,Q.jsx)(Ce,{align:`inline-end`,children:(0,Q.jsx)(we,{size:`icon-xs`,className:l(Ee,`transition-[background-color,transform] duration-150 active:scale-[0.96]`),"aria-label":o?`Hide value`:`Show value`,onClick:r,children:o?(0,Q.jsx)(Be,{}):(0,Q.jsx)(z,{})})})]})]})}function _t({attemptedSave:e,icon:t,inputType:n=`text`,label:r,onChange:i,placeholder:a,required:o=!0,value:s}){let c=(0,Z.useId)(),l=ht(s,e,o);return(0,Q.jsxs)(J,{"data-invalid":l||void 0,children:[(0,Q.jsx)(q,{htmlFor:c,children:r}),(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ce,{align:`inline-start`,children:(0,Q.jsx)(t,{})}),(0,Q.jsx)(Se,{id:c,type:n,placeholder:a,value:s,onChange:e=>i(e.target.value),"aria-label":r,"aria-invalid":l||void 0})]})]})}function vt({children:e,className:t,description:n,icon:r,label:i,trailing:a}){let o=a??e;return(0,Q.jsxs)(J,{orientation:`horizontal`,className:l(`items-center justify-between gap-6 rounded-xl border border-border/60 bg-card p-4 transition-colors`,t),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[r?(0,Q.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-md border border-border/40 bg-background/60 text-foreground/70`,children:r}):null,(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(q,{className:`text-sm font-medium text-foreground`,children:i}),n?(0,Q.jsx)(fe,{className:`mt-0.5 text-xs text-muted-foreground leading-normal`,children:n}):null]})]}),o?(0,Q.jsx)(`div`,{className:`shrink-0`,children:o}):null]})}var yt={unconfigured:`Add a key below to turn this on.`,unverified:`Checking the key…`,ready:`Ready.`,error:`The TypeSafe key could not be verified.`},bt={settings:`Using the key saved here.`,environment:`Using TYPESAFE_API_KEY from the server environment.`,none:`No key is set.`};function xt({enabled:e,keySource:t,status:n,onClearKey:r,onEnabledChange:i,onSaveKey:a}){let[o,s]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),_=(0,Z.useCallback)(async()=>{if(f(!0),m(null),!(!o.trim()||!a)){g(!0);try{await a(o.trim()),s(``),u(!1),f(!1)}catch(e){m(e instanceof Error?e.message:`Failed to save key`)}finally{g(!1)}}},[o,a]),v=(0,Z.useCallback)(async()=>{if(r){g(!0),m(null);try{await r(),s(``)}catch(e){m(e instanceof Error?e.message:`Failed to remove key`)}finally{g(!1)}}},[r]),y=n===`unconfigured`||n===`error`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(vt,{label:`Describe a command`,description:`Recognise when a message is really asking for a built-in command, like "compact this" or "show the shortcuts". Messages you send are shared with TypeSafe for classification only when this is on. ${yt[n]}`,trailing:(0,Q.jsx)(me,{"aria-label":`Describe a command`,checked:e,disabled:!i||!e&&y,onCheckedChange:i})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl border p-4`,children:[(0,Q.jsx)(gt,{attemptedSave:d,label:`TypeSafe API key`,onChange:e=>{s(e),p&&m(null)},onToggleVisibility:()=>u(e=>!e),placeholder:`Paste your TypeSafe API key`,showPassword:l,value:o}),p?(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:p}):null,(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:bt[t]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(c,{type:`button`,size:`compact`,disabled:h||!o.trim(),onClick:()=>void _(),children:`Save key`}),t===`settings`?(0,Q.jsx)(c,{type:`button`,variant:`outline`,size:`compact`,disabled:h,onClick:()=>void v(),children:`Remove key`}):null]})]})]})}function St({className:e,interactive:t,padding:n,tone:r,...i}){return(0,Q.jsx)(`div`,{className:l(De({interactive:t,padding:n,tone:r}),e),...i})}function $({icon:e,title:t,subtitle:n,trailing:r,className:i,interactive:a=!0,tone:o=`default`,truncateSubtitle:s=!0,truncateTitle:c=!0}){return(0,Q.jsxs)(St,{tone:o,padding:`md`,interactive:a,className:l(`items-center gap-3`,i),children:[e?(0,Q.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-md border border-border/40 bg-background/60 text-foreground/70`,children:e}):null,(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:l(`text-sm font-medium text-foreground`,c&&`truncate`),children:t}),n?(0,Q.jsx)(`div`,{className:l(`mt-0.5 text-xs text-muted-foreground`,s?`truncate`:`leading-normal`),children:n}):null]}),r?(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:r}):null]})}function Ct({actions:e,children:t,description:n,title:r}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-medium text-balance`,children:r}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-pretty text-muted-foreground`,children:n})]}),e?(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5 pt-0.5`,children:e}):null]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})]})}function wt({dirty:e,disabled:t,onRevert:n,onSave:r,saving:i}){return(0,Q.jsxs)(Q.Fragment,{children:[e?(0,Q.jsx)(c,{type:`button`,variant:`ghost`,size:`icon-compact`,className:`text-muted-foreground transition-transform active:scale-[0.96]`,disabled:t||i,onClick:n,"aria-label":`Revert changes`,children:(0,Q.jsx)(oe,{})}):null,(0,Q.jsxs)(c,{type:`button`,variant:`outline`,size:`compact`,className:l(ke,`transition-transform active:scale-[0.96]`,e&&`border-primary/30 text-primary`),disabled:!e||t||i,onClick:r,children:[i?(0,Q.jsx)(te,{className:`animate-spin`,"data-icon":`inline-start`}):(0,Q.jsx)(Qe,{"data-icon":`inline-start`}),`Commit`]})]})}var Tt=1500,Et=`Unknown or expired OAuth login`;function Dt(e){return new Promise(t=>{setTimeout(t,e)})}function Ot({onConfigured:e,onOAuthLogin:t,providerId:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),l=(0,Z.useRef)(null),u=(0,Z.useRef)(0),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(t),p=(0,Z.useRef)(e),m=(0,Z.useRef)(n);(0,Z.useEffect)(()=>{f.current=t,p.current=e,m.current=n},[e,t,n]);let h=(0,Z.useCallback)(async e=>{if(!(!e||!f.current))try{await f.current({providerId:m.current,loginId:e,cancel:!0})}catch{}},[]),g=(0,Z.useCallback)(()=>{l.current=null,d.current=!1,i(null),c(``),o(!1)},[]);(0,Z.useEffect)(()=>()=>{u.current+=1;let e=l.current;l.current=null,h(e)},[h]);let _=(0,Z.useCallback)((e,t)=>{if(t!==u.current){e.status===`waiting`&&e.loginId&&h(e.loginId);return}if(e.status===`success`){l.current=null,i(null),c(``),o(!1),Y.success(`Provider credentials applied to your active sessions.`),p.current?.();return}if(e.status===`error`){if(e.error===Et&&l.current===null)return;let t=l.current;l.current=null,t&&e.error!==`Login cancelled`&&h(t),i(e),o(!1);return}e.loginId&&(l.current=e.loginId),i(e)},[h]),v=(0,Z.useCallback)(async()=>{if(!f.current||d.current)return;d.current=!0;let e=u.current;o(!0);let t=l.current;if(l.current=null,i(null),await h(t),e!==u.current){d.current=!1;return}try{let t=await f.current({providerId:m.current});_(t,e)}catch(t){if(e!==u.current)return;i({status:`error`,error:t instanceof Error?t.message:`Failed to start OAuth sign-in`})}finally{d.current=!1,e===u.current&&o(!1)}},[_,h]),y=(0,Z.useCallback)(async()=>{let e=l.current;if(!f.current||!e)return;let t=u.current;o(!0);try{let n=await f.current({providerId:m.current,loginId:e,promptAnswer:s});c(``),_(n,t)}catch(e){if(t!==u.current)return;Y.error(e instanceof Error?e.message:`Failed to continue OAuth sign-in`)}finally{t===u.current&&o(!1)}},[_,s]),b=(0,Z.useCallback)(async()=>{u.current+=1;let e=l.current;g(),await h(e)},[h,g]);return(0,Z.useEffect)(()=>{if(!f.current||r?.status!==`waiting`||!r.loginId)return;let e=u.current,t=r.loginId,n=!1;return(async()=>{for(;!n;){try{let r=await f.current({providerId:m.current,loginId:t});if(n||e!==u.current||(_(r,e),r.status!==`waiting`))return}catch(r){if(n||e!==u.current||l.current!==t)return;l.current=null,h(t),i({status:`error`,error:r instanceof Error?r.message:`OAuth sign-in failed`});return}if(await Dt(Tt),n||e!==u.current||l.current!==t)return}})(),()=>{n=!0}},[_,h,r?.loginId,r?.status]),{busy:a,cancel:b,canStart:!!t,login:r,promptAnswer:s,setPromptAnswer:c,start:v,submitPrompt:y}}function kt({onConfigured:e,onOAuthLogin:t,provider:n}){let{busy:r,cancel:i,canStart:a,login:o,promptAnswer:s,setPromptAnswer:l,start:u,submitPrompt:d}=Ot({onConfigured:e,onOAuthLogin:t,providerId:n.id}),f=o?.status===`waiting`,p=o?.status===`error`?o.error:void 0,m=f?o?.authUrl:void 0,h=f?o?.userCode:void 0,g=f?o?.instructions:void 0,_=f?o?.prompt:void 0,v=n.authType===`oauth`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n.isConfigured&&v&&!f?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(P,{className:`size-3.5 text-muted-foreground`}),(0,Q.jsx)(`span`,{children:`Connected`})]}):null,f?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Sign in with `,n.name,` to store OAuth credentials for this account.`]}),h?(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Enter this code: `,(0,Q.jsx)(`span`,{className:`font-mono text-foreground`,children:h})]}):null,g&&!h?(0,Q.jsx)(`p`,{className:`text-xs text-pretty text-muted-foreground`,children:g}):null,m?(0,Q.jsxs)(c,{type:`button`,size:`compact`,onClick:()=>{window.open(m,`_blank`,`noopener,noreferrer`)},children:[(0,Q.jsx)(I,{"data-icon":`inline-start`}),`Open sign-in page`]}):_?null:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(X,{className:`size-3`}),`Waiting for sign-in…`]}),_?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-pretty text-muted-foreground`,children:_.message}),(0,Q.jsx)(be,{value:s,placeholder:_.placeholder,onChange:e=>l(e.target.value),"aria-label":_.message}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(c,{type:`button`,size:`compact`,disabled:r||!_.allowEmpty&&!s.trim(),onClick:()=>{d()},children:[r?(0,Q.jsx)(X,{"data-icon":`inline-start`}):null,`Continue`]})})]}):null,(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,disabled:r,onClick:()=>{i()},children:`Cancel sign-in`})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[p?(0,Q.jsx)(pe,{className:`px-3 py-2`,children:(0,Q.jsx)(ue,{className:`text-xs text-pretty`,children:p})}):(0,Q.jsx)(`p`,{className:`text-xs text-pretty text-muted-foreground`,children:v&&n.isConfigured?`Sign in again with ${n.name} to refresh OAuth credentials.`:v?`Sign in with ${n.name}. No API key is stored; credentials are saved to auth.json.`:`Sign in with ${n.name} to use OAuth credentials; API-key editing remains available above.`}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(c,{type:`button`,size:`compact`,disabled:r||!a,onClick:()=>{u()},children:[r?(0,Q.jsx)(X,{"data-icon":`inline-start`}):null,`Sign in with `,n.name]})})]})]})}function At(e){switch(e.status){case`connected`:return`Connected`;case`anonymous`:return`Available without sign-in`;case`needs_auth`:return`Sign-in required`;case`disabled`:return`Disabled`;default:return e.status}}function jt(e){let t=e.transport===`http`?e.url:e.commandPreview;return[e.source===`builtin`?`Built-in`:`User`,e.transport===`http`?`HTTP`:`stdio`,At(e),t].filter(e=>!!e).join(` · `)}function Mt({connections:e,isLoading:t,isPending:n,onOAuth:r,onRemove:i,onUpsert:a}){let[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`http`),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(!0),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(``),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(``),[k,A]=(0,Z.useState)(null),j=()=>{f(``),m(``),g(!0),v(``),b(``),S(``),T(``),D(``),u(`http`),s(!1)},M=async()=>{if(!a)return;let e=d.trim();try{if(l===`http`)await a({name:e,transport:`http`,url:p.trim(),...h?{oauth:!0}:{},..._.trim()?{bearerTokenEnvVar:_.trim()}:{},force:!0});else{let t=x.split(/\s+/).map(e=>e.trim()).filter(Boolean),n=E.split(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-Cvdyeg_0.js";import{t as n}from"./jsx-runtime-NZYk81nU.js";import{J as r,X as i,et as a,n as o,q as s,t as c}from"./button-Bqms7ZKX.js";import{t as l}from"./utils-CFDGLzf6.js";import{P as u,T as d,et as f,nt as p,rt as m}from"./createBaseUIEventDetails-DklXWq23.js";import{r as h}from"./toast-DRDVljMF.js";import{N as g,S as _,_ as v,a as y,c as b,g as x,r as S,t as C,v as w}from"./select-Dp15z1lf.js";import{t as T}from"./useBaseUiId-BlzQUkVG.js";import{t as E}from"./createLucideIcon-CQY2ECfR.js";import{a as D,i as O,n as k,o as A,r as j,s as M,t as N}from"./provider-label-COVNyoZo.js";import{t as P}from"./check-BTwIaCtI.js";import{t as F}from"./chevron-right-BPCB1mOg.js";import{i as I,r as L,t as R}from"./sparkles-C4VQyMox.js";import{t as z}from"./eye-iNSvs0UA.js";import{t as B}from"./hard-drive-B3opVeEB.js";import{i as ee,n as V,r as H,t as U}from"./sun-C7zg8Oas.js";import{t as te}from"./loader-circle-BmKYM_C4.js";import{t as W}from"./pencil-Cbgq3ybX.js";import{t as ne}from"./plug-wCz-036u.js";import{a as G,n as re,r as ie}from"./right-panel-context-DHKWoetk.js";import{t as ae}from"./refresh-cw-CqPE3kNY.js";import{t as oe}from"./rotate-ccw-DLkfsmG9.js";import{t as K}from"./search-Cb6fFWew.js";import{a as se,n as ce,r as le}from"./ui-preferences-1YaENqef.js";import{a as q,c as ue,i as de,n as J,r as fe,s as pe,t as me}from"./switch-eqXIzePo.js";import{a as he,n as ge,o as _e,r as ve,t as ye}from"./dialog-DuCD5hRq.js";import{t as be}from"./input-DECT4vz2.js";import{a as xe,i as Se,n as Ce,r as we,t as Te}from"./input-group-CZlz1ygA.js";import{c as Ee,f as De,l as Oe,o as ke}from"./tokens-CtP2s1Y3.js";import{t as Y}from"./notify-mVA6z9Ly.js";import{t as X}from"./spinner-CSBXk3Lo.js";import{a as Ae,i as je,n as Me,o as Ne,r as Pe,s as Fe,t as Ie}from"./alert-dialog-OoasP5iO.js";var Le={name:`box`,size:24,node:[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]};Le.node;var Re=E(Le),ze={name:`eye-off`,size:24,node:[[`path`,{d:`M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49`,key:`ct8e1f`}],[`path`,{d:`M14.084 14.158a3 3 0 0 1-4.242-4.242`,key:`151rxh`}],[`path`,{d:`M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143`,key:`13bj9a`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}]]};ze.node;var Be=E(ze),Ve={name:`key-round`,size:24,node:[[`path`,{d:`M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z`,key:`1s6t7t`}],[`circle`,{cx:`16.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`w0ekpg`}]]};Ve.node;var He=E(Ve),Ue={name:`layers`,size:24,node:[[`path`,{d:`M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z`,key:`zw3jo`}],[`path`,{d:`M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12`,key:`1wduqc`}],[`path`,{d:`M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17`,key:`kqbvx6`}]],aliases:[`layers-3`]};Ue.node;var We=E(Ue),Ge={name:`lock`,size:24,node:[[`rect`,{width:`18`,height:`11`,x:`3`,y:`11`,rx:`2`,ry:`2`,key:`1w4ew1`}],[`path`,{d:`M7 11V7a5 5 0 0 1 10 0v4`,key:`fwvmzm`}]]};Ge.node;var Ke=E(Ge),qe={name:`message-square`,size:24,node:[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]};qe.node;var Je=E(qe),Ye={name:`paintbrush`,size:24,node:[[`path`,{d:`m14.622 17.897-10.68-2.913`,key:`vj2p1u`}],[`path`,{d:`M18.376 2.622a1 1 0 1 1 3.002 3.002L17.36 9.643a.5.5 0 0 0 0 .707l.944.944a2.41 2.41 0 0 1 0 3.408l-.944.944a.5.5 0 0 1-.707 0L8.354 7.348a.5.5 0 0 1 0-.707l.944-.944a2.41 2.41 0 0 1 3.408 0l.944.944a.5.5 0 0 0 .707 0z`,key:`18tc5c`}],[`path`,{d:`M9 8c-1.804 2.71-3.97 3.46-6.583 3.948a.507.507 0 0 0-.302.819l7.32 8.883a1 1 0 0 0 1.185.204C12.735 20.405 16 16.792 16 15`,key:`ytzfxy`}]]};Ye.node;var Xe=E(Ye),Ze={name:`save`,size:24,node:[[`path`,{d:`M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z`,key:`1c8476`}],[`path`,{d:`M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7`,key:`1ydtos`}],[`path`,{d:`M7 3v4a1 1 0 0 0 1 1h7`,key:`t51u73`}]]};Ze.node;var Qe=E(Ze),$e={name:`star`,size:24,node:[[`path`,{d:`M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z`,key:`r04s7s`}]]};$e.node;var et=E($e),tt={name:`tag`,size:24,node:[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]};tt.node;var nt=E(tt),rt={name:`users`,size:24,node:[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]};rt.node;var it=E(rt),Z=e(t(),1),Q=n(),at=new Set([`off`,`minimal`,`low`,`medium`,`high`,`xhigh`,`max`]),ot=new Map,st=500;function ct(e){let t=ot.get(e);if(t)return t;let n=RegExp(`^${e.split(``).map(e=>e===`*`?`.*`:e===`?`?`.`:pt(e)).join(``)}$`);return ot.size>=st&&ot.clear(),ot.set(e,n),n}function lt(e,t){return t===void 0||t.length!==0&&t.some(t=>ut(e,t))}function ut(e,t){let n=dt(t.trim()).toLowerCase(),r=[e.id,e.modelId,e.name,e.key,e.provider&&e.modelId?`${e.provider}/${e.modelId}`:void 0,e.provider&&e.id?`${e.provider}/${e.id}`:void 0].filter(e=>typeof e==`string`).map(e=>e.toLowerCase());if(!ft(n))return r.includes(n);let i=ct(n);return r.some(e=>i.test(e))}function dt(e){let t=e.lastIndexOf(`:`);if(t===-1)return e;let n=e.slice(t+1);return at.has(n)?e.slice(0,t):e}function ft(e){return e.includes(`*`)||e.includes(`?`)}function pt(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function mt(e,t){return`${e}/${t}`}function ht(e,t,n=!0){return t&&n&&e.trim().length===0}function gt({attemptedSave:e,label:t,onChange:n,onToggleVisibility:r,placeholder:i,required:a=!0,showPassword:o,value:s}){let c=(0,Z.useId)(),u=ht(s,e,a);return(0,Q.jsxs)(J,{"data-invalid":u||void 0,children:[(0,Q.jsx)(q,{htmlFor:c,children:t}),(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ce,{align:`inline-start`,children:(0,Q.jsx)(Ke,{})}),(0,Q.jsx)(Se,{id:c,type:o?`text`:`password`,placeholder:i,value:s,onChange:e=>n(e.target.value),"aria-label":t,"aria-invalid":u||void 0}),(0,Q.jsx)(Ce,{align:`inline-end`,children:(0,Q.jsx)(we,{size:`icon-xs`,className:l(Ee,`transition-[background-color,transform] duration-150 active:scale-[0.96]`),"aria-label":o?`Hide value`:`Show value`,onClick:r,children:o?(0,Q.jsx)(Be,{}):(0,Q.jsx)(z,{})})})]})]})}function _t({attemptedSave:e,icon:t,inputType:n=`text`,label:r,onChange:i,placeholder:a,required:o=!0,value:s}){let c=(0,Z.useId)(),l=ht(s,e,o);return(0,Q.jsxs)(J,{"data-invalid":l||void 0,children:[(0,Q.jsx)(q,{htmlFor:c,children:r}),(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ce,{align:`inline-start`,children:(0,Q.jsx)(t,{})}),(0,Q.jsx)(Se,{id:c,type:n,placeholder:a,value:s,onChange:e=>i(e.target.value),"aria-label":r,"aria-invalid":l||void 0})]})]})}function vt({children:e,className:t,description:n,icon:r,label:i,trailing:a}){let o=a??e;return(0,Q.jsxs)(J,{orientation:`horizontal`,className:l(`items-center justify-between gap-6 rounded-xl border border-border/60 bg-card p-4 transition-colors`,t),children:[(0,Q.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-start gap-3`,children:[r?(0,Q.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-md border border-border/40 bg-background/60 text-foreground/70`,children:r}):null,(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(q,{className:`text-sm font-medium text-foreground`,children:i}),n?(0,Q.jsx)(fe,{className:`mt-0.5 text-xs text-muted-foreground leading-normal`,children:n}):null]})]}),o?(0,Q.jsx)(`div`,{className:`shrink-0`,children:o}):null]})}var yt={unconfigured:`Add a key below to turn this on.`,unverified:`Checking the key…`,ready:`Ready.`,error:`The TypeSafe key could not be verified.`},bt={settings:`Using the key saved here.`,environment:`Using TYPESAFE_API_KEY from the server environment.`,none:`No key is set.`};function xt({enabled:e,keySource:t,status:n,onClearKey:r,onEnabledChange:i,onSaveKey:a}){let[o,s]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(!1),[d,f]=(0,Z.useState)(!1),[p,m]=(0,Z.useState)(null),[h,g]=(0,Z.useState)(!1),_=(0,Z.useCallback)(async()=>{if(f(!0),m(null),!(!o.trim()||!a)){g(!0);try{await a(o.trim()),s(``),u(!1),f(!1)}catch(e){m(e instanceof Error?e.message:`Failed to save key`)}finally{g(!1)}}},[o,a]),v=(0,Z.useCallback)(async()=>{if(r){g(!0),m(null);try{await r(),s(``)}catch(e){m(e instanceof Error?e.message:`Failed to remove key`)}finally{g(!1)}}},[r]),y=n===`unconfigured`||n===`error`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsx)(vt,{label:`Describe a command`,description:`Recognise when a message is really asking for a built-in command, like "compact this" or "show the shortcuts". Messages you send are shared with TypeSafe for classification only when this is on. ${yt[n]}`,trailing:(0,Q.jsx)(me,{"aria-label":`Describe a command`,checked:e,disabled:!i||!e&&y,onCheckedChange:i})}),(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-xl border p-4`,children:[(0,Q.jsx)(gt,{attemptedSave:d,label:`TypeSafe API key`,onChange:e=>{s(e),p&&m(null)},onToggleVisibility:()=>u(e=>!e),placeholder:`Paste your TypeSafe API key`,showPassword:l,value:o}),p?(0,Q.jsx)(`p`,{className:`text-xs text-destructive`,children:p}):null,(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:bt[t]}),(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(c,{type:`button`,size:`compact`,disabled:h||!o.trim(),onClick:()=>void _(),children:`Save key`}),t===`settings`?(0,Q.jsx)(c,{type:`button`,variant:`outline`,size:`compact`,disabled:h,onClick:()=>void v(),children:`Remove key`}):null]})]})]})}function St({className:e,interactive:t,padding:n,tone:r,...i}){return(0,Q.jsx)(`div`,{className:l(De({interactive:t,padding:n,tone:r}),e),...i})}function $({icon:e,title:t,subtitle:n,trailing:r,className:i,interactive:a=!0,tone:o=`default`,truncateSubtitle:s=!0,truncateTitle:c=!0}){return(0,Q.jsxs)(St,{tone:o,padding:`md`,interactive:a,className:l(`items-center gap-3`,i),children:[e?(0,Q.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-md border border-border/40 bg-background/60 text-foreground/70`,children:e}):null,(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:l(`text-sm font-medium text-foreground`,c&&`truncate`),children:t}),n?(0,Q.jsx)(`div`,{className:l(`mt-0.5 text-xs text-muted-foreground`,s?`truncate`:`leading-normal`),children:n}):null]}),r?(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:r}):null]})}function Ct({actions:e,children:t,description:n,title:r}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`h3`,{className:`text-lg font-medium text-balance`,children:r}),(0,Q.jsx)(`p`,{className:`mt-1 text-sm text-pretty text-muted-foreground`,children:n})]}),e?(0,Q.jsx)(`div`,{className:`flex shrink-0 items-center gap-1.5 pt-0.5`,children:e}):null]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:t})]})}function wt({dirty:e,disabled:t,onRevert:n,onSave:r,saving:i}){return(0,Q.jsxs)(Q.Fragment,{children:[e?(0,Q.jsx)(c,{type:`button`,variant:`ghost`,size:`icon-compact`,className:`text-muted-foreground transition-transform active:scale-[0.96]`,disabled:t||i,onClick:n,"aria-label":`Revert changes`,children:(0,Q.jsx)(oe,{})}):null,(0,Q.jsxs)(c,{type:`button`,variant:`outline`,size:`compact`,className:l(ke,`transition-transform active:scale-[0.96]`,e&&`border-primary/30 text-primary`),disabled:!e||t||i,onClick:r,children:[i?(0,Q.jsx)(te,{className:`animate-spin`,"data-icon":`inline-start`}):(0,Q.jsx)(Qe,{"data-icon":`inline-start`}),`Commit`]})]})}var Tt=1500,Et=`Unknown or expired OAuth login`;function Dt(e){return new Promise(t=>{setTimeout(t,e)})}function Ot({onConfigured:e,onOAuthLogin:t,providerId:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),l=(0,Z.useRef)(null),u=(0,Z.useRef)(0),d=(0,Z.useRef)(!1),f=(0,Z.useRef)(t),p=(0,Z.useRef)(e),m=(0,Z.useRef)(n);(0,Z.useEffect)(()=>{f.current=t,p.current=e,m.current=n},[e,t,n]);let h=(0,Z.useCallback)(async e=>{if(!(!e||!f.current))try{await f.current({providerId:m.current,loginId:e,cancel:!0})}catch{}},[]),g=(0,Z.useCallback)(()=>{l.current=null,d.current=!1,i(null),c(``),o(!1)},[]);(0,Z.useEffect)(()=>()=>{u.current+=1;let e=l.current;l.current=null,h(e)},[h]);let _=(0,Z.useCallback)((e,t)=>{if(t!==u.current){e.status===`waiting`&&e.loginId&&h(e.loginId);return}if(e.status===`success`){l.current=null,i(null),c(``),o(!1),Y.success(`Provider credentials applied to your active sessions.`),p.current?.();return}if(e.status===`error`){if(e.error===Et&&l.current===null)return;let t=l.current;l.current=null,t&&e.error!==`Login cancelled`&&h(t),i(e),o(!1);return}e.loginId&&(l.current=e.loginId),i(e)},[h]),v=(0,Z.useCallback)(async()=>{if(!f.current||d.current)return;d.current=!0;let e=u.current;o(!0);let t=l.current;if(l.current=null,i(null),await h(t),e!==u.current){d.current=!1;return}try{let t=await f.current({providerId:m.current});_(t,e)}catch(t){if(e!==u.current)return;i({status:`error`,error:t instanceof Error?t.message:`Failed to start OAuth sign-in`})}finally{d.current=!1,e===u.current&&o(!1)}},[_,h]),y=(0,Z.useCallback)(async()=>{let e=l.current;if(!f.current||!e)return;let t=u.current;o(!0);try{let n=await f.current({providerId:m.current,loginId:e,promptAnswer:s});c(``),_(n,t)}catch(e){if(t!==u.current)return;Y.error(e instanceof Error?e.message:`Failed to continue OAuth sign-in`)}finally{t===u.current&&o(!1)}},[_,s]),b=(0,Z.useCallback)(async()=>{u.current+=1;let e=l.current;g(),await h(e)},[h,g]);return(0,Z.useEffect)(()=>{if(!f.current||r?.status!==`waiting`||!r.loginId)return;let e=u.current,t=r.loginId,n=!1;return(async()=>{for(;!n;){try{let r=await f.current({providerId:m.current,loginId:t});if(n||e!==u.current||(_(r,e),r.status!==`waiting`))return}catch(r){if(n||e!==u.current||l.current!==t)return;l.current=null,h(t),i({status:`error`,error:r instanceof Error?r.message:`OAuth sign-in failed`});return}if(await Dt(Tt),n||e!==u.current||l.current!==t)return}})(),()=>{n=!0}},[_,h,r?.loginId,r?.status]),{busy:a,cancel:b,canStart:!!t,login:r,promptAnswer:s,setPromptAnswer:c,start:v,submitPrompt:y}}function kt({onConfigured:e,onOAuthLogin:t,provider:n}){let{busy:r,cancel:i,canStart:a,login:o,promptAnswer:s,setPromptAnswer:l,start:u,submitPrompt:d}=Ot({onConfigured:e,onOAuthLogin:t,providerId:n.id}),f=o?.status===`waiting`,p=o?.status===`error`?o.error:void 0,m=f?o?.authUrl:void 0,h=f?o?.userCode:void 0,g=f?o?.instructions:void 0,_=f?o?.prompt:void 0,v=n.authType===`oauth`;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n.isConfigured&&v&&!f?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm`,children:[(0,Q.jsx)(P,{className:`size-3.5 text-muted-foreground`}),(0,Q.jsx)(`span`,{children:`Connected`})]}):null,f?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Sign in with `,n.name,` to store OAuth credentials for this account.`]}),h?(0,Q.jsxs)(`p`,{className:`text-sm`,children:[`Enter this code: `,(0,Q.jsx)(`span`,{className:`font-mono text-foreground`,children:h})]}):null,g&&!h?(0,Q.jsx)(`p`,{className:`text-xs text-pretty text-muted-foreground`,children:g}):null,m?(0,Q.jsxs)(c,{type:`button`,size:`compact`,onClick:()=>{window.open(m,`_blank`,`noopener,noreferrer`)},children:[(0,Q.jsx)(I,{"data-icon":`inline-start`}),`Open sign-in page`]}):_?null:(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-xs text-muted-foreground`,children:[(0,Q.jsx)(X,{className:`size-3`}),`Waiting for sign-in…`]}),_?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(`p`,{className:`text-xs text-pretty text-muted-foreground`,children:_.message}),(0,Q.jsx)(be,{value:s,placeholder:_.placeholder,onChange:e=>l(e.target.value),"aria-label":_.message}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(c,{type:`button`,size:`compact`,disabled:r||!_.allowEmpty&&!s.trim(),onClick:()=>{d()},children:[r?(0,Q.jsx)(X,{"data-icon":`inline-start`}):null,`Continue`]})})]}):null,(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,disabled:r,onClick:()=>{i()},children:`Cancel sign-in`})})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[p?(0,Q.jsx)(pe,{className:`px-3 py-2`,children:(0,Q.jsx)(ue,{className:`text-xs text-pretty`,children:p})}):(0,Q.jsx)(`p`,{className:`text-xs text-pretty text-muted-foreground`,children:v&&n.isConfigured?`Sign in again with ${n.name} to refresh OAuth credentials.`:v?`Sign in with ${n.name}. No API key is stored; credentials are saved to auth.json.`:`Sign in with ${n.name} to use OAuth credentials; API-key editing remains available above.`}),(0,Q.jsx)(`div`,{className:`flex justify-end`,children:(0,Q.jsxs)(c,{type:`button`,size:`compact`,disabled:r||!a,onClick:()=>{u()},children:[r?(0,Q.jsx)(X,{"data-icon":`inline-start`}):null,`Sign in with `,n.name]})})]})]})}function At(e){switch(e.status){case`connected`:return`Connected`;case`anonymous`:return`Available without sign-in`;case`needs_auth`:return`Sign-in required`;case`disabled`:return`Disabled`;default:return e.status}}function jt(e){let t=e.transport===`http`?e.url:e.commandPreview;return[e.source===`builtin`?`Built-in`:`User`,e.transport===`http`?`HTTP`:`stdio`,At(e),t].filter(e=>!!e).join(` · `)}function Mt({connections:e,isLoading:t,isPending:n,onOAuth:r,onRemove:i,onUpsert:a}){let[o,s]=(0,Z.useState)(!1),[l,u]=(0,Z.useState)(`http`),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(!0),[_,v]=(0,Z.useState)(``),[y,b]=(0,Z.useState)(``),[x,S]=(0,Z.useState)(``),[w,T]=(0,Z.useState)(``),[E,D]=(0,Z.useState)(``),[k,A]=(0,Z.useState)(null),j=()=>{f(``),m(``),g(!0),v(``),b(``),S(``),T(``),D(``),u(`http`),s(!1)},M=async()=>{if(!a)return;let e=d.trim();try{if(l===`http`)await a({name:e,transport:`http`,url:p.trim(),...h?{oauth:!0}:{},..._.trim()?{bearerTokenEnvVar:_.trim()}:{},force:!0});else{let t=x.split(/\s+/).map(e=>e.trim()).filter(Boolean),n=E.split(`
2
2
  `).map(e=>e.trim()).filter(Boolean).flatMap(e=>{let t=e.indexOf(`=`);if(t<=0)return[];let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();return!n||!r?[]:[{child:n,source:r}]});await a({name:e,transport:`stdio`,command:y.trim(),...t.length>0?{args:t}:{},...w.trim()?{cwd:w.trim()}:{},...n.length>0?{env:n}:{},force:!0})}Y.success(`MCP connection saved`),j()}catch(e){Y.error(e instanceof Error?e.message:`Could not save MCP connection`)}},N=async e=>{if(i)try{await i({name:e}),Y.success(`Removed ${e}`),A(null)}catch(e){Y.error(e instanceof Error?e.message:`Could not remove MCP connection`)}},P=async e=>{if(r)try{await r({name:e,action:`logout`}),Y.success(`Signed out of ${e}`)}catch(e){Y.error(e instanceof Error?e.message:`Could not sign out`)}},F=(0,Z.useMemo)(()=>{if(r)return e=>async t=>{let n=!t.loginId&&!t.cancel;return await r({name:e.name,action:n&&e.status===`connected`?`reconnect`:`login`,loginId:t.loginId,promptAnswer:t.promptAnswer,cancel:t.cancel})}},[r]);return(0,Q.jsxs)(Ct,{title:`MCP`,description:`Connect built-in and user MCP servers. Tokens stay on the server; this list only shows status and environment-variable names.`,actions:(0,Q.jsxs)(c,{type:`button`,size:`compact`,variant:`outline`,disabled:n||o,onClick:()=>s(!0),children:[(0,Q.jsx)(G,{"data-icon":`inline-start`}),`Add server`]}),children:[t?(0,Q.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,Q.jsx)(X,{className:`size-3.5`}),`Loading MCP connections…`]}):null,o?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3 rounded-xl border p-4`,children:[(0,Q.jsxs)(J,{children:[(0,Q.jsx)(q,{children:`Name`}),(0,Q.jsx)(be,{value:d,onChange:e=>f(e.target.value),"aria-label":`MCP server name`})]}),(0,Q.jsxs)(J,{children:[(0,Q.jsx)(q,{children:`Transport`}),(0,Q.jsx)(C,{value:l,onValueChange:e=>u(e),options:[{label:`HTTP`,value:`http`},{label:`stdio`,value:`stdio`}]})]}),l===`http`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(J,{children:[(0,Q.jsx)(q,{children:`URL`}),(0,Q.jsx)(be,{value:p,onChange:e=>m(e.target.value),"aria-label":`MCP server URL`})]}),(0,Q.jsxs)(J,{orientation:`horizontal`,className:`items-center justify-between`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(q,{children:`OAuth`}),(0,Q.jsx)(fe,{children:`Use the browser sign-in flow for this server.`})]}),(0,Q.jsx)(me,{checked:h,onCheckedChange:e=>g(e),"aria-label":`Use OAuth`})]}),h?null:(0,Q.jsxs)(J,{children:[(0,Q.jsx)(q,{children:`Bearer token environment variable`}),(0,Q.jsx)(be,{value:_,onChange:e=>v(e.target.value),"aria-label":`Bearer token environment variable`,placeholder:`MCP_BEARER_TOKEN`})]})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(J,{children:[(0,Q.jsx)(q,{children:`Command`}),(0,Q.jsx)(be,{value:y,onChange:e=>b(e.target.value),"aria-label":`MCP command`})]}),(0,Q.jsxs)(J,{children:[(0,Q.jsx)(q,{children:`Arguments`}),(0,Q.jsx)(be,{value:x,onChange:e=>S(e.target.value),"aria-label":`MCP command arguments`})]}),(0,Q.jsxs)(J,{children:[(0,Q.jsx)(q,{children:`Working directory`}),(0,Q.jsx)(be,{value:w,onChange:e=>T(e.target.value),"aria-label":`MCP working directory`}),(0,Q.jsx)(fe,{children:`Must stay inside the current workspace.`})]}),(0,Q.jsxs)(J,{children:[(0,Q.jsx)(q,{children:`Environment mappings`}),(0,Q.jsx)(xe,{value:E,onChange:e=>D(e.target.value),"aria-label":`MCP environment mappings`,placeholder:`CHILD=SOURCE`}),(0,Q.jsx)(fe,{children:`One CHILD=SOURCE pair per line. Only variable names are stored.`})]})]}),(0,Q.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,Q.jsx)(c,{type:`button`,size:`compact`,variant:`ghost`,onClick:j,children:`Cancel`}),(0,Q.jsxs)(c,{type:`button`,size:`compact`,disabled:n||!d.trim(),onClick:()=>void M(),children:[n?(0,Q.jsx)(X,{"data-icon":`inline-start`}):null,`Save`]})]})]}):null,!t&&e.length===0&&!o?(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No MCP connections yet.`}):null,(0,Q.jsx)(`div`,{className:`flex flex-col gap-2`,children:e.map(e=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)($,{icon:(0,Q.jsx)(ne,{className:`size-4`}),title:e.label,subtitle:jt(e),trailing:(0,Q.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[e.usesOAuth&&e.status!==`needs_auth`?(0,Q.jsx)(c,{type:`button`,size:`compact`,variant:`ghost`,disabled:n||!r,onClick:()=>{P(e.name)},children:`Sign out`}):null,e.source===`user`?k===e.name?(0,Q.jsx)(c,{type:`button`,size:`compact`,variant:`destructive`,disabled:n,onClick:()=>{N(e.name)},children:`Confirm remove`}):(0,Q.jsx)(c,{type:`button`,size:`compact`,variant:`ghost`,disabled:n||!i,"aria-label":`Remove ${e.name}`,onClick:()=>A(e.name),children:(0,Q.jsx)(O,{className:`size-3.5`})}):null]})}),e.error?(0,Q.jsx)(pe,{className:`px-3 py-2`,children:(0,Q.jsx)(ue,{className:`text-xs text-pretty`,children:e.error})}):null,e.usesOAuth&&F?(0,Q.jsx)(kt,{provider:{id:e.name,name:e.label,isConfigured:e.status===`connected`,envVarName:``,authType:`oauth`,supportsOAuth:!0},onOAuthLogin:F(e)}):null]},`${e.source}:${e.name}`))})]})}var Nt=[{value:`system`,label:`System`,icon:H},{value:`light`,label:`Light`,icon:U},{value:`dark`,label:`Dark`,icon:V}];function Pt({onThemePreferenceChange:e,themePreference:t}){return(0,Q.jsxs)(J,{orientation:`horizontal`,className:`items-center justify-between gap-6 rounded-xl border p-4`,children:[(0,Q.jsxs)(`div`,{className:`min-w-0`,children:[(0,Q.jsx)(q,{children:`Theme`}),(0,Q.jsx)(fe,{children:`Match the system theme or pick light or dark.`})]}),(0,Q.jsx)(`div`,{className:`shrink-0`,children:(0,Q.jsx)(C,{"aria-label":`Theme`,className:`w-[160px]`,onValueChange:t=>e(t),options:[...Nt],value:t})})]})}function Ft(e,t){return`${e}/${t}`}function It(e,t){return lt({id:e.id,name:e.name,provider:e.provider,modelId:e.modelId},t)}function Lt({currentPatterns:e,enabled:t,model:n,models:r}){if(e===void 0&&t)return;let i=e??[],a=new Set(r.map(e=>Rt(e))),o=new Set;for(let t of r)It(t,e)&&o.add(Rt(t));return t?o.add(Rt(n)):o.delete(Rt(n)),[...i.filter(e=>a.has(e)?!1:t||!ut(n,e)),...o]}function Rt(e){return mt(e.provider,e.modelId)}function zt(e){return[e.name,e.modelId,e.provider,e.id].join(` `).toLowerCase()}function Bt({configuredProviderIds:e,discoverableProviderIds:t,discoveringProviderId:n,enabledModels:r,modelOptions:i,onAddModels:a,onDiscoverProvider:o,onOpenChange:s,open:u,providerLabel:d=N}){let[f,p]=(0,Z.useState)(``),[m,h]=(0,Z.useState)(new Set),g=f.trim().toLowerCase(),_=(0,Z.useMemo)(()=>i.filter(t=>!e.has(t.provider)||It(t,r)?!1:!g||zt(t).includes(g)),[e,r,i,g]),v=(0,Z.useMemo)(()=>{let e=new Map;for(let t of _){let n=e.get(t.provider);n?n.push(t):e.set(t.provider,[t])}return[...e.entries()]},[_]),y=(0,Z.useMemo)(()=>{let n=t??e;return Array.from(n).filter(t=>e.has(t)).sort((e,t)=>d(e).localeCompare(d(t)))},[e,t,d]),b=(0,Z.useMemo)(()=>{let e=new Map;for(let t of i)It(t,r)&&e.set(t.provider,(e.get(t.provider)??0)+1);return e},[r,i]),x=e=>{h(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n})};return(0,Q.jsx)(ye,{open:u,onOpenChange:s,children:(0,Q.jsxs)(ge,{className:`max-w-lg`,children:[(0,Q.jsxs)(he,{children:[(0,Q.jsx)(_e,{children:`Add models`}),(0,Q.jsxs)(ve,{children:[`Pick models discovered from your configured providers. For OpenAI Chat Completions, refresh runs`,` `,(0,Q.jsxs)(`span`,{className:`font-medium`,children:[`GET `,`{baseUrl}/models`]}),`.`]})]}),(0,Q.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:y.map(e=>{let t=n===e,r=b.get(e)??0;return(0,Q.jsxs)(c,{type:`button`,variant:`outline`,size:`compact`,disabled:n!==null,onClick:()=>{o(e)},children:[t?(0,Q.jsx)(X,{"data-icon":`inline-start`}):(0,Q.jsx)(ae,{"data-icon":`inline-start`}),d(e),r>0?(0,Q.jsxs)(`span`,{className:`tabular-nums text-muted-foreground`,children:[`· `,r,` active`]}):null]},e)})}),(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ce,{align:`inline-start`,children:(0,Q.jsx)(K,{})}),(0,Q.jsx)(Se,{"aria-label":`Search discovered models`,value:f,onChange:e=>p(e.target.value),placeholder:`Search discovered models…`})]}),(0,Q.jsx)(`div`,{className:`max-h-72 overflow-y-auto`,children:v.length===0?(0,Q.jsx)(`p`,{className:`py-6 text-center text-xs text-pretty text-muted-foreground`,children:_.length===0&&!g?`All discovered models are already in your list, or none are available yet.`:`No models match your search.`}):(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,children:v.map(([e,t])=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsxs)(`div`,{className:`px-2 text-caption font-medium tracking-wide text-muted-foreground uppercase`,children:[d(e),(b.get(e)??0)>0?(0,Q.jsxs)(`span`,{className:`ml-1 font-normal normal-case tabular-nums`,children:[`· `,b.get(e),` active`]}):null]}),t.map(e=>{let t=m.has(e.id);return(0,Q.jsxs)(`button`,{type:`button`,className:l(`flex w-full items-center gap-3 rounded-lg px-2 py-2 text-left transition-[background-color,transform] duration-150`,`hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none active:scale-[0.96]`,t&&`bg-muted/70`),"aria-pressed":t,onClick:()=>x(e),children:[(0,Q.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-[4px] border border-border/40 bg-background/60`,children:(0,Q.jsx)(k,{provider:e.provider,className:`text-foreground/70`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-medium`,children:e.name}),(0,Q.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:e.modelId})]}),(0,Q.jsx)(`span`,{className:l(`size-4 rounded border border-border/60`,t&&`border-foreground bg-foreground`),"aria-hidden":!0})]},e.id)})]},e))})}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,Q.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,onClick:()=>s(!1),children:`Cancel`}),(0,Q.jsxs)(c,{type:`button`,size:`compact`,disabled:m.size===0,onClick:()=>{let e=_.filter(e=>m.has(e.id));e.length>0&&a(e),s(!1)},children:[`Add `,m.size>0?(0,Q.jsxs)(`span`,{className:`tabular-nums`,children:[`(`,m.size,`)`]}):null]})]})]})})}function Vt({draft:e,discoveringProviderId:t,modelDirty:n,modelFilter:r,modelOptions:i,onAddModels:a,onDiscoverProvider:o,onModelFilterChange:s,onRemoveModel:u,onSetDefaultModel:d,onRevert:f,onSave:p,providers:m,saving:h,settingsLoading:g}){let[_,v]=(0,Z.useState)(!1),y=!e||g,b=r.trim().toLowerCase(),x=(0,Z.useMemo)(()=>{let t=new Set;for(let e of m)e.isConfigured&&t.add(e.id);for(let n of i)It(n,e?.enabledModels)&&t.add(n.provider);return t},[e?.enabledModels,i,m]),S=(0,Z.useMemo)(()=>{let e=new Set;for(let t of m)t.discoverable===!0&&x.has(t.id)&&e.add(t.id);return e},[x,m]),C=(0,Z.useMemo)(()=>t=>!!e?.defaultProvider&&!!e?.defaultModel&&t.provider===e.defaultProvider&&t.modelId===e.defaultModel,[e?.defaultModel,e?.defaultProvider]),w=(0,Z.useMemo)(()=>{let e=new Map;for(let t of m)(t.displayName||t.name)&&e.set(t.id,t.displayName??t.name??t.id);return t=>e.get(t)??N(t)},[m]),T=(0,Z.useMemo)(()=>i.filter(t=>It(t,e?.enabledModels)?!b||[t.name,t.modelId,t.provider,t.id].join(` `).toLowerCase().includes(b):!1),[e?.enabledModels,i,b]),E=(0,Z.useMemo)(()=>{let e=new Map;for(let t of T){let n=e.get(t.provider);n?n.push(t):e.set(t.provider,[t])}return[...e.entries()]},[T]),D=i.length===0?`No models discovered yet. Configure a provider, then add models.`:T.length===0&&!b?`Add models from your configured providers to make them available in chat.`:T.length===0?`No models match your search.`:null,A=()=>{v(!0)};return(0,Q.jsxs)(Ct,{title:`LLM Models`,description:(0,Q.jsxs)(Q.Fragment,{children:[`Models available in chat. Discover from configured providers, add the ones you want, and remove any you do not need — changes save automatically. `,(0,Q.jsx)(`span`,{className:`tabular-nums`,children:T.length}),` in list`,i.length>0?(0,Q.jsxs)(Q.Fragment,{children:[` `,`· `,(0,Q.jsx)(`span`,{className:`tabular-nums`,children:i.length}),` discovered`]}):null,`.`]}),actions:(0,Q.jsx)(wt,{dirty:n,disabled:y,onRevert:f,onSave:p,saving:h}),children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(Te,{className:`flex-1`,children:[(0,Q.jsx)(Ce,{align:`inline-start`,children:(0,Q.jsx)(K,{})}),(0,Q.jsx)(Se,{"aria-label":`Search listed models`,value:r,onChange:e=>s(e.target.value),placeholder:`Search listed models…`,disabled:y||T.length===0})]}),(0,Q.jsxs)(c,{type:`button`,variant:`outline`,size:`compact`,disabled:y,onClick:A,children:[(0,Q.jsx)(G,{"data-icon":`inline-start`}),`Add models`]})]}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-3`,"data-testid":`runtime-models-list`,children:D?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-8`,children:[(0,Q.jsx)(`p`,{className:`px-1 text-center text-xs text-pretty text-muted-foreground`,children:D}),b?null:(0,Q.jsxs)(c,{type:`button`,variant:`outline`,size:`compact`,disabled:y,onClick:A,children:[(0,Q.jsx)(G,{"data-icon":`inline-start`}),`Add models`]})]}):E.map(([e,t])=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsx)(`div`,{className:`px-1 text-xs font-medium text-muted-foreground`,children:w(e)}),t.map(e=>(0,Q.jsx)($,{icon:(0,Q.jsx)(k,{provider:e.provider}),title:e.name,subtitle:`${w(e.provider)} · ${e.modelId}`,trailing:(0,Q.jsxs)(`div`,{className:`flex items-center`,children:[C(e)?(0,Q.jsx)(`span`,{className:`px-2 text-xs font-medium text-muted-foreground`,children:`Default`}):d?(0,Q.jsxs)(c,{type:`button`,variant:`ghost`,size:`compact`,className:l(Oe,`h-7 px-2 text-xs text-muted-foreground transition-[background-color,color,transform] duration-150 active:scale-[0.96]`),disabled:y,"aria-label":`Set ${e.name} as default`,onClick:()=>d(e),children:[(0,Q.jsx)(et,{"data-icon":`inline-start`}),`Set default`]}):null,(0,Q.jsxs)(c,{type:`button`,variant:`ghost`,size:`compact`,className:l(Oe,`h-7 px-2 text-xs text-muted-foreground transition-[background-color,color,transform] duration-150 hover:text-destructive active:scale-[0.96]`),disabled:y,"aria-label":`Remove ${e.name}`,onClick:()=>u(e),children:[(0,Q.jsx)(O,{"data-icon":`inline-start`}),`Remove`]})]})},e.id))]},e))}),(0,Q.jsx)(Bt,{open:_,configuredProviderIds:x,discoverableProviderIds:S,discoveringProviderId:t,enabledModels:e?.enabledModels,modelOptions:i,onAddModels:a,onDiscoverProvider:o,onOpenChange:v,providerLabel:w})]})}var Ht=`https://opencode.ai/zen/v1`,Ut=`qwen35-122b-a10b`,Wt=`e.g. OpenCode Zen, Nebius, Groq…`,Gt=`model-a, model-b (comma-separated)`,Kt=[{value:`openai-completions`,label:`OpenAI Chat Completions`},{value:`openai-responses`,label:`OpenAI Responses`},{value:`anthropic-messages`,label:`Anthropic Messages`},{value:`google-genai`,label:`Google Generative AI`}];function qt({attemptedSave:e,apiKey:t,api:n,baseUrl:r,modelId:i,models:a,displayName:o,isCustom:s,onApiKeyChange:c,onApiChange:l,onBaseUrlChange:u,onModelIdChange:d,onModelsChange:f,onDisplayNameChange:p,onTogglePassword:m,openAiChat:h,placeholder:g,showPassword:_}){let v=s&&l,y=s&&f;return(0,Q.jsxs)(de,{className:`gap-2`,children:[(h||s)&&p?(0,Q.jsx)(_t,{attemptedSave:e,icon:nt,label:`Provider name`,placeholder:Wt,value:o??``,onChange:p}):null,v?(0,Q.jsx)(Jt,{value:n??`openai-completions`,onChange:l}):null,(0,Q.jsx)(gt,{attemptedSave:e,label:`API key`,placeholder:g,value:t,showPassword:_,onChange:c,onToggleVisibility:m}),h||s?(0,Q.jsx)(_t,{attemptedSave:e,icon:L,inputType:`url`,label:`Base URL`,placeholder:Ht,value:r,onChange:u}):null,y?(0,Q.jsx)(_t,{attemptedSave:e,icon:We,label:`Model ids`,placeholder:Gt,value:a??``,onChange:f}):null,h&&!y?(0,Q.jsx)(_t,{attemptedSave:e,icon:Re,label:`Model name`,placeholder:Ut,value:i,onChange:d}):null]})}function Jt({value:e,onChange:t}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,Q.jsx)(`span`,{className:`text-xs font-medium text-muted-foreground`,children:`API family`}),(0,Q.jsx)(C,{"aria-label":`API family`,value:e,options:Kt,placeholder:`Select API family`,onValueChange:e=>t(e)})]})}function Yt(e){return e.authType===`oauth`}function Xt(e){return e.supportsOAuth===!0}var Zt={id:`custom`,name:`Custom provider`,isConfigured:!1,envVarName:`CUSTOM_PROVIDER_API_KEY`,displayName:`Custom provider`};function Qt(e){return e.split(`,`).map(e=>e.trim()).filter(e=>e.length>0)}function $t({onRemoveProvider:e,onUpdateProvider:t,providers:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(!1),[s,c]=(0,Z.useState)(``),[l,u]=(0,Z.useState)(``),[d,f]=(0,Z.useState)(``),[p,m]=(0,Z.useState)(``),[h,g]=(0,Z.useState)(`openai-completions`),[_,y]=(0,Z.useState)(``),[b,S]=(0,Z.useState)(!1),[C,T]=(0,Z.useState)(!1),[E,D]=(0,Z.useState)(``),[O,k]=(0,Z.useState)(!1),[A,j]=(0,Z.useState)(``),[M,N]=(0,Z.useState)(null),P=(0,Z.useMemo)(()=>[...n.filter(e=>e.id!==Zt.id),Zt],[n]),F=(0,Z.useMemo)(()=>P.filter(e=>e.isConfigured),[P]),I=(0,Z.useMemo)(()=>P.filter(e=>!e.isConfigured||e.id===`openai-chat-completions`&&e.providerFamily===void 0),[P]),L=(0,Z.useMemo)(()=>{let e=E.trim().toLowerCase();return e?F.filter(t=>en(t,e)):F},[F,E]),R=(0,Z.useMemo)(()=>{let e=A.trim().toLowerCase();return I.filter(t=>en(t,e))},[A,I]),z=(0,Z.useMemo)(()=>{let e=A.trim().toLowerCase();return F.filter(t=>en(t,e))},[F,A]),B=R.length>0||z.length>0,ee=r&&!F.some(e=>e.id===r)?P.find(e=>e.id===r)??null:null,V=()=>{c(``),u(``),f(``),m(``),g(`openai-completions`),y(``),S(!1),T(!1)},H=()=>{i(null),o(!1),V()},U=(e,t)=>{k(!1),j(``),i(e),o(t?.newOccInstance===!0),V();let r=n.find(t=>t.id===e);u(r?.baseUrl??``),y(r?.displayName??(x(e)?r?.name??``:``)),g(r?.api??`openai-completions`),m((r?.modelIds??[]).join(`, `)),f(r?.modelIds?.[0]??``)},te=()=>{H(),j(``),k(!0)},W=()=>{k(!1),j(``)};return{activeProviders:F,addPickerOpen:O,addPickerQuery:A,api:h,apiKey:s,attemptedSave:C,baseUrl:l,canSave:(0,Z.useMemo)(()=>s.trim().length===0?!1:r?r===`custom`||x(r)?l.trim().length===0||Qt(p).length===0?!1:_.trim().length>0:w(r)?l.trim().length===0||d.trim().length===0?!1:v(r)||a?_.trim().length>0:!0:!0:!0,[s,l,d,p,_,r,a]),closeAddPicker:W,closeEditor:H,confirmRemoveProvider:M,credentialProviders:P,displayName:_,editingIsNewOccInstance:a,editingProvider:r,editingUnconfiguredProvider:ee,filteredActiveProviders:L,filteredPickerAvailable:R,filteredPickerConfigured:z,handleRemove:async t=>{if(e)try{await e({providerId:t.id}),r===t.id&&H(),Y.success(`${t.name} removed from your configured providers.`),N(null)}catch(e){Y.error(e instanceof Error?e.message:`Failed to remove provider`)}},handleSave:async e=>{if(!t)return;T(!0);let n=e===`custom`||x(e),r=w(e);if(n){let n=Qt(p);if(!s.trim()||!l.trim()||!_.trim()||n.length===0)return;try{await t({providerId:e,apiKey:s.trim(),baseUrl:l.trim(),displayName:_.trim(),api:h,models:n,...e===`custom`?{createOccInstance:!0}:{}}),Y.success(`Provider credentials applied to your active sessions.`),H(),W()}catch(e){Y.error(e instanceof Error?e.message:`Failed to update provider`)}return}let i=r&&v(e),o=r&&(i||a);if(s.trim()&&!(r&&(!l.trim()||!d.trim()))&&!(o&&!_.trim()))try{await t({providerId:e,apiKey:s.trim(),...r?{baseUrl:l.trim(),modelId:d.trim(),...o?{displayName:_.trim()}:{},...a?{createOccInstance:!0}:{}}:{}}),Y.success(`Provider credentials applied to your active sessions.`),H(),W()}catch(e){Y.error(e instanceof Error?e.message:`Failed to update provider`)}},modelId:d,models:p,openAddPicker:te,openEditor:U,pickerHasResults:B,resetEditor:V,searchQuery:E,selectProviderFromPicker:e=>{U(e,{newOccInstance:w(e)})},setAddPickerOpen:k,setAddPickerQuery:j,setApi:g,setApiKey:c,setAttemptedSave:T,setBaseUrl:u,setConfirmRemoveProvider:N,setDisplayName:y,setEditingIsNewOccInstance:o,setEditingProvider:i,setModelId:f,setModels:m,setSearchQuery:D,setShowPassword:S,showPassword:b,unconfiguredProviders:I}}function en(e,t){if(!t)return!0;let n=Xt(e)?Yt(e)?`oauth sign-in login`:`api key oauth sign-in login`:e.id===`custom`||x(e.id)?`custom provider endpoint openai anthropic google compatible`:w(e.id)?`api key base url model name chat completions`:``;return[e.name,e.envVarName,e.id,n].join(` `).toLowerCase().includes(t)}function tn({addPickerQuery:e,credentialProvidersLength:t,filteredPickerAvailable:n,filteredPickerConfigured:r,pickerHasResults:i,onClose:a,onQueryChange:o,onSelect:s}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(c,{type:`button`,variant:`ghost`,size:`icon-compact`,"aria-label":`Back to providers`,onClick:a,children:(0,Q.jsx)(M,{})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`p`,{className:`text-sm font-medium`,children:`Add provider`}),(0,Q.jsx)(`p`,{className:`text-xs text-pretty text-muted-foreground`,children:`Choose a provider to store encrypted credentials for this account.`})]})]}),(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Ce,{align:`inline-start`,children:(0,Q.jsx)(K,{})}),(0,Q.jsx)(Se,{type:`text`,placeholder:`Search providers…`,value:e,onChange:e=>o(e.target.value),"aria-label":`Search providers to add`})]}),(0,Q.jsx)(`div`,{className:`max-h-[min(24rem,50vh)] overflow-y-auto`,children:i?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[n.length>0?(0,Q.jsx)(`div`,{className:`flex flex-col gap-1`,children:n.map(e=>(0,Q.jsx)(on,{provider:e,configured:!1,onSelect:()=>s(e.id)},e.id))}):null,r.length>0?(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[n.length>0?(0,Q.jsx)(`p`,{className:`px-2 pt-1 text-caption font-medium tracking-wide text-muted-foreground uppercase`,children:`Already configured`}):null,r.map(e=>(0,Q.jsx)(on,{provider:e,configured:!0,onSelect:()=>s(e.id)},e.id))]}):null]}):(0,Q.jsx)(`p`,{className:`py-6 text-center text-xs text-pretty text-muted-foreground`,children:t===0?`No providers available.`:`No matching providers found.`})})]})}function nn({onBack:e,onConfigured:t,onOAuthLogin:n,provider:r}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(c,{type:`button`,variant:`ghost`,size:`icon-compact`,"aria-label":`Back to provider list`,onClick:e,children:(0,Q.jsx)(M,{})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Configure `,r.name]}),(0,Q.jsx)(`p`,{className:`text-xs text-pretty text-muted-foreground`,children:`OAuth sign-in. Credentials are stored in auth.json for this account.`})]})]}),(0,Q.jsx)(kt,{provider:r,onConfigured:t,onOAuthLogin:n},r.id)]})}function rn({provider:e,api:t,apiKey:n,baseUrl:r,modelId:i,models:a,displayName:o,showPassword:s,attemptedSave:l,isPending:u,canSave:d,onApiKeyChange:f,onApiChange:p,onBaseUrlChange:m,onModelIdChange:g,onModelsChange:_,onDisplayNameChange:v,onTogglePassword:y,onBack:b,onCancel:S,onConfigured:C,onOAuthLogin:T,onSave:E}){let D=e.id===`custom`||x(e.id),O=j[e.id]??(D?j.custom:{placeholder:`Enter credentials…`,help:`Stored securely in your local environment overrides.`}),k=w(e.id)&&!D,A=Xt(e);return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsx)(c,{type:`button`,variant:`ghost`,size:`icon-compact`,"aria-label":`Back to provider list`,onClick:b,children:(0,Q.jsx)(M,{})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsxs)(`p`,{className:`text-sm font-medium`,children:[`Configure `,e.name]}),(0,Q.jsx)(`p`,{className:`text-xs text-pretty text-muted-foreground`,children:D?`Name this custom provider, pick its API family, then enter its API key, https base URL, and model ids.`:k?`Name this OpenAI-compatible provider, then enter its API key, base URL, and model name.`:`Stored as ${e.envVarName} for this account.`})]})]}),(0,Q.jsx)(qt,{attemptedSave:l,api:t,apiKey:n,baseUrl:r,modelId:i,models:a,displayName:o,isCustom:D,openAiChat:k,placeholder:O.placeholder,showPassword:s,onApiKeyChange:f,onApiChange:p,onBaseUrlChange:m,onModelIdChange:g,onModelsChange:_,onDisplayNameChange:v,onTogglePassword:y}),(0,Q.jsxs)(pe,{className:`px-3 py-2`,children:[(0,Q.jsx)(h,{}),(0,Q.jsx)(ue,{className:`text-xs text-pretty`,children:O.help})]}),(0,Q.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,children:[(0,Q.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,onClick:S,children:`Cancel`}),(0,Q.jsxs)(c,{type:`button`,size:`compact`,disabled:u||!d,onClick:E,children:[u?(0,Q.jsx)(X,{"data-icon":`inline-start`}):null,`Save`]})]}),A?(0,Q.jsx)(kt,{provider:e,onConfigured:C??S,onOAuthLogin:T},`${e.id}-oauth`):null]})}function an({confirmRemoveProvider:e,isPending:t,onClose:n,onConfirm:r}){return(0,Q.jsx)(Ie,{open:e!==null,onOpenChange:e=>{e||n()},children:(0,Q.jsxs)(je,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsxs)(Fe,{children:[`Remove `,e?.name??`provider`,`?`]}),(0,Q.jsx)(Ae,{children:`This clears stored credentials for this provider from your workspace settings. Active sessions will stop using it immediately.`})]}),(0,Q.jsxs)(Ne,{children:[(0,Q.jsx)(Pe,{disabled:t,children:`Cancel`}),(0,Q.jsxs)(Me,{disabled:t||!e,onClick:()=>{e&&r(e)},children:[t?(0,Q.jsx)(X,{"data-icon":`inline-start`}):null,`Remove provider`]})]})]})})}function on({configured:e,onSelect:t,provider:n}){let r=w(n.id),i=n.id===`custom`||x(n.id),a=Yt(n),o=Xt(n);return(0,Q.jsxs)(`button`,{type:`button`,className:l(`flex w-full items-center gap-3 rounded-lg px-2 py-2 text-left transition-[background-color,transform] duration-150`,`hover:bg-muted/60 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none active:scale-[0.96]`),onClick:t,children:[(0,Q.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-[4px] border border-border/40 bg-background/60`,children:(0,Q.jsx)(k,{provider:i?`custom`:n.id,api:n.api,className:`text-foreground/70`})}),(0,Q.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Q.jsx)(`div`,{className:`truncate text-sm font-medium`,children:n.name}),(0,Q.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[a?`OAuth sign-in`:o?`API key or OAuth`:i?`API family + key + https base URL + models`:r?`API key + base URL + model name`:n.envVarName,e?` · Update`:``]})]})]})}function sn({providers:e,editingProvider:t,form:n,operation:r,actions:i,onEdit:a,onCancelEdit:o,onSave:s,onRemove:u,onOAuthLogin:d,onConfigured:f}){let{api:p,apiKey:m,baseUrl:g,modelId:_,models:v,displayName:y,showPassword:b,attemptedSave:S,canSave:C}=n,{isPending:T,canRemove:E}=r,{onApiKeyChange:D,onApiChange:A,onBaseUrlChange:M,onModelIdChange:N,onModelsChange:P,onDisplayNameChange:F,onTogglePassword:I}=i;return(0,Q.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:e.map(e=>{let n=t===e.id,r=x(e.id),i=j[e.id]??j[r?`custom`:`openai-chat-completions`],L=w(e.id),R=Yt(e),z=Xt(e);return(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)($,{interactive:!1,icon:(0,Q.jsx)(k,{provider:e.id,api:e.api,className:`text-foreground/80`}),title:e.name,subtitle:R?`OAuth sign-in`:z?`API key or OAuth`:r?`Custom provider · API key + base URL + models`:L?`OpenAI-compatible · API key + base URL + model name`:e.envVarName,trailing:(0,Q.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,Q.jsxs)(c,{type:`button`,variant:`ghost`,size:`compact`,className:l(Oe,`h-7 px-2 text-xs text-muted-foreground transition-[background-color,color,transform] duration-150 hover:text-destructive active:scale-[0.96]`),disabled:T||!E,"aria-label":`Remove ${e.name}`,onClick:()=>u(e),children:[(0,Q.jsx)(O,{"data-icon":`inline-start`}),`Remove`]}),(0,Q.jsxs)(c,{type:`button`,variant:`ghost`,size:`compact`,className:l(Oe,`h-7 px-2 text-xs transition-[background-color,transform] duration-150 active:scale-[0.96]`),disabled:T,onClick:()=>{if(n){o();return}a(e.id)},children:[n?null:(0,Q.jsx)(W,{"data-icon":`inline-start`}),n?`Cancel`:`Update`]})]})}),n?(0,Q.jsx)(St,{tone:`inset`,padding:`md`,className:`flex flex-col gap-2 border-t border-border/30`,children:R?(0,Q.jsx)(kt,{provider:e,onConfigured:f,onOAuthLogin:d},e.id):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(qt,{attemptedSave:S,api:e.api??p,apiKey:m,baseUrl:g,modelId:_,models:v,displayName:y,isCustom:r,openAiChat:L,placeholder:i.placeholder,showPassword:b,onApiKeyChange:D,onApiChange:A,onBaseUrlChange:M,onModelIdChange:N,onModelsChange:P,onDisplayNameChange:r||e.providerFamily!==void 0?F:void 0,onTogglePassword:I}),(0,Q.jsxs)(pe,{className:`px-3 py-2`,children:[(0,Q.jsx)(h,{}),(0,Q.jsx)(ue,{className:`text-xs text-pretty`,children:i.help})]}),(0,Q.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,Q.jsxs)(c,{type:`button`,size:`compact`,disabled:T||!C,onClick:()=>s(e.id),children:[T?(0,Q.jsx)(X,{"data-icon":`inline-start`}):null,`Save`]})}),z?(0,Q.jsx)(kt,{provider:e,onConfigured:f,onOAuthLogin:d},`${e.id}-oauth`):null]})}):null]},e.id)})})}function cn({isLoading:e,isPending:t,onOAuthLogin:n,onRemoveProvider:r,onUpdateProvider:i,providers:a}){let{activeProviders:o,addPickerOpen:s,addPickerQuery:l,api:u,apiKey:d,attemptedSave:f,baseUrl:p,canSave:m,closeAddPicker:h,closeEditor:g,confirmRemoveProvider:_,credentialProviders:v,displayName:y,editingProvider:b,editingUnconfiguredProvider:x,filteredActiveProviders:S,filteredPickerAvailable:C,filteredPickerConfigured:w,handleRemove:T,handleSave:E,modelId:D,models:O,openAddPicker:k,openEditor:A,pickerHasResults:j,searchQuery:M,selectProviderFromPicker:N,setAddPickerQuery:P,setApi:F,setApiKey:I,setBaseUrl:L,setConfirmRemoveProvider:R,setDisplayName:z,setModelId:B,setModels:ee,setSearchQuery:V,setShowPassword:H,showPassword:U}=$t({onRemoveProvider:r,onUpdateProvider:i,providers:a}),te={api:u,apiKey:d,baseUrl:p,modelId:D,models:O,displayName:y,showPassword:U,attemptedSave:f,canSave:m},W={isPending:t,canRemove:!!r},ne={onApiKeyChange:I,onApiChange:F,onBaseUrlChange:L,onModelIdChange:B,onModelsChange:ee,onDisplayNameChange:z,onTogglePassword:()=>H(e=>!e)};return(0,Q.jsxs)(Ct,{title:`Providers`,description:"Locally, API keys are stored in `.env.local`. When deployed, they are stored encrypted in your account.",children:[s?(0,Q.jsx)(tn,{addPickerQuery:l,credentialProvidersLength:v.length,filteredPickerAvailable:C,filteredPickerConfigured:w,pickerHasResults:j,onClose:h,onQueryChange:P,onSelect:N}):x&&Yt(x)?(0,Q.jsx)(nn,{provider:x,onBack:k,onConfigured:g,onOAuthLogin:n},x.id):x?(0,Q.jsx)(rn,{provider:x,api:u,apiKey:d,baseUrl:p,modelId:D,models:O,displayName:y,showPassword:U,attemptedSave:f,isPending:t,canSave:m,onApiKeyChange:I,onApiChange:F,onBaseUrlChange:L,onModelIdChange:B,onModelsChange:ee,onDisplayNameChange:z,onTogglePassword:()=>H(e=>!e),onBack:k,onCancel:g,onConfigured:g,onOAuthLogin:n,onSave:()=>{b&&E(b)}}):(0,Q.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,Q.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Q.jsxs)(Te,{className:`flex-1`,children:[(0,Q.jsx)(Ce,{align:`inline-start`,children:(0,Q.jsx)(K,{})}),(0,Q.jsx)(Se,{type:`text`,placeholder:`Search credentials…`,value:M,onChange:e=>V(e.target.value),"aria-label":`Search credentials`,disabled:e||o.length===0})]}),(0,Q.jsxs)(c,{type:`button`,variant:`outline`,size:`compact`,disabled:e||v.length===0,onClick:k,children:[(0,Q.jsx)(G,{"data-icon":`inline-start`}),`Add provider`]})]}),e?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(X,{className:`size-3`}),(0,Q.jsx)(`span`,{children:`Loading…`})]}):o.length===0?(0,Q.jsxs)(`div`,{className:`flex flex-col items-center gap-3 py-8`,children:[(0,Q.jsx)(`p`,{className:`text-center text-xs text-pretty text-muted-foreground`,children:`No providers configured`}),(0,Q.jsxs)(c,{type:`button`,variant:`outline`,size:`compact`,disabled:v.length===0,onClick:k,children:[(0,Q.jsx)(G,{"data-icon":`inline-start`}),`Add provider`]})]}):S.length===0?(0,Q.jsx)(`p`,{className:`py-6 text-center text-xs text-pretty text-muted-foreground`,children:`No matching providers found.`}):(0,Q.jsx)(sn,{providers:S,editingProvider:b,form:te,operation:W,actions:ne,onEdit:A,onCancelEdit:g,onSave:e=>void E(e),onRemove:R,onOAuthLogin:n,onConfigured:g})]}),(0,Q.jsx)(an,{confirmRemoveProvider:_,isPending:t,onClose:()=>R(null),onConfirm:e=>{T(e)}})]})}function ln(e){return{defaultProvider:e.defaultProvider,defaultModel:e.defaultModel,defaultThinkingLevel:e.defaultThinkingLevel,enabledModels:e.enabledModels===void 0?null:_n(e.enabledModels)}}function un(e){let t=e.enabledModels,n=t==null?null:_n(t).toSorted();return{defaultProvider:e.defaultProvider,defaultModel:e.defaultModel,defaultThinkingLevel:e.defaultThinkingLevel,enabledModels:n}}function dn(e){return{packages:e.packages,extensions:_n(e.extensions),skills:_n(e.skills),prompts:_n(e.prompts),themes:_n(e.themes),enableSkillCommands:e.enableSkillCommands}}function fn(e){return{compaction:{enabled:e.compaction.enabled,reserveTokens:e.compaction.reserveTokens,keepRecentTokens:e.compaction.keepRecentTokens},retry:{enabled:e.retry.enabled,maxRetries:e.retry.maxRetries,baseDelayMs:e.retry.baseDelayMs},transport:e.transport,steeringMode:e.steeringMode,followUpMode:e.followUpMode}}function pn(e,t){return JSON.stringify(e)===JSON.stringify(t)}function mn(e){let t=e?[...e.skills,...e.prompts,...e.extensions,...e.packages,...e.themes,...e.agentsFiles]:[];return{active:t.filter(e=>e.activationStatus===`active`).length,staged:t.filter(e=>e.activationStatus===`staged`).length,reloadRequired:t.filter(e=>e.activationStatus===`reload-required`).length,diagnostics:e?.diagnostics??[],total:t.length}}function hn(e){return e.map(e=>typeof e==`string`?e:JSON.stringify(e))}function gn(e){let t=[];for(let n of e){let e=n.trim();if(!e)continue;if(!e.startsWith(`{`)){t.push(e);continue}let r=JSON.parse(e);if(!r||typeof r!=`object`||Array.isArray(r))throw Error(`Package JSON entries must be objects.`);t.push(r)}return t}function _n(e){return e.flatMap(e=>{let t=e.trim();return t?[t]:[]})}function vn({draft:e,setDraft:t,updateDraft:n,settings:r,providers:i,models:a,modelCatalog:o,onDiscoverModels:s,saveSettings:c,setSavingSection:l}){let[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)([]),[m,h]=(0,Z.useState)(null),g=(0,Z.useRef)(null),_=(0,Z.useMemo)(()=>{let e=new Set;for(let t of i)t.isConfigured&&e.add(t.id);return e},[i]),v=o??a,y=(0,Z.useMemo)(()=>{let t=new Map;for(let e of v)_.has(e.provider)&&t.set(e.id,e);for(let e of f)_.has(e.provider)&&t.set(e.id,e);let n=[...t.values()];return!e?.defaultProvider||!e.defaultModel||n.some(t=>t.provider===e.defaultProvider&&t.modelId===e.defaultModel)||!_.has(e.defaultProvider)?n:[{id:Ft(e.defaultProvider,e.defaultModel),name:e.defaultModel,provider:e.defaultProvider,modelId:e.defaultModel,available:!1},...n]},[v,_,f,e]),b=g.current??(r?un(r.effective):null),x=!!e&&!!b&&!pn(un(e),b),S=(0,Z.useCallback)(()=>{g.current=null},[]),C=async(e,n)=>{t(e),l(`models`);try{let r=await c(ln(e)),i={...r.effective,enabledModels:r.project.enabledModels??e.enabledModels??r.effective.enabledModels,defaultProvider:r.project.defaultProvider??e.defaultProvider??r.effective.defaultProvider,defaultModel:r.project.defaultModel??e.defaultModel??r.effective.defaultModel,defaultThinkingLevel:r.project.defaultThinkingLevel??e.defaultThinkingLevel??r.effective.defaultThinkingLevel};return g.current=un(i),t(i),n?.silent||Y.success(`Pi settings saved`),!0}catch(e){return Y.error(e instanceof Error?e.message:`Settings save failed`),!1}finally{l(null)}},w=e=>{C(e)},T=(t,n)=>{if(!e)return;let r={...e,enabledModels:Lt({currentPatterns:e.enabledModels,enabled:n,model:t,models:y})};w(r)};return{modelFilter:u,setModelFilter:d,modelOptions:y,modelDirty:x,addModels:t=>{if(!e||t.length===0)return;let n=e.enabledModels;for(let e of t)n=Lt({currentPatterns:n,enabled:!0,model:e,models:y});w({...e,enabledModels:n})},removeModel:e=>{T(e,!1)},setDefaultModel:t=>{e&&C({...e,defaultProvider:t.provider,defaultModel:t.modelId})},discoverProvider:async e=>{if(s){h(e);try{let t=await s(e);p(e=>{let n=new Map(e.map(e=>[e.id,e]));for(let e of t)n.set(e.id,e);return[...n.values()]})}finally{h(null)}}},discoveringProviderId:m,commitModelSettings:C,revertModelDraft:()=>{r&&n(e=>({...e,defaultProvider:r.effective.defaultProvider,defaultModel:r.effective.defaultModel,defaultThinkingLevel:r.effective.defaultThinkingLevel,enabledModels:r.effective.enabledModels}))},resetCommittedModelBaseline:S}}var yn=[{value:`auto`,label:`Auto`},{value:`sse`,label:`SSE`},{value:`websocket`,label:`WebSocket`}],bn=[{value:`all`,label:`All`},{value:`one-at-a-time`,label:`One at a time`}];function xn({draft:e,updateDraft:t}){let n=!e;return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)($,{title:`Compaction`,subtitle:`Summarize old turns when context fills up`,trailing:(0,Q.jsx)(me,{"aria-label":`Compaction`,checked:e?.compaction.enabled??!1,disabled:n,onCheckedChange:e=>t(t=>({...t,compaction:{...t.compaction,enabled:e}}))})}),(0,Q.jsx)($,{title:`Auto-retry`,subtitle:`Retry failed provider requests`,trailing:(0,Q.jsx)(me,{"aria-label":`Auto-retry`,checked:e?.retry.enabled??!1,disabled:n,onCheckedChange:e=>t(t=>({...t,retry:{...t.retry,enabled:e}}))})}),(0,Q.jsx)($,{title:`Transport`,trailing:(0,Q.jsx)(C,{"aria-label":`Transport`,className:`w-[160px]`,disabled:n,onValueChange:e=>t(t=>({...t,transport:e})),options:[...yn],value:e?.transport??`auto`})}),(0,Q.jsx)($,{title:`Steering`,subtitle:`How queued steers are delivered mid-turn`,trailing:(0,Q.jsx)(C,{"aria-label":`Steering`,className:`w-[160px]`,disabled:n,onValueChange:e=>t(t=>({...t,steeringMode:e})),options:[...bn],value:e?.steeringMode??`all`})}),(0,Q.jsx)($,{title:`Follow-up`,subtitle:`How queued follow-ups run after the turn`,trailing:(0,Q.jsx)(C,{"aria-label":`Follow-up`,className:`w-[160px]`,disabled:n,onValueChange:e=>t(t=>({...t,followUpMode:e})),options:[...bn],value:e?.followUpMode??`all`})})]})}var Sn=new Set([`auto`,`global`,`local`,`project`,`workspace`]);function Cn(e){let t=e.source?.trim();if(t&&!Sn.has(t))return t;let n=(e.workspacePath??e.path??``).trim();return n?wn(n):e.name.trim()}function wn(e){let t=e.replace(/\\/g,`/`);if(/^\/Users\//.test(t)||/^\/home\//.test(t)||/^[A-Za-z]:\//.test(t))return``;if(!t.startsWith(`/`)&&!/^[A-Za-z]:\//.test(t))return t.startsWith(`agent-workspace/`)?Tn(`../${t}`):t.startsWith(`../agent-workspace/.pi/`)?Tn(t.replace(`../agent-workspace/.pi/`,`../agent-workspace/pi/`)):Tn(t);let n=t.match(/\/(agent-workspace\/.+)$/);if(n?.[1])return Tn(`../${n[1].replace(/^agent-workspace\/\.pi\//,`agent-workspace/pi/`)}`);let r=t.match(/\/\.pi\/(extensions\/.+|skills\/.+|prompts\/.+|themes\/.+)$/);return r?.[1]?Tn(r[1]):``}function Tn(e){return e.replace(/\/SKILL\.md$/i,``).replace(/\/index\.(ts|tsx|js|jsx|mjs|cjs)$/i,``)}function En(e,t){let n=wn(t);return e.some(e=>wn(e)===n)}function Dn(e,t){let n=t.trim();if(!n)return e;let r=wn(n);return!r||En(e,r)?e:[...e,r]}function On({addLabel:e,catalog:t,onChange:n,placeholder:r,values:i}){let[a,o]=(0,Z.useState)(``),s=new Set,l=[];for(let e of t){let t=Cn(e);t.length===0||s.has(t)||(s.add(t),l.push({value:t,label:e.name||t}))}let u=new Map(l.map(e=>[e.value,e.label])),d=e=>u.get(e)??u.get(wn(e)),f=l.filter(e=>!En(i,e.value)),p=()=>{let e=a.trim();e&&(n(Dn(i,e)),o(``))};return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[i.length===0?(0,Q.jsx)(`p`,{className:`px-1 py-2 text-xs text-pretty text-muted-foreground`,children:`Nothing selected yet.`}):i.map(e=>{let t=d(e);return(0,Q.jsx)($,{interactive:!1,title:t??e,subtitle:t&&t!==e?e:void 0,trailing:(0,Q.jsx)(c,{type:`button`,variant:`ghost`,size:`icon-compact`,"aria-label":`Remove ${e}`,onClick:()=>n(i.filter(t=>t!==e)),children:(0,Q.jsx)(O,{})})},e)}),f.length>0?(0,Q.jsx)(C,{"aria-label":e,value:null,placeholder:e,options:f,onValueChange:e=>{e&&n(Dn(i,e))}}):(0,Q.jsxs)(Te,{children:[(0,Q.jsx)(Se,{"aria-label":e,value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),p())},placeholder:r}),(0,Q.jsx)(Ce,{align:`inline-end`,children:(0,Q.jsxs)(we,{onClick:p,disabled:!a.trim(),children:[(0,Q.jsx)(G,{"data-icon":`inline-start`}),`Add`]})})]})]})}function kn({draft:e,onEnableSkillCommandsChange:t,onExtensionsChange:n,onPackageRowsChange:r,onPromptsChange:i,onRevert:a,onSave:o,onSkillsChange:s,onThemesChange:c,packageError:l,packageRows:u,resourceDirty:d,resources:f,resourceSummary:p,saving:m,scope:h=`harness`,settingsLoading:g,updateDraft:_}){let v=!e||g||!!l,y=p.total===0?`Empty`:p.reloadRequired>0?`${p.total} · ${p.reloadRequired} reload`:`${p.total}`;return(0,Q.jsx)(Ct,{title:h===`skills`?`Skills`:`Pi Harness`,description:h===`skills`?`Pick detected workspace skills and slash-command discovery.`:`Runtime (compaction, retry, transport) plus packages, extensions, prompts, and themes.`,actions:(0,Q.jsx)(wt,{dirty:d,disabled:v,onRevert:a,onSave:o,saving:m}),children:h===`skills`?(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)($,{title:`Skill slash commands`,trailing:(0,Q.jsx)(me,{"aria-label":`Skill slash commands`,checked:e?.enableSkillCommands??!0,disabled:!e,onCheckedChange:t})}),(0,Q.jsx)(An,{label:`Skills`,count:e?.skills.length??0,children:(0,Q.jsx)(On,{addLabel:`Add skill`,catalog:f?.skills??[],placeholder:`../agent-workspace/pi/skills`,values:e?.skills??[],onChange:s})})]}):(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsx)(xn,{draft:e,updateDraft:_}),(0,Q.jsx)($,{interactive:!1,title:`Catalog`,subtitle:(0,Q.jsx)(`span`,{className:`tabular-nums`,children:y})}),(0,Q.jsxs)(An,{label:`Packages`,count:u.length,children:[(0,Q.jsx)(On,{addLabel:`Add package`,catalog:f?.packages??[],placeholder:`npm:pi-skills or {"source":"npm:pkg"}`,values:u,onChange:r}),l?(0,Q.jsx)(`p`,{className:`px-1 text-xs text-destructive`,children:l}):null]}),(0,Q.jsx)(An,{label:`Extensions`,count:e?.extensions.length??0,children:(0,Q.jsx)(On,{addLabel:`Add extension`,catalog:f?.extensions??[],placeholder:`../agent-workspace/pi/extensions`,values:e?.extensions??[],onChange:n})}),(0,Q.jsx)(An,{label:`Prompts`,count:e?.prompts.length??0,children:(0,Q.jsx)(On,{addLabel:`Add prompt`,catalog:f?.prompts??[],placeholder:`../agent-workspace/pi/prompts`,values:e?.prompts??[],onChange:i})}),(0,Q.jsx)(An,{label:`Themes`,count:e?.themes.length??0,children:(0,Q.jsx)(On,{addLabel:`Add theme`,catalog:f?.themes??[],placeholder:`../agent-workspace/pi/themes`,values:e?.themes??[],onChange:c})})]})})}function An({children:e,count:t,label:n}){return(0,Q.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,Q.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2 px-1`,children:[(0,Q.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:n}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground tabular-nums`,children:t===1?`1 item`:`${t} items`})]}),e]})}function jn({isLoading:e,isPending:t,onUpdateProvider:n,providers:r}){let[i,a]=(0,Z.useState)(!1),[o,s]=(0,Z.useState)(``),[u,d]=(0,Z.useState)(``),[f,p]=(0,Z.useState)(!1),[m,g]=(0,Z.useState)(!1),_=(0,Z.useMemo)(()=>r.find(e=>e.id===`daytona`),[r]),v=(0,Z.useMemo)(()=>r.find(e=>e.id===`daytona-target`),[r]),y=!!(_?.isConfigured&&v?.isConfigured),b=()=>{s(``),d(``),p(!1),g(!1)},x=()=>{a(!1),b()},S=async()=>{if(n&&(g(!0),!(!o.trim()&&!u.trim())))try{o.trim()&&await n({providerId:`daytona`,apiKey:o.trim()}),u.trim()&&await n({providerId:`daytona-target`,apiKey:u.trim()}),Y.success(`Sandbox Provider updated successfully`),x()}catch(e){Y.error(e instanceof Error?e.message:`Failed to update provider`)}},C=o.trim().length>0||u.trim().length>0;return(0,Q.jsx)(Ct,{title:`Sandbox`,description:`Configure isolated execution environments.`,children:e?(0,Q.jsxs)(`div`,{className:`flex items-center justify-center gap-2 py-6 text-xs text-muted-foreground`,children:[(0,Q.jsx)(X,{}),(0,Q.jsx)(`span`,{children:`Loading…`})]}):(0,Q.jsxs)(`div`,{className:`flex flex-col`,children:[(0,Q.jsx)($,{interactive:!1,icon:(0,Q.jsx)(B,{className:`size-4 text-foreground/80`}),title:`Daytona`,subtitle:`DAYTONA_API_KEY · DAYTONA_TARGET`,trailing:(0,Q.jsx)(c,{type:`button`,variant:`ghost`,size:`compact`,className:l(Oe,`h-7 px-2 text-xs transition-[background-color,transform] duration-150 active:scale-[0.96]`),onClick:()=>{if(i){x();return}a(!0),b()},children:i?`Cancel`:y?`Update`:`Configure`})}),i?(0,Q.jsxs)(St,{tone:`inset`,padding:`md`,className:`flex flex-col gap-2 border-t border-border/30`,children:[(0,Q.jsxs)(de,{className:`gap-2`,children:[(0,Q.jsx)(gt,{attemptedSave:m,label:`Daytona API key`,placeholder:`Enter Daytona API Key…`,value:o,showPassword:f,required:!1,onChange:s,onToggleVisibility:()=>p(e=>!e)}),(0,Q.jsx)(_t,{attemptedSave:m,icon:L,label:`Region / target`,placeholder:`e.g. us-east`,value:u,required:!1,onChange:d})]}),(0,Q.jsxs)(pe,{className:`px-3 py-2`,children:[(0,Q.jsx)(h,{}),(0,Q.jsx)(ue,{className:`text-xs text-pretty`,children:`Settings are stored securely in your local environment overrides. Provide at least one value to save.`})]}),(0,Q.jsx)(`div`,{className:`flex items-center justify-end`,children:(0,Q.jsxs)(c,{type:`button`,size:`compact`,disabled:t||!C,onClick:()=>void S(),children:[t?(0,Q.jsx)(X,{"data-icon":`inline-start`}):null,`Save`]})})]}):null]})})}var Mn={appearance:{id:`appearance`,order:10,title:`Appearance`,ariaLabel:`Appearance settings`,icon:Xe,group:`workspace`},chat:{id:`chat`,order:20,title:`Chat`,ariaLabel:`Chat settings`,icon:Je,group:`workspace`},mcp:{id:`mcp`,order:25,title:`MCP`,ariaLabel:`MCP connection settings`,icon:ne,group:`workspace`},sandbox:{id:`sandbox`,order:30,title:`Sandbox`,ariaLabel:`Sandbox settings`,icon:B,group:`advanced`},providers:{id:`providers`,order:40,title:`Providers`,ariaLabel:`Provider settings`,icon:He,group:`models`},"llm-models":{id:`llm-models`,order:50,title:`LLM Models`,ariaLabel:`LLM model settings`,icon:A,group:`models`},skills:{id:`skills`,order:60,title:`Skills`,ariaLabel:`Skill settings`,icon:R,group:`advanced`},"pi-harness":{id:`pi-harness`,order:70,title:`Pi Harness`,ariaLabel:`Pi harness settings`,icon:D,group:`advanced`},keybindings:{id:`keybindings`,order:80,title:`Keybindings`,ariaLabel:`Keybinding settings`,icon:ee,group:`advanced`},sessions:{id:`sessions`,order:90,title:`Sessions`,ariaLabel:`Session settings`,icon:it,group:`workspace`}},Nn=[{id:`workspace`,label:`Workspace`},{id:`models`,label:`Models`},{id:`advanced`,label:`Advanced`}],Pn=Object.values(Mn).sort((e,t)=>e.order-t.order);function Fn(e){return Pn.some(t=>t.id===e)}function In({draft:e,settings:t,updateDraft:n}){let[r,i]=(0,Z.useState)(null),[a,o]=(0,Z.useState)(),s=(0,Z.useMemo)(()=>hn(t?.effective.packages??[]),[t?.effective.packages]),c=r??s;return{packageRows:c,packageError:a,resourceDirty:!!e&&!!t&&(!pn(dn(e),dn(t.effective))||!pn(fn(e),fn(t.effective))||!pn(c.filter(e=>e.trim()),hn(t.effective.packages))),handlePackageRowsChange:e=>{i(e);try{let t=gn(e);o(void 0),n(e=>({...e,packages:t}))}catch(e){o(e instanceof Error?e.message:String(e))}},revertResourceDraft:()=>{t&&(n(e=>({...e,packages:t.effective.packages,extensions:t.effective.extensions,skills:t.effective.skills,prompts:t.effective.prompts,themes:t.effective.themes,enableSkillCommands:t.effective.enableSkillCommands,compaction:t.effective.compaction,retry:t.effective.retry,transport:t.effective.transport,steeringMode:t.effective.steeringMode,followUpMode:t.effective.followUpMode})),i(null),o(void 0))}}}function Ln({className:e,...t}){return(0,Q.jsx)(`nav`,{"aria-label":`breadcrumb`,"data-slot":`breadcrumb`,className:l(e),...t})}function Rn({className:e,...t}){return(0,Q.jsx)(`ol`,{"data-slot":`breadcrumb-list`,className:l(`flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground`,e),...t})}function zn({className:e,...t}){return(0,Q.jsx)(`li`,{"data-slot":`breadcrumb-item`,className:l(`inline-flex items-center gap-1`,e),...t})}function Bn({className:e,...t}){return(0,Q.jsx)(`span`,{"data-slot":`breadcrumb-page`,"aria-current":`page`,className:l(`font-normal text-foreground`,e),...t})}function Vn({children:e,className:t,...n}){return(0,Q.jsx)(`li`,{"data-slot":`breadcrumb-separator`,role:`presentation`,"aria-hidden":`true`,className:l(`[&>svg]:size-3.5`,t),...n,children:e??(0,Q.jsx)(F,{})})}var Hn=Z.createContext(void 0);function Un(){let e=Z.useContext(Hn);if(e===void 0)throw Error(p(53));return e}function Wn(e,t,n){if(!e)return 0;let r=getComputedStyle(e),i=`${t}${n===`x`?`Inline`:`Block`}`,a=parseFloat(r[`${i}Start`]);return n===`x`&&t===`margin`?a*2:a+parseFloat(r[`${i}End`])}var Gn=`data-has-overflow-x`,Kn=`data-has-overflow-y`,qn=`data-overflow-x-start`,Jn=`data-overflow-x-end`,Yn=`data-overflow-y-start`,Xn=`data-overflow-y-end`,Zn=e=>t=>t?{[e]:``}:null,Qn={hasOverflowX:Zn(Gn),hasOverflowY:Zn(Kn),overflowXStart:Zn(qn),overflowXEnd:Zn(Jn),overflowYStart:Zn(Yn),overflowYEnd:Zn(Xn),cornerHidden:()=>null},$n=`--scroll-area-corner-height`,er=`--scroll-area-corner-width`,tr=`data-orientation`,nr={x:0,y:0},rr={width:0,height:0},ir={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},ar={x:!0,y:!0,corner:!0},or=Z.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,style:o,...c}=e,{xStart:l,xEnd:u,yStart:p,yEnd:m}=sr(i),h=T(),g=a(),_=a(),{nonce:v,disableStyleElements:b}=S(),[x,C]=Z.useState(!1),[w,E]=Z.useState(!1),[D,O]=Z.useState(!1),[k,A]=Z.useState(!1),[j,M]=Z.useState(!1),[N,P]=Z.useState(rr),[F,I]=Z.useState(rr),[L,R]=Z.useState(ir),[z,B]=Z.useState(ar),ee=Z.useRef(null),V=Z.useRef(null),H=Z.useRef(null),U=Z.useRef(null),te=Z.useRef(null),W=Z.useRef(null),ne=Z.useRef(null),G=Z.useRef(null),re=Z.useRef(0),ie=Z.useRef(0),ae=Z.useRef(0),oe=Z.useRef(0),K=Z.useRef(`vertical`),se=Z.useRef(nr),ce=Z.useRef(null);function le(e){let t=e?O:E,n=e?g:_;t(!0),n.start(500,()=>{t(!1)})}let q=f(e=>{let t=e.x-se.current.x,n=e.y-se.current.y;se.current=e,n!==0&&le(!0),t!==0&&le(!1)}),ue=f(()=>{let e=V.current;e&&ce.current===null&&(ce.current=e.style.scrollSnapType,e.style.scrollSnapType=`none`)}),de=f(e=>{if(e.button!==0||G.current!==null&&(K.current===`vertical`?te.current:W.current)?.hasPointerCapture(G.current))return;G.current=e.pointerId,re.current=e.clientY,ie.current=e.clientX,K.current=e.currentTarget.getAttribute(tr);let t=V.current;t&&(ae.current=t.scrollTop,oe.current=t.scrollLeft,ue()),(K.current===`vertical`?te.current:W.current)?.setPointerCapture(e.pointerId)}),J=f(e=>{if(e.pointerId!==G.current)return;G.current=null,(K.current===`vertical`?O:E)(!1),ce.current!==null&&(V.current&&(V.current.style.scrollSnapType=ce.current),ce.current=null);let t=K.current===`vertical`?te.current:W.current;t?.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId)}),fe=f(e=>{if(e.pointerId!==G.current)return;if(e.buttons%2==0){J(e);return}let t=V.current;if(!t)return;let n=K.current===`vertical`,r=n?te.current:W.current,i=n?H.current:U.current;if(!r||!i)return;let a=n?`y`:`x`,o=Wn(i,`padding`,a),s=Wn(r,`margin`,a),c=n?r.offsetHeight:r.offsetWidth,l=(n?i.offsetHeight:i.offsetWidth)-c-o-s,u=n?e.clientY-re.current:e.clientX-ie.current,d=l<=0?0:u/l,f=n?t.scrollHeight:t.scrollWidth,p=n?t.clientHeight:t.clientWidth,m=(n?ae.current:oe.current)+d*(f-p);n?t.scrollTop=m:t.scrollLeft=m,e.preventDefault(),le(n)});function pe(e){A(e.pointerType===`touch`)}function me(e){if(pe(e),e.pointerType!==`touch`){let t=s(ee.current,e.target);C(t)}}let he=Z.useMemo(()=>({scrolling:w||D,hasOverflowX:!z.x,hasOverflowY:!z.y,overflowXStart:L.xStart,overflowXEnd:L.xEnd,overflowYStart:L.yStart,overflowYEnd:L.yEnd,cornerHidden:z.corner}),[w,D,z.x,z.y,z.corner,L]),ge={role:`presentation`,onPointerEnter:me,onPointerMove:me,onPointerDown:pe,onPointerLeave(){C(!1)},style:{position:`relative`,[$n]:`${N.height}px`,[er]:`${N.width}px`}},_e=d(`div`,e,{state:he,ref:[t,ee],props:[ge,c],stateAttributesMapping:Qn}),ve=Z.useMemo(()=>({handlePointerDown:de,handlePointerMove:fe,handlePointerUp:J,handleScroll:q,disableViewportSnap:ue,cornerSize:N,setCornerSize:P,thumbSize:F,setThumbSize:I,hasMeasuredScrollbar:j,setHasMeasuredScrollbar:M,touchModality:k,cornerRef:ne,scrollingX:w,scrollingY:D,hovering:x,setHovering:C,viewportRef:V,scrollbarYRef:H,scrollbarXRef:U,thumbYRef:te,thumbXRef:W,rootId:h,hiddenState:z,setHiddenState:B,overflowEdges:L,setOverflowEdges:R,viewportState:he,overflowEdgeThreshold:{xStart:l,xEnd:u,yStart:p,yEnd:m}}),[de,fe,J,q,ue,N,F,j,k,w,D,x,h,z,L,he,l,u,p,m]);return(0,Q.jsxs)(Hn.Provider,{value:ve,children:[!b&&y.getElement(v),_e]})});function sr(e){let t=typeof e==`number`?{xStart:e,xEnd:e,yStart:e,yEnd:e}:e;return{xStart:Math.max(0,t?.xStart||0),xEnd:Math.max(0,t?.xEnd||0),yStart:Math.max(0,t?.yStart||0),yEnd:Math.max(0,t?.yEnd||0)}}var cr=Z.createContext(void 0);function lr(){let e=Z.useContext(cr);if(e===void 0)throw Error(p(55));return e}var ur=`--scroll-area-overflow-x-start`,dr=`--scroll-area-overflow-x-end`,fr=`--scroll-area-overflow-y-start`,pr=`--scroll-area-overflow-y-end`,mr=`--scroll-area-thumb-height`,hr=`--scroll-area-thumb-width`,gr=[ur,dr,fr,pr],_r=!1;function vr(){_r||i||(typeof CSS<`u`&&`registerProperty`in CSS&&gr.forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),_r=!0)}var yr=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...o}=e,{viewportRef:s,scrollbarYRef:c,scrollbarXRef:l,thumbYRef:u,thumbXRef:p,cornerRef:h,cornerSize:g,setCornerSize:v,setThumbSize:x,rootId:S,setHiddenState:C,hiddenState:w,setHasMeasuredScrollbar:T,handleScroll:E,touchModality:D,setHovering:O,setOverflowEdges:k,overflowEdgeThreshold:A,viewportState:j}=Un(),M=_(),N=Z.useRef(!0),P=Z.useRef([NaN,NaN,NaN,NaN]),F=a(),I=a(),L=f(()=>{let e=s.current,t=c.current,n=l.current,r=u.current,i=p.current,a=h.current;if(!e)return;let o=e.scrollHeight,d=e.scrollWidth,f=e.clientHeight,m=e.clientWidth,_=e.scrollTop,y=e.scrollLeft,S=P.current,w=Number.isNaN(S[0]);if(S[0]=f,S[1]=o,S[2]=m,S[3]=d,w&&T(!0),o===0||d===0)return;let E=br(e),D=E.y,O=E.x,j=m/d,N=f/o,F=Math.max(0,d-m),I=Math.max(0,o-f),L=0,R=0;O||(L=b(M===`rtl`?-y:y,F),R=F-L);let z=D?0:b(_,I),B=D?0:I-z,ee=O?0:m,V=D?0:f,H=0,U=0;!O&&!D&&(H=t?.offsetWidth||0,U=n?.offsetHeight||0);let te=g.width===0&&g.height===0,W=te?H:0,ne=te?U:0,G=Wn(n,`padding`,`x`),re=Wn(t,`padding`,`y`),ie=Wn(i,`margin`,`x`),ae=Wn(r,`margin`,`y`),oe=ee-G-ie,K=V-re-ae,se=n?Math.min(n.offsetWidth-W,oe):oe,ce=t?Math.min(t.offsetHeight-ne,K):K,le=Math.max(16,se*j),q=Math.max(16,ce*N);if(x(e=>xr(e,{width:le,height:q})),t&&r){let e=Sr(r,mr,_,I,o,q,t.offsetHeight-q-re-ae);r.style.transform=`translate3d(0,${e}px,0)`}if(n&&i){let e=n.offsetWidth-le-G-ie,t=Sr(i,hr,M===`rtl`?-y:y,F,d,le,e);i.style.transform=`translate3d(${M===`rtl`?-t:t}px,0,0)`}let ue=[L,R,z,B];gr.forEach((t,n)=>{e.style.setProperty(t,`${ue[n]}px`)}),a&&v(e=>xr(e,{width:H,height:U})),C(e=>xr(e,E));let de={xStart:!O&&L>A.xStart,xEnd:!O&&R>A.xEnd,yStart:!D&&z>A.yStart,yEnd:!D&&B>A.yEnd};k(e=>xr(e,de))});m(()=>{vr()},[]),m(()=>{queueMicrotask(L)},[L,w,M,A.xStart,A.xEnd,A.yStart,A.yEnd]),m(()=>{s.current?.matches(`:hover`)&&O(!0)},[s,O]),m(()=>{let e=s.current;if(typeof ResizeObserver>`u`||!e)return;let t=!1,n=new ResizeObserver(()=>{if(!t){t=!0;let n=P.current;if(n[0]===e.clientHeight&&n[1]===e.scrollHeight&&n[2]===e.clientWidth&&n[3]===e.scrollWidth)return}L()});return n.observe(e),I.start(0,()=>{let t=e.getAnimations({subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished)).then(L).catch(()=>{})}),()=>{n.disconnect(),I.clear()}},[L,s,I]);function R(){N.current=!1}let z={role:`presentation`,...S&&{"data-id":`${S}-viewport`},tabIndex:w.x&&w.y?-1:0,className:y.className,style:{overflow:`scroll`},onScroll(){s.current&&(L(),(D||!N.current)&&E({x:s.current.scrollLeft,y:s.current.scrollTop}),F.start(100,()=>{N.current=!0}))},onWheel:R,onPointerMove:R,onPointerEnter:R,onKeyDown:R},B=d(`div`,e,{ref:[t,s],state:j,props:[z,o],stateAttributesMapping:Qn}),ee=Z.useMemo(()=>({computeThumbPosition:L}),[L]);return(0,Q.jsx)(cr.Provider,{value:ee,children:B})});function br(e){let t=e.clientHeight>=e.scrollHeight,n=e.clientWidth>=e.scrollWidth;return{y:t,x:n,corner:t||n}}function xr(e,t){for(let n in t)if(e[n]!==t[n])return t;return e}function Sr(e,t,n,r,i,a,o){let s=g(n,0,r),c=n-s,l=Math.max(16,a*i/(i+Math.abs(c)));return e.style.setProperty(t,c?`${l}px`:``),(r?s/r*o:0)+(c>0?a-l:0)}var Cr=Z.createContext(void 0);function wr(){let e=Z.useContext(Cr);if(e===void 0)throw Error(p(54));return e}var Tr=Z.forwardRef(function(e,t){let{render:n,className:i,orientation:a=`vertical`,keepMounted:o=!1,style:c,...l}=e,{hovering:f,scrollingX:p,scrollingY:m,hiddenState:h,scrollbarYRef:g,scrollbarXRef:v,viewportRef:y,thumbYRef:b,thumbXRef:x,handlePointerDown:S,handlePointerUp:C,handleScroll:w,disableViewportSnap:T,rootId:E,thumbSize:D,hasMeasuredScrollbar:O,viewportState:k}=Un(),A=a===`vertical`,j={...k,hovering:f,scrolling:A?m:p,orientation:a},M=_(),N=!O&&!o,P=A?h.y:h.x,F=o||!P;Z.useEffect(()=>{if(!F)return;let e=y.current,t=A?g.current:v.current;if(!t)return;function n(t){if(!e||t.ctrlKey)return;let n=!A,r=n?`scrollLeft`:`scrollTop`,i=n?t.deltaX:t.deltaY;if(i===0)return;let a=n?e.scrollWidth-e.clientWidth:e.scrollHeight-e.clientHeight,o=n&&M===`rtl`?-a:0,s=n&&M===`rtl`?0:a,c=e[r];c<=o&&i<0||c>=s&&i>0||(t.preventDefault(),e[r]=Math.min(s,Math.max(o,c+i)),w({x:e.scrollLeft,y:e.scrollTop}))}return u(t,`wheel`,n,{passive:!1})},[M,w,A,v,g,F,y]);let I={...E&&{"data-id":`${E}-scrollbar`},"aria-hidden":!0,onPointerDown(e){if(e.button!==0)return;let t=r(e.nativeEvent),n=A?b.current:x.current;if(n&&s(n,t))return;let i=y.current;if(!i)return;let a=A?g.current:v.current;if(!n||!a)return;let o=A?`y`:`x`,c=Wn(n,`margin`,o),l=Wn(a,`padding`,o),u=A?n.offsetHeight:n.offsetWidth,d=a.getBoundingClientRect(),f=A?e.clientY-d.top-u/2-l+c/2:e.clientX-d.left-u/2-l+c/2,p=A?i.scrollHeight:i.scrollWidth,m=A?i.clientHeight:i.clientWidth,h=(A?a.offsetHeight:a.offsetWidth)-u-l-c;if(h<=0)return;let _=f/h,C=p-m;T(),A?i.scrollTop=_*C:i.scrollLeft=M===`rtl`?-(1-_)*C:_*C,w({x:i.scrollLeft,y:i.scrollTop}),S(e)},onMouseDown(e){e.preventDefault()},onPointerUp:C,onPointerCancel:C,style:{position:`absolute`,touchAction:`none`,WebkitUserSelect:`none`,userSelect:`none`,visibility:N?`hidden`:void 0,...A?{top:0,bottom:`var(${$n})`,insetInlineEnd:0,[mr]:`${D.height}px`}:{insetInlineStart:0,insetInlineEnd:`var(${er})`,bottom:0,[hr]:`${D.width}px`}}},L=d(`div`,e,{ref:[t,A?g:v],state:j,props:[I,l],stateAttributesMapping:Qn});return F?(0,Q.jsx)(Cr.Provider,{value:a,children:L}):null}),Er=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{computeThumbPosition:o}=lr(),{hasMeasuredScrollbar:s,viewportState:c}=Un(),l=Z.useRef(null),u=Z.useRef(s);return m(()=>{if(typeof ResizeObserver>`u`)return;let e=!1,t=new ResizeObserver(()=>{!e&&(e=!0,!u.current)||o()});return l.current&&t.observe(l.current),()=>{t.disconnect()}},[o]),d(`div`,e,{ref:[t,l],state:c,stateAttributesMapping:Qn,props:[{role:`presentation`,style:{minWidth:`fit-content`}},a]})}),Dr=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{thumbYRef:o,thumbXRef:s,handlePointerDown:c,handlePointerMove:l,handlePointerUp:u,scrollingX:f,scrollingY:p,hasMeasuredScrollbar:m}=Un(),h=wr(),g=h===`vertical`;return d(`div`,e,{ref:[t,g?o:s],state:{scrolling:g?p:f,orientation:h},props:[{onPointerDown:c,onPointerMove:l,onPointerUp:u,onPointerCancel:u,style:{visibility:m?void 0:`hidden`,...g?{height:`var(--scroll-area-thumb-height)`}:{width:`var(--scroll-area-thumb-width)`}}},a]})}),Or=Z.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,{cornerRef:o,cornerSize:s,hiddenState:c}=Un(),l=d(`div`,e,{ref:[t,o],props:[{"aria-hidden":!0,style:{position:`absolute`,bottom:0,insetInlineEnd:0,width:s.width,height:s.height}},a]});return c.corner?null:l});function kr(){let[e,t]=(0,Z.useState)(!1);return(0,Z.useEffect)(()=>{if(typeof window>`u`)return;let e=new AbortController,{signal:n}=e,r=()=>{let e=`ontouchstart`in window||navigator.maxTouchPoints>0,n=window.matchMedia(`(pointer: coarse)`).matches;t(e&&n)};return window.matchMedia(`(pointer: coarse)`).addEventListener(`change`,r,{signal:n}),window.addEventListener(`pointerdown`,r,{signal:n}),r(),()=>e.abort()},[]),e}var Ar=(0,Z.createContext)(!1),jr=(0,Z.forwardRef)(({className:e,children:t,viewportClassName:n,orientation:r=`vertical`,...i},a)=>{let o=kr();return(0,Q.jsx)(Ar.Provider,{value:o,children:o?(0,Q.jsx)(`div`,{ref:a,role:`group`,"data-slot":`scroll-area`,"aria-roledescription":`scroll area`,className:l(`relative overflow-hidden`,e),...i,children:(0,Q.jsx)(`div`,{"data-slot":`scroll-area-viewport`,className:l(`size-full rounded-[inherit]`,r===`vertical`&&`overflow-y-auto`,r===`horizontal`&&`overflow-x-auto`,r===`both`&&`overflow-auto`,n),tabIndex:0,children:t})}):(0,Q.jsxs)(or,{ref:a,"data-slot":`scroll-area`,className:l(`relative overflow-hidden`,e),...i,children:[(0,Q.jsx)(yr,{"data-slot":`scroll-area-viewport`,className:l(`size-full rounded-[inherit]`,n),children:(0,Q.jsx)(Er,{children:t})}),r!==`horizontal`&&(0,Q.jsx)(Mr,{orientation:`vertical`}),r!==`vertical`&&(0,Q.jsx)(Mr,{orientation:`horizontal`}),r===`both`&&(0,Q.jsx)(Or,{})]})})});jr.displayName=`ScrollArea`;var Mr=(0,Z.forwardRef)(({className:e,orientation:t=`vertical`,...n},r)=>{let i=(0,Z.useContext)(Ar),a=o();return i?null:(0,Q.jsx)(Tr,{ref:r,orientation:t,"data-slot":`scroll-area-scrollbar`,className:l(`group/scrollbar absolute z-20 flex touch-none select-none`,`opacity-0 transition-opacity duration-120 ease-out delay-160`,`data-[hovering]:duration-160 data-[scrolling]:duration-160`,`data-[hovering]:opacity-100 data-[scrolling]:opacity-100`,`data-[hovering]:delay-0 data-[scrolling]:delay-0`,t===`vertical`&&`top-0 right-0 h-full w-2.5`,t===`horizontal`&&`bottom-0 left-0 h-2.5 w-full flex-col`,e),...n,children:(0,Q.jsx)(Dr,{"data-slot":`scroll-area-thumb`,className:l(`relative bg-[rgb(var(--overlay)/0.08)] transition-[background-color,width,height] duration-160 ease-in-out`,`group-hover/scrollbar:bg-[rgb(var(--overlay)/0.12)] active:!bg-[rgb(var(--overlay)/0.16)]`,a.bg,t===`vertical`&&`mx-auto my-1 w-1 -translate-x-0.5 h-[var(--scroll-area-thumb-height)] group-hover/scrollbar:w-1.5`,t===`horizontal`&&`my-auto mx-1 h-1 -translate-y-0.5 w-[var(--scroll-area-thumb-width)] group-hover/scrollbar:h-1.5`)})})});Mr.displayName=`ScrollBar`;function Nr(){let{isLoadingMcp:e,isLoadingProviders:t,isUpdatingMcp:n,isUpdatingProvider:r,mcpConnections:i=[],modelCatalog:a,onDiscoverModels:o,onMcpOAuth:s,onOAuthLogin:c,onRemoveMcp:l,onRemoveProvider:u,onThemePreferenceChange:d,onUpdateMcp:f,onUpdateProvider:p,providers:m=[],saveSettings:h,settings:g,settingsLoading:_,themePreference:v}=ie(),{models:y,resources:b}=re(),[x,S]=(0,Z.useState)(null),[C,w]=(0,Z.useState)(null),T=mn(b),E=e=>{S(t=>t&&e(t))},{packageRows:D,packageError:O,resourceDirty:k,handlePackageRowsChange:A,revertResourceDraft:j}=In({draft:x,settings:g,updateDraft:E}),{modelFilter:M,setModelFilter:N,modelOptions:P,modelDirty:F,addModels:I,removeModel:L,setDefaultModel:R,discoverProvider:z,discoveringProviderId:B,commitModelSettings:ee,revertModelDraft:V,resetCommittedModelBaseline:H}=vn({draft:x,setDraft:S,updateDraft:E,settings:g,providers:m,models:y,modelCatalog:a,onDiscoverModels:o,saveSettings:h,setSavingSection:w}),U=F||k;return(0,Z.useEffect)(()=>{if(!g)return;let e=g.effective;x&&U||x&&pn(x,e)||S(e)},[x,U,g]),{isLoadingMcp:e,isLoadingProviders:t,isUpdatingMcp:n,isUpdatingProvider:r,mcpConnections:i,onMcpOAuth:s,onOAuthLogin:c,onRemoveMcp:l,onRemoveProvider:u,onThemePreferenceChange:d,onUpdateMcp:f,onUpdateProvider:p,providers:m,resources:b,settingsLoading:_,themePreference:v,draft:x,savingSection:C,packageRows:D,packageError:O,modelFilter:M,setModelFilter:N,resourceSummary:T,modelOptions:P,modelDirty:F,resourceDirty:k,revertResourceDraft:j,revertModelDraft:V,resetDraft:()=>{g&&S(g.effective)},updateDraft:E,handlePackageRowsChange:A,addModels:I,removeModel:L,setDefaultModel:R,discoverProvider:z,discoveringProviderId:B,saveSection:async(e,t)=>{if(e===`models`&&x){if(!await ee(x))throw Error(`Settings save failed`);return}w(e);try{await h(t),Y.success(`Pi settings saved`)}catch(e){throw Y.error(e instanceof Error?e.message:`Settings save failed`),e}finally{w(null)}},requestCloseSettings:async()=>C===`models`?`wait`:k?`discard-prompt`:F&&x?await ee(x,{silent:!0})?`close`:`discard-prompt`:`close`,resetCommittedModelBaseline:H}}function Pr({active:e,onClick:t,icon:n,label:r}){return(0,Q.jsxs)(`button`,{type:`button`,onClick:t,className:l(`flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-label transition-colors`,e?`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:bg-muted hover:text-foreground`),children:[(0,Q.jsx)(n,{className:`size-4 shrink-0`}),(0,Q.jsx)(`span`,{children:r})]})}function Fr({open:e,onOpenChange:t,initialTab:n}){return(0,Z.useEffect)(()=>{ce(le())},[]),(0,Q.jsx)(Ir,{initialTab:n,onOpenChange:t,open:e})}function Ir({initialTab:e,onOpenChange:t,open:n}){let r=(0,Z.useRef)(()=>{t(!1)});return(0,Q.jsx)(ye,{open:n,onOpenChange:(e,n)=>{if(e){t(!0);return}r.current(n)},children:n?(0,Q.jsx)(Rr,{initialTab:e,onCloseAttemptRef:r,onOpenChange:t}):null})}function Lr({activeTab:e,composerIntent:t,form:n,onComposerIntentChange:r,onComposerIntentKeyChange:i,preferences:a,updatePreference:o}){let{isLoadingMcp:s,isLoadingProviders:c,isUpdatingMcp:l,isUpdatingProvider:u,mcpConnections:d,onMcpOAuth:f,onOAuthLogin:p,onRemoveMcp:m,onRemoveProvider:h,onThemePreferenceChange:g,onUpdateMcp:_,onUpdateProvider:v,providers:y,resources:b,settingsLoading:x,themePreference:S,draft:w,savingSection:T,packageRows:E,packageError:D,modelFilter:O,setModelFilter:k,resourceSummary:A,modelOptions:j,modelDirty:M,resourceDirty:N,revertResourceDraft:P,revertModelDraft:F,updateDraft:I,handlePackageRowsChange:L,addModels:R,removeModel:z,setDefaultModel:B,discoverProvider:ee,discoveringProviderId:V,saveSection:H}=n,U=e=>(0,Q.jsx)(kn,{scope:e,draft:w,updateDraft:I,onEnableSkillCommandsChange:e=>I(t=>({...t,enableSkillCommands:e})),onExtensionsChange:e=>I(t=>({...t,extensions:e})),onPackageRowsChange:L,onPromptsChange:e=>I(t=>({...t,prompts:e})),onRevert:P,onSave:()=>w&&H(`resources`,{...dn(w),...e===`harness`?fn(w):{}}),onSkillsChange:e=>I(t=>({...t,skills:e})),onThemesChange:e=>I(t=>({...t,themes:e})),packageError:D,packageRows:E,resourceDirty:N,resources:b,resourceSummary:A,saving:T===`resources`,settingsLoading:x});return{appearance:()=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-medium`,children:`Appearance`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Customize the look and feel of the interface.`})]}),(0,Q.jsx)(Pt,{onThemePreferenceChange:g,themePreference:S}),(0,Q.jsx)(vt,{label:`Density`,description:`Adjust spacing across chat and panels.`,children:(0,Q.jsx)(C,{"aria-label":`Density`,value:a.density,onValueChange:e=>o(`density`,e),options:[{label:`Comfortable`,value:`comfortable`},{label:`Compact`,value:`compact`}]})}),(0,Q.jsx)(vt,{label:`Motion`,description:`Respect the system setting or reduce UI motion.`,children:(0,Q.jsx)(C,{"aria-label":`Motion`,value:a.motion,onValueChange:e=>o(`motion`,e),options:[{label:`System`,value:`system`},{label:`Reduced`,value:`reduced`}]})})]}),chat:()=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-medium`,children:`Chat`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Control transcript behavior.`})]}),(0,Q.jsx)(vt,{label:`Streaming transcript`,description:`Follow new output or preserve the reading position.`,children:(0,Q.jsx)(C,{"aria-label":`Streaming transcript`,value:a.transcript,onValueChange:e=>o(`transcript`,e),options:[{label:`Follow output`,value:`follow`},{label:`Manual`,value:`manual`}]})}),(0,Q.jsx)(xt,{enabled:t?.enabled??!1,keySource:t?.keySource??`none`,status:t?.status??`unconfigured`,onClearKey:()=>i?.(null),onEnabledChange:r,onSaveKey:e=>i?.(e)})]}),mcp:()=>(0,Q.jsx)(Mt,{connections:d,isLoading:s??!1,isPending:l??!1,onOAuth:f,onRemove:m,onUpsert:_}),sandbox:()=>(0,Q.jsx)(jn,{isLoading:c??!1,isPending:u??!1,providers:y,onUpdateProvider:v}),providers:()=>(0,Q.jsx)(cn,{isLoading:c??!1,isPending:u??!1,providers:y,onOAuthLogin:p,onRemoveProvider:h,onUpdateProvider:v}),"llm-models":()=>(0,Q.jsx)(Vt,{draft:w,discoveringProviderId:V,modelDirty:M,modelFilter:O,modelOptions:j,onAddModels:R,onDiscoverProvider:ee,onModelFilterChange:k,onRemoveModel:z,onSetDefaultModel:B,providers:y,onRevert:F,onSave:()=>w&&H(`models`,ln(w)),saving:T===`models`,settingsLoading:x}),skills:()=>U(`skills`),"pi-harness":()=>U(`harness`),keybindings:()=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4 text-sm`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-medium`,children:`Keybindings`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Every shortcut also has a visible control in the header, panel, or composer.`})]}),(0,Q.jsxs)(`div`,{className:`rounded-xl border p-4 font-mono text-xs leading-7`,children:[(0,Q.jsx)(`div`,{children:`Command palette: Ctrl/Command K`}),(0,Q.jsx)(`div`,{children:`Conversation sidebar: Ctrl/Command B`}),(0,Q.jsx)(`div`,{children:`Toggle Resources: Ctrl/Command Shift 1`}),(0,Q.jsx)(`div`,{children:`Toggle Workspace: Ctrl/Command Shift 2`}),(0,Q.jsx)(`div`,{children:`Toggle Artifacts: Ctrl/Command Shift 3`}),(0,Q.jsx)(`div`,{children:`Focus active panel: Ctrl/Command Shift P`}),(0,Q.jsx)(`div`,{children:`Return focus to chat: Ctrl/Command Shift C`}),(0,Q.jsx)(`div`,{children:`Close active panel: Escape`})]})]}),sessions:()=>(0,Q.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,Q.jsxs)(`div`,{children:[(0,Q.jsx)(`h3`,{className:`text-lg font-medium`,children:`Sessions`}),(0,Q.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Set local conversation preferences. Provider and workspace configuration remains Fleet Prime-owned.`})]}),(0,Q.jsx)(vt,{label:`Confirm session deletion`,description:`Require confirmation before deleting a saved conversation.`,children:(0,Q.jsx)(me,{checked:a.confirmSessionDelete,onCheckedChange:e=>o(`confirmSessionDelete`,e),"aria-label":`Confirm session deletion`})}),(0,Q.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Provider credentials, OAuth, models, sandbox configuration, and workspace selection are managed by Fleet Prime and its CLI.`})]})}[e]()}function Rr({initialTab:e,onCloseAttemptRef:t,onOpenChange:n}){let r=Nr(),{composerIntent:i,onComposerIntentChange:a,onComposerIntentKeyChange:o}=ie(),{resourceDirty:s,revertResourceDraft:c,resetDraft:l,requestCloseSettings:u,resetCommittedModelBaseline:d}=r,[f,p]=(0,Z.useState)(()=>e??`appearance`),[m,h]=(0,Z.useState)(le);(0,Z.useEffect)(()=>{se(m)},[m]);let g=(e,t)=>{h(n=>({...n,[e]:t}))},[_,v]=(0,Z.useState)(!1),[y,b]=(0,Z.useState)(`resource`),x=Pn.find(e=>e.id===f)??Pn[0],S=(e,t)=>{if(e){n(!0);return}t?.cancel(),(async()=>{let e=await u();if(e===`close`){n(!1);return}if(e===`wait`){Y.message(`Saving model list…`);return}b(s?`resource`:`model`),v(!0)})()};t.current=e=>{S(!1,e)};let w=()=>{c(),l(),d(),v(!1),n(!1)};(0,Z.useEffect)(()=>{d()},[d]);let T=(0,Q.jsx)(Lr,{activeTab:f,composerIntent:i,form:r,onComposerIntentChange:a,onComposerIntentKeyChange:o,preferences:m,updatePreference:g});return(0,Q.jsxs)(Q.Fragment,{children:[(0,Q.jsxs)(ge,{className:`flex h-[min(640px,calc(100dvh-4rem))] w-full max-w-[calc(100%-2rem)] overflow-hidden rounded-2xl p-0 sm:max-w-[min(860px,calc(100%-2rem))]`,children:[(0,Q.jsx)(_e,{className:`sr-only`,children:`Settings`}),(0,Q.jsx)(ve,{className:`sr-only`,children:`Customize your settings here.`}),(0,Q.jsxs)(`div`,{className:`flex h-full min-h-0 min-w-0`,children:[(0,Q.jsxs)(`nav`,{"aria-label":`Settings sections`,className:`hidden h-full w-52 shrink-0 flex-col border-r border-border bg-sidebar sm:flex`,children:[(0,Q.jsx)(`div`,{className:`px-6 pt-6 pb-2 text-label font-semibold`,children:`Settings`}),(0,Q.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-2 pb-6`,children:Nn.map(e=>(0,Q.jsxs)(`div`,{className:`py-2`,children:[(0,Q.jsx)(`p`,{className:`px-2 pb-1 text-caption font-medium uppercase tracking-wide text-muted-foreground`,children:e.label}),(0,Q.jsx)(`div`,{className:`flex flex-col gap-0.5`,children:Pn.filter(t=>t.group===e.id).map(e=>(0,Q.jsx)(Pr,{active:f===e.id,onClick:()=>p(e.id),icon:e.icon,label:e.title},e.id))})]},e.id))})]}),(0,Q.jsxs)(`main`,{className:`flex h-full min-h-0 min-w-0 flex-1 flex-col overflow-hidden`,children:[(0,Q.jsx)(`header`,{className:`flex h-14 shrink-0 items-center gap-2 border-b border-border/10 px-6`,children:(0,Q.jsx)(`div`,{className:`flex flex-1 items-center justify-between`,children:(0,Q.jsx)(Ln,{children:(0,Q.jsxs)(Rn,{children:[(0,Q.jsx)(zn,{className:`hidden sm:block`,children:`Settings`}),(0,Q.jsx)(Vn,{className:`hidden sm:block`}),(0,Q.jsx)(zn,{children:(0,Q.jsx)(Bn,{children:x.title})})]})})})}),(0,Q.jsx)(`div`,{className:`shrink-0 border-b border-border/10 bg-muted/5 px-4 py-2.5 sm:hidden`,children:(0,Q.jsx)(C,{"aria-label":`Settings sections`,value:f,onValueChange:e=>{Fn(e)&&p(e)},options:Pn.map(e=>({label:e.title,value:e.id}))})}),(0,Q.jsx)(jr,{className:`min-h-0 flex-1`,children:(0,Q.jsx)(`div`,{id:`panel-${f}`,role:`tabpanel`,"aria-label":x.title,tabIndex:0,className:`p-6 outline-none`,children:T})})]})]})]}),(0,Q.jsx)(Ie,{open:_,onOpenChange:v,children:(0,Q.jsxs)(je,{children:[(0,Q.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Q.jsx)(Fe,{children:`Discard unsaved changes?`}),(0,Q.jsx)(Ae,{children:y===`resource`?`Your resource changes have not been committed. If you leave settings now, those changes will be lost.`:`Your model list could not be saved. If you leave settings now, those changes will be lost.`})]}),(0,Q.jsxs)(Ne,{children:[(0,Q.jsx)(Pe,{children:`Keep editing`}),(0,Q.jsx)(Me,{onClick:w,children:`Discard changes`})]})]})})]})}export{Fr as SettingsDialog};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-NZYk81nU.js";import{t}from"./utils-Dpy9ZFOr.js";var n=e();function r({className:e,...r}){return(0,n.jsx)(`div`,{"data-slot":`skeleton`,className:t(`animate-pulse rounded-md bg-muted`,e),...r})}export{r as t};
1
+ import{t as e}from"./jsx-runtime-NZYk81nU.js";import{t}from"./utils-CFDGLzf6.js";var n=e();function r({className:e,...r}){return(0,n.jsx)(`div`,{"data-slot":`skeleton`,className:t(`animate-pulse rounded-md bg-muted`,e),...r})}export{r as t};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-NZYk81nU.js";import{i as t,n}from"./resource-helpers-CKbSmzpw.js";import{t as r}from"./skeleton-D5Y9nBfp.js";var i=e();function a({description:e,icon:t,title:n}){return(0,i.jsxs)(`div`,{className:`my-1.5 rounded-sm bg-foreground/5 px-2.5 py-2`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-2 text-label font-medium text-foreground/65`,children:[(0,i.jsx)(t,{className:`size-3.5`}),(0,i.jsx)(`span`,{children:n})]}),(0,i.jsx)(`p`,{className:`mt-1 text-caption leading-4 text-foreground/40`,children:e})]})}function o({id:e,icon:n,items:r,label:a}){return(0,i.jsxs)(`section`,{id:`resource-section-${e}`,className:`flex min-w-0 flex-col gap-2 py-2.5`,"aria-label":`${a} resources`,children:[(0,i.jsxs)(`div`,{className:`flex min-w-0 items-center text-body leading-5 text-foreground/45`,children:[(0,i.jsx)(`span`,{className:`truncate underline decoration-foreground/25 underline-offset-2`,children:a}),(0,i.jsx)(`span`,{className:`ml-1 shrink-0 text-caption leading-4 text-foreground/30 tabular-nums no-underline`,children:r.length})]}),(0,i.jsx)(`ul`,{className:`flex min-w-0 flex-col items-stretch gap-1.5`,"data-testid":`resource-chip-section-${a.toLowerCase()}`,children:r.length===0?(0,i.jsx)(`li`,{className:`inline-flex h-7.5 items-center rounded-lg border border-border/60 bg-background px-3 text-body leading-5 text-foreground/35 shadow-[0_1px_4px_-1px_rgba(0,0,0,0.06)]`,children:`Empty`}):r.map(e=>(0,i.jsx)(s,{icon:n,item:e,stacked:!0},t(e)))})]})}function s({icon:e,item:t,stacked:r=!1}){let a=n(t);return(0,i.jsxs)(`li`,{className:`max-w-full rounded-lg border border-border/70 bg-background px-2.5 text-body leading-5 text-foreground/80 shadow-[0_1px_4px_-1px_rgba(0,0,0,0.06)] ${r?`flex min-h-9 w-full min-w-0 items-center gap-2 py-1.5`:`inline-flex h-7.5 items-center gap-1`}`,"aria-label":a,"data-testid":`resource-chip`,title:a,children:[(0,i.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,i.jsx)(c,{icon:e}),(0,i.jsx)(`span`,{className:`min-w-0 truncate`,children:t.name})]}),t.source&&(0,i.jsx)(`span`,{className:`max-w-20 shrink-0 truncate rounded-[5px] bg-foreground/5 px-1.5 py-0.5 text-micro leading-3 text-foreground/35`,children:t.source}),t.activationStatus&&(0,i.jsx)(`span`,{className:`max-w-24 shrink-0 truncate rounded-[5px] bg-foreground/5 px-1.5 py-0.5 text-micro leading-3 text-foreground/35`,children:t.activationStatus})]})}function c({icon:e}){return(0,i.jsx)(`span`,{className:`inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-foreground/4 text-foreground/45`,children:(0,i.jsx)(e,{className:`size-3.5`})})}function l(){return(0,i.jsxs)(`div`,{className:`flex flex-col gap-4 p-1`,children:[(0,i.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,i.jsx)(r,{className:`h-4 w-24`}),(0,i.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,i.jsx)(r,{className:`h-7 w-20 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-24 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-16 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-28 rounded-full`})]})]}),(0,i.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,i.jsx)(r,{className:`h-4 w-28`}),(0,i.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,i.jsx)(r,{className:`h-7 w-22 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-18 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-26 rounded-full`})]})]}),(0,i.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,i.jsx)(r,{className:`h-4 w-20`}),(0,i.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,i.jsx)(r,{className:`h-7 w-24 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-20 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-30 rounded-full`})]})]})]})}function u(){return(0,i.jsxs)(`div`,{className:`flex flex-col gap-2 p-1`,children:[(0,i.jsx)(r,{className:`h-7 w-full rounded-sm`}),(0,i.jsx)(r,{className:`h-6 w-[90%]`}),(0,i.jsx)(r,{className:`h-6 w-[85%]`}),(0,i.jsx)(r,{className:`h-6 w-[70%]`}),(0,i.jsx)(r,{className:`h-6 w-[80%]`}),(0,i.jsx)(r,{className:`h-6 w-[60%]`}),(0,i.jsx)(r,{className:`h-6 w-[75%]`}),(0,i.jsx)(r,{className:`h-6 w-[55%]`})]})}function d(){return(0,i.jsxs)(`div`,{className:`flex flex-col gap-3 p-2`,children:[(0,i.jsx)(r,{className:`h-4 w-3/4`}),(0,i.jsx)(r,{className:`h-4 w-full`}),(0,i.jsx)(r,{className:`h-4 w-[95%]`}),(0,i.jsx)(r,{className:`h-4 w-[80%]`}),(0,i.jsx)(r,{className:`h-4 w-full`}),(0,i.jsx)(r,{className:`h-4 w-[70%]`}),(0,i.jsx)(r,{className:`h-4 w-[90%]`}),(0,i.jsx)(r,{className:`h-4 w-[60%]`})]})}export{a,o as i,d as n,u as r,l as t};
1
+ import{t as e}from"./jsx-runtime-NZYk81nU.js";import{i as t,n}from"./resource-helpers-CKbSmzpw.js";import{t as r}from"./skeleton-DNAr5ULI.js";var i=e();function a({description:e,icon:t,title:n}){return(0,i.jsxs)(`div`,{className:`my-1.5 rounded-sm bg-foreground/5 px-2.5 py-2`,children:[(0,i.jsxs)(`div`,{className:`flex items-center gap-2 text-label font-medium text-foreground/65`,children:[(0,i.jsx)(t,{className:`size-3.5`}),(0,i.jsx)(`span`,{children:n})]}),(0,i.jsx)(`p`,{className:`mt-1 text-caption leading-4 text-foreground/40`,children:e})]})}function o({id:e,icon:n,items:r,label:a}){return(0,i.jsxs)(`section`,{id:`resource-section-${e}`,className:`flex min-w-0 flex-col gap-2 py-2.5`,"aria-label":`${a} resources`,children:[(0,i.jsxs)(`div`,{className:`flex min-w-0 items-center text-body leading-5 text-foreground/45`,children:[(0,i.jsx)(`span`,{className:`truncate underline decoration-foreground/25 underline-offset-2`,children:a}),(0,i.jsx)(`span`,{className:`ml-1 shrink-0 text-caption leading-4 text-foreground/30 tabular-nums no-underline`,children:r.length})]}),(0,i.jsx)(`ul`,{className:`flex min-w-0 flex-col items-stretch gap-1.5`,"data-testid":`resource-chip-section-${a.toLowerCase()}`,children:r.length===0?(0,i.jsx)(`li`,{className:`inline-flex h-7.5 items-center rounded-lg border border-border/60 bg-background px-3 text-body leading-5 text-foreground/35 shadow-[0_1px_4px_-1px_rgba(0,0,0,0.06)]`,children:`Empty`}):r.map(e=>(0,i.jsx)(s,{icon:n,item:e,stacked:!0},t(e)))})]})}function s({icon:e,item:t,stacked:r=!1}){let a=n(t);return(0,i.jsxs)(`li`,{className:`max-w-full rounded-lg border border-border/70 bg-background px-2.5 text-body leading-5 text-foreground/80 shadow-[0_1px_4px_-1px_rgba(0,0,0,0.06)] ${r?`flex min-h-9 w-full min-w-0 items-center gap-2 py-1.5`:`inline-flex h-7.5 items-center gap-1`}`,"aria-label":a,"data-testid":`resource-chip`,title:a,children:[(0,i.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,i.jsx)(c,{icon:e}),(0,i.jsx)(`span`,{className:`min-w-0 truncate`,children:t.name})]}),t.source&&(0,i.jsx)(`span`,{className:`max-w-20 shrink-0 truncate rounded-[5px] bg-foreground/5 px-1.5 py-0.5 text-micro leading-3 text-foreground/35`,children:t.source}),t.activationStatus&&(0,i.jsx)(`span`,{className:`max-w-24 shrink-0 truncate rounded-[5px] bg-foreground/5 px-1.5 py-0.5 text-micro leading-3 text-foreground/35`,children:t.activationStatus})]})}function c({icon:e}){return(0,i.jsx)(`span`,{className:`inline-flex size-5 shrink-0 items-center justify-center rounded-full bg-foreground/4 text-foreground/45`,children:(0,i.jsx)(e,{className:`size-3.5`})})}function l(){return(0,i.jsxs)(`div`,{className:`flex flex-col gap-4 p-1`,children:[(0,i.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,i.jsx)(r,{className:`h-4 w-24`}),(0,i.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,i.jsx)(r,{className:`h-7 w-20 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-24 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-16 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-28 rounded-full`})]})]}),(0,i.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,i.jsx)(r,{className:`h-4 w-28`}),(0,i.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,i.jsx)(r,{className:`h-7 w-22 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-18 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-26 rounded-full`})]})]}),(0,i.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,i.jsx)(r,{className:`h-4 w-20`}),(0,i.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[(0,i.jsx)(r,{className:`h-7 w-24 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-20 rounded-full`}),(0,i.jsx)(r,{className:`h-7 w-30 rounded-full`})]})]})]})}function u(){return(0,i.jsxs)(`div`,{className:`flex flex-col gap-2 p-1`,children:[(0,i.jsx)(r,{className:`h-7 w-full rounded-sm`}),(0,i.jsx)(r,{className:`h-6 w-[90%]`}),(0,i.jsx)(r,{className:`h-6 w-[85%]`}),(0,i.jsx)(r,{className:`h-6 w-[70%]`}),(0,i.jsx)(r,{className:`h-6 w-[80%]`}),(0,i.jsx)(r,{className:`h-6 w-[60%]`}),(0,i.jsx)(r,{className:`h-6 w-[75%]`}),(0,i.jsx)(r,{className:`h-6 w-[55%]`})]})}function d(){return(0,i.jsxs)(`div`,{className:`flex flex-col gap-3 p-2`,children:[(0,i.jsx)(r,{className:`h-4 w-3/4`}),(0,i.jsx)(r,{className:`h-4 w-full`}),(0,i.jsx)(r,{className:`h-4 w-[95%]`}),(0,i.jsx)(r,{className:`h-4 w-[80%]`}),(0,i.jsx)(r,{className:`h-4 w-full`}),(0,i.jsx)(r,{className:`h-4 w-[70%]`}),(0,i.jsx)(r,{className:`h-4 w-[90%]`}),(0,i.jsx)(r,{className:`h-4 w-[60%]`})]})}export{a,o as i,d as n,u as r,l as t};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-NZYk81nU.js";import{t}from"./utils-Dpy9ZFOr.js";import{t as n}from"./loader-circle-BmKYM_C4.js";var r=e();function i({className:e,...i}){return(0,r.jsx)(n,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:t(`size-4 animate-spin`,e),...i})}export{i as t};
1
+ import{t as e}from"./jsx-runtime-NZYk81nU.js";import{t}from"./utils-CFDGLzf6.js";import{t as n}from"./loader-circle-BmKYM_C4.js";var r=e();function i({className:e,...i}){return(0,r.jsx)(n,{"data-slot":`spinner`,role:`status`,"aria-label":`Loading`,className:t(`size-4 animate-spin`,e),...i})}export{i as t};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-NZYk81nU.js";import{t}from"./prompt-input-IwZOepG7.js";import{t as n}from"./subagent-transcript-D_L-8PQi.js";var r=e();function i({disabled:e,sending:n,onSend:i,onStop:a,placeholder:o=`Message this subagent… (Enter to steer)`}){return(0,r.jsx)(`div`,{className:`shrink-0 border-t border-border/60 bg-background/80 px-4 py-3 backdrop-blur`,children:(0,r.jsx)(`div`,{className:`mx-auto w-full max-w-3xl`,children:(0,r.jsx)(t,{"aria-label":`Message subagent`,disabled:e,loading:n,minRows:1,onSubmit:e=>i(e),onStop:a,placeholder:o})})})}function a({child:e,parentSessionId:t,state:a}){let o=a.error??(a.status===`error`?Error(e.error??`The subagent thread ended with an error.`):void 0),s=a.loading?`loading`:a.status===`error`||o?`error`:`ready`,c=t!==void 0&&!a.loading;return(0,r.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,r.jsx)(n,{child:e,fullWidth:!0,parentSessionId:t,status:a.status,transcript:{status:s,messages:a.messages,presentation:a.presentation,error:o},onRefresh:a.refresh}),(0,r.jsx)(i,{disabled:!c,sending:a.sending,onSend:e=>void a.sendMessage(e),onStop:a.stop})]})}export{a as SubagentChatPanel};
1
+ import{t as e}from"./jsx-runtime-NZYk81nU.js";import{t}from"./prompt-input-Bnl0HyL6.js";import{t as n}from"./subagent-transcript-BCUhqVvi.js";var r=e();function i({disabled:e,sending:n,onSend:i,onStop:a,placeholder:o=`Message this subagent… (Enter to steer)`}){return(0,r.jsx)(`div`,{className:`shrink-0 border-t border-border/60 bg-background/80 px-4 py-3 backdrop-blur`,children:(0,r.jsx)(`div`,{className:`mx-auto w-full max-w-3xl`,children:(0,r.jsx)(t,{"aria-label":`Message subagent`,disabled:e,loading:n,minRows:1,onSubmit:e=>i(e),onStop:a,placeholder:o})})})}function a({child:e,parentSessionId:t,state:a}){let o=a.error??(a.status===`error`?Error(e.error??`The subagent thread ended with an error.`):void 0),s=a.loading?`loading`:a.status===`error`||o?`error`:`ready`,c=t!==void 0&&!a.loading;return(0,r.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,r.jsx)(n,{child:e,fullWidth:!0,parentSessionId:t,status:a.status,transcript:{status:s,messages:a.messages,presentation:a.presentation,error:o},onRefresh:a.refresh}),(0,r.jsx)(i,{disabled:!c,sending:a.sending,onSend:e=>void a.sendMessage(e),onStop:a.stop})]})}export{a as SubagentChatPanel};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-Cvdyeg_0.js";import{t as n}from"./jsx-runtime-NZYk81nU.js";import{t as r}from"./button-Bqms7ZKX.js";import{t as i}from"./utils-CFDGLzf6.js";import{t as a}from"./bot-DETalD3q.js";import{t as o}from"./chevron-down-Bse1ggZM.js";import{c as s,d as c,f as l,i as u,l as d,m as f,n as p,o as m,p as h,r as g,s as _,t as v,u as y}from"./subagent-utils-CM2qX9BG.js";import{t as b}from"./session-tool-renderer-BFC3-Md4.js";import{n as x}from"./file-text-cqOanUYv.js";import{t as S}from"./circle-check-DBhaebaM.js";import{t as C}from"./tool-timeline-4k2iSEky.js";import{t as w}from"./loader-circle-BmKYM_C4.js";import{t as T}from"./refresh-cw-CqPE3kNY.js";import{t as E}from"./prime-agent-artifacts-C-g1VPiW.js";var D=e(t(),1);function O(e){return e.status===`running`||e.status===`recovering`?`streaming`:e.status===`error`||e.status===`failed`?`error`:`ready`}var k=n();function A({children:e,tree:t,className:n}){let r=(0,D.useMemo)(()=>v(e,t),[e,t]),a=r.some(e=>e.status===`queued`||e.status===`running`||e.status===`recovering`),[s,c]=(0,D.useState)(a);return r.length===0?null:(0,k.jsxs)(`section`,{className:i(`mt-2 rounded-xl border border-border/60 bg-muted/20`,n),children:[(0,k.jsxs)(`button`,{type:`button`,"aria-expanded":s||a,onClick:()=>c(e=>!e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,children:[a?(0,k.jsx)(w,{className:`size-3.5 animate-spin text-primary`}):(0,k.jsx)(S,{className:`size-3.5 text-emerald-600 dark:text-emerald-400`}),(0,k.jsx)(`span`,{className:`flex-1 font-medium`,children:a?`Subagents working`:`Subagents completed`}),(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r.length}),(0,k.jsx)(o,{className:i(`size-3.5 text-muted-foreground transition-transform`,(s||a)&&`rotate-180`)})]}),s||a?(0,k.jsx)(`div`,{className:`space-y-1 border-t border-border/50 px-3 py-2`,children:r.map(e=>(0,k.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,style:{paddingLeft:`${Math.max(0,e.depth??0)*12}px`},children:[(0,k.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:p(e.status)}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,k.jsx)(`span`,{className:`truncate text-sm text-foreground/85`,children:e.label}),e.model?(0,k.jsx)(`span`,{className:`truncate font-mono text-micro text-muted-foreground`,children:e.model}):null]}),e.answerPreview||e.progressNote||e.activity?.toolName||e.error?(0,k.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.error??e.answerPreview??e.progressNote??e.activity?.toolName}):null]}),(0,k.jsx)(`span`,{className:`shrink-0 text-micro capitalize text-muted-foreground`,children:e.status})]},e.id))}):null]})}function j({turn:e,isLast:t,isStreaming:n,artifacts:r,presentation:i}){let a=(0,D.useMemo)(()=>e.assistants.flatMap((r,i)=>m(_(r.parts??[]),{messageId:r.id,isLast:t&&i===e.assistants.length-1,isStreaming:n,suppressQuestionTool:!0,ToolRendererComponent:b,TextRendererComponent:f})),[t,n,e.assistants]);return(0,k.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e.user?(0,k.jsx)(s,{from:`user`,children:(0,k.jsx)(d,{children:(0,k.jsx)(u,{message:e.user,enableImagePreview:!1})})}):null,e.assistants.length>0?(0,k.jsx)(s,{from:`assistant`,children:(0,k.jsx)(d,{children:(0,k.jsx)(c,{variant:`ghost`,children:(0,k.jsxs)(l,{children:[t?(0,k.jsx)(C,{messages:e.assistants,artifacts:r,streaming:n}):null,(0,k.jsx)(`div`,{className:`flex flex-col gap-3`,children:a}),t&&i?(0,k.jsx)(A,{tree:i.rlmTree,children:i.rlmChildren}):null]})})})}):null]})}function M(e,t){return e.user?.id??e.assistants[0]?.id??`subagent-turn-${t}`}function N({child:e,parentSessionId:t,transcript:n,onRefresh:o,fullWidth:s=!1,status:c}){let l=(0,D.useMemo)(()=>n?.status===`loading`?[]:h(n?.messages??[]),[n]),u=c??O(e),d=(0,D.useMemo)(()=>n?.status===`loading`?[]:E(n?.messages??[],n?.presentation,u),[u,n]),f=(0,D.useMemo)(()=>d.flatMap(e=>e.artifacts),[d]),p=n?.presentation,m=(0,D.useCallback)((e,t)=>{let n=t===l.length-1;return(0,k.jsx)(j,{turn:e,isLast:n,isStreaming:n&&u===`streaming`,artifacts:n?f:[],presentation:n?p:void 0})},[f,u,p,l.length]),_=e.sessionName||e.label,[v,b]=(0,D.useState)(null);(0,D.useEffect)(()=>{b(e.lastHeardFrom?new Date(e.lastHeardFrom).toLocaleTimeString():null)},[e.lastHeardFrom]);let S=(0,D.useRef)(null);return(0,k.jsxs)(`section`,{"aria-label":`Subagent thread: ${e.label}`,className:i(s?`flex min-h-0 min-w-0 flex-1 flex-col`:`space-y-2`,`min-w-0`),"data-testid":s?`subagent-conversation-surface`:void 0,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2 rounded-md border border-border/60 bg-background px-2.5 py-2`,children:[(0,k.jsx)(a,{className:`mt-0.5 size-3.5 shrink-0 text-foreground/45`}),(0,k.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,k.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,k.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs font-medium text-foreground/80`,children:_}),(0,k.jsx)(`span`,{className:`shrink-0 text-micro capitalize text-foreground/45`,children:e.status})]}),e.model?(0,k.jsx)(`p`,{className:`truncate font-mono text-micro text-foreground/40`,children:e.model}):null,v?(0,k.jsxs)(`p`,{className:`truncate text-micro text-foreground/40`,children:[`Heartbeat: `,v]}):null,e.progressNote&&e.status===`running`?(0,k.jsxs)(`p`,{className:`truncate text-micro text-foreground/50`,title:e.progressNote,children:[`Progress: `,e.progressNote]}):null,e.answerPreview||e.recap?(0,k.jsx)(`p`,{className:`mt-1 line-clamp-3 whitespace-pre-wrap text-caption leading-4 text-foreground/55`,children:e.answerPreview??e.recap}):null]}),o?(0,k.jsx)(r,{"aria-label":`Refresh ${e.label} thread`,className:`shrink-0 text-foreground/40 hover:text-foreground/70`,onClick:o,size:`icon-compact`,title:`Refresh ${e.label} thread`,type:`button`,variant:`ghost`,children:(0,k.jsx)(T,{className:i(`size-3.5`,n?.status===`loading`&&`animate-spin`)})}):null]}),t?n?.status===`loading`?(0,k.jsx)(`div`,{className:i(`flex items-center justify-center rounded-md border border-dashed border-border/70 text-caption text-foreground/45`,s?`min-h-32 flex-1`:`min-h-32`),children:`Loading subagent thread…`}):n?.status===`error`&&l.length===0?(0,k.jsxs)(`div`,{role:`alert`,className:`flex items-start gap-2 rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-caption leading-4 text-destructive`,children:[(0,k.jsx)(x,{className:`mt-0.5 size-3.5 shrink-0`}),(0,k.jsx)(`span`,{children:n.error?.message??`Unable to load this subagent thread.`})]}):l.length===0?(0,k.jsx)(`p`,{className:`rounded-md border border-dashed border-border/70 p-3 text-caption leading-4 text-foreground/45`,children:`This subagent thread has no messages yet.`}):(0,k.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[n?.error?(0,k.jsxs)(`div`,{role:`alert`,className:`mx-4 mt-2 flex items-start gap-2 rounded-md border border-destructive/30 bg-destructive/5 px-3 py-2 text-caption leading-4 text-destructive sm:mx-6`,children:[(0,k.jsx)(x,{className:`mt-0.5 size-3.5 shrink-0`}),(0,k.jsx)(`span`,{children:n.error.message})]}):null,(0,k.jsx)(`div`,{className:i(`min-h-0 rounded-md border border-border/60 bg-background`,s?`flex min-h-0 flex-1 flex-col border-x-0 rounded-none border-b-0`:`h-96 max-h-[calc(100svh-18rem)]`),children:(0,k.jsx)(y,{busy:u===`streaming`,className:s?`min-h-0 flex-1`:void 0,followOutput:u===`streaming`,label:`Transcript for ${e.label}`,smooth:u!==`streaming`,viewportRef:S,viewportClassName:s?`px-0`:void 0,contentClassName:i(`flex flex-col gap-4`,s?`mx-auto w-full max-w-3xl px-4 py-6 sm:px-6`:`px-2.5 py-3`),children:(0,k.jsx)(g,{estimateSize:320,getItemKey:M,itemGap:16,items:l,renderItem:m,viewportRef:S})})})]}):(0,k.jsx)(`p`,{className:`rounded-md border border-dashed border-border/70 p-3 text-caption leading-4 text-foreground/45`,children:`This subagent thread is unavailable until the parent session is active.`})]})}export{N as t};
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/openui-renderer-DrfHxs1t.js","assets/rolldown-runtime-hePW80VL.js","assets/react-Cvdyeg_0.js","assets/react-dom-B7th3XGm.js","assets/jsx-runtime-NZYk81nU.js","assets/button-BJyg7l5W.js","assets/utils-Dpy9ZFOr.js","assets/createBaseUIEventDetails-DklXWq23.js","assets/dist-BogNzeK9.js","assets/clsx-DB0hHKMi.js","assets/card-BScRdZNS.js","assets/select-COK0Kaq2.js","assets/surface-context-DWplCCcO.js","assets/useBaseUiId-BlzQUkVG.js","assets/check-BTwIaCtI.js","assets/createLucideIcon-CQY2ECfR.js","assets/chevron-down-Bse1ggZM.js","assets/input-Ce8yLnXY.js","assets/useControlled-CkQSkSv1.js","assets/safe-external-url-BnEhm9A0.js","assets/chunk-YOKDWASO-Dego39cu.js","assets/preload-helper-BZ1Pz5am.js","assets/lib-ChrQ49PO.js","assets/character-entities-legacy-Wut6vMuj.js","assets/badge-DOGhnsYk.js","assets/dist-BJJVCio8.js","assets/markdown-yn-nhRzB.js","assets/switch-DQETDDJT.js","assets/dialog-DLIPvl1s.js","assets/x-DEU6H3M-.js","assets/openui-utils-DawGoQNp.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-Cvdyeg_0.js";import{t as n}from"./react-dom-B7th3XGm.js";import{t as r}from"./jsx-runtime-NZYk81nU.js";import{t as i}from"./utils-Dpy9ZFOr.js";import{d as a,o,r as s}from"./ease-DKi-MOH5.js";import{n as c,t as l}from"./use-reduced-motion-BgG7f9xw.js";import{t as u}from"./createLucideIcon-CQY2ECfR.js";import{i as d}from"./citations-BhyqbxcZ.js";import{t as f}from"./check-BTwIaCtI.js";import{t as p}from"./chevron-right-BPCB1mOg.js";import{n as m,t as h}from"./file-text-cqOanUYv.js";import{t as g}from"./circle-check-DBhaebaM.js";import{a as _,i as v}from"./action-swap-roll-BfVrBOVd.js";import{t as y}from"./loader-circle-BmKYM_C4.js";import{t as b}from"./x-DEU6H3M-.js";import{t as x}from"./preload-helper-BZ1Pz5am.js";import{t as S}from"./openui-utils-DawGoQNp.js";import"./tokens-CtP2s1Y3.js";import{i as C}from"./workspace-path-nav-eVT0rYvv.js";import{t as w}from"./notify-BC0a76VJ.js";var T={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};T.node;var E=u(T),D={name:`file-braces`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]],aliases:[`file-json`]};D.node;var O=u(D),k={name:`file-code`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]};k.node;var A=u(k),j={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};j.node;var M=u(j),N={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};N.node;var P=u(N),F=e(t(),1),I=r(),L=(0,F.lazy)(()=>x(async()=>{let{GenerativeTextRenderer:e}=await import(`./openui-renderer-DrfHxs1t.js`).then(e=>e.n);return{GenerativeTextRenderer:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30])).then(({GenerativeTextRenderer:e})=>({default:e})));function R({className:e,content:t}){return(0,I.jsx)(`div`,{className:e?`${e} whitespace-pre-wrap`:`whitespace-pre-wrap`,children:t})}function z(e){return(0,F.useMemo)(()=>S(e.content).some(e=>e.type===`openui`),[e.content])?(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(R,{className:e.className,content:e.content}),children:(0,I.jsx)(L,{...e})}):(0,I.jsx)(C,{className:e.className,content:e.content,isStreaming:e.isStreaming})}function B(e){let t=[],n;for(let r of e){if(r.role===`user`){n&&t.push(n),n={user:r,assistants:[]};continue}if(r.role===`assistant`){if(!n||r.source===`local`){n&&t.push(n),n={assistants:[r]};continue}n.assistants.push(r)}}return n&&t.push(n),t}var V=(0,F.createContext)(void 0),H=(0,F.createContext)({animateIn:!0,variant:`soft`}),U=(0,F.createContext)(()=>{});function ee(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n&&(n.current=t)}}var W={duration:.12,ease:s,delay:.04},G={type:`spring`,stiffness:520,damping:27,mass:.52};function te({variant:e=`soft`,align:t,animateIn:n=!1,className:r,children:s,initial:c,animate:u,exit:d,transition:f,layout:p,...m}){let h=l()??!1,g=(0,F.useContext)(V),_=t??g??`start`,v=(0,F.useMemo)(()=>({align:_,animateIn:n,variant:e}),[n,_,e]);return(0,I.jsx)(H.Provider,{value:v,children:(0,I.jsx)(a.div,{"data-slot":`message-bubble`,"data-align":_,"data-variant":e,layout:p,initial:c??!1,animate:u,exit:d??(h?{opacity:0}:{opacity:0,y:-3,scale:.99}),transition:f??(h?{duration:.12}:o),className:i(`group/bubble flex w-full flex-col`,_===`end`?`items-end`:`items-start`,r),...m,children:s})})}function ne(e,t){return i(`relative z-0 min-w-9 max-w-[82%] rounded-2xl px-3.5 py-2.5 text-sm leading-6 text-foreground`,`[&_a]:font-medium [&_a]:underline [&_a]:underline-offset-4 [&_code]:rounded [&_code]:bg-background/60 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[90%] [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p+p]:mt-2 [&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-xl [&_pre]:bg-background/60 [&_pre]:p-3 [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5`,e===`solid`&&`text-background`,e===`ghost`&&`w-full max-w-none rounded-none px-0 py-0`,e===`danger`&&`text-destructive`,t&&`cursor-pointer text-left outline-none transition-[background-color,color,transform] duration-150 hover:brightness-[0.98] focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.99]`)}function re(e,t){return i(`pointer-events-none absolute inset-0 -z-10 rounded-[inherit]`,t===`end`?`origin-bottom-right`:`origin-bottom-left`,e===`solid`&&`bg-foreground`,e===`soft`&&`bg-muted`,e===`tint`&&`bg-primary/10`,e===`outline`&&`border border-border/70 bg-background`,e===`danger`&&`bg-destructive/10`)}function ie({render:e,className:t,children:n,ref:r,...c}){let u=l()??!1,{align:d=`start`,animateIn:f,variant:p}=(0,F.useContext)(H),[m,h]=(0,F.useState)(0),g=(0,F.useCallback)(()=>h(e=>e+1),[]),_=e?.type===`button`||e?.type===`a`,v=i(ne(p,_),t),y=(0,I.jsxs)(I.Fragment,{children:[p===`ghost`?null:(0,I.jsx)(a.span,{"aria-hidden":`true`,layout:!1,layoutDependency:m,initial:f&&!u?{opacity:0,scale:.92}:!1,animate:{opacity:1,scale:1},transition:u?{duration:0}:{opacity:{duration:.12,ease:s},scale:G,layout:o},className:re(p,d)}),(0,I.jsx)(U.Provider,{value:g,children:(0,I.jsx)(a.div,{initial:f?{opacity:0}:!1,animate:{opacity:1},transition:u?{duration:.12,ease:s}:W,className:`relative`,children:n})})]});if(e){let t=e;return(0,F.cloneElement)(t,{...c,ref:ee(t.props.ref,r),className:i(v,t.props.className),children:y,"data-slot":`message-bubble-content`})}return(0,I.jsx)(`div`,{ref:r,"data-slot":`message-bubble-content`,className:v,...c,children:y})}var K=56,ae=88;function oe(e,t){if(e.length<=t)return e;let n=e.slice(0,t),r=n.lastIndexOf(` `);return`${n.slice(0,r>t*.65?r:t).trim()}…`}function q(e){return((e.querySelector(`[data-slot="message-bubble-content"]`)??e.querySelector(`[data-slot="message-content"]`)??e).textContent??``).replace(/\s+/g,` `).trim()}function se(e,t){let n=q(e);if(!n)return{label:`Message`,description:void 0};if(n.length<=K){let e=t?q(t):``;return{label:n,description:e?oe(e,ae):void 0}}let r=n.slice(0,K).lastIndexOf(` `),i=r>K*.65?r:K,a=`${n.slice(0,i).trim()}…`,o=t?q(t):n.slice(i).trim();return{label:a,description:o?oe(o,ae):void 0}}function ce({navigation:e,followThreshold:t,contentRef:n,viewportRef:r,reduce:i,smooth:a,scrollToEnd:o,setFollowing:s,markProgrammaticScroll:c}){let l=(0,F.useRef)(void 0),u=(0,F.useRef)(new WeakMap),d=(0,F.useRef)(0),f=(0,F.useRef)(new Map),[p,m]=(0,F.useState)([]),[h,g]=(0,F.useState)(``),[_,v]=(0,F.useState)(!1),y=(0,F.useCallback)(()=>{if(e!==`rail`)return;let n=r.current,i=[...f.current.entries()];if(!n||i.length===0)return;let a=n.getBoundingClientRect();if(n.scrollTop<=t){let e=i[0]?.[0]??``;g(t=>t===e?t:e);return}if(n.scrollHeight-n.scrollTop-n.clientHeight<=t){let e=i.at(-1)?.[0]??``;g(t=>t===e?t:e);return}let o=a.top+a.height/2,s=i[0]?.[0]??``,c=1/0;for(let[e,t]of i){let n=t.getBoundingClientRect(),r=Math.abs(n.top+n.height/2-o);r<c&&(c=r,s=e)}g(e=>e===s?e:s)},[t,e,r]),b=(0,F.useCallback)(()=>{if(e!==`rail`)return;let t=n.current,i=r.current;if(!t||!i)return;let a=Array.from(t.querySelectorAll(`[data-slot="message"]`)),o=new Map,s=a.map((e,t)=>{let n=u.current.get(e);n||(d.current+=1,n=`message-rail-${d.current}`,u.current.set(e,n)),o.set(n,e);let r=e.dataset.from??`conversation`,i=se(e,r===`user`?a.slice(t+1).find(e=>e.dataset.from===`assistant`):void 0);return{id:n,label:i.label,description:i.description,ariaLabel:`Go to ${r} message ${t+1} of ${a.length}`}});f.current=o,m(e=>e.length===s.length&&e.every((e,t)=>e.id===s[t]?.id&&e.label===s[t]?.label&&e.description===s[t]?.description&&e.ariaLabel===s[t]?.ariaLabel)?e:s),v(i.scrollHeight>i.clientHeight+1&&a.length>1)},[n,e,r]),x=(0,F.useCallback)(()=>{e===`rail`&&(l.current&&cancelAnimationFrame(l.current),l.current=requestAnimationFrame(()=>{b(),y()}))},[e,b,y]);return(0,F.useEffect)(()=>{if(e!==`rail`){f.current.clear(),m([]),v(!1);return}let t=n.current,i=r.current;if(!t||!i)return;x();let a=typeof MutationObserver>`u`?null:new MutationObserver(x);a?.observe(t,{childList:!0,characterData:!0,subtree:!0});let o=typeof ResizeObserver>`u`?null:new ResizeObserver(x);return o?.observe(t),o?.observe(i),()=>{a?.disconnect(),o?.disconnect()}},[n,e,x,r]),(0,F.useEffect)(()=>()=>{l.current&&cancelAnimationFrame(l.current)},[]),{activeRailId:h,railItems:p,railOverflowing:_,scheduleRailSync:x,scrollToRailItem:(0,F.useCallback)(e=>{let t=r.current,n=f.current.get(e.id);if(!t||!n)return;let l=p.at(-1)?.id===e.id;if(g(e.id),l){s(!0),o(i||!a?`auto`:`smooth`);return}s(!1),c(i||!a?`auto`:`smooth`);let u=t.getBoundingClientRect(),d=n.getBoundingClientRect(),m=t.scrollTop+d.top-u.top-(t.clientHeight-d.height)/2,h=i||!a?`auto`:`smooth`;typeof t.scrollTo==`function`?t.scrollTo({top:m,behavior:h}):t.scrollTop=m},[c,p,i,o,s,a,r])}}function le({item:e}){return(0,I.jsxs)(`div`,{"data-slot":`preview-rail-card`,className:`rounded-2xl border border-border bg-card p-4 shadow-sm`,children:[(0,I.jsx)(`p`,{"data-slot":`preview-rail-title`,className:`font-medium text-card-foreground`,children:e.label}),e.description?(0,I.jsx)(`div`,{"data-slot":`preview-rail-description`,className:`mt-1 text-sm leading-6 text-muted-foreground`,children:e.description}):null]})}function ue({items:e,label:t=`Section navigation`,orientation:n=`vertical`,activeId:r,defaultActiveId:u,onActiveChange:f,onItemSelect:p,renderPreview:m,showPreview:h=!0,previewSide:g=`after`,highlightActive:_=!1,itemSize:v=24,children:y,className:b,railClassName:x,previewContainerClassName:S,previewClassName:C}){let w=(0,F.useId)(),T=l(),E=d(),[D,O]=(0,F.useState)(u??e[0]?.id??``),[k,A]=(0,F.useState)(null),[j,M]=(0,F.useState)(null),N=r??D,P=e.some(e=>e.id===N)?N:e[0]?.id??``,L=k??j??``,R=L||(_?P:``),z=e.findIndex(e=>e.id===R),B=e.length?`repeat(${e.length}, ${v}px)`:void 0,V=n===`horizontal`,H=e=>{r===void 0&&O(e),f?.(e)};return(0,I.jsxs)(a.div,{layoutRoot:!0,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||M(null)},className:i(`isolate relative flex w-full overflow-visible`,V?`min-h-64 flex-col items-center justify-center`:`min-h-80`,b),children:[(0,I.jsx)(`nav`,{"aria-label":t,onPointerLeave:()=>A(null),style:V?{gridTemplateColumns:B}:{gridTemplateRows:B},className:i(`relative z-10 grid shrink-0`,V?`h-12 w-fit max-w-full self-center justify-center`:`w-12 content-center`,x),children:e.map((e,t)=>{let n=e.id===P,r=e.id===R,s=z<0?1/0:Math.abs(t-z),c=r?1:s===1?.68:s===2?.44:.25,l=(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(a.span,{"data-slot":`preview-rail-tick`,"aria-hidden":`true`,animate:V?{scaleY:c}:{scaleX:c},transition:T?{duration:0}:o,className:i(`block bg-current`,V?`h-12 w-0.5 origin-bottom`:`h-0.5 w-12 origin-left`,r?`text-foreground`:void 0)})}),u=i(`relative flex text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,V?`h-12 w-6 items-end justify-center`:`h-6 w-12 items-center`),d=V?{width:v}:{height:v},f=()=>{E&&A(e.id)},m=t=>{t.matches(`:focus-visible`)&&M(e.id)},h=()=>{H(e.id),p?.(e)};return e.href?(0,I.jsx)(`a`,{"data-slot":`preview-rail-item`,href:e.href,target:e.target,rel:e.rel??(e.target===`_blank`?`noreferrer noopener`:void 0),"aria-label":e.ariaLabel??e.label,"aria-current":n?`page`:void 0,onPointerEnter:f,onMouseEnter:f,onPointerDown:()=>M(null),onFocus:e=>m(e.currentTarget),onClick:h,style:d,className:u,children:l},e.id):(0,I.jsx)(`button`,{"data-slot":`preview-rail-item`,type:`button`,"aria-label":e.ariaLabel??e.label,"aria-current":n?`location`:void 0,onPointerEnter:f,onMouseEnter:f,onPointerDown:()=>M(null),onFocus:e=>m(e.currentTarget),onClick:h,style:d,className:u,children:l},e.id)})}),h?(0,I.jsx)(`div`,{"aria-hidden":`true`,style:V?{gridTemplateColumns:B}:{gridTemplateRows:B},className:i(`pointer-events-none absolute z-50 grid`,V?`top-1/2 left-1/2 h-5 w-fit max-w-full -translate-x-1/2 -translate-y-1/2 justify-center`:g===`before`?`inset-y-0 right-16 left-4 content-center`:`inset-y-0 right-4 left-16 content-center`,S),children:e.map(e=>(0,I.jsx)(`div`,{style:V?{width:v}:{height:v},className:i(`relative flex items-center`,V?`justify-center`:void 0),children:(0,I.jsx)(c,{mode:`wait`,initial:!1,children:e.id===L?(0,I.jsx)(a.div,{initial:T?{opacity:0}:{opacity:0,y:4,filter:`blur(6px)`},animate:T?{opacity:1}:{opacity:1,y:0,filter:`blur(0px)`},exit:T?{opacity:0}:{opacity:0,y:-2,filter:`blur(4px)`,transition:{duration:.12,ease:s}},transition:{duration:T?0:.18,ease:s},className:i(V?`absolute bottom-12 left-1/2 w-72 -translate-x-1/2`:i(`w-full max-w-sm`,g===`before`&&`ml-auto`),C),children:(0,I.jsx)(a.div,{layoutId:`preview-rail-card-${w}`,transition:T?{duration:0}:o,children:m?m(e):(0,I.jsx)(le,{item:e})})},e.id):null})},e.id))}):null,y?(0,I.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:y}):null]})}function de({followOutput:e=!0,followThreshold:t=56,smooth:n=!0,onFollowChange:r,label:a=`Conversation`,busy:o,navigation:s,navigationLabel:c=`Message navigation`,viewportClassName:u,contentClassName:d,railClassName:f,viewportRef:p,viewportProps:m,contentProps:h,className:g,children:_,...v}){let y=l()??!1,b=(0,F.useRef)(null),x=(0,F.useRef)(null),S=(0,F.useRef)(e),C=(0,F.useRef)(!1),w=(0,F.useRef)(void 0),T=(0,F.useRef)(void 0),{onScroll:E,onWheel:D,onTouchStart:O,onKeyDown:k,...A}=m??{},j=(0,F.useCallback)(e=>{b.current=e,typeof p==`function`?p(e):p&&(p.current=e)},[p]),M=(0,F.useCallback)(e=>{S.current!==e&&(S.current=e,r?.(e))},[r]),N=(0,F.useCallback)(e=>{C.current=!0,w.current&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{C.current=!1},e===`smooth`?320:0)},[]),P=(0,F.useCallback)(e=>{let t=b.current;t&&(N(e),typeof t.scrollTo==`function`?t.scrollTo({top:t.scrollHeight,behavior:e}):t.scrollTop=t.scrollHeight)},[N]),{activeRailId:L,railItems:R,railOverflowing:z,scheduleRailSync:B,scrollToRailItem:V}=ce({navigation:s,followThreshold:t,contentRef:x,viewportRef:b,reduce:y,smooth:n,scrollToEnd:P,setFollowing:M,markProgrammaticScroll:N}),H=(0,F.useEffectEvent)(B),U=(0,F.useEffectEvent)(P),ee=(0,F.useCallback)(()=>{let e=b.current;if(!e||C.current)return;let n=e.scrollHeight-e.scrollTop-e.clientHeight;M(n<=t),B()},[t,B,M]),W=(0,F.useCallback)(()=>{C.current=!1},[]);(0,F.useLayoutEffect)(()=>{if(S.current=e,e)return T.current=requestAnimationFrame(()=>U(`auto`)),()=>{T.current&&cancelAnimationFrame(T.current)}},[e]),(0,F.useEffect)(()=>{let t=x.current;if(!t||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{H(),!(!e||!S.current)&&U(y||!n?`auto`:`smooth`)});return r.observe(t),()=>r.disconnect()},[e,y,n]),(0,F.useEffect)(()=>()=>{w.current&&window.clearTimeout(w.current),T.current&&cancelAnimationFrame(T.current)},[]);let G=(0,I.jsx)(`section`,{ref:j,"aria-label":a,...A,onScroll:e=>{ee(),E?.(e)},onWheel:e=>{W(),D?.(e)},onTouchStart:e=>{W(),O?.(e)},onKeyDown:e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)&&W(),k?.(e)},className:i(`h-full overflow-y-auto overscroll-contain outline-none [overflow-anchor:none] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,s===`rail`?`[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`:`[scrollbar-gutter:stable]`,u,s===`rail`&&z&&`pr-10`),children:(0,I.jsx)(`div`,{ref:x,role:`log`,"aria-live":o?`off`:`polite`,"aria-relevant":`additions text`,"aria-busy":o,className:d,...h,children:_})});return(0,I.jsx)(`div`,{"data-slot":`message-scroller`,className:i(`min-h-0`,g),...v,children:s===`rail`?(0,I.jsx)(ue,{items:z?R:[],label:c,activeId:L,onItemSelect:V,previewSide:`before`,highlightActive:!0,itemSize:14,className:`h-full min-h-0 overflow-hidden`,previewContainerClassName:`right-8 left-3`,previewClassName:`mr-1 w-64 max-w-full [&_[data-slot=preview-rail-card]]:h-20 [&_[data-slot=preview-rail-card]]:overflow-hidden [&_[data-slot=preview-rail-card]]:p-3 [&_[data-slot=preview-rail-title]]:line-clamp-1 [&_[data-slot=preview-rail-title]]:text-xs [&_[data-slot=preview-rail-title]]:leading-4 [&_[data-slot=preview-rail-description]]:line-clamp-2 [&_[data-slot=preview-rail-description]]:text-xs [&_[data-slot=preview-rail-description]]:leading-4`,railClassName:i(`absolute inset-y-3 right-1 w-7 content-center py-1 [&_[data-slot=preview-rail-item]]:w-7 [&_[data-slot=preview-rail-item]]:justify-end [&_[data-slot=preview-rail-tick]]:h-px [&_[data-slot=preview-rail-tick]]:w-4 [&_[data-slot=preview-rail-tick]]:origin-right`,z?`pointer-events-auto opacity-100`:`pointer-events-none opacity-0`,f),children:G}):G})}var fe=(0,F.createContext)({from:`assistant`}),pe={type:`spring`,stiffness:480,damping:32,mass:.62};function me({from:e,animateIn:t=!1,children:n,className:r,initial:o,animate:s,transition:c,exit:u,style:d,...f}){let p=l()??!1,m=(0,F.useMemo)(()=>({from:e}),[e]);return(0,I.jsx)(V.Provider,{value:e===`user`?`end`:`start`,children:(0,I.jsx)(fe.Provider,{value:m,children:(0,I.jsx)(a.article,{"data-slot":`message`,"data-from":e,"aria-label":f[`aria-label`]??`${e} message`,initial:o??(t&&!p?{opacity:0,transform:`translateY(8px) scale(0.95)`}:!1),animate:s??(t&&!p?{opacity:1,transform:`translateY(0px) scale(1)`}:{opacity:1}),exit:u??(p?{opacity:0}:{opacity:0,transform:`translateY(-3px) scale(0.99)`}),transition:c??(p?{duration:.12}:pe),style:{transformOrigin:e===`user`?`100% 100%`:`0% 100%`,...d},className:i(`group/message flex w-full items-start gap-2`,e===`user`?`flex-row-reverse`:`flex-row`,r),...f,children:n})})})}function he({className:e,...t}){let{from:n}=(0,F.useContext)(fe);return(0,I.jsx)(`div`,{"data-slot":`message-content`,className:i(`flex min-w-0 flex-1 flex-col gap-1.5`,n===`user`?`items-end`:`items-start`,e),...t})}var ge=(0,F.memo)(function({title:e=`Something went wrong`,message:t,className:n}){return(0,I.jsx)(`div`,{className:i(`flex justify-start`,n),children:(0,I.jsxs)(`div`,{className:`rounded-[8px] border border-red-500/30 bg-red-500/10 px-4 py-2.5 text-sm text-foreground`,children:[(0,I.jsx)(`div`,{className:`font-medium text-foreground`,children:e}),(0,I.jsx)(`div`,{className:`mt-0.5 text-muted-foreground`,children:t})]})})}),_e=new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,minute:`2-digit`,hour12:!0}),ve=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`});function ye(e){let t=new Date;return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()?_e.format(e):ve.format(e)}function be({text:e,onCopied:t}){let[n,r]=(0,F.useState)(!1),a=(0,F.useRef)(null);return(0,F.useEffect)(()=>()=>{a.current&&window.clearTimeout(a.current)},[]),(0,I.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":n?`Copied`:`Copy message`,onClick:async()=>{try{await navigator.clipboard.writeText(e),r(!0),a.current&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{r(!1),a.current=null},2e3),w.success(`Copied to clipboard`),t?.()}catch{w.error(`Failed to copy to clipboard`)}},onPointerDown:e=>{e.stopPropagation()},onMouseDown:e=>e.stopPropagation(),className:i(`flex size-6 items-center justify-center rounded-md transition-[background-color,opacity,transform] duration-150 ease-out active:scale-[0.97]`,`bg-transparent opacity-50 hover:bg-foreground/10 hover:opacity-100`),children:(0,I.jsxs)(`div`,{className:`relative size-3.5`,children:[(0,I.jsx)(v,{className:i(`absolute inset-0 h-3.5 w-3.5 text-muted-foreground transition-[opacity,transform] duration-150 ease-out`,n?`scale-50 opacity-0`:`scale-100 opacity-100`)}),(0,I.jsx)(f,{className:i(`absolute inset-0 h-3.5 w-3.5 text-muted-foreground transition-[opacity,transform] duration-150 ease-out`,n?`scale-100 opacity-100`:`scale-50 opacity-0`)})]})})}function xe({text:e,timestamp:t,heightClass:n,hoverClass:r,isVisible:a,alignClass:o,onCopied:s}){return(0,I.jsxs)(`div`,{className:i(`pointer-events-none flex items-center gap-1 pt-1 text-xs text-muted-foreground/70 opacity-0 transition-opacity duration-100`,n,o,r,a&&`pointer-events-auto opacity-100`),onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:[t&&(0,I.jsx)(`span`,{children:t}),e&&(0,I.jsx)(be,{text:e,onCopied:s})]})}function Se(e){if(typeof e==`string`)return e;if(e===void 0)return``;try{return JSON.stringify(e,null,2)??``}catch{return String(e)}}function Ce({part:e}){let t=Se(e.payload);return(0,I.jsxs)(`section`,{"data-payload-kind":e.kind,className:`w-full min-w-0 overflow-hidden rounded-xl border border-border/60 bg-muted/40 text-sm`,children:[(0,I.jsx)(`div`,{className:`border-b border-border/50 px-3 py-2 text-xs font-medium text-muted-foreground`,children:e.title}),e.text?(0,I.jsx)(`pre`,{className:`m-0 whitespace-pre-wrap break-words p-3 font-mono text-xs leading-5 text-foreground/80`,children:e.text}):null,t?(0,I.jsxs)(`details`,{open:!0,className:`border-t border-border/50 px-3 py-2`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-muted-foreground`,children:`Payload`}),(0,I.jsx)(`pre`,{className:`m-0 mt-2 max-w-full whitespace-pre-wrap break-words font-mono text-xs leading-5 text-foreground/70`,children:t})]}):null]})}function J(e){return typeof e==`object`&&!!e}function Y(e){return J(e)&&e.type===`text`&&typeof e.text==`string`}function we(e){return J(e)&&e.type===`error`&&typeof e.message==`string`}function Te(e){return J(e)&&e.type===`payload`&&typeof e.kind==`string`&&typeof e.title==`string`}function X(e){if(!J(e))return!1;let t=e.type;return t===`dynamic-tool`||typeof t==`string`&&t.startsWith(`tool-`)}function Ee(e,t){let n=[];for(let t of e)Y(t)&&n.push(t.text);return n.join(t)}function De(e){return typeof e==`object`&&!!e}function Z(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t)return e;try{let n=JSON.parse(t);return De(n)||Array.isArray(n)?n:e}catch{return e}}function Oe(e){if(!De(e)||typeof e.type!=`string`||!e.type.startsWith(`tool-`))return e;let t=Z(e.input),n=Z(e.output),r=Z(e.result),i=t!==e.input,a=n!==e.output,o=r!==e.result;if(!i&&!a&&!o)return e;let s={...e};return i&&(s.input=t),a&&(s.output=n),o&&(s.result=r),s}function ke(e){let t=!1,n=e.map(e=>{let n=Oe(e);return n!==e&&(t=!0),n});return t?n:e}var Ae=[];(0,F.memo)(function(e){let{message:t,UserMessageComponent:n,userMessageClassName:r,onCopied:i,display:a}=e,{enableImagePreview:o,showCopyToolbar:s,isMounted:c,isCopyVisible:l}=a,u=Ee(t.parts??[],``),d=(t.parts??[]).length>0;if(!u&&!d)return null;let f=t?.createdAt,p=`user-${t.id}`,m=c&&f?ye(new Date(f)):void 0;return(0,I.jsxs)(`div`,{className:`group/user-message`,children:[(0,I.jsx)(n,{message:t,className:r,enableImagePreview:o}),(s&&!!u||!!m)&&(0,I.jsx)(xe,{text:s?u:``,timestamp:m,heightClass:`h-[28px]`,hoverClass:`group-hover/user-message:opacity-100 group-hover/user-message:pointer-events-auto`,isVisible:l,alignClass:`justify-end`,onCopied:()=>i(p)})]})}),(0,F.memo)(function(e){let{assistantMsgs:t,turnKey:n,ToolRendererComponent:r,TextRendererComponent:i,toolRenderers:a,onOpenUIAction:o,onOpenUIArtifactReady:s,onOpenArtifact:c,onCopied:l,stream:u,copy:d,display:f}=e,{isLast:p,isStreaming:m}=u,{enabled:h,isVisible:g}=d,{suppressQuestionTool:_}=f,v=Ee(t.flatMap(e=>e.parts??[]),`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/openui-renderer-ByP8yQph.js","assets/rolldown-runtime-hePW80VL.js","assets/react-Cvdyeg_0.js","assets/react-dom-B7th3XGm.js","assets/jsx-runtime-NZYk81nU.js","assets/button-Bqms7ZKX.js","assets/utils-CFDGLzf6.js","assets/createBaseUIEventDetails-DklXWq23.js","assets/dist-BogNzeK9.js","assets/clsx-DB0hHKMi.js","assets/card-DPCbcrMK.js","assets/select-Dp15z1lf.js","assets/surface-context-VvasJf_6.js","assets/useBaseUiId-BlzQUkVG.js","assets/check-BTwIaCtI.js","assets/createLucideIcon-CQY2ECfR.js","assets/chevron-down-Bse1ggZM.js","assets/input-DECT4vz2.js","assets/useControlled-CkQSkSv1.js","assets/safe-external-url-BnEhm9A0.js","assets/chunk-YOKDWASO-Dego39cu.js","assets/preload-helper-BZ1Pz5am.js","assets/lib-ChrQ49PO.js","assets/character-entities-legacy-Wut6vMuj.js","assets/badge-9wr3qUp1.js","assets/dist-BJJVCio8.js","assets/markdown-B2tpfUKu.js","assets/switch-eqXIzePo.js","assets/dialog-DuCD5hRq.js","assets/x-DEU6H3M-.js","assets/openui-utils-DawGoQNp.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-Cvdyeg_0.js";import{t as n}from"./react-dom-B7th3XGm.js";import{t as r}from"./jsx-runtime-NZYk81nU.js";import{t as i}from"./utils-CFDGLzf6.js";import{d as a,o,r as s}from"./ease-2gsl7ABx.js";import{n as c,t as l}from"./use-reduced-motion-BzGFRmoG.js";import{t as u}from"./createLucideIcon-CQY2ECfR.js";import{i as d}from"./citations-C7USoVdz.js";import{t as f}from"./check-BTwIaCtI.js";import{t as p}from"./chevron-right-BPCB1mOg.js";import{n as m,t as h}from"./file-text-cqOanUYv.js";import{t as g}from"./circle-check-DBhaebaM.js";import{a as _,i as v}from"./action-swap-roll-Bek47h-E.js";import{t as y}from"./loader-circle-BmKYM_C4.js";import{t as b}from"./x-DEU6H3M-.js";import{t as x}from"./preload-helper-BZ1Pz5am.js";import{t as S}from"./openui-utils-DawGoQNp.js";import"./tokens-CtP2s1Y3.js";import{i as C}from"./workspace-path-nav-umvkE4ut.js";import{t as w}from"./notify-mVA6z9Ly.js";var T={name:`chevron-left`,size:24,node:[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]};T.node;var E=u(T),D={name:`file-braces`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1`,key:`1oajmo`}],[`path`,{d:`M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1`,key:`mpwhp6`}]],aliases:[`file-json`]};D.node;var O=u(D),k={name:`file-code`,size:24,node:[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M10 12.5 8 15l2 2.5`,key:`1tg20x`}],[`path`,{d:`m14 12.5 2 2.5-2 2.5`,key:`yinavb`}]]};k.node;var A=u(k),j={name:`image`,size:24,node:[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,ry:`2`,key:`1m3agn`}],[`circle`,{cx:`9`,cy:`9`,r:`2`,key:`af1f0g`}],[`path`,{d:`m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21`,key:`1xmnt7`}]]};j.node;var M=u(j),N={name:`rotate-cw`,size:24,node:[[`path`,{d:`M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8`,key:`1p45f6`}],[`path`,{d:`M21 3v5h-5`,key:`1q7to0`}]]};N.node;var P=u(N),F=e(t(),1),I=r(),L=(0,F.lazy)(()=>x(async()=>{let{GenerativeTextRenderer:e}=await import(`./openui-renderer-ByP8yQph.js`).then(e=>e.n);return{GenerativeTextRenderer:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30])).then(({GenerativeTextRenderer:e})=>({default:e})));function R({className:e,content:t}){return(0,I.jsx)(`div`,{className:e?`${e} whitespace-pre-wrap`:`whitespace-pre-wrap`,children:t})}function z(e){return(0,F.useMemo)(()=>S(e.content).some(e=>e.type===`openui`),[e.content])?(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(R,{className:e.className,content:e.content}),children:(0,I.jsx)(L,{...e})}):(0,I.jsx)(C,{className:e.className,content:e.content,isStreaming:e.isStreaming})}function B(e){let t=[],n;for(let r of e){if(r.role===`user`){n&&t.push(n),n={user:r,assistants:[]};continue}if(r.role===`assistant`){if(!n||r.source===`local`){n&&t.push(n),n={assistants:[r]};continue}n.assistants.push(r)}}return n&&t.push(n),t}var V=(0,F.createContext)(void 0),H=(0,F.createContext)({animateIn:!0,variant:`soft`}),U=(0,F.createContext)(()=>{});function ee(...e){return t=>{for(let n of e)typeof n==`function`?n(t):n&&(n.current=t)}}var W={duration:.12,ease:s,delay:.04},G={type:`spring`,stiffness:520,damping:27,mass:.52};function te({variant:e=`soft`,align:t,animateIn:n=!1,className:r,children:s,initial:c,animate:u,exit:d,transition:f,layout:p,...m}){let h=l()??!1,g=(0,F.useContext)(V),_=t??g??`start`,v=(0,F.useMemo)(()=>({align:_,animateIn:n,variant:e}),[n,_,e]);return(0,I.jsx)(H.Provider,{value:v,children:(0,I.jsx)(a.div,{"data-slot":`message-bubble`,"data-align":_,"data-variant":e,layout:p,initial:c??!1,animate:u,exit:d??(h?{opacity:0}:{opacity:0,y:-3,scale:.99}),transition:f??(h?{duration:.12}:o),className:i(`group/bubble flex w-full flex-col`,_===`end`?`items-end`:`items-start`,r),...m,children:s})})}function ne(e,t){return i(`relative z-0 min-w-9 max-w-[82%] rounded-2xl px-3.5 py-2.5 text-sm leading-6 text-foreground`,`[&_a]:font-medium [&_a]:underline [&_a]:underline-offset-4 [&_code]:rounded [&_code]:bg-background/60 [&_code]:px-1 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[90%] [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p+p]:mt-2 [&_pre]:my-2 [&_pre]:overflow-x-auto [&_pre]:rounded-xl [&_pre]:bg-background/60 [&_pre]:p-3 [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5`,e===`solid`&&`text-background`,e===`ghost`&&`w-full max-w-none rounded-none px-0 py-0`,e===`danger`&&`text-destructive`,t&&`cursor-pointer text-left outline-none transition-[background-color,color,transform] duration-150 hover:brightness-[0.98] focus-visible:ring-2 focus-visible:ring-ring active:scale-[0.99]`)}function re(e,t){return i(`pointer-events-none absolute inset-0 -z-10 rounded-[inherit]`,t===`end`?`origin-bottom-right`:`origin-bottom-left`,e===`solid`&&`bg-foreground`,e===`soft`&&`bg-muted`,e===`tint`&&`bg-primary/10`,e===`outline`&&`border border-border/70 bg-background`,e===`danger`&&`bg-destructive/10`)}function ie({render:e,className:t,children:n,ref:r,...c}){let u=l()??!1,{align:d=`start`,animateIn:f,variant:p}=(0,F.useContext)(H),[m,h]=(0,F.useState)(0),g=(0,F.useCallback)(()=>h(e=>e+1),[]),_=e?.type===`button`||e?.type===`a`,v=i(ne(p,_),t),y=(0,I.jsxs)(I.Fragment,{children:[p===`ghost`?null:(0,I.jsx)(a.span,{"aria-hidden":`true`,layout:!1,layoutDependency:m,initial:f&&!u?{opacity:0,scale:.92}:!1,animate:{opacity:1,scale:1},transition:u?{duration:0}:{opacity:{duration:.12,ease:s},scale:G,layout:o},className:re(p,d)}),(0,I.jsx)(U.Provider,{value:g,children:(0,I.jsx)(a.div,{initial:f?{opacity:0}:!1,animate:{opacity:1},transition:u?{duration:.12,ease:s}:W,className:`relative`,children:n})})]});if(e){let t=e;return(0,F.cloneElement)(t,{...c,ref:ee(t.props.ref,r),className:i(v,t.props.className),children:y,"data-slot":`message-bubble-content`})}return(0,I.jsx)(`div`,{ref:r,"data-slot":`message-bubble-content`,className:v,...c,children:y})}var K=56,ae=88;function oe(e,t){if(e.length<=t)return e;let n=e.slice(0,t),r=n.lastIndexOf(` `);return`${n.slice(0,r>t*.65?r:t).trim()}…`}function q(e){return((e.querySelector(`[data-slot="message-bubble-content"]`)??e.querySelector(`[data-slot="message-content"]`)??e).textContent??``).replace(/\s+/g,` `).trim()}function se(e,t){let n=q(e);if(!n)return{label:`Message`,description:void 0};if(n.length<=K){let e=t?q(t):``;return{label:n,description:e?oe(e,ae):void 0}}let r=n.slice(0,K).lastIndexOf(` `),i=r>K*.65?r:K,a=`${n.slice(0,i).trim()}…`,o=t?q(t):n.slice(i).trim();return{label:a,description:o?oe(o,ae):void 0}}function ce({navigation:e,followThreshold:t,contentRef:n,viewportRef:r,reduce:i,smooth:a,scrollToEnd:o,setFollowing:s,markProgrammaticScroll:c}){let l=(0,F.useRef)(void 0),u=(0,F.useRef)(new WeakMap),d=(0,F.useRef)(0),f=(0,F.useRef)(new Map),[p,m]=(0,F.useState)([]),[h,g]=(0,F.useState)(``),[_,v]=(0,F.useState)(!1),y=(0,F.useCallback)(()=>{if(e!==`rail`)return;let n=r.current,i=[...f.current.entries()];if(!n||i.length===0)return;let a=n.getBoundingClientRect();if(n.scrollTop<=t){let e=i[0]?.[0]??``;g(t=>t===e?t:e);return}if(n.scrollHeight-n.scrollTop-n.clientHeight<=t){let e=i.at(-1)?.[0]??``;g(t=>t===e?t:e);return}let o=a.top+a.height/2,s=i[0]?.[0]??``,c=1/0;for(let[e,t]of i){let n=t.getBoundingClientRect(),r=Math.abs(n.top+n.height/2-o);r<c&&(c=r,s=e)}g(e=>e===s?e:s)},[t,e,r]),b=(0,F.useCallback)(()=>{if(e!==`rail`)return;let t=n.current,i=r.current;if(!t||!i)return;let a=Array.from(t.querySelectorAll(`[data-slot="message"]`)),o=new Map,s=a.map((e,t)=>{let n=u.current.get(e);n||(d.current+=1,n=`message-rail-${d.current}`,u.current.set(e,n)),o.set(n,e);let r=e.dataset.from??`conversation`,i=se(e,r===`user`?a.slice(t+1).find(e=>e.dataset.from===`assistant`):void 0);return{id:n,label:i.label,description:i.description,ariaLabel:`Go to ${r} message ${t+1} of ${a.length}`}});f.current=o,m(e=>e.length===s.length&&e.every((e,t)=>e.id===s[t]?.id&&e.label===s[t]?.label&&e.description===s[t]?.description&&e.ariaLabel===s[t]?.ariaLabel)?e:s),v(i.scrollHeight>i.clientHeight+1&&a.length>1)},[n,e,r]),x=(0,F.useCallback)(()=>{e===`rail`&&(l.current&&cancelAnimationFrame(l.current),l.current=requestAnimationFrame(()=>{b(),y()}))},[e,b,y]);return(0,F.useEffect)(()=>{if(e!==`rail`){f.current.clear(),m([]),v(!1);return}let t=n.current,i=r.current;if(!t||!i)return;x();let a=typeof MutationObserver>`u`?null:new MutationObserver(x);a?.observe(t,{childList:!0,characterData:!0,subtree:!0});let o=typeof ResizeObserver>`u`?null:new ResizeObserver(x);return o?.observe(t),o?.observe(i),()=>{a?.disconnect(),o?.disconnect()}},[n,e,x,r]),(0,F.useEffect)(()=>()=>{l.current&&cancelAnimationFrame(l.current)},[]),{activeRailId:h,railItems:p,railOverflowing:_,scheduleRailSync:x,scrollToRailItem:(0,F.useCallback)(e=>{let t=r.current,n=f.current.get(e.id);if(!t||!n)return;let l=p.at(-1)?.id===e.id;if(g(e.id),l){s(!0),o(i||!a?`auto`:`smooth`);return}s(!1),c(i||!a?`auto`:`smooth`);let u=t.getBoundingClientRect(),d=n.getBoundingClientRect(),m=t.scrollTop+d.top-u.top-(t.clientHeight-d.height)/2,h=i||!a?`auto`:`smooth`;typeof t.scrollTo==`function`?t.scrollTo({top:m,behavior:h}):t.scrollTop=m},[c,p,i,o,s,a,r])}}function le({item:e}){return(0,I.jsxs)(`div`,{"data-slot":`preview-rail-card`,className:`rounded-2xl border border-border bg-card p-4 shadow-sm`,children:[(0,I.jsx)(`p`,{"data-slot":`preview-rail-title`,className:`font-medium text-card-foreground`,children:e.label}),e.description?(0,I.jsx)(`div`,{"data-slot":`preview-rail-description`,className:`mt-1 text-sm leading-6 text-muted-foreground`,children:e.description}):null]})}function ue({items:e,label:t=`Section navigation`,orientation:n=`vertical`,activeId:r,defaultActiveId:u,onActiveChange:f,onItemSelect:p,renderPreview:m,showPreview:h=!0,previewSide:g=`after`,highlightActive:_=!1,itemSize:v=24,children:y,className:b,railClassName:x,previewContainerClassName:S,previewClassName:C}){let w=(0,F.useId)(),T=l(),E=d(),[D,O]=(0,F.useState)(u??e[0]?.id??``),[k,A]=(0,F.useState)(null),[j,M]=(0,F.useState)(null),N=r??D,P=e.some(e=>e.id===N)?N:e[0]?.id??``,L=k??j??``,R=L||(_?P:``),z=e.findIndex(e=>e.id===R),B=e.length?`repeat(${e.length}, ${v}px)`:void 0,V=n===`horizontal`,H=e=>{r===void 0&&O(e),f?.(e)};return(0,I.jsxs)(a.div,{layoutRoot:!0,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||M(null)},className:i(`isolate relative flex w-full overflow-visible`,V?`min-h-64 flex-col items-center justify-center`:`min-h-80`,b),children:[(0,I.jsx)(`nav`,{"aria-label":t,onPointerLeave:()=>A(null),style:V?{gridTemplateColumns:B}:{gridTemplateRows:B},className:i(`relative z-10 grid shrink-0`,V?`h-12 w-fit max-w-full self-center justify-center`:`w-12 content-center`,x),children:e.map((e,t)=>{let n=e.id===P,r=e.id===R,s=z<0?1/0:Math.abs(t-z),c=r?1:s===1?.68:s===2?.44:.25,l=(0,I.jsx)(I.Fragment,{children:(0,I.jsx)(a.span,{"data-slot":`preview-rail-tick`,"aria-hidden":`true`,animate:V?{scaleY:c}:{scaleX:c},transition:T?{duration:0}:o,className:i(`block bg-current`,V?`h-12 w-0.5 origin-bottom`:`h-0.5 w-12 origin-left`,r?`text-foreground`:void 0)})}),u=i(`relative flex text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background`,V?`h-12 w-6 items-end justify-center`:`h-6 w-12 items-center`),d=V?{width:v}:{height:v},f=()=>{E&&A(e.id)},m=t=>{t.matches(`:focus-visible`)&&M(e.id)},h=()=>{H(e.id),p?.(e)};return e.href?(0,I.jsx)(`a`,{"data-slot":`preview-rail-item`,href:e.href,target:e.target,rel:e.rel??(e.target===`_blank`?`noreferrer noopener`:void 0),"aria-label":e.ariaLabel??e.label,"aria-current":n?`page`:void 0,onPointerEnter:f,onMouseEnter:f,onPointerDown:()=>M(null),onFocus:e=>m(e.currentTarget),onClick:h,style:d,className:u,children:l},e.id):(0,I.jsx)(`button`,{"data-slot":`preview-rail-item`,type:`button`,"aria-label":e.ariaLabel??e.label,"aria-current":n?`location`:void 0,onPointerEnter:f,onMouseEnter:f,onPointerDown:()=>M(null),onFocus:e=>m(e.currentTarget),onClick:h,style:d,className:u,children:l},e.id)})}),h?(0,I.jsx)(`div`,{"aria-hidden":`true`,style:V?{gridTemplateColumns:B}:{gridTemplateRows:B},className:i(`pointer-events-none absolute z-50 grid`,V?`top-1/2 left-1/2 h-5 w-fit max-w-full -translate-x-1/2 -translate-y-1/2 justify-center`:g===`before`?`inset-y-0 right-16 left-4 content-center`:`inset-y-0 right-4 left-16 content-center`,S),children:e.map(e=>(0,I.jsx)(`div`,{style:V?{width:v}:{height:v},className:i(`relative flex items-center`,V?`justify-center`:void 0),children:(0,I.jsx)(c,{mode:`wait`,initial:!1,children:e.id===L?(0,I.jsx)(a.div,{initial:T?{opacity:0}:{opacity:0,y:4,filter:`blur(6px)`},animate:T?{opacity:1}:{opacity:1,y:0,filter:`blur(0px)`},exit:T?{opacity:0}:{opacity:0,y:-2,filter:`blur(4px)`,transition:{duration:.12,ease:s}},transition:{duration:T?0:.18,ease:s},className:i(V?`absolute bottom-12 left-1/2 w-72 -translate-x-1/2`:i(`w-full max-w-sm`,g===`before`&&`ml-auto`),C),children:(0,I.jsx)(a.div,{layoutId:`preview-rail-card-${w}`,transition:T?{duration:0}:o,children:m?m(e):(0,I.jsx)(le,{item:e})})},e.id):null})},e.id))}):null,y?(0,I.jsx)(`div`,{className:`min-h-0 min-w-0 flex-1`,children:y}):null]})}function de({followOutput:e=!0,followThreshold:t=56,smooth:n=!0,onFollowChange:r,label:a=`Conversation`,busy:o,navigation:s,navigationLabel:c=`Message navigation`,viewportClassName:u,contentClassName:d,railClassName:f,viewportRef:p,viewportProps:m,contentProps:h,className:g,children:_,...v}){let y=l()??!1,b=(0,F.useRef)(null),x=(0,F.useRef)(null),S=(0,F.useRef)(e),C=(0,F.useRef)(!1),w=(0,F.useRef)(void 0),T=(0,F.useRef)(void 0),{onScroll:E,onWheel:D,onTouchStart:O,onKeyDown:k,...A}=m??{},j=(0,F.useCallback)(e=>{b.current=e,typeof p==`function`?p(e):p&&(p.current=e)},[p]),M=(0,F.useCallback)(e=>{S.current!==e&&(S.current=e,r?.(e))},[r]),N=(0,F.useCallback)(e=>{C.current=!0,w.current&&window.clearTimeout(w.current),w.current=window.setTimeout(()=>{C.current=!1},e===`smooth`?320:0)},[]),P=(0,F.useCallback)(e=>{let t=b.current;t&&(N(e),typeof t.scrollTo==`function`?t.scrollTo({top:t.scrollHeight,behavior:e}):t.scrollTop=t.scrollHeight)},[N]),{activeRailId:L,railItems:R,railOverflowing:z,scheduleRailSync:B,scrollToRailItem:V}=ce({navigation:s,followThreshold:t,contentRef:x,viewportRef:b,reduce:y,smooth:n,scrollToEnd:P,setFollowing:M,markProgrammaticScroll:N}),H=(0,F.useEffectEvent)(B),U=(0,F.useEffectEvent)(P),ee=(0,F.useCallback)(()=>{let e=b.current;if(!e||C.current)return;let n=e.scrollHeight-e.scrollTop-e.clientHeight;M(n<=t),B()},[t,B,M]),W=(0,F.useCallback)(()=>{C.current=!1},[]);(0,F.useLayoutEffect)(()=>{if(S.current=e,e)return T.current=requestAnimationFrame(()=>U(`auto`)),()=>{T.current&&cancelAnimationFrame(T.current)}},[e]),(0,F.useEffect)(()=>{let t=x.current;if(!t||typeof ResizeObserver>`u`)return;let r=new ResizeObserver(()=>{H(),!(!e||!S.current)&&U(y||!n?`auto`:`smooth`)});return r.observe(t),()=>r.disconnect()},[e,y,n]),(0,F.useEffect)(()=>()=>{w.current&&window.clearTimeout(w.current),T.current&&cancelAnimationFrame(T.current)},[]);let G=(0,I.jsx)(`section`,{ref:j,"aria-label":a,...A,onScroll:e=>{ee(),E?.(e)},onWheel:e=>{W(),D?.(e)},onTouchStart:e=>{W(),O?.(e)},onKeyDown:e=>{[`ArrowUp`,`PageUp`,`Home`].includes(e.key)&&W(),k?.(e)},className:i(`h-full overflow-y-auto overscroll-contain outline-none [overflow-anchor:none] focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,s===`rail`?`[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`:`[scrollbar-gutter:stable]`,u,s===`rail`&&z&&`pr-10`),children:(0,I.jsx)(`div`,{ref:x,role:`log`,"aria-live":o?`off`:`polite`,"aria-relevant":`additions text`,"aria-busy":o,className:d,...h,children:_})});return(0,I.jsx)(`div`,{"data-slot":`message-scroller`,className:i(`min-h-0`,g),...v,children:s===`rail`?(0,I.jsx)(ue,{items:z?R:[],label:c,activeId:L,onItemSelect:V,previewSide:`before`,highlightActive:!0,itemSize:14,className:`h-full min-h-0 overflow-hidden`,previewContainerClassName:`right-8 left-3`,previewClassName:`mr-1 w-64 max-w-full [&_[data-slot=preview-rail-card]]:h-20 [&_[data-slot=preview-rail-card]]:overflow-hidden [&_[data-slot=preview-rail-card]]:p-3 [&_[data-slot=preview-rail-title]]:line-clamp-1 [&_[data-slot=preview-rail-title]]:text-xs [&_[data-slot=preview-rail-title]]:leading-4 [&_[data-slot=preview-rail-description]]:line-clamp-2 [&_[data-slot=preview-rail-description]]:text-xs [&_[data-slot=preview-rail-description]]:leading-4`,railClassName:i(`absolute inset-y-3 right-1 w-7 content-center py-1 [&_[data-slot=preview-rail-item]]:w-7 [&_[data-slot=preview-rail-item]]:justify-end [&_[data-slot=preview-rail-tick]]:h-px [&_[data-slot=preview-rail-tick]]:w-4 [&_[data-slot=preview-rail-tick]]:origin-right`,z?`pointer-events-auto opacity-100`:`pointer-events-none opacity-0`,f),children:G}):G})}var fe=(0,F.createContext)({from:`assistant`}),pe={type:`spring`,stiffness:480,damping:32,mass:.62};function me({from:e,animateIn:t=!1,children:n,className:r,initial:o,animate:s,transition:c,exit:u,style:d,...f}){let p=l()??!1,m=(0,F.useMemo)(()=>({from:e}),[e]);return(0,I.jsx)(V.Provider,{value:e===`user`?`end`:`start`,children:(0,I.jsx)(fe.Provider,{value:m,children:(0,I.jsx)(a.article,{"data-slot":`message`,"data-from":e,"aria-label":f[`aria-label`]??`${e} message`,initial:o??(t&&!p?{opacity:0,transform:`translateY(8px) scale(0.95)`}:!1),animate:s??(t&&!p?{opacity:1,transform:`translateY(0px) scale(1)`}:{opacity:1}),exit:u??(p?{opacity:0}:{opacity:0,transform:`translateY(-3px) scale(0.99)`}),transition:c??(p?{duration:.12}:pe),style:{transformOrigin:e===`user`?`100% 100%`:`0% 100%`,...d},className:i(`group/message flex w-full items-start gap-2`,e===`user`?`flex-row-reverse`:`flex-row`,r),...f,children:n})})})}function he({className:e,...t}){let{from:n}=(0,F.useContext)(fe);return(0,I.jsx)(`div`,{"data-slot":`message-content`,className:i(`flex min-w-0 flex-1 flex-col gap-1.5`,n===`user`?`items-end`:`items-start`,e),...t})}var ge=(0,F.memo)(function({title:e=`Something went wrong`,message:t,className:n}){return(0,I.jsx)(`div`,{className:i(`flex justify-start`,n),children:(0,I.jsxs)(`div`,{className:`rounded-[8px] border border-red-500/30 bg-red-500/10 px-4 py-2.5 text-sm text-foreground`,children:[(0,I.jsx)(`div`,{className:`font-medium text-foreground`,children:e}),(0,I.jsx)(`div`,{className:`mt-0.5 text-muted-foreground`,children:t})]})})}),_e=new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,minute:`2-digit`,hour12:!0}),ve=new Intl.DateTimeFormat(`en-US`,{month:`short`,day:`numeric`});function ye(e){let t=new Date;return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()?_e.format(e):ve.format(e)}function be({text:e,onCopied:t}){let[n,r]=(0,F.useState)(!1),a=(0,F.useRef)(null);return(0,F.useEffect)(()=>()=>{a.current&&window.clearTimeout(a.current)},[]),(0,I.jsx)(`button`,{type:`button`,tabIndex:-1,"aria-label":n?`Copied`:`Copy message`,onClick:async()=>{try{await navigator.clipboard.writeText(e),r(!0),a.current&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{r(!1),a.current=null},2e3),w.success(`Copied to clipboard`),t?.()}catch{w.error(`Failed to copy to clipboard`)}},onPointerDown:e=>{e.stopPropagation()},onMouseDown:e=>e.stopPropagation(),className:i(`flex size-6 items-center justify-center rounded-md transition-[background-color,opacity,transform] duration-150 ease-out active:scale-[0.97]`,`bg-transparent opacity-50 hover:bg-foreground/10 hover:opacity-100`),children:(0,I.jsxs)(`div`,{className:`relative size-3.5`,children:[(0,I.jsx)(v,{className:i(`absolute inset-0 h-3.5 w-3.5 text-muted-foreground transition-[opacity,transform] duration-150 ease-out`,n?`scale-50 opacity-0`:`scale-100 opacity-100`)}),(0,I.jsx)(f,{className:i(`absolute inset-0 h-3.5 w-3.5 text-muted-foreground transition-[opacity,transform] duration-150 ease-out`,n?`scale-100 opacity-100`:`scale-50 opacity-0`)})]})})}function xe({text:e,timestamp:t,heightClass:n,hoverClass:r,isVisible:a,alignClass:o,onCopied:s}){return(0,I.jsxs)(`div`,{className:i(`pointer-events-none flex items-center gap-1 pt-1 text-xs text-muted-foreground/70 opacity-0 transition-opacity duration-100`,n,o,r,a&&`pointer-events-auto opacity-100`),onMouseDown:e=>e.stopPropagation(),onPointerDown:e=>e.stopPropagation(),children:[t&&(0,I.jsx)(`span`,{children:t}),e&&(0,I.jsx)(be,{text:e,onCopied:s})]})}function Se(e){if(typeof e==`string`)return e;if(e===void 0)return``;try{return JSON.stringify(e,null,2)??``}catch{return String(e)}}function Ce({part:e}){let t=Se(e.payload);return(0,I.jsxs)(`section`,{"data-payload-kind":e.kind,className:`w-full min-w-0 overflow-hidden rounded-xl border border-border/60 bg-muted/40 text-sm`,children:[(0,I.jsx)(`div`,{className:`border-b border-border/50 px-3 py-2 text-xs font-medium text-muted-foreground`,children:e.title}),e.text?(0,I.jsx)(`pre`,{className:`m-0 whitespace-pre-wrap break-words p-3 font-mono text-xs leading-5 text-foreground/80`,children:e.text}):null,t?(0,I.jsxs)(`details`,{open:!0,className:`border-t border-border/50 px-3 py-2`,children:[(0,I.jsx)(`summary`,{className:`cursor-pointer text-xs font-medium text-muted-foreground`,children:`Payload`}),(0,I.jsx)(`pre`,{className:`m-0 mt-2 max-w-full whitespace-pre-wrap break-words font-mono text-xs leading-5 text-foreground/70`,children:t})]}):null]})}function J(e){return typeof e==`object`&&!!e}function Y(e){return J(e)&&e.type===`text`&&typeof e.text==`string`}function we(e){return J(e)&&e.type===`error`&&typeof e.message==`string`}function Te(e){return J(e)&&e.type===`payload`&&typeof e.kind==`string`&&typeof e.title==`string`}function X(e){if(!J(e))return!1;let t=e.type;return t===`dynamic-tool`||typeof t==`string`&&t.startsWith(`tool-`)}function Ee(e,t){let n=[];for(let t of e)Y(t)&&n.push(t.text);return n.join(t)}function De(e){return typeof e==`object`&&!!e}function Z(e){if(typeof e!=`string`)return e;let t=e.trim();if(!t)return e;try{let n=JSON.parse(t);return De(n)||Array.isArray(n)?n:e}catch{return e}}function Oe(e){if(!De(e)||typeof e.type!=`string`||!e.type.startsWith(`tool-`))return e;let t=Z(e.input),n=Z(e.output),r=Z(e.result),i=t!==e.input,a=n!==e.output,o=r!==e.result;if(!i&&!a&&!o)return e;let s={...e};return i&&(s.input=t),a&&(s.output=n),o&&(s.result=r),s}function ke(e){let t=!1,n=e.map(e=>{let n=Oe(e);return n!==e&&(t=!0),n});return t?n:e}var Ae=[];(0,F.memo)(function(e){let{message:t,UserMessageComponent:n,userMessageClassName:r,onCopied:i,display:a}=e,{enableImagePreview:o,showCopyToolbar:s,isMounted:c,isCopyVisible:l}=a,u=Ee(t.parts??[],``),d=(t.parts??[]).length>0;if(!u&&!d)return null;let f=t?.createdAt,p=`user-${t.id}`,m=c&&f?ye(new Date(f)):void 0;return(0,I.jsxs)(`div`,{className:`group/user-message`,children:[(0,I.jsx)(n,{message:t,className:r,enableImagePreview:o}),(s&&!!u||!!m)&&(0,I.jsx)(xe,{text:s?u:``,timestamp:m,heightClass:`h-[28px]`,hoverClass:`group-hover/user-message:opacity-100 group-hover/user-message:pointer-events-auto`,isVisible:l,alignClass:`justify-end`,onCopied:()=>i(p)})]})}),(0,F.memo)(function(e){let{assistantMsgs:t,turnKey:n,ToolRendererComponent:r,TextRendererComponent:i,toolRenderers:a,onOpenUIAction:o,onOpenUIArtifactReady:s,onOpenArtifact:c,onCopied:l,stream:u,copy:d,display:f}=e,{isLast:p,isStreaming:m}=u,{enabled:h,isVisible:g}=d,{suppressQuestionTool:_}=f,v=Ee(t.flatMap(e=>e.parts??[]),`
3
3
 
4
4
  `),y=m&&p,b=h&&!!v.trim()&&!y,x=`assistant-${n}-all`,S=h?v:``;return(0,I.jsxs)(`div`,{className:`group/assistant-turn`,children:[(0,I.jsx)(`div`,{className:`flex flex-col gap-3`,children:t.map((e,n)=>{let l=p&&n===t.length-1;return(0,I.jsx)(Fe,{msg:e,isLast:l,isStreaming:m,suppressQuestionTool:_,ToolRendererComponent:r,TextRendererComponent:i,toolRenderers:a,onOpenUIAction:o,onOpenUIArtifactReady:s,onOpenArtifact:c},e.id)})}),(b||g)&&(0,I.jsx)(xe,{text:S,heightClass:`h-[48px] flex items-start w-full`,hoverClass:`group-hover/assistant-turn:opacity-100 group-hover/assistant-turn:pointer-events-auto`,isVisible:g,alignClass:`justify-start`,onCopied:()=>l(x)})]})});var je=`tool-call:`,Me=`unkeyed-tool:`;function Ne(e,t,n){return t.toolCallId?`${je}${t.toolCallId}`:`${Me}${e}:${t.type}:${n}`}function Pe(e,t){let{messageId:n,isLast:r,isStreaming:i,suppressQuestionTool:a,suppressTextWhenPlanWrite:o=!1,ToolRendererComponent:s,TextRendererComponent:c,toolRenderers:l,onOpenUIAction:u,onOpenUIArtifactReady:d,onOpenArtifact:f}=t,p=[],m=[],h=o&&e.some(e=>X(e)&&e.type===`tool-PlanWrite`),g=new Set(e.filter(e=>X(e)&&(e.type===`tool-Task`||e.type===`tool-Agent`)&&typeof e.toolCallId==`string`).map(e=>e.toolCallId)),_=new Map,v=new Set,y=new Map;for(let t of e){if(!X(t)||t.type===`tool-TaskOutput`||!t.toolCallId||!t.toolCallId.includes(`:`))continue;let e=t.toolCallId.split(`:`)[0];g.has(e)&&(_.has(e)||_.set(e,[]),_.get(e).push(t),v.add(t.toolCallId))}let b=0;for(;b<e.length;){let t=e[b];if(X(t)&&t.type===`tool-TaskOutput`){b++;continue}if(Y(t)){let e=t.text;e&&!h&&m.push(e),b++;continue}if(we(t)){p.push((0,I.jsx)(ge,{title:t.title,message:t.message},`${n}-error-${t.title}-${t.message}`)),b++;continue}if(Te(t)){p.push((0,I.jsx)(Ce,{part:t},`${n}-payload-${b}`)),b++;continue}if(X(t)){if(a&&t.type===`tool-Question`){b++;continue}if(t.toolCallId&&v.has(t.toolCallId)){b++;continue}let e=r&&i?`streaming`:void 0,o=t.toolCallId,c=(t.type===`tool-Task`||t.type===`tool-Agent`)&&o?_.get(o)??Ae:void 0,u=t.toolCallId?0:y.get(t.type)??0;t.toolCallId||y.set(t.type,u+1),p.push((0,I.jsx)(s,{part:t,nestedTools:c,chatStatus:e,toolRenderers:l},Ne(n,t,u))),b++;continue}b++}let x=m.join(`
5
5
 
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-Cvdyeg_0.js";import{t as n}from"./jsx-runtime-NZYk81nU.js";import{t as r}from"./button-BJyg7l5W.js";import{t as i}from"./utils-Dpy9ZFOr.js";import{t as a}from"./bot-DETalD3q.js";import{n as o,t as s}from"./subagent-utils-D7sXbLsS.js";import{t as c}from"./chevron-right-BPCB1mOg.js";import{t as l}from"./subagent-transcript-D_L-8PQi.js";var u=e(t(),1),d=n();function f({agents:e,loadSession:t,onOpenTab:n,parentSessionId:f,tree:p}){let m=(0,u.useMemo)(()=>s(e,p),[e,p]),[h,g]=(0,u.useState)(null),[_,v]=(0,u.useState)({}),y=(0,u.useRef)(new Map),b=m.find(e=>e.id===h)??m[0];(0,u.useEffect)(()=>{h&&m.some(e=>e.id===h)||g(m[0]?.id??null)},[m,h]);let x=(0,u.useCallback)(async(e,n=!1)=>{if(!f)return;let r=`${f}:${e.id}:${e.status}:${e.timestamp}:${e.activeSessionId??``}`,i=_[e.id];if(!n&&i?.requestKey===r)return;let a=(y.current.get(e.id)??0)+1;y.current.set(e.id,a),v(t=>({...t,[e.id]:{requestKey:r,status:`loading`,messages:[]}}));try{let n=await t(f,e.id);if(y.current.get(e.id)!==a)return;v(t=>({...t,[e.id]:{requestKey:r,status:`ready`,messages:n.messages,presentation:n.presentation}}))}catch(t){if(y.current.get(e.id)!==a)return;v(n=>({...n,[e.id]:{requestKey:r,status:`error`,messages:[],error:t instanceof Error?t:Error(String(t))}}))}},[t,f,_]);return(0,u.useEffect)(()=>{b&&x(b)},[x,b]),m.length===0?(0,d.jsx)(`section`,{"aria-label":`Subagents`,className:`flex min-h-36 items-center rounded-md border border-dashed border-border/70 px-4 text-center text-label leading-5 text-foreground/45`,children:`Subagent threads will appear here when Prime delegates work.`}):(0,d.jsxs)(`section`,{"aria-label":`Subagents`,className:`space-y-2 pb-1`,children:[(0,d.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-sm bg-foreground/5 px-2 py-1.5`,children:[(0,d.jsx)(a,{className:`size-3.5 shrink-0 text-foreground/45`}),(0,d.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-label font-medium text-foreground/70`,children:`Invoked subagents`}),(0,d.jsx)(`span`,{className:`shrink-0 text-micro text-foreground/40`,children:m.length})]}),(0,d.jsx)(`div`,{className:`space-y-0.5`,"data-testid":`subagent-thread-list`,children:m.map(e=>{let t=e.id===b?.id;return(0,d.jsxs)(r,{type:`button`,variant:`ghost`,size:`compact`,"aria-pressed":t,className:i(`flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-foreground/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,t&&`bg-foreground/8`),style:{paddingLeft:`${8+Math.max(0,e.depth??0)*12}px`},onClick:()=>{g(e.id),n?.(e.id)},children:[(0,d.jsx)(`span`,{className:`shrink-0`,children:o(e.status)}),(0,d.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground/80`,children:e.label}),(0,d.jsx)(c,{className:`size-3 shrink-0 text-foreground/30`}),(0,d.jsx)(`span`,{className:`shrink-0 text-micro capitalize text-foreground/45`,children:e.status})]},e.id)})}),b?(0,d.jsx)(l,{child:b,parentSessionId:f,transcript:_[b.id],onRefresh:()=>void x(b,!0)}):null]})}export{f as SubagentsPanelContent};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{t}from"./react-Cvdyeg_0.js";import{t as n}from"./jsx-runtime-NZYk81nU.js";import{t as r}from"./button-Bqms7ZKX.js";import{t as i}from"./utils-CFDGLzf6.js";import{t as a}from"./bot-DETalD3q.js";import{n as o,t as s}from"./subagent-utils-CM2qX9BG.js";import{t as c}from"./chevron-right-BPCB1mOg.js";import{t as l}from"./subagent-transcript-BCUhqVvi.js";var u=e(t(),1),d=n();function f({agents:e,loadSession:t,onOpenTab:n,parentSessionId:f,tree:p}){let m=(0,u.useMemo)(()=>s(e,p),[e,p]),[h,g]=(0,u.useState)(null),[_,v]=(0,u.useState)({}),y=(0,u.useRef)(new Map),b=m.find(e=>e.id===h)??m[0];(0,u.useEffect)(()=>{h&&m.some(e=>e.id===h)||g(m[0]?.id??null)},[m,h]);let x=(0,u.useCallback)(async(e,n=!1)=>{if(!f)return;let r=`${f}:${e.id}:${e.status}:${e.timestamp}:${e.activeSessionId??``}`,i=_[e.id];if(!n&&i?.requestKey===r)return;let a=(y.current.get(e.id)??0)+1;y.current.set(e.id,a),v(t=>({...t,[e.id]:{requestKey:r,status:`loading`,messages:[]}}));try{let n=await t(f,e.id);if(y.current.get(e.id)!==a)return;v(t=>({...t,[e.id]:{requestKey:r,status:`ready`,messages:n.messages,presentation:n.presentation}}))}catch(t){if(y.current.get(e.id)!==a)return;v(n=>({...n,[e.id]:{requestKey:r,status:`error`,messages:[],error:t instanceof Error?t:Error(String(t))}}))}},[t,f,_]);return(0,u.useEffect)(()=>{b&&x(b)},[x,b]),m.length===0?(0,d.jsx)(`section`,{"aria-label":`Subagents`,className:`flex min-h-36 items-center rounded-md border border-dashed border-border/70 px-4 text-center text-label leading-5 text-foreground/45`,children:`Subagent threads will appear here when Prime delegates work.`}):(0,d.jsxs)(`section`,{"aria-label":`Subagents`,className:`space-y-2 pb-1`,children:[(0,d.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 rounded-sm bg-foreground/5 px-2 py-1.5`,children:[(0,d.jsx)(a,{className:`size-3.5 shrink-0 text-foreground/45`}),(0,d.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-label font-medium text-foreground/70`,children:`Invoked subagents`}),(0,d.jsx)(`span`,{className:`shrink-0 text-micro text-foreground/40`,children:m.length})]}),(0,d.jsx)(`div`,{className:`space-y-0.5`,"data-testid":`subagent-thread-list`,children:m.map(e=>{let t=e.id===b?.id;return(0,d.jsxs)(r,{type:`button`,variant:`ghost`,size:`compact`,"aria-pressed":t,className:i(`flex w-full min-w-0 items-center gap-2 rounded-md px-2 py-1.5 text-left transition-colors hover:bg-foreground/5 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,t&&`bg-foreground/8`),style:{paddingLeft:`${8+Math.max(0,e.depth??0)*12}px`},onClick:()=>{g(e.id),n?.(e.id)},children:[(0,d.jsx)(`span`,{className:`shrink-0`,children:o(e.status)}),(0,d.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-xs text-foreground/80`,children:e.label}),(0,d.jsx)(c,{className:`size-3 shrink-0 text-foreground/30`}),(0,d.jsx)(`span`,{className:`shrink-0 text-micro capitalize text-foreground/45`,children:e.status})]},e.id)})}),b?(0,d.jsx)(l,{child:b,parentSessionId:f,transcript:_[b.id],onRefresh:()=>void x(b,!0)}):null]})}export{f as SubagentsPanelContent};