@yuriai/web 0.3.6-beta.10 → 0.3.6-beta.11

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 (143) hide show
  1. package/dist/assets/{AgentAvatar-C_s-cMy0.js → AgentAvatar-Ce3xIokt.js} +1 -1
  2. package/dist/assets/{AgentSelector-Df4rBNQs.js → AgentSelector-CMGO3rt5.js} +1 -1
  3. package/dist/assets/{ArchivedSessionsDialog-BQdqEIFM.js → ArchivedSessionsDialog-7SxXt_dN.js} +1 -1
  4. package/dist/assets/{AssistantConversationSurface-BOsGik2U.js → AssistantConversationSurface-DN_0TqBx.js} +3 -3
  5. package/dist/assets/{AssistantSessionCard-DFi6eIIE.js → AssistantSessionCard-CpXxEZ9s.js} +2 -2
  6. package/dist/assets/{AssistantUnreadBadge-B9IS5LPM.js → AssistantUnreadBadge-DMz3nOHJ.js} +1 -1
  7. package/dist/assets/{AssistantView-yCnV95Dr.js → AssistantView-hrY8xNCO.js} +1 -1
  8. package/dist/assets/{AssistantWorkingAvatar-Bp1KXuhO.js → AssistantWorkingAvatar-D8BEeeXa.js} +1 -1
  9. package/dist/assets/{AssistantsSettingsPage-pPeanepy.js → AssistantsSettingsPage-6dBzudvs.js} +1 -1
  10. package/dist/assets/{BinaryFileFallback-C3sgeTIN.js → BinaryFileFallback-Ck_aBVmU.js} +1 -1
  11. package/dist/assets/{BtwPanel-BvqTaKLQ.js → BtwPanel-CXo0GBAo.js} +1 -1
  12. package/dist/assets/{BusyDots-CU41Xq9E.js → BusyDots-CWyfTnAt.js} +1 -1
  13. package/dist/assets/{ChatContainer-DXRL0aB2.js → ChatContainer-C0aZYA_a.js} +4 -4
  14. package/dist/assets/{ChatView-AcZ0Fl7_.js → ChatView-tz6gA9q_.js} +1 -1
  15. package/dist/assets/{DiagramView-CyGBR2qn.js → DiagramView-CzXoWMbU.js} +1 -1
  16. package/dist/assets/{DiffView-z4ArmNTm.js → DiffView-CC2W_84v.js} +1 -1
  17. package/dist/assets/{DiffViewToggle-BBxj5Yby.js → DiffViewToggle-CI88C8kG.js} +1 -1
  18. package/dist/assets/{ErrorBoundary-B4CbFTTY.js → ErrorBoundary-DBZXhhMA.js} +1 -1
  19. package/dist/assets/{FadeInOnReveal-C2UMs63r.js → FadeInOnReveal-Crw10nRn.js} +1 -1
  20. package/dist/assets/{GuiPluginMount-JWmLTeLO.js → GuiPluginMount-wQ9DWE6I.js} +1 -1
  21. package/dist/assets/{GuiPluginPage-BB6qitNb.js → GuiPluginPage-CqHPTVP4.js} +1 -1
  22. package/dist/assets/{GuiPluginSurface-CKW1UPZD.js → GuiPluginSurface-sDPisFX3.js} +1 -1
  23. package/dist/assets/{GuiPluginTitlebarItems-Bmo9W0sn.js → GuiPluginTitlebarItems-Dx5pTQiP.js} +1 -1
  24. package/dist/assets/{GuiPluginWindow-B-6WWulE.js → GuiPluginWindow-BP8DRUZz.js} +1 -1
  25. package/dist/assets/{Icon-CMNOrIAp.js → Icon-DrO1MlqW.js} +1 -1
  26. package/dist/assets/{ImageLoadingPlaceholder-FqoECDc5.js → ImageLoadingPlaceholder-Brhbk0iP.js} +1 -1
  27. package/dist/assets/{LoadingImage-U4z75PsW.js → LoadingImage-k1x9Kvl1.js} +1 -1
  28. package/dist/assets/{MarkdownRenderer-CckbVkti.js → MarkdownRenderer-BHnonkuY.js} +2 -2
  29. package/dist/assets/{MarkdownRendererImpl-CO17sAsd.js → MarkdownRendererImpl-CnPzG_rJ.js} +1 -1
  30. package/dist/assets/{MarkstreamRendererImpl-FOsYqre1.js → MarkstreamRendererImpl-CBGT2iHG.js} +1 -1
  31. package/dist/assets/{MobileAssistantSettingsPage-CYnXMlRV.js → MobileAssistantSettingsPage-C3BxNP1l.js} +1 -1
  32. package/dist/assets/{MobileAssistantTab-CtIoTTOV.js → MobileAssistantTab-BRkzsLvg.js} +1 -1
  33. package/dist/assets/{MobileBtwPage-CqiEtHuG.js → MobileBtwPage-BjuxFp6a.js} +1 -1
  34. package/dist/assets/{MobileChangesSurface-D7AUZxEK.js → MobileChangesSurface-B2flw1Ap.js} +1 -1
  35. package/dist/assets/{MobileChatScreen-CCNqpS3r.js → MobileChatScreen-D9fpOOvH.js} +1 -1
  36. package/dist/assets/{MobileDetailNavigation-BncgS1Gb.js → MobileDetailNavigation-BVA0JCsG.js} +1 -1
  37. package/dist/assets/{MobileFilesSurface-D6Fzko7m.js → MobileFilesSurface-CMBH785S.js} +2 -2
  38. package/dist/assets/{MobileHtmlNetworkBoundary-DXkpR8iy.js → MobileHtmlNetworkBoundary-BJj2vivL.js} +2 -2
  39. package/dist/assets/{MobileOverlayPanel-dc8EKqfh.js → MobileOverlayPanel-DPgcB7AO.js} +1 -1
  40. package/dist/assets/{MobileResizableSheet-Ddf0s-Dp.js → MobileResizableSheet-D5HcC4ME.js} +1 -1
  41. package/dist/assets/{MobileSettingsTab-DoCREe-W.js → MobileSettingsTab-B0-1WZRt.js} +1 -1
  42. package/dist/assets/{MobileShareBridge-DIIhDUmO.js → MobileShareBridge-8X_vdmZN.js} +1 -1
  43. package/dist/assets/{MobileSurface-bA5ONMXf.js → MobileSurface-41iI-7Zd.js} +1 -1
  44. package/dist/assets/{MobileTabPageHeader-DuWdhFAU.js → MobileTabPageHeader-CPz8P10R.js} +1 -1
  45. package/dist/assets/{ModelLogo-Bb63bM4S.js → ModelLogo-D4aymugJ.js} +1 -1
  46. package/dist/assets/{ModelSelector-Dpt_OeOA.js → ModelSelector-BUSeXkcU.js} +1 -1
  47. package/dist/assets/{MultiRunWindow-CIueenaz.js → MultiRunWindow-BbYMumwu.js} +1 -1
  48. package/dist/assets/{OnboardingScreen-DQz9jluT.js → OnboardingScreen-DMLpMUuF.js} +1 -1
  49. package/dist/assets/{OverlayScrollbar-Dsj-t--1.js → OverlayScrollbar-B0O9-JfD.js} +1 -1
  50. package/dist/assets/{PierreDiffViewer-BPY2vUDa.js → PierreDiffViewer-DFDVqbNq.js} +1 -1
  51. package/dist/assets/{ProviderLogo-pBVtlU5X.js → ProviderLogo-CBoJS4Di.js} +1 -1
  52. package/dist/assets/{RemoteAssistantSessionCard-DV_D7Lmx.js → RemoteAssistantSessionCard-1MEZ6Wc_.js} +1 -1
  53. package/dist/assets/{RemoteDesktopPanel-DvF7mNsC.js → RemoteDesktopPanel-CkwyCtui.js} +1 -1
  54. package/dist/assets/{ScheduledTasksDialog-DbV9D6t0.js → ScheduledTasksDialog-Cb_as8Cv.js} +1 -1
  55. package/dist/assets/{ScrollableOverlay-T7ADHNbV.js → ScrollableOverlay-Cuq3KKRE.js} +1 -1
  56. package/dist/assets/{SettingsGroup-ZY4tnwQZ.js → SettingsGroup-BE-0Ya_e.js} +1 -1
  57. package/dist/assets/{SettingsView-C1cFkPEn.js → SettingsView-Q23asKrK.js} +1 -1
  58. package/dist/assets/{SettingsWindow-CPqIwaDs.js → SettingsWindow-C5quZoiL.js} +1 -1
  59. package/dist/assets/{SetupTourDialog-D8MqnViH.js → SetupTourDialog-nJgPu0Kk.js} +1 -1
  60. package/dist/assets/{SyncActions-BUkOsuvk.js → SyncActions-DddhcMDs.js} +1 -1
  61. package/dist/assets/{TerminalView-CoeBAVr1.js → TerminalView-DUwwOkqI.js} +1 -1
  62. package/dist/assets/{TextSelectionMenu-CZWUVT4Q.js → TextSelectionMenu-Cd9EOoKM.js} +1 -1
  63. package/dist/assets/{ToolOutputDialog-DLxoc22s.js → ToolOutputDialog-DjekF5-2.js} +1 -1
  64. package/dist/assets/{assistantMessagePreview-DyHFl0Zy.js → assistantMessagePreview-CR3sWqIa.js} +1 -1
  65. package/dist/assets/{assistantQueries-BLm65-22.js → assistantQueries-wJSqumUZ.js} +1 -1
  66. package/dist/assets/{auto-read-context-eOYxlJjR.js → auto-read-context-0SET_04C.js} +1 -1
  67. package/dist/assets/{capgoAdapter-DYyTs76s.js → capgoAdapter-DgVdXFZa.js} +1 -1
  68. package/dist/assets/{card-Csh0Af72.js → card-Br81AS-C.js} +1 -1
  69. package/dist/assets/{chatUpwardIntent-CivAb4ux.js → chatUpwardIntent-D8gCJWE9.js} +1 -1
  70. package/dist/assets/{checkbox-CK288doZ.js → checkbox-Cs7zimcx.js} +1 -1
  71. package/dist/assets/{collapsible-C8knwYWk.js → collapsible-BqnGY5G1.js} +1 -1
  72. package/dist/assets/{connection-hint-BboPqLXQ.js → connection-hint--2YSFO6b.js} +1 -1
  73. package/dist/assets/{context-menu-CBjNNTDr.js → context-menu-C6YvSFUQ.js} +1 -1
  74. package/dist/assets/{diagram-DuMpiER6.js → diagram-IShCLLT-.js} +1 -1
  75. package/dist/assets/dialog-B6B8FIrL.css +1 -0
  76. package/dist/assets/{dialog-BPtWiCtF.js → dialog-C67GCo29.js} +1 -1
  77. package/dist/assets/{dropdown-menu-BWP9Nxwt.js → dropdown-menu-B6hbejyF.js} +1 -1
  78. package/dist/assets/{fileMentionTouchSelection-3GZYNOSd.js → fileMentionTouchSelection-SC-2eaMJ.js} +1 -1
  79. package/dist/assets/{gitApi-CwF3k_rj.js → gitApi-BZ4ZoWbQ.js} +1 -1
  80. package/dist/assets/{icons-C25QjTQy.js → icons-YECUJPe2.js} +1 -1
  81. package/dist/assets/{input-DHQ_HUNG.js → input-B2oH-nQc.js} +1 -1
  82. package/dist/assets/{insertionBoundaries-6VDrFW8E.js → insertionBoundaries-B2RO01sd.js} +1 -1
  83. package/dist/assets/{kbd-CVXHcAl2.js → kbd-B7_YRVny.js} +1 -1
  84. package/dist/assets/{main-BGVs-a-z.js → main-DCJxCPr0.js} +2 -2
  85. package/dist/assets/{main-CHSIwKhf.js → main-DM5FeSEG.js} +4 -4
  86. package/dist/assets/{markdownHeightCache-BsFEgT5Y.js → markdownHeightCache-BO7vbFmt.js} +1 -1
  87. package/dist/assets/{mcpQueries-BGNMOHKb.js → mcpQueries-CojZBAVK.js} +1 -1
  88. package/dist/assets/{miniChat-ByGJ6Q_E.js → miniChat-VubQ-eH-.js} +2 -2
  89. package/dist/assets/{mobile-txc-T67P.js → mobile-IXaFJ00O.js} +2 -2
  90. package/dist/assets/{mobileBackNavigation-Cpb7IiCG.js → mobileBackNavigation-CJq7EFq0.js} +1 -1
  91. package/dist/assets/{mobileConnections-5xypkCyd.js → mobileConnections--cUobzs-.js} +2 -2
  92. package/dist/assets/{multirun-B5_-5JYt.js → multirun-CphZu9f5.js} +1 -1
  93. package/dist/assets/{native-config-DLw0Zm99.js → native-config-Bes4FTeA.js} +1 -1
  94. package/dist/assets/{nativeComposerCover-Btj57e5V.js → nativeComposerCover-C6VDH0H0.js} +1 -1
  95. package/dist/assets/{navigation-C2qzByuq.js → navigation-DRRQnuzD.js} +1 -1
  96. package/dist/assets/{openRemoteProjectSession-BFp0YlF-.js → openRemoteProjectSession-B4_B76XM.js} +1 -1
  97. package/dist/assets/{openSessionFromDeepLink-DUPajGkN.js → openSessionFromDeepLink-DnoNsjzY.js} +2 -2
  98. package/dist/assets/{pluginPresentation-wl8POjDE.js → pluginPresentation-DxjMvNYM.js} +1 -1
  99. package/dist/assets/{pwa-FAC1qERc.js → pwa-Duem_qqG.js} +1 -1
  100. package/dist/assets/{queue-abort-optimistic-s-DVErY6.js → queue-abort-optimistic-BX5gCxYj.js} +1 -1
  101. package/dist/assets/{reference-history-B9H6MkUC.js → reference-history-DV-P9xV1.js} +1 -1
  102. package/dist/assets/{remoteSessionReference-BHvAalXk.js → remoteSessionReference-C2q6a218.js} +1 -1
  103. package/dist/assets/{renderElectronMiniChatApp-D3Vd8ffe.js → renderElectronMiniChatApp-CdLIP8ke.js} +2 -2
  104. package/dist/assets/{renderMobileApp-BulRo1RJ.js → renderMobileApp-YszxdkcG.js} +4 -4
  105. package/dist/assets/{runtimeConfig-8Z7A5ncj.js → runtimeConfig-CMNPCJna.js} +1 -1
  106. package/dist/assets/{runtimeEndpointReset-D5p8n8Z1.js → runtimeEndpointReset-DUTNA8O6.js} +2 -2
  107. package/dist/assets/{select-BL02HQzN.js → select-DU75Zpg-.js} +1 -1
  108. package/dist/assets/{sessionLookup-CLqpm_Sq.js → sessionLookup-D-QJrAW9.js} +1 -1
  109. package/dist/assets/{sessionOwnership-Zl2YX7dC.js → sessionOwnership-WB9z_776.js} +1 -1
  110. package/dist/assets/{shortcuts-2XAaIaaK.js → shortcuts-CDljO5Z0.js} +1 -1
  111. package/dist/assets/{sortable-tabs-strip-BsjgK90l.js → sortable-tabs-strip-D_QG6WdD.js} +1 -1
  112. package/dist/assets/{speechSettingsQueries-cQ6M7fJ3.js → speechSettingsQueries-Ccs4XLfn.js} +1 -1
  113. package/dist/assets/src-Dv9gb-Yy.css +2 -0
  114. package/dist/assets/{switch-ps5COI8_.js → switch-CYejZ7B8.js} +1 -1
  115. package/dist/assets/{textarea-DXs25Z8k.js → textarea-D-k4tYDG.js} +1 -1
  116. package/dist/assets/{tooltip-DYZonA8U.js → tooltip-DxtaOQnv.js} +1 -1
  117. package/dist/assets/{truncated-path-DJfRXALm.js → truncated-path-DDDJbtPi.js} +1 -1
  118. package/dist/assets/{types-b90cIxfC.js → types-BXjMc92F.js} +1 -1
  119. package/dist/assets/{ui-z2JsXLmb.js → ui-DLZtbTLJ.js} +4 -4
  120. package/dist/assets/{useAppFontEffects-tKUtvOIn.js → useAppFontEffects-DpMTXkXR.js} +2 -2
  121. package/dist/assets/{useDesktopWindowControlsLayout-CNAzDasQ.js → useDesktopWindowControlsLayout-3qd6LXL-.js} +1 -1
  122. package/dist/assets/{useEffectiveDirectory-hu13SCnK.js → useEffectiveDirectory-CXt-KLYT.js} +1 -1
  123. package/dist/assets/{useGitStore-Dsh_ZiT1.js → useGitStore-CAj3309H.js} +1 -1
  124. package/dist/assets/{useInlineCommentDraftStore-C75YIRui.js → useInlineCommentDraftStore-DEzJN8u2.js} +1 -1
  125. package/dist/assets/{useMcpConfigStore-BfdokvWe.js → useMcpConfigStore-CCsT0TQj.js} +1 -1
  126. package/dist/assets/{useMobileSwipeActions-jAZpJVTB.js → useMobileSwipeActions-BnJa2tLR.js} +1 -1
  127. package/dist/assets/{useMobileTranscriptSyncHint-XT7TWzKn.js → useMobileTranscriptSyncHint-DwBUhnBr.js} +1 -1
  128. package/dist/assets/{useModelLists-DrXScJk8.js → useModelLists-Bd8KjZ16.js} +1 -1
  129. package/dist/assets/{useOpenCodeReadiness-DLqT6fD5.js → useOpenCodeReadiness-BodiUrhs.js} +1 -1
  130. package/dist/assets/{usePluginsStore-DYO8nss8.js → usePluginsStore-BLP01bCp.js} +1 -1
  131. package/dist/assets/{useProjectGitActions-CYWPTGNa.js → useProjectGitActions-iY0OP_M-.js} +1 -1
  132. package/dist/assets/{useProjectGitStore-C1Tswys-.js → useProjectGitStore-aVtBQPmn.js} +1 -1
  133. package/dist/assets/{useProjectRuntimeAPIs-BpdOaT67.js → useProjectRuntimeAPIs-ACsFy7es.js} +1 -1
  134. package/dist/assets/{useSessionBtwStore-PdQPx7tm.js → useSessionBtwStore-DwgrTiCi.js} +1 -1
  135. package/dist/assets/{useStreamingTextThrottle-Btl31Wol.js → useStreamingTextThrottle-aFrPa42L.js} +1 -1
  136. package/dist/assets/{worktreeManager-DIrqBI6K.js → worktreeManager-B1qB2-Pa.js} +1 -1
  137. package/dist/assets/{worktreeSourceBranchPreference-DncAXqYk.js → worktreeSourceBranchPreference-DOyD0AQN.js} +1 -1
  138. package/dist/index.html +6 -6
  139. package/dist/mini-chat.html +6 -6
  140. package/dist/mobile.html +2 -2
  141. package/package.json +1 -1
  142. package/dist/assets/dialog-D9CkSNCA.css +0 -1
  143. package/dist/assets/src-DYCPWwUH.css +0 -2
@@ -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-CNdx57HN.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-P32bzAJc.js";import{s as u}from"./terminalApi-D2ECmoAo.js";import{n as d,r as f,t as ee}from"./vendor-ghostty-web-DbBrwBII.js";import{Yn as p,f as m,no as h,to as g}from"./ui-z2JsXLmb.js";import{n as _}from"./Icon-CMNOrIAp.js";import{t as v}from"./i18n-BU8XOKjS.js";import{t as y}from"./OverlayScrollbar-Dsj-t--1.js";import{n as b}from"./useThemeSystem-BIXghnHj.js";import{r as te}from"./device-CtdJ8KBJ.js";import{n as x}from"./useEffectiveDirectory-hu13SCnK.js";import{n as ne}from"./useProjectRuntimeAPIs-BpdOaT67.js";import{t as re}from"./sortable-tabs-strip-BsjgK90l.js";import{n as S,t as C}from"./useFontPreferences-BY0TXvWI.js";import{t as ie}from"./project-preview-CIkGbBPZ.js";import{n as ae}from"./projectActions-D84EVh3q.js";var w=e(o(),1);function oe(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 se(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 ce=e(i(),1),T=a(),E=null;function D(){return E||=f.load(),E}function O(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 k=w.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}=v(),m=w.useRef(null),_=w.useRef(null),b=w.useRef(null),te=w.useRef(null),x=w.useRef(n),ne=w.useRef(r),re=w.useRef(null),S=w.useRef(``),C=w.useRef(null),ie=w.useRef(!1),ae=w.useRef(null),oe=w.useRef(!0),E=w.useRef(null),k=w.useRef(null),le=w.useRef(0),ue=w.useRef(null),de=w.useRef(null),A=w.useRef(!1),j=w.useRef(!1),M=w.useRef(null),N=w.useRef(null),fe=w.useRef(null),pe=w.useRef(``),me=w.useRef(null),P=w.useRef(!c),he=w.useRef(u),[,ge]=w.useReducer(e=>e+1,0),[_e,ve]=w.useReducer(e=>e+1,0);x.current=n,ne.current=r;let ye=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),F=!!c;w.useEffect(()=>{if(!c){P.current=!0,he.current=u;return}!he.current&&u&&(P.current=!1),he.current=u},[c,u]);let be=w.useCallback(()=>{if(!F)return;let e=m.current,t=ue.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=w.useCallback(e=>{if(me.current===e)return;let t=b.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=w.useCallback((e,t)=>{let n=L?de.current:ue.current,r=m.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=w.useCallback(()=>{if(F){R(),I(!0);return}b.current?.focus(),I(!0)},[R,I,F]),B=w.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),V=w.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),xe=w.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&&x.current(a.replace(/\r\n|\r|\n/g,`\r`)),V(e),pe.current=``},t===0?0:24)};n()},[V,B,L]);w.useEffect(()=>{let e=m.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=w.useCallback(()=>{let e=b.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),H=w.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=m.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),U=w.useCallback(async()=>{if(typeof document>`u`)return;let e=Se()||H();e.trim()&&await g(e)},[H,Se]),W=w.useCallback(()=>Se().trim()?!0:!!H().trim(),[H,Se]);w.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=w.useCallback(()=>{S.current=``,C.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(C.current),C.current=null,ie.current=!1,ae.current=null},[]),K=w.useCallback(()=>{let e=te.current,t=b.current,n=m.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=re.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(re.current=n,ne.current(n.cols,n.rows))}catch{}},[]),Ce=w.useCallback(()=>{if(ie.current)return;let e=b.current;if(!e){G();return}if(!S.current)return;let t=S.current;S.current=``,ie.current=!0,e.write(t,()=>{ie.current=!1,S.current&&(typeof window<`u`?C.current=window.requestAnimationFrame(()=>{C.current=null,Ce()}):Ce())})},[G]),we=w.useCallback(()=>{C.current===null&&(typeof window<`u`?C.current=window.requestAnimationFrame(()=>{C.current=null,Ce()}):Ce())},[Ce]),Te=w.useCallback(e=>{e&&(S.current+=e,we())},[we]),Ee=w.useCallback(()=>{if(E.current?.(),E.current=null,k.current!==null&&typeof window<`u`&&(window.clearTimeout(k.current),k.current=null),!c){le.current=0;return}let e=m.current;if(!e)return;let t=b.current;if(!t)return;le.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},h={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,b.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,h),e.addEventListener(`pointermove`,d,h),e.addEventListener(`pointerup`,f,h),e.addEventListener(`pointercancel`,f,h);let m=e.style.touchAction,g=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,E.current=()=>{p(),k.current!==null&&typeof window<`u`&&(window.clearTimeout(k.current),k.current=null),le.current=0,e.removeEventListener(`pointerdown`,o,h),e.removeEventListener(`pointermove`,d,h),e.removeEventListener(`pointerup`,f,h),e.removeEventListener(`pointercancel`,f,h),e.style.touchAction=m,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)},_=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)},v=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,b.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,h),e.addEventListener(`touchmove`,_,h),e.addEventListener(`touchend`,v,h),e.addEventListener(`touchcancel`,v,h);let y=e.style.touchAction,te=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,E.current=()=>{p(),k.current!==null&&typeof window<`u`&&(window.clearTimeout(k.current),k.current=null),le.current=0,e.removeEventListener(`touchstart`,g,h),e.removeEventListener(`touchmove`,_,h),e.removeEventListener(`touchend`,v,h),e.removeEventListener(`touchcancel`,v,h),e.style.touchAction=y,e.style.overscrollBehaviorY=te}},[c,F,R,o]);w.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,u=null,f=null,p=m.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 h=()=>{I(!0)},g=()=>{I(!1)},v=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)},y=()=>{I(!1)},ne=null;return(async()=>{try{let f=await D();if(e)return;let m=se(a,o,i,f,!1),v=new d(m);oe.current=!0,F&&(v.focus=()=>{});let y=v;if(typeof y.scrollToBottom==`function`){let e=y.scrollToBottom.bind(y);y.scrollToBottom=()=>{oe.current&&e()},l=()=>{y.scrollToBottom=e}}let re=new ee;if(t=v,b.current=v,te.current=re,v.loadAddon(re),v.open(p),c){let e=v.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},u=()=>{e.renderScrollbar=t}}}ve(),me.current=!1,ne=v.textarea??p.querySelector(`textarea`),ne&&(ne.addEventListener(`focus`,h),ne.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 S=O(p);S?(S.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),_.current=S,ge()):_.current=null,K();let C=re;typeof C.observeResize==`function`&&C.observeResize(),Ee(),s=[v.onData(e=>{x.current(e)}),v.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof v.hasSelection==`function`&&v.hasSelection();oe.current=!t&&e<=.5}}),v.onSelectionChange(()=>{if(typeof v.hasSelection==`function`&&v.hasSelection()){oe.current=!1;return}let e=typeof v.getViewportY==`function`?v.getViewportY():0;oe.current=e<=.5})],n=new ResizeObserver(()=>{K()}),n.observe(p),typeof window<`u`&&window.setTimeout(()=>{K()},0)}catch{}})(),document.addEventListener(`focusin`,v,!0),window.addEventListener(`blur`,y),()=>{e=!0,E.current?.(),E.current=null,document.removeEventListener(`focusin`,v,!0),window.removeEventListener(`blur`,y),s.forEach(e=>e.dispose()),l?.(),l=null,u?.(),u=null,ne&&(ne.removeEventListener(`focus`,h),ne.removeEventListener(`blur`,g)),n?.disconnect(),r?.disconnect(),f?.(),t?.dispose(),b.current=null,te.current=null,_.current=null,re.current=null,me.current=null,G()}},[be,c,K,R,a,o,Ee,i,G,I,F]),w.useEffect(()=>{let e=b.current;e&&(e.reset(),G(),re.current=null,K())},[e,_e,K,G]),w.useEffect(()=>{l&&b.current&&z()},[l,z,e,_e]),w.useEffect(()=>(Ee(),()=>{E.current?.(),E.current=null}),[Ee,e]),w.useEffect(()=>{let e=b.current;if(!e)return;if(t.length===0){ae.current!==null&&(e.reset(),G(),K());return}let n=ae.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(``)),ae.current=t[t.length-1].id},[t,_e,Te,K,G]),w.useImperativeHandle(f,()=>({focus:()=>{z()},clear:()=>{let e=b.current;e&&(e.reset(),G(),K())},fit:()=>{K()}}),[z,K,G]);let De=w.useCallback(e=>{if(!F)return;let t=m.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=w.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(),x.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(),x.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(),x.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(),x.current(``),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0}},[]),Oe=w.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`);x.current(r),V(t),pe.current=``},[V,B]),J=w.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(),x.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(),x.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(),x.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(),x.current(`\r`),V(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;B(a)||x.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=N.current;t&&s-t<50||(e.preventDefault(),x.current(e.key),j.current=!0,M.current={type:`keydown-text`,at:s})}xe(a)},[V,U,W,B,xe]),ke=w.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||xe(t)},[xe]),Y=w.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`);x.current(r),V(t),M.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0},[V,B]),X=w.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=b.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;x.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,T.jsxs)(`div`,{ref:m,className:h(`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 b.current?.focus()},onMouseUp:()=>{!c&&W()&&U()},onTouchEnd:()=>{!c&&W()&&U()},children:[F&&typeof document<`u`?(0,ce.createPortal)((0,T.jsxs)(T.Fragment,{children:[(0,T.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,T.jsx)(`textarea`,{ref:ue,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,_.current&&!c?(0,T.jsx)(y,{containerRef:_,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});k.displayName=`TerminalViewport`;var le=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),ue=/(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(le,``),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-CNdx57HN.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-P32bzAJc.js";import{s as u}from"./terminalApi-D2ECmoAo.js";import{n as d,r as f,t as ee}from"./vendor-ghostty-web-DbBrwBII.js";import{Yn as p,f as m,no as h,to as g}from"./ui-DLZtbTLJ.js";import{n as _}from"./Icon-DrO1MlqW.js";import{t as v}from"./i18n-BU8XOKjS.js";import{t as y}from"./OverlayScrollbar-B0O9-JfD.js";import{n as b}from"./useThemeSystem-BIXghnHj.js";import{r as te}from"./device-CtdJ8KBJ.js";import{n as x}from"./useEffectiveDirectory-CXt-KLYT.js";import{n as ne}from"./useProjectRuntimeAPIs-ACsFy7es.js";import{t as re}from"./sortable-tabs-strip-D_QG6WdD.js";import{n as S,t as C}from"./useFontPreferences-BY0TXvWI.js";import{t as ie}from"./project-preview-CIkGbBPZ.js";import{n as ae}from"./projectActions-D84EVh3q.js";var w=e(o(),1);function oe(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 se(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 ce=e(i(),1),T=a(),E=null;function D(){return E||=f.load(),E}function O(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 k=w.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}=v(),m=w.useRef(null),_=w.useRef(null),b=w.useRef(null),te=w.useRef(null),x=w.useRef(n),ne=w.useRef(r),re=w.useRef(null),S=w.useRef(``),C=w.useRef(null),ie=w.useRef(!1),ae=w.useRef(null),oe=w.useRef(!0),E=w.useRef(null),k=w.useRef(null),le=w.useRef(0),ue=w.useRef(null),de=w.useRef(null),A=w.useRef(!1),j=w.useRef(!1),M=w.useRef(null),N=w.useRef(null),fe=w.useRef(null),pe=w.useRef(``),me=w.useRef(null),P=w.useRef(!c),he=w.useRef(u),[,ge]=w.useReducer(e=>e+1,0),[_e,ve]=w.useReducer(e=>e+1,0);x.current=n,ne.current=r;let ye=typeof navigator<`u`&&(/Android/i.test(navigator.userAgent)||navigator.userAgentData?.platform===`Android`),F=!!c;w.useEffect(()=>{if(!c){P.current=!0,he.current=u;return}!he.current&&u&&(P.current=!1),he.current=u},[c,u]);let be=w.useCallback(()=>{if(!F)return;let e=m.current,t=ue.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=w.useCallback(e=>{if(me.current===e)return;let t=b.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=w.useCallback((e,t)=>{let n=L?de.current:ue.current,r=m.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=w.useCallback(()=>{if(F){R(),I(!0);return}b.current?.focus(),I(!0)},[R,I,F]),B=w.useCallback(e=>e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement?e.value:e.textContent??``,[]),V=w.useCallback(e=>{if(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement){e.value=``;return}e.textContent=``},[]),xe=w.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&&x.current(a.replace(/\r\n|\r|\n/g,`\r`)),V(e),pe.current=``},t===0?0:24)};n()},[V,B,L]);w.useEffect(()=>{let e=m.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=w.useCallback(()=>{let e=b.current;if(!e||typeof e.getSelection!=`function`)return``;let t=e.getSelection();return typeof t==`string`?t:``},[]),H=w.useCallback(()=>{if(typeof window>`u`)return``;let e=window.getSelection();if(!e)return``;let t=e.toString();if(!t.trim())return``;let n=m.current;if(!n)return``;let r=e.anchorNode,i=e.focusNode;return r&&!n.contains(r)||i&&!n.contains(i)?``:t},[]),U=w.useCallback(async()=>{if(typeof document>`u`)return;let e=Se()||H();e.trim()&&await g(e)},[H,Se]),W=w.useCallback(()=>Se().trim()?!0:!!H().trim(),[H,Se]);w.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=w.useCallback(()=>{S.current=``,C.current!==null&&typeof window<`u`&&window.cancelAnimationFrame(C.current),C.current=null,ie.current=!1,ae.current=null},[]),K=w.useCallback(()=>{let e=te.current,t=b.current,n=m.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=re.current;(!r||r.cols!==n.cols||r.rows!==n.rows)&&(re.current=n,ne.current(n.cols,n.rows))}catch{}},[]),Ce=w.useCallback(()=>{if(ie.current)return;let e=b.current;if(!e){G();return}if(!S.current)return;let t=S.current;S.current=``,ie.current=!0,e.write(t,()=>{ie.current=!1,S.current&&(typeof window<`u`?C.current=window.requestAnimationFrame(()=>{C.current=null,Ce()}):Ce())})},[G]),we=w.useCallback(()=>{C.current===null&&(typeof window<`u`?C.current=window.requestAnimationFrame(()=>{C.current=null,Ce()}):Ce())},[Ce]),Te=w.useCallback(e=>{e&&(S.current+=e,we())},[we]),Ee=w.useCallback(()=>{if(E.current?.(),E.current=null,k.current!==null&&typeof window<`u`&&(window.clearTimeout(k.current),k.current=null),!c){le.current=0;return}let e=m.current;if(!e)return;let t=b.current;if(!t)return;le.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},h={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,b.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,h),e.addEventListener(`pointermove`,d,h),e.addEventListener(`pointerup`,f,h),e.addEventListener(`pointercancel`,f,h);let m=e.style.touchAction,g=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,E.current=()=>{p(),k.current!==null&&typeof window<`u`&&(window.clearTimeout(k.current),k.current=null),le.current=0,e.removeEventListener(`pointerdown`,o,h),e.removeEventListener(`pointermove`,d,h),e.removeEventListener(`pointerup`,f,h),e.removeEventListener(`pointercancel`,f,h),e.style.touchAction=m,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)},_=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)},v=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,b.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,h),e.addEventListener(`touchmove`,_,h),e.addEventListener(`touchend`,v,h),e.addEventListener(`touchcancel`,v,h);let y=e.style.touchAction,te=e.style.overscrollBehaviorY;e.style.touchAction=`none`,e.style.overscrollBehaviorY=`contain`,E.current=()=>{p(),k.current!==null&&typeof window<`u`&&(window.clearTimeout(k.current),k.current=null),le.current=0,e.removeEventListener(`touchstart`,g,h),e.removeEventListener(`touchmove`,_,h),e.removeEventListener(`touchend`,v,h),e.removeEventListener(`touchcancel`,v,h),e.style.touchAction=y,e.style.overscrollBehaviorY=te}},[c,F,R,o]);w.useEffect(()=>{let e=!1,t=null,n=null,r=null,s=[],l=null,u=null,f=null,p=m.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 h=()=>{I(!0)},g=()=>{I(!1)},v=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)},y=()=>{I(!1)},ne=null;return(async()=>{try{let f=await D();if(e)return;let m=se(a,o,i,f,!1),v=new d(m);oe.current=!0,F&&(v.focus=()=>{});let y=v;if(typeof y.scrollToBottom==`function`){let e=y.scrollToBottom.bind(y);y.scrollToBottom=()=>{oe.current&&e()},l=()=>{y.scrollToBottom=e}}let re=new ee;if(t=v,b.current=v,te.current=re,v.loadAddon(re),v.open(p),c){let e=v.renderer;if(e&&typeof e.renderScrollbar==`function`){let t=e.renderScrollbar.bind(e);e.renderScrollbar=()=>{},u=()=>{e.renderScrollbar=t}}}ve(),me.current=!1,ne=v.textarea??p.querySelector(`textarea`),ne&&(ne.addEventListener(`focus`,h),ne.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 S=O(p);S?(S.classList.add(`overlay-scrollbar-target`,`overlay-scrollbar-container`),_.current=S,ge()):_.current=null,K();let C=re;typeof C.observeResize==`function`&&C.observeResize(),Ee(),s=[v.onData(e=>{x.current(e)}),v.onScroll(e=>{if(typeof e==`number`&&Number.isFinite(e)){let t=typeof v.hasSelection==`function`&&v.hasSelection();oe.current=!t&&e<=.5}}),v.onSelectionChange(()=>{if(typeof v.hasSelection==`function`&&v.hasSelection()){oe.current=!1;return}let e=typeof v.getViewportY==`function`?v.getViewportY():0;oe.current=e<=.5})],n=new ResizeObserver(()=>{K()}),n.observe(p),typeof window<`u`&&window.setTimeout(()=>{K()},0)}catch{}})(),document.addEventListener(`focusin`,v,!0),window.addEventListener(`blur`,y),()=>{e=!0,E.current?.(),E.current=null,document.removeEventListener(`focusin`,v,!0),window.removeEventListener(`blur`,y),s.forEach(e=>e.dispose()),l?.(),l=null,u?.(),u=null,ne&&(ne.removeEventListener(`focus`,h),ne.removeEventListener(`blur`,g)),n?.disconnect(),r?.disconnect(),f?.(),t?.dispose(),b.current=null,te.current=null,_.current=null,re.current=null,me.current=null,G()}},[be,c,K,R,a,o,Ee,i,G,I,F]),w.useEffect(()=>{let e=b.current;e&&(e.reset(),G(),re.current=null,K())},[e,_e,K,G]),w.useEffect(()=>{l&&b.current&&z()},[l,z,e,_e]),w.useEffect(()=>(Ee(),()=>{E.current?.(),E.current=null}),[Ee,e]),w.useEffect(()=>{let e=b.current;if(!e)return;if(t.length===0){ae.current!==null&&(e.reset(),G(),K());return}let n=ae.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(``)),ae.current=t[t.length-1].id},[t,_e,Te,K,G]),w.useImperativeHandle(f,()=>({focus:()=>{z()},clear:()=>{let e=b.current;e&&(e.reset(),G(),K())},fit:()=>{K()}}),[z,K,G]);let De=w.useCallback(e=>{if(!F)return;let t=m.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=w.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(),x.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(),x.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(),x.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(),x.current(``),M.current={type:n,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0}},[]),Oe=w.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`);x.current(r),V(t),pe.current=``},[V,B]),J=w.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(),x.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(),x.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(),x.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(),x.current(`\r`),V(a);return}if(e.key===`Backspace`){if(e.preventDefault(),c&&o?.type===`deleteContentBackward`)return;B(a)||x.current(``)}if(e.key.length===1&&!e.ctrlKey&&!e.metaKey&&!e.altKey){let t=N.current;t&&s-t<50||(e.preventDefault(),x.current(e.key),j.current=!0,M.current={type:`keydown-text`,at:s})}xe(a)},[V,U,W,B,xe]),ke=w.useCallback(e=>{e.stopPropagation();let t=e.currentTarget;e.nativeEvent?.isComposing||xe(t)},[xe]),Y=w.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`);x.current(r),V(t),M.current={type:`compositionend`,at:typeof performance<`u`?performance.now():Date.now()},j.current=!0},[V,B]),X=w.useCallback(e=>{e.stopPropagation();let t=e.clipboardData?.getData(`text`)??``;if(!t)return;e.preventDefault();let n=b.current?.hasBracketedPaste?.()?`\x1b[200~${t}\x1b[201~`:t;x.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,T.jsxs)(`div`,{ref:m,className:h(`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 b.current?.focus()},onMouseUp:()=>{!c&&W()&&U()},onTouchEnd:()=>{!c&&W()&&U()},children:[F&&typeof document<`u`?(0,ce.createPortal)((0,T.jsxs)(T.Fragment,{children:[(0,T.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,T.jsx)(`textarea`,{ref:ue,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,_.current&&!c?(0,T.jsx)(y,{containerRef:_,disableHorizontal:!0,className:`overlay-scrollbar--flush overlay-scrollbar--dense overlay-scrollbar--zero`}):null]})});k.displayName=`TerminalViewport`;var le=RegExp(`\x1B\\[[0-9;?]*[ -/]*[@-~]`,`g`),ue=/(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(le,``),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(ue));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}=v(),{terminal:t,runtime:i,projectScope:a}=ne(),{currentTheme:o}=b(),{monoFont:d}=C(),f=l(e=>e.terminalFontSize),ee=l(e=>e.bottomTerminalHeight),g=l(e=>e.isBottomTerminalExpanded),{isMobile:y,isTablet:se,hasTouchOnlyPointer:ce}=te(),E=y||se,D=(E||ce)&&i.platform===`web`,O=i.platform!==`vscode`,le=l(e=>e.showTerminalQuickKeysOnDesktop),ue=!n()&&(E||le),de=m(e=>e.currentSessionId),A=m(e=>e.newSessionDraft),j=!!a||de!==null||A?.open===!0,M=x()??null??a?.location.directory??null,N=a?r({...a.location,directory:M??a.location.directory}):M,me=S(e=>e.sessions),P=S(e=>e.hasHydrated),ve=S(e=>e.ensureDirectory),ye=S(e=>e.createTab),F=S(e=>e.setActiveTab),be=S(e=>e.closeTab),I=w.useMemo(()=>a?async(e,n)=>{await be(e,n,t.close)}:be,[a,t,be]),L=S(e=>e.setTabSessionId),R=S(e=>e.setTabLifecycle),z=S(e=>e.setConnecting),B=S(e=>e.appendToBuffer),V=S(e=>e.setTabPreviewUrl),xe=S(e=>e.clearBuffer),Se=l(e=>e.openContextPreview),H=w.useMemo(()=>{if(N)return me.get(N)},[me,N]),U=w.useMemo(()=>H?O?H.activeTabId??H.tabs[0]?.id??null:H.tabs[0]?.id??null:null,[H,O]),W=w.useMemo(()=>{if(H)return U?H.tabs.find(e=>e.id===U)??H.tabs[0]:H.tabs[0]},[H,U]),G=w.useMemo(()=>(H?.tabs??[]).map(t=>({icon:(()=>{let e=t.iconKey?ae[t.iconKey]??`terminal`:`terminal`;return(0,T.jsx)(_,{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]=w.useState(null),[Oe,J]=w.useState(!1),[ke,Y]=w.useState(!1),[X,Z]=w.useState(null),[Ae,je]=w.useState(!1),[Me,Ne]=w.useState(0),Pe=w.useRef(null),Fe=w.useRef(null),Ie=w.useRef(U),Le=w.useRef(K),Re=w.useRef(N),ze=w.useRef(null),Be=w.useRef(null),Ve=w.useRef(!1),He=w.useRef(!1),Ue=w.useRef(null),We=w.useRef(null),Ge=w.useRef(new Set),Ke=w.useRef(!1),qe=w.useRef(``),Je=w.useRef(new Set),Ye=w.useRef(0),Xe=w.useCallback(()=>{qe.current=``,Je.current.clear(),Ye.current+=1},[]),Ze=w.useCallback(()=>{D||typeof document<`u`&&!document.hasFocus()||ze.current?.focus()},[D]),Qe=w.useCallback(()=>{D||ze.current?.focus()},[D]);w.useEffect(()=>{if(!P||Ke.current)return;Ke.current=!0;let e=new Set;for(let[,t]of S.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]=w.useState(Q);w.useEffect(()=>{!Q||i.platform===`vscode`||a||u()},[Q,i.platform,a]),w.useEffect(()=>{Q&&at(!0)},[Q]),w.useEffect(()=>{He.current=Q},[Q]),w.useEffect(()=>{Le.current=K},[K]),w.useEffect(()=>{Ie.current=U,Xe()},[U,Xe]),w.useEffect(()=>{Re.current=N},[N]),w.useEffect(()=>{!ue&&X!==null&&Z(null)},[ue,X,Z]),w.useEffect(()=>{!K&&X!==null&&Z(null)},[K,X,Z]);let $=w.useCallback(()=>{Pe.current?.(),Pe.current=null,Fe.current=null,Ue.current=null,Y(!1)},[]);w.useEffect(()=>()=>{$(),Le.current=null},[$]),w.useEffect(()=>($(),$),[t,$]);let ot=w.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-CNdx57HN.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-DKJJoOOc.js";import{r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{a as c,o as l,r as u}from"./useUIStore-P32bzAJc.js";import{Yn as ee,co as d,f,jt as p,no as te}from"./ui-z2JsXLmb.js";import{t as ne}from"./i18n-BU8XOKjS.js";import{n as re}from"./useEffectiveDirectory-hu13SCnK.js";import{s as m}from"./mobileBackNavigation-Cpb7IiCG.js";import{i as h,n as g}from"./shortcuts-2XAaIaaK.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-PdQPx7tm.js";import{a as ce,i as y,r as le,t as b}from"./nativeComposerCover-Btj57e5V.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-CNdx57HN.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-DKJJoOOc.js";import{r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{a as c,o as l,r as u}from"./useUIStore-P32bzAJc.js";import{Yn as ee,co as d,f,jt as p,no as te}from"./ui-DLZtbTLJ.js";import{t as ne}from"./i18n-BU8XOKjS.js";import{n as re}from"./useEffectiveDirectory-CXt-KLYT.js";import{s as m}from"./mobileBackNavigation-CJq7EFq0.js";import{i as h,n as g}from"./shortcuts-CDljO5Z0.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-DwgrTiCi.js";import{a as ce,i as y,r as le,t as b}from"./nativeComposerCover-C6VDH0H0.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-CNdx57HN.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-DKJJoOOc.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-P32bzAJc.js";import{n as D,t as O}from"./runtime-file-download-wMVtKk2v.js";import{n as k,t as A}from"./vendor-pierre-diffs-B0OmIhMO.js";import{Yn as j,no as M}from"./ui-z2JsXLmb.js";import{n as N}from"./Icon-CMNOrIAp.js";import{t as P}from"./i18n-BU8XOKjS.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-BPtWiCtF.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-hu13SCnK.js";import{n as de}from"./mobileBackNavigation-Cpb7IiCG.js";import{t as fe}from"./ImageLoadingPlaceholder-FqoECDc5.js";import{n as V,r as pe}from"./MarkdownRenderer-CckbVkti.js";import{a as H,c as me,i as U,o as W}from"./imageSource-B39pFDdo.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-BBxj5Yby.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-CNdx57HN.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-DKJJoOOc.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-P32bzAJc.js";import{n as D,t as O}from"./runtime-file-download-wMVtKk2v.js";import{n as k,t as A}from"./vendor-pierre-diffs-B0OmIhMO.js";import{Yn as j,no as M}from"./ui-DLZtbTLJ.js";import{n as N}from"./Icon-DrO1MlqW.js";import{t as P}from"./i18n-BU8XOKjS.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-C67GCo29.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-CXt-KLYT.js";import{n as de}from"./mobileBackNavigation-CJq7EFq0.js";import{t as fe}from"./ImageLoadingPlaceholder-Brhbk0iP.js";import{n as V,r as pe}from"./MarkdownRenderer-BHnonkuY.js";import{a as H,c as me,i as U,o as W}from"./imageSource-B39pFDdo.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-CI88C8kG.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 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,w as n}from"./runtime-auth-DA-qfGHk.js";import{i as r,t as i}from"./runtime-switch-DEPKHgdL.js";import{A as a,f as o}from"./platform-CNdx57HN.js";import{ot as s,st as c}from"./vendor-base-ui-wXsskyKm.js";import{n as l}from"./vendor-react-BkccXcWz.js";import{n as u}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{r as d}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as f}from"./vendor-sonner-DX3nfJx4.js";import{Yn as p,no as m}from"./ui-z2JsXLmb.js";import{n as h}from"./Icon-CMNOrIAp.js";import{t as g}from"./i18n-BU8XOKjS.js";import{i as _}from"./useAssistantUIStore-DEiMjSqf.js";import{a as v,i as y,n as b,o as x,r as S,t as C}from"./dialog-BPtWiCtF.js";import{a as w,i as T,n as E,r as D,t as O}from"./context-menu-CBjNNTDr.js";import{c as k,i as A,o as j,p as M}from"./assistantQueries-BLm65-22.js";import{t as N}from"./assistantPresentation-DRbsH1Ej.js";import{r as P,t as F}from"./AssistantWorkingAvatar-Bp1KXuhO.js";import{n as I}from"./AssistantUnreadBadge-B9IS5LPM.js";var L=e(c(),1),R=l(),z=()=>o()&&!n(),B=async e=>{if(!z())throw Error(`Assistant Mini Chat requires a direct desktop connection`);await a(`desktop_open_assistant_mini_chat_window`,{assistantID:e,apiBaseUrl:i(),clientToken:t()})},V=s();function H(e){let t=(0,R.c)(49),{assistant:n,trigger:i,onEdit:a,onDelete:o,doubleClickMiniChat:s}=e,c=s!==void 0&&s,{t:l}=g(),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=r(),t[0]=d):d=t[0];let p;t[1]===n.id?p=t[2]:(p=[d,`assistants`,n.id,`pin`],t[1]=n.id,t[2]=p);let m;t[3]===n?m=t[4]:(m=()=>M(n,{pinned:n.pinnedAt==null}),t[3]=n,t[4]=m);let _;t[5]===l?_=t[6]:(_=()=>f.error(l(`assistants.menu.pinError`)),t[5]=l,t[6]=_);let v;t[7]!==p||t[8]!==m||t[9]!==_?(v={mutationKey:p,mutationFn:m,onError:_},t[7]=p,t[8]=m,t[9]=_,t[10]=v):v=t[10];let y=u(v),b;t[11]!==n.id||t[12]!==l?(b=()=>{B(n.id).catch(()=>f.error(l(`miniChat.actions.failed`)))},t[11]=n.id,t[12]=l,t[13]=b):b=t[13];let x=b,S=i,C;t[14]!==S||t[15]!==c||t[16]!==x||t[17]!==i?(C=c?L.cloneElement(S,{onDoubleClick:e=>{S.props.onDoubleClick?.(e),!e.defaultPrevented&&z()&&x()}}):i,t[14]=S,t[15]=c,t[16]=x,t[17]=i,t[18]=C):C=t[18];let k;t[19]===C?k=t[20]:(k=(0,V.jsx)(w,{render:C}),t[19]=C,t[20]=k);let A;t[21]!==n.pinnedAt||t[22]!==y||t[23]!==l?(A=n.pinnedAt===void 0?null:(0,V.jsxs)(D,{disabled:y.isPending,onClick:()=>y.mutate(),children:[(0,V.jsx)(h,{name:n.pinnedAt==null?`pushpin-2`:`unpin`,className:`size-4`}),l(n.pinnedAt==null?`assistants.menu.pin`:`assistants.menu.unpin`)]}),t[21]=n.pinnedAt,t[22]=y,t[23]=l,t[24]=A):A=t[24];let j;t[25]!==x||t[26]!==l?(j=z()?(0,V.jsxs)(D,{onClick:x,children:[(0,V.jsx)(h,{name:`external-link`,className:`size-4`}),l(`sessions.sidebar.session.menu.openMiniChatWindow`)]}):null,t[25]=x,t[26]=l,t[27]=j):j=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,V.jsx)(h,{name:`edit`,className:`size-4`}),t[28]=N):N=t[28];let P;t[29]===l?P=t[30]:(P=l(`assistants.menu.edit`),t[29]=l,t[30]=P);let F;t[31]!==a||t[32]!==P?(F=(0,V.jsxs)(D,{onClick:a,children:[N,P]}),t[31]=a,t[32]=P,t[33]=F):F=t[33];let I;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,V.jsx)(T,{}),t[34]=I):I=t[34];let H;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,V.jsx)(h,{name:`delete-bin`,className:`size-4 text-inherit`}),t[35]=H):H=t[35];let U;t[36]===l?U=t[37]:(U=l(`assistants.settings.delete`),t[36]=l,t[37]=U);let W;t[38]!==o||t[39]!==U?(W=(0,V.jsxs)(D,{onClick:o,className:`text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)]`,children:[H,U]}),t[38]=o,t[39]=U,t[40]=W):W=t[40];let G;t[41]!==A||t[42]!==j||t[43]!==F||t[44]!==W?(G=(0,V.jsxs)(E,{className:`min-w-[10rem]`,children:[A,j,F,I,W]}),t[41]=A,t[42]=j,t[43]=F,t[44]=W,t[45]=G):G=t[45];let K;return t[46]!==G||t[47]!==k?(K=(0,V.jsxs)(O,{children:[k,G]}),t[46]=G,t[47]=k,t[48]=K):K=t[48],K}function U(e){let t=(0,R.c)(38),{assistant:n,selected:r,onSelect:i,onEdit:a,onDelete:o}=e,s=L.useRef(null),c=P(n.id,n.working),l;t[0]===n.name?l=t[1]:(l=N(n.name).displayName||n.name,t[0]=n.name,t[1]=l);let u=l,d;t[2]!==n.id||t[3]!==a?(d=()=>a(n.id),t[2]=n.id,t[3]=a,t[4]=d):d=t[4];let f;t[5]!==n||t[6]!==o?(f=()=>o(n),t[5]=n,t[6]=o,t[7]=f):f=t[7];let p=n.id,h;t[8]!==n.id||t[9]!==i?(h=()=>i(n.id),t[8]=n.id,t[9]=i,t[10]=h):h=t[10];let g=r?`bg-[var(--surface-muted)]`:`hover:bg-interactive-hover`,_;t[11]===g?_=t[12]:(_=m(`flex w-full min-w-0 max-w-28 flex-col items-center gap-2 rounded-2xl px-2 py-3 text-center outline-none transition-colors focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] active:bg-interactive-active motion-reduce:transition-none`,g),t[11]=g,t[12]=_);let v;t[13]!==n.avatarSeed||t[14]!==n.id||t[15]!==u||t[16]!==c?(v=(0,V.jsx)(F,{name:n.id,avatarSeed:n.avatarSeed,size:64,label:u,working:c,hoverTarget:s}),t[13]=n.avatarSeed,t[14]=n.id,t[15]=u,t[16]=c,t[17]=v):v=t[17];let y=n.unreadCount??0,b;t[18]===y?b=t[19]:(b=(0,V.jsx)(I,{count:y,className:`absolute -right-1 -top-1`}),t[18]=y,t[19]=b);let x;t[20]!==b||t[21]!==v?(x=(0,V.jsxs)(`span`,{className:`relative`,children:[v,b]}),t[20]=b,t[21]=v,t[22]=x):x=t[22];let S;t[23]===u?S=t[24]:(S=(0,V.jsx)(`span`,{className:`w-full truncate typography-ui-label font-medium leading-5`,children:u}),t[23]=u,t[24]=S);let C;t[25]!==n.id||t[26]!==u||t[27]!==r||t[28]!==x||t[29]!==S||t[30]!==h||t[31]!==_?(C=(0,V.jsxs)(`button`,{ref:s,type:`button`,role:`option`,"aria-selected":r,title:u,"data-assistant-pinned":p,"data-mobile-press-feedback":`soft`,onClick:h,className:_,children:[x,S]}),t[25]=n.id,t[26]=u,t[27]=r,t[28]=x,t[29]=S,t[30]=h,t[31]=_,t[32]=C):C=t[32];let w;return t[33]!==n||t[34]!==C||t[35]!==d||t[36]!==f?(w=(0,V.jsx)(H,{assistant:n,doubleClickMiniChat:!0,onEdit:d,onDelete:f,trigger:C}),t[33]=n,t[34]=C,t[35]=d,t[36]=f,t[37]=w):w=t[37],w}function W(e){let t=(0,R.c)(16),{contacts:n,selectedAssistantID:r,onSelect:i,onEdit:a,onDelete:o}=e,{t:s}=g();if(n.length===0)return null;let c;t[0]===s?c=t[1]:(c=s(`assistants.list.pinned`),t[0]=s,t[1]=c);let l;if(t[2]!==n||t[3]!==o||t[4]!==a||t[5]!==i||t[6]!==r){let e;t[8]!==o||t[9]!==a||t[10]!==i||t[11]!==r?(e=e=>(0,V.jsx)(U,{assistant:e,selected:e.id===r,onSelect:i,onEdit:a,onDelete:o},e.id),t[8]=o,t[9]=a,t[10]=i,t[11]=r,t[12]=e):e=t[12],l=n.map(e),t[2]=n,t[3]=o,t[4]=a,t[5]=i,t[6]=r,t[7]=l}else l=t[7];let u;return t[13]!==c||t[14]!==l?(u=(0,V.jsx)(`div`,{role:`group`,"aria-label":c,className:`yuri-assistant-pinned-contacts grid grid-cols-1 justify-items-center gap-2 pb-3 pt-2`,children:l}),t[13]=c,t[14]=l,t[15]=u):u=t[15],u}function G({snapshot:e,rowClassName:t,compact:n=!1,mobile:r=!1}){let{t:i}=g(),[a,o]=L.useState(!1),s=L.useRef(!1),c=d(async()=>{if(!s.current){s.current=!0,o(!0);try{(await k(e)).failed&&f.error(i(`assistants.unread.markAllFailed`))}catch{f.error(i(`assistants.unread.markAllFailed`))}finally{s.current=!1,o(!1)}}}),l=e.assistants.some(e=>(e.unreadCount??0)>0);return!n&&!l?null:(0,V.jsx)(`div`,{className:t,style:n&&!l?{visibility:`hidden`}:void 0,children:(0,V.jsx)(p,{type:`button`,variant:r?`mobileGlass`:`ghost`,size:r?`mobileIcon`:`icon`,onClick:c,"aria-label":i(`assistants.unread.markAll`),title:i(`assistants.unread.markAll`),disabled:a||!e.assistants.some(e=>(e.unreadCount??0)>0&&e.readTip),"aria-busy":a,children:(0,V.jsx)(h,{name:`check-double`,className:r?`size-5`:`size-4`})})})}async function K(e){await A(e);let t=_.getState().defaultShareAssistant;if(t?.assistantID!==e.id)return;let n=await j();n.serverInstanceID&&t.serverInstanceID===n.serverInstanceID&&_.getState().setDefaultShareAssistant(null)}function q({assistant:e,open:t,onOpenChange:n,onDeleted:r}){let{t:i}=g(),[a,o]=L.useState(!1),s=e?N(e.name).displayName||e.name:``,c=d(e=>{a&&!e||n(e)}),l=d(()=>{a||n(!1)}),u=d(async()=>{if(!(!e||a)){o(!0);try{await K(e),r?.(e.id),n(!1),f.success(i(`assistants.settings.toast.deleted`))}catch{f.error(i(`assistants.settings.toast.deleteFailed`))}finally{o(!1)}}});return(0,V.jsx)(C,{open:t&&e!==null,onOpenChange:c,children:(0,V.jsxs)(b,{className:`max-w-md`,children:[(0,V.jsxs)(v,{children:[(0,V.jsx)(x,{children:i(`assistants.settings.delete`)}),(0,V.jsx)(S,{children:i(`assistants.settings.deleteConfirm`,{name:s})})]}),(0,V.jsxs)(y,{children:[(0,V.jsx)(p,{size:`sm`,variant:`ghost`,onClick:l,disabled:a,children:i(`settings.common.actions.cancel`)}),(0,V.jsx)(p,{size:`sm`,variant:`destructive`,onClick:u,disabled:a,children:i(`settings.common.actions.delete`)})]})]})})}var J=`block min-w-0 max-w-full truncate typography-micro text-muted-foreground`,Y={image:`assistants.contact.attachment.image`,file:`assistants.contact.attachment.file`,session:`assistants.contact.card.session.untitled`,assistant:`assistants.title`,schedule:`assistants.settings.scheduledTasks.title`};function X(e,t){let n=e?.text??``;return(e?.fallbackKind?n:n.replace(/^\s{0,3}(?:`{3,}|~{3,})[\w+-]*(?:\s+|$)/gmu,``).replace(/`{3,}|~{3,}/gu,``).replace(/^\s{0,3}(?:#{1,6}\s+|(?:>\s*)+|[-+*]\s+(?:\[[ xX]\]\s*)?|\d+[.)]\s+)/gmu,``).replace(/!?\[([^\]\n]*)\]\([^\n)]*(?:\)|$)/gu,`$1`).replace(/!\[([^\]\n]*)(?:\]|$)/gu,`$1`).replace(/(`+)([^`\n]+)\1/gu,`$2`).replace(/(\*{1,3}|~~)(?=\S)(.+?)\1/gu,`$2`).replace(/(?<![\p{L}\p{N}_])(_{1,3})(?=\S)(.+?)\1(?![\p{L}\p{N}_])/gu,`$2`)).replace(/\s+/gu,` `).trim()||t(e?.fallbackKind?Y[e.fallbackKind]:`assistants.contact.empty`)}export{W as a,G as i,X as n,H as o,q as r,J as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{c as t,w as n}from"./runtime-auth-DA-qfGHk.js";import{i as r,t as i}from"./runtime-switch-DEPKHgdL.js";import{A as a,f as o}from"./platform-CNdx57HN.js";import{ot as s,st as c}from"./vendor-base-ui-wXsskyKm.js";import{n as l}from"./vendor-react-BkccXcWz.js";import{n as u}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{r as d}from"./vendor-reactuses-core-DjKFMfz7.js";import{r as f}from"./vendor-sonner-DX3nfJx4.js";import{Yn as p,no as m}from"./ui-DLZtbTLJ.js";import{n as h}from"./Icon-DrO1MlqW.js";import{t as g}from"./i18n-BU8XOKjS.js";import{i as _}from"./useAssistantUIStore-DEiMjSqf.js";import{a as v,i as y,n as b,o as x,r as S,t as C}from"./dialog-C67GCo29.js";import{a as w,i as T,n as E,r as D,t as O}from"./context-menu-C6YvSFUQ.js";import{c as k,i as A,o as j,p as M}from"./assistantQueries-wJSqumUZ.js";import{t as N}from"./assistantPresentation-DRbsH1Ej.js";import{r as P,t as F}from"./AssistantWorkingAvatar-D8BEeeXa.js";import{n as I}from"./AssistantUnreadBadge-DMz3nOHJ.js";var L=e(c(),1),R=l(),z=()=>o()&&!n(),B=async e=>{if(!z())throw Error(`Assistant Mini Chat requires a direct desktop connection`);await a(`desktop_open_assistant_mini_chat_window`,{assistantID:e,apiBaseUrl:i(),clientToken:t()})},V=s();function H(e){let t=(0,R.c)(49),{assistant:n,trigger:i,onEdit:a,onDelete:o,doubleClickMiniChat:s}=e,c=s!==void 0&&s,{t:l}=g(),d;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(d=r(),t[0]=d):d=t[0];let p;t[1]===n.id?p=t[2]:(p=[d,`assistants`,n.id,`pin`],t[1]=n.id,t[2]=p);let m;t[3]===n?m=t[4]:(m=()=>M(n,{pinned:n.pinnedAt==null}),t[3]=n,t[4]=m);let _;t[5]===l?_=t[6]:(_=()=>f.error(l(`assistants.menu.pinError`)),t[5]=l,t[6]=_);let v;t[7]!==p||t[8]!==m||t[9]!==_?(v={mutationKey:p,mutationFn:m,onError:_},t[7]=p,t[8]=m,t[9]=_,t[10]=v):v=t[10];let y=u(v),b;t[11]!==n.id||t[12]!==l?(b=()=>{B(n.id).catch(()=>f.error(l(`miniChat.actions.failed`)))},t[11]=n.id,t[12]=l,t[13]=b):b=t[13];let x=b,S=i,C;t[14]!==S||t[15]!==c||t[16]!==x||t[17]!==i?(C=c?L.cloneElement(S,{onDoubleClick:e=>{S.props.onDoubleClick?.(e),!e.defaultPrevented&&z()&&x()}}):i,t[14]=S,t[15]=c,t[16]=x,t[17]=i,t[18]=C):C=t[18];let k;t[19]===C?k=t[20]:(k=(0,V.jsx)(w,{render:C}),t[19]=C,t[20]=k);let A;t[21]!==n.pinnedAt||t[22]!==y||t[23]!==l?(A=n.pinnedAt===void 0?null:(0,V.jsxs)(D,{disabled:y.isPending,onClick:()=>y.mutate(),children:[(0,V.jsx)(h,{name:n.pinnedAt==null?`pushpin-2`:`unpin`,className:`size-4`}),l(n.pinnedAt==null?`assistants.menu.pin`:`assistants.menu.unpin`)]}),t[21]=n.pinnedAt,t[22]=y,t[23]=l,t[24]=A):A=t[24];let j;t[25]!==x||t[26]!==l?(j=z()?(0,V.jsxs)(D,{onClick:x,children:[(0,V.jsx)(h,{name:`external-link`,className:`size-4`}),l(`sessions.sidebar.session.menu.openMiniChatWindow`)]}):null,t[25]=x,t[26]=l,t[27]=j):j=t[27];let N;t[28]===Symbol.for(`react.memo_cache_sentinel`)?(N=(0,V.jsx)(h,{name:`edit`,className:`size-4`}),t[28]=N):N=t[28];let P;t[29]===l?P=t[30]:(P=l(`assistants.menu.edit`),t[29]=l,t[30]=P);let F;t[31]!==a||t[32]!==P?(F=(0,V.jsxs)(D,{onClick:a,children:[N,P]}),t[31]=a,t[32]=P,t[33]=F):F=t[33];let I;t[34]===Symbol.for(`react.memo_cache_sentinel`)?(I=(0,V.jsx)(T,{}),t[34]=I):I=t[34];let H;t[35]===Symbol.for(`react.memo_cache_sentinel`)?(H=(0,V.jsx)(h,{name:`delete-bin`,className:`size-4 text-inherit`}),t[35]=H):H=t[35];let U;t[36]===l?U=t[37]:(U=l(`assistants.settings.delete`),t[36]=l,t[37]=U);let W;t[38]!==o||t[39]!==U?(W=(0,V.jsxs)(D,{onClick:o,className:`text-[var(--status-error)] focus:text-[var(--status-error)] data-[highlighted]:text-[var(--status-error)]`,children:[H,U]}),t[38]=o,t[39]=U,t[40]=W):W=t[40];let G;t[41]!==A||t[42]!==j||t[43]!==F||t[44]!==W?(G=(0,V.jsxs)(E,{className:`min-w-[10rem]`,children:[A,j,F,I,W]}),t[41]=A,t[42]=j,t[43]=F,t[44]=W,t[45]=G):G=t[45];let K;return t[46]!==G||t[47]!==k?(K=(0,V.jsxs)(O,{children:[k,G]}),t[46]=G,t[47]=k,t[48]=K):K=t[48],K}function U(e){let t=(0,R.c)(38),{assistant:n,selected:r,onSelect:i,onEdit:a,onDelete:o}=e,s=L.useRef(null),c=P(n.id,n.working),l;t[0]===n.name?l=t[1]:(l=N(n.name).displayName||n.name,t[0]=n.name,t[1]=l);let u=l,d;t[2]!==n.id||t[3]!==a?(d=()=>a(n.id),t[2]=n.id,t[3]=a,t[4]=d):d=t[4];let f;t[5]!==n||t[6]!==o?(f=()=>o(n),t[5]=n,t[6]=o,t[7]=f):f=t[7];let p=n.id,h;t[8]!==n.id||t[9]!==i?(h=()=>i(n.id),t[8]=n.id,t[9]=i,t[10]=h):h=t[10];let g=r?`bg-[var(--surface-muted)]`:`hover:bg-interactive-hover`,_;t[11]===g?_=t[12]:(_=m(`flex w-full min-w-0 max-w-28 flex-col items-center gap-2 rounded-2xl px-2 py-3 text-center outline-none transition-colors focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] active:bg-interactive-active motion-reduce:transition-none`,g),t[11]=g,t[12]=_);let v;t[13]!==n.avatarSeed||t[14]!==n.id||t[15]!==u||t[16]!==c?(v=(0,V.jsx)(F,{name:n.id,avatarSeed:n.avatarSeed,size:64,label:u,working:c,hoverTarget:s}),t[13]=n.avatarSeed,t[14]=n.id,t[15]=u,t[16]=c,t[17]=v):v=t[17];let y=n.unreadCount??0,b;t[18]===y?b=t[19]:(b=(0,V.jsx)(I,{count:y,className:`absolute -right-1 -top-1`}),t[18]=y,t[19]=b);let x;t[20]!==b||t[21]!==v?(x=(0,V.jsxs)(`span`,{className:`relative`,children:[v,b]}),t[20]=b,t[21]=v,t[22]=x):x=t[22];let S;t[23]===u?S=t[24]:(S=(0,V.jsx)(`span`,{className:`w-full truncate typography-ui-label font-medium leading-5`,children:u}),t[23]=u,t[24]=S);let C;t[25]!==n.id||t[26]!==u||t[27]!==r||t[28]!==x||t[29]!==S||t[30]!==h||t[31]!==_?(C=(0,V.jsxs)(`button`,{ref:s,type:`button`,role:`option`,"aria-selected":r,title:u,"data-assistant-pinned":p,"data-mobile-press-feedback":`soft`,onClick:h,className:_,children:[x,S]}),t[25]=n.id,t[26]=u,t[27]=r,t[28]=x,t[29]=S,t[30]=h,t[31]=_,t[32]=C):C=t[32];let w;return t[33]!==n||t[34]!==C||t[35]!==d||t[36]!==f?(w=(0,V.jsx)(H,{assistant:n,doubleClickMiniChat:!0,onEdit:d,onDelete:f,trigger:C}),t[33]=n,t[34]=C,t[35]=d,t[36]=f,t[37]=w):w=t[37],w}function W(e){let t=(0,R.c)(16),{contacts:n,selectedAssistantID:r,onSelect:i,onEdit:a,onDelete:o}=e,{t:s}=g();if(n.length===0)return null;let c;t[0]===s?c=t[1]:(c=s(`assistants.list.pinned`),t[0]=s,t[1]=c);let l;if(t[2]!==n||t[3]!==o||t[4]!==a||t[5]!==i||t[6]!==r){let e;t[8]!==o||t[9]!==a||t[10]!==i||t[11]!==r?(e=e=>(0,V.jsx)(U,{assistant:e,selected:e.id===r,onSelect:i,onEdit:a,onDelete:o},e.id),t[8]=o,t[9]=a,t[10]=i,t[11]=r,t[12]=e):e=t[12],l=n.map(e),t[2]=n,t[3]=o,t[4]=a,t[5]=i,t[6]=r,t[7]=l}else l=t[7];let u;return t[13]!==c||t[14]!==l?(u=(0,V.jsx)(`div`,{role:`group`,"aria-label":c,className:`yuri-assistant-pinned-contacts grid grid-cols-1 justify-items-center gap-2 pb-3 pt-2`,children:l}),t[13]=c,t[14]=l,t[15]=u):u=t[15],u}function G({snapshot:e,rowClassName:t,compact:n=!1,mobile:r=!1}){let{t:i}=g(),[a,o]=L.useState(!1),s=L.useRef(!1),c=d(async()=>{if(!s.current){s.current=!0,o(!0);try{(await k(e)).failed&&f.error(i(`assistants.unread.markAllFailed`))}catch{f.error(i(`assistants.unread.markAllFailed`))}finally{s.current=!1,o(!1)}}}),l=e.assistants.some(e=>(e.unreadCount??0)>0);return!n&&!l?null:(0,V.jsx)(`div`,{className:t,style:n&&!l?{visibility:`hidden`}:void 0,children:(0,V.jsx)(p,{type:`button`,variant:r?`mobileGlass`:`ghost`,size:r?`mobileIcon`:`icon`,onClick:c,"aria-label":i(`assistants.unread.markAll`),title:i(`assistants.unread.markAll`),disabled:a||!e.assistants.some(e=>(e.unreadCount??0)>0&&e.readTip),"aria-busy":a,children:(0,V.jsx)(h,{name:`check-double`,className:r?`size-5`:`size-4`})})})}async function K(e){await A(e);let t=_.getState().defaultShareAssistant;if(t?.assistantID!==e.id)return;let n=await j();n.serverInstanceID&&t.serverInstanceID===n.serverInstanceID&&_.getState().setDefaultShareAssistant(null)}function q({assistant:e,open:t,onOpenChange:n,onDeleted:r}){let{t:i}=g(),[a,o]=L.useState(!1),s=e?N(e.name).displayName||e.name:``,c=d(e=>{a&&!e||n(e)}),l=d(()=>{a||n(!1)}),u=d(async()=>{if(!(!e||a)){o(!0);try{await K(e),r?.(e.id),n(!1),f.success(i(`assistants.settings.toast.deleted`))}catch{f.error(i(`assistants.settings.toast.deleteFailed`))}finally{o(!1)}}});return(0,V.jsx)(C,{open:t&&e!==null,onOpenChange:c,children:(0,V.jsxs)(b,{className:`max-w-md`,children:[(0,V.jsxs)(v,{children:[(0,V.jsx)(x,{children:i(`assistants.settings.delete`)}),(0,V.jsx)(S,{children:i(`assistants.settings.deleteConfirm`,{name:s})})]}),(0,V.jsxs)(y,{children:[(0,V.jsx)(p,{size:`sm`,variant:`ghost`,onClick:l,disabled:a,children:i(`settings.common.actions.cancel`)}),(0,V.jsx)(p,{size:`sm`,variant:`destructive`,onClick:u,disabled:a,children:i(`settings.common.actions.delete`)})]})]})})}var J=`block min-w-0 max-w-full truncate typography-micro text-muted-foreground`,Y={image:`assistants.contact.attachment.image`,file:`assistants.contact.attachment.file`,session:`assistants.contact.card.session.untitled`,assistant:`assistants.title`,schedule:`assistants.settings.scheduledTasks.title`};function X(e,t){let n=e?.text??``;return(e?.fallbackKind?n:n.replace(/^\s{0,3}(?:`{3,}|~{3,})[\w+-]*(?:\s+|$)/gmu,``).replace(/`{3,}|~{3,}/gu,``).replace(/^\s{0,3}(?:#{1,6}\s+|(?:>\s*)+|[-+*]\s+(?:\[[ xX]\]\s*)?|\d+[.)]\s+)/gmu,``).replace(/!?\[([^\]\n]*)\]\([^\n)]*(?:\)|$)/gu,`$1`).replace(/!\[([^\]\n]*)(?:\]|$)/gu,`$1`).replace(/(`+)([^`\n]+)\1/gu,`$2`).replace(/(\*{1,3}|~~)(?=\S)(.+?)\1/gu,`$2`).replace(/(?<![\p{L}\p{N}_])(_{1,3})(?=\S)(.+?)\1(?![\p{L}\p{N}_])/gu,`$2`)).replace(/\s+/gu,` `).trim()||t(e?.fallbackKind?Y[e.fallbackKind]:`assistants.contact.empty`)}export{W as a,G as i,X as n,H as o,q as r,J as t};
@@ -1 +1 @@
1
- import{r 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{st as i}from"./vendor-base-ui-wXsskyKm.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{s as o}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{P as s,W as c}from"./runtime-file-resource-DKJJoOOc.js";import{Tt as l}from"./ui-z2JsXLmb.js";import{i as u}from"./store-DWS9gJPW.js";var d=e(i(),1),f=a(),p=class extends Error{code;status;resource;constructor(e,t,n,r){super(typeof r==`string`&&r.trim()?r.trim():e),this.code=e,this.status=t,this.resource=n}},m=e=>{if(!e||typeof e!=`object`)return!1;let t=`name`in e?String(e.name):``;return t===`AbortError`||t===`TimeoutError`},h=class extends p{operation;constructor(e,t,n){super(e,t,`share_operation`),this.operation=n}},g=(e,t=200)=>{throw new p(`invalid_${e}_response`,t,e)},_=(e,t)=>e&&typeof e==`object`&&!Array.isArray(e)?e:g(t),v=(e,t)=>typeof e==`string`?e:g(t),y=(e,t)=>e===null||typeof e==`string`?e:g(t),b=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:g(t),x=(e,t)=>e===null?null:b(e,t),S=(e,t)=>typeof e==`boolean`?e:g(t),C=(e,t,n)=>t.includes(e)?e:g(n),w=e=>{let t=_(e,`capability`);return{supported:S(t.supported,`capability`),enabled:S(t.enabled,`capability`),revision:b(t.revision,`capability`),serverInstanceID:y(t.serverInstanceID,`capability`),sharingAvailable:t.sharingAvailable!==void 0&&S(t.sharingAvailable,`capability`)}},T=e=>{if(e==null)return null;let t=_(e,`assistant`);return{turnID:v(t.turnID,`assistant`),messageID:v(t.messageID,`assistant`),status:C(t.status,[`queued`,`running`],`assistant`),admittedAt:b(t.admittedAt,`assistant`)}},E=e=>{if(e==null)return null;let t=_(e,`assistant_preview`),n=b(t.ordinal,`assistant_preview`);return!Number.isSafeInteger(n)||n<0?g(`assistant_preview`):{...t.createdAt===void 0?{}:{createdAt:b(t.createdAt,`assistant_preview`)},messageID:v(t.messageID,`assistant_preview`),ordinal:n,role:C(t.role,[`user`,`assistant`],`assistant_preview`),text:v(t.text,`assistant_preview`),fallbackKind:t.fallbackKind===null?null:C(t.fallbackKind,[`image`,`file`,`session`,`assistant`,`schedule`],`assistant_preview`)}},D=e=>{let t=b(e,`assistant_read`);return Number.isSafeInteger(t)&&t>=0?t:g(`assistant_read`)},O=e=>{let t=_(e,`assistant_read`);return{generation:D(t.generation),ordinal:D(t.ordinal),messageID:v(t.messageID,`assistant_read`)}},ee=e=>({unreadCount:e.unreadCount===void 0?0:D(e.unreadCount),readWatermark:e.readWatermark==null?null:O(e.readWatermark),readTip:e.readTip==null?null:O(e.readTip)}),te=e=>{let t=_(e,`assistant_read`);return{assistantID:v(t.assistantID,`assistant_read`),changed:S(t.changed,`assistant_read`),unreadCount:D(t.unreadCount),readWatermark:O(t.readWatermark),readTip:O(t.readTip),revision:D(t.revision)}},k=e=>{let t=_(e,`assistant`),n=Array.isArray(t.historySessionIDs)?t.historySessionIDs.map(e=>v(e,`assistant`)):[],r=t.historySessionCount===void 0?n.length:b(t.historySessionCount,`assistant`);if(!Number.isSafeInteger(r)||r<n.length)return g(`assistant`);let i=Array.isArray(t.assignedSessionIDs)?t.assignedSessionIDs.map(e=>v(e,`assistant`)):[],a=t.activeContactTurn===void 0?null:T(t.activeContactTurn),o=t.working===void 0?a!=null:S(t.working,`assistant`);return{...ee(t),pinnedAt:t.pinnedAt===void 0?void 0:x(t.pinnedAt,`assistant`),latestMessagePreview:E(t.latestMessagePreview),id:v(t.id,`assistant`),avatarSeed:v(t.avatarSeed??t.id,`assistant`),revision:b(t.revision,`assistant`),enabled:S(t.enabled,`assistant`),name:v(t.name,`assistant`),defaultPrompt:v(t.defaultPrompt,`assistant`),workspacePath:y(t.workspacePath,`assistant`),effectiveWorkspacePath:v(t.effectiveWorkspacePath,`assistant`),managedWorkspacePath:y(t.managedWorkspacePath??null,`assistant`),providerID:v(t.providerID,`assistant`),modelID:v(t.modelID,`assistant`),agent:y(t.agent,`assistant`),variant:y(t.variant??null,`assistant`),mode:C(t.mode,[`continuous`,`stateless`],`assistant`),sessionID:y(t.sessionID,`assistant`),sessionGeneration:b(t.sessionGeneration,`assistant`),historySessionIDs:n,historySessionCount:r,assignedSessionIDs:i,working:o,activeContactTurn:a,createdAt:x(t.createdAt,`assistant`),updatedAt:b(t.updatedAt,`assistant`),tombstoneAt:x(t.tombstoneAt,`assistant`)}},ne=e=>{let t=_(e,`snapshot`);return{revision:b(t.revision,`snapshot`),enabled:S(t.enabled,`snapshot`),assistants:Array.isArray(t.assistants)?t.assistants.map(k):g(`snapshot`)}},re=e=>{let t=_(e,`binding`);return{sessionID:y(t.sessionID,`binding`),directory:v(t.directory,`binding`),sessionGeneration:b(t.sessionGeneration,`binding`)}},ie=e=>{let t=_(e,`message_admission`);if(t.admitted!==!0)return g(`message_admission`);let n=t.revision===void 0||t.revision===null?null:b(t.revision,`message_admission`);return{binding:re(t.binding),messageID:v(t.messageID,`message_admission`),admitted:!0,revision:n,...t.replayed===!0?{replayed:!0}:{}}},A=e=>{let t=_(e,`share_operation`);return{operationID:v(t.operationID,`share_operation`),assistantID:v(t.assistantID,`share_operation`),sessionID:y(t.sessionID,`share_operation`),messageID:y(t.messageID,`share_operation`),state:C(t.state,[`submitting`,`running`,`completed`,`failed`,`unresolved`],`share_operation`),phase:v(t.phase,`share_operation`),attempt:b(t.attempt,`share_operation`),leaseExpiresAt:x(t.leaseExpiresAt,`share_operation`),errorCode:y(t.errorCode,`share_operation`)}},ae=e=>{let t=_(e,`assistant_contact_part`);if(t.type===`text`)return{type:`text`,text:v(t.text,`assistant_contact_part`)};if(t.type===`file`){let e=t.filename===void 0||t.filename===null?void 0:v(t.filename,`assistant_contact_part`),n=v(t.mime,`assistant_contact_part`),r=t.url!==void 0&&t.url!==null,i=t.attachmentID!==void 0&&t.attachmentID!==null;if(r&&i)return g(`assistant_contact_part`);if(i){let r=b(t.size,`assistant_contact_part`);return!Number.isSafeInteger(r)||r<0?g(`assistant_contact_part`):{type:`file`,mime:n,attachmentID:v(t.attachmentID,`assistant_contact_part`),sha256:v(t.sha256,`assistant_contact_part`),size:r,...e?{filename:e}:{}}}return r?{type:`file`,mime:n,url:v(t.url,`assistant_contact_part`),...e?{filename:e}:{}}:g(`assistant_contact_part`)}if(t.type===`card`){let e=C(t.cardType,[`session`,`assistant`,`schedule`],`assistant_contact_part`);if(e===`session`){let e;if(t.target!==void 0){let n=_(t.target,`assistant_contact_part`),r=e=>{let t=v(n[e],`assistant_contact_part`);return!t||t!==t.trim()||t.length>512||Array.from(t).some(e=>e.charCodeAt(0)<32)?g(`assistant_contact_part`):t};e={hubId:r(`hubId`),hostId:r(`hostId`),instanceId:r(`instanceId`)}}return{type:`card`,cardType:`session`,sessionID:v(t.sessionID,`assistant_contact_part`),directory:v(t.directory,`assistant_contact_part`),title:y(t.title??null,`assistant_contact_part`),status:y(t.status??null,`assistant_contact_part`),branch:y(t.branch??null,`assistant_contact_part`),...e?{target:e}:{}}}return e===`assistant`?{type:`card`,cardType:`assistant`,assistantID:v(t.assistantID,`assistant_contact_part`),name:v(t.name,`assistant_contact_part`),providerID:v(t.providerID,`assistant_contact_part`),modelID:v(t.modelID,`assistant_contact_part`),mode:C(t.mode??`continuous`,[`continuous`,`stateless`],`assistant_contact_part`)}:{type:`card`,cardType:`schedule`,taskID:v(t.taskID,`assistant_contact_part`),projectID:v(t.projectID,`assistant_contact_part`),name:v(t.name,`assistant_contact_part`),kind:y(t.kind??null,`assistant_contact_part`),time:y(t.time??null,`assistant_contact_part`),timezone:y(t.timezone??null,`assistant_contact_part`),prompt:y(t.prompt??null,`assistant_contact_part`),...t.cron===void 0?{}:{cron:y(t.cron,`assistant_contact_part`)},...t.date===void 0?{}:{date:y(t.date,`assistant_contact_part`)},...t.times===void 0?{}:{times:t.times===null?null:Array.isArray(t.times)?t.times.map(e=>v(e,`assistant_contact_part`)):g(`assistant_contact_part`)},...t.weekdays===void 0?{}:{weekdays:t.weekdays===null?null:Array.isArray(t.weekdays)?t.weekdays.map(e=>{let t=b(e,`assistant_contact_part`);return Number.isInteger(t)&&t>=0&&t<=6?t:g(`assistant_contact_part`)}):g(`assistant_contact_part`)}}}return g(`assistant_contact_part`)},oe=e=>{let t=_(e,`assistant_contact`),n=y(t.nextCursor,`assistant_contact`),r=S(t.complete,`assistant_contact`);if(!r&&!n||r&&n||!Array.isArray(t.messages))return g(`assistant_contact`);let i=b(t.generation,`assistant_contact`),a=b(t.revision,`assistant_contact`);return!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(a)||a<0?g(`assistant_contact`):{messages:t.messages.map(e=>{let t=_(e,`assistant_contact_message`);if(!Array.isArray(t.parts))return g(`assistant_contact_message`);let n=t.parts.map(ae);return{messageID:v(t.messageID,`assistant_contact_message`),assistantID:v(t.assistantID,`assistant_contact_message`),role:C(t.role,[`user`,`assistant`,`peer`],`assistant_contact_message`),turnID:v(t.turnID,`assistant_contact_message`),bubbleIndex:b(t.bubbleIndex,`assistant_contact_message`),createdAt:b(t.createdAt,`assistant_contact_message`),ordinal:b(t.ordinal,`assistant_contact_message`),status:v(t.status,`assistant_contact_message`),fromAssistantID:y(t.fromAssistantID??null,`assistant_contact_message`),fromAssistantName:y(t.fromAssistantName??null,`assistant_contact_message`),parts:n,text:typeof t.text==`string`?t.text:n.filter(e=>e.type===`text`).map(e=>e.text).join(``),cards:n.filter(e=>e.type===`card`)}}),nextCursor:n,complete:r,generation:i,revision:a}},se=e=>{let t=_(e,`assistant_scheduled_tasks`);return Array.isArray(t.tasks)?{tasks:t.tasks.map(e=>{let t=_(e,`assistant_scheduled_task`),n=t.task===null||t.task===void 0?null:_(t.task,`assistant_scheduled_task_live`);return{assistantID:v(t.assistantID,`assistant_scheduled_task`),projectID:v(t.projectID,`assistant_scheduled_task`),taskID:v(t.taskID,`assistant_scheduled_task`),createdAt:b(t.createdAt,`assistant_scheduled_task`),projectPath:y(t.projectPath??null,`assistant_scheduled_task`),projectLabel:y(t.projectLabel??null,`assistant_scheduled_task`),task:n}})}:g(`assistant_scheduled_tasks`)},j=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim().length>0)return t.error}catch{return t}return t},M=e=>{let t=typeof e==`string`?e.trim():``;if(!t)throw Error(`projectId is required`);return t},N=e=>e===null||typeof e==`string`,ce=e=>e===null||typeof e==`number`&&Number.isFinite(e),le=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=864e13,ue=e=>e===null||le(e),de=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.projectId==`string`&&t.projectId.length>0&&typeof t.taskId==`string`&&t.taskId.length>0&&typeof t.taskName==`string`&&(t.trigger===`scheduled`||t.trigger===`manual`)&&(t.status===`running`||t.status===`success`||t.status===`error`)&&N(t.sessionId)&&N(t.directory)&&N(t.error)&&le(t.startedAt)&&ue(t.finishedAt)&&ce(t.durationMs)&&(t.durationMs===null||t.durationMs>=0)},fe=e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed scheduled task runs response`);let t=e;if(!Array.isArray(t.runs)||!t.runs.every(de)||!N(t.nextCursor)||typeof t.complete!=`boolean`||t.complete!==(t.nextCursor===null)||t.nextCursor!==null&&t.nextCursor.length===0)throw Error(`Malformed scheduled task runs response`);return{runs:t.runs,nextCursor:t.nextCursor,complete:t.complete}},pe=async(e,t)=>{let n=new URLSearchParams;e.before&&n.set(`before`,e.before);let i=e.limit??20;if(!Number.isInteger(i)||i<1)throw Error(`limit must be a positive integer`);n.set(`limit`,String(i)),e.projectId&&n.set(`projectId`,e.projectId),e.taskId&&n.set(`taskId`,e.taskId);let a=await r(`/api/yuri/scheduled-task-runs?${n.toString()}`,{signal:t});if(!a.ok)throw Error(await j(a,`Failed to load scheduled task history`));return fe(await a.json().catch(()=>null))},me=async({signal:e}={})=>{let t=await r(`/api/yuri/scheduled-tasks`,{signal:e});if(!t.ok)throw Error(await j(t,`Failed to load schedules`));let n=await t.json().catch(()=>null);if(!n||!Array.isArray(n.tasks))throw Error(`Malformed schedules response`);return{tasks:Array.isArray(n?.tasks)?n.tasks:[],failedProjectIds:Array.isArray(n?.failedProjectIds)?n.failedProjectIds.filter(e=>typeof e==`string`):[]}},he=async(e,t)=>{let n=M(e),i=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks`,{method:`PUT`,headers:{"content-type":`application/json`,accept:`application/json`},body:JSON.stringify({task:t})});if(!i.ok)throw Error(await j(i,`Failed to save schedule`));let a=await i.json().catch(()=>null);return!a||!Array.isArray(a.tasks)?[]:a.tasks},ge=async(e,t)=>{let n=M(e),i=M(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}`,{method:`DELETE`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await j(a,`Failed to delete schedule`));let o=await a.json().catch(()=>null);return!o||!Array.isArray(o.tasks)?[]:o.tasks},_e=async(e,t)=>{let n=M(e),i=M(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}/run`,{method:`POST`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await j(a,`Failed to run schedule`));let o=await a.json().catch(()=>null);return{sessionId:typeof o?.sessionId==`string`&&o.sessionId.length>0?o.sessionId:void 0}},P=(e,t)=>e.ordinal===t.ordinal?e.messageID<t.messageID?-1:+(e.messageID>t.messageID):e.ordinal-t.ordinal,ve=e=>{if(e.type===`file`||e.type===`card`)return!0;if(e.type!==`text`)return!1;let t=typeof e.text==`string`?e.text.trim():``;return!!t&&!t.startsWith(`yuri.settle.`)&&!t.startsWith(`oc.settle.`)},ye=(e,t)=>{if(!t||!e.readTip||!((e.unreadCount??0)>0))return null;let n=e.readTip;if(t.generation!==n.generation)return null;let r;for(let n=t.messages.length-1;n>=0;--n){let i=t.messages[n];if(i.assistantID===e.id&&(i.status===`complete`||i.status===`error`)&&i.parts.some(ve)){r=i;break}}if(!r)return null;let i=e.readWatermark;return i&&(i.generation>t.generation||i.generation===t.generation&&P({ordinal:i.ordinal,messageID:i.messageID},{ordinal:r.ordinal,messageID:r.messageID})>=0)?null:{generation:t.generation,ordinal:r.ordinal,messageID:r.messageID}},be=()=>({messages:[],generation:-1,revision:0,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}),F=e=>!!(e&&e.generation>=0),I=(e,t)=>P({ordinal:e.ordinal,messageID:e.messageID},{ordinal:t.ordinal,messageID:t.messageID}),L=(e,t,n=`incoming`)=>{let r=new Map;for(let t of e)r.set(t.messageID,t);for(let e of t)(n===`incoming`||!r.has(e.messageID))&&r.set(e.messageID,e);return[...r.values()].sort(I)},xe=e=>{let t=1/0;for(let n of e)n.ordinal<t&&(t=n.ordinal);return Number.isFinite(t)?t:null},R=e=>e.map(e=>e.messageID),z=(e,t)=>{for(let n of e)if(t.has(n))return!0;return!1},B=e=>new Set(e),Se=(e,t)=>!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n]),Ce=e=>({...e,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null}),V=e=>({ordinal:e.ordinal,messageID:e.messageID}),we=(e,t,n)=>{if(n)return[...t];if(t.length===0)return[...e];let r=t[0];return[...e.filter(e=>P(V(e),V(r))<0),...t]},Te=(e,t)=>{let n=e??be(),r=F(n),i=[...t.messages].sort(I),a=R(i);if(r&&t.generation<n.generation)return n;if(r&&t.generation>n.generation)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};if(!r)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};let o=Math.max(n.revision,t.revision),s=t.revision>=n.revision;if(i.length===0)return s&&t.complete?{messages:[],generation:t.generation,revision:o,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}:{...n,generation:t.generation,revision:o,olderCursor:n.olderCursor??t.nextCursor,olderComplete:n.olderComplete&&t.complete,liveWindowIDs:[],hasMessageGap:n.hasMessageGap,gapCursor:n.hasMessageGap?t.nextCursor??n.gapCursor:null,gapRequestIDs:n.hasMessageGap?n.gapRequestIDs:null,gapTargetIDs:n.hasMessageGap?n.gapTargetIDs:null};let c;if(s)c=we(n.messages,i,t.complete);else{let e=xe(i);c=L(n.messages.filter(t=>t.ordinal<e),L(n.messages.filter(t=>t.ordinal>=e),i,`existing`),`incoming`)}let l=n.liveWindowIDs,u=B(a),d=l.length>0&&z(l,u),f=n.hasMessageGap,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs;if(!d&&l.length>0&&t.nextCursor){f=!0,p=t.nextCursor;let e=l.filter(e=>!u.has(e));m=e.length>0?e:[...l],h=n.hasMessageGap&&n.gapTargetIDs&&n.gapTargetIDs.length>0?n.gapTargetIDs:m}else n.hasMessageGap?(f=!0,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs):(f=!1,p=null,m=null,h=null);return{messages:c,generation:t.generation,revision:o,olderCursor:n.liveWindowIDs.length===0&&n.messages.length===0?t.complete?null:t.nextCursor:n.olderCursor,olderComplete:!r||n.liveWindowIDs.length===0&&n.messages.length===0?t.complete:n.olderComplete,hasMessageGap:f,gapCursor:f?p:null,gapRequestIDs:f?m:null,gapTargetIDs:f?h:null,liveWindowIDs:a}},Ee=(e,t)=>{if(!F(e)||t.generation!==e.generation)return e;let n=t.revision>=e.revision?`incoming`:`existing`,r=L(e.messages,t.messages,n);return{...e,messages:r,revision:Math.max(e.revision,t.revision),olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete}},De=(e,t,n)=>{if(!F(e)||t.generation!==e.generation)return e;let r=t.revision>=e.revision?`incoming`:`existing`,i=L(e.messages,t.messages,r),a=Math.max(e.revision,t.revision),o=n?.requestIDs??e.gapRequestIDs;if(!(e.hasMessageGap&&o&&e.gapRequestIDs&&Se(o,e.gapRequestIDs)))return{...e,messages:i,revision:a};let s=R(t.messages),c=e.gapTargetIDs??[],l=B(c);return c.length>0&&z(s,l)||t.complete||!t.nextCursor?Ce({...e,messages:i,revision:a}):{...e,messages:i,revision:a,hasMessageGap:!0,gapCursor:t.nextCursor??e.gapCursor,gapRequestIDs:e.gapRequestIDs,gapTargetIDs:e.gapTargetIDs}},H={snapshot:(e=t())=>[e,`assistants`,`snapshot`],capability:(e=t())=>[e,`assistants`,`capability`],history:(e,r,i,a=t(),o=n())=>[a,o,`assistants`,`history`,e,r,i],contact:(e,r=t(),i=n())=>[r,i,`assistants`,`contact`,e],scheduledTasks:(e,r=t(),i=n())=>[r,i,`assistants`,`scheduled-tasks`,e],globalScheduledTasks:(e=t())=>[e,`scheduled-tasks`]},U=async(e,t={})=>{let n=await r(e,t),i=await n.json().catch(()=>null);if(!n.ok){let e=i&&typeof i==`object`&&`error`in i&&typeof i.error==`string`?i.error:`request_failed`,t=i&&typeof i==`object`&&`message`in i&&typeof i.message==`string`?i.message:void 0;throw new p(e,n.status,void 0,t)}return i},W=(e,t)=>({method:e,headers:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),G=(e,r)=>{if(t()!==e||n()!==r)throw new p(`runtime_stale`,409)},Oe=(e,t,r)=>{c.setQueryData(H.snapshot(r),n=>n&&{...n,assistants:n.assistants.map(n=>n.id!==e||n.sessionGeneration>t.sessionGeneration?n:{...n,sessionID:t.sessionID,sessionGeneration:t.sessionGeneration,effectiveWorkspacePath:t.directory})}),c.invalidateQueries({queryKey:H.snapshot(r)}),c.invalidateQueries({queryKey:[r,n(),`assistants`,`history`,e]})},ke=(e,t)=>{c.setQueryData(H.snapshot(t),t=>t&&{...t,assistants:t.assistants.some(t=>t.id===e.id)?t.assistants.map(t=>t.id===e.id?e:t):[...t.assistants,e]}),c.invalidateQueries({queryKey:H.snapshot(t)})},Ae=2500,je=15e3,Me=e=>!!e?.assistants.some(e=>e.working||e.activeContactTurn),Ne=(e,t={})=>{if(t.assistantID){let n=e?.assistants.find(e=>e.id===t.assistantID);return n?.working||n?.activeContactTurn?Ae:je}return Me(e)?Ae:je},K=(e=t())=>({queryKey:H.snapshot(e),queryFn:async({signal:e})=>ne(await U(`/api/yuri/assistants/snapshot`,{signal:e})),staleTime:0,retry:2,refetchInterval:e=>Ne(e.state.data),refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),q=new Map,J=e=>{let r=q.get(e);if(r)r.count+=1;else{let r=n(),i=!1,a=!1,o=!1,l=()=>!i&&t()===e&&n()===r,u=async()=>{if(o=!0,!a){a=!0;try{do o=!1,c.getQueryCache().find({queryKey:H.snapshot(e),exact:!0})?.state.fetchStatus===`fetching`&&(o=!0),await c.invalidateQueries({queryKey:H.snapshot(e),exact:!0},{cancelRefetch:!1});while(o&&l())}finally{a=!1}}},d=s(t=>{if(!l())return;let n=c.getQueryData(H.snapshot(e));(t.type===`event-stream-ready`||t.type===`contact-turn-start`||t.type===`contact-turn-end`||t.type===`assistants-changed`&&(!n||t.revision>n.revision))&&u()});q.set(e,{count:1,dispose:()=>{i=!0,d()}})}return()=>{let t=q.get(e);t&&--t.count===0&&(t.dispose(),q.delete(e))}},Pe=e=>{let n=(0,f.c)(7),r,i,a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=t(),i=o,r=K(a),n[0]=r,n[1]=i,n[2]=a):(r=n[0],i=n[1],a=n[2]);let s;n[3]===e?s=n[4]:(s={...r,select:e},n[3]=e,n[4]=s);let c=i(s),l,u;return n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>J(a),u=[a],n[5]=l,n[6]=u):(l=n[5],u=n[6]),d.useEffect(l,u),c},Fe=e=>e.enabled?e.assistants.reduce((e,t)=>e+(t.unreadCount??0),0):0,Ie=()=>{let e=(0,f.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=o,r={...K(i),select:Fe},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),s,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>J(i),c=[i],e[3]=s,e[4]=c):(s=e[3],c=e[4]),d.useEffect(s,c),a.data??0},Le=e=>e.enabled&&Me(e),Re=()=>{let e=(0,f.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=o,r={...K(i),select:Le},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),s,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>J(i),c=[i],e[3]=s,e[4]=c):(s=e[3],c=e[4]),d.useEffect(s,c),a.data??!1},ze=(e,t={})=>{let n=new URLSearchParams;return n.set(`limit`,String(t.limit??20)),t.before&&n.set(`before`,t.before),t.messageID&&n.set(`messageID`,t.messageID),`/api/yuri/assistants/${encodeURIComponent(e)}/contact/messages?${n}`},Y=async(e,t,n)=>oe(await U(ze(e,t),n?{signal:n}:{})),Be=(e,t)=>e.generation===t.generation&&e.revision===t.revision&&e.olderCursor===t.olderCursor&&e.olderComplete===t.olderComplete&&e.hasMessageGap===t.hasMessageGap&&e.gapCursor===t.gapCursor&&e.messages===t.messages&&e.liveWindowIDs===t.liveWindowIDs&&e.gapRequestIDs===t.gapRequestIDs&&e.gapTargetIDs===t.gapTargetIDs,X=new Map,Z=new Map,Q=e=>e.join(``),Ve=async(e,t,n,r,i)=>{let a=Q(t),o=Z.get(a);if(o)return o;let s=(async()=>{let a=c.getQueryData(t)??n,o=0,s=!1,l=!1,u=a.gapRequestIDs?[...a.gapRequestIDs]:null,d=a.gapCursor;for(;a.hasMessageGap&&a.gapCursor&&o<5&&!i?.aborted;){G(r.transport,r.runtimeGeneration),o+=1;let n=a.gapCursor;try{let o=await Y(e,{limit:20,before:n},i);G(r.transport,r.runtimeGeneration);let l=c.getQueryData(t)??a;if(o.generation!==l.generation){a=l;break}let f=!u||!!(l.hasMessageGap&&l.gapRequestIDs&&l.gapRequestIDs.length===u.length&&l.gapRequestIDs.every((e,t)=>e===u[t]));if(a=De(l,o,u?{requestIDs:u,cursor:d}:void 0),c.setQueryData(t,a),!f)break;if(!a.hasMessageGap){s=!0;break}if(a.gapCursor&&a.gapCursor!==n)s=!0;else break}catch(e){if(i?.aborted||m(e))break;l=!0,a=c.getQueryData(t)??a;break}}return{view:c.getQueryData(t)??a,failed:l,progressed:s}})();Z.set(a,s);try{return await s}finally{Z.get(a)===s&&Z.delete(a)}},He=(e,r=t(),i=n(),a={})=>({queryKey:H.contact(e,r,i),queryFn:async({signal:t})=>{G(r,i),await l(),G(r,i);let n=H.contact(e,r,i),a=c.getQueryData(n),o=await Y(e,{limit:20},t);G(r,i);let s=Te(c.getQueryData(n)??a??null,o);c.setQueryData(n,s);let u=Q(n);if(s.hasMessageGap&&s.gapCursor){X.delete(u);let a=await Ve(e,n,s,{transport:r,runtimeGeneration:i},t);s=a.view,(a.failed||a.view.hasMessageGap&&!a.progressed)&&a.view.gapCursor&&X.set(u,a.view.gapCursor)}else X.delete(u);G(r,i);let d=c.getQueryData(n)??s;return a&&Be(a,d)?a:d},retry:2,staleTime:0,refetchInterval:()=>a.reconcileInForeground?Ne(c.getQueryData(H.snapshot(r)),{assistantID:e}):!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,structuralSharing:!0}),Ue=(e,r=!0)=>{let i=t(),a=n(),[l,u]=d.useState(!1),[f,p]=d.useState(null),[h,g]=d.useState(!1),_=d.useRef(null),v=d.useRef(null),y=d.useRef(null),b=d.useRef(null),x=d.useRef({assistantID:e,transport:i,runtimeGeneration:a,enabled:r});x.current={assistantID:e,transport:i,runtimeGeneration:a,enabled:r};let S=o({...He(e,i,a,{reconcileInForeground:!0}),enabled:r&&!!e});d.useEffect(()=>{!r||!e||c.invalidateQueries({queryKey:H.snapshot(i),exact:!0},{cancelRefetch:!1})},[e,r,a,i]),d.useEffect(()=>s(n=>{t()===i&&(n.type===`assistants-changed`||n.type===`event-stream-ready`||n.type===`contact-turn-end`)&&(n.type===`contact-turn-end`&&`assistantID`in n&&n.assistantID!==e||c.invalidateQueries({queryKey:H.contact(e,i,a),exact:!0}))}),[e,a,i]),d.useEffect(()=>{let t=Q(H.contact(e,i,a));return()=>{y.current?.abort(),b.current?.abort(),y.current=null,b.current=null,_.current=null,v.current=null,X.delete(t)}},[e,i,a,r]);let C=S.data,w=H.contact(e,i,a),T=async()=>{if(!e||!r)return;if(_.current)return _.current;let t=c.getQueryData(w)??C;if(!t||t.olderComplete||!t.olderCursor)return;p(null),u(!0);let n=new AbortController;b.current?.abort(),b.current=n;let o={transport:i,runtimeGeneration:a,assistantID:e,cursor:t.olderCursor},s=(async()=>{try{G(o.transport,o.runtimeGeneration);let e=await Y(o.assistantID,{limit:20,before:o.cursor},n.signal);if(n.signal.aborted||(G(o.transport,o.runtimeGeneration),x.current.assistantID!==o.assistantID||x.current.transport!==o.transport||x.current.runtimeGeneration!==o.runtimeGeneration))return;let r=c.getQueryData(w)??t;if(e.generation!==r.generation)return;c.setQueryData(w,Ee(r,e))}catch(e){if(n.signal.aborted||m(e))return;let t=e instanceof Error?e:Error(String(e));throw p(t),t}finally{b.current===n&&(b.current=null),u(!1),_.current=null}})();return _.current=s,s},E=async(t=`explicit`)=>{if(!e||!r)return;if(v.current)return v.current;let n=c.getQueryData(w)??C;if(!n?.hasMessageGap||!n.gapCursor)return;let o=Q(w);if(t===`auto`&&X.get(o)===n.gapCursor)return;t===`explicit`&&X.delete(o),g(!0);let s=new AbortController;y.current?.abort(),y.current=s;let l={transport:i,runtimeGeneration:a,assistantID:e,cursor:n.gapCursor},u=(async()=>{try{G(l.transport,l.runtimeGeneration);let e=await Ve(l.assistantID,w,n,{transport:l.transport,runtimeGeneration:l.runtimeGeneration},s.signal);if(s.signal.aborted)return;if(G(l.transport,l.runtimeGeneration),e.failed||!e.progressed){e.view.gapCursor&&X.set(o,e.view.gapCursor);return}e.view.hasMessageGap||X.delete(o)}catch(e){if(s.signal.aborted||m(e))return;throw X.set(o,l.cursor),e}finally{y.current===s&&(y.current=null),g(!1),v.current=null}})();return v.current=u,u};return d.useEffect(()=>{if(!r||!e||!C?.hasMessageGap||!C.gapCursor||S.isFetching||h)return;let t=Q(w);X.get(t)!==C.gapCursor&&E(`auto`).catch(()=>void 0)},[r,e,C?.hasMessageGap,C?.gapCursor,S.isFetching,h,w]),{data:C?{messages:C.messages,generation:C.generation,revision:C.revision,nextCursor:C.olderCursor,complete:C.olderComplete}:void 0,status:S.status,fetchStatus:S.fetchStatus,isError:S.isError,isPending:S.isPending,isFetching:S.isFetching,isSuccess:S.isSuccess,error:S.error instanceof Error?S.error:S.error?Error(String(S.error)):null,refetch:()=>S.refetch(),fetchPreviousPage:T,hasPreviousPage:!!(C&&!C.olderComplete&&C.olderCursor),isFetchingPreviousPage:l,previousPageError:f,hasMessageGap:!!C?.hasMessageGap,isFillingMessageGap:h,retryMessageGap:()=>E(`explicit`)}},We=async(e,r)=>{let i=t(),a=n();await l(),G(i,a);let o=await Y(e,{messageID:r,limit:1});if(G(i,a),!o.messages.some(e=>e.messageID===r&&e.role===`user`))return null;c.invalidateQueries({queryKey:H.contact(e,i,a),exact:!0}),c.invalidateQueries({queryKey:H.snapshot(i),exact:!0});let s=c.getQueryData(H.snapshot(i));return{admitted:!0,messageID:r,revision:o.revision??s?.revision??null}},Ge=(e,r=t(),i=n())=>({queryKey:H.scheduledTasks(e,r,i),queryFn:async({signal:t})=>{G(r,i);let n=se(await U(`/api/yuri/assistants/${encodeURIComponent(e)}/scheduled-tasks`,{signal:t}));return G(r,i),n},refetchOnMount:`always`,retry:(e,t)=>!(t instanceof p&&t.status===404)&&e<2}),Ke=(e,r)=>{let i=(0,f.c)(6),a=r===void 0||r,s,c;if(i[0]!==e){let r=t(),a=n();c=o,s=Ge(e,r,a),i[0]=e,i[1]=s,i[2]=c}else s=i[1],c=i[2];let l=a&&!!e,u;return i[3]!==s||i[4]!==l?(u={...s,enabled:l},i[3]=s,i[4]=l,i[5]=u):u=i[5],c(u)},$=(e=t())=>({queryKey:H.globalScheduledTasks(e),queryFn:me,refetchOnMount:`always`}),qe=e=>{let t=(0,f.c)(3),n=e===void 0||e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=$(),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i={...r,enabled:n},t[1]=n,t[2]=i),o(i)},Je=e=>e.tasks.some(({task:e})=>e.state.lastStatus===`running`),Ye=()=>{let e=(0,f.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=o,r={...$(i),select:Je,staleTime:0,refetchInterval:mt,refetchIntervalInBackground:!1},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),l,u;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>s(e=>{t()===i&&(e.type===`scheduled-task-ran`||e.type===`event-stream-ready`)&&c.invalidateQueries({queryKey:$(i).queryKey,exact:!0})}),u=[i],e[3]=l,e[4]=u):(l=e[3],u=e[4]),d.useEffect(l,u),a.data===!0},Xe=(e,r=t())=>{c.invalidateQueries({queryKey:[r,n(),`assistants`,`contact`,e]})},Ze=(e=t())=>({queryKey:H.capability(e),queryFn:()=>dt(),retry:!1}),Qe=()=>{let e=(0,f.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=Ze(),e[0]=t):t=e[0],o(t)},$e=(e=c,n=t())=>e.getQueryData(H.snapshot(n)),et=(e=c,n=t())=>e.fetchQuery(K(n)),tt=async(e=c)=>{let r=t(),i=n();await e.invalidateQueries({queryKey:H.snapshot(r),exact:!0}),G(r,i);let a=await e.fetchQuery(K(r));return G(r,i),a},nt=15e3,rt=e=>{throw e instanceof p?e:m(e)?new p(`admission_timeout`,408):e},it=async(e,r,i)=>{let a=t(),o=n(),s=typeof i==`string`?[{type:`text`,text:i}]:Array.isArray(i.parts)&&i.parts.length>0?i.parts:[{type:`text`,text:i.text??``}],c=AbortSignal.timeout(nt);try{let t=ie(await U(`/api/yuri/assistants/${encodeURIComponent(e)}/messages`,{...W(`POST`,{messageID:r,parts:s,language:u.getState().locale}),signal:c}));return G(a,o),Oe(e,t.binding,a),Xe(e,a),t}catch(e){return rt(e)}},at=async(e,r,i,a,o)=>{let s=t(),c=n(),l=A(await U(`/api/yuri/assistants/${encodeURIComponent(e)}/share`,W(`POST`,{operationID:r,payload:{messageID:i,parts:a,source:o}})));return G(s,c),l},ot=async(e,r=t(),i=n())=>{G(r,i);let a=A(await U(`/api/yuri/assistants/share-operations/${encodeURIComponent(e)}`));return G(r,i),a},st=async(e,r=t(),i=n())=>{let a=e;for(let e=0;e<60&&(a.state===`running`||a.state===`submitting`);e+=1)G(r,i),await new Promise(e=>setTimeout(e,750)),a=await ot(a.operationID,r,i);if(G(r,i),a.state===`completed`)return a;throw a.state===`failed`?new h(a.errorCode??`share_failed`,400,a):new h(`share_unresolved`,408,a)},ct=async e=>{let n=t(),r=k(await U(`/api/yuri/assistants`,W(`POST`,{...e,language:u.getState().locale})));return ke(r,n),r},lt=async(e,r)=>{let i=t(),a=n(),o=k(await U(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,W(`PATCH`,{...r,expectedRevision:e.revision})));return G(i,a),r.pinned===void 0?ke(o,i):(await c.cancelQueries({queryKey:H.snapshot(i),exact:!0}),G(i,a),await c.fetchQuery(K(i)),G(i,a)),o},ut=async e=>{await U(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,W(`DELETE`,{expectedRevision:e.revision})),await c.invalidateQueries({queryKey:H.snapshot(t())})},dt=async()=>w(await U(`/api/yuri/assistants/capability`)),ft=async(e,r)=>{let i=t(),a=n(),o=O(r);try{let t=te(await U(`/api/yuri/assistants/${encodeURIComponent(e)}/contact/read`,{...W(`POST`,o),signal:AbortSignal.timeout(15e3)}));if(G(i,a),t.assistantID!==e)throw new p(`invalid_assistant_read_response`,200);return t}finally{t()===i&&n()===a&&c.invalidateQueries({queryKey:H.snapshot(i),exact:!0})}},pt=async e=>{let r=e.assistants.filter(e=>(e.unreadCount??0)>0&&e.readTip).map(e=>({id:e.id,position:{...e.readTip}})),i=t(),a=n(),o=[];for(let e=0;e<r.length;e+=4)o.push(...await Promise.allSettled(r.slice(e,e+4).map(async e=>(G(i,a),ft(e.id,e.position)))));return{failed:o.filter(e=>e.status===`rejected`).length}};function mt(e){return e.state.data&&Je(e.state.data)?2500:15e3}export{p as A,ye as C,pe as D,me as E,m as M,_e as O,st as S,ge as T,Pe as _,et as a,qe as b,pt as c,it as d,at as f,Ke as g,Ue as h,ut as i,h as j,he as k,ft as l,Qe as m,We as n,dt as o,lt as p,ct as r,tt as s,He as t,$e as u,Ie as v,ve as w,Ye as x,Re as y};
1
+ import{r 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{st as i}from"./vendor-base-ui-wXsskyKm.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{s as o}from"./vendor-tanstack-react-query-DIb_ItL-.js";import{P as s,W as c}from"./runtime-file-resource-DKJJoOOc.js";import{Tt as l}from"./ui-DLZtbTLJ.js";import{i as u}from"./store-DWS9gJPW.js";var d=e(i(),1),f=a(),p=class extends Error{code;status;resource;constructor(e,t,n,r){super(typeof r==`string`&&r.trim()?r.trim():e),this.code=e,this.status=t,this.resource=n}},m=e=>{if(!e||typeof e!=`object`)return!1;let t=`name`in e?String(e.name):``;return t===`AbortError`||t===`TimeoutError`},h=class extends p{operation;constructor(e,t,n){super(e,t,`share_operation`),this.operation=n}},g=(e,t=200)=>{throw new p(`invalid_${e}_response`,t,e)},_=(e,t)=>e&&typeof e==`object`&&!Array.isArray(e)?e:g(t),v=(e,t)=>typeof e==`string`?e:g(t),y=(e,t)=>e===null||typeof e==`string`?e:g(t),b=(e,t)=>typeof e==`number`&&Number.isFinite(e)?e:g(t),x=(e,t)=>e===null?null:b(e,t),S=(e,t)=>typeof e==`boolean`?e:g(t),C=(e,t,n)=>t.includes(e)?e:g(n),w=e=>{let t=_(e,`capability`);return{supported:S(t.supported,`capability`),enabled:S(t.enabled,`capability`),revision:b(t.revision,`capability`),serverInstanceID:y(t.serverInstanceID,`capability`),sharingAvailable:t.sharingAvailable!==void 0&&S(t.sharingAvailable,`capability`)}},T=e=>{if(e==null)return null;let t=_(e,`assistant`);return{turnID:v(t.turnID,`assistant`),messageID:v(t.messageID,`assistant`),status:C(t.status,[`queued`,`running`],`assistant`),admittedAt:b(t.admittedAt,`assistant`)}},E=e=>{if(e==null)return null;let t=_(e,`assistant_preview`),n=b(t.ordinal,`assistant_preview`);return!Number.isSafeInteger(n)||n<0?g(`assistant_preview`):{...t.createdAt===void 0?{}:{createdAt:b(t.createdAt,`assistant_preview`)},messageID:v(t.messageID,`assistant_preview`),ordinal:n,role:C(t.role,[`user`,`assistant`],`assistant_preview`),text:v(t.text,`assistant_preview`),fallbackKind:t.fallbackKind===null?null:C(t.fallbackKind,[`image`,`file`,`session`,`assistant`,`schedule`],`assistant_preview`)}},D=e=>{let t=b(e,`assistant_read`);return Number.isSafeInteger(t)&&t>=0?t:g(`assistant_read`)},O=e=>{let t=_(e,`assistant_read`);return{generation:D(t.generation),ordinal:D(t.ordinal),messageID:v(t.messageID,`assistant_read`)}},ee=e=>({unreadCount:e.unreadCount===void 0?0:D(e.unreadCount),readWatermark:e.readWatermark==null?null:O(e.readWatermark),readTip:e.readTip==null?null:O(e.readTip)}),te=e=>{let t=_(e,`assistant_read`);return{assistantID:v(t.assistantID,`assistant_read`),changed:S(t.changed,`assistant_read`),unreadCount:D(t.unreadCount),readWatermark:O(t.readWatermark),readTip:O(t.readTip),revision:D(t.revision)}},k=e=>{let t=_(e,`assistant`),n=Array.isArray(t.historySessionIDs)?t.historySessionIDs.map(e=>v(e,`assistant`)):[],r=t.historySessionCount===void 0?n.length:b(t.historySessionCount,`assistant`);if(!Number.isSafeInteger(r)||r<n.length)return g(`assistant`);let i=Array.isArray(t.assignedSessionIDs)?t.assignedSessionIDs.map(e=>v(e,`assistant`)):[],a=t.activeContactTurn===void 0?null:T(t.activeContactTurn),o=t.working===void 0?a!=null:S(t.working,`assistant`);return{...ee(t),pinnedAt:t.pinnedAt===void 0?void 0:x(t.pinnedAt,`assistant`),latestMessagePreview:E(t.latestMessagePreview),id:v(t.id,`assistant`),avatarSeed:v(t.avatarSeed??t.id,`assistant`),revision:b(t.revision,`assistant`),enabled:S(t.enabled,`assistant`),name:v(t.name,`assistant`),defaultPrompt:v(t.defaultPrompt,`assistant`),workspacePath:y(t.workspacePath,`assistant`),effectiveWorkspacePath:v(t.effectiveWorkspacePath,`assistant`),managedWorkspacePath:y(t.managedWorkspacePath??null,`assistant`),providerID:v(t.providerID,`assistant`),modelID:v(t.modelID,`assistant`),agent:y(t.agent,`assistant`),variant:y(t.variant??null,`assistant`),mode:C(t.mode,[`continuous`,`stateless`],`assistant`),sessionID:y(t.sessionID,`assistant`),sessionGeneration:b(t.sessionGeneration,`assistant`),historySessionIDs:n,historySessionCount:r,assignedSessionIDs:i,working:o,activeContactTurn:a,createdAt:x(t.createdAt,`assistant`),updatedAt:b(t.updatedAt,`assistant`),tombstoneAt:x(t.tombstoneAt,`assistant`)}},ne=e=>{let t=_(e,`snapshot`);return{revision:b(t.revision,`snapshot`),enabled:S(t.enabled,`snapshot`),assistants:Array.isArray(t.assistants)?t.assistants.map(k):g(`snapshot`)}},re=e=>{let t=_(e,`binding`);return{sessionID:y(t.sessionID,`binding`),directory:v(t.directory,`binding`),sessionGeneration:b(t.sessionGeneration,`binding`)}},ie=e=>{let t=_(e,`message_admission`);if(t.admitted!==!0)return g(`message_admission`);let n=t.revision===void 0||t.revision===null?null:b(t.revision,`message_admission`);return{binding:re(t.binding),messageID:v(t.messageID,`message_admission`),admitted:!0,revision:n,...t.replayed===!0?{replayed:!0}:{}}},A=e=>{let t=_(e,`share_operation`);return{operationID:v(t.operationID,`share_operation`),assistantID:v(t.assistantID,`share_operation`),sessionID:y(t.sessionID,`share_operation`),messageID:y(t.messageID,`share_operation`),state:C(t.state,[`submitting`,`running`,`completed`,`failed`,`unresolved`],`share_operation`),phase:v(t.phase,`share_operation`),attempt:b(t.attempt,`share_operation`),leaseExpiresAt:x(t.leaseExpiresAt,`share_operation`),errorCode:y(t.errorCode,`share_operation`)}},ae=e=>{let t=_(e,`assistant_contact_part`);if(t.type===`text`)return{type:`text`,text:v(t.text,`assistant_contact_part`)};if(t.type===`file`){let e=t.filename===void 0||t.filename===null?void 0:v(t.filename,`assistant_contact_part`),n=v(t.mime,`assistant_contact_part`),r=t.url!==void 0&&t.url!==null,i=t.attachmentID!==void 0&&t.attachmentID!==null;if(r&&i)return g(`assistant_contact_part`);if(i){let r=b(t.size,`assistant_contact_part`);return!Number.isSafeInteger(r)||r<0?g(`assistant_contact_part`):{type:`file`,mime:n,attachmentID:v(t.attachmentID,`assistant_contact_part`),sha256:v(t.sha256,`assistant_contact_part`),size:r,...e?{filename:e}:{}}}return r?{type:`file`,mime:n,url:v(t.url,`assistant_contact_part`),...e?{filename:e}:{}}:g(`assistant_contact_part`)}if(t.type===`card`){let e=C(t.cardType,[`session`,`assistant`,`schedule`],`assistant_contact_part`);if(e===`session`){let e;if(t.target!==void 0){let n=_(t.target,`assistant_contact_part`),r=e=>{let t=v(n[e],`assistant_contact_part`);return!t||t!==t.trim()||t.length>512||Array.from(t).some(e=>e.charCodeAt(0)<32)?g(`assistant_contact_part`):t};e={hubId:r(`hubId`),hostId:r(`hostId`),instanceId:r(`instanceId`)}}return{type:`card`,cardType:`session`,sessionID:v(t.sessionID,`assistant_contact_part`),directory:v(t.directory,`assistant_contact_part`),title:y(t.title??null,`assistant_contact_part`),status:y(t.status??null,`assistant_contact_part`),branch:y(t.branch??null,`assistant_contact_part`),...e?{target:e}:{}}}return e===`assistant`?{type:`card`,cardType:`assistant`,assistantID:v(t.assistantID,`assistant_contact_part`),name:v(t.name,`assistant_contact_part`),providerID:v(t.providerID,`assistant_contact_part`),modelID:v(t.modelID,`assistant_contact_part`),mode:C(t.mode??`continuous`,[`continuous`,`stateless`],`assistant_contact_part`)}:{type:`card`,cardType:`schedule`,taskID:v(t.taskID,`assistant_contact_part`),projectID:v(t.projectID,`assistant_contact_part`),name:v(t.name,`assistant_contact_part`),kind:y(t.kind??null,`assistant_contact_part`),time:y(t.time??null,`assistant_contact_part`),timezone:y(t.timezone??null,`assistant_contact_part`),prompt:y(t.prompt??null,`assistant_contact_part`),...t.cron===void 0?{}:{cron:y(t.cron,`assistant_contact_part`)},...t.date===void 0?{}:{date:y(t.date,`assistant_contact_part`)},...t.times===void 0?{}:{times:t.times===null?null:Array.isArray(t.times)?t.times.map(e=>v(e,`assistant_contact_part`)):g(`assistant_contact_part`)},...t.weekdays===void 0?{}:{weekdays:t.weekdays===null?null:Array.isArray(t.weekdays)?t.weekdays.map(e=>{let t=b(e,`assistant_contact_part`);return Number.isInteger(t)&&t>=0&&t<=6?t:g(`assistant_contact_part`)}):g(`assistant_contact_part`)}}}return g(`assistant_contact_part`)},oe=e=>{let t=_(e,`assistant_contact`),n=y(t.nextCursor,`assistant_contact`),r=S(t.complete,`assistant_contact`);if(!r&&!n||r&&n||!Array.isArray(t.messages))return g(`assistant_contact`);let i=b(t.generation,`assistant_contact`),a=b(t.revision,`assistant_contact`);return!Number.isSafeInteger(i)||i<0||!Number.isSafeInteger(a)||a<0?g(`assistant_contact`):{messages:t.messages.map(e=>{let t=_(e,`assistant_contact_message`);if(!Array.isArray(t.parts))return g(`assistant_contact_message`);let n=t.parts.map(ae);return{messageID:v(t.messageID,`assistant_contact_message`),assistantID:v(t.assistantID,`assistant_contact_message`),role:C(t.role,[`user`,`assistant`,`peer`],`assistant_contact_message`),turnID:v(t.turnID,`assistant_contact_message`),bubbleIndex:b(t.bubbleIndex,`assistant_contact_message`),createdAt:b(t.createdAt,`assistant_contact_message`),ordinal:b(t.ordinal,`assistant_contact_message`),status:v(t.status,`assistant_contact_message`),fromAssistantID:y(t.fromAssistantID??null,`assistant_contact_message`),fromAssistantName:y(t.fromAssistantName??null,`assistant_contact_message`),parts:n,text:typeof t.text==`string`?t.text:n.filter(e=>e.type===`text`).map(e=>e.text).join(``),cards:n.filter(e=>e.type===`card`)}}),nextCursor:n,complete:r,generation:i,revision:a}},se=e=>{let t=_(e,`assistant_scheduled_tasks`);return Array.isArray(t.tasks)?{tasks:t.tasks.map(e=>{let t=_(e,`assistant_scheduled_task`),n=t.task===null||t.task===void 0?null:_(t.task,`assistant_scheduled_task_live`);return{assistantID:v(t.assistantID,`assistant_scheduled_task`),projectID:v(t.projectID,`assistant_scheduled_task`),taskID:v(t.taskID,`assistant_scheduled_task`),createdAt:b(t.createdAt,`assistant_scheduled_task`),projectPath:y(t.projectPath??null,`assistant_scheduled_task`),projectLabel:y(t.projectLabel??null,`assistant_scheduled_task`),task:n}})}:g(`assistant_scheduled_tasks`)},j=async(e,t)=>{try{let t=await e.json();if(t&&typeof t.error==`string`&&t.error.trim().length>0)return t.error}catch{return t}return t},M=e=>{let t=typeof e==`string`?e.trim():``;if(!t)throw Error(`projectId is required`);return t},N=e=>e===null||typeof e==`string`,ce=e=>e===null||typeof e==`number`&&Number.isFinite(e),le=e=>typeof e==`number`&&Number.isFinite(e)&&e>=0&&e<=864e13,ue=e=>e===null||le(e),de=e=>{if(!e||typeof e!=`object`||Array.isArray(e))return!1;let t=e;return typeof t.id==`string`&&t.id.length>0&&typeof t.projectId==`string`&&t.projectId.length>0&&typeof t.taskId==`string`&&t.taskId.length>0&&typeof t.taskName==`string`&&(t.trigger===`scheduled`||t.trigger===`manual`)&&(t.status===`running`||t.status===`success`||t.status===`error`)&&N(t.sessionId)&&N(t.directory)&&N(t.error)&&le(t.startedAt)&&ue(t.finishedAt)&&ce(t.durationMs)&&(t.durationMs===null||t.durationMs>=0)},fe=e=>{if(!e||typeof e!=`object`||Array.isArray(e))throw Error(`Malformed scheduled task runs response`);let t=e;if(!Array.isArray(t.runs)||!t.runs.every(de)||!N(t.nextCursor)||typeof t.complete!=`boolean`||t.complete!==(t.nextCursor===null)||t.nextCursor!==null&&t.nextCursor.length===0)throw Error(`Malformed scheduled task runs response`);return{runs:t.runs,nextCursor:t.nextCursor,complete:t.complete}},pe=async(e,t)=>{let n=new URLSearchParams;e.before&&n.set(`before`,e.before);let i=e.limit??20;if(!Number.isInteger(i)||i<1)throw Error(`limit must be a positive integer`);n.set(`limit`,String(i)),e.projectId&&n.set(`projectId`,e.projectId),e.taskId&&n.set(`taskId`,e.taskId);let a=await r(`/api/yuri/scheduled-task-runs?${n.toString()}`,{signal:t});if(!a.ok)throw Error(await j(a,`Failed to load scheduled task history`));return fe(await a.json().catch(()=>null))},me=async({signal:e}={})=>{let t=await r(`/api/yuri/scheduled-tasks`,{signal:e});if(!t.ok)throw Error(await j(t,`Failed to load schedules`));let n=await t.json().catch(()=>null);if(!n||!Array.isArray(n.tasks))throw Error(`Malformed schedules response`);return{tasks:Array.isArray(n?.tasks)?n.tasks:[],failedProjectIds:Array.isArray(n?.failedProjectIds)?n.failedProjectIds.filter(e=>typeof e==`string`):[]}},he=async(e,t)=>{let n=M(e),i=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks`,{method:`PUT`,headers:{"content-type":`application/json`,accept:`application/json`},body:JSON.stringify({task:t})});if(!i.ok)throw Error(await j(i,`Failed to save schedule`));let a=await i.json().catch(()=>null);return!a||!Array.isArray(a.tasks)?[]:a.tasks},ge=async(e,t)=>{let n=M(e),i=M(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}`,{method:`DELETE`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await j(a,`Failed to delete schedule`));let o=await a.json().catch(()=>null);return!o||!Array.isArray(o.tasks)?[]:o.tasks},_e=async(e,t)=>{let n=M(e),i=M(t),a=await r(`/api/projects/${encodeURIComponent(n)}/scheduled-tasks/${encodeURIComponent(i)}/run`,{method:`POST`,headers:{accept:`application/json`}});if(!a.ok)throw Error(await j(a,`Failed to run schedule`));let o=await a.json().catch(()=>null);return{sessionId:typeof o?.sessionId==`string`&&o.sessionId.length>0?o.sessionId:void 0}},P=(e,t)=>e.ordinal===t.ordinal?e.messageID<t.messageID?-1:+(e.messageID>t.messageID):e.ordinal-t.ordinal,ve=e=>{if(e.type===`file`||e.type===`card`)return!0;if(e.type!==`text`)return!1;let t=typeof e.text==`string`?e.text.trim():``;return!!t&&!t.startsWith(`yuri.settle.`)&&!t.startsWith(`oc.settle.`)},ye=(e,t)=>{if(!t||!e.readTip||!((e.unreadCount??0)>0))return null;let n=e.readTip;if(t.generation!==n.generation)return null;let r;for(let n=t.messages.length-1;n>=0;--n){let i=t.messages[n];if(i.assistantID===e.id&&(i.status===`complete`||i.status===`error`)&&i.parts.some(ve)){r=i;break}}if(!r)return null;let i=e.readWatermark;return i&&(i.generation>t.generation||i.generation===t.generation&&P({ordinal:i.ordinal,messageID:i.messageID},{ordinal:r.ordinal,messageID:r.messageID})>=0)?null:{generation:t.generation,ordinal:r.ordinal,messageID:r.messageID}},be=()=>({messages:[],generation:-1,revision:0,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}),F=e=>!!(e&&e.generation>=0),I=(e,t)=>P({ordinal:e.ordinal,messageID:e.messageID},{ordinal:t.ordinal,messageID:t.messageID}),L=(e,t,n=`incoming`)=>{let r=new Map;for(let t of e)r.set(t.messageID,t);for(let e of t)(n===`incoming`||!r.has(e.messageID))&&r.set(e.messageID,e);return[...r.values()].sort(I)},xe=e=>{let t=1/0;for(let n of e)n.ordinal<t&&(t=n.ordinal);return Number.isFinite(t)?t:null},R=e=>e.map(e=>e.messageID),z=(e,t)=>{for(let n of e)if(t.has(n))return!0;return!1},B=e=>new Set(e),Se=(e,t)=>!e||!t||e.length!==t.length?!1:e.every((e,n)=>e===t[n]),Ce=e=>({...e,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null}),V=e=>({ordinal:e.ordinal,messageID:e.messageID}),we=(e,t,n)=>{if(n)return[...t];if(t.length===0)return[...e];let r=t[0];return[...e.filter(e=>P(V(e),V(r))<0),...t]},Te=(e,t)=>{let n=e??be(),r=F(n),i=[...t.messages].sort(I),a=R(i);if(r&&t.generation<n.generation)return n;if(r&&t.generation>n.generation)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};if(!r)return{messages:i,generation:t.generation,revision:t.revision,olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:a};let o=Math.max(n.revision,t.revision),s=t.revision>=n.revision;if(i.length===0)return s&&t.complete?{messages:[],generation:t.generation,revision:o,olderCursor:null,olderComplete:!0,hasMessageGap:!1,gapCursor:null,gapRequestIDs:null,gapTargetIDs:null,liveWindowIDs:[]}:{...n,generation:t.generation,revision:o,olderCursor:n.olderCursor??t.nextCursor,olderComplete:n.olderComplete&&t.complete,liveWindowIDs:[],hasMessageGap:n.hasMessageGap,gapCursor:n.hasMessageGap?t.nextCursor??n.gapCursor:null,gapRequestIDs:n.hasMessageGap?n.gapRequestIDs:null,gapTargetIDs:n.hasMessageGap?n.gapTargetIDs:null};let c;if(s)c=we(n.messages,i,t.complete);else{let e=xe(i);c=L(n.messages.filter(t=>t.ordinal<e),L(n.messages.filter(t=>t.ordinal>=e),i,`existing`),`incoming`)}let l=n.liveWindowIDs,u=B(a),d=l.length>0&&z(l,u),f=n.hasMessageGap,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs;if(!d&&l.length>0&&t.nextCursor){f=!0,p=t.nextCursor;let e=l.filter(e=>!u.has(e));m=e.length>0?e:[...l],h=n.hasMessageGap&&n.gapTargetIDs&&n.gapTargetIDs.length>0?n.gapTargetIDs:m}else n.hasMessageGap?(f=!0,p=n.gapCursor,m=n.gapRequestIDs,h=n.gapTargetIDs):(f=!1,p=null,m=null,h=null);return{messages:c,generation:t.generation,revision:o,olderCursor:n.liveWindowIDs.length===0&&n.messages.length===0?t.complete?null:t.nextCursor:n.olderCursor,olderComplete:!r||n.liveWindowIDs.length===0&&n.messages.length===0?t.complete:n.olderComplete,hasMessageGap:f,gapCursor:f?p:null,gapRequestIDs:f?m:null,gapTargetIDs:f?h:null,liveWindowIDs:a}},Ee=(e,t)=>{if(!F(e)||t.generation!==e.generation)return e;let n=t.revision>=e.revision?`incoming`:`existing`,r=L(e.messages,t.messages,n);return{...e,messages:r,revision:Math.max(e.revision,t.revision),olderCursor:t.complete?null:t.nextCursor,olderComplete:t.complete}},De=(e,t,n)=>{if(!F(e)||t.generation!==e.generation)return e;let r=t.revision>=e.revision?`incoming`:`existing`,i=L(e.messages,t.messages,r),a=Math.max(e.revision,t.revision),o=n?.requestIDs??e.gapRequestIDs;if(!(e.hasMessageGap&&o&&e.gapRequestIDs&&Se(o,e.gapRequestIDs)))return{...e,messages:i,revision:a};let s=R(t.messages),c=e.gapTargetIDs??[],l=B(c);return c.length>0&&z(s,l)||t.complete||!t.nextCursor?Ce({...e,messages:i,revision:a}):{...e,messages:i,revision:a,hasMessageGap:!0,gapCursor:t.nextCursor??e.gapCursor,gapRequestIDs:e.gapRequestIDs,gapTargetIDs:e.gapTargetIDs}},H={snapshot:(e=t())=>[e,`assistants`,`snapshot`],capability:(e=t())=>[e,`assistants`,`capability`],history:(e,r,i,a=t(),o=n())=>[a,o,`assistants`,`history`,e,r,i],contact:(e,r=t(),i=n())=>[r,i,`assistants`,`contact`,e],scheduledTasks:(e,r=t(),i=n())=>[r,i,`assistants`,`scheduled-tasks`,e],globalScheduledTasks:(e=t())=>[e,`scheduled-tasks`]},U=async(e,t={})=>{let n=await r(e,t),i=await n.json().catch(()=>null);if(!n.ok){let e=i&&typeof i==`object`&&`error`in i&&typeof i.error==`string`?i.error:`request_failed`,t=i&&typeof i==`object`&&`message`in i&&typeof i.message==`string`?i.message:void 0;throw new p(e,n.status,void 0,t)}return i},W=(e,t)=>({method:e,headers:{"Content-Type":`application/json`},body:t===void 0?void 0:JSON.stringify(t)}),G=(e,r)=>{if(t()!==e||n()!==r)throw new p(`runtime_stale`,409)},Oe=(e,t,r)=>{c.setQueryData(H.snapshot(r),n=>n&&{...n,assistants:n.assistants.map(n=>n.id!==e||n.sessionGeneration>t.sessionGeneration?n:{...n,sessionID:t.sessionID,sessionGeneration:t.sessionGeneration,effectiveWorkspacePath:t.directory})}),c.invalidateQueries({queryKey:H.snapshot(r)}),c.invalidateQueries({queryKey:[r,n(),`assistants`,`history`,e]})},ke=(e,t)=>{c.setQueryData(H.snapshot(t),t=>t&&{...t,assistants:t.assistants.some(t=>t.id===e.id)?t.assistants.map(t=>t.id===e.id?e:t):[...t.assistants,e]}),c.invalidateQueries({queryKey:H.snapshot(t)})},Ae=2500,je=15e3,Me=e=>!!e?.assistants.some(e=>e.working||e.activeContactTurn),Ne=(e,t={})=>{if(t.assistantID){let n=e?.assistants.find(e=>e.id===t.assistantID);return n?.working||n?.activeContactTurn?Ae:je}return Me(e)?Ae:je},K=(e=t())=>({queryKey:H.snapshot(e),queryFn:async({signal:e})=>ne(await U(`/api/yuri/assistants/snapshot`,{signal:e})),staleTime:0,retry:2,refetchInterval:e=>Ne(e.state.data),refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0}),q=new Map,J=e=>{let r=q.get(e);if(r)r.count+=1;else{let r=n(),i=!1,a=!1,o=!1,l=()=>!i&&t()===e&&n()===r,u=async()=>{if(o=!0,!a){a=!0;try{do o=!1,c.getQueryCache().find({queryKey:H.snapshot(e),exact:!0})?.state.fetchStatus===`fetching`&&(o=!0),await c.invalidateQueries({queryKey:H.snapshot(e),exact:!0},{cancelRefetch:!1});while(o&&l())}finally{a=!1}}},d=s(t=>{if(!l())return;let n=c.getQueryData(H.snapshot(e));(t.type===`event-stream-ready`||t.type===`contact-turn-start`||t.type===`contact-turn-end`||t.type===`assistants-changed`&&(!n||t.revision>n.revision))&&u()});q.set(e,{count:1,dispose:()=>{i=!0,d()}})}return()=>{let t=q.get(e);t&&--t.count===0&&(t.dispose(),q.delete(e))}},Pe=e=>{let n=(0,f.c)(7),r,i,a;n[0]===Symbol.for(`react.memo_cache_sentinel`)?(a=t(),i=o,r=K(a),n[0]=r,n[1]=i,n[2]=a):(r=n[0],i=n[1],a=n[2]);let s;n[3]===e?s=n[4]:(s={...r,select:e},n[3]=e,n[4]=s);let c=i(s),l,u;return n[5]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>J(a),u=[a],n[5]=l,n[6]=u):(l=n[5],u=n[6]),d.useEffect(l,u),c},Fe=e=>e.enabled?e.assistants.reduce((e,t)=>e+(t.unreadCount??0),0):0,Ie=()=>{let e=(0,f.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=o,r={...K(i),select:Fe},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),s,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>J(i),c=[i],e[3]=s,e[4]=c):(s=e[3],c=e[4]),d.useEffect(s,c),a.data??0},Le=e=>e.enabled&&Me(e),Re=()=>{let e=(0,f.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=o,r={...K(i),select:Le},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),s,c;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(s=()=>J(i),c=[i],e[3]=s,e[4]=c):(s=e[3],c=e[4]),d.useEffect(s,c),a.data??!1},ze=(e,t={})=>{let n=new URLSearchParams;return n.set(`limit`,String(t.limit??20)),t.before&&n.set(`before`,t.before),t.messageID&&n.set(`messageID`,t.messageID),`/api/yuri/assistants/${encodeURIComponent(e)}/contact/messages?${n}`},Y=async(e,t,n)=>oe(await U(ze(e,t),n?{signal:n}:{})),Be=(e,t)=>e.generation===t.generation&&e.revision===t.revision&&e.olderCursor===t.olderCursor&&e.olderComplete===t.olderComplete&&e.hasMessageGap===t.hasMessageGap&&e.gapCursor===t.gapCursor&&e.messages===t.messages&&e.liveWindowIDs===t.liveWindowIDs&&e.gapRequestIDs===t.gapRequestIDs&&e.gapTargetIDs===t.gapTargetIDs,X=new Map,Z=new Map,Q=e=>e.join(``),Ve=async(e,t,n,r,i)=>{let a=Q(t),o=Z.get(a);if(o)return o;let s=(async()=>{let a=c.getQueryData(t)??n,o=0,s=!1,l=!1,u=a.gapRequestIDs?[...a.gapRequestIDs]:null,d=a.gapCursor;for(;a.hasMessageGap&&a.gapCursor&&o<5&&!i?.aborted;){G(r.transport,r.runtimeGeneration),o+=1;let n=a.gapCursor;try{let o=await Y(e,{limit:20,before:n},i);G(r.transport,r.runtimeGeneration);let l=c.getQueryData(t)??a;if(o.generation!==l.generation){a=l;break}let f=!u||!!(l.hasMessageGap&&l.gapRequestIDs&&l.gapRequestIDs.length===u.length&&l.gapRequestIDs.every((e,t)=>e===u[t]));if(a=De(l,o,u?{requestIDs:u,cursor:d}:void 0),c.setQueryData(t,a),!f)break;if(!a.hasMessageGap){s=!0;break}if(a.gapCursor&&a.gapCursor!==n)s=!0;else break}catch(e){if(i?.aborted||m(e))break;l=!0,a=c.getQueryData(t)??a;break}}return{view:c.getQueryData(t)??a,failed:l,progressed:s}})();Z.set(a,s);try{return await s}finally{Z.get(a)===s&&Z.delete(a)}},He=(e,r=t(),i=n(),a={})=>({queryKey:H.contact(e,r,i),queryFn:async({signal:t})=>{G(r,i),await l(),G(r,i);let n=H.contact(e,r,i),a=c.getQueryData(n),o=await Y(e,{limit:20},t);G(r,i);let s=Te(c.getQueryData(n)??a??null,o);c.setQueryData(n,s);let u=Q(n);if(s.hasMessageGap&&s.gapCursor){X.delete(u);let a=await Ve(e,n,s,{transport:r,runtimeGeneration:i},t);s=a.view,(a.failed||a.view.hasMessageGap&&!a.progressed)&&a.view.gapCursor&&X.set(u,a.view.gapCursor)}else X.delete(u);G(r,i);let d=c.getQueryData(n)??s;return a&&Be(a,d)?a:d},retry:2,staleTime:0,refetchInterval:()=>a.reconcileInForeground?Ne(c.getQueryData(H.snapshot(r)),{assistantID:e}):!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:!0,refetchOnReconnect:!0,structuralSharing:!0}),Ue=(e,r=!0)=>{let i=t(),a=n(),[l,u]=d.useState(!1),[f,p]=d.useState(null),[h,g]=d.useState(!1),_=d.useRef(null),v=d.useRef(null),y=d.useRef(null),b=d.useRef(null),x=d.useRef({assistantID:e,transport:i,runtimeGeneration:a,enabled:r});x.current={assistantID:e,transport:i,runtimeGeneration:a,enabled:r};let S=o({...He(e,i,a,{reconcileInForeground:!0}),enabled:r&&!!e});d.useEffect(()=>{!r||!e||c.invalidateQueries({queryKey:H.snapshot(i),exact:!0},{cancelRefetch:!1})},[e,r,a,i]),d.useEffect(()=>s(n=>{t()===i&&(n.type===`assistants-changed`||n.type===`event-stream-ready`||n.type===`contact-turn-end`)&&(n.type===`contact-turn-end`&&`assistantID`in n&&n.assistantID!==e||c.invalidateQueries({queryKey:H.contact(e,i,a),exact:!0}))}),[e,a,i]),d.useEffect(()=>{let t=Q(H.contact(e,i,a));return()=>{y.current?.abort(),b.current?.abort(),y.current=null,b.current=null,_.current=null,v.current=null,X.delete(t)}},[e,i,a,r]);let C=S.data,w=H.contact(e,i,a),T=async()=>{if(!e||!r)return;if(_.current)return _.current;let t=c.getQueryData(w)??C;if(!t||t.olderComplete||!t.olderCursor)return;p(null),u(!0);let n=new AbortController;b.current?.abort(),b.current=n;let o={transport:i,runtimeGeneration:a,assistantID:e,cursor:t.olderCursor},s=(async()=>{try{G(o.transport,o.runtimeGeneration);let e=await Y(o.assistantID,{limit:20,before:o.cursor},n.signal);if(n.signal.aborted||(G(o.transport,o.runtimeGeneration),x.current.assistantID!==o.assistantID||x.current.transport!==o.transport||x.current.runtimeGeneration!==o.runtimeGeneration))return;let r=c.getQueryData(w)??t;if(e.generation!==r.generation)return;c.setQueryData(w,Ee(r,e))}catch(e){if(n.signal.aborted||m(e))return;let t=e instanceof Error?e:Error(String(e));throw p(t),t}finally{b.current===n&&(b.current=null),u(!1),_.current=null}})();return _.current=s,s},E=async(t=`explicit`)=>{if(!e||!r)return;if(v.current)return v.current;let n=c.getQueryData(w)??C;if(!n?.hasMessageGap||!n.gapCursor)return;let o=Q(w);if(t===`auto`&&X.get(o)===n.gapCursor)return;t===`explicit`&&X.delete(o),g(!0);let s=new AbortController;y.current?.abort(),y.current=s;let l={transport:i,runtimeGeneration:a,assistantID:e,cursor:n.gapCursor},u=(async()=>{try{G(l.transport,l.runtimeGeneration);let e=await Ve(l.assistantID,w,n,{transport:l.transport,runtimeGeneration:l.runtimeGeneration},s.signal);if(s.signal.aborted)return;if(G(l.transport,l.runtimeGeneration),e.failed||!e.progressed){e.view.gapCursor&&X.set(o,e.view.gapCursor);return}e.view.hasMessageGap||X.delete(o)}catch(e){if(s.signal.aborted||m(e))return;throw X.set(o,l.cursor),e}finally{y.current===s&&(y.current=null),g(!1),v.current=null}})();return v.current=u,u};return d.useEffect(()=>{if(!r||!e||!C?.hasMessageGap||!C.gapCursor||S.isFetching||h)return;let t=Q(w);X.get(t)!==C.gapCursor&&E(`auto`).catch(()=>void 0)},[r,e,C?.hasMessageGap,C?.gapCursor,S.isFetching,h,w]),{data:C?{messages:C.messages,generation:C.generation,revision:C.revision,nextCursor:C.olderCursor,complete:C.olderComplete}:void 0,status:S.status,fetchStatus:S.fetchStatus,isError:S.isError,isPending:S.isPending,isFetching:S.isFetching,isSuccess:S.isSuccess,error:S.error instanceof Error?S.error:S.error?Error(String(S.error)):null,refetch:()=>S.refetch(),fetchPreviousPage:T,hasPreviousPage:!!(C&&!C.olderComplete&&C.olderCursor),isFetchingPreviousPage:l,previousPageError:f,hasMessageGap:!!C?.hasMessageGap,isFillingMessageGap:h,retryMessageGap:()=>E(`explicit`)}},We=async(e,r)=>{let i=t(),a=n();await l(),G(i,a);let o=await Y(e,{messageID:r,limit:1});if(G(i,a),!o.messages.some(e=>e.messageID===r&&e.role===`user`))return null;c.invalidateQueries({queryKey:H.contact(e,i,a),exact:!0}),c.invalidateQueries({queryKey:H.snapshot(i),exact:!0});let s=c.getQueryData(H.snapshot(i));return{admitted:!0,messageID:r,revision:o.revision??s?.revision??null}},Ge=(e,r=t(),i=n())=>({queryKey:H.scheduledTasks(e,r,i),queryFn:async({signal:t})=>{G(r,i);let n=se(await U(`/api/yuri/assistants/${encodeURIComponent(e)}/scheduled-tasks`,{signal:t}));return G(r,i),n},refetchOnMount:`always`,retry:(e,t)=>!(t instanceof p&&t.status===404)&&e<2}),Ke=(e,r)=>{let i=(0,f.c)(6),a=r===void 0||r,s,c;if(i[0]!==e){let r=t(),a=n();c=o,s=Ge(e,r,a),i[0]=e,i[1]=s,i[2]=c}else s=i[1],c=i[2];let l=a&&!!e,u;return i[3]!==s||i[4]!==l?(u={...s,enabled:l},i[3]=s,i[4]=l,i[5]=u):u=i[5],c(u)},$=(e=t())=>({queryKey:H.globalScheduledTasks(e),queryFn:me,refetchOnMount:`always`}),qe=e=>{let t=(0,f.c)(3),n=e===void 0||e,r;t[0]===Symbol.for(`react.memo_cache_sentinel`)?(r=$(),t[0]=r):r=t[0];let i;return t[1]===n?i=t[2]:(i={...r,enabled:n},t[1]=n,t[2]=i),o(i)},Je=e=>e.tasks.some(({task:e})=>e.state.lastStatus===`running`),Ye=()=>{let e=(0,f.c)(5),n,r,i;e[0]===Symbol.for(`react.memo_cache_sentinel`)?(i=t(),n=o,r={...$(i),select:Je,staleTime:0,refetchInterval:mt,refetchIntervalInBackground:!1},e[0]=n,e[1]=r,e[2]=i):(n=e[0],r=e[1],i=e[2]);let a=n(r),l,u;return e[3]===Symbol.for(`react.memo_cache_sentinel`)?(l=()=>s(e=>{t()===i&&(e.type===`scheduled-task-ran`||e.type===`event-stream-ready`)&&c.invalidateQueries({queryKey:$(i).queryKey,exact:!0})}),u=[i],e[3]=l,e[4]=u):(l=e[3],u=e[4]),d.useEffect(l,u),a.data===!0},Xe=(e,r=t())=>{c.invalidateQueries({queryKey:[r,n(),`assistants`,`contact`,e]})},Ze=(e=t())=>({queryKey:H.capability(e),queryFn:()=>dt(),retry:!1}),Qe=()=>{let e=(0,f.c)(1),t;return e[0]===Symbol.for(`react.memo_cache_sentinel`)?(t=Ze(),e[0]=t):t=e[0],o(t)},$e=(e=c,n=t())=>e.getQueryData(H.snapshot(n)),et=(e=c,n=t())=>e.fetchQuery(K(n)),tt=async(e=c)=>{let r=t(),i=n();await e.invalidateQueries({queryKey:H.snapshot(r),exact:!0}),G(r,i);let a=await e.fetchQuery(K(r));return G(r,i),a},nt=15e3,rt=e=>{throw e instanceof p?e:m(e)?new p(`admission_timeout`,408):e},it=async(e,r,i)=>{let a=t(),o=n(),s=typeof i==`string`?[{type:`text`,text:i}]:Array.isArray(i.parts)&&i.parts.length>0?i.parts:[{type:`text`,text:i.text??``}],c=AbortSignal.timeout(nt);try{let t=ie(await U(`/api/yuri/assistants/${encodeURIComponent(e)}/messages`,{...W(`POST`,{messageID:r,parts:s,language:u.getState().locale}),signal:c}));return G(a,o),Oe(e,t.binding,a),Xe(e,a),t}catch(e){return rt(e)}},at=async(e,r,i,a,o)=>{let s=t(),c=n(),l=A(await U(`/api/yuri/assistants/${encodeURIComponent(e)}/share`,W(`POST`,{operationID:r,payload:{messageID:i,parts:a,source:o}})));return G(s,c),l},ot=async(e,r=t(),i=n())=>{G(r,i);let a=A(await U(`/api/yuri/assistants/share-operations/${encodeURIComponent(e)}`));return G(r,i),a},st=async(e,r=t(),i=n())=>{let a=e;for(let e=0;e<60&&(a.state===`running`||a.state===`submitting`);e+=1)G(r,i),await new Promise(e=>setTimeout(e,750)),a=await ot(a.operationID,r,i);if(G(r,i),a.state===`completed`)return a;throw a.state===`failed`?new h(a.errorCode??`share_failed`,400,a):new h(`share_unresolved`,408,a)},ct=async e=>{let n=t(),r=k(await U(`/api/yuri/assistants`,W(`POST`,{...e,language:u.getState().locale})));return ke(r,n),r},lt=async(e,r)=>{let i=t(),a=n(),o=k(await U(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,W(`PATCH`,{...r,expectedRevision:e.revision})));return G(i,a),r.pinned===void 0?ke(o,i):(await c.cancelQueries({queryKey:H.snapshot(i),exact:!0}),G(i,a),await c.fetchQuery(K(i)),G(i,a)),o},ut=async e=>{await U(`/api/yuri/assistants/${encodeURIComponent(e.id)}`,W(`DELETE`,{expectedRevision:e.revision})),await c.invalidateQueries({queryKey:H.snapshot(t())})},dt=async()=>w(await U(`/api/yuri/assistants/capability`)),ft=async(e,r)=>{let i=t(),a=n(),o=O(r);try{let t=te(await U(`/api/yuri/assistants/${encodeURIComponent(e)}/contact/read`,{...W(`POST`,o),signal:AbortSignal.timeout(15e3)}));if(G(i,a),t.assistantID!==e)throw new p(`invalid_assistant_read_response`,200);return t}finally{t()===i&&n()===a&&c.invalidateQueries({queryKey:H.snapshot(i),exact:!0})}},pt=async e=>{let r=e.assistants.filter(e=>(e.unreadCount??0)>0&&e.readTip).map(e=>({id:e.id,position:{...e.readTip}})),i=t(),a=n(),o=[];for(let e=0;e<r.length;e+=4)o.push(...await Promise.allSettled(r.slice(e,e+4).map(async e=>(G(i,a),ft(e.id,e.position)))));return{failed:o.filter(e=>e.status===`rejected`).length}};function mt(e){return e.state.data&&Je(e.state.data)?2500:15e3}export{p as A,ye as C,pe as D,me as E,m as M,_e as O,st as S,ge as T,Pe as _,et as a,qe as b,pt as c,it as d,at as f,Ke as g,Ue as h,ut as i,h as j,he as k,ft as l,Qe as m,We as n,dt as o,lt as p,ct as r,tt as s,He as t,$e as u,Ie as v,ve as w,Ye as x,Re as y};
@@ -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-QcYZg8_d.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{i as o,r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{Yi as c}from"./ui-z2JsXLmb.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-QcYZg8_d.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{i as o,r as s}from"./vendor-reactuses-core-DjKFMfz7.js";import{Yi as c}from"./ui-DLZtbTLJ.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-b90cIxfC.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-BXjMc92F.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"./rolldown-runtime-hePW80VL.js";import{ot as e,st as t}from"./vendor-base-ui-wXsskyKm.js";import{n}from"./vendor-react-BkccXcWz.js";import{no as r}from"./ui-z2JsXLmb.js";var i=n();t();var a=e();function o(e){let t=(0,i.c)(8),n,o;t[0]===e?(n=t[1],o=t[2]):({className:n,...o}=e,t[0]=e,t[1]=n,t[2]=o);let s;t[3]===n?s=t[4]:(s=r(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-none`,n),t[3]=n,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,a.jsx)(`div`,{"data-slot":`card`,className:s,...o}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function s(e){let t=(0,i.c)(8),n,o;t[0]===e?(n=t[1],o=t[2]):({className:n,...o}=e,t[0]=e,t[1]=n,t[2]=o);let s;t[3]===n?s=t[4]:(s=r(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,n),t[3]=n,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,a.jsx)(`div`,{"data-slot":`card-header`,className:s,...o}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function c(e){let t=(0,i.c)(8),n,o;t[0]===e?(n=t[1],o=t[2]):({className:n,...o}=e,t[0]=e,t[1]=n,t[2]=o);let s;t[3]===n?s=t[4]:(s=r(`leading-none font-semibold`,n),t[3]=n,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,a.jsx)(`div`,{"data-slot":`card-title`,className:s,...o}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function l(e){let t=(0,i.c)(8),n,o;t[0]===e?(n=t[1],o=t[2]):({className:n,...o}=e,t[0]=e,t[1]=n,t[2]=o);let s;t[3]===n?s=t[4]:(s=r(`px-6`,n),t[3]=n,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,a.jsx)(`div`,{"data-slot":`card-content`,className:s,...o}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}export{c as i,l as n,s as r,o as t};
1
+ import"./rolldown-runtime-hePW80VL.js";import{ot as e,st as t}from"./vendor-base-ui-wXsskyKm.js";import{n}from"./vendor-react-BkccXcWz.js";import{no as r}from"./ui-DLZtbTLJ.js";var i=n();t();var a=e();function o(e){let t=(0,i.c)(8),n,o;t[0]===e?(n=t[1],o=t[2]):({className:n,...o}=e,t[0]=e,t[1]=n,t[2]=o);let s;t[3]===n?s=t[4]:(s=r(`bg-card text-card-foreground flex flex-col gap-6 rounded-xl border py-6 shadow-none`,n),t[3]=n,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,a.jsx)(`div`,{"data-slot":`card`,className:s,...o}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function s(e){let t=(0,i.c)(8),n,o;t[0]===e?(n=t[1],o=t[2]):({className:n,...o}=e,t[0]=e,t[1]=n,t[2]=o);let s;t[3]===n?s=t[4]:(s=r(`@container/card-header grid auto-rows-min grid-rows-[auto_auto] items-start gap-1.5 px-6 has-data-[slot=card-action]:grid-cols-[1fr_auto] [.border-b]:pb-6`,n),t[3]=n,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,a.jsx)(`div`,{"data-slot":`card-header`,className:s,...o}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function c(e){let t=(0,i.c)(8),n,o;t[0]===e?(n=t[1],o=t[2]):({className:n,...o}=e,t[0]=e,t[1]=n,t[2]=o);let s;t[3]===n?s=t[4]:(s=r(`leading-none font-semibold`,n),t[3]=n,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,a.jsx)(`div`,{"data-slot":`card-title`,className:s,...o}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}function l(e){let t=(0,i.c)(8),n,o;t[0]===e?(n=t[1],o=t[2]):({className:n,...o}=e,t[0]=e,t[1]=n,t[2]=o);let s;t[3]===n?s=t[4]:(s=r(`px-6`,n),t[3]=n,t[4]=s);let c;return t[5]!==o||t[6]!==s?(c=(0,a.jsx)(`div`,{"data-slot":`card-content`,className:s,...o}),t[5]=o,t[6]=s,t[7]=c):c=t[7],c}export{c as i,l as n,s as r,o as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./platform-CNdx57HN.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{Yn as u,no as d,t as f}from"./ui-z2JsXLmb.js";import{n as p}from"./Icon-CMNOrIAp.js";import{t as m}from"./i18n-BU8XOKjS.js";import{t as h}from"./MobileResizableSheet-Ddf0s-Dp.js";import{o as g,t as _}from"./vendor-framer-motion-D5NyyC73.js";import{t as v}from"./textarea-DXs25Z8k.js";import{t as y}from"./LoadingImage-U4z75PsW.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 f;t[6]===s?f=t[7]:(f=s(`mobile.surface.closeAria`),t[6]=s,t[7]=f);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)(p,{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)(p,{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]!==f||t[36]!==g?(k=(0,D.jsx)(h,{id:n,open:r,onOpenChange:i,title:l,ariaLabel:d,closeAriaLabel:f,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]=f,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)(p,{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),f.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)(p,{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)(p,{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)(p,{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)(p,{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)(p,{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-CNdx57HN.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{Yn as u,no as d,t as f}from"./ui-DLZtbTLJ.js";import{n as p}from"./Icon-DrO1MlqW.js";import{t as m}from"./i18n-BU8XOKjS.js";import{t as h}from"./MobileResizableSheet-D5HcC4ME.js";import{o as g,t as _}from"./vendor-framer-motion-D5NyyC73.js";import{t as v}from"./textarea-D-k4tYDG.js";import{t as y}from"./LoadingImage-k1x9Kvl1.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 f;t[6]===s?f=t[7]:(f=s(`mobile.surface.closeAria`),t[6]=s,t[7]=f);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)(p,{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)(p,{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]!==f||t[36]!==g?(k=(0,D.jsx)(h,{id:n,open:r,onOpenChange:i,title:l,ariaLabel:d,closeAriaLabel:f,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]=f,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)(p,{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),f.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)(p,{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)(p,{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)(p,{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)(p,{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)(p,{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 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{T as t,ot as n,st as r,w as i}from"./vendor-base-ui-wXsskyKm.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{no as o}from"./ui-z2JsXLmb.js";import{n as s}from"./Icon-CMNOrIAp.js";var c=a(),l=e(r(),1),u=n(),d=l.memo(function(e){let n=(0,c.c)(20),{checked:r,onChange:a,disabled:l,indeterminate:d,ariaLabel:f,className:p,iconClassName:m}=e,h=l!==void 0&&l,g=r||d,_;n[0]===a?_=n[1]:(_=e=>a(!!e),n[0]=a,n[1]=_);let v=g?`border-[color:color-mix(in_srgb,var(--primary-base)_65%,var(--interactive-border))] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[color:color-mix(in_srgb,var(--primary-base)_75%,var(--interactive-border))]`:`border-[var(--interactive-border)] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[var(--interactive-border)]`,y;n[2]!==p||n[3]!==v?(y=o(`group/checkbox relative flex shrink-0 self-center items-center justify-center rounded-[4px] border outline-none`,`h-[14px] w-[14px] min-h-[14px] min-w-[14px]`,`transition-[background-color,border-color,box-shadow] duration-200 ease-out`,v,`focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-transparent`,`disabled:cursor-not-allowed disabled:opacity-50`,p),n[2]=p,n[3]=v,n[4]=y):y=n[4];let b;n[5]===m?b=n[6]:(b=o(`flex items-center justify-center text-[var(--primary-base)]`,`data-[unchecked]:hidden`,m),n[5]=m,n[6]=b);let x;n[7]===d?x=n[8]:(x=d?(0,u.jsx)(s,{name:`subtract`,className:o(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}):(0,u.jsx)(s,{name:`check`,className:o(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}),n[7]=d,n[8]=x);let S;n[9]!==b||n[10]!==x?(S=(0,u.jsx)(i,{keepMounted:!0,className:b,children:x}),n[9]=b,n[10]=x,n[11]=S):S=n[11];let C;return n[12]!==f||n[13]!==r||n[14]!==h||n[15]!==d||n[16]!==_||n[17]!==y||n[18]!==S?(C=(0,u.jsx)(t,{checked:r,onCheckedChange:_,disabled:h,indeterminate:d,"aria-label":f,className:y,children:S}),n[12]=f,n[13]=r,n[14]=h,n[15]=d,n[16]=_,n[17]=y,n[18]=S,n[19]=C):C=n[19],C});export{d as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{T as t,ot as n,st as r,w as i}from"./vendor-base-ui-wXsskyKm.js";import{n as a}from"./vendor-react-BkccXcWz.js";import{no as o}from"./ui-DLZtbTLJ.js";import{n as s}from"./Icon-DrO1MlqW.js";var c=a(),l=e(r(),1),u=n(),d=l.memo(function(e){let n=(0,c.c)(20),{checked:r,onChange:a,disabled:l,indeterminate:d,ariaLabel:f,className:p,iconClassName:m}=e,h=l!==void 0&&l,g=r||d,_;n[0]===a?_=n[1]:(_=e=>a(!!e),n[0]=a,n[1]=_);let v=g?`border-[color:color-mix(in_srgb,var(--primary-base)_65%,var(--interactive-border))] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[color:color-mix(in_srgb,var(--primary-base)_75%,var(--interactive-border))]`:`border-[var(--interactive-border)] bg-transparent shadow-none hover:bg-[var(--interactive-hover)] hover:border-[var(--interactive-border)]`,y;n[2]!==p||n[3]!==v?(y=o(`group/checkbox relative flex shrink-0 self-center items-center justify-center rounded-[4px] border outline-none`,`h-[14px] w-[14px] min-h-[14px] min-w-[14px]`,`transition-[background-color,border-color,box-shadow] duration-200 ease-out`,v,`focus-visible:ring-2 focus-visible:ring-[var(--interactive-focus-ring)] focus-visible:ring-offset-1 focus-visible:ring-offset-transparent`,`disabled:cursor-not-allowed disabled:opacity-50`,p),n[2]=p,n[3]=v,n[4]=y):y=n[4];let b;n[5]===m?b=n[6]:(b=o(`flex items-center justify-center text-[var(--primary-base)]`,`data-[unchecked]:hidden`,m),n[5]=m,n[6]=b);let x;n[7]===d?x=n[8]:(x=d?(0,u.jsx)(s,{name:`subtract`,className:o(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}):(0,u.jsx)(s,{name:`check`,className:o(`h-[10px] w-[10px] min-h-[10px] min-w-[10px]`,`text-[var(--primary-base)]`)}),n[7]=d,n[8]=x);let S;n[9]!==b||n[10]!==x?(S=(0,u.jsx)(i,{keepMounted:!0,className:b,children:x}),n[9]=b,n[10]=x,n[11]=S):S=n[11];let C;return n[12]!==f||n[13]!==r||n[14]!==h||n[15]!==d||n[16]!==_||n[17]!==y||n[18]!==S?(C=(0,u.jsx)(t,{checked:r,onCheckedChange:_,disabled:h,indeterminate:d,"aria-label":f,className:y,children:S}),n[12]=f,n[13]=r,n[14]=h,n[15]=d,n[16]=_,n[17]=y,n[18]=S,n[19]=C):C=n[19],C});export{d as t};