@yuriai/web 0.3.3 → 0.3.4

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 (93) hide show
  1. package/dist/assets/{AgentSelector-DpOQ7dyw.js → AgentSelector-uBoLtut8.js} +1 -1
  2. package/dist/assets/{ArchivedSessionsDialog-nqnWb-Vc.js → ArchivedSessionsDialog-DZcicxVO.js} +1 -1
  3. package/dist/assets/{AssistantConversationSurface-CKXgty02.js → AssistantConversationSurface-36aP0hRf.js} +3 -3
  4. package/dist/assets/{AssistantSessionCard-C2-2fJul.js → AssistantSessionCard-CZ-1oJiE.js} +2 -2
  5. package/dist/assets/{AssistantView-BR8hsjOv.js → AssistantView-8fyAae7J.js} +1 -1
  6. package/dist/assets/{AssistantsSettingsPage-Bwid1xE0.js → AssistantsSettingsPage-DD6spbXz.js} +1 -1
  7. package/dist/assets/{BinaryFileFallback-Cb3uP7y1.js → BinaryFileFallback-DgYaMG9f.js} +1 -1
  8. package/dist/assets/{BtwPanel-9VAdk_qa.js → BtwPanel-BkobGcf3.js} +1 -1
  9. package/dist/assets/{BusyDots-DeDkh4Ke.js → BusyDots-COTTwItx.js} +1 -1
  10. package/dist/assets/{ChatContainer-wP6o_O4K.js → ChatContainer-BfQ7RXwY.js} +8 -8
  11. package/dist/assets/{ChatView-DU_2-cfD.js → ChatView-ByMRjY1h.js} +1 -1
  12. package/dist/assets/{DiagramView-CaefmjA4.js → DiagramView-DGnmjS2b.js} +1 -1
  13. package/dist/assets/{DiffView-BaqthIvq.js → DiffView-Bbit6OZ8.js} +1 -1
  14. package/dist/assets/{ErrorBoundary-_5B1xjgZ.js → ErrorBoundary-D7QcwhmL.js} +1 -1
  15. package/dist/assets/{FadeInOnReveal-BYHr1gqj.js → FadeInOnReveal-B3uT04YJ.js} +1 -1
  16. package/dist/assets/{GuiPluginMount-Btp3mJT2.js → GuiPluginMount-TC5FELtQ.js} +1 -1
  17. package/dist/assets/{GuiPluginPage-DM_RLx6u.js → GuiPluginPage-BPjU8N49.js} +1 -1
  18. package/dist/assets/{GuiPluginSurface-KiyqqEKU.js → GuiPluginSurface-CYPH6XzX.js} +1 -1
  19. package/dist/assets/{MarkdownRenderer-D7p9Iflj.js → MarkdownRenderer-VvziwyJB.js} +2 -2
  20. package/dist/assets/{MarkdownRendererImpl-BZc_jUrV.js → MarkdownRendererImpl-D8q0FMnr.js} +1 -1
  21. package/dist/assets/{MarkstreamRendererImpl-BUk_c3g1.js → MarkstreamRendererImpl-U_m_ZKG7.js} +1 -1
  22. package/dist/assets/{MobileAssistantSettingsPage-BBIiFN2g.js → MobileAssistantSettingsPage-Dgq5FMho.js} +1 -1
  23. package/dist/assets/{MobileBtwPage-DVZm5hrZ.js → MobileBtwPage-DQUkSO6N.js} +1 -1
  24. package/dist/assets/{MobileChangesSurface-CiqsGZsg.js → MobileChangesSurface-DsYNmAuM.js} +1 -1
  25. package/dist/assets/{MobileChatScreen-DDenVTX8.js → MobileChatScreen-p356_BCN.js} +1 -1
  26. package/dist/assets/{MobileFilesSurface-DIVH9aPV.js → MobileFilesSurface-CF3EW_SK.js} +2 -2
  27. package/dist/assets/{MobileHtmlNetworkBoundary-TBxrF4jJ.js → MobileHtmlNetworkBoundary-DlPF4iPS.js} +2 -2
  28. package/dist/assets/{MobileSettingsTab-MmDnxG47.js → MobileSettingsTab-DaTtRHo1.js} +1 -1
  29. package/dist/assets/{MobileShareBridge-DAlGSXoj.js → MobileShareBridge-CZpFYmiy.js} +1 -1
  30. package/dist/assets/{ModelSelector-HJmXcB3j.js → ModelSelector-EmtltPnd.js} +1 -1
  31. package/dist/assets/{MultiRunWindow-BmxVnblA.js → MultiRunWindow-CeSxAB8w.js} +1 -1
  32. package/dist/assets/{OnboardingScreen-DnEtIaxG.js → OnboardingScreen-BubjTNcy.js} +1 -1
  33. package/dist/assets/{PierreDiffViewer-B1e1H6br.js → PierreDiffViewer-DVKsdwJR.js} +1 -1
  34. package/dist/assets/{RemoteAssistantSessionCard-BgL7oxAK.js → RemoteAssistantSessionCard-DAoFvZht.js} +1 -1
  35. package/dist/assets/{RemoteDesktopPanel-DBrEQwpr.js → RemoteDesktopPanel-f3vRj4ZP.js} +1 -1
  36. package/dist/assets/{ScheduledTasksDialog-BVh0yaZR.js → ScheduledTasksDialog-D_hBP47Y.js} +1 -1
  37. package/dist/assets/{SettingsView-CLE6ra3s.js → SettingsView-DEU94-h1.js} +1 -1
  38. package/dist/assets/{SettingsWindow-DpzeOekS.js → SettingsWindow-DMVAV_el.js} +1 -1
  39. package/dist/assets/{SetupTourDialog-CY_CU5qU.js → SetupTourDialog-BlR7FJvd.js} +1 -1
  40. package/dist/assets/{TerminalView-mO5f0Axl.js → TerminalView-Xcwp3SG1.js} +1 -1
  41. package/dist/assets/{TextSelectionMenu-VsKriqtT.js → TextSelectionMenu-h8iUeNzE.js} +1 -1
  42. package/dist/assets/{ToolOutputDialog-DqCCsC-N.js → ToolOutputDialog-DpaaQ1uZ.js} +1 -1
  43. package/dist/assets/{auto-read-context-DVGIDEr6.js → auto-read-context-ClBUErN2.js} +1 -1
  44. package/dist/assets/{capgoAdapter-94K243Zv.js → capgoAdapter-pfQJmvW2.js} +1 -1
  45. package/dist/assets/{chatUpwardIntent-tvLWGs9Q.js → chatUpwardIntent-B2NrGMm-.js} +1 -1
  46. package/dist/assets/{gitApi-BWsBS_2N.js → gitApi-CoVwjIDy.js} +1 -1
  47. package/dist/assets/{insertionBoundaries-BSDUOMHN.js → insertionBoundaries-Btqgsu1M.js} +1 -1
  48. package/dist/assets/{main-DAbyAg5_.js → main-CXH2hObl.js} +4 -4
  49. package/dist/assets/{main-CHO9s_kb.js → main-ClH7cLKr.js} +2 -2
  50. package/dist/assets/{mcpQueries-1WNtiFYh.js → mcpQueries-Rmp1BKeo.js} +1 -1
  51. package/dist/assets/{miniChat-BZMkNMht.js → miniChat-B_Bw6udu.js} +2 -2
  52. package/dist/assets/{mobile-C9XDDOHq.js → mobile-BR73yoNi.js} +2 -2
  53. package/dist/assets/{mobileBackNavigation-DF_uhF-i.js → mobileBackNavigation-C94n2eLT.js} +1 -1
  54. package/dist/assets/{mobileConnections-DjT1L-_m.js → mobileConnections-x07fHO_5.js} +2 -2
  55. package/dist/assets/{multirun-D34EMeEj.js → multirun-CKQymP08.js} +1 -1
  56. package/dist/assets/{native-config-DSpTDz3F.js → native-config-DVg8_Zx1.js} +1 -1
  57. package/dist/assets/{nativeComposerCover-DXFy97OQ.js → nativeComposerCover-Bhv1EKPT.js} +1 -1
  58. package/dist/assets/{navigation-jU0HUH9s.js → navigation-D1klsD7k.js} +1 -1
  59. package/dist/assets/{openRemoteProjectSession-Bm_nafYw.js → openRemoteProjectSession-DNr74gHD.js} +1 -1
  60. package/dist/assets/{pluginPresentation-DexqrdQ0.js → pluginPresentation-DtyC8NF2.js} +1 -1
  61. package/dist/assets/{pwa-BaWpUiOR.js → pwa-CtDladgB.js} +1 -1
  62. package/dist/assets/{queue-abort-optimistic-UwpgXn4g.js → queue-abort-optimistic-DFbWDRKT.js} +1 -1
  63. package/dist/assets/{reference-history-DBxnA_fF.js → reference-history-IEuzG8KC.js} +1 -1
  64. package/dist/assets/{remoteSessionReference-Cug8RfIG.js → remoteSessionReference-ex07CtrZ.js} +1 -1
  65. package/dist/assets/{renderElectronMiniChatApp-CqrlQAsJ.js → renderElectronMiniChatApp-DM9y9qXo.js} +2 -2
  66. package/dist/assets/{renderMobileApp-CwcwGOox.js → renderMobileApp-DqpPYtZI.js} +4 -4
  67. package/dist/assets/{runtimeConfig-zzeYHX6k.js → runtimeConfig-CyvlrO58.js} +1 -1
  68. package/dist/assets/{runtimeEndpointReset-DUD-TCLY.js → runtimeEndpointReset-C0zNrsI9.js} +3 -3
  69. package/dist/assets/{sessionLookup-4zOaVAuF.js → sessionLookup-DQOiycHr.js} +1 -1
  70. package/dist/assets/{sessionOwnership-CEkPFbS4.js → sessionOwnership-BjhXe6pi.js} +1 -1
  71. package/dist/assets/{speechSettingsQueries-DQnPLEf3.js → speechSettingsQueries-BmkXNn4w.js} +1 -1
  72. package/dist/assets/{types-s_oc_LRs.js → types-DpcA-uDW.js} +1 -1
  73. package/dist/assets/{ui-DrAJTWV6.js → ui-ee2iN869.js} +12 -12
  74. package/dist/assets/{useAppFontEffects-nvkTSYHB.js → useAppFontEffects-rbTKcF0f.js} +2 -2
  75. package/dist/assets/{useDesktopWindowControlsLayout-i6qqpMbd.js → useDesktopWindowControlsLayout-BOkRz-p9.js} +1 -1
  76. package/dist/assets/{useEffectiveDirectory-BxolHzt4.js → useEffectiveDirectory-DiJBIfai.js} +1 -1
  77. package/dist/assets/{useGitStore-B641o_o0.js → useGitStore-Bv8xmXDa.js} +1 -1
  78. package/dist/assets/{useMcpConfigStore-BUSvv0Bl.js → useMcpConfigStore-DKTl0PvE.js} +1 -1
  79. package/dist/assets/{useMobileTranscriptSyncHint-86i3xO8J.js → useMobileTranscriptSyncHint-DM8WG7kz.js} +1 -1
  80. package/dist/assets/{useModelLists-Ca085-di.js → useModelLists-Bf60FIJu.js} +1 -1
  81. package/dist/assets/{useOpenCodeReadiness-CsNcdsCJ.js → useOpenCodeReadiness-Dm6BjA1T.js} +1 -1
  82. package/dist/assets/{usePluginsStore-ZHQOW-R5.js → usePluginsStore-Du4WlceO.js} +1 -1
  83. package/dist/assets/{useProjectGitActions-1QRsD7Rb.js → useProjectGitActions-D3B9ma9z.js} +1 -1
  84. package/dist/assets/{useProjectGitStore-C1K6WpCe.js → useProjectGitStore-DzU2pvrH.js} +1 -1
  85. package/dist/assets/{useProjectRuntimeAPIs-BItoD9Bt.js → useProjectRuntimeAPIs-tjGuODhu.js} +1 -1
  86. package/dist/assets/{useSessionBtwStore-BCHq3UOB.js → useSessionBtwStore-CwvlMabN.js} +1 -1
  87. package/dist/assets/{useStreamingTextThrottle-DGAjmaMZ.js → useStreamingTextThrottle-C9SaKeil.js} +1 -1
  88. package/dist/assets/{worktreeManager-QmahFqHc.js → worktreeManager-DGu8M01Z.js} +1 -1
  89. package/dist/assets/{worktreeSourceBranchPreference-B5Fldnhm.js → worktreeSourceBranchPreference-CuLKwxkx.js} +1 -1
  90. package/dist/index.html +5 -5
  91. package/dist/mini-chat.html +5 -5
  92. package/dist/mobile.html +1 -1
  93. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./runtime-fetch-V-iMWR8t.js";import{F as n,s as r}from"./platform-CiUKDeXd.js";import{it as i,ot as a,st as o}from"./vendor-base-ui-wXsskyKm.js";import{f as s,p as c,r as l}from"./useUIStore-C3ewjGgP.js";import{s as u}from"./terminalApi-DXvEquBF.js";import{n as d,r as f,t as ee}from"./vendor-ghostty-web-DbBrwBII.js";import{i as p,o as m}from"./session-startup-barrier-DT-hIBRf.js";import{n as h}from"./Icon-DmykXZL1.js";import{Ja as g,f as te}from"./ui-DrAJTWV6.js";import{t as _}from"./i18n-DXc6czdR.js";import{t as v}from"./OverlayScrollbar-D6vmoMkQ.js";import{n as y}from"./useThemeSystem-BIXghnHj.js";import{r as ne}from"./device-EIfSfSWk.js";import{n as b}from"./useEffectiveDirectory-BxolHzt4.js";import{n as re}from"./useProjectRuntimeAPIs-BItoD9Bt.js";import{t as ie}from"./sortable-tabs-strip-DmtfYPz0.js";import{n as x,t as S}from"./useFontPreferences-BiRBKhti.js";import{t as ae}from"./project-preview-BCtFY4Rg.js";import{n as oe}from"./projectActions-BPmI9_mW.js";var C=e(o(),1);function se(e){let{colors:t}=e,n=t.syntax.base;return{background:t.surface.background,foreground:n.foreground,cursor:t.interactive.cursor,cursorAccent:t.surface.background,selectionBackground:t.interactive.selection,selectionForeground:t.interactive.selectionForeground,selectionInactiveBackground:t.interactive.selection+`50`,black:t.surface.muted,red:t.status.error,green:t.status.success,yellow:t.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:t.status.error,brightGreen:t.status.success,brightYellow:t.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:t.surface.elevatedForeground}}function ce(e,t,n,r,i=!1){return{cursorBlink:!1,cursorStyle:`bar`,fontSize:t,lineHeight:1.15,fontFamily:`${e}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:i}}var le=e(i(),1),w=a(),T=null;function E(){return T||=f.load(),T}function D(e){if(typeof window>`u`)return null;let t=[e,...Array.from(e.querySelectorAll(`*`))],n=null;for(let e of t){let t=window.getComputedStyle(e).overflowY;if(t===`auto`||t===`scroll`){if(e.scrollHeight-e.clientHeight>2)return e;n||=e}}return n}var O=C.forwardRef(({sessionKey:e,chunks:t,onInput:n,onResize:r,theme:i,fontFamily:a,fontSize:o,className:s,enableTouchScroll:c,autoFocus:l=!0,isVisible:u=!0},f)=>{let{t:p}=_(),h=C.useRef(null),te=C.useRef(null),y=C.useRef(null),ne=C.useRef(null),b=C.useRef(n),re=C.useRef(r),ie=C.useRef(null),x=C.useRef(``),S=C.useRef(null),ae=C.useRef(!1),oe=C.useRef(null),se=C.useRef(!0),T=C.useRef(null),O=C.useRef(null),ue=C.useRef(0),k=C.useRef(null),de=C.useRef(null),A=C.useRef(!1),j=C.useRef(!1),M=C.useRef(null),N=C.useRef(null),fe=C.useRef(null),pe=C.useRef(``),me=C.useRef(null),P=C.useRef(!c),he=C.useRef(u),[,ge]=C.useReducer(e=>e+1,0),[_e,ve]=C.useReducer(e=>e+1,0);b.current=n,re.current=r;let ye=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),F=!!c;C.useEffect(()=>{if(!c){P.current=!0,he.current=u;return}!he.current&&u&&(P.current=!1),he.current=u},[c,u]);let be=C.useCallback(()=>{if(!F)return;let e=h.current,t=k.current;if(!e)return;let n=[];e.getAttribute(`contenteditable`)===`true`&&n.push(e),n.push(...Array.from(e.querySelectorAll(`[contenteditable="true"]`))),n.forEach(e=>{e.setAttribute(`data-terminal-disabled-contenteditable`,`true`),e.setAttribute(`contenteditable`,`false`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.setProperty(`user-select`,`none`),e.style.setProperty(`-webkit-user-select`,`none`)}),e.tabIndex=-1,e.removeAttribute(`role`),e.removeAttribute(`aria-multiline`),Array.from(e.querySelectorAll(`textarea`)).forEach(e=>{e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.border=`0`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.fontSize=`0`,e.style.lineHeight=`0`,e!==t&&e.getAttribute(`data-terminal-disabled-input`)!==`true`&&(e.setAttribute(`data-terminal-disabled-input`,`true`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.disabled=!0,e.style.position=`absolute`,e.style.opacity=`0`,e.style.width=`0px`,e.style.height=`0px`,e.style.pointerEvents=`none`,e.style.zIndex=`-1`)})},[F]),I=C.useCallback(e=>{if(me.current===e)return;let t=y.current;if(t)try{if(typeof t.setOption==`function`){t.setOption(`cursorBlink`,e),me.current=e;return}t.options&&(t.options.cursorBlink=e,me.current=e)}catch{}},[]),L=F&&ye,R=C.useCallback((e,t)=>{let n=L?de.current:k.current,r=h.current;if(!n||!r)return;let i=r.getBoundingClientRect(),a=typeof window<`u`?window.innerWidth:i.width,o=typeof window<`u`?window.innerHeight:i.height,s=i.left+i.width/2,c=i.top+i.height-12,l=typeof e==`number`?e:s,u=typeof t==`number`?t:c,d=Math.max(8,Math.min(a-8,l)),f=Math.max(8,Math.min(o-8,u));n.style.left=`${d}px`,n.style.top=`${f}px`,n.style.bottom=``,(n instanceof HTMLTextAreaElement||n instanceof HTMLInputElement)&&(n.disabled=!1,n.readOnly=!1,n.removeAttribute(`disabled`),n.removeAttribute(`readonly`));try{n.focus({preventScroll:!0})}catch{try{n.focus()}catch{}}},[L]),z=C.useCallback(()=>{if(F){R(),I(!0);return}y.current?.focus(),I(!0)},[R,I,F]),B=C.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),V=C.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),xe=C.useCallback(e=>{if(typeof window>`u`||L)return;fe.current!==null&&(window.clearTimeout(fe.current),fe.current=null);let t=0,n=()=>{fe.current=window.setTimeout(()=>{fe.current=null;let r=B(e);if(!r){if(t+=1,t<3){n();return}return}let i=pe.current;pe.current=r;let a=r.startsWith(i)?r.slice(i.length):r;a&&b.current(a.replace(/\r\n|\r|\n/g,`\r`)),V(e),pe.current=``},t===0?0:24)};n()},[V,B,L]);C.useEffect(()=>{let e=h.current;if(!F||!e||c)return;let t=t=>{let n=t.target;if(n&&n.getAttribute(`data-terminal-hidden-input`)!==`true`&&e.contains(n)){try{n.blur()}catch{}R()}};return e.addEventListener(`focusin`,t,!0),()=>{e.removeEventListener(`focusin`,t,!0)}},[c,F,R]);let Se=C.useCallback(()=>{let e=y.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),H=C.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=h.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),U=C.useCallback(async()=>{if(typeof document>`u`)return;let e=Se()||H();e.trim()&&await g(e)},[H,Se]),W=C.useCallback(()=>Se().trim()?!0:!!H().trim(),[H,Se]);C.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{W()&&(e.preventDefault(),U())};return window.addEventListener(`yuri:copy`,e),()=>{window.removeEventListener(`yuri:copy`,e)}},[U,W]);let G=C.useCallback(()=>{x.current=``,S.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(S.current),S.current=null,ae.current=!1,oe.current=null},[]),K=C.useCallback(()=>{let e=ne.current,t=y.current,n=h.current;if(!e||!t||!n)return;let r=n.getBoundingClientRect();if(!(r.width<24||r.height<24))try{e.fit();let n={cols:t.cols,rows:t.rows},r=ie.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(ie.current=n,re.current(n.cols,n.rows))}catch{}},[]),Ce=C.useCallback(()=>{if(ae.current)return;let e=y.current;if(!e){G();return}if(!x.current)return;let t=x.current;x.current=``,ae.current=!0,e.write(t,()=>{ae.current=!1,x.current&&(typeof window<`u`?S.current=window.requestAnimationFrame(()=>{S.current=null,Ce()}):Ce())})},[G]),we=C.useCallback(()=>{S.current===null&&(typeof window<`u`?S.current=window.requestAnimationFrame(()=>{S.current=null,Ce()}):Ce())},[Ce]),Te=C.useCallback(e=>{e&&(x.current+=e,we())},[we]),Ee=C.useCallback(()=>{if(T.current?.(),T.current=null,O.current!==null&&typeof window<`u`&&(window.clearTimeout(O.current),O.current=null),!c){ue.current=0;return}let e=h.current;if(!e)return;let t=y.current;if(!t)return;ue.current=0;let n=2.2,r=2.8,i=.25,a=.05,s=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},u=()=>typeof performance<`u`?performance.now():Date.now(),d=Math.max(12,Math.round(o*1.35)),f=0,ee=e=>{if(!e)return!1;let n=t.getViewportY(),r=f+e,i=Math.trunc(r/d);return f=r-i*d,i!==0&&t.scrollLines(i),t.getViewportY()!==n},p=()=>{l.rafId!==null&&typeof window<`u`&&window.cancelAnimationFrame(l.rafId),l.rafId=null},m={passive:!1,capture:!1};if(typeof window<`u`&&`PointerEvent`in window){let t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),o=n=>{if(n.pointerType===`touch`){p(),t.pointerId=n.pointerId,t.startX=n.clientX,t.startY=n.clientY,t.moved=!1,t.lastY=n.clientY,t.lastTime=u(),t.velocity=0;try{e.setPointerCapture(n.pointerId)}catch{}}},d=e=>{if(e.pointerType!==`touch`||t.pointerId!==e.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>=6&&(t.moved=!0)}if(t.lastY===null){t.lastY=e.clientY,t.lastTime=u();return}let a=t.lastY,o=t.lastTime??u(),s=u();t.lastY=e.clientY,t.lastTime=s;let c=a-e.clientY;if(Math.abs(c)<1)return;let l=Math.max(s-o,8),d=c*(n+Math.min(r,Math.abs(c)/25)),f=d/l;t.velocity=t.velocity*.75+f*i,t.velocity>8?t.velocity=8:t.velocity<-8&&(t.velocity=-8),t.moved&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),ee(d)},f=n=>{if(n.pointerType!==`touch`||t.pointerId!==n.pointerId)return;let r=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(n.pointerId)}catch{}if(r){F?R(n.clientX,n.clientY):c&&!P.current&&(P.current=!0,y.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(t.velocity)<a){t.velocity=0;return}let i=u(),o=()=>{let e=u(),n=Math.max(e-i,8);i=e;let r=ee(t.velocity*n)??!1,c=Math.sign(t.velocity),l=Math.max(0,Math.abs(t.velocity)-s*n);if(t.velocity=l*c,!r||l<=a){p(),t.velocity=0;return}t.rafId=window.requestAnimationFrame(o)};t.rafId=window.requestAnimationFrame(o)};e.addEventListener(`pointerdown`,o,m),e.addEventListener(`pointermove`,d,m),e.addEventListener(`pointerup`,f,m),e.addEventListener(`pointercancel`,f,m);let h=e.style.touchAction,g=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,T.current=()=>{p(),O.current!==null&&typeof window<`u`&&(window.clearTimeout(O.current),O.current=null),ue.current=0,e.removeEventListener(`pointerdown`,o,m),e.removeEventListener(`pointermove`,d,m),e.removeEventListener(`pointerup`,f,m),e.removeEventListener(`pointercancel`,f,m),e.style.touchAction=h,e.style.overscrollBehaviorY=g};return}let g=e=>{e.touches.length===1&&(p(),l.lastY=e.touches[0].clientY,l.lastTime=u(),l.velocity=0,l.startX=e.touches[0].clientX,l.startY=e.touches[0].clientY,l.didMove=!1)},te=e=>{if(e.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,p();return}let t=e.touches[0].clientX,a=e.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){let e=t-l.startX,n=a-l.startY;Math.hypot(e,n)>=6&&(l.didMove=!0)}if(l.lastY===null){l.lastY=a,l.lastTime=u();return}let o=l.lastY,s=l.lastTime??u(),c=u();l.lastY=a,l.lastTime=c;let d=o-a;if(Math.abs(d)<1)return;let f=Math.max(c-s,8),m=d*(n+Math.min(r,Math.abs(d)/25)),h=m/f;l.velocity=l.velocity*.75+h*i,l.velocity>8?l.velocity=8:l.velocity<-8&&(l.velocity=-8),l.didMove&&(e.preventDefault(),e.stopPropagation()),ee(m)},_=e=>{let t=!l.didMove;l.lastY=null,l.lastTime=null;let n=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,t){let t=e.changedTouches?.[0];F?R(t?.clientX,t?.clientY):c&&!P.current&&(P.current=!0,y.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(n)<a){l.velocity=0;return}let r=u(),i=()=>{let e=u(),t=Math.max(e-r,8);r=e;let n=ee(l.velocity*t)??!1,o=Math.sign(l.velocity),c=Math.max(0,Math.abs(l.velocity)-s*t);if(l.velocity=c*o,!n||c<=a){p(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(i)};l.rafId=window.requestAnimationFrame(i)};e.addEventListener(`touchstart`,g,m),e.addEventListener(`touchmove`,te,m),e.addEventListener(`touchend`,_,m),e.addEventListener(`touchcancel`,_,m);let v=e.style.touchAction,ne=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,T.current=()=>{p(),O.current!==null&&typeof window<`u`&&(window.clearTimeout(O.current),O.current=null),ue.current=0,e.removeEventListener(`touchstart`,g,m),e.removeEventListener(`touchmove`,te,m),e.removeEventListener(`touchend`,_,m),e.removeEventListener(`touchcancel`,_,m),e.style.touchAction=v,e.style.overscrollBehaviorY=ne}},[c,F,R,o]);C.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,u=null,f=null,p=h.current;if(!p)return;if(p.tabIndex=F?-1:0,F){let e=p.focus.bind(p),t=p;t.focus=((...e)=>{R()}),f=()=>{t.focus=e}}let m=()=>{I(!0)},g=()=>{I(!1)},_=e=>{let t=e.target;if(t&&p.contains(t)){if(F&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur(),R()},0),I(!1);return}if(c&&!P.current&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur()},0),I(!1);return}I(!0);return}I(!1)},v=()=>{I(!1)},re=null;return(async()=>{try{let f=await E();if(e)return;let h=ce(a,o,i,f,!1),_=new d(h);se.current=!0,F&&(_.focus=()=>{});let v=_;if(typeof v.scrollToBottom==`function`){let e=v.scrollToBottom.bind(v);v.scrollToBottom=()=>{se.current&&e()},l=()=>{v.scrollToBottom=e}}let ie=new ee;if(t=_,y.current=_,ne.current=ie,_.loadAddon(ie),_.open(p),c){let e=_.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},u=()=>{e.renderScrollbar=t}}}ve(),me.current=!1,re=_.textarea??p.querySelector(`textarea`),re&&(re.addEventListener(`focus`,m),re.addEventListener(`blur`,g)),be(),typeof MutationObserver<`u`&&(r=new MutationObserver(()=>{be()}),r.observe(p,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`contenteditable`,`role`,`tabindex`,`aria-label`]}));let x=D(p);x?(x.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),te.current=x,ge()):te.current=null,K();let S=ie;typeof S.observeResize==`function`&&S.observeResize(),Ee(),s=[_.onData(e=>{b.current(e)}),_.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof _.hasSelection==`function`&&_.hasSelection();se.current=!t&&e<=.5}}),_.onSelectionChange(()=>{if(typeof _.hasSelection==`function`&&_.hasSelection()){se.current=!1;return}let e=typeof _.getViewportY==`function`?_.getViewportY():0;se.current=e<=.5})],n=new ResizeObserver(()=>{K()}),n.observe(p),typeof window<`u`&&window.setTimeout(()=>{K()},0)}catch{}})(),document.addEventListener(`focusin`,_,!0),window.addEventListener(`blur`,v),()=>{e=!0,T.current?.(),T.current=null,document.removeEventListener(`focusin`,_,!0),window.removeEventListener(`blur`,v),s.forEach(e=>e.dispose()),l?.(),l=null,u?.(),u=null,re&&(re.removeEventListener(`focus`,m),re.removeEventListener(`blur`,g)),n?.disconnect(),r?.disconnect(),f?.(),t?.dispose(),y.current=null,ne.current=null,te.current=null,ie.current=null,me.current=null,G()}},[be,c,K,R,a,o,Ee,i,G,I,F]),C.useEffect(()=>{let e=y.current;e&&(e.reset(),G(),ie.current=null,K())},[e,_e,K,G]),C.useEffect(()=>{l&&y.current&&z()},[l,z,e,_e]),C.useEffect(()=>(Ee(),()=>{T.current?.(),T.current=null}),[Ee,e]),C.useEffect(()=>{let e=y.current;if(!e)return;if(t.length===0){oe.current!==null&&(e.reset(),G(),K());return}let n=oe.current,r;if(n===null)r=t;else{let e=t.findIndex(e=>e.id===n);r=e>=0?t.slice(e+1):t}r.length>0&&Te(r.map(e=>e.data).join(``)),oe.current=t[t.length-1].id},[t,_e,Te,K,G]),C.useImperativeHandle(f,()=>({focus:()=>{z()},clear:()=>{let e=y.current;e&&(e.reset(),G(),K())},fit:()=>{K()}}),[z,K,G]);let De=C.useCallback(e=>{if(!F)return;let t=h.current,n=e.relatedTarget,r=n?.tagName;r===`INPUT`||r===`TEXTAREA`||n?.isContentEditable,n?.getAttribute(`data-terminal-hidden-input`),n&&t?.contains(n)},[F]),q=C.useCallback(e=>{let t=e.nativeEvent,n=t?.inputType??``,r=typeof t?.data==`string`?t.data:``;if(N.current=typeof performance<`u`?performance.now():Date.now(),n===`insertCompositionText`){A.current=!0;return}if(!n&&r){if(A.current)return;e.preventDefault(),b.current(r),M.current={type:`insertText`,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0;return}if(n===`insertText`&&r){if(A.current)return;e.preventDefault(),b.current(r),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0;return}if(n===`insertLineBreak`){if(A.current)return;e.preventDefault(),b.current(`\r`),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0;return}if(n===`deleteContentBackward`){if(A.current)return;e.preventDefault(),b.current(``),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0}},[]),Oe=C.useCallback(e=>{let t=e.currentTarget;if(N.current=typeof performance<`u`?performance.now():Date.now(),A.current)return;if(j.current){let e=M.current,n=typeof performance<`u`?performance.now():Date.now();if(e&&n-e.at<50){j.current=!1,V(t);return}j.current=!1}let n=B(t);if(!n)return;pe.current=n;let r=n.replace(/\r\n|\r|\n/g,`\r`);b.current(r),V(t),pe.current=``},[V,B]),J=C.useCallback(e=>{e.stopPropagation();let t=e.key.toLowerCase(),n=e.metaKey&&!e.ctrlKey&&!e.altKey&&t===`c`,r=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&t===`c`;if((n||r)&&W()){e.preventDefault(),U();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){let t=e.key.toUpperCase();if(t>=`A`&&t<=`Z`){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),b.current(String.fromCharCode(t.charCodeAt(0)-64)),V(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),b.current(`\x1B`+e.key),V(e.currentTarget);return}let i={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Escape:`\x1B`,Tab:` `,Delete:`\x1B[3~`,Home:`\x1B[H`,End:`\x1B[F`}[e.key];if(i){e.preventDefault(),b.current(i),V(e.currentTarget);return}let a=e.currentTarget;if(e.nativeEvent?.isComposing)return;let o=M.current,s=typeof performance<`u`?performance.now():Date.now(),c=!!(o&&s-o.at<50);if(e.key===`Enter`){if(c&&o?.type===`insertLineBreak`)return;e.preventDefault(),b.current(`\r`),V(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;B(a)||b.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=N.current;t&&s-t<50||(e.preventDefault(),b.current(e.key),j.current=!0,M.current={type:`keydown-text`,at:s})}xe(a)},[V,U,W,B,xe]),ke=C.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||xe(t)},[xe]),Y=C.useCallback(e=>{let t=e.currentTarget;A.current=!1;let n=e.data||B(t);if(N.current=typeof performance<`u`?performance.now():Date.now(),!n)return;let r=n.replace(/\r\n|\r|\n/g,`\r`);b.current(r),V(t),M.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0},[V,B]),X=C.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=y.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;b.current(n)},[]),Z={position:`fixed`,left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:`transparent`,color:`transparent`,WebkitTextFillColor:`transparent`,caretColor:`transparent`,textShadow:`none`,WebkitAppearance:`none`,appearance:`none`,resize:`none`,overflow:`hidden`,whiteSpace:`nowrap`,border:`0`,padding:0,margin:0,outline:`none`,outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:`none`,WebkitUserSelect:`none`,userSelect:`none`};return(0,w.jsxs)(`div`,{ref:h,className:m(`relative h-full w-full terminal-viewport-container`,s),"data-hidden-input-overlay-active":F?`true`:void 0,style:{backgroundColor:i.background},onTouchStart:e=>{if(!(!F||c)&&!W()){let t=e.touches?.[0];R(t?.clientX,t?.clientY)}},onClick:e=>{if(!c)if(F){if(W())return;R(e.clientX,e.clientY)}else y.current?.focus()},onMouseUp:()=>{!c&&W()&&U()},onTouchEnd:()=>{!c&&W()&&U()},children:[F&&typeof document<`u`?(0,le.createPortal)((0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`input`,{ref:de,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":p(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Z,display:L?`block`:`none`},onBlur:De,onBeforeInput:q,onCompositionStart:()=>{A.current=!0},onInput:Oe,onKeyDown:J,onKeyUp:ke,onCompositionEnd:Y,onPaste:X}),(0,w.jsx)(`textarea`,{ref:k,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":p(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Z,display:L?`none`:`block`},onBlur:De,onBeforeInput:q,onCompositionStart:()=>{A.current=!0},onInput:Oe,onKeyDown:J,onKeyUp:ke,onCompositionEnd:Y,onPaste:X})]}),document.body):null,te.current&&!c?(0,w.jsx)(v,{containerRef:te,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});O.displayName=`TerminalViewport`;var ue=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),k=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,de=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,A=/Serving HTTP on .*? port (\d{2,5})/i,j=new Set([`.`,`,`,`;`,`:`,`!`,`?`]),M=e=>{let t=e;for(;t.length>0;){let e=t[t.length-1];if(e===`)`||e===`]`||e===`}`||e===`>`){let n=e===`)`?`(`:e===`]`?`[`:e===`}`?`{`:`<`,r=t.slice(0,-1);if((r.match(RegExp(`\\${n}`,`g`))||[]).length>(r.match(RegExp(`\\${e}`,`g`))||[]).length)break;t=r;continue}if(j.has(e)){t=t.slice(0,-1);continue}break}return t},N=e=>{let t=M(e);return t=t.replace(`0.0.0.0`,`127.0.0.1`),t=t.replace(`[::1]`,`127.0.0.1`),t=t.replace(`[::]`,`127.0.0.1`),t},fe=e=>{if(!e)return null;let t=e.replace(ue,``),n=t.match(A);if(n?.[1]){let e=Number.parseInt(n[1],10);if(Number.isFinite(e)&&e>0&&e<=65535)return`http://127.0.0.1:${e}/`}let r=t.split(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t}from"./runtime-fetch-V-iMWR8t.js";import{F as n,s as r}from"./platform-CiUKDeXd.js";import{it as i,ot as a,st as o}from"./vendor-base-ui-wXsskyKm.js";import{f as s,p as c,r as l}from"./useUIStore-C3ewjGgP.js";import{s as u}from"./terminalApi-DXvEquBF.js";import{n as d,r as f,t as ee}from"./vendor-ghostty-web-DbBrwBII.js";import{i as p,o as m}from"./session-startup-barrier-DT-hIBRf.js";import{n as h}from"./Icon-DmykXZL1.js";import{Ja as g,f as te}from"./ui-ee2iN869.js";import{t as _}from"./i18n-DXc6czdR.js";import{t as v}from"./OverlayScrollbar-D6vmoMkQ.js";import{n as y}from"./useThemeSystem-BIXghnHj.js";import{r as ne}from"./device-EIfSfSWk.js";import{n as b}from"./useEffectiveDirectory-DiJBIfai.js";import{n as re}from"./useProjectRuntimeAPIs-tjGuODhu.js";import{t as ie}from"./sortable-tabs-strip-DmtfYPz0.js";import{n as x,t as S}from"./useFontPreferences-BiRBKhti.js";import{t as ae}from"./project-preview-BCtFY4Rg.js";import{n as oe}from"./projectActions-BPmI9_mW.js";var C=e(o(),1);function se(e){let{colors:t}=e,n=t.syntax.base;return{background:t.surface.background,foreground:n.foreground,cursor:t.interactive.cursor,cursorAccent:t.surface.background,selectionBackground:t.interactive.selection,selectionForeground:t.interactive.selectionForeground,selectionInactiveBackground:t.interactive.selection+`50`,black:t.surface.muted,red:t.status.error,green:t.status.success,yellow:t.status.warning,blue:n.function,magenta:n.keyword,cyan:n.type,white:n.foreground,brightBlack:n.comment,brightRed:t.status.error,brightGreen:t.status.success,brightYellow:t.status.warning,brightBlue:n.function,brightMagenta:n.keyword,brightCyan:n.type,brightWhite:t.surface.elevatedForeground}}function ce(e,t,n,r,i=!1){return{cursorBlink:!1,cursorStyle:`bar`,fontSize:t,lineHeight:1.15,fontFamily:`${e}, "JetBrainsMonoNL Nerd Font", "FiraCode Nerd Font", "Cascadia Code PL", "Fira Code", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", "Courier New", monospace`,allowTransparency:!1,theme:{background:n.background,foreground:n.foreground,cursor:n.cursor,cursorAccent:n.cursorAccent,selectionBackground:n.selectionBackground,selectionForeground:n.selectionForeground,black:n.black,red:n.red,green:n.green,yellow:n.yellow,blue:n.blue,magenta:n.magenta,cyan:n.cyan,white:n.white,brightBlack:n.brightBlack,brightRed:n.brightRed,brightGreen:n.brightGreen,brightYellow:n.brightYellow,brightBlue:n.brightBlue,brightMagenta:n.brightMagenta,brightCyan:n.brightCyan,brightWhite:n.brightWhite},scrollback:1e4,ghostty:r,disableStdin:i}}var le=e(i(),1),w=a(),T=null;function E(){return T||=f.load(),T}function D(e){if(typeof window>`u`)return null;let t=[e,...Array.from(e.querySelectorAll(`*`))],n=null;for(let e of t){let t=window.getComputedStyle(e).overflowY;if(t===`auto`||t===`scroll`){if(e.scrollHeight-e.clientHeight>2)return e;n||=e}}return n}var O=C.forwardRef(({sessionKey:e,chunks:t,onInput:n,onResize:r,theme:i,fontFamily:a,fontSize:o,className:s,enableTouchScroll:c,autoFocus:l=!0,isVisible:u=!0},f)=>{let{t:p}=_(),h=C.useRef(null),te=C.useRef(null),y=C.useRef(null),ne=C.useRef(null),b=C.useRef(n),re=C.useRef(r),ie=C.useRef(null),x=C.useRef(``),S=C.useRef(null),ae=C.useRef(!1),oe=C.useRef(null),se=C.useRef(!0),T=C.useRef(null),O=C.useRef(null),ue=C.useRef(0),k=C.useRef(null),de=C.useRef(null),A=C.useRef(!1),j=C.useRef(!1),M=C.useRef(null),N=C.useRef(null),fe=C.useRef(null),pe=C.useRef(``),me=C.useRef(null),P=C.useRef(!c),he=C.useRef(u),[,ge]=C.useReducer(e=>e+1,0),[_e,ve]=C.useReducer(e=>e+1,0);b.current=n,re.current=r;let ye=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),F=!!c;C.useEffect(()=>{if(!c){P.current=!0,he.current=u;return}!he.current&&u&&(P.current=!1),he.current=u},[c,u]);let be=C.useCallback(()=>{if(!F)return;let e=h.current,t=k.current;if(!e)return;let n=[];e.getAttribute(`contenteditable`)===`true`&&n.push(e),n.push(...Array.from(e.querySelectorAll(`[contenteditable="true"]`))),n.forEach(e=>{e.setAttribute(`data-terminal-disabled-contenteditable`,`true`),e.setAttribute(`contenteditable`,`false`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.setProperty(`user-select`,`none`),e.style.setProperty(`-webkit-user-select`,`none`)}),e.tabIndex=-1,e.removeAttribute(`role`),e.removeAttribute(`aria-multiline`),Array.from(e.querySelectorAll(`textarea`)).forEach(e=>{e.style.setProperty(`caret-color`,`transparent`),e.style.color=`transparent`,e.style.setProperty(`-webkit-text-fill-color`,`transparent`),e.style.background=`transparent`,e.style.border=`0`,e.style.outline=`none`,e.style.boxShadow=`none`,e.style.textShadow=`none`,e.style.fontSize=`0`,e.style.lineHeight=`0`,e!==t&&e.getAttribute(`data-terminal-disabled-input`)!==`true`&&(e.setAttribute(`data-terminal-disabled-input`,`true`),e.setAttribute(`aria-hidden`,`true`),e.tabIndex=-1,e.disabled=!0,e.style.position=`absolute`,e.style.opacity=`0`,e.style.width=`0px`,e.style.height=`0px`,e.style.pointerEvents=`none`,e.style.zIndex=`-1`)})},[F]),I=C.useCallback(e=>{if(me.current===e)return;let t=y.current;if(t)try{if(typeof t.setOption==`function`){t.setOption(`cursorBlink`,e),me.current=e;return}t.options&&(t.options.cursorBlink=e,me.current=e)}catch{}},[]),L=F&&ye,R=C.useCallback((e,t)=>{let n=L?de.current:k.current,r=h.current;if(!n||!r)return;let i=r.getBoundingClientRect(),a=typeof window<`u`?window.innerWidth:i.width,o=typeof window<`u`?window.innerHeight:i.height,s=i.left+i.width/2,c=i.top+i.height-12,l=typeof e==`number`?e:s,u=typeof t==`number`?t:c,d=Math.max(8,Math.min(a-8,l)),f=Math.max(8,Math.min(o-8,u));n.style.left=`${d}px`,n.style.top=`${f}px`,n.style.bottom=``,(n instanceof HTMLTextAreaElement||n instanceof HTMLInputElement)&&(n.disabled=!1,n.readOnly=!1,n.removeAttribute(`disabled`),n.removeAttribute(`readonly`));try{n.focus({preventScroll:!0})}catch{try{n.focus()}catch{}}},[L]),z=C.useCallback(()=>{if(F){R(),I(!0);return}y.current?.focus(),I(!0)},[R,I,F]),B=C.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),V=C.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),xe=C.useCallback(e=>{if(typeof window>`u`||L)return;fe.current!==null&&(window.clearTimeout(fe.current),fe.current=null);let t=0,n=()=>{fe.current=window.setTimeout(()=>{fe.current=null;let r=B(e);if(!r){if(t+=1,t<3){n();return}return}let i=pe.current;pe.current=r;let a=r.startsWith(i)?r.slice(i.length):r;a&&b.current(a.replace(/\r\n|\r|\n/g,`\r`)),V(e),pe.current=``},t===0?0:24)};n()},[V,B,L]);C.useEffect(()=>{let e=h.current;if(!F||!e||c)return;let t=t=>{let n=t.target;if(n&&n.getAttribute(`data-terminal-hidden-input`)!==`true`&&e.contains(n)){try{n.blur()}catch{}R()}};return e.addEventListener(`focusin`,t,!0),()=>{e.removeEventListener(`focusin`,t,!0)}},[c,F,R]);let Se=C.useCallback(()=>{let e=y.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),H=C.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=h.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),U=C.useCallback(async()=>{if(typeof document>`u`)return;let e=Se()||H();e.trim()&&await g(e)},[H,Se]),W=C.useCallback(()=>Se().trim()?!0:!!H().trim(),[H,Se]);C.useEffect(()=>{if(typeof window>`u`)return;let e=e=>{W()&&(e.preventDefault(),U())};return window.addEventListener(`yuri:copy`,e),()=>{window.removeEventListener(`yuri:copy`,e)}},[U,W]);let G=C.useCallback(()=>{x.current=``,S.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(S.current),S.current=null,ae.current=!1,oe.current=null},[]),K=C.useCallback(()=>{let e=ne.current,t=y.current,n=h.current;if(!e||!t||!n)return;let r=n.getBoundingClientRect();if(!(r.width<24||r.height<24))try{e.fit();let n={cols:t.cols,rows:t.rows},r=ie.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(ie.current=n,re.current(n.cols,n.rows))}catch{}},[]),Ce=C.useCallback(()=>{if(ae.current)return;let e=y.current;if(!e){G();return}if(!x.current)return;let t=x.current;x.current=``,ae.current=!0,e.write(t,()=>{ae.current=!1,x.current&&(typeof window<`u`?S.current=window.requestAnimationFrame(()=>{S.current=null,Ce()}):Ce())})},[G]),we=C.useCallback(()=>{S.current===null&&(typeof window<`u`?S.current=window.requestAnimationFrame(()=>{S.current=null,Ce()}):Ce())},[Ce]),Te=C.useCallback(e=>{e&&(x.current+=e,we())},[we]),Ee=C.useCallback(()=>{if(T.current?.(),T.current=null,O.current!==null&&typeof window<`u`&&(window.clearTimeout(O.current),O.current=null),!c){ue.current=0;return}let e=h.current;if(!e)return;let t=y.current;if(!t)return;ue.current=0;let n=2.2,r=2.8,i=.25,a=.05,s=.015,l={lastY:null,lastTime:null,velocity:0,rafId:null,startX:null,startY:null,didMove:!1},u=()=>typeof performance<`u`?performance.now():Date.now(),d=Math.max(12,Math.round(o*1.35)),f=0,ee=e=>{if(!e)return!1;let n=t.getViewportY(),r=f+e,i=Math.trunc(r/d);return f=r-i*d,i!==0&&t.scrollLines(i),t.getViewportY()!==n},p=()=>{l.rafId!==null&&typeof window<`u`&&window.cancelAnimationFrame(l.rafId),l.rafId=null},m={passive:!1,capture:!1};if(typeof window<`u`&&`PointerEvent`in window){let t=Object.assign(l,{pointerId:null,startX:null,startY:null,moved:!1}),o=n=>{if(n.pointerType===`touch`){p(),t.pointerId=n.pointerId,t.startX=n.clientX,t.startY=n.clientY,t.moved=!1,t.lastY=n.clientY,t.lastTime=u(),t.velocity=0;try{e.setPointerCapture(n.pointerId)}catch{}}},d=e=>{if(e.pointerType!==`touch`||t.pointerId!==e.pointerId)return;if(t.startX!==null&&t.startY!==null&&!t.moved){let n=e.clientX-t.startX,r=e.clientY-t.startY;Math.hypot(n,r)>=6&&(t.moved=!0)}if(t.lastY===null){t.lastY=e.clientY,t.lastTime=u();return}let a=t.lastY,o=t.lastTime??u(),s=u();t.lastY=e.clientY,t.lastTime=s;let c=a-e.clientY;if(Math.abs(c)<1)return;let l=Math.max(s-o,8),d=c*(n+Math.min(r,Math.abs(c)/25)),f=d/l;t.velocity=t.velocity*.75+f*i,t.velocity>8?t.velocity=8:t.velocity<-8&&(t.velocity=-8),t.moved&&(e.cancelable&&e.preventDefault(),e.stopPropagation()),ee(d)},f=n=>{if(n.pointerType!==`touch`||t.pointerId!==n.pointerId)return;let r=!t.moved;t.pointerId=null,t.startX=null,t.startY=null,t.moved=!1,t.lastY=null,t.lastTime=null;try{e.releasePointerCapture(n.pointerId)}catch{}if(r){F?R(n.clientX,n.clientY):c&&!P.current&&(P.current=!0,y.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(t.velocity)<a){t.velocity=0;return}let i=u(),o=()=>{let e=u(),n=Math.max(e-i,8);i=e;let r=ee(t.velocity*n)??!1,c=Math.sign(t.velocity),l=Math.max(0,Math.abs(t.velocity)-s*n);if(t.velocity=l*c,!r||l<=a){p(),t.velocity=0;return}t.rafId=window.requestAnimationFrame(o)};t.rafId=window.requestAnimationFrame(o)};e.addEventListener(`pointerdown`,o,m),e.addEventListener(`pointermove`,d,m),e.addEventListener(`pointerup`,f,m),e.addEventListener(`pointercancel`,f,m);let h=e.style.touchAction,g=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,T.current=()=>{p(),O.current!==null&&typeof window<`u`&&(window.clearTimeout(O.current),O.current=null),ue.current=0,e.removeEventListener(`pointerdown`,o,m),e.removeEventListener(`pointermove`,d,m),e.removeEventListener(`pointerup`,f,m),e.removeEventListener(`pointercancel`,f,m),e.style.touchAction=h,e.style.overscrollBehaviorY=g};return}let g=e=>{e.touches.length===1&&(p(),l.lastY=e.touches[0].clientY,l.lastTime=u(),l.velocity=0,l.startX=e.touches[0].clientX,l.startY=e.touches[0].clientY,l.didMove=!1)},te=e=>{if(e.touches.length!==1){l.lastY=null,l.lastTime=null,l.velocity=0,l.startX=null,l.startY=null,l.didMove=!1,p();return}let t=e.touches[0].clientX,a=e.touches[0].clientY;if(l.startX!==null&&l.startY!==null&&!l.didMove){let e=t-l.startX,n=a-l.startY;Math.hypot(e,n)>=6&&(l.didMove=!0)}if(l.lastY===null){l.lastY=a,l.lastTime=u();return}let o=l.lastY,s=l.lastTime??u(),c=u();l.lastY=a,l.lastTime=c;let d=o-a;if(Math.abs(d)<1)return;let f=Math.max(c-s,8),m=d*(n+Math.min(r,Math.abs(d)/25)),h=m/f;l.velocity=l.velocity*.75+h*i,l.velocity>8?l.velocity=8:l.velocity<-8&&(l.velocity=-8),l.didMove&&(e.preventDefault(),e.stopPropagation()),ee(m)},_=e=>{let t=!l.didMove;l.lastY=null,l.lastTime=null;let n=l.velocity;if(l.startX=null,l.startY=null,l.didMove=!1,t){let t=e.changedTouches?.[0];F?R(t?.clientX,t?.clientY):c&&!P.current&&(P.current=!0,y.current?.focus());return}if(typeof window>`u`)return;if(Math.abs(n)<a){l.velocity=0;return}let r=u(),i=()=>{let e=u(),t=Math.max(e-r,8);r=e;let n=ee(l.velocity*t)??!1,o=Math.sign(l.velocity),c=Math.max(0,Math.abs(l.velocity)-s*t);if(l.velocity=c*o,!n||c<=a){p(),l.velocity=0;return}l.rafId=window.requestAnimationFrame(i)};l.rafId=window.requestAnimationFrame(i)};e.addEventListener(`touchstart`,g,m),e.addEventListener(`touchmove`,te,m),e.addEventListener(`touchend`,_,m),e.addEventListener(`touchcancel`,_,m);let v=e.style.touchAction,ne=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,T.current=()=>{p(),O.current!==null&&typeof window<`u`&&(window.clearTimeout(O.current),O.current=null),ue.current=0,e.removeEventListener(`touchstart`,g,m),e.removeEventListener(`touchmove`,te,m),e.removeEventListener(`touchend`,_,m),e.removeEventListener(`touchcancel`,_,m),e.style.touchAction=v,e.style.overscrollBehaviorY=ne}},[c,F,R,o]);C.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,u=null,f=null,p=h.current;if(!p)return;if(p.tabIndex=F?-1:0,F){let e=p.focus.bind(p),t=p;t.focus=((...e)=>{R()}),f=()=>{t.focus=e}}let m=()=>{I(!0)},g=()=>{I(!1)},_=e=>{let t=e.target;if(t&&p.contains(t)){if(F&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur(),R()},0),I(!1);return}if(c&&!P.current&&t instanceof HTMLElement){window.setTimeout(()=>{t.blur()},0),I(!1);return}I(!0);return}I(!1)},v=()=>{I(!1)},re=null;return(async()=>{try{let f=await E();if(e)return;let h=ce(a,o,i,f,!1),_=new d(h);se.current=!0,F&&(_.focus=()=>{});let v=_;if(typeof v.scrollToBottom==`function`){let e=v.scrollToBottom.bind(v);v.scrollToBottom=()=>{se.current&&e()},l=()=>{v.scrollToBottom=e}}let ie=new ee;if(t=_,y.current=_,ne.current=ie,_.loadAddon(ie),_.open(p),c){let e=_.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},u=()=>{e.renderScrollbar=t}}}ve(),me.current=!1,re=_.textarea??p.querySelector(`textarea`),re&&(re.addEventListener(`focus`,m),re.addEventListener(`blur`,g)),be(),typeof MutationObserver<`u`&&(r=new MutationObserver(()=>{be()}),r.observe(p,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`contenteditable`,`role`,`tabindex`,`aria-label`]}));let x=D(p);x?(x.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),te.current=x,ge()):te.current=null,K();let S=ie;typeof S.observeResize==`function`&&S.observeResize(),Ee(),s=[_.onData(e=>{b.current(e)}),_.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof _.hasSelection==`function`&&_.hasSelection();se.current=!t&&e<=.5}}),_.onSelectionChange(()=>{if(typeof _.hasSelection==`function`&&_.hasSelection()){se.current=!1;return}let e=typeof _.getViewportY==`function`?_.getViewportY():0;se.current=e<=.5})],n=new ResizeObserver(()=>{K()}),n.observe(p),typeof window<`u`&&window.setTimeout(()=>{K()},0)}catch{}})(),document.addEventListener(`focusin`,_,!0),window.addEventListener(`blur`,v),()=>{e=!0,T.current?.(),T.current=null,document.removeEventListener(`focusin`,_,!0),window.removeEventListener(`blur`,v),s.forEach(e=>e.dispose()),l?.(),l=null,u?.(),u=null,re&&(re.removeEventListener(`focus`,m),re.removeEventListener(`blur`,g)),n?.disconnect(),r?.disconnect(),f?.(),t?.dispose(),y.current=null,ne.current=null,te.current=null,ie.current=null,me.current=null,G()}},[be,c,K,R,a,o,Ee,i,G,I,F]),C.useEffect(()=>{let e=y.current;e&&(e.reset(),G(),ie.current=null,K())},[e,_e,K,G]),C.useEffect(()=>{l&&y.current&&z()},[l,z,e,_e]),C.useEffect(()=>(Ee(),()=>{T.current?.(),T.current=null}),[Ee,e]),C.useEffect(()=>{let e=y.current;if(!e)return;if(t.length===0){oe.current!==null&&(e.reset(),G(),K());return}let n=oe.current,r;if(n===null)r=t;else{let e=t.findIndex(e=>e.id===n);r=e>=0?t.slice(e+1):t}r.length>0&&Te(r.map(e=>e.data).join(``)),oe.current=t[t.length-1].id},[t,_e,Te,K,G]),C.useImperativeHandle(f,()=>({focus:()=>{z()},clear:()=>{let e=y.current;e&&(e.reset(),G(),K())},fit:()=>{K()}}),[z,K,G]);let De=C.useCallback(e=>{if(!F)return;let t=h.current,n=e.relatedTarget,r=n?.tagName;r===`INPUT`||r===`TEXTAREA`||n?.isContentEditable,n?.getAttribute(`data-terminal-hidden-input`),n&&t?.contains(n)},[F]),q=C.useCallback(e=>{let t=e.nativeEvent,n=t?.inputType??``,r=typeof t?.data==`string`?t.data:``;if(N.current=typeof performance<`u`?performance.now():Date.now(),n===`insertCompositionText`){A.current=!0;return}if(!n&&r){if(A.current)return;e.preventDefault(),b.current(r),M.current={type:`insertText`,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0;return}if(n===`insertText`&&r){if(A.current)return;e.preventDefault(),b.current(r),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0;return}if(n===`insertLineBreak`){if(A.current)return;e.preventDefault(),b.current(`\r`),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0;return}if(n===`deleteContentBackward`){if(A.current)return;e.preventDefault(),b.current(``),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0}},[]),Oe=C.useCallback(e=>{let t=e.currentTarget;if(N.current=typeof performance<`u`?performance.now():Date.now(),A.current)return;if(j.current){let e=M.current,n=typeof performance<`u`?performance.now():Date.now();if(e&&n-e.at<50){j.current=!1,V(t);return}j.current=!1}let n=B(t);if(!n)return;pe.current=n;let r=n.replace(/\r\n|\r|\n/g,`\r`);b.current(r),V(t),pe.current=``},[V,B]),J=C.useCallback(e=>{e.stopPropagation();let t=e.key.toLowerCase(),n=e.metaKey&&!e.ctrlKey&&!e.altKey&&t===`c`,r=e.ctrlKey&&e.shiftKey&&!e.metaKey&&!e.altKey&&t===`c`;if((n||r)&&W()){e.preventDefault(),U();return}if(e.ctrlKey&&!e.metaKey&&!e.altKey&&e.key.length===1){let t=e.key.toUpperCase();if(t>=`A`&&t<=`Z`){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),b.current(String.fromCharCode(t.charCodeAt(0)-64)),V(e.currentTarget);return}}if(e.altKey&&!e.ctrlKey&&!e.metaKey&&e.key.length===1){e.preventDefault(),e.nativeEvent?.stopImmediatePropagation(),b.current(`\x1B`+e.key),V(e.currentTarget);return}let i={ArrowUp:`\x1B[A`,ArrowDown:`\x1B[B`,ArrowRight:`\x1B[C`,ArrowLeft:`\x1B[D`,Escape:`\x1B`,Tab:` `,Delete:`\x1B[3~`,Home:`\x1B[H`,End:`\x1B[F`}[e.key];if(i){e.preventDefault(),b.current(i),V(e.currentTarget);return}let a=e.currentTarget;if(e.nativeEvent?.isComposing)return;let o=M.current,s=typeof performance<`u`?performance.now():Date.now(),c=!!(o&&s-o.at<50);if(e.key===`Enter`){if(c&&o?.type===`insertLineBreak`)return;e.preventDefault(),b.current(`\r`),V(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;B(a)||b.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=N.current;t&&s-t<50||(e.preventDefault(),b.current(e.key),j.current=!0,M.current={type:`keydown-text`,at:s})}xe(a)},[V,U,W,B,xe]),ke=C.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||xe(t)},[xe]),Y=C.useCallback(e=>{let t=e.currentTarget;A.current=!1;let n=e.data||B(t);if(N.current=typeof performance<`u`?performance.now():Date.now(),!n)return;let r=n.replace(/\r\n|\r|\n/g,`\r`);b.current(r),V(t),M.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0},[V,B]),X=C.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=y.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;b.current(n)},[]),Z={position:`fixed`,left:0,top:0,width:1,height:1,opacity:0,zIndex:-1,background:`transparent`,color:`transparent`,WebkitTextFillColor:`transparent`,caretColor:`transparent`,textShadow:`none`,WebkitAppearance:`none`,appearance:`none`,resize:`none`,overflow:`hidden`,whiteSpace:`nowrap`,border:`0`,padding:0,margin:0,outline:`none`,outlineOffset:0,fontSize:16,fontWeight:400,pointerEvents:`none`,WebkitUserSelect:`none`,userSelect:`none`};return(0,w.jsxs)(`div`,{ref:h,className:m(`relative h-full w-full terminal-viewport-container`,s),"data-hidden-input-overlay-active":F?`true`:void 0,style:{backgroundColor:i.background},onTouchStart:e=>{if(!(!F||c)&&!W()){let t=e.touches?.[0];R(t?.clientX,t?.clientY)}},onClick:e=>{if(!c)if(F){if(W())return;R(e.clientX,e.clientY)}else y.current?.focus()},onMouseUp:()=>{!c&&W()&&U()},onTouchEnd:()=>{!c&&W()&&U()},children:[F&&typeof document<`u`?(0,le.createPortal)((0,w.jsxs)(w.Fragment,{children:[(0,w.jsx)(`input`,{ref:de,type:`text`,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":p(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Z,display:L?`block`:`none`},onBlur:De,onBeforeInput:q,onCompositionStart:()=>{A.current=!0},onInput:Oe,onKeyDown:J,onKeyUp:ke,onCompositionEnd:Y,onPaste:X}),(0,w.jsx)(`textarea`,{ref:k,inputMode:`text`,autoCapitalize:`off`,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,tabIndex:-1,enterKeyHint:`send`,"data-terminal-hidden-input":`true`,"aria-label":p(`terminalView.viewport.inputAria`),"aria-hidden":`true`,style:{...Z,display:L?`none`:`block`},onBlur:De,onBeforeInput:q,onCompositionStart:()=>{A.current=!0},onInput:Oe,onKeyDown:J,onKeyUp:ke,onCompositionEnd:Y,onPaste:X})]}),document.body):null,te.current&&!c?(0,w.jsx)(v,{containerRef:te,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});O.displayName=`TerminalViewport`;var ue=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),k=/(https?:\/\/(?:localhost|127\.0\.0\.1|0\.0\.0\.0|\[(?:::1|::)\])(?::\d{2,5})?(?:\/[^\s<>'"`]*)?)/gi,de=/(?:➜\s*(?:Local|Network):)|\b(?:local|network|loopback|serving|listening|available|ready|started|running|server|vite|webpack|next\.js|astro|sveltekit|nuxt)\b/i,A=/Serving HTTP on .*? port (\d{2,5})/i,j=new Set([`.`,`,`,`;`,`:`,`!`,`?`]),M=e=>{let t=e;for(;t.length>0;){let e=t[t.length-1];if(e===`)`||e===`]`||e===`}`||e===`>`){let n=e===`)`?`(`:e===`]`?`[`:e===`}`?`{`:`<`,r=t.slice(0,-1);if((r.match(RegExp(`\\${n}`,`g`))||[]).length>(r.match(RegExp(`\\${e}`,`g`))||[]).length)break;t=r;continue}if(j.has(e)){t=t.slice(0,-1);continue}break}return t},N=e=>{let t=M(e);return t=t.replace(`0.0.0.0`,`127.0.0.1`),t=t.replace(`[::1]`,`127.0.0.1`),t=t.replace(`[::]`,`127.0.0.1`),t},fe=e=>{if(!e)return null;let t=e.replace(ue,``),n=t.match(A);if(n?.[1]){let e=Number.parseInt(n[1],10);if(Number.isFinite(e)&&e>0&&e<=65535)return`http://127.0.0.1:${e}/`}let r=t.split(`
2
2
  `);for(let e of r){if(!de.test(e))continue;let t=Array.from(e.matchAll(k));if(t.length!==0)return N((t.find(e=>{try{return!!new URL(N(e[1])).port}catch{return!1}})??t[0])[1])}return null},pe=async(e,n=1500)=>{if(!e||typeof window>`u`)return!1;let r;try{r=new URL(e)}catch{return!1}if(r.protocol!==`http:`&&r.protocol!==`https:`)return!1;let i=r.hostname.toLowerCase();if(i!==`localhost`&&i!==`127.0.0.1`&&i!==`0.0.0.0`&&i!==`::1`&&i!==`::`)return!1;let a=new AbortController,o=window.setTimeout(()=>a.abort(),n);try{let e=await t(`/api/system/probe-url`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:r.toString()}),cache:`no-store`,signal:a.signal});return e.ok?(await e.json().catch(()=>null))?.ok===!0:!1}catch{return!1}finally{window.clearTimeout(o)}},me={esc:`\x1B`,tab:` `,enter:`\r`,"arrow-up":`\x1B[A`,"arrow-down":`\x1B[B`,"arrow-left":`\x1B[D`,"arrow-right":`\x1B[C`},P={ctrl:`5`,cmd:`3`},he={retry:{maxRetries:3,initialDelayMs:500,maxDelayMs:8e3},connectionTimeoutMs:1e4},ge={retry:{maxRetries:8,initialDelayMs:400,maxDelayMs:8e3},connectionTimeoutMs:15e3},_e=(e,t)=>{if(t)switch(e){case`arrow-up`:return`\u001b[1;${P[t]}A`;case`arrow-down`:return`\u001b[1;${P[t]}B`;case`arrow-right`:return`\u001b[1;${P[t]}C`;case`arrow-left`:return`\u001b[1;${P[t]}D`}return me[e]??null},ve=()=>{let{t:e}=_(),{terminal:t,runtime:i,projectScope:a}=re(),{currentTheme:o}=y(),{monoFont:d}=S(),f=l(e=>e.terminalFontSize),ee=l(e=>e.bottomTerminalHeight),g=l(e=>e.isBottomTerminalExpanded),{isMobile:v,isTablet:ce,hasTouchOnlyPointer:le}=ne(),T=v||ce,E=(T||le)&&i.platform===`web`,D=i.platform!==`vscode`,ue=l(e=>e.showTerminalQuickKeysOnDesktop),k=!n()&&(T||ue),de=te(e=>e.currentSessionId),A=te(e=>e.newSessionDraft),j=!!a||de!==null||A?.open===!0,M=b()??null??a?.location.directory??null,N=a?r({...a.location,directory:M??a.location.directory}):M,me=x(e=>e.sessions),P=x(e=>e.hasHydrated),ve=x(e=>e.ensureDirectory),ye=x(e=>e.createTab),F=x(e=>e.setActiveTab),be=x(e=>e.closeTab),I=C.useMemo(()=>a?async(e,n)=>{await be(e,n,t.close)}:be,[a,t,be]),L=x(e=>e.setTabSessionId),R=x(e=>e.setTabLifecycle),z=x(e=>e.setConnecting),B=x(e=>e.appendToBuffer),V=x(e=>e.setTabPreviewUrl),xe=x(e=>e.clearBuffer),Se=l(e=>e.openContextPreview),H=C.useMemo(()=>{if(N)return me.get(N)},[me,N]),U=C.useMemo(()=>H?D?H.activeTabId??H.tabs[0]?.id??null:H.tabs[0]?.id??null:null,[H,D]),W=C.useMemo(()=>{if(H)return U?H.tabs.find(e=>e.id===U)??H.tabs[0]:H.tabs[0]},[H,U]),G=C.useMemo(()=>(H?.tabs??[]).map(t=>({icon:(()=>{let e=t.iconKey?oe[t.iconKey]??`terminal`:`terminal`;return(0,w.jsx)(h,{name:e,className:`h-4 w-4`})})(),id:t.id,label:t.label,title:t.label,closeLabel:e(`terminalView.tabs.closeTabTitle`)})),[H?.tabs,e]),K=W?.terminalSessionId??null,Ce=W?.lifecycle??`idle`,we=W?.bufferChunks??[],Te=W?.isConnecting??!1,Ee=W?.previewUrl??null,[De,q]=C.useState(null),[Oe,J]=C.useState(!1),[ke,Y]=C.useState(!1),[X,Z]=C.useState(null),[Ae,je]=C.useState(!1),[Me,Ne]=C.useState(0),Pe=C.useRef(null),Fe=C.useRef(null),Ie=C.useRef(U),Le=C.useRef(K),Re=C.useRef(N),ze=C.useRef(null),Be=C.useRef(null),Ve=C.useRef(!1),He=C.useRef(!1),Ue=C.useRef(null),We=C.useRef(null),Ge=C.useRef(new Set),Ke=C.useRef(!1),qe=C.useRef(``),Je=C.useRef(new Set),Ye=C.useRef(0),Xe=C.useCallback(()=>{qe.current=``,Je.current.clear(),Ye.current+=1},[]),Ze=C.useCallback(()=>{E||typeof document<`u`&&!document.hasFocus()||ze.current?.focus()},[E]),Qe=C.useCallback(()=>{E||ze.current?.focus()},[E]);C.useEffect(()=>{if(!P||Ke.current)return;Ke.current=!0;let e=new Set;for(let[,t]of x.getState().sessions.entries())for(let n of t.tabs)n.terminalSessionId&&e.add(n.terminalSessionId);Ge.current=e},[P]);let $e=l(e=>e.activeMainTab),et=l(e=>e.isBottomTerminalOpen),tt=l(e=>e.setBottomTerminalOpen),nt=l(e=>e.setBottomTerminalExpanded),rt=$e===`terminal`,Q=rt||et,[it,at]=C.useState(Q);C.useEffect(()=>{!Q||i.platform===`vscode`||a||u()},[Q,i.platform,a]),C.useEffect(()=>{Q&&at(!0)},[Q]),C.useEffect(()=>{He.current=Q},[Q]),C.useEffect(()=>{Le.current=K},[K]),C.useEffect(()=>{Ie.current=U,Xe()},[U,Xe]),C.useEffect(()=>{Re.current=N},[N]),C.useEffect(()=>{!k&&X!==null&&Z(null)},[k,X,Z]),C.useEffect(()=>{!K&&X!==null&&Z(null)},[K,X,Z]);let $=C.useCallback(()=>{Pe.current?.(),Pe.current=null,Fe.current=null,Ue.current=null,Y(!1)},[]);C.useEffect(()=>()=>{$(),Le.current=null},[$]),C.useEffect(()=>($(),$),[t,$]);let ot=C.useCallback((e,t,n)=>{if(!n)return;let r=`${qe.current}${n}`.replace(/\r\n|\r/g,`
3
3
  `),i=r.split(`
4
4
  `),o=r.endsWith(`
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t}from"./platform-CiUKDeXd.js";import{a as n}from"./vendor-zustand-CTekDqaS.js";import{it as r,ot as i,st as a}from"./vendor-base-ui-wXsskyKm.js";import{E as o}from"./runtime-file-resource-Bc_ss-sW.js";import{r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{a as c,o as l,r as u}from"./useUIStore-C3ewjGgP.js";import{f as d,i as ee,o as f}from"./session-startup-barrier-DT-hIBRf.js";import{Dt as p,f as te}from"./ui-DrAJTWV6.js";import{t as ne}from"./i18n-DXc6czdR.js";import{n as re}from"./useEffectiveDirectory-BxolHzt4.js";import{s as m}from"./mobileBackNavigation-DF_uhF-i.js";import{i as h,n as g}from"./shortcuts-WkN3Gh8v.js";import{a as ie,c as _,l as v,s as ae,u as oe}from"./SessionSurfaceContext-BP4NCKp6.js";import{o as se}from"./useSessionBtwStore-BCHq3UOB.js";import{a as ce,i as y,r as le,t as b}from"./nativeComposerCover-DXFy97OQ.js";var x=e(a(),1),S=e(r(),1),C=(e,t)=>{if(!(t in e))return e;let n={...e};return delete n[t],n},w=n(e=>({quotesByKey:{},addQuote:(t,n)=>e(e=>{let r=e.quotesByKey[t]??_,i=v(r,n);return i===r?e:{quotesByKey:{...e.quotesByKey,[t]:i}}}),removeQuote:(t,n)=>e(e=>{let r=e.quotesByKey[t];if(!r||n<0||n>=r.length)return e;let i=r.filter((e,t)=>t!==n);return{quotesByKey:i.length===0?C(e.quotesByKey,t):{...e.quotesByKey,[t]:i}}}),removeLast:t=>e(e=>{let n=e.quotesByKey[t];if(!n||n.length===0)return e;let r=n.slice(0,-1);return{quotesByKey:r.length===0?C(e.quotesByKey,t):{...e.quotesByKey,[t]:r}}}),clear:t=>e(e=>({quotesByKey:C(e.quotesByKey,t)})),restore:(t,n)=>e(e=>n.length===0?{quotesByKey:C(e.quotesByKey,t)}:{quotesByKey:{...e.quotesByKey,[t]:n}})})),T=e=>t=>e?t.quotesByKey[e]??_:_,E=()=>{typeof window>`u`||window.requestAnimationFrame(()=>{document.querySelector(`[data-btw-composer] textarea`)?.focus()})},D=e=>{let t=e.directory??null;p({sessionId:e.sessionId,directory:t})?y(b):u.getState().openContextPanelTab(t??``,{mode:`btw`}),E()},O=e=>{let t=Number.isFinite(e.cssInsetPx)?Math.max(0,e.cssInsetPx):0,n=e.visualHeight,r=n==null||!Number.isFinite(n)?0:Math.max(0,e.innerHeight-n-(e.visualOffsetTop??0));return Math.max(t,r)},k=e=>{let t=Number.parseFloat(e??``);return Number.isFinite(t)?Math.max(0,t):0},A=48,j=88,M=e=>{let t=e.composer;if(t&&t.height>=A&&t.width>=A)return{left:t.left,top:t.top,width:t.width,height:t.height};let n=e.nativeComposerHeightPx>=A?e.nativeComposerHeightPx:e.lastHeightPx>=A?e.lastHeightPx:j,r=Math.max(0,e.keyboardOverlapPx);return{left:0,top:Math.max(0,e.viewportHeight-r-n),width:Math.max(0,e.viewportWidth),height:n}},N=i(),P=8,F=`mod+l`,I=`mod+shift+s`,L=[`⌃`,`⌥`,`⇧`,`⌘`],ue=e=>{let t=h(e).split(` + `);if(!d())return t.join(`+`);let n=t[t.length-1];return[...t.slice(0,-1).sort((e,t)=>L.indexOf(e)-L.indexOf(t)),n].join(``)},de=280,R=()=>{if(typeof document>`u`)return null;let e=null;for(let t of document.querySelectorAll(`.yuri-mobile-composer`)){let n=window.getComputedStyle(t);if(n.display===`none`||n.visibility===`hidden`)continue;let r=t.getBoundingClientRect();r.height<48||r.width<48||r.bottom<0||r.top>window.innerHeight||(!e||r.bottom>e.top+e.height)&&(e={left:r.left,top:r.top,width:r.width,height:r.height})}return e},fe=e=>{let t=document.documentElement,n=window.visualViewport;return M({composer:R(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,keyboardOverlapPx:O({cssInsetPx:k(t.style.getPropertyValue(`--yuri-keyboard-inset`)),innerHeight:window.innerHeight,visualHeight:n?.height,visualOffsetTop:n?.offsetTop}),nativeComposerHeightPx:k(t.style.getPropertyValue(m)),lastHeightPx:e})},z=null;l(()=>{typeof window<`u`&&!document.activeElement?.matches(`textarea[data-chat-input="true"]`)&&window.getSelection()?.removeAllRanges(),z?.()});var B=new Set(`address.article.aside.blockquote.dd.div.dl.dt.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hr.li.main.nav.ol.p.pre.section.table.ul`.split(`.`)),V=e=>e.replace(/\r\n?/g,`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t}from"./platform-CiUKDeXd.js";import{a as n}from"./vendor-zustand-CTekDqaS.js";import{it as r,ot as i,st as a}from"./vendor-base-ui-wXsskyKm.js";import{E as o}from"./runtime-file-resource-Bc_ss-sW.js";import{r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{a as c,o as l,r as u}from"./useUIStore-C3ewjGgP.js";import{f as d,i as ee,o as f}from"./session-startup-barrier-DT-hIBRf.js";import{Dt as p,f as te}from"./ui-ee2iN869.js";import{t as ne}from"./i18n-DXc6czdR.js";import{n as re}from"./useEffectiveDirectory-DiJBIfai.js";import{s as m}from"./mobileBackNavigation-C94n2eLT.js";import{i as h,n as g}from"./shortcuts-WkN3Gh8v.js";import{a as ie,c as _,l as v,s as ae,u as oe}from"./SessionSurfaceContext-BP4NCKp6.js";import{o as se}from"./useSessionBtwStore-CwvlMabN.js";import{a as ce,i as y,r as le,t as b}from"./nativeComposerCover-Bhv1EKPT.js";var x=e(a(),1),S=e(r(),1),C=(e,t)=>{if(!(t in e))return e;let n={...e};return delete n[t],n},w=n(e=>({quotesByKey:{},addQuote:(t,n)=>e(e=>{let r=e.quotesByKey[t]??_,i=v(r,n);return i===r?e:{quotesByKey:{...e.quotesByKey,[t]:i}}}),removeQuote:(t,n)=>e(e=>{let r=e.quotesByKey[t];if(!r||n<0||n>=r.length)return e;let i=r.filter((e,t)=>t!==n);return{quotesByKey:i.length===0?C(e.quotesByKey,t):{...e.quotesByKey,[t]:i}}}),removeLast:t=>e(e=>{let n=e.quotesByKey[t];if(!n||n.length===0)return e;let r=n.slice(0,-1);return{quotesByKey:r.length===0?C(e.quotesByKey,t):{...e.quotesByKey,[t]:r}}}),clear:t=>e(e=>({quotesByKey:C(e.quotesByKey,t)})),restore:(t,n)=>e(e=>n.length===0?{quotesByKey:C(e.quotesByKey,t)}:{quotesByKey:{...e.quotesByKey,[t]:n}})})),T=e=>t=>e?t.quotesByKey[e]??_:_,E=()=>{typeof window>`u`||window.requestAnimationFrame(()=>{document.querySelector(`[data-btw-composer] textarea`)?.focus()})},D=e=>{let t=e.directory??null;p({sessionId:e.sessionId,directory:t})?y(b):u.getState().openContextPanelTab(t??``,{mode:`btw`}),E()},O=e=>{let t=Number.isFinite(e.cssInsetPx)?Math.max(0,e.cssInsetPx):0,n=e.visualHeight,r=n==null||!Number.isFinite(n)?0:Math.max(0,e.innerHeight-n-(e.visualOffsetTop??0));return Math.max(t,r)},k=e=>{let t=Number.parseFloat(e??``);return Number.isFinite(t)?Math.max(0,t):0},A=48,j=88,M=e=>{let t=e.composer;if(t&&t.height>=A&&t.width>=A)return{left:t.left,top:t.top,width:t.width,height:t.height};let n=e.nativeComposerHeightPx>=A?e.nativeComposerHeightPx:e.lastHeightPx>=A?e.lastHeightPx:j,r=Math.max(0,e.keyboardOverlapPx);return{left:0,top:Math.max(0,e.viewportHeight-r-n),width:Math.max(0,e.viewportWidth),height:n}},N=i(),P=8,F=`mod+l`,I=`mod+shift+s`,L=[`⌃`,`⌥`,`⇧`,`⌘`],ue=e=>{let t=h(e).split(` + `);if(!d())return t.join(`+`);let n=t[t.length-1];return[...t.slice(0,-1).sort((e,t)=>L.indexOf(e)-L.indexOf(t)),n].join(``)},de=280,R=()=>{if(typeof document>`u`)return null;let e=null;for(let t of document.querySelectorAll(`.yuri-mobile-composer`)){let n=window.getComputedStyle(t);if(n.display===`none`||n.visibility===`hidden`)continue;let r=t.getBoundingClientRect();r.height<48||r.width<48||r.bottom<0||r.top>window.innerHeight||(!e||r.bottom>e.top+e.height)&&(e={left:r.left,top:r.top,width:r.width,height:r.height})}return e},fe=e=>{let t=document.documentElement,n=window.visualViewport;return M({composer:R(),viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,keyboardOverlapPx:O({cssInsetPx:k(t.style.getPropertyValue(`--yuri-keyboard-inset`)),innerHeight:window.innerHeight,visualHeight:n?.height,visualOffsetTop:n?.offsetTop}),nativeComposerHeightPx:k(t.style.getPropertyValue(m)),lastHeightPx:e})},z=null;l(()=>{typeof window<`u`&&!document.activeElement?.matches(`textarea[data-chat-input="true"]`)&&window.getSelection()?.removeAllRanges(),z?.()});var B=new Set(`address.article.aside.blockquote.dd.div.dl.dt.fieldset.figcaption.figure.footer.form.h1.h2.h3.h4.h5.h6.header.hr.li.main.nav.ol.p.pre.section.table.ul`.split(`.`)),V=e=>e.replace(/\r\n?/g,`
2
2
  `),H=e=>V(e).trim(),U=(e,t)=>{if(e.contains(t))return!0;let n=t instanceof ShadowRoot?t:t.getRootNode();return n instanceof ShadowRoot&&e.contains(n.host)},W=e=>{let t=[],n=e=>{for(let r of e.querySelectorAll(`*`))r.shadowRoot&&(t.push(r.shadowRoot),n(r.shadowRoot))};return n(e),t},G=(e,t)=>{let n=W(t),r=e.getComposedRanges?.({shadowRoots:n})[0];if(r){let e=document.createRange();if(e.setStart(r.startContainer,r.startOffset),e.setEnd(r.endContainer,r.endOffset),U(t,e.commonAncestorContainer))return e}if(e.rangeCount===0)return null;let i=e.getRangeAt(0);return U(t,i.commonAncestorContainer)?i:null},K=e=>e.replace(/\s+/g,` `).trim(),q=e=>{if(e.nodeType===Node.TEXT_NODE)return K(e.textContent||``);if(e.nodeType!==Node.ELEMENT_NODE)return``;let t=e,n=t.tagName.toLowerCase(),r=Array.from(t.childNodes).map(e=>q(e)).join(``).replace(/\s+/g,` `).trim();if(!r&&n!==`br`)return``;if(n===`br`)return`
3
3
  `;if(n===`strong`||n===`b`)return`**${r}**`;if(n===`em`||n===`i`)return`*${r}*`;if(n===`code`)return`\`${r.replace(/`/g,"\\`")}\``;if(n===`a`){let e=t.getAttribute(`href`);return e?`[${r}](${e})`:r}return r},J=(e,t)=>Array.from(e.children).filter(e=>e instanceof HTMLElement&&e.tagName.toLowerCase()===`li`).map((e,n)=>{let r=t?`${n+1}. `:`- `,i=Array.from(e.childNodes).map(e=>q(e)).join(``).replace(/\s+/g,` `).trim();return i?`${r}${i}`:``}).filter(Boolean).join(`
4
4
  `),Y=e=>{if(e.nodeType===Node.TEXT_NODE)return H(e.textContent||``);if(e.nodeType!==Node.ELEMENT_NODE)return``;let t=e,n=t.tagName.toLowerCase();if(n===`pre`){let e=t.querySelector(`code`);return`\`\`\`${((e?.className||``).match(/language-([\w-]+)/)?.[1]||``).trim()}\n${V(e?.textContent||t.textContent||``).replace(/\n$/,``)}\n\`\`\``}if(n===`code`){let e=V(t.textContent||``).trim();return e?`\`${e.replace(/`/g,"\\`")}\``:``}if(n===`ul`)return J(t,!1);if(n===`ol`)return J(t,!0);if(n===`blockquote`)return H(Array.from(t.childNodes).map(e=>Y(e)).join(`
@@ -1,4 +1,4 @@
1
- import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{_ as n,t as r,v as i,w as a}from"./runtime-auth-DA-qfGHk.js";import{c as o,i as s}from"./runtime-switch-DEPKHgdL.js";import{n as c}from"./runtime-fetch-V-iMWR8t.js";import{R as l,n as u}from"./platform-CiUKDeXd.js";import{t as d}from"./runtimeAPIRegistry-C2VogTny.js";import{it as f,ot as p,st as m}from"./vendor-base-ui-wXsskyKm.js";import{n as h}from"./vendor-react-BkccXcWz.js";import{s as g}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as _,c as v,f as y,o as b,s as x}from"./runtime-file-resource-Bc_ss-sW.js";import{r as S}from"./vendor-reactuses-core-DjKFMfz7.js";import{a as C,n as w}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{S as T,x as E}from"./useUIStore-C3ewjGgP.js";import{n as D,t as O}from"./runtime-file-download-BWeoSXRb.js";import{n as k,t as A}from"./vendor-pierre-diffs-B0OmIhMO.js";import{i as j,o as M}from"./session-startup-barrier-DT-hIBRf.js";import{n as N}from"./Icon-DmykXZL1.js";import{t as P}from"./i18n-DXc6czdR.js";import{a as F,n as I,r as L}from"./toolHelpers-iEHVHQ9p.js";import{l as R,o as ee,s as te,u as ne}from"./vendor-framer-motion-D5NyyC73.js";import{t as z}from"./MobileWindowStack-DGLdgoGr.js";import{t as re}from"./vendor-tanstack-react-virtual-qsd3nvZb.js";import{n as ie,t as ae}from"./dialog-BeFBA6ja.js";import{t as oe}from"./tap-LkQum5bB.js";import{n as se,t as ce}from"./useThemeSystem-BIXghnHj.js";import{t as B}from"./appThemeRegistry-BdjrGBQ4.js";import{r as le}from"./themes-BgDJcxRc.js";import{n as ue}from"./useEffectiveDirectory-BxolHzt4.js";import{n as de}from"./mobileBackNavigation-DF_uhF-i.js";import{t as fe}from"./ImageLoadingPlaceholder-DgM_EFHn.js";import{n as V,r as pe}from"./MarkdownRenderer-D7p9Iflj.js";import{a as H,c as me,i as U,o as W}from"./imageSource-BR4C9TuS.js";import{n as G}from"./markdownTheme-D84XyNiT.js";import{n as K,t as he}from"./markdown-worker-oBGEB9Eg.js";import{t as ge}from"./DiffViewToggle-BwJ6MYB7.js";import{t as _e}from"./touch-gestures-DOoBxhz5.js";var q=t(m(),1),J=h(),Y=p(),X=e=>e===`in_progress`||e===`completed`||e===`cancelled`?e:`pending`,Z=e=>e.status===`completed`||e.status===`cancelled`,ve={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},ye={in_progress:`text-foreground`,pending:`text-muted-foreground/60`,completed:`text-muted-foreground`,cancelled:`text-muted-foreground/60`},be={in_progress:`text-foreground`,pending:`text-muted-foreground`,completed:`text-muted-foreground/60 line-through decoration-1`,cancelled:`text-muted-foreground/60 line-through decoration-1`},xe=1.2,Se=24,Ce=`1 1`,we=e=>{let t=(0,J.c)(23),{status:n,className:r}=e,{t:i}=P(),a=ve[n],o;t[0]!==i||t[1]!==a?(o=i(a),t[0]=i,t[1]=a,t[2]=o):o=t[2];let s=ye[n],c;t[3]!==r||t[4]!==s?(c=M(`size-[1em] shrink-0 transition-colors duration-300`,s,r),t[3]=r,t[4]=s,t[5]=c):c=t[5];let l=n===`pending`?xe:void 0,u=n===`pending`?Se:void 0,d=n===`pending`?Ce:void 0,f;t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Y.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6.5`,stroke:`currentColor`,strokeWidth:l,pathLength:u,strokeDasharray:d}),t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9];let p;t[10]===n?p=t[11]:(p=n===`in_progress`?(0,Y.jsx)(`path`,{d:`M4.8 8h6.4M8.6 5.4 11.2 8l-2.6 2.6`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}):null,t[10]=n,t[11]=p);let m;t[12]===n?m=t[13]:(m=n===`completed`?(0,Y.jsx)(`path`,{d:`M5 8 7.5 11 11 5.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}):null,t[12]=n,t[13]=m);let h;t[14]===n?h=t[15]:(h=n===`cancelled`?(0,Y.jsx)(`path`,{d:`M3.5 12.5 12.5 3.5`,stroke:`currentColor`}):null,t[14]=n,t[15]=h);let g;return t[16]!==m||t[17]!==h||t[18]!==o||t[19]!==c||t[20]!==f||t[21]!==p?(g=(0,Y.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,role:`img`,"aria-label":o,className:c,children:[f,p,m,h]}),t[16]=m,t[17]=h,t[18]=o,t[19]=c,t[20]=f,t[21]=p,t[22]=g):g=t[22],g},Te=3.2,Ee=e=>{let t=Math.PI*2*e,n=8+Te*Math.sin(t),r=8-Te*Math.cos(t);return`M8 8 L8 4.8 A${Te} ${Te} 0 ${+(e>.5)} 1 ${n.toFixed(3)} ${r.toFixed(3)} Z`},De=e=>{let t=(0,J.c)(11),{done:n,total:r,spinning:i,className:a}=e,o=n===void 0?0:n,s=r===void 0?0:r,c=i!==void 0&&i,l=s>0?Math.min(1,o/s):0,u;t[0]===a?u=t[1]:(u=M(`size-[1.15em] shrink-0 text-foreground`,a),t[0]=a,t[1]=u);let d=c?`yuri-todo-spin`:void 0,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f={transformBox:`fill-box`,transformOrigin:`center`},t[2]=f):f=t[2];let p;t[3]===d?p=t[4]:(p=(0,Y.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6.5`,stroke:`currentColor`,strokeWidth:xe,pathLength:Se,strokeDasharray:Ce,className:d,style:f}),t[3]=d,t[4]=p);let m;t[5]===l?m=t[6]:(m=l>0?(0,Y.jsx)(`path`,{d:Ee(l),fill:`currentColor`,className:`transition-opacity duration-300`}):null,t[5]=l,t[6]=m);let h;return t[7]!==u||t[8]!==p||t[9]!==m?(h=(0,Y.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:u,children:[p,m]}),t[7]=u,t[8]=p,t[9]=m,t[10]=h):h=t[10],h},Oe=({done:e,total:t,className:n,animate:r=!0})=>{let i=q.useRef(e),a=r&&i.current!==e;return q.useEffect(()=>{i.current=e},[e]),(0,Y.jsxs)(`span`,{className:M(`shrink-0 tabular-nums`,n),children:[(0,Y.jsx)(`span`,{className:M(a&&`yuri-todo-count-tick`),children:e},e),`/${t}`]})},ke=e=>{let t=(0,J.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=M(`flex size-[1.15em] shrink-0 items-center justify-center rounded-full bg-[var(--status-success)] text-[var(--status-success-foreground)]`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Y.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:`size-[70%]`,children:(0,Y.jsx)(`path`,{d:`M4.5 8.2 7 10.8 11.5 5.5`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})}),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,Y.jsx)(`span`,{"data-todo-complete":!0,className:r,children:i}),t[3]=r,t[4]=a),a},Ae=e=>{let t=(0,J.c)(27),{todos:n,isWorking:r,animate:i,className:a,rowClassName:o,listRef:s,id:c}=e,l=r!==void 0&&r,u=i!==void 0&&i,{t:d}=P(),f=n.findIndex(je),p;t[0]!==f||t[1]!==n?(p=f>=0?f:n.findIndex(Me),t[0]=f,t[1]=n,t[2]=p):p=t[2];let m=p,h;t[3]===n?h=t[4]:(h=n.some(Ne),t[3]=n,t[4]=h);let g=h,_;t[5]===a?_=t[6]:(_=M(`m-0 flex min-w-0 list-none flex-col gap-[0.125em] p-0`,a),t[5]=a,t[6]=_);let v;if(t[7]!==m||t[8]!==u||t[9]!==g||t[10]!==l||t[11]!==o||t[12]!==d||t[13]!==n){let e;t[15]!==m||t[16]!==u||t[17]!==g||t[18]!==l||t[19]!==o||t[20]!==d?(e=(e,t)=>{let n=X(e.status),r=l&&!g&&t===m&&n===`pending`?`in_progress`:n;return(0,Y.jsxs)(`li`,{"data-status":r,"aria-current":t===m?`step`:void 0,className:M(`grid min-w-0 shrink-0 grid-cols-[auto_minmax(0,1fr)] items-start py-[0.25em]`,o??`gap-[0.6em] px-[0.5em]`,u&&`yuri-todo-row-in`),children:[(0,Y.jsx)(`span`,{className:M(`flex h-[1.32em] w-[1.15em] items-center justify-center`,u&&`yuri-todo-icon-pop`),title:d(ve[r]),children:(0,Y.jsx)(we,{status:r})},r),(0,Y.jsx)(`span`,{dir:`auto`,title:e.content,className:M(`line-clamp-3 min-w-0 whitespace-normal text-[0.88em] break-words leading-[1.5] transition-colors duration-300`,be[r]),children:(0,Y.jsx)(`span`,{className:M(r===`in_progress`&&`animate-text-shimmer`),children:e.content})})]},e.id??`${t}:${e.content}`)},t[15]=m,t[16]=u,t[17]=g,t[18]=l,t[19]=o,t[20]=d,t[21]=e):e=t[21],v=n.map(e),t[7]=m,t[8]=u,t[9]=g,t[10]=l,t[11]=o,t[12]=d,t[13]=n,t[14]=v}else v=t[14];let y;return t[22]!==c||t[23]!==s||t[24]!==_||t[25]!==v?(y=(0,Y.jsx)(`ul`,{id:c,ref:s,className:_,children:v}),t[22]=c,t[23]=s,t[24]=_,t[25]=v,t[26]=y):y=t[26],y};function je(e){return e.status===`in_progress`}function Me(e){return e.status===`pending`}function Ne(e){return e.status===`in_progress`}var Pe=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),Fe=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,Ie=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=Fe(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},Le=e=>`<pre><code>${Pe(e)}</code></pre>`,Re=e=>{let t=(0,J.c)(21),{code:n,language:r,className:i,style:a,codeStyle:o,wrap:s}=e,c=s!==void 0&&s,{currentTheme:l}=se(),u=q.useRef(null),d;t[0]===l?d=t[1]:(d=G(l),t[0]=l,t[1]=d);let f=d,p,m;t[2]!==n||t[3]!==o||t[4]!==c?(p=()=>{let e=u.current;e&&(e.innerHTML=Le(n),Ie(e,c,o))},m=[n,c,o],t[2]=n,t[3]=o,t[4]=c,t[5]=p,t[6]=m):(p=t[5],m=t[6]),q.useLayoutEffect(p,m);let h,g;t[7]!==n||t[8]!==o||t[9]!==r||t[10]!==c?(h=()=>{let e=u.current;if(!e)return;let t=!0,i=new AbortController;return he(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,Ie(e,c,o))}),()=>{t=!1,i.abort()}},g=[n,r,c,o],t[7]=n,t[8]=o,t[9]=r,t[10]=c,t[11]=h,t[12]=g):(h=t[11],g=t[12]),q.useEffect(h,g);let _;t[13]===i?_=t[14]:(_=M(`typography-code`,i),t[13]=i,t[14]=_);let v=f,y;t[15]!==a||t[16]!==v?(y={...v,...a},t[15]=a,t[16]=v,t[17]=y):y=t[17];let b;return t[18]!==_||t[19]!==y?(b=(0,Y.jsx)(`div`,{ref:u,className:_,style:y}),t[18]=_,t[19]=y,t[20]=b):b=t[20],b},ze=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},Be=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},Ve=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,He=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,Ue=(e,t)=>!e||typeof e!=`object`?String(e):L(e,t||``),We=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},Ge=e=>{if(!e||typeof e!=`object`)return;let t=We(e.patch)??We(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=We(e.patch)??We(e.diff);if(t)return t}},Ke=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},qe=(e,t,n)=>{let r=ze(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&Ve(r)&&(r=He(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=Ge(n);if(e)return e}return r},Je=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
1
+ import{n as e,r as t}from"./rolldown-runtime-hePW80VL.js";import{_ as n,t as r,v as i,w as a}from"./runtime-auth-DA-qfGHk.js";import{c as o,i as s}from"./runtime-switch-DEPKHgdL.js";import{n as c}from"./runtime-fetch-V-iMWR8t.js";import{R as l,n as u}from"./platform-CiUKDeXd.js";import{t as d}from"./runtimeAPIRegistry-C2VogTny.js";import{it as f,ot as p,st as m}from"./vendor-base-ui-wXsskyKm.js";import{n as h}from"./vendor-react-BkccXcWz.js";import{s as g}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as _,c as v,f as y,o as b,s as x}from"./runtime-file-resource-Bc_ss-sW.js";import{r as S}from"./vendor-reactuses-core-DjKFMfz7.js";import{a as C,n as w}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{S as T,x as E}from"./useUIStore-C3ewjGgP.js";import{n as D,t as O}from"./runtime-file-download-BWeoSXRb.js";import{n as k,t as A}from"./vendor-pierre-diffs-B0OmIhMO.js";import{i as j,o as M}from"./session-startup-barrier-DT-hIBRf.js";import{n as N}from"./Icon-DmykXZL1.js";import{t as P}from"./i18n-DXc6czdR.js";import{a as F,n as I,r as L}from"./toolHelpers-iEHVHQ9p.js";import{l as R,o as ee,s as te,u as ne}from"./vendor-framer-motion-D5NyyC73.js";import{t as z}from"./MobileWindowStack-DGLdgoGr.js";import{t as re}from"./vendor-tanstack-react-virtual-qsd3nvZb.js";import{n as ie,t as ae}from"./dialog-BeFBA6ja.js";import{t as oe}from"./tap-LkQum5bB.js";import{n as se,t as ce}from"./useThemeSystem-BIXghnHj.js";import{t as B}from"./appThemeRegistry-BdjrGBQ4.js";import{r as le}from"./themes-BgDJcxRc.js";import{n as ue}from"./useEffectiveDirectory-DiJBIfai.js";import{n as de}from"./mobileBackNavigation-C94n2eLT.js";import{t as fe}from"./ImageLoadingPlaceholder-DgM_EFHn.js";import{n as V,r as pe}from"./MarkdownRenderer-VvziwyJB.js";import{a as H,c as me,i as U,o as W}from"./imageSource-BR4C9TuS.js";import{n as G}from"./markdownTheme-D84XyNiT.js";import{n as K,t as he}from"./markdown-worker-oBGEB9Eg.js";import{t as ge}from"./DiffViewToggle-BwJ6MYB7.js";import{t as _e}from"./touch-gestures-DOoBxhz5.js";var q=t(m(),1),J=h(),Y=p(),X=e=>e===`in_progress`||e===`completed`||e===`cancelled`?e:`pending`,Z=e=>e.status===`completed`||e.status===`cancelled`,ve={in_progress:`chat.statusRow.todo.status.inProgress`,pending:`chat.statusRow.todo.status.pending`,completed:`chat.statusRow.todo.status.completed`,cancelled:`chat.statusRow.todo.status.cancelled`},ye={in_progress:`text-foreground`,pending:`text-muted-foreground/60`,completed:`text-muted-foreground`,cancelled:`text-muted-foreground/60`},be={in_progress:`text-foreground`,pending:`text-muted-foreground`,completed:`text-muted-foreground/60 line-through decoration-1`,cancelled:`text-muted-foreground/60 line-through decoration-1`},xe=1.2,Se=24,Ce=`1 1`,we=e=>{let t=(0,J.c)(23),{status:n,className:r}=e,{t:i}=P(),a=ve[n],o;t[0]!==i||t[1]!==a?(o=i(a),t[0]=i,t[1]=a,t[2]=o):o=t[2];let s=ye[n],c;t[3]!==r||t[4]!==s?(c=M(`size-[1em] shrink-0 transition-colors duration-300`,s,r),t[3]=r,t[4]=s,t[5]=c):c=t[5];let l=n===`pending`?xe:void 0,u=n===`pending`?Se:void 0,d=n===`pending`?Ce:void 0,f;t[6]!==l||t[7]!==u||t[8]!==d?(f=(0,Y.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6.5`,stroke:`currentColor`,strokeWidth:l,pathLength:u,strokeDasharray:d}),t[6]=l,t[7]=u,t[8]=d,t[9]=f):f=t[9];let p;t[10]===n?p=t[11]:(p=n===`in_progress`?(0,Y.jsx)(`path`,{d:`M4.8 8h6.4M8.6 5.4 11.2 8l-2.6 2.6`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}):null,t[10]=n,t[11]=p);let m;t[12]===n?m=t[13]:(m=n===`completed`?(0,Y.jsx)(`path`,{d:`M5 8 7.5 11 11 5.5`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`}):null,t[12]=n,t[13]=m);let h;t[14]===n?h=t[15]:(h=n===`cancelled`?(0,Y.jsx)(`path`,{d:`M3.5 12.5 12.5 3.5`,stroke:`currentColor`}):null,t[14]=n,t[15]=h);let g;return t[16]!==m||t[17]!==h||t[18]!==o||t[19]!==c||t[20]!==f||t[21]!==p?(g=(0,Y.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,role:`img`,"aria-label":o,className:c,children:[f,p,m,h]}),t[16]=m,t[17]=h,t[18]=o,t[19]=c,t[20]=f,t[21]=p,t[22]=g):g=t[22],g},Te=3.2,Ee=e=>{let t=Math.PI*2*e,n=8+Te*Math.sin(t),r=8-Te*Math.cos(t);return`M8 8 L8 4.8 A${Te} ${Te} 0 ${+(e>.5)} 1 ${n.toFixed(3)} ${r.toFixed(3)} Z`},De=e=>{let t=(0,J.c)(11),{done:n,total:r,spinning:i,className:a}=e,o=n===void 0?0:n,s=r===void 0?0:r,c=i!==void 0&&i,l=s>0?Math.min(1,o/s):0,u;t[0]===a?u=t[1]:(u=M(`size-[1.15em] shrink-0 text-foreground`,a),t[0]=a,t[1]=u);let d=c?`yuri-todo-spin`:void 0,f;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(f={transformBox:`fill-box`,transformOrigin:`center`},t[2]=f):f=t[2];let p;t[3]===d?p=t[4]:(p=(0,Y.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6.5`,stroke:`currentColor`,strokeWidth:xe,pathLength:Se,strokeDasharray:Ce,className:d,style:f}),t[3]=d,t[4]=p);let m;t[5]===l?m=t[6]:(m=l>0?(0,Y.jsx)(`path`,{d:Ee(l),fill:`currentColor`,className:`transition-opacity duration-300`}):null,t[5]=l,t[6]=m);let h;return t[7]!==u||t[8]!==p||t[9]!==m?(h=(0,Y.jsxs)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:u,children:[p,m]}),t[7]=u,t[8]=p,t[9]=m,t[10]=h):h=t[10],h},Oe=({done:e,total:t,className:n,animate:r=!0})=>{let i=q.useRef(e),a=r&&i.current!==e;return q.useEffect(()=>{i.current=e},[e]),(0,Y.jsxs)(`span`,{className:M(`shrink-0 tabular-nums`,n),children:[(0,Y.jsx)(`span`,{className:M(a&&`yuri-todo-count-tick`),children:e},e),`/${t}`]})},ke=e=>{let t=(0,J.c)(5),{className:n}=e,r;t[0]===n?r=t[1]:(r=M(`flex size-[1.15em] shrink-0 items-center justify-center rounded-full bg-[var(--status-success)] text-[var(--status-success-foreground)]`,n),t[0]=n,t[1]=r);let i;t[2]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,Y.jsx)(`svg`,{viewBox:`0 0 16 16`,fill:`none`,"aria-hidden":`true`,className:`size-[70%]`,children:(0,Y.jsx)(`path`,{d:`M4.5 8.2 7 10.8 11.5 5.5`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})}),t[2]=i):i=t[2];let a;return t[3]===r?a=t[4]:(a=(0,Y.jsx)(`span`,{"data-todo-complete":!0,className:r,children:i}),t[3]=r,t[4]=a),a},Ae=e=>{let t=(0,J.c)(27),{todos:n,isWorking:r,animate:i,className:a,rowClassName:o,listRef:s,id:c}=e,l=r!==void 0&&r,u=i!==void 0&&i,{t:d}=P(),f=n.findIndex(je),p;t[0]!==f||t[1]!==n?(p=f>=0?f:n.findIndex(Me),t[0]=f,t[1]=n,t[2]=p):p=t[2];let m=p,h;t[3]===n?h=t[4]:(h=n.some(Ne),t[3]=n,t[4]=h);let g=h,_;t[5]===a?_=t[6]:(_=M(`m-0 flex min-w-0 list-none flex-col gap-[0.125em] p-0`,a),t[5]=a,t[6]=_);let v;if(t[7]!==m||t[8]!==u||t[9]!==g||t[10]!==l||t[11]!==o||t[12]!==d||t[13]!==n){let e;t[15]!==m||t[16]!==u||t[17]!==g||t[18]!==l||t[19]!==o||t[20]!==d?(e=(e,t)=>{let n=X(e.status),r=l&&!g&&t===m&&n===`pending`?`in_progress`:n;return(0,Y.jsxs)(`li`,{"data-status":r,"aria-current":t===m?`step`:void 0,className:M(`grid min-w-0 shrink-0 grid-cols-[auto_minmax(0,1fr)] items-start py-[0.25em]`,o??`gap-[0.6em] px-[0.5em]`,u&&`yuri-todo-row-in`),children:[(0,Y.jsx)(`span`,{className:M(`flex h-[1.32em] w-[1.15em] items-center justify-center`,u&&`yuri-todo-icon-pop`),title:d(ve[r]),children:(0,Y.jsx)(we,{status:r})},r),(0,Y.jsx)(`span`,{dir:`auto`,title:e.content,className:M(`line-clamp-3 min-w-0 whitespace-normal text-[0.88em] break-words leading-[1.5] transition-colors duration-300`,be[r]),children:(0,Y.jsx)(`span`,{className:M(r===`in_progress`&&`animate-text-shimmer`),children:e.content})})]},e.id??`${t}:${e.content}`)},t[15]=m,t[16]=u,t[17]=g,t[18]=l,t[19]=o,t[20]=d,t[21]=e):e=t[21],v=n.map(e),t[7]=m,t[8]=u,t[9]=g,t[10]=l,t[11]=o,t[12]=d,t[13]=n,t[14]=v}else v=t[14];let y;return t[22]!==c||t[23]!==s||t[24]!==_||t[25]!==v?(y=(0,Y.jsx)(`ul`,{id:c,ref:s,className:_,children:v}),t[22]=c,t[23]=s,t[24]=_,t[25]=v,t[26]=y):y=t[26],y};function je(e){return e.status===`in_progress`}function Me(e){return e.status===`pending`}function Ne(e){return e.status===`in_progress`}var Pe=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`).replace(/"/g,`&quot;`).replace(/'/g,`&#39;`),Fe=e=>e?Object.entries(e).map(([e,t])=>t==null?``:`${e.startsWith(`--`)?e:e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}:${typeof t==`number`?`${t}px`:t};`).join(``):``,Ie=(e,t,n)=>{let r=e.querySelector(`pre`);r&&(r.style.margin=`0`,r.style.background=`transparent`,r.style.whiteSpace=t?`pre-wrap`:`pre`,t&&(r.style.wordBreak=`break-word`,r.style.overflowWrap=`break-word`));let i=e.querySelector(`code`);if(i){let e=Fe(n);e&&i.setAttribute(`style`,`${i.getAttribute(`style`)??``}${e}`)}},Le=e=>`<pre><code>${Pe(e)}</code></pre>`,Re=e=>{let t=(0,J.c)(21),{code:n,language:r,className:i,style:a,codeStyle:o,wrap:s}=e,c=s!==void 0&&s,{currentTheme:l}=se(),u=q.useRef(null),d;t[0]===l?d=t[1]:(d=G(l),t[0]=l,t[1]=d);let f=d,p,m;t[2]!==n||t[3]!==o||t[4]!==c?(p=()=>{let e=u.current;e&&(e.innerHTML=Le(n),Ie(e,c,o))},m=[n,c,o],t[2]=n,t[3]=o,t[4]=c,t[5]=p,t[6]=m):(p=t[5],m=t[6]),q.useLayoutEffect(p,m);let h,g;t[7]!==n||t[8]!==o||t[9]!==r||t[10]!==c?(h=()=>{let e=u.current;if(!e)return;let t=!0,i=new AbortController;return he(n,(r||`text`).toLowerCase(),{signal:i.signal,priority:`visible`}).then(n=>{!t||!e||!n||(e.innerHTML=n,Ie(e,c,o))}),()=>{t=!1,i.abort()}},g=[n,r,c,o],t[7]=n,t[8]=o,t[9]=r,t[10]=c,t[11]=h,t[12]=g):(h=t[11],g=t[12]),q.useEffect(h,g);let _;t[13]===i?_=t[14]:(_=M(`typography-code`,i),t[13]=i,t[14]=_);let v=f,y;t[15]!==a||t[16]!==v?(y={...v,...a},t[15]=a,t[16]=v,t[17]=y):y=t[17];let b;return t[18]!==_||t[19]!==y?(b=(0,Y.jsx)(`div`,{ref:u,className:_,style:y}),t[18]=_,t[19]=y,t[20]=b):b=t[20],b},ze=e=>{let t=e.replace(/^<file>\s*\n?/,``).replace(/\n?<\/file>\s*$/,``);return t=t.replace(/^\s*\d{5}\|\s?/gm,``),t.trim()},Be=(e,t=``)=>{if(typeof e==`string`)return e;if(e==null)return t;if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return String(e);try{return JSON.stringify(e)}catch{return t}},Ve=e=>e?e.includes(`<diagnostics`)||e.includes(`<file_diagnostics>`)||e.includes(`LSP errors detected`)||e.includes(`This file has errors`):!1,He=e=>e?e.replace(/\n{0,2}LSP errors detected[\s\S]*?<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/\n{0,2}This file has errors[\s\S]*?<\/file_diagnostics>/g,``).replace(/<diagnostics[^>]*>[\s\S]*?<\/diagnostics>/g,``).replace(/<file_diagnostics>[\s\S]*?<\/file_diagnostics>/g,``).trim():``,Ue=(e,t)=>!e||typeof e!=`object`?String(e):L(e,t||``),We=e=>{if(typeof e==`string`){let t=e.trim();return t.length>0?t:void 0}if(e&&typeof e==`object`){let t=e.patch;if(typeof t==`string`){let e=t.trim();return e.length>0?e:void 0}}},Ge=e=>{if(!e||typeof e!=`object`)return;let t=We(e.patch)??We(e.diff);if(t)return t;let n=Array.isArray(e.files)?e.files:[];for(let e of n){if(!e||typeof e!=`object`)continue;let t=We(e.patch)??We(e.diff);if(t)return t}},Ke=e=>{if(!e||typeof e!=`string`)return{data:null,isJson:!1};let t=e.trim();if(!t.startsWith(`{`)&&!t.startsWith(`[`)||!t.endsWith(`}`)&&!t.endsWith(`]`)||t.length<2)return{data:null,isJson:!1};try{let e=JSON.parse(t);return typeof e==`object`&&e?{data:e,isJson:!0}:{data:null,isJson:!1}}catch{return{data:null,isJson:!1}}},qe=(e,t,n)=>{let r=ze(e);if((t===`edit`||t===`multiedit`||t===`write`||t===`apply_patch`)&&Ve(r)&&(r=He(r)),(t===`edit`||t===`multiedit`||t===`apply_patch`)&&r.trim().length===0){let e=Ge(n);if(e)return e}return r},Je=e=>{let t=e.match(/<type>(file|directory)<\/type>/i)?.[1]?.toLowerCase()??`unknown`,n=(e.match(/<content>([\s\S]*?)<\/content>/i)?.[1]??e).replace(/\r\n/g,`
2
2
  `).split(`
3
3
  `),r=e=>/\(\s*File has more lines\..*offset.*\)/i.test(e.trim());return{type:t,lines:n.map(e=>{let n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);if(t!==`directory`){let t=e.match(/^(\d+):\s?(.*)$/);if(t){let e=t[2],n=e.trim(),i=n.startsWith(`(`)&&n.endsWith(`)`)||r(n);return{lineNumber:i?null:Number(t[1]),text:e,isInfo:i}}}return{lineNumber:null,text:e,isInfo:i}}).filter((e,t,n)=>{if(e.text.trim().length>0)return!0;let r=n[t-1],i=n[t+1],a=!!(r?.isInfo||i?.isInfo),o=e.lineNumber!==null;return!(a&&o)})}},Ye=(e,t)=>{try{let n=e.trim().split(`
4
4
  `).filter(Boolean);if(n.length===0)return null;let r=[];return n.forEach(e=>{let t=e.match(/^(\s*)(.+)$/);if(t){let[,e,n]=t,i=Math.floor(e.length/2),a=!n.endsWith(`/`);r.push({name:n.replace(/\/$/,``),depth:i,isFile:a})}}),(0,Y.jsx)(`div`,{className:M(`w-full min-w-0 font-mono space-y-0.5`,t?.unstyled?null:`p-3 bg-muted/20 rounded-xl border border-border/30`),style:T.tool.popup,children:r.map((e,t)=>(0,Y.jsx)(`div`,{className:`min-w-0`,style:{paddingLeft:`${e.depth*20}px`},children:e.isFile?(0,Y.jsx)(`span`,{className:`text-foreground/90 block truncate`,children:e.name}):(0,Y.jsxs)(`span`,{className:`font-semibold text-foreground block truncate`,children:[e.name,`/`]})},t))})}catch{return null}},Xe={backgroundColor:`var(--status-info)`,opacity:.6},Ze=(e,t,n)=>{try{let r=e.trim().split(`
@@ -1,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t}from"./runtime-switch-DEPKHgdL.js";import{n}from"./runtime-fetch-V-iMWR8t.js";import{st as r}from"./vendor-base-ui-wXsskyKm.js";import{U as i}from"./client-B_907PBv.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{i as o,r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{Hi as c}from"./ui-DrAJTWV6.js";import{n as l,r as u}from"./audio-session-BFWjrDbp.js";import{n as d,r as f,t as p}from"./browserVoiceService-x5Pci8L3.js";var m=e=>!!(e&&typeof e==`object`&&typeof e.type==`string`),h=e=>e.filter(m),g=e=>{let t=e,n=t.text;return typeof n==`string`?n:t.content||t.value||``},_=e=>/[^\s\u200B-\u200D\u2060\uFEFF]/u.test(e),v=e=>e.type===`text`&&!_(g(e)),y=(e,t={})=>{let{includeReasoning:n=!0}=t,r=h(e),a=r.some(e=>!e.synthetic);return r.filter(e=>{let t=!!e.synthetic;if(e.type===`text`){if(v(e))return!1;let t=g(e);if(t.includes(`<system-reminder>`)&&i(t).length===0)return!1}return t&&a||!n&&e.type===`reasoning`?!1:e.type!==`patch`})},b=e(r(),1),x=3e4,S=null,C=null;async function w(){return S&&Date.now()-S.checkedAt<x?S:C||(C=(async()=>{try{let e=await n(`/api/tts/say/status`);if(!e.ok){let e={available:!1,voices:[],checkedAt:Date.now()};return S=e,e}let t=await e.json(),r={available:!!t.available,voices:Array.isArray(t.voices)?t.voices:[],checkedAt:Date.now()};return S=r,r}catch{let e={available:!1,voices:[],checkedAt:Date.now()};return S=e,e}finally{C=null}})(),C)}var T=null;function E(){return l(),T||=new(window.AudioContext||window.webkitAudioContext),T}function D(e={}){let t=e.enabled??!0,[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)([]),[l,d]=(0,b.useState)(null),f=(0,b.useRef)(null),p=(0,b.useRef)(null),m=(0,b.useCallback)(async()=>{try{let e=E();e.state===`suspended`&&await e.resume();let t=e.createBuffer(1,1,22050),n=e.createBufferSource();n.buffer=t,n.connect(e.destination),n.start(0)}catch(e){console.error(`[useSayTTS] Failed to unlock audio:`,e)}},[]),h=(0,b.useCallback)(async()=>{if(!t)return o(!1),c([]),!1;try{let e=await w();return o(e.available),c(e.voices),e.available}catch{return o(!1),c([]),!1}},[t]);(0,b.useEffect)(()=>{h()},[h]);let g=(0,b.useCallback)(()=>{if(f.current){try{f.current.stop()}catch{}f.current=null}p.current&&=(p.current.abort(),null),i(!1)},[]),_=(0,b.useCallback)(async(e,t)=>{if(g(),!e.trim()){d(`No text to speak`),t?.onError?.(`No text to speak`);return}d(null);try{p.current=new AbortController;let r=await n(`/api/tts/say/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e.trim()}),signal:p.current.signal});if(!r.ok){let e=await r.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${r.status}`)}let a=await r.blob(),o=await a.arrayBuffer();a.size;let s=E();s.state===`suspended`&&await s.resume();let c=await s.decodeAudioData(o),l=s.createBufferSource();l.buffer=c,l.connect(s.destination),f.current=l,l.onended=()=>{i(!1),f.current=null,t?.onEnd?.()},i(!0),t?.onStart?.(),l.start(0)}catch(e){if(e.name===`AbortError`)return;let n=e instanceof Error?e.message:`Failed to speak`;console.error(`[useSayTTS] Error:`,n),d(n),t?.onError?.(n),i(!1)}},[g]);return(0,b.useEffect)(()=>u(g),[g]),(0,b.useEffect)(()=>()=>{g()},[g]),{isPlaying:r,isAvailable:a,voices:s,error:l,speak:_,stop:g,checkAvailability:h,unlockAudio:m}}function O(e,t=!1){return e?e.replace(/```[\s\S]*?```/g,``).replace(/`([^`\n]*)`/g,`$1`).replace(/!\[(?:\\.|[^\]\\])*\]\((?:\\.|[^()\\]|\((?:\\.|[^()\\])*\))*\)/g,` `).replace(/[*_~#]/g,``).replace(/https?:\/\/[^\s]+/g,``).replace(/(^|\s)\/(?:[\w.-]+\/)*[\w.-]+/g,`$1`).replace(/[//]+/g,` `).replace(/^\s*[$#>]\s*/gm,``).replace(/[[\]{}()<>|&;]/g,` `).replace(/\\/g,``).replace(/\s+/g,e=>t&&/\n\s*\n/.test(e)?`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t}from"./runtime-switch-DEPKHgdL.js";import{n}from"./runtime-fetch-V-iMWR8t.js";import{st as r}from"./vendor-base-ui-wXsskyKm.js";import{U as i}from"./client-B_907PBv.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{i as o,r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{Hi as c}from"./ui-ee2iN869.js";import{n as l,r as u}from"./audio-session-BFWjrDbp.js";import{n as d,r as f,t as p}from"./browserVoiceService-x5Pci8L3.js";var m=e=>!!(e&&typeof e==`object`&&typeof e.type==`string`),h=e=>e.filter(m),g=e=>{let t=e,n=t.text;return typeof n==`string`?n:t.content||t.value||``},_=e=>/[^\s\u200B-\u200D\u2060\uFEFF]/u.test(e),v=e=>e.type===`text`&&!_(g(e)),y=(e,t={})=>{let{includeReasoning:n=!0}=t,r=h(e),a=r.some(e=>!e.synthetic);return r.filter(e=>{let t=!!e.synthetic;if(e.type===`text`){if(v(e))return!1;let t=g(e);if(t.includes(`<system-reminder>`)&&i(t).length===0)return!1}return t&&a||!n&&e.type===`reasoning`?!1:e.type!==`patch`})},b=e(r(),1),x=3e4,S=null,C=null;async function w(){return S&&Date.now()-S.checkedAt<x?S:C||(C=(async()=>{try{let e=await n(`/api/tts/say/status`);if(!e.ok){let e={available:!1,voices:[],checkedAt:Date.now()};return S=e,e}let t=await e.json(),r={available:!!t.available,voices:Array.isArray(t.voices)?t.voices:[],checkedAt:Date.now()};return S=r,r}catch{let e={available:!1,voices:[],checkedAt:Date.now()};return S=e,e}finally{C=null}})(),C)}var T=null;function E(){return l(),T||=new(window.AudioContext||window.webkitAudioContext),T}function D(e={}){let t=e.enabled??!0,[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(!1),[s,c]=(0,b.useState)([]),[l,d]=(0,b.useState)(null),f=(0,b.useRef)(null),p=(0,b.useRef)(null),m=(0,b.useCallback)(async()=>{try{let e=E();e.state===`suspended`&&await e.resume();let t=e.createBuffer(1,1,22050),n=e.createBufferSource();n.buffer=t,n.connect(e.destination),n.start(0)}catch(e){console.error(`[useSayTTS] Failed to unlock audio:`,e)}},[]),h=(0,b.useCallback)(async()=>{if(!t)return o(!1),c([]),!1;try{let e=await w();return o(e.available),c(e.voices),e.available}catch{return o(!1),c([]),!1}},[t]);(0,b.useEffect)(()=>{h()},[h]);let g=(0,b.useCallback)(()=>{if(f.current){try{f.current.stop()}catch{}f.current=null}p.current&&=(p.current.abort(),null),i(!1)},[]),_=(0,b.useCallback)(async(e,t)=>{if(g(),!e.trim()){d(`No text to speak`),t?.onError?.(`No text to speak`);return}d(null);try{p.current=new AbortController;let r=await n(`/api/tts/say/speak`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:e.trim()}),signal:p.current.signal});if(!r.ok){let e=await r.json().catch(()=>({error:`Unknown error`}));throw Error(e.error||`HTTP ${r.status}`)}let a=await r.blob(),o=await a.arrayBuffer();a.size;let s=E();s.state===`suspended`&&await s.resume();let c=await s.decodeAudioData(o),l=s.createBufferSource();l.buffer=c,l.connect(s.destination),f.current=l,l.onended=()=>{i(!1),f.current=null,t?.onEnd?.()},i(!0),t?.onStart?.(),l.start(0)}catch(e){if(e.name===`AbortError`)return;let n=e instanceof Error?e.message:`Failed to speak`;console.error(`[useSayTTS] Error:`,n),d(n),t?.onError?.(n),i(!1)}},[g]);return(0,b.useEffect)(()=>u(g),[g]),(0,b.useEffect)(()=>()=>{g()},[g]),{isPlaying:r,isAvailable:a,voices:s,error:l,speak:_,stop:g,checkAvailability:h,unlockAudio:m}}function O(e,t=!1){return e?e.replace(/```[\s\S]*?```/g,``).replace(/`([^`\n]*)`/g,`$1`).replace(/!\[(?:\\.|[^\]\\])*\]\((?:\\.|[^()\\]|\((?:\\.|[^()\\])*\))*\)/g,` `).replace(/[*_~#]/g,``).replace(/https?:\/\/[^\s]+/g,``).replace(/(^|\s)\/(?:[\w.-]+\/)*[\w.-]+/g,`$1`).replace(/[//]+/g,` `).replace(/^\s*[$#>]\s*/gm,``).replace(/[[\]{}()<>|&;]/g,` `).replace(/\\/g,``).replace(/\s+/g,e=>t&&/\n\s*\n/.test(e)?`
2
2
 
3
3
  `:` `).trim():``}function k(e){let t=[],n=e.trim();for(;n;){let e=n.indexOf(`
4
4
 
@@ -1 +1 @@
1
- import{a as e,n as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t as n}from"./types-s_oc_LRs.js";var r=e(`CapacitorUpdater`),i=()=>{if(typeof window>`u`)return!1;try{return t.isNativePlatform()&&t.isPluginAvailable(`CapacitorUpdater`)}catch{return!1}},a=()=>{throw new n},o=()=>({async notifyAppReady(){return i()||a(),r.notifyAppReady()},async download(e){return i()||a(),r.download(e)},async next(e){return i()||a(),r.next(e)},async reload(){return i()||a(),r.reload()},async current(){return i()||a(),r.current()},async getDeviceId(){return i()||a(),r.getDeviceId()},async list(){return i()||a(),r.list()},addListener:(async(e,t)=>(i()||a(),r.addListener(e,t)))}),s,c=async()=>s===void 0?i()?(s=o(),s):(s=null,null):s,l=()=>i();export{l as n,c as t};
1
+ import{a as e,n as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{t as n}from"./types-DpcA-uDW.js";var r=e(`CapacitorUpdater`),i=()=>{if(typeof window>`u`)return!1;try{return t.isNativePlatform()&&t.isPluginAvailable(`CapacitorUpdater`)}catch{return!1}},a=()=>{throw new n},o=()=>({async notifyAppReady(){return i()||a(),r.notifyAppReady()},async download(e){return i()||a(),r.download(e)},async next(e){return i()||a(),r.next(e)},async reload(){return i()||a(),r.reload()},async current(){return i()||a(),r.current()},async getDeviceId(){return i()||a(),r.getDeviceId()},async list(){return i()||a(),r.list()},addListener:(async(e,t)=>(i()||a(),r.addListener(e,t)))}),s,c=async()=>s===void 0?i()?(s=o(),s):(s=null,null):s,l=()=>i();export{l as n,c as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./platform-CiUKDeXd.js";import{ot as r,st as i}from"./vendor-base-ui-wXsskyKm.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{m as o,r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{a as c,n as l}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{i as u,o as d}from"./session-startup-barrier-DT-hIBRf.js";import{n as f}from"./Icon-DmykXZL1.js";import{t as p}from"./ui-DrAJTWV6.js";import{t as m}from"./i18n-DXc6czdR.js";import{t as h}from"./MobileResizableSheet-CqphcaKq.js";import{o as g,t as _}from"./vendor-framer-motion-D5NyyC73.js";import{t as v}from"./textarea-ZiXxEOHK.js";import{t as y}from"./LoadingImage-Df22Rkor.js";var b=e(i(),1),x=a(),S=c(`YuriMedia`);function C(e){return e.platform===`android`||/Android/i.test(e.userAgent)||e.userAgentDataPlatform===`Android`}function w(){if(typeof window>`u`)return!1;let e=navigator.userAgentData;return C({platform:n(),userAgent:navigator.userAgent||``,userAgentDataPlatform:e?.platform})}function T(){return t()&&l.getPlatform()===`android`&&l.isPluginAvailable(`YuriMedia`)}async function E(e){if(!T())return null;let t=await S.pickMedia({limit:e});if(t.cancelled)return[];let n=[];for(let e of t.files){let t=await fetch(l.convertFileSrc(e.path));if(!t.ok)throw Error(`Native media fetch failed (${t.status})`);let r=await t.blob();n.push(new File([r],e.name,{type:e.mimeType}))}return n}var D=r(),O=`h-auto min-h-12 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 border-b border-[var(--surface-subtle)] last:border-b-0`,k=e=>{let t=(0,x.c)(38),{id:n,open:r,onOpenChange:i,onPickPhotos:a,onPickFiles:o}=e,{t:s}=m(),c;t[0]===s?c=t[1]:(c=s(`chat.chatInput.actions.addAttachment`),t[0]=s,t[1]=c);let l;t[2]===c?l=t[3]:(l=(0,D.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:c}),t[2]=c,t[3]=l);let d;t[4]===s?d=t[5]:(d=s(`chat.chatInput.actions.addAttachment`),t[4]=s,t[5]=d);let p;t[6]===s?p=t[7]:(p=s(`mobile.surface.closeAria`),t[6]=s,t[7]=p);let g;t[8]===s?g=t[9]:(g=s(`mobile.sessions.sheet.resizeAria`),t[8]=s,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,D.jsx)(f,{name:`file-image`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[10]=_):_=t[10];let v;t[11]===s?v=t[12]:(v=s(`chat.chatInput.actions.attachPhotos`),t[11]=s,t[12]=v);let y;t[13]===v?y=t[14]:(y=(0,D.jsx)(`span`,{className:`truncate`,children:v}),t[13]=v,t[14]=y);let b;t[15]!==a||t[16]!==y?(b=(0,D.jsxs)(u,{type:`button`,variant:`ghost`,size:`lg`,className:O,"data-mobile-press-feedback":`none`,onClick:a,children:[_,y]}),t[15]=a,t[16]=y,t[17]=b):b=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,D.jsx)(f,{name:`attachment-2`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[18]=S):S=t[18];let C;t[19]===s?C=t[20]:(C=s(`chat.chatInput.actions.attachFiles`),t[19]=s,t[20]=C);let w;t[21]===C?w=t[22]:(w=(0,D.jsx)(`span`,{className:`truncate`,children:C}),t[21]=C,t[22]=w);let T;t[23]!==o||t[24]!==w?(T=(0,D.jsxs)(u,{type:`button`,variant:`ghost`,size:`lg`,className:O,"data-mobile-press-feedback":`none`,onClick:o,children:[S,w]}),t[23]=o,t[24]=w,t[25]=T):T=t[25];let E;t[26]!==T||t[27]!==b?(E=(0,D.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,D.jsxs)(`div`,{className:`overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-page-scroll-lock":`true`,children:[b,T]})}),t[26]=T,t[27]=b,t[28]=E):E=t[28];let k;return t[29]!==n||t[30]!==i||t[31]!==r||t[32]!==E||t[33]!==l||t[34]!==d||t[35]!==p||t[36]!==g?(k=(0,D.jsx)(h,{id:n,open:r,onOpenChange:i,title:l,ariaLabel:d,closeAriaLabel:p,resizeAriaLabel:g,fitContent:!0,children:E}),t[29]=n,t[30]=i,t[31]=r,t[32]=E,t[33]=l,t[34]=d,t[35]=p,t[36]=g,t[37]=k):k=t[37],k},ee=e=>e.nativeEvent.isComposing||e.nativeEvent.keyCode===229;function A(e){let t=(0,x.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=d(`inline-flex shrink-0 items-center justify-center rounded-full bg-foreground text-background`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,D.jsx)(`span`,{className:a,...i,"aria-hidden":!0,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function j(e){let t=(0,x.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,D.jsx)(`span`,{"data-stop-glyph":`true`,className:`block size-[38%] rounded-[20%] bg-current`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,D.jsx)(A,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function M(e){let t=(0,x.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,spinning:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i,o=a?`loader-4`:`arrow-up`,s=a?`size-[50%] animate-spin`:`size-[56%]`,c;t[4]===s?c=t[5]:(c=d(s),t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,D.jsx)(f,{name:o,weight:`medium`,className:c}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==n||t[10]!==r||t[11]!==l?(u=(0,D.jsx)(A,{className:n,...r,children:l}),t[9]=n,t[10]=r,t[11]=l,t[12]=u):u=t[12],u}var N=`border border-[color-mix(in_srgb,var(--interactive-border)_50%,transparent)] dark:border-transparent bg-[var(--surface-background)] shadow-[0_2px_6px_-3px_color-mix(in_srgb,var(--surface-foreground)_4%,transparent),inset_0_1px_0_var(--yuri-mobile-glass-highlight)] transition-colors duration-150 motion-reduce:transition-none dark:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_8%)] dark:shadow-none`,te=b.memo(function(){let e=(0,x.c)(10),t=b.useRef(null),n=b.useRef(0),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],e[0]=r):r=e[0];let i=b.useRef(r),a=_(),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>t.current?.parentElement,e[1]=s):s=e[1];let c=s,l;e[2]===a?l=e[3]:(l=()=>{let e=t.current,r=e?.parentElement;if(!e||!r)return;let o=r.getBoundingClientRect().height,s=n.current;if(!o||Math.abs(o-s)<.5)return;n.current=o;let c=r.querySelector(`[data-composer-input-shell]`),l=new DOMMatrixReadOnly(window.getComputedStyle(e).transform).m22,u=c?new DOMMatrixReadOnly(window.getComputedStyle(c).transform).m42:0;if(i.current.forEach(re),i.current=[],!s||a){e.style.transform=``,c&&(c.style.transform=``);return}let d={duration:.2,ease:`easeOut`};i.current.push(g(e,{scaleY:[s*l/o,1]},d)),c&&i.current.push(g(c,{y:[o-s+u,0]},d))},e[2]=a,e[3]=l),o(typeof ResizeObserver<`u`?c:null,l);let u,f;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{let e=t.current,r=e?.parentElement;return n.current=r?.getBoundingClientRect().height??0,()=>{i.current.forEach(P),e&&(e.style.transform=``);let t=r?.querySelector(`[data-composer-input-shell]`);t&&(t.style.transform=``)}},f=[],e[4]=u,e[5]=f):(u=e[4],f=e[5]),b.useLayoutEffect(u,f);let p,m;e[6]===a?(p=e[7],m=e[8]):(p=()=>{if(!a)return;i.current.forEach(F),i.current=[],t.current&&(t.current.style.transform=``);let e=t.current?.parentElement?.querySelector(`[data-composer-input-shell]`);e&&(e.style.transform=``)},m=[a],e[6]=a,e[7]=p,e[8]=m),b.useLayoutEffect(p,m);let h;return e[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,D.jsx)(`div`,{ref:t,"aria-hidden":`true`,"data-composer-material":``,className:d(`pointer-events-none absolute -inset-px -z-10`,N,`dark:group-hover/composer:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)] dark:group-focus-within/composer:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)]`),style:{borderRadius:`inherit`,transformOrigin:`50% 100%`}}),e[9]=h):h=e[9],h}),ne=b.forwardRef((e,t)=>{let n=(0,x.c)(23),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({children:r,className:i,expanded:s,animateResize:c,style:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l=s!==void 0&&s,u=c!==void 0&&c,f;n[7]!==u||n[8]!==i||n[9]!==l?(f=d(`relative flex flex-col overflow-visible`,u?`group/composer isolate border border-transparent`:d(N,`dark:hover:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)] dark:focus-within:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)]`),l&&`min-h-0 flex-1`,i),n[7]=u,n[8]=i,n[9]=l,n[10]=f):f=n[10];let p;n[11]===o?p=n[12]:(p={borderRadius:`var(--radius-xl)`,...o},n[11]=o,n[12]=p);let m=u||void 0,h;n[13]===u?h=n[14]:(h=u?(0,D.jsx)(te,{}):null,n[13]=u,n[14]=h);let g;return n[15]!==r||n[16]!==a||n[17]!==t||n[18]!==f||n[19]!==p||n[20]!==m||n[21]!==h?(g=(0,D.jsxs)(`div`,{ref:t,className:f,style:p,...a,"data-composer-animated-resize":m,children:[h,r]}),n[15]=r,n[16]=a,n[17]=t,n[18]=f,n[19]=p,n[20]=m,n[21]=h,n[22]=g):g=n[22],g});ne.displayName=`ChatComposerSurface`;function re(e){return e.stop()}function P(e){return e.stop()}function F(e){return e.stop()}var ie=b.forwardRef((e,t)=>{let n=(0,x.c)(3),r;return n[0]!==e||n[1]!==t?(r=(0,D.jsx)(v,{ref:t,...e}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});ie.displayName=`ChatPromptTextarea`;var ae=e=>{let t=(0,x.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=d(`flex shrink-0 items-center gap-2 bg-transparent px-2.5 py-1.5`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,D.jsx)(`div`,{className:a,"data-chat-input-footer":`true`,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o},oe=(e,t)=>{typeof e==`function`?e(t):e&&(e.current=t)},se=({value:e,attachments:t=[],disabled:n=!1,pending:r=!1,placeholder:i,isMobile:a=!1,onChange:c,onSubmit:l,onStop:u,onAddFiles:h,onRemoveAttachment:g,addFilesLabel:_,removeAttachmentLabel:v,fileAccept:x=`image/*`,sendLabel:S,stopLabel:C,hint:O,leftControls:A,rightControls:N,footerContent:te,inputHeader:re,attachmentContent:P,highlightedContent:F,highlightRef:se,inputRef:ce,textareaProps:I,textLayoutClassName:L,inputClassName:R,inputOuterClassName:le,inputStyle:ue,footerClassName:de,footerStyle:fe,contentClassName:pe,inputSectionClassName:me,autoResize:z=!0,disableInputWhilePending:B=!0,layout:he=`stacked`,children:ge,className:_e,expanded:V=!1,...ve})=>{let{t:ye}=m(),H=he===`inline`,[be,xe]=b.useState(!1),[Se,U]=b.useState(!1),W=w(),Ce=t.length>0||be,G=b.useRef(null),K=b.useRef(null),q=b.useRef(null),we=b.useId().replace(/:/g,``),J=s(()=>{if(!z||V||I?.fillContainer){H&&xe(!1);return}let e=G.current;if(!e)return;e.style.height=H?`0px`:`auto`;let t=window.getComputedStyle(e),n=Number.parseFloat(t.maxHeight),r=H?Math.max(Number.parseFloat(t.minHeight)||0,(Number.parseFloat(t.lineHeight)||0)+(Number.parseFloat(t.paddingTop)||0)+(Number.parseFloat(t.paddingBottom)||0)):0,i=H?Math.max(e.scrollHeight,r):e.scrollHeight,a=Number.isFinite(n)?Math.min(i,n):i;e.style.height=`${a}px`,e.style.overflowY=Number.isFinite(n)&&i>n?`auto`:`hidden`;let o=a>Math.ceil(r);H&&xe(e=>e===o?e:o)});b.useLayoutEffect(()=>{J()},[z,V,H,I?.fillContainer,e,J]),o(H&&z&&!V&&!I?.fillContainer?G:null,J);let Te=e=>{I?.onKeyDown?.(e),!(e.defaultPrevented||ee(e))&&e.key===`Enter`&&!e.shiftKey&&!a&&(e.preventDefault(),!n&&(!r||!B)&&l())},Ee=e=>{h?.(e.target.files),e.target.value=``},De=s(()=>{G.current?.blur(),U(!0)}),Oe=s(e=>{U(!1),requestAnimationFrame(()=>e?.click())}),ke=s(()=>{U(!1),requestAnimationFrame(()=>{(async()=>{if(!T()){q.current?.click();return}try{let e=await E(20);if(e===null){q.current?.click();return}e.length>0&&h?.(e)}catch(e){console.error(`Native photo pick failed`,e),p.error(ye(`chat.chatInput.toast.attachFileFailed`))}})()})}),Y=e.trim().length>0||t.length>0,Ae=t.filter(e=>e.mime.startsWith(`image/`)),X=t.filter(e=>!e.mime.startsWith(`image/`)),je=h?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`input`,{ref:K,type:`file`,accept:x,multiple:!0,className:`hidden`,onChange:Ee}),W?(0,D.jsx)(`input`,{ref:q,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:Ee}):null,(0,D.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-md text-foreground outline-none hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>W?De():K.current?.click(),onMouseDown:a?e=>e.preventDefault():void 0,onPointerDownCapture:a?e=>e.preventDefault():void 0,disabled:n||r,"aria-label":_,children:(0,D.jsx)(f,{name:`attachment-2`,className:`size-[18px]`})})]}):null,Z=!n&&!r&&Y,Q=a?`size-6`:`size-full`,Me=r&&u?(0,D.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:u,"aria-label":C,children:(0,D.jsx)(j,{className:Q})}):(0,D.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":Z?`true`:void 0,className:d(`flex size-8 shrink-0 items-center justify-center outline-none`,Z?`rounded-full hover:opacity-80`:`rounded-md text-primary hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-30`),disabled:n||r||!Y,"aria-label":S,children:Z?(0,D.jsx)(M,{className:Q}):(0,D.jsx)(f,{name:r?`loader-4`:`send-plane-2`,className:d(`size-4`,r&&`animate-spin`)})}),Ne=r&&u?(0,D.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:u,"aria-label":C,children:(0,D.jsx)(j,{className:Q})}):(0,D.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":`true`,className:d(`flex size-8 shrink-0 items-center justify-center rounded-full outline-none`,Z?`hover:opacity-80`:`cursor-not-allowed opacity-30`),disabled:n||r||!Y,"aria-busy":r||void 0,"aria-label":S,onClick:()=>G.current?.focus({preventScroll:!0}),onMouseDown:e=>e.preventDefault(),onPointerDownCapture:a?e=>e.preventDefault():void 0,children:(0,D.jsx)(M,{className:Q,spinning:r})}),Pe=H?Ne:Me,$=A===void 0?je:A;return(0,D.jsxs)(ne,{className:_e,expanded:V,...ve,children:[ge,(0,D.jsxs)(`div`,{"data-composer-content":`true`,"data-composer-layout":he,className:d(`relative flex min-h-0`,H?d(`min-h-12 flex-row`,Ce?`items-end`:`items-center`):`flex-col`,V&&`flex-1`,pe),children:[H&&$?(0,D.jsx)(`div`,{className:`flex h-12 shrink-0 items-center pl-1.5`,"data-composer-inline-attach":`true`,children:$}):null,(0,D.jsxs)(`div`,{className:d(`overflow-hidden`,H&&`min-w-0 flex-1`,V&&`flex min-h-0 flex-1 flex-col`,me),children:[re,P,Ae.length>0?(0,D.jsx)(`div`,{className:`flex gap-2 overflow-x-auto px-3 pt-3`,"data-chat-prompt-attachments":`true`,children:Ae.map(e=>(0,D.jsxs)(`div`,{className:`group relative shrink-0`,children:[(0,D.jsx)(`span`,{className:`block size-16`,children:(0,D.jsx)(y,{fill:!0,src:e.url,alt:e.name,className:`size-16 rounded-lg border border-border object-cover`})}),g?(0,D.jsx)(`button`,{type:`button`,className:`absolute -right-1 -top-1 flex size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] shadow-sm hover:bg-[var(--interactive-hover)]`,onClick:()=>g(e.id),"aria-label":v,children:(0,D.jsx)(f,{name:`close`,className:`size-3`})}):null]},e.id))}):null,X.length>0?(0,D.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,"data-chat-prompt-file-attachments":`true`,children:X.map(e=>(0,D.jsxs)(`div`,{className:`relative flex max-w-[12rem] items-center gap-1.5 rounded-lg border border-border bg-[var(--surface-elevated)] px-2 py-1`,children:[(0,D.jsx)(f,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,D.jsx)(`span`,{className:`min-w-0 truncate typography-micro`,children:e.name}),g?(0,D.jsx)(`button`,{type:`button`,className:`flex size-5 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-[var(--interactive-hover)]`,onClick:()=>g(e.id),"aria-label":v,children:(0,D.jsx)(f,{name:`close`,className:`size-3`})}):null]},e.id))}):null,(0,D.jsxs)(`div`,{className:d(`relative overflow-hidden`,H&&d(`flex min-h-12`,be?`items-end`:`items-center`),V&&`flex min-h-0 flex-1 flex-col`),"data-composer-input-shell":`true`,children:[F?(0,D.jsx)(`div`,{ref:se,"aria-hidden":!0,"data-composer-highlight":`true`,className:d(`pointer-events-none absolute inset-0 z-0 rounded-b-none`,L,R),children:F}):null,(0,D.jsx)(ie,{...I,simple:!0,fillContainer:!H&&I?.fillContainer,ref:e=>{G.current=e,oe(ce,e)},"data-chat-input":`true`,value:e,onChange:e=>c(e.target.value,e),onKeyDown:Te,disabled:n||r&&B,placeholder:i,enterKeyHint:a?`enter`:I?.enterKeyHint,outerClassName:d(`ring-0 bg-transparent shadow-none hover:bg-transparent focus-within:ring-0`,H&&`flex-none`,V&&`min-h-0 flex-1`,le),className:d(`relative z-10 resize-none overflow-y-hidden appearance-none border-0 bg-transparent typography-markdown hover:border-transparent md:typography-ui-label`,H?`field-sizing-fixed min-h-12 max-h-32 px-3 py-3 leading-6`:`min-h-[52px] max-h-40 rounded-b-none px-3 pb-2 pt-4`,L,R,F&&`text-transparent caret-[var(--surface-foreground)]`),style:ue,rows:I?.rows??1})]})]}),H?(0,D.jsx)(`div`,{className:d(`flex h-12 shrink-0 items-center pr-1.5`,de),style:fe,"data-composer-inline-send":`true`,children:N??Pe}):(0,D.jsx)(ae,{className:de,style:fe,children:te??(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`flex items-center gap-1.5`,children:A??je}),O?(0,D.jsx)(`div`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,children:O}):(0,D.jsx)(`div`,{className:`flex-1`}),(0,D.jsx)(`div`,{className:`flex items-center gap-1.5`,children:N??Pe})]})})]}),W&&h?(0,D.jsx)(k,{id:`mobile-attach-pick-${we}`,open:Se,onOpenChange:e=>{e||U(!1)},onPickPhotos:ke,onPickFiles:()=>Oe(K.current)}):null]})},ce=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return!1;switch(e.key){case`ArrowUp`:case`PageUp`:case`Home`:return!0;default:return!1}},I=(e,t,n)=>{let r=t instanceof Element?t:t instanceof Node?t.parentElement:null;for(;r&&r!==e;){if(r instanceof HTMLElement){let e=r.scrollHeight-r.clientHeight;if(e>1&&(n===`up`?r.scrollTop>0:r.scrollTop<e-1))return!0}r=r.parentElement}return!1},L=(e,t)=>I(e,t,`up`),R=(e,t)=>I(e,t,`down`);export{M as a,k as c,w as d,se as i,T as l,R as n,j as o,L as r,ee as s,ce as t,E as u};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./platform-CiUKDeXd.js";import{ot as r,st as i}from"./vendor-base-ui-wXsskyKm.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{m as o,r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{a as c,n as l}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{i as u,o as d}from"./session-startup-barrier-DT-hIBRf.js";import{n as f}from"./Icon-DmykXZL1.js";import{t as p}from"./ui-ee2iN869.js";import{t as m}from"./i18n-DXc6czdR.js";import{t as h}from"./MobileResizableSheet-CqphcaKq.js";import{o as g,t as _}from"./vendor-framer-motion-D5NyyC73.js";import{t as v}from"./textarea-ZiXxEOHK.js";import{t as y}from"./LoadingImage-Df22Rkor.js";var b=e(i(),1),x=a(),S=c(`YuriMedia`);function C(e){return e.platform===`android`||/Android/i.test(e.userAgent)||e.userAgentDataPlatform===`Android`}function w(){if(typeof window>`u`)return!1;let e=navigator.userAgentData;return C({platform:n(),userAgent:navigator.userAgent||``,userAgentDataPlatform:e?.platform})}function T(){return t()&&l.getPlatform()===`android`&&l.isPluginAvailable(`YuriMedia`)}async function E(e){if(!T())return null;let t=await S.pickMedia({limit:e});if(t.cancelled)return[];let n=[];for(let e of t.files){let t=await fetch(l.convertFileSrc(e.path));if(!t.ok)throw Error(`Native media fetch failed (${t.status})`);let r=await t.blob();n.push(new File([r],e.name,{type:e.mimeType}))}return n}var D=r(),O=`h-auto min-h-12 w-full justify-start gap-3 rounded-none supports-[corner-shape:squircle]:rounded-none px-4 border-b border-[var(--surface-subtle)] last:border-b-0`,k=e=>{let t=(0,x.c)(38),{id:n,open:r,onOpenChange:i,onPickPhotos:a,onPickFiles:o}=e,{t:s}=m(),c;t[0]===s?c=t[1]:(c=s(`chat.chatInput.actions.addAttachment`),t[0]=s,t[1]=c);let l;t[2]===c?l=t[3]:(l=(0,D.jsx)(`h2`,{className:`truncate typography-ui-label font-semibold`,children:c}),t[2]=c,t[3]=l);let d;t[4]===s?d=t[5]:(d=s(`chat.chatInput.actions.addAttachment`),t[4]=s,t[5]=d);let p;t[6]===s?p=t[7]:(p=s(`mobile.surface.closeAria`),t[6]=s,t[7]=p);let g;t[8]===s?g=t[9]:(g=s(`mobile.sessions.sheet.resizeAria`),t[8]=s,t[9]=g);let _;t[10]===Symbol.for(`react.memo_cache_sentinel`)?(_=(0,D.jsx)(f,{name:`file-image`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[10]=_):_=t[10];let v;t[11]===s?v=t[12]:(v=s(`chat.chatInput.actions.attachPhotos`),t[11]=s,t[12]=v);let y;t[13]===v?y=t[14]:(y=(0,D.jsx)(`span`,{className:`truncate`,children:v}),t[13]=v,t[14]=y);let b;t[15]!==a||t[16]!==y?(b=(0,D.jsxs)(u,{type:`button`,variant:`ghost`,size:`lg`,className:O,"data-mobile-press-feedback":`none`,onClick:a,children:[_,y]}),t[15]=a,t[16]=y,t[17]=b):b=t[17];let S;t[18]===Symbol.for(`react.memo_cache_sentinel`)?(S=(0,D.jsx)(f,{name:`attachment-2`,className:`size-5 flex-shrink-0 text-muted-foreground`}),t[18]=S):S=t[18];let C;t[19]===s?C=t[20]:(C=s(`chat.chatInput.actions.attachFiles`),t[19]=s,t[20]=C);let w;t[21]===C?w=t[22]:(w=(0,D.jsx)(`span`,{className:`truncate`,children:C}),t[21]=C,t[22]=w);let T;t[23]!==o||t[24]!==w?(T=(0,D.jsxs)(u,{type:`button`,variant:`ghost`,size:`lg`,className:O,"data-mobile-press-feedback":`none`,onClick:o,children:[S,w]}),t[23]=o,t[24]=w,t[25]=T):T=t[25];let E;t[26]!==T||t[27]!==b?(E=(0,D.jsx)(`div`,{className:`flex min-h-0 flex-col overflow-y-auto overscroll-contain px-3 pb-3`,children:(0,D.jsxs)(`div`,{className:`overflow-hidden rounded-2xl bg-[var(--surface-muted)]`,"data-page-scroll-lock":`true`,children:[b,T]})}),t[26]=T,t[27]=b,t[28]=E):E=t[28];let k;return t[29]!==n||t[30]!==i||t[31]!==r||t[32]!==E||t[33]!==l||t[34]!==d||t[35]!==p||t[36]!==g?(k=(0,D.jsx)(h,{id:n,open:r,onOpenChange:i,title:l,ariaLabel:d,closeAriaLabel:p,resizeAriaLabel:g,fitContent:!0,children:E}),t[29]=n,t[30]=i,t[31]=r,t[32]=E,t[33]=l,t[34]=d,t[35]=p,t[36]=g,t[37]=k):k=t[37],k},ee=e=>e.nativeEvent.isComposing||e.nativeEvent.keyCode===229;function A(e){let t=(0,x.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=d(`inline-flex shrink-0 items-center justify-center rounded-full bg-foreground text-background`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,D.jsx)(`span`,{className:a,...i,"aria-hidden":!0,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o}function j(e){let t=(0,x.c)(7),n,r;t[0]===e?(n=t[1],r=t[2]):({className:n,...r}=e,t[0]=e,t[1]=n,t[2]=r);let i;t[3]===Symbol.for(`react.memo_cache_sentinel`)?(i=(0,D.jsx)(`span`,{"data-stop-glyph":`true`,className:`block size-[38%] rounded-[20%] bg-current`}),t[3]=i):i=t[3];let a;return t[4]!==n||t[5]!==r?(a=(0,D.jsx)(A,{className:n,...r,children:i}),t[4]=n,t[5]=r,t[6]=a):a=t[6],a}function M(e){let t=(0,x.c)(13),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:n,spinning:i,...r}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a=i!==void 0&&i,o=a?`loader-4`:`arrow-up`,s=a?`size-[50%] animate-spin`:`size-[56%]`,c;t[4]===s?c=t[5]:(c=d(s),t[4]=s,t[5]=c);let l;t[6]!==o||t[7]!==c?(l=(0,D.jsx)(f,{name:o,weight:`medium`,className:c}),t[6]=o,t[7]=c,t[8]=l):l=t[8];let u;return t[9]!==n||t[10]!==r||t[11]!==l?(u=(0,D.jsx)(A,{className:n,...r,children:l}),t[9]=n,t[10]=r,t[11]=l,t[12]=u):u=t[12],u}var N=`border border-[color-mix(in_srgb,var(--interactive-border)_50%,transparent)] dark:border-transparent bg-[var(--surface-background)] shadow-[0_2px_6px_-3px_color-mix(in_srgb,var(--surface-foreground)_4%,transparent),inset_0_1px_0_var(--yuri-mobile-glass-highlight)] transition-colors duration-150 motion-reduce:transition-none dark:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_8%)] dark:shadow-none`,te=b.memo(function(){let e=(0,x.c)(10),t=b.useRef(null),n=b.useRef(0),r;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=[],e[0]=r):r=e[0];let i=b.useRef(r),a=_(),s;e[1]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>t.current?.parentElement,e[1]=s):s=e[1];let c=s,l;e[2]===a?l=e[3]:(l=()=>{let e=t.current,r=e?.parentElement;if(!e||!r)return;let o=r.getBoundingClientRect().height,s=n.current;if(!o||Math.abs(o-s)<.5)return;n.current=o;let c=r.querySelector(`[data-composer-input-shell]`),l=new DOMMatrixReadOnly(window.getComputedStyle(e).transform).m22,u=c?new DOMMatrixReadOnly(window.getComputedStyle(c).transform).m42:0;if(i.current.forEach(re),i.current=[],!s||a){e.style.transform=``,c&&(c.style.transform=``);return}let d={duration:.2,ease:`easeOut`};i.current.push(g(e,{scaleY:[s*l/o,1]},d)),c&&i.current.push(g(c,{y:[o-s+u,0]},d))},e[2]=a,e[3]=l),o(typeof ResizeObserver<`u`?c:null,l);let u,f;e[4]===Symbol.for(`react.memo_cache_sentinel`)?(u=()=>{let e=t.current,r=e?.parentElement;return n.current=r?.getBoundingClientRect().height??0,()=>{i.current.forEach(P),e&&(e.style.transform=``);let t=r?.querySelector(`[data-composer-input-shell]`);t&&(t.style.transform=``)}},f=[],e[4]=u,e[5]=f):(u=e[4],f=e[5]),b.useLayoutEffect(u,f);let p,m;e[6]===a?(p=e[7],m=e[8]):(p=()=>{if(!a)return;i.current.forEach(F),i.current=[],t.current&&(t.current.style.transform=``);let e=t.current?.parentElement?.querySelector(`[data-composer-input-shell]`);e&&(e.style.transform=``)},m=[a],e[6]=a,e[7]=p,e[8]=m),b.useLayoutEffect(p,m);let h;return e[9]===Symbol.for(`react.memo_cache_sentinel`)?(h=(0,D.jsx)(`div`,{ref:t,"aria-hidden":`true`,"data-composer-material":``,className:d(`pointer-events-none absolute -inset-px -z-10`,N,`dark:group-hover/composer:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)] dark:group-focus-within/composer:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)]`),style:{borderRadius:`inherit`,transformOrigin:`50% 100%`}}),e[9]=h):h=e[9],h}),ne=b.forwardRef((e,t)=>{let n=(0,x.c)(23),r,i,a,o,s,c;n[0]===e?(r=n[1],i=n[2],a=n[3],o=n[4],s=n[5],c=n[6]):({children:r,className:i,expanded:s,animateResize:c,style:o,...a}=e,n[0]=e,n[1]=r,n[2]=i,n[3]=a,n[4]=o,n[5]=s,n[6]=c);let l=s!==void 0&&s,u=c!==void 0&&c,f;n[7]!==u||n[8]!==i||n[9]!==l?(f=d(`relative flex flex-col overflow-visible`,u?`group/composer isolate border border-transparent`:d(N,`dark:hover:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)] dark:focus-within:bg-[color-mix(in_srgb,var(--surface-background),var(--surface-foreground)_11%)]`),l&&`min-h-0 flex-1`,i),n[7]=u,n[8]=i,n[9]=l,n[10]=f):f=n[10];let p;n[11]===o?p=n[12]:(p={borderRadius:`var(--radius-xl)`,...o},n[11]=o,n[12]=p);let m=u||void 0,h;n[13]===u?h=n[14]:(h=u?(0,D.jsx)(te,{}):null,n[13]=u,n[14]=h);let g;return n[15]!==r||n[16]!==a||n[17]!==t||n[18]!==f||n[19]!==p||n[20]!==m||n[21]!==h?(g=(0,D.jsxs)(`div`,{ref:t,className:f,style:p,...a,"data-composer-animated-resize":m,children:[h,r]}),n[15]=r,n[16]=a,n[17]=t,n[18]=f,n[19]=p,n[20]=m,n[21]=h,n[22]=g):g=n[22],g});ne.displayName=`ChatComposerSurface`;function re(e){return e.stop()}function P(e){return e.stop()}function F(e){return e.stop()}var ie=b.forwardRef((e,t)=>{let n=(0,x.c)(3),r;return n[0]!==e||n[1]!==t?(r=(0,D.jsx)(v,{ref:t,...e}),n[0]=e,n[1]=t,n[2]=r):r=n[2],r});ie.displayName=`ChatPromptTextarea`;var ae=e=>{let t=(0,x.c)(10),n,r,i;t[0]===e?(n=t[1],r=t[2],i=t[3]):({className:r,children:n,...i}=e,t[0]=e,t[1]=n,t[2]=r,t[3]=i);let a;t[4]===r?a=t[5]:(a=d(`flex shrink-0 items-center gap-2 bg-transparent px-2.5 py-1.5`,r),t[4]=r,t[5]=a);let o;return t[6]!==n||t[7]!==i||t[8]!==a?(o=(0,D.jsx)(`div`,{className:a,"data-chat-input-footer":`true`,...i,children:n}),t[6]=n,t[7]=i,t[8]=a,t[9]=o):o=t[9],o},oe=(e,t)=>{typeof e==`function`?e(t):e&&(e.current=t)},se=({value:e,attachments:t=[],disabled:n=!1,pending:r=!1,placeholder:i,isMobile:a=!1,onChange:c,onSubmit:l,onStop:u,onAddFiles:h,onRemoveAttachment:g,addFilesLabel:_,removeAttachmentLabel:v,fileAccept:x=`image/*`,sendLabel:S,stopLabel:C,hint:O,leftControls:A,rightControls:N,footerContent:te,inputHeader:re,attachmentContent:P,highlightedContent:F,highlightRef:se,inputRef:ce,textareaProps:I,textLayoutClassName:L,inputClassName:R,inputOuterClassName:le,inputStyle:ue,footerClassName:de,footerStyle:fe,contentClassName:pe,inputSectionClassName:me,autoResize:z=!0,disableInputWhilePending:B=!0,layout:he=`stacked`,children:ge,className:_e,expanded:V=!1,...ve})=>{let{t:ye}=m(),H=he===`inline`,[be,xe]=b.useState(!1),[Se,U]=b.useState(!1),W=w(),Ce=t.length>0||be,G=b.useRef(null),K=b.useRef(null),q=b.useRef(null),we=b.useId().replace(/:/g,``),J=s(()=>{if(!z||V||I?.fillContainer){H&&xe(!1);return}let e=G.current;if(!e)return;e.style.height=H?`0px`:`auto`;let t=window.getComputedStyle(e),n=Number.parseFloat(t.maxHeight),r=H?Math.max(Number.parseFloat(t.minHeight)||0,(Number.parseFloat(t.lineHeight)||0)+(Number.parseFloat(t.paddingTop)||0)+(Number.parseFloat(t.paddingBottom)||0)):0,i=H?Math.max(e.scrollHeight,r):e.scrollHeight,a=Number.isFinite(n)?Math.min(i,n):i;e.style.height=`${a}px`,e.style.overflowY=Number.isFinite(n)&&i>n?`auto`:`hidden`;let o=a>Math.ceil(r);H&&xe(e=>e===o?e:o)});b.useLayoutEffect(()=>{J()},[z,V,H,I?.fillContainer,e,J]),o(H&&z&&!V&&!I?.fillContainer?G:null,J);let Te=e=>{I?.onKeyDown?.(e),!(e.defaultPrevented||ee(e))&&e.key===`Enter`&&!e.shiftKey&&!a&&(e.preventDefault(),!n&&(!r||!B)&&l())},Ee=e=>{h?.(e.target.files),e.target.value=``},De=s(()=>{G.current?.blur(),U(!0)}),Oe=s(e=>{U(!1),requestAnimationFrame(()=>e?.click())}),ke=s(()=>{U(!1),requestAnimationFrame(()=>{(async()=>{if(!T()){q.current?.click();return}try{let e=await E(20);if(e===null){q.current?.click();return}e.length>0&&h?.(e)}catch(e){console.error(`Native photo pick failed`,e),p.error(ye(`chat.chatInput.toast.attachFileFailed`))}})()})}),Y=e.trim().length>0||t.length>0,Ae=t.filter(e=>e.mime.startsWith(`image/`)),X=t.filter(e=>!e.mime.startsWith(`image/`)),je=h?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`input`,{ref:K,type:`file`,accept:x,multiple:!0,className:`hidden`,onChange:Ee}),W?(0,D.jsx)(`input`,{ref:q,type:`file`,accept:`image/*`,multiple:!0,className:`hidden`,onChange:Ee}):null,(0,D.jsx)(`button`,{type:`button`,className:`flex size-8 shrink-0 items-center justify-center rounded-md text-foreground outline-none hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-40`,onClick:()=>W?De():K.current?.click(),onMouseDown:a?e=>e.preventDefault():void 0,onPointerDownCapture:a?e=>e.preventDefault():void 0,disabled:n||r,"aria-label":_,children:(0,D.jsx)(f,{name:`attachment-2`,className:`size-[18px]`})})]}):null,Z=!n&&!r&&Y,Q=a?`size-6`:`size-full`,Me=r&&u?(0,D.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:u,"aria-label":C,children:(0,D.jsx)(j,{className:Q})}):(0,D.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":Z?`true`:void 0,className:d(`flex size-8 shrink-0 items-center justify-center outline-none`,Z?`rounded-full hover:opacity-80`:`rounded-md text-primary hover:bg-[var(--interactive-hover)] disabled:cursor-not-allowed disabled:opacity-30`),disabled:n||r||!Y,"aria-label":S,children:Z?(0,D.jsx)(M,{className:Q}):(0,D.jsx)(f,{name:r?`loader-4`:`send-plane-2`,className:d(`size-4`,r&&`animate-spin`)})}),Ne=r&&u?(0,D.jsx)(`button`,{type:`button`,"data-composer-stop":`true`,className:`flex size-8 shrink-0 items-center justify-center rounded-full outline-none hover:opacity-80`,onClick:u,"aria-label":C,children:(0,D.jsx)(j,{className:Q})}):(0,D.jsx)(`button`,{type:`submit`,"data-composer-send":`true`,"data-composer-circle":`true`,className:d(`flex size-8 shrink-0 items-center justify-center rounded-full outline-none`,Z?`hover:opacity-80`:`cursor-not-allowed opacity-30`),disabled:n||r||!Y,"aria-busy":r||void 0,"aria-label":S,onClick:()=>G.current?.focus({preventScroll:!0}),onMouseDown:e=>e.preventDefault(),onPointerDownCapture:a?e=>e.preventDefault():void 0,children:(0,D.jsx)(M,{className:Q,spinning:r})}),Pe=H?Ne:Me,$=A===void 0?je:A;return(0,D.jsxs)(ne,{className:_e,expanded:V,...ve,children:[ge,(0,D.jsxs)(`div`,{"data-composer-content":`true`,"data-composer-layout":he,className:d(`relative flex min-h-0`,H?d(`min-h-12 flex-row`,Ce?`items-end`:`items-center`):`flex-col`,V&&`flex-1`,pe),children:[H&&$?(0,D.jsx)(`div`,{className:`flex h-12 shrink-0 items-center pl-1.5`,"data-composer-inline-attach":`true`,children:$}):null,(0,D.jsxs)(`div`,{className:d(`overflow-hidden`,H&&`min-w-0 flex-1`,V&&`flex min-h-0 flex-1 flex-col`,me),children:[re,P,Ae.length>0?(0,D.jsx)(`div`,{className:`flex gap-2 overflow-x-auto px-3 pt-3`,"data-chat-prompt-attachments":`true`,children:Ae.map(e=>(0,D.jsxs)(`div`,{className:`group relative shrink-0`,children:[(0,D.jsx)(`span`,{className:`block size-16`,children:(0,D.jsx)(y,{fill:!0,src:e.url,alt:e.name,className:`size-16 rounded-lg border border-border object-cover`})}),g?(0,D.jsx)(`button`,{type:`button`,className:`absolute -right-1 -top-1 flex size-6 items-center justify-center rounded-full border border-border bg-[var(--surface-elevated)] shadow-sm hover:bg-[var(--interactive-hover)]`,onClick:()=>g(e.id),"aria-label":v,children:(0,D.jsx)(f,{name:`close`,className:`size-3`})}):null]},e.id))}):null,X.length>0?(0,D.jsx)(`div`,{className:`flex flex-wrap gap-2 px-3 pt-3`,"data-chat-prompt-file-attachments":`true`,children:X.map(e=>(0,D.jsxs)(`div`,{className:`relative flex max-w-[12rem] items-center gap-1.5 rounded-lg border border-border bg-[var(--surface-elevated)] px-2 py-1`,children:[(0,D.jsx)(f,{name:`file-text`,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,D.jsx)(`span`,{className:`min-w-0 truncate typography-micro`,children:e.name}),g?(0,D.jsx)(`button`,{type:`button`,className:`flex size-5 shrink-0 items-center justify-center rounded-full text-muted-foreground hover:bg-[var(--interactive-hover)]`,onClick:()=>g(e.id),"aria-label":v,children:(0,D.jsx)(f,{name:`close`,className:`size-3`})}):null]},e.id))}):null,(0,D.jsxs)(`div`,{className:d(`relative overflow-hidden`,H&&d(`flex min-h-12`,be?`items-end`:`items-center`),V&&`flex min-h-0 flex-1 flex-col`),"data-composer-input-shell":`true`,children:[F?(0,D.jsx)(`div`,{ref:se,"aria-hidden":!0,"data-composer-highlight":`true`,className:d(`pointer-events-none absolute inset-0 z-0 rounded-b-none`,L,R),children:F}):null,(0,D.jsx)(ie,{...I,simple:!0,fillContainer:!H&&I?.fillContainer,ref:e=>{G.current=e,oe(ce,e)},"data-chat-input":`true`,value:e,onChange:e=>c(e.target.value,e),onKeyDown:Te,disabled:n||r&&B,placeholder:i,enterKeyHint:a?`enter`:I?.enterKeyHint,outerClassName:d(`ring-0 bg-transparent shadow-none hover:bg-transparent focus-within:ring-0`,H&&`flex-none`,V&&`min-h-0 flex-1`,le),className:d(`relative z-10 resize-none overflow-y-hidden appearance-none border-0 bg-transparent typography-markdown hover:border-transparent md:typography-ui-label`,H?`field-sizing-fixed min-h-12 max-h-32 px-3 py-3 leading-6`:`min-h-[52px] max-h-40 rounded-b-none px-3 pb-2 pt-4`,L,R,F&&`text-transparent caret-[var(--surface-foreground)]`),style:ue,rows:I?.rows??1})]})]}),H?(0,D.jsx)(`div`,{className:d(`flex h-12 shrink-0 items-center pr-1.5`,de),style:fe,"data-composer-inline-send":`true`,children:N??Pe}):(0,D.jsx)(ae,{className:de,style:fe,children:te??(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`flex items-center gap-1.5`,children:A??je}),O?(0,D.jsx)(`div`,{className:`min-w-0 flex-1 truncate typography-micro text-muted-foreground`,children:O}):(0,D.jsx)(`div`,{className:`flex-1`}),(0,D.jsx)(`div`,{className:`flex items-center gap-1.5`,children:N??Pe})]})})]}),W&&h?(0,D.jsx)(k,{id:`mobile-attach-pick-${we}`,open:Se,onOpenChange:e=>{e||U(!1)},onPickPhotos:ke,onPickFiles:()=>Oe(K.current)}):null]})},ce=e=>{if(e.altKey||e.ctrlKey||e.metaKey)return!1;switch(e.key){case`ArrowUp`:case`PageUp`:case`Home`:return!0;default:return!1}},I=(e,t,n)=>{let r=t instanceof Element?t:t instanceof Node?t.parentElement:null;for(;r&&r!==e;){if(r instanceof HTMLElement){let e=r.scrollHeight-r.clientHeight;if(e>1&&(n===`up`?r.scrollTop>0:r.scrollTop<e-1))return!0}r=r.parentElement}return!1},L=(e,t)=>I(e,t,`up`),R=(e,t)=>I(e,t,`down`);export{M as a,k as c,w as d,se as i,T as l,R as n,j as o,L as r,ee as s,ce as t,E as u};
@@ -1,4 +1,4 @@
1
- import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEPKHgdL.js";import{n as r}from"./runtime-fetch-V-iMWR8t.js";import{t as i}from"./runtimeAPIRegistry-C2VogTny.js";import{$ as a,A as o,B as s,D as c,E as l,F as u,G as d,H as f,I as p,J as m,K as ee,L as te,M as ne,N as re,O as ie,P as ae,Q as oe,R as se,S as ce,T as le,U as ue,V as de,W as h,X as fe,Y as pe,Z as me,_ as he,_t as ge,a as _e,at as ve,b as ye,bt as be,c as xe,ct as Se,d as Ce,dt as we,et as Te,f as Ee,ft as De,g as Oe,gt as ke,h as Ae,ht as je,i as Me,it as Ne,j as g,k as Pe,l as Fe,lt as Ie,m as Le,mt as Re,n as ze,nt as Be,o as Ve,ot as He,p as Ue,pt as We,q as Ge,r as Ke,rt as qe,s as Je,st as Ye,t as Xe,tt as Ze,u as Qe,ut as $e,v as et,vt as tt,x as nt,y as rt,yt as it,z as at}from"./gitApiHttp-Dd-FwgCq.js";import{n as ot}from"./client-B_907PBv.js";import{Hi as _,f as v,l as st}from"./ui-DrAJTWV6.js";var y=`/api/magic-prompts`,ct=new Map([{id:`git.commit.generate.visible`,title:`Commit Generation Visible Prompt`,group:`Git`,description:`Visible user message for commit message generation.`,template:`You are generating a Conventional Commits subject line from the diffs of the selected files.`},{id:`git.commit.generate.instructions`,title:`Commit Generation Instructions`,group:`Git`,description:`Hidden instructions for commit message generation.`,placeholders:[{key:`selected_files`,description:`Bullet list of currently selected file paths.`}],template:`Return exactly one JSON object and nothing else. Do not include prose, markdown, explanations, or code fences.
1
+ import{n as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,n}from"./runtime-switch-DEPKHgdL.js";import{n as r}from"./runtime-fetch-V-iMWR8t.js";import{t as i}from"./runtimeAPIRegistry-C2VogTny.js";import{$ as a,A as o,B as s,D as c,E as l,F as u,G as d,H as f,I as p,J as m,K as ee,L as te,M as ne,N as re,O as ie,P as ae,Q as oe,R as se,S as ce,T as le,U as ue,V as de,W as h,X as fe,Y as pe,Z as me,_ as he,_t as ge,a as _e,at as ve,b as ye,bt as be,c as xe,ct as Se,d as Ce,dt as we,et as Te,f as Ee,ft as De,g as Oe,gt as ke,h as Ae,ht as je,i as Me,it as Ne,j as g,k as Pe,l as Fe,lt as Ie,m as Le,mt as Re,n as ze,nt as Be,o as Ve,ot as He,p as Ue,pt as We,q as Ge,r as Ke,rt as qe,s as Je,st as Ye,t as Xe,tt as Ze,u as Qe,ut as $e,v as et,vt as tt,x as nt,y as rt,yt as it,z as at}from"./gitApiHttp-Dd-FwgCq.js";import{n as ot}from"./client-B_907PBv.js";import{Hi as _,f as v,l as st}from"./ui-ee2iN869.js";var y=`/api/magic-prompts`,ct=new Map([{id:`git.commit.generate.visible`,title:`Commit Generation Visible Prompt`,group:`Git`,description:`Visible user message for commit message generation.`,template:`You are generating a Conventional Commits subject line from the diffs of the selected files.`},{id:`git.commit.generate.instructions`,title:`Commit Generation Instructions`,group:`Git`,description:`Hidden instructions for commit message generation.`,placeholders:[{key:`selected_files`,description:`Bullet list of currently selected file paths.`}],template:`Return exactly one JSON object and nothing else. Do not include prose, markdown, explanations, or code fences.
2
2
 
3
3
  The JSON object must have exactly this shape:
4
4
  {"subject": string, "highlights": string[]}
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{R as t,l as n,u as r}from"./platform-CiUKDeXd.js";import{a as i,i as a,r as o}from"./vendor-zustand-CTekDqaS.js";import{ot as s,st as c}from"./vendor-base-ui-wXsskyKm.js";import{St as l,an as u,jt as d,on as f}from"./gitApiHttp-Dd-FwgCq.js";import{t as p}from"./safeStorage-DTOhKN0V.js";import{i as m,t as h}from"./vendor-pathe-vBmvQE8f.js";import{n as g}from"./vendor-react-BkccXcWz.js";import{s as _,u as v}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as y}from"./runtime-file-resource-Bc_ss-sW.js";import{o as b}from"./path-utils-jGozTg9d.js";import{r as x}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as S}from"./useUIStore-C3ewjGgP.js";import{o as C,s as w}from"./spacedFileMention-Ds4GtgiF.js";import{o as T,p as E}from"./session-startup-barrier-DT-hIBRf.js";import{n as D}from"./Icon-DmykXZL1.js";import{Da as O,Hi as k,L as A,Ma as ee,Na as j,Oi as M,_ as N,b as P,f as F,lt as I,ma as te,ra as ne,xi as L,yt as R}from"./ui-DrAJTWV6.js";import{s as re}from"./remoteProjectQueries-C8382jM8.js";import{t as ie}from"./i18n-DXc6czdR.js";import{t as ae}from"./ScrollableOverlay-stxT7gLf.js";import{t as oe}from"./useDebouncedValue-BHlMPqY8.js";import{t as se}from"./AgentAvatar-CHCjMxCF.js";import{c as ce,d as le,l as ue,n as de,r as fe,t as pe}from"./fileMentionTouchSelection-BQEUty_A.js";import{a as me,o as he,s as ge}from"./fileMentionAutocompleteState-B9411b4o.js";var _e=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=w([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},ve=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.title===r.title&&(e.subtitle??``)===(r.subtitle??``)&&(e.badge??``)===(r.badge??``)&&e.iconName===r.iconName&&e.agentName===r.agentName}),ye=(e,t)=>e.highlightedIndex===t.highlightedIndex&&ve(e.rows,t.rows),be=(e,t)=>ve(e,t)?e:t.slice(),xe=(e,t,n)=>{e&&(t.current&&ye(t.current,n)||(t.current=n,e(n)))},Se=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},z=e(c(),1),B=g(),Ce=e=>e.directories.flatMap(e=>e.sessions),V=(e,t)=>({...re(e,t.location.hostId),select:Ce}),we=async(e,t,n)=>{n.sdk();let r=await e.fetchQuery(V(t,n));return n.sdk(),Ce(r)},H=(e,t,n,r)=>{n.sdk();let i=e.getQueryData(V(t,n).queryKey);for(let e of i?.directories??[]){let t=e.sessions.find(e=>e.id===r);if(t)return t.title||r}return r},U=(e,t,n,r={})=>({queryKey:[...e.queryScope,`composer-files`,t,n,r],staleTime:3e4,gcTime:3e4,queryFn:async({signal:i})=>{let a=await e.sdk().file.find({query:t,location:{directory:e.location.directory},limit:n,type:r.type},{signal:i});if(e.sdk(),i.throwIfAborted(),!Array.isArray(a.data))throw Error(`File search returned no data`);return a.data.map(t=>{let n=m(t.path),r=h(n);return{name:r,path:b(e.location.directory,n),relativePath:n,extension:r.includes(`.`)?r.split(`.`).pop()?.toLowerCase():void 0,isDirectory:t.type===`directory`}})}}),W=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},G=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,K=e=>e.startsWith(`yuri-remote-location:`)?n(e):W(e),q=(e,t)=>{let n=W(r(t,`local`).directory),i=W(e);if(!n||!i)return!1;let a=G(n),o=G(i);return o===a||o.startsWith(a.endsWith(`/`)?a:`${a}/`)},J=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t;try{t=K(e)}catch{continue}if(!t||!r||typeof r!=`object`)continue;let i=r,a=Array.isArray(i.openPaths)?Array.from(new Set(i.openPaths.filter(e=>typeof e==`string`).map(e=>W(e)).filter(e=>q(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>W(e)).filter(e=>q(e,t)))):[],s=typeof i.selectedPath==`string`?W(i.selectedPath):null,c=s&&q(s,t)?s:a[0]??null,l=typeof i.touchedAt==`number`&&Number.isFinite(i.touchedAt)?i.touchedAt:Date.now(),u=n[t];if(u){let e=Array.from(new Set([...u.openPaths,...a])),r=Array.from(new Set([...u.expandedPaths,...o])),i=u.selectedPath??c??e[0]??null;n[t]={openPaths:e,selectedPath:i,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},Y=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},X=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Z=i()(o(a((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=K((t||``).trim()),a=W((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!q(a,i)||e(e=>{let t=e.byRoot[i],n=X(t),r=n.openPaths.includes(a),o=r?n.openPaths:[...n.openPaths,a],s=n.selectedPath??a;return t&&r&&t.selectedPath===s?e:{byRoot:Y({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=G(i),a=e=>G(e)===n,o=t.selectedPath?a(t.selectedPath):!1;if(!t.openPaths.some(a)&&!o)return e;let s=t.openPaths.filter(e=>!a(e)),c=o?s[0]??null:t.selectedPath;return{byRoot:Y({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=G(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=G(e);return t===n||t.startsWith(a)},s=t.openPaths.filter(e=>!o(e));if(s.length===t.openPaths.length)return e;let c=t.selectedPath&&o(t.selectedPath)?s[0]??null:t.selectedPath;return{byRoot:Y({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=G(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=G(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:Y({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=K((t||``).trim()),a=n?W(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!q(a,i)||e(e=>{let t=e.byRoot[i],n=X(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:Y({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=K((e||``).trim());if(!n)return;let r=t().byRoot[n];if(!r||r.selectedPath)return;let i=r.openPaths[0]??null;i&&t().setSelectedPath(n,i)},toggleExpandedPath:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||!q(i,r)||e(e=>{let t=e.byRoot[r],n=X(t),a=n.expandedPaths.includes(i)?n.expandedPaths.filter(e=>e!==i):[...n.expandedPaths,i];return t&&t.expandedPaths===a&&t.selectedPath===n.selectedPath&&t.openPaths===n.openPaths?e:{byRoot:Y({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||!q(i,r)||e(e=>{let t=e.byRoot[r],n=X(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:Y({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=K((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>W((e||``).trim())).filter(e=>e&&q(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=X(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:Y({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:p(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:J(t)}},merge:(e,t)=>({...t,byRoot:J(e&&typeof e==`object`?e.byRoot:void 0)}),partialize:e=>({byRoot:J(e.byRoot)})}),{name:`files-view-tabs-store`})),Q=()=>{let e=(0,B.c)(17),t=F(Te),n=R(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=P(r),a=F(Ee),o=F(De),s=j(Oe),c=j(ke),u=l(Ae);if(t){let r;e[2]===i?r=e[3]:(r=N(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return u??void 0};function Te(e){return e.currentSessionId}function Ee(e){return e.worktreeMetadata}function De(e){return e.newSessionDraft}function Oe(e){return e.activeProjectId}function ke(e){return e.projects}function Ae(e){return e.currentDirectory}var $=s(),je=`bg-transparent font-[inherit] text-[var(--primary-base)]`,Me=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,$.jsx)(`mark`,{className:je,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},Ne=z.forwardRef((e,t)=>{let n=(0,B.c)(4),r=y(),i;return n[0]!==r||n[1]!==e||n[2]!==t?(i=r?.entry.location.hostId?(0,$.jsx)(Le,{...e,ref:t,entry:r.entry,registry:r.registry},JSON.stringify(r.entry.queryScope)):(0,$.jsx)(Pe,{...e,ref:t}),n[0]=r,n[1]=e,n[2]=t,n[3]=i):i=n[3],i}),Pe=z.forwardRef((e,t)=>{let n=(0,B.c)(22),r=Q()??``,i=F(ze),a=M(Be),o=!!e.onSessionSelect,s;n[0]===o?s=n[1]:(s={enabled:o},n[0]=o,n[1]=s);let c=A(s),l=j(Ve),u=j(He),f;if(n[2]!==l||n[3]!==r||n[4]!==u){let e=u.find(e=>e.id===l)?.path||r;f=e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null,n[2]=l,n[3]=r,n[4]=u,n[5]=f}else f=n[5];let p=f,m;n[6]===p?m=n[7]:(m=e=>p?e.byRoot[p]:void 0,n[6]=p,n[7]=m);let h=Z(m),g=k(Ue),_=d(We),v;n[8]!==a||n[9]!==c||n[10]!==e.onSessionSelect?(v=e.onSessionSelect?L(a,c):[],n[8]=a,n[9]=c,n[10]=e.onSessionSelect,n[11]=v):v=n[11];let y=v,b=e.currentSessionId??i,x;return n[12]!==g||n[13]!==r||n[14]!==p||n[15]!==h||n[16]!==e||n[17]!==t||n[18]!==_||n[19]!==y||n[20]!==b?(x=(0,$.jsx)(Re,{...e,ref:t,currentDirectory:r,currentSessionId:b,projectRoot:p,projectTabs:h,agentCatalog:g,sessions:y,searchFiles:_}),n[12]=g,n[13]=r,n[14]=p,n[15]=h,n[16]=e,n[17]=t,n[18]=_,n[19]=y,n[20]=b,n[21]=x):x=n[21],x}),Fe=[],Ie=[],Le=z.forwardRef((e,t)=>{let n=(0,B.c)(32),{entry:r,registry:i}=e,a=v(),o;n[0]===r?o=n[1]:(o=O(r.location.directory,void 0,r),n[0]=r,n[1]=o);let s=!!e.onAgentSelect,c;n[2]!==o||n[3]!==s?(c={...o,enabled:s},n[2]=o,n[3]=s,n[4]=c):c=n[4];let l=_(c),u;n[5]!==r||n[6]!==i?(u=V(i,r),n[5]=r,n[6]=i,n[7]=u):u=n[7];let d=!!e.onSessionSelect,f;n[8]!==u||n[9]!==d?(f={...u,enabled:d},n[8]=u,n[9]=d,n[10]=f):f=n[10];let p=_(f),m;n[11]===r.key?m=n[12]:(m=e=>e.byRoot[r.key],n[11]=r.key,n[12]=m);let h=Z(m),g;n[13]!==a||n[14]!==r?(g=(e,t,n,i)=>{let o=n===void 0?60:n;return a.fetchQuery(U(r,t,o,i))},n[13]=a,n[14]=r,n[15]=g):g=n[15];let y=x(g),b=r.location.directory,S;if(n[16]!==r.location.directory){let e;n[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\/+$/,n[18]=e):e=n[18],S=r.location.directory.replace(/\\/g,`/`).replace(e,``),n[16]=r.location.directory,n[17]=S}else S=n[17];let C=l.data??Ie,w=p.data??Fe,T=l.error??p.error,E;n[19]===r?E=n[20]:(E=()=>{r.sdk()},n[19]=r,n[20]=E);let D;return n[21]!==r.location.directory||n[22]!==h||n[23]!==e||n[24]!==t||n[25]!==y||n[26]!==C||n[27]!==w||n[28]!==T||n[29]!==E||n[30]!==S?(D=(0,$.jsx)(Re,{...e,ref:t,currentDirectory:b,projectRoot:S,projectTabs:h,agentCatalog:C,sessions:w,searchFiles:y,catalogError:T,assertCurrent:E}),n[21]=r.location.directory,n[22]=h,n[23]=e,n[24]=t,n[25]=y,n[26]=C,n[27]=w,n[28]=T,n[29]=E,n[30]=S,n[31]=D):D=n[31],D}),Re=z.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s,currentDirectory:c,currentSessionId:l,projectRoot:d,projectTabs:p,agentCatalog:m,sessions:h,searchFiles:g,catalogError:_,assertCurrent:v},y)=>{let{t:b}=ie(),w=oe(e,180),O=f(),k=u(),[A,ee]=z.useState([]),[j,M]=z.useState(!1),[N,P]=z.useState(null),[F,I]=z.useState(0),L=z.useRef(0),R=z.useRef({query:e,directory:c,ids:[]}),[re,le]=z.useState(360),[ue,_e]=z.useState({}),[ve,ye]=z.useState({}),be=z.useRef([]),B=z.useRef([]),Ce=z.useRef([]),V=z.useRef(null),we=z.useRef(null),H=z.useRef(null);H.current||=pe();let U=S(e=>e.isMobile),W=(e??``).trim(),G=te({directory:c||null}),K=z.useMemo(()=>r?G.data??[]:[],[r,G.data]),q=z.useMemo(()=>{if(!d||!p)return[];let e=[p.selectedPath,...p.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${d}/`)?e.slice(d.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return ge(n,W,{limit:6})},[W,d,p]),J=z.useMemo(()=>n?ne(m).filter(e=>e.mode!==`primary`):[],[m,n]),Y=z.useMemo(()=>i?me({sessions:h,currentSessionId:l??null,searchQuery:W}):[],[h,l,W,i]),X=q,Z=A,Q=z.useMemo(()=>ce({skills:K,agents:J,sessions:Y,recentFiles:X,pathHits:Z,searchQuery:W,untitledSession:b(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:b(`chat.fileMentionAutocomplete.sessionType`),skillBadge:b(`chat.commandAutocomplete.badge.skill`)}),[K,J,Y,X,Z,W,b]);z.useEffect(()=>{let e=e=>{let t=e.target;!t||!V.current||V.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),z.useEffect(()=>{if(!c){ee([]),M(!1),P(null);return}let e=(w??``).trim(),t=C(e);if(!t){ee([]),M(!1),P(null);return}let n=!1;M(!0),P(null);let r={includeHidden:O,respectGitignore:!k};return Promise.all([g(c,t,80,{...r,type:`file`}),g(c,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(q.map(e=>e.path));ee(he({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(e=>{n||P(e instanceof Error?e:Error(String(e)))}).finally(()=>{n||M(!1)}),()=>{n=!0}},[c,w,q,g,O,k]),z.useLayoutEffect(()=>{let t=R.current,n=t.ids[L.current],r=t.query===e&&t.directory===c?Math.max(0,Q.findIndex(e=>e.id===n)):0;R.current={query:e,directory:c,ids:Q.map(e=>e.id)},L.current=r,I(r)},[Q,e,c]),z.useEffect(()=>{_e({}),ye({})},[Q]),z.useEffect(()=>{be.current[F]?.scrollIntoView({block:`nearest`})},[F]),z.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};B.current.forEach((n,r)=>{if(!n)return;let i=Ce.current[r]?.offsetWidth??n.scrollWidth,a=Math.max(0,i-n.clientWidth),o=a>8;if(e[r]=o,o){let e=Math.max(.6,a/110);t[r]=e}}),_e(e),ye(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[Q]),z.useEffect(()=>{let e=B.current[F];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&le(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[F]);let Te=x(e=>{t(e)}),Ee=x(e=>{n?.(e)}),De=x(e=>{i?.(e)}),Oe=x(e=>{r?.(e)}),ke=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&H.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&H.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(H.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>H.current?.pointerCancel(),onClick:()=>{H.current?.click(t)},onMouseMove:()=>{L.current=e,I(e)}}),Ae=e=>{try{v?.()}catch(e){P(e instanceof Error?e:Error(String(e)));return}let t=Q.length;if(t===0)return;let n=(e%t+t)%t,r=Q[n];if(r.agentName!==void 0){Ee(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=K.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Oe(e);return}if(r.id.startsWith(`session:`)){let e=Y.find(e=>r.id===`session:${e.id}`);e&&De(e);return}let i=r.id.startsWith(`recent:`)?X.find(e=>r.id===`recent:${e.path}`):Z.find(e=>r.id===`file:${e.path}`);i&&Te(i)};z.useEffect(()=>{xe(s,we,{rows:Q,highlightedIndex:F})},[s,F,Q]);let je=z.useRef(s);return je.current=s,z.useEffect(()=>()=>{Se(je.current,we)},[]),z.useImperativeHandle(y,()=>({acceptIndex:e=>{Ae(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=Q.length;if(t!==0){if(e===`ArrowDown`){L.current=(L.current+1)%t,I(L.current);return}if(e===`ArrowUp`){L.current=(L.current-1+t)%t,I(L.current);return}(e===`Enter`||e===`Tab`)&&Ae(L.current)}}})),(0,$.jsxs)(de,{ref:V,isMobile:U,className:`max-w-[640px] max-h-64`,style:o,children:[(0,$.jsx)(ae,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,$.jsxs)(`div`,{className:`py-1`,children:[_||G.error||N?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:(_??G.error??N)?.message}):null,Q.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?E(e.title,{maxLength:60}):e.title,i=F===t,a=ue[t]??!1,o=ve[t]??2.6;return(0,$.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{be.current[t]=e},className:T(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,U&&`min-h-11`,fe(U,i),!U&&i&&`text-interactive-selection-foreground`),...ke(t,()=>Ae(t)),children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,$.jsx)(D,{name:e.iconName,className:`size-3.5 text-current`}):(0,$.jsx)(se,{name:e.agentName,size:20})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsxs)(`span`,{ref:e=>{B.current[t]=e},className:T(`relative block min-w-0 overflow-hidden`,n&&a&&i&&`file-mention-marquee-container`),style:i?{"--file-mention-marquee-width":`${re}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,$.jsx)(`span`,{ref:e=>{Ce.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,$.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Me(e.title,W)}):(0,$.jsx)(`span`,{className:`block truncate`,children:Me(r,W)})]}),e.trailingLabel?(0,$.jsx)(`span`,{className:T(`max-w-[40%] shrink-0 truncate text-muted-foreground`,U?`typography-micro`:`typography-meta`),children:e.trailingLabel}):null]}),e.subtitle?(0,$.jsx)(`div`,{className:T(`truncate text-muted-foreground`,U?`typography-micro`:`typography-meta`),children:Me(e.subtitle,W)}):null]})]},e.id)}),j&&Z.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,$.jsx)(D,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!j&&Q.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:b(`chat.fileMentionAutocomplete.empty`)})]})}),!U&&(0,$.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:b(`chat.autocomplete.keyboardHint`)})]})});function ze(e){return e.currentSessionId}function Be(e){return e.activeSessions}function Ve(e){return e.activeProjectId}function He(e){return e.projects}function Ue(e){return e.agents}function We(e){return e.searchFiles}var Ge=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`btw`]),Ke=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Ge.has(n))},qe=(e,t)=>!e||t({name:e}),Je=` `,Ye=(e,t)=>{let n=Math.max(0,Math.min(t,e.length)),r=n;for(;r>0&&!/\s/.test(e[r-1]);)--r;return r>=2&&e[r-1]===Je&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Xe=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Ze=T(Xe,`bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]`),Qe=T(Xe,`bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]`),$e=T(Xe,`bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]`),et=T(Xe,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),tt=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),nt=e=>{let t=!!e.sessionID;return{hasSession:t,canStartSessionCommand:t||e.hasNewDraft}},rt=z.forwardRef(({searchQuery:e,onCommandSelect:n,onClose:r,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=ie(),d=S(e=>e.isMobile),f=F(e=>e.currentSessionId),p=F(e=>!!e.newSessionDraft?.open),m=F(z.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=I(f??``,m??void 0),g=z.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v}=z.useMemo(()=>nt(g),[g]),y=g.hasMessages,[b,x]=z.useState([]),[C,w]=z.useState(!1),E=ee({directory:i}),O=z.useMemo(()=>E.data??[],[E.data]),k=E.isFetching,[A,j]=z.useState(0),M=z.useRef(0),N=z.useRef(!1),P=z.useRef([]),te=z.useRef(null),ne=z.useRef(!1),L=z.useRef(null),R=z.useRef(!1),re=z.useRef(null);z.useEffect(()=>{let e=e=>{let t=e.target;!t||!te.current||te.current.contains(t)||r()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[r]),z.useEffect(()=>{(async()=>{w(k);try{let n=O.flatMap((e,t)=>e.source===`skill`?[]:[{id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,scope:e.scope,reference:e.reference}]),r=[{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!y?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...t()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...n],i=!y,a=_e(r.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>tt(e,a)?e:a)}catch{let n=!y,r=_e([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!y?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...t()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[]].filter(e=>(n||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>tt(e,r)?e:r)}finally{w(!1)}})()},[e,y,_,v,O,k,u,o]),z.useEffect(()=>{j(0)},[b]),z.useEffect(()=>{M.current=A},[A]),z.useEffect(()=>{P.current[A]?.scrollIntoView({block:`nearest`})},[A]),z.useEffect(()=>{xe(c,re,{rows:ue(b,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:A})},[b,c,A,u]);let oe=z.useRef(c);oe.current=c,z.useEffect(()=>()=>{Se(oe.current,re)},[]),z.useImperativeHandle(l,()=>({acceptIndex:(e,t=!0)=>{let r=b[e];r&&n(r,Ke(r,t))},handleKeyDown:e=>{let t=b.length;if(e===`Escape`){r();return}if(t!==0){if(e===`ArrowDown`){N.current=!0,j(e=>(e+1)%t);return}if(e===`ArrowUp`){N.current=!0,j(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){let r=(M.current%t+t)%t,i=b[r];i&&n(i,Ke(i,e===`Enter`))}}}}),[b,r,n]);let se=e=>{let t=le(e);switch(e.name){case`new`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,$.jsxs)(de,{ref:te,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,$.jsx)(ae,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:C?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,$.jsx)(D,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,$.jsxs)(`div`,{children:[b.map((t,r)=>{let i=t.isBuiltIn,a=t.isYuri;return(0,$.jsxs)(`div`,{ref:e=>{P.current[r]=e},className:T(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,fe(d,r===A),!d&&r===A&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(L.current={x:e.clientX,y:e.clientY},R.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!L.current)return;let t=e.clientX-L.current.x,n=e.clientY-L.current.y;Math.hypot(t,n)>6&&(R.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=R.current;L.current=null,R.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),ne.current=!0,n(t,Ke(t,d)))},onPointerCancel:()=>{L.current=null,R.current=!1},onClick:()=>{if(ne.current){ne.current=!1;return}n(t,Ke(t,d))},onMouseMove:()=>{N.current=!1,j(r)},children:[(0,$.jsx)(`div`,{className:T(!d&&`mt-0.5`),children:se(t)}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,Me(t.name,e)]}),t.isSkill?(0,$.jsx)(`span`,{className:Ze,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,$.jsx)(`span`,{className:Ze,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,$.jsx)(`span`,{className:et,children:`Yuri`}):i?(0,$.jsx)(`span`,{className:et,children:u(`chat.commandAutocomplete.badge.system`)}):t.scope?(0,$.jsx)(`span`,{className:t.scope===`project`?$e:Qe,children:t.scope}):null,t.agent&&(0,$.jsx)(`span`,{className:et,children:t.agent})]}),t.description&&!d&&(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Me(t.description,e)})]})]},t.id)}),b.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,$.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});rt.displayName=`CommandAutocomplete`;var it=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},at=(e,t,n)=>{let r=it(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},ot=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=at(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},st=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))||e.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},ct=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{rt as a,Ne as c,we as d,H as f,at as i,Q as l,st as n,Ye as o,be as p,ot as r,qe as s,ct as t,Z as u};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{R as t,l as n,u as r}from"./platform-CiUKDeXd.js";import{a as i,i as a,r as o}from"./vendor-zustand-CTekDqaS.js";import{ot as s,st as c}from"./vendor-base-ui-wXsskyKm.js";import{St as l,an as u,jt as d,on as f}from"./gitApiHttp-Dd-FwgCq.js";import{t as p}from"./safeStorage-DTOhKN0V.js";import{i as m,t as h}from"./vendor-pathe-vBmvQE8f.js";import{n as g}from"./vendor-react-BkccXcWz.js";import{s as _,u as v}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{E as y}from"./runtime-file-resource-Bc_ss-sW.js";import{o as b}from"./path-utils-jGozTg9d.js";import{r as x}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as S}from"./useUIStore-C3ewjGgP.js";import{o as C,s as w}from"./spacedFileMention-Ds4GtgiF.js";import{o as T,p as E}from"./session-startup-barrier-DT-hIBRf.js";import{n as D}from"./Icon-DmykXZL1.js";import{Da as O,Hi as k,L as A,Ma as ee,Na as j,Oi as M,_ as N,b as P,f as F,lt as I,ma as te,ra as ne,xi as L,yt as R}from"./ui-ee2iN869.js";import{s as re}from"./remoteProjectQueries-C8382jM8.js";import{t as ie}from"./i18n-DXc6czdR.js";import{t as ae}from"./ScrollableOverlay-stxT7gLf.js";import{t as oe}from"./useDebouncedValue-BHlMPqY8.js";import{t as se}from"./AgentAvatar-CHCjMxCF.js";import{c as ce,d as le,l as ue,n as de,r as fe,t as pe}from"./fileMentionTouchSelection-BQEUty_A.js";import{a as me,o as he,s as ge}from"./fileMentionAutocompleteState-B9411b4o.js";var _e=(e,t)=>{let n=t.trim();if(!n)return[...e].sort((e,t)=>e.isBuiltIn===t.isBuiltIn?e.name.localeCompare(t.name):e.isBuiltIn?-1:1);let r=w([...e],n,e=>[e.name,e.description??``]);return r.sort((e,t)=>e.score===t.score?e.item.isBuiltIn===t.item.isBuiltIn?e.item.name.localeCompare(t.item.name):e.item.isBuiltIn?-1:1:e.score-t.score),r.map(e=>e.item)},ve=(e,t)=>e===t||e.length===t.length&&e.every((e,n)=>{let r=t[n];return r!=null&&e.id===r.id&&e.title===r.title&&(e.subtitle??``)===(r.subtitle??``)&&(e.badge??``)===(r.badge??``)&&e.iconName===r.iconName&&e.agentName===r.agentName}),ye=(e,t)=>e.highlightedIndex===t.highlightedIndex&&ve(e.rows,t.rows),be=(e,t)=>ve(e,t)?e:t.slice(),xe=(e,t,n)=>{e&&(t.current&&ye(t.current,n)||(t.current=n,e(n)))},Se=(e,t)=>{t.current=null,e?.({rows:[],highlightedIndex:0})},z=e(c(),1),B=g(),Ce=e=>e.directories.flatMap(e=>e.sessions),V=(e,t)=>({...re(e,t.location.hostId),select:Ce}),we=async(e,t,n)=>{n.sdk();let r=await e.fetchQuery(V(t,n));return n.sdk(),Ce(r)},H=(e,t,n,r)=>{n.sdk();let i=e.getQueryData(V(t,n).queryKey);for(let e of i?.directories??[]){let t=e.sessions.find(e=>e.id===r);if(t)return t.title||r}return r},U=(e,t,n,r={})=>({queryKey:[...e.queryScope,`composer-files`,t,n,r],staleTime:3e4,gcTime:3e4,queryFn:async({signal:i})=>{let a=await e.sdk().file.find({query:t,location:{directory:e.location.directory},limit:n,type:r.type},{signal:i});if(e.sdk(),i.throwIfAborted(),!Array.isArray(a.data))throw Error(`File search returned no data`);return a.data.map(t=>{let n=m(t.path),r=h(n);return{name:r,path:b(e.location.directory,n),relativePath:n,extension:r.includes(`.`)?r.split(`.`).pop()?.toLowerCase():void 0,isDirectory:t.type===`directory`}})}}),W=e=>{if(!e)return``;let t=e.replace(/\\/g,`/`),n=t.startsWith(`//`),r=t.replace(/\/+/g,`/`);n&&!r.startsWith(`//`)&&(r=`/${r}`);let i=r===`/`,a=/^[A-Za-z]:\/$/.test(r);return!i&&!a&&(r=r.replace(/\/+$/,``)),r},G=e=>/^[A-Za-z]:\//.test(e)?e.toLowerCase():e,K=e=>e.startsWith(`yuri-remote-location:`)?n(e):W(e),q=(e,t)=>{let n=W(r(t,`local`).directory),i=W(e);if(!n||!i)return!1;let a=G(n),o=G(i);return o===a||o.startsWith(a.endsWith(`/`)?a:`${a}/`)},J=e=>{if(!e||typeof e!=`object`)return{};let t=e,n={};for(let[e,r]of Object.entries(t)){let t;try{t=K(e)}catch{continue}if(!t||!r||typeof r!=`object`)continue;let i=r,a=Array.isArray(i.openPaths)?Array.from(new Set(i.openPaths.filter(e=>typeof e==`string`).map(e=>W(e)).filter(e=>q(e,t)))):[],o=Array.isArray(i.expandedPaths)?Array.from(new Set(i.expandedPaths.filter(e=>typeof e==`string`).map(e=>W(e)).filter(e=>q(e,t)))):[],s=typeof i.selectedPath==`string`?W(i.selectedPath):null,c=s&&q(s,t)?s:a[0]??null,l=typeof i.touchedAt==`number`&&Number.isFinite(i.touchedAt)?i.touchedAt:Date.now(),u=n[t];if(u){let e=Array.from(new Set([...u.openPaths,...a])),r=Array.from(new Set([...u.expandedPaths,...o])),i=u.selectedPath??c??e[0]??null;n[t]={openPaths:e,selectedPath:i,expandedPaths:r,touchedAt:Math.max(u.touchedAt,l)};continue}n[t]={openPaths:a,selectedPath:c,expandedPaths:o,touchedAt:l}}return n},Y=(e,t)=>{let n=Object.entries(e);if(n.length<=t)return e;n.sort((e,t)=>(t[1]?.touchedAt??0)-(e[1]?.touchedAt??0));let r={};for(let[e,i]of n.slice(0,t))r[e]=i;return r},X=e=>e?{...e,touchedAt:Date.now()}:{openPaths:[],selectedPath:null,expandedPaths:[],touchedAt:Date.now()},Z=i()(o(a((e,t)=>({byRoot:{},addOpenPath:(t,n,r)=>{let i=K((t||``).trim()),a=W((n||``).trim());!i||!a||!r?.allowOutsideRoot&&!q(a,i)||e(e=>{let t=e.byRoot[i],n=X(t),r=n.openPaths.includes(a),o=r?n.openPaths:[...n.openPaths,a],s=n.selectedPath??a;return t&&r&&t.selectedPath===s?e:{byRoot:Y({...e.byRoot,[i]:{...n,openPaths:o,selectedPath:s}},20)}})},removeOpenPath:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=G(i),a=e=>G(e)===n,o=t.selectedPath?a(t.selectedPath):!1;if(!t.openPaths.some(a)&&!o)return e;let s=t.openPaths.filter(e=>!a(e)),c=o?s[0]??null:t.selectedPath;return{byRoot:Y({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeOpenPathsByPrefix:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=G(i),a=n.endsWith(`/`)?n:`${n}/`,o=e=>{let t=G(e);return t===n||t.startsWith(a)},s=t.openPaths.filter(e=>!o(e));if(s.length===t.openPaths.length)return e;let c=t.selectedPath&&o(t.selectedPath)?s[0]??null:t.selectedPath;return{byRoot:Y({...e.byRoot,[r]:{...t,openPaths:s,selectedPath:c,touchedAt:Date.now()}},20)}})},removeExpandedPathsByPrefix:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||e(e=>{let t=e.byRoot[r];if(!t)return e;let n=G(i),a=n.endsWith(`/`)?n:`${n}/`,o=t.expandedPaths.filter(e=>{let t=G(e);return t!==n&&!t.startsWith(a)});return o.length===t.expandedPaths.length?e:{byRoot:Y({...e.byRoot,[r]:{...t,expandedPaths:o,touchedAt:Date.now()}},20)}})},setSelectedPath:(t,n,r)=>{let i=K((t||``).trim()),a=n?W(n.trim()):null;!i||a&&!r?.allowOutsideRoot&&!q(a,i)||e(e=>{let t=e.byRoot[i],n=X(t),r=a&&!n.openPaths.includes(a)?[...n.openPaths,a]:n.openPaths;return t&&t.selectedPath===a&&r===t.openPaths?e:{byRoot:Y({...e.byRoot,[i]:{...n,openPaths:r,selectedPath:a}},20)}})},ensureSelectedPath:e=>{let n=K((e||``).trim());if(!n)return;let r=t().byRoot[n];if(!r||r.selectedPath)return;let i=r.openPaths[0]??null;i&&t().setSelectedPath(n,i)},toggleExpandedPath:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||!q(i,r)||e(e=>{let t=e.byRoot[r],n=X(t),a=n.expandedPaths.includes(i)?n.expandedPaths.filter(e=>e!==i):[...n.expandedPaths,i];return t&&t.expandedPaths===a&&t.selectedPath===n.selectedPath&&t.openPaths===n.openPaths?e:{byRoot:Y({...e.byRoot,[r]:{...n,expandedPaths:a}},20)}})},expandPath:(t,n)=>{let r=K((t||``).trim()),i=W((n||``).trim());!r||!i||!q(i,r)||e(e=>{let t=e.byRoot[r],n=X(t);return n.expandedPaths.includes(i)&&t?e:{byRoot:Y({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,i]}},20)}})},expandPaths:(t,n)=>{let r=K((t||``).trim());if(!r||!n||n.length===0)return;let i=n.map(e=>W((e||``).trim())).filter(e=>e&&q(e,r));i.length!==0&&e(e=>{let t=e.byRoot[r],n=X(t),a=new Set(n.expandedPaths),o=i.filter(e=>!a.has(e));return o.length===0?e:{byRoot:Y({...e.byRoot,[r]:{...n,expandedPaths:[...n.expandedPaths,...o]}},20)}})}}),{name:`files-view-tabs-store`,version:2,storage:p(),migrate:e=>{if(!e||typeof e!=`object`)return{byRoot:{}};let t=e.byRoot;return{byRoot:J(t)}},merge:(e,t)=>({...t,byRoot:J(e&&typeof e==`object`?e.byRoot:void 0)}),partialize:e=>({byRoot:J(e.byRoot)})}),{name:`files-view-tabs-store`})),Q=()=>{let e=(0,B.c)(17),t=F(Te),n=R(),r;e[0]===t?r=e[1]:(r=e=>t?e.getAttachment(t):void 0,e[0]=t,e[1]=r);let i=P(r),a=F(Ee),o=F(De),s=j(Oe),c=j(ke),u=l(Ae);if(t){let r;e[2]===i?r=e[3]:(r=N(i),e[2]=i,e[3]=r);let o=r;if(o)return o;let s;e[4]!==t||e[5]!==a?(s=a.get(t),e[4]=t,e[5]=a,e[6]=s):s=e[6];let c=s;if(c?.path)return c.path;let l;if(e[7]!==t||e[8]!==n){let r;e[10]===t?r=e[11]:(r=e=>e.id===t,e[10]=t,e[11]=r),l=n.find(r),e[7]=t,e[8]=n,e[9]=l}else l=e[9];let u=l;if(u?.directory)return u.directory}if(o?.open&&(o.bootstrapPendingDirectory||o.directoryOverride))return(o.bootstrapPendingDirectory||o.directoryOverride)??void 0;if(s){let t;if(e[12]!==s||e[13]!==c){let n;e[15]===s?n=e[16]:(n=e=>e.id===s,e[15]=s,e[16]=n),t=c.find(n),e[12]=s,e[13]=c,e[14]=t}else t=e[14];let n=t;if(n?.path)return n.path}return u??void 0};function Te(e){return e.currentSessionId}function Ee(e){return e.worktreeMetadata}function De(e){return e.newSessionDraft}function Oe(e){return e.activeProjectId}function ke(e){return e.projects}function Ae(e){return e.currentDirectory}var $=s(),je=`bg-transparent font-[inherit] text-[var(--primary-base)]`,Me=(e,t)=>{let n=t.trim().toLowerCase();if(!n)return e;let r=e.toLowerCase();if(!r.includes(n))return e;let i=[],a=0,o=r.indexOf(n);for(;o!==-1;)o>a&&i.push(e.slice(a,o)),i.push((0,$.jsx)(`mark`,{className:je,children:e.slice(o,o+n.length)},`${o}-${n}`)),a=o+n.length,o=r.indexOf(n,a);return a<e.length&&i.push(e.slice(a)),i},Ne=z.forwardRef((e,t)=>{let n=(0,B.c)(4),r=y(),i;return n[0]!==r||n[1]!==e||n[2]!==t?(i=r?.entry.location.hostId?(0,$.jsx)(Le,{...e,ref:t,entry:r.entry,registry:r.registry},JSON.stringify(r.entry.queryScope)):(0,$.jsx)(Pe,{...e,ref:t}),n[0]=r,n[1]=e,n[2]=t,n[3]=i):i=n[3],i}),Pe=z.forwardRef((e,t)=>{let n=(0,B.c)(22),r=Q()??``,i=F(ze),a=M(Be),o=!!e.onSessionSelect,s;n[0]===o?s=n[1]:(s={enabled:o},n[0]=o,n[1]=s);let c=A(s),l=j(Ve),u=j(He),f;if(n[2]!==l||n[3]!==r||n[4]!==u){let e=u.find(e=>e.id===l)?.path||r;f=e?e.replace(/\\/g,`/`).replace(/\/+$/,``):null,n[2]=l,n[3]=r,n[4]=u,n[5]=f}else f=n[5];let p=f,m;n[6]===p?m=n[7]:(m=e=>p?e.byRoot[p]:void 0,n[6]=p,n[7]=m);let h=Z(m),g=k(Ue),_=d(We),v;n[8]!==a||n[9]!==c||n[10]!==e.onSessionSelect?(v=e.onSessionSelect?L(a,c):[],n[8]=a,n[9]=c,n[10]=e.onSessionSelect,n[11]=v):v=n[11];let y=v,b=e.currentSessionId??i,x;return n[12]!==g||n[13]!==r||n[14]!==p||n[15]!==h||n[16]!==e||n[17]!==t||n[18]!==_||n[19]!==y||n[20]!==b?(x=(0,$.jsx)(Re,{...e,ref:t,currentDirectory:r,currentSessionId:b,projectRoot:p,projectTabs:h,agentCatalog:g,sessions:y,searchFiles:_}),n[12]=g,n[13]=r,n[14]=p,n[15]=h,n[16]=e,n[17]=t,n[18]=_,n[19]=y,n[20]=b,n[21]=x):x=n[21],x}),Fe=[],Ie=[],Le=z.forwardRef((e,t)=>{let n=(0,B.c)(32),{entry:r,registry:i}=e,a=v(),o;n[0]===r?o=n[1]:(o=O(r.location.directory,void 0,r),n[0]=r,n[1]=o);let s=!!e.onAgentSelect,c;n[2]!==o||n[3]!==s?(c={...o,enabled:s},n[2]=o,n[3]=s,n[4]=c):c=n[4];let l=_(c),u;n[5]!==r||n[6]!==i?(u=V(i,r),n[5]=r,n[6]=i,n[7]=u):u=n[7];let d=!!e.onSessionSelect,f;n[8]!==u||n[9]!==d?(f={...u,enabled:d},n[8]=u,n[9]=d,n[10]=f):f=n[10];let p=_(f),m;n[11]===r.key?m=n[12]:(m=e=>e.byRoot[r.key],n[11]=r.key,n[12]=m);let h=Z(m),g;n[13]!==a||n[14]!==r?(g=(e,t,n,i)=>{let o=n===void 0?60:n;return a.fetchQuery(U(r,t,o,i))},n[13]=a,n[14]=r,n[15]=g):g=n[15];let y=x(g),b=r.location.directory,S;if(n[16]!==r.location.directory){let e;n[18]===Symbol.for(`react.memo_cache_sentinel`)?(e=/\/+$/,n[18]=e):e=n[18],S=r.location.directory.replace(/\\/g,`/`).replace(e,``),n[16]=r.location.directory,n[17]=S}else S=n[17];let C=l.data??Ie,w=p.data??Fe,T=l.error??p.error,E;n[19]===r?E=n[20]:(E=()=>{r.sdk()},n[19]=r,n[20]=E);let D;return n[21]!==r.location.directory||n[22]!==h||n[23]!==e||n[24]!==t||n[25]!==y||n[26]!==C||n[27]!==w||n[28]!==T||n[29]!==E||n[30]!==S?(D=(0,$.jsx)(Re,{...e,ref:t,currentDirectory:b,projectRoot:S,projectTabs:h,agentCatalog:C,sessions:w,searchFiles:y,catalogError:T,assertCurrent:E}),n[21]=r.location.directory,n[22]=h,n[23]=e,n[24]=t,n[25]=y,n[26]=C,n[27]=w,n[28]=T,n[29]=E,n[30]=S,n[31]=D):D=n[31],D}),Re=z.forwardRef(({searchQuery:e,onFileSelect:t,onAgentSelect:n,onSkillSelect:r,onSessionSelect:i,onClose:a,style:o,onRowsChange:s,currentDirectory:c,currentSessionId:l,projectRoot:d,projectTabs:p,agentCatalog:m,sessions:h,searchFiles:g,catalogError:_,assertCurrent:v},y)=>{let{t:b}=ie(),w=oe(e,180),O=f(),k=u(),[A,ee]=z.useState([]),[j,M]=z.useState(!1),[N,P]=z.useState(null),[F,I]=z.useState(0),L=z.useRef(0),R=z.useRef({query:e,directory:c,ids:[]}),[re,le]=z.useState(360),[ue,_e]=z.useState({}),[ve,ye]=z.useState({}),be=z.useRef([]),B=z.useRef([]),Ce=z.useRef([]),V=z.useRef(null),we=z.useRef(null),H=z.useRef(null);H.current||=pe();let U=S(e=>e.isMobile),W=(e??``).trim(),G=te({directory:c||null}),K=z.useMemo(()=>r?G.data??[]:[],[r,G.data]),q=z.useMemo(()=>{if(!d||!p)return[];let e=[p.selectedPath,...p.openPaths.slice().reverse()].filter(e=>typeof e==`string`&&e.length>0),t=new Set,n=[];for(let r of e){if(t.has(r))continue;t.add(r);let e=r.replace(/\\/g,`/`),i=e.split(`/`).filter(Boolean).pop()||e,a=e.startsWith(`${d}/`)?e.slice(d.length+1):e;n.push({name:i,path:e,relativePath:a,extension:i.includes(`.`)?i.split(`.`).pop()?.toLowerCase():void 0})}return ge(n,W,{limit:6})},[W,d,p]),J=z.useMemo(()=>n?ne(m).filter(e=>e.mode!==`primary`):[],[m,n]),Y=z.useMemo(()=>i?me({sessions:h,currentSessionId:l??null,searchQuery:W}):[],[h,l,W,i]),X=q,Z=A,Q=z.useMemo(()=>ce({skills:K,agents:J,sessions:Y,recentFiles:X,pathHits:Z,searchQuery:W,untitledSession:b(`chat.fileMentionAutocomplete.untitledSession`),sessionBadge:b(`chat.fileMentionAutocomplete.sessionType`),skillBadge:b(`chat.commandAutocomplete.badge.skill`)}),[K,J,Y,X,Z,W,b]);z.useEffect(()=>{let e=e=>{let t=e.target;!t||!V.current||V.current.contains(t)||a()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[a]),z.useEffect(()=>{if(!c){ee([]),M(!1),P(null);return}let e=(w??``).trim(),t=C(e);if(!t){ee([]),M(!1),P(null);return}let n=!1;M(!0),P(null);let r={includeHidden:O,respectGitignore:!k};return Promise.all([g(c,t,80,{...r,type:`file`}),g(c,t,40,{...r,type:`directory`})]).then(([t,r])=>{if(n)return;let i=new Set(q.map(e=>e.path));ee(he({files:t,directories:r,query:e,excludePaths:i,limit:20}))}).catch(e=>{n||P(e instanceof Error?e:Error(String(e)))}).finally(()=>{n||M(!1)}),()=>{n=!0}},[c,w,q,g,O,k]),z.useLayoutEffect(()=>{let t=R.current,n=t.ids[L.current],r=t.query===e&&t.directory===c?Math.max(0,Q.findIndex(e=>e.id===n)):0;R.current={query:e,directory:c,ids:Q.map(e=>e.id)},L.current=r,I(r)},[Q,e,c]),z.useEffect(()=>{_e({}),ye({})},[Q]),z.useEffect(()=>{be.current[F]?.scrollIntoView({block:`nearest`})},[F]),z.useEffect(()=>{let e=null,t=()=>{e!==null&&cancelAnimationFrame(e),e=requestAnimationFrame(()=>{let e={},t={};B.current.forEach((n,r)=>{if(!n)return;let i=Ce.current[r]?.offsetWidth??n.scrollWidth,a=Math.max(0,i-n.clientWidth),o=a>8;if(e[r]=o,o){let e=Math.max(.6,a/110);t[r]=e}}),_e(e),ye(t)})};return t(),window.addEventListener(`resize`,t),()=>{e!==null&&cancelAnimationFrame(e),window.removeEventListener(`resize`,t)}},[Q]),z.useEffect(()=>{let e=B.current[F];if(!e)return;let t=()=>{let t=e.clientWidth;t>0&&le(t)};if(t(),typeof ResizeObserver>`u`)return;let n=new ResizeObserver(t);return n.observe(e),()=>{n.disconnect()}},[F]);let Te=x(e=>{t(e)}),Ee=x(e=>{n?.(e)}),De=x(e=>{i?.(e)}),Oe=x(e=>{r?.(e)}),ke=(e,t)=>({onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&H.current?.pointerDown(e.clientX,e.clientY)},onPointerMove:e=>{e.pointerType===`touch`&&H.current?.pointerMove(e.clientX,e.clientY)},onPointerUp:e=>{e.pointerType===`touch`&&(H.current?.pointerUp(t)??!1)&&(e.preventDefault(),e.stopPropagation())},onPointerCancel:()=>H.current?.pointerCancel(),onClick:()=>{H.current?.click(t)},onMouseMove:()=>{L.current=e,I(e)}}),Ae=e=>{try{v?.()}catch(e){P(e instanceof Error?e:Error(String(e)));return}let t=Q.length;if(t===0)return;let n=(e%t+t)%t,r=Q[n];if(r.agentName!==void 0){Ee(r.agentName);return}if(r.id.startsWith(`skill:`)){let e=K.find(e=>r.id===`skill:${e.name}-${e.scope}`);e&&Oe(e);return}if(r.id.startsWith(`session:`)){let e=Y.find(e=>r.id===`session:${e.id}`);e&&De(e);return}let i=r.id.startsWith(`recent:`)?X.find(e=>r.id===`recent:${e.path}`):Z.find(e=>r.id===`file:${e.path}`);i&&Te(i)};z.useEffect(()=>{xe(s,we,{rows:Q,highlightedIndex:F})},[s,F,Q]);let je=z.useRef(s);return je.current=s,z.useEffect(()=>()=>{Se(je.current,we)},[]),z.useImperativeHandle(y,()=>({acceptIndex:e=>{Ae(e)},handleKeyDown:e=>{if(e===`Escape`){a();return}let t=Q.length;if(t!==0){if(e===`ArrowDown`){L.current=(L.current+1)%t,I(L.current);return}if(e===`ArrowUp`){L.current=(L.current-1+t)%t,I(L.current);return}(e===`Enter`||e===`Tab`)&&Ae(L.current)}}})),(0,$.jsxs)(de,{ref:V,isMobile:U,className:`max-w-[640px] max-h-64`,style:o,children:[(0,$.jsx)(ae,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0`,children:(0,$.jsxs)(`div`,{className:`py-1`,children:[_||G.error||N?(0,$.jsx)(`div`,{role:`alert`,className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:(_??G.error??N)?.message}):null,Q.map((e,t)=>{let n=e.id.startsWith(`file:`)||e.id.startsWith(`recent:`),r=n?E(e.title,{maxLength:60}):e.title,i=F===t,a=ue[t]??!1,o=ve[t]??2.6;return(0,$.jsxs)(`div`,{"data-mention-id":e.id,ref:e=>{be.current[t]=e},className:T(`flex items-center gap-2 px-3 py-1.5 cursor-pointer typography-ui-label rounded-lg`,U&&`min-h-11`,fe(U,i),!U&&i&&`text-interactive-selection-foreground`),...ke(t,()=>Ae(t)),children:[(0,$.jsx)(`span`,{className:`flex size-5 shrink-0 items-center justify-center`,children:e.agentName===void 0?(0,$.jsx)(D,{name:e.iconName,className:`size-3.5 text-current`}):(0,$.jsx)(se,{name:e.agentName,size:20})}),(0,$.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,$.jsxs)(`div`,{className:`flex min-w-0 items-baseline gap-2`,children:[(0,$.jsxs)(`span`,{ref:e=>{B.current[t]=e},className:T(`relative block min-w-0 overflow-hidden`,n&&a&&i&&`file-mention-marquee-container`),style:i?{"--file-mention-marquee-width":`${re}px`,"--file-mention-marquee-duration":`${o}s`}:void 0,title:e.title,children:[(0,$.jsx)(`span`,{ref:e=>{Ce.current[t]=e},className:`absolute invisible whitespace-nowrap pointer-events-none`,"aria-hidden":!0,children:e.title}),n&&a&&i?(0,$.jsx)(`span`,{className:`inline-block whitespace-nowrap file-mention-marquee`,children:Me(e.title,W)}):(0,$.jsx)(`span`,{className:`block truncate`,children:Me(r,W)})]}),e.trailingLabel?(0,$.jsx)(`span`,{className:T(`max-w-[40%] shrink-0 truncate text-muted-foreground`,U?`typography-micro`:`typography-meta`),children:e.trailingLabel}):null]}),e.subtitle?(0,$.jsx)(`div`,{className:T(`truncate text-muted-foreground`,U?`typography-micro`:`typography-meta`),children:Me(e.subtitle,W)}):null]})]},e.id)}),j&&Z.length===0?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-3`,children:(0,$.jsx)(D,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):null,!j&&Q.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:b(`chat.fileMentionAutocomplete.empty`)})]})}),!U&&(0,$.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:b(`chat.autocomplete.keyboardHint`)})]})});function ze(e){return e.currentSessionId}function Be(e){return e.activeSessions}function Ve(e){return e.activeProjectId}function He(e){return e.projects}function Ue(e){return e.agents}function We(e){return e.searchFiles}var Ge=new Set([`new`,`fork`,`compact`,`reload`,`undo`,`redo`,`model`,`btw`]),Ke=(e,t)=>{if(!t||e.isSkill)return!1;let n=e.name?.trim().toLowerCase();return!!(n&&Ge.has(n))},qe=(e,t)=>!e||t({name:e}),Je=` `,Ye=(e,t)=>{let n=Math.max(0,Math.min(t,e.length)),r=n;for(;r>0&&!/\s/.test(e[r-1]);)--r;return r>=2&&e[r-1]===Je&&e[r-2]===`/`&&(r-=2),e[r]===`/`?{start:r,end:n}:null},Xe=`text-[10px] leading-none uppercase font-bold tracking-tight px-1.5 py-1 rounded border flex-shrink-0`,Ze=T(Xe,`bg-[color-mix(in_srgb,var(--primary-base)_12%,transparent)] text-[color-mix(in_srgb,var(--primary-base)_70%,transparent)] border-[color-mix(in_srgb,var(--primary-base)_24%,transparent)]`),Qe=T(Xe,`bg-[color-mix(in_srgb,var(--status-success)_12%,transparent)] text-[color-mix(in_srgb,var(--status-success)_70%,transparent)] border-[color-mix(in_srgb,var(--status-success)_24%,transparent)]`),$e=T(Xe,`bg-[color-mix(in_srgb,var(--status-info)_12%,transparent)] text-[color-mix(in_srgb,var(--status-info)_70%,transparent)] border-[color-mix(in_srgb,var(--status-info)_24%,transparent)]`),et=T(Xe,`bg-[var(--surface-muted)] text-muted-foreground border-[var(--interactive-border)]/60`),tt=(e,t)=>e.length===t.length&&e.every((e,n)=>e.id===t[n]?.id&&e.description===t[n]?.description),nt=e=>{let t=!!e.sessionID;return{hasSession:t,canStartSessionCommand:t||e.hasNewDraft}},rt=z.forwardRef(({searchQuery:e,onCommandSelect:n,onClose:r,directory:i,style:a,commandPolicy:o,commandContext:s,onRowsChange:c},l)=>{let{t:u}=ie(),d=S(e=>e.isMobile),f=F(e=>e.currentSessionId),p=F(e=>!!e.newSessionDraft?.open),m=F(z.useCallback(e=>f?e.getDirectoryForSession(f):void 0,[f])),h=I(f??``,m??void 0),g=z.useMemo(()=>s??{sessionID:f??null,hasMessages:h.length>0,hasNewDraft:p},[s,f,h.length,p]),{hasSession:_,canStartSessionCommand:v}=z.useMemo(()=>nt(g),[g]),y=g.hasMessages,[b,x]=z.useState([]),[C,w]=z.useState(!1),E=ee({directory:i}),O=z.useMemo(()=>E.data??[],[E.data]),k=E.isFetching,[A,j]=z.useState(0),M=z.useRef(0),N=z.useRef(!1),P=z.useRef([]),te=z.useRef(null),ne=z.useRef(!1),L=z.useRef(null),R=z.useRef(!1),re=z.useRef(null);z.useEffect(()=>{let e=e=>{let t=e.target;!t||!te.current||te.current.contains(t)||r()};return document.addEventListener(`pointerdown`,e,!0),()=>{document.removeEventListener(`pointerdown`,e,!0)}},[r]),z.useEffect(()=>{(async()=>{w(k);try{let n=O.flatMap((e,t)=>e.source===`skill`?[]:[{id:`opencode:${e.scope??`global`}:${e.name}:${e.agent??``}:${e.model??``}:${t}`,name:e.name,source:`opencode`,description:e.description,agent:e.agent??void 0,model:e.model??void 0,isBuiltIn:e.isBuiltIn,scope:e.scope,reference:e.reference}]),r=[{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!y?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...t()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[],...n],i=!y,a=_e(r.filter(e=>(i||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>tt(e,a)?e:a)}catch{let n=!y,r=_e([{id:`yuri:new`,name:`new`,source:`yuri`,description:u(`chat.commandAutocomplete.command.newDescription`),isBuiltIn:!0},..._&&!y?[{id:`yuri:init`,name:`init`,source:`yuri`,description:u(`chat.commandAutocomplete.command.initDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:btw`,name:`btw`,source:`yuri`,description:u(`chat.btw.description`),isBuiltIn:!0},{id:`yuri:undo`,name:`undo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.undoDescription`),isBuiltIn:!0},{id:`yuri:redo`,name:`redo`,source:`yuri`,description:u(`chat.commandAutocomplete.command.redoDescription`),isBuiltIn:!0},{id:`yuri:fork`,name:`fork`,source:`yuri`,description:u(`chat.commandAutocomplete.command.forkDescription`),isBuiltIn:!0},{id:`yuri:timeline`,name:`timeline`,source:`yuri`,description:u(`chat.commandAutocomplete.command.timelineDescription`),isBuiltIn:!0}]:[],{id:`yuri:model`,name:`model`,source:`yuri`,description:u(`chat.commandAutocomplete.command.modelDescription`),isBuiltIn:!0},{id:`yuri:compact`,name:`compact`,source:`yuri`,description:u(`chat.commandAutocomplete.command.compactDescription`),isBuiltIn:!0},...t()?[{id:`yuri:reload`,name:`reload`,source:`yuri`,description:u(`chat.commandAutocomplete.command.reloadDescription`),isBuiltIn:!0}]:[],..._?[{id:`yuri:summary`,name:`summary`,source:`yuri`,description:u(`chat.commandAutocomplete.command.summaryDescription`),isYuri:!0}]:[],...v?[{id:`yuri:workspace-review`,name:`workspace-review`,source:`yuri`,description:u(`chat.commandAutocomplete.command.workspaceReviewDescription`),isYuri:!0}]:[],...v?[{id:`yuri:craft-goal`,name:`craft-goal`,source:`yuri`,description:u(`chat.commandAutocomplete.command.craftGoalDescription`),isYuri:!0}]:[],...v?[{id:`yuri:catch-up`,name:`catch-up`,source:`yuri`,description:u(`chat.commandAutocomplete.command.catchUpDescription`),isYuri:!0}]:[],...v?[{id:`yuri:debug`,name:`debug`,source:`yuri`,description:u(`chat.commandAutocomplete.command.debugDescription`),isYuri:!0}]:[],...v?[{id:`yuri:weigh`,name:`weigh`,source:`yuri`,description:u(`chat.commandAutocomplete.command.weighDescription`),isYuri:!0}]:[],...v?[{id:`yuri:explore`,name:`explore`,source:`yuri`,description:u(`chat.commandAutocomplete.command.exploreDescription`),isYuri:!0}]:[]].filter(e=>(n||e.name!==`init`)&&(o?.(e)??!0)),e);x(e=>tt(e,r)?e:r)}finally{w(!1)}})()},[e,y,_,v,O,k,u,o]),z.useEffect(()=>{j(0)},[b]),z.useEffect(()=>{M.current=A},[A]),z.useEffect(()=>{P.current[A]?.scrollIntoView({block:`nearest`})},[A]),z.useEffect(()=>{xe(c,re,{rows:ue(b,{skill:u(`chat.commandAutocomplete.badge.skill`),command:u(`chat.commandAutocomplete.badge.command`),system:u(`chat.commandAutocomplete.badge.system`)}),highlightedIndex:A})},[b,c,A,u]);let oe=z.useRef(c);oe.current=c,z.useEffect(()=>()=>{Se(oe.current,re)},[]),z.useImperativeHandle(l,()=>({acceptIndex:(e,t=!0)=>{let r=b[e];r&&n(r,Ke(r,t))},handleKeyDown:e=>{let t=b.length;if(e===`Escape`){r();return}if(t!==0){if(e===`ArrowDown`){N.current=!0,j(e=>(e+1)%t);return}if(e===`ArrowUp`){N.current=!0,j(e=>(e-1+t)%t);return}if(e===`Enter`||e===`Tab`){let r=(M.current%t+t)%t,i=b[r];i&&n(i,Ke(i,e===`Enter`))}}}}),[b,r,n]);let se=e=>{let t=le(e);switch(e.name){case`new`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5`});case`init`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-green-500`});case`undo`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`redo`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-orange-500`});case`timeline`:case`reload`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5`});case`compact`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-purple-500`});case`goal`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5`});case`review`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-blue-500`});case`test`:case`build`:case`run`:return(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-cyan-500`});default:return e.isBuiltIn?(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-yellow-500`}):(0,$.jsx)(D,{name:t,className:`h-3.5 w-3.5 text-muted-foreground`})}};return(0,$.jsxs)(de,{ref:te,isMobile:d,className:`max-w-[450px] max-h-64`,style:a,children:[(0,$.jsx)(ae,{preventOverscroll:!0,outerClassName:`flex-1 min-h-0`,className:`px-0 py-1.5`,children:C?(0,$.jsx)(`div`,{className:`flex items-center justify-center py-4`,children:(0,$.jsx)(D,{name:`refresh`,className:`h-4 w-4 animate-spin text-muted-foreground`})}):(0,$.jsxs)(`div`,{children:[b.map((t,r)=>{let i=t.isBuiltIn,a=t.isYuri;return(0,$.jsxs)(`div`,{ref:e=>{P.current[r]=e},className:T(`flex gap-2 px-2 py-2 cursor-pointer rounded-lg`,d?`items-center`:`items-start`,fe(d,r===A),!d&&r===A&&`bg-interactive-selection/35`),onMouseDown:e=>e.preventDefault(),onPointerDown:e=>{e.pointerType===`touch`&&(L.current={x:e.clientX,y:e.clientY},R.current=!1)},onPointerMove:e=>{if(e.pointerType!==`touch`||!L.current)return;let t=e.clientX-L.current.x,n=e.clientY-L.current.y;Math.hypot(t,n)>6&&(R.current=!0)},onPointerUp:e=>{if(e.pointerType!==`touch`)return;let r=R.current;L.current=null,R.current=!1,!r&&(e.preventDefault(),e.stopPropagation(),ne.current=!0,n(t,Ke(t,d)))},onPointerCancel:()=>{L.current=null,R.current=!1},onClick:()=>{if(ne.current){ne.current=!1;return}n(t,Ke(t,d))},onMouseMove:()=>{N.current=!1,j(r)},children:[(0,$.jsx)(`div`,{className:T(!d&&`mt-0.5`),children:se(t)}),(0,$.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsxs)(`span`,{className:`typography-ui-label font-medium`,children:[`/`,Me(t.name,e)]}),t.isSkill?(0,$.jsx)(`span`,{className:Ze,children:u(`chat.commandAutocomplete.badge.skill`)}):(0,$.jsx)(`span`,{className:Ze,children:u(`chat.commandAutocomplete.badge.command`)}),a?(0,$.jsx)(`span`,{className:et,children:`Yuri`}):i?(0,$.jsx)(`span`,{className:et,children:u(`chat.commandAutocomplete.badge.system`)}):t.scope?(0,$.jsx)(`span`,{className:t.scope===`project`?$e:Qe,children:t.scope}):null,t.agent&&(0,$.jsx)(`span`,{className:et,children:t.agent})]}),t.description&&!d&&(0,$.jsx)(`div`,{className:`typography-meta text-muted-foreground mt-0.5 truncate`,children:Me(t.description,e)})]})]},t.id)}),b.length===0&&(0,$.jsx)(`div`,{className:`px-3 py-2 typography-ui-label text-muted-foreground`,children:u(`chat.commandAutocomplete.empty`)})]})}),!d&&(0,$.jsx)(`div`,{className:`px-3 pt-1 pb-1.5 border-t typography-meta text-muted-foreground`,children:u(`chat.autocomplete.keyboardHint`)})]})});rt.displayName=`CommandAutocomplete`;var it=(e,t,n)=>{if(!e)return e;let r=t.length>0&&!/\s$/.test(t)&&!/^\s/.test(e)&&!/[([{]$/.test(t),i=n.length>0&&!/\s$/.test(e)&&!/^\s/.test(n)&&!/^[\])}.,;:!?]/.test(n);return`${r?` `:``}${e}${i?` `:``}`},at=(e,t,n)=>{let r=it(e,t,n);return`${t.length===0&&!/^\s/.test(r)?` `:``}${r}${n.length===0&&!/\s$/.test(r)?` `:``}`},ot=(e,t,n,r)=>{let i=e.slice(0,t),a=e.slice(n),o=at(r,i,a),s=Math.max(0,o.indexOf(r)),c=i.length+s;return{text:`${i}${o}${a}`,caret:i.length+o.length,start:c,end:c+r.length}},st=(e,t)=>{let n=e=>`${e.kind}:${e.value}:${e.range.start}:${e.range.end}`;return new Set(e.map(n)).has(n(t))||e.some(e=>e.range.start<t.range.end&&t.range.start<e.range.end)?[...e]:[...e,t]},ct=(e,t)=>t<e.length&&e[t]===` `?t+1:t;export{rt as a,Ne as c,we as d,H as f,at as i,Q as l,st as n,Ye as o,be as p,ot as r,qe as s,ct as t,Z as u};